[Scummvm-git-logs] scummvm master -> a46cc8597cdc2ab2aca146ed79c0fcf3f4df5617

sev- sev at scummvm.org
Sat Sep 10 17:04:26 CEST 2016


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

Summary:
96cc074ea0 DM: Create engine and detection with dummy data
5ae7d3a84b DM: Add detection for Amiga v2.0 English
055e789d04 DM: Create DisplayMan, add support parsing IMG0 files
cdf377f7a7 DM: Add support for Dungeon.dat uncompression
b7987d84c1 DM: Fix memory leak in dm.cpp and gfx.cpp
66c55db9f0 DM: Fix typos and whitespace
4a8b34e993 DM: Add the original palettes, edit palette loading accordingly
77cd7df08d DM: Add support for drawing portions of bitmaps
cb2bb82b32 DM: Add support for transparency in blitting
18ff2e9940 DM: Refactor DisplayMan::DrawFrame and Frame POD
c725fdec9e DM: Add horizontal and vertical bitmap flipping
64371787e2 DM: Rewrite blitting methods, revise FRAME POD
9823845c99 DM: Fix constant and global variable names according to coding conventions
98a4379244 DM: Delete TOBE2 macro, use READ_BE_UINT16 instead
a8434fc165 DM: Add support for viewports with blitting
4f9182507a DM: Implement Dungeon.dat file parsing, add relevant structures
68f13e8462 DM: Implement F0173_DUNGEON_SetCurrentMap
8172a07d1a DM: Add square query in DungeonMan
853b87f19e DM: Add drawDungeon test code
bf78e63d2e DM: Add missing cross-references in gfx.h
16199b4091 DM: Add loadWallSet(..) and loadFloorSet(..)
af6e6ca468 DM: Refactor Frame POD
05fbf0b358 DM: Add dungeonman.o to module.mk, fix _bitmaps memory leak
f39b22f321 DM: Refactor Thing POD
253730787d DM: Finish implementing ornament masks in DungeonMan::getSquare
6d5f8e2757 DM: Add wrapper class around raw map bytes
a8c82c1e94 DM: Add some draw dungeon dependencies
73a7cba589 DM: Fix bug with uninitialized _currMap.index and file loading order
f21a9197a6 DM: Fix file loading dependancy
2e9483cf2e DM: Fix dungeon.dat file loading
909ec36edf DM: Fix loading map data in loadDungeonFile(..)
7ddd96bc60 DM: Fix destructor and allocation issues in DungeonMan and DisplayMan
d49c081785 DM: Fix loadDungeonFile(..) zero sized array allocation
e3136f4247 DM: Add viewsquare enum
134b482e60 DM: Add flipped wall bitmaps
d9bb44eeb9 DM: Add the partial drawing of dungeonwalls
9655066a06 DM: getSquareAspect(..) is complete
807fda8a9a DM: Add wall flipping display
f591cbbcf3 DM: Add dummy movement code for testing
3ada56f6b1 DM: Add stairs display
082e3fb37c DM: Add global variable dependencies for isDrawnWallOrnAnAlcove
3a85c56581 DM: Add decodeText dependencies
02c0487b57 DM: Add decodeText function
ab1e17257c DM: Add isDrawnWallOrnAnAlcove function
b9935dfddc DM: Add blitToBitmapShrinkWithPalChange
24c7c1e905 DM: Fix some compilation errors under MSVC9
35677f1c82 DM: Fix Frame initializations
442d417140 DM: Fix some warnings
bdc57056cd DM: Move some structs to header in gfx
6ffca3a7db DM: Forgot to commit these lines earlier
3ca7622a6c DM: Fix wrong MemoryReadStream size when loading dungeon.dat
ad8fbaa118 DM: Add event manager
de3bb231d7 DM: Add dummy cursor display
251768b883 DM: Add commands
28874dee1f DM: Add global static MouseInput arrays
6b31b1bbc3 DM: Add KeyboardInput struct
bcfe176df5 DM: Add mouseclick processing
98c79f89bf DM: Add mouse input processing and display for movement arrows
9b57cdb8dd DM: Add champion POD and it's enums
42567b744d DM: Fix compilation on MSVC9
75db418e64 DM: Fix a couple of warnings
59af06fd82 DM: Fix some CppCheck warnings
3ff3512c64 DM: Add initialization related to F0435_STARTEND_LoadGame_CPSF
332a515d2c DM: Add getIndexInCell function in ChampionMan
e744d8a427 DM: Add F0279_CHAMPION_GetDecodedValue, M27_PORTRAIT_X, M28_PORTRAIT_Y
793ebd32a3 DM: Add WEAPON_INFO and related enums
ef95c50fbb DM: Add gWeaponInfo
21be32bb17 DM: Add ArmourInfo and realted enums
5874a7fb56 DM: Add G0239_as_Graphic559_ArmourInfo
c96f24d8fe DM: Add G0241_auc_Graphic559_JunkInfo
d6e90e8a90 DM: Add F0140_DUNGEON_GetObjectWeight and types for Potions, Armour, Weapons and Junk
40e4cceb3f DM: Add F0368_COMMAND_SetLeader, G0411_i_LeaderIndex, G0299_ui_CandidateChampionOrdinal
a2328b9eb2 DM: Add G0508_B_RefreshActionArea
7a25591999 DM: Rearrange main parts to better align with the original
ea33eb8c87 DM: Some renaming
9ad057a486 DM: Some more renaming, remove extra semi-column
bcbb3e447f DM: Some more renaming
78d8a8d3c8 DM: Add several global variables, add code to F0462_START_StartGame_CPSF
43cedc4c78 DM: Add F0003_MAIN_ProcessNewPartyMap_CPSE
bcf8e07f28 DM: Add IconIndex enum, F0278_CHAMPION_ResetDataToStartGame, related global variables
cc6ff27dd3 DM: Move F0463_START_InitializeGame_CPSADEF, F0002_MAIN_GameLoop_CPSDF in DMEngine to private
6b833550b0 DM: Add F0388_MENUS_ClearActingChampion
7dd90c3daf DM: Add F0141_DUNGEON_GetObjectInfoIndex, getType for Container
c97a4560b2 DM: Change some comments to warnings
16d65d476d DM: Add ObjectInfo
b7c225b4d4 DM: Add G0237_as_Graphic559_ObjectInfo
9d7f35cc82 DM: Add ObjectMan
749ffcc3f0 DM: Add F0032_OBJECT_GetType
ceed621a51 DM: Fix missing else in DMEngine::startGame()
359ef01a33 DM: Add G0029_auc_Graphic562_ChargeCountToTorchType
23c1acff19 DM: Add ObjectMan to DMEngine
29d832b353 DM: Add F0033_OBJECT_GetIconIndex and several getters for object types
472778a06e DM: Replace WeaponClass enum with #defines
0597fdc658 DM: Add D24_FillScreenBox
592cd05575 DM: Add G0026_ai_Graphic562_IconGraphicFirstIconIndex
6e041819b4 DM: Add F0036_OBJECT_ExtractIconFromBitmap, K0077_ai_IconGraphicHeight, ObjectIcon indices
d9ed599de6 DM: Add G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
7782754d68 DM: Add F0386_MENUS_DrawActionIcon
f4f4c867a4 DM: Add InventoryMan, G0041_s_Graphic562_Box_ViewportFloppyZzzCross
e64e352815 DM: Add G0326_B_RefreshMousePointerInMainLoop, G0598_B_MousePointerBitmapUpdated
e9a4e818f2 DM: Add F0355_INVENTORY_Toggle_CPSE
11e779e0a4 DM: Add F0456_START_DrawDisabledMenus
3342757569 DM: Add G0234_ai_Graphic559_DirectionToStepNorthCount, G0233_ai_Graphic559_DirectionToStepEastCount, G0047_s_Graphic562_
c87e3ba048 DM: Fix compilation, fix typos and some comment alignement
61500b3dc8 DM: Add F0280_CHAMPION_AddCandidateChampionToParty
cfebcea041 DM: Add dummy test code for chmpion selection
0e0fb97632 DM: Some renaming
2a2a9a53b0 DM: Add champion reset, fix ChampionMan::addCandidateChampionToPart while loop condition
051b1d9adf DM: Remove demo code from ToggleInventory,  add dummy code setting _inventoryChampionOrdinal, fix error in InventoryTogg
3fe7213947 DM: Add PARTY and SCENT types
35b5f03b26 DM: Add G0048_s_Graphic562_Box_Mouth, G0049_s_Graphic562_Box_Eye, G0054_ai_Graphic562_Box_ChampionIcons, G0046_auc_Graph
aa269b9f5e DM: Add blitToScreen using Box
d5e4448ec6 DM: Add F0354_INVENTORY_DrawStatusBoxPortrait
ef2411f7af DM: Add F0287_CHAMPION_DrawBarGraph
493c8ed4bc DM: Add F0306_CHAMPION_GetStaminaAdjustedValue
3134891f6c DM: Add F0309_CHAMPION_GetMaximumLoad
b068beb33f DM: Add G0032_s_Graphic562_Box_Panel, G0035_s_Graphic562_Box_Food, G0036_s_Graphic562_Box_Water, G0037_s_Graphic562_Box_
3385a3dd5c DM: Add F0343_INVENTORY_DrawPanel_HorizontalBar
8c007d02fa DM: Add F0344_INVENTORY_DrawPanel_FoodOrWaterBar
6eea379cc5 DM: Add  F0345_INVENTORY_DrawPanel_FoodWaterPoisoned
b8c35406ac DM: Some renaming
e59be236e1 DM: Move junkInfo to getObjectWeight, make it static and const.
038056ed0f DM: Add G0423_i_InventoryChampionOrdinal and related enum, PanelContent
2c669d4119 DM: Add F0347_INVENTORY_DrawPanel
c986a71bea DM: Add F0292_CHAMPION_DrawState, G0407_s_Party,  M26_CHAMPION_ICON_INDEX, several graphic indices, fix missing kPanelRe
afd844b6de DM: Add missing F0292_CHAMPION_DrawState functions, fix error in toggleInventory
4b83ebc0da DM: Add fix gDungeonViewport, some comments
485d5f94de DM: Fix box coordinates in drawChampionState
1639c2e887 DM: Fix several inclusive boundary errors with Box types
3a2677eecf DM: Add missing code setting champion mana in ChampionMan::addCandidateChampionToParty
0f04a0902b DM: Fix some GCC warnings
b97535ef69 DM: Fix some more GCC warnings
f1ef774a28 DM: Fix another GCC warning and a bug
f46a588164 DM: Silent two more GCC warnings
9538db0b61 Add: TextMan, font loading and basic text display
45419f971a DM: Add color setting to TextMan::printTextToBitmap
63d06a4011 DM: Fix code formatting
75f9721e1d DM: Silent some CppCheck warnings
2048539522 DM: Initialize some variables
9d7cfe5cd8 DM: Add several functions realted to text display
a72bfe712d DM: Fix link
0ad91dfe67 DM: Add missing explicit keyword
8ffd4a0bad DM: Add some default statements in switches, change the scope of namespace DM in gfx.cpp
2f6e8a8e64 DM: Add G0030_as_Graphic562_SlotBoxes, SLOT_BOX, F0038_OBJECT_DrawIconInSlotBox
94bd6db7a6 DM: Add  F0291_CHAMPION_DrawSlot, G0425_aT_ChestSlots and constructor to Viewport, swap some warnings for code
23e0dfcc28 DM: Add standard GPLv2 header
4b67e047ed DM: Add MovesensMan
18106aa967 DM: Add Cell enum,  F0275_SENSOR_IsTriggeredByClickOnWall
d40e328e51 DM: Add F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall
4044dfa364 DM: Add F0157_DUNGEON_GetSquareFirstThingData, F0377_COMMAND_ProcessType80_ClickInDungeonView
fab0510936 DM: Move gSlotBoxes to ObjectMan
45461a4908 DM: Fix compilation on GCC
c1abeffecc DM: Fix some GCC warnings
eddf2f494d DM: Add F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel
b820a36d3a DM: Add F0378_COMMAND_ProcessType81_ClickInPanel
c392f7e977 DM: Add F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived
dad087454c DM: Add missing load display in ChampionMan::drawChampionState
9c544a44f2 DM: Add renameChampion stub, fix wrong inputArray EventManager::commandProcess81ClickInPanel
d893075343 DM: Fix unused viewport in DisplayMan::clearScreenBox
12d359166c DM: Add F0387_MENUS_DrawActionArea
5893dc7c98 DM: Add F0393_MENUS_DrawSpellAreaControls
fc6837b964 DM: Add F0392_MENUS_BuildSpellAreaLine
72506aebba DM: Add MenuMan::setMagicCasterAndDrawSpellArea
bcd7c1d763 DM: Fix possible bug in MenuMan::setMagicCasterAndDrawSpellArea
84a9102205 DM: Initial TODOs
398b309a03 DM: Add F0163_DUNGEON_LinkThingToList
7ecd3333d7 DM: Fix and simplify commandProcessType80ClickInDungeonViewTouchFrontWall()
f00f5c19e7 DM: Add G0426_T_OpenChest, F0334_INVENTORY_CloseChest
d770ec0f61 DM: Reduce scope of a couple of variables, simplify a couple of lines
0d314b9bea DM: Fix a GCC warning, fix code alignment in hasPendingClick
5859ff8aaf DM: Remove extra semi-column
703fd8aca2 DM: Fix bug in getIconIndex
652b2c6f98 DM: Add F0340_INVENTORY_DrawPanel_ScrollTextLine
49aae8932b DM: Add F0341_INVENTORY_DrawPanel_Scroll
ebdcac5073 DM: Add F0333_INVENTORY_OpenAndDrawChest
d6af931ad7 DM: Add  F0303_CHAMPION_GetSkillLevel
17f2a7f2e6 DM: Add F0332_INVENTORY_DrawIconToViewport
cb9979fade DM: Add F0336_INVENTORY_DrawPanel_BuildObjectAttributesString
c40aca2d2d DM: Add F0335_INVENTORY_DrawPanel_ObjectDescriptionString
792f48858b DM: Add F0339_INVENTORY_DrawPanel_ArrowOrEye, G0033_s_Graphic562_Box_ArrowOrEye
1f73d771ce DM: F0342_INVENTORY_DrawPanel_Object, F0031_OBJECT_LoadNames
3442019d94 DM: Add F0299_CHAMPION_ApplyObjectModifiersToStatistics
ae6f2d711c DM: Add F0034_OBJECT_DrawLeaderHandObjectName
5ba83b8b4d DM: Add F0295_CHAMPION_HasObjectIconInSlotBoxChanged, F0039_OBJECT_GetIconIndexInSlotBox
d4ad444ecc DM: Add F0296_CHAMPION_DrawChangedObjectIcons
6daa5c572e DM: Add F0301_CHAMPION_AddObjectInSlot
e6c3389e53 DM: Continue F0460_START_InitializeGraphicData
36a29bbe86 DM: Reorder files in MK file
3f19bcdf6b DM: Add F0491_CACHE_IsDerivedBitmapInCache, F0492_CACHE_GetDerivedBitmap
57ca9afcff DM: Move two global arrays to DMEngine
bc583bf0d5 DM: Fix missing call to initArrays()
b3e1760bfb DM: Add dummy blitBoxFilledWithMaskedBitmap and DisplayMan::drawField
a09ff6a165 DM: Add F0114_DUNGEONVIEW_GetExplosionBitmap
f3d4b854b7 DM: Add F0142_DUNGEON_GetProjectileAspect
5bb19fd261 DM: Add GroupMan, Group, ActiveGroup,  F0196_GROUP_InitializeActiveGroups
4f394fc301 DM: Add F0145_DUNGEON_GetGroupCells
cd7363f8de DM: Add F0147_DUNGEON_GetGroupDirections
6d2d839d27 DM: Add creature masks/types, F0176_GROUP_GetCreatureOrdinalInCell
d312ac086d DM: Add dependencies for F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
bf4ae50e6b DM: Add F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
579b56d212 DM: Reversing several modifications and adding missing code warninings
e95470d189 DM: Fix errors in DisplayMan::isDerivedBitmapInCache
5f25c6aae2 DM: Add missing code to DisplayMan::drawSquareD3R (@F0117_DUNGEONVIEW_DrawSquareD3R)
e2300bd04c DM: Massive renaming in gfx.h
da317f14be DM: Massive renameing in gfx.cpp
71e4b5b2bc DM: Renaming in champion.c/h
a9cda9df7c DM: More renaming
ce45a71ba0 DM: More renaming
63ff1666d6 DM: More constant and global variable renaming
46b9b1100e DM: Refactor DungeonMan
683230207c DM: Refactor DisplayMan::_walsetBitmaps
c5f118079c DM: Renaming stuff
8c06b0afd0 DM: Add F0097_DUNGEONVIEW_DrawViewport
883370eb7d DM: Remove several blitting overloads
ce1c52bceb DM: Remove blitToScreen overloads
31b10d6d0d DM: Remove blitToBitmap overload
d69236e674 DM: Rename functions
ec0b26ce79 DM: Reorder blitting method parameters
c756d17556 DM: Reorder DisplayMan::D24_clearScrenBox parameters
f01a03e918 DM: Add default parameters to DipslayMan::f132_blitToBitmap
bd06132072 DM: Box objects are not expected to conatain inclusive boundaries, blitting and other methods adapted
d7b0413be6 DM: Reorder blitshrink parameters
cb345ff614 DM: Reorder fillBitmap parameters
816319c659 DM: Revert to using byteWidths where the original does so as well
01ed61e066 DM: Fix some comments
94c878143e DM: Add F0108_DUNGEONVIEW_DrawFloorOrnament
7fef7b8312 DM: Add paritial drawing of doors
411ad40ca4 DM: Add missing code to several display functions
c95b23317c DM: Add some missing code
f33b4f3877 DM: Fix some compilation errors using MSVC9
c74c4f362e DM: Make some arrays static and local
e02d165fce DM: Move g186_doorFrame_D1C to DisplayMan
723c96fffe DM: Clean up some initialization
0d4b09980e DM: Replace ChampionMan::f292_drawChampionState with original
92a3ccb4a7 DM: Replace InventoryMan::f355_toggleInventory with original
89473344d8 DM: Fix several bugs realted to dungeon thing management and item handling
0a0e79357d DM: Fix compilation using MSVC9
8504f944e0 DM: Fix style used for pointer casts
3447af80f8 DM: Some soft refactoring in champion.cpp
dce7465ad5 DM: Silent some more CppCheck warnings
2edabfae99 DM: Some rework in group.cpp
2c860f1069 DM: Some soft refactoring, in order to silent some CppCheck warnings
af42277a93 DM: Reduce some variable scopes, silent CppCheck warnings
9c4236d039 DM: Remove extra parenthesis
c8f6666480 DM: Remove some more extra parenthesis, remove a useless call to c_str()
9272b18329 DM: Fix typo in comment
1f73323113 DM: Add proper keyboard input handling
14bef5326a DM: Add warning with repeat parameter
9c79d02a1f DM: Add missing code to command move party
1baf135c2f DM: Add missing code to command turn party
9d1afe3022 DM: Fix broken display of the leftmost champion
8c7760bd61 DM: Add F0239_TIMELINE_ExtractFirstEvent
dd3f12c7d5 DM: Complete main gameloop
12f06fd1d9 DM: Add f219_processEvents48To49_projectile
953f7909fc DM: Add f241_timelineProcessEvent1_doorAnimation
cc5f1ab478 DM: Add f220_explosionProcessEvent25_explosion
12dff65535 DM: Add f242_timelineProcessEvent7_squareFakewall
d1f0281e9d DM: Add f243_timelineProcessEvent2_doorDestruction
ad11a4f48c DM: Add f244_timelineProcessEvent10_squareDoor
81a8c8cf74 DM: Clear some warnings
f6dea6c73e DM: Add f251_timelineProcessEvent9_squarePit
d77ffceff9 DM: Add f250_timelineProcessEvent8_squareTeleporter
536e9c1bb9 DM: Add f248_timelineProcessEvent6_squareWall
8ae94ec075 DM: Refactor f111 and f112
e8342f2d2a DM: Fix a bug in drawPanelObject, fix some casts formatting
9aa6c28fab DM: Add f245_timlineProcessEvent5_squareCorridor
278e0b6647 DM: Add f252_timelineProcessEvents60to61_moveGroup
3b917d35c4 DM: Add f246_timelineProcesEvent65_enableGroupGenerator
4818eaaf55 DM: Add f253_timelineProcessEvent11Part1_enableChampionAction
c62029211d DM: Add f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot
639fd36f38 DM: Add f254_timelineProcessEvent12_hideDamageReceived
f7e4486d84 DM: Add f257_timelineProcessEvent70_light
800100e2bc DM: Add f260_timelineRefreshAllChampionStatusBoxes
3e40cc46e3 DM: Add f255_timelineProcessEvent13_ViAltarRebirth
0f76448e57 DM: Fix up main loop
42cbf35b0b DM: Clean up f380_processCommandQueue, add _g318_waitForInputMaxVerticalBlankCount
4d3c9d99f1 DM: Add f367_commandProcessTypes12to27_clickInChampionStatusBox
0f107cead2 DM: Add f70_mouseProcessCommands125To128_clickOnChampionIcon
1e8dfd7bb6 DM: Add f370_commandProcessType100_clickInSpellArea
b4bebaa845 DM: Add f371_commandProcessType111To115_ClickInActionArea and it's dependencies
5602d07f96 DM: Fix Timeline _g370_events initialization
b092e74be9 DM: Fix broken ChampionMan::f303_getSkillLevel
75fe72b27c DM: Add input timeout and fix movement after throwing a projectile
3a654ff91e DM: Add ChampionMan::f320_applyAndDrawPendingDamageAndWounds()
3f01beea8a DM: Add ChampionMan::f331_applyTimeEffects
78cf0030e3 DM: Fix missing messages at the bottom of the screen
9f9ac99b31 DM: Fix broken damage display
665ea3beff DM: Fix champion bar graphs
d7c7f110c1 DM: Fix pressure plate on level 0
247b9210e1 DM: Some refactoring
ac1b49496d DM: Fix setting _g309_partyMapIndex when moving between levels
bd9fa3eb87 DM: Engine now correctly set's the activeGroupIndex of groups
11704d0c50 DM: Add savegame functions
aacecd6c06 DM: Add entrance processing
e824972245 DM: Fix activeGroup removal
aa92c3ba20 DM: Fix footprints everywhere
ee3973aa15 DM: Add code for loading the save files
0f02cc5b02 DM: Fix compilation using MSVC9
877b1b051b DM: Remove a broken character in the definition of f231_getMeleeActionDamage
33aac99bee DM: Reduce the scope of a couple of variables
185588f098 DM: Silent some CppCheck warnings in eventman.cpp
c15c5a16f4 DM: Remove broken characters in f231_getMeleeActionDamage body
2f3c9b7c78 DM: Remove variable redefinition in f337_setDungeonViewPalette, reduce some scopes
ebd672770a DM: Properly stub f064_SOUND_RequestPlay_CPSD
5418c2288b DM: Fix some more CppCheck warnings
5cef0e66be DM: Light refactoring and renaming of local variables in f328_isObjectThrown
9d5b3f53c8 DM: Fix a bug in f288_getStringFromInteger
a46d815617 DM: Refactor f299_applyModifiersToStatistics, remove a GOTO.
18ea37f5fb DM: Some renaming in f298_getObjectRemovedFromLeaderHand, refactor f312_getStrength
9d0541035b DM: Rename f325_decrementStamina, refactor f300_getObjectRemovedFromSlot and f325_decrementStamina
9b12ddd6a9 DM: Some refactoring in f321_addPendingDamageAndWounds_getDamage
eab5879ef5 DM: Get rid of a GOTO in f321_addPendingDamageAndWounds_getDamage
76667176f4 DM: Refactor f313_getWoundDefense
710464c5d2 DM: Refactor f307_getStatisticAdjustedAttack, f305_getThrowingStaminaCost and f330_disableAction
831eca5c42 DM: Refactor f304_addSkillExperience, change _g313_gameTime to int32
d5d41f4559 DM: Refactor f324_damageAll_getDamagedChampionCount, f286_getTargetChampionIndex, f311_getDexterity and f308_isLucky
af84d233d0 DM: Refactor f322_championPoison, f284_setPartyDirection, f316_deleteScent, f317_addScentStrength, f310_getMovementTicks
02c8f286e7 DM: Fix segfault with resume game
e8bdaee8bf DM: Add DialogMan
63fc9fb27d DM: Add f427_dialogDraw, f425_printCenteredChoice, f426_isMessageOnTwoLines
b174331e71 DM: refact f293_drawAllChampionStates, f283_viAltarRebirth, f327_isProjectileSpellCast and f326_championShootProjectile.
58d8235344 DM: Refactor f320_applyAndDrawPendingDamageAndWounds
cdbbc15e56 DM: Refactor f318_dropAllObjects, f319_championKill and f323_unpoison. Rename _moveSens
a21c677831 DM: Remove useless cast and the associated obsolete comment
e8e1a54cea DM: Rename mapTime in dm.cpp
e0219fd6f7 DM: Refactor f331_applyTimeEffects
42f7f17c09 DM: Fix compilation on MSVC9
afaaa4d58e DM: Use error() in f278_resetDataToStartGame
9fd7c56198 DM: Finish f433_processCommand140_saveGame
715ef2d404 DM: Debug loading savegames, add missing save loading parts
4de7ff5703 DM: First pass of refactoring in f280_addCandidateChampionToParty
698eb12770 DM: Rename a variable in f287_drawChampionBarGraphs
133404c635 DM: Fix compilation with MSVC9, some light renaming
4b066bf6f5 DM: Update todos
c8ab784330 DM: Get rid of labels and GOTOs in f280_addCandidateChampionToParty
dfc2d7e769 DM: Fix broken champion action hand slots
f0a916197a DM: Use ternary operator in f287_drawChampionBarGraphs to reduce code duplication
700c4327d3 DM: Move DMEngine::_rnd to private, fix erroneous ranges with random number generations
111d5ddc38 DM: Fix champion bargraphs
571a6b7a07 DM: Refactoring of f292_drawChampionState, including removing its GOTOs
2cb7938c52 DM: Fix broken champion after loading
2cd9c90e17 DM: Revert from using DisplayMan::_bitmaps directly
572d3bf822 DM: Fix torch, lever bug and fix several Sensor methods
040a02003b DM: Complete ChampionMan::f281_renameChampion
356f80af50 DM: Fix bug where code crashed if trying to display a doorfront in square R3
e0d89afbc3 DM: Add some missing code warnings to function calls
e9622e27b1 DM: Add f349_processCommand70_clickOnMouth
78f716e1c1 DM: Some refactoring in gfx.cpp, refactoring of f107_isDrawnWallOrnAnAlcove
800aec5d57 DM: Remove duplicate array
8540fdc800 DM: Some rework in f303_getSkillLevel
6e9fbffce3 DM: Add f352_processCommand71_clickOnEye, setting _g597_ignoreMouseMovements now prevents mouse movement
6bbd68199c DM: Add missing call to f379_drawSleepScreen, fix bytewidth bug in f379_drawSleepScreen
ac9f4d7d44 DM: Add some missing calls to already implemented methods
734abf8d48 DM: Adjust idle delay when renaming champion
ec28573a3b DM: Add f385_drawActionDamage
2b2a028332 DM: Add f444_endGame and checks for Common::EVENT_QUIT
084b1df8f3 DM: Refactor f281_renameChampion
b87d762087 DM: Fix compilation using MSVC9
a80ae55379 DM: some minor changes in f291_drawSlot and f281_renameChampion
f52469ce05 DM: Add a stub for f436_STARTEND_FadeToPalette
e29d843cfa DM: Refactor f427_dialogDraw
22d6973de5 DM: Add sound loading
ba46060b13 DM: Fix compilation using MSVC9
16c3757dcd DM: Refactor f426_isMessageOnTwoLines
f0e037e305 DM: Some renaming, add a couple of STUBS
ef34e8bb39 DM: Apply coding conventions to a couple of oneliner functions, remove a GOTO
a2b495e0e5 DM: Refactor f444_endGame
db164ae9d6 DM: Refactor f439_drawEntrance
19317e631c DM: Some renaming in f173_setCurrentMap
03db641f25 DM: Refactor f151_getSquare
a387f45d57 DM: Add f60_playSound
79c0a0adc9 DM: Add  f064_SOUND_RequestPlay_CPSD, f65_playPendingSound, f505_soundGetVolume
2e2732df39 DM: Partially fix drawing of shrunk bitmaps
483f05206f DM: Fix drawing of some wall oranments
1a96af48c5 DM: Fix portrait drawing
d02a66d5ee DM: Remove hack from f107_isDrawnWallOrnAnAlcove
65e4098080 DM: Improve on broken display
9cd5732b03 DM: Improve upon blitShrink
da7c739d71 DM: Fix cursor data decoding
15918a00cb DM: Some refactoring in dungeonman.cpp
5ff8c3d92d DM: First pass of refactoring in f161_getSquareFirstThing
af5e50a837 DM: Remove some GOTOs in f172_setSquareAspect
6122e199fe DM: remove some more GOTOs in f172_setSquareAspect
dd418e439f DM: Move 3 arrays to f168_decodeText, some refactoring in f166_getUnusedThing and f140_getObjectWeight
f92ba7f55d DM: Refactoring of f163_linkThingToList, f142_getProjectileAspect and f154_getLocationAfterLevelChange
81781f6f00 DM: Remove two GOTOs in f165_getDiscardTHing
0009c223ea DM: Refactor f165_getDiscardThing
c57929d3da DM: Refactor f144_getCreatureAttributes, f146_setGroupCells and f139_isCreatureAllowedOnMap
2b1b784479 DM: Remove GOTOs in f164_unlinkThingFromList
a0543f7502 DM: Remove unnecessary memset from setMousePointerFromSpriteData
2994cf707b DM: Fix mouse cursor dimensions
262e74aee8 DM: Fix item display in the dungeon, add f480_releaseBlock
be4f0665d0 DM: Update TODOs
774ae8e821 DM: Remove unnecessary redirection through DMEngine members
233f93fefe DM: Swap some warnings to stub methods
d7ff812715 DM: Refactor f164_unlinkThingFromList
3f1fee6dcb DM: Add _g335_selectedDialogChoice
fd775be377 DM: Swap warnings to stub method f363_highlightBoxDisable
0f9995851b DM: Add stub method f6_highlightScreenBox
ead63373ca DM: Add stub methods, clean up warnings and some comments
d69c2d12fa DM: Change Box's member fields from uint16 to int16
7570844f5e DM: Fill stub method f438_STARTEND_OpenEntranceDoors
6428110da8 DM: Fix dungon not drawn behind entrance doors
1f99dab5b5 DM: Fix double delete[] of DMEngine::_savedScreenForOpenEntranceDoor
256c2c10f8 DM: Reorder MenuMan::f392_buildSpellAreaLine, add MenuMan::_gK73_bitmapSpellAreaLines
644284e077 DM: Fix entrance door placement
f563f8d04f DM: Fix g0_BoxSpellArea value
0ab1a2a51e DM: Reorder MenuMan::f393_drawSpellAreaControls
6885cf6e59 DM: Fix broken spell symbols
69c5b01e12 DM: Refactor f155_getStairsExitDirection
b41f86651f DM: Refactor f167_getObjForProjectileLaucherOrObjGen
c97b5e170f DM: Refactor f68_setPointerToObject
1690a717ef DM: Refactor f73_buildpointerScreenArea, enable code in f78_showMouse and f77_hideMouse
1be1728c95 DM: Add missing code setting _g587_hideMousePointerRequestCount
50c5b39887 DM: Add debugger console
36395c5b26 DM: Add .gitattributes to repository
50f3cfa625 DM: Add debug command godmode
1c3c33c76d DM: Add noclip debug command
172477b115 DM: Rename engine debug command so they are listed first
c380ccf3f3 DM: Add SingleUseFlag to console.cpp
9e3e58a722 DM: Add missing include guard to console.h
9b772cfb75 DM: Fix possibly dangerous cast in eventman.cpp, moveParty
0eea48a59b DM: Add missing return in processInput with ctrl+d
a5c0a32446 DM: Add debug command .pos
56f5af7592 DM: Add debug command .map
5955b8d9ca DM: Rename engine debug commands
6279c56615 DM: Add debug command 'items', add option 'list'
50453e02bf DM: Add gimme debug command spawning items
bf403cc6e3 DM: Renaming in f380_processCommandQueue and f366_commandMoveParty
ed9d1e4f38 DM: Refactor f366_commandMoveParty
90a57f3625 DM: REfactor f375_processType80_clickDungeonView_isLeaderHandObjThrown, f372_commandProcessType80ClickInDungeonViewTouch
cba80bc69d DM: Some refactoring in f373_processType80_clickInDungeonView_grabLeaderHandObject and f374_processType80_clickInDungeon
834595a7f9 DM: Fix multiword item names with debug command gimme
9e333a6216 DM: Add search by substring in listItems debug command
5c2ee5c748 DM: Fix wrong champIcon hidden in f319_championKill
6cba484abb DM: Make EventManager:f541_waitForMouseOrKeyActivity discard input first
f5646efa44 DM: Add TextMan::f43_messageAreaClearAllRows()
13daeb62af DM: Make DMEngine::f22_delay and DMEngine::f444_endGame more responsive
b46ade6b6c DM: Add DMEngine::f445_STARTEND_fuseSequenceUpdate
37db95c336 DM: Add DMEngine::f446_STARTEND_fuseSequnce()
94ba2fdb2b DM: Add partial fix of color palette
181995cff9 DM: Deprecate DisplayMan::loadPalette
6113b75ca9 DM: Complete DisplayMan::f436_STARTEND_fadeToPalette
5fb1b3e808 DM: Add missing code related to palettes
629e0c1a6d DM: Fix building copper
d36b492b61 DM: Remove a useless variable in f374_processType80_clickInDungeonViewDropLeaderHandObject
94e0dbc3fe DM: Refactor f367_commandProcessTypes12to27_clickInChampionStatusBox, f70_mouseProcessCommands125To128_clickOnChampionIc
6ea782eeb5 DM: Start moving globals to DisplayMan
c798b1ca02 DM: Add offset to debug command pos
0bd785e7eb DM: Fix addActiveGroup with groupGenerator
8e2dac5fb5 DM: Add DialogMan::f424_dialogGetChoice
e1ddc2d3ab DM: Remove trashing input from DMEngine::f22_delay
3cb1c6d6ef DM: Disable releaseBlock code in f115_cthulhu
151b2d64d9 DM: Adjust choose dialog responsiveness
a11ae306e4 DM: Add dialog choice to savegame
e7d460bdc8 DM: Attempt to fix menus.cpp crlf problem
78f34ae4e3 DM: Make DMEngine::f22_delay call EventMan::processInput()
52f76a5d74 DM: Remove default parameters from blitToBitmap
29f5210b3f DM: Add sanity check to blitToBimap
fa0009fbb7 DM: Add entrance credits
e49bda9994 DM: Move some globals in DisplayMan, renaming
5bb786caae DM: Refactoring in DisplayMan
07907a8c98 DM: Get rid of more global variables
469b026bc7 DM: Get rid of more global variables in gfx
a6d5ad7c99 DM: More work on global variables
013b555338 DM: Add missing code in f125_drawSquareD0L, rename a constant
89030204bc DM: More work on globals in gfx.cpp
7f11c2551f DM: Get rid of more globals
f866d4a1ca DM: Add colour to mouse
fd1022d722 DM: More work on globals
641ef973b0 DM: More work on globals in gfx.cpp
514bad0d09 DM: Get rid the last globals of gfx.cpp
3fdd68fe31 DM: Minor adjustment to fuseSequence timing
c7b353385d DM: Fix mouse when clicking on eye
3fffb08a40 DM: Add missing localization warnings and query function for language
e75c07d9a2 DM: Fix no food and water bar graphs
f7ad6488e3 DM: Add localization
57f6575388 DM: Fix compilation, some renaming
9a174928d2 DM: Some small refactoring in DisplayMan
5bd6e3a49b DM: Add missing calls in constructors to initConstant methods
aacbcc0757 DM: Correct language from GR_GRE to DE_DEU
b5eb075a66 DM: Fix wrong global initialized in InventoryMan::initConstants()
4f916a08d2 DM: Add support for uncompressed dungeon.dat
cc8d3d9dd7 DM: Add LZW decompressor
170c52a4e0 DM: Add unknown Atari game version
7cc41a1929 DM: Add support for LZW compresssed graphics.dat
0eb61d0a7d DM: Pull sound handling into a separate class
621d83c66b DM: Add SoundMan_Atari
2f424adc30 DM: Fix broken wallOrnamentIndices
aaa0c7e3cc DM: Refactor f108_drawFloorOrnament, get rid of a GOTO
eb2b298631 DM: Refactor f109_drawDoorOrnament, f111_drawDoor, f112_drawCeilingPit and f116_drawSquareD3L
c62e449bbf DM: Refactor f116_drawSquareD3L, remove 4 GOTOs
b038124261 DM: Refactor f117_drawSquareD3R, get rid of several GOTOs
9b1af23a35 DM: Refactor f118_drawSquareD3C and f119_drawSquareD2L, remove several GOTOs
3ef8dedebd DM: Refactor f120_drawSquareD2R, f121_drawSquareD2C and f122_drawSquareD1L, remove more GOTOs
72912d4a5f DM: Refactor f123_drawSquareD1R, f124_drawSquareD1C and f125_drawSquareD0L
e4e30eaafd DM: Refactor f107_isDrawnWallOrnAnAlcove
09c865fb8f DM: Some refactoring, get rid of some more globals
fbf796779a DM: Some refactoring and renaming
e2860eb838 DM: WIP renaming and cleanup in f115_cthulhu
ab9563b7ff DM: Some more work on f115_cthulhu
921431c7ea DM: Some renaming in group.cpp, get rid of a global
44a5e36fc1 DM: Pull K0016_aui_Palette_FadeTemporary into a class vaiable
4442b0b302 DM: Finish f113_drawField
bcb067698e DM: Add support for loading from launcher
fb14fea014 DM: Make thumbnail capture the dungeon
c01293162c DM: Make resume button load up ScummVM's global load dialog
cefc231968 DM: Make ScummVM's save dialog open up when saving
5cb1d02972 DM: Fix double load when loading from launcher
efac7b5eb0 DM: Add loading from game
b4b76047ff DM: Fix some GCC warnings
f9d76556c2 DM: Fix regression in f107_isDrawnWallOrnAnAlcove
6aabe84bf6 DM: Complete f437_STARTEND_drawTittle
80f2199151 DM: Clear check some warnings, complete minor functions
a5b8085c48 DM: Fix regression (pressure plate), fix compilation
58d1bcc3e7 DM: Silent a couple of CppCheck warnings
705e906698 DM: Some renaming, move some globals to class member
92c9c54481 DM: Start refactoring of eventMan
d85970b4e4 DM: Fix releasing flagged bitmaps
ca267da97c DM: Add file error checking for save game
d97a8905cc DM: Remove some warnings
c469c72824 DM: Move some more globals
d90f365728 DM: Work on eventman globals, renaming and apply some coding conventions
901ba6f132 DM: Move more globals to EventMan
e26a655e67 DM: Finish moving globals to EventMan
20165b1865 DM: Fix some GCC warnings
53121afb09 DM: Fix some GCC warnings
07438a94e1 DM: Implement missing code in f125_drawSquareD0L
30eea48e4a DM: Fix some more GCC warnings
4613e8ffad DM: Fix some more GCC warnings
236a27e4cc DM: Fix more GCC warnings
f9323fe9fa DM: Get rid of some globals in inventory
2ee50eda35 DM: Add proper save header
1a0fe29af8 DM: Fix drawing title
22a79ac965 DM: Fix drawing of some dungeon items
2199f879bd DM: Fix incorrect thumbnails
2bdabc3b7a DM: Add target and original platform to save files
fecb869af9 DM: Fix some more GCC warnings, move some globals to MenuMan
8ed20d852e DM: Change several string constness, hopefully fixing GCC warnings
0233b503f1 DM: Some more work on GCC warnings
857d4e72ed DM: Renaming of Champion and ChampionMan functions
5bd4464076 DM: Fix some more GCC warnings
3510303656 DM: Fix 2 more warnings
31cb7cd2fc DM: Refactor unreadable if statement
0229a10df0 DM: Make private some function declarations in console
e728cb706e DM: Rename functions of DMEngine and DialogMan
544ce3578b DM: rename members of dungeonman
64b1c4fdf1 DM: Rename DungeonMan class members
36e6eac2f3 DM: Fix GCC errors in detection.cpp
0d5f9a762e DM: Rename class members in EventManager
6a02a571cd DM: Rename variables and functions of DisplayMan
5c81e4f4fd DM: Rename functions and class members of GroupMan
5b05f3cff4 DM: Rename members of InventoryMan
d2fbd98f3d DM: Renaming in MenuMan definition
938b38a66a DM: Rename class members of MovesensMan
52170d39ae DM: Rename ObjectMan and ProjExpl members
42fea91d5d DM: Finish the renaming of class members
8f6f350aa5 DM: Renaming in ChampionMan
6a5182ac19 DM: Renaming in DialogMan::getChoice()
b9986f4f27 DM: Rework processEntrance() and drawTittle()
bf5875d2fe DM: Janitorial - Fix the style of some pointers
5ca6975665 DM: Remove custom warning function
1e2fa9630f DM: Rework fuseSequence
d76ef497f7 DM: Rewrite 3 for loops
b4fecce3fc DM: Remove a couple of GOTOs in fuseSequence()
361722d459 DM: More renaming in DungeonMan, move some arrays
8c9eed7bac DM: Some renaming
ed248ca1e0 DM: Renaming in GroupMan
c54204910d DM: WIP rework of processEvents29to41, some more renaming
adf3931e40 DM: Renaming in isMovementPossible and groupGetDistanceToVisibleParty, rewrite getDistanceBetweenSquares
150a16cd49 DM: Refactor getDistanceBetweenSquares, get rid of GOTOs
dc40f028af DM: Add message area scroller
95272838e1 DM: renaming and some refactoring in getDistanceBetweenUnblockedSquares
ff96b8eeb6 DM: Refactor a couple of 'if' nightmares in getDistanceBetweenUnblockedSquares
643fd69f87 DM: More renaming and refactoring in GroupMan
c4bf70c9a8 DM: Rework getChampionDamage and startWanedring
deca60efc9 DM: More renaming in GroupMan
40da6882af DM: Remove GOTOs in fluxCageAction
d32f6f8388 DM: Fix a typo in the spelling of startWandering()
0d7481b2a5 DM: More renaming in InventoryMan, some refactoring
cd3b485952 DM: Clean up includes
cb8fca46c5 DM: Fix include headers
2e0fae6547 DM: Fix copyright issues
d059a1cd4b DM: Use delayMillis(10) in mainLoop
2fec2241e4 DM: More renaming and refactoring in InventoryMan
9aa582e341 DM: Refactor string manipulation in drawPanelObject
fbe9c92ce1 DM: Fix the style used for some pointers and casts
d0bae5b805 DM: Replace _vm->_system with g_system
3191f2605b Merge branch 'dm' of https://github.com/WinterGrascph/scummvm into dm
8d41bf9ad7 DM: Some more fixes concerning pointer formatting
807bfc270b DM: Finish the renaming of variables in InventoryMan
e4863c0c73 DM: Polishing in loadsave
3ecc98e832 DM: Change savegame signature to DM21 instead of DMDM. That breaks savegames compatibility.
ef144e1e8b DM: Polishing in LZWdecompressor
4eeeea2c8d DM: Refactoring, enforce the use of ChampionIndex
f81093168e DM: Rework getClickOnSpellCastResult
e0f1285fbc DM: Remove useless code in setMagicCasterAndDrawSpellArea
04c3beefd7 DM: First pass of renaming in getChampionSpellCastResult
88c8fcf302 DM: More rework in getChampionSpellCastResult, remove GOTOs
5bb8d33a1a DM: More refactoring in MenuMan
db99e8bc60 DM: Fix original bug in MenuMan
c5f45cb301 DM: WIP rework in isActionPerformed()
f2fdc9c06f DM: Finish the rework in isActionPerformed, remove all GOTOs
e8f4b15af9 DM: More refactoring and renaming in MenuMan
9284e4c9fd DM: Remove a variant of blitToScreen, refactor drawActionDamage
d663f7f788 DM: First pass of refactoring in sensorIsTriggeredByClickOnWall, clean pointers type in movesens
3b4c06e926 DM: Refactor sensorIsTriggeredByClickOnWall, remove all GOTOs
3df32ecf20 DM: Refactor getMoveResult()
1a9f9c54aa DM: Fix original bug in isLevitating
e5c1888e8c DM: Some more refactoring in MovesensMan, change return value of getSound()
c95620b8db DM: First pass of refactoring of getTeleporterRotatedGroupResult
91fe53762d DM: First pass of refactoring in isObjcetInPartyPossession
47741742f5 DM: Fix typo in the name of isObjectInPartyPossession, get rid of the GOTO
d6b2ea67b0 DM: More polishing in MovesensMan
6e404ec0bc DM: Small refactoring in processThingAdditionOrRemoval
4663d190c4 DM: Get rid of Gotos in processThingAdditionOrRemoval
4befd3a232 Merge branch 'dm' of github.com:WinterGrascph/scummvm into dm
17bf26821b DM: Better refactoring of processThingAdditionOrRemoval
70906ba7eb DM: Better refactoring of sensorIsTriggeredByClickOnWall
e4fe372bdb DM: Start refactoring ObjectMan
b6ab58658f DM: Finish the renaming in ObjectMan
dad8637ae8 DM: Fix pointer style in ObjectMan
0ae23fa2db DM: Fix regression introduced in 901ba6f
06ec57e7e3 DM: Merge branch 'dm' of github.com:WinterGrascph/scummvm into dm
a4de5d0dd2 DM: First pass of refactoring in hasProjectileImpactOccurred
46b41f9b2b DM: Split redefined variables in hasProjectileImpactOccurred()
92ca2ae87b DM: Rework a if statement in hasProjectileImpactOccurred to make it readable
78085dcd8d DM: Take Dreammaster's suggestion into account to make it even more readable
6df9a20b85 DM: Renaming in ProjExpl
8f33b469be DM: Get rid of a GOTO in projectileGetImpactCount
57d950b46f DM: Refactor processEvents48To49
4a29167fd0 DM: Refactor processEvent25
6e1a3d6217 DM: Remove the use of GOTO in processEvent25
b62f4babbe DM: Fix regression introduced in e4fe372
4414995c29 DM: Fix the style of some pointers in projexpl
878ae1a882 DM: More renaming and refactoring
53a8bda124 DM: Finish the renaming and first refactoring pass in TextMan
7bda512dde DM: Start refactoring Timeline
40f57744ef DM: Remove a GOTO from fixChronology()
6e412c6a8b DM: more renaming in Timeline
4703c6e799 DM: Remove GOTOs from processTimeline()
3d4c73251d DM: More refactoring in Timeline
f18013db65 DM: Renaming in more functions of Timeline
ebc0dbe8b8 DM: Check the style used for the pointers in Timeline, more renaming
7654c89d4f DM: Finish refactoring pass in Timeline
b365338293 DM: Rename IconIndice enum
1b482a1e12 DM: Rename enums ChampionIndex, ChampionAttribute, ChampionWound, ChampionStatisticType, ChampionStatisticValue
93fb0efc0b DM: More renaming in champion.h
33287b7657 DM: Fix regression in 4613e8ffad84e76d06024448f9215439d5cea5e7
d588e15dad DM: Rename ChampionSlot enum
d2b0829476 DM: Change constants into enums in champion.h, renaming
4099814fbe DM: Finish the renaming in champion.h
a46cc8597c Merge pull request #817 from WinterGrascph/dm


Commit: 96cc074ea0752165d2eb9281c9affeda8e5be5b1
    https://github.com/scummvm/scummvm/commit/96cc074ea0752165d2eb9281c9affeda8e5be5b1
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Create engine and detection with dummy data

Changed paths:
  A engines/dm/configure.engine
  A engines/dm/detection.cpp
  A engines/dm/dm.cpp
  A engines/dm/dm.h
  A engines/dm/module.mk



diff --git a/engines/dm/configure.engine b/engines/dm/configure.engine
new file mode 100644
index 0000000..50a3d99
--- /dev/null
+++ b/engines/dm/configure.engine
@@ -0,0 +1,3 @@
+# This file is included from the main "configure" script
+# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
+add_engine dm "Dungeon Master" yes
diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp
new file mode 100644
index 0000000..4c970e3
--- /dev/null
+++ b/engines/dm/detection.cpp
@@ -0,0 +1,55 @@
+#include "dm/dm.h"
+
+#include "common/config-manager.h"
+#include "common/error.h"
+#include "common/fs.h"
+
+#include "engines/advancedDetector.h"
+namespace DM {
+static const PlainGameDescriptor DMGames[] = {
+	{0, 0}
+};
+
+static const ADGameDescription gameDescriptions[] = {
+	AD_TABLE_END_MARKER
+};
+
+static const ADExtraGuiOptionsMap optionsList[] = {
+	AD_EXTRA_GUI_OPTIONS_TERMINATOR
+};
+
+
+class DMMetaEngine : public AdvancedMetaEngine {
+public:
+
+
+	DMMetaEngine() : AdvancedMetaEngine(DM::gameDescriptions, sizeof(ADGameDescription), DMGames, optionsList) {
+		_singleId = "Dummy";
+	}
+
+	virtual const char *getName() const {
+		return "Dummy";
+	}
+
+	virtual const char *getOriginalCopyright() const {
+		return "Dummy";
+	}
+
+	virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { return gameDescriptions; }
+	virtual bool hasFeature(MetaEngineFeature f) const { return false; }
+	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+		*engine = new DM::DMEngine(syst);
+		return true;
+	}
+	virtual int getMaximumSaveSlot() const { return 99; }
+	virtual SaveStateList listSaves(const char *target) const { return SaveStateList(); }
+	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { return SaveStateDescriptor(); }
+	virtual void removeSaveState(const char *target, int slot) const {}
+};
+
+}
+#if PLUGIN_ENABLED_DYNAMIC(DM)
+REGISTER_PLUGIN_DYNAMIC(DM, PLUGIN_TYPE_ENGINE, DM::DMMetaEngine);
+#else
+REGISTER_PLUGIN_STATIC(DM, PLUGIN_TYPE_ENGINE, DM::DMMetaEngine);
+#endif
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
new file mode 100644
index 0000000..b0c281a
--- /dev/null
+++ b/engines/dm/dm.cpp
@@ -0,0 +1,61 @@
+#include "common/scummsys.h"
+
+#include "common/config-manager.h"
+#include "common/debug.h"
+#include "common/debug-channels.h"
+#include "common/error.h"
+#include "gui/EventRecorder.h"
+#include "common/file.h"
+#include "common/fs.h"
+
+#include "engines/util.h"
+
+#include "dm/dm.h"
+
+namespace DM {
+
+DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
+	// Do not load data files
+	// Do not initialize graphics here
+	// Do not initialize audio devices here
+	// Do these from run
+
+	//Specify all default directories
+	const Common::FSNode gameDataDir(ConfMan.get("example"));
+	SearchMan.addSubDirectoryMatching(gameDataDir, "example2");
+
+	DebugMan.addDebugChannel(kDMDebugExample, "example", "example desc");
+
+	// regiser random source
+	_rnd = new Common::RandomSource("quux");
+
+	debug("DMEngine::DMEngine");
+}
+
+DMEngine::~DMEngine() {
+	debug("DMEngine::~DMEngine");
+
+	// dispose of resources
+	delete _rnd;
+
+	// clear debug channels
+	DebugMan.clearAllDebugChannels();
+}
+
+Common::Error DMEngine::run() {
+	// Init graphics
+	initGraphics(320, 200, false);
+
+	// Create debug console (it requirese GFX to be inited)
+	_console = new Console(this);
+
+	// Additional setup
+	debug("DMEngine::init");
+
+	// Run main loop
+	debug("DMEngine:: start main loop");
+
+	return Common::kNoError;
+}
+
+} // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
new file mode 100644
index 0000000..79deb29
--- /dev/null
+++ b/engines/dm/dm.h
@@ -0,0 +1,38 @@
+#ifndef DM_H
+#define DM_H
+
+#include "common/random.h"
+#include "engines/engine.h"
+#include "gui/debugger.h"
+
+
+namespace DM {
+
+class Console;
+
+enum {
+	// engine debug channels
+	kDMDebugExample = 1 << 0
+};
+
+class DMEngine : public Engine {
+public:
+	DMEngine(OSystem *syst);
+	~DMEngine();
+
+	virtual Common::Error run();
+
+private:
+	Console *_console;
+	Common::RandomSource *_rnd;
+};
+
+class Console : public GUI::Debugger {
+public:
+	Console(DMEngine *vm) {}
+	virtual ~Console(void) {}
+};
+
+} // End of namespace DM
+
+#endif
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
new file mode 100644
index 0000000..808b4e5
--- /dev/null
+++ b/engines/dm/module.mk
@@ -0,0 +1,17 @@
+MODULE := engines/dm
+
+MODULE_OBJS := \
+	detection.o \
+	dm.o
+
+MODULE_DIRS += \
+	engines/dm
+
+# This module can be built as a plugin
+ifeq ($(ENABLE_DM), DYNAMIC_PLUGIN)
+PLUGIN := 1
+endif
+
+# Include common rules
+include $(srcdir)/rules.mk
+


Commit: 5ae7d3a84b04336b65b93e2efe1c988c795e1752
    https://github.com/scummvm/scummvm/commit/5ae7d3a84b04336b65b93e2efe1c988c795e1752
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add detection for Amiga v2.0 English

Changed paths:
    engines/dm/detection.cpp
    engines/dm/dm.cpp



diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp
index 4c970e3..443d2db 100644
--- a/engines/dm/detection.cpp
+++ b/engines/dm/detection.cpp
@@ -7,13 +7,35 @@
 #include "engines/advancedDetector.h"
 namespace DM {
 static const PlainGameDescriptor DMGames[] = {
+	{"dm", "Dungeon Master"},
 	{0, 0}
 };
 
 static const ADGameDescription gameDescriptions[] = {
+	{
+		"dm", "Amiga 2.0v English",
+		{
+		{"graphics.dat", 0, "6A2F135B53C2220F0251FA103E2A6E7E", 411960},
+		{"Dungeon.dat", 0, "30028FB6A301ECB20127EF0B3AF32B05", 25006},
+		AD_LISTEND
+		},
+	    Common::EN_GRB, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE)
+	},
+
 	AD_TABLE_END_MARKER
 };
 
+static ADGameDescription fallbackDesc = {
+	"dm",
+	"Unknown version",
+	AD_ENTRY1(0, 0), // This should always be AD_ENTRY1(0, 0) in the fallback descriptor
+	Common::UNK_LANG,
+	Common::kPlatformDOS,
+	ADGF_NO_FLAGS,
+	GUIO1(GUIO_NONE)
+};
+
+
 static const ADExtraGuiOptionsMap optionsList[] = {
 	AD_EXTRA_GUI_OPTIONS_TERMINATOR
 };
@@ -21,14 +43,12 @@ static const ADExtraGuiOptionsMap optionsList[] = {
 
 class DMMetaEngine : public AdvancedMetaEngine {
 public:
-
-
 	DMMetaEngine() : AdvancedMetaEngine(DM::gameDescriptions, sizeof(ADGameDescription), DMGames, optionsList) {
-		_singleId = "Dummy";
+		_singleId = "dm";
 	}
 
 	virtual const char *getName() const {
-		return "Dummy";
+		return "Dungeon Master";
 	}
 
 	virtual const char *getOriginalCopyright() const {
@@ -38,8 +58,9 @@ public:
 	virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { return gameDescriptions; }
 	virtual bool hasFeature(MetaEngineFeature f) const { return false; }
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
-		*engine = new DM::DMEngine(syst);
-		return true;
+		if(desc)
+			*engine = new DM::DMEngine(syst);
+		return desc != nullptr;
 	}
 	virtual int getMaximumSaveSlot() const { return 99; }
 	virtual SaveStateList listSaves(const char *target) const { return SaveStateList(); }
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index b0c281a..ba6c326 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -21,9 +21,8 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	// Do these from run
 
 	//Specify all default directories
-	const Common::FSNode gameDataDir(ConfMan.get("example"));
-	SearchMan.addSubDirectoryMatching(gameDataDir, "example2");
-
+	//const Common::FSNode gameDataDir(ConfMan.get("example"));
+	//SearchMan.addSubDirectoryMatching(gameDataDir, "example2");
 	DebugMan.addDebugChannel(kDMDebugExample, "example", "example desc");
 
 	// regiser random source
@@ -55,6 +54,9 @@ Common::Error DMEngine::run() {
 	// Run main loop
 	debug("DMEngine:: start main loop");
 
+	while (true)
+		debug("Run!");
+
 	return Common::kNoError;
 }
 


Commit: 055e789d0461f881b13cb4fe6e3331b1872eb633
    https://github.com/scummvm/scummvm/commit/055e789d0461f881b13cb4fe6e3331b1872eb633
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Create DisplayMan, add support parsing IMG0 files

Add display manager named DisplayMan with functions: setUpScreens(),
loadGraphics() (which loads graphics from the graphics.dat file),
setPalette(..), loadIntoBitmap(..) which loads the requested image into a
bitmap and blitToScreen(..)

Changed paths:
  A engines/dm/gfx.cpp
  A engines/dm/gfx.h
    engines/dm/detection.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/module.mk



diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp
index 443d2db..855d128 100644
--- a/engines/dm/detection.cpp
+++ b/engines/dm/detection.cpp
@@ -15,8 +15,8 @@ static const ADGameDescription gameDescriptions[] = {
 	{
 		"dm", "Amiga 2.0v English",
 		{
-		{"graphics.dat", 0, "6A2F135B53C2220F0251FA103E2A6E7E", 411960},
-		{"Dungeon.dat", 0, "30028FB6A301ECB20127EF0B3AF32B05", 25006},
+			{"graphics.dat", 0, "c2205f6225bde728417de29394f97d55", 411960},
+			{"Dungeon.dat", 0, "43a213da8eda413541dd12f90ce202f6", 25006},
 		AD_LISTEND
 		},
 	    Common::EN_GRB, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE)
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index ba6c326..d6fc1f3 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -1,16 +1,17 @@
 #include "common/scummsys.h"
+#include "common/system.h"
 
-#include "common/config-manager.h"
 #include "common/debug.h"
 #include "common/debug-channels.h"
 #include "common/error.h"
-#include "gui/EventRecorder.h"
-#include "common/file.h"
-#include "common/fs.h"
 
 #include "engines/util.h"
+#include "engines/engine.h"
+#include "graphics/palette.h"
+#include "common/file.h"
 
 #include "dm/dm.h"
+#include "dm/gfx.h"
 
 namespace DM {
 
@@ -36,26 +37,48 @@ DMEngine::~DMEngine() {
 
 	// dispose of resources
 	delete _rnd;
+	delete _console;
+	delete _displayMan;
 
 	// clear debug channels
 	DebugMan.clearAllDebugChannels();
 }
 
 Common::Error DMEngine::run() {
-	// Init graphics
 	initGraphics(320, 200, false);
-
-	// Create debug console (it requirese GFX to be inited)
 	_console = new Console(this);
+	_displayMan = new DisplayMan(this);
+	_displayMan->setUpScreens(320, 200);
+	_displayMan->loadGraphics();
+
+
+	byte *palette = new byte[256 * 3];
+	for (int i = 0; i < 16; ++i)
+		palette[i * 3] = palette[i * 3 + 1] = palette[i * 3 + 2] = i * 16;
+
+	_displayMan->setPalette(palette, 16);
+
+	byte *buffer = new byte[320 * 200];
+	for (int i = 0; i < 320 * 100; ++i)
+		buffer[i] = 4;
+	for (int i = 320 * 100; i < 320 * 200; ++i)
+		buffer[i] = 6;
+
+	_system->copyRectToScreen(buffer, 320, 0, 0, 320, 200);
+	_system->updateScreen();
+
+
+	uint16 width = _displayMan->getImageWidth(75);
+	uint16 height = _displayMan->getImageHeight(75);
+	byte *cleanByteImg0Data = new byte[width * height];
+	_displayMan->loadIntoBitmap(75, cleanByteImg0Data);
+	_displayMan->blitToScreen(cleanByteImg0Data, width, height, 30, 30);
 
-	// Additional setup
-	debug("DMEngine::init");
 
-	// Run main loop
-	debug("DMEngine:: start main loop");
+	while (true) {
+		_displayMan->updateScreen();
+	}
 
-	while (true)
-		debug("Run!");
 
 	return Common::kNoError;
 }
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 79deb29..6820640 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -9,6 +9,7 @@
 namespace DM {
 
 class Console;
+class DisplayMan;
 
 enum {
 	// engine debug channels
@@ -21,10 +22,12 @@ public:
 	~DMEngine();
 
 	virtual Common::Error run();
+	Common::Error go();
 
 private:
 	Console *_console;
 	Common::RandomSource *_rnd;
+	DisplayMan *_displayMan;
 };
 
 class Console : public GUI::Debugger {
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
new file mode 100644
index 0000000..53abbbf
--- /dev/null
+++ b/engines/dm/gfx.cpp
@@ -0,0 +1,126 @@
+#include "gfx.h"
+#include "engines/util.h"
+#include "common/system.h"
+#include "common/file.h"
+#include "graphics/palette.h"
+#include "common/endian.h"
+
+using namespace DM;
+
+DisplayMan::DisplayMan(DMEngine *dmEngine) :
+	_vm(dmEngine), _currPalette(NULL), _screenWidth(0), _screenHeight(0),
+	_vgaBuffer(0), _itemCount(0), _indexBytePos(NULL), _compressedData(NULL) {}
+
+DisplayMan::~DisplayMan() {
+	delete[] _compressedData;
+	delete[] _indexBytePos;
+	delete[] _currPalette;
+}
+
+void DisplayMan::setUpScreens(uint16 width, uint16 height) {
+	_currPalette = new byte[256 * 2];
+	_screenWidth = width;
+	_screenHeight = height;
+	_vgaBuffer = new byte[_screenWidth * _screenHeight];
+	memset(_vgaBuffer, 0, width * height);
+}
+
+void DisplayMan::loadGraphics() {
+	Common::File f;
+	f.open("graphics.dat");
+
+	_itemCount = f.readUint16BE();
+	_indexBytePos = new uint32[_itemCount + 1];
+	_indexBytePos[0] = 0;
+	for (uint16 i = 1; i < _itemCount + 1; ++i)
+		_indexBytePos[i] = f.readUint16BE() + _indexBytePos[i - 1];
+
+	_compressedData = new uint8[_indexBytePos[_itemCount]];
+
+	f.seek(2 + _itemCount * 4);
+	for (uint32 i = 0; i < _indexBytePos[_itemCount]; ++i)
+		_compressedData[i] = f.readByte();
+
+	f.close();
+}
+
+void DisplayMan::setPalette(byte *buff, uint16 colorCount) {
+	memcpy(_currPalette, buff, sizeof(byte) * colorCount * 3);
+	_vm->_system->getPaletteManager()->setPalette(buff, 0, colorCount);
+}
+
+#define TOBE2(byte1, byte2) ((((uint16)(byte1)) << 8) | (uint16)(byte2))
+
+void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
+	uint8 *data = _compressedData + _indexBytePos[index];
+	uint16 width = TOBE2(data[0], data[1]);
+	uint16 height = TOBE2(data[2], data[3]);
+	uint16 nextByteIndex = 4;
+	for (uint16 k = 0; k < width * height;) {
+		uint8 nextByte = data[nextByteIndex++];
+		uint8 nibble1 = (nextByte & 0xF0) >> 4;
+		uint8 nibble2 = (nextByte & 0x0F);
+		if (nibble1 <= 7) {
+			for (int j = 0; j < nibble1 + 1; ++j)
+				destBitmap[k++] = nibble2;
+		} else if (nibble1 == 0x8) {
+			uint8 byte1 = data[nextByteIndex++];
+			for (int j = 0; j < byte1 + 1; ++j)
+				destBitmap[k++] = nibble2;
+		} else if (nibble1 == 0xC) {
+			uint16 word1 = TOBE2(data[nextByteIndex], data[nextByteIndex + 1]);
+			nextByteIndex += 2;
+			for (int j = 0; j < word1 + 1; ++j)
+				destBitmap[k++] = nibble2;
+		} else if (nibble1 == 0xB) {
+			uint8 byte1 = data[nextByteIndex++];
+			for (int j = 0; j < byte1 + 1; ++j, ++k)
+				destBitmap[k] = destBitmap[k - width];
+			destBitmap[k++] = nibble2;
+		} else if (nibble1 == 0xF) {
+			uint16 word1 = TOBE2(data[nextByteIndex], data[nextByteIndex + 1]);
+			nextByteIndex += 2;
+			for (int j = 0; j < word1 + 1; ++j, ++k)
+				destBitmap[k] = destBitmap[k - width];
+			destBitmap[k++] = nibble2;
+		} else if (nibble1 == 9) {
+			uint8 byte1 = data[nextByteIndex++];
+			if (byte1 % 2)
+				byte1++;
+			else
+				destBitmap[k++] = nibble2;
+
+			for (int j = 0; j < byte1 / 2; ++j) {
+				uint8 byte2 = data[nextByteIndex++];
+				destBitmap[k++] = byte2 & 0x0F;
+				destBitmap[k++] = (byte2 & 0xF0) >> 4;
+			}
+		}
+	}
+}
+
+void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, uint16 destX, uint16 destY) {
+	for (uint16 y = 0; y < srcHeight; ++y)
+		memcpy(getCurrentVgaBuffer() + ((y + destY) * _screenWidth + destX), srcBitmap + y * srcWidth, srcWidth * sizeof(byte));
+
+}
+
+void DisplayMan::updateScreen() {
+	_vm->_system->copyRectToScreen(_vgaBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
+	_vm->_system->updateScreen();
+}
+
+byte *DisplayMan::getCurrentVgaBuffer() {
+	return _vgaBuffer;
+}
+
+uint16 DisplayMan::getImageWidth(uint16 index) {
+	uint8 *data = _compressedData + _indexBytePos[index];
+	return TOBE2(data[0], data[1]);
+}
+
+uint16 DisplayMan::getImageHeight(uint16 index) {
+	uint8 *data = _compressedData + _indexBytePos[index];
+	return TOBE2(data[2], data[3]);
+}
+
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
new file mode 100644
index 0000000..91cf7e1
--- /dev/null
+++ b/engines/dm/gfx.h
@@ -0,0 +1,38 @@
+#ifndef GFX_H
+#define GFX_H
+
+#include "common/scummsys.h"
+#include "dm/dm.h"
+
+namespace DM {
+
+class DisplayMan {
+	DMEngine *_vm;
+	byte *_currPalette;
+	uint16 _screenWidth;
+	uint16 _screenHeight;
+	byte *_vgaBuffer;
+	uint16 _itemCount;
+	uint32 *_indexBytePos;
+	uint8 *_compressedData;
+	DisplayMan(const DMEngine &dmEngine); // no implementation on purpose
+	void operator=(const DisplayMan &rhs); // no implementation on purpose
+public:
+	DisplayMan(DMEngine *dmEngine);
+	~DisplayMan();
+	void setUpScreens(uint16 width, uint16 height);
+	void loadGraphics();
+	void setPalette(byte *buff, uint16 colorCount);
+	void loadIntoBitmap(uint16 index, byte *destBitmap);
+	uint16 getImageWidth(uint16 index);
+	uint16 getImageHeight(uint16 index);
+	void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, uint16 destX, uint16 destY);
+	byte *getCurrentVgaBuffer();
+	void updateScreen();
+};
+
+}
+
+
+
+#endif
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index 808b4e5..3fad4ee 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -2,7 +2,8 @@ MODULE := engines/dm
 
 MODULE_OBJS := \
 	detection.o \
-	dm.o
+	dm.o \
+	gfx.o
 
 MODULE_DIRS += \
 	engines/dm


Commit: cdf377f7a7a43521403c38014bb1406b1ce15721
    https://github.com/scummvm/scummvm/commit/cdf377f7a7a43521403c38014bb1406b1ce15721
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add support for Dungeon.dat uncompression

Add DungeonMan class with support for loading and uncompressing
Dungeon.dat file into memory

Changed paths:
  A engines/dm/dungeonman.cpp
  A engines/dm/dungeonman.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index d6fc1f3..61e68df 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -12,6 +12,7 @@
 
 #include "dm/dm.h"
 #include "dm/gfx.h"
+#include "dm/dungeonman.h"
 
 namespace DM {
 
@@ -39,17 +40,23 @@ DMEngine::~DMEngine() {
 	delete _rnd;
 	delete _console;
 	delete _displayMan;
+	delete _dungeonMan;
 
 	// clear debug channels
 	DebugMan.clearAllDebugChannels();
 }
 
+
 Common::Error DMEngine::run() {
 	initGraphics(320, 200, false);
 	_console = new Console(this);
 	_displayMan = new DisplayMan(this);
+	_dungeonMan = new DungeonMan(this);
 	_displayMan->setUpScreens(320, 200);
 	_displayMan->loadGraphics();
+	_dungeonMan->loadDungeonFile();
+
+
 
 
 	byte *palette = new byte[256 * 3];
@@ -79,7 +86,6 @@ Common::Error DMEngine::run() {
 		_displayMan->updateScreen();
 	}
 
-
 	return Common::kNoError;
 }
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 6820640..705939c 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -10,6 +10,7 @@ namespace DM {
 
 class Console;
 class DisplayMan;
+class DungeonMan;
 
 enum {
 	// engine debug channels
@@ -28,6 +29,7 @@ private:
 	Console *_console;
 	Common::RandomSource *_rnd;
 	DisplayMan *_displayMan;
+	DungeonMan *_dungeonMan;
 };
 
 class Console : public GUI::Debugger {
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
new file mode 100644
index 0000000..6ddf966
--- /dev/null
+++ b/engines/dm/dungeonman.cpp
@@ -0,0 +1,62 @@
+#include "dungeonman.h"
+#include "common/file.h"
+
+
+namespace DM {
+DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _dungeonDataSize(0), _dungeonData(NULL) {}
+DungeonMan::~DungeonMan() { delete[] _dungeonData; }
+void DungeonMan::loadDungeonFile() {
+	Common::File f;
+	f.open("Dungeon.dat");
+	if (f.readUint16BE() == 0x8104) {
+		_dungeonDataSize = f.readUint32BE();
+		_dungeonData = new byte[_dungeonDataSize];
+		f.readUint16BE();
+		byte common[4];
+		for (uint16 i = 0; i < 4; ++i)
+			common[i] = f.readByte();
+		byte lessCommon[16];
+		for (uint16 i = 0; i < 16; ++i)
+			lessCommon[i] = f.readByte();
+
+		// start unpacking
+		uint32 uncompIndex = 0;
+		uint8 bitsUsedInWord = 0;
+		uint16 wordBuff = f.readUint16BE();
+		uint8 bitsLeftInByte = 8;
+		byte byteBuff = f.readByte();
+		while (uncompIndex < _dungeonDataSize) {
+			while (bitsUsedInWord != 0) {
+				uint8 shiftVal;
+				if (f.eos()) {
+					shiftVal = bitsUsedInWord;
+					wordBuff <<= shiftVal;
+				} else {
+					shiftVal = MIN(bitsLeftInByte, bitsUsedInWord);
+					wordBuff <<= shiftVal;
+					wordBuff |= (byteBuff >> (8 - shiftVal));
+					byteBuff <<= shiftVal;
+					bitsLeftInByte -= shiftVal;
+					if (!bitsLeftInByte) {
+						byteBuff = f.readByte();
+						bitsLeftInByte = 8;
+					}
+				}
+				bitsUsedInWord -= shiftVal;
+			}
+			if (((wordBuff >> 15) & 1) == 0) {
+				_dungeonData[uncompIndex++] = common[(wordBuff >> 13) & 3];
+				bitsUsedInWord += 3;
+			} else if (((wordBuff >> 14) & 3) == 2) {
+				_dungeonData[uncompIndex++] = lessCommon[(wordBuff >> 10) & 15];
+				bitsUsedInWord += 6;
+			} else if (((wordBuff >> 14) & 3) == 3) {
+				_dungeonData[uncompIndex++] = (wordBuff >> 6) & 255;
+				bitsUsedInWord += 10;
+			}
+		}
+	}
+	f.close();
+}
+
+}
\ No newline at end of file
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
new file mode 100644
index 0000000..b820bb2
--- /dev/null
+++ b/engines/dm/dungeonman.h
@@ -0,0 +1,22 @@
+#ifndef DUNGEONMAN_H
+#define DUNGEONMAN_H
+
+#include "dm.h"
+
+namespace DM {
+
+class DungeonMan {
+	DMEngine *_vm;
+	uint32 _dungeonDataSize;
+	byte *_dungeonData;
+	DungeonMan(const DungeonMan &other); // no implementation on purpose
+	void operator=(const DungeonMan &rhs); // no implementation on purpose
+public:
+	DungeonMan(DMEngine *dmEngine);
+	~DungeonMan();
+	void loadDungeonFile();
+};
+
+}
+
+#endif
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 91cf7e1..98d035b 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -15,7 +15,7 @@ class DisplayMan {
 	uint16 _itemCount;
 	uint32 *_indexBytePos;
 	uint8 *_compressedData;
-	DisplayMan(const DMEngine &dmEngine); // no implementation on purpose
+	DisplayMan(const DisplayMan &other); // no implementation on purpose
 	void operator=(const DisplayMan &rhs); // no implementation on purpose
 public:
 	DisplayMan(DMEngine *dmEngine);


Commit: b7987d84c1de7c7f6c40b9995026009058d43ab3
    https://github.com/scummvm/scummvm/commit/b7987d84c1de7c7f6c40b9995026009058d43ab3
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix memory leak in dm.cpp and gfx.cpp

Changed paths:
    engines/dm/dm.cpp
    engines/dm/gfx.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 61e68df..24ebfbf 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -86,6 +86,10 @@ Common::Error DMEngine::run() {
 		_displayMan->updateScreen();
 	}
 
+
+	delete[] buffer;
+	delete[] cleanByteImg0Data;
+
 	return Common::kNoError;
 }
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 53abbbf..577251c 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -15,10 +15,11 @@ DisplayMan::~DisplayMan() {
 	delete[] _compressedData;
 	delete[] _indexBytePos;
 	delete[] _currPalette;
+	delete[] _vgaBuffer;
 }
 
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
-	_currPalette = new byte[256 * 2];
+	_currPalette = new byte[256 * 3];
 	_screenWidth = width;
 	_screenHeight = height;
 	_vgaBuffer = new byte[_screenWidth * _screenHeight];


Commit: 66c55db9f056a1c5c74e82e84650ac7fbbe4d899
    https://github.com/scummvm/scummvm/commit/66c55db9f056a1c5c74e82e84650ac7fbbe4d899
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix typos and whitespace

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 24ebfbf..aac8336 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -27,7 +27,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "example2");
 	DebugMan.addDebugChannel(kDMDebugExample, "example", "example desc");
 
-	// regiser random source
+	// register random source
 	_rnd = new Common::RandomSource("quux");
 
 	debug("DMEngine::DMEngine");
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 6ddf966..292ca02 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -4,7 +4,11 @@
 
 namespace DM {
 DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _dungeonDataSize(0), _dungeonData(NULL) {}
-DungeonMan::~DungeonMan() { delete[] _dungeonData; }
+
+DungeonMan::~DungeonMan() {
+	delete[] _dungeonData;
+}
+
 void DungeonMan::loadDungeonFile() {
 	Common::File f;
 	f.open("Dungeon.dat");


Commit: 4a8b34e993729dd90d12b1717977d8c4945e9325
    https://github.com/scummvm/scummvm/commit/4a8b34e993729dd90d12b1717977d8c4945e9325
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add the original palettes, edit palette loading accordingly

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index aac8336..53ed3de 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -16,6 +16,7 @@
 
 namespace DM {
 
+
 DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	// Do not load data files
 	// Do not initialize graphics here
@@ -56,38 +57,20 @@ Common::Error DMEngine::run() {
 	_displayMan->loadGraphics();
 	_dungeonMan->loadDungeonFile();
 
+	_displayMan->loadPalette(palCredits);
 
-
-
-	byte *palette = new byte[256 * 3];
-	for (int i = 0; i < 16; ++i)
-		palette[i * 3] = palette[i * 3 + 1] = palette[i * 3 + 2] = i * 16;
-
-	_displayMan->setPalette(palette, 16);
-
-	byte *buffer = new byte[320 * 200];
-	for (int i = 0; i < 320 * 100; ++i)
-		buffer[i] = 4;
-	for (int i = 320 * 100; i < 320 * 200; ++i)
-		buffer[i] = 6;
-
-	_system->copyRectToScreen(buffer, 320, 0, 0, 320, 200);
-	_system->updateScreen();
-
-
-	uint16 width = _displayMan->getImageWidth(75);
-	uint16 height = _displayMan->getImageHeight(75);
+	uint16 width = _displayMan->getImageWidth(1);
+	uint16 height = _displayMan->getImageHeight(1);
 	byte *cleanByteImg0Data = new byte[width * height];
-	_displayMan->loadIntoBitmap(75, cleanByteImg0Data);
-	_displayMan->blitToScreen(cleanByteImg0Data, width, height, 30, 30);
+	_displayMan->loadIntoBitmap(1, cleanByteImg0Data);
+	_displayMan->blitToScreen(cleanByteImg0Data, width, height, 0, 0);
 
 
 	while (true) {
 		_displayMan->updateScreen();
+		_system->delayMillis(10);
 	}
 
-
-	delete[] buffer;
 	delete[] cleanByteImg0Data;
 
 	return Common::kNoError;
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 705939c..35f6493 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -23,7 +23,6 @@ public:
 	~DMEngine();
 
 	virtual Common::Error run();
-	Common::Error go();
 
 private:
 	Console *_console;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 577251c..846f4bc 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -7,21 +7,35 @@
 
 using namespace DM;
 
+// this is for the Amiga version, later when we add support for more versions, this will have to be renamed
+uint16 dmPalettes[10][16] = {
+	{0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0},
+	{0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x000, 0xAAA, 0x00F, 0xFFF},
+	{0x006, 0x0AA, 0xFF6, 0x840, 0xFF8, 0x000, 0x080, 0xA00, 0xC84, 0xFFA, 0xF84, 0xFC0, 0xFA0, 0x000, 0x620, 0xFFC},
+	{0x000, 0x666, 0x888, 0x840, 0xCA8, 0x0C0, 0x080, 0x0A0, 0x864, 0xF00, 0xA86, 0x642, 0x444, 0xAAA, 0x620, 0xFFF},
+	{0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x444, 0xAAA, 0x00F, 0xFFF},
+	{0x000, 0x444, 0x666, 0x620, 0x0CC, 0x820, 0x060, 0x0A0, 0xC00, 0x000, 0x000, 0xFC0, 0x222, 0x888, 0x00C, 0xCCC},
+	{0x000, 0x222, 0x444, 0x420, 0x0CC, 0x620, 0x040, 0x080, 0xA00, 0x000, 0x000, 0xFA0, 0x000, 0x666, 0x00A, 0xAAA},
+	{0x000, 0x000, 0x222, 0x200, 0x0CC, 0x420, 0x020, 0x060, 0x800, 0x000, 0x000, 0xC80, 0x000, 0x444, 0x008, 0x888},
+	{0x000, 0x000, 0x000, 0x000, 0x0CC, 0x200, 0x000, 0x040, 0x600, 0x000, 0x000, 0xA60, 0x000, 0x222, 0x006, 0x666},
+	{0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444}
+};
+
+
 DisplayMan::DisplayMan(DMEngine *dmEngine) :
-	_vm(dmEngine), _currPalette(NULL), _screenWidth(0), _screenHeight(0),
+	_vm(dmEngine), _currPalette(palSwoosh), _screenWidth(0), _screenHeight(0),
 	_vgaBuffer(0), _itemCount(0), _indexBytePos(NULL), _compressedData(NULL) {}
 
 DisplayMan::~DisplayMan() {
 	delete[] _compressedData;
 	delete[] _indexBytePos;
-	delete[] _currPalette;
 	delete[] _vgaBuffer;
 }
 
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
-	_currPalette = new byte[256 * 3];
 	_screenWidth = width;
 	_screenHeight = height;
+	loadPalette(palSwoosh);
 	_vgaBuffer = new byte[_screenWidth * _screenHeight];
 	memset(_vgaBuffer, 0, width * height);
 }
@@ -45,9 +59,14 @@ void DisplayMan::loadGraphics() {
 	f.close();
 }
 
-void DisplayMan::setPalette(byte *buff, uint16 colorCount) {
-	memcpy(_currPalette, buff, sizeof(byte) * colorCount * 3);
-	_vm->_system->getPaletteManager()->setPalette(buff, 0, colorCount);
+void DisplayMan::loadPalette(dmPaletteEnum palette) {
+	byte colorPalette[16 * 3];
+	for (int i = 0; i < 16; ++i) {
+		colorPalette[i * 3] = (dmPalettes[palette][i] >> 8) * (256 / 16);
+		colorPalette[i * 3 + 1] = (dmPalettes[palette][i] >> 4) * (256 / 16);
+		colorPalette[i * 3 + 2] = dmPalettes[palette][i] * (256 / 16);
+	}
+	_vm->_system->getPaletteManager()->setPalette(colorPalette, 0, 16);
 }
 
 #define TOBE2(byte1, byte2) ((((uint16)(byte1)) << 8) | (uint16)(byte2))
@@ -103,7 +122,6 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
 void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, uint16 destX, uint16 destY) {
 	for (uint16 y = 0; y < srcHeight; ++y)
 		memcpy(getCurrentVgaBuffer() + ((y + destY) * _screenWidth + destX), srcBitmap + y * srcWidth, srcWidth * sizeof(byte));
-
 }
 
 void DisplayMan::updateScreen() {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 98d035b..acdabfa 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -6,9 +6,23 @@
 
 namespace DM {
 
+enum dmPaletteEnum {
+	palSwoosh = 0,
+	palMousePointer = 1,
+	palCredits = 2,
+	palEntrance = 3,
+	palDungeonView0 = 4,
+	palDungeonView1 = 5,
+	palDungeonView2 = 6,
+	palDungeonView3 = 7,
+	palDungeonView4 = 8,
+	palDungeonView5 = 9,
+};
+
+
 class DisplayMan {
 	DMEngine *_vm;
-	byte *_currPalette;
+	dmPaletteEnum _currPalette;
 	uint16 _screenWidth;
 	uint16 _screenHeight;
 	byte *_vgaBuffer;
@@ -22,7 +36,7 @@ public:
 	~DisplayMan();
 	void setUpScreens(uint16 width, uint16 height);
 	void loadGraphics();
-	void setPalette(byte *buff, uint16 colorCount);
+	void loadPalette(dmPaletteEnum palette);
 	void loadIntoBitmap(uint16 index, byte *destBitmap);
 	uint16 getImageWidth(uint16 index);
 	uint16 getImageHeight(uint16 index);


Commit: 77cd7df08d31aecaae7390f7f12151f82e47dbac
    https://github.com/scummvm/scummvm/commit/77cd7df08d31aecaae7390f7f12151f82e47dbac
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add support for drawing portions of bitmaps

Create Frame structure and drawFrame(..) convenience method, also
DisplayMan unpacks all the bitmaps with unpackGraphics()

Changed paths:
    engines/dm/dm.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 53ed3de..e30aace 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -57,6 +57,7 @@ Common::Error DMEngine::run() {
 	_displayMan->loadGraphics();
 	_dungeonMan->loadDungeonFile();
 
+	/*
 	_displayMan->loadPalette(palCredits);
 
 	uint16 width = _displayMan->getImageWidth(1);
@@ -64,14 +65,16 @@ Common::Error DMEngine::run() {
 	byte *cleanByteImg0Data = new byte[width * height];
 	_displayMan->loadIntoBitmap(1, cleanByteImg0Data);
 	_displayMan->blitToScreen(cleanByteImg0Data, width, height, 0, 0);
+	delete[] cleanByteImg0Data;
+	*/
 
 
 	while (true) {
+		_displayMan->drawDungeon();
 		_displayMan->updateScreen();
 		_system->delayMillis(10);
 	}
 
-	delete[] cleanByteImg0Data;
 
 	return Common::kNoError;
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 846f4bc..52cc787 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -5,7 +5,8 @@
 #include "graphics/palette.h"
 #include "common/endian.h"
 
-using namespace DM;
+
+namespace DM {
 
 // this is for the Amiga version, later when we add support for more versions, this will have to be renamed
 uint16 dmPalettes[10][16] = {
@@ -21,15 +22,36 @@ uint16 dmPalettes[10][16] = {
 	{0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444}
 };
 
+enum GraphicIndice {
+	FloorGraphIndice = 75,
+	CeilingGraphIndice = 76
+};
+
+struct Frame {
+	/*	this might have to be removed, depends on if the game uses frames with multiple bitmaps
+		If so, then GraphIndice enum will have to be moved to be available from outside gfx.cpp*/
+	GraphicIndice graphIndice;
+	// srcWidth and srcHeight (present in the original sources) is redundant here, can be deduced from gaphicsIndice
+	uint16 srcFromX, srcToX, srcFromY, srcToY;
+	uint16 destX, destY;
+};
+
+Frame ceilingFrame = {CeilingGraphIndice, 0, 223, 0, 28, 0, 0};
+
+}
+
+using namespace DM;
 
 DisplayMan::DisplayMan(DMEngine *dmEngine) :
 	_vm(dmEngine), _currPalette(palSwoosh), _screenWidth(0), _screenHeight(0),
-	_vgaBuffer(0), _itemCount(0), _indexBytePos(NULL), _compressedData(NULL) {}
+	_vgaBuffer(NULL), _itemCount(0), _packedItemPos(NULL), _packedBitmaps(NULL),
+	_unpackedBitmaps(NULL) {}
 
 DisplayMan::~DisplayMan() {
-	delete[] _compressedData;
-	delete[] _indexBytePos;
+	delete[] _packedBitmaps;
+	delete[] _packedItemPos;
 	delete[] _vgaBuffer;
+	delete[] _unpackedBitmaps;
 }
 
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
@@ -45,21 +67,47 @@ void DisplayMan::loadGraphics() {
 	f.open("graphics.dat");
 
 	_itemCount = f.readUint16BE();
-	_indexBytePos = new uint32[_itemCount + 1];
-	_indexBytePos[0] = 0;
+	_packedItemPos = new uint32[_itemCount + 1];
+	_packedItemPos[0] = 0;
 	for (uint16 i = 1; i < _itemCount + 1; ++i)
-		_indexBytePos[i] = f.readUint16BE() + _indexBytePos[i - 1];
+		_packedItemPos[i] = f.readUint16BE() + _packedItemPos[i - 1];
 
-	_compressedData = new uint8[_indexBytePos[_itemCount]];
+	_packedBitmaps = new uint8[_packedItemPos[_itemCount]];
 
 	f.seek(2 + _itemCount * 4);
-	for (uint32 i = 0; i < _indexBytePos[_itemCount]; ++i)
-		_compressedData[i] = f.readByte();
+	for (uint32 i = 0; i < _packedItemPos[_itemCount]; ++i)
+		_packedBitmaps[i] = f.readByte();
 
 	f.close();
+
+	unpackGraphics();
+}
+
+void DisplayMan::unpackGraphics() {
+	uint32 unpackedBitmapsSize = 0;
+	for (uint16 i = 0; i <= 20; ++i)
+		unpackedBitmapsSize += getImageWidth(i) * getImageHeight(i);
+	for (uint16 i = 22; i <= 532; ++i)
+		unpackedBitmapsSize += getImageWidth(i) * getImageHeight(i);
+	_unpackedBitmaps = new byte*[533];
+	// graphics items go from 0-20 and 22-532 inclusive, _unpackedItemPos 21 and 22 are there for indexing convenience
+	_unpackedBitmaps[0] = new byte[unpackedBitmapsSize];
+	loadIntoBitmap(0, _unpackedBitmaps[0]);
+	for (uint16 i = 1; i <= 20; ++i) {
+		_unpackedBitmaps[i] = _unpackedBitmaps[i - 1] + getImageWidth(i - 1) * getImageHeight(i - 1);
+		loadIntoBitmap(i, _unpackedBitmaps[i]);
+	}
+	_unpackedBitmaps[22] = _unpackedBitmaps[20] + getImageWidth(20) * getImageHeight(20);
+	for (uint16 i = 23; i < 533; ++i) {
+		_unpackedBitmaps[i] = _unpackedBitmaps[i - 1] + getImageWidth(i - 1) * getImageHeight(i - 1);
+		loadIntoBitmap(i, _unpackedBitmaps[i]);
+	}
 }
 
 void DisplayMan::loadPalette(dmPaletteEnum palette) {
+	if (_currPalette == palette)
+		return;
+
 	byte colorPalette[16 * 3];
 	for (int i = 0; i < 16; ++i) {
 		colorPalette[i * 3] = (dmPalettes[palette][i] >> 8) * (256 / 16);
@@ -67,12 +115,13 @@ void DisplayMan::loadPalette(dmPaletteEnum palette) {
 		colorPalette[i * 3 + 2] = dmPalettes[palette][i] * (256 / 16);
 	}
 	_vm->_system->getPaletteManager()->setPalette(colorPalette, 0, 16);
+	_currPalette = palette;
 }
 
 #define TOBE2(byte1, byte2) ((((uint16)(byte1)) << 8) | (uint16)(byte2))
 
 void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
-	uint8 *data = _compressedData + _indexBytePos[index];
+	uint8 *data = _packedBitmaps + _packedItemPos[index];
 	uint16 width = TOBE2(data[0], data[1]);
 	uint16 height = TOBE2(data[2], data[3]);
 	uint16 nextByteIndex = 4;
@@ -119,9 +168,18 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
 	}
 }
 
-void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, uint16 destX, uint16 destY) {
-	for (uint16 y = 0; y < srcHeight; ++y)
-		memcpy(getCurrentVgaBuffer() + ((y + destY) * _screenWidth + destX), srcBitmap + y * srcWidth, srcWidth * sizeof(byte));
+void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
+							  int16 srcWidth, uint16 destX, uint16 destY,
+							  byte *destBitmap, uint16 destWidth) {
+	for (uint16 y = 0; y < srcToY - srcFromY; ++y)
+		memcpy(destBitmap + destWidth * (y + destY) + destX,
+			   srcBitmap + srcWidth * (y + srcFromY) + srcFromX,
+			   sizeof(byte) * (srcToX - srcFromX));
+}
+
+void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
+							  int16 srcWidth, uint16 destX, uint16 destY) {
+	blitToBitmap(srcBitmap, srcFromX, srcToX, srcFromY, srcToY, srcWidth, destX, destY, getCurrentVgaBuffer(), _screenWidth);
 }
 
 void DisplayMan::updateScreen() {
@@ -134,12 +192,20 @@ byte *DisplayMan::getCurrentVgaBuffer() {
 }
 
 uint16 DisplayMan::getImageWidth(uint16 index) {
-	uint8 *data = _compressedData + _indexBytePos[index];
+	byte *data = _packedBitmaps + _packedItemPos[index];
 	return TOBE2(data[0], data[1]);
 }
 
 uint16 DisplayMan::getImageHeight(uint16 index) {
-	uint8 *data = _compressedData + _indexBytePos[index];
+	uint8 *data = _packedBitmaps + _packedItemPos[index];
 	return TOBE2(data[2], data[3]);
 }
 
+void DisplayMan::drawFrame(Frame &f) {
+	blitToScreen(_unpackedBitmaps[f.graphIndice], f.srcFromX, f.srcToX, f.srcFromY, f.srcToY, getImageWidth(f.graphIndice), f.destX, f.destY);
+}
+
+void DisplayMan::drawDungeon() {
+	loadPalette(palDungeonView0);
+	drawFrame(ceilingFrame);
+}
\ No newline at end of file
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index acdabfa..f52381e 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -6,6 +6,8 @@
 
 namespace DM {
 
+struct Frame;
+
 enum dmPaletteEnum {
 	palSwoosh = 0,
 	palMousePointer = 1,
@@ -27,22 +29,34 @@ class DisplayMan {
 	uint16 _screenHeight;
 	byte *_vgaBuffer;
 	uint16 _itemCount;
-	uint32 *_indexBytePos;
-	uint8 *_compressedData;
+	// TODO: will probably be redundant
+	uint32 *_packedItemPos;
+	// TODO: will probably be reundant
+	byte *_packedBitmaps; // TODO: this doesn't not contaion graphics exclusively, will have to be moved
 	DisplayMan(const DisplayMan &other); // no implementation on purpose
 	void operator=(const DisplayMan &rhs); // no implementation on purpose
+
+
+	byte **_unpackedBitmaps;
+	void unpackGraphics();
+	void drawFrame(Frame &f);
 public:
 	DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
 	void setUpScreens(uint16 width, uint16 height);
 	void loadGraphics();
 	void loadPalette(dmPaletteEnum palette);
+	// TODO: will probably be redundant with public visibility
 	void loadIntoBitmap(uint16 index, byte *destBitmap);
 	uint16 getImageWidth(uint16 index);
 	uint16 getImageHeight(uint16 index);
-	void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, uint16 destX, uint16 destY);
+	void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
+								  int16 srcWidth, uint16 destX, uint16 destY, byte *destBitmap, uint16 destWidth);
+	inline void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
+								  int16 srcWidth, uint16 destX, uint16 destY);
 	byte *getCurrentVgaBuffer();
 	void updateScreen();
+	void drawDungeon();
 };
 
 }


Commit: cb2bb82b32ade022eb626c6b8cc580abc5b9df8d
    https://github.com/scummvm/scummvm/commit/cb2bb82b32ade022eb626c6b8cc580abc5b9df8d
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add support for transparency in blitting

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 52cc787..e3faf94 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -22,6 +22,7 @@ uint16 dmPalettes[10][16] = {
 	{0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444}
 };
 
+
 enum GraphicIndice {
 	FloorGraphIndice = 75,
 	CeilingGraphIndice = 76
@@ -34,9 +35,10 @@ struct Frame {
 	// srcWidth and srcHeight (present in the original sources) is redundant here, can be deduced from gaphicsIndice
 	uint16 srcFromX, srcToX, srcFromY, srcToY;
 	uint16 destX, destY;
+	Color transparent;
 };
 
-Frame ceilingFrame = {CeilingGraphIndice, 0, 223, 0, 28, 0, 0};
+Frame ceilingFrame = {CeilingGraphIndice, 0, 223, 0, 28, 0, 0, colorFlesh};
 
 }
 
@@ -170,16 +172,18 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
 
 void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
 							  int16 srcWidth, uint16 destX, uint16 destY,
-							  byte *destBitmap, uint16 destWidth) {
+							  byte *destBitmap, uint16 destWidth, Color transparent) {
 	for (uint16 y = 0; y < srcToY - srcFromY; ++y)
-		memcpy(destBitmap + destWidth * (y + destY) + destX,
-			   srcBitmap + srcWidth * (y + srcFromY) + srcFromX,
-			   sizeof(byte) * (srcToX - srcFromX));
+		for (uint16 x = 0; x < srcToX - srcFromX; ++x) {
+			byte srcPixel = srcBitmap[srcWidth*(y + srcFromY) + srcFromX + x];
+			if (srcPixel != transparent)
+				destBitmap[destWidth * (y + destY) + destX + x] = srcPixel;
+		}
 }
 
 void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
-							  int16 srcWidth, uint16 destX, uint16 destY) {
-	blitToBitmap(srcBitmap, srcFromX, srcToX, srcFromY, srcToY, srcWidth, destX, destY, getCurrentVgaBuffer(), _screenWidth);
+							  int16 srcWidth, uint16 destX, uint16 destY, Color transparent) {
+	blitToBitmap(srcBitmap, srcFromX, srcToX, srcFromY, srcToY, srcWidth, destX, destY, getCurrentVgaBuffer(), _screenWidth, transparent);
 }
 
 void DisplayMan::updateScreen() {
@@ -202,7 +206,7 @@ uint16 DisplayMan::getImageHeight(uint16 index) {
 }
 
 void DisplayMan::drawFrame(Frame &f) {
-	blitToScreen(_unpackedBitmaps[f.graphIndice], f.srcFromX, f.srcToX, f.srcFromY, f.srcToY, getImageWidth(f.graphIndice), f.destX, f.destY);
+	blitToScreen(_unpackedBitmaps[f.graphIndice], f.srcFromX, f.srcToX, f.srcFromY, f.srcToY, getImageWidth(f.graphIndice), f.destX, f.destY, f.transparent);
 }
 
 void DisplayMan::drawDungeon() {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index f52381e..3ecffb1 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -7,6 +7,25 @@
 namespace DM {
 
 struct Frame;
+enum Color {
+	colorNoTransparency = 255,
+	colorBlack = 0,
+	colorDarkGary = 1,
+	colorLightGray = 2,
+	colorDarkBrown = 3,
+	colorCyan = 4,
+	colorLightBrown = 5,
+	colorDarkGreen = 6,
+	colorLightGreen = 7,
+	colorRed = 8,
+	colorGold = 9,
+	colorFlesh = 10,
+	colorYellow = 11,
+	colorDarkestGray = 12,
+	colorLightestGray = 13,
+	colorBlue = 14,
+	colorWhite = 15
+};
 
 enum dmPaletteEnum {
 	palSwoosh = 0,
@@ -51,9 +70,9 @@ public:
 	uint16 getImageWidth(uint16 index);
 	uint16 getImageHeight(uint16 index);
 	void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
-								  int16 srcWidth, uint16 destX, uint16 destY, byte *destBitmap, uint16 destWidth);
+								  int16 srcWidth, uint16 destX, uint16 destY, byte *destBitmap, uint16 destWidth, Color transparent = colorNoTransparency);
 	inline void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
-								  int16 srcWidth, uint16 destX, uint16 destY);
+								  int16 srcWidth, uint16 destX, uint16 destY, Color transparent = colorNoTransparency);
 	byte *getCurrentVgaBuffer();
 	void updateScreen();
 	void drawDungeon();


Commit: 18ff2e9940f584041798af670a07c381a02918aa
    https://github.com/scummvm/scummvm/commit/18ff2e9940f584041798af670a07c381a02918aa
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor DisplayMan::DrawFrame and Frame POD

Changed paths:
    engines/dm/dm.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index e30aace..1909b7e 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -57,9 +57,9 @@ Common::Error DMEngine::run() {
 	_displayMan->loadGraphics();
 	_dungeonMan->loadDungeonFile();
 
-	/*
 	_displayMan->loadPalette(palCredits);
 
+	/*
 	uint16 width = _displayMan->getImageWidth(1);
 	uint16 height = _displayMan->getImageHeight(1);
 	byte *cleanByteImg0Data = new byte[width * height];
@@ -68,8 +68,8 @@ Common::Error DMEngine::run() {
 	delete[] cleanByteImg0Data;
 	*/
 
-
 	while (true) {
+		_displayMan->clearScreen(colorBlack);
 		_displayMan->drawDungeon();
 		_displayMan->updateScreen();
 		_system->delayMillis(10);
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index e3faf94..f441214 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -29,16 +29,15 @@ enum GraphicIndice {
 };
 
 struct Frame {
-	/*	this might have to be removed, depends on if the game uses frames with multiple bitmaps
-		If so, then GraphIndice enum will have to be moved to be available from outside gfx.cpp*/
-	GraphicIndice graphIndice;
 	// srcWidth and srcHeight (present in the original sources) is redundant here, can be deduced from gaphicsIndice
+	// these coorinates are inclusive boundaries, when blitting you gotta add +1 to srcTo fields
 	uint16 srcFromX, srcToX, srcFromY, srcToY;
+	uint16 srcWidth, srcHeight;
 	uint16 destX, destY;
-	Color transparent;
 };
 
-Frame ceilingFrame = {CeilingGraphIndice, 0, 223, 0, 28, 0, 0, colorFlesh};
+Frame ceilingFrame = {0, 223, 0, 28, 224, 29, 0, 0};
+Frame floorFrame = {0, 223, 66, 135, 224, 70, 0, 0};
 
 }
 
@@ -61,7 +60,7 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) {
 	_screenHeight = height;
 	loadPalette(palSwoosh);
 	_vgaBuffer = new byte[_screenWidth * _screenHeight];
-	memset(_vgaBuffer, 0, width * height);
+	clearScreen(colorBlack);
 }
 
 void DisplayMan::loadGraphics() {
@@ -205,11 +204,19 @@ uint16 DisplayMan::getImageHeight(uint16 index) {
 	return TOBE2(data[2], data[3]);
 }
 
-void DisplayMan::drawFrame(Frame &f) {
-	blitToScreen(_unpackedBitmaps[f.graphIndice], f.srcFromX, f.srcToX, f.srcFromY, f.srcToY, getImageWidth(f.graphIndice), f.destX, f.destY, f.transparent);
+void DisplayMan::drawFrameToScreen(byte *bitmap, Frame &f, Color transparent) {
+	blitToScreen(bitmap, f.srcFromX, f.srcToX + 1, f.srcFromY, f.srcToY + 1, f.srcWidth, f.destX, f.destY, transparent);
+}
+
+void DisplayMan::drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, byte *destBitmap, uint16 destWidth) {
+	blitToBitmap(bitmap, f.srcFromX, f.srcToX + 1, f.srcFromY, f.srcToY + 1, f.srcWidth, f.destX, f.destY, destBitmap, destWidth, transparent);
 }
 
 void DisplayMan::drawDungeon() {
 	loadPalette(palDungeonView0);
-	drawFrame(ceilingFrame);
+	drawFrameToScreen(_unpackedBitmaps[CeilingGraphIndice], ceilingFrame, colorFlesh);
+}
+
+void DisplayMan::clearScreen(Color color) {
+	memset(getCurrentVgaBuffer(), color, sizeof(byte) * _screenWidth * _screenHeight);
 }
\ No newline at end of file
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 3ecffb1..e479c6c 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -58,7 +58,8 @@ class DisplayMan {
 
 	byte **_unpackedBitmaps;
 	void unpackGraphics();
-	void drawFrame(Frame &f);
+	inline void drawFrameToScreen(byte *bitmap, Frame &f, Color transparent);
+	inline void drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, byte *destBitmap, uint16 destWidth);
 public:
 	DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
@@ -72,10 +73,11 @@ public:
 	void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
 								  int16 srcWidth, uint16 destX, uint16 destY, byte *destBitmap, uint16 destWidth, Color transparent = colorNoTransparency);
 	inline void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
-								  int16 srcWidth, uint16 destX, uint16 destY, Color transparent = colorNoTransparency);
+										 int16 srcWidth, uint16 destX, uint16 destY, Color transparent = colorNoTransparency);
 	byte *getCurrentVgaBuffer();
 	void updateScreen();
 	void drawDungeon();
+	void clearScreen(Color color);
 };
 
 }


Commit: c725fdec9eececc155d0c39bf905910100baeea0
    https://github.com/scummvm/scummvm/commit/c725fdec9eececc155d0c39bf905910100baeea0
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add horizontal and vertical bitmap flipping

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index f441214..761585c 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -180,6 +180,30 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, u
 		}
 }
 
+
+void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) {
+	for(uint16 y = 0; y < height / 2; ++y)
+		for (uint16 x = 0; x < width; ++x) {
+			byte tmp;
+			tmp = bitmap[y*width + x];
+			bitmap[y*width + x] = bitmap[y*width + width - 1 - x];
+			bitmap[y*width + width - 1 - x] = tmp;
+		}
+}
+
+void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) {
+	byte *tmp = new byte[width];
+
+	for (uint16 y = 0; y < height / 2; ++y) {
+		memcpy(tmp, bitmap + y * width, sizeof(byte) * width);
+		memcpy(bitmap + y * width, bitmap + (height - 1 - y) * width, sizeof(byte) * width);
+		memcpy(bitmap + y * width, tmp, sizeof(byte) * width);
+		memcpy(bitmap + (height - 1 - y) * width, tmp, sizeof(byte) * width);
+	}
+
+	delete[] tmp;
+}
+
 void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
 							  int16 srcWidth, uint16 destX, uint16 destY, Color transparent) {
 	blitToBitmap(srcBitmap, srcFromX, srcToX, srcFromY, srcToY, srcWidth, destX, destY, getCurrentVgaBuffer(), _screenWidth, transparent);
@@ -212,11 +236,25 @@ void DisplayMan::drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, by
 	blitToBitmap(bitmap, f.srcFromX, f.srcToX + 1, f.srcFromY, f.srcToY + 1, f.srcWidth, f.destX, f.destY, destBitmap, destWidth, transparent);
 }
 
+
 void DisplayMan::drawDungeon() {
 	loadPalette(palDungeonView0);
+
 	drawFrameToScreen(_unpackedBitmaps[CeilingGraphIndice], ceilingFrame, colorFlesh);
+
+	byte *tmpBitmap = new byte[305 * 111]; // because original source reasons
+	clearBitmap(tmpBitmap, 111, 305, colorBlack);
+	blitToBitmap(_unpackedBitmaps[FloorGraphIndice], 0, getImageWidth(FloorGraphIndice), 0, getImageHeight(FloorGraphIndice), getImageWidth(FloorGraphIndice), 0, 0, tmpBitmap, 305);
+	flipBitmapHorizontal(tmpBitmap, 305, 111);
+	drawFrameToScreen(tmpBitmap, floorFrame, colorFlesh);
+
+	delete[] tmpBitmap;
 }
 
 void DisplayMan::clearScreen(Color color) {
 	memset(getCurrentVgaBuffer(), color, sizeof(byte) * _screenWidth * _screenHeight);
+}
+
+void DisplayMan::clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color) {
+	memset(bitmap, color, sizeof(byte) * width * height);
 }
\ No newline at end of file
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index e479c6c..39cfff9 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -58,8 +58,8 @@ class DisplayMan {
 
 	byte **_unpackedBitmaps;
 	void unpackGraphics();
-	inline void drawFrameToScreen(byte *bitmap, Frame &f, Color transparent);
-	inline void drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, byte *destBitmap, uint16 destWidth);
+	void drawFrameToScreen(byte *bitmap, Frame &f, Color transparent);
+	void drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, byte *destBitmap, uint16 destWidth);
 public:
 	DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
@@ -72,8 +72,11 @@ public:
 	uint16 getImageHeight(uint16 index);
 	void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
 								  int16 srcWidth, uint16 destX, uint16 destY, byte *destBitmap, uint16 destWidth, Color transparent = colorNoTransparency);
-	inline void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
-										 int16 srcWidth, uint16 destX, uint16 destY, Color transparent = colorNoTransparency);
+	void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
+								  int16 srcWidth, uint16 destX, uint16 destY, Color transparent = colorNoTransparency);
+	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
+	void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height);
+	void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color);
 	byte *getCurrentVgaBuffer();
 	void updateScreen();
 	void drawDungeon();


Commit: 64371787e28fba114dc5dff27c5c7d61bb2bc293
    https://github.com/scummvm/scummvm/commit/64371787e28fba114dc5dff27c5c7d61bb2bc293
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rewrite blitting methods, revise FRAME POD

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 1909b7e..a1b8dc0 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -59,20 +59,12 @@ Common::Error DMEngine::run() {
 
 	_displayMan->loadPalette(palCredits);
 
-	/*
-	uint16 width = _displayMan->getImageWidth(1);
-	uint16 height = _displayMan->getImageHeight(1);
-	byte *cleanByteImg0Data = new byte[width * height];
-	_displayMan->loadIntoBitmap(1, cleanByteImg0Data);
-	_displayMan->blitToScreen(cleanByteImg0Data, width, height, 0, 0);
-	delete[] cleanByteImg0Data;
-	*/
-
+	uint16 i = 0; //TODO: testing, please delete me
 	while (true) {
 		_displayMan->clearScreen(colorBlack);
-		_displayMan->drawDungeon();
+		_displayMan->drawDungeon(kDirNorth, i++, 0);
 		_displayMan->updateScreen();
-		_system->delayMillis(10);
+		_system->delayMillis(1000); //TODO: testing, please set me to 10
 	}
 
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 35f6493..22ef1ec 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -8,6 +8,13 @@
 
 namespace DM {
 
+enum direction {
+	kDirNorth = 0,
+	kDirEast = 1,
+	kDirSouth = 2,
+	kDirWest = 3
+};
+
 class Console;
 class DisplayMan;
 class DungeonMan;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 761585c..afed9bb 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -8,7 +8,7 @@
 
 namespace DM {
 
-// this is for the Amiga version, later when we add support for more versions, this will have to be renamed
+// TODO: this is ONLY for the Amiga version, name will have to be refactored
 uint16 dmPalettes[10][16] = {
 	{0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0},
 	{0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x000, 0xAAA, 0x00F, 0xFFF},
@@ -24,20 +24,19 @@ uint16 dmPalettes[10][16] = {
 
 
 enum GraphicIndice {
-	FloorGraphIndice = 75,
-	CeilingGraphIndice = 76
+	floorIndice = 75,
+	ceilingIndice = 76
 };
 
 struct Frame {
+	// FIXME: these bundaries are inclusive, workaround by adding +1 in the drawFrame methods
+	uint16 destFromX, destToX, destFromY, destToY;
 	// srcWidth and srcHeight (present in the original sources) is redundant here, can be deduced from gaphicsIndice
-	// these coorinates are inclusive boundaries, when blitting you gotta add +1 to srcTo fields
-	uint16 srcFromX, srcToX, srcFromY, srcToY;
-	uint16 srcWidth, srcHeight;
-	uint16 destX, destY;
+	uint16 srcX, srcY;
 };
 
-Frame ceilingFrame = {0, 223, 0, 28, 224, 29, 0, 0};
-Frame floorFrame = {0, 223, 66, 135, 224, 70, 0, 0};
+Frame ceilingFrame = {0, 223, 0, 28, 0, 0};
+Frame floorFrame = {0, 223, 66, 135, 0, 0};
 
 }
 
@@ -46,13 +45,13 @@ using namespace DM;
 DisplayMan::DisplayMan(DMEngine *dmEngine) :
 	_vm(dmEngine), _currPalette(palSwoosh), _screenWidth(0), _screenHeight(0),
 	_vgaBuffer(NULL), _itemCount(0), _packedItemPos(NULL), _packedBitmaps(NULL),
-	_unpackedBitmaps(NULL) {}
+	_bitmaps(NULL) {}
 
 DisplayMan::~DisplayMan() {
 	delete[] _packedBitmaps;
 	delete[] _packedItemPos;
 	delete[] _vgaBuffer;
-	delete[] _unpackedBitmaps;
+	delete[] _bitmaps;
 }
 
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
@@ -87,21 +86,21 @@ void DisplayMan::loadGraphics() {
 void DisplayMan::unpackGraphics() {
 	uint32 unpackedBitmapsSize = 0;
 	for (uint16 i = 0; i <= 20; ++i)
-		unpackedBitmapsSize += getImageWidth(i) * getImageHeight(i);
+		unpackedBitmapsSize += width(i) * height(i);
 	for (uint16 i = 22; i <= 532; ++i)
-		unpackedBitmapsSize += getImageWidth(i) * getImageHeight(i);
-	_unpackedBitmaps = new byte*[533];
+		unpackedBitmapsSize += width(i) * height(i);
 	// graphics items go from 0-20 and 22-532 inclusive, _unpackedItemPos 21 and 22 are there for indexing convenience
-	_unpackedBitmaps[0] = new byte[unpackedBitmapsSize];
-	loadIntoBitmap(0, _unpackedBitmaps[0]);
+	_bitmaps = new byte*[533];
+	_bitmaps[0] = new byte[unpackedBitmapsSize];
+	loadIntoBitmap(0, _bitmaps[0]);
 	for (uint16 i = 1; i <= 20; ++i) {
-		_unpackedBitmaps[i] = _unpackedBitmaps[i - 1] + getImageWidth(i - 1) * getImageHeight(i - 1);
-		loadIntoBitmap(i, _unpackedBitmaps[i]);
+		_bitmaps[i] = _bitmaps[i - 1] + width(i - 1) * height(i - 1);
+		loadIntoBitmap(i, _bitmaps[i]);
 	}
-	_unpackedBitmaps[22] = _unpackedBitmaps[20] + getImageWidth(20) * getImageHeight(20);
+	_bitmaps[22] = _bitmaps[20] + width(20) * height(20);
 	for (uint16 i = 23; i < 533; ++i) {
-		_unpackedBitmaps[i] = _unpackedBitmaps[i - 1] + getImageWidth(i - 1) * getImageHeight(i - 1);
-		loadIntoBitmap(i, _unpackedBitmaps[i]);
+		_bitmaps[i] = _bitmaps[i - 1] + width(i - 1) * height(i - 1);
+		loadIntoBitmap(i, _bitmaps[i]);
 	}
 }
 
@@ -169,21 +168,33 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
 	}
 }
 
-void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
-							  int16 srcWidth, uint16 destX, uint16 destY,
-							  byte *destBitmap, uint16 destWidth, Color transparent) {
-	for (uint16 y = 0; y < srcToY - srcFromY; ++y)
-		for (uint16 x = 0; x < srcToX - srcFromX; ++x) {
-			byte srcPixel = srcBitmap[srcWidth*(y + srcFromY) + srcFromX + x];
+void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
+							  byte *destBitmap, uint16 destWidth,
+							  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
+							  Color transparent) {
+	for (uint16 y = 0; y < destToY - destFromY; ++y)
+		for (uint16 x = 0; x < destToX - destFromX; ++x) {
+			byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x];
 			if (srcPixel != transparent)
-				destBitmap[destWidth * (y + destY) + destX + x] = srcPixel;
+				destBitmap[destWidth * (y + destFromY) + destFromX + x] = srcPixel;
 		}
 }
 
+void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
+							  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
+							  Color transparent) {
+	blitToBitmap(srcBitmap, srcWidth, srcX, srcY,
+				 getCurrentVgaBuffer(), _screenWidth, destFromX, destToX, destFromY, destToY, transparent);
+}
 
-void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) {
-	for(uint16 y = 0; y < height / 2; ++y)
-		for (uint16 x = 0; x < width; ++x) {
+void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX, uint16 destY) {
+	for (uint16 y = 0; y < srcHeight; ++y)
+		memcpy(destBitmap + destWidth*(y + destY) + destX, srcBitmap + y * srcWidth, sizeof(byte)* srcWidth);
+}
+
+void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) {
+	for (uint16 y = 0; y < height; ++y)
+		for (uint16 x = 0; x < width / 2; ++x) {
 			byte tmp;
 			tmp = bitmap[y*width + x];
 			bitmap[y*width + x] = bitmap[y*width + width - 1 - x];
@@ -191,23 +202,19 @@ void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) {
 		}
 }
 
-void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) {
+void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) {
 	byte *tmp = new byte[width];
 
 	for (uint16 y = 0; y < height / 2; ++y) {
-		memcpy(tmp, bitmap + y * width, sizeof(byte) * width);
-		memcpy(bitmap + y * width, bitmap + (height - 1 - y) * width, sizeof(byte) * width);
-		memcpy(bitmap + y * width, tmp, sizeof(byte) * width);
-		memcpy(bitmap + (height - 1 - y) * width, tmp, sizeof(byte) * width);
+		memcpy(tmp, bitmap + y * width, width);
+		memcpy(bitmap + y * width, bitmap + (height - 1 - y) * width, width);
+		memcpy(bitmap + (height - 1 - y) * width, tmp, width);
 	}
 
 	delete[] tmp;
 }
 
-void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
-							  int16 srcWidth, uint16 destX, uint16 destY, Color transparent) {
-	blitToBitmap(srcBitmap, srcFromX, srcToX, srcFromY, srcToY, srcWidth, destX, destY, getCurrentVgaBuffer(), _screenWidth, transparent);
-}
+
 
 void DisplayMan::updateScreen() {
 	_vm->_system->copyRectToScreen(_vgaBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
@@ -218,35 +225,43 @@ byte *DisplayMan::getCurrentVgaBuffer() {
 	return _vgaBuffer;
 }
 
-uint16 DisplayMan::getImageWidth(uint16 index) {
+uint16 DisplayMan::width(uint16 index) {
 	byte *data = _packedBitmaps + _packedItemPos[index];
 	return TOBE2(data[0], data[1]);
 }
 
-uint16 DisplayMan::getImageHeight(uint16 index) {
+uint16 DisplayMan::height(uint16 index) {
 	uint8 *data = _packedBitmaps + _packedItemPos[index];
 	return TOBE2(data[2], data[3]);
 }
 
-void DisplayMan::drawFrameToScreen(byte *bitmap, Frame &f, Color transparent) {
-	blitToScreen(bitmap, f.srcFromX, f.srcToX + 1, f.srcFromY, f.srcToY + 1, f.srcWidth, f.destX, f.destY, transparent);
+void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth) {
+	blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX + 1, f.destFromY, f.destToY + 1, colorFlesh);
 }
 
-void DisplayMan::drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, byte *destBitmap, uint16 destWidth) {
-	blitToBitmap(bitmap, f.srcFromX, f.srcToX + 1, f.srcFromY, f.srcToY + 1, f.srcWidth, f.destX, f.destY, destBitmap, destWidth, transparent);
-}
 
 
-void DisplayMan::drawDungeon() {
+void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) {
 	loadPalette(palDungeonView0);
+	// TODO: this is a global variable, set from here
+	bool flippedWallAndFootprints = (posX + posY + dir) & 1;
+
+	// NOTE: this can hold every bitmap, width and height is "flexible"
+	byte  *tmpBitmap = new byte[305 * 111];
+	clearBitmap(tmpBitmap, 305, 111, colorBlack);
+
+	if (flippedWallAndFootprints) {
+		blitToBitmap(_bitmaps[floorIndice], width(floorIndice), height(floorIndice), tmpBitmap, width(floorIndice));
+		flipBitmapHorizontal(tmpBitmap, width(floorIndice), height(floorIndice));
+		drawWallSetBitmap(tmpBitmap, floorFrame, width(floorIndice));
+		drawWallSetBitmap(_bitmaps[ceilingIndice], ceilingFrame, width(ceilingIndice));
+	} else {
+		blitToBitmap(_bitmaps[ceilingIndice], width(ceilingIndice), height(ceilingIndice), tmpBitmap, width(ceilingIndice));
+		flipBitmapHorizontal(tmpBitmap, width(ceilingIndice), height(ceilingIndice));
+		drawWallSetBitmap(tmpBitmap, ceilingFrame, width(ceilingIndice));
+		drawWallSetBitmap(_bitmaps[floorIndice], floorFrame, width(floorIndice));
+	}
 
-	drawFrameToScreen(_unpackedBitmaps[CeilingGraphIndice], ceilingFrame, colorFlesh);
-
-	byte *tmpBitmap = new byte[305 * 111]; // because original source reasons
-	clearBitmap(tmpBitmap, 111, 305, colorBlack);
-	blitToBitmap(_unpackedBitmaps[FloorGraphIndice], 0, getImageWidth(FloorGraphIndice), 0, getImageHeight(FloorGraphIndice), getImageWidth(FloorGraphIndice), 0, 0, tmpBitmap, 305);
-	flipBitmapHorizontal(tmpBitmap, 305, 111);
-	drawFrameToScreen(tmpBitmap, floorFrame, colorFlesh);
 
 	delete[] tmpBitmap;
 }
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 39cfff9..f4d74ab 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -41,6 +41,8 @@ enum dmPaletteEnum {
 };
 
 
+
+
 class DisplayMan {
 	DMEngine *_vm;
 	dmPaletteEnum _currPalette;
@@ -48,39 +50,44 @@ class DisplayMan {
 	uint16 _screenHeight;
 	byte *_vgaBuffer;
 	uint16 _itemCount;
-	// TODO: will probably be redundant
 	uint32 *_packedItemPos;
-	// TODO: will probably be reundant
 	byte *_packedBitmaps; // TODO: this doesn't not contaion graphics exclusively, will have to be moved
 	DisplayMan(const DisplayMan &other); // no implementation on purpose
 	void operator=(const DisplayMan &rhs); // no implementation on purpose
 
-
-	byte **_unpackedBitmaps;
+	byte **_bitmaps;
+	byte *getCurrentVgaBuffer();
+	void loadIntoBitmap(uint16 index, byte *destBitmap);
 	void unpackGraphics();
-	void drawFrameToScreen(byte *bitmap, Frame &f, Color transparent);
-	void drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, byte *destBitmap, uint16 destWidth);
+	void drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth);
 public:
 	DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
 	void setUpScreens(uint16 width, uint16 height);
 	void loadGraphics();
 	void loadPalette(dmPaletteEnum palette);
-	// TODO: will probably be redundant with public visibility
-	void loadIntoBitmap(uint16 index, byte *destBitmap);
-	uint16 getImageWidth(uint16 index);
-	uint16 getImageHeight(uint16 index);
-	void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
-								  int16 srcWidth, uint16 destX, uint16 destY, byte *destBitmap, uint16 destWidth, Color transparent = colorNoTransparency);
-	void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY,
-								  int16 srcWidth, uint16 destX, uint16 destY, Color transparent = colorNoTransparency);
-	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
+
+	/// Gives the width of an IMG0 type item
+	uint16 width(uint16 index);
+	/// Gives the height of an IMG1 type item
+	uint16 height(uint16 index);
+
+	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
+					  byte *destBitmap, uint16 destWidth,
+					  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
+					  Color transparent = colorNoTransparency);
+	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0);
+	void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
+					  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
+					  Color transparent = colorNoTransparency);
+
 	void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height);
+	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
+
 	void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color);
-	byte *getCurrentVgaBuffer();
-	void updateScreen();
-	void drawDungeon();
 	void clearScreen(Color color);
+	void drawDungeon(direction dir, uint16 posX, uint16 posY);
+	void updateScreen();
 };
 
 }


Commit: 9823845c990bc23010c985706a26b491c2d0c21e
    https://github.com/scummvm/scummvm/commit/9823845c990bc23010c985706a26b491c2d0c21e
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix constant and global variable names according to coding conventions

Changed paths:
    engines/dm/dm.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index a1b8dc0..8f6f294 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -57,11 +57,11 @@ Common::Error DMEngine::run() {
 	_displayMan->loadGraphics();
 	_dungeonMan->loadDungeonFile();
 
-	_displayMan->loadPalette(palCredits);
+	_displayMan->loadPalette(kPalCredits);
 
 	uint16 i = 0; //TODO: testing, please delete me
 	while (true) {
-		_displayMan->clearScreen(colorBlack);
+		_displayMan->clearScreen(kColorBlack);
 		_displayMan->drawDungeon(kDirNorth, i++, 0);
 		_displayMan->updateScreen();
 		_system->delayMillis(1000); //TODO: testing, please set me to 10
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index afed9bb..b8e3ad6 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -24,8 +24,8 @@ uint16 dmPalettes[10][16] = {
 
 
 enum GraphicIndice {
-	floorIndice = 75,
-	ceilingIndice = 76
+	gFloorIndice = 75,
+	gCeilingIndice = 76
 };
 
 struct Frame {
@@ -35,15 +35,15 @@ struct Frame {
 	uint16 srcX, srcY;
 };
 
-Frame ceilingFrame = {0, 223, 0, 28, 0, 0};
-Frame floorFrame = {0, 223, 66, 135, 0, 0};
+Frame gCeilingFrame = {0, 223, 0, 28, 0, 0};
+Frame gFloorFrame = {0, 223, 66, 135, 0, 0};
 
 }
 
 using namespace DM;
 
 DisplayMan::DisplayMan(DMEngine *dmEngine) :
-	_vm(dmEngine), _currPalette(palSwoosh), _screenWidth(0), _screenHeight(0),
+	_vm(dmEngine), _currPalette(kPalSwoosh), _screenWidth(0), _screenHeight(0),
 	_vgaBuffer(NULL), _itemCount(0), _packedItemPos(NULL), _packedBitmaps(NULL),
 	_bitmaps(NULL) {}
 
@@ -57,9 +57,9 @@ DisplayMan::~DisplayMan() {
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
 	_screenWidth = width;
 	_screenHeight = height;
-	loadPalette(palSwoosh);
+	loadPalette(kPalSwoosh);
 	_vgaBuffer = new byte[_screenWidth * _screenHeight];
-	clearScreen(colorBlack);
+	clearScreen(kColorBlack);
 }
 
 void DisplayMan::loadGraphics() {
@@ -236,30 +236,30 @@ uint16 DisplayMan::height(uint16 index) {
 }
 
 void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth) {
-	blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX + 1, f.destFromY, f.destToY + 1, colorFlesh);
+	blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX + 1, f.destFromY, f.destToY + 1, kColorFlesh);
 }
 
 
 
 void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) {
-	loadPalette(palDungeonView0);
+	loadPalette(kPalDungeonView0);
 	// TODO: this is a global variable, set from here
 	bool flippedWallAndFootprints = (posX + posY + dir) & 1;
 
 	// NOTE: this can hold every bitmap, width and height is "flexible"
 	byte  *tmpBitmap = new byte[305 * 111];
-	clearBitmap(tmpBitmap, 305, 111, colorBlack);
+	clearBitmap(tmpBitmap, 305, 111, kColorBlack);
 
 	if (flippedWallAndFootprints) {
-		blitToBitmap(_bitmaps[floorIndice], width(floorIndice), height(floorIndice), tmpBitmap, width(floorIndice));
-		flipBitmapHorizontal(tmpBitmap, width(floorIndice), height(floorIndice));
-		drawWallSetBitmap(tmpBitmap, floorFrame, width(floorIndice));
-		drawWallSetBitmap(_bitmaps[ceilingIndice], ceilingFrame, width(ceilingIndice));
+		blitToBitmap(_bitmaps[gFloorIndice], width(gFloorIndice), height(gFloorIndice), tmpBitmap, width(gFloorIndice));
+		flipBitmapHorizontal(tmpBitmap, width(gFloorIndice), height(gFloorIndice));
+		drawWallSetBitmap(tmpBitmap, gFloorFrame, width(gFloorIndice));
+		drawWallSetBitmap(_bitmaps[gCeilingIndice], gCeilingFrame, width(gCeilingIndice));
 	} else {
-		blitToBitmap(_bitmaps[ceilingIndice], width(ceilingIndice), height(ceilingIndice), tmpBitmap, width(ceilingIndice));
-		flipBitmapHorizontal(tmpBitmap, width(ceilingIndice), height(ceilingIndice));
-		drawWallSetBitmap(tmpBitmap, ceilingFrame, width(ceilingIndice));
-		drawWallSetBitmap(_bitmaps[floorIndice], floorFrame, width(floorIndice));
+		blitToBitmap(_bitmaps[gCeilingIndice], width(gCeilingIndice), height(gCeilingIndice), tmpBitmap, width(gCeilingIndice));
+		flipBitmapHorizontal(tmpBitmap, width(gCeilingIndice), height(gCeilingIndice));
+		drawWallSetBitmap(tmpBitmap, gCeilingFrame, width(gCeilingIndice));
+		drawWallSetBitmap(_bitmaps[gFloorIndice], gFloorFrame, width(gFloorIndice));
 	}
 
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index f4d74ab..79a4afd 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -8,36 +8,36 @@ namespace DM {
 
 struct Frame;
 enum Color {
-	colorNoTransparency = 255,
-	colorBlack = 0,
-	colorDarkGary = 1,
-	colorLightGray = 2,
-	colorDarkBrown = 3,
-	colorCyan = 4,
-	colorLightBrown = 5,
-	colorDarkGreen = 6,
-	colorLightGreen = 7,
-	colorRed = 8,
-	colorGold = 9,
-	colorFlesh = 10,
-	colorYellow = 11,
-	colorDarkestGray = 12,
-	colorLightestGray = 13,
-	colorBlue = 14,
-	colorWhite = 15
+	kColorNoTransparency = 255,
+	kColorBlack = 0,
+	kColorDarkGary = 1,
+	kColorLightGray = 2,
+	kColorDarkBrown = 3,
+	kColorCyan = 4,
+	kColorLightBrown = 5,
+	kColorDarkGreen = 6,
+	kColorLightGreen = 7,
+	kColorRed = 8,
+	kColorGold = 9,
+	kColorFlesh = 10,
+	kColorYellow = 11,
+	kColorDarkestGray = 12,
+	kColorLightestGray = 13,
+	kColorBlue = 14,
+	kColorWhite = 15
 };
 
 enum dmPaletteEnum {
-	palSwoosh = 0,
-	palMousePointer = 1,
-	palCredits = 2,
-	palEntrance = 3,
-	palDungeonView0 = 4,
-	palDungeonView1 = 5,
-	palDungeonView2 = 6,
-	palDungeonView3 = 7,
-	palDungeonView4 = 8,
-	palDungeonView5 = 9,
+	kPalSwoosh = 0,
+	kPalMousePointer = 1,
+	kPalCredits = 2,
+	kPalEntrance = 3,
+	kPalDungeonView0 = 4,
+	kPalDungeonView1 = 5,
+	kPalDungeonView2 = 6,
+	kPalDungeonView3 = 7,
+	kPalDungeonView4 = 8,
+	kPalDungeonView5 = 9,
 };
 
 
@@ -75,11 +75,11 @@ public:
 	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 					  byte *destBitmap, uint16 destWidth,
 					  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
-					  Color transparent = colorNoTransparency);
+					  Color transparent = kColorNoTransparency);
 	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0);
 	void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 					  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
-					  Color transparent = colorNoTransparency);
+					  Color transparent = kColorNoTransparency);
 
 	void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height);
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);


Commit: 98a43792448fc937fa48dffd79adc0b1dda6cbf0
    https://github.com/scummvm/scummvm/commit/98a43792448fc937fa48dffd79adc0b1dda6cbf0
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Delete TOBE2 macro, use READ_BE_UINT16 instead

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index b8e3ad6..52e2e20 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -118,12 +118,11 @@ void DisplayMan::loadPalette(dmPaletteEnum palette) {
 	_currPalette = palette;
 }
 
-#define TOBE2(byte1, byte2) ((((uint16)(byte1)) << 8) | (uint16)(byte2))
 
 void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
 	uint8 *data = _packedBitmaps + _packedItemPos[index];
-	uint16 width = TOBE2(data[0], data[1]);
-	uint16 height = TOBE2(data[2], data[3]);
+	uint16 width = READ_BE_UINT16(data);
+	uint16 height = READ_BE_UINT16(data + 2);
 	uint16 nextByteIndex = 4;
 	for (uint16 k = 0; k < width * height;) {
 		uint8 nextByte = data[nextByteIndex++];
@@ -137,7 +136,7 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
 			for (int j = 0; j < byte1 + 1; ++j)
 				destBitmap[k++] = nibble2;
 		} else if (nibble1 == 0xC) {
-			uint16 word1 = TOBE2(data[nextByteIndex], data[nextByteIndex + 1]);
+			uint16 word1 = READ_BE_UINT16(data + nextByteIndex);
 			nextByteIndex += 2;
 			for (int j = 0; j < word1 + 1; ++j)
 				destBitmap[k++] = nibble2;
@@ -147,7 +146,7 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
 				destBitmap[k] = destBitmap[k - width];
 			destBitmap[k++] = nibble2;
 		} else if (nibble1 == 0xF) {
-			uint16 word1 = TOBE2(data[nextByteIndex], data[nextByteIndex + 1]);
+			uint16 word1 = READ_BE_UINT16(data + nextByteIndex);
 			nextByteIndex += 2;
 			for (int j = 0; j < word1 + 1; ++j, ++k)
 				destBitmap[k] = destBitmap[k - width];
@@ -227,12 +226,12 @@ byte *DisplayMan::getCurrentVgaBuffer() {
 
 uint16 DisplayMan::width(uint16 index) {
 	byte *data = _packedBitmaps + _packedItemPos[index];
-	return TOBE2(data[0], data[1]);
+	return READ_BE_UINT16(data);
 }
 
 uint16 DisplayMan::height(uint16 index) {
 	uint8 *data = _packedBitmaps + _packedItemPos[index];
-	return TOBE2(data[2], data[3]);
+	return READ_BE_UINT16(data + 2);
 }
 
 void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth) {


Commit: a8434fc165266fb6a788618cdf334b01be53c25e
    https://github.com/scummvm/scummvm/commit/a8434fc165266fb6a788618cdf334b01be53c25e
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add support for viewports with blitting

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 52e2e20..0ae3b25 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -38,6 +38,9 @@ struct Frame {
 Frame gCeilingFrame = {0, 223, 0, 28, 0, 0};
 Frame gFloorFrame = {0, 223, 66, 135, 0, 0};
 
+extern Viewport gDefultViewPort = {0, 0};
+extern Viewport gDungeonViewport = {0, 64};
+
 }
 
 using namespace DM;
@@ -170,20 +173,20 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
 void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 							  byte *destBitmap, uint16 destWidth,
 							  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
-							  Color transparent) {
+							  Color transparent, Viewport &destViewport) {
 	for (uint16 y = 0; y < destToY - destFromY; ++y)
 		for (uint16 x = 0; x < destToX - destFromX; ++x) {
 			byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x];
 			if (srcPixel != transparent)
-				destBitmap[destWidth * (y + destFromY) + destFromX + x] = srcPixel;
+				destBitmap[destWidth * (y + destFromY + destViewport.posY) + destFromX + x + destViewport.posX] = srcPixel;
 		}
 }
 
 void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 							  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
-							  Color transparent) {
+							  Color transparent, Viewport &viewport) {
 	blitToBitmap(srcBitmap, srcWidth, srcX, srcY,
-				 getCurrentVgaBuffer(), _screenWidth, destFromX, destToX, destFromY, destToY, transparent);
+				 getCurrentVgaBuffer(), _screenWidth, destFromX, destToX, destFromY, destToY, transparent, viewport);
 }
 
 void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX, uint16 destY) {
@@ -235,7 +238,7 @@ uint16 DisplayMan::height(uint16 index) {
 }
 
 void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth) {
-	blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX + 1, f.destFromY, f.destToY + 1, kColorFlesh);
+	blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX + 1, f.destFromY, f.destToY + 1, kColorFlesh, gDungeonViewport);
 }
 
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 79a4afd..34bb8cf 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -7,6 +7,7 @@
 namespace DM {
 
 struct Frame;
+
 enum Color {
 	kColorNoTransparency = 255,
 	kColorBlack = 0,
@@ -40,6 +41,13 @@ enum dmPaletteEnum {
 	kPalDungeonView5 = 9,
 };
 
+struct Viewport {
+	// TODO: should probably add width and height, seems redundant right meow
+	uint16 posX, posY;
+};
+
+extern Viewport gDefultViewPort;
+extern Viewport gDungeonViewport;
 
 
 
@@ -75,11 +83,11 @@ public:
 	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 					  byte *destBitmap, uint16 destWidth,
 					  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
-					  Color transparent = kColorNoTransparency);
+					  Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort);
 	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0);
 	void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 					  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
-					  Color transparent = kColorNoTransparency);
+					  Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort);
 
 	void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height);
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);


Commit: 4f9182507afb365638b33341fb797d82c3a50df0
    https://github.com/scummvm/scummvm/commit/4f9182507afb365638b33341fb797d82c3a50df0
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Implement Dungeon.dat file parsing, add relevant structures

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 292ca02..e33895d 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1,20 +1,49 @@
 #include "dungeonman.h"
 #include "common/file.h"
+#include "common/memstream.h"
+
 
 
 namespace DM {
-DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _dungeonDataSize(0), _dungeonData(NULL) {}
+// TODO: refactor direction into a class
+int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */};
+int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */};
+
+void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
+
+
+}
+
+using namespace DM;
+
+
+void DungeonMan::mapCoordsAfterRelMovement(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 &posX, uint16 &posY) {
+	posX += dirIntoStepCountEast[dir] * stepsForward;
+	posY += dirIntoStepCountNorth[dir] * stepsForward;
+	turnDirRight(dir);
+	posX += dirIntoStepCountEast[dir] * stepsRight;
+	posY += dirIntoStepCountNorth[dir] * stepsRight;
+}
+
+DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) {}
 
 DungeonMan::~DungeonMan() {
-	delete[] _dungeonData;
+	delete[] _rawDunFileData;
+	delete[] _maps;
+	delete[] _dunData.dunMapsFirstColumnIndex;
+	delete[] _dunData.dunColumnsCumulativeSquareThingCount;
+	delete[] _dunData.squareFirstThings;
+	delete[] _dunData.dunTextData;
+	delete[] _dunData.dungeonMapData;
 }
 
-void DungeonMan::loadDungeonFile() {
+void DungeonMan::decompressDungeonFile() {
 	Common::File f;
 	f.open("Dungeon.dat");
 	if (f.readUint16BE() == 0x8104) {
-		_dungeonDataSize = f.readUint32BE();
-		_dungeonData = new byte[_dungeonDataSize];
+		_rawDunFileDataSize = f.readUint32BE();
+		if (_rawDunFileData) delete[] _rawDunFileData;
+		_rawDunFileData = new byte[_rawDunFileDataSize];
 		f.readUint16BE();
 		byte common[4];
 		for (uint16 i = 0; i < 4; ++i)
@@ -29,7 +58,7 @@ void DungeonMan::loadDungeonFile() {
 		uint16 wordBuff = f.readUint16BE();
 		uint8 bitsLeftInByte = 8;
 		byte byteBuff = f.readByte();
-		while (uncompIndex < _dungeonDataSize) {
+		while (uncompIndex < _rawDunFileDataSize) {
 			while (bitsUsedInWord != 0) {
 				uint8 shiftVal;
 				if (f.eos()) {
@@ -49,18 +78,198 @@ void DungeonMan::loadDungeonFile() {
 				bitsUsedInWord -= shiftVal;
 			}
 			if (((wordBuff >> 15) & 1) == 0) {
-				_dungeonData[uncompIndex++] = common[(wordBuff >> 13) & 3];
+				_rawDunFileData[uncompIndex++] = common[(wordBuff >> 13) & 3];
 				bitsUsedInWord += 3;
 			} else if (((wordBuff >> 14) & 3) == 2) {
-				_dungeonData[uncompIndex++] = lessCommon[(wordBuff >> 10) & 15];
+				_rawDunFileData[uncompIndex++] = lessCommon[(wordBuff >> 10) & 15];
 				bitsUsedInWord += 6;
 			} else if (((wordBuff >> 14) & 3) == 3) {
-				_dungeonData[uncompIndex++] = (wordBuff >> 6) & 255;
+				_rawDunFileData[uncompIndex++] = (wordBuff >> 6) & 255;
 				bitsUsedInWord += 10;
 			}
 		}
+	} else {
+		// TODO: if the dungeon is uncompressed, read it here
 	}
 	f.close();
 }
 
+
+uint8 gAdditionalThingCounts[16] = {
+	0,    /* Door */
+	0,    /* Teleporter */
+	0,    /* Text String */
+	0,    /* Sensor */
+	75,   /* Group */
+	100,  /* Weapon */
+	120,  /* Armour */
+	0,    /* Scroll */
+	5,    /* Potion */
+	0,    /* Container */
+	140,  /* Junk */
+	0,    /* Unused */
+	0,    /* Unused */
+	0,    /* Unused */
+	60,   /* Projectile */
+	50    /* Explosion */
+}; // @ G0236_auc_Graphic559_AdditionalThingCounts
+
+// TODO: refactor THINGS into classes
+unsigned char gThingDataByteCount[16] = {
+	4,   /* Door */
+	6,   /* Teleporter */
+	4,   /* Text String */
+	8,   /* Sensor */
+	16,  /* Group */
+	4,   /* Weapon */
+	4,   /* Armour */
+	4,   /* Scroll */
+	4,   /* Potion */
+	8,   /* Container */
+	4,   /* Junk */
+	0,   /* Unused */
+	0,   /* Unused */
+	0,   /* Unused */
+	8,   /* Projectile */
+	4    /* Explosion */
+}; // @ G0235_auc_Graphic559_ThingDataByteCount
+
+const Thing Thing::specThingNone(0, 0, 0);
+
+
+void DungeonMan::loadDungeonFile() {
+	if (_messages.newGame)
+		decompressDungeonFile();
+
+	Common::MemoryReadStream dunDataStream(_rawDunFileData, _fileHeader.rawMapDataSize, DisposeAfterUse::NO);
+
+	// initialize _fileHeader
+	_fileHeader.dungeonId = _fileHeader.ornamentRandomSeed = dunDataStream.readUint16BE();
+	_fileHeader.rawMapDataSize = dunDataStream.readUint16BE();
+	_fileHeader.mapCount = dunDataStream.readByte();
+	dunDataStream.readByte(); // discard 1 byte
+	_fileHeader.textDataWordCount = dunDataStream.readUint16BE();
+	uint16 partyPosition = dunDataStream.readUint16BE();
+	_fileHeader.partyStartDir = (direction)((partyPosition >> 10) & 3);
+	_fileHeader.partyStartPosY = (partyPosition >> 5) & 0x1F;
+	_fileHeader.partyStartPosX = (partyPosition >> 0) & 0x1F;
+	_fileHeader.squareFirstThingCount = dunDataStream.readUint16BE();
+	for (uint16 i = 0; i < kThingTypeTotal; ++i)
+		_fileHeader.thingCounts[i] = dunDataStream.readUint16BE();
+
+	// init party position and mapindex
+	if (_messages.newGame) {
+		_dunData.partyDir = _fileHeader.partyStartDir;
+		_dunData.partyPosX = _fileHeader.partyStartPosX;
+		_dunData.partyPosY = _fileHeader.partyStartPosY;
+		_dunData.currMapIndex = 0;
+	}
+
+	// load map data
+	if (_maps) delete[] _maps;
+
+	_maps = new Map[_fileHeader.mapCount];
+	for (uint16 i = 0; i < _fileHeader.mapCount; ++i) {
+		_maps[i].rawDunDataOffset = dunDataStream.readUint16BE();
+		dunDataStream.readUint32BE(); // discard 4 bytes
+		_maps[i].offsetMapX = dunDataStream.readByte();
+		_maps[i].offsetMapY = dunDataStream.readByte();
+
+		uint16 tmp = dunDataStream.readUint16BE();
+		_maps[i].height = tmp >> 11;
+		_maps[i].width = (tmp >> 6) & 0x1F;
+		_maps[i].level = tmp & 0x1F; // Only used in DMII
+
+		tmp = dunDataStream.readUint16BE();
+		_maps[i].randFloorOrnCount = tmp >> 12;
+		_maps[i].floorOrnCount = (tmp >> 8) & 0xF;
+		_maps[i].randWallOrnCount = (tmp >> 4) & 0xF;
+		_maps[i].wallOrnCount = tmp & 0xF;
+
+		tmp = dunDataStream.readUint16BE();
+		_maps[i].difficulty = tmp >> 12;
+		_maps[i].creatureTypeCount = (tmp >> 4) & 0xF;
+		_maps[i].doorOrnCount = tmp & 0xF;
+
+		tmp = dunDataStream.readUint16BE();
+		_maps[i].doorSet1 = (tmp >> 12) & 0xF;
+		_maps[i].doorSet0 = (tmp >> 8) & 0xF;
+		_maps[i].wallSet = (tmp >> 4) & 0xF;
+		_maps[i].floorSet = tmp & 0xF;
+	}
+
+	// TODO: ??? is this - begin
+	if (_dunData.dunMapsFirstColumnIndex) delete[] _dunData.dunMapsFirstColumnIndex;
+
+	_dunData.dunMapsFirstColumnIndex = new uint16[_fileHeader.mapCount];
+	uint16 columCount = 0;
+	for (uint16 i = 0; i < _fileHeader.mapCount; ++i) {
+		_dunData.dunMapsFirstColumnIndex[i] = columCount;
+		columCount += _maps[i].width + 1;
+	}
+	_dunData.dunColumCount = columCount;
+	// TODO: ??? is this - end
+
+	if (_messages.newGame) // TODO: what purpose does this serve?
+		_fileHeader.squareFirstThingCount += 300;
+
+	// TODO: ??? is this - begin
+	if (_dunData.dunColumnsCumulativeSquareThingCount)
+		delete[] _dunData.dunColumnsCumulativeSquareThingCount;
+	_dunData.dunColumnsCumulativeSquareThingCount = new uint16[columCount];
+	for (uint16 i = 0; i < columCount; ++i)
+		_dunData.dunColumnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE();
+	// TODO: ??? is this - end
+
+	// TODO: ??? is this - begin
+	if (_dunData.squareFirstThings)
+		delete[] _dunData.squareFirstThings;
+	_dunData.squareFirstThings = new Thing[_fileHeader.squareFirstThingCount];
+	for (uint16 i = 0; i < _fileHeader.squareFirstThingCount; ++i) {
+		uint16 tmp = dunDataStream.readUint16BE();
+		_dunData.squareFirstThings[i].cell = tmp >> 14;
+		_dunData.squareFirstThings[i].type = (tmp >> 10) & 0xF;
+		_dunData.squareFirstThings[i].index = tmp & 0x1FF;
+	}
+	if (_messages.newGame)
+		for (uint16 i = 0; i < 300; ++i)
+			_dunData.squareFirstThings[i] = Thing::specThingNone;
+
+	// TODO: ??? is this - end
+
+	// load text data
+	if (_dunData.dunTextData)
+		delete[] _dunData.dunTextData;
+	_dunData.dunTextData = new uint16[_fileHeader.textDataWordCount];
+	for (uint16 i = 0; i < _fileHeader.textDataWordCount; ++i)
+		_dunData.dunTextData[i] = dunDataStream.readUint16BE();
+
+	// TODO: ??? what this
+	if (_messages.newGame)
+		_dunData.eventMaximumCount = 100;
+
+	// load 'Things'
+	// TODO: implement load things
+	// this is a temporary workaround to seek to raw map data
+	for (uint16 i = 0; i < kThingTypeTotal; ++i)
+		dunDataStream.skip(_fileHeader.thingCounts[i] * gThingDataByteCount[i]);
+
+	_rawMapData = _rawDunFileData + dunDataStream.pos();
+
+	if (_dunData.dungeonMapData) delete[] _dunData.dungeonMapData;
+
+	if (_messages.restartGameRequest) {
+		uint8 mapCount = _fileHeader.mapCount;
+		_dunData.dungeonMapData = new byte**[_dunData.dunColumCount + mapCount];
+		byte **colFirstSquares = _dunData.dungeonMapData[mapCount];
+		for (uint8 i = 0; i < mapCount; ++i) {
+			_dunData.dungeonMapData[i] = colFirstSquares;
+			byte *square = _rawMapData + _maps[i].rawDunDataOffset;
+			*colFirstSquares++ = square;
+			for (uint16 w = 0; w <= _maps[i].width; ++w) {
+				square += _maps[w].height + 1;
+				*colFirstSquares++ = square;
+			}
+		}
+	}
 }
\ No newline at end of file
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index b820bb2..b26d56f 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -5,16 +5,135 @@
 
 namespace DM {
 
+class DungeonMan;
+
+enum ThingType {
+	kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value
+	kDoorThingType = 0,
+	kTeleporterThingType = 1,
+	kTextstringType = 2,
+	kSensorThingType = 3,
+	kGroupThingType = 4,
+	kWeaponThingType = 5,
+	kArmourThingType = 6,
+	kScrollThingType = 7,
+	kPotionThingType = 8,
+	kContainerThingType = 9,
+	kJunkThingType = 10,
+	kProjectileThingType = 14,
+	kExplosionThingType = 15,
+	kThingTypeTotal = 16 // +1 than the last
+}; // @ C[00..15]_THING_TYPE_...
+
+
+class DungeonFileHeader {
+	friend class DungeonMan;
+
+	uint16 dungeonId; // @ G0526_ui_DungeonID
+	// equal to dungeonId
+	uint16 ornamentRandomSeed;
+	uint32 rawMapDataSize;
+	uint8 mapCount;
+	uint16 textDataWordCount;
+	direction partyStartDir; // @ InitialPartyLocation
+	uint16 partyStartPosX, partyStartPosY;
+	uint16 squareFirstThingCount; // @ SquareFirstThingCount
+	uint16 thingCounts[16]; // @ ThingCount[16]
+}; // @ DUNGEON_HEADER
+
+class Thing {
+	friend class DungeonMan;
+
+	static const Thing specThingNone;
+
+	Thing(uint8 cell, uint8 type, uint8 index) : cell(cell), type(type), index(index) {}
+	Thing() {}
+
+	uint8 cell;
+	uint8 type;
+	uint8 index;
+}; // @ THING
+
+class DungeonData {
+	friend class DungeonMan;
+
+	direction partyDir; // @ G0308_i_PartyDirection
+	uint16 partyPosX; // @ G0306_i_PartyMapX
+	uint16 partyPosY; // @ G0307_i_PartyMapY
+	uint8 currMapIndex; // @ G0309_i_PartyMapIndex
+
+	// I have no idea the heck is this
+	uint16 *dunMapsFirstColumnIndex = NULL; // @ G0281_pui_DungeonMapsFirstColumnIndex
+	uint16 dunColumCount; // @ G0282_ui_DungeonColumnCount
+
+	// I have no idea the heck is this
+	uint16 *dunColumnsCumulativeSquareThingCount = NULL; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
+	Thing *squareFirstThings = NULL; // @ G0283_pT_SquareFirstThings
+	uint16 *dunTextData = NULL; // @ G0260_pui_DungeonTextData
+
+	byte *rawThingData[16] = {NULL}; // @ G0284_apuc_ThingData
+
+	byte ***dungeonMapData = NULL; // @ G0279_pppuc_DungeonMapData
+
+	uint16 eventMaximumCount; // @ G0369_ui_EventMaximumCount
+}; // @ AGGREGATE
+
+struct Messages {
+	friend class DungeonMan;
+
+private:
+	bool newGame = true; // @ G0298_B_NewGame
+	bool restartGameRequest = false; // @ G0523_B_RestartGameRequested
+}; // @ AGGREGATE
+
+class Map {
+	friend class DungeonMan;
+
+	uint32 rawDunDataOffset;
+	uint8 offsetMapX, offsetMapY;
+
+	uint8 level; // only used in DMII
+	uint8 width, height; // THESRE ARE INCLUSIVE BOUNDARIES
+	// orn short for Ornament
+	uint8 wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */
+	uint8 randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */
+	uint8 floorOrnCount; /* May be used in a Sensor on a Pit, open Fake Wall, Corridor or Teleporter square */
+	uint8 randFloorOrnCount; /* Used only on some Corridor squares and some open Fake Wall squares */
+
+	uint8 doorOrnCount;
+	uint8 creatureTypeCount;
+	uint8 difficulty;
+
+	uint8 floorSet, wallSet, doorSet0, doorSet1;
+
+}; // @ MAP
+
+
+
 class DungeonMan {
 	DMEngine *_vm;
-	uint32 _dungeonDataSize;
-	byte *_dungeonData;
+
+	uint32 _rawDunFileDataSize;
+	byte *_rawDunFileData; // @ ???
+	DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader
+
+	DungeonData _dunData; // @ NONE
+	Map *_maps; // @ G0277_ps_DungeonMaps
+	// does not have to be freed
+	byte *_rawMapData; // @ G0276_puc_DungeonRawMapData
+	Messages _messages; // @ NONE
+
 	DungeonMan(const DungeonMan &other); // no implementation on purpose
 	void operator=(const DungeonMan &rhs); // no implementation on purpose
+
+	void mapCoordsAfterRelMovement(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 &posX, uint16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement
+
+	void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon
 public:
 	DungeonMan(DMEngine *dmEngine);
 	~DungeonMan();
-	void loadDungeonFile();
+	// TODO: this does stuff other than load the file!
+	void loadDungeonFile();	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
 };
 
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 0ae3b25..0c2efc6 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -39,7 +39,7 @@ Frame gCeilingFrame = {0, 223, 0, 28, 0, 0};
 Frame gFloorFrame = {0, 223, 66, 135, 0, 0};
 
 extern Viewport gDefultViewPort = {0, 0};
-extern Viewport gDungeonViewport = {0, 64};
+extern Viewport gDungeonViewport = {0, 64};	// TODO: I guessed the numbers
 
 }
 


Commit: 68f13e8462bfb6ca85b45273696173acdf112910
    https://github.com/scummvm/scummvm/commit/68f13e8462bfb6ca85b45273696173acdf112910
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Implement F0173_DUNGEON_SetCurrentMap

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 8f6f294..a27506d 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -59,6 +59,8 @@ Common::Error DMEngine::run() {
 
 	_displayMan->loadPalette(kPalCredits);
 
+	_dungeonMan->setCurrentMap(0);
+
 	uint16 i = 0; //TODO: testing, please delete me
 	while (true) {
 		_displayMan->clearScreen(kColorBlack);
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index e33895d..07c52a7 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -30,11 +30,11 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL
 DungeonMan::~DungeonMan() {
 	delete[] _rawDunFileData;
 	delete[] _maps;
-	delete[] _dunData.dunMapsFirstColumnIndex;
-	delete[] _dunData.dunColumnsCumulativeSquareThingCount;
+	delete[] _dunData.mapsFirstColumnIndex;
+	delete[] _dunData.columnsCumulativeSquareThingCount;
 	delete[] _dunData.squareFirstThings;
-	delete[] _dunData.dunTextData;
-	delete[] _dunData.dungeonMapData;
+	delete[] _dunData.textData;
+	delete[] _dunData.mapData;
 }
 
 void DungeonMan::decompressDungeonFile() {
@@ -159,10 +159,10 @@ void DungeonMan::loadDungeonFile() {
 
 	// init party position and mapindex
 	if (_messages.newGame) {
-		_dunData.partyDir = _fileHeader.partyStartDir;
-		_dunData.partyPosX = _fileHeader.partyStartPosX;
-		_dunData.partyPosY = _fileHeader.partyStartPosY;
-		_dunData.currMapIndex = 0;
+		_currMap.partyDir = _fileHeader.partyStartDir;
+		_currMap.partyPosX = _fileHeader.partyStartPosX;
+		_currMap.partyPosY = _fileHeader.partyStartPosY;
+		_currMap.currPartyMapIndex = 0;
 	}
 
 	// load map data
@@ -199,26 +199,26 @@ void DungeonMan::loadDungeonFile() {
 	}
 
 	// TODO: ??? is this - begin
-	if (_dunData.dunMapsFirstColumnIndex) delete[] _dunData.dunMapsFirstColumnIndex;
+	if (_dunData.mapsFirstColumnIndex) delete[] _dunData.mapsFirstColumnIndex;
 
-	_dunData.dunMapsFirstColumnIndex = new uint16[_fileHeader.mapCount];
+	_dunData.mapsFirstColumnIndex = new uint16[_fileHeader.mapCount];
 	uint16 columCount = 0;
 	for (uint16 i = 0; i < _fileHeader.mapCount; ++i) {
-		_dunData.dunMapsFirstColumnIndex[i] = columCount;
+		_dunData.mapsFirstColumnIndex[i] = columCount;
 		columCount += _maps[i].width + 1;
 	}
-	_dunData.dunColumCount = columCount;
+	_dunData.columCount = columCount;
 	// TODO: ??? is this - end
 
 	if (_messages.newGame) // TODO: what purpose does this serve?
 		_fileHeader.squareFirstThingCount += 300;
 
 	// TODO: ??? is this - begin
-	if (_dunData.dunColumnsCumulativeSquareThingCount)
-		delete[] _dunData.dunColumnsCumulativeSquareThingCount;
-	_dunData.dunColumnsCumulativeSquareThingCount = new uint16[columCount];
+	if (_dunData.columnsCumulativeSquareThingCount)
+		delete[] _dunData.columnsCumulativeSquareThingCount;
+	_dunData.columnsCumulativeSquareThingCount = new uint16[columCount];
 	for (uint16 i = 0; i < columCount; ++i)
-		_dunData.dunColumnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE();
+		_dunData.columnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE();
 	// TODO: ??? is this - end
 
 	// TODO: ??? is this - begin
@@ -238,11 +238,11 @@ void DungeonMan::loadDungeonFile() {
 	// TODO: ??? is this - end
 
 	// load text data
-	if (_dunData.dunTextData)
-		delete[] _dunData.dunTextData;
-	_dunData.dunTextData = new uint16[_fileHeader.textDataWordCount];
+	if (_dunData.textData)
+		delete[] _dunData.textData;
+	_dunData.textData = new uint16[_fileHeader.textDataWordCount];
 	for (uint16 i = 0; i < _fileHeader.textDataWordCount; ++i)
-		_dunData.dunTextData[i] = dunDataStream.readUint16BE();
+		_dunData.textData[i] = dunDataStream.readUint16BE();
 
 	// TODO: ??? what this
 	if (_messages.newGame)
@@ -256,14 +256,14 @@ void DungeonMan::loadDungeonFile() {
 
 	_rawMapData = _rawDunFileData + dunDataStream.pos();
 
-	if (_dunData.dungeonMapData) delete[] _dunData.dungeonMapData;
+	if (_dunData.mapData) delete[] _dunData.mapData;
 
-	if (_messages.restartGameRequest) {
+	if (!_messages.restartGameRequest) {
 		uint8 mapCount = _fileHeader.mapCount;
-		_dunData.dungeonMapData = new byte**[_dunData.dunColumCount + mapCount];
-		byte **colFirstSquares = _dunData.dungeonMapData[mapCount];
+		_dunData.mapData = new byte**[_dunData.columCount + mapCount];
+		byte **colFirstSquares = (byte**)_dunData.mapData + mapCount;
 		for (uint8 i = 0; i < mapCount; ++i) {
-			_dunData.dungeonMapData[i] = colFirstSquares;
+			_dunData.mapData[i] = colFirstSquares;
 			byte *square = _rawMapData + _maps[i].rawDunDataOffset;
 			*colFirstSquares++ = square;
 			for (uint16 w = 0; w <= _maps[i].width; ++w) {
@@ -272,4 +272,17 @@ void DungeonMan::loadDungeonFile() {
 			}
 		}
 	}
+}
+
+void DungeonMan::setCurrentMap(uint16 mapIndex) {
+	if (_currMap.index == mapIndex)
+		return;
+
+	_currMap.index = mapIndex;
+	_currMap.data = _dunData.mapData[mapIndex];
+	_currMap.map = _maps + mapIndex;
+	_currMap.width = _maps[mapIndex].width + 1;
+	_currMap.height = _maps[mapIndex].height + 1;
+	_currMap.colCumulativeSquareFirstThingCount
+		= &_dunData.columnsCumulativeSquareThingCount[_dunData.mapsFirstColumnIndex[mapIndex]];
 }
\ No newline at end of file
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index b26d56f..213a76d 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -6,6 +6,7 @@
 namespace DM {
 
 class DungeonMan;
+class Map;
 
 enum ThingType {
 	kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value
@@ -57,27 +58,39 @@ class Thing {
 class DungeonData {
 	friend class DungeonMan;
 
-	direction partyDir; // @ G0308_i_PartyDirection
-	uint16 partyPosX; // @ G0306_i_PartyMapX
-	uint16 partyPosY; // @ G0307_i_PartyMapY
-	uint8 currMapIndex; // @ G0309_i_PartyMapIndex
-
 	// I have no idea the heck is this
-	uint16 *dunMapsFirstColumnIndex = NULL; // @ G0281_pui_DungeonMapsFirstColumnIndex
-	uint16 dunColumCount; // @ G0282_ui_DungeonColumnCount
+	uint16 *mapsFirstColumnIndex = NULL; // @ G0281_pui_DungeonMapsFirstColumnIndex
+	uint16 columCount; // @ G0282_ui_DungeonColumnCount
 
 	// I have no idea the heck is this
-	uint16 *dunColumnsCumulativeSquareThingCount = NULL; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
+	uint16 *columnsCumulativeSquareThingCount = NULL; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
 	Thing *squareFirstThings = NULL; // @ G0283_pT_SquareFirstThings
-	uint16 *dunTextData = NULL; // @ G0260_pui_DungeonTextData
+	uint16 *textData = NULL; // @ G0260_pui_DungeonTextData
 
 	byte *rawThingData[16] = {NULL}; // @ G0284_apuc_ThingData
 
-	byte ***dungeonMapData = NULL; // @ G0279_pppuc_DungeonMapData
+	byte ***mapData = NULL; // @ G0279_pppuc_DungeonMapData
 
+	// TODO: ??? is this doing here
 	uint16 eventMaximumCount; // @ G0369_ui_EventMaximumCount
 }; // @ AGGREGATE
 
+class CurrMapData {
+	friend class DungeonMan;
+
+	direction partyDir; // @ G0308_i_PartyDirection
+	uint16 partyPosX; // @ G0306_i_PartyMapX
+	uint16 partyPosY; // @ G0307_i_PartyMapY
+	uint8 currPartyMapIndex; // @ G0309_i_PartyMapIndex
+
+	uint8 index; // @ G0272_i_CurrentMapIndex
+	byte **data; // @ G0271_ppuc_CurrentMapData
+	Map *map; // @ G0269_ps_CurrentMap
+	uint16 width; // @ G0273_i_CurrentMapWidth
+	uint16 height; // @ G0274_i_CurrentMapHeight
+	uint16 *colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount
+}; // @ AGGREGATE
+
 struct Messages {
 	friend class DungeonMan;
 
@@ -93,7 +106,7 @@ class Map {
 	uint8 offsetMapX, offsetMapY;
 
 	uint8 level; // only used in DMII
-	uint8 width, height; // THESRE ARE INCLUSIVE BOUNDARIES
+	uint8 width, height; // !!! THESRE ARE INCLUSIVE BOUNDARIES
 	// orn short for Ornament
 	uint8 wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */
 	uint8 randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */
@@ -113,11 +126,12 @@ class Map {
 class DungeonMan {
 	DMEngine *_vm;
 
-	uint32 _rawDunFileDataSize;
+	uint32 _rawDunFileDataSize;	 // @ probably NONE
 	byte *_rawDunFileData; // @ ???
 	DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader
 
 	DungeonData _dunData; // @ NONE
+	CurrMapData _currMap; // @ NONE
 	Map *_maps; // @ G0277_ps_DungeonMaps
 	// does not have to be freed
 	byte *_rawMapData; // @ G0276_puc_DungeonRawMapData
@@ -134,6 +148,7 @@ public:
 	~DungeonMan();
 	// TODO: this does stuff other than load the file!
 	void loadDungeonFile();	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
+	void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
 };
 
 }


Commit: 8172a07d1ad933b228313f164b7d6a5b1bf3951e
    https://github.com/scummvm/scummvm/commit/8172a07d1ad933b228313f164b7d6a5b1bf3951e
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add square query in DungeonMan

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 07c52a7..87188ae 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -285,4 +285,19 @@ void DungeonMan::setCurrentMap(uint16 mapIndex) {
 	_currMap.height = _maps[mapIndex].height + 1;
 	_currMap.colCumulativeSquareFirstThingCount
 		= &_dunData.columnsCumulativeSquareThingCount[_dunData.mapsFirstColumnIndex[mapIndex]];
+}
+
+byte DungeonMan::getSquare(uint16 mapX, uint16 mapY) {
+	bool isInXBounds = (mapX >= 0) && (mapX < _currMap.width);
+	bool isInYBounds = (mapY >= 0) && (mapY < _currMap.height);
+
+	if (isInXBounds && isInYBounds)
+		return _currMap.data[mapX][mapY];
+	else
+		return kWallSquareType;
+}
+
+byte DungeonMan::getRelSquare(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY) {
+	mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY);
+	return getSquare(posX, posY);
 }
\ No newline at end of file
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 213a76d..c88c08d 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -26,6 +26,16 @@ enum ThingType {
 	kThingTypeTotal = 16 // +1 than the last
 }; // @ C[00..15]_THING_TYPE_...
 
+enum SquareType {
+	kWallSquareType = 0,
+	kCorridorSquareType = 1,
+	kPitSquareType = 2,
+	kStairsSquareType = 3,
+	kDoorSquareType = 4,
+	kTeleporterSquareType = 5,
+	kFakeWallSquareType = 6
+}; // @ C[00..06]_ELEMENT_...
+
 
 class DungeonFileHeader {
 	friend class DungeonMan;
@@ -141,6 +151,10 @@ class DungeonMan {
 	void operator=(const DungeonMan &rhs); // no implementation on purpose
 
 	void mapCoordsAfterRelMovement(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 &posX, uint16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement
+	byte getSquare(uint16 mapX, uint16 mapY); // @ F0151_DUNGEON_GetSquare
+	byte getRelSquare(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY); // @ F0152_DUNGEON_GetRelativeSquare
+
+	SquareType getSquareType(uint16 square) { return (SquareType)(square << 5); } // @ M34_SQUARE_TYPE
 
 	void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon
 public:
@@ -149,6 +163,9 @@ public:
 	// TODO: this does stuff other than load the file!
 	void loadDungeonFile();	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
 	void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
+	SquareType getRelSquareType(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY) {
+		return getSquareType(getRelSquare(dir, stepsForward, stepsRight, posX, posY));
+	}// @ F0153_DUNGEON_GetRelativeSquareType
 };
 
 }


Commit: 853b87f19e2ad99db495be9e86a312d8775ed37c
    https://github.com/scummvm/scummvm/commit/853b87f19e2ad99db495be9e86a312d8775ed37c
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add drawDungeon test code

Changed paths:
    engines/dm/dm.h
    engines/dm/gfx.cpp



diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 22ef1ec..d5d7487 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -34,6 +34,7 @@ public:
 private:
 	Console *_console;
 	Common::RandomSource *_rnd;
+public:
 	DisplayMan *_displayMan;
 	DungeonMan *_dungeonMan;
 };
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 0c2efc6..fd3b281 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -4,6 +4,7 @@
 #include "common/file.h"
 #include "graphics/palette.h"
 #include "common/endian.h"
+#include "dm/dungeonman.h"
 
 
 namespace DM {
@@ -37,6 +38,8 @@ struct Frame {
 
 Frame gCeilingFrame = {0, 223, 0, 28, 0, 0};
 Frame gFloorFrame = {0, 223, 66, 135, 0, 0};
+Frame gWallFrameD3L2 = {0,  15, 25, 73, 0, 0}; // @ FRAME G0711_s_Graphic558_Frame_Wall_D3L2
+Frame gWallFrameD3R2 = {208, 223, 25, 73, 0, 0}; // @ G0712_s_Graphic558_Frame_Wall_D3R2
 
 extern Viewport gDefultViewPort = {0, 0};
 extern Viewport gDungeonViewport = {0, 64};	// TODO: I guessed the numbers
@@ -264,6 +267,13 @@ void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) {
 		drawWallSetBitmap(_bitmaps[gFloorIndice], gFloorFrame, width(gFloorIndice));
 	}
 
+	// TODO: CRUDE TEST CODE AT BEST
+	if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallSquareType)
+		drawWallSetBitmap(_bitmaps[77 + 12], gWallFrameD3L2, width(77 + 12));
+	// TODO CRUDE TEST CODE AT BEST
+
+
+
 
 	delete[] tmpBitmap;
 }


Commit: bf78e63d2e900b73c592c8087156ea261cd35354
    https://github.com/scummvm/scummvm/commit/bf78e63d2e900b73c592c8087156ea261cd35354
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing cross-references in gfx.h

Changed paths:
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 34bb8cf..3199fb8 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -65,9 +65,10 @@ class DisplayMan {
 
 	byte **_bitmaps;
 	byte *getCurrentVgaBuffer();
-	void loadIntoBitmap(uint16 index, byte *destBitmap);
+	// the original functions has two position parameters, but they are always set to zero
+	void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap
 	void unpackGraphics();
-	void drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth);
+	void drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap
 public:
 	DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
@@ -94,7 +95,7 @@ public:
 
 	void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color);
 	void clearScreen(Color color);
-	void drawDungeon(direction dir, uint16 posX, uint16 posY);
+	void drawDungeon(direction dir, uint16 posX, uint16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
 };
 


Commit: 16199b4091e4fae39a6569d985e2b460c7d2516b
    https://github.com/scummvm/scummvm/commit/16199b4091e4fae39a6569d985e2b460c7d2516b
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add loadWallSet(..) and loadFloorSet(..)

Changed paths:
    engines/dm/dm.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index a27506d..60b2b2a 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -56,6 +56,8 @@ Common::Error DMEngine::run() {
 	_displayMan->setUpScreens(320, 200);
 	_displayMan->loadGraphics();
 	_dungeonMan->loadDungeonFile();
+	_displayMan->loadFloorSet(kFloorSetStone);
+	_displayMan->loadWallSet(kWallSetStone);
 
 	_displayMan->loadPalette(kPalCredits);
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index fd3b281..11c2d81 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -24,6 +24,7 @@ uint16 dmPalettes[10][16] = {
 };
 
 
+
 enum GraphicIndice {
 	gFloorIndice = 75,
 	gCeilingIndice = 76
@@ -50,7 +51,7 @@ using namespace DM;
 
 DisplayMan::DisplayMan(DMEngine *dmEngine) :
 	_vm(dmEngine), _currPalette(kPalSwoosh), _screenWidth(0), _screenHeight(0),
-	_vgaBuffer(NULL), _itemCount(0), _packedItemPos(NULL), _packedBitmaps(NULL),
+	_vgaBuffer(NULL), _packedItemCount(0), _packedItemPos(NULL), _packedBitmaps(NULL),
 	_bitmaps(NULL) {}
 
 DisplayMan::~DisplayMan() {
@@ -58,6 +59,8 @@ DisplayMan::~DisplayMan() {
 	delete[] _packedItemPos;
 	delete[] _vgaBuffer;
 	delete[] _bitmaps;
+	delete[] _wallSetBitMaps[13]; // copy of another bitmap, just flipped
+	delete[] _wallSetBitMaps[14]; // copy of another bitmap, just flipped
 }
 
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
@@ -72,16 +75,16 @@ void DisplayMan::loadGraphics() {
 	Common::File f;
 	f.open("graphics.dat");
 
-	_itemCount = f.readUint16BE();
-	_packedItemPos = new uint32[_itemCount + 1];
+	_packedItemCount = f.readUint16BE();
+	_packedItemPos = new uint32[_packedItemCount + 1];
 	_packedItemPos[0] = 0;
-	for (uint16 i = 1; i < _itemCount + 1; ++i)
+	for (uint16 i = 1; i < _packedItemCount + 1; ++i)
 		_packedItemPos[i] = f.readUint16BE() + _packedItemPos[i - 1];
 
-	_packedBitmaps = new uint8[_packedItemPos[_itemCount]];
+	_packedBitmaps = new uint8[_packedItemPos[_packedItemCount]];
 
-	f.seek(2 + _itemCount * 4);
-	for (uint32 i = 0; i < _packedItemPos[_itemCount]; ++i)
+	f.seek(2 + _packedItemCount * 4);
+	for (uint32 i = 0; i < _packedItemPos[_packedItemCount]; ++i)
 		_packedBitmaps[i] = f.readByte();
 
 	f.close();
@@ -245,17 +248,35 @@ void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth) {
 }
 
 
+enum WallSetIndices {
+	kDoorFrameFront = 0, // @  G0709_puc_Bitmap_WallSet_DoorFrameFront
+	kDoorFrameLeft_D1C = 1, // @  G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C
+	kFameLeft_D2C = 2, // @  G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C
+	kDoorFrameLeft_D3C = 3, // @  G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C
+	kDoorFrameLeft_D3L = 4, // @  G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L
+	kDoorFrameTop_D1LCR = 5, // @  G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR
+	kDoorFrameTop_D2LCR = 6, // @  G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR
+	kWall_D0R = 7, // @  G0702_puc_Bitmap_WallSet_Wall_D0R
+	kWall_D0L = 8, // @  G0701_puc_Bitmap_WallSet_Wall_D0L
+	kWall_D1LCR = 9, // @  G0700_puc_Bitmap_WallSet_Wall_D1LCR
+	kWall_D2LCR = 10, // @  G0699_puc_Bitmap_WallSet_Wall_D2LCR
+	kWall_D3LCR = 11, // @  G0698_puc_Bitmap_WallSet_Wall_D3LCR
+	kWall_D3L2 = 12, // @  G0697_puc_Bitmap_WallSet_Wall_D3L2
+
+	kWall_D3R2 = 13, // @  G0696_puc_Bitmap_WallSet_Wall_D3R2
+	kDoorFrameRight_D1C = 14// @  G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C
+};
 
 void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) {
 	loadPalette(kPalDungeonView0);
 	// TODO: this is a global variable, set from here
-	bool flippedWallAndFootprints = (posX + posY + dir) & 1;
+	bool flippedFloorCeiling = (posX + posY + dir) & 1;
 
 	// NOTE: this can hold every bitmap, width and height is "flexible"
 	byte  *tmpBitmap = new byte[305 * 111];
 	clearBitmap(tmpBitmap, 305, 111, kColorBlack);
 
-	if (flippedWallAndFootprints) {
+	if (flippedFloorCeiling) {
 		blitToBitmap(_bitmaps[gFloorIndice], width(gFloorIndice), height(gFloorIndice), tmpBitmap, width(gFloorIndice));
 		flipBitmapHorizontal(tmpBitmap, width(gFloorIndice), height(gFloorIndice));
 		drawWallSetBitmap(tmpBitmap, gFloorFrame, width(gFloorIndice));
@@ -284,4 +305,37 @@ void DisplayMan::clearScreen(Color color) {
 
 void DisplayMan::clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color) {
 	memset(bitmap, color, sizeof(byte) * width * height);
+}
+
+
+void DisplayMan::loadWallSet(WallSet set) {
+	// there are 2 bitmaps per set, first one is at 75
+	GraphicIndice indice = (GraphicIndice)(75 + (2 * set));
+	_floorBitmap = _bitmaps[indice];
+	_ceilingBitmap = _bitmaps[indice + 1];
+}
+
+void DisplayMan::loadFloorSet(FloorSet set) {
+	// there are 13 bitmaps perset, first one is at 77
+	uint16 firstIndice = (set * 13) + 77;
+	for (uint16 i = 0; i < 13; ++i) {
+		_wallSetBitMaps[i] = _bitmaps[i + firstIndice];
+	}
+
+
+	uint16 leftDoorIndice = firstIndice + kDoorFrameLeft_D1C;
+	uint16 w = width(leftDoorIndice), h = height(leftDoorIndice);
+	if (_wallSetBitMaps[kDoorFrameRight_D1C])
+		delete[] _wallSetBitMaps[kDoorFrameRight_D1C];
+	_wallSetBitMaps[kDoorFrameRight_D1C] = new byte[w * h];
+	blitToBitmap(_wallSetBitMaps[kDoorFrameLeft_D1C], w, h, _wallSetBitMaps[kDoorFrameRight_D1C], w);
+	flipBitmapHorizontal(_wallSetBitMaps[kDoorFrameRight_D1C], w, h);
+
+	uint16 leftWallIndice = firstIndice + kWall_D3L2;
+	w = width(leftWallIndice), h = height(leftWallIndice);
+	if (_wallSetBitMaps[kWall_D3R2])
+		delete[] _wallSetBitMaps[kWall_D3R2];
+	_wallSetBitMaps[kWall_D3R2] = new byte[w * h];
+	blitToBitmap(_wallSetBitMaps[kWall_D3L2], w, h, _wallSetBitMaps[kWall_D3R2], w);
+	flipBitmapHorizontal(_wallSetBitMaps[kWall_D3R2], w, h);
 }
\ No newline at end of file
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 3199fb8..45b1bb7 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -7,6 +7,13 @@
 namespace DM {
 
 struct Frame;
+enum WallSet {
+	kWallSetStone = 0 // @ C0_WALL_SET_STONE
+};
+
+enum FloorSet {
+	kFloorSetStone = 0 // @ C0_FLOOR_SET_STONE
+};
 
 enum Color {
 	kColorNoTransparency = 255,
@@ -57,13 +64,24 @@ class DisplayMan {
 	uint16 _screenWidth;
 	uint16 _screenHeight;
 	byte *_vgaBuffer;
-	uint16 _itemCount;
+
+	uint16 _packedItemCount;
 	uint32 *_packedItemPos;
 	byte *_packedBitmaps; // TODO: this doesn't not contaion graphics exclusively, will have to be moved
+
+	byte **_bitmaps;
+
+
+	// the last two pointers are owned by this array
+	byte *_wallSetBitMaps[15] = {NULL};	// @G[0696..0710]_puc_Bitmap_WallSet_...
+
+	// pointers are not owned by these fields
+	byte *_floorBitmap;
+	byte *_ceilingBitmap;
+
 	DisplayMan(const DisplayMan &other); // no implementation on purpose
 	void operator=(const DisplayMan &rhs); // no implementation on purpose
 
-	byte **_bitmaps;
 	byte *getCurrentVgaBuffer();
 	// the original functions has two position parameters, but they are always set to zero
 	void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap
@@ -73,7 +91,11 @@ public:
 	DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
 	void setUpScreens(uint16 width, uint16 height);
+
 	void loadGraphics();
+	void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet
+	void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet
+
 	void loadPalette(dmPaletteEnum palette);
 
 	/// Gives the width of an IMG0 type item


Commit: af6e6ca4682981e6d193968e508531055e18c52e
    https://github.com/scummvm/scummvm/commit/af6e6ca4682981e6d193968e508531055e18c52e
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor Frame POD

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 11c2d81..603021e 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -30,17 +30,22 @@ enum GraphicIndice {
 	gCeilingIndice = 76
 };
 
+// The frames in the orignal sources contain inclusive boundaries and byte widths, not pixel widths
 struct Frame {
-	// FIXME: these bundaries are inclusive, workaround by adding +1 in the drawFrame methods
 	uint16 destFromX, destToX, destFromY, destToY;
-	// srcWidth and srcHeight (present in the original sources) is redundant here, can be deduced from gaphicsIndice
+	uint16 srcWidth, srcHeight;
 	uint16 srcX, srcY;
+
+	Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
+		  uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY):
+		destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1),
+		srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {}
 };
 
-Frame gCeilingFrame = {0, 223, 0, 28, 0, 0};
-Frame gFloorFrame = {0, 223, 66, 135, 0, 0};
-Frame gWallFrameD3L2 = {0,  15, 25, 73, 0, 0}; // @ FRAME G0711_s_Graphic558_Frame_Wall_D3L2
-Frame gWallFrameD3R2 = {208, 223, 25, 73, 0, 0}; // @ G0712_s_Graphic558_Frame_Wall_D3R2
+Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0);
+Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0);
+Frame gWallFrameD3L2(0,  15, 25, 73, 8, 49, 0, 0); // @ FRAME G0711_s_Graphic558_Frame_Wall_D3L2
+Frame gWallFrameD3R2(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2
 
 extern Viewport gDefultViewPort = {0, 0};
 extern Viewport gDungeonViewport = {0, 64};	// TODO: I guessed the numbers
@@ -59,8 +64,8 @@ DisplayMan::~DisplayMan() {
 	delete[] _packedItemPos;
 	delete[] _vgaBuffer;
 	delete[] _bitmaps;
-	delete[] _wallSetBitMaps[13]; // copy of another bitmap, just flipped
-	delete[] _wallSetBitMaps[14]; // copy of another bitmap, just flipped
+	delete[] _wallSetBitMaps[13]; // copy of another bitmap, but flipped
+	delete[] _wallSetBitMaps[14]; // copy of another bitmap, but flipped
 }
 
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
@@ -244,7 +249,7 @@ uint16 DisplayMan::height(uint16 index) {
 }
 
 void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth) {
-	blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX + 1, f.destFromY, f.destToY + 1, kColorFlesh, gDungeonViewport);
+	blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport);
 }
 
 


Commit: 05fbf0b3584c5bef1827ce43951b325a20ac40ac
    https://github.com/scummvm/scummvm/commit/05fbf0b3584c5bef1827ce43951b325a20ac40ac
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add dungeonman.o to module.mk, fix _bitmaps memory leak

Changed paths:
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/module.mk



diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index c88c08d..e60fb40 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -163,7 +163,7 @@ public:
 	// TODO: this does stuff other than load the file!
 	void loadDungeonFile();	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
 	void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
-	SquareType getRelSquareType(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY) {
+	SquareType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
 		return getSquareType(getRelSquare(dir, stepsForward, stepsRight, posX, posY));
 	}// @ F0153_DUNGEON_GetRelativeSquareType
 };
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 603021e..ad8d230 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -37,14 +37,14 @@ struct Frame {
 	uint16 srcX, srcY;
 
 	Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
-		  uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY):
+		  uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) :
 		destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1),
 		srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {}
 };
 
 Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0);
 Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0);
-Frame gWallFrameD3L2(0,  15, 25, 73, 8, 49, 0, 0); // @ FRAME G0711_s_Graphic558_Frame_Wall_D3L2
+Frame gWallFrameD3L2(0, 15, 25, 73, 8, 49, 0, 0); // @ FRAME G0711_s_Graphic558_Frame_Wall_D3L2
 Frame gWallFrameD3R2(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2
 
 extern Viewport gDefultViewPort = {0, 0};
@@ -63,6 +63,7 @@ DisplayMan::~DisplayMan() {
 	delete[] _packedBitmaps;
 	delete[] _packedItemPos;
 	delete[] _vgaBuffer;
+	delete[] _bitmaps[0];
 	delete[] _bitmaps;
 	delete[] _wallSetBitMaps[13]; // copy of another bitmap, but flipped
 	delete[] _wallSetBitMaps[14]; // copy of another bitmap, but flipped
@@ -248,8 +249,8 @@ uint16 DisplayMan::height(uint16 index) {
 	return READ_BE_UINT16(data + 2);
 }
 
-void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth) {
-	blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport);
+void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) {
+	blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport);
 }
 
 
@@ -282,21 +283,23 @@ void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) {
 	clearBitmap(tmpBitmap, 305, 111, kColorBlack);
 
 	if (flippedFloorCeiling) {
-		blitToBitmap(_bitmaps[gFloorIndice], width(gFloorIndice), height(gFloorIndice), tmpBitmap, width(gFloorIndice));
-		flipBitmapHorizontal(tmpBitmap, width(gFloorIndice), height(gFloorIndice));
-		drawWallSetBitmap(tmpBitmap, gFloorFrame, width(gFloorIndice));
-		drawWallSetBitmap(_bitmaps[gCeilingIndice], gCeilingFrame, width(gCeilingIndice));
+		uint16 w = gFloorFrame.srcWidth, h = gFloorFrame.srcHeight;
+		blitToBitmap(_floorBitmap, w, h, tmpBitmap, w);
+		flipBitmapHorizontal(tmpBitmap, w, h);
+		drawWallSetBitmap(tmpBitmap, gFloorFrame);
+		drawWallSetBitmap(_ceilingBitmap, gCeilingFrame);
 	} else {
-		blitToBitmap(_bitmaps[gCeilingIndice], width(gCeilingIndice), height(gCeilingIndice), tmpBitmap, width(gCeilingIndice));
-		flipBitmapHorizontal(tmpBitmap, width(gCeilingIndice), height(gCeilingIndice));
-		drawWallSetBitmap(tmpBitmap, gCeilingFrame, width(gCeilingIndice));
-		drawWallSetBitmap(_bitmaps[gFloorIndice], gFloorFrame, width(gFloorIndice));
+		uint16 w = gCeilingFrame.srcWidth, h = gCeilingFrame.srcHeight;
+		blitToBitmap(_ceilingBitmap, w, h, tmpBitmap, w);
+		flipBitmapHorizontal(tmpBitmap, w, h);
+		drawWallSetBitmap(tmpBitmap, gCeilingFrame);
+		drawWallSetBitmap(_floorBitmap, gFloorFrame);
 	}
 
-	// TODO: CRUDE TEST CODE AT BEST
 	if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallSquareType)
-		drawWallSetBitmap(_bitmaps[77 + 12], gWallFrameD3L2, width(77 + 12));
-	// TODO CRUDE TEST CODE AT BEST
+		drawWallSetBitmap(_wallSetBitMaps[kWall_D3L2], gWallFrameD3L2);
+	if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallSquareType)
+		drawWallSetBitmap(_wallSetBitMaps[kWall_D3R2], gWallFrameD3R2);
 
 
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 45b1bb7..b2c29bf 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -86,7 +86,7 @@ class DisplayMan {
 	// the original functions has two position parameters, but they are always set to zero
 	void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap
 	void unpackGraphics();
-	void drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap
+	void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap
 public:
 	DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index 3fad4ee..ca425c5 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -3,7 +3,8 @@ MODULE := engines/dm
 MODULE_OBJS := \
 	detection.o \
 	dm.o \
-	gfx.o
+	gfx.o \
+	dungeonman.o
 
 MODULE_DIRS += \
 	engines/dm


Commit: f39b22f32133cd40c20996e75dfcb167c91e2ae2
    https://github.com/scummvm/scummvm/commit/f39b22f32133cd40c20996e75dfcb167c91e2ae2
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor Thing POD

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 87188ae..b5c2a3e 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -11,7 +11,6 @@ int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /
 
 void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
 
-
 }
 
 using namespace DM;
@@ -225,12 +224,8 @@ void DungeonMan::loadDungeonFile() {
 	if (_dunData.squareFirstThings)
 		delete[] _dunData.squareFirstThings;
 	_dunData.squareFirstThings = new Thing[_fileHeader.squareFirstThingCount];
-	for (uint16 i = 0; i < _fileHeader.squareFirstThingCount; ++i) {
-		uint16 tmp = dunDataStream.readUint16BE();
-		_dunData.squareFirstThings[i].cell = tmp >> 14;
-		_dunData.squareFirstThings[i].type = (tmp >> 10) & 0xF;
-		_dunData.squareFirstThings[i].index = tmp & 0x1FF;
-	}
+	for (uint16 i = 0; i < _fileHeader.squareFirstThingCount; ++i)
+		_dunData.squareFirstThings[i].set(dunDataStream.readUint16BE());
 	if (_messages.newGame)
 		for (uint16 i = 0; i < 300; ++i)
 			_dunData.squareFirstThings[i] = Thing::specThingNone;
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index e60fb40..2afc2aa 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -52,13 +52,40 @@ class DungeonFileHeader {
 	uint16 thingCounts[16]; // @ ThingCount[16]
 }; // @ DUNGEON_HEADER
 
+class Map {
+	friend class DungeonMan;
+
+	uint32 rawDunDataOffset;
+	uint8 offsetMapX, offsetMapY;
+
+	uint8 level; // only used in DMII
+	uint8 width, height; // !!! THESRE ARE INCLUSIVE BOUNDARIES
+	// orn short for Ornament
+	uint8 wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */
+	uint8 randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */
+	uint8 floorOrnCount; /* May be used in a Sensor on a Pit, open Fake Wall, Corridor or Teleporter square */
+	uint8 randFloorOrnCount; /* Used only on some Corridor squares and some open Fake Wall squares */
+
+	uint8 doorOrnCount;
+	uint8 creatureTypeCount;
+	uint8 difficulty;
+
+	uint8 floorSet, wallSet, doorSet0, doorSet1;
+}; // @ MAP
+
 class Thing {
 	friend class DungeonMan;
 
 	static const Thing specThingNone;
 
-	Thing(uint8 cell, uint8 type, uint8 index) : cell(cell), type(type), index(index) {}
 	Thing() {}
+	Thing(uint8 cell, uint8 type, uint8 index) : cell(cell), type(type), index(index) {}
+
+	void set(uint16 dat) {
+		cell = dat >> 14;
+		type = (dat >> 10) & 0xF;
+		index = dat & 0x1FF;
+	}
 
 	uint8 cell;
 	uint8 type;
@@ -109,27 +136,6 @@ private:
 	bool restartGameRequest = false; // @ G0523_B_RestartGameRequested
 }; // @ AGGREGATE
 
-class Map {
-	friend class DungeonMan;
-
-	uint32 rawDunDataOffset;
-	uint8 offsetMapX, offsetMapY;
-
-	uint8 level; // only used in DMII
-	uint8 width, height; // !!! THESRE ARE INCLUSIVE BOUNDARIES
-	// orn short for Ornament
-	uint8 wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */
-	uint8 randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */
-	uint8 floorOrnCount; /* May be used in a Sensor on a Pit, open Fake Wall, Corridor or Teleporter square */
-	uint8 randFloorOrnCount; /* Used only on some Corridor squares and some open Fake Wall squares */
-
-	uint8 doorOrnCount;
-	uint8 creatureTypeCount;
-	uint8 difficulty;
-
-	uint8 floorSet, wallSet, doorSet0, doorSet1;
-
-}; // @ MAP
 
 
 


Commit: 253730787de69da9b914f41138f7a54214f41eff
    https://github.com/scummvm/scummvm/commit/253730787de69da9b914f41138f7a54214f41eff
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Finish implementing ornament masks in DungeonMan::getSquare

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index b5c2a3e..80239e1 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -16,7 +16,7 @@ void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
 using namespace DM;
 
 
-void DungeonMan::mapCoordsAfterRelMovement(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 &posX, uint16 &posY) {
+void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
 	posX += dirIntoStepCountEast[dir] * stepsForward;
 	posY += dirIntoStepCountNorth[dir] * stepsForward;
 	turnDirRight(dir);
@@ -282,17 +282,36 @@ void DungeonMan::setCurrentMap(uint16 mapIndex) {
 		= &_dunData.columnsCumulativeSquareThingCount[_dunData.mapsFirstColumnIndex[mapIndex]];
 }
 
-byte DungeonMan::getSquare(uint16 mapX, uint16 mapY) {
+byte DungeonMan::getSquare(int16 mapX, int16 mapY) {
 	bool isInXBounds = (mapX >= 0) && (mapX < _currMap.width);
 	bool isInYBounds = (mapY >= 0) && (mapY < _currMap.height);
 
 	if (isInXBounds && isInYBounds)
 		return _currMap.data[mapX][mapY];
-	else
-		return kWallSquareType;
+
+	int16 tmpSquare;
+	if (isInYBounds) {
+		tmpSquare = getSquareType(_currMap.data[0][mapY]);
+		if (mapX == -1 && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType))
+			return (kWallElemType << 5) | kWallEastRandOrnAllowed;
+
+		tmpSquare = getSquareType(_currMap.data[_currMap.width - 1][mapY]);
+		if (mapX == _currMap.width && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType))
+			return (kWallElemType << 5) | kWallWestRandOrnAllowed;
+	} else if (isInXBounds) {
+		tmpSquare = getSquareType(_currMap.data[mapX][0]);
+		if (mapY == -1 && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType))
+			return (kWallElemType << 5) | kWallSouthRandOrnAllowed;
+
+		tmpSquare = getSquareType(_currMap.data[mapX][_currMap.height - 1]);
+		if (mapY == _currMap.height && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType))
+			return (kWallElemType << 5) | kWallNorthRandOrnAllowed;
+	}
+
+	return kWallElemType << 5;
 }
 
-byte DungeonMan::getRelSquare(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY) {
+byte DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
 	mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY);
 	return getSquare(posX, posY);
 }
\ No newline at end of file
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 2afc2aa..dbe13d3 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -26,15 +26,28 @@ enum ThingType {
 	kThingTypeTotal = 16 // +1 than the last
 }; // @ C[00..15]_THING_TYPE_...
 
-enum SquareType {
-	kWallSquareType = 0,
-	kCorridorSquareType = 1,
-	kPitSquareType = 2,
-	kStairsSquareType = 3,
-	kDoorSquareType = 4,
-	kTeleporterSquareType = 5,
-	kFakeWallSquareType = 6
-}; // @ C[00..06]_ELEMENT_...
+enum ElementType {
+	kChampionElemType = -2,
+	kCreatureElemType = -1,
+	kWallElemType = 0,
+	kCorridorElemType = 1,
+	kPitElemType = 2,
+	kStairsElemType = 3,
+	kDoorElemType = 4,
+	kTeleporterElemType = 5,
+	kFakeWallElemType = 6,
+	kDoorSideElemType = 16,
+	kDoorFrontElemType = 17,
+	kStairsSideElemType = 18,
+	kStairsFrontElemType = 19
+}; // @ C[-2..19]_ELEMENT_...
+
+enum WallOrnMask {
+	kWallWestRandOrnAllowed = 0x1,
+	kWallSouthRandOrnAllowed = 0x2,
+	kWallEastRandOrnAllowed = 0x4,
+	kWallNorthRandOrnAllowed = 0x8
+};
 
 
 class DungeonFileHeader {
@@ -156,11 +169,10 @@ class DungeonMan {
 	DungeonMan(const DungeonMan &other); // no implementation on purpose
 	void operator=(const DungeonMan &rhs); // no implementation on purpose
 
-	void mapCoordsAfterRelMovement(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 &posX, uint16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement
-	byte getSquare(uint16 mapX, uint16 mapY); // @ F0151_DUNGEON_GetSquare
-	byte getRelSquare(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY); // @ F0152_DUNGEON_GetRelativeSquare
+	byte getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare
+	byte getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare
 
-	SquareType getSquareType(uint16 square) { return (SquareType)(square << 5); } // @ M34_SQUARE_TYPE
+	ElementType getSquareType(int16 square) { return (ElementType)(square << 5); } // @ M34_SQUARE_TYPE
 
 	void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon
 public:
@@ -169,7 +181,8 @@ public:
 	// TODO: this does stuff other than load the file!
 	void loadDungeonFile();	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
 	void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
-	SquareType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
+	void mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement
+	ElementType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
 		return getSquareType(getRelSquare(dir, stepsForward, stepsRight, posX, posY));
 	}// @ F0153_DUNGEON_GetRelativeSquareType
 };
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index ad8d230..385b23f 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -253,6 +253,10 @@ void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) {
 	blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport);
 }
 
+void drawSquareD3L(direction dir, int16 posX, int16 posY) {
+
+}
+
 
 enum WallSetIndices {
 	kDoorFrameFront = 0, // @  G0709_puc_Bitmap_WallSet_DoorFrameFront
@@ -273,7 +277,7 @@ enum WallSetIndices {
 	kDoorFrameRight_D1C = 14// @  G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C
 };
 
-void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) {
+void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	loadPalette(kPalDungeonView0);
 	// TODO: this is a global variable, set from here
 	bool flippedFloorCeiling = (posX + posY + dir) & 1;
@@ -296,11 +300,14 @@ void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) {
 		drawWallSetBitmap(_floorBitmap, gFloorFrame);
 	}
 
-	if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallSquareType)
+	if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallElemType)
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D3L2], gWallFrameD3L2);
-	if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallSquareType)
+	if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallElemType)
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D3R2], gWallFrameD3R2);
 
+	// D3L
+	int16 tmpPosX = posX, tmpPosY = posY;
+	_vm->_dungeonMan->getRelSquareType(dir, 3, -1, tmpPosX, tmpPosY);
 
 
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index b2c29bf..5670a56 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -87,6 +87,7 @@ class DisplayMan {
 	void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap
 	void unpackGraphics();
 	void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap
+	void drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L
 public:
 	DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
@@ -117,7 +118,7 @@ public:
 
 	void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color);
 	void clearScreen(Color color);
-	void drawDungeon(direction dir, uint16 posX, uint16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
+	void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
 };
 


Commit: 6d5f8e2757d04d47208f096795cb3755fd8a16f2
    https://github.com/scummvm/scummvm/commit/6d5f8e2757d04d47208f096795cb3755fd8a16f2
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add wrapper class around raw map bytes

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 80239e1..b94382e 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -282,36 +282,43 @@ void DungeonMan::setCurrentMap(uint16 mapIndex) {
 		= &_dunData.columnsCumulativeSquareThingCount[_dunData.mapsFirstColumnIndex[mapIndex]];
 }
 
-byte DungeonMan::getSquare(int16 mapX, int16 mapY) {
+
+Square DungeonMan::getSquare(int16 mapX, int16 mapY) {
 	bool isInXBounds = (mapX >= 0) && (mapX < _currMap.width);
 	bool isInYBounds = (mapY >= 0) && (mapY < _currMap.height);
 
 	if (isInXBounds && isInYBounds)
 		return _currMap.data[mapX][mapY];
 
-	int16 tmpSquare;
+
+	Square tmpSquare;
 	if (isInYBounds) {
-		tmpSquare = getSquareType(_currMap.data[0][mapY]);
-		if (mapX == -1 && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType))
-			return (kWallElemType << 5) | kWallEastRandOrnAllowed;
+		Square tmpSquare(_currMap.data[0][mapY]);
+		if (mapX == -1 && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType))
+			return Square(kWallElemType).set(kWallEastRandOrnAllowed);
 
-		tmpSquare = getSquareType(_currMap.data[_currMap.width - 1][mapY]);
-		if (mapX == _currMap.width && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType))
-			return (kWallElemType << 5) | kWallWestRandOrnAllowed;
+		tmpSquare.set(_currMap.data[_currMap.width - 1][mapY]);
+		if (mapX == _currMap.width && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType))
+			return Square(kWallElemType).set(kWallWestRandOrnAllowed);
 	} else if (isInXBounds) {
-		tmpSquare = getSquareType(_currMap.data[mapX][0]);
-		if (mapY == -1 && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType))
-			return (kWallElemType << 5) | kWallSouthRandOrnAllowed;
+		tmpSquare.set(_currMap.data[mapX][0]);
+		if (mapY == -1 && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType))
+			return Square(kWallElemType).set(kWallSouthRandOrnAllowed);
 
-		tmpSquare = getSquareType(_currMap.data[mapX][_currMap.height - 1]);
-		if (mapY == _currMap.height && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType))
+		tmpSquare.set(_currMap.data[mapX][_currMap.height - 1]);
+		if (mapY == _currMap.height && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType))
 			return (kWallElemType << 5) | kWallNorthRandOrnAllowed;
 	}
 
-	return kWallElemType << 5;
+	return Square(kWallElemType);
 }
 
-byte DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
+Square DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
 	mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY);
 	return getSquare(posX, posY);
+}
+
+Thing DungeonMan::getSqureFirstThingIndex(int16 mapX, int16 mapY) {
+	//if (mapX < 0 || mapX >= _currMap.width || mapY < 0 || mapY >= _currMap.height || !(_currMap.data[mapX] & kThingListPresent))
+	return Thing();
 }
\ No newline at end of file
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index dbe13d3..8c7ed84 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -26,7 +26,27 @@ enum ThingType {
 	kThingTypeTotal = 16 // +1 than the last
 }; // @ C[00..15]_THING_TYPE_...
 
-enum ElementType {
+
+enum SquareMask {
+	kWallWestRandOrnAllowed = 0x1,
+	kWallSouthRandOrnAllowed = 0x2,
+	kWallEastRandOrnAllowed = 0x4,
+	kWallNorthRandOrnAllowed = 0x8,
+	kPitImaginary = 0x1,
+	kPitInvisible = 0x4,
+	kPitOpen = 0x8,
+	kStairsUp = 0x4,
+	kStairsNorthSouthOrient = 0x8,
+	kDoorNorthSouthOrient = 0x8,
+	kTeleporterVisible = 0x4,
+	kTeleporterOpen = 0x8,
+	kFakeWallImaginary = 0x1,
+	kFakeWallOpen = 0x4,
+	kFakeWallRandOrnOrFootPAllowed = 0x8,
+	kThingListPresent = 0x10
+};
+
+enum SquareType {
 	kChampionElemType = -2,
 	kCreatureElemType = -1,
 	kWallElemType = 0,
@@ -42,11 +62,17 @@ enum ElementType {
 	kStairsFrontElemType = 19
 }; // @ C[-2..19]_ELEMENT_...
 
-enum WallOrnMask {
-	kWallWestRandOrnAllowed = 0x1,
-	kWallSouthRandOrnAllowed = 0x2,
-	kWallEastRandOrnAllowed = 0x4,
-	kWallNorthRandOrnAllowed = 0x8
+class Square {
+	byte dat;
+public:
+	Square(byte dat = 0) : dat(dat) {}
+	Square(SquareType type) { setType(type); }
+	Square &set(byte dat) { this->dat = dat; return *this; }
+	Square &set(SquareMask mask) { dat |= mask; return *this; }
+	bool get(SquareMask mask) { return dat & mask; }
+	SquareType getType() { return (SquareType)(dat >> 5); } // @ M34_SQUARE_TYPE
+	Square &setType(SquareType type) { dat = (dat & 0x1F) | type << 5; return *this; }
+	byte toByte() { return dat; } // I don't like 'em casts
 };
 
 
@@ -169,12 +195,12 @@ class DungeonMan {
 	DungeonMan(const DungeonMan &other); // no implementation on purpose
 	void operator=(const DungeonMan &rhs); // no implementation on purpose
 
-	byte getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare
-	byte getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare
-
-	ElementType getSquareType(int16 square) { return (ElementType)(square << 5); } // @ M34_SQUARE_TYPE
+	Square getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare
+	Square getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare
 
 	void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon
+
+	Thing getSqureFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex
 public:
 	DungeonMan(DMEngine *dmEngine);
 	~DungeonMan();
@@ -182,9 +208,9 @@ public:
 	void loadDungeonFile();	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
 	void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
 	void mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement
-	ElementType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
-		return getSquareType(getRelSquare(dir, stepsForward, stepsRight, posX, posY));
-	}// @ F0153_DUNGEON_GetRelativeSquareType
+	SquareType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
+		return Square(getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType();
+	} // @ F0153_DUNGEON_GetRelativeSquareType
 };
 
 }


Commit: a8c82c1e947e845e201aa114a246a5b3e3dd863b
    https://github.com/scummvm/scummvm/commit/a8c82c1e947e845e201aa114a246a5b3e3dd863b
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add some draw dungeon dependencies

I forgot to do commits and it was already too late to revert back the
changes I've because they were too numerous.

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 60b2b2a..ee81849 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -53,15 +53,18 @@ Common::Error DMEngine::run() {
 	_console = new Console(this);
 	_displayMan = new DisplayMan(this);
 	_dungeonMan = new DungeonMan(this);
+
+	_dungeonMan->loadDungeonFile();
+
 	_displayMan->setUpScreens(320, 200);
 	_displayMan->loadGraphics();
-	_dungeonMan->loadDungeonFile();
-	_displayMan->loadFloorSet(kFloorSetStone);
-	_displayMan->loadWallSet(kWallSetStone);
 
-	_displayMan->loadPalette(kPalCredits);
 
-	_dungeonMan->setCurrentMap(0);
+	_displayMan->loadCurrentMapGraphics();
+
+	_displayMan->loadPalette(gPalCredits);
+
+	_dungeonMan->setCurrentMapAndPartyMap(0);
 
 	uint16 i = 0; //TODO: testing, please delete me
 	while (true) {
@@ -69,6 +72,7 @@ Common::Error DMEngine::run() {
 		_displayMan->drawDungeon(kDirNorth, i++, 0);
 		_displayMan->updateScreen();
 		_system->delayMillis(1000); //TODO: testing, please set me to 10
+		if (i == 3) break;
 	}
 
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index d5d7487..7c8afd1 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -33,8 +33,8 @@ public:
 
 private:
 	Console *_console;
-	Common::RandomSource *_rnd;
 public:
+	Common::RandomSource *_rnd;
 	DisplayMan *_displayMan;
 	DungeonMan *_dungeonMan;
 };
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index b94382e..46d4f62 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1,4 +1,5 @@
 #include "dungeonman.h"
+#include "gfx.h"
 #include "common/file.h"
 #include "common/memstream.h"
 
@@ -11,10 +12,46 @@ int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /
 
 void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
 
+
 }
 
 using namespace DM;
 
+CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo
+												   /* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo,
+												   MovementTicks, AttackTicks, Defense, BaseHealth, Attack, PoisonAttack,
+												   Dexterity, Ranges, Properties, Resistances, AnimationTicks, WoundProbabilities, AttackType } */
+	{0,  4, 0x0482, 0x623D,   8, 20,  55, 150, 150, 240,  55, 0x1153, 0x299B, 0x0876, 0x0254, 0xFD40, 4},
+	{1,  0, 0x0480, 0xA625,  15, 32,  20, 110,  80,  15,  20, 0x3132, 0x33A9, 0x0E42, 0x0384, 0xFC41, 3},
+	{2,  6, 0x0510, 0x6198,   3,  5,  50,  10,  10,   0, 110, 0x1376, 0x710A, 0x0235, 0x0222, 0xFD20, 0},
+	{3,  0, 0x04B4, 0xB225,  10, 21,  30,  40,  58,   0,  80, 0x320A, 0x96AA, 0x0B3C, 0x0113, 0xF910, 5},
+	{4,  1, 0x0701, 0xA3B8,   9,  8,  45, 101,  90,   0,  65, 0x1554, 0x58FF, 0x0A34, 0x0143, 0xFE93, 4},
+	{5,  0, 0x0581, 0x539D,  20, 18, 100,  60,  30,   0,  30, 0x1232, 0x4338, 0x0583, 0x0265, 0xFFD6, 3},
+	{6,  3, 0x070C, 0x0020, 120, 10,   5, 165,   5,   0,   5, 0x1111, 0x10F1, 0x0764, 0x02F2, 0xFC84, 6},
+	{7,  7, 0x0300, 0x0220, 185, 15, 170,  50,  40,   5,  10, 0x1463, 0x25C4, 0x06E3, 0x01F4, 0xFD93, 4}, /* Atari ST: AttackSoundOrdinal = 0 */
+	{8,  2, 0x1864, 0x5225,  11, 16,  15,  30,  55,   0,  80, 0x1423, 0x4664, 0x0FC8, 0x0116, 0xFB30, 6},
+	{9, 10, 0x0282, 0x71B8,  21, 14, 240, 120, 219,   0,  35, 0x1023, 0x3BFF, 0x0FF7, 0x04F3, 0xF920, 3}, /* Atari ST: AttackSoundOrdinal = 7 */
+	{10,  2, 0x1480, 0x11B8,  17, 12,  25,  33,  20,   0,  40, 0x1224, 0x5497, 0x0F15, 0x0483, 0xFB20, 3},
+	{11,  0, 0x18C6, 0x0225, 255,  8,  45,  80, 105,   0,  60, 0x1314, 0x55A5, 0x0FF9, 0x0114, 0xFD95, 1},
+	{12, 11, 0x1280, 0x6038,   7,  7,  22,  20,  22,   0,  80, 0x1013, 0x6596, 0x0F63, 0x0132, 0xFA30, 4}, /* Atari ST: AttackSoundOrdinal = 8 */
+	{13,  9, 0x14A2, 0xB23D,   5, 10,  42,  39,  90, 100,  88, 0x1343, 0x5734, 0x0638, 0x0112, 0xFA30, 4}, /* Atari ST: AttackSoundOrdinal = 0 */
+	{14,  0, 0x05B8, 0x1638,  10, 20,  47,  44,  75,   0,  90, 0x4335, 0xD952, 0x035B, 0x0664, 0xFD60, 5},
+	{15,  5, 0x0381, 0x523D,  18, 19,  72,  70,  45,  35,  35, 0x1AA1, 0x15AB, 0x0B93, 0x0253, 0xFFC5, 4},
+	{16, 10, 0x0680, 0xA038,  13,  8,  28,  20,  25,   0,  41, 0x1343, 0x2148, 0x0321, 0x0332, 0xFC30, 3}, /* Atari ST: AttackSoundOrdinal = 7 */
+	{17,  0, 0x04A0, 0xF23D,   1, 16, 180,   8,  28,  20, 150, 0x1432, 0x19FD, 0x0004, 0x0112, 0xF710, 4},
+	{18, 11, 0x0280, 0xA3BD,  14,  6, 140,  60, 105,   0,  70, 0x1005, 0x7AFF, 0x0FFA, 0x0143, 0xFA30, 4}, /* Atari ST: AttackSoundOrdinal = 8 */
+	{19,  0, 0x0060, 0xE23D,   5, 18,  15,  33,  61,   0,  65, 0x3258, 0xAC77, 0x0F56, 0x0117, 0xFC40, 5},
+	{20,  8, 0x10DE, 0x0225,  25, 25,  75, 144,  66,   0,  50, 0x1381, 0x7679, 0x0EA7, 0x0345, 0xFD93, 3}, /* Atari ST: AttackSoundOrdinal = 0 */
+	{21,  3, 0x0082, 0xA3BD,   7, 15,  33,  77, 130,   0,  60, 0x1592, 0x696A, 0x0859, 0x0224, 0xFC30, 4},
+	{22,  0, 0x1480, 0x53BD,  10, 14,  68, 100, 100,   0,  75, 0x4344, 0xBDF9, 0x0A5D, 0x0124, 0xF920, 3},
+	{23,  0, 0x38AA, 0x0038,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5},
+	{24,  1, 0x068A, 0x97BD,  13, 28, 110, 255, 255,   0,  70, 0x3645, 0xBF7C, 0x06CD, 0x0445, 0xFC30, 4}, /* Atari ST Version 1.0 1987-12-08 1987-12-11: Ranges = 0x2645 */
+	{25,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5},
+	{26,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}};
+
+int16 DM::ordinalToIndex(int16 val) { return val - 1; }
+int16 DM::indexToOrdinal(int16 val) { return val + 1; }
+
 
 void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
 	posX += dirIntoStepCountEast[dir] * stepsForward;
@@ -34,6 +71,11 @@ DungeonMan::~DungeonMan() {
 	delete[] _dunData.squareFirstThings;
 	delete[] _dunData.textData;
 	delete[] _dunData.mapData;
+	for (uint16 i = 0; i < 16; ++i) {
+		if (_dunData.thingsData[i])
+			delete[] _dunData.thingsData[i][0];
+		delete[] _dunData.thingsData[i];
+	}
 }
 
 void DungeonMan::decompressDungeonFile() {
@@ -113,27 +155,28 @@ uint8 gAdditionalThingCounts[16] = {
 	50    /* Explosion */
 }; // @ G0236_auc_Graphic559_AdditionalThingCounts
 
-// TODO: refactor THINGS into classes
-unsigned char gThingDataByteCount[16] = {
-	4,   /* Door */
-	6,   /* Teleporter */
-	4,   /* Text String */
-	8,   /* Sensor */
-	16,  /* Group */
-	4,   /* Weapon */
-	4,   /* Armour */
-	4,   /* Scroll */
-	4,   /* Potion */
-	8,   /* Container */
-	4,   /* Junk */
+// this is the number of uint16s the data has to be stored, not the lenght of the data in dungeon.dat!
+unsigned char gThingDataWordCount[16] = {
+	2,   /* Door */
+	3,   /* Teleporter */
+	2,   /* Text String */
+	4,   /* Sensor */
+	9,  /* Group */
+	2,   /* Weapon */
+	2,   /* Armour */
+	2,   /* Scroll */
+	2,   /* Potion */
+	4,   /* Container */
+	2,   /* Junk */
 	0,   /* Unused */
 	0,   /* Unused */
 	0,   /* Unused */
-	8,   /* Projectile */
-	4    /* Explosion */
+	5,   /* Projectile */
+	2    /* Explosion */
 }; // @ G0235_auc_Graphic559_ThingDataByteCount
 
-const Thing Thing::specThingNone(0, 0, 0);
+const Thing Thing::thingNone(0);
+const Thing Thing::thingEndOfList(0xFFFE);
 
 
 void DungeonMan::loadDungeonFile() {
@@ -193,8 +236,8 @@ void DungeonMan::loadDungeonFile() {
 		tmp = dunDataStream.readUint16BE();
 		_maps[i].doorSet1 = (tmp >> 12) & 0xF;
 		_maps[i].doorSet0 = (tmp >> 8) & 0xF;
-		_maps[i].wallSet = (tmp >> 4) & 0xF;
-		_maps[i].floorSet = tmp & 0xF;
+		_maps[i].wallSet = (WallSet)((tmp >> 4) & 0xF);
+		_maps[i].floorSet = (FloorSet)(tmp & 0xF);
 	}
 
 	// TODO: ??? is this - begin
@@ -228,7 +271,7 @@ void DungeonMan::loadDungeonFile() {
 		_dunData.squareFirstThings[i].set(dunDataStream.readUint16BE());
 	if (_messages.newGame)
 		for (uint16 i = 0; i < 300; ++i)
-			_dunData.squareFirstThings[i] = Thing::specThingNone;
+			_dunData.squareFirstThings[i] = Thing::thingNone;
 
 	// TODO: ??? is this - end
 
@@ -243,12 +286,51 @@ void DungeonMan::loadDungeonFile() {
 	if (_messages.newGame)
 		_dunData.eventMaximumCount = 100;
 
-	// load 'Things'
-	// TODO: implement load things
-	// this is a temporary workaround to seek to raw map data
-	for (uint16 i = 0; i < kThingTypeTotal; ++i)
-		dunDataStream.skip(_fileHeader.thingCounts[i] * gThingDataByteCount[i]);
 
+	// load things
+	for (uint16 thingType = kDoorThingType; thingType < kThingTypeTotal; ++thingType) {
+		uint16 thingCount = _fileHeader.thingCounts[thingType];
+		if (_messages.newGame) {
+			// _fileHeader.thingCounts[thingType] = 1024; // TODO: what this?? check back later
+		}
+		uint16 thingStoreWordCount = gThingDataWordCount[thingType];
+		if (!thingStoreWordCount || !thingCount)
+			continue;
+
+		if (_dunData.thingsData[thingType]) {
+			delete[] _dunData.thingsData[thingType][0];
+			delete[] _dunData.thingsData[thingType];
+		}
+		_dunData.thingsData[thingType] = new uint16*[thingCount];
+		_dunData.thingsData[thingType][0] = new uint16[thingCount * thingStoreWordCount];
+		for (uint16 i = 0; i < thingCount; ++i)
+			_dunData.thingsData[thingType][i] = _dunData.thingsData[thingType][0] + i * thingStoreWordCount;
+
+		if (thingType == kGroupThingType) {
+			for (uint16 i = 0; i < thingCount; ++i)
+				for (uint16 j = 0; j < thingStoreWordCount; ++j) {
+					if (j == 2 || j == 3)
+						_dunData.thingsData[thingType][i][j] = dunDataStream.readByte();
+					else
+						_dunData.thingsData[thingType][i][j] = dunDataStream.readUint16BE();
+				}
+		} else if (thingType == kProjectileThingType) {
+			for (uint16 i = 0; i < thingCount; ++i) {
+				_dunData.thingsData[thingType][i][0] = dunDataStream.readUint16BE();
+				_dunData.thingsData[thingType][i][1] = dunDataStream.readUint16BE();
+				_dunData.thingsData[thingType][i][2] = dunDataStream.readByte();
+				_dunData.thingsData[thingType][i][3] = dunDataStream.readByte();
+				_dunData.thingsData[thingType][i][4] = dunDataStream.readUint16BE();
+			}
+		} else {
+			for (uint16 i = 0; i < thingCount; ++i)
+				for (uint16 j = 0; j < thingStoreWordCount; ++j)
+					_dunData.thingsData[thingType][i][j] = dunDataStream.readUint16BE();
+		}
+	}
+
+
+	// load map data
 	_rawMapData = _rawDunFileData + dunDataStream.pos();
 
 	if (_dunData.mapData) delete[] _dunData.mapData;
@@ -282,6 +364,26 @@ void DungeonMan::setCurrentMap(uint16 mapIndex) {
 		= &_dunData.columnsCumulativeSquareThingCount[_dunData.mapsFirstColumnIndex[mapIndex]];
 }
 
+void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) {
+	setCurrentMap(mapIndex);
+
+	byte *metaMapData = _currMap.data[_currMap.width - 1] + _currMap.height;
+	_vm->_displayMan->_currMapAllowedCreatureTypes = metaMapData;
+
+	metaMapData += _currMap.map->creatureTypeCount;
+	memcpy(_vm->_displayMan->_currMapWallOrnIndices, metaMapData, _currMap.map->wallOrnCount);
+
+	metaMapData += _currMap.map->wallOrnCount;
+	memcpy(_vm->_displayMan->_currMapFloorOrnIndices, metaMapData, _currMap.map->floorOrnCount);
+
+	metaMapData += _currMap.map->wallOrnCount;
+	memcpy(_vm->_displayMan->_currMapDoorOrnIndices, metaMapData, _currMap.map->doorOrnCount);
+
+	_currMapInscriptionWallOrnIndex = _currMap.map->wallOrnCount;
+	_vm->_displayMan->_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = kWallOrnInscription;
+
+}
+
 
 Square DungeonMan::getSquare(int16 mapX, int16 mapY) {
 	bool isInXBounds = (mapX >= 0) && (mapX < _currMap.width);
@@ -293,7 +395,7 @@ Square DungeonMan::getSquare(int16 mapX, int16 mapY) {
 
 	Square tmpSquare;
 	if (isInYBounds) {
-		Square tmpSquare(_currMap.data[0][mapY]);
+		tmpSquare.set(_currMap.data[0][mapY]);
 		if (mapX == -1 && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType))
 			return Square(kWallElemType).set(kWallEastRandOrnAllowed);
 
@@ -318,7 +420,149 @@ Square DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRi
 	return getSquare(posX, posY);
 }
 
-Thing DungeonMan::getSqureFirstThingIndex(int16 mapX, int16 mapY) {
-	//if (mapX < 0 || mapX >= _currMap.width || mapY < 0 || mapY >= _currMap.height || !(_currMap.data[mapX] & kThingListPresent))
-	return Thing();
-}
\ No newline at end of file
+int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) {
+	if (mapX < 0 || mapX >= _currMap.width || mapY < 0 || mapY >= _currMap.height || !Square(_currMap.data[mapX][mapY]).get(kThingListPresent))
+		return -1;
+
+	int16 y;
+	uint16 index = _currMap.colCumulativeSquareFirstThingCount[mapX];
+	byte* square = _currMap.data[mapX];
+	while (y++ != mapY)
+		if (Square(*square++).get(kThingListPresent))
+			index++;
+
+	return index;
+}
+
+Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) {
+	int16 index = getSquareFirstThingIndex(mapX, mapY);
+	if (index == -1)
+		return Thing::thingEndOfList;
+	return _dunData.squareFirstThings[index];
+}
+
+enum SquareAspectIndice {
+	kElemAspect = 0,
+	kFirstGroupOrObjectAspect = 1,
+	kRightWallOrnOrdAspect = 2,
+	kFrontWallOrnOrdAspect = 3,
+	kLeftWallOrnOrdAspect = 4,
+	kPitInvisibleAspect = 2,
+	kTeleporterVisibleAspect = 2,
+	kStairsUpAspect = 2,
+	kDoorStateAspect = 2,
+	kDoorThingIndexAspect = 3,
+	kFloorOrnOrdAspect = 4
+};
+
+
+void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) {
+	bool leftOrnAllowed, rightOrnAllowed, frontOrnAllowed;
+	bool squareIsFakeWall;
+
+	Thing thing = getSquareFirstThing(mapX, mapY);
+	Square square = getSquare(mapX, mapY);
+
+	memset(aspectArray, 0, 5 * sizeof(int16));
+	aspectArray[kElemAspect] = square.getType();
+
+	_vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75
+	switch (square.getType()) {
+	case kWallElemType:
+		switch (dir) {
+		case kDirNorth:
+			leftOrnAllowed = square.get(kWallEastRandOrnAllowed);
+			frontOrnAllowed = square.get(kWallSouthRandOrnAllowed);
+			rightOrnAllowed = square.get(kWallWestRandOrnAllowed);
+			break;
+		case kDirEast:
+			leftOrnAllowed = square.get(kWallSouthRandOrnAllowed);
+			frontOrnAllowed = square.get(kWallWestRandOrnAllowed);
+			rightOrnAllowed = square.get(kWallNorthRandOrnAllowed);
+			break;
+		case kDirSouth:
+			leftOrnAllowed = square.get(kWallWestRandOrnAllowed);
+			frontOrnAllowed = square.get(kWallNorthRandOrnAllowed);
+			rightOrnAllowed = square.get(kWallEastRandOrnAllowed);
+			break;
+		case kDirWest:
+			leftOrnAllowed = square.get(kWallNorthRandOrnAllowed);
+			frontOrnAllowed = square.get(kWallEastRandOrnAllowed);
+			rightOrnAllowed = square.get(kWallSouthRandOrnAllowed);
+			break;
+		}
+
+		squareIsFakeWall = false;
+		setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall);
+
+		while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) {
+			int16 sideIndex = (thing.getCell() - dir) & 3;
+			if (sideIndex) {
+				if (thing.getType() == kTextstringType) {
+					if (TextString(getThingData(thing)).isVisible()) {
+						aspectArray[sideIndex + 1] = _currMapInscriptionWallOrnIndex + 1;
+
+					} else {
+						Sensor sensor(getThingData(thing));
+						aspectArray[sideIndex + 1] = sensor.getOrnOrdinal();
+						if (sensor.getType() == kSensorWallChampionPortrait) {
+							_vm->_displayMan->_championPortraitOrdinal = indexToOrdinal(sensor.getData());
+						}
+					}
+				}
+			}
+			thing = getNextThing(thing);
+		}
+		if (squareIsFakeWall && (_currMap.partyPosX != mapX) && (_currMap.partyPosY != mapY)) {
+			aspectArray[kFirstGroupOrObjectAspect] = Thing::thingEndOfList.toUint16();
+		}
+		break;
+	}
+	aspectArray[kFirstGroupOrObjectAspect] = thing.toUint16();
+}
+
+void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
+											int16 mapX, int16 mapY, bool isFakeWall) {
+	int16 ornCount = _currMap.map->randWallOrnCount;
+
+	turnDirRight(dir);
+	aspectArray[kRightWallOrnOrdAspect] = getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
+	turnDirRight(dir);
+	aspectArray[kFrontWallOrnOrdAspect] = getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
+	turnDirRight(dir);
+	aspectArray[kLeftWallOrnOrdAspect] = getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
+
+	if (isFakeWall || mapX < 0 || mapX >= _currMap.width || mapY < 0 || mapY >= _currMap.height) {
+		for (uint16 i = kRightWallOrnOrdAspect; i <= kLeftWallOrnOrdAspect; ++i) {
+			if (isWallOrnAnAlcove(ordinalToIndex(aspectArray[i])))
+				aspectArray[i] = 0;
+		}
+	}
+}
+
+int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) {
+	int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1)
+					+ (3000 + (_currMap.index << 6) + _currMap.width + _currMap.height) * 11
+					+ _fileHeader.ornamentRandomSeed) >> 2) % modulo;
+	if (allowed && index < count)
+		return indexToOrdinal(index);
+	return 0;
+}
+
+
+bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) {
+	if (wallOrnIndex >= 0)
+		for (uint16 i = 0; i < kAlcoveOrnCount; ++i)
+			if (_vm->_displayMan->_currMapAlcoveOrnIndices[i] == wallOrnIndex)
+				return true;
+	return false;
+}
+
+uint16 *DungeonMan::getThingData(Thing thing) {
+	return _dunData.thingsData[thing.getType()][thing.getIndex()];
+}
+
+Thing DungeonMan::getNextThing(Thing thing) {
+	return getThingData(thing)[0]; // :)
+}
+
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 8c7ed84..df83953 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -2,12 +2,16 @@
 #define DUNGEONMAN_H
 
 #include "dm.h"
+#include "gfx.h"
 
 namespace DM {
 
 class DungeonMan;
-class Map;
+struct Map;
 
+
+int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
+int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
 enum ThingType {
 	kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value
 	kDoorThingType = 0,
@@ -23,9 +27,270 @@ enum ThingType {
 	kJunkThingType = 10,
 	kProjectileThingType = 14,
 	kExplosionThingType = 15,
-	kThingTypeTotal = 16 // +1 than the last
+	kThingTypeTotal = 16 // +1 than the last (explosionThingType)
 }; // @ C[00..15]_THING_TYPE_...
 
+class Thing {
+	uint16 data;
+public:
+	static const Thing thingNone;
+	static const Thing thingEndOfList;
+
+	Thing() {}
+	Thing(uint16 d) { set(d); }
+
+	void set(uint16 d) {
+		data = d;
+	}
+
+	byte getCell() const { return data >> 14; }
+	ThingType getType() const { return (ThingType)((data >> 10) & 0xF); }
+	uint16 getIndex() const { return data & 0x1FF; }
+	uint16 toUint16() const { return data; } // I don't like 'em cast operators
+	bool operator==(const Thing &rhs) const { return data == rhs.data; }
+	bool operator!=(const Thing &rhs) const { return data != rhs.data; }
+}; // @ THING
+
+struct CreatureInfo {
+	byte creatureAspectIndex;
+	byte attackSoundOrdinal;
+	uint16 attributes; /* Bits 15-14 Unreferenced */
+	uint16 graphicInfo; /* Bits 11 and 6 Unreferenced */
+	byte movementTicks; /* Value 255 means the creature cannot move */
+	byte attackTicks; /* Minimum ticks between attacks */
+	byte defense;
+	byte baseHealth;
+	byte attack;
+	byte poisonAttack;
+	byte dexterity;
+	uint16 Ranges; /* Bits 7-4 Unreferenced */
+	uint16 Properties;
+	uint16 Resistances; /* Bits 15-12 and 3-0 Unreferenced */
+	uint16 AnimationTicks; /* Bits 15-12 Unreferenced */
+	uint16 WoundProbabilities; /* Contains 4 probabilities to wound a champion's Head (Bits 15-12), Legs (Bits 11-8), Torso (Bits 7-4) and Feet (Bits 3-0) */
+	byte AttackType;
+}; // @ CREATURE_INFO
+
+
+extern CreatureInfo gCreatureInfo[kCreatureTypeCount];
+
+class Door {
+	Thing nextThing;
+	uint16 attributes;
+public:
+	Door(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {}
+	Thing getNextThing() { return nextThing; }
+	bool isMeleeDestructible() { return (attributes >> 8) & 1; }
+	bool isMagicDestructible() { return (attributes >> 7) & 1; }
+	bool hasButton() { return (attributes >> 6) & 1; }
+	bool opensVertically() { return (attributes >> 5) & 1; }
+	byte getOrnOrdinal() { return (attributes >> 1) & 0xF; }
+	byte getType() { return attributes & 1; }
+}; // @ DOOR
+
+enum TeleporterScope {
+	kTelepScopeCreatures = 1, // @ MASK0x0001_SCOPE_CREATURES
+	kTelepScopeObjOrParty = 2 // @ MASK0x0002_SCOPE_OBJECTS_OR_PARTY
+};
+
+
+class Teleporter {
+	Thing nextThing;
+	uint16 attributes;
+	uint16 destMapIndex;
+public:
+	Teleporter(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]), destMapIndex(rawDat[2]) {}
+	Thing getNextThing() { return nextThing; }
+	bool makesSound() { return (attributes >> 15) & 1; }
+	TeleporterScope getScope() { return (TeleporterScope)((attributes >> 13) & 1); }
+	bool absRotation() { return (attributes >> 12) & 1; }
+	direction getRotationDir() { return (direction)((attributes >> 10) & 1); }
+	byte getDestY() { return (attributes >> 5) & 0xF; }
+	byte getDestX() { return attributes & 0xF; }
+	uint16 getDestMapIndex() { return destMapIndex >> 8; }
+}; // @ TELEPORTER
+
+
+
+class TextString {
+	Thing nextThing;
+	uint16 textDataRef;
+public:
+	TextString(uint16 *rawDat) : nextThing(rawDat[0]), textDataRef(rawDat[1]) {}
+
+	Thing getNextThing() { return nextThing; }
+	uint16 getWordOffset() { return textDataRef >> 3; }
+	bool isVisible() { return textDataRef & 1; }
+}; // @ TEXTSTRING
+
+enum SensorActionType {
+	kSensorEffNone = -1, // @ CM1_EFFECT_NONE
+	kSensorEffSet = 0, // @ C00_EFFECT_SET
+	kSensorEffClear = 1, // @ C01_EFFECT_CLEAR
+	kSensorEffToggle = 2, // @ C02_EFFECT_TOGGLE
+	kSensorEffHold = 3, // @ C03_EFFECT_HOLD
+	kSensorEffAddExp = 10 // @ C10_EFFECT_ADD_EXPERIENCE
+};
+
+enum SensorType {
+	kSensorDisabled = 0, // @ C000_SENSOR_DISABLED                                                           /* Never triggered, may be used for a floor or wall ornament */
+	kSensorFloorTheronPartyCreatureObj = 1, // @ C001_SENSOR_FLOOR_THERON_PARTY_CREATURE_OBJECT                                 /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorFloorTheronPartyCreature = 2, // @ C002_SENSOR_FLOOR_THERON_PARTY_CREATURE                                        /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorFloorParty = 3, // @ C003_SENSOR_FLOOR_PARTY                                                        /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorFloorObj = 4, // @ C004_SENSOR_FLOOR_OBJECT                                                       /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorFloorPartyOnStairs = 5, // @ C005_SENSOR_FLOOR_PARTY_ON_STAIRS                                              /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorFloorGroupGenerator = 6, // @ C006_SENSOR_FLOOR_GROUP_GENERATOR                                              /* Triggered by event F0245_TIMELINE_ProcessEvent5_Square_Corridor */
+	kSensorFloorCreature = 7, // @ C007_SENSOR_FLOOR_CREATURE                                                     /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorFloorPartyPossession = 8, // @ C008_SENSOR_FLOOR_PARTY_POSSESSION                                             /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorFloorVersionChecker = 9, // @ C009_SENSOR_FLOOR_VERSION_CHECKER                                              /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorWallOrnClick = 1, // @ C001_SENSOR_WALL_ORNAMENT_CLICK                                                /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallOrnClickWithAnyObj = 2, // @ C002_SENSOR_WALL_ORNAMENT_CLICK_WITH_ANY_OBJECT                                /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallOrnClickWithSpecObj = 3, // @ C003_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT                           /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallOrnClickWithSpecObjRemoved = 4, // @ C004_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED                   /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallAndOrGate = 5, // @ C005_SENSOR_WALL_AND_OR_GATE                                                   /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallCountdown = 6, // @ C006_SENSOR_WALL_COUNTDOWN                                                     /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallSingleProjLauncherNewObj = 7, // @ C007_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_NEW_OBJECT                         /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallSingleProjLauncherExplosion = 8, // @ C008_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_EXPLOSION                          /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallDoubleProjLauncherNewObj = 9, // @ C009_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_NEW_OBJECT                         /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallDoubleProjLauncherExplosion = 10, // @ C010_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_EXPLOSION                         /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallOrnClickWithSpecObjRemovedRotateSensors = 11, // @ C011_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_ROTATE_SENSORS   /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallObjGeneratorRotateSensors = 12, // @ C012_SENSOR_WALL_OBJECT_GENERATOR_ROTATE_SENSORS                              /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallSingleObjStorageRotateSensors = 13, // @ C013_SENSOR_WALL_SINGLE_OBJECT_STORAGE_ROTATE_SENSORS                         /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallSingleProjLauncherSquareObj = 14, // @ C014_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT                     /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallDoubleProjLauncherSquareObj = 15, // @ C015_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT                     /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallObjExchanger = 16, // @ C016_SENSOR_WALL_OBJECT_EXCHANGER                                             /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallOrnClickWithSpecObjRemovedSensor = 17, // @ C017_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_REMOVE_SENSOR    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallEndGame = 18, // @ C018_SENSOR_WALL_END_GAME                                                     /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallChampionPortrait = 127 // @ C127_SENSOR_WALL_CHAMPION_PORTRAIT                                           /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+};
+
+class Sensor {
+	Thing nextThing;
+	uint16 datAndType;
+	uint16 attributes;
+	uint16 action;
+public:
+	Sensor(uint16 *rawDat) : nextThing(rawDat[0]), datAndType(rawDat[1]), attributes(rawDat[2]), action(rawDat[3]) {}
+
+	Thing getNextThing() { return nextThing; }
+	SensorType getType() { return (SensorType)(datAndType & 0x7F); } // @ M39_TYPE
+	uint16 getData() { return datAndType >> 7; } // @ M40_DATA
+	uint16 getDataMask1() { return (datAndType >> 7) & 0xF; } // @ M42_MASK1
+	uint16 getDataMask2() { return (datAndType >> 11) & 0xF; } // @ M43_MASK2
+	void setData(int16 dat) { datAndType = (datAndType & 0x7F) | (dat << 7); } // @ M41_SET_DATA
+	void setTypeDisabled() { datAndType &= 0xFF80; } // @ M44_SET_TYPE_DISABLED
+	uint16 getOrnOrdinal() { return attributes >> 12; }
+	bool isLocalAction() { return (attributes >> 11) & 1; }
+	uint16 getDelay() { return (attributes >> 7) & 0xF; }
+	bool hasSound() { return (attributes >> 6) & 1; }
+	bool shouldRevert() { return (attributes >> 5) & 1; }
+	SensorActionType getActionType() { return (SensorActionType)((attributes >> 3) & 3); }
+	bool isSingleUse() { return (attributes >> 2) & 1; }
+	uint16 getRemoteMapY() { return (action >> 11); }
+	uint16 getRemoteMapX() { return (action >> 6) & 0x1F; }
+	direction getRemoteDir() { return (direction)((action >> 4) & 3); }
+	uint16 getLocalAction() { return (action >> 4); }
+	// some macros missing, i got bored
+}; // @ SENSOR
+
+class Group {
+	Thing nextThing;
+	Thing possessionID;
+	byte type;
+	byte position;
+	uint16 health[4];
+	uint16 attributes;
+public:
+	Group(uint16 *rawDat) : nextThing(rawDat[0]), possessionID(rawDat[1]), type(rawDat[2]),
+		position(rawDat[3]), attributes(rawDat[8]) {
+		health[0] = rawDat[4];
+		health[1] = rawDat[5];
+		health[2] = rawDat[6];
+		health[3] = rawDat[7];
+	}
+	Thing getNextThing() { return nextThing; }
+}; // @ GROUP
+
+class Weapon {
+	Thing nextThing;
+	uint16 desc;
+public:
+	Weapon(uint16 *rawDat) : nextThing(rawDat[0]), desc(rawDat[1]) {}
+
+	Thing getNextThing() { return nextThing; }
+}; // @ WEAPON
+
+class Armour {
+	Thing nextThing;
+	uint16 attributes;
+public:
+	Armour(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {}
+
+	Thing getNextThing() { return nextThing; }
+}; // @ ARMOUR
+
+class Scroll {
+	Thing nextThing;
+	uint16 attributes;
+public:
+	Scroll(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {}
+	void set(Thing next, uint16 attribs) {
+		nextThing = next;
+		attributes = attribs;
+	}
+	Thing getNextThing() { return nextThing; }
+}; // @ SCROLL
+
+class Potion {
+	Thing nextThing;
+	uint16 attributes;
+public:
+	Potion(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {}
+
+	Thing getNextThing() { return nextThing; }
+}; // @ POTION
+
+class Container {
+	Thing nextThing;
+	Thing nextContainedThing;
+	uint16 type;
+public:
+	Container(uint16 *rawDat) : nextThing(rawDat[0]), nextContainedThing(rawDat[1]), type(rawDat[2]) {}
+
+	Thing getNextThing() { return nextThing; }
+}; // @ CONTAINER
+
+class Junk {
+	Thing nextThing;
+	uint16 attributes;
+public:
+	Junk(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {}
+
+	Thing getNextThing() { return nextThing; }
+}; // @ JUNK
+
+class Projectile {
+	Thing nextThing;
+	Thing object;
+	byte kineticEnergy;
+	byte damageEnergy;
+	uint16 timerIndex;
+public:
+	Projectile(uint16 *rawDat) : nextThing(rawDat[0]), object(rawDat[1]), kineticEnergy(rawDat[2]),
+		damageEnergy(rawDat[3]), timerIndex(rawDat[4]) {}
+
+	Thing getNextThing() { return nextThing; }
+}; // @ PROJECTILE
+
+class Explosion {
+	Thing nextThing;
+	uint16 attributes;
+public:
+	Explosion(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {}
+
+	Thing getNextThing() { return nextThing; }
+}; // @ EXPLOSION
+
 
 enum SquareMask {
 	kWallWestRandOrnAllowed = 0x1,
@@ -63,22 +328,20 @@ enum SquareType {
 }; // @ C[-2..19]_ELEMENT_...
 
 class Square {
-	byte dat;
+	byte data;
 public:
-	Square(byte dat = 0) : dat(dat) {}
+	Square(byte dat = 0) : data(dat) {}
 	Square(SquareType type) { setType(type); }
-	Square &set(byte dat) { this->dat = dat; return *this; }
-	Square &set(SquareMask mask) { dat |= mask; return *this; }
-	bool get(SquareMask mask) { return dat & mask; }
-	SquareType getType() { return (SquareType)(dat >> 5); } // @ M34_SQUARE_TYPE
-	Square &setType(SquareType type) { dat = (dat & 0x1F) | type << 5; return *this; }
-	byte toByte() { return dat; } // I don't like 'em casts
+	Square &set(byte dat) { this->data = dat; return *this; }
+	Square &set(SquareMask mask) { data |= mask; return *this; }
+	bool get(SquareMask mask) { return data & mask; }
+	SquareType getType() { return (SquareType)(data >> 5); } // @ M34_SQUARE_TYPE
+	Square &setType(SquareType type) { data = (data & 0x1F) | type << 5; return *this; }
+	byte toByte() { return data; } // I don't like 'em casts
 };
 
 
-class DungeonFileHeader {
-	friend class DungeonMan;
-
+struct DungeonFileHeader {
 	uint16 dungeonId; // @ G0526_ui_DungeonID
 	// equal to dungeonId
 	uint16 ornamentRandomSeed;
@@ -91,9 +354,7 @@ class DungeonFileHeader {
 	uint16 thingCounts[16]; // @ ThingCount[16]
 }; // @ DUNGEON_HEADER
 
-class Map {
-	friend class DungeonMan;
-
+struct Map {
 	uint32 rawDunDataOffset;
 	uint8 offsetMapX, offsetMapY;
 
@@ -109,31 +370,14 @@ class Map {
 	uint8 creatureTypeCount;
 	uint8 difficulty;
 
-	uint8 floorSet, wallSet, doorSet0, doorSet1;
+	FloorSet floorSet;
+	WallSet wallSet;
+	uint8 doorSet0, doorSet1;
 }; // @ MAP
 
-class Thing {
-	friend class DungeonMan;
-
-	static const Thing specThingNone;
-
-	Thing() {}
-	Thing(uint8 cell, uint8 type, uint8 index) : cell(cell), type(type), index(index) {}
-
-	void set(uint16 dat) {
-		cell = dat >> 14;
-		type = (dat >> 10) & 0xF;
-		index = dat & 0x1FF;
-	}
-
-	uint8 cell;
-	uint8 type;
-	uint8 index;
-}; // @ THING
 
-class DungeonData {
-	friend class DungeonMan;
 
+struct DungeonData {
 	// I have no idea the heck is this
 	uint16 *mapsFirstColumnIndex = NULL; // @ G0281_pui_DungeonMapsFirstColumnIndex
 	uint16 columCount; // @ G0282_ui_DungeonColumnCount
@@ -143,7 +387,7 @@ class DungeonData {
 	Thing *squareFirstThings = NULL; // @ G0283_pT_SquareFirstThings
 	uint16 *textData = NULL; // @ G0260_pui_DungeonTextData
 
-	byte *rawThingData[16] = {NULL}; // @ G0284_apuc_ThingData
+	uint16 **thingsData[16] = {NULL}; // @ G0284_apuc_ThingData
 
 	byte ***mapData = NULL; // @ G0279_pppuc_DungeonMapData
 
@@ -151,9 +395,7 @@ class DungeonData {
 	uint16 eventMaximumCount; // @ G0369_ui_EventMaximumCount
 }; // @ AGGREGATE
 
-class CurrMapData {
-	friend class DungeonMan;
-
+struct CurrMapData {
 	direction partyDir; // @ G0308_i_PartyDirection
 	uint16 partyPosX; // @ G0306_i_PartyMapX
 	uint16 partyPosY; // @ G0307_i_PartyMapY
@@ -168,9 +410,6 @@ class CurrMapData {
 }; // @ AGGREGATE
 
 struct Messages {
-	friend class DungeonMan;
-
-private:
 	bool newGame = true; // @ G0298_B_NewGame
 	bool restartGameRequest = false; // @ G0523_B_RestartGameRequested
 }; // @ AGGREGATE
@@ -181,17 +420,6 @@ private:
 class DungeonMan {
 	DMEngine *_vm;
 
-	uint32 _rawDunFileDataSize;	 // @ probably NONE
-	byte *_rawDunFileData; // @ ???
-	DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader
-
-	DungeonData _dunData; // @ NONE
-	CurrMapData _currMap; // @ NONE
-	Map *_maps; // @ G0277_ps_DungeonMaps
-	// does not have to be freed
-	byte *_rawMapData; // @ G0276_puc_DungeonRawMapData
-	Messages _messages; // @ NONE
-
 	DungeonMan(const DungeonMan &other); // no implementation on purpose
 	void operator=(const DungeonMan &rhs); // no implementation on purpose
 
@@ -200,19 +428,49 @@ class DungeonMan {
 
 	void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon
 
-	Thing getSqureFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex
+	int16 getSquareFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex
+	Thing getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing
+
+	int16 getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal
+	void setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
+									int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals
+
+	bool isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove
+
+	void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
+
+	Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing)
+	uint16 *getThingData(Thing thing); // @ unsigned char* F0156_DUNGEON_GetThingData(register THING P0276_T_Thing)
 public:
 	DungeonMan(DMEngine *dmEngine);
 	~DungeonMan();
 	// TODO: this does stuff other than load the file!
 	void loadDungeonFile();	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
-	void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
+	void setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap
+
 	void mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement
 	SquareType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
 		return Square(getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType();
 	} // @ F0153_DUNGEON_GetRelativeSquareType
+	void setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect
+
+	uint32 _rawDunFileDataSize;	 // @ probably NONE
+	byte *_rawDunFileData; // @ ???
+	DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader
+
+	DungeonData _dunData; // @ NONE
+	CurrMapData _currMap; // @ NONE
+	Map *_maps; // @ G0277_ps_DungeonMaps
+	// does not have to be freed
+	byte *_rawMapData; // @ G0276_puc_DungeonRawMapData
+	Messages _messages; // @ NONE;
+
+	int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex
+
+
 };
 
 }
 
+
 #endif
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 385b23f..ae5bcd9 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1,33 +1,456 @@
-#include "gfx.h"
 #include "engines/util.h"
 #include "common/system.h"
 #include "common/file.h"
 #include "graphics/palette.h"
 #include "common/endian.h"
-#include "dm/dungeonman.h"
+
+#include "gfx.h"
+#include "dungeonman.h"
 
 
 namespace DM {
 
-// TODO: this is ONLY for the Amiga version, name will have to be refactored
-uint16 dmPalettes[10][16] = {
-	{0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0},
-	{0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x000, 0xAAA, 0x00F, 0xFFF},
-	{0x006, 0x0AA, 0xFF6, 0x840, 0xFF8, 0x000, 0x080, 0xA00, 0xC84, 0xFFA, 0xF84, 0xFC0, 0xFA0, 0x000, 0x620, 0xFFC},
-	{0x000, 0x666, 0x888, 0x840, 0xCA8, 0x0C0, 0x080, 0x0A0, 0x864, 0xF00, 0xA86, 0x642, 0x444, 0xAAA, 0x620, 0xFFF},
-	{0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x444, 0xAAA, 0x00F, 0xFFF},
-	{0x000, 0x444, 0x666, 0x620, 0x0CC, 0x820, 0x060, 0x0A0, 0xC00, 0x000, 0x000, 0xFC0, 0x222, 0x888, 0x00C, 0xCCC},
-	{0x000, 0x222, 0x444, 0x420, 0x0CC, 0x620, 0x040, 0x080, 0xA00, 0x000, 0x000, 0xFA0, 0x000, 0x666, 0x00A, 0xAAA},
-	{0x000, 0x000, 0x222, 0x200, 0x0CC, 0x420, 0x020, 0x060, 0x800, 0x000, 0x000, 0xC80, 0x000, 0x444, 0x008, 0x888},
-	{0x000, 0x000, 0x000, 0x000, 0x0CC, 0x200, 0x000, 0x040, 0x600, 0x000, 0x000, 0xA60, 0x000, 0x222, 0x006, 0x666},
-	{0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444}
+
+#define kFirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT
+#define kFirstFloorSet 75 // @ C075_GRAPHIC_FIRST_FLOOR_SET
+#define kFirstWallSet 77 // @ C077_GRAPHIC_FIRST_WALL_SET
+#define kFirstStairs 90 // @ C090_GRAPHIC_FIRST_STAIRS
+#define kFirstDoorSet 108 // @ C108_GRAPHIC_FIRST_DOOR_SET
+#define kInscriptionFont 120 // @ C120_GRAPHIC_INSCRIPTION_FONT
+#define kFirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT
+#define kFirstFloorOrn 247 // @ C247_GRAPHIC_FIRST_FLOOR_ORNAMENT
+#define kFirstDoorOrn 303 // @ C303_GRAPHIC_FIRST_DOOR_ORNAMENT
+
+
+byte gDoorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordinateSetIndices
+	0,   /* Door Ornament #00 Square Grid */
+	1,   /* Door Ornament #01 Iron Bars */
+	1,   /* Door Ornament #02 Jewels */
+	1,   /* Door Ornament #03 Wooden Bars */
+	0,   /* Door Ornament #04 Arched Grid */
+	2,   /* Door Ornament #05 Block Lock */
+	3,   /* Door Ornament #06 Corner Lock */
+	1,   /* Door Ornament #07 Black door */
+	2,   /* Door Ornament #08 Red Triangle Lock */
+	2,   /* Door Ornament #09 Triangle Lock */
+	1,   /* Door Ornament #10 Ra Door */
+	1}; /* Door Ornament #11 Iron Door Damages */
+
+byte gFloorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnamentCoordinateSetIndices
+	0,   /* Floor Ornament 00 Square Grate */
+	0,   /* Floor Ornament 01 Square Pressure Pad */
+	0,   /* Floor Ornament 02 Moss */
+	0,   /* Floor Ornament 03 Round Grate */
+	2,   /* Floor Ornament 04 Round Pressure Plate */
+	0,   /* Floor Ornament 05 Black Flame Pit */
+	0,   /* Floor Ornament 06 Crack */
+	2,   /* Floor Ornament 07 Tiny Pressure Pad */
+	0}; /* Floor Ornament 08 Puddle */
+
+byte gWallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets
+	/* { X1, X2, Y1, Y2, PixelWidth, Height } */
+	{{80,  83, 41,  45,  8 * 2,   5},     /* D3L */
+	{140, 143, 41,  45,  8 * 2,   5},     /* D3R */
+	{16,  29, 39,  50,  8 * 2,  12},     /* D3L */
+	{107, 120, 39,  50,  8 * 2,  12},     /* D3C */
+	{187, 200, 39,  50,  8 * 2,  12},     /* D3R */
+	{67,  77, 40,  49,  8 * 2,  10},     /* D2L */
+	{146, 156, 40,  49,  8 * 2,  10},     /* D2R */
+	{0,  17, 38,  55, 16 * 2,  18},     /* D2L */
+	{102, 123, 38,  55, 16 * 2,  18},     /* D2C */
+	{206, 223, 38,  55, 16 * 2,  18},     /* D2R */
+	{48,  63, 38,  56,  8 * 2,  19},     /* D1L */
+	{160, 175, 38,  56,  8 * 2,  19},     /* D1R */
+	{96, 127, 36,  63, 16 * 2,  28}},   /* D1C */
+	{{74,  82, 41,  60,  8 * 2,  20},     /* D3L */
+	{141, 149, 41,  60,  8 * 2,  20},     /* D3R */
+	{1,  47, 37,  63, 24 * 2,  27},     /* D3L */
+	{88, 134, 37,  63, 24 * 2,  27},     /* D3C */
+	{171, 217, 37,  63, 24 * 2,  27},     /* D3R */
+	{61,  76, 38,  67,  8 * 2,  30},     /* D2L */
+	{147, 162, 38,  67,  8 * 2,  30},     /* D2R */
+	{0,  43, 37,  73, 32 * 2,  37},     /* D2L */
+	{80, 143, 37,  73, 32 * 2,  37},     /* D2C */
+	{180, 223, 37,  73, 32 * 2,  37},     /* D2R */
+	{32,  63, 36,  83, 16 * 2,  48},     /* D1L */
+	{160, 191, 36,  83, 16 * 2,  48},     /* D1R */
+	{64, 159, 36,  91, 48 * 2,  56}},   /* D1C */
+	{{80,  83, 66,  70,  8 * 2,   5},     /* D3L */
+	{140, 143, 66,  70,  8 * 2,   5},     /* D3R */
+	{16,  29, 64,  75,  8 * 2,  12},     /* D3L */
+	{106, 119, 64,  75,  8 * 2,  12},     /* D3C */
+	{187, 200, 64,  75,  8 * 2,  12},     /* D3R */
+	{67,  77, 74,  83,  8 * 2,  10},     /* D2L */
+	{146, 156, 74,  83,  8 * 2,  10},     /* D2R */
+	{0,  17, 73,  90, 16 * 2,  18},     /* D2L */
+	{100, 121, 73,  90, 16 * 2,  18},     /* D2C */
+	{206, 223, 73,  90, 16 * 2,  18},     /* D2R */
+	{48,  63, 84, 102,  8 * 2,  19},     /* D1L */
+	{160, 175, 84, 102,  8 * 2,  19},     /* D1R */
+	{96, 127, 92, 119, 16 * 2,  28}},   /* D1C */
+	{{80,  83, 49,  53,  8 * 2,   5},     /* D3L */
+	{140, 143, 49,  53,  8 * 2,   5},     /* D3R */
+	{16,  29, 50,  61,  8 * 2,  12},     /* D3L */
+	{106, 119, 50,  61,  8 * 2,  12},     /* D3C */
+	{187, 200, 50,  61,  8 * 2,  12},     /* D3R */
+	{67,  77, 53,  62,  8 * 2,  10},     /* D2L */
+	{146, 156, 53,  62,  8 * 2,  10},     /* D2R */
+	{0,  17, 55,  72, 16 * 2,  18},     /* D2L */
+	{100, 121, 55,  72, 16 * 2,  18},     /* D2C */
+	{206, 223, 55,  72, 16 * 2,  18},     /* D2R */
+	{48,  63, 57,  75,  8 * 2,  19},     /* D1L */
+	{160, 175, 57,  75,  8 * 2,  19},     /* D1R */
+	{96, 127, 64,  91, 16 * 2,  28}},   /* D1C */
+	{{75,  90, 40,  44,  8 * 2,   5},     /* D3L */
+	{133, 148, 40,  44,  8 * 2,   5},     /* D3R */
+	{1,  48, 44,  49, 24 * 2,   6},     /* D3L */
+	{88, 135, 44,  49, 24 * 2,   6},     /* D3C */
+	{171, 218, 44,  49, 24 * 2,   6},     /* D3R */
+	{60,  77, 40,  46, 16 * 2,   7},     /* D2L */
+	{146, 163, 40,  46, 16 * 2,   7},     /* D2R */
+	{0,  35, 43,  50, 32 * 2,   8},     /* D2L */
+	{80, 143, 43,  50, 32 * 2,   8},     /* D2C */
+	{184, 223, 43,  50, 32 * 2,   8},     /* D2R */
+	{32,  63, 41,  52, 16 * 2,  12},     /* D1L */
+	{160, 191, 41,  52, 16 * 2,  12},     /* D1R */
+	{64, 159, 41,  52, 48 * 2,  12}},   /* D1C */
+	{{78,  85, 36,  51,  8 * 2,  16},     /* D3L */
+	{138, 145, 36,  51,  8 * 2,  16},     /* D3R */
+	{10,  41, 34,  53, 16 * 2,  20},     /* D3L */
+	{98, 129, 34,  53, 16 * 2,  20},     /* D3C */
+	{179, 210, 34,  53, 16 * 2,  20},     /* D3R */
+	{66,  75, 34,  56,  8 * 2,  23},     /* D2L */
+	{148, 157, 34,  56,  8 * 2,  23},     /* D2R */
+	{0,  26, 33,  61, 24 * 2,  29},     /* D2L */
+	{91, 133, 33,  61, 24 * 2,  29},     /* D2C */
+	{194, 223, 33,  61, 24 * 2,  29},     /* D2R */
+	{41,  56, 31,  65,  8 * 2,  35},     /* D1L */
+	{167, 182, 31,  65,  8 * 2,  35},     /* D1R */
+	{80, 143, 29,  71, 32 * 2,  43}},   /* D1C */
+	{{75,  82, 25,  75,  8 * 2,  51},     /* D3L */
+	{142, 149, 25,  75,  8 * 2,  51},     /* D3R */
+	{12,  60, 25,  75, 32 * 2,  51},     /* D3L */
+	{88, 136, 25,  75, 32 * 2,  51},     /* D3C */
+	{163, 211, 25,  75, 32 * 2,  51},     /* D3R */
+	{64,  73, 20,  90,  8 * 2,  71},     /* D2L */
+	{150, 159, 20,  90,  8 * 2,  71},     /* D2R */
+	{0,  38, 20,  90, 32 * 2,  71},     /* D2L */
+	{82, 142, 20,  90, 32 * 2,  71},     /* D2C */
+	{184, 223, 20,  90, 32 * 2,  71},     /* D2R */
+	{41,  56,  9, 119,  8 * 2, 111},     /* D1L */
+	{169, 184,  9, 119,  8 * 2, 111},     /* D1R */
+	{64, 159,  9, 119, 48 * 2, 111}},   /* D1C */
+	{{74,  85, 25,  75,  8 * 2,  51},     /* D3L */
+	{137, 149, 25,  75,  8 * 2,  51},     /* D3R */
+	{0,  75, 25,  75, 40 * 2,  51},     /* D3L Atari ST: {   0,  83, 25,  75, 48*2,  51 } */
+	{74, 149, 25,  75, 40 * 2,  51},     /* D3C Atari ST: {  74, 149, 25,  75, 48*2,  51 } */
+	{148, 223, 25,  75, 40 * 2,  51},     /* D3R Atari ST: { 139, 223, 25,  75, 48*2,  51 } */
+	{60,  77, 20,  90, 16 * 2,  71},     /* D2L */
+	{146, 163, 20,  90, 16 * 2,  71},     /* D2R */
+	{0,  74, 20,  90, 56 * 2,  71},     /* D2L */
+	{60, 163, 20,  90, 56 * 2,  71},     /* D2C */
+	{149, 223, 20,  90, 56 * 2,  71},     /* D2R */
+	{32,  63,  9, 119, 16 * 2, 111},     /* D1L */
+	{160, 191,  9, 119, 16 * 2, 111},     /* D1R */
+	{32, 191,  9, 119, 80 * 2, 111}}}; /* D1C */
+
+byte gWallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoordinateSetIndices
+	1,   /* Wall Ornament 00 Unreadable Inscription */
+	1,   /* Wall Ornament 01 Square Alcove */
+	1,   /* Wall Ornament 02 Vi Altar */
+	1,   /* Wall Ornament 03 Arched Alcove */
+	0,   /* Wall Ornament 04 Hook */
+	0,   /* Wall Ornament 05 Iron Lock */
+	0,   /* Wall Ornament 06 Wood Ring */
+	0,   /* Wall Ornament 07 Small Switch */
+	0,   /* Wall Ornament 08 Dent 1 */
+	0,   /* Wall Ornament 09 Dent 2 */
+	0,   /* Wall Ornament 10 Iron Ring */
+	2,   /* Wall Ornament 11 Crack */
+	3,   /* Wall Ornament 12 Slime Outlet */
+	0,   /* Wall Ornament 13 Dent 3 */
+	0,   /* Wall Ornament 14 Tiny Switch */
+	0,   /* Wall Ornament 15 Green Switch Out */
+	0,   /* Wall Ornament 16 Blue Switch Out */
+	0,   /* Wall Ornament 17 Coin Slot */
+	0,   /* Wall Ornament 18 Double Iron Lock */
+	0,   /* Wall Ornament 19 Square Lock */
+	0,   /* Wall Ornament 20 Winged Lock */
+	0,   /* Wall Ornament 21 Onyx Lock */
+	0,   /* Wall Ornament 22 Stone Lock */
+	0,   /* Wall Ornament 23 Cross Lock */
+	0,   /* Wall Ornament 24 Topaz Lock */
+	0,   /* Wall Ornament 25 Skeleton Lock */
+	0,   /* Wall Ornament 26 Gold Lock */
+	0,   /* Wall Ornament 27 Tourquoise Lock */
+	0,   /* Wall Ornament 28 Emerald Lock */
+	0,   /* Wall Ornament 29 Ruby Lock */
+	0,   /* Wall Ornament 30 Ra Lock */
+	0,   /* Wall Ornament 31 Master Lock */
+	0,   /* Wall Ornament 32 Gem Hole */
+	2,   /* Wall Ornament 33 Slime */
+	2,   /* Wall Ornament 34 Grate */
+	1,   /* Wall Ornament 35 Fountain */
+	1,   /* Wall Ornament 36 Manacles */
+	1,   /* Wall Ornament 37 Ghoul's Head */
+	1,   /* Wall Ornament 38 Empty Torch Holder */
+	1,   /* Wall Ornament 39 Scratches */
+	4,   /* Wall Ornament 40 Poison Holes */
+	4,   /* Wall Ornament 41 Fireball Holes */
+	4,   /* Wall Ornament 42 Dagger Holes */
+	5,   /* Wall Ornament 43 Champion Mirror */
+	0,   /* Wall Ornament 44 Lever Up */
+	0,   /* Wall Ornament 45 Lever Down */
+	1,   /* Wall Ornament 46 Full Torch Holder */
+	0,   /* Wall Ornament 47 Red Switch Out */
+	0,   /* Wall Ornament 48 Eye Switch */
+	0,   /* Wall Ornament 49 Big Switch Out */
+	2,   /* Wall Ornament 50 Crack Switch Out */
+	0,   /* Wall Ornament 51 Green Switch In */
+	0,   /* Wall Ornament 52 Blue Switch In */
+	0,   /* Wall Ornament 53 Red Switch In */
+	0,   /* Wall Ornament 54 Big Switch In */
+	2,   /* Wall Ornament 55 Crack Switch In. Atari ST Version 1.0 1987-12-08: 0  */
+	6,   /* Wall Ornament 56 Amalgam (Encased Gem) */
+	6,   /* Wall Ornament 57 Amalgam (Free Gem) */
+	6,   /* Wall Ornament 58 Amalgam (Without Gem) */
+	7}; /* Wall Ornament 59 Lord Order (Outside) */
+
+struct CreatureAspect {
+	uint16 firstNativeBitmapRelativeIndex;
+	uint16 firstDerivedBitmapIndex;
+	byte byteWidthFront;
+	byte heightFront;
+	byte byteWidthSide;
+	byte heightSide;
+	byte byteWidthAttack;
+	byte heightAttack;
+	byte coordinateSet_TransparentColor;
+	byte replacementColorSetIndices;
+
+	byte getCoordSet() { return (coordinateSet_TransparentColor >> 4) & 0xF; } // @ M71_COORDINATE_SET
+	byte getTranspColour() { return  coordinateSet_TransparentColor & 0xF; } // @ M72_TRANSPARENT_COLOR
+	byte getReplColour10() { return (replacementColorSetIndices >> 4) & 0xF; } // @ M74_COLOR_10_REPLACEMENT_COLOR_SET
+	byte getReplColour9() { return replacementColorSetIndices & 0xF; } // @ M73_COLOR_09_REPLACEMENT_COLOR_SET
+}; // @ CREATURE_ASPECT
+
+
+CreatureAspect gCreatureAspects[kCreatureTypeCount] = { // @ G0219_as_Graphic558_CreatureAspects
+/* { FirstNativeBitmapRelativeIndex, FirstDerivedBitmapIndex, pixelWidthFront, HeightFront,
+pixelWidthSide, HeightSide, pixelWidthAttack, HeightAttack, CoordinateSet / TransparentColor,
+Replacement Color Set Index for color 10 / Replacement Color Set Index for color 9 } */
+	{0, 0, 56 * 2,  84, 56 * 2,  84, 56 * 2,  84, 0x1D, 0x01},   /* Creature #00 Giant Scorpion / Scorpion */
+	{4, 0, 32 * 2,  66,  0 * 2,   0, 32 * 2,  69, 0x0B, 0x20},   /* Creature #01 Swamp Slime / Slime Devil */
+	{6, 0, 24 * 2,  48, 24 * 2,  48,  0 * 2,   0, 0x0B, 0x00},   /* Creature #02 Giggler */
+	{10, 0, 32 * 2,  61,  0 * 2,   0, 32 * 2,  61, 0x24, 0x31},   /* Creature #03 Wizard Eye / Flying Eye */
+	{12, 0, 32 * 2,  64, 56 * 2,  64, 32 * 2,  64, 0x14, 0x34},   /* Creature #04 Pain Rat / Hellhound */
+	{16, 0, 24 * 2,  49, 40 * 2,  49,  0 * 2,   0, 0x18, 0x34},   /* Creature #05 Ruster */
+	{19, 0, 32 * 2,  60,  0 * 2,   0, 32 * 2,  60, 0x0D, 0x00},   /* Creature #06 Screamer */
+	{21, 0, 32 * 2,  43,  0 * 2,   0, 32 * 2,  64, 0x04, 0x00},   /* Creature #07 Rockpile / Rock pile */
+	{23, 0, 32 * 2,  83,  0 * 2,   0, 32 * 2,  93, 0x04, 0x00},   /* Creature #08 Ghost / Rive */
+	{25, 0, 32 * 2, 101, 32 * 2, 101, 32 * 2, 101, 0x14, 0x00},   /* Creature #09 Stone Golem */
+	{29, 0, 32 * 2,  82, 32 * 2,  82, 32 * 2,  83, 0x04, 0x00},   /* Creature #10 Mummy */
+	{33, 0, 32 * 2,  80,  0 * 2,   0, 32 * 2,  99, 0x14, 0x00},   /* Creature #11 Black Flame */
+	{35, 0, 32 * 2,  80, 32 * 2,  80, 32 * 2,  76, 0x04, 0x00},   /* Creature #12 Skeleton */
+	{39, 0, 32 * 2,  96, 56 * 2,  93, 32 * 2,  90, 0x1D, 0x20},   /* Creature #13 Couatl */
+	{43, 0, 32 * 2,  49, 16 * 2,  49, 32 * 2,  56, 0x04, 0x30},   /* Creature #14 Vexirk */
+	{47, 0, 32 * 2,  59, 56 * 2,  43, 32 * 2,  67, 0x14, 0x78},   /* Creature #15 Magenta Worm / Worm */
+	{51, 0, 32 * 2,  83, 32 * 2,  74, 32 * 2,  74, 0x04, 0x65},   /* Creature #16 Trolin / Ant Man */
+	{55, 0, 24 * 2,  49, 24 * 2,  53, 24 * 2,  53, 0x24, 0x00},   /* Creature #17 Giant Wasp / Muncher */
+	{59, 0, 32 * 2,  89, 32 * 2,  89, 32 * 2,  89, 0x04, 0x00},   /* Creature #18 Animated Armour / Deth Knight */
+	{63, 0, 32 * 2,  84, 32 * 2,  84, 32 * 2,  84, 0x0D, 0xA9},   /* Creature #19 Materializer / Zytaz */
+	{67, 0, 56 * 2,  27,  0 * 2,   0, 56 * 2,  80, 0x04, 0x65},   /* Creature #20 Water Elemental */
+	{69, 0, 56 * 2,  77, 56 * 2,  81, 56 * 2,  77, 0x04, 0xA9},   /* Creature #21 Oitu */
+	{73, 0, 32 * 2,  87, 32 * 2,  89, 32 * 2,  89, 0x04, 0xCB},   /* Creature #22 Demon */
+	{77, 0, 32 * 2,  96, 32 * 2,  94, 32 * 2,  96, 0x04, 0x00},   /* Creature #23 Lord Chaos */
+	{81, 0, 64 * 2,  94, 72 * 2,  94, 64 * 2,  94, 0x04, 0xCB},   /* Creature #24 Red Dragon / Dragon */
+	{85, 0, 32 * 2,  93,  0 * 2,   0,  0 * 2,   0, 0x04, 0xCB},   /* Creature #25 Lord Order */
+	{86, 0, 32 * 2,  93,  0 * 2,   0,  0 * 2,   0, 0x04, 0xCB}}; /* Creature #26 Grey Lord */
+
+struct ObjectAspect {
+	byte firstNativeBitmapRelativeIndex;
+	byte firstDerivedBitmapRelativeIndex;
+	byte width;
+	byte height;
+	byte graphicInfo; /* Bits 7-5 and 3-1 Unreferenced */
+	byte coordinateSet;
+	ObjectAspect(byte firstN, byte firstD, byte byteWidth, byte h, byte grap, byte coord) :
+		firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD),
+		width(byteWidth * 2), height(h), graphicInfo(grap), coordinateSet(coord) {}
+}; // @ OBJECT_ASPECT
+
+ObjectAspect gObjectAspects[kObjAspectCount] = { // @ G0209_as_Graphic558_ObjectAspects
+	/* FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo, CoordinateSet */
+	ObjectAspect(0,   0, 24, 27, 0x11, 0),
+	ObjectAspect(2,   6, 24,  8, 0x00, 1),
+	ObjectAspect(3,   8,  8, 18, 0x00, 1),
+	ObjectAspect(4,  10,  8,  8, 0x00, 1),
+	ObjectAspect(5,  12,  8,  4, 0x00, 1),
+	ObjectAspect(6,  14, 16, 11, 0x00, 1),
+	ObjectAspect(7,  16, 24, 13, 0x00, 0),
+	ObjectAspect(8,  18, 32, 16, 0x00, 0),
+	ObjectAspect(9,  20, 40, 24, 0x00, 0),
+	ObjectAspect(10,  22, 16, 20, 0x00, 1),
+	ObjectAspect(11,  24, 40, 20, 0x00, 0),
+	ObjectAspect(12,  26, 32,  4, 0x00, 1),
+	ObjectAspect(13,  28, 40,  8, 0x00, 1),
+	ObjectAspect(14,  30, 32, 17, 0x00, 0),
+	ObjectAspect(15,  32, 40, 17, 0x00, 2),
+	ObjectAspect(16,  34, 16,  9, 0x00, 1),
+	ObjectAspect(17,  36, 24,  5, 0x00, 1),
+	ObjectAspect(18,  38, 16,  9, 0x00, 0),
+	ObjectAspect(19,  40,  8,  4, 0x00, 1),
+	ObjectAspect(20,  42, 32, 21, 0x00, 2),
+	ObjectAspect(21,  44, 32, 25, 0x00, 2),
+	ObjectAspect(22,  46, 32, 14, 0x00, 1),
+	ObjectAspect(23,  48, 32, 26, 0x00, 2),
+	ObjectAspect(24,  50, 32, 16, 0x00, 0),
+	ObjectAspect(25,  52, 32, 16, 0x00, 0),
+	ObjectAspect(26,  54, 16, 16, 0x00, 1),
+	ObjectAspect(27,  56, 16, 15, 0x00, 1),
+	ObjectAspect(28,  58, 16, 13, 0x00, 1),
+	ObjectAspect(29,  60, 16, 10, 0x00, 1),
+	ObjectAspect(30,  62, 40, 24, 0x00, 0),
+	ObjectAspect(31,  64, 40,  9, 0x00, 1),
+	ObjectAspect(32,  66, 16,  3, 0x00, 1),
+	ObjectAspect(33,  68, 32,  5, 0x00, 1),
+	ObjectAspect(34,  70, 40, 16, 0x00, 0),
+	ObjectAspect(35,  72,  8,  7, 0x00, 1),
+	ObjectAspect(36,  74, 32,  7, 0x00, 1),
+	ObjectAspect(37,  76, 24, 14, 0x00, 0),
+	ObjectAspect(38,  78, 16,  8, 0x00, 0),
+	ObjectAspect(39,  80,  8,  3, 0x00, 1),
+	ObjectAspect(40,  82, 40,  9, 0x00, 1),
+	ObjectAspect(41,  84, 24, 14, 0x00, 0),
+	ObjectAspect(42,  86, 40, 20, 0x00, 0),
+	ObjectAspect(43,  88, 40, 15, 0x00, 1),
+	ObjectAspect(44,  90, 32, 10, 0x00, 1),
+	ObjectAspect(45,  92, 32, 19, 0x00, 0),
+	ObjectAspect(46,  94, 40, 25, 0x00, 2),
+	ObjectAspect(47,  96, 24,  7, 0x00, 1),
+	ObjectAspect(48,  98,  8,  7, 0x00, 1),
+	ObjectAspect(49, 100, 16,  5, 0x00, 1),
+	ObjectAspect(50, 102,  8,  9, 0x00, 1),
+	ObjectAspect(51, 104, 32, 11, 0x00, 1),
+	ObjectAspect(52, 106, 32, 14, 0x00, 0),
+	ObjectAspect(53, 108, 24, 20, 0x00, 0),
+	ObjectAspect(54, 110, 16, 14, 0x00, 1),
+	ObjectAspect(55, 112, 32, 23, 0x00, 0),
+	ObjectAspect(56, 114, 24, 16, 0x00, 0),
+	ObjectAspect(57, 116, 32, 25, 0x00, 0),
+	ObjectAspect(58, 118, 24, 25, 0x00, 0),
+	ObjectAspect(59, 120,  8,  8, 0x00, 1),
+	ObjectAspect(60, 122,  8,  7, 0x00, 1),
+	ObjectAspect(61, 124,  8,  8, 0x00, 1),
+	ObjectAspect(62, 126,  8,  8, 0x00, 1),
+	ObjectAspect(63, 128,  8,  5, 0x00, 1),
+	ObjectAspect(64, 130,  8, 13, 0x01, 1),
+	ObjectAspect(65, 134, 16, 13, 0x00, 1),
+	ObjectAspect(66, 136, 16, 14, 0x00, 0),
+	ObjectAspect(67, 138, 16, 10, 0x00, 1),
+	ObjectAspect(68, 140,  8, 18, 0x00, 1),
+	ObjectAspect(69, 142,  8, 17, 0x00, 1),
+	ObjectAspect(70, 144, 32, 18, 0x00, 0),
+	ObjectAspect(71, 146, 16, 23, 0x00, 0),
+	ObjectAspect(72, 148, 16, 24, 0x00, 0),
+	ObjectAspect(73, 150, 16, 15, 0x00, 0),
+	ObjectAspect(74, 152,  8,  7, 0x00, 1),
+	ObjectAspect(75, 154,  8, 15, 0x00, 1),
+	ObjectAspect(76, 156,  8,  9, 0x00, 1),
+	ObjectAspect(77, 158, 16, 14, 0x00, 0),
+	ObjectAspect(78, 160,  8,  8, 0x00, 1),
+	ObjectAspect(79, 162, 16,  9, 0x00, 1),
+	ObjectAspect(80, 164,  8, 13, 0x01, 1),
+	ObjectAspect(81, 168,  8, 18, 0x00, 1),
+	ObjectAspect(82, 170, 24, 28, 0x00, 0),
+	ObjectAspect(83, 172, 40, 13, 0x00, 1),
+	ObjectAspect(84, 174,  8,  4, 0x00, 1),
+	ObjectAspect(85, 176, 32, 17, 0x00, 0)};
+
+struct ProjectileAspect {
+	byte firstNativeBitmapRelativeIndex;
+	byte firstDerivedBitmapRelativeIndex;
+	byte width;
+	byte height;
+	uint16 graphicInfo; /* Bits 15-9, 7-5 and 3-2 Unreferenced */
+
+	ProjectileAspect(byte firstN, byte firstD, byte byteWidth, byte h, uint16 grap) :
+		firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD),
+		width(byteWidth * 2), height(h), graphicInfo(grap) {}
+}; // @ PROJECTIL_ASPECT
+
+
+ProjectileAspect gProjectileAspect[kProjectileAspectCount] = { // @ G0210_as_Graphic558_ProjectileAspects
+	/* ProjectileAspect( FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo ) */
+	ProjectileAspect(0,   0, 32, 11, 0x0011),   /* Arrow */
+	ProjectileAspect(3,  18, 16, 11, 0x0011),   /* Dagger */
+	ProjectileAspect(6,  36, 24, 47, 0x0010),   /* Axe - Executioner */
+	ProjectileAspect(9,  54, 32, 15, 0x0112),   /* Explosion Lightning Bolt */
+	ProjectileAspect(11,  54, 32, 12, 0x0011),   /* Slayer */
+	ProjectileAspect(14,  72, 24, 47, 0x0010),   /* Stone Club */
+	ProjectileAspect(17,  90, 24, 47, 0x0010),   /* Club */
+	ProjectileAspect(20, 108, 16, 11, 0x0011),   /* Poison Dart */
+	ProjectileAspect(23, 126, 48, 18, 0x0011),   /* Storm - Side Splitter - Diamond Edge - Falchion - Ra Blade - Rapier - Biter - Samurai Sword - Sword - Dragon Fang */
+	ProjectileAspect(26, 144,  8, 15, 0x0012),   /* Throwing Star */
+	ProjectileAspect(28, 156, 16, 28, 0x0103),   /* Explosion Fireball */
+	ProjectileAspect(29, 156, 16, 11, 0x0103),   /* Explosion Default */
+	ProjectileAspect(30, 156, 16, 28, 0x0103),   /* Explosion Slime */
+	ProjectileAspect(31, 156, 16, 24, 0x0103) /* Explosion Poison Bolt Poison Cloud */
 };
 
 
+// TODO: this is ONLY for the Amiga version, name will have to be refactored
+
+/* Identical to the palette at the end of the swoosh palette animation */
+uint16 gPalSwoosh[16] = {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}; // @ K0057_aui_Palette_Swoosh
+uint16 gPalMousePointer[16] = {0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x000, 0xAAA, 0x00F, 0xFFF}; // @ K0150_aui_Palette_MousePointer
+/* Atari ST: { 0x003, 0x055, 0x773, 0x420, 0x774, 0x000, 0x040, 0x500, 0x642, 0x775, 0x742, 0x760, 0x750, 0x000, 0x310, 0x776 }, RGB colors are different */
+uint16 gPalCredits[16] = {0x006, 0x0AA, 0xFF6, 0x840, 0xFF8, 0x000, 0x080, 0xA00, 0xC84, 0xFFA, 0xF84, 0xFC0, 0xFA0, 0x000, 0x620, 0xFFC}; // @ G0019_aui_Graphic562_Palette_Credits
+/* Atari ST: { 0x000, 0x333, 0x444, 0x420, 0x654, 0x210, 0x040, 0x050, 0x432, 0x700, 0x543, 0x321, 0x222, 0x555, 0x310, 0x777 }, RGB colors are different */
+uint16 gPalEntrance[16] = {0x000, 0x666, 0x888, 0x840, 0xCA8, 0x0C0, 0x080, 0x0A0, 0x864, 0xF00, 0xA86, 0x642, 0x444, 0xAAA, 0x620, 0xFFF}; // @ G0020_aui_Graphic562_Palette_Entrance
+uint16 gPalDungeonView[6][16] = { // @ G0021_aaui_Graphic562_Palette_DungeonView
+	/* Atari ST: { 0x000, 0x333, 0x444, 0x310, 0x066, 0x420, 0x040, 0x060, 0x700, 0x750, 0x643, 0x770, 0x222, 0x555, 0x007, 0x777 }, RGB colors are different */
+	0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x444, 0xAAA, 0x00F, 0xFFF,
+	/* Atari ST: { 0x000, 0x222, 0x333, 0x310, 0x066, 0x410, 0x030, 0x050, 0x600, 0x640, 0x532, 0x760, 0x111, 0x444, 0x006, 0x666 }, RGB colors are different */
+	0x000, 0x444, 0x666, 0x620, 0x0CC, 0x820, 0x060, 0x0A0, 0xC00, 0x000, 0x000, 0xFC0, 0x222, 0x888, 0x00C, 0xCCC,
+	/* Atari ST: { 0x000, 0x111, 0x222, 0x210, 0x066, 0x310, 0x020, 0x040, 0x500, 0x530, 0x421, 0x750, 0x000, 0x333, 0x005, 0x555 }, RGB colors are different */
+	0x000, 0x222, 0x444, 0x420, 0x0CC, 0x620, 0x040, 0x080, 0xA00, 0x000, 0x000, 0xFA0, 0x000, 0x666, 0x00A, 0xAAA,
+	/* Atari ST: { 0x000, 0x000, 0x111, 0x100, 0x066, 0x210, 0x010, 0x030, 0x400, 0x420, 0x310, 0x640, 0x000, 0x222, 0x004, 0x444 }, RGB colors are different */
+	0x000, 0x000, 0x222, 0x200, 0x0CC, 0x420, 0x020, 0x060, 0x800, 0x000, 0x000, 0xC80, 0x000, 0x444, 0x008, 0x888,
+	/* Atari ST: { 0x000, 0x000, 0x000, 0x000, 0x066, 0x100, 0x000, 0x020, 0x300, 0x310, 0x200, 0x530, 0x000, 0x111, 0x003, 0x333 }, RGB colors are different */
+	0x000, 0x000, 0x000, 0x000, 0x0CC, 0x200, 0x000, 0x040, 0x600, 0x000, 0x000, 0xA60, 0x000, 0x222, 0x006, 0x666,
+	/* Atari ST: { 0x000, 0x000, 0x000, 0x000, 0x066, 0x000, 0x000, 0x010, 0x200, 0x200, 0x100, 0x320, 0x000, 0x000, 0x002, 0x222 }, RGB colors are different */
+	0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444};
+
+
+struct CreatureReplColorSet {
+	uint16 RGBColor[6];
+	byte D2ReplacementColor;
+	byte D3ReplacementColor;
+}; // @ CREATURE_REPLACEMENT_COLOR_SET
+
+CreatureReplColorSet gCreatureReplColorSets[13] = { // @ G0220_as_Graphic558_CreatureReplacementColorSets
+	/* { Color, Color, Color, Color, Color, Color, D2 replacement color index (x10), D3 replacement color index (x10) } */
+	{0x0CA0, 0x0A80, 0x0860, 0x0640, 0x0420, 0x0200,  90,  90},    /* Atari ST: { 0x0650, 0x0540, 0x0430, 0x0320, 0x0210, 0x0100,  90,  90 }, RGB colors are different */
+	{0x0060, 0x0040, 0x0020, 0x0000, 0x0000, 0x0000,   0,   0},    /* Atari ST: { 0x0030, 0x0020, 0x0010, 0x0000, 0x0000, 0x0000,   0,   0 }, */
+	{0x0860, 0x0640, 0x0420, 0x0200, 0x0000, 0x0000, 100, 100},    /* Atari ST: { 0x0430, 0x0320, 0x0210, 0x0100, 0x0000, 0x0000, 100, 100 }, */
+	{0x0640, 0x0420, 0x0200, 0x0000, 0x0000, 0x0000,  90,   0},    /* Atari ST: { 0x0320, 0x0210, 0x0100, 0x0000, 0x0000, 0x0000,  90,   0 }, */
+	{0x000A, 0x0008, 0x0006, 0x0004, 0x0002, 0x0000,  90, 100},    /* Atari ST: { 0x0005, 0x0004, 0x0003, 0x0002, 0x0001, 0x0000,  90, 100 }, */
+	{0x0008, 0x0006, 0x0004, 0x0002, 0x0000, 0x0000, 100,   0},    /* Atari ST: { 0x0004, 0x0003, 0x0002, 0x0001, 0x0000, 0x0000, 100,   0 }, */
+	{0x0808, 0x0606, 0x0404, 0x0202, 0x0000, 0x0000,  90,   0},    /* Atari ST: { 0x0404, 0x0303, 0x0202, 0x0101, 0x0000, 0x0000,  90,   0 }, */
+	{0x0A0A, 0x0808, 0x0606, 0x0404, 0x0202, 0x0000, 100,  90},    /* Atari ST: { 0x0505, 0x0404, 0x0303, 0x0202, 0x0101, 0x0000, 100,  90 }, */
+	{0x0FA0, 0x0C80, 0x0A60, 0x0840, 0x0620, 0x0400, 100,  50},    /* Atari ST: { 0x0750, 0x0640, 0x0530, 0x0420, 0x0310, 0x0200, 100,  50 }, */
+	{0x0F80, 0x0C60, 0x0A40, 0x0820, 0x0600, 0x0200,  50,  70},    /* Atari ST: { 0x0740, 0x0630, 0x0520, 0x0410, 0x0300, 0x0100,  50,  30 }, D3 replacement color index is different */
+	{0x0800, 0x0600, 0x0400, 0x0200, 0x0000, 0x0000, 100, 120},    /* Atari ST: { 0x0400, 0x0300, 0x0200, 0x0100, 0x0000, 0x0000, 100, 100 }, D3 replacement color index is different */
+	{0x0600, 0x0400, 0x0200, 0x0000, 0x0000, 0x0000, 120,   0},    /* Atari ST: { 0x0300, 0x0200, 0x0100, 0x0000, 0x0000, 0x0000, 120,   0 }, */
+	{0x0C86, 0x0A64, 0x0842, 0x0620, 0x0400, 0x0200, 100,  50}};  /* Atari ST: { 0x0643, 0x0532, 0x0421, 0x0310, 0x0200, 0x0100, 100,  50 } }; */
+
+byte gPalChangesCreature_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 0, 0, 110, 0, 20, 0, 130}; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3
+byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, 120, 130, 140, 150}; // @ G0222_auc_Graphic558_PaletteChanges_Creature_D2
+
 
 enum GraphicIndice {
-	gFloorIndice = 75,
-	gCeilingIndice = 76
+	kDoorMaskDestroyedIndice = 301 // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
 };
 
 // The frames in the orignal sources contain inclusive boundaries and byte widths, not pixel widths
@@ -50,18 +473,28 @@ Frame gWallFrameD3R2(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Fra
 extern Viewport gDefultViewPort = {0, 0};
 extern Viewport gDungeonViewport = {0, 64};	// TODO: I guessed the numbers
 
+byte gPalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges
+
+byte gPalChangesFloorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 140, 130}; // @ G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3
+byte gPalChangesFloorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2
+
+int gFountainOrnIndices[kFountainOrnCount] = {35}; // @ G0193_ai_Graphic558_FountainOrnamentIndices
+byte gAlcoveOrnIndices[kAlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrnamentIndices
+	1,   /* Square Alcove */
+	2,   /* Vi Altar */
+	3}; /* Arched Alcove */
+
 }
 
 using namespace DM;
 
 DisplayMan::DisplayMan(DMEngine *dmEngine) :
-	_vm(dmEngine), _currPalette(kPalSwoosh), _screenWidth(0), _screenHeight(0),
-	_vgaBuffer(NULL), _packedItemCount(0), _packedItemPos(NULL), _packedBitmaps(NULL),
-	_bitmaps(NULL) {}
+	_vm(dmEngine), _screenWidth(0), _screenHeight(0),
+	_vgaBuffer(NULL), _bitmaps(NULL) {}
 
 DisplayMan::~DisplayMan() {
-	delete[] _packedBitmaps;
 	delete[] _packedItemPos;
+	delete[] _packedBitmaps;
 	delete[] _vgaBuffer;
 	delete[] _bitmaps[0];
 	delete[] _bitmaps;
@@ -72,7 +505,6 @@ DisplayMan::~DisplayMan() {
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
 	_screenWidth = width;
 	_screenHeight = height;
-	loadPalette(kPalSwoosh);
 	_vgaBuffer = new byte[_screenWidth * _screenHeight];
 	clearScreen(kColorBlack);
 }
@@ -81,21 +513,37 @@ void DisplayMan::loadGraphics() {
 	Common::File f;
 	f.open("graphics.dat");
 
-	_packedItemCount = f.readUint16BE();
-	_packedItemPos = new uint32[_packedItemCount + 1];
+	grapItemCount = f.readUint16BE();
+	_packedItemPos = new uint32[grapItemCount + 1];
 	_packedItemPos[0] = 0;
-	for (uint16 i = 1; i < _packedItemCount + 1; ++i)
+	for (uint16 i = 1; i < grapItemCount + 1; ++i)
 		_packedItemPos[i] = f.readUint16BE() + _packedItemPos[i - 1];
 
-	_packedBitmaps = new uint8[_packedItemPos[_packedItemCount]];
+	_packedBitmaps = new uint8[_packedItemPos[grapItemCount]];
 
-	f.seek(2 + _packedItemCount * 4);
-	for (uint32 i = 0; i < _packedItemPos[_packedItemCount]; ++i)
+	f.seek(2 + grapItemCount * 4);
+	for (uint32 i = 0; i < _packedItemPos[grapItemCount]; ++i)
 		_packedBitmaps[i] = f.readByte();
 
 	f.close();
 
 	unpackGraphics();
+
+	for (uint16 i = kDoorOrnDestroyedMask; i <= kDoorOrnThivesEyeMask; ++i) {
+		_currMapDoorOrnInfo[i][kNativeBitmapIndex] = i + (kDoorMaskDestroyedIndice - kDoorOrnDestroyedMask);
+		_currMapDoorOrnInfo[i][kNativeCoordinateSet] = 1;
+	}
+
+	_currMapFloorOrnInfo[kFloorOrnFootprints][kNativeBitmapIndex] = 1;
+	_currMapFloorOrnInfo[kFloorOrnFootprints][kNativeCoordinateSet] = 1;
+
+	_palChangesProjectile[0] = gPalChangesFloorOrn_D3;
+	_palChangesProjectile[1] = gPalChangesFloorOrn_D2;
+	_palChangesProjectile[2] = _palChangesProjectile[3] = gPalChangesNoChanges;
+
+	loadFloorSet(kFloorSetStone);
+	loadWallSet(kWallSetStone);
+
 }
 
 void DisplayMan::unpackGraphics() {
@@ -119,18 +567,14 @@ void DisplayMan::unpackGraphics() {
 	}
 }
 
-void DisplayMan::loadPalette(dmPaletteEnum palette) {
-	if (_currPalette == palette)
-		return;
-
+void DisplayMan::loadPalette(uint16 *palette) {
 	byte colorPalette[16 * 3];
 	for (int i = 0; i < 16; ++i) {
-		colorPalette[i * 3] = (dmPalettes[palette][i] >> 8) * (256 / 16);
-		colorPalette[i * 3 + 1] = (dmPalettes[palette][i] >> 4) * (256 / 16);
-		colorPalette[i * 3 + 2] = dmPalettes[palette][i] * (256 / 16);
+		colorPalette[i * 3] = (palette[i] >> 8) * (256 / 16);
+		colorPalette[i * 3 + 1] = (palette[i] >> 4) * (256 / 16);
+		colorPalette[i * 3 + 2] = palette[i] * (256 / 16);
 	}
 	_vm->_system->getPaletteManager()->setPalette(colorPalette, 0, 16);
-	_currPalette = palette;
 }
 
 
@@ -253,7 +697,7 @@ void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) {
 	blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport);
 }
 
-void drawSquareD3L(direction dir, int16 posX, int16 posY) {
+void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
 
 }
 
@@ -278,7 +722,7 @@ enum WallSetIndices {
 };
 
 void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
-	loadPalette(kPalDungeonView0);
+	loadPalette(gPalDungeonView[0]);
 	// TODO: this is a global variable, set from here
 	bool flippedFloorCeiling = (posX + posY + dir) & 1;
 
@@ -323,17 +767,16 @@ void DisplayMan::clearBitmap(byte *bitmap, uint16 width, uint16 height, Color co
 }
 
 
-void DisplayMan::loadWallSet(WallSet set) {
+void DisplayMan::loadFloorSet(FloorSet set) {
 	// there are 2 bitmaps per set, first one is at 75
-	GraphicIndice indice = (GraphicIndice)(75 + (2 * set));
+	GraphicIndice indice = (GraphicIndice)(kFirstFloorSet + (kFloorSetGraphicCount * set));
 	_floorBitmap = _bitmaps[indice];
 	_ceilingBitmap = _bitmaps[indice + 1];
 }
 
-void DisplayMan::loadFloorSet(FloorSet set) {
-	// there are 13 bitmaps perset, first one is at 77
-	uint16 firstIndice = (set * 13) + 77;
-	for (uint16 i = 0; i < 13; ++i) {
+void DisplayMan::loadWallSet(WallSet set) {
+	uint16 firstIndice = (set * kWallSetGraphicCount) + kFirstWallSet;
+	for (uint16 i = 0; i < kWallSetGraphicCount; ++i) {
 		_wallSetBitMaps[i] = _bitmaps[i + firstIndice];
 	}
 
@@ -353,4 +796,77 @@ void DisplayMan::loadFloorSet(FloorSet set) {
 	_wallSetBitMaps[kWall_D3R2] = new byte[w * h];
 	blitToBitmap(_wallSetBitMaps[kWall_D3L2], w, h, _wallSetBitMaps[kWall_D3R2], w);
 	flipBitmapHorizontal(_wallSetBitMaps[kWall_D3R2], w, h);
-}
\ No newline at end of file
+}
+
+
+void DisplayMan::loadCurrentMapGraphics() {
+	loadFloorSet(_vm->_dungeonMan->_currMap.map->floorSet);
+	loadWallSet(_vm->_dungeonMan->_currMap.map->wallSet);
+
+	for (int16 i = 0; i < kAlcoveOrnCount; ++i)
+		_currMapAlcoveOrnIndices[i] = -1;
+	for (int16 i = 0; i < kFountainOrnCount; ++i)
+		_currMapFountainOrnIndices[i] = -1;
+
+
+
+
+	uint16 alcoveCount = 0;
+	uint16 fountainCount = 0;
+	Map &currMap = *_vm->_dungeonMan->_currMap.map;
+
+	for (uint16 i = 0; i < currMap.wallOrnCount; ++i) {
+		uint16 ornIndice = _currMapWallOrnIndices[i];
+		uint16 nativeIndice = kFirstWallOrn + ornIndice * 2;
+
+		_currMapWallOrnInfo[i][kNativeBitmapIndex] = nativeIndice;
+		for (uint16 ornCounter = 0; ornCounter < kAlcoveOrnCount; ++ornCounter) {
+			if (ornIndice == gAlcoveOrnIndices[ornCounter]) {
+				_currMapAlcoveOrnIndices[alcoveCount++] = i;
+				if (ornIndice == 2)
+					_currMapViAltarIndex = i;
+			}
+		}
+
+		for (uint16 ornCounter = 0; ornCounter < kFountainOrnCount; ++ornCounter)
+			if (ornIndice == gFountainOrnIndices[ornCounter])
+				_currMapFountainOrnIndices[fountainCount++] = i;
+
+		_currMapWallOrnInfo[i][kNativeCoordinateSet] = gWallOrnCoordSetIndices[ornIndice];
+	}
+
+	for (uint16 i = 0; i < currMap.floorOrnCount; ++i) {
+		uint16 ornIndice = _currMapFloorOrnIndices[i];
+		uint16 nativeIndice = kFirstFloorOrn + ornIndice * 6;
+		_currMapFloorOrnInfo[i][kNativeBitmapIndex] = nativeIndice;
+		_currMapFloorOrnInfo[i][kNativeCoordinateSet] = gFloorOrnCoordSetIndices[ornIndice];
+	}
+
+	for (uint16 i = 0; i < currMap.doorOrnCount; ++i) {
+		uint16 ornIndice = _currMapDoorOrnIndices[i];
+		uint16 nativeIndice = kFirstDoorOrn + ornIndice;
+		_currMapDoorOrnInfo[i][kNativeBitmapIndex] = nativeIndice;
+		_currMapDoorOrnInfo[i][kNativeCoordinateSet] = gDoorOrnCoordIndices[ornIndice];
+	}
+
+	applyCreatureReplColors(9, 8);
+	applyCreatureReplColors(10, 12);
+
+	for (uint16 creatureType = 0; creatureType < currMap.creatureTypeCount; ++creatureType) {
+		CreatureAspect &aspect = gCreatureAspects[_currMapAllowedCreatureTypes[creatureType]];
+		uint16 replColorOrdinal = aspect.getReplColour9();
+		if (replColorOrdinal)
+			applyCreatureReplColors(9, ordinalToIndex(replColorOrdinal));
+		replColorOrdinal = aspect.getReplColour10();
+		if (replColorOrdinal)
+			applyCreatureReplColors(10, ordinalToIndex(replColorOrdinal));
+	}
+}
+
+void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor) {
+	for (int16 i = 0; i < 6; ++i)
+		gPalDungeonView[i][replacedColor] = gCreatureReplColorSets[replacementColor].RGBColor[i];
+
+	gPalChangesCreature_D2[replacedColor] = gCreatureReplColorSets[replacementColor].D2ReplacementColor;
+	gPalChangesCreature_D3[replacedColor] = gCreatureReplColorSets[replacementColor].D3ReplacementColor;
+}
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 5670a56..4c6b461 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -6,6 +6,12 @@
 
 namespace DM {
 
+extern uint16 gPalSwoosh[16];
+extern uint16 gPalMousePointer[16];
+extern uint16 gPalCredits[16];
+extern uint16 gPalEntrance[16];
+extern uint16 gPalDungeonView[6][16];
+
 struct Frame;
 enum WallSet {
 	kWallSetStone = 0 // @ C0_WALL_SET_STONE
@@ -35,18 +41,6 @@ enum Color {
 	kColorWhite = 15
 };
 
-enum dmPaletteEnum {
-	kPalSwoosh = 0,
-	kPalMousePointer = 1,
-	kPalCredits = 2,
-	kPalEntrance = 3,
-	kPalDungeonView0 = 4,
-	kPalDungeonView1 = 5,
-	kPalDungeonView2 = 6,
-	kPalDungeonView3 = 7,
-	kPalDungeonView4 = 8,
-	kPalDungeonView5 = 9,
-};
 
 struct Viewport {
 	// TODO: should probably add width and height, seems redundant right meow
@@ -57,18 +51,42 @@ extern Viewport gDefultViewPort;
 extern Viewport gDungeonViewport;
 
 
+#define kAlcoveOrnCount 3
+#define kFountainOrnCount 1
+
+#define kFloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT
+#define kWallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT
+#define kStairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT
+#define kDoorSetGraphicsCount 3 // @ C003_DOOR_SET_GRAPHIC_COUNT
+#define kDoorButtonCount 1 // @ C001_DOOR_BUTTON_COUNT
+#define kNativeBitmapIndex 0 // @ C0_NATIVE_BITMAP_INDEX
+#define kNativeCoordinateSet 1 // @ C1_COORDINATE_SET
+#define kCreatureTypeCount 27 // @ C027_CREATURE_TYPE_COUNT
+#define kExplosionAspectCount 4 // @ C004_EXPLOSION_ASPECT_COUNT
+#define kObjAspectCount 85 // @ C085_OBJECT_ASPECT_COUNT
+#define kProjectileAspectCount 14 // @ C014_PROJECTILE_ASPECT_COUNT
+
+
+#define kDoorButton 0 // @ C0_DOOR_BUTTON
+#define kWallOrnInscription 0 // @ C0_WALL_ORNAMENT_INSCRIPTION
+#define kFloorOrnFootprints 15 // @ C15_FLOOR_ORNAMENT_FOOTPRINTS
+#define kDoorOrnDestroyedMask 15 // @ C15_DOOR_ORNAMENT_DESTROYED_MASK
+#define kDoorOrnThivesEyeMask 16 // @ C16_DOOR_ORNAMENT_THIEVES_EYE_MASK
+
+
+
 
 class DisplayMan {
 	DMEngine *_vm;
-	dmPaletteEnum _currPalette;
 	uint16 _screenWidth;
 	uint16 _screenHeight;
 	byte *_vgaBuffer;
 
-	uint16 _packedItemCount;
-	uint32 *_packedItemPos;
-	byte *_packedBitmaps; // TODO: this doesn't not contaion graphics exclusively, will have to be moved
 
+	/// Related to graphics.dat file
+	uint16 grapItemCount; // @ G0632_ui_GraphicCount
+	uint32 *_packedItemPos;
+	byte *_packedBitmaps;
 	byte **_bitmaps;
 
 
@@ -79,25 +97,36 @@ class DisplayMan {
 	byte *_floorBitmap;
 	byte *_ceilingBitmap;
 
+
+	byte *_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile
+
+
 	DisplayMan(const DisplayMan &other); // no implementation on purpose
 	void operator=(const DisplayMan &rhs); // no implementation on purpose
 
 	byte *getCurrentVgaBuffer();
-	// the original functions has two position parameters, but they are always set to zero
+	// the original function has two position parameters, but they are always set to zero
 	void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap
 	void unpackGraphics();
+
 	void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap
 	void drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L
+
+	void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet
+	void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet
+
+	void applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors
+
 public:
 	DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
 	void setUpScreens(uint16 width, uint16 height);
 
-	void loadGraphics();
-	void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet
-	void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet
+	void loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader, F0460_START_InitializeGraphicData
 
-	void loadPalette(dmPaletteEnum palette);
+	void loadCurrentMapGraphics();
+
+	void loadPalette(uint16 *palette);
 
 	/// Gives the width of an IMG0 type item
 	uint16 width(uint16 index);
@@ -120,10 +149,22 @@ public:
 	void clearScreen(Color color);
 	void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
-};
 
-}
 
+	int16 _championPortraitOrdinal = 0; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
+	int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
+	int16 _currMapFountainOrnIndices[kFountainOrnCount]; // @ G0268_ai_CurrentMapFountainOrnamentIndices
+	int16 _currMapWallOrnInfo[16][2]; // @ G0101_aai_CurrentMapWallOrnamentsInf
+	int16 _currMapFloorOrnInfo[16][2]; // @ G0102_aai_CurrentMapFloorOrnamentsInfo
+	int16 _currMapDoorOrnInfo[17][2]; // @ G0103_aai_CurrentMapDoorOrnamentsInfo
+	byte *_currMapAllowedCreatureTypes; // @ G0264_puc_CurrentMapAllowedCreatureTypes
+	byte _currMapWallOrnIndices[16]; // @ G0261_auc_CurrentMapWallOrnamentIndices
+	byte _currMapFloorOrnIndices[16]; // @ G0262_auc_CurrentMapFloorOrnamentIndices
+	byte _currMapDoorOrnIndices[18]; // @ G0263_auc_CurrentMapDoorOrnamentIndices
 
+	int16 _currMapViAltarIndex; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex
+};
+
+}
 
 #endif


Commit: 73a7cba58921e59cdd3049f57b0a3990e7422ea2
    https://github.com/scummvm/scummvm/commit/73a7cba58921e59cdd3049f57b0a3990e7422ea2
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix bug with uninitialized _currMap.index and file loading order

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index ee81849..34efcf3 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -54,9 +54,12 @@ Common::Error DMEngine::run() {
 	_displayMan = new DisplayMan(this);
 	_dungeonMan = new DungeonMan(this);
 
+	_displayMan->setUpScreens(320, 200);
+
 	_dungeonMan->loadDungeonFile();
+	_dungeonMan->setCurrentMapAndPartyMap(0);
+
 
-	_displayMan->setUpScreens(320, 200);
 	_displayMan->loadGraphics();
 
 
@@ -64,7 +67,7 @@ Common::Error DMEngine::run() {
 
 	_displayMan->loadPalette(gPalCredits);
 
-	_dungeonMan->setCurrentMapAndPartyMap(0);
+
 
 	uint16 i = 0; //TODO: testing, please delete me
 	while (true) {
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 46d4f62..824a730 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -352,9 +352,6 @@ void DungeonMan::loadDungeonFile() {
 }
 
 void DungeonMan::setCurrentMap(uint16 mapIndex) {
-	if (_currMap.index == mapIndex)
-		return;
-
 	_currMap.index = mapIndex;
 	_currMap.data = _dunData.mapData[mapIndex];
 	_currMap.map = _maps + mapIndex;


Commit: f21a9197a629fcb225c1c47bb2a9f4cd3018c395
    https://github.com/scummvm/scummvm/commit/f21a9197a629fcb225c1c47bb2a9f4cd3018c395
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix file loading dependancy

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 34efcf3..64793a9 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -56,11 +56,12 @@ Common::Error DMEngine::run() {
 
 	_displayMan->setUpScreens(320, 200);
 
+	_displayMan->loadGraphics();
+
 	_dungeonMan->loadDungeonFile();
 	_dungeonMan->setCurrentMapAndPartyMap(0);
 
 
-	_displayMan->loadGraphics();
 
 
 	_displayMan->loadCurrentMapGraphics();
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 824a730..9b9791a 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -421,7 +421,7 @@ int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) {
 	if (mapX < 0 || mapX >= _currMap.width || mapY < 0 || mapY >= _currMap.height || !Square(_currMap.data[mapX][mapY]).get(kThingListPresent))
 		return -1;
 
-	int16 y;
+	int16 y = 0;
 	uint16 index = _currMap.colCumulativeSquareFirstThingCount[mapX];
 	byte* square = _currMap.data[mapX];
 	while (y++ != mapY)
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index df83953..5f1dcd3 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -402,11 +402,11 @@ struct CurrMapData {
 	uint8 currPartyMapIndex; // @ G0309_i_PartyMapIndex
 
 	uint8 index; // @ G0272_i_CurrentMapIndex
-	byte **data; // @ G0271_ppuc_CurrentMapData
-	Map *map; // @ G0269_ps_CurrentMap
+	byte **data = NULL; // @ G0271_ppuc_CurrentMapData
+	Map *map = NULL; // @ G0269_ps_CurrentMap
 	uint16 width; // @ G0273_i_CurrentMapWidth
 	uint16 height; // @ G0274_i_CurrentMapHeight
-	uint16 *colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount
+	uint16 *colCumulativeSquareFirstThingCount = NULL; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount
 }; // @ AGGREGATE
 
 struct Messages {
@@ -454,15 +454,15 @@ public:
 	} // @ F0153_DUNGEON_GetRelativeSquareType
 	void setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect
 
-	uint32 _rawDunFileDataSize;	 // @ probably NONE
-	byte *_rawDunFileData; // @ ???
+	uint32 _rawDunFileDataSize = 0;	 // @ probably NONE
+	byte *_rawDunFileData = NULL; // @ ???
 	DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader
 
 	DungeonData _dunData; // @ NONE
 	CurrMapData _currMap; // @ NONE
-	Map *_maps; // @ G0277_ps_DungeonMaps
+	Map *_maps = NULL; // @ G0277_ps_DungeonMaps
 	// does not have to be freed
-	byte *_rawMapData; // @ G0276_puc_DungeonRawMapData
+	byte *_rawMapData = NULL; // @ G0276_puc_DungeonRawMapData
 	Messages _messages; // @ NONE;
 
 	int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 4c6b461..576d9e3 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -77,28 +77,28 @@ extern Viewport gDungeonViewport;
 
 
 class DisplayMan {
-	DMEngine *_vm;
+	DMEngine *_vm = NULL;
 	uint16 _screenWidth;
-	uint16 _screenHeight;
-	byte *_vgaBuffer;
+	uint16 _screenHeight = 0;
+	byte *_vgaBuffer = NULL;
 
 
 	/// Related to graphics.dat file
-	uint16 grapItemCount; // @ G0632_ui_GraphicCount
-	uint32 *_packedItemPos;
-	byte *_packedBitmaps;
-	byte **_bitmaps;
+	uint16 grapItemCount = 0; // @ G0632_ui_GraphicCount
+	uint32 *_packedItemPos = NULL;
+	byte *_packedBitmaps = NULL;
+	byte **_bitmaps = NULL;
 
 
 	// the last two pointers are owned by this array
 	byte *_wallSetBitMaps[15] = {NULL};	// @G[0696..0710]_puc_Bitmap_WallSet_...
 
 	// pointers are not owned by these fields
-	byte *_floorBitmap;
-	byte *_ceilingBitmap;
+	byte *_floorBitmap = NULL;
+	byte *_ceilingBitmap = NULL;
 
 
-	byte *_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile
+	byte *_palChangesProjectile[4] = {NULL}; // @G0075_apuc_PaletteChanges_Projectile
 
 
 	DisplayMan(const DisplayMan &other); // no implementation on purpose
@@ -152,17 +152,17 @@ public:
 
 
 	int16 _championPortraitOrdinal = 0; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
-	int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
-	int16 _currMapFountainOrnIndices[kFountainOrnCount]; // @ G0268_ai_CurrentMapFountainOrnamentIndices
-	int16 _currMapWallOrnInfo[16][2]; // @ G0101_aai_CurrentMapWallOrnamentsInf
-	int16 _currMapFloorOrnInfo[16][2]; // @ G0102_aai_CurrentMapFloorOrnamentsInfo
-	int16 _currMapDoorOrnInfo[17][2]; // @ G0103_aai_CurrentMapDoorOrnamentsInfo
-	byte *_currMapAllowedCreatureTypes; // @ G0264_puc_CurrentMapAllowedCreatureTypes
-	byte _currMapWallOrnIndices[16]; // @ G0261_auc_CurrentMapWallOrnamentIndices
-	byte _currMapFloorOrnIndices[16]; // @ G0262_auc_CurrentMapFloorOrnamentIndices
-	byte _currMapDoorOrnIndices[18]; // @ G0263_auc_CurrentMapDoorOrnamentIndices
-
-	int16 _currMapViAltarIndex; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex
+	int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount] = {0}; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
+	int16 _currMapFountainOrnIndices[kFountainOrnCount] = {0}; // @ G0268_ai_CurrentMapFountainOrnamentIndices
+	int16 _currMapWallOrnInfo[16][2] = {0}; // @ G0101_aai_CurrentMapWallOrnamentsInf
+	int16 _currMapFloorOrnInfo[16][2] = {0}; // @ G0102_aai_CurrentMapFloorOrnamentsInfo
+	int16 _currMapDoorOrnInfo[17][2] = {0}; // @ G0103_aai_CurrentMapDoorOrnamentsInfo
+	byte *_currMapAllowedCreatureTypes = NULL; // @ G0264_puc_CurrentMapAllowedCreatureTypes
+	byte _currMapWallOrnIndices[16] = {0}; // @ G0261_auc_CurrentMapWallOrnamentIndices
+	byte _currMapFloorOrnIndices[16] = {0}; // @ G0262_auc_CurrentMapFloorOrnamentIndices
+	byte _currMapDoorOrnIndices[18] = {0}; // @ G0263_auc_CurrentMapDoorOrnamentIndices
+
+	int16 _currMapViAltarIndex = 0; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex
 };
 
 }


Commit: 2e9483cf2e5937f03bc89f9366d3b84d1199237b
    https://github.com/scummvm/scummvm/commit/2e9483cf2e5937f03bc89f9366d3b84d1199237b
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix dungeon.dat file loading

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 9b9791a..c933744 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -5,6 +5,7 @@
 
 
 
+
 namespace DM {
 // TODO: refactor direction into a class
 int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */};
@@ -252,6 +253,8 @@ void DungeonMan::loadDungeonFile() {
 	_dunData.columCount = columCount;
 	// TODO: ??? is this - end
 
+
+	uint32 actualSquareFirstThingCount = _fileHeader.squareFirstThingCount;
 	if (_messages.newGame) // TODO: what purpose does this serve?
 		_fileHeader.squareFirstThingCount += 300;
 
@@ -267,11 +270,11 @@ void DungeonMan::loadDungeonFile() {
 	if (_dunData.squareFirstThings)
 		delete[] _dunData.squareFirstThings;
 	_dunData.squareFirstThings = new Thing[_fileHeader.squareFirstThingCount];
-	for (uint16 i = 0; i < _fileHeader.squareFirstThingCount; ++i)
+	for (uint16 i = 0; i < actualSquareFirstThingCount; ++i)
 		_dunData.squareFirstThings[i].set(dunDataStream.readUint16BE());
 	if (_messages.newGame)
 		for (uint16 i = 0; i < 300; ++i)
-			_dunData.squareFirstThings[i] = Thing::thingNone;
+			_dunData.squareFirstThings[actualSquareFirstThingCount + i] = Thing::thingNone;
 
 	// TODO: ??? is this - end
 
@@ -291,19 +294,18 @@ void DungeonMan::loadDungeonFile() {
 	for (uint16 thingType = kDoorThingType; thingType < kThingTypeTotal; ++thingType) {
 		uint16 thingCount = _fileHeader.thingCounts[thingType];
 		if (_messages.newGame) {
-			// _fileHeader.thingCounts[thingType] = 1024; // TODO: what this?? check back later
+			_fileHeader.thingCounts[thingType] = MIN((thingType == kExplosionThingType) ? 768 : 1024, thingCount + gAdditionalThingCounts[thingType]);
 		}
 		uint16 thingStoreWordCount = gThingDataWordCount[thingType];
-		if (!thingStoreWordCount || !thingCount)
-			continue;
+
 
 		if (_dunData.thingsData[thingType]) {
 			delete[] _dunData.thingsData[thingType][0];
 			delete[] _dunData.thingsData[thingType];
 		}
-		_dunData.thingsData[thingType] = new uint16*[thingCount];
-		_dunData.thingsData[thingType][0] = new uint16[thingCount * thingStoreWordCount];
-		for (uint16 i = 0; i < thingCount; ++i)
+		_dunData.thingsData[thingType] = new uint16*[_fileHeader.thingCounts[thingType]];
+		_dunData.thingsData[thingType][0] = new uint16[_fileHeader.thingCounts[thingType] * thingStoreWordCount];
+		for (uint16 i = 0; i < _fileHeader.thingCounts[thingType]; ++i)
 			_dunData.thingsData[thingType][i] = _dunData.thingsData[thingType][0] + i * thingStoreWordCount;
 
 		if (thingType == kGroupThingType) {
@@ -327,23 +329,34 @@ void DungeonMan::loadDungeonFile() {
 				for (uint16 j = 0; j < thingStoreWordCount; ++j)
 					_dunData.thingsData[thingType][i][j] = dunDataStream.readUint16BE();
 		}
+
+		if (_messages.newGame) {
+			if ((thingType == kGroupThingType) || thingType >= kProjectileThingType)
+				_dunData.eventMaximumCount += _fileHeader.thingCounts[thingType];
+			for (uint16 i = 0; i < gAdditionalThingCounts[thingType]; ++i) {
+				_dunData.thingsData[thingType][thingCount + i][0] = Thing::thingNone.toUint16();
+			}
+		}
+
 	}
 
 
 	// load map data
-	_rawMapData = _rawDunFileData + dunDataStream.pos();
+	if (!_messages.restartGameRequest)
+		_rawMapData = _rawDunFileData + dunDataStream.pos();
 
-	if (_dunData.mapData) delete[] _dunData.mapData;
 
 	if (!_messages.restartGameRequest) {
 		uint8 mapCount = _fileHeader.mapCount;
+		if (_dunData.mapData)
+			delete[] _dunData.mapData;
 		_dunData.mapData = new byte**[_dunData.columCount + mapCount];
 		byte **colFirstSquares = (byte**)_dunData.mapData + mapCount;
 		for (uint8 i = 0; i < mapCount; ++i) {
 			_dunData.mapData[i] = colFirstSquares;
 			byte *square = _rawMapData + _maps[i].rawDunDataOffset;
 			*colFirstSquares++ = square;
-			for (uint16 w = 0; w <= _maps[i].width; ++w) {
+			for (uint16 w = 1; w <= _maps[i].width; ++w) {
 				square += _maps[w].height + 1;
 				*colFirstSquares++ = square;
 			}


Commit: 909ec36edf6206efac5d2b4bea32a019520087b7
    https://github.com/scummvm/scummvm/commit/909ec36edf6206efac5d2b4bea32a019520087b7
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix loading map data in loadDungeonFile(..)

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index c933744..e6d94ec 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -357,7 +357,7 @@ void DungeonMan::loadDungeonFile() {
 			byte *square = _rawMapData + _maps[i].rawDunDataOffset;
 			*colFirstSquares++ = square;
 			for (uint16 w = 1; w <= _maps[i].width; ++w) {
-				square += _maps[w].height + 1;
+				square += _maps[i].height + 1;
 				*colFirstSquares++ = square;
 			}
 		}


Commit: 7ddd96bc60e9a5cbe33a5a246f5a8709d4948181
    https://github.com/scummvm/scummvm/commit/7ddd96bc60e9a5cbe33a5a246f5a8709d4948181
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix destructor and allocation issues in DungeonMan and DisplayMan

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/gfx.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index e6d94ec..2d700f3 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -84,7 +84,7 @@ void DungeonMan::decompressDungeonFile() {
 	f.open("Dungeon.dat");
 	if (f.readUint16BE() == 0x8104) {
 		_rawDunFileDataSize = f.readUint32BE();
-		if (_rawDunFileData) delete[] _rawDunFileData;
+		delete[] _rawDunFileData;
 		_rawDunFileData = new byte[_rawDunFileDataSize];
 		f.readUint16BE();
 		byte common[4];
@@ -209,8 +209,7 @@ void DungeonMan::loadDungeonFile() {
 	}
 
 	// load map data
-	if (_maps) delete[] _maps;
-
+	delete[] _maps;
 	_maps = new Map[_fileHeader.mapCount];
 	for (uint16 i = 0; i < _fileHeader.mapCount; ++i) {
 		_maps[i].rawDunDataOffset = dunDataStream.readUint16BE();
@@ -242,8 +241,7 @@ void DungeonMan::loadDungeonFile() {
 	}
 
 	// TODO: ??? is this - begin
-	if (_dunData.mapsFirstColumnIndex) delete[] _dunData.mapsFirstColumnIndex;
-
+	delete[] _dunData.mapsFirstColumnIndex;
 	_dunData.mapsFirstColumnIndex = new uint16[_fileHeader.mapCount];
 	uint16 columCount = 0;
 	for (uint16 i = 0; i < _fileHeader.mapCount; ++i) {
@@ -259,16 +257,14 @@ void DungeonMan::loadDungeonFile() {
 		_fileHeader.squareFirstThingCount += 300;
 
 	// TODO: ??? is this - begin
-	if (_dunData.columnsCumulativeSquareThingCount)
-		delete[] _dunData.columnsCumulativeSquareThingCount;
+	delete[] _dunData.columnsCumulativeSquareThingCount;
 	_dunData.columnsCumulativeSquareThingCount = new uint16[columCount];
 	for (uint16 i = 0; i < columCount; ++i)
 		_dunData.columnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE();
 	// TODO: ??? is this - end
 
 	// TODO: ??? is this - begin
-	if (_dunData.squareFirstThings)
-		delete[] _dunData.squareFirstThings;
+	delete[] _dunData.squareFirstThings;
 	_dunData.squareFirstThings = new Thing[_fileHeader.squareFirstThingCount];
 	for (uint16 i = 0; i < actualSquareFirstThingCount; ++i)
 		_dunData.squareFirstThings[i].set(dunDataStream.readUint16BE());
@@ -279,8 +275,7 @@ void DungeonMan::loadDungeonFile() {
 	// TODO: ??? is this - end
 
 	// load text data
-	if (_dunData.textData)
-		delete[] _dunData.textData;
+	delete[] _dunData.textData;
 	_dunData.textData = new uint16[_fileHeader.textDataWordCount];
 	for (uint16 i = 0; i < _fileHeader.textDataWordCount; ++i)
 		_dunData.textData[i] = dunDataStream.readUint16BE();
@@ -348,8 +343,7 @@ void DungeonMan::loadDungeonFile() {
 
 	if (!_messages.restartGameRequest) {
 		uint8 mapCount = _fileHeader.mapCount;
-		if (_dunData.mapData)
-			delete[] _dunData.mapData;
+		delete[] _dunData.mapData;
 		_dunData.mapData = new byte**[_dunData.columCount + mapCount];
 		byte **colFirstSquares = (byte**)_dunData.mapData + mapCount;
 		for (uint8 i = 0; i < mapCount; ++i) {
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index ae5bcd9..3a9d1f0 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -21,6 +21,25 @@ namespace DM {
 #define kFirstFloorOrn 247 // @ C247_GRAPHIC_FIRST_FLOOR_ORNAMENT
 #define kFirstDoorOrn 303 // @ C303_GRAPHIC_FIRST_DOOR_ORNAMENT
 
+enum WallSetIndices {
+	kDoorFrameFront = 0, // @  G0709_puc_Bitmap_WallSet_DoorFrameFront
+	kDoorFrameLeft_D1C = 1, // @  G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C
+	kFameLeft_D2C = 2, // @  G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C
+	kDoorFrameLeft_D3C = 3, // @  G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C
+	kDoorFrameLeft_D3L = 4, // @  G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L
+	kDoorFrameTop_D1LCR = 5, // @  G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR
+	kDoorFrameTop_D2LCR = 6, // @  G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR
+	kWall_D0R = 7, // @  G0702_puc_Bitmap_WallSet_Wall_D0R
+	kWall_D0L = 8, // @  G0701_puc_Bitmap_WallSet_Wall_D0L
+	kWall_D1LCR = 9, // @  G0700_puc_Bitmap_WallSet_Wall_D1LCR
+	kWall_D2LCR = 10, // @  G0699_puc_Bitmap_WallSet_Wall_D2LCR
+	kWall_D3LCR = 11, // @  G0698_puc_Bitmap_WallSet_Wall_D3LCR
+	kWall_D3L2 = 12, // @  G0697_puc_Bitmap_WallSet_Wall_D3L2
+
+	kWall_D3R2 = 13, // @  G0696_puc_Bitmap_WallSet_Wall_D3R2
+	kDoorFrameRight_D1C = 14// @  G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C
+};
+
 
 byte gDoorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordinateSetIndices
 	0,   /* Door Ornament #00 Square Grid */
@@ -496,15 +515,18 @@ DisplayMan::~DisplayMan() {
 	delete[] _packedItemPos;
 	delete[] _packedBitmaps;
 	delete[] _vgaBuffer;
-	delete[] _bitmaps[0];
-	delete[] _bitmaps;
-	delete[] _wallSetBitMaps[13]; // copy of another bitmap, but flipped
-	delete[] _wallSetBitMaps[14]; // copy of another bitmap, but flipped
+	if (_bitmaps) {
+		delete[] _bitmaps[0];
+		delete[] _bitmaps;
+	}
+	delete[] _wallSetBitMaps[kWall_D3R2]; // copy of another bitmap, but flipped
+	delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; // copy of another bitmap, but flipped
 }
 
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
 	_screenWidth = width;
 	_screenHeight = height;
+	delete[] _vgaBuffer;
 	_vgaBuffer = new byte[_screenWidth * _screenHeight];
 	clearScreen(kColorBlack);
 }
@@ -514,11 +536,13 @@ void DisplayMan::loadGraphics() {
 	f.open("graphics.dat");
 
 	grapItemCount = f.readUint16BE();
+	delete[] _packedItemPos;
 	_packedItemPos = new uint32[grapItemCount + 1];
 	_packedItemPos[0] = 0;
 	for (uint16 i = 1; i < grapItemCount + 1; ++i)
 		_packedItemPos[i] = f.readUint16BE() + _packedItemPos[i - 1];
 
+	delete[] _packedBitmaps;
 	_packedBitmaps = new uint8[_packedItemPos[grapItemCount]];
 
 	f.seek(2 + grapItemCount * 4);
@@ -553,6 +577,10 @@ void DisplayMan::unpackGraphics() {
 	for (uint16 i = 22; i <= 532; ++i)
 		unpackedBitmapsSize += width(i) * height(i);
 	// graphics items go from 0-20 and 22-532 inclusive, _unpackedItemPos 21 and 22 are there for indexing convenience
+	if (_bitmaps) {
+		delete[] _bitmaps[0];
+		delete[] _bitmaps;
+	}
 	_bitmaps = new byte*[533];
 	_bitmaps[0] = new byte[unpackedBitmapsSize];
 	loadIntoBitmap(0, _bitmaps[0]);
@@ -702,25 +730,6 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
 }
 
 
-enum WallSetIndices {
-	kDoorFrameFront = 0, // @  G0709_puc_Bitmap_WallSet_DoorFrameFront
-	kDoorFrameLeft_D1C = 1, // @  G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C
-	kFameLeft_D2C = 2, // @  G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C
-	kDoorFrameLeft_D3C = 3, // @  G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C
-	kDoorFrameLeft_D3L = 4, // @  G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L
-	kDoorFrameTop_D1LCR = 5, // @  G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR
-	kDoorFrameTop_D2LCR = 6, // @  G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR
-	kWall_D0R = 7, // @  G0702_puc_Bitmap_WallSet_Wall_D0R
-	kWall_D0L = 8, // @  G0701_puc_Bitmap_WallSet_Wall_D0L
-	kWall_D1LCR = 9, // @  G0700_puc_Bitmap_WallSet_Wall_D1LCR
-	kWall_D2LCR = 10, // @  G0699_puc_Bitmap_WallSet_Wall_D2LCR
-	kWall_D3LCR = 11, // @  G0698_puc_Bitmap_WallSet_Wall_D3LCR
-	kWall_D3L2 = 12, // @  G0697_puc_Bitmap_WallSet_Wall_D3L2
-
-	kWall_D3R2 = 13, // @  G0696_puc_Bitmap_WallSet_Wall_D3R2
-	kDoorFrameRight_D1C = 14// @  G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C
-};
-
 void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	loadPalette(gPalDungeonView[0]);
 	// TODO: this is a global variable, set from here
@@ -783,16 +792,14 @@ void DisplayMan::loadWallSet(WallSet set) {
 
 	uint16 leftDoorIndice = firstIndice + kDoorFrameLeft_D1C;
 	uint16 w = width(leftDoorIndice), h = height(leftDoorIndice);
-	if (_wallSetBitMaps[kDoorFrameRight_D1C])
-		delete[] _wallSetBitMaps[kDoorFrameRight_D1C];
+	delete[] _wallSetBitMaps[kDoorFrameRight_D1C];
 	_wallSetBitMaps[kDoorFrameRight_D1C] = new byte[w * h];
 	blitToBitmap(_wallSetBitMaps[kDoorFrameLeft_D1C], w, h, _wallSetBitMaps[kDoorFrameRight_D1C], w);
 	flipBitmapHorizontal(_wallSetBitMaps[kDoorFrameRight_D1C], w, h);
 
 	uint16 leftWallIndice = firstIndice + kWall_D3L2;
 	w = width(leftWallIndice), h = height(leftWallIndice);
-	if (_wallSetBitMaps[kWall_D3R2])
-		delete[] _wallSetBitMaps[kWall_D3R2];
+	delete[] _wallSetBitMaps[kWall_D3R2];
 	_wallSetBitMaps[kWall_D3R2] = new byte[w * h];
 	blitToBitmap(_wallSetBitMaps[kWall_D3L2], w, h, _wallSetBitMaps[kWall_D3R2], w);
 	flipBitmapHorizontal(_wallSetBitMaps[kWall_D3R2], w, h);


Commit: d49c081785bc4eab83246a9c9697604692f47b1d
    https://github.com/scummvm/scummvm/commit/d49c081785bc4eab83246a9c9697604692f47b1d
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix loadDungeonFile(..) zero sized array allocation

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 2d700f3..d467f59 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -293,6 +293,8 @@ void DungeonMan::loadDungeonFile() {
 		}
 		uint16 thingStoreWordCount = gThingDataWordCount[thingType];
 
+		if (thingStoreWordCount == 0)
+			continue;
 
 		if (_dunData.thingsData[thingType]) {
 			delete[] _dunData.thingsData[thingType][0];


Commit: e3136f4247280272e6004e0d4b012e1864489f77
    https://github.com/scummvm/scummvm/commit/e3136f4247280272e6004e0d4b012e1864489f77
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add viewsquare enum

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 3a9d1f0..6205bc9 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -21,6 +21,30 @@ namespace DM {
 #define kFirstFloorOrn 247 // @ C247_GRAPHIC_FIRST_FLOOR_ORNAMENT
 #define kFirstDoorOrn 303 // @ C303_GRAPHIC_FIRST_DOOR_ORNAMENT
 
+
+enum ViewSquare {
+	kViewSquare_D4C = -3, // @ CM3_VIEW_SQUARE_D4C
+	kViewSquare_D4L = -2, // @ CM2_VIEW_SQUARE_D4L
+	kViewSquare_D4R = -1, // @ CM1_VIEW_SQUARE_D4R
+	kViewSquare_D3C = 0, // @ C00_VIEW_SQUARE_D3C
+	kViewSquare_D3L = 1, // @ C01_VIEW_SQUARE_D3L
+	kViewSquare_D3R = 2, // @ C02_VIEW_SQUARE_D3R
+	kViewSquare_D2C = 3, // @ C03_VIEW_SQUARE_D2C
+	kViewSquare_D2L = 4, // @ C04_VIEW_SQUARE_D2L
+	kViewSquare_D2R = 5, // @ C05_VIEW_SQUARE_D2R
+	kViewSquare_D1C = 6, // @ C06_VIEW_SQUARE_D1C
+	kViewSquare_D1L = 7, // @ C07_VIEW_SQUARE_D1L
+	kViewSquare_D1R = 8, // @ C08_VIEW_SQUARE_D1R
+	kViewSquare_D0C = 9, // @ C09_VIEW_SQUARE_D0C
+	kViewSquare_D0L = 10, // @ C10_VIEW_SQUARE_D0L
+	kViewSquare_D0R = 11, // @ C11_VIEW_SQUARE_D0R
+	kViewSquare_D3C_Explosion = 3, // @ C03_VIEW_SQUARE_D3C_EXPLOSION
+	kViewSquare_D3L_Explosion = 4, // @ C04_VIEW_SQUARE_D3L_EXPLOSION
+	kViewSquare_D1C_Explosion = 9, // @ C09_VIEW_SQUARE_D1C_EXPLOSION
+	kViewSquare_D0C_Explosion = 12 // @ C12_VIEW_SQUARE_D0C_EXPLOSION
+};
+
+
 enum WallSetIndices {
 	kDoorFrameFront = 0, // @  G0709_puc_Bitmap_WallSet_DoorFrameFront
 	kDoorFrameLeft_D1C = 1, // @  G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C
@@ -484,9 +508,9 @@ struct Frame {
 		srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {}
 };
 
-Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0);
-Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0);
-Frame gWallFrameD3L2(0, 15, 25, 73, 8, 49, 0, 0); // @ FRAME G0711_s_Graphic558_Frame_Wall_D3L2
+Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling
+Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor
+Frame gWallFrameD3L2(0, 15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2
 Frame gWallFrameD3R2(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2
 
 extern Viewport gDefultViewPort = {0, 0};
@@ -761,6 +785,7 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	// D3L
 	int16 tmpPosX = posX, tmpPosY = posY;
 	_vm->_dungeonMan->getRelSquareType(dir, 3, -1, tmpPosX, tmpPosY);
+	drawSquareD3L(dir, posX, posY);
 
 
 


Commit: 134b482e60944597d4c8c2290ca1b17e549718d9
    https://github.com/scummvm/scummvm/commit/134b482e60944597d4c8c2290ca1b17e549718d9
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add flipped wall bitmaps

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 64793a9..45863d1 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -76,7 +76,7 @@ Common::Error DMEngine::run() {
 		_displayMan->drawDungeon(kDirNorth, i++, 0);
 		_displayMan->updateScreen();
 		_system->delayMillis(1000); //TODO: testing, please set me to 10
-		if (i == 3) break;
+		if (i == 10) break;
 	}
 
 
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 5f1dcd3..931d635 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -466,8 +466,6 @@ public:
 	Messages _messages; // @ NONE;
 
 	int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex
-
-
 };
 
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 6205bc9..3e170d1 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -10,6 +10,18 @@
 
 namespace DM {
 
+// The frames in the orignal sources contain inclusive boundaries and byte widths, not pixel widths
+struct Frame {
+	uint16 destFromX, destToX, destFromY, destToY;
+	uint16 srcWidth, srcHeight;
+	uint16 srcX, srcY;
+
+	Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
+		  uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) :
+		destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1),
+		srcWidth(srcWidth), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {}
+};
+
 
 #define kFirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT
 #define kFirstFloorSet 75 // @ C075_GRAPHIC_FIRST_FLOOR_SET
@@ -44,6 +56,26 @@ enum ViewSquare {
 	kViewSquare_D0C_Explosion = 12 // @ C12_VIEW_SQUARE_D0C_EXPLOSION
 };
 
+Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling
+Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor
+
+Frame gFrameWall_D3L2 = {0,  15, 25, 73, 8 * 2, 49, 0, 0}; // @ G0711_s_Graphic558_Frame_Wall_D3L2
+Frame gFrameWall_D3R2 = {208, 223, 25, 73, 8 * 2, 49, 0, 0}; // @ G0712_s_Graphic558_Frame_Wall_D3R2
+Frame gFrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls
+	/* { X1, X2, Y1, Y2, pixelWidth, Height, X, Y } */
+	{74, 149, 25,  75,  64 * 2,  51,  18, 0},   /* D3C */
+	{0,  83, 25,  75,  64 * 2,  51,  32, 0},   /* D3L */
+	{139, 223, 25,  75,  64 * 2,  51,   0, 0},   /* D3R */
+	{60, 163, 20,  90,  72 * 2,  71,  16, 0},   /* D2C */
+	{0,  74, 20,  90,  72 * 2,  71,  61, 0},   /* D2L */
+	{149, 223, 20,  90,  72 * 2,  71,   0, 0},   /* D2R */
+	{32, 191,  9, 119, 128 * 2, 111,  48, 0},   /* D1C */
+	{0,  63,  9, 119, 128 * 2, 111, 192, 0},   /* D1L */
+	{160, 223,  9, 119, 128 * 2, 111,   0, 0},   /* D1R */
+	{0, 223,  0, 135,   0 * 2,   0,   0, 0},   /* D0C */
+	{0,  31,  0, 135,  16 * 2, 136,   0, 0},   /* D0L */
+	{192, 223,  0, 135,  16 * 2, 136,   0, 0}}; /* D0R */
+
 
 enum WallSetIndices {
 	kDoorFrameFront = 0, // @  G0709_puc_Bitmap_WallSet_DoorFrameFront
@@ -496,22 +528,7 @@ enum GraphicIndice {
 	kDoorMaskDestroyedIndice = 301 // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
 };
 
-// The frames in the orignal sources contain inclusive boundaries and byte widths, not pixel widths
-struct Frame {
-	uint16 destFromX, destToX, destFromY, destToY;
-	uint16 srcWidth, srcHeight;
-	uint16 srcX, srcY;
-
-	Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
-		  uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) :
-		destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1),
-		srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {}
-};
 
-Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling
-Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor
-Frame gWallFrameD3L2(0, 15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2
-Frame gWallFrameD3R2(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2
 
 extern Viewport gDefultViewPort = {0, 0};
 extern Viewport gDungeonViewport = {0, 64};	// TODO: I guessed the numbers
@@ -545,6 +562,8 @@ DisplayMan::~DisplayMan() {
 	}
 	delete[] _wallSetBitMaps[kWall_D3R2]; // copy of another bitmap, but flipped
 	delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; // copy of another bitmap, but flipped
+	for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i)
+		delete[] _wallSetBitMapsFlipped[i];
 }
 
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
@@ -750,7 +769,13 @@ void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) {
 }
 
 void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
-
+	uint16 squareAspect[5];
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	switch (squareAspect[0]) {
+	case kWallElemType:
+		drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3L]);
+		break;
+	}
 }
 
 
@@ -769,6 +794,9 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 		flipBitmapHorizontal(tmpBitmap, w, h);
 		drawWallSetBitmap(tmpBitmap, gFloorFrame);
 		drawWallSetBitmap(_ceilingBitmap, gCeilingFrame);
+
+		for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i)
+			_wallSetBitMaps[i] = _wallSetBitMapsFlipped[i];
 	} else {
 		uint16 w = gCeilingFrame.srcWidth, h = gCeilingFrame.srcHeight;
 		blitToBitmap(_ceilingBitmap, w, h, tmpBitmap, w);
@@ -778,16 +806,18 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	}
 
 	if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallElemType)
-		drawWallSetBitmap(_wallSetBitMaps[kWall_D3L2], gWallFrameD3L2);
+		drawWallSetBitmap(_wallSetBitMaps[kWall_D3L2], gFrameWall_D3L2);
 	if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallElemType)
-		drawWallSetBitmap(_wallSetBitMaps[kWall_D3R2], gWallFrameD3R2);
+		drawWallSetBitmap(_wallSetBitMaps[kWall_D3R2], gFrameWall_D3R2);
 
 	// D3L
 	int16 tmpPosX = posX, tmpPosY = posY;
 	_vm->_dungeonMan->getRelSquareType(dir, 3, -1, tmpPosX, tmpPosY);
-	drawSquareD3L(dir, posX, posY);
+	//drawSquareD3L(dir, posX, posY);
 
 
+	for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i)
+		_wallSetBitMaps[i] = _wallSetBitMapsNative[i];
 
 	delete[] tmpBitmap;
 }
@@ -814,7 +844,6 @@ void DisplayMan::loadWallSet(WallSet set) {
 		_wallSetBitMaps[i] = _bitmaps[i + firstIndice];
 	}
 
-
 	uint16 leftDoorIndice = firstIndice + kDoorFrameLeft_D1C;
 	uint16 w = width(leftDoorIndice), h = height(leftDoorIndice);
 	delete[] _wallSetBitMaps[kDoorFrameRight_D1C];
@@ -828,6 +857,16 @@ void DisplayMan::loadWallSet(WallSet set) {
 	_wallSetBitMaps[kWall_D3R2] = new byte[w * h];
 	blitToBitmap(_wallSetBitMaps[kWall_D3L2], w, h, _wallSetBitMaps[kWall_D3R2], w);
 	flipBitmapHorizontal(_wallSetBitMaps[kWall_D3R2], w, h);
+	for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i)
+		_wallSetBitMapsNative[i] = _wallSetBitMaps[i];
+
+	for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i) {
+		uint16 w = width(firstIndice + i), h = height(firstIndice + i);
+		delete[] _wallSetBitMapsFlipped[i];
+		_wallSetBitMapsFlipped[i] = new byte[w * h];
+		blitToBitmap(_wallSetBitMaps[i], w, h, _wallSetBitMapsFlipped[i], w);
+		flipBitmapHorizontal(_wallSetBitMapsFlipped[i], w, h);
+	}
 }
 
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 576d9e3..ee2b373 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -93,6 +93,10 @@ class DisplayMan {
 	// the last two pointers are owned by this array
 	byte *_wallSetBitMaps[15] = {NULL};	// @G[0696..0710]_puc_Bitmap_WallSet_...
 
+	// only [7-11] is used, indexing convenience
+	byte *_wallSetBitMapsNative[12] = {NULL}; // @G[0095..0099]_puc_Bitmap_Wall...
+	byte *_wallSetBitMapsFlipped[12] = {NULL}; // @G[0090..0094]_puc_Bitmap_Wall...
+
 	// pointers are not owned by these fields
 	byte *_floorBitmap = NULL;
 	byte *_ceilingBitmap = NULL;


Commit: d9bb44eeb97370f5ff6d25f9b917073072db6552
    https://github.com/scummvm/scummvm/commit/d9bb44eeb97370f5ff6d25f9b917073072db6552
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add the partial drawing of dungeonwalls

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 45863d1..9295ea6 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -68,15 +68,13 @@ Common::Error DMEngine::run() {
 
 	_displayMan->loadPalette(gPalCredits);
 
-
-
 	uint16 i = 0; //TODO: testing, please delete me
 	while (true) {
 		_displayMan->clearScreen(kColorBlack);
-		_displayMan->drawDungeon(kDirNorth, i++, 0);
+		_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY + i);
 		_displayMan->updateScreen();
-		_system->delayMillis(1000); //TODO: testing, please set me to 10
-		if (i == 10) break;
+		_system->delayMillis(2000); //TODO: testing, please set me to 10
+		if (++i == 100) break;
 	}
 
 
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index d467f59..e2ad66a 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -472,7 +472,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
 	memset(aspectArray, 0, 5 * sizeof(int16));
 	aspectArray[kElemAspect] = square.getType();
 
-	_vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75
+	_vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75, possible fix
 	switch (square.getType()) {
 	case kWallElemType:
 		switch (dir) {
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 3e170d1..8bf6178 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -19,7 +19,7 @@ struct Frame {
 	Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
 		  uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) :
 		destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1),
-		srcWidth(srcWidth), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {}
+		srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {}
 };
 
 
@@ -59,28 +59,28 @@ enum ViewSquare {
 Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling
 Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor
 
-Frame gFrameWall_D3L2 = {0,  15, 25, 73, 8 * 2, 49, 0, 0}; // @ G0711_s_Graphic558_Frame_Wall_D3L2
-Frame gFrameWall_D3R2 = {208, 223, 25, 73, 8 * 2, 49, 0, 0}; // @ G0712_s_Graphic558_Frame_Wall_D3R2
+Frame gFrameWall_D3L2 = {0,  15, 25, 73, 8, 49, 0, 0}; // @ G0711_s_Graphic558_Frame_Wall_D3L2
+Frame gFrameWall_D3R2 = {208, 223, 25, 73, 8, 49, 0, 0}; // @ G0712_s_Graphic558_Frame_Wall_D3R2
 Frame gFrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls
 	/* { X1, X2, Y1, Y2, pixelWidth, Height, X, Y } */
-	{74, 149, 25,  75,  64 * 2,  51,  18, 0},   /* D3C */
-	{0,  83, 25,  75,  64 * 2,  51,  32, 0},   /* D3L */
-	{139, 223, 25,  75,  64 * 2,  51,   0, 0},   /* D3R */
-	{60, 163, 20,  90,  72 * 2,  71,  16, 0},   /* D2C */
-	{0,  74, 20,  90,  72 * 2,  71,  61, 0},   /* D2L */
-	{149, 223, 20,  90,  72 * 2,  71,   0, 0},   /* D2R */
-	{32, 191,  9, 119, 128 * 2, 111,  48, 0},   /* D1C */
-	{0,  63,  9, 119, 128 * 2, 111, 192, 0},   /* D1L */
-	{160, 223,  9, 119, 128 * 2, 111,   0, 0},   /* D1R */
-	{0, 223,  0, 135,   0 * 2,   0,   0, 0},   /* D0C */
-	{0,  31,  0, 135,  16 * 2, 136,   0, 0},   /* D0L */
-	{192, 223,  0, 135,  16 * 2, 136,   0, 0}}; /* D0R */
+	{74, 149, 25,  75,  64,  51,  18, 0},   /* D3C */
+	{0,  83, 25,  75,  64,  51,  32, 0},   /* D3L */
+	{139, 223, 25,  75,  64,  51,   0, 0},   /* D3R */
+	{60, 163, 20,  90,  72,  71,  16, 0},   /* D2C */
+	{0,  74, 20,  90,  72,  71,  61, 0},   /* D2L */
+	{149, 223, 20,  90,  72,  71,   0, 0},   /* D2R */
+	{32, 191,  9, 119, 128, 111,  48, 0},   /* D1C */
+	{0,  63,  9, 119, 128, 111, 192, 0},   /* D1L */
+	{160, 223,  9, 119, 128, 111,   0, 0},   /* D1R */
+	{0, 223,  0, 135,   0,   0,   0, 0},   /* D0C */
+	{0,  31,  0, 135,  16, 136,   0, 0},   /* D0L */
+	{192, 223,  0, 135,  16, 136,   0, 0}}; /* D0R */
 
 
 enum WallSetIndices {
 	kDoorFrameFront = 0, // @  G0709_puc_Bitmap_WallSet_DoorFrameFront
 	kDoorFrameLeft_D1C = 1, // @  G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C
-	kFameLeft_D2C = 2, // @  G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C
+	kDoorFameLeft_D2C = 2, // @  G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C
 	kDoorFrameLeft_D3C = 3, // @  G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C
 	kDoorFrameLeft_D3L = 4, // @  G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L
 	kDoorFrameTop_D1LCR = 5, // @  G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR
@@ -690,8 +690,8 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
 
 			for (int j = 0; j < byte1 / 2; ++j) {
 				uint8 byte2 = data[nextByteIndex++];
-				destBitmap[k++] = byte2 & 0x0F;
 				destBitmap[k++] = (byte2 & 0xF0) >> 4;
+				destBitmap[k++] = byte2 & 0x0F;
 			}
 		}
 	}
@@ -764,8 +764,15 @@ uint16 DisplayMan::height(uint16 index) {
 	return READ_BE_UINT16(data + 2);
 }
 
+
+void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
+	if (f.srcWidth)
+		blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorNoTransparency, gDungeonViewport);
+}
+
 void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) {
-	blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport);
+	if (f.srcWidth)
+		blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport);
 }
 
 void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
@@ -778,9 +785,110 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
 	}
 }
 
+void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
+	uint16 squareAspect[5];
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	switch (squareAspect[0]) {
+	case kWallElemType:
+		drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3R]);
+		break;
+	}
+}
+void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) {
+	uint16 squareAspect[5];
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	switch (squareAspect[0]) {
+	case kWallElemType:
+		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3C]);
+		break;
+	}
+}
+void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) {
+	uint16 squareAspect[5];
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	switch (squareAspect[0]) {
+	case kWallElemType:
+		drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2L]);
+		break;
+	}
+}
+void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) {
+	uint16 squareAspect[5];
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	switch (squareAspect[0]) {
+	case kWallElemType:
+		drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2R]);
+		break;
+	}
+}
+void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) {
+	uint16 squareAspect[5];
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	switch (squareAspect[0]) {
+	case kWallElemType:
+		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2C]);
+		break;
+	}
+}
+void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) {
+	uint16 squareAspect[5];
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	switch (squareAspect[0]) {
+	case kWallElemType:
+		drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1L]);
+		break;
+	}
+}
+void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) {
+	uint16 squareAspect[5];
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	switch (squareAspect[0]) {
+	case kWallElemType:
+		drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1R]);
+		break;
+	}
+}
+void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) {
+	uint16 squareAspect[5];
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	switch (squareAspect[0]) {
+	case kWallElemType:
+		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1C]);
+		break;
+	}
+}
+void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) {
+	uint16 squareAspect[5];
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	switch (squareAspect[0]) {
+	case kWallElemType:
+		drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]);
+		break;
+	}
+}
+
+void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) {
+	uint16 squareAspect[5];
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	switch (squareAspect[0]) {
+	case kWallElemType:
+		drawWallSetBitmap(_wallSetBitMaps[kWall_D0R], gFrameWalls[kViewSquare_D0R]);
+		break;
+	}
+}
+
+void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) {
+	uint16 squareAspect[5];
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	switch (squareAspect[0]) {
+	case kWallElemType:
+		drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]);
+		break;
+	}
+}
 
 void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
-	loadPalette(gPalDungeonView[0]);
+	loadPalette(gPalEntrance);
 	// TODO: this is a global variable, set from here
 	bool flippedFloorCeiling = (posX + posY + dir) & 1;
 
@@ -795,7 +903,7 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 		drawWallSetBitmap(tmpBitmap, gFloorFrame);
 		drawWallSetBitmap(_ceilingBitmap, gCeilingFrame);
 
-		for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i)
+		for (uint16 i = kWall_D0R; i <= kWall_D3LCR && false; ++i) // TODO: I dunno what this flipped wall thing is, but it messes everything up, disable with && false
 			_wallSetBitMaps[i] = _wallSetBitMapsFlipped[i];
 	} else {
 		uint16 w = gCeilingFrame.srcWidth, h = gCeilingFrame.srcHeight;
@@ -810,10 +918,40 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallElemType)
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D3R2], gFrameWall_D3R2);
 
-	// D3L
 	int16 tmpPosX = posX, tmpPosY = posY;
-	_vm->_dungeonMan->getRelSquareType(dir, 3, -1, tmpPosX, tmpPosY);
-	//drawSquareD3L(dir, posX, posY);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY);
+	drawSquareD3L(dir, posX, posY);
+	tmpPosX = posX, tmpPosY = posY;
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, 1, tmpPosX, tmpPosY);
+	drawSquareD3R(dir, tmpPosX, tmpPosY);
+	tmpPosX = posX, tmpPosY = posY;
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, 0, tmpPosX, tmpPosY);
+	drawSquareD3C(dir, tmpPosX, tmpPosY);
+	tmpPosX = posX, tmpPosY = posY;
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, -1, tmpPosX, tmpPosY);
+	drawSquareD2L(dir, tmpPosX, tmpPosY);
+	tmpPosX = posX, tmpPosY = posY;
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, 1, tmpPosX, tmpPosY);
+	drawSquareD2R(dir, tmpPosX, tmpPosY);
+	tmpPosX = posX, tmpPosY = posY;
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, 0, tmpPosX, tmpPosY);
+	drawSquareD2C(dir, tmpPosX, tmpPosY);
+	tmpPosX = posX, tmpPosY = posY;
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, -1, tmpPosX, tmpPosY);
+	drawSquareD1L(dir, tmpPosX, tmpPosY);
+	tmpPosX = posX, tmpPosY = posY;
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, 1, tmpPosX, tmpPosY);
+	drawSquareD1R(dir, tmpPosX, tmpPosY);
+	tmpPosX = posX, tmpPosY = posY;
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, 0, tmpPosX, tmpPosY);
+	drawSquareD1C(dir, tmpPosX, tmpPosY);
+	tmpPosX = posX, tmpPosY = posY;
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 0, -1, tmpPosX, tmpPosY);
+	drawSquareD0L(dir, tmpPosX, tmpPosY);
+	tmpPosX = posX, tmpPosY = posY;
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 0, 1, tmpPosX, tmpPosY);
+	drawSquareD0R(dir, tmpPosX, tmpPosY);
+	drawSquareD0C(dir, posX, posY);
 
 
 	for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i)
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index ee2b373..963a841 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -114,7 +114,19 @@ class DisplayMan {
 	void unpackGraphics();
 
 	void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap
+	void drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency
 	void drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L
+	void drawSquareD3R(direction dir, int16 posX, int16 posY); // @ F0117_DUNGEONVIEW_DrawSquareD3R
+	void drawSquareD3C(direction dir, int16 posX, int16 posY); // @ F0118_DUNGEONVIEW_DrawSquareD3C_CPSF
+	void drawSquareD2L(direction dir, int16 posX, int16 posY); // @ F0119_DUNGEONVIEW_DrawSquareD2L
+	void drawSquareD2R(direction dir, int16 posX, int16 posY); // @ F0120_DUNGEONVIEW_DrawSquareD2R_CPSF
+	void drawSquareD2C(direction dir, int16 posX, int16 posY); // @ F0121_DUNGEONVIEW_DrawSquareD2C
+	void drawSquareD1L(direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1L
+	void drawSquareD1R(direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1R
+	void drawSquareD1C(direction dir, int16 posX, int16 posY); // @ F0124_DUNGEONVIEW_DrawSquareD1C
+	void drawSquareD0L(direction dir, int16 posX, int16 posY); // @ F0125_DUNGEONVIEW_DrawSquareD0L
+	void drawSquareD0R(direction dir, int16 posX, int16 posY); // @ F0126_DUNGEONVIEW_DrawSquareD0R
+	void drawSquareD0C(direction dir, int16 posX, int16 posY); // @ F0127_DUNGEONVIEW_DrawSquareD0C
 
 	void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet
 	void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet


Commit: 9655066a069bc86a956b7da19f6a06ceda2fd4bf
    https://github.com/scummvm/scummvm/commit/9655066a069bc86a956b7da19f6a06ceda2fd4bf
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: getSquareAspect(..) is complete

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 9295ea6..72a068d 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -71,7 +71,7 @@ Common::Error DMEngine::run() {
 	uint16 i = 0; //TODO: testing, please delete me
 	while (true) {
 		_displayMan->clearScreen(kColorBlack);
-		_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY + i);
+		_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY);
 		_displayMan->updateScreen();
 		_system->delayMillis(2000); //TODO: testing, please set me to 10
 		if (++i == 100) break;
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 7c8afd1..a0bbadd 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -8,6 +8,11 @@
 
 namespace DM {
 
+class Console;
+class DisplayMan;
+class DungeonMan;
+
+
 enum direction {
 	kDirNorth = 0,
 	kDirEast = 1,
@@ -15,9 +20,47 @@ enum direction {
 	kDirWest = 3
 };
 
-class Console;
-class DisplayMan;
-class DungeonMan;
+int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
+int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
+enum ThingType {
+	kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value
+	kDoorThingType = 0,
+	kTeleporterThingType = 1,
+	kTextstringType = 2,
+	kSensorThingType = 3,
+	kGroupThingType = 4,
+	kWeaponThingType = 5,
+	kArmourThingType = 6,
+	kScrollThingType = 7,
+	kPotionThingType = 8,
+	kContainerThingType = 9,
+	kJunkThingType = 10,
+	kProjectileThingType = 14,
+	kExplosionThingType = 15,
+	kThingTypeTotal = 16 // +1 than the last (explosionThingType)
+}; // @ C[00..15]_THING_TYPE_...
+
+class Thing {
+	uint16 data;
+public:
+	static const Thing thingNone;
+	static const Thing thingEndOfList;
+
+	Thing() {}
+	Thing(uint16 d) { set(d); }
+
+	void set(uint16 d) {
+		data = d;
+	}
+
+	byte getCell() const { return data >> 14; }
+	ThingType getType() const { return (ThingType)((data >> 10) & 0xF); }
+	uint16 getIndex() const { return data & 0x1FF; }
+	uint16 toUint16() const { return data; } // I don't like 'em cast operators
+	bool operator==(const Thing &rhs) const { return data == rhs.data; }
+	bool operator!=(const Thing &rhs) const { return data != rhs.data; }
+}; // @ THING
+
 
 enum {
 	// engine debug channels
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index e2ad66a..cd713e4 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -12,6 +12,7 @@ int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /*
 int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */};
 
 void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
+bool isOrientedWestEast(direction dir) { return dir & 1; }
 
 
 }
@@ -458,21 +459,24 @@ enum SquareAspectIndice {
 	kStairsUpAspect = 2,
 	kDoorStateAspect = 2,
 	kDoorThingIndexAspect = 3,
-	kFloorOrnOrdAspect = 4
+	kFloorOrnOrdAspect = 4,
+	kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS          
 };
 
 
-void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) {
+// TODO: get rid of the GOTOs
+void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) {	// complete, except where marked
 	bool leftOrnAllowed, rightOrnAllowed, frontOrnAllowed;
 	bool squareIsFakeWall;
+	bool footPrintsAllowed;
 
+	_vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75, possible fix
+
+	memset(aspectArray, 0, 5 * sizeof(uint16));
 	Thing thing = getSquareFirstThing(mapX, mapY);
 	Square square = getSquare(mapX, mapY);
 
-	memset(aspectArray, 0, 5 * sizeof(int16));
 	aspectArray[kElemAspect] = square.getType();
-
-	_vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75, possible fix
 	switch (square.getType()) {
 	case kWallElemType:
 		switch (dir) {
@@ -499,6 +503,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
 		}
 
 		squareIsFakeWall = false;
+T0172010_ClosedFakeWall:
 		setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall);
 
 		while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) {
@@ -507,13 +512,13 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
 				if (thing.getType() == kTextstringType) {
 					if (TextString(getThingData(thing)).isVisible()) {
 						aspectArray[sideIndex + 1] = _currMapInscriptionWallOrnIndex + 1;
-
-					} else {
-						Sensor sensor(getThingData(thing));
-						aspectArray[sideIndex + 1] = sensor.getOrnOrdinal();
-						if (sensor.getType() == kSensorWallChampionPortrait) {
-							_vm->_displayMan->_championPortraitOrdinal = indexToOrdinal(sensor.getData());
-						}
+						_vm->_displayMan->_inscriptionThing = thing; // BUG0_76
+					}
+				} else {
+					Sensor sensor(getThingData(thing));
+					aspectArray[sideIndex + 1] = sensor.getOrnOrdinal();
+					if (sensor.getType() == kSensorWallChampionPortrait) {
+						_vm->_displayMan->_championPortraitOrdinal = indexToOrdinal(sensor.getData());
 					}
 				}
 			}
@@ -521,8 +526,60 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
 		}
 		if (squareIsFakeWall && (_currMap.partyPosX != mapX) && (_currMap.partyPosY != mapY)) {
 			aspectArray[kFirstGroupOrObjectAspect] = Thing::thingEndOfList.toUint16();
+			return;
 		}
 		break;
+	case kPitElemType:
+		if (square.get(kPitOpen))
+			aspectArray[kPitInvisibleAspect] = square.get(kPitInvisible);
+		else
+			aspectArray[kElemAspect] = kCorridorElemType;
+		footPrintsAllowed = true;
+		goto T0172030_Pit;
+	case kFakeWallElemType:
+		if (!square.get(kFakeWallOpen)) {
+			aspectArray[kElemAspect] = kWallElemType;
+			leftOrnAllowed = rightOrnAllowed = frontOrnAllowed = square.get(kFakeWallRandOrnOrFootPAllowed);
+			squareIsFakeWall = true;
+			goto T0172010_ClosedFakeWall;
+		}
+		aspectArray[kWallElemType] = kCorridorElemType;
+		footPrintsAllowed = square.get(kFakeWallRandOrnOrFootPAllowed);
+		// intentional fallthrough
+	case kCorridorElemType:
+		aspectArray[kFloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(kCorridorRandOrnAllowed), _currMap.map->randFloorOrnCount, mapX, mapY, 30);
+T0172029_Teleporter:
+		footPrintsAllowed = true;
+T0172030_Pit:
+		while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) {
+			if (thing.getType() == kSensorThingType)
+				aspectArray[kFloorOrnOrdAspect] = Sensor(getThingData(thing)).getOrnOrdinal();
+			thing = getNextThing(thing);
+		}
+		goto T0172049_Footprints;
+	case kTeleporterElemType:
+		aspectArray[kTeleporterVisibleAspect] = square.get(kTeleporterOpen) && square.get(kTeleporterVisible);
+		goto T0172029_Teleporter;
+	case kStairsElemType:
+		aspectArray[kElemAspect] = ((square.get(kStairsNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) ? kStairsSideElemType : kStairsFrontElemType;
+		aspectArray[kStairsUpAspect] = square.get(kStairsUp);
+		footPrintsAllowed = false;
+		goto T0172046_Stairs;
+	case kDoorElemType:
+		if ((square.get(kDoorNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) {
+			aspectArray[kElemAspect] = kDoorSideElemType;
+		} else {
+			aspectArray[kElemAspect] = kDoorFrontElemType;
+			aspectArray[kDoorStateAspect] = square.getDoorState();
+			aspectArray[kDoorThingIndexAspect] = getSquareFirstThing(mapX, mapY).getIndex();
+		}
+		footPrintsAllowed = true;
+T0172046_Stairs:
+		while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType))
+			thing = getNextThing(thing);
+T0172049_Footprints:
+		if (footPrintsAllowed) // TODO: I skipped some party query code, must come back later and complete
+			aspectArray[kFloorOrnOrdAspect] &= kFootprintsAspect;
 	}
 	aspectArray[kFirstGroupOrObjectAspect] = thing.toUint16();
 }
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 931d635..3c02158 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -10,46 +10,6 @@ class DungeonMan;
 struct Map;
 
 
-int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
-int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
-enum ThingType {
-	kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value
-	kDoorThingType = 0,
-	kTeleporterThingType = 1,
-	kTextstringType = 2,
-	kSensorThingType = 3,
-	kGroupThingType = 4,
-	kWeaponThingType = 5,
-	kArmourThingType = 6,
-	kScrollThingType = 7,
-	kPotionThingType = 8,
-	kContainerThingType = 9,
-	kJunkThingType = 10,
-	kProjectileThingType = 14,
-	kExplosionThingType = 15,
-	kThingTypeTotal = 16 // +1 than the last (explosionThingType)
-}; // @ C[00..15]_THING_TYPE_...
-
-class Thing {
-	uint16 data;
-public:
-	static const Thing thingNone;
-	static const Thing thingEndOfList;
-
-	Thing() {}
-	Thing(uint16 d) { set(d); }
-
-	void set(uint16 d) {
-		data = d;
-	}
-
-	byte getCell() const { return data >> 14; }
-	ThingType getType() const { return (ThingType)((data >> 10) & 0xF); }
-	uint16 getIndex() const { return data & 0x1FF; }
-	uint16 toUint16() const { return data; } // I don't like 'em cast operators
-	bool operator==(const Thing &rhs) const { return data == rhs.data; }
-	bool operator!=(const Thing &rhs) const { return data != rhs.data; }
-}; // @ THING
 
 struct CreatureInfo {
 	byte creatureAspectIndex;
@@ -297,6 +257,7 @@ enum SquareMask {
 	kWallSouthRandOrnAllowed = 0x2,
 	kWallEastRandOrnAllowed = 0x4,
 	kWallNorthRandOrnAllowed = 0x8,
+	kCorridorRandOrnAllowed = 0x8,
 	kPitImaginary = 0x1,
 	kPitInvisible = 0x4,
 	kPitOpen = 0x8,
@@ -334,7 +295,9 @@ public:
 	Square(SquareType type) { setType(type); }
 	Square &set(byte dat) { this->data = dat; return *this; }
 	Square &set(SquareMask mask) { data |= mask; return *this; }
-	bool get(SquareMask mask) { return data & mask; }
+	byte get(SquareMask mask) { return data & mask; }
+	byte getDoorState() { return data & 0x7; } // @ M36_DOOR_STATE
+	Square &setDoorState(byte state) { data = ((data & ~0x7) | state); } // @ M37_SET_DOOR_STATE
 	SquareType getType() { return (SquareType)(data >> 5); } // @ M34_SQUARE_TYPE
 	Square &setType(SquareType type) { data = (data & 0x1F) | type << 5; return *this; }
 	byte toByte() { return data; } // I don't like 'em casts
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 963a841..4c54ff6 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -166,7 +166,6 @@ public:
 	void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
 
-
 	int16 _championPortraitOrdinal = 0; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
 	int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount] = {0}; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
 	int16 _currMapFountainOrnIndices[kFountainOrnCount] = {0}; // @ G0268_ai_CurrentMapFountainOrnamentIndices
@@ -179,6 +178,8 @@ public:
 	byte _currMapDoorOrnIndices[18] = {0}; // @ G0263_auc_CurrentMapDoorOrnamentIndices
 
 	int16 _currMapViAltarIndex = 0; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex
+
+	Thing _inscriptionThing = Thing::thingNone; // @ G0290_T_DungeonView_InscriptionThing
 };
 
 }


Commit: 807fda8a9a3d7b975a749c6d82232526bc43281d
    https://github.com/scummvm/scummvm/commit/807fda8a9a3d7b975a749c6d82232526bc43281d
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add wall flipping display

Changed paths:
    engines/dm/dm.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 72a068d..9cdcd1a 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -68,13 +68,18 @@ Common::Error DMEngine::run() {
 
 	_displayMan->loadPalette(gPalCredits);
 
+	byte pos[] = {kDirSouth, 1, 3, kDirSouth, 1, 4, kDirSouth, 1, 5, kDirSouth, 1, 6, kDirSouth, 1, 7, kDirEast, 1, 7};
+
 	uint16 i = 0; //TODO: testing, please delete me
 	while (true) {
 		_displayMan->clearScreen(kColorBlack);
-		_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY);
+		_displayMan->drawDungeon((direction)pos[i*3 + 0], pos[i*3 + 1], pos[i*3 + 2]);
+		//_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY + i);
 		_displayMan->updateScreen();
-		_system->delayMillis(2000); //TODO: testing, please set me to 10
-		if (++i == 100) break;
+		_system->delayMillis(1000); //TODO: testing, please set me to 10
+		if(i == 0)
+			_system->delayMillis(0000); //TODO: testing, please set me to 10
+		if (++i == 6) i = 0;
 	}
 
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 8bf6178..4dbc315 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -93,7 +93,19 @@ enum WallSetIndices {
 	kWall_D3L2 = 12, // @  G0697_puc_Bitmap_WallSet_Wall_D3L2
 
 	kWall_D3R2 = 13, // @  G0696_puc_Bitmap_WallSet_Wall_D3R2
-	kDoorFrameRight_D1C = 14// @  G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C
+	kDoorFrameRight_D1C = 14, // @  G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C
+
+	kWall_D0R_Flipped = 15,
+	kWall_D0L_Flipped = 16,
+	kWall_D1LCR_Flipped = 17,
+	kWall_D2LCR_Flipped = 18,
+	kWall_D3LCR_Flipped = 19,
+
+	kWall_D0R_Native = 20,
+	kWall_D0L_Native = 21,
+	kWall_D1LCR_Native = 22,
+	kWall_D2LCR_Native = 23,
+	kWall_D3LCR_Native = 24,
 };
 
 
@@ -562,8 +574,8 @@ DisplayMan::~DisplayMan() {
 	}
 	delete[] _wallSetBitMaps[kWall_D3R2]; // copy of another bitmap, but flipped
 	delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; // copy of another bitmap, but flipped
-	for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i)
-		delete[] _wallSetBitMapsFlipped[i];
+	for (uint16 i = kWall_D0L_Flipped; i <= kWall_D3LCR_Flipped; ++i)
+		delete[] _wallSetBitMaps[i];
 }
 
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
@@ -903,8 +915,8 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 		drawWallSetBitmap(tmpBitmap, gFloorFrame);
 		drawWallSetBitmap(_ceilingBitmap, gCeilingFrame);
 
-		for (uint16 i = kWall_D0R; i <= kWall_D3LCR && false; ++i) // TODO: I dunno what this flipped wall thing is, but it messes everything up, disable with && false
-			_wallSetBitMaps[i] = _wallSetBitMapsFlipped[i];
+		for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i)
+			_wallSetBitMaps[i + kWall_D0R] = _wallSetBitMaps[i + kWall_D0R_Flipped];
 	} else {
 		uint16 w = gCeilingFrame.srcWidth, h = gCeilingFrame.srcHeight;
 		blitToBitmap(_ceilingBitmap, w, h, tmpBitmap, w);
@@ -920,7 +932,7 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 
 	int16 tmpPosX = posX, tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY);
-	drawSquareD3L(dir, posX, posY);
+	drawSquareD3L(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX, tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, 1, tmpPosX, tmpPosY);
 	drawSquareD3R(dir, tmpPosX, tmpPosY);
@@ -954,8 +966,8 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	drawSquareD0C(dir, posX, posY);
 
 
-	for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i)
-		_wallSetBitMaps[i] = _wallSetBitMapsNative[i];
+	for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i)
+		_wallSetBitMaps[i + kWall_D0R] = _wallSetBitMaps[i + kWall_D0R_Native];
 
 	delete[] tmpBitmap;
 }
@@ -976,35 +988,54 @@ void DisplayMan::loadFloorSet(FloorSet set) {
 	_ceilingBitmap = _bitmaps[indice + 1];
 }
 
+
+Box gBoxWallBitmap_D3LCR = {0, 115, 0, 50}; // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR
+Box gBoxWallBitmap_D2LCR = {0, 135, 0, 70}; // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR
+
 void DisplayMan::loadWallSet(WallSet set) {
 	uint16 firstIndice = (set * kWallSetGraphicCount) + kFirstWallSet;
 	for (uint16 i = 0; i < kWallSetGraphicCount; ++i) {
 		_wallSetBitMaps[i] = _bitmaps[i + firstIndice];
 	}
 
-	uint16 leftDoorIndice = firstIndice + kDoorFrameLeft_D1C;
-	uint16 w = width(leftDoorIndice), h = height(leftDoorIndice);
-	delete[] _wallSetBitMaps[kDoorFrameRight_D1C];
-	_wallSetBitMaps[kDoorFrameRight_D1C] = new byte[w * h];
-	blitToBitmap(_wallSetBitMaps[kDoorFrameLeft_D1C], w, h, _wallSetBitMaps[kDoorFrameRight_D1C], w);
-	flipBitmapHorizontal(_wallSetBitMaps[kDoorFrameRight_D1C], w, h);
-
-	uint16 leftWallIndice = firstIndice + kWall_D3L2;
-	w = width(leftWallIndice), h = height(leftWallIndice);
-	delete[] _wallSetBitMaps[kWall_D3R2];
-	_wallSetBitMaps[kWall_D3R2] = new byte[w * h];
-	blitToBitmap(_wallSetBitMaps[kWall_D3L2], w, h, _wallSetBitMaps[kWall_D3R2], w);
-	flipBitmapHorizontal(_wallSetBitMaps[kWall_D3R2], w, h);
-	for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i)
-		_wallSetBitMapsNative[i] = _wallSetBitMaps[i];
-
-	for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i) {
-		uint16 w = width(firstIndice + i), h = height(firstIndice + i);
-		delete[] _wallSetBitMapsFlipped[i];
-		_wallSetBitMapsFlipped[i] = new byte[w * h];
-		blitToBitmap(_wallSetBitMaps[i], w, h, _wallSetBitMapsFlipped[i], w);
-		flipBitmapHorizontal(_wallSetBitMapsFlipped[i], w, h);
+	for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i)
+		_wallSetBitMaps[i + kWall_D0R_Native] = _wallSetBitMaps[i + kWall_D0R];
+
+	uint16 srcIndex[7] = {kDoorFrameLeft_D1C,  kWall_D3L2, kWall_D1LCR,         kWall_D0L,         kWall_D0R,
+	kWall_D2LCR,         kWall_D3LCR};
+
+	uint16 destIndex[7] = {kDoorFrameRight_D1C, kWall_D3R2, kWall_D1LCR_Flipped, kWall_D0R_Flipped, kWall_D0L_Flipped,
+	kWall_D2LCR_Flipped, kWall_D3LCR_Flipped};
+
+	for (uint16 i = 0; i < 7; ++i) {
+		uint16 srcGraphicIndice = firstIndice + srcIndex[i];
+		uint16 w = width(srcGraphicIndice), h = height(srcGraphicIndice);
+		delete[] _wallSetBitMaps[destIndex[i]];
+		_wallSetBitMaps[destIndex[i]] = new byte[w * h];
+		blitToBitmap(_wallSetBitMaps[srcIndex[i]], w, h, _wallSetBitMaps[destIndex[i]], w);
+		if (srcIndex[i] != kWall_D2LCR && srcIndex[i] != kWall_D3LCR) // TODO: implement flipping of these two bitmaps, disabled with if
+			flipBitmapHorizontal(_wallSetBitMaps[destIndex[i]], w, h);
 	}
+
+
+	/*
+	uint16 graphicIndice = firstIndice + kWall_D2LCR;
+	uint16 w = width(graphicIndice), h = height(graphicIndice);
+	byte *tmp = new byte[w * h];
+	clearBitmap(tmp, w, h, kColorFlesh);
+	Box *box = &gBoxWallBitmap_D2LCR;
+	blitToBitmap(_wallSetBitMaps[kWall_D2LCR_Flipped], w, 8, 0, tmp, w, box->X1, box->X2, box->Y1, box->Y2, kColorNoTransparency);
+	delete[] _wallSetBitMaps[kWall_D2LCR_Flipped];
+	_wallSetBitMaps[kWall_D2LCR_Flipped] = tmp;
+
+	graphicIndice = firstIndice + kWall_D3LCR;
+	w = width(graphicIndice), h = height(graphicIndice);
+	tmp = new byte[w * h];
+	clearBitmap(tmp, w, h, kColorFlesh);
+	box = &gBoxWallBitmap_D3LCR;
+	blitToBitmap(_wallSetBitMaps[kWall_D3LCR_Flipped], w, 8, 0, tmp, w, box->X1, box->X2, box->Y1, box->Y2, kColorNoTransparency);
+	delete[] _wallSetBitMaps[kWall_D3LCR_Flipped];
+	_wallSetBitMaps[kWall_D3LCR_Flipped] = tmp;*/
 }
 
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 4c54ff6..8b59d51 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -12,6 +12,13 @@ extern uint16 gPalCredits[16];
 extern uint16 gPalEntrance[16];
 extern uint16 gPalDungeonView[6][16];
 
+typedef struct {
+	uint16 X1;
+	uint16 X2;
+	uint16 Y1;
+	uint16 Y2;
+} Box; // @ BOX_BYTE, BOX_WORD
+
 struct Frame;
 enum WallSet {
 	kWallSetStone = 0 // @ C0_WALL_SET_STONE
@@ -91,11 +98,7 @@ class DisplayMan {
 
 
 	// the last two pointers are owned by this array
-	byte *_wallSetBitMaps[15] = {NULL};	// @G[0696..0710]_puc_Bitmap_WallSet_...
-
-	// only [7-11] is used, indexing convenience
-	byte *_wallSetBitMapsNative[12] = {NULL}; // @G[0095..0099]_puc_Bitmap_Wall...
-	byte *_wallSetBitMapsFlipped[12] = {NULL}; // @G[0090..0094]_puc_Bitmap_Wall...
+	byte *_wallSetBitMaps[25] = {NULL};	// @G[0696..0710]_puc_Bitmap_WallSet_...
 
 	// pointers are not owned by these fields
 	byte *_floorBitmap = NULL;


Commit: f591cbbcf350b0f61cb2441bd4a89a7b45e3c689
    https://github.com/scummvm/scummvm/commit/f591cbbcf350b0f61cb2441bd4a89a7b45e3c689
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add dummy movement code for testing

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 9cdcd1a..0aa4cb3 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -9,6 +9,7 @@
 #include "engines/engine.h"
 #include "graphics/palette.h"
 #include "common/file.h"
+#include "common/events.h"
 
 #include "dm/dm.h"
 #include "dm/gfx.h"
@@ -16,6 +17,13 @@
 
 namespace DM {
 
+int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */};
+int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */};
+
+void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
+void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); }
+bool isOrientedWestEast(direction dir) { return dir & 1; }
+
 
 DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	// Do not load data files
@@ -59,7 +67,8 @@ Common::Error DMEngine::run() {
 	_displayMan->loadGraphics();
 
 	_dungeonMan->loadDungeonFile();
-	_dungeonMan->setCurrentMapAndPartyMap(0);
+	int16 dummyMapIndex = 0;
+	_dungeonMan->setCurrentMapAndPartyMap(dummyMapIndex);
 
 
 
@@ -68,18 +77,44 @@ Common::Error DMEngine::run() {
 
 	_displayMan->loadPalette(gPalCredits);
 
-	byte pos[] = {kDirSouth, 1, 3, kDirSouth, 1, 4, kDirSouth, 1, 5, kDirSouth, 1, 6, kDirSouth, 1, 7, kDirEast, 1, 7};
-
-	uint16 i = 0; //TODO: testing, please delete me
+	CurrMapData &currMap = _dungeonMan->_currMap;
 	while (true) {
+		Common::Event event;
+		while (_system->getEventManager()->pollEvent(event)) {
+			if (event.type == Common::EVENT_KEYDOWN && !event.synthetic)
+				switch (event.kbd.keycode) {
+				case Common::KEYCODE_w:
+					_dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY);
+					break;
+				case Common::KEYCODE_a:
+					_dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, 0, -1, currMap.partyPosX, currMap.partyPosY);
+					break;
+				case Common::KEYCODE_s:
+					_dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, -1, 0, currMap.partyPosX, currMap.partyPosY);
+					break;
+				case Common::KEYCODE_d:
+					_dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, 0, 1, currMap.partyPosX, currMap.partyPosY);
+					break;
+				case Common::KEYCODE_q:
+					turnDirLeft(currMap.partyDir);
+					break;
+				case Common::KEYCODE_e:
+					turnDirRight(currMap.partyDir);
+					break;
+				case Common::KEYCODE_UP:
+					if (dummyMapIndex < 13)
+						_dungeonMan->setCurrentMapAndPartyMap(++dummyMapIndex);
+					break;
+				case Common::KEYCODE_DOWN:
+					if (dummyMapIndex > 0)
+						_dungeonMan->setCurrentMapAndPartyMap(--dummyMapIndex);
+					break;
+				}
+		}
 		_displayMan->clearScreen(kColorBlack);
-		_displayMan->drawDungeon((direction)pos[i*3 + 0], pos[i*3 + 1], pos[i*3 + 2]);
-		//_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY + i);
+		_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY);
 		_displayMan->updateScreen();
-		_system->delayMillis(1000); //TODO: testing, please set me to 10
-		if(i == 0)
-			_system->delayMillis(0000); //TODO: testing, please set me to 10
-		if (++i == 6) i = 0;
+		_system->delayMillis(10);
 	}
 
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index a0bbadd..817c3ec 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -20,8 +20,15 @@ enum direction {
 	kDirWest = 3
 };
 
-int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
-int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
+// TODO: refactor direction into a class
+extern int8 dirIntoStepCountEast[4];
+extern int8 dirIntoStepCountNorth[4];
+
+void turnDirRight(direction &dir);
+void turnDirLeft(direction &dir);
+bool isOrientedWestEast(direction dir);
+
+
 enum ThingType {
 	kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value
 	kDoorThingType = 0,
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index cd713e4..cceface 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -5,18 +5,6 @@
 
 
 
-
-namespace DM {
-// TODO: refactor direction into a class
-int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */};
-int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */};
-
-void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
-bool isOrientedWestEast(direction dir) { return dir & 1; }
-
-
-}
-
 using namespace DM;
 
 CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 3c02158..35a337d 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -9,7 +9,8 @@ namespace DM {
 class DungeonMan;
 struct Map;
 
-
+int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
+int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
 
 struct CreatureInfo {
 	byte creatureAspectIndex;
@@ -360,8 +361,8 @@ struct DungeonData {
 
 struct CurrMapData {
 	direction partyDir; // @ G0308_i_PartyDirection
-	uint16 partyPosX; // @ G0306_i_PartyMapX
-	uint16 partyPosY; // @ G0307_i_PartyMapY
+	int16 partyPosX; // @ G0306_i_PartyMapX
+	int16 partyPosY; // @ G0307_i_PartyMapY
 	uint8 currPartyMapIndex; // @ G0309_i_PartyMapIndex
 
 	uint8 index; // @ G0272_i_CurrentMapIndex
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 8b59d51..d558e81 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -116,6 +116,7 @@ class DisplayMan {
 	void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap
 	void unpackGraphics();
 
+	// @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap
 	void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap
 	void drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency
 	void drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L


Commit: 3ada56f6b1e8f2b65b6a77dbd3ff4d91bba705a0
    https://github.com/scummvm/scummvm/commit/3ada56f6b1e8f2b65b6a77dbd3ff4d91bba705a0
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add stairs display

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index cceface..af10338 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -7,6 +7,8 @@
 
 using namespace DM;
 
+
+
 CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo
 												   /* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo,
 												   MovementTicks, AttackTicks, Defense, BaseHealth, Attack, PoisonAttack,
@@ -436,21 +438,6 @@ Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) {
 	return _dunData.squareFirstThings[index];
 }
 
-enum SquareAspectIndice {
-	kElemAspect = 0,
-	kFirstGroupOrObjectAspect = 1,
-	kRightWallOrnOrdAspect = 2,
-	kFrontWallOrnOrdAspect = 3,
-	kLeftWallOrnOrdAspect = 4,
-	kPitInvisibleAspect = 2,
-	kTeleporterVisibleAspect = 2,
-	kStairsUpAspect = 2,
-	kDoorStateAspect = 2,
-	kDoorThingIndexAspect = 3,
-	kFloorOrnOrdAspect = 4,
-	kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS          
-};
-
 
 // TODO: get rid of the GOTOs
 void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) {	// complete, except where marked
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 35a337d..60a0bb6 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -12,6 +12,23 @@ struct Map;
 int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
 int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
 
+
+enum SquareAspectIndice {
+	kElemAspect = 0,
+	kFirstGroupOrObjectAspect = 1,
+	kRightWallOrnOrdAspect = 2,
+	kFrontWallOrnOrdAspect = 3,
+	kLeftWallOrnOrdAspect = 4,
+	kPitInvisibleAspect = 2,
+	kTeleporterVisibleAspect = 2,
+	kStairsUpAspect = 2,
+	kDoorStateAspect = 2,
+	kDoorThingIndexAspect = 3,
+	kFloorOrnOrdAspect = 4,
+	kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS          
+};
+
+
 struct CreatureInfo {
 	byte creatureAspectIndex;
 	byte attackSoundOrdinal;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 4dbc315..c88ca00 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -23,6 +23,71 @@ struct Frame {
 };
 
 
+enum StairFrameIndex {
+	kFrameStairsUpFront_D3L = 0, // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L 
+	kFrameStairsUpFront_D3C = 1, // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C 
+	kFrameStairsUpFront_D3R = 2, // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R 
+	kFrameStairsUpFront_D2L = 3, // @ G0113_s_Graphic558_Frame_StairsUpFront_D2L 
+	kFrameStairsUpFront_D2C = 4, // @ G0114_s_Graphic558_Frame_StairsUpFront_D2C 
+	kFrameStairsUpFront_D2R = 5, // @ G0115_s_Graphic558_Frame_StairsUpFront_D2R 
+	kFrameStairsUpFront_D1L = 6, // @ G0116_s_Graphic558_Frame_StairsUpFront_D1L 
+	kFrameStairsUpFront_D1C = 7, // @ G0117_s_Graphic558_Frame_StairsUpFront_D1C 
+	kFrameStairsUpFront_D1R = 8, // @ G0118_s_Graphic558_Frame_StairsUpFront_D1R 
+	kFrameStairsUpFront_D0L = 9, // @ G0119_s_Graphic558_Frame_StairsUpFront_D0L 
+	kFrameStairsUpFront_D0R = 10, // @ G0120_s_Graphic558_Frame_StairsUpFront_D0R 
+	kFrameStairsDownFront_D3L = 11, // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L 
+	kFrameStairsDownFront_D3C = 12, // @ G0122_s_Graphic558_Frame_StairsDownFront_D3C 
+	kFrameStairsDownFront_D3R = 13, // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R 
+	kFrameStairsDownFront_D2L = 14, // @ G0124_s_Graphic558_Frame_StairsDownFront_D2L 
+	kFrameStairsDownFront_D2C = 15, // @ G0125_s_Graphic558_Frame_StairsDownFront_D2C 
+	kFrameStairsDownFront_D2R = 16, // @ G0126_s_Graphic558_Frame_StairsDownFront_D2R 
+	kFrameStairsDownFront_D1L = 17, // @ G0127_s_Graphic558_Frame_StairsDownFront_D1L 
+	kFrameStairsDownFront_D1C = 18, // @ G0128_s_Graphic558_Frame_StairsDownFront_D1C 
+	kFrameStairsDownFront_D1R = 19, // @ G0129_s_Graphic558_Frame_StairsDownFront_D1R 
+	kFrameStairsDownFront_D0L = 20, // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L 
+	kFrameStairsDownFront_D0R = 21, // @ G0131_s_Graphic558_Frame_StairsDownFront_D0R 
+	kFrameStairsSide_D2L = 22, // @ G0132_s_Graphic558_Frame_StairsSide_D2L 
+	kFrameStairsSide_D2R = 23, // @ G0133_s_Graphic558_Frame_StairsSide_D2R 
+	kFrameStairsUpSide_D1L = 24, // @ G0134_s_Graphic558_Frame_StairsUpSide_D1L 
+	kFrameStairsUpSide_D1R = 25, // @ G0135_s_Graphic558_Frame_StairsUpSide_D1R 
+	kFrameStairsDownSide_D1L = 26, // @ G0136_s_Graphic558_Frame_StairsDownSide_D1L 
+	kFrameStairsDownSide_D1R = 27, // @ G0137_s_Graphic558_Frame_StairsDownSide_D1R 
+	kFrameStairsSide_D0L = 28, // @ G0138_s_Graphic558_Frame_StairsSide_D0L 
+	kFrameStairsSide_D0R = 29 // @ G0139_s_Graphic558_Frame_StairsSide_D0R 
+};
+
+Frame gStairFrames[] = {{0, 79, 25, 70, 40, 46, 0, 0},
+{64, 159, 25, 70, 48, 46, 0, 0},
+{149, 223, 25, 70, 40, 46, 5, 0},
+{0, 63, 22, 83, 32, 62, 0, 0},
+{64, 159, 22, 83, 48, 62, 0, 0},
+{160, 223, 22, 83, 32, 62, 0, 0},
+{0, 31, 9, 108, 16, 100, 0, 0},
+{32, 191, 9, 108, 80, 100, 0, 0},
+{192, 223, 9, 108, 16, 100, 0, 0},
+{0, 31, 58, 101, 16, 44, 0, 0},
+{192, 223, 58, 101, 16, 44, 0, 0},
+{0, 79, 28, 68, 40, 41, 0, 0},
+{64, 159, 28, 70, 48, 43, 0, 0},
+{149, 223, 28, 68, 40, 41, 5, 0},
+{0, 63, 24, 85, 32, 62, 0, 0},
+{64, 159, 24, 85, 48, 62, 0, 0},
+{160, 223, 24, 85, 32, 62, 0, 0},
+{0, 31, 18, 108, 16, 91, 0, 0},
+{32, 191, 18, 108, 80, 91, 0, 0},
+{192, 223, 18, 108, 16, 91, 0, 0},
+{0, 31, 76, 135, 16, 60, 0, 0},
+{192, 223, 76, 135, 16, 60, 0, 0},
+{60, 75, 57, 61, 8, 5, 0, 0},
+{148, 163, 57, 61, 8, 5, 0, 0},
+{32, 63, 57, 99, 16, 43, 0, 0},
+{160, 191, 57, 99, 16, 43, 0, 0},
+{32, 63, 60, 98, 16, 39, 0, 0},
+{160, 191, 60, 98, 16, 39, 0, 0},
+{0, 15, 73, 85, 8, 13, 0, 0},
+{208, 223, 73, 85, 8, 13, 0, 0}};
+
+
 #define kFirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT
 #define kFirstFloorSet 75 // @ C075_GRAPHIC_FIRST_FLOOR_SET
 #define kFirstWallSet 77 // @ C077_GRAPHIC_FIRST_WALL_SET
@@ -581,6 +646,8 @@ DisplayMan::~DisplayMan() {
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
 	_screenWidth = width;
 	_screenHeight = height;
+	delete[] _tmpBitmap;
+	_tmpBitmap = new byte[_screenWidth * _screenHeight];
 	delete[] _vgaBuffer;
 	_vgaBuffer = new byte[_screenWidth * _screenHeight];
 	clearScreen(kColorBlack);
@@ -590,18 +657,18 @@ void DisplayMan::loadGraphics() {
 	Common::File f;
 	f.open("graphics.dat");
 
-	grapItemCount = f.readUint16BE();
+	_grapItemCount = f.readUint16BE();
 	delete[] _packedItemPos;
-	_packedItemPos = new uint32[grapItemCount + 1];
+	_packedItemPos = new uint32[_grapItemCount + 1];
 	_packedItemPos[0] = 0;
-	for (uint16 i = 1; i < grapItemCount + 1; ++i)
+	for (uint16 i = 1; i < _grapItemCount + 1; ++i)
 		_packedItemPos[i] = f.readUint16BE() + _packedItemPos[i - 1];
 
 	delete[] _packedBitmaps;
-	_packedBitmaps = new uint8[_packedItemPos[grapItemCount]];
+	_packedBitmaps = new uint8[_packedItemPos[_grapItemCount]];
 
-	f.seek(2 + grapItemCount * 4);
-	for (uint32 i = 0; i < _packedItemPos[grapItemCount]; ++i)
+	f.seek(2 + _grapItemCount * 4);
+	for (uint32 i = 0; i < _packedItemPos[_grapItemCount]; ++i)
 		_packedBitmaps[i] = f.readByte();
 
 	f.close();
@@ -790,7 +857,13 @@ void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) {
 void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[0]) {
+	switch (squareAspect[kElemAspect]) {
+	case kStairsFrontElemType:
+		if (squareAspect[kStairsUpAspect])
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3L]);
+		else
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3L]);
+		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3L]);
 		break;
@@ -801,6 +874,12 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
+	case kStairsFrontElemType:
+		if (squareAspect[kStairsUpAspect])
+			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3R]);
+		else
+			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3R]);
+		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3R]);
 		break;
@@ -810,6 +889,12 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
+	case kStairsFrontElemType:
+		if (squareAspect[kStairsUpAspect])
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D3C, gStairFrames[kFrameStairsUpFront_D3C]);
+		else
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D3C, gStairFrames[kFrameStairsDownFront_D3C]);
+		break;
 	case kWallElemType:
 		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3C]);
 		break;
@@ -819,24 +904,48 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
+	case kStairsFrontElemType:
+		if (squareAspect[kStairsUpAspect])
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2L]);
+		else
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2L]);
+		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2L]);
 		break;
+	case kStairsSideElemType:
+		drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D2L, gFrameWalls[kFrameStairsSide_D2L]);
+		break;
 	}
 }
 void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
+	case kStairsFrontElemType:
+		if (squareAspect[kStairsUpAspect])
+			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2R]);
+		else
+			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2R]);
+		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2R]);
 		break;
+	case kStairsSideElemType:
+		drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]);
+		break;
 	}
 }
 void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
+	case kStairsFrontElemType:
+		if (squareAspect[kStairsUpAspect])
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D2C, gStairFrames[kFrameStairsUpFront_D2C]);
+		else
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D2C, gStairFrames[kFrameStairsDownFront_D2C]);
+		break;
 	case kWallElemType:
 		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2C]);
 		break;
@@ -846,24 +955,54 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
+	case kStairsFrontElemType:
+		if (squareAspect[kStairsUpAspect])
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1L]);
+		else
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1L]);
+		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1L]);
 		break;
+	case kStairsSideElemType:
+		if (squareAspect[kStairsUpAspect])
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1L]);
+		else
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1L]);
+		break;
 	}
 }
 void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
+	case kStairsFrontElemType:
+		if (squareAspect[kStairsUpAspect])
+			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1R]);
+		else
+			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1R]);
+		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1R]);
 		break;
+	case kStairsSideElemType:
+		if (squareAspect[kStairsUpAspect])
+			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1R]);
+		else
+			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1R]);
+		break;
 	}
 }
 void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
+	case kStairsFrontElemType:
+		if (squareAspect[kStairsUpAspect])
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D1C, gStairFrames[kFrameStairsUpFront_D1C]);
+		else
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D1C, gStairFrames[kFrameStairsDownFront_D1C]);
+		break;
 	case kWallElemType:
 		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1C]);
 		break;
@@ -873,6 +1012,10 @@ void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
+	case kStairsSideElemType:
+		if (squareAspect[kStairsUpAspect])
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0L]);
+		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]);
 		break;
@@ -883,6 +1026,10 @@ void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
+	case kStairsSideElemType:
+		if (squareAspect[kStairsUpAspect])
+			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0R]);
+		return;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D0R], gFrameWalls[kViewSquare_D0R]);
 		break;
@@ -893,8 +1040,14 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
-	case kWallElemType:
-		drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]);
+	case kStairsFrontElemType:
+		if (squareAspect[kStairsUpAspect]) {
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0L]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0R]);
+		} else {
+			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0L]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0R]);
+		}
 		break;
 	}
 }
@@ -1007,6 +1160,8 @@ void DisplayMan::loadWallSet(WallSet set) {
 	uint16 destIndex[7] = {kDoorFrameRight_D1C, kWall_D3R2, kWall_D1LCR_Flipped, kWall_D0R_Flipped, kWall_D0L_Flipped,
 	kWall_D2LCR_Flipped, kWall_D3LCR_Flipped};
 
+	// the original loads these flipped walls in loadCurrentMapGraphics
+
 	for (uint16 i = 0; i < 7; ++i) {
 		uint16 srcGraphicIndice = firstIndice + srcIndex[i];
 		uint16 w = width(srcGraphicIndice), h = height(srcGraphicIndice);
@@ -1043,6 +1198,11 @@ void DisplayMan::loadCurrentMapGraphics() {
 	loadFloorSet(_vm->_dungeonMan->_currMap.map->floorSet);
 	loadWallSet(_vm->_dungeonMan->_currMap.map->wallSet);
 
+	// the original loads some flipped walls here, I moved it to loadWallSet
+
+	for (uint16 i = 0, firstGraphicIndex = _vm->_dungeonMan->_currMap.map->wallSet * kStairsGraphicCount + kFirstStairs; i < kStairsGraphicCount; ++i)
+		_stairIndices[i] = firstGraphicIndex + i;
+
 	for (int16 i = 0; i < kAlcoveOrnCount; ++i)
 		_currMapAlcoveOrnIndices[i] = -1;
 	for (int16 i = 0; i < kFountainOrnCount; ++i)
@@ -1110,3 +1270,17 @@ void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor
 	gPalChangesCreature_D2[replacedColor] = gCreatureReplColorSets[replacementColor].D2ReplacementColor;
 	gPalChangesCreature_D3[replacedColor] = gCreatureReplColorSets[replacementColor].D3ReplacementColor;
 }
+
+void DisplayMan::drawFloorPitOrStairsBitmap(StairIndex relIndex, Frame &f) {
+	if (f.srcWidth) {
+		blitToScreen(_bitmaps[_stairIndices[relIndex]], f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport);
+	}
+}
+
+void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relIndex, Frame &f) {
+	if (f.srcWidth) {
+		blitToBitmap(_bitmaps[_stairIndices[relIndex]], f.srcWidth, f.srcHeight, _tmpBitmap, f.srcWidth);
+		flipBitmapHorizontal(_tmpBitmap, f.srcWidth, f.srcHeight);
+		blitToScreen(_tmpBitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport);
+	}
+}
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index d558e81..bc7296e 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -28,6 +28,28 @@ enum FloorSet {
 	kFloorSetStone = 0 // @ C0_FLOOR_SET_STONE
 };
 
+enum StairIndex {
+	kStairsNativeIndex_Up_Front_D3L = 0, // @ G0675_i_StairsNativeBitmapIndex_Up_Front_D3L
+	kStairsNativeIndex_Up_Front_D3C = 1, // @ G0676_i_StairsNativeBitmapIndex_Up_Front_D3C
+	kStairsNativeIndex_Up_Front_D2L = 2, // @ G0677_i_StairsNativeBitmapIndex_Up_Front_D2L
+	kStairsNativeIndex_Up_Front_D2C = 3, // @ G0678_i_StairsNativeBitmapIndex_Up_Front_D2C
+	kStairsNativeIndex_Up_Front_D1L = 4, // @ G0679_i_StairsNativeBitmapIndex_Up_Front_D1L
+	kStairsNativeIndex_Up_Front_D1C = 5, // @ G0680_i_StairsNativeBitmapIndex_Up_Front_D1C
+	kStairsNativeIndex_Up_Front_D0C_Left = 6, // @ G0681_i_StairsNativeBitmapIndex_Up_Front_D0C_Left
+	kStairsNativeIndex_Down_Front_D3L = 7, // @ G0682_i_StairsNativeBitmapIndex_Down_Front_D3L
+	kStairsNativeIndex_Down_Front_D3C = 8, // @ G0683_i_StairsNativeBitmapIndex_Down_Front_D3C
+	kStairsNativeIndex_Down_Front_D2L = 9, // @ G0684_i_StairsNativeBitmapIndex_Down_Front_D2L
+	kStairsNativeIndex_Down_Front_D2C = 10, // @ G0685_i_StairsNativeBitmapIndex_Down_Front_D2C
+	kStairsNativeIndex_Down_Front_D1L = 11, // @ G0686_i_StairsNativeBitmapIndex_Down_Front_D1L
+	kStairsNativeIndex_Down_Front_D1C = 12, // @ G0687_i_StairsNativeBitmapIndex_Down_Front_D1C
+	kStairsNativeIndex_Down_Front_D0C_Left = 13, // @ G0688_i_StairsNativeBitmapIndex_Down_Front_D0C_Left
+	kStairsNativeIndex_Side_D2L = 14, // @ G0689_i_StairsNativeBitmapIndex_Side_D2L
+	kStairsNativeIndex_Up_Side_D1L = 15, // @ G0690_i_StairsNativeBitmapIndex_Up_Side_D1L
+	kStairsNativeIndex_Down_Side_D1L = 16, // @ G0691_i_StairsNativeBitmapIndex_Down_Side_D1L
+	kStairsNativeIndex_Side_D0L = 17 // @ G0692_i_StairsNativeBitmapIndex_Side_D0L
+};
+
+
 enum Color {
 	kColorNoTransparency = 255,
 	kColorBlack = 0,
@@ -91,15 +113,18 @@ class DisplayMan {
 
 
 	/// Related to graphics.dat file
-	uint16 grapItemCount = 0; // @ G0632_ui_GraphicCount
+	uint16 _grapItemCount = 0; // @ G0632_ui_GraphicCount
 	uint32 *_packedItemPos = NULL;
 	byte *_packedBitmaps = NULL;
 	byte **_bitmaps = NULL;
 
 
-	// the last two pointers are owned by this array
+	// pointers 13,14 and [15-19] are owned by this array
 	byte *_wallSetBitMaps[25] = {NULL};	// @G[0696..0710]_puc_Bitmap_WallSet_...
 
+	uint16 _stairIndices[kStairsGraphicCount] = {0};
+
+
 	// pointers are not owned by these fields
 	byte *_floorBitmap = NULL;
 	byte *_ceilingBitmap = NULL;
@@ -116,7 +141,8 @@ class DisplayMan {
 	void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap
 	void unpackGraphics();
 
-	// @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap
+	void drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally
+	void drawFloorPitOrStairsBitmap(StairIndex relIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap
 	void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap
 	void drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency
 	void drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L
@@ -137,6 +163,8 @@ class DisplayMan {
 
 	void applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors
 
+	// some methods use this for a stratchpad, don't make assumptions about content between function calls
+	byte *_tmpBitmap = NULL;
 public:
 	DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();


Commit: 082e3fb37ccd97f9d8a782f4fb47adf9a0661ecb
    https://github.com/scummvm/scummvm/commit/082e3fb37ccd97f9d8a782f4fb47adf9a0661ecb
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add global variable dependencies for isDrawnWallOrnAnAlcove

Changed paths:
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 60a0bb6..dbcb6fb 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -447,6 +447,10 @@ public:
 	Messages _messages; // @ NONE;
 
 	int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex
+	byte _dungeonViewClickableBoxes[6][4]; // G0291_aauc_DungeonViewClickableBoxes
+	bool _isFacingAlcove; // @ G0286_B_FacingAlcove
+	bool _isFacingViAltar; // @ G0287_B_FacingViAltar
+	bool _isFacingFountain; // @ G0288_B_FacingFountain
 };
 
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index c88ca00..0840da6 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -121,6 +121,7 @@ enum ViewSquare {
 	kViewSquare_D0C_Explosion = 12 // @ C12_VIEW_SQUARE_D0C_EXPLOSION
 };
 
+
 Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling
 Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor
 
@@ -607,8 +608,9 @@ enum GraphicIndice {
 
 
 
-extern Viewport gDefultViewPort = {0, 0};
-extern Viewport gDungeonViewport = {0, 64};	// TODO: I guessed the numbers
+Viewport gDefultViewPort = {0, 0};
+// TODO: I guessed the numbers
+Viewport gDungeonViewport = {0, 64}; // @ G0296_puc_Bitmap_Viewport
 
 byte gPalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges
 
@@ -1004,6 +1006,9 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) {
 			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D1C, gStairFrames[kFrameStairsDownFront_D1C]);
 		break;
 	case kWallElemType:
+		_vm->_dungeonMan->_isFacingAlcove = false;
+		_vm->_dungeonMan->_isFacingViAltar = false;
+		_vm->_dungeonMan->_isFacingFountain = false;
 		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1C]);
 		break;
 	}
@@ -1061,6 +1066,11 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	byte  *tmpBitmap = new byte[305 * 111];
 	clearBitmap(tmpBitmap, 305, 111, kColorBlack);
 
+	memset(_vm->_dungeonMan->_dungeonViewClickableBoxes, 0, sizeof(_vm->_dungeonMan->_dungeonViewClickableBoxes));
+	for (uint16 i = 0; i < 6; ++i) {
+		_vm->_dungeonMan->_dungeonViewClickableBoxes[i][0] = 255;
+	}
+
 	if (flippedFloorCeiling) {
 		uint16 w = gFloorFrame.srcWidth, h = gFloorFrame.srcHeight;
 		blitToBitmap(_floorBitmap, w, h, tmpBitmap, w);
@@ -1215,6 +1225,8 @@ void DisplayMan::loadCurrentMapGraphics() {
 	uint16 fountainCount = 0;
 	Map &currMap = *_vm->_dungeonMan->_currMap.map;
 
+	_currMapViAltarIndex = -1;
+
 	for (uint16 i = 0; i < currMap.wallOrnCount; ++i) {
 		uint16 ornIndice = _currMapWallOrnIndices[i];
 		uint16 nativeIndice = kFirstWallOrn + ornIndice * 2;
@@ -1284,3 +1296,41 @@ void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relInd
 		blitToScreen(_tmpBitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport);
 	}
 }
+
+
+Box gBoxWallPatchBehindInscription = {110, 113, 37, 63}; // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription 
+byte gInscriptionLineY[4] = { // @ G0203_auc_Graphic558_InscriptionLineY
+	48,   /* 1 Line  */
+	59,   /* 2 lines */
+	75,   /* 3 lines */
+	86}; /* 4 lines */
+byte gWallOrnDerivedBitmapIndexIncrement[12] = { // @ G0190_auc_Graphic558_WallOrnamentDerivedBitmapIndexIncrement
+	0,   /* D3L Right */
+	0,   /* D3R Left */
+	1,   /* D3L Front */
+	1,   /* D3C Front */
+	1,   /* D3R Front */
+	2,   /* D2L Right */
+	2,   /* D2R Left */
+	3,   /* D2L Front */
+	3,   /* D2C Front */
+	3,   /* D2R Front */
+	4,   /* D1L Right */
+	4}; /* D1R Left */
+
+byte gPalChangesDoorButtonAndWallOrn_D3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3
+byte gPalChangesDoorButtonAndWallOrn_D2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2
+
+byte gUnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableInscriptionBoxY2
+	/* { Y for 1 line, Y for 2 lines, Y for 3 lines } */
+	45, 48, 53,   /* D3L Right, D3R Left */
+	43, 49, 56,   /* D3L Front, D3C Front, D3R Front */
+	42, 49, 56,   /* D2L Right, D2R Left */
+	46, 53, 63,   /* D2L Front, D2C Front, D2R Front */
+	46, 57, 68}; /* D1L Right, D1R Left */
+
+Box gBoxChampionPortraitOnWall = {96, 127, 35, 63}; // G0109_s_Graphic558_Box_ChampionPortraitOnWall
+
+bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) {
+	return false; // dummy
+}
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index bc7296e..bbd9eb4 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -49,6 +49,23 @@ enum StairIndex {
 	kStairsNativeIndex_Side_D0L = 17 // @ G0692_i_StairsNativeBitmapIndex_Side_D0L
 };
 
+enum ViewWall {
+	kViewWall_D3L_RIGHT = 0, // @ C00_VIEW_WALL_D3L_RIGHT 
+	kViewWall_D3R_LEFT = 1, // @ C01_VIEW_WALL_D3R_LEFT  
+	kViewWall_D3L_FRONT = 2, // @ C02_VIEW_WALL_D3L_FRONT 
+	kViewWall_D3C_FRONT = 3, // @ C03_VIEW_WALL_D3C_FRONT 
+	kViewWall_D3R_FRONT = 4, // @ C04_VIEW_WALL_D3R_FRONT 
+	kViewWall_D2L_RIGHT = 5, // @ C05_VIEW_WALL_D2L_RIGHT 
+	kViewWall_D2R_LEFT = 6, // @ C06_VIEW_WALL_D2R_LEFT  
+	kViewWall_D2L_FRONT = 7, // @ C07_VIEW_WALL_D2L_FRONT 
+	kViewWall_D2C_FRONT = 8, // @ C08_VIEW_WALL_D2C_FRONT 
+	kViewWall_D2R_FRONT = 9, // @ C09_VIEW_WALL_D2R_FRONT 
+	kViewWall_D1L_RIGHT = 10, // @ C10_VIEW_WALL_D1L_RIGHT
+	kViewWall_D1R_LEFT = 11, // @ C11_VIEW_WALL_D1R_LEFT 
+	kViewWall_D1C_FRONT = 12  // @ C12_VIEW_WALL_D1C_FRONT
+};
+
+
 
 enum Color {
 	kColorNoTransparency = 255,
@@ -163,6 +180,8 @@ class DisplayMan {
 
 	void applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors
 
+	bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF
+
 	// some methods use this for a stratchpad, don't make assumptions about content between function calls
 	byte *_tmpBitmap = NULL;
 public:
@@ -201,7 +220,7 @@ public:
 	int16 _championPortraitOrdinal = 0; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
 	int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount] = {0}; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
 	int16 _currMapFountainOrnIndices[kFountainOrnCount] = {0}; // @ G0268_ai_CurrentMapFountainOrnamentIndices
-	int16 _currMapWallOrnInfo[16][2] = {0}; // @ G0101_aai_CurrentMapWallOrnamentsInf
+	int16 _currMapWallOrnInfo[16][2] = {0}; // @ G0101_aai_CurrentMapWallOrnamentsInfo
 	int16 _currMapFloorOrnInfo[16][2] = {0}; // @ G0102_aai_CurrentMapFloorOrnamentsInfo
 	int16 _currMapDoorOrnInfo[17][2] = {0}; // @ G0103_aai_CurrentMapDoorOrnamentsInfo
 	byte *_currMapAllowedCreatureTypes = NULL; // @ G0264_puc_CurrentMapAllowedCreatureTypes


Commit: 3a85c565815c58e6e6c9b007776b83ad942d7767
    https://github.com/scummvm/scummvm/commit/3a85c565815c58e6e6c9b007776b83ad942d7767
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add decodeText dependencies

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index af10338..1da24e6 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -604,3 +604,107 @@ Thing DungeonMan::getNextThing(Thing thing) {
 	return getThingData(thing)[0]; // :)
 }
 
+char gMessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings
+	{'x',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '?',  0,  0,  0, 0, 0, 0, 0 }, */
+	{'y',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '!',  0,  0,  0, 0, 0, 0, 0 }, */
+	{'T','H','E',' ', 0, 0, 0, 0},
+	{'Y','O','U',' ', 0, 0, 0, 0},
+	{'z',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+	{'{',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+	{'|',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+	{'}',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+	{'~',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+	{'',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0}};
+char gEscReplacementCharacters[32][2] = { // @ G0256_aac_Graphic559_EscapeReplacementCharacters
+	{'a', 0},
+	{'b', 0},
+	{'c', 0},
+	{'d', 0},
+	{'e', 0},
+	{'f', 0},
+	{'g', 0},
+	{'h', 0},
+	{'i', 0},
+	{'j', 0},
+	{'k', 0},
+	{'l', 0},
+	{'m', 0},
+	{'n', 0},
+	{'o', 0},
+	{'p', 0},
+	{'q', 0},
+	{'r', 0},
+	{'s', 0},
+	{'t', 0},
+	{'u', 0},
+	{'v', 0},
+	{'w', 0},
+	{'x', 0},
+	{'0', 0},
+	{'1', 0},
+	{'2', 0},
+	{'3', 0},
+	{'4', 0},
+	{'5', 0},
+	{'6', 0},
+	{'7', 0}};
+char gInscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_InscriptionEscapeReplacementStrings
+	{28,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+	{29,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+	{19,  7,  4, 26, 0, 0, 0, 0},
+	{24, 14, 20, 26, 0, 0, 0, 0},
+	{30,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+	{31,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+	{32,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+	{33,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+	{34,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+	{35,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0},
+	{0,  0,  0,  0, 0, 0, 0, 0}};
+
+
+void decodeText(char *destString, Thing thing, TextType type) {
+
+}
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index dbcb6fb..4a5ff17 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -13,6 +13,15 @@ int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
 int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
 
 
+enum TextType {
+	/* Used for text on walls */
+	kTextTypeInscription = 0, // @ C0_TEXT_TYPE_INSCRIPTION 
+	/* Used for messages displayed when the party walks on a square */
+	kTextTypeMessage = 1, // @ C1_TEXT_TYPE_MESSAGE 
+	/* Used for text on scrolls and champion information */
+	kTextTypeScroll = 2 // @ C2_TEXT_TYPE_SCROLL 
+};
+
 enum SquareAspectIndice {
 	kElemAspect = 0,
 	kFirstGroupOrObjectAspect = 1,
@@ -287,7 +296,8 @@ enum SquareMask {
 	kFakeWallImaginary = 0x1,
 	kFakeWallOpen = 0x4,
 	kFakeWallRandOrnOrFootPAllowed = 0x8,
-	kThingListPresent = 0x10
+	kThingListPresent = 0x10,
+	kDecodeEvenIfInvisible = 0x8000
 };
 
 enum SquareType {
@@ -434,8 +444,9 @@ public:
 		return Square(getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType();
 	} // @ F0153_DUNGEON_GetRelativeSquareType
 	void setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect
+	void decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText
 
-	uint32 _rawDunFileDataSize = 0;	 // @ probably NONE
+		uint32 _rawDunFileDataSize = 0;	 // @ probably NONE
 	byte *_rawDunFileData = NULL; // @ ???
 	DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader
 


Commit: 02c0487b5769b9a2d53f1cf692c2bb616b03be96
    https://github.com/scummvm/scummvm/commit/02c0487b5769b9a2d53f1cf692c2bb616b03be96
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add decodeText function

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 1da24e6..4d75d12 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -705,6 +705,69 @@ char gInscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_Insc
 	{0,  0,  0,  0, 0, 0, 0, 0}};
 
 
-void decodeText(char *destString, Thing thing, TextType type) {
-
+void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
+	char sepChar;
+	TextString textString(_dunData.thingsData[kTextstringType][thing.getIndex()]);
+	if ((textString.isVisible()) || (type & kDecodeEvenIfInvisible)) {
+		type = (TextType)(type & ~kDecodeEvenIfInvisible);
+		if (type == kTextTypeMessage) {
+			*destString++ = '\n';
+			sepChar = ' ';
+		} else if (type == kTextTypeInscription) {
+			sepChar = 0x80;
+		} else {
+			sepChar = '\n';
+		}
+		uint16 codeCounter = 0;
+		int16 escChar = 0;
+		uint16 *codeWord = _dunData.textData + textString.getWordOffset();
+		uint16 code, codes;
+		char *escReplString = NULL;
+		for (;;) { /*infinite loop*/
+			if (!codeCounter) {
+				codes = *codeWord++;
+				code = (codes >> 10) & 0x1F;
+			} else if (codeCounter == 1) {
+				code = (codes >> 5) & 0x1F;
+			} else {
+				code = codes & 0x1F;
+			}
+			++codeCounter;
+			codeCounter %= 3;
+
+			if (escChar) {
+				*destString = '\0';
+				if (escChar == 30) {
+					if (type != kTextTypeInscription) {
+						escReplString = gMessageAndScrollEscReplacementStrings[code];
+					} else {
+						escReplString = gInscriptionEscReplacementStrings[code];
+					}
+				} else {
+					escReplString = gEscReplacementCharacters[code];
+				}
+				strcat(destString, escReplString);
+				destString += strlen(escReplString);
+				escChar = 0;
+			} else if (code < 28) {
+				if (type != kTextTypeInscription) {
+					if (code == 26) {
+						code = ' ';
+					} else if (code == 27) {
+						code = '.';
+					} else {
+						code += 'A';
+					}
+				}
+				*destString++ = code;
+			} else if (code == 28) {
+				*destString++ = sepChar;
+			} else if (code <= 30) {
+				escChar = code;
+			} else {
+				break;
+			}
+		}
+	}
+	*destString = ((type == kTextTypeInscription) ? 0x81 : '\0');
 }


Commit: ab1e17257ca737c89c3e1a5f51741b2665ab4cac
    https://github.com/scummvm/scummvm/commit/ab1e17257ca737c89c3e1a5f51741b2665ab4cac
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add isDrawnWallOrnAnAlcove function

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 4d75d12..0702ab2 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -378,7 +378,6 @@ void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) {
 
 	_currMapInscriptionWallOrnIndex = _currMap.map->wallOrnCount;
 	_vm->_displayMan->_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = kWallOrnInscription;
-
 }
 
 
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 4a5ff17..cb53ba0 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -120,35 +120,35 @@ enum SensorActionType {
 };
 
 enum SensorType {
-	kSensorDisabled = 0, // @ C000_SENSOR_DISABLED                                                           /* Never triggered, may be used for a floor or wall ornament */
-	kSensorFloorTheronPartyCreatureObj = 1, // @ C001_SENSOR_FLOOR_THERON_PARTY_CREATURE_OBJECT                                 /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorFloorTheronPartyCreature = 2, // @ C002_SENSOR_FLOOR_THERON_PARTY_CREATURE                                        /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorFloorParty = 3, // @ C003_SENSOR_FLOOR_PARTY                                                        /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorFloorObj = 4, // @ C004_SENSOR_FLOOR_OBJECT                                                       /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorFloorPartyOnStairs = 5, // @ C005_SENSOR_FLOOR_PARTY_ON_STAIRS                                              /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorFloorGroupGenerator = 6, // @ C006_SENSOR_FLOOR_GROUP_GENERATOR                                              /* Triggered by event F0245_TIMELINE_ProcessEvent5_Square_Corridor */
-	kSensorFloorCreature = 7, // @ C007_SENSOR_FLOOR_CREATURE                                                     /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorFloorPartyPossession = 8, // @ C008_SENSOR_FLOOR_PARTY_POSSESSION                                             /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorFloorVersionChecker = 9, // @ C009_SENSOR_FLOOR_VERSION_CHECKER                                              /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorWallOrnClick = 1, // @ C001_SENSOR_WALL_ORNAMENT_CLICK                                                /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallOrnClickWithAnyObj = 2, // @ C002_SENSOR_WALL_ORNAMENT_CLICK_WITH_ANY_OBJECT                                /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallOrnClickWithSpecObj = 3, // @ C003_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT                           /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallOrnClickWithSpecObjRemoved = 4, // @ C004_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED                   /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallAndOrGate = 5, // @ C005_SENSOR_WALL_AND_OR_GATE                                                   /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallCountdown = 6, // @ C006_SENSOR_WALL_COUNTDOWN                                                     /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallSingleProjLauncherNewObj = 7, // @ C007_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_NEW_OBJECT                         /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallSingleProjLauncherExplosion = 8, // @ C008_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_EXPLOSION                          /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallDoubleProjLauncherNewObj = 9, // @ C009_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_NEW_OBJECT                         /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallDoubleProjLauncherExplosion = 10, // @ C010_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_EXPLOSION                         /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorDisabled = 0, // @ C000_SENSOR_DISABLED    /* Never triggered, may be used for a floor or wall ornament */
+	kSensorFloorTheronPartyCreatureObj = 1, // @ C001_SENSOR_FLOOR_THERON_PARTY_CREATURE_OBJECT    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorFloorTheronPartyCreature = 2, // @ C002_SENSOR_FLOOR_THERON_PARTY_CREATURE    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorFloorParty = 3, // @ C003_SENSOR_FLOOR_PARTY    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorFloorObj = 4, // @ C004_SENSOR_FLOOR_OBJECT    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorFloorPartyOnStairs = 5, // @ C005_SENSOR_FLOOR_PARTY_ON_STAIRS    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorFloorGroupGenerator = 6, // @ C006_SENSOR_FLOOR_GROUP_GENERATOR    /* Triggered by event F0245_TIMELINE_ProcessEvent5_Square_Corridor */
+	kSensorFloorCreature = 7, // @ C007_SENSOR_FLOOR_CREATURE    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorFloorPartyPossession = 8, // @ C008_SENSOR_FLOOR_PARTY_POSSESSION    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorFloorVersionChecker = 9, // @ C009_SENSOR_FLOOR_VERSION_CHECKER    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	kSensorWallOrnClick = 1, // @ C001_SENSOR_WALL_ORNAMENT_CLICK    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallOrnClickWithAnyObj = 2, // @ C002_SENSOR_WALL_ORNAMENT_CLICK_WITH_ANY_OBJECT    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallOrnClickWithSpecObj = 3, // @ C003_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallOrnClickWithSpecObjRemoved = 4, // @ C004_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallAndOrGate = 5, // @ C005_SENSOR_WALL_AND_OR_GATE    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallCountdown = 6, // @ C006_SENSOR_WALL_COUNTDOWN    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallSingleProjLauncherNewObj = 7, // @ C007_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_NEW_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallSingleProjLauncherExplosion = 8, // @ C008_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_EXPLOSION    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallDoubleProjLauncherNewObj = 9, // @ C009_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_NEW_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallDoubleProjLauncherExplosion = 10, // @ C010_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_EXPLOSION    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
 	kSensorWallOrnClickWithSpecObjRemovedRotateSensors = 11, // @ C011_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_ROTATE_SENSORS   /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallObjGeneratorRotateSensors = 12, // @ C012_SENSOR_WALL_OBJECT_GENERATOR_ROTATE_SENSORS                              /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallSingleObjStorageRotateSensors = 13, // @ C013_SENSOR_WALL_SINGLE_OBJECT_STORAGE_ROTATE_SENSORS                         /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallSingleProjLauncherSquareObj = 14, // @ C014_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT                     /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallDoubleProjLauncherSquareObj = 15, // @ C015_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT                     /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallObjExchanger = 16, // @ C016_SENSOR_WALL_OBJECT_EXCHANGER                                             /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallObjGeneratorRotateSensors = 12, // @ C012_SENSOR_WALL_OBJECT_GENERATOR_ROTATE_SENSORS    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallSingleObjStorageRotateSensors = 13, // @ C013_SENSOR_WALL_SINGLE_OBJECT_STORAGE_ROTATE_SENSORS    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallSingleProjLauncherSquareObj = 14, // @ C014_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallDoubleProjLauncherSquareObj = 15, // @ C015_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallObjExchanger = 16, // @ C016_SENSOR_WALL_OBJECT_EXCHANGER    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
 	kSensorWallOrnClickWithSpecObjRemovedSensor = 17, // @ C017_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_REMOVE_SENSOR    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallEndGame = 18, // @ C018_SENSOR_WALL_END_GAME                                                     /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallChampionPortrait = 127 // @ C127_SENSOR_WALL_CHAMPION_PORTRAIT                                           /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	kSensorWallEndGame = 18, // @ C018_SENSOR_WALL_END_GAME    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	kSensorWallChampionPortrait = 127 // @ C127_SENSOR_WALL_CHAMPION_PORTRAIT    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
 };
 
 class Sensor {
@@ -426,7 +426,6 @@ class DungeonMan {
 	void setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
 									int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals
 
-	bool isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove
 
 	void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
 
@@ -439,6 +438,7 @@ public:
 	void loadDungeonFile();	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
 	void setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap
 
+	bool isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove
 	void mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement
 	SquareType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
 		return Square(getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType();
@@ -458,7 +458,7 @@ public:
 	Messages _messages; // @ NONE;
 
 	int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex
-	byte _dungeonViewClickableBoxes[6][4]; // G0291_aauc_DungeonViewClickableBoxes
+	uint16 _dungeonViewClickableBoxes[6][4]; // G0291_aauc_DungeonViewClickableBoxes
 	bool _isFacingAlcove; // @ G0286_B_FacingAlcove
 	bool _isFacingViAltar; // @ G0287_B_FacingViAltar
 	bool _isFacingFountain; // @ G0288_B_FacingFountain
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 0840da6..cc9d971 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -16,6 +16,7 @@ struct Frame {
 	uint16 srcWidth, srcHeight;
 	uint16 srcX, srcY;
 
+	Frame() {}
 	Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
 		  uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) :
 		destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1),
@@ -23,6 +24,15 @@ struct Frame {
 };
 
 
+enum ViewCell {
+	kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT
+	kViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT
+	kViewCellBackRight = 2, // @ C02_VIEW_CELL_BACK_RIGHT
+	kViewCellBackLeft = 3, // @ C03_VIEW_CELL_BACK_LEFT
+	kViewCellAlcove = 4, // @ C04_VIEW_CELL_ALCOVE
+	kViewCellDoorButtonOrWallOrn = 5 // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT
+};
+
 enum StairFrameIndex {
 	kFrameStairsUpFront_D3L = 0, // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L 
 	kFrameStairsUpFront_D3C = 1, // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C 
@@ -200,7 +210,7 @@ byte gFloorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnamentCoor
 	2,   /* Floor Ornament 07 Tiny Pressure Pad */
 	0}; /* Floor Ornament 08 Puddle */
 
-byte gWallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets
+uint16 gWallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets
 	/* { X1, X2, Y1, Y2, PixelWidth, Height } */
 	{{80,  83, 41,  45,  8 * 2,   5},     /* D3L */
 	{140, 143, 41,  45,  8 * 2,   5},     /* D3R */
@@ -603,7 +613,9 @@ byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110,
 
 
 enum GraphicIndice {
-	kDoorMaskDestroyedIndice = 301 // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
+	kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT
+	kDoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
+	kChampionPortraitsIndice = 26 // @ C026_GRAPHIC_CHAMPION_PORTRAITS
 };
 
 
@@ -868,6 +880,10 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3L]);
+		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], kViewWall_D3L_RIGHT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3L_FRONT)) {
+			// ... missing code
+		}
 		break;
 	}
 }
@@ -884,6 +900,10 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3R]);
+		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], kViewWall_D3R_LEFT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3R_FRONT)) {
+			// ... missing code
+		}
 		break;
 	}
 }
@@ -899,6 +919,9 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) {
 		break;
 	case kWallElemType:
 		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3C]);
+		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3C_FRONT)) {
+			//... missing code
+		}
 		break;
 	}
 }
@@ -914,6 +937,10 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) {
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2L]);
+		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], kViewWall_D2L_RIGHT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D2L_FRONT)) {
+			// ... missing code
+		}
 		break;
 	case kStairsSideElemType:
 		drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D2L, gFrameWalls[kFrameStairsSide_D2L]);
@@ -932,6 +959,10 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) {
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2R]);
+		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], kViewWall_D2R_LEFT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D2R_FRONT)) {
+			// ... missing code
+		}
 		break;
 	case kStairsSideElemType:
 		drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]);
@@ -950,6 +981,9 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) {
 		break;
 	case kWallElemType:
 		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2C]);
+		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D2C_FRONT)) {
+			// ... missing code
+		}
 		break;
 	}
 }
@@ -965,6 +999,7 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) {
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1L]);
+		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], kViewWall_D1L_RIGHT);
 		break;
 	case kStairsSideElemType:
 		if (squareAspect[kStairsUpAspect])
@@ -986,6 +1021,7 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) {
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1R]);
+		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], kViewWall_D1R_LEFT);
 		break;
 	case kStairsSideElemType:
 		if (squareAspect[kStairsUpAspect])
@@ -1010,6 +1046,9 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) {
 		_vm->_dungeonMan->_isFacingViAltar = false;
 		_vm->_dungeonMan->_isFacingFountain = false;
 		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1C]);
+		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D1C_FRONT)) {
+			// .... code not yet implemneted
+		}
 		break;
 	}
 }
@@ -1332,5 +1371,134 @@ byte gUnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableIns
 Box gBoxChampionPortraitOnWall = {96, 127, 35, 63}; // G0109_s_Graphic558_Box_ChampionPortraitOnWall
 
 bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) {
-	return false; // dummy
+	byte *bitmapGreen;
+	byte *bitmapRed;
+	int16 coordinateSetOffset;
+	bool flipHorizontal;
+	bool isInscription;
+	bool isAlcove;
+	Frame frame;
+	unsigned char inscriptionString[70];
+
+
+	if (wallOrnOrd) {
+		int16 var_X;
+		int16 wallOrnIndex = wallOrnOrd - 1;
+		int16 nativeBitmapIndex = _currMapWallOrnInfo[wallOrnIndex][kNativeBitmapIndex];
+
+		uint16 *coordinateSetA = gWallOrnCoordSets[_currMapWallOrnInfo[wallOrnIndex][kNativeCoordinateSet]][viewWallIndex];
+		isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnIndex);
+		if (isInscription = (wallOrnIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex)) {
+			_vm->_dungeonMan->decodeText((char*)inscriptionString, _inscriptionThing, kTextTypeInscription);
+		}
+
+		if (viewWallIndex >= kViewWall_D1L_RIGHT) {
+			if (viewWallIndex == kViewWall_D1C_FRONT) {
+				if (isInscription) {
+					Frame &D1CFrame = gFrameWalls[kViewSquare_D1C];
+					blitToScreen(_wallSetBitMaps[kWall_D1LCR], D1CFrame.srcWidth, 94, 28, gBoxWallPatchBehindInscription.X1, gBoxWallPatchBehindInscription.X2,
+								 gBoxWallPatchBehindInscription.Y1, gBoxWallPatchBehindInscription.Y2, kColorNoTransparency, gDungeonViewport);
+
+					unsigned char *string = inscriptionString;
+					bitmapRed = _bitmaps[kInscriptionFontIndice];
+					int16 textLineIndex = 0;
+					do {
+						int16 characterCount = 0;
+						unsigned char *character = string;
+						while (*character++ < 0x80) {
+							characterCount++;
+						}
+						frame.destToX = (frame.destFromX = 112 - (characterCount * 4)) + 7;
+						frame.destFromY = (frame.destToY = gInscriptionLineY[textLineIndex++]) - 7;
+						while (characterCount--) {
+							blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame.destFromX, frame.destToX, frame.destFromY, frame.destToY, kColorFlesh, gDungeonViewport);
+							frame.destFromX += 8;
+							frame.destToX += 8;
+						}
+					} while (*string++ != 0x81);
+					return isAlcove;
+				}
+				nativeBitmapIndex++;
+				for (uint16 i = 0; i < 4; ++i)
+					_vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn][i] = coordinateSetA[i];
+				_vm->_dungeonMan->_isFacingAlcove = isAlcove;
+				_vm->_dungeonMan->_isFacingViAltar = (wallOrnIndex == _currMapViAltarIndex);
+				_vm->_dungeonMan->_isFacingFountain = false;
+				for (int16 fountainOrnIndex = 0; fountainOrnIndex < kFountainOrnCount; ++fountainOrnIndex) {
+					if (_currMapFountainOrnIndices[fountainOrnIndex] == wallOrnIndex) {
+						_vm->_dungeonMan->_isFacingFountain = true;
+						break;
+					}
+				}
+			}
+			bitmapGreen = _bitmaps[nativeBitmapIndex];
+			if (viewWallIndex == kViewWall_D1R_LEFT) {
+				blitToBitmap(bitmapGreen, coordinateSetA[4], coordinateSetA[5], _tmpBitmap, coordinateSetA[4]);
+				bitmapGreen = _tmpBitmap;
+			}
+			var_X = 0;
+		} else {
+			coordinateSetOffset = 0;
+			uint16 *coordSetB;
+			int16 wallOrnCoordSetIndex = _currMapWallOrnInfo[wallOrnIndex][kNativeCoordinateSet];
+			if (flipHorizontal = (viewWallIndex == kViewWall_D2R_LEFT) || (viewWallIndex == kViewWall_D3R_LEFT)) {
+				coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1R_LEFT];
+			} else if ((viewWallIndex == kViewWall_D2L_RIGHT) || (viewWallIndex == kViewWall_D3L_RIGHT)) {
+				coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1L_RIGHT];
+			} else {
+				nativeBitmapIndex++;
+				coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1C_FRONT];
+				if (viewWallIndex == kViewWall_D2L_FRONT) {
+					coordinateSetOffset = 6;
+				} else if (viewWallIndex == kViewWall_D2R_FRONT) {
+					coordinateSetOffset = -6;
+				}
+			}
+			int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0];
+			// TODO: I skipped some bitmap shrinking code here
+			bitmapGreen = _bitmaps[nativeBitmapIndex];
+			var_X = pixelWidth;
+			if (flipHorizontal) {
+				blitToBitmap(bitmapGreen, coordSetB[4], coordSetB[5], _tmpBitmap, coordSetB[4]);
+				bitmapGreen = _tmpBitmap;
+				var_X = 15 - (var_X & 0xF);
+			} else if (viewWallIndex == kViewWall_D2L_FRONT) {
+				var_X -= coordinateSetA[1] - coordinateSetA[0];
+			} else {
+				var_X = 0;
+			}
+		}
+		if (isInscription) {
+			unsigned char *string = inscriptionString;
+			int16 unreadableTextLineCount = 0;
+			do {
+				while (*string < 0x80) {
+					string++;
+				}
+				unreadableTextLineCount++;
+			} while (*string++ != 0x81);
+
+			if (unreadableTextLineCount < 4) {
+				frame.destFromX = coordinateSetA[0];
+				frame.destToX = coordinateSetA[1];
+				frame.destFromY = coordinateSetA[2];
+				frame.destToY = coordinateSetA[3];
+				frame.srcWidth = coordinateSetA[4];
+				frame.srcHeight = coordinateSetA[5];
+
+				coordinateSetA = &frame.destFromX;
+
+				coordinateSetA[3] = gUnreadableInscriptionBoxY2[gWallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
+			}
+		}
+		blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, coordinateSetA[0], coordinateSetA[1], coordinateSetA[2], coordinateSetA[3], kColorFlesh, gDungeonViewport);
+
+		if ((viewWallIndex == kViewWall_D1C_FRONT) && _championPortraitOrdinal--) {
+			Box &box = gBoxChampionPortraitOnWall;
+			blitToScreen(_bitmaps[kChampionPortraitsIndice], 256, (_championPortraitOrdinal & 0x7) << 5, _championPortraitOrdinal, box.X1, box.X2, box.Y1, box.Y2,
+						 kColorDarkGary, gDungeonViewport);
+		}
+		return isAlcove;
+	}
+	return false;
 }
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index bbd9eb4..14cb6eb 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -12,6 +12,8 @@ extern uint16 gPalCredits[16];
 extern uint16 gPalEntrance[16];
 extern uint16 gPalDungeonView[6][16];
 
+
+
 typedef struct {
 	uint16 X1;
 	uint16 X2;


Commit: b9935dfddc17ed71a6135896554d27d80c30b516
    https://github.com/scummvm/scummvm/commit/b9935dfddc17ed71a6135896554d27d80c30b516
Author: WinterGrascph (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add blitToBitmapShrinkWithPalChange

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index cc9d971..5a81151 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1052,6 +1052,7 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) {
 		break;
 	}
 }
+
 void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
@@ -1434,6 +1435,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 			bitmapGreen = _bitmaps[nativeBitmapIndex];
 			if (viewWallIndex == kViewWall_D1R_LEFT) {
 				blitToBitmap(bitmapGreen, coordinateSetA[4], coordinateSetA[5], _tmpBitmap, coordinateSetA[4]);
+				flipBitmapHorizontal(_tmpBitmap, coordinateSetA[4], coordinateSetA[5]);
 				bitmapGreen = _tmpBitmap;
 			}
 			var_X = 0;
@@ -1455,11 +1457,14 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 				}
 			}
 			int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0];
-			// TODO: I skipped some bitmap shrinking code here
+			blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], coordSetB[4] << 1, coordSetB[5], _tmpBitmap, pixelWidth + 1, coordinateSetA[5],
+				(viewWallIndex <= kViewWall_D3R_FRONT) ? gPalChangesDoorButtonAndWallOrn_D3 : gPalChangesDoorButtonAndWallOrn_D2);
 			bitmapGreen = _bitmaps[nativeBitmapIndex];
 			var_X = pixelWidth;
 			if (flipHorizontal) {
-				blitToBitmap(bitmapGreen, coordSetB[4], coordSetB[5], _tmpBitmap, coordSetB[4]);
+				if(bitmapGreen != _tmpBitmap)
+					blitToBitmap(bitmapGreen, coordSetB[4], coordSetB[5], _tmpBitmap, coordSetB[4]);
+				flipBitmapHorizontal(_tmpBitmap, coordSetB[4], coordSetB[5]);
 				bitmapGreen = _tmpBitmap;
 				var_X = 15 - (var_X & 0xF);
 			} else if (viewWallIndex == kViewWall_D2L_FRONT) {
@@ -1495,10 +1500,26 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 
 		if ((viewWallIndex == kViewWall_D1C_FRONT) && _championPortraitOrdinal--) {
 			Box &box = gBoxChampionPortraitOnWall;
-			blitToScreen(_bitmaps[kChampionPortraitsIndice], 256, (_championPortraitOrdinal & 0x7) << 5, _championPortraitOrdinal, box.X1, box.X2, box.Y1, box.Y2,
+			blitToScreen(_bitmaps[kChampionPortraitsIndice], 256, (_championPortraitOrdinal & 0x7) << 5, (_championPortraitOrdinal >> 3) * 29, box.X1, box.X2, box.Y1, box.Y2,
 						 kColorDarkGary, gDungeonViewport);
 		}
 		return isAlcove;
 	}
 	return false;
 }
+
+
+void DisplayMan::blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHeight, byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange) {
+	double rateW = srcWidth / destWidth;
+	double rateH = srcHeight / destHeight;
+
+	for (uint16 y = 0; y < destHeight; ++y) {
+		for (uint16 x = 0; x < destWidth; ++x) {
+			if (palChange)
+				destBitmap[y * destWidth + x] = palChange[srcBitmap[(int)(y * rateH * srcWidth) + (int)(x * rateW)]];
+			else
+				destBitmap[y * destWidth + x] = srcBitmap[(int)(y * rateH * srcWidth) + (int)(x * rateW)];
+		}
+	}
+
+}
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 14cb6eb..d8f4e29 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -206,6 +206,9 @@ public:
 					  byte *destBitmap, uint16 destWidth,
 					  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
 					  Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort);
+	void blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight,
+										 byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
+
 	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0);
 	void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 					  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,


Commit: 24c7c1e905991a846f6853020962bc3a942cfdfe
    https://github.com/scummvm/scummvm/commit/24c7c1e905991a846f6853020962bc3a942cfdfe
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some compilation errors under MSVC9

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 0702ab2..bb803ab 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -53,7 +53,62 @@ void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, in
 	posY += dirIntoStepCountNorth[dir] * stepsRight;
 }
 
-DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) {}
+DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) {
+	_dunData.columCount = 0;
+	_dunData.eventMaximumCount = 0;
+
+	_dunData.mapsFirstColumnIndex = nullptr;
+	_dunData.columnsCumulativeSquareThingCount = nullptr;
+	_dunData.squareFirstThings = nullptr;
+	_dunData.textData = nullptr;
+	_dunData.mapData = nullptr;
+
+	for (int i = 0; i < 16; i++)
+		_dunData.thingsData[i] = nullptr;
+
+	_currMap.partyDir = kDirNorth;
+	_currMap.partyPosX = 0;
+	_currMap.partyPosY = 0;
+	_currMap.currPartyMapIndex = 0;
+	_currMap.index = 0;
+	_currMap.width = 0;
+	_currMap.height = 0;
+
+	_currMap.data = nullptr;
+	_currMap.map = nullptr;
+	_currMap.colCumulativeSquareFirstThingCount = nullptr;
+
+	_messages.newGame = true;
+	_messages.restartGameRequest = false;
+
+	_rawDunFileDataSize = 0;
+	_rawDunFileData = nullptr;
+
+	_fileHeader.dungeonId = 0;
+	_fileHeader.ornamentRandomSeed = 0;
+	_fileHeader.rawMapDataSize = 0;
+	_fileHeader.mapCount = 0;
+	_fileHeader.textDataWordCount = 0;
+	_fileHeader.partyStartDir = kDirNorth;
+	_fileHeader.partyStartPosX = 0;
+	_fileHeader.partyStartPosY = 0;
+	_fileHeader.squareFirstThingCount = 0;
+
+	for (int i = 0; i < 16; i++)
+		_fileHeader.thingCounts[i] = 0;
+
+	_maps = nullptr;
+	_rawMapData = nullptr;
+
+	_currMapInscriptionWallOrnIndex = 0;
+	_isFacingAlcove = false;
+	_isFacingViAltar = false;
+	_isFacingFountain = false;
+
+	for (int i = 0; i < 4; i++)
+		for (int j = 0; j < 6; j++)
+			_dungeonViewClickableBoxes[j][i] = 0;
+}
 
 DungeonMan::~DungeonMan() {
 	delete[] _rawDunFileData;
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index cb53ba0..7652596 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -331,7 +331,6 @@ public:
 	byte toByte() { return data; } // I don't like 'em casts
 };
 
-
 struct DungeonFileHeader {
 	uint16 dungeonId; // @ G0526_ui_DungeonID
 	// equal to dungeonId
@@ -366,21 +365,19 @@ struct Map {
 	uint8 doorSet0, doorSet1;
 }; // @ MAP
 
-
-
 struct DungeonData {
 	// I have no idea the heck is this
-	uint16 *mapsFirstColumnIndex = NULL; // @ G0281_pui_DungeonMapsFirstColumnIndex
+	uint16 *mapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex
 	uint16 columCount; // @ G0282_ui_DungeonColumnCount
 
 	// I have no idea the heck is this
-	uint16 *columnsCumulativeSquareThingCount = NULL; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
-	Thing *squareFirstThings = NULL; // @ G0283_pT_SquareFirstThings
-	uint16 *textData = NULL; // @ G0260_pui_DungeonTextData
+	uint16 *columnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
+	Thing *squareFirstThings; // @ G0283_pT_SquareFirstThings
+	uint16 *textData; // @ G0260_pui_DungeonTextData
 
-	uint16 **thingsData[16] = {NULL}; // @ G0284_apuc_ThingData
+	uint16 **thingsData[16]; // @ G0284_apuc_ThingData
 
-	byte ***mapData = NULL; // @ G0279_pppuc_DungeonMapData
+	byte ***mapData; // @ G0279_pppuc_DungeonMapData
 
 	// TODO: ??? is this doing here
 	uint16 eventMaximumCount; // @ G0369_ui_EventMaximumCount
@@ -393,21 +390,18 @@ struct CurrMapData {
 	uint8 currPartyMapIndex; // @ G0309_i_PartyMapIndex
 
 	uint8 index; // @ G0272_i_CurrentMapIndex
-	byte **data = NULL; // @ G0271_ppuc_CurrentMapData
-	Map *map = NULL; // @ G0269_ps_CurrentMap
+	byte **data; // @ G0271_ppuc_CurrentMapData
+	Map *map; // @ G0269_ps_CurrentMap
 	uint16 width; // @ G0273_i_CurrentMapWidth
 	uint16 height; // @ G0274_i_CurrentMapHeight
-	uint16 *colCumulativeSquareFirstThingCount = NULL; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount
+	uint16 *colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount
 }; // @ AGGREGATE
 
 struct Messages {
-	bool newGame = true; // @ G0298_B_NewGame
-	bool restartGameRequest = false; // @ G0523_B_RestartGameRequested
+	bool newGame; // @ G0298_B_NewGame
+	bool restartGameRequest; // @ G0523_B_RestartGameRequested
 }; // @ AGGREGATE
 
-
-
-
 class DungeonMan {
 	DMEngine *_vm;
 
@@ -446,15 +440,15 @@ public:
 	void setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect
 	void decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText
 
-		uint32 _rawDunFileDataSize = 0;	 // @ probably NONE
-	byte *_rawDunFileData = NULL; // @ ???
+	uint32 _rawDunFileDataSize;	 // @ probably NONE
+	byte *_rawDunFileData; // @ ???
 	DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader
 
 	DungeonData _dunData; // @ NONE
 	CurrMapData _currMap; // @ NONE
-	Map *_maps = NULL; // @ G0277_ps_DungeonMaps
+	Map *_maps; // @ G0277_ps_DungeonMaps
 	// does not have to be freed
-	byte *_rawMapData = NULL; // @ G0276_puc_DungeonRawMapData
+	byte *_rawMapData; // @ G0276_puc_DungeonRawMapData
 	Messages _messages; // @ NONE;
 
 	int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 5a81151..581e4fa 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -633,15 +633,62 @@ int gFountainOrnIndices[kFountainOrnCount] = {35}; // @ G0193_ai_Graphic558_Foun
 byte gAlcoveOrnIndices[kAlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrnamentIndices
 	1,   /* Square Alcove */
 	2,   /* Vi Altar */
-	3}; /* Arched Alcove */
-
+	3};  /* Arched Alcove */
 }
 
 using namespace DM;
 
-DisplayMan::DisplayMan(DMEngine *dmEngine) :
-	_vm(dmEngine), _screenWidth(0), _screenHeight(0),
-	_vgaBuffer(NULL), _bitmaps(NULL) {}
+DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {	
+	_vgaBuffer = nullptr;
+	_bitmaps = nullptr;
+	_grapItemCount = 0;
+	_packedItemPos = nullptr;
+	_packedBitmaps = nullptr;
+	_bitmaps = nullptr;
+	_tmpBitmap = nullptr;
+	_floorBitmap = nullptr;
+	_ceilingBitmap = nullptr;
+	_currMapAllowedCreatureTypes = nullptr;
+
+	_screenWidth = _screenHeight = 0;
+	_championPortraitOrdinal = 0;
+	_currMapViAltarIndex = 0;
+
+	for (int i = 0; i < 25; i++)
+		_wallSetBitMaps[i] = nullptr;
+
+	for (int i = 0; i < kStairsGraphicCount; i++)
+		_stairIndices[i] = 0;
+	
+	for (int i = 0; i < 4; i++)
+		_palChangesProjectile[i] =  nullptr;
+
+	for (int i = 0; i < kAlcoveOrnCount; i++)
+		_currMapAlcoveOrnIndices[i] = 0;
+
+	for (int i = 0; i < kFountainOrnCount; i++)
+		_currMapFountainOrnIndices[i] = 0;
+
+	for (int i = 0; i < 2; i++) {
+		for (int j = 0; j < 16; j++) {
+			_currMapWallOrnInfo[j][i] = 0;
+			_currMapFloorOrnInfo[j][i] = 0;
+		}
+		for (int j = 0; j < 17; j++) {
+			_currMapDoorOrnInfo[j][i] = 0;
+		}
+	}
+	
+	for (int i = 0; i < 16; i++) {
+		_currMapWallOrnIndices[i] = 0;
+		_currMapFloorOrnIndices[i] = 0;
+	}
+
+	for (int i = 0; i < 18; i++)
+		_currMapDoorOrnIndices[i] = 0;
+
+	Thing _inscriptionThing = Thing::thingNone;
+}
 
 DisplayMan::~DisplayMan() {
 	delete[] _packedItemPos;
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index d8f4e29..8ed7c56 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -121,36 +121,26 @@ extern Viewport gDungeonViewport;
 #define kDoorOrnDestroyedMask 15 // @ C15_DOOR_ORNAMENT_DESTROYED_MASK
 #define kDoorOrnThivesEyeMask 16 // @ C16_DOOR_ORNAMENT_THIEVES_EYE_MASK
 
-
-
-
 class DisplayMan {
-	DMEngine *_vm = NULL;
+	DMEngine *_vm;
 	uint16 _screenWidth;
-	uint16 _screenHeight = 0;
-	byte *_vgaBuffer = NULL;
-
+	uint16 _screenHeight;
+	byte *_vgaBuffer;
 
 	/// Related to graphics.dat file
-	uint16 _grapItemCount = 0; // @ G0632_ui_GraphicCount
-	uint32 *_packedItemPos = NULL;
-	byte *_packedBitmaps = NULL;
-	byte **_bitmaps = NULL;
-
+	uint16 _grapItemCount; // @ G0632_ui_GraphicCount
+	uint32 *_packedItemPos;
+	byte *_packedBitmaps;
+	byte **_bitmaps;
 
 	// pointers 13,14 and [15-19] are owned by this array
-	byte *_wallSetBitMaps[25] = {NULL};	// @G[0696..0710]_puc_Bitmap_WallSet_...
-
-	uint16 _stairIndices[kStairsGraphicCount] = {0};
-
+	byte *_wallSetBitMaps[25];	// @G[0696..0710]_puc_Bitmap_WallSet_...
+	uint16 _stairIndices[kStairsGraphicCount];
 
 	// pointers are not owned by these fields
-	byte *_floorBitmap = NULL;
-	byte *_ceilingBitmap = NULL;
-
-
-	byte *_palChangesProjectile[4] = {NULL}; // @G0075_apuc_PaletteChanges_Projectile
-
+	byte *_floorBitmap;
+	byte *_ceilingBitmap;
+	byte *_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile
 
 	DisplayMan(const DisplayMan &other); // no implementation on purpose
 	void operator=(const DisplayMan &rhs); // no implementation on purpose
@@ -185,16 +175,14 @@ class DisplayMan {
 	bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF
 
 	// some methods use this for a stratchpad, don't make assumptions about content between function calls
-	byte *_tmpBitmap = NULL;
+	byte *_tmpBitmap;
 public:
 	DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
-	void setUpScreens(uint16 width, uint16 height);
 
+	void setUpScreens(uint16 width, uint16 height);
 	void loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader, F0460_START_InitializeGraphicData
-
 	void loadCurrentMapGraphics();
-
 	void loadPalette(uint16 *palette);
 
 	/// Gives the width of an IMG0 type item
@@ -222,20 +210,20 @@ public:
 	void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
 
-	int16 _championPortraitOrdinal = 0; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
-	int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount] = {0}; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
-	int16 _currMapFountainOrnIndices[kFountainOrnCount] = {0}; // @ G0268_ai_CurrentMapFountainOrnamentIndices
-	int16 _currMapWallOrnInfo[16][2] = {0}; // @ G0101_aai_CurrentMapWallOrnamentsInfo
-	int16 _currMapFloorOrnInfo[16][2] = {0}; // @ G0102_aai_CurrentMapFloorOrnamentsInfo
-	int16 _currMapDoorOrnInfo[17][2] = {0}; // @ G0103_aai_CurrentMapDoorOrnamentsInfo
-	byte *_currMapAllowedCreatureTypes = NULL; // @ G0264_puc_CurrentMapAllowedCreatureTypes
-	byte _currMapWallOrnIndices[16] = {0}; // @ G0261_auc_CurrentMapWallOrnamentIndices
-	byte _currMapFloorOrnIndices[16] = {0}; // @ G0262_auc_CurrentMapFloorOrnamentIndices
-	byte _currMapDoorOrnIndices[18] = {0}; // @ G0263_auc_CurrentMapDoorOrnamentIndices
+	int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
+	int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
+	int16 _currMapFountainOrnIndices[kFountainOrnCount]; // @ G0268_ai_CurrentMapFountainOrnamentIndices
+	int16 _currMapWallOrnInfo[16][2]; // @ G0101_aai_CurrentMapWallOrnamentsInfo
+	int16 _currMapFloorOrnInfo[16][2]; // @ G0102_aai_CurrentMapFloorOrnamentsInfo
+	int16 _currMapDoorOrnInfo[17][2]; // @ G0103_aai_CurrentMapDoorOrnamentsInfo
+	byte *_currMapAllowedCreatureTypes; // @ G0264_puc_CurrentMapAllowedCreatureTypes
+	byte _currMapWallOrnIndices[16]; // @ G0261_auc_CurrentMapWallOrnamentIndices
+	byte _currMapFloorOrnIndices[16]; // @ G0262_auc_CurrentMapFloorOrnamentIndices
+	byte _currMapDoorOrnIndices[18]; // @ G0263_auc_CurrentMapDoorOrnamentIndices
 
-	int16 _currMapViAltarIndex = 0; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex
+	int16 _currMapViAltarIndex; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex
 
-	Thing _inscriptionThing = Thing::thingNone; // @ G0290_T_DungeonView_InscriptionThing
+	Thing _inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing
 };
 
 }


Commit: 35677f1c82d0e47463ddb537ed894d582bf823aa
    https://github.com/scummvm/scummvm/commit/35677f1c82d0e47463ddb537ed894d582bf823aa
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix Frame initializations

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 581e4fa..d559fb9 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -66,37 +66,38 @@ enum StairFrameIndex {
 	kFrameStairsSide_D0R = 29 // @ G0139_s_Graphic558_Frame_StairsSide_D0R 
 };
 
-Frame gStairFrames[] = {{0, 79, 25, 70, 40, 46, 0, 0},
-{64, 159, 25, 70, 48, 46, 0, 0},
-{149, 223, 25, 70, 40, 46, 5, 0},
-{0, 63, 22, 83, 32, 62, 0, 0},
-{64, 159, 22, 83, 48, 62, 0, 0},
-{160, 223, 22, 83, 32, 62, 0, 0},
-{0, 31, 9, 108, 16, 100, 0, 0},
-{32, 191, 9, 108, 80, 100, 0, 0},
-{192, 223, 9, 108, 16, 100, 0, 0},
-{0, 31, 58, 101, 16, 44, 0, 0},
-{192, 223, 58, 101, 16, 44, 0, 0},
-{0, 79, 28, 68, 40, 41, 0, 0},
-{64, 159, 28, 70, 48, 43, 0, 0},
-{149, 223, 28, 68, 40, 41, 5, 0},
-{0, 63, 24, 85, 32, 62, 0, 0},
-{64, 159, 24, 85, 48, 62, 0, 0},
-{160, 223, 24, 85, 32, 62, 0, 0},
-{0, 31, 18, 108, 16, 91, 0, 0},
-{32, 191, 18, 108, 80, 91, 0, 0},
-{192, 223, 18, 108, 16, 91, 0, 0},
-{0, 31, 76, 135, 16, 60, 0, 0},
-{192, 223, 76, 135, 16, 60, 0, 0},
-{60, 75, 57, 61, 8, 5, 0, 0},
-{148, 163, 57, 61, 8, 5, 0, 0},
-{32, 63, 57, 99, 16, 43, 0, 0},
-{160, 191, 57, 99, 16, 43, 0, 0},
-{32, 63, 60, 98, 16, 39, 0, 0},
-{160, 191, 60, 98, 16, 39, 0, 0},
-{0, 15, 73, 85, 8, 13, 0, 0},
-{208, 223, 73, 85, 8, 13, 0, 0}};
-
+Frame gStairFrames[] = {
+	Frame(0, 79, 25, 70, 40, 46, 0, 0),
+	Frame(64, 159, 25, 70, 48, 46, 0, 0),
+	Frame(149, 223, 25, 70, 40, 46, 5, 0),
+	Frame(0, 63, 22, 83, 32, 62, 0, 0),
+	Frame(64, 159, 22, 83, 48, 62, 0, 0),
+	Frame(160, 223, 22, 83, 32, 62, 0, 0),
+	Frame(0, 31, 9, 108, 16, 100, 0, 0),
+	Frame(32, 191, 9, 108, 80, 100, 0, 0),
+	Frame(192, 223, 9, 108, 16, 100, 0, 0),
+	Frame(0, 31, 58, 101, 16, 44, 0, 0),
+	Frame(192, 223, 58, 101, 16, 44, 0, 0),
+	Frame(0, 79, 28, 68, 40, 41, 0, 0),
+	Frame(64, 159, 28, 70, 48, 43, 0, 0),
+	Frame(149, 223, 28, 68, 40, 41, 5, 0),
+	Frame(0, 63, 24, 85, 32, 62, 0, 0),
+	Frame(64, 159, 24, 85, 48, 62, 0, 0),
+	Frame(160, 223, 24, 85, 32, 62, 0, 0),
+	Frame(0, 31, 18, 108, 16, 91, 0, 0),
+	Frame(32, 191, 18, 108, 80, 91, 0, 0),
+	Frame(192, 223, 18, 108, 16, 91, 0, 0),
+	Frame(0, 31, 76, 135, 16, 60, 0, 0),
+	Frame(192, 223, 76, 135, 16, 60, 0, 0),
+	Frame(60, 75, 57, 61, 8, 5, 0, 0),
+	Frame(148, 163, 57, 61, 8, 5, 0, 0),
+	Frame(32, 63, 57, 99, 16, 43, 0, 0),
+	Frame(160, 191, 57, 99, 16, 43, 0, 0),
+	Frame(32, 63, 60, 98, 16, 39, 0, 0),
+	Frame(160, 191, 60, 98, 16, 39, 0, 0),
+	Frame(0, 15, 73, 85, 8, 13, 0, 0),
+	Frame(208, 223, 73, 85, 8, 13, 0, 0)
+};
 
 #define kFirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT
 #define kFirstFloorSet 75 // @ C075_GRAPHIC_FIRST_FLOOR_SET
@@ -135,23 +136,23 @@ enum ViewSquare {
 Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling
 Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor
 
-Frame gFrameWall_D3L2 = {0,  15, 25, 73, 8, 49, 0, 0}; // @ G0711_s_Graphic558_Frame_Wall_D3L2
-Frame gFrameWall_D3R2 = {208, 223, 25, 73, 8, 49, 0, 0}; // @ G0712_s_Graphic558_Frame_Wall_D3R2
+Frame gFrameWall_D3L2 = Frame(0,  15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2
+Frame gFrameWall_D3R2 = Frame(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2
 Frame gFrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls
 	/* { X1, X2, Y1, Y2, pixelWidth, Height, X, Y } */
-	{74, 149, 25,  75,  64,  51,  18, 0},   /* D3C */
-	{0,  83, 25,  75,  64,  51,  32, 0},   /* D3L */
-	{139, 223, 25,  75,  64,  51,   0, 0},   /* D3R */
-	{60, 163, 20,  90,  72,  71,  16, 0},   /* D2C */
-	{0,  74, 20,  90,  72,  71,  61, 0},   /* D2L */
-	{149, 223, 20,  90,  72,  71,   0, 0},   /* D2R */
-	{32, 191,  9, 119, 128, 111,  48, 0},   /* D1C */
-	{0,  63,  9, 119, 128, 111, 192, 0},   /* D1L */
-	{160, 223,  9, 119, 128, 111,   0, 0},   /* D1R */
-	{0, 223,  0, 135,   0,   0,   0, 0},   /* D0C */
-	{0,  31,  0, 135,  16, 136,   0, 0},   /* D0L */
-	{192, 223,  0, 135,  16, 136,   0, 0}}; /* D0R */
-
+	Frame(74, 149, 25,  75,  64,  51,  18, 0),   /* D3C */
+	Frame(0,  83, 25,  75,  64,  51,  32, 0),   /* D3L */
+	Frame(139, 223, 25,  75,  64,  51,   0, 0),   /* D3R */
+	Frame(60, 163, 20,  90,  72,  71,  16, 0),   /* D2C */
+	Frame(0,  74, 20,  90,  72,  71,  61, 0),   /* D2L */
+	Frame(149, 223, 20,  90,  72,  71,   0, 0),   /* D2R */
+	Frame(32, 191,  9, 119, 128, 111,  48, 0),   /* D1C */
+	Frame(0,  63,  9, 119, 128, 111, 192, 0),   /* D1L */
+	Frame(160, 223,  9, 119, 128, 111,   0, 0),   /* D1R */
+	Frame(0, 223,  0, 135,   0,   0,   0, 0),   /* D0C */
+	Frame(0,  31,  0, 135,  16, 136,   0, 0),   /* D0L */
+	Frame(192, 223,  0, 135,  16, 136,   0, 0)
+}; /* D0R */
 
 enum WallSetIndices {
 	kDoorFrameFront = 0, // @  G0709_puc_Bitmap_WallSet_DoorFrameFront


Commit: 442d41714023d2d128d92f15a284c5c0aa341ee4
    https://github.com/scummvm/scummvm/commit/442d41714023d2d128d92f15a284c5c0aa341ee4
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some warnings

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index bb803ab..c37467e 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -495,10 +495,6 @@ Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) {
 
 // TODO: get rid of the GOTOs
 void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) {	// complete, except where marked
-	bool leftOrnAllowed, rightOrnAllowed, frontOrnAllowed;
-	bool squareIsFakeWall;
-	bool footPrintsAllowed;
-
 	_vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75, possible fix
 
 	memset(aspectArray, 0, 5 * sizeof(uint16));
@@ -506,6 +502,12 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
 	Square square = getSquare(mapX, mapY);
 
 	aspectArray[kElemAspect] = square.getType();
+
+	bool leftOrnAllowed = false;
+	bool rightOrnAllowed = false;
+	bool frontOrnAllowed = false;
+	bool squareIsFakeWall = false;
+	bool footPrintsAllowed = false;
 	switch (square.getType()) {
 	case kWallElemType:
 		switch (dir) {
@@ -531,7 +533,6 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
 			break;
 		}
 
-		squareIsFakeWall = false;
 T0172010_ClosedFakeWall:
 		setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall);
 
@@ -775,8 +776,8 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 		uint16 codeCounter = 0;
 		int16 escChar = 0;
 		uint16 *codeWord = _dunData.textData + textString.getWordOffset();
-		uint16 code, codes;
-		char *escReplString = NULL;
+		uint16 code = 0, codes = 0;
+		char *escReplString = nullptr;
 		for (;;) { /*infinite loop*/
 			if (!codeCounter) {
 				codes = *codeWord++;


Commit: bdc57056cde5ae86d481147b3591c2ba5cd87090
    https://github.com/scummvm/scummvm/commit/bdc57056cde5ae86d481147b3591c2ba5cd87090
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Move some structs to header in gfx

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index d559fb9..1c820a9 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -10,20 +10,6 @@
 
 namespace DM {
 
-// The frames in the orignal sources contain inclusive boundaries and byte widths, not pixel widths
-struct Frame {
-	uint16 destFromX, destToX, destFromY, destToY;
-	uint16 srcWidth, srcHeight;
-	uint16 srcX, srcY;
-
-	Frame() {}
-	Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
-		  uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) :
-		destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1),
-		srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {}
-};
-
-
 enum ViewCell {
 	kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT
 	kViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT
@@ -380,25 +366,6 @@ byte gWallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoord
 	6,   /* Wall Ornament 58 Amalgam (Without Gem) */
 	7}; /* Wall Ornament 59 Lord Order (Outside) */
 
-struct CreatureAspect {
-	uint16 firstNativeBitmapRelativeIndex;
-	uint16 firstDerivedBitmapIndex;
-	byte byteWidthFront;
-	byte heightFront;
-	byte byteWidthSide;
-	byte heightSide;
-	byte byteWidthAttack;
-	byte heightAttack;
-	byte coordinateSet_TransparentColor;
-	byte replacementColorSetIndices;
-
-	byte getCoordSet() { return (coordinateSet_TransparentColor >> 4) & 0xF; } // @ M71_COORDINATE_SET
-	byte getTranspColour() { return  coordinateSet_TransparentColor & 0xF; } // @ M72_TRANSPARENT_COLOR
-	byte getReplColour10() { return (replacementColorSetIndices >> 4) & 0xF; } // @ M74_COLOR_10_REPLACEMENT_COLOR_SET
-	byte getReplColour9() { return replacementColorSetIndices & 0xF; } // @ M73_COLOR_09_REPLACEMENT_COLOR_SET
-}; // @ CREATURE_ASPECT
-
-
 CreatureAspect gCreatureAspects[kCreatureTypeCount] = { // @ G0219_as_Graphic558_CreatureAspects
 /* { FirstNativeBitmapRelativeIndex, FirstDerivedBitmapIndex, pixelWidthFront, HeightFront,
 pixelWidthSide, HeightSide, pixelWidthAttack, HeightAttack, CoordinateSet / TransparentColor,
@@ -431,18 +398,6 @@ Replacement Color Set Index for color 10 / Replacement Color Set Index for color
 	{85, 0, 32 * 2,  93,  0 * 2,   0,  0 * 2,   0, 0x04, 0xCB},   /* Creature #25 Lord Order */
 	{86, 0, 32 * 2,  93,  0 * 2,   0,  0 * 2,   0, 0x04, 0xCB}}; /* Creature #26 Grey Lord */
 
-struct ObjectAspect {
-	byte firstNativeBitmapRelativeIndex;
-	byte firstDerivedBitmapRelativeIndex;
-	byte width;
-	byte height;
-	byte graphicInfo; /* Bits 7-5 and 3-1 Unreferenced */
-	byte coordinateSet;
-	ObjectAspect(byte firstN, byte firstD, byte byteWidth, byte h, byte grap, byte coord) :
-		firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD),
-		width(byteWidth * 2), height(h), graphicInfo(grap), coordinateSet(coord) {}
-}; // @ OBJECT_ASPECT
-
 ObjectAspect gObjectAspects[kObjAspectCount] = { // @ G0209_as_Graphic558_ObjectAspects
 	/* FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo, CoordinateSet */
 	ObjectAspect(0,   0, 24, 27, 0x11, 0),
@@ -529,20 +484,8 @@ ObjectAspect gObjectAspects[kObjAspectCount] = { // @ G0209_as_Graphic558_Object
 	ObjectAspect(82, 170, 24, 28, 0x00, 0),
 	ObjectAspect(83, 172, 40, 13, 0x00, 1),
 	ObjectAspect(84, 174,  8,  4, 0x00, 1),
-	ObjectAspect(85, 176, 32, 17, 0x00, 0)};
-
-struct ProjectileAspect {
-	byte firstNativeBitmapRelativeIndex;
-	byte firstDerivedBitmapRelativeIndex;
-	byte width;
-	byte height;
-	uint16 graphicInfo; /* Bits 15-9, 7-5 and 3-2 Unreferenced */
-
-	ProjectileAspect(byte firstN, byte firstD, byte byteWidth, byte h, uint16 grap) :
-		firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD),
-		width(byteWidth * 2), height(h), graphicInfo(grap) {}
-}; // @ PROJECTIL_ASPECT
-
+	ObjectAspect(85, 176, 32, 17, 0x00, 0)
+};
 
 ProjectileAspect gProjectileAspect[kProjectileAspectCount] = { // @ G0210_as_Graphic558_ProjectileAspects
 	/* ProjectileAspect( FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo ) */
@@ -562,7 +505,6 @@ ProjectileAspect gProjectileAspect[kProjectileAspectCount] = { // @ G0210_as_Gra
 	ProjectileAspect(31, 156, 16, 24, 0x0103) /* Explosion Poison Bolt Poison Cloud */
 };
 
-
 // TODO: this is ONLY for the Amiga version, name will have to be refactored
 
 /* Identical to the palette at the end of the swoosh palette animation */
@@ -584,14 +526,8 @@ uint16 gPalDungeonView[6][16] = { // @ G0021_aaui_Graphic562_Palette_DungeonView
 	/* Atari ST: { 0x000, 0x000, 0x000, 0x000, 0x066, 0x100, 0x000, 0x020, 0x300, 0x310, 0x200, 0x530, 0x000, 0x111, 0x003, 0x333 }, RGB colors are different */
 	0x000, 0x000, 0x000, 0x000, 0x0CC, 0x200, 0x000, 0x040, 0x600, 0x000, 0x000, 0xA60, 0x000, 0x222, 0x006, 0x666,
 	/* Atari ST: { 0x000, 0x000, 0x000, 0x000, 0x066, 0x000, 0x000, 0x010, 0x200, 0x200, 0x100, 0x320, 0x000, 0x000, 0x002, 0x222 }, RGB colors are different */
-	0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444};
-
-
-struct CreatureReplColorSet {
-	uint16 RGBColor[6];
-	byte D2ReplacementColor;
-	byte D3ReplacementColor;
-}; // @ CREATURE_REPLACEMENT_COLOR_SET
+	0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444
+};
 
 CreatureReplColorSet gCreatureReplColorSets[13] = { // @ G0220_as_Graphic558_CreatureReplacementColorSets
 	/* { Color, Color, Color, Color, Color, Color, D2 replacement color index (x10), D3 replacement color index (x10) } */
@@ -612,7 +548,6 @@ CreatureReplColorSet gCreatureReplColorSets[13] = { // @ G0220_as_Graphic558_Cre
 byte gPalChangesCreature_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 0, 0, 110, 0, 20, 0, 130}; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3
 byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, 120, 130, 140, 150}; // @ G0222_auc_Graphic558_PaletteChanges_Creature_D2
 
-
 enum GraphicIndice {
 	kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT
 	kDoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
@@ -620,7 +555,6 @@ enum GraphicIndice {
 };
 
 
-
 Viewport gDefultViewPort = {0, 0};
 // TODO: I guessed the numbers
 Viewport gDungeonViewport = {0, 64}; // @ G0296_puc_Bitmap_Viewport
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 8ed7c56..bbd2b19 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -12,8 +12,6 @@ extern uint16 gPalCredits[16];
 extern uint16 gPalEntrance[16];
 extern uint16 gPalDungeonView[6][16];
 
-
-
 typedef struct {
 	uint16 X1;
 	uint16 X2;
@@ -21,7 +19,19 @@ typedef struct {
 	uint16 Y2;
 } Box; // @ BOX_BYTE, BOX_WORD
 
-struct Frame;
+// The frames in the original sources contain inclusive boundaries and byte widths, not pixel widths
+struct Frame {
+	uint16 destFromX, destToX, destFromY, destToY;
+	uint16 srcWidth, srcHeight;
+	uint16 srcX, srcY;
+
+	Frame() {}
+	Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
+		uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) :
+	destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1),
+		srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {}
+};
+
 enum WallSet {
 	kWallSetStone = 0 // @ C0_WALL_SET_STONE
 };
@@ -67,8 +77,6 @@ enum ViewWall {
 	kViewWall_D1C_FRONT = 12  // @ C12_VIEW_WALL_D1C_FRONT
 };
 
-
-
 enum Color {
 	kColorNoTransparency = 255,
 	kColorBlack = 0,
@@ -89,16 +97,62 @@ enum Color {
 	kColorWhite = 15
 };
 
-
 struct Viewport {
 	// TODO: should probably add width and height, seems redundant right meow
 	uint16 posX, posY;
 };
 
+struct CreatureAspect {
+	uint16 firstNativeBitmapRelativeIndex;
+	uint16 firstDerivedBitmapIndex;
+	byte byteWidthFront;
+	byte heightFront;
+	byte byteWidthSide;
+	byte heightSide;
+	byte byteWidthAttack;
+	byte heightAttack;
+	byte coordinateSet_TransparentColor;
+	byte replacementColorSetIndices;
+
+	byte getCoordSet() { return (coordinateSet_TransparentColor >> 4) & 0xF; } // @ M71_COORDINATE_SET
+	byte getTranspColour() { return  coordinateSet_TransparentColor & 0xF; } // @ M72_TRANSPARENT_COLOR
+	byte getReplColour10() { return (replacementColorSetIndices >> 4) & 0xF; } // @ M74_COLOR_10_REPLACEMENT_COLOR_SET
+	byte getReplColour9() { return replacementColorSetIndices & 0xF; } // @ M73_COLOR_09_REPLACEMENT_COLOR_SET
+}; // @ CREATURE_ASPECT
+
+struct ObjectAspect {
+	byte firstNativeBitmapRelativeIndex;
+	byte firstDerivedBitmapRelativeIndex;
+	byte width;
+	byte height;
+	byte graphicInfo; /* Bits 7-5 and 3-1 Unreferenced */
+	byte coordinateSet;
+	ObjectAspect(byte firstN, byte firstD, byte byteWidth, byte h, byte grap, byte coord) :
+	firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD),
+		width(byteWidth * 2), height(h), graphicInfo(grap), coordinateSet(coord) {}
+}; // @ OBJECT_ASPECT
+
+struct ProjectileAspect {
+	byte firstNativeBitmapRelativeIndex;
+	byte firstDerivedBitmapRelativeIndex;
+	byte width;
+	byte height;
+	uint16 graphicInfo; /* Bits 15-9, 7-5 and 3-2 Unreferenced */
+
+	ProjectileAspect(byte firstN, byte firstD, byte byteWidth, byte h, uint16 grap) :
+	firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD),
+		width(byteWidth * 2), height(h), graphicInfo(grap) {}
+}; // @ PROJECTIL_ASPECT
+
+struct CreatureReplColorSet {
+	uint16 RGBColor[6];
+	byte D2ReplacementColor;
+	byte D3ReplacementColor;
+}; // @ CREATURE_REPLACEMENT_COLOR_SET
+
 extern Viewport gDefultViewPort;
 extern Viewport gDungeonViewport;
 
-
 #define kAlcoveOrnCount 3
 #define kFountainOrnCount 1
 
@@ -114,7 +168,6 @@ extern Viewport gDungeonViewport;
 #define kObjAspectCount 85 // @ C085_OBJECT_ASPECT_COUNT
 #define kProjectileAspectCount 14 // @ C014_PROJECTILE_ASPECT_COUNT
 
-
 #define kDoorButton 0 // @ C0_DOOR_BUTTON
 #define kWallOrnInscription 0 // @ C0_WALL_ORNAMENT_INSCRIPTION
 #define kFloorOrnFootprints 15 // @ C15_FLOOR_ORNAMENT_FOOTPRINTS


Commit: 6ffca3a7dbf06227cadb791ca73ca99158f87ce0
    https://github.com/scummvm/scummvm/commit/6ffca3a7dbf06227cadb791ca73ca99158f87ce0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Forgot to commit these lines earlier

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index c37467e..0563649 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -497,7 +497,9 @@ Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) {
 void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) {	// complete, except where marked
 	_vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75, possible fix
 
-	memset(aspectArray, 0, 5 * sizeof(uint16));
+	for (uint16 i = 0; i < 5; ++i)
+		aspectArray[i] = 0;
+
 	Thing thing = getSquareFirstThing(mapX, mapY);
 	Square square = getSquare(mapX, mapY);
 
@@ -560,11 +562,13 @@ T0172010_ClosedFakeWall:
 		}
 		break;
 	case kPitElemType:
-		if (square.get(kPitOpen))
+		if (square.get(kPitOpen)) {
 			aspectArray[kPitInvisibleAspect] = square.get(kPitInvisible);
-		else
+			footPrintsAllowed = square.toByte() & 1;
+		} else {
 			aspectArray[kElemAspect] = kCorridorElemType;
-		footPrintsAllowed = true;
+			footPrintsAllowed = true;
+		}
 		goto T0172030_Pit;
 	case kFakeWallElemType:
 		if (!square.get(kFakeWallOpen)) {
@@ -575,6 +579,7 @@ T0172010_ClosedFakeWall:
 		}
 		aspectArray[kWallElemType] = kCorridorElemType;
 		footPrintsAllowed = square.get(kFakeWallRandOrnOrFootPAllowed);
+		square = footPrintsAllowed ? 8 : 0;
 		// intentional fallthrough
 	case kCorridorElemType:
 		aspectArray[kFloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(kCorridorRandOrnAllowed), _currMap.map->randFloorOrnCount, mapX, mapY, 30);
@@ -608,6 +613,7 @@ T0172046_Stairs:
 		while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType))
 			thing = getNextThing(thing);
 T0172049_Footprints:
+		unsigned char scentOrdinal; // see next line comment
 		if (footPrintsAllowed) // TODO: I skipped some party query code, must come back later and complete
 			aspectArray[kFloorOrnOrdAspect] &= kFootprintsAspect;
 	}


Commit: 3ca7622a6ca4563f7c906013d59f9213a55f4c1b
    https://github.com/scummvm/scummvm/commit/3ca7622a6ca4563f7c906013d59f9213a55f4c1b
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix wrong MemoryReadStream size when loading dungeon.dat

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 0563649..dd73e24 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -230,7 +230,7 @@ void DungeonMan::loadDungeonFile() {
 	if (_messages.newGame)
 		decompressDungeonFile();
 
-	Common::MemoryReadStream dunDataStream(_rawDunFileData, _fileHeader.rawMapDataSize, DisposeAfterUse::NO);
+	Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO);
 
 	// initialize _fileHeader
 	_fileHeader.dungeonId = _fileHeader.ornamentRandomSeed = dunDataStream.readUint16BE();


Commit: ad8fbaa118e26cb57d3d77ddb7a597c2b37a9f76
    https://github.com/scummvm/scummvm/commit/ad8fbaa118e26cb57d3d77ddb7a597c2b37a9f76
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add event manager

Changed paths:
  A engines/dm/eventman.cpp
  A engines/dm/eventman.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/module.mk



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 0aa4cb3..df6629c 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -50,6 +50,7 @@ DMEngine::~DMEngine() {
 	delete _console;
 	delete _displayMan;
 	delete _dungeonMan;
+	delete _eventMan;
 
 	// clear debug channels
 	DebugMan.clearAllDebugChannels();
@@ -61,6 +62,7 @@ Common::Error DMEngine::run() {
 	_console = new Console(this);
 	_displayMan = new DisplayMan(this);
 	_dungeonMan = new DungeonMan(this);
+	_eventMan = new EventManager(this);
 
 	_displayMan->setUpScreens(320, 200);
 
@@ -77,40 +79,10 @@ Common::Error DMEngine::run() {
 
 	_displayMan->loadPalette(gPalCredits);
 
-	CurrMapData &currMap = _dungeonMan->_currMap;
+	_eventMan->initMouse();
+
 	while (true) {
-		Common::Event event;
-		while (_system->getEventManager()->pollEvent(event)) {
-			if (event.type == Common::EVENT_KEYDOWN && !event.synthetic)
-				switch (event.kbd.keycode) {
-				case Common::KEYCODE_w:
-					_dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY);
-					break;
-				case Common::KEYCODE_a:
-					_dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, 0, -1, currMap.partyPosX, currMap.partyPosY);
-					break;
-				case Common::KEYCODE_s:
-					_dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, -1, 0, currMap.partyPosX, currMap.partyPosY);
-					break;
-				case Common::KEYCODE_d:
-					_dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, 0, 1, currMap.partyPosX, currMap.partyPosY);
-					break;
-				case Common::KEYCODE_q:
-					turnDirLeft(currMap.partyDir);
-					break;
-				case Common::KEYCODE_e:
-					turnDirRight(currMap.partyDir);
-					break;
-				case Common::KEYCODE_UP:
-					if (dummyMapIndex < 13)
-						_dungeonMan->setCurrentMapAndPartyMap(++dummyMapIndex);
-					break;
-				case Common::KEYCODE_DOWN:
-					if (dummyMapIndex > 0)
-						_dungeonMan->setCurrentMapAndPartyMap(--dummyMapIndex);
-					break;
-				}
-		}
+		_eventMan->processInput();
 		_displayMan->clearScreen(kColorBlack);
 		_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY);
 		_displayMan->updateScreen();
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 817c3ec..b77f2cc 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -4,6 +4,7 @@
 #include "common/random.h"
 #include "engines/engine.h"
 #include "gui/debugger.h"
+#include "eventman.h"
 
 
 namespace DM {
@@ -87,6 +88,7 @@ public:
 	Common::RandomSource *_rnd;
 	DisplayMan *_displayMan;
 	DungeonMan *_dungeonMan;
+	EventManager *_eventMan;
 };
 
 class Console : public GUI::Debugger {
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
new file mode 100644
index 0000000..44ea327
--- /dev/null
+++ b/engines/dm/eventman.cpp
@@ -0,0 +1,68 @@
+#include "eventman.h"
+#include "dm.h"
+#include "common/system.h"
+#include "dungeonman.h"
+
+
+
+using namespace DM;
+
+
+EventManager::EventManager(DMEngine *vm) : _vm(vm) {}
+
+
+void EventManager::initMouse() {
+	_mousePos = Common::Point(0, 0);
+	_dummyMapIndex = 0;				
+	// TODO: add cursor creatin, set to hidden
+}
+
+void showMouse(bool visibility) {
+	// TODO: add code
+}
+
+void EventManager::setMousePos(Common::Point pos) {
+	_vm->_system->warpMouse(pos.x, pos.y);
+}
+
+
+void EventManager::processInput() {
+	DungeonMan &dungeonMan = *_vm->_dungeonMan;
+	CurrMapData &currMap = dungeonMan._currMap;
+
+	Common::Event event;
+	while (_vm->_system->getEventManager()->pollEvent(event)) {
+		if (event.type == Common::EVENT_KEYDOWN && !event.synthetic) {
+			switch (event.kbd.keycode) {
+			case Common::KEYCODE_w:
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY);
+				break;
+			case Common::KEYCODE_a:
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, -1, currMap.partyPosX, currMap.partyPosY);
+				break;
+			case Common::KEYCODE_s:
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, -1, 0, currMap.partyPosX, currMap.partyPosY);
+				break;
+			case Common::KEYCODE_d:
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, 1, currMap.partyPosX, currMap.partyPosY);
+				break;
+			case Common::KEYCODE_q:
+				turnDirLeft(currMap.partyDir);
+				break;
+			case Common::KEYCODE_e:
+				turnDirRight(currMap.partyDir);
+				break;
+			case Common::KEYCODE_UP:
+				if (_dummyMapIndex < 13)
+					dungeonMan.setCurrentMapAndPartyMap(++_dummyMapIndex);
+				break;
+			case Common::KEYCODE_DOWN:
+				if (_dummyMapIndex > 0)
+					dungeonMan.setCurrentMapAndPartyMap(--_dummyMapIndex);
+				break;
+			}
+		} else if (event.type == Common::EVENT_MOUSEMOVE) {
+			_mousePos = event.mouse;
+		}
+	}
+}
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
new file mode 100644
index 0000000..eabff49
--- /dev/null
+++ b/engines/dm/eventman.h
@@ -0,0 +1,28 @@
+
+
+#ifndef DM_EVENTMAN_H
+#define DM_EVENTMAN_H
+
+#include "common/events.h"
+
+namespace DM {
+
+class DMEngine;
+
+class EventManager {
+	DMEngine *_vm;
+
+	Common::Point _mousePos;
+	uint16 _dummyMapIndex;
+public:
+	EventManager(DMEngine *vm);
+	void initMouse();
+
+	void setMousePos(Common::Point pos);
+	void processInput();
+};
+
+};
+
+
+#endif DM_EVENTMAN_H
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index ca425c5..3078fa5 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -4,7 +4,8 @@ MODULE_OBJS := \
 	detection.o \
 	dm.o \
 	gfx.o \
-	dungeonman.o
+	dungeonman.o \
+	eventman.o
 
 MODULE_DIRS += \
 	engines/dm


Commit: de3bb231d703a5f19c21e643f19506a27ab53255
    https://github.com/scummvm/scummvm/commit/de3bb231d703a5f19c21e643f19506a27ab53255
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add dummy cursor display

Changed paths:
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/eventman.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index df6629c..a86e785 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -80,6 +80,7 @@ Common::Error DMEngine::run() {
 	_displayMan->loadPalette(gPalCredits);
 
 	_eventMan->initMouse();
+	_eventMan->showMouse(true);
 
 	while (true) {
 		_eventMan->processInput();
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 44ea327..96a6bf5 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -2,23 +2,52 @@
 #include "dm.h"
 #include "common/system.h"
 #include "dungeonman.h"
+#include "graphics/cursorman.h"
+#include "gfx.h"
 
 
 
 using namespace DM;
 
 
-EventManager::EventManager(DMEngine *vm) : _vm(vm) {}
+EventManager::EventManager(DMEngine *vm) : _vm(vm) {
+	_dummyMapIndex = 0;				
+}
+
+
+// dummy data
+static const byte mouseData[] = {
+	1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
+	1, 7, 1, 0, 0, 0, 0, 0, 0, 0,
+	1, 7, 7, 1, 0, 0, 0, 0, 0, 0,
+	1, 7, 7, 7, 1, 0, 0, 0, 0, 0,
+	1, 7, 7, 7, 7, 1, 0, 0, 0, 0,
+	1, 7, 7, 7, 7, 7, 1, 0, 0, 0,
+	1, 7, 7, 7, 7, 7, 7, 1, 0, 0,
+	1, 7, 7, 7, 7, 7, 7, 7, 1, 0,
+	1, 7, 7, 7, 7, 7, 1, 1, 1, 1,
+	1, 7, 7, 1, 7, 7, 1, 0, 0, 0,
+	1, 7, 1, 0, 1, 7, 7, 1, 0, 0,
+	1, 1, 0, 0, 1, 7, 7, 1, 0, 0,
+	0, 0, 0, 0, 0, 1, 7, 7, 1, 0,
+	0, 0, 0, 0, 0, 1, 7, 7, 1, 0,
+	0, 0, 0, 0, 0, 0, 1, 1, 0, 0
+};
+#define MOUSE_WIDTH 10
+#define MOUSE_HEIGHT 15
 
 
 void EventManager::initMouse() {
 	_mousePos = Common::Point(0, 0);
-	_dummyMapIndex = 0;				
+	CursorMan.pushCursor(mouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
+	CursorMan.showMouse(false);
+
+	setMousePos(Common::Point(320/2, 200/2));
 	// TODO: add cursor creatin, set to hidden
 }
 
-void showMouse(bool visibility) {
-	// TODO: add code
+void EventManager::showMouse(bool visibility) {
+	CursorMan.showMouse(visibility);
 }
 
 void EventManager::setMousePos(Common::Point pos) {
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index eabff49..ccce4c4 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -17,12 +17,13 @@ class EventManager {
 public:
 	EventManager(DMEngine *vm);
 	void initMouse();
+	void showMouse(bool visibility);
 
 	void setMousePos(Common::Point pos);
 	void processInput();
 };
 
-};
+}
 
 
 #endif DM_EVENTMAN_H


Commit: 251768b883737a729b25b003fd531f40ccf6fe91
    https://github.com/scummvm/scummvm/commit/251768b883737a729b25b003fd531f40ccf6fe91
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add commands

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index a86e785..002068a 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -12,8 +12,9 @@
 #include "common/events.h"
 
 #include "dm/dm.h"
-#include "dm/gfx.h"
-#include "dm/dungeonman.h"
+#include "gfx.h"
+#include "dungeonman.h"
+#include "eventman.h"
 
 namespace DM {
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index b77f2cc..c381587 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -4,7 +4,6 @@
 #include "common/random.h"
 #include "engines/engine.h"
 #include "gui/debugger.h"
-#include "eventman.h"
 
 
 namespace DM {
@@ -12,6 +11,7 @@ namespace DM {
 class Console;
 class DisplayMan;
 class DungeonMan;
+class EventManager;
 
 
 enum direction {
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index dd73e24..efff5ff 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1,8 +1,6 @@
-#include "dungeonman.h"
-#include "gfx.h"
 #include "common/file.h"
 #include "common/memstream.h"
-
+#include "dungeonman.h"
 
 
 using namespace DM;
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 7652596..9326156 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -2,12 +2,12 @@
 #define DUNGEONMAN_H
 
 #include "dm.h"
+#include "dungeonman.h"
 #include "gfx.h"
 
+
 namespace DM {
 
-class DungeonMan;
-struct Map;
 
 int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
 int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
@@ -458,7 +458,7 @@ public:
 	bool _isFacingFountain; // @ G0288_B_FacingFountain
 };
 
-}
+};
 
 
 #endif
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 96a6bf5..860ea06 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1,9 +1,8 @@
-#include "eventman.h"
-#include "dm.h"
 #include "common/system.h"
-#include "dungeonman.h"
 #include "graphics/cursorman.h"
-#include "gfx.h"
+
+#include "eventman.h"
+#include "dungeonman.h"
 
 
 
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index ccce4c4..cf34636 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -1,12 +1,148 @@
-
-
 #ifndef DM_EVENTMAN_H
 #define DM_EVENTMAN_H
 
 #include "common/events.h"
+#include "gfx.h"
+
 
 namespace DM {
 
+enum MouseButton {
+	kLeftMouseButton,
+	kRightMouseButton
+};
+
+enum CommandType {
+	kCommandNone = 0, // @ C000_COMMAND_NONE
+	kCommandTurnLeft = 1, // @ C001_COMMAND_TURN_LEFT
+	kCommandTurnRight = 2, // @ C002_COMMAND_TURN_RIGHT
+	kCommandMoveForward = 3, // @ C003_COMMAND_MOVE_FORWARD
+	kCommandMoveRight = 4, // @ C004_COMMAND_MOVE_RIGHT
+	kCommandMoveBackward = 5, // @ C005_COMMAND_MOVE_BACKWARD
+	kCommandMoveLeft = 6, // @ C006_COMMAND_MOVE_LEFT
+	kCommandToggleInventoryChampion_0 = 7, // @ C007_COMMAND_TOGGLE_INVENTORY_CHAMPION_0
+	kCommandToggleInventoryChampion_1 = 8, // @ C008_COMMAND_TOGGLE_INVENTORY_CHAMPION_1
+	kCommandToggleInventoryChampion_2 = 9, // @ C009_COMMAND_TOGGLE_INVENTORY_CHAMPION_2
+	kCommandToggleInventoryChampion_3 = 10, // @ C010_COMMAND_TOGGLE_INVENTORY_CHAMPION_3
+	kCommandCloseInventory = 11, // @ C011_COMMAND_CLOSE_INVENTORY
+	kCommandClickInChampion_0_StatusBox = 12, // @ C012_COMMAND_CLICK_IN_CHAMPION_0_STATUS_BOX
+	kCommandClickInChampion_1_StatusBox = 13, // @ C013_COMMAND_CLICK_IN_CHAMPION_1_STATUS_BOX
+	kCommandClickInChampion_2_StatusBox = 14, // @ C014_COMMAND_CLICK_IN_CHAMPION_2_STATUS_BOX
+	kCommandClickInChampion_3_StatusBox = 15, // @ C015_COMMAND_CLICK_IN_CHAMPION_3_STATUS_BOX
+	kCommandSetLeaderChampion_0 = 16, // @ C016_COMMAND_SET_LEADER_CHAMPION_0
+	kCommandSetLeaderChampion_1 = 17, // @ C017_COMMAND_SET_LEADER_CHAMPION_1
+	kCommandSetLeaderChampion_2 = 18, // @ C018_COMMAND_SET_LEADER_CHAMPION_2
+	kCommandSetLeaderChampion_3 = 19, // @ C019_COMMAND_SET_LEADER_CHAMPION_3
+	kCommandClickOnSlotBoxChampion_0_StatusBoxReadyHand = 20, // @ C020_COMMAND_CLICK_ON_SLOT_BOX_00_CHAMPION_0_STATUS_BOX_READY_HAND
+	kCommandClickOnSlotBoxChampion_0_StatusBoxActionHand = 21, // @ C021_COMMAND_CLICK_ON_SLOT_BOX_01_CHAMPION_0_STATUS_BOX_ACTION_HAND
+	kCommandClickOnSlotBoxChampion_1_StatusBoxReadyHand = 22, // @ C022_COMMAND_CLICK_ON_SLOT_BOX_02_CHAMPION_1_STATUS_BOX_READY_HAND
+	kCommandClickOnSlotBoxChampion_1_StatusBoxAactionHand = 23, // @ C023_COMMAND_CLICK_ON_SLOT_BOX_03_CHAMPION_1_STATUS_BOX_ACTION_HAND
+	kCommandClickOnSlotBoxChampion_2_StatusBoxReadyHand = 24, // @ C024_COMMAND_CLICK_ON_SLOT_BOX_04_CHAMPION_2_STATUS_BOX_READY_HAND
+	kCommandClickOnSlotBoxChampion_2_StatusBoxActionHand = 25, // @ C025_COMMAND_CLICK_ON_SLOT_BOX_05_CHAMPION_2_STATUS_BOX_ACTION_HAND
+	kCommandClickOnSlotBoxChampion_3_StatusBoxReadyHand = 26, // @ C026_COMMAND_CLICK_ON_SLOT_BOX_06_CHAMPION_3_STATUS_BOX_READY_HAND
+	kCommandClickOnSlotBoxChampion_3_StatusBoxActionHand = 27, // @ C027_COMMAND_CLICK_ON_SLOT_BOX_07_CHAMPION_3_STATUS_BOX_ACTION_HAND
+	kCommandClickOnSlotBoxInventoryReadyHand = 28, // @ C028_COMMAND_CLICK_ON_SLOT_BOX_08_INVENTORY_READY_HAND
+	kCommandClickOnSlotBoxInventoryActionHand = 29, // @ C029_COMMAND_CLICK_ON_SLOT_BOX_09_INVENTORY_ACTION_HAND
+	kCommandClickOnSlotBoxInventoryHead = 30, // @ C030_COMMAND_CLICK_ON_SLOT_BOX_10_INVENTORY_HEAD
+	kCommandClickOnSlotBoxInventoryTorso = 31, // @ C031_COMMAND_CLICK_ON_SLOT_BOX_11_INVENTORY_TORSO
+	kCommandClickOnSlotBoxInventoryLegs = 32, // @ C032_COMMAND_CLICK_ON_SLOT_BOX_12_INVENTORY_LEGS
+	kCommandClickOnSlotBoxInventoryFeet = 33, // @ C033_COMMAND_CLICK_ON_SLOT_BOX_13_INVENTORY_FEET
+	kCommandClickOnSlotBoxInventoryPouch_2 = 34, // @ C034_COMMAND_CLICK_ON_SLOT_BOX_14_INVENTORY_POUCH_2
+	kCommandClickOnSlotBoxInventoryQuiverLine_2_1 = 35, // @ C035_COMMAND_CLICK_ON_SLOT_BOX_15_INVENTORY_QUIVER_LINE2_1
+	kCommandClickOnSlotBoxInventoryQuiverLine_1_2 = 36, // @ C036_COMMAND_CLICK_ON_SLOT_BOX_16_INVENTORY_QUIVER_LINE1_2
+	kCommandClickOnSlotBoxInventoryQuiverLine_2_2 = 37, // @ C037_COMMAND_CLICK_ON_SLOT_BOX_17_INVENTORY_QUIVER_LINE2_2
+	kCommandClickOnSlotBoxInventoryNeck = 38, // @ C038_COMMAND_CLICK_ON_SLOT_BOX_18_INVENTORY_NECK
+	kCommandClickOnSlotBoxInventoryPouch_1 = 39, // @ C039_COMMAND_CLICK_ON_SLOT_BOX_19_INVENTORY_POUCH_1
+	kCommandClickOnSlotBoxInventoryQuiverLine_1_1 = 40, // @ C040_COMMAND_CLICK_ON_SLOT_BOX_20_INVENTORY_QUIVER_LINE1_1
+	kCommandClickOnSlotBoxInventoryBackpackLine_1_1 = 41, // @ C041_COMMAND_CLICK_ON_SLOT_BOX_21_INVENTORY_BACKPACK_LINE1_1
+	kCommandClickOnSlotBoxInventoryBackpackLine_2_2 = 42, // @ C042_COMMAND_CLICK_ON_SLOT_BOX_22_INVENTORY_BACKPACK_LINE2_2
+	kCommandClickOnSlotBoxInventoryBackpackLine_2_3 = 43, // @ C043_COMMAND_CLICK_ON_SLOT_BOX_23_INVENTORY_BACKPACK_LINE2_3
+	kCommandClickOnSlotBoxInventoryBackpackLine_2_4 = 44, // @ C044_COMMAND_CLICK_ON_SLOT_BOX_24_INVENTORY_BACKPACK_LINE2_4
+	kCommandClickOnSlotBoxInventoryBackpackLine_2_5 = 45, // @ C045_COMMAND_CLICK_ON_SLOT_BOX_25_INVENTORY_BACKPACK_LINE2_5
+	kCommandClickOnSlotBoxInventoryBackpackLine_2_6 = 46, // @ C046_COMMAND_CLICK_ON_SLOT_BOX_26_INVENTORY_BACKPACK_LINE2_6
+	kCommandClickOnSlotBoxInventoryBackpackLine_2_7 = 47, // @ C047_COMMAND_CLICK_ON_SLOT_BOX_27_INVENTORY_BACKPACK_LINE2_7
+	kCommandClickOnSlotBoxInventoryBackpackLine_2_8 = 48, // @ C048_COMMAND_CLICK_ON_SLOT_BOX_28_INVENTORY_BACKPACK_LINE2_8
+	kCommandClickOnSlotBoxInventoryBackpackLine_2_9 = 49, // @ C049_COMMAND_CLICK_ON_SLOT_BOX_29_INVENTORY_BACKPACK_LINE2_9
+	kCommandClickOnSlotBoxInventoryBackpackLine_1_2 = 50, // @ C050_COMMAND_CLICK_ON_SLOT_BOX_30_INVENTORY_BACKPACK_LINE1_2
+	kCommandClickOnSlotBoxInventoryBackpackLine_1_3 = 51, // @ C051_COMMAND_CLICK_ON_SLOT_BOX_31_INVENTORY_BACKPACK_LINE1_3
+	kCommandClickOnSlotBoxInventoryBackpackLine_1_4 = 52, // @ C052_COMMAND_CLICK_ON_SLOT_BOX_32_INVENTORY_BACKPACK_LINE1_4
+	kCommandClickOnSlotBoxInventoryBackpackLine_1_5 = 53, // @ C053_COMMAND_CLICK_ON_SLOT_BOX_33_INVENTORY_BACKPACK_LINE1_5
+	kCommandClickOnSlotBoxInventoryBackpackLine_1_6 = 54, // @ C054_COMMAND_CLICK_ON_SLOT_BOX_34_INVENTORY_BACKPACK_LINE1_6
+	kCommandClickOnSlotBoxInventoryBackpackLine_1_7 = 55, // @ C055_COMMAND_CLICK_ON_SLOT_BOX_35_INVENTORY_BACKPACK_LINE1_7
+	kCommandClickOnSlotBoxInventoryBackpackLine_1_8 = 56, // @ C056_COMMAND_CLICK_ON_SLOT_BOX_36_INVENTORY_BACKPACK_LINE1_8
+	kCommandClickOnSlotBoxInventoryBackpackLine_1_9 = 57, // @ C057_COMMAND_CLICK_ON_SLOT_BOX_37_INVENTORY_BACKPACK_LINE1_9
+	kCommandClickOnSlotBoxChest_1 = 58, // @ C058_COMMAND_CLICK_ON_SLOT_BOX_38_CHEST_1
+	kCommandClickOnSlotBoxChest_2 = 59, // @ C059_COMMAND_CLICK_ON_SLOT_BOX_39_CHEST_2
+	kCommandClickOnSlotBoxChest_3 = 60, // @ C060_COMMAND_CLICK_ON_SLOT_BOX_40_CHEST_3
+	kCommandClickOnSlotBoxChest_4 = 61, // @ C061_COMMAND_CLICK_ON_SLOT_BOX_41_CHEST_4
+	kCommandClickOnSlotBoxChest_5 = 62, // @ C062_COMMAND_CLICK_ON_SLOT_BOX_42_CHEST_5
+	kCommandClickOnSlotBoxChest_6 = 63, // @ C063_COMMAND_CLICK_ON_SLOT_BOX_43_CHEST_6
+	kCommandClickOnSlotBoxChest_7 = 64, // @ C064_COMMAND_CLICK_ON_SLOT_BOX_44_CHEST_7
+	kCommandClickOnSlotBoxChest_8 = 65, // @ C065_COMMAND_CLICK_ON_SLOT_BOX_45_CHEST_8
+	kCommandClickOnMouth = 70, // @ C070_COMMAND_CLICK_ON_MOUTH
+	kCommandClickOnEye = 71, // @ C071_COMMAND_CLICK_ON_EYE
+	kCommandClickInDungeonView = 80, // @ C080_COMMAND_CLICK_IN_DUNGEON_VIEW
+	kCommandClickInPanel = 81, // @ C081_COMMAND_CLICK_IN_PANEL
+	kCommandToggleInventoryLeader = 83, // @ C083_COMMAND_TOGGLE_INVENTORY_LEADER
+	kCommandClickInSpellArea = 100, // @ C100_COMMAND_CLICK_IN_SPELL_AREA
+	kCommandClickInSpellAreaSymbol_1 = 101, // @ C101_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_1
+	kCommandClickInSpellAreaSymbol_2 = 102, // @ C102_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_2
+	kCommandClickInSpellAreaSymbol_3 = 103, // @ C103_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_3
+	kCommandClickInSpellAreaSymbol_4 = 104, // @ C104_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_4
+	kCommandClickInSpellAreaSymbol_5 = 105, // @ C105_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_5
+	kCommandClickInSpellAreaSymbol_6 = 106, // @ C106_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_6
+	kCommandClickInSpellAreaRecantSymbol = 107, // @ C107_COMMAND_CLICK_IN_SPELL_AREA_RECANT_SYMBOL
+	kCommandClickInSpeallAreaCastSpell = 108, // @ C108_COMMAND_CLICK_IN_SPELL_AREA_CAST_SPELL
+	kCommandClickInActionArea = 111, // @ C111_COMMAND_CLICK_IN_ACTION_AREA
+	kCommandClickInActionAreaPass = 112, // @ C112_COMMAND_CLICK_IN_ACTION_AREA_PASS
+	kCommandClickInActionAreaAction_0 = 113, // @ C113_COMMAND_CLICK_IN_ACTION_AREA_ACTION_0
+	kCommandClickInActionAreaAction_1 = 114, // @ C114_COMMAND_CLICK_IN_ACTION_AREA_ACTION_1
+	kCommandClickInActionAreaAction_2 = 115, // @ C115_COMMAND_CLICK_IN_ACTION_AREA_ACTION_2
+	kCommandClickInActionAreaChampion_0_Action = 116, // @ C116_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_0_ACTION
+	kCommandClickInActionAreaChampion_1_Action = 117, // @ C117_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_1_ACTION
+	kCommandClickInActionAreaChampion_2_Action = 118, // @ C118_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_2_ACTION
+	kCommandClickInActionAreaChampion_3_Action = 119, // @ C119_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_3_ACTION
+	kCommandClickOnChamptionIcon_Top_Left = 125, // @ C125_COMMAND_CLICK_ON_CHAMPION_ICON_TOP_LEFT
+	kCommandClickOnChamptionIcon_Top_Right = 126, // @ C126_COMMAND_CLICK_ON_CHAMPION_ICON_TOP_RIGHT
+	kCommandClickOnChamptionIcon_Lower_Right = 127, // @ C127_COMMAND_CLICK_ON_CHAMPION_ICON_LOWER_RIGHT
+	kCommandClickOnChamptionIcon_Lower_Left = 128, // @ C128_COMMAND_CLICK_ON_CHAMPION_ICON_LOWER_LEFT
+	kCommandSaveGame = 140, // @ C140_COMMAND_SAVE_GAME
+	kCommandSleep = 145, // @ C145_COMMAND_SLEEP
+	kCommandWakeUp = 146, // @ C146_COMMAND_WAKE_UP
+	kCommandFreezeGame = 147, // @ C147_COMMAND_FREEZE_GAME
+	kCommandUnfreezeGame = 148, // @ C148_COMMAND_UNFREEZE_GAME
+	kCommandClickInPanelResurrect = 160, // @ C160_COMMAND_CLICK_IN_PANEL_RESURRECT
+	kCommandClickInPanelReincarnate = 161, // @ C161_COMMAND_CLICK_IN_PANEL_REINCARNATE
+	kCommandClickInPanelCancel = 162, // @ C162_COMMAND_CLICK_IN_PANEL_CANCEL
+	kCommandEntranceEnterDungeon = 200, // @ C200_COMMAND_ENTRANCE_ENTER_DUNGEON
+	kCommandEntranceResume = 201, // @ C201_COMMAND_ENTRANCE_RESUME /* Versions 1.x and 2.x command */
+	kCommandEntranceDrawCredits = 202, // @ C202_COMMAND_ENTRANCE_DRAW_CREDITS /* Versions 1.x and 2.x command */
+	kCommandClickOnDialogChoice_1 = 210, // @ C210_COMMAND_CLICK_ON_DIALOG_CHOICE_1
+	kCommandClickOnDialogChoice_2 = 211, // @ C211_COMMAND_CLICK_ON_DIALOG_CHOICE_2
+	kCommandClickOnDialogChoice_3 = 212, // @ C212_COMMAND_CLICK_ON_DIALOG_CHOICE_3
+	kCommandClickOnDialogChoice_4 = 213, // @ C213_COMMAND_CLICK_ON_DIALOG_CHOICE_4
+	kCommandRestartGame = 215 // @ C215_COMMAND_RESTART_GAME
+}; // @ NONE
+
+class Command {
+public:
+	int16 posX, posY;
+	CommandType type;
+
+	Command(int16 x, int16 y, CommandType commandType): posX(x), posY(y), type(type) {}
+}; // @ COMMAND
+
+
+class MouseInput {
+public:
+	CommandType commandTypeToIssue;
+	Box hitbox;
+	MouseButton button;
+
+	MouseInput(CommandType type, uint16 x1, uint16 x2, uint16 y1, uint16 y2, MouseButton mouseButton)
+		: commandTypeToIssue(type), hitbox(x1, x2, y1, y2), button(mouseButton) {}
+}; // @ MOUSE_INPUT
+
 class DMEngine;
 
 class EventManager {
@@ -26,4 +162,4 @@ public:
 }
 
 
-#endif DM_EVENTMAN_H
+#endif
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index bbd2b19..9790517 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -2,7 +2,7 @@
 #define GFX_H
 
 #include "common/scummsys.h"
-#include "dm/dm.h"
+#include "dm.h"
 
 namespace DM {
 
@@ -12,12 +12,15 @@ extern uint16 gPalCredits[16];
 extern uint16 gPalEntrance[16];
 extern uint16 gPalDungeonView[6][16];
 
-typedef struct {
+class Box {
+public:
 	uint16 X1;
 	uint16 X2;
 	uint16 Y1;
 	uint16 Y2;
-} Box; // @ BOX_BYTE, BOX_WORD
+
+	Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): X1(x1), X2(x2), Y1(y1), Y2(y2) {}
+}; // @ BOX_BYTE, BOX_WORD
 
 // The frames in the original sources contain inclusive boundaries and byte widths, not pixel widths
 struct Frame {


Commit: 28874dee1f555abbc31e4ea85bd92c3dd71d1c03
    https://github.com/scummvm/scummvm/commit/28874dee1f555abbc31e4ea85bd92c3dd71d1c03
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add global static MouseInput arrays

Changed paths:
    engines/dm/eventman.cpp
    engines/dm/eventman.h



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 860ea06..8bf5a5b 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -9,6 +9,207 @@
 using namespace DM;
 
 
+MouseInput DM::gPrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
+												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+	MouseInput(kCommandEntranceEnterDungeon, 244, 298,  45,  58, kLeftMouseButton),
+	// Strangerke - C201_COMMAND_ENTRANCE_RESUME isn't present in the demo
+	MouseInput(kCommandEntranceResume,        244, 298,  76,  93, kLeftMouseButton),
+	MouseInput(kCommandEntranceDrawCredits,  248, 293, 187, 199, kLeftMouseButton),
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gPrimaryMouseInput_RestartGame[2] = { // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
+													 /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+	MouseInput(kCommandRestartGame, 103, 217, 145, 159, kLeftMouseButton),
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gPrimaryMouseInput_Interface[20] = { // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
+													/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+	MouseInput(kCommandClickInChampion_0_StatusBox,       0,  42,   0,  28, kLeftMouseButton),
+	MouseInput(kCommandClickInChampion_1_StatusBox,      69, 111,   0,  28, kLeftMouseButton),
+	MouseInput(kCommandClickInChampion_2_StatusBox,     138, 180,   0,  28, kLeftMouseButton),
+	MouseInput(kCommandClickInChampion_3_StatusBox,     207, 249,   0,  28, kLeftMouseButton),
+	MouseInput(kCommandClickOnChamptionIcon_Top_Left,    274, 299,   0,  13, kLeftMouseButton),
+	MouseInput(kCommandClickOnChamptionIcon_Top_Right,   301, 319,   0,  13, kLeftMouseButton),
+	MouseInput(kCommandClickOnChamptionIcon_Lower_Right, 301, 319,  15,  28, kLeftMouseButton),
+	MouseInput(kCommandClickOnChamptionIcon_Lower_Left,  274, 299,  15,  28, kLeftMouseButton),
+	MouseInput(kCommandToggleInventoryChampion_0,         43,  66,   0,  28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 =  44. swapped with 4 next entries */
+	MouseInput(kCommandToggleInventoryChampion_1,        112, 135,   0,  28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 113. swapped with 4 next entries */
+	MouseInput(kCommandToggleInventoryChampion_2,        181, 204,   0,  28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 182. swapped with 4 next entries */
+	MouseInput(kCommandToggleInventoryChampion_3,        250, 273,   0,  28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 251. swapped with 4 next entries */
+	MouseInput(kCommandToggleInventoryChampion_0,          0,  66,   0,  28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */
+	MouseInput(kCommandToggleInventoryChampion_1,         69, 135,   0,  28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */
+	MouseInput(kCommandToggleInventoryChampion_2,        138, 204,   0,  28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */
+	MouseInput(kCommandToggleInventoryChampion_3,        207, 273,   0,  28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */
+	MouseInput(kCommandClickInSpellArea,                233, 319,  42,  73, kLeftMouseButton),
+	MouseInput(kCommandClickInActionArea,               233, 319,  77, 121, kLeftMouseButton),
+	MouseInput(kCommandFreezeGame,                          0,   1, 198, 199, kLeftMouseButton),
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gSecondaryMouseInput_Movement[9] = { // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9]
+													/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+	MouseInput(kCommandTurnLeft,             234, 261, 125, 145, kLeftMouseButton),
+	MouseInput(kCommandMoveForward,          263, 289, 125, 145, kLeftMouseButton),
+	MouseInput(kCommandTurnRight,            291, 318, 125, 145, kLeftMouseButton),
+	MouseInput(kCommandMoveLeft,             234, 261, 147, 167, kLeftMouseButton),
+	MouseInput(kCommandMoveBackward,         263, 289, 147, 167, kLeftMouseButton),
+	MouseInput(kCommandMoveRight,            291, 318, 147, 167, kLeftMouseButton),
+	MouseInput(kCommandClickInDungeonView,   0, 223,  33, 168, kLeftMouseButton),
+	MouseInput(kCommandToggleInventoryLeader, 0, 319,  33, 199, kRightMouseButton),
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gSecondaryMouseInput_ChampionInventory[38] = { // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38]
+															  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+	MouseInput(kCommandCloseInventory,                                   0, 319,   0, 199, kRightMouseButton),
+	MouseInput(kCommandSaveGame,                                       174, 182,  36,  44, kLeftMouseButton),
+	MouseInput(kCommandSleep,                                           188, 204,  36,  44, kLeftMouseButton),
+	MouseInput(kCommandCloseInventory,                                 210, 218,  36,  44, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryReadyHand ,        6,  21,  86, 101, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryActionHand,       62,  77,  86, 101, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryHead,              34,  49,  59,  74, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryTorso,             34,  49,  79,  94, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryLegs,              34,  49,  99, 114, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryFeet,              34,  49, 119, 134, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryPouch_2,            6,  21, 123, 138, kLeftMouseButton),
+	MouseInput(kCommandClickOnMouth,                                   56,  71,  46,  61, kLeftMouseButton),
+	MouseInput(kCommandClickOnEye,                                     12,  27,  46,  61, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_2_1,    79,  94, 106, 121, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_1_2,    62,  77, 123, 138, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_2_2,    79,  94, 123, 138, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryNeck,               6,  21,  66,  81, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryPouch_1,            6,  21, 106, 121, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_1_1,    62,  77, 106, 121, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_1,  66,  81,  66,  81, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_2,  83,  98,  49,  64, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_3, 100, 115,  49,  64, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_4, 117, 132,  49,  64, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_5, 134, 149,  49,  64, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_6, 151, 166,  49,  64, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_7, 168, 183,  49,  64, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_8, 185, 200,  49,  64, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_9, 202, 217,  49,  64, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_2,  83,  98,  66,  81, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_3, 100, 115,  66,  81, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_4, 117, 132,  66,  81, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_5, 134, 149,  66,  81, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_6, 151, 166,  66,  81, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_7, 168, 183,  66,  81, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_8, 185, 200,  66,  81, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_9, 202, 217,  66,  81, kLeftMouseButton),
+	MouseInput(kCommandClickInPanel,                                   96, 223,  83, 167, kLeftMouseButton),
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gPrimaryMouseInput_PartySleeping[3] = { // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
+													   /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+	MouseInput(kCommandWakeUp, 0, 223, 33, 168, kLeftMouseButton),
+	MouseInput(kCommandWakeUp, 0, 223, 33, 168, kRightMouseButton),
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gPrimaryMouseInput_FrozenGame[3] = { // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3]
+													/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+	MouseInput(kCommandUnfreezeGame, 0, 319, 0, 199, kLeftMouseButton),
+	MouseInput(kCommandUnfreezeGame, 0, 319, 0, 199, kRightMouseButton),
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gMouseInput_ActionAreaNames[5] = { // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5]
+												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+	MouseInput(kCommandClickInActionAreaPass,     285, 318,  77,  83, kLeftMouseButton),
+	MouseInput(kCommandClickInActionAreaAction_0, 234, 318,  86,  96, kLeftMouseButton),
+	MouseInput(kCommandClickInActionAreaAction_1, 234, 318,  98, 108, kLeftMouseButton),
+	MouseInput(kCommandClickInActionAreaAction_2, 234, 318, 110, 120, kLeftMouseButton),
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gMouseInput_ActionAreaIcons[5] = { // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5]
+												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+	MouseInput(kCommandClickInActionAreaChampion_0_Action, 233, 252, 86, 120, kLeftMouseButton),
+	MouseInput(kCommandClickInActionAreaChampion_1_Action, 255, 274, 86, 120, kLeftMouseButton),
+	MouseInput(kCommandClickInActionAreaChampion_2_Action, 277, 296, 86, 120, kLeftMouseButton),
+	MouseInput(kCommandClickInActionAreaChampion_3_Action, 299, 318, 86, 120, kLeftMouseButton),
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gMouseInput_SpellArea[9] = { // @ G0454_as_Graphic561_MouseInput_SpellArea[9]
+											/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+	MouseInput(kCommandClickInSpellAreaSymbol_1,      235, 247, 51, 61, kLeftMouseButton),
+	MouseInput(kCommandClickInSpellAreaSymbol_2,      249, 261, 51, 61, kLeftMouseButton),
+	MouseInput(kCommandClickInSpellAreaSymbol_3,      263, 275, 51, 61, kLeftMouseButton),
+	MouseInput(kCommandClickInSpellAreaSymbol_4,      277, 289, 51, 61, kLeftMouseButton),
+	MouseInput(kCommandClickInSpellAreaSymbol_5,      291, 303, 51, 61, kLeftMouseButton),
+	MouseInput(kCommandClickInSpellAreaSymbol_6,      305, 317, 51, 61, kLeftMouseButton),
+	MouseInput(kCommandClickInSpeallAreaCastSpell,    234, 303, 63, 73, kLeftMouseButton),
+	MouseInput(kCommandClickInSpellAreaRecantSymbol, 305, 318, 63, 73, kLeftMouseButton),
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gMouseInput_ChampionNamesHands[13] = { // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
+													  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+	MouseInput(kCommandSetLeaderChampion_0,                                    0,  42,  0,  6, kLeftMouseButton),
+	MouseInput(kCommandSetLeaderChampion_1,                                   69, 111,  0,  6, kLeftMouseButton),
+	MouseInput(kCommandSetLeaderChampion_2,                                  138, 180,  0,  6, kLeftMouseButton),
+	MouseInput(kCommandSetLeaderChampion_3,                                  207, 249,  0,  6, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxChampion_0_StatusBoxReadyHand,    4,  19, 10, 25, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxChampion_0_StatusBoxActionHand,  24,  39, 10, 25, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxChampion_1_StatusBoxReadyHand,   73,  88, 10, 25, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxChampion_1_StatusBoxActionHand,  93, 108, 10, 25, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxChampion_2_StatusBoxReadyHand,  142, 157, 10, 25, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxChampion_2_StatusBoxActionHand, 162, 177, 10, 25, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxChampion_3_StatusBoxReadyHand,  211, 226, 10, 25, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxChampion_3_StatusBoxActionHand, 231, 246, 10, 25, kLeftMouseButton),
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gMouseInput_PanelChest[9] = { // @ G0456_as_Graphic561_MouseInput_PanelChest[9]
+											 /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+	MouseInput(kCommandClickOnSlotBoxChest_1, 117, 132,  92, 107, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxChest_2, 106, 121, 109, 124, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxChest_3, 111, 126, 126, 141, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxChest_4, 128, 143, 131, 146, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxChest_5, 145, 160, 134, 149, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxChest_6, 162, 177, 136, 151, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxChest_7, 179, 194, 137, 152, kLeftMouseButton),
+	MouseInput(kCommandClickOnSlotBoxChest_8, 196, 211, 138, 153, kLeftMouseButton),
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gMouseInput_PanelResurrectReincarnateCancel[4] = { // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4]
+																  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+	MouseInput(kCommandClickInPanelResurrect,   108, 158,  90, 138, kLeftMouseButton), /* Atari ST: Box = 104, 158,  86, 142 */
+	MouseInput(kCommandClickInPanelReincarnate, 161, 211,  90, 138, kLeftMouseButton), /* Atari ST: Box = 163, 217,  86, 142 */
+	MouseInput(kCommandClickInPanelCancel,      108, 211, 141, 153, kLeftMouseButton), /* Atari ST: Box = 104, 217, 146, 156 */
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+
+
+MouseInput DM::gPrimaryMouseInput_ViewportDialog1Choice[2] = { // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
+	MouseInput(kCommandClickOnDialogChoice_1, 16, 207, 138, 152, kLeftMouseButton), /* Bottom button */
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gPrimaryMouseInput_ViewportDialog2Choices[3] = { // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3]
+	MouseInput(kCommandClickOnDialogChoice_1, 16, 207, 101, 115, kLeftMouseButton), /* Top button */
+	MouseInput(kCommandClickOnDialogChoice_2, 16, 207, 138, 152, kLeftMouseButton), /* Bottom button */
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gPrimaryMouseInput_ViewportDialog3Choices[4] = { // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4]
+	MouseInput(kCommandClickOnDialogChoice_1,  16, 207, 101, 115, kLeftMouseButton), /* Top button */
+	MouseInput(kCommandClickOnDialogChoice_2,  16, 101, 138, 152, kLeftMouseButton), /* Lower left button */
+	MouseInput(kCommandClickOnDialogChoice_3, 123, 207, 138, 152, kLeftMouseButton), /* Lower right button */
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gPrimaryMouseInput_ViewportDialog4Choices[5] = { // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5]
+	MouseInput(kCommandClickOnDialogChoice_1,  16, 101, 101, 115, kLeftMouseButton), /* Top left button */
+	MouseInput(kCommandClickOnDialogChoice_2, 123, 207, 101, 115, kLeftMouseButton), /* Top right button */
+	MouseInput(kCommandClickOnDialogChoice_3,  16, 101, 138, 152, kLeftMouseButton), /* Lower left button */
+	MouseInput(kCommandClickOnDialogChoice_4, 123, 207, 138, 152, kLeftMouseButton), /* Lower right button */
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gPrimaryMouseInput_ScreenDialog1Choice[2] = { // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2]
+	MouseInput(kCommandClickOnDialogChoice_1, 63, 254, 138, 152, kLeftMouseButton), /* Bottom button */
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gPrimaryMouseInput_ScreenDialog2Choices[3] = { // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3]
+	MouseInput(kCommandClickOnDialogChoice_1, 63, 254, 101, 115, kLeftMouseButton), /* Top button */
+	MouseInput(kCommandClickOnDialogChoice_2, 63, 254, 138, 152, kLeftMouseButton), /* Bottom button */
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gPrimaryMouseInput_ScreenDialog3Choices[4] = { // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4]
+	MouseInput(kCommandClickOnDialogChoice_1,  63, 254, 101, 115, kLeftMouseButton), /* Top button */
+	MouseInput(kCommandClickOnDialogChoice_2,  63, 148, 138, 152, kLeftMouseButton), /* Lower left button */
+	MouseInput(kCommandClickOnDialogChoice_3, 170, 254, 138, 152, kLeftMouseButton), /* Lower right button */
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+MouseInput DM::gPrimaryMouseInput_ScreenDialog4Choices[5] = { // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
+	MouseInput(kCommandClickOnDialogChoice_1,  63, 148, 101, 115, kLeftMouseButton), /* Top left button */
+	MouseInput(kCommandClickOnDialogChoice_2, 170, 254, 101, 115, kLeftMouseButton), /* Top right button */
+	MouseInput(kCommandClickOnDialogChoice_3,  63, 148, 138, 152, kLeftMouseButton), /* Lower left button */
+	MouseInput(kCommandClickOnDialogChoice_4, 170, 254, 138, 152, kLeftMouseButton), /* Lower right button */
+	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
+
+MouseInput* DM::gPrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryMouseInput_DialogSets
+	{gPrimaryMouseInput_ViewportDialog1Choice,
+	gPrimaryMouseInput_ViewportDialog2Choices,
+	gPrimaryMouseInput_ViewportDialog3Choices,
+	gPrimaryMouseInput_ViewportDialog4Choices},
+	{gPrimaryMouseInput_ScreenDialog1Choice,
+	gPrimaryMouseInput_ScreenDialog2Choices,
+	gPrimaryMouseInput_ScreenDialog3Choices,
+	gPrimaryMouseInput_ScreenDialog4Choices},};
+
+
 EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 	_dummyMapIndex = 0;				
 }
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index cf34636..996443d 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -8,8 +8,9 @@
 namespace DM {
 
 enum MouseButton {
-	kLeftMouseButton,
-	kRightMouseButton
+	kNoneMouseButton = 0, // present only because of typesafety
+	kLeftMouseButton = 1,
+	kRightMouseButton = 2
 };
 
 enum CommandType {
@@ -36,7 +37,7 @@ enum CommandType {
 	kCommandClickOnSlotBoxChampion_0_StatusBoxReadyHand = 20, // @ C020_COMMAND_CLICK_ON_SLOT_BOX_00_CHAMPION_0_STATUS_BOX_READY_HAND
 	kCommandClickOnSlotBoxChampion_0_StatusBoxActionHand = 21, // @ C021_COMMAND_CLICK_ON_SLOT_BOX_01_CHAMPION_0_STATUS_BOX_ACTION_HAND
 	kCommandClickOnSlotBoxChampion_1_StatusBoxReadyHand = 22, // @ C022_COMMAND_CLICK_ON_SLOT_BOX_02_CHAMPION_1_STATUS_BOX_READY_HAND
-	kCommandClickOnSlotBoxChampion_1_StatusBoxAactionHand = 23, // @ C023_COMMAND_CLICK_ON_SLOT_BOX_03_CHAMPION_1_STATUS_BOX_ACTION_HAND
+	kCommandClickOnSlotBoxChampion_1_StatusBoxActionHand = 23, // @ C023_COMMAND_CLICK_ON_SLOT_BOX_03_CHAMPION_1_STATUS_BOX_ACTION_HAND
 	kCommandClickOnSlotBoxChampion_2_StatusBoxReadyHand = 24, // @ C024_COMMAND_CLICK_ON_SLOT_BOX_04_CHAMPION_2_STATUS_BOX_READY_HAND
 	kCommandClickOnSlotBoxChampion_2_StatusBoxActionHand = 25, // @ C025_COMMAND_CLICK_ON_SLOT_BOX_05_CHAMPION_2_STATUS_BOX_ACTION_HAND
 	kCommandClickOnSlotBoxChampion_3_StatusBoxReadyHand = 26, // @ C026_COMMAND_CLICK_ON_SLOT_BOX_06_CHAMPION_3_STATUS_BOX_READY_HAND
@@ -143,6 +144,30 @@ public:
 		: commandTypeToIssue(type), hitbox(x1, x2, y1, y2), button(mouseButton) {}
 }; // @ MOUSE_INPUT
 
+extern MouseInput gPrimaryMouseInput_Entrance[4]; // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
+extern MouseInput gPrimaryMouseInput_RestartGame[2]; // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
+extern MouseInput gPrimaryMouseInput_Interface[20]; // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
+extern MouseInput gSecondaryMouseInput_Movement[9]; // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9]
+extern MouseInput gSecondaryMouseInput_ChampionInventory[38]; // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38]
+extern MouseInput gPrimaryMouseInput_PartySleeping[3]; // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
+extern MouseInput gPrimaryMouseInput_FrozenGame[3]; // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3]
+extern MouseInput gMouseInput_ActionAreaNames[5]; // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5]
+extern MouseInput gMouseInput_ActionAreaIcons[5]; // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5]
+extern MouseInput gMouseInput_SpellArea[9]; // @ G0454_as_Graphic561_MouseInput_SpellArea[9]
+extern MouseInput gMouseInput_ChampionNamesHands[13]; // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
+extern MouseInput gMouseInput_PanelChest[9]; // @ G0456_as_Graphic561_MouseInput_PanelChest[9]
+extern MouseInput gMouseInput_PanelResurrectReincarnateCancel[4]; // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4]
+extern MouseInput gPrimaryMouseInput_ViewportDialog1Choice[2]; // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
+extern MouseInput gPrimaryMouseInput_ViewportDialog2Choices[3]; // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3]
+extern MouseInput gPrimaryMouseInput_ViewportDialog3Choices[4]; // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4]
+extern MouseInput gPrimaryMouseInput_ViewportDialog4Choices[5]; // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5]
+extern MouseInput gPrimaryMouseInput_ScreenDialog1Choice[2]; // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2]
+extern MouseInput gPrimaryMouseInput_ScreenDialog2Choices[3]; // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3]
+extern MouseInput gPrimaryMouseInput_ScreenDialog3Choices[4]; // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4]
+extern MouseInput gPrimaryMouseInput_ScreenDialog4Choices[5]; // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
+extern MouseInput* gPrimaryMouseInput_DialogSets[2][4]; // @ G0480_aaps_PrimaryMouseInput_DialogSets
+
+
 class DMEngine;
 
 class EventManager {


Commit: 6b31b1bbc32ecb021de8b92a02e31621c7d8e45f
    https://github.com/scummvm/scummvm/commit/6b31b1bbc32ecb021de8b92a02e31621c7d8e45f
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add KeyboardInput struct

Changed paths:
    engines/dm/eventman.h



diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 996443d..ae3eb90 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -167,6 +167,14 @@ extern MouseInput gPrimaryMouseInput_ScreenDialog3Choices[4]; // @ G0477_as_Grap
 extern MouseInput gPrimaryMouseInput_ScreenDialog4Choices[5]; // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
 extern MouseInput* gPrimaryMouseInput_DialogSets[2][4]; // @ G0480_aaps_PrimaryMouseInput_DialogSets
 
+class KeyboardInput {
+public:
+	Command commandToIssue;
+	Common::KeyCode key;
+	byte modifiers;
+
+	KeyboardInput(Command command, Common::KeyCode keycode, byte modifierFlags) : commandToIssue(command), key(keycode), modifiers(modifierFlags) {}
+}; // @ KEYBOARD_INPUT
 
 class DMEngine;
 


Commit: bcfe176df557b78adf9181a9dfea229ff3fadfe1
    https://github.com/scummvm/scummvm/commit/bcfe176df557b78adf9181a9dfea229ff3fadfe1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add mouseclick processing

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 002068a..44c90d2 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -74,15 +74,15 @@ Common::Error DMEngine::run() {
 	_dungeonMan->setCurrentMapAndPartyMap(dummyMapIndex);
 
 
-
-
 	_displayMan->loadCurrentMapGraphics();
-
 	_displayMan->loadPalette(gPalCredits);
 
 	_eventMan->initMouse();
 	_eventMan->showMouse(true);
 
+	startGame();
+
+
 	while (true) {
 		_eventMan->processInput();
 		_displayMan->clearScreen(kColorBlack);
@@ -95,4 +95,10 @@ Common::Error DMEngine::run() {
 	return Common::kNoError;
 }
 
+
+void DMEngine::startGame() {
+	_eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface;
+	_eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement;
+}
+
 } // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index c381587..83f80e4 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -76,6 +76,7 @@ enum {
 };
 
 class DMEngine : public Engine {
+	void startGame(); // @ F0462_START_StartGame_CPSF
 public:
 	DMEngine(OSystem *syst);
 	~DMEngine();
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 8bf5a5b..f2ca15e 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -6,21 +6,21 @@
 
 
 
-using namespace DM;
 
+namespace DM {
 
-MouseInput DM::gPrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
+MouseInput gPrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
 												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(kCommandEntranceEnterDungeon, 244, 298,  45,  58, kLeftMouseButton),
 	// Strangerke - C201_COMMAND_ENTRANCE_RESUME isn't present in the demo
 	MouseInput(kCommandEntranceResume,        244, 298,  76,  93, kLeftMouseButton),
 	MouseInput(kCommandEntranceDrawCredits,  248, 293, 187, 199, kLeftMouseButton),
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gPrimaryMouseInput_RestartGame[2] = { // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
+MouseInput gPrimaryMouseInput_RestartGame[2] = { // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
 													 /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(kCommandRestartGame, 103, 217, 145, 159, kLeftMouseButton),
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gPrimaryMouseInput_Interface[20] = { // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
+MouseInput gPrimaryMouseInput_Interface[20] = { // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
 													/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(kCommandClickInChampion_0_StatusBox,       0,  42,   0,  28, kLeftMouseButton),
 	MouseInput(kCommandClickInChampion_1_StatusBox,      69, 111,   0,  28, kLeftMouseButton),
@@ -42,7 +42,7 @@ MouseInput DM::gPrimaryMouseInput_Interface[20] = { // @ G0447_as_Graphic561_Pri
 	MouseInput(kCommandClickInActionArea,               233, 319,  77, 121, kLeftMouseButton),
 	MouseInput(kCommandFreezeGame,                          0,   1, 198, 199, kLeftMouseButton),
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gSecondaryMouseInput_Movement[9] = { // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9]
+MouseInput gSecondaryMouseInput_Movement[9] = { // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9]
 													/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(kCommandTurnLeft,             234, 261, 125, 145, kLeftMouseButton),
 	MouseInput(kCommandMoveForward,          263, 289, 125, 145, kLeftMouseButton),
@@ -53,7 +53,7 @@ MouseInput DM::gSecondaryMouseInput_Movement[9] = { // @ G0448_as_Graphic561_Sec
 	MouseInput(kCommandClickInDungeonView,   0, 223,  33, 168, kLeftMouseButton),
 	MouseInput(kCommandToggleInventoryLeader, 0, 319,  33, 199, kRightMouseButton),
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gSecondaryMouseInput_ChampionInventory[38] = { // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38]
+MouseInput gSecondaryMouseInput_ChampionInventory[38] = { // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38]
 															  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(kCommandCloseInventory,                                   0, 319,   0, 199, kRightMouseButton),
 	MouseInput(kCommandSaveGame,                                       174, 182,  36,  44, kLeftMouseButton),
@@ -93,31 +93,31 @@ MouseInput DM::gSecondaryMouseInput_ChampionInventory[38] = { // @ G0449_as_Grap
 	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_9, 202, 217,  66,  81, kLeftMouseButton),
 	MouseInput(kCommandClickInPanel,                                   96, 223,  83, 167, kLeftMouseButton),
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gPrimaryMouseInput_PartySleeping[3] = { // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
+MouseInput gPrimaryMouseInput_PartySleeping[3] = { // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
 													   /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(kCommandWakeUp, 0, 223, 33, 168, kLeftMouseButton),
 	MouseInput(kCommandWakeUp, 0, 223, 33, 168, kRightMouseButton),
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gPrimaryMouseInput_FrozenGame[3] = { // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3]
+MouseInput gPrimaryMouseInput_FrozenGame[3] = { // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3]
 													/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(kCommandUnfreezeGame, 0, 319, 0, 199, kLeftMouseButton),
 	MouseInput(kCommandUnfreezeGame, 0, 319, 0, 199, kRightMouseButton),
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gMouseInput_ActionAreaNames[5] = { // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5]
+MouseInput gMouseInput_ActionAreaNames[5] = { // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5]
 												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(kCommandClickInActionAreaPass,     285, 318,  77,  83, kLeftMouseButton),
 	MouseInput(kCommandClickInActionAreaAction_0, 234, 318,  86,  96, kLeftMouseButton),
 	MouseInput(kCommandClickInActionAreaAction_1, 234, 318,  98, 108, kLeftMouseButton),
 	MouseInput(kCommandClickInActionAreaAction_2, 234, 318, 110, 120, kLeftMouseButton),
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gMouseInput_ActionAreaIcons[5] = { // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5]
+MouseInput gMouseInput_ActionAreaIcons[5] = { // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5]
 												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(kCommandClickInActionAreaChampion_0_Action, 233, 252, 86, 120, kLeftMouseButton),
 	MouseInput(kCommandClickInActionAreaChampion_1_Action, 255, 274, 86, 120, kLeftMouseButton),
 	MouseInput(kCommandClickInActionAreaChampion_2_Action, 277, 296, 86, 120, kLeftMouseButton),
 	MouseInput(kCommandClickInActionAreaChampion_3_Action, 299, 318, 86, 120, kLeftMouseButton),
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gMouseInput_SpellArea[9] = { // @ G0454_as_Graphic561_MouseInput_SpellArea[9]
+MouseInput gMouseInput_SpellArea[9] = { // @ G0454_as_Graphic561_MouseInput_SpellArea[9]
 											/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(kCommandClickInSpellAreaSymbol_1,      235, 247, 51, 61, kLeftMouseButton),
 	MouseInput(kCommandClickInSpellAreaSymbol_2,      249, 261, 51, 61, kLeftMouseButton),
@@ -128,7 +128,7 @@ MouseInput DM::gMouseInput_SpellArea[9] = { // @ G0454_as_Graphic561_MouseInput_
 	MouseInput(kCommandClickInSpeallAreaCastSpell,    234, 303, 63, 73, kLeftMouseButton),
 	MouseInput(kCommandClickInSpellAreaRecantSymbol, 305, 318, 63, 73, kLeftMouseButton),
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gMouseInput_ChampionNamesHands[13] = { // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
+MouseInput gMouseInput_ChampionNamesHands[13] = { // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
 													  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(kCommandSetLeaderChampion_0,                                    0,  42,  0,  6, kLeftMouseButton),
 	MouseInput(kCommandSetLeaderChampion_1,                                   69, 111,  0,  6, kLeftMouseButton),
@@ -143,7 +143,7 @@ MouseInput DM::gMouseInput_ChampionNamesHands[13] = { // @ G0455_as_Graphic561_M
 	MouseInput(kCommandClickOnSlotBoxChampion_3_StatusBoxReadyHand,  211, 226, 10, 25, kLeftMouseButton),
 	MouseInput(kCommandClickOnSlotBoxChampion_3_StatusBoxActionHand, 231, 246, 10, 25, kLeftMouseButton),
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gMouseInput_PanelChest[9] = { // @ G0456_as_Graphic561_MouseInput_PanelChest[9]
+MouseInput gMouseInput_PanelChest[9] = { // @ G0456_as_Graphic561_MouseInput_PanelChest[9]
 											 /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(kCommandClickOnSlotBoxChest_1, 117, 132,  92, 107, kLeftMouseButton),
 	MouseInput(kCommandClickOnSlotBoxChest_2, 106, 121, 109, 124, kLeftMouseButton),
@@ -154,7 +154,7 @@ MouseInput DM::gMouseInput_PanelChest[9] = { // @ G0456_as_Graphic561_MouseInput
 	MouseInput(kCommandClickOnSlotBoxChest_7, 179, 194, 137, 152, kLeftMouseButton),
 	MouseInput(kCommandClickOnSlotBoxChest_8, 196, 211, 138, 153, kLeftMouseButton),
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gMouseInput_PanelResurrectReincarnateCancel[4] = { // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4]
+MouseInput gMouseInput_PanelResurrectReincarnateCancel[4] = { // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4]
 																  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(kCommandClickInPanelResurrect,   108, 158,  90, 138, kLeftMouseButton), /* Atari ST: Box = 104, 158,  86, 142 */
 	MouseInput(kCommandClickInPanelReincarnate, 161, 211,  90, 138, kLeftMouseButton), /* Atari ST: Box = 163, 217,  86, 142 */
@@ -162,44 +162,44 @@ MouseInput DM::gMouseInput_PanelResurrectReincarnateCancel[4] = { // @ G0457_as_
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
 
 
-MouseInput DM::gPrimaryMouseInput_ViewportDialog1Choice[2] = { // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
+MouseInput gPrimaryMouseInput_ViewportDialog1Choice[2] = { // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
 	MouseInput(kCommandClickOnDialogChoice_1, 16, 207, 138, 152, kLeftMouseButton), /* Bottom button */
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gPrimaryMouseInput_ViewportDialog2Choices[3] = { // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3]
+MouseInput gPrimaryMouseInput_ViewportDialog2Choices[3] = { // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3]
 	MouseInput(kCommandClickOnDialogChoice_1, 16, 207, 101, 115, kLeftMouseButton), /* Top button */
 	MouseInput(kCommandClickOnDialogChoice_2, 16, 207, 138, 152, kLeftMouseButton), /* Bottom button */
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gPrimaryMouseInput_ViewportDialog3Choices[4] = { // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4]
+MouseInput gPrimaryMouseInput_ViewportDialog3Choices[4] = { // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4]
 	MouseInput(kCommandClickOnDialogChoice_1,  16, 207, 101, 115, kLeftMouseButton), /* Top button */
 	MouseInput(kCommandClickOnDialogChoice_2,  16, 101, 138, 152, kLeftMouseButton), /* Lower left button */
 	MouseInput(kCommandClickOnDialogChoice_3, 123, 207, 138, 152, kLeftMouseButton), /* Lower right button */
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gPrimaryMouseInput_ViewportDialog4Choices[5] = { // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5]
+MouseInput gPrimaryMouseInput_ViewportDialog4Choices[5] = { // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5]
 	MouseInput(kCommandClickOnDialogChoice_1,  16, 101, 101, 115, kLeftMouseButton), /* Top left button */
 	MouseInput(kCommandClickOnDialogChoice_2, 123, 207, 101, 115, kLeftMouseButton), /* Top right button */
 	MouseInput(kCommandClickOnDialogChoice_3,  16, 101, 138, 152, kLeftMouseButton), /* Lower left button */
 	MouseInput(kCommandClickOnDialogChoice_4, 123, 207, 138, 152, kLeftMouseButton), /* Lower right button */
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gPrimaryMouseInput_ScreenDialog1Choice[2] = { // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2]
+MouseInput gPrimaryMouseInput_ScreenDialog1Choice[2] = { // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2]
 	MouseInput(kCommandClickOnDialogChoice_1, 63, 254, 138, 152, kLeftMouseButton), /* Bottom button */
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gPrimaryMouseInput_ScreenDialog2Choices[3] = { // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3]
+MouseInput gPrimaryMouseInput_ScreenDialog2Choices[3] = { // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3]
 	MouseInput(kCommandClickOnDialogChoice_1, 63, 254, 101, 115, kLeftMouseButton), /* Top button */
 	MouseInput(kCommandClickOnDialogChoice_2, 63, 254, 138, 152, kLeftMouseButton), /* Bottom button */
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gPrimaryMouseInput_ScreenDialog3Choices[4] = { // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4]
+MouseInput gPrimaryMouseInput_ScreenDialog3Choices[4] = { // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4]
 	MouseInput(kCommandClickOnDialogChoice_1,  63, 254, 101, 115, kLeftMouseButton), /* Top button */
 	MouseInput(kCommandClickOnDialogChoice_2,  63, 148, 138, 152, kLeftMouseButton), /* Lower left button */
 	MouseInput(kCommandClickOnDialogChoice_3, 170, 254, 138, 152, kLeftMouseButton), /* Lower right button */
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput DM::gPrimaryMouseInput_ScreenDialog4Choices[5] = { // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
+MouseInput gPrimaryMouseInput_ScreenDialog4Choices[5] = { // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
 	MouseInput(kCommandClickOnDialogChoice_1,  63, 148, 101, 115, kLeftMouseButton), /* Top left button */
 	MouseInput(kCommandClickOnDialogChoice_2, 170, 254, 101, 115, kLeftMouseButton), /* Top right button */
 	MouseInput(kCommandClickOnDialogChoice_3,  63, 148, 138, 152, kLeftMouseButton), /* Lower left button */
 	MouseInput(kCommandClickOnDialogChoice_4, 170, 254, 138, 152, kLeftMouseButton), /* Lower right button */
 	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
 
-MouseInput* DM::gPrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryMouseInput_DialogSets
+MouseInput* gPrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryMouseInput_DialogSets
 	{gPrimaryMouseInput_ViewportDialog1Choice,
 	gPrimaryMouseInput_ViewportDialog2Choices,
 	gPrimaryMouseInput_ViewportDialog3Choices,
@@ -211,7 +211,13 @@ MouseInput* DM::gPrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryM
 
 
 EventManager::EventManager(DMEngine *vm) : _vm(vm) {
-	_dummyMapIndex = 0;				
+	_primaryMouseInput = nullptr;
+	_secondaryMouseInput = nullptr;
+
+	_pendingClickPresent = false;
+	_isCommandQueueLocked = true;
+
+	_dummyMapIndex = 0;
 }
 
 
@@ -242,7 +248,7 @@ void EventManager::initMouse() {
 	CursorMan.pushCursor(mouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
 	CursorMan.showMouse(false);
 
-	setMousePos(Common::Point(320/2, 200/2));
+	setMousePos(Common::Point(320 / 2, 200 / 2));
 	// TODO: add cursor creatin, set to hidden
 }
 
@@ -261,7 +267,11 @@ void EventManager::processInput() {
 
 	Common::Event event;
 	while (_vm->_system->getEventManager()->pollEvent(event)) {
-		if (event.type == Common::EVENT_KEYDOWN && !event.synthetic) {
+		switch (event.type) {
+		case Common::EVENT_KEYDOWN:
+			if (event.synthetic)
+				break;
+
 			switch (event.kbd.keycode) {
 			case Common::KEYCODE_w:
 				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY);
@@ -290,8 +300,51 @@ void EventManager::processInput() {
 					dungeonMan.setCurrentMapAndPartyMap(--_dummyMapIndex);
 				break;
 			}
-		} else if (event.type == Common::EVENT_MOUSEMOVE) {
+		case Common::EVENT_MOUSEMOVE:
 			_mousePos = event.mouse;
+			break;
+		case Common::EVENT_LBUTTONUP:
+		case Common::EVENT_RBUTTONUP:
+			_pendingClickPresent = true;
+			_pendingClickPos = _mousePos;
+			_pendingClickButton = (event.type == Common::EVENT_LBUTTONUP) ? kLeftMouseButton : kRightMouseButton;
+			break;
 		}
 	}
 }
+
+void EventManager::processPendingClick() {
+	if (_pendingClickPresent) {
+		_pendingClickPresent = false;
+		processClick(_pendingClickPos, _pendingClickButton);
+	}
+}
+
+void EventManager::processClick(Common::Point mousePos, MouseButton button) {
+	CommandType commandType;
+
+	commandType = getCommandTypeFromMouseInput(_primaryMouseInput, mousePos, button);
+	if (commandType == kCommandNone)
+		commandType = getCommandTypeFromMouseInput(_secondaryMouseInput, mousePos, button);
+
+	if (commandType != kCommandNone)
+		_commandQueue.push(Command(mousePos, commandType));
+
+	_isCommandQueueLocked = false;
+}
+
+CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button) {
+	if (!input)
+		return kCommandNone;
+	CommandType commandType = kCommandNone;
+
+	while ((commandType = input->commandTypeToIssue) != kCommandNone) {
+		if (input->hitbox.isPointInside(mousePos) && input->button == button)
+			break;
+		input++;
+	}
+	return commandType;
+}
+
+
+}; // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index ae3eb90..c52cf6d 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -2,6 +2,7 @@
 #define DM_EVENTMAN_H
 
 #include "common/events.h"
+#include "common/queue.h"
 #include "gfx.h"
 
 
@@ -127,10 +128,10 @@ enum CommandType {
 
 class Command {
 public:
-	int16 posX, posY;
+	Common::Point pos;
 	CommandType type;
 
-	Command(int16 x, int16 y, CommandType commandType): posX(x), posY(y), type(type) {}
+	Command(Common::Point position, CommandType commandType): pos(position), type(type) {}
 }; // @ COMMAND
 
 
@@ -141,7 +142,7 @@ public:
 	MouseButton button;
 
 	MouseInput(CommandType type, uint16 x1, uint16 x2, uint16 y1, uint16 y2, MouseButton mouseButton)
-		: commandTypeToIssue(type), hitbox(x1, x2, y1, y2), button(mouseButton) {}
+		: commandTypeToIssue(type), hitbox(x1, x2 + 1, y1, y2 + 1), button(mouseButton) {}
 }; // @ MOUSE_INPUT
 
 extern MouseInput gPrimaryMouseInput_Entrance[4]; // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
@@ -183,13 +184,26 @@ class EventManager {
 
 	Common::Point _mousePos;
 	uint16 _dummyMapIndex;
+
+	bool _pendingClickPresent; // G0436_B_PendingClickPresent
+	Common::Point _pendingClickPos; // @ G0437_i_PendingClickX, G0438_i_PendingClickY
+	MouseButton _pendingClickButton; // @ G0439_i_PendingClickButtonsStatus
+
+	bool _isCommandQueueLocked;
+	Common::Queue<Command> _commandQueue;
 public:
+	MouseInput* _primaryMouseInput;// @ G0441_ps_PrimaryMouseInput
+	MouseInput* _secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput
+
 	EventManager(DMEngine *vm);
 	void initMouse();
 	void showMouse(bool visibility);
 
 	void setMousePos(Common::Point pos);
 	void processInput();
+	void processPendingClick(); // @ F0360_COMMAND_ProcessPendingClick
+	void processClick(Common::Point mousePos, MouseButton button); // @	F0359_COMMAND_ProcessClick_CPSC
+	CommandType getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC
 };
 
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 1c820a9..3042d8f 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -622,7 +622,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	for (int i = 0; i < 18; i++)
 		_currMapDoorOrnIndices[i] = 0;
 
-	Thing _inscriptionThing = Thing::thingNone;
+	_inscriptionThing = Thing::thingNone;
 }
 
 DisplayMan::~DisplayMan() {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 9790517..50171fe 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -2,6 +2,7 @@
 #define GFX_H
 
 #include "common/scummsys.h"
+#include "common/rect.h"
 #include "dm.h"
 
 namespace DM {
@@ -20,6 +21,9 @@ public:
 	uint16 Y2;
 
 	Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): X1(x1), X2(x2), Y1(y1), Y2(y2) {}
+	bool isPointInside(Common::Point point) {
+		return (X1 <= point.x) && (point.x < X2) && (Y1 <= point.y) && (point.y < Y2);
+	}
 }; // @ BOX_BYTE, BOX_WORD
 
 // The frames in the original sources contain inclusive boundaries and byte widths, not pixel widths


Commit: 98c79f89bf2c5860f39a6ec7ca88a01a2f987323
    https://github.com/scummvm/scummvm/commit/98c79f89bf2c5860f39a6ec7ca88a01a2f987323
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add mouse input processing and display for movement arrows

Changed paths:
  A engines/dm/menus.cpp
  A engines/dm/menus.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/module.mk



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 44c90d2..40e25d3 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -15,6 +15,7 @@
 #include "gfx.h"
 #include "dungeonman.h"
 #include "eventman.h"
+#include "menus.h"
 
 namespace DM {
 
@@ -52,6 +53,7 @@ DMEngine::~DMEngine() {
 	delete _displayMan;
 	delete _dungeonMan;
 	delete _eventMan;
+	delete _menuMan;
 
 	// clear debug channels
 	DebugMan.clearAllDebugChannels();
@@ -64,6 +66,7 @@ Common::Error DMEngine::run() {
 	_displayMan = new DisplayMan(this);
 	_dungeonMan = new DungeonMan(this);
 	_eventMan = new EventManager(this);
+	_menuMan = new MenuMan(this);
 
 	_displayMan->setUpScreens(320, 200);
 
@@ -84,9 +87,16 @@ Common::Error DMEngine::run() {
 
 
 	while (true) {
-		_eventMan->processInput();
+		_stopWaitingForPlayerInput = false;
+		//do {
+			_eventMan->processInput();
+			_eventMan->processCommandQueue();
+		//} while (!_stopWaitingForPlayerInput || !_gameTimeTicking);
+
 		_displayMan->clearScreen(kColorBlack);
 		_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY);
+		// DUMMY CODE:
+		_menuMan->drawMovementArrows();
 		_displayMan->updateScreen();
 		_system->delayMillis(10);
 	}
@@ -99,6 +109,9 @@ Common::Error DMEngine::run() {
 void DMEngine::startGame() {
 	_eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface;
 	_eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement;
+
+	_menuMan->drawMovementArrows();
+	_gameTimeTicking = true;
 }
 
 } // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 83f80e4..384ac1d 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -12,6 +12,7 @@ class Console;
 class DisplayMan;
 class DungeonMan;
 class EventManager;
+class MenuMan;
 
 
 enum direction {
@@ -90,6 +91,9 @@ public:
 	DisplayMan *_displayMan;
 	DungeonMan *_dungeonMan;
 	EventManager *_eventMan;
+	MenuMan *_menuMan;
+	bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput
+	bool _gameTimeTicking; // @ G0301_B_GameTimeTicking
 };
 
 class Console : public GUI::Debugger {
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index f2ca15e..488deeb 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -268,6 +268,7 @@ void EventManager::processInput() {
 	Common::Event event;
 	while (_vm->_system->getEventManager()->pollEvent(event)) {
 		switch (event.type) {
+		// DUMMY CODE: EVENT_KEYDOWN, only for testing
 		case Common::EVENT_KEYDOWN:
 			if (event.synthetic)
 				break;
@@ -303,11 +304,11 @@ void EventManager::processInput() {
 		case Common::EVENT_MOUSEMOVE:
 			_mousePos = event.mouse;
 			break;
-		case Common::EVENT_LBUTTONUP:
-		case Common::EVENT_RBUTTONUP:
+		case Common::EVENT_LBUTTONDOWN:
+		case Common::EVENT_RBUTTONDOWN:
 			_pendingClickPresent = true;
 			_pendingClickPos = _mousePos;
-			_pendingClickButton = (event.type == Common::EVENT_LBUTTONUP) ? kLeftMouseButton : kRightMouseButton;
+			_pendingClickButton = (event.type == Common::EVENT_LBUTTONDOWN) ? kLeftMouseButton : kRightMouseButton;
 			break;
 		}
 	}
@@ -347,4 +348,76 @@ CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common
 }
 
 
+void EventManager::processCommandQueue() {
+	_isCommandQueueLocked = true;
+	if (_commandQueue.empty()) {
+		_isCommandQueueLocked = false;
+		processPendingClick();
+		return;
+	}
+
+	Command cmd = _commandQueue.pop();
+
+	// MISSING CODE: for when movement is disabled
+
+	_isCommandQueueLocked = false;
+	processPendingClick();
+
+	if ((cmd.type == kCommandTurnRight) || (cmd.type == kCommandTurnLeft)) {
+		commandTurnParty(cmd.type);
+		return;
+	}
+
+	if ((cmd.type >= kCommandMoveForward) && (cmd.type <= kCommandMoveLeft)) {
+		commandMoveParty(cmd.type);
+		return;
+	}
+
+	// MISSING CODE: the rest of the function
+}
+
+void EventManager::commandTurnParty(CommandType cmdType) {
+	_vm->_stopWaitingForPlayerInput = true;
+
+	// MISSING CODE: highlight turn left/right buttons
+
+	// MISSING CODE: processing stairs
+
+	// MISSING CODE: process sensors
+
+	// DUMMY CODE: should call F0284_CHAMPION_SetPartyDirection instead
+	direction &partyDir = _vm->_dungeonMan->_currMap.partyDir;
+	(cmdType == kCommandTurnLeft) ? turnDirLeft(partyDir) : turnDirRight(partyDir);
+
+	// MISSING CODE: process sensors
+}
+
+void EventManager::commandMoveParty(CommandType cmdType) {
+	_vm->_stopWaitingForPlayerInput = true;
+
+	// MISSING CODE: Lots of code
+
+	// DUMMY CODE:
+	DungeonMan &dungeonMan = *_vm->_dungeonMan;
+	CurrMapData &currMap = dungeonMan._currMap;
+
+	switch (cmdType) {
+	case kCommandMoveForward:
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY);
+		break;
+	case kCommandMoveLeft:
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, -1, currMap.partyPosX, currMap.partyPosY);
+		break;
+	case kCommandMoveBackward:
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, -1, 0, currMap.partyPosX, currMap.partyPosY);
+		break;
+	case kCommandMoveRight:
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, 1, currMap.partyPosX, currMap.partyPosY);
+		break;
+	}
+
+	// MISSING CODE: Lots of code
+}
+
+
 }; // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index c52cf6d..ed6bba2 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -131,7 +131,7 @@ public:
 	Common::Point pos;
 	CommandType type;
 
-	Command(Common::Point position, CommandType commandType): pos(position), type(type) {}
+	Command(Common::Point position, CommandType commandType): pos(position), type(commandType) {}
 }; // @ COMMAND
 
 
@@ -189,8 +189,11 @@ class EventManager {
 	Common::Point _pendingClickPos; // @ G0437_i_PendingClickX, G0438_i_PendingClickY
 	MouseButton _pendingClickButton; // @ G0439_i_PendingClickButtonsStatus
 
-	bool _isCommandQueueLocked;
+	bool _isCommandQueueLocked; // this doesn't seem to be used anywhere at all
 	Common::Queue<Command> _commandQueue;
+
+	void commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty
+	void commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty
 public:
 	MouseInput* _primaryMouseInput;// @ G0441_ps_PrimaryMouseInput
 	MouseInput* _secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput
@@ -200,10 +203,11 @@ public:
 	void showMouse(bool visibility);
 
 	void setMousePos(Common::Point pos);
-	void processInput();
+	void processInput(); // acknowledges mouse and keyboard input
 	void processPendingClick(); // @ F0360_COMMAND_ProcessPendingClick
 	void processClick(Common::Point mousePos, MouseButton button); // @	F0359_COMMAND_ProcessClick_CPSC
 	CommandType getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC
+	void processCommandQueue(); // @ F0380_COMMAND_ProcessQueue_CPSC
 };
 
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 3042d8f..8f88bab 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -10,6 +10,8 @@
 
 namespace DM {
 
+Box gBoxMovementArrows = {224, 319, 124, 168};
+
 enum ViewCell {
 	kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT
 	kViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT
@@ -548,11 +550,7 @@ CreatureReplColorSet gCreatureReplColorSets[13] = { // @ G0220_as_Graphic558_Cre
 byte gPalChangesCreature_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 0, 0, 110, 0, 20, 0, 130}; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3
 byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, 120, 130, 140, 150}; // @ G0222_auc_Graphic558_PaletteChanges_Creature_D2
 
-enum GraphicIndice {
-	kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT
-	kDoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
-	kChampionPortraitsIndice = 26 // @ C026_GRAPHIC_CHAMPION_PORTRAITS
-};
+
 
 
 Viewport gDefultViewPort = {0, 0};
@@ -1505,3 +1503,7 @@ void DisplayMan::blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth
 	}
 
 }
+
+byte* DisplayMan::getBitmap(uint16 index) {
+	return _bitmaps[index];
+}
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 50171fe..fd9a4a3 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -7,6 +7,14 @@
 
 namespace DM {
 
+
+enum GraphicIndice {
+	kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT
+	kDoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
+	kChampionPortraitsIndice = 26, // @ C026_GRAPHIC_CHAMPION_PORTRAITS
+	kMovementArrowsIndice = 13 // @ C013_GRAPHIC_MOVEMENT_ARROWS
+};
+
 extern uint16 gPalSwoosh[16];
 extern uint16 gPalMousePointer[16];
 extern uint16 gPalCredits[16];
@@ -20,12 +28,14 @@ public:
 	uint16 Y1;
 	uint16 Y2;
 
-	Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): X1(x1), X2(x2), Y1(y1), Y2(y2) {}
+	Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): X1(x1), X2(x2 + 1), Y1(y1), Y2(y2 + 1) {}
 	bool isPointInside(Common::Point point) {
 		return (X1 <= point.x) && (point.x < X2) && (Y1 <= point.y) && (point.y < Y2);
 	}
 }; // @ BOX_BYTE, BOX_WORD
 
+extern Box gBoxMovementArrows; // G0002_s_Graphic562_Box_MovementArrows
+
 // The frames in the original sources contain inclusive boundaries and byte widths, not pixel widths
 struct Frame {
 	uint16 destFromX, destToX, destFromY, destToY;
@@ -269,6 +279,7 @@ public:
 	void clearScreen(Color color);
 	void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
+	byte* getBitmap(uint16 index);
 
 	int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
 	int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
new file mode 100644
index 0000000..1b4c68d
--- /dev/null
+++ b/engines/dm/menus.cpp
@@ -0,0 +1,18 @@
+#include "menus.h"
+#include "gfx.h"
+
+
+namespace DM {
+
+MenuMan::MenuMan(DMEngine *vm): _vm(vm) {}
+
+void MenuMan::drawMovementArrows() {
+	DisplayMan &disp = *_vm->_displayMan;
+	byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice);
+	Box &dest = gBoxMovementArrows;
+	uint16 w = disp.width(kMovementArrowsIndice);
+
+	disp.blitToScreen(arrowsBitmap, w, 0, 0, dest.X1, dest.X2, dest.Y1, dest.Y2, kColorNoTransparency);
+}
+
+}
\ No newline at end of file
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
new file mode 100644
index 0000000..d4ea2d6
--- /dev/null
+++ b/engines/dm/menus.h
@@ -0,0 +1,18 @@
+#ifndef DM_MENUS_H
+#define DM_MENUS_H
+
+#include "dm.h"
+
+namespace DM {
+
+class MenuMan {
+	DMEngine *_vm;
+public:
+	MenuMan(DMEngine *vm);
+
+	void drawMovementArrows();
+};
+
+}
+
+#endif // !DM_MENUS_H
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index 3078fa5..ed2e2ea 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -5,7 +5,8 @@ MODULE_OBJS := \
 	dm.o \
 	gfx.o \
 	dungeonman.o \
-	eventman.o
+	eventman.o \
+	menus.o
 
 MODULE_DIRS += \
 	engines/dm


Commit: 9b57cdb8ddc6e8c199bd47d1ca04ce49c3280e6d
    https://github.com/scummvm/scummvm/commit/9b57cdb8ddc6e8c199bd47d1ca04ce49c3280e6d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add champion POD and it's enums

Changed paths:
  A engines/dm/champion.cpp
  A engines/dm/champion.h
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/module.mk



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
new file mode 100644
index 0000000..b3a4ad5
--- /dev/null
+++ b/engines/dm/champion.cpp
@@ -0,0 +1,8 @@
+#include "champion.h"
+
+
+namespace DM {
+
+ChampionMan::ChampionMan(DMEngine *vm): _vm(vm) {}
+
+}
\ No newline at end of file
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
new file mode 100644
index 0000000..ab6d491
--- /dev/null
+++ b/engines/dm/champion.h
@@ -0,0 +1,250 @@
+#ifndef DM_CHAMPION_H
+#define DM_CHAMPION_H
+
+#include "dm.h"
+#include "gfx.h"
+
+namespace DM {
+
+enum ChampionIndice {
+	kChampionNone = -1, // @ CM1_CHAMPION_NONE
+	kChampionFirst = 0, // @ C00_CHAMPION_FIRST
+	kChmpionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY
+	kChampionSpecialInventory = 5 // @ C05_CHAMPION_SPECIAL_INVENTORY
+};
+
+enum ChampionAttribute {
+	kChampionAttributNone = 0x0000, // @ MASK0x0000_NONE
+	kChampionAttributeDisableAction = 0x0008, // @ MASK0x0008_DISABLE_ACTION
+	kChampionAttributeMale = 0x0010, // @ MASK0x0010_MALE
+	kChampionAttributeNameTitle = 0x0080, // @ MASK0x0080_NAME_TITLE
+	kChampionAttributeStatistics = 0x0100, // @ MASK0x0100_STATISTICS
+	kChampionAttributeLoad = 0x0200, // @ MASK0x0200_LOAD
+	kChampionAttributeIcon = 0x0400, // @ MASK0x0400_ICON
+	kChampionAttributePanel = 0x0800, // @ MASK0x0800_PANEL
+	kChampionAttributeStatusBox = 0x1000, // @ MASK0x1000_STATUS_BOX
+	kChampionAttributeWounds = 0x2000, // @ MASK0x2000_WOUNDS
+	kChampionAttributeViewport = 0x4000, // @ MASK0x4000_VIEWPORT
+	kChampionAttributeActionHand = 0x8000 // @ MASK0x8000_ACTION_HAND
+};
+
+
+enum ChampionWound {
+	kChampionWoundNone = 0x0000, // @ MASK0x0000_NO_WOUND
+	kChampionWoundReadHand = 0x0001, // @ MASK0x0001_READY_HAND
+	kChampionWoundActionHand = 0x0002, // @ MASK0x0002_ACTION_HAND
+	kChampionWoundHead = 0x0004, // @ MASK0x0004_HEAD
+	kChampionWoundTorso = 0x0008, // @ MASK0x0008_TORSO
+	kChampionWoundLegs = 0x0010, // @ MASK0x0010_LEGS
+	kChampionWoundFeet = 0x0020 // @ MASK0x0020_FEET
+};
+
+
+enum ChampionStatisticType {
+	kChampionStatLuck = 0, // @ C0_STATISTIC_LUCK
+	kChampionStatStrength = 1, // @ C1_STATISTIC_STRENGTH
+	kChampionStatDexterity = 2, // @ C2_STATISTIC_DEXTERITY
+	kChampionStatWisdom = 3, // @ C3_STATISTIC_WISDOM
+	kChampionStatVitality = 4, // @ C4_STATISTIC_VITALITY
+	kChampionStatAntimagic = 5, // @ C5_STATISTIC_ANTIMAGIC
+	kChampionStatAntifire = 6, // @ C6_STATISTIC_ANTIFIRE
+	kChampionStatMana = 8 // @ C8_STATISTIC_MANA /* Used as a fake statistic index for objects granting a Mana bonus */
+};
+
+enum ChampionStatisticValue {
+	kChampionStatMaximum = 0, // @ C0_MAXIMUM
+	kChampionStatCurrent = 1, // @ C1_CURRENT
+	kChampionStatMinimum = 2 // @ C2_MINIMUM
+};
+
+enum ChampionSkill {
+	kChampionSkillFighter = 0, // @ C00_SKILL_FIGHTER
+	kChampionSkillNinja = 1, // @ C01_SKILL_NINJA
+	kChampionSkillPriest = 2, // @ C02_SKILL_PRIEST
+	kChampionSkillWizard = 3, // @ C03_SKILL_WIZARD
+	kChampionSkillSwing = 4, // @ C04_SKILL_SWING
+	kChampionSkillThrust = 5, // @ C05_SKILL_THRUST
+	kChampionSkillClub = 6, // @ C06_SKILL_CLUB
+	kChampionSkillParry = 7, // @ C07_SKILL_PARRY
+	kChampionSkillSteal = 8, // @ C08_SKILL_STEAL
+	kChampionSkillFight = 9, // @ C09_SKILL_FIGHT
+	kChampionSkillThrow = 10, // @ C10_SKILL_THROW
+	kChampionSkillShoot = 11, // @ C11_SKILL_SHOOT
+	kChampionSkillIdentify = 12, // @ C12_SKILL_IDENTIFY
+	kChampionSkillHeal = 13, // @ C13_SKILL_HEAL
+	kChampionSkillInfluence = 14, // @ C14_SKILL_INFLUENCE
+	kChampionSkillDefend = 15, // @ C15_SKILL_DEFEND
+	kChampionSkillFire = 16, // @ C16_SKILL_FIRE
+	kChampionSkillAir = 17, // @ C17_SKILL_AIR
+	kChampionSkillEarth = 18, // @ C18_SKILL_EARTH
+	kChampionSkillWater = 19 // @ C19_SKILL_WATER
+};
+
+enum ChampionSlot {
+	kChampionSlotLeaderHand = -1, // @ CM1_SLOT_LEADER_HAND
+	kChampionSlotReadyHand = 0, // @ C00_SLOT_READY_HAND
+	kChampionSlotActionHand = 1, // @ C01_SLOT_ACTION_HAND
+	kChampionSlotHead = 2, // @ C02_SLOT_HEAD
+	kChampionSlotTorso = 3, // @ C03_SLOT_TORSO
+	kChampionSlotLegs = 4, // @ C04_SLOT_LEGS
+	kChampionSlotFeet = 5, // @ C05_SLOT_FEET
+	kChampionSlotPouch_2 = 6, // @ C06_SLOT_POUCH_2
+	kChampionSlotQuiverLine_2_1 = 7, // @ C07_SLOT_QUIVER_LINE2_1
+	kChampionSlotQuiverLine_1_2 = 8, // @ C08_SLOT_QUIVER_LINE1_2
+	kChampionSlotQuiverLine_2_2 = 9, // @ C09_SLOT_QUIVER_LINE2_2
+	kChampionSlotNeck = 10, // @ C10_SLOT_NECK
+	kChampionSlotPouch_1 = 11, // @ C11_SLOT_POUCH_1
+	kChampionSlotQuiverLine_1_1 = 12, // @ C12_SLOT_QUIVER_LINE1_1
+	kChampionSlotBackpackLine_1_1 = 13, // @ C13_SLOT_BACKPACK_LINE1_1
+	kChampionSlotBackpackLine_2_2 = 14, // @ C14_SLOT_BACKPACK_LINE2_2
+	kChampionSlotBackpackLine_2_3 = 15, // @ C15_SLOT_BACKPACK_LINE2_3
+	kChampionSlotBackpackLine_2_4 = 16, // @ C16_SLOT_BACKPACK_LINE2_4
+	kChampionSlotBackpackLine_2_5 = 17, // @ C17_SLOT_BACKPACK_LINE2_5
+	kChampionSlotBackpackLine_2_6 = 18, // @ C18_SLOT_BACKPACK_LINE2_6
+	kChampionSlotBackpackLine_2_7 = 19, // @ C19_SLOT_BACKPACK_LINE2_7
+	kChampionSlotBackpackLine_2_8 = 20, // @ C20_SLOT_BACKPACK_LINE2_8
+	kChampionSlotBackpackLine_2_9 = 21, // @ C21_SLOT_BACKPACK_LINE2_9
+	kChampionSlotBackpackLine_1_2 = 22, // @ C22_SLOT_BACKPACK_LINE1_2
+	kChampionSlotBackpackLine_1_3 = 23, // @ C23_SLOT_BACKPACK_LINE1_3
+	kChampionSlotBackpackLine_1_4 = 24, // @ C24_SLOT_BACKPACK_LINE1_4
+	kChampionSlotBackpackLine_1_5 = 25, // @ C25_SLOT_BACKPACK_LINE1_5
+	kChampionSlotBackpackLine_1_6 = 26, // @ C26_SLOT_BACKPACK_LINE1_6
+	kChampionSlotBackpackLine_1_7 = 27, // @ C27_SLOT_BACKPACK_LINE1_7
+	kChampionSlotBackpackLine_1_8 = 28, // @ C28_SLOT_BACKPACK_LINE1_8
+	kChampionSlotBackpackLine_1_9 = 29, // @ C29_SLOT_BACKPACK_LINE1_9
+	kChampionSlotChest_1 = 30, // @ C30_SLOT_CHEST_1
+	kChampionSlotChest_2 = 31, // @ C31_SLOT_CHEST_2
+	kChampionSlotChest_3 = 32, // @ C32_SLOT_CHEST_3
+	kChampionSlotChest_4 = 33, // @ C33_SLOT_CHEST_4
+	kChampionSlotChest_5 = 34, // @ C34_SLOT_CHEST_5
+	kChampionSlotChest_6 = 35, // @ C35_SLOT_CHEST_6
+	kChampionSlotChest_7 = 36, // @ C36_SLOT_CHEST_7
+	kChampionSlotChest_8 = 37 // @ C37_SLOT_CHEST_8
+};
+
+enum ChampionAction {
+	kChampionActionN = 0, // @ C000_ACTION_N
+	kChampionActionBlock = 1, // @ C001_ACTION_BLOCK
+	kChampionActionChop = 2, // @ C002_ACTION_CHOP
+	kChampionActionX_C003 = 3, // @ C003_ACTION_X
+	kChampionActionBlowHorn = 4, // @ C004_ACTION_BLOW_HORN
+	kChampionActionFlip = 5, // @ C005_ACTION_FLIP
+	kChampionActionPunch = 6, // @ C006_ACTION_PUNCH
+	kChampionActionKick = 7, // @ C007_ACTION_KICK
+	kChampionActionWarCry = 8, // @ C008_ACTION_WAR_CRY
+	kChampionActionStab_C009 = 9, // @ C009_ACTION_STAB
+	kChampionActionClimbDown = 10, // @ C010_ACTION_CLIMB_DOWN
+	kChampionActionFreezeLife = 11, // @ C011_ACTION_FREEZE_LIFE
+	kChampionActionHit = 12, // @ C012_ACTION_HIT
+	kChampionActionSwing = 13, // @ C013_ACTION_SWING
+	kChampionActionStab_C014 = 14, // @ C014_ACTION_STAB
+	kChampionActionThrust = 15, // @ C015_ACTION_THRUST
+	kChampionActionJab = 16, // @ C016_ACTION_JAB
+	kChampionActionParry = 17, // @ C017_ACTION_PARRY
+	kChampionActionHack = 18, // @ C018_ACTION_HACK
+	kChampionActionBerzerk = 19, // @ C019_ACTION_BERZERK
+	kChampionActionFireball = 20, // @ C020_ACTION_FIREBALL
+	kChampionActionDispel = 21, // @ C021_ACTION_DISPELL
+	kChampionActionConfuse = 22, // @ C022_ACTION_CONFUSE
+	kChampionActionLightning = 23, // @ C023_ACTION_LIGHTNING
+	kChampionActionDisrupt = 24, // @ C024_ACTION_DISRUPT
+	kChampionActionMelee = 25, // @ C025_ACTION_MELEE
+	kChampionActionX_C026 = 26, // @ C026_ACTION_X
+	kChampionActionInvoke = 27, // @ C027_ACTION_INVOKE
+	kChampionActionSlash = 28, // @ C028_ACTION_SLASH
+	kChampionActionCleave = 29, // @ C029_ACTION_CLEAVE
+	kChampionActionBash = 30, // @ C030_ACTION_BASH
+	kChampionActionStun = 31, // @ C031_ACTION_STUN
+	kChampionActionShoot = 32, // @ C032_ACTION_SHOOT
+	kChampionActionSpellshield = 33, // @ C033_ACTION_SPELLSHIELD
+	kChampionActionFireshield = 34, // @ C034_ACTION_FIRESHIELD
+	kChampionActionFluxcage = 35, // @ C035_ACTION_FLUXCAGE
+	kChampionActionHeal = 36, // @ C036_ACTION_HEAL
+	kChampionActionCalm = 37, // @ C037_ACTION_CALM
+	kChampionActionLight = 38, // @ C038_ACTION_LIGHT
+	kChampionActionWindow = 39, // @ C039_ACTION_WINDOW
+	kChampionActionSpit = 40, // @ C040_ACTION_SPIT
+	kChampionActionBrandish = 41, // @ C041_ACTION_BRANDISH
+	kChampionActionThrow = 42, // @ C042_ACTION_THROW
+	kChampionActionFuse = 43, // @ C043_ACTION_FUSE
+	kChampionActionNone = 255 // @ C255_ACTION_NONE
+};
+
+
+class Skill {
+	int TemporaryExperience;
+	long Experience;
+}; // @ SKILL
+
+class Champion {
+	Thing _slots[30];
+	Skill _skills[20];
+public:
+	char _name[8];
+	char _title[20];
+	direction _dir;
+	ViewCell _cell;
+	ChampionAction _actionIndex;
+	uint16 _symbolStep;
+	char _symbols[5];
+	uint16 _directionMaximumDamageReceived;
+	uint16 _maximumDamageReceived;
+	uint16 _poisonEventCount;
+	int16 _enableActionEventIndex;
+	int16 _hideDamageReceivedIndex;
+	uint16 _attributes;
+	uint16 _wounds;
+	int16 _currHealth;
+	int16 _maxHealth;
+	int16 _currStamina;
+	int16 _maxStamina;
+	int16 _currMana;
+	int16 _maxMana;
+	int16 _actionDefense;
+	int16 _food;
+	int16 _water;
+	byte _statistics[7][3];
+	uint16 _load;
+	int16 _shieldDefense;
+	byte Portrait[464]; // 32 x 29 pixel portrait
+
+	Thing getSlot(ChampionSlot slot) { return _slots[slot]; }
+	void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; }
+
+	Skill getSkill(ChampionSkill skill) { return _skills[skill]; }
+	void setSkill(ChampionSkill skill, Skill val) { _skills[skill] = val; }
+
+	byte getStatistic(ChampionStatisticType type, ChampionStatisticValue valType) { return _statistics[type][valType]; }
+	void setStatistic(ChampionStatisticType type, ChampionStatisticValue valType, byte newVal) { _statistics[type][valType] = newVal; }
+
+	uint16 getAttributes() { return _attributes; }
+	void setAttributeFlag(ChampionAttribute flag, bool value) {
+		if (value) {
+			_attributes |= flag;
+		} else {
+			_attributes &= ~flag;
+		}
+	}
+	void clearAttributes(){ _attributes = kChampionAttributNone; }
+
+	uint16 getWounds() { return _wounds; }
+	void setWoundsFlag(ChampionWound flag, bool value) {
+		if (value) {
+			_wounds |= flag;
+		} else {
+			_wounds &= ~flag;
+		}
+	}
+	void clearWounds(){ _wounds = kChampionWoundNone; }
+}; // @ CHAMPION_INCLUDING_PORTRAIT
+
+class ChampionMan {
+	DMEngine *_vm;
+	Champion champions[4];
+public:
+	ChampionMan(DMEngine *vm);
+};
+
+}
+
+#endif
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 488deeb..6a13b84 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -268,7 +268,7 @@ void EventManager::processInput() {
 	Common::Event event;
 	while (_vm->_system->getEventManager()->pollEvent(event)) {
 		switch (event.type) {
-		// DUMMY CODE: EVENT_KEYDOWN, only for testing
+		// DUMMY CODE: case EVENT_KEYDOWN, only for testing
 		case Common::EVENT_KEYDOWN:
 			if (event.synthetic)
 				break;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 8f88bab..61592fd 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -12,14 +12,7 @@ namespace DM {
 
 Box gBoxMovementArrows = {224, 319, 124, 168};
 
-enum ViewCell {
-	kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT
-	kViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT
-	kViewCellBackRight = 2, // @ C02_VIEW_CELL_BACK_RIGHT
-	kViewCellBackLeft = 3, // @ C03_VIEW_CELL_BACK_LEFT
-	kViewCellAlcove = 4, // @ C04_VIEW_CELL_ALCOVE
-	kViewCellDoorButtonOrWallOrn = 5 // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT
-};
+
 
 enum StairFrameIndex {
 	kFrameStairsUpFront_D3L = 0, // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index fd9a4a3..cf06f1c 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -7,6 +7,14 @@
 
 namespace DM {
 
+enum ViewCell {
+	kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT
+	kViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT
+	kViewCellBackRight = 2, // @ C02_VIEW_CELL_BACK_RIGHT
+	kViewCellBackLeft = 3, // @ C03_VIEW_CELL_BACK_LEFT
+	kViewCellAlcove = 4, // @ C04_VIEW_CELL_ALCOVE
+	kViewCellDoorButtonOrWallOrn = 5 // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT
+};
 
 enum GraphicIndice {
 	kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index ed2e2ea..1acf291 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -6,7 +6,8 @@ MODULE_OBJS := \
 	gfx.o \
 	dungeonman.o \
 	eventman.o \
-	menus.o
+	menus.o \
+	champion.o
 
 MODULE_DIRS += \
 	engines/dm


Commit: 42567b744d4a8a2dcc3055d4d43058a1d34fe1c0
    https://github.com/scummvm/scummvm/commit/42567b744d4a8a2dcc3055d4d43058a1d34fe1c0
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix compilation on MSVC9

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 61592fd..b0b2c73 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -10,7 +10,7 @@
 
 namespace DM {
 
-Box gBoxMovementArrows = {224, 319, 124, 168};
+Box gBoxMovementArrows = Box(224, 319, 124, 168);
 
 
 
@@ -1165,8 +1165,8 @@ void DisplayMan::loadFloorSet(FloorSet set) {
 }
 
 
-Box gBoxWallBitmap_D3LCR = {0, 115, 0, 50}; // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR
-Box gBoxWallBitmap_D2LCR = {0, 135, 0, 70}; // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR
+Box gBoxWallBitmap_D3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR
+Box gBoxWallBitmap_D2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR
 
 void DisplayMan::loadWallSet(WallSet set) {
 	uint16 firstIndice = (set * kWallSetGraphicCount) + kFirstWallSet;
@@ -1311,7 +1311,7 @@ void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relInd
 }
 
 
-Box gBoxWallPatchBehindInscription = {110, 113, 37, 63}; // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription 
+Box gBoxWallPatchBehindInscription = Box(110, 113, 37, 63); // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription 
 byte gInscriptionLineY[4] = { // @ G0203_auc_Graphic558_InscriptionLineY
 	48,   /* 1 Line  */
 	59,   /* 2 lines */
@@ -1342,7 +1342,7 @@ byte gUnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableIns
 	46, 53, 63,   /* D2L Front, D2C Front, D2R Front */
 	46, 57, 68}; /* D1L Right, D1R Left */
 
-Box gBoxChampionPortraitOnWall = {96, 127, 35, 63}; // G0109_s_Graphic558_Box_ChampionPortraitOnWall
+Box gBoxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall
 
 bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) {
 	byte *bitmapGreen;


Commit: 75db418e64e7e8753c5c8ab48f322e425c31f9b4
    https://github.com/scummvm/scummvm/commit/75db418e64e7e8753c5c8ab48f322e425c31f9b4
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix a couple of warnings

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index efff5ff..35b299d 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -594,12 +594,12 @@ T0172030_Pit:
 		aspectArray[kTeleporterVisibleAspect] = square.get(kTeleporterOpen) && square.get(kTeleporterVisible);
 		goto T0172029_Teleporter;
 	case kStairsElemType:
-		aspectArray[kElemAspect] = ((square.get(kStairsNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) ? kStairsSideElemType : kStairsFrontElemType;
+		aspectArray[kElemAspect] = ((square.get(kStairsNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) ? kStairsSideElemType : kStairsFrontElemType;
 		aspectArray[kStairsUpAspect] = square.get(kStairsUp);
 		footPrintsAllowed = false;
 		goto T0172046_Stairs;
 	case kDoorElemType:
-		if ((square.get(kDoorNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) {
+		if ((square.get(kDoorNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) {
 			aspectArray[kElemAspect] = kDoorSideElemType;
 		} else {
 			aspectArray[kElemAspect] = kDoorFrontElemType;


Commit: 59af06fd821911c44b44b5338db568b1ae2eff4d
    https://github.com/scummvm/scummvm/commit/59af06fd821911c44b44b5338db568b1ae2eff4d
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some CppCheck warnings

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 40e25d3..7875c5c 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -41,6 +41,13 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	// register random source
 	_rnd = new Common::RandomSource("quux");
 
+	_displayMan = nullptr;
+	_dungeonMan = nullptr;
+	_eventMan = nullptr;
+	_menuMan = nullptr;
+	_stopWaitingForPlayerInput = false;
+	_gameTimeTicking = false;
+
 	debug("DMEngine::DMEngine");
 }
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 384ac1d..de37d3f 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -55,7 +55,7 @@ public:
 	static const Thing thingNone;
 	static const Thing thingEndOfList;
 
-	Thing() {}
+	Thing() : data(0) {}
 	Thing(uint16 d) { set(d); }
 
 	void set(uint16 d) {
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 35b299d..4e09ce4 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -773,7 +773,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 			*destString++ = '\n';
 			sepChar = ' ';
 		} else if (type == kTextTypeInscription) {
-			sepChar = 0x80;
+			sepChar = (char)0x80;
 		} else {
 			sepChar = '\n';
 		}
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 6a13b84..626887e 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -218,6 +218,7 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 	_isCommandQueueLocked = true;
 
 	_dummyMapIndex = 0;
+	_pendingClickButton = kNoneMouseButton;
 }
 
 


Commit: 3ff3512c64fd3e5245b45506203a8d5083598a88
    https://github.com/scummvm/scummvm/commit/3ff3512c64fd3e5245b45506203a8d5083598a88
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add initialization related to F0435_STARTEND_LoadGame_CPSF

Changed paths:
  A engines/dm/loadsave.cpp
  A engines/dm/loadsave.h
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/module.mk



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index b3a4ad5..0e0d5e8 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -5,4 +5,8 @@ namespace DM {
 
 ChampionMan::ChampionMan(DMEngine *vm): _vm(vm) {}
 
+ChampionIndex ChampionMan::getIndexInCell(int16 mapX, int16 mapY, ViewCell cell) {
+	return kChampionNone;
+}
+
 }
\ No newline at end of file
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index ab6d491..36f1689b 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -6,9 +6,12 @@
 
 namespace DM {
 
-enum ChampionIndice {
+enum ChampionIndex {
 	kChampionNone = -1, // @ CM1_CHAMPION_NONE
 	kChampionFirst = 0, // @ C00_CHAMPION_FIRST
+	kChampionSecond = 1,
+	kChampionThird = 2,
+	kChampionFourth = 3,
 	kChmpionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY
 	kChampionSpecialInventory = 5 // @ C05_CHAMPION_SPECIAL_INVENTORY
 };
@@ -242,7 +245,12 @@ class ChampionMan {
 	DMEngine *_vm;
 	Champion champions[4];
 public:
+	uint16 _partChampionCount;
+	bool _partyDead; // @ G0303_B_PartyDead
+	Thing _leaderHand;
+
 	ChampionMan(DMEngine *vm);
+	ChampionIndex getIndexInCell(int16 mapX, int16 mapY, ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell
 };
 
 }
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 7875c5c..77d7ed0 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -16,6 +16,8 @@
 #include "dungeonman.h"
 #include "eventman.h"
 #include "menus.h"
+#include "champion.h"
+#include "loadsave.h"
 
 namespace DM {
 
@@ -41,10 +43,12 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	// register random source
 	_rnd = new Common::RandomSource("quux");
 
-	_displayMan = nullptr;
 	_dungeonMan = nullptr;
+	_displayMan = nullptr;
 	_eventMan = nullptr;
 	_menuMan = nullptr;
+	_championMan = nullptr;
+	_loadsaveMan = nullptr;
 	_stopWaitingForPlayerInput = false;
 	_gameTimeTicking = false;
 
@@ -61,6 +65,8 @@ DMEngine::~DMEngine() {
 	delete _dungeonMan;
 	delete _eventMan;
 	delete _menuMan;
+	delete _championMan;
+	delete _loadsaveMan;
 
 	// clear debug channels
 	DebugMan.clearAllDebugChannels();
@@ -74,14 +80,15 @@ Common::Error DMEngine::run() {
 	_dungeonMan = new DungeonMan(this);
 	_eventMan = new EventManager(this);
 	_menuMan = new MenuMan(this);
+	_championMan = new ChampionMan(this);
+	_loadsaveMan = new LoadsaveMan(this);
 
 	_displayMan->setUpScreens(320, 200);
 
 	_displayMan->loadGraphics();
 
 	_dungeonMan->loadDungeonFile();
-	int16 dummyMapIndex = 0;
-	_dungeonMan->setCurrentMapAndPartyMap(dummyMapIndex);
+	_dungeonMan->setCurrentMapAndPartyMap(0);
 
 
 	_displayMan->loadCurrentMapGraphics();
@@ -90,13 +97,15 @@ Common::Error DMEngine::run() {
 	_eventMan->initMouse();
 	_eventMan->showMouse(true);
 
+	_loadsaveMan->loadgame();
+
 	startGame();
 
 
 	while (true) {
 		_stopWaitingForPlayerInput = false;
 		//do {
-			_eventMan->processInput();
+				_eventMan->processInput();
 			_eventMan->processCommandQueue();
 		//} while (!_stopWaitingForPlayerInput || !_gameTimeTicking);
 
@@ -117,8 +126,11 @@ void DMEngine::startGame() {
 	_eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface;
 	_eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement;
 
+
 	_menuMan->drawMovementArrows();
 	_gameTimeTicking = true;
+
+	// MISSING CODE: Lot of stuff
 }
 
 } // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index de37d3f..67d968a 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -13,6 +13,8 @@ class DisplayMan;
 class DungeonMan;
 class EventManager;
 class MenuMan;
+class ChampionMan;
+class LoadsaveMan;
 
 
 enum direction {
@@ -92,8 +94,12 @@ public:
 	DungeonMan *_dungeonMan;
 	EventManager *_eventMan;
 	MenuMan *_menuMan;
+	ChampionMan *_championMan;
+	LoadsaveMan *_loadsaveMan;
 	bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput
 	bool _gameTimeTicking; // @ G0301_B_GameTimeTicking
+	bool _restartGameAllowed; // @ G0524_B_RestartGameAllowed
+	uint32 _gameId; // @ G0525_l_GameID, probably useless here
 };
 
 class Console : public GUI::Debugger {
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
new file mode 100644
index 0000000..cd522fa
--- /dev/null
+++ b/engines/dm/loadsave.cpp
@@ -0,0 +1,37 @@
+#include "loadsave.h"
+#include "dungeonman.h"
+#include "champion.h"
+
+
+
+namespace DM {
+
+LoadsaveMan::LoadsaveMan(DMEngine *vm) : _vm(vm) {}
+
+
+LoadgameResponse LoadsaveMan::loadgame() {
+	bool newGame = _vm->_dungeonMan->_messages.newGame;
+	ChampionMan &cm = *_vm->_championMan;
+
+	if (newGame) {
+		_vm->_restartGameAllowed = false;
+		cm._partChampionCount = 0;
+		cm._leaderHand = Thing::thingNone;
+		_vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536);
+	} else {
+		assert(false);
+		// MISSING CODE: load game
+	}
+
+
+	if (newGame) {
+		warning("MISSING CODE: Timline init, Group init");
+	} else {
+		assert(false);
+		// MISSING CODE: load game
+	}
+	cm._partyDead = false;
+	return kLoadgameSuccess;
+}
+
+}
\ No newline at end of file
diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h
new file mode 100644
index 0000000..8571912
--- /dev/null
+++ b/engines/dm/loadsave.h
@@ -0,0 +1,25 @@
+#ifndef DM_LOADSAVE_H
+#define DM_LOADSAVE_H
+
+#include "dm.h"
+
+namespace DM {
+
+enum LoadgameResponse {
+	kLoadgameFailure = -1, // @ CM1_LOAD_GAME_FAILURE
+	kLoadgameSuccess = 1// @ C01_LOAD_GAME_SUCCESS
+};
+
+class LoadsaveMan {
+	DMEngine *_vm;
+public:
+	LoadsaveMan(DMEngine *vm);
+
+	LoadgameResponse loadgame(); // @ F0435_STARTEND_LoadGame_CPSF
+
+};
+
+}
+
+#endif
+
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index 1acf291..45a6ed5 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -7,7 +7,8 @@ MODULE_OBJS := \
 	dungeonman.o \
 	eventman.o \
 	menus.o \
-	champion.o
+	champion.o \
+	loadsave.o
 
 MODULE_DIRS += \
 	engines/dm


Commit: 332a515d2cb718fdaa46f8c01875f430dbd03036
    https://github.com/scummvm/scummvm/commit/332a515d2cb718fdaa46f8c01875f430dbd03036
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add getIndexInCell function in ChampionMan

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/loadsave.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 0e0d5e8..0ae0539 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -5,7 +5,12 @@ namespace DM {
 
 ChampionMan::ChampionMan(DMEngine *vm): _vm(vm) {}
 
-ChampionIndex ChampionMan::getIndexInCell(int16 mapX, int16 mapY, ViewCell cell) {
+ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
+	for (uint16 i = 0; i < _partyChampionCount; ++i) {
+		if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
+			return (ChampionIndex)i;
+	}
+
 	return kChampionNone;
 }
 
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 36f1689b..536d367 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -243,14 +243,14 @@ public:
 
 class ChampionMan {
 	DMEngine *_vm;
-	Champion champions[4];
+	Champion _champions[4];
 public:
-	uint16 _partChampionCount;
+	uint16 _partyChampionCount;
 	bool _partyDead; // @ G0303_B_PartyDead
 	Thing _leaderHand;
 
 	ChampionMan(DMEngine *vm);
-	ChampionIndex getIndexInCell(int16 mapX, int16 mapY, ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell
+	ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell
 };
 
 }
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index cd522fa..e58b746 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -15,7 +15,7 @@ LoadgameResponse LoadsaveMan::loadgame() {
 
 	if (newGame) {
 		_vm->_restartGameAllowed = false;
-		cm._partChampionCount = 0;
+		cm._partyChampionCount = 0;
 		cm._leaderHand = Thing::thingNone;
 		_vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536);
 	} else {


Commit: e744d8a42710ae9219e0b48ffb7094b08c0f5f5f
    https://github.com/scummvm/scummvm/commit/e744d8a42710ae9219e0b48ffb7094b08c0f5f5f
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0279_CHAMPION_GetDecodedValue, M27_PORTRAIT_X, M28_PORTRAIT_Y

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 0ae0539..3aabfb0 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -3,7 +3,23 @@
 
 namespace DM {
 
-ChampionMan::ChampionMan(DMEngine *vm): _vm(vm) {}
+ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {}
+
+uint16 ChampionMan::getChampionPortraitX(uint16 index) {
+	return ((index) & 0x7) << 5;
+}
+
+uint16 ChampionMan::getChampionPortraitY(uint16 index) {
+	return ((index) >> 3) * 29;
+}
+
+int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) {
+	int val = 0;
+	for (uint16 i = 0; i < characterCount; ++i) {
+		val = (val << 4) + (string[i] - 'A');
+	}
+	return val;
+}
 
 ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
 	for (uint16 i = 0; i < _partyChampionCount; ++i) {
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 536d367..dc0e11c 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -228,7 +228,7 @@ public:
 			_attributes &= ~flag;
 		}
 	}
-	void clearAttributes(){ _attributes = kChampionAttributNone; }
+	void clearAttributes() { _attributes = kChampionAttributNone; }
 
 	uint16 getWounds() { return _wounds; }
 	void setWoundsFlag(ChampionWound flag, bool value) {
@@ -238,19 +238,24 @@ public:
 			_wounds &= ~flag;
 		}
 	}
-	void clearWounds(){ _wounds = kChampionWoundNone; }
+	void clearWounds() { _wounds = kChampionWoundNone; }
 }; // @ CHAMPION_INCLUDING_PORTRAIT
 
 class ChampionMan {
 	DMEngine *_vm;
 	Champion _champions[4];
+
+	uint16 getChampionPortraitX(uint16 index); // @ M27_PORTRAIT_X
+	uint16 getChampionPortraitY(uint16 index); // @ M28_PORTRAIT_Y
+
+	ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell
+	int16 getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue
 public:
 	uint16 _partyChampionCount;
 	bool _partyDead; // @ G0303_B_PartyDead
 	Thing _leaderHand;
 
 	ChampionMan(DMEngine *vm);
-	ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell
 };
 
 }


Commit: 793ebd32a394bac738c27ac448431ef2c9faed38
    https://github.com/scummvm/scummvm/commit/793ebd32a394bac738c27ac448431ef2c9faed38
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add WEAPON_INFO and related enums

Changed paths:
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 9326156..6d4653e 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -9,6 +9,39 @@
 namespace DM {
 
 
+enum WeaponClass {
+/* Class 0: SWING weapons */
+	kWeaponClassSwingWeapon = 0, // @ C000_CLASS_SWING_WEAPON 
+	/* Class 1 to 15: THROW weapons */
+	kWeaponClassDaggerAndAxes = 2, // @ C002_CLASS_DAGGER_AND_AXES 
+	kWeaponClassBowAmmunition = 10, // @ C010_CLASS_BOW_AMMUNITION
+	kWeaponClassSlingAmmunition = 11, // @ C011_CLASS_SLING_AMMUNITION
+	kWeaponClassPoisinDart = 12, // @ C012_CLASS_POISON_DART
+	/* Class 16 to 111: SHOOT weapons */
+	kWeaponClassFirstBow = 16, // @ C016_CLASS_FIRST_BOW 
+	kWeaponClassLastBow = 31, // @ C031_CLASS_LAST_BOW
+	kWeaponClassFirstSling = 32, // @ C032_CLASS_FIRST_SLING
+	kWeaponClassLastSling = 47, // @ C047_CLASS_LAST_SLING
+	/* Class 112 to 255: Magic and special weapons */
+	kWeaponClassFirstMagicWeapon = 112 // @ C112_CLASS_FIRST_MAGIC_WEAPON
+};
+
+class WeaponInfo {
+		uint16 _attributes; /* Bits 15-13 Unreferenced */
+public:
+        byte _weight;
+        WeaponClass _class;
+        byte _strength;
+        byte _kineticEnergy;
+        
+        WeaponInfo(byte weight, WeaponClass wClass, byte strength, byte kineticEnergy, uint16 attributes)
+        	: _attributes(attributes), _weight(weight), _class(wClass), _strength(strength), _kineticEnergy(kineticEnergy) {}
+
+        uint16 getShootAttack() {return _attributes & 0xFF;} // @ M65_SHOOT_ATTACK
+        uint16 getProjectileAspectOrdinal() {return (_attributes >> 8) & 0x1F;} // @ M66_PROJECTILE_ASPECT_ORDINAL
+}; // @ WEAPON_INFO
+
+
 int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
 int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
 


Commit: ef95c50fbb7acfa97b10a009c1f65e060ba26815
    https://github.com/scummvm/scummvm/commit/ef95c50fbb7acfa97b10a009c1f65e060ba26815
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add gWeaponInfo

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 4e09ce4..3fd2e06 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -6,6 +6,54 @@
 using namespace DM;
 
 
+WeaponInfo gWeaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo
+							   /* { Weight, Class, Strength, KineticEnergy, Attributes } */
+	WeaponInfo(1, (WeaponClass)130,   2,   0, 0x2000),   /* EYE OF TIME */
+	WeaponInfo(1, (WeaponClass)131,   2,   0, 0x2000),   /* STORMRING */
+	WeaponInfo(11, (WeaponClass)0,   8,   2, 0x2000),   /* TORCH */
+	WeaponInfo(12, (WeaponClass)112,  10,  80, 0x2028),   /* FLAMITT */
+	WeaponInfo(9, (WeaponClass)129,  16,   7, 0x2000),   /* STAFF OF CLAWS */
+	WeaponInfo(30, (WeaponClass)113,  49, 110, 0x0942),   /* BOLT BLADE */
+	WeaponInfo(47, (WeaponClass)0,  55,  20, 0x0900),   /* FURY */
+	WeaponInfo(24, (WeaponClass)255,  25,  10, 0x20FF),   /* THE FIRESTAFF */
+	WeaponInfo(5, (WeaponClass)2,  10,  19, 0x0200),   /* DAGGER */
+	WeaponInfo(33, (WeaponClass)0,  30,   8, 0x0900),   /* FALCHION */
+	WeaponInfo(32, (WeaponClass)0,  34,  10, 0x0900),   /* SWORD */
+	WeaponInfo(26, (WeaponClass)0,  38,  10, 0x0900),   /* RAPIER */
+	WeaponInfo(35, (WeaponClass)0,  42,  11, 0x0900),   /* SABRE */
+	WeaponInfo(36, (WeaponClass)0,  46,  12, 0x0900),   /* SAMURAI SWORD */
+	WeaponInfo(33, (WeaponClass)0,  50,  14, 0x0900),   /* DELTA */
+	WeaponInfo(37, (WeaponClass)0,  62,  14, 0x0900),   /* DIAMOND EDGE */
+	WeaponInfo(30, (WeaponClass)0,  48,  13, 0x0000),   /* VORPAL BLADE */
+	WeaponInfo(39, (WeaponClass)0,  58,  15, 0x0900),   /* THE INQUISITOR */
+	WeaponInfo(43, (WeaponClass)2,  49,  33, 0x0300),   /* AXE */
+	WeaponInfo(65, (WeaponClass)2,  70,  44, 0x0300),   /* HARDCLEAVE */
+	WeaponInfo(31, (WeaponClass)0,  32,  10, 0x2000),   /* MACE */
+	WeaponInfo(41, (WeaponClass)0,  42,  13, 0x2000),   /* MACE OF ORDER */
+	WeaponInfo(50, (WeaponClass)0,  60,  15, 0x2000),   /* MORNINGSTAR */
+	WeaponInfo(36, (WeaponClass)0,  19,  10, 0x2700),   /* CLUB */
+	WeaponInfo(110, (WeaponClass)0,  44,  22, 0x2600),   /* STONE CLUB */
+	WeaponInfo(10, (WeaponClass)20,   1,  50, 0x2032),   /* BOW */
+	WeaponInfo(28, (WeaponClass)30,   1, 180, 0x2078),   /* CROSSBOW */
+	WeaponInfo(2, (WeaponClass)10,   2,  10, 0x0100),   /* ARROW */
+	WeaponInfo(2, (WeaponClass)10,   2,  28, 0x0500),   /* SLAYER */
+	WeaponInfo(19, (WeaponClass)39,   5,  20, 0x2032),   /* SLING */
+	WeaponInfo(10, (WeaponClass)11,   6,  18, 0x2000),   /* ROCK */
+	WeaponInfo(3, (WeaponClass)12,   7,  23, 0x0800),   /* POISON DART */
+	WeaponInfo(1, (WeaponClass)1,   3,  19, 0x0A00),   /* THROWING STAR */
+	WeaponInfo(8, (WeaponClass)0,   4,   4, 0x2000),   /* STICK */
+	WeaponInfo(26, (WeaponClass)129,  12,   4, 0x2000),   /* STAFF */
+	WeaponInfo(1, (WeaponClass)130,   0,   0, 0x2000),   /* WAND */
+	WeaponInfo(2, (WeaponClass)140,   1,  20, 0x2000),   /* TEOWAND */
+	WeaponInfo(35, (WeaponClass)128,  18,   6, 0x2000),   /* YEW STAFF */
+	WeaponInfo(29, (WeaponClass)159,   0,   4, 0x2000),   /* STAFF OF MANAR */
+	WeaponInfo(21, (WeaponClass)131,   0,   3, 0x2000),   /* SNAKE STAFF */
+	WeaponInfo(33, (WeaponClass)136,   0,   7, 0x2000),   /* THE CONDUIT */
+	WeaponInfo(8, (WeaponClass)132,   3,   1, 0x2000),   /* DRAGON SPIT */
+	WeaponInfo(18, (WeaponClass)131,   9,   4, 0x2000),   /* SCEPTRE OF LYF */
+	WeaponInfo(8, (WeaponClass)192,   1,   1, 0x2000),   /* HORN OF FEAR */
+	WeaponInfo(30, (WeaponClass)26,   1, 220, 0x207D),   /* SPEEDBOW */
+	WeaponInfo(36, (WeaponClass)255, 100,  50, 0x20FF)}; /* THE FIRESTAFF */
 
 CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo
 												   /* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo,
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 6d4653e..9370572 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -27,15 +27,17 @@ enum WeaponClass {
 };
 
 class WeaponInfo {
-		uint16 _attributes; /* Bits 15-13 Unreferenced */
+
 public:
-        byte _weight;
+        uint16 _weight;
         WeaponClass _class;
-        byte _strength;
-        byte _kineticEnergy;
-        
-        WeaponInfo(byte weight, WeaponClass wClass, byte strength, byte kineticEnergy, uint16 attributes)
-        	: _attributes(attributes), _weight(weight), _class(wClass), _strength(strength), _kineticEnergy(kineticEnergy) {}
+        uint16 _strength;
+        uint16 _kineticEnergy;
+private:
+	uint16 _attributes; /* Bits 15-13 Unreferenced */
+public:
+        WeaponInfo(uint16 weight, WeaponClass wClass, uint16 strength, uint16 kineticEnergy, uint16 attributes)
+        	: _weight(weight), _class(wClass), _strength(strength), _kineticEnergy(kineticEnergy), _attributes(attributes) {}
 
         uint16 getShootAttack() {return _attributes & 0xFF;} // @ M65_SHOOT_ATTACK
         uint16 getProjectileAspectOrdinal() {return (_attributes >> 8) & 0x1F;} // @ M66_PROJECTILE_ASPECT_ORDINAL


Commit: 21be32bb17530ef833a6d60b9a685007a209fac0
    https://github.com/scummvm/scummvm/commit/21be32bb17530ef833a6d60b9a685007a209fac0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add ArmourInfo and realted enums

Changed paths:
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 9370572..f5943cd 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -8,6 +8,25 @@
 
 namespace DM {
 
+				
+enum ArmourAttribute {
+	kArmourAttributeIsAShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD
+	kArmourAttributeSharpDefense = 0x0007, // @ MASK0x0007_SHARP_DEFENSE
+};
+
+class ArmourInfo {
+public:
+	uint16 _weight;
+	uint16 _defense;
+private:
+	uint16 _attributes;
+public:
+	ArmourInfo(uint16 weight, uint16 defense)
+		:_weight(weight), _defense(defense) {}
+
+	uint16 getAttribute(ArmourAttribute attribute) { return _attributes & attribute; }
+	void setAttribute(ArmourAttribute attribute) { _attributes |= attribute; }
+}; // @ ARMOUR_INFO
 
 enum WeaponClass {
 /* Class 0: SWING weapons */


Commit: 5874a7fb56d3e3a0ee1d0cb3e9d243f3080530c3
    https://github.com/scummvm/scummvm/commit/5874a7fb56d3e3a0ee1d0cb3e9d243f3080530c3
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add G0239_as_Graphic559_ArmourInfo

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 3fd2e06..723b6a1 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -6,6 +6,67 @@
 using namespace DM;
 
 
+ArmourInfo gArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo
+/* { Weight, Defense, Attributes, Unreferenced } */
+	ArmourInfo(3,   5, 0x01),   /* CAPE */
+	ArmourInfo(4,  10, 0x01),   /* CLOAK OF NIGHT */
+	ArmourInfo(3,   4, 0x01),   /* BARBARIAN HIDE */
+	ArmourInfo(6,   5, 0x02),   /* SANDALS */
+	ArmourInfo(16,  25, 0x04),   /* LEATHER BOOTS */
+	ArmourInfo(4,   5, 0x00),   /* ROBE */
+	ArmourInfo(4,   5, 0x00),   /* ROBE */
+	ArmourInfo(3,   7, 0x01),   /* FINE ROBE */
+	ArmourInfo(3,   7, 0x01),   /* FINE ROBE */
+	ArmourInfo(4,   6, 0x01),   /* KIRTLE */
+	ArmourInfo(2,   4, 0x00),   /* SILK SHIRT */
+	ArmourInfo(4,   5, 0x01),   /* TABARD */
+	ArmourInfo(5,   7, 0x01),   /* GUNNA */
+	ArmourInfo(3,  11, 0x02),   /* ELVEN DOUBLET */
+	ArmourInfo(3,  13, 0x02),   /* ELVEN HUKE */
+	ArmourInfo(4,  13, 0x02),   /* ELVEN BOOTS */
+	ArmourInfo(6,  17, 0x03),   /* LEATHER JERKIN */
+	ArmourInfo(8,  20, 0x03),   /* LEATHER PANTS */
+	ArmourInfo(14,  20, 0x03),   /* SUEDE BOOTS */
+	ArmourInfo(6,  12, 0x02),   /* BLUE PANTS */
+	ArmourInfo(5,   9, 0x01),   /* TUNIC */
+	ArmourInfo(5,   8, 0x01),   /* GHI */
+	ArmourInfo(5,   9, 0x01),   /* GHI TROUSERS */
+	ArmourInfo(4,   1, 0x04),   /* CALISTA */
+	ArmourInfo(6,   5, 0x04),   /* CROWN OF NERRA */
+	ArmourInfo(11,  12, 0x05),   /* BEZERKER HELM */
+	ArmourInfo(14,  17, 0x05),   /* HELMET */
+	ArmourInfo(15,  20, 0x05),   /* BASINET */
+	ArmourInfo(11,  22, 0x85),   /* BUCKLER */
+	ArmourInfo(10,  16, 0x82),   /* HIDE SHIELD */
+	ArmourInfo(14,  20, 0x83),   /* WOODEN SHIELD */
+	ArmourInfo(21,  35, 0x84),   /* SMALL SHIELD */
+	ArmourInfo(65,  35, 0x05),   /* MAIL AKETON */
+	ArmourInfo(53,  35, 0x05),   /* LEG MAIL */
+	ArmourInfo(52,  70, 0x07),   /* MITHRAL AKETON */
+	ArmourInfo(41,  55, 0x07),   /* MITHRAL MAIL */
+	ArmourInfo(16,  25, 0x06),   /* CASQUE 'N COIF */
+	ArmourInfo(16,  30, 0x06),   /* HOSEN */
+	ArmourInfo(19,  40, 0x07),   /* ARMET */
+	ArmourInfo(120,  65, 0x04),   /* TORSO PLATE */
+	ArmourInfo(80,  56, 0x04),   /* LEG PLATE */
+	ArmourInfo(28,  37, 0x05),   /* FOOT PLATE */
+	ArmourInfo(34,  56, 0x84),   /* LARGE SHIELD */
+	ArmourInfo(17,  62, 0x05),   /* HELM OF LYTE */
+	ArmourInfo(108, 125, 0x04),   /* PLATE OF LYTE */
+	ArmourInfo(72,  90, 0x04),   /* POLEYN OF LYTE */
+	ArmourInfo(24,  50, 0x05),   /* GREAVE OF LYTE */
+	ArmourInfo(30,  85, 0x84),   /* SHIELD OF LYTE */
+	ArmourInfo(35,  76, 0x04),   /* HELM OF DARC */
+	ArmourInfo(141, 160, 0x04),   /* PLATE OF DARC */
+	ArmourInfo(90, 101, 0x04),   /* POLEYN OF DARC */
+	ArmourInfo(31,  60, 0x05),   /* GREAVE OF DARC */
+	ArmourInfo(40, 100, 0x84),   /* SHIELD OF DARC */
+	ArmourInfo(14,  54, 0x06),   /* DEXHELM */
+	ArmourInfo(57,  60, 0x07),   /* FLAMEBAIN */
+	ArmourInfo(81,  88, 0x04),   /* POWERTOWERS */
+	ArmourInfo(3,  16, 0x02),   /* BOOTS OF SPEED */
+	ArmourInfo(2,   3, 0x03)}; /* HALTER */
+
 WeaponInfo gWeaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo
 							   /* { Weight, Class, Strength, KineticEnergy, Attributes } */
 	WeaponInfo(1, (WeaponClass)130,   2,   0, 0x2000),   /* EYE OF TIME */
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index f5943cd..645dd2f 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -21,13 +21,15 @@ public:
 private:
 	uint16 _attributes;
 public:
-	ArmourInfo(uint16 weight, uint16 defense)
-		:_weight(weight), _defense(defense) {}
+	ArmourInfo(uint16 weight, uint16 defense, uint16 attributes)
+		:_weight(weight), _defense(defense), _attributes(attributes) {}
 
 	uint16 getAttribute(ArmourAttribute attribute) { return _attributes & attribute; }
 	void setAttribute(ArmourAttribute attribute) { _attributes |= attribute; }
 }; // @ ARMOUR_INFO
 
+extern ArmourInfo gArmourInfo[58];
+
 enum WeaponClass {
 /* Class 0: SWING weapons */
 	kWeaponClassSwingWeapon = 0, // @ C000_CLASS_SWING_WEAPON 
@@ -62,6 +64,8 @@ public:
         uint16 getProjectileAspectOrdinal() {return (_attributes >> 8) & 0x1F;} // @ M66_PROJECTILE_ASPECT_ORDINAL
 }; // @ WEAPON_INFO
 
+extern WeaponInfo gWeaponInfo[46];
+
 
 int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
 int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL


Commit: c96f24d8fe265306619282685ee9e8f6ac8aac6a
    https://github.com/scummvm/scummvm/commit/c96f24d8fe265306619282685ee9e8f6ac8aac6a
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add G0241_auc_Graphic559_JunkInfo

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 723b6a1..9ec9830 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -5,6 +5,60 @@
 
 using namespace DM;
 
+uint16 gJunkInfo[53] = { // @ G0241_auc_Graphic559_JunkInfo
+	1,   /* COMPASS */
+	3,   /* WATERSKIN */
+	2,   /* JEWEL SYMAL */
+	2,   /* ILLUMULET */
+	4,   /* ASHES */
+	15,  /* BONES */
+	1,   /* COPPER COIN */
+	1,   /* SILVER COIN */
+	1,   /* GOLD COIN */
+	2,   /* IRON KEY */
+	1,   /* KEY OF B */
+	1,   /* SOLID KEY */
+	1,   /* SQUARE KEY */
+	1,   /* TOURQUOISE KEY */
+	1,   /* CROSS KEY */
+	1,   /* ONYX KEY */
+	1,   /* SKELETON KEY */
+	1,   /* GOLD KEY */
+	1,   /* WINGED KEY */
+	1,   /* TOPAZ KEY */
+	1,   /* SAPPHIRE KEY */
+	1,   /* EMERALD KEY */
+	1,   /* RUBY KEY */
+	1,   /* RA KEY */
+	1,   /* MASTER KEY */
+	81,  /* BOULDER */
+	2,   /* BLUE GEM */
+	3,   /* ORANGE GEM */
+	2,   /* GREEN GEM */
+	4,   /* APPLE */
+	4,   /* CORN */
+	3,   /* BREAD */
+	8,   /* CHEESE */
+	5,   /* SCREAMER SLICE */
+	11,  /* WORM ROUND */
+	4,   /* DRUMSTICK */
+	6,   /* DRAGON STEAK */
+	2,   /* GEM OF AGES */
+	3,   /* EKKHARD CROSS */
+	2,   /* MOONSTONE */
+	2,   /* THE HELLION */
+	2,   /* PENDANT FERAL */
+	6,   /* MAGICAL BOX */
+	9,   /* MAGICAL BOX */
+	3,   /* MIRROR OF DAWN */
+	10,  /* ROPE */
+	1,   /* RABBIT'S FOOT */
+	0,   /* CORBAMITE */
+	1,   /* CHOKER */
+	1,   /* LOCK PICKS */
+	2,   /* MAGNIFIER */
+	0,   /* ZOKATHRA SPELL */
+	8}; /* BONES */
 
 ArmourInfo gArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo
 /* { Weight, Defense, Attributes, Unreferenced } */
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 645dd2f..2502a38 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -8,6 +8,7 @@
 
 namespace DM {
 
+extern uint16 gJunkInfo[53];
 				
 enum ArmourAttribute {
 	kArmourAttributeIsAShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD


Commit: d6e90e8a9090ad29406d25ee317332a5500a31de
    https://github.com/scummvm/scummvm/commit/d6e90e8a9090ad29406d25ee317332a5500a31de
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0140_DUNGEON_GetObjectWeight and types for Potions, Armour, Weapons and Junk

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 9ec9830..fa1ec5c 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -3,7 +3,8 @@
 #include "dungeonman.h"
 
 
-using namespace DM;
+
+namespace DM {
 
 uint16 gJunkInfo[53] = { // @ G0241_auc_Graphic559_JunkInfo
 	1,   /* COMPASS */
@@ -529,9 +530,10 @@ void DungeonMan::loadDungeonFile() {
 				_dunData.thingsData[thingType][i][4] = dunDataStream.readUint16BE();
 			}
 		} else {
-			for (uint16 i = 0; i < thingCount; ++i)
+			for (uint16 i = 0; i < thingCount; ++i) {
 				for (uint16 j = 0; j < thingStoreWordCount; ++j)
 					_dunData.thingsData[thingType][i][j] = dunDataStream.readUint16BE();
+			}
 		}
 
 		if (_messages.newGame) {
@@ -993,3 +995,45 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 	}
 	*destString = ((type == kTextTypeInscription) ? 0x81 : '\0');
 }
+
+
+uint16 DungeonMan::getObjectWeight(Thing thing) {
+	if (thing == Thing::thingNone)
+		return 0;
+	switch (thing.getType()) {
+	case kWeaponThingType:
+		return gWeaponInfo[Weapon(getThingData(thing)).getType()]._weight;
+	case kArmourThingType:
+		return gArmourInfo[Armour(getThingData(thing)).getType()]._weight;
+	case kJunkThingType: {
+		Junk junk = getThingData(thing);
+		uint16 weight = gJunkInfo[junk.getType()];
+		if (junk.getType() == kJunkTypeWaterskin)
+			weight += junk.getChargeCount() * 2;
+		return weight;
+	}
+	case kContainerThingType: {
+		uint16 weight = 50;
+		Container container = getThingData(thing);
+		Thing slotThing = container.getNextContainedThing();
+		while (slotThing != Thing::thingEndOfList) {
+			weight += getObjectWeight(slotThing);
+			slotThing = getNextThing(slotThing);
+		}
+		return weight;
+	}
+	case kPotionThingType:
+		if (Junk(getThingData(thing)).getType() == kPotionTypeEmptyFlask) {
+			return 1;
+		} else {
+			return 3;
+		}
+	case kScrollThingType:
+		return 1;
+	}
+
+	assert(false); // this should never be taken
+	return 0; // dummy
+}
+
+}
\ No newline at end of file
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 2502a38..c13d460 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -257,21 +257,43 @@ public:
 	Thing getNextThing() { return nextThing; }
 }; // @ GROUP
 
+enum WeaponType {
+	kWeaponTypeTorch = 2, // @ C02_WEAPON_TORCH
+	kWeaponTypeDagger = 8, // @ C08_WEAPON_DAGGER
+	kWeaponTypeFalchion = 9, // @ C09_WEAPON_FALCHION
+	kWeaponTypeSword = 10, // @ C10_WEAPON_SWORD
+	kWeaponTypeClub = 23, // @ C23_WEAPON_CLUB
+	kWeaponTypeStoneClub = 24, // @ C24_WEAPON_STONE_CLUB
+	kWeaponTypeArrow = 27, // @ C27_WEAPON_ARROW
+	kWeaponTypeSlayer = 28, // @ C28_WEAPON_SLAYER
+	kWeaponTypeRock = 30, // @ C30_WEAPON_ROCK
+	kWeaponTypePoisonDart = 31, // @ C31_WEAPON_POISON_DART
+	kWeaponTypeThrowingStar = 32 // @ C32_WEAPON_THROWING_STAR
+};
 class Weapon {
 	Thing nextThing;
 	uint16 desc;
 public:
 	Weapon(uint16 *rawDat) : nextThing(rawDat[0]), desc(rawDat[1]) {}
 
+	WeaponType getType() { return (WeaponType)(desc & 0x7F); }
 	Thing getNextThing() { return nextThing; }
 }; // @ WEAPON
 
+enum ArmourType {
+	kArmourTypeWoodenShield = 30, // @ C30_ARMOUR_WOODEN_SHIELD
+	kArmourTypeArmet = 38, // @ C38_ARMOUR_ARMET
+	kArmourTypeTorsoPlate = 39, // @ C39_ARMOUR_TORSO_PLATE
+	kArmourTypeLegPlate = 40, // @ C40_ARMOUR_LEG_PLATE
+	kArmourTypeFootPlate = 41 // @ C41_ARMOUR_FOOT_PLATE
+};
 class Armour {
 	Thing nextThing;
 	uint16 attributes;
 public:
 	Armour(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {}
 
+	ArmourType getType() { return (ArmourType)(attributes & 0x7F); }
 	Thing getNextThing() { return nextThing; }
 }; // @ ARMOUR
 
@@ -287,12 +309,28 @@ public:
 	Thing getNextThing() { return nextThing; }
 }; // @ SCROLL
 
+enum PotionType {
+	kPotionTypeVen = 3, // @ C03_POTION_VEN_POTION,
+	kPotionTypeRos = 6, // @ C06_POTION_ROS_POTION,
+	kPotionTypeKu = 7, // @ C07_POTION_KU_POTION,
+	kPotionTypeDane = 8, // @ C08_POTION_DANE_POTION,
+	kPotionTypeNeta = 9, // @ C09_POTION_NETA_POTION,
+	kPotionTypeAntivenin = 10, // @ C10_POTION_ANTIVENIN,
+	kPotionTypeMon = 11, // @ C11_POTION_MON_POTION,
+	kPotionTypeYa = 12, // @ C12_POTION_YA_POTION,
+	kPotionTypeEe = 13, // @ C13_POTION_EE_POTION,
+	kPotionTypeVi = 14, // @ C14_POTION_VI_POTION,
+	kPotionTypeWaterFlask = 15, // @ C15_POTION_WATER_FLASK,
+	kPotionTypeFulBomb = 19, // @ C19_POTION_FUL_BOMB,
+	kPotionTypeEmptyFlask = 20 // @ C20_POTION_EMPTY_FLASK,
+};
 class Potion {
 	Thing nextThing;
 	uint16 attributes;
 public:
 	Potion(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {}
 
+	PotionType getType() { return (PotionType)((attributes >> 8) & 0x7F); }
 	Thing getNextThing() { return nextThing; }
 }; // @ POTION
 
@@ -303,15 +341,32 @@ class Container {
 public:
 	Container(uint16 *rawDat) : nextThing(rawDat[0]), nextContainedThing(rawDat[1]), type(rawDat[2]) {}
 
+	Thing getNextContainedThing() { return nextContainedThing; }
 	Thing getNextThing() { return nextThing; }
 }; // @ CONTAINER
 
+enum JunkType {
+	kJunkTypeWaterskin = 1, // @ C01_JUNK_WATERSKIN,
+	kJunkTypeBones = 5, // @ C05_JUNK_BONES,
+	kJunkTypeBoulder = 25, // @ C25_JUNK_BOULDER,
+	kJunkTypeScreamerSlice = 33, // @ C33_JUNK_SCREAMER_SLICE,
+	kJunkTypeWormRound = 34, // @ C34_JUNK_WORM_ROUND,
+	kJunkTypeDrumstickShank = 35, // @ C35_JUNK_DRUMSTICK_SHANK,
+	kJunkTypeDragonSteak = 36, // @ C36_JUNK_DRAGON_STEAK,
+	kJunkTypeMagicalBoxBlue = 42, // @ C42_JUNK_MAGICAL_BOX_BLUE,
+	kJunkTypeMagicalBoxGreen = 43, // @ C43_JUNK_MAGICAL_BOX_GREEN,
+	kJunkTypeZokathra = 51 // @ C51_JUNK_ZOKATHRA,
+};
+
 class Junk {
 	Thing nextThing;
 	uint16 attributes;
 public:
 	Junk(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {}
 
+	JunkType getType() { return (JunkType)(attributes & 0x7F); }
+	uint16 getChargeCount() { return (attributes >> 14) & 0x3; }
+
 	Thing getNextThing() { return nextThing; }
 }; // @ JUNK
 
@@ -499,6 +554,8 @@ public:
 	void setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect
 	void decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText
 
+	uint16 getObjectWeight(Thing thing);// @ F0140_DUNGEON_GetObjectWeight
+
 	uint32 _rawDunFileDataSize;	 // @ probably NONE
 	byte *_rawDunFileData; // @ ???
 	DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader


Commit: 40e4cceb3feb9da805f2c2dde47802b404a7e5cc
    https://github.com/scummvm/scummvm/commit/40e4cceb3feb9da805f2c2dde47802b404a7e5cc
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0368_COMMAND_SetLeader, G0411_i_LeaderIndex, G0299_ui_CandidateChampionOrdinal

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 3aabfb0..5ba529d 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -3,7 +3,9 @@
 
 namespace DM {
 
-ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {}
+ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
+	_leaderIndex = kChampionNone;
+}
 
 uint16 ChampionMan::getChampionPortraitX(uint16 index) {
 	return ((index) & 0x7) << 5;
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index dc0e11c..353fcf0 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -182,6 +182,9 @@ class Skill {
 class Champion {
 	Thing _slots[30];
 	Skill _skills[20];
+	uint16 _attributes;
+	byte _statistics[7][3];
+	uint16 _wounds;
 public:
 	char _name[8];
 	char _title[20];
@@ -195,8 +198,6 @@ public:
 	uint16 _poisonEventCount;
 	int16 _enableActionEventIndex;
 	int16 _hideDamageReceivedIndex;
-	uint16 _attributes;
-	uint16 _wounds;
 	int16 _currHealth;
 	int16 _maxHealth;
 	int16 _currStamina;
@@ -206,7 +207,6 @@ public:
 	int16 _actionDefense;
 	int16 _food;
 	int16 _water;
-	byte _statistics[7][3];
 	uint16 _load;
 	int16 _shieldDefense;
 	byte Portrait[464]; // 32 x 29 pixel portrait
@@ -243,7 +243,6 @@ public:
 
 class ChampionMan {
 	DMEngine *_vm;
-	Champion _champions[4];
 
 	uint16 getChampionPortraitX(uint16 index); // @ M27_PORTRAIT_X
 	uint16 getChampionPortraitY(uint16 index); // @ M28_PORTRAIT_Y
@@ -251,9 +250,12 @@ class ChampionMan {
 	ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell
 	int16 getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue
 public:
-	uint16 _partyChampionCount;
+	Champion _champions[4];
+	uint16 _partyChampionCount;	// @ G0305_ui_PartyChampionCount
 	bool _partyDead; // @ G0303_B_PartyDead
-	Thing _leaderHand;
+	Thing _leaderHand; // @ G0414_T_LeaderHandObject
+	ChampionIndex _leaderIndex;	// @ G0411_i_LeaderIndex
+	uint16 _candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal
 
 	ChampionMan(DMEngine *vm);
 };
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 626887e..8728dd7 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -420,5 +420,34 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 	// MISSING CODE: Lots of code
 }
 
+void EventManager::commandSetLeader(ChampionIndex index) {
+	ChampionMan &cm = *_vm->_championMan;
+	ChampionIndex leaderIndex;
+
+	if ((cm._leaderIndex == index) || ((index != kChampionNone) && !cm._champions[index]._currHealth))
+		return;
+
+	if (cm._leaderIndex != kChampionNone) {
+		leaderIndex = cm._leaderIndex;
+		cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeLoad, true);
+		cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeNameTitle, true);
+		cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._leaderHand);
+		cm._leaderIndex = kChampionNone;
+		warning("MISSING CODE: F0292_CHAMPION_DrawState");
+	}
+	if (index == kChampionNone) {
+		cm._leaderIndex = kChampionNone;
+		return;
+	}
+	cm._leaderIndex = index;
+	Champion *champion = &cm._champions[cm._leaderIndex];
+	champion->_dir = _vm->_dungeonMan->_currMap.partyDir;
+	cm._champions[index]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHand);
+	if (indexToOrdinal(index) != cm._candidateChampionOrdinal) {
+		champion->setAttributeFlag(kChampionAttributeIcon, true);
+		champion->setAttributeFlag(kChampionAttributeNameTitle, true);
+		warning("MISSING CODE: F0292_CHAMPION_DrawState");
+	}
+}
 
 }; // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index ed6bba2..8984b02 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -3,7 +3,9 @@
 
 #include "common/events.h"
 #include "common/queue.h"
+
 #include "gfx.h"
+#include "champion.h"
 
 
 namespace DM {
@@ -208,6 +210,8 @@ public:
 	void processClick(Common::Point mousePos, MouseButton button); // @	F0359_COMMAND_ProcessClick_CPSC
 	CommandType getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC
 	void processCommandQueue(); // @ F0380_COMMAND_ProcessQueue_CPSC
+
+	void commandSetLeader(ChampionIndex index); // @ F0368_COMMAND_SetLeader
 };
 
 }


Commit: a2328b9eb2867c4b6ce78c4e4bab0c7f3a6cb620
    https://github.com/scummvm/scummvm/commit/a2328b9eb2867c4b6ce78c4e4bab0c7f3a6cb620
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add G0508_B_RefreshActionArea

Changed paths:
    engines/dm/menus.h



diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index d4ea2d6..c1ceddd 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -8,6 +8,7 @@ namespace DM {
 class MenuMan {
 	DMEngine *_vm;
 public:
+	bool _shouldRefreshActionArea; // @ G0508_B_RefreshActionArea
 	MenuMan(DMEngine *vm);
 
 	void drawMovementArrows();


Commit: 7a255919994af82f4a09915f5586f9756ca0348a
    https://github.com/scummvm/scummvm/commit/7a255919994af82f4a09915f5586f9756ca0348a
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rearrange main parts to better align with the original

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/gfx.h
    engines/dm/loadsave.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 77d7ed0..94f9f30 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -72,8 +72,43 @@ DMEngine::~DMEngine() {
 	DebugMan.clearAllDebugChannels();
 }
 
+void DMEngine::initializeGame() {
+	_displayMan->loadGraphics();
+	// DUMMY CODE: next line
+	_displayMan->loadPalette(gPalCredits);
+
+	_eventMan->initMouse();
+
+	while (_loadsaveMan->loadgame() != kLoadgameSuccess) {
+		// MISSING CODE: F0441_STARTEND_ProcessEntrance
+	}
+
+	_displayMan->loadFloorSet(kFloorSetStone);
+	_displayMan->loadWallSet(kWallSetStone);
+
+	startGame();
+	warning("MISSING CODE: F0267_MOVE_GetMoveResult_CPSCE (if newGame)");
+	_eventMan->showMouse(true);
+	warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
+}
+
+
+void DMEngine::startGame() {
+	_eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface;
+	_eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement;
+	// TODO:(next 2 lines) move to F0003_MAIN_ProcessNewPartyMap_CPSE
+	_dungeonMan->setCurrentMapAndPartyMap(0);
+	_displayMan->loadCurrentMapGraphics();
+
+
+	_menuMan->drawMovementArrows();
+	_gameTimeTicking = true;
+
+	// MISSING CODE: Lot of stuff
+}
 
 Common::Error DMEngine::run() {
+	// scummvm/engine specific
 	initGraphics(320, 200, false);
 	_console = new Console(this);
 	_displayMan = new DisplayMan(this);
@@ -82,55 +117,32 @@ Common::Error DMEngine::run() {
 	_menuMan = new MenuMan(this);
 	_championMan = new ChampionMan(this);
 	_loadsaveMan = new LoadsaveMan(this);
-
 	_displayMan->setUpScreens(320, 200);
 
-	_displayMan->loadGraphics();
-
-	_dungeonMan->loadDungeonFile();
-	_dungeonMan->setCurrentMapAndPartyMap(0);
-
-
-	_displayMan->loadCurrentMapGraphics();
-	_displayMan->loadPalette(gPalCredits);
-
-	_eventMan->initMouse();
-	_eventMan->showMouse(true);
-
-	_loadsaveMan->loadgame();
-
-	startGame();
+	initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
+	while (true) {
+		gameloop();
+		// MISSING CODE: F0444_STARTEND_Endgame(G0303_B_PartyDead);
+	}
 
+	return Common::kNoError;
+}
 
+void DMEngine::gameloop() {
 	while (true) {
 		_stopWaitingForPlayerInput = false;
 		//do {
-				_eventMan->processInput();
-			_eventMan->processCommandQueue();
+		_eventMan->processInput();
+		_eventMan->processCommandQueue();
 		//} while (!_stopWaitingForPlayerInput || !_gameTimeTicking);
 
 		_displayMan->clearScreen(kColorBlack);
 		_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY);
-		// DUMMY CODE:
+		// DUMMY CODE: next line
 		_menuMan->drawMovementArrows();
 		_displayMan->updateScreen();
 		_system->delayMillis(10);
 	}
-
-
-	return Common::kNoError;
-}
-
-
-void DMEngine::startGame() {
-	_eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface;
-	_eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement;
-
-
-	_menuMan->drawMovementArrows();
-	_gameTimeTicking = true;
-
-	// MISSING CODE: Lot of stuff
 }
 
 } // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 67d968a..852b210 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -84,7 +84,9 @@ public:
 	DMEngine(OSystem *syst);
 	~DMEngine();
 
-	virtual Common::Error run();
+	virtual Common::Error run(); // @ main
+	void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
+	void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF
 
 private:
 	Console *_console;
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index cf06f1c..241d45b 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -245,8 +245,6 @@ class DisplayMan {
 	void drawSquareD0R(direction dir, int16 posX, int16 posY); // @ F0126_DUNGEONVIEW_DrawSquareD0R
 	void drawSquareD0C(direction dir, int16 posX, int16 posY); // @ F0127_DUNGEONVIEW_DrawSquareD0C
 
-	void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet
-	void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet
 
 	void applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors
 
@@ -258,6 +256,9 @@ public:
 	DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
 
+	void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet
+	void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet
+
 	void setUpScreens(uint16 width, uint16 height);
 	void loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader, F0460_START_InitializeGraphicData
 	void loadCurrentMapGraphics();
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index e58b746..5518e79 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -22,6 +22,7 @@ LoadgameResponse LoadsaveMan::loadgame() {
 		assert(false);
 		// MISSING CODE: load game
 	}
+	_vm->_dungeonMan->loadDungeonFile();
 
 
 	if (newGame) {


Commit: ea33eb8c87cef8ceeb53ce370c527a79553aa1e2
    https://github.com/scummvm/scummvm/commit/ea33eb8c87cef8ceeb53ce370c527a79553aa1e2
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some renaming

Changed paths:
    engines/dm/champion.h
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/loadsave.cpp



diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 353fcf0..5844760 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -175,8 +175,8 @@ enum ChampionAction {
 
 
 class Skill {
-	int TemporaryExperience;
-	long Experience;
+	int _temporaryExperience;
+	long _experience;
 }; // @ SKILL
 
 class Champion {
@@ -209,7 +209,7 @@ public:
 	int16 _water;
 	uint16 _load;
 	int16 _shieldDefense;
-	byte Portrait[464]; // 32 x 29 pixel portrait
+	byte _portrait[464]; // 32 x 29 pixel portrait
 
 	Thing getSlot(ChampionSlot slot) { return _slots[slot]; }
 	void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; }
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 852b210..888e631 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -52,24 +52,24 @@ enum ThingType {
 }; // @ C[00..15]_THING_TYPE_...
 
 class Thing {
-	uint16 data;
+	uint16 _data;
 public:
-	static const Thing thingNone;
-	static const Thing thingEndOfList;
+	static const Thing _thingNone;
+	static const Thing _thingEndOfList;
 
-	Thing() : data(0) {}
+	Thing() : _data(0) {}
 	Thing(uint16 d) { set(d); }
 
 	void set(uint16 d) {
-		data = d;
+		_data = d;
 	}
 
-	byte getCell() const { return data >> 14; }
-	ThingType getType() const { return (ThingType)((data >> 10) & 0xF); }
-	uint16 getIndex() const { return data & 0x1FF; }
-	uint16 toUint16() const { return data; } // I don't like 'em cast operators
-	bool operator==(const Thing &rhs) const { return data == rhs.data; }
-	bool operator!=(const Thing &rhs) const { return data != rhs.data; }
+	byte getCell() const { return _data >> 14; }
+	ThingType getType() const { return (ThingType)((_data >> 10) & 0xF); }
+	uint16 getIndex() const { return _data & 0x1FF; }
+	uint16 toUint16() const { return _data; } // I don't like 'em cast operators
+	bool operator==(const Thing &rhs) const { return _data == rhs._data; }
+	bool operator!=(const Thing &rhs) const { return _data != rhs._data; }
 }; // @ THING
 
 
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index fa1ec5c..80fb733 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -216,17 +216,17 @@ void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, in
 }
 
 DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) {
-	_dunData.columCount = 0;
-	_dunData.eventMaximumCount = 0;
+	_dunData._columCount = 0;
+	_dunData._eventMaximumCount = 0;
 
-	_dunData.mapsFirstColumnIndex = nullptr;
-	_dunData.columnsCumulativeSquareThingCount = nullptr;
-	_dunData.squareFirstThings = nullptr;
-	_dunData.textData = nullptr;
-	_dunData.mapData = nullptr;
+	_dunData._mapsFirstColumnIndex = nullptr;
+	_dunData._columnsCumulativeSquareThingCount = nullptr;
+	_dunData._squareFirstThings = nullptr;
+	_dunData._textData = nullptr;
+	_dunData._mapData = nullptr;
 
 	for (int i = 0; i < 16; i++)
-		_dunData.thingsData[i] = nullptr;
+		_dunData._thingsData[i] = nullptr;
 
 	_currMap.partyDir = kDirNorth;
 	_currMap.partyPosX = 0;
@@ -246,18 +246,18 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL
 	_rawDunFileDataSize = 0;
 	_rawDunFileData = nullptr;
 
-	_fileHeader.dungeonId = 0;
-	_fileHeader.ornamentRandomSeed = 0;
-	_fileHeader.rawMapDataSize = 0;
-	_fileHeader.mapCount = 0;
-	_fileHeader.textDataWordCount = 0;
-	_fileHeader.partyStartDir = kDirNorth;
-	_fileHeader.partyStartPosX = 0;
-	_fileHeader.partyStartPosY = 0;
-	_fileHeader.squareFirstThingCount = 0;
+	_fileHeader._dungeonId = 0;
+	_fileHeader._ornamentRandomSeed = 0;
+	_fileHeader._rawMapDataSize = 0;
+	_fileHeader._mapCount = 0;
+	_fileHeader._textDataWordCount = 0;
+	_fileHeader._partyStartDir = kDirNorth;
+	_fileHeader._partyStartPosX = 0;
+	_fileHeader._partyStartPosY = 0;
+	_fileHeader._squareFirstThingCount = 0;
 
 	for (int i = 0; i < 16; i++)
-		_fileHeader.thingCounts[i] = 0;
+		_fileHeader._thingCounts[i] = 0;
 
 	_maps = nullptr;
 	_rawMapData = nullptr;
@@ -275,15 +275,15 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL
 DungeonMan::~DungeonMan() {
 	delete[] _rawDunFileData;
 	delete[] _maps;
-	delete[] _dunData.mapsFirstColumnIndex;
-	delete[] _dunData.columnsCumulativeSquareThingCount;
-	delete[] _dunData.squareFirstThings;
-	delete[] _dunData.textData;
-	delete[] _dunData.mapData;
+	delete[] _dunData._mapsFirstColumnIndex;
+	delete[] _dunData._columnsCumulativeSquareThingCount;
+	delete[] _dunData._squareFirstThings;
+	delete[] _dunData._textData;
+	delete[] _dunData._mapData;
 	for (uint16 i = 0; i < 16; ++i) {
-		if (_dunData.thingsData[i])
-			delete[] _dunData.thingsData[i][0];
-		delete[] _dunData.thingsData[i];
+		if (_dunData._thingsData[i])
+			delete[] _dunData._thingsData[i][0];
+		delete[] _dunData._thingsData[i];
 	}
 }
 
@@ -384,8 +384,8 @@ unsigned char gThingDataWordCount[16] = {
 	2    /* Explosion */
 }; // @ G0235_auc_Graphic559_ThingDataByteCount
 
-const Thing Thing::thingNone(0);
-const Thing Thing::thingEndOfList(0xFFFE);
+const Thing Thing::_thingNone(0);
+const Thing Thing::_thingEndOfList(0xFFFE);
 
 
 void DungeonMan::loadDungeonFile() {
@@ -395,152 +395,152 @@ void DungeonMan::loadDungeonFile() {
 	Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO);
 
 	// initialize _fileHeader
-	_fileHeader.dungeonId = _fileHeader.ornamentRandomSeed = dunDataStream.readUint16BE();
-	_fileHeader.rawMapDataSize = dunDataStream.readUint16BE();
-	_fileHeader.mapCount = dunDataStream.readByte();
+	_fileHeader._dungeonId = _fileHeader._ornamentRandomSeed = dunDataStream.readUint16BE();
+	_fileHeader._rawMapDataSize = dunDataStream.readUint16BE();
+	_fileHeader._mapCount = dunDataStream.readByte();
 	dunDataStream.readByte(); // discard 1 byte
-	_fileHeader.textDataWordCount = dunDataStream.readUint16BE();
+	_fileHeader._textDataWordCount = dunDataStream.readUint16BE();
 	uint16 partyPosition = dunDataStream.readUint16BE();
-	_fileHeader.partyStartDir = (direction)((partyPosition >> 10) & 3);
-	_fileHeader.partyStartPosY = (partyPosition >> 5) & 0x1F;
-	_fileHeader.partyStartPosX = (partyPosition >> 0) & 0x1F;
-	_fileHeader.squareFirstThingCount = dunDataStream.readUint16BE();
+	_fileHeader._partyStartDir = (direction)((partyPosition >> 10) & 3);
+	_fileHeader._partyStartPosY = (partyPosition >> 5) & 0x1F;
+	_fileHeader._partyStartPosX = (partyPosition >> 0) & 0x1F;
+	_fileHeader._squareFirstThingCount = dunDataStream.readUint16BE();
 	for (uint16 i = 0; i < kThingTypeTotal; ++i)
-		_fileHeader.thingCounts[i] = dunDataStream.readUint16BE();
+		_fileHeader._thingCounts[i] = dunDataStream.readUint16BE();
 
 	// init party position and mapindex
 	if (_messages.newGame) {
-		_currMap.partyDir = _fileHeader.partyStartDir;
-		_currMap.partyPosX = _fileHeader.partyStartPosX;
-		_currMap.partyPosY = _fileHeader.partyStartPosY;
+		_currMap.partyDir = _fileHeader._partyStartDir;
+		_currMap.partyPosX = _fileHeader._partyStartPosX;
+		_currMap.partyPosY = _fileHeader._partyStartPosY;
 		_currMap.currPartyMapIndex = 0;
 	}
 
 	// load map data
 	delete[] _maps;
-	_maps = new Map[_fileHeader.mapCount];
-	for (uint16 i = 0; i < _fileHeader.mapCount; ++i) {
-		_maps[i].rawDunDataOffset = dunDataStream.readUint16BE();
+	_maps = new Map[_fileHeader._mapCount];
+	for (uint16 i = 0; i < _fileHeader._mapCount; ++i) {
+		_maps[i]._rawDunDataOffset = dunDataStream.readUint16BE();
 		dunDataStream.readUint32BE(); // discard 4 bytes
-		_maps[i].offsetMapX = dunDataStream.readByte();
-		_maps[i].offsetMapY = dunDataStream.readByte();
+		_maps[i]._offsetMapX = dunDataStream.readByte();
+		_maps[i]._offsetMapY = dunDataStream.readByte();
 
 		uint16 tmp = dunDataStream.readUint16BE();
-		_maps[i].height = tmp >> 11;
-		_maps[i].width = (tmp >> 6) & 0x1F;
-		_maps[i].level = tmp & 0x1F; // Only used in DMII
+		_maps[i]._height = tmp >> 11;
+		_maps[i]._width = (tmp >> 6) & 0x1F;
+		_maps[i]._level = tmp & 0x1F; // Only used in DMII
 
 		tmp = dunDataStream.readUint16BE();
-		_maps[i].randFloorOrnCount = tmp >> 12;
-		_maps[i].floorOrnCount = (tmp >> 8) & 0xF;
-		_maps[i].randWallOrnCount = (tmp >> 4) & 0xF;
-		_maps[i].wallOrnCount = tmp & 0xF;
+		_maps[i]._randFloorOrnCount = tmp >> 12;
+		_maps[i]._floorOrnCount = (tmp >> 8) & 0xF;
+		_maps[i]._randWallOrnCount = (tmp >> 4) & 0xF;
+		_maps[i]._wallOrnCount = tmp & 0xF;
 
 		tmp = dunDataStream.readUint16BE();
-		_maps[i].difficulty = tmp >> 12;
-		_maps[i].creatureTypeCount = (tmp >> 4) & 0xF;
-		_maps[i].doorOrnCount = tmp & 0xF;
+		_maps[i]._difficulty = tmp >> 12;
+		_maps[i]._creatureTypeCount = (tmp >> 4) & 0xF;
+		_maps[i]._doorOrnCount = tmp & 0xF;
 
 		tmp = dunDataStream.readUint16BE();
-		_maps[i].doorSet1 = (tmp >> 12) & 0xF;
-		_maps[i].doorSet0 = (tmp >> 8) & 0xF;
-		_maps[i].wallSet = (WallSet)((tmp >> 4) & 0xF);
-		_maps[i].floorSet = (FloorSet)(tmp & 0xF);
+		_maps[i]._doorSet1 = (tmp >> 12) & 0xF;
+		_maps[i]._doorSet0 = (tmp >> 8) & 0xF;
+		_maps[i]._wallSet = (WallSet)((tmp >> 4) & 0xF);
+		_maps[i]._floorSet = (FloorSet)(tmp & 0xF);
 	}
 
 	// TODO: ??? is this - begin
-	delete[] _dunData.mapsFirstColumnIndex;
-	_dunData.mapsFirstColumnIndex = new uint16[_fileHeader.mapCount];
+	delete[] _dunData._mapsFirstColumnIndex;
+	_dunData._mapsFirstColumnIndex = new uint16[_fileHeader._mapCount];
 	uint16 columCount = 0;
-	for (uint16 i = 0; i < _fileHeader.mapCount; ++i) {
-		_dunData.mapsFirstColumnIndex[i] = columCount;
-		columCount += _maps[i].width + 1;
+	for (uint16 i = 0; i < _fileHeader._mapCount; ++i) {
+		_dunData._mapsFirstColumnIndex[i] = columCount;
+		columCount += _maps[i]._width + 1;
 	}
-	_dunData.columCount = columCount;
+	_dunData._columCount = columCount;
 	// TODO: ??? is this - end
 
 
-	uint32 actualSquareFirstThingCount = _fileHeader.squareFirstThingCount;
+	uint32 actualSquareFirstThingCount = _fileHeader._squareFirstThingCount;
 	if (_messages.newGame) // TODO: what purpose does this serve?
-		_fileHeader.squareFirstThingCount += 300;
+		_fileHeader._squareFirstThingCount += 300;
 
 	// TODO: ??? is this - begin
-	delete[] _dunData.columnsCumulativeSquareThingCount;
-	_dunData.columnsCumulativeSquareThingCount = new uint16[columCount];
+	delete[] _dunData._columnsCumulativeSquareThingCount;
+	_dunData._columnsCumulativeSquareThingCount = new uint16[columCount];
 	for (uint16 i = 0; i < columCount; ++i)
-		_dunData.columnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE();
+		_dunData._columnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE();
 	// TODO: ??? is this - end
 
 	// TODO: ??? is this - begin
-	delete[] _dunData.squareFirstThings;
-	_dunData.squareFirstThings = new Thing[_fileHeader.squareFirstThingCount];
+	delete[] _dunData._squareFirstThings;
+	_dunData._squareFirstThings = new Thing[_fileHeader._squareFirstThingCount];
 	for (uint16 i = 0; i < actualSquareFirstThingCount; ++i)
-		_dunData.squareFirstThings[i].set(dunDataStream.readUint16BE());
+		_dunData._squareFirstThings[i].set(dunDataStream.readUint16BE());
 	if (_messages.newGame)
 		for (uint16 i = 0; i < 300; ++i)
-			_dunData.squareFirstThings[actualSquareFirstThingCount + i] = Thing::thingNone;
+			_dunData._squareFirstThings[actualSquareFirstThingCount + i] = Thing::_thingNone;
 
 	// TODO: ??? is this - end
 
 	// load text data
-	delete[] _dunData.textData;
-	_dunData.textData = new uint16[_fileHeader.textDataWordCount];
-	for (uint16 i = 0; i < _fileHeader.textDataWordCount; ++i)
-		_dunData.textData[i] = dunDataStream.readUint16BE();
+	delete[] _dunData._textData;
+	_dunData._textData = new uint16[_fileHeader._textDataWordCount];
+	for (uint16 i = 0; i < _fileHeader._textDataWordCount; ++i)
+		_dunData._textData[i] = dunDataStream.readUint16BE();
 
 	// TODO: ??? what this
 	if (_messages.newGame)
-		_dunData.eventMaximumCount = 100;
+		_dunData._eventMaximumCount = 100;
 
 
 	// load things
 	for (uint16 thingType = kDoorThingType; thingType < kThingTypeTotal; ++thingType) {
-		uint16 thingCount = _fileHeader.thingCounts[thingType];
+		uint16 thingCount = _fileHeader._thingCounts[thingType];
 		if (_messages.newGame) {
-			_fileHeader.thingCounts[thingType] = MIN((thingType == kExplosionThingType) ? 768 : 1024, thingCount + gAdditionalThingCounts[thingType]);
+			_fileHeader._thingCounts[thingType] = MIN((thingType == kExplosionThingType) ? 768 : 1024, thingCount + gAdditionalThingCounts[thingType]);
 		}
 		uint16 thingStoreWordCount = gThingDataWordCount[thingType];
 
 		if (thingStoreWordCount == 0)
 			continue;
 
-		if (_dunData.thingsData[thingType]) {
-			delete[] _dunData.thingsData[thingType][0];
-			delete[] _dunData.thingsData[thingType];
+		if (_dunData._thingsData[thingType]) {
+			delete[] _dunData._thingsData[thingType][0];
+			delete[] _dunData._thingsData[thingType];
 		}
-		_dunData.thingsData[thingType] = new uint16*[_fileHeader.thingCounts[thingType]];
-		_dunData.thingsData[thingType][0] = new uint16[_fileHeader.thingCounts[thingType] * thingStoreWordCount];
-		for (uint16 i = 0; i < _fileHeader.thingCounts[thingType]; ++i)
-			_dunData.thingsData[thingType][i] = _dunData.thingsData[thingType][0] + i * thingStoreWordCount;
+		_dunData._thingsData[thingType] = new uint16*[_fileHeader._thingCounts[thingType]];
+		_dunData._thingsData[thingType][0] = new uint16[_fileHeader._thingCounts[thingType] * thingStoreWordCount];
+		for (uint16 i = 0; i < _fileHeader._thingCounts[thingType]; ++i)
+			_dunData._thingsData[thingType][i] = _dunData._thingsData[thingType][0] + i * thingStoreWordCount;
 
 		if (thingType == kGroupThingType) {
 			for (uint16 i = 0; i < thingCount; ++i)
 				for (uint16 j = 0; j < thingStoreWordCount; ++j) {
 					if (j == 2 || j == 3)
-						_dunData.thingsData[thingType][i][j] = dunDataStream.readByte();
+						_dunData._thingsData[thingType][i][j] = dunDataStream.readByte();
 					else
-						_dunData.thingsData[thingType][i][j] = dunDataStream.readUint16BE();
+						_dunData._thingsData[thingType][i][j] = dunDataStream.readUint16BE();
 				}
 		} else if (thingType == kProjectileThingType) {
 			for (uint16 i = 0; i < thingCount; ++i) {
-				_dunData.thingsData[thingType][i][0] = dunDataStream.readUint16BE();
-				_dunData.thingsData[thingType][i][1] = dunDataStream.readUint16BE();
-				_dunData.thingsData[thingType][i][2] = dunDataStream.readByte();
-				_dunData.thingsData[thingType][i][3] = dunDataStream.readByte();
-				_dunData.thingsData[thingType][i][4] = dunDataStream.readUint16BE();
+				_dunData._thingsData[thingType][i][0] = dunDataStream.readUint16BE();
+				_dunData._thingsData[thingType][i][1] = dunDataStream.readUint16BE();
+				_dunData._thingsData[thingType][i][2] = dunDataStream.readByte();
+				_dunData._thingsData[thingType][i][3] = dunDataStream.readByte();
+				_dunData._thingsData[thingType][i][4] = dunDataStream.readUint16BE();
 			}
 		} else {
 			for (uint16 i = 0; i < thingCount; ++i) {
 				for (uint16 j = 0; j < thingStoreWordCount; ++j)
-					_dunData.thingsData[thingType][i][j] = dunDataStream.readUint16BE();
+					_dunData._thingsData[thingType][i][j] = dunDataStream.readUint16BE();
 			}
 		}
 
 		if (_messages.newGame) {
 			if ((thingType == kGroupThingType) || thingType >= kProjectileThingType)
-				_dunData.eventMaximumCount += _fileHeader.thingCounts[thingType];
+				_dunData._eventMaximumCount += _fileHeader._thingCounts[thingType];
 			for (uint16 i = 0; i < gAdditionalThingCounts[thingType]; ++i) {
-				_dunData.thingsData[thingType][thingCount + i][0] = Thing::thingNone.toUint16();
+				_dunData._thingsData[thingType][thingCount + i][0] = Thing::_thingNone.toUint16();
 			}
 		}
 
@@ -553,16 +553,16 @@ void DungeonMan::loadDungeonFile() {
 
 
 	if (!_messages.restartGameRequest) {
-		uint8 mapCount = _fileHeader.mapCount;
-		delete[] _dunData.mapData;
-		_dunData.mapData = new byte**[_dunData.columCount + mapCount];
-		byte **colFirstSquares = (byte**)_dunData.mapData + mapCount;
+		uint8 mapCount = _fileHeader._mapCount;
+		delete[] _dunData._mapData;
+		_dunData._mapData = new byte**[_dunData._columCount + mapCount];
+		byte **colFirstSquares = (byte**)_dunData._mapData + mapCount;
 		for (uint8 i = 0; i < mapCount; ++i) {
-			_dunData.mapData[i] = colFirstSquares;
-			byte *square = _rawMapData + _maps[i].rawDunDataOffset;
+			_dunData._mapData[i] = colFirstSquares;
+			byte *square = _rawMapData + _maps[i]._rawDunDataOffset;
 			*colFirstSquares++ = square;
-			for (uint16 w = 1; w <= _maps[i].width; ++w) {
-				square += _maps[i].height + 1;
+			for (uint16 w = 1; w <= _maps[i]._width; ++w) {
+				square += _maps[i]._height + 1;
 				*colFirstSquares++ = square;
 			}
 		}
@@ -571,12 +571,12 @@ void DungeonMan::loadDungeonFile() {
 
 void DungeonMan::setCurrentMap(uint16 mapIndex) {
 	_currMap.index = mapIndex;
-	_currMap.data = _dunData.mapData[mapIndex];
+	_currMap.data = _dunData._mapData[mapIndex];
 	_currMap.map = _maps + mapIndex;
-	_currMap.width = _maps[mapIndex].width + 1;
-	_currMap.height = _maps[mapIndex].height + 1;
+	_currMap.width = _maps[mapIndex]._width + 1;
+	_currMap.height = _maps[mapIndex]._height + 1;
 	_currMap.colCumulativeSquareFirstThingCount
-		= &_dunData.columnsCumulativeSquareThingCount[_dunData.mapsFirstColumnIndex[mapIndex]];
+		= &_dunData._columnsCumulativeSquareThingCount[_dunData._mapsFirstColumnIndex[mapIndex]];
 }
 
 void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) {
@@ -585,16 +585,16 @@ void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) {
 	byte *metaMapData = _currMap.data[_currMap.width - 1] + _currMap.height;
 	_vm->_displayMan->_currMapAllowedCreatureTypes = metaMapData;
 
-	metaMapData += _currMap.map->creatureTypeCount;
-	memcpy(_vm->_displayMan->_currMapWallOrnIndices, metaMapData, _currMap.map->wallOrnCount);
+	metaMapData += _currMap.map->_creatureTypeCount;
+	memcpy(_vm->_displayMan->_currMapWallOrnIndices, metaMapData, _currMap.map->_wallOrnCount);
 
-	metaMapData += _currMap.map->wallOrnCount;
-	memcpy(_vm->_displayMan->_currMapFloorOrnIndices, metaMapData, _currMap.map->floorOrnCount);
+	metaMapData += _currMap.map->_wallOrnCount;
+	memcpy(_vm->_displayMan->_currMapFloorOrnIndices, metaMapData, _currMap.map->_floorOrnCount);
 
-	metaMapData += _currMap.map->wallOrnCount;
-	memcpy(_vm->_displayMan->_currMapDoorOrnIndices, metaMapData, _currMap.map->doorOrnCount);
+	metaMapData += _currMap.map->_wallOrnCount;
+	memcpy(_vm->_displayMan->_currMapDoorOrnIndices, metaMapData, _currMap.map->_doorOrnCount);
 
-	_currMapInscriptionWallOrnIndex = _currMap.map->wallOrnCount;
+	_currMapInscriptionWallOrnIndex = _currMap.map->_wallOrnCount;
 	_vm->_displayMan->_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = kWallOrnInscription;
 }
 
@@ -651,8 +651,8 @@ int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) {
 Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) {
 	int16 index = getSquareFirstThingIndex(mapX, mapY);
 	if (index == -1)
-		return Thing::thingEndOfList;
-	return _dunData.squareFirstThings[index];
+		return Thing::_thingEndOfList;
+	return _dunData._squareFirstThings[index];
 }
 
 
@@ -701,7 +701,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
 T0172010_ClosedFakeWall:
 		setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall);
 
-		while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) {
+		while ((thing != Thing::_thingEndOfList) && (thing.getType() <= kSensorThingType)) {
 			int16 sideIndex = (thing.getCell() - dir) & 3;
 			if (sideIndex) {
 				if (thing.getType() == kTextstringType) {
@@ -720,7 +720,7 @@ T0172010_ClosedFakeWall:
 			thing = getNextThing(thing);
 		}
 		if (squareIsFakeWall && (_currMap.partyPosX != mapX) && (_currMap.partyPosY != mapY)) {
-			aspectArray[kFirstGroupOrObjectAspect] = Thing::thingEndOfList.toUint16();
+			aspectArray[kFirstGroupOrObjectAspect] = Thing::_thingEndOfList.toUint16();
 			return;
 		}
 		break;
@@ -745,11 +745,11 @@ T0172010_ClosedFakeWall:
 		square = footPrintsAllowed ? 8 : 0;
 		// intentional fallthrough
 	case kCorridorElemType:
-		aspectArray[kFloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(kCorridorRandOrnAllowed), _currMap.map->randFloorOrnCount, mapX, mapY, 30);
+		aspectArray[kFloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(kCorridorRandOrnAllowed), _currMap.map->_randFloorOrnCount, mapX, mapY, 30);
 T0172029_Teleporter:
 		footPrintsAllowed = true;
 T0172030_Pit:
-		while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) {
+		while ((thing != Thing::_thingEndOfList) && (thing.getType() <= kSensorThingType)) {
 			if (thing.getType() == kSensorThingType)
 				aspectArray[kFloorOrnOrdAspect] = Sensor(getThingData(thing)).getOrnOrdinal();
 			thing = getNextThing(thing);
@@ -773,7 +773,7 @@ T0172030_Pit:
 		}
 		footPrintsAllowed = true;
 T0172046_Stairs:
-		while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType))
+		while ((thing != Thing::_thingEndOfList) && (thing.getType() <= kSensorThingType))
 			thing = getNextThing(thing);
 T0172049_Footprints:
 		unsigned char scentOrdinal; // see next line comment
@@ -785,7 +785,7 @@ T0172049_Footprints:
 
 void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
 											int16 mapX, int16 mapY, bool isFakeWall) {
-	int16 ornCount = _currMap.map->randWallOrnCount;
+	int16 ornCount = _currMap.map->_randWallOrnCount;
 
 	turnDirRight(dir);
 	aspectArray[kRightWallOrnOrdAspect] = getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
@@ -805,7 +805,7 @@ void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowe
 int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) {
 	int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1)
 					+ (3000 + (_currMap.index << 6) + _currMap.width + _currMap.height) * 11
-					+ _fileHeader.ornamentRandomSeed) >> 2) % modulo;
+					+ _fileHeader._ornamentRandomSeed) >> 2) % modulo;
 	if (allowed && index < count)
 		return indexToOrdinal(index);
 	return 0;
@@ -821,7 +821,7 @@ bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) {
 }
 
 uint16 *DungeonMan::getThingData(Thing thing) {
-	return _dunData.thingsData[thing.getType()][thing.getIndex()];
+	return _dunData._thingsData[thing.getType()][thing.getIndex()];
 }
 
 Thing DungeonMan::getNextThing(Thing thing) {
@@ -931,7 +931,7 @@ char gInscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_Insc
 
 void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 	char sepChar;
-	TextString textString(_dunData.thingsData[kTextstringType][thing.getIndex()]);
+	TextString textString(_dunData._thingsData[kTextstringType][thing.getIndex()]);
 	if ((textString.isVisible()) || (type & kDecodeEvenIfInvisible)) {
 		type = (TextType)(type & ~kDecodeEvenIfInvisible);
 		if (type == kTextTypeMessage) {
@@ -944,7 +944,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 		}
 		uint16 codeCounter = 0;
 		int16 escChar = 0;
-		uint16 *codeWord = _dunData.textData + textString.getWordOffset();
+		uint16 *codeWord = _dunData._textData + textString.getWordOffset();
 		uint16 code = 0, codes = 0;
 		char *escReplString = nullptr;
 		for (;;) { /*infinite loop*/
@@ -998,7 +998,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 
 
 uint16 DungeonMan::getObjectWeight(Thing thing) {
-	if (thing == Thing::thingNone)
+	if (thing == Thing::_thingNone)
 		return 0;
 	switch (thing.getType()) {
 	case kWeaponThingType:
@@ -1016,7 +1016,7 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 		uint16 weight = 50;
 		Container container = getThingData(thing);
 		Thing slotThing = container.getNextContainedThing();
-		while (slotThing != Thing::thingEndOfList) {
+		while (slotThing != Thing::_thingEndOfList) {
 			weight += getObjectWeight(slotThing);
 			slotThing = getNextThing(slotThing);
 		}
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index c13d460..7ae10f1 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -98,40 +98,40 @@ enum SquareAspectIndice {
 
 
 struct CreatureInfo {
-	byte creatureAspectIndex;
-	byte attackSoundOrdinal;
-	uint16 attributes; /* Bits 15-14 Unreferenced */
-	uint16 graphicInfo; /* Bits 11 and 6 Unreferenced */
-	byte movementTicks; /* Value 255 means the creature cannot move */
-	byte attackTicks; /* Minimum ticks between attacks */
-	byte defense;
-	byte baseHealth;
-	byte attack;
-	byte poisonAttack;
-	byte dexterity;
-	uint16 Ranges; /* Bits 7-4 Unreferenced */
-	uint16 Properties;
-	uint16 Resistances; /* Bits 15-12 and 3-0 Unreferenced */
-	uint16 AnimationTicks; /* Bits 15-12 Unreferenced */
-	uint16 WoundProbabilities; /* Contains 4 probabilities to wound a champion's Head (Bits 15-12), Legs (Bits 11-8), Torso (Bits 7-4) and Feet (Bits 3-0) */
-	byte AttackType;
+	byte _creatureAspectIndex;
+	byte _attackSoundOrdinal;
+	uint16 _attributes; /* Bits 15-14 Unreferenced */
+	uint16 _graphicInfo; /* Bits 11 and 6 Unreferenced */
+	byte _movementTicks; /* Value 255 means the creature cannot move */
+	byte _attackTicks; /* Minimum ticks between attacks */
+	byte _defense;
+	byte _baseHealth;
+	byte _attack;
+	byte _poisonAttack;
+	byte _dexterity;
+	uint16 _ranges; /* Bits 7-4 Unreferenced */
+	uint16 _properties;
+	uint16 _resistances; /* Bits 15-12 and 3-0 Unreferenced */
+	uint16 _animationTicks; /* Bits 15-12 Unreferenced */
+	uint16 _woundProbabilities; /* Contains 4 probabilities to wound a champion's Head (Bits 15-12), Legs (Bits 11-8), Torso (Bits 7-4) and Feet (Bits 3-0) */
+	byte _attackType;
 }; // @ CREATURE_INFO
 
 
 extern CreatureInfo gCreatureInfo[kCreatureTypeCount];
 
 class Door {
-	Thing nextThing;
-	uint16 attributes;
+	Thing _nextThing;
+	uint16 _attributes;
 public:
-	Door(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {}
-	Thing getNextThing() { return nextThing; }
-	bool isMeleeDestructible() { return (attributes >> 8) & 1; }
-	bool isMagicDestructible() { return (attributes >> 7) & 1; }
-	bool hasButton() { return (attributes >> 6) & 1; }
-	bool opensVertically() { return (attributes >> 5) & 1; }
-	byte getOrnOrdinal() { return (attributes >> 1) & 0xF; }
-	byte getType() { return attributes & 1; }
+	Door(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
+	Thing getNextThing() { return _nextThing; }
+	bool isMeleeDestructible() { return (_attributes >> 8) & 1; }
+	bool isMagicDestructible() { return (_attributes >> 7) & 1; }
+	bool hasButton() { return (_attributes >> 6) & 1; }
+	bool opensVertically() { return (_attributes >> 5) & 1; }
+	byte getOrnOrdinal() { return (_attributes >> 1) & 0xF; }
+	byte getType() { return _attributes & 1; }
 }; // @ DOOR
 
 enum TeleporterScope {
@@ -159,14 +159,14 @@ public:
 
 
 class TextString {
-	Thing nextThing;
-	uint16 textDataRef;
+	Thing _nextThing;
+	uint16 _textDataRef;
 public:
-	TextString(uint16 *rawDat) : nextThing(rawDat[0]), textDataRef(rawDat[1]) {}
+	TextString(uint16 *rawDat) : _nextThing(rawDat[0]), _textDataRef(rawDat[1]) {}
 
-	Thing getNextThing() { return nextThing; }
-	uint16 getWordOffset() { return textDataRef >> 3; }
-	bool isVisible() { return textDataRef & 1; }
+	Thing getNextThing() { return _nextThing; }
+	uint16 getWordOffset() { return _textDataRef >> 3; }
+	bool isVisible() { return _textDataRef & 1; }
 }; // @ TEXTSTRING
 
 enum SensorActionType {
@@ -211,50 +211,50 @@ enum SensorType {
 };
 
 class Sensor {
-	Thing nextThing;
-	uint16 datAndType;
-	uint16 attributes;
-	uint16 action;
+	Thing _nextThing;
+	uint16 _datAndType;
+	uint16 _attributes;
+	uint16 _action;
 public:
-	Sensor(uint16 *rawDat) : nextThing(rawDat[0]), datAndType(rawDat[1]), attributes(rawDat[2]), action(rawDat[3]) {}
-
-	Thing getNextThing() { return nextThing; }
-	SensorType getType() { return (SensorType)(datAndType & 0x7F); } // @ M39_TYPE
-	uint16 getData() { return datAndType >> 7; } // @ M40_DATA
-	uint16 getDataMask1() { return (datAndType >> 7) & 0xF; } // @ M42_MASK1
-	uint16 getDataMask2() { return (datAndType >> 11) & 0xF; } // @ M43_MASK2
-	void setData(int16 dat) { datAndType = (datAndType & 0x7F) | (dat << 7); } // @ M41_SET_DATA
-	void setTypeDisabled() { datAndType &= 0xFF80; } // @ M44_SET_TYPE_DISABLED
-	uint16 getOrnOrdinal() { return attributes >> 12; }
-	bool isLocalAction() { return (attributes >> 11) & 1; }
-	uint16 getDelay() { return (attributes >> 7) & 0xF; }
-	bool hasSound() { return (attributes >> 6) & 1; }
-	bool shouldRevert() { return (attributes >> 5) & 1; }
-	SensorActionType getActionType() { return (SensorActionType)((attributes >> 3) & 3); }
-	bool isSingleUse() { return (attributes >> 2) & 1; }
-	uint16 getRemoteMapY() { return (action >> 11); }
-	uint16 getRemoteMapX() { return (action >> 6) & 0x1F; }
-	direction getRemoteDir() { return (direction)((action >> 4) & 3); }
-	uint16 getLocalAction() { return (action >> 4); }
+	Sensor(uint16 *rawDat) : _nextThing(rawDat[0]), _datAndType(rawDat[1]), _attributes(rawDat[2]), _action(rawDat[3]) {}
+
+	Thing getNextThing() { return _nextThing; }
+	SensorType getType() { return (SensorType)(_datAndType & 0x7F); } // @ M39_TYPE
+	uint16 getData() { return _datAndType >> 7; } // @ M40_DATA
+	uint16 getDataMask1() { return (_datAndType >> 7) & 0xF; } // @ M42_MASK1
+	uint16 getDataMask2() { return (_datAndType >> 11) & 0xF; } // @ M43_MASK2
+	void setData(int16 dat) { _datAndType = (_datAndType & 0x7F) | (dat << 7); } // @ M41_SET_DATA
+	void setTypeDisabled() { _datAndType &= 0xFF80; } // @ M44_SET_TYPE_DISABLED
+	uint16 getOrnOrdinal() { return _attributes >> 12; }
+	bool isLocalAction() { return (_attributes >> 11) & 1; }
+	uint16 getDelay() { return (_attributes >> 7) & 0xF; }
+	bool hasSound() { return (_attributes >> 6) & 1; }
+	bool shouldRevert() { return (_attributes >> 5) & 1; }
+	SensorActionType getActionType() { return (SensorActionType)((_attributes >> 3) & 3); }
+	bool isSingleUse() { return (_attributes >> 2) & 1; }
+	uint16 getRemoteMapY() { return (_action >> 11); }
+	uint16 getRemoteMapX() { return (_action >> 6) & 0x1F; }
+	direction getRemoteDir() { return (direction)((_action >> 4) & 3); }
+	uint16 getLocalAction() { return (_action >> 4); }
 	// some macros missing, i got bored
 }; // @ SENSOR
 
 class Group {
-	Thing nextThing;
-	Thing possessionID;
-	byte type;
-	byte position;
-	uint16 health[4];
-	uint16 attributes;
+	Thing _nextThing;
+	Thing _possessionID;
+	byte _type;
+	byte _position;
+	uint16 _health[4];
+	uint16 _attributes;
 public:
-	Group(uint16 *rawDat) : nextThing(rawDat[0]), possessionID(rawDat[1]), type(rawDat[2]),
-		position(rawDat[3]), attributes(rawDat[8]) {
-		health[0] = rawDat[4];
-		health[1] = rawDat[5];
-		health[2] = rawDat[6];
-		health[3] = rawDat[7];
+	Group(uint16 *rawDat) : _nextThing(rawDat[0]), _possessionID(rawDat[1]), _type(rawDat[2]),
+		_position(rawDat[3]), _attributes(rawDat[8]) {
+		_health[0] = rawDat[4];
+		_health[1] = rawDat[5];
+		_health[2] = rawDat[6];
+		_health[3] = rawDat[7];
 	}
-	Thing getNextThing() { return nextThing; }
+	Thing getNextThing() { return _nextThing; }
 }; // @ GROUP
 
 enum WeaponType {
@@ -271,13 +271,13 @@ enum WeaponType {
 	kWeaponTypeThrowingStar = 32 // @ C32_WEAPON_THROWING_STAR
 };
 class Weapon {
-	Thing nextThing;
-	uint16 desc;
+	Thing _nextThing;
+	uint16 _desc;
 public:
-	Weapon(uint16 *rawDat) : nextThing(rawDat[0]), desc(rawDat[1]) {}
+	Weapon(uint16 *rawDat) : _nextThing(rawDat[0]), _desc(rawDat[1]) {}
 
-	WeaponType getType() { return (WeaponType)(desc & 0x7F); }
-	Thing getNextThing() { return nextThing; }
+	WeaponType getType() { return (WeaponType)(_desc & 0x7F); }
+	Thing getNextThing() { return _nextThing; }
 }; // @ WEAPON
 
 enum ArmourType {
@@ -288,25 +288,25 @@ enum ArmourType {
 	kArmourTypeFootPlate = 41 // @ C41_ARMOUR_FOOT_PLATE
 };
 class Armour {
-	Thing nextThing;
-	uint16 attributes;
+	Thing _nextThing;
+	uint16 _attributes;
 public:
-	Armour(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {}
+	Armour(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 
-	ArmourType getType() { return (ArmourType)(attributes & 0x7F); }
-	Thing getNextThing() { return nextThing; }
+	ArmourType getType() { return (ArmourType)(_attributes & 0x7F); }
+	Thing getNextThing() { return _nextThing; }
 }; // @ ARMOUR
 
 class Scroll {
-	Thing nextThing;
-	uint16 attributes;
+	Thing _nextThing;
+	uint16 _attributes;
 public:
-	Scroll(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {}
+	Scroll(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 	void set(Thing next, uint16 attribs) {
-		nextThing = next;
-		attributes = attribs;
+		_nextThing = next;
+		_attributes = attribs;
 	}
-	Thing getNextThing() { return nextThing; }
+	Thing getNextThing() { return _nextThing; }
 }; // @ SCROLL
 
 enum PotionType {
@@ -325,24 +325,24 @@ enum PotionType {
 	kPotionTypeEmptyFlask = 20 // @ C20_POTION_EMPTY_FLASK,
 };
 class Potion {
-	Thing nextThing;
-	uint16 attributes;
+	Thing _nextThing;
+	uint16 _attributes;
 public:
-	Potion(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {}
+	Potion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 
-	PotionType getType() { return (PotionType)((attributes >> 8) & 0x7F); }
-	Thing getNextThing() { return nextThing; }
+	PotionType getType() { return (PotionType)((_attributes >> 8) & 0x7F); }
+	Thing getNextThing() { return _nextThing; }
 }; // @ POTION
 
 class Container {
-	Thing nextThing;
-	Thing nextContainedThing;
-	uint16 type;
+	Thing _nextThing;
+	Thing _nextContainedThing;
+	uint16 _type;
 public:
-	Container(uint16 *rawDat) : nextThing(rawDat[0]), nextContainedThing(rawDat[1]), type(rawDat[2]) {}
+	Container(uint16 *rawDat) : _nextThing(rawDat[0]), _nextContainedThing(rawDat[1]), _type(rawDat[2]) {}
 
-	Thing getNextContainedThing() { return nextContainedThing; }
-	Thing getNextThing() { return nextThing; }
+	Thing getNextContainedThing() { return _nextContainedThing; }
+	Thing getNextThing() { return _nextThing; }
 }; // @ CONTAINER
 
 enum JunkType {
@@ -359,37 +359,37 @@ enum JunkType {
 };
 
 class Junk {
-	Thing nextThing;
-	uint16 attributes;
+	Thing _nextThing;
+	uint16 _attributes;
 public:
-	Junk(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {}
+	Junk(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 
-	JunkType getType() { return (JunkType)(attributes & 0x7F); }
-	uint16 getChargeCount() { return (attributes >> 14) & 0x3; }
+	JunkType getType() { return (JunkType)(_attributes & 0x7F); }
+	uint16 getChargeCount() { return (_attributes >> 14) & 0x3; }
 
-	Thing getNextThing() { return nextThing; }
+	Thing getNextThing() { return _nextThing; }
 }; // @ JUNK
 
 class Projectile {
-	Thing nextThing;
-	Thing object;
-	byte kineticEnergy;
-	byte damageEnergy;
-	uint16 timerIndex;
+	Thing _nextThing;
+	Thing _object;
+	byte _kineticEnergy;
+	byte _damageEnergy;
+	uint16 _timerIndex;
 public:
-	Projectile(uint16 *rawDat) : nextThing(rawDat[0]), object(rawDat[1]), kineticEnergy(rawDat[2]),
-		damageEnergy(rawDat[3]), timerIndex(rawDat[4]) {}
+	Projectile(uint16 *rawDat) : _nextThing(rawDat[0]), _object(rawDat[1]), _kineticEnergy(rawDat[2]),
+		_damageEnergy(rawDat[3]), _timerIndex(rawDat[4]) {}
 
-	Thing getNextThing() { return nextThing; }
+	Thing getNextThing() { return _nextThing; }
 }; // @ PROJECTILE
 
 class Explosion {
-	Thing nextThing;
-	uint16 attributes;
+	Thing _nextThing;
+	uint16 _attributes;
 public:
-	Explosion(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {}
+	Explosion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 
-	Thing getNextThing() { return nextThing; }
+	Thing getNextThing() { return _nextThing; }
 }; // @ EXPLOSION
 
 
@@ -431,70 +431,70 @@ enum SquareType {
 }; // @ C[-2..19]_ELEMENT_...
 
 class Square {
-	byte data;
+	byte _data;
 public:
-	Square(byte dat = 0) : data(dat) {}
+	Square(byte dat = 0) : _data(dat) {}
 	Square(SquareType type) { setType(type); }
-	Square &set(byte dat) { this->data = dat; return *this; }
-	Square &set(SquareMask mask) { data |= mask; return *this; }
-	byte get(SquareMask mask) { return data & mask; }
-	byte getDoorState() { return data & 0x7; } // @ M36_DOOR_STATE
-	Square &setDoorState(byte state) { data = ((data & ~0x7) | state); } // @ M37_SET_DOOR_STATE
-	SquareType getType() { return (SquareType)(data >> 5); } // @ M34_SQUARE_TYPE
-	Square &setType(SquareType type) { data = (data & 0x1F) | type << 5; return *this; }
-	byte toByte() { return data; } // I don't like 'em casts
+	Square &set(byte dat) { this->_data = dat; return *this; }
+	Square &set(SquareMask mask) { _data |= mask; return *this; }
+	byte get(SquareMask mask) { return _data & mask; }
+	byte getDoorState() { return _data & 0x7; } // @ M36_DOOR_STATE
+	Square &setDoorState(byte state) { _data = ((_data & ~0x7) | state); } // @ M37_SET_DOOR_STATE
+	SquareType getType() { return (SquareType)(_data >> 5); } // @ M34_SQUARE_TYPE
+	Square &setType(SquareType type) { _data = (_data & 0x1F) | type << 5; return *this; }
+	byte toByte() { return _data; } // I don't like 'em casts
 };
 
 struct DungeonFileHeader {
-	uint16 dungeonId; // @ G0526_ui_DungeonID
+	uint16 _dungeonId; // @ G0526_ui_DungeonID
 	// equal to dungeonId
-	uint16 ornamentRandomSeed;
-	uint32 rawMapDataSize;
-	uint8 mapCount;
-	uint16 textDataWordCount;
-	direction partyStartDir; // @ InitialPartyLocation
-	uint16 partyStartPosX, partyStartPosY;
-	uint16 squareFirstThingCount; // @ SquareFirstThingCount
-	uint16 thingCounts[16]; // @ ThingCount[16]
+	uint16 _ornamentRandomSeed;
+	uint32 _rawMapDataSize;
+	uint8 _mapCount;
+	uint16 _textDataWordCount;
+	direction _partyStartDir; // @ InitialPartyLocation
+	uint16 _partyStartPosX, _partyStartPosY;
+	uint16 _squareFirstThingCount; // @ SquareFirstThingCount
+	uint16 _thingCounts[16]; // @ ThingCount[16]
 }; // @ DUNGEON_HEADER
 
 struct Map {
-	uint32 rawDunDataOffset;
-	uint8 offsetMapX, offsetMapY;
+	uint32 _rawDunDataOffset;
+	uint8 _offsetMapX, _offsetMapY;
 
-	uint8 level; // only used in DMII
-	uint8 width, height; // !!! THESRE ARE INCLUSIVE BOUNDARIES
+	uint8 _level; // only used in DMII
+	uint8 _width, _height; // !!! THESRE ARE INCLUSIVE BOUNDARIES
 	// orn short for Ornament
-	uint8 wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */
-	uint8 randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */
-	uint8 floorOrnCount; /* May be used in a Sensor on a Pit, open Fake Wall, Corridor or Teleporter square */
-	uint8 randFloorOrnCount; /* Used only on some Corridor squares and some open Fake Wall squares */
-
-	uint8 doorOrnCount;
-	uint8 creatureTypeCount;
-	uint8 difficulty;
-
-	FloorSet floorSet;
-	WallSet wallSet;
-	uint8 doorSet0, doorSet1;
+	uint8 _wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */
+	uint8 _randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */
+	uint8 _floorOrnCount; /* May be used in a Sensor on a Pit, open Fake Wall, Corridor or Teleporter square */
+	uint8 _randFloorOrnCount; /* Used only on some Corridor squares and some open Fake Wall squares */
+
+	uint8 _doorOrnCount;
+	uint8 _creatureTypeCount;
+	uint8 _difficulty;
+
+	FloorSet _floorSet;
+	WallSet _wallSet;
+	uint8 _doorSet0, _doorSet1;
 }; // @ MAP
 
 struct DungeonData {
 	// I have no idea the heck is this
-	uint16 *mapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex
-	uint16 columCount; // @ G0282_ui_DungeonColumnCount
+	uint16 *_mapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex
+	uint16 _columCount; // @ G0282_ui_DungeonColumnCount
 
 	// I have no idea the heck is this
-	uint16 *columnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
-	Thing *squareFirstThings; // @ G0283_pT_SquareFirstThings
-	uint16 *textData; // @ G0260_pui_DungeonTextData
+	uint16 *_columnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
+	Thing *_squareFirstThings; // @ G0283_pT_SquareFirstThings
+	uint16 *_textData; // @ G0260_pui_DungeonTextData
 
-	uint16 **thingsData[16]; // @ G0284_apuc_ThingData
+	uint16 **_thingsData[16]; // @ G0284_apuc_ThingData
 
-	byte ***mapData; // @ G0279_pppuc_DungeonMapData
+	byte ***_mapData; // @ G0279_pppuc_DungeonMapData
 
 	// TODO: ??? is this doing here
-	uint16 eventMaximumCount; // @ G0369_ui_EventMaximumCount
+	uint16 _eventMaximumCount; // @ G0369_ui_EventMaximumCount
 }; // @ AGGREGATE
 
 struct CurrMapData {
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index b0b2c73..13ec773 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -613,7 +613,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	for (int i = 0; i < 18; i++)
 		_currMapDoorOrnIndices[i] = 0;
 
-	_inscriptionThing = Thing::thingNone;
+	_inscriptionThing = Thing::_thingNone;
 }
 
 DisplayMan::~DisplayMan() {
@@ -1218,12 +1218,12 @@ void DisplayMan::loadWallSet(WallSet set) {
 
 
 void DisplayMan::loadCurrentMapGraphics() {
-	loadFloorSet(_vm->_dungeonMan->_currMap.map->floorSet);
-	loadWallSet(_vm->_dungeonMan->_currMap.map->wallSet);
+	loadFloorSet(_vm->_dungeonMan->_currMap.map->_floorSet);
+	loadWallSet(_vm->_dungeonMan->_currMap.map->_wallSet);
 
 	// the original loads some flipped walls here, I moved it to loadWallSet
 
-	for (uint16 i = 0, firstGraphicIndex = _vm->_dungeonMan->_currMap.map->wallSet * kStairsGraphicCount + kFirstStairs; i < kStairsGraphicCount; ++i)
+	for (uint16 i = 0, firstGraphicIndex = _vm->_dungeonMan->_currMap.map->_wallSet * kStairsGraphicCount + kFirstStairs; i < kStairsGraphicCount; ++i)
 		_stairIndices[i] = firstGraphicIndex + i;
 
 	for (int16 i = 0; i < kAlcoveOrnCount; ++i)
@@ -1240,7 +1240,7 @@ void DisplayMan::loadCurrentMapGraphics() {
 
 	_currMapViAltarIndex = -1;
 
-	for (uint16 i = 0; i < currMap.wallOrnCount; ++i) {
+	for (uint16 i = 0; i < currMap._wallOrnCount; ++i) {
 		uint16 ornIndice = _currMapWallOrnIndices[i];
 		uint16 nativeIndice = kFirstWallOrn + ornIndice * 2;
 
@@ -1260,14 +1260,14 @@ void DisplayMan::loadCurrentMapGraphics() {
 		_currMapWallOrnInfo[i][kNativeCoordinateSet] = gWallOrnCoordSetIndices[ornIndice];
 	}
 
-	for (uint16 i = 0; i < currMap.floorOrnCount; ++i) {
+	for (uint16 i = 0; i < currMap._floorOrnCount; ++i) {
 		uint16 ornIndice = _currMapFloorOrnIndices[i];
 		uint16 nativeIndice = kFirstFloorOrn + ornIndice * 6;
 		_currMapFloorOrnInfo[i][kNativeBitmapIndex] = nativeIndice;
 		_currMapFloorOrnInfo[i][kNativeCoordinateSet] = gFloorOrnCoordSetIndices[ornIndice];
 	}
 
-	for (uint16 i = 0; i < currMap.doorOrnCount; ++i) {
+	for (uint16 i = 0; i < currMap._doorOrnCount; ++i) {
 		uint16 ornIndice = _currMapDoorOrnIndices[i];
 		uint16 nativeIndice = kFirstDoorOrn + ornIndice;
 		_currMapDoorOrnInfo[i][kNativeBitmapIndex] = nativeIndice;
@@ -1277,7 +1277,7 @@ void DisplayMan::loadCurrentMapGraphics() {
 	applyCreatureReplColors(9, 8);
 	applyCreatureReplColors(10, 12);
 
-	for (uint16 creatureType = 0; creatureType < currMap.creatureTypeCount; ++creatureType) {
+	for (uint16 creatureType = 0; creatureType < currMap._creatureTypeCount; ++creatureType) {
 		CreatureAspect &aspect = gCreatureAspects[_currMapAllowedCreatureTypes[creatureType]];
 		uint16 replColorOrdinal = aspect.getReplColour9();
 		if (replColorOrdinal)
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 5518e79..a153d8e 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -16,7 +16,7 @@ LoadgameResponse LoadsaveMan::loadgame() {
 	if (newGame) {
 		_vm->_restartGameAllowed = false;
 		cm._partyChampionCount = 0;
-		cm._leaderHand = Thing::thingNone;
+		cm._leaderHand = Thing::_thingNone;
 		_vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536);
 	} else {
 		assert(false);


Commit: 9ad057a4864ac33a16ec0fb9ab8124a2526b1f1a
    https://github.com/scummvm/scummvm/commit/9ad057a4864ac33a16ec0fb9ab8124a2526b1f1a
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some more renaming, remove extra semi-column

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/loadsave.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 94f9f30..2ff815c 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -137,7 +137,7 @@ void DMEngine::gameloop() {
 		//} while (!_stopWaitingForPlayerInput || !_gameTimeTicking);
 
 		_displayMan->clearScreen(kColorBlack);
-		_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY);
+		_displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY);
 		// DUMMY CODE: next line
 		_menuMan->drawMovementArrows();
 		_displayMan->updateScreen();
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 80fb733..6b577ca 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -228,20 +228,20 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL
 	for (int i = 0; i < 16; i++)
 		_dunData._thingsData[i] = nullptr;
 
-	_currMap.partyDir = kDirNorth;
-	_currMap.partyPosX = 0;
-	_currMap.partyPosY = 0;
-	_currMap.currPartyMapIndex = 0;
-	_currMap.index = 0;
-	_currMap.width = 0;
-	_currMap.height = 0;
+	_currMap._partyDir = kDirNorth;
+	_currMap._partyPosX = 0;
+	_currMap._partyPosY = 0;
+	_currMap._currPartyMapIndex = 0;
+	_currMap._index = 0;
+	_currMap._width = 0;
+	_currMap._height = 0;
 
-	_currMap.data = nullptr;
-	_currMap.map = nullptr;
-	_currMap.colCumulativeSquareFirstThingCount = nullptr;
+	_currMap._data = nullptr;
+	_currMap._map = nullptr;
+	_currMap._colCumulativeSquareFirstThingCount = nullptr;
 
-	_messages.newGame = true;
-	_messages.restartGameRequest = false;
+	_messages._newGame = true;
+	_messages._restartGameRequest = false;
 
 	_rawDunFileDataSize = 0;
 	_rawDunFileData = nullptr;
@@ -389,7 +389,7 @@ const Thing Thing::_thingEndOfList(0xFFFE);
 
 
 void DungeonMan::loadDungeonFile() {
-	if (_messages.newGame)
+	if (_messages._newGame)
 		decompressDungeonFile();
 
 	Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO);
@@ -409,11 +409,11 @@ void DungeonMan::loadDungeonFile() {
 		_fileHeader._thingCounts[i] = dunDataStream.readUint16BE();
 
 	// init party position and mapindex
-	if (_messages.newGame) {
-		_currMap.partyDir = _fileHeader._partyStartDir;
-		_currMap.partyPosX = _fileHeader._partyStartPosX;
-		_currMap.partyPosY = _fileHeader._partyStartPosY;
-		_currMap.currPartyMapIndex = 0;
+	if (_messages._newGame) {
+		_currMap._partyDir = _fileHeader._partyStartDir;
+		_currMap._partyPosX = _fileHeader._partyStartPosX;
+		_currMap._partyPosY = _fileHeader._partyStartPosY;
+		_currMap._currPartyMapIndex = 0;
 	}
 
 	// load map data
@@ -461,7 +461,7 @@ void DungeonMan::loadDungeonFile() {
 
 
 	uint32 actualSquareFirstThingCount = _fileHeader._squareFirstThingCount;
-	if (_messages.newGame) // TODO: what purpose does this serve?
+	if (_messages._newGame) // TODO: what purpose does this serve?
 		_fileHeader._squareFirstThingCount += 300;
 
 	// TODO: ??? is this - begin
@@ -476,7 +476,7 @@ void DungeonMan::loadDungeonFile() {
 	_dunData._squareFirstThings = new Thing[_fileHeader._squareFirstThingCount];
 	for (uint16 i = 0; i < actualSquareFirstThingCount; ++i)
 		_dunData._squareFirstThings[i].set(dunDataStream.readUint16BE());
-	if (_messages.newGame)
+	if (_messages._newGame)
 		for (uint16 i = 0; i < 300; ++i)
 			_dunData._squareFirstThings[actualSquareFirstThingCount + i] = Thing::_thingNone;
 
@@ -489,14 +489,14 @@ void DungeonMan::loadDungeonFile() {
 		_dunData._textData[i] = dunDataStream.readUint16BE();
 
 	// TODO: ??? what this
-	if (_messages.newGame)
+	if (_messages._newGame)
 		_dunData._eventMaximumCount = 100;
 
 
 	// load things
 	for (uint16 thingType = kDoorThingType; thingType < kThingTypeTotal; ++thingType) {
 		uint16 thingCount = _fileHeader._thingCounts[thingType];
-		if (_messages.newGame) {
+		if (_messages._newGame) {
 			_fileHeader._thingCounts[thingType] = MIN((thingType == kExplosionThingType) ? 768 : 1024, thingCount + gAdditionalThingCounts[thingType]);
 		}
 		uint16 thingStoreWordCount = gThingDataWordCount[thingType];
@@ -536,7 +536,7 @@ void DungeonMan::loadDungeonFile() {
 			}
 		}
 
-		if (_messages.newGame) {
+		if (_messages._newGame) {
 			if ((thingType == kGroupThingType) || thingType >= kProjectileThingType)
 				_dunData._eventMaximumCount += _fileHeader._thingCounts[thingType];
 			for (uint16 i = 0; i < gAdditionalThingCounts[thingType]; ++i) {
@@ -548,11 +548,11 @@ void DungeonMan::loadDungeonFile() {
 
 
 	// load map data
-	if (!_messages.restartGameRequest)
+	if (!_messages._restartGameRequest)
 		_rawMapData = _rawDunFileData + dunDataStream.pos();
 
 
-	if (!_messages.restartGameRequest) {
+	if (!_messages._restartGameRequest) {
 		uint8 mapCount = _fileHeader._mapCount;
 		delete[] _dunData._mapData;
 		_dunData._mapData = new byte**[_dunData._columCount + mapCount];
@@ -570,59 +570,59 @@ void DungeonMan::loadDungeonFile() {
 }
 
 void DungeonMan::setCurrentMap(uint16 mapIndex) {
-	_currMap.index = mapIndex;
-	_currMap.data = _dunData._mapData[mapIndex];
-	_currMap.map = _maps + mapIndex;
-	_currMap.width = _maps[mapIndex]._width + 1;
-	_currMap.height = _maps[mapIndex]._height + 1;
-	_currMap.colCumulativeSquareFirstThingCount
+	_currMap._index = mapIndex;
+	_currMap._data = _dunData._mapData[mapIndex];
+	_currMap._map = _maps + mapIndex;
+	_currMap._width = _maps[mapIndex]._width + 1;
+	_currMap._height = _maps[mapIndex]._height + 1;
+	_currMap._colCumulativeSquareFirstThingCount
 		= &_dunData._columnsCumulativeSquareThingCount[_dunData._mapsFirstColumnIndex[mapIndex]];
 }
 
 void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) {
 	setCurrentMap(mapIndex);
 
-	byte *metaMapData = _currMap.data[_currMap.width - 1] + _currMap.height;
+	byte *metaMapData = _currMap._data[_currMap._width - 1] + _currMap._height;
 	_vm->_displayMan->_currMapAllowedCreatureTypes = metaMapData;
 
-	metaMapData += _currMap.map->_creatureTypeCount;
-	memcpy(_vm->_displayMan->_currMapWallOrnIndices, metaMapData, _currMap.map->_wallOrnCount);
+	metaMapData += _currMap._map->_creatureTypeCount;
+	memcpy(_vm->_displayMan->_currMapWallOrnIndices, metaMapData, _currMap._map->_wallOrnCount);
 
-	metaMapData += _currMap.map->_wallOrnCount;
-	memcpy(_vm->_displayMan->_currMapFloorOrnIndices, metaMapData, _currMap.map->_floorOrnCount);
+	metaMapData += _currMap._map->_wallOrnCount;
+	memcpy(_vm->_displayMan->_currMapFloorOrnIndices, metaMapData, _currMap._map->_floorOrnCount);
 
-	metaMapData += _currMap.map->_wallOrnCount;
-	memcpy(_vm->_displayMan->_currMapDoorOrnIndices, metaMapData, _currMap.map->_doorOrnCount);
+	metaMapData += _currMap._map->_wallOrnCount;
+	memcpy(_vm->_displayMan->_currMapDoorOrnIndices, metaMapData, _currMap._map->_doorOrnCount);
 
-	_currMapInscriptionWallOrnIndex = _currMap.map->_wallOrnCount;
+	_currMapInscriptionWallOrnIndex = _currMap._map->_wallOrnCount;
 	_vm->_displayMan->_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = kWallOrnInscription;
 }
 
 
 Square DungeonMan::getSquare(int16 mapX, int16 mapY) {
-	bool isInXBounds = (mapX >= 0) && (mapX < _currMap.width);
-	bool isInYBounds = (mapY >= 0) && (mapY < _currMap.height);
+	bool isInXBounds = (mapX >= 0) && (mapX < _currMap._width);
+	bool isInYBounds = (mapY >= 0) && (mapY < _currMap._height);
 
 	if (isInXBounds && isInYBounds)
-		return _currMap.data[mapX][mapY];
+		return _currMap._data[mapX][mapY];
 
 
 	Square tmpSquare;
 	if (isInYBounds) {
-		tmpSquare.set(_currMap.data[0][mapY]);
+		tmpSquare.set(_currMap._data[0][mapY]);
 		if (mapX == -1 && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType))
 			return Square(kWallElemType).set(kWallEastRandOrnAllowed);
 
-		tmpSquare.set(_currMap.data[_currMap.width - 1][mapY]);
-		if (mapX == _currMap.width && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType))
+		tmpSquare.set(_currMap._data[_currMap._width - 1][mapY]);
+		if (mapX == _currMap._width && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType))
 			return Square(kWallElemType).set(kWallWestRandOrnAllowed);
 	} else if (isInXBounds) {
-		tmpSquare.set(_currMap.data[mapX][0]);
+		tmpSquare.set(_currMap._data[mapX][0]);
 		if (mapY == -1 && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType))
 			return Square(kWallElemType).set(kWallSouthRandOrnAllowed);
 
-		tmpSquare.set(_currMap.data[mapX][_currMap.height - 1]);
-		if (mapY == _currMap.height && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType))
+		tmpSquare.set(_currMap._data[mapX][_currMap._height - 1]);
+		if (mapY == _currMap._height && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType))
 			return (kWallElemType << 5) | kWallNorthRandOrnAllowed;
 	}
 
@@ -635,12 +635,12 @@ Square DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRi
 }
 
 int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) {
-	if (mapX < 0 || mapX >= _currMap.width || mapY < 0 || mapY >= _currMap.height || !Square(_currMap.data[mapX][mapY]).get(kThingListPresent))
+	if (mapX < 0 || mapX >= _currMap._width || mapY < 0 || mapY >= _currMap._height || !Square(_currMap._data[mapX][mapY]).get(kThingListPresent))
 		return -1;
 
 	int16 y = 0;
-	uint16 index = _currMap.colCumulativeSquareFirstThingCount[mapX];
-	byte* square = _currMap.data[mapX];
+	uint16 index = _currMap._colCumulativeSquareFirstThingCount[mapX];
+	byte* square = _currMap._data[mapX];
 	while (y++ != mapY)
 		if (Square(*square++).get(kThingListPresent))
 			index++;
@@ -719,7 +719,7 @@ T0172010_ClosedFakeWall:
 			}
 			thing = getNextThing(thing);
 		}
-		if (squareIsFakeWall && (_currMap.partyPosX != mapX) && (_currMap.partyPosY != mapY)) {
+		if (squareIsFakeWall && (_currMap._partyPosX != mapX) && (_currMap._partyPosY != mapY)) {
 			aspectArray[kFirstGroupOrObjectAspect] = Thing::_thingEndOfList.toUint16();
 			return;
 		}
@@ -745,7 +745,7 @@ T0172010_ClosedFakeWall:
 		square = footPrintsAllowed ? 8 : 0;
 		// intentional fallthrough
 	case kCorridorElemType:
-		aspectArray[kFloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(kCorridorRandOrnAllowed), _currMap.map->_randFloorOrnCount, mapX, mapY, 30);
+		aspectArray[kFloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(kCorridorRandOrnAllowed), _currMap._map->_randFloorOrnCount, mapX, mapY, 30);
 T0172029_Teleporter:
 		footPrintsAllowed = true;
 T0172030_Pit:
@@ -785,7 +785,7 @@ T0172049_Footprints:
 
 void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
 											int16 mapX, int16 mapY, bool isFakeWall) {
-	int16 ornCount = _currMap.map->_randWallOrnCount;
+	int16 ornCount = _currMap._map->_randWallOrnCount;
 
 	turnDirRight(dir);
 	aspectArray[kRightWallOrnOrdAspect] = getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
@@ -794,7 +794,7 @@ void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowe
 	turnDirRight(dir);
 	aspectArray[kLeftWallOrnOrdAspect] = getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
 
-	if (isFakeWall || mapX < 0 || mapX >= _currMap.width || mapY < 0 || mapY >= _currMap.height) {
+	if (isFakeWall || mapX < 0 || mapX >= _currMap._width || mapY < 0 || mapY >= _currMap._height) {
 		for (uint16 i = kRightWallOrnOrdAspect; i <= kLeftWallOrnOrdAspect; ++i) {
 			if (isWallOrnAnAlcove(ordinalToIndex(aspectArray[i])))
 				aspectArray[i] = 0;
@@ -804,7 +804,7 @@ void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowe
 
 int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) {
 	int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1)
-					+ (3000 + (_currMap.index << 6) + _currMap.width + _currMap.height) * 11
+					+ (3000 + (_currMap._index << 6) + _currMap._width + _currMap._height) * 11
 					+ _fileHeader._ornamentRandomSeed) >> 2) % modulo;
 	if (allowed && index < count)
 		return indexToOrdinal(index);
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 7ae10f1..aba2872 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -498,22 +498,22 @@ struct DungeonData {
 }; // @ AGGREGATE
 
 struct CurrMapData {
-	direction partyDir; // @ G0308_i_PartyDirection
-	int16 partyPosX; // @ G0306_i_PartyMapX
-	int16 partyPosY; // @ G0307_i_PartyMapY
-	uint8 currPartyMapIndex; // @ G0309_i_PartyMapIndex
-
-	uint8 index; // @ G0272_i_CurrentMapIndex
-	byte **data; // @ G0271_ppuc_CurrentMapData
-	Map *map; // @ G0269_ps_CurrentMap
-	uint16 width; // @ G0273_i_CurrentMapWidth
-	uint16 height; // @ G0274_i_CurrentMapHeight
-	uint16 *colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount
+	direction _partyDir; // @ G0308_i_PartyDirection
+	int16 _partyPosX; // @ G0306_i_PartyMapX
+	int16 _partyPosY; // @ G0307_i_PartyMapY
+	uint8 _currPartyMapIndex; // @ G0309_i_PartyMapIndex
+
+	uint8 _index; // @ G0272_i_CurrentMapIndex
+	byte **_data; // @ G0271_ppuc_CurrentMapData
+	Map *_map; // @ G0269_ps_CurrentMap
+	uint16 _width; // @ G0273_i_CurrentMapWidth
+	uint16 _height; // @ G0274_i_CurrentMapHeight
+	uint16 *_colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount
 }; // @ AGGREGATE
 
 struct Messages {
-	bool newGame; // @ G0298_B_NewGame
-	bool restartGameRequest; // @ G0523_B_RestartGameRequested
+	bool _newGame; // @ G0298_B_NewGame
+	bool _restartGameRequest; // @ G0523_B_RestartGameRequested
 }; // @ AGGREGATE
 
 class DungeonMan {
@@ -574,7 +574,6 @@ public:
 	bool _isFacingFountain; // @ G0288_B_FacingFountain
 };
 
-};
-
+}
 
 #endif
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 8728dd7..e182b78 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -276,22 +276,22 @@ void EventManager::processInput() {
 
 			switch (event.kbd.keycode) {
 			case Common::KEYCODE_w:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY);
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 1, 0, currMap._partyPosX, currMap._partyPosY);
 				break;
 			case Common::KEYCODE_a:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, -1, currMap.partyPosX, currMap.partyPosY);
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, -1, currMap._partyPosX, currMap._partyPosY);
 				break;
 			case Common::KEYCODE_s:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, -1, 0, currMap.partyPosX, currMap.partyPosY);
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, -1, 0, currMap._partyPosX, currMap._partyPosY);
 				break;
 			case Common::KEYCODE_d:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, 1, currMap.partyPosX, currMap.partyPosY);
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, 1, currMap._partyPosX, currMap._partyPosY);
 				break;
 			case Common::KEYCODE_q:
-				turnDirLeft(currMap.partyDir);
+				turnDirLeft(currMap._partyDir);
 				break;
 			case Common::KEYCODE_e:
-				turnDirRight(currMap.partyDir);
+				turnDirRight(currMap._partyDir);
 				break;
 			case Common::KEYCODE_UP:
 				if (_dummyMapIndex < 13)
@@ -387,7 +387,7 @@ void EventManager::commandTurnParty(CommandType cmdType) {
 	// MISSING CODE: process sensors
 
 	// DUMMY CODE: should call F0284_CHAMPION_SetPartyDirection instead
-	direction &partyDir = _vm->_dungeonMan->_currMap.partyDir;
+	direction &partyDir = _vm->_dungeonMan->_currMap._partyDir;
 	(cmdType == kCommandTurnLeft) ? turnDirLeft(partyDir) : turnDirRight(partyDir);
 
 	// MISSING CODE: process sensors
@@ -404,16 +404,16 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 
 	switch (cmdType) {
 	case kCommandMoveForward:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY);
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 1, 0, currMap._partyPosX, currMap._partyPosY);
 		break;
 	case kCommandMoveLeft:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, -1, currMap.partyPosX, currMap.partyPosY);
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, -1, currMap._partyPosX, currMap._partyPosY);
 		break;
 	case kCommandMoveBackward:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, -1, 0, currMap.partyPosX, currMap.partyPosY);
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, -1, 0, currMap._partyPosX, currMap._partyPosY);
 		break;
 	case kCommandMoveRight:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, 1, currMap.partyPosX, currMap.partyPosY);
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, 1, currMap._partyPosX, currMap._partyPosY);
 		break;
 	}
 
@@ -441,7 +441,7 @@ void EventManager::commandSetLeader(ChampionIndex index) {
 	}
 	cm._leaderIndex = index;
 	Champion *champion = &cm._champions[cm._leaderIndex];
-	champion->_dir = _vm->_dungeonMan->_currMap.partyDir;
+	champion->_dir = _vm->_dungeonMan->_currMap._partyDir;
 	cm._champions[index]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHand);
 	if (indexToOrdinal(index) != cm._candidateChampionOrdinal) {
 		champion->setAttributeFlag(kChampionAttributeIcon, true);
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 13ec773..ae9ef62 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1218,12 +1218,12 @@ void DisplayMan::loadWallSet(WallSet set) {
 
 
 void DisplayMan::loadCurrentMapGraphics() {
-	loadFloorSet(_vm->_dungeonMan->_currMap.map->_floorSet);
-	loadWallSet(_vm->_dungeonMan->_currMap.map->_wallSet);
+	loadFloorSet(_vm->_dungeonMan->_currMap._map->_floorSet);
+	loadWallSet(_vm->_dungeonMan->_currMap._map->_wallSet);
 
 	// the original loads some flipped walls here, I moved it to loadWallSet
 
-	for (uint16 i = 0, firstGraphicIndex = _vm->_dungeonMan->_currMap.map->_wallSet * kStairsGraphicCount + kFirstStairs; i < kStairsGraphicCount; ++i)
+	for (uint16 i = 0, firstGraphicIndex = _vm->_dungeonMan->_currMap._map->_wallSet * kStairsGraphicCount + kFirstStairs; i < kStairsGraphicCount; ++i)
 		_stairIndices[i] = firstGraphicIndex + i;
 
 	for (int16 i = 0; i < kAlcoveOrnCount; ++i)
@@ -1236,7 +1236,7 @@ void DisplayMan::loadCurrentMapGraphics() {
 
 	uint16 alcoveCount = 0;
 	uint16 fountainCount = 0;
-	Map &currMap = *_vm->_dungeonMan->_currMap.map;
+	Map &currMap = *_vm->_dungeonMan->_currMap._map;
 
 	_currMapViAltarIndex = -1;
 
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index a153d8e..1a07ae2 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -10,7 +10,7 @@ LoadsaveMan::LoadsaveMan(DMEngine *vm) : _vm(vm) {}
 
 
 LoadgameResponse LoadsaveMan::loadgame() {
-	bool newGame = _vm->_dungeonMan->_messages.newGame;
+	bool newGame = _vm->_dungeonMan->_messages._newGame;
 	ChampionMan &cm = *_vm->_championMan;
 
 	if (newGame) {


Commit: bcbb3e447f5037d4026ad5bed6d7a34eaa378e46
    https://github.com/scummvm/scummvm/commit/bcbb3e447f5037d4026ad5bed6d7a34eaa378e46
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some more renaming

Changed paths:
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/menus.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index e182b78..6d76ddb 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -340,8 +340,8 @@ CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common
 		return kCommandNone;
 	CommandType commandType = kCommandNone;
 
-	while ((commandType = input->commandTypeToIssue) != kCommandNone) {
-		if (input->hitbox.isPointInside(mousePos) && input->button == button)
+	while ((commandType = input->_commandTypeToIssue) != kCommandNone) {
+		if (input->_hitbox.isPointInside(mousePos) && input->_button == button)
 			break;
 		input++;
 	}
@@ -364,13 +364,13 @@ void EventManager::processCommandQueue() {
 	_isCommandQueueLocked = false;
 	processPendingClick();
 
-	if ((cmd.type == kCommandTurnRight) || (cmd.type == kCommandTurnLeft)) {
-		commandTurnParty(cmd.type);
+	if ((cmd._type == kCommandTurnRight) || (cmd._type == kCommandTurnLeft)) {
+		commandTurnParty(cmd._type);
 		return;
 	}
 
-	if ((cmd.type >= kCommandMoveForward) && (cmd.type <= kCommandMoveLeft)) {
-		commandMoveParty(cmd.type);
+	if ((cmd._type >= kCommandMoveForward) && (cmd._type <= kCommandMoveLeft)) {
+		commandMoveParty(cmd._type);
 		return;
 	}
 
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 8984b02..cdf0f06 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -130,21 +130,21 @@ enum CommandType {
 
 class Command {
 public:
-	Common::Point pos;
-	CommandType type;
+	Common::Point _pos;
+	CommandType _type;
 
-	Command(Common::Point position, CommandType commandType): pos(position), type(commandType) {}
+	Command(Common::Point position, CommandType commandType): _pos(position), _type(commandType) {}
 }; // @ COMMAND
 
 
 class MouseInput {
 public:
-	CommandType commandTypeToIssue;
-	Box hitbox;
-	MouseButton button;
+	CommandType _commandTypeToIssue;
+	Box _hitbox;
+	MouseButton _button;
 
 	MouseInput(CommandType type, uint16 x1, uint16 x2, uint16 y1, uint16 y2, MouseButton mouseButton)
-		: commandTypeToIssue(type), hitbox(x1, x2 + 1, y1, y2 + 1), button(mouseButton) {}
+		: _commandTypeToIssue(type), _hitbox(x1, x2 + 1, y1, y2 + 1), _button(mouseButton) {}
 }; // @ MOUSE_INPUT
 
 extern MouseInput gPrimaryMouseInput_Entrance[4]; // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
@@ -172,11 +172,11 @@ extern MouseInput* gPrimaryMouseInput_DialogSets[2][4]; // @ G0480_aaps_PrimaryM
 
 class KeyboardInput {
 public:
-	Command commandToIssue;
-	Common::KeyCode key;
-	byte modifiers;
+	Command _commandToIssue;
+	Common::KeyCode _key;
+	byte _modifiers;
 
-	KeyboardInput(Command command, Common::KeyCode keycode, byte modifierFlags) : commandToIssue(command), key(keycode), modifiers(modifierFlags) {}
+	KeyboardInput(Command command, Common::KeyCode keycode, byte modifierFlags) : _commandToIssue(command), _key(keycode), _modifiers(modifierFlags) {}
 }; // @ KEYBOARD_INPUT
 
 class DMEngine;
@@ -216,5 +216,4 @@ public:
 
 }
 
-
 #endif
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index ae9ef62..790c055 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -682,9 +682,9 @@ void DisplayMan::loadGraphics() {
 void DisplayMan::unpackGraphics() {
 	uint32 unpackedBitmapsSize = 0;
 	for (uint16 i = 0; i <= 20; ++i)
-		unpackedBitmapsSize += width(i) * height(i);
+		unpackedBitmapsSize += getWidth(i) * getHeight(i);
 	for (uint16 i = 22; i <= 532; ++i)
-		unpackedBitmapsSize += width(i) * height(i);
+		unpackedBitmapsSize += getWidth(i) * getHeight(i);
 	// graphics items go from 0-20 and 22-532 inclusive, _unpackedItemPos 21 and 22 are there for indexing convenience
 	if (_bitmaps) {
 		delete[] _bitmaps[0];
@@ -694,12 +694,12 @@ void DisplayMan::unpackGraphics() {
 	_bitmaps[0] = new byte[unpackedBitmapsSize];
 	loadIntoBitmap(0, _bitmaps[0]);
 	for (uint16 i = 1; i <= 20; ++i) {
-		_bitmaps[i] = _bitmaps[i - 1] + width(i - 1) * height(i - 1);
+		_bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1);
 		loadIntoBitmap(i, _bitmaps[i]);
 	}
-	_bitmaps[22] = _bitmaps[20] + width(20) * height(20);
+	_bitmaps[22] = _bitmaps[20] + getWidth(20) * getHeight(20);
 	for (uint16 i = 23; i < 533; ++i) {
-		_bitmaps[i] = _bitmaps[i - 1] + width(i - 1) * height(i - 1);
+		_bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1);
 		loadIntoBitmap(i, _bitmaps[i]);
 	}
 }
@@ -771,7 +771,7 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uin
 		for (uint16 x = 0; x < destToX - destFromX; ++x) {
 			byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x];
 			if (srcPixel != transparent)
-				destBitmap[destWidth * (y + destFromY + destViewport.posY) + destFromX + x + destViewport.posX] = srcPixel;
+				destBitmap[destWidth * (y + destFromY + destViewport._posY) + destFromX + x + destViewport._posX] = srcPixel;
 		}
 }
 
@@ -820,25 +820,25 @@ byte *DisplayMan::getCurrentVgaBuffer() {
 	return _vgaBuffer;
 }
 
-uint16 DisplayMan::width(uint16 index) {
+uint16 DisplayMan::getWidth(uint16 index) {
 	byte *data = _packedBitmaps + _packedItemPos[index];
 	return READ_BE_UINT16(data);
 }
 
-uint16 DisplayMan::height(uint16 index) {
+uint16 DisplayMan::getHeight(uint16 index) {
 	uint8 *data = _packedBitmaps + _packedItemPos[index];
 	return READ_BE_UINT16(data + 2);
 }
 
 
 void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
-	if (f.srcWidth)
-		blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorNoTransparency, gDungeonViewport);
+	if (f._srcWidth)
+		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorNoTransparency, gDungeonViewport);
 }
 
 void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) {
-	if (f.srcWidth)
-		blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport);
+	if (f._srcWidth)
+		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorFlesh, gDungeonViewport);
 }
 
 void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
@@ -1085,7 +1085,7 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	}
 
 	if (flippedFloorCeiling) {
-		uint16 w = gFloorFrame.srcWidth, h = gFloorFrame.srcHeight;
+		uint16 w = gFloorFrame._srcWidth, h = gFloorFrame._srcHeight;
 		blitToBitmap(_floorBitmap, w, h, tmpBitmap, w);
 		flipBitmapHorizontal(tmpBitmap, w, h);
 		drawWallSetBitmap(tmpBitmap, gFloorFrame);
@@ -1094,7 +1094,7 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 		for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i)
 			_wallSetBitMaps[i + kWall_D0R] = _wallSetBitMaps[i + kWall_D0R_Flipped];
 	} else {
-		uint16 w = gCeilingFrame.srcWidth, h = gCeilingFrame.srcHeight;
+		uint16 w = gCeilingFrame._srcWidth, h = gCeilingFrame._srcHeight;
 		blitToBitmap(_ceilingBitmap, w, h, tmpBitmap, w);
 		flipBitmapHorizontal(tmpBitmap, w, h);
 		drawWallSetBitmap(tmpBitmap, gCeilingFrame);
@@ -1187,7 +1187,7 @@ void DisplayMan::loadWallSet(WallSet set) {
 
 	for (uint16 i = 0; i < 7; ++i) {
 		uint16 srcGraphicIndice = firstIndice + srcIndex[i];
-		uint16 w = width(srcGraphicIndice), h = height(srcGraphicIndice);
+		uint16 w = getWidth(srcGraphicIndice), h = getHeight(srcGraphicIndice);
 		delete[] _wallSetBitMaps[destIndex[i]];
 		_wallSetBitMaps[destIndex[i]] = new byte[w * h];
 		blitToBitmap(_wallSetBitMaps[srcIndex[i]], w, h, _wallSetBitMaps[destIndex[i]], w);
@@ -1290,23 +1290,23 @@ void DisplayMan::loadCurrentMapGraphics() {
 
 void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor) {
 	for (int16 i = 0; i < 6; ++i)
-		gPalDungeonView[i][replacedColor] = gCreatureReplColorSets[replacementColor].RGBColor[i];
+		gPalDungeonView[i][replacedColor] = gCreatureReplColorSets[replacementColor]._RGBColor[i];
 
-	gPalChangesCreature_D2[replacedColor] = gCreatureReplColorSets[replacementColor].D2ReplacementColor;
-	gPalChangesCreature_D3[replacedColor] = gCreatureReplColorSets[replacementColor].D3ReplacementColor;
+	gPalChangesCreature_D2[replacedColor] = gCreatureReplColorSets[replacementColor]._D2ReplacementColor;
+	gPalChangesCreature_D3[replacedColor] = gCreatureReplColorSets[replacementColor]._D3ReplacementColor;
 }
 
 void DisplayMan::drawFloorPitOrStairsBitmap(StairIndex relIndex, Frame &f) {
-	if (f.srcWidth) {
-		blitToScreen(_bitmaps[_stairIndices[relIndex]], f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport);
+	if (f._srcWidth) {
+		blitToScreen(_bitmaps[_stairIndices[relIndex]], f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorFlesh, gDungeonViewport);
 	}
 }
 
 void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relIndex, Frame &f) {
-	if (f.srcWidth) {
-		blitToBitmap(_bitmaps[_stairIndices[relIndex]], f.srcWidth, f.srcHeight, _tmpBitmap, f.srcWidth);
-		flipBitmapHorizontal(_tmpBitmap, f.srcWidth, f.srcHeight);
-		blitToScreen(_tmpBitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport);
+	if (f._srcWidth) {
+		blitToBitmap(_bitmaps[_stairIndices[relIndex]], f._srcWidth, f._srcHeight, _tmpBitmap, f._srcWidth);
+		flipBitmapHorizontal(_tmpBitmap, f._srcWidth, f._srcHeight);
+		blitToScreen(_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorFlesh, gDungeonViewport);
 	}
 }
 
@@ -1370,8 +1370,8 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 			if (viewWallIndex == kViewWall_D1C_FRONT) {
 				if (isInscription) {
 					Frame &D1CFrame = gFrameWalls[kViewSquare_D1C];
-					blitToScreen(_wallSetBitMaps[kWall_D1LCR], D1CFrame.srcWidth, 94, 28, gBoxWallPatchBehindInscription.X1, gBoxWallPatchBehindInscription.X2,
-								 gBoxWallPatchBehindInscription.Y1, gBoxWallPatchBehindInscription.Y2, kColorNoTransparency, gDungeonViewport);
+					blitToScreen(_wallSetBitMaps[kWall_D1LCR], D1CFrame._srcWidth, 94, 28, gBoxWallPatchBehindInscription._x1, gBoxWallPatchBehindInscription._x2,
+								 gBoxWallPatchBehindInscription._y1, gBoxWallPatchBehindInscription._y2, kColorNoTransparency, gDungeonViewport);
 
 					unsigned char *string = inscriptionString;
 					bitmapRed = _bitmaps[kInscriptionFontIndice];
@@ -1382,12 +1382,12 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 						while (*character++ < 0x80) {
 							characterCount++;
 						}
-						frame.destToX = (frame.destFromX = 112 - (characterCount * 4)) + 7;
-						frame.destFromY = (frame.destToY = gInscriptionLineY[textLineIndex++]) - 7;
+						frame._destToX = (frame._destFromX = 112 - (characterCount * 4)) + 7;
+						frame._destFromY = (frame._destToY = gInscriptionLineY[textLineIndex++]) - 7;
 						while (characterCount--) {
-							blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame.destFromX, frame.destToX, frame.destFromY, frame.destToY, kColorFlesh, gDungeonViewport);
-							frame.destFromX += 8;
-							frame.destToX += 8;
+							blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._destFromX, frame._destToX, frame._destFromY, frame._destToY, kColorFlesh, gDungeonViewport);
+							frame._destFromX += 8;
+							frame._destToX += 8;
 						}
 					} while (*string++ != 0x81);
 					return isAlcove;
@@ -1457,14 +1457,14 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 			} while (*string++ != 0x81);
 
 			if (unreadableTextLineCount < 4) {
-				frame.destFromX = coordinateSetA[0];
-				frame.destToX = coordinateSetA[1];
-				frame.destFromY = coordinateSetA[2];
-				frame.destToY = coordinateSetA[3];
-				frame.srcWidth = coordinateSetA[4];
-				frame.srcHeight = coordinateSetA[5];
+				frame._destFromX = coordinateSetA[0];
+				frame._destToX = coordinateSetA[1];
+				frame._destFromY = coordinateSetA[2];
+				frame._destToY = coordinateSetA[3];
+				frame._srcWidth = coordinateSetA[4];
+				frame._srcHeight = coordinateSetA[5];
 
-				coordinateSetA = &frame.destFromX;
+				coordinateSetA = &frame._destFromX;
 
 				coordinateSetA[3] = gUnreadableInscriptionBoxY2[gWallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
 			}
@@ -1473,7 +1473,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 
 		if ((viewWallIndex == kViewWall_D1C_FRONT) && _championPortraitOrdinal--) {
 			Box &box = gBoxChampionPortraitOnWall;
-			blitToScreen(_bitmaps[kChampionPortraitsIndice], 256, (_championPortraitOrdinal & 0x7) << 5, (_championPortraitOrdinal >> 3) * 29, box.X1, box.X2, box.Y1, box.Y2,
+			blitToScreen(_bitmaps[kChampionPortraitsIndice], 256, (_championPortraitOrdinal & 0x7) << 5, (_championPortraitOrdinal >> 3) * 29, box._x1, box._x2, box._y1, box._y2,
 						 kColorDarkGary, gDungeonViewport);
 		}
 		return isAlcove;
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 241d45b..3283175 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -31,14 +31,14 @@ extern uint16 gPalDungeonView[6][16];
 
 class Box {
 public:
-	uint16 X1;
-	uint16 X2;
-	uint16 Y1;
-	uint16 Y2;
+	uint16 _x1;
+	uint16 _x2;
+	uint16 _y1;
+	uint16 _y2;
 
-	Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): X1(x1), X2(x2 + 1), Y1(y1), Y2(y2 + 1) {}
+	Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): _x1(x1), _x2(x2 + 1), _y1(y1), _y2(y2 + 1) {}
 	bool isPointInside(Common::Point point) {
-		return (X1 <= point.x) && (point.x < X2) && (Y1 <= point.y) && (point.y < Y2);
+		return (_x1 <= point.x) && (point.x < _x2) && (_y1 <= point.y) && (point.y < _y2);
 	}
 }; // @ BOX_BYTE, BOX_WORD
 
@@ -46,15 +46,15 @@ extern Box gBoxMovementArrows; // G0002_s_Graphic562_Box_MovementArrows
 
 // The frames in the original sources contain inclusive boundaries and byte widths, not pixel widths
 struct Frame {
-	uint16 destFromX, destToX, destFromY, destToY;
-	uint16 srcWidth, srcHeight;
-	uint16 srcX, srcY;
+	uint16 _destFromX, _destToX, _destFromY, _destToY;
+	uint16 _srcWidth, _srcHeight;
+	uint16 _srcX, _srcY;
 
 	Frame() {}
 	Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
 		uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) :
-	destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1),
-		srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {}
+	_destFromX(destFromX), _destToX(destToX + 1), _destFromY(destFromY), _destToY(destToY + 1),
+		_srcWidth(srcWidth * 2), _srcHeight(srcHeight), _srcX(srcX), _srcY(srcY) {}
 };
 
 enum WallSet {
@@ -124,55 +124,55 @@ enum Color {
 
 struct Viewport {
 	// TODO: should probably add width and height, seems redundant right meow
-	uint16 posX, posY;
+	uint16 _posX, _posY;
 };
 
 struct CreatureAspect {
-	uint16 firstNativeBitmapRelativeIndex;
-	uint16 firstDerivedBitmapIndex;
-	byte byteWidthFront;
-	byte heightFront;
-	byte byteWidthSide;
-	byte heightSide;
-	byte byteWidthAttack;
-	byte heightAttack;
-	byte coordinateSet_TransparentColor;
-	byte replacementColorSetIndices;
-
-	byte getCoordSet() { return (coordinateSet_TransparentColor >> 4) & 0xF; } // @ M71_COORDINATE_SET
-	byte getTranspColour() { return  coordinateSet_TransparentColor & 0xF; } // @ M72_TRANSPARENT_COLOR
-	byte getReplColour10() { return (replacementColorSetIndices >> 4) & 0xF; } // @ M74_COLOR_10_REPLACEMENT_COLOR_SET
-	byte getReplColour9() { return replacementColorSetIndices & 0xF; } // @ M73_COLOR_09_REPLACEMENT_COLOR_SET
+	uint16 _firstNativeBitmapRelativeIndex;
+	uint16 _firstDerivedBitmapIndex;
+	byte _byteWidthFront;
+	byte _heightFront;
+	byte _byteWidthSide;
+	byte _heightSide;
+	byte _byteWidthAttack;
+	byte _heightAttack;
+	byte _coordinateSet_TransparentColor;
+	byte _replacementColorSetIndices;
+
+	byte getCoordSet() { return (_coordinateSet_TransparentColor >> 4) & 0xF; } // @ M71_COORDINATE_SET
+	byte getTranspColour() { return  _coordinateSet_TransparentColor & 0xF; } // @ M72_TRANSPARENT_COLOR
+	byte getReplColour10() { return (_replacementColorSetIndices >> 4) & 0xF; } // @ M74_COLOR_10_REPLACEMENT_COLOR_SET
+	byte getReplColour9() { return _replacementColorSetIndices & 0xF; } // @ M73_COLOR_09_REPLACEMENT_COLOR_SET
 }; // @ CREATURE_ASPECT
 
 struct ObjectAspect {
-	byte firstNativeBitmapRelativeIndex;
-	byte firstDerivedBitmapRelativeIndex;
-	byte width;
-	byte height;
-	byte graphicInfo; /* Bits 7-5 and 3-1 Unreferenced */
-	byte coordinateSet;
+	byte _firstNativeBitmapRelativeIndex;
+	byte _firstDerivedBitmapRelativeIndex;
+	byte _width;
+	byte _height;
+	byte _graphicInfo; /* Bits 7-5 and 3-1 Unreferenced */
+	byte _coordinateSet;
 	ObjectAspect(byte firstN, byte firstD, byte byteWidth, byte h, byte grap, byte coord) :
-	firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD),
-		width(byteWidth * 2), height(h), graphicInfo(grap), coordinateSet(coord) {}
+		_firstNativeBitmapRelativeIndex(firstN), _firstDerivedBitmapRelativeIndex(firstD),
+		_width(byteWidth * 2), _height(h), _graphicInfo(grap), _coordinateSet(coord) {}
 }; // @ OBJECT_ASPECT
 
 struct ProjectileAspect {
-	byte firstNativeBitmapRelativeIndex;
-	byte firstDerivedBitmapRelativeIndex;
-	byte width;
-	byte height;
-	uint16 graphicInfo; /* Bits 15-9, 7-5 and 3-2 Unreferenced */
+	byte _firstNativeBitmapRelativeIndex;
+	byte _firstDerivedBitmapRelativeIndex;
+	byte _width;
+	byte _height;
+	uint16 _graphicInfo; /* Bits 15-9, 7-5 and 3-2 Unreferenced */
 
 	ProjectileAspect(byte firstN, byte firstD, byte byteWidth, byte h, uint16 grap) :
-	firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD),
-		width(byteWidth * 2), height(h), graphicInfo(grap) {}
+		_firstNativeBitmapRelativeIndex(firstN), _firstDerivedBitmapRelativeIndex(firstD),
+		_width(byteWidth * 2), _height(h), _graphicInfo(grap) {}
 }; // @ PROJECTIL_ASPECT
 
 struct CreatureReplColorSet {
-	uint16 RGBColor[6];
-	byte D2ReplacementColor;
-	byte D3ReplacementColor;
+	uint16 _RGBColor[6];
+	byte _D2ReplacementColor;
+	byte _D3ReplacementColor;
 }; // @ CREATURE_REPLACEMENT_COLOR_SET
 
 extern Viewport gDefultViewPort;
@@ -265,9 +265,9 @@ public:
 	void loadPalette(uint16 *palette);
 
 	/// Gives the width of an IMG0 type item
-	uint16 width(uint16 index);
+	uint16 getWidth(uint16 index);
 	/// Gives the height of an IMG1 type item
-	uint16 height(uint16 index);
+	uint16 getHeight(uint16 index);
 
 	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 					  byte *destBitmap, uint16 destWidth,
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 1b4c68d..4e079e4 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -10,9 +10,9 @@ void MenuMan::drawMovementArrows() {
 	DisplayMan &disp = *_vm->_displayMan;
 	byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice);
 	Box &dest = gBoxMovementArrows;
-	uint16 w = disp.width(kMovementArrowsIndice);
+	uint16 w = disp.getWidth(kMovementArrowsIndice);
 
-	disp.blitToScreen(arrowsBitmap, w, 0, 0, dest.X1, dest.X2, dest.Y1, dest.Y2, kColorNoTransparency);
+	disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency);
 }
 
 }
\ No newline at end of file


Commit: 78d8a8d3c842cfa94b011cf318680d4ad3e71bd0
    https://github.com/scummvm/scummvm/commit/78d8a8d3c842cfa94b011cf318680d4ad3e71bd0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add several global variables, add code to F0462_START_StartGame_CPSF

Changed paths:
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/eventman.h
    engines/dm/gfx.h
    engines/dm/menus.h



diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 5844760..2dda3de 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -256,6 +256,8 @@ public:
 	Thing _leaderHand; // @ G0414_T_LeaderHandObject
 	ChampionIndex _leaderIndex;	// @ G0411_i_LeaderIndex
 	uint16 _candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal
+	bool _partyIsSleeping; // @ G0300_B_PartyIsSleeping
+	uint16 _actingChampionOrdinal; // @ G0506_ui_ActingChampionOrdinal
 
 	ChampionMan(DMEngine *vm);
 };
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 2ff815c..a669154 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -94,17 +94,37 @@ void DMEngine::initializeGame() {
 
 
 void DMEngine::startGame() {
+	_pressingEye = false;
+	_stopPressingEye = false;
+	_pressingMouth = false;
+	_stopPressingMouth = false;
+	_highlightBoxInversionRequested = false;
+	_eventMan->_highlightBoxEnabled = false;
+	_championMan->_partyIsSleeping = false;
+	_championMan->_actingChampionOrdinal = indexToOrdinal(kChampionNone);
+	_menuMan->_actionAreaContainsIcons = true;
+	_eventMan->_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kChampionNone);
+
 	_eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface;
 	_eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement;
+	warning("MISSING CODE: set primary/secondary keyboard input");
+
+	// MISSING CODE: F0003_MAIN_ProcessNewPartyMap_CPSE
 	// TODO:(next 2 lines) move to F0003_MAIN_ProcessNewPartyMap_CPSE
 	_dungeonMan->setCurrentMapAndPartyMap(0);
 	_displayMan->loadCurrentMapGraphics();
 
+	if (!_dungeonMan->_messages._newGame) {
+		// MISSING CODE: loading game
+	} {
+		_displayMan->_useByteBoxCoordinates = false;
+		// MISSING CODE: clear screen
+	}
 
+	// MISSING CODE: build copper
 	_menuMan->drawMovementArrows();
+	warning("MISSING CODE: F0278_CHAMPION_ResetDataToStartGame");
 	_gameTimeTicking = true;
-
-	// MISSING CODE: Lot of stuff
 }
 
 Common::Error DMEngine::run() {
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 888e631..468390d 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -102,6 +102,11 @@ public:
 	bool _gameTimeTicking; // @ G0301_B_GameTimeTicking
 	bool _restartGameAllowed; // @ G0524_B_RestartGameAllowed
 	uint32 _gameId; // @ G0525_l_GameID, probably useless here
+	bool _pressingEye; // @ G0331_B_PressingEye
+	bool _stopPressingEye; // @ G0332_B_StopPressingEye
+	bool _pressingMouth; // @ G0333_B_PressingMouth
+	bool _stopPressingMouth; // @ G0334_B_StopPressingMouth
+	bool _highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested
 };
 
 class Console : public GUI::Debugger {
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index cdf0f06..b2834e8 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -199,7 +199,8 @@ class EventManager {
 public:
 	MouseInput* _primaryMouseInput;// @ G0441_ps_PrimaryMouseInput
 	MouseInput* _secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput
-
+	bool _highlightBoxEnabled; // @ G0341_B_HighlightBoxEnabled
+	uint16 _useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap
 	EventManager(DMEngine *vm);
 	void initMouse();
 	void showMouse(bool visibility);
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 3283175..86a152a 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -304,6 +304,8 @@ public:
 	int16 _currMapViAltarIndex; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex
 
 	Thing _inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing
+
+	bool _useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates
 };
 
 }
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index c1ceddd..6006d7a 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -9,6 +9,7 @@ class MenuMan {
 	DMEngine *_vm;
 public:
 	bool _shouldRefreshActionArea; // @ G0508_B_RefreshActionArea
+	bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons
 	MenuMan(DMEngine *vm);
 
 	void drawMovementArrows();


Commit: 43cedc4c78a0565df6eb37b9e16ac07ba2e498e7
    https://github.com/scummvm/scummvm/commit/43cedc4c78a0565df6eb37b9e16ac07ba2e498e7
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0003_MAIN_ProcessNewPartyMap_CPSE

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



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index a669154..d8eb3b8 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -109,10 +109,7 @@ void DMEngine::startGame() {
 	_eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement;
 	warning("MISSING CODE: set primary/secondary keyboard input");
 
-	// MISSING CODE: F0003_MAIN_ProcessNewPartyMap_CPSE
-	// TODO:(next 2 lines) move to F0003_MAIN_ProcessNewPartyMap_CPSE
-	_dungeonMan->setCurrentMapAndPartyMap(0);
-	_displayMan->loadCurrentMapGraphics();
+	processNewPartyMap(_dungeonMan->_currMap._currPartyMapIndex);
 
 	if (!_dungeonMan->_messages._newGame) {
 		// MISSING CODE: loading game
@@ -127,6 +124,14 @@ void DMEngine::startGame() {
 	_gameTimeTicking = true;
 }
 
+void DMEngine::processNewPartyMap(uint16 mapIndex) {
+	warning("MISSING CODE: F0194_GROUP_RemoveAllActiveGroups");
+	_dungeonMan->setCurrentMapAndPartyMap(mapIndex);
+	_displayMan->loadCurrentMapGraphics();
+	warning("MISSING CODE: F0195_GROUP_AddAllActiveGroups");
+	warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette");
+}
+
 Common::Error DMEngine::run() {
 	// scummvm/engine specific
 	initGraphics(320, 200, false);
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 468390d..a900b86 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -80,6 +80,7 @@ enum {
 
 class DMEngine : public Engine {
 	void startGame(); // @ F0462_START_StartGame_CPSF
+	void processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
 public:
 	DMEngine(OSystem *syst);
 	~DMEngine();


Commit: bcf8e07f2859ae8f04d414bc84975e67dd7dc5f0
    https://github.com/scummvm/scummvm/commit/bcf8e07f2859ae8f04d414bc84975e67dd7dc5f0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add IconIndex enum, F0278_CHAMPION_ResetDataToStartGame, related global variables

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 5ba529d..83d5204 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1,4 +1,5 @@
 #include "champion.h"
+#include "dungeonman.h"
 
 
 namespace DM {
@@ -32,4 +33,15 @@ ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
 	return kChampionNone;
 }
 
+void ChampionMan::resetDataToStartGame() {
+	if (!_vm->_dungeonMan->_messages._newGame) {
+		warning("MISSING CODE: stuff for reeseting for loaded games");
+		assert(false);
+	}
+
+	_leaderHand = Thing::_thingNone;
+	_leaderHandObjectIconIndex = kIconIndiceNone;
+	_leaderEmptyHanded = true;
+}
+
 }
\ No newline at end of file
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 2dda3de..89a1d05 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -6,6 +6,82 @@
 
 namespace DM {
 
+enum IconIndice {
+	kIconIndiceNone = -1, // @ CM1_ICON_NONE
+	kIconIndiceJunkCompassNorth = 0, // @ C000_ICON_JUNK_COMPASS_NORTH
+	kIconIndiceJunkCompassWest = 3, // @ C003_ICON_JUNK_COMPASS_WEST
+	kIconIndiceWeaponTorchUnlit = 4, // @ C004_ICON_WEAPON_TORCH_UNLIT
+	kIconIndiceWeaponTorchLit = 7, // @ C007_ICON_WEAPON_TORCH_LIT
+	kIconIndiceJunkWater = 8, // @ C008_ICON_JUNK_WATER
+	kIconIndiceJunkWaterSkin = 9, // @ C009_ICON_JUNK_WATERSKIN
+	kIconIndiceJunkJewelSymalUnequipped = 10, // @ C010_ICON_JUNK_JEWEL_SYMAL_UNEQUIPPED
+	kIconIndiceJunkJewelSymalEquipped = 11, // @ C011_ICON_JUNK_JEWEL_SYMAL_EQUIPPED
+	kIconIndiceJunkIllumuletUnequipped = 12, // @ C012_ICON_JUNK_ILLUMULET_UNEQUIPPED
+	kIconIndiceJunkIllumuletEquipped = 13, // @ C013_ICON_JUNK_ILLUMULET_EQUIPPED
+	kIconIndiceWeaponFlamittEmpty = 14, // @ C014_ICON_WEAPON_FLAMITT_EMPTY
+	kIconIndiceWeaponEyeOfTimeEmpty = 16, // @ C016_ICON_WEAPON_EYE_OF_TIME_EMPTY
+	kIconIndiceWeaponStormringEmpty = 18, // @ C018_ICON_WEAPON_STORMRING_EMPTY
+	kIconIndiceWeaponStaffOfClawsEmpty = 20, // @ C020_ICON_WEAPON_STAFF_OF_CLAWS_EMPTY
+	kIconIndiceWeaponStaffOfClawsFull = 22, // @ C022_ICON_WEAPON_STAFF_OF_CLAWS_FULL
+	kIconIndiceWeaponBoltBladeStormEmpty = 23, // @ C023_ICON_WEAPON_BOLT_BLADE_STORM_EMPTY
+	kIconIndiceWeaponFuryRaBladeEmpty = 25, // @ C025_ICON_WEAPON_FURY_RA_BLADE_EMPTY
+	kIconIndiceWeaponTheFirestaff = 27, // @ C027_ICON_WEAPON_THE_FIRESTAFF
+	kIconIndiceWeaponTheFirestaffComplete = 28, // @ C028_ICON_WEAPON_THE_FIRESTAFF_COMPLETE
+	kIconIndiceScrollOpen = 30, // @ C030_ICON_SCROLL_SCROLL_OPEN
+	kIconIndiceScrollClosed = 31, // @ C031_ICON_SCROLL_SCROLL_CLOSED
+	kIconIndiceWeaponDagger = 32, // @ C032_ICON_WEAPON_DAGGER
+	kIconIndiceWeaponDeltaSideSplitter = 38, // @ C038_ICON_WEAPON_DELTA_SIDE_SPLITTER
+	kIconIndiceWeaponDiamondEdge = 39, // @ C039_ICON_WEAPON_DIAMOND_EDGE
+	kIconIndiceWeaponVorpalBlade = 40, // @ C040_ICON_WEAPON_VORPAL_BLADE
+	kIconIndiceWeaponTheInquisitorDragonFang = 41, // @ C041_ICON_WEAPON_THE_INQUISITOR_DRAGON_FANG
+	kIconIndiceWeaponHardcleaveExecutioner = 43, // @ C043_ICON_WEAPON_HARDCLEAVE_EXECUTIONER
+	kIconIndiceWeaponMaceOfOrder = 45, // @ C045_ICON_WEAPON_MACE_OF_ORDER
+	kIconIndiceWeaponArrow = 51, // @ C051_ICON_WEAPON_ARROW
+	kIconIndiceWeaponSlayer = 52, // @ C052_ICON_WEAPON_SLAYER
+	kIconIndiceWeaponRock = 54, // @ C054_ICON_WEAPON_ROCK
+	kIconIndiceWeaponPoisonDart = 55, // @ C055_ICON_WEAPON_POISON_DART
+	kIconIndiceWeaponThrowingStar = 56, // @ C056_ICON_WEAPON_THROWING_STAR
+	kIconIndiceWeaponStaff = 58, // @ C058_ICON_WEAPON_STAFF
+	kIconIndiceWeaponWand = 59, // @ C059_ICON_WEAPON_WAND
+	kIconIndiceWeaponTeowand = 60, // @ C060_ICON_WEAPON_TEOWAND
+	kIconIndiceWeaponYewStaff = 61, // @ C061_ICON_WEAPON_YEW_STAFF
+	kIconIndiceWeaponStaffOfManarStaffOfIrra = 62, // @ C062_ICON_WEAPON_STAFF_OF_MANAR_STAFF_OF_IRRA
+	kIconIndiceWeaponSnakeStaffCrossOfNeta = 63, // @ C063_ICON_WEAPON_SNAKE_STAFF_CROSS_OF_NETA
+	kIconIndiceWeaponTheConduitSerpentStaff = 64, // @ C064_ICON_WEAPON_THE_CONDUIT_SERPENT_STAFF
+	kIconIndiceWeaponDragonSpit = 65, // @ C065_ICON_WEAPON_DRAGON_SPIT
+	kIconIndiceWeaponSceptreOfLyf = 66, // @ C066_ICON_WEAPON_SCEPTRE_OF_LYF
+	kIconIndiceArmourCloakOfNight = 81, // @ C081_ICON_ARMOUR_CLOAK_OF_NIGHT
+	kIconIndiceArmourCrownOfNerra = 104, // @ C104_ICON_ARMOUR_CROWN_OF_NERRA
+	kIconIndiceArmourElvenBoots = 119, // @ C119_ICON_ARMOUR_ELVEN_BOOTS
+	kIconIndiceJunkGemOfAges = 120, // @ C120_ICON_JUNK_GEM_OF_AGES
+	kIconIndiceJunkEkkhardCross = 121, // @ C121_ICON_JUNK_EKKHARD_CROSS
+	kIconIndiceJunkMoonstone = 122, // @ C122_ICON_JUNK_MOONSTONE
+	kIconIndiceJunkPendantFeral = 124, // @ C124_ICON_JUNK_PENDANT_FERAL
+	kIconIndiceJunkBoulder = 128, // @ C128_ICON_JUNK_BOULDER
+	kIconIndiceJunkRabbitsFoot = 137, // @ C137_ICON_JUNK_RABBITS_FOOT
+	kIconIndiceArmourDexhelm = 140, // @ C140_ICON_ARMOUR_DEXHELM
+	kIconIndiceArmourFlamebain = 141, // @ C141_ICON_ARMOUR_FLAMEBAIN
+	kIconIndiceArmourPowertowers = 142, // @ C142_ICON_ARMOUR_POWERTOWERS
+	kIconIndiceContainerChestClosed = 144, // @ C144_ICON_CONTAINER_CHEST_CLOSED
+	kIconIndiceContainerChestOpen = 145, // @ C145_ICON_CONTAINER_CHEST_OPEN
+	kIconIndiceJunkChampionBones = 147, // @ C147_ICON_JUNK_CHAMPION_BONES
+	kIconIndicePotionMaPotionMonPotion = 148, // @ C148_ICON_POTION_MA_POTION_MON_POTION
+	kIconIndicePotionWaterFlask = 163, // @ C163_ICON_POTION_WATER_FLASK
+	kIconIndiceJunkApple = 168, // @ C168_ICON_JUNK_APPLE
+	kIconIndiceJunkIronKey = 176, // @ C176_ICON_JUNK_IRON_KEY
+	kIconIndiceJunkMasterKey = 191, // @ C191_ICON_JUNK_MASTER_KEY
+	kIconIndiceArmourBootOfSpeed = 194, // @ C194_ICON_ARMOUR_BOOT_OF_SPEED
+	kIconIndicePotionEmptyFlask = 195, // @ C195_ICON_POTION_EMPTY_FLASK
+	kIconIndiceJunkZokathra = 197, // @ C197_ICON_JUNK_ZOKATHRA
+	kIconIndiceActionEmptyHand = 201, // @ C201_ICON_ACTION_ICON_EMPTY_HAND
+	kIconIndiceEyeNotLooking = 202, // @ C202_ICON_EYE_NOT_LOOKING /* One pixel is different in this bitmap from the eye in C017_GRAPHIC_INVENTORY. This is visible by selecting another champion after clicking the eye */
+	kIconIndiceEyeLooking = 203, // @ C203_ICON_EYE_LOOKING
+	kIconIndiceEmptyBox = 204, // @ C204_ICON_EMPTY_BOX
+	kIconIndiceMouthOpen = 205, // @ C205_ICON_MOUTH_OPEN
+	kIconIndiceNeck = 208, // @ C208_ICON_NECK
+	kIconIndiceReadyHand = 212 // @ C212_ICON_READY_HAND
+};
+
 enum ChampionIndex {
 	kChampionNone = -1, // @ CM1_CHAMPION_NONE
 	kChampionFirst = 0, // @ C00_CHAMPION_FIRST
@@ -258,8 +334,11 @@ public:
 	uint16 _candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal
 	bool _partyIsSleeping; // @ G0300_B_PartyIsSleeping
 	uint16 _actingChampionOrdinal; // @ G0506_ui_ActingChampionOrdinal
+	IconIndice _leaderHandObjectIconIndex; // @ G0413_i_LeaderHandObjectIconIndex
+	bool _leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded
 
 	ChampionMan(DMEngine *vm);
+	void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
 };
 
 }
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index d8eb3b8..1466c80 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -120,7 +120,7 @@ void DMEngine::startGame() {
 
 	// MISSING CODE: build copper
 	_menuMan->drawMovementArrows();
-	warning("MISSING CODE: F0278_CHAMPION_ResetDataToStartGame");
+	_championMan->resetDataToStartGame();
 	_gameTimeTicking = true;
 }
 


Commit: cc6ff27dd34b3c72ecff18aeca08fa6d1f574999
    https://github.com/scummvm/scummvm/commit/cc6ff27dd34b3c72ecff18aeca08fa6d1f574999
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Move F0463_START_InitializeGame_CPSADEF, F0002_MAIN_GameLoop_CPSDF in DMEngine to private

Changed paths:
    engines/dm/dm.h



diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index a900b86..468cd5c 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -81,13 +81,13 @@ enum {
 class DMEngine : public Engine {
 	void startGame(); // @ F0462_START_StartGame_CPSF
 	void processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
+	void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
+	void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF
 public:
 	DMEngine(OSystem *syst);
 	~DMEngine();
 
 	virtual Common::Error run(); // @ main
-	void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
-	void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF
 
 private:
 	Console *_console;


Commit: 6b833550b0371919c9108ceb36c916a7030f9b7c
    https://github.com/scummvm/scummvm/commit/6b833550b0371919c9108ceb36c916a7030f9b7c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0388_MENUS_ClearActingChampion

Changed paths:
    engines/dm/menus.cpp
    engines/dm/menus.h



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 4e079e4..d7948c2 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -1,5 +1,7 @@
 #include "menus.h"
 #include "gfx.h"
+#include "champion.h"
+#include "dungeonman.h"
 
 
 namespace DM {
@@ -14,5 +16,15 @@ void MenuMan::drawMovementArrows() {
 
 	disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency);
 }
+void MenuMan::clearActingChampion() {
+	ChampionMan &cm = *_vm->_championMan;
+	if (cm._actingChampionOrdinal) {
+		cm._actingChampionOrdinal--;
+		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true);
+		warning("MISSING CODE: F0292_CHAMPION_DrawState");
+		cm._actingChampionOrdinal = indexToOrdinal(kChampionNone);
+		_shouldRefreshActionArea = true;
+	}
+}
 
 }
\ No newline at end of file
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 6006d7a..ce6c166 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -11,6 +11,7 @@ public:
 	bool _shouldRefreshActionArea; // @ G0508_B_RefreshActionArea
 	bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons
 	MenuMan(DMEngine *vm);
+	void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
 
 	void drawMovementArrows();
 };


Commit: 7dd90c3daf2d9955ba232c0ed70d1f4b90ba81e9
    https://github.com/scummvm/scummvm/commit/7dd90c3daf2d9955ba232c0ed70d1f4b90ba81e9
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0141_DUNGEON_GetObjectInfoIndex, getType for Container

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 6b577ca..93bde02 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1036,4 +1036,32 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 	return 0; // dummy
 }
 
+/* Object info */
+#define kObjectInfoIndexFirstScroll 0 // @ C000_OBJECT_INFO_INDEX_FIRST_SCROLL
+#define kObjectInfoIndexFirstContainer 1 // @ C001_OBJECT_INFO_INDEX_FIRST_CONTAINER
+#define kObjectInfoIndexFirstPotion 2 // @ C002_OBJECT_INFO_INDEX_FIRST_POTION
+#define kObjectInfoIndexFirstWeapon 23 // @ C023_OBJECT_INFO_INDEX_FIRST_WEAPON
+#define kObjectInfoIndexFirstArmour 69 // @ C069_OBJECT_INFO_INDEX_FIRST_ARMOUR
+#define kObjectInfoIndexFirstJunk 127 // @ C127_OBJECT_INFO_INDEX_FIRST_JUNK
+
+int16 DungeonMan::getObjectInfoIndex(Thing thing) {
+	uint16 *rawType = getThingData(thing);
+	switch (thing.getType()) {
+	case kScrollThingType:
+		return kObjectInfoIndexFirstScroll;
+	case kContainerThingType:
+		return kObjectInfoIndexFirstContainer + Container(rawType).getType();
+	case kJunkThingType:
+		return kObjectInfoIndexFirstJunk + Junk(rawType).getType();
+	case kWeaponThingType:
+		return kObjectInfoIndexFirstWeapon + Weapon(rawType).getType();
+	case kArmourThingType:
+		return kObjectInfoIndexFirstArmour + Armour(rawType).getType();
+	case kPotionThingType:
+		return kObjectInfoIndexFirstPotion + Potion(rawType).getType();
+	default:
+		return -1;
+	}
+}
+
 }
\ No newline at end of file
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index aba2872..0a68600 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -341,6 +341,7 @@ class Container {
 public:
 	Container(uint16 *rawDat) : _nextThing(rawDat[0]), _nextContainedThing(rawDat[1]), _type(rawDat[2]) {}
 
+	uint16 getType() { return (_type >> 1) & 0x3; }
 	Thing getNextContainedThing() { return _nextContainedThing; }
 	Thing getNextThing() { return _nextThing; }
 }; // @ CONTAINER
@@ -554,7 +555,8 @@ public:
 	void setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect
 	void decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText
 
-	uint16 getObjectWeight(Thing thing);// @ F0140_DUNGEON_GetObjectWeight
+	uint16 getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight
+	int16 getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex
 
 	uint32 _rawDunFileDataSize;	 // @ probably NONE
 	byte *_rawDunFileData; // @ ???


Commit: c97a4560b21ba73537e59cbcc9c18d8943992231
    https://github.com/scummvm/scummvm/commit/c97a4560b21ba73537e59cbcc9c18d8943992231
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Change some comments to warnings

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 1466c80..2a20b86 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -80,7 +80,7 @@ void DMEngine::initializeGame() {
 	_eventMan->initMouse();
 
 	while (_loadsaveMan->loadgame() != kLoadgameSuccess) {
-		// MISSING CODE: F0441_STARTEND_ProcessEntrance
+		warning("TODO: F0441_STARTEND_ProcessEntrance");
 	}
 
 	_displayMan->loadFloorSet(kFloorSetStone);
@@ -112,13 +112,13 @@ void DMEngine::startGame() {
 	processNewPartyMap(_dungeonMan->_currMap._currPartyMapIndex);
 
 	if (!_dungeonMan->_messages._newGame) {
-		// MISSING CODE: loading game
+		warning("TODO: loading game");
 	} {
 		_displayMan->_useByteBoxCoordinates = false;
-		// MISSING CODE: clear screen
+		warning("TODO: clear screen");
 	}
 
-	// MISSING CODE: build copper
+	warning("TODO: build copper");
 	_menuMan->drawMovementArrows();
 	_championMan->resetDataToStartGame();
 	_gameTimeTicking = true;
@@ -147,7 +147,7 @@ Common::Error DMEngine::run() {
 	initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
 	while (true) {
 		gameloop();
-		// MISSING CODE: F0444_STARTEND_Endgame(G0303_B_PartyDead);
+		warning("TODO: F0444_STARTEND_Endgame(G0303_B_PartyDead);");
 	}
 
 	return Common::kNoError;


Commit: 16d65d476d2acdefd559e79e34b1854cc4d141d3
    https://github.com/scummvm/scummvm/commit/16d65d476d2acdefd559e79e34b1854cc4d141d3
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add ObjectInfo

Changed paths:
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 0a68600..00dbcc2 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -8,6 +8,40 @@
 
 namespace DM {
 
+enum ObjectAllowedSlot {
+	kObjectAllowedSlotMouth = 0x0001, // @ MASK0x0001_MOUTH
+	kObjectAllowedSlotHead = 0x0002, // @ MASK0x0002_HEAD
+	kObjectAllowedSlotNeck = 0x0004, // @ MASK0x0004_NECK
+	kObjectAllowedSlotTorso = 0x0008, // @ MASK0x0008_TORSO
+	kObjectAllowedSlotLegs = 0x0010, // @ MASK0x0010_LEGS
+	kObjectAllowedSlotFeet = 0x0020, // @ MASK0x0020_FEET
+	kObjectAllowedSlotQuiverLine_1 = 0x0040, // @ MASK0x0040_QUIVER_LINE1
+	kObjectAllowedSlotQuiverLine_2 = 0x0080, // @ MASK0x0080_QUIVER_LINE2
+	kObjectAllowedSlotPouchPassAndThroughDoors = 0x0100, // @ MASK0x0100_POUCH_PASS_AND_THROUGH_DOORS
+	kObjectAllowedSlotHands = 0x0200, // @ MASK0x0200_HANDS
+	kObjectAllowedSlotContainer = 0x0400 // @ MASK0x0400_CONTAINER
+};
+
+class ObjectInfo {
+public:
+	int16 _type;
+	uint16 _objectAspectIndex;
+	uint16 _actionSetIndex;
+private:
+	uint16 _allowedSlots;
+public:
+	ObjectInfo(int16 type, uint16 objectAspectIndex, uint16 actionSetIndex, uint16 allowedSlots)
+		: _type(type), _objectAspectIndex(objectAspectIndex), _actionSetIndex(actionSetIndex), _allowedSlots(allowedSlots) {}
+	bool getAllowedSlot(ObjectAllowedSlot slot) { return _allowedSlots & slot; }
+	void setAllowedSlot(ObjectAllowedSlot slot, bool val) {
+		if (val) {
+			_allowedSlots |= slot;
+		} else {
+			_allowedSlots &= ~slot;
+		}
+	}
+}; // @ OBJECT_INFO
+
 extern uint16 gJunkInfo[53];
 				
 enum ArmourAttribute {


Commit: b7c225b4d4fe1bbdf0cd13ac0b72c1f614e37be0
    https://github.com/scummvm/scummvm/commit/b7c225b4d4fe1bbdf0cd13ac0b72c1f614e37be0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add G0237_as_Graphic559_ObjectInfo

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 93bde02..01791bf 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -6,6 +6,189 @@
 
 namespace DM {
 
+ObjectInfo gObjectInfo[180] = { // @ G0237_as_Graphic559_ObjectInfo
+/* { Type, ObjectAspectIndex, ActionSetIndex, AllowedSlots } */
+	ObjectInfo(30,  1,  0, 0x0500),   /* COMPASS        Pouch/Chest */
+	ObjectInfo(144,  0,  0, 0x0200),   /* COMPASS        Hands */
+	ObjectInfo(148, 67,  0, 0x0500),   /* COMPASS        Pouch/Chest */
+	ObjectInfo(149, 67,  0, 0x0500),   /* COMPASS        Pouch/Chest */
+	ObjectInfo(150, 67,  0, 0x0500),   /* TORCH          Pouch/Chest */
+	ObjectInfo(151, 67, 42, 0x0500),   /* TORCH          Pouch/Chest */
+	ObjectInfo(152, 67,  0, 0x0500),   /* TORCH          Pouch/Chest */
+	ObjectInfo(153, 67,  0, 0x0500),   /* TORCH          Pouch/Chest */
+	ObjectInfo(154,  2,  0, 0x0501),   /* WATERSKIN      Mouth/Pouch/Chest */
+	ObjectInfo(155,  2,  0, 0x0501),   /* WATER          Mouth/Pouch/Chest */
+	ObjectInfo(156,  2,  0, 0x0501),   /* JEWEL SYMAL    Mouth/Pouch/Chest */
+	ObjectInfo(157,  2,  0, 0x0501),   /* JEWEL SYMAL    Mouth/Pouch/Chest */
+	ObjectInfo(158,  2,  0, 0x0501),   /* ILLUMULET      Mouth/Pouch/Chest */
+	ObjectInfo(159,  2,  0, 0x0501),   /* ILLUMULET      Mouth/Pouch/Chest */
+	ObjectInfo(160,  2,  0, 0x0501),   /* FLAMITT        Mouth/Pouch/Chest */
+	ObjectInfo(161,  2,  0, 0x0501),   /* FLAMITT        Mouth/Pouch/Chest */
+	ObjectInfo(162,  2,  0, 0x0501),   /* EYE OF TIME    Mouth/Pouch/Chest */
+	ObjectInfo(163,  2,  0, 0x0501),   /* EYE OF TIME    Mouth/Pouch/Chest */
+	ObjectInfo(164, 68,  0, 0x0500),   /* STORMRING      Pouch/Chest */
+	ObjectInfo(165, 68,  0, 0x0500),   /* STORMRING      Pouch/Chest */
+	ObjectInfo(166, 68,  0, 0x0500),   /* STAFF OF CLAWS Pouch/Chest */
+	ObjectInfo(167, 68, 42, 0x0500),   /* STAFF OF CLAWS Pouch/Chest */
+	ObjectInfo(195, 80,  0, 0x0500),   /* STAFF OF CLAWS Pouch/Chest */
+	ObjectInfo(16, 38, 43, 0x0500),   /* BOLT BLADE     Pouch/Chest */
+	ObjectInfo(18, 38,  7, 0x0500),   /* BOLT BLADE     Pouch/Chest */
+	ObjectInfo(4, 35,  5, 0x0400),   /* FURY           Chest */
+	ObjectInfo(14, 37,  6, 0x0400),   /* FURY           Chest */
+	ObjectInfo(20, 11,  8, 0x0040),   /* THE FIRESTAFF  Quiver 1 */
+	ObjectInfo(23, 12,  9, 0x0040),   /* THE FIRESTAFF  Quiver 1 */
+	ObjectInfo(25, 12, 10, 0x0040),   /* THE FIRESTAFF  Quiver 1 */
+	ObjectInfo(27, 39, 11, 0x0040),   /* OPEN SCROLL    Quiver 1 */
+	ObjectInfo(32, 17, 12, 0x05C0),   /* SCROLL         Quiver 1/Quiver 2/Pouch/Chest */
+	ObjectInfo(33, 12, 13, 0x0040),   /* DAGGER         Quiver 1 */
+	ObjectInfo(34, 12, 13, 0x0040),   /* FALCHION       Quiver 1 */
+	ObjectInfo(35, 12, 14, 0x0040),   /* SWORD          Quiver 1 */
+	ObjectInfo(36, 12, 15, 0x0040),   /* RAPIER         Quiver 1 */
+	ObjectInfo(37, 12, 15, 0x0040),   /* SABRE          Quiver 1 */
+	ObjectInfo(38, 12, 16, 0x0040),   /* SAMURAI SWORD  Quiver 1 */
+	ObjectInfo(39, 12, 17, 0x0040),   /* DELTA          Quiver 1 */
+	ObjectInfo(40, 42, 18, 0x0040),   /* DIAMOND EDGE   Quiver 1 */
+	ObjectInfo(41, 12, 19, 0x0040),   /* VORPAL BLADE   Quiver 1 */
+	ObjectInfo(42, 13, 20, 0x0040),   /* THE INQUISITOR Quiver 1 */
+	ObjectInfo(43, 13, 21, 0x0040),   /* AXE            Quiver 1 */
+	ObjectInfo(44, 21, 22, 0x0040),   /* HARDCLEAVE     Quiver 1 */
+	ObjectInfo(45, 21, 22, 0x0040),   /* MACE           Quiver 1 */
+	ObjectInfo(46, 33, 23, 0x0440),   /* MACE OF ORDER  Quiver 1/Chest */
+	ObjectInfo(47, 43, 24, 0x0040),   /* MORNINGSTAR    Quiver 1 */
+	ObjectInfo(48, 44, 24, 0x0040),   /* CLUB           Quiver 1 */
+	ObjectInfo(49, 14, 27, 0x0040),   /* STONE CLUB     Quiver 1 */
+	ObjectInfo(50, 45, 27, 0x0040),   /* BOW            Quiver 1 */
+	ObjectInfo(51, 16, 26, 0x05C0),   /* CROSSBOW       Quiver 1/Quiver 2/Pouch/Chest */
+	ObjectInfo(52, 46, 26, 0x05C0),   /* ARROW          Quiver 1/Quiver 2/Pouch/Chest */
+	ObjectInfo(53, 11, 27, 0x0440),   /* SLAYER         Quiver 1/Chest */
+	ObjectInfo(54, 47, 42, 0x05C0),   /* SLING          Quiver 1/Quiver 2/Pouch/Chest */
+	ObjectInfo(55, 48, 40, 0x05C0),   /* ROCK           Quiver 1/Quiver 2/Pouch/Chest */
+	ObjectInfo(56, 49, 42, 0x05C0),   /* POISON DART    Quiver 1/Quiver 2/Pouch/Chest */
+	ObjectInfo(57, 50,  5, 0x0040),   /* THROWING STAR  Quiver 1 */
+	ObjectInfo(58, 11,  5, 0x0040),   /* STICK          Quiver 1 */
+	ObjectInfo(59, 31, 28, 0x0540),   /* STAFF          Quiver 1/Pouch/Chest */
+	ObjectInfo(60, 31, 29, 0x0540),   /* WAND           Quiver 1/Pouch/Chest */
+	ObjectInfo(61, 11, 30, 0x0040),   /* TEOWAND        Quiver 1 */
+	ObjectInfo(62, 11, 31, 0x0040),   /* YEW STAFF      Quiver 1 */
+	ObjectInfo(63, 11, 32, 0x0040),   /* STAFF OF MANAR Quiver 1 Atari ST Version 1.0 1987-12-08: ObjectAspectIndex = 35 */
+	ObjectInfo(64, 51, 33, 0x0040),   /* SNAKE STAFF    Quiver 1 */
+	ObjectInfo(65, 32,  5, 0x0440),   /* THE CONDUIT    Quiver 1/Chest */
+	ObjectInfo(66, 30, 35, 0x0040),   /* DRAGON SPIT    Quiver 1 */
+	ObjectInfo(135, 65, 36, 0x0440),   /* SCEPTRE OF LYF Quiver 1/Chest */
+	ObjectInfo(143, 45, 27, 0x0040),   /* ROBE           Quiver 1 */
+	ObjectInfo(28, 82,  1, 0x0040),   /* FINE ROBE      Quiver 1 */
+	ObjectInfo(80, 23,  0, 0x040C),   /* KIRTLE         Neck/Torso/Chest */
+	ObjectInfo(81, 23,  0, 0x040C),   /* SILK SHIRT     Neck/Torso/Chest */
+	ObjectInfo(82, 23,  0, 0x0410),   /* ELVEN DOUBLET  Legs/Chest */
+	ObjectInfo(112, 55,  0, 0x0420),   /* LEATHER JERKIN Feet/Chest */
+	ObjectInfo(114,  8,  0, 0x0420),   /* TUNIC          Feet/Chest */
+	ObjectInfo(67, 24,  0, 0x0408),   /* GHI            Torso/Chest */
+	ObjectInfo(83, 24,  0, 0x0410),   /* MAIL AKETON    Legs/Chest */
+	ObjectInfo(68, 24,  0, 0x0408),   /* MITHRAL AKETON Torso/Chest */
+	ObjectInfo(84, 24,  0, 0x0410),   /* TORSO PLATE    Legs/Chest */
+	ObjectInfo(69, 69,  0, 0x0408),   /* PLATE OF LYTE  Torso/Chest */
+	ObjectInfo(70, 24,  0, 0x0408),   /* PLATE OF DARC  Torso/Chest */
+	ObjectInfo(85, 24,  0, 0x0410),   /* CAPE           Legs/Chest */
+	ObjectInfo(86, 69,  0, 0x0410),   /* CLOAK OF NIGHT Legs/Chest */
+	ObjectInfo(71,  7,  0, 0x0408),   /* BARBARIAN HIDE Torso/Chest */
+	ObjectInfo(87,  7,  0, 0x0410),   /* ROBE           Legs/Chest */
+	ObjectInfo(119, 57,  0, 0x0420),   /* FINE ROBE      Feet/Chest */
+	ObjectInfo(72, 23,  0, 0x0408),   /* TABARD         Torso/Chest */
+	ObjectInfo(88, 23,  0, 0x0410),   /* GUNNA          Legs/Chest */
+	ObjectInfo(113, 29,  0, 0x0420),   /* ELVEN HUKE     Feet/Chest */
+	ObjectInfo(89, 69,  0, 0x0410),   /* LEATHER PANTS  Legs/Chest */
+	ObjectInfo(73, 69,  0, 0x0408),   /* BLUE PANTS     Torso/Chest */
+	ObjectInfo(74, 24,  0, 0x0408),   /* GHI TROUSERS   Torso/Chest */
+	ObjectInfo(90, 24,  0, 0x0410),   /* LEG MAIL       Legs/Chest */
+	ObjectInfo(103, 53,  0, 0x0402),   /* MITHRAL MAIL   Head/Chest */
+	ObjectInfo(104, 53,  0, 0x0402),   /* LEG PLATE      Head/Chest */
+	ObjectInfo(96,  9,  0, 0x0402),   /* POLEYN OF LYTE Head/Chest */
+	ObjectInfo(97,  9,  0, 0x0402),   /* POLEYN OF DARC Head/Chest */
+	ObjectInfo(98,  9,  0, 0x0402),   /* BEZERKER HELM  Head/Chest */
+	ObjectInfo(105, 54, 41, 0x0400),   /* HELMET         Chest */
+	ObjectInfo(106, 54, 41, 0x0200),   /* BASINET        Hands */
+	ObjectInfo(108, 10, 41, 0x0200),   /* CASQUE 'N COIF Hands */
+	ObjectInfo(107, 54, 41, 0x0200),   /* ARMET          Hands */
+	ObjectInfo(75, 19,  0, 0x0408),   /* HELM OF LYTE   Torso/Chest */
+	ObjectInfo(91, 19,  0, 0x0410),   /* HELM OF DARC   Legs/Chest */
+	ObjectInfo(76, 19,  0, 0x0408),   /* CALISTA        Torso/Chest */
+	ObjectInfo(92, 19,  0, 0x0410),   /* CROWN OF NERRA Legs/Chest */
+	ObjectInfo(99,  9,  0, 0x0402),   /* BUCKLER        Head/Chest */
+	ObjectInfo(115, 19,  0, 0x0420),   /* HIDE SHIELD    Feet/Chest */
+	ObjectInfo(100, 52,  0, 0x0402),   /* SMALL SHIELD   Head/Chest */
+	ObjectInfo(77, 20,  0, 0x0008),   /* WOODEN SHIELD  Torso */
+	ObjectInfo(93, 22,  0, 0x0010),   /* LARGE SHIELD   Legs */
+	ObjectInfo(116, 56,  0, 0x0420),   /* SHIELD OF LYTE Feet/Chest */
+	ObjectInfo(109, 10, 41, 0x0200),   /* SHIELD OF DARC Hands */
+	ObjectInfo(101, 52,  0, 0x0402),   /* SANDALS        Head/Chest */
+	ObjectInfo(78, 20,  0, 0x0008),   /* SUEDE BOOTS    Torso */
+	ObjectInfo(94, 22,  0, 0x0010),   /* LEATHER BOOTS  Legs */
+	ObjectInfo(117, 56,  0, 0x0420),   /* HOSEN          Feet/Chest */
+	ObjectInfo(110, 10, 41, 0x0200),   /* FOOT PLATE     Hands */
+	ObjectInfo(102, 52,  0, 0x0402),   /* GREAVE OF LYTE Head/Chest */
+	ObjectInfo(79, 20,  0, 0x0008),   /* GREAVE OF DARC Torso */
+	ObjectInfo(95, 22,  0, 0x0010),   /* ELVEN BOOTS    Legs */
+	ObjectInfo(118, 56,  0, 0x0420),   /* GEM OF AGES    Feet/Chest */
+	ObjectInfo(111, 10, 41, 0x0200),   /* EKKHARD CROSS  Hands */
+	ObjectInfo(140, 52,  0, 0x0402),   /* MOONSTONE      Head/Chest */
+	ObjectInfo(141, 19,  0, 0x0408),   /* THE HELLION    Torso/Chest */
+	ObjectInfo(142, 22,  0, 0x0010),   /* PENDANT FERAL  Legs */
+	ObjectInfo(194, 81,  0, 0x0420),   /* COPPER COIN    Feet/Chest */
+	ObjectInfo(196, 84,  0, 0x0408),   /* SILVER COIN    Torso/Chest */
+	ObjectInfo(0, 34,  0, 0x0500),   /* GOLD COIN      Pouch/Chest */
+	ObjectInfo(8,  6,  0, 0x0501),   /* BOULDER        Mouth/Pouch/Chest */
+	ObjectInfo(10, 15,  0, 0x0504),   /* BLUE GEM       Neck/Pouch/Chest */
+	ObjectInfo(12, 15,  0, 0x0504),   /* ORANGE GEM     Neck/Pouch/Chest */
+	ObjectInfo(146, 40,  0, 0x0500),   /* GREEN GEM      Pouch/Chest */
+	ObjectInfo(147, 41,  0, 0x0400),   /* MAGICAL BOX    Chest */
+	ObjectInfo(125,  4, 37, 0x0500),   /* MAGICAL BOX    Pouch/Chest */
+	ObjectInfo(126, 83, 37, 0x0500),   /* MIRROR OF DAWN Pouch/Chest */
+	ObjectInfo(127,  4, 37, 0x0500),   /* HORN OF FEAR   Pouch/Chest */
+	ObjectInfo(176, 18,  0, 0x0500),   /* ROPE           Pouch/Chest */
+	ObjectInfo(177, 18,  0, 0x0500),   /* RABBIT'S FOOT  Pouch/Chest */
+	ObjectInfo(178, 18,  0, 0x0500),   /* CORBAMITE      Pouch/Chest */
+	ObjectInfo(179, 18,  0, 0x0500),   /* CHOKER         Pouch/Chest */
+	ObjectInfo(180, 18,  0, 0x0500),   /* DEXHELM        Pouch/Chest */
+	ObjectInfo(181, 18,  0, 0x0500),   /* FLAMEBAIN      Pouch/Chest */
+	ObjectInfo(182, 18,  0, 0x0500),   /* POWERTOWERS    Pouch/Chest */
+	ObjectInfo(183, 18,  0, 0x0500),   /* SPEEDBOW       Pouch/Chest */
+	ObjectInfo(184, 62,  0, 0x0500),   /* CHEST          Pouch/Chest */
+	ObjectInfo(185, 62,  0, 0x0500),   /* OPEN CHEST     Pouch/Chest */
+	ObjectInfo(186, 62,  0, 0x0500),   /* ASHES          Pouch/Chest */
+	ObjectInfo(187, 62,  0, 0x0500),   /* BONES          Pouch/Chest */
+	ObjectInfo(188, 62,  0, 0x0500),   /* MON POTION     Pouch/Chest */
+	ObjectInfo(189, 62,  0, 0x0500),   /* UM POTION      Pouch/Chest */
+	ObjectInfo(190, 62,  0, 0x0500),   /* DES POTION     Pouch/Chest */
+	ObjectInfo(191, 62,  0, 0x0500),   /* VEN POTION     Pouch/Chest */
+	ObjectInfo(128, 76,  0, 0x0200),   /* SAR POTION     Hands */
+	ObjectInfo(129,  3,  0, 0x0500),   /* ZO POTION      Pouch/Chest */
+	ObjectInfo(130, 60,  0, 0x0500),   /* ROS POTION     Pouch/Chest */
+	ObjectInfo(131, 61,  0, 0x0500),   /* KU POTION      Pouch/Chest */
+	ObjectInfo(168, 27,  0, 0x0501),   /* DANE POTION    Mouth/Pouch/Chest */
+	ObjectInfo(169, 28,  0, 0x0501),   /* NETA POTION    Mouth/Pouch/Chest */
+	ObjectInfo(170, 25,  0, 0x0501),   /* BRO POTION     Mouth/Pouch/Chest */
+	ObjectInfo(171, 26,  0, 0x0501),   /* MA POTION      Mouth/Pouch/Chest */
+	ObjectInfo(172, 71,  0, 0x0401),   /* YA POTION      Mouth/Chest */
+	ObjectInfo(173, 70,  0, 0x0401),   /* EE POTION      Mouth/Chest */
+	ObjectInfo(174,  5,  0, 0x0501),   /* VI POTION      Mouth/Pouch/Chest */
+	ObjectInfo(175, 66,  0, 0x0501),   /* WATER FLASK    Mouth/Pouch/Chest */
+	ObjectInfo(120, 15,  0, 0x0504),   /* KATH BOMB      Neck/Pouch/Chest */
+	ObjectInfo(121, 15,  0, 0x0504),   /* PEW BOMB       Neck/Pouch/Chest */
+	ObjectInfo(122, 58,  0, 0x0504),   /* RA BOMB        Neck/Pouch/Chest */
+	ObjectInfo(123, 59,  0, 0x0504),   /* FUL BOMB       Neck/Pouch/Chest */
+	ObjectInfo(124, 59,  0, 0x0504),   /* APPLE          Neck/Pouch/Chest */
+	ObjectInfo(132, 79, 38, 0x0500),   /* CORN           Pouch/Chest */
+	ObjectInfo(133, 63, 38, 0x0500),   /* BREAD          Pouch/Chest */
+	ObjectInfo(134, 64,  0, 0x0500),   /* CHEESE         Pouch/Chest */
+	ObjectInfo(136, 72, 39, 0x0400),   /* SCREAMER SLICE Chest */
+	ObjectInfo(137, 73,  0, 0x0500),   /* WORM ROUND     Pouch/Chest */
+	ObjectInfo(138, 74,  0, 0x0500),   /* DRUMSTICK      Pouch/Chest */
+	ObjectInfo(139, 75,  0, 0x0504),   /* DRAGON STEAK   Neck/Pouch/Chest */
+	ObjectInfo(192, 77,  0, 0x0500),   /* IRON KEY       Pouch/Chest */
+	ObjectInfo(193, 78,  0, 0x0500),   /* KEY OF B       Pouch/Chest */
+	ObjectInfo(197, 74,  0, 0x0000),   /* SOLID KEY */
+	ObjectInfo(198, 41,  0, 0x0400)}; /* SQUARE KEY     Chest */
+
 uint16 gJunkInfo[53] = { // @ G0241_auc_Graphic559_JunkInfo
 	1,   /* COMPASS */
 	3,   /* WATERSKIN */
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 00dbcc2..5a7bf24 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -42,6 +42,8 @@ public:
 	}
 }; // @ OBJECT_INFO
 
+extern ObjectInfo gObjectInfo[180];
+
 extern uint16 gJunkInfo[53];
 				
 enum ArmourAttribute {


Commit: 9d7f35cc8282f1ee6a41ea98d56388030435b4c4
    https://github.com/scummvm/scummvm/commit/9d7f35cc8282f1ee6a41ea98d56388030435b4c4
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add ObjectMan

Changed paths:
  A engines/dm/objectman.cpp
  A engines/dm/objectman.h
    engines/dm/module.mk



diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index 45a6ed5..088caf8 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -8,7 +8,8 @@ MODULE_OBJS := \
 	eventman.o \
 	menus.o \
 	champion.o \
-	loadsave.o
+	loadsave.o \
+	objectman.o
 
 MODULE_DIRS += \
 	engines/dm
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
new file mode 100644
index 0000000..4ab760d
--- /dev/null
+++ b/engines/dm/objectman.cpp
@@ -0,0 +1,8 @@
+#include "objectman.h"
+
+
+namespace DM {
+
+ObjectMan::ObjectMan(DMEngine *vm): _vm(vm) {}
+
+}
\ No newline at end of file
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
new file mode 100644
index 0000000..347703c
--- /dev/null
+++ b/engines/dm/objectman.h
@@ -0,0 +1,13 @@
+#include "dm.h"
+
+
+namespace DM {
+
+class ObjectMan {
+	DMEngine *_vm;
+public:
+	ObjectMan(DMEngine *vm);
+
+};
+
+}


Commit: 749ffcc3f0e7866a8edc8d9591fe70d152fc157a
    https://github.com/scummvm/scummvm/commit/749ffcc3f0e7866a8edc8d9591fe70d152fc157a
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0032_OBJECT_GetType

Changed paths:
    engines/dm/objectman.cpp
    engines/dm/objectman.h



diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 4ab760d..e65b061 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -1,8 +1,21 @@
 #include "objectman.h"
+#include "dungeonman.h"
 
 
 namespace DM {
 
 ObjectMan::ObjectMan(DMEngine *vm): _vm(vm) {}
 
+IconIndice ObjectMan::getObjectType(Thing thing) {
+	if (thing == Thing::_thingNone)
+		return kIconIndiceNone;
+
+	int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing);
+	if (objectInfoIndex != -1) {
+		objectInfoIndex = gObjectInfo[objectInfoIndex]._type;
+	}
+	return (IconIndice)objectInfoIndex;
+}
+
+
 }
\ No newline at end of file
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index 347703c..6421d7c 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -1,4 +1,5 @@
 #include "dm.h"
+#include "champion.h"
 
 
 namespace DM {
@@ -7,6 +8,7 @@ class ObjectMan {
 	DMEngine *_vm;
 public:
 	ObjectMan(DMEngine *vm);
+	IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType
 
 };
 


Commit: ceed621a51366be53bd5f189e275bf631328dd24
    https://github.com/scummvm/scummvm/commit/ceed621a51366be53bd5f189e275bf631328dd24
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix missing else in DMEngine::startGame()

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 2a20b86..4408eb4 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -113,7 +113,7 @@ void DMEngine::startGame() {
 
 	if (!_dungeonMan->_messages._newGame) {
 		warning("TODO: loading game");
-	} {
+	} else {
 		_displayMan->_useByteBoxCoordinates = false;
 		warning("TODO: clear screen");
 	}


Commit: 359ef01a338e9571101baac2ddb82032ca6a1cc7
    https://github.com/scummvm/scummvm/commit/359ef01a338e9571101baac2ddb82032ca6a1cc7
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add G0029_auc_Graphic562_ChargeCountToTorchType

Changed paths:
    engines/dm/objectman.cpp



diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index e65b061..04888ee 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -18,4 +18,7 @@ IconIndice ObjectMan::getObjectType(Thing thing) {
 }
 
 
+byte gChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType
+
+
 }
\ No newline at end of file


Commit: 23c1acff1939b8feb4bcbbf04bc44ca00321547d
    https://github.com/scummvm/scummvm/commit/23c1acff1939b8feb4bcbbf04bc44ca00321547d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add ObjectMan to DMEngine

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



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 4408eb4..af0868d 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -18,6 +18,7 @@
 #include "menus.h"
 #include "champion.h"
 #include "loadsave.h"
+#include "objectman.h"
 
 namespace DM {
 
@@ -49,6 +50,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_menuMan = nullptr;
 	_championMan = nullptr;
 	_loadsaveMan = nullptr;
+	_objectMan = nullptr;
 	_stopWaitingForPlayerInput = false;
 	_gameTimeTicking = false;
 
@@ -67,6 +69,7 @@ DMEngine::~DMEngine() {
 	delete _menuMan;
 	delete _championMan;
 	delete _loadsaveMan;
+	delete _objectMan;
 
 	// clear debug channels
 	DebugMan.clearAllDebugChannels();
@@ -142,6 +145,7 @@ Common::Error DMEngine::run() {
 	_menuMan = new MenuMan(this);
 	_championMan = new ChampionMan(this);
 	_loadsaveMan = new LoadsaveMan(this);
+	_objectMan = new ObjectMan(this);
 	_displayMan->setUpScreens(320, 200);
 
 	initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 468cd5c..14a8772 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -15,6 +15,7 @@ class EventManager;
 class MenuMan;
 class ChampionMan;
 class LoadsaveMan;
+class ObjectMan;
 
 
 enum direction {
@@ -99,6 +100,7 @@ public:
 	MenuMan *_menuMan;
 	ChampionMan *_championMan;
 	LoadsaveMan *_loadsaveMan;
+	ObjectMan *_objectMan;
 	bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput
 	bool _gameTimeTicking; // @ G0301_B_GameTimeTicking
 	bool _restartGameAllowed; // @ G0524_B_RestartGameAllowed


Commit: 29d832b353c94f2e1096117b34142ded9675f822
    https://github.com/scummvm/scummvm/commit/29d832b353c94f2e1096117b34142ded9675f822
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0033_OBJECT_GetIconIndex and several getters for object types

Changed paths:
    engines/dm/dungeonman.h
    engines/dm/objectman.cpp
    engines/dm/objectman.h



diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 5a7bf24..45130e8 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -313,6 +313,8 @@ public:
 	Weapon(uint16 *rawDat) : _nextThing(rawDat[0]), _desc(rawDat[1]) {}
 
 	WeaponType getType() { return (WeaponType)(_desc & 0x7F); }
+	bool isLit() { return (_desc >> 15) & 1; }
+	uint16 getChargeCount() { return (_desc >> 10) & 0xF; }
 	Thing getNextThing() { return _nextThing; }
 }; // @ WEAPON
 
@@ -343,6 +345,7 @@ public:
 		_attributes = attribs;
 	}
 	Thing getNextThing() { return _nextThing; }
+	uint16 getClosed() { return (_attributes >> 10) & 0x3F; } // ??? dunno why, the original bitfield is 6 bits long
 }; // @ SCROLL
 
 enum PotionType {
@@ -574,11 +577,13 @@ class DungeonMan {
 
 	void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
 
-	Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing)
-	uint16 *getThingData(Thing thing); // @ unsigned char* F0156_DUNGEON_GetThingData(register THING P0276_T_Thing)
 public:
 	DungeonMan(DMEngine *dmEngine);
 	~DungeonMan();
+
+	Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing)
+	uint16 *getThingData(Thing thing); // @ unsigned char* F0156_DUNGEON_GetThingData(register THING P0276_T_Thing)
+
 	// TODO: this does stuff other than load the file!
 	void loadDungeonFile();	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
 	void setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 04888ee..a373e94 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -4,7 +4,7 @@
 
 namespace DM {
 
-ObjectMan::ObjectMan(DMEngine *vm): _vm(vm) {}
+ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {}
 
 IconIndice ObjectMan::getObjectType(Thing thing) {
 	if (thing == Thing::_thingNone)
@@ -17,8 +17,54 @@ IconIndice ObjectMan::getObjectType(Thing thing) {
 	return (IconIndice)objectInfoIndex;
 }
 
-
 byte gChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType
 
+int16 ObjectMan::getIconIndex(Thing thing) {
+	IconIndice iconIndex = getObjectType(thing);
+
+	if ((iconIndex != kIconIndiceNone) &&
+		((iconIndex < kIconIndiceWeaponDagger) &&(iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error
+		((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) ||
+		(iconIndex == kIconIndicePotionEmptyFlask)
+		) {
+		uint16 *rawType = _vm->_dungeonMan->getThingData(thing);
+		switch (iconIndex) {
+		case kIconIndiceJunkCompassNorth:
+			iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_currMap._partyDir);
+			break;
+		case kIconIndiceWeaponTorchUnlit: {
+			Weapon weapon(rawType);
+			if (weapon.isLit()) {
+				iconIndex = (IconIndice)(iconIndex + gChargeCountToTorchType[weapon.getChargeCount()]);
+			}
+			break;
+		}
+		case kIconIndiceScrollOpen:
+			if (Scroll(rawType).getClosed()) {
+				iconIndex = (IconIndice)(iconIndex + 1);
+			}
+			break;
+		case kIconIndiceJunkWater:
+		case kIconIndiceJunkIllumuletUnequipped:
+		case kIconIndiceJunkJewelSymalUnequipped:
+			if (Junk(rawType).getChargeCount()) {
+				iconIndex = (IconIndice)(iconIndex + 1);
+			}
+			break;
+		case kIconIndiceWeaponBoltBladeStormEmpty:
+		case kIconIndiceWeaponFlamittEmpty:
+		case kIconIndiceWeaponStormringEmpty:
+		case kIconIndiceWeaponFuryRaBladeEmpty:
+		case kIconIndiceWeaponEyeOfTimeEmpty:
+		case kIconIndiceWeaponStaffOfClawsEmpty:
+			if (Weapon(rawType).getChargeCount()) {
+				iconIndex = (IconIndice)(iconIndex + 1);
+			}
+			break;
+		}
+	}
+
+	return iconIndex;
+}
 
 }
\ No newline at end of file
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index 6421d7c..bad5f7c 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -9,6 +9,7 @@ class ObjectMan {
 public:
 	ObjectMan(DMEngine *vm);
 	IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType
+	int16 getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
 
 };
 


Commit: 472778a06e141188dd157fd088873279970608db
    https://github.com/scummvm/scummvm/commit/472778a06e141188dd157fd088873279970608db
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Replace WeaponClass enum with #defines

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 01791bf..f93ad0f 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -307,52 +307,52 @@ ArmourInfo gArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo
 
 WeaponInfo gWeaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo
 							   /* { Weight, Class, Strength, KineticEnergy, Attributes } */
-	WeaponInfo(1, (WeaponClass)130,   2,   0, 0x2000),   /* EYE OF TIME */
-	WeaponInfo(1, (WeaponClass)131,   2,   0, 0x2000),   /* STORMRING */
-	WeaponInfo(11, (WeaponClass)0,   8,   2, 0x2000),   /* TORCH */
-	WeaponInfo(12, (WeaponClass)112,  10,  80, 0x2028),   /* FLAMITT */
-	WeaponInfo(9, (WeaponClass)129,  16,   7, 0x2000),   /* STAFF OF CLAWS */
-	WeaponInfo(30, (WeaponClass)113,  49, 110, 0x0942),   /* BOLT BLADE */
-	WeaponInfo(47, (WeaponClass)0,  55,  20, 0x0900),   /* FURY */
-	WeaponInfo(24, (WeaponClass)255,  25,  10, 0x20FF),   /* THE FIRESTAFF */
-	WeaponInfo(5, (WeaponClass)2,  10,  19, 0x0200),   /* DAGGER */
-	WeaponInfo(33, (WeaponClass)0,  30,   8, 0x0900),   /* FALCHION */
-	WeaponInfo(32, (WeaponClass)0,  34,  10, 0x0900),   /* SWORD */
-	WeaponInfo(26, (WeaponClass)0,  38,  10, 0x0900),   /* RAPIER */
-	WeaponInfo(35, (WeaponClass)0,  42,  11, 0x0900),   /* SABRE */
-	WeaponInfo(36, (WeaponClass)0,  46,  12, 0x0900),   /* SAMURAI SWORD */
-	WeaponInfo(33, (WeaponClass)0,  50,  14, 0x0900),   /* DELTA */
-	WeaponInfo(37, (WeaponClass)0,  62,  14, 0x0900),   /* DIAMOND EDGE */
-	WeaponInfo(30, (WeaponClass)0,  48,  13, 0x0000),   /* VORPAL BLADE */
-	WeaponInfo(39, (WeaponClass)0,  58,  15, 0x0900),   /* THE INQUISITOR */
-	WeaponInfo(43, (WeaponClass)2,  49,  33, 0x0300),   /* AXE */
-	WeaponInfo(65, (WeaponClass)2,  70,  44, 0x0300),   /* HARDCLEAVE */
-	WeaponInfo(31, (WeaponClass)0,  32,  10, 0x2000),   /* MACE */
-	WeaponInfo(41, (WeaponClass)0,  42,  13, 0x2000),   /* MACE OF ORDER */
-	WeaponInfo(50, (WeaponClass)0,  60,  15, 0x2000),   /* MORNINGSTAR */
-	WeaponInfo(36, (WeaponClass)0,  19,  10, 0x2700),   /* CLUB */
-	WeaponInfo(110, (WeaponClass)0,  44,  22, 0x2600),   /* STONE CLUB */
-	WeaponInfo(10, (WeaponClass)20,   1,  50, 0x2032),   /* BOW */
-	WeaponInfo(28, (WeaponClass)30,   1, 180, 0x2078),   /* CROSSBOW */
-	WeaponInfo(2, (WeaponClass)10,   2,  10, 0x0100),   /* ARROW */
-	WeaponInfo(2, (WeaponClass)10,   2,  28, 0x0500),   /* SLAYER */
-	WeaponInfo(19, (WeaponClass)39,   5,  20, 0x2032),   /* SLING */
-	WeaponInfo(10, (WeaponClass)11,   6,  18, 0x2000),   /* ROCK */
-	WeaponInfo(3, (WeaponClass)12,   7,  23, 0x0800),   /* POISON DART */
-	WeaponInfo(1, (WeaponClass)1,   3,  19, 0x0A00),   /* THROWING STAR */
-	WeaponInfo(8, (WeaponClass)0,   4,   4, 0x2000),   /* STICK */
-	WeaponInfo(26, (WeaponClass)129,  12,   4, 0x2000),   /* STAFF */
-	WeaponInfo(1, (WeaponClass)130,   0,   0, 0x2000),   /* WAND */
-	WeaponInfo(2, (WeaponClass)140,   1,  20, 0x2000),   /* TEOWAND */
-	WeaponInfo(35, (WeaponClass)128,  18,   6, 0x2000),   /* YEW STAFF */
-	WeaponInfo(29, (WeaponClass)159,   0,   4, 0x2000),   /* STAFF OF MANAR */
-	WeaponInfo(21, (WeaponClass)131,   0,   3, 0x2000),   /* SNAKE STAFF */
-	WeaponInfo(33, (WeaponClass)136,   0,   7, 0x2000),   /* THE CONDUIT */
-	WeaponInfo(8, (WeaponClass)132,   3,   1, 0x2000),   /* DRAGON SPIT */
-	WeaponInfo(18, (WeaponClass)131,   9,   4, 0x2000),   /* SCEPTRE OF LYF */
-	WeaponInfo(8, (WeaponClass)192,   1,   1, 0x2000),   /* HORN OF FEAR */
-	WeaponInfo(30, (WeaponClass)26,   1, 220, 0x207D),   /* SPEEDBOW */
-	WeaponInfo(36, (WeaponClass)255, 100,  50, 0x20FF)}; /* THE FIRESTAFF */
+	WeaponInfo(1, 130,   2,   0, 0x2000),   /* EYE OF TIME */
+	WeaponInfo(1, 131,   2,   0, 0x2000),   /* STORMRING */
+	WeaponInfo(11, 0,   8,   2, 0x2000),   /* TORCH */
+	WeaponInfo(12, 112,  10,  80, 0x2028),   /* FLAMITT */
+	WeaponInfo(9, 129,  16,   7, 0x2000),   /* STAFF OF CLAWS */
+	WeaponInfo(30, 113,  49, 110, 0x0942),   /* BOLT BLADE */
+	WeaponInfo(47, 0,  55,  20, 0x0900),   /* FURY */
+	WeaponInfo(24, 255,  25,  10, 0x20FF),   /* THE FIRESTAFF */
+	WeaponInfo(5, 2,  10,  19, 0x0200),   /* DAGGER */
+	WeaponInfo(33, 0,  30,   8, 0x0900),   /* FALCHION */
+	WeaponInfo(32, 0,  34,  10, 0x0900),   /* SWORD */
+	WeaponInfo(26, 0,  38,  10, 0x0900),   /* RAPIER */
+	WeaponInfo(35, 0,  42,  11, 0x0900),   /* SABRE */
+	WeaponInfo(36, 0,  46,  12, 0x0900),   /* SAMURAI SWORD */
+	WeaponInfo(33, 0,  50,  14, 0x0900),   /* DELTA */
+	WeaponInfo(37, 0,  62,  14, 0x0900),   /* DIAMOND EDGE */
+	WeaponInfo(30, 0,  48,  13, 0x0000),   /* VORPAL BLADE */
+	WeaponInfo(39, 0,  58,  15, 0x0900),   /* THE INQUISITOR */
+	WeaponInfo(43, 2,  49,  33, 0x0300),   /* AXE */
+	WeaponInfo(65, 2,  70,  44, 0x0300),   /* HARDCLEAVE */
+	WeaponInfo(31, 0,  32,  10, 0x2000),   /* MACE */
+	WeaponInfo(41, 0,  42,  13, 0x2000),   /* MACE OF ORDER */
+	WeaponInfo(50, 0,  60,  15, 0x2000),   /* MORNINGSTAR */
+	WeaponInfo(36, 0,  19,  10, 0x2700),   /* CLUB */
+	WeaponInfo(110, 0,  44,  22, 0x2600),   /* STONE CLUB */
+	WeaponInfo(10, 20,   1,  50, 0x2032),   /* BOW */
+	WeaponInfo(28, 30,   1, 180, 0x2078),   /* CROSSBOW */
+	WeaponInfo(2, 10,   2,  10, 0x0100),   /* ARROW */
+	WeaponInfo(2, 10,   2,  28, 0x0500),   /* SLAYER */
+	WeaponInfo(19, 39,   5,  20, 0x2032),   /* SLING */
+	WeaponInfo(10, 11,   6,  18, 0x2000),   /* ROCK */
+	WeaponInfo(3, 12,   7,  23, 0x0800),   /* POISON DART */
+	WeaponInfo(1, 1,   3,  19, 0x0A00),   /* THROWING STAR */
+	WeaponInfo(8, 0,   4,   4, 0x2000),   /* STICK */
+	WeaponInfo(26, 129,  12,   4, 0x2000),   /* STAFF */
+	WeaponInfo(1, 130,   0,   0, 0x2000),   /* WAND */
+	WeaponInfo(2, 140,   1,  20, 0x2000),   /* TEOWAND */
+	WeaponInfo(35, 128,  18,   6, 0x2000),   /* YEW STAFF */
+	WeaponInfo(29, 159,   0,   4, 0x2000),   /* STAFF OF MANAR */
+	WeaponInfo(21, 131,   0,   3, 0x2000),   /* SNAKE STAFF */
+	WeaponInfo(33, 136,   0,   7, 0x2000),   /* THE CONDUIT */
+	WeaponInfo(8, 132,   3,   1, 0x2000),   /* DRAGON SPIT */
+	WeaponInfo(18, 131,   9,   4, 0x2000),   /* SCEPTRE OF LYF */
+	WeaponInfo(8, 192,   1,   1, 0x2000),   /* HORN OF FEAR */
+	WeaponInfo(30, 26,   1, 220, 0x207D),   /* SPEEDBOW */
+	WeaponInfo(36, 255, 100,  50, 0x20FF)}; /* THE FIRESTAFF */
 
 CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo
 												   /* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo,
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 45130e8..41a3973 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -67,34 +67,32 @@ public:
 
 extern ArmourInfo gArmourInfo[58];
 
-enum WeaponClass {
 /* Class 0: SWING weapons */
-	kWeaponClassSwingWeapon = 0, // @ C000_CLASS_SWING_WEAPON 
-	/* Class 1 to 15: THROW weapons */
-	kWeaponClassDaggerAndAxes = 2, // @ C002_CLASS_DAGGER_AND_AXES 
-	kWeaponClassBowAmmunition = 10, // @ C010_CLASS_BOW_AMMUNITION
-	kWeaponClassSlingAmmunition = 11, // @ C011_CLASS_SLING_AMMUNITION
-	kWeaponClassPoisinDart = 12, // @ C012_CLASS_POISON_DART
-	/* Class 16 to 111: SHOOT weapons */
-	kWeaponClassFirstBow = 16, // @ C016_CLASS_FIRST_BOW 
-	kWeaponClassLastBow = 31, // @ C031_CLASS_LAST_BOW
-	kWeaponClassFirstSling = 32, // @ C032_CLASS_FIRST_SLING
-	kWeaponClassLastSling = 47, // @ C047_CLASS_LAST_SLING
-	/* Class 112 to 255: Magic and special weapons */
-	kWeaponClassFirstMagicWeapon = 112 // @ C112_CLASS_FIRST_MAGIC_WEAPON
-};
+#define kWeaponClassSwingWeapon			0 // @ C000_CLASS_SWING_WEAPON 
+/* Class 1 to 15: THROW weapons */
+#define kWeaponClassDaggerAndAxes		2 // @ C002_CLASS_DAGGER_AND_AXES 
+#define kWeaponClassBowAmmunition		10 // @ C010_CLASS_BOW_AMMUNITION
+#define kWeaponClassSlingAmmunition		11 // @ C011_CLASS_SLING_AMMUNITION
+#define kWeaponClassPoisinDart			12 // @ C012_CLASS_POISON_DART
+/* Class 16 to 111: SHOOT weapons */
+#define kWeaponClassFirstBow			16 // @ C016_CLASS_FIRST_BOW 
+#define kWeaponClassLastBow				31 // @ C031_CLASS_LAST_BOW
+#define kWeaponClassFirstSling			32 // @ C032_CLASS_FIRST_SLING
+#define kWeaponClassLastSling			47 // @ C047_CLASS_LAST_SLING
+/* Class 112 to 255: Magic and special weapons */
+#define kWeaponClassFirstMagicWeapon	112 // @ C112_CLASS_FIRST_MAGIC_WEAPON
 
 class WeaponInfo {
 
 public:
         uint16 _weight;
-        WeaponClass _class;
+        uint16 _class;
         uint16 _strength;
         uint16 _kineticEnergy;
 private:
 	uint16 _attributes; /* Bits 15-13 Unreferenced */
 public:
-        WeaponInfo(uint16 weight, WeaponClass wClass, uint16 strength, uint16 kineticEnergy, uint16 attributes)
+        WeaponInfo(uint16 weight, uint16 wClass, uint16 strength, uint16 kineticEnergy, uint16 attributes)
         	: _weight(weight), _class(wClass), _strength(strength), _kineticEnergy(kineticEnergy), _attributes(attributes) {}
 
         uint16 getShootAttack() {return _attributes & 0xFF;} // @ M65_SHOOT_ATTACK


Commit: 0597fdc6584f806f9dcae69c2456464014227908
    https://github.com/scummvm/scummvm/commit/0597fdc6584f806f9dcae69c2456464014227908
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add D24_FillScreenBox

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 790c055..ea05f44 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1500,3 +1500,9 @@ void DisplayMan::blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth
 byte* DisplayMan::getBitmap(uint16 index) {
 	return _bitmaps[index];
 }
+
+void DisplayMan::clearScreenBox(Color color, Box &box) {
+	uint16 width = box._x2 - box._x1;
+	for (int y = box._y1; y < box._y2; ++y)
+		memset(_vgaBuffer + y * _screenWidth + box._x1, color, sizeof(byte) * width);
+}
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 86a152a..749d487 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -286,6 +286,7 @@ public:
 
 	void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color);
 	void clearScreen(Color color);
+	void clearScreenBox(Color color, Box &box); // @ D24_FillScreenBox
 	void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
 	byte* getBitmap(uint16 index);


Commit: 592cd055758427c8832773cdde2e5fa09d89ed52
    https://github.com/scummvm/scummvm/commit/592cd055758427c8832773cdde2e5fa09d89ed52
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add G0026_ai_Graphic562_IconGraphicFirstIconIndex

Changed paths:
    engines/dm/objectman.cpp



diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index a373e94..0e6394f 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -4,6 +4,15 @@
 
 namespace DM {
 
+int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex
+	0,     /* First icon index in graphic #42 */
+	32,    /* First icon index in graphic #43 */
+	64,    /* First icon index in graphic #44 */
+	96,    /* First icon index in graphic #45 */
+	128,   /* First icon index in graphic #46 */
+	160,   /* First icon index in graphic #47 */
+	192}; /* First icon index in graphic #48 */
+
 ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {}
 
 IconIndice ObjectMan::getObjectType(Thing thing) {


Commit: 6e041819b480785b452a9023cdecb5421b8066ce
    https://github.com/scummvm/scummvm/commit/6e041819b480785b452a9023cdecb5421b8066ce
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0036_OBJECT_ExtractIconFromBitmap, K0077_ai_IconGraphicHeight, ObjectIcon indices

Changed paths:
    engines/dm/gfx.h
    engines/dm/objectman.cpp
    engines/dm/objectman.h



diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 749d487..46ce6e3 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -20,7 +20,14 @@ enum GraphicIndice {
 	kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT
 	kDoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
 	kChampionPortraitsIndice = 26, // @ C026_GRAPHIC_CHAMPION_PORTRAITS
-	kMovementArrowsIndice = 13 // @ C013_GRAPHIC_MOVEMENT_ARROWS
+	kMovementArrowsIndice = 13, // @ C013_GRAPHIC_MOVEMENT_ARROWS
+	kObjectIcons_000_TO_031 = 42, // @ C042_GRAPHIC_OBJECT_ICONS_000_TO_031
+	kObjectIcons_032_TO_063 = 43, // @ C043_GRAPHIC_OBJECT_ICONS_032_TO_063
+	kObjectIcons_064_TO_095 = 44, // @ C044_GRAPHIC_OBJECT_ICONS_064_TO_095
+	kObjectIcons_096_TO_127 = 45, // @ C045_GRAPHIC_OBJECT_ICONS_096_TO_127
+	kObjectIcons_128_TO_159 = 46, // @ C046_GRAPHIC_OBJECT_ICONS_128_TO_159
+	kObjectIcons_160_TO_191 = 47, // @ C047_GRAPHIC_OBJECT_ICONS_160_TO_191
+	kObjectIcons_192_TO_223 = 48 // @ C048_GRAPHIC_OBJECT_ICONS_192_TO_223
 };
 
 extern uint16 gPalSwoosh[16];
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 0e6394f..bc0b923 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -4,6 +4,8 @@
 
 namespace DM {
 
+int16 gIconGraphicHeight[7] = {32, 32, 32, 32, 32, 32, 32}; // @ K0077_ai_IconGraphicHeight
+
 int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex
 	0,     /* First icon index in graphic #42 */
 	32,    /* First icon index in graphic #43 */
@@ -76,4 +78,17 @@ int16 ObjectMan::getIconIndex(Thing thing) {
 	return iconIndex;
 }
 
+void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
+	int16 i;
+	for (i = 0; i < 7; ++i)
+		if (gIconGraphicFirstIndex[i] > iconIndex)
+			break;
+	--i;
+	byte *srcBitmap = _vm->_displayMan->getBitmap(kObjectIcons_000_TO_031 + i);
+	iconIndex -= gIconGraphicFirstIndex[i];
+	_vm->_displayMan->_useByteBoxCoordinates = true;
+	_vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, 0, 16, 0, 16, kColorNoTransparency);
+
+}
+
 }
\ No newline at end of file
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index bad5f7c..177d3bb 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -10,7 +10,7 @@ public:
 	ObjectMan(DMEngine *vm);
 	IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType
 	int16 getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
-
+	void extractIconFromBitmap(uint16 iconIndex, byte *srcBitmap); // F0036_OBJECT_ExtractIconFromBitmap
 };
 
 }


Commit: d9ed599de6a4c362f9d3eaf6e37b9fb1f86edfb3
    https://github.com/scummvm/scummvm/commit/d9ed599de6a4c362f9d3eaf6e37b9fb1f86edfb3
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon

Changed paths:
    engines/dm/menus.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index d7948c2..075543b 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -6,6 +6,8 @@
 
 namespace DM {
 
+byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
+
 MenuMan::MenuMan(DMEngine *vm): _vm(vm) {}
 
 void MenuMan::drawMovementArrows() {


Commit: 7782754d68e87d5bfd9980aa1c78a01c29a87574
    https://github.com/scummvm/scummvm/commit/7782754d68e87d5bfd9980aa1c78a01c29a87574
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0386_MENUS_DrawActionIcon

Changed paths:
    engines/dm/champion.h
    engines/dm/gfx.h
    engines/dm/menus.cpp
    engines/dm/menus.h
    engines/dm/objectman.cpp
    engines/dm/objectman.h



diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 89a1d05..0c8a46f 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -297,6 +297,7 @@ public:
 	void setStatistic(ChampionStatisticType type, ChampionStatisticValue valType, byte newVal) { _statistics[type][valType] = newVal; }
 
 	uint16 getAttributes() { return _attributes; }
+	uint16 getAttributes(ChampionAttribute flag) { return _attributes & flag; }
 	void setAttributeFlag(ChampionAttribute flag, bool value) {
 		if (value) {
 			_attributes |= flag;
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 46ce6e3..99d3f8f 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -44,6 +44,7 @@ public:
 	uint16 _y2;
 
 	Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): _x1(x1), _x2(x2 + 1), _y1(y1), _y2(y2 + 1) {}
+	Box() {}
 	bool isPointInside(Common::Point point) {
 		return (_x1 <= point.x) && (point.x < _x2) && (_y1 <= point.y) && (point.y < _y2);
 	}
@@ -257,9 +258,10 @@ class DisplayMan {
 
 	bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF
 
+public:
 	// some methods use this for a stratchpad, don't make assumptions about content between function calls
 	byte *_tmpBitmap;
-public:
+
 	DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 075543b..530ac24 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -1,32 +1,70 @@
-#include "menus.h"
-#include "gfx.h"
-#include "champion.h"
-#include "dungeonman.h"
-
-
-namespace DM {
-
-byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
-
-MenuMan::MenuMan(DMEngine *vm): _vm(vm) {}
-
-void MenuMan::drawMovementArrows() {
-	DisplayMan &disp = *_vm->_displayMan;
-	byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice);
-	Box &dest = gBoxMovementArrows;
-	uint16 w = disp.getWidth(kMovementArrowsIndice);
-
-	disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency);
-}
-void MenuMan::clearActingChampion() {
-	ChampionMan &cm = *_vm->_championMan;
-	if (cm._actingChampionOrdinal) {
-		cm._actingChampionOrdinal--;
-		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true);
-		warning("MISSING CODE: F0292_CHAMPION_DrawState");
-		cm._actingChampionOrdinal = indexToOrdinal(kChampionNone);
-		_shouldRefreshActionArea = true;
-	}
-}
-
-}
\ No newline at end of file
+#include "menus.h"
+#include "gfx.h"
+#include "champion.h"
+#include "dungeonman.h"
+#include "objectman.h"
+
+
+namespace DM {
+
+byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
+
+MenuMan::MenuMan(DMEngine *vm): _vm(vm) {}
+
+void MenuMan::drawMovementArrows() {
+	DisplayMan &disp = *_vm->_displayMan;
+	byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice);
+	Box &dest = gBoxMovementArrows;
+	uint16 w = disp.getWidth(kMovementArrowsIndice);
+
+	disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency);
+}
+void MenuMan::clearActingChampion() {
+	ChampionMan &cm = *_vm->_championMan;
+	if (cm._actingChampionOrdinal) {
+		cm._actingChampionOrdinal--;
+		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true);
+		warning("MISSING CODE: F0292_CHAMPION_DrawState");
+		cm._actingChampionOrdinal = indexToOrdinal(kChampionNone);
+		_shouldRefreshActionArea = true;
+	}
+}
+
+void MenuMan::drawActionIcon(ChampionIndex championIndex) {
+	if (!_actionAreaContainsIcons)
+		return;
+	DisplayMan &dm = *_vm->_displayMan;
+	Champion &champion = _vm->_championMan->_champions[championIndex];
+
+	Box box;
+	box._x1 = championIndex * 22 + 233;
+	box._x2 = box._x1 + 19 + 1;
+	box._y1 = 86;
+	box._y2 = 120 + 1;
+	dm._useByteBoxCoordinates = false;
+	if (!champion._currHealth) {
+		dm.clearScreenBox(kColorBlack, box);
+		return;
+	}
+	byte *bitmapIcon = dm._tmpBitmap;
+	Thing thing = champion.getSlot(kChampionSlotActionHand);
+	IconIndice iconIndex;
+	if (thing == Thing::_thingNone) {
+		iconIndex = kIconIndiceActionEmptyHand;
+	} else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
+		iconIndex = _vm->_objectMan->getIconIndex(thing);
+	} else {
+		dm.clearBitmap(bitmapIcon, 16, 16, kColorCyan);
+		goto T0386006;
+	}
+	_vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon);
+	dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, gPalChangesActionAreaObjectIcon);
+T0386006:
+	dm.clearScreenBox(kColorCyan, box);
+	Box box2;
+	box2._x1 = box._x1 + 2;
+	box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that
+	box2._y1 = 95;
+	box2._y2 = 110 + 1;
+	dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2);
+	if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) {
		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
	}
}
}
\ No newline at end of file
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index ce6c166..a35659d 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -2,6 +2,7 @@
 #define DM_MENUS_H
 
 #include "dm.h"
+#include "champion.h"
 
 namespace DM {
 
@@ -12,6 +13,7 @@ public:
 	bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons
 	MenuMan(DMEngine *vm);
 	void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
+	void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon
 
 	void drawMovementArrows();
 };
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index bc0b923..c237b91 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -30,7 +30,7 @@ IconIndice ObjectMan::getObjectType(Thing thing) {
 
 byte gChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType
 
-int16 ObjectMan::getIconIndex(Thing thing) {
+IconIndice ObjectMan::getIconIndex(Thing thing) {
 	IconIndice iconIndex = getObjectType(thing);
 
 	if ((iconIndex != kIconIndiceNone) &&
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index 177d3bb..908520c 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -9,7 +9,7 @@ class ObjectMan {
 public:
 	ObjectMan(DMEngine *vm);
 	IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType
-	int16 getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
+	IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
 	void extractIconFromBitmap(uint16 iconIndex, byte *srcBitmap); // F0036_OBJECT_ExtractIconFromBitmap
 };
 


Commit: f4f4c867a41a8bd306c3ec288e5b948ad1bf7e25
    https://github.com/scummvm/scummvm/commit/f4f4c867a41a8bd306c3ec288e5b948ad1bf7e25
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add InventoryMan, G0041_s_Graphic562_Box_ViewportFloppyZzzCross

Changed paths:
  A engines/dm/inventory.cpp
  A engines/dm/inventory.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/module.mk



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index af0868d..24182e3 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -19,6 +19,7 @@
 #include "champion.h"
 #include "loadsave.h"
 #include "objectman.h"
+#include "inventory.h"
 
 namespace DM {
 
@@ -51,6 +52,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_championMan = nullptr;
 	_loadsaveMan = nullptr;
 	_objectMan = nullptr;
+	_inventoryMan = nullptr;
 	_stopWaitingForPlayerInput = false;
 	_gameTimeTicking = false;
 
@@ -70,6 +72,7 @@ DMEngine::~DMEngine() {
 	delete _championMan;
 	delete _loadsaveMan;
 	delete _objectMan;
+	delete _inventoryMan;
 
 	// clear debug channels
 	DebugMan.clearAllDebugChannels();
@@ -146,6 +149,7 @@ Common::Error DMEngine::run() {
 	_championMan = new ChampionMan(this);
 	_loadsaveMan = new LoadsaveMan(this);
 	_objectMan = new ObjectMan(this);
+	_inventoryMan = new InventoryMan(this);
 	_displayMan->setUpScreens(320, 200);
 
 	initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 14a8772..66be764 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -16,6 +16,7 @@ class MenuMan;
 class ChampionMan;
 class LoadsaveMan;
 class ObjectMan;
+class InventoryMan;
 
 
 enum direction {
@@ -101,6 +102,7 @@ public:
 	ChampionMan *_championMan;
 	LoadsaveMan *_loadsaveMan;
 	ObjectMan *_objectMan;
+	InventoryMan *_inventoryMan;
 	bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput
 	bool _gameTimeTicking; // @ G0301_B_GameTimeTicking
 	bool _restartGameAllowed; // @ G0524_B_RestartGameAllowed
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
new file mode 100644
index 0000000..378d798
--- /dev/null
+++ b/engines/dm/inventory.cpp
@@ -0,0 +1,11 @@
+#include "inventory.h"
+
+
+
+namespace DM {
+
+Viewport gViewportFloppyZzzCross = {174, 2}; // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
+
+InventoryMan::InventoryMan(DMEngine *vm): _vm(vm) {}
+
+}
\ No newline at end of file
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
new file mode 100644
index 0000000..06488fe
--- /dev/null
+++ b/engines/dm/inventory.h
@@ -0,0 +1,14 @@
+#include "dm.h"
+#include "gfx.h"
+
+
+
+namespace DM {
+
+class InventoryMan {
+	DMEngine *_vm;
+public:
+	InventoryMan(DMEngine *vm);
+};
+
+}
\ No newline at end of file
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index 088caf8..3a7fa10 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -9,7 +9,8 @@ MODULE_OBJS := \
 	menus.o \
 	champion.o \
 	loadsave.o \
-	objectman.o
+	objectman.o \
+	inventory.o
 
 MODULE_DIRS += \
 	engines/dm


Commit: e64e352815cb80d4aa0b709b86ad30abb6b6ef8c
    https://github.com/scummvm/scummvm/commit/e64e352815cb80d4aa0b709b86ad30abb6b6ef8c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add G0326_B_RefreshMousePointerInMainLoop, G0598_B_MousePointerBitmapUpdated

Changed paths:
    engines/dm/eventman.h



diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index b2834e8..f72a985 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -199,6 +199,8 @@ class EventManager {
 public:
 	MouseInput* _primaryMouseInput;// @ G0441_ps_PrimaryMouseInput
 	MouseInput* _secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput
+	bool _mousePointerBitmapUpdated; // @ G0598_B_MousePointerBitmapUpdated
+	bool _refreshMousePointerInMainLoop; // @ G0326_B_RefreshMousePointerInMainLoop
 	bool _highlightBoxEnabled; // @ G0341_B_HighlightBoxEnabled
 	uint16 _useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap
 	EventManager(DMEngine *vm);


Commit: e9a4e818f21af256eea54bf08993425c6933e998
    https://github.com/scummvm/scummvm/commit/e9a4e818f21af256eea54bf08993425c6933e998
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0355_INVENTORY_Toggle_CPSE

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index ea05f44..223257c 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1501,7 +1501,7 @@ byte* DisplayMan::getBitmap(uint16 index) {
 	return _bitmaps[index];
 }
 
-void DisplayMan::clearScreenBox(Color color, Box &box) {
+void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) {
 	uint16 width = box._x2 - box._x1;
 	for (int y = box._y1; y < box._y2; ++y)
 		memset(_vgaBuffer + y * _screenWidth + box._x1, color, sizeof(byte) * width);
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 99d3f8f..6532291 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -27,7 +27,8 @@ enum GraphicIndice {
 	kObjectIcons_096_TO_127 = 45, // @ C045_GRAPHIC_OBJECT_ICONS_096_TO_127
 	kObjectIcons_128_TO_159 = 46, // @ C046_GRAPHIC_OBJECT_ICONS_128_TO_159
 	kObjectIcons_160_TO_191 = 47, // @ C047_GRAPHIC_OBJECT_ICONS_160_TO_191
-	kObjectIcons_192_TO_223 = 48 // @ C048_GRAPHIC_OBJECT_ICONS_192_TO_223
+	kObjectIcons_192_TO_223 = 48, // @ C048_GRAPHIC_OBJECT_ICONS_192_TO_223
+	kInventoryGraphicIndice = 17 // @ C017_GRAPHIC_INVENTORY
 };
 
 extern uint16 gPalSwoosh[16];
@@ -295,7 +296,7 @@ public:
 
 	void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color);
 	void clearScreen(Color color);
-	void clearScreenBox(Color color, Box &box); // @ D24_FillScreenBox
+	void clearScreenBox(Color color, Box &box, Viewport &viewport = gDefultViewPort); // @ D24_FillScreenBox
 	void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
 	byte* getBitmap(uint16 index);
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 378d798..7035933 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -1,11 +1,88 @@
 #include "inventory.h"
+#include "dungeonman.h"
+#include "eventman.h"
+#include "menus.h"
 
 
 
 namespace DM {
 
-Viewport gViewportFloppyZzzCross = {174, 2}; // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
+Box gBoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
 
 InventoryMan::InventoryMan(DMEngine *vm): _vm(vm) {}
 
+void InventoryMan::toggleInventory(ChampionIndex championIndex) {
+	ChampionMan &cm = *_vm->_championMan;
+	EventManager &em = *_vm->_eventMan;
+	DisplayMan &dm = *_vm->_displayMan;
+
+	if ((championIndex == kChmpionCloseInventory) && !cm._champions[championIndex]._currHealth)
+		return;
+	if (_vm->_pressingEye || _vm->_pressingMouth)
+		return;
+	_vm->_stopWaitingForPlayerInput = true;
+	int16 invChampOrdinal = _inventoryChampionOrdinal; // copy, as the original will be edited
+	if (indexToOrdinal(championIndex) == invChampOrdinal) {
+		championIndex = kChmpionCloseInventory;
+	}
+
+	Champion *champion;
+	if (invChampOrdinal) {
+		_inventoryChampionOrdinal = indexToOrdinal(kChampionNone);
+		warning("MISSING CODE: F0334_INVENTORY_CloseChest");
+		champion = &cm._champions[ordinalToIndex(kChampionNone)];
+		if (champion->_currHealth && !cm._candidateChampionOrdinal) {
+			champion->setAttributeFlag(kChampionAttributeStatusBox, true);
+			warning("MISSING CODE: F0292_CHAMPION_DrawState");
+		}
+		if (cm._partyIsSleeping) {
+			return;
+		}
+		if (championIndex == kChmpionCloseInventory) {
+			em._refreshMousePointerInMainLoop = true;
+			_vm->_menuMan->drawMovementArrows();
+			em._secondaryMouseInput = gSecondaryMouseInput_Movement;
+			warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput");
+			warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
+			return;
+		}
+	}
+
+	dm._useByteBoxCoordinates = false;
+	_inventoryChampionOrdinal = indexToOrdinal(championIndex);
+	if (!invChampOrdinal) {
+		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+	}
+
+	champion = &cm._champions[championIndex];
+	int16 w = dm.getWidth(kInventoryGraphicIndice);
+	int16 h = dm.getHeight(kInventoryGraphicIndice);
+	dm.blitToScreen(dm.getBitmap(kInventoryGraphicIndice), w, 0, 0, 0, w, 0, h, kColorNoTransparency, gDungeonViewport);
+	if (cm._candidateChampionOrdinal) {
+		dm.clearScreenBox(kColorDarkestGray, gBoxFloppyZzzCross, gDungeonViewport);
+	} else {
+		static Box gBoxFloppy = Box(174, 182, 2, 12); // @ K0300_s_Box_ViewportFloppy
+		dm.clearScreenBox(kColorDarkestGray, gBoxFloppy, gDungeonViewport);
+	}
+	warning("MISSING CODE: F0052_TEXT_PrintToViewport -> HEALTH");
+	warning("MISSING CODE: F0052_TEXT_PrintToViewport -> STAMINA");
+	warning("MISSING CODE: F0052_TEXT_PrintToViewport -> MANA");
+
+	warning("MISSING CODE: F0291_CHAMPION_DrawSlot in LOOOOOOOOOOOOP");
+
+	champion->setAttributeFlag(kChampionAttributeViewport, true);
+	champion->setAttributeFlag(kChampionAttributeStatusBox, true);
+	champion->setAttributeFlag(kChampionAttributePanel, true);
+	champion->setAttributeFlag(kChampionAttributeLoad, true);
+	champion->setAttributeFlag(kChampionAttributeStatistics, true);
+	champion->setAttributeFlag(kChampionAttributeNameTitle, true);
+
+	warning("MISSING CODE: F0292_CHAMPION_DrawState");
+	em._mousePointerBitmapUpdated = true;
+	em._secondaryMouseInput = gSecondaryMouseInput_ChampionInventory;
+	warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput");
+	warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
+}
+
+
 }
\ No newline at end of file
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 06488fe..6579708 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -1,5 +1,6 @@
 #include "dm.h"
 #include "gfx.h"
+#include "champion.h"
 
 
 
@@ -8,7 +9,9 @@ namespace DM {
 class InventoryMan {
 	DMEngine *_vm;
 public:
+	int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal
 	InventoryMan(DMEngine *vm);
+	void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE
 };
 
 }
\ No newline at end of file


Commit: 11e779e0a4cdcf00db4ef69940554da0faab91d5
    https://github.com/scummvm/scummvm/commit/11e779e0a4cdcf00db4ef69940554da0faab91d5
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0456_START_DrawDisabledMenus

Changed paths:
    engines/dm/menus.cpp
    engines/dm/menus.h



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 530ac24..1d8b00c 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -3,13 +3,14 @@
 #include "champion.h"
 #include "dungeonman.h"
 #include "objectman.h"
+#include "inventory.h"
 
 
 namespace DM {
 
 byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
 
-MenuMan::MenuMan(DMEngine *vm): _vm(vm) {}
+MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {}
 
 void MenuMan::drawMovementArrows() {
 	DisplayMan &disp = *_vm->_displayMan;
@@ -67,4 +68,4 @@ T0386006:
 	box2._y1 = 95;
 	box2._y2 = 110 + 1;
 	dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2);
-	if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) {
		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
	}
}
}
\ No newline at end of file
+	if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) {
		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
	}
}

void MenuMan::drawDisabledMenu() {
	if (!_vm->_championMan->_partyIsSleeping) {
		warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
		_vm->_displayMan->_useByteBoxCoordinates = false;
		if (_vm->_inventoryMan->_inventoryChampionOrdinal) {
			warning("MISSING CODE: F0334_INVENTORY_CloseChest");
		} else {
			warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
		}
		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
		warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal");
	}
}

}
\ No newline at end of file
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index a35659d..52b99ab 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -16,6 +16,7 @@ public:
 	void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon
 
 	void drawMovementArrows();
+	void drawDisabledMenu(); // @ F0456_START_DrawDisabledMenus
 };
 
 }


Commit: 334275756946b6079718bcbed16be3cd72afe0c2
    https://github.com/scummvm/scummvm/commit/334275756946b6079718bcbed16be3cd72afe0c2
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add G0234_ai_Graphic559_DirectionToStepNorthCount, G0233_ai_Graphic559_DirectionToStepEastCount, G0047_s_Graphic562_Box_ChampionPortrait

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 83d5204..a6b1ff6 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -4,6 +4,8 @@
 
 namespace DM {
 
+Box gBoxChampionPortrait = {0, 31, 0, 28}; // @ G0047_s_Graphic562_Box_ChampionPortrait 
+
 ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
 	_leaderIndex = kChampionNone;
 }
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 24182e3..63ddf12 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -23,8 +23,8 @@
 
 namespace DM {
 
-int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */};
-int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */};
+int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount
+int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
 
 void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
 void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); }


Commit: c87e3ba0488b10c4dafa7c8d36e99938b22e216a
    https://github.com/scummvm/scummvm/commit/c87e3ba0488b10c4dafa7c8d36e99938b22e216a
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix compilation, fix typos and some comment alignement

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index a6b1ff6..01f8637 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -4,7 +4,7 @@
 
 namespace DM {
 
-Box gBoxChampionPortrait = {0, 31, 0, 28}; // @ G0047_s_Graphic562_Box_ChampionPortrait 
+Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
 
 ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
 	_leaderIndex = kChampionNone;
@@ -37,7 +37,7 @@ ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
 
 void ChampionMan::resetDataToStartGame() {
 	if (!_vm->_dungeonMan->_messages._newGame) {
-		warning("MISSING CODE: stuff for reeseting for loaded games");
+		warning("MISSING CODE: stuff for resetting for loaded games");
 		assert(false);
 	}
 
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index f93ad0f..1ac9e85 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -522,12 +522,11 @@ void DungeonMan::decompressDungeonFile() {
 			}
 		}
 	} else {
-		// TODO: if the dungeon is uncompressed, read it here
+		warning("TODO: if the dungeon is uncompressed, read it here");
 	}
 	f.close();
 }
 
-
 uint8 gAdditionalThingCounts[16] = {
 	0,    /* Door */
 	0,    /* Teleporter */
@@ -547,13 +546,13 @@ uint8 gAdditionalThingCounts[16] = {
 	50    /* Explosion */
 }; // @ G0236_auc_Graphic559_AdditionalThingCounts
 
-// this is the number of uint16s the data has to be stored, not the lenght of the data in dungeon.dat!
+// this is the number of uint16s the data has to be stored, not the length of the data in dungeon.dat!
 unsigned char gThingDataWordCount[16] = {
 	2,   /* Door */
 	3,   /* Teleporter */
 	2,   /* Text String */
 	4,   /* Sensor */
-	9,  /* Group */
+	9,   /* Group */
 	2,   /* Weapon */
 	2,   /* Armour */
 	2,   /* Scroll */
@@ -570,7 +569,6 @@ unsigned char gThingDataWordCount[16] = {
 const Thing Thing::_thingNone(0);
 const Thing Thing::_thingEndOfList(0xFFFE);
 
-
 void DungeonMan::loadDungeonFile() {
 	if (_messages._newGame)
 		decompressDungeonFile();
@@ -675,7 +673,6 @@ void DungeonMan::loadDungeonFile() {
 	if (_messages._newGame)
 		_dunData._eventMaximumCount = 100;
 
-
 	// load things
 	for (uint16 thingType = kDoorThingType; thingType < kThingTypeTotal; ++thingType) {
 		uint16 thingCount = _fileHeader._thingCounts[thingType];
@@ -726,10 +723,8 @@ void DungeonMan::loadDungeonFile() {
 				_dunData._thingsData[thingType][thingCount + i][0] = Thing::_thingNone.toUint16();
 			}
 		}
-
 	}
 
-
 	// load map data
 	if (!_messages._restartGameRequest)
 		_rawMapData = _rawDunFileData + dunDataStream.pos();


Commit: 61500b3dc8253df3c62fada6ee6e5f297d67b33e
    https://github.com/scummvm/scummvm/commit/61500b3dc8253df3c62fada6ee6e5f297d67b33e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0280_CHAMPION_AddCandidateChampionToParty

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.h
    engines/dm/menus.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 01f8637..f93a9aa 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1,10 +1,54 @@
 #include "champion.h"
 #include "dungeonman.h"
+#include "eventman.h"
+#include "menus.h"
+#include "inventory.h"
 
 
 namespace DM {
 
-Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
+uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
+	/* 30 for champion inventory, 8 for chest */
+	0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Action Hand      Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0x0002,   /* Head             Head */
+	0x0008,   /* Torso            Torso */
+	0x0010,   /* Legs             Legs */
+	0x0020,   /* Feet             Feet */
+	0x0100,   /* Pouch 2          Pouch */
+	0x0080,   /* Quiver Line2 1   Quiver 2 */
+	0x0080,   /* Quiver Line1 2   Quiver 2 */
+	0x0080,   /* Quiver Line2 2   Quiver 2 */
+	0x0004,   /* Neck             Neck */
+	0x0100,   /* Pouch 1          Pouch */
+	0x0040,   /* Quiver Line1 1   Quiver 1 */
+	0xFFFF,   /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0x0400,   /* Chest 1          Chest */
+	0x0400,   /* Chest 2          Chest */
+	0x0400,   /* Chest 3          Chest */
+	0x0400,   /* Chest 4          Chest */
+	0x0400,   /* Chest 5          Chest */
+	0x0400,   /* Chest 6          Chest */
+	0x0400,   /* Chest 7          Chest */
+	0x0400}; /* Chest 8          Chest */
+
+Box gBoxChampionPortrait = {0, 31, 0, 28}; // @ G0047_s_Graphic562_Box_ChampionPortrait 
 
 ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
 	_leaderIndex = kChampionNone;
@@ -37,7 +81,7 @@ ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
 
 void ChampionMan::resetDataToStartGame() {
 	if (!_vm->_dungeonMan->_messages._newGame) {
-		warning("MISSING CODE: stuff for resetting for loaded games");
+		warning("MISSING CODE: stuff for reeseting for loaded games");
 		assert(false);
 	}
 
@@ -46,4 +90,177 @@ void ChampionMan::resetDataToStartGame() {
 	_leaderEmptyHanded = true;
 }
 
+
+void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
+	DisplayMan &dispMan = *_vm->_displayMan;
+	DungeonMan &dunMan = *_vm->_dungeonMan;
+
+	if (!_leaderEmptyHanded || _partyChampionCount == 4)
+		return;
+
+	uint16 prevChampCount = _partyChampionCount;
+	Champion *champ = &_champions[prevChampCount];
+	warning("MISSING CODE: Fill champ memory with zero bytes");
+	dispMan._useByteBoxCoordinates = true;
+	{ // block on purpose
+		Box &destBox = gBoxChampionPortrait;
+		dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex),
+							 champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency);
+	}
+
+	champ->_actionIndex = kChampionActionNone;
+	champ->_enableActionEventIndex = -1;
+	champ->_hideDamageReceivedIndex = -1;
+	champ->_dir = dunMan._currMap._partyDir;
+	ViewCell AL_0_viewCell = kViewCellFronLeft;
+	while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone)
+		AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
+	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3);
+	champ->clearAttributes(kChampionAttributeIcon);
+	champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir;
+	champ->_food = 1500 + _vm->_rnd->getRandomNumber(256);
+	champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
+	int16 AL_0_slotIndex_Red;
+	for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) {
+		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone);
+	}
+	Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY);
+	while (thing.getType() != kTextstringType) {
+		thing = dunMan.getNextThing(thing);
+	}
+	char decodedChampionText[77];
+	char* character_Green = decodedChampionText;
+	dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible));
+	int16 AL_0_characterIndex = 0;
+	uint16 AL_2_character;
+	while ((AL_2_character = *character_Green++) != '\n') {
+		champ->_name[AL_0_characterIndex++] = AL_2_character;
+	}
+	champ->_name[AL_0_characterIndex] = '\0';
+	AL_0_characterIndex = 0;
+	bool AL_4_champTitleCopied = false;
+	for (;;) { // infinite
+		AL_2_character = *character_Green++;
+		if (AL_2_character == '\n') {
+			if (AL_4_champTitleCopied)
+				break;
+			AL_4_champTitleCopied = true;
+		} else {
+			champ->_title[AL_0_characterIndex++] = AL_2_character;
+		}
+	}
+	champ->_title[AL_0_characterIndex] = '\0';
+	if (*character_Green++ == 'M') {
+		champ->setAttributeFlag(kChampionAttributeMale, true);
+	}
+	character_Green++;
+	champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4);
+	character_Green += 4;
+	champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4);
+	character_Green += 4;
+	character_Green++;
+
+	int16 AL_0_statisticIndex;
+	for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) {
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30);
+		uint16 currMaxVal = getDecodedValue(character_Green, 2);
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal);
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal);
+		character_Green += 2;
+	}
+
+	champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10);
+	character_Green++;
+
+	int16 AL_0_skillIndex;
+	int16 AL_2_skillValue;
+	for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) {
+		if ((AL_2_skillValue = *character_Green++ - 'A') > 0) {
+			champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue);
+		}
+	}
+
+	for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) {
+		int32 baseSkillExp = 0;
+		int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2;
+		for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) {
+			baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience;
+		}
+		champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp);
+	}
+
+	_candidateChampionOrdinal = prevChampCount + 1;
+	if (++_partyChampionCount == 1) {
+		_vm->_eventMan->commandSetLeader(kChampionFirst);
+		_vm->_menuMan->_shouldRefreshActionArea = true;
+	} else {
+		_vm->_menuMan->clearActingChampion();
+		_vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1));
+	}
+
+	int16 mapX = _vm->_dungeonMan->_currMap._partyPosX;
+	int16 mapY = _vm->_dungeonMan->_currMap._partyPosY;
+
+	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir));
+	mapX += dirIntoStepCountEast[dunMan._currMap._partyDir];
+	mapY += dirIntoStepCountNorth[dunMan._currMap._partyDir];
+	thing = dunMan.getSquareFirstThing(mapX, mapY);
+	AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
+	uint16 slotIndex_Green;
+	while (thing != Thing::_thingNone) {
+		ThingType AL_2_thingType = thing.getType();
+		if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) {
+			int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots();
+			switch (AL_2_thingType) {
+			case kArmourThingType:
+				for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) {
+					if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
+						goto T0280048;
+				}
+				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
+					slotIndex_Green = kChampionSlotNeck;
+				} else {
+					goto T0280046;
+				}
+				break;
+			case kWeaponThingType:
+				if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) {
+					slotIndex_Green = kChampionSlotActionHand;
+				} else {
+					goto T0280046;
+				}
+				break;
+			case kScrollThingType:
+			case kPotionThingType:
+				if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) {
+					slotIndex_Green = kChampionSlotPouch_1;
+				} else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) {
+					slotIndex_Green = kChampionSlotPouch_2;
+				} else {
+					goto T0280046;
+				}
+				break;
+			case kContainerThingType:
+			case kJunkThingType:
+T0280046:
+				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
+					slotIndex_Green = kChampionSlotNeck;
+				} else {
+					slotIndex_Green = AL_0_slotIndex_Red++;
+				}
+				break;
+			}
+T0280048:
+			if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) {
+				goto T0280046;
+			}
+			warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot");
+		}
+		thing = dunMan.getNextThing(thing);
+	}
+
+	_vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount);
+	_vm->_menuMan->drawDisabledMenu();
+}
+
 }
\ No newline at end of file
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 0c8a46f..96a5ef5 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -251,8 +251,9 @@ enum ChampionAction {
 
 
 class Skill {
-	int _temporaryExperience;
-	long _experience;
+public:
+	int16 _temporaryExperience;
+	int32 _experience;
 }; // @ SKILL
 
 class Champion {
@@ -291,7 +292,8 @@ public:
 	void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; }
 
 	Skill getSkill(ChampionSkill skill) { return _skills[skill]; }
-	void setSkill(ChampionSkill skill, Skill val) { _skills[skill] = val; }
+	void setSkillExp(ChampionSkill skill,  int32 val) { _skills[skill]._experience = val; }
+	void setSkillTempExp(ChampionSkill skill,  int16 val) { _skills[skill]._temporaryExperience= val; }
 
 	byte getStatistic(ChampionStatisticType type, ChampionStatisticValue valType) { return _statistics[type][valType]; }
 	void setStatistic(ChampionStatisticType type, ChampionStatisticValue valType, byte newVal) { _statistics[type][valType] = newVal; }
@@ -305,7 +307,7 @@ public:
 			_attributes &= ~flag;
 		}
 	}
-	void clearAttributes() { _attributes = kChampionAttributNone; }
+	void clearAttributes(ChampionAttribute attribute = kChampionAttributNone) { _attributes = attribute; }
 
 	uint16 getWounds() { return _wounds; }
 	void setWoundsFlag(ChampionWound flag, bool value) {
@@ -340,8 +342,10 @@ public:
 
 	ChampionMan(DMEngine *vm);
 	void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
+	void addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty
 };
 
+
 }
 
 #endif
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 63ddf12..860fba2 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -28,6 +28,7 @@ int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /
 
 void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
 void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); }
+direction returnOppositeDir(direction dir) { return (direction)((dir + 2) & 3); }
 bool isOrientedWestEast(direction dir) { return dir & 1; }
 
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 66be764..61cb92c 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -32,6 +32,7 @@ extern int8 dirIntoStepCountNorth[4];
 
 void turnDirRight(direction &dir);
 void turnDirLeft(direction &dir);
+direction returnOppositeDir(direction dir);
 bool isOrientedWestEast(direction dir);
 
 
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 41a3973..ad64b85 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -33,6 +33,7 @@ public:
 	ObjectInfo(int16 type, uint16 objectAspectIndex, uint16 actionSetIndex, uint16 allowedSlots)
 		: _type(type), _objectAspectIndex(objectAspectIndex), _actionSetIndex(actionSetIndex), _allowedSlots(allowedSlots) {}
 	bool getAllowedSlot(ObjectAllowedSlot slot) { return _allowedSlots & slot; }
+	uint16 getAllowedSlots() { return _allowedSlots; }
 	void setAllowedSlot(ObjectAllowedSlot slot, bool val) {
 		if (val) {
 			_allowedSlots |= slot;
@@ -566,7 +567,6 @@ class DungeonMan {
 	void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon
 
 	int16 getSquareFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex
-	Thing getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing
 
 	int16 getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal
 	void setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
@@ -579,6 +579,7 @@ public:
 	DungeonMan(DMEngine *dmEngine);
 	~DungeonMan();
 
+	Thing getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing
 	Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing)
 	uint16 *getThingData(Thing thing); // @ unsigned char* F0156_DUNGEON_GetThingData(register THING P0276_T_Thing)
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 1d8b00c..d39aa22 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -1,71 +1,91 @@
-#include "menus.h"
-#include "gfx.h"
-#include "champion.h"
-#include "dungeonman.h"
-#include "objectman.h"
-#include "inventory.h"
-
-
-namespace DM {
-
-byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
-
-MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {}
-
-void MenuMan::drawMovementArrows() {
-	DisplayMan &disp = *_vm->_displayMan;
-	byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice);
-	Box &dest = gBoxMovementArrows;
-	uint16 w = disp.getWidth(kMovementArrowsIndice);
-
-	disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency);
-}
-void MenuMan::clearActingChampion() {
-	ChampionMan &cm = *_vm->_championMan;
-	if (cm._actingChampionOrdinal) {
-		cm._actingChampionOrdinal--;
-		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true);
-		warning("MISSING CODE: F0292_CHAMPION_DrawState");
-		cm._actingChampionOrdinal = indexToOrdinal(kChampionNone);
-		_shouldRefreshActionArea = true;
-	}
-}
-
-void MenuMan::drawActionIcon(ChampionIndex championIndex) {
-	if (!_actionAreaContainsIcons)
-		return;
-	DisplayMan &dm = *_vm->_displayMan;
-	Champion &champion = _vm->_championMan->_champions[championIndex];
-
-	Box box;
-	box._x1 = championIndex * 22 + 233;
-	box._x2 = box._x1 + 19 + 1;
-	box._y1 = 86;
-	box._y2 = 120 + 1;
-	dm._useByteBoxCoordinates = false;
-	if (!champion._currHealth) {
-		dm.clearScreenBox(kColorBlack, box);
-		return;
-	}
-	byte *bitmapIcon = dm._tmpBitmap;
-	Thing thing = champion.getSlot(kChampionSlotActionHand);
-	IconIndice iconIndex;
-	if (thing == Thing::_thingNone) {
-		iconIndex = kIconIndiceActionEmptyHand;
-	} else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
-		iconIndex = _vm->_objectMan->getIconIndex(thing);
-	} else {
-		dm.clearBitmap(bitmapIcon, 16, 16, kColorCyan);
-		goto T0386006;
-	}
-	_vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon);
-	dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, gPalChangesActionAreaObjectIcon);
-T0386006:
-	dm.clearScreenBox(kColorCyan, box);
-	Box box2;
-	box2._x1 = box._x1 + 2;
-	box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that
-	box2._y1 = 95;
-	box2._y2 = 110 + 1;
-	dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2);
-	if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) {
		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
	}
}

void MenuMan::drawDisabledMenu() {
	if (!_vm->_championMan->_partyIsSleeping) {
		warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
		_vm->_displayMan->_useByteBoxCoordinates = false;
		if (_vm->_inventoryMan->_inventoryChampionOrdinal) {
			warning("MISSING CODE: F0334_INVENTORY_CloseChest");
		} else {
			warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
		}
		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
		warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal");
	}
}

}
\ No newline at end of file
+#include "menus.h"
+#include "gfx.h"
+#include "champion.h"
+#include "dungeonman.h"
+#include "objectman.h"
+#include "inventory.h"
+
+
+namespace DM {
+
+byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
+
+MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {}
+
+void MenuMan::drawMovementArrows() {
+	DisplayMan &disp = *_vm->_displayMan;
+	byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice);
+	Box &dest = gBoxMovementArrows;
+	uint16 w = disp.getWidth(kMovementArrowsIndice);
+
+	disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency);
+}
+void MenuMan::clearActingChampion() {
+	ChampionMan &cm = *_vm->_championMan;
+	if (cm._actingChampionOrdinal) {
+		cm._actingChampionOrdinal--;
+		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true);
+		warning("MISSING CODE: F0292_CHAMPION_DrawState");
+		cm._actingChampionOrdinal = indexToOrdinal(kChampionNone);
+		_shouldRefreshActionArea = true;
+	}
+}
+
+void MenuMan::drawActionIcon(ChampionIndex championIndex) {
+	if (!_actionAreaContainsIcons)
+		return;
+	DisplayMan &dm = *_vm->_displayMan;
+	Champion &champion = _vm->_championMan->_champions[championIndex];
+
+	Box box;
+	box._x1 = championIndex * 22 + 233;
+	box._x2 = box._x1 + 19 + 1;
+	box._y1 = 86;
+	box._y2 = 120 + 1;
+	dm._useByteBoxCoordinates = false;
+	if (!champion._currHealth) {
+		dm.clearScreenBox(kColorBlack, box);
+		return;
+	}
+	byte *bitmapIcon = dm._tmpBitmap;
+	Thing thing = champion.getSlot(kChampionSlotActionHand);
+	IconIndice iconIndex;
+	if (thing == Thing::_thingNone) {
+		iconIndex = kIconIndiceActionEmptyHand;
+	} else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
+		iconIndex = _vm->_objectMan->getIconIndex(thing);
+	} else {
+		dm.clearBitmap(bitmapIcon, 16, 16, kColorCyan);
+		goto T0386006;
+	}
+	_vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon);
+	dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, gPalChangesActionAreaObjectIcon);
+T0386006:
+	dm.clearScreenBox(kColorCyan, box);
+	Box box2;
+	box2._x1 = box._x1 + 2;
+	box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that
+	box2._y1 = 95;
+	box2._y2 = 110 + 1;
+	dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2);
+	if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) {
+		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+	}
+}
+
+void MenuMan::drawDisabledMenu() {
+	if (!_vm->_championMan->_partyIsSleeping) {
+		warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
+		_vm->_displayMan->_useByteBoxCoordinates = false;
+		if (_vm->_inventoryMan->_inventoryChampionOrdinal) {
+			warning("MISSING CODE: F0334_INVENTORY_CloseChest");
+		} else {
+			warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+		}
+		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+		warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal");
+	}
+}
+
+}
\ No newline at end of file


Commit: cfebcea041d9fd123e06a01d1ddaf87b6e246bc0
    https://github.com/scummvm/scummvm/commit/cfebcea041d9fd123e06a01d1ddaf87b6e246bc0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add dummy test code for chmpion selection

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index f93a9aa..6518ee9 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -48,7 +48,7 @@ uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
 	0x0400,   /* Chest 7          Chest */
 	0x0400}; /* Chest 8          Chest */
 
-Box gBoxChampionPortrait = {0, 31, 0, 28}; // @ G0047_s_Graphic562_Box_ChampionPortrait 
+Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
 
 ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
 	_leaderIndex = kChampionNone;
@@ -81,7 +81,7 @@ ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
 
 void ChampionMan::resetDataToStartGame() {
 	if (!_vm->_dungeonMan->_messages._newGame) {
-		warning("MISSING CODE: stuff for reeseting for loaded games");
+		warning("MISSING CODE: stuff for resetting for loaded games");
 		assert(false);
 	}
 
@@ -202,8 +202,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	int16 mapY = _vm->_dungeonMan->_currMap._partyPosY;
 
 	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir));
-	mapX += dirIntoStepCountEast[dunMan._currMap._partyDir];
-	mapY += dirIntoStepCountNorth[dunMan._currMap._partyDir];
+	mapX += gDirIntoStepCountEast[dunMan._currMap._partyDir];
+	mapY += gDirIntoStepCountNorth[dunMan._currMap._partyDir];
 	thing = dunMan.getSquareFirstThing(mapX, mapY);
 	AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
 	uint16 slotIndex_Green;
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 860fba2..6d9b503 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -23,8 +23,8 @@
 
 namespace DM {
 
-int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount
-int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
+int8 gDirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount
+int8 gDirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
 
 void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
 void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); }
@@ -163,6 +163,11 @@ Common::Error DMEngine::run() {
 }
 
 void DMEngine::gameloop() {
+	warning("DUMMY CODE SETTING PARTY POS AND DIRECTION");
+	_dungeonMan->_currMap._partyPosX = 10;
+	_dungeonMan->_currMap._partyPosY = 4;
+	_dungeonMan->_currMap._partyDir = kDirNorth;
+	
 	while (true) {
 		_stopWaitingForPlayerInput = false;
 		//do {
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 61cb92c..d9cecaa 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -27,8 +27,8 @@ enum direction {
 };
 
 // TODO: refactor direction into a class
-extern int8 dirIntoStepCountEast[4];
-extern int8 dirIntoStepCountNorth[4];
+extern int8 gDirIntoStepCountEast[4];
+extern int8 gDirIntoStepCountNorth[4];
 
 void turnDirRight(direction &dir);
 void turnDirLeft(direction &dir);
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 1ac9e85..f489c53 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -391,11 +391,11 @@ int16 DM::indexToOrdinal(int16 val) { return val + 1; }
 
 
 void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
-	posX += dirIntoStepCountEast[dir] * stepsForward;
-	posY += dirIntoStepCountNorth[dir] * stepsForward;
+	posX += gDirIntoStepCountEast[dir] * stepsForward;
+	posY += gDirIntoStepCountNorth[dir] * stepsForward;
 	turnDirRight(dir);
-	posX += dirIntoStepCountEast[dir] * stepsRight;
-	posY += dirIntoStepCountNorth[dir] * stepsRight;
+	posX += gDirIntoStepCountEast[dir] * stepsRight;
+	posY += gDirIntoStepCountNorth[dir] * stepsRight;
 }
 
 DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) {
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 6d76ddb..a7a3303 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -372,6 +372,21 @@ void EventManager::processCommandQueue() {
 	if ((cmd._type >= kCommandMoveForward) && (cmd._type <= kCommandMoveLeft)) {
 		commandMoveParty(cmd._type);
 		return;
+	}		 
+	
+	if (cmd._type == kCommandClickInDungeonView) {
+		warning("DUMMY CODE, all of this");
+		DungeonMan &dunMan = *_vm->_dungeonMan;
+		CurrMapData &currMap = dunMan._currMap;
+		uint16 mapX = currMap._partyPosX;
+		uint16 mapY = currMap._partyPosY;
+		mapX += gDirIntoStepCountEast[currMap._partyDir];
+		mapY += gDirIntoStepCountNorth[currMap._partyDir];
+		Thing squareFirstThing = dunMan.getSquareFirstThing(mapX, mapY);
+		Sensor sensor(dunMan.getThingData(squareFirstThing));
+		if (sensor.getType() == kSensorWallChampionPortrait) {
+			_vm->_championMan->addCandidateChampionToParty(sensor.getData());
+		}
 	}
 
 	// MISSING CODE: the rest of the function


Commit: 0e0fb9763220f0949925fe8d5c6e0dcbd2a15b14
    https://github.com/scummvm/scummvm/commit/0e0fb9763220f0949925fe8d5c6e0dcbd2a15b14
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some renaming

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 6518ee9..1ef0e8a 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -202,8 +202,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	int16 mapY = _vm->_dungeonMan->_currMap._partyPosY;
 
 	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir));
-	mapX += gDirIntoStepCountEast[dunMan._currMap._partyDir];
-	mapY += gDirIntoStepCountNorth[dunMan._currMap._partyDir];
+	mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir];
+	mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir];
 	thing = dunMan.getSquareFirstThing(mapX, mapY);
 	AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
 	uint16 slotIndex_Green;
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 6d9b503..e8543fc 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -23,8 +23,8 @@
 
 namespace DM {
 
-int8 gDirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount
-int8 gDirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
+int8 _dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount
+int8 _dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
 
 void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
 void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); }
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index d9cecaa..0b69aff 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -27,15 +27,14 @@ enum direction {
 };
 
 // TODO: refactor direction into a class
-extern int8 gDirIntoStepCountEast[4];
-extern int8 gDirIntoStepCountNorth[4];
+extern int8 _dirIntoStepCountEast[4];
+extern int8 _dirIntoStepCountNorth[4];
 
 void turnDirRight(direction &dir);
 void turnDirLeft(direction &dir);
 direction returnOppositeDir(direction dir);
 bool isOrientedWestEast(direction dir);
 
-
 enum ThingType {
 	kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value
 	kDoorThingType = 0,
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index f489c53..d9554f2 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -391,11 +391,11 @@ int16 DM::indexToOrdinal(int16 val) { return val + 1; }
 
 
 void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
-	posX += gDirIntoStepCountEast[dir] * stepsForward;
-	posY += gDirIntoStepCountNorth[dir] * stepsForward;
+	posX += _dirIntoStepCountEast[dir] * stepsForward;
+	posY += _dirIntoStepCountNorth[dir] * stepsForward;
 	turnDirRight(dir);
-	posX += gDirIntoStepCountEast[dir] * stepsRight;
-	posY += gDirIntoStepCountNorth[dir] * stepsRight;
+	posX += _dirIntoStepCountEast[dir] * stepsRight;
+	posY += _dirIntoStepCountNorth[dir] * stepsRight;
 }
 
 DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) {
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index ad64b85..3dc3ab4 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -176,19 +176,19 @@ enum TeleporterScope {
 
 
 class Teleporter {
-	Thing nextThing;
-	uint16 attributes;
-	uint16 destMapIndex;
+	Thing _nextThing;
+	uint16 _attributes;
+	uint16 _destMapIndex;
 public:
-	Teleporter(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]), destMapIndex(rawDat[2]) {}
-	Thing getNextThing() { return nextThing; }
-	bool makesSound() { return (attributes >> 15) & 1; }
-	TeleporterScope getScope() { return (TeleporterScope)((attributes >> 13) & 1); }
-	bool absRotation() { return (attributes >> 12) & 1; }
-	direction getRotationDir() { return (direction)((attributes >> 10) & 1); }
-	byte getDestY() { return (attributes >> 5) & 0xF; }
-	byte getDestX() { return attributes & 0xF; }
-	uint16 getDestMapIndex() { return destMapIndex >> 8; }
+	Teleporter(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]), _destMapIndex(rawDat[2]) {}
+	Thing getNextThing() { return _nextThing; }
+	bool makesSound() { return (_attributes >> 15) & 1; }
+	TeleporterScope getScope() { return (TeleporterScope)((_attributes >> 13) & 1); }
+	bool absRotation() { return (_attributes >> 12) & 1; }
+	direction getRotationDir() { return (direction)((_attributes >> 10) & 1); }
+	byte getDestY() { return (_attributes >> 5) & 0xF; }
+	byte getDestX() { return _attributes & 0xF; }
+	uint16 getDestMapIndex() { return _destMapIndex >> 8; }
 }; // @ TELEPORTER
 
 


Commit: 2a2a9a53b0b6dbd0cb18104b2603b3f7968f9d74
    https://github.com/scummvm/scummvm/commit/2a2a9a53b0b6dbd0cb18104b2603b3f7968f9d74
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add champion reset, fix ChampionMan::addCandidateChampionToPart while loop condition

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 1ef0e8a..ec098ee 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -100,9 +100,9 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 
 	uint16 prevChampCount = _partyChampionCount;
 	Champion *champ = &_champions[prevChampCount];
-	warning("MISSING CODE: Fill champ memory with zero bytes");
+	champ->resetToZero();
 	dispMan._useByteBoxCoordinates = true;
-	{ // block on purpose
+	{ // limit destBox scope
 		Box &destBox = gBoxChampionPortrait;
 		dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex),
 							 champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency);
@@ -207,7 +207,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	thing = dunMan.getSquareFirstThing(mapX, mapY);
 	AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
 	uint16 slotIndex_Green;
-	while (thing != Thing::_thingNone) {
+	while (thing != Thing::_thingEndOfList) {
 		ThingType AL_2_thingType = thing.getType();
 		if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) {
 			int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots();
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 96a5ef5..a3c6f80 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -254,6 +254,8 @@ class Skill {
 public:
 	int16 _temporaryExperience;
 	int32 _experience;
+	
+	void resetToZero() { _temporaryExperience = _experience = 0; }
 }; // @ SKILL
 
 class Champion {
@@ -318,6 +320,25 @@ public:
 		}
 	}
 	void clearWounds() { _wounds = kChampionWoundNone; }
+	void resetToZero() { // oh boy > . <
+		for (int16 i = 0; i < 30; ++i)
+			_slots[i] = Thing::_thingNone;
+		for (int16 i = 0; i < 20; ++i)
+			_skills[i].resetToZero();
+		_attributes = _wounds = 0;
+		memset(_statistics, 0, 7 * 3);
+		memset(_name, '\0', 8);
+		memset(_title, '\0', 20);
+		_dir = kDirNorth;
+		_cell = kViewCellFronLeft;
+		_actionIndex = kChampionActionN;
+		_symbolStep = 0;
+		memset(_symbols, '\0', 5);
+		_directionMaximumDamageReceived = _maximumDamageReceived = _poisonEventCount = _enableActionEventIndex = 0;
+		_hideDamageReceivedIndex = _currHealth = _maxHealth = _currStamina = _maxStamina = _currMana = _maxMana = 0;
+		_actionDefense = _food = _water = _load = _shieldDefense = 0;
+		memset(_portrait, 0, 464);
+	}
 }; // @ CHAMPION_INCLUDING_PORTRAIT
 
 class ChampionMan {


Commit: 051b1d9adf69ac82a76751a0fe13c69ac7822934
    https://github.com/scummvm/scummvm/commit/051b1d9adf69ac82a76751a0fe13c69ac7822934
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove demo code from ToggleInventory,  add dummy code setting _inventoryChampionOrdinal, fix error in InventoryToggle getting champion pointer

Changed paths:
    engines/dm/dm.cpp
    engines/dm/inventory.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index e8543fc..c1d7e14 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -168,6 +168,9 @@ void DMEngine::gameloop() {
 	_dungeonMan->_currMap._partyPosY = 4;
 	_dungeonMan->_currMap._partyDir = kDirNorth;
 	
+
+	warning("DUMMY CODE: setting InventoryMan::_inventoryChampionOrdinal to zero");
+	_inventoryMan->_inventoryChampionOrdinal = 0;
 	while (true) {
 		_stopWaitingForPlayerInput = false;
 		//do {
@@ -175,8 +178,9 @@ void DMEngine::gameloop() {
 		_eventMan->processCommandQueue();
 		//} while (!_stopWaitingForPlayerInput || !_gameTimeTicking);
 
-		_displayMan->clearScreen(kColorBlack);
-		_displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY);
+		if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) {
+			_displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY);
+		}
 		// DUMMY CODE: next line
 		_menuMan->drawMovementArrows();
 		_displayMan->updateScreen();
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 7035933..5c448c0 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -9,7 +9,7 @@ namespace DM {
 
 Box gBoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
 
-InventoryMan::InventoryMan(DMEngine *vm): _vm(vm) {}
+InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {}
 
 void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	ChampionMan &cm = *_vm->_championMan;
@@ -30,7 +30,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	if (invChampOrdinal) {
 		_inventoryChampionOrdinal = indexToOrdinal(kChampionNone);
 		warning("MISSING CODE: F0334_INVENTORY_CloseChest");
-		champion = &cm._champions[ordinalToIndex(kChampionNone)];
+		champion = &cm._champions[ordinalToIndex(_inventoryChampionOrdinal)];
 		if (champion->_currHealth && !cm._candidateChampionOrdinal) {
 			champion->setAttributeFlag(kChampionAttributeStatusBox, true);
 			warning("MISSING CODE: F0292_CHAMPION_DrawState");
@@ -60,9 +60,6 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	dm.blitToScreen(dm.getBitmap(kInventoryGraphicIndice), w, 0, 0, 0, w, 0, h, kColorNoTransparency, gDungeonViewport);
 	if (cm._candidateChampionOrdinal) {
 		dm.clearScreenBox(kColorDarkestGray, gBoxFloppyZzzCross, gDungeonViewport);
-	} else {
-		static Box gBoxFloppy = Box(174, 182, 2, 12); // @ K0300_s_Box_ViewportFloppy
-		dm.clearScreenBox(kColorDarkestGray, gBoxFloppy, gDungeonViewport);
 	}
 	warning("MISSING CODE: F0052_TEXT_PrintToViewport -> HEALTH");
 	warning("MISSING CODE: F0052_TEXT_PrintToViewport -> STAMINA");


Commit: 3fe7213947a52b75ad7a0777af840909a372ef8f
    https://github.com/scummvm/scummvm/commit/3fe7213947a52b75ad7a0777af840909a372ef8f
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add PARTY and SCENT types

Changed paths:
    engines/dm/champion.h



diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index a3c6f80..8f20261 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -6,6 +6,46 @@
 
 namespace DM {
 
+class Scent {
+	uint16 _scent;
+public:
+	Scent(uint16 scent = 0): _scent(scent) {}
+
+	uint16 getMapX() { return _scent & 0x1F; }
+	uint16 getMapY() { return (_scent >> 5) & 0x1F; }
+	uint16 getMapIndex() { return (_scent >> 10) & 0x3F; }
+
+	uint16 setMapX(uint16 val) { _scent = (_scent & ~0x1F) & (val & 0x1F); }
+	uint16 setMapY(uint16 val) { _scent = (_scent & ~(0x1F << 5)) & (val & 0x1F); }
+	uint16 setMapIndex(uint16 val) { _scent = (_scent & ~(0x1F << 10)) & (val & 0x3F); }
+}; // @ SCENT
+
+class Party {
+public:
+	Party() {
+		_magicalLightAmount = _event73Count_ThievesEye = _event79Count_Footprints = _shieldDefense = 0;
+		_fireShieldDefense = _spellShieldDefense = _scentCount = _freezeLifeTicks = _firstScentIndex = 0;
+		_lastScentIndex = _event71Count_Invisibility = 0;
+		for (int16 i = 0; i < 24; ++i)
+			_scentStrengths[i] = 0;
+	}
+	int16 _magicalLightAmount;
+	byte _event73Count_ThievesEye;
+	byte _event79Count_Footprints;
+	int16 _shieldDefense;
+
+	int16 _fireShieldDefense;
+	int16 _spellShieldDefense;
+	byte _scentCount;
+	byte _freezeLifeTicks;
+	byte _firstScentIndex;
+
+	byte _lastScentIndex;
+	Scent _scents[24]; // if I remember correctly, user defined default constructors are always called
+	byte _scentStrengths[24];
+	byte _event71Count_Invisibility;
+}; // @  PARTY
+
 enum IconIndice {
 	kIconIndiceNone = -1, // @ CM1_ICON_NONE
 	kIconIndiceJunkCompassNorth = 0, // @ C000_ICON_JUNK_COMPASS_NORTH


Commit: 35b5f03b26ec126af55a901af68f392e8fa883a1
    https://github.com/scummvm/scummvm/commit/35b5f03b26ec126af55a901af68f392e8fa883a1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add G0048_s_Graphic562_Box_Mouth, G0049_s_Graphic562_Box_Eye, G0054_ai_Graphic562_Box_ChampionIcons, G0046_auc_Graphic562_ChampionColor

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index ec098ee..052c7e8 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1,266 +1,275 @@
-#include "champion.h"
-#include "dungeonman.h"
-#include "eventman.h"
-#include "menus.h"
-#include "inventory.h"
-
-
-namespace DM {
-
-uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
-	/* 30 for champion inventory, 8 for chest */
-	0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Action Hand      Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0x0002,   /* Head             Head */
-	0x0008,   /* Torso            Torso */
-	0x0010,   /* Legs             Legs */
-	0x0020,   /* Feet             Feet */
-	0x0100,   /* Pouch 2          Pouch */
-	0x0080,   /* Quiver Line2 1   Quiver 2 */
-	0x0080,   /* Quiver Line1 2   Quiver 2 */
-	0x0080,   /* Quiver Line2 2   Quiver 2 */
-	0x0004,   /* Neck             Neck */
-	0x0100,   /* Pouch 1          Pouch */
-	0x0040,   /* Quiver Line1 1   Quiver 1 */
-	0xFFFF,   /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0x0400,   /* Chest 1          Chest */
-	0x0400,   /* Chest 2          Chest */
-	0x0400,   /* Chest 3          Chest */
-	0x0400,   /* Chest 4          Chest */
-	0x0400,   /* Chest 5          Chest */
-	0x0400,   /* Chest 6          Chest */
-	0x0400,   /* Chest 7          Chest */
-	0x0400}; /* Chest 8          Chest */
-
-Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
-
-ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
-	_leaderIndex = kChampionNone;
-}
-
-uint16 ChampionMan::getChampionPortraitX(uint16 index) {
-	return ((index) & 0x7) << 5;
-}
-
-uint16 ChampionMan::getChampionPortraitY(uint16 index) {
-	return ((index) >> 3) * 29;
-}
-
-int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) {
-	int val = 0;
-	for (uint16 i = 0; i < characterCount; ++i) {
-		val = (val << 4) + (string[i] - 'A');
-	}
-	return val;
-}
-
-ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
-	for (uint16 i = 0; i < _partyChampionCount; ++i) {
-		if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
-			return (ChampionIndex)i;
-	}
-
-	return kChampionNone;
-}
-
-void ChampionMan::resetDataToStartGame() {
-	if (!_vm->_dungeonMan->_messages._newGame) {
-		warning("MISSING CODE: stuff for resetting for loaded games");
-		assert(false);
-	}
-
-	_leaderHand = Thing::_thingNone;
-	_leaderHandObjectIconIndex = kIconIndiceNone;
-	_leaderEmptyHanded = true;
-}
-
-
-void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
-	DisplayMan &dispMan = *_vm->_displayMan;
-	DungeonMan &dunMan = *_vm->_dungeonMan;
-
-	if (!_leaderEmptyHanded || _partyChampionCount == 4)
-		return;
-
-	uint16 prevChampCount = _partyChampionCount;
-	Champion *champ = &_champions[prevChampCount];
-	champ->resetToZero();
-	dispMan._useByteBoxCoordinates = true;
-	{ // limit destBox scope
-		Box &destBox = gBoxChampionPortrait;
-		dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex),
-							 champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency);
-	}
-
-	champ->_actionIndex = kChampionActionNone;
-	champ->_enableActionEventIndex = -1;
-	champ->_hideDamageReceivedIndex = -1;
-	champ->_dir = dunMan._currMap._partyDir;
-	ViewCell AL_0_viewCell = kViewCellFronLeft;
-	while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone)
-		AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
-	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3);
-	champ->clearAttributes(kChampionAttributeIcon);
-	champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir;
-	champ->_food = 1500 + _vm->_rnd->getRandomNumber(256);
-	champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
-	int16 AL_0_slotIndex_Red;
-	for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) {
-		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone);
-	}
-	Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY);
-	while (thing.getType() != kTextstringType) {
-		thing = dunMan.getNextThing(thing);
-	}
-	char decodedChampionText[77];
-	char* character_Green = decodedChampionText;
-	dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible));
-	int16 AL_0_characterIndex = 0;
-	uint16 AL_2_character;
-	while ((AL_2_character = *character_Green++) != '\n') {
-		champ->_name[AL_0_characterIndex++] = AL_2_character;
-	}
-	champ->_name[AL_0_characterIndex] = '\0';
-	AL_0_characterIndex = 0;
-	bool AL_4_champTitleCopied = false;
-	for (;;) { // infinite
-		AL_2_character = *character_Green++;
-		if (AL_2_character == '\n') {
-			if (AL_4_champTitleCopied)
-				break;
-			AL_4_champTitleCopied = true;
-		} else {
-			champ->_title[AL_0_characterIndex++] = AL_2_character;
-		}
-	}
-	champ->_title[AL_0_characterIndex] = '\0';
-	if (*character_Green++ == 'M') {
-		champ->setAttributeFlag(kChampionAttributeMale, true);
-	}
-	character_Green++;
-	champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4);
-	character_Green += 4;
-	champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4);
-	character_Green += 4;
-	character_Green++;
-
-	int16 AL_0_statisticIndex;
-	for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) {
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30);
-		uint16 currMaxVal = getDecodedValue(character_Green, 2);
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal);
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal);
-		character_Green += 2;
-	}
-
-	champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10);
-	character_Green++;
-
-	int16 AL_0_skillIndex;
-	int16 AL_2_skillValue;
-	for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) {
-		if ((AL_2_skillValue = *character_Green++ - 'A') > 0) {
-			champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue);
-		}
-	}
-
-	for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) {
-		int32 baseSkillExp = 0;
-		int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2;
-		for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) {
-			baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience;
-		}
-		champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp);
-	}
-
-	_candidateChampionOrdinal = prevChampCount + 1;
-	if (++_partyChampionCount == 1) {
-		_vm->_eventMan->commandSetLeader(kChampionFirst);
-		_vm->_menuMan->_shouldRefreshActionArea = true;
-	} else {
-		_vm->_menuMan->clearActingChampion();
-		_vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1));
-	}
-
-	int16 mapX = _vm->_dungeonMan->_currMap._partyPosX;
-	int16 mapY = _vm->_dungeonMan->_currMap._partyPosY;
-
-	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir));
-	mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir];
-	mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir];
-	thing = dunMan.getSquareFirstThing(mapX, mapY);
-	AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
-	uint16 slotIndex_Green;
-	while (thing != Thing::_thingEndOfList) {
-		ThingType AL_2_thingType = thing.getType();
-		if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) {
-			int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots();
-			switch (AL_2_thingType) {
-			case kArmourThingType:
-				for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) {
-					if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
-						goto T0280048;
-				}
-				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
-					slotIndex_Green = kChampionSlotNeck;
-				} else {
-					goto T0280046;
-				}
-				break;
-			case kWeaponThingType:
-				if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) {
-					slotIndex_Green = kChampionSlotActionHand;
-				} else {
-					goto T0280046;
-				}
-				break;
-			case kScrollThingType:
-			case kPotionThingType:
-				if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) {
-					slotIndex_Green = kChampionSlotPouch_1;
-				} else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) {
-					slotIndex_Green = kChampionSlotPouch_2;
-				} else {
-					goto T0280046;
-				}
-				break;
-			case kContainerThingType:
-			case kJunkThingType:
-T0280046:
-				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
-					slotIndex_Green = kChampionSlotNeck;
-				} else {
-					slotIndex_Green = AL_0_slotIndex_Red++;
-				}
-				break;
-			}
-T0280048:
-			if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) {
-				goto T0280046;
-			}
-			warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot");
-		}
-		thing = dunMan.getNextThing(thing);
-	}
-
-	_vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount);
-	_vm->_menuMan->drawDisabledMenu();
-}
-
+#include "champion.h"
+#include "dungeonman.h"
+#include "eventman.h"
+#include "menus.h"
+#include "inventory.h"
+
+
+namespace DM {
+
+Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
+Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
+Box gBoxChampionIcons[4] = { // @ G0054_ai_Graphic562_Box_ChampionIcons
+	Box(281, 299,  0, 13),
+	Box(301, 319,  0, 13),
+	Box(301, 319, 15, 28),
+	Box(281, 299, 15, 28) };
+byte gChampionColor[4] = {7, 11, 8, 14}; // @ G0046_auc_Graphic562_ChampionColor
+
+uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
+	/* 30 for champion inventory, 8 for chest */
+	0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Action Hand      Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0x0002,   /* Head             Head */
+	0x0008,   /* Torso            Torso */
+	0x0010,   /* Legs             Legs */
+	0x0020,   /* Feet             Feet */
+	0x0100,   /* Pouch 2          Pouch */
+	0x0080,   /* Quiver Line2 1   Quiver 2 */
+	0x0080,   /* Quiver Line1 2   Quiver 2 */
+	0x0080,   /* Quiver Line2 2   Quiver 2 */
+	0x0004,   /* Neck             Neck */
+	0x0100,   /* Pouch 1          Pouch */
+	0x0040,   /* Quiver Line1 1   Quiver 1 */
+	0xFFFF,   /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0x0400,   /* Chest 1          Chest */
+	0x0400,   /* Chest 2          Chest */
+	0x0400,   /* Chest 3          Chest */
+	0x0400,   /* Chest 4          Chest */
+	0x0400,   /* Chest 5          Chest */
+	0x0400,   /* Chest 6          Chest */
+	0x0400,   /* Chest 7          Chest */
+	0x0400}; /* Chest 8          Chest */
+
+Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
+
+ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
+	_leaderIndex = kChampionNone;
+}
+
+uint16 ChampionMan::getChampionPortraitX(uint16 index) {
+	return ((index) & 0x7) << 5;
+}
+
+uint16 ChampionMan::getChampionPortraitY(uint16 index) {
+	return ((index) >> 3) * 29;
+}
+
+int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) {
+	int val = 0;
+	for (uint16 i = 0; i < characterCount; ++i) {
+		val = (val << 4) + (string[i] - 'A');
+	}
+	return val;
+}
+
+ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
+	for (uint16 i = 0; i < _partyChampionCount; ++i) {
+		if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
+			return (ChampionIndex)i;
+	}
+
+	return kChampionNone;
+}
+
+void ChampionMan::resetDataToStartGame() {
+	if (!_vm->_dungeonMan->_messages._newGame) {
+		warning("MISSING CODE: stuff for resetting for loaded games");
+		assert(false);
+	}
+
+	_leaderHand = Thing::_thingNone;
+	_leaderHandObjectIconIndex = kIconIndiceNone;
+	_leaderEmptyHanded = true;
+}
+
+
+void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
+	DisplayMan &dispMan = *_vm->_displayMan;
+	DungeonMan &dunMan = *_vm->_dungeonMan;
+
+	if (!_leaderEmptyHanded || _partyChampionCount == 4)
+		return;
+
+	uint16 prevChampCount = _partyChampionCount;
+	Champion *champ = &_champions[prevChampCount];
+	champ->resetToZero();
+	dispMan._useByteBoxCoordinates = true;
+	{ // limit destBox scope
+		Box &destBox = gBoxChampionPortrait;
+		dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex),
+							 champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency);
+	}
+
+	champ->_actionIndex = kChampionActionNone;
+	champ->_enableActionEventIndex = -1;
+	champ->_hideDamageReceivedIndex = -1;
+	champ->_dir = dunMan._currMap._partyDir;
+	ViewCell AL_0_viewCell = kViewCellFronLeft;
+	while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone)
+		AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
+	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3);
+	champ->clearAttributes(kChampionAttributeIcon);
+	champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir;
+	champ->_food = 1500 + _vm->_rnd->getRandomNumber(256);
+	champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
+	int16 AL_0_slotIndex_Red;
+	for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) {
+		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone);
+	}
+	Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY);
+	while (thing.getType() != kTextstringType) {
+		thing = dunMan.getNextThing(thing);
+	}
+	char decodedChampionText[77];
+	char* character_Green = decodedChampionText;
+	dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible));
+	int16 AL_0_characterIndex = 0;
+	uint16 AL_2_character;
+	while ((AL_2_character = *character_Green++) != '\n') {
+		champ->_name[AL_0_characterIndex++] = AL_2_character;
+	}
+	champ->_name[AL_0_characterIndex] = '\0';
+	AL_0_characterIndex = 0;
+	bool AL_4_champTitleCopied = false;
+	for (;;) { // infinite
+		AL_2_character = *character_Green++;
+		if (AL_2_character == '\n') {
+			if (AL_4_champTitleCopied)
+				break;
+			AL_4_champTitleCopied = true;
+		} else {
+			champ->_title[AL_0_characterIndex++] = AL_2_character;
+		}
+	}
+	champ->_title[AL_0_characterIndex] = '\0';
+	if (*character_Green++ == 'M') {
+		champ->setAttributeFlag(kChampionAttributeMale, true);
+	}
+	character_Green++;
+	champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4);
+	character_Green += 4;
+	champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4);
+	character_Green += 4;
+	character_Green++;
+
+	int16 AL_0_statisticIndex;
+	for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) {
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30);
+		uint16 currMaxVal = getDecodedValue(character_Green, 2);
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal);
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal);
+		character_Green += 2;
+	}
+
+	champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10);
+	character_Green++;
+
+	int16 AL_0_skillIndex;
+	int16 AL_2_skillValue;
+	for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) {
+		if ((AL_2_skillValue = *character_Green++ - 'A') > 0) {
+			champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue);
+		}
+	}
+
+	for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) {
+		int32 baseSkillExp = 0;
+		int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2;
+		for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) {
+			baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience;
+		}
+		champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp);
+	}
+
+	_candidateChampionOrdinal = prevChampCount + 1;
+	if (++_partyChampionCount == 1) {
+		_vm->_eventMan->commandSetLeader(kChampionFirst);
+		_vm->_menuMan->_shouldRefreshActionArea = true;
+	} else {
+		_vm->_menuMan->clearActingChampion();
+		_vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1));
+	}
+
+	int16 mapX = _vm->_dungeonMan->_currMap._partyPosX;
+	int16 mapY = _vm->_dungeonMan->_currMap._partyPosY;
+
+	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir));
+	mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir];
+	mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir];
+	thing = dunMan.getSquareFirstThing(mapX, mapY);
+	AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
+	uint16 slotIndex_Green;
+	while (thing != Thing::_thingEndOfList) {
+		ThingType AL_2_thingType = thing.getType();
+		if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) {
+			int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots();
+			switch (AL_2_thingType) {
+			case kArmourThingType:
+				for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) {
+					if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
+						goto T0280048;
+				}
+				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
+					slotIndex_Green = kChampionSlotNeck;
+				} else {
+					goto T0280046;
+				}
+				break;
+			case kWeaponThingType:
+				if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) {
+					slotIndex_Green = kChampionSlotActionHand;
+				} else {
+					goto T0280046;
+				}
+				break;
+			case kScrollThingType:
+			case kPotionThingType:
+				if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) {
+					slotIndex_Green = kChampionSlotPouch_1;
+				} else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) {
+					slotIndex_Green = kChampionSlotPouch_2;
+				} else {
+					goto T0280046;
+				}
+				break;
+			case kContainerThingType:
+			case kJunkThingType:
+T0280046:
+				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
+					slotIndex_Green = kChampionSlotNeck;
+				} else {
+					slotIndex_Green = AL_0_slotIndex_Red++;
+				}
+				break;
+			}
+T0280048:
+			if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) {
+				goto T0280046;
+			}
+			warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot");
+		}
+		thing = dunMan.getNextThing(thing);
+	}
+
+	_vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount);
+	_vm->_menuMan->drawDisabledMenu();
+}
+
 }
\ No newline at end of file


Commit: aa269b9f5e30cd2592884362b4e25a2a1a4c4ce6
    https://github.com/scummvm/scummvm/commit/aa269b9f5e30cd2592884362b4e25a2a1a4c4ce6
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add blitToScreen using Box

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 223257c..28fb63c 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -117,7 +117,7 @@ enum ViewSquare {
 Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling
 Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor
 
-Frame gFrameWall_D3L2 = Frame(0,  15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2
+Frame gFrameWall_D3L2 = Frame(0, 15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2
 Frame gFrameWall_D3R2 = Frame(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2
 Frame gFrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls
 	/* { X1, X2, Y1, Y2, pixelWidth, Height, X, Y } */
@@ -564,7 +564,7 @@ byte gAlcoveOrnIndices[kAlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrna
 
 using namespace DM;
 
-DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {	
+DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_vgaBuffer = nullptr;
 	_bitmaps = nullptr;
 	_grapItemCount = 0;
@@ -585,9 +585,9 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 
 	for (int i = 0; i < kStairsGraphicCount; i++)
 		_stairIndices[i] = 0;
-	
+
 	for (int i = 0; i < 4; i++)
-		_palChangesProjectile[i] =  nullptr;
+		_palChangesProjectile[i] = nullptr;
 
 	for (int i = 0; i < kAlcoveOrnCount; i++)
 		_currMapAlcoveOrnIndices[i] = 0;
@@ -604,7 +604,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 			_currMapDoorOrnInfo[j][i] = 0;
 		}
 	}
-	
+
 	for (int i = 0; i < 16; i++) {
 		_currMapWallOrnIndices[i] = 0;
 		_currMapFloorOrnIndices[i] = 0;
@@ -1435,7 +1435,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 			bitmapGreen = _bitmaps[nativeBitmapIndex];
 			var_X = pixelWidth;
 			if (flipHorizontal) {
-				if(bitmapGreen != _tmpBitmap)
+				if (bitmapGreen != _tmpBitmap)
 					blitToBitmap(bitmapGreen, coordSetB[4], coordSetB[5], _tmpBitmap, coordSetB[4]);
 				flipBitmapHorizontal(_tmpBitmap, coordSetB[4], coordSetB[5]);
 				bitmapGreen = _tmpBitmap;
@@ -1506,3 +1506,9 @@ void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) {
 	for (int y = box._y1; y < box._y2; ++y)
 		memset(_vgaBuffer + y * _screenWidth + box._x1, color, sizeof(byte) * width);
 }
+
+void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
+				  Box &box,
+				  Color transparent, Viewport &viewport) {
+	blitToScreen(srcBitmap, srcWidth, srcX, srcY, box._x1, box._x2, box._y1, box._y2, transparent, viewport);
+}
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 6532291..48df3d7 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -290,6 +290,9 @@ public:
 	void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 					  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
 					  Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort);
+	void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
+					  Box &box,
+					  Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort);
 
 	void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height);
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);


Commit: d5e4448ec619dd724fbdcbda38a5d3db8f74122a
    https://github.com/scummvm/scummvm/commit/d5e4448ec619dd724fbdcbda38a5d3db8f74122a
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0354_INVENTORY_DrawStatusBoxPortrait

Changed paths:
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 5c448c0..c62bf15 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -2,6 +2,7 @@
 #include "dungeonman.h"
 #include "eventman.h"
 #include "menus.h"
+#include "gfx.h"
 
 
 
@@ -81,5 +82,16 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
 }
 
+#define kChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING
+void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) {
+	DisplayMan &dispMan = *_vm->_displayMan;
+	dispMan._useByteBoxCoordinates = false;
+	Box box;
+	box._y1 = 0;
+	box._y2 = 28 + 1;
+	box._x1 = championIndex * kChampionStatusBoxSpacing + 7;
+	box._x2 = box._x1 + 31 + 1;
+	dispMan.blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0, box, kColorNoTransparency);
+}
 
-}
\ No newline at end of file
+}
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 6579708..90565f5 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -12,6 +12,7 @@ public:
 	int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal
 	InventoryMan(DMEngine *vm);
 	void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE
+	void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait
 };
 
 }
\ No newline at end of file


Commit: ef2411f7afe060ce60b6b2d6d607dc3d8d339021
    https://github.com/scummvm/scummvm/commit/ef2411f7afe060ce60b6b2d6d607dc3d8d339021
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0287_CHAMPION_DrawBarGraph

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 052c7e8..b30d339 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -13,8 +13,8 @@ Box gBoxChampionIcons[4] = { // @ G0054_ai_Graphic562_Box_ChampionIcons
 	Box(281, 299,  0, 13),
 	Box(301, 319,  0, 13),
 	Box(301, 319, 15, 28),
-	Box(281, 299, 15, 28) };
-byte gChampionColor[4] = {7, 11, 8, 14}; // @ G0046_auc_Graphic562_ChampionColor
+	Box(281, 299, 15, 28)};
+Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; // @ G0046_auc_Graphic562_ChampionColor
 
 uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
 	/* 30 for champion inventory, 8 for chest */
@@ -272,4 +272,68 @@ T0280048:
 	_vm->_menuMan->drawDisabledMenu();
 }
 
+void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
+
+	Champion *AL_6_champion = &_champions[champIndex];
+	int16 AL_2_barGraphIndex = 0;
+	int16 barGraphHeightArray[3];
+
+	if (AL_6_champion->_currHealth > 0) {
+		uint32 AL_4_barGraphHeight = (((uint32)(AL_6_champion->_currHealth) << 10) * 25) / AL_6_champion->_maxHealth;
+		if (AL_4_barGraphHeight & 0x3FF) {
+			barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10) + 1;
+		} else {
+			barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10);
+		}
+	} else {
+		barGraphHeightArray[AL_2_barGraphIndex++] = 0;
+	}
+
+	if (AL_6_champion->_currStamina > 0) {
+		uint32 AL_4_barGraphHeight = (((uint32)(AL_6_champion->_currStamina) << 10) * 25) / AL_6_champion->_maxStamina;
+		if (AL_4_barGraphHeight & 0x3FF) {
+			barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10) + 1;
+		} else {
+			barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10);
+		}
+	} else {
+		barGraphHeightArray[AL_2_barGraphIndex++] = 0;
+	}
+
+	if (AL_6_champion->_currMana > 0) {
+		uint32 AL_4_barGraphHeight = (((uint32)(AL_6_champion->_currMana) << 10) * 25) / AL_6_champion->_maxMana;
+		if (AL_4_barGraphHeight & 0x3FF) {
+			barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10) + 1;
+		} else {
+			barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10);
+		}
+	} else {
+		barGraphHeightArray[AL_2_barGraphIndex++] = 0;
+	}
+	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+
+	Box box;
+	box._x1 = champIndex * kChampionStatusBoxSpacing + 46;
+	box._x2 = box._x1 + 3;
+	box._y1 = 2;
+	box._y2 = 26;
+
+	for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) {
+		int16 AL_2_barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex];
+		if (AL_2_barGraphHeight < 25) {
+			box._y1 = 2;
+			box._y1 = 27 - AL_2_barGraphHeight;
+			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
+		}
+		if (AL_2_barGraphHeight) {
+			box._y1 = 27 - AL_2_barGraphHeight;
+			box._y2 = 26;
+			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
+		}
+		box._x1 += 7;
+		box._x2 += 7;
+	}
+	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+}
+
 }
\ No newline at end of file
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 8f20261..b92462d 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -404,6 +404,7 @@ public:
 	ChampionMan(DMEngine *vm);
 	void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
 	void addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty
+	void drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs
 };
 
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index c62bf15..15dbd7e 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -82,7 +82,6 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
 }
 
-#define kChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING
 void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 	dispMan._useByteBoxCoordinates = false;
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 90565f5..eb4b458 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -6,6 +6,8 @@
 
 namespace DM {
 
+#define kChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING
+
 class InventoryMan {
 	DMEngine *_vm;
 public:


Commit: 493c8ed4bcdfc02b5327ad0e2e083cd4e8158736
    https://github.com/scummvm/scummvm/commit/493c8ed4bcdfc02b5327ad0e2e083cd4e8158736
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0306_CHAMPION_GetStaminaAdjustedValue

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index b30d339..f38552a 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -336,4 +336,15 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 
+
+int16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) {
+	int16 currStamina = champ->_currStamina;
+	int16 halfMaxStamina = champ->_maxStamina / 2;
+	if (currStamina < halfMaxStamina) {
+		val /= 2;
+		return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina;
+	}
+	return val;
+}
+
 }
\ No newline at end of file
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index b92462d..6271c94 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -405,6 +405,7 @@ public:
 	void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
 	void addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty
 	void drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs
+	int16 getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue
 };
 
 


Commit: 3134891f6cf62b1c20f2622030bfd2deb2ecefee
    https://github.com/scummvm/scummvm/commit/3134891f6cf62b1c20f2622030bfd2deb2ecefee
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0309_CHAMPION_GetMaximumLoad

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index f38552a..898975d 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -3,6 +3,7 @@
 #include "eventman.h"
 #include "menus.h"
 #include "inventory.h"
+#include "objectman.h"
 
 
 namespace DM {
@@ -337,14 +338,30 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
 }
 
 
-int16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) {
+uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) {
 	int16 currStamina = champ->_currStamina;
 	int16 halfMaxStamina = champ->_maxStamina / 2;
 	if (currStamina < halfMaxStamina) {
+		warning("Possible undefined behaviour in the original code");
 		val /= 2;
 		return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina;
 	}
 	return val;
 }
 
+uint16 ChampionMan::getMaximumLoad(Champion *champ) {
+	uint16 maximumLoad = champ->getStatistic(kChampionStatStrength, kChampionStatCurrent) * 8 + 100;
+	maximumLoad = getStaminaAdjustedValue(champ, maximumLoad);
+	int16 wounds = champ->getWounds();
+	if (wounds) {
+		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kChampionWoundLegs) ? 2 : 3);
+	}
+	if (_vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotFeet)) == kIconIndiceArmourElvenBoots) {
+		maximumLoad += maximumLoad * 16;
+	}
+	maximumLoad += 9;
+	maximumLoad -= maximumLoad % 10;
+	return maximumLoad;
+}
+
 }
\ No newline at end of file
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 6271c94..db55412 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -359,6 +359,7 @@ public:
 			_wounds &= ~flag;
 		}
 	}
+	uint16 getWoundsFlag(ChampionWound wound) { return _wounds & wound; }
 	void clearWounds() { _wounds = kChampionWoundNone; }
 	void resetToZero() { // oh boy > . <
 		for (int16 i = 0; i < 30; ++i)
@@ -405,7 +406,8 @@ public:
 	void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
 	void addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty
 	void drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs
-	int16 getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue
+	uint16 getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue
+	uint16 getMaximumLoad(Champion *champ); // @ F0309_CHAMPION_GetMaximumLoad
 };
 
 


Commit: b068beb33f38c2f3a4cb8c5ea0b26ad53b3e35b0
    https://github.com/scummvm/scummvm/commit/b068beb33f38c2f3a4cb8c5ea0b26ad53b3e35b0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add G0032_s_Graphic562_Box_Panel, G0035_s_Graphic562_Box_Food, G0036_s_Graphic562_Box_Water, G0037_s_Graphic562_Box_Poisoned

Changed paths:
    engines/dm/inventory.cpp



diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 15dbd7e..2e7f254 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -9,6 +9,10 @@
 namespace DM {
 
 Box gBoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
+Box gBoxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel
+Box gBoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food
+Box gBoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
+Box gBoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
 
 InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {}
 


Commit: 3385a3dd5cc21a3e8b05ad065dd46fc38e39ba33
    https://github.com/scummvm/scummvm/commit/3385a3dd5cc21a3e8b05ad065dd46fc38e39ba33
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0343_INVENTORY_DrawPanel_HorizontalBar

Changed paths:
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 2e7f254..ea643da 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -97,4 +97,14 @@ void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) {
 	dispMan.blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0, box, kColorNoTransparency);
 }
 
+void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
+	Box box;
+	box._x1 = x;
+	box._x2 = box._x1 + pixelWidth;
+	box._y1 = y;
+	box._y2 = box._y1 + 6;
+	_vm->_displayMan->_useByteBoxCoordinates = false;
+	_vm->_displayMan->clearScreenBox(color, box);
+}
+
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index eb4b458..192b689 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -15,6 +15,7 @@ public:
 	InventoryMan(DMEngine *vm);
 	void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE
 	void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait
+	void drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar
 };
 
 }
\ No newline at end of file


Commit: 8c007d02faf933ae633a5f10694e9d1667d424c3
    https://github.com/scummvm/scummvm/commit/8c007d02faf933ae633a5f10694e9d1667d424c3
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0344_INVENTORY_DrawPanel_FoodOrWaterBar

Changed paths:
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index ea643da..98713d0 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -107,4 +107,20 @@ void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Co
 	_vm->_displayMan->clearScreenBox(color, box);
 }
 
+void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
+	if (amount < -512) {
+		color = kColorRed;
+	} else if(amount < 0) {
+		color = kColorYellow;
+	}
+
+	int16 pixelWidth = amount + 1024;
+	if (pixelWidth == 3072) {
+		pixelWidth = 3071;
+	}
+	pixelWidth /= 32;
+	drawPanelHorizontalBar(115, y + 2, pixelWidth, kColorBlack);
+	drawPanelHorizontalBar(113, y, pixelWidth, color);
+}
+
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 192b689..bd6f18d 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -16,6 +16,7 @@ public:
 	void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE
 	void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait
 	void drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar
+	void drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color); // @ F0344_INVENTORY_DrawPanel_FoodOrWaterBar 
 };
 
 }
\ No newline at end of file


Commit: 6eea379cc5d7311fde62b9f63fa175b42762a565
    https://github.com/scummvm/scummvm/commit/6eea379cc5d7311fde62b9f63fa175b42762a565
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add  F0345_INVENTORY_DrawPanel_FoodWaterPoisoned

Changed paths:
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 48df3d7..023535f 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -13,7 +13,7 @@ enum ViewCell {
 	kViewCellBackRight = 2, // @ C02_VIEW_CELL_BACK_RIGHT
 	kViewCellBackLeft = 3, // @ C03_VIEW_CELL_BACK_LEFT
 	kViewCellAlcove = 4, // @ C04_VIEW_CELL_ALCOVE
-	kViewCellDoorButtonOrWallOrn = 5 // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT
+	kViewCellDoorButtonOrWallOrn = 5, // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT
 };
 
 enum GraphicIndice {
@@ -28,7 +28,11 @@ enum GraphicIndice {
 	kObjectIcons_128_TO_159 = 46, // @ C046_GRAPHIC_OBJECT_ICONS_128_TO_159
 	kObjectIcons_160_TO_191 = 47, // @ C047_GRAPHIC_OBJECT_ICONS_160_TO_191
 	kObjectIcons_192_TO_223 = 48, // @ C048_GRAPHIC_OBJECT_ICONS_192_TO_223
-	kInventoryGraphicIndice = 17 // @ C017_GRAPHIC_INVENTORY
+	kInventoryGraphicIndice = 17, // @ C017_GRAPHIC_INVENTORY
+	kPanelEmptyIndice = 20, // @ C020_GRAPHIC_PANEL_EMPTY
+	kFoodLabelIndice = 30, // @ C030_GRAPHIC_FOOD_LABEL
+	kWaterLabelIndice = 31, // @ C031_GRAPHIC_WATER_LABEL
+	kPoisionedLabelIndice = 32 // @ C032_GRAPHIC_POISONED_LABEL
 };
 
 extern uint16 gPalSwoosh[16];
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 98713d0..68ebd61 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -110,7 +110,7 @@ void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Co
 void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
 	if (amount < -512) {
 		color = kColorRed;
-	} else if(amount < 0) {
+	} else if (amount < 0) {
 		color = kColorYellow;
 	}
 
@@ -123,4 +123,18 @@ void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
 	drawPanelHorizontalBar(113, y, pixelWidth, color);
 }
 
+void InventoryMan::drawPanelFoodWaterPoisoned() {
+	Champion &champ = _vm->_championMan->_champions[_inventoryChampionOrdinal];
+	warning("MISSING CODE: F0334_INVENTORY_CloseChest");
+	DisplayMan &dispMan = *_vm->_displayMan;
+	dispMan.blitToScreen(dispMan.getBitmap(kPanelEmptyIndice), 144, 0, 0, gBoxPanel, kColorRed);
+	dispMan.blitToScreen(dispMan.getBitmap(kFoodLabelIndice), 48, 0, 0, gBoxFood, kColorDarkestGray);
+	dispMan.blitToScreen(dispMan.getBitmap(kWaterLabelIndice), 48, 0, 0, gBoxWater, kColorDarkestGray);
+	if (champ._poisonEventCount) {
+		dispMan.blitToScreen(dispMan.getBitmap(kPoisionedLabelIndice), 96, 0, 0, gBoxPoisoned, kColorDarkestGray);
+	}
+	drawPanelFoodOrWaterBar(champ._food, 69, kColorLightBrown);
+	drawPanelFoodOrWaterBar(champ._water, 92, kColorBlue);
+}
+
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index bd6f18d..5fb3f75 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -17,6 +17,7 @@ public:
 	void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait
 	void drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar
 	void drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color); // @ F0344_INVENTORY_DrawPanel_FoodOrWaterBar 
+	void drawPanelFoodWaterPoisoned(); // @ F0345_INVENTORY_DrawPanel_FoodWaterPoisoned
 };
 
 }
\ No newline at end of file


Commit: b8c35406acefb716117fca0cf1f2564cc1786d5a
    https://github.com/scummvm/scummvm/commit/b8c35406acefb716117fca0cf1f2564cc1786d5a
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some renaming

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 898975d..3dfc2e3 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -275,41 +275,41 @@ T0280048:
 
 void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
 
-	Champion *AL_6_champion = &_champions[champIndex];
-	int16 AL_2_barGraphIndex = 0;
+	Champion *curChampion = &_champions[champIndex];
+	int16 barGraphIndex = 0;
 	int16 barGraphHeightArray[3];
 
-	if (AL_6_champion->_currHealth > 0) {
-		uint32 AL_4_barGraphHeight = (((uint32)(AL_6_champion->_currHealth) << 10) * 25) / AL_6_champion->_maxHealth;
-		if (AL_4_barGraphHeight & 0x3FF) {
-			barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10) + 1;
+	if (curChampion->_currHealth > 0) {
+		uint32 barGraphHeight = (((uint32)(curChampion->_currHealth) << 10) * 25) / curChampion->_maxHealth;
+		if (barGraphHeight & 0x3FF) {
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
 		} else {
-			barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10);
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
 		}
 	} else {
-		barGraphHeightArray[AL_2_barGraphIndex++] = 0;
+		barGraphHeightArray[barGraphIndex++] = 0;
 	}
 
-	if (AL_6_champion->_currStamina > 0) {
-		uint32 AL_4_barGraphHeight = (((uint32)(AL_6_champion->_currStamina) << 10) * 25) / AL_6_champion->_maxStamina;
-		if (AL_4_barGraphHeight & 0x3FF) {
-			barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10) + 1;
+	if (curChampion->_currStamina > 0) {
+		uint32 barGraphHeight = (((uint32)(curChampion->_currStamina) << 10) * 25) / curChampion->_maxStamina;
+		if (barGraphHeight & 0x3FF) {
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
 		} else {
-			barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10);
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
 		}
 	} else {
-		barGraphHeightArray[AL_2_barGraphIndex++] = 0;
+		barGraphHeightArray[barGraphIndex++] = 0;
 	}
 
-	if (AL_6_champion->_currMana > 0) {
-		uint32 AL_4_barGraphHeight = (((uint32)(AL_6_champion->_currMana) << 10) * 25) / AL_6_champion->_maxMana;
-		if (AL_4_barGraphHeight & 0x3FF) {
-			barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10) + 1;
+	if (curChampion->_currMana > 0) {
+		uint32 barGraphHeight = (((uint32)(curChampion->_currMana) << 10) * 25) / curChampion->_maxMana;
+		if (barGraphHeight & 0x3FF) {
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
 		} else {
-			barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10);
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
 		}
 	} else {
-		barGraphHeightArray[AL_2_barGraphIndex++] = 0;
+		barGraphHeightArray[barGraphIndex++] = 0;
 	}
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 
@@ -320,14 +320,14 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
 	box._y2 = 26;
 
 	for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) {
-		int16 AL_2_barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex];
-		if (AL_2_barGraphHeight < 25) {
+		int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex];
+		if (barGraphHeight < 25) {
 			box._y1 = 2;
-			box._y1 = 27 - AL_2_barGraphHeight;
+			box._y1 = 27 - barGraphHeight;
 			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
 		}
-		if (AL_2_barGraphHeight) {
-			box._y1 = 27 - AL_2_barGraphHeight;
+		if (barGraphHeight) {
+			box._y1 = 27 - barGraphHeight;
 			box._y2 = 26;
 			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
 		}
@@ -342,7 +342,7 @@ uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) {
 	int16 currStamina = champ->_currStamina;
 	int16 halfMaxStamina = champ->_maxStamina / 2;
 	if (currStamina < halfMaxStamina) {
-		warning("Possible undefined behaviour in the original code");
+		warning("Possible undefined behavior in the original code");
 		val /= 2;
 		return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina;
 	}


Commit: e59be236e11f13fd8c257a0fc72594f00a9dff63
    https://github.com/scummvm/scummvm/commit/e59be236e11f13fd8c257a0fc72594f00a9dff63
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Move junkInfo to getObjectWeight, make it static and const.

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index d9554f2..bbf0c7d 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -189,61 +189,6 @@ ObjectInfo gObjectInfo[180] = { // @ G0237_as_Graphic559_ObjectInfo
 	ObjectInfo(197, 74,  0, 0x0000),   /* SOLID KEY */
 	ObjectInfo(198, 41,  0, 0x0400)}; /* SQUARE KEY     Chest */
 
-uint16 gJunkInfo[53] = { // @ G0241_auc_Graphic559_JunkInfo
-	1,   /* COMPASS */
-	3,   /* WATERSKIN */
-	2,   /* JEWEL SYMAL */
-	2,   /* ILLUMULET */
-	4,   /* ASHES */
-	15,  /* BONES */
-	1,   /* COPPER COIN */
-	1,   /* SILVER COIN */
-	1,   /* GOLD COIN */
-	2,   /* IRON KEY */
-	1,   /* KEY OF B */
-	1,   /* SOLID KEY */
-	1,   /* SQUARE KEY */
-	1,   /* TOURQUOISE KEY */
-	1,   /* CROSS KEY */
-	1,   /* ONYX KEY */
-	1,   /* SKELETON KEY */
-	1,   /* GOLD KEY */
-	1,   /* WINGED KEY */
-	1,   /* TOPAZ KEY */
-	1,   /* SAPPHIRE KEY */
-	1,   /* EMERALD KEY */
-	1,   /* RUBY KEY */
-	1,   /* RA KEY */
-	1,   /* MASTER KEY */
-	81,  /* BOULDER */
-	2,   /* BLUE GEM */
-	3,   /* ORANGE GEM */
-	2,   /* GREEN GEM */
-	4,   /* APPLE */
-	4,   /* CORN */
-	3,   /* BREAD */
-	8,   /* CHEESE */
-	5,   /* SCREAMER SLICE */
-	11,  /* WORM ROUND */
-	4,   /* DRUMSTICK */
-	6,   /* DRAGON STEAK */
-	2,   /* GEM OF AGES */
-	3,   /* EKKHARD CROSS */
-	2,   /* MOONSTONE */
-	2,   /* THE HELLION */
-	2,   /* PENDANT FERAL */
-	6,   /* MAGICAL BOX */
-	9,   /* MAGICAL BOX */
-	3,   /* MIRROR OF DAWN */
-	10,  /* ROPE */
-	1,   /* RABBIT'S FOOT */
-	0,   /* CORBAMITE */
-	1,   /* CHOKER */
-	1,   /* LOCK PICKS */
-	2,   /* MAGNIFIER */
-	0,   /* ZOKATHRA SPELL */
-	8}; /* BONES */
-
 ArmourInfo gArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo
 /* { Weight, Defense, Attributes, Unreferenced } */
 	ArmourInfo(3,   5, 0x01),   /* CAPE */
@@ -1176,6 +1121,31 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 
 
 uint16 DungeonMan::getObjectWeight(Thing thing) {
+	static const uint16 junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo
+		// COMPASS - WATERSKIN - JEWEL SYMAL - ILLUMULET - ASHES
+		1, 3, 2, 2, 4, 
+		// BONES - COPPER COIN - SILVER COIN - GOLD COIN - IRON KEY
+		15, 1, 1, 1, 2,
+		// KEY OF B - SOLID KEY - SQUARE KEY - TOURQUOISE KEY - CROSS KEY
+		1, 1, 1, 1, 1,
+		// ONYX KEY - SKELETON KEY - GOLD KEY - WINGED KEY - TOPAZ KEY
+		1, 1, 1, 1, 1,
+		// SAPPHIRE KEY - EMERALD KEY - RUBY KEY - RA KEY - MASTER KEY
+		1, 1, 1, 1, 1,
+		// BOULDER - BLUE GEM - ORANGE GEM - GREEN GEM - APPLE
+		81, 2, 3, 2, 4,
+		// CORN - BREAD - CHEESE - SCREAMER SLICE - WORM ROUND
+		4, 3, 8, 5, 11,
+		// DRUMSTICK - DRAGON STEAK - GEM OF AGES - EKKHARD CROSS - MOONSTONE
+		4, 6, 2, 3, 2,
+		// THE HELLION - PENDANT FERAL - MAGICAL BOX - MAGICAL BOX - MIRROR OF DAWN
+		2, 2, 6, 9, 3,
+		// ROPE - RABBIT'S FOOT - CORBAMITE - CHOKER - LOCK PICKS
+		10, 1, 0, 1, 1,
+		// MAGNIFIER - ZOKATHRA SPELL - BONES
+		2, 0, 8
+	};
+
 	if (thing == Thing::_thingNone)
 		return 0;
 	switch (thing.getType()) {
@@ -1185,7 +1155,7 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 		return gArmourInfo[Armour(getThingData(thing)).getType()]._weight;
 	case kJunkThingType: {
 		Junk junk = getThingData(thing);
-		uint16 weight = gJunkInfo[junk.getType()];
+		uint16 weight = junkInfo[junk.getType()];
 		if (junk.getType() == kJunkTypeWaterskin)
 			weight += junk.getChargeCount() * 2;
 		return weight;
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 3dc3ab4..9ab7951 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -44,8 +44,6 @@ public:
 }; // @ OBJECT_INFO
 
 extern ObjectInfo gObjectInfo[180];
-
-extern uint16 gJunkInfo[53];
 				
 enum ArmourAttribute {
 	kArmourAttributeIsAShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD
@@ -572,7 +570,6 @@ class DungeonMan {
 	void setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
 									int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals
 
-
 	void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
 
 public:


Commit: 038056ed0f29af6146be45462a2f581a2293e946
    https://github.com/scummvm/scummvm/commit/038056ed0f29af6146be45462a2f581a2293e946
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add G0423_i_InventoryChampionOrdinal and related enum, PanelContent

Changed paths:
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 023535f..07dabce 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -32,7 +32,8 @@ enum GraphicIndice {
 	kPanelEmptyIndice = 20, // @ C020_GRAPHIC_PANEL_EMPTY
 	kFoodLabelIndice = 30, // @ C030_GRAPHIC_FOOD_LABEL
 	kWaterLabelIndice = 31, // @ C031_GRAPHIC_WATER_LABEL
-	kPoisionedLabelIndice = 32 // @ C032_GRAPHIC_POISONED_LABEL
+	kPoisionedLabelIndice = 32, // @ C032_GRAPHIC_POISONED_LABEL
+	kPanelResurectReincaranteIndice // @ C040_GRAPHIC_PANEL_RESURRECT_REINCARNATE 
 };
 
 extern uint16 gPalSwoosh[16];
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 68ebd61..e488710 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -14,7 +14,9 @@ Box gBoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food
 Box gBoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
 Box gBoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
 
-InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {}
+InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
+	_panelContent = kPanelContentFoodWaterPoisoned;
+}
 
 void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	ChampionMan &cm = *_vm->_championMan;
@@ -137,4 +139,9 @@ void InventoryMan::drawPanelFoodWaterPoisoned() {
 	drawPanelFoodOrWaterBar(champ._water, 92, kColorBlue);
 }
 
+void InventoryMan::drawPanelResurrectReincarnate() {
+	_panelContent = kPanelContentResurrectReincarnate;
+	_vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(kPanelResurectReincaranteIndice), 144, 0, 0, gBoxPanel, kColorDarkGreen, gDungeonViewport);
+}
+
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 5fb3f75..b6b23c4 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -8,16 +8,29 @@ namespace DM {
 
 #define kChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING
 
+
+enum PanelContent {
+	kPanelContentFoodWaterPoisoned = 0, // @ C00_PANEL_FOOD_WATER_POISONED
+	kPanelContentScroll = 2, // @ C02_PANEL_SCROLL
+	kPanelContentChest = 4, // @ C04_PANEL_CHEST
+	kPanelContentResurrectReincarnate = 5 // @ C05_PANEL_RESURRECT_REINCARNATE
+};
+
+
+
 class InventoryMan {
 	DMEngine *_vm;
 public:
 	int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal
+	PanelContent _panelContent; // @ G0424_i_PanelContent 
 	InventoryMan(DMEngine *vm);
 	void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE
 	void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait
 	void drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar
 	void drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color); // @ F0344_INVENTORY_DrawPanel_FoodOrWaterBar 
 	void drawPanelFoodWaterPoisoned(); // @ F0345_INVENTORY_DrawPanel_FoodWaterPoisoned
+	void drawPanelResurrectReincarnate(); // @ F0346_INVENTORY_DrawPanel_ResurrectReincarnate
+
 };
 
 }
\ No newline at end of file


Commit: 2c669d4119c2e218010c7d1d2eca0b81be58a99b
    https://github.com/scummvm/scummvm/commit/2c669d4119c2e218010c7d1d2eca0b81be58a99b
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0347_INVENTORY_DrawPanel

Changed paths:
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index e488710..db34720 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -144,4 +144,33 @@ void InventoryMan::drawPanelResurrectReincarnate() {
 	_vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(kPanelResurectReincaranteIndice), 144, 0, 0, gBoxPanel, kColorDarkGreen, gDungeonViewport);
 }
 
+void InventoryMan::drawPanel() {
+	warning("MISSING CODE: F0334_INVENTORY_CloseChest, altho adding it may reintroduce BUG0_48");
+
+	ChampionMan &cm = *_vm->_championMan;
+	if (cm._candidateChampionOrdinal) {
+		drawPanelResurrectReincarnate();
+		return;
+	}
+
+	Thing thing = cm._champions[ordinalToIndex(_inventoryChampionOrdinal)].getSlot(kChampionSlotActionHand);
+
+	_panelContent = kPanelContentFoodWaterPoisoned;
+	switch (thing.getType()) {
+	case kContainerThingType:
+		_panelContent = kPanelContentChest;
+		break;
+	case kScrollThingType:
+		_panelContent = kPanelContentScroll;
+		break;
+	default:
+		thing = Thing::_thingNone;
+		break;
+	}
+	if (thing == Thing::_thingNone) {
+		drawPanelFoodWaterPoisoned();
+	} else {
+		warning("MISSING CODE: F0342_INVENTORY_DrawPanel_Object(L1075_T_Thing, C0_FALSE);");
+	}
+}
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index b6b23c4..32c3d45 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -30,6 +30,7 @@ public:
 	void drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color); // @ F0344_INVENTORY_DrawPanel_FoodOrWaterBar 
 	void drawPanelFoodWaterPoisoned(); // @ F0345_INVENTORY_DrawPanel_FoodWaterPoisoned
 	void drawPanelResurrectReincarnate(); // @ F0346_INVENTORY_DrawPanel_ResurrectReincarnate
+	void drawPanel(); // @ F0347_INVENTORY_DrawPanel
 
 };
 


Commit: c986a71beabb7ba8f54a79f3b20735ab6a83e7e0
    https://github.com/scummvm/scummvm/commit/c986a71beabb7ba8f54a79f3b20735ab6a83e7e0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0292_CHAMPION_DrawState, G0407_s_Party,  M26_CHAMPION_ICON_INDEX, several graphic indices, fix missing kPanelResurectReincaranteIndice value

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.h
    engines/dm/gfx.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 3dfc2e3..ca5c6ac 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -364,4 +364,168 @@ uint16 ChampionMan::getMaximumLoad(Champion *champ) {
 	return maximumLoad;
 }
 
-}
\ No newline at end of file
+void ChampionMan::drawChampionState(ChampionIndex champIndex) {
+	InventoryMan &invMan = *_vm->_inventoryMan;
+	DisplayMan &dispMan = *_vm->_displayMan;
+	MenuMan &menuMan = *_vm->_menuMan;
+	EventManager &eventMan = *_vm->_eventMan;
+
+	Box box;
+	int16 champStatusBoxX = champIndex * kChampionStatusBoxSpacing;
+	Champion *champ = &_champions[champIndex];
+	uint16 champAttributes = champ->getAttributes();
+	if (!((champAttributes) & (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon |
+												  kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport |
+												  kChampionAttributeActionHand))) {
+		return;
+	}
+	bool isInventoryChamp = (indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
+	dispMan._useByteBoxCoordinates = false;
+	if (champAttributes & kChampionAttributeStatusBox) {
+		box._y1 = 0;
+		box._y2 = 28;
+		box._x1 = champStatusBoxX;
+		box._x2 = box._x1 + 66;
+		if (champ->_currHealth) {
+			dispMan.clearScreenBox(kColorDarkestGray, box);
+			int16 nativeBitmapIndices[3];
+			for (int16 i = 0; i < 3; ++i)
+				nativeBitmapIndices[i] = 0;
+			int16 AL_0_borderCount = 0;
+			if (_party._fireShieldDefense > 0)
+				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyFireshieldIndice;
+			if (_party._spellShieldDefense > 0)
+				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartySpellshieldIndice;
+			if (_party._shieldDefense > 0)
+				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyShieldIndice;
+			while (AL_0_borderCount--) {
+				dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, kColorFlesh);
+			}
+			if (isInventoryChamp) {
+				invMan.drawStatusBoxPortrait(champIndex);
+				champAttributes |= kChampionAttributeStatistics;
+			} else {
+				champAttributes |= (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeWounds | kChampionAttributeActionHand);
+			}
+		} else {
+			dispMan.blitToScreen(dispMan.getBitmap(kStatusBoxDeadChampion), 80, 0, 0, box, kColorNoTransparency);
+			warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen");
+			menuMan.drawActionIcon(champIndex);
+			goto T0292042_green;
+		}
+	}
+
+	if (!champ->_currHealth)
+		goto T0292042_green;
+
+	if(champAttributes & kChampionAttributeNameTitle) {
+		int16 AL_0_colorIndex = (champIndex == _leaderIndex) ? kColorGold : kColorLightestGray; // unused because of missing functions
+		if(isInventoryChamp) {
+			char *champName = champ->_name;
+			warning("MISSING CODE: F0052_TEXT_PrintToViewport");
+			int16 champTitleX = 6 * strlen(champName) + 3;
+			char champTitleFirstChar = champ->_title[0];
+			if ((champTitleFirstChar != ',') && (champTitleFirstChar != ';') && (champTitleFirstChar != '-')) {
+				champTitleX += 6;
+			}
+			warning("MISSING CODE: F0052_TEXT_PrintToViewport");
+			champAttributes |= kChampionAttributeViewport;
+		} else {
+			box._y1 = 0;
+			box._y2 = 6;
+			box._x1 = champStatusBoxX;
+			box._x2 = box._x1 + 42;
+			dispMan.clearScreenBox(kColorDarkGary, box);
+			warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen");
+		}
+	}
+
+	if (champAttributes & kChampionAttributeStatistics) {
+		drawChampionBarGraphs(champIndex);
+		if (isInventoryChamp) {
+			warning("MISSING CODE: F0290_CHAMPION_DrawHealthStaminaManaValues");
+			int16 AL_2_nativeBitmapIndex;
+			if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) {
+				AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice;
+			} else {
+				AL_2_nativeBitmapIndex = kSlotBoxNormalIndice;
+			}
+			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, kColorDarkestGray, gDungeonViewport);
+			AL_2_nativeBitmapIndex = kSlotBoxNormalIndice;
+			for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) {
+				if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent) 
+					< champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum)) {
+					AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice;
+					break;
+				}
+			}
+			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, kColorDarkestGray, gDungeonViewport);
+			champAttributes |= kChampionAttributeViewport;
+		}
+	}
+
+	if (champAttributes & kChampionAttributeWounds) {
+		for (int16 AL_0_slotIndex = isInventoryChamp ? kChampionSlotFeet : kChampionSlotActionHand; AL_0_slotIndex >= kChampionSlotReadyHand; AL_0_slotIndex--) {
+			warning("MISSING CODE: F0291_CHAMPION_DrawSlot");
+		}
+		if (isInventoryChamp) {
+			champAttributes |= kChampionAttributeViewport;
+		}
+	}
+
+	if (champAttributes & kChampionAttributeLoad) {
+		warning("MISSING CODE: whole if branch, many F0052_TEXT_PrintToViewport-s");
+
+
+
+		champAttributes |= kChampionAttributeViewport;
+	}
+
+	{ // block so goto won't skip AL_0_championIconIndex initialization 
+		int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir);
+
+		if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != indexToOrdinal(AL_0_championIconIndex))) {
+			dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]);
+			dispMan.blitToScreen(dispMan.getBitmap(kChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0,
+								 gBoxChampionIcons[AL_0_championIconIndex], kColorDarkestGray);
+		}
+	}
+
+	if ((champAttributes & kChampionAttributePanel) && isInventoryChamp) {
+		if (_vm->_pressingMouth) {
+			invMan.drawPanelFoodWaterPoisoned();
+		} else if (_vm->_pressingEye) {
+			if (_leaderEmptyHanded) {
+				warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics");
+			}
+		} else {
+			invMan.drawPanel();
+		}
+		champAttributes |= kChampionAttributeViewport;
+	}
+
+	if (champAttributes & kChampionAttributeActionHand) {
+		warning("MISSING CODE: F0291_CHAMPION_DrawSlot");
+		menuMan.drawActionIcon(champIndex);
+		if (isInventoryChamp) {
+			champAttributes |= kChampionAttributeViewport;
+		}
+	}
+
+	if (champAttributes & kChampionAttributeViewport) {
+		warning("MISSGIN CODE: F0097_DUNGEONVIEW_DrawViewport");
+	}
+
+
+T0292042_green:
+	champ->setAttributeFlag((ChampionAttribute)(kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon |
+												kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport |
+												kChampionAttributeActionHand), false);
+	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+}
+
+	uint16 ChampionMan::championIconIndex(int16 val, direction dir)
+	{
+		return ((val + 4 - dir) & 0x3);
+	}
+}
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index db55412..f8ea79c 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -401,6 +401,7 @@ public:
 	uint16 _actingChampionOrdinal; // @ G0506_ui_ActingChampionOrdinal
 	IconIndice _leaderHandObjectIconIndex; // @ G0413_i_LeaderHandObjectIconIndex
 	bool _leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded
+	Party _party; // @ G0407_s_Party
 
 	ChampionMan(DMEngine *vm);
 	void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
@@ -408,6 +409,8 @@ public:
 	void drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs
 	uint16 getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue
 	uint16 getMaximumLoad(Champion *champ); // @ F0309_CHAMPION_GetMaximumLoad
+	void drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState
+	uint16 championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX
 };
 
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 0b69aff..2a718ce 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -35,6 +35,7 @@ void turnDirLeft(direction &dir);
 direction returnOppositeDir(direction dir);
 bool isOrientedWestEast(direction dir);
 
+
 enum ThingType {
 	kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value
 	kDoorThingType = 0,
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 07dabce..0c92214 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -33,7 +33,14 @@ enum GraphicIndice {
 	kFoodLabelIndice = 30, // @ C030_GRAPHIC_FOOD_LABEL
 	kWaterLabelIndice = 31, // @ C031_GRAPHIC_WATER_LABEL
 	kPoisionedLabelIndice = 32, // @ C032_GRAPHIC_POISONED_LABEL
-	kPanelResurectReincaranteIndice // @ C040_GRAPHIC_PANEL_RESURRECT_REINCARNATE 
+	kPanelResurectReincaranteIndice = 40, // @ C040_GRAPHIC_PANEL_RESURRECT_REINCARNATE 
+	kBorderPartyShieldIndice = 37, // @ C037_GRAPHIC_BORDER_PARTY_SHIELD
+	kBorderPartyFireshieldIndice = 38, // @ C038_GRAPHIC_BORDER_PARTY_FIRESHIELD
+	kBorderPartySpellshieldIndice = 39, // @ C039_GRAPHIC_BORDER_PARTY_SPELLSHIELD
+	kStatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION
+	kSlotBoxNormalIndice = 33, // @ C033_GRAPHIC_SLOT_BOX_NORMAL                   
+	kSlotBoxWoundedIndice = 34, // @ C034_GRAPHIC_SLOT_BOX_WOUNDED                  
+	kChampionIcons = 28 // @ C028_GRAPHIC_CHAMPION_ICONS
 };
 
 extern uint16 gPalSwoosh[16];
@@ -49,7 +56,7 @@ public:
 	uint16 _y1;
 	uint16 _y2;
 
-	Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): _x1(x1), _x2(x2 + 1), _y1(y1), _y2(y2 + 1) {}
+	Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2) : _x1(x1), _x2(x2 + 1), _y1(y1), _y2(y2 + 1) {}
 	Box() {}
 	bool isPointInside(Common::Point point) {
 		return (_x1 <= point.x) && (point.x < _x2) && (_y1 <= point.y) && (point.y < _y2);
@@ -66,8 +73,8 @@ struct Frame {
 
 	Frame() {}
 	Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
-		uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) :
-	_destFromX(destFromX), _destToX(destToX + 1), _destFromY(destFromY), _destToY(destToY + 1),
+		  uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) :
+		_destFromX(destFromX), _destToX(destToX + 1), _destFromY(destFromY), _destToY(destToY + 1),
 		_srcWidth(srcWidth * 2), _srcHeight(srcHeight), _srcX(srcX), _srcY(srcY) {}
 };
 


Commit: afd844b6de922f27e22a66e075c273dc7a586ac0
    https://github.com/scummvm/scummvm/commit/afd844b6de922f27e22a66e075c273dc7a586ac0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing F0292_CHAMPION_DrawState functions, fix error in toggleInventory

Changed paths:
    engines/dm/eventman.cpp
    engines/dm/inventory.cpp
    engines/dm/menus.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index a7a3303..b7caa60 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -435,11 +435,11 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 	// MISSING CODE: Lots of code
 }
 
-void EventManager::commandSetLeader(ChampionIndex index) {
+void EventManager::commandSetLeader(ChampionIndex champIndex) {
 	ChampionMan &cm = *_vm->_championMan;
 	ChampionIndex leaderIndex;
 
-	if ((cm._leaderIndex == index) || ((index != kChampionNone) && !cm._champions[index]._currHealth))
+	if ((cm._leaderIndex == champIndex) || ((champIndex != kChampionNone) && !cm._champions[champIndex]._currHealth))
 		return;
 
 	if (cm._leaderIndex != kChampionNone) {
@@ -448,20 +448,20 @@ void EventManager::commandSetLeader(ChampionIndex index) {
 		cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeNameTitle, true);
 		cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._leaderHand);
 		cm._leaderIndex = kChampionNone;
-		warning("MISSING CODE: F0292_CHAMPION_DrawState");
+		cm.drawChampionState(leaderIndex);
 	}
-	if (index == kChampionNone) {
+	if (champIndex == kChampionNone) {
 		cm._leaderIndex = kChampionNone;
 		return;
 	}
-	cm._leaderIndex = index;
+	cm._leaderIndex = champIndex;
 	Champion *champion = &cm._champions[cm._leaderIndex];
 	champion->_dir = _vm->_dungeonMan->_currMap._partyDir;
-	cm._champions[index]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHand);
-	if (indexToOrdinal(index) != cm._candidateChampionOrdinal) {
+	cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHand);
+	if (indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) {
 		champion->setAttributeFlag(kChampionAttributeIcon, true);
 		champion->setAttributeFlag(kChampionAttributeNameTitle, true);
-		warning("MISSING CODE: F0292_CHAMPION_DrawState");
+		cm.drawChampionState(champIndex);
 	}
 }
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index db34720..b0cc9f0 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -37,10 +37,10 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	if (invChampOrdinal) {
 		_inventoryChampionOrdinal = indexToOrdinal(kChampionNone);
 		warning("MISSING CODE: F0334_INVENTORY_CloseChest");
-		champion = &cm._champions[ordinalToIndex(_inventoryChampionOrdinal)];
+		champion = &cm._champions[ordinalToIndex(invChampOrdinal)];
 		if (champion->_currHealth && !cm._candidateChampionOrdinal) {
 			champion->setAttributeFlag(kChampionAttributeStatusBox, true);
-			warning("MISSING CODE: F0292_CHAMPION_DrawState");
+			cm.drawChampionState((ChampionIndex)ordinalToIndex(invChampOrdinal));
 		}
 		if (cm._partyIsSleeping) {
 			return;
@@ -81,7 +81,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	champion->setAttributeFlag(kChampionAttributeStatistics, true);
 	champion->setAttributeFlag(kChampionAttributeNameTitle, true);
 
-	warning("MISSING CODE: F0292_CHAMPION_DrawState");
+	cm.drawChampionState(championIndex);
 	em._mousePointerBitmapUpdated = true;
 	em._secondaryMouseInput = gSecondaryMouseInput_ChampionInventory;
 	warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput");
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index d39aa22..f641e02 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -25,7 +25,7 @@ void MenuMan::clearActingChampion() {
 	if (cm._actingChampionOrdinal) {
 		cm._actingChampionOrdinal--;
 		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true);
-		warning("MISSING CODE: F0292_CHAMPION_DrawState");
+		cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal);
 		cm._actingChampionOrdinal = indexToOrdinal(kChampionNone);
 		_shouldRefreshActionArea = true;
 	}
@@ -88,4 +88,4 @@ void MenuMan::drawDisabledMenu() {
 	}
 }
 
-}
\ No newline at end of file
+}


Commit: 4b83ebc0da2a2bb46c2435ddfe96c333b7cbd8ed
    https://github.com/scummvm/scummvm/commit/4b83ebc0da2a2bb46c2435ddfe96c333b7cbd8ed
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add fix gDungeonViewport, some comments

Changed paths:
    engines/dm/dm.cpp
    engines/dm/gfx.cpp
    engines/dm/menus.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index c1d7e14..3a1a951 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -171,6 +171,7 @@ void DMEngine::gameloop() {
 
 	warning("DUMMY CODE: setting InventoryMan::_inventoryChampionOrdinal to zero");
 	_inventoryMan->_inventoryChampionOrdinal = 0;
+	warning("DUMMY CODE: clearing screen to black");
 	while (true) {
 		_stopWaitingForPlayerInput = false;
 		//do {
@@ -179,6 +180,7 @@ void DMEngine::gameloop() {
 		//} while (!_stopWaitingForPlayerInput || !_gameTimeTicking);
 
 		if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) {
+			_displayMan->clearScreen(kColorBlack); // dummy code
 			_displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY);
 		}
 		// DUMMY CODE: next line
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 28fb63c..6ddff20 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -548,7 +548,7 @@ byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110,
 
 Viewport gDefultViewPort = {0, 0};
 // TODO: I guessed the numbers
-Viewport gDungeonViewport = {0, 64}; // @ G0296_puc_Bitmap_Viewport
+Viewport gDungeonViewport = {0, 33}; // @ G0296_puc_Bitmap_Viewport
 
 byte gPalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges
 
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 52b99ab..de0c43a 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -15,7 +15,7 @@ public:
 	void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
 	void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon
 
-	void drawMovementArrows();
+	void drawMovementArrows(); // @ F0395_MENUS_DrawMovementArrows
 	void drawDisabledMenu(); // @ F0456_START_DrawDisabledMenus
 };
 


Commit: 485d5f94de671aa28017edca2c4725fc09c796c4
    https://github.com/scummvm/scummvm/commit/485d5f94de671aa28017edca2c4725fc09c796c4
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix box coordinates in drawChampionState

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index ca5c6ac..d41429e 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -383,9 +383,9 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	dispMan._useByteBoxCoordinates = false;
 	if (champAttributes & kChampionAttributeStatusBox) {
 		box._y1 = 0;
-		box._y2 = 28;
+		box._y2 = 28 + 1;
 		box._x1 = champStatusBoxX;
-		box._x2 = box._x1 + 66;
+		box._x2 = box._x1 + 66 + 1;
 		if (champ->_currHealth) {
 			dispMan.clearScreenBox(kColorDarkestGray, box);
 			int16 nativeBitmapIndices[3];
@@ -432,9 +432,9 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			champAttributes |= kChampionAttributeViewport;
 		} else {
 			box._y1 = 0;
-			box._y2 = 6;
+			box._y2 = 6 + 1;
 			box._x1 = champStatusBoxX;
-			box._x2 = box._x1 + 42;
+			box._x2 = box._x1 + 42 + 1;
 			dispMan.clearScreenBox(kColorDarkGary, box);
 			warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen");
 		}


Commit: 1639c2e887ae8bee4d43bddb84440b8639ce4efb
    https://github.com/scummvm/scummvm/commit/1639c2e887ae8bee4d43bddb84440b8639ce4efb
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix several inclusive boundary errors with Box types

Changed paths:
    engines/dm/champion.cpp
    engines/dm/inventory.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index d41429e..693fb50 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -315,20 +315,20 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
 
 	Box box;
 	box._x1 = champIndex * kChampionStatusBoxSpacing + 46;
-	box._x2 = box._x1 + 3;
+	box._x2 = box._x1 + 3 + 1;
 	box._y1 = 2;
-	box._y2 = 26;
+	box._y2 = 26 + 1;
 
 	for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) {
 		int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex];
 		if (barGraphHeight < 25) {
 			box._y1 = 2;
-			box._y1 = 27 - barGraphHeight;
+			box._y1 = 27 - barGraphHeight + 1;
 			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
 		}
 		if (barGraphHeight) {
 			box._y1 = 27 - barGraphHeight;
-			box._y2 = 26;
+			box._y2 = 26 + 1;
 			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
 		}
 		box._x1 += 7;
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index b0cc9f0..a67d308 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -102,9 +102,9 @@ void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) {
 void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
 	Box box;
 	box._x1 = x;
-	box._x2 = box._x1 + pixelWidth;
+	box._x2 = box._x1 + pixelWidth + 1;
 	box._y1 = y;
-	box._y2 = box._y1 + 6;
+	box._y2 = box._y1 + 6 + 1;
 	_vm->_displayMan->_useByteBoxCoordinates = false;
 	_vm->_displayMan->clearScreenBox(color, box);
 }


Commit: 3a2677eecfd5123fc186f056518f5ec242873a59
    https://github.com/scummvm/scummvm/commit/3a2677eecfd5123fc186f056518f5ec242873a59
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing code setting champion mana in ChampionMan::addCandidateChampionToParty

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 693fb50..71e285e 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -168,6 +168,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	character_Green += 4;
 	champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4);
 	character_Green += 4;
+	champ->_currMana = champ->_maxMana = getDecodedValue(character_Green, 4);
+	character_Green += 4;
 	character_Green++;
 
 	int16 AL_0_statisticIndex;


Commit: 0f04a0902b9b5dc3b83dc506a2155f679feeac0c
    https://github.com/scummvm/scummvm/commit/0f04a0902b9b5dc3b83dc506a2155f679feeac0c
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some GCC warnings

Changed paths:
    engines/dm/dungeonman.h
    engines/dm/gfx.h



diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 9ab7951..7f6e966 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -47,7 +47,7 @@ extern ObjectInfo gObjectInfo[180];
 				
 enum ArmourAttribute {
 	kArmourAttributeIsAShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD
-	kArmourAttributeSharpDefense = 0x0007, // @ MASK0x0007_SHARP_DEFENSE
+	kArmourAttributeSharpDefense = 0x0007 // @ MASK0x0007_SHARP_DEFENSE
 };
 
 class ArmourInfo {
@@ -476,9 +476,9 @@ public:
 	Square &set(SquareMask mask) { _data |= mask; return *this; }
 	byte get(SquareMask mask) { return _data & mask; }
 	byte getDoorState() { return _data & 0x7; } // @ M36_DOOR_STATE
-	Square &setDoorState(byte state) { _data = ((_data & ~0x7) | state); } // @ M37_SET_DOOR_STATE
+	void setDoorState(byte state) { _data = ((_data & ~0x7) | state); } // @ M37_SET_DOOR_STATE
 	SquareType getType() { return (SquareType)(_data >> 5); } // @ M34_SQUARE_TYPE
-	Square &setType(SquareType type) { _data = (_data & 0x1F) | type << 5; return *this; }
+	void setType(SquareType type) { _data = (_data & 0x1F) | type << 5; }
 	byte toByte() { return _data; } // I don't like 'em casts
 };
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 0c92214..87d6bda 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -13,7 +13,7 @@ enum ViewCell {
 	kViewCellBackRight = 2, // @ C02_VIEW_CELL_BACK_RIGHT
 	kViewCellBackLeft = 3, // @ C03_VIEW_CELL_BACK_LEFT
 	kViewCellAlcove = 4, // @ C04_VIEW_CELL_ALCOVE
-	kViewCellDoorButtonOrWallOrn = 5, // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT
+	kViewCellDoorButtonOrWallOrn = 5 // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT
 };
 
 enum GraphicIndice {


Commit: b97535ef698f3fda7dac27ee39499d67aed1418c
    https://github.com/scummvm/scummvm/commit/b97535ef698f3fda7dac27ee39499d67aed1418c
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some more GCC warnings

Changed paths:
    engines/dm/champion.h
    engines/dm/inventory.h



diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index f8ea79c..2428308 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -15,9 +15,9 @@ public:
 	uint16 getMapY() { return (_scent >> 5) & 0x1F; }
 	uint16 getMapIndex() { return (_scent >> 10) & 0x3F; }
 
-	uint16 setMapX(uint16 val) { _scent = (_scent & ~0x1F) & (val & 0x1F); }
-	uint16 setMapY(uint16 val) { _scent = (_scent & ~(0x1F << 5)) & (val & 0x1F); }
-	uint16 setMapIndex(uint16 val) { _scent = (_scent & ~(0x1F << 10)) & (val & 0x3F); }
+	void setMapX(uint16 val) { _scent = (_scent & ~0x1F) & (val & 0x1F); }
+	void setMapY(uint16 val) { _scent = (_scent & ~(0x1F << 5)) & (val & 0x1F); }
+	void setMapIndex(uint16 val) { _scent = (_scent & ~(0x1F << 10)) & (val & 0x3F); }
 }; // @ SCENT
 
 class Party {
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 32c3d45..aa75dc0 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -34,4 +34,4 @@ public:
 
 };
 
-}
\ No newline at end of file
+}


Commit: f1ef774a285844edd3a01c7d21e41e957a175ba8
    https://github.com/scummvm/scummvm/commit/f1ef774a285844edd3a01c7d21e41e957a175ba8
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix another GCC warning and a bug

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 6ddff20..8027425 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -163,7 +163,7 @@ enum WallSetIndices {
 	kWall_D0L_Native = 21,
 	kWall_D1LCR_Native = 22,
 	kWall_D2LCR_Native = 23,
-	kWall_D3LCR_Native = 24,
+	kWall_D3LCR_Native = 24
 };
 
 
@@ -916,7 +916,7 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) {
 		}
 		break;
 	case kStairsSideElemType:
-		drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D2L, gFrameWalls[kFrameStairsSide_D2L]);
+		drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2L]);
 		break;
 	}
 }


Commit: f46a588164f7a49767ed75cd108d16cfc6cf7410
    https://github.com/scummvm/scummvm/commit/f46a588164f7a49767ed75cd108d16cfc6cf7410
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Silent two more GCC warnings

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 8027425..1af0a03 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1362,7 +1362,8 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 
 		uint16 *coordinateSetA = gWallOrnCoordSets[_currMapWallOrnInfo[wallOrnIndex][kNativeCoordinateSet]][viewWallIndex];
 		isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnIndex);
-		if (isInscription = (wallOrnIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex)) {
+		isInscription = (wallOrnIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex);
+		if (isInscription) {
 			_vm->_dungeonMan->decodeText((char*)inscriptionString, _inscriptionThing, kTextTypeInscription);
 		}
 
@@ -1416,7 +1417,8 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 			coordinateSetOffset = 0;
 			uint16 *coordSetB;
 			int16 wallOrnCoordSetIndex = _currMapWallOrnInfo[wallOrnIndex][kNativeCoordinateSet];
-			if (flipHorizontal = (viewWallIndex == kViewWall_D2R_LEFT) || (viewWallIndex == kViewWall_D3R_LEFT)) {
+			flipHorizontal = (viewWallIndex == kViewWall_D2R_LEFT) || (viewWallIndex == kViewWall_D3R_LEFT);
+			if (flipHorizontal) {
 				coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1R_LEFT];
 			} else if ((viewWallIndex == kViewWall_D2L_RIGHT) || (viewWallIndex == kViewWall_D3L_RIGHT)) {
 				coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1L_RIGHT];


Commit: 9538db0b6100b407d3ed1450256ffdc63efef4c2
    https://github.com/scummvm/scummvm/commit/9538db0b6100b407d3ed1450256ffdc63efef4c2
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
Add: TextMan, font loading and basic text display

Changed paths:
  A engines/dm/text.cpp
  A engines/dm/text.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 3a1a951..8d38c5b 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -20,6 +20,7 @@
 #include "loadsave.h"
 #include "objectman.h"
 #include "inventory.h"
+#include "text.h"
 
 namespace DM {
 
@@ -54,6 +55,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_loadsaveMan = nullptr;
 	_objectMan = nullptr;
 	_inventoryMan = nullptr;
+	_textMan = nullptr;
 	_stopWaitingForPlayerInput = false;
 	_gameTimeTicking = false;
 
@@ -74,6 +76,7 @@ DMEngine::~DMEngine() {
 	delete _loadsaveMan;
 	delete _objectMan;
 	delete _inventoryMan;
+	delete _textMan;
 
 	// clear debug channels
 	DebugMan.clearAllDebugChannels();
@@ -151,6 +154,7 @@ Common::Error DMEngine::run() {
 	_loadsaveMan = new LoadsaveMan(this);
 	_objectMan = new ObjectMan(this);
 	_inventoryMan = new InventoryMan(this);
+	_textMan = new TextMan(this);
 	_displayMan->setUpScreens(320, 200);
 
 	initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 2a718ce..f2d14c9 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -17,6 +17,7 @@ class ChampionMan;
 class LoadsaveMan;
 class ObjectMan;
 class InventoryMan;
+class TextMan;
 
 
 enum direction {
@@ -104,6 +105,8 @@ public:
 	LoadsaveMan *_loadsaveMan;
 	ObjectMan *_objectMan;
 	InventoryMan *_inventoryMan;
+	TextMan *_textMan;
+
 	bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput
 	bool _gameTimeTicking; // @ G0301_B_GameTimeTicking
 	bool _restartGameAllowed; // @ G0524_B_RestartGameAllowed
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 1af0a03..ab0f9f1 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -685,12 +685,13 @@ void DisplayMan::unpackGraphics() {
 		unpackedBitmapsSize += getWidth(i) * getHeight(i);
 	for (uint16 i = 22; i <= 532; ++i)
 		unpackedBitmapsSize += getWidth(i) * getHeight(i);
+	unpackedBitmapsSize += (5 + 1) * (6 + 1) * 128; // 5 x 6 characters, 128 of them, +1 for convenience padding
 	// graphics items go from 0-20 and 22-532 inclusive, _unpackedItemPos 21 and 22 are there for indexing convenience
 	if (_bitmaps) {
 		delete[] _bitmaps[0];
 		delete[] _bitmaps;
 	}
-	_bitmaps = new byte*[533];
+	_bitmaps = new byte*[575]; // largest graphic indice (i think)
 	_bitmaps[0] = new byte[unpackedBitmapsSize];
 	loadIntoBitmap(0, _bitmaps[0]);
 	for (uint16 i = 1; i <= 20; ++i) {
@@ -698,10 +699,29 @@ void DisplayMan::unpackGraphics() {
 		loadIntoBitmap(i, _bitmaps[i]);
 	}
 	_bitmaps[22] = _bitmaps[20] + getWidth(20) * getHeight(20);
-	for (uint16 i = 23; i < 533; ++i) {
+	for (uint16 i = 23; i <= 532; ++i) {
 		_bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1);
 		loadIntoBitmap(i, _bitmaps[i]);
 	}
+	_bitmaps[kFontGraphicIndice] = _bitmaps[532] + getWidth(532) * getHeight(532);
+	loadFNT1intoBitmap(kFontGraphicIndice, _bitmaps[kFontGraphicIndice]);
+}
+
+void DisplayMan::loadFNT1intoBitmap(uint16 index, byte* destBitmap)
+{
+	uint8 *data = _packedBitmaps + _packedItemPos[index];
+	for (uint16 i = 0; i < 6; i++) {
+		for (uint16 w = 0; w < 128; ++w) {
+			*destBitmap++ = kColorBlack;
+
+			uint16 nextByte = *data++;
+			for (int16 pixel = 4; pixel >= 0; --pixel) {
+				*destBitmap++ = (nextByte >> pixel) & 0x1;
+			}
+		}
+	}
+	memset(data, 0, 128);
+	data += 128;
 }
 
 void DisplayMan::loadPalette(uint16 *palette) {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 87d6bda..38d6630 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -40,7 +40,8 @@ enum GraphicIndice {
 	kStatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION
 	kSlotBoxNormalIndice = 33, // @ C033_GRAPHIC_SLOT_BOX_NORMAL                   
 	kSlotBoxWoundedIndice = 34, // @ C034_GRAPHIC_SLOT_BOX_WOUNDED                  
-	kChampionIcons = 28 // @ C028_GRAPHIC_CHAMPION_ICONS
+	kChampionIcons = 28, // @ C028_GRAPHIC_CHAMPION_ICONS
+	kFontGraphicIndice = 557 // @ C557_GRAPHIC_FONT 
 };
 
 extern uint16 gPalSwoosh[16];
@@ -221,6 +222,8 @@ extern Viewport gDungeonViewport;
 #define kDoorOrnThivesEyeMask 16 // @ C16_DOOR_ORNAMENT_THIEVES_EYE_MASK
 
 class DisplayMan {
+	friend class DM::TextMan;
+
 	DMEngine *_vm;
 	uint16 _screenWidth;
 	uint16 _screenHeight;
@@ -248,6 +251,7 @@ class DisplayMan {
 	// the original function has two position parameters, but they are always set to zero
 	void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap
 	void unpackGraphics();
+	void loadFNT1intoBitmap(uint16 index, byte *destBitmap);
 
 	void drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally
 	void drawFloorPitOrStairsBitmap(StairIndex relIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
new file mode 100644
index 0000000..116058d
--- /dev/null
+++ b/engines/dm/text.cpp
@@ -0,0 +1,37 @@
+#include "text.h"
+
+
+namespace DM {
+
+TextMan::TextMan(DMEngine* vm) : _vm(vm) {}
+
+#define kLetterWidth 5
+#define kLetterHeight 6
+
+void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, Color textColor, Color bgColor, char* text, uint16 destHeight, Viewport &viewport) {
+	uint16 textLength = strlen(text);
+	uint16 nextX = destX;
+	uint16 nextY = destY;
+	byte *srcBitmap = _vm->_displayMan->getBitmap(kFontGraphicIndice);
+
+
+	for (char *begin = text, *end = text + textLength; begin != end; ++begin) {
+		// Note: this does no wraps in the middle of words
+		if (nextX + kLetterWidth + 1 > destPixelWidth || (*begin == '\n')) {
+			nextX = destX;
+			nextY += kLetterHeight + 1;
+		}
+		if (nextY + kLetterHeight + 1 > destHeight)
+			break;
+		uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
+		_vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, srcX, 0, destBitmap, destPixelWidth,
+									   nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight + 1, kColorNoTransparency, viewport);
+		nextX += kLetterWidth + 1;
+	}
+}
+
+void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, char* text, Viewport &viewport) {
+	printTextToBitmap(_vm->_displayMan->_vgaBuffer, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight, viewport);
+}
+
+}
diff --git a/engines/dm/text.h b/engines/dm/text.h
new file mode 100644
index 0000000..7f57525
--- /dev/null
+++ b/engines/dm/text.h
@@ -0,0 +1,20 @@
+#ifndef DM_TEXT_H
+#define DM_TEXT_H
+
+#include "dm.h"
+#include "gfx.h"
+
+namespace DM {
+
+class TextMan {
+	DMEngine *_vm;
+public:
+	TextMan(DMEngine *vm);
+	void printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY,
+						   Color textColor, Color bgColor, char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print
+	void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, char *text, Viewport &viewport = gDefultViewPort); 
+};
+
+}
+
+#endif


Commit: 45419f971a0d12ebec0e3f5b7c02312edfb6d75f
    https://github.com/scummvm/scummvm/commit/45419f971a0d12ebec0e3f5b7c02312edfb6d75f
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add color setting to TextMan::printTextToBitmap

Changed paths:
    engines/dm/text.cpp



diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 116058d..d6d005f 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -14,6 +14,12 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16
 	uint16 nextY = destY;
 	byte *srcBitmap = _vm->_displayMan->getBitmap(kFontGraphicIndice);
 
+	byte *tmp = _vm->_displayMan->_tmpBitmap;
+	for (uint16 i = 0; i < (kLetterWidth + 1) * (kLetterHeight + 1) * 128; ++i) {
+		tmp[i] = srcBitmap[i] ? textColor : bgColor;
+	}
+	srcBitmap = tmp;
+
 
 	for (char *begin = text, *end = text + textLength; begin != end; ++begin) {
 		// Note: this does no wraps in the middle of words


Commit: 63d06a40118716a0869b9d031567e83c2398e890
    https://github.com/scummvm/scummvm/commit/63d06a40118716a0869b9d031567e83c2398e890
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix code formatting

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 71e285e..8a79271 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -526,8 +526,8 @@ T0292042_green:
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 
-	uint16 ChampionMan::championIconIndex(int16 val, direction dir)
-	{
-		return ((val + 4 - dir) & 0x3);
-	}
+uint16 ChampionMan::championIconIndex(int16 val, direction dir) {
+	return ((val + 4 - dir) & 0x3);
+}
+
 }


Commit: 75f9721e1df0e9675ac330087fac28999382d096
    https://github.com/scummvm/scummvm/commit/75f9721e1df0e9675ac330087fac28999382d096
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Silent some CppCheck warnings

Changed paths:
    engines/dm/champion.h
    engines/dm/dm.h
    engines/dm/dungeonman.h
    engines/dm/eventman.h
    engines/dm/gfx.h
    engines/dm/inventory.h
    engines/dm/loadsave.h
    engines/dm/menus.h
    engines/dm/objectman.h



diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 2428308..4e9e29d 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -9,7 +9,7 @@ namespace DM {
 class Scent {
 	uint16 _scent;
 public:
-	Scent(uint16 scent = 0): _scent(scent) {}
+	explicit Scent(uint16 scent = 0): _scent(scent) {}
 
 	uint16 getMapX() { return _scent & 0x1F; }
 	uint16 getMapY() { return (_scent >> 5) & 0x1F; }
@@ -403,7 +403,7 @@ public:
 	bool _leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded
 	Party _party; // @ G0407_s_Party
 
-	ChampionMan(DMEngine *vm);
+	explicit ChampionMan(DMEngine *vm);
 	void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
 	void addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty
 	void drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index f2d14c9..61583a3 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -62,7 +62,7 @@ public:
 	static const Thing _thingEndOfList;
 
 	Thing() : _data(0) {}
-	Thing(uint16 d) { set(d); }
+	explicit Thing(uint16 d) { set(d); }
 
 	void set(uint16 d) {
 		_data = d;
@@ -88,7 +88,7 @@ class DMEngine : public Engine {
 	void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
 	void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF
 public:
-	DMEngine(OSystem *syst);
+	explicit DMEngine(OSystem *syst);
 	~DMEngine();
 
 	virtual Common::Error run(); // @ main
@@ -120,7 +120,7 @@ public:
 
 class Console : public GUI::Debugger {
 public:
-	Console(DMEngine *vm) {}
+	explicit Console(DMEngine *vm) {}
 	virtual ~Console(void) {}
 };
 
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 7f6e966..c5c356e 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -157,7 +157,7 @@ class Door {
 	Thing _nextThing;
 	uint16 _attributes;
 public:
-	Door(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
+	explicit Door(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 	Thing getNextThing() { return _nextThing; }
 	bool isMeleeDestructible() { return (_attributes >> 8) & 1; }
 	bool isMagicDestructible() { return (_attributes >> 7) & 1; }
@@ -178,7 +178,7 @@ class Teleporter {
 	uint16 _attributes;
 	uint16 _destMapIndex;
 public:
-	Teleporter(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]), _destMapIndex(rawDat[2]) {}
+	explicit Teleporter(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]), _destMapIndex(rawDat[2]) {}
 	Thing getNextThing() { return _nextThing; }
 	bool makesSound() { return (_attributes >> 15) & 1; }
 	TeleporterScope getScope() { return (TeleporterScope)((_attributes >> 13) & 1); }
@@ -195,7 +195,7 @@ class TextString {
 	Thing _nextThing;
 	uint16 _textDataRef;
 public:
-	TextString(uint16 *rawDat) : _nextThing(rawDat[0]), _textDataRef(rawDat[1]) {}
+	explicit TextString(uint16 *rawDat) : _nextThing(rawDat[0]), _textDataRef(rawDat[1]) {}
 
 	Thing getNextThing() { return _nextThing; }
 	uint16 getWordOffset() { return _textDataRef >> 3; }
@@ -249,7 +249,7 @@ class Sensor {
 	uint16 _attributes;
 	uint16 _action;
 public:
-	Sensor(uint16 *rawDat) : _nextThing(rawDat[0]), _datAndType(rawDat[1]), _attributes(rawDat[2]), _action(rawDat[3]) {}
+	explicit Sensor(uint16 *rawDat) : _nextThing(rawDat[0]), _datAndType(rawDat[1]), _attributes(rawDat[2]), _action(rawDat[3]) {}
 
 	Thing getNextThing() { return _nextThing; }
 	SensorType getType() { return (SensorType)(_datAndType & 0x7F); } // @ M39_TYPE
@@ -280,7 +280,7 @@ class Group {
 	uint16 _health[4];
 	uint16 _attributes;
 public:
-	Group(uint16 *rawDat) : _nextThing(rawDat[0]), _possessionID(rawDat[1]), _type(rawDat[2]),
+	explicit Group(uint16 *rawDat) : _nextThing(rawDat[0]), _possessionID(rawDat[1]), _type(rawDat[2]),
 		_position(rawDat[3]), _attributes(rawDat[8]) {
 		_health[0] = rawDat[4];
 		_health[1] = rawDat[5];
@@ -307,7 +307,7 @@ class Weapon {
 	Thing _nextThing;
 	uint16 _desc;
 public:
-	Weapon(uint16 *rawDat) : _nextThing(rawDat[0]), _desc(rawDat[1]) {}
+	explicit Weapon(uint16 *rawDat) : _nextThing(rawDat[0]), _desc(rawDat[1]) {}
 
 	WeaponType getType() { return (WeaponType)(_desc & 0x7F); }
 	bool isLit() { return (_desc >> 15) & 1; }
@@ -326,7 +326,7 @@ class Armour {
 	Thing _nextThing;
 	uint16 _attributes;
 public:
-	Armour(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
+	explicit Armour(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 
 	ArmourType getType() { return (ArmourType)(_attributes & 0x7F); }
 	Thing getNextThing() { return _nextThing; }
@@ -336,7 +336,7 @@ class Scroll {
 	Thing _nextThing;
 	uint16 _attributes;
 public:
-	Scroll(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
+	explicit Scroll(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 	void set(Thing next, uint16 attribs) {
 		_nextThing = next;
 		_attributes = attribs;
@@ -364,7 +364,7 @@ class Potion {
 	Thing _nextThing;
 	uint16 _attributes;
 public:
-	Potion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
+	explicit Potion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 
 	PotionType getType() { return (PotionType)((_attributes >> 8) & 0x7F); }
 	Thing getNextThing() { return _nextThing; }
@@ -375,7 +375,7 @@ class Container {
 	Thing _nextContainedThing;
 	uint16 _type;
 public:
-	Container(uint16 *rawDat) : _nextThing(rawDat[0]), _nextContainedThing(rawDat[1]), _type(rawDat[2]) {}
+	explicit Container(uint16 *rawDat) : _nextThing(rawDat[0]), _nextContainedThing(rawDat[1]), _type(rawDat[2]) {}
 
 	uint16 getType() { return (_type >> 1) & 0x3; }
 	Thing getNextContainedThing() { return _nextContainedThing; }
@@ -399,7 +399,7 @@ class Junk {
 	Thing _nextThing;
 	uint16 _attributes;
 public:
-	Junk(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
+	explicit Junk(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 
 	JunkType getType() { return (JunkType)(_attributes & 0x7F); }
 	uint16 getChargeCount() { return (_attributes >> 14) & 0x3; }
@@ -414,7 +414,7 @@ class Projectile {
 	byte _damageEnergy;
 	uint16 _timerIndex;
 public:
-	Projectile(uint16 *rawDat) : _nextThing(rawDat[0]), _object(rawDat[1]), _kineticEnergy(rawDat[2]),
+	explicit Projectile(uint16 *rawDat) : _nextThing(rawDat[0]), _object(rawDat[1]), _kineticEnergy(rawDat[2]),
 		_damageEnergy(rawDat[3]), _timerIndex(rawDat[4]) {}
 
 	Thing getNextThing() { return _nextThing; }
@@ -424,7 +424,7 @@ class Explosion {
 	Thing _nextThing;
 	uint16 _attributes;
 public:
-	Explosion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
+	explicit Explosion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 
 	Thing getNextThing() { return _nextThing; }
 }; // @ EXPLOSION
@@ -470,8 +470,8 @@ enum SquareType {
 class Square {
 	byte _data;
 public:
-	Square(byte dat = 0) : _data(dat) {}
-	Square(SquareType type) { setType(type); }
+	explicit Square(byte dat = 0) : _data(dat) {}
+	explicit Square(SquareType type) { setType(type); }
 	Square &set(byte dat) { this->_data = dat; return *this; }
 	Square &set(SquareMask mask) { _data |= mask; return *this; }
 	byte get(SquareMask mask) { return _data & mask; }
@@ -573,7 +573,7 @@ class DungeonMan {
 	void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
 
 public:
-	DungeonMan(DMEngine *dmEngine);
+	explicit DungeonMan(DMEngine *dmEngine);
 	~DungeonMan();
 
 	Thing getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index f72a985..4b62677 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -197,13 +197,15 @@ class EventManager {
 	void commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty
 	void commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty
 public:
+	explicit EventManager(DMEngine *vm);
+
 	MouseInput* _primaryMouseInput;// @ G0441_ps_PrimaryMouseInput
 	MouseInput* _secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput
 	bool _mousePointerBitmapUpdated; // @ G0598_B_MousePointerBitmapUpdated
 	bool _refreshMousePointerInMainLoop; // @ G0326_B_RefreshMousePointerInMainLoop
 	bool _highlightBoxEnabled; // @ G0341_B_HighlightBoxEnabled
 	uint16 _useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap
-	EventManager(DMEngine *vm);
+
 	void initMouse();
 	void showMouse(bool visibility);
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 38d6630..e2f30f3 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -279,7 +279,7 @@ public:
 	// some methods use this for a stratchpad, don't make assumptions about content between function calls
 	byte *_tmpBitmap;
 
-	DisplayMan(DMEngine *dmEngine);
+	explicit DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
 
 	void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index aa75dc0..b8fbe51 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -21,9 +21,11 @@ enum PanelContent {
 class InventoryMan {
 	DMEngine *_vm;
 public:
+	explicit InventoryMan(DMEngine *vm);
+
 	int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal
 	PanelContent _panelContent; // @ G0424_i_PanelContent 
-	InventoryMan(DMEngine *vm);
+
 	void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE
 	void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait
 	void drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar
diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h
index 8571912..abedf54 100644
--- a/engines/dm/loadsave.h
+++ b/engines/dm/loadsave.h
@@ -13,13 +13,11 @@ enum LoadgameResponse {
 class LoadsaveMan {
 	DMEngine *_vm;
 public:
-	LoadsaveMan(DMEngine *vm);
+	explicit LoadsaveMan(DMEngine *vm);
 
 	LoadgameResponse loadgame(); // @ F0435_STARTEND_LoadGame_CPSF
-
 };
 
 }
 
 #endif
-
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index de0c43a..edaa970 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -9,9 +9,11 @@ namespace DM {
 class MenuMan {
 	DMEngine *_vm;
 public:
+	explicit MenuMan(DMEngine *vm);
+
 	bool _shouldRefreshActionArea; // @ G0508_B_RefreshActionArea
 	bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons
-	MenuMan(DMEngine *vm);
+
 	void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
 	void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon
 
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index 908520c..dd0150d 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -7,7 +7,8 @@ namespace DM {
 class ObjectMan {
 	DMEngine *_vm;
 public:
-	ObjectMan(DMEngine *vm);
+	explicit ObjectMan(DMEngine *vm);
+
 	IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType
 	IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
 	void extractIconFromBitmap(uint16 iconIndex, byte *srcBitmap); // F0036_OBJECT_ExtractIconFromBitmap


Commit: 204853952295bf6504921979db32d6c10909131a
    https://github.com/scummvm/scummvm/commit/204853952295bf6504921979db32d6c10909131a
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Initialize some variables

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/menus.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 8a79271..ff3e5f7 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1,533 +1,538 @@
-#include "champion.h"
-#include "dungeonman.h"
-#include "eventman.h"
-#include "menus.h"
-#include "inventory.h"
-#include "objectman.h"
-
-
-namespace DM {
-
-Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
-Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
-Box gBoxChampionIcons[4] = { // @ G0054_ai_Graphic562_Box_ChampionIcons
-	Box(281, 299,  0, 13),
-	Box(301, 319,  0, 13),
-	Box(301, 319, 15, 28),
-	Box(281, 299, 15, 28)};
-Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; // @ G0046_auc_Graphic562_ChampionColor
-
-uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
-	/* 30 for champion inventory, 8 for chest */
-	0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Action Hand      Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0x0002,   /* Head             Head */
-	0x0008,   /* Torso            Torso */
-	0x0010,   /* Legs             Legs */
-	0x0020,   /* Feet             Feet */
-	0x0100,   /* Pouch 2          Pouch */
-	0x0080,   /* Quiver Line2 1   Quiver 2 */
-	0x0080,   /* Quiver Line1 2   Quiver 2 */
-	0x0080,   /* Quiver Line2 2   Quiver 2 */
-	0x0004,   /* Neck             Neck */
-	0x0100,   /* Pouch 1          Pouch */
-	0x0040,   /* Quiver Line1 1   Quiver 1 */
-	0xFFFF,   /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0x0400,   /* Chest 1          Chest */
-	0x0400,   /* Chest 2          Chest */
-	0x0400,   /* Chest 3          Chest */
-	0x0400,   /* Chest 4          Chest */
-	0x0400,   /* Chest 5          Chest */
-	0x0400,   /* Chest 6          Chest */
-	0x0400,   /* Chest 7          Chest */
-	0x0400}; /* Chest 8          Chest */
-
-Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
-
-ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
-	_leaderIndex = kChampionNone;
-}
-
-uint16 ChampionMan::getChampionPortraitX(uint16 index) {
-	return ((index) & 0x7) << 5;
-}
-
-uint16 ChampionMan::getChampionPortraitY(uint16 index) {
-	return ((index) >> 3) * 29;
-}
-
-int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) {
-	int val = 0;
-	for (uint16 i = 0; i < characterCount; ++i) {
-		val = (val << 4) + (string[i] - 'A');
-	}
-	return val;
-}
-
-ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
-	for (uint16 i = 0; i < _partyChampionCount; ++i) {
-		if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
-			return (ChampionIndex)i;
-	}
-
-	return kChampionNone;
-}
-
-void ChampionMan::resetDataToStartGame() {
-	if (!_vm->_dungeonMan->_messages._newGame) {
-		warning("MISSING CODE: stuff for resetting for loaded games");
-		assert(false);
-	}
-
-	_leaderHand = Thing::_thingNone;
-	_leaderHandObjectIconIndex = kIconIndiceNone;
-	_leaderEmptyHanded = true;
-}
-
-
-void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
-	DisplayMan &dispMan = *_vm->_displayMan;
-	DungeonMan &dunMan = *_vm->_dungeonMan;
-
-	if (!_leaderEmptyHanded || _partyChampionCount == 4)
-		return;
-
-	uint16 prevChampCount = _partyChampionCount;
-	Champion *champ = &_champions[prevChampCount];
-	champ->resetToZero();
-	dispMan._useByteBoxCoordinates = true;
-	{ // limit destBox scope
-		Box &destBox = gBoxChampionPortrait;
-		dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex),
-							 champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency);
-	}
-
-	champ->_actionIndex = kChampionActionNone;
-	champ->_enableActionEventIndex = -1;
-	champ->_hideDamageReceivedIndex = -1;
-	champ->_dir = dunMan._currMap._partyDir;
-	ViewCell AL_0_viewCell = kViewCellFronLeft;
-	while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone)
-		AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
-	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3);
-	champ->clearAttributes(kChampionAttributeIcon);
-	champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir;
-	champ->_food = 1500 + _vm->_rnd->getRandomNumber(256);
-	champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
-	int16 AL_0_slotIndex_Red;
-	for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) {
-		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone);
-	}
-	Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY);
-	while (thing.getType() != kTextstringType) {
-		thing = dunMan.getNextThing(thing);
-	}
-	char decodedChampionText[77];
-	char* character_Green = decodedChampionText;
-	dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible));
-	int16 AL_0_characterIndex = 0;
-	uint16 AL_2_character;
-	while ((AL_2_character = *character_Green++) != '\n') {
-		champ->_name[AL_0_characterIndex++] = AL_2_character;
-	}
-	champ->_name[AL_0_characterIndex] = '\0';
-	AL_0_characterIndex = 0;
-	bool AL_4_champTitleCopied = false;
-	for (;;) { // infinite
-		AL_2_character = *character_Green++;
-		if (AL_2_character == '\n') {
-			if (AL_4_champTitleCopied)
-				break;
-			AL_4_champTitleCopied = true;
-		} else {
-			champ->_title[AL_0_characterIndex++] = AL_2_character;
-		}
-	}
-	champ->_title[AL_0_characterIndex] = '\0';
-	if (*character_Green++ == 'M') {
-		champ->setAttributeFlag(kChampionAttributeMale, true);
-	}
-	character_Green++;
-	champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4);
-	character_Green += 4;
-	champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4);
-	character_Green += 4;
-	champ->_currMana = champ->_maxMana = getDecodedValue(character_Green, 4);
-	character_Green += 4;
-	character_Green++;
-
-	int16 AL_0_statisticIndex;
-	for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) {
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30);
-		uint16 currMaxVal = getDecodedValue(character_Green, 2);
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal);
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal);
-		character_Green += 2;
-	}
-
-	champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10);
-	character_Green++;
-
-	int16 AL_0_skillIndex;
-	int16 AL_2_skillValue;
-	for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) {
-		if ((AL_2_skillValue = *character_Green++ - 'A') > 0) {
-			champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue);
-		}
-	}
-
-	for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) {
-		int32 baseSkillExp = 0;
-		int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2;
-		for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) {
-			baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience;
-		}
-		champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp);
-	}
-
-	_candidateChampionOrdinal = prevChampCount + 1;
-	if (++_partyChampionCount == 1) {
-		_vm->_eventMan->commandSetLeader(kChampionFirst);
-		_vm->_menuMan->_shouldRefreshActionArea = true;
-	} else {
-		_vm->_menuMan->clearActingChampion();
-		_vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1));
-	}
-
-	int16 mapX = _vm->_dungeonMan->_currMap._partyPosX;
-	int16 mapY = _vm->_dungeonMan->_currMap._partyPosY;
-
-	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir));
-	mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir];
-	mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir];
-	thing = dunMan.getSquareFirstThing(mapX, mapY);
-	AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
-	uint16 slotIndex_Green;
-	while (thing != Thing::_thingEndOfList) {
-		ThingType AL_2_thingType = thing.getType();
-		if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) {
-			int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots();
-			switch (AL_2_thingType) {
-			case kArmourThingType:
-				for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) {
-					if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
-						goto T0280048;
-				}
-				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
-					slotIndex_Green = kChampionSlotNeck;
-				} else {
-					goto T0280046;
-				}
-				break;
-			case kWeaponThingType:
-				if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) {
-					slotIndex_Green = kChampionSlotActionHand;
-				} else {
-					goto T0280046;
-				}
-				break;
-			case kScrollThingType:
-			case kPotionThingType:
-				if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) {
-					slotIndex_Green = kChampionSlotPouch_1;
-				} else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) {
-					slotIndex_Green = kChampionSlotPouch_2;
-				} else {
-					goto T0280046;
-				}
-				break;
-			case kContainerThingType:
-			case kJunkThingType:
-T0280046:
-				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
-					slotIndex_Green = kChampionSlotNeck;
-				} else {
-					slotIndex_Green = AL_0_slotIndex_Red++;
-				}
-				break;
-			}
-T0280048:
-			if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) {
-				goto T0280046;
-			}
-			warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot");
-		}
-		thing = dunMan.getNextThing(thing);
-	}
-
-	_vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount);
-	_vm->_menuMan->drawDisabledMenu();
-}
-
-void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
-
-	Champion *curChampion = &_champions[champIndex];
-	int16 barGraphIndex = 0;
-	int16 barGraphHeightArray[3];
-
-	if (curChampion->_currHealth > 0) {
-		uint32 barGraphHeight = (((uint32)(curChampion->_currHealth) << 10) * 25) / curChampion->_maxHealth;
-		if (barGraphHeight & 0x3FF) {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
-		} else {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
-		}
-	} else {
-		barGraphHeightArray[barGraphIndex++] = 0;
-	}
-
-	if (curChampion->_currStamina > 0) {
-		uint32 barGraphHeight = (((uint32)(curChampion->_currStamina) << 10) * 25) / curChampion->_maxStamina;
-		if (barGraphHeight & 0x3FF) {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
-		} else {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
-		}
-	} else {
-		barGraphHeightArray[barGraphIndex++] = 0;
-	}
-
-	if (curChampion->_currMana > 0) {
-		uint32 barGraphHeight = (((uint32)(curChampion->_currMana) << 10) * 25) / curChampion->_maxMana;
-		if (barGraphHeight & 0x3FF) {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
-		} else {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
-		}
-	} else {
-		barGraphHeightArray[barGraphIndex++] = 0;
-	}
-	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-
-	Box box;
-	box._x1 = champIndex * kChampionStatusBoxSpacing + 46;
-	box._x2 = box._x1 + 3 + 1;
-	box._y1 = 2;
-	box._y2 = 26 + 1;
-
-	for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) {
-		int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex];
-		if (barGraphHeight < 25) {
-			box._y1 = 2;
-			box._y1 = 27 - barGraphHeight + 1;
-			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
-		}
-		if (barGraphHeight) {
-			box._y1 = 27 - barGraphHeight;
-			box._y2 = 26 + 1;
-			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
-		}
-		box._x1 += 7;
-		box._x2 += 7;
-	}
-	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
-}
-
-
-uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) {
-	int16 currStamina = champ->_currStamina;
-	int16 halfMaxStamina = champ->_maxStamina / 2;
-	if (currStamina < halfMaxStamina) {
-		warning("Possible undefined behavior in the original code");
-		val /= 2;
-		return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina;
-	}
-	return val;
-}
-
-uint16 ChampionMan::getMaximumLoad(Champion *champ) {
-	uint16 maximumLoad = champ->getStatistic(kChampionStatStrength, kChampionStatCurrent) * 8 + 100;
-	maximumLoad = getStaminaAdjustedValue(champ, maximumLoad);
-	int16 wounds = champ->getWounds();
-	if (wounds) {
-		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kChampionWoundLegs) ? 2 : 3);
-	}
-	if (_vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotFeet)) == kIconIndiceArmourElvenBoots) {
-		maximumLoad += maximumLoad * 16;
-	}
-	maximumLoad += 9;
-	maximumLoad -= maximumLoad % 10;
-	return maximumLoad;
-}
-
-void ChampionMan::drawChampionState(ChampionIndex champIndex) {
-	InventoryMan &invMan = *_vm->_inventoryMan;
-	DisplayMan &dispMan = *_vm->_displayMan;
-	MenuMan &menuMan = *_vm->_menuMan;
-	EventManager &eventMan = *_vm->_eventMan;
-
-	Box box;
-	int16 champStatusBoxX = champIndex * kChampionStatusBoxSpacing;
-	Champion *champ = &_champions[champIndex];
-	uint16 champAttributes = champ->getAttributes();
-	if (!((champAttributes) & (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon |
-												  kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport |
-												  kChampionAttributeActionHand))) {
-		return;
-	}
-	bool isInventoryChamp = (indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
-	dispMan._useByteBoxCoordinates = false;
-	if (champAttributes & kChampionAttributeStatusBox) {
-		box._y1 = 0;
-		box._y2 = 28 + 1;
-		box._x1 = champStatusBoxX;
-		box._x2 = box._x1 + 66 + 1;
-		if (champ->_currHealth) {
-			dispMan.clearScreenBox(kColorDarkestGray, box);
-			int16 nativeBitmapIndices[3];
-			for (int16 i = 0; i < 3; ++i)
-				nativeBitmapIndices[i] = 0;
-			int16 AL_0_borderCount = 0;
-			if (_party._fireShieldDefense > 0)
-				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyFireshieldIndice;
-			if (_party._spellShieldDefense > 0)
-				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartySpellshieldIndice;
-			if (_party._shieldDefense > 0)
-				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyShieldIndice;
-			while (AL_0_borderCount--) {
-				dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, kColorFlesh);
-			}
-			if (isInventoryChamp) {
-				invMan.drawStatusBoxPortrait(champIndex);
-				champAttributes |= kChampionAttributeStatistics;
-			} else {
-				champAttributes |= (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeWounds | kChampionAttributeActionHand);
-			}
-		} else {
-			dispMan.blitToScreen(dispMan.getBitmap(kStatusBoxDeadChampion), 80, 0, 0, box, kColorNoTransparency);
-			warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen");
-			menuMan.drawActionIcon(champIndex);
-			goto T0292042_green;
-		}
-	}
-
-	if (!champ->_currHealth)
-		goto T0292042_green;
-
-	if(champAttributes & kChampionAttributeNameTitle) {
-		int16 AL_0_colorIndex = (champIndex == _leaderIndex) ? kColorGold : kColorLightestGray; // unused because of missing functions
-		if(isInventoryChamp) {
-			char *champName = champ->_name;
-			warning("MISSING CODE: F0052_TEXT_PrintToViewport");
-			int16 champTitleX = 6 * strlen(champName) + 3;
-			char champTitleFirstChar = champ->_title[0];
-			if ((champTitleFirstChar != ',') && (champTitleFirstChar != ';') && (champTitleFirstChar != '-')) {
-				champTitleX += 6;
-			}
-			warning("MISSING CODE: F0052_TEXT_PrintToViewport");
-			champAttributes |= kChampionAttributeViewport;
-		} else {
-			box._y1 = 0;
-			box._y2 = 6 + 1;
-			box._x1 = champStatusBoxX;
-			box._x2 = box._x1 + 42 + 1;
-			dispMan.clearScreenBox(kColorDarkGary, box);
-			warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen");
-		}
-	}
-
-	if (champAttributes & kChampionAttributeStatistics) {
-		drawChampionBarGraphs(champIndex);
-		if (isInventoryChamp) {
-			warning("MISSING CODE: F0290_CHAMPION_DrawHealthStaminaManaValues");
-			int16 AL_2_nativeBitmapIndex;
-			if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) {
-				AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice;
-			} else {
-				AL_2_nativeBitmapIndex = kSlotBoxNormalIndice;
-			}
-			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, kColorDarkestGray, gDungeonViewport);
-			AL_2_nativeBitmapIndex = kSlotBoxNormalIndice;
-			for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) {
-				if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent) 
-					< champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum)) {
-					AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice;
-					break;
-				}
-			}
-			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, kColorDarkestGray, gDungeonViewport);
-			champAttributes |= kChampionAttributeViewport;
-		}
-	}
-
-	if (champAttributes & kChampionAttributeWounds) {
-		for (int16 AL_0_slotIndex = isInventoryChamp ? kChampionSlotFeet : kChampionSlotActionHand; AL_0_slotIndex >= kChampionSlotReadyHand; AL_0_slotIndex--) {
-			warning("MISSING CODE: F0291_CHAMPION_DrawSlot");
-		}
-		if (isInventoryChamp) {
-			champAttributes |= kChampionAttributeViewport;
-		}
-	}
-
-	if (champAttributes & kChampionAttributeLoad) {
-		warning("MISSING CODE: whole if branch, many F0052_TEXT_PrintToViewport-s");
-
-
-
-		champAttributes |= kChampionAttributeViewport;
-	}
-
-	{ // block so goto won't skip AL_0_championIconIndex initialization 
-		int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir);
-
-		if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != indexToOrdinal(AL_0_championIconIndex))) {
-			dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]);
-			dispMan.blitToScreen(dispMan.getBitmap(kChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0,
-								 gBoxChampionIcons[AL_0_championIconIndex], kColorDarkestGray);
-		}
-	}
-
-	if ((champAttributes & kChampionAttributePanel) && isInventoryChamp) {
-		if (_vm->_pressingMouth) {
-			invMan.drawPanelFoodWaterPoisoned();
-		} else if (_vm->_pressingEye) {
-			if (_leaderEmptyHanded) {
-				warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics");
-			}
-		} else {
-			invMan.drawPanel();
-		}
-		champAttributes |= kChampionAttributeViewport;
-	}
-
-	if (champAttributes & kChampionAttributeActionHand) {
-		warning("MISSING CODE: F0291_CHAMPION_DrawSlot");
-		menuMan.drawActionIcon(champIndex);
-		if (isInventoryChamp) {
-			champAttributes |= kChampionAttributeViewport;
-		}
-	}
-
-	if (champAttributes & kChampionAttributeViewport) {
-		warning("MISSGIN CODE: F0097_DUNGEONVIEW_DrawViewport");
-	}
-
-
-T0292042_green:
-	champ->setAttributeFlag((ChampionAttribute)(kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon |
-												kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport |
-												kChampionAttributeActionHand), false);
-	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
-}
-
-uint16 ChampionMan::championIconIndex(int16 val, direction dir) {
-	return ((val + 4 - dir) & 0x3);
-}
-
-}
+#include "champion.h"
+#include "dungeonman.h"
+#include "eventman.h"
+#include "menus.h"
+#include "inventory.h"
+#include "objectman.h"
+
+
+namespace DM {
+
+Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
+Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
+Box gBoxChampionIcons[4] = { // @ G0054_ai_Graphic562_Box_ChampionIcons
+	Box(281, 299,  0, 13),
+	Box(301, 319,  0, 13),
+	Box(301, 319, 15, 28),
+	Box(281, 299, 15, 28)};
+Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; // @ G0046_auc_Graphic562_ChampionColor
+
+uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
+	/* 30 for champion inventory, 8 for chest */
+	0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Action Hand      Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0x0002,   /* Head             Head */
+	0x0008,   /* Torso            Torso */
+	0x0010,   /* Legs             Legs */
+	0x0020,   /* Feet             Feet */
+	0x0100,   /* Pouch 2          Pouch */
+	0x0080,   /* Quiver Line2 1   Quiver 2 */
+	0x0080,   /* Quiver Line1 2   Quiver 2 */
+	0x0080,   /* Quiver Line2 2   Quiver 2 */
+	0x0004,   /* Neck             Neck */
+	0x0100,   /* Pouch 1          Pouch */
+	0x0040,   /* Quiver Line1 1   Quiver 1 */
+	0xFFFF,   /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0x0400,   /* Chest 1          Chest */
+	0x0400,   /* Chest 2          Chest */
+	0x0400,   /* Chest 3          Chest */
+	0x0400,   /* Chest 4          Chest */
+	0x0400,   /* Chest 5          Chest */
+	0x0400,   /* Chest 6          Chest */
+	0x0400,   /* Chest 7          Chest */
+	0x0400}; /* Chest 8          Chest */
+
+Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
+
+ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
+	_leaderIndex = kChampionNone;
+
+	_partyDead = false;
+	_partyIsSleeping = false;
+	_leaderHandObjectIconIndex = kIconIndiceNone;
+	_leaderEmptyHanded = true;
+}
+
+uint16 ChampionMan::getChampionPortraitX(uint16 index) {
+	return ((index) & 0x7) << 5;
+}
+
+uint16 ChampionMan::getChampionPortraitY(uint16 index) {
+	return ((index) >> 3) * 29;
+}
+
+int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) {
+	int val = 0;
+	for (uint16 i = 0; i < characterCount; ++i) {
+		val = (val << 4) + (string[i] - 'A');
+	}
+	return val;
+}
+
+ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
+	for (uint16 i = 0; i < _partyChampionCount; ++i) {
+		if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
+			return (ChampionIndex)i;
+	}
+
+	return kChampionNone;
+}
+
+void ChampionMan::resetDataToStartGame() {
+	if (!_vm->_dungeonMan->_messages._newGame) {
+		warning("MISSING CODE: stuff for resetting for loaded games");
+		assert(false);
+	}
+
+	_leaderHand = Thing::_thingNone;
+	_leaderHandObjectIconIndex = kIconIndiceNone;
+	_leaderEmptyHanded = true;
+}
+
+
+void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
+	DisplayMan &dispMan = *_vm->_displayMan;
+	DungeonMan &dunMan = *_vm->_dungeonMan;
+
+	if (!_leaderEmptyHanded || _partyChampionCount == 4)
+		return;
+
+	uint16 prevChampCount = _partyChampionCount;
+	Champion *champ = &_champions[prevChampCount];
+	champ->resetToZero();
+	dispMan._useByteBoxCoordinates = true;
+	{ // limit destBox scope
+		Box &destBox = gBoxChampionPortrait;
+		dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex),
+							 champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency);
+	}
+
+	champ->_actionIndex = kChampionActionNone;
+	champ->_enableActionEventIndex = -1;
+	champ->_hideDamageReceivedIndex = -1;
+	champ->_dir = dunMan._currMap._partyDir;
+	ViewCell AL_0_viewCell = kViewCellFronLeft;
+	while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone)
+		AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
+	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3);
+	champ->clearAttributes(kChampionAttributeIcon);
+	champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir;
+	champ->_food = 1500 + _vm->_rnd->getRandomNumber(256);
+	champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
+	int16 AL_0_slotIndex_Red;
+	for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) {
+		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone);
+	}
+	Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY);
+	while (thing.getType() != kTextstringType) {
+		thing = dunMan.getNextThing(thing);
+	}
+	char decodedChampionText[77];
+	char* character_Green = decodedChampionText;
+	dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible));
+	int16 AL_0_characterIndex = 0;
+	uint16 AL_2_character;
+	while ((AL_2_character = *character_Green++) != '\n') {
+		champ->_name[AL_0_characterIndex++] = AL_2_character;
+	}
+	champ->_name[AL_0_characterIndex] = '\0';
+	AL_0_characterIndex = 0;
+	bool AL_4_champTitleCopied = false;
+	for (;;) { // infinite
+		AL_2_character = *character_Green++;
+		if (AL_2_character == '\n') {
+			if (AL_4_champTitleCopied)
+				break;
+			AL_4_champTitleCopied = true;
+		} else {
+			champ->_title[AL_0_characterIndex++] = AL_2_character;
+		}
+	}
+	champ->_title[AL_0_characterIndex] = '\0';
+	if (*character_Green++ == 'M') {
+		champ->setAttributeFlag(kChampionAttributeMale, true);
+	}
+	character_Green++;
+	champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4);
+	character_Green += 4;
+	champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4);
+	character_Green += 4;
+	champ->_currMana = champ->_maxMana = getDecodedValue(character_Green, 4);
+	character_Green += 4;
+	character_Green++;
+
+	int16 AL_0_statisticIndex;
+	for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) {
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30);
+		uint16 currMaxVal = getDecodedValue(character_Green, 2);
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal);
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal);
+		character_Green += 2;
+	}
+
+	champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10);
+	character_Green++;
+
+	int16 AL_0_skillIndex;
+	int16 AL_2_skillValue;
+	for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) {
+		if ((AL_2_skillValue = *character_Green++ - 'A') > 0) {
+			champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue);
+		}
+	}
+
+	for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) {
+		int32 baseSkillExp = 0;
+		int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2;
+		for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) {
+			baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience;
+		}
+		champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp);
+	}
+
+	_candidateChampionOrdinal = prevChampCount + 1;
+	if (++_partyChampionCount == 1) {
+		_vm->_eventMan->commandSetLeader(kChampionFirst);
+		_vm->_menuMan->_shouldRefreshActionArea = true;
+	} else {
+		_vm->_menuMan->clearActingChampion();
+		_vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1));
+	}
+
+	int16 mapX = _vm->_dungeonMan->_currMap._partyPosX;
+	int16 mapY = _vm->_dungeonMan->_currMap._partyPosY;
+
+	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir));
+	mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir];
+	mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir];
+	thing = dunMan.getSquareFirstThing(mapX, mapY);
+	AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
+	uint16 slotIndex_Green;
+	while (thing != Thing::_thingEndOfList) {
+		ThingType AL_2_thingType = thing.getType();
+		if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) {
+			int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots();
+			switch (AL_2_thingType) {
+			case kArmourThingType:
+				for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) {
+					if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
+						goto T0280048;
+				}
+				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
+					slotIndex_Green = kChampionSlotNeck;
+				} else {
+					goto T0280046;
+				}
+				break;
+			case kWeaponThingType:
+				if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) {
+					slotIndex_Green = kChampionSlotActionHand;
+				} else {
+					goto T0280046;
+				}
+				break;
+			case kScrollThingType:
+			case kPotionThingType:
+				if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) {
+					slotIndex_Green = kChampionSlotPouch_1;
+				} else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) {
+					slotIndex_Green = kChampionSlotPouch_2;
+				} else {
+					goto T0280046;
+				}
+				break;
+			case kContainerThingType:
+			case kJunkThingType:
+T0280046:
+				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
+					slotIndex_Green = kChampionSlotNeck;
+				} else {
+					slotIndex_Green = AL_0_slotIndex_Red++;
+				}
+				break;
+			}
+T0280048:
+			if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) {
+				goto T0280046;
+			}
+			warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot");
+		}
+		thing = dunMan.getNextThing(thing);
+	}
+
+	_vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount);
+	_vm->_menuMan->drawDisabledMenu();
+}
+
+void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
+
+	Champion *curChampion = &_champions[champIndex];
+	int16 barGraphIndex = 0;
+	int16 barGraphHeightArray[3];
+
+	if (curChampion->_currHealth > 0) {
+		uint32 barGraphHeight = (((uint32)(curChampion->_currHealth) << 10) * 25) / curChampion->_maxHealth;
+		if (barGraphHeight & 0x3FF) {
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
+		} else {
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
+		}
+	} else {
+		barGraphHeightArray[barGraphIndex++] = 0;
+	}
+
+	if (curChampion->_currStamina > 0) {
+		uint32 barGraphHeight = (((uint32)(curChampion->_currStamina) << 10) * 25) / curChampion->_maxStamina;
+		if (barGraphHeight & 0x3FF) {
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
+		} else {
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
+		}
+	} else {
+		barGraphHeightArray[barGraphIndex++] = 0;
+	}
+
+	if (curChampion->_currMana > 0) {
+		uint32 barGraphHeight = (((uint32)(curChampion->_currMana) << 10) * 25) / curChampion->_maxMana;
+		if (barGraphHeight & 0x3FF) {
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
+		} else {
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
+		}
+	} else {
+		barGraphHeightArray[barGraphIndex++] = 0;
+	}
+	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+
+	Box box;
+	box._x1 = champIndex * kChampionStatusBoxSpacing + 46;
+	box._x2 = box._x1 + 3 + 1;
+	box._y1 = 2;
+	box._y2 = 26 + 1;
+
+	for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) {
+		int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex];
+		if (barGraphHeight < 25) {
+			box._y1 = 2;
+			box._y1 = 27 - barGraphHeight + 1;
+			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
+		}
+		if (barGraphHeight) {
+			box._y1 = 27 - barGraphHeight;
+			box._y2 = 26 + 1;
+			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
+		}
+		box._x1 += 7;
+		box._x2 += 7;
+	}
+	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+}
+
+
+uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) {
+	int16 currStamina = champ->_currStamina;
+	int16 halfMaxStamina = champ->_maxStamina / 2;
+	if (currStamina < halfMaxStamina) {
+		warning("Possible undefined behavior in the original code");
+		val /= 2;
+		return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina;
+	}
+	return val;
+}
+
+uint16 ChampionMan::getMaximumLoad(Champion *champ) {
+	uint16 maximumLoad = champ->getStatistic(kChampionStatStrength, kChampionStatCurrent) * 8 + 100;
+	maximumLoad = getStaminaAdjustedValue(champ, maximumLoad);
+	int16 wounds = champ->getWounds();
+	if (wounds) {
+		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kChampionWoundLegs) ? 2 : 3);
+	}
+	if (_vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotFeet)) == kIconIndiceArmourElvenBoots) {
+		maximumLoad += maximumLoad * 16;
+	}
+	maximumLoad += 9;
+	maximumLoad -= maximumLoad % 10;
+	return maximumLoad;
+}
+
+void ChampionMan::drawChampionState(ChampionIndex champIndex) {
+	InventoryMan &invMan = *_vm->_inventoryMan;
+	DisplayMan &dispMan = *_vm->_displayMan;
+	MenuMan &menuMan = *_vm->_menuMan;
+	EventManager &eventMan = *_vm->_eventMan;
+
+	Box box;
+	int16 champStatusBoxX = champIndex * kChampionStatusBoxSpacing;
+	Champion *champ = &_champions[champIndex];
+	uint16 champAttributes = champ->getAttributes();
+	if (!((champAttributes) & (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon |
+												  kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport |
+												  kChampionAttributeActionHand))) {
+		return;
+	}
+	bool isInventoryChamp = (indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
+	dispMan._useByteBoxCoordinates = false;
+	if (champAttributes & kChampionAttributeStatusBox) {
+		box._y1 = 0;
+		box._y2 = 28 + 1;
+		box._x1 = champStatusBoxX;
+		box._x2 = box._x1 + 66 + 1;
+		if (champ->_currHealth) {
+			dispMan.clearScreenBox(kColorDarkestGray, box);
+			int16 nativeBitmapIndices[3];
+			for (int16 i = 0; i < 3; ++i)
+				nativeBitmapIndices[i] = 0;
+			int16 AL_0_borderCount = 0;
+			if (_party._fireShieldDefense > 0)
+				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyFireshieldIndice;
+			if (_party._spellShieldDefense > 0)
+				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartySpellshieldIndice;
+			if (_party._shieldDefense > 0)
+				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyShieldIndice;
+			while (AL_0_borderCount--) {
+				dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, kColorFlesh);
+			}
+			if (isInventoryChamp) {
+				invMan.drawStatusBoxPortrait(champIndex);
+				champAttributes |= kChampionAttributeStatistics;
+			} else {
+				champAttributes |= (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeWounds | kChampionAttributeActionHand);
+			}
+		} else {
+			dispMan.blitToScreen(dispMan.getBitmap(kStatusBoxDeadChampion), 80, 0, 0, box, kColorNoTransparency);
+			warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen");
+			menuMan.drawActionIcon(champIndex);
+			goto T0292042_green;
+		}
+	}
+
+	if (!champ->_currHealth)
+		goto T0292042_green;
+
+	if(champAttributes & kChampionAttributeNameTitle) {
+		int16 AL_0_colorIndex = (champIndex == _leaderIndex) ? kColorGold : kColorLightestGray; // unused because of missing functions
+		if(isInventoryChamp) {
+			char *champName = champ->_name;
+			warning("MISSING CODE: F0052_TEXT_PrintToViewport");
+			int16 champTitleX = 6 * strlen(champName) + 3;
+			char champTitleFirstChar = champ->_title[0];
+			if ((champTitleFirstChar != ',') && (champTitleFirstChar != ';') && (champTitleFirstChar != '-')) {
+				champTitleX += 6;
+			}
+			warning("MISSING CODE: F0052_TEXT_PrintToViewport");
+			champAttributes |= kChampionAttributeViewport;
+		} else {
+			box._y1 = 0;
+			box._y2 = 6 + 1;
+			box._x1 = champStatusBoxX;
+			box._x2 = box._x1 + 42 + 1;
+			dispMan.clearScreenBox(kColorDarkGary, box);
+			warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen");
+		}
+	}
+
+	if (champAttributes & kChampionAttributeStatistics) {
+		drawChampionBarGraphs(champIndex);
+		if (isInventoryChamp) {
+			warning("MISSING CODE: F0290_CHAMPION_DrawHealthStaminaManaValues");
+			int16 AL_2_nativeBitmapIndex;
+			if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) {
+				AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice;
+			} else {
+				AL_2_nativeBitmapIndex = kSlotBoxNormalIndice;
+			}
+			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, kColorDarkestGray, gDungeonViewport);
+			AL_2_nativeBitmapIndex = kSlotBoxNormalIndice;
+			for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) {
+				if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent) 
+					< champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum)) {
+					AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice;
+					break;
+				}
+			}
+			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, kColorDarkestGray, gDungeonViewport);
+			champAttributes |= kChampionAttributeViewport;
+		}
+	}
+
+	if (champAttributes & kChampionAttributeWounds) {
+		for (int16 AL_0_slotIndex = isInventoryChamp ? kChampionSlotFeet : kChampionSlotActionHand; AL_0_slotIndex >= kChampionSlotReadyHand; AL_0_slotIndex--) {
+			warning("MISSING CODE: F0291_CHAMPION_DrawSlot");
+		}
+		if (isInventoryChamp) {
+			champAttributes |= kChampionAttributeViewport;
+		}
+	}
+
+	if (champAttributes & kChampionAttributeLoad) {
+		warning("MISSING CODE: whole if branch, many F0052_TEXT_PrintToViewport-s");
+
+
+
+		champAttributes |= kChampionAttributeViewport;
+	}
+
+	{ // block so goto won't skip AL_0_championIconIndex initialization 
+		int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir);
+
+		if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != indexToOrdinal(AL_0_championIconIndex))) {
+			dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]);
+			dispMan.blitToScreen(dispMan.getBitmap(kChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0,
+								 gBoxChampionIcons[AL_0_championIconIndex], kColorDarkestGray);
+		}
+	}
+
+	if ((champAttributes & kChampionAttributePanel) && isInventoryChamp) {
+		if (_vm->_pressingMouth) {
+			invMan.drawPanelFoodWaterPoisoned();
+		} else if (_vm->_pressingEye) {
+			if (_leaderEmptyHanded) {
+				warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics");
+			}
+		} else {
+			invMan.drawPanel();
+		}
+		champAttributes |= kChampionAttributeViewport;
+	}
+
+	if (champAttributes & kChampionAttributeActionHand) {
+		warning("MISSING CODE: F0291_CHAMPION_DrawSlot");
+		menuMan.drawActionIcon(champIndex);
+		if (isInventoryChamp) {
+			champAttributes |= kChampionAttributeViewport;
+		}
+	}
+
+	if (champAttributes & kChampionAttributeViewport) {
+		warning("MISSGIN CODE: F0097_DUNGEONVIEW_DrawViewport");
+	}
+
+
+T0292042_green:
+	champ->setAttributeFlag((ChampionAttribute)(kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon |
+												kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport |
+												kChampionAttributeActionHand), false);
+	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+}
+
+uint16 ChampionMan::championIconIndex(int16 val, direction dir) {
+	return ((val + 4 - dir) & 0x3);
+}
+
+}
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 8d38c5b..61810e8 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -56,8 +56,15 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_objectMan = nullptr;
 	_inventoryMan = nullptr;
 	_textMan = nullptr;
+
 	_stopWaitingForPlayerInput = false;
 	_gameTimeTicking = false;
+	_restartGameAllowed = false;
+	_pressingEye = false;
+	_pressingMouth = false;
+	_stopPressingEye = false;
+	_stopPressingMouth = false;
+	_highlightBoxInversionRequested = false;
 
 	debug("DMEngine::DMEngine");
 }
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index b7caa60..b593729 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -216,6 +216,9 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 
 	_pendingClickPresent = false;
 	_isCommandQueueLocked = true;
+	_mousePointerBitmapUpdated = false;
+	_refreshMousePointerInMainLoop = false;
+	_highlightBoxEnabled = false;
 
 	_dummyMapIndex = 0;
 	_pendingClickButton = kNoneMouseButton;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index ab0f9f1..e2713a2 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -12,8 +12,6 @@ namespace DM {
 
 Box gBoxMovementArrows = Box(224, 319, 124, 168);
 
-
-
 enum StairFrameIndex {
 	kFrameStairsUpFront_D3L = 0, // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L 
 	kFrameStairsUpFront_D3C = 1, // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C 
@@ -614,6 +612,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 		_currMapDoorOrnIndices[i] = 0;
 
 	_inscriptionThing = Thing::_thingNone;
+	_useByteBoxCoordinates = false;
 }
 
 DisplayMan::~DisplayMan() {
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index f641e02..b346464 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -10,7 +10,10 @@ namespace DM {
 
 byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
 
-MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {}
+MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
+	_shouldRefreshActionArea = false;
+	_actionAreaContainsIcons = false;
+}
 
 void MenuMan::drawMovementArrows() {
 	DisplayMan &disp = *_vm->_displayMan;


Commit: 9d7cfe5cd8cc5ba12b544c0da2e8d3d1f84133fa
    https://github.com/scummvm/scummvm/commit/9d7cfe5cd8cc5ba12b544c0da2e8d3d1f84133fa
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add several functions realted to text display

 Add F0290_CHAMPION_DrawHealthStaminaManaValues, F0289_CHAMPION_DrawHealthOrStaminaOrManaValue,
F0288_CHAMPION_GetStringFromInteger, F0052_TEXT_PrintToViewport, swap warning for real code, expand viewport fields with width, height, remove self-inclusion
in dungeonman.h, remove extra black line when loading fonts, fix alignment error in TextMan::printTextToBitmap

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/text.cpp
    engines/dm/text.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index ff3e5f7..79f4267 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1,538 +1,563 @@
-#include "champion.h"
-#include "dungeonman.h"
-#include "eventman.h"
-#include "menus.h"
-#include "inventory.h"
-#include "objectman.h"
-
-
-namespace DM {
-
-Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
-Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
-Box gBoxChampionIcons[4] = { // @ G0054_ai_Graphic562_Box_ChampionIcons
-	Box(281, 299,  0, 13),
-	Box(301, 319,  0, 13),
-	Box(301, 319, 15, 28),
-	Box(281, 299, 15, 28)};
-Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; // @ G0046_auc_Graphic562_ChampionColor
-
-uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
-	/* 30 for champion inventory, 8 for chest */
-	0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Action Hand      Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0x0002,   /* Head             Head */
-	0x0008,   /* Torso            Torso */
-	0x0010,   /* Legs             Legs */
-	0x0020,   /* Feet             Feet */
-	0x0100,   /* Pouch 2          Pouch */
-	0x0080,   /* Quiver Line2 1   Quiver 2 */
-	0x0080,   /* Quiver Line1 2   Quiver 2 */
-	0x0080,   /* Quiver Line2 2   Quiver 2 */
-	0x0004,   /* Neck             Neck */
-	0x0100,   /* Pouch 1          Pouch */
-	0x0040,   /* Quiver Line1 1   Quiver 1 */
-	0xFFFF,   /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0x0400,   /* Chest 1          Chest */
-	0x0400,   /* Chest 2          Chest */
-	0x0400,   /* Chest 3          Chest */
-	0x0400,   /* Chest 4          Chest */
-	0x0400,   /* Chest 5          Chest */
-	0x0400,   /* Chest 6          Chest */
-	0x0400,   /* Chest 7          Chest */
-	0x0400}; /* Chest 8          Chest */
-
-Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
-
-ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
-	_leaderIndex = kChampionNone;
-
-	_partyDead = false;
-	_partyIsSleeping = false;
-	_leaderHandObjectIconIndex = kIconIndiceNone;
-	_leaderEmptyHanded = true;
-}
-
-uint16 ChampionMan::getChampionPortraitX(uint16 index) {
-	return ((index) & 0x7) << 5;
-}
-
-uint16 ChampionMan::getChampionPortraitY(uint16 index) {
-	return ((index) >> 3) * 29;
-}
-
-int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) {
-	int val = 0;
-	for (uint16 i = 0; i < characterCount; ++i) {
-		val = (val << 4) + (string[i] - 'A');
-	}
-	return val;
-}
-
-ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
-	for (uint16 i = 0; i < _partyChampionCount; ++i) {
-		if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
-			return (ChampionIndex)i;
-	}
-
-	return kChampionNone;
-}
-
-void ChampionMan::resetDataToStartGame() {
-	if (!_vm->_dungeonMan->_messages._newGame) {
-		warning("MISSING CODE: stuff for resetting for loaded games");
-		assert(false);
-	}
-
-	_leaderHand = Thing::_thingNone;
-	_leaderHandObjectIconIndex = kIconIndiceNone;
-	_leaderEmptyHanded = true;
-}
-
-
-void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
-	DisplayMan &dispMan = *_vm->_displayMan;
-	DungeonMan &dunMan = *_vm->_dungeonMan;
-
-	if (!_leaderEmptyHanded || _partyChampionCount == 4)
-		return;
-
-	uint16 prevChampCount = _partyChampionCount;
-	Champion *champ = &_champions[prevChampCount];
-	champ->resetToZero();
-	dispMan._useByteBoxCoordinates = true;
-	{ // limit destBox scope
-		Box &destBox = gBoxChampionPortrait;
-		dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex),
-							 champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency);
-	}
-
-	champ->_actionIndex = kChampionActionNone;
-	champ->_enableActionEventIndex = -1;
-	champ->_hideDamageReceivedIndex = -1;
-	champ->_dir = dunMan._currMap._partyDir;
-	ViewCell AL_0_viewCell = kViewCellFronLeft;
-	while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone)
-		AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
-	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3);
-	champ->clearAttributes(kChampionAttributeIcon);
-	champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir;
-	champ->_food = 1500 + _vm->_rnd->getRandomNumber(256);
-	champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
-	int16 AL_0_slotIndex_Red;
-	for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) {
-		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone);
-	}
-	Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY);
-	while (thing.getType() != kTextstringType) {
-		thing = dunMan.getNextThing(thing);
-	}
-	char decodedChampionText[77];
-	char* character_Green = decodedChampionText;
-	dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible));
-	int16 AL_0_characterIndex = 0;
-	uint16 AL_2_character;
-	while ((AL_2_character = *character_Green++) != '\n') {
-		champ->_name[AL_0_characterIndex++] = AL_2_character;
-	}
-	champ->_name[AL_0_characterIndex] = '\0';
-	AL_0_characterIndex = 0;
-	bool AL_4_champTitleCopied = false;
-	for (;;) { // infinite
-		AL_2_character = *character_Green++;
-		if (AL_2_character == '\n') {
-			if (AL_4_champTitleCopied)
-				break;
-			AL_4_champTitleCopied = true;
-		} else {
-			champ->_title[AL_0_characterIndex++] = AL_2_character;
-		}
-	}
-	champ->_title[AL_0_characterIndex] = '\0';
-	if (*character_Green++ == 'M') {
-		champ->setAttributeFlag(kChampionAttributeMale, true);
-	}
-	character_Green++;
-	champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4);
-	character_Green += 4;
-	champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4);
-	character_Green += 4;
-	champ->_currMana = champ->_maxMana = getDecodedValue(character_Green, 4);
-	character_Green += 4;
-	character_Green++;
-
-	int16 AL_0_statisticIndex;
-	for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) {
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30);
-		uint16 currMaxVal = getDecodedValue(character_Green, 2);
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal);
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal);
-		character_Green += 2;
-	}
-
-	champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10);
-	character_Green++;
-
-	int16 AL_0_skillIndex;
-	int16 AL_2_skillValue;
-	for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) {
-		if ((AL_2_skillValue = *character_Green++ - 'A') > 0) {
-			champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue);
-		}
-	}
-
-	for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) {
-		int32 baseSkillExp = 0;
-		int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2;
-		for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) {
-			baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience;
-		}
-		champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp);
-	}
-
-	_candidateChampionOrdinal = prevChampCount + 1;
-	if (++_partyChampionCount == 1) {
-		_vm->_eventMan->commandSetLeader(kChampionFirst);
-		_vm->_menuMan->_shouldRefreshActionArea = true;
-	} else {
-		_vm->_menuMan->clearActingChampion();
-		_vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1));
-	}
-
-	int16 mapX = _vm->_dungeonMan->_currMap._partyPosX;
-	int16 mapY = _vm->_dungeonMan->_currMap._partyPosY;
-
-	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir));
-	mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir];
-	mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir];
-	thing = dunMan.getSquareFirstThing(mapX, mapY);
-	AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
-	uint16 slotIndex_Green;
-	while (thing != Thing::_thingEndOfList) {
-		ThingType AL_2_thingType = thing.getType();
-		if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) {
-			int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots();
-			switch (AL_2_thingType) {
-			case kArmourThingType:
-				for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) {
-					if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
-						goto T0280048;
-				}
-				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
-					slotIndex_Green = kChampionSlotNeck;
-				} else {
-					goto T0280046;
-				}
-				break;
-			case kWeaponThingType:
-				if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) {
-					slotIndex_Green = kChampionSlotActionHand;
-				} else {
-					goto T0280046;
-				}
-				break;
-			case kScrollThingType:
-			case kPotionThingType:
-				if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) {
-					slotIndex_Green = kChampionSlotPouch_1;
-				} else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) {
-					slotIndex_Green = kChampionSlotPouch_2;
-				} else {
-					goto T0280046;
-				}
-				break;
-			case kContainerThingType:
-			case kJunkThingType:
-T0280046:
-				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
-					slotIndex_Green = kChampionSlotNeck;
-				} else {
-					slotIndex_Green = AL_0_slotIndex_Red++;
-				}
-				break;
-			}
-T0280048:
-			if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) {
-				goto T0280046;
-			}
-			warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot");
-		}
-		thing = dunMan.getNextThing(thing);
-	}
-
-	_vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount);
-	_vm->_menuMan->drawDisabledMenu();
-}
-
-void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
-
-	Champion *curChampion = &_champions[champIndex];
-	int16 barGraphIndex = 0;
-	int16 barGraphHeightArray[3];
-
-	if (curChampion->_currHealth > 0) {
-		uint32 barGraphHeight = (((uint32)(curChampion->_currHealth) << 10) * 25) / curChampion->_maxHealth;
-		if (barGraphHeight & 0x3FF) {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
-		} else {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
-		}
-	} else {
-		barGraphHeightArray[barGraphIndex++] = 0;
-	}
-
-	if (curChampion->_currStamina > 0) {
-		uint32 barGraphHeight = (((uint32)(curChampion->_currStamina) << 10) * 25) / curChampion->_maxStamina;
-		if (barGraphHeight & 0x3FF) {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
-		} else {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
-		}
-	} else {
-		barGraphHeightArray[barGraphIndex++] = 0;
-	}
-
-	if (curChampion->_currMana > 0) {
-		uint32 barGraphHeight = (((uint32)(curChampion->_currMana) << 10) * 25) / curChampion->_maxMana;
-		if (barGraphHeight & 0x3FF) {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
-		} else {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
-		}
-	} else {
-		barGraphHeightArray[barGraphIndex++] = 0;
-	}
-	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-
-	Box box;
-	box._x1 = champIndex * kChampionStatusBoxSpacing + 46;
-	box._x2 = box._x1 + 3 + 1;
-	box._y1 = 2;
-	box._y2 = 26 + 1;
-
-	for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) {
-		int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex];
-		if (barGraphHeight < 25) {
-			box._y1 = 2;
-			box._y1 = 27 - barGraphHeight + 1;
-			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
-		}
-		if (barGraphHeight) {
-			box._y1 = 27 - barGraphHeight;
-			box._y2 = 26 + 1;
-			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
-		}
-		box._x1 += 7;
-		box._x2 += 7;
-	}
-	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
-}
-
-
-uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) {
-	int16 currStamina = champ->_currStamina;
-	int16 halfMaxStamina = champ->_maxStamina / 2;
-	if (currStamina < halfMaxStamina) {
-		warning("Possible undefined behavior in the original code");
-		val /= 2;
-		return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina;
-	}
-	return val;
-}
-
-uint16 ChampionMan::getMaximumLoad(Champion *champ) {
-	uint16 maximumLoad = champ->getStatistic(kChampionStatStrength, kChampionStatCurrent) * 8 + 100;
-	maximumLoad = getStaminaAdjustedValue(champ, maximumLoad);
-	int16 wounds = champ->getWounds();
-	if (wounds) {
-		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kChampionWoundLegs) ? 2 : 3);
-	}
-	if (_vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotFeet)) == kIconIndiceArmourElvenBoots) {
-		maximumLoad += maximumLoad * 16;
-	}
-	maximumLoad += 9;
-	maximumLoad -= maximumLoad % 10;
-	return maximumLoad;
-}
-
-void ChampionMan::drawChampionState(ChampionIndex champIndex) {
-	InventoryMan &invMan = *_vm->_inventoryMan;
-	DisplayMan &dispMan = *_vm->_displayMan;
-	MenuMan &menuMan = *_vm->_menuMan;
-	EventManager &eventMan = *_vm->_eventMan;
-
-	Box box;
-	int16 champStatusBoxX = champIndex * kChampionStatusBoxSpacing;
-	Champion *champ = &_champions[champIndex];
-	uint16 champAttributes = champ->getAttributes();
-	if (!((champAttributes) & (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon |
-												  kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport |
-												  kChampionAttributeActionHand))) {
-		return;
-	}
-	bool isInventoryChamp = (indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
-	dispMan._useByteBoxCoordinates = false;
-	if (champAttributes & kChampionAttributeStatusBox) {
-		box._y1 = 0;
-		box._y2 = 28 + 1;
-		box._x1 = champStatusBoxX;
-		box._x2 = box._x1 + 66 + 1;
-		if (champ->_currHealth) {
-			dispMan.clearScreenBox(kColorDarkestGray, box);
-			int16 nativeBitmapIndices[3];
-			for (int16 i = 0; i < 3; ++i)
-				nativeBitmapIndices[i] = 0;
-			int16 AL_0_borderCount = 0;
-			if (_party._fireShieldDefense > 0)
-				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyFireshieldIndice;
-			if (_party._spellShieldDefense > 0)
-				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartySpellshieldIndice;
-			if (_party._shieldDefense > 0)
-				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyShieldIndice;
-			while (AL_0_borderCount--) {
-				dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, kColorFlesh);
-			}
-			if (isInventoryChamp) {
-				invMan.drawStatusBoxPortrait(champIndex);
-				champAttributes |= kChampionAttributeStatistics;
-			} else {
-				champAttributes |= (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeWounds | kChampionAttributeActionHand);
-			}
-		} else {
-			dispMan.blitToScreen(dispMan.getBitmap(kStatusBoxDeadChampion), 80, 0, 0, box, kColorNoTransparency);
-			warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen");
-			menuMan.drawActionIcon(champIndex);
-			goto T0292042_green;
-		}
-	}
-
-	if (!champ->_currHealth)
-		goto T0292042_green;
-
-	if(champAttributes & kChampionAttributeNameTitle) {
-		int16 AL_0_colorIndex = (champIndex == _leaderIndex) ? kColorGold : kColorLightestGray; // unused because of missing functions
-		if(isInventoryChamp) {
-			char *champName = champ->_name;
-			warning("MISSING CODE: F0052_TEXT_PrintToViewport");
-			int16 champTitleX = 6 * strlen(champName) + 3;
-			char champTitleFirstChar = champ->_title[0];
-			if ((champTitleFirstChar != ',') && (champTitleFirstChar != ';') && (champTitleFirstChar != '-')) {
-				champTitleX += 6;
-			}
-			warning("MISSING CODE: F0052_TEXT_PrintToViewport");
-			champAttributes |= kChampionAttributeViewport;
-		} else {
-			box._y1 = 0;
-			box._y2 = 6 + 1;
-			box._x1 = champStatusBoxX;
-			box._x2 = box._x1 + 42 + 1;
-			dispMan.clearScreenBox(kColorDarkGary, box);
-			warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen");
-		}
-	}
-
-	if (champAttributes & kChampionAttributeStatistics) {
-		drawChampionBarGraphs(champIndex);
-		if (isInventoryChamp) {
-			warning("MISSING CODE: F0290_CHAMPION_DrawHealthStaminaManaValues");
-			int16 AL_2_nativeBitmapIndex;
-			if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) {
-				AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice;
-			} else {
-				AL_2_nativeBitmapIndex = kSlotBoxNormalIndice;
-			}
-			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, kColorDarkestGray, gDungeonViewport);
-			AL_2_nativeBitmapIndex = kSlotBoxNormalIndice;
-			for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) {
-				if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent) 
-					< champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum)) {
-					AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice;
-					break;
-				}
-			}
-			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, kColorDarkestGray, gDungeonViewport);
-			champAttributes |= kChampionAttributeViewport;
-		}
-	}
-
-	if (champAttributes & kChampionAttributeWounds) {
-		for (int16 AL_0_slotIndex = isInventoryChamp ? kChampionSlotFeet : kChampionSlotActionHand; AL_0_slotIndex >= kChampionSlotReadyHand; AL_0_slotIndex--) {
-			warning("MISSING CODE: F0291_CHAMPION_DrawSlot");
-		}
-		if (isInventoryChamp) {
-			champAttributes |= kChampionAttributeViewport;
-		}
-	}
-
-	if (champAttributes & kChampionAttributeLoad) {
-		warning("MISSING CODE: whole if branch, many F0052_TEXT_PrintToViewport-s");
-
-
-
-		champAttributes |= kChampionAttributeViewport;
-	}
-
-	{ // block so goto won't skip AL_0_championIconIndex initialization 
-		int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir);
-
-		if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != indexToOrdinal(AL_0_championIconIndex))) {
-			dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]);
-			dispMan.blitToScreen(dispMan.getBitmap(kChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0,
-								 gBoxChampionIcons[AL_0_championIconIndex], kColorDarkestGray);
-		}
-	}
-
-	if ((champAttributes & kChampionAttributePanel) && isInventoryChamp) {
-		if (_vm->_pressingMouth) {
-			invMan.drawPanelFoodWaterPoisoned();
-		} else if (_vm->_pressingEye) {
-			if (_leaderEmptyHanded) {
-				warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics");
-			}
-		} else {
-			invMan.drawPanel();
-		}
-		champAttributes |= kChampionAttributeViewport;
-	}
-
-	if (champAttributes & kChampionAttributeActionHand) {
-		warning("MISSING CODE: F0291_CHAMPION_DrawSlot");
-		menuMan.drawActionIcon(champIndex);
-		if (isInventoryChamp) {
-			champAttributes |= kChampionAttributeViewport;
-		}
-	}
-
-	if (champAttributes & kChampionAttributeViewport) {
-		warning("MISSGIN CODE: F0097_DUNGEONVIEW_DrawViewport");
-	}
-
-
-T0292042_green:
-	champ->setAttributeFlag((ChampionAttribute)(kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon |
-												kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport |
-												kChampionAttributeActionHand), false);
-	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
-}
-
-uint16 ChampionMan::championIconIndex(int16 val, direction dir) {
-	return ((val + 4 - dir) & 0x3);
-}
-
-}
+#include "champion.h"
+#include "dungeonman.h"
+#include "eventman.h"
+#include "menus.h"
+#include "inventory.h"
+#include "objectman.h"
+#include "text.h"
+
+
+namespace DM {
+
+Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
+Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
+Box gBoxChampionIcons[4] = { // @ G0054_ai_Graphic562_Box_ChampionIcons
+	Box(281, 299,  0, 13),
+	Box(301, 319,  0, 13),
+	Box(301, 319, 15, 28),
+	Box(281, 299, 15, 28)};
+Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; // @ G0046_auc_Graphic562_ChampionColor
+
+uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
+	/* 30 for champion inventory, 8 for chest */
+	0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Action Hand      Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0x0002,   /* Head             Head */
+	0x0008,   /* Torso            Torso */
+	0x0010,   /* Legs             Legs */
+	0x0020,   /* Feet             Feet */
+	0x0100,   /* Pouch 2          Pouch */
+	0x0080,   /* Quiver Line2 1   Quiver 2 */
+	0x0080,   /* Quiver Line1 2   Quiver 2 */
+	0x0080,   /* Quiver Line2 2   Quiver 2 */
+	0x0004,   /* Neck             Neck */
+	0x0100,   /* Pouch 1          Pouch */
+	0x0040,   /* Quiver Line1 1   Quiver 1 */
+	0xFFFF,   /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0x0400,   /* Chest 1          Chest */
+	0x0400,   /* Chest 2          Chest */
+	0x0400,   /* Chest 3          Chest */
+	0x0400,   /* Chest 4          Chest */
+	0x0400,   /* Chest 5          Chest */
+	0x0400,   /* Chest 6          Chest */
+	0x0400,   /* Chest 7          Chest */
+	0x0400}; /* Chest 8          Chest */
+
+Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
+
+ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
+	_leaderIndex = kChampionNone;
+
+	_partyDead = false;
+	_partyIsSleeping = false;
+	_leaderHandObjectIconIndex = kIconIndiceNone;
+	_leaderEmptyHanded = true;
+}
+
+uint16 ChampionMan::getChampionPortraitX(uint16 index) {
+	return ((index) & 0x7) << 5;
+}
+
+uint16 ChampionMan::getChampionPortraitY(uint16 index) {
+	return ((index) >> 3) * 29;
+}
+
+int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) {
+	int val = 0;
+	for (uint16 i = 0; i < characterCount; ++i) {
+		val = (val << 4) + (string[i] - 'A');
+	}
+	return val;
+}
+
+void ChampionMan::drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) {
+	Common::String tmp = getStringFromInteger(currVal, true, 3).c_str();
+	_vm->_textMan->printToViewport(55, posY, kColorLightestGray, tmp.c_str());
+	_vm->_textMan->printToViewport(73, posY, kColorLightestGray, "/");
+	tmp = getStringFromInteger(maxVal, true, 3);
+	_vm->_textMan->printToViewport(79, posY, kColorLightestGray, tmp.c_str());
+}
+
+Common::String ChampionMan::getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) {
+	using namespace Common;
+	String valToStr = String::format("%d", val);
+	String result;
+	for (int16 i = 0, end = paddingCharCount - valToStr.size(); i < end; ++i)
+		result += ' ';
+
+	return result += valToStr;
+}
+
+ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
+	for (uint16 i = 0; i < _partyChampionCount; ++i) {
+		if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
+			return (ChampionIndex)i;
+	}
+
+	return kChampionNone;
+}
+
+void ChampionMan::resetDataToStartGame() {
+	if (!_vm->_dungeonMan->_messages._newGame) {
+		warning("MISSING CODE: stuff for resetting for loaded games");
+		assert(false);
+	}
+
+	_leaderHand = Thing::_thingNone;
+	_leaderHandObjectIconIndex = kIconIndiceNone;
+	_leaderEmptyHanded = true;
+}
+
+
+void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
+	DisplayMan &dispMan = *_vm->_displayMan;
+	DungeonMan &dunMan = *_vm->_dungeonMan;
+
+	if (!_leaderEmptyHanded || _partyChampionCount == 4)
+		return;
+
+	uint16 prevChampCount = _partyChampionCount;
+	Champion *champ = &_champions[prevChampCount];
+	champ->resetToZero();
+	dispMan._useByteBoxCoordinates = true;
+	{ // limit destBox scope
+		Box &destBox = gBoxChampionPortrait;
+		dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex),
+							 champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency);
+	}
+
+	champ->_actionIndex = kChampionActionNone;
+	champ->_enableActionEventIndex = -1;
+	champ->_hideDamageReceivedIndex = -1;
+	champ->_dir = dunMan._currMap._partyDir;
+	ViewCell AL_0_viewCell = kViewCellFronLeft;
+	while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone)
+		AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
+	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3);
+	champ->clearAttributes(kChampionAttributeIcon);
+	champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir;
+	champ->_food = 1500 + _vm->_rnd->getRandomNumber(256);
+	champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
+	int16 AL_0_slotIndex_Red;
+	for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) {
+		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone);
+	}
+	Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY);
+	while (thing.getType() != kTextstringType) {
+		thing = dunMan.getNextThing(thing);
+	}
+	char decodedChampionText[77];
+	char* character_Green = decodedChampionText;
+	dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible));
+	int16 AL_0_characterIndex = 0;
+	uint16 AL_2_character;
+	while ((AL_2_character = *character_Green++) != '\n') {
+		champ->_name[AL_0_characterIndex++] = AL_2_character;
+	}
+	champ->_name[AL_0_characterIndex] = '\0';
+	AL_0_characterIndex = 0;
+	bool AL_4_champTitleCopied = false;
+	for (;;) { // infinite
+		AL_2_character = *character_Green++;
+		if (AL_2_character == '\n') {
+			if (AL_4_champTitleCopied)
+				break;
+			AL_4_champTitleCopied = true;
+		} else {
+			champ->_title[AL_0_characterIndex++] = AL_2_character;
+		}
+	}
+	champ->_title[AL_0_characterIndex] = '\0';
+	if (*character_Green++ == 'M') {
+		champ->setAttributeFlag(kChampionAttributeMale, true);
+	}
+	character_Green++;
+	champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4);
+	character_Green += 4;
+	champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4);
+	character_Green += 4;
+	champ->_currMana = champ->_maxMana = getDecodedValue(character_Green, 4);
+	character_Green += 4;
+	character_Green++;
+
+	int16 AL_0_statisticIndex;
+	for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) {
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30);
+		uint16 currMaxVal = getDecodedValue(character_Green, 2);
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal);
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal);
+		character_Green += 2;
+	}
+
+	champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10);
+	character_Green++;
+
+	int16 AL_0_skillIndex;
+	int16 AL_2_skillValue;
+	for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) {
+		if ((AL_2_skillValue = *character_Green++ - 'A') > 0) {
+			champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue);
+		}
+	}
+
+	for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) {
+		int32 baseSkillExp = 0;
+		int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2;
+		for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) {
+			baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience;
+		}
+		champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp);
+	}
+
+	_candidateChampionOrdinal = prevChampCount + 1;
+	if (++_partyChampionCount == 1) {
+		_vm->_eventMan->commandSetLeader(kChampionFirst);
+		_vm->_menuMan->_shouldRefreshActionArea = true;
+	} else {
+		_vm->_menuMan->clearActingChampion();
+		_vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1));
+	}
+
+	int16 mapX = _vm->_dungeonMan->_currMap._partyPosX;
+	int16 mapY = _vm->_dungeonMan->_currMap._partyPosY;
+
+	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir));
+	mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir];
+	mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir];
+	thing = dunMan.getSquareFirstThing(mapX, mapY);
+	AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
+	uint16 slotIndex_Green;
+	while (thing != Thing::_thingEndOfList) {
+		ThingType AL_2_thingType = thing.getType();
+		if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) {
+			int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots();
+			switch (AL_2_thingType) {
+			case kArmourThingType:
+				for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) {
+					if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
+						goto T0280048;
+				}
+				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
+					slotIndex_Green = kChampionSlotNeck;
+				} else {
+					goto T0280046;
+				}
+				break;
+			case kWeaponThingType:
+				if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) {
+					slotIndex_Green = kChampionSlotActionHand;
+				} else {
+					goto T0280046;
+				}
+				break;
+			case kScrollThingType:
+			case kPotionThingType:
+				if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) {
+					slotIndex_Green = kChampionSlotPouch_1;
+				} else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) {
+					slotIndex_Green = kChampionSlotPouch_2;
+				} else {
+					goto T0280046;
+				}
+				break;
+			case kContainerThingType:
+			case kJunkThingType:
+T0280046:
+				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
+					slotIndex_Green = kChampionSlotNeck;
+				} else {
+					slotIndex_Green = AL_0_slotIndex_Red++;
+				}
+				break;
+			}
+T0280048:
+			if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) {
+				goto T0280046;
+			}
+			warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot");
+		}
+		thing = dunMan.getNextThing(thing);
+	}
+
+	_vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount);
+	_vm->_menuMan->drawDisabledMenu();
+}
+
+void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
+
+	Champion *curChampion = &_champions[champIndex];
+	int16 barGraphIndex = 0;
+	int16 barGraphHeightArray[3];
+
+	if (curChampion->_currHealth > 0) {
+		uint32 barGraphHeight = (((uint32)(curChampion->_currHealth) << 10) * 25) / curChampion->_maxHealth;
+		if (barGraphHeight & 0x3FF) {
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
+		} else {
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
+		}
+	} else {
+		barGraphHeightArray[barGraphIndex++] = 0;
+	}
+
+	if (curChampion->_currStamina > 0) {
+		uint32 barGraphHeight = (((uint32)(curChampion->_currStamina) << 10) * 25) / curChampion->_maxStamina;
+		if (barGraphHeight & 0x3FF) {
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
+		} else {
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
+		}
+	} else {
+		barGraphHeightArray[barGraphIndex++] = 0;
+	}
+
+	if (curChampion->_currMana > 0) {
+		uint32 barGraphHeight = (((uint32)(curChampion->_currMana) << 10) * 25) / curChampion->_maxMana;
+		if (barGraphHeight & 0x3FF) {
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
+		} else {
+			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
+		}
+	} else {
+		barGraphHeightArray[barGraphIndex++] = 0;
+	}
+	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+
+	Box box;
+	box._x1 = champIndex * kChampionStatusBoxSpacing + 46;
+	box._x2 = box._x1 + 3 + 1;
+	box._y1 = 2;
+	box._y2 = 26 + 1;
+
+	for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) {
+		int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex];
+		if (barGraphHeight < 25) {
+			box._y1 = 2;
+			box._y1 = 27 - barGraphHeight + 1;
+			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
+		}
+		if (barGraphHeight) {
+			box._y1 = 27 - barGraphHeight;
+			box._y2 = 26 + 1;
+			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
+		}
+		box._x1 += 7;
+		box._x2 += 7;
+	}
+	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+}
+
+
+uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) {
+	int16 currStamina = champ->_currStamina;
+	int16 halfMaxStamina = champ->_maxStamina / 2;
+	if (currStamina < halfMaxStamina) {
+		warning("Possible undefined behavior in the original code");
+		val /= 2;
+		return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina;
+	}
+	return val;
+}
+
+uint16 ChampionMan::getMaximumLoad(Champion *champ) {
+	uint16 maximumLoad = champ->getStatistic(kChampionStatStrength, kChampionStatCurrent) * 8 + 100;
+	maximumLoad = getStaminaAdjustedValue(champ, maximumLoad);
+	int16 wounds = champ->getWounds();
+	if (wounds) {
+		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kChampionWoundLegs) ? 2 : 3);
+	}
+	if (_vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotFeet)) == kIconIndiceArmourElvenBoots) {
+		maximumLoad += maximumLoad * 16;
+	}
+	maximumLoad += 9;
+	maximumLoad -= maximumLoad % 10;
+	return maximumLoad;
+}
+
+void ChampionMan::drawChampionState(ChampionIndex champIndex) {
+	InventoryMan &invMan = *_vm->_inventoryMan;
+	DisplayMan &dispMan = *_vm->_displayMan;
+	MenuMan &menuMan = *_vm->_menuMan;
+	EventManager &eventMan = *_vm->_eventMan;
+
+	Box box;
+	int16 champStatusBoxX = champIndex * kChampionStatusBoxSpacing;
+	Champion *champ = &_champions[champIndex];
+	uint16 champAttributes = champ->getAttributes();
+	if (!((champAttributes) & (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon |
+							   kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport |
+							   kChampionAttributeActionHand))) {
+		return;
+	}
+	bool isInventoryChamp = (indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
+	dispMan._useByteBoxCoordinates = false;
+	if (champAttributes & kChampionAttributeStatusBox) {
+		box._y1 = 0;
+		box._y2 = 28 + 1;
+		box._x1 = champStatusBoxX;
+		box._x2 = box._x1 + 66 + 1;
+		if (champ->_currHealth) {
+			dispMan.clearScreenBox(kColorDarkestGray, box);
+			int16 nativeBitmapIndices[3];
+			for (int16 i = 0; i < 3; ++i)
+				nativeBitmapIndices[i] = 0;
+			int16 AL_0_borderCount = 0;
+			if (_party._fireShieldDefense > 0)
+				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyFireshieldIndice;
+			if (_party._spellShieldDefense > 0)
+				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartySpellshieldIndice;
+			if (_party._shieldDefense > 0)
+				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyShieldIndice;
+			while (AL_0_borderCount--) {
+				dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, kColorFlesh);
+			}
+			if (isInventoryChamp) {
+				invMan.drawStatusBoxPortrait(champIndex);
+				champAttributes |= kChampionAttributeStatistics;
+			} else {
+				champAttributes |= (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeWounds | kChampionAttributeActionHand);
+			}
+		} else {
+			dispMan.blitToScreen(dispMan.getBitmap(kStatusBoxDeadChampion), 80, 0, 0, box, kColorNoTransparency);
+			_vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, kColorLightestGray, kColorDarkGary, champ->_name);
+			menuMan.drawActionIcon(champIndex);
+			goto T0292042_green;
+		}
+	}
+
+	if (!champ->_currHealth)
+		goto T0292042_green;
+
+	if (champAttributes & kChampionAttributeNameTitle) {
+		Color AL_0_colorIndex = (champIndex == _leaderIndex) ? kColorGold : kColorLightestGray; // unused because of missing functions
+		if (isInventoryChamp) {
+			char *champName = champ->_name;
+			_vm->_textMan->printToViewport(3, 7, AL_0_colorIndex, champName);
+			int16 champTitleX = 6 * strlen(champName) + 3;
+			char champTitleFirstChar = champ->_title[0];
+			if ((champTitleFirstChar != ',') && (champTitleFirstChar != ';') && (champTitleFirstChar != '-')) {
+				champTitleX += 6;
+			}
+			_vm->_textMan->printToViewport(champTitleX, 7, AL_0_colorIndex, champ->_title);
+			champAttributes |= kChampionAttributeViewport;
+		} else {
+			box._y1 = 0;
+			box._y2 = 6 + 1;
+			box._x1 = champStatusBoxX;
+			box._x2 = box._x1 + 42 + 1;
+			dispMan.clearScreenBox(kColorDarkGary, box);
+			_vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, kColorDarkGary, champ->_name);
+		}
+	}
+
+	if (champAttributes & kChampionAttributeStatistics) {
+		drawChampionBarGraphs(champIndex);
+		if (isInventoryChamp) {
+			drawHealthStaminaManaValues(champ);
+			int16 AL_2_nativeBitmapIndex;
+			if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) {
+				AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice;
+			} else {
+				AL_2_nativeBitmapIndex = kSlotBoxNormalIndice;
+			}
+			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, kColorDarkestGray, gDungeonViewport);
+			AL_2_nativeBitmapIndex = kSlotBoxNormalIndice;
+			for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) {
+				if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent)
+					< champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum)) {
+					AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice;
+					break;
+				}
+			}
+			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, kColorDarkestGray, gDungeonViewport);
+			champAttributes |= kChampionAttributeViewport;
+		}
+	}
+
+	if (champAttributes & kChampionAttributeWounds) {
+		for (int16 AL_0_slotIndex = isInventoryChamp ? kChampionSlotFeet : kChampionSlotActionHand; AL_0_slotIndex >= kChampionSlotReadyHand; AL_0_slotIndex--) {
+			warning("MISSING CODE: F0291_CHAMPION_DrawSlot");
+		}
+		if (isInventoryChamp) {
+			champAttributes |= kChampionAttributeViewport;
+		}
+	}
+
+	if (champAttributes & kChampionAttributeLoad) {
+		warning("MISSING CODE: whole if branch, many F0052_TEXT_PrintToViewport-s");
+
+
+
+		champAttributes |= kChampionAttributeViewport;
+	}
+
+	{ // block so goto won't skip AL_0_championIconIndex initialization 
+		int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir);
+
+		if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != indexToOrdinal(AL_0_championIconIndex))) {
+			dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]);
+			dispMan.blitToScreen(dispMan.getBitmap(kChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0,
+								 gBoxChampionIcons[AL_0_championIconIndex], kColorDarkestGray);
+		}
+	}
+
+	if ((champAttributes & kChampionAttributePanel) && isInventoryChamp) {
+		if (_vm->_pressingMouth) {
+			invMan.drawPanelFoodWaterPoisoned();
+		} else if (_vm->_pressingEye) {
+			if (_leaderEmptyHanded) {
+				warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics");
+			}
+		} else {
+			invMan.drawPanel();
+		}
+		champAttributes |= kChampionAttributeViewport;
+	}
+
+	if (champAttributes & kChampionAttributeActionHand) {
+		warning("MISSING CODE: F0291_CHAMPION_DrawSlot");
+		menuMan.drawActionIcon(champIndex);
+		if (isInventoryChamp) {
+			champAttributes |= kChampionAttributeViewport;
+		}
+	}
+
+	if (champAttributes & kChampionAttributeViewport) {
+		warning("MISSGIN CODE: F0097_DUNGEONVIEW_DrawViewport");
+	}
+
+
+T0292042_green:
+	champ->setAttributeFlag((ChampionAttribute)(kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon |
+												kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport |
+												kChampionAttributeActionHand), false);
+	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+}
+
+uint16 ChampionMan::championIconIndex(int16 val, direction dir) {
+	return ((val + 4 - dir) & 0x3);
+}
+
+void ChampionMan::drawHealthStaminaManaValues(Champion* champ) {
+	drawHealthOrStaminaOrManaValue(116, champ->_currHealth, champ->_maxHealth);
+	drawHealthOrStaminaOrManaValue(124, champ->_currStamina, champ->_maxStamina);
+	drawHealthOrStaminaOrManaValue(132, champ->_currMana, champ->_maxMana);
+}
+
+}
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 4e9e29d..4cc32c5 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -1,6 +1,8 @@
 #ifndef DM_CHAMPION_H
 #define DM_CHAMPION_H
 
+#include "common/str.h"
+
 #include "dm.h"
 #include "gfx.h"
 
@@ -390,6 +392,8 @@ class ChampionMan {
 
 	ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell
 	int16 getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue
+	void drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue
+	Common::String getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger
 public:
 	Champion _champions[4];
 	uint16 _partyChampionCount;	// @ G0305_ui_PartyChampionCount
@@ -411,6 +415,7 @@ public:
 	uint16 getMaximumLoad(Champion *champ); // @ F0309_CHAMPION_GetMaximumLoad
 	void drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState
 	uint16 championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX
+	void drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues
 };
 
 
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index bbf0c7d..6ff8b7a 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1,5 +1,6 @@
 #include "common/file.h"
 #include "common/memstream.h"
+
 #include "dungeonman.h"
 
 
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index c5c356e..59e1a82 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -2,7 +2,6 @@
 #define DUNGEONMAN_H
 
 #include "dm.h"
-#include "dungeonman.h"
 #include "gfx.h"
 
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index e2713a2..18aaebe 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -544,9 +544,9 @@ byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110,
 
 
 
-Viewport gDefultViewPort = {0, 0};
+Viewport gDefultViewPort = {0, 0, 320, 200};
 // TODO: I guessed the numbers
-Viewport gDungeonViewport = {0, 33}; // @ G0296_puc_Bitmap_Viewport
+Viewport gDungeonViewport = {0, 33, 224, 126}; // @ G0296_puc_Bitmap_Viewport
 
 byte gPalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges
 
@@ -684,7 +684,7 @@ void DisplayMan::unpackGraphics() {
 		unpackedBitmapsSize += getWidth(i) * getHeight(i);
 	for (uint16 i = 22; i <= 532; ++i)
 		unpackedBitmapsSize += getWidth(i) * getHeight(i);
-	unpackedBitmapsSize += (5 + 1) * (6 + 1) * 128; // 5 x 6 characters, 128 of them, +1 for convenience padding
+	unpackedBitmapsSize += (5 + 1) * 6 * 128; // 5 x 6 characters, 128 of them, +1 for convenience padding
 	// graphics items go from 0-20 and 22-532 inclusive, _unpackedItemPos 21 and 22 are there for indexing convenience
 	if (_bitmaps) {
 		delete[] _bitmaps[0];
@@ -719,8 +719,6 @@ void DisplayMan::loadFNT1intoBitmap(uint16 index, byte* destBitmap)
 			}
 		}
 	}
-	memset(data, 0, 128);
-	data += 128;
 }
 
 void DisplayMan::loadPalette(uint16 *palette) {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index e2f30f3..ed246de 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -7,6 +7,7 @@
 
 namespace DM {
 
+
 enum ViewCell {
 	kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT
 	kViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT
@@ -144,9 +145,10 @@ enum Color {
 	kColorWhite = 15
 };
 
+
 struct Viewport {
-	// TODO: should probably add width and height, seems redundant right meow
 	uint16 _posX, _posY;
+	uint16 _width, _height;
 };
 
 struct CreatureAspect {
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index a67d308..271fd3b 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -3,6 +3,7 @@
 #include "eventman.h"
 #include "menus.h"
 #include "gfx.h"
+#include "text.h"
 
 
 
@@ -68,9 +69,9 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	if (cm._candidateChampionOrdinal) {
 		dm.clearScreenBox(kColorDarkestGray, gBoxFloppyZzzCross, gDungeonViewport);
 	}
-	warning("MISSING CODE: F0052_TEXT_PrintToViewport -> HEALTH");
-	warning("MISSING CODE: F0052_TEXT_PrintToViewport -> STAMINA");
-	warning("MISSING CODE: F0052_TEXT_PrintToViewport -> MANA");
+	_vm->_textMan->printToViewport(5, 116, kColorLightestGray, "HEALTH");
+	_vm->_textMan->printToViewport(5, 124, kColorLightestGray, "STAMINA");
+	_vm->_textMan->printToViewport(5, 132, kColorLightestGray, "MANA");
 
 	warning("MISSING CODE: F0291_CHAMPION_DrawSlot in LOOOOOOOOOOOOP");
 
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index d6d005f..5ad2ac7 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -8,36 +8,42 @@ TextMan::TextMan(DMEngine* vm) : _vm(vm) {}
 #define kLetterWidth 5
 #define kLetterHeight 6
 
-void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, Color textColor, Color bgColor, char* text, uint16 destHeight, Viewport &viewport) {
+void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY,
+								Color textColor, Color bgColor, const char* text, uint16 destHeight, Viewport &viewport) {
+	destX -= 1; // fixes missalignment, to be checked
+	destY -= 4; // fixes missalignment, to be checked
+
 	uint16 textLength = strlen(text);
 	uint16 nextX = destX;
 	uint16 nextY = destY;
 	byte *srcBitmap = _vm->_displayMan->getBitmap(kFontGraphicIndice);
 
 	byte *tmp = _vm->_displayMan->_tmpBitmap;
-	for (uint16 i = 0; i < (kLetterWidth + 1) * (kLetterHeight + 1) * 128; ++i) {
+	for (uint16 i = 0; i < (kLetterWidth + 1) * kLetterHeight * 128; ++i) {
 		tmp[i] = srcBitmap[i] ? textColor : bgColor;
 	}
 	srcBitmap = tmp;
 
-
-	for (char *begin = text, *end = text + textLength; begin != end; ++begin) {
-		// Note: this does no wraps in the middle of words
-		if (nextX + kLetterWidth + 1 > destPixelWidth || (*begin == '\n')) {
+	for (const char *begin = text, *end = text + textLength; begin != end; ++begin) {
+		if (nextX + kLetterWidth + 1 >= (viewport._posX + viewport._width) || (*begin == '\n')) {
 			nextX = destX;
 			nextY += kLetterHeight + 1;
 		}
-		if (nextY + kLetterHeight + 1 > destHeight)
+		if (nextY + kLetterHeight >= (viewport._posY + viewport._height))
 			break;
 		uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
-		_vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, srcX, 0, destBitmap, destPixelWidth,
-									   nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight + 1, kColorNoTransparency, viewport);
+		_vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth,
+									   (nextX == destX) ? (nextX + 1) : nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight, kColorNoTransparency, viewport);
 		nextX += kLetterWidth + 1;
 	}
 }
 
-void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, char* text, Viewport &viewport) {
+void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text, Viewport &viewport) {
 	printTextToBitmap(_vm->_displayMan->_vgaBuffer, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight, viewport);
 }
 
+void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text) {
+	printTextToScreen(posX, posY, textColor, kColorDarkestGray, text, gDungeonViewport);
+}
+
 }
diff --git a/engines/dm/text.h b/engines/dm/text.h
index 7f57525..baf9b72 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -11,8 +11,9 @@ class TextMan {
 public:
 	TextMan(DMEngine *vm);
 	void printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY,
-						   Color textColor, Color bgColor, char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print
-	void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, char *text, Viewport &viewport = gDefultViewPort); 
+						   Color textColor, Color bgColor, const char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print
+	void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, Viewport &viewport = gDefultViewPort); // @ F0053_TEXT_PrintToLogicalScreen
+	void printToViewport(int16 posX, int16 posY, Color textColor, const char *text); // @ F0052_TEXT_PrintToViewport
 };
 
 }


Commit: a72bfe712da048fce3f32375826cd5724c6f9508
    https://github.com/scummvm/scummvm/commit/a72bfe712da048fce3f32375826cd5724c6f9508
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix link

Changed paths:
    engines/dm/module.mk



diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index 3a7fa10..bc36e8b 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -10,7 +10,8 @@ MODULE_OBJS := \
 	champion.o \
 	loadsave.o \
 	objectman.o \
-	inventory.o
+	inventory.o \
+	text.o
 
 MODULE_DIRS += \
 	engines/dm


Commit: 0ad91dfe6723e04271cbb44e7ccbce3071e1af6a
    https://github.com/scummvm/scummvm/commit/0ad91dfe6723e04271cbb44e7ccbce3071e1af6a
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing explicit keyword

Changed paths:
    engines/dm/text.h



diff --git a/engines/dm/text.h b/engines/dm/text.h
index baf9b72..d273de3 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -9,7 +9,7 @@ namespace DM {
 class TextMan {
 	DMEngine *_vm;
 public:
-	TextMan(DMEngine *vm);
+	explicit TextMan(DMEngine *vm);
 	void printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY,
 						   Color textColor, Color bgColor, const char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print
 	void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, Viewport &viewport = gDefultViewPort); // @ F0053_TEXT_PrintToLogicalScreen


Commit: 8ffd4a0bad2015af360d0949f5f12a02f5b93c1d
    https://github.com/scummvm/scummvm/commit/8ffd4a0bad2015af360d0949f5f12a02f5b93c1d
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add some default statements in switches, change the scope of namespace DM in gfx.cpp

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 18aaebe..f430a6f 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -558,9 +558,7 @@ byte gAlcoveOrnIndices[kAlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrna
 	1,   /* Square Alcove */
 	2,   /* Vi Altar */
 	3};  /* Arched Alcove */
-}
 
-using namespace DM;
 
 DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_vgaBuffer = nullptr;
@@ -805,13 +803,14 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight
 }
 
 void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) {
-	for (uint16 y = 0; y < height; ++y)
+	for (uint16 y = 0; y < height; ++y) {
 		for (uint16 x = 0; x < width / 2; ++x) {
 			byte tmp;
 			tmp = bitmap[y*width + x];
 			bitmap[y*width + x] = bitmap[y*width + width - 1 - x];
 			bitmap[y*width + width - 1 - x] = tmp;
 		}
+	}
 }
 
 void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) {
@@ -875,6 +874,8 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
 			// ... missing code
 		}
 		break;
+	default:
+		break;
 	}
 }
 
@@ -895,6 +896,8 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
 			// ... missing code
 		}
 		break;
+	default:
+		break;
 	}
 }
 void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) {
@@ -913,6 +916,8 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) {
 			//... missing code
 		}
 		break;
+	default:
+		break;
 	}
 }
 void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) {
@@ -935,6 +940,8 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) {
 	case kStairsSideElemType:
 		drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2L]);
 		break;
+	default:
+		break;
 	}
 }
 void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) {
@@ -957,6 +964,8 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) {
 	case kStairsSideElemType:
 		drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]);
 		break;
+	default:
+		break;
 	}
 }
 void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) {
@@ -975,6 +984,8 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) {
 			// ... missing code
 		}
 		break;
+	default:
+		break;
 	}
 }
 void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) {
@@ -997,6 +1008,8 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) {
 		else
 			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1L]);
 		break;
+	default:
+		break;
 	}
 }
 void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) {
@@ -1019,6 +1032,8 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) {
 		else
 			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1R]);
 		break;
+	default:
+		break;
 	}
 }
 void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) {
@@ -1040,6 +1055,8 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) {
 			// .... code not yet implemneted
 		}
 		break;
+	default:
+		break;
 	}
 }
 
@@ -1054,6 +1071,8 @@ void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) {
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]);
 		break;
+	default:
+		break;
 	}
 }
 
@@ -1068,6 +1087,8 @@ void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) {
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D0R], gFrameWalls[kViewSquare_D0R]);
 		break;
+	default:
+		break;
 	}
 }
 
@@ -1084,6 +1105,8 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) {
 			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0R]);
 		}
 		break;
+	default:
+		break;
 	}
 }
 
@@ -1531,3 +1554,5 @@ void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uin
 				  Color transparent, Viewport &viewport) {
 	blitToScreen(srcBitmap, srcWidth, srcX, srcY, box._x1, box._x2, box._y1, box._y2, transparent, viewport);
 }
+
+}


Commit: 2f6e8a8e64ac2e5bc641532f0dd2ff10915cc469
    https://github.com/scummvm/scummvm/commit/2f6e8a8e64ac2e5bc641532f0dd2ff10915cc469
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add G0030_as_Graphic562_SlotBoxes, SLOT_BOX, F0038_OBJECT_DrawIconInSlotBox

Changed paths:
    engines/dm/objectman.cpp
    engines/dm/objectman.h



diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index c237b91..87d6992 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -4,6 +4,55 @@
 
 namespace DM {
 
+SlotBox gSlotBoxes[46] = { 
+/* 8 for champion hands in status boxes, 30 for champion inventory, 8 for chest */
+	SlotBox(4,  10, 0), /* Champion Status Box 0 Ready Hand */
+	SlotBox(24,  10, 0), /* Champion Status Box 0 Action Hand */
+	SlotBox(73,  10, 0), /* Champion Status Box 1 Ready Hand */
+	SlotBox(93,  10, 0), /* Champion Status Box 1 Action Hand */
+	SlotBox(142,  10, 0), /* Champion Status Box 2 Ready Hand */
+	SlotBox(162,  10, 0), /* Champion Status Box 2 Action Hand */
+	SlotBox(211,  10, 0), /* Champion Status Box 3 Ready Hand */
+	SlotBox(231,  10, 0), /* Champion Status Box 3 Action Hand */
+	SlotBox(6,  53, 0), /* Ready Hand */
+	SlotBox(62,  53, 0), /* Action Hand */
+	SlotBox(34,  26, 0), /* Head */
+	SlotBox(34,  46, 0), /* Torso */
+	SlotBox(34,  66, 0), /* Legs */
+	SlotBox(34,  86, 0), /* Feet */
+	SlotBox(6,  90, 0), /* Pouch 2 */
+	SlotBox(79,  73, 0), /* Quiver Line2 1 */
+	SlotBox(62,  90, 0), /* Quiver Line1 2 */
+	SlotBox(79,  90, 0), /* Quiver Line2 2 */
+	SlotBox(6,  33, 0), /* Neck */
+	SlotBox(6,  73, 0), /* Pouch 1 */
+	SlotBox(62,  73, 0), /* Quiver Line1 1 */
+	SlotBox(66,  33, 0), /* Backpack Line1 1 */
+	SlotBox(83,  16, 0), /* Backpack Line2 2 */
+	SlotBox(100,  16, 0), /* Backpack Line2 3 */
+	SlotBox(117,  16, 0), /* Backpack Line2 4 */
+	SlotBox(134,  16, 0), /* Backpack Line2 5 */
+	SlotBox(151,  16, 0), /* Backpack Line2 6 */
+	SlotBox(168,  16, 0), /* Backpack Line2 7 */
+	SlotBox(185,  16, 0), /* Backpack Line2 8 */
+	SlotBox(202,  16, 0), /* Backpack Line2 9 */
+	SlotBox(83,  33, 0), /* Backpack Line1 2 */
+	SlotBox(100,  33, 0), /* Backpack Line1 3 */
+	SlotBox(117,  33, 0), /* Backpack Line1 4 */
+	SlotBox(134,  33, 0), /* Backpack Line1 5 */
+	SlotBox(151,  33, 0), /* Backpack Line1 6 */
+	SlotBox(168,  33, 0), /* Backpack Line1 7 */
+	SlotBox(185,  33, 0), /* Backpack Line1 8 */
+	SlotBox(202,  33, 0), /* Backpack Line1 9 */
+	SlotBox(117,  59, 0), /* Chest 1 */
+	SlotBox(106,  76, 0), /* Chest 2 */
+	SlotBox(111,  93, 0), /* Chest 3 */
+	SlotBox(128,  98, 0), /* Chest 4 */
+	SlotBox(145, 101, 0), /* Chest 5 */
+	SlotBox(162, 103, 0), /* Chest 6 */
+	SlotBox(179, 104, 0), /* Chest 7 */
+	SlotBox(196, 105, 0)}; /* Chest 8 */
+
 int16 gIconGraphicHeight[7] = {32, 32, 32, 32, 32, 32, 32}; // @ K0077_ai_IconGraphicHeight
 
 int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex
@@ -34,7 +83,7 @@ IconIndice ObjectMan::getIconIndex(Thing thing) {
 	IconIndice iconIndex = getObjectType(thing);
 
 	if ((iconIndex != kIconIndiceNone) &&
-		((iconIndex < kIconIndiceWeaponDagger) &&(iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error
+		((iconIndex < kIconIndiceWeaponDagger) && (iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error
 		((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) ||
 		(iconIndex == kIconIndicePotionEmptyFlask)
 		) {
@@ -91,4 +140,34 @@ void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 
 }
 
-}
\ No newline at end of file
+void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
+	SlotBox *slotBox = &gSlotBoxes[slotBoxIndex];
+	slotBox->_iconIndex = iconIndex; // yes, this modifies the global array
+	if (slotBox->_iconIndex == kIconIndiceNone) {
+		return;
+	}
+	Box box;
+	box._x1 = slotBox->_x;
+	box._y1 = slotBox->_y;
+	box._x2 = box._x1 + 15; // no need to add +1, comes from a global array 
+	box._y2 = box._y1 + 15; // no need to add +1, comes from a global array
+	
+	uint16 iconGraphicIndex;
+	for (iconGraphicIndex = 0; iconGraphicIndex < 7; ++iconGraphicIndex) {
+		if (gIconGraphicFirstIndex[iconGraphicIndex] > iconIndex) {
+			break;
+		}
+	}
+	iconGraphicIndex--;
+	byte *iconsBitmap = _vm->_displayMan->getBitmap(iconGraphicIndex + kObjectIcons_000_TO_031);
+	iconIndex -= gIconGraphicFirstIndex[iconGraphicIndex];
+
+	_vm->_displayMan->_useByteBoxCoordinates = false;
+	if (slotBoxIndex >= kSlotBoxInventoryFirstSlot) {
+		_vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, box, kColorNoTransparency, gDungeonViewport);
+	} else {
+		_vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, box, kColorNoTransparency, gDefultViewPort);
+	}
+}
+
+}
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index dd0150d..fd0f5a1 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -4,6 +4,20 @@
 
 namespace DM {
 
+#define kSlotBoxInventoryFirstSlot 8 // @ C08_SLOT_BOX_INVENTORY_FIRST_SLOT   
+#define kSlotBoxInventoryActionHand 9 // @ C09_SLOT_BOX_INVENTORY_ACTION_HAND  
+#define kSlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT      
+
+class SlotBox {
+public:
+	int16 _x;
+	int16 _y;
+	int16 _iconIndex;
+	SlotBox(int16 x, int16 y, int16 iconIndex): _x(x), _y(y), _iconIndex(iconIndex) {}
+}; // @ SLOT_BOX
+
+extern SlotBox gSlotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes;
+
 class ObjectMan {
 	DMEngine *_vm;
 public:
@@ -12,6 +26,7 @@ public:
 	IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType
 	IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
 	void extractIconFromBitmap(uint16 iconIndex, byte *srcBitmap); // F0036_OBJECT_ExtractIconFromBitmap
+	void drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox
 };
 
 }


Commit: 94bd6db7a61af0d5552f86eac06c785a027041bc
    https://github.com/scummvm/scummvm/commit/94bd6db7a61af0d5552f86eac06c785a027041bc
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add  F0291_CHAMPION_DrawSlot, G0425_aT_ChestSlots and constructor to Viewport, swap some warnings for code

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/objectman.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 79f4267..2899f90 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -492,7 +492,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 
 	if (champAttributes & kChampionAttributeWounds) {
 		for (int16 AL_0_slotIndex = isInventoryChamp ? kChampionSlotFeet : kChampionSlotActionHand; AL_0_slotIndex >= kChampionSlotReadyHand; AL_0_slotIndex--) {
-			warning("MISSING CODE: F0291_CHAMPION_DrawSlot");
+			drawSlot(champIndex, (ChampionSlot)AL_0_slotIndex);
 		}
 		if (isInventoryChamp) {
 			champAttributes |= kChampionAttributeViewport;
@@ -531,7 +531,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	}
 
 	if (champAttributes & kChampionAttributeActionHand) {
-		warning("MISSING CODE: F0291_CHAMPION_DrawSlot");
+		drawSlot(champIndex, kChampionSlotActionHand);
 		menuMan.drawActionIcon(champIndex);
 		if (isInventoryChamp) {
 			champAttributes |= kChampionAttributeViewport;
@@ -560,4 +560,91 @@ void ChampionMan::drawHealthStaminaManaValues(Champion* champ) {
 	drawHealthOrStaminaOrManaValue(132, champ->_currMana, champ->_maxMana);
 }
 
+void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
+	int16 nativeBitmapIndex = -1;
+	Champion *champ = &_champions[champIndex];
+	bool isInventoryChamp = (_vm->_inventoryMan->_inventoryChampionOrdinal == indexToOrdinal(champIndex));
+
+	uint16 slotBoxIndex;
+	if (!isInventoryChamp) {  /* If drawing a slot for a champion other than the champion whose inventory is open */
+		if ((slotIndex > kChampionSlotActionHand) || (_candidateChampionOrdinal == indexToOrdinal(champIndex))) {
+			return;
+		}
+		slotBoxIndex = (champIndex << 1) + slotIndex;
+	} else {
+		slotBoxIndex = kSlotBoxInventoryFirstSlot + slotIndex;
+	}
+
+	Thing thing;
+	if (slotIndex >= kChampionSlotChest_1) {
+		thing = _vm->_inventoryMan->_chestSlots[slotIndex - kChampionSlotChest_1];
+	} else {
+		thing = champ->getSlot(slotIndex);
+	}
+
+	SlotBox *slotBox = &gSlotBoxes[slotBoxIndex];
+	Box box;
+	box._x1 = slotBox->_x - 1;
+	box._y1 = slotBox->_y - 1;
+	box._x2 = box._x1 + 17 + 1;
+	box._y2 = box._y1 + 17 + 1;
+
+
+	if (!isInventoryChamp) {
+		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+	}
+
+	int16 iconIndex;
+	if (thing == Thing::_thingNone) {
+		if (slotIndex <= kChampionSlotFeet) {
+			iconIndex = kIconIndiceReadyHand + (slotIndex << 1);
+			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) {
+				iconIndex++;
+				nativeBitmapIndex = kSlotBoxWoundedIndice;
+			} else {
+				nativeBitmapIndex = kSlotBoxNormalIndice;
+			}
+		} else {
+			if ((slotIndex >= kChampionSlotNeck) && (slotIndex <= kChampionSlotBackpackLine_1_1)) {
+				iconIndex = kIconIndiceNeck + (slotIndex - kChampionSlotNeck);
+			} else {
+				iconIndex = kIconIndiceEmptyBox;
+			}
+		}
+	} else {
+		warning("BUG0_35");
+		iconIndex = _vm->_objectMan->getIconIndex(thing); // BUG0_35
+		if (isInventoryChamp && (slotIndex == kChampionSlotActionHand) && ((iconIndex == kIconIndiceContainerChestClosed) || (iconIndex == kIconIndiceScrollOpen))) {
+			warning("BUG2_00");
+			iconIndex++;
+		} // BUG2_00
+		if (slotIndex <= kChampionSlotFeet) {
+			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) {
+				nativeBitmapIndex = kSlotBoxWoundedIndice;
+			} else {
+				nativeBitmapIndex = kSlotBoxNormalIndice;
+			}
+		}
+	}
+
+	if ((slotIndex == kChampionSlotActionHand) && (indexToOrdinal(champIndex) == _actingChampionOrdinal)) {
+		nativeBitmapIndex = kSlotBoxActingHandIndice;
+	}
+
+	if (nativeBitmapIndex != -1) {
+		_vm->_displayMan->_useByteBoxCoordinates = false;
+		_vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0,
+									   box, kColorDarkestGray, isInventoryChamp ? gDungeonViewport : gDefultViewPort);
+	}
+
+	_vm->_objectMan->drawIconInSlotBox(slotBoxIndex, iconIndex);
+
+	if (!isInventoryChamp) {
+		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+	}
 }
+
+
+}
+
+
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 4cc32c5..2b2aaf9 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -416,6 +416,7 @@ public:
 	void drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState
 	uint16 championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX
 	void drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues
+	void drawSlot(uint16 champIndex, ChampionSlot slotIndex); // @ F0291_CHAMPION_DrawSlot
 };
 
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index f430a6f..8c38f4b 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -544,9 +544,9 @@ byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110,
 
 
 
-Viewport gDefultViewPort = {0, 0, 320, 200};
+Viewport gDefultViewPort(0, 0, 320, 200);
 // TODO: I guessed the numbers
-Viewport gDungeonViewport = {0, 33, 224, 126}; // @ G0296_puc_Bitmap_Viewport
+Viewport gDungeonViewport(0, 33, 224, 126); // @ G0296_puc_Bitmap_Viewport
 
 byte gPalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index ed246de..5e0307e 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -42,7 +42,8 @@ enum GraphicIndice {
 	kSlotBoxNormalIndice = 33, // @ C033_GRAPHIC_SLOT_BOX_NORMAL                   
 	kSlotBoxWoundedIndice = 34, // @ C034_GRAPHIC_SLOT_BOX_WOUNDED                  
 	kChampionIcons = 28, // @ C028_GRAPHIC_CHAMPION_ICONS
-	kFontGraphicIndice = 557 // @ C557_GRAPHIC_FONT 
+	kFontGraphicIndice = 557, // @ C557_GRAPHIC_FONT 
+	kSlotBoxActingHandIndice = 35 // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND
 };
 
 extern uint16 gPalSwoosh[16];
@@ -146,9 +147,13 @@ enum Color {
 };
 
 
-struct Viewport {
+class Viewport {
+public:
 	uint16 _posX, _posY;
 	uint16 _width, _height;
+	Viewport() {}
+	Viewport(uint16 posX, uint16 posY, uint16 width, uint16 height)
+		:_posX(posX), _posY(posY), _width(width), _height(height) {}
 };
 
 struct CreatureAspect {
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 271fd3b..31b495c 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -17,6 +17,8 @@ Box gBoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
 
 InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
 	_panelContent = kPanelContentFoodWaterPoisoned;
+	for (uint16 i = 0; i < 8; ++i)
+		_chestSlots[i] = Thing::_thingNone;
 }
 
 void InventoryMan::toggleInventory(ChampionIndex championIndex) {
@@ -73,7 +75,9 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	_vm->_textMan->printToViewport(5, 124, kColorLightestGray, "STAMINA");
 	_vm->_textMan->printToViewport(5, 132, kColorLightestGray, "MANA");
 
-	warning("MISSING CODE: F0291_CHAMPION_DrawSlot in LOOOOOOOOOOOOP");
+	for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) {
+		_vm->_championMan->drawSlot(championIndex, (ChampionSlot)slotIndex);
+	}
 
 	champion->setAttributeFlag(kChampionAttributeViewport, true);
 	champion->setAttributeFlag(kChampionAttributeStatusBox, true);
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index b8fbe51..45bc3e9 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -25,6 +25,7 @@ public:
 
 	int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal
 	PanelContent _panelContent; // @ G0424_i_PanelContent 
+	Thing _chestSlots[8]; // @ G0425_aT_ChestSlots
 
 	void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE
 	void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 87d6992..96f9579 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -149,8 +149,8 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 	Box box;
 	box._x1 = slotBox->_x;
 	box._y1 = slotBox->_y;
-	box._x2 = box._x1 + 15; // no need to add +1, comes from a global array 
-	box._y2 = box._y1 + 15; // no need to add +1, comes from a global array
+	box._x2 = box._x1 + 15 + 1; 
+	box._y2 = box._y1 + 15 + 1;
 	
 	uint16 iconGraphicIndex;
 	for (iconGraphicIndex = 0; iconGraphicIndex < 7; ++iconGraphicIndex) {
@@ -164,9 +164,11 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 
 	_vm->_displayMan->_useByteBoxCoordinates = false;
 	if (slotBoxIndex >= kSlotBoxInventoryFirstSlot) {
-		_vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, box, kColorNoTransparency, gDungeonViewport);
+		_vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
+									   box, kColorNoTransparency, gDungeonViewport);
 	} else {
-		_vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, box, kColorNoTransparency, gDefultViewPort);
+		_vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
+									   box, kColorNoTransparency, gDefultViewPort);
 	}
 }
 


Commit: 23e0dfcc282a27ff16ba2891971de5ea5fe336c9
    https://github.com/scummvm/scummvm/commit/23e0dfcc282a27ff16ba2891971de5ea5fe336c9
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add standard GPLv2 header

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/configure.engine
    engines/dm/detection.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/loadsave.cpp
    engines/dm/loadsave.h
    engines/dm/menus.cpp
    engines/dm/menus.h
    engines/dm/module.mk
    engines/dm/objectman.cpp
    engines/dm/objectman.h
    engines/dm/text.cpp
    engines/dm/text.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 2899f90..28f477c 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #include "champion.h"
 #include "dungeonman.h"
 #include "eventman.h"
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 2b2aaf9..0610f29 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #ifndef DM_CHAMPION_H
 #define DM_CHAMPION_H
 
diff --git a/engines/dm/configure.engine b/engines/dm/configure.engine
index 50a3d99..476044a 100644
--- a/engines/dm/configure.engine
+++ b/engines/dm/configure.engine
@@ -1,3 +1,31 @@
+# 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.
+#
+#
+#
+#
+# Based on the Reverse Engineering work of Christophe Fontanel,
+# maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+#
+
+
 # This file is included from the main "configure" script
 # add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
 add_engine dm "Dungeon Master" yes
diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp
index 855d128..1d31a74 100644
--- a/engines/dm/detection.cpp
+++ b/engines/dm/detection.cpp
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #include "dm/dm.h"
 
 #include "common/config-manager.h"
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 61810e8..c8b02e9 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #include "common/scummsys.h"
 #include "common/system.h"
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 61583a3..430c7d3 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #ifndef DM_H
 #define DM_H
 
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 6ff8b7a..0041307 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #include "common/file.h"
 #include "common/memstream.h"
 
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 59e1a82..1ccb1d2 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #ifndef DUNGEONMAN_H
 #define DUNGEONMAN_H
 
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index b593729..fd7f907 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #include "common/system.h"
 #include "graphics/cursorman.h"
 
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 4b62677..bbf0b66 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #ifndef DM_EVENTMAN_H
 #define DM_EVENTMAN_H
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 8c38f4b..14324bd 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #include "engines/util.h"
 #include "common/system.h"
 #include "common/file.h"
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 5e0307e..11679ef 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #ifndef GFX_H
 #define GFX_H
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 31b495c..7dd1b00 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #include "inventory.h"
 #include "dungeonman.h"
 #include "eventman.h"
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 45bc3e9..6c34e2a 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #include "dm.h"
 #include "gfx.h"
 #include "champion.h"
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 1a07ae2..0251e8b 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #include "loadsave.h"
 #include "dungeonman.h"
 #include "champion.h"
diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h
index abedf54..71043a2 100644
--- a/engines/dm/loadsave.h
+++ b/engines/dm/loadsave.h
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #ifndef DM_LOADSAVE_H
 #define DM_LOADSAVE_H
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index b346464..7b971e5 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -1,94 +1,121 @@
-#include "menus.h"
-#include "gfx.h"
-#include "champion.h"
-#include "dungeonman.h"
-#include "objectman.h"
-#include "inventory.h"
-
-
-namespace DM {
-
-byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
-
-MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
-	_shouldRefreshActionArea = false;
-	_actionAreaContainsIcons = false;
-}
-
-void MenuMan::drawMovementArrows() {
-	DisplayMan &disp = *_vm->_displayMan;
-	byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice);
-	Box &dest = gBoxMovementArrows;
-	uint16 w = disp.getWidth(kMovementArrowsIndice);
-
-	disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency);
-}
-void MenuMan::clearActingChampion() {
-	ChampionMan &cm = *_vm->_championMan;
-	if (cm._actingChampionOrdinal) {
-		cm._actingChampionOrdinal--;
-		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true);
-		cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal);
-		cm._actingChampionOrdinal = indexToOrdinal(kChampionNone);
-		_shouldRefreshActionArea = true;
-	}
-}
-
-void MenuMan::drawActionIcon(ChampionIndex championIndex) {
-	if (!_actionAreaContainsIcons)
-		return;
-	DisplayMan &dm = *_vm->_displayMan;
-	Champion &champion = _vm->_championMan->_champions[championIndex];
-
-	Box box;
-	box._x1 = championIndex * 22 + 233;
-	box._x2 = box._x1 + 19 + 1;
-	box._y1 = 86;
-	box._y2 = 120 + 1;
-	dm._useByteBoxCoordinates = false;
-	if (!champion._currHealth) {
-		dm.clearScreenBox(kColorBlack, box);
-		return;
-	}
-	byte *bitmapIcon = dm._tmpBitmap;
-	Thing thing = champion.getSlot(kChampionSlotActionHand);
-	IconIndice iconIndex;
-	if (thing == Thing::_thingNone) {
-		iconIndex = kIconIndiceActionEmptyHand;
-	} else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
-		iconIndex = _vm->_objectMan->getIconIndex(thing);
-	} else {
-		dm.clearBitmap(bitmapIcon, 16, 16, kColorCyan);
-		goto T0386006;
-	}
-	_vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon);
-	dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, gPalChangesActionAreaObjectIcon);
-T0386006:
-	dm.clearScreenBox(kColorCyan, box);
-	Box box2;
-	box2._x1 = box._x1 + 2;
-	box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that
-	box2._y1 = 95;
-	box2._y2 = 110 + 1;
-	dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2);
-	if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) {
-		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
-	}
-}
-
-void MenuMan::drawDisabledMenu() {
-	if (!_vm->_championMan->_partyIsSleeping) {
-		warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
-		_vm->_displayMan->_useByteBoxCoordinates = false;
-		if (_vm->_inventoryMan->_inventoryChampionOrdinal) {
-			warning("MISSING CODE: F0334_INVENTORY_CloseChest");
-		} else {
-			warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
-		}
-		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
-		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
-		warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal");
-	}
-}
-
-}
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#include "menus.h"
+#include "gfx.h"
+#include "champion.h"
+#include "dungeonman.h"
+#include "objectman.h"
+#include "inventory.h"
+
+
+namespace DM {
+
+byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
+
+MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
+	_shouldRefreshActionArea = false;
+	_actionAreaContainsIcons = false;
+}
+
+void MenuMan::drawMovementArrows() {
+	DisplayMan &disp = *_vm->_displayMan;
+	byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice);
+	Box &dest = gBoxMovementArrows;
+	uint16 w = disp.getWidth(kMovementArrowsIndice);
+
+	disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency);
+}
+void MenuMan::clearActingChampion() {
+	ChampionMan &cm = *_vm->_championMan;
+	if (cm._actingChampionOrdinal) {
+		cm._actingChampionOrdinal--;
+		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true);
+		cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal);
+		cm._actingChampionOrdinal = indexToOrdinal(kChampionNone);
+		_shouldRefreshActionArea = true;
+	}
+}
+
+void MenuMan::drawActionIcon(ChampionIndex championIndex) {
+	if (!_actionAreaContainsIcons)
+		return;
+	DisplayMan &dm = *_vm->_displayMan;
+	Champion &champion = _vm->_championMan->_champions[championIndex];
+
+	Box box;
+	box._x1 = championIndex * 22 + 233;
+	box._x2 = box._x1 + 19 + 1;
+	box._y1 = 86;
+	box._y2 = 120 + 1;
+	dm._useByteBoxCoordinates = false;
+	if (!champion._currHealth) {
+		dm.clearScreenBox(kColorBlack, box);
+		return;
+	}
+	byte *bitmapIcon = dm._tmpBitmap;
+	Thing thing = champion.getSlot(kChampionSlotActionHand);
+	IconIndice iconIndex;
+	if (thing == Thing::_thingNone) {
+		iconIndex = kIconIndiceActionEmptyHand;
+	} else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
+		iconIndex = _vm->_objectMan->getIconIndex(thing);
+	} else {
+		dm.clearBitmap(bitmapIcon, 16, 16, kColorCyan);
+		goto T0386006;
+	}
+	_vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon);
+	dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, gPalChangesActionAreaObjectIcon);
+T0386006:
+	dm.clearScreenBox(kColorCyan, box);
+	Box box2;
+	box2._x1 = box._x1 + 2;
+	box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that
+	box2._y1 = 95;
+	box2._y2 = 110 + 1;
+	dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2);
+	if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) {
+		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+	}
+}
+
+void MenuMan::drawDisabledMenu() {
+	if (!_vm->_championMan->_partyIsSleeping) {
+		warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
+		_vm->_displayMan->_useByteBoxCoordinates = false;
+		if (_vm->_inventoryMan->_inventoryChampionOrdinal) {
+			warning("MISSING CODE: F0334_INVENTORY_CloseChest");
+		} else {
+			warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+		}
+		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+		warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal");
+	}
+}
+
+}
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index edaa970..91f89cd 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #ifndef DM_MENUS_H
 #define DM_MENUS_H
 
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index bc36e8b..b78ad96 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -1,3 +1,31 @@
+# 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.
+#
+#
+#
+#
+# Based on the Reverse Engineering work of Christophe Fontanel,
+# maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+#
+
+
 MODULE := engines/dm
 
 MODULE_OBJS := \
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 96f9579..f75b116 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #include "objectman.h"
 #include "dungeonman.h"
 
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index fd0f5a1..740ac0f 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #include "dm.h"
 #include "champion.h"
 
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 5ad2ac7..3adc1a9 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #include "text.h"
 
 
diff --git a/engines/dm/text.h b/engines/dm/text.h
index d273de3..1a413ee 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -1,3 +1,30 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
 #ifndef DM_TEXT_H
 #define DM_TEXT_H
 


Commit: 4b67e047eda34ae4ee54f416355f3154bb08d56d
    https://github.com/scummvm/scummvm/commit/4b67e047eda34ae4ee54f416355f3154bb08d56d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add MovesensMan

Changed paths:
  A engines/dm/movesens.cpp
  A engines/dm/movesens.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/module.mk



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index c8b02e9..fec043a 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -48,6 +48,7 @@
 #include "objectman.h"
 #include "inventory.h"
 #include "text.h"
+#include "movesens.h"
 
 namespace DM {
 
@@ -83,7 +84,8 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_objectMan = nullptr;
 	_inventoryMan = nullptr;
 	_textMan = nullptr;
-
+	_movsens = nullptr;
+	
 	_stopWaitingForPlayerInput = false;
 	_gameTimeTicking = false;
 	_restartGameAllowed = false;
@@ -111,6 +113,7 @@ DMEngine::~DMEngine() {
 	delete _objectMan;
 	delete _inventoryMan;
 	delete _textMan;
+	delete _movsens;
 
 	// clear debug channels
 	DebugMan.clearAllDebugChannels();
@@ -189,6 +192,7 @@ Common::Error DMEngine::run() {
 	_objectMan = new ObjectMan(this);
 	_inventoryMan = new InventoryMan(this);
 	_textMan = new TextMan(this);
+	_movsens = new MovesensMan(this);
 	_displayMan->setUpScreens(320, 200);
 
 	initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 430c7d3..aa37776 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -45,6 +45,7 @@ class LoadsaveMan;
 class ObjectMan;
 class InventoryMan;
 class TextMan;
+class MovesensMan;
 
 
 enum direction {
@@ -133,6 +134,7 @@ public:
 	ObjectMan *_objectMan;
 	InventoryMan *_inventoryMan;
 	TextMan *_textMan;
+	MovesensMan *_movsens;
 
 	bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput
 	bool _gameTimeTicking; // @ G0301_B_GameTimeTicking
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index b78ad96..bd9b576 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -39,7 +39,8 @@ MODULE_OBJS := \
 	loadsave.o \
 	objectman.o \
 	inventory.o \
-	text.o
+	text.o \
+	movesens.o
 
 MODULE_DIRS += \
 	engines/dm
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
new file mode 100644
index 0000000..9654d77
--- /dev/null
+++ b/engines/dm/movesens.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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+
+#include "movesens.h"
+
+
+namespace DM {
+
+MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {}
+
+
+}
\ No newline at end of file
diff --git a/engines/dm/movesens.h b/engines/dm/movesens.h
new file mode 100644
index 0000000..e0f397d
--- /dev/null
+++ b/engines/dm/movesens.h
@@ -0,0 +1,44 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+
+#ifndef DM_MOVESENS_H
+#define DM_MOVESENS_H
+
+#include "dm.h"
+
+namespace DM {
+
+class MovesensMan {
+	DMEngine *_vm;
+public:
+	explicit MovesensMan(DMEngine *vm);
+};
+
+}
+
+#endif


Commit: 18106aa967a3b0ff9a481c512f4ee91d5fd0eb09
    https://github.com/scummvm/scummvm/commit/18106aa967a3b0ff9a481c512f4ee91d5fd0eb09
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add Cell enum,  F0275_SENSOR_IsTriggeredByClickOnWall

Changed paths:
    engines/dm/dm.h
    engines/dm/dungeonman.h
    engines/dm/movesens.cpp
    engines/dm/movesens.h



diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index aa37776..2c8ff1c 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -83,6 +83,14 @@ enum ThingType {
 	kThingTypeTotal = 16 // +1 than the last (explosionThingType)
 }; // @ C[00..15]_THING_TYPE_...
 
+enum Cell {
+	kCellAny = -1, // @ CM1_CELL_ANY      
+	kCellNorthWest = 0, // @ C00_CELL_NORTHWEST 
+	kCellNorthEast = 1, // @ C01_CELL_NORTHEAST 
+	kCellSouthEast = 2, // @ C02_CELL_SOUTHEAST 
+	kCellSouthWest = 3 // @ C03_CELL_SOUTHWEST 
+};
+
 class Thing {
 	uint16 _data;
 public:
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 1ccb1d2..4a80d0e 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -278,6 +278,7 @@ public:
 	explicit Sensor(uint16 *rawDat) : _nextThing(rawDat[0]), _datAndType(rawDat[1]), _attributes(rawDat[2]), _action(rawDat[3]) {}
 
 	Thing getNextThing() { return _nextThing; }
+	void setNextThing(Thing thing) { _nextThing = thing; }
 	SensorType getType() { return (SensorType)(_datAndType & 0x7F); } // @ M39_TYPE
 	uint16 getData() { return _datAndType >> 7; } // @ M40_DATA
 	uint16 getDataMask1() { return (_datAndType >> 7) & 0xF; } // @ M42_MASK1
@@ -295,6 +296,11 @@ public:
 	uint16 getRemoteMapX() { return (_action >> 6) & 0x1F; }
 	direction getRemoteDir() { return (direction)((_action >> 4) & 3); }
 	uint16 getLocalAction() { return (_action >> 4); }
+	uint16 getEffectA() { return (_attributes >> 3) & 0x3; }
+	bool getRevertEffectA() { return (_attributes >> 5) & 0x1; }
+	bool getAudibleA() { return (_attributes >> 6) & 0x1; }
+
+
 	// some macros missing, i got bored
 }; // @ SENSOR
 
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 9654d77..2c25251 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -27,11 +27,169 @@
 
 
 #include "movesens.h"
+#include "champion.h"
+#include "inventory.h"
+#include "dungeonman.h"
+#include "objectman.h"
 
 
 namespace DM {
 
 MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {}
 
+bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam) {
+	ChampionMan &champMan = *_vm->_championMan;
+	DungeonMan &dunMan = *_vm->_dungeonMan;
+	ObjectMan &objMan = *_vm->_objectMan;
 
-}
\ No newline at end of file
+
+	bool atLeastOneSensorWasTriggered = false;
+	Thing leaderHandObject = champMan._leaderHand;
+	int16 sensorCountToProcessPerCell[4];
+	uint16 cell;
+	for (cell = kCellNorthWest; cell < kCellSouthWest; ++cell) {
+		sensorCountToProcessPerCell[cell] = 0;
+	}
+	Thing squareFirstThing;
+	Thing thingBeingProcessed = squareFirstThing = dunMan.getSquareFirstThing(mapX, mapY);
+	ThingType thingType;
+	while (thingBeingProcessed != Thing::_thingEndOfList) {
+		thingType = thingBeingProcessed.getType();
+		if (thingType == kSensorThingType) {
+			sensorCountToProcessPerCell[thingBeingProcessed.getCell()]++;
+		} else if (thingType >= kGroupThingType) {
+			break;
+		}
+		thingBeingProcessed = dunMan.getNextThing(thingBeingProcessed);
+	}
+	Thing lastProcessedThing = thingBeingProcessed = squareFirstThing;
+
+	while (thingBeingProcessed != Thing::_thingEndOfList) {
+		thingType = thingBeingProcessed.getType();
+		if (thingType == kSensorThingType) {
+			cell = thingBeingProcessed.getCell();
+			sensorCountToProcessPerCell[cell]--;
+			Sensor *sensor = (Sensor*)dunMan.getThingData(thingBeingProcessed); // IF YOU CHECK ME, I'LL CALL THE COPS!
+			SensorType sensorType = sensor->getType();
+			if (sensorType == kSensorDisabled)
+				goto T0275058_ProceedToNextThing;
+			if ((champMan._leaderIndex == kChampionNone) && (sensorType != kSensorWallChampionPortrait))
+				goto T0275058_ProceedToNextThing;
+			if (cell != cellParam)
+				goto T0275058_ProceedToNextThing;
+			int16 sensorData = sensor->getData();
+			int16 sensorEffect = sensor->getEffectA();
+			bool doNotTriggerSensor;
+			switch (sensorType) {
+			case kSensorWallOrnClick:
+				doNotTriggerSensor = false;
+				if (sensor->getEffectA() == kSensorEffHold) {
+					goto T0275058_ProceedToNextThing;
+				}
+				break;
+			case kSensorWallOrnClickWithAnyObj:
+				doNotTriggerSensor = (champMan._leaderEmptyHanded != sensor->getRevertEffectA());
+				break;
+			case kSensorWallOrnClickWithSpecObjRemovedSensor:
+			case kSensorWallOrnClickWithSpecObjRemovedRotateSensors:
+				if (sensorCountToProcessPerCell[cell])
+					goto T0275058_ProceedToNextThing;
+			case kSensorWallOrnClickWithSpecObj:
+			case kSensorWallOrnClickWithSpecObjRemoved:
+				doNotTriggerSensor = ((sensorData == objMan.getObjectType(leaderHandObject)) == sensor->getRevertEffectA());
+				if (!doNotTriggerSensor && (sensorType == kSensorWallOrnClickWithSpecObjRemovedSensor)) {
+					if (lastProcessedThing == thingBeingProcessed)
+						break;
+					((Sensor*)dunMan.getThingData(lastProcessedThing))->setNextThing(sensor->getNextThing());
+					sensor->setNextThing(Thing::_thingNone);
+					thingBeingProcessed = lastProcessedThing;
+				}
+				if (!doNotTriggerSensor && (sensorType == kSensorWallOrnClickWithSpecObjRemovedRotateSensors)) {
+					warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect");
+				}
+				break;
+			case kSensorWallObjGeneratorRotateSensors:
+				if (sensorCountToProcessPerCell[cell])
+					goto T0275058_ProceedToNextThing;
+				doNotTriggerSensor = !champMan._leaderEmptyHanded;
+				if (!doNotTriggerSensor) {
+					warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect");
+				}
+				break;
+			case kSensorWallSingleObjStorageRotateSensors:
+				if (champMan._leaderEmptyHanded) {
+					warning("MISSING CODE: F0273_SENSOR_GetObjectOfTypeInCell");
+					warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList");
+					warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand");
+				} else {
+					warning("MISSING CODE: F0273_SENSOR_GetObjectOfTypeInCell");
+					warning(("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand"));
+					warning("MISSING CODE: F0163_DUNGEON_LinkThingToList");
+					leaderHandObject = Thing::_thingNone;
+				}
+				warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect");
+				if ((sensorEffect == kSensorEffHold) && !champMan._leaderEmptyHanded) {
+					doNotTriggerSensor = true;
+				} else {
+					doNotTriggerSensor = false;
+				}
+				break;
+			case kSensorWallObjExchanger: {
+				if (sensorCountToProcessPerCell[cell])
+					goto T0275058_ProceedToNextThing;
+				Thing thingOnSquare = dunMan.getSquareFirstThing(mapX, mapY);
+				if ((objMan.getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_thingNone))
+					goto T0275058_ProceedToNextThing;
+				warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList");
+				warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand");
+				warning("MISSING CODE: F0163_DUNGEON_LinkThingToList");
+				warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand");
+				doNotTriggerSensor = false;
+				break;
+			}
+			case kSensorWallChampionPortrait:
+				champMan.addCandidateChampionToParty(sensorData);
+				goto T0275058_ProceedToNextThing;
+			default:
+				goto T0275058_ProceedToNextThing;
+			}
+
+			if (sensorEffect == kSensorEffHold) {
+				sensorEffect = doNotTriggerSensor ? kSensorEffClear : kSensorEffSet;
+				doNotTriggerSensor = false;
+			}
+
+			if (!doNotTriggerSensor) {
+				atLeastOneSensorWasTriggered = true;
+				if (sensor->getAudibleA()) {
+					warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+				}
+				if (!champMan._leaderEmptyHanded &&
+					((sensorType == kSensorWallOrnClickWithSpecObjRemoved) ||
+					(sensorType == kSensorWallOrnClickWithSpecObjRemovedRotateSensors) ||
+					 (sensorType == kSensorWallOrnClickWithSpecObjRemovedSensor))) {
+
+					*((Thing*)dunMan.getThingData(leaderHandObject)) = Thing::_thingNone;
+					warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand");
+					leaderHandObject = Thing::_thingNone;
+				} else {
+					warning("MISSING CODE: (leaderHandObject = F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator(sensorData)");
+					if (champMan._leaderEmptyHanded && (sensorType == kSensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_thingNone)) {
+						warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand");
+					}
+				}
+				warning("MISSING CODE: F0272_SENSOR_TriggerEffect");
+			}
+			goto T0275058_ProceedToNextThing;
+		}
+		if (thingType >= kGroupThingType)
+			break;
+T0275058_ProceedToNextThing:
+		lastProcessedThing = thingBeingProcessed;
+		thingBeingProcessed = dunMan.getNextThing(thingBeingProcessed);
+	}
+	warning("MISSING CODE: F0271_SENSOR_ProcessRotationEffect");
+	return atLeastOneSensorWasTriggered;
+}
+
+}
diff --git a/engines/dm/movesens.h b/engines/dm/movesens.h
index e0f397d..b73f727 100644
--- a/engines/dm/movesens.h
+++ b/engines/dm/movesens.h
@@ -37,6 +37,7 @@ class MovesensMan {
 	DMEngine *_vm;
 public:
 	explicit MovesensMan(DMEngine *vm);
+	bool sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam); // @ F0275_SENSOR_IsTriggeredByClickOnWall
 };
 
 }


Commit: d40e328e519cafe25cd1f5c668b3dd90c993d865
    https://github.com/scummvm/scummvm/commit/d40e328e519cafe25cd1f5c668b3dd90c993d865
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall

Changed paths:
    engines/dm/eventman.cpp
    engines/dm/eventman.h



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index fd7f907..50fba84 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -30,6 +30,7 @@
 
 #include "eventman.h"
 #include "dungeonman.h"
+#include "movesens.h"
 
 
 
@@ -402,8 +403,8 @@ void EventManager::processCommandQueue() {
 	if ((cmd._type >= kCommandMoveForward) && (cmd._type <= kCommandMoveLeft)) {
 		commandMoveParty(cmd._type);
 		return;
-	}		 
-	
+	}
+
 	if (cmd._type == kCommandClickInDungeonView) {
 		warning("DUMMY CODE, all of this");
 		DungeonMan &dunMan = *_vm->_dungeonMan;
@@ -495,4 +496,18 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
 	}
 }
 
+void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() {
+	DungeonMan &dunMan = *_vm->_dungeonMan;
+	CurrMapData &currMap = dunMan._currMap;
+	uint16 mapX = currMap._partyPosX;
+	uint16 mapY = currMap._partyPosY;
+	mapX += _dirIntoStepCountEast[currMap._partyDir];
+	mapY += _dirIntoStepCountNorth[currMap._partyDir];
+	if ((mapX >= 0)
+		&& (mapX < currMap._width)
+		&& (mapY >= 0)
+		&& (mapY < currMap._height)) {
+		_vm->_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(currMap._partyDir));
+	}
+}
 }; // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index bbf0b66..e0e78f9 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -244,6 +244,7 @@ public:
 	void processCommandQueue(); // @ F0380_COMMAND_ProcessQueue_CPSC
 
 	void commandSetLeader(ChampionIndex index); // @ F0368_COMMAND_SetLeader
+	void commandProcessType80ClickInDungeonViewTouchFrontWall(); // @ F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall
 };
 
 }


Commit: 4044dfa3647f0ba40493d8f07863b2d1f5f76f09
    https://github.com/scummvm/scummvm/commit/4044dfa3647f0ba40493d8f07863b2d1f5f76f09
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0157_DUNGEON_GetSquareFirstThingData, F0377_COMMAND_ProcessType80_ClickInDungeonView

Also add ElementType enum and G0462_as_Graphic561_Box_ObjectPiles, refactor DungeonMan::_dungeonViewClickableBoxes into Box type

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/objectman.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 0041307..dcf2325 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -423,9 +423,8 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL
 	_isFacingViAltar = false;
 	_isFacingFountain = false;
 
-	for (int i = 0; i < 4; i++)
-		for (int j = 0; j < 6; j++)
-			_dungeonViewClickableBoxes[j][i] = 0;
+	for (int j = 0; j < 6; j++)
+		_dungeonViewClickableBoxes[j].setToZero();
 }
 
 DungeonMan::~DungeonMan() {
@@ -975,6 +974,10 @@ uint16 *DungeonMan::getThingData(Thing thing) {
 	return _dunData._thingsData[thing.getType()][thing.getIndex()];
 }
 
+uint16* DungeonMan::getSquareFirstThingData(int16 mapX, int16 mapY) {
+	return getThingData(getSquareFirstThing(mapX, mapY));
+}
+
 Thing DungeonMan::getNextThing(Thing thing) {
 	return getThingData(thing)[0]; // :)
 }
@@ -1151,7 +1154,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 uint16 DungeonMan::getObjectWeight(Thing thing) {
 	static const uint16 junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo
 		// COMPASS - WATERSKIN - JEWEL SYMAL - ILLUMULET - ASHES
-		1, 3, 2, 2, 4, 
+		1, 3, 2, 2, 4,
 		// BONES - COPPER COIN - SILVER COIN - GOLD COIN - IRON KEY
 		15, 1, 1, 1, 2,
 		// KEY OF B - SOLID KEY - SQUARE KEY - TOURQUOISE KEY - CROSS KEY
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 4a80d0e..df2069f 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -34,6 +34,23 @@
 
 namespace DM {
 
+enum ElementType {
+	kElementTypeChampion = -2, // @ CM2_ELEMENT_CHAMPION /* Values -2 and -1 are only used as projectile impact types */
+	kElementTypeCreature = -1, // @ CM1_ELEMENT_CREATURE
+	kElementTypeWall = 0, // @ C00_ELEMENT_WALL /* Values 0-6 are used as square types and projectile impact types. Values 0-2 and 5-6 are also used for square aspect */
+	kElementTypeCorridor = 1, // @ C01_ELEMENT_CORRIDOR
+	kElementTypePit = 2, // @ C02_ELEMENT_PIT
+	kElementTypeStairs = 3, // @ C03_ELEMENT_STAIRS
+	kElementTypeDoor = 4, // @ C04_ELEMENT_DOOR
+	kElementTypeTeleporter = 5, // @ C05_ELEMENT_TELEPORTER
+	kElementTypeFakeWall = 6, // @ C06_ELEMENT_FAKEWALL
+	kElementTypeDoorSide = 16, // @ C16_ELEMENT_DOOR_SIDE /* Values 16-19 are only used for square aspect */
+	kElementTypeDoorFront = 17, // @ C17_ELEMENT_DOOR_FRONT
+	kElementTypeStairsSide = 18, // @ C18_ELEMENT_STAIRS_SIDE
+	kElementTypeStaisFront = 19  // @ C19_ELEMENT_STAIRS_FRONT	
+};
+
+
 enum ObjectAllowedSlot {
 	kObjectAllowedSlotMouth = 0x0001, // @ MASK0x0001_MOUTH
 	kObjectAllowedSlotHead = 0x0002, // @ MASK0x0002_HEAD
@@ -399,6 +416,7 @@ public:
 	explicit Potion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 
 	PotionType getType() { return (PotionType)((_attributes >> 8) & 0x7F); }
+	void setType(PotionType val) { _attributes = (_attributes & ~(0x7F << 8)) | ((val & 0x7F) << 8); }
 	Thing getNextThing() { return _nextThing; }
 }; // @ POTION
 
@@ -435,6 +453,7 @@ public:
 
 	JunkType getType() { return (JunkType)(_attributes & 0x7F); }
 	uint16 getChargeCount() { return (_attributes >> 14) & 0x3; }
+	void setChargeCount(uint16 val) { _attributes = (_attributes & ~(0x3 << 14)) | ((val & 0x3) << 14); }
 
 	Thing getNextThing() { return _nextThing; }
 }; // @ JUNK
@@ -611,6 +630,7 @@ public:
 	Thing getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing
 	Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing)
 	uint16 *getThingData(Thing thing); // @ unsigned char* F0156_DUNGEON_GetThingData(register THING P0276_T_Thing)
+	uint16 *getSquareFirstThingData(int16 mapX, int16 mapY); // @ F0157_DUNGEON_GetSquareFirstThingData
 
 	// TODO: this does stuff other than load the file!
 	void loadDungeonFile();	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
@@ -639,10 +659,11 @@ public:
 	Messages _messages; // @ NONE;
 
 	int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex
-	uint16 _dungeonViewClickableBoxes[6][4]; // G0291_aauc_DungeonViewClickableBoxes
+	Box _dungeonViewClickableBoxes[6]; // G0291_aauc_DungeonViewClickableBoxes
 	bool _isFacingAlcove; // @ G0286_B_FacingAlcove
 	bool _isFacingViAltar; // @ G0287_B_FacingViAltar
 	bool _isFacingFountain; // @ G0288_B_FacingFountain
+	ElementType _squareAheadElement; // @ G0285_i_SquareAheadElement 
 };
 
 }
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 50fba84..fcfc975 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -31,12 +31,20 @@
 #include "eventman.h"
 #include "dungeonman.h"
 #include "movesens.h"
+#include "objectman.h"
 
 
 
 
 namespace DM {
 
+Box gBoxObjectPiles[4] = { // @ G0462_as_Graphic561_Box_ObjectPiles
+	/* { X1, X2, Y1, Y2 } */
+	Box(24, 111, 148, 168),   /* Front left */
+	Box(112, 199, 148, 168),   /* Front right */
+	Box(112, 183, 122, 147),   /* Back right */
+	Box(40, 111, 122, 147)}; /* Back left */
+
 MouseInput gPrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
 												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(kCommandEntranceEnterDungeon, 244, 298,  45,  58, kLeftMouseButton),
@@ -390,7 +398,8 @@ void EventManager::processCommandQueue() {
 
 	Command cmd = _commandQueue.pop();
 
-	// MISSING CODE: for when movement is disabled
+	int16 commandX = cmd._pos.x;
+	int16 commandY = cmd._pos.y;
 
 	_isCommandQueueLocked = false;
 	processPendingClick();
@@ -406,7 +415,7 @@ void EventManager::processCommandQueue() {
 	}
 
 	if (cmd._type == kCommandClickInDungeonView) {
-		warning("DUMMY CODE, all of this");
+		/*warning("DUMMY CODE, all of this");
 		DungeonMan &dunMan = *_vm->_dungeonMan;
 		CurrMapData &currMap = dunMan._currMap;
 		uint16 mapX = currMap._partyPosX;
@@ -417,7 +426,8 @@ void EventManager::processCommandQueue() {
 		Sensor sensor(dunMan.getThingData(squareFirstThing));
 		if (sensor.getType() == kSensorWallChampionPortrait) {
 			_vm->_championMan->addCandidateChampionToParty(sensor.getData());
-		}
+		}*/
+		commandProcessType80ClickInDungeonView(commandX, commandY);
 	}
 
 	// MISSING CODE: the rest of the function
@@ -510,4 +520,94 @@ void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() {
 		_vm->_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(currMap._partyDir));
 	}
 }
+
+void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY) {
+	DungeonMan &dunMan = *_vm->_dungeonMan;
+	ChampionMan &champMan = *_vm->_championMan;
+	CurrMapData &currMap = _vm->_dungeonMan->_currMap;
+
+	int16 mapX;
+	int16 mapY;
+
+
+	if (dunMan._squareAheadElement == kElementTypeDoorFront) {
+		if (champMan._leaderIndex == kChampionNone) {
+			return;
+		}
+		mapX = currMap._partyPosX;
+		mapY = currMap._partyPosY;
+		mapX += _dirIntoStepCountEast[currMap._partyDir];
+		mapY += _dirIntoStepCountNorth[currMap._partyDir];
+
+		if (champMan._leaderEmptyHanded) {
+			if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() &&
+				dunMan._dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
+				_vm->_stopWaitingForPlayerInput = true;
+				warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+				warning("MISSING CODE: F0268_SENSOR_AddEvent");
+				return;
+			}
+
+			warning("MISSING CODE: F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown in elseif condition");
+		}
+	}
+
+	if (champMan._leaderEmptyHanded) {
+		for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellDoorButtonOrWallOrn; viewCell++) {
+			if (dunMan._dungeonViewClickableBoxes[viewCell].isPointInside(Common::Point(posX, posY - 33))) {
+				if (viewCell == kViewCellDoorButtonOrWallOrn) {
+					if (!dunMan._isFacingAlcove) {
+						commandProcessType80ClickInDungeonViewTouchFrontWall();
+					} 
+				} else {
+					warning("MISSING CODE: F0373_COMMAND_ProcessType80_ClickInDungeonView_GrabLeaderHandObject");
+				}
+				return;
+			}
+		}
+	} else {
+		Thing thing = champMan._leaderHand;
+		uint16 *rawThingPointer = dunMan.getThingData(thing);
+		if (dunMan._squareAheadElement == kElementTypeWall) {
+			for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellFrontRight; ++viewCell) {
+				if (gBoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) {
+					warning("F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject");
+					return;
+				}
+			}
+
+			if (dunMan._dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
+				if (dunMan._isFacingAlcove) {
+					warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject");
+				} else {
+					if (dunMan._isFacingFountain) {
+						uint16 iconIndex = _vm->_objectMan->getIconIndex(thing);
+						int16 weight = dunMan.getObjectWeight(thing);
+						if ((iconIndex >= kIconIndiceJunkWater) && (iconIndex <= kIconIndiceJunkWaterSkin)) {
+							((Junk*)rawThingPointer)->setChargeCount(3);
+						} else if (iconIndex == kIconIndicePotionEmptyFlask) {
+							((Potion*)rawThingPointer)->setType(kPotionTypeWaterFlask);
+						} else {
+							goto T0377019;
+						}
+						warning("MISSING CODE: F0296_CHAMPION_DrawChangedObjectIcons");
+						champMan._champions[champMan._leaderIndex]._load += dunMan.getObjectWeight(thing) - weight;
+					}
+T0377019:
+					commandProcessType80ClickInDungeonViewTouchFrontWall();
+				}
+			}
+
+		} else {
+			warning("MISSING CODE: F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown in if branch");
+			for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellBackLeft; viewCell++) {
+				if (gBoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) {
+					warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject");
+					return;
+				}
+			}
+		}
+	}
+}
+
 }; // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index e0e78f9..1a4d663 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -37,6 +37,8 @@
 
 namespace DM {
 
+
+
 enum MouseButton {
 	kNoneMouseButton = 0, // present only because of typesafety
 	kLeftMouseButton = 1,
@@ -245,6 +247,7 @@ public:
 
 	void commandSetLeader(ChampionIndex index); // @ F0368_COMMAND_SetLeader
 	void commandProcessType80ClickInDungeonViewTouchFrontWall(); // @ F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall
+	void commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView
 };
 
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 14324bd..d9bb6af 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1146,9 +1146,11 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	byte  *tmpBitmap = new byte[305 * 111];
 	clearBitmap(tmpBitmap, 305, 111, kColorBlack);
 
-	memset(_vm->_dungeonMan->_dungeonViewClickableBoxes, 0, sizeof(_vm->_dungeonMan->_dungeonViewClickableBoxes));
+	for (int16 i = 0; i < 6; ++i)
+		_vm->_dungeonMan->_dungeonViewClickableBoxes[i].setToZero();
+
 	for (uint16 i = 0; i < 6; ++i) {
-		_vm->_dungeonMan->_dungeonViewClickableBoxes[i][0] = 255;
+		_vm->_dungeonMan->_dungeonViewClickableBoxes[i]._x1 = 255 + 1;
 	}
 
 	if (flippedFloorCeiling) {
@@ -1461,8 +1463,12 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 					return isAlcove;
 				}
 				nativeBitmapIndex++;
-				for (uint16 i = 0; i < 4; ++i)
-					_vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn][i] = coordinateSetA[i];
+
+				_vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._x1 = coordinateSetA[0];
+				_vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._x2 = coordinateSetA[1];
+				_vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._y1 = coordinateSetA[2];
+				_vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._y2 = coordinateSetA[3];
+
 				_vm->_dungeonMan->_isFacingAlcove = isAlcove;
 				_vm->_dungeonMan->_isFacingViAltar = (wallOrnIndex == _currMapViAltarIndex);
 				_vm->_dungeonMan->_isFacingFountain = false;
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 11679ef..e73c44e 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -91,6 +91,7 @@ public:
 	bool isPointInside(Common::Point point) {
 		return (_x1 <= point.x) && (point.x < _x2) && (_y1 <= point.y) && (point.y < _y2);
 	}
+	void setToZero() { _x1 = _x2 = _y1 = _y2 = 0; }
 }; // @ BOX_BYTE, BOX_WORD
 
 extern Box gBoxMovementArrows; // G0002_s_Graphic562_Box_MovementArrows
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index 740ac0f..fbf880d 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -43,7 +43,7 @@ public:
 	SlotBox(int16 x, int16 y, int16 iconIndex): _x(x), _y(y), _iconIndex(iconIndex) {}
 }; // @ SLOT_BOX
 
-extern SlotBox gSlotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes;
+extern SlotBox gSlotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes
 
 class ObjectMan {
 	DMEngine *_vm;


Commit: fab051093691fdcf3f29662e95699bc080f5602a
    https://github.com/scummvm/scummvm/commit/fab051093691fdcf3f29662e95699bc080f5602a
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Move gSlotBoxes to ObjectMan

Changed paths:
    engines/dm/champion.cpp
    engines/dm/objectman.cpp
    engines/dm/objectman.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 28f477c..6f2aa4a 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -609,7 +609,7 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 		thing = champ->getSlot(slotIndex);
 	}
 
-	SlotBox *slotBox = &gSlotBoxes[slotBoxIndex];
+	SlotBox *slotBox = &_vm->_objectMan->_slotBoxes[slotBoxIndex];
 	Box box;
 	box._x1 = slotBox->_x - 1;
 	box._y1 = slotBox->_y - 1;
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index f75b116..4099b33 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -28,58 +28,8 @@
 #include "objectman.h"
 #include "dungeonman.h"
 
-
 namespace DM {
 
-SlotBox gSlotBoxes[46] = { 
-/* 8 for champion hands in status boxes, 30 for champion inventory, 8 for chest */
-	SlotBox(4,  10, 0), /* Champion Status Box 0 Ready Hand */
-	SlotBox(24,  10, 0), /* Champion Status Box 0 Action Hand */
-	SlotBox(73,  10, 0), /* Champion Status Box 1 Ready Hand */
-	SlotBox(93,  10, 0), /* Champion Status Box 1 Action Hand */
-	SlotBox(142,  10, 0), /* Champion Status Box 2 Ready Hand */
-	SlotBox(162,  10, 0), /* Champion Status Box 2 Action Hand */
-	SlotBox(211,  10, 0), /* Champion Status Box 3 Ready Hand */
-	SlotBox(231,  10, 0), /* Champion Status Box 3 Action Hand */
-	SlotBox(6,  53, 0), /* Ready Hand */
-	SlotBox(62,  53, 0), /* Action Hand */
-	SlotBox(34,  26, 0), /* Head */
-	SlotBox(34,  46, 0), /* Torso */
-	SlotBox(34,  66, 0), /* Legs */
-	SlotBox(34,  86, 0), /* Feet */
-	SlotBox(6,  90, 0), /* Pouch 2 */
-	SlotBox(79,  73, 0), /* Quiver Line2 1 */
-	SlotBox(62,  90, 0), /* Quiver Line1 2 */
-	SlotBox(79,  90, 0), /* Quiver Line2 2 */
-	SlotBox(6,  33, 0), /* Neck */
-	SlotBox(6,  73, 0), /* Pouch 1 */
-	SlotBox(62,  73, 0), /* Quiver Line1 1 */
-	SlotBox(66,  33, 0), /* Backpack Line1 1 */
-	SlotBox(83,  16, 0), /* Backpack Line2 2 */
-	SlotBox(100,  16, 0), /* Backpack Line2 3 */
-	SlotBox(117,  16, 0), /* Backpack Line2 4 */
-	SlotBox(134,  16, 0), /* Backpack Line2 5 */
-	SlotBox(151,  16, 0), /* Backpack Line2 6 */
-	SlotBox(168,  16, 0), /* Backpack Line2 7 */
-	SlotBox(185,  16, 0), /* Backpack Line2 8 */
-	SlotBox(202,  16, 0), /* Backpack Line2 9 */
-	SlotBox(83,  33, 0), /* Backpack Line1 2 */
-	SlotBox(100,  33, 0), /* Backpack Line1 3 */
-	SlotBox(117,  33, 0), /* Backpack Line1 4 */
-	SlotBox(134,  33, 0), /* Backpack Line1 5 */
-	SlotBox(151,  33, 0), /* Backpack Line1 6 */
-	SlotBox(168,  33, 0), /* Backpack Line1 7 */
-	SlotBox(185,  33, 0), /* Backpack Line1 8 */
-	SlotBox(202,  33, 0), /* Backpack Line1 9 */
-	SlotBox(117,  59, 0), /* Chest 1 */
-	SlotBox(106,  76, 0), /* Chest 2 */
-	SlotBox(111,  93, 0), /* Chest 3 */
-	SlotBox(128,  98, 0), /* Chest 4 */
-	SlotBox(145, 101, 0), /* Chest 5 */
-	SlotBox(162, 103, 0), /* Chest 6 */
-	SlotBox(179, 104, 0), /* Chest 7 */
-	SlotBox(196, 105, 0)}; /* Chest 8 */
-
 int16 gIconGraphicHeight[7] = {32, 32, 32, 32, 32, 32, 32}; // @ K0077_ai_IconGraphicHeight
 
 int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex
@@ -91,7 +41,55 @@ int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconI
 	160,   /* First icon index in graphic #47 */
 	192}; /* First icon index in graphic #48 */
 
-ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {}
+ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {
+	/* 8 for champion hands in status boxes, 30 for champion inventory, 8 for chest */
+	_slotBoxes[0] = SlotBox(4,  10, 0);    /* Champion Status Box 0 Ready Hand */
+	_slotBoxes[1] = SlotBox(24,  10, 0);   /* Champion Status Box 0 Action Hand */
+	_slotBoxes[2] = SlotBox(73,  10, 0);   /* Champion Status Box 1 Ready Hand */
+	_slotBoxes[3] = SlotBox(93,  10, 0);   /* Champion Status Box 1 Action Hand */
+	_slotBoxes[4] = SlotBox(142,  10, 0);  /* Champion Status Box 2 Ready Hand */
+	_slotBoxes[5] = SlotBox(162,  10, 0);  /* Champion Status Box 2 Action Hand */
+	_slotBoxes[6] = SlotBox(211,  10, 0);  /* Champion Status Box 3 Ready Hand */
+	_slotBoxes[7] = SlotBox(231,  10, 0);  /* Champion Status Box 3 Action Hand */
+	_slotBoxes[8] = SlotBox(6,  53, 0);    /* Ready Hand */
+	_slotBoxes[9] = SlotBox(62,  53, 0);   /* Action Hand */
+	_slotBoxes[10] = SlotBox(34,  26, 0);  /* Head */
+	_slotBoxes[11] = SlotBox(34,  46, 0);  /* Torso */
+	_slotBoxes[12] = SlotBox(34,  66, 0);  /* Legs */
+	_slotBoxes[13] = SlotBox(34,  86, 0);  /* Feet */
+	_slotBoxes[14] = SlotBox(6,  90, 0);   /* Pouch 2 */
+	_slotBoxes[15] = SlotBox(79,  73, 0);  /* Quiver Line2 1 */
+	_slotBoxes[16] = SlotBox(62,  90, 0);  /* Quiver Line1 2 */
+	_slotBoxes[17] = SlotBox(79,  90, 0);  /* Quiver Line2 2 */
+	_slotBoxes[18] = SlotBox(6,  33, 0);   /* Neck */
+	_slotBoxes[19] = SlotBox(6,  73, 0);   /* Pouch 1 */
+	_slotBoxes[20] = SlotBox(62,  73, 0);  /* Quiver Line1 1 */
+	_slotBoxes[21] = SlotBox(66,  33, 0);  /* Backpack Line1 1 */
+	_slotBoxes[22] = SlotBox(83,  16, 0);  /* Backpack Line2 2 */
+	_slotBoxes[23] = SlotBox(100,  16, 0); /* Backpack Line2 3 */
+	_slotBoxes[24] = SlotBox(117,  16, 0); /* Backpack Line2 4 */
+	_slotBoxes[25] = SlotBox(134,  16, 0); /* Backpack Line2 5 */
+	_slotBoxes[26] = SlotBox(151,  16, 0); /* Backpack Line2 6 */
+	_slotBoxes[27] = SlotBox(168,  16, 0); /* Backpack Line2 7 */
+	_slotBoxes[28] = SlotBox(185,  16, 0); /* Backpack Line2 8 */
+	_slotBoxes[29] = SlotBox(202,  16, 0); /* Backpack Line2 9 */
+	_slotBoxes[30] = SlotBox(83,  33, 0);  /* Backpack Line1 2 */
+	_slotBoxes[31] = SlotBox(100,  33, 0); /* Backpack Line1 3 */
+	_slotBoxes[32] = SlotBox(117,  33, 0); /* Backpack Line1 4 */
+	_slotBoxes[33] = SlotBox(134,  33, 0); /* Backpack Line1 5 */
+	_slotBoxes[34] = SlotBox(151,  33, 0); /* Backpack Line1 6 */
+	_slotBoxes[35] = SlotBox(168,  33, 0); /* Backpack Line1 7 */
+	_slotBoxes[36] = SlotBox(185,  33, 0); /* Backpack Line1 8 */
+	_slotBoxes[37] = SlotBox(202,  33, 0); /* Backpack Line1 9 */
+	_slotBoxes[38] = SlotBox(117,  59, 0); /* Chest 1 */
+	_slotBoxes[39] = SlotBox(106,  76, 0); /* Chest 2 */
+	_slotBoxes[40] = SlotBox(111,  93, 0); /* Chest 3 */
+	_slotBoxes[41] = SlotBox(128,  98, 0); /* Chest 4 */
+	_slotBoxes[42] = SlotBox(145, 101, 0); /* Chest 5 */
+	_slotBoxes[43] = SlotBox(162, 103, 0); /* Chest 6 */
+	_slotBoxes[44] = SlotBox(179, 104, 0); /* Chest 7 */
+	_slotBoxes[45] = SlotBox(196, 105, 0); /* Chest 8 */
+}
 
 IconIndice ObjectMan::getObjectType(Thing thing) {
 	if (thing == Thing::_thingNone)
@@ -156,23 +154,25 @@ IconIndice ObjectMan::getIconIndex(Thing thing) {
 
 void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 	int16 i;
-	for (i = 0; i < 7; ++i)
+	for (i = 0; i < 7; ++i) {
 		if (gIconGraphicFirstIndex[i] > iconIndex)
 			break;
+	}
+
 	--i;
 	byte *srcBitmap = _vm->_displayMan->getBitmap(kObjectIcons_000_TO_031 + i);
 	iconIndex -= gIconGraphicFirstIndex[i];
 	_vm->_displayMan->_useByteBoxCoordinates = true;
 	_vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, 0, 16, 0, 16, kColorNoTransparency);
-
 }
 
 void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
-	SlotBox *slotBox = &gSlotBoxes[slotBoxIndex];
+	SlotBox *slotBox = &_slotBoxes[slotBoxIndex];
 	slotBox->_iconIndex = iconIndex; // yes, this modifies the global array
 	if (slotBox->_iconIndex == kIconIndiceNone) {
 		return;
 	}
+
 	Box box;
 	box._x1 = slotBox->_x;
 	box._y1 = slotBox->_y;
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index fbf880d..a2ceafe 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -41,15 +41,17 @@ public:
 	int16 _y;
 	int16 _iconIndex;
 	SlotBox(int16 x, int16 y, int16 iconIndex): _x(x), _y(y), _iconIndex(iconIndex) {}
+	SlotBox(): _x(-1), _y(-1), _iconIndex(-1) {}
 }; // @ SLOT_BOX
 
-extern SlotBox gSlotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes
-
 class ObjectMan {
 	DMEngine *_vm;
+
 public:
 	explicit ObjectMan(DMEngine *vm);
 
+	SlotBox _slotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes;
+
 	IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType
 	IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
 	void extractIconFromBitmap(uint16 iconIndex, byte *srcBitmap); // F0036_OBJECT_ExtractIconFromBitmap


Commit: 45461a4908bfab95fa41ff90aba2e697b2581c96
    https://github.com/scummvm/scummvm/commit/45461a4908bfab95fa41ff90aba2e697b2581c96
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix compilation on GCC

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/inventory.cpp
    engines/dm/menus.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 6f2aa4a..8579fb6 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -432,7 +432,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 							   kChampionAttributeActionHand))) {
 		return;
 	}
-	bool isInventoryChamp = (indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
+	bool isInventoryChamp = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
 	dispMan._useByteBoxCoordinates = false;
 	if (champAttributes & kChampionAttributeStatusBox) {
 		box._y1 = 0;
@@ -537,7 +537,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	{ // block so goto won't skip AL_0_championIconIndex initialization 
 		int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir);
 
-		if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != indexToOrdinal(AL_0_championIconIndex))) {
+		if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) {
 			dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]);
 			dispMan.blitToScreen(dispMan.getBitmap(kChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0,
 								 gBoxChampionIcons[AL_0_championIconIndex], kColorDarkestGray);
@@ -590,11 +590,11 @@ void ChampionMan::drawHealthStaminaManaValues(Champion* champ) {
 void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 	int16 nativeBitmapIndex = -1;
 	Champion *champ = &_champions[champIndex];
-	bool isInventoryChamp = (_vm->_inventoryMan->_inventoryChampionOrdinal == indexToOrdinal(champIndex));
+	bool isInventoryChamp = (_vm->_inventoryMan->_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex));
 
 	uint16 slotBoxIndex;
 	if (!isInventoryChamp) {  /* If drawing a slot for a champion other than the champion whose inventory is open */
-		if ((slotIndex > kChampionSlotActionHand) || (_candidateChampionOrdinal == indexToOrdinal(champIndex))) {
+		if ((slotIndex > kChampionSlotActionHand) || (_candidateChampionOrdinal == _vm->indexToOrdinal(champIndex))) {
 			return;
 		}
 		slotBoxIndex = (champIndex << 1) + slotIndex;
@@ -654,7 +654,7 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 		}
 	}
 
-	if ((slotIndex == kChampionSlotActionHand) && (indexToOrdinal(champIndex) == _actingChampionOrdinal)) {
+	if ((slotIndex == kChampionSlotActionHand) && (_vm->indexToOrdinal(champIndex) == _actingChampionOrdinal)) {
 		nativeBitmapIndex = kSlotBoxActingHandIndice;
 	}
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index fec043a..aa4290f 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -232,4 +232,12 @@ void DMEngine::gameloop() {
 	}
 }
 
+int16 DMEngine::ordinalToIndex(int16 val) {
+	return val - 1;
+}
+
+int16 DMEngine::indexToOrdinal(int16 val) {
+	return val + 1;
+}
+
 } // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 2c8ff1c..e9ab80f 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -127,6 +127,8 @@ public:
 	explicit DMEngine(OSystem *syst);
 	~DMEngine();
 
+	int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
+	int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
 	virtual Common::Error run(); // @ main
 
 private:
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index dcf2325..d948082 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -359,10 +359,6 @@ CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_Crea
 	{25,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5},
 	{26,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}};
 
-int16 DM::ordinalToIndex(int16 val) { return val - 1; }
-int16 DM::indexToOrdinal(int16 val) { return val + 1; }
-
-
 void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
 	posX += _dirIntoStepCountEast[dir] * stepsForward;
 	posY += _dirIntoStepCountNorth[dir] * stepsForward;
@@ -863,7 +859,7 @@ T0172010_ClosedFakeWall:
 					Sensor sensor(getThingData(thing));
 					aspectArray[sideIndex + 1] = sensor.getOrnOrdinal();
 					if (sensor.getType() == kSensorWallChampionPortrait) {
-						_vm->_displayMan->_championPortraitOrdinal = indexToOrdinal(sensor.getData());
+						_vm->_displayMan->_championPortraitOrdinal = _vm->indexToOrdinal(sensor.getData());
 					}
 				}
 			}
@@ -946,7 +942,7 @@ void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowe
 
 	if (isFakeWall || mapX < 0 || mapX >= _currMap._width || mapY < 0 || mapY >= _currMap._height) {
 		for (uint16 i = kRightWallOrnOrdAspect; i <= kLeftWallOrnOrdAspect; ++i) {
-			if (isWallOrnAnAlcove(ordinalToIndex(aspectArray[i])))
+			if (isWallOrnAnAlcove(_vm->ordinalToIndex(aspectArray[i])))
 				aspectArray[i] = 0;
 		}
 	}
@@ -957,7 +953,7 @@ int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int
 					+ (3000 + (_currMap._index << 6) + _currMap._width + _currMap._height) * 11
 					+ _fileHeader._ornamentRandomSeed) >> 2) % modulo;
 	if (allowed && index < count)
-		return indexToOrdinal(index);
+		return _vm->indexToOrdinal(index);
 	return 0;
 }
 
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index df2069f..5191ba9 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -143,11 +143,6 @@ public:
 
 extern WeaponInfo gWeaponInfo[46];
 
-
-int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
-int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
-
-
 enum TextType {
 	/* Used for text on walls */
 	kTextTypeInscription = 0, // @ C0_TEXT_TYPE_INSCRIPTION 
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index fcfc975..0b76af3 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -499,7 +499,7 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
 	Champion *champion = &cm._champions[cm._leaderIndex];
 	champion->_dir = _vm->_dungeonMan->_currMap._partyDir;
 	cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHand);
-	if (indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) {
+	if (_vm->indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) {
 		champion->setAttributeFlag(kChampionAttributeIcon, true);
 		champion->setAttributeFlag(kChampionAttributeNameTitle, true);
 		cm.drawChampionState(champIndex);
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index d9bb6af..f5d5883 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1350,10 +1350,10 @@ void DisplayMan::loadCurrentMapGraphics() {
 		CreatureAspect &aspect = gCreatureAspects[_currMapAllowedCreatureTypes[creatureType]];
 		uint16 replColorOrdinal = aspect.getReplColour9();
 		if (replColorOrdinal)
-			applyCreatureReplColors(9, ordinalToIndex(replColorOrdinal));
+			applyCreatureReplColors(9, _vm->ordinalToIndex(replColorOrdinal));
 		replColorOrdinal = aspect.getReplColour10();
 		if (replColorOrdinal)
-			applyCreatureReplColors(10, ordinalToIndex(replColorOrdinal));
+			applyCreatureReplColors(10, _vm->ordinalToIndex(replColorOrdinal));
 	}
 }
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 7dd1b00..ab57883 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -59,18 +59,18 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 		return;
 	_vm->_stopWaitingForPlayerInput = true;
 	int16 invChampOrdinal = _inventoryChampionOrdinal; // copy, as the original will be edited
-	if (indexToOrdinal(championIndex) == invChampOrdinal) {
+	if (_vm->indexToOrdinal(championIndex) == invChampOrdinal) {
 		championIndex = kChmpionCloseInventory;
 	}
 
 	Champion *champion;
 	if (invChampOrdinal) {
-		_inventoryChampionOrdinal = indexToOrdinal(kChampionNone);
+		_inventoryChampionOrdinal = _vm->indexToOrdinal(kChampionNone);
 		warning("MISSING CODE: F0334_INVENTORY_CloseChest");
-		champion = &cm._champions[ordinalToIndex(invChampOrdinal)];
+		champion = &cm._champions[_vm->ordinalToIndex(invChampOrdinal)];
 		if (champion->_currHealth && !cm._candidateChampionOrdinal) {
 			champion->setAttributeFlag(kChampionAttributeStatusBox, true);
-			cm.drawChampionState((ChampionIndex)ordinalToIndex(invChampOrdinal));
+			cm.drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
 		}
 		if (cm._partyIsSleeping) {
 			return;
@@ -86,7 +86,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	}
 
 	dm._useByteBoxCoordinates = false;
-	_inventoryChampionOrdinal = indexToOrdinal(championIndex);
+	_inventoryChampionOrdinal = _vm->indexToOrdinal(championIndex);
 	if (!invChampOrdinal) {
 		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 	}
@@ -185,7 +185,7 @@ void InventoryMan::drawPanel() {
 		return;
 	}
 
-	Thing thing = cm._champions[ordinalToIndex(_inventoryChampionOrdinal)].getSlot(kChampionSlotActionHand);
+	Thing thing = cm._champions[_vm->ordinalToIndex(_inventoryChampionOrdinal)].getSlot(kChampionSlotActionHand);
 
 	_panelContent = kPanelContentFoodWaterPoisoned;
 	switch (thing.getType()) {
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 7b971e5..f83fa6e 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -56,7 +56,7 @@ void MenuMan::clearActingChampion() {
 		cm._actingChampionOrdinal--;
 		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true);
 		cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal);
-		cm._actingChampionOrdinal = indexToOrdinal(kChampionNone);
+		cm._actingChampionOrdinal = _vm->indexToOrdinal(kChampionNone);
 		_shouldRefreshActionArea = true;
 	}
 }


Commit: c1abeffecccf5cd6096f3a780f17e1327ee744da
    https://github.com/scummvm/scummvm/commit/c1abeffecccf5cd6096f3a780f17e1327ee744da
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some GCC warnings

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/objectman.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 8579fb6..b246ecc 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -312,6 +312,9 @@ T0280046:
 					slotIndex_Green = AL_0_slotIndex_Red++;
 				}
 				break;
+			
+			default:
+				break;
 			}
 T0280048:
 			if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) {
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index d948082..ac38a07 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -842,6 +842,8 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
 			frontOrnAllowed = square.get(kWallEastRandOrnAllowed);
 			rightOrnAllowed = square.get(kWallSouthRandOrnAllowed);
 			break;
+		default:
+			break;
 		}
 
 T0172010_ClosedFakeWall:
@@ -925,6 +927,9 @@ T0172049_Footprints:
 		unsigned char scentOrdinal; // see next line comment
 		if (footPrintsAllowed) // TODO: I skipped some party query code, must come back later and complete
 			aspectArray[kFloorOrnOrdAspect] &= kFootprintsAspect;
+		break;
+	default:
+		break;
 	}
 	aspectArray[kFirstGroupOrObjectAspect] = thing.toUint16();
 }
@@ -1205,6 +1210,8 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 		}
 	case kScrollThingType:
 		return 1;
+	default:
+		break;
 	}
 
 	assert(false); // this should never be taken
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 0b76af3..680c621 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -340,6 +340,8 @@ void EventManager::processInput() {
 				if (_dummyMapIndex > 0)
 					dungeonMan.setCurrentMapAndPartyMap(--_dummyMapIndex);
 				break;
+			default:
+				break;
 			}
 		case Common::EVENT_MOUSEMOVE:
 			_mousePos = event.mouse;
@@ -350,6 +352,8 @@ void EventManager::processInput() {
 			_pendingClickPos = _mousePos;
 			_pendingClickButton = (event.type == Common::EVENT_LBUTTONDOWN) ? kLeftMouseButton : kRightMouseButton;
 			break;
+		default:
+			break;
 		}
 	}
 }
@@ -471,6 +475,8 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 	case kCommandMoveRight:
 		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, 1, currMap._partyPosX, currMap._partyPosY);
 		break;
+	default:
+		break;
 	}
 
 	// MISSING CODE: Lots of code
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 4099b33..d20c235 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -146,6 +146,8 @@ IconIndice ObjectMan::getIconIndex(Thing thing) {
 				iconIndex = (IconIndice)(iconIndex + 1);
 			}
 			break;
+		default:
+			break;
 		}
 	}
 


Commit: eddf2f494d3e750519e0d515d97834f05974c3c1
    https://github.com/scummvm/scummvm/commit/eddf2f494d3e750519e0d515d97834f05974c3c1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/inventory.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index b246ecc..03515a0 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -38,12 +38,12 @@ namespace DM {
 
 Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
 Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
-Box gBoxChampionIcons[4] = { // @ G0054_ai_Graphic562_Box_ChampionIcons
+Box gBoxChampionIcons[4] = { 
 	Box(281, 299,  0, 13),
 	Box(301, 319,  0, 13),
 	Box(301, 319, 15, 28),
 	Box(281, 299, 15, 28)};
-Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; // @ G0046_auc_Graphic562_ChampionColor
+Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; 
 
 uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
 	/* 30 for champion inventory, 8 for chest */
@@ -265,8 +265,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	int16 mapY = _vm->_dungeonMan->_currMap._partyPosY;
 
 	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir));
-	mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir];
-	mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir];
+	mapX += gDirIntoStepCountEast[dunMan._currMap._partyDir];
+	mapY += gDirIntoStepCountNorth[dunMan._currMap._partyDir];
 	thing = dunMan.getSquareFirstThing(mapX, mapY);
 	AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
 	uint16 slotIndex_Green;
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 0610f29..1a89bc2 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -35,6 +35,9 @@
 
 namespace DM {
 
+extern Box gBoxChampionIcons[4]; // @ G0054_ai_Graphic562_Box_ChampionIcons
+extern Color gChampionColor[4]; // @ G0046_auc_Graphic562_ChampionColor
+
 class Scent {
 	uint16 _scent;
 public:
@@ -157,7 +160,7 @@ enum ChampionIndex {
 	kChampionSecond = 1,
 	kChampionThird = 2,
 	kChampionFourth = 3,
-	kChmpionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY
+	kChampionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY
 	kChampionSpecialInventory = 5 // @ C05_CHAMPION_SPECIAL_INVENTORY
 };
 
@@ -366,7 +369,7 @@ public:
 	void setSkillExp(ChampionSkill skill,  int32 val) { _skills[skill]._experience = val; }
 	void setSkillTempExp(ChampionSkill skill,  int16 val) { _skills[skill]._temporaryExperience= val; }
 
-	byte getStatistic(ChampionStatisticType type, ChampionStatisticValue valType) { return _statistics[type][valType]; }
+	byte& getStatistic(ChampionStatisticType type, ChampionStatisticValue valType) { return _statistics[type][valType]; }
 	void setStatistic(ChampionStatisticType type, ChampionStatisticValue valType, byte newVal) { _statistics[type][valType] = newVal; }
 
 	uint16 getAttributes() { return _attributes; }
@@ -409,6 +412,10 @@ public:
 		_actionDefense = _food = _water = _load = _shieldDefense = 0;
 		memset(_portrait, 0, 464);
 	}
+	void resetSkillsToZero() {
+		for (int16 i = 0; i < 20; ++i)
+			_skills[i].resetToZero();
+	}
 }; // @ CHAMPION_INCLUDING_PORTRAIT
 
 class ChampionMan {
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index aa4290f..a28c14c 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -52,8 +52,8 @@
 
 namespace DM {
 
-int8 _dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount
-int8 _dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
+int8 gDirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount
+int8 gDirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
 
 void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
 void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); }
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index e9ab80f..5a7e548 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -56,8 +56,8 @@ enum direction {
 };
 
 // TODO: refactor direction into a class
-extern int8 _dirIntoStepCountEast[4];
-extern int8 _dirIntoStepCountNorth[4];
+extern int8 gDirIntoStepCountEast[4];
+extern int8 gDirIntoStepCountNorth[4];
 
 void turnDirRight(direction &dir);
 void turnDirLeft(direction &dir);
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index ac38a07..755a7d8 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -360,11 +360,11 @@ CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_Crea
 	{26,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}};
 
 void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
-	posX += _dirIntoStepCountEast[dir] * stepsForward;
-	posY += _dirIntoStepCountNorth[dir] * stepsForward;
+	posX += gDirIntoStepCountEast[dir] * stepsForward;
+	posY += gDirIntoStepCountNorth[dir] * stepsForward;
 	turnDirRight(dir);
-	posX += _dirIntoStepCountEast[dir] * stepsRight;
-	posY += _dirIntoStepCountNorth[dir] * stepsRight;
+	posX += gDirIntoStepCountEast[dir] * stepsRight;
+	posY += gDirIntoStepCountNorth[dir] * stepsRight;
 }
 
 DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) {
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 680c621..ca09421 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -32,6 +32,7 @@
 #include "dungeonman.h"
 #include "movesens.h"
 #include "objectman.h"
+#include "inventory.h"
 
 
 
@@ -517,8 +518,8 @@ void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() {
 	CurrMapData &currMap = dunMan._currMap;
 	uint16 mapX = currMap._partyPosX;
 	uint16 mapY = currMap._partyPosY;
-	mapX += _dirIntoStepCountEast[currMap._partyDir];
-	mapY += _dirIntoStepCountNorth[currMap._partyDir];
+	mapX += gDirIntoStepCountEast[currMap._partyDir];
+	mapY += gDirIntoStepCountNorth[currMap._partyDir];
 	if ((mapX >= 0)
 		&& (mapX < currMap._width)
 		&& (mapY >= 0)
@@ -542,8 +543,8 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 		}
 		mapX = currMap._partyPosX;
 		mapY = currMap._partyPosY;
-		mapX += _dirIntoStepCountEast[currMap._partyDir];
-		mapY += _dirIntoStepCountNorth[currMap._partyDir];
+		mapX += gDirIntoStepCountEast[currMap._partyDir];
+		mapY += gDirIntoStepCountNorth[currMap._partyDir];
 
 		if (champMan._leaderEmptyHanded) {
 			if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() &&
@@ -564,7 +565,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 				if (viewCell == kViewCellDoorButtonOrWallOrn) {
 					if (!dunMan._isFacingAlcove) {
 						commandProcessType80ClickInDungeonViewTouchFrontWall();
-					} 
+					}
 				} else {
 					warning("MISSING CODE: F0373_COMMAND_ProcessType80_ClickInDungeonView_GrabLeaderHandObject");
 				}
@@ -616,4 +617,83 @@ T0377019:
 	}
 }
 
+void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType) {
+	ChampionMan &champMan = *_vm->_championMan;
+	InventoryMan &invMan = *_vm->_inventoryMan;
+	DisplayMan &dispMan = *_vm->_displayMan;
+	CurrMapData &currMap = _vm->_dungeonMan->_currMap;
+	DungeonMan &dunMan = *_vm->_dungeonMan;
+
+	uint16 championIndex = champMan._partyChampionCount - 1;
+	Champion *champ = &champMan._champions[championIndex];
+	if (commandType == kCommandClickInPanelCancel) {
+		invMan.toggleInventory(kChampionCloseInventory);
+		champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kChampionNone);
+		if (champMan._partyChampionCount == 1) {
+			commandSetLeader(kChampionNone);
+		}
+		champMan._partyChampionCount--;
+		Box box;
+		box._y1 = 0;
+		box._y2 = 28 + 1;
+		box._x1 = championIndex * kChampionStatusBoxSpacing;
+		box._x2 = box._x1 + 66 + 1;
+		dispMan._useByteBoxCoordinates = false;
+		dispMan.clearScreenBox(kColorBlack, box);
+		dispMan.clearScreenBox(kColorBlack, gBoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._partyDir) * 2]);
+		warning("F0457_START_DrawEnabledMenus_CPSF");
+		warning("F0078_MOUSE_ShowPointer");
+		return;
+	}
+
+	champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kChampionNone);
+	int16 mapX = currMap._partyPosX;
+	int16 mapY = currMap._partyPosY;
+
+	mapX += gDirIntoStepCountEast[currMap._partyDir];
+	mapY += gDirIntoStepCountNorth[currMap._partyDir];
+	for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) {
+		Thing thing = champ->getSlot((ChampionSlot)slotIndex);
+		if (thing != Thing::_thingNone) {
+			warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList");
+		}
+	}
+	Thing thing = dunMan.getSquareFirstThing(mapX, mapY);
+	for (;;) { // infinite
+		if (thing.getType() == kSensorThingType) {
+			((Sensor*)dunMan.getThingData(thing))->setTypeDisabled();
+			break;
+		}
+		thing = dunMan.getNextThing(thing);
+	}
+
+	if (commandType == kCommandClickInPanelReincarnate) {
+		warning("MISSING CODE: F0281_CHAMPION_Rename");
+		champ->resetSkillsToZero();
+
+		for (uint16 i = 0; i < 12; i++) {
+			uint16 statIndex = _vm->_rnd->getRandomNumber(7);
+			champ->getStatistic((ChampionStatisticType)statIndex, kChampionStatCurrent)++; // returns reference
+			champ->getStatistic((ChampionStatisticType)statIndex, kChampionStatMaximum)++; // returns reference
+		}
+	}
+
+	if (champMan._partyChampionCount == 1) {
+		warning("MISSING CODE: setting time, G0362_l_LastPartyMovementTime , G0313_ul_GameTime");
+		commandSetLeader(kChampionFirst);
+		warning("MISSING CODE: F0394_MENUS_SetMagicCasterAndDrawSpellArea");
+	} else {
+		warning("MISSING CODE: F0393_MENUS_DrawSpellAreaControls");
+	}
+
+	warning("MISSING CODE: F0051_TEXT_MESSAGEAREA_PrintLineFeed");
+	Color champColor = gChampionColor[championIndex]; // unreferenced because of missing code
+	warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage");
+	warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage");
+
+	invMan.toggleInventory(kChampionCloseInventory);
+	warning("MISSING CODE: F0457_START_DrawEnabledMenus_CPSF");
+	warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal");
+}
+
 }; // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 1a4d663..fa47287 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -31,6 +31,7 @@
 #include "common/events.h"
 #include "common/queue.h"
 
+#include "dm.h"
 #include "gfx.h"
 #include "champion.h"
 
@@ -248,6 +249,7 @@ public:
 	void commandSetLeader(ChampionIndex index); // @ F0368_COMMAND_SetLeader
 	void commandProcessType80ClickInDungeonViewTouchFrontWall(); // @ F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall
 	void commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView
+	void commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType); // @ F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel
 };
 
 }
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index ab57883..2fd4f41 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -53,14 +53,14 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	EventManager &em = *_vm->_eventMan;
 	DisplayMan &dm = *_vm->_displayMan;
 
-	if ((championIndex == kChmpionCloseInventory) && !cm._champions[championIndex]._currHealth)
+	if ((championIndex == kChampionCloseInventory) && !cm._champions[championIndex]._currHealth)
 		return;
 	if (_vm->_pressingEye || _vm->_pressingMouth)
 		return;
 	_vm->_stopWaitingForPlayerInput = true;
 	int16 invChampOrdinal = _inventoryChampionOrdinal; // copy, as the original will be edited
 	if (_vm->indexToOrdinal(championIndex) == invChampOrdinal) {
-		championIndex = kChmpionCloseInventory;
+		championIndex = kChampionCloseInventory;
 	}
 
 	Champion *champion;
@@ -75,7 +75,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 		if (cm._partyIsSleeping) {
 			return;
 		}
-		if (championIndex == kChmpionCloseInventory) {
+		if (championIndex == kChampionCloseInventory) {
 			em._refreshMousePointerInMainLoop = true;
 			_vm->_menuMan->drawMovementArrows();
 			em._secondaryMouseInput = gSecondaryMouseInput_Movement;


Commit: b820a36d3a94e9510e313144378b789efe954fe4
    https://github.com/scummvm/scummvm/commit/b820a36d3a94e9510e313144378b789efe954fe4
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0378_COMMAND_ProcessType81_ClickInPanel

Changed paths:
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/inventory.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index ca09421..689d9fd 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -420,20 +420,11 @@ void EventManager::processCommandQueue() {
 	}
 
 	if (cmd._type == kCommandClickInDungeonView) {
-		/*warning("DUMMY CODE, all of this");
-		DungeonMan &dunMan = *_vm->_dungeonMan;
-		CurrMapData &currMap = dunMan._currMap;
-		uint16 mapX = currMap._partyPosX;
-		uint16 mapY = currMap._partyPosY;
-		mapX += gDirIntoStepCountEast[currMap._partyDir];
-		mapY += gDirIntoStepCountNorth[currMap._partyDir];
-		Thing squareFirstThing = dunMan.getSquareFirstThing(mapX, mapY);
-		Sensor sensor(dunMan.getThingData(squareFirstThing));
-		if (sensor.getType() == kSensorWallChampionPortrait) {
-			_vm->_championMan->addCandidateChampionToParty(sensor.getData());
-		}*/
 		commandProcessType80ClickInDungeonView(commandX, commandY);
 	}
+	if (cmd._type == kCommandClickInPanel) {
+		commandProcess81ClickInPanel(commandX, commandY);
+	}
 
 	// MISSING CODE: the rest of the function
 }
@@ -696,4 +687,27 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal");
 }
 
+void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) {
+	ChampionMan &champMan = *_vm->_championMan;
+	InventoryMan &invMan = *_vm->_inventoryMan;
+
+	CommandType commandType;
+	switch (invMan._panelContent) {
+	case kPanelContentChest:
+		if (champMan._leaderIndex == kChampionNone) // if no leader
+			return;
+		commandType = getCommandTypeFromMouseInput(gMouseInput_PanelChest, Common::Point(x, y), kLeftMouseButton);
+		if (commandType != kCommandNone)
+			warning("MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox");
+		break;
+	case kPanelContentResurrectReincarnate:
+		if (!champMan._leaderEmptyHanded)
+			break;
+		commandType = getCommandTypeFromMouseInput(gMouseInput_PanelChest, Common::Point(x, y), kLeftMouseButton);
+		if (commandType != kCommandNone)
+			commandProcessCommands160To162ClickInResurrectReincarnatePanel(commandType);
+		break;
+	}
+}
+
 }; // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index fa47287..ca95877 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -250,6 +250,7 @@ public:
 	void commandProcessType80ClickInDungeonViewTouchFrontWall(); // @ F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall
 	void commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView
 	void commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType); // @ F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel
+	void commandProcess81ClickInPanel(int16 x, int16 y); // @ F0378_COMMAND_ProcessType81_ClickInPanel
 };
 
 }
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 2fd4f41..550c4c8 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -53,7 +53,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	EventManager &em = *_vm->_eventMan;
 	DisplayMan &dm = *_vm->_displayMan;
 
-	if ((championIndex == kChampionCloseInventory) && !cm._champions[championIndex]._currHealth)
+	if ((championIndex != kChampionCloseInventory) && !cm._champions[championIndex]._currHealth)
 		return;
 	if (_vm->_pressingEye || _vm->_pressingMouth)
 		return;


Commit: c392f7e9772ad2d5a23b6c8407afa0f32ce4ebbc
    https://github.com/scummvm/scummvm/commit/c392f7e9772ad2d5a23b6c8407afa0f32ce4ebbc
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/menus.cpp
    engines/dm/menus.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 03515a0..f1c3c5e 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -255,7 +255,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	_candidateChampionOrdinal = prevChampCount + 1;
 	if (++_partyChampionCount == 1) {
 		_vm->_eventMan->commandSetLeader(kChampionFirst);
-		_vm->_menuMan->_shouldRefreshActionArea = true;
+		_vm->_menuMan->_refreshActionArea = true;
 	} else {
 		_vm->_menuMan->clearActingChampion();
 		_vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1));
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index a28c14c..eab2d14 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -213,16 +213,20 @@ void DMEngine::gameloop() {
 
 	warning("DUMMY CODE: setting InventoryMan::_inventoryChampionOrdinal to zero");
 	_inventoryMan->_inventoryChampionOrdinal = 0;
-	warning("DUMMY CODE: clearing screen to black");
+	warning("DUMMY CODE: clearing screen to black"); // in loop below
 	while (true) {
 		_stopWaitingForPlayerInput = false;
+
+		_menuMan->refreshActionAreaAndSetChampDirMaxDamageReceived();
+
 		//do {
 		_eventMan->processInput();
 		_eventMan->processCommandQueue();
 		//} while (!_stopWaitingForPlayerInput || !_gameTimeTicking);
 
 		if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) {
-			_displayMan->clearScreen(kColorBlack); // dummy code
+			Box box(0, 0 + 224 + 1, 33, 33 + 126 + 1);
+			_displayMan->clearScreenBox(kColorBlack, box); // dummy code
 			_displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY);
 		}
 		// DUMMY CODE: next line
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index f83fa6e..25ed432 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -38,8 +38,9 @@ namespace DM {
 byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
 
 MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
-	_shouldRefreshActionArea = false;
+	_refreshActionArea = false;
 	_actionAreaContainsIcons = false;
+	_actionDamage = 0;
 }
 
 void MenuMan::drawMovementArrows() {
@@ -57,7 +58,7 @@ void MenuMan::clearActingChampion() {
 		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true);
 		cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal);
 		cm._actingChampionOrdinal = _vm->indexToOrdinal(kChampionNone);
-		_shouldRefreshActionArea = true;
+		_refreshActionArea = true;
 	}
 }
 
@@ -118,4 +119,55 @@ void MenuMan::drawDisabledMenu() {
 	}
 }
 
+void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
+	ChampionMan &champMan = *_vm->_championMan;
+
+	if (!champMan._partyChampionCount)
+		return;
+
+	Champion *champ = nullptr;
+	if (champMan._partyIsSleeping || champMan._candidateChampionOrdinal) {
+		if (champMan._actingChampionOrdinal) {
+			clearActingChampion();
+			return;
+		}
+		if (!champMan._candidateChampionOrdinal)
+			return;
+	} else {
+		champ = champMan._champions;
+		int16 champIndex = kChampionFirst;
+
+		do {
+			if ((champIndex != champMan._leaderIndex)
+				&& (_vm->indexToOrdinal(champIndex) != champMan._actingChampionOrdinal)
+				&& (champ->_maximumDamageReceived)
+				&& (champ->_dir != champ->_directionMaximumDamageReceived)) {
+
+				champ->_dir = (direction)champ->_directionMaximumDamageReceived;
+				champ->setAttributeFlag(kChampionAttributeIcon, true);
+				champMan.drawChampionState((ChampionIndex)champIndex);
+			}
+			champ->_maximumDamageReceived = 0;
+			champ++;
+			champIndex++;
+		} while (champIndex < champMan._partyChampionCount);
+	}
+
+	if (_refreshActionArea) {
+		if (!champMan._actingChampionOrdinal) {
+			if (_actionDamage) {
+				warning("MISSING CODE: F0385_MENUS_DrawActionDamage");
+				_actionDamage = 0;
+			} else {
+				_actionAreaContainsIcons = true;
+				warning("MISSING CODE: F0387_MENUS_DrawActionArea");
+			}
+		} else {
+			_actionAreaContainsIcons = false;
+			champ->setAttributeFlag(kChampionAttributeActionHand, true);
+			champMan.drawChampionState((ChampionIndex)_vm->ordinalToIndex(champMan._actingChampionOrdinal));
+			warning("MISSING CODE: F0387_MENUS_DrawActionArea");
+		}
+	}
+}
 }
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 91f89cd..3562ced 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -38,14 +38,16 @@ class MenuMan {
 public:
 	explicit MenuMan(DMEngine *vm);
 
-	bool _shouldRefreshActionArea; // @ G0508_B_RefreshActionArea
+	bool _refreshActionArea; // @ G0508_B_RefreshActionArea
 	bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons
+	int16 _actionDamage;
 
 	void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
 	void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon
 
 	void drawMovementArrows(); // @ F0395_MENUS_DrawMovementArrows
 	void drawDisabledMenu(); // @ F0456_START_DrawDisabledMenus
+	void refreshActionAreaAndSetChampDirMaxDamageReceived(); // @ F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived
 };
 
 }


Commit: dad087454c87059736fa69543124c7ac44085085
    https://github.com/scummvm/scummvm/commit/dad087454c87059736fa69543124c7ac44085085
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing load display in ChampionMan::drawChampionState

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index f1c3c5e..ef4257f 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -529,11 +529,27 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		}
 	}
 
-	if (champAttributes & kChampionAttributeLoad) {
-		warning("MISSING CODE: whole if branch, many F0052_TEXT_PrintToViewport-s");
-
-
-
+	if ((champAttributes & kChampionAttributeLoad) && isInventoryChamp) {
+		Color loadColor;
+		int16 champMaxLoad = getMaximumLoad(champ);
+		if (champ->_load > champMaxLoad) {
+			loadColor = kColorRed;
+		} else if (((int32)champ->_load) * 8 > ((int32)champMaxLoad) * 5) {
+			loadColor = kColorYellow;
+		} else {
+			loadColor = kColorLightestGray;
+		}
+		_vm->_textMan->printToViewport(104, 132, loadColor, "LOAD ");
+
+		int16 loadTmp = champ->_load / 10;
+		Common::String str = getStringFromInteger(loadTmp, true, 3);
+		str += '.';
+		loadTmp = champ->_load - (loadTmp * 10);
+		str += getStringFromInteger(loadTmp, false, 1);
+		str += '/';
+		loadTmp = (getMaximumLoad(champ) + 5) / 10;
+		str += "KG";
+		_vm->_textMan->printToViewport(148, 132, loadColor, str.c_str());
 		champAttributes |= kChampionAttributeViewport;
 	}
 


Commit: 9c544a44f22cdf15662f90d0cdffe5770a77ce4c
    https://github.com/scummvm/scummvm/commit/9c544a44f22cdf15662f90d0cdffe5770a77ce4c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add renameChampion stub, fix wrong inputArray EventManager::commandProcess81ClickInPanel

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index ef4257f..8b4149b 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -38,12 +38,12 @@ namespace DM {
 
 Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
 Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
-Box gBoxChampionIcons[4] = { 
+Box gBoxChampionIcons[4] = {
 	Box(281, 299,  0, 13),
 	Box(301, 319,  0, 13),
 	Box(301, 319, 15, 28),
 	Box(281, 299, 15, 28)};
-Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; 
+Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14};
 
 uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
 	/* 30 for champion inventory, 8 for chest */
@@ -312,7 +312,7 @@ T0280046:
 					slotIndex_Green = AL_0_slotIndex_Red++;
 				}
 				break;
-			
+
 			default:
 				break;
 			}
@@ -690,7 +690,32 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 	}
 }
 
+void ChampionMan::renameChampion(Champion* champ) {
+	warning("STUB METHOD: Champion::renameChampion, F0281_CHAMPION_Rename");
+
+	DisplayMan &dispMan = *_vm->_displayMan;
+	TextMan &textMan = *_vm->_textMan;
 
+	Box box;
+	box._y1 = 3;
+	box._y2 = 8 + 1;
+	box._x1 = 3;
+	box._x2 = box._x1 + 167;
+
+	dispMan.clearScreenBox(kColorDarkestGray, box, gDungeonViewport);
+	dispMan.blitToScreen(dispMan.getBitmap(kPanelRenameChampionIndice), 144, 0, 0, gBoxPanel, kColorCyan, gDungeonViewport);
+	textMan.printToViewport(177, 58, kColorLightestGray, "_______");
+	textMan.printToViewport(105, 76, kColorLightestGray, "___________________");
+	Common::Point clickPos;
+	static Box okButtonBox(197, 215, 147, 155); // inclusive boundaries, constructor adds +1
+	for (;;) {
+		_vm->_eventMan->processInput();
+		if (_vm->_eventMan->hasPendingClick(clickPos, kLeftMouseButton) && okButtonBox.isPointInside(clickPos)) {
+			return;
+		}
+		dispMan.updateScreen();
+	}
+}
 }
 
 
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 1a89bc2..d5e74a6 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -451,6 +451,7 @@ public:
 	uint16 championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX
 	void drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues
 	void drawSlot(uint16 champIndex, ChampionSlot slotIndex); // @ F0291_CHAMPION_DrawSlot
+	void renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename
 };
 
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index eab2d14..a3479d2 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -225,8 +225,8 @@ void DMEngine::gameloop() {
 		//} while (!_stopWaitingForPlayerInput || !_gameTimeTicking);
 
 		if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) {
-			Box box(0, 0 + 224 + 1, 33, 33 + 126 + 1);
-			_displayMan->clearScreenBox(kColorBlack, box); // dummy code
+			Box box(0, 224, 0, 126);
+			_displayMan->clearScreenBox(kColorBlack, box, gDungeonViewport); // dummy code
 			_displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY);
 		}
 		// DUMMY CODE: next line
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 689d9fd..0a79b19 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -659,7 +659,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	}
 
 	if (commandType == kCommandClickInPanelReincarnate) {
-		warning("MISSING CODE: F0281_CHAMPION_Rename");
+		champMan.renameChampion(champ);
 		champ->resetSkillsToZero();
 
 		for (uint16 i = 0; i < 12; i++) {
@@ -703,11 +703,17 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) {
 	case kPanelContentResurrectReincarnate:
 		if (!champMan._leaderEmptyHanded)
 			break;
-		commandType = getCommandTypeFromMouseInput(gMouseInput_PanelChest, Common::Point(x, y), kLeftMouseButton);
+		commandType = getCommandTypeFromMouseInput(gMouseInput_PanelResurrectReincarnateCancel, Common::Point(x, y), kLeftMouseButton);
 		if (commandType != kCommandNone)
 			commandProcessCommands160To162ClickInResurrectReincarnatePanel(commandType);
 		break;
 	}
 }
 
+	bool EventManager::hasPendingClick(Common::Point& point, MouseButton button)
+	{
+		if (_pendingClickButton && button == _pendingClickButton)
+			point = _pendingClickPos;
+		return _pendingClickPresent;
+	}
 }; // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index ca95877..ca60c46 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -251,6 +251,8 @@ public:
 	void commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView
 	void commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType); // @ F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel
 	void commandProcess81ClickInPanel(int16 x, int16 y); // @ F0378_COMMAND_ProcessType81_ClickInPanel
+
+	bool hasPendingClick(Common::Point &point, MouseButton button);
 };
 
 }
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index e73c44e..5db354d 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -70,7 +70,8 @@ enum GraphicIndice {
 	kSlotBoxWoundedIndice = 34, // @ C034_GRAPHIC_SLOT_BOX_WOUNDED                  
 	kChampionIcons = 28, // @ C028_GRAPHIC_CHAMPION_ICONS
 	kFontGraphicIndice = 557, // @ C557_GRAPHIC_FONT 
-	kSlotBoxActingHandIndice = 35 // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND
+	kSlotBoxActingHandIndice = 35, // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND
+	kPanelRenameChampionIndice = 27 // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION
 };
 
 extern uint16 gPalSwoosh[16];
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 550c4c8..f6fe61f 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -37,7 +37,7 @@
 namespace DM {
 
 Box gBoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
-Box gBoxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel
+Box gBoxPanel = Box(80, 223, 52, 124);
 Box gBoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food
 Box gBoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
 Box gBoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 6c34e2a..f225e41 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -36,6 +36,8 @@ namespace DM {
 #define kChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING
 
 
+extern Box gBoxPanel; // @ G0032_s_Graphic562_Box_Panel
+
 enum PanelContent {
 	kPanelContentFoodWaterPoisoned = 0, // @ C00_PANEL_FOOD_WATER_POISONED
 	kPanelContentScroll = 2, // @ C02_PANEL_SCROLL


Commit: d893075343c8b27a6f20eab436fea6aa6b02d800
    https://github.com/scummvm/scummvm/commit/d893075343c8b27a6f20eab436fea6aa6b02d800
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix unused viewport in DisplayMan::clearScreenBox

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index f5d5883..f1a93a1 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1578,8 +1578,8 @@ byte* DisplayMan::getBitmap(uint16 index) {
 
 void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) {
 	uint16 width = box._x2 - box._x1;
-	for (int y = box._y1; y < box._y2; ++y)
-		memset(_vgaBuffer + y * _screenWidth + box._x1, color, sizeof(byte) * width);
+	for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y)
+		memset(_vgaBuffer + y * _screenWidth + box._x1 + viewport._posX, color, sizeof(byte) * width);
 }
 
 void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,


Commit: 12d359166ca87d74cfe6598162d78da97939c0d3
    https://github.com/scummvm/scummvm/commit/12d359166ca87d74cfe6598162d78da97939c0d3
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0387_MENUS_DrawActionArea

Changed paths:
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/menus.h
    engines/dm/text.cpp
    engines/dm/text.h



diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 5db354d..d3e1947 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -71,7 +71,8 @@ enum GraphicIndice {
 	kChampionIcons = 28, // @ C028_GRAPHIC_CHAMPION_ICONS
 	kFontGraphicIndice = 557, // @ C557_GRAPHIC_FONT 
 	kSlotBoxActingHandIndice = 35, // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND
-	kPanelRenameChampionIndice = 27 // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION
+	kPanelRenameChampionIndice = 27, // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION
+	kMenuActionAreaIndice = 10 // @ C010_GRAPHIC_MENU_ACTION_AREA
 };
 
 extern uint16 gPalSwoosh[16];
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index f6fe61f..550c4c8 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -37,7 +37,7 @@
 namespace DM {
 
 Box gBoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
-Box gBoxPanel = Box(80, 223, 52, 124);
+Box gBoxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel
 Box gBoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food
 Box gBoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
 Box gBoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 25ed432..ec87a3b 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -31,10 +31,15 @@
 #include "dungeonman.h"
 #include "objectman.h"
 #include "inventory.h"
+#include "text.h"
 
 
 namespace DM {
 
+Box  gBoxActionArea3ActionMenu = Box(224, 319, 77, 121); // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu
+Box  gBoxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
+Box  gBoxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
+Box gBoxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea 
 byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
 
 MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
@@ -160,7 +165,7 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
 				_actionDamage = 0;
 			} else {
 				_actionAreaContainsIcons = true;
-				warning("MISSING CODE: F0387_MENUS_DrawActionArea");
+				drawActionArea();
 			}
 		} else {
 			_actionAreaContainsIcons = false;
@@ -170,4 +175,52 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
 		}
 	}
 }
+
+#define kChampionNameMaximumLength 7 // @ C007_CHAMPION_NAME_MAXIMUM_LENGTH
+#define kActionNameMaximumLength 12 // @ C012_ACTION_NAME_MAXIMUM_LENGTH
+
+void MenuMan::drawActionArea() {
+	DisplayMan &dispMan = *_vm->_displayMan;
+	ChampionMan &champMan = *_vm->_championMan;
+	TextMan &textMan = *_vm->_textMan;
+
+	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+	dispMan._useByteBoxCoordinates = false;
+	dispMan.clearScreenBox(kColorBlack, gBoxActionArea);
+	if (_actionAreaContainsIcons) {
+		for (uint16 champIndex = kChampionFirst; champIndex < champMan._partyChampionCount; ++champIndex)
+			drawActionIcon((ChampionIndex)champIndex);
+	} else if (champMan._actingChampionOrdinal) {
+		Box box = gBoxActionArea3ActionMenu;
+		if (_actionList._actionIndices[2] == kChampionActionNone)
+			box = gBoxActionArea2ActionMenu;
+		if (_actionList._actionIndices[1] == kChampionActionNone)
+			box = gBoxActionArea1ActionMenu;
+		dispMan.blitToScreen(dispMan.getBitmap(kMenuActionAreaIndice), 96, 0, 0, box, kColorNoTransparency);
+		textMan.printWithTrailingSpacesToScreen(235, 83, kColorBlack, kColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._actingChampionOrdinal)]._name,
+												kChampionNameMaximumLength);
+		for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) {
+			textMan.printWithTrailingSpacesToScreen(241, 93 + actionListIndex * 12, kColorCyan, kColorBlack,
+													getActionName(_actionList._actionIndices[actionListIndex]),
+													kActionNameMaximumLength);
+		}
+	}
+	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+	_refreshActionArea = false;
+}
+
+const char *gChampionActionNames[44] = {
+	"N", "BLOCK", "CHOP", "X", "BLOW HORN", "FLIP", "PUNCH",
+	"KICK", "WAR CRY", "STAB", "CLIMB DOWN", "FREEZE LIFE",
+	"HIT", "SWING", "STAB", "THRUST", "JAB", "PARRY", "HACK",
+	"BERZERK", "FIREBALL", "DISPELL", "CONFUSE", "LIGHTNING",
+	"DISRUPT", "MELEE", "X", "INVOKE", "SLASH", "CLEAVE",
+	"BASH", "STUN", "SHOOT", "SPELLSHIELD", "FIRESHIELD",
+	"FLUXCAGE", "HEAL", "CALM", "LIGHT", "WINDOW", "SPIT",
+	"BRANDISH", "THROW", "FUSE"};
+
+const char* MenuMan::getActionName(ChampionAction actionIndex) {
+	return (actionIndex == kChampionActionNone) ? "" : gChampionActionNames[actionIndex];
+}
+
 }
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 3562ced..4ae7784 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -33,6 +33,20 @@
 
 namespace DM {
 
+extern Box gBoxActionArea;
+
+class ActionList {
+public:
+	byte _minimumSkillLevel[3]; /* Bit 7: requires charge, Bit 6-0: minimum skill level. */
+	ChampionAction _actionIndices[3];
+	ActionList() {
+		for (uint16 i = 0; i < 3; ++i) {
+			_minimumSkillLevel[i] = 0;
+			_actionIndices[i] = kChampionActionNone;
+		}
+	}
+}; // @ ACTION_LIST
+
 class MenuMan {
 	DMEngine *_vm;
 public:
@@ -40,7 +54,8 @@ public:
 
 	bool _refreshActionArea; // @ G0508_B_RefreshActionArea
 	bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons
-	int16 _actionDamage;
+	int16 _actionDamage; // @ G0513_i_ActionDamage
+	ActionList _actionList; // @ G0713_s_ActionList
 
 	void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
 	void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon
@@ -48,6 +63,8 @@ public:
 	void drawMovementArrows(); // @ F0395_MENUS_DrawMovementArrows
 	void drawDisabledMenu(); // @ F0456_START_DrawDisabledMenus
 	void refreshActionAreaAndSetChampDirMaxDamageReceived(); // @ F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived
+	void drawActionArea(); // @ F0387_MENUS_DrawActionArea
+	const char* getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName
 };
 
 }
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 3adc1a9..ab22ac4 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -60,7 +60,7 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16
 			break;
 		uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
 		_vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth,
-									   (nextX == destX) ? (nextX + 1) : nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight, kColorNoTransparency, viewport);
+			(nextX == destX) ? (nextX + 1) : nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight, kColorNoTransparency, viewport);
 		nextX += kLetterWidth + 1;
 	}
 }
@@ -73,4 +73,17 @@ void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const cha
 	printTextToScreen(posX, posY, textColor, kColorDarkestGray, text, gDungeonViewport);
 }
 
+void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor,
+									  Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight, Viewport& viewport) {
+	Common::String str = text;
+	for (int16 i = str.size(); i < requiredTextLength; ++i)
+		str += ' ';
+	printTextToBitmap(destBitmap, destPixelWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight, viewport);
+}
+
+void TextMan::printWithTrailingSpacesToScreen(int16 destX, int16 destY, Color textColor, Color bgColor, const char* text, int16 strLenght, Viewport& viewport) {
+	printWithTrailingSpaces(_vm->_displayMan->_vgaBuffer, _vm->_displayMan->_screenWidth, destX, destY,
+							textColor, bgColor, text, strLenght, _vm->_displayMan->_screenHeight, viewport);
+}
+
 }
diff --git a/engines/dm/text.h b/engines/dm/text.h
index 1a413ee..b03d00a 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -41,6 +41,10 @@ public:
 						   Color textColor, Color bgColor, const char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print
 	void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, Viewport &viewport = gDefultViewPort); // @ F0053_TEXT_PrintToLogicalScreen
 	void printToViewport(int16 posX, int16 posY, Color textColor, const char *text); // @ F0052_TEXT_PrintToViewport
+	void printWithTrailingSpaces(byte *destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, Color bgColor,
+								 const char *text, int16 strLenght, int16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0041_TEXT_PrintWithTrailingSpaces
+	void printWithTrailingSpacesToScreen(int16 destX, int16 destY, Color textColor, Color bgColor,
+								 const char *text, int16 strLenght, Viewport &viewport = gDefultViewPort); // @ F0041_TEXT_PrintWithTrailingSpaces
 };
 
 }


Commit: 5893dc7c981a3131882f705a5058a5e4e6af660f
    https://github.com/scummvm/scummvm/commit/5893dc7c981a3131882f705a5058a5e4e6af660f
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0393_MENUS_DrawSpellAreaControls

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/eventman.cpp
    engines/dm/menus.cpp
    engines/dm/menus.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 8b4149b..b8676c8 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -95,6 +95,7 @@ ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
 	_partyIsSleeping = false;
 	_leaderHandObjectIconIndex = kIconIndiceNone;
 	_leaderEmptyHanded = true;
+	_magicCasterChampionIndex = kChampionNone;
 }
 
 uint16 ChampionMan::getChampionPortraitX(uint16 index) {
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index d5e74a6..3e72be3 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -440,6 +440,7 @@ public:
 	IconIndice _leaderHandObjectIconIndex; // @ G0413_i_LeaderHandObjectIconIndex
 	bool _leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded
 	Party _party; // @ G0407_s_Party
+	ChampionIndex _magicCasterChampionIndex; // @ G0514_i_MagicCasterChampionIndex
 
 	explicit ChampionMan(DMEngine *vm);
 	void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 0a79b19..9ebda0f 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -33,6 +33,7 @@
 #include "movesens.h"
 #include "objectman.h"
 #include "inventory.h"
+#include "menus.h"
 
 
 
@@ -674,7 +675,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 		commandSetLeader(kChampionFirst);
 		warning("MISSING CODE: F0394_MENUS_SetMagicCasterAndDrawSpellArea");
 	} else {
-		warning("MISSING CODE: F0393_MENUS_DrawSpellAreaControls");
+		_vm->_menuMan->drawSpellAreaControls(champMan._magicCasterChampionIndex);
 	}
 
 	warning("MISSING CODE: F0051_TEXT_MESSAGEAREA_PrintLineFeed");
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index ec87a3b..8014a82 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -223,4 +223,75 @@ const char* MenuMan::getActionName(ChampionAction actionIndex) {
 	return (actionIndex == kChampionActionNone) ? "" : gChampionActionNames[actionIndex];
 }
 
+
+Box gBoxSpellAreaControls = Box(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls 
+
+void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
+	ChampionMan &champMan = *_vm->_championMan;
+	DisplayMan &dispMan = *_vm->_displayMan;
+	TextMan &textMan = *_vm->_textMan;
+
+	Champion &champ = champMan._champions[champIndex];
+	int16 champCurrHealth[4];
+	for (uint16 i = 0; i < 4; ++i)
+		champCurrHealth[i] = champMan._champions[i]._currHealth;
+	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+	dispMan.clearScreenBox(kColorBlack, gBoxSpellAreaControls);
+	int16 champCount = champMan._partyChampionCount;
+	switch (champIndex) {
+	case kChampionFirst:
+		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		textMan.printTextToScreen(235, 48, kColorBlack, kColorCyan, champ._name);
+		if (champCount) {
+			if (champCurrHealth[1]) {
+				warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+			}
+labelChamp2:
+			if (champCount > 2) {
+				if (champCurrHealth[2]) {
+					warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+				}
+labelChamp3:
+				if (champCount > 3) {
+					if (champCurrHealth[3]) {
+						warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+					}
+				}
+			}
+		}
+		break;
+	case kChampionSecond:
+		if (champCurrHealth[0]) {
+			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		}
+		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		textMan.printTextToScreen(249, 48, kColorBlack, kColorCyan, champ._name);
+		goto labelChamp2;
+	case kChampionThird:
+		if (champCurrHealth[0]) {
+			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		}
+		if (champCurrHealth[1]) {
+			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		}
+		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		textMan.printTextToScreen(263, 48, kColorBlack, kColorCyan, champ._name);
+		goto labelChamp3;
+	case kChampionFourth:
+		if (champCurrHealth[0]) {
+			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		}
+		if (champCurrHealth[1]) {
+			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		}
+		if (champCurrHealth[2]) {
+			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		}
+		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		textMan.printTextToScreen(277, 48, kColorBlack, kColorCyan, champ._name);
+		break;
+	}
+	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+}
+
 }
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 4ae7784..ac2f462 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -65,6 +65,7 @@ public:
 	void refreshActionAreaAndSetChampDirMaxDamageReceived(); // @ F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived
 	void drawActionArea(); // @ F0387_MENUS_DrawActionArea
 	const char* getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName
+	void drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls
 };
 
 }


Commit: fc6837b9648797df5bc48cdde1b38e714b86187b
    https://github.com/scummvm/scummvm/commit/fc6837b9648797df5bc48cdde1b38e714b86187b
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0392_MENUS_BuildSpellAreaLine

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/menus.cpp
    engines/dm/menus.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index f1a93a1..7466cb4 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -817,7 +817,12 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uin
 		}
 }
 
-void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
+	void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent, Viewport& viewport)
+	{
+		blitToBitmap(srcBitmap, srcWidth, srcX, srcY, destBitmap, destWidth, box._x1, box._x2, box._y1, box._y2, transparent, viewport);
+	}
+
+	void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 							  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
 							  Color transparent, Viewport &viewport) {
 	blitToBitmap(srcBitmap, srcWidth, srcX, srcY,
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index d3e1947..209559b 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -72,7 +72,8 @@ enum GraphicIndice {
 	kFontGraphicIndice = 557, // @ C557_GRAPHIC_FONT 
 	kSlotBoxActingHandIndice = 35, // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND
 	kPanelRenameChampionIndice = 27, // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION
-	kMenuActionAreaIndice = 10 // @ C010_GRAPHIC_MENU_ACTION_AREA
+	kMenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA
+	kMenuSpellAreLinesIndice = 11 // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES
 };
 
 extern uint16 gPalSwoosh[16];
@@ -336,6 +337,8 @@ public:
 					  byte *destBitmap, uint16 destWidth,
 					  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
 					  Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort);
+	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
+					  byte *destBitmap, uint16 destWidth, Box &box, Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort);
 	void blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight,
 										 byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 8014a82..02a6689 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -42,10 +42,19 @@ Box  gBoxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_
 Box gBoxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea 
 byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
 
+Box gBoxSpellAreaLine = Box(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine 
+Box gBoxSpellAreaLine2 = Box(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 
+Box gBoxSpellAreaLine3 = Box(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 
+
 MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
 	_refreshActionArea = false;
 	_actionAreaContainsIcons = false;
 	_actionDamage = 0;
+	_bitmapSpellAreaLine = new byte[96 * 12];
+}
+
+MenuMan::~MenuMan() {
+	delete[] _bitmapSpellAreaLine;
 }
 
 void MenuMan::drawMovementArrows() {
@@ -294,4 +303,34 @@ labelChamp3:
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 
+#define kSpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
+#define kSpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
+
+void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
+	DisplayMan &dispMan = *_vm->_displayMan;
+
+	Champion &champ = _vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
+	if (spellAreaBitmapLine == kSpellAreaAvailableSymbols) {
+		dispMan._useByteBoxCoordinates = false;
+		dispMan.blitToBitmap(dispMan.getBitmap(kMenuSpellAreLinesIndice), 96, 0, 12, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, kColorNoTransparency);
+		int16 x = 1;
+		char c = 96 + (6 * champ._symbolStep);
+		char spellSymbolString[2] = {'\0', '\0'};
+		for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
+			spellSymbolString[0] = c++;
+			_vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 14, 8, kColorCyan, kColorBlack, spellSymbolString, 12);
+		}
+	} else if (spellAreaBitmapLine == kSpellAreaChampionSymbols) {
+		dispMan._useByteBoxCoordinates = false;
+		dispMan.blitToBitmap(dispMan.getBitmap(kMenuSpellAreLinesIndice), 96, 0, 24, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, kColorNoTransparency);
+		int16 x = 8;
+		char spellSymbolString[2] = {'\0', '\0'};
+		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
+			if ((spellSymbolString[0] = champ._symbols[symbolIndex]) == '\0')
+				break;
+			_vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 9, 8, kColorCyan, kColorBlack, spellSymbolString, 12);
+		}
+	}
+}
+
 }
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index ac2f462..b4006e1 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -51,11 +51,13 @@ class MenuMan {
 	DMEngine *_vm;
 public:
 	explicit MenuMan(DMEngine *vm);
+	~MenuMan();
 
 	bool _refreshActionArea; // @ G0508_B_RefreshActionArea
 	bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons
 	int16 _actionDamage; // @ G0513_i_ActionDamage
 	ActionList _actionList; // @ G0713_s_ActionList
+	byte *_bitmapSpellAreaLine; // @ K0072_puc_Bitmap_SpellAreaLine
 
 	void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
 	void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon
@@ -66,6 +68,7 @@ public:
 	void drawActionArea(); // @ F0387_MENUS_DrawActionArea
 	const char* getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName
 	void drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls
+	void buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine
 };
 
 }


Commit: 72506aebba96dec6e709a6efc8577ebee40407f9
    https://github.com/scummvm/scummvm/commit/72506aebba96dec6e709a6efc8577ebee40407f9
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add MenuMan::setMagicCasterAndDrawSpellArea

Changed paths:
    engines/dm/eventman.cpp
    engines/dm/gfx.h
    engines/dm/menus.cpp
    engines/dm/menus.h



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 9ebda0f..4e5a59c 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -673,7 +673,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	if (champMan._partyChampionCount == 1) {
 		warning("MISSING CODE: setting time, G0362_l_LastPartyMovementTime , G0313_ul_GameTime");
 		commandSetLeader(kChampionFirst);
-		warning("MISSING CODE: F0394_MENUS_SetMagicCasterAndDrawSpellArea");
+		_vm->_menuMan->setMagicCasterAndDrawSpellArea(kChampionFirst);
 	} else {
 		_vm->_menuMan->drawSpellAreaControls(champMan._magicCasterChampionIndex);
 	}
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 209559b..9354b99 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -73,7 +73,8 @@ enum GraphicIndice {
 	kSlotBoxActingHandIndice = 35, // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND
 	kPanelRenameChampionIndice = 27, // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION
 	kMenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA
-	kMenuSpellAreLinesIndice = 11 // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES
+	kMenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES
+	kMenuSpellAreaBackground = 9 // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND
 };
 
 extern uint16 gPalSwoosh[16];
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 02a6689..47c35b9 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -45,6 +45,7 @@ byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 Box gBoxSpellAreaLine = Box(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine 
 Box gBoxSpellAreaLine2 = Box(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 
 Box gBoxSpellAreaLine3 = Box(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 
+Box gBoxSpellArea = Box(224, 319, 77, 121); 
 
 MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
 	_refreshActionArea = false;
@@ -333,4 +334,35 @@ void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
 	}
 }
 
+	void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex)
+	{
+		ChampionMan &champMan = *_vm->_championMan;
+		DisplayMan &dispMan = *_vm->_displayMan;
+		
+		if((champIndex == champMan._magicCasterChampionIndex) 
+		   || ((champIndex != kChampionNone) && !champMan._champions[champIndex]._currHealth))
+			return;
+		if (champMan._magicCasterChampionIndex == kChampionNone) {
+			warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+			dispMan.blitToScreen(dispMan.getBitmap(kMenuSpellAreaBackground), 96, 0, 0, gBoxSpellArea);
+			warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+		}
+		if (champIndex == kChampionNone) {
+			champMan._magicCasterChampionIndex = kChampionNone;
+			warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+			dispMan._useByteBoxCoordinates = false;
+			dispMan.clearScreenBox(kColorBlack, gBoxSpellArea);
+			warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+			return;
+		}
+
+		champMan._magicCasterChampionIndex = champIndex;
+		buildSpellAreaLine(kSpellAreaAvailableSymbols);
+		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+		drawSpellAreaControls((ChampionIndex)champIndex);
+		dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine2);
+		buildSpellAreaLine(kSpellAreaChampionSymbols);
+		dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine3);
+		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+	}
 }
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index b4006e1..a8df735 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -33,7 +33,8 @@
 
 namespace DM {
 
-extern Box gBoxActionArea;
+extern Box gBoxActionArea; // @ G0001_s_Graphic562_Box_ActionArea
+extern Box gBoxSpellArea; // @ G0000_s_Graphic562_Box_SpellArea
 
 class ActionList {
 public:
@@ -69,6 +70,7 @@ public:
 	const char* getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName
 	void drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls
 	void buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine
+	void setMagicCasterAndDrawSpellArea(int16 champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea
 };
 
 }


Commit: bcd7c1d763e9ad8e5455808bcb7a6d5614035914
    https://github.com/scummvm/scummvm/commit/bcd7c1d763e9ad8e5455808bcb7a6d5614035914
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix possible bug in MenuMan::setMagicCasterAndDrawSpellArea

Changed paths:
    engines/dm/menus.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 47c35b9..dfbe5b5 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -45,7 +45,7 @@ byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 Box gBoxSpellAreaLine = Box(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine 
 Box gBoxSpellAreaLine2 = Box(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 
 Box gBoxSpellAreaLine3 = Box(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 
-Box gBoxSpellArea = Box(224, 319, 77, 121); 
+Box gBoxSpellArea = Box(224, 319, 77, 121);
 
 MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
 	_refreshActionArea = false;
@@ -315,7 +315,7 @@ void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
 		dispMan._useByteBoxCoordinates = false;
 		dispMan.blitToBitmap(dispMan.getBitmap(kMenuSpellAreLinesIndice), 96, 0, 12, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, kColorNoTransparency);
 		int16 x = 1;
-		char c = 96 + (6 * champ._symbolStep);
+		byte c = 96 + (6 * champ._symbolStep);
 		char spellSymbolString[2] = {'\0', '\0'};
 		for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
 			spellSymbolString[0] = c++;
@@ -324,8 +324,8 @@ void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
 	} else if (spellAreaBitmapLine == kSpellAreaChampionSymbols) {
 		dispMan._useByteBoxCoordinates = false;
 		dispMan.blitToBitmap(dispMan.getBitmap(kMenuSpellAreLinesIndice), 96, 0, 24, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, kColorNoTransparency);
-		int16 x = 8;
 		char spellSymbolString[2] = {'\0', '\0'};
+		int16 x = 8;
 		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
 			if ((spellSymbolString[0] = champ._symbols[symbolIndex]) == '\0')
 				break;
@@ -334,35 +334,34 @@ void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
 	}
 }
 
-	void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex)
-	{
-		ChampionMan &champMan = *_vm->_championMan;
-		DisplayMan &dispMan = *_vm->_displayMan;
-		
-		if((champIndex == champMan._magicCasterChampionIndex) 
-		   || ((champIndex != kChampionNone) && !champMan._champions[champIndex]._currHealth))
-			return;
-		if (champMan._magicCasterChampionIndex == kChampionNone) {
-			warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-			dispMan.blitToScreen(dispMan.getBitmap(kMenuSpellAreaBackground), 96, 0, 0, gBoxSpellArea);
-			warning("MISSING CODE: F0078_MOUSE_ShowPointer");
-		}
-		if (champIndex == kChampionNone) {
-			champMan._magicCasterChampionIndex = kChampionNone;
-			warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-			dispMan._useByteBoxCoordinates = false;
-			dispMan.clearScreenBox(kColorBlack, gBoxSpellArea);
-			warning("MISSING CODE: F0078_MOUSE_ShowPointer");
-			return;
-		}
+void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
+	ChampionMan &champMan = *_vm->_championMan;
+	DisplayMan &dispMan = *_vm->_displayMan;
 
-		champMan._magicCasterChampionIndex = champIndex;
-		buildSpellAreaLine(kSpellAreaAvailableSymbols);
+	if ((champIndex == champMan._magicCasterChampionIndex)
+		|| ((champIndex != kChampionNone) && !champMan._champions[champIndex]._currHealth))
+		return;
+	if (champMan._magicCasterChampionIndex == kChampionNone) {
 		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-		drawSpellAreaControls((ChampionIndex)champIndex);
-		dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine2);
-		buildSpellAreaLine(kSpellAreaChampionSymbols);
-		dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine3);
+		dispMan.blitToScreen(dispMan.getBitmap(kMenuSpellAreaBackground), 96, 0, 0, gBoxSpellArea);
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 	}
+	if (champIndex == kChampionNone) {
+		champMan._magicCasterChampionIndex = kChampionNone;
+		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+		dispMan._useByteBoxCoordinates = false;
+		dispMan.clearScreenBox(kColorBlack, gBoxSpellArea);
+		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+		return;
+	}
+
+	champMan._magicCasterChampionIndex = (ChampionIndex)champIndex;
+	buildSpellAreaLine(kSpellAreaAvailableSymbols);
+	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+	drawSpellAreaControls((ChampionIndex)champIndex);
+	dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine2);
+	buildSpellAreaLine(kSpellAreaChampionSymbols);
+	dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine3);
+	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+}
 }


Commit: 84a91022052bfcdf42f89823e3c24322ef147d26
    https://github.com/scummvm/scummvm/commit/84a91022052bfcdf42f89823e3c24322ef147d26
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Initial TODOs

Changed paths:
  A engines/dm/TODOs/methodtree.txt
  A engines/dm/TODOs/todo.txt



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
new file mode 100644
index 0000000..0887966
--- /dev/null
+++ b/engines/dm/TODOs/methodtree.txt
@@ -0,0 +1,162 @@
+F0380_COMMAND_ProcessQueue_CPSC // in progress
+	C080_COMMAND_CLICK_IN_DUNGEON_VIEW // cool
+		F0377_COMMAND_ProcessType80_ClickInDungeonView // done so-so
+			F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall // done so-so
+				F0275_SENSOR_IsTriggeredByClickOnWall // done so-so
+					F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
+	
+
+F0378_COMMAND_ProcessType81_ClickInPanel
+	F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel // done
+		F0368_COMMAND_SetLeader // done
+		F0457_START_DrawEnabledMenus_CPSF // wat skip
+		F0281_CHAMPION_Rename // skip
+		F0394_MENUS_SetMagicCasterAndDrawSpellArea // post skip	
+		F0393_MENUS_DrawSpellAreaControls // post skip
+		F0051_TEXT_MESSAGEAREA_PrintLineFeed // post skip
+		F0047_TEXT_MESSAGEAREA_PrintMessage // post skip
+		F0067_MOUSE_SetPointerToNormal // skip
+
+
+
+F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
+	M27_PORTRAIT_X // done
+	M28_PORTRAIT_Y // done
+	F0285_CHAMPION_GetIndexInCell // done
+	F0279_CHAMPION_GetDecodedValue // done
+	F0368_COMMAND_SetLeader // done
+		F0292_CHAMPION_DrawState // done
+			G0407_s_Party // done
+			G0048_s_Graphic562_Box_Mouth // done
+			G0049_s_Graphic562_Box_Eye // done
+			G0054_ai_Graphic562_Box_ChampionIcons // done
+			G0353_ac_StringBuildBuffer // done
+			G0046_auc_Graphic562_ChampionColor // done
+			F0354_INVENTORY_DrawStatusBoxPortrait // done
+			F0287_CHAMPION_DrawBarGraphs // done
+			F0290_CHAMPION_DrawHealthStaminaManaValues // done
+			F0309_CHAMPION_GetMaximumLoad // done
+				F0306_CHAMPION_GetStaminaAdjustedValue // done
+			F0288_CHAMPION_GetStringFromInteger // done
+			F0345_INVENTORY_DrawPanel_FoodWaterPoisoned // done
+				F0344_INVENTORY_DrawPanel_FoodOrWaterBar // done
+						F0343_INVENTORY_DrawPanel_HorizontalBar // done
+				G0032_s_Graphic562_Box_Panel // done 
+				G0035_s_Graphic562_Box_Food // done 
+				G0036_s_Graphic562_Box_Water // done 
+				G0037_s_Graphic562_Box_Poisoned // done
+
+			F0351_INVENTORY_DrawChampionSkillsAndStatistics // skip -----------------
+			F0347_INVENTORY_DrawPanel // done
+				F0342_INVENTORY_DrawPanel_Object // skip ---------------------
+				F0346_INVENTORY_DrawPanel_ResurrectReincarnate // done
+
+			F0291_CHAMPION_DrawSlot // done
+				F0038_OBJECT_DrawIconInSlotBox // done
+
+
+		F0140_DUNGEON_GetObjectWeight // done
+			G0238_as_Graphic559_WeaponInfo // done
+				WEAPON_INFO // done
+			G0239_as_Graphic559_ArmourInfo // done
+				ARMOUR_INFO // done
+			G0241_auc_Graphic559_JunkInfo // done
+				JUNK_INFO // done
+		G0411_i_LeaderIndex // done
+		G0299_ui_CandidateChampionOrdinal // done
+	F0388_MENUS_ClearActingChampion // done.
+		F0292_CHAMPION_DrawState // done
+		G0508_B_RefreshActionArea // done
+		G0506_ui_ActingChampionOrdinal // done
+	F0386_MENUS_DrawActionIcon // done								
+		F0141_DUNGEON_GetObjectInfoIndex // done 
+		F0033_OBJECT_GetIconIndex // done
+			F0032_OBJECT_GetType // done
+				G0237_as_Graphic559_ObjectInfo // done
+					OBJECT_INFO // done
+			G0029_auc_Graphic562_ChargeCountToTorchType // done
+		F0134_VIDEO_FillBitmap // done
+		D24_FillScreenBox // done
+		F0036_OBJECT_ExtractIconFromBitmap // done
+			G0026_ai_Graphic562_IconGraphicFirstIconIndex // done 
+		F0129_VIDEO_BlitShrinkWithPaletteChanges // eeeh
+		F0136_VIDEO_ShadeScreenBox // skip
+		G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon // done
+		G0237_as_Graphic559_ObjectInfo // done
+		G0509_B_ActionAreaContainsIcons // done
+	F0301_CHAMPION_AddObjectInSlot // skip
+		F0296_CHAMPION_DrawChangedObjectIcons
+			F0292_CHAMPION_DrawState // skip
+			F0034_OBJECT_DrawLeaderHandObjectName // skip
+			F0295_CHAMPION_HasObjectIconInSlotBoxChanged
+			M70_HAND_SLOT_INDEX
+			G0423_i_InventoryChampionOrdinal
+			G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen
+			G0412_puc_Bitmap_ObjectIconForMousePointer
+			G0424_i_PanelContent
+			G0425_aT_ChestSlots
+		F0337_INVENTORY_SetDungeonViewPalette
+		F0299_CHAMPION_ApplyObjectModifiersToStatistics
+		F0291_CHAMPION_DrawSlot
+		G0425_aT_ChestSlots
+		G0423_i_InventoryChampionOrdinal
+		G0039_ai_Graphic562_LightPowerToLightAmount
+		G0407_s_Party
+	F0355_INVENTORY_Toggle_CPSE // done
+		F0292_CHAMPION_DrawState // done
+		F0334_INVENTORY_CloseChest // skip
+		F0395_MENUS_DrawMovementArrows // done
+		F0357_COMMAND_DiscardAllInput // skip
+		F0098_DUNGEONVIEW_DrawFloorAndCeiling // wat
+		F0136_VIDEO_ShadeScreenBox // skip
+		D25_F0135_VIDEO_FillBox // done
+		G0423_i_InventoryChampionOrdinal
+		G0326_B_RefreshMousePointerInMainLoop  // lol you wat m8
+		G0002_s_Graphic562_Box_MovementArrows // done
+		G0041_s_Graphic562_Box_ViewportFloppyZzzCross // done
+		G0296_puc_Bitmap_Viewport // done 
+		G0598_B_MousePointerBitmapUpdated // done
+	F0456_START_DrawDisabledMenus // done
+	G0415_B_LeaderEmptyHanded // done
+	G0305_ui_PartyChampionCount // done
+	G0578_B_UseByteBoxCoordinates // done
+	G0047_s_Graphic562_Box_ChampionPortrait // done
+	G0308_i_PartyDirection // done
+	G0306_i_PartyMapX // done 
+	G0307_i_PartyMapY // done
+	G0299_ui_CandidateChampionOrdinal // done
+	G0508_B_RefreshActionArea // done
+	G0233_ai_Graphic559_DirectionToStepEastCount // done 
+	G0234_ai_Graphic559_DirectionToStepNorthCount // done
+	G0237_as_Graphic559_ObjectInfo // done
+	G0038_ai_Graphic562_SlotMasks // done
+								
+F0462_START_StartGame_CPSF
+	F0003_MAIN_ProcessNewPartyMap_CPSE // partially done
+	F0278_CHAMPION_ResetDataToStartGame // paritally done
+
+	G0331_B_PressingEye // dm // done
+	G0332_B_StopPressingEye // dm // done
+	G0333_B_PressingMouth // dm // done
+	G0334_B_StopPressingMouth // dm // done
+	G0340_B_HighlightBoxInversionRequested // dm, useless // done
+	G0341_B_HighlightBoxEnabled // eventman // done
+	G0300_B_PartyIsSleeping // champion // done
+	G0506_ui_ActingChampionOrdinal // champion // done
+	G0509_B_ActionAreaContainsIcons // menus // done
+	G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap // eventman // done
+
+F0463_START_InitializeGame_CPSADEF // partially done
+	F0267_MOVE_GetMoveResult_CPSCE // skip, really though
+	F0357_COMMAND_DiscardAllInput // done
+
+
+C013_GRAPHIC_MOVEMENT_ARROWS
+	F0395_MENUS_DrawMovementArrows
+		F0355_INVENTORY_Toggle_CPSE
+		F0462_START_StartGame_CPSF
+		F0457_START_DrawEnabledMenus_CPSF
+			F0314_CHAMPION_WakeUp
+			F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel
+			F0380_COMMAND_ProcessQueue_CPSC
+			F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF
diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
new file mode 100644
index 0000000..ee198d8
--- /dev/null
+++ b/engines/dm/TODOs/todo.txt
@@ -0,0 +1,18 @@
+Bugs:
+	Display:
+		Broken colour palette
+		Portraits, alcoves etc. look broken from afar
+		Ornaments are not displayed if looked at from certain angles
+		Ornaments are displayed where they should not be, probably error in the pseudo RNG
+		Command gui is broken
+	Logic:
+		Game crashes when reincaranting a fourth champion and trying to copy his portrait
+
+
+Todo:
+	Add wiki entry for DM
+	Rename GraphicIndice enum entires and have their name include GraphicIndice
+	I forgot to add localization warnings
+	Attend to Arnaud's notes on github
+	Double check enums with hex literals, I think I screwed the regex when processing them
+	
\ No newline at end of file


Commit: 398b309a0373c647ad9cd9c553ad626784d2b459
    https://github.com/scummvm/scummvm/commit/398b309a0373c647ad9cd9c553ad626784d2b459
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0163_DUNGEON_LinkThingToList

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/TODOs/todo.txt
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index 0887966..15e01ee 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -6,13 +6,13 @@ F0380_COMMAND_ProcessQueue_CPSC // in progress
 					F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 	
 
-F0378_COMMAND_ProcessType81_ClickInPanel
+F0378_COMMAND_ProcessType81_ClickInPanel // done so-so
 	F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel // done
 		F0368_COMMAND_SetLeader // done
-		F0457_START_DrawEnabledMenus_CPSF // wat skip
-		F0281_CHAMPION_Rename // skip
-		F0394_MENUS_SetMagicCasterAndDrawSpellArea // post skip	
-		F0393_MENUS_DrawSpellAreaControls // post skip
+		F0457_START_DrawEnabledMenus_CPSF // can't yet see it's purpose
+		F0281_CHAMPION_Rename // stub
+		F0394_MENUS_SetMagicCasterAndDrawSpellArea // done
+		F0393_MENUS_DrawSpellAreaControls // done
 		F0051_TEXT_MESSAGEAREA_PrintLineFeed // post skip
 		F0047_TEXT_MESSAGEAREA_PrintMessage // post skip
 		F0067_MOUSE_SetPointerToNormal // skip
@@ -104,7 +104,12 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 		G0407_s_Party
 	F0355_INVENTORY_Toggle_CPSE // done
 		F0292_CHAMPION_DrawState // done
-		F0334_INVENTORY_CloseChest // skip
+		F0334_INVENTORY_CloseChest
+			F0163_DUNGEON_LinkThingToList
+			G0426_T_OpenChest
+			G0425_aT_ChestSlots
+
+
 		F0395_MENUS_DrawMovementArrows // done
 		F0357_COMMAND_DiscardAllInput // skip
 		F0098_DUNGEONVIEW_DrawFloorAndCeiling // wat
diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index ee198d8..558fc8a 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -9,10 +9,14 @@ Bugs:
 		Game crashes when reincaranting a fourth champion and trying to copy his portrait
 
 
+
 Todo:
 	Add wiki entry for DM
 	Rename GraphicIndice enum entires and have their name include GraphicIndice
 	I forgot to add localization warnings
 	Attend to Arnaud's notes on github
 	Double check enums with hex literals, I think I screwed the regex when processing them
+
+	Missing functions:
+		 Add missing  F0163_DUNGEON_LinkThingToList in MovesensMan::sensorIsTriggeredByClickOnWall (I don't think it's safe yet)
 	
\ No newline at end of file
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 755a7d8..7de4d76 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1246,4 +1246,47 @@ int16 DungeonMan::getObjectInfoIndex(Thing thing) {
 	}
 }
 
-}
\ No newline at end of file
+void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) {
+	if (thingToLink == Thing::_thingEndOfList)
+		return;
+
+	uint16 *rawObjPtr = getThingData(thingToLink);
+	*rawObjPtr = Thing::_thingEndOfList.toUint16();
+
+	if (mapX >= 0) {
+		Square *squarePtr = (Square*)&_currMap._data[mapX][mapY];
+		if (squarePtr->get(kThingListPresent)) {
+			thingInList = getSquareFirstThing(mapX, mapY);
+		} else {
+			squarePtr->set(kThingListPresent);
+			uint16 *cumulativeCount = &_currMap._colCumulativeSquareFirstThingCount[mapX + 1];
+			uint16 column = _dunData._columCount - (_dunData._mapsFirstColumnIndex[_currMap._index] + mapX) - 1;
+			while (column--) {
+				(*cumulativeCount++)++;
+			}
+			uint16 mapYStep = 0;
+			squarePtr -= mapY;
+			uint16 squareFirstThingIndex = _currMap._colCumulativeSquareFirstThingCount[mapX];
+			while (mapYStep++ != mapY) {
+				if (squarePtr->get(kThingListPresent)) {
+					squareFirstThingIndex++;
+				}
+				squarePtr++;
+			}
+			Thing* thingPtr = &_dunData._squareFirstThings[squareFirstThingIndex];
+			memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_fileHeader._squareFirstThingCount - squareFirstThingIndex - 1));
+			*thingPtr = thingToLink;
+			return;
+		}
+	}
+
+	Thing thing = getNextThing(thingInList);
+	while (thing != Thing::_thingEndOfList) {
+		thing = getNextThing(thing);
+		thingInList = thing;
+	}
+	rawObjPtr = getThingData(thingInList);
+	*rawObjPtr = thingToLink.toUint16();
+}
+
+}
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 5191ba9..064ea49 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -641,6 +641,7 @@ public:
 
 	uint16 getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight
 	int16 getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex
+	void linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY); // @ F0163_DUNGEON_LinkThingToList
 
 	uint32 _rawDunFileDataSize;	 // @ probably NONE
 	byte *_rawDunFileData; // @ ???


Commit: 7ecd3333d7821aa69fa3df4ebbffb33228f43171
    https://github.com/scummvm/scummvm/commit/7ecd3333d7821aa69fa3df4ebbffb33228f43171
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix and simplify commandProcessType80ClickInDungeonViewTouchFrontWall()

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 4e5a59c..6d39a12 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -508,14 +508,9 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
 void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() {
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 	CurrMapData &currMap = dunMan._currMap;
-	uint16 mapX = currMap._partyPosX;
-	uint16 mapY = currMap._partyPosY;
-	mapX += gDirIntoStepCountEast[currMap._partyDir];
-	mapY += gDirIntoStepCountNorth[currMap._partyDir];
-	if ((mapX >= 0)
-		&& (mapX < currMap._width)
-		&& (mapY >= 0)
-		&& (mapY < currMap._height)) {
+	int16 mapX = currMap._partyPosX + gDirIntoStepCountEast[currMap._partyDir];
+	int16 mapY = currMap._partyPosY + gDirIntoStepCountNorth[currMap._partyDir];
+	if ((mapX >= 0) && (mapX < currMap._width) && (mapY >= 0) && (mapY < currMap._height)) {
 		_vm->_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(currMap._partyDir));
 	}
 }
@@ -528,7 +523,6 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 	int16 mapX;
 	int16 mapY;
 
-
 	if (dunMan._squareAheadElement == kElementTypeDoorFront) {
 		if (champMan._leaderIndex == kChampionNone) {
 			return;


Commit: f00f5c19e73204ba44ed508871bb50d348e62a5b
    https://github.com/scummvm/scummvm/commit/f00f5c19e73204ba44ed508871bb50d348e62a5b
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add G0426_T_OpenChest, F0334_INVENTORY_CloseChest

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/menus.cpp



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index 15e01ee..36237c2 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -104,10 +104,10 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 		G0407_s_Party
 	F0355_INVENTORY_Toggle_CPSE // done
 		F0292_CHAMPION_DrawState // done
-		F0334_INVENTORY_CloseChest
-			F0163_DUNGEON_LinkThingToList
-			G0426_T_OpenChest
-			G0425_aT_ChestSlots
+		F0334_INVENTORY_CloseChest // done
+			F0163_DUNGEON_LinkThingToList // done
+			G0426_T_OpenChest // done
+			G0425_aT_ChestSlots // done
 
 
 		F0395_MENUS_DrawMovementArrows // done
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 7de4d76..6d5a540 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1194,8 +1194,8 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 	}
 	case kContainerThingType: {
 		uint16 weight = 50;
-		Container container = getThingData(thing);
-		Thing slotThing = container.getNextContainedThing();
+		Container container(getThingData(thing));
+		Thing slotThing = container.getSlot();
 		while (slotThing != Thing::_thingEndOfList) {
 			weight += getObjectWeight(slotThing);
 			slotThing = getNextThing(slotThing);
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 064ea49..1175298 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -34,6 +34,8 @@
 
 namespace DM {
 
+#define kMapXNotOnASquare -1 // @ CM1_MAPX_NOT_ON_A_SQUARE
+
 enum ElementType {
 	kElementTypeChampion = -2, // @ CM2_ELEMENT_CHAMPION /* Values -2 and -1 are only used as projectile impact types */
 	kElementTypeCreature = -1, // @ CM1_ELEMENT_CREATURE
@@ -417,14 +419,14 @@ public:
 
 class Container {
 	Thing _nextThing;
-	Thing _nextContainedThing;
+	Thing _slot;
 	uint16 _type;
 public:
-	explicit Container(uint16 *rawDat) : _nextThing(rawDat[0]), _nextContainedThing(rawDat[1]), _type(rawDat[2]) {}
+	explicit Container(uint16 *rawDat) : _nextThing(rawDat[0]), _slot(rawDat[1]), _type(rawDat[2]) {}
 
 	uint16 getType() { return (_type >> 1) & 0x3; }
-	Thing getNextContainedThing() { return _nextContainedThing; }
-	Thing getNextThing() { return _nextThing; }
+	Thing &getSlot() { return _slot; }
+	Thing &getNextThing() { return _nextThing; }
 }; // @ CONTAINER
 
 enum JunkType {
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 550c4c8..c02aed4 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -46,6 +46,8 @@ InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
 	_panelContent = kPanelContentFoodWaterPoisoned;
 	for (uint16 i = 0; i < 8; ++i)
 		_chestSlots[i] = Thing::_thingNone;
+	_openChest = Thing::_thingNone;
+	_openChest = Thing::_thingNone;
 }
 
 void InventoryMan::toggleInventory(ChampionIndex championIndex) {
@@ -66,7 +68,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	Champion *champion;
 	if (invChampOrdinal) {
 		_inventoryChampionOrdinal = _vm->indexToOrdinal(kChampionNone);
-		warning("MISSING CODE: F0334_INVENTORY_CloseChest");
+		closeChest();
 		champion = &cm._champions[_vm->ordinalToIndex(invChampOrdinal)];
 		if (champion->_currHealth && !cm._candidateChampionOrdinal) {
 			champion->setAttributeFlag(kChampionAttributeStatusBox, true);
@@ -159,7 +161,7 @@ void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
 
 void InventoryMan::drawPanelFoodWaterPoisoned() {
 	Champion &champ = _vm->_championMan->_champions[_inventoryChampionOrdinal];
-	warning("MISSING CODE: F0334_INVENTORY_CloseChest");
+	closeChest();
 	DisplayMan &dispMan = *_vm->_displayMan;
 	dispMan.blitToScreen(dispMan.getBitmap(kPanelEmptyIndice), 144, 0, 0, gBoxPanel, kColorRed);
 	dispMan.blitToScreen(dispMan.getBitmap(kFoodLabelIndice), 48, 0, 0, gBoxFood, kColorDarkestGray);
@@ -177,7 +179,8 @@ void InventoryMan::drawPanelResurrectReincarnate() {
 }
 
 void InventoryMan::drawPanel() {
-	warning("MISSING CODE: F0334_INVENTORY_CloseChest, altho adding it may reintroduce BUG0_48");
+	warning("possible reintroduction of BUG0_48");
+	closeChest(); // possibility of BUG0_48
 
 	ChampionMan &cm = *_vm->_championMan;
 	if (cm._candidateChampionOrdinal) {
@@ -205,4 +208,32 @@ void InventoryMan::drawPanel() {
 		warning("MISSING CODE: F0342_INVENTORY_DrawPanel_Object(L1075_T_Thing, C0_FALSE);");
 	}
 }
+
+void InventoryMan::closeChest() {
+	DungeonMan &dunMan = *_vm->_dungeonMan;
+
+	bool processFirstChestSlot = true;
+	if (_openChest == Thing::_thingNone)
+		return;
+	Container *container = (Container*)dunMan.getThingData(_openChest);
+	_openChest = Thing::_thingNone;
+	container->getSlot() = Thing::_thingEndOfList;
+	Thing prevThing;
+	for (int16 chestSlotIndex = 0; chestSlotIndex < 8; ++chestSlotIndex) {
+		Thing thing = _chestSlots[chestSlotIndex];
+		if (thing != Thing::_thingNone) {
+			_chestSlots[chestSlotIndex] = Thing::_thingNone; // CHANGE8_09_FIX
+
+			if (processFirstChestSlot) {
+				processFirstChestSlot = false;
+				*dunMan.getThingData(thing) = Thing::_thingEndOfList.toUint16();
+				container->getSlot() = prevThing = thing;
+			} else {
+				dunMan.linkThingToList(thing, prevThing, kMapXNotOnASquare, 0);
+				prevThing = thing;
+			}
+		}
+	}
+}
+
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index f225e41..8457e98 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -55,6 +55,7 @@ public:
 	int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal
 	PanelContent _panelContent; // @ G0424_i_PanelContent 
 	Thing _chestSlots[8]; // @ G0425_aT_ChestSlots
+	Thing _openChest; // @ G0426_T_OpenChest
 
 	void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE
 	void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait
@@ -63,6 +64,7 @@ public:
 	void drawPanelFoodWaterPoisoned(); // @ F0345_INVENTORY_DrawPanel_FoodWaterPoisoned
 	void drawPanelResurrectReincarnate(); // @ F0346_INVENTORY_DrawPanel_ResurrectReincarnate
 	void drawPanel(); // @ F0347_INVENTORY_DrawPanel
+	void closeChest(); // @ F0334_INVENTORY_CloseChest
 
 };
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index dfbe5b5..d6c09d8 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -124,7 +124,9 @@ void MenuMan::drawDisabledMenu() {
 		warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
 		_vm->_displayMan->_useByteBoxCoordinates = false;
 		if (_vm->_inventoryMan->_inventoryChampionOrdinal) {
-			warning("MISSING CODE: F0334_INVENTORY_CloseChest");
+			if (_vm->_inventoryMan->_panelContent == kPanelContentChest) {
+				_vm->_inventoryMan->closeChest();
+			}
 		} else {
 			warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 		}


Commit: d770ec0f61a8fea8a2e276be6c6b841dab01bae2
    https://github.com/scummvm/scummvm/commit/d770ec0f61a8fea8a2e276be6c6b841dab01bae2
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Reduce scope of a couple of variables, simplify a couple of lines

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 6d39a12..96cda36 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -520,19 +520,14 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 	ChampionMan &champMan = *_vm->_championMan;
 	CurrMapData &currMap = _vm->_dungeonMan->_currMap;
 
-	int16 mapX;
-	int16 mapY;
-
 	if (dunMan._squareAheadElement == kElementTypeDoorFront) {
-		if (champMan._leaderIndex == kChampionNone) {
+		if (champMan._leaderIndex == kChampionNone)
 			return;
-		}
-		mapX = currMap._partyPosX;
-		mapY = currMap._partyPosY;
-		mapX += gDirIntoStepCountEast[currMap._partyDir];
-		mapY += gDirIntoStepCountNorth[currMap._partyDir];
 
 		if (champMan._leaderEmptyHanded) {
+			int16 mapX = currMap._partyPosX + gDirIntoStepCountEast[currMap._partyDir];
+			int16 mapY = currMap._partyPosY + gDirIntoStepCountNorth[currMap._partyDir];
+
 			if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() &&
 				dunMan._dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
 				_vm->_stopWaitingForPlayerInput = true;
@@ -590,7 +585,6 @@ T0377019:
 					commandProcessType80ClickInDungeonViewTouchFrontWall();
 				}
 			}
-
 		} else {
 			warning("MISSING CODE: F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown in if branch");
 			for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellBackLeft; viewCell++) {
@@ -633,11 +627,9 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	}
 
 	champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kChampionNone);
-	int16 mapX = currMap._partyPosX;
-	int16 mapY = currMap._partyPosY;
+	int16 mapX = currMap._partyPosX + gDirIntoStepCountEast[currMap._partyDir];
+	int16 mapY = currMap._partyPosY + gDirIntoStepCountNorth[currMap._partyDir];
 
-	mapX += gDirIntoStepCountEast[currMap._partyDir];
-	mapY += gDirIntoStepCountNorth[currMap._partyDir];
 	for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) {
 		Thing thing = champ->getSlot((ChampionSlot)slotIndex);
 		if (thing != Thing::_thingNone) {


Commit: 0d314b9bea506a75da3e5d54763759a33851b18d
    https://github.com/scummvm/scummvm/commit/0d314b9bea506a75da3e5d54763759a33851b18d
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix a GCC warning, fix code alignment in hasPendingClick

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 96cda36..437a02d 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -694,13 +694,16 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) {
 		if (commandType != kCommandNone)
 			commandProcessCommands160To162ClickInResurrectReincarnatePanel(commandType);
 		break;
+	default:
+		break;
 	}
 }
 
-	bool EventManager::hasPendingClick(Common::Point& point, MouseButton button)
-	{
-		if (_pendingClickButton && button == _pendingClickButton)
-			point = _pendingClickPos;
-		return _pendingClickPresent;
-	}
+bool EventManager::hasPendingClick(Common::Point& point, MouseButton button) {
+	if (_pendingClickButton && button == _pendingClickButton)
+		point = _pendingClickPos;
+
+	return _pendingClickPresent;
+}
+
 }; // end of namespace DM


Commit: 5859ff8aaf63772a19e3576f24cec24286d98dff
    https://github.com/scummvm/scummvm/commit/5859ff8aaf63772a19e3576f24cec24286d98dff
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove extra semi-column

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 437a02d..5c9e68b 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -706,4 +706,4 @@ bool EventManager::hasPendingClick(Common::Point& point, MouseButton button) {
 	return _pendingClickPresent;
 }
 
-}; // end of namespace DM
+} // end of namespace DM


Commit: 703fd8aca2e15edc03aa854365e20bfdcf524add
    https://github.com/scummvm/scummvm/commit/703fd8aca2e15edc03aa854365e20bfdcf524add
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix bug in getIconIndex

Changed paths:
    engines/dm/objectman.cpp



diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index d20c235..c92427b 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -108,9 +108,9 @@ IconIndice ObjectMan::getIconIndex(Thing thing) {
 	IconIndice iconIndex = getObjectType(thing);
 
 	if ((iconIndex != kIconIndiceNone) &&
-		((iconIndex < kIconIndiceWeaponDagger) && (iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error
-		((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) ||
-		(iconIndex == kIconIndicePotionEmptyFlask)
+		(((iconIndex < kIconIndiceWeaponDagger) && (iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error
+		 ((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) ||
+		 (iconIndex == kIconIndicePotionEmptyFlask))
 		) {
 		uint16 *rawType = _vm->_dungeonMan->getThingData(thing);
 		switch (iconIndex) {


Commit: 652b2c6f98f291a76397c9035e4f8338b9c792f9
    https://github.com/scummvm/scummvm/commit/652b2c6f98f291a76397c9035e4f8338b9c792f9
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0340_INVENTORY_DrawPanel_ScrollTextLine

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/text.cpp
    engines/dm/text.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index 36237c2..a672a8a 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -45,16 +45,27 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 				G0035_s_Graphic562_Box_Food // done 
 				G0036_s_Graphic562_Box_Water // done 
 				G0037_s_Graphic562_Box_Poisoned // done
-
 			F0351_INVENTORY_DrawChampionSkillsAndStatistics // skip -----------------
 			F0347_INVENTORY_DrawPanel // done
-				F0342_INVENTORY_DrawPanel_Object // skip ---------------------
-				F0346_INVENTORY_DrawPanel_ResurrectReincarnate // done
+				F0342_INVENTORY_DrawPanel_Object
+					F0341_INVENTORY_DrawPanel_Scroll
+						F0340_INVENTORY_DrawPanel_ScrollTextLine // done
+					F0333_INVENTORY_OpenAndDrawChest
+					F0303_CHAMPION_GetSkillLevel
+					F0332_INVENTORY_DrawIconToViewport
+					F0336_INVENTORY_DrawPanel_BuildObjectAttributesString
+					F0335_INVENTORY_DrawPanel_ObjectDescriptionString
+					F0339_INVENTORY_DrawPanel_ArrowOrEye
+					G0430_apc_DirectionNames
+					G0034_s_Graphic562_Box_ObjectDescriptionCircle
+					G0032_s_Graphic562_Box_Panel
+					G0352_apc_ObjectNames
+					G0237_as_Graphic559_ObjectInfo
+					G0422_i_ObjectDescriptionTextY
 
+				F0346_INVENTORY_DrawPanel_ResurrectReincarnate // done
 			F0291_CHAMPION_DrawSlot // done
 				F0038_OBJECT_DrawIconInSlotBox // done
-
-
 		F0140_DUNGEON_GetObjectWeight // done
 			G0238_as_Graphic559_WeaponInfo // done
 				WEAPON_INFO // done
@@ -108,8 +119,6 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 			F0163_DUNGEON_LinkThingToList // done
 			G0426_T_OpenChest // done
 			G0425_aT_ChestSlots // done
-
-
 		F0395_MENUS_DrawMovementArrows // done
 		F0357_COMMAND_DiscardAllInput // skip
 		F0098_DUNGEONVIEW_DrawFloorAndCeiling // wat
@@ -135,11 +144,11 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 	G0234_ai_Graphic559_DirectionToStepNorthCount // done
 	G0237_as_Graphic559_ObjectInfo // done
 	G0038_ai_Graphic562_SlotMasks // done
-								
+						
+
 F0462_START_StartGame_CPSF
 	F0003_MAIN_ProcessNewPartyMap_CPSE // partially done
 	F0278_CHAMPION_ResetDataToStartGame // paritally done
-
 	G0331_B_PressingEye // dm // done
 	G0332_B_StopPressingEye // dm // done
 	G0333_B_PressingMouth // dm // done
@@ -151,6 +160,7 @@ F0462_START_StartGame_CPSF
 	G0509_B_ActionAreaContainsIcons // menus // done
 	G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap // eventman // done
 
+
 F0463_START_InitializeGame_CPSADEF // partially done
 	F0267_MOVE_GetMoveResult_CPSCE // skip, really though
 	F0357_COMMAND_DiscardAllInput // done
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index c02aed4..1a08022 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -33,7 +33,6 @@
 #include "text.h"
 
 
-
 namespace DM {
 
 Box gBoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
@@ -236,4 +235,15 @@ void InventoryMan::closeChest() {
 	}
 }
 
+void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) {
+	warning("CHANGE5_03_IMPROVEMENT");
+	for (char* iter = text; *iter != '\0'; ++iter) {
+		if ((*iter >= 'A') && (*iter <= 'Z')) {
+			*iter -= 64;
+		} else if (*iter >= '{') { // this branch is CHANGE5_03_IMPROVEMENT
+			*iter -= 96;
+		}
+	}
+	_vm->_textMan->printToViewport(162 - (6 * strlen(text) / 2), yPos, kColorBlack, text, kColorWhite);
+}
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 8457e98..fe974b6 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -65,6 +65,7 @@ public:
 	void drawPanelResurrectReincarnate(); // @ F0346_INVENTORY_DrawPanel_ResurrectReincarnate
 	void drawPanel(); // @ F0347_INVENTORY_DrawPanel
 	void closeChest(); // @ F0334_INVENTORY_CloseChest
+	void drawPanelScrollTextLine(int16 yPos, char *text); // @ F0340_INVENTORY_DrawPanel_ScrollTextLine
 
 };
 
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index ab22ac4..f8aabb3 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -69,8 +69,8 @@ void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Col
 	printTextToBitmap(_vm->_displayMan->_vgaBuffer, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight, viewport);
 }
 
-void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text) {
-	printTextToScreen(posX, posY, textColor, kColorDarkestGray, text, gDungeonViewport);
+void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) {
+	printTextToScreen(posX, posY, textColor, bgColor, text, gDungeonViewport);
 }
 
 void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor,
diff --git a/engines/dm/text.h b/engines/dm/text.h
index b03d00a..590fade 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -40,7 +40,7 @@ public:
 	void printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY,
 						   Color textColor, Color bgColor, const char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print
 	void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, Viewport &viewport = gDefultViewPort); // @ F0053_TEXT_PrintToLogicalScreen
-	void printToViewport(int16 posX, int16 posY, Color textColor, const char *text); // @ F0052_TEXT_PrintToViewport
+	void printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = kColorDarkestGray); // @ F0052_TEXT_PrintToViewport
 	void printWithTrailingSpaces(byte *destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, Color bgColor,
 								 const char *text, int16 strLenght, int16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0041_TEXT_PrintWithTrailingSpaces
 	void printWithTrailingSpacesToScreen(int16 destX, int16 destY, Color textColor, Color bgColor,


Commit: 49aae8932bcb4698c37516f00ae2f6728044b0bd
    https://github.com/scummvm/scummvm/commit/49aae8932bcb4698c37516f00ae2f6728044b0bd
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0341_INVENTORY_DrawPanel_Scroll

Changed paths:
    engines/dm/dm.h
    engines/dm/dungeonman.h
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 5a7e548..19eda10 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -106,7 +106,7 @@ public:
 
 	byte getCell() const { return _data >> 14; }
 	ThingType getType() const { return (ThingType)((_data >> 10) & 0xF); }
-	uint16 getIndex() const { return _data & 0x1FF; }
+	uint16 getIndex() const { return _data & 0x3FF; }
 	uint16 toUint16() const { return _data; } // I don't like 'em cast operators
 	bool operator==(const Thing &rhs) const { return _data == rhs._data; }
 	bool operator!=(const Thing &rhs) const { return _data != rhs._data; }
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 1175298..767044e 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -389,6 +389,7 @@ public:
 	}
 	Thing getNextThing() { return _nextThing; }
 	uint16 getClosed() { return (_attributes >> 10) & 0x3F; } // ??? dunno why, the original bitfield is 6 bits long
+	uint16 getTextStringThingIndex() { return _attributes & 0x3FF; }
 }; // @ SCROLL
 
 enum PotionType {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 9354b99..3ff4bf5 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -74,7 +74,8 @@ enum GraphicIndice {
 	kPanelRenameChampionIndice = 27, // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION
 	kMenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA
 	kMenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES
-	kMenuSpellAreaBackground = 9 // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND
+	kMenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND
+	kPanelOpenScrollIndice = 23 // @ C023_GRAPHIC_PANEL_OPEN_SCROLL
 };
 
 extern uint16 gPalSwoosh[16];
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 1a08022..eb3192a 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -246,4 +246,52 @@ void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) {
 	}
 	_vm->_textMan->printToViewport(162 - (6 * strlen(text) / 2), yPos, kColorBlack, text, kColorWhite);
 }
+
+void InventoryMan::drawPanelScroll(Scroll* scroll) {
+	DisplayMan &dispMan = *_vm->_displayMan;
+
+	char stringFirstLine[300];
+	_vm->_dungeonMan->decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible));
+	char *charRed = stringFirstLine;
+	while (*charRed && (*charRed != '\n')) {
+		charRed++;									   
+	}
+	*charRed = '\0';
+	dispMan.blitToScreen(dispMan.getBitmap(kPanelOpenScrollIndice), 144, 0, 0, gBoxPanel, kColorRed, gDungeonViewport);
+	int16 lineCount = 1;
+	charRed++;
+	char *charGreen = charRed; // first char of the second line
+	while (*charGreen) {
+		warning("BUG0_47");
+		/* BUG0_47 Graphical glitch when you open a scroll. If there is a single line of text in a scroll
+		(with no carriage return) then charGreen points to undefined data. This may result in a graphical
+		glitch and also corrupt other memory. This is not an issue in the original dungeons where all 
+		scrolls contain at least one carriage return character */
+		if (*charGreen == '\n') {
+			lineCount++;
+		}
+		charGreen++;
+	}
+	if (*(charGreen - 1) != '\n') {
+		lineCount++;
+	} else if (*(charGreen - 2) == '\n') {
+		lineCount--;
+	}
+	int16 yPos = 92 - (7 * lineCount) / 2; // center the text vertically
+	drawPanelScrollTextLine(yPos, stringFirstLine);
+	charGreen = charRed;
+	while (*charGreen) {
+		yPos += 7;
+		while (*charRed && (*charRed != '\n')) {
+			charRed++;
+		}
+		if (!(*charRed)) {
+			charRed[1] = '\0';
+		}
+		*charRed++ = '\0';
+		drawPanelScrollTextLine(yPos, charGreen);
+		charGreen = charRed;
+	}
+}
+
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index fe974b6..3f6783b 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -28,6 +28,7 @@
 #include "dm.h"
 #include "gfx.h"
 #include "champion.h"
+#include "dungeonman.h"
 
 
 
@@ -66,6 +67,7 @@ public:
 	void drawPanel(); // @ F0347_INVENTORY_DrawPanel
 	void closeChest(); // @ F0334_INVENTORY_CloseChest
 	void drawPanelScrollTextLine(int16 yPos, char *text); // @ F0340_INVENTORY_DrawPanel_ScrollTextLine
+	void drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll
 
 };
 


Commit: ebdcac50734b4a1e297e40af6d096c52b183e4d9
    https://github.com/scummvm/scummvm/commit/ebdcac50734b4a1e297e40af6d096c52b183e4d9
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0333_INVENTORY_OpenAndDrawChest

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index a672a8a..a352403 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -48,9 +48,9 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 			F0351_INVENTORY_DrawChampionSkillsAndStatistics // skip -----------------
 			F0347_INVENTORY_DrawPanel // done
 				F0342_INVENTORY_DrawPanel_Object
-					F0341_INVENTORY_DrawPanel_Scroll
+					F0341_INVENTORY_DrawPanel_Scroll // done
 						F0340_INVENTORY_DrawPanel_ScrollTextLine // done
-					F0333_INVENTORY_OpenAndDrawChest
+					F0333_INVENTORY_OpenAndDrawChest // done
 					F0303_CHAMPION_GetSkillLevel
 					F0332_INVENTORY_DrawIconToViewport
 					F0336_INVENTORY_DrawPanel_BuildObjectAttributesString
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 3ff4bf5..25ffbb2 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -75,7 +75,8 @@ enum GraphicIndice {
 	kMenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA
 	kMenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES
 	kMenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND
-	kPanelOpenScrollIndice = 23 // @ C023_GRAPHIC_PANEL_OPEN_SCROLL
+	kPanelOpenScrollIndice = 23, // @ C023_GRAPHIC_PANEL_OPEN_SCROLL
+	kPanelOpenChestIndice = 25 // @ C025_GRAPHIC_PANEL_OPEN_CHEST
 };
 
 extern uint16 gPalSwoosh[16];
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index eb3192a..a64c489 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -31,6 +31,7 @@
 #include "menus.h"
 #include "gfx.h"
 #include "text.h"
+#include "objectman.h"
 
 
 namespace DM {
@@ -254,7 +255,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) {
 	_vm->_dungeonMan->decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible));
 	char *charRed = stringFirstLine;
 	while (*charRed && (*charRed != '\n')) {
-		charRed++;									   
+		charRed++;
 	}
 	*charRed = '\0';
 	dispMan.blitToScreen(dispMan.getBitmap(kPanelOpenScrollIndice), 144, 0, 0, gBoxPanel, kColorRed, gDungeonViewport);
@@ -265,7 +266,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) {
 		warning("BUG0_47");
 		/* BUG0_47 Graphical glitch when you open a scroll. If there is a single line of text in a scroll
 		(with no carriage return) then charGreen points to undefined data. This may result in a graphical
-		glitch and also corrupt other memory. This is not an issue in the original dungeons where all 
+		glitch and also corrupt other memory. This is not an issue in the original dungeons where all
 		scrolls contain at least one carriage return character */
 		if (*charGreen == '\n') {
 			lineCount++;
@@ -294,4 +295,39 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) {
 	}
 }
 
+void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool isPressingEye) {
+	DisplayMan &dispMan = *_vm->_displayMan;
+	ObjectMan &objMan = *_vm->_objectMan;
+
+	if (_openChest == thingToOpen)
+		return;
+
+	warning("CHANGE8_09_FIX");
+	if (_openChest != Thing::_thingNone)
+		closeChest(); // CHANGE8_09_FIX
+
+	_openChest = thingToOpen;
+	if (!isPressingEye) {
+		objMan.drawIconInSlotBox(kSlotBoxInventoryActionHand, kIconIndiceContainerChestOpen);
+	}
+	dispMan.blitToScreen(dispMan.getBitmap(kPanelOpenChestIndice), 144, 0, 0, gBoxPanel, kColorRed);
+	
+	int16 chestSlotIndex = 0;
+	Thing thing = chest->getSlot();
+	int16 thingCount = 0;
+	while (thing != Thing::_thingEndOfList) {
+		warning("CHANGE8_08_FIX");
+		if (++thingCount > 8)
+			break; // CHANGE8_08_FIX, make sure that no more than the first 8 objects in a chest are drawn
+
+		objMan.drawIconInSlotBox(chestSlotIndex + kSlotBoxChestFirstSlot, objMan.getIconIndex(thing));
+		_chestSlots[chestSlotIndex++] = thing;
+		thing = _vm->_dungeonMan->getNextThing(thing);
+	}
+	while (chestSlotIndex < 8) {
+		objMan.drawIconInSlotBox(chestSlotIndex + kSlotBoxChestFirstSlot, kIconIndiceNone);
+		_chestSlots[chestSlotIndex++] = Thing::_thingNone;
+	}
+}
+
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 3f6783b..3232ab5 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -35,6 +35,7 @@
 namespace DM {
 
 #define kChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING
+#define kSlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT
 
 
 extern Box gBoxPanel; // @ G0032_s_Graphic562_Box_Panel
@@ -68,6 +69,7 @@ public:
 	void closeChest(); // @ F0334_INVENTORY_CloseChest
 	void drawPanelScrollTextLine(int16 yPos, char *text); // @ F0340_INVENTORY_DrawPanel_ScrollTextLine
 	void drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll
+	void openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye); // @ F0333_INVENTORY_OpenAndDrawChest
 
 };
 


Commit: d6af931ad7d921e3a6e947634c4efcffef6545d0
    https://github.com/scummvm/scummvm/commit/d6af931ad7d921e3a6e947634c4efcffef6545d0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add  F0303_CHAMPION_GetSkillLevel

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index b8676c8..c974a71 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -717,6 +717,68 @@ void ChampionMan::renameChampion(Champion* champ) {
 		dispMan.updateScreen();
 	}
 }
+
+uint16 ChampionMan::getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex) {
+	if (_partyIsSleeping)
+		return 1;
+
+	bool ignoreTempExp = skillIndex & kIgnoreTemporaryExperience;
+	bool ignoreObjModifiers = skillIndex & kIgnoreObjectModifiers;
+	skillIndex = (ChampionSkill)(skillIndex & ~(ignoreTempExp | ignoreObjModifiers));
+	Champion *champ = &_champions[champIndex];
+	Skill *skill = &champ->getSkill(skillIndex);
+	int32 experience = skill->_experience;
+
+	if (!ignoreTempExp)
+		experience += skill->_temporaryExperience;
+
+	if (skillIndex > kChampionSkillWizard) { // hidden skill
+		skill = &champ->getSkill((ChampionSkill)((skillIndex - kChampionSkillSwing) / 4));
+		experience += skill->_experience; // add exp to the base skill
+		if (!ignoreTempExp)
+			experience += skill->_temporaryExperience;
+
+		experience /= 2; // halve the exp to get avarage of base skill + hidden skill exp
+	}
+
+	int16 skillLevel = 1;
+	while (experience >= 500) {
+		experience /= 2;
+		skillLevel++;
+	}
+
+	if (!ignoreObjModifiers) {
+		IconIndice actionHandIconIndex = _vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotActionHand));
+		if (actionHandIconIndex == kIconIndiceWeaponTheFirestaff) {
+			skillLevel++;
+		} else if (actionHandIconIndex == kIconIndiceWeaponTheFirestaffComplete) {
+			skillLevel += 2;
+		}
+
+		IconIndice neckIconIndice = _vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotNeck));
+		switch (skillIndex) {
+		case kChampionSkillWizard:
+			if (neckIconIndice == kIconIndiceJunkPendantFeral)
+				skillLevel++;
+			break;
+		case kChampionSkillDefend:
+			if (neckIconIndice == kIconIndiceJunkEkkhardCross)
+				skillLevel++;
+			break;
+		case kChampionSkillHeal:
+			// these two are not cummulative
+			if ((neckIconIndice == kIconIndiceJunkGemOfAges) || (neckIconIndice == kIconIndiceWeaponSceptreOfLyf))
+				skillLevel++;
+			break;
+		case kChampionSkillInfluence:
+			if (neckIconIndice == kIconIndiceJunkMoonstone)
+				skillLevel++;
+			break;
+		}
+	}
+	return skillLevel;
+}
+
 }
 
 
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 3e72be3..86425b4 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -35,6 +35,9 @@
 
 namespace DM {
 
+#define kIgnoreObjectModifiers 0x4000 // @ MASK0x4000_IGNORE_OBJECT_MODIFIERS     
+#define kIgnoreTemporaryExperience 0x8000 // @ MASK0x8000_IGNORE_TEMPORARY_EXPERIENCE 
+
 extern Box gBoxChampionIcons[4]; // @ G0054_ai_Graphic562_Box_ChampionIcons
 extern Color gChampionColor[4]; // @ G0046_auc_Graphic562_ChampionColor
 
@@ -365,7 +368,7 @@ public:
 	Thing getSlot(ChampionSlot slot) { return _slots[slot]; }
 	void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; }
 
-	Skill getSkill(ChampionSkill skill) { return _skills[skill]; }
+	Skill &getSkill(ChampionSkill skill) { return _skills[skill]; }
 	void setSkillExp(ChampionSkill skill,  int32 val) { _skills[skill]._experience = val; }
 	void setSkillTempExp(ChampionSkill skill,  int16 val) { _skills[skill]._temporaryExperience= val; }
 
@@ -453,6 +456,7 @@ public:
 	void drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues
 	void drawSlot(uint16 champIndex, ChampionSlot slotIndex); // @ F0291_CHAMPION_DrawSlot
 	void renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename
+	uint16 getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex);// @ F0303_CHAMPION_GetSkillLevel
 };
 
 


Commit: 17f2a7f2e64caddaf437bac9947c1e15e659725b
    https://github.com/scummvm/scummvm/commit/17f2a7f2e64caddaf437bac9947c1e15e659725b
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0332_INVENTORY_DrawIconToViewport

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/objectman.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index a352403..60f6b47 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -51,8 +51,8 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 					F0341_INVENTORY_DrawPanel_Scroll // done
 						F0340_INVENTORY_DrawPanel_ScrollTextLine // done
 					F0333_INVENTORY_OpenAndDrawChest // done
-					F0303_CHAMPION_GetSkillLevel
-					F0332_INVENTORY_DrawIconToViewport
+					F0303_CHAMPION_GetSkillLevel // done
+					F0332_INVENTORY_DrawIconToViewport // done 
 					F0336_INVENTORY_DrawPanel_BuildObjectAttributesString
 					F0335_INVENTORY_DrawPanel_ObjectDescriptionString
 					F0339_INVENTORY_DrawPanel_ArrowOrEye
@@ -75,7 +75,7 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 				JUNK_INFO // done
 		G0411_i_LeaderIndex // done
 		G0299_ui_CandidateChampionOrdinal // done
-	F0388_MENUS_ClearActingChampion // done.
+	F0388_MENUS_ClearActingChampion // done
 		F0292_CHAMPION_DrawState // done
 		G0508_B_RefreshActionArea // done
 		G0506_ui_ActingChampionOrdinal // done
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index a64c489..7124e1b 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -311,7 +311,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 		objMan.drawIconInSlotBox(kSlotBoxInventoryActionHand, kIconIndiceContainerChestOpen);
 	}
 	dispMan.blitToScreen(dispMan.getBitmap(kPanelOpenChestIndice), 144, 0, 0, gBoxPanel, kColorRed);
-	
+
 	int16 chestSlotIndex = 0;
 	Thing thing = chest->getSlot();
 	int16 thingCount = 0;
@@ -330,4 +330,12 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 	}
 }
 
+void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos) {
+	static byte iconBitmap[16 * 16];
+	Box box;
+	box._x2 = (box._x1 = xPos) + 15 + 1;
+	box._y2 = (box._y1 = yPos) + 15 + 1;
+	_vm->_objectMan->extractIconFromBitmap(iconIndex, iconBitmap);
+	_vm->_displayMan->blitToScreen(iconBitmap, 16, 0, 0, box, kColorNoTransparency, gDungeonViewport);
+}
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 3232ab5..4b06ce0 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -70,6 +70,7 @@ public:
 	void drawPanelScrollTextLine(int16 yPos, char *text); // @ F0340_INVENTORY_DrawPanel_ScrollTextLine
 	void drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll
 	void openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye); // @ F0333_INVENTORY_OpenAndDrawChest
+	void drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos); // @ F0332_INVENTORY_DrawIconToViewport
 
 };
 
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index a2ceafe..1dbba69 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -54,7 +54,7 @@ public:
 
 	IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType
 	IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
-	void extractIconFromBitmap(uint16 iconIndex, byte *srcBitmap); // F0036_OBJECT_ExtractIconFromBitmap
+	void extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // F0036_OBJECT_ExtractIconFromBitmap
 	void drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox
 };
 


Commit: cb9979fade6cd5746ea54c261bdaa8c28e375f3e
    https://github.com/scummvm/scummvm/commit/cb9979fade6cd5746ea54c261bdaa8c28e375f3e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0336_INVENTORY_DrawPanel_BuildObjectAttributesString

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index 60f6b47..064e095 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -53,7 +53,7 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 					F0333_INVENTORY_OpenAndDrawChest // done
 					F0303_CHAMPION_GetSkillLevel // done
 					F0332_INVENTORY_DrawIconToViewport // done 
-					F0336_INVENTORY_DrawPanel_BuildObjectAttributesString
+					F0336_INVENTORY_DrawPanel_BuildObjectAttributesString // done
 					F0335_INVENTORY_DrawPanel_ObjectDescriptionString
 					F0339_INVENTORY_DrawPanel_ArrowOrEye
 					G0430_apc_DirectionNames
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 7124e1b..b23321b 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -338,4 +338,35 @@ void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yP
 	_vm->_objectMan->extractIconFromBitmap(iconIndex, iconBitmap);
 	_vm->_displayMan->blitToScreen(iconBitmap, 16, 0, 0, box, kColorNoTransparency, gDungeonViewport);
 }
+
+void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) {
+	uint16 identicalBitCount = 0;
+	int16 attribMask = 1;
+	for (uint16 stringIndex = 0; stringIndex < 16; stringIndex++, attribMask <<= 1) {
+		if (attribMask & potentialAttribMask & actualAttribMask) {
+			identicalBitCount++;
+		}
+	}
+
+	if (identicalBitCount == 0) {
+		*destString = '\0';
+		return;
+	}
+
+	strcpy(destString, prefixString);
+
+	attribMask = 1;
+	for (uint16 stringIndex = 0; stringIndex < 16; stringIndex++, attribMask <<= 1) {
+		if (attribMask & potentialAttribMask & actualAttribMask) {
+			strcat(destString, attribStrings[stringIndex]);
+			if (identicalBitCount-- > 2) {
+				strcat(destString, ", ");
+			} else if (identicalBitCount == 1) {
+				strcat(destString, " AND "); // TODO: localization
+			}
+		}
+	}
+
+	strcat(destString, suffixString);
+}
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 4b06ce0..ac68b54 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -71,6 +71,8 @@ public:
 	void drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll
 	void openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye); // @ F0333_INVENTORY_OpenAndDrawChest
 	void drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos); // @ F0332_INVENTORY_DrawIconToViewport
+	void buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char ** attribStrings,
+									char *destString, char *prefixString, char *suffixString); // @ F0336_INVENTORY_DrawPanel_BuildObjectAttributesString
 
 };
 


Commit: c40aca2d2d146ca6e3e56ee11dd504d9e4d31afb
    https://github.com/scummvm/scummvm/commit/c40aca2d2d146ca6e3e56ee11dd504d9e4d31afb
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0335_INVENTORY_DrawPanel_ObjectDescriptionString

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index 064e095..ab44a3f 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -54,14 +54,16 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 					F0303_CHAMPION_GetSkillLevel // done
 					F0332_INVENTORY_DrawIconToViewport // done 
 					F0336_INVENTORY_DrawPanel_BuildObjectAttributesString // done
-					F0335_INVENTORY_DrawPanel_ObjectDescriptionString
+					F0335_INVENTORY_DrawPanel_ObjectDescriptionString // done 
+						G0421_i_ObjectDescriptionTextX // done
+						G0422_i_ObjectDescriptionTextY // done
 					F0339_INVENTORY_DrawPanel_ArrowOrEye
 					G0430_apc_DirectionNames
 					G0034_s_Graphic562_Box_ObjectDescriptionCircle
 					G0032_s_Graphic562_Box_Panel
 					G0352_apc_ObjectNames
 					G0237_as_Graphic559_ObjectInfo
-					G0422_i_ObjectDescriptionTextY
+					G0422_i_ObjectDescriptionTextY // done
 
 				F0346_INVENTORY_DrawPanel_ResurrectReincarnate // done
 			F0291_CHAMPION_DrawSlot // done
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index b23321b..fe7807d 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -369,4 +369,40 @@ void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 a
 
 	strcat(destString, suffixString);
 }
+
+void InventoryMan::drawPanelObjectDescriptionString(char* descString) {
+	if (descString[0] == '\f') { // form feed
+		descString++;
+		_objDescTextXpos = 108;
+		_objDescTextYpos = 59;
+	}
+
+	if (descString[0]) {
+		char stringTmpBuff[128];
+		strcpy(stringTmpBuff, descString);
+
+		char *stringLine = stringTmpBuff;
+		bool severalLines = false;
+		char *string = nullptr;
+		while (*stringLine) {
+			if (strlen(stringLine) > 18) { // if string is too long to fit on one line
+				string = &stringLine[17];
+				while (*string != ' ') // go back to the last space character
+					string--;
+
+				*string = '\0'; // and split the string there
+				severalLines = true;
+			}
+
+			_vm->_textMan->printToViewport(_objDescTextXpos, _objDescTextYpos, kColorLightestGray, stringLine);
+			_objDescTextYpos += 7;
+			if (severalLines) {
+				severalLines = false;
+				stringLine = ++string;
+			} else {
+				*stringLine = '\0';
+			}
+		}
+	}
+}
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index ac68b54..18fe179 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -58,6 +58,8 @@ public:
 	PanelContent _panelContent; // @ G0424_i_PanelContent 
 	Thing _chestSlots[8]; // @ G0425_aT_ChestSlots
 	Thing _openChest; // @ G0426_T_OpenChest
+	int16 _objDescTextXpos; // @ G0421_i_ObjectDescriptionTextX
+	int16 _objDescTextYpos; // @ G0422_i_ObjectDescriptionTextY
 
 	void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE
 	void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait
@@ -73,6 +75,7 @@ public:
 	void drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos); // @ F0332_INVENTORY_DrawIconToViewport
 	void buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char ** attribStrings,
 									char *destString, char *prefixString, char *suffixString); // @ F0336_INVENTORY_DrawPanel_BuildObjectAttributesString
+	void drawPanelObjectDescriptionString(char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString
 
 };
 


Commit: 792f48858baec961fde793e5d80222e2bb03525d
    https://github.com/scummvm/scummvm/commit/792f48858baec961fde793e5d80222e2bb03525d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0339_INVENTORY_DrawPanel_ArrowOrEye, G0033_s_Graphic562_Box_ArrowOrEye

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index ab44a3f..65b79bb 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -57,7 +57,7 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 					F0335_INVENTORY_DrawPanel_ObjectDescriptionString // done 
 						G0421_i_ObjectDescriptionTextX // done
 						G0422_i_ObjectDescriptionTextY // done
-					F0339_INVENTORY_DrawPanel_ArrowOrEye
+					F0339_INVENTORY_DrawPanel_ArrowOrEye // done 
 					G0430_apc_DirectionNames
 					G0034_s_Graphic562_Box_ObjectDescriptionCircle
 					G0032_s_Graphic562_Box_Panel
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 25ffbb2..e4fe12a 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -76,7 +76,9 @@ enum GraphicIndice {
 	kMenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES
 	kMenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND
 	kPanelOpenScrollIndice = 23, // @ C023_GRAPHIC_PANEL_OPEN_SCROLL
-	kPanelOpenChestIndice = 25 // @ C025_GRAPHIC_PANEL_OPEN_CHEST
+	kPanelOpenChestIndice = 25, // @ C025_GRAPHIC_PANEL_OPEN_CHEST
+	kEyeForObjectDescriptionIndice = 19, // @ C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION
+	kArrowForChestContentIndice = 18 // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT
 };
 
 extern uint16 gPalSwoosh[16];
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index fe7807d..9724d83 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -405,4 +405,13 @@ void InventoryMan::drawPanelObjectDescriptionString(char* descString) {
 		}
 	}
 }
+
+Box gBoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye 
+
+void InventoryMan::drawPanelArrowOrEye(bool pressingEye) {
+	DisplayMan &dispMan = *_vm->_displayMan;
+	dispMan.blitToScreen(dispMan.getBitmap(pressingEye ? kEyeForObjectDescriptionIndice : kArrowForChestContentIndice),
+						 16, 0, 0, gBoxArrowOrEye, kColorRed, gDungeonViewport);
+}
+
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 18fe179..8868a53 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -76,6 +76,7 @@ public:
 	void buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char ** attribStrings,
 									char *destString, char *prefixString, char *suffixString); // @ F0336_INVENTORY_DrawPanel_BuildObjectAttributesString
 	void drawPanelObjectDescriptionString(char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString
+	void drawPanelArrowOrEye(bool pressingEye); // @ F0339_INVENTORY_DrawPanel_ArrowOrEye
 
 };
 


Commit: 1f73d771ce31223dc94743432ec8368905d408f1
    https://github.com/scummvm/scummvm/commit/1f73d771ce31223dc94743432ec8368905d408f1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: F0342_INVENTORY_DrawPanel_Object, F0031_OBJECT_LoadNames

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/TODOs/todo.txt
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/objectman.cpp
    engines/dm/objectman.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index 65b79bb..fb7021e 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -47,7 +47,7 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 				G0037_s_Graphic562_Box_Poisoned // done
 			F0351_INVENTORY_DrawChampionSkillsAndStatistics // skip -----------------
 			F0347_INVENTORY_DrawPanel // done
-				F0342_INVENTORY_DrawPanel_Object
+				F0342_INVENTORY_DrawPanel_Object // done
 					F0341_INVENTORY_DrawPanel_Scroll // done
 						F0340_INVENTORY_DrawPanel_ScrollTextLine // done
 					F0333_INVENTORY_OpenAndDrawChest // done
@@ -58,11 +58,11 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 						G0421_i_ObjectDescriptionTextX // done
 						G0422_i_ObjectDescriptionTextY // done
 					F0339_INVENTORY_DrawPanel_ArrowOrEye // done 
-					G0430_apc_DirectionNames
-					G0034_s_Graphic562_Box_ObjectDescriptionCircle
-					G0032_s_Graphic562_Box_Panel
-					G0352_apc_ObjectNames
-					G0237_as_Graphic559_ObjectInfo
+					G0430_apc_DirectionNames // done
+					G0034_s_Graphic562_Box_ObjectDescriptionCircle // done
+					G0032_s_Graphic562_Box_Panel // done
+					G0352_apc_ObjectNames // done
+					G0237_as_Graphic559_ObjectInfo // done
 					G0422_i_ObjectDescriptionTextY // done
 
 				F0346_INVENTORY_DrawPanel_ResurrectReincarnate // done
diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 558fc8a..196d68f 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -16,6 +16,7 @@ Todo:
 	I forgot to add localization warnings
 	Attend to Arnaud's notes on github
 	Double check enums with hex literals, I think I screwed the regex when processing them
+	Double check strcat, strstr usages, I might have messed them up in many places
 
 	Missing functions:
 		 Add missing  F0163_DUNGEON_LinkThingToList in MovesensMan::sensorIsTriggeredByClickOnWall (I don't think it's safe yet)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 86425b4..8ea8a6d 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -430,7 +430,6 @@ class ChampionMan {
 	ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell
 	int16 getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue
 	void drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue
-	Common::String getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger
 public:
 	Champion _champions[4];
 	uint16 _partyChampionCount;	// @ G0305_ui_PartyChampionCount
@@ -457,6 +456,7 @@ public:
 	void drawSlot(uint16 champIndex, ChampionSlot slotIndex); // @ F0291_CHAMPION_DrawSlot
 	void renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename
 	uint16 getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex);// @ F0303_CHAMPION_GetSkillLevel
+	Common::String getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger
 };
 
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index a3479d2..138e7b8 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -132,6 +132,7 @@ void DMEngine::initializeGame() {
 
 	_displayMan->loadFloorSet(kFloorSetStone);
 	_displayMan->loadWallSet(kWallSetStone);
+	_objectMan->loadObjectNames();
 
 	startGame();
 	warning("MISSING CODE: F0267_MOVE_GetMoveResult_CPSCE (if newGame)");
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 6d5a540..899e791 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1218,13 +1218,6 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 	return 0; // dummy
 }
 
-/* Object info */
-#define kObjectInfoIndexFirstScroll 0 // @ C000_OBJECT_INFO_INDEX_FIRST_SCROLL
-#define kObjectInfoIndexFirstContainer 1 // @ C001_OBJECT_INFO_INDEX_FIRST_CONTAINER
-#define kObjectInfoIndexFirstPotion 2 // @ C002_OBJECT_INFO_INDEX_FIRST_POTION
-#define kObjectInfoIndexFirstWeapon 23 // @ C023_OBJECT_INFO_INDEX_FIRST_WEAPON
-#define kObjectInfoIndexFirstArmour 69 // @ C069_OBJECT_INFO_INDEX_FIRST_ARMOUR
-#define kObjectInfoIndexFirstJunk 127 // @ C127_OBJECT_INFO_INDEX_FIRST_JUNK
 
 int16 DungeonMan::getObjectInfoIndex(Thing thing) {
 	uint16 *rawType = getThingData(thing);
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 767044e..69746ac 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -34,6 +34,14 @@
 
 namespace DM {
 
+/* Object info */
+#define kObjectInfoIndexFirstScroll 0 // @ C000_OBJECT_INFO_INDEX_FIRST_SCROLL
+#define kObjectInfoIndexFirstContainer 1 // @ C001_OBJECT_INFO_INDEX_FIRST_CONTAINER
+#define kObjectInfoIndexFirstPotion 2 // @ C002_OBJECT_INFO_INDEX_FIRST_POTION
+#define kObjectInfoIndexFirstWeapon 23 // @ C023_OBJECT_INFO_INDEX_FIRST_WEAPON
+#define kObjectInfoIndexFirstArmour 69 // @ C069_OBJECT_INFO_INDEX_FIRST_ARMOUR
+#define kObjectInfoIndexFirstJunk 127 // @ C127_OBJECT_INFO_INDEX_FIRST_JUNK
+
 #define kMapXNotOnASquare -1 // @ CM1_MAPX_NOT_ON_A_SQUARE
 
 enum ElementType {
@@ -89,7 +97,7 @@ public:
 }; // @ OBJECT_INFO
 
 extern ObjectInfo gObjectInfo[180];
-				
+
 enum ArmourAttribute {
 	kArmourAttributeIsAShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD
 	kArmourAttributeSharpDefense = 0x0007 // @ MASK0x0007_SHARP_DEFENSE
@@ -129,18 +137,18 @@ extern ArmourInfo gArmourInfo[58];
 class WeaponInfo {
 
 public:
-        uint16 _weight;
-        uint16 _class;
-        uint16 _strength;
-        uint16 _kineticEnergy;
+	uint16 _weight;
+	uint16 _class;
+	uint16 _strength;
+	uint16 _kineticEnergy;
 private:
 	uint16 _attributes; /* Bits 15-13 Unreferenced */
 public:
-        WeaponInfo(uint16 weight, uint16 wClass, uint16 strength, uint16 kineticEnergy, uint16 attributes)
-        	: _weight(weight), _class(wClass), _strength(strength), _kineticEnergy(kineticEnergy), _attributes(attributes) {}
+	WeaponInfo(uint16 weight, uint16 wClass, uint16 strength, uint16 kineticEnergy, uint16 attributes)
+		: _weight(weight), _class(wClass), _strength(strength), _kineticEnergy(kineticEnergy), _attributes(attributes) {}
 
-        uint16 getShootAttack() {return _attributes & 0xFF;} // @ M65_SHOOT_ATTACK
-        uint16 getProjectileAspectOrdinal() {return (_attributes >> 8) & 0x1F;} // @ M66_PROJECTILE_ASPECT_ORDINAL
+	uint16 getShootAttack() { return _attributes & 0xFF; } // @ M65_SHOOT_ATTACK
+	uint16 getProjectileAspectOrdinal() { return (_attributes >> 8) & 0x1F; } // @ M66_PROJECTILE_ASPECT_ORDINAL
 }; // @ WEAPON_INFO
 
 extern WeaponInfo gWeaponInfo[46];
@@ -359,6 +367,9 @@ public:
 	bool isLit() { return (_desc >> 15) & 1; }
 	uint16 getChargeCount() { return (_desc >> 10) & 0xF; }
 	Thing getNextThing() { return _nextThing; }
+	uint16 getCursed() { return (_desc >> 8) & 1; }
+	uint16 getPoisoned() { return (_desc >> 9) & 1; }
+	uint16 getBroken() { return (_desc >> 14) & 1; }
 }; // @ WEAPON
 
 enum ArmourType {
@@ -376,6 +387,8 @@ public:
 
 	ArmourType getType() { return (ArmourType)(_attributes & 0x7F); }
 	Thing getNextThing() { return _nextThing; }
+	uint16 getCursed() { return (_attributes >> 8) & 1; }
+	uint16 getBroken() { return (_attributes >> 13) & 1; }
 }; // @ ARMOUR
 
 class Scroll {
@@ -416,6 +429,7 @@ public:
 	PotionType getType() { return (PotionType)((_attributes >> 8) & 0x7F); }
 	void setType(PotionType val) { _attributes = (_attributes & ~(0x7F << 8)) | ((val & 0x7F) << 8); }
 	Thing getNextThing() { return _nextThing; }
+	uint16 getPower() { return _attributes & 0xFF; }
 }; // @ POTION
 
 class Container {
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 7466cb4..b1c5c6a 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -731,8 +731,7 @@ void DisplayMan::unpackGraphics() {
 	loadFNT1intoBitmap(kFontGraphicIndice, _bitmaps[kFontGraphicIndice]);
 }
 
-void DisplayMan::loadFNT1intoBitmap(uint16 index, byte* destBitmap)
-{
+void DisplayMan::loadFNT1intoBitmap(uint16 index, byte* destBitmap) {
 	uint8 *data = _packedBitmaps + _packedItemPos[index];
 	for (uint16 i = 0; i < 6; i++) {
 		for (uint16 w = 0; w < 128; ++w) {
@@ -817,12 +816,11 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uin
 		}
 }
 
-	void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent, Viewport& viewport)
-	{
-		blitToBitmap(srcBitmap, srcWidth, srcX, srcY, destBitmap, destWidth, box._x1, box._x2, box._y1, box._y2, transparent, viewport);
-	}
+void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent, Viewport& viewport) {
+	blitToBitmap(srcBitmap, srcWidth, srcX, srcY, destBitmap, destWidth, box._x1, box._x2, box._y1, box._y2, transparent, viewport);
+}
 
-	void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
+void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 							  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
 							  Color transparent, Viewport &viewport) {
 	blitToBitmap(srcBitmap, srcWidth, srcX, srcY,
@@ -1581,6 +1579,14 @@ byte* DisplayMan::getBitmap(uint16 index) {
 	return _bitmaps[index];
 }
 
+Common::MemoryReadStream DisplayMan::getCompressedData(uint16 index) {
+	return Common::MemoryReadStream(_packedBitmaps + _packedItemPos[index], getCompressedDataSize(index), DisposeAfterUse::NO);
+}
+
+uint32 DisplayMan::getCompressedDataSize(uint16 index) {
+	return _packedItemPos[index + 1] - _packedItemPos[index];
+}
+
 void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) {
 	uint16 width = box._x2 - box._x1;
 	for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y)
@@ -1588,8 +1594,8 @@ void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) {
 }
 
 void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
-				  Box &box,
-				  Color transparent, Viewport &viewport) {
+							  Box &box,
+							  Color transparent, Viewport &viewport) {
 	blitToScreen(srcBitmap, srcWidth, srcX, srcY, box._x1, box._x2, box._y1, box._y2, transparent, viewport);
 }
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index e4fe12a..b6a32c5 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -30,6 +30,7 @@
 
 #include "common/scummsys.h"
 #include "common/rect.h"
+#include "common/memstream.h"
 #include "dm.h"
 
 namespace DM {
@@ -78,7 +79,8 @@ enum GraphicIndice {
 	kPanelOpenScrollIndice = 23, // @ C023_GRAPHIC_PANEL_OPEN_SCROLL
 	kPanelOpenChestIndice = 25, // @ C025_GRAPHIC_PANEL_OPEN_CHEST
 	kEyeForObjectDescriptionIndice = 19, // @ C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION
-	kArrowForChestContentIndice = 18 // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT
+	kArrowForChestContentIndice = 18, // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT
+	kObjectDescCircleIndice = 29 // @ C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE
 };
 
 extern uint16 gPalSwoosh[16];
@@ -364,6 +366,8 @@ public:
 	void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
 	byte* getBitmap(uint16 index);
+	Common::MemoryReadStream getCompressedData(uint16 index);
+	uint32 getCompressedDataSize(uint16 index);
 
 	int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
 	int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 9724d83..4e3d0d3 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -205,7 +205,7 @@ void InventoryMan::drawPanel() {
 	if (thing == Thing::_thingNone) {
 		drawPanelFoodWaterPoisoned();
 	} else {
-		warning("MISSING CODE: F0342_INVENTORY_DrawPanel_Object(L1075_T_Thing, C0_FALSE);");
+		drawPanelObject(thing, false);
 	}
 }
 
@@ -414,4 +414,144 @@ void InventoryMan::drawPanelArrowOrEye(bool pressingEye) {
 						 16, 0, 0, gBoxArrowOrEye, kColorRed, gDungeonViewport);
 }
 
+
+Box gBoxObjectDescCircle = Box(105, 136, 53, 79); // @ G0034_s_Graphic562_Box_ObjectDescriptionCircle 
+
+#define kDescriptionMaskConsumable 0x0001 // @ MASK0x0001_DESCRIPTION_CONSUMABLE
+#define kDescriptionMaskPoisoned 0x0002 // @ MASK0x0002_DESCRIPTION_POISONED  
+#define kDescriptionMaskBroken 0x0004 // @ MASK0x0004_DESCRIPTION_BROKEN    
+#define kDescriptionMaskCursed 0x0008 // @ MASK0x0008_DESCRIPTION_CURSED    
+
+void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
+	DungeonMan &dunMan = *_vm->_dungeonMan;
+	ObjectMan &objMan = *_vm->_objectMan;
+	DisplayMan &dispMan = *_vm->_displayMan;
+	ChampionMan &champMan = *_vm->_championMan;
+	TextMan &textMan = *_vm->_textMan;
+
+	if (_vm->_pressingEye || _vm->_pressingMouth) {
+		warning("BUG0_48 The contents of a chest are reorganized when an object with a statistic modifier is placed or removed on a champion");
+		closeChest();
+	}
+
+	uint16 *rawThingPtr = dunMan.getThingData(thingToDraw);
+	drawPanelObjectDescriptionString("\f"); // form feed
+	ThingType thingType = thingToDraw.getType();
+	if (thingType == kScrollThingType) {
+		drawPanelScroll((Scroll*)rawThingPtr);
+	} else if (thingType == kContainerThingType) {
+		openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye);
+	} else {
+		IconIndice iconIndex = objMan.getIconIndex(thingToDraw);
+		dispMan.blitToScreen(dispMan.getBitmap(kPanelEmptyIndice), 144, 0, 0, gBoxPanel, kColorRed, gDungeonViewport);
+		dispMan.blitToScreen(dispMan.getBitmap(kObjectDescCircleIndice), 32, 0, 0, gBoxObjectDescCircle, kColorDarkestGray, gDungeonViewport);
+
+		char *descString = nullptr;
+		char str[40];
+		if (iconIndex == kIconIndiceJunkChampionBones) {
+			strcpy(str, champMan._champions[((Junk*)rawThingPtr)->getChargeCount()]._name);  // TODO: localization
+			strcat(str, " "); // TODO: localization
+			strcat(str, objMan._objectNames[iconIndex]);  // TODO: localization
+
+			descString = str;
+		} else if ((thingType == kPotionThingType)
+				   && (iconIndex != kIconIndicePotionWaterFlask)
+				   && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_inventoryChampionOrdinal), kChampionSkillPriest) > 1)) {
+			str[0] = '_' + ((Potion*)rawThingPtr)->getPower() / 40;
+			str[1] = ' ';
+			str[2] = '\0';
+			strcat(str, objMan._objectNames[iconIndex]);
+			descString = str;
+		} else {
+			descString = objMan._objectNames[iconIndex];
+		}
+
+		textMan.printToViewport(134, 68, kColorLightestGray, descString);
+		drawIconToViewport(iconIndex, 111, 59);
+
+		char *attribString[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"}; // TODO: localization
+
+		_objDescTextYpos = 87;
+
+		uint16 potentialAttribMask;
+		uint16 actualAttribMask;
+		switch (thingType) {
+		case kWeaponThingType: {
+			potentialAttribMask = kDescriptionMaskCursed | kDescriptionMaskPoisoned | kDescriptionMaskBroken;
+			Weapon *weapon = (Weapon*)rawThingPtr;
+			actualAttribMask = (weapon->getCursed() << 3) | (weapon->getPoisoned() << 1) | (weapon->getBroken() << 2);
+			if ((iconIndex >= kIconIndiceWeaponTorchUnlit)
+				&& (iconIndex <= kIconIndiceWeaponTorchLit)
+				&& (weapon->getChargeCount() == 0)) {
+				drawPanelObjectDescriptionString("(BURNT OUT)"); // TODO: localization
+			}
+			break;
+		}
+		case kArmourThingType: {
+			potentialAttribMask = kDescriptionMaskCursed | kDescriptionMaskBroken;
+			Armour *armour = (Armour*)rawThingPtr;
+			actualAttribMask = (armour->getCursed() << 3) | (armour->getBroken() << 2);
+			break;
+		}
+		case kPotionThingType: {
+			actualAttribMask = kDescriptionMaskConsumable;
+			Potion *potion = (Potion*)rawThingPtr;
+			actualAttribMask = gObjectInfo[kObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots();
+			break;
+		}
+		case kJunkThingType: {
+			Junk *junk = (Junk*)rawThingPtr;
+			if ((iconIndex >= kIconIndiceJunkWater) && (iconIndex <= kIconIndiceJunkWaterSkin)) {
+				potentialAttribMask = 0;
+				switch (junk->getChargeCount()) {
+				case 0:
+					descString = "(EMPTY)"; // TODO: localization
+					break;
+				case 1:
+					descString = "(ALMOST EMPTY)"; // TODO: localization
+					break;
+				case 2:
+					descString = "(ALMOST FULL)"; // TODO: localization
+					break;
+				case 3:
+					descString = "(FULL)"; // TODO: localization
+					break;
+				}
+				drawPanelObjectDescriptionString(descString);
+			} else if ((iconIndex >= kIconIndiceJunkCompassNorth) && (iconIndex <= kIconIndiceJunkCompassWest)) {
+				potentialAttribMask = 0;
+				strcpy(str, "PARTY FACING "); // TODO: localization
+				static char* directionName[4] = {"NORTH", "EAST", "SOUTH", "WEST"}; // G0430_apc_DirectionNames // TODO: localization
+				strcat(str, directionName[iconIndex]);
+				drawPanelObjectDescriptionString(str);
+			} else {
+				potentialAttribMask = kDescriptionMaskConsumable;
+				actualAttribMask = gObjectInfo[kObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots();
+			}
+			break;
+		}
+		} // end of switch 
+
+		if (potentialAttribMask) {
+			buildObjectAttributeString(potentialAttribMask, actualAttribMask, attribString, str, "(", ")");
+			drawPanelObjectDescriptionString(str);
+		}
+
+		strcpy(str, "WEIGHS "); // TODO: localization
+
+		uint16 weight = dunMan.getObjectWeight(thingToDraw);
+		strcat(str, champMan.getStringFromInteger(weight / 10, false, 3).c_str());
+
+		strcat(str, "."); // TODO: localization
+
+		weight -= (weight / 10) * 10;
+		strcat(str, champMan.getStringFromInteger(weight, false, 1).c_str()); 
+
+		strcat(str, " KG."); // TODO: localization
+
+		drawPanelObjectDescriptionString(str);
+	}
+	drawPanelArrowOrEye(pressingEye);
+
+}
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 8868a53..952511d 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -77,6 +77,7 @@ public:
 									char *destString, char *prefixString, char *suffixString); // @ F0336_INVENTORY_DrawPanel_BuildObjectAttributesString
 	void drawPanelObjectDescriptionString(char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString
 	void drawPanelArrowOrEye(bool pressingEye); // @ F0339_INVENTORY_DrawPanel_ArrowOrEye
+	void drawPanelObject(Thing thingToDraw, bool pressingEye); // @ F0342_INVENTORY_DrawPanel_Object
 
 };
 
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index c92427b..c83c16c 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -43,52 +43,81 @@ int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconI
 
 ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {
 	/* 8 for champion hands in status boxes, 30 for champion inventory, 8 for chest */
-	_slotBoxes[0] = SlotBox(4,  10, 0);    /* Champion Status Box 0 Ready Hand */
-	_slotBoxes[1] = SlotBox(24,  10, 0);   /* Champion Status Box 0 Action Hand */
-	_slotBoxes[2] = SlotBox(73,  10, 0);   /* Champion Status Box 1 Ready Hand */
-	_slotBoxes[3] = SlotBox(93,  10, 0);   /* Champion Status Box 1 Action Hand */
-	_slotBoxes[4] = SlotBox(142,  10, 0);  /* Champion Status Box 2 Ready Hand */
-	_slotBoxes[5] = SlotBox(162,  10, 0);  /* Champion Status Box 2 Action Hand */
-	_slotBoxes[6] = SlotBox(211,  10, 0);  /* Champion Status Box 3 Ready Hand */
-	_slotBoxes[7] = SlotBox(231,  10, 0);  /* Champion Status Box 3 Action Hand */
-	_slotBoxes[8] = SlotBox(6,  53, 0);    /* Ready Hand */
-	_slotBoxes[9] = SlotBox(62,  53, 0);   /* Action Hand */
-	_slotBoxes[10] = SlotBox(34,  26, 0);  /* Head */
-	_slotBoxes[11] = SlotBox(34,  46, 0);  /* Torso */
-	_slotBoxes[12] = SlotBox(34,  66, 0);  /* Legs */
-	_slotBoxes[13] = SlotBox(34,  86, 0);  /* Feet */
-	_slotBoxes[14] = SlotBox(6,  90, 0);   /* Pouch 2 */
-	_slotBoxes[15] = SlotBox(79,  73, 0);  /* Quiver Line2 1 */
-	_slotBoxes[16] = SlotBox(62,  90, 0);  /* Quiver Line1 2 */
-	_slotBoxes[17] = SlotBox(79,  90, 0);  /* Quiver Line2 2 */
-	_slotBoxes[18] = SlotBox(6,  33, 0);   /* Neck */
-	_slotBoxes[19] = SlotBox(6,  73, 0);   /* Pouch 1 */
-	_slotBoxes[20] = SlotBox(62,  73, 0);  /* Quiver Line1 1 */
-	_slotBoxes[21] = SlotBox(66,  33, 0);  /* Backpack Line1 1 */
-	_slotBoxes[22] = SlotBox(83,  16, 0);  /* Backpack Line2 2 */
-	_slotBoxes[23] = SlotBox(100,  16, 0); /* Backpack Line2 3 */
-	_slotBoxes[24] = SlotBox(117,  16, 0); /* Backpack Line2 4 */
-	_slotBoxes[25] = SlotBox(134,  16, 0); /* Backpack Line2 5 */
-	_slotBoxes[26] = SlotBox(151,  16, 0); /* Backpack Line2 6 */
-	_slotBoxes[27] = SlotBox(168,  16, 0); /* Backpack Line2 7 */
-	_slotBoxes[28] = SlotBox(185,  16, 0); /* Backpack Line2 8 */
-	_slotBoxes[29] = SlotBox(202,  16, 0); /* Backpack Line2 9 */
-	_slotBoxes[30] = SlotBox(83,  33, 0);  /* Backpack Line1 2 */
-	_slotBoxes[31] = SlotBox(100,  33, 0); /* Backpack Line1 3 */
-	_slotBoxes[32] = SlotBox(117,  33, 0); /* Backpack Line1 4 */
-	_slotBoxes[33] = SlotBox(134,  33, 0); /* Backpack Line1 5 */
-	_slotBoxes[34] = SlotBox(151,  33, 0); /* Backpack Line1 6 */
-	_slotBoxes[35] = SlotBox(168,  33, 0); /* Backpack Line1 7 */
-	_slotBoxes[36] = SlotBox(185,  33, 0); /* Backpack Line1 8 */
-	_slotBoxes[37] = SlotBox(202,  33, 0); /* Backpack Line1 9 */
-	_slotBoxes[38] = SlotBox(117,  59, 0); /* Chest 1 */
-	_slotBoxes[39] = SlotBox(106,  76, 0); /* Chest 2 */
-	_slotBoxes[40] = SlotBox(111,  93, 0); /* Chest 3 */
-	_slotBoxes[41] = SlotBox(128,  98, 0); /* Chest 4 */
+	_slotBoxes[0] = SlotBox(4, 10, 0);    /* Champion Status Box 0 Ready Hand */
+	_slotBoxes[1] = SlotBox(24, 10, 0);   /* Champion Status Box 0 Action Hand */
+	_slotBoxes[2] = SlotBox(73, 10, 0);   /* Champion Status Box 1 Ready Hand */
+	_slotBoxes[3] = SlotBox(93, 10, 0);   /* Champion Status Box 1 Action Hand */
+	_slotBoxes[4] = SlotBox(142, 10, 0);  /* Champion Status Box 2 Ready Hand */
+	_slotBoxes[5] = SlotBox(162, 10, 0);  /* Champion Status Box 2 Action Hand */
+	_slotBoxes[6] = SlotBox(211, 10, 0);  /* Champion Status Box 3 Ready Hand */
+	_slotBoxes[7] = SlotBox(231, 10, 0);  /* Champion Status Box 3 Action Hand */
+	_slotBoxes[8] = SlotBox(6, 53, 0);    /* Ready Hand */
+	_slotBoxes[9] = SlotBox(62, 53, 0);   /* Action Hand */
+	_slotBoxes[10] = SlotBox(34, 26, 0);  /* Head */
+	_slotBoxes[11] = SlotBox(34, 46, 0);  /* Torso */
+	_slotBoxes[12] = SlotBox(34, 66, 0);  /* Legs */
+	_slotBoxes[13] = SlotBox(34, 86, 0);  /* Feet */
+	_slotBoxes[14] = SlotBox(6, 90, 0);   /* Pouch 2 */
+	_slotBoxes[15] = SlotBox(79, 73, 0);  /* Quiver Line2 1 */
+	_slotBoxes[16] = SlotBox(62, 90, 0);  /* Quiver Line1 2 */
+	_slotBoxes[17] = SlotBox(79, 90, 0);  /* Quiver Line2 2 */
+	_slotBoxes[18] = SlotBox(6, 33, 0);   /* Neck */
+	_slotBoxes[19] = SlotBox(6, 73, 0);   /* Pouch 1 */
+	_slotBoxes[20] = SlotBox(62, 73, 0);  /* Quiver Line1 1 */
+	_slotBoxes[21] = SlotBox(66, 33, 0);  /* Backpack Line1 1 */
+	_slotBoxes[22] = SlotBox(83, 16, 0);  /* Backpack Line2 2 */
+	_slotBoxes[23] = SlotBox(100, 16, 0); /* Backpack Line2 3 */
+	_slotBoxes[24] = SlotBox(117, 16, 0); /* Backpack Line2 4 */
+	_slotBoxes[25] = SlotBox(134, 16, 0); /* Backpack Line2 5 */
+	_slotBoxes[26] = SlotBox(151, 16, 0); /* Backpack Line2 6 */
+	_slotBoxes[27] = SlotBox(168, 16, 0); /* Backpack Line2 7 */
+	_slotBoxes[28] = SlotBox(185, 16, 0); /* Backpack Line2 8 */
+	_slotBoxes[29] = SlotBox(202, 16, 0); /* Backpack Line2 9 */
+	_slotBoxes[30] = SlotBox(83, 33, 0);  /* Backpack Line1 2 */
+	_slotBoxes[31] = SlotBox(100, 33, 0); /* Backpack Line1 3 */
+	_slotBoxes[32] = SlotBox(117, 33, 0); /* Backpack Line1 4 */
+	_slotBoxes[33] = SlotBox(134, 33, 0); /* Backpack Line1 5 */
+	_slotBoxes[34] = SlotBox(151, 33, 0); /* Backpack Line1 6 */
+	_slotBoxes[35] = SlotBox(168, 33, 0); /* Backpack Line1 7 */
+	_slotBoxes[36] = SlotBox(185, 33, 0); /* Backpack Line1 8 */
+	_slotBoxes[37] = SlotBox(202, 33, 0); /* Backpack Line1 9 */
+	_slotBoxes[38] = SlotBox(117, 59, 0); /* Chest 1 */
+	_slotBoxes[39] = SlotBox(106, 76, 0); /* Chest 2 */
+	_slotBoxes[40] = SlotBox(111, 93, 0); /* Chest 3 */
+	_slotBoxes[41] = SlotBox(128, 98, 0); /* Chest 4 */
 	_slotBoxes[42] = SlotBox(145, 101, 0); /* Chest 5 */
 	_slotBoxes[43] = SlotBox(162, 103, 0); /* Chest 6 */
 	_slotBoxes[44] = SlotBox(179, 104, 0); /* Chest 7 */
 	_slotBoxes[45] = SlotBox(196, 105, 0); /* Chest 8 */
+
+	_objectIconForMousePointer = nullptr;
+}
+
+ObjectMan::~ObjectMan() {
+	delete[] _objectIconForMousePointer;
+	delete[] _objectNames[0];
+}
+
+#define kObjectNamesGraphicIndice 556 // @ C556_GRAPHIC_OBJECT_NAMES
+
+void ObjectMan::loadObjectNames() {
+	DisplayMan &dispMan = *_vm->_displayMan;
+
+	_objectIconForMousePointer = new byte[16 * 16];
+
+	char *objectNames = new char[dispMan.getCompressedDataSize(kObjectNamesGraphicIndice) + kObjectNameCount];
+	Common::MemoryReadStream stream = dispMan.getCompressedData(kObjectNamesGraphicIndice);
+
+	for (uint16 objNameIndex = 0; objNameIndex < kObjectNameCount; ++objNameIndex) {
+		_objectNames[objNameIndex] = objectNames;
+
+		byte tmpByte;
+		for (tmpByte = stream.readByte(); !(tmpByte & 0x80); tmpByte = stream.readByte()) // last char of object name has 7th bit on
+			*objectNames++ = tmpByte; // write while not last char
+
+		*objectNames++ = tmpByte & 0x7F; // write without the 7th bit
+		*objectNames++ = '\0'; // terminate string
+	}
 }
 
 IconIndice ObjectMan::getObjectType(Thing thing) {
@@ -109,7 +138,7 @@ IconIndice ObjectMan::getIconIndex(Thing thing) {
 
 	if ((iconIndex != kIconIndiceNone) &&
 		(((iconIndex < kIconIndiceWeaponDagger) && (iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error
-		 ((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) ||
+		((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) ||
 		 (iconIndex == kIconIndicePotionEmptyFlask))
 		) {
 		uint16 *rawType = _vm->_dungeonMan->getThingData(thing);
@@ -178,9 +207,9 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 	Box box;
 	box._x1 = slotBox->_x;
 	box._y1 = slotBox->_y;
-	box._x2 = box._x1 + 15 + 1; 
+	box._x2 = box._x1 + 15 + 1;
 	box._y2 = box._y1 + 15 + 1;
-	
+
 	uint16 iconGraphicIndex;
 	for (iconGraphicIndex = 0; iconGraphicIndex < 7; ++iconGraphicIndex) {
 		if (gIconGraphicFirstIndex[iconGraphicIndex] > iconIndex) {
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index 1dbba69..e01d064 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -35,6 +35,8 @@ namespace DM {
 #define kSlotBoxInventoryActionHand 9 // @ C09_SLOT_BOX_INVENTORY_ACTION_HAND  
 #define kSlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT      
 
+#define kObjectNameCount 199 // @ C199_OBJECT_NAME_COUNT
+
 class SlotBox {
 public:
 	int16 _x;
@@ -49,8 +51,12 @@ class ObjectMan {
 
 public:
 	explicit ObjectMan(DMEngine *vm);
+	~ObjectMan();
+	void loadObjectNames();	// @ F0031_OBJECT_LoadNames
 
 	SlotBox _slotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes;
+	char *_objectNames[kObjectNameCount]; // @ G0352_apc_ObjectNames
+	byte *_objectIconForMousePointer; // @ G0412_puc_Bitmap_ObjectIconForMousePointer
 
 	IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType
 	IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex


Commit: 3442019d941adb0f8f6f4bf7957e881daed32a41
    https://github.com/scummvm/scummvm/commit/3442019d941adb0f8f6f4bf7957e881daed32a41
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0299_CHAMPION_ApplyObjectModifiersToStatistics

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/champion.cpp
    engines/dm/champion.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 196d68f..0357673 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -15,6 +15,7 @@ Todo:
 	Rename GraphicIndice enum entires and have their name include GraphicIndice
 	I forgot to add localization warnings
 	Attend to Arnaud's notes on github
+	Attend to sev's notes on github
 	Double check enums with hex literals, I think I screwed the regex when processing them
 	Double check strcat, strstr usages, I might have messed them up in many places
 
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index c974a71..deae8b4 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -132,6 +132,141 @@ Common::String ChampionMan::getStringFromInteger(uint16 val, bool padding, uint1
 	return result += valToStr;
 }
 
+void ChampionMan::applyModifiersToStatistics(Champion* champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing) {
+	int16 statIndex;
+	int16 modifier = 0;
+	ThingType thingType = thing.getType();
+	if (((thingType == kWeaponThingType) || (thingType == kArmourThingType))
+		&& (slotIndex >= kChampionSlotReadyHand)
+		&& (slotIndex <= kChampionSlotQuiverLine_1_1)) {
+		Weapon *weapon = (Weapon*)_vm->_dungeonMan->getThingData(thing);
+		Armour *armour = (Armour*)_vm->_dungeonMan->getThingData(thing);
+		if (((thingType == kWeaponThingType) && weapon->getCursed())
+			|| ((thingType == kArmourThingType) && armour->getCursed())) {
+			statIndex = kChampionStatLuck;
+			modifier = -3;
+			goto T0299044_ApplyModifier;
+		}
+	}
+
+	statIndex = (ChampionStatisticType)thingType; // variable sharing
+
+	if ((iconIndex == kIconIndiceJunkRabbitsFoot) && (slotIndex < kChampionSlotChest_1)) {
+		statIndex = kChampionStatLuck;
+		modifier = 10;
+	} else if (slotIndex == kChampionSlotActionHand) {
+
+		if (iconIndex == kIconIndiceWeaponMaceOfOrder) {
+			statIndex = kChampionStatStrength;
+			modifier = 5;
+		} else {
+
+			statIndex = kChampionStatMana;
+			if ((iconIndex >= kIconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= kIconIndiceWeaponStaffOfClawsFull)) {
+				modifier = 4;
+			} else if ((iconIndex >= kIconIndiceWeaponStaff) && (iconIndex <= kIconIndiceWeaponSceptreOfLyf)) {
+				switch (iconIndex) {
+				case kIconIndiceWeaponStaff:
+					modifier = 2;
+					break;
+				case kIconIndiceWeaponWand:
+					modifier = 1;
+					break;
+				case kIconIndiceWeaponTeowand:
+					modifier = 6;
+					break;
+				case kIconIndiceWeaponYewStaff:
+					modifier = 4;
+					break;
+				case kIconIndiceWeaponStaffOfManarStaffOfIrra:
+					modifier = 10;
+					break;
+				case kIconIndiceWeaponSnakeStaffCrossOfNeta:
+					modifier = 8;
+					break;
+				case kIconIndiceWeaponTheConduitSerpentStaff:
+					modifier = 16;
+					break;
+				case kIconIndiceWeaponDragonSpit:
+					modifier = 7;
+					break;
+				case kIconIndiceWeaponSceptreOfLyf:
+					modifier = 5;
+					break;
+				}
+			} else {
+				switch (iconIndex) {
+				case kIconIndiceWeaponDeltaSideSplitter:
+					modifier = 1;
+					break;
+				case kIconIndiceWeaponTheInquisitorDragonFang:
+					modifier = 2;
+					break;
+				case kIconIndiceWeaponVorpalBlade:
+					modifier = 4;
+					break;
+				}
+			} // end of else
+
+		}
+
+	} else if (slotIndex == kChampionSlotLegs) {
+
+		if (iconIndex == kIconIndiceArmourPowertowers) {
+			statIndex = kChampionStatStrength;
+			modifier = 10;
+		}
+
+	} else if (slotIndex == kChampionSlotHead) {
+
+		if (iconIndex == kIconIndiceArmourCrownOfNerra) {
+			statIndex = kChampionStatWisdom;
+			modifier = 10;
+		} else if (iconIndex == kIconIndiceArmourDexhelm) {
+			statIndex = kChampionStatDexterity;
+			modifier = 10;
+		}
+
+	} else if (slotIndex == kChampionSlotTorso) {
+
+		if (iconIndex == kIconIndiceArmourFlamebain) {
+			statIndex = kChampionStatAntifire;
+			modifier = 12;
+		} else if (iconIndex == kIconIndiceArmourCloakOfNight) {
+			statIndex = kChampionStatDexterity;
+			modifier = 8;
+		}
+
+	} else if (slotIndex == kChampionSlotNeck) {
+
+		if ((iconIndex >= kIconIndiceJunkJewelSymalUnequipped) && (iconIndex <= kIconIndiceJunkJewelSymalEquipped)) {
+			statIndex = kChampionStatAntimagic;
+			modifier = 15;
+		} else if (iconIndex == kIconIndiceArmourCloakOfNight) {
+			statIndex = kChampionStatDexterity;
+			modifier = 8;
+		} else if (iconIndex == kIconIndiceJunkMoonstone) {
+			statIndex = kChampionStatMana;
+			modifier = 3;
+		}
+
+	}
+
+T0299044_ApplyModifier:
+	if (modifier) {
+		modifier *= modifierFactor;
+		if (statIndex == kChampionStatMana) {
+			champ->_maxMana += modifier;
+		} else if (statIndex < kChampionStatAntifire + 1) {
+			for (uint16 statValIndex = kChampionStatMaximum; statValIndex <= kChampionStatMinimum; ++statValIndex) {
+				champ->getStatistic((ChampionStatisticType)statIndex, (ChampionStatisticValue)statValIndex) += modifier;
+				warning("BUG0_38");
+			}
+		}
+	}
+
+}
+
 ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
 	for (uint16 i = 0; i < _partyChampionCount; ++i) {
 		if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 8ea8a6d..c61dbe4 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -457,6 +457,8 @@ public:
 	void renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename
 	uint16 getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex);// @ F0303_CHAMPION_GetSkillLevel
 	Common::String getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger
+	void applyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex,
+									int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics
 };
 
 


Commit: ae6f2d711ccf3a2351be2d98da07ed2daf95c017
    https://github.com/scummvm/scummvm/commit/ae6f2d711ccf3a2351be2d98da07ed2daf95c017
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0034_OBJECT_DrawLeaderHandObjectName

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/TODOs/todo.txt
    engines/dm/objectman.cpp
    engines/dm/objectman.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index fb7021e..92bbd38 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -97,24 +97,24 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 		G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon // done
 		G0237_as_Graphic559_ObjectInfo // done
 		G0509_B_ActionAreaContainsIcons // done
-	F0301_CHAMPION_AddObjectInSlot // skip
+	F0301_CHAMPION_AddObjectInSlot
+		F0299_CHAMPION_ApplyObjectModifiersToStatistics // done
 		F0296_CHAMPION_DrawChangedObjectIcons
-			F0292_CHAMPION_DrawState // skip
-			F0034_OBJECT_DrawLeaderHandObjectName // skip
+			F0068_MOUSE_SetPointerToObject // skip
+			F0077_MOUSE_HidePointer_CPSE // skip
+			F0078_MOUSE_ShowPointer // skip
+			F0034_OBJECT_DrawLeaderHandObjectName // done
+			F0386_MENUS_DrawActionIcon
 			F0295_CHAMPION_HasObjectIconInSlotBoxChanged
 			M70_HAND_SLOT_INDEX
-			G0423_i_InventoryChampionOrdinal
 			G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen
 			G0412_puc_Bitmap_ObjectIconForMousePointer
-			G0424_i_PanelContent
-			G0425_aT_ChestSlots
+			G0413_i_LeaderHandObjectIconIndex
+			G0414_T_LeaderHandObject
 		F0337_INVENTORY_SetDungeonViewPalette
-		F0299_CHAMPION_ApplyObjectModifiersToStatistics
-		F0291_CHAMPION_DrawSlot
-		G0425_aT_ChestSlots
-		G0423_i_InventoryChampionOrdinal
-		G0039_ai_Graphic562_LightPowerToLightAmount
 		G0407_s_Party
+		G0039_ai_Graphic562_LightPowerToLightAmount
+
 	F0355_INVENTORY_Toggle_CPSE // done
 		F0292_CHAMPION_DrawState // done
 		F0334_INVENTORY_CloseChest // done
diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 0357673..ca4bc3f 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -18,6 +18,7 @@ Todo:
 	Attend to sev's notes on github
 	Double check enums with hex literals, I think I screwed the regex when processing them
 	Double check strcat, strstr usages, I might have messed them up in many places
+	I forgot to add a bunch of warning for show/hide mouse pointer
 
 	Missing functions:
 		 Add missing  F0163_DUNGEON_LinkThingToList in MovesensMan::sensorIsTriggeredByClickOnWall (I don't think it's safe yet)
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index c83c16c..0f04fb4 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -27,6 +27,7 @@
 
 #include "objectman.h"
 #include "dungeonman.h"
+#include "text.h"
 
 namespace DM {
 
@@ -229,5 +230,21 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 									   box, kColorNoTransparency, gDefultViewPort);
 	}
 }
-
+	
+#define kObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH
+
+void ObjectMan::drawLeaderObjectName(Thing thing) {
+	IconIndice iconIndex = getIconIndex(thing);
+	char *objName;
+	char objectNameBuffer[16];
+	if (iconIndex == kIconIndiceJunkChampionBones) {
+		Junk *junk = (Junk*)_vm->_dungeonMan->getThingData(thing);
+		strcpy(objectNameBuffer, _vm->_championMan->_champions[junk->getChargeCount()]._name);
+		strcat(objectNameBuffer, _objectNames[iconIndex]);
+		objName = objectNameBuffer;
+	} else {
+		objName = _objectNames[iconIndex];
+	}
+	_vm->_textMan->printWithTrailingSpacesToScreen(233, 37, kColorCyan, kColorBlack, objName, kObjectNameMaximumLength);
+}
 }
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index e01d064..e5e4cf3 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -62,6 +62,7 @@ public:
 	IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
 	void extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // F0036_OBJECT_ExtractIconFromBitmap
 	void drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox
+	void drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName
 };
 
 }


Commit: 5ba83b8b4dfb3ed4bf4789c528d0c5d0d169fae8
    https://github.com/scummvm/scummvm/commit/5ba83b8b4dfb3ed4bf4789c528d0c5d0d169fae8
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0295_CHAMPION_HasObjectIconInSlotBoxChanged, F0039_OBJECT_GetIconIndexInSlotBox

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/objectman.cpp
    engines/dm/objectman.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index 92bbd38..d213c03 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -104,10 +104,11 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 			F0077_MOUSE_HidePointer_CPSE // skip
 			F0078_MOUSE_ShowPointer // skip
 			F0034_OBJECT_DrawLeaderHandObjectName // done
-			F0386_MENUS_DrawActionIcon
-			F0295_CHAMPION_HasObjectIconInSlotBoxChanged
+			F0386_MENUS_DrawActionIcon // done
+			F0295_CHAMPION_HasObjectIconInSlotBoxChanged // done 	
+				F0039_OBJECT_GetIconIndexInSlotBox // done 
 			M70_HAND_SLOT_INDEX
-			G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen
+			G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen // done
 			G0412_puc_Bitmap_ObjectIconForMousePointer
 			G0413_i_LeaderHandObjectIconIndex
 			G0414_T_LeaderHandObject
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index deae8b4..d2df2ac 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -267,6 +267,27 @@ T0299044_ApplyModifier:
 
 }
 
+bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) {
+	ObjectMan &objMan = *_vm->_objectMan;
+
+	IconIndice currIconIndex = objMan.getIconIndexInSlotBox(slotBoxIndex);
+	if (((currIconIndex < kIconIndiceWeaponDagger) && (currIconIndex >= kIconIndiceJunkCompassNorth))
+		|| ((currIconIndex >= kIconIndicePotionMaPotionMonPotion) && (currIconIndex <= kIconIndicePotionWaterFlask))
+		|| (currIconIndex == kIconIndicePotionEmptyFlask)) {
+		IconIndice newIconIndex = objMan.getIconIndex(thing);
+		if (newIconIndex != currIconIndex) {
+			if ((slotBoxIndex < kSlotBoxInventoryFirstSlot) && !_mousePointerHiddenToDrawChangedObjIconOnScreen) {
+				_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
+				warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+			}
+			objMan.drawIconInSlotBox(slotBoxIndex, newIconIndex);
+			return true;
+		}
+	}
+
+	return false;
+}
+
 ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
 	for (uint16 i = 0; i < _partyChampionCount; ++i) {
 		if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index c61dbe4..a85ab57 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -443,6 +443,7 @@ public:
 	bool _leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded
 	Party _party; // @ G0407_s_Party
 	ChampionIndex _magicCasterChampionIndex; // @ G0514_i_MagicCasterChampionIndex
+	bool _mousePointerHiddenToDrawChangedObjIconOnScreen; // @ G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen
 
 	explicit ChampionMan(DMEngine *vm);
 	void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
@@ -459,6 +460,7 @@ public:
 	Common::String getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger
 	void applyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex,
 									int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics
+	bool hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged
 };
 
 
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 0f04fb4..aed1c13 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -230,7 +230,7 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 									   box, kColorNoTransparency, gDefultViewPort);
 	}
 }
-	
+
 #define kObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH
 
 void ObjectMan::drawLeaderObjectName(Thing thing) {
@@ -247,4 +247,8 @@ void ObjectMan::drawLeaderObjectName(Thing thing) {
 	}
 	_vm->_textMan->printWithTrailingSpacesToScreen(233, 37, kColorCyan, kColorBlack, objName, kObjectNameMaximumLength);
 }
+
+IconIndice ObjectMan::getIconIndexInSlotBox(uint16 slotBoxIndex) {
+	return (IconIndice)_slotBoxes[slotBoxIndex]._iconIndex;
+}
 }
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index e5e4cf3..f075076 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -63,6 +63,9 @@ public:
 	void extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // F0036_OBJECT_ExtractIconFromBitmap
 	void drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox
 	void drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName
+	IconIndice getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox
+
+
 };
 
 }


Commit: d4ad444ecc753674c862d92f5e3533bdd799fef2
    https://github.com/scummvm/scummvm/commit/d4ad444ecc753674c862d92f5e3533bdd799fef2
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0296_CHAMPION_DrawChangedObjectIcons

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/eventman.cpp
    engines/dm/loadsave.cpp
    engines/dm/movesens.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index d2df2ac..1d9e19e 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -122,6 +122,10 @@ void ChampionMan::drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int1
 	_vm->_textMan->printToViewport(79, posY, kColorLightestGray, tmp.c_str());
 }
 
+uint16 ChampionMan::handSlotIndex(uint16 slotBoxIndex) {
+	return slotBoxIndex & 0x1;
+}
+
 Common::String ChampionMan::getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) {
 	using namespace Common;
 	String valToStr = String::format("%d", val);
@@ -288,6 +292,74 @@ bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing)
 	return false;
 }
 
+void ChampionMan::drawChangedObjectIcons() {
+	InventoryMan &invMan = *_vm->_inventoryMan;
+	ObjectMan &objMan = *_vm->_objectMan;
+	MenuMan &menuMan = *_vm->_menuMan;
+
+	uint16 invChampOrdinal = invMan._inventoryChampionOrdinal;
+	if (_candidateChampionOrdinal && !invChampOrdinal)
+		return;
+
+	_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
+	IconIndice leaderHandObjIconIndex = _leaderHandObjectIconIndex;
+
+	if (((leaderHandObjIconIndex < kIconIndiceWeaponDagger) && (leaderHandObjIconIndex >= kIconIndiceJunkCompassNorth))	// < instead of <= is correct
+		|| ((leaderHandObjIconIndex >= kIconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= kIconIndicePotionWaterFlask))
+			|| (leaderHandObjIconIndex == kIconIndicePotionEmptyFlask)) {
+		IconIndice iconIndex = objMan.getIconIndex(_leaderHandObject);
+		if (iconIndex != leaderHandObjIconIndex) {
+			_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
+			warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+			objMan.extractIconFromBitmap(iconIndex, objMan._objectIconForMousePointer);
+			warning("MISSING CODE: F0068_MOUSE_SetPointerToObject");
+			_leaderHandObjectIconIndex = iconIndex;
+			objMan.drawLeaderObjectName(_leaderHandObject);
+		}
+	}
+
+	for (uint16 slotBoxIndex = 0; slotBoxIndex < (_partyChampionCount * 2); ++slotBoxIndex) {
+		int16 champIndex = slotBoxIndex >> 1;
+		if(invChampOrdinal == _vm->indexToOrdinal(champIndex))
+			continue;
+
+		if (hasObjectIconInSlotBoxChanged(slotBoxIndex, _champions[champIndex].getSlot((ChampionSlot)handSlotIndex(slotBoxIndex)))
+			&& (handSlotIndex(slotBoxIndex) == kChampionSlotActionHand)) {
+
+			menuMan.drawActionIcon((ChampionIndex)champIndex);
+		}
+	}
+
+	if (invChampOrdinal) {
+		Champion *champ = &_champions[_vm->ordinalToIndex(invChampOrdinal)];
+		Thing *thing = &champ->getSlot(kChampionSlotReadyHand);
+		uint16 drawViewport = 0;
+
+		for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++, thing++) {
+			uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + kSlotBoxInventoryFirstSlot, *thing) ? 1 : 0;
+			drawViewport |= objIconChanged;
+			if (objIconChanged && (slotIndex == kChampionSlotActionHand)) {
+				menuMan.drawActionIcon((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
+			}
+		}
+
+		if (invMan._panelContent = kPanelContentChest) {
+			thing = invMan._chestSlots;
+			for (int16 slotIndex = 0; slotIndex < 8; ++slotIndex, thing++) {
+				drawViewport |= (hasObjectIconInSlotBoxChanged(slotIndex + kSlotBoxChestFirstSlot, *thing) ? 1 : 0);
+			}
+		}
+
+		if (drawViewport) {
+			champ->setAttributeFlag(kChampionAttributeViewport, true);
+			drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
+		}
+	}
+
+	if (_mousePointerHiddenToDrawChangedObjIconOnScreen)
+		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+}
+
 ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
 	for (uint16 i = 0; i < _partyChampionCount; ++i) {
 		if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
@@ -303,7 +375,7 @@ void ChampionMan::resetDataToStartGame() {
 		assert(false);
 	}
 
-	_leaderHand = Thing::_thingNone;
+	_leaderHandObject = Thing::_thingNone;
 	_leaderHandObjectIconIndex = kIconIndiceNone;
 	_leaderEmptyHanded = true;
 }
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index a85ab57..f3a4116 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -365,7 +365,7 @@ public:
 	int16 _shieldDefense;
 	byte _portrait[464]; // 32 x 29 pixel portrait
 
-	Thing getSlot(ChampionSlot slot) { return _slots[slot]; }
+	Thing &getSlot(ChampionSlot slot) { return _slots[slot]; }
 	void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; }
 
 	Skill &getSkill(ChampionSkill skill) { return _skills[skill]; }
@@ -430,11 +430,12 @@ class ChampionMan {
 	ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell
 	int16 getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue
 	void drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue
+	uint16 handSlotIndex(uint16 slotBoxIndex);// @ M70_HAND_SLOT_INDEX
 public:
 	Champion _champions[4];
 	uint16 _partyChampionCount;	// @ G0305_ui_PartyChampionCount
 	bool _partyDead; // @ G0303_B_PartyDead
-	Thing _leaderHand; // @ G0414_T_LeaderHandObject
+	Thing _leaderHandObject; // @ G0414_T_LeaderHandObject
 	ChampionIndex _leaderIndex;	// @ G0411_i_LeaderIndex
 	uint16 _candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal
 	bool _partyIsSleeping; // @ G0300_B_PartyIsSleeping
@@ -461,6 +462,7 @@ public:
 	void applyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex,
 									int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics
 	bool hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged
+	void drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons
 };
 
 
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 5c9e68b..20c2888 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -486,7 +486,7 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
 		leaderIndex = cm._leaderIndex;
 		cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeLoad, true);
 		cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeNameTitle, true);
-		cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._leaderHand);
+		cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject);
 		cm._leaderIndex = kChampionNone;
 		cm.drawChampionState(leaderIndex);
 	}
@@ -497,7 +497,7 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
 	cm._leaderIndex = champIndex;
 	Champion *champion = &cm._champions[cm._leaderIndex];
 	champion->_dir = _vm->_dungeonMan->_currMap._partyDir;
-	cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHand);
+	cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject);
 	if (_vm->indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) {
 		champion->setAttributeFlag(kChampionAttributeIcon, true);
 		champion->setAttributeFlag(kChampionAttributeNameTitle, true);
@@ -554,7 +554,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 			}
 		}
 	} else {
-		Thing thing = champMan._leaderHand;
+		Thing thing = champMan._leaderHandObject;
 		uint16 *rawThingPointer = dunMan.getThingData(thing);
 		if (dunMan._squareAheadElement == kElementTypeWall) {
 			for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellFrontRight; ++viewCell) {
@@ -578,7 +578,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 						} else {
 							goto T0377019;
 						}
-						warning("MISSING CODE: F0296_CHAMPION_DrawChangedObjectIcons");
+						champMan.drawChangedObjectIcons();
 						champMan._champions[champMan._leaderIndex]._load += dunMan.getObjectWeight(thing) - weight;
 					}
 T0377019:
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 0251e8b..7ac9283 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -43,7 +43,7 @@ LoadgameResponse LoadsaveMan::loadgame() {
 	if (newGame) {
 		_vm->_restartGameAllowed = false;
 		cm._partyChampionCount = 0;
-		cm._leaderHand = Thing::_thingNone;
+		cm._leaderHandObject = Thing::_thingNone;
 		_vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536);
 	} else {
 		assert(false);
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 2c25251..8a833a3 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -44,7 +44,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 
 
 	bool atLeastOneSensorWasTriggered = false;
-	Thing leaderHandObject = champMan._leaderHand;
+	Thing leaderHandObject = champMan._leaderHandObject;
 	int16 sensorCountToProcessPerCell[4];
 	uint16 cell;
 	for (cell = kCellNorthWest; cell < kCellSouthWest; ++cell) {


Commit: 6daa5c572e3a96602be4df5115126415cecc72f7
    https://github.com/scummvm/scummvm/commit/6daa5c572e3a96602be4df5115126415cecc72f7
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0301_CHAMPION_AddObjectInSlot

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dungeonman.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index d213c03..71846ef 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -97,9 +97,9 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 		G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon // done
 		G0237_as_Graphic559_ObjectInfo // done
 		G0509_B_ActionAreaContainsIcons // done
-	F0301_CHAMPION_AddObjectInSlot
+	F0301_CHAMPION_AddObjectInSlot // done
 		F0299_CHAMPION_ApplyObjectModifiersToStatistics // done
-		F0296_CHAMPION_DrawChangedObjectIcons
+		F0296_CHAMPION_DrawChangedObjectIcons // done 
 			F0068_MOUSE_SetPointerToObject // skip
 			F0077_MOUSE_HidePointer_CPSE // skip
 			F0078_MOUSE_ShowPointer // skip
@@ -107,14 +107,14 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
 			F0386_MENUS_DrawActionIcon // done
 			F0295_CHAMPION_HasObjectIconInSlotBoxChanged // done 	
 				F0039_OBJECT_GetIconIndexInSlotBox // done 
-			M70_HAND_SLOT_INDEX
+			M70_HAND_SLOT_INDEX // done
 			G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen // done
-			G0412_puc_Bitmap_ObjectIconForMousePointer
-			G0413_i_LeaderHandObjectIconIndex
-			G0414_T_LeaderHandObject
-		F0337_INVENTORY_SetDungeonViewPalette
-		G0407_s_Party
-		G0039_ai_Graphic562_LightPowerToLightAmount
+			G0412_puc_Bitmap_ObjectIconForMousePointer // done
+			G0413_i_LeaderHandObjectIconIndex // done 
+			G0414_T_LeaderHandObject // done
+		F0337_INVENTORY_SetDungeonViewPalette // skip
+		G0407_s_Party // done
+		G0039_ai_Graphic562_LightPowerToLightAmount // skip
 
 	F0355_INVENTORY_Toggle_CPSE // done
 		F0292_CHAMPION_DrawState // done
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 1d9e19e..cce3f55 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -45,6 +45,8 @@ Box gBoxChampionIcons[4] = {
 	Box(281, 299, 15, 28)};
 Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14};
 
+int16 gLightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100};
+
 uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
 	/* 30 for champion inventory, 8 for chest */
 	0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
@@ -306,7 +308,7 @@ void ChampionMan::drawChangedObjectIcons() {
 
 	if (((leaderHandObjIconIndex < kIconIndiceWeaponDagger) && (leaderHandObjIconIndex >= kIconIndiceJunkCompassNorth))	// < instead of <= is correct
 		|| ((leaderHandObjIconIndex >= kIconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= kIconIndicePotionWaterFlask))
-			|| (leaderHandObjIconIndex == kIconIndicePotionEmptyFlask)) {
+		|| (leaderHandObjIconIndex == kIconIndicePotionEmptyFlask)) {
 		IconIndice iconIndex = objMan.getIconIndex(_leaderHandObject);
 		if (iconIndex != leaderHandObjIconIndex) {
 			_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
@@ -320,7 +322,7 @@ void ChampionMan::drawChangedObjectIcons() {
 
 	for (uint16 slotBoxIndex = 0; slotBoxIndex < (_partyChampionCount * 2); ++slotBoxIndex) {
 		int16 champIndex = slotBoxIndex >> 1;
-		if(invChampOrdinal == _vm->indexToOrdinal(champIndex))
+		if (invChampOrdinal == _vm->indexToOrdinal(champIndex))
 			continue;
 
 		if (hasObjectIconInSlotBoxChanged(slotBoxIndex, _champions[champIndex].getSlot((ChampionSlot)handSlotIndex(slotBoxIndex)))
@@ -360,6 +362,71 @@ void ChampionMan::drawChangedObjectIcons() {
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 
+void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex) {
+	InventoryMan &invMan = *_vm->_inventoryMan;
+	DungeonMan &dunMan = *_vm->_dungeonMan;
+	ObjectMan &objMan = *_vm->_objectMan;
+	MenuMan &menuMan = *_vm->_menuMan;
+
+	if (thing == Thing::_thingNone)
+		return;
+
+	Champion *champ = &_champions[champIndex];
+
+	if (slotIndex >= kChampionSlotChest_1) {
+		invMan._chestSlots[slotIndex - kChampionSlotChest_1] = thing;
+	} else {
+		champ->setSlot(slotIndex, thing);
+	}
+
+	champ->_load += dunMan.getObjectWeight(thing);
+	champ->setAttributeFlag(kChampionAttributeLoad, true);
+	IconIndice iconIndex = objMan.getIconIndex(thing);
+	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
+	applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
+	uint16 *rawObjPtr = dunMan.getThingData(thing);
+
+	if (slotIndex < kChampionSlotHead) {
+
+		if (slotIndex == kChampionSlotActionHand) {
+			champ->setAttributeFlag(kChampionAttributeActionHand, true);
+			if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
+				menuMan.clearActingChampion();
+
+			if ((iconIndex >= kIconIndiceScrollOpen) && (iconIndex <= kIconIndiceScrollClosed)) {
+				((Scroll*)rawObjPtr)->setClosed(false);
+				drawChangedObjectIcons();
+			}
+		}
+
+		if (iconIndex = kIconIndiceWeaponTorchUnlit) {
+			((Weapon*)rawObjPtr)->setLit(true);
+			warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette");
+			drawChangedObjectIcons();
+		} else if (isInventoryChampion && (slotIndex == kChampionSlotActionHand) &&
+			((iconIndex == kIconIndiceContainerChestClosed) || ((iconIndex >= kIconIndiceScrollOpen) && (iconIndex <= kIconIndiceScrollClosed)))) {
+			champ->setAttributeFlag(kChampionAttributePanel, true);
+		}
+
+	} else if (slotIndex == kChampionSlotNeck) {
+
+		if ((iconIndex >= kIconIndiceJunkIllumuletUnequipped) && (iconIndex <= kIconIndiceJunkIllumuletEquipped)) {
+			((Junk*)rawObjPtr)->setChargeCount(1);
+			_party._magicalLightAmount += gLightPowerToLightAmount[2];
+			warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette");
+			iconIndex = (IconIndice) (iconIndex + 1);
+		} else if ((iconIndex >= kIconIndiceJunkJewelSymalUnequipped) && (iconIndex <= kIconIndiceJunkJewelSymalEquipped)) {
+			((Junk*)rawObjPtr)->setChargeCount(1);
+			iconIndex = (IconIndice) (iconIndex + 1);
+		}
+
+	}
+
+	drawSlot(champIndex, slotIndex);
+	if (isInventoryChampion)
+		champ->setAttributeFlag(kChampionAttributeViewport, true);
+}
+
 ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
 	for (uint16 i = 0; i < _partyChampionCount; ++i) {
 		if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
@@ -549,7 +616,7 @@ T0280048:
 			if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) {
 				goto T0280046;
 			}
-			warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot");
+			addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green);
 		}
 		thing = dunMan.getNextThing(thing);
 	}
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index f3a4116..d712e6b 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -41,6 +41,8 @@ namespace DM {
 extern Box gBoxChampionIcons[4]; // @ G0054_ai_Graphic562_Box_ChampionIcons
 extern Color gChampionColor[4]; // @ G0046_auc_Graphic562_ChampionColor
 
+extern int16 gLightPowerToLightAmount[16]; // @ G0039_ai_Graphic562_LightPowerToLightAmount
+
 class Scent {
 	uint16 _scent;
 public:
@@ -463,6 +465,7 @@ public:
 									int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics
 	bool hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged
 	void drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons
+	void addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex); // @ F0301_CHAMPION_AddObjectInSlot
 };
 
 
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 69746ac..9a49fe9 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -365,6 +365,12 @@ public:
 
 	WeaponType getType() { return (WeaponType)(_desc & 0x7F); }
 	bool isLit() { return (_desc >> 15) & 1; }
+	void setLit(bool val) {
+		if (val)
+			_desc |= (1 << 15);
+		else
+			_desc &= (~(1 << 15));
+	}
 	uint16 getChargeCount() { return (_desc >> 10) & 0xF; }
 	Thing getNextThing() { return _nextThing; }
 	uint16 getCursed() { return (_desc >> 8) & 1; }
@@ -402,6 +408,12 @@ public:
 	}
 	Thing getNextThing() { return _nextThing; }
 	uint16 getClosed() { return (_attributes >> 10) & 0x3F; } // ??? dunno why, the original bitfield is 6 bits long
+	void setClosed(bool val) {
+		if (val)
+			_attributes |= (1 << 10);
+		else
+			_attributes &= (~(0x3F << 10));
+	}
 	uint16 getTextStringThingIndex() { return _attributes & 0x3FF; }
 }; // @ SCROLL
 


Commit: e6c3389e53cad4069c696132ed4ef7a3c1d6991c
    https://github.com/scummvm/scummvm/commit/e6c3389e53cad4069c696132ed4ef7a3c1d6991c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Continue F0460_START_InitializeGraphicData

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index 71846ef..10ed85f 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -1,3 +1,53 @@
+F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
+	F0113_DUNGEONVIEW_DrawField // dummy
+		F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
+		FIELD_ASPECT
+	F0114_DUNGEONVIEW_GetExplosionBitmap
+	F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
+	F0141_DUNGEON_GetObjectInfoIndex
+	F0142_DUNGEON_GetProjectileAspect
+	F0176_GROUP_GetCreatureOrdinalInCell
+	G0017_auc_Graphic562_PaletteChanges_NoChanges
+	G0075_apuc_PaletteChanges_Projectile
+	G0077_B_DoNotDrawFluxcagesDuringEndgame
+	G0105_s_Graphic558_Box_ExplosionPattern_D0C
+	G0163_as_Graphic558_Frame_Walls
+	G0188_as_Graphic558_FieldAspects
+	G0209_as_Graphic558_ObjectAspects
+	G0210_as_Graphic558_ProjectileAspects
+	G0212_auc_Graphic558_PaletteChanges_Smoke
+	G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3
+	G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2
+	G0215_auc_Graphic558_ProjectileScales
+	G0216_auc_Graphic558_ExplosionBaseScales
+	G0217_aauc_Graphic558_ObjectPileShiftSetIndices
+	G0218_aaaauc_Graphic558_ObjectCoordinateSets
+	G0219_as_Graphic558_CreatureAspects
+	G0221_auc_Graphic558_PaletteChanges_Creature_D3
+	G0222_auc_Graphic558_PaletteChanges_Creature_D2
+	G0223_aac_Graphic558_ShiftSets
+	G0224_aaaauc_Graphic558_CreatureCoordinateSets
+	G0225_aai_Graphic558_CenteredExplosionCoordinates
+	G0226_aaai_Graphic558_ExplosionCoordinates
+	G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates
+	G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates
+	G0237_as_Graphic559_ObjectInfo
+	G0243_as_Graphic559_CreatureInfo
+	G0291_aauc_DungeonViewClickableBoxes
+	G0292_aT_PileTopObject
+	G0370_ps_Events
+	G0375_ps_ActiveGroups
+	OBJECT_ASPECT
+	GROUP
+	ACTIVE_GROUP
+	CREATURE_INFO
+	CREATURE_ASPECT
+	PROJECTILE
+	EXPLOSION
+	FIELD_ASPECT
+
+
+
 F0380_COMMAND_ProcessQueue_CPSC // in progress
 	C080_COMMAND_CLICK_IN_DUNGEON_VIEW // cool
 		F0377_COMMAND_ProcessType80_ClickInDungeonView // done so-so
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 138e7b8..0df836a 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -60,16 +60,27 @@ void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); }
 direction returnOppositeDir(direction dir) { return (direction)((dir + 2) & 3); }
 bool isOrientedWestEast(direction dir) { return dir & 1; }
 
+uint16 getFlag(uint16 val, uint16 mask) {
+	return val & mask;
+}
+
+void setFlag(uint16 &val, uint16 mask) {
+	val |= mask;
+}
+
+void clearFlag(uint16 &val, uint16 mask) {
+	val &= ~mask;
+}
 
 DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
-	// Do not load data files
-	// Do not initialize graphics here
-	// Do not initialize audio devices here
-	// Do these from run
-
-	//Specify all default directories
-	//const Common::FSNode gameDataDir(ConfMan.get("example"));
-	//SearchMan.addSubDirectoryMatching(gameDataDir, "example2");
+// Do not load data files
+// Do not initialize graphics here
+// Do not initialize audio devices here
+// Do these from run
+
+//Specify all default directories
+//const Common::FSNode gameDataDir(ConfMan.get("example"));
+//SearchMan.addSubDirectoryMatching(gameDataDir, "example2");
 	DebugMan.addDebugChannel(kDMDebugExample, "example", "example desc");
 
 	// register random source
@@ -210,7 +221,7 @@ void DMEngine::gameloop() {
 	_dungeonMan->_currMap._partyPosX = 10;
 	_dungeonMan->_currMap._partyPosY = 4;
 	_dungeonMan->_currMap._partyDir = kDirNorth;
-	
+
 
 	warning("DUMMY CODE: setting InventoryMan::_inventoryChampionOrdinal to zero");
 	_inventoryMan->_inventoryChampionOrdinal = 0;
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 19eda10..7b68e6d 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -65,6 +65,11 @@ direction returnOppositeDir(direction dir);
 bool isOrientedWestEast(direction dir);
 
 
+uint16 getFlag(uint16 val, uint16 mask);
+void setFlag(uint16 &val, uint16 mask);
+void clearFlag(uint16 &val, uint16 mask);
+
+
 enum ThingType {
 	kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value
 	kDoorThingType = 0,
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index b1c5c6a..0c55fe5 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -39,6 +39,24 @@ namespace DM {
 
 Box gBoxMovementArrows = Box(224, 319, 124, 168);
 
+ExplosionAspect gExplosionAspects[kExplosionAspectCount] = { // @ G0211_as_Graphic558_ExplosionAspects
+	/* { ByteWidth, Height } */
+	ExplosionAspect(80, 111),   /* Fire   */
+ExplosionAspect(64,  97),   /* Spell  */
+ExplosionAspect(80,  91),   /* Poison */
+ExplosionAspect(80,  91)}; /* Death  */
+
+#define kDerivedBitmapMaximumCount 730 // @ C730_DERIVED_BITMAP_MAXIMUM_COUNT
+
+byte gProjectileScales[7] = {
+	13,   /* D4 Back  */
+	16,   /* D4 Front */
+	19,   /* D3 Back  */
+	22,   /* D3 Front */
+	25,   /* D2 Back  */
+	28,   /* D2 Front */
+	32}; /* D1 Back  */
+
 enum StairFrameIndex {
 	kFrameStairsUpFront_D3L = 0, // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L 
 	kFrameStairsUpFront_D3C = 1, // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C 
@@ -598,6 +616,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_floorBitmap = nullptr;
 	_ceilingBitmap = nullptr;
 	_currMapAllowedCreatureTypes = nullptr;
+	_derivedBitmapByteCount = nullptr;
 
 	_screenWidth = _screenHeight = 0;
 	_championPortraitOrdinal = 0;
@@ -686,21 +705,126 @@ void DisplayMan::loadGraphics() {
 
 	unpackGraphics();
 
-	for (uint16 i = kDoorOrnDestroyedMask; i <= kDoorOrnThivesEyeMask; ++i) {
-		_currMapDoorOrnInfo[i][kNativeBitmapIndex] = i + (kDoorMaskDestroyedIndice - kDoorOrnDestroyedMask);
-		_currMapDoorOrnInfo[i][kNativeCoordinateSet] = 1;
+	loadFloorSet(kFloorSetStone);
+	loadWallSet(kWallSetStone);
+
+
+
+	if (!_derivedBitmapByteCount)
+		_derivedBitmapByteCount = new uint16[kDerivedBitmapMaximumCount];
+
+	_derivedBitmapByteCount[kDerivedBitmapViewport] = 224 * 136;
+	_derivedBitmapByteCount[kDerivedBitmapThievesEyeVisibleArea] = 96 * 95;
+	_derivedBitmapByteCount[kDerivedBitmapDamageToCreatureMedium] = 64 * 37;
+	_derivedBitmapByteCount[kDerivedBitmapDamageToCreatureSmall] = 48 * 37;
+
+	for (int16 doorOrnamentIndex = kDoorOrnDestroyedMask; doorOrnamentIndex <= kDoorOrnThivesEyeMask; doorOrnamentIndex++) {
+		_currMapDoorOrnInfo[doorOrnamentIndex][kNativeBitmapIndex] = doorOrnamentIndex + (kDoorMaskDestroyedIndice - kDoorOrnDestroyedMask);
+		_currMapDoorOrnInfo[doorOrnamentIndex][kCoordinateSet] = 1;
+
+		_derivedBitmapByteCount[doorOrnamentIndex * 2 + kDerivedBitmapFirstDoorOrnament_D3] = 48 * 41;
+		_derivedBitmapByteCount[doorOrnamentIndex * 2 + kDerivedBitmapFirstDoorOrnament_D2] = 64 * 61;
+	}
+
+	_currMapFloorOrnInfo[kFloorOrnFootprints][kNativeBitmapIndex] = kFloorOrn_15_D3L_footprints;
+	_currMapFloorOrnInfo[kFloorOrnFootprints][kCoordinateSet] = 1;
+
+	ObjectAspect *objectAspect = gObjectAspects;
+	int16 derivedBitmapIndex;
+	for (int16 objectAspectIndex = 0; objectAspectIndex < kObjAspectCount; ++objectAspectIndex, ++objectAspect) {
+		derivedBitmapIndex = kDerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex;
+
+		_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, kScale16_D3);
+		_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, kScale20_D2);
+
+		if (getFlag(objectAspect->_graphicInfo, kObjectFlipOnRightMask)) {
+			_derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2];
+			derivedBitmapIndex++;
+			_derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2];
+			derivedBitmapIndex++;
+		}
+
+		if (getFlag(objectAspect->_graphicInfo, kObjectAlcoveMask)) {
+			_derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2];
+			derivedBitmapIndex++;
+			_derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2];
+		}
 	}
 
-	_currMapFloorOrnInfo[kFloorOrnFootprints][kNativeBitmapIndex] = 1;
-	_currMapFloorOrnInfo[kFloorOrnFootprints][kNativeCoordinateSet] = 1;
+	ProjectileAspect *projectileAspect = gProjectileAspect;
+	for (int16 projectileAspectIndex = 0; projectileAspectIndex < kProjectileAspectCount; projectileAspectIndex++, projectileAspect++) {
+
+		if (!getFlag(projectileAspect->_graphicInfo, kProjectileScaleWithKineticEnergyMask)) {
+			derivedBitmapIndex = kDerivedBitmapFirstProjectile + projectileAspect->_firstDerivedBitmapRelativeIndex;
+
+			for (int16 projectileScaleIndex = 0; projectileScaleIndex < 6; projectileScaleIndex++) {
+				int16 bitmapPixelCount = getScaledBitmapPixelCount(projectileAspect->_width, projectileAspect->_height, gProjectileScales[projectileScaleIndex]);
+				_derivedBitmapByteCount[derivedBitmapIndex] = bitmapPixelCount;
+
+				if (getFlag(projectileAspect->_graphicInfo, kProjectileAspectTypeMask) != kProjectileAspectHasNone) {
+					_derivedBitmapByteCount[derivedBitmapIndex + 6] = bitmapPixelCount;
+
+					if (getFlag(projectileAspect->_graphicInfo, kProjectileAspectTypeMask) != kProjectileAspectHasRotation) {
+						_derivedBitmapByteCount[derivedBitmapIndex + 12] = bitmapPixelCount;
+					}
+				}
+			}
+		}
+	}
 
 	_palChangesProjectile[0] = gPalChangesFloorOrn_D3;
 	_palChangesProjectile[1] = gPalChangesFloorOrn_D2;
 	_palChangesProjectile[2] = _palChangesProjectile[3] = gPalChangesNoChanges;
 
-	loadFloorSet(kFloorSetStone);
-	loadWallSet(kWallSetStone);
+	derivedBitmapIndex = kDerivedBitmapFirstExplosion;
+	ExplosionAspect *expAsp = gExplosionAspects;
+	for (uint16 expAspIndex = 0; expAspIndex < kExplosionAspectCount; ++expAspIndex, expAsp++) {
+		for (int16 scale = 4; scale < 32; scale += 2)
+			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(expAsp->_pixelWidth, expAsp->_height, scale);
+
+		if (expAspIndex == kExplosionAspectSmoke) {
+			_derivedBitmapByteCount[derivedBitmapIndex++] = expAsp->_pixelWidth * expAsp->_height;
+		}
+	}
+
+	derivedBitmapIndex = kDerivedBitmapFirstCreature;
+	CreatureAspect *creatureAsp;
+	for (int16 creatureIndex = 0; creatureIndex < kCreatureTypeCount; creatureIndex++) {
+		creatureAsp = &gCreatureAspects[creatureIndex];
+		
+		int16 creatureGraphicInfo = gCreatureInfo[creatureIndex]._graphicInfo;
+		creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex;
+		
+		int16 creatureFrontBitmapD3PixelCount;
+		_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3);
+		
+		int16 creatureFrontBitmapD2PixelCount;
+		_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2);
+		
+		if (getFlag(creatureGraphicInfo, kCreatureInfoMaskSide)) {
+			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale16_D3);
+			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale20_D2);
+		}
 
+		if (getFlag(creatureGraphicInfo, kCreatureInfoMaskBack)) {
+			_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount;
+			_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount;
+		}
+
+		if (getFlag(creatureGraphicInfo, kCreatureInfoMaskAttack)) {
+			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, kScale16_D3);
+			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, kScale20_D2);
+		}
+
+		int16 additionalFronGraphicCount;
+		if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, kCreatureInfoMaskAdditional)) {
+			do {
+				_derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront;
+				_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3);
+				_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2);
+			} while (--additionalFronGraphicCount);
+		}
+	}
 }
 
 void DisplayMan::unpackGraphics() {
@@ -1329,21 +1453,21 @@ void DisplayMan::loadCurrentMapGraphics() {
 			if (ornIndice == gFountainOrnIndices[ornCounter])
 				_currMapFountainOrnIndices[fountainCount++] = i;
 
-		_currMapWallOrnInfo[i][kNativeCoordinateSet] = gWallOrnCoordSetIndices[ornIndice];
+		_currMapWallOrnInfo[i][kCoordinateSet] = gWallOrnCoordSetIndices[ornIndice];
 	}
 
 	for (uint16 i = 0; i < currMap._floorOrnCount; ++i) {
 		uint16 ornIndice = _currMapFloorOrnIndices[i];
 		uint16 nativeIndice = kFirstFloorOrn + ornIndice * 6;
 		_currMapFloorOrnInfo[i][kNativeBitmapIndex] = nativeIndice;
-		_currMapFloorOrnInfo[i][kNativeCoordinateSet] = gFloorOrnCoordSetIndices[ornIndice];
+		_currMapFloorOrnInfo[i][kCoordinateSet] = gFloorOrnCoordSetIndices[ornIndice];
 	}
 
 	for (uint16 i = 0; i < currMap._doorOrnCount; ++i) {
 		uint16 ornIndice = _currMapDoorOrnIndices[i];
 		uint16 nativeIndice = kFirstDoorOrn + ornIndice;
 		_currMapDoorOrnInfo[i][kNativeBitmapIndex] = nativeIndice;
-		_currMapDoorOrnInfo[i][kNativeCoordinateSet] = gDoorOrnCoordIndices[ornIndice];
+		_currMapDoorOrnInfo[i][kCoordinateSet] = gDoorOrnCoordIndices[ornIndice];
 	}
 
 	applyCreatureReplColors(9, 8);
@@ -1432,7 +1556,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 		int16 wallOrnIndex = wallOrnOrd - 1;
 		int16 nativeBitmapIndex = _currMapWallOrnInfo[wallOrnIndex][kNativeBitmapIndex];
 
-		uint16 *coordinateSetA = gWallOrnCoordSets[_currMapWallOrnInfo[wallOrnIndex][kNativeCoordinateSet]][viewWallIndex];
+		uint16 *coordinateSetA = gWallOrnCoordSets[_currMapWallOrnInfo[wallOrnIndex][kCoordinateSet]][viewWallIndex];
 		isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnIndex);
 		isInscription = (wallOrnIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex);
 		if (isInscription) {
@@ -1492,7 +1616,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 		} else {
 			coordinateSetOffset = 0;
 			uint16 *coordSetB;
-			int16 wallOrnCoordSetIndex = _currMapWallOrnInfo[wallOrnIndex][kNativeCoordinateSet];
+			int16 wallOrnCoordSetIndex = _currMapWallOrnInfo[wallOrnIndex][kCoordinateSet];
 			flipHorizontal = (viewWallIndex == kViewWall_D2R_LEFT) || (viewWallIndex == kViewWall_D3R_LEFT);
 			if (flipHorizontal) {
 				coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1R_LEFT];
@@ -1587,6 +1711,14 @@ uint32 DisplayMan::getCompressedDataSize(uint16 index) {
 	return _packedItemPos[index + 1] - _packedItemPos[index];
 }
 
+int16 DisplayMan::getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale) {
+	return getScaledDimension(pixelWidth, scale) * getScaledDimension(pixelHeight, scale);
+}
+
+int16 DisplayMan::getScaledDimension(int16 dimension, int16 scale) {
+	return (dimension * scale + scale / 2) / 32;
+}
+
 void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) {
 	uint16 width = box._x2 - box._x1;
 	for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y)
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index b6a32c5..0e7bcf6 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -32,9 +32,89 @@
 #include "common/rect.h"
 #include "common/memstream.h"
 #include "dm.h"
+#include "common/array.h"
 
 namespace DM {
+#define kFloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT
+#define kWallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT
+#define kStairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT
+#define kDoorSetGraphicsCount 3 // @ C003_DOOR_SET_GRAPHIC_COUNT
+#define kDoorButtonCount 1 // @ C001_DOOR_BUTTON_COUNT
+#define kNativeBitmapIndex 0 // @ C0_NATIVE_BITMAP_INDEX
+#define kCoordinateSet 1 // @ C1_COORDINATE_SET
+#define kCreatureTypeCount 27 // @ C027_CREATURE_TYPE_COUNT
+#define kExplosionAspectCount 4 // @ C004_EXPLOSION_ASPECT_COUNT
+#define kObjAspectCount 85 // @ C085_OBJECT_ASPECT_COUNT
+#define kProjectileAspectCount 14 // @ C014_PROJECTILE_ASPECT_COUNT
+
+/* Explosion aspects */
+#define kExplosionAspectFire 0 // @ C0_EXPLOSION_ASPECT_FIRE  
+#define kExplosionAspectSpell 1 // @ C1_EXPLOSION_ASPECT_SPELL 
+#define kExplosionAspectPoison 2 // @ C2_EXPLOSION_ASPECT_POISON
+#define kExplosionAspectSmoke 3 // @ C3_EXPLOSION_ASPECT_SMOKE 
+
+/* Creature info GraphicInfo */
+#define kCreatureInfoMaskAdditional 0x0003 // @ MASK0x0003_ADDITIONAL                        
+#define kCreatureInfoMaskFlipNonAttack 0x0004 // @ MASK0x0004_FLIP_NON_ATTACK                  
+#define kCreatureInfoMaskSide 0x0008 // @ MASK0x0008_SIDE                             
+#define kCreatureInfoMaskBack 0x0010 // @ MASK0x0010_BACK                             
+#define kCreatureInfoMaskAttack 0x0020 // @ MASK0x0020_ATTACK                           
+#define kCreatureInfoMaskSpecialD2Front 0x0080 // @ MASK0x0080_SPECIAL_D2_FRONT                                                                               
+#define kCreatureInfoMaskSpecialD2FrontIsFlipped 0x0100 // @ MASK0x0100_SPECIAL_D2_FRONT_IS_FLIPPED_FRONT 
+#define kCreatureInfoMaskFlipAttack 0x0200 // @ MASK0x0200_FLIP_ATTACK                      
+#define kCreatureInfoMaskFlipDuringAttack 0x0400 // @ MASK0x0400_FLIP_DURING_ATTACK               
+
+class ExplosionAspect {
+public:
+	uint16 _pixelWidth;
+	uint16 _height;
+
+	ExplosionAspect(uint16 byteWidth, uint16 height) :_pixelWidth(byteWidth * 2), _height(height) {}
+}; // @ EXPLOSION_ASPECT
+
+extern ExplosionAspect gExplosionAspects[kExplosionAspectCount];
+
+extern byte gProjectileScales[7]; // @ G0215_auc_Graphic558_ProjectileScales
+
+
+#define kDerivedBitmapViewport 0 // @ C000_DERIVED_BITMAP_VIEWPORT                    
+#define kDerivedBitmapThievesEyeVisibleArea 1 // @ C001_DERIVED_BITMAP_THIEVES_EYE_VISIBLE_AREA    
+#define kDerivedBitmapDamageToCreatureMedium 2 // @ C002_DERIVED_BITMAP_DAMAGE_TO_CREATURE_MEDIUM   
+#define kDerivedBitmapDamageToCreatureSmall 3 // @ C003_DERIVED_BITMAP_DAMAGE_TO_CREATURE_SMALL    
+#define kDerivedBitmapFirstWallOrnament 4 // @ C004_DERIVED_BITMAP_FIRST_WALL_ORNAMENT         
+#define kDerivedBitmapFirstDoorOrnament_D3 68 // @ C068_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D3     
+#define kDerivedBitmapFirstDoorOrnament_D2 69 // @ C069_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D2    
+#define kDerivedBitmapFirstDoorButton 102 // @ C102_DERIVED_BITMAP_FIRST_DOOR_BUTTON         
+#define kDerivedBitmapFirstObject 104 // @ C104_DERIVED_BITMAP_FIRST_OBJECT              
+#define kDerivedBitmapFirstProjectile 282 // @ C282_DERIVED_BITMAP_FIRST_PROJECTILE          
+#define kDerivedBitmapFirstExplosion 438 // @ C438_DERIVED_BITMAP_FIRST_EXPLOSION           
+#define kDerivedBitmapFirstCreature 495 // @ C495_DERIVED_BITMAP_FIRST_CREATURE            
+
+
+#define kScale16_D3 16 // @ C16_SCALE_D3 
+#define kScale20_D2 20 // @ C20_SCALE_D2 
 
+/* Object aspect GraphicInfo */
+#define kObjectFlipOnRightMask 0x0001 // @ MASK0x0001_FLIP_ON_RIGHT 
+#define kObjectAlcoveMask 0x0010 // @ MASK0x0010_ALCOVE        
+
+/* Projectile aspect GraphicInfo */
+#define kProjectileSideMask 0x0010 // @ MASK0x0010_SIDE                      
+#define kProjectileScaleWithKineticEnergyMask 0x0100 // @ MASK0x0100_SCALE_WITH_KINETIC_ENERGY 
+#define kProjectileAspectTypeMask 0x0003 // @ MASK0x0003_ASPECT_TYPE               
+
+/* Projectile aspect type */
+#define kProjectileAspectHasBackGraphicRotation 0 // @ C0_PROJECTILE_ASPECT_TYPE_HAS_BACK_GRAPHIC_AND_ROTATION   
+#define kProjectileAspectBackGraphic 1 // @ C1_PROJECTILE_ASPECT_TYPE_HAS_BACK_GRAPHIC_AND_NO_ROTATION
+#define kProjectileAspectHasRotation 2 // @ C2_PROJECTILE_ASPECT_TYPE_NO_BACK_GRAPHIC_AND_ROTATION    
+#define kProjectileAspectHasNone 3 // @ C3_PROJECTILE_ASPECT_TYPE_NO_BACK_GRAPHIC_AND_NO_ROTATION 
+
+/* Projectile aspects */
+#define kProjectileAspectExplosionLightningBolt 3 // @ C03_PROJECTILE_ASPECT_EXPLOSION_LIGHTNING_BOLT           
+#define kProjectileAspectExplosionFireBall 10 // @ C10_PROJECTILE_ASPECT_EXPLOSION_FIREBALL                
+#define kProjectileAspectExplosionDefault 11 // @ C11_PROJECTILE_ASPECT_EXPLOSION_DEFAULT                 
+#define kProjectileAspectExplosionSlime 12 // @ C12_PROJECTILE_ASPECT_EXPLOSION_SLIME                   
+#define kProjectileAspectExplosionPoisonBoltCloud 13 // @ C13_PROJECTILE_ASPECT_EXPLOSION_POISON_BOLT_POISON_CLOUD
 
 enum ViewCell {
 	kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT
@@ -80,7 +160,8 @@ enum GraphicIndice {
 	kPanelOpenChestIndice = 25, // @ C025_GRAPHIC_PANEL_OPEN_CHEST
 	kEyeForObjectDescriptionIndice = 19, // @ C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION
 	kArrowForChestContentIndice = 18, // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT
-	kObjectDescCircleIndice = 29 // @ C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE
+	kObjectDescCircleIndice = 29, // @ C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE
+	kFloorOrn_15_D3L_footprints = 241 // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS
 };
 
 extern uint16 gPalSwoosh[16];
@@ -248,17 +329,6 @@ extern Viewport gDungeonViewport;
 #define kAlcoveOrnCount 3
 #define kFountainOrnCount 1
 
-#define kFloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT
-#define kWallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT
-#define kStairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT
-#define kDoorSetGraphicsCount 3 // @ C003_DOOR_SET_GRAPHIC_COUNT
-#define kDoorButtonCount 1 // @ C001_DOOR_BUTTON_COUNT
-#define kNativeBitmapIndex 0 // @ C0_NATIVE_BITMAP_INDEX
-#define kNativeCoordinateSet 1 // @ C1_COORDINATE_SET
-#define kCreatureTypeCount 27 // @ C027_CREATURE_TYPE_COUNT
-#define kExplosionAspectCount 4 // @ C004_EXPLOSION_ASPECT_COUNT
-#define kObjAspectCount 85 // @ C085_OBJECT_ASPECT_COUNT
-#define kProjectileAspectCount 14 // @ C014_PROJECTILE_ASPECT_COUNT
 
 #define kDoorButton 0 // @ C0_DOOR_BUTTON
 #define kWallOrnInscription 0 // @ C0_WALL_ORNAMENT_INSCRIPTION
@@ -320,6 +390,8 @@ class DisplayMan {
 
 	bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF
 
+	uint16 *_derivedBitmapByteCount;// @ G0639_pui_DerivedBitmapByteCount
+
 public:
 	// some methods use this for a stratchpad, don't make assumptions about content between function calls
 	byte *_tmpBitmap;
@@ -332,7 +404,7 @@ public:
 
 	void setUpScreens(uint16 width, uint16 height);
 	void loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader, F0460_START_InitializeGraphicData
-	void loadCurrentMapGraphics();
+	void loadCurrentMapGraphics(); // @ F0096_DUNGEONVIEW_LoadCurrentMapGraphics_CPSDF
 	void loadPalette(uint16 *palette);
 
 	/// Gives the width of an IMG0 type item
@@ -369,6 +441,9 @@ public:
 	Common::MemoryReadStream getCompressedData(uint16 index);
 	uint32 getCompressedDataSize(uint16 index);
 
+	int16 getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount
+	int16 getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION
+
 	int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
 	int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
 	int16 _currMapFountainOrnIndices[kFountainOrnCount]; // @ G0268_ai_CurrentMapFountainOrnamentIndices
@@ -385,6 +460,12 @@ public:
 	Thing _inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing
 
 	bool _useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates
+
+	bool isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
+	byte *getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap
+
+
+
 };
 
 }


Commit: 36a29bbe867206d2b0b408550ad4ee15610c9276
    https://github.com/scummvm/scummvm/commit/36a29bbe867206d2b0b408550ad4ee15610c9276
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Reorder files in MK file

Changed paths:
    engines/dm/module.mk



diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index bd9b576..d5756c9 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -29,18 +29,18 @@
 MODULE := engines/dm
 
 MODULE_OBJS := \
+	champion.o \
 	detection.o \
 	dm.o \
-	gfx.o \
 	dungeonman.o \
 	eventman.o \
-	menus.o \
-	champion.o \
+	gfx.o \
+	inventory.o \
 	loadsave.o \
+	menus.o \
+	movesens.o \
 	objectman.o \
-	inventory.o \
-	text.o \
-	movesens.o
+	text.o
 
 MODULE_DIRS += \
 	engines/dm


Commit: 3f19bcdf6b47bc7227eb91c6eb95fb20335276f6
    https://github.com/scummvm/scummvm/commit/3f19bcdf6b47bc7227eb91c6eb95fb20335276f6
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0491_CACHE_IsDerivedBitmapInCache, F0492_CACHE_GetDerivedBitmap

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 0c55fe5..ea3a4b7 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -617,6 +617,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_ceilingBitmap = nullptr;
 	_currMapAllowedCreatureTypes = nullptr;
 	_derivedBitmapByteCount = nullptr;
+	_derivedBitmaps = nullptr;
 
 	_screenWidth = _screenHeight = 0;
 	_championPortraitOrdinal = 0;
@@ -671,6 +672,13 @@ DisplayMan::~DisplayMan() {
 	delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; // copy of another bitmap, but flipped
 	for (uint16 i = kWall_D0L_Flipped; i <= kWall_D3LCR_Flipped; ++i)
 		delete[] _wallSetBitMaps[i];
+
+	delete[] _derivedBitmapByteCount;
+	if (_derivedBitmaps) {
+		for (uint16 i = 0; i < kDerivedBitmapMaximumCount; ++i)
+			delete[] _derivedBitmaps;
+		delete[] _derivedBitmaps;
+	}
 }
 
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
@@ -712,6 +720,11 @@ void DisplayMan::loadGraphics() {
 
 	if (!_derivedBitmapByteCount)
 		_derivedBitmapByteCount = new uint16[kDerivedBitmapMaximumCount];
+	if (!_derivedBitmaps) {
+		_derivedBitmaps = new byte*[kDerivedBitmapMaximumCount];
+		for (uint16 i = 0; i < kDerivedBitmapMaximumCount; ++i)
+			_derivedBitmaps[i] = nullptr;
+	}
 
 	_derivedBitmapByteCount[kDerivedBitmapViewport] = 224 * 136;
 	_derivedBitmapByteCount[kDerivedBitmapThievesEyeVisibleArea] = 96 * 95;
@@ -791,16 +804,16 @@ void DisplayMan::loadGraphics() {
 	CreatureAspect *creatureAsp;
 	for (int16 creatureIndex = 0; creatureIndex < kCreatureTypeCount; creatureIndex++) {
 		creatureAsp = &gCreatureAspects[creatureIndex];
-		
+
 		int16 creatureGraphicInfo = gCreatureInfo[creatureIndex]._graphicInfo;
 		creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex;
-		
+
 		int16 creatureFrontBitmapD3PixelCount;
 		_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3);
-		
+
 		int16 creatureFrontBitmapD2PixelCount;
 		_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2);
-		
+
 		if (getFlag(creatureGraphicInfo, kCreatureInfoMaskSide)) {
 			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale16_D3);
 			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale20_D2);
@@ -1719,6 +1732,18 @@ int16 DisplayMan::getScaledDimension(int16 dimension, int16 scale) {
 	return (dimension * scale + scale / 2) / 32;
 }
 
+bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) {
+	if (_derivedBitmaps == nullptr) {
+		_derivedBitmaps[derivedBitmapIndex] = new byte[_derivedBitmapByteCount[derivedBitmapIndex]];
+		return false;
+	} else
+		return true;
+}
+
+byte* DisplayMan::getDerivedBitmap(int16 derivedBitmapIndex) {
+	return _derivedBitmaps[derivedBitmapIndex];
+}
+
 void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) {
 	uint16 width = box._x2 - box._x1;
 	for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y)
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 0e7bcf6..ba6584f 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -390,7 +390,8 @@ class DisplayMan {
 
 	bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF
 
-	uint16 *_derivedBitmapByteCount;// @ G0639_pui_DerivedBitmapByteCount
+	uint16 *_derivedBitmapByteCount; // @ G0639_pui_DerivedBitmapByteCount
+	byte **_derivedBitmaps; // @ G0638_pui_DerivedBitmapBlockIndices
 
 public:
 	// some methods use this for a stratchpad, don't make assumptions about content between function calls


Commit: 57ca9afcff6b688d438a7c02096141921f28fc36
    https://github.com/scummvm/scummvm/commit/57ca9afcff6b688d438a7c02096141921f28fc36
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Move two global arrays to DMEngine

Changed paths:
  A engines/dm/dmglobals.cpp
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/module.mk



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index cce3f55..88e03a5 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -561,8 +561,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	int16 mapY = _vm->_dungeonMan->_currMap._partyPosY;
 
 	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir));
-	mapX += gDirIntoStepCountEast[dunMan._currMap._partyDir];
-	mapY += gDirIntoStepCountNorth[dunMan._currMap._partyDir];
+	mapX += _vm->_dirIntoStepCountEast[dunMan._currMap._partyDir];
+	mapY += _vm->_dirIntoStepCountNorth[dunMan._currMap._partyDir];
 	thing = dunMan.getSquareFirstThing(mapX, mapY);
 	AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
 	uint16 slotIndex_Green;
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 0df836a..af0c9d5 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -52,9 +52,6 @@
 
 namespace DM {
 
-int8 gDirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount
-int8 gDirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
-
 void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
 void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); }
 direction returnOppositeDir(direction dir) { return (direction)((dir + 2) & 3); }
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 7b68e6d..4bf8584 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -55,10 +55,6 @@ enum direction {
 	kDirWest = 3
 };
 
-// TODO: refactor direction into a class
-extern int8 gDirIntoStepCountEast[4];
-extern int8 gDirIntoStepCountNorth[4];
-
 void turnDirRight(direction &dir);
 void turnDirLeft(direction &dir);
 direction returnOppositeDir(direction dir);
@@ -128,6 +124,8 @@ class DMEngine : public Engine {
 	void processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
 	void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
 	void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF
+	void initArrays();
+
 public:
 	explicit DMEngine(OSystem *syst);
 	~DMEngine();
@@ -160,6 +158,10 @@ public:
 	bool _pressingMouth; // @ G0333_B_PressingMouth
 	bool _stopPressingMouth; // @ G0334_B_StopPressingMouth
 	bool _highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested
+
+	// TODO: refactor direction into a class
+	int8 _dirIntoStepCountEast[4];
+	int8 _dirIntoStepCountNorth[4];
 };
 
 class Console : public GUI::Debugger {
diff --git a/engines/dm/dmglobals.cpp b/engines/dm/dmglobals.cpp
new file mode 100644
index 0000000..c138453
--- /dev/null
+++ b/engines/dm/dmglobals.cpp
@@ -0,0 +1,55 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#include "dm/dm.h"
+#include "gfx.h"
+#include "dungeonman.h"
+#include "eventman.h"
+#include "menus.h"
+#include "champion.h"
+#include "loadsave.h"
+#include "objectman.h"
+#include "inventory.h"
+#include "text.h"
+#include "movesens.h"
+
+namespace DM {
+
+void DMEngine::initArrays() {
+	// G0233_ai_Graphic559_DirectionToStepEastCount
+	_dirIntoStepCountEast[0] = 0;  // North
+	_dirIntoStepCountEast[1] = 1;  // East
+	_dirIntoStepCountEast[2] = 0;  // West
+	_dirIntoStepCountEast[3] = -1; // South
+
+	// G0234_ai_Graphic559_DirectionToStepNorthCount
+	_dirIntoStepCountNorth[0] = -1; // North
+	_dirIntoStepCountNorth[1] = 0;  // East
+	_dirIntoStepCountNorth[2] = 1;  // West
+	_dirIntoStepCountNorth[3] = 0;  // South
+}
+} // End of namespace DM
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 899e791..83c43aa 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -360,11 +360,11 @@ CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_Crea
 	{26,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}};
 
 void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
-	posX += gDirIntoStepCountEast[dir] * stepsForward;
-	posY += gDirIntoStepCountNorth[dir] * stepsForward;
+	posX += _vm->_dirIntoStepCountEast[dir] * stepsForward;
+	posY += _vm->_dirIntoStepCountNorth[dir] * stepsForward;
 	turnDirRight(dir);
-	posX += gDirIntoStepCountEast[dir] * stepsRight;
-	posY += gDirIntoStepCountNorth[dir] * stepsRight;
+	posX += _vm->_dirIntoStepCountEast[dir] * stepsRight;
+	posY += _vm->_dirIntoStepCountNorth[dir] * stepsRight;
 }
 
 DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) {
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 20c2888..f26930c 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -508,8 +508,8 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
 void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() {
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 	CurrMapData &currMap = dunMan._currMap;
-	int16 mapX = currMap._partyPosX + gDirIntoStepCountEast[currMap._partyDir];
-	int16 mapY = currMap._partyPosY + gDirIntoStepCountNorth[currMap._partyDir];
+	int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir];
+	int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir];
 	if ((mapX >= 0) && (mapX < currMap._width) && (mapY >= 0) && (mapY < currMap._height)) {
 		_vm->_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(currMap._partyDir));
 	}
@@ -525,8 +525,8 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 			return;
 
 		if (champMan._leaderEmptyHanded) {
-			int16 mapX = currMap._partyPosX + gDirIntoStepCountEast[currMap._partyDir];
-			int16 mapY = currMap._partyPosY + gDirIntoStepCountNorth[currMap._partyDir];
+			int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir];
+			int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir];
 
 			if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() &&
 				dunMan._dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
@@ -627,8 +627,8 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	}
 
 	champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kChampionNone);
-	int16 mapX = currMap._partyPosX + gDirIntoStepCountEast[currMap._partyDir];
-	int16 mapY = currMap._partyPosY + gDirIntoStepCountNorth[currMap._partyDir];
+	int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir];
+	int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir];
 
 	for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) {
 		Thing thing = champ->getSlot((ChampionSlot)slotIndex);
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index d5756c9..28bcaa2 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -32,6 +32,7 @@ MODULE_OBJS := \
 	champion.o \
 	detection.o \
 	dm.o \
+	dmglobals.o \
 	dungeonman.o \
 	eventman.o \
 	gfx.o \


Commit: bc583bf0d52cb2e9d959ad36a06e462707084d63
    https://github.com/scummvm/scummvm/commit/bc583bf0d52cb2e9d959ad36a06e462707084d63
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix missing call to initArrays()

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index af0c9d5..2d55c5e 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -189,6 +189,8 @@ void DMEngine::processNewPartyMap(uint16 mapIndex) {
 }
 
 Common::Error DMEngine::run() {
+	initArrays();
+
 	// scummvm/engine specific
 	initGraphics(320, 200, false);
 	_console = new Console(this);


Commit: b3e1760bfb6113159a7a8d6079c358a451eee781
    https://github.com/scummvm/scummvm/commit/b3e1760bfb6113159a7a8d6079c358a451eee781
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add dummy blitBoxFilledWithMaskedBitmap and DisplayMan::drawField

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index 10ed85f..7a05ad1 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -1,9 +1,9 @@
 F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
-	F0113_DUNGEONVIEW_DrawField // dummy
-		F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
-		FIELD_ASPECT
+	F0113_DUNGEONVIEW_DrawField // stub method
+		F0133_VIDEO_BlitBoxFilledWithMaskedBitmap // dummy
+		FIELD_ASPECT // done
 	F0114_DUNGEONVIEW_GetExplosionBitmap
-	F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
+	F0133_VIDEO_BlitBoxFilledWithMaskedBitmap // dummy
 	F0141_DUNGEON_GetObjectInfoIndex
 	F0142_DUNGEON_GetProjectileAspect
 	F0176_GROUP_GetCreatureOrdinalInCell
@@ -44,7 +44,7 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 	CREATURE_ASPECT
 	PROJECTILE
 	EXPLOSION
-	FIELD_ASPECT
+	FIELD_ASPECT // done
 
 
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index ea3a4b7..2fa2bf5 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -969,6 +969,12 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight
 		memcpy(destBitmap + destWidth*(y + destY) + destX, srcBitmap + y * srcWidth, sizeof(byte)* srcWidth);
 }
 
+void DisplayMan::blitBoxFilledWithMaskedBitmapToScreen(byte* src, byte* mask, byte* tmp, Box& box,
+													   int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
+													   int16 xPos, int16 yPos, int16 height2, Viewport& viewport) {
+	blitBoxFilledWithMaskedBitmap(src, _vgaBuffer, mask, tmp, box, lastUnitIndex, firstUnitIndex, _screenWidth, transparent, xPos, yPos, _screenHeight, height2, viewport);
+}
+
 void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) {
 	for (uint16 y = 0; y < height; ++y) {
 		for (uint16 x = 0; x < width / 2; ++x) {
@@ -1724,6 +1730,32 @@ uint32 DisplayMan::getCompressedDataSize(uint16 index) {
 	return _packedItemPos[index + 1] - _packedItemPos[index];
 }
 
+/* Field Aspect Mask */
+#define kMaskFieldAspectFlipMask 0x0080 // @ MASK0x0080_FLIP_MASK 
+#define kMaskFieldAspectIndex 0x007F // @ MASK0x007F_MASK_INDEX
+#define kMaskFieldAspectNoMask 255 // @ C255_NO_MASK            
+
+void DisplayMan::drawField(FieldAspect* fieldAspect, Box& box) {
+	DisplayMan &dispMan = *_vm->_displayMan;
+
+	byte *bitmapMask;
+	if (fieldAspect->_mask == kMaskFieldAspectNoMask) {
+		bitmapMask = nullptr;
+	} else {
+		bitmapMask = dispMan._tmpBitmap;
+		memcpy(bitmapMask, dispMan.getBitmap(kFieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)),
+			   fieldAspect->_height * fieldAspect->_pixelWidth * sizeof(bitmapMask[0]));
+		if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask)) {
+			dispMan.flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height);
+		}
+	}
+
+	byte *bitmap = dispMan.getBitmap(kFieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex);
+	warning("MISSING CODE: F0133_VIDEO_BlitBoxFilledWithMaskedBitmap");
+
+	warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache, F0493_CACHE_AddDerivedBitmap, F0480_CACHE_ReleaseBlock");
+}
+
 int16 DisplayMan::getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale) {
 	return getScaledDimension(pixelWidth, scale) * getScaledDimension(pixelHeight, scale);
 }
@@ -1756,4 +1788,10 @@ void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uin
 	blitToScreen(srcBitmap, srcWidth, srcX, srcY, box._x1, box._x2, box._y1, box._y2, transparent, viewport);
 }
 
+void DisplayMan::blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box,
+											   int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
+											   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport) {
+	warning("STUB FUNCTION: does nothing at all");
+}
+
 }
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index ba6584f..34a1399 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -35,6 +35,9 @@
 #include "common/array.h"
 
 namespace DM {
+
+
+
 #define kFloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT
 #define kWallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT
 #define kStairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT
@@ -161,7 +164,9 @@ enum GraphicIndice {
 	kEyeForObjectDescriptionIndice = 19, // @ C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION
 	kArrowForChestContentIndice = 18, // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT
 	kObjectDescCircleIndice = 29, // @ C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE
-	kFloorOrn_15_D3L_footprints = 241 // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS
+	kFloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS
+	kFieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R
+	kFieldTeleporterGraphicIndice = 73 // @ C073_GRAPHIC_FIELD_TELEPORTER
 };
 
 extern uint16 gPalSwoosh[16];
@@ -265,6 +270,20 @@ enum Color {
 	kColorWhite = 15
 };
 
+class FieldAspect {
+public:
+	uint16 _nativeBitmapRelativeIndex;
+	uint16 _baseStartUnitIndex; /* Index of the unit (16 pixels = 8 bytes) in bitmap where blit will start from. A random value of 0 or 1 is added to this base index */
+	Color _transparentColor; /* Bit 7: Do not use mask if set, Bits 6-0: Transparent color index. 0xFF = no transparency */
+	byte _mask; /* Bit 7: Flip, Bits 6-0: Mask index. 0xFF = no mask */
+	uint16 _pixelWidth;
+	uint16 _height;
+	uint16 _xPos;
+	FieldAspect(uint16 native, uint16 base, Color transparent, byte mask, uint16 byteWidth, uint16 height, uint16 xPos)
+		: _nativeBitmapRelativeIndex(native), _baseStartUnitIndex(base), _transparentColor(transparent), _mask(mask),
+		_pixelWidth(byteWidth * 2), _height(height), _xPos(xPos) {}
+}; // @ FIELD_ASPECT
+
 
 class Viewport {
 public:
@@ -429,6 +448,12 @@ public:
 	void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 					  Box &box,
 					  Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort);
+	void blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
+									   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
+									   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDefultViewPort); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
+	void blitBoxFilledWithMaskedBitmapToScreen(byte *src, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
+									   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
+									   int16 xPos, int16 yPos, int16 height2, Viewport &viewport = gDungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
 
 	void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height);
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
@@ -441,6 +466,7 @@ public:
 	byte* getBitmap(uint16 index);
 	Common::MemoryReadStream getCompressedData(uint16 index);
 	uint32 getCompressedDataSize(uint16 index);
+	void drawField(FieldAspect *fieldAspect, Box &box); // @ F0113_DUNGEONVIEW_DrawField
 
 	int16 getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount
 	int16 getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION


Commit: a09ff6a165ded27abed68edd4067acd494ec5221
    https://github.com/scummvm/scummvm/commit/a09ff6a165ded27abed68edd4067acd494ec5221
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0114_DUNGEONVIEW_GetExplosionBitmap

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index 7a05ad1..da5e0cc 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -2,7 +2,7 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 	F0113_DUNGEONVIEW_DrawField // stub method
 		F0133_VIDEO_BlitBoxFilledWithMaskedBitmap // dummy
 		FIELD_ASPECT // done
-	F0114_DUNGEONVIEW_GetExplosionBitmap
+	F0114_DUNGEONVIEW_GetExplosionBitmap // done
 	F0133_VIDEO_BlitBoxFilledWithMaskedBitmap // dummy
 	F0141_DUNGEON_GetObjectInfoIndex
 	F0142_DUNGEON_GetProjectileAspect
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 2fa2bf5..81b53d4 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -39,6 +39,8 @@ namespace DM {
 
 Box gBoxMovementArrows = Box(224, 319, 124, 168);
 
+byte gPalChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke
+
 ExplosionAspect gExplosionAspects[kExplosionAspectCount] = { // @ G0211_as_Graphic558_ExplosionAspects
 	/* { ByteWidth, Height } */
 	ExplosionAspect(80, 111),   /* Fire   */
@@ -998,6 +1000,30 @@ void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) {
 	delete[] tmp;
 }
 
+byte* DisplayMan::getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnPixelWidth, int16& returnHeight) {
+	ExplosionAspect *explAsp = &gExplosionAspects[explosionAspIndex];
+	if (scale > 32)
+		scale = 32;
+	int16 pixelWidth = getScaledDimension(explAsp->_pixelWidth, scale);
+	int16 height = getScaledDimension(explAsp->_height, scale);
+	byte *bitmap;
+	int16 derBitmapIndex = (explosionAspIndex * 14) + scale / 2 + kDerivedBitmapFirstExplosion - 2;
+	if ((scale == 32) && (explosionAspIndex != kExplosionAspectSmoke)) {
+		bitmap = getBitmap(explosionAspIndex + kFirstExplosionGraphicIndice);
+	} else if (isDerivedBitmapInCache(derBitmapIndex)) {
+		bitmap = getDerivedBitmap(derBitmapIndex);
+	} else {
+		byte *nativeBitmap = getBitmap(MIN(explosionAspIndex, (uint16)kExplosionAspectPoison) + kFirstExplosionGraphicIndice);
+		bitmap = getDerivedBitmap(derBitmapIndex);
+		blitToBitmapShrinkWithPalChange(nativeBitmap, explAsp->_pixelWidth, explAsp->_height, bitmap, pixelWidth, height,
+			(explosionAspIndex == kExplosionAspectSmoke) ? gPalChangeSmoke : gPalChangesNoChanges);
+		warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+	}
+
+	returnPixelWidth = pixelWidth;
+	returnHeight = height;
+	return bitmap;
+}
 
 
 void DisplayMan::updateScreen() {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 34a1399..2df0ac0 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -166,7 +166,8 @@ enum GraphicIndice {
 	kObjectDescCircleIndice = 29, // @ C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE
 	kFloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS
 	kFieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R
-	kFieldTeleporterGraphicIndice = 73 // @ C073_GRAPHIC_FIELD_TELEPORTER
+	kFieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER
+	kFirstExplosionGraphicIndice = 348 // @ C348_GRAPHIC_FIRST_EXPLOSION
 };
 
 extern uint16 gPalSwoosh[16];
@@ -457,6 +458,7 @@ public:
 
 	void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height);
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
+	byte *getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap
 
 	void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color);
 	void clearScreen(Color color);


Commit: f3d4b854b7544c1379414983fcc750d60dfe2151
    https://github.com/scummvm/scummvm/commit/f3d4b854b7544c1379414983fcc750d60dfe2151
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0142_DUNGEON_GetProjectileAspect

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/objectman.cpp



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index da5e0cc..9f09e9d 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -4,8 +4,10 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 		FIELD_ASPECT // done
 	F0114_DUNGEONVIEW_GetExplosionBitmap // done
 	F0133_VIDEO_BlitBoxFilledWithMaskedBitmap // dummy
-	F0141_DUNGEON_GetObjectInfoIndex
-	F0142_DUNGEON_GetProjectileAspect
+	F0141_DUNGEON_GetObjectInfoIndex // done
+	F0142_DUNGEON_GetProjectileAspect // done 
+		F0158_DUNGEON_GetWeaponInfo // done
+		M66_PROJECTILE_ASPECT_ORDINAL // done
 	F0176_GROUP_GetCreatureOrdinalInCell
 	G0017_auc_Graphic562_PaletteChanges_NoChanges
 	G0075_apuc_PaletteChanges_Projectile
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 88e03a5..730eaa2 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -368,7 +368,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 	ObjectMan &objMan = *_vm->_objectMan;
 	MenuMan &menuMan = *_vm->_menuMan;
 
-	if (thing == Thing::_thingNone)
+	if (thing == Thing::_none)
 		return;
 
 	Champion *champ = &_champions[champIndex];
@@ -442,7 +442,7 @@ void ChampionMan::resetDataToStartGame() {
 		assert(false);
 	}
 
-	_leaderHandObject = Thing::_thingNone;
+	_leaderHandObject = Thing::_none;
 	_leaderHandObjectIconIndex = kIconIndiceNone;
 	_leaderEmptyHanded = true;
 }
@@ -479,7 +479,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
 	int16 AL_0_slotIndex_Red;
 	for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) {
-		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone);
+		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none);
 	}
 	Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY);
 	while (thing.getType() != kTextstringType) {
@@ -566,7 +566,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	thing = dunMan.getSquareFirstThing(mapX, mapY);
 	AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
 	uint16 slotIndex_Green;
-	while (thing != Thing::_thingEndOfList) {
+	while (thing != Thing::_endOfList) {
 		ThingType AL_2_thingType = thing.getType();
 		if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) {
 			int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots();
@@ -576,14 +576,14 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 					if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
 						goto T0280048;
 				}
-				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
+				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_none)) {
 					slotIndex_Green = kChampionSlotNeck;
 				} else {
 					goto T0280046;
 				}
 				break;
 			case kWeaponThingType:
-				if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) {
+				if (champ->getSlot(kChampionSlotActionHand) == Thing::_none) {
 					slotIndex_Green = kChampionSlotActionHand;
 				} else {
 					goto T0280046;
@@ -591,9 +591,9 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 				break;
 			case kScrollThingType:
 			case kPotionThingType:
-				if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) {
+				if (champ->getSlot(kChampionSlotPouch_1) == Thing::_none) {
 					slotIndex_Green = kChampionSlotPouch_1;
-				} else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) {
+				} else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_none) {
 					slotIndex_Green = kChampionSlotPouch_2;
 				} else {
 					goto T0280046;
@@ -602,7 +602,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 			case kContainerThingType:
 			case kJunkThingType:
 T0280046:
-				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) {
+				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_none)) {
 					slotIndex_Green = kChampionSlotNeck;
 				} else {
 					slotIndex_Green = AL_0_slotIndex_Red++;
@@ -613,7 +613,7 @@ T0280046:
 				break;
 			}
 T0280048:
-			if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) {
+			if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_none) {
 				goto T0280046;
 			}
 			addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green);
@@ -937,7 +937,7 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 	}
 
 	int16 iconIndex;
-	if (thing == Thing::_thingNone) {
+	if (thing == Thing::_none) {
 		if (slotIndex <= kChampionSlotFeet) {
 			iconIndex = kIconIndiceReadyHand + (slotIndex << 1);
 			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) {
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index d712e6b..e0390a4 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -400,7 +400,7 @@ public:
 	void clearWounds() { _wounds = kChampionWoundNone; }
 	void resetToZero() { // oh boy > . <
 		for (int16 i = 0; i < 30; ++i)
-			_slots[i] = Thing::_thingNone;
+			_slots[i] = Thing::_none;
 		for (int16 i = 0; i < 20; ++i)
 			_skills[i].resetToZero();
 		_attributes = _wounds = 0;
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 4bf8584..251a0af 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -95,8 +95,21 @@ enum Cell {
 class Thing {
 	uint16 _data;
 public:
-	static const Thing _thingNone;
-	static const Thing _thingEndOfList;
+	static const Thing _none; // @ C0xFFFF_THING_NONE
+	static const Thing _endOfList; // @ C0xFFFE_THING_ENDOFLIST
+	static const Thing _firstExplosion; // @ C0xFF80_THING_FIRST_EXPLOSION            
+	static const Thing _explFireBall; // @ C0xFF80_THING_EXPLOSION_FIREBALL         
+	static const Thing _explSlime; // @ C0xFF81_THING_EXPLOSION_SLIME            
+	static const Thing _explLightningBolt; // @ C0xFF82_THING_EXPLOSION_LIGHTNING_BOLT   
+	static const Thing _explHarmNonMaterial; // @ C0xFF83_THING_EXPLOSION_HARM_NON_MATERIAL
+	static const Thing _explOpenDoor; // @ C0xFF84_THING_EXPLOSION_OPEN_DOOR        
+	static const Thing _explPoisonBolt; // @ C0xFF86_THING_EXPLOSION_POISON_BOLT      
+	static const Thing _explPoisonCloud; // @ C0xFF87_THING_EXPLOSION_POISON_CLOUD     
+	static const Thing _explSmoke; // @ C0xFFA8_THING_EXPLOSION_SMOKE            
+	static const Thing _explFluxcage; // @ C0xFFB2_THING_EXPLOSION_FLUXCAGE         
+	static const Thing _explRebirthStep1; // @ C0xFFE4_THING_EXPLOSION_REBIRTH_STEP1    
+	static const Thing _explRebirthStep2; // @ C0xFFE5_THING_EXPLOSION_REBIRTH_STEP2    
+	static const Thing _party; // @ C0xFFFF_THING_PARTY  
 
 	Thing() : _data(0) {}
 	explicit Thing(uint16 d) { set(d); }
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 83c43aa..12531b6 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -534,8 +534,21 @@ unsigned char gThingDataWordCount[16] = {
 	2    /* Explosion */
 }; // @ G0235_auc_Graphic559_ThingDataByteCount
 
-const Thing Thing::_thingNone(0);
-const Thing Thing::_thingEndOfList(0xFFFE);
+const Thing Thing::_none(0); // @ C0xFFFF_THING_NONE
+const Thing Thing::_endOfList(0xFFFE); // @ C0xFFFE_THING_ENDOFLIST
+const Thing Thing::_firstExplosion(0xFF80); // @ C0xFF80_THING_FIRST_EXPLOSION            
+const Thing Thing::_explFireBall(0xFF80); // @ C0xFF80_THING_EXPLOSION_FIREBALL         
+const Thing Thing::_explSlime(0xFF81); // @ C0xFF81_THING_EXPLOSION_SLIME            
+const Thing Thing::_explLightningBolt(0xFF82); // @ C0xFF82_THING_EXPLOSION_LIGHTNING_BOLT   
+const Thing Thing::_explHarmNonMaterial(0xFF83); // @ C0xFF83_THING_EXPLOSION_HARM_NON_MATERIAL
+const Thing Thing::_explOpenDoor(0xFF84); // @ C0xFF84_THING_EXPLOSION_OPEN_DOOR        
+const Thing Thing::_explPoisonBolt(0xFF86); // @ C0xFF86_THING_EXPLOSION_POISON_BOLT      
+const Thing Thing::_explPoisonCloud(0xFF87); // @ C0xFF87_THING_EXPLOSION_POISON_CLOUD     
+const Thing Thing::_explSmoke(0xFFA8); // @ C0xFFA8_THING_EXPLOSION_SMOKE            
+const Thing Thing::_explFluxcage(0xFFB2); // @ C0xFFB2_THING_EXPLOSION_FLUXCAGE         
+const Thing Thing::_explRebirthStep1(0xFFE4); // @ C0xFFE4_THING_EXPLOSION_REBIRTH_STEP1    
+const Thing Thing::_explRebirthStep2(0xFFE5); // @ C0xFFE5_THING_EXPLOSION_REBIRTH_STEP2    
+const Thing Thing::_party(0xFFFF); // @ C0xFFFF_THING_PARTY          
 
 void DungeonMan::loadDungeonFile() {
 	if (_messages._newGame)
@@ -627,7 +640,7 @@ void DungeonMan::loadDungeonFile() {
 		_dunData._squareFirstThings[i].set(dunDataStream.readUint16BE());
 	if (_messages._newGame)
 		for (uint16 i = 0; i < 300; ++i)
-			_dunData._squareFirstThings[actualSquareFirstThingCount + i] = Thing::_thingNone;
+			_dunData._squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none;
 
 	// TODO: ??? is this - end
 
@@ -688,7 +701,7 @@ void DungeonMan::loadDungeonFile() {
 			if ((thingType == kGroupThingType) || thingType >= kProjectileThingType)
 				_dunData._eventMaximumCount += _fileHeader._thingCounts[thingType];
 			for (uint16 i = 0; i < gAdditionalThingCounts[thingType]; ++i) {
-				_dunData._thingsData[thingType][thingCount + i][0] = Thing::_thingNone.toUint16();
+				_dunData._thingsData[thingType][thingCount + i][0] = Thing::_none.toUint16();
 			}
 		}
 	}
@@ -797,7 +810,7 @@ int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) {
 Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) {
 	int16 index = getSquareFirstThingIndex(mapX, mapY);
 	if (index == -1)
-		return Thing::_thingEndOfList;
+		return Thing::_endOfList;
 	return _dunData._squareFirstThings[index];
 }
 
@@ -849,7 +862,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
 T0172010_ClosedFakeWall:
 		setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall);
 
-		while ((thing != Thing::_thingEndOfList) && (thing.getType() <= kSensorThingType)) {
+		while ((thing != Thing::_endOfList) && (thing.getType() <= kSensorThingType)) {
 			int16 sideIndex = (thing.getCell() - dir) & 3;
 			if (sideIndex) {
 				if (thing.getType() == kTextstringType) {
@@ -868,7 +881,7 @@ T0172010_ClosedFakeWall:
 			thing = getNextThing(thing);
 		}
 		if (squareIsFakeWall && (_currMap._partyPosX != mapX) && (_currMap._partyPosY != mapY)) {
-			aspectArray[kFirstGroupOrObjectAspect] = Thing::_thingEndOfList.toUint16();
+			aspectArray[kFirstGroupOrObjectAspect] = Thing::_endOfList.toUint16();
 			return;
 		}
 		break;
@@ -897,7 +910,7 @@ T0172010_ClosedFakeWall:
 T0172029_Teleporter:
 		footPrintsAllowed = true;
 T0172030_Pit:
-		while ((thing != Thing::_thingEndOfList) && (thing.getType() <= kSensorThingType)) {
+		while ((thing != Thing::_endOfList) && (thing.getType() <= kSensorThingType)) {
 			if (thing.getType() == kSensorThingType)
 				aspectArray[kFloorOrnOrdAspect] = Sensor(getThingData(thing)).getOrnOrdinal();
 			thing = getNextThing(thing);
@@ -921,7 +934,7 @@ T0172030_Pit:
 		}
 		footPrintsAllowed = true;
 T0172046_Stairs:
-		while ((thing != Thing::_thingEndOfList) && (thing.getType() <= kSensorThingType))
+		while ((thing != Thing::_endOfList) && (thing.getType() <= kSensorThingType))
 			thing = getNextThing(thing);
 T0172049_Footprints:
 		unsigned char scentOrdinal; // see next line comment
@@ -1178,7 +1191,7 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 		2, 0, 8
 	};
 
-	if (thing == Thing::_thingNone)
+	if (thing == Thing::_none)
 		return 0;
 	switch (thing.getType()) {
 	case kWeaponThingType:
@@ -1196,7 +1209,7 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 		uint16 weight = 50;
 		Container container(getThingData(thing));
 		Thing slotThing = container.getSlot();
-		while (slotThing != Thing::_thingEndOfList) {
+		while (slotThing != Thing::_endOfList) {
 			weight += getObjectWeight(slotThing);
 			slotThing = getNextThing(slotThing);
 		}
@@ -1240,11 +1253,11 @@ int16 DungeonMan::getObjectInfoIndex(Thing thing) {
 }
 
 void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) {
-	if (thingToLink == Thing::_thingEndOfList)
+	if (thingToLink == Thing::_endOfList)
 		return;
 
 	uint16 *rawObjPtr = getThingData(thingToLink);
-	*rawObjPtr = Thing::_thingEndOfList.toUint16();
+	*rawObjPtr = Thing::_endOfList.toUint16();
 
 	if (mapX >= 0) {
 		Square *squarePtr = (Square*)&_currMap._data[mapX][mapY];
@@ -1274,7 +1287,7 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map
 	}
 
 	Thing thing = getNextThing(thingInList);
-	while (thing != Thing::_thingEndOfList) {
+	while (thing != Thing::_endOfList) {
 		thing = getNextThing(thing);
 		thingInList = thing;
 	}
@@ -1282,4 +1295,34 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map
 	*rawObjPtr = thingToLink.toUint16();
 }
 
+WeaponInfo* DungeonMan::getWeaponInfo(Thing thing) {
+	Weapon* weapon = (Weapon*)getThingData(thing);
+	return &gWeaponInfo[weapon->getType()];
+}
+
+int16 DungeonMan::getProjectileAspect(Thing thing) {
+	ThingType thingType;
+	int16 projAspOrd;
+	WeaponInfo *weaponInfo;
+
+	if ((thingType == thing.getType()) == kExplosionThingType) {
+		if (thing == Thing::_explFireBall)
+			return -_vm->indexToOrdinal(kProjectileAspectExplosionFireBall);
+		if (thing == Thing::_explSlime)
+			return -_vm->indexToOrdinal(kProjectileAspectExplosionSlime);
+		if (thing == Thing::_explLightningBolt)
+			return -_vm->indexToOrdinal(kProjectileAspectExplosionLightningBolt);
+		if ((thing == Thing::_explPoisonBolt) || (thing == Thing::_explPoisonCloud))
+			return -_vm->indexToOrdinal(kProjectileAspectExplosionPoisonBoltCloud);
+
+		return -_vm->indexToOrdinal(kProjectileAspectExplosionDefault);
+	} else if (thingType == kWeaponThingType) {
+		weaponInfo = getWeaponInfo(thing);
+		if (projAspOrd = weaponInfo->getProjectileAspectOrdinal())
+			return -projAspOrd;
+	}
+
+	return gObjectInfo[getObjectInfoIndex(thing)]._objectAspectIndex;
+}
+
 }
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 9a49fe9..0e17f62 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -671,6 +671,8 @@ public:
 	uint16 getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight
 	int16 getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex
 	void linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY); // @ F0163_DUNGEON_LinkThingToList
+	WeaponInfo *getWeaponInfo(Thing thing); // @ F0158_DUNGEON_GetWeaponInfo
+	int16 getProjectileAspect(Thing thing); // @ F0142_DUNGEON_GetProjectileAspect
 
 	uint32 _rawDunFileDataSize;	 // @ probably NONE
 	byte *_rawDunFileData; // @ ???
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index f26930c..e9abf94 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -632,7 +632,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 
 	for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) {
 		Thing thing = champ->getSlot((ChampionSlot)slotIndex);
-		if (thing != Thing::_thingNone) {
+		if (thing != Thing::_none) {
 			warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList");
 		}
 	}
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 81b53d4..177f9ae 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -658,7 +658,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	for (int i = 0; i < 18; i++)
 		_currMapDoorOrnIndices[i] = 0;
 
-	_inscriptionThing = Thing::_thingNone;
+	_inscriptionThing = Thing::_none;
 	_useByteBoxCoordinates = false;
 }
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 4e3d0d3..b3c3a90 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -45,9 +45,9 @@ Box gBoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
 InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
 	_panelContent = kPanelContentFoodWaterPoisoned;
 	for (uint16 i = 0; i < 8; ++i)
-		_chestSlots[i] = Thing::_thingNone;
-	_openChest = Thing::_thingNone;
-	_openChest = Thing::_thingNone;
+		_chestSlots[i] = Thing::_none;
+	_openChest = Thing::_none;
+	_openChest = Thing::_none;
 }
 
 void InventoryMan::toggleInventory(ChampionIndex championIndex) {
@@ -199,10 +199,10 @@ void InventoryMan::drawPanel() {
 		_panelContent = kPanelContentScroll;
 		break;
 	default:
-		thing = Thing::_thingNone;
+		thing = Thing::_none;
 		break;
 	}
-	if (thing == Thing::_thingNone) {
+	if (thing == Thing::_none) {
 		drawPanelFoodWaterPoisoned();
 	} else {
 		drawPanelObject(thing, false);
@@ -213,20 +213,20 @@ void InventoryMan::closeChest() {
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 
 	bool processFirstChestSlot = true;
-	if (_openChest == Thing::_thingNone)
+	if (_openChest == Thing::_none)
 		return;
 	Container *container = (Container*)dunMan.getThingData(_openChest);
-	_openChest = Thing::_thingNone;
-	container->getSlot() = Thing::_thingEndOfList;
+	_openChest = Thing::_none;
+	container->getSlot() = Thing::_endOfList;
 	Thing prevThing;
 	for (int16 chestSlotIndex = 0; chestSlotIndex < 8; ++chestSlotIndex) {
 		Thing thing = _chestSlots[chestSlotIndex];
-		if (thing != Thing::_thingNone) {
-			_chestSlots[chestSlotIndex] = Thing::_thingNone; // CHANGE8_09_FIX
+		if (thing != Thing::_none) {
+			_chestSlots[chestSlotIndex] = Thing::_none; // CHANGE8_09_FIX
 
 			if (processFirstChestSlot) {
 				processFirstChestSlot = false;
-				*dunMan.getThingData(thing) = Thing::_thingEndOfList.toUint16();
+				*dunMan.getThingData(thing) = Thing::_endOfList.toUint16();
 				container->getSlot() = prevThing = thing;
 			} else {
 				dunMan.linkThingToList(thing, prevThing, kMapXNotOnASquare, 0);
@@ -303,7 +303,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 		return;
 
 	warning("CHANGE8_09_FIX");
-	if (_openChest != Thing::_thingNone)
+	if (_openChest != Thing::_none)
 		closeChest(); // CHANGE8_09_FIX
 
 	_openChest = thingToOpen;
@@ -315,7 +315,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 	int16 chestSlotIndex = 0;
 	Thing thing = chest->getSlot();
 	int16 thingCount = 0;
-	while (thing != Thing::_thingEndOfList) {
+	while (thing != Thing::_endOfList) {
 		warning("CHANGE8_08_FIX");
 		if (++thingCount > 8)
 			break; // CHANGE8_08_FIX, make sure that no more than the first 8 objects in a chest are drawn
@@ -326,7 +326,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 	}
 	while (chestSlotIndex < 8) {
 		objMan.drawIconInSlotBox(chestSlotIndex + kSlotBoxChestFirstSlot, kIconIndiceNone);
-		_chestSlots[chestSlotIndex++] = Thing::_thingNone;
+		_chestSlots[chestSlotIndex++] = Thing::_none;
 	}
 }
 
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 7ac9283..7da701b 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -43,7 +43,7 @@ LoadgameResponse LoadsaveMan::loadgame() {
 	if (newGame) {
 		_vm->_restartGameAllowed = false;
 		cm._partyChampionCount = 0;
-		cm._leaderHandObject = Thing::_thingNone;
+		cm._leaderHandObject = Thing::_none;
 		_vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536);
 	} else {
 		assert(false);
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index d6c09d8..a09a33d 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -96,7 +96,7 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) {
 	byte *bitmapIcon = dm._tmpBitmap;
 	Thing thing = champion.getSlot(kChampionSlotActionHand);
 	IconIndice iconIndex;
-	if (thing == Thing::_thingNone) {
+	if (thing == Thing::_none) {
 		iconIndex = kIconIndiceActionEmptyHand;
 	} else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
 		iconIndex = _vm->_objectMan->getIconIndex(thing);
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 8a833a3..1511146 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -53,7 +53,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 	Thing squareFirstThing;
 	Thing thingBeingProcessed = squareFirstThing = dunMan.getSquareFirstThing(mapX, mapY);
 	ThingType thingType;
-	while (thingBeingProcessed != Thing::_thingEndOfList) {
+	while (thingBeingProcessed != Thing::_endOfList) {
 		thingType = thingBeingProcessed.getType();
 		if (thingType == kSensorThingType) {
 			sensorCountToProcessPerCell[thingBeingProcessed.getCell()]++;
@@ -64,7 +64,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 	}
 	Thing lastProcessedThing = thingBeingProcessed = squareFirstThing;
 
-	while (thingBeingProcessed != Thing::_thingEndOfList) {
+	while (thingBeingProcessed != Thing::_endOfList) {
 		thingType = thingBeingProcessed.getType();
 		if (thingType == kSensorThingType) {
 			cell = thingBeingProcessed.getCell();
@@ -101,7 +101,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 					if (lastProcessedThing == thingBeingProcessed)
 						break;
 					((Sensor*)dunMan.getThingData(lastProcessedThing))->setNextThing(sensor->getNextThing());
-					sensor->setNextThing(Thing::_thingNone);
+					sensor->setNextThing(Thing::_none);
 					thingBeingProcessed = lastProcessedThing;
 				}
 				if (!doNotTriggerSensor && (sensorType == kSensorWallOrnClickWithSpecObjRemovedRotateSensors)) {
@@ -125,7 +125,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 					warning("MISSING CODE: F0273_SENSOR_GetObjectOfTypeInCell");
 					warning(("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand"));
 					warning("MISSING CODE: F0163_DUNGEON_LinkThingToList");
-					leaderHandObject = Thing::_thingNone;
+					leaderHandObject = Thing::_none;
 				}
 				warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect");
 				if ((sensorEffect == kSensorEffHold) && !champMan._leaderEmptyHanded) {
@@ -138,7 +138,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 				if (sensorCountToProcessPerCell[cell])
 					goto T0275058_ProceedToNextThing;
 				Thing thingOnSquare = dunMan.getSquareFirstThing(mapX, mapY);
-				if ((objMan.getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_thingNone))
+				if ((objMan.getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_none))
 					goto T0275058_ProceedToNextThing;
 				warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList");
 				warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand");
@@ -169,12 +169,12 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 					(sensorType == kSensorWallOrnClickWithSpecObjRemovedRotateSensors) ||
 					 (sensorType == kSensorWallOrnClickWithSpecObjRemovedSensor))) {
 
-					*((Thing*)dunMan.getThingData(leaderHandObject)) = Thing::_thingNone;
+					*((Thing*)dunMan.getThingData(leaderHandObject)) = Thing::_none;
 					warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand");
-					leaderHandObject = Thing::_thingNone;
+					leaderHandObject = Thing::_none;
 				} else {
 					warning("MISSING CODE: (leaderHandObject = F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator(sensorData)");
-					if (champMan._leaderEmptyHanded && (sensorType == kSensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_thingNone)) {
+					if (champMan._leaderEmptyHanded && (sensorType == kSensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_none)) {
 						warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand");
 					}
 				}
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index aed1c13..458f3fd 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -122,7 +122,7 @@ void ObjectMan::loadObjectNames() {
 }
 
 IconIndice ObjectMan::getObjectType(Thing thing) {
-	if (thing == Thing::_thingNone)
+	if (thing == Thing::_none)
 		return kIconIndiceNone;
 
 	int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing);


Commit: 5bb19fd2611dd28e6187b4d873de3f754a352b74
    https://github.com/scummvm/scummvm/commit/5bb19fd2611dd28e6187b4d873de3f754a352b74
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add GroupMan, Group, ActiveGroup,  F0196_GROUP_InitializeActiveGroups

Changed paths:
  A engines/dm/group.cpp
  A engines/dm/group.h
    engines/dm/TODOs/methodtree.txt
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/loadsave.cpp
    engines/dm/module.mk



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index 9f09e9d..ec7229b 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -9,6 +9,10 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 		F0158_DUNGEON_GetWeaponInfo // done
 		M66_PROJECTILE_ASPECT_ORDINAL // done
 	F0176_GROUP_GetCreatureOrdinalInCell
+		F0145_DUNGEON_GetGroupCells
+		F0147_DUNGEON_GetGroupDirections
+		GROUP // done 
+		CreatureType
 	G0017_auc_Graphic562_PaletteChanges_NoChanges
 	G0075_apuc_PaletteChanges_Projectile
 	G0077_B_DoNotDrawFluxcagesDuringEndgame
@@ -40,7 +44,7 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 	G0370_ps_Events
 	G0375_ps_ActiveGroups
 	OBJECT_ASPECT
-	GROUP
+	GROUP // done
 	ACTIVE_GROUP
 	CREATURE_INFO
 	CREATURE_ASPECT
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 2d55c5e..1b2edce 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -49,6 +49,7 @@
 #include "inventory.h"
 #include "text.h"
 #include "movesens.h"
+#include "group.h"
 
 namespace DM {
 
@@ -93,7 +94,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_inventoryMan = nullptr;
 	_textMan = nullptr;
 	_movsens = nullptr;
-	
+	_groupMan = nullptr;
 	_stopWaitingForPlayerInput = false;
 	_gameTimeTicking = false;
 	_restartGameAllowed = false;
@@ -122,6 +123,7 @@ DMEngine::~DMEngine() {
 	delete _inventoryMan;
 	delete _textMan;
 	delete _movsens;
+	delete _groupMan;
 
 	// clear debug channels
 	DebugMan.clearAllDebugChannels();
@@ -203,7 +205,8 @@ Common::Error DMEngine::run() {
 	_objectMan = new ObjectMan(this);
 	_inventoryMan = new InventoryMan(this);
 	_textMan = new TextMan(this);
-	_movsens = new MovesensMan(this);
+	_movsens = new MovesensMan(this);		 
+	_groupMan = new GroupMan(this);
 	_displayMan->setUpScreens(320, 200);
 
 	initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 251a0af..5bbeb4f 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -46,6 +46,7 @@ class ObjectMan;
 class InventoryMan;
 class TextMan;
 class MovesensMan;
+class GroupMan;
 
 
 enum direction {
@@ -161,6 +162,7 @@ public:
 	InventoryMan *_inventoryMan;
 	TextMan *_textMan;
 	MovesensMan *_movsens;
+	GroupMan *_groupMan;
 
 	bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput
 	bool _gameTimeTicking; // @ G0301_B_GameTimeTicking
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 12531b6..e513e58 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1305,7 +1305,7 @@ int16 DungeonMan::getProjectileAspect(Thing thing) {
 	int16 projAspOrd;
 	WeaponInfo *weaponInfo;
 
-	if ((thingType == thing.getType()) == kExplosionThingType) {
+	if ((thingType = thing.getType()) == kExplosionThingType) {
 		if (thing == Thing::_explFireBall)
 			return -_vm->indexToOrdinal(kProjectileAspectExplosionFireBall);
 		if (thing == Thing::_explSlime)
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 0e17f62..a4f06ee 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -326,23 +326,6 @@ public:
 	// some macros missing, i got bored
 }; // @ SENSOR
 
-class Group {
-	Thing _nextThing;
-	Thing _possessionID;
-	byte _type;
-	byte _position;
-	uint16 _health[4];
-	uint16 _attributes;
-public:
-	explicit Group(uint16 *rawDat) : _nextThing(rawDat[0]), _possessionID(rawDat[1]), _type(rawDat[2]),
-		_position(rawDat[3]), _attributes(rawDat[8]) {
-		_health[0] = rawDat[4];
-		_health[1] = rawDat[5];
-		_health[2] = rawDat[6];
-		_health[3] = rawDat[7];
-	}
-	Thing getNextThing() { return _nextThing; }
-}; // @ GROUP
 
 enum WeaponType {
 	kWeaponTypeTorch = 2, // @ C02_WEAPON_TORCH
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
new file mode 100644
index 0000000..645d81f
--- /dev/null
+++ b/engines/dm/group.cpp
@@ -0,0 +1,54 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#include "group.h"
+#include "dungeonman.h"
+
+
+
+namespace DM {
+
+
+GroupMan::GroupMan(DMEngine* vm) : _vm(vm) {
+	_activeGroups = nullptr;
+}
+
+GroupMan::~GroupMan() {
+	delete[] _activeGroups;
+}
+
+void GroupMan::initActiveGroups() {
+	if (_vm->_dungeonMan->_messages._newGame)
+		_maxActiveGroupCount = 60;
+	if (_activeGroups)
+		delete[] _activeGroups;
+	_activeGroups = new ActiveGroup[_maxActiveGroupCount];
+	for (uint16 i = 0; i < _maxActiveGroupCount; ++i)
+		_activeGroups[i]._groupThingIndex = -1;
+}
+
+}
diff --git a/engines/dm/group.h b/engines/dm/group.h
new file mode 100644
index 0000000..9e1300c
--- /dev/null
+++ b/engines/dm/group.h
@@ -0,0 +1,94 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+
+#ifndef DM_GROUP_H
+#define DM_GROUP_H
+
+#include "dm.h"
+
+namespace DM {
+
+class ActiveGroup {
+public:
+	int _groupThingIndex;
+	byte _directions;
+	byte _cells;
+	byte _lastMoveTime;
+	byte _delayFleeingFromTarget;
+	byte _targetMapX;
+	byte _targetMapY;
+	byte _priorMapX;
+	byte _priorMapY;
+	byte _homeMapX;
+	byte _homeMapY;
+	byte _aspect[4];
+}; // @ ACTIVE_GROUP
+
+
+class Group {
+public:
+	Thing _nextThing;
+	Thing _slot;
+	byte _type;
+	byte _cells;
+	uint16 _health[4];
+private:
+	uint16 _flags;
+public:
+	explicit Group(uint16 *rawDat) : _nextThing(rawDat[0]), _slot(rawDat[1]), _type(rawDat[2]),
+		_cells(rawDat[3]), _flags(rawDat[8]) {
+		_health[0] = rawDat[4];
+		_health[1] = rawDat[5];
+		_health[2] = rawDat[6];
+		_health[3] = rawDat[7];
+	}
+
+	byte &getActiveGroupIndex() { return _cells; }
+
+	uint16 getBehaviour() { return _flags & 0xF; }
+	uint16 getCount() { return (_flags >> 5) & 0x3; }
+	direction getDir() { return (direction)((_flags >> 8) & 0x3); }
+	uint16 getDoNotDiscard() { return (_flags >> 10) & 0x1; }
+}; // @ GROUP
+
+
+class GroupMan {
+	DMEngine *_vm;
+public:
+	uint16 _maxActiveGroupCount = 60; // @ G0376_ui_MaximumActiveGroupCount
+	ActiveGroup *_activeGroups; // @ G0375_ps_ActiveGroups
+	GroupMan(DMEngine *vm);
+	~GroupMan();
+	void initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups
+};
+
+
+
+}
+
+#endif
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 7da701b..583762c 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -28,6 +28,7 @@
 #include "loadsave.h"
 #include "dungeonman.h"
 #include "champion.h"
+#include "group.h"
 
 
 
@@ -53,7 +54,8 @@ LoadgameResponse LoadsaveMan::loadgame() {
 
 
 	if (newGame) {
-		warning("MISSING CODE: Timline init, Group init");
+		warning("MISSING CODE: Timline init");
+		_vm->_groupMan->initActiveGroups();
 	} else {
 		assert(false);
 		// MISSING CODE: load game
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index 28bcaa2..721eb43 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -36,6 +36,7 @@ MODULE_OBJS := \
 	dungeonman.o \
 	eventman.o \
 	gfx.o \
+	group.o \
 	inventory.o \
 	loadsave.o \
 	menus.o \


Commit: 4f394fc301ed9ae087e6cabbf54607ea89629ffa
    https://github.com/scummvm/scummvm/commit/4f394fc301ed9ae087e6cabbf54607ea89629ffa
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0145_DUNGEON_GetGroupCells

Changed paths:
    engines/dm/group.cpp
    engines/dm/group.h



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 645d81f..10edf01 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -27,6 +27,7 @@
 
 #include "group.h"
 #include "dungeonman.h"
+#include "champion.h"
 
 
 
@@ -51,4 +52,11 @@ void GroupMan::initActiveGroups() {
 		_activeGroups[i]._groupThingIndex = -1;
 }
 
+uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) {
+	byte cells;
+	cells = group->_cells;
+	if (mapIndex == _vm->_dungeonMan->_currMap._currPartyMapIndex)
+		cells = _activeGroups[cells]._cells;
+	return cells;
+}
 }
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 9e1300c..3cd286a 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -85,6 +85,7 @@ public:
 	GroupMan(DMEngine *vm);
 	~GroupMan();
 	void initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups
+	uint16 getGroupCells(Group *group, int16 mapIndex); // @ F0145_DUNGEON_GetGroupCells
 };
 
 


Commit: cd7363f8de93001208f34d43bcb4f656b8514110
    https://github.com/scummvm/scummvm/commit/cd7363f8de93001208f34d43bcb4f656b8514110
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0147_DUNGEON_GetGroupDirections

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/group.cpp
    engines/dm/group.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index ec7229b..2b9d6bd 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -9,7 +9,7 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 		F0158_DUNGEON_GetWeaponInfo // done
 		M66_PROJECTILE_ASPECT_ORDINAL // done
 	F0176_GROUP_GetCreatureOrdinalInCell
-		F0145_DUNGEON_GetGroupCells
+		F0145_DUNGEON_GetGroupCells // done
 		F0147_DUNGEON_GetGroupDirections
 		GROUP // done 
 		CreatureType
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 10edf01..4a1a7e1 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -59,4 +59,13 @@ uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) {
 		cells = _activeGroups[cells]._cells;
 	return cells;
 }
+
+byte gGroupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_GroupDirections
+
+uint16 GroupMan::getGroupDirections(Group* group, int16 mapIndex) {
+	if (mapIndex == _vm->_dungeonMan->_currMap._currPartyMapIndex)
+		return _activeGroups[group->getActiveGroupIndex()]._directions;
+
+	return gGroupDirections[group->getDir()];
+}
 }
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 3cd286a..0ad9cbb 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -36,7 +36,7 @@ namespace DM {
 class ActiveGroup {
 public:
 	int _groupThingIndex;
-	byte _directions;
+	direction _directions;
 	byte _cells;
 	byte _lastMoveTime;
 	byte _delayFleeingFromTarget;
@@ -86,6 +86,7 @@ public:
 	~GroupMan();
 	void initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups
 	uint16 getGroupCells(Group *group, int16 mapIndex); // @ F0145_DUNGEON_GetGroupCells
+	uint16 getGroupDirections(Group *group, int16 mapIndex); // @ F0147_DUNGEON_GetGroupDirections
 };
 
 


Commit: 6d2d839d2721917e2c512511da544a07a9382322
    https://github.com/scummvm/scummvm/commit/6d2d839d2721917e2c512511da544a07a9382322
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add creature masks/types, F0176_GROUP_GetCreatureOrdinalInCell

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/group.cpp
    engines/dm/group.h



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index 2b9d6bd..894ea89 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -8,11 +8,11 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 	F0142_DUNGEON_GetProjectileAspect // done 
 		F0158_DUNGEON_GetWeaponInfo // done
 		M66_PROJECTILE_ASPECT_ORDINAL // done
-	F0176_GROUP_GetCreatureOrdinalInCell
+	F0176_GROUP_GetCreatureOrdinalInCell // done
 		F0145_DUNGEON_GetGroupCells // done
-		F0147_DUNGEON_GetGroupDirections
+		F0147_DUNGEON_GetGroupDirections // done
 		GROUP // done 
-		CreatureType
+		CreatureType // done
 	G0017_auc_Graphic562_PaletteChanges_NoChanges
 	G0075_apuc_PaletteChanges_Projectile
 	G0077_B_DoNotDrawFluxcagesDuringEndgame
@@ -46,8 +46,8 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 	OBJECT_ASPECT
 	GROUP // done
 	ACTIVE_GROUP
-	CREATURE_INFO
-	CREATURE_ASPECT
+	CREATURE_INFO // done
+	CREATURE_ASPECT // done
 	PROJECTILE
 	EXPLOSION
 	FIELD_ASPECT // done
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 1b2edce..924988d 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -56,6 +56,15 @@ namespace DM {
 void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
 void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); }
 direction returnOppositeDir(direction dir) { return (direction)((dir + 2) & 3); }
+
+uint16 returnPrevVal(uint16 val) {
+	return (direction)((val + 3) & 3);
+}
+
+uint16 returnNextVal(uint16 val) {
+	return (val + 1) & 0x3;
+}
+
 bool isOrientedWestEast(direction dir) { return dir & 1; }
 
 uint16 getFlag(uint16 val, uint16 mask) {
@@ -205,7 +214,7 @@ Common::Error DMEngine::run() {
 	_objectMan = new ObjectMan(this);
 	_inventoryMan = new InventoryMan(this);
 	_textMan = new TextMan(this);
-	_movsens = new MovesensMan(this);		 
+	_movsens = new MovesensMan(this);
 	_groupMan = new GroupMan(this);
 	_displayMan->setUpScreens(320, 200);
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 5bbeb4f..b0d0631 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -58,8 +58,10 @@ enum direction {
 
 void turnDirRight(direction &dir);
 void turnDirLeft(direction &dir);
-direction returnOppositeDir(direction dir);
-bool isOrientedWestEast(direction dir);
+direction returnOppositeDir(direction dir);	// @ M18_OPPOSITE
+uint16 returnPrevVal(uint16 val); // @ M19_PREVIOUS
+uint16 returnNextVal(uint16 val); // @ M17_NEXT
+bool isOrientedWestEast(direction dir);	// @ M16_IS_ORIENTED_WEST_EAST
 
 
 uint16 getFlag(uint16 val, uint16 mask);
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index a4f06ee..ec04aa8 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -177,6 +177,8 @@ enum SquareAspectIndice {
 	kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS          
 };
 
+               
+
 
 struct CreatureInfo {
 	byte _creatureAspectIndex;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 177f9ae..67604f9 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -816,23 +816,23 @@ void DisplayMan::loadGraphics() {
 		int16 creatureFrontBitmapD2PixelCount;
 		_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2);
 
-		if (getFlag(creatureGraphicInfo, kCreatureInfoMaskSide)) {
+		if (getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskSide)) {
 			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale16_D3);
 			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale20_D2);
 		}
 
-		if (getFlag(creatureGraphicInfo, kCreatureInfoMaskBack)) {
+		if (getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskBack)) {
 			_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount;
 			_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount;
 		}
 
-		if (getFlag(creatureGraphicInfo, kCreatureInfoMaskAttack)) {
+		if (getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskAttack)) {
 			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, kScale16_D3);
 			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, kScale20_D2);
 		}
 
 		int16 additionalFronGraphicCount;
-		if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, kCreatureInfoMaskAdditional)) {
+		if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskAdditional)) {
 			do {
 				_derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront;
 				_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3);
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 2df0ac0..3d5d46e 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -57,15 +57,15 @@ namespace DM {
 #define kExplosionAspectSmoke 3 // @ C3_EXPLOSION_ASPECT_SMOKE 
 
 /* Creature info GraphicInfo */
-#define kCreatureInfoMaskAdditional 0x0003 // @ MASK0x0003_ADDITIONAL                        
-#define kCreatureInfoMaskFlipNonAttack 0x0004 // @ MASK0x0004_FLIP_NON_ATTACK                  
-#define kCreatureInfoMaskSide 0x0008 // @ MASK0x0008_SIDE                             
-#define kCreatureInfoMaskBack 0x0010 // @ MASK0x0010_BACK                             
-#define kCreatureInfoMaskAttack 0x0020 // @ MASK0x0020_ATTACK                           
-#define kCreatureInfoMaskSpecialD2Front 0x0080 // @ MASK0x0080_SPECIAL_D2_FRONT                                                                               
-#define kCreatureInfoMaskSpecialD2FrontIsFlipped 0x0100 // @ MASK0x0100_SPECIAL_D2_FRONT_IS_FLIPPED_FRONT 
-#define kCreatureInfoMaskFlipAttack 0x0200 // @ MASK0x0200_FLIP_ATTACK                      
-#define kCreatureInfoMaskFlipDuringAttack 0x0400 // @ MASK0x0400_FLIP_DURING_ATTACK               
+#define kCreatureInfoGraphicMaskAdditional 0x0003 // @ MASK0x0003_ADDITIONAL                        
+#define kCreatureInfoGraphicMaskFlipNonAttack 0x0004 // @ MASK0x0004_FLIP_NON_ATTACK                  
+#define kCreatureInfoGraphicMaskSide 0x0008 // @ MASK0x0008_SIDE                             
+#define kCreatureInfoGraphicMaskBack 0x0010 // @ MASK0x0010_BACK                             
+#define kCreatureInfoGraphicMaskAttack 0x0020 // @ MASK0x0020_ATTACK                           
+#define kCreatureInfoGraphicMaskSpecialD2Front 0x0080 // @ MASK0x0080_SPECIAL_D2_FRONT                                                                               
+#define kCreatureInfoGraphicMaskSpecialD2FrontIsFlipped 0x0100 // @ MASK0x0100_SPECIAL_D2_FRONT_IS_FLIPPED_FRONT 
+#define kCreatureInfoGraphicMaskFlipAttack 0x0200 // @ MASK0x0200_FLIP_ATTACK                      
+#define kCreatureInfoGraphicMaskFlipDuringAttack 0x0400 // @ MASK0x0400_FLIP_DURING_ATTACK               
 
 class ExplosionAspect {
 public:
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 4a1a7e1..b224dff 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -68,4 +68,33 @@ uint16 GroupMan::getGroupDirections(Group* group, int16 mapIndex) {
 
 	return gGroupDirections[group->getDir()];
 }
+
+int16 GroupMan::getCreatureOrdinalInCell(Group* group, uint16 cell) {
+	uint16 currMapIndex = _vm->_dungeonMan->_currMap._index;
+	byte groupCells = getGroupCells(group, currMapIndex);
+	if (groupCells == kCreatureTypeSingleCenteredCreature)
+		return _vm->indexToOrdinal(0);
+
+	byte creatureIndex = group->getCount();
+	if (getFlag(gCreatureInfo[group->_type]._attributes, kMaskCreatureInfo_size) == kMaskCreatureSizeHalf) {
+		if ((getGroupDirections(group, currMapIndex) & 1) == (cell & 1))
+			cell = returnPrevVal(cell);
+
+		do {
+			byte creatureCell = getCreatureValue(groupCells, creatureIndex);
+			if (creatureCell == cell || creatureCell == returnNextVal(cell))
+				return _vm->indexToOrdinal(creatureIndex);
+		} while (creatureIndex--);
+	} else {
+		do {
+			if (getCreatureValue(groupCells, creatureIndex) == cell)
+				return _vm->indexToOrdinal(creatureIndex);
+		} while (creatureIndex--);
+	}
+	return 0;
+}
+
+uint16 GroupMan::getCreatureValue(uint16 groupVal, uint16 creatureIndex) {
+	return (groupVal >> (creatureIndex << 1)) & 0x3;
+}
 }
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 0ad9cbb..49ec009 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -33,6 +33,55 @@
 
 namespace DM {
 
+/* Creature types */
+enum CreatureType {
+	kCreatureTypeGiantScorpionScorpion = 0, // @ C00_CREATURE_GIANT_SCORPION_SCORPION     
+	kCreatureTypeSwampSlimeSlime = 1, // @ C01_CREATURE_SWAMP_SLIME_SLIME_DEVIL     
+	kCreatureTypeGiggler = 2, // @ C02_CREATURE_GIGGLER                     
+	kCreatureTypeWizardEyeFlyingEye = 3, // @ C03_CREATURE_WIZARD_EYE_FLYING_EYE       
+	kCreatureTypePainRatHellHound = 4, // @ C04_CREATURE_PAIN_RAT_HELLHOUND          
+	kCreatureTypeRuster = 5, // @ C05_CREATURE_RUSTER                      
+	kCreatureTypeScreamer = 6, // @ C06_CREATURE_SCREAMER                    
+	kCreatureTypeRockpile = 7, // @ C07_CREATURE_ROCK_ROCKPILE               
+	kCreatureTypeGhostRive = 8, // @ C08_CREATURE_GHOST_RIVE                  
+	kCreatureTypeStoneGolem = 9, // @ C09_CREATURE_STONE_GOLEM                 
+	kCreatureTypeMummy = 10, // @ C10_CREATURE_MUMMY                      
+	kCreatureTypeBlackFlame = 11, // @ C11_CREATURE_BLACK_FLAME                
+	kCreatureTypeSkeleton = 12, // @ C12_CREATURE_SKELETON                   
+	kCreatureTypeCouatl = 13, // @ C13_CREATURE_COUATL                     
+	kCreatureTypeVexirk = 14, // @ C14_CREATURE_VEXIRK                     
+	kCreatureTypeMagnetaWormWorm = 15, // @ C15_CREATURE_MAGENTA_WORM_WORM          
+	kCreatureTypeTrolinAntman = 16, // @ C16_CREATURE_TROLIN_ANTMAN              
+	kCreatureTypeGiantWaspMuncher = 17, // @ C17_CREATURE_GIANT_WASP_MUNCHER         
+	kCreatureTypeAnimatedArmourDethKnight = 18, // @ C18_CREATURE_ANIMATED_ARMOUR_DETH_KNIGHT
+	kCreatureTypeMaterializerZytaz = 19, // @ C19_CREATURE_MATERIALIZER_ZYTAZ         
+	kCreatureTypeWaterElemental = 20, // @ C20_CREATURE_WATER_ELEMENTAL            
+	kCreatureTypeOitu = 21, // @ C21_CREATURE_OITU                       
+	kCreatureTypeDemon = 22, // @ C22_CREATURE_DEMON                      
+	kCreatureTypeLordChaos = 23, // @ C23_CREATURE_LORD_CHAOS                 
+	kCreatureTypeRedDragon = 24, // @ C24_CREATURE_RED_DRAGON                 
+	kCreatureTypeLordOrder = 25, // @ C25_CREATURE_LORD_ORDER                 
+	kCreatureTypeGreyLord = 26, // @ C26_CREATURE_GREY_LORD                  
+	kCreatureTypeSingleCenteredCreature = 255 // @ C255_SINGLE_CENTERED_CREATURE
+};
+
+#define kMaskCreatureSizeQuarter 0 // @ C0_SIZE_QUARTER_SQUARE
+#define kMaskCreatureSizeHalf 1 // @ C1_SIZE_HALF_SQUARE   
+#define kMaskCreatureSizeFull 2 // @ C2_SIZE_FULL_SQUARE   
+
+#define kMaskCreatureInfo_size 0x0003 // @ MASK0x0003_SIZE                     
+#define kMaskCreatureInfo_sideAttack 0x0004 // @ MASK0x0004_SIDE_ATTACK              
+#define kMaskCreatureInfo_preferBackRow 0x0008 // @ MASK0x0008_PREFER_BACK_ROW          
+#define kMaskCreatureInfo_attackAnyChamp 0x0010 // @ MASK0x0010_ATTACK_ANY_CHAMPION      
+#define kMaskCreatureInfo_levitation 0x0020 // @ MASK0x0020_LEVITATION               
+#define kMaskCreatureInfo_nonMaterial 0x0040 // @ MASK0x0040_NON_MATERIAL             
+#define kMaskCreatureInfo_dropFixedPoss 0x0200 // @ MASK0x0200_DROP_FIXED_POSSESSIONS   
+#define kMaskCreatureInfo_keepThrownSharpWeapon 0x0400 // @ MASK0x0400_KEEP_THROWN_SHARP_WEAPONS
+#define kMaskCreatureInfo_seeInvisible 0x0800 // @ MASK0x0800_SEE_INVISIBLE            
+#define kMaskCreatureInfo_nightVision 0x1000 // @ MASK0x1000_NIGHT_VISION             
+#define kMaskCreatureInfo_archenemy 0x2000 // @ MASK0x2000_ARCHENEMY                
+#define kMaskCreatureInfo_magicmap 0x4000 // @ MASK0x4000_MAGICMAP  
+
 class ActiveGroup {
 public:
 	int _groupThingIndex;
@@ -87,6 +136,8 @@ public:
 	void initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups
 	uint16 getGroupCells(Group *group, int16 mapIndex); // @ F0145_DUNGEON_GetGroupCells
 	uint16 getGroupDirections(Group *group, int16 mapIndex); // @ F0147_DUNGEON_GetGroupDirections
+	int16 getCreatureOrdinalInCell(Group *group, uint16 cell); // @ F0176_GROUP_GetCreatureOrdinalInCell
+	uint16 getCreatureValue(uint16 groupVal, uint16 creatureIndex); // @ M50_CREATURE_VALUE
 };
 
 


Commit: d312ac086d0a1cd19c784e1fd7752652f8896ad8
    https://github.com/scummvm/scummvm/commit/d312ac086d0a1cd19c784e1fd7752652f8896ad8
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add dependencies for F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF

Changed paths:
  A engines/dm/timeline.cpp
  A engines/dm/timeline.h
    engines/dm/TODOs/methodtree.txt
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/loadsave.cpp
    engines/dm/module.mk



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index 894ea89..f790d50 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -12,45 +12,22 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 		F0145_DUNGEON_GetGroupCells // done
 		F0147_DUNGEON_GetGroupDirections // done
 		GROUP // done 
-		CreatureType // done
-	G0017_auc_Graphic562_PaletteChanges_NoChanges
-	G0075_apuc_PaletteChanges_Projectile
-	G0077_B_DoNotDrawFluxcagesDuringEndgame
-	G0105_s_Graphic558_Box_ExplosionPattern_D0C
-	G0163_as_Graphic558_Frame_Walls
-	G0188_as_Graphic558_FieldAspects
-	G0209_as_Graphic558_ObjectAspects
-	G0210_as_Graphic558_ProjectileAspects
-	G0212_auc_Graphic558_PaletteChanges_Smoke
-	G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3
-	G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2
-	G0215_auc_Graphic558_ProjectileScales
-	G0216_auc_Graphic558_ExplosionBaseScales
-	G0217_aauc_Graphic558_ObjectPileShiftSetIndices
-	G0218_aaaauc_Graphic558_ObjectCoordinateSets
-	G0219_as_Graphic558_CreatureAspects
-	G0221_auc_Graphic558_PaletteChanges_Creature_D3
-	G0222_auc_Graphic558_PaletteChanges_Creature_D2
-	G0223_aac_Graphic558_ShiftSets
-	G0224_aaaauc_Graphic558_CreatureCoordinateSets
-	G0225_aai_Graphic558_CenteredExplosionCoordinates
-	G0226_aaai_Graphic558_ExplosionCoordinates
-	G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates
-	G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates
-	G0237_as_Graphic559_ObjectInfo
-	G0243_as_Graphic559_CreatureInfo
-	G0291_aauc_DungeonViewClickableBoxes
-	G0292_aT_PileTopObject
-	G0370_ps_Events
-	G0375_ps_ActiveGroups
-	OBJECT_ASPECT
-	GROUP // done
-	ACTIVE_GROUP
-	CREATURE_INFO // done
-	CREATURE_ASPECT // done
-	PROJECTILE
-	EXPLOSION
-	FIELD_ASPECT // done
+		CreatureType // done 
+	G0077_B_DoNotDrawFluxcagesDuringEndgame // done
+	G0105_s_Graphic558_Box_ExplosionPattern_D0C // one
+	G0188_as_Graphic558_FieldAspects // done
+	G0216_auc_Graphic558_ExplosionBaseScales // done
+	G0217_aauc_Graphic558_ObjectPileShiftSetIndices // done 
+	G0218_aaaauc_Graphic558_ObjectCoordinateSets // done 
+	G0223_aac_Graphic558_ShiftSets // done
+	G0224_aaaauc_Graphic558_CreatureCoordinateSets // done 
+	G0225_aai_Graphic558_CenteredExplosionCoordinates // done
+	G0226_aaai_Graphic558_ExplosionCoordinates // done
+	G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates // done
+	G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates // done
+	G0292_aT_PileTopObject // done
+	G0370_ps_Events // done 
+
 
 
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 924988d..66a1125 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -50,6 +50,7 @@
 #include "text.h"
 #include "movesens.h"
 #include "group.h"
+#include "timeline.h"
 
 namespace DM {
 
@@ -104,6 +105,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_textMan = nullptr;
 	_movsens = nullptr;
 	_groupMan = nullptr;
+	_timeline = nullptr;
 	_stopWaitingForPlayerInput = false;
 	_gameTimeTicking = false;
 	_restartGameAllowed = false;
@@ -133,6 +135,7 @@ DMEngine::~DMEngine() {
 	delete _textMan;
 	delete _movsens;
 	delete _groupMan;
+	delete _timeline;
 
 	// clear debug channels
 	DebugMan.clearAllDebugChannels();
@@ -216,6 +219,7 @@ Common::Error DMEngine::run() {
 	_textMan = new TextMan(this);
 	_movsens = new MovesensMan(this);
 	_groupMan = new GroupMan(this);
+	_timeline = new Timeline(this);
 	_displayMan->setUpScreens(320, 200);
 
 	initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index b0d0631..814b89d 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -47,6 +47,7 @@ class InventoryMan;
 class TextMan;
 class MovesensMan;
 class GroupMan;
+class Timeline;
 
 
 enum direction {
@@ -165,6 +166,7 @@ public:
 	TextMan *_textMan;
 	MovesensMan *_movsens;
 	GroupMan *_groupMan;
+	Timeline *_timeline;
 
 	bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput
 	bool _gameTimeTicking; // @ G0301_B_GameTimeTicking
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index e513e58..8d5c99b 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -29,6 +29,7 @@
 #include "common/memstream.h"
 
 #include "dungeonman.h"
+#include "timeline.h"
 
 
 
@@ -369,7 +370,6 @@ void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, in
 
 DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) {
 	_dunData._columCount = 0;
-	_dunData._eventMaximumCount = 0;
 
 	_dunData._mapsFirstColumnIndex = nullptr;
 	_dunData._columnsCumulativeSquareThingCount = nullptr;
@@ -652,7 +652,7 @@ void DungeonMan::loadDungeonFile() {
 
 	// TODO: ??? what this
 	if (_messages._newGame)
-		_dunData._eventMaximumCount = 100;
+		_vm->_timeline->_eventMaxCount = 100;
 
 	// load things
 	for (uint16 thingType = kDoorThingType; thingType < kThingTypeTotal; ++thingType) {
@@ -699,7 +699,7 @@ void DungeonMan::loadDungeonFile() {
 
 		if (_messages._newGame) {
 			if ((thingType == kGroupThingType) || thingType >= kProjectileThingType)
-				_dunData._eventMaximumCount += _fileHeader._thingCounts[thingType];
+				_vm->_timeline->_eventMaxCount += _fileHeader._thingCounts[thingType];
 			for (uint16 i = 0; i < gAdditionalThingCounts[thingType]; ++i) {
 				_dunData._thingsData[thingType][thingCount + i][0] = Thing::_none.toUint16();
 			}
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index ec04aa8..f3faafd 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -589,9 +589,6 @@ struct DungeonData {
 	uint16 **_thingsData[16]; // @ G0284_apuc_ThingData
 
 	byte ***_mapData; // @ G0279_pppuc_DungeonMapData
-
-	// TODO: ??? is this doing here
-	uint16 _eventMaximumCount; // @ G0369_ui_EventMaximumCount
 }; // @ AGGREGATE
 
 struct CurrMapData {
@@ -676,6 +673,7 @@ public:
 	bool _isFacingViAltar; // @ G0287_B_FacingViAltar
 	bool _isFacingFountain; // @ G0288_B_FacingFountain
 	ElementType _squareAheadElement; // @ G0285_i_SquareAheadElement 
+	Thing _pileTopObject[5]; // @ G0292_aT_PileTopObject
 };
 
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 67604f9..4506f3e 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -37,6 +37,21 @@
 
 namespace DM {
 
+FieldAspect gFieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects
+								  /* { NativeBitmapRelativeIndex, BaseStartUnitIndex, Transparent color, Mask, ByteWidth, Height, X, BitPlaneWordCount } */
+	FieldAspect(0, 63, 0x8A, 0xFF,  0,   0,  0, 64),   /* D3C */
+	FieldAspect(0, 63, 0x0A, 0x80, 48,  51, 11, 64),   /* D3L */
+	FieldAspect(0, 63, 0x0A, 0x00, 48,  51,  0, 64),   /* D3R */
+	FieldAspect(0, 60, 0x8A, 0xFF,  0,   0,  0, 64),   /* D2C */
+	FieldAspect(0, 63, 0x0A, 0x81, 40,  71,  5, 64),   /* D2L */
+	FieldAspect(0, 63, 0x0A, 0x01, 40,  71,  0, 64),   /* D2R */
+	FieldAspect(0, 61, 0x8A, 0xFF,  0,   0,  0, 64),   /* D1C */
+	FieldAspect(0, 63, 0x0A, 0x82, 32, 111,  0, 64),   /* D1L */
+	FieldAspect(0, 63, 0x0A, 0x02, 32, 111,  0, 64),   /* D1R */
+	FieldAspect(0, 59, 0x8A, 0xFF,  0,   0,  0, 64),   /* D0C */
+	FieldAspect(0, 63, 0x0A, 0x83, 16, 136,  0, 64),   /* D0L */
+	FieldAspect(0, 63, 0x0A, 0x03, 16, 136,  0, 64)}; /* D0R */
+
 Box gBoxMovementArrows = Box(224, 319, 124, 168);
 
 byte gPalChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke
@@ -1790,6 +1805,167 @@ int16 DisplayMan::getScaledDimension(int16 dimension, int16 scale) {
 	return (dimension * scale + scale / 2) / 32;
 }
 
+/* This is the full dungeon view */
+Box gBoxExplosionPattern_D0C = Box(0, 223, 0, 135); // @ G0105_s_Graphic558_Box_ExplosionPattern_D0C 
+
+byte gExplosionBaseScales[5] = { // @ G0216_auc_Graphic558_ExplosionBaseScales
+	10,/* D4 */   16,/* D3 */   23,/* D2 */   32,/* D1 */   32};/* D0 */
+
+byte gObjectPileShiftSetIndices[16][2] = { // @ G0217_aauc_Graphic558_ObjectPileShiftSetIndices
+	/* { X shift index, Y shift index } */
+	{2, 5},
+	{0, 6},
+	{5, 7},
+	{3, 0},
+	{7, 1},
+	{1, 2},
+	{6, 3},
+	{3, 3},
+	{5, 5},
+	{2, 6},
+	{7, 7},
+	{1, 0},
+	{3, 1},
+	{6, 2},
+	{1, 3},
+	{5, 3}}; /* 16 pairs of X and Y shift values */
+
+byte gObjectCoordinateSets[3][10][5][2] = { // @ G0218_aaaauc_Graphic558_ObjectCoordinateSets
+	/* { {X, Y }, {X, Y }, {X, Y }, {X, Y }, {X, Y } } */
+	{{{0,   0},{0,   0},{125,  72},{95,  72},{112, 64}},     /* D3C */
+	{{0,   0},{0,   0},{62,  72},{25,  72},{24, 64}},     /* D3L */
+	{{0,   0},{0,   0},{200,  72},{162,  72},{194, 64}},     /* D3R */
+	{{92,  78},{132,  78},{136,  86},{88,  86},{112, 74}},     /* D2C */
+	{{10,  78},{53,  78},{41,  86},{0,   0},{3, 74}},     /* D2L */
+	{{171,  78},{218,  78},{0,   0},{183,  86},{219, 74}},     /* D2R */
+	{{83,  96},{141,  96},{148, 111},{76, 111},{112, 94}},     /* D1C */
+	{{0,   0},{26,  96},{5, 111},{0,   0},{0,  0}},     /* D1L */
+	{{197,  96},{0,   0},{0,   0},{220, 111},{0,  0}},     /* D1R */
+	{{66, 131},{158, 131},{0,   0},{0,   0},{0,  0}}},   /* D0C */
+	{{{0,   0},{0,   0},{125,  72},{95,  72},{112, 63}},     /* D3C */
+	{{0,   0},{0,   0},{62,  72},{25,  72},{24, 63}},     /* D3L */
+	{{0,   0},{0,   0},{200,  72},{162,  72},{194, 63}},     /* D3R */
+	{{92,  78},{132,  78},{136,  86},{88,  86},{112, 73}},     /* D2C */
+	{{10,  78},{53,  78},{41,  86},{0,   0},{3, 73}},     /* D2L */
+	{{171,  78},{218,  78},{0,   0},{183,  86},{219, 73}},     /* D2R */
+	{{83,  96},{141,  96},{148, 111},{76, 111},{112, 89}},     /* D1C */
+	{{0,   0},{26,  96},{5, 111},{0,   0},{0,  0}},     /* D1L */
+	{{197,  96},{0,   0},{0,   0},{220, 111},{0,  0}},     /* D1R */
+	{{66, 131},{158, 131},{0,   0},{0,   0},{0,  0}}},   /* D0C */
+	{{{0,   0},{0,   0},{125,  75},{95,  75},{112, 65}},     /* D3C */
+	{{0,   0},{0,   0},{62,  75},{25,  75},{24, 65}},     /* D3L */
+	{{0,   0},{0,   0},{200,  75},{162,  75},{194, 65}},     /* D3R */
+	{{92,  81},{132,  81},{136,  88},{88,  88},{112, 76}},     /* D2C */
+	{{10,  81},{53,  81},{41,  88},{0,   0},{3, 76}},     /* D2L */
+	{{171,  81},{218,  81},{0,  0},{183,  88},{219, 76}},     /* D2R */
+	{{83,  98},{141,  98},{148, 115},{76, 115},{112, 98}},     /* D1C */
+	{{0,   0},{26,  98},{5, 115},{0,   0},{0,  0}},     /* D1L */
+	{{197,  98},{0,   0},{0,   0},{220, 115},{0,  0}},     /* D1R */
+	{{66, 135},{158, 135},{0,   0},{0,   0},{0,  0}}}}; /* D0C */
+
+
+int16 gShiftSets[3][8] = { // @ G0223_aac_Graphic558_ShiftSets
+	{0, 1, 2, 3, 0, -3, -2, -1},   /* D0 Back or D1 Front */
+	{0, 1, 1, 2, 0, -2, -1, -1},   /* D1 Back or D2 Front */
+	{0, 1, 1, 1, 0, -1, -1, -1}}; /* D2 Back or D3 Front */
+
+byte gCreatureCoordinateSets[3][11][5][2] = { // @ G0224_aaaauc_Graphic558_CreatureCoordinateSets
+	/* { { X, Y }, { X, Y }, { X, Y }, { X, Y }, { X, Y } } */
+	{{{95,  70},{127,  70},{129,  75},{93,  75},{111,  72}},     /* D3C */
+	{{131,  70},{163,  70},{158,  75},{120,  75},{145,  72}},     /* D3L */
+	{{59,  70},{91,  70},{107,  75},{66,  75},{79,  72}},     /* D3R */
+	{{92,  81},{131,  81},{132,  90},{91,  90},{111,  85}},     /* D2C */
+	{{99,  81},{146,  81},{135,  90},{80,  90},{120,  85}},     /* D2L */
+	{{77,  81},{124,  81},{143,  90},{89,  90},{105,  85}},     /* D2R */
+	{{83, 103},{141, 103},{148, 119},{76, 119},{109, 111}},     /* D1C */
+	{{46, 103},{118, 103},{101, 119},{0,   0},{79, 111}},     /* D1L */
+	{{107, 103},{177, 103},{0,   0},{123, 119},{144, 111}},     /* D1R */
+	{{0,   0},{67, 135},{0,   0},{0,   0},{0,   0}},     /* D0L */
+	{{156, 135},{0,   0},{0,   0},{0,   0},{0,   0}}},   /* D0R */
+	{{{94,  75},{128,  75},{111,  70},{111,  72},{111,  75}},     /* D3C */
+	{{120,  75},{158,  75},{149,  70},{145,  72},{150,  75}},     /* D3L */
+	{{66,  75},{104,  75},{75,  70},{79,  72},{73,  75}},     /* D3R */
+	{{91,  90},{132,  90},{111,  83},{111,  85},{111,  90}},     /* D2C */
+	{{80,  90},{135,  90},{125,  83},{120,  85},{125,  90}},     /* D2L */
+	{{89,  90},{143,  90},{99,  83},{105,  85},{98,  90}},     /* D2R */
+	{{81, 119},{142, 119},{111, 105},{111, 111},{111, 119}},     /* D1C */
+	{{0,   0},{101, 119},{84, 105},{70, 111},{77, 119}},     /* D1L */
+	{{123, 119},{0,   0},{139, 105},{153, 111},{146, 119}},     /* D1R */
+	{{0,   0},{83, 130},{57, 121},{47, 126},{57, 130}},     /* D0L */
+	{{140, 130},{0,   0},{166, 121},{176, 126},{166, 130}}},   /* D0R */
+	{{{95,  59},{127,  59},{129,  61},{93,  61},{111,  60}},     /* D3C */
+	{{131,  59},{163,  59},{158,  61},{120,  61},{145,  60}},     /* D3L */
+	{{59,  59},{91,  59},{107,  61},{66,  61},{79,  60}},     /* D3R */
+	{{92,  65},{131,  65},{132,  67},{91,  67},{111,  66}},     /* D2C */
+	{{99,  65},{146,  65},{135,  67},{80,  67},{120,  66}},     /* D2L */
+	{{77,  65},{124,  65},{143,  67},{89,  67},{105,  66}},     /* D2R */
+	{{83,  79},{141,  79},{148,  85},{76,  85},{111,  81}},     /* D1C */
+	{{46,  79},{118,  79},{101,  85},{0,   0},{79,  81}},     /* D1L */
+	{{107,  79},{177,  79},{0,   0},{123,  85},{144,  81}},     /* D1R */
+	{{0,   0},{67,  96},{0,   0},{0,   0},{0,   0}},     /* D0L */
+	{{156,  96},{0,   0},{0,   0},{0,   0},{0,   0}}}}; /* D0R */
+
+int16 gExplosionCoordinates[15][2][2] = { // @ G0226_aaai_Graphic558_ExplosionCoordinates
+	/* { { Front Left X, Front Left Y }, { Front Right X, Front Right Y } } */
+	{{100, 47},{122, 47}},   /* D4C */
+	{{52, 47},{76, 47}},   /* D4L */
+	{{148, 47},{172, 47}},   /* D4R */
+	{{95, 50},{127, 50}},   /* D3C */
+	{{31, 50},{63, 50}},   /* D3L */
+	{{159, 50},{191, 50}},   /* D3R */
+	{{92, 53},{131, 53}},   /* D2C */
+	{{-3, 53},{46, 53}},   /* D2L */
+	{{177, 53},{226, 53}},   /* D2R */
+	{{83, 57},{141, 57}},   /* D1C */
+	{{-54, 57},{18, 57}},   /* D1L */
+	{{207, 57},{277, 57}},   /* D1R */
+	{{0,  0},{0,  0}},   /* D0C */
+	{{-73, 60},{-33, 60}},   /* D0L */
+	{{256, 60},{296, 60}}}; /* D0R */
+int16 gRebirthStep2ExplosionCoordinates[7][3] = { // @ G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates
+	/* { X, Y, Scale } */
+	{113, 57, 12},   /* D3C */
+	{24, 57, 12},   /* D3L */
+	{195, 57, 12},   /* D3R */
+	{111, 63, 16},   /* D2C */
+	{12, 63, 16},   /* D2L */
+	{213, 63, 16},   /* D2R */
+	{112, 76, 24}}; /* D1C */
+int16 gRebirthStep1ExplosionCoordinates[7][3] = { // @ G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates
+	/* { X, Y, Scale } */
+	{112, 53, 15},   /* D3C */
+	{24, 53, 15},   /* D3L */
+	{194, 53, 15},   /* D3R */
+	{112, 59, 20},   /* D2C */
+	{15, 59, 20},   /* D2L */
+	{208, 59, 20},   /* D2R */
+	{112, 70, 32}}; /* D1C */
+
+int16 gCenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_CenteredExplosionCoordinates
+	/* { X, Y } */
+	{111, 47},   /* D4C */
+	{57, 47},   /* D4L */
+	{167, 47},   /* D4R */
+	{111, 50},   /* D3C */
+	{45, 50},   /* D3L */
+	{179, 50},   /* D3R */
+	{111, 53},   /* D2C */
+	{20, 53},   /* D2L */
+	{205, 53},   /* D2R */
+	{111, 57},   /* D1C */
+	{-30, 57},   /* D1L */
+	{253, 57},   /* D1R */
+	{111, 60},   /* D0C */
+	{-53, 60},   /* D0L */
+	{276, 60}}; /* D0R */
+
+void DisplayMan::drawObjectsCreaturesProjectilesExplosions(Thing thingParam, direction directionParam, int16 mapXpos,
+														   int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) {
+
+}
+
+
+
 bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) {
 	if (_derivedBitmaps == nullptr) {
 		_derivedBitmaps[derivedBitmapIndex] = new byte[_derivedBitmapByteCount[derivedBitmapIndex]];
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 3d5d46e..07a0806 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -275,14 +275,15 @@ class FieldAspect {
 public:
 	uint16 _nativeBitmapRelativeIndex;
 	uint16 _baseStartUnitIndex; /* Index of the unit (16 pixels = 8 bytes) in bitmap where blit will start from. A random value of 0 or 1 is added to this base index */
-	Color _transparentColor; /* Bit 7: Do not use mask if set, Bits 6-0: Transparent color index. 0xFF = no transparency */
+	uint16 _transparentColor; /* Bit 7: Do not use mask if set, Bits 6-0: Transparent color index. 0xFF = no transparency */
 	byte _mask; /* Bit 7: Flip, Bits 6-0: Mask index. 0xFF = no mask */
 	uint16 _pixelWidth;
 	uint16 _height;
 	uint16 _xPos;
-	FieldAspect(uint16 native, uint16 base, Color transparent, byte mask, uint16 byteWidth, uint16 height, uint16 xPos)
+	uint16 _bitplaneWordCount;
+	FieldAspect(uint16 native, uint16 base, uint16 transparent, byte mask, uint16 byteWidth, uint16 height, uint16 xPos, uint16 bitplane)
 		: _nativeBitmapRelativeIndex(native), _baseStartUnitIndex(base), _transparentColor(transparent), _mask(mask),
-		_pixelWidth(byteWidth * 2), _height(height), _xPos(xPos) {}
+		_pixelWidth(byteWidth * 2), _height(height), _xPos(xPos), _bitplaneWordCount(bitplane) {}
 }; // @ FIELD_ASPECT
 
 
@@ -472,6 +473,9 @@ public:
 
 	int16 getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount
 	int16 getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION
+	void drawObjectsCreaturesProjectilesExplosions(Thing thingParam, direction directionParam,
+												   int16 mapXpos, int16 mapYpos, int16 viewSquareIndex,
+												   uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 
 	int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
 	int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
@@ -489,6 +493,7 @@ public:
 	Thing _inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing
 
 	bool _useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates
+	bool _doNotDrawFluxcagesDuringEndgame; // @ G0077_B_DoNotDrawFluxcagesDuringEndgame
 
 	bool isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
 	byte *getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 583762c..463e02d 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -29,6 +29,7 @@
 #include "dungeonman.h"
 #include "champion.h"
 #include "group.h"
+#include "timeline.h"
 
 
 
@@ -54,7 +55,7 @@ LoadgameResponse LoadsaveMan::loadgame() {
 
 
 	if (newGame) {
-		warning("MISSING CODE: Timline init");
+		_vm->_timeline->initTimeline();
 		_vm->_groupMan->initActiveGroups();
 	} else {
 		assert(false);
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index 721eb43..a1460ae 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -42,7 +42,8 @@ MODULE_OBJS := \
 	menus.o \
 	movesens.o \
 	objectman.o \
-	text.o
+	text.o \
+	timeline.o
 
 MODULE_DIRS += \
 	engines/dm
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
new file mode 100644
index 0000000..150c3c2
--- /dev/null
+++ b/engines/dm/timeline.cpp
@@ -0,0 +1,55 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#include "timeline.h"
+#include "dungeonman.h"
+
+
+namespace DM {
+
+Timeline::Timeline(DMEngine* vm) : _vm(vm) {
+	_events = nullptr;
+	_timeline = nullptr;
+}
+
+Timeline::~Timeline() {
+	delete[] _events;
+	delete[] _timeline;
+}
+
+void Timeline::initTimeline() {
+	_events = new TimelineEvent[_eventMaxCount];
+	_timeline = new uint16[_eventMaxCount];
+	if (_vm->_dungeonMan->_messages._newGame) {
+		for (int16 i = 0; i < _eventMaxCount; ++i)
+			_events->_type = kTMEventTypeNone;
+		_eventCount = 0;
+		_firstUnusedEventIndex = 0;
+	}
+}
+
+}
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
new file mode 100644
index 0000000..f773530
--- /dev/null
+++ b/engines/dm/timeline.h
@@ -0,0 +1,162 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#ifndef DM_TIMELINE_H
+#define DM_TIMELINE_H
+
+#include "dm.h"
+
+namespace DM {
+
+/* Event types */
+enum TimelineEventType {
+/* Used when a creature in a group was damaged or killed by a Poison Cloud or by a closing door or if Lord Chaos is surrounded by = 3, Fluxcages */
+kTMEventTypeCreateReactionEvent29DangerOnSquare = 253, // @ CM3_EVENT_CREATE_REACTION_EVENT_29_DANGER_ON_SQUARE 
+/* Used when a projectile impacts with a creature in a group */
+kTMEventTypeCreateReactionEvent30HitByProjectile = 254, // @ CM2_EVENT_CREATE_REACTION_EVENT_30_HIT_BY_PROJECTILE
+/* Used when the party bumps into a group or performs a melee attack */
+kTMEventTypeCreateReactionEvent31ParyIsAdjacent = 255,  // @ CM1_EVENT_CREATE_REACTION_EVENT_31_PARTY_IS_ADJACENT
+kTMEventTypeNone = 0, // @ C00_EVENT_NONE                                       
+kTMEventTypeDoorAnimation = 1, // @ C01_EVENT_DOOR_ANIMATION                             
+kTMEventTypeDoorDestruction = 2, // @ C02_EVENT_DOOR_DESTRUCTION                           
+kTMEventTypeCorridor = 5, // @ C05_EVENT_CORRIDOR                                   
+kTMEventTypeWall = 6, // @ C06_EVENT_WALL                                       
+kTMEventTypeFakeWall = 7, // @ C07_EVENT_FAKEWALL                                   
+kTMEventTypeTeleporter = 8, // @ C08_EVENT_TELEPORTER                                 
+kTMEventTypePit = 9, // @ C09_EVENT_PIT                                        
+kTMEventTypeDoor = 10, // @ C10_EVENT_DOOR                                      
+kTMEventTypeEnableChampionAction = 11, // @ C11_EVENT_ENABLE_CHAMPION_ACTION                    
+kTMEventTypeHideDamageReceived = 12, // @ C12_EVENT_HIDE_DAMAGE_RECEIVED                      
+kTMEventTypeViAltarRebirth = 13, // @ C13_EVENT_VI_ALTAR_REBIRTH                          
+kTMEventTypePlaySound = 20, // @ C20_EVENT_PLAY_SOUND                                
+kTMEventTypeCPSE = 22, // @ C22_EVENT_CPSE                                      
+kTMEventTypeRemoveFluxcage = 24, // @ C24_EVENT_REMOVE_FLUXCAGE                           
+kTMEventTypeExplosion = 25, // @ C25_EVENT_EXPLOSION                                 
+kTMEventTypeGroupReactionDangerOnSquare = 29, // @ C29_EVENT_GROUP_REACTION_DANGER_ON_SQUARE           
+kTMEventTypeGroupReacionHitByProjectile = 30, // @ C30_EVENT_GROUP_REACTION_HIT_BY_PROJECTILE          
+kTMEventTypeGroupReactionPartyIsAdjecent = 31, // @ C31_EVENT_GROUP_REACTION_PARTY_IS_ADJACENT          
+kTMEventTypeUpdateAspectGroup = 32, // @ C32_EVENT_UPDATE_ASPECT_GROUP                       
+/* Events = 33,-36 and = 38,-41 are used for individual creatures only while the group is attacking the party */
+kTMEventTypeUpdateAspectCreature_0 = 33,  // @ C33_EVENT_UPDATE_ASPECT_CREATURE_0                  
+kTMEventTypeUpdateAspectCreature_1 = 34, // @ C34_EVENT_UPDATE_ASPECT_CREATURE_1                  
+kTMEventTypeUpdateAspectCreature_2 = 35, // @ C35_EVENT_UPDATE_ASPECT_CREATURE_2                  
+kTMEventTypeUpdateAspectCreature_3 = 36, // @ C36_EVENT_UPDATE_ASPECT_CREATURE_3                  
+kTMEventTypeUpdateBehaviourGroup = 37, // @ C37_EVENT_UPDATE_BEHAVIOR_GROUP                     
+kTMEventTypeUpdateBehaviour_0 = 38, // @ C38_EVENT_UPDATE_BEHAVIOR_CREATURE_0                
+kTMEventTypeUpdateBehaviour_1 = 39, // @ C39_EVENT_UPDATE_BEHAVIOR_CREATURE_1                
+kTMEventTypeUpdateBehaviour_2 = 40, // @ C40_EVENT_UPDATE_BEHAVIOR_CREATURE_2                
+kTMEventTypeUpdateBehaviour_3 = 41, // @ C41_EVENT_UPDATE_BEHAVIOR_CREATURE_3                
+/* Projectiles created by a champion (by casting a spell, shooting a weapon or throwing an object) or by a creature (by casting a spell) ignore impacts during their first movement otherwise an impact would always occur immediately as these projectiles are created on the champion or creature square */
+kTMEventTypeMoveProjectileIgnoreImpacts = 48, // @ C48_EVENT_MOVE_PROJECTILE_IGNORE_IMPACTS            
+/* Projectiles created by projectile launcher sensors never ignore impacts as well as all other projectiles after their first movement */
+kTMEventTypeMoveProjectile = 49,  // @ C49_EVENT_MOVE_PROJECTILE                           
+kTMEventTypeWatchdoge = 53, // @ C53_EVENT_WATCHDOG                                  
+kTMEventTypeMoveGroupSilent = 60, // @ C60_EVENT_MOVE_GROUP_SILENT                         
+kTMEventTypeMoveGroupAudible = 61, // @ C61_EVENT_MOVE_GROUP_AUDIBLE                        
+kTMEventTypeEnableGroupGenerator = 65, // @ C65_EVENT_ENABLE_GROUP_GENERATOR                    
+kTMEventTypeLight = 70, // @ C70_EVENT_LIGHT                                     
+kTMEventTypeInvisibility = 71, // @ C71_EVENT_INVISIBILITY                              
+kTMEventTypeChampionShield = 72, // @ C72_EVENT_CHAMPION_SHIELD                           
+kTMEventTypeThievesEye = 73, // @ C73_EVENT_THIEVES_EYE                               
+kTMEventTypePartyShield = 74, // @ C74_EVENT_PARTY_SHIELD                              
+kTMEventTypePoisonChampion = 75, // @ C75_EVENT_POISON_CHAMPION                           
+kTMEventTypeSpellShield = 77, // @ C77_EVENT_SPELLSHIELD                               
+kTMEventTypeFireShield = 78, // @ C78_EVENT_FIRESHIELD                                
+kTMEventTypeFootprints = 79, // @ C79_EVENT_FOOTPRINTS                                
+kTMEventTypeMagicMap_C80 = 80, // @ C80_EVENT_MAGIC_MAP                                 
+kTMEventTypeMagicMap_C81 = 81, // @ C81_EVENT_MAGIC_MAP                                 
+kTMEventTypeMagicMap_C82 = 82, // @ C82_EVENT_MAGIC_MAP                                 
+kTMEventTypeMagicMap_C83 = 83  // @ C83_EVENT_MAGIC_MAP    
+};
+
+class TimelineEvent {
+public:
+	int32 _mapTime;
+	byte _type;
+	byte _priority;
+
+	uint16 getTypePriority() { return (_type << 8) + _priority; }
+
+	union B_unionTimelineEvent {
+		struct {
+			byte _mapX;
+			byte _mapY;
+		} _location;
+		int16 _attack;
+		int16 _defense;
+		int16 _lightPower;
+		Thing _slot;
+		int16 _slotOrdinal;
+		B_unionTimelineEvent() {}
+	} _B;
+
+	int16 getMapXY() { return (_B._location._mapX << 8) + _B._location._mapY; }
+
+	union C_uionTimelineEvent {
+		struct {
+			byte _cell;
+			byte _effect;
+		} A;
+
+		class {
+			uint16 _backing;
+		public:
+			uint16 getMapX() { return _backing & 0x1F; }
+			uint16 getMapY() { return (_backing >> 5) & 0x1F; }
+			direction getDir() { return (direction)((_backing >> 10) & 0x3); }
+			uint16 getStepEnergy() { return (_backing >> 12) & 0xF; }
+			void setMapX(uint16 val) { _backing = (_backing & ~0x1F) | (val & 0x1F); }
+			void setMapY(uint16 val) { _backing = (_backing & ~(0x1F << 5)) | ((val & 0x1F) << 5); }
+			void setDir(direction val) { _backing = (_backing & ~(0x3 << 10)) | ((val & 0x3) << 10); }
+			void setStepEnergy(uint16 val) { _backing = (_backing & ~(0xF << 12)) | ((val & 0xF) << 12); }
+		} _projectile;
+
+		Thing _slot;
+		int16 _soundIndex;
+		byte _ticks;
+		C_uionTimelineEvent() {}
+	} _C;
+}; // @ EVENT
+
+class Timeline {
+	DMEngine *_vm;
+public:
+	uint16 _eventMaxCount; // @ G0369_ui_EventMaximumCount
+	TimelineEvent *_events; // @ G0370_ps_Events
+	uint16 _eventCount; // @ G0372_ui_EventCount 
+	uint16 *_timeline; // @ G0371_pui_Timeline
+	uint16 _firstUnusedEventIndex; // @ G0373_ui_FirstUnusedEventIndex
+
+	Timeline(DMEngine *vm);
+	~Timeline();
+	void initTimeline(); // @ F0233_TIMELINE_Initialize
+};
+
+
+}
+
+#endif


Commit: bf4ae50e6ba18fdd9c7dedb1e40a467b58fd9ac1
    https://github.com/scummvm/scummvm/commit/bf4ae50e6ba18fdd9c7dedb1e40a467b58fd9ac1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF

Changed paths:
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/group.h



diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index f3faafd..dcf1659 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -468,18 +468,30 @@ public:
 }; // @ JUNK
 
 class Projectile {
+public:
 	Thing _nextThing;
 	Thing _object;
 	byte _kineticEnergy;
 	byte _damageEnergy;
 	uint16 _timerIndex;
-public:
 	explicit Projectile(uint16 *rawDat) : _nextThing(rawDat[0]), _object(rawDat[1]), _kineticEnergy(rawDat[2]),
 		_damageEnergy(rawDat[3]), _timerIndex(rawDat[4]) {}
 
 	Thing getNextThing() { return _nextThing; }
 }; // @ PROJECTILE
 
+#define kExplosionType_Fireball 0 // @ C000_EXPLOSION_FIREBALL           
+#define kExplosionType_Slime 1 // @ C001_EXPLOSION_SLIME              
+#define kExplosionType_LightningBolt 2 // @ C002_EXPLOSION_LIGHTNING_BOLT     
+#define kExplosionType_HarmNonMaterial 3 // @ C003_EXPLOSION_HARM_NON_MATERIAL  
+#define kExplosionType_OpenDoor 4 // @ C004_EXPLOSION_OPEN_DOOR          
+#define kExplosionType_PoisonBolt 6 // @ C006_EXPLOSION_POISON_BOLT        
+#define kExplosionType_PoisonCloud 7 // @ C007_EXPLOSION_POISON_CLOUD       
+#define kExplosionType_Smoke 40 // @ C040_EXPLOSION_SMOKE             
+#define kExplosionType_Fluxcage 50 // @ C050_EXPLOSION_FLUXCAGE          
+#define kExplosionType_RebirthStep1 100 // @ C100_EXPLOSION_REBIRTH_STEP1    
+#define kExplosionType_RebirthStep2 101 // @ C101_EXPLOSION_REBIRTH_STEP2    
+
 class Explosion {
 	Thing _nextThing;
 	uint16 _attributes;
@@ -487,6 +499,9 @@ public:
 	explicit Explosion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 
 	Thing getNextThing() { return _nextThing; }
+	uint16 getType() { return _attributes & 0x7F; }
+	uint16 getAttack() { return (_attributes >> 8) & 0xFF; }
+	uint16 getCentered() { return (_attributes >> 7) & 0x1;  }
 }; // @ EXPLOSION
 
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 4506f3e..81b7e64 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -33,6 +33,8 @@
 
 #include "gfx.h"
 #include "dungeonman.h"
+#include "group.h"
+#include "timeline.h"
 
 
 namespace DM {
@@ -988,7 +990,7 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight
 
 void DisplayMan::blitBoxFilledWithMaskedBitmapToScreen(byte* src, byte* mask, byte* tmp, Box& box,
 													   int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
-													   int16 xPos, int16 yPos, int16 height2, Viewport& viewport) {
+													   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport& viewport) {
 	blitBoxFilledWithMaskedBitmap(src, _vgaBuffer, mask, tmp, box, lastUnitIndex, firstUnitIndex, _screenWidth, transparent, xPos, yPos, _screenHeight, height2, viewport);
 }
 
@@ -1959,12 +1961,852 @@ int16 gCenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_Centere
 	{-53, 60},   /* D0L */
 	{276, 60}}; /* D0R */
 
-void DisplayMan::drawObjectsCreaturesProjectilesExplosions(Thing thingParam, direction directionParam, int16 mapXpos,
+#define kBlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK
+
+void DisplayMan::cthulhu(Thing thingParam, direction directionParam, int16 mapXpos,
 														   int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) {
 
+	DungeonMan &dunMan = *_vm->_dungeonMan;
+
+	// AL_0 shared
+	uint16 &AL_0_creatureIndexRed = *(uint16*)&thingParam;
+	uint16 &AL_0_creatureGraphicInfoRed = *(uint16*)&thingParam;
+	uint16 &AL_0_creaturePosX = *(uint16*)&thingParam;
+	// AL_1 shared
+	int16 &AL_1_viewSquareExplosionIndex = viewSquareIndex;
+	// AL_2 shared
+	int16 L0126_i_Multiple;
+	int16 &AL_2_viewCell = L0126_i_Multiple;
+	int16 &AL_2_cellPurpleMan = L0126_i_Multiple;
+	int16 &AL_2_explosionSize = L0126_i_Multiple;
+	// AL_4 shared
+	int16 L0127_i_Multiple;
+	int16 &AL_4_thingType = L0127_i_Multiple;
+	int16 &AL_4_nativeBitmapIndex = L0127_i_Multiple;
+	int16 &AL_4_xPos = L0127_i_Multiple;
+	int16 &AL_4_groupCells = L0127_i_Multiple;
+	int16 &AL_4_normalizdByteWidth = L0127_i_Multiple;
+	int16 &AL_4_yPos = L0127_i_Multiple;
+	int16 &AL_4_projectileAspect = L0127_i_Multiple;
+	int16 &AL_4_explosionType = L0127_i_Multiple;
+	int16 &AL_4_explosionAspectIndex = L0127_i_Multiple;
+	// AL_6 shared
+	byte *L0128_puc_Multiple;
+	byte *&AL_6_bitmapRedBanana = L0128_puc_Multiple;
+
+	ObjectAspect *objectAspect;
+	uint32 remainingViewCellOrdinalsToProcess;
+	byte* paletteChanges;
+	byte* bitmapGreenAnt;
+	byte* coordinateSet;
+	int16 derivedBitmapIndex;
+
+	int16 byteWidth;
+	int16 heightRedEagle;
+	int16 viewLane; /* The lane (center/left/right) that the specified square is part of */
+	int16 cellYellowBear;
+	int16 paddingPixelCount;
+	int16 heightGreenGoat;
+	bool useAlcoveObjectImage; /* C1_TRUE for objects that have a special graphic when drawn in an alcove, like the Chest */
+	bool flipHorizontal;
+	bool drawingGrabbableObject;
+	Box boxByteGreen;
+	Thing firstThingToDraw; /* Initialized to thingParam and never changed afterwards. Used as a backup of the specified first object to draw */
+
+	int16 cellCounter;
+	uint16 objectShiftIndex;
+
+	uint16 L0150_ui_Multiple;
+	uint16 &AL_8_shiftSetIndex = L0150_ui_Multiple;
+	uint16 &AL_8_projectileScaleIndex = L0150_ui_Multiple;
+
+	Thing groupThing;
+	Group* group;
+	ActiveGroup* activeGroup;
+	CreatureInfo* creatureInfo;
+	CreatureAspect* creatureAspectStruct;
+	int16 creatureSize;
+	int16 creatureDirectionDelta;
+	int16 creatureGraphicInfoGreen;
+	int16 creatureAspectInt;
+	int16 creatureIndexGreen;
+	int16 transparentColor;
+	int16 sourceByteWidth;
+	int16 sourceHeight;
+	int16 creaturePaddingPixelCount;
+	bool twoHalfSquareCreaturesFrontView;
+	bool drawingLastBackRowCell;
+	bool useCreatureSideBitmap;
+	bool useCreatureBackBitmap;
+	bool useCreatureSpecialD2FrontBitmap;
+	bool useCreatureAttackBitmap;
+	bool useFlippedHorizontallyCreatureFrontImage;
+
+/* Set to C1_TRUE when the last creature that the function should draw is being drawn. This is used to avoid processing the code to draw creatures for the remaining square cells */
+	bool drawCreaturesCompleted;
+
+	int16 doorFrontViewDrawingPass; /* Value 0, 1 or 2 */
+	int16 scale;
+	bool derivedBitmapInCache;
+	Projectile* projectile;
+	byte projectileCoordinates[2];
+	int16 projectilePosX;
+	int16 projectileDirection;
+	int16 projectileAspectType;
+	int16 projectileBitmapIndexData;
+	bool doNotScaleWithKineticEnergy;
+
+/* When true, the code section to draw an object is called (with a goto) to draw the projectile, then the code section goes back to projectile processing with another goto */
+	bool drawProjectileAsObject;
+
+	bool sqaureHasProjectile;
+	uint16 currentViewCellToDraw;
+	bool projectileFlipVertical;
+	bool projectileAspectTypeHasBackGraphicAndRotation;
+	bool flipVertical;
+	Explosion* explosion;
+	Explosion* fluxcageExplosion;
+	int16* explosionCoordinates;
+	int16 explosionScale;
+	bool squareHasExplosion;
+	bool rebirthExplosion;
+	bool smoke;
+	FieldAspect fieldAspect;
+
+
+	if (thingParam == Thing::_endOfList)
+		return;
+
+	group = 0;
+	groupThing = Thing::_none;
+	drawCreaturesCompleted = sqaureHasProjectile = squareHasExplosion = false;
+	cellCounter = 0;
+	firstThingToDraw = thingParam;
+	if (getFlag(orderedViewCellOrdinals, kCellOrder_DoorFront)) { /* If the function call is to draw objects on a door square viewed from the front */
+/* Two function calls are made in that case to draw objects on both sides of the door frame.
+The door and its frame are drawn between the two calls. This value indicates the drawing pass so that
+creatures are drawn in the right order and so that Fluxcages are not drawn twice */
+		doorFrontViewDrawingPass = (orderedViewCellOrdinals & 0x1) + 1;
+		orderedViewCellOrdinals >>= 4;	/* Remove the first nibble that was used for the door front view pass */
+	} else {
+		doorFrontViewDrawingPass = 0;  /* The function call is not to draw objects on a door square viewed from the front */
+	}
+
+	bool drawAlcoveObjects = !(remainingViewCellOrdinalsToProcess = orderedViewCellOrdinals);
+	uint16 viewSquareIndexBackup = viewSquareIndex;
+	viewLane = (viewSquareIndex + 3) % 3;
+
+
+	do {
+/* Draw objects */
+		if (drawAlcoveObjects) {
+			AL_2_viewCell = kViewCellAlcove; /* Index of coordinates to draw objects in alcoves */
+			cellYellowBear = returnOppositeDir(directionParam); /* Alcove is on the opposite direction of the viewing direction */
+			objectShiftIndex = 2;
+		} else {
+			AL_2_viewCell = _vm->ordinalToIndex((int16)remainingViewCellOrdinalsToProcess & 0x000F); /* View cell is the index of coordinates to draw object */
+			currentViewCellToDraw = AL_2_viewCell;
+			remainingViewCellOrdinalsToProcess >>= 4; /* Proceed to the next cell ordinal */
+			cellCounter++;
+			cellYellowBear = (AL_2_viewCell + directionParam) % 3; /* Convert view cell to absolute cell */
+			thingParam = firstThingToDraw;
+			viewSquareIndex = viewSquareIndexBackup; /* Restore value as it may have been modified while drawing a creature */
+			objectShiftIndex = 0;
+		}
+
+		objectShiftIndex += (cellYellowBear & 0x0001) << 3;
+		drawProjectileAsObject = false;
+		do {
+			if ((AL_4_thingType = thingParam.getType()) == kGroupThingType) {
+				groupThing = thingParam;
+				continue;
+			}
+			if (AL_4_thingType == kProjectileThingType) {
+				sqaureHasProjectile = true;
+				continue;
+			}
+			if (AL_4_thingType == kExplosionThingType) {
+				squareHasExplosion = true;
+				continue;
+			}
+
+			/* Square where objects are visible and object is located on cell being processed */
+			if ((viewSquareIndex >= kViewSquare_D3C) && (viewSquareIndex <= kViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) {
+				objectAspect = &(gObjectAspects[gObjectInfo[dunMan.getObjectInfoIndex(thingParam)]._objectAspectIndex]);
+				AL_4_nativeBitmapIndex = kFirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex;
+				if (useAlcoveObjectImage = (drawAlcoveObjects && getFlag(objectAspect->_graphicInfo, kObjectAlcoveMask) && !viewLane)) {
+					AL_4_nativeBitmapIndex++;
+				}
+				coordinateSet = gObjectCoordinateSets[objectAspect->_coordinateSet][viewSquareIndex][AL_2_viewCell];
+				if (!coordinateSet[1]) /* If object is not visible */
+					continue;
+T0115015_DrawProjectileAsObject:
+				flipHorizontal = getFlag(objectAspect->_graphicInfo, kObjectFlipOnRightMask) &&
+					!useAlcoveObjectImage &&
+					((viewLane == kViewLaneRight) || (!viewLane && ((AL_2_viewCell == kViewCellFrontRight) || (AL_2_viewCell == kViewCellBackRight))));
+				/* Flip horizontally if object graphic requires it and is not being drawn in an alcove and the object is
+				either on the right lane or on the right column of the center lane */
+				paddingPixelCount = 0;
+
+				if ((viewSquareIndex == kViewSquare_D0C) || ((viewSquareIndex >= kViewSquare_D1C) && (AL_2_viewCell >= kViewCellBackRight))) {
+					/* If object is in the center lane (only D0C or D1C with condition above) and is not a projectile */
+					drawingGrabbableObject = (!viewLane && !drawProjectileAsObject);
+					AL_8_shiftSetIndex = kShiftSet_D0BackD1Front;
+					AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */
+					byteWidth = objectAspect->_width;
+					heightRedEagle = objectAspect->_height;
+					if (flipHorizontal) {
+						memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
+						flipBitmapHorizontal(_tmpBitmap, byteWidth, heightRedEagle);
+						AL_6_bitmapRedBanana = _tmpBitmap;
+					}
+				} else {
+					drawingGrabbableObject = false;
+					derivedBitmapIndex = kDerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex;
+					if ((viewSquareIndex >= kViewSquare_D1C) || ((viewSquareIndex >= kViewSquare_D2C) && (AL_2_viewCell >= kViewCellBackRight))) {
+						derivedBitmapIndex++;
+						AL_8_shiftSetIndex = kShiftSet_D1BackD2Front;
+						byteWidth = getScaledDimension(objectAspect->_width, kScale20_D2);
+						heightRedEagle = getScaledDimension(objectAspect->_height, kScale20_D2);
+						paletteChanges = gPalChangesFloorOrn_D2;
+					} else {
+						AL_8_shiftSetIndex = kShiftSet_D2BackD3Front;
+						byteWidth = getScaledDimension(objectAspect->_width, kScale16_D3);
+						heightRedEagle = getScaledDimension(objectAspect->_height, kScale16_D3);
+						paletteChanges = gPalChangesFloorOrn_D3;
+					}
+					if (flipHorizontal) {
+						derivedBitmapIndex += 2;
+						paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1;
+					} else if (useAlcoveObjectImage) {
+						derivedBitmapIndex += 4;
+					}
+
+					if (isDerivedBitmapInCache(derivedBitmapIndex)) {
+						AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
+					} else {
+						bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex);
+						blitToBitmapShrinkWithPalChange(bitmapGreenAnt, objectAspect->_width, objectAspect->_height, AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex),
+														byteWidth, heightRedEagle, paletteChanges);
+						if (flipHorizontal) {
+							flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
+						}
+						warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+					}
+				}
+				AL_4_xPos = coordinateSet[0];
+				boxByteGreen._y2 = coordinateSet[1] + 1;
+				if (!drawProjectileAsObject) { /* If drawing an object that is not a projectile */
+					AL_4_xPos += gShiftSets[AL_8_shiftSetIndex][gObjectPileShiftSetIndices[objectShiftIndex][0]];
+					boxByteGreen._y2 += gShiftSets[AL_8_shiftSetIndex][gObjectPileShiftSetIndices[objectShiftIndex][1]];
+					objectShiftIndex++; /* The next object drawn will use the next shift values */
+					if (drawAlcoveObjects) {
+						if (objectShiftIndex >= 14) {
+							objectShiftIndex = 2;
+						}
+					} else {
+						objectShiftIndex &= 0x000F;
+					}
+				}
+				boxByteGreen._y1 = boxByteGreen._y2 - (heightRedEagle - 1) - 1;
+				if (boxByteGreen._y2 > 136) {
+					boxByteGreen._y2 = 136;
+				}
+				boxByteGreen._x2 = MIN(224, AL_4_xPos + byteWidth);
+				if (boxByteGreen._x1 = MAX(0, AL_4_xPos - byteWidth + 1)) {
+					if (flipHorizontal) {
+						AL_4_xPos = paddingPixelCount;
+					} else {
+						AL_4_xPos = 0;
+					}
+				} else {
+					AL_4_xPos = byteWidth - AL_4_xPos - 1;
+				}
+
+				if (drawingGrabbableObject) {
+					bitmapGreenAnt = AL_6_bitmapRedBanana;
+					Box *AL_6_boxPtrRed = &dunMan._dungeonViewClickableBoxes[AL_2_viewCell];
+					if (AL_6_boxPtrRed->_x1 == 255) { /* If the grabbable object is the first */
+						*AL_6_boxPtrRed = boxByteGreen;
+
+						if ((heightGreenGoat = AL_6_boxPtrRed->_y2 - AL_6_boxPtrRed->_y1) < 15) { /* If the box is too small then enlarge it a little */
+							heightGreenGoat = heightGreenGoat >> 1;
+							AL_6_boxPtrRed->_y1 += heightGreenGoat - 7;
+							if (heightGreenGoat < 4) {
+								AL_6_boxPtrRed->_y2 -= heightGreenGoat - 3;
+							}
+						}
+					} else { /* If there are several grabbable objects then enlarge the box so it includes all objects */
+						AL_6_boxPtrRed->_x1 = MIN(AL_6_boxPtrRed->_x1, boxByteGreen._x1);
+						AL_6_boxPtrRed->_x2 = MIN(AL_6_boxPtrRed->_x2, boxByteGreen._x2);
+						AL_6_boxPtrRed->_y1 = MIN(AL_6_boxPtrRed->_y1, boxByteGreen._y1);
+						AL_6_boxPtrRed->_y2 = MIN(AL_6_boxPtrRed->_y2, boxByteGreen._y2);
+					}
+					AL_6_bitmapRedBanana = bitmapGreenAnt;
+					dunMan._pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */
+				}
+				blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, kColorFlesh, gDungeonViewport);
+
+				if (drawProjectileAsObject)
+					goto T0115171_BackFromT0115015_DrawProjectileAsObject;
+			}
+		} while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList);
+		if (AL_2_viewCell == kViewCellAlcove)
+			break; /* End of processing when drawing objects in an alcove */
+		if (viewSquareIndex < kViewSquare_D3C)
+			break; /* End of processing if square is too far away at D4 */
+				   /* Draw creatures */
+
+		/* If (draw cell on the back row or second cell being processed) and (no more cells to draw or next cell to draw is a cell on the front row) */
+		drawingLastBackRowCell = ((AL_2_viewCell <= kViewCellFrontRight) || (cellCounter == 1))
+			&& (!remainingViewCellOrdinalsToProcess || ((remainingViewCellOrdinalsToProcess & 0x0000000F) >= 3));
+
+		if ((groupThing == Thing::_none) || drawCreaturesCompleted)
+			goto T0115129_DrawProjectiles; /* Skip code to draw creatures */
+		if (group == nullptr) { /* If all creature data and info has not already been gathered */
+			group = (Group*)dunMan.getThingData(groupThing);
+			activeGroup = &_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()];
+			creatureInfo = &gCreatureInfo[group->_type];
+			creatureAspectStruct = &gCreatureAspects[creatureInfo->_creatureAspectIndex];
+			creatureSize = getFlag(creatureInfo->_attributes, kMaskCreatureInfo_size);
+			creatureGraphicInfoGreen = creatureInfo->_graphicInfo;
+		}
+		objectAspect = (ObjectAspect*)creatureAspectStruct;
+		if (AL_0_creatureIndexRed = _vm->_groupMan->getCreatureOrdinalInCell(group, cellYellowBear)) { /* If there is a creature on the cell being processed */
+			AL_0_creatureIndexRed--; /* Convert ordinal to index */
+			creatureIndexGreen = AL_0_creatureIndexRed;
+		} else if (creatureSize == kMaskCreatureSizeHalf) {
+			AL_0_creatureIndexRed = 0;
+			creatureIndexGreen = -1;
+		} else {
+			goto T0115129_DrawProjectiles; /* No creature to draw at cell, skip to projectiles */
+		}
+
+		creatureDirectionDelta = (directionParam - _vm->_groupMan->getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed)) % 3;
+		twoHalfSquareCreaturesFrontView = false;
+		if ((AL_4_groupCells = activeGroup->_cells) == kCreatureTypeSingleCenteredCreature) { /* If there is a single centered creature in the group */
+			if (remainingViewCellOrdinalsToProcess || (doorFrontViewDrawingPass == 1))
+/* Do not draw a single centered creature now, wait until second pass (for a front view door)
+ or until all cells have been drawn so the creature is drawn over all the objects on the floor */
+				goto T0115129_DrawProjectiles; 
+			drawCreaturesCompleted = true;
+			if ((creatureSize == kMaskCreatureSizeHalf) && (creatureDirectionDelta & 0x0001)) { /* Side view of half square creature */
+				AL_2_viewCell = kHalfSizedViewCell_CenterColumn;
+			} else {
+				AL_2_viewCell = kHalfSizedViewCell_FrontRow;
+			}
+		} else if ((creatureSize == kMaskCreatureSizeHalf) && (drawingLastBackRowCell || !remainingViewCellOrdinalsToProcess || (creatureIndexGreen < 0))) {
+			if (drawingLastBackRowCell && (doorFrontViewDrawingPass != 2)) {
+				if ((creatureIndexGreen >= 0) && (creatureDirectionDelta & 0x0001)) {
+					AL_2_viewCell = kHalfSizedViewCell_BackRow; /* Side view of a half square creature on the back row. Drawn during pass 1 for a door square */
+				} else {
+					goto T0115129_DrawProjectiles;
+				}
+			} else if ((doorFrontViewDrawingPass != 1) && !remainingViewCellOrdinalsToProcess) {
+				if (creatureDirectionDelta & 0x0001) {
+					if (creatureIndexGreen >= 0) {
+						AL_2_viewCell = kHalfSizedViewCell_FrontRow; /* Side view of a half square creature on the front row. Drawn during pass 2 for a door square */
+					} else {
+						goto T0115129_DrawProjectiles;
+					}
+				} else {
+					drawCreaturesCompleted = true;
+					if (creatureIndexGreen < 0) {
+						creatureIndexGreen = 0;
+					}
+					twoHalfSquareCreaturesFrontView = group->getCount();
+					if (((AL_4_groupCells = _vm->_groupMan->getCreatureValue(AL_4_groupCells, AL_0_creatureIndexRed)) == directionParam)
+						|| (AL_4_groupCells == returnPrevVal(directionParam))) {
+						AL_2_viewCell = kHalfSizedViewCell_LeftColumn;
+					} else {
+						AL_2_viewCell = kHalfSizedViewCell_RightColumn;
+					}
+				}
+			} else {
+				goto T0115129_DrawProjectiles;
+			}
+
+		} else if (creatureSize != kMaskCreatureSizeQuarter)
+			goto T0115129_DrawProjectiles;
+
+
+		creatureAspectInt = activeGroup->_aspect[creatureIndexGreen];
+		if (viewSquareIndex > kViewSquare_D0C) {
+			viewSquareIndex--;
+		}
+T0115077_DrawSecondHalfSquareCreature:
+		coordinateSet = gCreatureCoordinateSets[((CreatureAspect*)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell];
+		if (!coordinateSet[1])
+			goto T0115126_CreatureNotVisible;
+		AL_0_creatureGraphicInfoRed = creatureGraphicInfoGreen;
+		AL_4_nativeBitmapIndex = kFirstCreatureGraphicIndice + ((CreatureAspect*)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */
+		derivedBitmapIndex = ((CreatureAspect*)objectAspect)->_firstDerivedBitmapIndex;
+		if (useCreatureSideBitmap = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide) && (creatureDirectionDelta & 0x0001)) {
+			useCreatureAttackBitmap = useFlippedHorizontallyCreatureFrontImage = useCreatureBackBitmap = false;
+			AL_4_nativeBitmapIndex++; /* Skip the front image. Side image is right after the front image */
+			derivedBitmapIndex += 2;
+			sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthSide;
+			sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightSide;
+		} else {
+			useCreatureBackBitmap = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskBack) && (creatureDirectionDelta == 0);
+			if (useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupIsAttacking)
+				&& getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskAttack)) {
+
+				useFlippedHorizontallyCreatureFrontImage = false;
+				sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthAttack;
+				sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightAttack;
+				AL_4_nativeBitmapIndex++; /* Skip the front image */
+				derivedBitmapIndex += 2;
+				if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide)) {
+					AL_4_nativeBitmapIndex++; /* If the creature has a side image, it preceeds the attack image */
+					derivedBitmapIndex += 2;
+				}
+				if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskBack)) {
+					AL_4_nativeBitmapIndex++; /* If the creature has a back image, it preceeds the attack image */
+					derivedBitmapIndex += 2;
+				}
+			} else {
+				sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthFront;
+				sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightFront;
+				if (useCreatureBackBitmap) {
+					useFlippedHorizontallyCreatureFrontImage = false;
+					if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide)) {
+						AL_4_nativeBitmapIndex += 2; /* If the creature has a side image, it preceeds the back image */
+						derivedBitmapIndex += 4;
+					} else {
+						AL_4_nativeBitmapIndex++; /* If the creature does not have a side image, the back image follows the front image */
+						derivedBitmapIndex += 2;
+					}
+				} else {
+					if (useFlippedHorizontallyCreatureFrontImage = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskFlipNonAttack)
+						&& getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) {
+						derivedBitmapIndex += 2;
+						if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide)) {
+							derivedBitmapIndex += 2;
+						}
+						if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskBack)) {
+							derivedBitmapIndex += 2;
+						}
+						if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskAttack)) {
+							derivedBitmapIndex += 2;
+						}
+					}
+				}
+			}
+		}
+		if (viewSquareIndex >= kViewSquare_D1C) { /* Creature is on D1 */
+			creaturePaddingPixelCount = 0;
+			AL_8_shiftSetIndex = kShiftSet_D0BackD1Front;
+			transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour();
+			if (useCreatureSideBitmap) {
+				AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex);
+				if (creatureDirectionDelta == 1) {
+					memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
+					flipBitmapHorizontal(_tmpBitmap, byteWidth, heightRedEagle);
+					AL_6_bitmapRedBanana = _tmpBitmap;
+				}
+			} else {
+				if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) {
+					AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex);
+					if (useCreatureAttackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) {
+						memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
+						flipBitmapHorizontal(_tmpBitmap, byteWidth, heightRedEagle);
+						AL_6_bitmapRedBanana = _tmpBitmap;
+					}
+				} else { /* Use first additional derived graphic: front D1 */
+					if (isDerivedBitmapInCache(derivedBitmapIndex)) { /* If derived graphic is already in memory */
+						AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
+					} else {
+						bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex);
+						if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskFlipNonAttack)) {
+							AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
+							memcpy(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * heightRedEagle * sizeof(byte));
+							flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
+						}
+						warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+					}
+				}
+			}
+		} else { /* Creature is on D2 or D3 */
+			if (useFlippedHorizontallyCreatureFrontImage) {
+				derivedBitmapIndex++; /* Skip front D1 image in additional graphics */
+			}
+			if (viewSquareIndex >= kViewSquare_D2C) { /* Creature is on D2 */
+				derivedBitmapIndex++; /* Skip front D3 image in additional graphics */
+				AL_8_shiftSetIndex = kShiftSet_D1BackD2Front;
+				useCreatureSpecialD2FrontBitmap = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSpecialD2Front)
+					&& !useCreatureSideBitmap && !useCreatureBackBitmap && !useCreatureAttackBitmap;
+				paletteChanges = gPalChangesCreature_D2;
+				scale = kScale20_D2;
+			} else { /* Creature is on D3 */
+				AL_8_shiftSetIndex = kShiftSet_D2BackD3Front;
+				useCreatureSpecialD2FrontBitmap = false;
+				paletteChanges = gPalChangesCreature_D3;
+				scale = kScale16_D3;
+			}
+			byteWidth = getScaledDimension(sourceByteWidth, scale);
+			heightRedEagle = getScaledDimension(sourceHeight, scale);
+			transparentColor = paletteChanges[((CreatureAspect*)objectAspect)->getTranspColour()] / 10;
+			if (derivedBitmapInCache = isDerivedBitmapInCache(derivedBitmapIndex)) {
+				AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
+			} else {
+				bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex);
+				AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
+				blitToBitmapShrinkWithPalChange(bitmapGreenAnt, sourceByteWidth, sourceHeight, AL_6_bitmapRedBanana, byteWidth, heightRedEagle, paletteChanges);
+				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+			}
+			if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */
+				(useCreatureAttackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) ||
+				(useCreatureSpecialD2FrontBitmap && getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSpecialD2FrontIsFlipped)) ||
+				(useFlippedHorizontallyCreatureFrontImage && getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskFlipNonAttack))) { /* If the graphic should be flipped */
+				if (!useFlippedHorizontallyCreatureFrontImage || !derivedBitmapInCache) {
+					AL_4_normalizdByteWidth = byteWidth;
+					warning("SUPER WARNING: we might need getNormalizedByteWidthM77");
+					if (!useFlippedHorizontallyCreatureFrontImage) {
+						memcpy(_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte));
+						AL_6_bitmapRedBanana = _tmpBitmap;
+					}
+					flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
+				}
+				creaturePaddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1;
+			} else {
+				creaturePaddingPixelCount = 0;
+			}
+		}
+		AL_4_yPos = coordinateSet[1];
+		AL_4_yPos += gShiftSets[AL_8_shiftSetIndex][getVerticalOffsetM23(creatureAspectInt)];
+		boxByteGreen._y2 = MIN(AL_4_yPos, (int16)135) + 1;
+		boxByteGreen._y1 = MIN(0, AL_4_yPos - (heightRedEagle - 1));
+		AL_4_xPos = coordinateSet[0];
+		AL_4_xPos += gShiftSets[AL_8_shiftSetIndex][getHorizontalOffsetM22(creatureAspectInt)];
+		if (viewLane == kViewLaneLeft) {
+			AL_4_xPos -= 100;
+		} else {
+			if (viewLane) { /* Lane right */
+				AL_4_xPos += 100;
+			}
+		}
+		if (boxByteGreen._x2 = 1 + MIN(MAX(0, AL_4_xPos + byteWidth), 223) <= 1)
+			goto T0115126_CreatureNotVisible;
+		if (boxByteGreen._x1 = MIN(MAX(0, AL_4_xPos - byteWidth + 1), 223)) {
+			if (boxByteGreen._x1 == 223)
+				goto T0115126_CreatureNotVisible;
+			AL_0_creaturePosX = creaturePaddingPixelCount;
+		} else {
+			AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1);
+		}
+		warning("SUPER WARNINIG: we might nee noralized with on byteWidth");
+		blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, boxByteGreen, (Color)transparentColor, gDungeonViewport);
+
+T0115126_CreatureNotVisible:
+		if (twoHalfSquareCreaturesFrontView) {
+			twoHalfSquareCreaturesFrontView = false;
+			creatureAspectInt = activeGroup->_aspect[!creatureIndexGreen]; /* Aspect of the other creature in the pair */
+			if (AL_2_viewCell == kHalfSizedViewCell_RightColumn) {
+				AL_2_viewCell = kHalfSizedViewCell_LeftColumn;
+			} else {
+				AL_2_viewCell = kHalfSizedViewCell_RightColumn;
+			}
+			goto T0115077_DrawSecondHalfSquareCreature;
+		}
+		/* Draw projectiles */
+T0115129_DrawProjectiles:
+		if (!sqaureHasProjectile
+			|| ((viewSquareIndex = viewSquareIndexBackup) > kViewSquare_D0C)
+/* If there is no projectile to draw or if projectiles are not visible on the specified square or on the cell being drawn */
+			|| (!(projectilePosX = gObjectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0]))) 
+			continue;
+		thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */
+
+		do {
+			if ((thingParam.getType() == kProjectileThingType) && (thingParam.getCell() == cellYellowBear)) {
+				projectile = (Projectile*)dunMan.getThingData(thingParam);
+				if ((AL_4_projectileAspect = dunMan.getProjectileAspect(projectile->_object)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
+					objectAspect = (ObjectAspect*)&gProjectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)];
+					AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + kFirstProjectileGraphicIndice;
+					projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, kProjectileAspectTypeMask);
+					if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, kProjectileScaleWithKineticEnergyMask))
+						 || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == kViewSquare_D0C)) {
+						scale = 0; /* Use native bitmap without resizing */
+						byteWidth = ((ProjectileAspect*)objectAspect)->_width;
+						heightRedEagle = ((ProjectileAspect*)objectAspect)->_height;
+					} else {
+						AL_8_projectileScaleIndex = ((viewSquareIndex / 3) << 1) + (AL_2_viewCell >> 1);
+						scale = gProjectileScales[AL_8_projectileScaleIndex];
+						if (!doNotScaleWithKineticEnergy) {
+							scale = (scale * MAX(96, projectile->_kineticEnergy + 1)) >> 8;
+						}
+						byteWidth = getScaledDimension(((ProjectileAspect*)objectAspect)->_width, scale);
+						heightRedEagle = getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale);
+					}
+					if (projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == kProjectileAspectHasBackGraphicRotation)) {
+						projectileFlipVertical = ((mapXpos + mapYpos) & 0x0001);
+					}
+					if (projectileAspectType == kProjectileAspectHasNone) {
+						projectileBitmapIndexData = 0;
+						flipVertical = flipHorizontal = false;
+					} else {
+						if (isOrientedWestEast((direction)(projectileDirection = _vm->_timeline->_events[projectile->_timerIndex]._C._projectile.getDir()))
+							!= isOrientedWestEast(directionParam)) {
+							if (projectileAspectType == kProjectileAspectHasRotation) {
+								projectileBitmapIndexData = 1;
+							} else {
+								projectileBitmapIndexData = 2;
+							}
+							if (projectileAspectTypeHasBackGraphicAndRotation) {
+								flipHorizontal = !AL_2_viewCell || (AL_2_viewCell == kViewCellBackLeft);
+								if (!(flipVertical = projectileFlipVertical)) {
+									flipHorizontal = !flipHorizontal;
+								}
+							} else {
+								flipVertical = false;
+								flipHorizontal = (returnNextVal(directionParam) == projectileDirection);
+							}
+						} else {
+/* If the projectile does not have a back graphic or has one but is not seen from the back or if it has a back graphic and rotation and should be flipped vertically */
+							if ((projectileAspectType >= kProjectileAspectHasRotation)
+								|| ((projectileAspectType == kProjectileAspectBackGraphic)
+									&& (projectileDirection != directionParam)) || (projectileAspectTypeHasBackGraphicAndRotation && projectileFlipVertical)) {
+								projectileBitmapIndexData = 0;
+							} else {
+								projectileBitmapIndexData = 1;
+							}
+							flipVertical = projectileAspectTypeHasBackGraphicAndRotation && (AL_2_viewCell < kViewCellBackRight);
+							flipHorizontal = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, kProjectileSideMask)
+								&& !((viewLane == kViewLaneRight) || (!viewLane && ((AL_2_viewCell == kViewCellFrontRight) || (AL_2_viewCell == kViewCellBackRight))));
+						}
+					}
+					AL_4_nativeBitmapIndex += projectileBitmapIndexData;
+					paddingPixelCount = 0;
+					if (!scale) {
+						AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex);
+					} else {
+						if (flipHorizontal) {
+							paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1;
+						}
+						derivedBitmapIndex = kDerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (projectileBitmapIndexData * 6);
+						if (doNotScaleWithKineticEnergy && isDerivedBitmapInCache(derivedBitmapIndex) + AL_8_projectileScaleIndex) {
+							AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
+						} else {
+							bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex);
+							if (doNotScaleWithKineticEnergy) {
+								AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
+							} else {
+								AL_6_bitmapRedBanana = _tmpBitmap;
+							}
+							blitToBitmapShrinkWithPalChange(bitmapGreenAnt, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height,
+															AL_6_bitmapRedBanana, byteWidth, heightRedEagle, _palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
+							if (doNotScaleWithKineticEnergy) {
+								warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap");
+							}
+						}
+					}
+					if (flipHorizontal || flipVertical) {
+						warning("might need noralized bytewidth");
+						AL_4_normalizdByteWidth = byteWidth;
+						if (AL_6_bitmapRedBanana != _tmpBitmap) {
+							memcpy(_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte));
+							AL_6_bitmapRedBanana = _tmpBitmap;
+						}
+						if (flipVertical) {
+							flipBitmapVertical(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
+						}
+						if (flipHorizontal) {
+							flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
+						}
+					}
+					boxByteGreen._y2 = (heightRedEagle >> 1) + 47 + 1;
+					boxByteGreen._y1 = 47 - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001);
+					boxByteGreen._x2 = MIN(223, projectilePosX + byteWidth) + 1;
+					if (boxByteGreen._x1 = MAX(0, projectilePosX - byteWidth + 1)) {
+						if (flipHorizontal) {
+							AL_4_xPos = paddingPixelCount;
+						} else {
+							AL_4_xPos = 0;
+						}
+					} else {
+/* BUG0_06 Graphical glitch when drawing projectiles or explosions. If a projectile or explosion bitmap
+is cropped because it is only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and
+the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part of the bitmap is drawn on
+screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
+						AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - projectilePosX - 1));
+					}
+					blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, kColorFlesh, gDungeonViewport);
+				} else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */
+					useAlcoveObjectImage = false;
+					projectileCoordinates[0] = projectilePosX;
+					projectileCoordinates[1] = 47;
+					coordinateSet = projectileCoordinates;
+					objectAspect = &gObjectAspects[AL_4_projectileAspect];
+					AL_4_nativeBitmapIndex = objectAspect->_firstNativeBitmapRelativeIndex + kFirstObjectGraphicIndice;
+					drawProjectileAsObject = true;
+/* Go to code section to draw an object. Once completed, it jumps back to T0115171_BackFromT0115015_DrawProjectileAsObject below */
+					goto T0115015_DrawProjectileAsObject; 
+				}
+			}
+T0115171_BackFromT0115015_DrawProjectileAsObject:;
+		} while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList);
+
+	} while (remainingViewCellOrdinalsToProcess);
+
+
+	/* Draw explosions */
+	if (!squareHasExplosion)
+		return;
+	fluxcageExplosion = 0;
+	AL_1_viewSquareExplosionIndex = viewSquareIndexBackup + 3; /* Convert square index to square index for explosions */
+	uint16 explosionScaleIndex = AL_1_viewSquareExplosionIndex / 3;
+	thingParam = firstThingToDraw; /* Restart processing list of things from the beginning. The next loop draws only explosion things among the list */
+	do {
+		if (thingParam.getType() == kExplosionThingType) {
+			AL_2_cellPurpleMan = thingParam.getCell();
+			explosion = (Explosion*)dunMan.getThingData(thingParam);
+			if ((rebirthExplosion = ((unsigned int)(AL_4_explosionType = explosion->getType()) >= kExplosionType_RebirthStep1))
+				&& ((AL_1_viewSquareExplosionIndex < kViewSquare_D3C_Explosion) 
+					|| (AL_1_viewSquareExplosionIndex > kViewSquare_D1C_Explosion)
+					|| (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */
+				continue;
+			smoke = false;
+			if ((AL_4_explosionType == kExplosionType_Fireball) || (AL_4_explosionType == kExplosionType_LightningBolt) || (AL_4_explosionType == kExplosionType_RebirthStep2)) {
+				AL_4_explosionAspectIndex = kExplosionAspectFire;
+			} else {
+				if ((AL_4_explosionType == kExplosionType_PoisonBolt) || (AL_4_explosionType == kExplosionType_PoisonCloud)) {
+					AL_4_explosionAspectIndex = kExplosionAspectPoison;
+				} else {
+					if (AL_4_explosionType == kExplosionType_Smoke) {
+						smoke = true;
+						AL_4_explosionAspectIndex = kExplosionAspectSmoke;
+					} else {
+						if (AL_4_explosionType == kExplosionType_RebirthStep1) {
+							objectAspect = (ObjectAspect*)&gProjectileAspect[_vm->ordinalToIndex(-dunMan.getProjectileAspect(Thing::_explLightningBolt))];
+							AL_6_bitmapRedBanana = getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (kFirstProjectileGraphicIndice + 1));
+							explosionCoordinates = gRebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
+							byteWidth = getScaledDimension((((ProjectileAspect*)objectAspect)->_width), explosionCoordinates[2]);
+							heightRedEagle = getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
+							if (AL_1_viewSquareExplosionIndex != kViewSquare_D1C_Explosion) {
+								blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana,
+									((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, _tmpBitmap,
+																		 byteWidth, heightRedEagle, gPalChangesNoChanges);
+								AL_6_bitmapRedBanana = _tmpBitmap;
+							}
+							goto T0115200_DrawExplosion;
+						}
+						if (AL_4_explosionType == kExplosionType_Fluxcage) {
+							if (AL_1_viewSquareExplosionIndex >= kViewSquare_D3L_Explosion) {
+								fluxcageExplosion = explosion;
+							}
+							continue;
+						}
+						AL_4_explosionAspectIndex = kExplosionAspectSpell;
+					}
+				}
+			}
+			if (AL_1_viewSquareExplosionIndex == kViewSquare_D0C_Explosion) {
+				if (smoke) {
+					AL_4_explosionAspectIndex--; /* Smoke uses the same graphics as Poison Cloud, but with palette changes */
+				}
+				AL_4_explosionAspectIndex = AL_4_explosionAspectIndex * 3; /* 3 graphics per explosion pattern */
+				if (AL_2_explosionSize = (explosion->getAttack() >> 5)) {
+					AL_4_explosionAspectIndex++; /* Use second graphic in the pattern for medium explosion attack */
+					if (AL_2_explosionSize > 3) {
+						AL_4_explosionAspectIndex++; /* Use third graphic in the pattern for large explosion attack */
+					}
+				}
+				warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache");
+				AL_6_bitmapRedBanana = getBitmap(AL_4_explosionAspectIndex + kFirstExplosionPatternGraphicIndice);
+				if (smoke) {
+					blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _tmpBitmap, 48, 32, gPalChangeSmoke);
+					AL_6_bitmapRedBanana = _tmpBitmap;
+				}
+				blitBoxFilledWithMaskedBitmapToScreen(AL_6_bitmapRedBanana, nullptr, getDerivedBitmap(kDerivedBitmapViewport), gBoxExplosionPattern_D0C,
+													  _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64),
+													  224, (Color)(kBlitDoNotUseMask | kColorFlesh), 0, 0, 136, 93);
+				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+			} else {
+				if (rebirthExplosion) {
+					explosionCoordinates = gRebirthStep2ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
+					explosionScale = explosionCoordinates[2];
+				} else {
+					if (explosion->getCentered()) {
+						explosionCoordinates = gCenteredExplosionCoordinates[AL_1_viewSquareExplosionIndex];
+					} else {
+						if ((AL_2_cellPurpleMan == directionParam) || (AL_2_cellPurpleMan == returnPrevVal(directionParam))) {
+							AL_2_viewCell = kViewCellFronLeft;
+						} else {
+							AL_2_viewCell = kViewCellFrontRight;
+						}
+						explosionCoordinates = gExplosionCoordinates[AL_1_viewSquareExplosionIndex][AL_2_viewCell];
+					}
+					explosionScale = MAX(4, (MAX(48, explosion->getAttack() + 1) * gExplosionBaseScales[explosionScaleIndex]) >> 8) & (int16)0xFFFE;
+				}
+				AL_6_bitmapRedBanana = getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle);
+T0115200_DrawExplosion:
+				flipVertical = _vm->_rnd->getRandomNumber(2);
+				paddingPixelCount = 0;
+				if (flipHorizontal = _vm->_rnd->getRandomNumber(2)) {
+					paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; /* Number of unused pixels in the units on the right of the bitmap */
+				}
+				boxByteGreen._y2 = MIN(135, explosionCoordinates[1] + (heightRedEagle >> 1)) + 1; 
+				AL_4_yPos = MAX(0, explosionCoordinates[1] - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001));
+				if (AL_4_yPos >= 136)
+					continue;
+				boxByteGreen._y1 = AL_4_yPos;
+				if ((AL_4_xPos = MIN(223, explosionCoordinates[0] + byteWidth)) < 0)
+					continue;
+				boxByteGreen._x2 = AL_4_xPos + 1;
+				AL_4_xPos = explosionCoordinates[0];
+				if (boxByteGreen._x1 = MIN(MAX(0, AL_4_xPos - byteWidth + 1), 223)) {
+					AL_4_xPos = paddingPixelCount;
+				} else {
+/* BUG0_07 Graphical glitch when drawing explosions. If an explosion bitmap is cropped because it is only partly visible on the
+left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is not flipped horizontally (flipHorizontal = C0_FALSE) then the
+variable paddingPixelCount is not set before being used here. Its previous value (defined while drawing something else) is used
+and may cause an incorrect bitmap to be drawn */
+					AL_4_xPos = MIN(paddingPixelCount,(int16)( byteWidth / 2 - AL_4_xPos - 1)); 
+
+/* BUG0_06 Graphical glitch when drawing projectiles or explosions. If a projectile or explosion bitmap is cropped because it is
+only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is flipped horizontally (flipHorizontal = C1_TRUE)
+then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
+				}
+				if (boxByteGreen._x2 - 1 <= boxByteGreen._x1)
+					continue;
+				warning("might need M77_NORMALIZED_BYTE_WIDTH");
+				byteWidth = byteWidth;
+				if (flipHorizontal || flipVertical) {
+					memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle);
+					AL_6_bitmapRedBanana = _tmpBitmap;
+				}
+				if (flipHorizontal) {
+					flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
+				}
+				if (flipVertical) {
+					flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
+				}
+				blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, kColorFlesh, gDungeonViewport);
+			}
+		}
+	} while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList);
+/* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */
+	if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_doNotDrawFluxcagesDuringEndgame) { 
+		AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */
+		fieldAspect = gFieldAspects[viewSquareIndex];
+		(fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */
+		drawField(&fieldAspect, *(Box*)&gFrameWalls[viewSquareIndex]);
+	}
 }
 
+uint16 DisplayMan::getNormalizedByteWidthM77(uint16 byteWidth) {
+	return (byteWidth + 7) & 0xFFF8;
+}
+
+uint16 DisplayMan::getVerticalOffsetM23(uint16 val) {
+	return (val >> 3) & 0x7;
+}
 
+uint16 DisplayMan::getHorizontalOffsetM22(uint16 val) {
+	return (val & 0x7);
+}
 
 bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) {
 	if (_derivedBitmaps == nullptr) {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 07a0806..8a116b5 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -37,6 +37,44 @@
 namespace DM {
 
 
+/* View lanes */
+#define kViewLaneCenter 0 // @ C0_VIEW_LANE_CENTER 
+#define kViewLaneLeft 1 // @ C1_VIEW_LANE_LEFT   
+#define kViewLaneRight 2 // @ C2_VIEW_LANE_RIGHT  
+
+#define kHalfSizedViewCell_LeftColumn 0 // @ C00_VIEW_CELL_LEFT_COLUMN  
+#define kHalfSizedViewCell_RightColumn 1 // @ C01_VIEW_CELL_RIGHT_COLUMN 
+#define kHalfSizedViewCell_BackRow 2 // @ C02_VIEW_CELL_BACK_ROW     
+#define kHalfSizedViewCell_CenterColumn 3 // @ C03_VIEW_CELL_CENTER_COLUMN
+#define kHalfSizedViewCell_FrontRow 4 // @ C04_VIEW_CELL_FRONT_ROW    
+
+/* Shift sets */
+#define kShiftSet_D0BackD1Front 0 // @ C0_SHIFT_SET_D0_BACK_OR_D1_FRONT
+#define kShiftSet_D1BackD2Front 1 // @ C1_SHIFT_SET_D1_BACK_OR_D2_FRONT
+#define kShiftSet_D2BackD3Front 2 // @ C2_SHIFT_SET_D2_BACK_OR_D3_FRONT
+
+#define kCellOrder_DoorFront 0x0008 // @ MASK0x0008_DOOR_FRONT                                   
+#define kCellOrder_Alcove 0x0000 // @ C0000_CELL_ORDER_ALCOVE                                 
+#define kCellOrder_BackLeft 0x0001 // @ C0001_CELL_ORDER_BACKLEFT                               
+#define kCellOrder_BackRight 0x0002 // @ C0002_CELL_ORDER_BACKRIGHT                              
+#define kCellOrder_DoorPass1_BackLeft 0x0018 // @ C0018_CELL_ORDER_DOORPASS1_BACKLEFT                     
+#define kCellOrder_BackLeft_BackRight 0x0021 // @ C0021_CELL_ORDER_BACKLEFT_BACKRIGHT                     
+#define kCellOrder_DoorPass1_BackRight 0x0028 // @ C0028_CELL_ORDER_DOORPASS1_BACKRIGHT                    
+#define kCellOrder_BackRight_FrontRight 0x0032 // @ C0032_CELL_ORDER_BACKRIGHT_FRONTRIGHT                   
+#define kCellOrder_DoorPass2_FrontRight 0x0039 // @ C0039_CELL_ORDER_DOORPASS2_FRONTRIGHT                   
+#define kCellOrder_BackLeft_FrontLeft 0x0041 // @ C0041_CELL_ORDER_BACKLEFT_FRONTLEFT                     
+#define kCellOrder_DoorPass2_FrontLeft 0x0049 // @ C0049_CELL_ORDER_DOORPASS2_FRONTLEFT                    
+#define kCellOrder_DoorPass1_BackRight_BackLeft 0x0128 // @ C0128_CELL_ORDER_DOORPASS1_BACKRIGHT_BACKLEFT           
+#define kCellOrder_DoorPass1_BackLeft_BackRight 0x0218 // @ C0218_CELL_ORDER_DOORPASS1_BACKLEFT_BACKRIGHT           
+#define kCellOrder_BackLeft_BackRight_FrontRight 0x0321 // @ C0321_CELL_ORDER_BACKLEFT_BACKRIGHT_FRONTRIGHT          
+#define kCellOrder_BackRight_FrontLeft_FrontRight 0x0342 // @ C0342_CELL_ORDER_BACKRIGHT_FRONTLEFT_FRONTRIGHT         
+#define kCellOrder_DoorPass2_FrontLeft_FrontRight 0x0349 // @ C0349_CELL_ORDER_DOORPASS2_FRONTLEFT_FRONTRIGHT         
+#define kCellOrder_BackRight_BackLeft_FrontLeft 0x0412 // @ C0412_CELL_ORDER_BACKRIGHT_BACKLEFT_FRONTLEFT           
+#define kCellOrder_BackLeft_FrontRight_FrontLeft 0x0431 // @ C0431_CELL_ORDER_BACKLEFT_FRONTRIGHT_FRONTLEFT          
+#define kCellOrder_DoorPass2_FrontRight_FrontLeft 0x0439 // @ C0439_CELL_ORDER_DOORPASS2_FRONTRIGHT_FRONTLEFT         
+#define kCellOrder_BackLeft_BackRight_FrontLeft_FrontRight 0x3421 // @ C3421_CELL_ORDER_BACKLEFT_BACKRIGHT_FRONTLEFT_FRONTRIGHT
+#define kCellOrder_BackRight_BackLeft_FrontRight_FrontLeft 0x4312 // @ C4312_CELL_ORDER_BACKRIGHT_BACKLEFT_FRONTRIGHT_FRONTLEFT
+
 
 #define kFloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT
 #define kWallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT
@@ -167,7 +205,11 @@ enum GraphicIndice {
 	kFloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS
 	kFieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R
 	kFieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER
-	kFirstExplosionGraphicIndice = 348 // @ C348_GRAPHIC_FIRST_EXPLOSION
+	kFirstExplosionGraphicIndice = 348, // @ C348_GRAPHIC_FIRST_EXPLOSION
+	kFirstObjectGraphicIndice = 360, // @ C360_GRAPHIC_FIRST_OBJECT
+	kFirstCreatureGraphicIndice = 446, // @ C446_GRAPHIC_FIRST_CREATURE
+	kFirstProjectileGraphicIndice = 316, // @ C316_GRAPHIC_FIRST_PROJECTILE 
+	kFirstExplosionPatternGraphicIndice = 351 // @ C351_GRAPHIC_FIRST_EXPLOSION_PATTERN 
 };
 
 extern uint16 gPalSwoosh[16];
@@ -284,6 +326,7 @@ public:
 	FieldAspect(uint16 native, uint16 base, uint16 transparent, byte mask, uint16 byteWidth, uint16 height, uint16 xPos, uint16 bitplane)
 		: _nativeBitmapRelativeIndex(native), _baseStartUnitIndex(base), _transparentColor(transparent), _mask(mask),
 		_pixelWidth(byteWidth * 2), _height(height), _xPos(xPos), _bitplaneWordCount(bitplane) {}
+	FieldAspect() {}
 }; // @ FIELD_ASPECT
 
 
@@ -455,7 +498,7 @@ public:
 									   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDefultViewPort); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
 	void blitBoxFilledWithMaskedBitmapToScreen(byte *src, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
 									   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
-									   int16 xPos, int16 yPos, int16 height2, Viewport &viewport = gDungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
+									   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
 
 	void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height);
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
@@ -473,9 +516,12 @@ public:
 
 	int16 getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount
 	int16 getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION
-	void drawObjectsCreaturesProjectilesExplosions(Thing thingParam, direction directionParam,
+	void cthulhu(Thing thingParam, direction directionParam,
 												   int16 mapXpos, int16 mapYpos, int16 viewSquareIndex,
 												   uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
+	uint16 getNormalizedByteWidthM77(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH
+	uint16 getVerticalOffsetM23(uint16 val); // @ M23_VERTICAL_OFFSET
+	uint16 getHorizontalOffsetM22(uint16 val); // @ M22_HORIZONTAL_OFFSET
 
 	int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
 	int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 49ec009..0c2233d 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -82,6 +82,10 @@ enum CreatureType {
 #define kMaskCreatureInfo_archenemy 0x2000 // @ MASK0x2000_ARCHENEMY                
 #define kMaskCreatureInfo_magicmap 0x4000 // @ MASK0x4000_MAGICMAP  
 
+
+#define kMaskActiveGroupFlipBitmap 0x0040 // @ MASK0x0040_FLIP_BITMAP  
+#define kMaskActiveGroupIsAttacking 0x0080 // @ MASK0x0080_IS_ATTACKING 
+
 class ActiveGroup {
 public:
 	int _groupThingIndex;


Commit: 579b56d2124fabafd5f99ab6e308c9a286fc14af
    https://github.com/scummvm/scummvm/commit/579b56d2124fabafd5f99ab6e308c9a286fc14af
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Reversing several modifications and adding missing code warninings

Add missing code warnings to DisplayMan::drawSquareD3L  (@F0116_DUNGEONVIEW_DrawSquareD3L)
Add missing annotations to SquareAspectIndice.
Add several Frame globals.
Remove StairIndex, replace DisplayMan::_stairIndices with direct class members.
Refactor Frame into class, make it use Box type.
Add several entries to GraphicIndices type.

Changed paths:
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index dcf1659..df56ec2 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -163,19 +163,20 @@ enum TextType {
 };
 
 enum SquareAspectIndice {
-	kElemAspect = 0,
-	kFirstGroupOrObjectAspect = 1,
-	kRightWallOrnOrdAspect = 2,
-	kFrontWallOrnOrdAspect = 3,
-	kLeftWallOrnOrdAspect = 4,
-	kPitInvisibleAspect = 2,
-	kTeleporterVisibleAspect = 2,
-	kStairsUpAspect = 2,
-	kDoorStateAspect = 2,
-	kDoorThingIndexAspect = 3,
-	kFloorOrnOrdAspect = 4,
-	kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS          
+	kElemAspect = 0, // @ C0_ELEMENT
+	kFirstGroupOrObjectAspect = 1, // @ C1_FIRST_GROUP_OR_OBJECT 
+	kRightWallOrnOrdAspect = 2, // @ C2_RIGHT_WALL_ORNAMENT_ORDINAL 
+	kFrontWallOrnOrdAspect = 3, // @ C3_FRONT_WALL_ORNAMENT_ORDINAL 
+	kLeftWallOrnOrdAspect = 4, // @ C4_LEFT_WALL_ORNAMENT_ORDINAL 
+	kPitInvisibleAspect = 2, // @ C2_PIT_INVISIBLE 
+	kTeleporterVisibleAspect = 2, // @ C2_TELEPORTER_VISIBLE 
+	kStairsUpAspect = 2, // @ C2_STAIRS_UP 
+	kDoorStateAspect = 2, // @ C2_DOOR_STATE 
+	kDoorThingIndexAspect = 3, // @ C3_DOOR_THING_INDEX 
+	kFloorOrnOrdAspect = 4, // @ C4_FLOOR_ORNAMENT_ORDINAL 
+	kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS             
 };
+;
 
                
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 81b7e64..49f0d2e 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -39,6 +39,43 @@
 
 namespace DM {
 
+Frame g0164Frame_DoorFrameLeft_D3L = Frame(0, 31, 28, 70, 16, 43, 0, 0); // @ G0164_s_Graphic558_Frame_DoorFrameLeft_D3L
+Frame g0165Frame_DoorFrameRight_D3R = Frame(192, 223, 28, 70, 16, 43, 0, 0); // @ G0165_s_Graphic558_Frame_DoorFrameRight_D3R
+Frame g0166Frame_DoorFrameLeft_D3C = Frame(64, 95, 27, 70, 16, 44, 0, 0); // @ G0166_s_Graphic558_Frame_DoorFrameLeft_D3C
+Frame g0167Frame_DoorFrameRight_D3C = Frame(128, 159, 27, 70, 16, 44, 0, 0); // @ G0167_s_Graphic558_Frame_DoorFrameRight_D3C
+Frame g0168Frame_DoorFrameLeft_D2C = Frame(48, 95, 22, 86, 24, 65, 0, 0); // @ G0168_s_Graphic558_Frame_DoorFrameLeft_D2C
+Frame g0169Frame_DoorFrameRight_D2C = Frame(128, 175, 22, 86, 24, 65, 0, 0); // @ G0169_s_Graphic558_Frame_DoorFrameRight_D2C
+Frame g0170Frame_DoorFrameLeft_D1C = Frame(43, 74, 14, 107, 16, 94, 0, 0); // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C
+Frame g0171Frame_DoorFrameRight_D1C = Frame(149, 180, 14, 107, 16, 94, 0, 0); // @ G0171_s_Graphic558_Frame_DoorFrameRight_D1C
+Frame g0172Frame_DoorFrame_D0C = Frame(96, 127, 0, 122, 16, 123, 0, 0); // @ G0172_s_Graphic558_Frame_DoorFrame_D0C
+Frame g0173Frame_DoorFrameTop_D2L = Frame(0, 59, 22, 24, 48, 3, 16, 0); // @ G0173_s_Graphic558_Frame_DoorFrameTop_D2L
+Frame g0174Frame_DoorFrameTop_D2C = Frame(64, 159, 22, 24, 48, 3, 0, 0); // @ G0174_s_Graphic558_Frame_DoorFrameTop_D2C
+Frame g0175Frame_DoorFrameTop_D2R = Frame(164, 223, 22, 24, 48, 3, 16, 0); // @ G0175_s_Graphic558_Frame_DoorFrameTop_D2R
+Frame g0176Frame_DoorFrameTop_D1L = Frame(0, 31, 14, 17, 64, 4, 16, 0); // @ G0176_s_Graphic558_Frame_DoorFrameTop_D1L
+Frame g0177Frame_DoorFrameTop_D1C = Frame(48, 175, 14, 17, 64, 4, 0, 0); // @ G0177_s_Graphic558_Frame_DoorFrameTop_D1C
+Frame g0178Frame_DoorFrameTop_D1R = Frame(192, 223, 14, 17, 64, 4, 16, 0); // @ G0178_s_Graphic558_Frame_DoorFrameTop_D1R
+Frame g0140FrameFloorPit_D3L = Frame(0, 79, 66, 73, 40, 8, 0, 0); // @ G0140_s_Graphic558_Frame_FloorPit_D3L
+Frame g0141FrameFloorPit_D3C = Frame(64, 159, 66, 73, 48, 8, 0, 0); // @ G0141_s_Graphic558_Frame_FloorPit_D3C
+Frame g0142FrameFloorPit_D3R = Frame(144, 223, 66, 73, 40, 8, 0, 0); // @ G0142_s_Graphic558_Frame_FloorPit_D3R
+Frame g0143FrameFloorPit_D2L = Frame(0, 79, 77, 88, 40, 12, 0, 0); // @ G0143_s_Graphic558_Frame_FloorPit_D2L
+Frame g0144FrameFloorPit_D2C = Frame(64, 159, 77, 88, 48, 12, 0, 0); // @ G0144_s_Graphic558_Frame_FloorPit_D2C
+Frame g0145FrameFloorPit_D2R = Frame(144, 223, 77, 88, 40, 12, 0, 0); // @ G0145_s_Graphic558_Frame_FloorPit_D2R
+Frame g0146FrameFloorPit_D1L = Frame(0, 63, 93, 116, 32, 24, 0, 0); // @ G0146_s_Graphic558_Frame_FloorPit_D1L
+Frame g0147FrameFloorPit_D1C = Frame(32, 191, 93, 116, 80, 24, 0, 0); // @ G0147_s_Graphic558_Frame_FloorPit_D1C
+Frame g0148FrameFloorPit_D1R = Frame(160, 223, 93, 116, 32, 24, 0, 0); // @ G0148_s_Graphic558_Frame_FloorPit_D1R
+Frame g0149FrameFloorPit_D0L = Frame(0, 31, 124, 135, 16, 12, 0, 0); // @ G0149_s_Graphic558_Frame_FloorPit_D0L
+Frame g0150FrameFloorPit_D0C = Frame(16, 207, 124, 135, 96, 12, 0, 0); // @ G0150_s_Graphic558_Frame_FloorPit_D0C
+Frame g0151FrameFloorPit_D0R = Frame(192, 223, 124, 135, 16, 12, 0, 0); // @ G0151_s_Graphic558_Frame_FloorPit_D0R
+Frame g0152FrameFloorPit_D2L = Frame(0, 79, 19, 23, 40, 5, 0, 0); // @ G0152_s_Graphic558_Frame_CeilingPit_D2L
+Frame g0153FrameFloorPit_D2C = Frame(64, 159, 19, 23, 48, 5, 0, 0); // @ G0153_s_Graphic558_Frame_CeilingPit_D2C
+Frame g0154FrameFloorPit_D2R = Frame(144, 223, 19, 23, 40, 5, 0, 0); // @ G0154_s_Graphic558_Frame_CeilingPit_D2R
+Frame g0155FrameFloorPit_D1L = Frame(0, 63, 8, 16, 32, 9, 0, 0); // @ G0155_s_Graphic558_Frame_CeilingPit_D1L
+Frame g0156FrameFloorPit_D1C = Frame(32, 191, 8, 16, 80, 9, 0, 0); // @ G0156_s_Graphic558_Frame_CeilingPit_D1C
+Frame g0157FrameFloorPit_D1R = Frame(160, 223, 8, 16, 32, 9, 0, 0); // @ G0157_s_Graphic558_Frame_CeilingPit_D1R
+Frame g0158FrameFloorPit_D0L = Frame(0, 15, 0, 3, 8, 4, 0, 0); // @ G0158_s_Graphic558_Frame_CeilingPit_D0L
+Frame g0159FrameFloorPit_D0C = Frame(16, 207, 0, 3, 96, 4, 0, 0); // @ G0159_s_Graphic558_Frame_CeilingPit_D0C
+Frame g0160FrameFloorPit_D0R = Frame(208, 223, 0, 3, 8, 4, 0, 0); // @ G0160_s_Graphic558_Frame_CeilingPit_D0R
+
 FieldAspect gFieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects
 								  /* { NativeBitmapRelativeIndex, BaseStartUnitIndex, Transparent color, Mask, ByteWidth, Height, X, BitPlaneWordCount } */
 	FieldAspect(0, 63, 0x8A, 0xFF,  0,   0,  0, 64),   /* D3C */
@@ -645,8 +682,8 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	for (int i = 0; i < 25; i++)
 		_wallSetBitMaps[i] = nullptr;
 
-	for (int i = 0; i < kStairsGraphicCount; i++)
-		_stairIndices[i] = 0;
+	//for (int i = 0; i < kStairsGraphicCount; i++)
+	//	_stairIndices[i] = 0;
 
 	for (int i = 0; i < 4; i++)
 		_palChangesProjectile[i] = nullptr;
@@ -1065,33 +1102,62 @@ uint16 DisplayMan::getHeight(uint16 index) {
 
 void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
 	if (f._srcWidth)
-		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorNoTransparency, gDungeonViewport);
+		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, kColorNoTransparency, gDungeonViewport);
 }
 
 void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) {
 	if (f._srcWidth)
-		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorFlesh, gDungeonViewport);
+		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, kColorFlesh, gDungeonViewport);
 }
 
+
+// NOTE: has been screened for missing code
 void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
+	int16 order;
+
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[kElemAspect]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3L]);
+			drawFloorPitOrStairsBitmap(_g0675stairsNativeBitmapIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3L]);
 		else
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3L]);
-		break;
+			drawFloorPitOrStairsBitmap(_g0682stairsNativeBitmapIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3L]);
+		goto T0116015_redEagle;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3L]);
 		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], kViewWall_D3L_RIGHT);
 		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3L_FRONT)) {
-			// ... missing code
+			order = kCellOrder_Alcove;
+			goto T0116017_orangeElk;
 		}
-		break;
-	default:
-		break;
+		return;
+	case kElementTypeDoorSide:
+	case kElementTypeStairsSide:
+		order = kCellOrder_BackLeft_BackRight_FrontRight;
+		goto T0116016_blueToad;
+	case kElementTypeDoorFront:
+		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
+		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3L, kCellOrder_DoorPass1_BackLeft_BackRight);
+		drawWallSetBitmap(_wallSetBitMaps[kDoorFrameLeft_D3L], g0164Frame_DoorFrameLeft_D3L);
+		warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor");
+		order = kCellOrder_DoorPass2_FrontLeft_FrontRight;
+		goto T0116017_orangeElk;
+	case kElementTypePit:
+		if (!squareAspect[kPitInvisibleAspect]) {
+			drawFloorPitOrStairsBitmap(k049FloorPit_D3L_GraphicIndice, g0140FrameFloorPit_D3L);
+		}
+	case kElementTypeTeleporter:
+	case kElementTypeCorridor:
+T0116015_redEagle:
+		order = kCellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
+T0116016_blueToad:
+		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
+T0116017_orangeElk:
+		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3L, order);
+	}
+	if ((squareAspect[kElemAspect] == kElementTypeTeleporter) && squareAspect[kTeleporterVisibleAspect]) {
+		drawField(&gFieldAspects[kViewSquare_D3L], gFrameWalls[kViewSquare_D3L]._box);
 	}
 }
 
@@ -1101,9 +1167,9 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0675stairsNativeBitmapIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3R]);
 		else
-			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0682stairsNativeBitmapIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3R]);
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3R]);
@@ -1122,9 +1188,9 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D3C, gStairFrames[kFrameStairsUpFront_D3C]);
+			drawFloorPitOrStairsBitmap(_g0676stairsNativeBitmapIndex_Up_Front_D3C, gStairFrames[kFrameStairsUpFront_D3C]);
 		else
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D3C, gStairFrames[kFrameStairsDownFront_D3C]);
+			drawFloorPitOrStairsBitmap(_g0683stairsNativeBitmapIndex_Down_Front_D3C, gStairFrames[kFrameStairsDownFront_D3C]);
 		break;
 	case kWallElemType:
 		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3C]);
@@ -1142,9 +1208,9 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2L]);
+			drawFloorPitOrStairsBitmap(_g0677stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2L]);
 		else
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2L]);
+			drawFloorPitOrStairsBitmap(_g0684stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2L]);
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2L]);
@@ -1154,7 +1220,7 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) {
 		}
 		break;
 	case kStairsSideElemType:
-		drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2L]);
+		drawFloorPitOrStairsBitmap(_g0689stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2L]);
 		break;
 	default:
 		break;
@@ -1166,9 +1232,9 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0677stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2R]);
 		else
-			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0684stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2R]);
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2R]);
@@ -1178,7 +1244,7 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) {
 		}
 		break;
 	case kStairsSideElemType:
-		drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]);
+		drawFloorPitOrStairsBitmapFlippedHorizontally(_g0689stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]);
 		break;
 	default:
 		break;
@@ -1190,9 +1256,9 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D2C, gStairFrames[kFrameStairsUpFront_D2C]);
+			drawFloorPitOrStairsBitmap(_g0678stairsNativeBitmapIndex_Up_Front_D2C, gStairFrames[kFrameStairsUpFront_D2C]);
 		else
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D2C, gStairFrames[kFrameStairsDownFront_D2C]);
+			drawFloorPitOrStairsBitmap(_g0685stairsNativeBitmapIndex_Down_Front_D2C, gStairFrames[kFrameStairsDownFront_D2C]);
 		break;
 	case kWallElemType:
 		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2C]);
@@ -1210,9 +1276,9 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1L]);
+			drawFloorPitOrStairsBitmap(_g0679stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1L]);
 		else
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1L]);
+			drawFloorPitOrStairsBitmap(_g0686stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1L]);
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1L]);
@@ -1220,9 +1286,9 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) {
 		break;
 	case kStairsSideElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1L]);
+			drawFloorPitOrStairsBitmap(_g0690stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1L]);
 		else
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1L]);
+			drawFloorPitOrStairsBitmap(_g0691stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1L]);
 		break;
 	default:
 		break;
@@ -1234,9 +1300,9 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0679stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1R]);
 		else
-			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0686stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1R]);
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1R]);
@@ -1244,9 +1310,9 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) {
 		break;
 	case kStairsSideElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0690stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1R]);
 		else
-			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0691stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1R]);
 		break;
 	default:
 		break;
@@ -1258,9 +1324,9 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D1C, gStairFrames[kFrameStairsUpFront_D1C]);
+			drawFloorPitOrStairsBitmap(_g0680stairsNativeBitmapIndex_Up_Front_D1C, gStairFrames[kFrameStairsUpFront_D1C]);
 		else
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D1C, gStairFrames[kFrameStairsDownFront_D1C]);
+			drawFloorPitOrStairsBitmap(_g0687stairsNativeBitmapIndex_Down_Front_D1C, gStairFrames[kFrameStairsDownFront_D1C]);
 		break;
 	case kWallElemType:
 		_vm->_dungeonMan->_isFacingAlcove = false;
@@ -1282,7 +1348,7 @@ void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsSideElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0L]);
+			drawFloorPitOrStairsBitmap(_g0692stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0L]);
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]);
@@ -1298,7 +1364,7 @@ void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsSideElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0692stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0R]);
 		return;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D0R], gFrameWalls[kViewSquare_D0R]);
@@ -1314,11 +1380,11 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect]) {
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0L]);
-			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0R]);
+			drawFloorPitOrStairsBitmap(_g0681stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0L]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0681stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0R]);
 		} else {
-			drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0L]);
-			drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0R]);
+			drawFloorPitOrStairsBitmap(_g0688stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0L]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0688stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0R]);
 		}
 		break;
 	default:
@@ -1481,8 +1547,27 @@ void DisplayMan::loadCurrentMapGraphics() {
 
 	// the original loads some flipped walls here, I moved it to loadWallSet
 
-	for (uint16 i = 0, firstGraphicIndex = _vm->_dungeonMan->_currMap._map->_wallSet * kStairsGraphicCount + kFirstStairs; i < kStairsGraphicCount; ++i)
-		_stairIndices[i] = firstGraphicIndex + i;
+	{
+		int16 val = _vm->_dungeonMan->_currMap._map->_wallSet * kStairsGraphicCount + kFirstStairs;
+		_g0675stairsNativeBitmapIndex_Up_Front_D3L = val++;
+		_g0676stairsNativeBitmapIndex_Up_Front_D3C = val++;
+		_g0677stairsNativeBitmapIndex_Up_Front_D2L = val++;
+		_g0678stairsNativeBitmapIndex_Up_Front_D2C = val++;
+		_g0679stairsNativeBitmapIndex_Up_Front_D1L = val++;
+		_g0680stairsNativeBitmapIndex_Up_Front_D1C = val++;
+		_g0681stairsNativeBitmapIndex_Up_Front_D0C_Left = val++;
+		_g0682stairsNativeBitmapIndex_Down_Front_D3L = val++;
+		_g0683stairsNativeBitmapIndex_Down_Front_D3C = val++;
+		_g0684stairsNativeBitmapIndex_Down_Front_D2L = val++;
+		_g0685stairsNativeBitmapIndex_Down_Front_D2C = val++;
+		_g0686stairsNativeBitmapIndex_Down_Front_D1L = val++;
+		_g0687stairsNativeBitmapIndex_Down_Front_D1C = val++;
+		_g0688stairsNativeBitmapIndex_Down_Front_D0C_Left = val++;
+		_g0689stairsNativeBitmapIndex_Side_D2L = val++;
+		_g0690stairsNativeBitmapIndex_Up_Side_D1L = val++;
+		_g0691stairsNativeBitmapIndex_Down_Side_D1L = val++;
+		_g0692stairsNativeBitmapIndex_Side_D0L = val++;
+	}
 
 	for (int16 i = 0; i < kAlcoveOrnCount; ++i)
 		_currMapAlcoveOrnIndices[i] = -1;
@@ -1554,17 +1639,17 @@ void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor
 	gPalChangesCreature_D3[replacedColor] = gCreatureReplColorSets[replacementColor]._D3ReplacementColor;
 }
 
-void DisplayMan::drawFloorPitOrStairsBitmap(StairIndex relIndex, Frame &f) {
+void DisplayMan::drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
 	if (f._srcWidth) {
-		blitToScreen(_bitmaps[_stairIndices[relIndex]], f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorFlesh, gDungeonViewport);
+		blitToScreen(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, f._box, kColorFlesh, gDungeonViewport);
 	}
 }
 
-void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relIndex, Frame &f) {
+void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) {
 	if (f._srcWidth) {
-		blitToBitmap(_bitmaps[_stairIndices[relIndex]], f._srcWidth, f._srcHeight, _tmpBitmap, f._srcWidth);
+		blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcHeight, _tmpBitmap, f._srcWidth);
 		flipBitmapHorizontal(_tmpBitmap, f._srcWidth, f._srcHeight);
-		blitToScreen(_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorFlesh, gDungeonViewport);
+		blitToScreen(_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._box, kColorFlesh, gDungeonViewport);
 	}
 }
 
@@ -1641,12 +1726,12 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 						while (*character++ < 0x80) {
 							characterCount++;
 						}
-						frame._destToX = (frame._destFromX = 112 - (characterCount * 4)) + 7;
-						frame._destFromY = (frame._destToY = gInscriptionLineY[textLineIndex++]) - 7;
+						frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7;
+						frame._box._y1 = (frame._box._y2 = gInscriptionLineY[textLineIndex++]) - 7;
 						while (characterCount--) {
-							blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._destFromX, frame._destToX, frame._destFromY, frame._destToY, kColorFlesh, gDungeonViewport);
-							frame._destFromX += 8;
-							frame._destToX += 8;
+							blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._box, kColorFlesh, gDungeonViewport);
+							frame._box._x1 += 8;
+							frame._box._x2 += 8;
 						}
 					} while (*string++ != 0x81);
 					return isAlcove;
@@ -1721,14 +1806,14 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 			} while (*string++ != 0x81);
 
 			if (unreadableTextLineCount < 4) {
-				frame._destFromX = coordinateSetA[0];
-				frame._destToX = coordinateSetA[1];
-				frame._destFromY = coordinateSetA[2];
-				frame._destToY = coordinateSetA[3];
+				frame._box._x1 = coordinateSetA[0];
+				frame._box._x2 = coordinateSetA[1];
+				frame._box._y1 = coordinateSetA[2];
+				frame._box._y2 = coordinateSetA[3];
 				frame._srcWidth = coordinateSetA[4];
 				frame._srcHeight = coordinateSetA[5];
 
-				coordinateSetA = &frame._destFromX;
+				coordinateSetA = (uint16*)&frame._box;
 
 				coordinateSetA[3] = gUnreadableInscriptionBoxY2[gWallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
 			}
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 8a116b5..397417f 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -209,7 +209,15 @@ enum GraphicIndice {
 	kFirstObjectGraphicIndice = 360, // @ C360_GRAPHIC_FIRST_OBJECT
 	kFirstCreatureGraphicIndice = 446, // @ C446_GRAPHIC_FIRST_CREATURE
 	kFirstProjectileGraphicIndice = 316, // @ C316_GRAPHIC_FIRST_PROJECTILE 
-	kFirstExplosionPatternGraphicIndice = 351 // @ C351_GRAPHIC_FIRST_EXPLOSION_PATTERN 
+	kFirstExplosionPatternGraphicIndice = 351, // @ C351_GRAPHIC_FIRST_EXPLOSION_PATTERN 
+	k049FloorPit_D3L_GraphicIndice = 49, // @ C049_GRAPHIC_FLOOR_PIT_D3L
+	k050FloorPit_D3C_GraphicIndice = 50, // @ C050_GRAPHIC_FLOOR_PIT_D3C
+	k051FloorPit_D2L_GraphicIndice = 51, // @ C051_GRAPHIC_FLOOR_PIT_D2L
+	k052FloorPit_D2C_GraphicIndice = 52, // @ C052_GRAPHIC_FLOOR_PIT_D2C
+	k053FloorPit_D1L_GraphicIndice = 53, // @ C053_GRAPHIC_FLOOR_PIT_D1L
+	k054FloorPit_D1C_GraphicIndice = 54, // @ C054_GRAPHIC_FLOOR_PIT_D1C
+	k055FloorPit_D0L_GraphicIndice = 55, // @ C055_GRAPHIC_FLOOR_PIT_D0L
+	k056FloorPit_D0C_GraphicIndice = 56 // @ C056_GRAPHIC_FLOOR_PIT_D0C
 };
 
 extern uint16 gPalSwoosh[16];
@@ -235,16 +243,16 @@ public:
 
 extern Box gBoxMovementArrows; // G0002_s_Graphic562_Box_MovementArrows
 
-// The frames in the original sources contain inclusive boundaries and byte widths, not pixel widths
-struct Frame {
-	uint16 _destFromX, _destToX, _destFromY, _destToY;
+class Frame {
+public:
+	Box _box;
 	uint16 _srcWidth, _srcHeight;
 	uint16 _srcX, _srcY;
 
 	Frame() {}
 	Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
 		  uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) :
-		_destFromX(destFromX), _destToX(destToX + 1), _destFromY(destFromY), _destToY(destToY + 1),
+		_box(destFromX, destToX, destFromY, destToY),
 		_srcWidth(srcWidth * 2), _srcHeight(srcHeight), _srcX(srcX), _srcY(srcY) {}
 };
 
@@ -256,27 +264,6 @@ enum FloorSet {
 	kFloorSetStone = 0 // @ C0_FLOOR_SET_STONE
 };
 
-enum StairIndex {
-	kStairsNativeIndex_Up_Front_D3L = 0, // @ G0675_i_StairsNativeBitmapIndex_Up_Front_D3L
-	kStairsNativeIndex_Up_Front_D3C = 1, // @ G0676_i_StairsNativeBitmapIndex_Up_Front_D3C
-	kStairsNativeIndex_Up_Front_D2L = 2, // @ G0677_i_StairsNativeBitmapIndex_Up_Front_D2L
-	kStairsNativeIndex_Up_Front_D2C = 3, // @ G0678_i_StairsNativeBitmapIndex_Up_Front_D2C
-	kStairsNativeIndex_Up_Front_D1L = 4, // @ G0679_i_StairsNativeBitmapIndex_Up_Front_D1L
-	kStairsNativeIndex_Up_Front_D1C = 5, // @ G0680_i_StairsNativeBitmapIndex_Up_Front_D1C
-	kStairsNativeIndex_Up_Front_D0C_Left = 6, // @ G0681_i_StairsNativeBitmapIndex_Up_Front_D0C_Left
-	kStairsNativeIndex_Down_Front_D3L = 7, // @ G0682_i_StairsNativeBitmapIndex_Down_Front_D3L
-	kStairsNativeIndex_Down_Front_D3C = 8, // @ G0683_i_StairsNativeBitmapIndex_Down_Front_D3C
-	kStairsNativeIndex_Down_Front_D2L = 9, // @ G0684_i_StairsNativeBitmapIndex_Down_Front_D2L
-	kStairsNativeIndex_Down_Front_D2C = 10, // @ G0685_i_StairsNativeBitmapIndex_Down_Front_D2C
-	kStairsNativeIndex_Down_Front_D1L = 11, // @ G0686_i_StairsNativeBitmapIndex_Down_Front_D1L
-	kStairsNativeIndex_Down_Front_D1C = 12, // @ G0687_i_StairsNativeBitmapIndex_Down_Front_D1C
-	kStairsNativeIndex_Down_Front_D0C_Left = 13, // @ G0688_i_StairsNativeBitmapIndex_Down_Front_D0C_Left
-	kStairsNativeIndex_Side_D2L = 14, // @ G0689_i_StairsNativeBitmapIndex_Side_D2L
-	kStairsNativeIndex_Up_Side_D1L = 15, // @ G0690_i_StairsNativeBitmapIndex_Up_Side_D1L
-	kStairsNativeIndex_Down_Side_D1L = 16, // @ G0691_i_StairsNativeBitmapIndex_Down_Side_D1L
-	kStairsNativeIndex_Side_D0L = 17 // @ G0692_i_StairsNativeBitmapIndex_Side_D0L
-};
-
 enum ViewWall {
 	kViewWall_D3L_RIGHT = 0, // @ C00_VIEW_WALL_D3L_RIGHT 
 	kViewWall_D3R_LEFT = 1, // @ C01_VIEW_WALL_D3R_LEFT  
@@ -416,7 +403,6 @@ class DisplayMan {
 
 	// pointers 13,14 and [15-19] are owned by this array
 	byte *_wallSetBitMaps[25];	// @G[0696..0710]_puc_Bitmap_WallSet_...
-	uint16 _stairIndices[kStairsGraphicCount];
 
 	// pointers are not owned by these fields
 	byte *_floorBitmap;
@@ -432,8 +418,8 @@ class DisplayMan {
 	void unpackGraphics();
 	void loadFNT1intoBitmap(uint16 index, byte *destBitmap);
 
-	void drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally
-	void drawFloorPitOrStairsBitmap(StairIndex relIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap
+	void drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally
+	void drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap
 	void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap
 	void drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency
 	void drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L
@@ -457,6 +443,24 @@ class DisplayMan {
 	uint16 *_derivedBitmapByteCount; // @ G0639_pui_DerivedBitmapByteCount
 	byte **_derivedBitmaps; // @ G0638_pui_DerivedBitmapBlockIndices
 
+	int16 _g0675stairsNativeBitmapIndex_Up_Front_D3L; // @ G0675_i_StairsNativeBitmapIndex_Up_Front_D3L
+	int16 _g0676stairsNativeBitmapIndex_Up_Front_D3C; // @ G0676_i_StairsNativeBitmapIndex_Up_Front_D3C
+	int16 _g0677stairsNativeBitmapIndex_Up_Front_D2L; // @ G0677_i_StairsNativeBitmapIndex_Up_Front_D2L
+	int16 _g0678stairsNativeBitmapIndex_Up_Front_D2C; // @ G0678_i_StairsNativeBitmapIndex_Up_Front_D2C
+	int16 _g0679stairsNativeBitmapIndex_Up_Front_D1L; // @ G0679_i_StairsNativeBitmapIndex_Up_Front_D1L
+	int16 _g0680stairsNativeBitmapIndex_Up_Front_D1C; // @ G0680_i_StairsNativeBitmapIndex_Up_Front_D1C
+	int16 _g0681stairsNativeBitmapIndex_Up_Front_D0C_Left; // @ G0681_i_StairsNativeBitmapIndex_Up_Front_D0C_Left
+	int16 _g0682stairsNativeBitmapIndex_Down_Front_D3L; // @ G0682_i_StairsNativeBitmapIndex_Down_Front_D3L
+	int16 _g0683stairsNativeBitmapIndex_Down_Front_D3C; // @ G0683_i_StairsNativeBitmapIndex_Down_Front_D3C
+	int16 _g0684stairsNativeBitmapIndex_Down_Front_D2L; // @ G0684_i_StairsNativeBitmapIndex_Down_Front_D2L
+	int16 _g0685stairsNativeBitmapIndex_Down_Front_D2C; // @ G0685_i_StairsNativeBitmapIndex_Down_Front_D2C
+	int16 _g0686stairsNativeBitmapIndex_Down_Front_D1L; // @ G0686_i_StairsNativeBitmapIndex_Down_Front_D1L
+	int16 _g0687stairsNativeBitmapIndex_Down_Front_D1C; // @ G0687_i_StairsNativeBitmapIndex_Down_Front_D1C
+	int16 _g0688stairsNativeBitmapIndex_Down_Front_D0C_Left; // @ G0688_i_StairsNativeBitmapIndex_Down_Front_D0C_Left
+	int16 _g0689stairsNativeBitmapIndex_Side_D2L; // @ G0689_i_StairsNativeBitmapIndex_Side_D2L
+	int16 _g0690stairsNativeBitmapIndex_Up_Side_D1L; // @ G0690_i_StairsNativeBitmapIndex_Up_Side_D1L
+	int16 _g0691stairsNativeBitmapIndex_Down_Side_D1L; // @ G0691_i_StairsNativeBitmapIndex_Down_Side_D1L
+	int16 _g0692stairsNativeBitmapIndex_Side_D0L; // @ G0692_i_StairsNativeBitmapIndex_Side_D0L
 public:
 	// some methods use this for a stratchpad, don't make assumptions about content between function calls
 	byte *_tmpBitmap;


Commit: e95470d189cbe5877053b128c89a4aac6c973d54
    https://github.com/scummvm/scummvm/commit/e95470d189cbe5877053b128c89a4aac6c973d54
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix errors in DisplayMan::isDerivedBitmapInCache

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 49f0d2e..d8bf60e 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2894,8 +2894,9 @@ uint16 DisplayMan::getHorizontalOffsetM22(uint16 val) {
 }
 
 bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) {
-	if (_derivedBitmaps == nullptr) {
-		_derivedBitmaps[derivedBitmapIndex] = new byte[_derivedBitmapByteCount[derivedBitmapIndex]];
+	if (_derivedBitmaps[derivedBitmapIndex] == nullptr) {
+		// * 2, because the original uses 4 bits instead of 8 bits to store a pixel
+		_derivedBitmaps[derivedBitmapIndex] = new byte[_derivedBitmapByteCount[derivedBitmapIndex] * 2];
 		return false;
 	} else
 		return true;


Commit: 5f25c6aae28a3553183ee3c2e8af7b66e9622bf6
    https://github.com/scummvm/scummvm/commit/5f25c6aae28a3553183ee3c2e8af7b66e9622bf6
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing code to DisplayMan::drawSquareD3R (@F0117_DUNGEONVIEW_DrawSquareD3R)

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index d8bf60e..ce31c49 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -54,6 +54,36 @@ Frame g0175Frame_DoorFrameTop_D2R = Frame(164, 223, 22, 24, 48, 3, 16, 0); // @
 Frame g0176Frame_DoorFrameTop_D1L = Frame(0, 31, 14, 17, 64, 4, 16, 0); // @ G0176_s_Graphic558_Frame_DoorFrameTop_D1L
 Frame g0177Frame_DoorFrameTop_D1C = Frame(48, 175, 14, 17, 64, 4, 0, 0); // @ G0177_s_Graphic558_Frame_DoorFrameTop_D1C
 Frame g0178Frame_DoorFrameTop_D1R = Frame(192, 223, 14, 17, 64, 4, 16, 0); // @ G0178_s_Graphic558_Frame_DoorFrameTop_D1R
+Frame g0110FrameStairsUpFront_D3L = Frame(0, 79, 25, 70, 40, 46, 0, 0); // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L
+Frame g0111FrameStairsUpFront_D3C = Frame(64, 159, 25, 70, 48, 46, 0, 0); // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C
+Frame g0112FrameStairsUpFront_D3R = Frame(149, 223, 25, 70, 40, 46, 5, 0); // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R
+Frame g0113FrameStairsUpFront_D2L = Frame(0, 63, 22, 83, 32, 62, 0, 0); // @ G0113_s_Graphic558_Frame_StairsUpFront_D2L
+Frame g0114FrameStairsUpFront_D2C = Frame(64, 159, 22, 83, 48, 62, 0, 0); // @ G0114_s_Graphic558_Frame_StairsUpFront_D2C
+Frame g0115FrameStairsUpFront_D2R = Frame(160, 223, 22, 83, 32, 62, 0, 0); // @ G0115_s_Graphic558_Frame_StairsUpFront_D2R
+Frame g0116FrameStairsUpFront_D1L = Frame(0, 31, 9, 108, 16, 100, 0, 0); // @ G0116_s_Graphic558_Frame_StairsUpFront_D1L
+Frame g0117FrameStairsUpFront_D1C = Frame(32, 191, 9, 108, 80, 100, 0, 0); // @ G0117_s_Graphic558_Frame_StairsUpFront_D1C
+Frame g0118FrameStairsUpFront_D1R = Frame(192, 223, 9, 108, 16, 100, 0, 0); // @ G0118_s_Graphic558_Frame_StairsUpFront_D1R
+Frame g0119FrameStairsUpFront_D0L = Frame(0, 31, 58, 101, 16, 44, 0, 0); // @ G0119_s_Graphic558_Frame_StairsUpFront_D0L
+Frame g0120FrameStairsUpFront_D0R = Frame(192, 223, 58, 101, 16, 44, 0, 0); // @ G0120_s_Graphic558_Frame_StairsUpFront_D0R
+Frame g0121FrameStairsDownFront_D3L = Frame(0, 79, 28, 68, 40, 41, 0, 0); // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L
+Frame g0122FrameStairsDownFront_D3C = Frame(64, 159, 28, 70, 48, 43, 0, 0); // @ G0122_s_Graphic558_Frame_StairsDownFront_D3C
+Frame g0123FrameStairsDownFront_D3R = Frame(149, 223, 28, 68, 40, 41, 5, 0); // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R
+Frame g0124FrameStairsDownFront_D2L = Frame(0, 63, 24, 85, 32, 62, 0, 0); // @ G0124_s_Graphic558_Frame_StairsDownFront_D2L
+Frame g0125FrameStairsDownFront_D2C = Frame(64, 159, 24, 85, 48, 62, 0, 0); // @ G0125_s_Graphic558_Frame_StairsDownFront_D2C
+Frame g0126FrameStairsDownFront_D2R = Frame(160, 223, 24, 85, 32, 62, 0, 0); // @ G0126_s_Graphic558_Frame_StairsDownFront_D2R
+Frame g0127FrameStairsDownFront_D1L = Frame(0, 31, 18, 108, 16, 91, 0, 0); // @ G0127_s_Graphic558_Frame_StairsDownFront_D1L
+Frame g0128FrameStairsDownFront_D1C = Frame(32, 191, 18, 108, 80, 91, 0, 0); // @ G0128_s_Graphic558_Frame_StairsDownFront_D1C
+Frame g0129FrameStairsDownFront_D1R = Frame(192, 223, 18, 108, 16, 91, 0, 0); // @ G0129_s_Graphic558_Frame_StairsDownFront_D1R
+Frame g0130FrameStairsDownFront_D0L = Frame(0, 31, 76, 135, 16, 60, 0, 0); // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L
+Frame g0131FrameStairsDownFront_D0R = Frame(192, 223, 76, 135, 16, 60, 0, 0); // @ G0131_s_Graphic558_Frame_StairsDownFront_D0R
+Frame g0132FrameStairsSide_D2L = Frame(60, 75, 57, 61, 8, 5, 0, 0); // @ G0132_s_Graphic558_Frame_StairsSide_D2L
+Frame g0133FrameStairsSide_D2R = Frame(148, 163, 57, 61, 8, 5, 0, 0); // @ G0133_s_Graphic558_Frame_StairsSide_D2R
+Frame g0134FrameStairsUpSide_D1L = Frame(32, 63, 57, 99, 16, 43, 0, 0); // @ G0134_s_Graphic558_Frame_StairsUpSide_D1L
+Frame g0135FrameStairsUpSide_D1R = Frame(160, 191, 57, 99, 16, 43, 0, 0); // @ G0135_s_Graphic558_Frame_StairsUpSide_D1R
+Frame g0136FrameStairsDownSide_D1L = Frame(32, 63, 60, 98, 16, 39, 0, 0); // @ G0136_s_Graphic558_Frame_StairsDownSide_D1L
+Frame g0137FrameStairsDownSide_D1R = Frame(160, 191, 60, 98, 16, 39, 0, 0); // @ G0137_s_Graphic558_Frame_StairsDownSide_D1R
+Frame g0138FrameStairsSide_D0L = Frame(0, 15, 73, 85, 8, 13, 0, 0); // @ G0138_s_Graphic558_Frame_StairsSide_D0L
+Frame g0139FrameStairsSide_D0R = Frame(208, 223, 73, 85, 8, 13, 0, 0); // @ G0139_s_Graphic558_Frame_StairsSide_D0R
 Frame g0140FrameFloorPit_D3L = Frame(0, 79, 66, 73, 40, 8, 0, 0); // @ G0140_s_Graphic558_Frame_FloorPit_D3L
 Frame g0141FrameFloorPit_D3C = Frame(64, 159, 66, 73, 48, 8, 0, 0); // @ G0141_s_Graphic558_Frame_FloorPit_D3C
 Frame g0142FrameFloorPit_D3R = Frame(144, 223, 66, 73, 40, 8, 0, 0); // @ G0142_s_Graphic558_Frame_FloorPit_D3R
@@ -1161,27 +1191,62 @@ T0116017_orangeElk:
 	}
 }
 
+// NOTE: has been screened for missing code
 void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
+	int16 order;
 	uint16 squareAspect[5];
+
+
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[0]) {
-	case kStairsFrontElemType:
-		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0675stairsNativeBitmapIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3R]);
-		else
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0682stairsNativeBitmapIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3R]);
-		break;
-	case kWallElemType:
+	switch (squareAspect[kElemAspect]) {
+	case kElementTypeStaisFront:
+		if (squareAspect[kStairsUpAspect]) {
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0675stairsNativeBitmapIndex_Up_Front_D3L, g0112FrameStairsUpFront_D3R);
+		} else {
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0682stairsNativeBitmapIndex_Down_Front_D3L, g0123FrameStairsDownFront_D3R);
+		}
+		goto T0117016;
+	case kElementTypeWall:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3R]);
 		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], kViewWall_D3R_LEFT);
 		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3R_FRONT)) {
-			// ... missing code
+			order = kCellOrder_Alcove;
+			goto T0117018;
 		}
-		break;
-	default:
-		break;
+		return;
+	case kElementTypeDoorSide:
+	case kElementTypeStairsSide:
+		order = kCellOrder_BackRight_BackLeft_FrontLeft;
+		goto T0117017;
+	case kElementTypeDoorFront:
+		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
+		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3R, kCellOrder_DoorPass1_BackRight_BackLeft);
+		memcpy(_tmpBitmap, _wallSetBitMaps[kDoorFrameLeft_D3L], 32 * 44);
+		warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally");
+		if (((Door*)_vm->_dungeonMan->_dunData._thingsData[kDoorThingType])[squareAspect[kDoorThingIndexAspect]].hasButton()) {
+			warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton");
+		}
+		warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor");
+		order = kCellOrder_DoorPass2_FrontRight_FrontLeft;
+		goto T0117018;
+	case kElementTypePit:
+		if (!squareAspect[kPitInvisibleAspect]) {
+		 drawFloorPitOrStairsBitmapFlippedHorizontally(k049FloorPit_D3L_GraphicIndice, g0142FrameFloorPit_D3R);
+		}
+	case kElementTypeTeleporter:
+	case kElementTypeCorridor:
+T0117016:
+		order = kCellOrder_BackRight_BackLeft_FrontRight_FrontLeft;
+T0117017:
+		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); 
+T0117018:
+		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3R, order);
+	}
+	if ((squareAspect[kElemAspect] == kElementTypeTeleporter) && squareAspect[kTeleporterVisibleAspect]) {
+		drawField(&gFieldAspects[kViewSquare_D3R], gFrameWalls[kViewSquare_D3R]._box);
 	}
 }
+
 void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);


Commit: e2300bd04c5aebe5736a5d0a431a9b85f53a9d17
    https://github.com/scummvm/scummvm/commit/e2300bd04c5aebe5736a5d0a431a9b85f53a9d17
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Massive renaming in gfx.h

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/objectman.cpp
    engines/dm/text.cpp
    engines/dm/text.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 730eaa2..fb2515b 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -118,10 +118,10 @@ int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) {
 
 void ChampionMan::drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) {
 	Common::String tmp = getStringFromInteger(currVal, true, 3).c_str();
-	_vm->_textMan->printToViewport(55, posY, kColorLightestGray, tmp.c_str());
-	_vm->_textMan->printToViewport(73, posY, kColorLightestGray, "/");
+	_vm->_textMan->printToViewport(55, posY, k13_ColorLightestGray, tmp.c_str());
+	_vm->_textMan->printToViewport(73, posY, k13_ColorLightestGray, "/");
 	tmp = getStringFromInteger(maxVal, true, 3);
-	_vm->_textMan->printToViewport(79, posY, kColorLightestGray, tmp.c_str());
+	_vm->_textMan->printToViewport(79, posY, k13_ColorLightestGray, tmp.c_str());
 }
 
 uint16 ChampionMan::handSlotIndex(uint16 slotBoxIndex) {
@@ -458,18 +458,18 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	uint16 prevChampCount = _partyChampionCount;
 	Champion *champ = &_champions[prevChampCount];
 	champ->resetToZero();
-	dispMan._useByteBoxCoordinates = true;
+	dispMan._g578_useByteBoxCoordinates = true;
 	{ // limit destBox scope
 		Box &destBox = gBoxChampionPortrait;
-		dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex),
-							 champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency);
+		dispMan.blitToBitmap(dispMan.getBitmap(k26_ChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex),
+							 champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, k255_ColorNoTransparency);
 	}
 
 	champ->_actionIndex = kChampionActionNone;
 	champ->_enableActionEventIndex = -1;
 	champ->_hideDamageReceivedIndex = -1;
 	champ->_dir = dunMan._currMap._partyDir;
-	ViewCell AL_0_viewCell = kViewCellFronLeft;
+	ViewCell AL_0_viewCell = k0_ViewCellFronLeft;
 	while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone)
 		AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
 	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3);
@@ -732,26 +732,26 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		return;
 	}
 	bool isInventoryChamp = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
-	dispMan._useByteBoxCoordinates = false;
+	dispMan._g578_useByteBoxCoordinates = false;
 	if (champAttributes & kChampionAttributeStatusBox) {
 		box._y1 = 0;
 		box._y2 = 28 + 1;
 		box._x1 = champStatusBoxX;
 		box._x2 = box._x1 + 66 + 1;
 		if (champ->_currHealth) {
-			dispMan.clearScreenBox(kColorDarkestGray, box);
+			dispMan.clearScreenBox(k12_ColorDarkestGray, box);
 			int16 nativeBitmapIndices[3];
 			for (int16 i = 0; i < 3; ++i)
 				nativeBitmapIndices[i] = 0;
 			int16 AL_0_borderCount = 0;
 			if (_party._fireShieldDefense > 0)
-				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyFireshieldIndice;
+				nativeBitmapIndices[AL_0_borderCount++] = k38_BorderPartyFireshieldIndice;
 			if (_party._spellShieldDefense > 0)
-				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartySpellshieldIndice;
+				nativeBitmapIndices[AL_0_borderCount++] = k39_BorderPartySpellshieldIndice;
 			if (_party._shieldDefense > 0)
-				nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyShieldIndice;
+				nativeBitmapIndices[AL_0_borderCount++] = k37_BorderPartyShieldIndice;
 			while (AL_0_borderCount--) {
-				dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, kColorFlesh);
+				dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, k10_ColorFlesh);
 			}
 			if (isInventoryChamp) {
 				invMan.drawStatusBoxPortrait(champIndex);
@@ -760,8 +760,8 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 				champAttributes |= (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeWounds | kChampionAttributeActionHand);
 			}
 		} else {
-			dispMan.blitToScreen(dispMan.getBitmap(kStatusBoxDeadChampion), 80, 0, 0, box, kColorNoTransparency);
-			_vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, kColorLightestGray, kColorDarkGary, champ->_name);
+			dispMan.blitToScreen(dispMan.getBitmap(k8_StatusBoxDeadChampion), 80, 0, 0, box, k255_ColorNoTransparency);
+			_vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, champ->_name);
 			menuMan.drawActionIcon(champIndex);
 			goto T0292042_green;
 		}
@@ -771,7 +771,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		goto T0292042_green;
 
 	if (champAttributes & kChampionAttributeNameTitle) {
-		Color AL_0_colorIndex = (champIndex == _leaderIndex) ? kColorGold : kColorLightestGray; // unused because of missing functions
+		Color AL_0_colorIndex = (champIndex == _leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; // unused because of missing functions
 		if (isInventoryChamp) {
 			char *champName = champ->_name;
 			_vm->_textMan->printToViewport(3, 7, AL_0_colorIndex, champName);
@@ -787,8 +787,8 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			box._y2 = 6 + 1;
 			box._x1 = champStatusBoxX;
 			box._x2 = box._x1 + 42 + 1;
-			dispMan.clearScreenBox(kColorDarkGary, box);
-			_vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, kColorDarkGary, champ->_name);
+			dispMan.clearScreenBox(k1_ColorDarkGary, box);
+			_vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, k1_ColorDarkGary, champ->_name);
 		}
 	}
 
@@ -798,20 +798,20 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			drawHealthStaminaManaValues(champ);
 			int16 AL_2_nativeBitmapIndex;
 			if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) {
-				AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice;
+				AL_2_nativeBitmapIndex = k34_SlotBoxWoundedIndice;
 			} else {
-				AL_2_nativeBitmapIndex = kSlotBoxNormalIndice;
+				AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			}
-			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, kColorDarkestGray, gDungeonViewport);
-			AL_2_nativeBitmapIndex = kSlotBoxNormalIndice;
+			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, k12_ColorDarkestGray, gDungeonViewport);
+			AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) {
 				if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent)
 					< champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum)) {
-					AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice;
+					AL_2_nativeBitmapIndex = k34_SlotBoxWoundedIndice;
 					break;
 				}
 			}
-			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, kColorDarkestGray, gDungeonViewport);
+			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, k12_ColorDarkestGray, gDungeonViewport);
 			champAttributes |= kChampionAttributeViewport;
 		}
 	}
@@ -829,11 +829,11 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		Color loadColor;
 		int16 champMaxLoad = getMaximumLoad(champ);
 		if (champ->_load > champMaxLoad) {
-			loadColor = kColorRed;
+			loadColor = k8_ColorRed;
 		} else if (((int32)champ->_load) * 8 > ((int32)champMaxLoad) * 5) {
-			loadColor = kColorYellow;
+			loadColor = k11_ColorYellow;
 		} else {
-			loadColor = kColorLightestGray;
+			loadColor = k13_ColorLightestGray;
 		}
 		_vm->_textMan->printToViewport(104, 132, loadColor, "LOAD ");
 
@@ -852,10 +852,10 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	{ // block so goto won't skip AL_0_championIconIndex initialization 
 		int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir);
 
-		if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) {
+		if ((champAttributes & k28_ChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) {
 			dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]);
-			dispMan.blitToScreen(dispMan.getBitmap(kChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0,
-								 gBoxChampionIcons[AL_0_championIconIndex], kColorDarkestGray);
+			dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0,
+								 gBoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray);
 		}
 	}
 
@@ -942,9 +942,9 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 			iconIndex = kIconIndiceReadyHand + (slotIndex << 1);
 			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) {
 				iconIndex++;
-				nativeBitmapIndex = kSlotBoxWoundedIndice;
+				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
 			} else {
-				nativeBitmapIndex = kSlotBoxNormalIndice;
+				nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			}
 		} else {
 			if ((slotIndex >= kChampionSlotNeck) && (slotIndex <= kChampionSlotBackpackLine_1_1)) {
@@ -962,21 +962,21 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 		} // BUG2_00
 		if (slotIndex <= kChampionSlotFeet) {
 			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) {
-				nativeBitmapIndex = kSlotBoxWoundedIndice;
+				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
 			} else {
-				nativeBitmapIndex = kSlotBoxNormalIndice;
+				nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			}
 		}
 	}
 
 	if ((slotIndex == kChampionSlotActionHand) && (_vm->indexToOrdinal(champIndex) == _actingChampionOrdinal)) {
-		nativeBitmapIndex = kSlotBoxActingHandIndice;
+		nativeBitmapIndex = k35_SlotBoxActingHandIndice;
 	}
 
 	if (nativeBitmapIndex != -1) {
-		_vm->_displayMan->_useByteBoxCoordinates = false;
+		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		_vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0,
-									   box, kColorDarkestGray, isInventoryChamp ? gDungeonViewport : gDefultViewPort);
+									   box, k12_ColorDarkestGray, isInventoryChamp ? gDungeonViewport : gDefultViewPort);
 	}
 
 	_vm->_objectMan->drawIconInSlotBox(slotBoxIndex, iconIndex);
@@ -998,10 +998,10 @@ void ChampionMan::renameChampion(Champion* champ) {
 	box._x1 = 3;
 	box._x2 = box._x1 + 167;
 
-	dispMan.clearScreenBox(kColorDarkestGray, box, gDungeonViewport);
-	dispMan.blitToScreen(dispMan.getBitmap(kPanelRenameChampionIndice), 144, 0, 0, gBoxPanel, kColorCyan, gDungeonViewport);
-	textMan.printToViewport(177, 58, kColorLightestGray, "_______");
-	textMan.printToViewport(105, 76, kColorLightestGray, "___________________");
+	dispMan.clearScreenBox(k12_ColorDarkestGray, box, gDungeonViewport);
+	dispMan.blitToScreen(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, gBoxPanel, k4_ColorCyan, gDungeonViewport);
+	textMan.printToViewport(177, 58, k13_ColorLightestGray, "_______");
+	textMan.printToViewport(105, 76, k13_ColorLightestGray, "___________________");
 	Common::Point clickPos;
 	static Box okButtonBox(197, 215, 147, 155); // inclusive boundaries, constructor adds +1
 	for (;;) {
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index e0390a4..c1abca1 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -408,7 +408,7 @@ public:
 		memset(_name, '\0', 8);
 		memset(_title, '\0', 20);
 		_dir = kDirNorth;
-		_cell = kViewCellFronLeft;
+		_cell = k0_ViewCellFronLeft;
 		_actionIndex = kChampionActionN;
 		_symbolStep = 0;
 		memset(_symbols, '\0', 5);
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 66a1125..be8da8b 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -144,7 +144,7 @@ DMEngine::~DMEngine() {
 void DMEngine::initializeGame() {
 	_displayMan->loadGraphics();
 	// DUMMY CODE: next line
-	_displayMan->loadPalette(gPalCredits);
+	_displayMan->loadPalette(g19_PalCredits);
 
 	_eventMan->initMouse();
 
@@ -152,8 +152,8 @@ void DMEngine::initializeGame() {
 		warning("TODO: F0441_STARTEND_ProcessEntrance");
 	}
 
-	_displayMan->loadFloorSet(kFloorSetStone);
-	_displayMan->loadWallSet(kWallSetStone);
+	_displayMan->loadFloorSet(k0_FloorSetStone);
+	_displayMan->loadWallSet(k0_WallSetStone);
 	_objectMan->loadObjectNames();
 
 	startGame();
@@ -184,7 +184,7 @@ void DMEngine::startGame() {
 	if (!_dungeonMan->_messages._newGame) {
 		warning("TODO: loading game");
 	} else {
-		_displayMan->_useByteBoxCoordinates = false;
+		_displayMan->_g578_useByteBoxCoordinates = false;
 		warning("TODO: clear screen");
 	}
 
@@ -253,7 +253,7 @@ void DMEngine::gameloop() {
 
 		if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) {
 			Box box(0, 224, 0, 126);
-			_displayMan->clearScreenBox(kColorBlack, box, gDungeonViewport); // dummy code
+			_displayMan->clearScreenBox(k0_ColorBlack, box, gDungeonViewport); // dummy code
 			_displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY);
 		}
 		// DUMMY CODE: next line
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 8d5c99b..1d74bec 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -328,7 +328,7 @@ WeaponInfo gWeaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo
 	WeaponInfo(30, 26,   1, 220, 0x207D),   /* SPEEDBOW */
 	WeaponInfo(36, 255, 100,  50, 0x20FF)}; /* THE FIRESTAFF */
 
-CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo
+CreatureInfo gCreatureInfo[k27_CreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo
 												   /* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo,
 												   MovementTicks, AttackTicks, Defense, BaseHealth, Attack, PoisonAttack,
 												   Dexterity, Ranges, Properties, Resistances, AnimationTicks, WoundProbabilities, AttackType } */
@@ -742,19 +742,19 @@ void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) {
 	setCurrentMap(mapIndex);
 
 	byte *metaMapData = _currMap._data[_currMap._width - 1] + _currMap._height;
-	_vm->_displayMan->_currMapAllowedCreatureTypes = metaMapData;
+	_vm->_displayMan->_g264_currMapAllowedCreatureTypes = metaMapData;
 
 	metaMapData += _currMap._map->_creatureTypeCount;
-	memcpy(_vm->_displayMan->_currMapWallOrnIndices, metaMapData, _currMap._map->_wallOrnCount);
+	memcpy(_vm->_displayMan->_g261_currMapWallOrnIndices, metaMapData, _currMap._map->_wallOrnCount);
 
 	metaMapData += _currMap._map->_wallOrnCount;
-	memcpy(_vm->_displayMan->_currMapFloorOrnIndices, metaMapData, _currMap._map->_floorOrnCount);
+	memcpy(_vm->_displayMan->_g262_currMapFloorOrnIndices, metaMapData, _currMap._map->_floorOrnCount);
 
 	metaMapData += _currMap._map->_wallOrnCount;
-	memcpy(_vm->_displayMan->_currMapDoorOrnIndices, metaMapData, _currMap._map->_doorOrnCount);
+	memcpy(_vm->_displayMan->_g263_currMapDoorOrnIndices, metaMapData, _currMap._map->_doorOrnCount);
 
 	_currMapInscriptionWallOrnIndex = _currMap._map->_wallOrnCount;
-	_vm->_displayMan->_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = kWallOrnInscription;
+	_vm->_displayMan->_g261_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = k0_WallOrnInscription;
 }
 
 
@@ -817,7 +817,7 @@ Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) {
 
 // TODO: get rid of the GOTOs
 void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) {	// complete, except where marked
-	_vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75, possible fix
+	_vm->_displayMan->_g289_championPortraitOrdinal = 0; // BUG0_75, possible fix
 
 	for (uint16 i = 0; i < 5; ++i)
 		aspectArray[i] = 0;
@@ -868,13 +868,13 @@ T0172010_ClosedFakeWall:
 				if (thing.getType() == kTextstringType) {
 					if (TextString(getThingData(thing)).isVisible()) {
 						aspectArray[sideIndex + 1] = _currMapInscriptionWallOrnIndex + 1;
-						_vm->_displayMan->_inscriptionThing = thing; // BUG0_76
+						_vm->_displayMan->_g290_inscriptionThing = thing; // BUG0_76
 					}
 				} else {
 					Sensor sensor(getThingData(thing));
 					aspectArray[sideIndex + 1] = sensor.getOrnOrdinal();
 					if (sensor.getType() == kSensorWallChampionPortrait) {
-						_vm->_displayMan->_championPortraitOrdinal = _vm->indexToOrdinal(sensor.getData());
+						_vm->_displayMan->_g289_championPortraitOrdinal = _vm->indexToOrdinal(sensor.getData());
 					}
 				}
 			}
@@ -978,8 +978,8 @@ int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int
 
 bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) {
 	if (wallOrnIndex >= 0)
-		for (uint16 i = 0; i < kAlcoveOrnCount; ++i)
-			if (_vm->_displayMan->_currMapAlcoveOrnIndices[i] == wallOrnIndex)
+		for (uint16 i = 0; i < k3_AlcoveOrnCount; ++i)
+			if (_vm->_displayMan->_g267_currMapAlcoveOrnIndices[i] == wallOrnIndex)
 				return true;
 	return false;
 }
@@ -1307,15 +1307,15 @@ int16 DungeonMan::getProjectileAspect(Thing thing) {
 
 	if ((thingType = thing.getType()) == kExplosionThingType) {
 		if (thing == Thing::_explFireBall)
-			return -_vm->indexToOrdinal(kProjectileAspectExplosionFireBall);
+			return -_vm->indexToOrdinal(k10_ProjectileAspectExplosionFireBall);
 		if (thing == Thing::_explSlime)
-			return -_vm->indexToOrdinal(kProjectileAspectExplosionSlime);
+			return -_vm->indexToOrdinal(k12_ProjectileAspectExplosionSlime);
 		if (thing == Thing::_explLightningBolt)
-			return -_vm->indexToOrdinal(kProjectileAspectExplosionLightningBolt);
+			return -_vm->indexToOrdinal(k3_ProjectileAspectExplosionLightningBolt);
 		if ((thing == Thing::_explPoisonBolt) || (thing == Thing::_explPoisonCloud))
-			return -_vm->indexToOrdinal(kProjectileAspectExplosionPoisonBoltCloud);
+			return -_vm->indexToOrdinal(k13_ProjectileAspectExplosionPoisonBoltCloud);
 
-		return -_vm->indexToOrdinal(kProjectileAspectExplosionDefault);
+		return -_vm->indexToOrdinal(k11_ProjectileAspectExplosionDefault);
 	} else if (thingType == kWeaponThingType) {
 		weaponInfo = getWeaponInfo(thing);
 		if (projAspOrd = weaponInfo->getProjectileAspectOrdinal())
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index df56ec2..b3f81d8 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -202,7 +202,7 @@ struct CreatureInfo {
 }; // @ CREATURE_INFO
 
 
-extern CreatureInfo gCreatureInfo[kCreatureTypeCount];
+extern CreatureInfo gCreatureInfo[k27_CreatureTypeCount];
 
 class Door {
 	Thing _nextThing;
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index e9abf94..1adb396 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -529,7 +529,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 			int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir];
 
 			if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() &&
-				dunMan._dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
+				dunMan._dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
 				_vm->_stopWaitingForPlayerInput = true;
 				warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 				warning("MISSING CODE: F0268_SENSOR_AddEvent");
@@ -541,9 +541,9 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 	}
 
 	if (champMan._leaderEmptyHanded) {
-		for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellDoorButtonOrWallOrn; viewCell++) {
+		for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k5_ViewCellDoorButtonOrWallOrn; viewCell++) {
 			if (dunMan._dungeonViewClickableBoxes[viewCell].isPointInside(Common::Point(posX, posY - 33))) {
-				if (viewCell == kViewCellDoorButtonOrWallOrn) {
+				if (viewCell == k5_ViewCellDoorButtonOrWallOrn) {
 					if (!dunMan._isFacingAlcove) {
 						commandProcessType80ClickInDungeonViewTouchFrontWall();
 					}
@@ -557,14 +557,14 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 		Thing thing = champMan._leaderHandObject;
 		uint16 *rawThingPointer = dunMan.getThingData(thing);
 		if (dunMan._squareAheadElement == kElementTypeWall) {
-			for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellFrontRight; ++viewCell) {
+			for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k1_ViewCellFrontRight; ++viewCell) {
 				if (gBoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) {
 					warning("F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject");
 					return;
 				}
 			}
 
-			if (dunMan._dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
+			if (dunMan._dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
 				if (dunMan._isFacingAlcove) {
 					warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject");
 				} else {
@@ -587,7 +587,7 @@ T0377019:
 			}
 		} else {
 			warning("MISSING CODE: F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown in if branch");
-			for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellBackLeft; viewCell++) {
+			for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k3_ViewCellBackLeft; viewCell++) {
 				if (gBoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) {
 					warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject");
 					return;
@@ -618,9 +618,9 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 		box._y2 = 28 + 1;
 		box._x1 = championIndex * kChampionStatusBoxSpacing;
 		box._x2 = box._x1 + 66 + 1;
-		dispMan._useByteBoxCoordinates = false;
-		dispMan.clearScreenBox(kColorBlack, box);
-		dispMan.clearScreenBox(kColorBlack, gBoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._partyDir) * 2]);
+		dispMan._g578_useByteBoxCoordinates = false;
+		dispMan.clearScreenBox(k0_ColorBlack, box);
+		dispMan.clearScreenBox(k0_ColorBlack, gBoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._partyDir) * 2]);
 		warning("F0457_START_DrawEnabledMenus_CPSF");
 		warning("F0078_MOUSE_ShowPointer");
 		return;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index ce31c49..f6b1b02 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -121,11 +121,11 @@ FieldAspect gFieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects
 	FieldAspect(0, 63, 0x0A, 0x83, 16, 136,  0, 64),   /* D0L */
 	FieldAspect(0, 63, 0x0A, 0x03, 16, 136,  0, 64)}; /* D0R */
 
-Box gBoxMovementArrows = Box(224, 319, 124, 168);
+Box g2_BoxMovementArrows = Box(224, 319, 124, 168);
 
 byte gPalChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke
 
-ExplosionAspect gExplosionAspects[kExplosionAspectCount] = { // @ G0211_as_Graphic558_ExplosionAspects
+ExplosionAspect g211_ExplosionAspects[k4_ExplosionAspectCount] = { // @ G0211_as_Graphic558_ExplosionAspects
 	/* { ByteWidth, Height } */
 	ExplosionAspect(80, 111),   /* Fire   */
 ExplosionAspect(64,  97),   /* Spell  */
@@ -134,7 +134,7 @@ ExplosionAspect(80,  91)}; /* Death  */
 
 #define kDerivedBitmapMaximumCount 730 // @ C730_DERIVED_BITMAP_MAXIMUM_COUNT
 
-byte gProjectileScales[7] = {
+byte g215_ProjectileScales[7] = {
 	13,   /* D4 Back  */
 	16,   /* D4 Front */
 	19,   /* D3 Back  */
@@ -490,39 +490,39 @@ byte gWallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoord
 	6,   /* Wall Ornament 58 Amalgam (Without Gem) */
 	7}; /* Wall Ornament 59 Lord Order (Outside) */
 
-CreatureAspect gCreatureAspects[kCreatureTypeCount] = { // @ G0219_as_Graphic558_CreatureAspects
-/* { FirstNativeBitmapRelativeIndex, FirstDerivedBitmapIndex, pixelWidthFront, HeightFront,
-pixelWidthSide, HeightSide, pixelWidthAttack, HeightAttack, CoordinateSet / TransparentColor,
-Replacement Color Set Index for color 10 / Replacement Color Set Index for color 9 } */
-	{0, 0, 56 * 2,  84, 56 * 2,  84, 56 * 2,  84, 0x1D, 0x01},   /* Creature #00 Giant Scorpion / Scorpion */
-	{4, 0, 32 * 2,  66,  0 * 2,   0, 32 * 2,  69, 0x0B, 0x20},   /* Creature #01 Swamp Slime / Slime Devil */
-	{6, 0, 24 * 2,  48, 24 * 2,  48,  0 * 2,   0, 0x0B, 0x00},   /* Creature #02 Giggler */
-	{10, 0, 32 * 2,  61,  0 * 2,   0, 32 * 2,  61, 0x24, 0x31},   /* Creature #03 Wizard Eye / Flying Eye */
-	{12, 0, 32 * 2,  64, 56 * 2,  64, 32 * 2,  64, 0x14, 0x34},   /* Creature #04 Pain Rat / Hellhound */
-	{16, 0, 24 * 2,  49, 40 * 2,  49,  0 * 2,   0, 0x18, 0x34},   /* Creature #05 Ruster */
-	{19, 0, 32 * 2,  60,  0 * 2,   0, 32 * 2,  60, 0x0D, 0x00},   /* Creature #06 Screamer */
-	{21, 0, 32 * 2,  43,  0 * 2,   0, 32 * 2,  64, 0x04, 0x00},   /* Creature #07 Rockpile / Rock pile */
-	{23, 0, 32 * 2,  83,  0 * 2,   0, 32 * 2,  93, 0x04, 0x00},   /* Creature #08 Ghost / Rive */
-	{25, 0, 32 * 2, 101, 32 * 2, 101, 32 * 2, 101, 0x14, 0x00},   /* Creature #09 Stone Golem */
-	{29, 0, 32 * 2,  82, 32 * 2,  82, 32 * 2,  83, 0x04, 0x00},   /* Creature #10 Mummy */
-	{33, 0, 32 * 2,  80,  0 * 2,   0, 32 * 2,  99, 0x14, 0x00},   /* Creature #11 Black Flame */
-	{35, 0, 32 * 2,  80, 32 * 2,  80, 32 * 2,  76, 0x04, 0x00},   /* Creature #12 Skeleton */
-	{39, 0, 32 * 2,  96, 56 * 2,  93, 32 * 2,  90, 0x1D, 0x20},   /* Creature #13 Couatl */
-	{43, 0, 32 * 2,  49, 16 * 2,  49, 32 * 2,  56, 0x04, 0x30},   /* Creature #14 Vexirk */
-	{47, 0, 32 * 2,  59, 56 * 2,  43, 32 * 2,  67, 0x14, 0x78},   /* Creature #15 Magenta Worm / Worm */
-	{51, 0, 32 * 2,  83, 32 * 2,  74, 32 * 2,  74, 0x04, 0x65},   /* Creature #16 Trolin / Ant Man */
-	{55, 0, 24 * 2,  49, 24 * 2,  53, 24 * 2,  53, 0x24, 0x00},   /* Creature #17 Giant Wasp / Muncher */
-	{59, 0, 32 * 2,  89, 32 * 2,  89, 32 * 2,  89, 0x04, 0x00},   /* Creature #18 Animated Armour / Deth Knight */
-	{63, 0, 32 * 2,  84, 32 * 2,  84, 32 * 2,  84, 0x0D, 0xA9},   /* Creature #19 Materializer / Zytaz */
-	{67, 0, 56 * 2,  27,  0 * 2,   0, 56 * 2,  80, 0x04, 0x65},   /* Creature #20 Water Elemental */
-	{69, 0, 56 * 2,  77, 56 * 2,  81, 56 * 2,  77, 0x04, 0xA9},   /* Creature #21 Oitu */
-	{73, 0, 32 * 2,  87, 32 * 2,  89, 32 * 2,  89, 0x04, 0xCB},   /* Creature #22 Demon */
-	{77, 0, 32 * 2,  96, 32 * 2,  94, 32 * 2,  96, 0x04, 0x00},   /* Creature #23 Lord Chaos */
-	{81, 0, 64 * 2,  94, 72 * 2,  94, 64 * 2,  94, 0x04, 0xCB},   /* Creature #24 Red Dragon / Dragon */
-	{85, 0, 32 * 2,  93,  0 * 2,   0,  0 * 2,   0, 0x04, 0xCB},   /* Creature #25 Lord Order */
-	{86, 0, 32 * 2,  93,  0 * 2,   0,  0 * 2,   0, 0x04, 0xCB}}; /* Creature #26 Grey Lord */
-
-ObjectAspect gObjectAspects[kObjAspectCount] = { // @ G0209_as_Graphic558_ObjectAspects
+CreatureAspect gCreatureAspects[k27_CreatureTypeCount] = { // @ G0219_as_Graphic558_CreatureAspects
+														   /* { FirstNativeBitmapRelativeIndex, FirstDerivedBitmapIndex, pixelWidthFront, HeightFront,
+														   pixelWidthSide, HeightSide, pixelWidthAttack, HeightAttack, CoordinateSet / TransparentColor,
+														   Replacement Color Set Index for color 10 / Replacement Color Set Index for color 9 } */
+	CreatureAspect(0, 0, 56 ,  84, 56 ,  84, 56 ,  84, 0x1D, 0x01),   /* Creature #00 Giant Scorpion / Scorpion */
+	CreatureAspect(4, 0, 32 ,  66,  0 ,   0, 32 ,  69, 0x0B, 0x20),   /* Creature #01 Swamp Slime / Slime Devil */
+	CreatureAspect(6, 0, 24 ,  48, 24 ,  48,  0 ,   0, 0x0B, 0x00),   /* Creature #02 Giggler */
+	CreatureAspect(10, 0, 32 ,  61,  0 ,   0, 32 ,  61, 0x24, 0x31),   /* Creature #03 Wizard Eye / Flying Eye */
+	CreatureAspect(12, 0, 32 ,  64, 56 ,  64, 32 ,  64, 0x14, 0x34),   /* Creature #04 Pain Rat / Hellhound */
+	CreatureAspect(16, 0, 24 ,  49, 40 ,  49,  0 ,   0, 0x18, 0x34),   /* Creature #05 Ruster */
+	CreatureAspect(19, 0, 32 ,  60,  0 ,   0, 32 ,  60, 0x0D, 0x00),   /* Creature #06 Screamer */
+	CreatureAspect(21, 0, 32 ,  43,  0 ,   0, 32 ,  64, 0x04, 0x00),   /* Creature #07 Rockpile / Rock pile */
+	CreatureAspect(23, 0, 32 ,  83,  0 ,   0, 32 ,  93, 0x04, 0x00),   /* Creature #08 Ghost / Rive */
+	CreatureAspect(25, 0, 32 , 101, 32 , 101, 32 , 101, 0x14, 0x00),   /* Creature #09 Stone Golem */
+	CreatureAspect(29, 0, 32 ,  82, 32 ,  82, 32 ,  83, 0x04, 0x00),   /* Creature #10 Mummy */
+	CreatureAspect(33, 0, 32 ,  80,  0 ,   0, 32 ,  99, 0x14, 0x00),   /* Creature #11 Black Flame */
+	CreatureAspect(35, 0, 32 ,  80, 32 ,  80, 32 ,  76, 0x04, 0x00),   /* Creature #12 Skeleton */
+	CreatureAspect(39, 0, 32 ,  96, 56 ,  93, 32 ,  90, 0x1D, 0x20),   /* Creature #13 Couatl */
+	CreatureAspect(43, 0, 32 ,  49, 16 ,  49, 32 ,  56, 0x04, 0x30),   /* Creature #14 Vexirk */
+	CreatureAspect(47, 0, 32 ,  59, 56 ,  43, 32 ,  67, 0x14, 0x78),   /* Creature #15 Magenta Worm / Worm */
+	CreatureAspect(51, 0, 32 ,  83, 32 ,  74, 32 ,  74, 0x04, 0x65),   /* Creature #16 Trolin / Ant Man */
+	CreatureAspect(55, 0, 24 ,  49, 24 ,  53, 24 ,  53, 0x24, 0x00),   /* Creature #17 Giant Wasp / Muncher */
+	CreatureAspect(59, 0, 32 ,  89, 32 ,  89, 32 ,  89, 0x04, 0x00),   /* Creature #18 Animated Armour / Deth Knight */
+	CreatureAspect(63, 0, 32 ,  84, 32 ,  84, 32 ,  84, 0x0D, 0xA9),   /* Creature #19 Materializer / Zytaz */
+	CreatureAspect(67, 0, 56 ,  27,  0 ,   0, 56 ,  80, 0x04, 0x65),   /* Creature #20 Water Elemental */
+	CreatureAspect(69, 0, 56 ,  77, 56 ,  81, 56 ,  77, 0x04, 0xA9),   /* Creature #21 Oitu */
+	CreatureAspect(73, 0, 32 ,  87, 32 ,  89, 32 ,  89, 0x04, 0xCB),   /* Creature #22 Demon */
+	CreatureAspect(77, 0, 32 ,  96, 32 ,  94, 32 ,  96, 0x04, 0x00),   /* Creature #23 Lord Chaos */
+	CreatureAspect(81, 0, 64 ,  94, 72 ,  94, 64 ,  94, 0x04, 0xCB),   /* Creature #24 Red Dragon / Dragon */
+	CreatureAspect(85, 0, 32 ,  93,  0 ,   0,  0 ,   0, 0x04, 0xCB),   /* Creature #25 Lord Order */
+	CreatureAspect(86, 0, 32 ,  93,  0 ,   0,  0 ,   0, 0x04, 0xCB)}; /* Creature #26 Grey Lord */
+
+ObjectAspect gObjectAspects[k85_ObjAspectCount] = { // @ G0209_as_Graphic558_ObjectAspects
 	/* FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo, CoordinateSet */
 	ObjectAspect(0,   0, 24, 27, 0x11, 0),
 	ObjectAspect(2,   6, 24,  8, 0x00, 1),
@@ -611,7 +611,7 @@ ObjectAspect gObjectAspects[kObjAspectCount] = { // @ G0209_as_Graphic558_Object
 	ObjectAspect(85, 176, 32, 17, 0x00, 0)
 };
 
-ProjectileAspect gProjectileAspect[kProjectileAspectCount] = { // @ G0210_as_Graphic558_ProjectileAspects
+ProjectileAspect gProjectileAspect[k14_ProjectileAspectCount] = { // @ G0210_as_Graphic558_ProjectileAspects
 	/* ProjectileAspect( FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo ) */
 	ProjectileAspect(0,   0, 32, 11, 0x0011),   /* Arrow */
 	ProjectileAspect(3,  18, 16, 11, 0x0011),   /* Dagger */
@@ -632,13 +632,13 @@ ProjectileAspect gProjectileAspect[kProjectileAspectCount] = { // @ G0210_as_Gra
 // TODO: this is ONLY for the Amiga version, name will have to be refactored
 
 /* Identical to the palette at the end of the swoosh palette animation */
-uint16 gPalSwoosh[16] = {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}; // @ K0057_aui_Palette_Swoosh
-uint16 gPalMousePointer[16] = {0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x000, 0xAAA, 0x00F, 0xFFF}; // @ K0150_aui_Palette_MousePointer
+uint16 gK57_PalSwoosh[16] = {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}; // @ K0057_aui_Palette_Swoosh
+uint16 gK150_PalMousePointer[16] = {0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x000, 0xAAA, 0x00F, 0xFFF}; // @ K0150_aui_Palette_MousePointer
 /* Atari ST: { 0x003, 0x055, 0x773, 0x420, 0x774, 0x000, 0x040, 0x500, 0x642, 0x775, 0x742, 0x760, 0x750, 0x000, 0x310, 0x776 }, RGB colors are different */
-uint16 gPalCredits[16] = {0x006, 0x0AA, 0xFF6, 0x840, 0xFF8, 0x000, 0x080, 0xA00, 0xC84, 0xFFA, 0xF84, 0xFC0, 0xFA0, 0x000, 0x620, 0xFFC}; // @ G0019_aui_Graphic562_Palette_Credits
+uint16 g19_PalCredits[16] = {0x006, 0x0AA, 0xFF6, 0x840, 0xFF8, 0x000, 0x080, 0xA00, 0xC84, 0xFFA, 0xF84, 0xFC0, 0xFA0, 0x000, 0x620, 0xFFC}; // @ G0019_aui_Graphic562_Palette_Credits
 /* Atari ST: { 0x000, 0x333, 0x444, 0x420, 0x654, 0x210, 0x040, 0x050, 0x432, 0x700, 0x543, 0x321, 0x222, 0x555, 0x310, 0x777 }, RGB colors are different */
-uint16 gPalEntrance[16] = {0x000, 0x666, 0x888, 0x840, 0xCA8, 0x0C0, 0x080, 0x0A0, 0x864, 0xF00, 0xA86, 0x642, 0x444, 0xAAA, 0x620, 0xFFF}; // @ G0020_aui_Graphic562_Palette_Entrance
-uint16 gPalDungeonView[6][16] = { // @ G0021_aaui_Graphic562_Palette_DungeonView
+uint16 g20_PalEntrance[16] = {0x000, 0x666, 0x888, 0x840, 0xCA8, 0x0C0, 0x080, 0x0A0, 0x864, 0xF00, 0xA86, 0x642, 0x444, 0xAAA, 0x620, 0xFFF}; // @ G0020_aui_Graphic562_Palette_Entrance
+uint16 g21_PalDungeonView[6][16] = { // @ G0021_aaui_Graphic562_Palette_DungeonView
 	/* Atari ST: { 0x000, 0x333, 0x444, 0x310, 0x066, 0x420, 0x040, 0x060, 0x700, 0x750, 0x643, 0x770, 0x222, 0x555, 0x007, 0x777 }, RGB colors are different */
 	0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x444, 0xAAA, 0x00F, 0xFFF,
 	/* Atari ST: { 0x000, 0x222, 0x333, 0x310, 0x066, 0x410, 0x030, 0x050, 0x600, 0x640, 0x532, 0x760, 0x111, 0x444, 0x006, 0x666 }, RGB colors are different */
@@ -684,8 +684,8 @@ byte gPalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110
 byte gPalChangesFloorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 140, 130}; // @ G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3
 byte gPalChangesFloorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2
 
-int gFountainOrnIndices[kFountainOrnCount] = {35}; // @ G0193_ai_Graphic558_FountainOrnamentIndices
-byte gAlcoveOrnIndices[kAlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrnamentIndices
+int gFountainOrnIndices[k1_FountainOrnCount] = {35}; // @ G0193_ai_Graphic558_FountainOrnamentIndices
+byte gAlcoveOrnIndices[k3_AlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrnamentIndices
 	1,   /* Square Alcove */
 	2,   /* Vi Altar */
 	3};  /* Arched Alcove */
@@ -698,52 +698,49 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_packedItemPos = nullptr;
 	_packedBitmaps = nullptr;
 	_bitmaps = nullptr;
-	_tmpBitmap = nullptr;
-	_floorBitmap = nullptr;
-	_ceilingBitmap = nullptr;
-	_currMapAllowedCreatureTypes = nullptr;
-	_derivedBitmapByteCount = nullptr;
-	_derivedBitmaps = nullptr;
+	_g74_tmpBitmap = nullptr;
+	_g84_floorBitmap = nullptr;
+	_g85_ceilingBitmap = nullptr;
+	_g264_currMapAllowedCreatureTypes = nullptr;
+	_g639_derivedBitmapByteCount = nullptr;
+	_g638_derivedBitmaps = nullptr;
 
 	_screenWidth = _screenHeight = 0;
-	_championPortraitOrdinal = 0;
-	_currMapViAltarIndex = 0;
+	_g289_championPortraitOrdinal = 0;
+	_g266_currMapViAltarIndex = 0;
 
 	for (int i = 0; i < 25; i++)
 		_wallSetBitMaps[i] = nullptr;
 
-	//for (int i = 0; i < kStairsGraphicCount; i++)
-	//	_stairIndices[i] = 0;
-
 	for (int i = 0; i < 4; i++)
-		_palChangesProjectile[i] = nullptr;
+		_g75_palChangesProjectile[i] = nullptr;
 
-	for (int i = 0; i < kAlcoveOrnCount; i++)
-		_currMapAlcoveOrnIndices[i] = 0;
+	for (int i = 0; i < k3_AlcoveOrnCount; i++)
+		_g267_currMapAlcoveOrnIndices[i] = 0;
 
-	for (int i = 0; i < kFountainOrnCount; i++)
-		_currMapFountainOrnIndices[i] = 0;
+	for (int i = 0; i < k1_FountainOrnCount; i++)
+		_g268_currMapFountainOrnIndices[i] = 0;
 
 	for (int i = 0; i < 2; i++) {
 		for (int j = 0; j < 16; j++) {
-			_currMapWallOrnInfo[j][i] = 0;
-			_currMapFloorOrnInfo[j][i] = 0;
+			_g101_currMapWallOrnInfo[j][i] = 0;
+			_g102_currMapFloorOrnInfo[j][i] = 0;
 		}
 		for (int j = 0; j < 17; j++) {
-			_currMapDoorOrnInfo[j][i] = 0;
+			_g103_currMapDoorOrnInfo[j][i] = 0;
 		}
 	}
 
 	for (int i = 0; i < 16; i++) {
-		_currMapWallOrnIndices[i] = 0;
-		_currMapFloorOrnIndices[i] = 0;
+		_g261_currMapWallOrnIndices[i] = 0;
+		_g262_currMapFloorOrnIndices[i] = 0;
 	}
 
 	for (int i = 0; i < 18; i++)
-		_currMapDoorOrnIndices[i] = 0;
+		_g263_currMapDoorOrnIndices[i] = 0;
 
-	_inscriptionThing = Thing::_none;
-	_useByteBoxCoordinates = false;
+	_g290_inscriptionThing = Thing::_none;
+	_g578_useByteBoxCoordinates = false;
 }
 
 DisplayMan::~DisplayMan() {
@@ -759,22 +756,22 @@ DisplayMan::~DisplayMan() {
 	for (uint16 i = kWall_D0L_Flipped; i <= kWall_D3LCR_Flipped; ++i)
 		delete[] _wallSetBitMaps[i];
 
-	delete[] _derivedBitmapByteCount;
-	if (_derivedBitmaps) {
+	delete[] _g639_derivedBitmapByteCount;
+	if (_g638_derivedBitmaps) {
 		for (uint16 i = 0; i < kDerivedBitmapMaximumCount; ++i)
-			delete[] _derivedBitmaps;
-		delete[] _derivedBitmaps;
+			delete[] _g638_derivedBitmaps;
+		delete[] _g638_derivedBitmaps;
 	}
 }
 
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
 	_screenWidth = width;
 	_screenHeight = height;
-	delete[] _tmpBitmap;
-	_tmpBitmap = new byte[_screenWidth * _screenHeight];
+	delete[] _g74_tmpBitmap;
+	_g74_tmpBitmap = new byte[_screenWidth * _screenHeight];
 	delete[] _vgaBuffer;
 	_vgaBuffer = new byte[_screenWidth * _screenHeight];
-	clearScreen(kColorBlack);
+	clearScreen(k0_ColorBlack);
 }
 
 void DisplayMan::loadGraphics() {
@@ -799,128 +796,128 @@ void DisplayMan::loadGraphics() {
 
 	unpackGraphics();
 
-	loadFloorSet(kFloorSetStone);
-	loadWallSet(kWallSetStone);
+	loadFloorSet(k0_FloorSetStone);
+	loadWallSet(k0_WallSetStone);
 
 
 
-	if (!_derivedBitmapByteCount)
-		_derivedBitmapByteCount = new uint16[kDerivedBitmapMaximumCount];
-	if (!_derivedBitmaps) {
-		_derivedBitmaps = new byte*[kDerivedBitmapMaximumCount];
+	if (!_g639_derivedBitmapByteCount)
+		_g639_derivedBitmapByteCount = new uint16[kDerivedBitmapMaximumCount];
+	if (!_g638_derivedBitmaps) {
+		_g638_derivedBitmaps = new byte*[kDerivedBitmapMaximumCount];
 		for (uint16 i = 0; i < kDerivedBitmapMaximumCount; ++i)
-			_derivedBitmaps[i] = nullptr;
+			_g638_derivedBitmaps[i] = nullptr;
 	}
 
-	_derivedBitmapByteCount[kDerivedBitmapViewport] = 224 * 136;
-	_derivedBitmapByteCount[kDerivedBitmapThievesEyeVisibleArea] = 96 * 95;
-	_derivedBitmapByteCount[kDerivedBitmapDamageToCreatureMedium] = 64 * 37;
-	_derivedBitmapByteCount[kDerivedBitmapDamageToCreatureSmall] = 48 * 37;
+	_g639_derivedBitmapByteCount[k0_DerivedBitmapViewport] = 224 * 136;
+	_g639_derivedBitmapByteCount[k1_DerivedBitmapThievesEyeVisibleArea] = 96 * 95;
+	_g639_derivedBitmapByteCount[k2_DerivedBitmapDamageToCreatureMedium] = 64 * 37;
+	_g639_derivedBitmapByteCount[k3_DerivedBitmapDamageToCreatureSmall] = 48 * 37;
 
-	for (int16 doorOrnamentIndex = kDoorOrnDestroyedMask; doorOrnamentIndex <= kDoorOrnThivesEyeMask; doorOrnamentIndex++) {
-		_currMapDoorOrnInfo[doorOrnamentIndex][kNativeBitmapIndex] = doorOrnamentIndex + (kDoorMaskDestroyedIndice - kDoorOrnDestroyedMask);
-		_currMapDoorOrnInfo[doorOrnamentIndex][kCoordinateSet] = 1;
+	for (int16 doorOrnamentIndex = k15_DoorOrnDestroyedMask; doorOrnamentIndex <= k16_DoorOrnThivesEyeMask; doorOrnamentIndex++) {
+		_g103_currMapDoorOrnInfo[doorOrnamentIndex][k0_NativeBitmapIndex] = doorOrnamentIndex + (k301_DoorMaskDestroyedIndice - k15_DoorOrnDestroyedMask);
+		_g103_currMapDoorOrnInfo[doorOrnamentIndex][k1_CoordinateSet] = 1;
 
-		_derivedBitmapByteCount[doorOrnamentIndex * 2 + kDerivedBitmapFirstDoorOrnament_D3] = 48 * 41;
-		_derivedBitmapByteCount[doorOrnamentIndex * 2 + kDerivedBitmapFirstDoorOrnament_D2] = 64 * 61;
+		_g639_derivedBitmapByteCount[doorOrnamentIndex * 2 + k68_DerivedBitmapFirstDoorOrnament_D3] = 48 * 41;
+		_g639_derivedBitmapByteCount[doorOrnamentIndex * 2 + k69_DerivedBitmapFirstDoorOrnament_D2] = 64 * 61;
 	}
 
-	_currMapFloorOrnInfo[kFloorOrnFootprints][kNativeBitmapIndex] = kFloorOrn_15_D3L_footprints;
-	_currMapFloorOrnInfo[kFloorOrnFootprints][kCoordinateSet] = 1;
+	_g102_currMapFloorOrnInfo[k15_FloorOrnFootprints][k0_NativeBitmapIndex] = k241_FloorOrn_15_D3L_footprints;
+	_g102_currMapFloorOrnInfo[k15_FloorOrnFootprints][k1_CoordinateSet] = 1;
 
 	ObjectAspect *objectAspect = gObjectAspects;
 	int16 derivedBitmapIndex;
-	for (int16 objectAspectIndex = 0; objectAspectIndex < kObjAspectCount; ++objectAspectIndex, ++objectAspect) {
-		derivedBitmapIndex = kDerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex;
+	for (int16 objectAspectIndex = 0; objectAspectIndex < k85_ObjAspectCount; ++objectAspectIndex, ++objectAspect) {
+		derivedBitmapIndex = k104_DerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex;
 
-		_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, kScale16_D3);
-		_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, kScale20_D2);
+		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k16_Scale_D3);
+		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k20_Scale_D2);
 
-		if (getFlag(objectAspect->_graphicInfo, kObjectFlipOnRightMask)) {
-			_derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2];
+		if (getFlag(objectAspect->_graphicInfo, k0x0001_ObjectFlipOnRightMask)) {
+			_g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2];
 			derivedBitmapIndex++;
-			_derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2];
+			_g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2];
 			derivedBitmapIndex++;
 		}
 
-		if (getFlag(objectAspect->_graphicInfo, kObjectAlcoveMask)) {
-			_derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2];
+		if (getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask)) {
+			_g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2];
 			derivedBitmapIndex++;
-			_derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2];
+			_g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2];
 		}
 	}
 
 	ProjectileAspect *projectileAspect = gProjectileAspect;
-	for (int16 projectileAspectIndex = 0; projectileAspectIndex < kProjectileAspectCount; projectileAspectIndex++, projectileAspect++) {
+	for (int16 projectileAspectIndex = 0; projectileAspectIndex < k14_ProjectileAspectCount; projectileAspectIndex++, projectileAspect++) {
 
-		if (!getFlag(projectileAspect->_graphicInfo, kProjectileScaleWithKineticEnergyMask)) {
-			derivedBitmapIndex = kDerivedBitmapFirstProjectile + projectileAspect->_firstDerivedBitmapRelativeIndex;
+		if (!getFlag(projectileAspect->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask)) {
+			derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + projectileAspect->_firstDerivedBitmapRelativeIndex;
 
 			for (int16 projectileScaleIndex = 0; projectileScaleIndex < 6; projectileScaleIndex++) {
-				int16 bitmapPixelCount = getScaledBitmapPixelCount(projectileAspect->_width, projectileAspect->_height, gProjectileScales[projectileScaleIndex]);
-				_derivedBitmapByteCount[derivedBitmapIndex] = bitmapPixelCount;
+				int16 bitmapPixelCount = getScaledBitmapPixelCount(projectileAspect->_width, projectileAspect->_height, g215_ProjectileScales[projectileScaleIndex]);
+				_g639_derivedBitmapByteCount[derivedBitmapIndex] = bitmapPixelCount;
 
-				if (getFlag(projectileAspect->_graphicInfo, kProjectileAspectTypeMask) != kProjectileAspectHasNone) {
-					_derivedBitmapByteCount[derivedBitmapIndex + 6] = bitmapPixelCount;
+				if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k3_ProjectileAspectHasNone) {
+					_g639_derivedBitmapByteCount[derivedBitmapIndex + 6] = bitmapPixelCount;
 
-					if (getFlag(projectileAspect->_graphicInfo, kProjectileAspectTypeMask) != kProjectileAspectHasRotation) {
-						_derivedBitmapByteCount[derivedBitmapIndex + 12] = bitmapPixelCount;
+					if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k2_ProjectileAspectHasRotation) {
+						_g639_derivedBitmapByteCount[derivedBitmapIndex + 12] = bitmapPixelCount;
 					}
 				}
 			}
 		}
 	}
 
-	_palChangesProjectile[0] = gPalChangesFloorOrn_D3;
-	_palChangesProjectile[1] = gPalChangesFloorOrn_D2;
-	_palChangesProjectile[2] = _palChangesProjectile[3] = gPalChangesNoChanges;
+	_g75_palChangesProjectile[0] = gPalChangesFloorOrn_D3;
+	_g75_palChangesProjectile[1] = gPalChangesFloorOrn_D2;
+	_g75_palChangesProjectile[2] = _g75_palChangesProjectile[3] = gPalChangesNoChanges;
 
-	derivedBitmapIndex = kDerivedBitmapFirstExplosion;
-	ExplosionAspect *expAsp = gExplosionAspects;
-	for (uint16 expAspIndex = 0; expAspIndex < kExplosionAspectCount; ++expAspIndex, expAsp++) {
+	derivedBitmapIndex = k438_DerivedBitmapFirstExplosion;
+	ExplosionAspect *expAsp = g211_ExplosionAspects;
+	for (uint16 expAspIndex = 0; expAspIndex < k4_ExplosionAspectCount; ++expAspIndex, expAsp++) {
 		for (int16 scale = 4; scale < 32; scale += 2)
-			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(expAsp->_pixelWidth, expAsp->_height, scale);
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(expAsp->_pixelWidth, expAsp->_height, scale);
 
-		if (expAspIndex == kExplosionAspectSmoke) {
-			_derivedBitmapByteCount[derivedBitmapIndex++] = expAsp->_pixelWidth * expAsp->_height;
+		if (expAspIndex == k3_ExplosionAspectSmoke) {
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = expAsp->_pixelWidth * expAsp->_height;
 		}
 	}
 
-	derivedBitmapIndex = kDerivedBitmapFirstCreature;
+	derivedBitmapIndex = k495_DerivedBitmapFirstCreature;
 	CreatureAspect *creatureAsp;
-	for (int16 creatureIndex = 0; creatureIndex < kCreatureTypeCount; creatureIndex++) {
+	for (int16 creatureIndex = 0; creatureIndex < k27_CreatureTypeCount; creatureIndex++) {
 		creatureAsp = &gCreatureAspects[creatureIndex];
 
 		int16 creatureGraphicInfo = gCreatureInfo[creatureIndex]._graphicInfo;
 		creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex;
 
 		int16 creatureFrontBitmapD3PixelCount;
-		_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3);
+		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
 
 		int16 creatureFrontBitmapD2PixelCount;
-		_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2);
+		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
 
-		if (getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskSide)) {
-			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale16_D3);
-			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale20_D2);
+		if (getFlag(creatureGraphicInfo, k0x0008_CreatureInfoGraphicMaskSide)) {
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k16_Scale_D3);
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k20_Scale_D2);
 		}
 
-		if (getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskBack)) {
-			_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount;
-			_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount;
+		if (getFlag(creatureGraphicInfo, k0x0010_CreatureInfoGraphicMaskBack)) {
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount;
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount;
 		}
 
-		if (getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskAttack)) {
-			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, kScale16_D3);
-			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, kScale20_D2);
+		if (getFlag(creatureGraphicInfo, k0x0020_CreatureInfoGraphicMaskAttack)) {
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k16_Scale_D3);
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k20_Scale_D2);
 		}
 
 		int16 additionalFronGraphicCount;
-		if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskAdditional)) {
+		if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, k0x0003_CreatureInfoGraphicMaskAdditional)) {
 			do {
-				_derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront;
-				_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3);
-				_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2);
+				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront;
+				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
+				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
 			} while (--additionalFronGraphicCount);
 		}
 	}
@@ -950,15 +947,15 @@ void DisplayMan::unpackGraphics() {
 		_bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1);
 		loadIntoBitmap(i, _bitmaps[i]);
 	}
-	_bitmaps[kFontGraphicIndice] = _bitmaps[532] + getWidth(532) * getHeight(532);
-	loadFNT1intoBitmap(kFontGraphicIndice, _bitmaps[kFontGraphicIndice]);
+	_bitmaps[k557_FontGraphicIndice] = _bitmaps[532] + getWidth(532) * getHeight(532);
+	loadFNT1intoBitmap(k557_FontGraphicIndice, _bitmaps[k557_FontGraphicIndice]);
 }
 
 void DisplayMan::loadFNT1intoBitmap(uint16 index, byte* destBitmap) {
 	uint8 *data = _packedBitmaps + _packedItemPos[index];
 	for (uint16 i = 0; i < 6; i++) {
 		for (uint16 w = 0; w < 128; ++w) {
-			*destBitmap++ = kColorBlack;
+			*destBitmap++ = k0_ColorBlack;
 
 			uint16 nextByte = *data++;
 			for (int16 pixel = 4; pixel >= 0; --pixel) {
@@ -1085,22 +1082,22 @@ void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) {
 }
 
 byte* DisplayMan::getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnPixelWidth, int16& returnHeight) {
-	ExplosionAspect *explAsp = &gExplosionAspects[explosionAspIndex];
+	ExplosionAspect *explAsp = &g211_ExplosionAspects[explosionAspIndex];
 	if (scale > 32)
 		scale = 32;
 	int16 pixelWidth = getScaledDimension(explAsp->_pixelWidth, scale);
 	int16 height = getScaledDimension(explAsp->_height, scale);
 	byte *bitmap;
-	int16 derBitmapIndex = (explosionAspIndex * 14) + scale / 2 + kDerivedBitmapFirstExplosion - 2;
-	if ((scale == 32) && (explosionAspIndex != kExplosionAspectSmoke)) {
-		bitmap = getBitmap(explosionAspIndex + kFirstExplosionGraphicIndice);
+	int16 derBitmapIndex = (explosionAspIndex * 14) + scale / 2 + k438_DerivedBitmapFirstExplosion - 2;
+	if ((scale == 32) && (explosionAspIndex != k3_ExplosionAspectSmoke)) {
+		bitmap = getBitmap(explosionAspIndex + k348_FirstExplosionGraphicIndice);
 	} else if (isDerivedBitmapInCache(derBitmapIndex)) {
 		bitmap = getDerivedBitmap(derBitmapIndex);
 	} else {
-		byte *nativeBitmap = getBitmap(MIN(explosionAspIndex, (uint16)kExplosionAspectPoison) + kFirstExplosionGraphicIndice);
+		byte *nativeBitmap = getBitmap(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice);
 		bitmap = getDerivedBitmap(derBitmapIndex);
 		blitToBitmapShrinkWithPalChange(nativeBitmap, explAsp->_pixelWidth, explAsp->_height, bitmap, pixelWidth, height,
-			(explosionAspIndex == kExplosionAspectSmoke) ? gPalChangeSmoke : gPalChangesNoChanges);
+			(explosionAspIndex == k3_ExplosionAspectSmoke) ? gPalChangeSmoke : gPalChangesNoChanges);
 		warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 	}
 
@@ -1132,12 +1129,12 @@ uint16 DisplayMan::getHeight(uint16 index) {
 
 void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
 	if (f._srcWidth)
-		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, kColorNoTransparency, gDungeonViewport);
+		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k255_ColorNoTransparency, gDungeonViewport);
 }
 
 void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) {
 	if (f._srcWidth)
-		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, kColorFlesh, gDungeonViewport);
+		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, gDungeonViewport);
 }
 
 
@@ -1150,37 +1147,37 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[kElemAspect]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g0675stairsNativeBitmapIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3L]);
+			drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3L]);
 		else
-			drawFloorPitOrStairsBitmap(_g0682stairsNativeBitmapIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3L]);
+			drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3L]);
 		goto T0116015_redEagle;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3L]);
-		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], kViewWall_D3L_RIGHT);
-		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3L_FRONT)) {
-			order = kCellOrder_Alcove;
+		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) {
+			order = k0x0000_CellOrder_Alcove;
 			goto T0116017_orangeElk;
 		}
 		return;
 	case kElementTypeDoorSide:
 	case kElementTypeStairsSide:
-		order = kCellOrder_BackLeft_BackRight_FrontRight;
+		order = k0x0321_CellOrder_BackLeft_BackRight_FrontRight;
 		goto T0116016_blueToad;
 	case kElementTypeDoorFront:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
-		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3L, kCellOrder_DoorPass1_BackLeft_BackRight);
+		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
 		drawWallSetBitmap(_wallSetBitMaps[kDoorFrameLeft_D3L], g0164Frame_DoorFrameLeft_D3L);
 		warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor");
-		order = kCellOrder_DoorPass2_FrontLeft_FrontRight;
+		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0116017_orangeElk;
 	case kElementTypePit:
 		if (!squareAspect[kPitInvisibleAspect]) {
-			drawFloorPitOrStairsBitmap(k049FloorPit_D3L_GraphicIndice, g0140FrameFloorPit_D3L);
+			drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, g0140FrameFloorPit_D3L);
 		}
 	case kElementTypeTeleporter:
 	case kElementTypeCorridor:
 T0116015_redEagle:
-		order = kCellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
+		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
 T0116016_blueToad:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
 T0116017_orangeElk:
@@ -1201,44 +1198,44 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[kElemAspect]) {
 	case kElementTypeStaisFront:
 		if (squareAspect[kStairsUpAspect]) {
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0675stairsNativeBitmapIndex_Up_Front_D3L, g0112FrameStairsUpFront_D3R);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g0112FrameStairsUpFront_D3R);
 		} else {
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0682stairsNativeBitmapIndex_Down_Front_D3L, g0123FrameStairsDownFront_D3R);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g0123FrameStairsDownFront_D3R);
 		}
 		goto T0117016;
 	case kElementTypeWall:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3R]);
-		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], kViewWall_D3R_LEFT);
-		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3R_FRONT)) {
-			order = kCellOrder_Alcove;
+		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) {
+			order = k0x0000_CellOrder_Alcove;
 			goto T0117018;
 		}
 		return;
 	case kElementTypeDoorSide:
 	case kElementTypeStairsSide:
-		order = kCellOrder_BackRight_BackLeft_FrontLeft;
+		order = k0x0412_CellOrder_BackRight_BackLeft_FrontLeft;
 		goto T0117017;
 	case kElementTypeDoorFront:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
-		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3R, kCellOrder_DoorPass1_BackRight_BackLeft);
-		memcpy(_tmpBitmap, _wallSetBitMaps[kDoorFrameLeft_D3L], 32 * 44);
+		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
+		memcpy(_g74_tmpBitmap, _wallSetBitMaps[kDoorFrameLeft_D3L], 32 * 44);
 		warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally");
 		if (((Door*)_vm->_dungeonMan->_dunData._thingsData[kDoorThingType])[squareAspect[kDoorThingIndexAspect]].hasButton()) {
 			warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton");
 		}
 		warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor");
-		order = kCellOrder_DoorPass2_FrontRight_FrontLeft;
+		order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft;
 		goto T0117018;
 	case kElementTypePit:
 		if (!squareAspect[kPitInvisibleAspect]) {
-		 drawFloorPitOrStairsBitmapFlippedHorizontally(k049FloorPit_D3L_GraphicIndice, g0142FrameFloorPit_D3R);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, g0142FrameFloorPit_D3R);
 		}
 	case kElementTypeTeleporter:
 	case kElementTypeCorridor:
 T0117016:
-		order = kCellOrder_BackRight_BackLeft_FrontRight_FrontLeft;
+		order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft;
 T0117017:
-		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); 
+		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
 T0117018:
 		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3R, order);
 	}
@@ -1253,13 +1250,13 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g0676stairsNativeBitmapIndex_Up_Front_D3C, gStairFrames[kFrameStairsUpFront_D3C]);
+			drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, gStairFrames[kFrameStairsUpFront_D3C]);
 		else
-			drawFloorPitOrStairsBitmap(_g0683stairsNativeBitmapIndex_Down_Front_D3C, gStairFrames[kFrameStairsDownFront_D3C]);
+			drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, gStairFrames[kFrameStairsDownFront_D3C]);
 		break;
 	case kWallElemType:
 		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3C]);
-		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3C_FRONT)) {
+		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) {
 			//... missing code
 		}
 		break;
@@ -1273,19 +1270,19 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g0677stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2L]);
+			drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2L]);
 		else
-			drawFloorPitOrStairsBitmap(_g0684stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2L]);
+			drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2L]);
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2L]);
-		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], kViewWall_D2L_RIGHT);
-		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D2L_FRONT)) {
+		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) {
 			// ... missing code
 		}
 		break;
 	case kStairsSideElemType:
-		drawFloorPitOrStairsBitmap(_g0689stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2L]);
+		drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2L]);
 		break;
 	default:
 		break;
@@ -1297,19 +1294,19 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0677stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2R]);
 		else
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0684stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2R]);
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2R]);
-		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], kViewWall_D2R_LEFT);
-		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D2R_FRONT)) {
+		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) {
 			// ... missing code
 		}
 		break;
 	case kStairsSideElemType:
-		drawFloorPitOrStairsBitmapFlippedHorizontally(_g0689stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]);
+		drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]);
 		break;
 	default:
 		break;
@@ -1321,13 +1318,13 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g0678stairsNativeBitmapIndex_Up_Front_D2C, gStairFrames[kFrameStairsUpFront_D2C]);
+			drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, gStairFrames[kFrameStairsUpFront_D2C]);
 		else
-			drawFloorPitOrStairsBitmap(_g0685stairsNativeBitmapIndex_Down_Front_D2C, gStairFrames[kFrameStairsDownFront_D2C]);
+			drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, gStairFrames[kFrameStairsDownFront_D2C]);
 		break;
 	case kWallElemType:
 		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2C]);
-		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D2C_FRONT)) {
+		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) {
 			// ... missing code
 		}
 		break;
@@ -1341,19 +1338,19 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g0679stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1L]);
+			drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1L]);
 		else
-			drawFloorPitOrStairsBitmap(_g0686stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1L]);
+			drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1L]);
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1L]);
-		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], kViewWall_D1L_RIGHT);
+		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT);
 		break;
 	case kStairsSideElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g0690stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1L]);
+			drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1L]);
 		else
-			drawFloorPitOrStairsBitmap(_g0691stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1L]);
+			drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1L]);
 		break;
 	default:
 		break;
@@ -1365,19 +1362,19 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0679stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1R]);
 		else
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0686stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1R]);
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1R]);
-		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], kViewWall_D1R_LEFT);
+		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT);
 		break;
 	case kStairsSideElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0690stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1R]);
 		else
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0691stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1R]);
 		break;
 	default:
 		break;
@@ -1389,16 +1386,16 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g0680stairsNativeBitmapIndex_Up_Front_D1C, gStairFrames[kFrameStairsUpFront_D1C]);
+			drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, gStairFrames[kFrameStairsUpFront_D1C]);
 		else
-			drawFloorPitOrStairsBitmap(_g0687stairsNativeBitmapIndex_Down_Front_D1C, gStairFrames[kFrameStairsDownFront_D1C]);
+			drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, gStairFrames[kFrameStairsDownFront_D1C]);
 		break;
 	case kWallElemType:
 		_vm->_dungeonMan->_isFacingAlcove = false;
 		_vm->_dungeonMan->_isFacingViAltar = false;
 		_vm->_dungeonMan->_isFacingFountain = false;
 		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1C]);
-		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D1C_FRONT)) {
+		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) {
 			// .... code not yet implemneted
 		}
 		break;
@@ -1413,7 +1410,7 @@ void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsSideElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g0692stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0L]);
+			drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0L]);
 		break;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]);
@@ -1429,7 +1426,7 @@ void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsSideElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0692stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0R]);
 		return;
 	case kWallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kWall_D0R], gFrameWalls[kViewSquare_D0R]);
@@ -1445,11 +1442,11 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect]) {
-			drawFloorPitOrStairsBitmap(_g0681stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0L]);
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0681stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0R]);
+			drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0L]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0R]);
 		} else {
-			drawFloorPitOrStairsBitmap(_g0688stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0L]);
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g0688stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0R]);
+			drawFloorPitOrStairsBitmap(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0L]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0R]);
 		}
 		break;
 	default:
@@ -1458,13 +1455,13 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) {
 }
 
 void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
-	loadPalette(gPalEntrance);
+	loadPalette(g20_PalEntrance);
 	// TODO: this is a global variable, set from here
 	bool flippedFloorCeiling = (posX + posY + dir) & 1;
 
 	// NOTE: this can hold every bitmap, width and height is "flexible"
 	byte  *tmpBitmap = new byte[305 * 111];
-	clearBitmap(tmpBitmap, 305, 111, kColorBlack);
+	clearBitmap(tmpBitmap, 305, 111, k10_ColorFlesh);
 
 	for (int16 i = 0; i < 6; ++i)
 		_vm->_dungeonMan->_dungeonViewClickableBoxes[i].setToZero();
@@ -1475,19 +1472,19 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 
 	if (flippedFloorCeiling) {
 		uint16 w = gFloorFrame._srcWidth, h = gFloorFrame._srcHeight;
-		blitToBitmap(_floorBitmap, w, h, tmpBitmap, w);
+		blitToBitmap(_g84_floorBitmap, w, h, tmpBitmap, w);
 		flipBitmapHorizontal(tmpBitmap, w, h);
 		drawWallSetBitmap(tmpBitmap, gFloorFrame);
-		drawWallSetBitmap(_ceilingBitmap, gCeilingFrame);
+		drawWallSetBitmap(_g85_ceilingBitmap, gCeilingFrame);
 
 		for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i)
 			_wallSetBitMaps[i + kWall_D0R] = _wallSetBitMaps[i + kWall_D0R_Flipped];
 	} else {
 		uint16 w = gCeilingFrame._srcWidth, h = gCeilingFrame._srcHeight;
-		blitToBitmap(_ceilingBitmap, w, h, tmpBitmap, w);
+		blitToBitmap(_g85_ceilingBitmap, w, h, tmpBitmap, w);
 		flipBitmapHorizontal(tmpBitmap, w, h);
 		drawWallSetBitmap(tmpBitmap, gCeilingFrame);
-		drawWallSetBitmap(_floorBitmap, gFloorFrame);
+		drawWallSetBitmap(_g84_floorBitmap, gFloorFrame);
 	}
 
 	if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallElemType)
@@ -1548,9 +1545,9 @@ void DisplayMan::clearBitmap(byte *bitmap, uint16 width, uint16 height, Color co
 
 void DisplayMan::loadFloorSet(FloorSet set) {
 	// there are 2 bitmaps per set, first one is at 75
-	GraphicIndice indice = (GraphicIndice)(kFirstFloorSet + (kFloorSetGraphicCount * set));
-	_floorBitmap = _bitmaps[indice];
-	_ceilingBitmap = _bitmaps[indice + 1];
+	GraphicIndice indice = (GraphicIndice)(kFirstFloorSet + (k2_FloorSetGraphicCount * set));
+	_g84_floorBitmap = _bitmaps[indice];
+	_g85_ceilingBitmap = _bitmaps[indice + 1];
 }
 
 
@@ -1558,8 +1555,8 @@ Box gBoxWallBitmap_D3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallB
 Box gBoxWallBitmap_D2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR
 
 void DisplayMan::loadWallSet(WallSet set) {
-	uint16 firstIndice = (set * kWallSetGraphicCount) + kFirstWallSet;
-	for (uint16 i = 0; i < kWallSetGraphicCount; ++i) {
+	uint16 firstIndice = (set * k13_WallSetGraphicCount) + kFirstWallSet;
+	for (uint16 i = 0; i < k13_WallSetGraphicCount; ++i) {
 		_wallSetBitMaps[i] = _bitmaps[i + firstIndice];
 	}
 
@@ -1613,31 +1610,31 @@ void DisplayMan::loadCurrentMapGraphics() {
 	// the original loads some flipped walls here, I moved it to loadWallSet
 
 	{
-		int16 val = _vm->_dungeonMan->_currMap._map->_wallSet * kStairsGraphicCount + kFirstStairs;
-		_g0675stairsNativeBitmapIndex_Up_Front_D3L = val++;
-		_g0676stairsNativeBitmapIndex_Up_Front_D3C = val++;
-		_g0677stairsNativeBitmapIndex_Up_Front_D2L = val++;
-		_g0678stairsNativeBitmapIndex_Up_Front_D2C = val++;
-		_g0679stairsNativeBitmapIndex_Up_Front_D1L = val++;
-		_g0680stairsNativeBitmapIndex_Up_Front_D1C = val++;
-		_g0681stairsNativeBitmapIndex_Up_Front_D0C_Left = val++;
-		_g0682stairsNativeBitmapIndex_Down_Front_D3L = val++;
-		_g0683stairsNativeBitmapIndex_Down_Front_D3C = val++;
-		_g0684stairsNativeBitmapIndex_Down_Front_D2L = val++;
-		_g0685stairsNativeBitmapIndex_Down_Front_D2C = val++;
-		_g0686stairsNativeBitmapIndex_Down_Front_D1L = val++;
-		_g0687stairsNativeBitmapIndex_Down_Front_D1C = val++;
-		_g0688stairsNativeBitmapIndex_Down_Front_D0C_Left = val++;
-		_g0689stairsNativeBitmapIndex_Side_D2L = val++;
-		_g0690stairsNativeBitmapIndex_Up_Side_D1L = val++;
-		_g0691stairsNativeBitmapIndex_Down_Side_D1L = val++;
-		_g0692stairsNativeBitmapIndex_Side_D0L = val++;
+		int16 val = _vm->_dungeonMan->_currMap._map->_wallSet * k18_StairsGraphicCount + kFirstStairs;
+		_g675_stairsNativeBitmapIndex_Up_Front_D3L = val++;
+		_g676_stairsNativeBitmapIndex_Up_Front_D3C = val++;
+		_g677_stairsNativeBitmapIndex_Up_Front_D2L = val++;
+		_g678_stairsNativeBitmapIndex_Up_Front_D2C = val++;
+		_g679_stairsNativeBitmapIndex_Up_Front_D1L = val++;
+		_g680_stairsNativeBitmapIndex_Up_Front_D1C = val++;
+		_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left = val++;
+		_g682_stairsNativeBitmapIndex_Down_Front_D3L = val++;
+		_g683_stairsNativeBitmapIndex_Down_Front_D3C = val++;
+		_g684_stairsNativeBitmapIndex_Down_Front_D2L = val++;
+		_g685_stairsNativeBitmapIndex_Down_Front_D2C = val++;
+		_g686_stairsNativeBitmapIndex_Down_Front_D1L = val++;
+		_g687_stairsNativeBitmapIndex_Down_Front_D1C = val++;
+		_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left = val++;
+		_g689_stairsNativeBitmapIndex_Side_D2L = val++;
+		_g690_stairsNativeBitmapIndex_Up_Side_D1L = val++;
+		_g691_stairsNativeBitmapIndex_Down_Side_D1L = val++;
+		_g692_stairsNativeBitmapIndex_Side_D0L = val++;
 	}
 
-	for (int16 i = 0; i < kAlcoveOrnCount; ++i)
-		_currMapAlcoveOrnIndices[i] = -1;
-	for (int16 i = 0; i < kFountainOrnCount; ++i)
-		_currMapFountainOrnIndices[i] = -1;
+	for (int16 i = 0; i < k3_AlcoveOrnCount; ++i)
+		_g267_currMapAlcoveOrnIndices[i] = -1;
+	for (int16 i = 0; i < k1_FountainOrnCount; ++i)
+		_g268_currMapFountainOrnIndices[i] = -1;
 
 
 
@@ -1646,47 +1643,47 @@ void DisplayMan::loadCurrentMapGraphics() {
 	uint16 fountainCount = 0;
 	Map &currMap = *_vm->_dungeonMan->_currMap._map;
 
-	_currMapViAltarIndex = -1;
+	_g266_currMapViAltarIndex = -1;
 
 	for (uint16 i = 0; i < currMap._wallOrnCount; ++i) {
-		uint16 ornIndice = _currMapWallOrnIndices[i];
+		uint16 ornIndice = _g261_currMapWallOrnIndices[i];
 		uint16 nativeIndice = kFirstWallOrn + ornIndice * 2;
 
-		_currMapWallOrnInfo[i][kNativeBitmapIndex] = nativeIndice;
-		for (uint16 ornCounter = 0; ornCounter < kAlcoveOrnCount; ++ornCounter) {
+		_g101_currMapWallOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice;
+		for (uint16 ornCounter = 0; ornCounter < k3_AlcoveOrnCount; ++ornCounter) {
 			if (ornIndice == gAlcoveOrnIndices[ornCounter]) {
-				_currMapAlcoveOrnIndices[alcoveCount++] = i;
+				_g267_currMapAlcoveOrnIndices[alcoveCount++] = i;
 				if (ornIndice == 2)
-					_currMapViAltarIndex = i;
+					_g266_currMapViAltarIndex = i;
 			}
 		}
 
-		for (uint16 ornCounter = 0; ornCounter < kFountainOrnCount; ++ornCounter)
+		for (uint16 ornCounter = 0; ornCounter < k1_FountainOrnCount; ++ornCounter)
 			if (ornIndice == gFountainOrnIndices[ornCounter])
-				_currMapFountainOrnIndices[fountainCount++] = i;
+				_g268_currMapFountainOrnIndices[fountainCount++] = i;
 
-		_currMapWallOrnInfo[i][kCoordinateSet] = gWallOrnCoordSetIndices[ornIndice];
+		_g101_currMapWallOrnInfo[i][k1_CoordinateSet] = gWallOrnCoordSetIndices[ornIndice];
 	}
 
 	for (uint16 i = 0; i < currMap._floorOrnCount; ++i) {
-		uint16 ornIndice = _currMapFloorOrnIndices[i];
+		uint16 ornIndice = _g262_currMapFloorOrnIndices[i];
 		uint16 nativeIndice = kFirstFloorOrn + ornIndice * 6;
-		_currMapFloorOrnInfo[i][kNativeBitmapIndex] = nativeIndice;
-		_currMapFloorOrnInfo[i][kCoordinateSet] = gFloorOrnCoordSetIndices[ornIndice];
+		_g102_currMapFloorOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice;
+		_g102_currMapFloorOrnInfo[i][k1_CoordinateSet] = gFloorOrnCoordSetIndices[ornIndice];
 	}
 
 	for (uint16 i = 0; i < currMap._doorOrnCount; ++i) {
-		uint16 ornIndice = _currMapDoorOrnIndices[i];
+		uint16 ornIndice = _g263_currMapDoorOrnIndices[i];
 		uint16 nativeIndice = kFirstDoorOrn + ornIndice;
-		_currMapDoorOrnInfo[i][kNativeBitmapIndex] = nativeIndice;
-		_currMapDoorOrnInfo[i][kCoordinateSet] = gDoorOrnCoordIndices[ornIndice];
+		_g103_currMapDoorOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice;
+		_g103_currMapDoorOrnInfo[i][k1_CoordinateSet] = gDoorOrnCoordIndices[ornIndice];
 	}
 
 	applyCreatureReplColors(9, 8);
 	applyCreatureReplColors(10, 12);
 
 	for (uint16 creatureType = 0; creatureType < currMap._creatureTypeCount; ++creatureType) {
-		CreatureAspect &aspect = gCreatureAspects[_currMapAllowedCreatureTypes[creatureType]];
+		CreatureAspect &aspect = gCreatureAspects[_g264_currMapAllowedCreatureTypes[creatureType]];
 		uint16 replColorOrdinal = aspect.getReplColour9();
 		if (replColorOrdinal)
 			applyCreatureReplColors(9, _vm->ordinalToIndex(replColorOrdinal));
@@ -1698,7 +1695,7 @@ void DisplayMan::loadCurrentMapGraphics() {
 
 void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor) {
 	for (int16 i = 0; i < 6; ++i)
-		gPalDungeonView[i][replacedColor] = gCreatureReplColorSets[replacementColor]._RGBColor[i];
+		g21_PalDungeonView[i][replacedColor] = gCreatureReplColorSets[replacementColor]._RGBColor[i];
 
 	gPalChangesCreature_D2[replacedColor] = gCreatureReplColorSets[replacementColor]._D2ReplacementColor;
 	gPalChangesCreature_D3[replacedColor] = gCreatureReplColorSets[replacementColor]._D3ReplacementColor;
@@ -1706,15 +1703,15 @@ void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor
 
 void DisplayMan::drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
 	if (f._srcWidth) {
-		blitToScreen(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, f._box, kColorFlesh, gDungeonViewport);
+		blitToScreen(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, gDungeonViewport);
 	}
 }
 
 void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) {
 	if (f._srcWidth) {
-		blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcHeight, _tmpBitmap, f._srcWidth);
-		flipBitmapHorizontal(_tmpBitmap, f._srcWidth, f._srcHeight);
-		blitToScreen(_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._box, kColorFlesh, gDungeonViewport);
+		blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcHeight, _g74_tmpBitmap, f._srcWidth);
+		flipBitmapHorizontal(_g74_tmpBitmap, f._srcWidth, f._srcHeight);
+		blitToScreen(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, gDungeonViewport);
 	}
 }
 
@@ -1766,24 +1763,24 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 	if (wallOrnOrd) {
 		int16 var_X;
 		int16 wallOrnIndex = wallOrnOrd - 1;
-		int16 nativeBitmapIndex = _currMapWallOrnInfo[wallOrnIndex][kNativeBitmapIndex];
+		int16 nativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k0_NativeBitmapIndex];
 
-		uint16 *coordinateSetA = gWallOrnCoordSets[_currMapWallOrnInfo[wallOrnIndex][kCoordinateSet]][viewWallIndex];
+		uint16 *coordinateSetA = gWallOrnCoordSets[_g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]][viewWallIndex];
 		isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnIndex);
 		isInscription = (wallOrnIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex);
 		if (isInscription) {
-			_vm->_dungeonMan->decodeText((char*)inscriptionString, _inscriptionThing, kTextTypeInscription);
+			_vm->_dungeonMan->decodeText((char*)inscriptionString, _g290_inscriptionThing, kTextTypeInscription);
 		}
 
-		if (viewWallIndex >= kViewWall_D1L_RIGHT) {
-			if (viewWallIndex == kViewWall_D1C_FRONT) {
+		if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) {
+			if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
 				if (isInscription) {
 					Frame &D1CFrame = gFrameWalls[kViewSquare_D1C];
 					blitToScreen(_wallSetBitMaps[kWall_D1LCR], D1CFrame._srcWidth, 94, 28, gBoxWallPatchBehindInscription._x1, gBoxWallPatchBehindInscription._x2,
-								 gBoxWallPatchBehindInscription._y1, gBoxWallPatchBehindInscription._y2, kColorNoTransparency, gDungeonViewport);
+								 gBoxWallPatchBehindInscription._y1, gBoxWallPatchBehindInscription._y2, k255_ColorNoTransparency, gDungeonViewport);
 
 					unsigned char *string = inscriptionString;
-					bitmapRed = _bitmaps[kInscriptionFontIndice];
+					bitmapRed = _bitmaps[k120_InscriptionFontIndice];
 					int16 textLineIndex = 0;
 					do {
 						int16 characterCount = 0;
@@ -1794,7 +1791,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 						frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7;
 						frame._box._y1 = (frame._box._y2 = gInscriptionLineY[textLineIndex++]) - 7;
 						while (characterCount--) {
-							blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._box, kColorFlesh, gDungeonViewport);
+							blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._box, k10_ColorFlesh, gDungeonViewport);
 							frame._box._x1 += 8;
 							frame._box._x2 += 8;
 						}
@@ -1803,58 +1800,58 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 				}
 				nativeBitmapIndex++;
 
-				_vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._x1 = coordinateSetA[0];
-				_vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._x2 = coordinateSetA[1];
-				_vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._y1 = coordinateSetA[2];
-				_vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._y2 = coordinateSetA[3];
+				_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordinateSetA[0];
+				_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordinateSetA[1];
+				_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordinateSetA[2];
+				_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordinateSetA[3];
 
 				_vm->_dungeonMan->_isFacingAlcove = isAlcove;
-				_vm->_dungeonMan->_isFacingViAltar = (wallOrnIndex == _currMapViAltarIndex);
+				_vm->_dungeonMan->_isFacingViAltar = (wallOrnIndex == _g266_currMapViAltarIndex);
 				_vm->_dungeonMan->_isFacingFountain = false;
-				for (int16 fountainOrnIndex = 0; fountainOrnIndex < kFountainOrnCount; ++fountainOrnIndex) {
-					if (_currMapFountainOrnIndices[fountainOrnIndex] == wallOrnIndex) {
+				for (int16 fountainOrnIndex = 0; fountainOrnIndex < k1_FountainOrnCount; ++fountainOrnIndex) {
+					if (_g268_currMapFountainOrnIndices[fountainOrnIndex] == wallOrnIndex) {
 						_vm->_dungeonMan->_isFacingFountain = true;
 						break;
 					}
 				}
 			}
 			bitmapGreen = _bitmaps[nativeBitmapIndex];
-			if (viewWallIndex == kViewWall_D1R_LEFT) {
-				blitToBitmap(bitmapGreen, coordinateSetA[4], coordinateSetA[5], _tmpBitmap, coordinateSetA[4]);
-				flipBitmapHorizontal(_tmpBitmap, coordinateSetA[4], coordinateSetA[5]);
-				bitmapGreen = _tmpBitmap;
+			if (viewWallIndex == k11_ViewWall_D1R_LEFT) {
+				blitToBitmap(bitmapGreen, coordinateSetA[4], coordinateSetA[5], _g74_tmpBitmap, coordinateSetA[4]);
+				flipBitmapHorizontal(_g74_tmpBitmap, coordinateSetA[4], coordinateSetA[5]);
+				bitmapGreen = _g74_tmpBitmap;
 			}
 			var_X = 0;
 		} else {
 			coordinateSetOffset = 0;
 			uint16 *coordSetB;
-			int16 wallOrnCoordSetIndex = _currMapWallOrnInfo[wallOrnIndex][kCoordinateSet];
-			flipHorizontal = (viewWallIndex == kViewWall_D2R_LEFT) || (viewWallIndex == kViewWall_D3R_LEFT);
+			int16 wallOrnCoordSetIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet];
+			flipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT);
 			if (flipHorizontal) {
-				coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1R_LEFT];
-			} else if ((viewWallIndex == kViewWall_D2L_RIGHT) || (viewWallIndex == kViewWall_D3L_RIGHT)) {
-				coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1L_RIGHT];
+				coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][k11_ViewWall_D1R_LEFT];
+			} else if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT)) {
+				coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][k10_ViewWall_D1L_RIGHT];
 			} else {
 				nativeBitmapIndex++;
-				coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1C_FRONT];
-				if (viewWallIndex == kViewWall_D2L_FRONT) {
+				coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][k12_ViewWall_D1C_FRONT];
+				if (viewWallIndex == k7_ViewWall_D2L_FRONT) {
 					coordinateSetOffset = 6;
-				} else if (viewWallIndex == kViewWall_D2R_FRONT) {
+				} else if (viewWallIndex == k9_ViewWall_D2R_FRONT) {
 					coordinateSetOffset = -6;
 				}
 			}
 			int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0];
-			blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], coordSetB[4] << 1, coordSetB[5], _tmpBitmap, pixelWidth + 1, coordinateSetA[5],
-				(viewWallIndex <= kViewWall_D3R_FRONT) ? gPalChangesDoorButtonAndWallOrn_D3 : gPalChangesDoorButtonAndWallOrn_D2);
+			blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], coordSetB[4] << 1, coordSetB[5], _g74_tmpBitmap, pixelWidth + 1, coordinateSetA[5],
+				(viewWallIndex <= k4_ViewWall_D3R_FRONT) ? gPalChangesDoorButtonAndWallOrn_D3 : gPalChangesDoorButtonAndWallOrn_D2);
 			bitmapGreen = _bitmaps[nativeBitmapIndex];
 			var_X = pixelWidth;
 			if (flipHorizontal) {
-				if (bitmapGreen != _tmpBitmap)
-					blitToBitmap(bitmapGreen, coordSetB[4], coordSetB[5], _tmpBitmap, coordSetB[4]);
-				flipBitmapHorizontal(_tmpBitmap, coordSetB[4], coordSetB[5]);
-				bitmapGreen = _tmpBitmap;
+				if (bitmapGreen != _g74_tmpBitmap)
+					blitToBitmap(bitmapGreen, coordSetB[4], coordSetB[5], _g74_tmpBitmap, coordSetB[4]);
+				flipBitmapHorizontal(_g74_tmpBitmap, coordSetB[4], coordSetB[5]);
+				bitmapGreen = _g74_tmpBitmap;
 				var_X = 15 - (var_X & 0xF);
-			} else if (viewWallIndex == kViewWall_D2L_FRONT) {
+			} else if (viewWallIndex == k7_ViewWall_D2L_FRONT) {
 				var_X -= coordinateSetA[1] - coordinateSetA[0];
 			} else {
 				var_X = 0;
@@ -1883,12 +1880,12 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 				coordinateSetA[3] = gUnreadableInscriptionBoxY2[gWallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
 			}
 		}
-		blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, coordinateSetA[0], coordinateSetA[1], coordinateSetA[2], coordinateSetA[3], kColorFlesh, gDungeonViewport);
+		blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, coordinateSetA[0], coordinateSetA[1], coordinateSetA[2], coordinateSetA[3], k10_ColorFlesh, gDungeonViewport);
 
-		if ((viewWallIndex == kViewWall_D1C_FRONT) && _championPortraitOrdinal--) {
+		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
 			Box &box = gBoxChampionPortraitOnWall;
-			blitToScreen(_bitmaps[kChampionPortraitsIndice], 256, (_championPortraitOrdinal & 0x7) << 5, (_championPortraitOrdinal >> 3) * 29, box._x1, box._x2, box._y1, box._y2,
-						 kColorDarkGary, gDungeonViewport);
+			blitToScreen(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29, box._x1, box._x2, box._y1, box._y2,
+						 k1_ColorDarkGary, gDungeonViewport);
 		}
 		return isAlcove;
 	}
@@ -1935,15 +1932,15 @@ void DisplayMan::drawField(FieldAspect* fieldAspect, Box& box) {
 	if (fieldAspect->_mask == kMaskFieldAspectNoMask) {
 		bitmapMask = nullptr;
 	} else {
-		bitmapMask = dispMan._tmpBitmap;
-		memcpy(bitmapMask, dispMan.getBitmap(kFieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)),
+		bitmapMask = dispMan._g74_tmpBitmap;
+		memcpy(bitmapMask, dispMan.getBitmap(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)),
 			   fieldAspect->_height * fieldAspect->_pixelWidth * sizeof(bitmapMask[0]));
 		if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask)) {
 			dispMan.flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height);
 		}
 	}
 
-	byte *bitmap = dispMan.getBitmap(kFieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex);
+	byte *bitmap = dispMan.getBitmap(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex);
 	warning("MISSING CODE: F0133_VIDEO_BlitBoxFilledWithMaskedBitmap");
 
 	warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache, F0493_CACHE_AddDerivedBitmap, F0480_CACHE_ReleaseBlock");
@@ -2114,7 +2111,7 @@ int16 gCenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_Centere
 #define kBlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK
 
 void DisplayMan::cthulhu(Thing thingParam, direction directionParam, int16 mapXpos,
-														   int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) {
+						 int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) {
 
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 
@@ -2232,7 +2229,7 @@ void DisplayMan::cthulhu(Thing thingParam, direction directionParam, int16 mapXp
 	drawCreaturesCompleted = sqaureHasProjectile = squareHasExplosion = false;
 	cellCounter = 0;
 	firstThingToDraw = thingParam;
-	if (getFlag(orderedViewCellOrdinals, kCellOrder_DoorFront)) { /* If the function call is to draw objects on a door square viewed from the front */
+	if (getFlag(orderedViewCellOrdinals, k0x0008_CellOrder_DoorFront)) { /* If the function call is to draw objects on a door square viewed from the front */
 /* Two function calls are made in that case to draw objects on both sides of the door frame.
 The door and its frame are drawn between the two calls. This value indicates the drawing pass so that
 creatures are drawn in the right order and so that Fluxcages are not drawn twice */
@@ -2250,7 +2247,7 @@ creatures are drawn in the right order and so that Fluxcages are not drawn twice
 	do {
 /* Draw objects */
 		if (drawAlcoveObjects) {
-			AL_2_viewCell = kViewCellAlcove; /* Index of coordinates to draw objects in alcoves */
+			AL_2_viewCell = k4_ViewCellAlcove; /* Index of coordinates to draw objects in alcoves */
 			cellYellowBear = returnOppositeDir(directionParam); /* Alcove is on the opposite direction of the viewing direction */
 			objectShiftIndex = 2;
 		} else {
@@ -2283,46 +2280,46 @@ creatures are drawn in the right order and so that Fluxcages are not drawn twice
 			/* Square where objects are visible and object is located on cell being processed */
 			if ((viewSquareIndex >= kViewSquare_D3C) && (viewSquareIndex <= kViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) {
 				objectAspect = &(gObjectAspects[gObjectInfo[dunMan.getObjectInfoIndex(thingParam)]._objectAspectIndex]);
-				AL_4_nativeBitmapIndex = kFirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex;
-				if (useAlcoveObjectImage = (drawAlcoveObjects && getFlag(objectAspect->_graphicInfo, kObjectAlcoveMask) && !viewLane)) {
+				AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex;
+				if (useAlcoveObjectImage = (drawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane)) {
 					AL_4_nativeBitmapIndex++;
 				}
 				coordinateSet = gObjectCoordinateSets[objectAspect->_coordinateSet][viewSquareIndex][AL_2_viewCell];
 				if (!coordinateSet[1]) /* If object is not visible */
 					continue;
 T0115015_DrawProjectileAsObject:
-				flipHorizontal = getFlag(objectAspect->_graphicInfo, kObjectFlipOnRightMask) &&
+				flipHorizontal = getFlag(objectAspect->_graphicInfo, k0x0001_ObjectFlipOnRightMask) &&
 					!useAlcoveObjectImage &&
-					((viewLane == kViewLaneRight) || (!viewLane && ((AL_2_viewCell == kViewCellFrontRight) || (AL_2_viewCell == kViewCellBackRight))));
+					((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight))));
 				/* Flip horizontally if object graphic requires it and is not being drawn in an alcove and the object is
 				either on the right lane or on the right column of the center lane */
 				paddingPixelCount = 0;
 
-				if ((viewSquareIndex == kViewSquare_D0C) || ((viewSquareIndex >= kViewSquare_D1C) && (AL_2_viewCell >= kViewCellBackRight))) {
+				if ((viewSquareIndex == kViewSquare_D0C) || ((viewSquareIndex >= kViewSquare_D1C) && (AL_2_viewCell >= k2_ViewCellBackRight))) {
 					/* If object is in the center lane (only D0C or D1C with condition above) and is not a projectile */
 					drawingGrabbableObject = (!viewLane && !drawProjectileAsObject);
-					AL_8_shiftSetIndex = kShiftSet_D0BackD1Front;
+					AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
 					AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */
 					byteWidth = objectAspect->_width;
 					heightRedEagle = objectAspect->_height;
 					if (flipHorizontal) {
-						memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
-						flipBitmapHorizontal(_tmpBitmap, byteWidth, heightRedEagle);
-						AL_6_bitmapRedBanana = _tmpBitmap;
+						memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
+						flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
+						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
 				} else {
 					drawingGrabbableObject = false;
-					derivedBitmapIndex = kDerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex;
-					if ((viewSquareIndex >= kViewSquare_D1C) || ((viewSquareIndex >= kViewSquare_D2C) && (AL_2_viewCell >= kViewCellBackRight))) {
+					derivedBitmapIndex = k104_DerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex;
+					if ((viewSquareIndex >= kViewSquare_D1C) || ((viewSquareIndex >= kViewSquare_D2C) && (AL_2_viewCell >= k2_ViewCellBackRight))) {
 						derivedBitmapIndex++;
-						AL_8_shiftSetIndex = kShiftSet_D1BackD2Front;
-						byteWidth = getScaledDimension(objectAspect->_width, kScale20_D2);
-						heightRedEagle = getScaledDimension(objectAspect->_height, kScale20_D2);
+						AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front;
+						byteWidth = getScaledDimension(objectAspect->_width, k20_Scale_D2);
+						heightRedEagle = getScaledDimension(objectAspect->_height, k20_Scale_D2);
 						paletteChanges = gPalChangesFloorOrn_D2;
 					} else {
-						AL_8_shiftSetIndex = kShiftSet_D2BackD3Front;
-						byteWidth = getScaledDimension(objectAspect->_width, kScale16_D3);
-						heightRedEagle = getScaledDimension(objectAspect->_height, kScale16_D3);
+						AL_8_shiftSetIndex = k2_ShiftSet_D2BackD3Front;
+						byteWidth = getScaledDimension(objectAspect->_width, k16_Scale_D3);
+						heightRedEagle = getScaledDimension(objectAspect->_height, k16_Scale_D3);
 						paletteChanges = gPalChangesFloorOrn_D3;
 					}
 					if (flipHorizontal) {
@@ -2395,20 +2392,20 @@ T0115015_DrawProjectileAsObject:
 					AL_6_bitmapRedBanana = bitmapGreenAnt;
 					dunMan._pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */
 				}
-				blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, kColorFlesh, gDungeonViewport);
+				blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, gDungeonViewport);
 
 				if (drawProjectileAsObject)
 					goto T0115171_BackFromT0115015_DrawProjectileAsObject;
 			}
 		} while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList);
-		if (AL_2_viewCell == kViewCellAlcove)
+		if (AL_2_viewCell == k4_ViewCellAlcove)
 			break; /* End of processing when drawing objects in an alcove */
 		if (viewSquareIndex < kViewSquare_D3C)
 			break; /* End of processing if square is too far away at D4 */
 				   /* Draw creatures */
 
 		/* If (draw cell on the back row or second cell being processed) and (no more cells to draw or next cell to draw is a cell on the front row) */
-		drawingLastBackRowCell = ((AL_2_viewCell <= kViewCellFrontRight) || (cellCounter == 1))
+		drawingLastBackRowCell = ((AL_2_viewCell <= k1_ViewCellFrontRight) || (cellCounter == 1))
 			&& (!remainingViewCellOrdinalsToProcess || ((remainingViewCellOrdinalsToProcess & 0x0000000F) >= 3));
 
 		if ((groupThing == Thing::_none) || drawCreaturesCompleted)
@@ -2438,24 +2435,24 @@ T0115015_DrawProjectileAsObject:
 			if (remainingViewCellOrdinalsToProcess || (doorFrontViewDrawingPass == 1))
 /* Do not draw a single centered creature now, wait until second pass (for a front view door)
  or until all cells have been drawn so the creature is drawn over all the objects on the floor */
-				goto T0115129_DrawProjectiles; 
+				goto T0115129_DrawProjectiles;
 			drawCreaturesCompleted = true;
 			if ((creatureSize == kMaskCreatureSizeHalf) && (creatureDirectionDelta & 0x0001)) { /* Side view of half square creature */
-				AL_2_viewCell = kHalfSizedViewCell_CenterColumn;
+				AL_2_viewCell = k3_HalfSizedViewCell_CenterColumn;
 			} else {
-				AL_2_viewCell = kHalfSizedViewCell_FrontRow;
+				AL_2_viewCell = k4_HalfSizedViewCell_FrontRow;
 			}
 		} else if ((creatureSize == kMaskCreatureSizeHalf) && (drawingLastBackRowCell || !remainingViewCellOrdinalsToProcess || (creatureIndexGreen < 0))) {
 			if (drawingLastBackRowCell && (doorFrontViewDrawingPass != 2)) {
 				if ((creatureIndexGreen >= 0) && (creatureDirectionDelta & 0x0001)) {
-					AL_2_viewCell = kHalfSizedViewCell_BackRow; /* Side view of a half square creature on the back row. Drawn during pass 1 for a door square */
+					AL_2_viewCell = k2_HalfSizedViewCell_BackRow; /* Side view of a half square creature on the back row. Drawn during pass 1 for a door square */
 				} else {
 					goto T0115129_DrawProjectiles;
 				}
 			} else if ((doorFrontViewDrawingPass != 1) && !remainingViewCellOrdinalsToProcess) {
 				if (creatureDirectionDelta & 0x0001) {
 					if (creatureIndexGreen >= 0) {
-						AL_2_viewCell = kHalfSizedViewCell_FrontRow; /* Side view of a half square creature on the front row. Drawn during pass 2 for a door square */
+						AL_2_viewCell = k4_HalfSizedViewCell_FrontRow; /* Side view of a half square creature on the front row. Drawn during pass 2 for a door square */
 					} else {
 						goto T0115129_DrawProjectiles;
 					}
@@ -2467,9 +2464,9 @@ T0115015_DrawProjectileAsObject:
 					twoHalfSquareCreaturesFrontView = group->getCount();
 					if (((AL_4_groupCells = _vm->_groupMan->getCreatureValue(AL_4_groupCells, AL_0_creatureIndexRed)) == directionParam)
 						|| (AL_4_groupCells == returnPrevVal(directionParam))) {
-						AL_2_viewCell = kHalfSizedViewCell_LeftColumn;
+						AL_2_viewCell = k0_HalfSizedViewCell_LeftColumn;
 					} else {
-						AL_2_viewCell = kHalfSizedViewCell_RightColumn;
+						AL_2_viewCell = k1_HalfSizedViewCell_RightColumn;
 					}
 				}
 			} else {
@@ -2489,29 +2486,29 @@ T0115077_DrawSecondHalfSquareCreature:
 		if (!coordinateSet[1])
 			goto T0115126_CreatureNotVisible;
 		AL_0_creatureGraphicInfoRed = creatureGraphicInfoGreen;
-		AL_4_nativeBitmapIndex = kFirstCreatureGraphicIndice + ((CreatureAspect*)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */
+		AL_4_nativeBitmapIndex = k446_FirstCreatureGraphicIndice + ((CreatureAspect*)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */
 		derivedBitmapIndex = ((CreatureAspect*)objectAspect)->_firstDerivedBitmapIndex;
-		if (useCreatureSideBitmap = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide) && (creatureDirectionDelta & 0x0001)) {
+		if (useCreatureSideBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide) && (creatureDirectionDelta & 0x0001)) {
 			useCreatureAttackBitmap = useFlippedHorizontallyCreatureFrontImage = useCreatureBackBitmap = false;
 			AL_4_nativeBitmapIndex++; /* Skip the front image. Side image is right after the front image */
 			derivedBitmapIndex += 2;
 			sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthSide;
 			sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightSide;
 		} else {
-			useCreatureBackBitmap = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskBack) && (creatureDirectionDelta == 0);
+			useCreatureBackBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack) && (creatureDirectionDelta == 0);
 			if (useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupIsAttacking)
-				&& getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskAttack)) {
+				&& getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack)) {
 
 				useFlippedHorizontallyCreatureFrontImage = false;
 				sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthAttack;
 				sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightAttack;
 				AL_4_nativeBitmapIndex++; /* Skip the front image */
 				derivedBitmapIndex += 2;
-				if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide)) {
+				if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) {
 					AL_4_nativeBitmapIndex++; /* If the creature has a side image, it preceeds the attack image */
 					derivedBitmapIndex += 2;
 				}
-				if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskBack)) {
+				if (getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack)) {
 					AL_4_nativeBitmapIndex++; /* If the creature has a back image, it preceeds the attack image */
 					derivedBitmapIndex += 2;
 				}
@@ -2520,7 +2517,7 @@ T0115077_DrawSecondHalfSquareCreature:
 				sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightFront;
 				if (useCreatureBackBitmap) {
 					useFlippedHorizontallyCreatureFrontImage = false;
-					if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide)) {
+					if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) {
 						AL_4_nativeBitmapIndex += 2; /* If the creature has a side image, it preceeds the back image */
 						derivedBitmapIndex += 4;
 					} else {
@@ -2528,16 +2525,16 @@ T0115077_DrawSecondHalfSquareCreature:
 						derivedBitmapIndex += 2;
 					}
 				} else {
-					if (useFlippedHorizontallyCreatureFrontImage = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskFlipNonAttack)
+					if (useFlippedHorizontallyCreatureFrontImage = getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)
 						&& getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) {
 						derivedBitmapIndex += 2;
-						if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide)) {
+						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) {
 							derivedBitmapIndex += 2;
 						}
-						if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskBack)) {
+						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack)) {
 							derivedBitmapIndex += 2;
 						}
-						if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskAttack)) {
+						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack)) {
 							derivedBitmapIndex += 2;
 						}
 					}
@@ -2546,29 +2543,29 @@ T0115077_DrawSecondHalfSquareCreature:
 		}
 		if (viewSquareIndex >= kViewSquare_D1C) { /* Creature is on D1 */
 			creaturePaddingPixelCount = 0;
-			AL_8_shiftSetIndex = kShiftSet_D0BackD1Front;
+			AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
 			transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour();
 			if (useCreatureSideBitmap) {
 				AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex);
 				if (creatureDirectionDelta == 1) {
-					memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
-					flipBitmapHorizontal(_tmpBitmap, byteWidth, heightRedEagle);
-					AL_6_bitmapRedBanana = _tmpBitmap;
+					memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
+					flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
+					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
 			} else {
 				if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) {
 					AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex);
 					if (useCreatureAttackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) {
-						memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
-						flipBitmapHorizontal(_tmpBitmap, byteWidth, heightRedEagle);
-						AL_6_bitmapRedBanana = _tmpBitmap;
+						memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
+						flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
+						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
 				} else { /* Use first additional derived graphic: front D1 */
 					if (isDerivedBitmapInCache(derivedBitmapIndex)) { /* If derived graphic is already in memory */
 						AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
 					} else {
 						bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex);
-						if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskFlipNonAttack)) {
+						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) {
 							AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
 							memcpy(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * heightRedEagle * sizeof(byte));
 							flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
@@ -2583,16 +2580,16 @@ T0115077_DrawSecondHalfSquareCreature:
 			}
 			if (viewSquareIndex >= kViewSquare_D2C) { /* Creature is on D2 */
 				derivedBitmapIndex++; /* Skip front D3 image in additional graphics */
-				AL_8_shiftSetIndex = kShiftSet_D1BackD2Front;
-				useCreatureSpecialD2FrontBitmap = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSpecialD2Front)
+				AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front;
+				useCreatureSpecialD2FrontBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0080_CreatureInfoGraphicMaskSpecialD2Front)
 					&& !useCreatureSideBitmap && !useCreatureBackBitmap && !useCreatureAttackBitmap;
 				paletteChanges = gPalChangesCreature_D2;
-				scale = kScale20_D2;
+				scale = k20_Scale_D2;
 			} else { /* Creature is on D3 */
-				AL_8_shiftSetIndex = kShiftSet_D2BackD3Front;
+				AL_8_shiftSetIndex = k2_ShiftSet_D2BackD3Front;
 				useCreatureSpecialD2FrontBitmap = false;
 				paletteChanges = gPalChangesCreature_D3;
-				scale = kScale16_D3;
+				scale = k16_Scale_D3;
 			}
 			byteWidth = getScaledDimension(sourceByteWidth, scale);
 			heightRedEagle = getScaledDimension(sourceHeight, scale);
@@ -2607,14 +2604,14 @@ T0115077_DrawSecondHalfSquareCreature:
 			}
 			if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */
 				(useCreatureAttackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) ||
-				(useCreatureSpecialD2FrontBitmap && getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSpecialD2FrontIsFlipped)) ||
-				(useFlippedHorizontallyCreatureFrontImage && getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskFlipNonAttack))) { /* If the graphic should be flipped */
+				(useCreatureSpecialD2FrontBitmap && getFlag(AL_0_creatureGraphicInfoRed, k0x0100_CreatureInfoGraphicMaskSpecialD2FrontIsFlipped)) ||
+				(useFlippedHorizontallyCreatureFrontImage && getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack))) { /* If the graphic should be flipped */
 				if (!useFlippedHorizontallyCreatureFrontImage || !derivedBitmapInCache) {
 					AL_4_normalizdByteWidth = byteWidth;
 					warning("SUPER WARNING: we might need getNormalizedByteWidthM77");
 					if (!useFlippedHorizontallyCreatureFrontImage) {
-						memcpy(_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte));
-						AL_6_bitmapRedBanana = _tmpBitmap;
+						memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte));
+						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
 					flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 				}
@@ -2629,7 +2626,7 @@ T0115077_DrawSecondHalfSquareCreature:
 		boxByteGreen._y1 = MIN(0, AL_4_yPos - (heightRedEagle - 1));
 		AL_4_xPos = coordinateSet[0];
 		AL_4_xPos += gShiftSets[AL_8_shiftSetIndex][getHorizontalOffsetM22(creatureAspectInt)];
-		if (viewLane == kViewLaneLeft) {
+		if (viewLane == k1_ViewLaneLeft) {
 			AL_4_xPos -= 100;
 		} else {
 			if (viewLane) { /* Lane right */
@@ -2652,10 +2649,10 @@ T0115126_CreatureNotVisible:
 		if (twoHalfSquareCreaturesFrontView) {
 			twoHalfSquareCreaturesFrontView = false;
 			creatureAspectInt = activeGroup->_aspect[!creatureIndexGreen]; /* Aspect of the other creature in the pair */
-			if (AL_2_viewCell == kHalfSizedViewCell_RightColumn) {
-				AL_2_viewCell = kHalfSizedViewCell_LeftColumn;
+			if (AL_2_viewCell == k1_HalfSizedViewCell_RightColumn) {
+				AL_2_viewCell = k0_HalfSizedViewCell_LeftColumn;
 			} else {
-				AL_2_viewCell = kHalfSizedViewCell_RightColumn;
+				AL_2_viewCell = k1_HalfSizedViewCell_RightColumn;
 			}
 			goto T0115077_DrawSecondHalfSquareCreature;
 		}
@@ -2664,8 +2661,8 @@ T0115129_DrawProjectiles:
 		if (!sqaureHasProjectile
 			|| ((viewSquareIndex = viewSquareIndexBackup) > kViewSquare_D0C)
 /* If there is no projectile to draw or if projectiles are not visible on the specified square or on the cell being drawn */
-			|| (!(projectilePosX = gObjectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0]))) 
-			continue;
+|| (!(projectilePosX = gObjectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0])))
+continue;
 		thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */
 
 		do {
@@ -2673,38 +2670,38 @@ T0115129_DrawProjectiles:
 				projectile = (Projectile*)dunMan.getThingData(thingParam);
 				if ((AL_4_projectileAspect = dunMan.getProjectileAspect(projectile->_object)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
 					objectAspect = (ObjectAspect*)&gProjectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)];
-					AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + kFirstProjectileGraphicIndice;
-					projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, kProjectileAspectTypeMask);
-					if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, kProjectileScaleWithKineticEnergyMask))
+					AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
+					projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
+					if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask))
 						 || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == kViewSquare_D0C)) {
 						scale = 0; /* Use native bitmap without resizing */
 						byteWidth = ((ProjectileAspect*)objectAspect)->_width;
 						heightRedEagle = ((ProjectileAspect*)objectAspect)->_height;
 					} else {
 						AL_8_projectileScaleIndex = ((viewSquareIndex / 3) << 1) + (AL_2_viewCell >> 1);
-						scale = gProjectileScales[AL_8_projectileScaleIndex];
+						scale = g215_ProjectileScales[AL_8_projectileScaleIndex];
 						if (!doNotScaleWithKineticEnergy) {
 							scale = (scale * MAX(96, projectile->_kineticEnergy + 1)) >> 8;
 						}
 						byteWidth = getScaledDimension(((ProjectileAspect*)objectAspect)->_width, scale);
 						heightRedEagle = getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale);
 					}
-					if (projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == kProjectileAspectHasBackGraphicRotation)) {
+					if (projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == k0_ProjectileAspectHasBackGraphicRotation)) {
 						projectileFlipVertical = ((mapXpos + mapYpos) & 0x0001);
 					}
-					if (projectileAspectType == kProjectileAspectHasNone) {
+					if (projectileAspectType == k3_ProjectileAspectHasNone) {
 						projectileBitmapIndexData = 0;
 						flipVertical = flipHorizontal = false;
 					} else {
 						if (isOrientedWestEast((direction)(projectileDirection = _vm->_timeline->_events[projectile->_timerIndex]._C._projectile.getDir()))
 							!= isOrientedWestEast(directionParam)) {
-							if (projectileAspectType == kProjectileAspectHasRotation) {
+							if (projectileAspectType == k2_ProjectileAspectHasRotation) {
 								projectileBitmapIndexData = 1;
 							} else {
 								projectileBitmapIndexData = 2;
 							}
 							if (projectileAspectTypeHasBackGraphicAndRotation) {
-								flipHorizontal = !AL_2_viewCell || (AL_2_viewCell == kViewCellBackLeft);
+								flipHorizontal = !AL_2_viewCell || (AL_2_viewCell == k3_ViewCellBackLeft);
 								if (!(flipVertical = projectileFlipVertical)) {
 									flipHorizontal = !flipHorizontal;
 								}
@@ -2714,16 +2711,16 @@ T0115129_DrawProjectiles:
 							}
 						} else {
 /* If the projectile does not have a back graphic or has one but is not seen from the back or if it has a back graphic and rotation and should be flipped vertically */
-							if ((projectileAspectType >= kProjectileAspectHasRotation)
-								|| ((projectileAspectType == kProjectileAspectBackGraphic)
+							if ((projectileAspectType >= k2_ProjectileAspectHasRotation)
+								|| ((projectileAspectType == k1_ProjectileAspectBackGraphic)
 									&& (projectileDirection != directionParam)) || (projectileAspectTypeHasBackGraphicAndRotation && projectileFlipVertical)) {
 								projectileBitmapIndexData = 0;
 							} else {
 								projectileBitmapIndexData = 1;
 							}
-							flipVertical = projectileAspectTypeHasBackGraphicAndRotation && (AL_2_viewCell < kViewCellBackRight);
-							flipHorizontal = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, kProjectileSideMask)
-								&& !((viewLane == kViewLaneRight) || (!viewLane && ((AL_2_viewCell == kViewCellFrontRight) || (AL_2_viewCell == kViewCellBackRight))));
+							flipVertical = projectileAspectTypeHasBackGraphicAndRotation && (AL_2_viewCell < k2_ViewCellBackRight);
+							flipHorizontal = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0010_ProjectileSideMask)
+								&& !((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight))));
 						}
 					}
 					AL_4_nativeBitmapIndex += projectileBitmapIndexData;
@@ -2734,7 +2731,7 @@ T0115129_DrawProjectiles:
 						if (flipHorizontal) {
 							paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1;
 						}
-						derivedBitmapIndex = kDerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (projectileBitmapIndexData * 6);
+						derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (projectileBitmapIndexData * 6);
 						if (doNotScaleWithKineticEnergy && isDerivedBitmapInCache(derivedBitmapIndex) + AL_8_projectileScaleIndex) {
 							AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
 						} else {
@@ -2742,10 +2739,10 @@ T0115129_DrawProjectiles:
 							if (doNotScaleWithKineticEnergy) {
 								AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
 							} else {
-								AL_6_bitmapRedBanana = _tmpBitmap;
+								AL_6_bitmapRedBanana = _g74_tmpBitmap;
 							}
 							blitToBitmapShrinkWithPalChange(bitmapGreenAnt, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height,
-															AL_6_bitmapRedBanana, byteWidth, heightRedEagle, _palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
+															AL_6_bitmapRedBanana, byteWidth, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
 							if (doNotScaleWithKineticEnergy) {
 								warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap");
 							}
@@ -2754,9 +2751,9 @@ T0115129_DrawProjectiles:
 					if (flipHorizontal || flipVertical) {
 						warning("might need noralized bytewidth");
 						AL_4_normalizdByteWidth = byteWidth;
-						if (AL_6_bitmapRedBanana != _tmpBitmap) {
-							memcpy(_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte));
-							AL_6_bitmapRedBanana = _tmpBitmap;
+						if (AL_6_bitmapRedBanana != _g74_tmpBitmap) {
+							memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte));
+							AL_6_bitmapRedBanana = _g74_tmpBitmap;
 						}
 						if (flipVertical) {
 							flipBitmapVertical(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
@@ -2781,17 +2778,17 @@ the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part
 screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
 						AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - projectilePosX - 1));
 					}
-					blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, kColorFlesh, gDungeonViewport);
+					blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, gDungeonViewport);
 				} else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */
 					useAlcoveObjectImage = false;
 					projectileCoordinates[0] = projectilePosX;
 					projectileCoordinates[1] = 47;
 					coordinateSet = projectileCoordinates;
 					objectAspect = &gObjectAspects[AL_4_projectileAspect];
-					AL_4_nativeBitmapIndex = objectAspect->_firstNativeBitmapRelativeIndex + kFirstObjectGraphicIndice;
+					AL_4_nativeBitmapIndex = objectAspect->_firstNativeBitmapRelativeIndex + k360_FirstObjectGraphicIndice;
 					drawProjectileAsObject = true;
 /* Go to code section to draw an object. Once completed, it jumps back to T0115171_BackFromT0115015_DrawProjectileAsObject below */
-					goto T0115015_DrawProjectileAsObject; 
+					goto T0115015_DrawProjectileAsObject;
 				}
 			}
 T0115171_BackFromT0115015_DrawProjectileAsObject:;
@@ -2812,32 +2809,32 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 			AL_2_cellPurpleMan = thingParam.getCell();
 			explosion = (Explosion*)dunMan.getThingData(thingParam);
 			if ((rebirthExplosion = ((unsigned int)(AL_4_explosionType = explosion->getType()) >= kExplosionType_RebirthStep1))
-				&& ((AL_1_viewSquareExplosionIndex < kViewSquare_D3C_Explosion) 
+				&& ((AL_1_viewSquareExplosionIndex < kViewSquare_D3C_Explosion)
 					|| (AL_1_viewSquareExplosionIndex > kViewSquare_D1C_Explosion)
 					|| (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */
 				continue;
 			smoke = false;
 			if ((AL_4_explosionType == kExplosionType_Fireball) || (AL_4_explosionType == kExplosionType_LightningBolt) || (AL_4_explosionType == kExplosionType_RebirthStep2)) {
-				AL_4_explosionAspectIndex = kExplosionAspectFire;
+				AL_4_explosionAspectIndex = k0_ExplosionAspectFire;
 			} else {
 				if ((AL_4_explosionType == kExplosionType_PoisonBolt) || (AL_4_explosionType == kExplosionType_PoisonCloud)) {
-					AL_4_explosionAspectIndex = kExplosionAspectPoison;
+					AL_4_explosionAspectIndex = k2_ExplosionAspectPoison;
 				} else {
 					if (AL_4_explosionType == kExplosionType_Smoke) {
 						smoke = true;
-						AL_4_explosionAspectIndex = kExplosionAspectSmoke;
+						AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke;
 					} else {
 						if (AL_4_explosionType == kExplosionType_RebirthStep1) {
 							objectAspect = (ObjectAspect*)&gProjectileAspect[_vm->ordinalToIndex(-dunMan.getProjectileAspect(Thing::_explLightningBolt))];
-							AL_6_bitmapRedBanana = getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (kFirstProjectileGraphicIndice + 1));
+							AL_6_bitmapRedBanana = getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
 							explosionCoordinates = gRebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
 							byteWidth = getScaledDimension((((ProjectileAspect*)objectAspect)->_width), explosionCoordinates[2]);
 							heightRedEagle = getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
 							if (AL_1_viewSquareExplosionIndex != kViewSquare_D1C_Explosion) {
 								blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana,
-									((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, _tmpBitmap,
-																		 byteWidth, heightRedEagle, gPalChangesNoChanges);
-								AL_6_bitmapRedBanana = _tmpBitmap;
+									((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, _g74_tmpBitmap,
+																byteWidth, heightRedEagle, gPalChangesNoChanges);
+								AL_6_bitmapRedBanana = _g74_tmpBitmap;
 							}
 							goto T0115200_DrawExplosion;
 						}
@@ -2847,7 +2844,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 							}
 							continue;
 						}
-						AL_4_explosionAspectIndex = kExplosionAspectSpell;
+						AL_4_explosionAspectIndex = k1_ExplosionAspectSpell;
 					}
 				}
 			}
@@ -2863,14 +2860,14 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					}
 				}
 				warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache");
-				AL_6_bitmapRedBanana = getBitmap(AL_4_explosionAspectIndex + kFirstExplosionPatternGraphicIndice);
+				AL_6_bitmapRedBanana = getBitmap(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice);
 				if (smoke) {
-					blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _tmpBitmap, 48, 32, gPalChangeSmoke);
-					AL_6_bitmapRedBanana = _tmpBitmap;
+					blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _g74_tmpBitmap, 48, 32, gPalChangeSmoke);
+					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
-				blitBoxFilledWithMaskedBitmapToScreen(AL_6_bitmapRedBanana, nullptr, getDerivedBitmap(kDerivedBitmapViewport), gBoxExplosionPattern_D0C,
+				blitBoxFilledWithMaskedBitmapToScreen(AL_6_bitmapRedBanana, nullptr, getDerivedBitmap(k0_DerivedBitmapViewport), gBoxExplosionPattern_D0C,
 													  _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64),
-													  224, (Color)(kBlitDoNotUseMask | kColorFlesh), 0, 0, 136, 93);
+													  224, (Color)(kBlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
 				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 			} else {
@@ -2882,9 +2879,9 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 						explosionCoordinates = gCenteredExplosionCoordinates[AL_1_viewSquareExplosionIndex];
 					} else {
 						if ((AL_2_cellPurpleMan == directionParam) || (AL_2_cellPurpleMan == returnPrevVal(directionParam))) {
-							AL_2_viewCell = kViewCellFronLeft;
+							AL_2_viewCell = k0_ViewCellFronLeft;
 						} else {
-							AL_2_viewCell = kViewCellFrontRight;
+							AL_2_viewCell = k1_ViewCellFrontRight;
 						}
 						explosionCoordinates = gExplosionCoordinates[AL_1_viewSquareExplosionIndex][AL_2_viewCell];
 					}
@@ -2897,7 +2894,7 @@ T0115200_DrawExplosion:
 				if (flipHorizontal = _vm->_rnd->getRandomNumber(2)) {
 					paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; /* Number of unused pixels in the units on the right of the bitmap */
 				}
-				boxByteGreen._y2 = MIN(135, explosionCoordinates[1] + (heightRedEagle >> 1)) + 1; 
+				boxByteGreen._y2 = MIN(135, explosionCoordinates[1] + (heightRedEagle >> 1)) + 1;
 				AL_4_yPos = MAX(0, explosionCoordinates[1] - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001));
 				if (AL_4_yPos >= 136)
 					continue;
@@ -2913,7 +2910,7 @@ T0115200_DrawExplosion:
 left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is not flipped horizontally (flipHorizontal = C0_FALSE) then the
 variable paddingPixelCount is not set before being used here. Its previous value (defined while drawing something else) is used
 and may cause an incorrect bitmap to be drawn */
-					AL_4_xPos = MIN(paddingPixelCount,(int16)( byteWidth / 2 - AL_4_xPos - 1)); 
+					AL_4_xPos = MIN(paddingPixelCount, (int16)(byteWidth / 2 - AL_4_xPos - 1));
 
 /* BUG0_06 Graphical glitch when drawing projectiles or explosions. If a projectile or explosion bitmap is cropped because it is
 only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is flipped horizontally (flipHorizontal = C1_TRUE)
@@ -2924,8 +2921,8 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP
 				warning("might need M77_NORMALIZED_BYTE_WIDTH");
 				byteWidth = byteWidth;
 				if (flipHorizontal || flipVertical) {
-					memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle);
-					AL_6_bitmapRedBanana = _tmpBitmap;
+					memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle);
+					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
 				if (flipHorizontal) {
 					flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
@@ -2933,12 +2930,12 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP
 				if (flipVertical) {
 					flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 				}
-				blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, kColorFlesh, gDungeonViewport);
+				blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, gDungeonViewport);
 			}
 		}
 	} while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList);
 /* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */
-	if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_doNotDrawFluxcagesDuringEndgame) { 
+	if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_g77_doNotDrawFluxcagesDuringEndgame) {
 		AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */
 		fieldAspect = gFieldAspects[viewSquareIndex];
 		(fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */
@@ -2959,16 +2956,16 @@ uint16 DisplayMan::getHorizontalOffsetM22(uint16 val) {
 }
 
 bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) {
-	if (_derivedBitmaps[derivedBitmapIndex] == nullptr) {
+	if (_g638_derivedBitmaps[derivedBitmapIndex] == nullptr) {
 		// * 2, because the original uses 4 bits instead of 8 bits to store a pixel
-		_derivedBitmaps[derivedBitmapIndex] = new byte[_derivedBitmapByteCount[derivedBitmapIndex] * 2];
+		_g638_derivedBitmaps[derivedBitmapIndex] = new byte[_g639_derivedBitmapByteCount[derivedBitmapIndex] * 2];
 		return false;
 	} else
 		return true;
 }
 
 byte* DisplayMan::getDerivedBitmap(int16 derivedBitmapIndex) {
-	return _derivedBitmaps[derivedBitmapIndex];
+	return _g638_derivedBitmaps[derivedBitmapIndex];
 }
 
 void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 397417f..ca478b3 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -36,74 +36,78 @@
 
 namespace DM {
 
+#define k2_FloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT
+#define k13_WallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT
+#define k18_StairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT
+#define k3_DoorSetGraphicsCount 3 // @ C003_DOOR_SET_GRAPHIC_COUNT
+#define k1_DoorButtonCount 1 // @ C001_DOOR_BUTTON_COUNT
+#define k3_AlcoveOrnCount 3 // @ C003_ALCOVE_ORNAMENT_COUNT
+#define k1_FountainOrnCount 1 // @ C001_FOUNTAIN_ORNAMENT_COUNT
+#define k27_CreatureTypeCount 27 // @ C027_CREATURE_TYPE_COUNT
+#define k4_ExplosionAspectCount 4 // @ C004_EXPLOSION_ASPECT_COUNT
+#define k14_ProjectileAspectCount 14 // @ C014_PROJECTILE_ASPECT_COUNT
+#define k85_ObjAspectCount 85 // @ C085_OBJECT_ASPECT_COUNT
+
+#define k0_NativeBitmapIndex 0 // @ C0_NATIVE_BITMAP_INDEX
+#define k1_CoordinateSet 1 // @ C1_COORDINATE_SET
 
 /* View lanes */
-#define kViewLaneCenter 0 // @ C0_VIEW_LANE_CENTER 
-#define kViewLaneLeft 1 // @ C1_VIEW_LANE_LEFT   
-#define kViewLaneRight 2 // @ C2_VIEW_LANE_RIGHT  
+#define k0_ViewLaneCenter 0 // @ C0_VIEW_LANE_CENTER 
+#define k1_ViewLaneLeft 1 // @ C1_VIEW_LANE_LEFT   
+#define k2_ViewLaneRight 2 // @ C2_VIEW_LANE_RIGHT  
 
-#define kHalfSizedViewCell_LeftColumn 0 // @ C00_VIEW_CELL_LEFT_COLUMN  
-#define kHalfSizedViewCell_RightColumn 1 // @ C01_VIEW_CELL_RIGHT_COLUMN 
-#define kHalfSizedViewCell_BackRow 2 // @ C02_VIEW_CELL_BACK_ROW     
-#define kHalfSizedViewCell_CenterColumn 3 // @ C03_VIEW_CELL_CENTER_COLUMN
-#define kHalfSizedViewCell_FrontRow 4 // @ C04_VIEW_CELL_FRONT_ROW    
+#define k0_HalfSizedViewCell_LeftColumn 0 // @ C00_VIEW_CELL_LEFT_COLUMN  
+#define k1_HalfSizedViewCell_RightColumn 1 // @ C01_VIEW_CELL_RIGHT_COLUMN 
+#define k2_HalfSizedViewCell_BackRow 2 // @ C02_VIEW_CELL_BACK_ROW     
+#define k3_HalfSizedViewCell_CenterColumn 3 // @ C03_VIEW_CELL_CENTER_COLUMN
+#define k4_HalfSizedViewCell_FrontRow 4 // @ C04_VIEW_CELL_FRONT_ROW    
 
 /* Shift sets */
-#define kShiftSet_D0BackD1Front 0 // @ C0_SHIFT_SET_D0_BACK_OR_D1_FRONT
-#define kShiftSet_D1BackD2Front 1 // @ C1_SHIFT_SET_D1_BACK_OR_D2_FRONT
-#define kShiftSet_D2BackD3Front 2 // @ C2_SHIFT_SET_D2_BACK_OR_D3_FRONT
-
-#define kCellOrder_DoorFront 0x0008 // @ MASK0x0008_DOOR_FRONT                                   
-#define kCellOrder_Alcove 0x0000 // @ C0000_CELL_ORDER_ALCOVE                                 
-#define kCellOrder_BackLeft 0x0001 // @ C0001_CELL_ORDER_BACKLEFT                               
-#define kCellOrder_BackRight 0x0002 // @ C0002_CELL_ORDER_BACKRIGHT                              
-#define kCellOrder_DoorPass1_BackLeft 0x0018 // @ C0018_CELL_ORDER_DOORPASS1_BACKLEFT                     
-#define kCellOrder_BackLeft_BackRight 0x0021 // @ C0021_CELL_ORDER_BACKLEFT_BACKRIGHT                     
-#define kCellOrder_DoorPass1_BackRight 0x0028 // @ C0028_CELL_ORDER_DOORPASS1_BACKRIGHT                    
-#define kCellOrder_BackRight_FrontRight 0x0032 // @ C0032_CELL_ORDER_BACKRIGHT_FRONTRIGHT                   
-#define kCellOrder_DoorPass2_FrontRight 0x0039 // @ C0039_CELL_ORDER_DOORPASS2_FRONTRIGHT                   
-#define kCellOrder_BackLeft_FrontLeft 0x0041 // @ C0041_CELL_ORDER_BACKLEFT_FRONTLEFT                     
-#define kCellOrder_DoorPass2_FrontLeft 0x0049 // @ C0049_CELL_ORDER_DOORPASS2_FRONTLEFT                    
-#define kCellOrder_DoorPass1_BackRight_BackLeft 0x0128 // @ C0128_CELL_ORDER_DOORPASS1_BACKRIGHT_BACKLEFT           
-#define kCellOrder_DoorPass1_BackLeft_BackRight 0x0218 // @ C0218_CELL_ORDER_DOORPASS1_BACKLEFT_BACKRIGHT           
-#define kCellOrder_BackLeft_BackRight_FrontRight 0x0321 // @ C0321_CELL_ORDER_BACKLEFT_BACKRIGHT_FRONTRIGHT          
-#define kCellOrder_BackRight_FrontLeft_FrontRight 0x0342 // @ C0342_CELL_ORDER_BACKRIGHT_FRONTLEFT_FRONTRIGHT         
-#define kCellOrder_DoorPass2_FrontLeft_FrontRight 0x0349 // @ C0349_CELL_ORDER_DOORPASS2_FRONTLEFT_FRONTRIGHT         
-#define kCellOrder_BackRight_BackLeft_FrontLeft 0x0412 // @ C0412_CELL_ORDER_BACKRIGHT_BACKLEFT_FRONTLEFT           
-#define kCellOrder_BackLeft_FrontRight_FrontLeft 0x0431 // @ C0431_CELL_ORDER_BACKLEFT_FRONTRIGHT_FRONTLEFT          
-#define kCellOrder_DoorPass2_FrontRight_FrontLeft 0x0439 // @ C0439_CELL_ORDER_DOORPASS2_FRONTRIGHT_FRONTLEFT         
-#define kCellOrder_BackLeft_BackRight_FrontLeft_FrontRight 0x3421 // @ C3421_CELL_ORDER_BACKLEFT_BACKRIGHT_FRONTLEFT_FRONTRIGHT
-#define kCellOrder_BackRight_BackLeft_FrontRight_FrontLeft 0x4312 // @ C4312_CELL_ORDER_BACKRIGHT_BACKLEFT_FRONTRIGHT_FRONTLEFT
-
-
-#define kFloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT
-#define kWallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT
-#define kStairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT
-#define kDoorSetGraphicsCount 3 // @ C003_DOOR_SET_GRAPHIC_COUNT
-#define kDoorButtonCount 1 // @ C001_DOOR_BUTTON_COUNT
-#define kNativeBitmapIndex 0 // @ C0_NATIVE_BITMAP_INDEX
-#define kCoordinateSet 1 // @ C1_COORDINATE_SET
-#define kCreatureTypeCount 27 // @ C027_CREATURE_TYPE_COUNT
-#define kExplosionAspectCount 4 // @ C004_EXPLOSION_ASPECT_COUNT
-#define kObjAspectCount 85 // @ C085_OBJECT_ASPECT_COUNT
-#define kProjectileAspectCount 14 // @ C014_PROJECTILE_ASPECT_COUNT
+#define k0_ShiftSet_D0BackD1Front 0 // @ C0_SHIFT_SET_D0_BACK_OR_D1_FRONT
+#define k1_ShiftSet_D1BackD2Front 1 // @ C1_SHIFT_SET_D1_BACK_OR_D2_FRONT
+#define k2_ShiftSet_D2BackD3Front 2 // @ C2_SHIFT_SET_D2_BACK_OR_D3_FRONT
+
+#define k0x0008_CellOrder_DoorFront 0x0008 // @ MASK0x0008_DOOR_FRONT                                   
+#define k0x0000_CellOrder_Alcove 0x0000 // @ C0000_CELL_ORDER_ALCOVE                                 
+#define k0x0001_CellOrder_BackLeft 0x0001 // @ C0001_CELL_ORDER_BACKLEFT                               
+#define k0x0002_CellOrder_BackRight 0x0002 // @ C0002_CELL_ORDER_BACKRIGHT                              
+#define k0x0018_CellOrder_DoorPass1_BackLeft 0x0018 // @ C0018_CELL_ORDER_DOORPASS1_BACKLEFT                     
+#define k0x0021_CellOrder_BackLeft_BackRight 0x0021 // @ C0021_CELL_ORDER_BACKLEFT_BACKRIGHT                     
+#define k0x0028_CellOrder_DoorPass1_BackRight 0x0028 // @ C0028_CELL_ORDER_DOORPASS1_BACKRIGHT                    
+#define k0x0032_CellOrder_BackRight_FrontRight 0x0032 // @ C0032_CELL_ORDER_BACKRIGHT_FRONTRIGHT                   
+#define k0x0039_CellOrder_DoorPass2_FrontRight 0x0039 // @ C0039_CELL_ORDER_DOORPASS2_FRONTRIGHT                   
+#define k0x0041_CellOrder_BackLeft_FrontLeft 0x0041 // @ C0041_CELL_ORDER_BACKLEFT_FRONTLEFT                     
+#define k0x0049_CellOrder_DoorPass2_FrontLeft 0x0049 // @ C0049_CELL_ORDER_DOORPASS2_FRONTLEFT                    
+#define k0x0128_CellOrder_DoorPass1_BackRight_BackLeft 0x0128 // @ C0128_CELL_ORDER_DOORPASS1_BACKRIGHT_BACKLEFT           
+#define k0x0218_CellOrder_DoorPass1_BackLeft_BackRight 0x0218 // @ C0218_CELL_ORDER_DOORPASS1_BACKLEFT_BACKRIGHT           
+#define k0x0321_CellOrder_BackLeft_BackRight_FrontRight 0x0321 // @ C0321_CELL_ORDER_BACKLEFT_BACKRIGHT_FRONTRIGHT          
+#define k0x0342_CellOrder_BackRight_FrontLeft_FrontRight 0x0342 // @ C0342_CELL_ORDER_BACKRIGHT_FRONTLEFT_FRONTRIGHT         
+#define k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight 0x0349 // @ C0349_CELL_ORDER_DOORPASS2_FRONTLEFT_FRONTRIGHT         
+#define k0x0412_CellOrder_BackRight_BackLeft_FrontLeft 0x0412 // @ C0412_CELL_ORDER_BACKRIGHT_BACKLEFT_FRONTLEFT           
+#define k0x0431_CellOrder_BackLeft_FrontRight_FrontLeft 0x0431 // @ C0431_CELL_ORDER_BACKLEFT_FRONTRIGHT_FRONTLEFT          
+#define k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft 0x0439 // @ C0439_CELL_ORDER_DOORPASS2_FRONTRIGHT_FRONTLEFT         
+#define k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight 0x3421 // @ C3421_CELL_ORDER_BACKLEFT_BACKRIGHT_FRONTLEFT_FRONTRIGHT
+#define k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft 0x4312 // @ C4312_CELL_ORDER_BACKRIGHT_BACKLEFT_FRONTRIGHT_FRONTLEFT
+
+
+
 
 /* Explosion aspects */
-#define kExplosionAspectFire 0 // @ C0_EXPLOSION_ASPECT_FIRE  
-#define kExplosionAspectSpell 1 // @ C1_EXPLOSION_ASPECT_SPELL 
-#define kExplosionAspectPoison 2 // @ C2_EXPLOSION_ASPECT_POISON
-#define kExplosionAspectSmoke 3 // @ C3_EXPLOSION_ASPECT_SMOKE 
+#define k0_ExplosionAspectFire 0 // @ C0_EXPLOSION_ASPECT_FIRE  
+#define k1_ExplosionAspectSpell 1 // @ C1_EXPLOSION_ASPECT_SPELL 
+#define k2_ExplosionAspectPoison 2 // @ C2_EXPLOSION_ASPECT_POISON
+#define k3_ExplosionAspectSmoke 3 // @ C3_EXPLOSION_ASPECT_SMOKE 
 
 /* Creature info GraphicInfo */
-#define kCreatureInfoGraphicMaskAdditional 0x0003 // @ MASK0x0003_ADDITIONAL                        
-#define kCreatureInfoGraphicMaskFlipNonAttack 0x0004 // @ MASK0x0004_FLIP_NON_ATTACK                  
-#define kCreatureInfoGraphicMaskSide 0x0008 // @ MASK0x0008_SIDE                             
-#define kCreatureInfoGraphicMaskBack 0x0010 // @ MASK0x0010_BACK                             
-#define kCreatureInfoGraphicMaskAttack 0x0020 // @ MASK0x0020_ATTACK                           
-#define kCreatureInfoGraphicMaskSpecialD2Front 0x0080 // @ MASK0x0080_SPECIAL_D2_FRONT                                                                               
-#define kCreatureInfoGraphicMaskSpecialD2FrontIsFlipped 0x0100 // @ MASK0x0100_SPECIAL_D2_FRONT_IS_FLIPPED_FRONT 
-#define kCreatureInfoGraphicMaskFlipAttack 0x0200 // @ MASK0x0200_FLIP_ATTACK                      
-#define kCreatureInfoGraphicMaskFlipDuringAttack 0x0400 // @ MASK0x0400_FLIP_DURING_ATTACK               
+#define k0x0003_CreatureInfoGraphicMaskAdditional 0x0003 // @ MASK0x0003_ADDITIONAL                        
+#define k0x0004_CreatureInfoGraphicMaskFlipNonAttack 0x0004 // @ MASK0x0004_FLIP_NON_ATTACK                  
+#define k0x0008_CreatureInfoGraphicMaskSide 0x0008 // @ MASK0x0008_SIDE                             
+#define k0x0010_CreatureInfoGraphicMaskBack 0x0010 // @ MASK0x0010_BACK                             
+#define k0x0020_CreatureInfoGraphicMaskAttack 0x0020 // @ MASK0x0020_ATTACK                           
+#define k0x0080_CreatureInfoGraphicMaskSpecialD2Front 0x0080 // @ MASK0x0080_SPECIAL_D2_FRONT                                                                               
+#define k0x0100_CreatureInfoGraphicMaskSpecialD2FrontIsFlipped 0x0100 // @ MASK0x0100_SPECIAL_D2_FRONT_IS_FLIPPED_FRONT 
+#define k0x0200_CreatureInfoGraphicMaskFlipAttack 0x0200 // @ MASK0x0200_FLIP_ATTACK                      
+#define k0x0400_CreatureInfoGraphicMaskFlipDuringAttack 0x0400 // @ MASK0x0400_FLIP_DURING_ATTACK               
 
 class ExplosionAspect {
 public:
@@ -113,118 +117,118 @@ public:
 	ExplosionAspect(uint16 byteWidth, uint16 height) :_pixelWidth(byteWidth * 2), _height(height) {}
 }; // @ EXPLOSION_ASPECT
 
-extern ExplosionAspect gExplosionAspects[kExplosionAspectCount];
+extern ExplosionAspect g211_ExplosionAspects[k4_ExplosionAspectCount]; // @ G0211_as_Graphic558_ExplosionAspects
 
-extern byte gProjectileScales[7]; // @ G0215_auc_Graphic558_ProjectileScales
+extern byte g215_ProjectileScales[7]; // @ G0215_auc_Graphic558_ProjectileScales
 
 
-#define kDerivedBitmapViewport 0 // @ C000_DERIVED_BITMAP_VIEWPORT                    
-#define kDerivedBitmapThievesEyeVisibleArea 1 // @ C001_DERIVED_BITMAP_THIEVES_EYE_VISIBLE_AREA    
-#define kDerivedBitmapDamageToCreatureMedium 2 // @ C002_DERIVED_BITMAP_DAMAGE_TO_CREATURE_MEDIUM   
-#define kDerivedBitmapDamageToCreatureSmall 3 // @ C003_DERIVED_BITMAP_DAMAGE_TO_CREATURE_SMALL    
-#define kDerivedBitmapFirstWallOrnament 4 // @ C004_DERIVED_BITMAP_FIRST_WALL_ORNAMENT         
-#define kDerivedBitmapFirstDoorOrnament_D3 68 // @ C068_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D3     
-#define kDerivedBitmapFirstDoorOrnament_D2 69 // @ C069_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D2    
-#define kDerivedBitmapFirstDoorButton 102 // @ C102_DERIVED_BITMAP_FIRST_DOOR_BUTTON         
-#define kDerivedBitmapFirstObject 104 // @ C104_DERIVED_BITMAP_FIRST_OBJECT              
-#define kDerivedBitmapFirstProjectile 282 // @ C282_DERIVED_BITMAP_FIRST_PROJECTILE          
-#define kDerivedBitmapFirstExplosion 438 // @ C438_DERIVED_BITMAP_FIRST_EXPLOSION           
-#define kDerivedBitmapFirstCreature 495 // @ C495_DERIVED_BITMAP_FIRST_CREATURE            
+#define k0_DerivedBitmapViewport 0 // @ C000_DERIVED_BITMAP_VIEWPORT                    
+#define k1_DerivedBitmapThievesEyeVisibleArea 1 // @ C001_DERIVED_BITMAP_THIEVES_EYE_VISIBLE_AREA    
+#define k2_DerivedBitmapDamageToCreatureMedium 2 // @ C002_DERIVED_BITMAP_DAMAGE_TO_CREATURE_MEDIUM   
+#define k3_DerivedBitmapDamageToCreatureSmall 3 // @ C003_DERIVED_BITMAP_DAMAGE_TO_CREATURE_SMALL    
+#define k4_DerivedBitmapFirstWallOrnament 4 // @ C004_DERIVED_BITMAP_FIRST_WALL_ORNAMENT         
+#define k68_DerivedBitmapFirstDoorOrnament_D3 68 // @ C068_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D3     
+#define k69_DerivedBitmapFirstDoorOrnament_D2 69 // @ C069_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D2    
+#define k102_DerivedBitmapFirstDoorButton 102 // @ C102_DERIVED_BITMAP_FIRST_DOOR_BUTTON         
+#define k104_DerivedBitmapFirstObject 104 // @ C104_DERIVED_BITMAP_FIRST_OBJECT              
+#define k282_DerivedBitmapFirstProjectile 282 // @ C282_DERIVED_BITMAP_FIRST_PROJECTILE          
+#define k438_DerivedBitmapFirstExplosion 438 // @ C438_DERIVED_BITMAP_FIRST_EXPLOSION           
+#define k495_DerivedBitmapFirstCreature 495 // @ C495_DERIVED_BITMAP_FIRST_CREATURE            
 
 
-#define kScale16_D3 16 // @ C16_SCALE_D3 
-#define kScale20_D2 20 // @ C20_SCALE_D2 
+#define k16_Scale_D3 16 // @ C16_SCALE_D3 
+#define k20_Scale_D2 20 // @ C20_SCALE_D2 
 
 /* Object aspect GraphicInfo */
-#define kObjectFlipOnRightMask 0x0001 // @ MASK0x0001_FLIP_ON_RIGHT 
-#define kObjectAlcoveMask 0x0010 // @ MASK0x0010_ALCOVE        
+#define k0x0001_ObjectFlipOnRightMask 0x0001 // @ MASK0x0001_FLIP_ON_RIGHT 
+#define k0x0010_ObjectAlcoveMask 0x0010 // @ MASK0x0010_ALCOVE        
 
 /* Projectile aspect GraphicInfo */
-#define kProjectileSideMask 0x0010 // @ MASK0x0010_SIDE                      
-#define kProjectileScaleWithKineticEnergyMask 0x0100 // @ MASK0x0100_SCALE_WITH_KINETIC_ENERGY 
-#define kProjectileAspectTypeMask 0x0003 // @ MASK0x0003_ASPECT_TYPE               
+#define k0x0010_ProjectileSideMask 0x0010 // @ MASK0x0010_SIDE                      
+#define k0x0100_ProjectileScaleWithKineticEnergyMask 0x0100 // @ MASK0x0100_SCALE_WITH_KINETIC_ENERGY 
+#define k0x0003_ProjectileAspectTypeMask 0x0003 // @ MASK0x0003_ASPECT_TYPE               
 
 /* Projectile aspect type */
-#define kProjectileAspectHasBackGraphicRotation 0 // @ C0_PROJECTILE_ASPECT_TYPE_HAS_BACK_GRAPHIC_AND_ROTATION   
-#define kProjectileAspectBackGraphic 1 // @ C1_PROJECTILE_ASPECT_TYPE_HAS_BACK_GRAPHIC_AND_NO_ROTATION
-#define kProjectileAspectHasRotation 2 // @ C2_PROJECTILE_ASPECT_TYPE_NO_BACK_GRAPHIC_AND_ROTATION    
-#define kProjectileAspectHasNone 3 // @ C3_PROJECTILE_ASPECT_TYPE_NO_BACK_GRAPHIC_AND_NO_ROTATION 
+#define k0_ProjectileAspectHasBackGraphicRotation 0 // @ C0_PROJECTILE_ASPECT_TYPE_HAS_BACK_GRAPHIC_AND_ROTATION   
+#define k1_ProjectileAspectBackGraphic 1 // @ C1_PROJECTILE_ASPECT_TYPE_HAS_BACK_GRAPHIC_AND_NO_ROTATION
+#define k2_ProjectileAspectHasRotation 2 // @ C2_PROJECTILE_ASPECT_TYPE_NO_BACK_GRAPHIC_AND_ROTATION    
+#define k3_ProjectileAspectHasNone 3 // @ C3_PROJECTILE_ASPECT_TYPE_NO_BACK_GRAPHIC_AND_NO_ROTATION 
 
 /* Projectile aspects */
-#define kProjectileAspectExplosionLightningBolt 3 // @ C03_PROJECTILE_ASPECT_EXPLOSION_LIGHTNING_BOLT           
-#define kProjectileAspectExplosionFireBall 10 // @ C10_PROJECTILE_ASPECT_EXPLOSION_FIREBALL                
-#define kProjectileAspectExplosionDefault 11 // @ C11_PROJECTILE_ASPECT_EXPLOSION_DEFAULT                 
-#define kProjectileAspectExplosionSlime 12 // @ C12_PROJECTILE_ASPECT_EXPLOSION_SLIME                   
-#define kProjectileAspectExplosionPoisonBoltCloud 13 // @ C13_PROJECTILE_ASPECT_EXPLOSION_POISON_BOLT_POISON_CLOUD
+#define k3_ProjectileAspectExplosionLightningBolt 3 // @ C03_PROJECTILE_ASPECT_EXPLOSION_LIGHTNING_BOLT           
+#define k10_ProjectileAspectExplosionFireBall 10 // @ C10_PROJECTILE_ASPECT_EXPLOSION_FIREBALL                
+#define k11_ProjectileAspectExplosionDefault 11 // @ C11_PROJECTILE_ASPECT_EXPLOSION_DEFAULT                 
+#define k12_ProjectileAspectExplosionSlime 12 // @ C12_PROJECTILE_ASPECT_EXPLOSION_SLIME                   
+#define k13_ProjectileAspectExplosionPoisonBoltCloud 13 // @ C13_PROJECTILE_ASPECT_EXPLOSION_POISON_BOLT_POISON_CLOUD
 
 enum ViewCell {
-	kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT
-	kViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT
-	kViewCellBackRight = 2, // @ C02_VIEW_CELL_BACK_RIGHT
-	kViewCellBackLeft = 3, // @ C03_VIEW_CELL_BACK_LEFT
-	kViewCellAlcove = 4, // @ C04_VIEW_CELL_ALCOVE
-	kViewCellDoorButtonOrWallOrn = 5 // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT
+	k0_ViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT
+	k1_ViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT
+	k2_ViewCellBackRight = 2, // @ C02_VIEW_CELL_BACK_RIGHT
+	k3_ViewCellBackLeft = 3, // @ C03_VIEW_CELL_BACK_LEFT
+	k4_ViewCellAlcove = 4, // @ C04_VIEW_CELL_ALCOVE
+	k5_ViewCellDoorButtonOrWallOrn = 5 // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT
 };
 
 enum GraphicIndice {
-	kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT
-	kDoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
-	kChampionPortraitsIndice = 26, // @ C026_GRAPHIC_CHAMPION_PORTRAITS
-	kMovementArrowsIndice = 13, // @ C013_GRAPHIC_MOVEMENT_ARROWS
-	kObjectIcons_000_TO_031 = 42, // @ C042_GRAPHIC_OBJECT_ICONS_000_TO_031
-	kObjectIcons_032_TO_063 = 43, // @ C043_GRAPHIC_OBJECT_ICONS_032_TO_063
-	kObjectIcons_064_TO_095 = 44, // @ C044_GRAPHIC_OBJECT_ICONS_064_TO_095
-	kObjectIcons_096_TO_127 = 45, // @ C045_GRAPHIC_OBJECT_ICONS_096_TO_127
-	kObjectIcons_128_TO_159 = 46, // @ C046_GRAPHIC_OBJECT_ICONS_128_TO_159
-	kObjectIcons_160_TO_191 = 47, // @ C047_GRAPHIC_OBJECT_ICONS_160_TO_191
-	kObjectIcons_192_TO_223 = 48, // @ C048_GRAPHIC_OBJECT_ICONS_192_TO_223
-	kInventoryGraphicIndice = 17, // @ C017_GRAPHIC_INVENTORY
-	kPanelEmptyIndice = 20, // @ C020_GRAPHIC_PANEL_EMPTY
-	kFoodLabelIndice = 30, // @ C030_GRAPHIC_FOOD_LABEL
-	kWaterLabelIndice = 31, // @ C031_GRAPHIC_WATER_LABEL
-	kPoisionedLabelIndice = 32, // @ C032_GRAPHIC_POISONED_LABEL
-	kPanelResurectReincaranteIndice = 40, // @ C040_GRAPHIC_PANEL_RESURRECT_REINCARNATE 
-	kBorderPartyShieldIndice = 37, // @ C037_GRAPHIC_BORDER_PARTY_SHIELD
-	kBorderPartyFireshieldIndice = 38, // @ C038_GRAPHIC_BORDER_PARTY_FIRESHIELD
-	kBorderPartySpellshieldIndice = 39, // @ C039_GRAPHIC_BORDER_PARTY_SPELLSHIELD
-	kStatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION
-	kSlotBoxNormalIndice = 33, // @ C033_GRAPHIC_SLOT_BOX_NORMAL                   
-	kSlotBoxWoundedIndice = 34, // @ C034_GRAPHIC_SLOT_BOX_WOUNDED                  
-	kChampionIcons = 28, // @ C028_GRAPHIC_CHAMPION_ICONS
-	kFontGraphicIndice = 557, // @ C557_GRAPHIC_FONT 
-	kSlotBoxActingHandIndice = 35, // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND
-	kPanelRenameChampionIndice = 27, // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION
-	kMenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA
-	kMenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES
-	kMenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND
-	kPanelOpenScrollIndice = 23, // @ C023_GRAPHIC_PANEL_OPEN_SCROLL
-	kPanelOpenChestIndice = 25, // @ C025_GRAPHIC_PANEL_OPEN_CHEST
-	kEyeForObjectDescriptionIndice = 19, // @ C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION
-	kArrowForChestContentIndice = 18, // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT
-	kObjectDescCircleIndice = 29, // @ C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE
-	kFloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS
-	kFieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R
-	kFieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER
-	kFirstExplosionGraphicIndice = 348, // @ C348_GRAPHIC_FIRST_EXPLOSION
-	kFirstObjectGraphicIndice = 360, // @ C360_GRAPHIC_FIRST_OBJECT
-	kFirstCreatureGraphicIndice = 446, // @ C446_GRAPHIC_FIRST_CREATURE
-	kFirstProjectileGraphicIndice = 316, // @ C316_GRAPHIC_FIRST_PROJECTILE 
-	kFirstExplosionPatternGraphicIndice = 351, // @ C351_GRAPHIC_FIRST_EXPLOSION_PATTERN 
-	k049FloorPit_D3L_GraphicIndice = 49, // @ C049_GRAPHIC_FLOOR_PIT_D3L
-	k050FloorPit_D3C_GraphicIndice = 50, // @ C050_GRAPHIC_FLOOR_PIT_D3C
-	k051FloorPit_D2L_GraphicIndice = 51, // @ C051_GRAPHIC_FLOOR_PIT_D2L
-	k052FloorPit_D2C_GraphicIndice = 52, // @ C052_GRAPHIC_FLOOR_PIT_D2C
-	k053FloorPit_D1L_GraphicIndice = 53, // @ C053_GRAPHIC_FLOOR_PIT_D1L
-	k054FloorPit_D1C_GraphicIndice = 54, // @ C054_GRAPHIC_FLOOR_PIT_D1C
-	k055FloorPit_D0L_GraphicIndice = 55, // @ C055_GRAPHIC_FLOOR_PIT_D0L
-	k056FloorPit_D0C_GraphicIndice = 56 // @ C056_GRAPHIC_FLOOR_PIT_D0C
+	k8_StatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION
+	k9_MenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND
+	k10_MenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA
+	k11_MenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES
+	k13_MovementArrowsIndice = 13, // @ C013_GRAPHIC_MOVEMENT_ARROWS
+	k17_InventoryGraphicIndice = 17, // @ C017_GRAPHIC_INVENTORY
+	k18_ArrowForChestContentIndice = 18, // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT
+	k19_EyeForObjectDescriptionIndice = 19, // @ C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION
+	k20_PanelEmptyIndice = 20, // @ C020_GRAPHIC_PANEL_EMPTY
+	k23_PanelOpenScrollIndice = 23, // @ C023_GRAPHIC_PANEL_OPEN_SCROLL
+	k25_PanelOpenChestIndice = 25, // @ C025_GRAPHIC_PANEL_OPEN_CHEST
+	k26_ChampionPortraitsIndice = 26, // @ C026_GRAPHIC_CHAMPION_PORTRAITS
+	k27_PanelRenameChampionIndice = 27, // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION
+	k28_ChampionIcons = 28, // @ C028_GRAPHIC_CHAMPION_ICONS
+	k29_ObjectDescCircleIndice = 29, // @ C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE
+	k30_FoodLabelIndice = 30, // @ C030_GRAPHIC_FOOD_LABEL
+	k31_WaterLabelIndice = 31, // @ C031_GRAPHIC_WATER_LABEL
+	k32_PoisionedLabelIndice = 32, // @ C032_GRAPHIC_POISONED_LABEL
+	k33_SlotBoxNormalIndice = 33, // @ C033_GRAPHIC_SLOT_BOX_NORMAL                   
+	k34_SlotBoxWoundedIndice = 34, // @ C034_GRAPHIC_SLOT_BOX_WOUNDED                  
+	k35_SlotBoxActingHandIndice = 35, // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND
+	k37_BorderPartyShieldIndice = 37, // @ C037_GRAPHIC_BORDER_PARTY_SHIELD
+	k38_BorderPartyFireshieldIndice = 38, // @ C038_GRAPHIC_BORDER_PARTY_FIRESHIELD
+	k39_BorderPartySpellshieldIndice = 39, // @ C039_GRAPHIC_BORDER_PARTY_SPELLSHIELD
+	k40_PanelResurectReincaranteIndice = 40, // @ C040_GRAPHIC_PANEL_RESURRECT_REINCARNATE 
+	k42_ObjectIcons_000_TO_031 = 42, // @ C042_GRAPHIC_OBJECT_ICONS_000_TO_031
+	k43_ObjectIcons_032_TO_063 = 43, // @ C043_GRAPHIC_OBJECT_ICONS_032_TO_063
+	k44_ObjectIcons_064_TO_095 = 44, // @ C044_GRAPHIC_OBJECT_ICONS_064_TO_095
+	k45_ObjectIcons_096_TO_127 = 45, // @ C045_GRAPHIC_OBJECT_ICONS_096_TO_127
+	k46_ObjectIcons_128_TO_159 = 46, // @ C046_GRAPHIC_OBJECT_ICONS_128_TO_159
+	k47_ObjectIcons_160_TO_191 = 47, // @ C047_GRAPHIC_OBJECT_ICONS_160_TO_191
+	k48_ObjectIcons_192_TO_223 = 48, // @ C048_GRAPHIC_OBJECT_ICONS_192_TO_223
+	k49_FloorPit_D3L_GraphicIndice = 49, // @ C049_GRAPHIC_FLOOR_PIT_D3L
+	k50_FloorPit_D3C_GraphicIndice = 50, // @ C050_GRAPHIC_FLOOR_PIT_D3C
+	k51_FloorPit_D2L_GraphicIndice = 51, // @ C051_GRAPHIC_FLOOR_PIT_D2L
+	k52_FloorPit_D2C_GraphicIndice = 52, // @ C052_GRAPHIC_FLOOR_PIT_D2C
+	k53_FloorPit_D1L_GraphicIndice = 53, // @ C053_GRAPHIC_FLOOR_PIT_D1L
+	k54_FloorPit_D1C_GraphicIndice = 54, // @ C054_GRAPHIC_FLOOR_PIT_D1C
+	k55_FloorPit_D0L_GraphicIndice = 55, // @ C055_GRAPHIC_FLOOR_PIT_D0L
+	k56_FloorPit_D0C_GraphicIndice = 56, // @ C056_GRAPHIC_FLOOR_PIT_D0C
+	k69_FieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R
+	k73_FieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER
+	k120_InscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT
+	k241_FloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS
+	k301_DoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
+	k316_FirstProjectileGraphicIndice = 316, // @ C316_GRAPHIC_FIRST_PROJECTILE 
+	k348_FirstExplosionGraphicIndice = 348, // @ C348_GRAPHIC_FIRST_EXPLOSION
+	k351_FirstExplosionPatternGraphicIndice = 351, // @ C351_GRAPHIC_FIRST_EXPLOSION_PATTERN 
+	k360_FirstObjectGraphicIndice = 360, // @ C360_GRAPHIC_FIRST_OBJECT
+	k446_FirstCreatureGraphicIndice = 446, // @ C446_GRAPHIC_FIRST_CREATURE
+	k557_FontGraphicIndice = 557 // @ C557_GRAPHIC_FONT 
 };
 
-extern uint16 gPalSwoosh[16];
-extern uint16 gPalMousePointer[16];
-extern uint16 gPalCredits[16];
-extern uint16 gPalEntrance[16];
-extern uint16 gPalDungeonView[6][16];
+extern uint16 gK57_PalSwoosh[16]; // @ K0057_aui_Palette_Swoosh
+extern uint16 gK150_PalMousePointer[16];	// @ K0150_aui_Palette_MousePointer
+extern uint16 g19_PalCredits[16];  // @ G0019_aui_Graphic562_Palette_Credits
+extern uint16 g20_PalEntrance[16]; // @ G0020_aui_Graphic562_Palette_Entrance
+extern uint16 g21_PalDungeonView[6][16]; // @ G0021_aaui_Graphic562_Palette_DungeonView
 
 class Box {
 public:
@@ -241,7 +245,7 @@ public:
 	void setToZero() { _x1 = _x2 = _y1 = _y2 = 0; }
 }; // @ BOX_BYTE, BOX_WORD
 
-extern Box gBoxMovementArrows; // G0002_s_Graphic562_Box_MovementArrows
+extern Box g2_BoxMovementArrows; // G0002_s_Graphic562_Box_MovementArrows
 
 class Frame {
 public:
@@ -257,47 +261,47 @@ public:
 };
 
 enum WallSet {
-	kWallSetStone = 0 // @ C0_WALL_SET_STONE
+	k0_WallSetStone = 0 // @ C0_WALL_SET_STONE
 };
 
 enum FloorSet {
-	kFloorSetStone = 0 // @ C0_FLOOR_SET_STONE
+	k0_FloorSetStone = 0 // @ C0_FLOOR_SET_STONE
 };
 
 enum ViewWall {
-	kViewWall_D3L_RIGHT = 0, // @ C00_VIEW_WALL_D3L_RIGHT 
-	kViewWall_D3R_LEFT = 1, // @ C01_VIEW_WALL_D3R_LEFT  
-	kViewWall_D3L_FRONT = 2, // @ C02_VIEW_WALL_D3L_FRONT 
-	kViewWall_D3C_FRONT = 3, // @ C03_VIEW_WALL_D3C_FRONT 
-	kViewWall_D3R_FRONT = 4, // @ C04_VIEW_WALL_D3R_FRONT 
-	kViewWall_D2L_RIGHT = 5, // @ C05_VIEW_WALL_D2L_RIGHT 
-	kViewWall_D2R_LEFT = 6, // @ C06_VIEW_WALL_D2R_LEFT  
-	kViewWall_D2L_FRONT = 7, // @ C07_VIEW_WALL_D2L_FRONT 
-	kViewWall_D2C_FRONT = 8, // @ C08_VIEW_WALL_D2C_FRONT 
-	kViewWall_D2R_FRONT = 9, // @ C09_VIEW_WALL_D2R_FRONT 
-	kViewWall_D1L_RIGHT = 10, // @ C10_VIEW_WALL_D1L_RIGHT
-	kViewWall_D1R_LEFT = 11, // @ C11_VIEW_WALL_D1R_LEFT 
-	kViewWall_D1C_FRONT = 12  // @ C12_VIEW_WALL_D1C_FRONT
+	k0_ViewWall_D3L_RIGHT = 0, // @ C00_VIEW_WALL_D3L_RIGHT 
+	k1_ViewWall_D3R_LEFT = 1, // @ C01_VIEW_WALL_D3R_LEFT  
+	k2_ViewWall_D3L_FRONT = 2, // @ C02_VIEW_WALL_D3L_FRONT 
+	k3_ViewWall_D3C_FRONT = 3, // @ C03_VIEW_WALL_D3C_FRONT 
+	k4_ViewWall_D3R_FRONT = 4, // @ C04_VIEW_WALL_D3R_FRONT 
+	k5_ViewWall_D2L_RIGHT = 5, // @ C05_VIEW_WALL_D2L_RIGHT 
+	k6_ViewWall_D2R_LEFT = 6, // @ C06_VIEW_WALL_D2R_LEFT  
+	k7_ViewWall_D2L_FRONT = 7, // @ C07_VIEW_WALL_D2L_FRONT 
+	k8_ViewWall_D2C_FRONT = 8, // @ C08_VIEW_WALL_D2C_FRONT 
+	k9_ViewWall_D2R_FRONT = 9, // @ C09_VIEW_WALL_D2R_FRONT 
+	k10_ViewWall_D1L_RIGHT = 10, // @ C10_VIEW_WALL_D1L_RIGHT
+	k11_ViewWall_D1R_LEFT = 11, // @ C11_VIEW_WALL_D1R_LEFT 
+	k12_ViewWall_D1C_FRONT = 12  // @ C12_VIEW_WALL_D1C_FRONT
 };
 
 enum Color {
-	kColorNoTransparency = 255,
-	kColorBlack = 0,
-	kColorDarkGary = 1,
-	kColorLightGray = 2,
-	kColorDarkBrown = 3,
-	kColorCyan = 4,
-	kColorLightBrown = 5,
-	kColorDarkGreen = 6,
-	kColorLightGreen = 7,
-	kColorRed = 8,
-	kColorGold = 9,
-	kColorFlesh = 10,
-	kColorYellow = 11,
-	kColorDarkestGray = 12,
-	kColorLightestGray = 13,
-	kColorBlue = 14,
-	kColorWhite = 15
+	k255_ColorNoTransparency = 255,
+	k0_ColorBlack = 0,
+	k1_ColorDarkGary = 1,
+	k2_ColorLightGray = 2,
+	k3_ColorDarkBrown = 3,
+	k4_ColorCyan = 4,
+	k5_ColorLightBrown = 5,
+	k6_ColorDarkGreen = 6,
+	k7_ColorLightGreen = 7,
+	k8_ColorRed = 8,
+	k9_ColorGold = 9,
+	k10_ColorFlesh = 10,
+	k11_ColorYellow = 11,
+	k12_ColorDarkestGray = 12,
+	k13_ColorLightestGray = 13,
+	k14_ColorBlue = 14,
+	k15_ColorWhite = 15
 };
 
 class FieldAspect {
@@ -326,7 +330,8 @@ public:
 		:_posX(posX), _posY(posY), _width(width), _height(height) {}
 };
 
-struct CreatureAspect {
+class CreatureAspect {
+public:
 	uint16 _firstNativeBitmapRelativeIndex;
 	uint16 _firstDerivedBitmapIndex;
 	byte _byteWidthFront;
@@ -335,16 +340,33 @@ struct CreatureAspect {
 	byte _heightSide;
 	byte _byteWidthAttack;
 	byte _heightAttack;
+private:
 	byte _coordinateSet_TransparentColor;
 	byte _replacementColorSetIndices;
+public:
+
+	CreatureAspect(uint16 uint161, uint16 uint162, byte byte0, byte byte1, byte byte2, byte byte3, byte byte4, byte byte5, byte byte6, byte byte7)
+		: _firstNativeBitmapRelativeIndex(uint161),
+		_firstDerivedBitmapIndex(uint162),
+		_byteWidthFront(byte0 * 2),
+		_heightFront(byte1),
+		_byteWidthSide(byte2 * 2),
+		_heightSide(byte3),
+		_byteWidthAttack(byte4 * 2),
+		_heightAttack(byte5),
+		_coordinateSet_TransparentColor(byte6),
+		_replacementColorSetIndices(byte7) {}
 
 	byte getCoordSet() { return (_coordinateSet_TransparentColor >> 4) & 0xF; } // @ M71_COORDINATE_SET
 	byte getTranspColour() { return  _coordinateSet_TransparentColor & 0xF; } // @ M72_TRANSPARENT_COLOR
 	byte getReplColour10() { return (_replacementColorSetIndices >> 4) & 0xF; } // @ M74_COLOR_10_REPLACEMENT_COLOR_SET
 	byte getReplColour9() { return _replacementColorSetIndices & 0xF; } // @ M73_COLOR_09_REPLACEMENT_COLOR_SET
+
+
 }; // @ CREATURE_ASPECT
 
-struct ObjectAspect {
+class ObjectAspect {
+public:
 	byte _firstNativeBitmapRelativeIndex;
 	byte _firstDerivedBitmapRelativeIndex;
 	byte _width;
@@ -356,7 +378,8 @@ struct ObjectAspect {
 		_width(byteWidth * 2), _height(h), _graphicInfo(grap), _coordinateSet(coord) {}
 }; // @ OBJECT_ASPECT
 
-struct ProjectileAspect {
+class ProjectileAspect {
+public:
 	byte _firstNativeBitmapRelativeIndex;
 	byte _firstDerivedBitmapRelativeIndex;
 	byte _width;
@@ -368,7 +391,8 @@ struct ProjectileAspect {
 		_width(byteWidth * 2), _height(h), _graphicInfo(grap) {}
 }; // @ PROJECTIL_ASPECT
 
-struct CreatureReplColorSet {
+class CreatureReplColorSet {
+public:
 	uint16 _RGBColor[6];
 	byte _D2ReplacementColor;
 	byte _D3ReplacementColor;
@@ -377,15 +401,12 @@ struct CreatureReplColorSet {
 extern Viewport gDefultViewPort;
 extern Viewport gDungeonViewport;
 
-#define kAlcoveOrnCount 3
-#define kFountainOrnCount 1
-
 
-#define kDoorButton 0 // @ C0_DOOR_BUTTON
-#define kWallOrnInscription 0 // @ C0_WALL_ORNAMENT_INSCRIPTION
-#define kFloorOrnFootprints 15 // @ C15_FLOOR_ORNAMENT_FOOTPRINTS
-#define kDoorOrnDestroyedMask 15 // @ C15_DOOR_ORNAMENT_DESTROYED_MASK
-#define kDoorOrnThivesEyeMask 16 // @ C16_DOOR_ORNAMENT_THIEVES_EYE_MASK
+#define k0_DoorButton 0 // @ C0_DOOR_BUTTON
+#define k0_WallOrnInscription 0 // @ C0_WALL_ORNAMENT_INSCRIPTION
+#define k15_FloorOrnFootprints 15 // @ C15_FLOOR_ORNAMENT_FOOTPRINTS
+#define k15_DoorOrnDestroyedMask 15 // @ C15_DOOR_ORNAMENT_DESTROYED_MASK
+#define k16_DoorOrnThivesEyeMask 16 // @ C16_DOOR_ORNAMENT_THIEVES_EYE_MASK
 
 class DisplayMan {
 	friend class DM::TextMan;
@@ -405,9 +426,9 @@ class DisplayMan {
 	byte *_wallSetBitMaps[25];	// @G[0696..0710]_puc_Bitmap_WallSet_...
 
 	// pointers are not owned by these fields
-	byte *_floorBitmap;
-	byte *_ceilingBitmap;
-	byte *_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile
+	byte *_g84_floorBitmap; // @ G0084_puc_Bitmap_Floor
+	byte *_g85_ceilingBitmap; // @ G0085_puc_Bitmap_Ceiling
+	byte *_g75_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile
 
 	DisplayMan(const DisplayMan &other); // no implementation on purpose
 	void operator=(const DisplayMan &rhs); // no implementation on purpose
@@ -440,30 +461,30 @@ class DisplayMan {
 
 	bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF
 
-	uint16 *_derivedBitmapByteCount; // @ G0639_pui_DerivedBitmapByteCount
-	byte **_derivedBitmaps; // @ G0638_pui_DerivedBitmapBlockIndices
-
-	int16 _g0675stairsNativeBitmapIndex_Up_Front_D3L; // @ G0675_i_StairsNativeBitmapIndex_Up_Front_D3L
-	int16 _g0676stairsNativeBitmapIndex_Up_Front_D3C; // @ G0676_i_StairsNativeBitmapIndex_Up_Front_D3C
-	int16 _g0677stairsNativeBitmapIndex_Up_Front_D2L; // @ G0677_i_StairsNativeBitmapIndex_Up_Front_D2L
-	int16 _g0678stairsNativeBitmapIndex_Up_Front_D2C; // @ G0678_i_StairsNativeBitmapIndex_Up_Front_D2C
-	int16 _g0679stairsNativeBitmapIndex_Up_Front_D1L; // @ G0679_i_StairsNativeBitmapIndex_Up_Front_D1L
-	int16 _g0680stairsNativeBitmapIndex_Up_Front_D1C; // @ G0680_i_StairsNativeBitmapIndex_Up_Front_D1C
-	int16 _g0681stairsNativeBitmapIndex_Up_Front_D0C_Left; // @ G0681_i_StairsNativeBitmapIndex_Up_Front_D0C_Left
-	int16 _g0682stairsNativeBitmapIndex_Down_Front_D3L; // @ G0682_i_StairsNativeBitmapIndex_Down_Front_D3L
-	int16 _g0683stairsNativeBitmapIndex_Down_Front_D3C; // @ G0683_i_StairsNativeBitmapIndex_Down_Front_D3C
-	int16 _g0684stairsNativeBitmapIndex_Down_Front_D2L; // @ G0684_i_StairsNativeBitmapIndex_Down_Front_D2L
-	int16 _g0685stairsNativeBitmapIndex_Down_Front_D2C; // @ G0685_i_StairsNativeBitmapIndex_Down_Front_D2C
-	int16 _g0686stairsNativeBitmapIndex_Down_Front_D1L; // @ G0686_i_StairsNativeBitmapIndex_Down_Front_D1L
-	int16 _g0687stairsNativeBitmapIndex_Down_Front_D1C; // @ G0687_i_StairsNativeBitmapIndex_Down_Front_D1C
-	int16 _g0688stairsNativeBitmapIndex_Down_Front_D0C_Left; // @ G0688_i_StairsNativeBitmapIndex_Down_Front_D0C_Left
-	int16 _g0689stairsNativeBitmapIndex_Side_D2L; // @ G0689_i_StairsNativeBitmapIndex_Side_D2L
-	int16 _g0690stairsNativeBitmapIndex_Up_Side_D1L; // @ G0690_i_StairsNativeBitmapIndex_Up_Side_D1L
-	int16 _g0691stairsNativeBitmapIndex_Down_Side_D1L; // @ G0691_i_StairsNativeBitmapIndex_Down_Side_D1L
-	int16 _g0692stairsNativeBitmapIndex_Side_D0L; // @ G0692_i_StairsNativeBitmapIndex_Side_D0L
+	uint16 *_g639_derivedBitmapByteCount; // @ G0639_pui_DerivedBitmapByteCount
+	byte **_g638_derivedBitmaps; // @ G0638_pui_DerivedBitmapBlockIndices
+
+	int16 _g675_stairsNativeBitmapIndex_Up_Front_D3L; // @ G0675_i_StairsNativeBitmapIndex_Up_Front_D3L
+	int16 _g676_stairsNativeBitmapIndex_Up_Front_D3C; // @ G0676_i_StairsNativeBitmapIndex_Up_Front_D3C
+	int16 _g677_stairsNativeBitmapIndex_Up_Front_D2L; // @ G0677_i_StairsNativeBitmapIndex_Up_Front_D2L
+	int16 _g678_stairsNativeBitmapIndex_Up_Front_D2C; // @ G0678_i_StairsNativeBitmapIndex_Up_Front_D2C
+	int16 _g679_stairsNativeBitmapIndex_Up_Front_D1L; // @ G0679_i_StairsNativeBitmapIndex_Up_Front_D1L
+	int16 _g680_stairsNativeBitmapIndex_Up_Front_D1C; // @ G0680_i_StairsNativeBitmapIndex_Up_Front_D1C
+	int16 _g681_stairsNativeBitmapIndex_Up_Front_D0C_Left; // @ G0681_i_StairsNativeBitmapIndex_Up_Front_D0C_Left
+	int16 _g682_stairsNativeBitmapIndex_Down_Front_D3L; // @ G0682_i_StairsNativeBitmapIndex_Down_Front_D3L
+	int16 _g683_stairsNativeBitmapIndex_Down_Front_D3C; // @ G0683_i_StairsNativeBitmapIndex_Down_Front_D3C
+	int16 _g684_stairsNativeBitmapIndex_Down_Front_D2L; // @ G0684_i_StairsNativeBitmapIndex_Down_Front_D2L
+	int16 _g685_stairsNativeBitmapIndex_Down_Front_D2C; // @ G0685_i_StairsNativeBitmapIndex_Down_Front_D2C
+	int16 _g686_stairsNativeBitmapIndex_Down_Front_D1L; // @ G0686_i_StairsNativeBitmapIndex_Down_Front_D1L
+	int16 _g687_stairsNativeBitmapIndex_Down_Front_D1C; // @ G0687_i_StairsNativeBitmapIndex_Down_Front_D1C
+	int16 _g688_stairsNativeBitmapIndex_Down_Front_D0C_Left; // @ G0688_i_StairsNativeBitmapIndex_Down_Front_D0C_Left
+	int16 _g689_stairsNativeBitmapIndex_Side_D2L; // @ G0689_i_StairsNativeBitmapIndex_Side_D2L
+	int16 _g690_stairsNativeBitmapIndex_Up_Side_D1L; // @ G0690_i_StairsNativeBitmapIndex_Up_Side_D1L
+	int16 _g691_stairsNativeBitmapIndex_Down_Side_D1L; // @ G0691_i_StairsNativeBitmapIndex_Down_Side_D1L
+	int16 _g692_stairsNativeBitmapIndex_Side_D0L; // @ G0692_i_StairsNativeBitmapIndex_Side_D0L
 public:
 	// some methods use this for a stratchpad, don't make assumptions about content between function calls
-	byte *_tmpBitmap;
+	byte *_g74_tmpBitmap; // @ G0074_puc_Bitmap_Temporary
 
 	explicit DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
@@ -484,25 +505,25 @@ public:
 	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 					  byte *destBitmap, uint16 destWidth,
 					  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
-					  Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort);
+					  Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort);
 	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
-					  byte *destBitmap, uint16 destWidth, Box &box, Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort);
+					  byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort);
 	void blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight,
 										 byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
 
 	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0);
 	void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 					  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
-					  Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort);
+					  Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort);
 	void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 					  Box &box,
-					  Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort);
+					  Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort);
 	void blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
 									   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
 									   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDefultViewPort); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
 	void blitBoxFilledWithMaskedBitmapToScreen(byte *src, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
-									   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
-									   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
+											   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
+											   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
 
 	void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height);
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
@@ -521,29 +542,29 @@ public:
 	int16 getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount
 	int16 getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION
 	void cthulhu(Thing thingParam, direction directionParam,
-												   int16 mapXpos, int16 mapYpos, int16 viewSquareIndex,
-												   uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
+				 int16 mapXpos, int16 mapYpos, int16 viewSquareIndex,
+				 uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 	uint16 getNormalizedByteWidthM77(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH
 	uint16 getVerticalOffsetM23(uint16 val); // @ M23_VERTICAL_OFFSET
 	uint16 getHorizontalOffsetM22(uint16 val); // @ M22_HORIZONTAL_OFFSET
 
-	int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
-	int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
-	int16 _currMapFountainOrnIndices[kFountainOrnCount]; // @ G0268_ai_CurrentMapFountainOrnamentIndices
-	int16 _currMapWallOrnInfo[16][2]; // @ G0101_aai_CurrentMapWallOrnamentsInfo
-	int16 _currMapFloorOrnInfo[16][2]; // @ G0102_aai_CurrentMapFloorOrnamentsInfo
-	int16 _currMapDoorOrnInfo[17][2]; // @ G0103_aai_CurrentMapDoorOrnamentsInfo
-	byte *_currMapAllowedCreatureTypes; // @ G0264_puc_CurrentMapAllowedCreatureTypes
-	byte _currMapWallOrnIndices[16]; // @ G0261_auc_CurrentMapWallOrnamentIndices
-	byte _currMapFloorOrnIndices[16]; // @ G0262_auc_CurrentMapFloorOrnamentIndices
-	byte _currMapDoorOrnIndices[18]; // @ G0263_auc_CurrentMapDoorOrnamentIndices
+	int16 _g289_championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
+	int16 _g267_currMapAlcoveOrnIndices[k3_AlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
+	int16 _g268_currMapFountainOrnIndices[k1_FountainOrnCount]; // @ G0268_ai_CurrentMapFountainOrnamentIndices
+	int16 _g101_currMapWallOrnInfo[16][2]; // @ G0101_aai_CurrentMapWallOrnamentsInfo
+	int16 _g102_currMapFloorOrnInfo[16][2]; // @ G0102_aai_CurrentMapFloorOrnamentsInfo
+	int16 _g103_currMapDoorOrnInfo[17][2]; // @ G0103_aai_CurrentMapDoorOrnamentsInfo
+	byte *_g264_currMapAllowedCreatureTypes; // @ G0264_puc_CurrentMapAllowedCreatureTypes
+	byte _g261_currMapWallOrnIndices[16]; // @ G0261_auc_CurrentMapWallOrnamentIndices
+	byte _g262_currMapFloorOrnIndices[16]; // @ G0262_auc_CurrentMapFloorOrnamentIndices
+	byte _g263_currMapDoorOrnIndices[18]; // @ G0263_auc_CurrentMapDoorOrnamentIndices
 
-	int16 _currMapViAltarIndex; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex
+	int16 _g266_currMapViAltarIndex; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex
 
-	Thing _inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing
+	Thing _g290_inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing
 
-	bool _useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates
-	bool _doNotDrawFluxcagesDuringEndgame; // @ G0077_B_DoNotDrawFluxcagesDuringEndgame
+	bool _g578_useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates
+	bool _g77_doNotDrawFluxcagesDuringEndgame; // @ G0077_B_DoNotDrawFluxcagesDuringEndgame
 
 	bool isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
 	byte *getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index b3c3a90..d738234 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -87,22 +87,22 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 		}
 	}
 
-	dm._useByteBoxCoordinates = false;
+	dm._g578_useByteBoxCoordinates = false;
 	_inventoryChampionOrdinal = _vm->indexToOrdinal(championIndex);
 	if (!invChampOrdinal) {
 		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 	}
 
 	champion = &cm._champions[championIndex];
-	int16 w = dm.getWidth(kInventoryGraphicIndice);
-	int16 h = dm.getHeight(kInventoryGraphicIndice);
-	dm.blitToScreen(dm.getBitmap(kInventoryGraphicIndice), w, 0, 0, 0, w, 0, h, kColorNoTransparency, gDungeonViewport);
+	int16 w = dm.getWidth(k17_InventoryGraphicIndice);
+	int16 h = dm.getHeight(k17_InventoryGraphicIndice);
+	dm.blitToScreen(dm.getBitmap(k17_InventoryGraphicIndice), w, 0, 0, 0, w, 0, h, k255_ColorNoTransparency, gDungeonViewport);
 	if (cm._candidateChampionOrdinal) {
-		dm.clearScreenBox(kColorDarkestGray, gBoxFloppyZzzCross, gDungeonViewport);
+		dm.clearScreenBox(k12_ColorDarkestGray, gBoxFloppyZzzCross, gDungeonViewport);
 	}
-	_vm->_textMan->printToViewport(5, 116, kColorLightestGray, "HEALTH");
-	_vm->_textMan->printToViewport(5, 124, kColorLightestGray, "STAMINA");
-	_vm->_textMan->printToViewport(5, 132, kColorLightestGray, "MANA");
+	_vm->_textMan->printToViewport(5, 116, k13_ColorLightestGray, "HEALTH");
+	_vm->_textMan->printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
+	_vm->_textMan->printToViewport(5, 132, k13_ColorLightestGray, "MANA");
 
 	for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) {
 		_vm->_championMan->drawSlot(championIndex, (ChampionSlot)slotIndex);
@@ -124,13 +124,13 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 
 void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) {
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan._useByteBoxCoordinates = false;
+	dispMan._g578_useByteBoxCoordinates = false;
 	Box box;
 	box._y1 = 0;
 	box._y2 = 28 + 1;
 	box._x1 = championIndex * kChampionStatusBoxSpacing + 7;
 	box._x2 = box._x1 + 31 + 1;
-	dispMan.blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0, box, kColorNoTransparency);
+	dispMan.blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0, box, k255_ColorNoTransparency);
 }
 
 void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
@@ -139,15 +139,15 @@ void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Co
 	box._x2 = box._x1 + pixelWidth + 1;
 	box._y1 = y;
 	box._y2 = box._y1 + 6 + 1;
-	_vm->_displayMan->_useByteBoxCoordinates = false;
+	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	_vm->_displayMan->clearScreenBox(color, box);
 }
 
 void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
 	if (amount < -512) {
-		color = kColorRed;
+		color = k8_ColorRed;
 	} else if (amount < 0) {
-		color = kColorYellow;
+		color = k11_ColorYellow;
 	}
 
 	int16 pixelWidth = amount + 1024;
@@ -155,7 +155,7 @@ void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
 		pixelWidth = 3071;
 	}
 	pixelWidth /= 32;
-	drawPanelHorizontalBar(115, y + 2, pixelWidth, kColorBlack);
+	drawPanelHorizontalBar(115, y + 2, pixelWidth, k0_ColorBlack);
 	drawPanelHorizontalBar(113, y, pixelWidth, color);
 }
 
@@ -163,19 +163,19 @@ void InventoryMan::drawPanelFoodWaterPoisoned() {
 	Champion &champ = _vm->_championMan->_champions[_inventoryChampionOrdinal];
 	closeChest();
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.blitToScreen(dispMan.getBitmap(kPanelEmptyIndice), 144, 0, 0, gBoxPanel, kColorRed);
-	dispMan.blitToScreen(dispMan.getBitmap(kFoodLabelIndice), 48, 0, 0, gBoxFood, kColorDarkestGray);
-	dispMan.blitToScreen(dispMan.getBitmap(kWaterLabelIndice), 48, 0, 0, gBoxWater, kColorDarkestGray);
+	dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, gBoxPanel, k8_ColorRed);
+	dispMan.blitToScreen(dispMan.getBitmap(k30_FoodLabelIndice), 48, 0, 0, gBoxFood, k12_ColorDarkestGray);
+	dispMan.blitToScreen(dispMan.getBitmap(k31_WaterLabelIndice), 48, 0, 0, gBoxWater, k12_ColorDarkestGray);
 	if (champ._poisonEventCount) {
-		dispMan.blitToScreen(dispMan.getBitmap(kPoisionedLabelIndice), 96, 0, 0, gBoxPoisoned, kColorDarkestGray);
+		dispMan.blitToScreen(dispMan.getBitmap(k32_PoisionedLabelIndice), 96, 0, 0, gBoxPoisoned, k12_ColorDarkestGray);
 	}
-	drawPanelFoodOrWaterBar(champ._food, 69, kColorLightBrown);
-	drawPanelFoodOrWaterBar(champ._water, 92, kColorBlue);
+	drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown);
+	drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue);
 }
 
 void InventoryMan::drawPanelResurrectReincarnate() {
 	_panelContent = kPanelContentResurrectReincarnate;
-	_vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(kPanelResurectReincaranteIndice), 144, 0, 0, gBoxPanel, kColorDarkGreen, gDungeonViewport);
+	_vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, gBoxPanel, k6_ColorDarkGreen, gDungeonViewport);
 }
 
 void InventoryMan::drawPanel() {
@@ -245,7 +245,7 @@ void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) {
 			*iter -= 96;
 		}
 	}
-	_vm->_textMan->printToViewport(162 - (6 * strlen(text) / 2), yPos, kColorBlack, text, kColorWhite);
+	_vm->_textMan->printToViewport(162 - (6 * strlen(text) / 2), yPos, k0_ColorBlack, text, k15_ColorWhite);
 }
 
 void InventoryMan::drawPanelScroll(Scroll* scroll) {
@@ -258,7 +258,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) {
 		charRed++;
 	}
 	*charRed = '\0';
-	dispMan.blitToScreen(dispMan.getBitmap(kPanelOpenScrollIndice), 144, 0, 0, gBoxPanel, kColorRed, gDungeonViewport);
+	dispMan.blitToScreen(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, gDungeonViewport);
 	int16 lineCount = 1;
 	charRed++;
 	char *charGreen = charRed; // first char of the second line
@@ -310,7 +310,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 	if (!isPressingEye) {
 		objMan.drawIconInSlotBox(kSlotBoxInventoryActionHand, kIconIndiceContainerChestOpen);
 	}
-	dispMan.blitToScreen(dispMan.getBitmap(kPanelOpenChestIndice), 144, 0, 0, gBoxPanel, kColorRed);
+	dispMan.blitToScreen(dispMan.getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, gBoxPanel, k8_ColorRed);
 
 	int16 chestSlotIndex = 0;
 	Thing thing = chest->getSlot();
@@ -336,7 +336,7 @@ void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yP
 	box._x2 = (box._x1 = xPos) + 15 + 1;
 	box._y2 = (box._y1 = yPos) + 15 + 1;
 	_vm->_objectMan->extractIconFromBitmap(iconIndex, iconBitmap);
-	_vm->_displayMan->blitToScreen(iconBitmap, 16, 0, 0, box, kColorNoTransparency, gDungeonViewport);
+	_vm->_displayMan->blitToScreen(iconBitmap, 16, 0, 0, box, k255_ColorNoTransparency, gDungeonViewport);
 }
 
 void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) {
@@ -394,7 +394,7 @@ void InventoryMan::drawPanelObjectDescriptionString(char* descString) {
 				severalLines = true;
 			}
 
-			_vm->_textMan->printToViewport(_objDescTextXpos, _objDescTextYpos, kColorLightestGray, stringLine);
+			_vm->_textMan->printToViewport(_objDescTextXpos, _objDescTextYpos, k13_ColorLightestGray, stringLine);
 			_objDescTextYpos += 7;
 			if (severalLines) {
 				severalLines = false;
@@ -410,8 +410,8 @@ Box gBoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye
 
 void InventoryMan::drawPanelArrowOrEye(bool pressingEye) {
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.blitToScreen(dispMan.getBitmap(pressingEye ? kEyeForObjectDescriptionIndice : kArrowForChestContentIndice),
-						 16, 0, 0, gBoxArrowOrEye, kColorRed, gDungeonViewport);
+	dispMan.blitToScreen(dispMan.getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice),
+						 16, 0, 0, gBoxArrowOrEye, k8_ColorRed, gDungeonViewport);
 }
 
 
@@ -443,8 +443,8 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye);
 	} else {
 		IconIndice iconIndex = objMan.getIconIndex(thingToDraw);
-		dispMan.blitToScreen(dispMan.getBitmap(kPanelEmptyIndice), 144, 0, 0, gBoxPanel, kColorRed, gDungeonViewport);
-		dispMan.blitToScreen(dispMan.getBitmap(kObjectDescCircleIndice), 32, 0, 0, gBoxObjectDescCircle, kColorDarkestGray, gDungeonViewport);
+		dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, gDungeonViewport);
+		dispMan.blitToScreen(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, gBoxObjectDescCircle, k12_ColorDarkestGray, gDungeonViewport);
 
 		char *descString = nullptr;
 		char str[40];
@@ -466,7 +466,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			descString = objMan._objectNames[iconIndex];
 		}
 
-		textMan.printToViewport(134, 68, kColorLightestGray, descString);
+		textMan.printToViewport(134, 68, k13_ColorLightestGray, descString);
 		drawIconToViewport(iconIndex, 111, 59);
 
 		char *attribString[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"}; // TODO: localization
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index a09a33d..74ca0ac 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -60,11 +60,11 @@ MenuMan::~MenuMan() {
 
 void MenuMan::drawMovementArrows() {
 	DisplayMan &disp = *_vm->_displayMan;
-	byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice);
-	Box &dest = gBoxMovementArrows;
-	uint16 w = disp.getWidth(kMovementArrowsIndice);
+	byte *arrowsBitmap = disp.getBitmap(k13_MovementArrowsIndice);
+	Box &dest = g2_BoxMovementArrows;
+	uint16 w = disp.getWidth(k13_MovementArrowsIndice);
 
-	disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency);
+	disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, k255_ColorNoTransparency);
 }
 void MenuMan::clearActingChampion() {
 	ChampionMan &cm = *_vm->_championMan;
@@ -88,12 +88,12 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) {
 	box._x2 = box._x1 + 19 + 1;
 	box._y1 = 86;
 	box._y2 = 120 + 1;
-	dm._useByteBoxCoordinates = false;
+	dm._g578_useByteBoxCoordinates = false;
 	if (!champion._currHealth) {
-		dm.clearScreenBox(kColorBlack, box);
+		dm.clearScreenBox(k0_ColorBlack, box);
 		return;
 	}
-	byte *bitmapIcon = dm._tmpBitmap;
+	byte *bitmapIcon = dm._g74_tmpBitmap;
 	Thing thing = champion.getSlot(kChampionSlotActionHand);
 	IconIndice iconIndex;
 	if (thing == Thing::_none) {
@@ -101,13 +101,13 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) {
 	} else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
 		iconIndex = _vm->_objectMan->getIconIndex(thing);
 	} else {
-		dm.clearBitmap(bitmapIcon, 16, 16, kColorCyan);
+		dm.clearBitmap(bitmapIcon, 16, 16, k4_ColorCyan);
 		goto T0386006;
 	}
 	_vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon);
 	dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, gPalChangesActionAreaObjectIcon);
 T0386006:
-	dm.clearScreenBox(kColorCyan, box);
+	dm.clearScreenBox(k4_ColorCyan, box);
 	Box box2;
 	box2._x1 = box._x1 + 2;
 	box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that
@@ -122,7 +122,7 @@ T0386006:
 void MenuMan::drawDisabledMenu() {
 	if (!_vm->_championMan->_partyIsSleeping) {
 		warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
-		_vm->_displayMan->_useByteBoxCoordinates = false;
+		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		if (_vm->_inventoryMan->_inventoryChampionOrdinal) {
 			if (_vm->_inventoryMan->_panelContent == kPanelContentChest) {
 				_vm->_inventoryMan->closeChest();
@@ -197,8 +197,8 @@ void MenuMan::drawActionArea() {
 	TextMan &textMan = *_vm->_textMan;
 
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-	dispMan._useByteBoxCoordinates = false;
-	dispMan.clearScreenBox(kColorBlack, gBoxActionArea);
+	dispMan._g578_useByteBoxCoordinates = false;
+	dispMan.clearScreenBox(k0_ColorBlack, gBoxActionArea);
 	if (_actionAreaContainsIcons) {
 		for (uint16 champIndex = kChampionFirst; champIndex < champMan._partyChampionCount; ++champIndex)
 			drawActionIcon((ChampionIndex)champIndex);
@@ -208,11 +208,11 @@ void MenuMan::drawActionArea() {
 			box = gBoxActionArea2ActionMenu;
 		if (_actionList._actionIndices[1] == kChampionActionNone)
 			box = gBoxActionArea1ActionMenu;
-		dispMan.blitToScreen(dispMan.getBitmap(kMenuActionAreaIndice), 96, 0, 0, box, kColorNoTransparency);
-		textMan.printWithTrailingSpacesToScreen(235, 83, kColorBlack, kColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._actingChampionOrdinal)]._name,
+		dispMan.blitToScreen(dispMan.getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, box, k255_ColorNoTransparency);
+		textMan.printWithTrailingSpacesToScreen(235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._actingChampionOrdinal)]._name,
 												kChampionNameMaximumLength);
 		for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) {
-			textMan.printWithTrailingSpacesToScreen(241, 93 + actionListIndex * 12, kColorCyan, kColorBlack,
+			textMan.printWithTrailingSpacesToScreen(241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
 													getActionName(_actionList._actionIndices[actionListIndex]),
 													kActionNameMaximumLength);
 		}
@@ -248,12 +248,12 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
 	for (uint16 i = 0; i < 4; ++i)
 		champCurrHealth[i] = champMan._champions[i]._currHealth;
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-	dispMan.clearScreenBox(kColorBlack, gBoxSpellAreaControls);
+	dispMan.clearScreenBox(k0_ColorBlack, gBoxSpellAreaControls);
 	int16 champCount = champMan._partyChampionCount;
 	switch (champIndex) {
 	case kChampionFirst:
 		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
-		textMan.printTextToScreen(235, 48, kColorBlack, kColorCyan, champ._name);
+		textMan.printTextToScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		if (champCount) {
 			if (champCurrHealth[1]) {
 				warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
@@ -277,7 +277,7 @@ labelChamp3:
 			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		}
 		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
-		textMan.printTextToScreen(249, 48, kColorBlack, kColorCyan, champ._name);
+		textMan.printTextToScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		goto labelChamp2;
 	case kChampionThird:
 		if (champCurrHealth[0]) {
@@ -287,7 +287,7 @@ labelChamp3:
 			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		}
 		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
-		textMan.printTextToScreen(263, 48, kColorBlack, kColorCyan, champ._name);
+		textMan.printTextToScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		goto labelChamp3;
 	case kChampionFourth:
 		if (champCurrHealth[0]) {
@@ -300,7 +300,7 @@ labelChamp3:
 			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		}
 		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
-		textMan.printTextToScreen(277, 48, kColorBlack, kColorCyan, champ._name);
+		textMan.printTextToScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		break;
 	}
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
@@ -314,24 +314,24 @@ void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
 
 	Champion &champ = _vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
 	if (spellAreaBitmapLine == kSpellAreaAvailableSymbols) {
-		dispMan._useByteBoxCoordinates = false;
-		dispMan.blitToBitmap(dispMan.getBitmap(kMenuSpellAreLinesIndice), 96, 0, 12, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, kColorNoTransparency);
+		dispMan._g578_useByteBoxCoordinates = false;
+		dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 12, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, k255_ColorNoTransparency);
 		int16 x = 1;
 		byte c = 96 + (6 * champ._symbolStep);
 		char spellSymbolString[2] = {'\0', '\0'};
 		for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
 			spellSymbolString[0] = c++;
-			_vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 14, 8, kColorCyan, kColorBlack, spellSymbolString, 12);
+			_vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 14, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
 		}
 	} else if (spellAreaBitmapLine == kSpellAreaChampionSymbols) {
-		dispMan._useByteBoxCoordinates = false;
-		dispMan.blitToBitmap(dispMan.getBitmap(kMenuSpellAreLinesIndice), 96, 0, 24, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, kColorNoTransparency);
+		dispMan._g578_useByteBoxCoordinates = false;
+		dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 24, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, k255_ColorNoTransparency);
 		char spellSymbolString[2] = {'\0', '\0'};
 		int16 x = 8;
 		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
 			if ((spellSymbolString[0] = champ._symbols[symbolIndex]) == '\0')
 				break;
-			_vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 9, 8, kColorCyan, kColorBlack, spellSymbolString, 12);
+			_vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 9, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
 		}
 	}
 }
@@ -345,14 +345,14 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
 		return;
 	if (champMan._magicCasterChampionIndex == kChampionNone) {
 		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-		dispMan.blitToScreen(dispMan.getBitmap(kMenuSpellAreaBackground), 96, 0, 0, gBoxSpellArea);
+		dispMan.blitToScreen(dispMan.getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, gBoxSpellArea);
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 	}
 	if (champIndex == kChampionNone) {
 		champMan._magicCasterChampionIndex = kChampionNone;
 		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-		dispMan._useByteBoxCoordinates = false;
-		dispMan.clearScreenBox(kColorBlack, gBoxSpellArea);
+		dispMan._g578_useByteBoxCoordinates = false;
+		dispMan.clearScreenBox(k0_ColorBlack, gBoxSpellArea);
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 		return;
 	}
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 458f3fd..ddb002d 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -192,10 +192,10 @@ void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 	}
 
 	--i;
-	byte *srcBitmap = _vm->_displayMan->getBitmap(kObjectIcons_000_TO_031 + i);
+	byte *srcBitmap = _vm->_displayMan->getBitmap(k42_ObjectIcons_000_TO_031 + i);
 	iconIndex -= gIconGraphicFirstIndex[i];
-	_vm->_displayMan->_useByteBoxCoordinates = true;
-	_vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, 0, 16, 0, 16, kColorNoTransparency);
+	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
+	_vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, 0, 16, 0, 16, k255_ColorNoTransparency);
 }
 
 void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
@@ -218,16 +218,16 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 		}
 	}
 	iconGraphicIndex--;
-	byte *iconsBitmap = _vm->_displayMan->getBitmap(iconGraphicIndex + kObjectIcons_000_TO_031);
+	byte *iconsBitmap = _vm->_displayMan->getBitmap(iconGraphicIndex + k42_ObjectIcons_000_TO_031);
 	iconIndex -= gIconGraphicFirstIndex[iconGraphicIndex];
 
-	_vm->_displayMan->_useByteBoxCoordinates = false;
+	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	if (slotBoxIndex >= kSlotBoxInventoryFirstSlot) {
 		_vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
-									   box, kColorNoTransparency, gDungeonViewport);
+									   box, k255_ColorNoTransparency, gDungeonViewport);
 	} else {
 		_vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
-									   box, kColorNoTransparency, gDefultViewPort);
+									   box, k255_ColorNoTransparency, gDefultViewPort);
 	}
 }
 
@@ -245,7 +245,7 @@ void ObjectMan::drawLeaderObjectName(Thing thing) {
 	} else {
 		objName = _objectNames[iconIndex];
 	}
-	_vm->_textMan->printWithTrailingSpacesToScreen(233, 37, kColorCyan, kColorBlack, objName, kObjectNameMaximumLength);
+	_vm->_textMan->printWithTrailingSpacesToScreen(233, 37, k4_ColorCyan, k0_ColorBlack, objName, kObjectNameMaximumLength);
 }
 
 IconIndice ObjectMan::getIconIndexInSlotBox(uint16 slotBoxIndex) {
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index f8aabb3..d535194 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -43,9 +43,9 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16
 	uint16 textLength = strlen(text);
 	uint16 nextX = destX;
 	uint16 nextY = destY;
-	byte *srcBitmap = _vm->_displayMan->getBitmap(kFontGraphicIndice);
+	byte *srcBitmap = _vm->_displayMan->getBitmap(k557_FontGraphicIndice);
 
-	byte *tmp = _vm->_displayMan->_tmpBitmap;
+	byte *tmp = _vm->_displayMan->_g74_tmpBitmap;
 	for (uint16 i = 0; i < (kLetterWidth + 1) * kLetterHeight * 128; ++i) {
 		tmp[i] = srcBitmap[i] ? textColor : bgColor;
 	}
@@ -60,7 +60,7 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16
 			break;
 		uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
 		_vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth,
-			(nextX == destX) ? (nextX + 1) : nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight, kColorNoTransparency, viewport);
+			(nextX == destX) ? (nextX + 1) : nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight, k255_ColorNoTransparency, viewport);
 		nextX += kLetterWidth + 1;
 	}
 }
diff --git a/engines/dm/text.h b/engines/dm/text.h
index 590fade..48c2d6e 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -40,7 +40,7 @@ public:
 	void printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY,
 						   Color textColor, Color bgColor, const char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print
 	void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, Viewport &viewport = gDefultViewPort); // @ F0053_TEXT_PrintToLogicalScreen
-	void printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = kColorDarkestGray); // @ F0052_TEXT_PrintToViewport
+	void printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport
 	void printWithTrailingSpaces(byte *destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, Color bgColor,
 								 const char *text, int16 strLenght, int16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0041_TEXT_PrintWithTrailingSpaces
 	void printWithTrailingSpacesToScreen(int16 destX, int16 destY, Color textColor, Color bgColor,


Commit: da317f14be4d2b6f1031d84b5fc7ee743998cf4c
    https://github.com/scummvm/scummvm/commit/da317f14be4d2b6f1031d84b5fc7ee743998cf4c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Massive renameing in gfx.cpp

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/objectman.cpp
    engines/dm/text.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index fb2515b..5f1b68c 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -802,7 +802,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			} else {
 				AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			}
-			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, k12_ColorDarkestGray, gDungeonViewport);
+			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, k12_ColorDarkestGray, g296_DungeonViewport);
 			AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) {
 				if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent)
@@ -811,7 +811,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 					break;
 				}
 			}
-			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, k12_ColorDarkestGray, gDungeonViewport);
+			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, k12_ColorDarkestGray, g296_DungeonViewport);
 			champAttributes |= kChampionAttributeViewport;
 		}
 	}
@@ -976,7 +976,7 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 	if (nativeBitmapIndex != -1) {
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		_vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0,
-									   box, k12_ColorDarkestGray, isInventoryChamp ? gDungeonViewport : gDefultViewPort);
+									   box, k12_ColorDarkestGray, isInventoryChamp ? g296_DungeonViewport : gDefultViewPort);
 	}
 
 	_vm->_objectMan->drawIconInSlotBox(slotBoxIndex, iconIndex);
@@ -998,8 +998,8 @@ void ChampionMan::renameChampion(Champion* champ) {
 	box._x1 = 3;
 	box._x2 = box._x1 + 167;
 
-	dispMan.clearScreenBox(k12_ColorDarkestGray, box, gDungeonViewport);
-	dispMan.blitToScreen(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, gBoxPanel, k4_ColorCyan, gDungeonViewport);
+	dispMan.clearScreenBox(k12_ColorDarkestGray, box, g296_DungeonViewport);
+	dispMan.blitToScreen(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, gBoxPanel, k4_ColorCyan, g296_DungeonViewport);
 	textMan.printToViewport(177, 58, k13_ColorLightestGray, "_______");
 	textMan.printToViewport(105, 76, k13_ColorLightestGray, "___________________");
 	Common::Point clickPos;
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index be8da8b..bf584fd 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -253,7 +253,7 @@ void DMEngine::gameloop() {
 
 		if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) {
 			Box box(0, 224, 0, 126);
-			_displayMan->clearScreenBox(k0_ColorBlack, box, gDungeonViewport); // dummy code
+			_displayMan->clearScreenBox(k0_ColorBlack, box, g296_DungeonViewport); // dummy code
 			_displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY);
 		}
 		// DUMMY CODE: next line
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index f6b1b02..35b30a3 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -39,74 +39,73 @@
 
 namespace DM {
 
-Frame g0164Frame_DoorFrameLeft_D3L = Frame(0, 31, 28, 70, 16, 43, 0, 0); // @ G0164_s_Graphic558_Frame_DoorFrameLeft_D3L
-Frame g0165Frame_DoorFrameRight_D3R = Frame(192, 223, 28, 70, 16, 43, 0, 0); // @ G0165_s_Graphic558_Frame_DoorFrameRight_D3R
-Frame g0166Frame_DoorFrameLeft_D3C = Frame(64, 95, 27, 70, 16, 44, 0, 0); // @ G0166_s_Graphic558_Frame_DoorFrameLeft_D3C
-Frame g0167Frame_DoorFrameRight_D3C = Frame(128, 159, 27, 70, 16, 44, 0, 0); // @ G0167_s_Graphic558_Frame_DoorFrameRight_D3C
-Frame g0168Frame_DoorFrameLeft_D2C = Frame(48, 95, 22, 86, 24, 65, 0, 0); // @ G0168_s_Graphic558_Frame_DoorFrameLeft_D2C
-Frame g0169Frame_DoorFrameRight_D2C = Frame(128, 175, 22, 86, 24, 65, 0, 0); // @ G0169_s_Graphic558_Frame_DoorFrameRight_D2C
-Frame g0170Frame_DoorFrameLeft_D1C = Frame(43, 74, 14, 107, 16, 94, 0, 0); // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C
-Frame g0171Frame_DoorFrameRight_D1C = Frame(149, 180, 14, 107, 16, 94, 0, 0); // @ G0171_s_Graphic558_Frame_DoorFrameRight_D1C
-Frame g0172Frame_DoorFrame_D0C = Frame(96, 127, 0, 122, 16, 123, 0, 0); // @ G0172_s_Graphic558_Frame_DoorFrame_D0C
-Frame g0173Frame_DoorFrameTop_D2L = Frame(0, 59, 22, 24, 48, 3, 16, 0); // @ G0173_s_Graphic558_Frame_DoorFrameTop_D2L
-Frame g0174Frame_DoorFrameTop_D2C = Frame(64, 159, 22, 24, 48, 3, 0, 0); // @ G0174_s_Graphic558_Frame_DoorFrameTop_D2C
-Frame g0175Frame_DoorFrameTop_D2R = Frame(164, 223, 22, 24, 48, 3, 16, 0); // @ G0175_s_Graphic558_Frame_DoorFrameTop_D2R
-Frame g0176Frame_DoorFrameTop_D1L = Frame(0, 31, 14, 17, 64, 4, 16, 0); // @ G0176_s_Graphic558_Frame_DoorFrameTop_D1L
-Frame g0177Frame_DoorFrameTop_D1C = Frame(48, 175, 14, 17, 64, 4, 0, 0); // @ G0177_s_Graphic558_Frame_DoorFrameTop_D1C
-Frame g0178Frame_DoorFrameTop_D1R = Frame(192, 223, 14, 17, 64, 4, 16, 0); // @ G0178_s_Graphic558_Frame_DoorFrameTop_D1R
-Frame g0110FrameStairsUpFront_D3L = Frame(0, 79, 25, 70, 40, 46, 0, 0); // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L
-Frame g0111FrameStairsUpFront_D3C = Frame(64, 159, 25, 70, 48, 46, 0, 0); // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C
-Frame g0112FrameStairsUpFront_D3R = Frame(149, 223, 25, 70, 40, 46, 5, 0); // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R
-Frame g0113FrameStairsUpFront_D2L = Frame(0, 63, 22, 83, 32, 62, 0, 0); // @ G0113_s_Graphic558_Frame_StairsUpFront_D2L
-Frame g0114FrameStairsUpFront_D2C = Frame(64, 159, 22, 83, 48, 62, 0, 0); // @ G0114_s_Graphic558_Frame_StairsUpFront_D2C
-Frame g0115FrameStairsUpFront_D2R = Frame(160, 223, 22, 83, 32, 62, 0, 0); // @ G0115_s_Graphic558_Frame_StairsUpFront_D2R
-Frame g0116FrameStairsUpFront_D1L = Frame(0, 31, 9, 108, 16, 100, 0, 0); // @ G0116_s_Graphic558_Frame_StairsUpFront_D1L
-Frame g0117FrameStairsUpFront_D1C = Frame(32, 191, 9, 108, 80, 100, 0, 0); // @ G0117_s_Graphic558_Frame_StairsUpFront_D1C
-Frame g0118FrameStairsUpFront_D1R = Frame(192, 223, 9, 108, 16, 100, 0, 0); // @ G0118_s_Graphic558_Frame_StairsUpFront_D1R
-Frame g0119FrameStairsUpFront_D0L = Frame(0, 31, 58, 101, 16, 44, 0, 0); // @ G0119_s_Graphic558_Frame_StairsUpFront_D0L
-Frame g0120FrameStairsUpFront_D0R = Frame(192, 223, 58, 101, 16, 44, 0, 0); // @ G0120_s_Graphic558_Frame_StairsUpFront_D0R
-Frame g0121FrameStairsDownFront_D3L = Frame(0, 79, 28, 68, 40, 41, 0, 0); // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L
-Frame g0122FrameStairsDownFront_D3C = Frame(64, 159, 28, 70, 48, 43, 0, 0); // @ G0122_s_Graphic558_Frame_StairsDownFront_D3C
-Frame g0123FrameStairsDownFront_D3R = Frame(149, 223, 28, 68, 40, 41, 5, 0); // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R
-Frame g0124FrameStairsDownFront_D2L = Frame(0, 63, 24, 85, 32, 62, 0, 0); // @ G0124_s_Graphic558_Frame_StairsDownFront_D2L
-Frame g0125FrameStairsDownFront_D2C = Frame(64, 159, 24, 85, 48, 62, 0, 0); // @ G0125_s_Graphic558_Frame_StairsDownFront_D2C
-Frame g0126FrameStairsDownFront_D2R = Frame(160, 223, 24, 85, 32, 62, 0, 0); // @ G0126_s_Graphic558_Frame_StairsDownFront_D2R
-Frame g0127FrameStairsDownFront_D1L = Frame(0, 31, 18, 108, 16, 91, 0, 0); // @ G0127_s_Graphic558_Frame_StairsDownFront_D1L
-Frame g0128FrameStairsDownFront_D1C = Frame(32, 191, 18, 108, 80, 91, 0, 0); // @ G0128_s_Graphic558_Frame_StairsDownFront_D1C
-Frame g0129FrameStairsDownFront_D1R = Frame(192, 223, 18, 108, 16, 91, 0, 0); // @ G0129_s_Graphic558_Frame_StairsDownFront_D1R
-Frame g0130FrameStairsDownFront_D0L = Frame(0, 31, 76, 135, 16, 60, 0, 0); // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L
-Frame g0131FrameStairsDownFront_D0R = Frame(192, 223, 76, 135, 16, 60, 0, 0); // @ G0131_s_Graphic558_Frame_StairsDownFront_D0R
-Frame g0132FrameStairsSide_D2L = Frame(60, 75, 57, 61, 8, 5, 0, 0); // @ G0132_s_Graphic558_Frame_StairsSide_D2L
-Frame g0133FrameStairsSide_D2R = Frame(148, 163, 57, 61, 8, 5, 0, 0); // @ G0133_s_Graphic558_Frame_StairsSide_D2R
-Frame g0134FrameStairsUpSide_D1L = Frame(32, 63, 57, 99, 16, 43, 0, 0); // @ G0134_s_Graphic558_Frame_StairsUpSide_D1L
-Frame g0135FrameStairsUpSide_D1R = Frame(160, 191, 57, 99, 16, 43, 0, 0); // @ G0135_s_Graphic558_Frame_StairsUpSide_D1R
-Frame g0136FrameStairsDownSide_D1L = Frame(32, 63, 60, 98, 16, 39, 0, 0); // @ G0136_s_Graphic558_Frame_StairsDownSide_D1L
-Frame g0137FrameStairsDownSide_D1R = Frame(160, 191, 60, 98, 16, 39, 0, 0); // @ G0137_s_Graphic558_Frame_StairsDownSide_D1R
-Frame g0138FrameStairsSide_D0L = Frame(0, 15, 73, 85, 8, 13, 0, 0); // @ G0138_s_Graphic558_Frame_StairsSide_D0L
-Frame g0139FrameStairsSide_D0R = Frame(208, 223, 73, 85, 8, 13, 0, 0); // @ G0139_s_Graphic558_Frame_StairsSide_D0R
-Frame g0140FrameFloorPit_D3L = Frame(0, 79, 66, 73, 40, 8, 0, 0); // @ G0140_s_Graphic558_Frame_FloorPit_D3L
-Frame g0141FrameFloorPit_D3C = Frame(64, 159, 66, 73, 48, 8, 0, 0); // @ G0141_s_Graphic558_Frame_FloorPit_D3C
-Frame g0142FrameFloorPit_D3R = Frame(144, 223, 66, 73, 40, 8, 0, 0); // @ G0142_s_Graphic558_Frame_FloorPit_D3R
-Frame g0143FrameFloorPit_D2L = Frame(0, 79, 77, 88, 40, 12, 0, 0); // @ G0143_s_Graphic558_Frame_FloorPit_D2L
-Frame g0144FrameFloorPit_D2C = Frame(64, 159, 77, 88, 48, 12, 0, 0); // @ G0144_s_Graphic558_Frame_FloorPit_D2C
-Frame g0145FrameFloorPit_D2R = Frame(144, 223, 77, 88, 40, 12, 0, 0); // @ G0145_s_Graphic558_Frame_FloorPit_D2R
-Frame g0146FrameFloorPit_D1L = Frame(0, 63, 93, 116, 32, 24, 0, 0); // @ G0146_s_Graphic558_Frame_FloorPit_D1L
-Frame g0147FrameFloorPit_D1C = Frame(32, 191, 93, 116, 80, 24, 0, 0); // @ G0147_s_Graphic558_Frame_FloorPit_D1C
-Frame g0148FrameFloorPit_D1R = Frame(160, 223, 93, 116, 32, 24, 0, 0); // @ G0148_s_Graphic558_Frame_FloorPit_D1R
-Frame g0149FrameFloorPit_D0L = Frame(0, 31, 124, 135, 16, 12, 0, 0); // @ G0149_s_Graphic558_Frame_FloorPit_D0L
-Frame g0150FrameFloorPit_D0C = Frame(16, 207, 124, 135, 96, 12, 0, 0); // @ G0150_s_Graphic558_Frame_FloorPit_D0C
-Frame g0151FrameFloorPit_D0R = Frame(192, 223, 124, 135, 16, 12, 0, 0); // @ G0151_s_Graphic558_Frame_FloorPit_D0R
-Frame g0152FrameFloorPit_D2L = Frame(0, 79, 19, 23, 40, 5, 0, 0); // @ G0152_s_Graphic558_Frame_CeilingPit_D2L
-Frame g0153FrameFloorPit_D2C = Frame(64, 159, 19, 23, 48, 5, 0, 0); // @ G0153_s_Graphic558_Frame_CeilingPit_D2C
-Frame g0154FrameFloorPit_D2R = Frame(144, 223, 19, 23, 40, 5, 0, 0); // @ G0154_s_Graphic558_Frame_CeilingPit_D2R
-Frame g0155FrameFloorPit_D1L = Frame(0, 63, 8, 16, 32, 9, 0, 0); // @ G0155_s_Graphic558_Frame_CeilingPit_D1L
-Frame g0156FrameFloorPit_D1C = Frame(32, 191, 8, 16, 80, 9, 0, 0); // @ G0156_s_Graphic558_Frame_CeilingPit_D1C
-Frame g0157FrameFloorPit_D1R = Frame(160, 223, 8, 16, 32, 9, 0, 0); // @ G0157_s_Graphic558_Frame_CeilingPit_D1R
-Frame g0158FrameFloorPit_D0L = Frame(0, 15, 0, 3, 8, 4, 0, 0); // @ G0158_s_Graphic558_Frame_CeilingPit_D0L
-Frame g0159FrameFloorPit_D0C = Frame(16, 207, 0, 3, 96, 4, 0, 0); // @ G0159_s_Graphic558_Frame_CeilingPit_D0C
-Frame g0160FrameFloorPit_D0R = Frame(208, 223, 0, 3, 8, 4, 0, 0); // @ G0160_s_Graphic558_Frame_CeilingPit_D0R
-
-FieldAspect gFieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects
+Frame g164_Frame_DoorFrameLeft_D3L = Frame(0, 31, 28, 70, 16, 43, 0, 0); // @ G0164_s_Graphic558_Frame_DoorFrameLeft_D3L
+Frame g165_Frame_DoorFrameRight_D3R = Frame(192, 223, 28, 70, 16, 43, 0, 0); // @ G0165_s_Graphic558_Frame_DoorFrameRight_D3R
+Frame g166_Frame_DoorFrameLeft_D3C = Frame(64, 95, 27, 70, 16, 44, 0, 0); // @ G0166_s_Graphic558_Frame_DoorFrameLeft_D3C
+Frame g167_Frame_DoorFrameRight_D3C = Frame(128, 159, 27, 70, 16, 44, 0, 0); // @ G0167_s_Graphic558_Frame_DoorFrameRight_D3C
+Frame g168_Frame_DoorFrameLeft_D2C = Frame(48, 95, 22, 86, 24, 65, 0, 0); // @ G0168_s_Graphic558_Frame_DoorFrameLeft_D2C
+Frame g169_Frame_DoorFrameRight_D2C = Frame(128, 175, 22, 86, 24, 65, 0, 0); // @ G0169_s_Graphic558_Frame_DoorFrameRight_D2C
+Frame g170_Frame_DoorFrameLeft_D1C = Frame(43, 74, 14, 107, 16, 94, 0, 0); // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C
+Frame g171_Frame_DoorFrameRight_D1C = Frame(149, 180, 14, 107, 16, 94, 0, 0); // @ G0171_s_Graphic558_Frame_DoorFrameRight_D1C
+Frame g172_Frame_DoorFrame_D0C = Frame(96, 127, 0, 122, 16, 123, 0, 0); // @ G0172_s_Graphic558_Frame_DoorFrame_D0C
+Frame g173_Frame_DoorFrameTop_D2L = Frame(0, 59, 22, 24, 48, 3, 16, 0); // @ G0173_s_Graphic558_Frame_DoorFrameTop_D2L
+Frame g174_Frame_DoorFrameTop_D2C = Frame(64, 159, 22, 24, 48, 3, 0, 0); // @ G0174_s_Graphic558_Frame_DoorFrameTop_D2C
+Frame g175_Frame_DoorFrameTop_D2R = Frame(164, 223, 22, 24, 48, 3, 16, 0); // @ G0175_s_Graphic558_Frame_DoorFrameTop_D2R
+Frame g176_Frame_DoorFrameTop_D1L = Frame(0, 31, 14, 17, 64, 4, 16, 0); // @ G0176_s_Graphic558_Frame_DoorFrameTop_D1L
+Frame g177_Frame_DoorFrameTop_D1C = Frame(48, 175, 14, 17, 64, 4, 0, 0); // @ G0177_s_Graphic558_Frame_DoorFrameTop_D1C
+Frame g178_Frame_DoorFrameTop_D1R = Frame(192, 223, 14, 17, 64, 4, 16, 0); // @ G0178_s_Graphic558_Frame_DoorFrameTop_D1R
+Frame g110_FrameStairsUpFront_D3L = Frame(0, 79, 25, 70, 40, 46, 0, 0); // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L
+Frame g111_FrameStairsUpFront_D3C = Frame(64, 159, 25, 70, 48, 46, 0, 0); // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C
+Frame g112_FrameStairsUpFront_D3R = Frame(149, 223, 25, 70, 40, 46, 5, 0); // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R
+Frame g113_FrameStairsUpFront_D2L = Frame(0, 63, 22, 83, 32, 62, 0, 0); // @ G0113_s_Graphic558_Frame_StairsUpFront_D2L
+Frame g114_FrameStairsUpFront_D2C = Frame(64, 159, 22, 83, 48, 62, 0, 0); // @ G0114_s_Graphic558_Frame_StairsUpFront_D2C
+Frame g115_FrameStairsUpFront_D2R = Frame(160, 223, 22, 83, 32, 62, 0, 0); // @ G0115_s_Graphic558_Frame_StairsUpFront_D2R
+Frame g116_FrameStairsUpFront_D1L = Frame(0, 31, 9, 108, 16, 100, 0, 0); // @ G0116_s_Graphic558_Frame_StairsUpFront_D1L
+Frame g117_FrameStairsUpFront_D1C = Frame(32, 191, 9, 108, 80, 100, 0, 0); // @ G0117_s_Graphic558_Frame_StairsUpFront_D1C
+Frame g118_FrameStairsUpFront_D1R = Frame(192, 223, 9, 108, 16, 100, 0, 0); // @ G0118_s_Graphic558_Frame_StairsUpFront_D1R
+Frame g119_FrameStairsUpFront_D0L = Frame(0, 31, 58, 101, 16, 44, 0, 0); // @ G0119_s_Graphic558_Frame_StairsUpFront_D0L
+Frame g120_FrameStairsUpFront_D0R = Frame(192, 223, 58, 101, 16, 44, 0, 0); // @ G0120_s_Graphic558_Frame_StairsUpFront_D0R
+Frame g121_FrameStairsDownFront_D3L = Frame(0, 79, 28, 68, 40, 41, 0, 0); // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L
+Frame g122_FrameStairsDownFront_D3C = Frame(64, 159, 28, 70, 48, 43, 0, 0); // @ G0122_s_Graphic558_Frame_StairsDownFront_D3C
+Frame g123_FrameStairsDownFront_D3R = Frame(149, 223, 28, 68, 40, 41, 5, 0); // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R
+Frame g124_FrameStairsDownFront_D2L = Frame(0, 63, 24, 85, 32, 62, 0, 0); // @ G0124_s_Graphic558_Frame_StairsDownFront_D2L
+Frame g125_FrameStairsDownFront_D2C = Frame(64, 159, 24, 85, 48, 62, 0, 0); // @ G0125_s_Graphic558_Frame_StairsDownFront_D2C
+Frame g126_FrameStairsDownFront_D2R = Frame(160, 223, 24, 85, 32, 62, 0, 0); // @ G0126_s_Graphic558_Frame_StairsDownFront_D2R
+Frame g127_FrameStairsDownFront_D1L = Frame(0, 31, 18, 108, 16, 91, 0, 0); // @ G0127_s_Graphic558_Frame_StairsDownFront_D1L
+Frame g128_FrameStairsDownFront_D1C = Frame(32, 191, 18, 108, 80, 91, 0, 0); // @ G0128_s_Graphic558_Frame_StairsDownFront_D1C
+Frame g129_FrameStairsDownFront_D1R = Frame(192, 223, 18, 108, 16, 91, 0, 0); // @ G0129_s_Graphic558_Frame_StairsDownFront_D1R
+Frame g130_FrameStairsDownFront_D0L = Frame(0, 31, 76, 135, 16, 60, 0, 0); // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L
+Frame g131_FrameStairsDownFront_D0R = Frame(192, 223, 76, 135, 16, 60, 0, 0); // @ G0131_s_Graphic558_Frame_StairsDownFront_D0R
+Frame g132_FrameStairsSide_D2L = Frame(60, 75, 57, 61, 8, 5, 0, 0); // @ G0132_s_Graphic558_Frame_StairsSide_D2L
+Frame g133_FrameStairsSide_D2R = Frame(148, 163, 57, 61, 8, 5, 0, 0); // @ G0133_s_Graphic558_Frame_StairsSide_D2R
+Frame g134_FrameStairsUpSide_D1L = Frame(32, 63, 57, 99, 16, 43, 0, 0); // @ G0134_s_Graphic558_Frame_StairsUpSide_D1L
+Frame g135_FrameStairsUpSide_D1R = Frame(160, 191, 57, 99, 16, 43, 0, 0); // @ G0135_s_Graphic558_Frame_StairsUpSide_D1R
+Frame g136_FrameStairsDownSide_D1L = Frame(32, 63, 60, 98, 16, 39, 0, 0); // @ G0136_s_Graphic558_Frame_StairsDownSide_D1L
+Frame g137_FrameStairsDownSide_D1R = Frame(160, 191, 60, 98, 16, 39, 0, 0); // @ G0137_s_Graphic558_Frame_StairsDownSide_D1R
+Frame g138_FrameStairsSide_D0L = Frame(0, 15, 73, 85, 8, 13, 0, 0); // @ G0138_s_Graphic558_Frame_StairsSide_D0L
+Frame g139_FrameStairsSide_D0R = Frame(208, 223, 73, 85, 8, 13, 0, 0); // @ G0139_s_Graphic558_Frame_StairsSide_D0R
+Frame g140_FrameFloorPit_D3L = Frame(0, 79, 66, 73, 40, 8, 0, 0); // @ G0140_s_Graphic558_Frame_FloorPit_D3L
+Frame g141_FrameFloorPit_D3C = Frame(64, 159, 66, 73, 48, 8, 0, 0); // @ G0141_s_Graphic558_Frame_FloorPit_D3C
+Frame g142_FrameFloorPit_D3R = Frame(144, 223, 66, 73, 40, 8, 0, 0); // @ G0142_s_Graphic558_Frame_FloorPit_D3R
+Frame g143_FrameFloorPit_D2L = Frame(0, 79, 77, 88, 40, 12, 0, 0); // @ G0143_s_Graphic558_Frame_FloorPit_D2L
+Frame g144_FrameFloorPit_D2C = Frame(64, 159, 77, 88, 48, 12, 0, 0); // @ G0144_s_Graphic558_Frame_FloorPit_D2C
+Frame g145_FrameFloorPit_D2R = Frame(144, 223, 77, 88, 40, 12, 0, 0); // @ G0145_s_Graphic558_Frame_FloorPit_D2R
+Frame g146_FrameFloorPit_D1L = Frame(0, 63, 93, 116, 32, 24, 0, 0); // @ G0146_s_Graphic558_Frame_FloorPit_D1L
+Frame g147_FrameFloorPit_D1C = Frame(32, 191, 93, 116, 80, 24, 0, 0); // @ G0147_s_Graphic558_Frame_FloorPit_D1C
+Frame g148_FrameFloorPit_D1R = Frame(160, 223, 93, 116, 32, 24, 0, 0); // @ G0148_s_Graphic558_Frame_FloorPit_D1R
+Frame g149_FrameFloorPit_D0L = Frame(0, 31, 124, 135, 16, 12, 0, 0); // @ G0149_s_Graphic558_Frame_FloorPit_D0L
+Frame g150_FrameFloorPit_D0C = Frame(16, 207, 124, 135, 96, 12, 0, 0); // @ G0150_s_Graphic558_Frame_FloorPit_D0C
+Frame g151_FrameFloorPit_D0R = Frame(192, 223, 124, 135, 16, 12, 0, 0); // @ G0151_s_Graphic558_Frame_FloorPit_D0R
+Frame g152_FrameFloorPit_D2L = Frame(0, 79, 19, 23, 40, 5, 0, 0); // @ G0152_s_Graphic558_Frame_CeilingPit_D2L
+Frame g153_FrameFloorPit_D2C = Frame(64, 159, 19, 23, 48, 5, 0, 0); // @ G0153_s_Graphic558_Frame_CeilingPit_D2C
+Frame g154_FrameFloorPit_D2R = Frame(144, 223, 19, 23, 40, 5, 0, 0); // @ G0154_s_Graphic558_Frame_CeilingPit_D2R
+Frame g155_FrameFloorPit_D1L = Frame(0, 63, 8, 16, 32, 9, 0, 0); // @ G0155_s_Graphic558_Frame_CeilingPit_D1L
+Frame g156_FrameFloorPit_D1C = Frame(32, 191, 8, 16, 80, 9, 0, 0); // @ G0156_s_Graphic558_Frame_CeilingPit_D1C
+Frame g157_FrameFloorPit_D1R = Frame(160, 223, 8, 16, 32, 9, 0, 0); // @ G0157_s_Graphic558_Frame_CeilingPit_D1R
+Frame g158_FrameFloorPit_D0L = Frame(0, 15, 0, 3, 8, 4, 0, 0); // @ G0158_s_Graphic558_Frame_CeilingPit_D0L
+Frame g159_FrameFloorPit_D0C = Frame(16, 207, 0, 3, 96, 4, 0, 0); // @ G0159_s_Graphic558_Frame_CeilingPit_D0C
+Frame g160_FrameFloorPit_D0R = Frame(208, 223, 0, 3, 8, 4, 0, 0); // @ G0160_s_Graphic558_Frame_CeilingPit_D0R
+FieldAspect g188_FieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects
 								  /* { NativeBitmapRelativeIndex, BaseStartUnitIndex, Transparent color, Mask, ByteWidth, Height, X, BitPlaneWordCount } */
 	FieldAspect(0, 63, 0x8A, 0xFF,  0,   0,  0, 64),   /* D3C */
 	FieldAspect(0, 63, 0x0A, 0x80, 48,  51, 11, 64),   /* D3L */
@@ -123,7 +122,7 @@ FieldAspect gFieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects
 
 Box g2_BoxMovementArrows = Box(224, 319, 124, 168);
 
-byte gPalChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke
+byte g212_PalChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke
 
 ExplosionAspect g211_ExplosionAspects[k4_ExplosionAspectCount] = { // @ G0211_as_Graphic558_ExplosionAspects
 	/* { ByteWidth, Height } */
@@ -132,7 +131,7 @@ ExplosionAspect(64,  97),   /* Spell  */
 ExplosionAspect(80,  91),   /* Poison */
 ExplosionAspect(80,  91)}; /* Death  */
 
-#define kDerivedBitmapMaximumCount 730 // @ C730_DERIVED_BITMAP_MAXIMUM_COUNT
+#define k730_DerivedBitmapMaximumCount 730 // @ C730_DERIVED_BITMAP_MAXIMUM_COUNT
 
 byte g215_ProjectileScales[7] = {
 	13,   /* D4 Back  */
@@ -143,112 +142,46 @@ byte g215_ProjectileScales[7] = {
 	28,   /* D2 Front */
 	32}; /* D1 Back  */
 
-enum StairFrameIndex {
-	kFrameStairsUpFront_D3L = 0, // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L 
-	kFrameStairsUpFront_D3C = 1, // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C 
-	kFrameStairsUpFront_D3R = 2, // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R 
-	kFrameStairsUpFront_D2L = 3, // @ G0113_s_Graphic558_Frame_StairsUpFront_D2L 
-	kFrameStairsUpFront_D2C = 4, // @ G0114_s_Graphic558_Frame_StairsUpFront_D2C 
-	kFrameStairsUpFront_D2R = 5, // @ G0115_s_Graphic558_Frame_StairsUpFront_D2R 
-	kFrameStairsUpFront_D1L = 6, // @ G0116_s_Graphic558_Frame_StairsUpFront_D1L 
-	kFrameStairsUpFront_D1C = 7, // @ G0117_s_Graphic558_Frame_StairsUpFront_D1C 
-	kFrameStairsUpFront_D1R = 8, // @ G0118_s_Graphic558_Frame_StairsUpFront_D1R 
-	kFrameStairsUpFront_D0L = 9, // @ G0119_s_Graphic558_Frame_StairsUpFront_D0L 
-	kFrameStairsUpFront_D0R = 10, // @ G0120_s_Graphic558_Frame_StairsUpFront_D0R 
-	kFrameStairsDownFront_D3L = 11, // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L 
-	kFrameStairsDownFront_D3C = 12, // @ G0122_s_Graphic558_Frame_StairsDownFront_D3C 
-	kFrameStairsDownFront_D3R = 13, // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R 
-	kFrameStairsDownFront_D2L = 14, // @ G0124_s_Graphic558_Frame_StairsDownFront_D2L 
-	kFrameStairsDownFront_D2C = 15, // @ G0125_s_Graphic558_Frame_StairsDownFront_D2C 
-	kFrameStairsDownFront_D2R = 16, // @ G0126_s_Graphic558_Frame_StairsDownFront_D2R 
-	kFrameStairsDownFront_D1L = 17, // @ G0127_s_Graphic558_Frame_StairsDownFront_D1L 
-	kFrameStairsDownFront_D1C = 18, // @ G0128_s_Graphic558_Frame_StairsDownFront_D1C 
-	kFrameStairsDownFront_D1R = 19, // @ G0129_s_Graphic558_Frame_StairsDownFront_D1R 
-	kFrameStairsDownFront_D0L = 20, // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L 
-	kFrameStairsDownFront_D0R = 21, // @ G0131_s_Graphic558_Frame_StairsDownFront_D0R 
-	kFrameStairsSide_D2L = 22, // @ G0132_s_Graphic558_Frame_StairsSide_D2L 
-	kFrameStairsSide_D2R = 23, // @ G0133_s_Graphic558_Frame_StairsSide_D2R 
-	kFrameStairsUpSide_D1L = 24, // @ G0134_s_Graphic558_Frame_StairsUpSide_D1L 
-	kFrameStairsUpSide_D1R = 25, // @ G0135_s_Graphic558_Frame_StairsUpSide_D1R 
-	kFrameStairsDownSide_D1L = 26, // @ G0136_s_Graphic558_Frame_StairsDownSide_D1L 
-	kFrameStairsDownSide_D1R = 27, // @ G0137_s_Graphic558_Frame_StairsDownSide_D1R 
-	kFrameStairsSide_D0L = 28, // @ G0138_s_Graphic558_Frame_StairsSide_D0L 
-	kFrameStairsSide_D0R = 29 // @ G0139_s_Graphic558_Frame_StairsSide_D0R 
-};
-
-Frame gStairFrames[] = {
-	Frame(0, 79, 25, 70, 40, 46, 0, 0),
-	Frame(64, 159, 25, 70, 48, 46, 0, 0),
-	Frame(149, 223, 25, 70, 40, 46, 5, 0),
-	Frame(0, 63, 22, 83, 32, 62, 0, 0),
-	Frame(64, 159, 22, 83, 48, 62, 0, 0),
-	Frame(160, 223, 22, 83, 32, 62, 0, 0),
-	Frame(0, 31, 9, 108, 16, 100, 0, 0),
-	Frame(32, 191, 9, 108, 80, 100, 0, 0),
-	Frame(192, 223, 9, 108, 16, 100, 0, 0),
-	Frame(0, 31, 58, 101, 16, 44, 0, 0),
-	Frame(192, 223, 58, 101, 16, 44, 0, 0),
-	Frame(0, 79, 28, 68, 40, 41, 0, 0),
-	Frame(64, 159, 28, 70, 48, 43, 0, 0),
-	Frame(149, 223, 28, 68, 40, 41, 5, 0),
-	Frame(0, 63, 24, 85, 32, 62, 0, 0),
-	Frame(64, 159, 24, 85, 48, 62, 0, 0),
-	Frame(160, 223, 24, 85, 32, 62, 0, 0),
-	Frame(0, 31, 18, 108, 16, 91, 0, 0),
-	Frame(32, 191, 18, 108, 80, 91, 0, 0),
-	Frame(192, 223, 18, 108, 16, 91, 0, 0),
-	Frame(0, 31, 76, 135, 16, 60, 0, 0),
-	Frame(192, 223, 76, 135, 16, 60, 0, 0),
-	Frame(60, 75, 57, 61, 8, 5, 0, 0),
-	Frame(148, 163, 57, 61, 8, 5, 0, 0),
-	Frame(32, 63, 57, 99, 16, 43, 0, 0),
-	Frame(160, 191, 57, 99, 16, 43, 0, 0),
-	Frame(32, 63, 60, 98, 16, 39, 0, 0),
-	Frame(160, 191, 60, 98, 16, 39, 0, 0),
-	Frame(0, 15, 73, 85, 8, 13, 0, 0),
-	Frame(208, 223, 73, 85, 8, 13, 0, 0)
-};
-
-#define kFirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT
-#define kFirstFloorSet 75 // @ C075_GRAPHIC_FIRST_FLOOR_SET
-#define kFirstWallSet 77 // @ C077_GRAPHIC_FIRST_WALL_SET
-#define kFirstStairs 90 // @ C090_GRAPHIC_FIRST_STAIRS
-#define kFirstDoorSet 108 // @ C108_GRAPHIC_FIRST_DOOR_SET
-#define kInscriptionFont 120 // @ C120_GRAPHIC_INSCRIPTION_FONT
-#define kFirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT
-#define kFirstFloorOrn 247 // @ C247_GRAPHIC_FIRST_FLOOR_ORNAMENT
-#define kFirstDoorOrn 303 // @ C303_GRAPHIC_FIRST_DOOR_ORNAMENT
+#define k121_FirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT
+#define k75_FirstFloorSet 75 // @ C075_GRAPHIC_FIRST_FLOOR_SET
+#define k77_FirstWallSet 77 // @ C077_GRAPHIC_FIRST_WALL_SET
+#define k90_FirstStairs 90 // @ C090_GRAPHIC_FIRST_STAIRS
+#define k108_FirstDoorSet 108 // @ C108_GRAPHIC_FIRST_DOOR_SET
+#define k120_InscriptionFont 120 // @ C120_GRAPHIC_INSCRIPTION_FONT
+#define k121_FirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT
+#define k247_FirstFloorOrn 247 // @ C247_GRAPHIC_FIRST_FLOOR_ORNAMENT
+#define k303_FirstDoorOrn 303 // @ C303_GRAPHIC_FIRST_DOOR_ORNAMENT
 
 
 enum ViewSquare {
-	kViewSquare_D4C = -3, // @ CM3_VIEW_SQUARE_D4C
-	kViewSquare_D4L = -2, // @ CM2_VIEW_SQUARE_D4L
-	kViewSquare_D4R = -1, // @ CM1_VIEW_SQUARE_D4R
-	kViewSquare_D3C = 0, // @ C00_VIEW_SQUARE_D3C
-	kViewSquare_D3L = 1, // @ C01_VIEW_SQUARE_D3L
-	kViewSquare_D3R = 2, // @ C02_VIEW_SQUARE_D3R
-	kViewSquare_D2C = 3, // @ C03_VIEW_SQUARE_D2C
-	kViewSquare_D2L = 4, // @ C04_VIEW_SQUARE_D2L
-	kViewSquare_D2R = 5, // @ C05_VIEW_SQUARE_D2R
-	kViewSquare_D1C = 6, // @ C06_VIEW_SQUARE_D1C
-	kViewSquare_D1L = 7, // @ C07_VIEW_SQUARE_D1L
-	kViewSquare_D1R = 8, // @ C08_VIEW_SQUARE_D1R
-	kViewSquare_D0C = 9, // @ C09_VIEW_SQUARE_D0C
-	kViewSquare_D0L = 10, // @ C10_VIEW_SQUARE_D0L
-	kViewSquare_D0R = 11, // @ C11_VIEW_SQUARE_D0R
-	kViewSquare_D3C_Explosion = 3, // @ C03_VIEW_SQUARE_D3C_EXPLOSION
-	kViewSquare_D3L_Explosion = 4, // @ C04_VIEW_SQUARE_D3L_EXPLOSION
-	kViewSquare_D1C_Explosion = 9, // @ C09_VIEW_SQUARE_D1C_EXPLOSION
-	kViewSquare_D0C_Explosion = 12 // @ C12_VIEW_SQUARE_D0C_EXPLOSION
+	kM3_ViewSquare_D4C = -3, // @ CM3_VIEW_SQUARE_D4C
+	kM2_ViewSquare_D4L = -2, // @ CM2_VIEW_SQUARE_D4L
+	kM1_ViewSquare_D4R = -1, // @ CM1_VIEW_SQUARE_D4R
+	k0_ViewSquare_D3C = 0, // @ C00_VIEW_SQUARE_D3C
+	k1_ViewSquare_D3L = 1, // @ C01_VIEW_SQUARE_D3L
+	k2_ViewSquare_D3R = 2, // @ C02_VIEW_SQUARE_D3R
+	k3_ViewSquare_D2C = 3, // @ C03_VIEW_SQUARE_D2C
+	k4_ViewSquare_D2L = 4, // @ C04_VIEW_SQUARE_D2L
+	k5_ViewSquare_D2R = 5, // @ C05_VIEW_SQUARE_D2R
+	k6_ViewSquare_D1C = 6, // @ C06_VIEW_SQUARE_D1C
+	k7_ViewSquare_D1L = 7, // @ C07_VIEW_SQUARE_D1L
+	k8_ViewSquare_D1R = 8, // @ C08_VIEW_SQUARE_D1R
+	k9_ViewSquare_D0C = 9, // @ C09_VIEW_SQUARE_D0C
+	k10_ViewSquare_D0L = 10, // @ C10_VIEW_SQUARE_D0L
+	k11_ViewSquare_D0R = 11, // @ C11_VIEW_SQUARE_D0R
+	k3_ViewSquare_D3C_Explosion = 3, // @ C03_VIEW_SQUARE_D3C_EXPLOSION
+	k4_ViewSquare_D3L_Explosion = 4, // @ C04_VIEW_SQUARE_D3L_EXPLOSION
+	k9_ViewSquare_D1C_Explosion = 9, // @ C09_VIEW_SQUARE_D1C_EXPLOSION
+	k12_ViewSquare_D0C_Explosion = 12 // @ C12_VIEW_SQUARE_D0C_EXPLOSION
 };
 
 
-Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling
-Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor
+Frame gK12_CeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling
+Frame gK13_FloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor
 
-Frame gFrameWall_D3L2 = Frame(0, 15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2
-Frame gFrameWall_D3R2 = Frame(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2
-Frame gFrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls
+Frame g711_FrameWall_D3L2 = Frame(0, 15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2
+Frame g712_FrameWall_D3R2 = Frame(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2
+Frame g163_FrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls
 	/* { X1, X2, Y1, Y2, pixelWidth, Height, X, Y } */
 	Frame(74, 149, 25,  75,  64,  51,  18, 0),   /* D3C */
 	Frame(0,  83, 25,  75,  64,  51,  32, 0),   /* D3L */
@@ -264,39 +197,41 @@ Frame gFrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls
 	Frame(192, 223,  0, 135,  16, 136,   0, 0)
 }; /* D0R */
 
+
+// these denote the corresponding global in DisplayMan::_wallsetbitmaps
 enum WallSetIndices {
-	kDoorFrameFront = 0, // @  G0709_puc_Bitmap_WallSet_DoorFrameFront
-	kDoorFrameLeft_D1C = 1, // @  G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C
-	kDoorFameLeft_D2C = 2, // @  G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C
-	kDoorFrameLeft_D3C = 3, // @  G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C
-	kDoorFrameLeft_D3L = 4, // @  G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L
-	kDoorFrameTop_D1LCR = 5, // @  G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR
-	kDoorFrameTop_D2LCR = 6, // @  G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR
-	kWall_D0R = 7, // @  G0702_puc_Bitmap_WallSet_Wall_D0R
-	kWall_D0L = 8, // @  G0701_puc_Bitmap_WallSet_Wall_D0L
-	kWall_D1LCR = 9, // @  G0700_puc_Bitmap_WallSet_Wall_D1LCR
-	kWall_D2LCR = 10, // @  G0699_puc_Bitmap_WallSet_Wall_D2LCR
-	kWall_D3LCR = 11, // @  G0698_puc_Bitmap_WallSet_Wall_D3LCR
-	kWall_D3L2 = 12, // @  G0697_puc_Bitmap_WallSet_Wall_D3L2
-
-	kWall_D3R2 = 13, // @  G0696_puc_Bitmap_WallSet_Wall_D3R2
-	kDoorFrameRight_D1C = 14, // @  G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C
-
-	kWall_D0R_Flipped = 15,
-	kWall_D0L_Flipped = 16,
-	kWall_D1LCR_Flipped = 17,
-	kWall_D2LCR_Flipped = 18,
-	kWall_D3LCR_Flipped = 19,
-
-	kWall_D0R_Native = 20,
-	kWall_D0L_Native = 21,
-	kWall_D1LCR_Native = 22,
-	kWall_D2LCR_Native = 23,
-	kWall_D3LCR_Native = 24
+	kG709_DoorFrameFront = 0, // @  G0709_puc_Bitmap_WallSet_DoorFrameFront
+	kG708_DoorFrameLeft_D1C = 1, // @  G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C
+	kG707_DoorFameLeft_D2C = 2, // @  G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C
+	kG706_DoorFrameLeft_D3C = 3, // @  G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C
+	kG705_DoorFrameLeft_D3L = 4, // @  G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L
+	kG704_DoorFrameTop_D1LCR = 5, // @  G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR
+	kG703_DoorFrameTop_D2LCR = 6, // @  G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR
+	kG702_Wall_D0R = 7, // @  G0702_puc_Bitmap_WallSet_Wall_D0R
+	kG701_Wall_D0L = 8, // @  G0701_puc_Bitmap_WallSet_Wall_D0L
+	kG700_Wall_D1LCR = 9, // @  G0700_puc_Bitmap_WallSet_Wall_D1LCR
+	kG699_Wall_D2LCR = 10, // @  G0699_puc_Bitmap_WallSet_Wall_D2LCR
+	kG698_Wall_D3LCR = 11, // @  G0698_puc_Bitmap_WallSet_Wall_D3LCR
+	kG697_Wall_D3L2 = 12, // @  G0697_puc_Bitmap_WallSet_Wall_D3L2
+
+	kG696_Wall_D3R2 = 13, // @  G0696_puc_Bitmap_WallSet_Wall_D3R2
+	kG710_DoorFrameRight_D1C = 14, // @  G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C
+
+	kG94_Wall_D0R_Flipped = 15, // @ G0094_puc_Bitmap_WallD0R_Flipped
+	kG93_Wall_D0L_Flipped = 16, // @ G0093_puc_Bitmap_WallD0L_Flipped
+	kG92_Wall_D1LCR_Flipped = 17, // @ G0092_puc_Bitmap_WallD1LCR_Flipped
+	kG91_Wall_D2LCR_Flipped = 18, // @ G0091_puc_Bitmap_WallD2LCR_Flipped
+	kG90_Wall_D3LCR_Flipped = 19, // @ G0090_puc_Bitmap_WallD3LCR_Flipped
+
+	kG99_Wall_D0R_Native = 20, // @ G0099_puc_Bitmap_WallD0R_Native
+	kG98_Wall_D0L_Native = 21, // @ G0098_puc_Bitmap_WallD0L_Native
+	kG97_Wall_D1LCR_Native = 22, // @ G0097_puc_Bitmap_WallD1LCR_Native 
+	kG96_Wall_D2LCR_Native = 23, // @ G0096_puc_Bitmap_WallD2LCR_Native
+	kG95_Wall_D3LCR_Native = 24 // @ G0095_puc_Bitmap_WallD3LCR_Native
 };
 
 
-byte gDoorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordinateSetIndices
+byte g196_DoorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordinateSetIndices
 	0,   /* Door Ornament #00 Square Grid */
 	1,   /* Door Ornament #01 Iron Bars */
 	1,   /* Door Ornament #02 Jewels */
@@ -310,7 +245,7 @@ byte gDoorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordina
 	1,   /* Door Ornament #10 Ra Door */
 	1}; /* Door Ornament #11 Iron Door Damages */
 
-byte gFloorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnamentCoordinateSetIndices
+byte g195_FloorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnamentCoordinateSetIndices
 	0,   /* Floor Ornament 00 Square Grate */
 	0,   /* Floor Ornament 01 Square Pressure Pad */
 	0,   /* Floor Ornament 02 Moss */
@@ -321,7 +256,7 @@ byte gFloorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnamentCoor
 	2,   /* Floor Ornament 07 Tiny Pressure Pad */
 	0}; /* Floor Ornament 08 Puddle */
 
-uint16 gWallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets
+uint16 g205_WallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets
 	/* { X1, X2, Y1, Y2, PixelWidth, Height } */
 	{{80,  83, 41,  45,  8 * 2,   5},     /* D3L */
 	{140, 143, 41,  45,  8 * 2,   5},     /* D3R */
@@ -428,7 +363,7 @@ uint16 gWallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentC
 	{160, 191,  9, 119, 16 * 2, 111},     /* D1R */
 	{32, 191,  9, 119, 80 * 2, 111}}}; /* D1C */
 
-byte gWallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoordinateSetIndices
+byte g194_WallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoordinateSetIndices
 	1,   /* Wall Ornament 00 Unreadable Inscription */
 	1,   /* Wall Ornament 01 Square Alcove */
 	1,   /* Wall Ornament 02 Vi Altar */
@@ -490,7 +425,7 @@ byte gWallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoord
 	6,   /* Wall Ornament 58 Amalgam (Without Gem) */
 	7}; /* Wall Ornament 59 Lord Order (Outside) */
 
-CreatureAspect gCreatureAspects[k27_CreatureTypeCount] = { // @ G0219_as_Graphic558_CreatureAspects
+CreatureAspect g219_CreatureAspects[k27_CreatureTypeCount] = { // @ G0219_as_Graphic558_CreatureAspects
 														   /* { FirstNativeBitmapRelativeIndex, FirstDerivedBitmapIndex, pixelWidthFront, HeightFront,
 														   pixelWidthSide, HeightSide, pixelWidthAttack, HeightAttack, CoordinateSet / TransparentColor,
 														   Replacement Color Set Index for color 10 / Replacement Color Set Index for color 9 } */
@@ -522,7 +457,7 @@ CreatureAspect gCreatureAspects[k27_CreatureTypeCount] = { // @ G0219_as_Graphic
 	CreatureAspect(85, 0, 32 ,  93,  0 ,   0,  0 ,   0, 0x04, 0xCB),   /* Creature #25 Lord Order */
 	CreatureAspect(86, 0, 32 ,  93,  0 ,   0,  0 ,   0, 0x04, 0xCB)}; /* Creature #26 Grey Lord */
 
-ObjectAspect gObjectAspects[k85_ObjAspectCount] = { // @ G0209_as_Graphic558_ObjectAspects
+ObjectAspect g209_ObjectAspects[k85_ObjAspectCount] = { // @ G0209_as_Graphic558_ObjectAspects
 	/* FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo, CoordinateSet */
 	ObjectAspect(0,   0, 24, 27, 0x11, 0),
 	ObjectAspect(2,   6, 24,  8, 0x00, 1),
@@ -611,7 +546,7 @@ ObjectAspect gObjectAspects[k85_ObjAspectCount] = { // @ G0209_as_Graphic558_Obj
 	ObjectAspect(85, 176, 32, 17, 0x00, 0)
 };
 
-ProjectileAspect gProjectileAspect[k14_ProjectileAspectCount] = { // @ G0210_as_Graphic558_ProjectileAspects
+ProjectileAspect g210_ProjectileAspect[k14_ProjectileAspectCount] = { // @ G0210_as_Graphic558_ProjectileAspects
 	/* ProjectileAspect( FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo ) */
 	ProjectileAspect(0,   0, 32, 11, 0x0011),   /* Arrow */
 	ProjectileAspect(3,  18, 16, 11, 0x0011),   /* Dagger */
@@ -653,7 +588,7 @@ uint16 g21_PalDungeonView[6][16] = { // @ G0021_aaui_Graphic562_Palette_DungeonV
 	0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444
 };
 
-CreatureReplColorSet gCreatureReplColorSets[13] = { // @ G0220_as_Graphic558_CreatureReplacementColorSets
+CreatureReplColorSet g220_CreatureReplColorSets[13] = { // @ G0220_as_Graphic558_CreatureReplacementColorSets
 	/* { Color, Color, Color, Color, Color, Color, D2 replacement color index (x10), D3 replacement color index (x10) } */
 	{0x0CA0, 0x0A80, 0x0860, 0x0640, 0x0420, 0x0200,  90,  90},    /* Atari ST: { 0x0650, 0x0540, 0x0430, 0x0320, 0x0210, 0x0100,  90,  90 }, RGB colors are different */
 	{0x0060, 0x0040, 0x0020, 0x0000, 0x0000, 0x0000,   0,   0},    /* Atari ST: { 0x0030, 0x0020, 0x0010, 0x0000, 0x0000, 0x0000,   0,   0 }, */
@@ -669,23 +604,23 @@ CreatureReplColorSet gCreatureReplColorSets[13] = { // @ G0220_as_Graphic558_Cre
 	{0x0600, 0x0400, 0x0200, 0x0000, 0x0000, 0x0000, 120,   0},    /* Atari ST: { 0x0300, 0x0200, 0x0100, 0x0000, 0x0000, 0x0000, 120,   0 }, */
 	{0x0C86, 0x0A64, 0x0842, 0x0620, 0x0400, 0x0200, 100,  50}};  /* Atari ST: { 0x0643, 0x0532, 0x0421, 0x0310, 0x0200, 0x0100, 100,  50 } }; */
 
-byte gPalChangesCreature_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 0, 0, 110, 0, 20, 0, 130}; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3
-byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, 120, 130, 140, 150}; // @ G0222_auc_Graphic558_PaletteChanges_Creature_D2
+byte g221_PalChangesCreature_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 0, 0, 110, 0, 20, 0, 130}; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3
+byte g222_PalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, 120, 130, 140, 150}; // @ G0222_auc_Graphic558_PaletteChanges_Creature_D2
 
 
 
 
 Viewport gDefultViewPort(0, 0, 320, 200);
 // TODO: I guessed the numbers
-Viewport gDungeonViewport(0, 33, 224, 126); // @ G0296_puc_Bitmap_Viewport
+Viewport g296_DungeonViewport(0, 33, 224, 126); // @ G0296_puc_Bitmap_Viewport
 
-byte gPalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges
+byte g17_PalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges
 
-byte gPalChangesFloorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 140, 130}; // @ G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3
-byte gPalChangesFloorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2
+byte g213_PalChangesFloorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 140, 130}; // @ G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3
+byte g214_PalChangesFloorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2
 
-int gFountainOrnIndices[k1_FountainOrnCount] = {35}; // @ G0193_ai_Graphic558_FountainOrnamentIndices
-byte gAlcoveOrnIndices[k3_AlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrnamentIndices
+int16 g193_FountainOrnIndices[k1_FountainOrnCount] = {35}; // @ G0193_ai_Graphic558_FountainOrnamentIndices
+byte g192_AlcoveOrnIndices[k3_AlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrnamentIndices
 	1,   /* Square Alcove */
 	2,   /* Vi Altar */
 	3};  /* Arched Alcove */
@@ -751,14 +686,14 @@ DisplayMan::~DisplayMan() {
 		delete[] _bitmaps[0];
 		delete[] _bitmaps;
 	}
-	delete[] _wallSetBitMaps[kWall_D3R2]; // copy of another bitmap, but flipped
-	delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; // copy of another bitmap, but flipped
-	for (uint16 i = kWall_D0L_Flipped; i <= kWall_D3LCR_Flipped; ++i)
+	delete[] _wallSetBitMaps[kG696_Wall_D3R2]; // copy of another bitmap, but flipped
+	delete[] _wallSetBitMaps[kG710_DoorFrameRight_D1C]; // copy of another bitmap, but flipped
+	for (uint16 i = kG93_Wall_D0L_Flipped; i <= kG90_Wall_D3LCR_Flipped; ++i)
 		delete[] _wallSetBitMaps[i];
 
 	delete[] _g639_derivedBitmapByteCount;
 	if (_g638_derivedBitmaps) {
-		for (uint16 i = 0; i < kDerivedBitmapMaximumCount; ++i)
+		for (uint16 i = 0; i < k730_DerivedBitmapMaximumCount; ++i)
 			delete[] _g638_derivedBitmaps;
 		delete[] _g638_derivedBitmaps;
 	}
@@ -802,10 +737,10 @@ void DisplayMan::loadGraphics() {
 
 
 	if (!_g639_derivedBitmapByteCount)
-		_g639_derivedBitmapByteCount = new uint16[kDerivedBitmapMaximumCount];
+		_g639_derivedBitmapByteCount = new uint16[k730_DerivedBitmapMaximumCount];
 	if (!_g638_derivedBitmaps) {
-		_g638_derivedBitmaps = new byte*[kDerivedBitmapMaximumCount];
-		for (uint16 i = 0; i < kDerivedBitmapMaximumCount; ++i)
+		_g638_derivedBitmaps = new byte*[k730_DerivedBitmapMaximumCount];
+		for (uint16 i = 0; i < k730_DerivedBitmapMaximumCount; ++i)
 			_g638_derivedBitmaps[i] = nullptr;
 	}
 
@@ -825,7 +760,7 @@ void DisplayMan::loadGraphics() {
 	_g102_currMapFloorOrnInfo[k15_FloorOrnFootprints][k0_NativeBitmapIndex] = k241_FloorOrn_15_D3L_footprints;
 	_g102_currMapFloorOrnInfo[k15_FloorOrnFootprints][k1_CoordinateSet] = 1;
 
-	ObjectAspect *objectAspect = gObjectAspects;
+	ObjectAspect *objectAspect = g209_ObjectAspects;
 	int16 derivedBitmapIndex;
 	for (int16 objectAspectIndex = 0; objectAspectIndex < k85_ObjAspectCount; ++objectAspectIndex, ++objectAspect) {
 		derivedBitmapIndex = k104_DerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex;
@@ -847,7 +782,7 @@ void DisplayMan::loadGraphics() {
 		}
 	}
 
-	ProjectileAspect *projectileAspect = gProjectileAspect;
+	ProjectileAspect *projectileAspect = g210_ProjectileAspect;
 	for (int16 projectileAspectIndex = 0; projectileAspectIndex < k14_ProjectileAspectCount; projectileAspectIndex++, projectileAspect++) {
 
 		if (!getFlag(projectileAspect->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask)) {
@@ -868,9 +803,9 @@ void DisplayMan::loadGraphics() {
 		}
 	}
 
-	_g75_palChangesProjectile[0] = gPalChangesFloorOrn_D3;
-	_g75_palChangesProjectile[1] = gPalChangesFloorOrn_D2;
-	_g75_palChangesProjectile[2] = _g75_palChangesProjectile[3] = gPalChangesNoChanges;
+	_g75_palChangesProjectile[0] = g213_PalChangesFloorOrn_D3;
+	_g75_palChangesProjectile[1] = g214_PalChangesFloorOrn_D2;
+	_g75_palChangesProjectile[2] = _g75_palChangesProjectile[3] = g17_PalChangesNoChanges;
 
 	derivedBitmapIndex = k438_DerivedBitmapFirstExplosion;
 	ExplosionAspect *expAsp = g211_ExplosionAspects;
@@ -886,7 +821,7 @@ void DisplayMan::loadGraphics() {
 	derivedBitmapIndex = k495_DerivedBitmapFirstCreature;
 	CreatureAspect *creatureAsp;
 	for (int16 creatureIndex = 0; creatureIndex < k27_CreatureTypeCount; creatureIndex++) {
-		creatureAsp = &gCreatureAspects[creatureIndex];
+		creatureAsp = &g219_CreatureAspects[creatureIndex];
 
 		int16 creatureGraphicInfo = gCreatureInfo[creatureIndex]._graphicInfo;
 		creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex;
@@ -1097,7 +1032,7 @@ byte* DisplayMan::getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int
 		byte *nativeBitmap = getBitmap(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice);
 		bitmap = getDerivedBitmap(derBitmapIndex);
 		blitToBitmapShrinkWithPalChange(nativeBitmap, explAsp->_pixelWidth, explAsp->_height, bitmap, pixelWidth, height,
-			(explosionAspIndex == k3_ExplosionAspectSmoke) ? gPalChangeSmoke : gPalChangesNoChanges);
+			(explosionAspIndex == k3_ExplosionAspectSmoke) ? g212_PalChangeSmoke : g17_PalChangesNoChanges);
 		warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 	}
 
@@ -1129,12 +1064,12 @@ uint16 DisplayMan::getHeight(uint16 index) {
 
 void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
 	if (f._srcWidth)
-		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k255_ColorNoTransparency, gDungeonViewport);
+		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k255_ColorNoTransparency, g296_DungeonViewport);
 }
 
 void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) {
 	if (f._srcWidth)
-		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, gDungeonViewport);
+		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, g296_DungeonViewport);
 }
 
 
@@ -1147,12 +1082,12 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[kElemAspect]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3L]);
+			drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g110_FrameStairsUpFront_D3L);
 		else
-			drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3L]);
+			drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g121_FrameStairsDownFront_D3L);
 		goto T0116015_redEagle;
 	case kWallElemType:
-		drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3L]);
+		drawWallSetBitmap(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k1_ViewSquare_D3L]);
 		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT);
 		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
@@ -1165,14 +1100,14 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
 		goto T0116016_blueToad;
 	case kElementTypeDoorFront:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
-		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
-		drawWallSetBitmap(_wallSetBitMaps[kDoorFrameLeft_D3L], g0164Frame_DoorFrameLeft_D3L);
+		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
+		drawWallSetBitmap(_wallSetBitMaps[kG705_DoorFrameLeft_D3L], g164_Frame_DoorFrameLeft_D3L);
 		warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor");
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0116017_orangeElk;
 	case kElementTypePit:
 		if (!squareAspect[kPitInvisibleAspect]) {
-			drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, g0140FrameFloorPit_D3L);
+			drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, g140_FrameFloorPit_D3L);
 		}
 	case kElementTypeTeleporter:
 	case kElementTypeCorridor:
@@ -1181,10 +1116,10 @@ T0116015_redEagle:
 T0116016_blueToad:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
 T0116017_orangeElk:
-		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3L, order);
+		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order);
 	}
 	if ((squareAspect[kElemAspect] == kElementTypeTeleporter) && squareAspect[kTeleporterVisibleAspect]) {
-		drawField(&gFieldAspects[kViewSquare_D3L], gFrameWalls[kViewSquare_D3L]._box);
+		drawField(&g188_FieldAspects[k1_ViewSquare_D3L], g163_FrameWalls[k1_ViewSquare_D3L]._box);
 	}
 }
 
@@ -1198,13 +1133,13 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[kElemAspect]) {
 	case kElementTypeStaisFront:
 		if (squareAspect[kStairsUpAspect]) {
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g0112FrameStairsUpFront_D3R);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g112_FrameStairsUpFront_D3R);
 		} else {
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g0123FrameStairsDownFront_D3R);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g123_FrameStairsDownFront_D3R);
 		}
 		goto T0117016;
 	case kElementTypeWall:
-		drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3R]);
+		drawWallSetBitmap(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k2_ViewSquare_D3R]);
 		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT);
 		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
@@ -1217,8 +1152,8 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
 		goto T0117017;
 	case kElementTypeDoorFront:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
-		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
-		memcpy(_g74_tmpBitmap, _wallSetBitMaps[kDoorFrameLeft_D3L], 32 * 44);
+		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
+		memcpy(_g74_tmpBitmap, _wallSetBitMaps[kG705_DoorFrameLeft_D3L], 32 * 44);
 		warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally");
 		if (((Door*)_vm->_dungeonMan->_dunData._thingsData[kDoorThingType])[squareAspect[kDoorThingIndexAspect]].hasButton()) {
 			warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton");
@@ -1228,7 +1163,7 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
 		goto T0117018;
 	case kElementTypePit:
 		if (!squareAspect[kPitInvisibleAspect]) {
-			drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, g0142FrameFloorPit_D3R);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, g142_FrameFloorPit_D3R);
 		}
 	case kElementTypeTeleporter:
 	case kElementTypeCorridor:
@@ -1237,10 +1172,10 @@ T0117016:
 T0117017:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
 T0117018:
-		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3R, order);
+		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order);
 	}
 	if ((squareAspect[kElemAspect] == kElementTypeTeleporter) && squareAspect[kTeleporterVisibleAspect]) {
-		drawField(&gFieldAspects[kViewSquare_D3R], gFrameWalls[kViewSquare_D3R]._box);
+		drawField(&g188_FieldAspects[k2_ViewSquare_D3R], g163_FrameWalls[k2_ViewSquare_D3R]._box);
 	}
 }
 
@@ -1250,12 +1185,12 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, gStairFrames[kFrameStairsUpFront_D3C]);
+			drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, g111_FrameStairsUpFront_D3C);
 		else
-			drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, gStairFrames[kFrameStairsDownFront_D3C]);
+			drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, g122_FrameStairsDownFront_D3C);
 		break;
 	case kWallElemType:
-		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3C]);
+		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k0_ViewSquare_D3C]);
 		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) {
 			//... missing code
 		}
@@ -1270,19 +1205,19 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2L]);
+			drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L);
 		else
-			drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2L]);
+			drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L);
 		break;
 	case kWallElemType:
-		drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2L]);
+		drawWallSetBitmap(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k4_ViewSquare_D2L]);
 		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT);
 		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) {
 			// ... missing code
 		}
 		break;
 	case kStairsSideElemType:
-		drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2L]);
+		drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L);
 		break;
 	default:
 		break;
@@ -1294,19 +1229,19 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R);
 		else
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R);
 		break;
 	case kWallElemType:
-		drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2R]);
+		drawWallSetBitmap(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k5_ViewSquare_D2R]);
 		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT);
 		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) {
 			// ... missing code
 		}
 		break;
 	case kStairsSideElemType:
-		drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]);
+		drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R);
 		break;
 	default:
 		break;
@@ -1318,12 +1253,12 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, gStairFrames[kFrameStairsUpFront_D2C]);
+			drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, g114_FrameStairsUpFront_D2C);
 		else
-			drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, gStairFrames[kFrameStairsDownFront_D2C]);
+			drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, g125_FrameStairsDownFront_D2C);
 		break;
 	case kWallElemType:
-		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2C]);
+		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k3_ViewSquare_D2C]);
 		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) {
 			// ... missing code
 		}
@@ -1338,19 +1273,19 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1L]);
+			drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g116_FrameStairsUpFront_D1L);
 		else
-			drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1L]);
+			drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g127_FrameStairsDownFront_D1L);
 		break;
 	case kWallElemType:
-		drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1L]);
+		drawWallSetBitmap(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k7_ViewSquare_D1L]);
 		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT);
 		break;
 	case kStairsSideElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1L]);
+			drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g134_FrameStairsUpSide_D1L);
 		else
-			drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1L]);
+			drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g136_FrameStairsDownSide_D1L);
 		break;
 	default:
 		break;
@@ -1362,19 +1297,19 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g118_FrameStairsUpFront_D1R);
 		else
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g129_FrameStairsDownFront_D1R);
 		break;
 	case kWallElemType:
-		drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1R]);
+		drawWallSetBitmap(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k8_ViewSquare_D1R]);
 		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT);
 		break;
 	case kStairsSideElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g135_FrameStairsUpSide_D1R);
 		else
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g137_FrameStairsDownSide_D1R);
 		break;
 	default:
 		break;
@@ -1386,15 +1321,15 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, gStairFrames[kFrameStairsUpFront_D1C]);
+			drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, g117_FrameStairsUpFront_D1C);
 		else
-			drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, gStairFrames[kFrameStairsDownFront_D1C]);
+			drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, g128_FrameStairsDownFront_D1C);
 		break;
 	case kWallElemType:
 		_vm->_dungeonMan->_isFacingAlcove = false;
 		_vm->_dungeonMan->_isFacingViAltar = false;
 		_vm->_dungeonMan->_isFacingFountain = false;
-		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1C]);
+		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k6_ViewSquare_D1C]);
 		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) {
 			// .... code not yet implemneted
 		}
@@ -1410,10 +1345,10 @@ void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsSideElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0L]);
+			drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, g138_FrameStairsSide_D0L);
 		break;
 	case kWallElemType:
-		drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]);
+		drawWallSetBitmap(_wallSetBitMaps[kG701_Wall_D0L], g163_FrameWalls[k10_ViewSquare_D0L]);
 		break;
 	default:
 		break;
@@ -1426,10 +1361,10 @@ void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsSideElemType:
 		if (squareAspect[kStairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0R]);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R);
 		return;
 	case kWallElemType:
-		drawWallSetBitmap(_wallSetBitMaps[kWall_D0R], gFrameWalls[kViewSquare_D0R]);
+		drawWallSetBitmap(_wallSetBitMaps[kG702_Wall_D0R], g163_FrameWalls[k11_ViewSquare_D0R]);
 		break;
 	default:
 		break;
@@ -1442,11 +1377,11 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[0]) {
 	case kStairsFrontElemType:
 		if (squareAspect[kStairsUpAspect]) {
-			drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0L]);
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0R]);
+			drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g119_FrameStairsUpFront_D0L);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g120_FrameStairsUpFront_D0R);
 		} else {
-			drawFloorPitOrStairsBitmap(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0L]);
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0R]);
+			drawFloorPitOrStairsBitmap(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g130_FrameStairsDownFront_D0L);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g131_FrameStairsDownFront_D0R);
 		}
 		break;
 	default:
@@ -1471,26 +1406,26 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	}
 
 	if (flippedFloorCeiling) {
-		uint16 w = gFloorFrame._srcWidth, h = gFloorFrame._srcHeight;
+		uint16 w = gK13_FloorFrame._srcWidth, h = gK13_FloorFrame._srcHeight;
 		blitToBitmap(_g84_floorBitmap, w, h, tmpBitmap, w);
 		flipBitmapHorizontal(tmpBitmap, w, h);
-		drawWallSetBitmap(tmpBitmap, gFloorFrame);
-		drawWallSetBitmap(_g85_ceilingBitmap, gCeilingFrame);
+		drawWallSetBitmap(tmpBitmap, gK13_FloorFrame);
+		drawWallSetBitmap(_g85_ceilingBitmap, gK12_CeilingFrame);
 
-		for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i)
-			_wallSetBitMaps[i + kWall_D0R] = _wallSetBitMaps[i + kWall_D0R_Flipped];
+		for (uint16 i = 0; i <= kG698_Wall_D3LCR - kG702_Wall_D0R; ++i)
+			_wallSetBitMaps[i + kG702_Wall_D0R] = _wallSetBitMaps[i + kG94_Wall_D0R_Flipped];
 	} else {
-		uint16 w = gCeilingFrame._srcWidth, h = gCeilingFrame._srcHeight;
+		uint16 w = gK12_CeilingFrame._srcWidth, h = gK12_CeilingFrame._srcHeight;
 		blitToBitmap(_g85_ceilingBitmap, w, h, tmpBitmap, w);
 		flipBitmapHorizontal(tmpBitmap, w, h);
-		drawWallSetBitmap(tmpBitmap, gCeilingFrame);
-		drawWallSetBitmap(_g84_floorBitmap, gFloorFrame);
+		drawWallSetBitmap(tmpBitmap, gK12_CeilingFrame);
+		drawWallSetBitmap(_g84_floorBitmap, gK13_FloorFrame);
 	}
 
 	if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallElemType)
-		drawWallSetBitmap(_wallSetBitMaps[kWall_D3L2], gFrameWall_D3L2);
+		drawWallSetBitmap(_wallSetBitMaps[kG697_Wall_D3L2], g711_FrameWall_D3L2);
 	if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallElemType)
-		drawWallSetBitmap(_wallSetBitMaps[kWall_D3R2], gFrameWall_D3R2);
+		drawWallSetBitmap(_wallSetBitMaps[kG696_Wall_D3R2], g712_FrameWall_D3R2);
 
 	int16 tmpPosX = posX, tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY);
@@ -1528,8 +1463,8 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	drawSquareD0C(dir, posX, posY);
 
 
-	for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i)
-		_wallSetBitMaps[i + kWall_D0R] = _wallSetBitMaps[i + kWall_D0R_Native];
+	for (uint16 i = 0; i <= kG698_Wall_D3LCR - kG702_Wall_D0R; ++i)
+		_wallSetBitMaps[i + kG702_Wall_D0R] = _wallSetBitMaps[i + kG99_Wall_D0R_Native];
 
 	delete[] tmpBitmap;
 }
@@ -1545,29 +1480,29 @@ void DisplayMan::clearBitmap(byte *bitmap, uint16 width, uint16 height, Color co
 
 void DisplayMan::loadFloorSet(FloorSet set) {
 	// there are 2 bitmaps per set, first one is at 75
-	GraphicIndice indice = (GraphicIndice)(kFirstFloorSet + (k2_FloorSetGraphicCount * set));
+	GraphicIndice indice = (GraphicIndice)(k75_FirstFloorSet + (k2_FloorSetGraphicCount * set));
 	_g84_floorBitmap = _bitmaps[indice];
 	_g85_ceilingBitmap = _bitmaps[indice + 1];
 }
 
 
-Box gBoxWallBitmap_D3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR
-Box gBoxWallBitmap_D2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR
+Box g161_BoxWallBitmap_D3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR
+Box g162_BoxWallBitmap_D2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR
 
 void DisplayMan::loadWallSet(WallSet set) {
-	uint16 firstIndice = (set * k13_WallSetGraphicCount) + kFirstWallSet;
+	uint16 firstIndice = (set * k13_WallSetGraphicCount) + k77_FirstWallSet;
 	for (uint16 i = 0; i < k13_WallSetGraphicCount; ++i) {
 		_wallSetBitMaps[i] = _bitmaps[i + firstIndice];
 	}
 
-	for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i)
-		_wallSetBitMaps[i + kWall_D0R_Native] = _wallSetBitMaps[i + kWall_D0R];
+	for (uint16 i = 0; i <= kG698_Wall_D3LCR - kG702_Wall_D0R; ++i)
+		_wallSetBitMaps[i + kG99_Wall_D0R_Native] = _wallSetBitMaps[i + kG702_Wall_D0R];
 
-	uint16 srcIndex[7] = {kDoorFrameLeft_D1C,  kWall_D3L2, kWall_D1LCR,         kWall_D0L,         kWall_D0R,
-	kWall_D2LCR,         kWall_D3LCR};
+	uint16 srcIndex[7] = {kG708_DoorFrameLeft_D1C,  kG697_Wall_D3L2, kG700_Wall_D1LCR,         kG701_Wall_D0L,         kG702_Wall_D0R,
+	kG699_Wall_D2LCR,         kG698_Wall_D3LCR};
 
-	uint16 destIndex[7] = {kDoorFrameRight_D1C, kWall_D3R2, kWall_D1LCR_Flipped, kWall_D0R_Flipped, kWall_D0L_Flipped,
-	kWall_D2LCR_Flipped, kWall_D3LCR_Flipped};
+	uint16 destIndex[7] = {kG710_DoorFrameRight_D1C, kG696_Wall_D3R2, kG92_Wall_D1LCR_Flipped, kG94_Wall_D0R_Flipped, kG93_Wall_D0L_Flipped,
+	kG91_Wall_D2LCR_Flipped, kG90_Wall_D3LCR_Flipped};
 
 	// the original loads these flipped walls in loadCurrentMapGraphics
 
@@ -1577,29 +1512,9 @@ void DisplayMan::loadWallSet(WallSet set) {
 		delete[] _wallSetBitMaps[destIndex[i]];
 		_wallSetBitMaps[destIndex[i]] = new byte[w * h];
 		blitToBitmap(_wallSetBitMaps[srcIndex[i]], w, h, _wallSetBitMaps[destIndex[i]], w);
-		if (srcIndex[i] != kWall_D2LCR && srcIndex[i] != kWall_D3LCR) // TODO: implement flipping of these two bitmaps, disabled with if
+		if (srcIndex[i] != kG699_Wall_D2LCR && srcIndex[i] != kG698_Wall_D3LCR) // TODO: implement flipping of these two bitmaps, disabled with if
 			flipBitmapHorizontal(_wallSetBitMaps[destIndex[i]], w, h);
 	}
-
-
-	/*
-	uint16 graphicIndice = firstIndice + kWall_D2LCR;
-	uint16 w = width(graphicIndice), h = height(graphicIndice);
-	byte *tmp = new byte[w * h];
-	clearBitmap(tmp, w, h, kColorFlesh);
-	Box *box = &gBoxWallBitmap_D2LCR;
-	blitToBitmap(_wallSetBitMaps[kWall_D2LCR_Flipped], w, 8, 0, tmp, w, box->X1, box->X2, box->Y1, box->Y2, kColorNoTransparency);
-	delete[] _wallSetBitMaps[kWall_D2LCR_Flipped];
-	_wallSetBitMaps[kWall_D2LCR_Flipped] = tmp;
-
-	graphicIndice = firstIndice + kWall_D3LCR;
-	w = width(graphicIndice), h = height(graphicIndice);
-	tmp = new byte[w * h];
-	clearBitmap(tmp, w, h, kColorFlesh);
-	box = &gBoxWallBitmap_D3LCR;
-	blitToBitmap(_wallSetBitMaps[kWall_D3LCR_Flipped], w, 8, 0, tmp, w, box->X1, box->X2, box->Y1, box->Y2, kColorNoTransparency);
-	delete[] _wallSetBitMaps[kWall_D3LCR_Flipped];
-	_wallSetBitMaps[kWall_D3LCR_Flipped] = tmp;*/
 }
 
 
@@ -1610,7 +1525,7 @@ void DisplayMan::loadCurrentMapGraphics() {
 	// the original loads some flipped walls here, I moved it to loadWallSet
 
 	{
-		int16 val = _vm->_dungeonMan->_currMap._map->_wallSet * k18_StairsGraphicCount + kFirstStairs;
+		int16 val = _vm->_dungeonMan->_currMap._map->_wallSet * k18_StairsGraphicCount + k90_FirstStairs;
 		_g675_stairsNativeBitmapIndex_Up_Front_D3L = val++;
 		_g676_stairsNativeBitmapIndex_Up_Front_D3C = val++;
 		_g677_stairsNativeBitmapIndex_Up_Front_D2L = val++;
@@ -1647,11 +1562,11 @@ void DisplayMan::loadCurrentMapGraphics() {
 
 	for (uint16 i = 0; i < currMap._wallOrnCount; ++i) {
 		uint16 ornIndice = _g261_currMapWallOrnIndices[i];
-		uint16 nativeIndice = kFirstWallOrn + ornIndice * 2;
+		uint16 nativeIndice = k121_FirstWallOrn + ornIndice * 2;
 
 		_g101_currMapWallOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice;
 		for (uint16 ornCounter = 0; ornCounter < k3_AlcoveOrnCount; ++ornCounter) {
-			if (ornIndice == gAlcoveOrnIndices[ornCounter]) {
+			if (ornIndice == g192_AlcoveOrnIndices[ornCounter]) {
 				_g267_currMapAlcoveOrnIndices[alcoveCount++] = i;
 				if (ornIndice == 2)
 					_g266_currMapViAltarIndex = i;
@@ -1659,31 +1574,31 @@ void DisplayMan::loadCurrentMapGraphics() {
 		}
 
 		for (uint16 ornCounter = 0; ornCounter < k1_FountainOrnCount; ++ornCounter)
-			if (ornIndice == gFountainOrnIndices[ornCounter])
+			if (ornIndice == g193_FountainOrnIndices[ornCounter])
 				_g268_currMapFountainOrnIndices[fountainCount++] = i;
 
-		_g101_currMapWallOrnInfo[i][k1_CoordinateSet] = gWallOrnCoordSetIndices[ornIndice];
+		_g101_currMapWallOrnInfo[i][k1_CoordinateSet] = g194_WallOrnCoordSetIndices[ornIndice];
 	}
 
 	for (uint16 i = 0; i < currMap._floorOrnCount; ++i) {
 		uint16 ornIndice = _g262_currMapFloorOrnIndices[i];
-		uint16 nativeIndice = kFirstFloorOrn + ornIndice * 6;
+		uint16 nativeIndice = k247_FirstFloorOrn + ornIndice * 6;
 		_g102_currMapFloorOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice;
-		_g102_currMapFloorOrnInfo[i][k1_CoordinateSet] = gFloorOrnCoordSetIndices[ornIndice];
+		_g102_currMapFloorOrnInfo[i][k1_CoordinateSet] = g195_FloorOrnCoordSetIndices[ornIndice];
 	}
 
 	for (uint16 i = 0; i < currMap._doorOrnCount; ++i) {
 		uint16 ornIndice = _g263_currMapDoorOrnIndices[i];
-		uint16 nativeIndice = kFirstDoorOrn + ornIndice;
+		uint16 nativeIndice = k303_FirstDoorOrn + ornIndice;
 		_g103_currMapDoorOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice;
-		_g103_currMapDoorOrnInfo[i][k1_CoordinateSet] = gDoorOrnCoordIndices[ornIndice];
+		_g103_currMapDoorOrnInfo[i][k1_CoordinateSet] = g196_DoorOrnCoordIndices[ornIndice];
 	}
 
 	applyCreatureReplColors(9, 8);
 	applyCreatureReplColors(10, 12);
 
 	for (uint16 creatureType = 0; creatureType < currMap._creatureTypeCount; ++creatureType) {
-		CreatureAspect &aspect = gCreatureAspects[_g264_currMapAllowedCreatureTypes[creatureType]];
+		CreatureAspect &aspect = g219_CreatureAspects[_g264_currMapAllowedCreatureTypes[creatureType]];
 		uint16 replColorOrdinal = aspect.getReplColour9();
 		if (replColorOrdinal)
 			applyCreatureReplColors(9, _vm->ordinalToIndex(replColorOrdinal));
@@ -1695,15 +1610,15 @@ void DisplayMan::loadCurrentMapGraphics() {
 
 void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor) {
 	for (int16 i = 0; i < 6; ++i)
-		g21_PalDungeonView[i][replacedColor] = gCreatureReplColorSets[replacementColor]._RGBColor[i];
+		g21_PalDungeonView[i][replacedColor] = g220_CreatureReplColorSets[replacementColor]._RGBColor[i];
 
-	gPalChangesCreature_D2[replacedColor] = gCreatureReplColorSets[replacementColor]._D2ReplacementColor;
-	gPalChangesCreature_D3[replacedColor] = gCreatureReplColorSets[replacementColor]._D3ReplacementColor;
+	g222_PalChangesCreature_D2[replacedColor] = g220_CreatureReplColorSets[replacementColor]._D2ReplacementColor;
+	g221_PalChangesCreature_D3[replacedColor] = g220_CreatureReplColorSets[replacementColor]._D3ReplacementColor;
 }
 
 void DisplayMan::drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
 	if (f._srcWidth) {
-		blitToScreen(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, gDungeonViewport);
+		blitToScreen(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, g296_DungeonViewport);
 	}
 }
 
@@ -1711,18 +1626,18 @@ void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeInde
 	if (f._srcWidth) {
 		blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcHeight, _g74_tmpBitmap, f._srcWidth);
 		flipBitmapHorizontal(_g74_tmpBitmap, f._srcWidth, f._srcHeight);
-		blitToScreen(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, gDungeonViewport);
+		blitToScreen(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, g296_DungeonViewport);
 	}
 }
 
 
-Box gBoxWallPatchBehindInscription = Box(110, 113, 37, 63); // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription 
-byte gInscriptionLineY[4] = { // @ G0203_auc_Graphic558_InscriptionLineY
+Box g202_BoxWallPatchBehindInscription = Box(110, 113, 37, 63); // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription 
+byte g203_InscriptionLineY[4] = { // @ G0203_auc_Graphic558_InscriptionLineY
 	48,   /* 1 Line  */
 	59,   /* 2 lines */
 	75,   /* 3 lines */
 	86}; /* 4 lines */
-byte gWallOrnDerivedBitmapIndexIncrement[12] = { // @ G0190_auc_Graphic558_WallOrnamentDerivedBitmapIndexIncrement
+byte g190_WallOrnDerivedBitmapIndexIncrement[12] = { // @ G0190_auc_Graphic558_WallOrnamentDerivedBitmapIndexIncrement
 	0,   /* D3L Right */
 	0,   /* D3R Left */
 	1,   /* D3L Front */
@@ -1736,10 +1651,10 @@ byte gWallOrnDerivedBitmapIndexIncrement[12] = { // @ G0190_auc_Graphic558_WallO
 	4,   /* D1L Right */
 	4}; /* D1R Left */
 
-byte gPalChangesDoorButtonAndWallOrn_D3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3
-byte gPalChangesDoorButtonAndWallOrn_D2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2
+byte g198_PalChangesDoorButtonAndWallOrn_D3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3
+byte g199_PalChangesDoorButtonAndWallOrn_D2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2
 
-byte gUnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableInscriptionBoxY2
+byte g204_UnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableInscriptionBoxY2
 	/* { Y for 1 line, Y for 2 lines, Y for 3 lines } */
 	45, 48, 53,   /* D3L Right, D3R Left */
 	43, 49, 56,   /* D3L Front, D3C Front, D3R Front */
@@ -1747,7 +1662,7 @@ byte gUnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableIns
 	46, 53, 63,   /* D2L Front, D2C Front, D2R Front */
 	46, 57, 68}; /* D1L Right, D1R Left */
 
-Box gBoxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall
+Box g109_BoxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall
 
 bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) {
 	byte *bitmapGreen;
@@ -1765,7 +1680,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 		int16 wallOrnIndex = wallOrnOrd - 1;
 		int16 nativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k0_NativeBitmapIndex];
 
-		uint16 *coordinateSetA = gWallOrnCoordSets[_g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]][viewWallIndex];
+		uint16 *coordinateSetA = g205_WallOrnCoordSets[_g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]][viewWallIndex];
 		isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnIndex);
 		isInscription = (wallOrnIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex);
 		if (isInscription) {
@@ -1775,9 +1690,9 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 		if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) {
 			if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
 				if (isInscription) {
-					Frame &D1CFrame = gFrameWalls[kViewSquare_D1C];
-					blitToScreen(_wallSetBitMaps[kWall_D1LCR], D1CFrame._srcWidth, 94, 28, gBoxWallPatchBehindInscription._x1, gBoxWallPatchBehindInscription._x2,
-								 gBoxWallPatchBehindInscription._y1, gBoxWallPatchBehindInscription._y2, k255_ColorNoTransparency, gDungeonViewport);
+					Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C];
+					blitToScreen(_wallSetBitMaps[kG700_Wall_D1LCR], D1CFrame._srcWidth, 94, 28, g202_BoxWallPatchBehindInscription._x1, g202_BoxWallPatchBehindInscription._x2,
+								 g202_BoxWallPatchBehindInscription._y1, g202_BoxWallPatchBehindInscription._y2, k255_ColorNoTransparency, g296_DungeonViewport);
 
 					unsigned char *string = inscriptionString;
 					bitmapRed = _bitmaps[k120_InscriptionFontIndice];
@@ -1789,9 +1704,9 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 							characterCount++;
 						}
 						frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7;
-						frame._box._y1 = (frame._box._y2 = gInscriptionLineY[textLineIndex++]) - 7;
+						frame._box._y1 = (frame._box._y2 = g203_InscriptionLineY[textLineIndex++]) - 7;
 						while (characterCount--) {
-							blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._box, k10_ColorFlesh, gDungeonViewport);
+							blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._box, k10_ColorFlesh, g296_DungeonViewport);
 							frame._box._x1 += 8;
 							frame._box._x2 += 8;
 						}
@@ -1828,12 +1743,12 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 			int16 wallOrnCoordSetIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet];
 			flipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT);
 			if (flipHorizontal) {
-				coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][k11_ViewWall_D1R_LEFT];
+				coordSetB = g205_WallOrnCoordSets[wallOrnCoordSetIndex][k11_ViewWall_D1R_LEFT];
 			} else if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT)) {
-				coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][k10_ViewWall_D1L_RIGHT];
+				coordSetB = g205_WallOrnCoordSets[wallOrnCoordSetIndex][k10_ViewWall_D1L_RIGHT];
 			} else {
 				nativeBitmapIndex++;
-				coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][k12_ViewWall_D1C_FRONT];
+				coordSetB = g205_WallOrnCoordSets[wallOrnCoordSetIndex][k12_ViewWall_D1C_FRONT];
 				if (viewWallIndex == k7_ViewWall_D2L_FRONT) {
 					coordinateSetOffset = 6;
 				} else if (viewWallIndex == k9_ViewWall_D2R_FRONT) {
@@ -1842,7 +1757,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 			}
 			int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0];
 			blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], coordSetB[4] << 1, coordSetB[5], _g74_tmpBitmap, pixelWidth + 1, coordinateSetA[5],
-				(viewWallIndex <= k4_ViewWall_D3R_FRONT) ? gPalChangesDoorButtonAndWallOrn_D3 : gPalChangesDoorButtonAndWallOrn_D2);
+				(viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
 			bitmapGreen = _bitmaps[nativeBitmapIndex];
 			var_X = pixelWidth;
 			if (flipHorizontal) {
@@ -1877,15 +1792,15 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 
 				coordinateSetA = (uint16*)&frame._box;
 
-				coordinateSetA[3] = gUnreadableInscriptionBoxY2[gWallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
+				coordinateSetA[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
 			}
 		}
-		blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, coordinateSetA[0], coordinateSetA[1], coordinateSetA[2], coordinateSetA[3], k10_ColorFlesh, gDungeonViewport);
+		blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, coordinateSetA[0], coordinateSetA[1], coordinateSetA[2], coordinateSetA[3], k10_ColorFlesh, g296_DungeonViewport);
 
 		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
-			Box &box = gBoxChampionPortraitOnWall;
+			Box &box = g109_BoxChampionPortraitOnWall;
 			blitToScreen(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29, box._x1, box._x2, box._y1, box._y2,
-						 k1_ColorDarkGary, gDungeonViewport);
+						 k1_ColorDarkGary, g296_DungeonViewport);
 		}
 		return isAlcove;
 	}
@@ -1955,12 +1870,12 @@ int16 DisplayMan::getScaledDimension(int16 dimension, int16 scale) {
 }
 
 /* This is the full dungeon view */
-Box gBoxExplosionPattern_D0C = Box(0, 223, 0, 135); // @ G0105_s_Graphic558_Box_ExplosionPattern_D0C 
+Box g105_BoxExplosionPattern_D0C = Box(0, 223, 0, 135); // @ G0105_s_Graphic558_Box_ExplosionPattern_D0C 
 
-byte gExplosionBaseScales[5] = { // @ G0216_auc_Graphic558_ExplosionBaseScales
+byte g216_ExplosionBaseScales[5] = { // @ G0216_auc_Graphic558_ExplosionBaseScales
 	10,/* D4 */   16,/* D3 */   23,/* D2 */   32,/* D1 */   32};/* D0 */
 
-byte gObjectPileShiftSetIndices[16][2] = { // @ G0217_aauc_Graphic558_ObjectPileShiftSetIndices
+byte g217_ObjectPileShiftSetIndices[16][2] = { // @ G0217_aauc_Graphic558_ObjectPileShiftSetIndices
 	/* { X shift index, Y shift index } */
 	{2, 5},
 	{0, 6},
@@ -1979,7 +1894,7 @@ byte gObjectPileShiftSetIndices[16][2] = { // @ G0217_aauc_Graphic558_ObjectPile
 	{1, 3},
 	{5, 3}}; /* 16 pairs of X and Y shift values */
 
-byte gObjectCoordinateSets[3][10][5][2] = { // @ G0218_aaaauc_Graphic558_ObjectCoordinateSets
+byte g218_ObjectCoordinateSets[3][10][5][2] = { // @ G0218_aaaauc_Graphic558_ObjectCoordinateSets
 	/* { {X, Y }, {X, Y }, {X, Y }, {X, Y }, {X, Y } } */
 	{{{0,   0},{0,   0},{125,  72},{95,  72},{112, 64}},     /* D3C */
 	{{0,   0},{0,   0},{62,  72},{25,  72},{24, 64}},     /* D3L */
@@ -2013,12 +1928,12 @@ byte gObjectCoordinateSets[3][10][5][2] = { // @ G0218_aaaauc_Graphic558_ObjectC
 	{{66, 135},{158, 135},{0,   0},{0,   0},{0,  0}}}}; /* D0C */
 
 
-int16 gShiftSets[3][8] = { // @ G0223_aac_Graphic558_ShiftSets
+int16 g223_ShiftSets[3][8] = { // @ G0223_aac_Graphic558_ShiftSets
 	{0, 1, 2, 3, 0, -3, -2, -1},   /* D0 Back or D1 Front */
 	{0, 1, 1, 2, 0, -2, -1, -1},   /* D1 Back or D2 Front */
 	{0, 1, 1, 1, 0, -1, -1, -1}}; /* D2 Back or D3 Front */
 
-byte gCreatureCoordinateSets[3][11][5][2] = { // @ G0224_aaaauc_Graphic558_CreatureCoordinateSets
+byte g224_CreatureCoordinateSets[3][11][5][2] = { // @ G0224_aaaauc_Graphic558_CreatureCoordinateSets
 	/* { { X, Y }, { X, Y }, { X, Y }, { X, Y }, { X, Y } } */
 	{{{95,  70},{127,  70},{129,  75},{93,  75},{111,  72}},     /* D3C */
 	{{131,  70},{163,  70},{158,  75},{120,  75},{145,  72}},     /* D3L */
@@ -2054,7 +1969,7 @@ byte gCreatureCoordinateSets[3][11][5][2] = { // @ G0224_aaaauc_Graphic558_Creat
 	{{0,   0},{67,  96},{0,   0},{0,   0},{0,   0}},     /* D0L */
 	{{156,  96},{0,   0},{0,   0},{0,   0},{0,   0}}}}; /* D0R */
 
-int16 gExplosionCoordinates[15][2][2] = { // @ G0226_aaai_Graphic558_ExplosionCoordinates
+int16 g226_ExplosionCoordinates[15][2][2] = { // @ G0226_aaai_Graphic558_ExplosionCoordinates
 	/* { { Front Left X, Front Left Y }, { Front Right X, Front Right Y } } */
 	{{100, 47},{122, 47}},   /* D4C */
 	{{52, 47},{76, 47}},   /* D4L */
@@ -2071,7 +1986,7 @@ int16 gExplosionCoordinates[15][2][2] = { // @ G0226_aaai_Graphic558_ExplosionCo
 	{{0,  0},{0,  0}},   /* D0C */
 	{{-73, 60},{-33, 60}},   /* D0L */
 	{{256, 60},{296, 60}}}; /* D0R */
-int16 gRebirthStep2ExplosionCoordinates[7][3] = { // @ G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates
+int16 g227_RebirthStep2ExplosionCoordinates[7][3] = { // @ G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates
 	/* { X, Y, Scale } */
 	{113, 57, 12},   /* D3C */
 	{24, 57, 12},   /* D3L */
@@ -2080,7 +1995,7 @@ int16 gRebirthStep2ExplosionCoordinates[7][3] = { // @ G0227_aai_Graphic558_Rebi
 	{12, 63, 16},   /* D2L */
 	{213, 63, 16},   /* D2R */
 	{112, 76, 24}}; /* D1C */
-int16 gRebirthStep1ExplosionCoordinates[7][3] = { // @ G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates
+int16 g228_RebirthStep1ExplosionCoordinates[7][3] = { // @ G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates
 	/* { X, Y, Scale } */
 	{112, 53, 15},   /* D3C */
 	{24, 53, 15},   /* D3L */
@@ -2090,7 +2005,7 @@ int16 gRebirthStep1ExplosionCoordinates[7][3] = { // @ G0228_aai_Graphic558_Rebi
 	{208, 59, 20},   /* D2R */
 	{112, 70, 32}}; /* D1C */
 
-int16 gCenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_CenteredExplosionCoordinates
+int16 g225_CenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_CenteredExplosionCoordinates
 	/* { X, Y } */
 	{111, 47},   /* D4C */
 	{57, 47},   /* D4L */
@@ -2108,7 +2023,7 @@ int16 gCenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_Centere
 	{-53, 60},   /* D0L */
 	{276, 60}}; /* D0R */
 
-#define kBlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK
+#define k0x0080_BlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK
 
 void DisplayMan::cthulhu(Thing thingParam, direction directionParam, int16 mapXpos,
 						 int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) {
@@ -2278,13 +2193,13 @@ creatures are drawn in the right order and so that Fluxcages are not drawn twice
 			}
 
 			/* Square where objects are visible and object is located on cell being processed */
-			if ((viewSquareIndex >= kViewSquare_D3C) && (viewSquareIndex <= kViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) {
-				objectAspect = &(gObjectAspects[gObjectInfo[dunMan.getObjectInfoIndex(thingParam)]._objectAspectIndex]);
+			if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) {
+				objectAspect = &(g209_ObjectAspects[gObjectInfo[dunMan.getObjectInfoIndex(thingParam)]._objectAspectIndex]);
 				AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex;
 				if (useAlcoveObjectImage = (drawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane)) {
 					AL_4_nativeBitmapIndex++;
 				}
-				coordinateSet = gObjectCoordinateSets[objectAspect->_coordinateSet][viewSquareIndex][AL_2_viewCell];
+				coordinateSet = g218_ObjectCoordinateSets[objectAspect->_coordinateSet][viewSquareIndex][AL_2_viewCell];
 				if (!coordinateSet[1]) /* If object is not visible */
 					continue;
 T0115015_DrawProjectileAsObject:
@@ -2295,7 +2210,7 @@ T0115015_DrawProjectileAsObject:
 				either on the right lane or on the right column of the center lane */
 				paddingPixelCount = 0;
 
-				if ((viewSquareIndex == kViewSquare_D0C) || ((viewSquareIndex >= kViewSquare_D1C) && (AL_2_viewCell >= k2_ViewCellBackRight))) {
+				if ((viewSquareIndex == k9_ViewSquare_D0C) || ((viewSquareIndex >= k6_ViewSquare_D1C) && (AL_2_viewCell >= k2_ViewCellBackRight))) {
 					/* If object is in the center lane (only D0C or D1C with condition above) and is not a projectile */
 					drawingGrabbableObject = (!viewLane && !drawProjectileAsObject);
 					AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
@@ -2310,17 +2225,17 @@ T0115015_DrawProjectileAsObject:
 				} else {
 					drawingGrabbableObject = false;
 					derivedBitmapIndex = k104_DerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex;
-					if ((viewSquareIndex >= kViewSquare_D1C) || ((viewSquareIndex >= kViewSquare_D2C) && (AL_2_viewCell >= k2_ViewCellBackRight))) {
+					if ((viewSquareIndex >= k6_ViewSquare_D1C) || ((viewSquareIndex >= k3_ViewSquare_D2C) && (AL_2_viewCell >= k2_ViewCellBackRight))) {
 						derivedBitmapIndex++;
 						AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front;
 						byteWidth = getScaledDimension(objectAspect->_width, k20_Scale_D2);
 						heightRedEagle = getScaledDimension(objectAspect->_height, k20_Scale_D2);
-						paletteChanges = gPalChangesFloorOrn_D2;
+						paletteChanges = g214_PalChangesFloorOrn_D2;
 					} else {
 						AL_8_shiftSetIndex = k2_ShiftSet_D2BackD3Front;
 						byteWidth = getScaledDimension(objectAspect->_width, k16_Scale_D3);
 						heightRedEagle = getScaledDimension(objectAspect->_height, k16_Scale_D3);
-						paletteChanges = gPalChangesFloorOrn_D3;
+						paletteChanges = g213_PalChangesFloorOrn_D3;
 					}
 					if (flipHorizontal) {
 						derivedBitmapIndex += 2;
@@ -2344,8 +2259,8 @@ T0115015_DrawProjectileAsObject:
 				AL_4_xPos = coordinateSet[0];
 				boxByteGreen._y2 = coordinateSet[1] + 1;
 				if (!drawProjectileAsObject) { /* If drawing an object that is not a projectile */
-					AL_4_xPos += gShiftSets[AL_8_shiftSetIndex][gObjectPileShiftSetIndices[objectShiftIndex][0]];
-					boxByteGreen._y2 += gShiftSets[AL_8_shiftSetIndex][gObjectPileShiftSetIndices[objectShiftIndex][1]];
+					AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][g217_ObjectPileShiftSetIndices[objectShiftIndex][0]];
+					boxByteGreen._y2 += g223_ShiftSets[AL_8_shiftSetIndex][g217_ObjectPileShiftSetIndices[objectShiftIndex][1]];
 					objectShiftIndex++; /* The next object drawn will use the next shift values */
 					if (drawAlcoveObjects) {
 						if (objectShiftIndex >= 14) {
@@ -2392,7 +2307,7 @@ T0115015_DrawProjectileAsObject:
 					AL_6_bitmapRedBanana = bitmapGreenAnt;
 					dunMan._pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */
 				}
-				blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, gDungeonViewport);
+				blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, g296_DungeonViewport);
 
 				if (drawProjectileAsObject)
 					goto T0115171_BackFromT0115015_DrawProjectileAsObject;
@@ -2400,7 +2315,7 @@ T0115015_DrawProjectileAsObject:
 		} while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList);
 		if (AL_2_viewCell == k4_ViewCellAlcove)
 			break; /* End of processing when drawing objects in an alcove */
-		if (viewSquareIndex < kViewSquare_D3C)
+		if (viewSquareIndex < k0_ViewSquare_D3C)
 			break; /* End of processing if square is too far away at D4 */
 				   /* Draw creatures */
 
@@ -2414,7 +2329,7 @@ T0115015_DrawProjectileAsObject:
 			group = (Group*)dunMan.getThingData(groupThing);
 			activeGroup = &_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()];
 			creatureInfo = &gCreatureInfo[group->_type];
-			creatureAspectStruct = &gCreatureAspects[creatureInfo->_creatureAspectIndex];
+			creatureAspectStruct = &g219_CreatureAspects[creatureInfo->_creatureAspectIndex];
 			creatureSize = getFlag(creatureInfo->_attributes, kMaskCreatureInfo_size);
 			creatureGraphicInfoGreen = creatureInfo->_graphicInfo;
 		}
@@ -2478,11 +2393,11 @@ T0115015_DrawProjectileAsObject:
 
 
 		creatureAspectInt = activeGroup->_aspect[creatureIndexGreen];
-		if (viewSquareIndex > kViewSquare_D0C) {
+		if (viewSquareIndex > k9_ViewSquare_D0C) {
 			viewSquareIndex--;
 		}
 T0115077_DrawSecondHalfSquareCreature:
-		coordinateSet = gCreatureCoordinateSets[((CreatureAspect*)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell];
+		coordinateSet = g224_CreatureCoordinateSets[((CreatureAspect*)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell];
 		if (!coordinateSet[1])
 			goto T0115126_CreatureNotVisible;
 		AL_0_creatureGraphicInfoRed = creatureGraphicInfoGreen;
@@ -2541,7 +2456,7 @@ T0115077_DrawSecondHalfSquareCreature:
 				}
 			}
 		}
-		if (viewSquareIndex >= kViewSquare_D1C) { /* Creature is on D1 */
+		if (viewSquareIndex >= k6_ViewSquare_D1C) { /* Creature is on D1 */
 			creaturePaddingPixelCount = 0;
 			AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
 			transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour();
@@ -2578,17 +2493,17 @@ T0115077_DrawSecondHalfSquareCreature:
 			if (useFlippedHorizontallyCreatureFrontImage) {
 				derivedBitmapIndex++; /* Skip front D1 image in additional graphics */
 			}
-			if (viewSquareIndex >= kViewSquare_D2C) { /* Creature is on D2 */
+			if (viewSquareIndex >= k3_ViewSquare_D2C) { /* Creature is on D2 */
 				derivedBitmapIndex++; /* Skip front D3 image in additional graphics */
 				AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front;
 				useCreatureSpecialD2FrontBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0080_CreatureInfoGraphicMaskSpecialD2Front)
 					&& !useCreatureSideBitmap && !useCreatureBackBitmap && !useCreatureAttackBitmap;
-				paletteChanges = gPalChangesCreature_D2;
+				paletteChanges = g222_PalChangesCreature_D2;
 				scale = k20_Scale_D2;
 			} else { /* Creature is on D3 */
 				AL_8_shiftSetIndex = k2_ShiftSet_D2BackD3Front;
 				useCreatureSpecialD2FrontBitmap = false;
-				paletteChanges = gPalChangesCreature_D3;
+				paletteChanges = g221_PalChangesCreature_D3;
 				scale = k16_Scale_D3;
 			}
 			byteWidth = getScaledDimension(sourceByteWidth, scale);
@@ -2621,11 +2536,11 @@ T0115077_DrawSecondHalfSquareCreature:
 			}
 		}
 		AL_4_yPos = coordinateSet[1];
-		AL_4_yPos += gShiftSets[AL_8_shiftSetIndex][getVerticalOffsetM23(creatureAspectInt)];
+		AL_4_yPos += g223_ShiftSets[AL_8_shiftSetIndex][getVerticalOffsetM23(creatureAspectInt)];
 		boxByteGreen._y2 = MIN(AL_4_yPos, (int16)135) + 1;
 		boxByteGreen._y1 = MIN(0, AL_4_yPos - (heightRedEagle - 1));
 		AL_4_xPos = coordinateSet[0];
-		AL_4_xPos += gShiftSets[AL_8_shiftSetIndex][getHorizontalOffsetM22(creatureAspectInt)];
+		AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][getHorizontalOffsetM22(creatureAspectInt)];
 		if (viewLane == k1_ViewLaneLeft) {
 			AL_4_xPos -= 100;
 		} else {
@@ -2643,7 +2558,7 @@ T0115077_DrawSecondHalfSquareCreature:
 			AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1);
 		}
 		warning("SUPER WARNINIG: we might nee noralized with on byteWidth");
-		blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, boxByteGreen, (Color)transparentColor, gDungeonViewport);
+		blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, boxByteGreen, (Color)transparentColor, g296_DungeonViewport);
 
 T0115126_CreatureNotVisible:
 		if (twoHalfSquareCreaturesFrontView) {
@@ -2659,9 +2574,9 @@ T0115126_CreatureNotVisible:
 		/* Draw projectiles */
 T0115129_DrawProjectiles:
 		if (!sqaureHasProjectile
-			|| ((viewSquareIndex = viewSquareIndexBackup) > kViewSquare_D0C)
+			|| ((viewSquareIndex = viewSquareIndexBackup) > k9_ViewSquare_D0C)
 /* If there is no projectile to draw or if projectiles are not visible on the specified square or on the cell being drawn */
-|| (!(projectilePosX = gObjectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0])))
+|| (!(projectilePosX = g218_ObjectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0])))
 continue;
 		thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */
 
@@ -2669,11 +2584,11 @@ continue;
 			if ((thingParam.getType() == kProjectileThingType) && (thingParam.getCell() == cellYellowBear)) {
 				projectile = (Projectile*)dunMan.getThingData(thingParam);
 				if ((AL_4_projectileAspect = dunMan.getProjectileAspect(projectile->_object)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
-					objectAspect = (ObjectAspect*)&gProjectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)];
+					objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)];
 					AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
 					projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
 					if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask))
-						 || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == kViewSquare_D0C)) {
+						 || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == k9_ViewSquare_D0C)) {
 						scale = 0; /* Use native bitmap without resizing */
 						byteWidth = ((ProjectileAspect*)objectAspect)->_width;
 						heightRedEagle = ((ProjectileAspect*)objectAspect)->_height;
@@ -2778,13 +2693,13 @@ the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part
 screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
 						AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - projectilePosX - 1));
 					}
-					blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, gDungeonViewport);
+					blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, g296_DungeonViewport);
 				} else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */
 					useAlcoveObjectImage = false;
 					projectileCoordinates[0] = projectilePosX;
 					projectileCoordinates[1] = 47;
 					coordinateSet = projectileCoordinates;
-					objectAspect = &gObjectAspects[AL_4_projectileAspect];
+					objectAspect = &g209_ObjectAspects[AL_4_projectileAspect];
 					AL_4_nativeBitmapIndex = objectAspect->_firstNativeBitmapRelativeIndex + k360_FirstObjectGraphicIndice;
 					drawProjectileAsObject = true;
 /* Go to code section to draw an object. Once completed, it jumps back to T0115171_BackFromT0115015_DrawProjectileAsObject below */
@@ -2809,8 +2724,8 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 			AL_2_cellPurpleMan = thingParam.getCell();
 			explosion = (Explosion*)dunMan.getThingData(thingParam);
 			if ((rebirthExplosion = ((unsigned int)(AL_4_explosionType = explosion->getType()) >= kExplosionType_RebirthStep1))
-				&& ((AL_1_viewSquareExplosionIndex < kViewSquare_D3C_Explosion)
-					|| (AL_1_viewSquareExplosionIndex > kViewSquare_D1C_Explosion)
+				&& ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion)
+					|| (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion)
 					|| (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */
 				continue;
 			smoke = false;
@@ -2825,21 +2740,21 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 						AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke;
 					} else {
 						if (AL_4_explosionType == kExplosionType_RebirthStep1) {
-							objectAspect = (ObjectAspect*)&gProjectileAspect[_vm->ordinalToIndex(-dunMan.getProjectileAspect(Thing::_explLightningBolt))];
+							objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->ordinalToIndex(-dunMan.getProjectileAspect(Thing::_explLightningBolt))];
 							AL_6_bitmapRedBanana = getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
-							explosionCoordinates = gRebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
+							explosionCoordinates = g228_RebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
 							byteWidth = getScaledDimension((((ProjectileAspect*)objectAspect)->_width), explosionCoordinates[2]);
 							heightRedEagle = getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
-							if (AL_1_viewSquareExplosionIndex != kViewSquare_D1C_Explosion) {
+							if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) {
 								blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana,
 									((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, _g74_tmpBitmap,
-																byteWidth, heightRedEagle, gPalChangesNoChanges);
+																byteWidth, heightRedEagle, g17_PalChangesNoChanges);
 								AL_6_bitmapRedBanana = _g74_tmpBitmap;
 							}
 							goto T0115200_DrawExplosion;
 						}
 						if (AL_4_explosionType == kExplosionType_Fluxcage) {
-							if (AL_1_viewSquareExplosionIndex >= kViewSquare_D3L_Explosion) {
+							if (AL_1_viewSquareExplosionIndex >= k4_ViewSquare_D3L_Explosion) {
 								fluxcageExplosion = explosion;
 							}
 							continue;
@@ -2848,7 +2763,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					}
 				}
 			}
-			if (AL_1_viewSquareExplosionIndex == kViewSquare_D0C_Explosion) {
+			if (AL_1_viewSquareExplosionIndex == k12_ViewSquare_D0C_Explosion) {
 				if (smoke) {
 					AL_4_explosionAspectIndex--; /* Smoke uses the same graphics as Poison Cloud, but with palette changes */
 				}
@@ -2862,30 +2777,30 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 				warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache");
 				AL_6_bitmapRedBanana = getBitmap(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice);
 				if (smoke) {
-					blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _g74_tmpBitmap, 48, 32, gPalChangeSmoke);
+					blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _g74_tmpBitmap, 48, 32, g212_PalChangeSmoke);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
-				blitBoxFilledWithMaskedBitmapToScreen(AL_6_bitmapRedBanana, nullptr, getDerivedBitmap(k0_DerivedBitmapViewport), gBoxExplosionPattern_D0C,
+				blitBoxFilledWithMaskedBitmapToScreen(AL_6_bitmapRedBanana, nullptr, getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C,
 													  _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64),
-													  224, (Color)(kBlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
+													  224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
 				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 			} else {
 				if (rebirthExplosion) {
-					explosionCoordinates = gRebirthStep2ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
+					explosionCoordinates = g227_RebirthStep2ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
 					explosionScale = explosionCoordinates[2];
 				} else {
 					if (explosion->getCentered()) {
-						explosionCoordinates = gCenteredExplosionCoordinates[AL_1_viewSquareExplosionIndex];
+						explosionCoordinates = g225_CenteredExplosionCoordinates[AL_1_viewSquareExplosionIndex];
 					} else {
 						if ((AL_2_cellPurpleMan == directionParam) || (AL_2_cellPurpleMan == returnPrevVal(directionParam))) {
 							AL_2_viewCell = k0_ViewCellFronLeft;
 						} else {
 							AL_2_viewCell = k1_ViewCellFrontRight;
 						}
-						explosionCoordinates = gExplosionCoordinates[AL_1_viewSquareExplosionIndex][AL_2_viewCell];
+						explosionCoordinates = g226_ExplosionCoordinates[AL_1_viewSquareExplosionIndex][AL_2_viewCell];
 					}
-					explosionScale = MAX(4, (MAX(48, explosion->getAttack() + 1) * gExplosionBaseScales[explosionScaleIndex]) >> 8) & (int16)0xFFFE;
+					explosionScale = MAX(4, (MAX(48, explosion->getAttack() + 1) * g216_ExplosionBaseScales[explosionScaleIndex]) >> 8) & (int16)0xFFFE;
 				}
 				AL_6_bitmapRedBanana = getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle);
 T0115200_DrawExplosion:
@@ -2930,16 +2845,16 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP
 				if (flipVertical) {
 					flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 				}
-				blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, gDungeonViewport);
+				blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, g296_DungeonViewport);
 			}
 		}
 	} while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList);
 /* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */
 	if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_g77_doNotDrawFluxcagesDuringEndgame) {
 		AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */
-		fieldAspect = gFieldAspects[viewSquareIndex];
+		fieldAspect = g188_FieldAspects[viewSquareIndex];
 		(fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */
-		drawField(&fieldAspect, *(Box*)&gFrameWalls[viewSquareIndex]);
+		drawField(&fieldAspect, *(Box*)&g163_FrameWalls[viewSquareIndex]);
 	}
 }
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index ca478b3..80902e4 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -399,7 +399,7 @@ public:
 }; // @ CREATURE_REPLACEMENT_COLOR_SET
 
 extern Viewport gDefultViewPort;
-extern Viewport gDungeonViewport;
+extern Viewport g296_DungeonViewport;
 
 
 #define k0_DoorButton 0 // @ C0_DOOR_BUTTON
@@ -523,7 +523,7 @@ public:
 									   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDefultViewPort); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
 	void blitBoxFilledWithMaskedBitmapToScreen(byte *src, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
 											   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
-											   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
+											   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = g296_DungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
 
 	void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height);
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index d738234..11ccd94 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -96,9 +96,9 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	champion = &cm._champions[championIndex];
 	int16 w = dm.getWidth(k17_InventoryGraphicIndice);
 	int16 h = dm.getHeight(k17_InventoryGraphicIndice);
-	dm.blitToScreen(dm.getBitmap(k17_InventoryGraphicIndice), w, 0, 0, 0, w, 0, h, k255_ColorNoTransparency, gDungeonViewport);
+	dm.blitToScreen(dm.getBitmap(k17_InventoryGraphicIndice), w, 0, 0, 0, w, 0, h, k255_ColorNoTransparency, g296_DungeonViewport);
 	if (cm._candidateChampionOrdinal) {
-		dm.clearScreenBox(k12_ColorDarkestGray, gBoxFloppyZzzCross, gDungeonViewport);
+		dm.clearScreenBox(k12_ColorDarkestGray, gBoxFloppyZzzCross, g296_DungeonViewport);
 	}
 	_vm->_textMan->printToViewport(5, 116, k13_ColorLightestGray, "HEALTH");
 	_vm->_textMan->printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
@@ -175,7 +175,7 @@ void InventoryMan::drawPanelFoodWaterPoisoned() {
 
 void InventoryMan::drawPanelResurrectReincarnate() {
 	_panelContent = kPanelContentResurrectReincarnate;
-	_vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, gBoxPanel, k6_ColorDarkGreen, gDungeonViewport);
+	_vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, gBoxPanel, k6_ColorDarkGreen, g296_DungeonViewport);
 }
 
 void InventoryMan::drawPanel() {
@@ -258,7 +258,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) {
 		charRed++;
 	}
 	*charRed = '\0';
-	dispMan.blitToScreen(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, gDungeonViewport);
+	dispMan.blitToScreen(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, g296_DungeonViewport);
 	int16 lineCount = 1;
 	charRed++;
 	char *charGreen = charRed; // first char of the second line
@@ -336,7 +336,7 @@ void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yP
 	box._x2 = (box._x1 = xPos) + 15 + 1;
 	box._y2 = (box._y1 = yPos) + 15 + 1;
 	_vm->_objectMan->extractIconFromBitmap(iconIndex, iconBitmap);
-	_vm->_displayMan->blitToScreen(iconBitmap, 16, 0, 0, box, k255_ColorNoTransparency, gDungeonViewport);
+	_vm->_displayMan->blitToScreen(iconBitmap, 16, 0, 0, box, k255_ColorNoTransparency, g296_DungeonViewport);
 }
 
 void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) {
@@ -411,7 +411,7 @@ Box gBoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye
 void InventoryMan::drawPanelArrowOrEye(bool pressingEye) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 	dispMan.blitToScreen(dispMan.getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice),
-						 16, 0, 0, gBoxArrowOrEye, k8_ColorRed, gDungeonViewport);
+						 16, 0, 0, gBoxArrowOrEye, k8_ColorRed, g296_DungeonViewport);
 }
 
 
@@ -443,8 +443,8 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye);
 	} else {
 		IconIndice iconIndex = objMan.getIconIndex(thingToDraw);
-		dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, gDungeonViewport);
-		dispMan.blitToScreen(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, gBoxObjectDescCircle, k12_ColorDarkestGray, gDungeonViewport);
+		dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, g296_DungeonViewport);
+		dispMan.blitToScreen(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, gBoxObjectDescCircle, k12_ColorDarkestGray, g296_DungeonViewport);
 
 		char *descString = nullptr;
 		char str[40];
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index ddb002d..dd35502 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -224,7 +224,7 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	if (slotBoxIndex >= kSlotBoxInventoryFirstSlot) {
 		_vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
-									   box, k255_ColorNoTransparency, gDungeonViewport);
+									   box, k255_ColorNoTransparency, g296_DungeonViewport);
 	} else {
 		_vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
 									   box, k255_ColorNoTransparency, gDefultViewPort);
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index d535194..8f4e04c 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -70,7 +70,7 @@ void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Col
 }
 
 void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) {
-	printTextToScreen(posX, posY, textColor, bgColor, text, gDungeonViewport);
+	printTextToScreen(posX, posY, textColor, bgColor, text, g296_DungeonViewport);
 }
 
 void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor,


Commit: 71e4b5b2bca49f0de8b07f4f85de9167dd9b5f99
    https://github.com/scummvm/scummvm/commit/71e4b5b2bca49f0de8b07f4f85de9167dd9b5f99
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Renaming in champion.c/h

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/menus.h
    engines/dm/movesens.cpp
    engines/dm/objectman.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 5f1b68c..9302216 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -38,14 +38,14 @@ namespace DM {
 
 Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
 Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
-Box gBoxChampionIcons[4] = {
+Box g54_BoxChampionIcons[4] = {
 	Box(281, 299,  0, 13),
 	Box(301, 319,  0, 13),
 	Box(301, 319, 15, 28),
 	Box(281, 299, 15, 28)};
-Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14};
+Color g46_ChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14};
 
-int16 gLightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100};
+int16 g39_LightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100};
 
 uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
 	/* 30 for champion inventory, 8 for chest */
@@ -91,13 +91,13 @@ uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
 Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
 
 ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
-	_leaderIndex = kChampionNone;
+	_g411_leaderIndex = kM1_ChampionNone;
 
-	_partyDead = false;
-	_partyIsSleeping = false;
-	_leaderHandObjectIconIndex = kIconIndiceNone;
-	_leaderEmptyHanded = true;
-	_magicCasterChampionIndex = kChampionNone;
+	_303_partyDead = false;
+	_g300_partyIsSleeping = false;
+	_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
+	_g415_leaderEmptyHanded = true;
+	_g514_magicCasterChampionIndex = kM1_ChampionNone;
 }
 
 uint16 ChampionMan::getChampionPortraitX(uint16 index) {
@@ -143,13 +143,13 @@ void ChampionMan::applyModifiersToStatistics(Champion* champ, ChampionSlot slotI
 	int16 modifier = 0;
 	ThingType thingType = thing.getType();
 	if (((thingType == kWeaponThingType) || (thingType == kArmourThingType))
-		&& (slotIndex >= kChampionSlotReadyHand)
-		&& (slotIndex <= kChampionSlotQuiverLine_1_1)) {
+		&& (slotIndex >= k0_ChampionSlotReadyHand)
+		&& (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) {
 		Weapon *weapon = (Weapon*)_vm->_dungeonMan->getThingData(thing);
 		Armour *armour = (Armour*)_vm->_dungeonMan->getThingData(thing);
 		if (((thingType == kWeaponThingType) && weapon->getCursed())
 			|| ((thingType == kArmourThingType) && armour->getCursed())) {
-			statIndex = kChampionStatLuck;
+			statIndex = k0_ChampionStatLuck;
 			modifier = -3;
 			goto T0299044_ApplyModifier;
 		}
@@ -157,58 +157,58 @@ void ChampionMan::applyModifiersToStatistics(Champion* champ, ChampionSlot slotI
 
 	statIndex = (ChampionStatisticType)thingType; // variable sharing
 
-	if ((iconIndex == kIconIndiceJunkRabbitsFoot) && (slotIndex < kChampionSlotChest_1)) {
-		statIndex = kChampionStatLuck;
+	if ((iconIndex == k137_IconIndiceJunkRabbitsFoot) && (slotIndex < k30_ChampionSlotChest_1)) {
+		statIndex = k0_ChampionStatLuck;
 		modifier = 10;
-	} else if (slotIndex == kChampionSlotActionHand) {
+	} else if (slotIndex == k1_ChampionSlotActionHand) {
 
-		if (iconIndex == kIconIndiceWeaponMaceOfOrder) {
-			statIndex = kChampionStatStrength;
+		if (iconIndex == k45_IconIndiceWeaponMaceOfOrder) {
+			statIndex = k1_ChampionStatStrength;
 			modifier = 5;
 		} else {
 
-			statIndex = kChampionStatMana;
-			if ((iconIndex >= kIconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= kIconIndiceWeaponStaffOfClawsFull)) {
+			statIndex = k8_ChampionStatMana;
+			if ((iconIndex >= k20_IconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= k22_IconIndiceWeaponStaffOfClawsFull)) {
 				modifier = 4;
-			} else if ((iconIndex >= kIconIndiceWeaponStaff) && (iconIndex <= kIconIndiceWeaponSceptreOfLyf)) {
+			} else if ((iconIndex >= k58_IconIndiceWeaponStaff) && (iconIndex <= k66_IconIndiceWeaponSceptreOfLyf)) {
 				switch (iconIndex) {
-				case kIconIndiceWeaponStaff:
+				case k58_IconIndiceWeaponStaff:
 					modifier = 2;
 					break;
-				case kIconIndiceWeaponWand:
+				case k59_IconIndiceWeaponWand:
 					modifier = 1;
 					break;
-				case kIconIndiceWeaponTeowand:
+				case k60_IconIndiceWeaponTeowand:
 					modifier = 6;
 					break;
-				case kIconIndiceWeaponYewStaff:
+				case k61_IconIndiceWeaponYewStaff:
 					modifier = 4;
 					break;
-				case kIconIndiceWeaponStaffOfManarStaffOfIrra:
+				case k62_IconIndiceWeaponStaffOfManarStaffOfIrra:
 					modifier = 10;
 					break;
-				case kIconIndiceWeaponSnakeStaffCrossOfNeta:
+				case k63_IconIndiceWeaponSnakeStaffCrossOfNeta:
 					modifier = 8;
 					break;
-				case kIconIndiceWeaponTheConduitSerpentStaff:
+				case k64_IconIndiceWeaponTheConduitSerpentStaff:
 					modifier = 16;
 					break;
-				case kIconIndiceWeaponDragonSpit:
+				case k65_IconIndiceWeaponDragonSpit:
 					modifier = 7;
 					break;
-				case kIconIndiceWeaponSceptreOfLyf:
+				case k66_IconIndiceWeaponSceptreOfLyf:
 					modifier = 5;
 					break;
 				}
 			} else {
 				switch (iconIndex) {
-				case kIconIndiceWeaponDeltaSideSplitter:
+				case k38_IconIndiceWeaponDeltaSideSplitter:
 					modifier = 1;
 					break;
-				case kIconIndiceWeaponTheInquisitorDragonFang:
+				case k41_IconIndiceWeaponTheInquisitorDragonFang:
 					modifier = 2;
 					break;
-				case kIconIndiceWeaponVorpalBlade:
+				case k40_IconIndiceWeaponVorpalBlade:
 					modifier = 4;
 					break;
 				}
@@ -216,43 +216,43 @@ void ChampionMan::applyModifiersToStatistics(Champion* champ, ChampionSlot slotI
 
 		}
 
-	} else if (slotIndex == kChampionSlotLegs) {
+	} else if (slotIndex == k4_ChampionSlotLegs) {
 
-		if (iconIndex == kIconIndiceArmourPowertowers) {
-			statIndex = kChampionStatStrength;
+		if (iconIndex == k142_IconIndiceArmourPowertowers) {
+			statIndex = k1_ChampionStatStrength;
 			modifier = 10;
 		}
 
-	} else if (slotIndex == kChampionSlotHead) {
+	} else if (slotIndex == k2_ChampionSlotHead) {
 
-		if (iconIndex == kIconIndiceArmourCrownOfNerra) {
-			statIndex = kChampionStatWisdom;
+		if (iconIndex == k104_IconIndiceArmourCrownOfNerra) {
+			statIndex = k3_ChampionStatWisdom;
 			modifier = 10;
-		} else if (iconIndex == kIconIndiceArmourDexhelm) {
-			statIndex = kChampionStatDexterity;
+		} else if (iconIndex == k140_IconIndiceArmourDexhelm) {
+			statIndex = k2_ChampionStatDexterity;
 			modifier = 10;
 		}
 
-	} else if (slotIndex == kChampionSlotTorso) {
+	} else if (slotIndex == k3_ChampionSlotTorso) {
 
-		if (iconIndex == kIconIndiceArmourFlamebain) {
-			statIndex = kChampionStatAntifire;
+		if (iconIndex == k141_IconIndiceArmourFlamebain) {
+			statIndex = k6_ChampionStatAntifire;
 			modifier = 12;
-		} else if (iconIndex == kIconIndiceArmourCloakOfNight) {
-			statIndex = kChampionStatDexterity;
+		} else if (iconIndex == k81_IconIndiceArmourCloakOfNight) {
+			statIndex = k2_ChampionStatDexterity;
 			modifier = 8;
 		}
 
-	} else if (slotIndex == kChampionSlotNeck) {
+	} else if (slotIndex == k10_ChampionSlotNeck) {
 
-		if ((iconIndex >= kIconIndiceJunkJewelSymalUnequipped) && (iconIndex <= kIconIndiceJunkJewelSymalEquipped)) {
-			statIndex = kChampionStatAntimagic;
+		if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
+			statIndex = k5_ChampionStatAntimagic;
 			modifier = 15;
-		} else if (iconIndex == kIconIndiceArmourCloakOfNight) {
-			statIndex = kChampionStatDexterity;
+		} else if (iconIndex == k81_IconIndiceArmourCloakOfNight) {
+			statIndex = k2_ChampionStatDexterity;
 			modifier = 8;
-		} else if (iconIndex == kIconIndiceJunkMoonstone) {
-			statIndex = kChampionStatMana;
+		} else if (iconIndex == k122_IconIndiceJunkMoonstone) {
+			statIndex = k8_ChampionStatMana;
 			modifier = 3;
 		}
 
@@ -261,10 +261,10 @@ void ChampionMan::applyModifiersToStatistics(Champion* champ, ChampionSlot slotI
 T0299044_ApplyModifier:
 	if (modifier) {
 		modifier *= modifierFactor;
-		if (statIndex == kChampionStatMana) {
+		if (statIndex == k8_ChampionStatMana) {
 			champ->_maxMana += modifier;
-		} else if (statIndex < kChampionStatAntifire + 1) {
-			for (uint16 statValIndex = kChampionStatMaximum; statValIndex <= kChampionStatMinimum; ++statValIndex) {
+		} else if (statIndex < k6_ChampionStatAntifire + 1) {
+			for (uint16 statValIndex = k0_ChampionStatMaximum; statValIndex <= k2_ChampionStatMinimum; ++statValIndex) {
 				champ->getStatistic((ChampionStatisticType)statIndex, (ChampionStatisticValue)statValIndex) += modifier;
 				warning("BUG0_38");
 			}
@@ -277,13 +277,13 @@ bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing)
 	ObjectMan &objMan = *_vm->_objectMan;
 
 	IconIndice currIconIndex = objMan.getIconIndexInSlotBox(slotBoxIndex);
-	if (((currIconIndex < kIconIndiceWeaponDagger) && (currIconIndex >= kIconIndiceJunkCompassNorth))
-		|| ((currIconIndex >= kIconIndicePotionMaPotionMonPotion) && (currIconIndex <= kIconIndicePotionWaterFlask))
-		|| (currIconIndex == kIconIndicePotionEmptyFlask)) {
+	if (((currIconIndex < k32_IconIndiceWeaponDagger) && (currIconIndex >= k0_IconIndiceJunkCompassNorth))
+		|| ((currIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (currIconIndex <= k163_IconIndicePotionWaterFlask))
+		|| (currIconIndex == k195_IconIndicePotionEmptyFlask)) {
 		IconIndice newIconIndex = objMan.getIconIndex(thing);
 		if (newIconIndex != currIconIndex) {
-			if ((slotBoxIndex < kSlotBoxInventoryFirstSlot) && !_mousePointerHiddenToDrawChangedObjIconOnScreen) {
-				_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
+			if ((slotBoxIndex < kSlotBoxInventoryFirstSlot) && !_g420_mousePointerHiddenToDrawChangedObjIconOnScreen) {
+				_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
 				warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 			}
 			objMan.drawIconInSlotBox(slotBoxIndex, newIconIndex);
@@ -300,33 +300,33 @@ void ChampionMan::drawChangedObjectIcons() {
 	MenuMan &menuMan = *_vm->_menuMan;
 
 	uint16 invChampOrdinal = invMan._inventoryChampionOrdinal;
-	if (_candidateChampionOrdinal && !invChampOrdinal)
+	if (_g299_candidateChampionOrdinal && !invChampOrdinal)
 		return;
 
-	_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
-	IconIndice leaderHandObjIconIndex = _leaderHandObjectIconIndex;
+	_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
+	IconIndice leaderHandObjIconIndex = _g413_leaderHandObjectIconIndex;
 
-	if (((leaderHandObjIconIndex < kIconIndiceWeaponDagger) && (leaderHandObjIconIndex >= kIconIndiceJunkCompassNorth))	// < instead of <= is correct
-		|| ((leaderHandObjIconIndex >= kIconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= kIconIndicePotionWaterFlask))
-		|| (leaderHandObjIconIndex == kIconIndicePotionEmptyFlask)) {
-		IconIndice iconIndex = objMan.getIconIndex(_leaderHandObject);
+	if (((leaderHandObjIconIndex < k32_IconIndiceWeaponDagger) && (leaderHandObjIconIndex >= k0_IconIndiceJunkCompassNorth))	// < instead of <= is correct
+		|| ((leaderHandObjIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= k163_IconIndicePotionWaterFlask))
+		|| (leaderHandObjIconIndex == k195_IconIndicePotionEmptyFlask)) {
+		IconIndice iconIndex = objMan.getIconIndex(_414_leaderHandObject);
 		if (iconIndex != leaderHandObjIconIndex) {
-			_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
+			_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
 			warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 			objMan.extractIconFromBitmap(iconIndex, objMan._objectIconForMousePointer);
 			warning("MISSING CODE: F0068_MOUSE_SetPointerToObject");
-			_leaderHandObjectIconIndex = iconIndex;
-			objMan.drawLeaderObjectName(_leaderHandObject);
+			_g413_leaderHandObjectIconIndex = iconIndex;
+			objMan.drawLeaderObjectName(_414_leaderHandObject);
 		}
 	}
 
-	for (uint16 slotBoxIndex = 0; slotBoxIndex < (_partyChampionCount * 2); ++slotBoxIndex) {
+	for (uint16 slotBoxIndex = 0; slotBoxIndex < (_g305_partyChampionCount * 2); ++slotBoxIndex) {
 		int16 champIndex = slotBoxIndex >> 1;
 		if (invChampOrdinal == _vm->indexToOrdinal(champIndex))
 			continue;
 
 		if (hasObjectIconInSlotBoxChanged(slotBoxIndex, _champions[champIndex].getSlot((ChampionSlot)handSlotIndex(slotBoxIndex)))
-			&& (handSlotIndex(slotBoxIndex) == kChampionSlotActionHand)) {
+			&& (handSlotIndex(slotBoxIndex) == k1_ChampionSlotActionHand)) {
 
 			menuMan.drawActionIcon((ChampionIndex)champIndex);
 		}
@@ -334,13 +334,13 @@ void ChampionMan::drawChangedObjectIcons() {
 
 	if (invChampOrdinal) {
 		Champion *champ = &_champions[_vm->ordinalToIndex(invChampOrdinal)];
-		Thing *thing = &champ->getSlot(kChampionSlotReadyHand);
+		Thing *thing = &champ->getSlot(k0_ChampionSlotReadyHand);
 		uint16 drawViewport = 0;
 
-		for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++, thing++) {
+		for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++, thing++) {
 			uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + kSlotBoxInventoryFirstSlot, *thing) ? 1 : 0;
 			drawViewport |= objIconChanged;
-			if (objIconChanged && (slotIndex == kChampionSlotActionHand)) {
+			if (objIconChanged && (slotIndex == k1_ChampionSlotActionHand)) {
 				menuMan.drawActionIcon((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
 			}
 		}
@@ -353,12 +353,12 @@ void ChampionMan::drawChangedObjectIcons() {
 		}
 
 		if (drawViewport) {
-			champ->setAttributeFlag(kChampionAttributeViewport, true);
+			champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
 			drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
 		}
 	}
 
-	if (_mousePointerHiddenToDrawChangedObjIconOnScreen)
+	if (_g420_mousePointerHiddenToDrawChangedObjIconOnScreen)
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 
@@ -373,49 +373,49 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 
 	Champion *champ = &_champions[champIndex];
 
-	if (slotIndex >= kChampionSlotChest_1) {
-		invMan._chestSlots[slotIndex - kChampionSlotChest_1] = thing;
+	if (slotIndex >= k30_ChampionSlotChest_1) {
+		invMan._chestSlots[slotIndex - k30_ChampionSlotChest_1] = thing;
 	} else {
 		champ->setSlot(slotIndex, thing);
 	}
 
 	champ->_load += dunMan.getObjectWeight(thing);
-	champ->setAttributeFlag(kChampionAttributeLoad, true);
+	champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
 	IconIndice iconIndex = objMan.getIconIndex(thing);
 	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
 	applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
 	uint16 *rawObjPtr = dunMan.getThingData(thing);
 
-	if (slotIndex < kChampionSlotHead) {
+	if (slotIndex < k2_ChampionSlotHead) {
 
-		if (slotIndex == kChampionSlotActionHand) {
-			champ->setAttributeFlag(kChampionAttributeActionHand, true);
-			if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
+		if (slotIndex == k1_ChampionSlotActionHand) {
+			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
+			if (_g506_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
 				menuMan.clearActingChampion();
 
-			if ((iconIndex >= kIconIndiceScrollOpen) && (iconIndex <= kIconIndiceScrollClosed)) {
+			if ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)) {
 				((Scroll*)rawObjPtr)->setClosed(false);
 				drawChangedObjectIcons();
 			}
 		}
 
-		if (iconIndex = kIconIndiceWeaponTorchUnlit) {
+		if (iconIndex = k4_IconIndiceWeaponTorchUnlit) {
 			((Weapon*)rawObjPtr)->setLit(true);
 			warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette");
 			drawChangedObjectIcons();
-		} else if (isInventoryChampion && (slotIndex == kChampionSlotActionHand) &&
-			((iconIndex == kIconIndiceContainerChestClosed) || ((iconIndex >= kIconIndiceScrollOpen) && (iconIndex <= kIconIndiceScrollClosed)))) {
-			champ->setAttributeFlag(kChampionAttributePanel, true);
+		} else if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand) &&
+			((iconIndex == k144_IconIndiceContainerChestClosed) || ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)))) {
+			champ->setAttributeFlag(k0x0800_ChampionAttributePanel, true);
 		}
 
-	} else if (slotIndex == kChampionSlotNeck) {
+	} else if (slotIndex == k10_ChampionSlotNeck) {
 
-		if ((iconIndex >= kIconIndiceJunkIllumuletUnequipped) && (iconIndex <= kIconIndiceJunkIllumuletEquipped)) {
+		if ((iconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (iconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
 			((Junk*)rawObjPtr)->setChargeCount(1);
-			_party._magicalLightAmount += gLightPowerToLightAmount[2];
+			_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2];
 			warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette");
 			iconIndex = (IconIndice) (iconIndex + 1);
-		} else if ((iconIndex >= kIconIndiceJunkJewelSymalUnequipped) && (iconIndex <= kIconIndiceJunkJewelSymalEquipped)) {
+		} else if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
 			((Junk*)rawObjPtr)->setChargeCount(1);
 			iconIndex = (IconIndice) (iconIndex + 1);
 		}
@@ -424,16 +424,16 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 
 	drawSlot(champIndex, slotIndex);
 	if (isInventoryChampion)
-		champ->setAttributeFlag(kChampionAttributeViewport, true);
+		champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
 }
 
 ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
-	for (uint16 i = 0; i < _partyChampionCount; ++i) {
+	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
 		if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
 			return (ChampionIndex)i;
 	}
 
-	return kChampionNone;
+	return kM1_ChampionNone;
 }
 
 void ChampionMan::resetDataToStartGame() {
@@ -442,9 +442,9 @@ void ChampionMan::resetDataToStartGame() {
 		assert(false);
 	}
 
-	_leaderHandObject = Thing::_none;
-	_leaderHandObjectIconIndex = kIconIndiceNone;
-	_leaderEmptyHanded = true;
+	_414_leaderHandObject = Thing::_none;
+	_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
+	_g415_leaderEmptyHanded = true;
 }
 
 
@@ -452,10 +452,10 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 
-	if (!_leaderEmptyHanded || _partyChampionCount == 4)
+	if (!_g415_leaderEmptyHanded || _g305_partyChampionCount == 4)
 		return;
 
-	uint16 prevChampCount = _partyChampionCount;
+	uint16 prevChampCount = _g305_partyChampionCount;
 	Champion *champ = &_champions[prevChampCount];
 	champ->resetToZero();
 	dispMan._g578_useByteBoxCoordinates = true;
@@ -465,20 +465,20 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 							 champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, k255_ColorNoTransparency);
 	}
 
-	champ->_actionIndex = kChampionActionNone;
+	champ->_actionIndex = k255_ChampionActionNone;
 	champ->_enableActionEventIndex = -1;
 	champ->_hideDamageReceivedIndex = -1;
 	champ->_dir = dunMan._currMap._partyDir;
 	ViewCell AL_0_viewCell = k0_ViewCellFronLeft;
-	while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone)
+	while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kM1_ChampionNone)
 		AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
 	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3);
-	champ->clearAttributes(kChampionAttributeIcon);
+	champ->clearAttributes(k0x0400_ChampionAttributeIcon);
 	champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir;
 	champ->_food = 1500 + _vm->_rnd->getRandomNumber(256);
 	champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
 	int16 AL_0_slotIndex_Red;
-	for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) {
+	for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) {
 		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none);
 	}
 	Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY);
@@ -508,7 +508,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	}
 	champ->_title[AL_0_characterIndex] = '\0';
 	if (*character_Green++ == 'M') {
-		champ->setAttributeFlag(kChampionAttributeMale, true);
+		champ->setAttributeFlag(k0x0010_ChampionAttributeMale, true);
 	}
 	character_Green++;
 	champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4);
@@ -520,26 +520,26 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	character_Green++;
 
 	int16 AL_0_statisticIndex;
-	for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) {
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30);
+	for (AL_0_statisticIndex = k0_ChampionStatLuck; AL_0_statisticIndex <= k6_ChampionStatAntifire; ++AL_0_statisticIndex) {
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k2_ChampionStatMinimum, 30);
 		uint16 currMaxVal = getDecodedValue(character_Green, 2);
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal);
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal);
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent, currMaxVal);
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k0_ChampionStatMaximum, currMaxVal);
 		character_Green += 2;
 	}
 
-	champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10);
+	champ->setStatistic(k0_ChampionStatLuck, k2_ChampionStatMinimum, 10);
 	character_Green++;
 
 	int16 AL_0_skillIndex;
 	int16 AL_2_skillValue;
-	for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) {
+	for (AL_0_skillIndex = k4_ChampionSkillSwing; AL_0_skillIndex <= k19_ChampionSkillWater; AL_0_skillIndex++) {
 		if ((AL_2_skillValue = *character_Green++ - 'A') > 0) {
 			champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue);
 		}
 	}
 
-	for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) {
+	for (AL_0_skillIndex = k0_ChampionSkillFighter; AL_0_skillIndex <= k3_ChampionSkillWizard; ++AL_0_skillIndex) {
 		int32 baseSkillExp = 0;
 		int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2;
 		for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) {
@@ -548,13 +548,13 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 		champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp);
 	}
 
-	_candidateChampionOrdinal = prevChampCount + 1;
-	if (++_partyChampionCount == 1) {
-		_vm->_eventMan->commandSetLeader(kChampionFirst);
+	_g299_candidateChampionOrdinal = prevChampCount + 1;
+	if (++_g305_partyChampionCount == 1) {
+		_vm->_eventMan->commandSetLeader(k0_ChampionFirst);
 		_vm->_menuMan->_refreshActionArea = true;
 	} else {
 		_vm->_menuMan->clearActingChampion();
-		_vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1));
+		_vm->_menuMan->drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1));
 	}
 
 	int16 mapX = _vm->_dungeonMan->_currMap._partyPosX;
@@ -564,7 +564,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	mapX += _vm->_dirIntoStepCountEast[dunMan._currMap._partyDir];
 	mapY += _vm->_dirIntoStepCountNorth[dunMan._currMap._partyDir];
 	thing = dunMan.getSquareFirstThing(mapX, mapY);
-	AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
+	AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1;
 	uint16 slotIndex_Green;
 	while (thing != Thing::_endOfList) {
 		ThingType AL_2_thingType = thing.getType();
@@ -572,29 +572,29 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 			int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots();
 			switch (AL_2_thingType) {
 			case kArmourThingType:
-				for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) {
+				for (slotIndex_Green = k2_ChampionSlotHead; slotIndex_Green <= k5_ChampionSlotFeet; slotIndex_Green++) {
 					if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
 						goto T0280048;
 				}
-				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_none)) {
-					slotIndex_Green = kChampionSlotNeck;
+				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) {
+					slotIndex_Green = k10_ChampionSlotNeck;
 				} else {
 					goto T0280046;
 				}
 				break;
 			case kWeaponThingType:
-				if (champ->getSlot(kChampionSlotActionHand) == Thing::_none) {
-					slotIndex_Green = kChampionSlotActionHand;
+				if (champ->getSlot(k1_ChampionSlotActionHand) == Thing::_none) {
+					slotIndex_Green = k1_ChampionSlotActionHand;
 				} else {
 					goto T0280046;
 				}
 				break;
 			case kScrollThingType:
 			case kPotionThingType:
-				if (champ->getSlot(kChampionSlotPouch_1) == Thing::_none) {
-					slotIndex_Green = kChampionSlotPouch_1;
-				} else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_none) {
-					slotIndex_Green = kChampionSlotPouch_2;
+				if (champ->getSlot(k11_ChampionSlotPouch_1) == Thing::_none) {
+					slotIndex_Green = k11_ChampionSlotPouch_1;
+				} else if (champ->getSlot(k6_ChampionSlotPouch_2) == Thing::_none) {
+					slotIndex_Green = k6_ChampionSlotPouch_2;
 				} else {
 					goto T0280046;
 				}
@@ -602,8 +602,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 			case kContainerThingType:
 			case kJunkThingType:
 T0280046:
-				if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_none)) {
-					slotIndex_Green = kChampionSlotNeck;
+				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) {
+					slotIndex_Green = k10_ChampionSlotNeck;
 				} else {
 					slotIndex_Green = AL_0_slotIndex_Red++;
 				}
@@ -676,12 +676,12 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
 		if (barGraphHeight < 25) {
 			box._y1 = 2;
 			box._y1 = 27 - barGraphHeight + 1;
-			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
+			_vm->_displayMan->clearScreenBox(g46_ChampionColor[champIndex], box);
 		}
 		if (barGraphHeight) {
 			box._y1 = 27 - barGraphHeight;
 			box._y2 = 26 + 1;
-			_vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box);
+			_vm->_displayMan->clearScreenBox(g46_ChampionColor[champIndex], box);
 		}
 		box._x1 += 7;
 		box._x2 += 7;
@@ -702,13 +702,13 @@ uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) {
 }
 
 uint16 ChampionMan::getMaximumLoad(Champion *champ) {
-	uint16 maximumLoad = champ->getStatistic(kChampionStatStrength, kChampionStatCurrent) * 8 + 100;
+	uint16 maximumLoad = champ->getStatistic(k1_ChampionStatStrength, k1_ChampionStatCurrent) * 8 + 100;
 	maximumLoad = getStaminaAdjustedValue(champ, maximumLoad);
 	int16 wounds = champ->getWounds();
 	if (wounds) {
-		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kChampionWoundLegs) ? 2 : 3);
+		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(k0x0010_ChampionWoundLegs) ? 2 : 3);
 	}
-	if (_vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotFeet)) == kIconIndiceArmourElvenBoots) {
+	if (_vm->_objectMan->getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == k119_IconIndiceArmourElvenBoots) {
 		maximumLoad += maximumLoad * 16;
 	}
 	maximumLoad += 9;
@@ -726,14 +726,14 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	int16 champStatusBoxX = champIndex * kChampionStatusBoxSpacing;
 	Champion *champ = &_champions[champIndex];
 	uint16 champAttributes = champ->getAttributes();
-	if (!((champAttributes) & (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon |
-							   kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport |
-							   kChampionAttributeActionHand))) {
+	if (!((champAttributes) & (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon |
+							   k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport |
+							   k0x8000_ChampionAttributeActionHand))) {
 		return;
 	}
 	bool isInventoryChamp = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
 	dispMan._g578_useByteBoxCoordinates = false;
-	if (champAttributes & kChampionAttributeStatusBox) {
+	if (champAttributes & k0x1000_ChampionAttributeStatusBox) {
 		box._y1 = 0;
 		box._y2 = 28 + 1;
 		box._x1 = champStatusBoxX;
@@ -744,20 +744,20 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			for (int16 i = 0; i < 3; ++i)
 				nativeBitmapIndices[i] = 0;
 			int16 AL_0_borderCount = 0;
-			if (_party._fireShieldDefense > 0)
+			if (_g407_party._fireShieldDefense > 0)
 				nativeBitmapIndices[AL_0_borderCount++] = k38_BorderPartyFireshieldIndice;
-			if (_party._spellShieldDefense > 0)
+			if (_g407_party._spellShieldDefense > 0)
 				nativeBitmapIndices[AL_0_borderCount++] = k39_BorderPartySpellshieldIndice;
-			if (_party._shieldDefense > 0)
+			if (_g407_party._shieldDefense > 0)
 				nativeBitmapIndices[AL_0_borderCount++] = k37_BorderPartyShieldIndice;
 			while (AL_0_borderCount--) {
 				dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, k10_ColorFlesh);
 			}
 			if (isInventoryChamp) {
 				invMan.drawStatusBoxPortrait(champIndex);
-				champAttributes |= kChampionAttributeStatistics;
+				champAttributes |= k0x0100_ChampionAttributeStatistics;
 			} else {
-				champAttributes |= (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeWounds | kChampionAttributeActionHand);
+				champAttributes |= (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand);
 			}
 		} else {
 			dispMan.blitToScreen(dispMan.getBitmap(k8_StatusBoxDeadChampion), 80, 0, 0, box, k255_ColorNoTransparency);
@@ -770,8 +770,8 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	if (!champ->_currHealth)
 		goto T0292042_green;
 
-	if (champAttributes & kChampionAttributeNameTitle) {
-		Color AL_0_colorIndex = (champIndex == _leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; // unused because of missing functions
+	if (champAttributes & k0x0080_ChampionAttributeNameTitle) {
+		Color AL_0_colorIndex = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; // unused because of missing functions
 		if (isInventoryChamp) {
 			char *champName = champ->_name;
 			_vm->_textMan->printToViewport(3, 7, AL_0_colorIndex, champName);
@@ -781,7 +781,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 				champTitleX += 6;
 			}
 			_vm->_textMan->printToViewport(champTitleX, 7, AL_0_colorIndex, champ->_title);
-			champAttributes |= kChampionAttributeViewport;
+			champAttributes |= k0x4000_ChampionAttributeViewport;
 		} else {
 			box._y1 = 0;
 			box._y2 = 6 + 1;
@@ -792,7 +792,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		}
 	}
 
-	if (champAttributes & kChampionAttributeStatistics) {
+	if (champAttributes & k0x0100_ChampionAttributeStatistics) {
 		drawChampionBarGraphs(champIndex);
 		if (isInventoryChamp) {
 			drawHealthStaminaManaValues(champ);
@@ -804,28 +804,28 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			}
 			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, k12_ColorDarkestGray, g296_DungeonViewport);
 			AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice;
-			for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) {
-				if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent)
-					< champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum)) {
+			for (int16 AL_0_statisticIndex = k1_ChampionStatStrength; AL_0_statisticIndex <= k6_ChampionStatAntifire; AL_0_statisticIndex++) {
+				if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent)
+					< champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, k0_ChampionStatMaximum)) {
 					AL_2_nativeBitmapIndex = k34_SlotBoxWoundedIndice;
 					break;
 				}
 			}
 			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, k12_ColorDarkestGray, g296_DungeonViewport);
-			champAttributes |= kChampionAttributeViewport;
+			champAttributes |= k0x4000_ChampionAttributeViewport;
 		}
 	}
 
-	if (champAttributes & kChampionAttributeWounds) {
-		for (int16 AL_0_slotIndex = isInventoryChamp ? kChampionSlotFeet : kChampionSlotActionHand; AL_0_slotIndex >= kChampionSlotReadyHand; AL_0_slotIndex--) {
+	if (champAttributes & k0x2000_ChampionAttributeWounds) {
+		for (int16 AL_0_slotIndex = isInventoryChamp ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL_0_slotIndex >= k0_ChampionSlotReadyHand; AL_0_slotIndex--) {
 			drawSlot(champIndex, (ChampionSlot)AL_0_slotIndex);
 		}
 		if (isInventoryChamp) {
-			champAttributes |= kChampionAttributeViewport;
+			champAttributes |= k0x4000_ChampionAttributeViewport;
 		}
 	}
 
-	if ((champAttributes & kChampionAttributeLoad) && isInventoryChamp) {
+	if ((champAttributes & k0x0200_ChampionAttributeLoad) && isInventoryChamp) {
 		Color loadColor;
 		int16 champMaxLoad = getMaximumLoad(champ);
 		if (champ->_load > champMaxLoad) {
@@ -846,49 +846,49 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		loadTmp = (getMaximumLoad(champ) + 5) / 10;
 		str += "KG";
 		_vm->_textMan->printToViewport(148, 132, loadColor, str.c_str());
-		champAttributes |= kChampionAttributeViewport;
+		champAttributes |= k0x4000_ChampionAttributeViewport;
 	}
 
 	{ // block so goto won't skip AL_0_championIconIndex initialization 
 		int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir);
 
 		if ((champAttributes & k28_ChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) {
-			dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]);
+			dispMan.clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]);
 			dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0,
-								 gBoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray);
+								 g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray);
 		}
 	}
 
-	if ((champAttributes & kChampionAttributePanel) && isInventoryChamp) {
+	if ((champAttributes & k0x0800_ChampionAttributePanel) && isInventoryChamp) {
 		if (_vm->_pressingMouth) {
 			invMan.drawPanelFoodWaterPoisoned();
 		} else if (_vm->_pressingEye) {
-			if (_leaderEmptyHanded) {
+			if (_g415_leaderEmptyHanded) {
 				warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics");
 			}
 		} else {
 			invMan.drawPanel();
 		}
-		champAttributes |= kChampionAttributeViewport;
+		champAttributes |= k0x4000_ChampionAttributeViewport;
 	}
 
-	if (champAttributes & kChampionAttributeActionHand) {
-		drawSlot(champIndex, kChampionSlotActionHand);
+	if (champAttributes & k0x8000_ChampionAttributeActionHand) {
+		drawSlot(champIndex, k1_ChampionSlotActionHand);
 		menuMan.drawActionIcon(champIndex);
 		if (isInventoryChamp) {
-			champAttributes |= kChampionAttributeViewport;
+			champAttributes |= k0x4000_ChampionAttributeViewport;
 		}
 	}
 
-	if (champAttributes & kChampionAttributeViewport) {
+	if (champAttributes & k0x4000_ChampionAttributeViewport) {
 		warning("MISSGIN CODE: F0097_DUNGEONVIEW_DrawViewport");
 	}
 
 
 T0292042_green:
-	champ->setAttributeFlag((ChampionAttribute)(kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon |
-												kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport |
-												kChampionAttributeActionHand), false);
+	champ->setAttributeFlag((ChampionAttribute)(k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon |
+												k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport |
+												k0x8000_ChampionAttributeActionHand), false);
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 
@@ -909,7 +909,7 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 
 	uint16 slotBoxIndex;
 	if (!isInventoryChamp) {  /* If drawing a slot for a champion other than the champion whose inventory is open */
-		if ((slotIndex > kChampionSlotActionHand) || (_candidateChampionOrdinal == _vm->indexToOrdinal(champIndex))) {
+		if ((slotIndex > k1_ChampionSlotActionHand) || (_g299_candidateChampionOrdinal == _vm->indexToOrdinal(champIndex))) {
 			return;
 		}
 		slotBoxIndex = (champIndex << 1) + slotIndex;
@@ -918,8 +918,8 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 	}
 
 	Thing thing;
-	if (slotIndex >= kChampionSlotChest_1) {
-		thing = _vm->_inventoryMan->_chestSlots[slotIndex - kChampionSlotChest_1];
+	if (slotIndex >= k30_ChampionSlotChest_1) {
+		thing = _vm->_inventoryMan->_chestSlots[slotIndex - k30_ChampionSlotChest_1];
 	} else {
 		thing = champ->getSlot(slotIndex);
 	}
@@ -938,8 +938,8 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 
 	int16 iconIndex;
 	if (thing == Thing::_none) {
-		if (slotIndex <= kChampionSlotFeet) {
-			iconIndex = kIconIndiceReadyHand + (slotIndex << 1);
+		if (slotIndex <= k5_ChampionSlotFeet) {
+			iconIndex = k212_IconIndiceReadyHand + (slotIndex << 1);
 			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) {
 				iconIndex++;
 				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
@@ -947,20 +947,20 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 				nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			}
 		} else {
-			if ((slotIndex >= kChampionSlotNeck) && (slotIndex <= kChampionSlotBackpackLine_1_1)) {
-				iconIndex = kIconIndiceNeck + (slotIndex - kChampionSlotNeck);
+			if ((slotIndex >= k10_ChampionSlotNeck) && (slotIndex <= k13_ChampionSlotBackpackLine_1_1)) {
+				iconIndex = k208_IconIndiceNeck + (slotIndex - k10_ChampionSlotNeck);
 			} else {
-				iconIndex = kIconIndiceEmptyBox;
+				iconIndex = k204_IconIndiceEmptyBox;
 			}
 		}
 	} else {
 		warning("BUG0_35");
 		iconIndex = _vm->_objectMan->getIconIndex(thing); // BUG0_35
-		if (isInventoryChamp && (slotIndex == kChampionSlotActionHand) && ((iconIndex == kIconIndiceContainerChestClosed) || (iconIndex == kIconIndiceScrollOpen))) {
+		if (isInventoryChamp && (slotIndex == k1_ChampionSlotActionHand) && ((iconIndex == k144_IconIndiceContainerChestClosed) || (iconIndex == k30_IconIndiceScrollOpen))) {
 			warning("BUG2_00");
 			iconIndex++;
 		} // BUG2_00
-		if (slotIndex <= kChampionSlotFeet) {
+		if (slotIndex <= k5_ChampionSlotFeet) {
 			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) {
 				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
 			} else {
@@ -969,7 +969,7 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 		}
 	}
 
-	if ((slotIndex == kChampionSlotActionHand) && (_vm->indexToOrdinal(champIndex) == _actingChampionOrdinal)) {
+	if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->indexToOrdinal(champIndex) == _g506_actingChampionOrdinal)) {
 		nativeBitmapIndex = k35_SlotBoxActingHandIndice;
 	}
 
@@ -1014,11 +1014,11 @@ void ChampionMan::renameChampion(Champion* champ) {
 }
 
 uint16 ChampionMan::getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex) {
-	if (_partyIsSleeping)
+	if (_g300_partyIsSleeping)
 		return 1;
 
-	bool ignoreTempExp = skillIndex & kIgnoreTemporaryExperience;
-	bool ignoreObjModifiers = skillIndex & kIgnoreObjectModifiers;
+	bool ignoreTempExp = skillIndex & k0x8000_IgnoreTemporaryExperience;
+	bool ignoreObjModifiers = skillIndex & k0x4000_IgnoreObjectModifiers;
 	skillIndex = (ChampionSkill)(skillIndex & ~(ignoreTempExp | ignoreObjModifiers));
 	Champion *champ = &_champions[champIndex];
 	Skill *skill = &champ->getSkill(skillIndex);
@@ -1027,8 +1027,8 @@ uint16 ChampionMan::getSkillLevel(ChampionIndex champIndex, ChampionSkill skillI
 	if (!ignoreTempExp)
 		experience += skill->_temporaryExperience;
 
-	if (skillIndex > kChampionSkillWizard) { // hidden skill
-		skill = &champ->getSkill((ChampionSkill)((skillIndex - kChampionSkillSwing) / 4));
+	if (skillIndex > k3_ChampionSkillWizard) { // hidden skill
+		skill = &champ->getSkill((ChampionSkill)((skillIndex - k4_ChampionSkillSwing) / 4));
 		experience += skill->_experience; // add exp to the base skill
 		if (!ignoreTempExp)
 			experience += skill->_temporaryExperience;
@@ -1043,30 +1043,30 @@ uint16 ChampionMan::getSkillLevel(ChampionIndex champIndex, ChampionSkill skillI
 	}
 
 	if (!ignoreObjModifiers) {
-		IconIndice actionHandIconIndex = _vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotActionHand));
-		if (actionHandIconIndex == kIconIndiceWeaponTheFirestaff) {
+		IconIndice actionHandIconIndex = _vm->_objectMan->getIconIndex(champ->getSlot(k1_ChampionSlotActionHand));
+		if (actionHandIconIndex == k27_IconIndiceWeaponTheFirestaff) {
 			skillLevel++;
-		} else if (actionHandIconIndex == kIconIndiceWeaponTheFirestaffComplete) {
+		} else if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete) {
 			skillLevel += 2;
 		}
 
-		IconIndice neckIconIndice = _vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotNeck));
+		IconIndice neckIconIndice = _vm->_objectMan->getIconIndex(champ->getSlot(k10_ChampionSlotNeck));
 		switch (skillIndex) {
-		case kChampionSkillWizard:
-			if (neckIconIndice == kIconIndiceJunkPendantFeral)
+		case k3_ChampionSkillWizard:
+			if (neckIconIndice == k124_IconIndiceJunkPendantFeral)
 				skillLevel++;
 			break;
-		case kChampionSkillDefend:
-			if (neckIconIndice == kIconIndiceJunkEkkhardCross)
+		case k15_ChampionSkillDefend:
+			if (neckIconIndice == k121_IconIndiceJunkEkkhardCross)
 				skillLevel++;
 			break;
-		case kChampionSkillHeal:
+		case k13_ChampionSkillHeal:
 			// these two are not cummulative
-			if ((neckIconIndice == kIconIndiceJunkGemOfAges) || (neckIconIndice == kIconIndiceWeaponSceptreOfLyf))
+			if ((neckIconIndice == k120_IconIndiceJunkGemOfAges) || (neckIconIndice == k66_IconIndiceWeaponSceptreOfLyf))
 				skillLevel++;
 			break;
-		case kChampionSkillInfluence:
-			if (neckIconIndice == kIconIndiceJunkMoonstone)
+		case k14_ChampionSkillInfluence:
+			if (neckIconIndice == k122_IconIndiceJunkMoonstone)
 				skillLevel++;
 			break;
 		}
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index c1abca1..cd66946 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -35,13 +35,13 @@
 
 namespace DM {
 
-#define kIgnoreObjectModifiers 0x4000 // @ MASK0x4000_IGNORE_OBJECT_MODIFIERS     
-#define kIgnoreTemporaryExperience 0x8000 // @ MASK0x8000_IGNORE_TEMPORARY_EXPERIENCE 
+#define k0x4000_IgnoreObjectModifiers 0x4000 // @ MASK0x4000_IGNORE_OBJECT_MODIFIERS     
+#define k0x8000_IgnoreTemporaryExperience 0x8000 // @ MASK0x8000_IGNORE_TEMPORARY_EXPERIENCE 
 
-extern Box gBoxChampionIcons[4]; // @ G0054_ai_Graphic562_Box_ChampionIcons
-extern Color gChampionColor[4]; // @ G0046_auc_Graphic562_ChampionColor
+extern Box g54_BoxChampionIcons[4]; // @ G0054_ai_Graphic562_Box_ChampionIcons
+extern Color g46_ChampionColor[4]; // @ G0046_auc_Graphic562_ChampionColor
 
-extern int16 gLightPowerToLightAmount[16]; // @ G0039_ai_Graphic562_LightPowerToLightAmount
+extern int16 g39_LightPowerToLightAmount[16]; // @ G0039_ai_Graphic562_LightPowerToLightAmount
 
 class Scent {
 	uint16 _scent;
@@ -84,246 +84,246 @@ public:
 }; // @  PARTY
 
 enum IconIndice {
-	kIconIndiceNone = -1, // @ CM1_ICON_NONE
-	kIconIndiceJunkCompassNorth = 0, // @ C000_ICON_JUNK_COMPASS_NORTH
-	kIconIndiceJunkCompassWest = 3, // @ C003_ICON_JUNK_COMPASS_WEST
-	kIconIndiceWeaponTorchUnlit = 4, // @ C004_ICON_WEAPON_TORCH_UNLIT
-	kIconIndiceWeaponTorchLit = 7, // @ C007_ICON_WEAPON_TORCH_LIT
-	kIconIndiceJunkWater = 8, // @ C008_ICON_JUNK_WATER
-	kIconIndiceJunkWaterSkin = 9, // @ C009_ICON_JUNK_WATERSKIN
-	kIconIndiceJunkJewelSymalUnequipped = 10, // @ C010_ICON_JUNK_JEWEL_SYMAL_UNEQUIPPED
-	kIconIndiceJunkJewelSymalEquipped = 11, // @ C011_ICON_JUNK_JEWEL_SYMAL_EQUIPPED
-	kIconIndiceJunkIllumuletUnequipped = 12, // @ C012_ICON_JUNK_ILLUMULET_UNEQUIPPED
-	kIconIndiceJunkIllumuletEquipped = 13, // @ C013_ICON_JUNK_ILLUMULET_EQUIPPED
-	kIconIndiceWeaponFlamittEmpty = 14, // @ C014_ICON_WEAPON_FLAMITT_EMPTY
-	kIconIndiceWeaponEyeOfTimeEmpty = 16, // @ C016_ICON_WEAPON_EYE_OF_TIME_EMPTY
-	kIconIndiceWeaponStormringEmpty = 18, // @ C018_ICON_WEAPON_STORMRING_EMPTY
-	kIconIndiceWeaponStaffOfClawsEmpty = 20, // @ C020_ICON_WEAPON_STAFF_OF_CLAWS_EMPTY
-	kIconIndiceWeaponStaffOfClawsFull = 22, // @ C022_ICON_WEAPON_STAFF_OF_CLAWS_FULL
-	kIconIndiceWeaponBoltBladeStormEmpty = 23, // @ C023_ICON_WEAPON_BOLT_BLADE_STORM_EMPTY
-	kIconIndiceWeaponFuryRaBladeEmpty = 25, // @ C025_ICON_WEAPON_FURY_RA_BLADE_EMPTY
-	kIconIndiceWeaponTheFirestaff = 27, // @ C027_ICON_WEAPON_THE_FIRESTAFF
-	kIconIndiceWeaponTheFirestaffComplete = 28, // @ C028_ICON_WEAPON_THE_FIRESTAFF_COMPLETE
-	kIconIndiceScrollOpen = 30, // @ C030_ICON_SCROLL_SCROLL_OPEN
-	kIconIndiceScrollClosed = 31, // @ C031_ICON_SCROLL_SCROLL_CLOSED
-	kIconIndiceWeaponDagger = 32, // @ C032_ICON_WEAPON_DAGGER
-	kIconIndiceWeaponDeltaSideSplitter = 38, // @ C038_ICON_WEAPON_DELTA_SIDE_SPLITTER
-	kIconIndiceWeaponDiamondEdge = 39, // @ C039_ICON_WEAPON_DIAMOND_EDGE
-	kIconIndiceWeaponVorpalBlade = 40, // @ C040_ICON_WEAPON_VORPAL_BLADE
-	kIconIndiceWeaponTheInquisitorDragonFang = 41, // @ C041_ICON_WEAPON_THE_INQUISITOR_DRAGON_FANG
-	kIconIndiceWeaponHardcleaveExecutioner = 43, // @ C043_ICON_WEAPON_HARDCLEAVE_EXECUTIONER
-	kIconIndiceWeaponMaceOfOrder = 45, // @ C045_ICON_WEAPON_MACE_OF_ORDER
-	kIconIndiceWeaponArrow = 51, // @ C051_ICON_WEAPON_ARROW
-	kIconIndiceWeaponSlayer = 52, // @ C052_ICON_WEAPON_SLAYER
-	kIconIndiceWeaponRock = 54, // @ C054_ICON_WEAPON_ROCK
-	kIconIndiceWeaponPoisonDart = 55, // @ C055_ICON_WEAPON_POISON_DART
-	kIconIndiceWeaponThrowingStar = 56, // @ C056_ICON_WEAPON_THROWING_STAR
-	kIconIndiceWeaponStaff = 58, // @ C058_ICON_WEAPON_STAFF
-	kIconIndiceWeaponWand = 59, // @ C059_ICON_WEAPON_WAND
-	kIconIndiceWeaponTeowand = 60, // @ C060_ICON_WEAPON_TEOWAND
-	kIconIndiceWeaponYewStaff = 61, // @ C061_ICON_WEAPON_YEW_STAFF
-	kIconIndiceWeaponStaffOfManarStaffOfIrra = 62, // @ C062_ICON_WEAPON_STAFF_OF_MANAR_STAFF_OF_IRRA
-	kIconIndiceWeaponSnakeStaffCrossOfNeta = 63, // @ C063_ICON_WEAPON_SNAKE_STAFF_CROSS_OF_NETA
-	kIconIndiceWeaponTheConduitSerpentStaff = 64, // @ C064_ICON_WEAPON_THE_CONDUIT_SERPENT_STAFF
-	kIconIndiceWeaponDragonSpit = 65, // @ C065_ICON_WEAPON_DRAGON_SPIT
-	kIconIndiceWeaponSceptreOfLyf = 66, // @ C066_ICON_WEAPON_SCEPTRE_OF_LYF
-	kIconIndiceArmourCloakOfNight = 81, // @ C081_ICON_ARMOUR_CLOAK_OF_NIGHT
-	kIconIndiceArmourCrownOfNerra = 104, // @ C104_ICON_ARMOUR_CROWN_OF_NERRA
-	kIconIndiceArmourElvenBoots = 119, // @ C119_ICON_ARMOUR_ELVEN_BOOTS
-	kIconIndiceJunkGemOfAges = 120, // @ C120_ICON_JUNK_GEM_OF_AGES
-	kIconIndiceJunkEkkhardCross = 121, // @ C121_ICON_JUNK_EKKHARD_CROSS
-	kIconIndiceJunkMoonstone = 122, // @ C122_ICON_JUNK_MOONSTONE
-	kIconIndiceJunkPendantFeral = 124, // @ C124_ICON_JUNK_PENDANT_FERAL
-	kIconIndiceJunkBoulder = 128, // @ C128_ICON_JUNK_BOULDER
-	kIconIndiceJunkRabbitsFoot = 137, // @ C137_ICON_JUNK_RABBITS_FOOT
-	kIconIndiceArmourDexhelm = 140, // @ C140_ICON_ARMOUR_DEXHELM
-	kIconIndiceArmourFlamebain = 141, // @ C141_ICON_ARMOUR_FLAMEBAIN
-	kIconIndiceArmourPowertowers = 142, // @ C142_ICON_ARMOUR_POWERTOWERS
-	kIconIndiceContainerChestClosed = 144, // @ C144_ICON_CONTAINER_CHEST_CLOSED
-	kIconIndiceContainerChestOpen = 145, // @ C145_ICON_CONTAINER_CHEST_OPEN
-	kIconIndiceJunkChampionBones = 147, // @ C147_ICON_JUNK_CHAMPION_BONES
-	kIconIndicePotionMaPotionMonPotion = 148, // @ C148_ICON_POTION_MA_POTION_MON_POTION
-	kIconIndicePotionWaterFlask = 163, // @ C163_ICON_POTION_WATER_FLASK
-	kIconIndiceJunkApple = 168, // @ C168_ICON_JUNK_APPLE
-	kIconIndiceJunkIronKey = 176, // @ C176_ICON_JUNK_IRON_KEY
-	kIconIndiceJunkMasterKey = 191, // @ C191_ICON_JUNK_MASTER_KEY
-	kIconIndiceArmourBootOfSpeed = 194, // @ C194_ICON_ARMOUR_BOOT_OF_SPEED
-	kIconIndicePotionEmptyFlask = 195, // @ C195_ICON_POTION_EMPTY_FLASK
-	kIconIndiceJunkZokathra = 197, // @ C197_ICON_JUNK_ZOKATHRA
-	kIconIndiceActionEmptyHand = 201, // @ C201_ICON_ACTION_ICON_EMPTY_HAND
-	kIconIndiceEyeNotLooking = 202, // @ C202_ICON_EYE_NOT_LOOKING /* One pixel is different in this bitmap from the eye in C017_GRAPHIC_INVENTORY. This is visible by selecting another champion after clicking the eye */
-	kIconIndiceEyeLooking = 203, // @ C203_ICON_EYE_LOOKING
-	kIconIndiceEmptyBox = 204, // @ C204_ICON_EMPTY_BOX
-	kIconIndiceMouthOpen = 205, // @ C205_ICON_MOUTH_OPEN
-	kIconIndiceNeck = 208, // @ C208_ICON_NECK
-	kIconIndiceReadyHand = 212 // @ C212_ICON_READY_HAND
+	kM1_IconIndiceNone = -1, // @ CM1_ICON_NONE
+	k0_IconIndiceJunkCompassNorth = 0, // @ C000_ICON_JUNK_COMPASS_NORTH
+	k3_IconIndiceJunkCompassWest = 3, // @ C003_ICON_JUNK_COMPASS_WEST
+	k4_IconIndiceWeaponTorchUnlit = 4, // @ C004_ICON_WEAPON_TORCH_UNLIT
+	k7_IconIndiceWeaponTorchLit = 7, // @ C007_ICON_WEAPON_TORCH_LIT
+	k8_IconIndiceJunkWater = 8, // @ C008_ICON_JUNK_WATER
+	k9_IconIndiceJunkWaterSkin = 9, // @ C009_ICON_JUNK_WATERSKIN
+	k10_IconIndiceJunkJewelSymalUnequipped = 10, // @ C010_ICON_JUNK_JEWEL_SYMAL_UNEQUIPPED
+	k11_IconIndiceJunkJewelSymalEquipped = 11, // @ C011_ICON_JUNK_JEWEL_SYMAL_EQUIPPED
+	k12_IconIndiceJunkIllumuletUnequipped = 12, // @ C012_ICON_JUNK_ILLUMULET_UNEQUIPPED
+	k13_IconIndiceJunkIllumuletEquipped = 13, // @ C013_ICON_JUNK_ILLUMULET_EQUIPPED
+	k14_IconIndiceWeaponFlamittEmpty = 14, // @ C014_ICON_WEAPON_FLAMITT_EMPTY
+	k16_IconIndiceWeaponEyeOfTimeEmpty = 16, // @ C016_ICON_WEAPON_EYE_OF_TIME_EMPTY
+	k18_IconIndiceWeaponStormringEmpty = 18, // @ C018_ICON_WEAPON_STORMRING_EMPTY
+	k20_IconIndiceWeaponStaffOfClawsEmpty = 20, // @ C020_ICON_WEAPON_STAFF_OF_CLAWS_EMPTY
+	k22_IconIndiceWeaponStaffOfClawsFull = 22, // @ C022_ICON_WEAPON_STAFF_OF_CLAWS_FULL
+	k23_IconIndiceWeaponBoltBladeStormEmpty = 23, // @ C023_ICON_WEAPON_BOLT_BLADE_STORM_EMPTY
+	k25_IconIndiceWeaponFuryRaBladeEmpty = 25, // @ C025_ICON_WEAPON_FURY_RA_BLADE_EMPTY
+	k27_IconIndiceWeaponTheFirestaff = 27, // @ C027_ICON_WEAPON_THE_FIRESTAFF
+	k28_IconIndiceWeaponTheFirestaffComplete = 28, // @ C028_ICON_WEAPON_THE_FIRESTAFF_COMPLETE
+	k30_IconIndiceScrollOpen = 30, // @ C030_ICON_SCROLL_SCROLL_OPEN
+	k31_IconIndiceScrollClosed = 31, // @ C031_ICON_SCROLL_SCROLL_CLOSED
+	k32_IconIndiceWeaponDagger = 32, // @ C032_ICON_WEAPON_DAGGER
+	k38_IconIndiceWeaponDeltaSideSplitter = 38, // @ C038_ICON_WEAPON_DELTA_SIDE_SPLITTER
+	k39_IconIndiceWeaponDiamondEdge = 39, // @ C039_ICON_WEAPON_DIAMOND_EDGE
+	k40_IconIndiceWeaponVorpalBlade = 40, // @ C040_ICON_WEAPON_VORPAL_BLADE
+	k41_IconIndiceWeaponTheInquisitorDragonFang = 41, // @ C041_ICON_WEAPON_THE_INQUISITOR_DRAGON_FANG
+	k43_IconIndiceWeaponHardcleaveExecutioner = 43, // @ C043_ICON_WEAPON_HARDCLEAVE_EXECUTIONER
+	k45_IconIndiceWeaponMaceOfOrder = 45, // @ C045_ICON_WEAPON_MACE_OF_ORDER
+	k51_IconIndiceWeaponArrow = 51, // @ C051_ICON_WEAPON_ARROW
+	k52_IconIndiceWeaponSlayer = 52, // @ C052_ICON_WEAPON_SLAYER
+	k54_IconIndiceWeaponRock = 54, // @ C054_ICON_WEAPON_ROCK
+	k55_IconIndiceWeaponPoisonDart = 55, // @ C055_ICON_WEAPON_POISON_DART
+	k56_IconIndiceWeaponThrowingStar = 56, // @ C056_ICON_WEAPON_THROWING_STAR
+	k58_IconIndiceWeaponStaff = 58, // @ C058_ICON_WEAPON_STAFF
+	k59_IconIndiceWeaponWand = 59, // @ C059_ICON_WEAPON_WAND
+	k60_IconIndiceWeaponTeowand = 60, // @ C060_ICON_WEAPON_TEOWAND
+	k61_IconIndiceWeaponYewStaff = 61, // @ C061_ICON_WEAPON_YEW_STAFF
+	k62_IconIndiceWeaponStaffOfManarStaffOfIrra = 62, // @ C062_ICON_WEAPON_STAFF_OF_MANAR_STAFF_OF_IRRA
+	k63_IconIndiceWeaponSnakeStaffCrossOfNeta = 63, // @ C063_ICON_WEAPON_SNAKE_STAFF_CROSS_OF_NETA
+	k64_IconIndiceWeaponTheConduitSerpentStaff = 64, // @ C064_ICON_WEAPON_THE_CONDUIT_SERPENT_STAFF
+	k65_IconIndiceWeaponDragonSpit = 65, // @ C065_ICON_WEAPON_DRAGON_SPIT
+	k66_IconIndiceWeaponSceptreOfLyf = 66, // @ C066_ICON_WEAPON_SCEPTRE_OF_LYF
+	k81_IconIndiceArmourCloakOfNight = 81, // @ C081_ICON_ARMOUR_CLOAK_OF_NIGHT
+	k104_IconIndiceArmourCrownOfNerra = 104, // @ C104_ICON_ARMOUR_CROWN_OF_NERRA
+	k119_IconIndiceArmourElvenBoots = 119, // @ C119_ICON_ARMOUR_ELVEN_BOOTS
+	k120_IconIndiceJunkGemOfAges = 120, // @ C120_ICON_JUNK_GEM_OF_AGES
+	k121_IconIndiceJunkEkkhardCross = 121, // @ C121_ICON_JUNK_EKKHARD_CROSS
+	k122_IconIndiceJunkMoonstone = 122, // @ C122_ICON_JUNK_MOONSTONE
+	k124_IconIndiceJunkPendantFeral = 124, // @ C124_ICON_JUNK_PENDANT_FERAL
+	k128_IconIndiceJunkBoulder = 128, // @ C128_ICON_JUNK_BOULDER
+	k137_IconIndiceJunkRabbitsFoot = 137, // @ C137_ICON_JUNK_RABBITS_FOOT
+	k140_IconIndiceArmourDexhelm = 140, // @ C140_ICON_ARMOUR_DEXHELM
+	k141_IconIndiceArmourFlamebain = 141, // @ C141_ICON_ARMOUR_FLAMEBAIN
+	k142_IconIndiceArmourPowertowers = 142, // @ C142_ICON_ARMOUR_POWERTOWERS
+	k144_IconIndiceContainerChestClosed = 144, // @ C144_ICON_CONTAINER_CHEST_CLOSED
+	k145_IconIndiceContainerChestOpen = 145, // @ C145_ICON_CONTAINER_CHEST_OPEN
+	k147_IconIndiceJunkChampionBones = 147, // @ C147_ICON_JUNK_CHAMPION_BONES
+	k148_IconIndicePotionMaPotionMonPotion = 148, // @ C148_ICON_POTION_MA_POTION_MON_POTION
+	k163_IconIndicePotionWaterFlask = 163, // @ C163_ICON_POTION_WATER_FLASK
+	k168_IconIndiceJunkApple = 168, // @ C168_ICON_JUNK_APPLE
+	k176_IconIndiceJunkIronKey = 176, // @ C176_ICON_JUNK_IRON_KEY
+	k191_IconIndiceJunkMasterKey = 191, // @ C191_ICON_JUNK_MASTER_KEY
+	k194_IconIndiceArmourBootOfSpeed = 194, // @ C194_ICON_ARMOUR_BOOT_OF_SPEED
+	k195_IconIndicePotionEmptyFlask = 195, // @ C195_ICON_POTION_EMPTY_FLASK
+	k197_IconIndiceJunkZokathra = 197, // @ C197_ICON_JUNK_ZOKATHRA
+	k201_IconIndiceActionEmptyHand = 201, // @ C201_ICON_ACTION_ICON_EMPTY_HAND
+	k202_IconIndiceEyeNotLooking = 202, // @ C202_ICON_EYE_NOT_LOOKING /* One pixel is different in this bitmap from the eye in C017_GRAPHIC_INVENTORY. This is visible by selecting another champion after clicking the eye */
+	k203_IconIndiceEyeLooking = 203, // @ C203_ICON_EYE_LOOKING
+	k204_IconIndiceEmptyBox = 204, // @ C204_ICON_EMPTY_BOX
+	k205_IconIndiceMouthOpen = 205, // @ C205_ICON_MOUTH_OPEN
+	k208_IconIndiceNeck = 208, // @ C208_ICON_NECK
+	k212_IconIndiceReadyHand = 212 // @ C212_ICON_READY_HAND
 };
 
 enum ChampionIndex {
-	kChampionNone = -1, // @ CM1_CHAMPION_NONE
-	kChampionFirst = 0, // @ C00_CHAMPION_FIRST
-	kChampionSecond = 1,
-	kChampionThird = 2,
-	kChampionFourth = 3,
-	kChampionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY
-	kChampionSpecialInventory = 5 // @ C05_CHAMPION_SPECIAL_INVENTORY
+	kM1_ChampionNone = -1, // @ CM1_CHAMPION_NONE
+	k0_ChampionFirst = 0, // @ C00_CHAMPION_FIRST
+	k1_ChampionSecond = 1,
+	k2_ChampionThird = 2,
+	k3_ChampionFourth = 3,
+	k4_ChampionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY
+	k5_ChampionSpecialInventory = 5 // @ C05_CHAMPION_SPECIAL_INVENTORY
 };
 
 enum ChampionAttribute {
-	kChampionAttributNone = 0x0000, // @ MASK0x0000_NONE
-	kChampionAttributeDisableAction = 0x0008, // @ MASK0x0008_DISABLE_ACTION
-	kChampionAttributeMale = 0x0010, // @ MASK0x0010_MALE
-	kChampionAttributeNameTitle = 0x0080, // @ MASK0x0080_NAME_TITLE
-	kChampionAttributeStatistics = 0x0100, // @ MASK0x0100_STATISTICS
-	kChampionAttributeLoad = 0x0200, // @ MASK0x0200_LOAD
-	kChampionAttributeIcon = 0x0400, // @ MASK0x0400_ICON
-	kChampionAttributePanel = 0x0800, // @ MASK0x0800_PANEL
-	kChampionAttributeStatusBox = 0x1000, // @ MASK0x1000_STATUS_BOX
-	kChampionAttributeWounds = 0x2000, // @ MASK0x2000_WOUNDS
-	kChampionAttributeViewport = 0x4000, // @ MASK0x4000_VIEWPORT
-	kChampionAttributeActionHand = 0x8000 // @ MASK0x8000_ACTION_HAND
+	k0x0000_ChampionAttributNone = 0x0000, // @ MASK0x0000_NONE
+	k0x0008_ChampionAttributeDisableAction = 0x0008, // @ MASK0x0008_DISABLE_ACTION
+	k0x0010_ChampionAttributeMale = 0x0010, // @ MASK0x0010_MALE
+	k0x0080_ChampionAttributeNameTitle = 0x0080, // @ MASK0x0080_NAME_TITLE
+	k0x0100_ChampionAttributeStatistics = 0x0100, // @ MASK0x0100_STATISTICS
+	k0x0200_ChampionAttributeLoad = 0x0200, // @ MASK0x0200_LOAD
+	k0x0400_ChampionAttributeIcon = 0x0400, // @ MASK0x0400_ICON
+	k0x0800_ChampionAttributePanel = 0x0800, // @ MASK0x0800_PANEL
+	k0x1000_ChampionAttributeStatusBox = 0x1000, // @ MASK0x1000_STATUS_BOX
+	k0x2000_ChampionAttributeWounds = 0x2000, // @ MASK0x2000_WOUNDS
+	k0x4000_ChampionAttributeViewport = 0x4000, // @ MASK0x4000_VIEWPORT
+	k0x8000_ChampionAttributeActionHand = 0x8000 // @ MASK0x8000_ACTION_HAND
 };
 
 
 enum ChampionWound {
-	kChampionWoundNone = 0x0000, // @ MASK0x0000_NO_WOUND
-	kChampionWoundReadHand = 0x0001, // @ MASK0x0001_READY_HAND
-	kChampionWoundActionHand = 0x0002, // @ MASK0x0002_ACTION_HAND
-	kChampionWoundHead = 0x0004, // @ MASK0x0004_HEAD
-	kChampionWoundTorso = 0x0008, // @ MASK0x0008_TORSO
-	kChampionWoundLegs = 0x0010, // @ MASK0x0010_LEGS
-	kChampionWoundFeet = 0x0020 // @ MASK0x0020_FEET
+	k0x0000_ChampionWoundNone = 0x0000, // @ MASK0x0000_NO_WOUND
+	k0x0001_ChampionWoundReadHand = 0x0001, // @ MASK0x0001_READY_HAND
+	k0x0002_ChampionWoundActionHand = 0x0002, // @ MASK0x0002_ACTION_HAND
+	k0x0004_ChampionWoundHead = 0x0004, // @ MASK0x0004_HEAD
+	k0x0008_ChampionWoundTorso = 0x0008, // @ MASK0x0008_TORSO
+	k0x0010_ChampionWoundLegs = 0x0010, // @ MASK0x0010_LEGS
+	k0x0020_ChampionWoundFeet = 0x0020 // @ MASK0x0020_FEET
 };
 
 
 enum ChampionStatisticType {
-	kChampionStatLuck = 0, // @ C0_STATISTIC_LUCK
-	kChampionStatStrength = 1, // @ C1_STATISTIC_STRENGTH
-	kChampionStatDexterity = 2, // @ C2_STATISTIC_DEXTERITY
-	kChampionStatWisdom = 3, // @ C3_STATISTIC_WISDOM
-	kChampionStatVitality = 4, // @ C4_STATISTIC_VITALITY
-	kChampionStatAntimagic = 5, // @ C5_STATISTIC_ANTIMAGIC
-	kChampionStatAntifire = 6, // @ C6_STATISTIC_ANTIFIRE
-	kChampionStatMana = 8 // @ C8_STATISTIC_MANA /* Used as a fake statistic index for objects granting a Mana bonus */
+	k0_ChampionStatLuck = 0, // @ C0_STATISTIC_LUCK
+	k1_ChampionStatStrength = 1, // @ C1_STATISTIC_STRENGTH
+	k2_ChampionStatDexterity = 2, // @ C2_STATISTIC_DEXTERITY
+	k3_ChampionStatWisdom = 3, // @ C3_STATISTIC_WISDOM
+	k4_ChampionStatVitality = 4, // @ C4_STATISTIC_VITALITY
+	k5_ChampionStatAntimagic = 5, // @ C5_STATISTIC_ANTIMAGIC
+	k6_ChampionStatAntifire = 6, // @ C6_STATISTIC_ANTIFIRE
+	k8_ChampionStatMana = 8 // @ C8_STATISTIC_MANA /* Used as a fake statistic index for objects granting a Mana bonus */
 };
 
 enum ChampionStatisticValue {
-	kChampionStatMaximum = 0, // @ C0_MAXIMUM
-	kChampionStatCurrent = 1, // @ C1_CURRENT
-	kChampionStatMinimum = 2 // @ C2_MINIMUM
+	k0_ChampionStatMaximum = 0, // @ C0_MAXIMUM
+	k1_ChampionStatCurrent = 1, // @ C1_CURRENT
+	k2_ChampionStatMinimum = 2 // @ C2_MINIMUM
 };
 
 enum ChampionSkill {
-	kChampionSkillFighter = 0, // @ C00_SKILL_FIGHTER
-	kChampionSkillNinja = 1, // @ C01_SKILL_NINJA
-	kChampionSkillPriest = 2, // @ C02_SKILL_PRIEST
-	kChampionSkillWizard = 3, // @ C03_SKILL_WIZARD
-	kChampionSkillSwing = 4, // @ C04_SKILL_SWING
-	kChampionSkillThrust = 5, // @ C05_SKILL_THRUST
-	kChampionSkillClub = 6, // @ C06_SKILL_CLUB
-	kChampionSkillParry = 7, // @ C07_SKILL_PARRY
-	kChampionSkillSteal = 8, // @ C08_SKILL_STEAL
-	kChampionSkillFight = 9, // @ C09_SKILL_FIGHT
-	kChampionSkillThrow = 10, // @ C10_SKILL_THROW
-	kChampionSkillShoot = 11, // @ C11_SKILL_SHOOT
-	kChampionSkillIdentify = 12, // @ C12_SKILL_IDENTIFY
-	kChampionSkillHeal = 13, // @ C13_SKILL_HEAL
-	kChampionSkillInfluence = 14, // @ C14_SKILL_INFLUENCE
-	kChampionSkillDefend = 15, // @ C15_SKILL_DEFEND
-	kChampionSkillFire = 16, // @ C16_SKILL_FIRE
-	kChampionSkillAir = 17, // @ C17_SKILL_AIR
-	kChampionSkillEarth = 18, // @ C18_SKILL_EARTH
-	kChampionSkillWater = 19 // @ C19_SKILL_WATER
+	k0_ChampionSkillFighter = 0, // @ C00_SKILL_FIGHTER
+	k1_ChampionSkillNinja = 1, // @ C01_SKILL_NINJA
+	k2_ChampionSkillPriest = 2, // @ C02_SKILL_PRIEST
+	k3_ChampionSkillWizard = 3, // @ C03_SKILL_WIZARD
+	k4_ChampionSkillSwing = 4, // @ C04_SKILL_SWING
+	k5_ChampionSkillThrust = 5, // @ C05_SKILL_THRUST
+	k6_ChampionSkillClub = 6, // @ C06_SKILL_CLUB
+	k7_ChampionSkillParry = 7, // @ C07_SKILL_PARRY
+	k8_ChampionSkillSteal = 8, // @ C08_SKILL_STEAL
+	k9_ChampionSkillFight = 9, // @ C09_SKILL_FIGHT
+	k10_ChampionSkillThrow = 10, // @ C10_SKILL_THROW
+	k11_ChampionSkillShoot = 11, // @ C11_SKILL_SHOOT
+	k12_ChampionSkillIdentify = 12, // @ C12_SKILL_IDENTIFY
+	k13_ChampionSkillHeal = 13, // @ C13_SKILL_HEAL
+	k14_ChampionSkillInfluence = 14, // @ C14_SKILL_INFLUENCE
+	k15_ChampionSkillDefend = 15, // @ C15_SKILL_DEFEND
+	k16_ChampionSkillFire = 16, // @ C16_SKILL_FIRE
+	k17_ChampionSkillAir = 17, // @ C17_SKILL_AIR
+	k18_ChampionSkillEarth = 18, // @ C18_SKILL_EARTH
+	k19_ChampionSkillWater = 19 // @ C19_SKILL_WATER
 };
 
 enum ChampionSlot {
-	kChampionSlotLeaderHand = -1, // @ CM1_SLOT_LEADER_HAND
-	kChampionSlotReadyHand = 0, // @ C00_SLOT_READY_HAND
-	kChampionSlotActionHand = 1, // @ C01_SLOT_ACTION_HAND
-	kChampionSlotHead = 2, // @ C02_SLOT_HEAD
-	kChampionSlotTorso = 3, // @ C03_SLOT_TORSO
-	kChampionSlotLegs = 4, // @ C04_SLOT_LEGS
-	kChampionSlotFeet = 5, // @ C05_SLOT_FEET
-	kChampionSlotPouch_2 = 6, // @ C06_SLOT_POUCH_2
-	kChampionSlotQuiverLine_2_1 = 7, // @ C07_SLOT_QUIVER_LINE2_1
-	kChampionSlotQuiverLine_1_2 = 8, // @ C08_SLOT_QUIVER_LINE1_2
-	kChampionSlotQuiverLine_2_2 = 9, // @ C09_SLOT_QUIVER_LINE2_2
-	kChampionSlotNeck = 10, // @ C10_SLOT_NECK
-	kChampionSlotPouch_1 = 11, // @ C11_SLOT_POUCH_1
-	kChampionSlotQuiverLine_1_1 = 12, // @ C12_SLOT_QUIVER_LINE1_1
-	kChampionSlotBackpackLine_1_1 = 13, // @ C13_SLOT_BACKPACK_LINE1_1
-	kChampionSlotBackpackLine_2_2 = 14, // @ C14_SLOT_BACKPACK_LINE2_2
-	kChampionSlotBackpackLine_2_3 = 15, // @ C15_SLOT_BACKPACK_LINE2_3
-	kChampionSlotBackpackLine_2_4 = 16, // @ C16_SLOT_BACKPACK_LINE2_4
-	kChampionSlotBackpackLine_2_5 = 17, // @ C17_SLOT_BACKPACK_LINE2_5
-	kChampionSlotBackpackLine_2_6 = 18, // @ C18_SLOT_BACKPACK_LINE2_6
-	kChampionSlotBackpackLine_2_7 = 19, // @ C19_SLOT_BACKPACK_LINE2_7
-	kChampionSlotBackpackLine_2_8 = 20, // @ C20_SLOT_BACKPACK_LINE2_8
-	kChampionSlotBackpackLine_2_9 = 21, // @ C21_SLOT_BACKPACK_LINE2_9
-	kChampionSlotBackpackLine_1_2 = 22, // @ C22_SLOT_BACKPACK_LINE1_2
-	kChampionSlotBackpackLine_1_3 = 23, // @ C23_SLOT_BACKPACK_LINE1_3
-	kChampionSlotBackpackLine_1_4 = 24, // @ C24_SLOT_BACKPACK_LINE1_4
-	kChampionSlotBackpackLine_1_5 = 25, // @ C25_SLOT_BACKPACK_LINE1_5
-	kChampionSlotBackpackLine_1_6 = 26, // @ C26_SLOT_BACKPACK_LINE1_6
-	kChampionSlotBackpackLine_1_7 = 27, // @ C27_SLOT_BACKPACK_LINE1_7
-	kChampionSlotBackpackLine_1_8 = 28, // @ C28_SLOT_BACKPACK_LINE1_8
-	kChampionSlotBackpackLine_1_9 = 29, // @ C29_SLOT_BACKPACK_LINE1_9
-	kChampionSlotChest_1 = 30, // @ C30_SLOT_CHEST_1
-	kChampionSlotChest_2 = 31, // @ C31_SLOT_CHEST_2
-	kChampionSlotChest_3 = 32, // @ C32_SLOT_CHEST_3
-	kChampionSlotChest_4 = 33, // @ C33_SLOT_CHEST_4
-	kChampionSlotChest_5 = 34, // @ C34_SLOT_CHEST_5
-	kChampionSlotChest_6 = 35, // @ C35_SLOT_CHEST_6
-	kChampionSlotChest_7 = 36, // @ C36_SLOT_CHEST_7
-	kChampionSlotChest_8 = 37 // @ C37_SLOT_CHEST_8
+	kM1_ChampionSlotLeaderHand = -1, // @ CM1_SLOT_LEADER_HAND
+	k0_ChampionSlotReadyHand = 0, // @ C00_SLOT_READY_HAND
+	k1_ChampionSlotActionHand = 1, // @ C01_SLOT_ACTION_HAND
+	k2_ChampionSlotHead = 2, // @ C02_SLOT_HEAD
+	k3_ChampionSlotTorso = 3, // @ C03_SLOT_TORSO
+	k4_ChampionSlotLegs = 4, // @ C04_SLOT_LEGS
+	k5_ChampionSlotFeet = 5, // @ C05_SLOT_FEET
+	k6_ChampionSlotPouch_2 = 6, // @ C06_SLOT_POUCH_2
+	k7_ChampionSlotQuiverLine_2_1 = 7, // @ C07_SLOT_QUIVER_LINE2_1
+	k8_ChampionSlotQuiverLine_1_2 = 8, // @ C08_SLOT_QUIVER_LINE1_2
+	k9_ChampionSlotQuiverLine_2_2 = 9, // @ C09_SLOT_QUIVER_LINE2_2
+	k10_ChampionSlotNeck = 10, // @ C10_SLOT_NECK
+	k11_ChampionSlotPouch_1 = 11, // @ C11_SLOT_POUCH_1
+	k12_ChampionSlotQuiverLine_1_1 = 12, // @ C12_SLOT_QUIVER_LINE1_1
+	k13_ChampionSlotBackpackLine_1_1 = 13, // @ C13_SLOT_BACKPACK_LINE1_1
+	k14_ChampionSlotBackpackLine_2_2 = 14, // @ C14_SLOT_BACKPACK_LINE2_2
+	k15_ChampionSlotBackpackLine_2_3 = 15, // @ C15_SLOT_BACKPACK_LINE2_3
+	k16_ChampionSlotBackpackLine_2_4 = 16, // @ C16_SLOT_BACKPACK_LINE2_4
+	k17_ChampionSlotBackpackLine_2_5 = 17, // @ C17_SLOT_BACKPACK_LINE2_5
+	k18_ChampionSlotBackpackLine_2_6 = 18, // @ C18_SLOT_BACKPACK_LINE2_6
+	k19_ChampionSlotBackpackLine_2_7 = 19, // @ C19_SLOT_BACKPACK_LINE2_7
+	k20_ChampionSlotBackpackLine_2_8 = 20, // @ C20_SLOT_BACKPACK_LINE2_8
+	k21_ChampionSlotBackpackLine_2_9 = 21, // @ C21_SLOT_BACKPACK_LINE2_9
+	k22_ChampionSlotBackpackLine_1_2 = 22, // @ C22_SLOT_BACKPACK_LINE1_2
+	k23_ChampionSlotBackpackLine_1_3 = 23, // @ C23_SLOT_BACKPACK_LINE1_3
+	k24_ChampionSlotBackpackLine_1_4 = 24, // @ C24_SLOT_BACKPACK_LINE1_4
+	k25_ChampionSlotBackpackLine_1_5 = 25, // @ C25_SLOT_BACKPACK_LINE1_5
+	k26_ChampionSlotBackpackLine_1_6 = 26, // @ C26_SLOT_BACKPACK_LINE1_6
+	k27_ChampionSlotBackpackLine_1_7 = 27, // @ C27_SLOT_BACKPACK_LINE1_7
+	k28_ChampionSlotBackpackLine_1_8 = 28, // @ C28_SLOT_BACKPACK_LINE1_8
+	k29_ChampionSlotBackpackLine_1_9 = 29, // @ C29_SLOT_BACKPACK_LINE1_9
+	k30_ChampionSlotChest_1 = 30, // @ C30_SLOT_CHEST_1
+	k31_ChampionSlotChest_2 = 31, // @ C31_SLOT_CHEST_2
+	k32_ChampionSlotChest_3 = 32, // @ C32_SLOT_CHEST_3
+	k33_ChampionSlotChest_4 = 33, // @ C33_SLOT_CHEST_4
+	k34_ChampionSlotChest_5 = 34, // @ C34_SLOT_CHEST_5
+	k35_ChampionSlotChest_6 = 35, // @ C35_SLOT_CHEST_6
+	k36_ChampionSlotChest_7 = 36, // @ C36_SLOT_CHEST_7
+	k37_ChampionSlotChest_8 = 37 // @ C37_SLOT_CHEST_8
 };
 
 enum ChampionAction {
-	kChampionActionN = 0, // @ C000_ACTION_N
-	kChampionActionBlock = 1, // @ C001_ACTION_BLOCK
-	kChampionActionChop = 2, // @ C002_ACTION_CHOP
-	kChampionActionX_C003 = 3, // @ C003_ACTION_X
-	kChampionActionBlowHorn = 4, // @ C004_ACTION_BLOW_HORN
-	kChampionActionFlip = 5, // @ C005_ACTION_FLIP
-	kChampionActionPunch = 6, // @ C006_ACTION_PUNCH
-	kChampionActionKick = 7, // @ C007_ACTION_KICK
-	kChampionActionWarCry = 8, // @ C008_ACTION_WAR_CRY
-	kChampionActionStab_C009 = 9, // @ C009_ACTION_STAB
-	kChampionActionClimbDown = 10, // @ C010_ACTION_CLIMB_DOWN
-	kChampionActionFreezeLife = 11, // @ C011_ACTION_FREEZE_LIFE
-	kChampionActionHit = 12, // @ C012_ACTION_HIT
-	kChampionActionSwing = 13, // @ C013_ACTION_SWING
-	kChampionActionStab_C014 = 14, // @ C014_ACTION_STAB
-	kChampionActionThrust = 15, // @ C015_ACTION_THRUST
-	kChampionActionJab = 16, // @ C016_ACTION_JAB
-	kChampionActionParry = 17, // @ C017_ACTION_PARRY
-	kChampionActionHack = 18, // @ C018_ACTION_HACK
-	kChampionActionBerzerk = 19, // @ C019_ACTION_BERZERK
-	kChampionActionFireball = 20, // @ C020_ACTION_FIREBALL
-	kChampionActionDispel = 21, // @ C021_ACTION_DISPELL
-	kChampionActionConfuse = 22, // @ C022_ACTION_CONFUSE
-	kChampionActionLightning = 23, // @ C023_ACTION_LIGHTNING
-	kChampionActionDisrupt = 24, // @ C024_ACTION_DISRUPT
-	kChampionActionMelee = 25, // @ C025_ACTION_MELEE
-	kChampionActionX_C026 = 26, // @ C026_ACTION_X
-	kChampionActionInvoke = 27, // @ C027_ACTION_INVOKE
-	kChampionActionSlash = 28, // @ C028_ACTION_SLASH
-	kChampionActionCleave = 29, // @ C029_ACTION_CLEAVE
-	kChampionActionBash = 30, // @ C030_ACTION_BASH
-	kChampionActionStun = 31, // @ C031_ACTION_STUN
-	kChampionActionShoot = 32, // @ C032_ACTION_SHOOT
-	kChampionActionSpellshield = 33, // @ C033_ACTION_SPELLSHIELD
-	kChampionActionFireshield = 34, // @ C034_ACTION_FIRESHIELD
-	kChampionActionFluxcage = 35, // @ C035_ACTION_FLUXCAGE
-	kChampionActionHeal = 36, // @ C036_ACTION_HEAL
-	kChampionActionCalm = 37, // @ C037_ACTION_CALM
-	kChampionActionLight = 38, // @ C038_ACTION_LIGHT
-	kChampionActionWindow = 39, // @ C039_ACTION_WINDOW
-	kChampionActionSpit = 40, // @ C040_ACTION_SPIT
-	kChampionActionBrandish = 41, // @ C041_ACTION_BRANDISH
-	kChampionActionThrow = 42, // @ C042_ACTION_THROW
-	kChampionActionFuse = 43, // @ C043_ACTION_FUSE
-	kChampionActionNone = 255 // @ C255_ACTION_NONE
+	k0_ChampionActionN = 0, // @ C000_ACTION_N
+	k1_ChampionActionBlock = 1, // @ C001_ACTION_BLOCK
+	k2_ChampionActionChop = 2, // @ C002_ACTION_CHOP
+	k3_ChampionActionX_C003 = 3, // @ C003_ACTION_X
+	k4_ChampionActionBlowHorn = 4, // @ C004_ACTION_BLOW_HORN
+	k5_ChampionActionFlip = 5, // @ C005_ACTION_FLIP
+	k6_ChampionActionPunch = 6, // @ C006_ACTION_PUNCH
+	k7_ChampionActionKick = 7, // @ C007_ACTION_KICK
+	k8_ChampionActionWarCry = 8, // @ C008_ACTION_WAR_CRY
+	k9_ChampionActionStab_C009 = 9, // @ C009_ACTION_STAB
+	k10_ChampionActionClimbDown = 10, // @ C010_ACTION_CLIMB_DOWN
+	k11_ChampionActionFreezeLife = 11, // @ C011_ACTION_FREEZE_LIFE
+	k12_ChampionActionHit = 12, // @ C012_ACTION_HIT
+	k13_ChampionActionSwing = 13, // @ C013_ACTION_SWING
+	k14_ChampionActionStab_C014 = 14, // @ C014_ACTION_STAB
+	k15_ChampionActionThrust = 15, // @ C015_ACTION_THRUST
+	k16_ChampionActionJab = 16, // @ C016_ACTION_JAB
+	k17_ChampionActionParry = 17, // @ C017_ACTION_PARRY
+	k18_ChampionActionHack = 18, // @ C018_ACTION_HACK
+	k19_ChampionActionBerzerk = 19, // @ C019_ACTION_BERZERK
+	k20_ChampionActionFireball = 20, // @ C020_ACTION_FIREBALL
+	k21_ChampionActionDispel = 21, // @ C021_ACTION_DISPELL
+	k22_ChampionActionConfuse = 22, // @ C022_ACTION_CONFUSE
+	k23_ChampionActionLightning = 23, // @ C023_ACTION_LIGHTNING
+	k24_ChampionActionDisrupt = 24, // @ C024_ACTION_DISRUPT
+	k25_ChampionActionMelee = 25, // @ C025_ACTION_MELEE
+	k26_ChampionActionX_C026 = 26, // @ C026_ACTION_X
+	k27_ChampionActionInvoke = 27, // @ C027_ACTION_INVOKE
+	k28_ChampionActionSlash = 28, // @ C028_ACTION_SLASH
+	k29_ChampionActionCleave = 29, // @ C029_ACTION_CLEAVE
+	k30_ChampionActionBash = 30, // @ C030_ACTION_BASH
+	k31_ChampionActionStun = 31, // @ C031_ACTION_STUN
+	k32_ChampionActionShoot = 32, // @ C032_ACTION_SHOOT
+	k33_ChampionActionSpellshield = 33, // @ C033_ACTION_SPELLSHIELD
+	k34_ChampionActionFireshield = 34, // @ C034_ACTION_FIRESHIELD
+	k35_ChampionActionFluxcage = 35, // @ C035_ACTION_FLUXCAGE
+	k36_ChampionActionHeal = 36, // @ C036_ACTION_HEAL
+	k37_ChampionActionCalm = 37, // @ C037_ACTION_CALM
+	k38_ChampionActionLight = 38, // @ C038_ACTION_LIGHT
+	k39_ChampionActionWindow = 39, // @ C039_ACTION_WINDOW
+	k40_ChampionActionSpit = 40, // @ C040_ACTION_SPIT
+	k41_ChampionActionBrandish = 41, // @ C041_ACTION_BRANDISH
+	k42_ChampionActionThrow = 42, // @ C042_ACTION_THROW
+	k43_ChampionActionFuse = 43, // @ C043_ACTION_FUSE
+	k255_ChampionActionNone = 255 // @ C255_ACTION_NONE
 };
 
 
@@ -386,7 +386,7 @@ public:
 			_attributes &= ~flag;
 		}
 	}
-	void clearAttributes(ChampionAttribute attribute = kChampionAttributNone) { _attributes = attribute; }
+	void clearAttributes(ChampionAttribute attribute = k0x0000_ChampionAttributNone) { _attributes = attribute; }
 
 	uint16 getWounds() { return _wounds; }
 	void setWoundsFlag(ChampionWound flag, bool value) {
@@ -397,7 +397,7 @@ public:
 		}
 	}
 	uint16 getWoundsFlag(ChampionWound wound) { return _wounds & wound; }
-	void clearWounds() { _wounds = kChampionWoundNone; }
+	void clearWounds() { _wounds = k0x0000_ChampionWoundNone; }
 	void resetToZero() { // oh boy > . <
 		for (int16 i = 0; i < 30; ++i)
 			_slots[i] = Thing::_none;
@@ -409,7 +409,7 @@ public:
 		memset(_title, '\0', 20);
 		_dir = kDirNorth;
 		_cell = k0_ViewCellFronLeft;
-		_actionIndex = kChampionActionN;
+		_actionIndex = k0_ChampionActionN;
 		_symbolStep = 0;
 		memset(_symbols, '\0', 5);
 		_directionMaximumDamageReceived = _maximumDamageReceived = _poisonEventCount = _enableActionEventIndex = 0;
@@ -435,18 +435,18 @@ class ChampionMan {
 	uint16 handSlotIndex(uint16 slotBoxIndex);// @ M70_HAND_SLOT_INDEX
 public:
 	Champion _champions[4];
-	uint16 _partyChampionCount;	// @ G0305_ui_PartyChampionCount
-	bool _partyDead; // @ G0303_B_PartyDead
-	Thing _leaderHandObject; // @ G0414_T_LeaderHandObject
-	ChampionIndex _leaderIndex;	// @ G0411_i_LeaderIndex
-	uint16 _candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal
-	bool _partyIsSleeping; // @ G0300_B_PartyIsSleeping
-	uint16 _actingChampionOrdinal; // @ G0506_ui_ActingChampionOrdinal
-	IconIndice _leaderHandObjectIconIndex; // @ G0413_i_LeaderHandObjectIconIndex
-	bool _leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded
-	Party _party; // @ G0407_s_Party
-	ChampionIndex _magicCasterChampionIndex; // @ G0514_i_MagicCasterChampionIndex
-	bool _mousePointerHiddenToDrawChangedObjIconOnScreen; // @ G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen
+	uint16 _g305_partyChampionCount;	// @ G0305_ui_PartyChampionCount
+	bool _303_partyDead; // @ G0303_B_PartyDead
+	Thing _414_leaderHandObject; // @ G0414_T_LeaderHandObject
+	ChampionIndex _g411_leaderIndex;	// @ G0411_i_LeaderIndex
+	uint16 _g299_candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal
+	bool _g300_partyIsSleeping; // @ G0300_B_PartyIsSleeping
+	uint16 _g506_actingChampionOrdinal; // @ G0506_ui_ActingChampionOrdinal
+	IconIndice _g413_leaderHandObjectIconIndex; // @ G0413_i_LeaderHandObjectIconIndex
+	bool _g415_leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded
+	Party _g407_party; // @ G0407_s_Party
+	ChampionIndex _g514_magicCasterChampionIndex; // @ G0514_i_MagicCasterChampionIndex
+	bool _g420_mousePointerHiddenToDrawChangedObjIconOnScreen; // @ G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen
 
 	explicit ChampionMan(DMEngine *vm);
 	void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index bf584fd..adc842b 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -170,10 +170,10 @@ void DMEngine::startGame() {
 	_stopPressingMouth = false;
 	_highlightBoxInversionRequested = false;
 	_eventMan->_highlightBoxEnabled = false;
-	_championMan->_partyIsSleeping = false;
-	_championMan->_actingChampionOrdinal = indexToOrdinal(kChampionNone);
+	_championMan->_g300_partyIsSleeping = false;
+	_championMan->_g506_actingChampionOrdinal = indexToOrdinal(kM1_ChampionNone);
 	_menuMan->_actionAreaContainsIcons = true;
-	_eventMan->_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kChampionNone);
+	_eventMan->_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kM1_ChampionNone);
 
 	_eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface;
 	_eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement;
@@ -251,7 +251,7 @@ void DMEngine::gameloop() {
 		_eventMan->processCommandQueue();
 		//} while (!_stopWaitingForPlayerInput || !_gameTimeTicking);
 
-		if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) {
+		if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
 			Box box(0, 224, 0, 126);
 			_displayMan->clearScreenBox(k0_ColorBlack, box, g296_DungeonViewport); // dummy code
 			_displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY);
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 1adb396..82fd07c 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -479,28 +479,28 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
 	ChampionMan &cm = *_vm->_championMan;
 	ChampionIndex leaderIndex;
 
-	if ((cm._leaderIndex == champIndex) || ((champIndex != kChampionNone) && !cm._champions[champIndex]._currHealth))
+	if ((cm._g411_leaderIndex == champIndex) || ((champIndex != kM1_ChampionNone) && !cm._champions[champIndex]._currHealth))
 		return;
 
-	if (cm._leaderIndex != kChampionNone) {
-		leaderIndex = cm._leaderIndex;
-		cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeLoad, true);
-		cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeNameTitle, true);
-		cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject);
-		cm._leaderIndex = kChampionNone;
+	if (cm._g411_leaderIndex != kM1_ChampionNone) {
+		leaderIndex = cm._g411_leaderIndex;
+		cm._champions[leaderIndex].setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
+		cm._champions[leaderIndex].setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
+		cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._414_leaderHandObject);
+		cm._g411_leaderIndex = kM1_ChampionNone;
 		cm.drawChampionState(leaderIndex);
 	}
-	if (champIndex == kChampionNone) {
-		cm._leaderIndex = kChampionNone;
+	if (champIndex == kM1_ChampionNone) {
+		cm._g411_leaderIndex = kM1_ChampionNone;
 		return;
 	}
-	cm._leaderIndex = champIndex;
-	Champion *champion = &cm._champions[cm._leaderIndex];
+	cm._g411_leaderIndex = champIndex;
+	Champion *champion = &cm._champions[cm._g411_leaderIndex];
 	champion->_dir = _vm->_dungeonMan->_currMap._partyDir;
-	cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject);
-	if (_vm->indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) {
-		champion->setAttributeFlag(kChampionAttributeIcon, true);
-		champion->setAttributeFlag(kChampionAttributeNameTitle, true);
+	cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._414_leaderHandObject);
+	if (_vm->indexToOrdinal(champIndex) != cm._g299_candidateChampionOrdinal) {
+		champion->setAttributeFlag(k0x0400_ChampionAttributeIcon, true);
+		champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
 		cm.drawChampionState(champIndex);
 	}
 }
@@ -521,10 +521,10 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 	CurrMapData &currMap = _vm->_dungeonMan->_currMap;
 
 	if (dunMan._squareAheadElement == kElementTypeDoorFront) {
-		if (champMan._leaderIndex == kChampionNone)
+		if (champMan._g411_leaderIndex == kM1_ChampionNone)
 			return;
 
-		if (champMan._leaderEmptyHanded) {
+		if (champMan._g415_leaderEmptyHanded) {
 			int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir];
 			int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir];
 
@@ -540,7 +540,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 		}
 	}
 
-	if (champMan._leaderEmptyHanded) {
+	if (champMan._g415_leaderEmptyHanded) {
 		for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k5_ViewCellDoorButtonOrWallOrn; viewCell++) {
 			if (dunMan._dungeonViewClickableBoxes[viewCell].isPointInside(Common::Point(posX, posY - 33))) {
 				if (viewCell == k5_ViewCellDoorButtonOrWallOrn) {
@@ -554,7 +554,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 			}
 		}
 	} else {
-		Thing thing = champMan._leaderHandObject;
+		Thing thing = champMan._414_leaderHandObject;
 		uint16 *rawThingPointer = dunMan.getThingData(thing);
 		if (dunMan._squareAheadElement == kElementTypeWall) {
 			for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k1_ViewCellFrontRight; ++viewCell) {
@@ -571,15 +571,15 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 					if (dunMan._isFacingFountain) {
 						uint16 iconIndex = _vm->_objectMan->getIconIndex(thing);
 						int16 weight = dunMan.getObjectWeight(thing);
-						if ((iconIndex >= kIconIndiceJunkWater) && (iconIndex <= kIconIndiceJunkWaterSkin)) {
+						if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
 							((Junk*)rawThingPointer)->setChargeCount(3);
-						} else if (iconIndex == kIconIndicePotionEmptyFlask) {
+						} else if (iconIndex == k195_IconIndicePotionEmptyFlask) {
 							((Potion*)rawThingPointer)->setType(kPotionTypeWaterFlask);
 						} else {
 							goto T0377019;
 						}
 						champMan.drawChangedObjectIcons();
-						champMan._champions[champMan._leaderIndex]._load += dunMan.getObjectWeight(thing) - weight;
+						champMan._champions[champMan._g411_leaderIndex]._load += dunMan.getObjectWeight(thing) - weight;
 					}
 T0377019:
 					commandProcessType80ClickInDungeonViewTouchFrontWall();
@@ -604,15 +604,15 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	CurrMapData &currMap = _vm->_dungeonMan->_currMap;
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 
-	uint16 championIndex = champMan._partyChampionCount - 1;
+	uint16 championIndex = champMan._g305_partyChampionCount - 1;
 	Champion *champ = &champMan._champions[championIndex];
 	if (commandType == kCommandClickInPanelCancel) {
-		invMan.toggleInventory(kChampionCloseInventory);
-		champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kChampionNone);
-		if (champMan._partyChampionCount == 1) {
-			commandSetLeader(kChampionNone);
+		invMan.toggleInventory(k4_ChampionCloseInventory);
+		champMan._g299_candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
+		if (champMan._g305_partyChampionCount == 1) {
+			commandSetLeader(kM1_ChampionNone);
 		}
-		champMan._partyChampionCount--;
+		champMan._g305_partyChampionCount--;
 		Box box;
 		box._y1 = 0;
 		box._y2 = 28 + 1;
@@ -620,17 +620,17 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 		box._x2 = box._x1 + 66 + 1;
 		dispMan._g578_useByteBoxCoordinates = false;
 		dispMan.clearScreenBox(k0_ColorBlack, box);
-		dispMan.clearScreenBox(k0_ColorBlack, gBoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._partyDir) * 2]);
+		dispMan.clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._partyDir) * 2]);
 		warning("F0457_START_DrawEnabledMenus_CPSF");
 		warning("F0078_MOUSE_ShowPointer");
 		return;
 	}
 
-	champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kChampionNone);
+	champMan._g299_candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 	int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir];
 	int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir];
 
-	for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) {
+	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
 		Thing thing = champ->getSlot((ChampionSlot)slotIndex);
 		if (thing != Thing::_none) {
 			warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList");
@@ -651,25 +651,25 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 
 		for (uint16 i = 0; i < 12; i++) {
 			uint16 statIndex = _vm->_rnd->getRandomNumber(7);
-			champ->getStatistic((ChampionStatisticType)statIndex, kChampionStatCurrent)++; // returns reference
-			champ->getStatistic((ChampionStatisticType)statIndex, kChampionStatMaximum)++; // returns reference
+			champ->getStatistic((ChampionStatisticType)statIndex, k1_ChampionStatCurrent)++; // returns reference
+			champ->getStatistic((ChampionStatisticType)statIndex, k0_ChampionStatMaximum)++; // returns reference
 		}
 	}
 
-	if (champMan._partyChampionCount == 1) {
+	if (champMan._g305_partyChampionCount == 1) {
 		warning("MISSING CODE: setting time, G0362_l_LastPartyMovementTime , G0313_ul_GameTime");
-		commandSetLeader(kChampionFirst);
-		_vm->_menuMan->setMagicCasterAndDrawSpellArea(kChampionFirst);
+		commandSetLeader(k0_ChampionFirst);
+		_vm->_menuMan->setMagicCasterAndDrawSpellArea(k0_ChampionFirst);
 	} else {
-		_vm->_menuMan->drawSpellAreaControls(champMan._magicCasterChampionIndex);
+		_vm->_menuMan->drawSpellAreaControls(champMan._g514_magicCasterChampionIndex);
 	}
 
 	warning("MISSING CODE: F0051_TEXT_MESSAGEAREA_PrintLineFeed");
-	Color champColor = gChampionColor[championIndex]; // unreferenced because of missing code
+	Color champColor = g46_ChampionColor[championIndex]; // unreferenced because of missing code
 	warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage");
 	warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage");
 
-	invMan.toggleInventory(kChampionCloseInventory);
+	invMan.toggleInventory(k4_ChampionCloseInventory);
 	warning("MISSING CODE: F0457_START_DrawEnabledMenus_CPSF");
 	warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal");
 }
@@ -681,14 +681,14 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) {
 	CommandType commandType;
 	switch (invMan._panelContent) {
 	case kPanelContentChest:
-		if (champMan._leaderIndex == kChampionNone) // if no leader
+		if (champMan._g411_leaderIndex == kM1_ChampionNone) // if no leader
 			return;
 		commandType = getCommandTypeFromMouseInput(gMouseInput_PanelChest, Common::Point(x, y), kLeftMouseButton);
 		if (commandType != kCommandNone)
 			warning("MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox");
 		break;
 	case kPanelContentResurrectReincarnate:
-		if (!champMan._leaderEmptyHanded)
+		if (!champMan._g415_leaderEmptyHanded)
 			break;
 		commandType = getCommandTypeFromMouseInput(gMouseInput_PanelResurrectReincarnateCancel, Common::Point(x, y), kLeftMouseButton);
 		if (commandType != kCommandNone)
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 11ccd94..0779a7e 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -55,29 +55,29 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	EventManager &em = *_vm->_eventMan;
 	DisplayMan &dm = *_vm->_displayMan;
 
-	if ((championIndex != kChampionCloseInventory) && !cm._champions[championIndex]._currHealth)
+	if ((championIndex != k4_ChampionCloseInventory) && !cm._champions[championIndex]._currHealth)
 		return;
 	if (_vm->_pressingEye || _vm->_pressingMouth)
 		return;
 	_vm->_stopWaitingForPlayerInput = true;
 	int16 invChampOrdinal = _inventoryChampionOrdinal; // copy, as the original will be edited
 	if (_vm->indexToOrdinal(championIndex) == invChampOrdinal) {
-		championIndex = kChampionCloseInventory;
+		championIndex = k4_ChampionCloseInventory;
 	}
 
 	Champion *champion;
 	if (invChampOrdinal) {
-		_inventoryChampionOrdinal = _vm->indexToOrdinal(kChampionNone);
+		_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 		closeChest();
 		champion = &cm._champions[_vm->ordinalToIndex(invChampOrdinal)];
-		if (champion->_currHealth && !cm._candidateChampionOrdinal) {
-			champion->setAttributeFlag(kChampionAttributeStatusBox, true);
+		if (champion->_currHealth && !cm._g299_candidateChampionOrdinal) {
+			champion->setAttributeFlag(k0x1000_ChampionAttributeStatusBox, true);
 			cm.drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
 		}
-		if (cm._partyIsSleeping) {
+		if (cm._g300_partyIsSleeping) {
 			return;
 		}
-		if (championIndex == kChampionCloseInventory) {
+		if (championIndex == k4_ChampionCloseInventory) {
 			em._refreshMousePointerInMainLoop = true;
 			_vm->_menuMan->drawMovementArrows();
 			em._secondaryMouseInput = gSecondaryMouseInput_Movement;
@@ -97,23 +97,23 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	int16 w = dm.getWidth(k17_InventoryGraphicIndice);
 	int16 h = dm.getHeight(k17_InventoryGraphicIndice);
 	dm.blitToScreen(dm.getBitmap(k17_InventoryGraphicIndice), w, 0, 0, 0, w, 0, h, k255_ColorNoTransparency, g296_DungeonViewport);
-	if (cm._candidateChampionOrdinal) {
+	if (cm._g299_candidateChampionOrdinal) {
 		dm.clearScreenBox(k12_ColorDarkestGray, gBoxFloppyZzzCross, g296_DungeonViewport);
 	}
 	_vm->_textMan->printToViewport(5, 116, k13_ColorLightestGray, "HEALTH");
 	_vm->_textMan->printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
 	_vm->_textMan->printToViewport(5, 132, k13_ColorLightestGray, "MANA");
 
-	for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) {
+	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
 		_vm->_championMan->drawSlot(championIndex, (ChampionSlot)slotIndex);
 	}
 
-	champion->setAttributeFlag(kChampionAttributeViewport, true);
-	champion->setAttributeFlag(kChampionAttributeStatusBox, true);
-	champion->setAttributeFlag(kChampionAttributePanel, true);
-	champion->setAttributeFlag(kChampionAttributeLoad, true);
-	champion->setAttributeFlag(kChampionAttributeStatistics, true);
-	champion->setAttributeFlag(kChampionAttributeNameTitle, true);
+	champion->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
+	champion->setAttributeFlag(k0x1000_ChampionAttributeStatusBox, true);
+	champion->setAttributeFlag(k0x0800_ChampionAttributePanel, true);
+	champion->setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
+	champion->setAttributeFlag(k0x0100_ChampionAttributeStatistics, true);
+	champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
 
 	cm.drawChampionState(championIndex);
 	em._mousePointerBitmapUpdated = true;
@@ -183,12 +183,12 @@ void InventoryMan::drawPanel() {
 	closeChest(); // possibility of BUG0_48
 
 	ChampionMan &cm = *_vm->_championMan;
-	if (cm._candidateChampionOrdinal) {
+	if (cm._g299_candidateChampionOrdinal) {
 		drawPanelResurrectReincarnate();
 		return;
 	}
 
-	Thing thing = cm._champions[_vm->ordinalToIndex(_inventoryChampionOrdinal)].getSlot(kChampionSlotActionHand);
+	Thing thing = cm._champions[_vm->ordinalToIndex(_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand);
 
 	_panelContent = kPanelContentFoodWaterPoisoned;
 	switch (thing.getType()) {
@@ -308,7 +308,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 
 	_openChest = thingToOpen;
 	if (!isPressingEye) {
-		objMan.drawIconInSlotBox(kSlotBoxInventoryActionHand, kIconIndiceContainerChestOpen);
+		objMan.drawIconInSlotBox(kSlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen);
 	}
 	dispMan.blitToScreen(dispMan.getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, gBoxPanel, k8_ColorRed);
 
@@ -325,7 +325,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 		thing = _vm->_dungeonMan->getNextThing(thing);
 	}
 	while (chestSlotIndex < 8) {
-		objMan.drawIconInSlotBox(chestSlotIndex + kSlotBoxChestFirstSlot, kIconIndiceNone);
+		objMan.drawIconInSlotBox(chestSlotIndex + kSlotBoxChestFirstSlot, kM1_IconIndiceNone);
 		_chestSlots[chestSlotIndex++] = Thing::_none;
 	}
 }
@@ -448,15 +448,15 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 
 		char *descString = nullptr;
 		char str[40];
-		if (iconIndex == kIconIndiceJunkChampionBones) {
+		if (iconIndex == k147_IconIndiceJunkChampionBones) {
 			strcpy(str, champMan._champions[((Junk*)rawThingPtr)->getChargeCount()]._name);  // TODO: localization
 			strcat(str, " "); // TODO: localization
 			strcat(str, objMan._objectNames[iconIndex]);  // TODO: localization
 
 			descString = str;
 		} else if ((thingType == kPotionThingType)
-				   && (iconIndex != kIconIndicePotionWaterFlask)
-				   && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_inventoryChampionOrdinal), kChampionSkillPriest) > 1)) {
+				   && (iconIndex != k163_IconIndicePotionWaterFlask)
+				   && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
 			str[0] = '_' + ((Potion*)rawThingPtr)->getPower() / 40;
 			str[1] = ' ';
 			str[2] = '\0';
@@ -480,8 +480,8 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			potentialAttribMask = kDescriptionMaskCursed | kDescriptionMaskPoisoned | kDescriptionMaskBroken;
 			Weapon *weapon = (Weapon*)rawThingPtr;
 			actualAttribMask = (weapon->getCursed() << 3) | (weapon->getPoisoned() << 1) | (weapon->getBroken() << 2);
-			if ((iconIndex >= kIconIndiceWeaponTorchUnlit)
-				&& (iconIndex <= kIconIndiceWeaponTorchLit)
+			if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit)
+				&& (iconIndex <= k7_IconIndiceWeaponTorchLit)
 				&& (weapon->getChargeCount() == 0)) {
 				drawPanelObjectDescriptionString("(BURNT OUT)"); // TODO: localization
 			}
@@ -501,7 +501,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		}
 		case kJunkThingType: {
 			Junk *junk = (Junk*)rawThingPtr;
-			if ((iconIndex >= kIconIndiceJunkWater) && (iconIndex <= kIconIndiceJunkWaterSkin)) {
+			if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
 				potentialAttribMask = 0;
 				switch (junk->getChargeCount()) {
 				case 0:
@@ -518,7 +518,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 					break;
 				}
 				drawPanelObjectDescriptionString(descString);
-			} else if ((iconIndex >= kIconIndiceJunkCompassNorth) && (iconIndex <= kIconIndiceJunkCompassWest)) {
+			} else if ((iconIndex >= k0_IconIndiceJunkCompassNorth) && (iconIndex <= k3_IconIndiceJunkCompassWest)) {
 				potentialAttribMask = 0;
 				strcpy(str, "PARTY FACING "); // TODO: localization
 				static char* directionName[4] = {"NORTH", "EAST", "SOUTH", "WEST"}; // G0430_apc_DirectionNames // TODO: localization
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 463e02d..42f8bad 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -44,8 +44,8 @@ LoadgameResponse LoadsaveMan::loadgame() {
 
 	if (newGame) {
 		_vm->_restartGameAllowed = false;
-		cm._partyChampionCount = 0;
-		cm._leaderHandObject = Thing::_none;
+		cm._g305_partyChampionCount = 0;
+		cm._414_leaderHandObject = Thing::_none;
 		_vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536);
 	} else {
 		assert(false);
@@ -61,7 +61,7 @@ LoadgameResponse LoadsaveMan::loadgame() {
 		assert(false);
 		// MISSING CODE: load game
 	}
-	cm._partyDead = false;
+	cm._303_partyDead = false;
 	return kLoadgameSuccess;
 }
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 74ca0ac..19912ad 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -68,11 +68,11 @@ void MenuMan::drawMovementArrows() {
 }
 void MenuMan::clearActingChampion() {
 	ChampionMan &cm = *_vm->_championMan;
-	if (cm._actingChampionOrdinal) {
-		cm._actingChampionOrdinal--;
-		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true);
-		cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal);
-		cm._actingChampionOrdinal = _vm->indexToOrdinal(kChampionNone);
+	if (cm._g506_actingChampionOrdinal) {
+		cm._g506_actingChampionOrdinal--;
+		cm._champions[cm._g506_actingChampionOrdinal].setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
+		cm.drawChampionState((ChampionIndex)cm._g506_actingChampionOrdinal);
+		cm._g506_actingChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 		_refreshActionArea = true;
 	}
 }
@@ -94,10 +94,10 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) {
 		return;
 	}
 	byte *bitmapIcon = dm._g74_tmpBitmap;
-	Thing thing = champion.getSlot(kChampionSlotActionHand);
+	Thing thing = champion.getSlot(k1_ChampionSlotActionHand);
 	IconIndice iconIndex;
 	if (thing == Thing::_none) {
-		iconIndex = kIconIndiceActionEmptyHand;
+		iconIndex = k201_IconIndiceActionEmptyHand;
 	} else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
 		iconIndex = _vm->_objectMan->getIconIndex(thing);
 	} else {
@@ -114,13 +114,13 @@ T0386006:
 	box2._y1 = 95;
 	box2._y2 = 110 + 1;
 	dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2);
-	if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) {
+	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) {
 		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 	}
 }
 
 void MenuMan::drawDisabledMenu() {
-	if (!_vm->_championMan->_partyIsSleeping) {
+	if (!_vm->_championMan->_g300_partyIsSleeping) {
 		warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		if (_vm->_inventoryMan->_inventoryChampionOrdinal) {
@@ -139,39 +139,39 @@ void MenuMan::drawDisabledMenu() {
 void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
 	ChampionMan &champMan = *_vm->_championMan;
 
-	if (!champMan._partyChampionCount)
+	if (!champMan._g305_partyChampionCount)
 		return;
 
 	Champion *champ = nullptr;
-	if (champMan._partyIsSleeping || champMan._candidateChampionOrdinal) {
-		if (champMan._actingChampionOrdinal) {
+	if (champMan._g300_partyIsSleeping || champMan._g299_candidateChampionOrdinal) {
+		if (champMan._g506_actingChampionOrdinal) {
 			clearActingChampion();
 			return;
 		}
-		if (!champMan._candidateChampionOrdinal)
+		if (!champMan._g299_candidateChampionOrdinal)
 			return;
 	} else {
 		champ = champMan._champions;
-		int16 champIndex = kChampionFirst;
+		int16 champIndex = k0_ChampionFirst;
 
 		do {
-			if ((champIndex != champMan._leaderIndex)
-				&& (_vm->indexToOrdinal(champIndex) != champMan._actingChampionOrdinal)
+			if ((champIndex != champMan._g411_leaderIndex)
+				&& (_vm->indexToOrdinal(champIndex) != champMan._g506_actingChampionOrdinal)
 				&& (champ->_maximumDamageReceived)
 				&& (champ->_dir != champ->_directionMaximumDamageReceived)) {
 
 				champ->_dir = (direction)champ->_directionMaximumDamageReceived;
-				champ->setAttributeFlag(kChampionAttributeIcon, true);
+				champ->setAttributeFlag(k0x0400_ChampionAttributeIcon, true);
 				champMan.drawChampionState((ChampionIndex)champIndex);
 			}
 			champ->_maximumDamageReceived = 0;
 			champ++;
 			champIndex++;
-		} while (champIndex < champMan._partyChampionCount);
+		} while (champIndex < champMan._g305_partyChampionCount);
 	}
 
 	if (_refreshActionArea) {
-		if (!champMan._actingChampionOrdinal) {
+		if (!champMan._g506_actingChampionOrdinal) {
 			if (_actionDamage) {
 				warning("MISSING CODE: F0385_MENUS_DrawActionDamage");
 				_actionDamage = 0;
@@ -181,8 +181,8 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
 			}
 		} else {
 			_actionAreaContainsIcons = false;
-			champ->setAttributeFlag(kChampionAttributeActionHand, true);
-			champMan.drawChampionState((ChampionIndex)_vm->ordinalToIndex(champMan._actingChampionOrdinal));
+			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
+			champMan.drawChampionState((ChampionIndex)_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal));
 			warning("MISSING CODE: F0387_MENUS_DrawActionArea");
 		}
 	}
@@ -200,16 +200,16 @@ void MenuMan::drawActionArea() {
 	dispMan._g578_useByteBoxCoordinates = false;
 	dispMan.clearScreenBox(k0_ColorBlack, gBoxActionArea);
 	if (_actionAreaContainsIcons) {
-		for (uint16 champIndex = kChampionFirst; champIndex < champMan._partyChampionCount; ++champIndex)
+		for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._g305_partyChampionCount; ++champIndex)
 			drawActionIcon((ChampionIndex)champIndex);
-	} else if (champMan._actingChampionOrdinal) {
+	} else if (champMan._g506_actingChampionOrdinal) {
 		Box box = gBoxActionArea3ActionMenu;
-		if (_actionList._actionIndices[2] == kChampionActionNone)
+		if (_actionList._actionIndices[2] == k255_ChampionActionNone)
 			box = gBoxActionArea2ActionMenu;
-		if (_actionList._actionIndices[1] == kChampionActionNone)
+		if (_actionList._actionIndices[1] == k255_ChampionActionNone)
 			box = gBoxActionArea1ActionMenu;
 		dispMan.blitToScreen(dispMan.getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, box, k255_ColorNoTransparency);
-		textMan.printWithTrailingSpacesToScreen(235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._actingChampionOrdinal)]._name,
+		textMan.printWithTrailingSpacesToScreen(235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name,
 												kChampionNameMaximumLength);
 		for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) {
 			textMan.printWithTrailingSpacesToScreen(241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
@@ -232,7 +232,7 @@ const char *gChampionActionNames[44] = {
 	"BRANDISH", "THROW", "FUSE"};
 
 const char* MenuMan::getActionName(ChampionAction actionIndex) {
-	return (actionIndex == kChampionActionNone) ? "" : gChampionActionNames[actionIndex];
+	return (actionIndex == k255_ChampionActionNone) ? "" : gChampionActionNames[actionIndex];
 }
 
 
@@ -249,9 +249,9 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
 		champCurrHealth[i] = champMan._champions[i]._currHealth;
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 	dispMan.clearScreenBox(k0_ColorBlack, gBoxSpellAreaControls);
-	int16 champCount = champMan._partyChampionCount;
+	int16 champCount = champMan._g305_partyChampionCount;
 	switch (champIndex) {
-	case kChampionFirst:
+	case k0_ChampionFirst:
 		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		textMan.printTextToScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		if (champCount) {
@@ -272,14 +272,14 @@ labelChamp3:
 			}
 		}
 		break;
-	case kChampionSecond:
+	case k1_ChampionSecond:
 		if (champCurrHealth[0]) {
 			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		}
 		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		textMan.printTextToScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		goto labelChamp2;
-	case kChampionThird:
+	case k2_ChampionThird:
 		if (champCurrHealth[0]) {
 			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		}
@@ -289,7 +289,7 @@ labelChamp3:
 		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		textMan.printTextToScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		goto labelChamp3;
-	case kChampionFourth:
+	case k3_ChampionFourth:
 		if (champCurrHealth[0]) {
 			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		}
@@ -312,7 +312,7 @@ labelChamp3:
 void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 
-	Champion &champ = _vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
+	Champion &champ = _vm->_championMan->_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
 	if (spellAreaBitmapLine == kSpellAreaAvailableSymbols) {
 		dispMan._g578_useByteBoxCoordinates = false;
 		dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 12, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, k255_ColorNoTransparency);
@@ -340,16 +340,16 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	ChampionMan &champMan = *_vm->_championMan;
 	DisplayMan &dispMan = *_vm->_displayMan;
 
-	if ((champIndex == champMan._magicCasterChampionIndex)
-		|| ((champIndex != kChampionNone) && !champMan._champions[champIndex]._currHealth))
+	if ((champIndex == champMan._g514_magicCasterChampionIndex)
+		|| ((champIndex != kM1_ChampionNone) && !champMan._champions[champIndex]._currHealth))
 		return;
-	if (champMan._magicCasterChampionIndex == kChampionNone) {
+	if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) {
 		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 		dispMan.blitToScreen(dispMan.getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, gBoxSpellArea);
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 	}
-	if (champIndex == kChampionNone) {
-		champMan._magicCasterChampionIndex = kChampionNone;
+	if (champIndex == kM1_ChampionNone) {
+		champMan._g514_magicCasterChampionIndex = kM1_ChampionNone;
 		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 		dispMan._g578_useByteBoxCoordinates = false;
 		dispMan.clearScreenBox(k0_ColorBlack, gBoxSpellArea);
@@ -357,7 +357,7 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
 		return;
 	}
 
-	champMan._magicCasterChampionIndex = (ChampionIndex)champIndex;
+	champMan._g514_magicCasterChampionIndex = (ChampionIndex)champIndex;
 	buildSpellAreaLine(kSpellAreaAvailableSymbols);
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 	drawSpellAreaControls((ChampionIndex)champIndex);
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index a8df735..b591872 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -43,7 +43,7 @@ public:
 	ActionList() {
 		for (uint16 i = 0; i < 3; ++i) {
 			_minimumSkillLevel[i] = 0;
-			_actionIndices[i] = kChampionActionNone;
+			_actionIndices[i] = k255_ChampionActionNone;
 		}
 	}
 }; // @ ACTION_LIST
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 1511146..0aca699 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -44,7 +44,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 
 
 	bool atLeastOneSensorWasTriggered = false;
-	Thing leaderHandObject = champMan._leaderHandObject;
+	Thing leaderHandObject = champMan._414_leaderHandObject;
 	int16 sensorCountToProcessPerCell[4];
 	uint16 cell;
 	for (cell = kCellNorthWest; cell < kCellSouthWest; ++cell) {
@@ -73,7 +73,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 			SensorType sensorType = sensor->getType();
 			if (sensorType == kSensorDisabled)
 				goto T0275058_ProceedToNextThing;
-			if ((champMan._leaderIndex == kChampionNone) && (sensorType != kSensorWallChampionPortrait))
+			if ((champMan._g411_leaderIndex == kM1_ChampionNone) && (sensorType != kSensorWallChampionPortrait))
 				goto T0275058_ProceedToNextThing;
 			if (cell != cellParam)
 				goto T0275058_ProceedToNextThing;
@@ -88,7 +88,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 				}
 				break;
 			case kSensorWallOrnClickWithAnyObj:
-				doNotTriggerSensor = (champMan._leaderEmptyHanded != sensor->getRevertEffectA());
+				doNotTriggerSensor = (champMan._g415_leaderEmptyHanded != sensor->getRevertEffectA());
 				break;
 			case kSensorWallOrnClickWithSpecObjRemovedSensor:
 			case kSensorWallOrnClickWithSpecObjRemovedRotateSensors:
@@ -111,13 +111,13 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 			case kSensorWallObjGeneratorRotateSensors:
 				if (sensorCountToProcessPerCell[cell])
 					goto T0275058_ProceedToNextThing;
-				doNotTriggerSensor = !champMan._leaderEmptyHanded;
+				doNotTriggerSensor = !champMan._g415_leaderEmptyHanded;
 				if (!doNotTriggerSensor) {
 					warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect");
 				}
 				break;
 			case kSensorWallSingleObjStorageRotateSensors:
-				if (champMan._leaderEmptyHanded) {
+				if (champMan._g415_leaderEmptyHanded) {
 					warning("MISSING CODE: F0273_SENSOR_GetObjectOfTypeInCell");
 					warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList");
 					warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand");
@@ -128,7 +128,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 					leaderHandObject = Thing::_none;
 				}
 				warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect");
-				if ((sensorEffect == kSensorEffHold) && !champMan._leaderEmptyHanded) {
+				if ((sensorEffect == kSensorEffHold) && !champMan._g415_leaderEmptyHanded) {
 					doNotTriggerSensor = true;
 				} else {
 					doNotTriggerSensor = false;
@@ -164,7 +164,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 				if (sensor->getAudibleA()) {
 					warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 				}
-				if (!champMan._leaderEmptyHanded &&
+				if (!champMan._g415_leaderEmptyHanded &&
 					((sensorType == kSensorWallOrnClickWithSpecObjRemoved) ||
 					(sensorType == kSensorWallOrnClickWithSpecObjRemovedRotateSensors) ||
 					 (sensorType == kSensorWallOrnClickWithSpecObjRemovedSensor))) {
@@ -174,7 +174,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 					leaderHandObject = Thing::_none;
 				} else {
 					warning("MISSING CODE: (leaderHandObject = F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator(sensorData)");
-					if (champMan._leaderEmptyHanded && (sensorType == kSensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_none)) {
+					if (champMan._g415_leaderEmptyHanded && (sensorType == kSensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_none)) {
 						warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand");
 					}
 				}
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index dd35502..ae67904 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -123,7 +123,7 @@ void ObjectMan::loadObjectNames() {
 
 IconIndice ObjectMan::getObjectType(Thing thing) {
 	if (thing == Thing::_none)
-		return kIconIndiceNone;
+		return kM1_IconIndiceNone;
 
 	int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing);
 	if (objectInfoIndex != -1) {
@@ -137,41 +137,41 @@ byte gChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3,
 IconIndice ObjectMan::getIconIndex(Thing thing) {
 	IconIndice iconIndex = getObjectType(thing);
 
-	if ((iconIndex != kIconIndiceNone) &&
-		(((iconIndex < kIconIndiceWeaponDagger) && (iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error
-		((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) ||
-		 (iconIndex == kIconIndicePotionEmptyFlask))
+	if ((iconIndex != kM1_IconIndiceNone) &&
+		(((iconIndex < k32_IconIndiceWeaponDagger) && (iconIndex >= k0_IconIndiceJunkCompassNorth)) || // < instead of <= is no error
+		((iconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (iconIndex <= k163_IconIndicePotionWaterFlask)) ||
+		 (iconIndex == k195_IconIndicePotionEmptyFlask))
 		) {
 		uint16 *rawType = _vm->_dungeonMan->getThingData(thing);
 		switch (iconIndex) {
-		case kIconIndiceJunkCompassNorth:
+		case k0_IconIndiceJunkCompassNorth:
 			iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_currMap._partyDir);
 			break;
-		case kIconIndiceWeaponTorchUnlit: {
+		case k4_IconIndiceWeaponTorchUnlit: {
 			Weapon weapon(rawType);
 			if (weapon.isLit()) {
 				iconIndex = (IconIndice)(iconIndex + gChargeCountToTorchType[weapon.getChargeCount()]);
 			}
 			break;
 		}
-		case kIconIndiceScrollOpen:
+		case k30_IconIndiceScrollOpen:
 			if (Scroll(rawType).getClosed()) {
 				iconIndex = (IconIndice)(iconIndex + 1);
 			}
 			break;
-		case kIconIndiceJunkWater:
-		case kIconIndiceJunkIllumuletUnequipped:
-		case kIconIndiceJunkJewelSymalUnequipped:
+		case k8_IconIndiceJunkWater:
+		case k12_IconIndiceJunkIllumuletUnequipped:
+		case k10_IconIndiceJunkJewelSymalUnequipped:
 			if (Junk(rawType).getChargeCount()) {
 				iconIndex = (IconIndice)(iconIndex + 1);
 			}
 			break;
-		case kIconIndiceWeaponBoltBladeStormEmpty:
-		case kIconIndiceWeaponFlamittEmpty:
-		case kIconIndiceWeaponStormringEmpty:
-		case kIconIndiceWeaponFuryRaBladeEmpty:
-		case kIconIndiceWeaponEyeOfTimeEmpty:
-		case kIconIndiceWeaponStaffOfClawsEmpty:
+		case k23_IconIndiceWeaponBoltBladeStormEmpty:
+		case k14_IconIndiceWeaponFlamittEmpty:
+		case k18_IconIndiceWeaponStormringEmpty:
+		case k25_IconIndiceWeaponFuryRaBladeEmpty:
+		case k16_IconIndiceWeaponEyeOfTimeEmpty:
+		case k20_IconIndiceWeaponStaffOfClawsEmpty:
 			if (Weapon(rawType).getChargeCount()) {
 				iconIndex = (IconIndice)(iconIndex + 1);
 			}
@@ -201,7 +201,7 @@ void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 	SlotBox *slotBox = &_slotBoxes[slotBoxIndex];
 	slotBox->_iconIndex = iconIndex; // yes, this modifies the global array
-	if (slotBox->_iconIndex == kIconIndiceNone) {
+	if (slotBox->_iconIndex == kM1_IconIndiceNone) {
 		return;
 	}
 
@@ -237,7 +237,7 @@ void ObjectMan::drawLeaderObjectName(Thing thing) {
 	IconIndice iconIndex = getIconIndex(thing);
 	char *objName;
 	char objectNameBuffer[16];
-	if (iconIndex == kIconIndiceJunkChampionBones) {
+	if (iconIndex == k147_IconIndiceJunkChampionBones) {
 		Junk *junk = (Junk*)_vm->_dungeonMan->getThingData(thing);
 		strcpy(objectNameBuffer, _vm->_championMan->_champions[junk->getChargeCount()]._name);
 		strcat(objectNameBuffer, _objectNames[iconIndex]);


Commit: a9cda9df7c4f03aadf080c6c166b7a1a02987a1b
    https://github.com/scummvm/scummvm/commit/a9cda9df7c4f03aadf080c6c166b7a1a02987a1b
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: More renaming

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/objectman.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 9302216..b8dac7f 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -142,13 +142,13 @@ void ChampionMan::applyModifiersToStatistics(Champion* champ, ChampionSlot slotI
 	int16 statIndex;
 	int16 modifier = 0;
 	ThingType thingType = thing.getType();
-	if (((thingType == kWeaponThingType) || (thingType == kArmourThingType))
+	if (((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType))
 		&& (slotIndex >= k0_ChampionSlotReadyHand)
 		&& (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) {
 		Weapon *weapon = (Weapon*)_vm->_dungeonMan->getThingData(thing);
 		Armour *armour = (Armour*)_vm->_dungeonMan->getThingData(thing);
-		if (((thingType == kWeaponThingType) && weapon->getCursed())
-			|| ((thingType == kArmourThingType) && armour->getCursed())) {
+		if (((thingType == k5_WeaponThingType) && weapon->getCursed())
+			|| ((thingType == k6_ArmourThingType) && armour->getCursed())) {
 			statIndex = k0_ChampionStatLuck;
 			modifier = -3;
 			goto T0299044_ApplyModifier;
@@ -437,7 +437,7 @@ ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
 }
 
 void ChampionMan::resetDataToStartGame() {
-	if (!_vm->_dungeonMan->_messages._newGame) {
+	if (!_vm->_dungeonMan->_messages._g298_newGame) {
 		warning("MISSING CODE: stuff for resetting for loaded games");
 		assert(false);
 	}
@@ -468,26 +468,26 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	champ->_actionIndex = k255_ChampionActionNone;
 	champ->_enableActionEventIndex = -1;
 	champ->_hideDamageReceivedIndex = -1;
-	champ->_dir = dunMan._currMap._partyDir;
+	champ->_dir = dunMan._currMap._g308_partyDir;
 	ViewCell AL_0_viewCell = k0_ViewCellFronLeft;
-	while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kM1_ChampionNone)
+	while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._g308_partyDir) & 3)) != kM1_ChampionNone)
 		AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
-	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3);
+	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._g308_partyDir) & 3);
 	champ->clearAttributes(k0x0400_ChampionAttributeIcon);
-	champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir;
+	champ->_directionMaximumDamageReceived = dunMan._currMap._g308_partyDir;
 	champ->_food = 1500 + _vm->_rnd->getRandomNumber(256);
 	champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
 	int16 AL_0_slotIndex_Red;
 	for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) {
 		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none);
 	}
-	Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY);
-	while (thing.getType() != kTextstringType) {
+	Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._g306_partyPosX, dunMan._currMap._g307_partyPosY);
+	while (thing.getType() != k2_TextstringType) {
 		thing = dunMan.getNextThing(thing);
 	}
 	char decodedChampionText[77];
 	char* character_Green = decodedChampionText;
-	dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible));
+	dunMan.decodeText(character_Green, thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
 	int16 AL_0_characterIndex = 0;
 	uint16 AL_2_character;
 	while ((AL_2_character = *character_Green++) != '\n') {
@@ -557,21 +557,21 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 		_vm->_menuMan->drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1));
 	}
 
-	int16 mapX = _vm->_dungeonMan->_currMap._partyPosX;
-	int16 mapY = _vm->_dungeonMan->_currMap._partyPosY;
+	int16 mapX = _vm->_dungeonMan->_currMap._g306_partyPosX;
+	int16 mapY = _vm->_dungeonMan->_currMap._g307_partyPosY;
 
-	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir));
-	mapX += _vm->_dirIntoStepCountEast[dunMan._currMap._partyDir];
-	mapY += _vm->_dirIntoStepCountNorth[dunMan._currMap._partyDir];
+	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._g308_partyDir));
+	mapX += _vm->_dirIntoStepCountEast[dunMan._currMap._g308_partyDir];
+	mapY += _vm->_dirIntoStepCountNorth[dunMan._currMap._g308_partyDir];
 	thing = dunMan.getSquareFirstThing(mapX, mapY);
 	AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1;
 	uint16 slotIndex_Green;
 	while (thing != Thing::_endOfList) {
 		ThingType AL_2_thingType = thing.getType();
-		if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) {
-			int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots();
+		if ((AL_2_thingType > k3_SensorThingType) && (thing.getCell() == championObjectsCell)) {
+			int16 objectAllowedSlots = g237_ObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots();
 			switch (AL_2_thingType) {
-			case kArmourThingType:
+			case k6_ArmourThingType:
 				for (slotIndex_Green = k2_ChampionSlotHead; slotIndex_Green <= k5_ChampionSlotFeet; slotIndex_Green++) {
 					if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
 						goto T0280048;
@@ -582,15 +582,15 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 					goto T0280046;
 				}
 				break;
-			case kWeaponThingType:
+			case k5_WeaponThingType:
 				if (champ->getSlot(k1_ChampionSlotActionHand) == Thing::_none) {
 					slotIndex_Green = k1_ChampionSlotActionHand;
 				} else {
 					goto T0280046;
 				}
 				break;
-			case kScrollThingType:
-			case kPotionThingType:
+			case k7_ScrollThingType:
+			case k8_PotionThingType:
 				if (champ->getSlot(k11_ChampionSlotPouch_1) == Thing::_none) {
 					slotIndex_Green = k11_ChampionSlotPouch_1;
 				} else if (champ->getSlot(k6_ChampionSlotPouch_2) == Thing::_none) {
@@ -599,8 +599,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 					goto T0280046;
 				}
 				break;
-			case kContainerThingType:
-			case kJunkThingType:
+			case k9_ContainerThingType:
+			case k10_JunkThingType:
 T0280046:
 				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) {
 					slotIndex_Green = k10_ChampionSlotNeck;
@@ -850,19 +850,19 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	}
 
 	{ // block so goto won't skip AL_0_championIconIndex initialization 
-		int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir);
+		int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._g308_partyDir);
 
 		if ((champAttributes & k28_ChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) {
 			dispMan.clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]);
-			dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0,
+			dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._g308_partyDir) * 19, 0,
 								 g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray);
 		}
 	}
 
 	if ((champAttributes & k0x0800_ChampionAttributePanel) && isInventoryChamp) {
-		if (_vm->_pressingMouth) {
+		if (_vm->_g333_pressingMouth) {
 			invMan.drawPanelFoodWaterPoisoned();
-		} else if (_vm->_pressingEye) {
+		} else if (_vm->_g331_pressingEye) {
 			if (_g415_leaderEmptyHanded) {
 				warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics");
 			}
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index adc842b..83fb506 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -106,14 +106,14 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_movsens = nullptr;
 	_groupMan = nullptr;
 	_timeline = nullptr;
-	_stopWaitingForPlayerInput = false;
-	_gameTimeTicking = false;
-	_restartGameAllowed = false;
-	_pressingEye = false;
-	_pressingMouth = false;
-	_stopPressingEye = false;
-	_stopPressingMouth = false;
-	_highlightBoxInversionRequested = false;
+	_g321_stopWaitingForPlayerInput = false;
+	_g301_gameTimeTicking = false;
+	_g524_restartGameAllowed = false;
+	_g331_pressingEye = false;
+	_g333_pressingMouth = false;
+	_g332_stopPressingEye = false;
+	_g334_stopPressingMouth = false;
+	_g340_highlightBoxInversionRequested = false;
 
 	debug("DMEngine::DMEngine");
 }
@@ -164,11 +164,11 @@ void DMEngine::initializeGame() {
 
 
 void DMEngine::startGame() {
-	_pressingEye = false;
-	_stopPressingEye = false;
-	_pressingMouth = false;
-	_stopPressingMouth = false;
-	_highlightBoxInversionRequested = false;
+	_g331_pressingEye = false;
+	_g332_stopPressingEye = false;
+	_g333_pressingMouth = false;
+	_g334_stopPressingMouth = false;
+	_g340_highlightBoxInversionRequested = false;
 	_eventMan->_highlightBoxEnabled = false;
 	_championMan->_g300_partyIsSleeping = false;
 	_championMan->_g506_actingChampionOrdinal = indexToOrdinal(kM1_ChampionNone);
@@ -179,9 +179,9 @@ void DMEngine::startGame() {
 	_eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement;
 	warning("MISSING CODE: set primary/secondary keyboard input");
 
-	processNewPartyMap(_dungeonMan->_currMap._currPartyMapIndex);
+	processNewPartyMap(_dungeonMan->_currMap._g309_currPartyMapIndex);
 
-	if (!_dungeonMan->_messages._newGame) {
+	if (!_dungeonMan->_messages._g298_newGame) {
 		warning("TODO: loading game");
 	} else {
 		_displayMan->_g578_useByteBoxCoordinates = false;
@@ -191,7 +191,7 @@ void DMEngine::startGame() {
 	warning("TODO: build copper");
 	_menuMan->drawMovementArrows();
 	_championMan->resetDataToStartGame();
-	_gameTimeTicking = true;
+	_g301_gameTimeTicking = true;
 }
 
 void DMEngine::processNewPartyMap(uint16 mapIndex) {
@@ -233,28 +233,28 @@ Common::Error DMEngine::run() {
 
 void DMEngine::gameloop() {
 	warning("DUMMY CODE SETTING PARTY POS AND DIRECTION");
-	_dungeonMan->_currMap._partyPosX = 10;
-	_dungeonMan->_currMap._partyPosY = 4;
-	_dungeonMan->_currMap._partyDir = kDirNorth;
+	_dungeonMan->_currMap._g306_partyPosX = 10;
+	_dungeonMan->_currMap._g307_partyPosY = 4;
+	_dungeonMan->_currMap._g308_partyDir = kDirNorth;
 
 
 	warning("DUMMY CODE: setting InventoryMan::_inventoryChampionOrdinal to zero");
 	_inventoryMan->_inventoryChampionOrdinal = 0;
 	warning("DUMMY CODE: clearing screen to black"); // in loop below
 	while (true) {
-		_stopWaitingForPlayerInput = false;
+		_g321_stopWaitingForPlayerInput = false;
 
 		_menuMan->refreshActionAreaAndSetChampDirMaxDamageReceived();
 
 		//do {
 		_eventMan->processInput();
 		_eventMan->processCommandQueue();
-		//} while (!_stopWaitingForPlayerInput || !_gameTimeTicking);
+		//} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking);
 
 		if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
 			Box box(0, 224, 0, 126);
 			_displayMan->clearScreenBox(k0_ColorBlack, box, g296_DungeonViewport); // dummy code
-			_displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY);
+			_displayMan->drawDungeon(_dungeonMan->_currMap._g308_partyDir, _dungeonMan->_currMap._g306_partyPosX, _dungeonMan->_currMap._g307_partyPosY);
 		}
 		// DUMMY CODE: next line
 		_menuMan->drawMovementArrows();
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 814b89d..4505c74 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -71,29 +71,29 @@ void clearFlag(uint16 &val, uint16 mask);
 
 
 enum ThingType {
-	kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value
-	kDoorThingType = 0,
-	kTeleporterThingType = 1,
-	kTextstringType = 2,
-	kSensorThingType = 3,
-	kGroupThingType = 4,
-	kWeaponThingType = 5,
-	kArmourThingType = 6,
-	kScrollThingType = 7,
-	kPotionThingType = 8,
-	kContainerThingType = 9,
-	kJunkThingType = 10,
-	kProjectileThingType = 14,
-	kExplosionThingType = 15,
-	kThingTypeTotal = 16 // +1 than the last (explosionThingType)
+	kM1_PartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value
+	k0_DoorThingType = 0,
+	k1_TeleporterThingType = 1,
+	k2_TextstringType = 2,
+	k3_SensorThingType = 3,
+	k4_GroupThingType = 4,
+	k5_WeaponThingType = 5,
+	k6_ArmourThingType = 6,
+	k7_ScrollThingType = 7,
+	k8_PotionThingType = 8,
+	k9_ContainerThingType = 9,
+	k10_JunkThingType = 10,
+	k14_ProjectileThingType = 14,
+	k15_ExplosionThingType = 15,
+	k16_ThingTypeTotal = 16 // +1 than the last (explosionThingType)
 }; // @ C[00..15]_THING_TYPE_...
 
 enum Cell {
-	kCellAny = -1, // @ CM1_CELL_ANY      
-	kCellNorthWest = 0, // @ C00_CELL_NORTHWEST 
-	kCellNorthEast = 1, // @ C01_CELL_NORTHEAST 
-	kCellSouthEast = 2, // @ C02_CELL_SOUTHEAST 
-	kCellSouthWest = 3 // @ C03_CELL_SOUTHWEST 
+	kM1_CellAny = -1, // @ CM1_CELL_ANY      
+	k0_CellNorthWest = 0, // @ C00_CELL_NORTHWEST 
+	k1_CellNorthEast = 1, // @ C01_CELL_NORTHEAST 
+	k2_CellSouthEast = 2, // @ C02_CELL_SOUTHEAST 
+	k3_CellSouthWest = 3 // @ C03_CELL_SOUTHWEST 
 };
 
 class Thing {
@@ -168,15 +168,15 @@ public:
 	GroupMan *_groupMan;
 	Timeline *_timeline;
 
-	bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput
-	bool _gameTimeTicking; // @ G0301_B_GameTimeTicking
-	bool _restartGameAllowed; // @ G0524_B_RestartGameAllowed
-	uint32 _gameId; // @ G0525_l_GameID, probably useless here
-	bool _pressingEye; // @ G0331_B_PressingEye
-	bool _stopPressingEye; // @ G0332_B_StopPressingEye
-	bool _pressingMouth; // @ G0333_B_PressingMouth
-	bool _stopPressingMouth; // @ G0334_B_StopPressingMouth
-	bool _highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested
+	bool _g321_stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput
+	bool _g301_gameTimeTicking; // @ G0301_B_GameTimeTicking
+	bool _g524_restartGameAllowed; // @ G0524_B_RestartGameAllowed
+	uint32 _g525_gameId; // @ G0525_l_GameID, probably useless here
+	bool _g331_pressingEye; // @ G0331_B_PressingEye
+	bool _g332_stopPressingEye; // @ G0332_B_StopPressingEye
+	bool _g333_pressingMouth; // @ G0333_B_PressingMouth
+	bool _g334_stopPressingMouth; // @ G0334_B_StopPressingMouth
+	bool _g340_highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested
 
 	// TODO: refactor direction into a class
 	int8 _dirIntoStepCountEast[4];
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 1d74bec..4ce3c18 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -35,7 +35,7 @@
 
 namespace DM {
 
-ObjectInfo gObjectInfo[180] = { // @ G0237_as_Graphic559_ObjectInfo
+ObjectInfo g237_ObjectInfo[180] = { // @ G0237_as_Graphic559_ObjectInfo
 /* { Type, ObjectAspectIndex, ActionSetIndex, AllowedSlots } */
 	ObjectInfo(30,  1,  0, 0x0500),   /* COMPASS        Pouch/Chest */
 	ObjectInfo(144,  0,  0, 0x0200),   /* COMPASS        Hands */
@@ -218,7 +218,7 @@ ObjectInfo gObjectInfo[180] = { // @ G0237_as_Graphic559_ObjectInfo
 	ObjectInfo(197, 74,  0, 0x0000),   /* SOLID KEY */
 	ObjectInfo(198, 41,  0, 0x0400)}; /* SQUARE KEY     Chest */
 
-ArmourInfo gArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo
+ArmourInfo g239_ArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo
 /* { Weight, Defense, Attributes, Unreferenced } */
 	ArmourInfo(3,   5, 0x01),   /* CAPE */
 	ArmourInfo(4,  10, 0x01),   /* CLOAK OF NIGHT */
@@ -279,7 +279,7 @@ ArmourInfo gArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo
 	ArmourInfo(3,  16, 0x02),   /* BOOTS OF SPEED */
 	ArmourInfo(2,   3, 0x03)}; /* HALTER */
 
-WeaponInfo gWeaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo
+WeaponInfo g238_WeaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo
 							   /* { Weight, Class, Strength, KineticEnergy, Attributes } */
 	WeaponInfo(1, 130,   2,   0, 0x2000),   /* EYE OF TIME */
 	WeaponInfo(1, 131,   2,   0, 0x2000),   /* STORMRING */
@@ -328,7 +328,7 @@ WeaponInfo gWeaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo
 	WeaponInfo(30, 26,   1, 220, 0x207D),   /* SPEEDBOW */
 	WeaponInfo(36, 255, 100,  50, 0x20FF)}; /* THE FIRESTAFF */
 
-CreatureInfo gCreatureInfo[k27_CreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo
+CreatureInfo g243_CreatureInfo[k27_CreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo
 												   /* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo,
 												   MovementTicks, AttackTicks, Defense, BaseHealth, Attack, PoisonAttack,
 												   Dexterity, Ranges, Properties, Resistances, AnimationTicks, WoundProbabilities, AttackType } */
@@ -368,73 +368,73 @@ void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, in
 	posY += _vm->_dirIntoStepCountNorth[dir] * stepsRight;
 }
 
-DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) {
-	_dunData._columCount = 0;
+DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _g277_maps(NULL), _g276_rawMapData(NULL) {
+	_dunData._g282_columCount = 0;
 
-	_dunData._mapsFirstColumnIndex = nullptr;
-	_dunData._columnsCumulativeSquareThingCount = nullptr;
-	_dunData._squareFirstThings = nullptr;
-	_dunData._textData = nullptr;
-	_dunData._mapData = nullptr;
+	_dunData._g281_mapsFirstColumnIndex = nullptr;
+	_dunData._g280_columnsCumulativeSquareThingCount = nullptr;
+	_dunData._g283_squareFirstThings = nullptr;
+	_dunData._g260_textData = nullptr;
+	_dunData._g279_mapData = nullptr;
 
 	for (int i = 0; i < 16; i++)
-		_dunData._thingsData[i] = nullptr;
+		_dunData._g284_thingsData[i] = nullptr;
 
-	_currMap._partyDir = kDirNorth;
-	_currMap._partyPosX = 0;
-	_currMap._partyPosY = 0;
-	_currMap._currPartyMapIndex = 0;
-	_currMap._index = 0;
-	_currMap._width = 0;
-	_currMap._height = 0;
+	_currMap._g308_partyDir = kDirNorth;
+	_currMap._g306_partyPosX = 0;
+	_currMap._g307_partyPosY = 0;
+	_currMap._g309_currPartyMapIndex = 0;
+	_currMap._g272_index = 0;
+	_currMap._g273_width = 0;
+	_currMap._g274_height = 0;
 
-	_currMap._data = nullptr;
-	_currMap._map = nullptr;
-	_currMap._colCumulativeSquareFirstThingCount = nullptr;
+	_currMap._g271_data = nullptr;
+	_currMap._g269_map = nullptr;
+	_currMap._g270_colCumulativeSquareFirstThingCount = nullptr;
 
-	_messages._newGame = true;
-	_messages._restartGameRequest = false;
+	_messages._g298_newGame = true;
+	_messages._g523_restartGameRequest = false;
 
 	_rawDunFileDataSize = 0;
 	_rawDunFileData = nullptr;
 
-	_fileHeader._dungeonId = 0;
-	_fileHeader._ornamentRandomSeed = 0;
-	_fileHeader._rawMapDataSize = 0;
-	_fileHeader._mapCount = 0;
-	_fileHeader._textDataWordCount = 0;
-	_fileHeader._partyStartDir = kDirNorth;
-	_fileHeader._partyStartPosX = 0;
-	_fileHeader._partyStartPosY = 0;
-	_fileHeader._squareFirstThingCount = 0;
+	_g278_fileHeader._dungeonId = 0;
+	_g278_fileHeader._ornamentRandomSeed = 0;
+	_g278_fileHeader._rawMapDataSize = 0;
+	_g278_fileHeader._mapCount = 0;
+	_g278_fileHeader._textDataWordCount = 0;
+	_g278_fileHeader._partyStartDir = kDirNorth;
+	_g278_fileHeader._partyStartPosX = 0;
+	_g278_fileHeader._partyStartPosY = 0;
+	_g278_fileHeader._squareFirstThingCount = 0;
 
 	for (int i = 0; i < 16; i++)
-		_fileHeader._thingCounts[i] = 0;
+		_g278_fileHeader._thingCounts[i] = 0;
 
-	_maps = nullptr;
-	_rawMapData = nullptr;
+	_g277_maps = nullptr;
+	_g276_rawMapData = nullptr;
 
-	_currMapInscriptionWallOrnIndex = 0;
-	_isFacingAlcove = false;
-	_isFacingViAltar = false;
-	_isFacingFountain = false;
+	_g265_currMapInscriptionWallOrnIndex = 0;
+	_g286_isFacingAlcove = false;
+	_g287_isFacingViAltar = false;
+	_g288_isFacingFountain = false;
 
 	for (int j = 0; j < 6; j++)
-		_dungeonViewClickableBoxes[j].setToZero();
+		_g291_dungeonViewClickableBoxes[j].setToZero();
 }
 
 DungeonMan::~DungeonMan() {
 	delete[] _rawDunFileData;
-	delete[] _maps;
-	delete[] _dunData._mapsFirstColumnIndex;
-	delete[] _dunData._columnsCumulativeSquareThingCount;
-	delete[] _dunData._squareFirstThings;
-	delete[] _dunData._textData;
-	delete[] _dunData._mapData;
+	delete[] _g277_maps;
+	delete[] _dunData._g281_mapsFirstColumnIndex;
+	delete[] _dunData._g280_columnsCumulativeSquareThingCount;
+	delete[] _dunData._g283_squareFirstThings;
+	delete[] _dunData._g260_textData;
+	delete[] _dunData._g279_mapData;
 	for (uint16 i = 0; i < 16; ++i) {
-		if (_dunData._thingsData[i])
-			delete[] _dunData._thingsData[i][0];
-		delete[] _dunData._thingsData[i];
+		if (_dunData._g284_thingsData[i])
+			delete[] _dunData._g284_thingsData[i][0];
+		delete[] _dunData._g284_thingsData[i];
 	}
 }
 
@@ -551,177 +551,177 @@ const Thing Thing::_explRebirthStep2(0xFFE5); // @ C0xFFE5_THING_EXPLOSION_REBIR
 const Thing Thing::_party(0xFFFF); // @ C0xFFFF_THING_PARTY          
 
 void DungeonMan::loadDungeonFile() {
-	if (_messages._newGame)
+	if (_messages._g298_newGame)
 		decompressDungeonFile();
 
 	Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO);
 
-	// initialize _fileHeader
-	_fileHeader._dungeonId = _fileHeader._ornamentRandomSeed = dunDataStream.readUint16BE();
-	_fileHeader._rawMapDataSize = dunDataStream.readUint16BE();
-	_fileHeader._mapCount = dunDataStream.readByte();
+	// initialize _g278_fileHeader
+	_g278_fileHeader._dungeonId = _g278_fileHeader._ornamentRandomSeed = dunDataStream.readUint16BE();
+	_g278_fileHeader._rawMapDataSize = dunDataStream.readUint16BE();
+	_g278_fileHeader._mapCount = dunDataStream.readByte();
 	dunDataStream.readByte(); // discard 1 byte
-	_fileHeader._textDataWordCount = dunDataStream.readUint16BE();
+	_g278_fileHeader._textDataWordCount = dunDataStream.readUint16BE();
 	uint16 partyPosition = dunDataStream.readUint16BE();
-	_fileHeader._partyStartDir = (direction)((partyPosition >> 10) & 3);
-	_fileHeader._partyStartPosY = (partyPosition >> 5) & 0x1F;
-	_fileHeader._partyStartPosX = (partyPosition >> 0) & 0x1F;
-	_fileHeader._squareFirstThingCount = dunDataStream.readUint16BE();
-	for (uint16 i = 0; i < kThingTypeTotal; ++i)
-		_fileHeader._thingCounts[i] = dunDataStream.readUint16BE();
+	_g278_fileHeader._partyStartDir = (direction)((partyPosition >> 10) & 3);
+	_g278_fileHeader._partyStartPosY = (partyPosition >> 5) & 0x1F;
+	_g278_fileHeader._partyStartPosX = (partyPosition >> 0) & 0x1F;
+	_g278_fileHeader._squareFirstThingCount = dunDataStream.readUint16BE();
+	for (uint16 i = 0; i < k16_ThingTypeTotal; ++i)
+		_g278_fileHeader._thingCounts[i] = dunDataStream.readUint16BE();
 
 	// init party position and mapindex
-	if (_messages._newGame) {
-		_currMap._partyDir = _fileHeader._partyStartDir;
-		_currMap._partyPosX = _fileHeader._partyStartPosX;
-		_currMap._partyPosY = _fileHeader._partyStartPosY;
-		_currMap._currPartyMapIndex = 0;
+	if (_messages._g298_newGame) {
+		_currMap._g308_partyDir = _g278_fileHeader._partyStartDir;
+		_currMap._g306_partyPosX = _g278_fileHeader._partyStartPosX;
+		_currMap._g307_partyPosY = _g278_fileHeader._partyStartPosY;
+		_currMap._g309_currPartyMapIndex = 0;
 	}
 
 	// load map data
-	delete[] _maps;
-	_maps = new Map[_fileHeader._mapCount];
-	for (uint16 i = 0; i < _fileHeader._mapCount; ++i) {
-		_maps[i]._rawDunDataOffset = dunDataStream.readUint16BE();
+	delete[] _g277_maps;
+	_g277_maps = new Map[_g278_fileHeader._mapCount];
+	for (uint16 i = 0; i < _g278_fileHeader._mapCount; ++i) {
+		_g277_maps[i]._rawDunDataOffset = dunDataStream.readUint16BE();
 		dunDataStream.readUint32BE(); // discard 4 bytes
-		_maps[i]._offsetMapX = dunDataStream.readByte();
-		_maps[i]._offsetMapY = dunDataStream.readByte();
+		_g277_maps[i]._offsetMapX = dunDataStream.readByte();
+		_g277_maps[i]._offsetMapY = dunDataStream.readByte();
 
 		uint16 tmp = dunDataStream.readUint16BE();
-		_maps[i]._height = tmp >> 11;
-		_maps[i]._width = (tmp >> 6) & 0x1F;
-		_maps[i]._level = tmp & 0x1F; // Only used in DMII
+		_g277_maps[i]._height = tmp >> 11;
+		_g277_maps[i]._width = (tmp >> 6) & 0x1F;
+		_g277_maps[i]._level = tmp & 0x1F; // Only used in DMII
 
 		tmp = dunDataStream.readUint16BE();
-		_maps[i]._randFloorOrnCount = tmp >> 12;
-		_maps[i]._floorOrnCount = (tmp >> 8) & 0xF;
-		_maps[i]._randWallOrnCount = (tmp >> 4) & 0xF;
-		_maps[i]._wallOrnCount = tmp & 0xF;
+		_g277_maps[i]._randFloorOrnCount = tmp >> 12;
+		_g277_maps[i]._floorOrnCount = (tmp >> 8) & 0xF;
+		_g277_maps[i]._randWallOrnCount = (tmp >> 4) & 0xF;
+		_g277_maps[i]._wallOrnCount = tmp & 0xF;
 
 		tmp = dunDataStream.readUint16BE();
-		_maps[i]._difficulty = tmp >> 12;
-		_maps[i]._creatureTypeCount = (tmp >> 4) & 0xF;
-		_maps[i]._doorOrnCount = tmp & 0xF;
+		_g277_maps[i]._difficulty = tmp >> 12;
+		_g277_maps[i]._creatureTypeCount = (tmp >> 4) & 0xF;
+		_g277_maps[i]._doorOrnCount = tmp & 0xF;
 
 		tmp = dunDataStream.readUint16BE();
-		_maps[i]._doorSet1 = (tmp >> 12) & 0xF;
-		_maps[i]._doorSet0 = (tmp >> 8) & 0xF;
-		_maps[i]._wallSet = (WallSet)((tmp >> 4) & 0xF);
-		_maps[i]._floorSet = (FloorSet)(tmp & 0xF);
+		_g277_maps[i]._doorSet1 = (tmp >> 12) & 0xF;
+		_g277_maps[i]._doorSet0 = (tmp >> 8) & 0xF;
+		_g277_maps[i]._wallSet = (WallSet)((tmp >> 4) & 0xF);
+		_g277_maps[i]._floorSet = (FloorSet)(tmp & 0xF);
 	}
 
 	// TODO: ??? is this - begin
-	delete[] _dunData._mapsFirstColumnIndex;
-	_dunData._mapsFirstColumnIndex = new uint16[_fileHeader._mapCount];
+	delete[] _dunData._g281_mapsFirstColumnIndex;
+	_dunData._g281_mapsFirstColumnIndex = new uint16[_g278_fileHeader._mapCount];
 	uint16 columCount = 0;
-	for (uint16 i = 0; i < _fileHeader._mapCount; ++i) {
-		_dunData._mapsFirstColumnIndex[i] = columCount;
-		columCount += _maps[i]._width + 1;
+	for (uint16 i = 0; i < _g278_fileHeader._mapCount; ++i) {
+		_dunData._g281_mapsFirstColumnIndex[i] = columCount;
+		columCount += _g277_maps[i]._width + 1;
 	}
-	_dunData._columCount = columCount;
+	_dunData._g282_columCount = columCount;
 	// TODO: ??? is this - end
 
 
-	uint32 actualSquareFirstThingCount = _fileHeader._squareFirstThingCount;
-	if (_messages._newGame) // TODO: what purpose does this serve?
-		_fileHeader._squareFirstThingCount += 300;
+	uint32 actualSquareFirstThingCount = _g278_fileHeader._squareFirstThingCount;
+	if (_messages._g298_newGame) // TODO: what purpose does this serve?
+		_g278_fileHeader._squareFirstThingCount += 300;
 
 	// TODO: ??? is this - begin
-	delete[] _dunData._columnsCumulativeSquareThingCount;
-	_dunData._columnsCumulativeSquareThingCount = new uint16[columCount];
+	delete[] _dunData._g280_columnsCumulativeSquareThingCount;
+	_dunData._g280_columnsCumulativeSquareThingCount = new uint16[columCount];
 	for (uint16 i = 0; i < columCount; ++i)
-		_dunData._columnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE();
+		_dunData._g280_columnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE();
 	// TODO: ??? is this - end
 
 	// TODO: ??? is this - begin
-	delete[] _dunData._squareFirstThings;
-	_dunData._squareFirstThings = new Thing[_fileHeader._squareFirstThingCount];
+	delete[] _dunData._g283_squareFirstThings;
+	_dunData._g283_squareFirstThings = new Thing[_g278_fileHeader._squareFirstThingCount];
 	for (uint16 i = 0; i < actualSquareFirstThingCount; ++i)
-		_dunData._squareFirstThings[i].set(dunDataStream.readUint16BE());
-	if (_messages._newGame)
+		_dunData._g283_squareFirstThings[i].set(dunDataStream.readUint16BE());
+	if (_messages._g298_newGame)
 		for (uint16 i = 0; i < 300; ++i)
-			_dunData._squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none;
+			_dunData._g283_squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none;
 
 	// TODO: ??? is this - end
 
 	// load text data
-	delete[] _dunData._textData;
-	_dunData._textData = new uint16[_fileHeader._textDataWordCount];
-	for (uint16 i = 0; i < _fileHeader._textDataWordCount; ++i)
-		_dunData._textData[i] = dunDataStream.readUint16BE();
+	delete[] _dunData._g260_textData;
+	_dunData._g260_textData = new uint16[_g278_fileHeader._textDataWordCount];
+	for (uint16 i = 0; i < _g278_fileHeader._textDataWordCount; ++i)
+		_dunData._g260_textData[i] = dunDataStream.readUint16BE();
 
 	// TODO: ??? what this
-	if (_messages._newGame)
+	if (_messages._g298_newGame)
 		_vm->_timeline->_eventMaxCount = 100;
 
 	// load things
-	for (uint16 thingType = kDoorThingType; thingType < kThingTypeTotal; ++thingType) {
-		uint16 thingCount = _fileHeader._thingCounts[thingType];
-		if (_messages._newGame) {
-			_fileHeader._thingCounts[thingType] = MIN((thingType == kExplosionThingType) ? 768 : 1024, thingCount + gAdditionalThingCounts[thingType]);
+	for (uint16 thingType = k0_DoorThingType; thingType < k16_ThingTypeTotal; ++thingType) {
+		uint16 thingCount = _g278_fileHeader._thingCounts[thingType];
+		if (_messages._g298_newGame) {
+			_g278_fileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + gAdditionalThingCounts[thingType]);
 		}
 		uint16 thingStoreWordCount = gThingDataWordCount[thingType];
 
 		if (thingStoreWordCount == 0)
 			continue;
 
-		if (_dunData._thingsData[thingType]) {
-			delete[] _dunData._thingsData[thingType][0];
-			delete[] _dunData._thingsData[thingType];
+		if (_dunData._g284_thingsData[thingType]) {
+			delete[] _dunData._g284_thingsData[thingType][0];
+			delete[] _dunData._g284_thingsData[thingType];
 		}
-		_dunData._thingsData[thingType] = new uint16*[_fileHeader._thingCounts[thingType]];
-		_dunData._thingsData[thingType][0] = new uint16[_fileHeader._thingCounts[thingType] * thingStoreWordCount];
-		for (uint16 i = 0; i < _fileHeader._thingCounts[thingType]; ++i)
-			_dunData._thingsData[thingType][i] = _dunData._thingsData[thingType][0] + i * thingStoreWordCount;
+		_dunData._g284_thingsData[thingType] = new uint16*[_g278_fileHeader._thingCounts[thingType]];
+		_dunData._g284_thingsData[thingType][0] = new uint16[_g278_fileHeader._thingCounts[thingType] * thingStoreWordCount];
+		for (uint16 i = 0; i < _g278_fileHeader._thingCounts[thingType]; ++i)
+			_dunData._g284_thingsData[thingType][i] = _dunData._g284_thingsData[thingType][0] + i * thingStoreWordCount;
 
-		if (thingType == kGroupThingType) {
+		if (thingType == k4_GroupThingType) {
 			for (uint16 i = 0; i < thingCount; ++i)
 				for (uint16 j = 0; j < thingStoreWordCount; ++j) {
 					if (j == 2 || j == 3)
-						_dunData._thingsData[thingType][i][j] = dunDataStream.readByte();
+						_dunData._g284_thingsData[thingType][i][j] = dunDataStream.readByte();
 					else
-						_dunData._thingsData[thingType][i][j] = dunDataStream.readUint16BE();
+						_dunData._g284_thingsData[thingType][i][j] = dunDataStream.readUint16BE();
 				}
-		} else if (thingType == kProjectileThingType) {
+		} else if (thingType == k14_ProjectileThingType) {
 			for (uint16 i = 0; i < thingCount; ++i) {
-				_dunData._thingsData[thingType][i][0] = dunDataStream.readUint16BE();
-				_dunData._thingsData[thingType][i][1] = dunDataStream.readUint16BE();
-				_dunData._thingsData[thingType][i][2] = dunDataStream.readByte();
-				_dunData._thingsData[thingType][i][3] = dunDataStream.readByte();
-				_dunData._thingsData[thingType][i][4] = dunDataStream.readUint16BE();
+				_dunData._g284_thingsData[thingType][i][0] = dunDataStream.readUint16BE();
+				_dunData._g284_thingsData[thingType][i][1] = dunDataStream.readUint16BE();
+				_dunData._g284_thingsData[thingType][i][2] = dunDataStream.readByte();
+				_dunData._g284_thingsData[thingType][i][3] = dunDataStream.readByte();
+				_dunData._g284_thingsData[thingType][i][4] = dunDataStream.readUint16BE();
 			}
 		} else {
 			for (uint16 i = 0; i < thingCount; ++i) {
 				for (uint16 j = 0; j < thingStoreWordCount; ++j)
-					_dunData._thingsData[thingType][i][j] = dunDataStream.readUint16BE();
+					_dunData._g284_thingsData[thingType][i][j] = dunDataStream.readUint16BE();
 			}
 		}
 
-		if (_messages._newGame) {
-			if ((thingType == kGroupThingType) || thingType >= kProjectileThingType)
-				_vm->_timeline->_eventMaxCount += _fileHeader._thingCounts[thingType];
+		if (_messages._g298_newGame) {
+			if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType)
+				_vm->_timeline->_eventMaxCount += _g278_fileHeader._thingCounts[thingType];
 			for (uint16 i = 0; i < gAdditionalThingCounts[thingType]; ++i) {
-				_dunData._thingsData[thingType][thingCount + i][0] = Thing::_none.toUint16();
+				_dunData._g284_thingsData[thingType][thingCount + i][0] = Thing::_none.toUint16();
 			}
 		}
 	}
 
 	// load map data
-	if (!_messages._restartGameRequest)
-		_rawMapData = _rawDunFileData + dunDataStream.pos();
+	if (!_messages._g523_restartGameRequest)
+		_g276_rawMapData = _rawDunFileData + dunDataStream.pos();
 
 
-	if (!_messages._restartGameRequest) {
-		uint8 mapCount = _fileHeader._mapCount;
-		delete[] _dunData._mapData;
-		_dunData._mapData = new byte**[_dunData._columCount + mapCount];
-		byte **colFirstSquares = (byte**)_dunData._mapData + mapCount;
+	if (!_messages._g523_restartGameRequest) {
+		uint8 mapCount = _g278_fileHeader._mapCount;
+		delete[] _dunData._g279_mapData;
+		_dunData._g279_mapData = new byte**[_dunData._g282_columCount + mapCount];
+		byte **colFirstSquares = (byte**)_dunData._g279_mapData + mapCount;
 		for (uint8 i = 0; i < mapCount; ++i) {
-			_dunData._mapData[i] = colFirstSquares;
-			byte *square = _rawMapData + _maps[i]._rawDunDataOffset;
+			_dunData._g279_mapData[i] = colFirstSquares;
+			byte *square = _g276_rawMapData + _g277_maps[i]._rawDunDataOffset;
 			*colFirstSquares++ = square;
-			for (uint16 w = 1; w <= _maps[i]._width; ++w) {
-				square += _maps[i]._height + 1;
+			for (uint16 w = 1; w <= _g277_maps[i]._width; ++w) {
+				square += _g277_maps[i]._height + 1;
 				*colFirstSquares++ = square;
 			}
 		}
@@ -729,63 +729,63 @@ void DungeonMan::loadDungeonFile() {
 }
 
 void DungeonMan::setCurrentMap(uint16 mapIndex) {
-	_currMap._index = mapIndex;
-	_currMap._data = _dunData._mapData[mapIndex];
-	_currMap._map = _maps + mapIndex;
-	_currMap._width = _maps[mapIndex]._width + 1;
-	_currMap._height = _maps[mapIndex]._height + 1;
-	_currMap._colCumulativeSquareFirstThingCount
-		= &_dunData._columnsCumulativeSquareThingCount[_dunData._mapsFirstColumnIndex[mapIndex]];
+	_currMap._g272_index = mapIndex;
+	_currMap._g271_data = _dunData._g279_mapData[mapIndex];
+	_currMap._g269_map = _g277_maps + mapIndex;
+	_currMap._g273_width = _g277_maps[mapIndex]._width + 1;
+	_currMap._g274_height = _g277_maps[mapIndex]._height + 1;
+	_currMap._g270_colCumulativeSquareFirstThingCount
+		= &_dunData._g280_columnsCumulativeSquareThingCount[_dunData._g281_mapsFirstColumnIndex[mapIndex]];
 }
 
 void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) {
 	setCurrentMap(mapIndex);
 
-	byte *metaMapData = _currMap._data[_currMap._width - 1] + _currMap._height;
+	byte *metaMapData = _currMap._g271_data[_currMap._g273_width - 1] + _currMap._g274_height;
 	_vm->_displayMan->_g264_currMapAllowedCreatureTypes = metaMapData;
 
-	metaMapData += _currMap._map->_creatureTypeCount;
-	memcpy(_vm->_displayMan->_g261_currMapWallOrnIndices, metaMapData, _currMap._map->_wallOrnCount);
+	metaMapData += _currMap._g269_map->_creatureTypeCount;
+	memcpy(_vm->_displayMan->_g261_currMapWallOrnIndices, metaMapData, _currMap._g269_map->_wallOrnCount);
 
-	metaMapData += _currMap._map->_wallOrnCount;
-	memcpy(_vm->_displayMan->_g262_currMapFloorOrnIndices, metaMapData, _currMap._map->_floorOrnCount);
+	metaMapData += _currMap._g269_map->_wallOrnCount;
+	memcpy(_vm->_displayMan->_g262_currMapFloorOrnIndices, metaMapData, _currMap._g269_map->_floorOrnCount);
 
-	metaMapData += _currMap._map->_wallOrnCount;
-	memcpy(_vm->_displayMan->_g263_currMapDoorOrnIndices, metaMapData, _currMap._map->_doorOrnCount);
+	metaMapData += _currMap._g269_map->_wallOrnCount;
+	memcpy(_vm->_displayMan->_g263_currMapDoorOrnIndices, metaMapData, _currMap._g269_map->_doorOrnCount);
 
-	_currMapInscriptionWallOrnIndex = _currMap._map->_wallOrnCount;
-	_vm->_displayMan->_g261_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = k0_WallOrnInscription;
+	_g265_currMapInscriptionWallOrnIndex = _currMap._g269_map->_wallOrnCount;
+	_vm->_displayMan->_g261_currMapWallOrnIndices[_g265_currMapInscriptionWallOrnIndex] = k0_WallOrnInscription;
 }
 
 
 Square DungeonMan::getSquare(int16 mapX, int16 mapY) {
-	bool isInXBounds = (mapX >= 0) && (mapX < _currMap._width);
-	bool isInYBounds = (mapY >= 0) && (mapY < _currMap._height);
+	bool isInXBounds = (mapX >= 0) && (mapX < _currMap._g273_width);
+	bool isInYBounds = (mapY >= 0) && (mapY < _currMap._g274_height);
 
 	if (isInXBounds && isInYBounds)
-		return _currMap._data[mapX][mapY];
+		return Square(_currMap._g271_data[mapX][mapY]);
 
 
 	Square tmpSquare;
 	if (isInYBounds) {
-		tmpSquare.set(_currMap._data[0][mapY]);
-		if (mapX == -1 && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType))
-			return Square(kWallElemType).set(kWallEastRandOrnAllowed);
+		tmpSquare.set(_currMap._g271_data[0][mapY]);
+		if (mapX == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
+			return Square(k0_WallElemType).set(k0x0004_WallEastRandOrnAllowed);
 
-		tmpSquare.set(_currMap._data[_currMap._width - 1][mapY]);
-		if (mapX == _currMap._width && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType))
-			return Square(kWallElemType).set(kWallWestRandOrnAllowed);
+		tmpSquare.set(_currMap._g271_data[_currMap._g273_width - 1][mapY]);
+		if (mapX == _currMap._g273_width && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
+			return Square(k0_WallElemType).set(k0x0001_WallWestRandOrnAllowed);
 	} else if (isInXBounds) {
-		tmpSquare.set(_currMap._data[mapX][0]);
-		if (mapY == -1 && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType))
-			return Square(kWallElemType).set(kWallSouthRandOrnAllowed);
+		tmpSquare.set(_currMap._g271_data[mapX][0]);
+		if (mapY == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
+			return Square(k0_WallElemType).set(k0x0002_WallSouthRandOrnAllowed);
 
-		tmpSquare.set(_currMap._data[mapX][_currMap._height - 1]);
-		if (mapY == _currMap._height && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType))
-			return (kWallElemType << 5) | kWallNorthRandOrnAllowed;
+		tmpSquare.set(_currMap._g271_data[mapX][_currMap._g274_height - 1]);
+		if (mapY == _currMap._g274_height && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
+			return Square((k0_WallElemType << 5) | k0x0008_WallNorthRandOrnAllowed);
 	}
 
-	return Square(kWallElemType);
+	return Square(k0_WallElemType);
 }
 
 Square DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
@@ -794,14 +794,14 @@ Square DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRi
 }
 
 int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) {
-	if (mapX < 0 || mapX >= _currMap._width || mapY < 0 || mapY >= _currMap._height || !Square(_currMap._data[mapX][mapY]).get(kThingListPresent))
+	if (mapX < 0 || mapX >= _currMap._g273_width || mapY < 0 || mapY >= _currMap._g274_height || !Square(_currMap._g271_data[mapX][mapY]).get(k0x0010_ThingListPresent))
 		return -1;
 
 	int16 y = 0;
-	uint16 index = _currMap._colCumulativeSquareFirstThingCount[mapX];
-	byte* square = _currMap._data[mapX];
+	uint16 index = _currMap._g270_colCumulativeSquareFirstThingCount[mapX];
+	byte* square = _currMap._g271_data[mapX];
 	while (y++ != mapY)
-		if (Square(*square++).get(kThingListPresent))
+		if (Square(*square++).get(k0x0010_ThingListPresent))
 			index++;
 
 	return index;
@@ -811,7 +811,7 @@ Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) {
 	int16 index = getSquareFirstThingIndex(mapX, mapY);
 	if (index == -1)
 		return Thing::_endOfList;
-	return _dunData._squareFirstThings[index];
+	return _dunData._g283_squareFirstThings[index];
 }
 
 
@@ -825,7 +825,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
 	Thing thing = getSquareFirstThing(mapX, mapY);
 	Square square = getSquare(mapX, mapY);
 
-	aspectArray[kElemAspect] = square.getType();
+	aspectArray[k0_ElemAspect] = square.getType();
 
 	bool leftOrnAllowed = false;
 	bool rightOrnAllowed = false;
@@ -833,27 +833,27 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
 	bool squareIsFakeWall = false;
 	bool footPrintsAllowed = false;
 	switch (square.getType()) {
-	case kWallElemType:
+	case k0_WallElemType:
 		switch (dir) {
 		case kDirNorth:
-			leftOrnAllowed = square.get(kWallEastRandOrnAllowed);
-			frontOrnAllowed = square.get(kWallSouthRandOrnAllowed);
-			rightOrnAllowed = square.get(kWallWestRandOrnAllowed);
+			leftOrnAllowed = square.get(k0x0004_WallEastRandOrnAllowed);
+			frontOrnAllowed = square.get(k0x0002_WallSouthRandOrnAllowed);
+			rightOrnAllowed = square.get(k0x0001_WallWestRandOrnAllowed);
 			break;
 		case kDirEast:
-			leftOrnAllowed = square.get(kWallSouthRandOrnAllowed);
-			frontOrnAllowed = square.get(kWallWestRandOrnAllowed);
-			rightOrnAllowed = square.get(kWallNorthRandOrnAllowed);
+			leftOrnAllowed = square.get(k0x0002_WallSouthRandOrnAllowed);
+			frontOrnAllowed = square.get(k0x0001_WallWestRandOrnAllowed);
+			rightOrnAllowed = square.get(k0x0008_WallNorthRandOrnAllowed);
 			break;
 		case kDirSouth:
-			leftOrnAllowed = square.get(kWallWestRandOrnAllowed);
-			frontOrnAllowed = square.get(kWallNorthRandOrnAllowed);
-			rightOrnAllowed = square.get(kWallEastRandOrnAllowed);
+			leftOrnAllowed = square.get(k0x0001_WallWestRandOrnAllowed);
+			frontOrnAllowed = square.get(k0x0008_WallNorthRandOrnAllowed);
+			rightOrnAllowed = square.get(k0x0004_WallEastRandOrnAllowed);
 			break;
 		case kDirWest:
-			leftOrnAllowed = square.get(kWallNorthRandOrnAllowed);
-			frontOrnAllowed = square.get(kWallEastRandOrnAllowed);
-			rightOrnAllowed = square.get(kWallSouthRandOrnAllowed);
+			leftOrnAllowed = square.get(k0x0008_WallNorthRandOrnAllowed);
+			frontOrnAllowed = square.get(k0x0004_WallEastRandOrnAllowed);
+			rightOrnAllowed = square.get(k0x0002_WallSouthRandOrnAllowed);
 			break;
 		default:
 			break;
@@ -862,104 +862,104 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
 T0172010_ClosedFakeWall:
 		setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall);
 
-		while ((thing != Thing::_endOfList) && (thing.getType() <= kSensorThingType)) {
+		while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) {
 			int16 sideIndex = (thing.getCell() - dir) & 3;
 			if (sideIndex) {
-				if (thing.getType() == kTextstringType) {
+				if (thing.getType() == k2_TextstringType) {
 					if (TextString(getThingData(thing)).isVisible()) {
-						aspectArray[sideIndex + 1] = _currMapInscriptionWallOrnIndex + 1;
+						aspectArray[sideIndex + 1] = _g265_currMapInscriptionWallOrnIndex + 1;
 						_vm->_displayMan->_g290_inscriptionThing = thing; // BUG0_76
 					}
 				} else {
 					Sensor sensor(getThingData(thing));
 					aspectArray[sideIndex + 1] = sensor.getOrnOrdinal();
-					if (sensor.getType() == kSensorWallChampionPortrait) {
+					if (sensor.getType() == k127_SensorWallChampionPortrait) {
 						_vm->_displayMan->_g289_championPortraitOrdinal = _vm->indexToOrdinal(sensor.getData());
 					}
 				}
 			}
 			thing = getNextThing(thing);
 		}
-		if (squareIsFakeWall && (_currMap._partyPosX != mapX) && (_currMap._partyPosY != mapY)) {
-			aspectArray[kFirstGroupOrObjectAspect] = Thing::_endOfList.toUint16();
+		if (squareIsFakeWall && (_currMap._g306_partyPosX != mapX) && (_currMap._g307_partyPosY != mapY)) {
+			aspectArray[k1_FirstGroupOrObjectAspect] = Thing::_endOfList.toUint16();
 			return;
 		}
 		break;
-	case kPitElemType:
-		if (square.get(kPitOpen)) {
-			aspectArray[kPitInvisibleAspect] = square.get(kPitInvisible);
+	case k2_PitElemType:
+		if (square.get(k0x0008_PitOpen)) {
+			aspectArray[k2_PitInvisibleAspect] = square.get(k0x0004_PitInvisible);
 			footPrintsAllowed = square.toByte() & 1;
 		} else {
-			aspectArray[kElemAspect] = kCorridorElemType;
+			aspectArray[k0_ElemAspect] = k1_CorridorElemType;
 			footPrintsAllowed = true;
 		}
 		goto T0172030_Pit;
-	case kFakeWallElemType:
-		if (!square.get(kFakeWallOpen)) {
-			aspectArray[kElemAspect] = kWallElemType;
-			leftOrnAllowed = rightOrnAllowed = frontOrnAllowed = square.get(kFakeWallRandOrnOrFootPAllowed);
+	case k6_FakeWallElemType:
+		if (!square.get(k0x0004_FakeWallOpen)) {
+			aspectArray[k0_ElemAspect] = k0_WallElemType;
+			leftOrnAllowed = rightOrnAllowed = frontOrnAllowed = square.get(k0x0008_FakeWallRandOrnOrFootPAllowed);
 			squareIsFakeWall = true;
 			goto T0172010_ClosedFakeWall;
 		}
-		aspectArray[kWallElemType] = kCorridorElemType;
-		footPrintsAllowed = square.get(kFakeWallRandOrnOrFootPAllowed);
-		square = footPrintsAllowed ? 8 : 0;
+		aspectArray[k0_WallElemType] = k1_CorridorElemType;
+		footPrintsAllowed = square.get(k0x0008_FakeWallRandOrnOrFootPAllowed);
+		square = Square(footPrintsAllowed ? 8 : 0);
 		// intentional fallthrough
-	case kCorridorElemType:
-		aspectArray[kFloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(kCorridorRandOrnAllowed), _currMap._map->_randFloorOrnCount, mapX, mapY, 30);
+	case k1_CorridorElemType:
+		aspectArray[k4_FloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(k0x0008_CorridorRandOrnAllowed), _currMap._g269_map->_randFloorOrnCount, mapX, mapY, 30);
 T0172029_Teleporter:
 		footPrintsAllowed = true;
 T0172030_Pit:
-		while ((thing != Thing::_endOfList) && (thing.getType() <= kSensorThingType)) {
-			if (thing.getType() == kSensorThingType)
-				aspectArray[kFloorOrnOrdAspect] = Sensor(getThingData(thing)).getOrnOrdinal();
+		while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) {
+			if (thing.getType() == k3_SensorThingType)
+				aspectArray[k4_FloorOrnOrdAspect] = Sensor(getThingData(thing)).getOrnOrdinal();
 			thing = getNextThing(thing);
 		}
 		goto T0172049_Footprints;
-	case kTeleporterElemType:
-		aspectArray[kTeleporterVisibleAspect] = square.get(kTeleporterOpen) && square.get(kTeleporterVisible);
+	case k5_TeleporterElemType:
+		aspectArray[k2_TeleporterVisibleAspect] = square.get(k0x0008_TeleporterOpen) && square.get(k0x0004_TeleporterVisible);
 		goto T0172029_Teleporter;
-	case kStairsElemType:
-		aspectArray[kElemAspect] = ((square.get(kStairsNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) ? kStairsSideElemType : kStairsFrontElemType;
-		aspectArray[kStairsUpAspect] = square.get(kStairsUp);
+	case k3_StairsElemType:
+		aspectArray[k0_ElemAspect] = ((square.get(k0x0008_StairsNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) ? k18_StairsSideElemType : k19_StairsFrontElemType;
+		aspectArray[k2_StairsUpAspect] = square.get(k0x0004_StairsUp);
 		footPrintsAllowed = false;
 		goto T0172046_Stairs;
-	case kDoorElemType:
-		if ((square.get(kDoorNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) {
-			aspectArray[kElemAspect] = kDoorSideElemType;
+	case k4_DoorElemType:
+		if ((square.get(k0x0008_DoorNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) {
+			aspectArray[k0_ElemAspect] = k16_DoorSideElemType;
 		} else {
-			aspectArray[kElemAspect] = kDoorFrontElemType;
-			aspectArray[kDoorStateAspect] = square.getDoorState();
-			aspectArray[kDoorThingIndexAspect] = getSquareFirstThing(mapX, mapY).getIndex();
+			aspectArray[k0_ElemAspect] = k17_DoorFrontElemType;
+			aspectArray[k2_DoorStateAspect] = square.getDoorState();
+			aspectArray[k3_DoorThingIndexAspect] = getSquareFirstThing(mapX, mapY).getIndex();
 		}
 		footPrintsAllowed = true;
 T0172046_Stairs:
-		while ((thing != Thing::_endOfList) && (thing.getType() <= kSensorThingType))
+		while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType))
 			thing = getNextThing(thing);
 T0172049_Footprints:
 		unsigned char scentOrdinal; // see next line comment
 		if (footPrintsAllowed) // TODO: I skipped some party query code, must come back later and complete
-			aspectArray[kFloorOrnOrdAspect] &= kFootprintsAspect;
+			aspectArray[k4_FloorOrnOrdAspect] &= k0x8000_FootprintsAspect;
 		break;
 	default:
 		break;
 	}
-	aspectArray[kFirstGroupOrObjectAspect] = thing.toUint16();
+	aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16();
 }
 
 void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
 											int16 mapX, int16 mapY, bool isFakeWall) {
-	int16 ornCount = _currMap._map->_randWallOrnCount;
+	int16 ornCount = _currMap._g269_map->_randWallOrnCount;
 
 	turnDirRight(dir);
-	aspectArray[kRightWallOrnOrdAspect] = getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
+	aspectArray[k2_RightWallOrnOrdAspect] = getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
 	turnDirRight(dir);
-	aspectArray[kFrontWallOrnOrdAspect] = getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
+	aspectArray[k3_FrontWallOrnOrdAspect] = getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
 	turnDirRight(dir);
-	aspectArray[kLeftWallOrnOrdAspect] = getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
+	aspectArray[k4_LeftWallOrnOrdAspect] = getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
 
-	if (isFakeWall || mapX < 0 || mapX >= _currMap._width || mapY < 0 || mapY >= _currMap._height) {
-		for (uint16 i = kRightWallOrnOrdAspect; i <= kLeftWallOrnOrdAspect; ++i) {
+	if (isFakeWall || mapX < 0 || mapX >= _currMap._g273_width || mapY < 0 || mapY >= _currMap._g274_height) {
+		for (uint16 i = k2_RightWallOrnOrdAspect; i <= k4_LeftWallOrnOrdAspect; ++i) {
 			if (isWallOrnAnAlcove(_vm->ordinalToIndex(aspectArray[i])))
 				aspectArray[i] = 0;
 		}
@@ -968,8 +968,8 @@ void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowe
 
 int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) {
 	int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1)
-					+ (3000 + (_currMap._index << 6) + _currMap._width + _currMap._height) * 11
-					+ _fileHeader._ornamentRandomSeed) >> 2) % modulo;
+					+ (3000 + (_currMap._g272_index << 6) + _currMap._g273_width + _currMap._g274_height) * 11
+					+ _g278_fileHeader._ornamentRandomSeed) >> 2) % modulo;
 	if (allowed && index < count)
 		return _vm->indexToOrdinal(index);
 	return 0;
@@ -985,7 +985,7 @@ bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) {
 }
 
 uint16 *DungeonMan::getThingData(Thing thing) {
-	return _dunData._thingsData[thing.getType()][thing.getIndex()];
+	return _dunData._g284_thingsData[thing.getType()][thing.getIndex()];
 }
 
 uint16* DungeonMan::getSquareFirstThingData(int16 mapX, int16 mapY) {
@@ -1099,20 +1099,20 @@ char gInscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_Insc
 
 void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 	char sepChar;
-	TextString textString(_dunData._thingsData[kTextstringType][thing.getIndex()]);
-	if ((textString.isVisible()) || (type & kDecodeEvenIfInvisible)) {
-		type = (TextType)(type & ~kDecodeEvenIfInvisible);
-		if (type == kTextTypeMessage) {
+	TextString textString(_dunData._g284_thingsData[k2_TextstringType][thing.getIndex()]);
+	if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) {
+		type = (TextType)(type & ~k0x8000_DecodeEvenIfInvisible);
+		if (type == k1_TextTypeMessage) {
 			*destString++ = '\n';
 			sepChar = ' ';
-		} else if (type == kTextTypeInscription) {
+		} else if (type == k0_TextTypeInscription) {
 			sepChar = (char)0x80;
 		} else {
 			sepChar = '\n';
 		}
 		uint16 codeCounter = 0;
 		int16 escChar = 0;
-		uint16 *codeWord = _dunData._textData + textString.getWordOffset();
+		uint16 *codeWord = _dunData._g260_textData + textString.getWordOffset();
 		uint16 code = 0, codes = 0;
 		char *escReplString = nullptr;
 		for (;;) { /*infinite loop*/
@@ -1130,7 +1130,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 			if (escChar) {
 				*destString = '\0';
 				if (escChar == 30) {
-					if (type != kTextTypeInscription) {
+					if (type != k0_TextTypeInscription) {
 						escReplString = gMessageAndScrollEscReplacementStrings[code];
 					} else {
 						escReplString = gInscriptionEscReplacementStrings[code];
@@ -1142,7 +1142,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 				destString += strlen(escReplString);
 				escChar = 0;
 			} else if (code < 28) {
-				if (type != kTextTypeInscription) {
+				if (type != k0_TextTypeInscription) {
 					if (code == 26) {
 						code = ' ';
 					} else if (code == 27) {
@@ -1161,7 +1161,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 			}
 		}
 	}
-	*destString = ((type == kTextTypeInscription) ? 0x81 : '\0');
+	*destString = ((type == k0_TextTypeInscription) ? 0x81 : '\0');
 }
 
 
@@ -1194,18 +1194,18 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 	if (thing == Thing::_none)
 		return 0;
 	switch (thing.getType()) {
-	case kWeaponThingType:
-		return gWeaponInfo[Weapon(getThingData(thing)).getType()]._weight;
-	case kArmourThingType:
-		return gArmourInfo[Armour(getThingData(thing)).getType()]._weight;
-	case kJunkThingType: {
-		Junk junk = getThingData(thing);
+	case k5_WeaponThingType:
+		return g238_WeaponInfo[Weapon(getThingData(thing)).getType()]._weight;
+	case k6_ArmourThingType:
+		return g239_ArmourInfo[Armour(getThingData(thing)).getType()]._weight;
+	case k10_JunkThingType: {
+		Junk junk(getThingData(thing));
 		uint16 weight = junkInfo[junk.getType()];
-		if (junk.getType() == kJunkTypeWaterskin)
+		if (junk.getType() == k1_JunkTypeWaterskin)
 			weight += junk.getChargeCount() * 2;
 		return weight;
 	}
-	case kContainerThingType: {
+	case k9_ContainerThingType: {
 		uint16 weight = 50;
 		Container container(getThingData(thing));
 		Thing slotThing = container.getSlot();
@@ -1215,13 +1215,13 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 		}
 		return weight;
 	}
-	case kPotionThingType:
-		if (Junk(getThingData(thing)).getType() == kPotionTypeEmptyFlask) {
+	case k8_PotionThingType:
+		if (Junk(getThingData(thing)).getType() == k20_PotionTypeEmptyFlask) {
 			return 1;
 		} else {
 			return 3;
 		}
-	case kScrollThingType:
+	case k7_ScrollThingType:
 		return 1;
 	default:
 		break;
@@ -1235,18 +1235,18 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 int16 DungeonMan::getObjectInfoIndex(Thing thing) {
 	uint16 *rawType = getThingData(thing);
 	switch (thing.getType()) {
-	case kScrollThingType:
-		return kObjectInfoIndexFirstScroll;
-	case kContainerThingType:
-		return kObjectInfoIndexFirstContainer + Container(rawType).getType();
-	case kJunkThingType:
-		return kObjectInfoIndexFirstJunk + Junk(rawType).getType();
-	case kWeaponThingType:
-		return kObjectInfoIndexFirstWeapon + Weapon(rawType).getType();
-	case kArmourThingType:
-		return kObjectInfoIndexFirstArmour + Armour(rawType).getType();
-	case kPotionThingType:
-		return kObjectInfoIndexFirstPotion + Potion(rawType).getType();
+	case k7_ScrollThingType:
+		return k0_ObjectInfoIndexFirstScroll;
+	case k9_ContainerThingType:
+		return k1_ObjectInfoIndexFirstContainer + Container(rawType).getType();
+	case k10_JunkThingType:
+		return k127_ObjectInfoIndexFirstJunk + Junk(rawType).getType();
+	case k5_WeaponThingType:
+		return k23_ObjectInfoIndexFirstWeapon + Weapon(rawType).getType();
+	case k6_ArmourThingType:
+		return k69_ObjectInfoIndexFirstArmour + Armour(rawType).getType();
+	case k8_PotionThingType:
+		return k2_ObjectInfoIndexFirstPotion + Potion(rawType).getType();
 	default:
 		return -1;
 	}
@@ -1260,27 +1260,27 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map
 	*rawObjPtr = Thing::_endOfList.toUint16();
 
 	if (mapX >= 0) {
-		Square *squarePtr = (Square*)&_currMap._data[mapX][mapY];
-		if (squarePtr->get(kThingListPresent)) {
+		Square *squarePtr = (Square*)&_currMap._g271_data[mapX][mapY];
+		if (squarePtr->get(k0x0010_ThingListPresent)) {
 			thingInList = getSquareFirstThing(mapX, mapY);
 		} else {
-			squarePtr->set(kThingListPresent);
-			uint16 *cumulativeCount = &_currMap._colCumulativeSquareFirstThingCount[mapX + 1];
-			uint16 column = _dunData._columCount - (_dunData._mapsFirstColumnIndex[_currMap._index] + mapX) - 1;
+			squarePtr->set(k0x0010_ThingListPresent);
+			uint16 *cumulativeCount = &_currMap._g270_colCumulativeSquareFirstThingCount[mapX + 1];
+			uint16 column = _dunData._g282_columCount - (_dunData._g281_mapsFirstColumnIndex[_currMap._g272_index] + mapX) - 1;
 			while (column--) {
 				(*cumulativeCount++)++;
 			}
 			uint16 mapYStep = 0;
 			squarePtr -= mapY;
-			uint16 squareFirstThingIndex = _currMap._colCumulativeSquareFirstThingCount[mapX];
+			uint16 squareFirstThingIndex = _currMap._g270_colCumulativeSquareFirstThingCount[mapX];
 			while (mapYStep++ != mapY) {
-				if (squarePtr->get(kThingListPresent)) {
+				if (squarePtr->get(k0x0010_ThingListPresent)) {
 					squareFirstThingIndex++;
 				}
 				squarePtr++;
 			}
-			Thing* thingPtr = &_dunData._squareFirstThings[squareFirstThingIndex];
-			memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_fileHeader._squareFirstThingCount - squareFirstThingIndex - 1));
+			Thing* thingPtr = &_dunData._g283_squareFirstThings[squareFirstThingIndex];
+			memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_g278_fileHeader._squareFirstThingCount - squareFirstThingIndex - 1));
 			*thingPtr = thingToLink;
 			return;
 		}
@@ -1297,7 +1297,7 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map
 
 WeaponInfo* DungeonMan::getWeaponInfo(Thing thing) {
 	Weapon* weapon = (Weapon*)getThingData(thing);
-	return &gWeaponInfo[weapon->getType()];
+	return &g238_WeaponInfo[weapon->getType()];
 }
 
 int16 DungeonMan::getProjectileAspect(Thing thing) {
@@ -1305,7 +1305,7 @@ int16 DungeonMan::getProjectileAspect(Thing thing) {
 	int16 projAspOrd;
 	WeaponInfo *weaponInfo;
 
-	if ((thingType = thing.getType()) == kExplosionThingType) {
+	if ((thingType = thing.getType()) == k15_ExplosionThingType) {
 		if (thing == Thing::_explFireBall)
 			return -_vm->indexToOrdinal(k10_ProjectileAspectExplosionFireBall);
 		if (thing == Thing::_explSlime)
@@ -1316,13 +1316,13 @@ int16 DungeonMan::getProjectileAspect(Thing thing) {
 			return -_vm->indexToOrdinal(k13_ProjectileAspectExplosionPoisonBoltCloud);
 
 		return -_vm->indexToOrdinal(k11_ProjectileAspectExplosionDefault);
-	} else if (thingType == kWeaponThingType) {
+	} else if (thingType == k5_WeaponThingType) {
 		weaponInfo = getWeaponInfo(thing);
 		if (projAspOrd = weaponInfo->getProjectileAspectOrdinal())
 			return -projAspOrd;
 	}
 
-	return gObjectInfo[getObjectInfoIndex(thing)]._objectAspectIndex;
+	return g237_ObjectInfo[getObjectInfoIndex(thing)]._objectAspectIndex;
 }
 
 }
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index b3f81d8..d6ebdc0 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -35,44 +35,44 @@
 namespace DM {
 
 /* Object info */
-#define kObjectInfoIndexFirstScroll 0 // @ C000_OBJECT_INFO_INDEX_FIRST_SCROLL
-#define kObjectInfoIndexFirstContainer 1 // @ C001_OBJECT_INFO_INDEX_FIRST_CONTAINER
-#define kObjectInfoIndexFirstPotion 2 // @ C002_OBJECT_INFO_INDEX_FIRST_POTION
-#define kObjectInfoIndexFirstWeapon 23 // @ C023_OBJECT_INFO_INDEX_FIRST_WEAPON
-#define kObjectInfoIndexFirstArmour 69 // @ C069_OBJECT_INFO_INDEX_FIRST_ARMOUR
-#define kObjectInfoIndexFirstJunk 127 // @ C127_OBJECT_INFO_INDEX_FIRST_JUNK
+#define k0_ObjectInfoIndexFirstScroll 0 // @ C000_OBJECT_INFO_INDEX_FIRST_SCROLL
+#define k1_ObjectInfoIndexFirstContainer 1 // @ C001_OBJECT_INFO_INDEX_FIRST_CONTAINER
+#define k2_ObjectInfoIndexFirstPotion 2 // @ C002_OBJECT_INFO_INDEX_FIRST_POTION
+#define k23_ObjectInfoIndexFirstWeapon 23 // @ C023_OBJECT_INFO_INDEX_FIRST_WEAPON
+#define k69_ObjectInfoIndexFirstArmour 69 // @ C069_OBJECT_INFO_INDEX_FIRST_ARMOUR
+#define k127_ObjectInfoIndexFirstJunk 127 // @ C127_OBJECT_INFO_INDEX_FIRST_JUNK
 
-#define kMapXNotOnASquare -1 // @ CM1_MAPX_NOT_ON_A_SQUARE
+#define kM1_MapXNotOnASquare -1 // @ CM1_MAPX_NOT_ON_A_SQUARE
 
 enum ElementType {
-	kElementTypeChampion = -2, // @ CM2_ELEMENT_CHAMPION /* Values -2 and -1 are only used as projectile impact types */
-	kElementTypeCreature = -1, // @ CM1_ELEMENT_CREATURE
-	kElementTypeWall = 0, // @ C00_ELEMENT_WALL /* Values 0-6 are used as square types and projectile impact types. Values 0-2 and 5-6 are also used for square aspect */
-	kElementTypeCorridor = 1, // @ C01_ELEMENT_CORRIDOR
-	kElementTypePit = 2, // @ C02_ELEMENT_PIT
-	kElementTypeStairs = 3, // @ C03_ELEMENT_STAIRS
-	kElementTypeDoor = 4, // @ C04_ELEMENT_DOOR
-	kElementTypeTeleporter = 5, // @ C05_ELEMENT_TELEPORTER
-	kElementTypeFakeWall = 6, // @ C06_ELEMENT_FAKEWALL
-	kElementTypeDoorSide = 16, // @ C16_ELEMENT_DOOR_SIDE /* Values 16-19 are only used for square aspect */
-	kElementTypeDoorFront = 17, // @ C17_ELEMENT_DOOR_FRONT
-	kElementTypeStairsSide = 18, // @ C18_ELEMENT_STAIRS_SIDE
-	kElementTypeStaisFront = 19  // @ C19_ELEMENT_STAIRS_FRONT	
+	kM2_ElementTypeChampion = -2, // @ CM2_ELEMENT_CHAMPION /* Values -2 and -1 are only used as projectile impact types */
+	kM1_ElementTypeCreature = -1, // @ CM1_ELEMENT_CREATURE
+	k0_ElementTypeWall = 0, // @ C00_ELEMENT_WALL /* Values 0-6 are used as square types and projectile impact types. Values 0-2 and 5-6 are also used for square aspect */
+	k1_ElementTypeCorridor = 1, // @ C01_ELEMENT_CORRIDOR
+	k2_ElementTypePit = 2, // @ C02_ELEMENT_PIT
+	k3_ElementTypeStairs = 3, // @ C03_ELEMENT_STAIRS
+	k4_ElementTypeDoor = 4, // @ C04_ELEMENT_DOOR
+	k5_ElementTypeTeleporter = 5, // @ C05_ELEMENT_TELEPORTER
+	k6_ElementTypeFakeWall = 6, // @ C06_ELEMENT_FAKEWALL
+	k16_ElementTypeDoorSide = 16, // @ C16_ELEMENT_DOOR_SIDE /* Values 16-19 are only used for square aspect */
+	k17_ElementTypeDoorFront = 17, // @ C17_ELEMENT_DOOR_FRONT
+	k18_ElementTypeStairsSide = 18, // @ C18_ELEMENT_STAIRS_SIDE
+	k19_ElementTypeStaisFront = 19  // @ C19_ELEMENT_STAIRS_FRONT	
 };
 
 
 enum ObjectAllowedSlot {
-	kObjectAllowedSlotMouth = 0x0001, // @ MASK0x0001_MOUTH
-	kObjectAllowedSlotHead = 0x0002, // @ MASK0x0002_HEAD
-	kObjectAllowedSlotNeck = 0x0004, // @ MASK0x0004_NECK
-	kObjectAllowedSlotTorso = 0x0008, // @ MASK0x0008_TORSO
-	kObjectAllowedSlotLegs = 0x0010, // @ MASK0x0010_LEGS
-	kObjectAllowedSlotFeet = 0x0020, // @ MASK0x0020_FEET
-	kObjectAllowedSlotQuiverLine_1 = 0x0040, // @ MASK0x0040_QUIVER_LINE1
-	kObjectAllowedSlotQuiverLine_2 = 0x0080, // @ MASK0x0080_QUIVER_LINE2
-	kObjectAllowedSlotPouchPassAndThroughDoors = 0x0100, // @ MASK0x0100_POUCH_PASS_AND_THROUGH_DOORS
-	kObjectAllowedSlotHands = 0x0200, // @ MASK0x0200_HANDS
-	kObjectAllowedSlotContainer = 0x0400 // @ MASK0x0400_CONTAINER
+	k0x0001_ObjectAllowedSlotMouth = 0x0001, // @ MASK0x0001_MOUTH
+	k0x0002_ObjectAllowedSlotHead = 0x0002, // @ MASK0x0002_HEAD
+	k0x0004_ObjectAllowedSlotNeck = 0x0004, // @ MASK0x0004_NECK
+	k0x0008_ObjectAllowedSlotTorso = 0x0008, // @ MASK0x0008_TORSO
+	k0x0010_ObjectAllowedSlotLegs = 0x0010, // @ MASK0x0010_LEGS
+	k0x0020_ObjectAllowedSlotFeet = 0x0020, // @ MASK0x0020_FEET
+	k0x0040_ObjectAllowedSlotQuiverLine_1 = 0x0040, // @ MASK0x0040_QUIVER_LINE1
+	k0x0080_ObjectAllowedSlotQuiverLine_2 = 0x0080, // @ MASK0x0080_QUIVER_LINE2
+	k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors = 0x0100, // @ MASK0x0100_POUCH_PASS_AND_THROUGH_DOORS
+	k0x0200_ObjectAllowedSlotHands = 0x0200, // @ MASK0x0200_HANDS
+	k0x0400_ObjectAllowedSlotContainer = 0x0400 // @ MASK0x0400_CONTAINER
 };
 
 class ObjectInfo {
@@ -96,11 +96,11 @@ public:
 	}
 }; // @ OBJECT_INFO
 
-extern ObjectInfo gObjectInfo[180];
+extern ObjectInfo g237_ObjectInfo[180]; // @ G0237_as_Graphic559_ObjectInfo
 
 enum ArmourAttribute {
-	kArmourAttributeIsAShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD
-	kArmourAttributeSharpDefense = 0x0007 // @ MASK0x0007_SHARP_DEFENSE
+	k0x0080_ArmourAttributeIsAShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD
+	k0x0007_ArmourAttributeSharpDefense = 0x0007 // @ MASK0x0007_SHARP_DEFENSE
 };
 
 class ArmourInfo {
@@ -117,22 +117,22 @@ public:
 	void setAttribute(ArmourAttribute attribute) { _attributes |= attribute; }
 }; // @ ARMOUR_INFO
 
-extern ArmourInfo gArmourInfo[58];
+extern ArmourInfo g239_ArmourInfo[58]; // G0239_as_Graphic559_ArmourInfo
 
 /* Class 0: SWING weapons */
-#define kWeaponClassSwingWeapon			0 // @ C000_CLASS_SWING_WEAPON 
+#define k0_WeaponClassSwingWeapon			0 // @ C000_CLASS_SWING_WEAPON 
 /* Class 1 to 15: THROW weapons */
-#define kWeaponClassDaggerAndAxes		2 // @ C002_CLASS_DAGGER_AND_AXES 
-#define kWeaponClassBowAmmunition		10 // @ C010_CLASS_BOW_AMMUNITION
-#define kWeaponClassSlingAmmunition		11 // @ C011_CLASS_SLING_AMMUNITION
-#define kWeaponClassPoisinDart			12 // @ C012_CLASS_POISON_DART
+#define k2_WeaponClassDaggerAndAxes		2 // @ C002_CLASS_DAGGER_AND_AXES 
+#define k10_WeaponClassBowAmmunition		10 // @ C010_CLASS_BOW_AMMUNITION
+#define k11_WeaponClassSlingAmmunition		11 // @ C011_CLASS_SLING_AMMUNITION
+#define k12_WeaponClassPoisinDart			12 // @ C012_CLASS_POISON_DART
 /* Class 16 to 111: SHOOT weapons */
-#define kWeaponClassFirstBow			16 // @ C016_CLASS_FIRST_BOW 
-#define kWeaponClassLastBow				31 // @ C031_CLASS_LAST_BOW
-#define kWeaponClassFirstSling			32 // @ C032_CLASS_FIRST_SLING
-#define kWeaponClassLastSling			47 // @ C047_CLASS_LAST_SLING
+#define k16_WeaponClassFirstBow			16 // @ C016_CLASS_FIRST_BOW 
+#define k31_WeaponClassLastBow				31 // @ C031_CLASS_LAST_BOW
+#define k32_WeaponClassFirstSling			32 // @ C032_CLASS_FIRST_SLING
+#define k47_WeaponClassLastSling			47 // @ C047_CLASS_LAST_SLING
 /* Class 112 to 255: Magic and special weapons */
-#define kWeaponClassFirstMagicWeapon	112 // @ C112_CLASS_FIRST_MAGIC_WEAPON
+#define k112_WeaponClassFirstMagicWeapon	112 // @ C112_CLASS_FIRST_MAGIC_WEAPON
 
 class WeaponInfo {
 
@@ -151,32 +151,32 @@ public:
 	uint16 getProjectileAspectOrdinal() { return (_attributes >> 8) & 0x1F; } // @ M66_PROJECTILE_ASPECT_ORDINAL
 }; // @ WEAPON_INFO
 
-extern WeaponInfo gWeaponInfo[46];
+extern WeaponInfo g238_WeaponInfo[46]; // @ G0238_as_Graphic559_WeaponInfo;
 
 enum TextType {
 	/* Used for text on walls */
-	kTextTypeInscription = 0, // @ C0_TEXT_TYPE_INSCRIPTION 
+	k0_TextTypeInscription = 0, // @ C0_TEXT_TYPE_INSCRIPTION 
 	/* Used for messages displayed when the party walks on a square */
-	kTextTypeMessage = 1, // @ C1_TEXT_TYPE_MESSAGE 
+	k1_TextTypeMessage = 1, // @ C1_TEXT_TYPE_MESSAGE 
 	/* Used for text on scrolls and champion information */
-	kTextTypeScroll = 2 // @ C2_TEXT_TYPE_SCROLL 
+	k2_TextTypeScroll = 2 // @ C2_TEXT_TYPE_SCROLL 
 };
 
 enum SquareAspectIndice {
-	kElemAspect = 0, // @ C0_ELEMENT
-	kFirstGroupOrObjectAspect = 1, // @ C1_FIRST_GROUP_OR_OBJECT 
-	kRightWallOrnOrdAspect = 2, // @ C2_RIGHT_WALL_ORNAMENT_ORDINAL 
-	kFrontWallOrnOrdAspect = 3, // @ C3_FRONT_WALL_ORNAMENT_ORDINAL 
-	kLeftWallOrnOrdAspect = 4, // @ C4_LEFT_WALL_ORNAMENT_ORDINAL 
-	kPitInvisibleAspect = 2, // @ C2_PIT_INVISIBLE 
-	kTeleporterVisibleAspect = 2, // @ C2_TELEPORTER_VISIBLE 
-	kStairsUpAspect = 2, // @ C2_STAIRS_UP 
-	kDoorStateAspect = 2, // @ C2_DOOR_STATE 
-	kDoorThingIndexAspect = 3, // @ C3_DOOR_THING_INDEX 
-	kFloorOrnOrdAspect = 4, // @ C4_FLOOR_ORNAMENT_ORDINAL 
-	kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS             
+	k0_ElemAspect = 0, // @ C0_ELEMENT
+	k1_FirstGroupOrObjectAspect = 1, // @ C1_FIRST_GROUP_OR_OBJECT 
+	k2_RightWallOrnOrdAspect = 2, // @ C2_RIGHT_WALL_ORNAMENT_ORDINAL 
+	k3_FrontWallOrnOrdAspect = 3, // @ C3_FRONT_WALL_ORNAMENT_ORDINAL 
+	k4_LeftWallOrnOrdAspect = 4, // @ C4_LEFT_WALL_ORNAMENT_ORDINAL 
+	k2_PitInvisibleAspect = 2, // @ C2_PIT_INVISIBLE 
+	k2_TeleporterVisibleAspect = 2, // @ C2_TELEPORTER_VISIBLE 
+	k2_StairsUpAspect = 2, // @ C2_STAIRS_UP 
+	k2_DoorStateAspect = 2, // @ C2_DOOR_STATE 
+	k3_DoorThingIndexAspect = 3, // @ C3_DOOR_THING_INDEX 
+	k4_FloorOrnOrdAspect = 4, // @ C4_FLOOR_ORNAMENT_ORDINAL 
+	k0x8000_FootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS             
 };
-;
+
 
                
 
@@ -202,7 +202,7 @@ struct CreatureInfo {
 }; // @ CREATURE_INFO
 
 
-extern CreatureInfo gCreatureInfo[k27_CreatureTypeCount];
+extern CreatureInfo g243_CreatureInfo[k27_CreatureTypeCount]; // @ G0243_as_Graphic559_CreatureInfo
 
 class Door {
 	Thing _nextThing;
@@ -219,8 +219,8 @@ public:
 }; // @ DOOR
 
 enum TeleporterScope {
-	kTelepScopeCreatures = 1, // @ MASK0x0001_SCOPE_CREATURES
-	kTelepScopeObjOrParty = 2 // @ MASK0x0002_SCOPE_OBJECTS_OR_PARTY
+	k0x0001_TelepScopeCreatures = 1, // @ MASK0x0001_SCOPE_CREATURES
+	k0x0002_TelepScopeObjOrParty = 2 // @ MASK0x0002_SCOPE_OBJECTS_OR_PARTY
 };
 
 
@@ -254,44 +254,44 @@ public:
 }; // @ TEXTSTRING
 
 enum SensorActionType {
-	kSensorEffNone = -1, // @ CM1_EFFECT_NONE
-	kSensorEffSet = 0, // @ C00_EFFECT_SET
-	kSensorEffClear = 1, // @ C01_EFFECT_CLEAR
-	kSensorEffToggle = 2, // @ C02_EFFECT_TOGGLE
-	kSensorEffHold = 3, // @ C03_EFFECT_HOLD
-	kSensorEffAddExp = 10 // @ C10_EFFECT_ADD_EXPERIENCE
+	kM1_SensorEffNone = -1, // @ CM1_EFFECT_NONE
+	k0_SensorEffSet = 0, // @ C00_EFFECT_SET
+	k1_SensorEffClear = 1, // @ C01_EFFECT_CLEAR
+	k2_SensorEffToggle = 2, // @ C02_EFFECT_TOGGLE
+	k3_SensorEffHold = 3, // @ C03_EFFECT_HOLD
+	k10_SensorEffAddExp = 10 // @ C10_EFFECT_ADD_EXPERIENCE
 };
 
 enum SensorType {
-	kSensorDisabled = 0, // @ C000_SENSOR_DISABLED    /* Never triggered, may be used for a floor or wall ornament */
-	kSensorFloorTheronPartyCreatureObj = 1, // @ C001_SENSOR_FLOOR_THERON_PARTY_CREATURE_OBJECT    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorFloorTheronPartyCreature = 2, // @ C002_SENSOR_FLOOR_THERON_PARTY_CREATURE    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorFloorParty = 3, // @ C003_SENSOR_FLOOR_PARTY    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorFloorObj = 4, // @ C004_SENSOR_FLOOR_OBJECT    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorFloorPartyOnStairs = 5, // @ C005_SENSOR_FLOOR_PARTY_ON_STAIRS    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorFloorGroupGenerator = 6, // @ C006_SENSOR_FLOOR_GROUP_GENERATOR    /* Triggered by event F0245_TIMELINE_ProcessEvent5_Square_Corridor */
-	kSensorFloorCreature = 7, // @ C007_SENSOR_FLOOR_CREATURE    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorFloorPartyPossession = 8, // @ C008_SENSOR_FLOOR_PARTY_POSSESSION    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorFloorVersionChecker = 9, // @ C009_SENSOR_FLOOR_VERSION_CHECKER    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
-	kSensorWallOrnClick = 1, // @ C001_SENSOR_WALL_ORNAMENT_CLICK    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallOrnClickWithAnyObj = 2, // @ C002_SENSOR_WALL_ORNAMENT_CLICK_WITH_ANY_OBJECT    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallOrnClickWithSpecObj = 3, // @ C003_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallOrnClickWithSpecObjRemoved = 4, // @ C004_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallAndOrGate = 5, // @ C005_SENSOR_WALL_AND_OR_GATE    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallCountdown = 6, // @ C006_SENSOR_WALL_COUNTDOWN    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallSingleProjLauncherNewObj = 7, // @ C007_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_NEW_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallSingleProjLauncherExplosion = 8, // @ C008_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_EXPLOSION    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallDoubleProjLauncherNewObj = 9, // @ C009_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_NEW_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallDoubleProjLauncherExplosion = 10, // @ C010_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_EXPLOSION    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallOrnClickWithSpecObjRemovedRotateSensors = 11, // @ C011_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_ROTATE_SENSORS   /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallObjGeneratorRotateSensors = 12, // @ C012_SENSOR_WALL_OBJECT_GENERATOR_ROTATE_SENSORS    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallSingleObjStorageRotateSensors = 13, // @ C013_SENSOR_WALL_SINGLE_OBJECT_STORAGE_ROTATE_SENSORS    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallSingleProjLauncherSquareObj = 14, // @ C014_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallDoubleProjLauncherSquareObj = 15, // @ C015_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallObjExchanger = 16, // @ C016_SENSOR_WALL_OBJECT_EXCHANGER    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallOrnClickWithSpecObjRemovedSensor = 17, // @ C017_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_REMOVE_SENSOR    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
-	kSensorWallEndGame = 18, // @ C018_SENSOR_WALL_END_GAME    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
-	kSensorWallChampionPortrait = 127 // @ C127_SENSOR_WALL_CHAMPION_PORTRAIT    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	k0_SensorDisabled = 0, // @ C000_SENSOR_DISABLED    /* Never triggered, may be used for a floor or wall ornament */
+	k1_SensorFloorTheronPartyCreatureObj = 1, // @ C001_SENSOR_FLOOR_THERON_PARTY_CREATURE_OBJECT    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	k2_SensorFloorTheronPartyCreature = 2, // @ C002_SENSOR_FLOOR_THERON_PARTY_CREATURE    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	k3_SensorFloorParty = 3, // @ C003_SENSOR_FLOOR_PARTY    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	k4_SensorFloorObj = 4, // @ C004_SENSOR_FLOOR_OBJECT    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	k5_SensorFloorPartyOnStairs = 5, // @ C005_SENSOR_FLOOR_PARTY_ON_STAIRS    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	k6_SensorFloorGroupGenerator = 6, // @ C006_SENSOR_FLOOR_GROUP_GENERATOR    /* Triggered by event F0245_TIMELINE_ProcessEvent5_Square_Corridor */
+	k7_SensorFloorCreature = 7, // @ C007_SENSOR_FLOOR_CREATURE    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	k8_SensorFloorPartyPossession = 8, // @ C008_SENSOR_FLOOR_PARTY_POSSESSION    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	k9_SensorFloorVersionChecker = 9, // @ C009_SENSOR_FLOOR_VERSION_CHECKER    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
+	k1_SensorWallOrnClick = 1, // @ C001_SENSOR_WALL_ORNAMENT_CLICK    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	k2_SensorWallOrnClickWithAnyObj = 2, // @ C002_SENSOR_WALL_ORNAMENT_CLICK_WITH_ANY_OBJECT    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	k3_SensorWallOrnClickWithSpecObj = 3, // @ C003_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	k4_SensorWallOrnClickWithSpecObjRemoved = 4, // @ C004_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	k5_SensorWallAndOrGate = 5, // @ C005_SENSOR_WALL_AND_OR_GATE    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	k6_SensorWallCountdown = 6, // @ C006_SENSOR_WALL_COUNTDOWN    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	k7_SensorWallSingleProjLauncherNewObj = 7, // @ C007_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_NEW_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	k8_SensorWallSingleProjLauncherExplosion = 8, // @ C008_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_EXPLOSION    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	k9_SensorWallDoubleProjLauncherNewObj = 9, // @ C009_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_NEW_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	k10_SensorWallDoubleProjLauncherExplosion = 10, // @ C010_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_EXPLOSION    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors = 11, // @ C011_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_ROTATE_SENSORS   /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	k12_SensorWallObjGeneratorRotateSensors = 12, // @ C012_SENSOR_WALL_OBJECT_GENERATOR_ROTATE_SENSORS    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	k13_SensorWallSingleObjStorageRotateSensors = 13, // @ C013_SENSOR_WALL_SINGLE_OBJECT_STORAGE_ROTATE_SENSORS    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	k14_SensorWallSingleProjLauncherSquareObj = 14, // @ C014_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	k15_SensorWallDoubleProjLauncherSquareObj = 15, // @ C015_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	k16_SensorWallObjExchanger = 16, // @ C016_SENSOR_WALL_OBJECT_EXCHANGER    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	k17_SensorWallOrnClickWithSpecObjRemovedSensor = 17, // @ C017_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_REMOVE_SENSOR    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
+	k18_SensorWallEndGame = 18, // @ C018_SENSOR_WALL_END_GAME    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
+	k127_SensorWallChampionPortrait = 127 // @ C127_SENSOR_WALL_CHAMPION_PORTRAIT    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
 };
 
 class Sensor {
@@ -331,17 +331,17 @@ public:
 
 
 enum WeaponType {
-	kWeaponTypeTorch = 2, // @ C02_WEAPON_TORCH
-	kWeaponTypeDagger = 8, // @ C08_WEAPON_DAGGER
-	kWeaponTypeFalchion = 9, // @ C09_WEAPON_FALCHION
-	kWeaponTypeSword = 10, // @ C10_WEAPON_SWORD
-	kWeaponTypeClub = 23, // @ C23_WEAPON_CLUB
-	kWeaponTypeStoneClub = 24, // @ C24_WEAPON_STONE_CLUB
-	kWeaponTypeArrow = 27, // @ C27_WEAPON_ARROW
-	kWeaponTypeSlayer = 28, // @ C28_WEAPON_SLAYER
-	kWeaponTypeRock = 30, // @ C30_WEAPON_ROCK
-	kWeaponTypePoisonDart = 31, // @ C31_WEAPON_POISON_DART
-	kWeaponTypeThrowingStar = 32 // @ C32_WEAPON_THROWING_STAR
+	k2_WeaponTypeTorch = 2, // @ C02_WEAPON_TORCH
+	k8_WeaponTypeDagger = 8, // @ C08_WEAPON_DAGGER
+	k9_WeaponTypeFalchion = 9, // @ C09_WEAPON_FALCHION
+	k10_WeaponTypeSword = 10, // @ C10_WEAPON_SWORD
+	k23_WeaponTypeClub = 23, // @ C23_WEAPON_CLUB
+	k24_WeaponTypeStoneClub = 24, // @ C24_WEAPON_STONE_CLUB
+	k27_WeaponTypeArrow = 27, // @ C27_WEAPON_ARROW
+	k28_WeaponTypeSlayer = 28, // @ C28_WEAPON_SLAYER
+	k30_WeaponTypeRock = 30, // @ C30_WEAPON_ROCK
+	k31_WeaponTypePoisonDart = 31, // @ C31_WEAPON_POISON_DART
+	k32_WeaponTypeThrowingStar = 32 // @ C32_WEAPON_THROWING_STAR
 };
 class Weapon {
 	Thing _nextThing;
@@ -365,11 +365,11 @@ public:
 }; // @ WEAPON
 
 enum ArmourType {
-	kArmourTypeWoodenShield = 30, // @ C30_ARMOUR_WOODEN_SHIELD
-	kArmourTypeArmet = 38, // @ C38_ARMOUR_ARMET
-	kArmourTypeTorsoPlate = 39, // @ C39_ARMOUR_TORSO_PLATE
-	kArmourTypeLegPlate = 40, // @ C40_ARMOUR_LEG_PLATE
-	kArmourTypeFootPlate = 41 // @ C41_ARMOUR_FOOT_PLATE
+	k30_ArmourTypeWoodenShield = 30, // @ C30_ARMOUR_WOODEN_SHIELD
+	k38_ArmourTypeArmet = 38, // @ C38_ARMOUR_ARMET
+	k39_ArmourTypeTorsoPlate = 39, // @ C39_ARMOUR_TORSO_PLATE
+	k40_ArmourTypeLegPlate = 40, // @ C40_ARMOUR_LEG_PLATE
+	k41_ArmourTypeFootPlate = 41 // @ C41_ARMOUR_FOOT_PLATE
 };
 class Armour {
 	Thing _nextThing;
@@ -404,19 +404,19 @@ public:
 }; // @ SCROLL
 
 enum PotionType {
-	kPotionTypeVen = 3, // @ C03_POTION_VEN_POTION,
-	kPotionTypeRos = 6, // @ C06_POTION_ROS_POTION,
-	kPotionTypeKu = 7, // @ C07_POTION_KU_POTION,
-	kPotionTypeDane = 8, // @ C08_POTION_DANE_POTION,
-	kPotionTypeNeta = 9, // @ C09_POTION_NETA_POTION,
-	kPotionTypeAntivenin = 10, // @ C10_POTION_ANTIVENIN,
-	kPotionTypeMon = 11, // @ C11_POTION_MON_POTION,
-	kPotionTypeYa = 12, // @ C12_POTION_YA_POTION,
-	kPotionTypeEe = 13, // @ C13_POTION_EE_POTION,
-	kPotionTypeVi = 14, // @ C14_POTION_VI_POTION,
-	kPotionTypeWaterFlask = 15, // @ C15_POTION_WATER_FLASK,
-	kPotionTypeFulBomb = 19, // @ C19_POTION_FUL_BOMB,
-	kPotionTypeEmptyFlask = 20 // @ C20_POTION_EMPTY_FLASK,
+	k3_PotionTypeVen = 3, // @ C03_POTION_VEN_POTION,
+	k6_PotionTypeRos = 6, // @ C06_POTION_ROS_POTION,
+	k7_PotionTypeKu = 7, // @ C07_POTION_KU_POTION,
+	k8_PotionTypeDane = 8, // @ C08_POTION_DANE_POTION,
+	k9_PotionTypeNeta = 9, // @ C09_POTION_NETA_POTION,
+	k10_PotionTypeAntivenin = 10, // @ C10_POTION_ANTIVENIN,
+	k11_PotionTypeMon = 11, // @ C11_POTION_MON_POTION,
+	k12_PotionTypeYa = 12, // @ C12_POTION_YA_POTION,
+	k13_PotionTypeEe = 13, // @ C13_POTION_EE_POTION,
+	k14_PotionTypeVi = 14, // @ C14_POTION_VI_POTION,
+	k15_PotionTypeWaterFlask = 15, // @ C15_POTION_WATER_FLASK,
+	k19_PotionTypeFulBomb = 19, // @ C19_POTION_FUL_BOMB,
+	k20_PotionTypeEmptyFlask = 20 // @ C20_POTION_EMPTY_FLASK,
 };
 class Potion {
 	Thing _nextThing;
@@ -443,16 +443,16 @@ public:
 }; // @ CONTAINER
 
 enum JunkType {
-	kJunkTypeWaterskin = 1, // @ C01_JUNK_WATERSKIN,
-	kJunkTypeBones = 5, // @ C05_JUNK_BONES,
-	kJunkTypeBoulder = 25, // @ C25_JUNK_BOULDER,
-	kJunkTypeScreamerSlice = 33, // @ C33_JUNK_SCREAMER_SLICE,
-	kJunkTypeWormRound = 34, // @ C34_JUNK_WORM_ROUND,
-	kJunkTypeDrumstickShank = 35, // @ C35_JUNK_DRUMSTICK_SHANK,
-	kJunkTypeDragonSteak = 36, // @ C36_JUNK_DRAGON_STEAK,
-	kJunkTypeMagicalBoxBlue = 42, // @ C42_JUNK_MAGICAL_BOX_BLUE,
-	kJunkTypeMagicalBoxGreen = 43, // @ C43_JUNK_MAGICAL_BOX_GREEN,
-	kJunkTypeZokathra = 51 // @ C51_JUNK_ZOKATHRA,
+	k1_JunkTypeWaterskin = 1, // @ C01_JUNK_WATERSKIN,
+	k5_JunkTypeBones = 5, // @ C05_JUNK_BONES,
+	k25_JunkTypeBoulder = 25, // @ C25_JUNK_BOULDER,
+	k33_JunkTypeScreamerSlice = 33, // @ C33_JUNK_SCREAMER_SLICE,
+	k34_JunkTypeWormRound = 34, // @ C34_JUNK_WORM_ROUND,
+	k35_JunkTypeDrumstickShank = 35, // @ C35_JUNK_DRUMSTICK_SHANK,
+	k36_JunkTypeDragonSteak = 36, // @ C36_JUNK_DRAGON_STEAK,
+	k42_JunkTypeMagicalBoxBlue = 42, // @ C42_JUNK_MAGICAL_BOX_BLUE,
+	k43_JunkTypeMagicalBoxGreen = 43, // @ C43_JUNK_MAGICAL_BOX_GREEN,
+	k51_JunkTypeZokathra = 51 // @ C51_JUNK_ZOKATHRA,
 };
 
 class Junk {
@@ -481,17 +481,17 @@ public:
 	Thing getNextThing() { return _nextThing; }
 }; // @ PROJECTILE
 
-#define kExplosionType_Fireball 0 // @ C000_EXPLOSION_FIREBALL           
-#define kExplosionType_Slime 1 // @ C001_EXPLOSION_SLIME              
-#define kExplosionType_LightningBolt 2 // @ C002_EXPLOSION_LIGHTNING_BOLT     
-#define kExplosionType_HarmNonMaterial 3 // @ C003_EXPLOSION_HARM_NON_MATERIAL  
-#define kExplosionType_OpenDoor 4 // @ C004_EXPLOSION_OPEN_DOOR          
-#define kExplosionType_PoisonBolt 6 // @ C006_EXPLOSION_POISON_BOLT        
-#define kExplosionType_PoisonCloud 7 // @ C007_EXPLOSION_POISON_CLOUD       
-#define kExplosionType_Smoke 40 // @ C040_EXPLOSION_SMOKE             
-#define kExplosionType_Fluxcage 50 // @ C050_EXPLOSION_FLUXCAGE          
-#define kExplosionType_RebirthStep1 100 // @ C100_EXPLOSION_REBIRTH_STEP1    
-#define kExplosionType_RebirthStep2 101 // @ C101_EXPLOSION_REBIRTH_STEP2    
+#define k0_ExplosionType_Fireball 0 // @ C000_EXPLOSION_FIREBALL           
+#define k1_ExplosionType_Slime 1 // @ C001_EXPLOSION_SLIME              
+#define k2_ExplosionType_LightningBolt 2 // @ C002_EXPLOSION_LIGHTNING_BOLT     
+#define k3_ExplosionType_HarmNonMaterial 3 // @ C003_EXPLOSION_HARM_NON_MATERIAL  
+#define k4_ExplosionType_OpenDoor 4 // @ C004_EXPLOSION_OPEN_DOOR          
+#define k6_ExplosionType_PoisonBolt 6 // @ C006_EXPLOSION_POISON_BOLT        
+#define k7_ExplosionType_PoisonCloud 7 // @ C007_EXPLOSION_POISON_CLOUD       
+#define k40_ExplosionType_Smoke 40 // @ C040_EXPLOSION_SMOKE             
+#define k50_ExplosionType_Fluxcage 50 // @ C050_EXPLOSION_FLUXCAGE          
+#define k100_ExplosionType_RebirthStep1 100 // @ C100_EXPLOSION_REBIRTH_STEP1    
+#define k101_ExplosionType_RebirthStep2 101 // @ C101_EXPLOSION_REBIRTH_STEP2    
 
 class Explosion {
 	Thing _nextThing;
@@ -507,40 +507,40 @@ public:
 
 
 enum SquareMask {
-	kWallWestRandOrnAllowed = 0x1,
-	kWallSouthRandOrnAllowed = 0x2,
-	kWallEastRandOrnAllowed = 0x4,
-	kWallNorthRandOrnAllowed = 0x8,
-	kCorridorRandOrnAllowed = 0x8,
-	kPitImaginary = 0x1,
-	kPitInvisible = 0x4,
-	kPitOpen = 0x8,
-	kStairsUp = 0x4,
-	kStairsNorthSouthOrient = 0x8,
-	kDoorNorthSouthOrient = 0x8,
-	kTeleporterVisible = 0x4,
-	kTeleporterOpen = 0x8,
-	kFakeWallImaginary = 0x1,
-	kFakeWallOpen = 0x4,
-	kFakeWallRandOrnOrFootPAllowed = 0x8,
-	kThingListPresent = 0x10,
-	kDecodeEvenIfInvisible = 0x8000
+	k0x0001_WallWestRandOrnAllowed = 0x1, // @ MASK0x0001_WALL_WEST_RANDOM_ORNAMENT_ALLOWED 
+	k0x0002_WallSouthRandOrnAllowed = 0x2, // @ MASK0x0002_WALL_SOUTH_RANDOM_ORNAMENT_ALLOWED 
+	k0x0004_WallEastRandOrnAllowed = 0x4, // @ MASK0x0004_WALL_EAST_RANDOM_ORNAMENT_ALLOWED 
+	k0x0008_WallNorthRandOrnAllowed = 0x8, // @ MASK0x0008_WALL_NORTH_RANDOM_ORNAMENT_ALLOWED 
+	k0x0008_CorridorRandOrnAllowed = 0x8, // @ MASK0x0008_CORRIDOR_RANDOM_ORNAMENT_ALLOWED 
+	k0x0001_PitImaginary = 0x1, // @ MASK0x0001_PIT_IMAGINARY 
+	k0x0004_PitInvisible = 0x4, // @ MASK0x0004_PIT_INVISIBLE 
+	k0x0008_PitOpen = 0x8, // @ MASK0x0008_PIT_OPEN 
+	k0x0004_StairsUp = 0x4, // @ MASK0x0004_STAIRS_UP 
+	k0x0008_StairsNorthSouthOrient = 0x8, // @ MASK0x0008_STAIRS_NORTH_SOUTH_ORIENTATION 
+	k0x0008_DoorNorthSouthOrient = 0x8, // @ MASK0x0008_DOOR_NORTH_SOUTH_ORIENTATION 
+	k0x0004_TeleporterVisible = 0x4, // @ MASK0x0004_TELEPORTER_VISIBLE 
+	k0x0008_TeleporterOpen = 0x8, // @ MASK0x0008_TELEPORTER_OPEN 
+	k0x0001_FakeWallImaginary = 0x1, // @ MASK0x0001_FAKEWALL_IMAGINARY 
+	k0x0004_FakeWallOpen = 0x4, // @ MASK0x0004_FAKEWALL_OPEN 
+	k0x0008_FakeWallRandOrnOrFootPAllowed = 0x8, // @ MASK0x0008_FAKEWALL_RANDOM_ORNAMENT_OR_FOOTPRINTS_ALLOWED 
+	k0x0010_ThingListPresent = 0x10, // @ MASK0x0010_THING_LIST_PRESENT 
+	k0x8000_DecodeEvenIfInvisible = 0x8000 // @ MASK0x8000_DECODE_EVEN_IF_INVISIBLE 
 };
 
 enum SquareType {
-	kChampionElemType = -2,
-	kCreatureElemType = -1,
-	kWallElemType = 0,
-	kCorridorElemType = 1,
-	kPitElemType = 2,
-	kStairsElemType = 3,
-	kDoorElemType = 4,
-	kTeleporterElemType = 5,
-	kFakeWallElemType = 6,
-	kDoorSideElemType = 16,
-	kDoorFrontElemType = 17,
-	kStairsSideElemType = 18,
-	kStairsFrontElemType = 19
+	kM2_ChampionElemType = -2, // @ CM2_ELEMENT_CHAMPION 
+	kM1_CreatureElemType = -1, // @ CM1_ELEMENT_CREATURE 
+	k0_WallElemType = 0, // @ C00_ELEMENT_WALL 
+	k1_CorridorElemType = 1, // @ C01_ELEMENT_CORRIDOR 
+	k2_PitElemType = 2, // @ C02_ELEMENT_PIT 
+	k3_StairsElemType = 3, // @ C03_ELEMENT_STAIRS 
+	k4_DoorElemType = 4, // @ C04_ELEMENT_DOOR 
+	k5_TeleporterElemType = 5, // @ C05_ELEMENT_TELEPORTER 
+	k6_FakeWallElemType = 6, // @ C06_ELEMENT_FAKEWALL 
+	k16_DoorSideElemType = 16, // @ C16_ELEMENT_DOOR_SIDE 
+	k17_DoorFrontElemType = 17, // @ C17_ELEMENT_DOOR_FRONT 
+	k18_StairsSideElemType = 18, // @ C18_ELEMENT_STAIRS_SIDE 
+	k19_StairsFrontElemType = 19 // @ C19_ELEMENT_STAIRS_FRONT 
 }; // @ C[-2..19]_ELEMENT_...
 
 class Square {
@@ -594,36 +594,36 @@ struct Map {
 
 struct DungeonData {
 	// I have no idea the heck is this
-	uint16 *_mapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex
-	uint16 _columCount; // @ G0282_ui_DungeonColumnCount
+	uint16 *_g281_mapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex
+	uint16 _g282_columCount; // @ G0282_ui_DungeonColumnCount
 
 	// I have no idea the heck is this
-	uint16 *_columnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
-	Thing *_squareFirstThings; // @ G0283_pT_SquareFirstThings
-	uint16 *_textData; // @ G0260_pui_DungeonTextData
+	uint16 *_g280_columnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
+	Thing *_g283_squareFirstThings; // @ G0283_pT_SquareFirstThings
+	uint16 *_g260_textData; // @ G0260_pui_DungeonTextData
 
-	uint16 **_thingsData[16]; // @ G0284_apuc_ThingData
+	uint16 **_g284_thingsData[16]; // @ G0284_apuc_ThingData
 
-	byte ***_mapData; // @ G0279_pppuc_DungeonMapData
+	byte ***_g279_mapData; // @ G0279_pppuc_DungeonMapData
 }; // @ AGGREGATE
 
 struct CurrMapData {
-	direction _partyDir; // @ G0308_i_PartyDirection
-	int16 _partyPosX; // @ G0306_i_PartyMapX
-	int16 _partyPosY; // @ G0307_i_PartyMapY
-	uint8 _currPartyMapIndex; // @ G0309_i_PartyMapIndex
-
-	uint8 _index; // @ G0272_i_CurrentMapIndex
-	byte **_data; // @ G0271_ppuc_CurrentMapData
-	Map *_map; // @ G0269_ps_CurrentMap
-	uint16 _width; // @ G0273_i_CurrentMapWidth
-	uint16 _height; // @ G0274_i_CurrentMapHeight
-	uint16 *_colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount
+	direction _g308_partyDir; // @ G0308_i_PartyDirection
+	int16 _g306_partyPosX; // @ G0306_i_PartyMapX
+	int16 _g307_partyPosY; // @ G0307_i_PartyMapY
+	uint8 _g309_currPartyMapIndex; // @ G0309_i_PartyMapIndex
+
+	uint8 _g272_index; // @ G0272_i_CurrentMapIndex
+	byte **_g271_data; // @ G0271_ppuc_CurrentMapData
+	Map *_g269_map; // @ G0269_ps_CurrentMap
+	uint16 _g273_width; // @ G0273_i_CurrentMapWidth
+	uint16 _g274_height; // @ G0274_i_CurrentMapHeight
+	uint16 *_g270_colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount
 }; // @ AGGREGATE
 
 struct Messages {
-	bool _newGame; // @ G0298_B_NewGame
-	bool _restartGameRequest; // @ G0523_B_RestartGameRequested
+	bool _g298_newGame; // @ G0298_B_NewGame
+	bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested
 }; // @ AGGREGATE
 
 class DungeonMan {
@@ -674,22 +674,22 @@ public:
 
 	uint32 _rawDunFileDataSize;	 // @ probably NONE
 	byte *_rawDunFileData; // @ ???
-	DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader
+	DungeonFileHeader _g278_fileHeader; // @ G0278_ps_DungeonHeader
 
 	DungeonData _dunData; // @ NONE
 	CurrMapData _currMap; // @ NONE
-	Map *_maps; // @ G0277_ps_DungeonMaps
+	Map *_g277_maps; // @ G0277_ps_DungeonMaps
 	// does not have to be freed
-	byte *_rawMapData; // @ G0276_puc_DungeonRawMapData
+	byte *_g276_rawMapData; // @ G0276_puc_DungeonRawMapData
 	Messages _messages; // @ NONE;
 
-	int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex
-	Box _dungeonViewClickableBoxes[6]; // G0291_aauc_DungeonViewClickableBoxes
-	bool _isFacingAlcove; // @ G0286_B_FacingAlcove
-	bool _isFacingViAltar; // @ G0287_B_FacingViAltar
-	bool _isFacingFountain; // @ G0288_B_FacingFountain
-	ElementType _squareAheadElement; // @ G0285_i_SquareAheadElement 
-	Thing _pileTopObject[5]; // @ G0292_aT_PileTopObject
+	int16 _g265_currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex
+	Box _g291_dungeonViewClickableBoxes[6]; // G0291_aauc_DungeonViewClickableBoxes
+	bool _g286_isFacingAlcove; // @ G0286_B_FacingAlcove
+	bool _g287_isFacingViAltar; // @ G0287_B_FacingViAltar
+	bool _g288_isFacingFountain; // @ G0288_B_FacingFountain
+	ElementType _g285_squareAheadElement; // @ G0285_i_SquareAheadElement 
+	Thing _g292_pileTopObject[5]; // @ G0292_aT_PileTopObject
 };
 
 }
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 82fd07c..4a60768 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -317,22 +317,22 @@ void EventManager::processInput() {
 
 			switch (event.kbd.keycode) {
 			case Common::KEYCODE_w:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 1, 0, currMap._partyPosX, currMap._partyPosY);
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY);
 				break;
 			case Common::KEYCODE_a:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, -1, currMap._partyPosX, currMap._partyPosY);
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, -1, currMap._g306_partyPosX, currMap._g307_partyPosY);
 				break;
 			case Common::KEYCODE_s:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, -1, 0, currMap._partyPosX, currMap._partyPosY);
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, -1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY);
 				break;
 			case Common::KEYCODE_d:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, 1, currMap._partyPosX, currMap._partyPosY);
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, 1, currMap._g306_partyPosX, currMap._g307_partyPosY);
 				break;
 			case Common::KEYCODE_q:
-				turnDirLeft(currMap._partyDir);
+				turnDirLeft(currMap._g308_partyDir);
 				break;
 			case Common::KEYCODE_e:
-				turnDirRight(currMap._partyDir);
+				turnDirRight(currMap._g308_partyDir);
 				break;
 			case Common::KEYCODE_UP:
 				if (_dummyMapIndex < 13)
@@ -431,7 +431,7 @@ void EventManager::processCommandQueue() {
 }
 
 void EventManager::commandTurnParty(CommandType cmdType) {
-	_vm->_stopWaitingForPlayerInput = true;
+	_vm->_g321_stopWaitingForPlayerInput = true;
 
 	// MISSING CODE: highlight turn left/right buttons
 
@@ -440,14 +440,14 @@ void EventManager::commandTurnParty(CommandType cmdType) {
 	// MISSING CODE: process sensors
 
 	// DUMMY CODE: should call F0284_CHAMPION_SetPartyDirection instead
-	direction &partyDir = _vm->_dungeonMan->_currMap._partyDir;
+	direction &partyDir = _vm->_dungeonMan->_currMap._g308_partyDir;
 	(cmdType == kCommandTurnLeft) ? turnDirLeft(partyDir) : turnDirRight(partyDir);
 
 	// MISSING CODE: process sensors
 }
 
 void EventManager::commandMoveParty(CommandType cmdType) {
-	_vm->_stopWaitingForPlayerInput = true;
+	_vm->_g321_stopWaitingForPlayerInput = true;
 
 	// MISSING CODE: Lots of code
 
@@ -457,16 +457,16 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 
 	switch (cmdType) {
 	case kCommandMoveForward:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 1, 0, currMap._partyPosX, currMap._partyPosY);
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY);
 		break;
 	case kCommandMoveLeft:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, -1, currMap._partyPosX, currMap._partyPosY);
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, -1, currMap._g306_partyPosX, currMap._g307_partyPosY);
 		break;
 	case kCommandMoveBackward:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, -1, 0, currMap._partyPosX, currMap._partyPosY);
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, -1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY);
 		break;
 	case kCommandMoveRight:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, 1, currMap._partyPosX, currMap._partyPosY);
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, 1, currMap._g306_partyPosX, currMap._g307_partyPosY);
 		break;
 	default:
 		break;
@@ -496,7 +496,7 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
 	}
 	cm._g411_leaderIndex = champIndex;
 	Champion *champion = &cm._champions[cm._g411_leaderIndex];
-	champion->_dir = _vm->_dungeonMan->_currMap._partyDir;
+	champion->_dir = _vm->_dungeonMan->_currMap._g308_partyDir;
 	cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._414_leaderHandObject);
 	if (_vm->indexToOrdinal(champIndex) != cm._g299_candidateChampionOrdinal) {
 		champion->setAttributeFlag(k0x0400_ChampionAttributeIcon, true);
@@ -508,10 +508,10 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
 void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() {
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 	CurrMapData &currMap = dunMan._currMap;
-	int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir];
-	int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir];
-	if ((mapX >= 0) && (mapX < currMap._width) && (mapY >= 0) && (mapY < currMap._height)) {
-		_vm->_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(currMap._partyDir));
+	int16 mapX = currMap._g306_partyPosX + _vm->_dirIntoStepCountEast[currMap._g308_partyDir];
+	int16 mapY = currMap._g307_partyPosY + _vm->_dirIntoStepCountNorth[currMap._g308_partyDir];
+	if ((mapX >= 0) && (mapX < currMap._g273_width) && (mapY >= 0) && (mapY < currMap._g274_height)) {
+		_vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(currMap._g308_partyDir));
 	}
 }
 
@@ -520,17 +520,17 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 	ChampionMan &champMan = *_vm->_championMan;
 	CurrMapData &currMap = _vm->_dungeonMan->_currMap;
 
-	if (dunMan._squareAheadElement == kElementTypeDoorFront) {
+	if (dunMan._g285_squareAheadElement == k17_ElementTypeDoorFront) {
 		if (champMan._g411_leaderIndex == kM1_ChampionNone)
 			return;
 
 		if (champMan._g415_leaderEmptyHanded) {
-			int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir];
-			int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir];
+			int16 mapX = currMap._g306_partyPosX + _vm->_dirIntoStepCountEast[currMap._g308_partyDir];
+			int16 mapY = currMap._g307_partyPosY + _vm->_dirIntoStepCountNorth[currMap._g308_partyDir];
 
 			if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() &&
-				dunMan._dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
-				_vm->_stopWaitingForPlayerInput = true;
+				dunMan._g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
+				_vm->_g321_stopWaitingForPlayerInput = true;
 				warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 				warning("MISSING CODE: F0268_SENSOR_AddEvent");
 				return;
@@ -542,9 +542,9 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 
 	if (champMan._g415_leaderEmptyHanded) {
 		for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k5_ViewCellDoorButtonOrWallOrn; viewCell++) {
-			if (dunMan._dungeonViewClickableBoxes[viewCell].isPointInside(Common::Point(posX, posY - 33))) {
+			if (dunMan._g291_dungeonViewClickableBoxes[viewCell].isPointInside(Common::Point(posX, posY - 33))) {
 				if (viewCell == k5_ViewCellDoorButtonOrWallOrn) {
-					if (!dunMan._isFacingAlcove) {
+					if (!dunMan._g286_isFacingAlcove) {
 						commandProcessType80ClickInDungeonViewTouchFrontWall();
 					}
 				} else {
@@ -556,7 +556,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 	} else {
 		Thing thing = champMan._414_leaderHandObject;
 		uint16 *rawThingPointer = dunMan.getThingData(thing);
-		if (dunMan._squareAheadElement == kElementTypeWall) {
+		if (dunMan._g285_squareAheadElement == k0_ElementTypeWall) {
 			for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k1_ViewCellFrontRight; ++viewCell) {
 				if (gBoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) {
 					warning("F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject");
@@ -564,17 +564,17 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 				}
 			}
 
-			if (dunMan._dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
-				if (dunMan._isFacingAlcove) {
+			if (dunMan._g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
+				if (dunMan._g286_isFacingAlcove) {
 					warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject");
 				} else {
-					if (dunMan._isFacingFountain) {
+					if (dunMan._g288_isFacingFountain) {
 						uint16 iconIndex = _vm->_objectMan->getIconIndex(thing);
 						int16 weight = dunMan.getObjectWeight(thing);
 						if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
 							((Junk*)rawThingPointer)->setChargeCount(3);
 						} else if (iconIndex == k195_IconIndicePotionEmptyFlask) {
-							((Potion*)rawThingPointer)->setType(kPotionTypeWaterFlask);
+							((Potion*)rawThingPointer)->setType(k15_PotionTypeWaterFlask);
 						} else {
 							goto T0377019;
 						}
@@ -620,15 +620,15 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 		box._x2 = box._x1 + 66 + 1;
 		dispMan._g578_useByteBoxCoordinates = false;
 		dispMan.clearScreenBox(k0_ColorBlack, box);
-		dispMan.clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._partyDir) * 2]);
+		dispMan.clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._g308_partyDir) * 2]);
 		warning("F0457_START_DrawEnabledMenus_CPSF");
 		warning("F0078_MOUSE_ShowPointer");
 		return;
 	}
 
 	champMan._g299_candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
-	int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir];
-	int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir];
+	int16 mapX = currMap._g306_partyPosX + _vm->_dirIntoStepCountEast[currMap._g308_partyDir];
+	int16 mapY = currMap._g307_partyPosY + _vm->_dirIntoStepCountNorth[currMap._g308_partyDir];
 
 	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
 		Thing thing = champ->getSlot((ChampionSlot)slotIndex);
@@ -638,7 +638,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	}
 	Thing thing = dunMan.getSquareFirstThing(mapX, mapY);
 	for (;;) { // infinite
-		if (thing.getType() == kSensorThingType) {
+		if (thing.getType() == k3_SensorThingType) {
 			((Sensor*)dunMan.getThingData(thing))->setTypeDisabled();
 			break;
 		}
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 35b30a3..c93bf1d 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -823,7 +823,7 @@ void DisplayMan::loadGraphics() {
 	for (int16 creatureIndex = 0; creatureIndex < k27_CreatureTypeCount; creatureIndex++) {
 		creatureAsp = &g219_CreatureAspects[creatureIndex];
 
-		int16 creatureGraphicInfo = gCreatureInfo[creatureIndex]._graphicInfo;
+		int16 creatureGraphicInfo = g243_CreatureInfo[creatureIndex]._graphicInfo;
 		creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex;
 
 		int16 creatureFrontBitmapD3PixelCount;
@@ -1079,46 +1079,46 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
 	int16 order;
 
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[kElemAspect]) {
-	case kStairsFrontElemType:
-		if (squareAspect[kStairsUpAspect])
+	switch (squareAspect[k0_ElemAspect]) {
+	case k19_StairsFrontElemType:
+		if (squareAspect[k2_StairsUpAspect])
 			drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g110_FrameStairsUpFront_D3L);
 		else
 			drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g121_FrameStairsDownFront_D3L);
 		goto T0116015_redEagle;
-	case kWallElemType:
+	case k0_WallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k1_ViewSquare_D3L]);
-		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT);
-		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) {
+		isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
 			goto T0116017_orangeElk;
 		}
 		return;
-	case kElementTypeDoorSide:
-	case kElementTypeStairsSide:
+	case k16_ElementTypeDoorSide:
+	case k18_ElementTypeStairsSide:
 		order = k0x0321_CellOrder_BackLeft_BackRight_FrontRight;
 		goto T0116016_blueToad;
-	case kElementTypeDoorFront:
+	case k17_ElementTypeDoorFront:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
-		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
+		cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
 		drawWallSetBitmap(_wallSetBitMaps[kG705_DoorFrameLeft_D3L], g164_Frame_DoorFrameLeft_D3L);
 		warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor");
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0116017_orangeElk;
-	case kElementTypePit:
-		if (!squareAspect[kPitInvisibleAspect]) {
+	case k2_ElementTypePit:
+		if (!squareAspect[k2_PitInvisibleAspect]) {
 			drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, g140_FrameFloorPit_D3L);
 		}
-	case kElementTypeTeleporter:
-	case kElementTypeCorridor:
+	case k5_ElementTypeTeleporter:
+	case k1_ElementTypeCorridor:
 T0116015_redEagle:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
 T0116016_blueToad:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
 T0116017_orangeElk:
-		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order);
+		cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order);
 	}
-	if ((squareAspect[kElemAspect] == kElementTypeTeleporter) && squareAspect[kTeleporterVisibleAspect]) {
+	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
 		drawField(&g188_FieldAspects[k1_ViewSquare_D3L], g163_FrameWalls[k1_ViewSquare_D3L]._box);
 	}
 }
@@ -1130,51 +1130,51 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
 
 
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[kElemAspect]) {
-	case kElementTypeStaisFront:
-		if (squareAspect[kStairsUpAspect]) {
+	switch (squareAspect[k0_ElemAspect]) {
+	case k19_ElementTypeStaisFront:
+		if (squareAspect[k2_StairsUpAspect]) {
 			drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g112_FrameStairsUpFront_D3R);
 		} else {
 			drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g123_FrameStairsDownFront_D3R);
 		}
 		goto T0117016;
-	case kElementTypeWall:
+	case k0_ElementTypeWall:
 		drawWallSetBitmap(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k2_ViewSquare_D3R]);
-		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT);
-		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) {
+		isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
 			goto T0117018;
 		}
 		return;
-	case kElementTypeDoorSide:
-	case kElementTypeStairsSide:
+	case k16_ElementTypeDoorSide:
+	case k18_ElementTypeStairsSide:
 		order = k0x0412_CellOrder_BackRight_BackLeft_FrontLeft;
 		goto T0117017;
-	case kElementTypeDoorFront:
+	case k17_ElementTypeDoorFront:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
-		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
+		cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
 		memcpy(_g74_tmpBitmap, _wallSetBitMaps[kG705_DoorFrameLeft_D3L], 32 * 44);
 		warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally");
-		if (((Door*)_vm->_dungeonMan->_dunData._thingsData[kDoorThingType])[squareAspect[kDoorThingIndexAspect]].hasButton()) {
+		if (((Door*)_vm->_dungeonMan->_dunData._g284_thingsData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
 			warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton");
 		}
 		warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor");
 		order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft;
 		goto T0117018;
-	case kElementTypePit:
-		if (!squareAspect[kPitInvisibleAspect]) {
+	case k2_ElementTypePit:
+		if (!squareAspect[k2_PitInvisibleAspect]) {
 			drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, g142_FrameFloorPit_D3R);
 		}
-	case kElementTypeTeleporter:
-	case kElementTypeCorridor:
+	case k5_ElementTypeTeleporter:
+	case k1_ElementTypeCorridor:
 T0117016:
 		order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft;
 T0117017:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
 T0117018:
-		cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order);
+		cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order);
 	}
-	if ((squareAspect[kElemAspect] == kElementTypeTeleporter) && squareAspect[kTeleporterVisibleAspect]) {
+	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
 		drawField(&g188_FieldAspects[k2_ViewSquare_D3R], g163_FrameWalls[k2_ViewSquare_D3R]._box);
 	}
 }
@@ -1183,15 +1183,15 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
-	case kStairsFrontElemType:
-		if (squareAspect[kStairsUpAspect])
+	case k19_StairsFrontElemType:
+		if (squareAspect[k2_StairsUpAspect])
 			drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, g111_FrameStairsUpFront_D3C);
 		else
 			drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, g122_FrameStairsDownFront_D3C);
 		break;
-	case kWallElemType:
+	case k0_WallElemType:
 		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k0_ViewSquare_D3C]);
-		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) {
+		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) {
 			//... missing code
 		}
 		break;
@@ -1203,20 +1203,20 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
-	case kStairsFrontElemType:
-		if (squareAspect[kStairsUpAspect])
+	case k19_StairsFrontElemType:
+		if (squareAspect[k2_StairsUpAspect])
 			drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L);
 		else
 			drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L);
 		break;
-	case kWallElemType:
+	case k0_WallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k4_ViewSquare_D2L]);
-		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT);
-		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) {
+		isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) {
 			// ... missing code
 		}
 		break;
-	case kStairsSideElemType:
+	case k18_StairsSideElemType:
 		drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L);
 		break;
 	default:
@@ -1227,20 +1227,20 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
-	case kStairsFrontElemType:
-		if (squareAspect[kStairsUpAspect])
+	case k19_StairsFrontElemType:
+		if (squareAspect[k2_StairsUpAspect])
 			drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R);
 		else
 			drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R);
 		break;
-	case kWallElemType:
+	case k0_WallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k5_ViewSquare_D2R]);
-		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT);
-		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) {
+		isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) {
 			// ... missing code
 		}
 		break;
-	case kStairsSideElemType:
+	case k18_StairsSideElemType:
 		drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R);
 		break;
 	default:
@@ -1251,15 +1251,15 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
-	case kStairsFrontElemType:
-		if (squareAspect[kStairsUpAspect])
+	case k19_StairsFrontElemType:
+		if (squareAspect[k2_StairsUpAspect])
 			drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, g114_FrameStairsUpFront_D2C);
 		else
 			drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, g125_FrameStairsDownFront_D2C);
 		break;
-	case kWallElemType:
+	case k0_WallElemType:
 		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k3_ViewSquare_D2C]);
-		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) {
+		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) {
 			// ... missing code
 		}
 		break;
@@ -1271,18 +1271,18 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
-	case kStairsFrontElemType:
-		if (squareAspect[kStairsUpAspect])
+	case k19_StairsFrontElemType:
+		if (squareAspect[k2_StairsUpAspect])
 			drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g116_FrameStairsUpFront_D1L);
 		else
 			drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g127_FrameStairsDownFront_D1L);
 		break;
-	case kWallElemType:
+	case k0_WallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k7_ViewSquare_D1L]);
-		isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT);
+		isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT);
 		break;
-	case kStairsSideElemType:
-		if (squareAspect[kStairsUpAspect])
+	case k18_StairsSideElemType:
+		if (squareAspect[k2_StairsUpAspect])
 			drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g134_FrameStairsUpSide_D1L);
 		else
 			drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g136_FrameStairsDownSide_D1L);
@@ -1295,18 +1295,18 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
-	case kStairsFrontElemType:
-		if (squareAspect[kStairsUpAspect])
+	case k19_StairsFrontElemType:
+		if (squareAspect[k2_StairsUpAspect])
 			drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g118_FrameStairsUpFront_D1R);
 		else
 			drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g129_FrameStairsDownFront_D1R);
 		break;
-	case kWallElemType:
+	case k0_WallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k8_ViewSquare_D1R]);
-		isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT);
+		isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT);
 		break;
-	case kStairsSideElemType:
-		if (squareAspect[kStairsUpAspect])
+	case k18_StairsSideElemType:
+		if (squareAspect[k2_StairsUpAspect])
 			drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g135_FrameStairsUpSide_D1R);
 		else
 			drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g137_FrameStairsDownSide_D1R);
@@ -1319,18 +1319,18 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
-	case kStairsFrontElemType:
-		if (squareAspect[kStairsUpAspect])
+	case k19_StairsFrontElemType:
+		if (squareAspect[k2_StairsUpAspect])
 			drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, g117_FrameStairsUpFront_D1C);
 		else
 			drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, g128_FrameStairsDownFront_D1C);
 		break;
-	case kWallElemType:
-		_vm->_dungeonMan->_isFacingAlcove = false;
-		_vm->_dungeonMan->_isFacingViAltar = false;
-		_vm->_dungeonMan->_isFacingFountain = false;
+	case k0_WallElemType:
+		_vm->_dungeonMan->_g286_isFacingAlcove = false;
+		_vm->_dungeonMan->_g287_isFacingViAltar = false;
+		_vm->_dungeonMan->_g288_isFacingFountain = false;
 		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k6_ViewSquare_D1C]);
-		if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) {
+		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) {
 			// .... code not yet implemneted
 		}
 		break;
@@ -1343,11 +1343,11 @@ void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
-	case kStairsSideElemType:
-		if (squareAspect[kStairsUpAspect])
+	case k18_StairsSideElemType:
+		if (squareAspect[k2_StairsUpAspect])
 			drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, g138_FrameStairsSide_D0L);
 		break;
-	case kWallElemType:
+	case k0_WallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kG701_Wall_D0L], g163_FrameWalls[k10_ViewSquare_D0L]);
 		break;
 	default:
@@ -1359,11 +1359,11 @@ void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
-	case kStairsSideElemType:
-		if (squareAspect[kStairsUpAspect])
+	case k18_StairsSideElemType:
+		if (squareAspect[k2_StairsUpAspect])
 			drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R);
 		return;
-	case kWallElemType:
+	case k0_WallElemType:
 		drawWallSetBitmap(_wallSetBitMaps[kG702_Wall_D0R], g163_FrameWalls[k11_ViewSquare_D0R]);
 		break;
 	default:
@@ -1375,8 +1375,8 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
-	case kStairsFrontElemType:
-		if (squareAspect[kStairsUpAspect]) {
+	case k19_StairsFrontElemType:
+		if (squareAspect[k2_StairsUpAspect]) {
 			drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g119_FrameStairsUpFront_D0L);
 			drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g120_FrameStairsUpFront_D0R);
 		} else {
@@ -1399,10 +1399,10 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	clearBitmap(tmpBitmap, 305, 111, k10_ColorFlesh);
 
 	for (int16 i = 0; i < 6; ++i)
-		_vm->_dungeonMan->_dungeonViewClickableBoxes[i].setToZero();
+		_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i].setToZero();
 
 	for (uint16 i = 0; i < 6; ++i) {
-		_vm->_dungeonMan->_dungeonViewClickableBoxes[i]._x1 = 255 + 1;
+		_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i]._x1 = 255 + 1;
 	}
 
 	if (flippedFloorCeiling) {
@@ -1422,9 +1422,9 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 		drawWallSetBitmap(_g84_floorBitmap, gK13_FloorFrame);
 	}
 
-	if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallElemType)
+	if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == k0_WallElemType)
 		drawWallSetBitmap(_wallSetBitMaps[kG697_Wall_D3L2], g711_FrameWall_D3L2);
-	if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallElemType)
+	if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == k0_WallElemType)
 		drawWallSetBitmap(_wallSetBitMaps[kG696_Wall_D3R2], g712_FrameWall_D3R2);
 
 	int16 tmpPosX = posX, tmpPosY = posY;
@@ -1519,13 +1519,13 @@ void DisplayMan::loadWallSet(WallSet set) {
 
 
 void DisplayMan::loadCurrentMapGraphics() {
-	loadFloorSet(_vm->_dungeonMan->_currMap._map->_floorSet);
-	loadWallSet(_vm->_dungeonMan->_currMap._map->_wallSet);
+	loadFloorSet(_vm->_dungeonMan->_currMap._g269_map->_floorSet);
+	loadWallSet(_vm->_dungeonMan->_currMap._g269_map->_wallSet);
 
 	// the original loads some flipped walls here, I moved it to loadWallSet
 
 	{
-		int16 val = _vm->_dungeonMan->_currMap._map->_wallSet * k18_StairsGraphicCount + k90_FirstStairs;
+		int16 val = _vm->_dungeonMan->_currMap._g269_map->_wallSet * k18_StairsGraphicCount + k90_FirstStairs;
 		_g675_stairsNativeBitmapIndex_Up_Front_D3L = val++;
 		_g676_stairsNativeBitmapIndex_Up_Front_D3C = val++;
 		_g677_stairsNativeBitmapIndex_Up_Front_D2L = val++;
@@ -1556,7 +1556,7 @@ void DisplayMan::loadCurrentMapGraphics() {
 
 	uint16 alcoveCount = 0;
 	uint16 fountainCount = 0;
-	Map &currMap = *_vm->_dungeonMan->_currMap._map;
+	Map &currMap = *_vm->_dungeonMan->_currMap._g269_map;
 
 	_g266_currMapViAltarIndex = -1;
 
@@ -1682,9 +1682,9 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 
 		uint16 *coordinateSetA = g205_WallOrnCoordSets[_g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]][viewWallIndex];
 		isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnIndex);
-		isInscription = (wallOrnIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex);
+		isInscription = (wallOrnIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex);
 		if (isInscription) {
-			_vm->_dungeonMan->decodeText((char*)inscriptionString, _g290_inscriptionThing, kTextTypeInscription);
+			_vm->_dungeonMan->decodeText((char*)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
 		}
 
 		if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) {
@@ -1715,17 +1715,17 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 				}
 				nativeBitmapIndex++;
 
-				_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordinateSetA[0];
-				_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordinateSetA[1];
-				_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordinateSetA[2];
-				_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordinateSetA[3];
+				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordinateSetA[0];
+				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordinateSetA[1];
+				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordinateSetA[2];
+				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordinateSetA[3];
 
-				_vm->_dungeonMan->_isFacingAlcove = isAlcove;
-				_vm->_dungeonMan->_isFacingViAltar = (wallOrnIndex == _g266_currMapViAltarIndex);
-				_vm->_dungeonMan->_isFacingFountain = false;
+				_vm->_dungeonMan->_g286_isFacingAlcove = isAlcove;
+				_vm->_dungeonMan->_g287_isFacingViAltar = (wallOrnIndex == _g266_currMapViAltarIndex);
+				_vm->_dungeonMan->_g288_isFacingFountain = false;
 				for (int16 fountainOrnIndex = 0; fountainOrnIndex < k1_FountainOrnCount; ++fountainOrnIndex) {
 					if (_g268_currMapFountainOrnIndices[fountainOrnIndex] == wallOrnIndex) {
-						_vm->_dungeonMan->_isFacingFountain = true;
+						_vm->_dungeonMan->_g288_isFacingFountain = true;
 						break;
 					}
 				}
@@ -2179,22 +2179,22 @@ creatures are drawn in the right order and so that Fluxcages are not drawn twice
 		objectShiftIndex += (cellYellowBear & 0x0001) << 3;
 		drawProjectileAsObject = false;
 		do {
-			if ((AL_4_thingType = thingParam.getType()) == kGroupThingType) {
+			if ((AL_4_thingType = thingParam.getType()) == k4_GroupThingType) {
 				groupThing = thingParam;
 				continue;
 			}
-			if (AL_4_thingType == kProjectileThingType) {
+			if (AL_4_thingType == k14_ProjectileThingType) {
 				sqaureHasProjectile = true;
 				continue;
 			}
-			if (AL_4_thingType == kExplosionThingType) {
+			if (AL_4_thingType == k15_ExplosionThingType) {
 				squareHasExplosion = true;
 				continue;
 			}
 
 			/* Square where objects are visible and object is located on cell being processed */
 			if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) {
-				objectAspect = &(g209_ObjectAspects[gObjectInfo[dunMan.getObjectInfoIndex(thingParam)]._objectAspectIndex]);
+				objectAspect = &(g209_ObjectAspects[g237_ObjectInfo[dunMan.getObjectInfoIndex(thingParam)]._objectAspectIndex]);
 				AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex;
 				if (useAlcoveObjectImage = (drawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane)) {
 					AL_4_nativeBitmapIndex++;
@@ -2287,7 +2287,7 @@ T0115015_DrawProjectileAsObject:
 
 				if (drawingGrabbableObject) {
 					bitmapGreenAnt = AL_6_bitmapRedBanana;
-					Box *AL_6_boxPtrRed = &dunMan._dungeonViewClickableBoxes[AL_2_viewCell];
+					Box *AL_6_boxPtrRed = &dunMan._g291_dungeonViewClickableBoxes[AL_2_viewCell];
 					if (AL_6_boxPtrRed->_x1 == 255) { /* If the grabbable object is the first */
 						*AL_6_boxPtrRed = boxByteGreen;
 
@@ -2305,7 +2305,7 @@ T0115015_DrawProjectileAsObject:
 						AL_6_boxPtrRed->_y2 = MIN(AL_6_boxPtrRed->_y2, boxByteGreen._y2);
 					}
 					AL_6_bitmapRedBanana = bitmapGreenAnt;
-					dunMan._pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */
+					dunMan._g292_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */
 				}
 				blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, g296_DungeonViewport);
 
@@ -2328,7 +2328,7 @@ T0115015_DrawProjectileAsObject:
 		if (group == nullptr) { /* If all creature data and info has not already been gathered */
 			group = (Group*)dunMan.getThingData(groupThing);
 			activeGroup = &_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()];
-			creatureInfo = &gCreatureInfo[group->_type];
+			creatureInfo = &g243_CreatureInfo[group->_type];
 			creatureAspectStruct = &g219_CreatureAspects[creatureInfo->_creatureAspectIndex];
 			creatureSize = getFlag(creatureInfo->_attributes, kMaskCreatureInfo_size);
 			creatureGraphicInfoGreen = creatureInfo->_graphicInfo;
@@ -2581,7 +2581,7 @@ continue;
 		thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */
 
 		do {
-			if ((thingParam.getType() == kProjectileThingType) && (thingParam.getCell() == cellYellowBear)) {
+			if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) {
 				projectile = (Projectile*)dunMan.getThingData(thingParam);
 				if ((AL_4_projectileAspect = dunMan.getProjectileAspect(projectile->_object)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
 					objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)];
@@ -2720,26 +2720,26 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 	uint16 explosionScaleIndex = AL_1_viewSquareExplosionIndex / 3;
 	thingParam = firstThingToDraw; /* Restart processing list of things from the beginning. The next loop draws only explosion things among the list */
 	do {
-		if (thingParam.getType() == kExplosionThingType) {
+		if (thingParam.getType() == k15_ExplosionThingType) {
 			AL_2_cellPurpleMan = thingParam.getCell();
 			explosion = (Explosion*)dunMan.getThingData(thingParam);
-			if ((rebirthExplosion = ((unsigned int)(AL_4_explosionType = explosion->getType()) >= kExplosionType_RebirthStep1))
+			if ((rebirthExplosion = ((unsigned int)(AL_4_explosionType = explosion->getType()) >= k100_ExplosionType_RebirthStep1))
 				&& ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion)
 					|| (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion)
 					|| (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */
 				continue;
 			smoke = false;
-			if ((AL_4_explosionType == kExplosionType_Fireball) || (AL_4_explosionType == kExplosionType_LightningBolt) || (AL_4_explosionType == kExplosionType_RebirthStep2)) {
+			if ((AL_4_explosionType == k0_ExplosionType_Fireball) || (AL_4_explosionType == k2_ExplosionType_LightningBolt) || (AL_4_explosionType == k101_ExplosionType_RebirthStep2)) {
 				AL_4_explosionAspectIndex = k0_ExplosionAspectFire;
 			} else {
-				if ((AL_4_explosionType == kExplosionType_PoisonBolt) || (AL_4_explosionType == kExplosionType_PoisonCloud)) {
+				if ((AL_4_explosionType == k6_ExplosionType_PoisonBolt) || (AL_4_explosionType == k7_ExplosionType_PoisonCloud)) {
 					AL_4_explosionAspectIndex = k2_ExplosionAspectPoison;
 				} else {
-					if (AL_4_explosionType == kExplosionType_Smoke) {
+					if (AL_4_explosionType == k40_ExplosionType_Smoke) {
 						smoke = true;
 						AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke;
 					} else {
-						if (AL_4_explosionType == kExplosionType_RebirthStep1) {
+						if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) {
 							objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->ordinalToIndex(-dunMan.getProjectileAspect(Thing::_explLightningBolt))];
 							AL_6_bitmapRedBanana = getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
 							explosionCoordinates = g228_RebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
@@ -2753,7 +2753,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 							}
 							goto T0115200_DrawExplosion;
 						}
-						if (AL_4_explosionType == kExplosionType_Fluxcage) {
+						if (AL_4_explosionType == k50_ExplosionType_Fluxcage) {
 							if (AL_1_viewSquareExplosionIndex >= k4_ViewSquare_D3L_Explosion) {
 								fluxcageExplosion = explosion;
 							}
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index b224dff..76aab71 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -43,7 +43,7 @@ GroupMan::~GroupMan() {
 }
 
 void GroupMan::initActiveGroups() {
-	if (_vm->_dungeonMan->_messages._newGame)
+	if (_vm->_dungeonMan->_messages._g298_newGame)
 		_maxActiveGroupCount = 60;
 	if (_activeGroups)
 		delete[] _activeGroups;
@@ -55,7 +55,7 @@ void GroupMan::initActiveGroups() {
 uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) {
 	byte cells;
 	cells = group->_cells;
-	if (mapIndex == _vm->_dungeonMan->_currMap._currPartyMapIndex)
+	if (mapIndex == _vm->_dungeonMan->_currMap._g309_currPartyMapIndex)
 		cells = _activeGroups[cells]._cells;
 	return cells;
 }
@@ -63,20 +63,20 @@ uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) {
 byte gGroupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_GroupDirections
 
 uint16 GroupMan::getGroupDirections(Group* group, int16 mapIndex) {
-	if (mapIndex == _vm->_dungeonMan->_currMap._currPartyMapIndex)
+	if (mapIndex == _vm->_dungeonMan->_currMap._g309_currPartyMapIndex)
 		return _activeGroups[group->getActiveGroupIndex()]._directions;
 
 	return gGroupDirections[group->getDir()];
 }
 
 int16 GroupMan::getCreatureOrdinalInCell(Group* group, uint16 cell) {
-	uint16 currMapIndex = _vm->_dungeonMan->_currMap._index;
+	uint16 currMapIndex = _vm->_dungeonMan->_currMap._g272_index;
 	byte groupCells = getGroupCells(group, currMapIndex);
 	if (groupCells == kCreatureTypeSingleCenteredCreature)
 		return _vm->indexToOrdinal(0);
 
 	byte creatureIndex = group->getCount();
-	if (getFlag(gCreatureInfo[group->_type]._attributes, kMaskCreatureInfo_size) == kMaskCreatureSizeHalf) {
+	if (getFlag(g243_CreatureInfo[group->_type]._attributes, kMaskCreatureInfo_size) == kMaskCreatureSizeHalf) {
 		if ((getGroupDirections(group, currMapIndex) & 1) == (cell & 1))
 			cell = returnPrevVal(cell);
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 0779a7e..742f392 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -57,9 +57,9 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 
 	if ((championIndex != k4_ChampionCloseInventory) && !cm._champions[championIndex]._currHealth)
 		return;
-	if (_vm->_pressingEye || _vm->_pressingMouth)
+	if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth)
 		return;
-	_vm->_stopWaitingForPlayerInput = true;
+	_vm->_g321_stopWaitingForPlayerInput = true;
 	int16 invChampOrdinal = _inventoryChampionOrdinal; // copy, as the original will be edited
 	if (_vm->indexToOrdinal(championIndex) == invChampOrdinal) {
 		championIndex = k4_ChampionCloseInventory;
@@ -192,10 +192,10 @@ void InventoryMan::drawPanel() {
 
 	_panelContent = kPanelContentFoodWaterPoisoned;
 	switch (thing.getType()) {
-	case kContainerThingType:
+	case k9_ContainerThingType:
 		_panelContent = kPanelContentChest;
 		break;
-	case kScrollThingType:
+	case k7_ScrollThingType:
 		_panelContent = kPanelContentScroll;
 		break;
 	default:
@@ -229,7 +229,7 @@ void InventoryMan::closeChest() {
 				*dunMan.getThingData(thing) = Thing::_endOfList.toUint16();
 				container->getSlot() = prevThing = thing;
 			} else {
-				dunMan.linkThingToList(thing, prevThing, kMapXNotOnASquare, 0);
+				dunMan.linkThingToList(thing, prevThing, kM1_MapXNotOnASquare, 0);
 				prevThing = thing;
 			}
 		}
@@ -252,7 +252,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 
 	char stringFirstLine[300];
-	_vm->_dungeonMan->decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible));
+	_vm->_dungeonMan->decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
 	char *charRed = stringFirstLine;
 	while (*charRed && (*charRed != '\n')) {
 		charRed++;
@@ -429,7 +429,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 	ChampionMan &champMan = *_vm->_championMan;
 	TextMan &textMan = *_vm->_textMan;
 
-	if (_vm->_pressingEye || _vm->_pressingMouth) {
+	if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) {
 		warning("BUG0_48 The contents of a chest are reorganized when an object with a statistic modifier is placed or removed on a champion");
 		closeChest();
 	}
@@ -437,9 +437,9 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 	uint16 *rawThingPtr = dunMan.getThingData(thingToDraw);
 	drawPanelObjectDescriptionString("\f"); // form feed
 	ThingType thingType = thingToDraw.getType();
-	if (thingType == kScrollThingType) {
+	if (thingType == k7_ScrollThingType) {
 		drawPanelScroll((Scroll*)rawThingPtr);
-	} else if (thingType == kContainerThingType) {
+	} else if (thingType == k9_ContainerThingType) {
 		openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye);
 	} else {
 		IconIndice iconIndex = objMan.getIconIndex(thingToDraw);
@@ -454,7 +454,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			strcat(str, objMan._objectNames[iconIndex]);  // TODO: localization
 
 			descString = str;
-		} else if ((thingType == kPotionThingType)
+		} else if ((thingType == k8_PotionThingType)
 				   && (iconIndex != k163_IconIndicePotionWaterFlask)
 				   && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
 			str[0] = '_' + ((Potion*)rawThingPtr)->getPower() / 40;
@@ -476,7 +476,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		uint16 potentialAttribMask;
 		uint16 actualAttribMask;
 		switch (thingType) {
-		case kWeaponThingType: {
+		case k5_WeaponThingType: {
 			potentialAttribMask = kDescriptionMaskCursed | kDescriptionMaskPoisoned | kDescriptionMaskBroken;
 			Weapon *weapon = (Weapon*)rawThingPtr;
 			actualAttribMask = (weapon->getCursed() << 3) | (weapon->getPoisoned() << 1) | (weapon->getBroken() << 2);
@@ -487,19 +487,19 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			}
 			break;
 		}
-		case kArmourThingType: {
+		case k6_ArmourThingType: {
 			potentialAttribMask = kDescriptionMaskCursed | kDescriptionMaskBroken;
 			Armour *armour = (Armour*)rawThingPtr;
 			actualAttribMask = (armour->getCursed() << 3) | (armour->getBroken() << 2);
 			break;
 		}
-		case kPotionThingType: {
+		case k8_PotionThingType: {
 			actualAttribMask = kDescriptionMaskConsumable;
 			Potion *potion = (Potion*)rawThingPtr;
-			actualAttribMask = gObjectInfo[kObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots();
+			actualAttribMask = g237_ObjectInfo[k2_ObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots();
 			break;
 		}
-		case kJunkThingType: {
+		case k10_JunkThingType: {
 			Junk *junk = (Junk*)rawThingPtr;
 			if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
 				potentialAttribMask = 0;
@@ -526,7 +526,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 				drawPanelObjectDescriptionString(str);
 			} else {
 				potentialAttribMask = kDescriptionMaskConsumable;
-				actualAttribMask = gObjectInfo[kObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots();
+				actualAttribMask = g237_ObjectInfo[k127_ObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots();
 			}
 			break;
 		}
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 42f8bad..bd99345 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -39,14 +39,14 @@ LoadsaveMan::LoadsaveMan(DMEngine *vm) : _vm(vm) {}
 
 
 LoadgameResponse LoadsaveMan::loadgame() {
-	bool newGame = _vm->_dungeonMan->_messages._newGame;
+	bool newGame = _vm->_dungeonMan->_messages._g298_newGame;
 	ChampionMan &cm = *_vm->_championMan;
 
 	if (newGame) {
-		_vm->_restartGameAllowed = false;
+		_vm->_g524_restartGameAllowed = false;
 		cm._g305_partyChampionCount = 0;
 		cm._414_leaderHandObject = Thing::_none;
-		_vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536);
+		_vm->_g525_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536);
 	} else {
 		assert(false);
 		// MISSING CODE: load game
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 19912ad..20d0f53 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -98,7 +98,7 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) {
 	IconIndice iconIndex;
 	if (thing == Thing::_none) {
 		iconIndex = k201_IconIndiceActionEmptyHand;
-	} else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
+	} else if (g237_ObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
 		iconIndex = _vm->_objectMan->getIconIndex(thing);
 	} else {
 		dm.clearBitmap(bitmapIcon, 16, 16, k4_ColorCyan);
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 0aca699..5d37884 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -47,7 +47,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 	Thing leaderHandObject = champMan._414_leaderHandObject;
 	int16 sensorCountToProcessPerCell[4];
 	uint16 cell;
-	for (cell = kCellNorthWest; cell < kCellSouthWest; ++cell) {
+	for (cell = k0_CellNorthWest; cell < k3_CellSouthWest; ++cell) {
 		sensorCountToProcessPerCell[cell] = 0;
 	}
 	Thing squareFirstThing;
@@ -55,9 +55,9 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 	ThingType thingType;
 	while (thingBeingProcessed != Thing::_endOfList) {
 		thingType = thingBeingProcessed.getType();
-		if (thingType == kSensorThingType) {
+		if (thingType == k3_SensorThingType) {
 			sensorCountToProcessPerCell[thingBeingProcessed.getCell()]++;
-		} else if (thingType >= kGroupThingType) {
+		} else if (thingType >= k4_GroupThingType) {
 			break;
 		}
 		thingBeingProcessed = dunMan.getNextThing(thingBeingProcessed);
@@ -66,14 +66,14 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 
 	while (thingBeingProcessed != Thing::_endOfList) {
 		thingType = thingBeingProcessed.getType();
-		if (thingType == kSensorThingType) {
+		if (thingType == k3_SensorThingType) {
 			cell = thingBeingProcessed.getCell();
 			sensorCountToProcessPerCell[cell]--;
 			Sensor *sensor = (Sensor*)dunMan.getThingData(thingBeingProcessed); // IF YOU CHECK ME, I'LL CALL THE COPS!
 			SensorType sensorType = sensor->getType();
-			if (sensorType == kSensorDisabled)
+			if (sensorType == k0_SensorDisabled)
 				goto T0275058_ProceedToNextThing;
-			if ((champMan._g411_leaderIndex == kM1_ChampionNone) && (sensorType != kSensorWallChampionPortrait))
+			if ((champMan._g411_leaderIndex == kM1_ChampionNone) && (sensorType != k127_SensorWallChampionPortrait))
 				goto T0275058_ProceedToNextThing;
 			if (cell != cellParam)
 				goto T0275058_ProceedToNextThing;
@@ -81,34 +81,34 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 			int16 sensorEffect = sensor->getEffectA();
 			bool doNotTriggerSensor;
 			switch (sensorType) {
-			case kSensorWallOrnClick:
+			case k1_SensorWallOrnClick:
 				doNotTriggerSensor = false;
-				if (sensor->getEffectA() == kSensorEffHold) {
+				if (sensor->getEffectA() == k3_SensorEffHold) {
 					goto T0275058_ProceedToNextThing;
 				}
 				break;
-			case kSensorWallOrnClickWithAnyObj:
+			case k2_SensorWallOrnClickWithAnyObj:
 				doNotTriggerSensor = (champMan._g415_leaderEmptyHanded != sensor->getRevertEffectA());
 				break;
-			case kSensorWallOrnClickWithSpecObjRemovedSensor:
-			case kSensorWallOrnClickWithSpecObjRemovedRotateSensors:
+			case k17_SensorWallOrnClickWithSpecObjRemovedSensor:
+			case k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors:
 				if (sensorCountToProcessPerCell[cell])
 					goto T0275058_ProceedToNextThing;
-			case kSensorWallOrnClickWithSpecObj:
-			case kSensorWallOrnClickWithSpecObjRemoved:
+			case k3_SensorWallOrnClickWithSpecObj:
+			case k4_SensorWallOrnClickWithSpecObjRemoved:
 				doNotTriggerSensor = ((sensorData == objMan.getObjectType(leaderHandObject)) == sensor->getRevertEffectA());
-				if (!doNotTriggerSensor && (sensorType == kSensorWallOrnClickWithSpecObjRemovedSensor)) {
+				if (!doNotTriggerSensor && (sensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) {
 					if (lastProcessedThing == thingBeingProcessed)
 						break;
 					((Sensor*)dunMan.getThingData(lastProcessedThing))->setNextThing(sensor->getNextThing());
 					sensor->setNextThing(Thing::_none);
 					thingBeingProcessed = lastProcessedThing;
 				}
-				if (!doNotTriggerSensor && (sensorType == kSensorWallOrnClickWithSpecObjRemovedRotateSensors)) {
+				if (!doNotTriggerSensor && (sensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors)) {
 					warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect");
 				}
 				break;
-			case kSensorWallObjGeneratorRotateSensors:
+			case k12_SensorWallObjGeneratorRotateSensors:
 				if (sensorCountToProcessPerCell[cell])
 					goto T0275058_ProceedToNextThing;
 				doNotTriggerSensor = !champMan._g415_leaderEmptyHanded;
@@ -116,7 +116,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 					warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect");
 				}
 				break;
-			case kSensorWallSingleObjStorageRotateSensors:
+			case k13_SensorWallSingleObjStorageRotateSensors:
 				if (champMan._g415_leaderEmptyHanded) {
 					warning("MISSING CODE: F0273_SENSOR_GetObjectOfTypeInCell");
 					warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList");
@@ -128,13 +128,13 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 					leaderHandObject = Thing::_none;
 				}
 				warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect");
-				if ((sensorEffect == kSensorEffHold) && !champMan._g415_leaderEmptyHanded) {
+				if ((sensorEffect == k3_SensorEffHold) && !champMan._g415_leaderEmptyHanded) {
 					doNotTriggerSensor = true;
 				} else {
 					doNotTriggerSensor = false;
 				}
 				break;
-			case kSensorWallObjExchanger: {
+			case k16_SensorWallObjExchanger: {
 				if (sensorCountToProcessPerCell[cell])
 					goto T0275058_ProceedToNextThing;
 				Thing thingOnSquare = dunMan.getSquareFirstThing(mapX, mapY);
@@ -147,15 +147,15 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 				doNotTriggerSensor = false;
 				break;
 			}
-			case kSensorWallChampionPortrait:
+			case k127_SensorWallChampionPortrait:
 				champMan.addCandidateChampionToParty(sensorData);
 				goto T0275058_ProceedToNextThing;
 			default:
 				goto T0275058_ProceedToNextThing;
 			}
 
-			if (sensorEffect == kSensorEffHold) {
-				sensorEffect = doNotTriggerSensor ? kSensorEffClear : kSensorEffSet;
+			if (sensorEffect == k3_SensorEffHold) {
+				sensorEffect = doNotTriggerSensor ? k1_SensorEffClear : k0_SensorEffSet;
 				doNotTriggerSensor = false;
 			}
 
@@ -165,16 +165,16 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 					warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 				}
 				if (!champMan._g415_leaderEmptyHanded &&
-					((sensorType == kSensorWallOrnClickWithSpecObjRemoved) ||
-					(sensorType == kSensorWallOrnClickWithSpecObjRemovedRotateSensors) ||
-					 (sensorType == kSensorWallOrnClickWithSpecObjRemovedSensor))) {
+					((sensorType == k4_SensorWallOrnClickWithSpecObjRemoved) ||
+					(sensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) ||
+					 (sensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
 
 					*((Thing*)dunMan.getThingData(leaderHandObject)) = Thing::_none;
 					warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand");
 					leaderHandObject = Thing::_none;
 				} else {
 					warning("MISSING CODE: (leaderHandObject = F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator(sensorData)");
-					if (champMan._g415_leaderEmptyHanded && (sensorType == kSensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_none)) {
+					if (champMan._g415_leaderEmptyHanded && (sensorType == k12_SensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_none)) {
 						warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand");
 					}
 				}
@@ -182,7 +182,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 			}
 			goto T0275058_ProceedToNextThing;
 		}
-		if (thingType >= kGroupThingType)
+		if (thingType >= k4_GroupThingType)
 			break;
 T0275058_ProceedToNextThing:
 		lastProcessedThing = thingBeingProcessed;
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index ae67904..810847c 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -127,7 +127,7 @@ IconIndice ObjectMan::getObjectType(Thing thing) {
 
 	int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing);
 	if (objectInfoIndex != -1) {
-		objectInfoIndex = gObjectInfo[objectInfoIndex]._type;
+		objectInfoIndex = g237_ObjectInfo[objectInfoIndex]._type;
 	}
 	return (IconIndice)objectInfoIndex;
 }
@@ -145,7 +145,7 @@ IconIndice ObjectMan::getIconIndex(Thing thing) {
 		uint16 *rawType = _vm->_dungeonMan->getThingData(thing);
 		switch (iconIndex) {
 		case k0_IconIndiceJunkCompassNorth:
-			iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_currMap._partyDir);
+			iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_currMap._g308_partyDir);
 			break;
 		case k4_IconIndiceWeaponTorchUnlit: {
 			Weapon weapon(rawType);
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 150c3c2..101fcca 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -44,7 +44,7 @@ Timeline::~Timeline() {
 void Timeline::initTimeline() {
 	_events = new TimelineEvent[_eventMaxCount];
 	_timeline = new uint16[_eventMaxCount];
-	if (_vm->_dungeonMan->_messages._newGame) {
+	if (_vm->_dungeonMan->_messages._g298_newGame) {
 		for (int16 i = 0; i < _eventMaxCount; ++i)
 			_events->_type = kTMEventTypeNone;
 		_eventCount = 0;


Commit: ce45a71ba0d294f5282c05859ac4097d26482b44
    https://github.com/scummvm/scummvm/commit/ce45a71ba0d294f5282c05859ac4097d26482b44
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: More renaming

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/group.h
    engines/dm/inventory.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index b8dac7f..0e062bb 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -852,7 +852,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	{ // block so goto won't skip AL_0_championIconIndex initialization 
 		int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._g308_partyDir);
 
-		if ((champAttributes & k28_ChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) {
+		if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) {
 			dispMan.clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]);
 			dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._g308_partyDir) * 19, 0,
 								 g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray);
@@ -1006,7 +1006,7 @@ void ChampionMan::renameChampion(Champion* champ) {
 	static Box okButtonBox(197, 215, 147, 155); // inclusive boundaries, constructor adds +1
 	for (;;) {
 		_vm->_eventMan->processInput();
-		if (_vm->_eventMan->hasPendingClick(clickPos, kLeftMouseButton) && okButtonBox.isPointInside(clickPos)) {
+		if (_vm->_eventMan->hasPendingClick(clickPos, k1_LeftMouseButton) && okButtonBox.isPointInside(clickPos)) {
 			return;
 		}
 		dispMan.updateScreen();
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 83fb506..6f0c465 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -169,14 +169,14 @@ void DMEngine::startGame() {
 	_g333_pressingMouth = false;
 	_g334_stopPressingMouth = false;
 	_g340_highlightBoxInversionRequested = false;
-	_eventMan->_highlightBoxEnabled = false;
+	_eventMan->_g341_highlightBoxEnabled = false;
 	_championMan->_g300_partyIsSleeping = false;
 	_championMan->_g506_actingChampionOrdinal = indexToOrdinal(kM1_ChampionNone);
 	_menuMan->_actionAreaContainsIcons = true;
-	_eventMan->_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kM1_ChampionNone);
+	_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kM1_ChampionNone);
 
-	_eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface;
-	_eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement;
+	_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface;
+	_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
 	warning("MISSING CODE: set primary/secondary keyboard input");
 
 	processNewPartyMap(_dungeonMan->_currMap._g309_currPartyMapIndex);
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 4ce3c18..7b12bf4 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -495,7 +495,7 @@ void DungeonMan::decompressDungeonFile() {
 	f.close();
 }
 
-uint8 gAdditionalThingCounts[16] = {
+byte g236_AdditionalThingCounts[16] = { // @ G0236_auc_Graphic559_AdditionalThingCounts{
 	0,    /* Door */
 	0,    /* Teleporter */
 	0,    /* Text String */
@@ -512,10 +512,10 @@ uint8 gAdditionalThingCounts[16] = {
 	0,    /* Unused */
 	60,   /* Projectile */
 	50    /* Explosion */
-}; // @ G0236_auc_Graphic559_AdditionalThingCounts
+}; 
 
 // this is the number of uint16s the data has to be stored, not the length of the data in dungeon.dat!
-unsigned char gThingDataWordCount[16] = {
+byte g235_ThingDataWordCount[16] = { // @ G0235_auc_Graphic559_ThingDataByteCount
 	2,   /* Door */
 	3,   /* Teleporter */
 	2,   /* Text String */
@@ -532,7 +532,7 @@ unsigned char gThingDataWordCount[16] = {
 	0,   /* Unused */
 	5,   /* Projectile */
 	2    /* Explosion */
-}; // @ G0235_auc_Graphic559_ThingDataByteCount
+}; 
 
 const Thing Thing::_none(0); // @ C0xFFFF_THING_NONE
 const Thing Thing::_endOfList(0xFFFE); // @ C0xFFFE_THING_ENDOFLIST
@@ -658,9 +658,9 @@ void DungeonMan::loadDungeonFile() {
 	for (uint16 thingType = k0_DoorThingType; thingType < k16_ThingTypeTotal; ++thingType) {
 		uint16 thingCount = _g278_fileHeader._thingCounts[thingType];
 		if (_messages._g298_newGame) {
-			_g278_fileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + gAdditionalThingCounts[thingType]);
+			_g278_fileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + g236_AdditionalThingCounts[thingType]);
 		}
-		uint16 thingStoreWordCount = gThingDataWordCount[thingType];
+		uint16 thingStoreWordCount = g235_ThingDataWordCount[thingType];
 
 		if (thingStoreWordCount == 0)
 			continue;
@@ -700,7 +700,7 @@ void DungeonMan::loadDungeonFile() {
 		if (_messages._g298_newGame) {
 			if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType)
 				_vm->_timeline->_eventMaxCount += _g278_fileHeader._thingCounts[thingType];
-			for (uint16 i = 0; i < gAdditionalThingCounts[thingType]; ++i) {
+			for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) {
 				_dunData._g284_thingsData[thingType][thingCount + i][0] = Thing::_none.toUint16();
 			}
 		}
@@ -996,7 +996,7 @@ Thing DungeonMan::getNextThing(Thing thing) {
 	return getThingData(thing)[0]; // :)
 }
 
-char gMessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings
+char g255_MessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings
 	{'x',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '?',  0,  0,  0, 0, 0, 0, 0 }, */
 	{'y',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '!',  0,  0,  0, 0, 0, 0, 0 }, */
 	{'T','H','E',' ', 0, 0, 0, 0},
@@ -1029,7 +1029,7 @@ char gMessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559
 	{0,  0,  0,  0, 0, 0, 0, 0},
 	{0,  0,  0,  0, 0, 0, 0, 0},
 	{0,  0,  0,  0, 0, 0, 0, 0}};
-char gEscReplacementCharacters[32][2] = { // @ G0256_aac_Graphic559_EscapeReplacementCharacters
+char g256_EscReplacementCharacters[32][2] = { // @ G0256_aac_Graphic559_EscapeReplacementCharacters
 	{'a', 0},
 	{'b', 0},
 	{'c', 0},
@@ -1062,7 +1062,7 @@ char gEscReplacementCharacters[32][2] = { // @ G0256_aac_Graphic559_EscapeReplac
 	{'5', 0},
 	{'6', 0},
 	{'7', 0}};
-char gInscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_InscriptionEscapeReplacementStrings
+char g257_InscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_InscriptionEscapeReplacementStrings
 	{28,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
 	{29,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
 	{19,  7,  4, 26, 0, 0, 0, 0},
@@ -1131,12 +1131,12 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 				*destString = '\0';
 				if (escChar == 30) {
 					if (type != k0_TextTypeInscription) {
-						escReplString = gMessageAndScrollEscReplacementStrings[code];
+						escReplString = g255_MessageAndScrollEscReplacementStrings[code];
 					} else {
-						escReplString = gInscriptionEscReplacementStrings[code];
+						escReplString = g257_InscriptionEscReplacementStrings[code];
 					}
 				} else {
-					escReplString = gEscReplacementCharacters[code];
+					escReplString = g256_EscReplacementCharacters[code];
 				}
 				strcat(destString, escReplString);
 				destString += strlen(escReplString);
@@ -1166,7 +1166,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 
 
 uint16 DungeonMan::getObjectWeight(Thing thing) {
-	static const uint16 junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo
+	static const uint16 g241_junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo
 		// COMPASS - WATERSKIN - JEWEL SYMAL - ILLUMULET - ASHES
 		1, 3, 2, 2, 4,
 		// BONES - COPPER COIN - SILVER COIN - GOLD COIN - IRON KEY
@@ -1200,7 +1200,7 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 		return g239_ArmourInfo[Armour(getThingData(thing)).getType()]._weight;
 	case k10_JunkThingType: {
 		Junk junk(getThingData(thing));
-		uint16 weight = junkInfo[junk.getType()];
+		uint16 weight = g241_junkInfo[junk.getType()];
 		if (junk.getType() == k1_JunkTypeWaterskin)
 			weight += junk.getChargeCount() * 2;
 		return weight;
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 4a60768..69886e5 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -40,226 +40,226 @@
 
 namespace DM {
 
-Box gBoxObjectPiles[4] = { // @ G0462_as_Graphic561_Box_ObjectPiles
+Box g462_BoxObjectPiles[4] = { // @ G0462_as_Graphic561_Box_ObjectPiles
 	/* { X1, X2, Y1, Y2 } */
 	Box(24, 111, 148, 168),   /* Front left */
 	Box(112, 199, 148, 168),   /* Front right */
 	Box(112, 183, 122, 147),   /* Back right */
 	Box(40, 111, 122, 147)}; /* Back left */
 
-MouseInput gPrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
+MouseInput g445_PrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
 												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(kCommandEntranceEnterDungeon, 244, 298,  45,  58, kLeftMouseButton),
+	MouseInput(k200_CommandEntranceEnterDungeon, 244, 298,  45,  58, k1_LeftMouseButton),
 	// Strangerke - C201_COMMAND_ENTRANCE_RESUME isn't present in the demo
-	MouseInput(kCommandEntranceResume,        244, 298,  76,  93, kLeftMouseButton),
-	MouseInput(kCommandEntranceDrawCredits,  248, 293, 187, 199, kLeftMouseButton),
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gPrimaryMouseInput_RestartGame[2] = { // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
+	MouseInput(k201_CommandEntranceResume,        244, 298,  76,  93, k1_LeftMouseButton),
+	MouseInput(k202_CommandEntranceDrawCredits,  248, 293, 187, 199, k1_LeftMouseButton),
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g446_PrimaryMouseInput_RestartGame[2] = { // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
 													 /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(kCommandRestartGame, 103, 217, 145, 159, kLeftMouseButton),
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gPrimaryMouseInput_Interface[20] = { // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
+	MouseInput(k215_CommandRestartGame, 103, 217, 145, 159, k1_LeftMouseButton),
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g447_PrimaryMouseInput_Interface[20] = { // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
 													/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(kCommandClickInChampion_0_StatusBox,       0,  42,   0,  28, kLeftMouseButton),
-	MouseInput(kCommandClickInChampion_1_StatusBox,      69, 111,   0,  28, kLeftMouseButton),
-	MouseInput(kCommandClickInChampion_2_StatusBox,     138, 180,   0,  28, kLeftMouseButton),
-	MouseInput(kCommandClickInChampion_3_StatusBox,     207, 249,   0,  28, kLeftMouseButton),
-	MouseInput(kCommandClickOnChamptionIcon_Top_Left,    274, 299,   0,  13, kLeftMouseButton),
-	MouseInput(kCommandClickOnChamptionIcon_Top_Right,   301, 319,   0,  13, kLeftMouseButton),
-	MouseInput(kCommandClickOnChamptionIcon_Lower_Right, 301, 319,  15,  28, kLeftMouseButton),
-	MouseInput(kCommandClickOnChamptionIcon_Lower_Left,  274, 299,  15,  28, kLeftMouseButton),
-	MouseInput(kCommandToggleInventoryChampion_0,         43,  66,   0,  28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 =  44. swapped with 4 next entries */
-	MouseInput(kCommandToggleInventoryChampion_1,        112, 135,   0,  28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 113. swapped with 4 next entries */
-	MouseInput(kCommandToggleInventoryChampion_2,        181, 204,   0,  28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 182. swapped with 4 next entries */
-	MouseInput(kCommandToggleInventoryChampion_3,        250, 273,   0,  28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 251. swapped with 4 next entries */
-	MouseInput(kCommandToggleInventoryChampion_0,          0,  66,   0,  28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */
-	MouseInput(kCommandToggleInventoryChampion_1,         69, 135,   0,  28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */
-	MouseInput(kCommandToggleInventoryChampion_2,        138, 204,   0,  28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */
-	MouseInput(kCommandToggleInventoryChampion_3,        207, 273,   0,  28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */
-	MouseInput(kCommandClickInSpellArea,                233, 319,  42,  73, kLeftMouseButton),
-	MouseInput(kCommandClickInActionArea,               233, 319,  77, 121, kLeftMouseButton),
-	MouseInput(kCommandFreezeGame,                          0,   1, 198, 199, kLeftMouseButton),
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gSecondaryMouseInput_Movement[9] = { // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9]
+	MouseInput(k12_CommandClickInChampion_0_StatusBox,       0,  42,   0,  28, k1_LeftMouseButton),
+	MouseInput(k13_CommandClickInChampion_1_StatusBox,      69, 111,   0,  28, k1_LeftMouseButton),
+	MouseInput(k14_CommandClickInChampion_2_StatusBox,     138, 180,   0,  28, k1_LeftMouseButton),
+	MouseInput(k15_CommandClickInChampion_3_StatusBox,     207, 249,   0,  28, k1_LeftMouseButton),
+	MouseInput(k125_CommandClickOnChamptionIcon_Top_Left,    274, 299,   0,  13, k1_LeftMouseButton),
+	MouseInput(k126_CommandClickOnChamptionIcon_Top_Right,   301, 319,   0,  13, k1_LeftMouseButton),
+	MouseInput(k127_CommandClickOnChamptionIcon_Lower_Right, 301, 319,  15,  28, k1_LeftMouseButton),
+	MouseInput(k128_CommandClickOnChamptionIcon_Lower_Left,  274, 299,  15,  28, k1_LeftMouseButton),
+	MouseInput(k7_CommandToggleInventoryChampion_0,         43,  66,   0,  28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 =  44. swapped with 4 next entries */
+	MouseInput(k8_CommandToggleInventoryChampion_1,        112, 135,   0,  28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 113. swapped with 4 next entries */
+	MouseInput(k9_CommandToggleInventoryChampion_2,        181, 204,   0,  28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 182. swapped with 4 next entries */
+	MouseInput(k10_CommandToggleInventoryChampion_3,        250, 273,   0,  28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 251. swapped with 4 next entries */
+	MouseInput(k7_CommandToggleInventoryChampion_0,          0,  66,   0,  28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */
+	MouseInput(k8_CommandToggleInventoryChampion_1,         69, 135,   0,  28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */
+	MouseInput(k9_CommandToggleInventoryChampion_2,        138, 204,   0,  28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */
+	MouseInput(k10_CommandToggleInventoryChampion_3,        207, 273,   0,  28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */
+	MouseInput(k100_CommandClickInSpellArea,                233, 319,  42,  73, k1_LeftMouseButton),
+	MouseInput(k111_CommandClickInActionArea,               233, 319,  77, 121, k1_LeftMouseButton),
+	MouseInput(k147_CommandFreezeGame,                          0,   1, 198, 199, k1_LeftMouseButton),
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g448_SecondaryMouseInput_Movement[9] = { // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9]
 													/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(kCommandTurnLeft,             234, 261, 125, 145, kLeftMouseButton),
-	MouseInput(kCommandMoveForward,          263, 289, 125, 145, kLeftMouseButton),
-	MouseInput(kCommandTurnRight,            291, 318, 125, 145, kLeftMouseButton),
-	MouseInput(kCommandMoveLeft,             234, 261, 147, 167, kLeftMouseButton),
-	MouseInput(kCommandMoveBackward,         263, 289, 147, 167, kLeftMouseButton),
-	MouseInput(kCommandMoveRight,            291, 318, 147, 167, kLeftMouseButton),
-	MouseInput(kCommandClickInDungeonView,   0, 223,  33, 168, kLeftMouseButton),
-	MouseInput(kCommandToggleInventoryLeader, 0, 319,  33, 199, kRightMouseButton),
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gSecondaryMouseInput_ChampionInventory[38] = { // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38]
+	MouseInput(k1_CommandTurnLeft,             234, 261, 125, 145, k1_LeftMouseButton),
+	MouseInput(k3_CommandMoveForward,          263, 289, 125, 145, k1_LeftMouseButton),
+	MouseInput(k2_CommandTurnRight,            291, 318, 125, 145, k1_LeftMouseButton),
+	MouseInput(k6_CommandMoveLeft,             234, 261, 147, 167, k1_LeftMouseButton),
+	MouseInput(k5_CommandMoveBackward,         263, 289, 147, 167, k1_LeftMouseButton),
+	MouseInput(k4_CommandMoveRight,            291, 318, 147, 167, k1_LeftMouseButton),
+	MouseInput(k80_CommandClickInDungeonView,   0, 223,  33, 168, k1_LeftMouseButton),
+	MouseInput(k83_CommandToggleInventoryLeader, 0, 319,  33, 199, k2_RightMouseButton),
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g449_SecondaryMouseInput_ChampionInventory[38] = { // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38]
 															  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(kCommandCloseInventory,                                   0, 319,   0, 199, kRightMouseButton),
-	MouseInput(kCommandSaveGame,                                       174, 182,  36,  44, kLeftMouseButton),
-	MouseInput(kCommandSleep,                                           188, 204,  36,  44, kLeftMouseButton),
-	MouseInput(kCommandCloseInventory,                                 210, 218,  36,  44, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryReadyHand ,        6,  21,  86, 101, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryActionHand,       62,  77,  86, 101, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryHead,              34,  49,  59,  74, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryTorso,             34,  49,  79,  94, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryLegs,              34,  49,  99, 114, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryFeet,              34,  49, 119, 134, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryPouch_2,            6,  21, 123, 138, kLeftMouseButton),
-	MouseInput(kCommandClickOnMouth,                                   56,  71,  46,  61, kLeftMouseButton),
-	MouseInput(kCommandClickOnEye,                                     12,  27,  46,  61, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_2_1,    79,  94, 106, 121, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_1_2,    62,  77, 123, 138, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_2_2,    79,  94, 123, 138, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryNeck,               6,  21,  66,  81, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryPouch_1,            6,  21, 106, 121, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_1_1,    62,  77, 106, 121, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_1,  66,  81,  66,  81, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_2,  83,  98,  49,  64, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_3, 100, 115,  49,  64, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_4, 117, 132,  49,  64, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_5, 134, 149,  49,  64, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_6, 151, 166,  49,  64, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_7, 168, 183,  49,  64, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_8, 185, 200,  49,  64, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_9, 202, 217,  49,  64, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_2,  83,  98,  66,  81, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_3, 100, 115,  66,  81, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_4, 117, 132,  66,  81, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_5, 134, 149,  66,  81, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_6, 151, 166,  66,  81, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_7, 168, 183,  66,  81, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_8, 185, 200,  66,  81, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_9, 202, 217,  66,  81, kLeftMouseButton),
-	MouseInput(kCommandClickInPanel,                                   96, 223,  83, 167, kLeftMouseButton),
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gPrimaryMouseInput_PartySleeping[3] = { // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
+	MouseInput(k11_CommandCloseInventory,                                   0, 319,   0, 199, k2_RightMouseButton),
+	MouseInput(k140_CommandSaveGame,                                       174, 182,  36,  44, k1_LeftMouseButton),
+	MouseInput(k145_CommandSleep,                                           188, 204,  36,  44, k1_LeftMouseButton),
+	MouseInput(k11_CommandCloseInventory,                                 210, 218,  36,  44, k1_LeftMouseButton),
+	MouseInput(k28_CommandClickOnSlotBoxInventoryReadyHand ,        6,  21,  86, 101, k1_LeftMouseButton),
+	MouseInput(k29_CommandClickOnSlotBoxInventoryActionHand,       62,  77,  86, 101, k1_LeftMouseButton),
+	MouseInput(k30_CommandClickOnSlotBoxInventoryHead,              34,  49,  59,  74, k1_LeftMouseButton),
+	MouseInput(k31_CommandClickOnSlotBoxInventoryTorso,             34,  49,  79,  94, k1_LeftMouseButton),
+	MouseInput(k32_CommandClickOnSlotBoxInventoryLegs,              34,  49,  99, 114, k1_LeftMouseButton),
+	MouseInput(k33_CommandClickOnSlotBoxInventoryFeet,              34,  49, 119, 134, k1_LeftMouseButton),
+	MouseInput(k34_CommandClickOnSlotBoxInventoryPouch_2,            6,  21, 123, 138, k1_LeftMouseButton),
+	MouseInput(k70_CommandClickOnMouth,                                   56,  71,  46,  61, k1_LeftMouseButton),
+	MouseInput(k71_CommandClickOnEye,                                     12,  27,  46,  61, k1_LeftMouseButton),
+	MouseInput(k35_CommandClickOnSlotBoxInventoryQuiverLine_2_1,    79,  94, 106, 121, k1_LeftMouseButton),
+	MouseInput(k36_CommandClickOnSlotBoxInventoryQuiverLine_1_2,    62,  77, 123, 138, k1_LeftMouseButton),
+	MouseInput(k37_CommandClickOnSlotBoxInventoryQuiverLine_2_2,    79,  94, 123, 138, k1_LeftMouseButton),
+	MouseInput(k38_CommandClickOnSlotBoxInventoryNeck,               6,  21,  66,  81, k1_LeftMouseButton),
+	MouseInput(k39_CommandClickOnSlotBoxInventoryPouch_1,            6,  21, 106, 121, k1_LeftMouseButton),
+	MouseInput(k40_CommandClickOnSlotBoxInventoryQuiverLine_1_1,    62,  77, 106, 121, k1_LeftMouseButton),
+	MouseInput(k41_CommandClickOnSlotBoxInventoryBackpackLine_1_1,  66,  81,  66,  81, k1_LeftMouseButton),
+	MouseInput(k42_CommandClickOnSlotBoxInventoryBackpackLine_2_2,  83,  98,  49,  64, k1_LeftMouseButton),
+	MouseInput(k43_CommandClickOnSlotBoxInventoryBackpackLine_2_3, 100, 115,  49,  64, k1_LeftMouseButton),
+	MouseInput(k44_CommandClickOnSlotBoxInventoryBackpackLine_2_4, 117, 132,  49,  64, k1_LeftMouseButton),
+	MouseInput(k45_CommandClickOnSlotBoxInventoryBackpackLine_2_5, 134, 149,  49,  64, k1_LeftMouseButton),
+	MouseInput(k46_CommandClickOnSlotBoxInventoryBackpackLine_2_6, 151, 166,  49,  64, k1_LeftMouseButton),
+	MouseInput(k47_CommandClickOnSlotBoxInventoryBackpackLine_2_7, 168, 183,  49,  64, k1_LeftMouseButton),
+	MouseInput(k48_CommandClickOnSlotBoxInventoryBackpackLine_2_8, 185, 200,  49,  64, k1_LeftMouseButton),
+	MouseInput(k49_CommandClickOnSlotBoxInventoryBackpackLine_2_9, 202, 217,  49,  64, k1_LeftMouseButton),
+	MouseInput(k50_CommandClickOnSlotBoxInventoryBackpackLine_1_2,  83,  98,  66,  81, k1_LeftMouseButton),
+	MouseInput(k51_CommandClickOnSlotBoxInventoryBackpackLine_1_3, 100, 115,  66,  81, k1_LeftMouseButton),
+	MouseInput(k52_CommandClickOnSlotBoxInventoryBackpackLine_1_4, 117, 132,  66,  81, k1_LeftMouseButton),
+	MouseInput(k53_CommandClickOnSlotBoxInventoryBackpackLine_1_5, 134, 149,  66,  81, k1_LeftMouseButton),
+	MouseInput(k54_CommandClickOnSlotBoxInventoryBackpackLine_1_6, 151, 166,  66,  81, k1_LeftMouseButton),
+	MouseInput(k55_CommandClickOnSlotBoxInventoryBackpackLine_1_7, 168, 183,  66,  81, k1_LeftMouseButton),
+	MouseInput(k56_CommandClickOnSlotBoxInventoryBackpackLine_1_8, 185, 200,  66,  81, k1_LeftMouseButton),
+	MouseInput(k57_CommandClickOnSlotBoxInventoryBackpackLine_1_9, 202, 217,  66,  81, k1_LeftMouseButton),
+	MouseInput(k81_CommandClickInPanel,                                   96, 223,  83, 167, k1_LeftMouseButton),
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g450_PrimaryMouseInput_PartySleeping[3] = { // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
 													   /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(kCommandWakeUp, 0, 223, 33, 168, kLeftMouseButton),
-	MouseInput(kCommandWakeUp, 0, 223, 33, 168, kRightMouseButton),
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gPrimaryMouseInput_FrozenGame[3] = { // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3]
+	MouseInput(k146_CommandWakeUp, 0, 223, 33, 168, k1_LeftMouseButton),
+	MouseInput(k146_CommandWakeUp, 0, 223, 33, 168, k2_RightMouseButton),
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g451_PrimaryMouseInput_FrozenGame[3] = { // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3]
 													/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(kCommandUnfreezeGame, 0, 319, 0, 199, kLeftMouseButton),
-	MouseInput(kCommandUnfreezeGame, 0, 319, 0, 199, kRightMouseButton),
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gMouseInput_ActionAreaNames[5] = { // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5]
+	MouseInput(k148_CommandUnfreezeGame, 0, 319, 0, 199, k1_LeftMouseButton),
+	MouseInput(k148_CommandUnfreezeGame, 0, 319, 0, 199, k2_RightMouseButton),
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g452_MouseInput_ActionAreaNames[5] = { // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5]
 												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(kCommandClickInActionAreaPass,     285, 318,  77,  83, kLeftMouseButton),
-	MouseInput(kCommandClickInActionAreaAction_0, 234, 318,  86,  96, kLeftMouseButton),
-	MouseInput(kCommandClickInActionAreaAction_1, 234, 318,  98, 108, kLeftMouseButton),
-	MouseInput(kCommandClickInActionAreaAction_2, 234, 318, 110, 120, kLeftMouseButton),
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gMouseInput_ActionAreaIcons[5] = { // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5]
+	MouseInput(k112_CommandClickInActionAreaPass,     285, 318,  77,  83, k1_LeftMouseButton),
+	MouseInput(k113_CommandClickInActionAreaAction_0, 234, 318,  86,  96, k1_LeftMouseButton),
+	MouseInput(k114_CommandClickInActionAreaAction_1, 234, 318,  98, 108, k1_LeftMouseButton),
+	MouseInput(k115_CommandClickInActionAreaAction_2, 234, 318, 110, 120, k1_LeftMouseButton),
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g453_MouseInput_ActionAreaIcons[5] = { // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5]
 												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(kCommandClickInActionAreaChampion_0_Action, 233, 252, 86, 120, kLeftMouseButton),
-	MouseInput(kCommandClickInActionAreaChampion_1_Action, 255, 274, 86, 120, kLeftMouseButton),
-	MouseInput(kCommandClickInActionAreaChampion_2_Action, 277, 296, 86, 120, kLeftMouseButton),
-	MouseInput(kCommandClickInActionAreaChampion_3_Action, 299, 318, 86, 120, kLeftMouseButton),
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gMouseInput_SpellArea[9] = { // @ G0454_as_Graphic561_MouseInput_SpellArea[9]
+	MouseInput(k116_CommandClickInActionAreaChampion_0_Action, 233, 252, 86, 120, k1_LeftMouseButton),
+	MouseInput(k117_CommandClickInActionAreaChampion_1_Action, 255, 274, 86, 120, k1_LeftMouseButton),
+	MouseInput(k118_CommandClickInActionAreaChampion_2_Action, 277, 296, 86, 120, k1_LeftMouseButton),
+	MouseInput(k119_CommandClickInActionAreaChampion_3_Action, 299, 318, 86, 120, k1_LeftMouseButton),
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g454_MouseInput_SpellArea[9] = { // @ G0454_as_Graphic561_MouseInput_SpellArea[9]
 											/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(kCommandClickInSpellAreaSymbol_1,      235, 247, 51, 61, kLeftMouseButton),
-	MouseInput(kCommandClickInSpellAreaSymbol_2,      249, 261, 51, 61, kLeftMouseButton),
-	MouseInput(kCommandClickInSpellAreaSymbol_3,      263, 275, 51, 61, kLeftMouseButton),
-	MouseInput(kCommandClickInSpellAreaSymbol_4,      277, 289, 51, 61, kLeftMouseButton),
-	MouseInput(kCommandClickInSpellAreaSymbol_5,      291, 303, 51, 61, kLeftMouseButton),
-	MouseInput(kCommandClickInSpellAreaSymbol_6,      305, 317, 51, 61, kLeftMouseButton),
-	MouseInput(kCommandClickInSpeallAreaCastSpell,    234, 303, 63, 73, kLeftMouseButton),
-	MouseInput(kCommandClickInSpellAreaRecantSymbol, 305, 318, 63, 73, kLeftMouseButton),
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gMouseInput_ChampionNamesHands[13] = { // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
+	MouseInput(k101_CommandClickInSpellAreaSymbol_1,      235, 247, 51, 61, k1_LeftMouseButton),
+	MouseInput(k102_CommandClickInSpellAreaSymbol_2,      249, 261, 51, 61, k1_LeftMouseButton),
+	MouseInput(k103_CommandClickInSpellAreaSymbol_3,      263, 275, 51, 61, k1_LeftMouseButton),
+	MouseInput(k104_CommandClickInSpellAreaSymbol_4,      277, 289, 51, 61, k1_LeftMouseButton),
+	MouseInput(k105_CommandClickInSpellAreaSymbol_5,      291, 303, 51, 61, k1_LeftMouseButton),
+	MouseInput(k106_CommandClickInSpellAreaSymbol_6,      305, 317, 51, 61, k1_LeftMouseButton),
+	MouseInput(k108_CommandClickInSpeallAreaCastSpell,    234, 303, 63, 73, k1_LeftMouseButton),
+	MouseInput(k107_CommandClickInSpellAreaRecantSymbol, 305, 318, 63, 73, k1_LeftMouseButton),
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g455_MouseInput_ChampionNamesHands[13] = { // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
 													  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(kCommandSetLeaderChampion_0,                                    0,  42,  0,  6, kLeftMouseButton),
-	MouseInput(kCommandSetLeaderChampion_1,                                   69, 111,  0,  6, kLeftMouseButton),
-	MouseInput(kCommandSetLeaderChampion_2,                                  138, 180,  0,  6, kLeftMouseButton),
-	MouseInput(kCommandSetLeaderChampion_3,                                  207, 249,  0,  6, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxChampion_0_StatusBoxReadyHand,    4,  19, 10, 25, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxChampion_0_StatusBoxActionHand,  24,  39, 10, 25, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxChampion_1_StatusBoxReadyHand,   73,  88, 10, 25, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxChampion_1_StatusBoxActionHand,  93, 108, 10, 25, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxChampion_2_StatusBoxReadyHand,  142, 157, 10, 25, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxChampion_2_StatusBoxActionHand, 162, 177, 10, 25, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxChampion_3_StatusBoxReadyHand,  211, 226, 10, 25, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxChampion_3_StatusBoxActionHand, 231, 246, 10, 25, kLeftMouseButton),
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gMouseInput_PanelChest[9] = { // @ G0456_as_Graphic561_MouseInput_PanelChest[9]
+	MouseInput(k16_CommandSetLeaderChampion_0,                                    0,  42,  0,  6, k1_LeftMouseButton),
+	MouseInput(k17_CommandSetLeaderChampion_1,                                   69, 111,  0,  6, k1_LeftMouseButton),
+	MouseInput(k18_CommandSetLeaderChampion_2,                                  138, 180,  0,  6, k1_LeftMouseButton),
+	MouseInput(k19_CommandSetLeaderChampion_3,                                  207, 249,  0,  6, k1_LeftMouseButton),
+	MouseInput(k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand,    4,  19, 10, 25, k1_LeftMouseButton),
+	MouseInput(k21_CommandClickOnSlotBoxChampion_0_StatusBoxActionHand,  24,  39, 10, 25, k1_LeftMouseButton),
+	MouseInput(k22_CommandClickOnSlotBoxChampion_1_StatusBoxReadyHand,   73,  88, 10, 25, k1_LeftMouseButton),
+	MouseInput(k23_CommandClickOnSlotBoxChampion_1_StatusBoxActionHand,  93, 108, 10, 25, k1_LeftMouseButton),
+	MouseInput(k24_CommandClickOnSlotBoxChampion_2_StatusBoxReadyHand,  142, 157, 10, 25, k1_LeftMouseButton),
+	MouseInput(k25_CommandClickOnSlotBoxChampion_2_StatusBoxActionHand, 162, 177, 10, 25, k1_LeftMouseButton),
+	MouseInput(k26_CommandClickOnSlotBoxChampion_3_StatusBoxReadyHand,  211, 226, 10, 25, k1_LeftMouseButton),
+	MouseInput(k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand, 231, 246, 10, 25, k1_LeftMouseButton),
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g456_MouseInput_PanelChest[9] = { // @ G0456_as_Graphic561_MouseInput_PanelChest[9]
 											 /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(kCommandClickOnSlotBoxChest_1, 117, 132,  92, 107, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxChest_2, 106, 121, 109, 124, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxChest_3, 111, 126, 126, 141, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxChest_4, 128, 143, 131, 146, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxChest_5, 145, 160, 134, 149, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxChest_6, 162, 177, 136, 151, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxChest_7, 179, 194, 137, 152, kLeftMouseButton),
-	MouseInput(kCommandClickOnSlotBoxChest_8, 196, 211, 138, 153, kLeftMouseButton),
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gMouseInput_PanelResurrectReincarnateCancel[4] = { // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4]
+	MouseInput(k58_CommandClickOnSlotBoxChest_1, 117, 132,  92, 107, k1_LeftMouseButton),
+	MouseInput(k59_CommandClickOnSlotBoxChest_2, 106, 121, 109, 124, k1_LeftMouseButton),
+	MouseInput(k60_CommandClickOnSlotBoxChest_3, 111, 126, 126, 141, k1_LeftMouseButton),
+	MouseInput(k61_CommandClickOnSlotBoxChest_4, 128, 143, 131, 146, k1_LeftMouseButton),
+	MouseInput(k62_CommandClickOnSlotBoxChest_5, 145, 160, 134, 149, k1_LeftMouseButton),
+	MouseInput(k63_CommandClickOnSlotBoxChest_6, 162, 177, 136, 151, k1_LeftMouseButton),
+	MouseInput(k64_CommandClickOnSlotBoxChest_7, 179, 194, 137, 152, k1_LeftMouseButton),
+	MouseInput(k65_CommandClickOnSlotBoxChest_8, 196, 211, 138, 153, k1_LeftMouseButton),
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g457_MouseInput_PanelResurrectReincarnateCancel[4] = { // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4]
 																  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(kCommandClickInPanelResurrect,   108, 158,  90, 138, kLeftMouseButton), /* Atari ST: Box = 104, 158,  86, 142 */
-	MouseInput(kCommandClickInPanelReincarnate, 161, 211,  90, 138, kLeftMouseButton), /* Atari ST: Box = 163, 217,  86, 142 */
-	MouseInput(kCommandClickInPanelCancel,      108, 211, 141, 153, kLeftMouseButton), /* Atari ST: Box = 104, 217, 146, 156 */
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-
-
-MouseInput gPrimaryMouseInput_ViewportDialog1Choice[2] = { // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
-	MouseInput(kCommandClickOnDialogChoice_1, 16, 207, 138, 152, kLeftMouseButton), /* Bottom button */
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gPrimaryMouseInput_ViewportDialog2Choices[3] = { // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3]
-	MouseInput(kCommandClickOnDialogChoice_1, 16, 207, 101, 115, kLeftMouseButton), /* Top button */
-	MouseInput(kCommandClickOnDialogChoice_2, 16, 207, 138, 152, kLeftMouseButton), /* Bottom button */
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gPrimaryMouseInput_ViewportDialog3Choices[4] = { // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4]
-	MouseInput(kCommandClickOnDialogChoice_1,  16, 207, 101, 115, kLeftMouseButton), /* Top button */
-	MouseInput(kCommandClickOnDialogChoice_2,  16, 101, 138, 152, kLeftMouseButton), /* Lower left button */
-	MouseInput(kCommandClickOnDialogChoice_3, 123, 207, 138, 152, kLeftMouseButton), /* Lower right button */
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gPrimaryMouseInput_ViewportDialog4Choices[5] = { // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5]
-	MouseInput(kCommandClickOnDialogChoice_1,  16, 101, 101, 115, kLeftMouseButton), /* Top left button */
-	MouseInput(kCommandClickOnDialogChoice_2, 123, 207, 101, 115, kLeftMouseButton), /* Top right button */
-	MouseInput(kCommandClickOnDialogChoice_3,  16, 101, 138, 152, kLeftMouseButton), /* Lower left button */
-	MouseInput(kCommandClickOnDialogChoice_4, 123, 207, 138, 152, kLeftMouseButton), /* Lower right button */
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gPrimaryMouseInput_ScreenDialog1Choice[2] = { // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2]
-	MouseInput(kCommandClickOnDialogChoice_1, 63, 254, 138, 152, kLeftMouseButton), /* Bottom button */
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gPrimaryMouseInput_ScreenDialog2Choices[3] = { // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3]
-	MouseInput(kCommandClickOnDialogChoice_1, 63, 254, 101, 115, kLeftMouseButton), /* Top button */
-	MouseInput(kCommandClickOnDialogChoice_2, 63, 254, 138, 152, kLeftMouseButton), /* Bottom button */
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gPrimaryMouseInput_ScreenDialog3Choices[4] = { // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4]
-	MouseInput(kCommandClickOnDialogChoice_1,  63, 254, 101, 115, kLeftMouseButton), /* Top button */
-	MouseInput(kCommandClickOnDialogChoice_2,  63, 148, 138, 152, kLeftMouseButton), /* Lower left button */
-	MouseInput(kCommandClickOnDialogChoice_3, 170, 254, 138, 152, kLeftMouseButton), /* Lower right button */
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-MouseInput gPrimaryMouseInput_ScreenDialog4Choices[5] = { // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
-	MouseInput(kCommandClickOnDialogChoice_1,  63, 148, 101, 115, kLeftMouseButton), /* Top left button */
-	MouseInput(kCommandClickOnDialogChoice_2, 170, 254, 101, 115, kLeftMouseButton), /* Top right button */
-	MouseInput(kCommandClickOnDialogChoice_3,  63, 148, 138, 152, kLeftMouseButton), /* Lower left button */
-	MouseInput(kCommandClickOnDialogChoice_4, 170, 254, 138, 152, kLeftMouseButton), /* Lower right button */
-	MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)};
-
-MouseInput* gPrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryMouseInput_DialogSets
-	{gPrimaryMouseInput_ViewportDialog1Choice,
-	gPrimaryMouseInput_ViewportDialog2Choices,
-	gPrimaryMouseInput_ViewportDialog3Choices,
-	gPrimaryMouseInput_ViewportDialog4Choices},
-	{gPrimaryMouseInput_ScreenDialog1Choice,
-	gPrimaryMouseInput_ScreenDialog2Choices,
-	gPrimaryMouseInput_ScreenDialog3Choices,
-	gPrimaryMouseInput_ScreenDialog4Choices},};
+	MouseInput(k160_CommandClickInPanelResurrect,   108, 158,  90, 138, k1_LeftMouseButton), /* Atari ST: Box = 104, 158,  86, 142 */
+	MouseInput(k161_CommandClickInPanelReincarnate, 161, 211,  90, 138, k1_LeftMouseButton), /* Atari ST: Box = 163, 217,  86, 142 */
+	MouseInput(k162_CommandClickInPanelCancel,      108, 211, 141, 153, k1_LeftMouseButton), /* Atari ST: Box = 104, 217, 146, 156 */
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+
+
+MouseInput g471_PrimaryMouseInput_ViewportDialog1Choice[2] = { // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
+	MouseInput(k210_CommandClickOnDialogChoice_1, 16, 207, 138, 152, k1_LeftMouseButton), /* Bottom button */
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g472_PrimaryMouseInput_ViewportDialog2Choices[3] = { // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3]
+	MouseInput(k210_CommandClickOnDialogChoice_1, 16, 207, 101, 115, k1_LeftMouseButton), /* Top button */
+	MouseInput(k211_CommandClickOnDialogChoice_2, 16, 207, 138, 152, k1_LeftMouseButton), /* Bottom button */
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g473_PrimaryMouseInput_ViewportDialog3Choices[4] = { // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4]
+	MouseInput(k210_CommandClickOnDialogChoice_1,  16, 207, 101, 115, k1_LeftMouseButton), /* Top button */
+	MouseInput(k211_CommandClickOnDialogChoice_2,  16, 101, 138, 152, k1_LeftMouseButton), /* Lower left button */
+	MouseInput(k212_CommandClickOnDialogChoice_3, 123, 207, 138, 152, k1_LeftMouseButton), /* Lower right button */
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g474_PrimaryMouseInput_ViewportDialog4Choices[5] = { // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5]
+	MouseInput(k210_CommandClickOnDialogChoice_1,  16, 101, 101, 115, k1_LeftMouseButton), /* Top left button */
+	MouseInput(k211_CommandClickOnDialogChoice_2, 123, 207, 101, 115, k1_LeftMouseButton), /* Top right button */
+	MouseInput(k212_CommandClickOnDialogChoice_3,  16, 101, 138, 152, k1_LeftMouseButton), /* Lower left button */
+	MouseInput(k213_CommandClickOnDialogChoice_4, 123, 207, 138, 152, k1_LeftMouseButton), /* Lower right button */
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g475_PrimaryMouseInput_ScreenDialog1Choice[2] = { // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2]
+	MouseInput(k210_CommandClickOnDialogChoice_1, 63, 254, 138, 152, k1_LeftMouseButton), /* Bottom button */
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g476_PrimaryMouseInput_ScreenDialog2Choices[3] = { // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3]
+	MouseInput(k210_CommandClickOnDialogChoice_1, 63, 254, 101, 115, k1_LeftMouseButton), /* Top button */
+	MouseInput(k211_CommandClickOnDialogChoice_2, 63, 254, 138, 152, k1_LeftMouseButton), /* Bottom button */
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g477_PrimaryMouseInput_ScreenDialog3Choices[4] = { // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4]
+	MouseInput(k210_CommandClickOnDialogChoice_1,  63, 254, 101, 115, k1_LeftMouseButton), /* Top button */
+	MouseInput(k211_CommandClickOnDialogChoice_2,  63, 148, 138, 152, k1_LeftMouseButton), /* Lower left button */
+	MouseInput(k212_CommandClickOnDialogChoice_3, 170, 254, 138, 152, k1_LeftMouseButton), /* Lower right button */
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+MouseInput g478_PrimaryMouseInput_ScreenDialog4Choices[5] = { // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
+	MouseInput(k210_CommandClickOnDialogChoice_1,  63, 148, 101, 115, k1_LeftMouseButton), /* Top left button */
+	MouseInput(k211_CommandClickOnDialogChoice_2, 170, 254, 101, 115, k1_LeftMouseButton), /* Top right button */
+	MouseInput(k212_CommandClickOnDialogChoice_3,  63, 148, 138, 152, k1_LeftMouseButton), /* Lower left button */
+	MouseInput(k213_CommandClickOnDialogChoice_4, 170, 254, 138, 152, k1_LeftMouseButton), /* Lower right button */
+	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
+
+MouseInput* g480_PrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryMouseInput_DialogSets
+	{g471_PrimaryMouseInput_ViewportDialog1Choice,
+	g472_PrimaryMouseInput_ViewportDialog2Choices,
+	g473_PrimaryMouseInput_ViewportDialog3Choices,
+	g474_PrimaryMouseInput_ViewportDialog4Choices},
+	{g475_PrimaryMouseInput_ScreenDialog1Choice,
+	g476_PrimaryMouseInput_ScreenDialog2Choices,
+	g477_PrimaryMouseInput_ScreenDialog3Choices,
+	g478_PrimaryMouseInput_ScreenDialog4Choices},};
 
 
 EventManager::EventManager(DMEngine *vm) : _vm(vm) {
-	_primaryMouseInput = nullptr;
-	_secondaryMouseInput = nullptr;
+	_g441_primaryMouseInput = nullptr;
+	_g442_secondaryMouseInput = nullptr;
 
-	_pendingClickPresent = false;
-	_isCommandQueueLocked = true;
-	_mousePointerBitmapUpdated = false;
-	_refreshMousePointerInMainLoop = false;
-	_highlightBoxEnabled = false;
+	_g436_pendingClickPresent = false;
+	_g435_isCommandQueueLocked = true;
+	_g598_mousePointerBitmapUpdated = false;
+	_g326_refreshMousePointerInMainLoop = false;
+	_g341_highlightBoxEnabled = false;
 
 	_dummyMapIndex = 0;
-	_pendingClickButton = kNoneMouseButton;
+	_g439_pendingClickButton = k0_NoneMouseButton;
 }
 
 
@@ -350,9 +350,9 @@ void EventManager::processInput() {
 			break;
 		case Common::EVENT_LBUTTONDOWN:
 		case Common::EVENT_RBUTTONDOWN:
-			_pendingClickPresent = true;
-			_pendingClickPos = _mousePos;
-			_pendingClickButton = (event.type == Common::EVENT_LBUTTONDOWN) ? kLeftMouseButton : kRightMouseButton;
+			_g436_pendingClickPresent = true;
+			_g437_pendingClickPos = _mousePos;
+			_g439_pendingClickButton = (event.type == Common::EVENT_LBUTTONDOWN) ? k1_LeftMouseButton : k2_RightMouseButton;
 			break;
 		default:
 			break;
@@ -361,31 +361,31 @@ void EventManager::processInput() {
 }
 
 void EventManager::processPendingClick() {
-	if (_pendingClickPresent) {
-		_pendingClickPresent = false;
-		processClick(_pendingClickPos, _pendingClickButton);
+	if (_g436_pendingClickPresent) {
+		_g436_pendingClickPresent = false;
+		processClick(_g437_pendingClickPos, _g439_pendingClickButton);
 	}
 }
 
 void EventManager::processClick(Common::Point mousePos, MouseButton button) {
 	CommandType commandType;
 
-	commandType = getCommandTypeFromMouseInput(_primaryMouseInput, mousePos, button);
-	if (commandType == kCommandNone)
-		commandType = getCommandTypeFromMouseInput(_secondaryMouseInput, mousePos, button);
+	commandType = getCommandTypeFromMouseInput(_g441_primaryMouseInput, mousePos, button);
+	if (commandType == k0_CommandNone)
+		commandType = getCommandTypeFromMouseInput(_g442_secondaryMouseInput, mousePos, button);
 
-	if (commandType != kCommandNone)
+	if (commandType != k0_CommandNone)
 		_commandQueue.push(Command(mousePos, commandType));
 
-	_isCommandQueueLocked = false;
+	_g435_isCommandQueueLocked = false;
 }
 
 CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button) {
 	if (!input)
-		return kCommandNone;
-	CommandType commandType = kCommandNone;
+		return k0_CommandNone;
+	CommandType commandType = k0_CommandNone;
 
-	while ((commandType = input->_commandTypeToIssue) != kCommandNone) {
+	while ((commandType = input->_commandTypeToIssue) != k0_CommandNone) {
 		if (input->_hitbox.isPointInside(mousePos) && input->_button == button)
 			break;
 		input++;
@@ -395,9 +395,9 @@ CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common
 
 
 void EventManager::processCommandQueue() {
-	_isCommandQueueLocked = true;
+	_g435_isCommandQueueLocked = true;
 	if (_commandQueue.empty()) {
-		_isCommandQueueLocked = false;
+		_g435_isCommandQueueLocked = false;
 		processPendingClick();
 		return;
 	}
@@ -407,23 +407,23 @@ void EventManager::processCommandQueue() {
 	int16 commandX = cmd._pos.x;
 	int16 commandY = cmd._pos.y;
 
-	_isCommandQueueLocked = false;
+	_g435_isCommandQueueLocked = false;
 	processPendingClick();
 
-	if ((cmd._type == kCommandTurnRight) || (cmd._type == kCommandTurnLeft)) {
+	if ((cmd._type == k2_CommandTurnRight) || (cmd._type == k1_CommandTurnLeft)) {
 		commandTurnParty(cmd._type);
 		return;
 	}
 
-	if ((cmd._type >= kCommandMoveForward) && (cmd._type <= kCommandMoveLeft)) {
+	if ((cmd._type >= k3_CommandMoveForward) && (cmd._type <= k6_CommandMoveLeft)) {
 		commandMoveParty(cmd._type);
 		return;
 	}
 
-	if (cmd._type == kCommandClickInDungeonView) {
+	if (cmd._type == k80_CommandClickInDungeonView) {
 		commandProcessType80ClickInDungeonView(commandX, commandY);
 	}
-	if (cmd._type == kCommandClickInPanel) {
+	if (cmd._type == k81_CommandClickInPanel) {
 		commandProcess81ClickInPanel(commandX, commandY);
 	}
 
@@ -441,7 +441,7 @@ void EventManager::commandTurnParty(CommandType cmdType) {
 
 	// DUMMY CODE: should call F0284_CHAMPION_SetPartyDirection instead
 	direction &partyDir = _vm->_dungeonMan->_currMap._g308_partyDir;
-	(cmdType == kCommandTurnLeft) ? turnDirLeft(partyDir) : turnDirRight(partyDir);
+	(cmdType == k1_CommandTurnLeft) ? turnDirLeft(partyDir) : turnDirRight(partyDir);
 
 	// MISSING CODE: process sensors
 }
@@ -456,16 +456,16 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 	CurrMapData &currMap = dungeonMan._currMap;
 
 	switch (cmdType) {
-	case kCommandMoveForward:
+	case k3_CommandMoveForward:
 		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY);
 		break;
-	case kCommandMoveLeft:
+	case k6_CommandMoveLeft:
 		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, -1, currMap._g306_partyPosX, currMap._g307_partyPosY);
 		break;
-	case kCommandMoveBackward:
+	case k5_CommandMoveBackward:
 		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, -1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY);
 		break;
-	case kCommandMoveRight:
+	case k4_CommandMoveRight:
 		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, 1, currMap._g306_partyPosX, currMap._g307_partyPosY);
 		break;
 	default:
@@ -558,7 +558,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 		uint16 *rawThingPointer = dunMan.getThingData(thing);
 		if (dunMan._g285_squareAheadElement == k0_ElementTypeWall) {
 			for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k1_ViewCellFrontRight; ++viewCell) {
-				if (gBoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) {
+				if (g462_BoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) {
 					warning("F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject");
 					return;
 				}
@@ -588,7 +588,7 @@ T0377019:
 		} else {
 			warning("MISSING CODE: F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown in if branch");
 			for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k3_ViewCellBackLeft; viewCell++) {
-				if (gBoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) {
+				if (g462_BoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) {
 					warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject");
 					return;
 				}
@@ -606,7 +606,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 
 	uint16 championIndex = champMan._g305_partyChampionCount - 1;
 	Champion *champ = &champMan._champions[championIndex];
-	if (commandType == kCommandClickInPanelCancel) {
+	if (commandType == k162_CommandClickInPanelCancel) {
 		invMan.toggleInventory(k4_ChampionCloseInventory);
 		champMan._g299_candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 		if (champMan._g305_partyChampionCount == 1) {
@@ -645,7 +645,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 		thing = dunMan.getNextThing(thing);
 	}
 
-	if (commandType == kCommandClickInPanelReincarnate) {
+	if (commandType == k161_CommandClickInPanelReincarnate) {
 		champMan.renameChampion(champ);
 		champ->resetSkillsToZero();
 
@@ -683,15 +683,15 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) {
 	case kPanelContentChest:
 		if (champMan._g411_leaderIndex == kM1_ChampionNone) // if no leader
 			return;
-		commandType = getCommandTypeFromMouseInput(gMouseInput_PanelChest, Common::Point(x, y), kLeftMouseButton);
-		if (commandType != kCommandNone)
+		commandType = getCommandTypeFromMouseInput(g456_MouseInput_PanelChest, Common::Point(x, y), k1_LeftMouseButton);
+		if (commandType != k0_CommandNone)
 			warning("MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox");
 		break;
 	case kPanelContentResurrectReincarnate:
 		if (!champMan._g415_leaderEmptyHanded)
 			break;
-		commandType = getCommandTypeFromMouseInput(gMouseInput_PanelResurrectReincarnateCancel, Common::Point(x, y), kLeftMouseButton);
-		if (commandType != kCommandNone)
+		commandType = getCommandTypeFromMouseInput(g457_MouseInput_PanelResurrectReincarnateCancel, Common::Point(x, y), k1_LeftMouseButton);
+		if (commandType != k0_CommandNone)
 			commandProcessCommands160To162ClickInResurrectReincarnatePanel(commandType);
 		break;
 	default:
@@ -700,10 +700,10 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) {
 }
 
 bool EventManager::hasPendingClick(Common::Point& point, MouseButton button) {
-	if (_pendingClickButton && button == _pendingClickButton)
-		point = _pendingClickPos;
+	if (_g439_pendingClickButton && button == _g439_pendingClickButton)
+		point = _g437_pendingClickPos;
 
-	return _pendingClickPresent;
+	return _g436_pendingClickPresent;
 }
 
 } // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index ca60c46..35f8bd6 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -41,121 +41,121 @@ namespace DM {
 
 
 enum MouseButton {
-	kNoneMouseButton = 0, // present only because of typesafety
-	kLeftMouseButton = 1,
-	kRightMouseButton = 2
+	k0_NoneMouseButton = 0, // present only because of typesafety
+	k1_LeftMouseButton = 1,
+	k2_RightMouseButton = 2
 };
 
 enum CommandType {
-	kCommandNone = 0, // @ C000_COMMAND_NONE
-	kCommandTurnLeft = 1, // @ C001_COMMAND_TURN_LEFT
-	kCommandTurnRight = 2, // @ C002_COMMAND_TURN_RIGHT
-	kCommandMoveForward = 3, // @ C003_COMMAND_MOVE_FORWARD
-	kCommandMoveRight = 4, // @ C004_COMMAND_MOVE_RIGHT
-	kCommandMoveBackward = 5, // @ C005_COMMAND_MOVE_BACKWARD
-	kCommandMoveLeft = 6, // @ C006_COMMAND_MOVE_LEFT
-	kCommandToggleInventoryChampion_0 = 7, // @ C007_COMMAND_TOGGLE_INVENTORY_CHAMPION_0
-	kCommandToggleInventoryChampion_1 = 8, // @ C008_COMMAND_TOGGLE_INVENTORY_CHAMPION_1
-	kCommandToggleInventoryChampion_2 = 9, // @ C009_COMMAND_TOGGLE_INVENTORY_CHAMPION_2
-	kCommandToggleInventoryChampion_3 = 10, // @ C010_COMMAND_TOGGLE_INVENTORY_CHAMPION_3
-	kCommandCloseInventory = 11, // @ C011_COMMAND_CLOSE_INVENTORY
-	kCommandClickInChampion_0_StatusBox = 12, // @ C012_COMMAND_CLICK_IN_CHAMPION_0_STATUS_BOX
-	kCommandClickInChampion_1_StatusBox = 13, // @ C013_COMMAND_CLICK_IN_CHAMPION_1_STATUS_BOX
-	kCommandClickInChampion_2_StatusBox = 14, // @ C014_COMMAND_CLICK_IN_CHAMPION_2_STATUS_BOX
-	kCommandClickInChampion_3_StatusBox = 15, // @ C015_COMMAND_CLICK_IN_CHAMPION_3_STATUS_BOX
-	kCommandSetLeaderChampion_0 = 16, // @ C016_COMMAND_SET_LEADER_CHAMPION_0
-	kCommandSetLeaderChampion_1 = 17, // @ C017_COMMAND_SET_LEADER_CHAMPION_1
-	kCommandSetLeaderChampion_2 = 18, // @ C018_COMMAND_SET_LEADER_CHAMPION_2
-	kCommandSetLeaderChampion_3 = 19, // @ C019_COMMAND_SET_LEADER_CHAMPION_3
-	kCommandClickOnSlotBoxChampion_0_StatusBoxReadyHand = 20, // @ C020_COMMAND_CLICK_ON_SLOT_BOX_00_CHAMPION_0_STATUS_BOX_READY_HAND
-	kCommandClickOnSlotBoxChampion_0_StatusBoxActionHand = 21, // @ C021_COMMAND_CLICK_ON_SLOT_BOX_01_CHAMPION_0_STATUS_BOX_ACTION_HAND
-	kCommandClickOnSlotBoxChampion_1_StatusBoxReadyHand = 22, // @ C022_COMMAND_CLICK_ON_SLOT_BOX_02_CHAMPION_1_STATUS_BOX_READY_HAND
-	kCommandClickOnSlotBoxChampion_1_StatusBoxActionHand = 23, // @ C023_COMMAND_CLICK_ON_SLOT_BOX_03_CHAMPION_1_STATUS_BOX_ACTION_HAND
-	kCommandClickOnSlotBoxChampion_2_StatusBoxReadyHand = 24, // @ C024_COMMAND_CLICK_ON_SLOT_BOX_04_CHAMPION_2_STATUS_BOX_READY_HAND
-	kCommandClickOnSlotBoxChampion_2_StatusBoxActionHand = 25, // @ C025_COMMAND_CLICK_ON_SLOT_BOX_05_CHAMPION_2_STATUS_BOX_ACTION_HAND
-	kCommandClickOnSlotBoxChampion_3_StatusBoxReadyHand = 26, // @ C026_COMMAND_CLICK_ON_SLOT_BOX_06_CHAMPION_3_STATUS_BOX_READY_HAND
-	kCommandClickOnSlotBoxChampion_3_StatusBoxActionHand = 27, // @ C027_COMMAND_CLICK_ON_SLOT_BOX_07_CHAMPION_3_STATUS_BOX_ACTION_HAND
-	kCommandClickOnSlotBoxInventoryReadyHand = 28, // @ C028_COMMAND_CLICK_ON_SLOT_BOX_08_INVENTORY_READY_HAND
-	kCommandClickOnSlotBoxInventoryActionHand = 29, // @ C029_COMMAND_CLICK_ON_SLOT_BOX_09_INVENTORY_ACTION_HAND
-	kCommandClickOnSlotBoxInventoryHead = 30, // @ C030_COMMAND_CLICK_ON_SLOT_BOX_10_INVENTORY_HEAD
-	kCommandClickOnSlotBoxInventoryTorso = 31, // @ C031_COMMAND_CLICK_ON_SLOT_BOX_11_INVENTORY_TORSO
-	kCommandClickOnSlotBoxInventoryLegs = 32, // @ C032_COMMAND_CLICK_ON_SLOT_BOX_12_INVENTORY_LEGS
-	kCommandClickOnSlotBoxInventoryFeet = 33, // @ C033_COMMAND_CLICK_ON_SLOT_BOX_13_INVENTORY_FEET
-	kCommandClickOnSlotBoxInventoryPouch_2 = 34, // @ C034_COMMAND_CLICK_ON_SLOT_BOX_14_INVENTORY_POUCH_2
-	kCommandClickOnSlotBoxInventoryQuiverLine_2_1 = 35, // @ C035_COMMAND_CLICK_ON_SLOT_BOX_15_INVENTORY_QUIVER_LINE2_1
-	kCommandClickOnSlotBoxInventoryQuiverLine_1_2 = 36, // @ C036_COMMAND_CLICK_ON_SLOT_BOX_16_INVENTORY_QUIVER_LINE1_2
-	kCommandClickOnSlotBoxInventoryQuiverLine_2_2 = 37, // @ C037_COMMAND_CLICK_ON_SLOT_BOX_17_INVENTORY_QUIVER_LINE2_2
-	kCommandClickOnSlotBoxInventoryNeck = 38, // @ C038_COMMAND_CLICK_ON_SLOT_BOX_18_INVENTORY_NECK
-	kCommandClickOnSlotBoxInventoryPouch_1 = 39, // @ C039_COMMAND_CLICK_ON_SLOT_BOX_19_INVENTORY_POUCH_1
-	kCommandClickOnSlotBoxInventoryQuiverLine_1_1 = 40, // @ C040_COMMAND_CLICK_ON_SLOT_BOX_20_INVENTORY_QUIVER_LINE1_1
-	kCommandClickOnSlotBoxInventoryBackpackLine_1_1 = 41, // @ C041_COMMAND_CLICK_ON_SLOT_BOX_21_INVENTORY_BACKPACK_LINE1_1
-	kCommandClickOnSlotBoxInventoryBackpackLine_2_2 = 42, // @ C042_COMMAND_CLICK_ON_SLOT_BOX_22_INVENTORY_BACKPACK_LINE2_2
-	kCommandClickOnSlotBoxInventoryBackpackLine_2_3 = 43, // @ C043_COMMAND_CLICK_ON_SLOT_BOX_23_INVENTORY_BACKPACK_LINE2_3
-	kCommandClickOnSlotBoxInventoryBackpackLine_2_4 = 44, // @ C044_COMMAND_CLICK_ON_SLOT_BOX_24_INVENTORY_BACKPACK_LINE2_4
-	kCommandClickOnSlotBoxInventoryBackpackLine_2_5 = 45, // @ C045_COMMAND_CLICK_ON_SLOT_BOX_25_INVENTORY_BACKPACK_LINE2_5
-	kCommandClickOnSlotBoxInventoryBackpackLine_2_6 = 46, // @ C046_COMMAND_CLICK_ON_SLOT_BOX_26_INVENTORY_BACKPACK_LINE2_6
-	kCommandClickOnSlotBoxInventoryBackpackLine_2_7 = 47, // @ C047_COMMAND_CLICK_ON_SLOT_BOX_27_INVENTORY_BACKPACK_LINE2_7
-	kCommandClickOnSlotBoxInventoryBackpackLine_2_8 = 48, // @ C048_COMMAND_CLICK_ON_SLOT_BOX_28_INVENTORY_BACKPACK_LINE2_8
-	kCommandClickOnSlotBoxInventoryBackpackLine_2_9 = 49, // @ C049_COMMAND_CLICK_ON_SLOT_BOX_29_INVENTORY_BACKPACK_LINE2_9
-	kCommandClickOnSlotBoxInventoryBackpackLine_1_2 = 50, // @ C050_COMMAND_CLICK_ON_SLOT_BOX_30_INVENTORY_BACKPACK_LINE1_2
-	kCommandClickOnSlotBoxInventoryBackpackLine_1_3 = 51, // @ C051_COMMAND_CLICK_ON_SLOT_BOX_31_INVENTORY_BACKPACK_LINE1_3
-	kCommandClickOnSlotBoxInventoryBackpackLine_1_4 = 52, // @ C052_COMMAND_CLICK_ON_SLOT_BOX_32_INVENTORY_BACKPACK_LINE1_4
-	kCommandClickOnSlotBoxInventoryBackpackLine_1_5 = 53, // @ C053_COMMAND_CLICK_ON_SLOT_BOX_33_INVENTORY_BACKPACK_LINE1_5
-	kCommandClickOnSlotBoxInventoryBackpackLine_1_6 = 54, // @ C054_COMMAND_CLICK_ON_SLOT_BOX_34_INVENTORY_BACKPACK_LINE1_6
-	kCommandClickOnSlotBoxInventoryBackpackLine_1_7 = 55, // @ C055_COMMAND_CLICK_ON_SLOT_BOX_35_INVENTORY_BACKPACK_LINE1_7
-	kCommandClickOnSlotBoxInventoryBackpackLine_1_8 = 56, // @ C056_COMMAND_CLICK_ON_SLOT_BOX_36_INVENTORY_BACKPACK_LINE1_8
-	kCommandClickOnSlotBoxInventoryBackpackLine_1_9 = 57, // @ C057_COMMAND_CLICK_ON_SLOT_BOX_37_INVENTORY_BACKPACK_LINE1_9
-	kCommandClickOnSlotBoxChest_1 = 58, // @ C058_COMMAND_CLICK_ON_SLOT_BOX_38_CHEST_1
-	kCommandClickOnSlotBoxChest_2 = 59, // @ C059_COMMAND_CLICK_ON_SLOT_BOX_39_CHEST_2
-	kCommandClickOnSlotBoxChest_3 = 60, // @ C060_COMMAND_CLICK_ON_SLOT_BOX_40_CHEST_3
-	kCommandClickOnSlotBoxChest_4 = 61, // @ C061_COMMAND_CLICK_ON_SLOT_BOX_41_CHEST_4
-	kCommandClickOnSlotBoxChest_5 = 62, // @ C062_COMMAND_CLICK_ON_SLOT_BOX_42_CHEST_5
-	kCommandClickOnSlotBoxChest_6 = 63, // @ C063_COMMAND_CLICK_ON_SLOT_BOX_43_CHEST_6
-	kCommandClickOnSlotBoxChest_7 = 64, // @ C064_COMMAND_CLICK_ON_SLOT_BOX_44_CHEST_7
-	kCommandClickOnSlotBoxChest_8 = 65, // @ C065_COMMAND_CLICK_ON_SLOT_BOX_45_CHEST_8
-	kCommandClickOnMouth = 70, // @ C070_COMMAND_CLICK_ON_MOUTH
-	kCommandClickOnEye = 71, // @ C071_COMMAND_CLICK_ON_EYE
-	kCommandClickInDungeonView = 80, // @ C080_COMMAND_CLICK_IN_DUNGEON_VIEW
-	kCommandClickInPanel = 81, // @ C081_COMMAND_CLICK_IN_PANEL
-	kCommandToggleInventoryLeader = 83, // @ C083_COMMAND_TOGGLE_INVENTORY_LEADER
-	kCommandClickInSpellArea = 100, // @ C100_COMMAND_CLICK_IN_SPELL_AREA
-	kCommandClickInSpellAreaSymbol_1 = 101, // @ C101_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_1
-	kCommandClickInSpellAreaSymbol_2 = 102, // @ C102_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_2
-	kCommandClickInSpellAreaSymbol_3 = 103, // @ C103_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_3
-	kCommandClickInSpellAreaSymbol_4 = 104, // @ C104_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_4
-	kCommandClickInSpellAreaSymbol_5 = 105, // @ C105_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_5
-	kCommandClickInSpellAreaSymbol_6 = 106, // @ C106_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_6
-	kCommandClickInSpellAreaRecantSymbol = 107, // @ C107_COMMAND_CLICK_IN_SPELL_AREA_RECANT_SYMBOL
-	kCommandClickInSpeallAreaCastSpell = 108, // @ C108_COMMAND_CLICK_IN_SPELL_AREA_CAST_SPELL
-	kCommandClickInActionArea = 111, // @ C111_COMMAND_CLICK_IN_ACTION_AREA
-	kCommandClickInActionAreaPass = 112, // @ C112_COMMAND_CLICK_IN_ACTION_AREA_PASS
-	kCommandClickInActionAreaAction_0 = 113, // @ C113_COMMAND_CLICK_IN_ACTION_AREA_ACTION_0
-	kCommandClickInActionAreaAction_1 = 114, // @ C114_COMMAND_CLICK_IN_ACTION_AREA_ACTION_1
-	kCommandClickInActionAreaAction_2 = 115, // @ C115_COMMAND_CLICK_IN_ACTION_AREA_ACTION_2
-	kCommandClickInActionAreaChampion_0_Action = 116, // @ C116_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_0_ACTION
-	kCommandClickInActionAreaChampion_1_Action = 117, // @ C117_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_1_ACTION
-	kCommandClickInActionAreaChampion_2_Action = 118, // @ C118_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_2_ACTION
-	kCommandClickInActionAreaChampion_3_Action = 119, // @ C119_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_3_ACTION
-	kCommandClickOnChamptionIcon_Top_Left = 125, // @ C125_COMMAND_CLICK_ON_CHAMPION_ICON_TOP_LEFT
-	kCommandClickOnChamptionIcon_Top_Right = 126, // @ C126_COMMAND_CLICK_ON_CHAMPION_ICON_TOP_RIGHT
-	kCommandClickOnChamptionIcon_Lower_Right = 127, // @ C127_COMMAND_CLICK_ON_CHAMPION_ICON_LOWER_RIGHT
-	kCommandClickOnChamptionIcon_Lower_Left = 128, // @ C128_COMMAND_CLICK_ON_CHAMPION_ICON_LOWER_LEFT
-	kCommandSaveGame = 140, // @ C140_COMMAND_SAVE_GAME
-	kCommandSleep = 145, // @ C145_COMMAND_SLEEP
-	kCommandWakeUp = 146, // @ C146_COMMAND_WAKE_UP
-	kCommandFreezeGame = 147, // @ C147_COMMAND_FREEZE_GAME
-	kCommandUnfreezeGame = 148, // @ C148_COMMAND_UNFREEZE_GAME
-	kCommandClickInPanelResurrect = 160, // @ C160_COMMAND_CLICK_IN_PANEL_RESURRECT
-	kCommandClickInPanelReincarnate = 161, // @ C161_COMMAND_CLICK_IN_PANEL_REINCARNATE
-	kCommandClickInPanelCancel = 162, // @ C162_COMMAND_CLICK_IN_PANEL_CANCEL
-	kCommandEntranceEnterDungeon = 200, // @ C200_COMMAND_ENTRANCE_ENTER_DUNGEON
-	kCommandEntranceResume = 201, // @ C201_COMMAND_ENTRANCE_RESUME /* Versions 1.x and 2.x command */
-	kCommandEntranceDrawCredits = 202, // @ C202_COMMAND_ENTRANCE_DRAW_CREDITS /* Versions 1.x and 2.x command */
-	kCommandClickOnDialogChoice_1 = 210, // @ C210_COMMAND_CLICK_ON_DIALOG_CHOICE_1
-	kCommandClickOnDialogChoice_2 = 211, // @ C211_COMMAND_CLICK_ON_DIALOG_CHOICE_2
-	kCommandClickOnDialogChoice_3 = 212, // @ C212_COMMAND_CLICK_ON_DIALOG_CHOICE_3
-	kCommandClickOnDialogChoice_4 = 213, // @ C213_COMMAND_CLICK_ON_DIALOG_CHOICE_4
-	kCommandRestartGame = 215 // @ C215_COMMAND_RESTART_GAME
+	k0_CommandNone = 0, // @ C000_COMMAND_NONE
+	k1_CommandTurnLeft = 1, // @ C001_COMMAND_TURN_LEFT
+	k2_CommandTurnRight = 2, // @ C002_COMMAND_TURN_RIGHT
+	k3_CommandMoveForward = 3, // @ C003_COMMAND_MOVE_FORWARD
+	k4_CommandMoveRight = 4, // @ C004_COMMAND_MOVE_RIGHT
+	k5_CommandMoveBackward = 5, // @ C005_COMMAND_MOVE_BACKWARD
+	k6_CommandMoveLeft = 6, // @ C006_COMMAND_MOVE_LEFT
+	k7_CommandToggleInventoryChampion_0 = 7, // @ C007_COMMAND_TOGGLE_INVENTORY_CHAMPION_0
+	k8_CommandToggleInventoryChampion_1 = 8, // @ C008_COMMAND_TOGGLE_INVENTORY_CHAMPION_1
+	k9_CommandToggleInventoryChampion_2 = 9, // @ C009_COMMAND_TOGGLE_INVENTORY_CHAMPION_2
+	k10_CommandToggleInventoryChampion_3 = 10, // @ C010_COMMAND_TOGGLE_INVENTORY_CHAMPION_3
+	k11_CommandCloseInventory = 11, // @ C011_COMMAND_CLOSE_INVENTORY
+	k12_CommandClickInChampion_0_StatusBox = 12, // @ C012_COMMAND_CLICK_IN_CHAMPION_0_STATUS_BOX
+	k13_CommandClickInChampion_1_StatusBox = 13, // @ C013_COMMAND_CLICK_IN_CHAMPION_1_STATUS_BOX
+	k14_CommandClickInChampion_2_StatusBox = 14, // @ C014_COMMAND_CLICK_IN_CHAMPION_2_STATUS_BOX
+	k15_CommandClickInChampion_3_StatusBox = 15, // @ C015_COMMAND_CLICK_IN_CHAMPION_3_STATUS_BOX
+	k16_CommandSetLeaderChampion_0 = 16, // @ C016_COMMAND_SET_LEADER_CHAMPION_0
+	k17_CommandSetLeaderChampion_1 = 17, // @ C017_COMMAND_SET_LEADER_CHAMPION_1
+	k18_CommandSetLeaderChampion_2 = 18, // @ C018_COMMAND_SET_LEADER_CHAMPION_2
+	k19_CommandSetLeaderChampion_3 = 19, // @ C019_COMMAND_SET_LEADER_CHAMPION_3
+	k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand = 20, // @ C020_COMMAND_CLICK_ON_SLOT_BOX_00_CHAMPION_0_STATUS_BOX_READY_HAND
+	k21_CommandClickOnSlotBoxChampion_0_StatusBoxActionHand = 21, // @ C021_COMMAND_CLICK_ON_SLOT_BOX_01_CHAMPION_0_STATUS_BOX_ACTION_HAND
+	k22_CommandClickOnSlotBoxChampion_1_StatusBoxReadyHand = 22, // @ C022_COMMAND_CLICK_ON_SLOT_BOX_02_CHAMPION_1_STATUS_BOX_READY_HAND
+	k23_CommandClickOnSlotBoxChampion_1_StatusBoxActionHand = 23, // @ C023_COMMAND_CLICK_ON_SLOT_BOX_03_CHAMPION_1_STATUS_BOX_ACTION_HAND
+	k24_CommandClickOnSlotBoxChampion_2_StatusBoxReadyHand = 24, // @ C024_COMMAND_CLICK_ON_SLOT_BOX_04_CHAMPION_2_STATUS_BOX_READY_HAND
+	k25_CommandClickOnSlotBoxChampion_2_StatusBoxActionHand = 25, // @ C025_COMMAND_CLICK_ON_SLOT_BOX_05_CHAMPION_2_STATUS_BOX_ACTION_HAND
+	k26_CommandClickOnSlotBoxChampion_3_StatusBoxReadyHand = 26, // @ C026_COMMAND_CLICK_ON_SLOT_BOX_06_CHAMPION_3_STATUS_BOX_READY_HAND
+	k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand = 27, // @ C027_COMMAND_CLICK_ON_SLOT_BOX_07_CHAMPION_3_STATUS_BOX_ACTION_HAND
+	k28_CommandClickOnSlotBoxInventoryReadyHand = 28, // @ C028_COMMAND_CLICK_ON_SLOT_BOX_08_INVENTORY_READY_HAND
+	k29_CommandClickOnSlotBoxInventoryActionHand = 29, // @ C029_COMMAND_CLICK_ON_SLOT_BOX_09_INVENTORY_ACTION_HAND
+	k30_CommandClickOnSlotBoxInventoryHead = 30, // @ C030_COMMAND_CLICK_ON_SLOT_BOX_10_INVENTORY_HEAD
+	k31_CommandClickOnSlotBoxInventoryTorso = 31, // @ C031_COMMAND_CLICK_ON_SLOT_BOX_11_INVENTORY_TORSO
+	k32_CommandClickOnSlotBoxInventoryLegs = 32, // @ C032_COMMAND_CLICK_ON_SLOT_BOX_12_INVENTORY_LEGS
+	k33_CommandClickOnSlotBoxInventoryFeet = 33, // @ C033_COMMAND_CLICK_ON_SLOT_BOX_13_INVENTORY_FEET
+	k34_CommandClickOnSlotBoxInventoryPouch_2 = 34, // @ C034_COMMAND_CLICK_ON_SLOT_BOX_14_INVENTORY_POUCH_2
+	k35_CommandClickOnSlotBoxInventoryQuiverLine_2_1 = 35, // @ C035_COMMAND_CLICK_ON_SLOT_BOX_15_INVENTORY_QUIVER_LINE2_1
+	k36_CommandClickOnSlotBoxInventoryQuiverLine_1_2 = 36, // @ C036_COMMAND_CLICK_ON_SLOT_BOX_16_INVENTORY_QUIVER_LINE1_2
+	k37_CommandClickOnSlotBoxInventoryQuiverLine_2_2 = 37, // @ C037_COMMAND_CLICK_ON_SLOT_BOX_17_INVENTORY_QUIVER_LINE2_2
+	k38_CommandClickOnSlotBoxInventoryNeck = 38, // @ C038_COMMAND_CLICK_ON_SLOT_BOX_18_INVENTORY_NECK
+	k39_CommandClickOnSlotBoxInventoryPouch_1 = 39, // @ C039_COMMAND_CLICK_ON_SLOT_BOX_19_INVENTORY_POUCH_1
+	k40_CommandClickOnSlotBoxInventoryQuiverLine_1_1 = 40, // @ C040_COMMAND_CLICK_ON_SLOT_BOX_20_INVENTORY_QUIVER_LINE1_1
+	k41_CommandClickOnSlotBoxInventoryBackpackLine_1_1 = 41, // @ C041_COMMAND_CLICK_ON_SLOT_BOX_21_INVENTORY_BACKPACK_LINE1_1
+	k42_CommandClickOnSlotBoxInventoryBackpackLine_2_2 = 42, // @ C042_COMMAND_CLICK_ON_SLOT_BOX_22_INVENTORY_BACKPACK_LINE2_2
+	k43_CommandClickOnSlotBoxInventoryBackpackLine_2_3 = 43, // @ C043_COMMAND_CLICK_ON_SLOT_BOX_23_INVENTORY_BACKPACK_LINE2_3
+	k44_CommandClickOnSlotBoxInventoryBackpackLine_2_4 = 44, // @ C044_COMMAND_CLICK_ON_SLOT_BOX_24_INVENTORY_BACKPACK_LINE2_4
+	k45_CommandClickOnSlotBoxInventoryBackpackLine_2_5 = 45, // @ C045_COMMAND_CLICK_ON_SLOT_BOX_25_INVENTORY_BACKPACK_LINE2_5
+	k46_CommandClickOnSlotBoxInventoryBackpackLine_2_6 = 46, // @ C046_COMMAND_CLICK_ON_SLOT_BOX_26_INVENTORY_BACKPACK_LINE2_6
+	k47_CommandClickOnSlotBoxInventoryBackpackLine_2_7 = 47, // @ C047_COMMAND_CLICK_ON_SLOT_BOX_27_INVENTORY_BACKPACK_LINE2_7
+	k48_CommandClickOnSlotBoxInventoryBackpackLine_2_8 = 48, // @ C048_COMMAND_CLICK_ON_SLOT_BOX_28_INVENTORY_BACKPACK_LINE2_8
+	k49_CommandClickOnSlotBoxInventoryBackpackLine_2_9 = 49, // @ C049_COMMAND_CLICK_ON_SLOT_BOX_29_INVENTORY_BACKPACK_LINE2_9
+	k50_CommandClickOnSlotBoxInventoryBackpackLine_1_2 = 50, // @ C050_COMMAND_CLICK_ON_SLOT_BOX_30_INVENTORY_BACKPACK_LINE1_2
+	k51_CommandClickOnSlotBoxInventoryBackpackLine_1_3 = 51, // @ C051_COMMAND_CLICK_ON_SLOT_BOX_31_INVENTORY_BACKPACK_LINE1_3
+	k52_CommandClickOnSlotBoxInventoryBackpackLine_1_4 = 52, // @ C052_COMMAND_CLICK_ON_SLOT_BOX_32_INVENTORY_BACKPACK_LINE1_4
+	k53_CommandClickOnSlotBoxInventoryBackpackLine_1_5 = 53, // @ C053_COMMAND_CLICK_ON_SLOT_BOX_33_INVENTORY_BACKPACK_LINE1_5
+	k54_CommandClickOnSlotBoxInventoryBackpackLine_1_6 = 54, // @ C054_COMMAND_CLICK_ON_SLOT_BOX_34_INVENTORY_BACKPACK_LINE1_6
+	k55_CommandClickOnSlotBoxInventoryBackpackLine_1_7 = 55, // @ C055_COMMAND_CLICK_ON_SLOT_BOX_35_INVENTORY_BACKPACK_LINE1_7
+	k56_CommandClickOnSlotBoxInventoryBackpackLine_1_8 = 56, // @ C056_COMMAND_CLICK_ON_SLOT_BOX_36_INVENTORY_BACKPACK_LINE1_8
+	k57_CommandClickOnSlotBoxInventoryBackpackLine_1_9 = 57, // @ C057_COMMAND_CLICK_ON_SLOT_BOX_37_INVENTORY_BACKPACK_LINE1_9
+	k58_CommandClickOnSlotBoxChest_1 = 58, // @ C058_COMMAND_CLICK_ON_SLOT_BOX_38_CHEST_1
+	k59_CommandClickOnSlotBoxChest_2 = 59, // @ C059_COMMAND_CLICK_ON_SLOT_BOX_39_CHEST_2
+	k60_CommandClickOnSlotBoxChest_3 = 60, // @ C060_COMMAND_CLICK_ON_SLOT_BOX_40_CHEST_3
+	k61_CommandClickOnSlotBoxChest_4 = 61, // @ C061_COMMAND_CLICK_ON_SLOT_BOX_41_CHEST_4
+	k62_CommandClickOnSlotBoxChest_5 = 62, // @ C062_COMMAND_CLICK_ON_SLOT_BOX_42_CHEST_5
+	k63_CommandClickOnSlotBoxChest_6 = 63, // @ C063_COMMAND_CLICK_ON_SLOT_BOX_43_CHEST_6
+	k64_CommandClickOnSlotBoxChest_7 = 64, // @ C064_COMMAND_CLICK_ON_SLOT_BOX_44_CHEST_7
+	k65_CommandClickOnSlotBoxChest_8 = 65, // @ C065_COMMAND_CLICK_ON_SLOT_BOX_45_CHEST_8
+	k70_CommandClickOnMouth = 70, // @ C070_COMMAND_CLICK_ON_MOUTH
+	k71_CommandClickOnEye = 71, // @ C071_COMMAND_CLICK_ON_EYE
+	k80_CommandClickInDungeonView = 80, // @ C080_COMMAND_CLICK_IN_DUNGEON_VIEW
+	k81_CommandClickInPanel = 81, // @ C081_COMMAND_CLICK_IN_PANEL
+	k83_CommandToggleInventoryLeader = 83, // @ C083_COMMAND_TOGGLE_INVENTORY_LEADER
+	k100_CommandClickInSpellArea = 100, // @ C100_COMMAND_CLICK_IN_SPELL_AREA
+	k101_CommandClickInSpellAreaSymbol_1 = 101, // @ C101_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_1
+	k102_CommandClickInSpellAreaSymbol_2 = 102, // @ C102_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_2
+	k103_CommandClickInSpellAreaSymbol_3 = 103, // @ C103_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_3
+	k104_CommandClickInSpellAreaSymbol_4 = 104, // @ C104_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_4
+	k105_CommandClickInSpellAreaSymbol_5 = 105, // @ C105_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_5
+	k106_CommandClickInSpellAreaSymbol_6 = 106, // @ C106_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_6
+	k107_CommandClickInSpellAreaRecantSymbol = 107, // @ C107_COMMAND_CLICK_IN_SPELL_AREA_RECANT_SYMBOL
+	k108_CommandClickInSpeallAreaCastSpell = 108, // @ C108_COMMAND_CLICK_IN_SPELL_AREA_CAST_SPELL
+	k111_CommandClickInActionArea = 111, // @ C111_COMMAND_CLICK_IN_ACTION_AREA
+	k112_CommandClickInActionAreaPass = 112, // @ C112_COMMAND_CLICK_IN_ACTION_AREA_PASS
+	k113_CommandClickInActionAreaAction_0 = 113, // @ C113_COMMAND_CLICK_IN_ACTION_AREA_ACTION_0
+	k114_CommandClickInActionAreaAction_1 = 114, // @ C114_COMMAND_CLICK_IN_ACTION_AREA_ACTION_1
+	k115_CommandClickInActionAreaAction_2 = 115, // @ C115_COMMAND_CLICK_IN_ACTION_AREA_ACTION_2
+	k116_CommandClickInActionAreaChampion_0_Action = 116, // @ C116_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_0_ACTION
+	k117_CommandClickInActionAreaChampion_1_Action = 117, // @ C117_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_1_ACTION
+	k118_CommandClickInActionAreaChampion_2_Action = 118, // @ C118_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_2_ACTION
+	k119_CommandClickInActionAreaChampion_3_Action = 119, // @ C119_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_3_ACTION
+	k125_CommandClickOnChamptionIcon_Top_Left = 125, // @ C125_COMMAND_CLICK_ON_CHAMPION_ICON_TOP_LEFT
+	k126_CommandClickOnChamptionIcon_Top_Right = 126, // @ C126_COMMAND_CLICK_ON_CHAMPION_ICON_TOP_RIGHT
+	k127_CommandClickOnChamptionIcon_Lower_Right = 127, // @ C127_COMMAND_CLICK_ON_CHAMPION_ICON_LOWER_RIGHT
+	k128_CommandClickOnChamptionIcon_Lower_Left = 128, // @ C128_COMMAND_CLICK_ON_CHAMPION_ICON_LOWER_LEFT
+	k140_CommandSaveGame = 140, // @ C140_COMMAND_SAVE_GAME
+	k145_CommandSleep = 145, // @ C145_COMMAND_SLEEP
+	k146_CommandWakeUp = 146, // @ C146_COMMAND_WAKE_UP
+	k147_CommandFreezeGame = 147, // @ C147_COMMAND_FREEZE_GAME
+	k148_CommandUnfreezeGame = 148, // @ C148_COMMAND_UNFREEZE_GAME
+	k160_CommandClickInPanelResurrect = 160, // @ C160_COMMAND_CLICK_IN_PANEL_RESURRECT
+	k161_CommandClickInPanelReincarnate = 161, // @ C161_COMMAND_CLICK_IN_PANEL_REINCARNATE
+	k162_CommandClickInPanelCancel = 162, // @ C162_COMMAND_CLICK_IN_PANEL_CANCEL
+	k200_CommandEntranceEnterDungeon = 200, // @ C200_COMMAND_ENTRANCE_ENTER_DUNGEON
+	k201_CommandEntranceResume = 201, // @ C201_COMMAND_ENTRANCE_RESUME /* Versions 1.x and 2.x command */
+	k202_CommandEntranceDrawCredits = 202, // @ C202_COMMAND_ENTRANCE_DRAW_CREDITS /* Versions 1.x and 2.x command */
+	k210_CommandClickOnDialogChoice_1 = 210, // @ C210_COMMAND_CLICK_ON_DIALOG_CHOICE_1
+	k211_CommandClickOnDialogChoice_2 = 211, // @ C211_COMMAND_CLICK_ON_DIALOG_CHOICE_2
+	k212_CommandClickOnDialogChoice_3 = 212, // @ C212_COMMAND_CLICK_ON_DIALOG_CHOICE_3
+	k213_CommandClickOnDialogChoice_4 = 213, // @ C213_COMMAND_CLICK_ON_DIALOG_CHOICE_4
+	k215_CommandRestartGame = 215 // @ C215_COMMAND_RESTART_GAME
 }; // @ NONE
 
 class Command {
@@ -177,28 +177,28 @@ public:
 		: _commandTypeToIssue(type), _hitbox(x1, x2 + 1, y1, y2 + 1), _button(mouseButton) {}
 }; // @ MOUSE_INPUT
 
-extern MouseInput gPrimaryMouseInput_Entrance[4]; // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
-extern MouseInput gPrimaryMouseInput_RestartGame[2]; // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
-extern MouseInput gPrimaryMouseInput_Interface[20]; // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
-extern MouseInput gSecondaryMouseInput_Movement[9]; // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9]
-extern MouseInput gSecondaryMouseInput_ChampionInventory[38]; // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38]
-extern MouseInput gPrimaryMouseInput_PartySleeping[3]; // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
-extern MouseInput gPrimaryMouseInput_FrozenGame[3]; // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3]
-extern MouseInput gMouseInput_ActionAreaNames[5]; // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5]
-extern MouseInput gMouseInput_ActionAreaIcons[5]; // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5]
-extern MouseInput gMouseInput_SpellArea[9]; // @ G0454_as_Graphic561_MouseInput_SpellArea[9]
-extern MouseInput gMouseInput_ChampionNamesHands[13]; // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
-extern MouseInput gMouseInput_PanelChest[9]; // @ G0456_as_Graphic561_MouseInput_PanelChest[9]
-extern MouseInput gMouseInput_PanelResurrectReincarnateCancel[4]; // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4]
-extern MouseInput gPrimaryMouseInput_ViewportDialog1Choice[2]; // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
-extern MouseInput gPrimaryMouseInput_ViewportDialog2Choices[3]; // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3]
-extern MouseInput gPrimaryMouseInput_ViewportDialog3Choices[4]; // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4]
-extern MouseInput gPrimaryMouseInput_ViewportDialog4Choices[5]; // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5]
-extern MouseInput gPrimaryMouseInput_ScreenDialog1Choice[2]; // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2]
-extern MouseInput gPrimaryMouseInput_ScreenDialog2Choices[3]; // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3]
-extern MouseInput gPrimaryMouseInput_ScreenDialog3Choices[4]; // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4]
-extern MouseInput gPrimaryMouseInput_ScreenDialog4Choices[5]; // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
-extern MouseInput* gPrimaryMouseInput_DialogSets[2][4]; // @ G0480_aaps_PrimaryMouseInput_DialogSets
+extern MouseInput g445_PrimaryMouseInput_Entrance[4]; // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
+extern MouseInput g446_PrimaryMouseInput_RestartGame[2]; // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
+extern MouseInput g447_PrimaryMouseInput_Interface[20]; // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
+extern MouseInput g448_SecondaryMouseInput_Movement[9]; // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9]
+extern MouseInput g449_SecondaryMouseInput_ChampionInventory[38]; // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38]
+extern MouseInput g450_PrimaryMouseInput_PartySleeping[3]; // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
+extern MouseInput g451_PrimaryMouseInput_FrozenGame[3]; // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3]
+extern MouseInput g452_MouseInput_ActionAreaNames[5]; // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5]
+extern MouseInput g453_MouseInput_ActionAreaIcons[5]; // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5]
+extern MouseInput g454_MouseInput_SpellArea[9]; // @ G0454_as_Graphic561_MouseInput_SpellArea[9]
+extern MouseInput g455_MouseInput_ChampionNamesHands[13]; // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
+extern MouseInput g456_MouseInput_PanelChest[9]; // @ G0456_as_Graphic561_MouseInput_PanelChest[9]
+extern MouseInput g457_MouseInput_PanelResurrectReincarnateCancel[4]; // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4]
+extern MouseInput g471_PrimaryMouseInput_ViewportDialog1Choice[2]; // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
+extern MouseInput g472_PrimaryMouseInput_ViewportDialog2Choices[3]; // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3]
+extern MouseInput g473_PrimaryMouseInput_ViewportDialog3Choices[4]; // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4]
+extern MouseInput g474_PrimaryMouseInput_ViewportDialog4Choices[5]; // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5]
+extern MouseInput g475_PrimaryMouseInput_ScreenDialog1Choice[2]; // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2]
+extern MouseInput g476_PrimaryMouseInput_ScreenDialog2Choices[3]; // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3]
+extern MouseInput g477_PrimaryMouseInput_ScreenDialog3Choices[4]; // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4]
+extern MouseInput g478_PrimaryMouseInput_ScreenDialog4Choices[5]; // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
+extern MouseInput* g480_PrimaryMouseInput_DialogSets[2][4]; // @ G0480_aaps_PrimaryMouseInput_DialogSets
 
 class KeyboardInput {
 public:
@@ -217,11 +217,12 @@ class EventManager {
 	Common::Point _mousePos;
 	uint16 _dummyMapIndex;
 
-	bool _pendingClickPresent; // G0436_B_PendingClickPresent
-	Common::Point _pendingClickPos; // @ G0437_i_PendingClickX, G0438_i_PendingClickY
-	MouseButton _pendingClickButton; // @ G0439_i_PendingClickButtonsStatus
+	bool _g436_pendingClickPresent; // G0436_B_PendingClickPresent
+	Common::Point _g437_pendingClickPos; // @ G0437_i_PendingClickX, G0438_i_PendingClickY
+	MouseButton _g439_pendingClickButton; // @ G0439_i_PendingClickButtonsStatus
 
-	bool _isCommandQueueLocked; // this doesn't seem to be used anywhere at all
+// this doesn't seem to be used anywhere at all
+	bool _g435_isCommandQueueLocked; // @ G0435_B_CommandQueueLocked
 	Common::Queue<Command> _commandQueue;
 
 	void commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty
@@ -229,12 +230,12 @@ class EventManager {
 public:
 	explicit EventManager(DMEngine *vm);
 
-	MouseInput* _primaryMouseInput;// @ G0441_ps_PrimaryMouseInput
-	MouseInput* _secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput
-	bool _mousePointerBitmapUpdated; // @ G0598_B_MousePointerBitmapUpdated
-	bool _refreshMousePointerInMainLoop; // @ G0326_B_RefreshMousePointerInMainLoop
-	bool _highlightBoxEnabled; // @ G0341_B_HighlightBoxEnabled
-	uint16 _useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap
+	MouseInput* _g441_primaryMouseInput;// @ G0441_ps_PrimaryMouseInput
+	MouseInput* _g442_secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput
+	bool _g598_mousePointerBitmapUpdated; // @ G0598_B_MousePointerBitmapUpdated
+	bool _g326_refreshMousePointerInMainLoop; // @ G0326_B_RefreshMousePointerInMainLoop
+	bool _g341_highlightBoxEnabled; // @ G0341_B_HighlightBoxEnabled
+	uint16 _g599_useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap
 
 	void initMouse();
 	void showMouse(bool visibility);
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 0c2233d..b5198ed 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -32,7 +32,7 @@
 #include "dm.h"
 
 namespace DM {
-
+// this doesn't seem to be used anywhere at all
 /* Creature types */
 enum CreatureType {
 	kCreatureTypeGiantScorpionScorpion = 0, // @ C00_CREATURE_GIANT_SCORPION_SCORPION     
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 742f392..0a95b7b 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -78,9 +78,9 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 			return;
 		}
 		if (championIndex == k4_ChampionCloseInventory) {
-			em._refreshMousePointerInMainLoop = true;
+			em._g326_refreshMousePointerInMainLoop = true;
 			_vm->_menuMan->drawMovementArrows();
-			em._secondaryMouseInput = gSecondaryMouseInput_Movement;
+			em._g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
 			warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput");
 			warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
 			return;
@@ -116,8 +116,8 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
 
 	cm.drawChampionState(championIndex);
-	em._mousePointerBitmapUpdated = true;
-	em._secondaryMouseInput = gSecondaryMouseInput_ChampionInventory;
+	em._g598_mousePointerBitmapUpdated = true;
+	em._g442_secondaryMouseInput = g449_SecondaryMouseInput_ChampionInventory;
 	warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput");
 	warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
 }


Commit: 63ff1666d693b0078e5b6fd603240e9453c11918
    https://github.com/scummvm/scummvm/commit/63ff1666d693b0078e5b6fd603240e9453c11918
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: More constant and global variable renaming

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/group.cpp
    engines/dm/group.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/loadsave.cpp
    engines/dm/loadsave.h
    engines/dm/menus.cpp
    engines/dm/menus.h
    engines/dm/objectman.cpp
    engines/dm/objectman.h
    engines/dm/text.cpp
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 0e062bb..17ee181 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -282,7 +282,7 @@ bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing)
 		|| (currIconIndex == k195_IconIndicePotionEmptyFlask)) {
 		IconIndice newIconIndex = objMan.getIconIndex(thing);
 		if (newIconIndex != currIconIndex) {
-			if ((slotBoxIndex < kSlotBoxInventoryFirstSlot) && !_g420_mousePointerHiddenToDrawChangedObjIconOnScreen) {
+			if ((slotBoxIndex < k8_SlotBoxInventoryFirstSlot) && !_g420_mousePointerHiddenToDrawChangedObjIconOnScreen) {
 				_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
 				warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 			}
@@ -299,7 +299,7 @@ void ChampionMan::drawChangedObjectIcons() {
 	ObjectMan &objMan = *_vm->_objectMan;
 	MenuMan &menuMan = *_vm->_menuMan;
 
-	uint16 invChampOrdinal = invMan._inventoryChampionOrdinal;
+	uint16 invChampOrdinal = invMan._g432_inventoryChampionOrdinal;
 	if (_g299_candidateChampionOrdinal && !invChampOrdinal)
 		return;
 
@@ -313,7 +313,7 @@ void ChampionMan::drawChangedObjectIcons() {
 		if (iconIndex != leaderHandObjIconIndex) {
 			_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
 			warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-			objMan.extractIconFromBitmap(iconIndex, objMan._objectIconForMousePointer);
+			objMan.extractIconFromBitmap(iconIndex, objMan._g412_objectIconForMousePointer);
 			warning("MISSING CODE: F0068_MOUSE_SetPointerToObject");
 			_g413_leaderHandObjectIconIndex = iconIndex;
 			objMan.drawLeaderObjectName(_414_leaderHandObject);
@@ -338,17 +338,17 @@ void ChampionMan::drawChangedObjectIcons() {
 		uint16 drawViewport = 0;
 
 		for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++, thing++) {
-			uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + kSlotBoxInventoryFirstSlot, *thing) ? 1 : 0;
+			uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + k8_SlotBoxInventoryFirstSlot, *thing) ? 1 : 0;
 			drawViewport |= objIconChanged;
 			if (objIconChanged && (slotIndex == k1_ChampionSlotActionHand)) {
 				menuMan.drawActionIcon((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
 			}
 		}
 
-		if (invMan._panelContent = kPanelContentChest) {
-			thing = invMan._chestSlots;
+		if (invMan._g424_panelContent = k4_PanelContentChest) {
+			thing = invMan._g425_chestSlots;
 			for (int16 slotIndex = 0; slotIndex < 8; ++slotIndex, thing++) {
-				drawViewport |= (hasObjectIconInSlotBoxChanged(slotIndex + kSlotBoxChestFirstSlot, *thing) ? 1 : 0);
+				drawViewport |= (hasObjectIconInSlotBoxChanged(slotIndex + k38_SlotBoxChestFirstSlot, *thing) ? 1 : 0);
 			}
 		}
 
@@ -374,7 +374,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 	Champion *champ = &_champions[champIndex];
 
 	if (slotIndex >= k30_ChampionSlotChest_1) {
-		invMan._chestSlots[slotIndex - k30_ChampionSlotChest_1] = thing;
+		invMan._g425_chestSlots[slotIndex - k30_ChampionSlotChest_1] = thing;
 	} else {
 		champ->setSlot(slotIndex, thing);
 	}
@@ -382,7 +382,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 	champ->_load += dunMan.getObjectWeight(thing);
 	champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
 	IconIndice iconIndex = objMan.getIconIndex(thing);
-	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
+	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal);
 	applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
 	uint16 *rawObjPtr = dunMan.getThingData(thing);
 
@@ -551,7 +551,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	_g299_candidateChampionOrdinal = prevChampCount + 1;
 	if (++_g305_partyChampionCount == 1) {
 		_vm->_eventMan->commandSetLeader(k0_ChampionFirst);
-		_vm->_menuMan->_refreshActionArea = true;
+		_vm->_menuMan->_g508_refreshActionArea = true;
 	} else {
 		_vm->_menuMan->clearActingChampion();
 		_vm->_menuMan->drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1));
@@ -666,7 +666,7 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 
 	Box box;
-	box._x1 = champIndex * kChampionStatusBoxSpacing + 46;
+	box._x1 = champIndex * k69_ChampionStatusBoxSpacing + 46;
 	box._x2 = box._x1 + 3 + 1;
 	box._y1 = 2;
 	box._y2 = 26 + 1;
@@ -723,7 +723,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	EventManager &eventMan = *_vm->_eventMan;
 
 	Box box;
-	int16 champStatusBoxX = champIndex * kChampionStatusBoxSpacing;
+	int16 champStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
 	Champion *champ = &_champions[champIndex];
 	uint16 champAttributes = champ->getAttributes();
 	if (!((champAttributes) & (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon |
@@ -731,7 +731,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 							   k0x8000_ChampionAttributeActionHand))) {
 		return;
 	}
-	bool isInventoryChamp = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
+	bool isInventoryChamp = (_vm->indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal);
 	dispMan._g578_useByteBoxCoordinates = false;
 	if (champAttributes & k0x1000_ChampionAttributeStatusBox) {
 		box._y1 = 0;
@@ -905,7 +905,7 @@ void ChampionMan::drawHealthStaminaManaValues(Champion* champ) {
 void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 	int16 nativeBitmapIndex = -1;
 	Champion *champ = &_champions[champIndex];
-	bool isInventoryChamp = (_vm->_inventoryMan->_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex));
+	bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex));
 
 	uint16 slotBoxIndex;
 	if (!isInventoryChamp) {  /* If drawing a slot for a champion other than the champion whose inventory is open */
@@ -914,17 +914,17 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 		}
 		slotBoxIndex = (champIndex << 1) + slotIndex;
 	} else {
-		slotBoxIndex = kSlotBoxInventoryFirstSlot + slotIndex;
+		slotBoxIndex = k8_SlotBoxInventoryFirstSlot + slotIndex;
 	}
 
 	Thing thing;
 	if (slotIndex >= k30_ChampionSlotChest_1) {
-		thing = _vm->_inventoryMan->_chestSlots[slotIndex - k30_ChampionSlotChest_1];
+		thing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
 	} else {
 		thing = champ->getSlot(slotIndex);
 	}
 
-	SlotBox *slotBox = &_vm->_objectMan->_slotBoxes[slotBoxIndex];
+	SlotBox *slotBox = &_vm->_objectMan->_g30_slotBoxes[slotBoxIndex];
 	Box box;
 	box._x1 = slotBox->_x - 1;
 	box._y1 = slotBox->_y - 1;
@@ -999,7 +999,7 @@ void ChampionMan::renameChampion(Champion* champ) {
 	box._x2 = box._x1 + 167;
 
 	dispMan.clearScreenBox(k12_ColorDarkestGray, box, g296_DungeonViewport);
-	dispMan.blitToScreen(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, gBoxPanel, k4_ColorCyan, g296_DungeonViewport);
+	dispMan.blitToScreen(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, g32_BoxPanel, k4_ColorCyan, g296_DungeonViewport);
 	textMan.printToViewport(177, 58, k13_ColorLightestGray, "_______");
 	textMan.printToViewport(105, 76, k13_ColorLightestGray, "___________________");
 	Common::Point clickPos;
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 6f0c465..5c854d5 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -148,7 +148,7 @@ void DMEngine::initializeGame() {
 
 	_eventMan->initMouse();
 
-	while (_loadsaveMan->loadgame() != kLoadgameSuccess) {
+	while (_loadsaveMan->loadgame() != k1_LoadgameSuccess) {
 		warning("TODO: F0441_STARTEND_ProcessEntrance");
 	}
 
@@ -172,7 +172,7 @@ void DMEngine::startGame() {
 	_eventMan->_g341_highlightBoxEnabled = false;
 	_championMan->_g300_partyIsSleeping = false;
 	_championMan->_g506_actingChampionOrdinal = indexToOrdinal(kM1_ChampionNone);
-	_menuMan->_actionAreaContainsIcons = true;
+	_menuMan->_g509_actionAreaContainsIcons = true;
 	_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kM1_ChampionNone);
 
 	_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface;
@@ -238,8 +238,8 @@ void DMEngine::gameloop() {
 	_dungeonMan->_currMap._g308_partyDir = kDirNorth;
 
 
-	warning("DUMMY CODE: setting InventoryMan::_inventoryChampionOrdinal to zero");
-	_inventoryMan->_inventoryChampionOrdinal = 0;
+	warning("DUMMY CODE: setting InventoryMan::_g432_inventoryChampionOrdinal to zero");
+	_inventoryMan->_g432_inventoryChampionOrdinal = 0;
 	warning("DUMMY CODE: clearing screen to black"); // in loop below
 	while (true) {
 		_g321_stopWaitingForPlayerInput = false;
@@ -251,7 +251,7 @@ void DMEngine::gameloop() {
 		_eventMan->processCommandQueue();
 		//} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking);
 
-		if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
+		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
 			Box box(0, 224, 0, 126);
 			_displayMan->clearScreenBox(k0_ColorBlack, box, g296_DungeonViewport); // dummy code
 			_displayMan->drawDungeon(_dungeonMan->_currMap._g308_partyDir, _dungeonMan->_currMap._g306_partyPosX, _dungeonMan->_currMap._g307_partyPosY);
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 7b12bf4..df61b45 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -652,7 +652,7 @@ void DungeonMan::loadDungeonFile() {
 
 	// TODO: ??? what this
 	if (_messages._g298_newGame)
-		_vm->_timeline->_eventMaxCount = 100;
+		_vm->_timeline->_g369_eventMaxCount = 100;
 
 	// load things
 	for (uint16 thingType = k0_DoorThingType; thingType < k16_ThingTypeTotal; ++thingType) {
@@ -699,7 +699,7 @@ void DungeonMan::loadDungeonFile() {
 
 		if (_messages._g298_newGame) {
 			if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType)
-				_vm->_timeline->_eventMaxCount += _g278_fileHeader._thingCounts[thingType];
+				_vm->_timeline->_g369_eventMaxCount += _g278_fileHeader._thingCounts[thingType];
 			for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) {
 				_dunData._g284_thingsData[thingType][thingCount + i][0] = Thing::_none.toUint16();
 			}
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 69886e5..6d59727 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -616,7 +616,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 		Box box;
 		box._y1 = 0;
 		box._y2 = 28 + 1;
-		box._x1 = championIndex * kChampionStatusBoxSpacing;
+		box._x1 = championIndex * k69_ChampionStatusBoxSpacing;
 		box._x2 = box._x1 + 66 + 1;
 		dispMan._g578_useByteBoxCoordinates = false;
 		dispMan.clearScreenBox(k0_ColorBlack, box);
@@ -679,15 +679,15 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) {
 	InventoryMan &invMan = *_vm->_inventoryMan;
 
 	CommandType commandType;
-	switch (invMan._panelContent) {
-	case kPanelContentChest:
+	switch (invMan._g424_panelContent) {
+	case k4_PanelContentChest:
 		if (champMan._g411_leaderIndex == kM1_ChampionNone) // if no leader
 			return;
 		commandType = getCommandTypeFromMouseInput(g456_MouseInput_PanelChest, Common::Point(x, y), k1_LeftMouseButton);
 		if (commandType != k0_CommandNone)
 			warning("MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox");
 		break;
-	case kPanelContentResurrectReincarnate:
+	case k5_PanelContentResurrectReincarnate:
 		if (!champMan._g415_leaderEmptyHanded)
 			break;
 		commandType = getCommandTypeFromMouseInput(g457_MouseInput_PanelResurrectReincarnateCancel, Common::Point(x, y), k1_LeftMouseButton);
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index c93bf1d..62bf070 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2327,17 +2327,17 @@ T0115015_DrawProjectileAsObject:
 			goto T0115129_DrawProjectiles; /* Skip code to draw creatures */
 		if (group == nullptr) { /* If all creature data and info has not already been gathered */
 			group = (Group*)dunMan.getThingData(groupThing);
-			activeGroup = &_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()];
+			activeGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
 			creatureInfo = &g243_CreatureInfo[group->_type];
 			creatureAspectStruct = &g219_CreatureAspects[creatureInfo->_creatureAspectIndex];
-			creatureSize = getFlag(creatureInfo->_attributes, kMaskCreatureInfo_size);
+			creatureSize = getFlag(creatureInfo->_attributes, k0x0003_MaskCreatureInfo_size);
 			creatureGraphicInfoGreen = creatureInfo->_graphicInfo;
 		}
 		objectAspect = (ObjectAspect*)creatureAspectStruct;
 		if (AL_0_creatureIndexRed = _vm->_groupMan->getCreatureOrdinalInCell(group, cellYellowBear)) { /* If there is a creature on the cell being processed */
 			AL_0_creatureIndexRed--; /* Convert ordinal to index */
 			creatureIndexGreen = AL_0_creatureIndexRed;
-		} else if (creatureSize == kMaskCreatureSizeHalf) {
+		} else if (creatureSize == k1_MaskCreatureSizeHalf) {
 			AL_0_creatureIndexRed = 0;
 			creatureIndexGreen = -1;
 		} else {
@@ -2346,18 +2346,18 @@ T0115015_DrawProjectileAsObject:
 
 		creatureDirectionDelta = (directionParam - _vm->_groupMan->getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed)) % 3;
 		twoHalfSquareCreaturesFrontView = false;
-		if ((AL_4_groupCells = activeGroup->_cells) == kCreatureTypeSingleCenteredCreature) { /* If there is a single centered creature in the group */
+		if ((AL_4_groupCells = activeGroup->_cells) == k255_CreatureTypeSingleCenteredCreature) { /* If there is a single centered creature in the group */
 			if (remainingViewCellOrdinalsToProcess || (doorFrontViewDrawingPass == 1))
 /* Do not draw a single centered creature now, wait until second pass (for a front view door)
  or until all cells have been drawn so the creature is drawn over all the objects on the floor */
 				goto T0115129_DrawProjectiles;
 			drawCreaturesCompleted = true;
-			if ((creatureSize == kMaskCreatureSizeHalf) && (creatureDirectionDelta & 0x0001)) { /* Side view of half square creature */
+			if ((creatureSize == k1_MaskCreatureSizeHalf) && (creatureDirectionDelta & 0x0001)) { /* Side view of half square creature */
 				AL_2_viewCell = k3_HalfSizedViewCell_CenterColumn;
 			} else {
 				AL_2_viewCell = k4_HalfSizedViewCell_FrontRow;
 			}
-		} else if ((creatureSize == kMaskCreatureSizeHalf) && (drawingLastBackRowCell || !remainingViewCellOrdinalsToProcess || (creatureIndexGreen < 0))) {
+		} else if ((creatureSize == k1_MaskCreatureSizeHalf) && (drawingLastBackRowCell || !remainingViewCellOrdinalsToProcess || (creatureIndexGreen < 0))) {
 			if (drawingLastBackRowCell && (doorFrontViewDrawingPass != 2)) {
 				if ((creatureIndexGreen >= 0) && (creatureDirectionDelta & 0x0001)) {
 					AL_2_viewCell = k2_HalfSizedViewCell_BackRow; /* Side view of a half square creature on the back row. Drawn during pass 1 for a door square */
@@ -2388,7 +2388,7 @@ T0115015_DrawProjectileAsObject:
 				goto T0115129_DrawProjectiles;
 			}
 
-		} else if (creatureSize != kMaskCreatureSizeQuarter)
+		} else if (creatureSize != k0_MaskCreatureSizeQuarter)
 			goto T0115129_DrawProjectiles;
 
 
@@ -2411,7 +2411,7 @@ T0115077_DrawSecondHalfSquareCreature:
 			sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightSide;
 		} else {
 			useCreatureBackBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack) && (creatureDirectionDelta == 0);
-			if (useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupIsAttacking)
+			if (useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, k0x0080_MaskActiveGroupIsAttacking)
 				&& getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack)) {
 
 				useFlippedHorizontallyCreatureFrontImage = false;
@@ -2441,7 +2441,7 @@ T0115077_DrawSecondHalfSquareCreature:
 					}
 				} else {
 					if (useFlippedHorizontallyCreatureFrontImage = getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)
-						&& getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) {
+						&& getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
 						derivedBitmapIndex += 2;
 						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) {
 							derivedBitmapIndex += 2;
@@ -2470,7 +2470,7 @@ T0115077_DrawSecondHalfSquareCreature:
 			} else {
 				if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) {
 					AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex);
-					if (useCreatureAttackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) {
+					if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
 						memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
 						flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
@@ -2518,7 +2518,7 @@ T0115077_DrawSecondHalfSquareCreature:
 				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 			}
 			if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */
-				(useCreatureAttackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) ||
+				(useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) ||
 				(useCreatureSpecialD2FrontBitmap && getFlag(AL_0_creatureGraphicInfoRed, k0x0100_CreatureInfoGraphicMaskSpecialD2FrontIsFlipped)) ||
 				(useFlippedHorizontallyCreatureFrontImage && getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack))) { /* If the graphic should be flipped */
 				if (!useFlippedHorizontallyCreatureFrontImage || !derivedBitmapInCache) {
@@ -2608,7 +2608,7 @@ continue;
 						projectileBitmapIndexData = 0;
 						flipVertical = flipHorizontal = false;
 					} else {
-						if (isOrientedWestEast((direction)(projectileDirection = _vm->_timeline->_events[projectile->_timerIndex]._C._projectile.getDir()))
+						if (isOrientedWestEast((direction)(projectileDirection = _vm->_timeline->_g370_events[projectile->_timerIndex]._C._projectile.getDir()))
 							!= isOrientedWestEast(directionParam)) {
 							if (projectileAspectType == k2_ProjectileAspectHasRotation) {
 								projectileBitmapIndexData = 1;
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 76aab71..2891da3 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -35,28 +35,28 @@ namespace DM {
 
 
 GroupMan::GroupMan(DMEngine* vm) : _vm(vm) {
-	_activeGroups = nullptr;
+	_g375_activeGroups = nullptr;
 }
 
 GroupMan::~GroupMan() {
-	delete[] _activeGroups;
+	delete[] _g375_activeGroups;
 }
 
 void GroupMan::initActiveGroups() {
 	if (_vm->_dungeonMan->_messages._g298_newGame)
-		_maxActiveGroupCount = 60;
-	if (_activeGroups)
-		delete[] _activeGroups;
-	_activeGroups = new ActiveGroup[_maxActiveGroupCount];
-	for (uint16 i = 0; i < _maxActiveGroupCount; ++i)
-		_activeGroups[i]._groupThingIndex = -1;
+		_g376_maxActiveGroupCount = 60;
+	if (_g375_activeGroups)
+		delete[] _g375_activeGroups;
+	_g375_activeGroups = new ActiveGroup[_g376_maxActiveGroupCount];
+	for (uint16 i = 0; i < _g376_maxActiveGroupCount; ++i)
+		_g375_activeGroups[i]._groupThingIndex = -1;
 }
 
 uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) {
 	byte cells;
 	cells = group->_cells;
 	if (mapIndex == _vm->_dungeonMan->_currMap._g309_currPartyMapIndex)
-		cells = _activeGroups[cells]._cells;
+		cells = _g375_activeGroups[cells]._cells;
 	return cells;
 }
 
@@ -64,7 +64,7 @@ byte gGroupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_G
 
 uint16 GroupMan::getGroupDirections(Group* group, int16 mapIndex) {
 	if (mapIndex == _vm->_dungeonMan->_currMap._g309_currPartyMapIndex)
-		return _activeGroups[group->getActiveGroupIndex()]._directions;
+		return _g375_activeGroups[group->getActiveGroupIndex()]._directions;
 
 	return gGroupDirections[group->getDir()];
 }
@@ -72,11 +72,11 @@ uint16 GroupMan::getGroupDirections(Group* group, int16 mapIndex) {
 int16 GroupMan::getCreatureOrdinalInCell(Group* group, uint16 cell) {
 	uint16 currMapIndex = _vm->_dungeonMan->_currMap._g272_index;
 	byte groupCells = getGroupCells(group, currMapIndex);
-	if (groupCells == kCreatureTypeSingleCenteredCreature)
+	if (groupCells == k255_CreatureTypeSingleCenteredCreature)
 		return _vm->indexToOrdinal(0);
 
 	byte creatureIndex = group->getCount();
-	if (getFlag(g243_CreatureInfo[group->_type]._attributes, kMaskCreatureInfo_size) == kMaskCreatureSizeHalf) {
+	if (getFlag(g243_CreatureInfo[group->_type]._attributes, k0x0003_MaskCreatureInfo_size) == k1_MaskCreatureSizeHalf) {
 		if ((getGroupDirections(group, currMapIndex) & 1) == (cell & 1))
 			cell = returnPrevVal(cell);
 
diff --git a/engines/dm/group.h b/engines/dm/group.h
index b5198ed..af7a4eb 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -35,56 +35,56 @@ namespace DM {
 // this doesn't seem to be used anywhere at all
 /* Creature types */
 enum CreatureType {
-	kCreatureTypeGiantScorpionScorpion = 0, // @ C00_CREATURE_GIANT_SCORPION_SCORPION     
-	kCreatureTypeSwampSlimeSlime = 1, // @ C01_CREATURE_SWAMP_SLIME_SLIME_DEVIL     
-	kCreatureTypeGiggler = 2, // @ C02_CREATURE_GIGGLER                     
-	kCreatureTypeWizardEyeFlyingEye = 3, // @ C03_CREATURE_WIZARD_EYE_FLYING_EYE       
-	kCreatureTypePainRatHellHound = 4, // @ C04_CREATURE_PAIN_RAT_HELLHOUND          
-	kCreatureTypeRuster = 5, // @ C05_CREATURE_RUSTER                      
-	kCreatureTypeScreamer = 6, // @ C06_CREATURE_SCREAMER                    
-	kCreatureTypeRockpile = 7, // @ C07_CREATURE_ROCK_ROCKPILE               
-	kCreatureTypeGhostRive = 8, // @ C08_CREATURE_GHOST_RIVE                  
-	kCreatureTypeStoneGolem = 9, // @ C09_CREATURE_STONE_GOLEM                 
-	kCreatureTypeMummy = 10, // @ C10_CREATURE_MUMMY                      
-	kCreatureTypeBlackFlame = 11, // @ C11_CREATURE_BLACK_FLAME                
-	kCreatureTypeSkeleton = 12, // @ C12_CREATURE_SKELETON                   
-	kCreatureTypeCouatl = 13, // @ C13_CREATURE_COUATL                     
-	kCreatureTypeVexirk = 14, // @ C14_CREATURE_VEXIRK                     
-	kCreatureTypeMagnetaWormWorm = 15, // @ C15_CREATURE_MAGENTA_WORM_WORM          
-	kCreatureTypeTrolinAntman = 16, // @ C16_CREATURE_TROLIN_ANTMAN              
-	kCreatureTypeGiantWaspMuncher = 17, // @ C17_CREATURE_GIANT_WASP_MUNCHER         
-	kCreatureTypeAnimatedArmourDethKnight = 18, // @ C18_CREATURE_ANIMATED_ARMOUR_DETH_KNIGHT
-	kCreatureTypeMaterializerZytaz = 19, // @ C19_CREATURE_MATERIALIZER_ZYTAZ         
-	kCreatureTypeWaterElemental = 20, // @ C20_CREATURE_WATER_ELEMENTAL            
-	kCreatureTypeOitu = 21, // @ C21_CREATURE_OITU                       
-	kCreatureTypeDemon = 22, // @ C22_CREATURE_DEMON                      
-	kCreatureTypeLordChaos = 23, // @ C23_CREATURE_LORD_CHAOS                 
-	kCreatureTypeRedDragon = 24, // @ C24_CREATURE_RED_DRAGON                 
-	kCreatureTypeLordOrder = 25, // @ C25_CREATURE_LORD_ORDER                 
-	kCreatureTypeGreyLord = 26, // @ C26_CREATURE_GREY_LORD                  
-	kCreatureTypeSingleCenteredCreature = 255 // @ C255_SINGLE_CENTERED_CREATURE
+	k0_CreatureTypeGiantScorpionScorpion = 0, // @ C00_CREATURE_GIANT_SCORPION_SCORPION     
+	k1_CreatureTypeSwampSlimeSlime = 1, // @ C01_CREATURE_SWAMP_SLIME_SLIME_DEVIL     
+	k2_CreatureTypeGiggler = 2, // @ C02_CREATURE_GIGGLER                     
+	k3_CreatureTypeWizardEyeFlyingEye = 3, // @ C03_CREATURE_WIZARD_EYE_FLYING_EYE       
+	k4_CreatureTypePainRatHellHound = 4, // @ C04_CREATURE_PAIN_RAT_HELLHOUND          
+	k5_CreatureTypeRuster = 5, // @ C05_CREATURE_RUSTER                      
+	k6_CreatureTypeScreamer = 6, // @ C06_CREATURE_SCREAMER                    
+	k7_CreatureTypeRockpile = 7, // @ C07_CREATURE_ROCK_ROCKPILE               
+	k8_CreatureTypeGhostRive = 8, // @ C08_CREATURE_GHOST_RIVE                  
+	k9_CreatureTypeStoneGolem = 9, // @ C09_CREATURE_STONE_GOLEM                 
+	k10_CreatureTypeMummy = 10, // @ C10_CREATURE_MUMMY                      
+	k11_CreatureTypeBlackFlame = 11, // @ C11_CREATURE_BLACK_FLAME                
+	k12_CreatureTypeSkeleton = 12, // @ C12_CREATURE_SKELETON                   
+	k13_CreatureTypeCouatl = 13, // @ C13_CREATURE_COUATL                     
+	k14_CreatureTypeVexirk = 14, // @ C14_CREATURE_VEXIRK                     
+	k15_CreatureTypeMagnetaWormWorm = 15, // @ C15_CREATURE_MAGENTA_WORM_WORM          
+	k16_CreatureTypeTrolinAntman = 16, // @ C16_CREATURE_TROLIN_ANTMAN              
+	k17_CreatureTypeGiantWaspMuncher = 17, // @ C17_CREATURE_GIANT_WASP_MUNCHER         
+	k18_CreatureTypeAnimatedArmourDethKnight = 18, // @ C18_CREATURE_ANIMATED_ARMOUR_DETH_KNIGHT
+	k19_CreatureTypeMaterializerZytaz = 19, // @ C19_CREATURE_MATERIALIZER_ZYTAZ         
+	k20_CreatureTypeWaterElemental = 20, // @ C20_CREATURE_WATER_ELEMENTAL            
+	k21_CreatureTypeOitu = 21, // @ C21_CREATURE_OITU                       
+	k22_CreatureTypeDemon = 22, // @ C22_CREATURE_DEMON                      
+	k23_CreatureTypeLordChaos = 23, // @ C23_CREATURE_LORD_CHAOS                 
+	k24_CreatureTypeRedDragon = 24, // @ C24_CREATURE_RED_DRAGON                 
+	k25_CreatureTypeLordOrder = 25, // @ C25_CREATURE_LORD_ORDER                 
+	k26_CreatureTypeGreyLord = 26, // @ C26_CREATURE_GREY_LORD                  
+	k255_CreatureTypeSingleCenteredCreature = 255 // @ C255_SINGLE_CENTERED_CREATURE
 };
 
-#define kMaskCreatureSizeQuarter 0 // @ C0_SIZE_QUARTER_SQUARE
-#define kMaskCreatureSizeHalf 1 // @ C1_SIZE_HALF_SQUARE   
-#define kMaskCreatureSizeFull 2 // @ C2_SIZE_FULL_SQUARE   
+#define k0_MaskCreatureSizeQuarter 0 // @ C0_SIZE_QUARTER_SQUARE
+#define k1_MaskCreatureSizeHalf 1 // @ C1_SIZE_HALF_SQUARE   
+#define k2_MaskCreatureSizeFull 2 // @ C2_SIZE_FULL_SQUARE   
 
-#define kMaskCreatureInfo_size 0x0003 // @ MASK0x0003_SIZE                     
-#define kMaskCreatureInfo_sideAttack 0x0004 // @ MASK0x0004_SIDE_ATTACK              
-#define kMaskCreatureInfo_preferBackRow 0x0008 // @ MASK0x0008_PREFER_BACK_ROW          
-#define kMaskCreatureInfo_attackAnyChamp 0x0010 // @ MASK0x0010_ATTACK_ANY_CHAMPION      
-#define kMaskCreatureInfo_levitation 0x0020 // @ MASK0x0020_LEVITATION               
-#define kMaskCreatureInfo_nonMaterial 0x0040 // @ MASK0x0040_NON_MATERIAL             
-#define kMaskCreatureInfo_dropFixedPoss 0x0200 // @ MASK0x0200_DROP_FIXED_POSSESSIONS   
-#define kMaskCreatureInfo_keepThrownSharpWeapon 0x0400 // @ MASK0x0400_KEEP_THROWN_SHARP_WEAPONS
-#define kMaskCreatureInfo_seeInvisible 0x0800 // @ MASK0x0800_SEE_INVISIBLE            
-#define kMaskCreatureInfo_nightVision 0x1000 // @ MASK0x1000_NIGHT_VISION             
-#define kMaskCreatureInfo_archenemy 0x2000 // @ MASK0x2000_ARCHENEMY                
-#define kMaskCreatureInfo_magicmap 0x4000 // @ MASK0x4000_MAGICMAP  
+#define k0x0003_MaskCreatureInfo_size 0x0003 // @ MASK0x0003_SIZE                     
+#define k0x0004_MaskCreatureInfo_sideAttack 0x0004 // @ MASK0x0004_SIDE_ATTACK              
+#define k0x0008_MaskCreatureInfo_preferBackRow 0x0008 // @ MASK0x0008_PREFER_BACK_ROW          
+#define k0x0010_MaskCreatureInfo_attackAnyChamp 0x0010 // @ MASK0x0010_ATTACK_ANY_CHAMPION      
+#define k0x0020_MaskCreatureInfo_levitation 0x0020 // @ MASK0x0020_LEVITATION               
+#define k0x0040_MaskCreatureInfo_nonMaterial 0x0040 // @ MASK0x0040_NON_MATERIAL             
+#define k0x0200_MaskCreatureInfo_dropFixedPoss 0x0200 // @ MASK0x0200_DROP_FIXED_POSSESSIONS   
+#define k0x0400_MaskCreatureInfo_keepThrownSharpWeapon 0x0400 // @ MASK0x0400_KEEP_THROWN_SHARP_WEAPONS
+#define k0x0800_MaskCreatureInfo_seeInvisible 0x0800 // @ MASK0x0800_SEE_INVISIBLE            
+#define k0x1000_MaskCreatureInfo_nightVision 0x1000 // @ MASK0x1000_NIGHT_VISION             
+#define k0x2000_MaskCreatureInfo_archenemy 0x2000 // @ MASK0x2000_ARCHENEMY                
+#define k0x4000_MaskCreatureInfo_magicmap 0x4000 // @ MASK0x4000_MAGICMAP  
 
 
-#define kMaskActiveGroupFlipBitmap 0x0040 // @ MASK0x0040_FLIP_BITMAP  
-#define kMaskActiveGroupIsAttacking 0x0080 // @ MASK0x0080_IS_ATTACKING 
+#define k0x0040_MaskActiveGroupFlipBitmap 0x0040 // @ MASK0x0040_FLIP_BITMAP  
+#define k0x0080_MaskActiveGroupIsAttacking 0x0080 // @ MASK0x0080_IS_ATTACKING 
 
 class ActiveGroup {
 public:
@@ -133,8 +133,8 @@ public:
 class GroupMan {
 	DMEngine *_vm;
 public:
-	uint16 _maxActiveGroupCount = 60; // @ G0376_ui_MaximumActiveGroupCount
-	ActiveGroup *_activeGroups; // @ G0375_ps_ActiveGroups
+	uint16 _g376_maxActiveGroupCount = 60; // @ G0376_ui_MaximumActiveGroupCount
+	ActiveGroup *_g375_activeGroups; // @ G0375_ps_ActiveGroups
 	GroupMan(DMEngine *vm);
 	~GroupMan();
 	void initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 0a95b7b..1d7bd95 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -36,18 +36,18 @@
 
 namespace DM {
 
-Box gBoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
-Box gBoxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel
-Box gBoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food
-Box gBoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
-Box gBoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
+Box g41_BoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
+Box g32_BoxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel
+Box g35_BoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food
+Box g36_BoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
+Box g37_BoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
 
 InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
-	_panelContent = kPanelContentFoodWaterPoisoned;
+	_g424_panelContent = k0_PanelContentFoodWaterPoisoned;
 	for (uint16 i = 0; i < 8; ++i)
-		_chestSlots[i] = Thing::_none;
-	_openChest = Thing::_none;
-	_openChest = Thing::_none;
+		_g425_chestSlots[i] = Thing::_none;
+	_g426_openChest = Thing::_none;
+	_g426_openChest = Thing::_none;
 }
 
 void InventoryMan::toggleInventory(ChampionIndex championIndex) {
@@ -60,14 +60,14 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth)
 		return;
 	_vm->_g321_stopWaitingForPlayerInput = true;
-	int16 invChampOrdinal = _inventoryChampionOrdinal; // copy, as the original will be edited
+	int16 invChampOrdinal = _g432_inventoryChampionOrdinal; // copy, as the original will be edited
 	if (_vm->indexToOrdinal(championIndex) == invChampOrdinal) {
 		championIndex = k4_ChampionCloseInventory;
 	}
 
 	Champion *champion;
 	if (invChampOrdinal) {
-		_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
+		_g432_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 		closeChest();
 		champion = &cm._champions[_vm->ordinalToIndex(invChampOrdinal)];
 		if (champion->_currHealth && !cm._g299_candidateChampionOrdinal) {
@@ -88,7 +88,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	}
 
 	dm._g578_useByteBoxCoordinates = false;
-	_inventoryChampionOrdinal = _vm->indexToOrdinal(championIndex);
+	_g432_inventoryChampionOrdinal = _vm->indexToOrdinal(championIndex);
 	if (!invChampOrdinal) {
 		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 	}
@@ -98,7 +98,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	int16 h = dm.getHeight(k17_InventoryGraphicIndice);
 	dm.blitToScreen(dm.getBitmap(k17_InventoryGraphicIndice), w, 0, 0, 0, w, 0, h, k255_ColorNoTransparency, g296_DungeonViewport);
 	if (cm._g299_candidateChampionOrdinal) {
-		dm.clearScreenBox(k12_ColorDarkestGray, gBoxFloppyZzzCross, g296_DungeonViewport);
+		dm.clearScreenBox(k12_ColorDarkestGray, g41_BoxFloppyZzzCross, g296_DungeonViewport);
 	}
 	_vm->_textMan->printToViewport(5, 116, k13_ColorLightestGray, "HEALTH");
 	_vm->_textMan->printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
@@ -128,7 +128,7 @@ void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) {
 	Box box;
 	box._y1 = 0;
 	box._y2 = 28 + 1;
-	box._x1 = championIndex * kChampionStatusBoxSpacing + 7;
+	box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7;
 	box._x2 = box._x1 + 31 + 1;
 	dispMan.blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0, box, k255_ColorNoTransparency);
 }
@@ -160,22 +160,22 @@ void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
 }
 
 void InventoryMan::drawPanelFoodWaterPoisoned() {
-	Champion &champ = _vm->_championMan->_champions[_inventoryChampionOrdinal];
+	Champion &champ = _vm->_championMan->_champions[_g432_inventoryChampionOrdinal];
 	closeChest();
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, gBoxPanel, k8_ColorRed);
-	dispMan.blitToScreen(dispMan.getBitmap(k30_FoodLabelIndice), 48, 0, 0, gBoxFood, k12_ColorDarkestGray);
-	dispMan.blitToScreen(dispMan.getBitmap(k31_WaterLabelIndice), 48, 0, 0, gBoxWater, k12_ColorDarkestGray);
+	dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed);
+	dispMan.blitToScreen(dispMan.getBitmap(k30_FoodLabelIndice), 48, 0, 0, g35_BoxFood, k12_ColorDarkestGray);
+	dispMan.blitToScreen(dispMan.getBitmap(k31_WaterLabelIndice), 48, 0, 0, g36_BoxWater, k12_ColorDarkestGray);
 	if (champ._poisonEventCount) {
-		dispMan.blitToScreen(dispMan.getBitmap(k32_PoisionedLabelIndice), 96, 0, 0, gBoxPoisoned, k12_ColorDarkestGray);
+		dispMan.blitToScreen(dispMan.getBitmap(k32_PoisionedLabelIndice), 96, 0, 0, g37_BoxPoisoned, k12_ColorDarkestGray);
 	}
 	drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown);
 	drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue);
 }
 
 void InventoryMan::drawPanelResurrectReincarnate() {
-	_panelContent = kPanelContentResurrectReincarnate;
-	_vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, gBoxPanel, k6_ColorDarkGreen, g296_DungeonViewport);
+	_g424_panelContent = k5_PanelContentResurrectReincarnate;
+	_vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, g32_BoxPanel, k6_ColorDarkGreen, g296_DungeonViewport);
 }
 
 void InventoryMan::drawPanel() {
@@ -188,15 +188,15 @@ void InventoryMan::drawPanel() {
 		return;
 	}
 
-	Thing thing = cm._champions[_vm->ordinalToIndex(_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand);
+	Thing thing = cm._champions[_vm->ordinalToIndex(_g432_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand);
 
-	_panelContent = kPanelContentFoodWaterPoisoned;
+	_g424_panelContent = k0_PanelContentFoodWaterPoisoned;
 	switch (thing.getType()) {
 	case k9_ContainerThingType:
-		_panelContent = kPanelContentChest;
+		_g424_panelContent = k4_PanelContentChest;
 		break;
 	case k7_ScrollThingType:
-		_panelContent = kPanelContentScroll;
+		_g424_panelContent = k2_PanelContentScroll;
 		break;
 	default:
 		thing = Thing::_none;
@@ -213,16 +213,16 @@ void InventoryMan::closeChest() {
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 
 	bool processFirstChestSlot = true;
-	if (_openChest == Thing::_none)
+	if (_g426_openChest == Thing::_none)
 		return;
-	Container *container = (Container*)dunMan.getThingData(_openChest);
-	_openChest = Thing::_none;
+	Container *container = (Container*)dunMan.getThingData(_g426_openChest);
+	_g426_openChest = Thing::_none;
 	container->getSlot() = Thing::_endOfList;
 	Thing prevThing;
 	for (int16 chestSlotIndex = 0; chestSlotIndex < 8; ++chestSlotIndex) {
-		Thing thing = _chestSlots[chestSlotIndex];
+		Thing thing = _g425_chestSlots[chestSlotIndex];
 		if (thing != Thing::_none) {
-			_chestSlots[chestSlotIndex] = Thing::_none; // CHANGE8_09_FIX
+			_g425_chestSlots[chestSlotIndex] = Thing::_none; // CHANGE8_09_FIX
 
 			if (processFirstChestSlot) {
 				processFirstChestSlot = false;
@@ -258,7 +258,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) {
 		charRed++;
 	}
 	*charRed = '\0';
-	dispMan.blitToScreen(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, g296_DungeonViewport);
+	dispMan.blitToScreen(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed, g296_DungeonViewport);
 	int16 lineCount = 1;
 	charRed++;
 	char *charGreen = charRed; // first char of the second line
@@ -299,18 +299,18 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 	DisplayMan &dispMan = *_vm->_displayMan;
 	ObjectMan &objMan = *_vm->_objectMan;
 
-	if (_openChest == thingToOpen)
+	if (_g426_openChest == thingToOpen)
 		return;
 
 	warning("CHANGE8_09_FIX");
-	if (_openChest != Thing::_none)
+	if (_g426_openChest != Thing::_none)
 		closeChest(); // CHANGE8_09_FIX
 
-	_openChest = thingToOpen;
+	_g426_openChest = thingToOpen;
 	if (!isPressingEye) {
-		objMan.drawIconInSlotBox(kSlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen);
+		objMan.drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen);
 	}
-	dispMan.blitToScreen(dispMan.getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, gBoxPanel, k8_ColorRed);
+	dispMan.blitToScreen(dispMan.getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed);
 
 	int16 chestSlotIndex = 0;
 	Thing thing = chest->getSlot();
@@ -320,13 +320,13 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 		if (++thingCount > 8)
 			break; // CHANGE8_08_FIX, make sure that no more than the first 8 objects in a chest are drawn
 
-		objMan.drawIconInSlotBox(chestSlotIndex + kSlotBoxChestFirstSlot, objMan.getIconIndex(thing));
-		_chestSlots[chestSlotIndex++] = thing;
+		objMan.drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, objMan.getIconIndex(thing));
+		_g425_chestSlots[chestSlotIndex++] = thing;
 		thing = _vm->_dungeonMan->getNextThing(thing);
 	}
 	while (chestSlotIndex < 8) {
-		objMan.drawIconInSlotBox(chestSlotIndex + kSlotBoxChestFirstSlot, kM1_IconIndiceNone);
-		_chestSlots[chestSlotIndex++] = Thing::_none;
+		objMan.drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, kM1_IconIndiceNone);
+		_g425_chestSlots[chestSlotIndex++] = Thing::_none;
 	}
 }
 
@@ -373,8 +373,8 @@ void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 a
 void InventoryMan::drawPanelObjectDescriptionString(char* descString) {
 	if (descString[0] == '\f') { // form feed
 		descString++;
-		_objDescTextXpos = 108;
-		_objDescTextYpos = 59;
+		_g421_objDescTextXpos = 108;
+		_g422_objDescTextYpos = 59;
 	}
 
 	if (descString[0]) {
@@ -394,8 +394,8 @@ void InventoryMan::drawPanelObjectDescriptionString(char* descString) {
 				severalLines = true;
 			}
 
-			_vm->_textMan->printToViewport(_objDescTextXpos, _objDescTextYpos, k13_ColorLightestGray, stringLine);
-			_objDescTextYpos += 7;
+			_vm->_textMan->printToViewport(_g421_objDescTextXpos, _g422_objDescTextYpos, k13_ColorLightestGray, stringLine);
+			_g422_objDescTextYpos += 7;
 			if (severalLines) {
 				severalLines = false;
 				stringLine = ++string;
@@ -406,21 +406,21 @@ void InventoryMan::drawPanelObjectDescriptionString(char* descString) {
 	}
 }
 
-Box gBoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye 
+Box g33_BoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye 
 
 void InventoryMan::drawPanelArrowOrEye(bool pressingEye) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 	dispMan.blitToScreen(dispMan.getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice),
-						 16, 0, 0, gBoxArrowOrEye, k8_ColorRed, g296_DungeonViewport);
+						 16, 0, 0, g33_BoxArrowOrEye, k8_ColorRed, g296_DungeonViewport);
 }
 
 
-Box gBoxObjectDescCircle = Box(105, 136, 53, 79); // @ G0034_s_Graphic562_Box_ObjectDescriptionCircle 
+Box g34_BoxObjectDescCircle = Box(105, 136, 53, 79); // @ G0034_s_Graphic562_Box_ObjectDescriptionCircle 
 
-#define kDescriptionMaskConsumable 0x0001 // @ MASK0x0001_DESCRIPTION_CONSUMABLE
-#define kDescriptionMaskPoisoned 0x0002 // @ MASK0x0002_DESCRIPTION_POISONED  
-#define kDescriptionMaskBroken 0x0004 // @ MASK0x0004_DESCRIPTION_BROKEN    
-#define kDescriptionMaskCursed 0x0008 // @ MASK0x0008_DESCRIPTION_CURSED    
+#define k0x0001_DescriptionMaskConsumable 0x0001 // @ MASK0x0001_DESCRIPTION_CONSUMABLE
+#define k0x0002_DescriptionMaskPoisoned 0x0002 // @ MASK0x0002_DESCRIPTION_POISONED  
+#define k0x0004_DescriptionMaskBroken 0x0004 // @ MASK0x0004_DESCRIPTION_BROKEN    
+#define k0x0008_DescriptionMaskCursed 0x0008 // @ MASK0x0008_DESCRIPTION_CURSED    
 
 void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 	DungeonMan &dunMan = *_vm->_dungeonMan;
@@ -443,27 +443,27 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye);
 	} else {
 		IconIndice iconIndex = objMan.getIconIndex(thingToDraw);
-		dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, g296_DungeonViewport);
-		dispMan.blitToScreen(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, gBoxObjectDescCircle, k12_ColorDarkestGray, g296_DungeonViewport);
+		dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed, g296_DungeonViewport);
+		dispMan.blitToScreen(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, g34_BoxObjectDescCircle, k12_ColorDarkestGray, g296_DungeonViewport);
 
 		char *descString = nullptr;
 		char str[40];
 		if (iconIndex == k147_IconIndiceJunkChampionBones) {
 			strcpy(str, champMan._champions[((Junk*)rawThingPtr)->getChargeCount()]._name);  // TODO: localization
 			strcat(str, " "); // TODO: localization
-			strcat(str, objMan._objectNames[iconIndex]);  // TODO: localization
+			strcat(str, objMan._g352_objectNames[iconIndex]);  // TODO: localization
 
 			descString = str;
 		} else if ((thingType == k8_PotionThingType)
 				   && (iconIndex != k163_IconIndicePotionWaterFlask)
-				   && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
+				   && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_g432_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
 			str[0] = '_' + ((Potion*)rawThingPtr)->getPower() / 40;
 			str[1] = ' ';
 			str[2] = '\0';
-			strcat(str, objMan._objectNames[iconIndex]);
+			strcat(str, objMan._g352_objectNames[iconIndex]);
 			descString = str;
 		} else {
-			descString = objMan._objectNames[iconIndex];
+			descString = objMan._g352_objectNames[iconIndex];
 		}
 
 		textMan.printToViewport(134, 68, k13_ColorLightestGray, descString);
@@ -471,13 +471,13 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 
 		char *attribString[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"}; // TODO: localization
 
-		_objDescTextYpos = 87;
+		_g422_objDescTextYpos = 87;
 
 		uint16 potentialAttribMask;
 		uint16 actualAttribMask;
 		switch (thingType) {
 		case k5_WeaponThingType: {
-			potentialAttribMask = kDescriptionMaskCursed | kDescriptionMaskPoisoned | kDescriptionMaskBroken;
+			potentialAttribMask = k0x0008_DescriptionMaskCursed | k0x0002_DescriptionMaskPoisoned | k0x0004_DescriptionMaskBroken;
 			Weapon *weapon = (Weapon*)rawThingPtr;
 			actualAttribMask = (weapon->getCursed() << 3) | (weapon->getPoisoned() << 1) | (weapon->getBroken() << 2);
 			if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit)
@@ -488,13 +488,13 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			break;
 		}
 		case k6_ArmourThingType: {
-			potentialAttribMask = kDescriptionMaskCursed | kDescriptionMaskBroken;
+			potentialAttribMask = k0x0008_DescriptionMaskCursed | k0x0004_DescriptionMaskBroken;
 			Armour *armour = (Armour*)rawThingPtr;
 			actualAttribMask = (armour->getCursed() << 3) | (armour->getBroken() << 2);
 			break;
 		}
 		case k8_PotionThingType: {
-			actualAttribMask = kDescriptionMaskConsumable;
+			actualAttribMask = k0x0001_DescriptionMaskConsumable;
 			Potion *potion = (Potion*)rawThingPtr;
 			actualAttribMask = g237_ObjectInfo[k2_ObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots();
 			break;
@@ -525,7 +525,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 				strcat(str, directionName[iconIndex]);
 				drawPanelObjectDescriptionString(str);
 			} else {
-				potentialAttribMask = kDescriptionMaskConsumable;
+				potentialAttribMask = k0x0001_DescriptionMaskConsumable;
 				actualAttribMask = g237_ObjectInfo[k127_ObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots();
 			}
 			break;
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 952511d..82865f5 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -34,17 +34,17 @@
 
 namespace DM {
 
-#define kChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING
-#define kSlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT
+#define k69_ChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING
+#define k38_SlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT
 
 
-extern Box gBoxPanel; // @ G0032_s_Graphic562_Box_Panel
+extern Box g32_BoxPanel; // @ G0032_s_Graphic562_Box_Panel
 
 enum PanelContent {
-	kPanelContentFoodWaterPoisoned = 0, // @ C00_PANEL_FOOD_WATER_POISONED
-	kPanelContentScroll = 2, // @ C02_PANEL_SCROLL
-	kPanelContentChest = 4, // @ C04_PANEL_CHEST
-	kPanelContentResurrectReincarnate = 5 // @ C05_PANEL_RESURRECT_REINCARNATE
+	k0_PanelContentFoodWaterPoisoned = 0, // @ C00_PANEL_FOOD_WATER_POISONED
+	k2_PanelContentScroll = 2, // @ C02_PANEL_SCROLL
+	k4_PanelContentChest = 4, // @ C04_PANEL_CHEST
+	k5_PanelContentResurrectReincarnate = 5 // @ C05_PANEL_RESURRECT_REINCARNATE
 };
 
 
@@ -54,12 +54,12 @@ class InventoryMan {
 public:
 	explicit InventoryMan(DMEngine *vm);
 
-	int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal
-	PanelContent _panelContent; // @ G0424_i_PanelContent 
-	Thing _chestSlots[8]; // @ G0425_aT_ChestSlots
-	Thing _openChest; // @ G0426_T_OpenChest
-	int16 _objDescTextXpos; // @ G0421_i_ObjectDescriptionTextX
-	int16 _objDescTextYpos; // @ G0422_i_ObjectDescriptionTextY
+	int16 _g432_inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal
+	PanelContent _g424_panelContent; // @ G0424_i_PanelContent 
+	Thing _g425_chestSlots[8]; // @ G0425_aT_ChestSlots
+	Thing _g426_openChest; // @ G0426_T_OpenChest
+	int16 _g421_objDescTextXpos; // @ G0421_i_ObjectDescriptionTextX
+	int16 _g422_objDescTextYpos; // @ G0422_i_ObjectDescriptionTextY
 
 	void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE
 	void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index bd99345..aabe88f 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -62,7 +62,7 @@ LoadgameResponse LoadsaveMan::loadgame() {
 		// MISSING CODE: load game
 	}
 	cm._303_partyDead = false;
-	return kLoadgameSuccess;
+	return k1_LoadgameSuccess;
 }
 
 }
\ No newline at end of file
diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h
index 71043a2..0ee7118 100644
--- a/engines/dm/loadsave.h
+++ b/engines/dm/loadsave.h
@@ -33,8 +33,8 @@
 namespace DM {
 
 enum LoadgameResponse {
-	kLoadgameFailure = -1, // @ CM1_LOAD_GAME_FAILURE
-	kLoadgameSuccess = 1// @ C01_LOAD_GAME_SUCCESS
+	kM1_LoadgameFailure = -1, // @ CM1_LOAD_GAME_FAILURE
+	k1_LoadgameSuccess = 1// @ C01_LOAD_GAME_SUCCESS
 };
 
 class LoadsaveMan {
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 20d0f53..ee27ee0 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -36,26 +36,26 @@
 
 namespace DM {
 
-Box  gBoxActionArea3ActionMenu = Box(224, 319, 77, 121); // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu
-Box  gBoxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
-Box  gBoxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
-Box gBoxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea 
-byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
+Box  g499_BoxActionArea3ActionMenu = Box(224, 319, 77, 121); // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu
+Box  g500_BoxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
+Box  g501_BoxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
+Box g1_BoxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea 
+byte g498_PalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
 
-Box gBoxSpellAreaLine = Box(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine 
-Box gBoxSpellAreaLine2 = Box(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 
-Box gBoxSpellAreaLine3 = Box(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 
-Box gBoxSpellArea = Box(224, 319, 77, 121);
+Box gK74_BoxSpellAreaLine = Box(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine 
+Box gK75_BoxSpellAreaLine2 = Box(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 
+Box gK76_BoxSpellAreaLine3 = Box(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 
+Box g0_BoxSpellArea = Box(224, 319, 77, 121);
 
 MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
-	_refreshActionArea = false;
-	_actionAreaContainsIcons = false;
-	_actionDamage = 0;
-	_bitmapSpellAreaLine = new byte[96 * 12];
+	_g508_refreshActionArea = false;
+	_g509_actionAreaContainsIcons = false;
+	_g513_actionDamage = 0;
+	_gK72_bitmapSpellAreaLine = new byte[96 * 12];
 }
 
 MenuMan::~MenuMan() {
-	delete[] _bitmapSpellAreaLine;
+	delete[] _gK72_bitmapSpellAreaLine;
 }
 
 void MenuMan::drawMovementArrows() {
@@ -73,12 +73,12 @@ void MenuMan::clearActingChampion() {
 		cm._champions[cm._g506_actingChampionOrdinal].setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
 		cm.drawChampionState((ChampionIndex)cm._g506_actingChampionOrdinal);
 		cm._g506_actingChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
-		_refreshActionArea = true;
+		_g508_refreshActionArea = true;
 	}
 }
 
 void MenuMan::drawActionIcon(ChampionIndex championIndex) {
-	if (!_actionAreaContainsIcons)
+	if (!_g509_actionAreaContainsIcons)
 		return;
 	DisplayMan &dm = *_vm->_displayMan;
 	Champion &champion = _vm->_championMan->_champions[championIndex];
@@ -105,7 +105,7 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) {
 		goto T0386006;
 	}
 	_vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon);
-	dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, gPalChangesActionAreaObjectIcon);
+	dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, g498_PalChangesActionAreaObjectIcon);
 T0386006:
 	dm.clearScreenBox(k4_ColorCyan, box);
 	Box box2;
@@ -123,8 +123,8 @@ void MenuMan::drawDisabledMenu() {
 	if (!_vm->_championMan->_g300_partyIsSleeping) {
 		warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		if (_vm->_inventoryMan->_inventoryChampionOrdinal) {
-			if (_vm->_inventoryMan->_panelContent == kPanelContentChest) {
+		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+			if (_vm->_inventoryMan->_g424_panelContent == k4_PanelContentChest) {
 				_vm->_inventoryMan->closeChest();
 			}
 		} else {
@@ -170,17 +170,17 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
 		} while (champIndex < champMan._g305_partyChampionCount);
 	}
 
-	if (_refreshActionArea) {
+	if (_g508_refreshActionArea) {
 		if (!champMan._g506_actingChampionOrdinal) {
-			if (_actionDamage) {
+			if (_g513_actionDamage) {
 				warning("MISSING CODE: F0385_MENUS_DrawActionDamage");
-				_actionDamage = 0;
+				_g513_actionDamage = 0;
 			} else {
-				_actionAreaContainsIcons = true;
+				_g509_actionAreaContainsIcons = true;
 				drawActionArea();
 			}
 		} else {
-			_actionAreaContainsIcons = false;
+			_g509_actionAreaContainsIcons = false;
 			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
 			champMan.drawChampionState((ChampionIndex)_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal));
 			warning("MISSING CODE: F0387_MENUS_DrawActionArea");
@@ -188,8 +188,8 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
 	}
 }
 
-#define kChampionNameMaximumLength 7 // @ C007_CHAMPION_NAME_MAXIMUM_LENGTH
-#define kActionNameMaximumLength 12 // @ C012_ACTION_NAME_MAXIMUM_LENGTH
+#define k7_ChampionNameMaximumLength 7 // @ C007_CHAMPION_NAME_MAXIMUM_LENGTH
+#define k12_ActionNameMaximumLength 12 // @ C012_ACTION_NAME_MAXIMUM_LENGTH
 
 void MenuMan::drawActionArea() {
 	DisplayMan &dispMan = *_vm->_displayMan;
@@ -198,30 +198,30 @@ void MenuMan::drawActionArea() {
 
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 	dispMan._g578_useByteBoxCoordinates = false;
-	dispMan.clearScreenBox(k0_ColorBlack, gBoxActionArea);
-	if (_actionAreaContainsIcons) {
+	dispMan.clearScreenBox(k0_ColorBlack, g1_BoxActionArea);
+	if (_g509_actionAreaContainsIcons) {
 		for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._g305_partyChampionCount; ++champIndex)
 			drawActionIcon((ChampionIndex)champIndex);
 	} else if (champMan._g506_actingChampionOrdinal) {
-		Box box = gBoxActionArea3ActionMenu;
-		if (_actionList._actionIndices[2] == k255_ChampionActionNone)
-			box = gBoxActionArea2ActionMenu;
-		if (_actionList._actionIndices[1] == k255_ChampionActionNone)
-			box = gBoxActionArea1ActionMenu;
+		Box box = g499_BoxActionArea3ActionMenu;
+		if (_g713_actionList._actionIndices[2] == k255_ChampionActionNone)
+			box = g500_BoxActionArea2ActionMenu;
+		if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone)
+			box = g501_BoxActionArea1ActionMenu;
 		dispMan.blitToScreen(dispMan.getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, box, k255_ColorNoTransparency);
 		textMan.printWithTrailingSpacesToScreen(235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name,
-												kChampionNameMaximumLength);
+												k7_ChampionNameMaximumLength);
 		for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) {
 			textMan.printWithTrailingSpacesToScreen(241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
-													getActionName(_actionList._actionIndices[actionListIndex]),
-													kActionNameMaximumLength);
+													getActionName(_g713_actionList._actionIndices[actionListIndex]),
+													k12_ActionNameMaximumLength);
 		}
 	}
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
-	_refreshActionArea = false;
+	_g508_refreshActionArea = false;
 }
 
-const char *gChampionActionNames[44] = {
+const char *g490_ChampionActionNames[44] = { // @ G0490_ac_Graphic560_ActionNames
 	"N", "BLOCK", "CHOP", "X", "BLOW HORN", "FLIP", "PUNCH",
 	"KICK", "WAR CRY", "STAB", "CLIMB DOWN", "FREEZE LIFE",
 	"HIT", "SWING", "STAB", "THRUST", "JAB", "PARRY", "HACK",
@@ -232,11 +232,11 @@ const char *gChampionActionNames[44] = {
 	"BRANDISH", "THROW", "FUSE"};
 
 const char* MenuMan::getActionName(ChampionAction actionIndex) {
-	return (actionIndex == k255_ChampionActionNone) ? "" : gChampionActionNames[actionIndex];
+	return (actionIndex == k255_ChampionActionNone) ? "" : g490_ChampionActionNames[actionIndex];
 }
 
 
-Box gBoxSpellAreaControls = Box(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls 
+Box g504_BoxSpellAreaControls = Box(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls 
 
 void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
 	ChampionMan &champMan = *_vm->_championMan;
@@ -248,7 +248,7 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
 	for (uint16 i = 0; i < 4; ++i)
 		champCurrHealth[i] = champMan._champions[i]._currHealth;
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-	dispMan.clearScreenBox(k0_ColorBlack, gBoxSpellAreaControls);
+	dispMan.clearScreenBox(k0_ColorBlack, g504_BoxSpellAreaControls);
 	int16 champCount = champMan._g305_partyChampionCount;
 	switch (champIndex) {
 	case k0_ChampionFirst:
@@ -306,32 +306,32 @@ labelChamp3:
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 
-#define kSpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
-#define kSpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
+#define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
+#define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
 
 void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 
 	Champion &champ = _vm->_championMan->_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
-	if (spellAreaBitmapLine == kSpellAreaAvailableSymbols) {
+	if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) {
 		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 12, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, k255_ColorNoTransparency);
+		dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 12, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency);
 		int16 x = 1;
 		byte c = 96 + (6 * champ._symbolStep);
 		char spellSymbolString[2] = {'\0', '\0'};
 		for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
 			spellSymbolString[0] = c++;
-			_vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 14, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
+			_vm->_textMan->printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 14, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
 		}
-	} else if (spellAreaBitmapLine == kSpellAreaChampionSymbols) {
+	} else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) {
 		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 24, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, k255_ColorNoTransparency);
+		dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 24, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency);
 		char spellSymbolString[2] = {'\0', '\0'};
 		int16 x = 8;
 		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
 			if ((spellSymbolString[0] = champ._symbols[symbolIndex]) == '\0')
 				break;
-			_vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 9, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
+			_vm->_textMan->printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 9, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
 		}
 	}
 }
@@ -345,25 +345,25 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
 		return;
 	if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) {
 		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-		dispMan.blitToScreen(dispMan.getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, gBoxSpellArea);
+		dispMan.blitToScreen(dispMan.getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, g0_BoxSpellArea);
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 	}
 	if (champIndex == kM1_ChampionNone) {
 		champMan._g514_magicCasterChampionIndex = kM1_ChampionNone;
 		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.clearScreenBox(k0_ColorBlack, gBoxSpellArea);
+		dispMan.clearScreenBox(k0_ColorBlack, g0_BoxSpellArea);
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 		return;
 	}
 
 	champMan._g514_magicCasterChampionIndex = (ChampionIndex)champIndex;
-	buildSpellAreaLine(kSpellAreaAvailableSymbols);
+	buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 	drawSpellAreaControls((ChampionIndex)champIndex);
-	dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine2);
-	buildSpellAreaLine(kSpellAreaChampionSymbols);
-	dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine3);
+	dispMan.blitToScreen(_gK72_bitmapSpellAreaLine, 96, 0, 0, gK75_BoxSpellAreaLine2);
+	buildSpellAreaLine(k3_SpellAreaChampionSymbols);
+	dispMan.blitToScreen(_gK72_bitmapSpellAreaLine, 96, 0, 0, gK76_BoxSpellAreaLine3);
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 }
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index b591872..30bf01c 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -33,8 +33,8 @@
 
 namespace DM {
 
-extern Box gBoxActionArea; // @ G0001_s_Graphic562_Box_ActionArea
-extern Box gBoxSpellArea; // @ G0000_s_Graphic562_Box_SpellArea
+extern Box g1_BoxActionArea; // @ G0001_s_Graphic562_Box_ActionArea
+extern Box g0_BoxSpellArea; // @ G0000_s_Graphic562_Box_SpellArea
 
 class ActionList {
 public:
@@ -54,11 +54,11 @@ public:
 	explicit MenuMan(DMEngine *vm);
 	~MenuMan();
 
-	bool _refreshActionArea; // @ G0508_B_RefreshActionArea
-	bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons
-	int16 _actionDamage; // @ G0513_i_ActionDamage
-	ActionList _actionList; // @ G0713_s_ActionList
-	byte *_bitmapSpellAreaLine; // @ K0072_puc_Bitmap_SpellAreaLine
+	bool _g508_refreshActionArea; // @ G0508_B_RefreshActionArea
+	bool _g509_actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons
+	int16 _g513_actionDamage; // @ G0513_i_ActionDamage
+	ActionList _g713_actionList; // @ G0713_s_ActionList
+	byte *_gK72_bitmapSpellAreaLine; // @ K0072_puc_Bitmap_SpellAreaLine
 
 	void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
 	void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 810847c..9c3b228 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -31,9 +31,9 @@
 
 namespace DM {
 
-int16 gIconGraphicHeight[7] = {32, 32, 32, 32, 32, 32, 32}; // @ K0077_ai_IconGraphicHeight
+int16 gK77_IconGraphicHeight[7] = {32, 32, 32, 32, 32, 32, 32}; // @ K0077_ai_IconGraphicHeight
 
-int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex
+int16 g26_IconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex
 	0,     /* First icon index in graphic #42 */
 	32,    /* First icon index in graphic #43 */
 	64,    /* First icon index in graphic #44 */
@@ -44,73 +44,73 @@ int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconI
 
 ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {
 	/* 8 for champion hands in status boxes, 30 for champion inventory, 8 for chest */
-	_slotBoxes[0] = SlotBox(4, 10, 0);    /* Champion Status Box 0 Ready Hand */
-	_slotBoxes[1] = SlotBox(24, 10, 0);   /* Champion Status Box 0 Action Hand */
-	_slotBoxes[2] = SlotBox(73, 10, 0);   /* Champion Status Box 1 Ready Hand */
-	_slotBoxes[3] = SlotBox(93, 10, 0);   /* Champion Status Box 1 Action Hand */
-	_slotBoxes[4] = SlotBox(142, 10, 0);  /* Champion Status Box 2 Ready Hand */
-	_slotBoxes[5] = SlotBox(162, 10, 0);  /* Champion Status Box 2 Action Hand */
-	_slotBoxes[6] = SlotBox(211, 10, 0);  /* Champion Status Box 3 Ready Hand */
-	_slotBoxes[7] = SlotBox(231, 10, 0);  /* Champion Status Box 3 Action Hand */
-	_slotBoxes[8] = SlotBox(6, 53, 0);    /* Ready Hand */
-	_slotBoxes[9] = SlotBox(62, 53, 0);   /* Action Hand */
-	_slotBoxes[10] = SlotBox(34, 26, 0);  /* Head */
-	_slotBoxes[11] = SlotBox(34, 46, 0);  /* Torso */
-	_slotBoxes[12] = SlotBox(34, 66, 0);  /* Legs */
-	_slotBoxes[13] = SlotBox(34, 86, 0);  /* Feet */
-	_slotBoxes[14] = SlotBox(6, 90, 0);   /* Pouch 2 */
-	_slotBoxes[15] = SlotBox(79, 73, 0);  /* Quiver Line2 1 */
-	_slotBoxes[16] = SlotBox(62, 90, 0);  /* Quiver Line1 2 */
-	_slotBoxes[17] = SlotBox(79, 90, 0);  /* Quiver Line2 2 */
-	_slotBoxes[18] = SlotBox(6, 33, 0);   /* Neck */
-	_slotBoxes[19] = SlotBox(6, 73, 0);   /* Pouch 1 */
-	_slotBoxes[20] = SlotBox(62, 73, 0);  /* Quiver Line1 1 */
-	_slotBoxes[21] = SlotBox(66, 33, 0);  /* Backpack Line1 1 */
-	_slotBoxes[22] = SlotBox(83, 16, 0);  /* Backpack Line2 2 */
-	_slotBoxes[23] = SlotBox(100, 16, 0); /* Backpack Line2 3 */
-	_slotBoxes[24] = SlotBox(117, 16, 0); /* Backpack Line2 4 */
-	_slotBoxes[25] = SlotBox(134, 16, 0); /* Backpack Line2 5 */
-	_slotBoxes[26] = SlotBox(151, 16, 0); /* Backpack Line2 6 */
-	_slotBoxes[27] = SlotBox(168, 16, 0); /* Backpack Line2 7 */
-	_slotBoxes[28] = SlotBox(185, 16, 0); /* Backpack Line2 8 */
-	_slotBoxes[29] = SlotBox(202, 16, 0); /* Backpack Line2 9 */
-	_slotBoxes[30] = SlotBox(83, 33, 0);  /* Backpack Line1 2 */
-	_slotBoxes[31] = SlotBox(100, 33, 0); /* Backpack Line1 3 */
-	_slotBoxes[32] = SlotBox(117, 33, 0); /* Backpack Line1 4 */
-	_slotBoxes[33] = SlotBox(134, 33, 0); /* Backpack Line1 5 */
-	_slotBoxes[34] = SlotBox(151, 33, 0); /* Backpack Line1 6 */
-	_slotBoxes[35] = SlotBox(168, 33, 0); /* Backpack Line1 7 */
-	_slotBoxes[36] = SlotBox(185, 33, 0); /* Backpack Line1 8 */
-	_slotBoxes[37] = SlotBox(202, 33, 0); /* Backpack Line1 9 */
-	_slotBoxes[38] = SlotBox(117, 59, 0); /* Chest 1 */
-	_slotBoxes[39] = SlotBox(106, 76, 0); /* Chest 2 */
-	_slotBoxes[40] = SlotBox(111, 93, 0); /* Chest 3 */
-	_slotBoxes[41] = SlotBox(128, 98, 0); /* Chest 4 */
-	_slotBoxes[42] = SlotBox(145, 101, 0); /* Chest 5 */
-	_slotBoxes[43] = SlotBox(162, 103, 0); /* Chest 6 */
-	_slotBoxes[44] = SlotBox(179, 104, 0); /* Chest 7 */
-	_slotBoxes[45] = SlotBox(196, 105, 0); /* Chest 8 */
-
-	_objectIconForMousePointer = nullptr;
+	_g30_slotBoxes[0] = SlotBox(4, 10, 0);    /* Champion Status Box 0 Ready Hand */
+	_g30_slotBoxes[1] = SlotBox(24, 10, 0);   /* Champion Status Box 0 Action Hand */
+	_g30_slotBoxes[2] = SlotBox(73, 10, 0);   /* Champion Status Box 1 Ready Hand */
+	_g30_slotBoxes[3] = SlotBox(93, 10, 0);   /* Champion Status Box 1 Action Hand */
+	_g30_slotBoxes[4] = SlotBox(142, 10, 0);  /* Champion Status Box 2 Ready Hand */
+	_g30_slotBoxes[5] = SlotBox(162, 10, 0);  /* Champion Status Box 2 Action Hand */
+	_g30_slotBoxes[6] = SlotBox(211, 10, 0);  /* Champion Status Box 3 Ready Hand */
+	_g30_slotBoxes[7] = SlotBox(231, 10, 0);  /* Champion Status Box 3 Action Hand */
+	_g30_slotBoxes[8] = SlotBox(6, 53, 0);    /* Ready Hand */
+	_g30_slotBoxes[9] = SlotBox(62, 53, 0);   /* Action Hand */
+	_g30_slotBoxes[10] = SlotBox(34, 26, 0);  /* Head */
+	_g30_slotBoxes[11] = SlotBox(34, 46, 0);  /* Torso */
+	_g30_slotBoxes[12] = SlotBox(34, 66, 0);  /* Legs */
+	_g30_slotBoxes[13] = SlotBox(34, 86, 0);  /* Feet */
+	_g30_slotBoxes[14] = SlotBox(6, 90, 0);   /* Pouch 2 */
+	_g30_slotBoxes[15] = SlotBox(79, 73, 0);  /* Quiver Line2 1 */
+	_g30_slotBoxes[16] = SlotBox(62, 90, 0);  /* Quiver Line1 2 */
+	_g30_slotBoxes[17] = SlotBox(79, 90, 0);  /* Quiver Line2 2 */
+	_g30_slotBoxes[18] = SlotBox(6, 33, 0);   /* Neck */
+	_g30_slotBoxes[19] = SlotBox(6, 73, 0);   /* Pouch 1 */
+	_g30_slotBoxes[20] = SlotBox(62, 73, 0);  /* Quiver Line1 1 */
+	_g30_slotBoxes[21] = SlotBox(66, 33, 0);  /* Backpack Line1 1 */
+	_g30_slotBoxes[22] = SlotBox(83, 16, 0);  /* Backpack Line2 2 */
+	_g30_slotBoxes[23] = SlotBox(100, 16, 0); /* Backpack Line2 3 */
+	_g30_slotBoxes[24] = SlotBox(117, 16, 0); /* Backpack Line2 4 */
+	_g30_slotBoxes[25] = SlotBox(134, 16, 0); /* Backpack Line2 5 */
+	_g30_slotBoxes[26] = SlotBox(151, 16, 0); /* Backpack Line2 6 */
+	_g30_slotBoxes[27] = SlotBox(168, 16, 0); /* Backpack Line2 7 */
+	_g30_slotBoxes[28] = SlotBox(185, 16, 0); /* Backpack Line2 8 */
+	_g30_slotBoxes[29] = SlotBox(202, 16, 0); /* Backpack Line2 9 */
+	_g30_slotBoxes[30] = SlotBox(83, 33, 0);  /* Backpack Line1 2 */
+	_g30_slotBoxes[31] = SlotBox(100, 33, 0); /* Backpack Line1 3 */
+	_g30_slotBoxes[32] = SlotBox(117, 33, 0); /* Backpack Line1 4 */
+	_g30_slotBoxes[33] = SlotBox(134, 33, 0); /* Backpack Line1 5 */
+	_g30_slotBoxes[34] = SlotBox(151, 33, 0); /* Backpack Line1 6 */
+	_g30_slotBoxes[35] = SlotBox(168, 33, 0); /* Backpack Line1 7 */
+	_g30_slotBoxes[36] = SlotBox(185, 33, 0); /* Backpack Line1 8 */
+	_g30_slotBoxes[37] = SlotBox(202, 33, 0); /* Backpack Line1 9 */
+	_g30_slotBoxes[38] = SlotBox(117, 59, 0); /* Chest 1 */
+	_g30_slotBoxes[39] = SlotBox(106, 76, 0); /* Chest 2 */
+	_g30_slotBoxes[40] = SlotBox(111, 93, 0); /* Chest 3 */
+	_g30_slotBoxes[41] = SlotBox(128, 98, 0); /* Chest 4 */
+	_g30_slotBoxes[42] = SlotBox(145, 101, 0); /* Chest 5 */
+	_g30_slotBoxes[43] = SlotBox(162, 103, 0); /* Chest 6 */
+	_g30_slotBoxes[44] = SlotBox(179, 104, 0); /* Chest 7 */
+	_g30_slotBoxes[45] = SlotBox(196, 105, 0); /* Chest 8 */
+
+	_g412_objectIconForMousePointer = nullptr;
 }
 
 ObjectMan::~ObjectMan() {
-	delete[] _objectIconForMousePointer;
-	delete[] _objectNames[0];
+	delete[] _g412_objectIconForMousePointer;
+	delete[] _g352_objectNames[0];
 }
 
-#define kObjectNamesGraphicIndice 556 // @ C556_GRAPHIC_OBJECT_NAMES
+#define k556_ObjectNamesGraphicIndice 556 // @ C556_GRAPHIC_OBJECT_NAMES
 
 void ObjectMan::loadObjectNames() {
 	DisplayMan &dispMan = *_vm->_displayMan;
 
-	_objectIconForMousePointer = new byte[16 * 16];
+	_g412_objectIconForMousePointer = new byte[16 * 16];
 
-	char *objectNames = new char[dispMan.getCompressedDataSize(kObjectNamesGraphicIndice) + kObjectNameCount];
-	Common::MemoryReadStream stream = dispMan.getCompressedData(kObjectNamesGraphicIndice);
+	char *objectNames = new char[dispMan.getCompressedDataSize(k556_ObjectNamesGraphicIndice) + k199_ObjectNameCount];
+	Common::MemoryReadStream stream = dispMan.getCompressedData(k556_ObjectNamesGraphicIndice);
 
-	for (uint16 objNameIndex = 0; objNameIndex < kObjectNameCount; ++objNameIndex) {
-		_objectNames[objNameIndex] = objectNames;
+	for (uint16 objNameIndex = 0; objNameIndex < k199_ObjectNameCount; ++objNameIndex) {
+		_g352_objectNames[objNameIndex] = objectNames;
 
 		byte tmpByte;
 		for (tmpByte = stream.readByte(); !(tmpByte & 0x80); tmpByte = stream.readByte()) // last char of object name has 7th bit on
@@ -132,7 +132,7 @@ IconIndice ObjectMan::getObjectType(Thing thing) {
 	return (IconIndice)objectInfoIndex;
 }
 
-byte gChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType
+byte g29_ChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType
 
 IconIndice ObjectMan::getIconIndex(Thing thing) {
 	IconIndice iconIndex = getObjectType(thing);
@@ -150,7 +150,7 @@ IconIndice ObjectMan::getIconIndex(Thing thing) {
 		case k4_IconIndiceWeaponTorchUnlit: {
 			Weapon weapon(rawType);
 			if (weapon.isLit()) {
-				iconIndex = (IconIndice)(iconIndex + gChargeCountToTorchType[weapon.getChargeCount()]);
+				iconIndex = (IconIndice)(iconIndex + g29_ChargeCountToTorchType[weapon.getChargeCount()]);
 			}
 			break;
 		}
@@ -187,19 +187,19 @@ IconIndice ObjectMan::getIconIndex(Thing thing) {
 void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 	int16 i;
 	for (i = 0; i < 7; ++i) {
-		if (gIconGraphicFirstIndex[i] > iconIndex)
+		if (g26_IconGraphicFirstIndex[i] > iconIndex)
 			break;
 	}
 
 	--i;
 	byte *srcBitmap = _vm->_displayMan->getBitmap(k42_ObjectIcons_000_TO_031 + i);
-	iconIndex -= gIconGraphicFirstIndex[i];
+	iconIndex -= g26_IconGraphicFirstIndex[i];
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
 	_vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, 0, 16, 0, 16, k255_ColorNoTransparency);
 }
 
 void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
-	SlotBox *slotBox = &_slotBoxes[slotBoxIndex];
+	SlotBox *slotBox = &_g30_slotBoxes[slotBoxIndex];
 	slotBox->_iconIndex = iconIndex; // yes, this modifies the global array
 	if (slotBox->_iconIndex == kM1_IconIndiceNone) {
 		return;
@@ -213,16 +213,16 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 
 	uint16 iconGraphicIndex;
 	for (iconGraphicIndex = 0; iconGraphicIndex < 7; ++iconGraphicIndex) {
-		if (gIconGraphicFirstIndex[iconGraphicIndex] > iconIndex) {
+		if (g26_IconGraphicFirstIndex[iconGraphicIndex] > iconIndex) {
 			break;
 		}
 	}
 	iconGraphicIndex--;
 	byte *iconsBitmap = _vm->_displayMan->getBitmap(iconGraphicIndex + k42_ObjectIcons_000_TO_031);
-	iconIndex -= gIconGraphicFirstIndex[iconGraphicIndex];
+	iconIndex -= g26_IconGraphicFirstIndex[iconGraphicIndex];
 
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	if (slotBoxIndex >= kSlotBoxInventoryFirstSlot) {
+	if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) {
 		_vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
 									   box, k255_ColorNoTransparency, g296_DungeonViewport);
 	} else {
@@ -231,7 +231,7 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 	}
 }
 
-#define kObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH
+#define k14_ObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH
 
 void ObjectMan::drawLeaderObjectName(Thing thing) {
 	IconIndice iconIndex = getIconIndex(thing);
@@ -240,15 +240,15 @@ void ObjectMan::drawLeaderObjectName(Thing thing) {
 	if (iconIndex == k147_IconIndiceJunkChampionBones) {
 		Junk *junk = (Junk*)_vm->_dungeonMan->getThingData(thing);
 		strcpy(objectNameBuffer, _vm->_championMan->_champions[junk->getChargeCount()]._name);
-		strcat(objectNameBuffer, _objectNames[iconIndex]);
+		strcat(objectNameBuffer, _g352_objectNames[iconIndex]);
 		objName = objectNameBuffer;
 	} else {
-		objName = _objectNames[iconIndex];
+		objName = _g352_objectNames[iconIndex];
 	}
-	_vm->_textMan->printWithTrailingSpacesToScreen(233, 37, k4_ColorCyan, k0_ColorBlack, objName, kObjectNameMaximumLength);
+	_vm->_textMan->printWithTrailingSpacesToScreen(233, 37, k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength);
 }
 
 IconIndice ObjectMan::getIconIndexInSlotBox(uint16 slotBoxIndex) {
-	return (IconIndice)_slotBoxes[slotBoxIndex]._iconIndex;
+	return (IconIndice)_g30_slotBoxes[slotBoxIndex]._iconIndex;
 }
 }
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index f075076..f0d2bed 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -31,11 +31,11 @@
 
 namespace DM {
 
-#define kSlotBoxInventoryFirstSlot 8 // @ C08_SLOT_BOX_INVENTORY_FIRST_SLOT   
-#define kSlotBoxInventoryActionHand 9 // @ C09_SLOT_BOX_INVENTORY_ACTION_HAND  
-#define kSlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT      
+#define k8_SlotBoxInventoryFirstSlot 8 // @ C08_SLOT_BOX_INVENTORY_FIRST_SLOT   
+#define k9_SlotBoxInventoryActionHand 9 // @ C09_SLOT_BOX_INVENTORY_ACTION_HAND  
+#define k38_SlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT      
 
-#define kObjectNameCount 199 // @ C199_OBJECT_NAME_COUNT
+#define k199_ObjectNameCount 199 // @ C199_OBJECT_NAME_COUNT
 
 class SlotBox {
 public:
@@ -54,9 +54,9 @@ public:
 	~ObjectMan();
 	void loadObjectNames();	// @ F0031_OBJECT_LoadNames
 
-	SlotBox _slotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes;
-	char *_objectNames[kObjectNameCount]; // @ G0352_apc_ObjectNames
-	byte *_objectIconForMousePointer; // @ G0412_puc_Bitmap_ObjectIconForMousePointer
+	SlotBox _g30_slotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes;
+	char *_g352_objectNames[k199_ObjectNameCount]; // @ G0352_apc_ObjectNames
+	byte *_g412_objectIconForMousePointer; // @ G0412_puc_Bitmap_ObjectIconForMousePointer
 
 	IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType
 	IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 8f4e04c..f526faa 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -32,8 +32,8 @@ namespace DM {
 
 TextMan::TextMan(DMEngine* vm) : _vm(vm) {}
 
-#define kLetterWidth 5
-#define kLetterHeight 6
+#define k5_LetterWidth 5
+#define k6_LetterHeight 6
 
 void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY,
 								Color textColor, Color bgColor, const char* text, uint16 destHeight, Viewport &viewport) {
@@ -46,22 +46,22 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16
 	byte *srcBitmap = _vm->_displayMan->getBitmap(k557_FontGraphicIndice);
 
 	byte *tmp = _vm->_displayMan->_g74_tmpBitmap;
-	for (uint16 i = 0; i < (kLetterWidth + 1) * kLetterHeight * 128; ++i) {
+	for (uint16 i = 0; i < (k5_LetterWidth + 1) * k6_LetterHeight * 128; ++i) {
 		tmp[i] = srcBitmap[i] ? textColor : bgColor;
 	}
 	srcBitmap = tmp;
 
 	for (const char *begin = text, *end = text + textLength; begin != end; ++begin) {
-		if (nextX + kLetterWidth + 1 >= (viewport._posX + viewport._width) || (*begin == '\n')) {
+		if (nextX + k5_LetterWidth + 1 >= (viewport._posX + viewport._width) || (*begin == '\n')) {
 			nextX = destX;
-			nextY += kLetterHeight + 1;
+			nextY += k6_LetterHeight + 1;
 		}
-		if (nextY + kLetterHeight >= (viewport._posY + viewport._height))
+		if (nextY + k6_LetterHeight >= (viewport._posY + viewport._height))
 			break;
 		uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
 		_vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth,
-			(nextX == destX) ? (nextX + 1) : nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight, k255_ColorNoTransparency, viewport);
-		nextX += kLetterWidth + 1;
+			(nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight, k255_ColorNoTransparency, viewport);
+		nextX += k5_LetterWidth + 1;
 	}
 }
 
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 101fcca..d9e7806 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -32,23 +32,23 @@
 namespace DM {
 
 Timeline::Timeline(DMEngine* vm) : _vm(vm) {
-	_events = nullptr;
-	_timeline = nullptr;
+	_g370_events = nullptr;
+	_g371_timeline = nullptr;
 }
 
 Timeline::~Timeline() {
-	delete[] _events;
-	delete[] _timeline;
+	delete[] _g370_events;
+	delete[] _g371_timeline;
 }
 
 void Timeline::initTimeline() {
-	_events = new TimelineEvent[_eventMaxCount];
-	_timeline = new uint16[_eventMaxCount];
+	_g370_events = new TimelineEvent[_g369_eventMaxCount];
+	_g371_timeline = new uint16[_g369_eventMaxCount];
 	if (_vm->_dungeonMan->_messages._g298_newGame) {
-		for (int16 i = 0; i < _eventMaxCount; ++i)
-			_events->_type = kTMEventTypeNone;
-		_eventCount = 0;
-		_firstUnusedEventIndex = 0;
+		for (int16 i = 0; i < _g369_eventMaxCount; ++i)
+			_g370_events->_type = k0_TMEventTypeNone;
+		_g372_eventCount = 0;
+		_g373_firstUnusedEventIndex = 0;
 	}
 }
 
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index f773530..47d339e 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -35,62 +35,62 @@ namespace DM {
 /* Event types */
 enum TimelineEventType {
 /* Used when a creature in a group was damaged or killed by a Poison Cloud or by a closing door or if Lord Chaos is surrounded by = 3, Fluxcages */
-kTMEventTypeCreateReactionEvent29DangerOnSquare = 253, // @ CM3_EVENT_CREATE_REACTION_EVENT_29_DANGER_ON_SQUARE 
+kM3_TMEventTypeCreateReactionEvent29DangerOnSquare = -3, // @ CM3_EVENT_CREATE_REACTION_EVENT_29_DANGER_ON_SQUARE 
 /* Used when a projectile impacts with a creature in a group */
-kTMEventTypeCreateReactionEvent30HitByProjectile = 254, // @ CM2_EVENT_CREATE_REACTION_EVENT_30_HIT_BY_PROJECTILE
+kM2_TMEventTypeCreateReactionEvent30HitByProjectile = -2, // @ CM2_EVENT_CREATE_REACTION_EVENT_30_HIT_BY_PROJECTILE
 /* Used when the party bumps into a group or performs a melee attack */
-kTMEventTypeCreateReactionEvent31ParyIsAdjacent = 255,  // @ CM1_EVENT_CREATE_REACTION_EVENT_31_PARTY_IS_ADJACENT
-kTMEventTypeNone = 0, // @ C00_EVENT_NONE                                       
-kTMEventTypeDoorAnimation = 1, // @ C01_EVENT_DOOR_ANIMATION                             
-kTMEventTypeDoorDestruction = 2, // @ C02_EVENT_DOOR_DESTRUCTION                           
-kTMEventTypeCorridor = 5, // @ C05_EVENT_CORRIDOR                                   
-kTMEventTypeWall = 6, // @ C06_EVENT_WALL                                       
-kTMEventTypeFakeWall = 7, // @ C07_EVENT_FAKEWALL                                   
-kTMEventTypeTeleporter = 8, // @ C08_EVENT_TELEPORTER                                 
-kTMEventTypePit = 9, // @ C09_EVENT_PIT                                        
-kTMEventTypeDoor = 10, // @ C10_EVENT_DOOR                                      
-kTMEventTypeEnableChampionAction = 11, // @ C11_EVENT_ENABLE_CHAMPION_ACTION                    
-kTMEventTypeHideDamageReceived = 12, // @ C12_EVENT_HIDE_DAMAGE_RECEIVED                      
-kTMEventTypeViAltarRebirth = 13, // @ C13_EVENT_VI_ALTAR_REBIRTH                          
-kTMEventTypePlaySound = 20, // @ C20_EVENT_PLAY_SOUND                                
-kTMEventTypeCPSE = 22, // @ C22_EVENT_CPSE                                      
-kTMEventTypeRemoveFluxcage = 24, // @ C24_EVENT_REMOVE_FLUXCAGE                           
-kTMEventTypeExplosion = 25, // @ C25_EVENT_EXPLOSION                                 
-kTMEventTypeGroupReactionDangerOnSquare = 29, // @ C29_EVENT_GROUP_REACTION_DANGER_ON_SQUARE           
-kTMEventTypeGroupReacionHitByProjectile = 30, // @ C30_EVENT_GROUP_REACTION_HIT_BY_PROJECTILE          
-kTMEventTypeGroupReactionPartyIsAdjecent = 31, // @ C31_EVENT_GROUP_REACTION_PARTY_IS_ADJACENT          
-kTMEventTypeUpdateAspectGroup = 32, // @ C32_EVENT_UPDATE_ASPECT_GROUP                       
+kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent = -1,  // @ CM1_EVENT_CREATE_REACTION_EVENT_31_PARTY_IS_ADJACENT
+k0_TMEventTypeNone = 0, // @ C00_EVENT_NONE                                       
+k1_TMEventTypeDoorAnimation = 1, // @ C01_EVENT_DOOR_ANIMATION                             
+k2_TMEventTypeDoorDestruction = 2, // @ C02_EVENT_DOOR_DESTRUCTION                           
+k5_TMEventTypeCorridor = 5, // @ C05_EVENT_CORRIDOR                                   
+k6_TMEventTypeWall = 6, // @ C06_EVENT_WALL                                       
+k7_TMEventTypeFakeWall = 7, // @ C07_EVENT_FAKEWALL                                   
+k8_TMEventTypeTeleporter = 8, // @ C08_EVENT_TELEPORTER                                 
+k9_TMEventTypePit = 9, // @ C09_EVENT_PIT                                        
+k10_TMEventTypeDoor = 10, // @ C10_EVENT_DOOR                                      
+k11_TMEventTypeEnableChampionAction = 11, // @ C11_EVENT_ENABLE_CHAMPION_ACTION                    
+k12_TMEventTypeHideDamageReceived = 12, // @ C12_EVENT_HIDE_DAMAGE_RECEIVED                      
+k13_TMEventTypeViAltarRebirth = 13, // @ C13_EVENT_VI_ALTAR_REBIRTH                          
+k20_TMEventTypePlaySound = 20, // @ C20_EVENT_PLAY_SOUND                                
+k22_TMEventTypeCPSE = 22, // @ C22_EVENT_CPSE                                      
+k24_TMEventTypeRemoveFluxcage = 24, // @ C24_EVENT_REMOVE_FLUXCAGE                           
+k25_TMEventTypeExplosion = 25, // @ C25_EVENT_EXPLOSION                                 
+k29_TMEventTypeGroupReactionDangerOnSquare = 29, // @ C29_EVENT_GROUP_REACTION_DANGER_ON_SQUARE           
+k30_TMEventTypeGroupReacionHitByProjectile = 30, // @ C30_EVENT_GROUP_REACTION_HIT_BY_PROJECTILE          
+k31_TMEventTypeGroupReactionPartyIsAdjecent = 31, // @ C31_EVENT_GROUP_REACTION_PARTY_IS_ADJACENT          
+k32_TMEventTypeUpdateAspectGroup = 32, // @ C32_EVENT_UPDATE_ASPECT_GROUP                       
 /* Events = 33,-36 and = 38,-41 are used for individual creatures only while the group is attacking the party */
-kTMEventTypeUpdateAspectCreature_0 = 33,  // @ C33_EVENT_UPDATE_ASPECT_CREATURE_0                  
-kTMEventTypeUpdateAspectCreature_1 = 34, // @ C34_EVENT_UPDATE_ASPECT_CREATURE_1                  
-kTMEventTypeUpdateAspectCreature_2 = 35, // @ C35_EVENT_UPDATE_ASPECT_CREATURE_2                  
-kTMEventTypeUpdateAspectCreature_3 = 36, // @ C36_EVENT_UPDATE_ASPECT_CREATURE_3                  
-kTMEventTypeUpdateBehaviourGroup = 37, // @ C37_EVENT_UPDATE_BEHAVIOR_GROUP                     
-kTMEventTypeUpdateBehaviour_0 = 38, // @ C38_EVENT_UPDATE_BEHAVIOR_CREATURE_0                
-kTMEventTypeUpdateBehaviour_1 = 39, // @ C39_EVENT_UPDATE_BEHAVIOR_CREATURE_1                
-kTMEventTypeUpdateBehaviour_2 = 40, // @ C40_EVENT_UPDATE_BEHAVIOR_CREATURE_2                
-kTMEventTypeUpdateBehaviour_3 = 41, // @ C41_EVENT_UPDATE_BEHAVIOR_CREATURE_3                
+k33_TMEventTypeUpdateAspectCreature_0 = 33,  // @ C33_EVENT_UPDATE_ASPECT_CREATURE_0                  
+k34_TMEventTypeUpdateAspectCreature_1 = 34, // @ C34_EVENT_UPDATE_ASPECT_CREATURE_1                  
+k35_TMEventTypeUpdateAspectCreature_2 = 35, // @ C35_EVENT_UPDATE_ASPECT_CREATURE_2                  
+k36_TMEventTypeUpdateAspectCreature_3 = 36, // @ C36_EVENT_UPDATE_ASPECT_CREATURE_3                  
+k37_TMEventTypeUpdateBehaviourGroup = 37, // @ C37_EVENT_UPDATE_BEHAVIOR_GROUP                     
+k38_TMEventTypeUpdateBehaviour_0 = 38, // @ C38_EVENT_UPDATE_BEHAVIOR_CREATURE_0                
+k39_TMEventTypeUpdateBehaviour_1 = 39, // @ C39_EVENT_UPDATE_BEHAVIOR_CREATURE_1                
+k40_TMEventTypeUpdateBehaviour_2 = 40, // @ C40_EVENT_UPDATE_BEHAVIOR_CREATURE_2                
+k41_TMEventTypeUpdateBehaviour_3 = 41, // @ C41_EVENT_UPDATE_BEHAVIOR_CREATURE_3                
 /* Projectiles created by a champion (by casting a spell, shooting a weapon or throwing an object) or by a creature (by casting a spell) ignore impacts during their first movement otherwise an impact would always occur immediately as these projectiles are created on the champion or creature square */
-kTMEventTypeMoveProjectileIgnoreImpacts = 48, // @ C48_EVENT_MOVE_PROJECTILE_IGNORE_IMPACTS            
+k48_TMEventTypeMoveProjectileIgnoreImpacts = 48, // @ C48_EVENT_MOVE_PROJECTILE_IGNORE_IMPACTS            
 /* Projectiles created by projectile launcher sensors never ignore impacts as well as all other projectiles after their first movement */
-kTMEventTypeMoveProjectile = 49,  // @ C49_EVENT_MOVE_PROJECTILE                           
-kTMEventTypeWatchdoge = 53, // @ C53_EVENT_WATCHDOG                                  
-kTMEventTypeMoveGroupSilent = 60, // @ C60_EVENT_MOVE_GROUP_SILENT                         
-kTMEventTypeMoveGroupAudible = 61, // @ C61_EVENT_MOVE_GROUP_AUDIBLE                        
-kTMEventTypeEnableGroupGenerator = 65, // @ C65_EVENT_ENABLE_GROUP_GENERATOR                    
-kTMEventTypeLight = 70, // @ C70_EVENT_LIGHT                                     
-kTMEventTypeInvisibility = 71, // @ C71_EVENT_INVISIBILITY                              
-kTMEventTypeChampionShield = 72, // @ C72_EVENT_CHAMPION_SHIELD                           
-kTMEventTypeThievesEye = 73, // @ C73_EVENT_THIEVES_EYE                               
-kTMEventTypePartyShield = 74, // @ C74_EVENT_PARTY_SHIELD                              
-kTMEventTypePoisonChampion = 75, // @ C75_EVENT_POISON_CHAMPION                           
-kTMEventTypeSpellShield = 77, // @ C77_EVENT_SPELLSHIELD                               
-kTMEventTypeFireShield = 78, // @ C78_EVENT_FIRESHIELD                                
-kTMEventTypeFootprints = 79, // @ C79_EVENT_FOOTPRINTS                                
-kTMEventTypeMagicMap_C80 = 80, // @ C80_EVENT_MAGIC_MAP                                 
-kTMEventTypeMagicMap_C81 = 81, // @ C81_EVENT_MAGIC_MAP                                 
-kTMEventTypeMagicMap_C82 = 82, // @ C82_EVENT_MAGIC_MAP                                 
-kTMEventTypeMagicMap_C83 = 83  // @ C83_EVENT_MAGIC_MAP    
+k49_TMEventTypeMoveProjectile = 49,  // @ C49_EVENT_MOVE_PROJECTILE                           
+k53_TMEventTypeWatchdoge = 53, // @ C53_EVENT_WATCHDOG                                  
+k60_TMEventTypeMoveGroupSilent = 60, // @ C60_EVENT_MOVE_GROUP_SILENT                         
+k61_TMEventTypeMoveGroupAudible = 61, // @ C61_EVENT_MOVE_GROUP_AUDIBLE                        
+k65_TMEventTypeEnableGroupGenerator = 65, // @ C65_EVENT_ENABLE_GROUP_GENERATOR                    
+k70_TMEventTypeLight = 70, // @ C70_EVENT_LIGHT                                     
+k71_TMEventTypeInvisibility = 71, // @ C71_EVENT_INVISIBILITY                              
+k72_TMEventTypeChampionShield = 72, // @ C72_EVENT_CHAMPION_SHIELD                           
+k73_TMEventTypeThievesEye = 73, // @ C73_EVENT_THIEVES_EYE                               
+k74_TMEventTypePartyShield = 74, // @ C74_EVENT_PARTY_SHIELD                              
+k75_TMEventTypePoisonChampion = 75, // @ C75_EVENT_POISON_CHAMPION                           
+k77_TMEventTypeSpellShield = 77, // @ C77_EVENT_SPELLSHIELD                               
+k78_TMEventTypeFireShield = 78, // @ C78_EVENT_FIRESHIELD                                
+k79_TMEventTypeFootprints = 79, // @ C79_EVENT_FOOTPRINTS                                
+k80_TMEventTypeMagicMap_C80 = 80, // @ C80_EVENT_MAGIC_MAP                                 
+k81_TMEventTypeMagicMap_C81 = 81, // @ C81_EVENT_MAGIC_MAP                                 
+k82_TMEventTypeMagicMap_C82 = 82, // @ C82_EVENT_MAGIC_MAP                                 
+k83_TMEventTypeMagicMap_C83 = 83  // @ C83_EVENT_MAGIC_MAP    
 };
 
 class TimelineEvent {
@@ -145,11 +145,11 @@ public:
 class Timeline {
 	DMEngine *_vm;
 public:
-	uint16 _eventMaxCount; // @ G0369_ui_EventMaximumCount
-	TimelineEvent *_events; // @ G0370_ps_Events
-	uint16 _eventCount; // @ G0372_ui_EventCount 
-	uint16 *_timeline; // @ G0371_pui_Timeline
-	uint16 _firstUnusedEventIndex; // @ G0373_ui_FirstUnusedEventIndex
+	uint16 _g369_eventMaxCount; // @ G0369_ui_EventMaximumCount
+	TimelineEvent *_g370_events; // @ G0370_ps_Events
+	uint16 _g372_eventCount; // @ G0372_ui_EventCount 
+	uint16 *_g371_timeline; // @ G0371_pui_Timeline
+	uint16 _g373_firstUnusedEventIndex; // @ G0373_ui_FirstUnusedEventIndex
 
 	Timeline(DMEngine *vm);
 	~Timeline();


Commit: 46b9b1100ef315e4a29edda864204a2e74e9f725
    https://github.com/scummvm/scummvm/commit/46b9b1100ef315e4a29edda864204a2e74e9f725
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor DungeonMan

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/group.cpp
    engines/dm/loadsave.cpp
    engines/dm/objectman.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 17ee181..5a85434 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -437,7 +437,7 @@ ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
 }
 
 void ChampionMan::resetDataToStartGame() {
-	if (!_vm->_dungeonMan->_messages._g298_newGame) {
+	if (!_vm->_g298_newGame) {
 		warning("MISSING CODE: stuff for resetting for loaded games");
 		assert(false);
 	}
@@ -468,20 +468,20 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	champ->_actionIndex = k255_ChampionActionNone;
 	champ->_enableActionEventIndex = -1;
 	champ->_hideDamageReceivedIndex = -1;
-	champ->_dir = dunMan._currMap._g308_partyDir;
+	champ->_dir = dunMan._g308_partyDir;
 	ViewCell AL_0_viewCell = k0_ViewCellFronLeft;
-	while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._g308_partyDir) & 3)) != kM1_ChampionNone)
+	while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3)) != kM1_ChampionNone)
 		AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
-	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._g308_partyDir) & 3);
+	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3);
 	champ->clearAttributes(k0x0400_ChampionAttributeIcon);
-	champ->_directionMaximumDamageReceived = dunMan._currMap._g308_partyDir;
+	champ->_directionMaximumDamageReceived = dunMan._g308_partyDir;
 	champ->_food = 1500 + _vm->_rnd->getRandomNumber(256);
 	champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
 	int16 AL_0_slotIndex_Red;
 	for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) {
 		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none);
 	}
-	Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._g306_partyPosX, dunMan._currMap._g307_partyPosY);
+	Thing thing = dunMan.getSquareFirstThing(dunMan._g306_partyMapX, dunMan._g307_partyMapY);
 	while (thing.getType() != k2_TextstringType) {
 		thing = dunMan.getNextThing(thing);
 	}
@@ -557,12 +557,12 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 		_vm->_menuMan->drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1));
 	}
 
-	int16 mapX = _vm->_dungeonMan->_currMap._g306_partyPosX;
-	int16 mapY = _vm->_dungeonMan->_currMap._g307_partyPosY;
+	int16 mapX = _vm->_dungeonMan->_g306_partyMapX;
+	int16 mapY = _vm->_dungeonMan->_g307_partyMapY;
 
-	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._g308_partyDir));
-	mapX += _vm->_dirIntoStepCountEast[dunMan._currMap._g308_partyDir];
-	mapY += _vm->_dirIntoStepCountNorth[dunMan._currMap._g308_partyDir];
+	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._g308_partyDir));
+	mapX += _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
+	mapY += _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
 	thing = dunMan.getSquareFirstThing(mapX, mapY);
 	AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1;
 	uint16 slotIndex_Green;
@@ -850,11 +850,11 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	}
 
 	{ // block so goto won't skip AL_0_championIconIndex initialization 
-		int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._g308_partyDir);
+		int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_g308_partyDir);
 
 		if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) {
 			dispMan.clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]);
-			dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._g308_partyDir) * 19, 0,
+			dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0,
 								 g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray);
 		}
 	}
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 5c854d5..a32f059 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -179,9 +179,9 @@ void DMEngine::startGame() {
 	_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
 	warning("MISSING CODE: set primary/secondary keyboard input");
 
-	processNewPartyMap(_dungeonMan->_currMap._g309_currPartyMapIndex);
+	processNewPartyMap(_dungeonMan->_g309_partyMapIndex);
 
-	if (!_dungeonMan->_messages._g298_newGame) {
+	if (!_g298_newGame) {
 		warning("TODO: loading game");
 	} else {
 		_displayMan->_g578_useByteBoxCoordinates = false;
@@ -233,9 +233,9 @@ Common::Error DMEngine::run() {
 
 void DMEngine::gameloop() {
 	warning("DUMMY CODE SETTING PARTY POS AND DIRECTION");
-	_dungeonMan->_currMap._g306_partyPosX = 10;
-	_dungeonMan->_currMap._g307_partyPosY = 4;
-	_dungeonMan->_currMap._g308_partyDir = kDirNorth;
+	_dungeonMan->_g306_partyMapX = 10;
+	_dungeonMan->_g307_partyMapY = 4;
+	_dungeonMan->_g308_partyDir = kDirNorth;
 
 
 	warning("DUMMY CODE: setting InventoryMan::_g432_inventoryChampionOrdinal to zero");
@@ -254,7 +254,7 @@ void DMEngine::gameloop() {
 		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
 			Box box(0, 224, 0, 126);
 			_displayMan->clearScreenBox(k0_ColorBlack, box, g296_DungeonViewport); // dummy code
-			_displayMan->drawDungeon(_dungeonMan->_currMap._g308_partyDir, _dungeonMan->_currMap._g306_partyPosX, _dungeonMan->_currMap._g307_partyPosY);
+			_displayMan->drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
 		}
 		// DUMMY CODE: next line
 		_menuMan->drawMovementArrows();
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 4505c74..f627fcc 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -168,6 +168,10 @@ public:
 	GroupMan *_groupMan;
 	Timeline *_timeline;
 
+
+	bool _g298_newGame; // @ G0298_B_NewGame
+	bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested
+
 	bool _g321_stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput
 	bool _g301_gameTimeTicking; // @ G0301_B_GameTimeTicking
 	bool _g524_restartGameAllowed; // @ G0524_B_RestartGameAllowed
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index df61b45..d75e92b 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -368,51 +368,51 @@ void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, in
 	posY += _vm->_dirIntoStepCountNorth[dir] * stepsRight;
 }
 
-DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _g277_maps(NULL), _g276_rawMapData(NULL) {
-	_dunData._g282_columCount = 0;
+DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _g277_dungeonMaps(NULL), _g276_dungeonRawMapData(NULL) {
+	_g282_dungeonColumCount = 0;
 
-	_dunData._g281_mapsFirstColumnIndex = nullptr;
-	_dunData._g280_columnsCumulativeSquareThingCount = nullptr;
-	_dunData._g283_squareFirstThings = nullptr;
-	_dunData._g260_textData = nullptr;
-	_dunData._g279_mapData = nullptr;
+	_g281_dungeonMapsFirstColumnIndex = nullptr;
+	_g280_dungeonColumnsCumulativeSquareThingCount = nullptr;
+	_g283_squareFirstThings = nullptr;
+	_g260_dungeonTextData = nullptr;
+	_g279_dungeonMapData = nullptr;
 
 	for (int i = 0; i < 16; i++)
-		_dunData._g284_thingsData[i] = nullptr;
+		_g284_thingData[i] = nullptr;
 
-	_currMap._g308_partyDir = kDirNorth;
-	_currMap._g306_partyPosX = 0;
-	_currMap._g307_partyPosY = 0;
-	_currMap._g309_currPartyMapIndex = 0;
-	_currMap._g272_index = 0;
-	_currMap._g273_width = 0;
-	_currMap._g274_height = 0;
+	_g308_partyDir = kDirNorth;
+	_g306_partyMapX = 0;
+	_g307_partyMapY = 0;
+	_g309_partyMapIndex = 0;
+	_g272_currMapIndex = 0;
+	_g273_currMapWidth = 0;
+	_g274_currMapHeight = 0;
 
-	_currMap._g271_data = nullptr;
-	_currMap._g269_map = nullptr;
-	_currMap._g270_colCumulativeSquareFirstThingCount = nullptr;
+	_g271_currMapData = nullptr;
+	_g269_currMap = nullptr;
+	_g270_currMapColCumulativeSquareFirstThingCount = nullptr;
 
-	_messages._g298_newGame = true;
-	_messages._g523_restartGameRequest = false;
+	_vm->_g298_newGame = true;
+	_vm->_g523_restartGameRequest = false;
 
 	_rawDunFileDataSize = 0;
 	_rawDunFileData = nullptr;
 
-	_g278_fileHeader._dungeonId = 0;
-	_g278_fileHeader._ornamentRandomSeed = 0;
-	_g278_fileHeader._rawMapDataSize = 0;
-	_g278_fileHeader._mapCount = 0;
-	_g278_fileHeader._textDataWordCount = 0;
-	_g278_fileHeader._partyStartDir = kDirNorth;
-	_g278_fileHeader._partyStartPosX = 0;
-	_g278_fileHeader._partyStartPosY = 0;
-	_g278_fileHeader._squareFirstThingCount = 0;
+	_g278_dungeonFileHeader._dungeonId = 0;
+	_g278_dungeonFileHeader._ornamentRandomSeed = 0;
+	_g278_dungeonFileHeader._rawMapDataSize = 0;
+	_g278_dungeonFileHeader._mapCount = 0;
+	_g278_dungeonFileHeader._textDataWordCount = 0;
+	_g278_dungeonFileHeader._partyStartDir = kDirNorth;
+	_g278_dungeonFileHeader._partyStartPosX = 0;
+	_g278_dungeonFileHeader._partyStartPosY = 0;
+	_g278_dungeonFileHeader._squareFirstThingCount = 0;
 
 	for (int i = 0; i < 16; i++)
-		_g278_fileHeader._thingCounts[i] = 0;
+		_g278_dungeonFileHeader._thingCounts[i] = 0;
 
-	_g277_maps = nullptr;
-	_g276_rawMapData = nullptr;
+	_g277_dungeonMaps = nullptr;
+	_g276_dungeonRawMapData = nullptr;
 
 	_g265_currMapInscriptionWallOrnIndex = 0;
 	_g286_isFacingAlcove = false;
@@ -425,16 +425,16 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL
 
 DungeonMan::~DungeonMan() {
 	delete[] _rawDunFileData;
-	delete[] _g277_maps;
-	delete[] _dunData._g281_mapsFirstColumnIndex;
-	delete[] _dunData._g280_columnsCumulativeSquareThingCount;
-	delete[] _dunData._g283_squareFirstThings;
-	delete[] _dunData._g260_textData;
-	delete[] _dunData._g279_mapData;
+	delete[] _g277_dungeonMaps;
+	delete[] _g281_dungeonMapsFirstColumnIndex;
+	delete[] _g280_dungeonColumnsCumulativeSquareThingCount;
+	delete[] _g283_squareFirstThings;
+	delete[] _g260_dungeonTextData;
+	delete[] _g279_dungeonMapData;
 	for (uint16 i = 0; i < 16; ++i) {
-		if (_dunData._g284_thingsData[i])
-			delete[] _dunData._g284_thingsData[i][0];
-		delete[] _dunData._g284_thingsData[i];
+		if (_g284_thingData[i])
+			delete[] _g284_thingData[i][0];
+		delete[] _g284_thingData[i];
 	}
 }
 
@@ -551,177 +551,177 @@ const Thing Thing::_explRebirthStep2(0xFFE5); // @ C0xFFE5_THING_EXPLOSION_REBIR
 const Thing Thing::_party(0xFFFF); // @ C0xFFFF_THING_PARTY          
 
 void DungeonMan::loadDungeonFile() {
-	if (_messages._g298_newGame)
+	if (_vm->_g298_newGame)
 		decompressDungeonFile();
 
 	Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO);
 
-	// initialize _g278_fileHeader
-	_g278_fileHeader._dungeonId = _g278_fileHeader._ornamentRandomSeed = dunDataStream.readUint16BE();
-	_g278_fileHeader._rawMapDataSize = dunDataStream.readUint16BE();
-	_g278_fileHeader._mapCount = dunDataStream.readByte();
+	// initialize _g278_dungeonFileHeader
+	_g278_dungeonFileHeader._dungeonId = _g278_dungeonFileHeader._ornamentRandomSeed = dunDataStream.readUint16BE();
+	_g278_dungeonFileHeader._rawMapDataSize = dunDataStream.readUint16BE();
+	_g278_dungeonFileHeader._mapCount = dunDataStream.readByte();
 	dunDataStream.readByte(); // discard 1 byte
-	_g278_fileHeader._textDataWordCount = dunDataStream.readUint16BE();
+	_g278_dungeonFileHeader._textDataWordCount = dunDataStream.readUint16BE();
 	uint16 partyPosition = dunDataStream.readUint16BE();
-	_g278_fileHeader._partyStartDir = (direction)((partyPosition >> 10) & 3);
-	_g278_fileHeader._partyStartPosY = (partyPosition >> 5) & 0x1F;
-	_g278_fileHeader._partyStartPosX = (partyPosition >> 0) & 0x1F;
-	_g278_fileHeader._squareFirstThingCount = dunDataStream.readUint16BE();
+	_g278_dungeonFileHeader._partyStartDir = (direction)((partyPosition >> 10) & 3);
+	_g278_dungeonFileHeader._partyStartPosY = (partyPosition >> 5) & 0x1F;
+	_g278_dungeonFileHeader._partyStartPosX = (partyPosition >> 0) & 0x1F;
+	_g278_dungeonFileHeader._squareFirstThingCount = dunDataStream.readUint16BE();
 	for (uint16 i = 0; i < k16_ThingTypeTotal; ++i)
-		_g278_fileHeader._thingCounts[i] = dunDataStream.readUint16BE();
+		_g278_dungeonFileHeader._thingCounts[i] = dunDataStream.readUint16BE();
 
 	// init party position and mapindex
-	if (_messages._g298_newGame) {
-		_currMap._g308_partyDir = _g278_fileHeader._partyStartDir;
-		_currMap._g306_partyPosX = _g278_fileHeader._partyStartPosX;
-		_currMap._g307_partyPosY = _g278_fileHeader._partyStartPosY;
-		_currMap._g309_currPartyMapIndex = 0;
+	if (_vm->_g298_newGame) {
+		_g308_partyDir = _g278_dungeonFileHeader._partyStartDir;
+		_g306_partyMapX = _g278_dungeonFileHeader._partyStartPosX;
+		_g307_partyMapY = _g278_dungeonFileHeader._partyStartPosY;
+		_g309_partyMapIndex = 0;
 	}
 
 	// load map data
-	delete[] _g277_maps;
-	_g277_maps = new Map[_g278_fileHeader._mapCount];
-	for (uint16 i = 0; i < _g278_fileHeader._mapCount; ++i) {
-		_g277_maps[i]._rawDunDataOffset = dunDataStream.readUint16BE();
+	delete[] _g277_dungeonMaps;
+	_g277_dungeonMaps = new Map[_g278_dungeonFileHeader._mapCount];
+	for (uint16 i = 0; i < _g278_dungeonFileHeader._mapCount; ++i) {
+		_g277_dungeonMaps[i]._rawDunDataOffset = dunDataStream.readUint16BE();
 		dunDataStream.readUint32BE(); // discard 4 bytes
-		_g277_maps[i]._offsetMapX = dunDataStream.readByte();
-		_g277_maps[i]._offsetMapY = dunDataStream.readByte();
+		_g277_dungeonMaps[i]._offsetMapX = dunDataStream.readByte();
+		_g277_dungeonMaps[i]._offsetMapY = dunDataStream.readByte();
 
 		uint16 tmp = dunDataStream.readUint16BE();
-		_g277_maps[i]._height = tmp >> 11;
-		_g277_maps[i]._width = (tmp >> 6) & 0x1F;
-		_g277_maps[i]._level = tmp & 0x1F; // Only used in DMII
+		_g277_dungeonMaps[i]._height = tmp >> 11;
+		_g277_dungeonMaps[i]._width = (tmp >> 6) & 0x1F;
+		_g277_dungeonMaps[i]._level = tmp & 0x1F; // Only used in DMII
 
 		tmp = dunDataStream.readUint16BE();
-		_g277_maps[i]._randFloorOrnCount = tmp >> 12;
-		_g277_maps[i]._floorOrnCount = (tmp >> 8) & 0xF;
-		_g277_maps[i]._randWallOrnCount = (tmp >> 4) & 0xF;
-		_g277_maps[i]._wallOrnCount = tmp & 0xF;
+		_g277_dungeonMaps[i]._randFloorOrnCount = tmp >> 12;
+		_g277_dungeonMaps[i]._floorOrnCount = (tmp >> 8) & 0xF;
+		_g277_dungeonMaps[i]._randWallOrnCount = (tmp >> 4) & 0xF;
+		_g277_dungeonMaps[i]._wallOrnCount = tmp & 0xF;
 
 		tmp = dunDataStream.readUint16BE();
-		_g277_maps[i]._difficulty = tmp >> 12;
-		_g277_maps[i]._creatureTypeCount = (tmp >> 4) & 0xF;
-		_g277_maps[i]._doorOrnCount = tmp & 0xF;
+		_g277_dungeonMaps[i]._difficulty = tmp >> 12;
+		_g277_dungeonMaps[i]._creatureTypeCount = (tmp >> 4) & 0xF;
+		_g277_dungeonMaps[i]._doorOrnCount = tmp & 0xF;
 
 		tmp = dunDataStream.readUint16BE();
-		_g277_maps[i]._doorSet1 = (tmp >> 12) & 0xF;
-		_g277_maps[i]._doorSet0 = (tmp >> 8) & 0xF;
-		_g277_maps[i]._wallSet = (WallSet)((tmp >> 4) & 0xF);
-		_g277_maps[i]._floorSet = (FloorSet)(tmp & 0xF);
+		_g277_dungeonMaps[i]._doorSet1 = (tmp >> 12) & 0xF;
+		_g277_dungeonMaps[i]._doorSet0 = (tmp >> 8) & 0xF;
+		_g277_dungeonMaps[i]._wallSet = (WallSet)((tmp >> 4) & 0xF);
+		_g277_dungeonMaps[i]._floorSet = (FloorSet)(tmp & 0xF);
 	}
 
 	// TODO: ??? is this - begin
-	delete[] _dunData._g281_mapsFirstColumnIndex;
-	_dunData._g281_mapsFirstColumnIndex = new uint16[_g278_fileHeader._mapCount];
+	delete[] _g281_dungeonMapsFirstColumnIndex;
+	_g281_dungeonMapsFirstColumnIndex = new uint16[_g278_dungeonFileHeader._mapCount];
 	uint16 columCount = 0;
-	for (uint16 i = 0; i < _g278_fileHeader._mapCount; ++i) {
-		_dunData._g281_mapsFirstColumnIndex[i] = columCount;
-		columCount += _g277_maps[i]._width + 1;
+	for (uint16 i = 0; i < _g278_dungeonFileHeader._mapCount; ++i) {
+		_g281_dungeonMapsFirstColumnIndex[i] = columCount;
+		columCount += _g277_dungeonMaps[i]._width + 1;
 	}
-	_dunData._g282_columCount = columCount;
+	_g282_dungeonColumCount = columCount;
 	// TODO: ??? is this - end
 
 
-	uint32 actualSquareFirstThingCount = _g278_fileHeader._squareFirstThingCount;
-	if (_messages._g298_newGame) // TODO: what purpose does this serve?
-		_g278_fileHeader._squareFirstThingCount += 300;
+	uint32 actualSquareFirstThingCount = _g278_dungeonFileHeader._squareFirstThingCount;
+	if (_vm->_g298_newGame) // TODO: what purpose does this serve?
+		_g278_dungeonFileHeader._squareFirstThingCount += 300;
 
 	// TODO: ??? is this - begin
-	delete[] _dunData._g280_columnsCumulativeSquareThingCount;
-	_dunData._g280_columnsCumulativeSquareThingCount = new uint16[columCount];
+	delete[] _g280_dungeonColumnsCumulativeSquareThingCount;
+	_g280_dungeonColumnsCumulativeSquareThingCount = new uint16[columCount];
 	for (uint16 i = 0; i < columCount; ++i)
-		_dunData._g280_columnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE();
+		_g280_dungeonColumnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE();
 	// TODO: ??? is this - end
 
 	// TODO: ??? is this - begin
-	delete[] _dunData._g283_squareFirstThings;
-	_dunData._g283_squareFirstThings = new Thing[_g278_fileHeader._squareFirstThingCount];
+	delete[] _g283_squareFirstThings;
+	_g283_squareFirstThings = new Thing[_g278_dungeonFileHeader._squareFirstThingCount];
 	for (uint16 i = 0; i < actualSquareFirstThingCount; ++i)
-		_dunData._g283_squareFirstThings[i].set(dunDataStream.readUint16BE());
-	if (_messages._g298_newGame)
+		_g283_squareFirstThings[i].set(dunDataStream.readUint16BE());
+	if (_vm->_g298_newGame)
 		for (uint16 i = 0; i < 300; ++i)
-			_dunData._g283_squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none;
+			_g283_squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none;
 
 	// TODO: ??? is this - end
 
 	// load text data
-	delete[] _dunData._g260_textData;
-	_dunData._g260_textData = new uint16[_g278_fileHeader._textDataWordCount];
-	for (uint16 i = 0; i < _g278_fileHeader._textDataWordCount; ++i)
-		_dunData._g260_textData[i] = dunDataStream.readUint16BE();
+	delete[] _g260_dungeonTextData;
+	_g260_dungeonTextData = new uint16[_g278_dungeonFileHeader._textDataWordCount];
+	for (uint16 i = 0; i < _g278_dungeonFileHeader._textDataWordCount; ++i)
+		_g260_dungeonTextData[i] = dunDataStream.readUint16BE();
 
 	// TODO: ??? what this
-	if (_messages._g298_newGame)
+	if (_vm->_g298_newGame)
 		_vm->_timeline->_g369_eventMaxCount = 100;
 
 	// load things
 	for (uint16 thingType = k0_DoorThingType; thingType < k16_ThingTypeTotal; ++thingType) {
-		uint16 thingCount = _g278_fileHeader._thingCounts[thingType];
-		if (_messages._g298_newGame) {
-			_g278_fileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + g236_AdditionalThingCounts[thingType]);
+		uint16 thingCount = _g278_dungeonFileHeader._thingCounts[thingType];
+		if (_vm->_g298_newGame) {
+			_g278_dungeonFileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + g236_AdditionalThingCounts[thingType]);
 		}
 		uint16 thingStoreWordCount = g235_ThingDataWordCount[thingType];
 
 		if (thingStoreWordCount == 0)
 			continue;
 
-		if (_dunData._g284_thingsData[thingType]) {
-			delete[] _dunData._g284_thingsData[thingType][0];
-			delete[] _dunData._g284_thingsData[thingType];
+		if (_g284_thingData[thingType]) {
+			delete[] _g284_thingData[thingType][0];
+			delete[] _g284_thingData[thingType];
 		}
-		_dunData._g284_thingsData[thingType] = new uint16*[_g278_fileHeader._thingCounts[thingType]];
-		_dunData._g284_thingsData[thingType][0] = new uint16[_g278_fileHeader._thingCounts[thingType] * thingStoreWordCount];
-		for (uint16 i = 0; i < _g278_fileHeader._thingCounts[thingType]; ++i)
-			_dunData._g284_thingsData[thingType][i] = _dunData._g284_thingsData[thingType][0] + i * thingStoreWordCount;
+		_g284_thingData[thingType] = new uint16*[_g278_dungeonFileHeader._thingCounts[thingType]];
+		_g284_thingData[thingType][0] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount];
+		for (uint16 i = 0; i < _g278_dungeonFileHeader._thingCounts[thingType]; ++i)
+			_g284_thingData[thingType][i] = _g284_thingData[thingType][0] + i * thingStoreWordCount;
 
 		if (thingType == k4_GroupThingType) {
 			for (uint16 i = 0; i < thingCount; ++i)
 				for (uint16 j = 0; j < thingStoreWordCount; ++j) {
 					if (j == 2 || j == 3)
-						_dunData._g284_thingsData[thingType][i][j] = dunDataStream.readByte();
+						_g284_thingData[thingType][i][j] = dunDataStream.readByte();
 					else
-						_dunData._g284_thingsData[thingType][i][j] = dunDataStream.readUint16BE();
+						_g284_thingData[thingType][i][j] = dunDataStream.readUint16BE();
 				}
 		} else if (thingType == k14_ProjectileThingType) {
 			for (uint16 i = 0; i < thingCount; ++i) {
-				_dunData._g284_thingsData[thingType][i][0] = dunDataStream.readUint16BE();
-				_dunData._g284_thingsData[thingType][i][1] = dunDataStream.readUint16BE();
-				_dunData._g284_thingsData[thingType][i][2] = dunDataStream.readByte();
-				_dunData._g284_thingsData[thingType][i][3] = dunDataStream.readByte();
-				_dunData._g284_thingsData[thingType][i][4] = dunDataStream.readUint16BE();
+				_g284_thingData[thingType][i][0] = dunDataStream.readUint16BE();
+				_g284_thingData[thingType][i][1] = dunDataStream.readUint16BE();
+				_g284_thingData[thingType][i][2] = dunDataStream.readByte();
+				_g284_thingData[thingType][i][3] = dunDataStream.readByte();
+				_g284_thingData[thingType][i][4] = dunDataStream.readUint16BE();
 			}
 		} else {
 			for (uint16 i = 0; i < thingCount; ++i) {
 				for (uint16 j = 0; j < thingStoreWordCount; ++j)
-					_dunData._g284_thingsData[thingType][i][j] = dunDataStream.readUint16BE();
+					_g284_thingData[thingType][i][j] = dunDataStream.readUint16BE();
 			}
 		}
 
-		if (_messages._g298_newGame) {
+		if (_vm->_g298_newGame) {
 			if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType)
-				_vm->_timeline->_g369_eventMaxCount += _g278_fileHeader._thingCounts[thingType];
+				_vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType];
 			for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) {
-				_dunData._g284_thingsData[thingType][thingCount + i][0] = Thing::_none.toUint16();
+				_g284_thingData[thingType][thingCount + i][0] = Thing::_none.toUint16();
 			}
 		}
 	}
 
 	// load map data
-	if (!_messages._g523_restartGameRequest)
-		_g276_rawMapData = _rawDunFileData + dunDataStream.pos();
+	if (!_vm->_g523_restartGameRequest)
+		_g276_dungeonRawMapData = _rawDunFileData + dunDataStream.pos();
 
 
-	if (!_messages._g523_restartGameRequest) {
-		uint8 mapCount = _g278_fileHeader._mapCount;
-		delete[] _dunData._g279_mapData;
-		_dunData._g279_mapData = new byte**[_dunData._g282_columCount + mapCount];
-		byte **colFirstSquares = (byte**)_dunData._g279_mapData + mapCount;
+	if (!_vm->_g523_restartGameRequest) {
+		uint8 mapCount = _g278_dungeonFileHeader._mapCount;
+		delete[] _g279_dungeonMapData;
+		_g279_dungeonMapData = new byte**[_g282_dungeonColumCount + mapCount];
+		byte **colFirstSquares = (byte**)_g279_dungeonMapData + mapCount;
 		for (uint8 i = 0; i < mapCount; ++i) {
-			_dunData._g279_mapData[i] = colFirstSquares;
-			byte *square = _g276_rawMapData + _g277_maps[i]._rawDunDataOffset;
+			_g279_dungeonMapData[i] = colFirstSquares;
+			byte *square = _g276_dungeonRawMapData + _g277_dungeonMaps[i]._rawDunDataOffset;
 			*colFirstSquares++ = square;
-			for (uint16 w = 1; w <= _g277_maps[i]._width; ++w) {
-				square += _g277_maps[i]._height + 1;
+			for (uint16 w = 1; w <= _g277_dungeonMaps[i]._width; ++w) {
+				square += _g277_dungeonMaps[i]._height + 1;
 				*colFirstSquares++ = square;
 			}
 		}
@@ -729,59 +729,59 @@ void DungeonMan::loadDungeonFile() {
 }
 
 void DungeonMan::setCurrentMap(uint16 mapIndex) {
-	_currMap._g272_index = mapIndex;
-	_currMap._g271_data = _dunData._g279_mapData[mapIndex];
-	_currMap._g269_map = _g277_maps + mapIndex;
-	_currMap._g273_width = _g277_maps[mapIndex]._width + 1;
-	_currMap._g274_height = _g277_maps[mapIndex]._height + 1;
-	_currMap._g270_colCumulativeSquareFirstThingCount
-		= &_dunData._g280_columnsCumulativeSquareThingCount[_dunData._g281_mapsFirstColumnIndex[mapIndex]];
+	_g272_currMapIndex = mapIndex;
+	_g271_currMapData = _g279_dungeonMapData[mapIndex];
+	_g269_currMap = _g277_dungeonMaps + mapIndex;
+	_g273_currMapWidth = _g277_dungeonMaps[mapIndex]._width + 1;
+	_g274_currMapHeight = _g277_dungeonMaps[mapIndex]._height + 1;
+	_g270_currMapColCumulativeSquareFirstThingCount
+		= &_g280_dungeonColumnsCumulativeSquareThingCount[_g281_dungeonMapsFirstColumnIndex[mapIndex]];
 }
 
 void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) {
 	setCurrentMap(mapIndex);
 
-	byte *metaMapData = _currMap._g271_data[_currMap._g273_width - 1] + _currMap._g274_height;
+	byte *metaMapData = _g271_currMapData[_g273_currMapWidth - 1] + _g274_currMapHeight;
 	_vm->_displayMan->_g264_currMapAllowedCreatureTypes = metaMapData;
 
-	metaMapData += _currMap._g269_map->_creatureTypeCount;
-	memcpy(_vm->_displayMan->_g261_currMapWallOrnIndices, metaMapData, _currMap._g269_map->_wallOrnCount);
+	metaMapData += _g269_currMap->_creatureTypeCount;
+	memcpy(_vm->_displayMan->_g261_currMapWallOrnIndices, metaMapData, _g269_currMap->_wallOrnCount);
 
-	metaMapData += _currMap._g269_map->_wallOrnCount;
-	memcpy(_vm->_displayMan->_g262_currMapFloorOrnIndices, metaMapData, _currMap._g269_map->_floorOrnCount);
+	metaMapData += _g269_currMap->_wallOrnCount;
+	memcpy(_vm->_displayMan->_g262_currMapFloorOrnIndices, metaMapData, _g269_currMap->_floorOrnCount);
 
-	metaMapData += _currMap._g269_map->_wallOrnCount;
-	memcpy(_vm->_displayMan->_g263_currMapDoorOrnIndices, metaMapData, _currMap._g269_map->_doorOrnCount);
+	metaMapData += _g269_currMap->_wallOrnCount;
+	memcpy(_vm->_displayMan->_g263_currMapDoorOrnIndices, metaMapData, _g269_currMap->_doorOrnCount);
 
-	_g265_currMapInscriptionWallOrnIndex = _currMap._g269_map->_wallOrnCount;
+	_g265_currMapInscriptionWallOrnIndex = _g269_currMap->_wallOrnCount;
 	_vm->_displayMan->_g261_currMapWallOrnIndices[_g265_currMapInscriptionWallOrnIndex] = k0_WallOrnInscription;
 }
 
 
 Square DungeonMan::getSquare(int16 mapX, int16 mapY) {
-	bool isInXBounds = (mapX >= 0) && (mapX < _currMap._g273_width);
-	bool isInYBounds = (mapY >= 0) && (mapY < _currMap._g274_height);
+	bool isInXBounds = (mapX >= 0) && (mapX < _g273_currMapWidth);
+	bool isInYBounds = (mapY >= 0) && (mapY < _g274_currMapHeight);
 
 	if (isInXBounds && isInYBounds)
-		return Square(_currMap._g271_data[mapX][mapY]);
+		return Square(_g271_currMapData[mapX][mapY]);
 
 
 	Square tmpSquare;
 	if (isInYBounds) {
-		tmpSquare.set(_currMap._g271_data[0][mapY]);
+		tmpSquare.set(_g271_currMapData[0][mapY]);
 		if (mapX == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
 			return Square(k0_WallElemType).set(k0x0004_WallEastRandOrnAllowed);
 
-		tmpSquare.set(_currMap._g271_data[_currMap._g273_width - 1][mapY]);
-		if (mapX == _currMap._g273_width && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
+		tmpSquare.set(_g271_currMapData[_g273_currMapWidth - 1][mapY]);
+		if (mapX == _g273_currMapWidth && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
 			return Square(k0_WallElemType).set(k0x0001_WallWestRandOrnAllowed);
 	} else if (isInXBounds) {
-		tmpSquare.set(_currMap._g271_data[mapX][0]);
+		tmpSquare.set(_g271_currMapData[mapX][0]);
 		if (mapY == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
 			return Square(k0_WallElemType).set(k0x0002_WallSouthRandOrnAllowed);
 
-		tmpSquare.set(_currMap._g271_data[mapX][_currMap._g274_height - 1]);
-		if (mapY == _currMap._g274_height && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
+		tmpSquare.set(_g271_currMapData[mapX][_g274_currMapHeight - 1]);
+		if (mapY == _g274_currMapHeight && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
 			return Square((k0_WallElemType << 5) | k0x0008_WallNorthRandOrnAllowed);
 	}
 
@@ -794,12 +794,12 @@ Square DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRi
 }
 
 int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) {
-	if (mapX < 0 || mapX >= _currMap._g273_width || mapY < 0 || mapY >= _currMap._g274_height || !Square(_currMap._g271_data[mapX][mapY]).get(k0x0010_ThingListPresent))
+	if (mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight || !Square(_g271_currMapData[mapX][mapY]).get(k0x0010_ThingListPresent))
 		return -1;
 
 	int16 y = 0;
-	uint16 index = _currMap._g270_colCumulativeSquareFirstThingCount[mapX];
-	byte* square = _currMap._g271_data[mapX];
+	uint16 index = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
+	byte* square = _g271_currMapData[mapX];
 	while (y++ != mapY)
 		if (Square(*square++).get(k0x0010_ThingListPresent))
 			index++;
@@ -811,7 +811,7 @@ Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) {
 	int16 index = getSquareFirstThingIndex(mapX, mapY);
 	if (index == -1)
 		return Thing::_endOfList;
-	return _dunData._g283_squareFirstThings[index];
+	return _g283_squareFirstThings[index];
 }
 
 
@@ -880,7 +880,7 @@ T0172010_ClosedFakeWall:
 			}
 			thing = getNextThing(thing);
 		}
-		if (squareIsFakeWall && (_currMap._g306_partyPosX != mapX) && (_currMap._g307_partyPosY != mapY)) {
+		if (squareIsFakeWall && (_g306_partyMapX != mapX) && (_g307_partyMapY != mapY)) {
 			aspectArray[k1_FirstGroupOrObjectAspect] = Thing::_endOfList.toUint16();
 			return;
 		}
@@ -906,7 +906,7 @@ T0172010_ClosedFakeWall:
 		square = Square(footPrintsAllowed ? 8 : 0);
 		// intentional fallthrough
 	case k1_CorridorElemType:
-		aspectArray[k4_FloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(k0x0008_CorridorRandOrnAllowed), _currMap._g269_map->_randFloorOrnCount, mapX, mapY, 30);
+		aspectArray[k4_FloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(k0x0008_CorridorRandOrnAllowed), _g269_currMap->_randFloorOrnCount, mapX, mapY, 30);
 T0172029_Teleporter:
 		footPrintsAllowed = true;
 T0172030_Pit:
@@ -949,7 +949,7 @@ T0172049_Footprints:
 
 void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
 											int16 mapX, int16 mapY, bool isFakeWall) {
-	int16 ornCount = _currMap._g269_map->_randWallOrnCount;
+	int16 ornCount = _g269_currMap->_randWallOrnCount;
 
 	turnDirRight(dir);
 	aspectArray[k2_RightWallOrnOrdAspect] = getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
@@ -958,7 +958,7 @@ void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowe
 	turnDirRight(dir);
 	aspectArray[k4_LeftWallOrnOrdAspect] = getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
 
-	if (isFakeWall || mapX < 0 || mapX >= _currMap._g273_width || mapY < 0 || mapY >= _currMap._g274_height) {
+	if (isFakeWall || mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight) {
 		for (uint16 i = k2_RightWallOrnOrdAspect; i <= k4_LeftWallOrnOrdAspect; ++i) {
 			if (isWallOrnAnAlcove(_vm->ordinalToIndex(aspectArray[i])))
 				aspectArray[i] = 0;
@@ -968,8 +968,8 @@ void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowe
 
 int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) {
 	int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1)
-					+ (3000 + (_currMap._g272_index << 6) + _currMap._g273_width + _currMap._g274_height) * 11
-					+ _g278_fileHeader._ornamentRandomSeed) >> 2) % modulo;
+					+ (3000 + (_g272_currMapIndex << 6) + _g273_currMapWidth + _g274_currMapHeight) * 11
+					+ _g278_dungeonFileHeader._ornamentRandomSeed) >> 2) % modulo;
 	if (allowed && index < count)
 		return _vm->indexToOrdinal(index);
 	return 0;
@@ -985,7 +985,7 @@ bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) {
 }
 
 uint16 *DungeonMan::getThingData(Thing thing) {
-	return _dunData._g284_thingsData[thing.getType()][thing.getIndex()];
+	return _g284_thingData[thing.getType()][thing.getIndex()];
 }
 
 uint16* DungeonMan::getSquareFirstThingData(int16 mapX, int16 mapY) {
@@ -1099,7 +1099,7 @@ char g257_InscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_
 
 void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 	char sepChar;
-	TextString textString(_dunData._g284_thingsData[k2_TextstringType][thing.getIndex()]);
+	TextString textString(_g284_thingData[k2_TextstringType][thing.getIndex()]);
 	if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) {
 		type = (TextType)(type & ~k0x8000_DecodeEvenIfInvisible);
 		if (type == k1_TextTypeMessage) {
@@ -1112,7 +1112,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 		}
 		uint16 codeCounter = 0;
 		int16 escChar = 0;
-		uint16 *codeWord = _dunData._g260_textData + textString.getWordOffset();
+		uint16 *codeWord = _g260_dungeonTextData + textString.getWordOffset();
 		uint16 code = 0, codes = 0;
 		char *escReplString = nullptr;
 		for (;;) { /*infinite loop*/
@@ -1260,27 +1260,27 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map
 	*rawObjPtr = Thing::_endOfList.toUint16();
 
 	if (mapX >= 0) {
-		Square *squarePtr = (Square*)&_currMap._g271_data[mapX][mapY];
+		Square *squarePtr = (Square*)&_g271_currMapData[mapX][mapY];
 		if (squarePtr->get(k0x0010_ThingListPresent)) {
 			thingInList = getSquareFirstThing(mapX, mapY);
 		} else {
 			squarePtr->set(k0x0010_ThingListPresent);
-			uint16 *cumulativeCount = &_currMap._g270_colCumulativeSquareFirstThingCount[mapX + 1];
-			uint16 column = _dunData._g282_columCount - (_dunData._g281_mapsFirstColumnIndex[_currMap._g272_index] + mapX) - 1;
+			uint16 *cumulativeCount = &_g270_currMapColCumulativeSquareFirstThingCount[mapX + 1];
+			uint16 column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1;
 			while (column--) {
 				(*cumulativeCount++)++;
 			}
 			uint16 mapYStep = 0;
 			squarePtr -= mapY;
-			uint16 squareFirstThingIndex = _currMap._g270_colCumulativeSquareFirstThingCount[mapX];
+			uint16 squareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
 			while (mapYStep++ != mapY) {
 				if (squarePtr->get(k0x0010_ThingListPresent)) {
 					squareFirstThingIndex++;
 				}
 				squarePtr++;
 			}
-			Thing* thingPtr = &_dunData._g283_squareFirstThings[squareFirstThingIndex];
-			memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_g278_fileHeader._squareFirstThingCount - squareFirstThingIndex - 1));
+			Thing* thingPtr = &_g283_squareFirstThings[squareFirstThingIndex];
+			memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_g278_dungeonFileHeader._squareFirstThingCount - squareFirstThingIndex - 1));
 			*thingPtr = thingToLink;
 			return;
 		}
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index d6ebdc0..628422c 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -556,7 +556,7 @@ public:
 	SquareType getType() { return (SquareType)(_data >> 5); } // @ M34_SQUARE_TYPE
 	void setType(SquareType type) { _data = (_data & 0x1F) | type << 5; }
 	byte toByte() { return _data; } // I don't like 'em casts
-};
+}; // wrapper for bytes which are used as squares
 
 struct DungeonFileHeader {
 	uint16 _dungeonId; // @ G0526_ui_DungeonID
@@ -592,39 +592,7 @@ struct Map {
 	uint8 _doorSet0, _doorSet1;
 }; // @ MAP
 
-struct DungeonData {
-	// I have no idea the heck is this
-	uint16 *_g281_mapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex
-	uint16 _g282_columCount; // @ G0282_ui_DungeonColumnCount
-
-	// I have no idea the heck is this
-	uint16 *_g280_columnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
-	Thing *_g283_squareFirstThings; // @ G0283_pT_SquareFirstThings
-	uint16 *_g260_textData; // @ G0260_pui_DungeonTextData
-
-	uint16 **_g284_thingsData[16]; // @ G0284_apuc_ThingData
-
-	byte ***_g279_mapData; // @ G0279_pppuc_DungeonMapData
-}; // @ AGGREGATE
 
-struct CurrMapData {
-	direction _g308_partyDir; // @ G0308_i_PartyDirection
-	int16 _g306_partyPosX; // @ G0306_i_PartyMapX
-	int16 _g307_partyPosY; // @ G0307_i_PartyMapY
-	uint8 _g309_currPartyMapIndex; // @ G0309_i_PartyMapIndex
-
-	uint8 _g272_index; // @ G0272_i_CurrentMapIndex
-	byte **_g271_data; // @ G0271_ppuc_CurrentMapData
-	Map *_g269_map; // @ G0269_ps_CurrentMap
-	uint16 _g273_width; // @ G0273_i_CurrentMapWidth
-	uint16 _g274_height; // @ G0274_i_CurrentMapHeight
-	uint16 *_g270_colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount
-}; // @ AGGREGATE
-
-struct Messages {
-	bool _g298_newGame; // @ G0298_B_NewGame
-	bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested
-}; // @ AGGREGATE
 
 class DungeonMan {
 	DMEngine *_vm;
@@ -674,14 +642,33 @@ public:
 
 	uint32 _rawDunFileDataSize;	 // @ probably NONE
 	byte *_rawDunFileData; // @ ???
-	DungeonFileHeader _g278_fileHeader; // @ G0278_ps_DungeonHeader
+	DungeonFileHeader _g278_dungeonFileHeader; // @ G0278_ps_DungeonHeader
 
-	DungeonData _dunData; // @ NONE
-	CurrMapData _currMap; // @ NONE
-	Map *_g277_maps; // @ G0277_ps_DungeonMaps
+
+	uint16 *_g281_dungeonMapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex
+	uint16 _g282_dungeonColumCount; // @ G0282_ui_DungeonColumnCount
+	uint16 *_g280_dungeonColumnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
+	Thing *_g283_squareFirstThings; // @ G0283_pT_SquareFirstThings
+	uint16 *_g260_dungeonTextData; // @ G0260_pui_DungeonTextData
+	uint16 **_g284_thingData[16]; // @ G0284_apuc_ThingData
+	byte ***_g279_dungeonMapData; // @ G0279_pppuc_DungeonMapData
+
+
+	direction _g308_partyDir; // @ G0308_i_PartyDirection
+	int16 _g306_partyMapX; // @ G0306_i_PartyMapX
+	int16 _g307_partyMapY; // @ G0307_i_PartyMapY
+	uint8 _g309_partyMapIndex; // @ G0309_i_PartyMapIndex
+	uint8 _g272_currMapIndex; // @ G0272_i_CurrentMapIndex
+	byte **_g271_currMapData; // @ G0271_ppuc_CurrentMapData
+	Map *_g269_currMap; // @ G0269_ps_CurrentMap
+	uint16 _g273_currMapWidth; // @ G0273_i_CurrentMapWidth
+	uint16 _g274_currMapHeight; // @ G0274_i_CurrentMapHeight
+	uint16 *_g270_currMapColCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount
+
+
+	Map *_g277_dungeonMaps; // @ G0277_ps_DungeonMaps
 	// does not have to be freed
-	byte *_g276_rawMapData; // @ G0276_puc_DungeonRawMapData
-	Messages _messages; // @ NONE;
+	byte *_g276_dungeonRawMapData; // @ G0276_puc_DungeonRawMapData
 
 	int16 _g265_currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex
 	Box _g291_dungeonViewClickableBoxes[6]; // G0291_aauc_DungeonViewClickableBoxes
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 6d59727..2e6f473 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -305,7 +305,6 @@ void EventManager::setMousePos(Common::Point pos) {
 
 void EventManager::processInput() {
 	DungeonMan &dungeonMan = *_vm->_dungeonMan;
-	CurrMapData &currMap = dungeonMan._currMap;
 
 	Common::Event event;
 	while (_vm->_system->getEventManager()->pollEvent(event)) {
@@ -317,22 +316,22 @@ void EventManager::processInput() {
 
 			switch (event.kbd.keycode) {
 			case Common::KEYCODE_w:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY);
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 				break;
 			case Common::KEYCODE_a:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, -1, currMap._g306_partyPosX, currMap._g307_partyPosY);
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 				break;
 			case Common::KEYCODE_s:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, -1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY);
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 				break;
 			case Common::KEYCODE_d:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, 1, currMap._g306_partyPosX, currMap._g307_partyPosY);
+				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 				break;
 			case Common::KEYCODE_q:
-				turnDirLeft(currMap._g308_partyDir);
+				turnDirLeft(dungeonMan._g308_partyDir);
 				break;
 			case Common::KEYCODE_e:
-				turnDirRight(currMap._g308_partyDir);
+				turnDirRight(dungeonMan._g308_partyDir);
 				break;
 			case Common::KEYCODE_UP:
 				if (_dummyMapIndex < 13)
@@ -440,7 +439,7 @@ void EventManager::commandTurnParty(CommandType cmdType) {
 	// MISSING CODE: process sensors
 
 	// DUMMY CODE: should call F0284_CHAMPION_SetPartyDirection instead
-	direction &partyDir = _vm->_dungeonMan->_currMap._g308_partyDir;
+	direction &partyDir = _vm->_dungeonMan->_g308_partyDir;
 	(cmdType == k1_CommandTurnLeft) ? turnDirLeft(partyDir) : turnDirRight(partyDir);
 
 	// MISSING CODE: process sensors
@@ -453,20 +452,19 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 
 	// DUMMY CODE:
 	DungeonMan &dungeonMan = *_vm->_dungeonMan;
-	CurrMapData &currMap = dungeonMan._currMap;
 
 	switch (cmdType) {
 	case k3_CommandMoveForward:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY);
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 		break;
 	case k6_CommandMoveLeft:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, -1, currMap._g306_partyPosX, currMap._g307_partyPosY);
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 		break;
 	case k5_CommandMoveBackward:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, -1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY);
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 		break;
 	case k4_CommandMoveRight:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, 1, currMap._g306_partyPosX, currMap._g307_partyPosY);
+		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 		break;
 	default:
 		break;
@@ -496,7 +494,7 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
 	}
 	cm._g411_leaderIndex = champIndex;
 	Champion *champion = &cm._champions[cm._g411_leaderIndex];
-	champion->_dir = _vm->_dungeonMan->_currMap._g308_partyDir;
+	champion->_dir = _vm->_dungeonMan->_g308_partyDir;
 	cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._414_leaderHandObject);
 	if (_vm->indexToOrdinal(champIndex) != cm._g299_candidateChampionOrdinal) {
 		champion->setAttributeFlag(k0x0400_ChampionAttributeIcon, true);
@@ -507,26 +505,24 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
 
 void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() {
 	DungeonMan &dunMan = *_vm->_dungeonMan;
-	CurrMapData &currMap = dunMan._currMap;
-	int16 mapX = currMap._g306_partyPosX + _vm->_dirIntoStepCountEast[currMap._g308_partyDir];
-	int16 mapY = currMap._g307_partyPosY + _vm->_dirIntoStepCountNorth[currMap._g308_partyDir];
-	if ((mapX >= 0) && (mapX < currMap._g273_width) && (mapY >= 0) && (mapY < currMap._g274_height)) {
-		_vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(currMap._g308_partyDir));
+	int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
+	int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
+	if ((mapX >= 0) && (mapX < dunMan._g273_currMapWidth) && (mapY >= 0) && (mapY < dunMan._g274_currMapHeight)) {
+		_vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(dunMan._g308_partyDir));
 	}
 }
 
 void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY) {
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 	ChampionMan &champMan = *_vm->_championMan;
-	CurrMapData &currMap = _vm->_dungeonMan->_currMap;
 
 	if (dunMan._g285_squareAheadElement == k17_ElementTypeDoorFront) {
 		if (champMan._g411_leaderIndex == kM1_ChampionNone)
 			return;
 
 		if (champMan._g415_leaderEmptyHanded) {
-			int16 mapX = currMap._g306_partyPosX + _vm->_dirIntoStepCountEast[currMap._g308_partyDir];
-			int16 mapY = currMap._g307_partyPosY + _vm->_dirIntoStepCountNorth[currMap._g308_partyDir];
+			int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
+			int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
 
 			if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() &&
 				dunMan._g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
@@ -601,7 +597,6 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	ChampionMan &champMan = *_vm->_championMan;
 	InventoryMan &invMan = *_vm->_inventoryMan;
 	DisplayMan &dispMan = *_vm->_displayMan;
-	CurrMapData &currMap = _vm->_dungeonMan->_currMap;
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 
 	uint16 championIndex = champMan._g305_partyChampionCount - 1;
@@ -620,15 +615,15 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 		box._x2 = box._x1 + 66 + 1;
 		dispMan._g578_useByteBoxCoordinates = false;
 		dispMan.clearScreenBox(k0_ColorBlack, box);
-		dispMan.clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._g308_partyDir) * 2]);
+		dispMan.clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2]);
 		warning("F0457_START_DrawEnabledMenus_CPSF");
 		warning("F0078_MOUSE_ShowPointer");
 		return;
 	}
 
 	champMan._g299_candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
-	int16 mapX = currMap._g306_partyPosX + _vm->_dirIntoStepCountEast[currMap._g308_partyDir];
-	int16 mapY = currMap._g307_partyPosY + _vm->_dirIntoStepCountNorth[currMap._g308_partyDir];
+	int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
+	int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
 
 	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
 		Thing thing = champ->getSlot((ChampionSlot)slotIndex);
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 62bf070..516c1d6 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1155,7 +1155,7 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
 		cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
 		memcpy(_g74_tmpBitmap, _wallSetBitMaps[kG705_DoorFrameLeft_D3L], 32 * 44);
 		warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally");
-		if (((Door*)_vm->_dungeonMan->_dunData._g284_thingsData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
+		if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
 			warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton");
 		}
 		warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor");
@@ -1519,13 +1519,13 @@ void DisplayMan::loadWallSet(WallSet set) {
 
 
 void DisplayMan::loadCurrentMapGraphics() {
-	loadFloorSet(_vm->_dungeonMan->_currMap._g269_map->_floorSet);
-	loadWallSet(_vm->_dungeonMan->_currMap._g269_map->_wallSet);
+	loadFloorSet(_vm->_dungeonMan->_g269_currMap->_floorSet);
+	loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet);
 
 	// the original loads some flipped walls here, I moved it to loadWallSet
 
 	{
-		int16 val = _vm->_dungeonMan->_currMap._g269_map->_wallSet * k18_StairsGraphicCount + k90_FirstStairs;
+		int16 val = _vm->_dungeonMan->_g269_currMap->_wallSet * k18_StairsGraphicCount + k90_FirstStairs;
 		_g675_stairsNativeBitmapIndex_Up_Front_D3L = val++;
 		_g676_stairsNativeBitmapIndex_Up_Front_D3C = val++;
 		_g677_stairsNativeBitmapIndex_Up_Front_D2L = val++;
@@ -1556,7 +1556,7 @@ void DisplayMan::loadCurrentMapGraphics() {
 
 	uint16 alcoveCount = 0;
 	uint16 fountainCount = 0;
-	Map &currMap = *_vm->_dungeonMan->_currMap._g269_map;
+	Map &currMap = *_vm->_dungeonMan->_g269_currMap;
 
 	_g266_currMapViAltarIndex = -1;
 
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 2891da3..2cc2646 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -43,7 +43,7 @@ GroupMan::~GroupMan() {
 }
 
 void GroupMan::initActiveGroups() {
-	if (_vm->_dungeonMan->_messages._g298_newGame)
+	if (_vm->_g298_newGame)
 		_g376_maxActiveGroupCount = 60;
 	if (_g375_activeGroups)
 		delete[] _g375_activeGroups;
@@ -55,7 +55,7 @@ void GroupMan::initActiveGroups() {
 uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) {
 	byte cells;
 	cells = group->_cells;
-	if (mapIndex == _vm->_dungeonMan->_currMap._g309_currPartyMapIndex)
+	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex)
 		cells = _g375_activeGroups[cells]._cells;
 	return cells;
 }
@@ -63,14 +63,14 @@ uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) {
 byte gGroupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_GroupDirections
 
 uint16 GroupMan::getGroupDirections(Group* group, int16 mapIndex) {
-	if (mapIndex == _vm->_dungeonMan->_currMap._g309_currPartyMapIndex)
+	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex)
 		return _g375_activeGroups[group->getActiveGroupIndex()]._directions;
 
 	return gGroupDirections[group->getDir()];
 }
 
 int16 GroupMan::getCreatureOrdinalInCell(Group* group, uint16 cell) {
-	uint16 currMapIndex = _vm->_dungeonMan->_currMap._g272_index;
+	uint16 currMapIndex = _vm->_dungeonMan->_g272_currMapIndex;
 	byte groupCells = getGroupCells(group, currMapIndex);
 	if (groupCells == k255_CreatureTypeSingleCenteredCreature)
 		return _vm->indexToOrdinal(0);
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index aabe88f..a0cd569 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -39,7 +39,7 @@ LoadsaveMan::LoadsaveMan(DMEngine *vm) : _vm(vm) {}
 
 
 LoadgameResponse LoadsaveMan::loadgame() {
-	bool newGame = _vm->_dungeonMan->_messages._g298_newGame;
+	bool newGame = _vm->_g298_newGame;
 	ChampionMan &cm = *_vm->_championMan;
 
 	if (newGame) {
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 9c3b228..499ae9d 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -145,7 +145,7 @@ IconIndice ObjectMan::getIconIndex(Thing thing) {
 		uint16 *rawType = _vm->_dungeonMan->getThingData(thing);
 		switch (iconIndex) {
 		case k0_IconIndiceJunkCompassNorth:
-			iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_currMap._g308_partyDir);
+			iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_g308_partyDir);
 			break;
 		case k4_IconIndiceWeaponTorchUnlit: {
 			Weapon weapon(rawType);
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index d9e7806..9803032 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -44,7 +44,7 @@ Timeline::~Timeline() {
 void Timeline::initTimeline() {
 	_g370_events = new TimelineEvent[_g369_eventMaxCount];
 	_g371_timeline = new uint16[_g369_eventMaxCount];
-	if (_vm->_dungeonMan->_messages._g298_newGame) {
+	if (_vm->_g298_newGame) {
 		for (int16 i = 0; i < _g369_eventMaxCount; ++i)
 			_g370_events->_type = k0_TMEventTypeNone;
 		_g372_eventCount = 0;


Commit: 683230207ccf7c0b3659b082a1dd68a621788621
    https://github.com/scummvm/scummvm/commit/683230207ccf7c0b3659b082a1dd68a621788621
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor DisplayMan::_walsetBitmaps

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index ca4bc3f..72d6057 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -22,4 +22,7 @@ Todo:
 
 	Missing functions:
 		 Add missing  F0163_DUNGEON_LinkThingToList in MovesensMan::sensorIsTriggeredByClickOnWall (I don't think it's safe yet)
+	
+Refactoring
+	Add constructor to CreatureInfo
 	
\ No newline at end of file
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index a32f059..bc4d1c9 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -143,9 +143,10 @@ DMEngine::~DMEngine() {
 
 void DMEngine::initializeGame() {
 	_displayMan->loadGraphics();
+	_displayMan->initializeGraphicData();
 	// DUMMY CODE: next line
 	_displayMan->loadPalette(g19_PalCredits);
-
+	
 	_eventMan->initMouse();
 
 	while (_loadsaveMan->loadgame() != k1_LoadgameSuccess) {
@@ -156,6 +157,9 @@ void DMEngine::initializeGame() {
 	_displayMan->loadWallSet(k0_WallSetStone);
 	_objectMan->loadObjectNames();
 
+	// There was some memory wizardy for the Amiga platform, I skipped that part
+	_displayMan->f461_allocateFlippedWallBitmaps();
+
 	startGame();
 	warning("MISSING CODE: F0267_MOVE_GetMoveResult_CPSCE (if newGame)");
 	_eventMan->showMouse(true);
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index f627fcc..361ff9e 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -133,7 +133,8 @@ public:
 
 enum {
 	// engine debug channels
-	kDMDebugExample = 1 << 0
+	kDMDebugExample = 1 << 0,
+	kDMDebugUselessCode = 1 << 1
 };
 
 class DMEngine : public Engine {
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 628422c..3b752bd 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -181,7 +181,8 @@ enum SquareAspectIndice {
                
 
 
-struct CreatureInfo {
+class CreatureInfo {
+public:
 	byte _creatureAspectIndex;
 	byte _attackSoundOrdinal;
 	uint16 _attributes; /* Bits 15-14 Unreferenced */
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 516c1d6..95c5cf2 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -198,39 +198,6 @@ Frame g163_FrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls
 }; /* D0R */
 
 
-// these denote the corresponding global in DisplayMan::_wallsetbitmaps
-enum WallSetIndices {
-	kG709_DoorFrameFront = 0, // @  G0709_puc_Bitmap_WallSet_DoorFrameFront
-	kG708_DoorFrameLeft_D1C = 1, // @  G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C
-	kG707_DoorFameLeft_D2C = 2, // @  G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C
-	kG706_DoorFrameLeft_D3C = 3, // @  G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C
-	kG705_DoorFrameLeft_D3L = 4, // @  G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L
-	kG704_DoorFrameTop_D1LCR = 5, // @  G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR
-	kG703_DoorFrameTop_D2LCR = 6, // @  G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR
-	kG702_Wall_D0R = 7, // @  G0702_puc_Bitmap_WallSet_Wall_D0R
-	kG701_Wall_D0L = 8, // @  G0701_puc_Bitmap_WallSet_Wall_D0L
-	kG700_Wall_D1LCR = 9, // @  G0700_puc_Bitmap_WallSet_Wall_D1LCR
-	kG699_Wall_D2LCR = 10, // @  G0699_puc_Bitmap_WallSet_Wall_D2LCR
-	kG698_Wall_D3LCR = 11, // @  G0698_puc_Bitmap_WallSet_Wall_D3LCR
-	kG697_Wall_D3L2 = 12, // @  G0697_puc_Bitmap_WallSet_Wall_D3L2
-
-	kG696_Wall_D3R2 = 13, // @  G0696_puc_Bitmap_WallSet_Wall_D3R2
-	kG710_DoorFrameRight_D1C = 14, // @  G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C
-
-	kG94_Wall_D0R_Flipped = 15, // @ G0094_puc_Bitmap_WallD0R_Flipped
-	kG93_Wall_D0L_Flipped = 16, // @ G0093_puc_Bitmap_WallD0L_Flipped
-	kG92_Wall_D1LCR_Flipped = 17, // @ G0092_puc_Bitmap_WallD1LCR_Flipped
-	kG91_Wall_D2LCR_Flipped = 18, // @ G0091_puc_Bitmap_WallD2LCR_Flipped
-	kG90_Wall_D3LCR_Flipped = 19, // @ G0090_puc_Bitmap_WallD3LCR_Flipped
-
-	kG99_Wall_D0R_Native = 20, // @ G0099_puc_Bitmap_WallD0R_Native
-	kG98_Wall_D0L_Native = 21, // @ G0098_puc_Bitmap_WallD0L_Native
-	kG97_Wall_D1LCR_Native = 22, // @ G0097_puc_Bitmap_WallD1LCR_Native 
-	kG96_Wall_D2LCR_Native = 23, // @ G0096_puc_Bitmap_WallD2LCR_Native
-	kG95_Wall_D3LCR_Native = 24 // @ G0095_puc_Bitmap_WallD3LCR_Native
-};
-
-
 byte g196_DoorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordinateSetIndices
 	0,   /* Door Ornament #00 Square Grid */
 	1,   /* Door Ornament #01 Iron Bars */
@@ -634,8 +601,8 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_packedBitmaps = nullptr;
 	_bitmaps = nullptr;
 	_g74_tmpBitmap = nullptr;
-	_g84_floorBitmap = nullptr;
-	_g85_ceilingBitmap = nullptr;
+	_g84_bitmapFloor = nullptr;
+	_g85_bitmapCeiling = nullptr;
 	_g264_currMapAllowedCreatureTypes = nullptr;
 	_g639_derivedBitmapByteCount = nullptr;
 	_g638_derivedBitmaps = nullptr;
@@ -644,8 +611,6 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_g289_championPortraitOrdinal = 0;
 	_g266_currMapViAltarIndex = 0;
 
-	for (int i = 0; i < 25; i++)
-		_wallSetBitMaps[i] = nullptr;
 
 	for (int i = 0; i < 4; i++)
 		_g75_palChangesProjectile[i] = nullptr;
@@ -676,6 +641,39 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 
 	_g290_inscriptionThing = Thing::_none;
 	_g578_useByteBoxCoordinates = false;
+
+	_g85_bitmapCeiling = nullptr;
+	_g84_bitmapFloor = nullptr;
+	_g697_bitmapWallSet_Wall_D3L2 = nullptr;
+	_g696_bitmapWallSet_Wall_D3R2 = nullptr;
+	_g698_bitmapWallSet_Wall_D3LCR = nullptr;
+	_g699_bitmapWallSet_Wall_D2LCR = nullptr;
+	_g700_bitmapWallSet_Wall_D1LCR = nullptr;
+	_g701_bitmapWallSet_Wall_D0L = nullptr;
+	_g702_bitmapWallSet_Wall_D0R = nullptr;
+	_g703_bitmapWallSet_DoorFrameTop_D2LCR = nullptr;
+	_g704_bitmapWallSet_DoorFrameTop_D1LCR = nullptr;
+	_g705_bitmapWallSet_DoorFrameLeft_D3L = nullptr;
+	_g706_bitmapWallSet_DoorFrameLeft_D3C = nullptr;
+	_g707_bitmapWallSet_DoorFrameLeft_D2C = nullptr;
+	_g708_bitmapWallSet_DoorFrameLeft_D1C = nullptr;
+	_g710_bitmapWallSet_DoorFrameRight_D1C = nullptr;
+	_g709_bitmapWallSet_DoorFrameFront = nullptr;
+	_g296_bitmapViewport = nullptr;
+
+	_g231_currentWallSet = -1;
+	_g230_currentFloorSet = -1;
+
+	_g90_bitmapWall_D3LCR_Flipped = nullptr;
+	_g91_bitmapWall_D2LCR_Flipped = nullptr;
+	_g92_bitmapWall_D1LCR_Flipped = nullptr;
+	_g93_bitmapWall_D0L_Flipped = nullptr;
+	_g94_bitmapWall_D0R_Flipped = nullptr;
+	_g95_bitmapWall_D3LCR_Native = nullptr;
+	_g96_bitmapWall_D2LCR_Native = nullptr;
+	_g97_bitmapWall_D1LCR_Native = nullptr;
+	_g98_bitmapWall_D0L_Native = nullptr;
+	_g99_bitmapWall_D0R_Native = nullptr;
 }
 
 DisplayMan::~DisplayMan() {
@@ -686,10 +684,6 @@ DisplayMan::~DisplayMan() {
 		delete[] _bitmaps[0];
 		delete[] _bitmaps;
 	}
-	delete[] _wallSetBitMaps[kG696_Wall_D3R2]; // copy of another bitmap, but flipped
-	delete[] _wallSetBitMaps[kG710_DoorFrameRight_D1C]; // copy of another bitmap, but flipped
-	for (uint16 i = kG93_Wall_D0L_Flipped; i <= kG90_Wall_D3LCR_Flipped; ++i)
-		delete[] _wallSetBitMaps[i];
 
 	delete[] _g639_derivedBitmapByteCount;
 	if (_g638_derivedBitmaps) {
@@ -697,13 +691,37 @@ DisplayMan::~DisplayMan() {
 			delete[] _g638_derivedBitmaps;
 		delete[] _g638_derivedBitmaps;
 	}
+
+	delete[] _g85_bitmapCeiling;
+	delete[] _g84_bitmapFloor;
+	delete[] _g697_bitmapWallSet_Wall_D3L2;
+	delete[] _g696_bitmapWallSet_Wall_D3R2;
+	delete[] _g698_bitmapWallSet_Wall_D3LCR;
+	delete[] _g699_bitmapWallSet_Wall_D2LCR;
+	delete[] _g700_bitmapWallSet_Wall_D1LCR;
+	delete[] _g701_bitmapWallSet_Wall_D0L;
+	delete[] _g702_bitmapWallSet_Wall_D0R;
+	delete[] _g703_bitmapWallSet_DoorFrameTop_D2LCR;
+	delete[] _g704_bitmapWallSet_DoorFrameTop_D1LCR;
+	delete[] _g705_bitmapWallSet_DoorFrameLeft_D3L;
+	delete[] _g706_bitmapWallSet_DoorFrameLeft_D3C;
+	delete[] _g707_bitmapWallSet_DoorFrameLeft_D2C;
+	delete[] _g708_bitmapWallSet_DoorFrameLeft_D1C;
+	delete[] _g710_bitmapWallSet_DoorFrameRight_D1C;
+	delete[] _g709_bitmapWallSet_DoorFrameFront;
+	delete[] _g296_bitmapViewport;
+
+	delete[] _g90_bitmapWall_D3LCR_Flipped;
+	delete[] _g91_bitmapWall_D2LCR_Flipped;
+	delete[] _g92_bitmapWall_D1LCR_Flipped;
+	delete[] _g93_bitmapWall_D0L_Flipped;
+	delete[] _g94_bitmapWall_D0R_Flipped;
 }
 
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
 	_screenWidth = width;
 	_screenHeight = height;
 	delete[] _g74_tmpBitmap;
-	_g74_tmpBitmap = new byte[_screenWidth * _screenHeight];
 	delete[] _vgaBuffer;
 	_vgaBuffer = new byte[_screenWidth * _screenHeight];
 	clearScreen(k0_ColorBlack);
@@ -712,7 +730,6 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) {
 void DisplayMan::loadGraphics() {
 	Common::File f;
 	f.open("graphics.dat");
-
 	_grapItemCount = f.readUint16BE();
 	delete[] _packedItemPos;
 	_packedItemPos = new uint32[_grapItemCount + 1];
@@ -728,13 +745,31 @@ void DisplayMan::loadGraphics() {
 		_packedBitmaps[i] = f.readByte();
 
 	f.close();
-
 	unpackGraphics();
+}
 
-	loadFloorSet(k0_FloorSetStone);
-	loadWallSet(k0_WallSetStone);
-
-
+void DisplayMan::initializeGraphicData() {
+	_g85_bitmapCeiling = new byte[224 * 29];
+	_g84_bitmapFloor = new byte[224 * 70];
+	_g697_bitmapWallSet_Wall_D3L2 = new byte[16 * 49];
+	_g696_bitmapWallSet_Wall_D3R2 = new byte[16 * 49];
+	_g698_bitmapWallSet_Wall_D3LCR = new byte[128 * 51];
+	_g699_bitmapWallSet_Wall_D2LCR = new byte[144 * 71];
+	_g700_bitmapWallSet_Wall_D1LCR = new byte[256 * 111];
+	_g701_bitmapWallSet_Wall_D0L = new byte[32 * 136];
+	_g702_bitmapWallSet_Wall_D0R = new byte[32 * 136];
+	_g703_bitmapWallSet_DoorFrameTop_D2LCR = new byte[96 * 3];
+	_g704_bitmapWallSet_DoorFrameTop_D1LCR = new byte[128 * 4];
+	_g705_bitmapWallSet_DoorFrameLeft_D3L = new byte[32 * 43];
+	_g706_bitmapWallSet_DoorFrameLeft_D3C = new byte[32 * 44];
+	_g707_bitmapWallSet_DoorFrameLeft_D2C = new byte[48 * 65];
+	_g708_bitmapWallSet_DoorFrameLeft_D1C = new byte[32 * 94];
+	_g710_bitmapWallSet_DoorFrameRight_D1C = new byte[32 * 94];
+	_g709_bitmapWallSet_DoorFrameFront = new byte[32 * 123];
+	_g296_bitmapViewport = new byte[224 * 136];
+
+	warning("SKIPPED CODE: G0086_puc_Bitmap_ViewportBlackArea it is useless");
+	warning("SKIPPED CODE: G0087_puc_Bitmap_ViewportFloorArea it is useless");
 
 	if (!_g639_derivedBitmapByteCount)
 		_g639_derivedBitmapByteCount = new uint16[k730_DerivedBitmapMaximumCount];
@@ -900,6 +935,14 @@ void DisplayMan::loadFNT1intoBitmap(uint16 index, byte* destBitmap) {
 	}
 }
 
+void DisplayMan::f461_allocateFlippedWallBitmaps() {
+	_g90_bitmapWall_D3LCR_Flipped = new byte[128 * 51];
+	_g91_bitmapWall_D2LCR_Flipped = new byte[144 * 71];
+	_g92_bitmapWall_D1LCR_Flipped = new byte[256 * 111];
+	_g93_bitmapWall_D0L_Flipped = new byte[32 * 136];
+	_g94_bitmapWall_D0R_Flipped = new byte[32 * 136];
+}
+
 void DisplayMan::loadPalette(uint16 *palette) {
 	byte colorPalette[16 * 3];
 	for (int i = 0; i < 16; ++i) {
@@ -1061,6 +1104,11 @@ uint16 DisplayMan::getHeight(uint16 index) {
 	return READ_BE_UINT16(data + 2);
 }
 
+// Note: has been screened for missing code
+void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitmap, uint16 pixelWidth, uint16 height) {
+	memcpy(destBitmap, srcBitmap, pixelWidth * height * sizeof(byte));
+	flipBitmapHorizontal(destBitmap, pixelWidth, height);
+}
 
 void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
 	if (f._srcWidth)
@@ -1087,7 +1135,7 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
 			drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g121_FrameStairsDownFront_D3L);
 		goto T0116015_redEagle;
 	case k0_WallElemType:
-		drawWallSetBitmap(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k1_ViewSquare_D3L]);
+		drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k1_ViewSquare_D3L]);
 		isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT);
 		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
@@ -1101,7 +1149,7 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
 	case k17_ElementTypeDoorFront:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
 		cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
-		drawWallSetBitmap(_wallSetBitMaps[kG705_DoorFrameLeft_D3L], g164_Frame_DoorFrameLeft_D3L);
+		drawWallSetBitmap(_g705_bitmapWallSet_DoorFrameLeft_D3L, g164_Frame_DoorFrameLeft_D3L);
 		warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor");
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0116017_orangeElk;
@@ -1139,7 +1187,7 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
 		}
 		goto T0117016;
 	case k0_ElementTypeWall:
-		drawWallSetBitmap(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k2_ViewSquare_D3R]);
+		drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k2_ViewSquare_D3R]);
 		isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT);
 		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
@@ -1153,7 +1201,7 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
 	case k17_ElementTypeDoorFront:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
 		cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
-		memcpy(_g74_tmpBitmap, _wallSetBitMaps[kG705_DoorFrameLeft_D3L], 32 * 44);
+		memcpy(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44);
 		warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally");
 		if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
 			warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton");
@@ -1190,7 +1238,7 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) {
 			drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, g122_FrameStairsDownFront_D3C);
 		break;
 	case k0_WallElemType:
-		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k0_ViewSquare_D3C]);
+		drawWallSetBitmapWithoutTransparency(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k0_ViewSquare_D3C]);
 		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) {
 			//... missing code
 		}
@@ -1210,7 +1258,7 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) {
 			drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L);
 		break;
 	case k0_WallElemType:
-		drawWallSetBitmap(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k4_ViewSquare_D2L]);
+		drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k4_ViewSquare_D2L]);
 		isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT);
 		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) {
 			// ... missing code
@@ -1234,7 +1282,7 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) {
 			drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R);
 		break;
 	case k0_WallElemType:
-		drawWallSetBitmap(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k5_ViewSquare_D2R]);
+		drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k5_ViewSquare_D2R]);
 		isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT);
 		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) {
 			// ... missing code
@@ -1258,7 +1306,7 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) {
 			drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, g125_FrameStairsDownFront_D2C);
 		break;
 	case k0_WallElemType:
-		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k3_ViewSquare_D2C]);
+		drawWallSetBitmapWithoutTransparency(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k3_ViewSquare_D2C]);
 		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) {
 			// ... missing code
 		}
@@ -1278,7 +1326,7 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) {
 			drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g127_FrameStairsDownFront_D1L);
 		break;
 	case k0_WallElemType:
-		drawWallSetBitmap(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k7_ViewSquare_D1L]);
+		drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k7_ViewSquare_D1L]);
 		isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT);
 		break;
 	case k18_StairsSideElemType:
@@ -1302,7 +1350,7 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) {
 			drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g129_FrameStairsDownFront_D1R);
 		break;
 	case k0_WallElemType:
-		drawWallSetBitmap(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k8_ViewSquare_D1R]);
+		drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k8_ViewSquare_D1R]);
 		isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT);
 		break;
 	case k18_StairsSideElemType:
@@ -1329,7 +1377,7 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) {
 		_vm->_dungeonMan->_g286_isFacingAlcove = false;
 		_vm->_dungeonMan->_g287_isFacingViAltar = false;
 		_vm->_dungeonMan->_g288_isFacingFountain = false;
-		drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k6_ViewSquare_D1C]);
+		drawWallSetBitmapWithoutTransparency(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k6_ViewSquare_D1C]);
 		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) {
 			// .... code not yet implemneted
 		}
@@ -1348,7 +1396,7 @@ void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) {
 			drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, g138_FrameStairsSide_D0L);
 		break;
 	case k0_WallElemType:
-		drawWallSetBitmap(_wallSetBitMaps[kG701_Wall_D0L], g163_FrameWalls[k10_ViewSquare_D0L]);
+		drawWallSetBitmap(_g701_bitmapWallSet_Wall_D0L, g163_FrameWalls[k10_ViewSquare_D0L]);
 		break;
 	default:
 		break;
@@ -1364,7 +1412,7 @@ void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) {
 			drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R);
 		return;
 	case k0_WallElemType:
-		drawWallSetBitmap(_wallSetBitMaps[kG702_Wall_D0R], g163_FrameWalls[k11_ViewSquare_D0R]);
+		drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, g163_FrameWalls[k11_ViewSquare_D0R]);
 		break;
 	default:
 		break;
@@ -1392,7 +1440,7 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) {
 void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	loadPalette(g20_PalEntrance);
 	// TODO: this is a global variable, set from here
-	bool flippedFloorCeiling = (posX + posY + dir) & 1;
+	bool flippedFloorCeiling = true;
 
 	// NOTE: this can hold every bitmap, width and height is "flexible"
 	byte  *tmpBitmap = new byte[305 * 111];
@@ -1405,27 +1453,32 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 		_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i]._x1 = 255 + 1;
 	}
 
-	if (flippedFloorCeiling) {
+	if (_g76_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1) {
 		uint16 w = gK13_FloorFrame._srcWidth, h = gK13_FloorFrame._srcHeight;
-		blitToBitmap(_g84_floorBitmap, w, h, tmpBitmap, w);
+		blitToBitmap(_g84_bitmapFloor, w, h, tmpBitmap, w);
 		flipBitmapHorizontal(tmpBitmap, w, h);
 		drawWallSetBitmap(tmpBitmap, gK13_FloorFrame);
-		drawWallSetBitmap(_g85_ceilingBitmap, gK12_CeilingFrame);
-
-		for (uint16 i = 0; i <= kG698_Wall_D3LCR - kG702_Wall_D0R; ++i)
-			_wallSetBitMaps[i + kG702_Wall_D0R] = _wallSetBitMaps[i + kG94_Wall_D0R_Flipped];
+		drawWallSetBitmap(_g85_bitmapCeiling, gK12_CeilingFrame);
+
+		if (flippedFloorCeiling) {
+			_g698_bitmapWallSet_Wall_D3LCR = _g90_bitmapWall_D3LCR_Flipped;
+			_g699_bitmapWallSet_Wall_D2LCR = _g91_bitmapWall_D2LCR_Flipped;
+			_g700_bitmapWallSet_Wall_D1LCR = _g92_bitmapWall_D1LCR_Flipped;
+			_g701_bitmapWallSet_Wall_D0L = _g93_bitmapWall_D0L_Flipped;
+			_g702_bitmapWallSet_Wall_D0R = _g94_bitmapWall_D0R_Flipped;
+		}
 	} else {
 		uint16 w = gK12_CeilingFrame._srcWidth, h = gK12_CeilingFrame._srcHeight;
-		blitToBitmap(_g85_ceilingBitmap, w, h, tmpBitmap, w);
+		blitToBitmap(_g85_bitmapCeiling, w, h, tmpBitmap, w);
 		flipBitmapHorizontal(tmpBitmap, w, h);
 		drawWallSetBitmap(tmpBitmap, gK12_CeilingFrame);
-		drawWallSetBitmap(_g84_floorBitmap, gK13_FloorFrame);
+		drawWallSetBitmap(_g84_bitmapFloor, gK13_FloorFrame);
 	}
 
 	if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == k0_WallElemType)
-		drawWallSetBitmap(_wallSetBitMaps[kG697_Wall_D3L2], g711_FrameWall_D3L2);
+		drawWallSetBitmap(_g697_bitmapWallSet_Wall_D3L2, g711_FrameWall_D3L2);
 	if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == k0_WallElemType)
-		drawWallSetBitmap(_wallSetBitMaps[kG696_Wall_D3R2], g712_FrameWall_D3R2);
+		drawWallSetBitmap(_g696_bitmapWallSet_Wall_D3R2, g712_FrameWall_D3R2);
 
 	int16 tmpPosX = posX, tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY);
@@ -1462,9 +1515,13 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	drawSquareD0R(dir, tmpPosX, tmpPosY);
 	drawSquareD0C(dir, posX, posY);
 
-
-	for (uint16 i = 0; i <= kG698_Wall_D3LCR - kG702_Wall_D0R; ++i)
-		_wallSetBitMaps[i + kG702_Wall_D0R] = _wallSetBitMaps[i + kG99_Wall_D0R_Native];
+	if (flippedFloorCeiling) {
+		_g698_bitmapWallSet_Wall_D3LCR = _g95_bitmapWall_D3LCR_Native;
+		_g699_bitmapWallSet_Wall_D2LCR = _g96_bitmapWall_D2LCR_Native;
+		_g700_bitmapWallSet_Wall_D1LCR = _g97_bitmapWall_D1LCR_Native;
+		_g701_bitmapWallSet_Wall_D0L = _g98_bitmapWall_D0L_Native;
+		_g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native;
+	}
 
 	delete[] tmpBitmap;
 }
@@ -1477,43 +1534,44 @@ void DisplayMan::clearBitmap(byte *bitmap, uint16 width, uint16 height, Color co
 	memset(bitmap, color, sizeof(byte) * width * height);
 }
 
-
+// NOTE: has been screened for missing code
 void DisplayMan::loadFloorSet(FloorSet set) {
-	// there are 2 bitmaps per set, first one is at 75
-	GraphicIndice indice = (GraphicIndice)(k75_FirstFloorSet + (k2_FloorSetGraphicCount * set));
-	_g84_floorBitmap = _bitmaps[indice];
-	_g85_ceilingBitmap = _bitmaps[indice + 1];
+	if (_g230_currentFloorSet != set) {
+		_g230_currentFloorSet = set;
+		int16 index = (set * k2_FloorSetGraphicCount) + k75_FirstFloorSet;
+		loadIntoBitmap(index, _g84_bitmapFloor);
+		loadIntoBitmap(index + 1, _g85_bitmapCeiling);
+	}
 }
 
-
 Box g161_BoxWallBitmap_D3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR
 Box g162_BoxWallBitmap_D2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR
 
+// Note: has been screened for missing code
 void DisplayMan::loadWallSet(WallSet set) {
-	uint16 firstIndice = (set * k13_WallSetGraphicCount) + k77_FirstWallSet;
-	for (uint16 i = 0; i < k13_WallSetGraphicCount; ++i) {
-		_wallSetBitMaps[i] = _bitmaps[i + firstIndice];
-	}
 
-	for (uint16 i = 0; i <= kG698_Wall_D3LCR - kG702_Wall_D0R; ++i)
-		_wallSetBitMaps[i + kG99_Wall_D0R_Native] = _wallSetBitMaps[i + kG702_Wall_D0R];
-
-	uint16 srcIndex[7] = {kG708_DoorFrameLeft_D1C,  kG697_Wall_D3L2, kG700_Wall_D1LCR,         kG701_Wall_D0L,         kG702_Wall_D0R,
-	kG699_Wall_D2LCR,         kG698_Wall_D3LCR};
-
-	uint16 destIndex[7] = {kG710_DoorFrameRight_D1C, kG696_Wall_D3R2, kG92_Wall_D1LCR_Flipped, kG94_Wall_D0R_Flipped, kG93_Wall_D0L_Flipped,
-	kG91_Wall_D2LCR_Flipped, kG90_Wall_D3LCR_Flipped};
-
-	// the original loads these flipped walls in loadCurrentMapGraphics
-
-	for (uint16 i = 0; i < 7; ++i) {
-		uint16 srcGraphicIndice = firstIndice + srcIndex[i];
-		uint16 w = getWidth(srcGraphicIndice), h = getHeight(srcGraphicIndice);
-		delete[] _wallSetBitMaps[destIndex[i]];
-		_wallSetBitMaps[destIndex[i]] = new byte[w * h];
-		blitToBitmap(_wallSetBitMaps[srcIndex[i]], w, h, _wallSetBitMaps[destIndex[i]], w);
-		if (srcIndex[i] != kG699_Wall_D2LCR && srcIndex[i] != kG698_Wall_D3LCR) // TODO: implement flipping of these two bitmaps, disabled with if
-			flipBitmapHorizontal(_wallSetBitMaps[destIndex[i]], w, h);
+	if ((_g231_currentWallSet != set) || _vm->_g523_restartGameRequest) {
+		_g231_currentWallSet = set;
+		{
+			int16 graphicIndice = (set * k13_WallSetGraphicCount) + k77_FirstWallSet;
+			loadIntoBitmap(graphicIndice++, _g709_bitmapWallSet_DoorFrameFront);
+			loadIntoBitmap(graphicIndice++, _g708_bitmapWallSet_DoorFrameLeft_D1C);
+			loadIntoBitmap(graphicIndice++, _g707_bitmapWallSet_DoorFrameLeft_D2C);
+			loadIntoBitmap(graphicIndice++, _g706_bitmapWallSet_DoorFrameLeft_D3C);
+			loadIntoBitmap(graphicIndice++, _g705_bitmapWallSet_DoorFrameLeft_D3L);
+			loadIntoBitmap(graphicIndice++, _g704_bitmapWallSet_DoorFrameTop_D1LCR);
+			loadIntoBitmap(graphicIndice++, _g703_bitmapWallSet_DoorFrameTop_D2LCR);
+			loadIntoBitmap(graphicIndice++, _g702_bitmapWallSet_Wall_D0R);
+			loadIntoBitmap(graphicIndice++, _g701_bitmapWallSet_Wall_D0L);
+			loadIntoBitmap(graphicIndice++, _g700_bitmapWallSet_Wall_D1LCR);
+			loadIntoBitmap(graphicIndice++, _g699_bitmapWallSet_Wall_D2LCR);
+			loadIntoBitmap(graphicIndice++, _g698_bitmapWallSet_Wall_D3LCR);
+			loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2);
+		}
+		f99_copyBitmapAndFlipHorizontal(_g708_bitmapWallSet_DoorFrameLeft_D1C, _g710_bitmapWallSet_DoorFrameRight_D1C,
+										g171_Frame_DoorFrameRight_D1C._srcWidth, g171_Frame_DoorFrameRight_D1C._srcHeight);
+		f99_copyBitmapAndFlipHorizontal(_g697_bitmapWallSet_Wall_D3L2, _g696_bitmapWallSet_Wall_D3R2,
+										g712_FrameWall_D3R2._srcWidth, g712_FrameWall_D3R2._srcHeight);
 	}
 }
 
@@ -1522,7 +1580,28 @@ void DisplayMan::loadCurrentMapGraphics() {
 	loadFloorSet(_vm->_dungeonMan->_g269_currMap->_floorSet);
 	loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet);
 
-	// the original loads some flipped walls here, I moved it to loadWallSet
+	{
+		_g74_tmpBitmap = new byte[_screenWidth * _screenHeight];
+		_g578_useByteBoxCoordinates = true;
+
+		f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap,
+										g163_FrameWalls[k0_ViewSquare_D3C]._srcWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight);
+		clearBitmap(_g90_bitmapWall_D3LCR_Flipped, 128, 51, k10_ColorFlesh);
+		blitToBitmap(_g74_tmpBitmap, 128, 11, 0, _g90_bitmapWall_D3LCR_Flipped, 128, g161_BoxWallBitmap_D3LCR, k255_ColorNoTransparency);
+
+		f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap,
+										g163_FrameWalls[k3_ViewSquare_D2C]._srcWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight);
+		clearBitmap(_g91_bitmapWall_D2LCR_Flipped, 144, 71, k10_ColorFlesh);
+		blitToBitmap(_g74_tmpBitmap, 144, 8, 0, _g91_bitmapWall_D2LCR_Flipped, 144, g162_BoxWallBitmap_D2LCR, k255_ColorNoTransparency);
+
+		f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped,
+										g163_FrameWalls[k6_ViewSquare_D1C]._srcWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight);
+		f99_copyBitmapAndFlipHorizontal(_g98_bitmapWall_D0L_Native = _g701_bitmapWallSet_Wall_D0L, _g94_bitmapWall_D0R_Flipped,
+										g163_FrameWalls[k10_ViewSquare_D0L]._srcWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight);
+		f99_copyBitmapAndFlipHorizontal(_g99_bitmapWall_D0R_Native = _g702_bitmapWallSet_Wall_D0R, _g93_bitmapWall_D0L_Flipped,
+										g163_FrameWalls[k10_ViewSquare_D0L]._srcWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight);
+	}
+
 
 	{
 		int16 val = _vm->_dungeonMan->_g269_currMap->_wallSet * k18_StairsGraphicCount + k90_FirstStairs;
@@ -1691,7 +1770,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 			if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
 				if (isInscription) {
 					Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C];
-					blitToScreen(_wallSetBitMaps[kG700_Wall_D1LCR], D1CFrame._srcWidth, 94, 28, g202_BoxWallPatchBehindInscription._x1, g202_BoxWallPatchBehindInscription._x2,
+					blitToScreen(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, g202_BoxWallPatchBehindInscription._x1, g202_BoxWallPatchBehindInscription._x2,
 								 g202_BoxWallPatchBehindInscription._y1, g202_BoxWallPatchBehindInscription._y2, k255_ColorNoTransparency, g296_DungeonViewport);
 
 					unsigned char *string = inscriptionString;
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 80902e4..039d270 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -422,12 +422,7 @@ class DisplayMan {
 	byte *_packedBitmaps;
 	byte **_bitmaps;
 
-	// pointers 13,14 and [15-19] are owned by this array
-	byte *_wallSetBitMaps[25];	// @G[0696..0710]_puc_Bitmap_WallSet_...
-
 	// pointers are not owned by these fields
-	byte *_g84_floorBitmap; // @ G0084_puc_Bitmap_Floor
-	byte *_g85_ceilingBitmap; // @ G0085_puc_Bitmap_Ceiling
 	byte *_g75_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile
 
 	DisplayMan(const DisplayMan &other); // no implementation on purpose
@@ -482,7 +477,43 @@ class DisplayMan {
 	int16 _g690_stairsNativeBitmapIndex_Up_Side_D1L; // @ G0690_i_StairsNativeBitmapIndex_Up_Side_D1L
 	int16 _g691_stairsNativeBitmapIndex_Down_Side_D1L; // @ G0691_i_StairsNativeBitmapIndex_Down_Side_D1L
 	int16 _g692_stairsNativeBitmapIndex_Side_D0L; // @ G0692_i_StairsNativeBitmapIndex_Side_D0L
+
+
+	byte *_g84_bitmapFloor; // @ G0084_puc_Bitmap_Floor
+	byte *_g85_bitmapCeiling; // @ G0085_puc_Bitmap_Ceiling
+	byte *_g697_bitmapWallSet_Wall_D3L2; // @ G0697_puc_Bitmap_WallSet_Wall_D3L2
+	byte *_g696_bitmapWallSet_Wall_D3R2; // @ G0696_puc_Bitmap_WallSet_Wall_D3R2
+	byte *_g698_bitmapWallSet_Wall_D3LCR; // @ G0698_puc_Bitmap_WallSet_Wall_D3LCR
+	byte *_g699_bitmapWallSet_Wall_D2LCR; // @ G0699_puc_Bitmap_WallSet_Wall_D2LCR
+	byte *_g700_bitmapWallSet_Wall_D1LCR; // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR
+	byte *_g701_bitmapWallSet_Wall_D0L; // @ G0701_puc_Bitmap_WallSet_Wall_D0L
+	byte *_g702_bitmapWallSet_Wall_D0R; // @ G0702_puc_Bitmap_WallSet_Wall_D0R
+	byte *_g703_bitmapWallSet_DoorFrameTop_D2LCR; // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR
+	byte *_g704_bitmapWallSet_DoorFrameTop_D1LCR; // @ G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR
+	byte *_g705_bitmapWallSet_DoorFrameLeft_D3L; // @ G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L
+	byte *_g706_bitmapWallSet_DoorFrameLeft_D3C; // @ G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C
+	byte *_g707_bitmapWallSet_DoorFrameLeft_D2C; // @ G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C
+	byte *_g708_bitmapWallSet_DoorFrameLeft_D1C; // @ G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C
+	byte *_g710_bitmapWallSet_DoorFrameRight_D1C; // @ G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C
+	byte *_g709_bitmapWallSet_DoorFrameFront; // @ G0709_puc_Bitmap_WallSet_DoorFrameFront
+
+	byte *_g90_bitmapWall_D3LCR_Flipped; // @ G0090_puc_Bitmap_WallD3LCR_Flipped;
+	byte *_g91_bitmapWall_D2LCR_Flipped; // @ G0091_puc_Bitmap_WallD2LCR_Flipped;
+	byte *_g92_bitmapWall_D1LCR_Flipped; // @ G0092_puc_Bitmap_WallD1LCR_Flipped;
+	byte *_g93_bitmapWall_D0L_Flipped; // @ G0093_puc_Bitmap_WallD0L_Flipped;
+	byte *_g94_bitmapWall_D0R_Flipped; // @ G0094_puc_Bitmap_WallD0R_Flipped;
+	byte *_g95_bitmapWall_D3LCR_Native; // @ G0095_puc_Bitmap_WallD3LCR_Native;
+	byte *_g96_bitmapWall_D2LCR_Native; // @ G0096_puc_Bitmap_WallD2LCR_Native;
+	byte *_g97_bitmapWall_D1LCR_Native; // @ G0097_puc_Bitmap_WallD1LCR_Native;
+	byte *_g98_bitmapWall_D0L_Native; // @ G0098_puc_Bitmap_WallD0L_Native;
+	byte *_g99_bitmapWall_D0R_Native; // @ G0099_puc_Bitmap_WallD0R_Native;
+
+	int16 _g231_currentWallSet; // @ G0231_i_CurrentWallSet
+	int16 _g230_currentFloorSet;// @ G0230_i_CurrentFloorSet
+
+	bool _g76_useFlippedWallAndFootprintsBitmap; // @ G0076_B_UseFlippedWallAndFootprintsBitmaps
 public:
+	byte* _g296_bitmapViewport; // @ G0296_puc_Bitmap_Viewport
 	// some methods use this for a stratchpad, don't make assumptions about content between function calls
 	byte *_g74_tmpBitmap; // @ G0074_puc_Bitmap_Temporary
 
@@ -494,14 +525,19 @@ public:
 
 	void setUpScreens(uint16 width, uint16 height);
 	void loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader, F0460_START_InitializeGraphicData
+	void initializeGraphicData(); // @ F0460_START_InitializeGraphicData
 	void loadCurrentMapGraphics(); // @ F0096_DUNGEONVIEW_LoadCurrentMapGraphics_CPSDF
 	void loadPalette(uint16 *palette);
+	void f461_allocateFlippedWallBitmaps(); // @ F0461_START_AllocateFlippedWallBitmaps
 
 	/// Gives the width of an IMG0 type item
 	uint16 getWidth(uint16 index);
 	/// Gives the height of an IMG1 type item
 	uint16 getHeight(uint16 index);
 
+
+	void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height);
+
 	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 					  byte *destBitmap, uint16 destWidth,
 					  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
@@ -563,6 +599,8 @@ public:
 
 	Thing _g290_inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing
 
+	// This tells blitting functions wther to assume a BYTE_BOX or a WORD_BOX has been passed to them,
+	// I only use WORD_BOX, so this will probably deem useless
 	bool _g578_useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates
 	bool _g77_doNotDrawFluxcagesDuringEndgame; // @ G0077_B_DoNotDrawFluxcagesDuringEndgame
 
@@ -571,6 +609,7 @@ public:
 
 
 
+
 };
 
 }


Commit: c5f118079c943de4a1a721b8fd6d0932ea1eee52
    https://github.com/scummvm/scummvm/commit/c5f118079c943de4a1a721b8fd6d0932ea1eee52
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Renaming stuff

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/menus.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 95c5cf2..a459109 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1444,7 +1444,7 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 
 	// NOTE: this can hold every bitmap, width and height is "flexible"
 	byte  *tmpBitmap = new byte[305 * 111];
-	clearBitmap(tmpBitmap, 305, 111, k10_ColorFlesh);
+	f134_fillBitmap(tmpBitmap, 305, 111, k10_ColorFlesh);
 
 	for (int16 i = 0; i < 6; ++i)
 		_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i].setToZero();
@@ -1530,7 +1530,7 @@ void DisplayMan::clearScreen(Color color) {
 	memset(getCurrentVgaBuffer(), color, sizeof(byte) * _screenWidth * _screenHeight);
 }
 
-void DisplayMan::clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color) {
+void DisplayMan::f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color) {
 	memset(bitmap, color, sizeof(byte) * width * height);
 }
 
@@ -1586,12 +1586,12 @@ void DisplayMan::loadCurrentMapGraphics() {
 
 		f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap,
 										g163_FrameWalls[k0_ViewSquare_D3C]._srcWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight);
-		clearBitmap(_g90_bitmapWall_D3LCR_Flipped, 128, 51, k10_ColorFlesh);
+		f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, 128, 51, k10_ColorFlesh);
 		blitToBitmap(_g74_tmpBitmap, 128, 11, 0, _g90_bitmapWall_D3LCR_Flipped, 128, g161_BoxWallBitmap_D3LCR, k255_ColorNoTransparency);
 
 		f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap,
 										g163_FrameWalls[k3_ViewSquare_D2C]._srcWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight);
-		clearBitmap(_g91_bitmapWall_D2LCR_Flipped, 144, 71, k10_ColorFlesh);
+		f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, 144, 71, k10_ColorFlesh);
 		blitToBitmap(_g74_tmpBitmap, 144, 8, 0, _g91_bitmapWall_D2LCR_Flipped, 144, g162_BoxWallBitmap_D2LCR, k255_ColorNoTransparency);
 
 		f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped,
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 039d270..2a30c53 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -565,11 +565,12 @@ public:
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
 	byte *getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap
 
-	void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color);
+	void f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color); // @ F0134_VIDEO_FillBitmap
 	void clearScreen(Color color);
-	void clearScreenBox(Color color, Box &box, Viewport &viewport = gDefultViewPort); // @ D24_FillScreenBox
+	void clearScreenBox(Color color, Box &box, Viewport &viewport = gDefultViewPort); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox
 	void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
+
 	byte* getBitmap(uint16 index);
 	Common::MemoryReadStream getCompressedData(uint16 index);
 	uint32 getCompressedDataSize(uint16 index);
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index ee27ee0..890c8c0 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -101,7 +101,7 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) {
 	} else if (g237_ObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
 		iconIndex = _vm->_objectMan->getIconIndex(thing);
 	} else {
-		dm.clearBitmap(bitmapIcon, 16, 16, k4_ColorCyan);
+		dm.f134_fillBitmap(bitmapIcon, 16, 16, k4_ColorCyan);
 		goto T0386006;
 	}
 	_vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon);


Commit: 8c06b0afd0c4ca9fa8f147a40ccd7210250f5a88
    https://github.com/scummvm/scummvm/commit/8c06b0afd0c4ca9fa8f147a40ccd7210250f5a88
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0097_DUNGEONVIEW_DrawViewport

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/text.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index bc4d1c9..ec455c4 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -166,8 +166,14 @@ void DMEngine::initializeGame() {
 	warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
 }
 
+	void DMEngine::f448_initMemoryManager()
+	{
+		warning("STUB FUNCTION");
+		for (uint16 i = 0; i < 16; ++i)
+			_displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i];
+	}
 
-void DMEngine::startGame() {
+	void DMEngine::startGame() {
 	_g331_pressingEye = false;
 	_g332_stopPressingEye = false;
 	_g333_pressingMouth = false;
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 361ff9e..d439cfa 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -134,13 +134,15 @@ public:
 enum {
 	// engine debug channels
 	kDMDebugExample = 1 << 0,
-	kDMDebugUselessCode = 1 << 1
+	kDMDebugUselessCode = 1 << 1,
+	kDMDebugOftenCalledWarning = 2 << 2
 };
 
 class DMEngine : public Engine {
 	void startGame(); // @ F0462_START_StartGame_CPSF
 	void processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
 	void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
+	void f448_initMemoryManager(); // @ F0448_STARTUP1_InitializeMemoryManager_CPSADEF
 	void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF
 	void initArrays();
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index a459109..25d4c46 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -578,8 +578,7 @@ byte g222_PalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0,
 
 
 Viewport gDefultViewPort(0, 0, 320, 200);
-// TODO: I guessed the numbers
-Viewport g296_DungeonViewport(0, 33, 224, 126); // @ G0296_puc_Bitmap_Viewport
+Viewport g296_DungeonViewport(0, 33, 224, 136); // @ G0296_puc_Bitmap_Viewport
 
 byte g17_PalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges
 
@@ -594,7 +593,7 @@ byte g192_AlcoveOrnIndices[k3_AlcoveOrnCount] = { // @ G0192_auc_Graphic558_Alco
 
 
 DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
-	_vgaBuffer = nullptr;
+	_g348_bitmapScreen = nullptr;
 	_bitmaps = nullptr;
 	_grapItemCount = 0;
 	_packedItemPos = nullptr;
@@ -674,12 +673,16 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_g97_bitmapWall_D1LCR_Native = nullptr;
 	_g98_bitmapWall_D0L_Native = nullptr;
 	_g99_bitmapWall_D0R_Native = nullptr;
+
+	_g322_paletteSwitchingEnabled = false;
+	warning("DUMMY CODE: setting _g304_dungeonViewPaletteIndex");
+	_g304_dungeonViewPaletteIndex = 0;
 }
 
 DisplayMan::~DisplayMan() {
 	delete[] _packedItemPos;
 	delete[] _packedBitmaps;
-	delete[] _vgaBuffer;
+	delete[] _g348_bitmapScreen;
 	if (_bitmaps) {
 		delete[] _bitmaps[0];
 		delete[] _bitmaps;
@@ -722,8 +725,8 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) {
 	_screenWidth = width;
 	_screenHeight = height;
 	delete[] _g74_tmpBitmap;
-	delete[] _vgaBuffer;
-	_vgaBuffer = new byte[_screenWidth * _screenHeight];
+	delete[] _g348_bitmapScreen;
+	_g348_bitmapScreen = new byte[_screenWidth * _screenHeight];
 	clearScreen(k0_ColorBlack);
 }
 
@@ -943,6 +946,20 @@ void DisplayMan::f461_allocateFlippedWallBitmaps() {
 	_g94_bitmapWall_D0R_Flipped = new byte[32 * 136];
 }
 
+void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* topAndBottomScreen) {
+	if (middleScreenPalette && topAndBottomScreen)
+		debugC(kDMDebugOftenCalledWarning, "MISSING CODE: F0508_AMIGA_BuildPaletteChangeCopperList");
+
+	f566_viewportBlitToScreen();
+}
+
+void DisplayMan::f566_viewportBlitToScreen() {
+	warning("MISSING FUNCTIONALITY: using correct colorpalette");
+	Box box(0, 33, 223, 135);
+
+	blitToBitmap(_g296_bitmapViewport, k112_byteWidthViewport * 2, 0, 0, _g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
+}
+
 void DisplayMan::loadPalette(uint16 *palette) {
 	byte colorPalette[16 * 3];
 	for (int i = 0; i < 16; ++i) {
@@ -1033,7 +1050,7 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight
 void DisplayMan::blitBoxFilledWithMaskedBitmapToScreen(byte* src, byte* mask, byte* tmp, Box& box,
 													   int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
 													   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport& viewport) {
-	blitBoxFilledWithMaskedBitmap(src, _vgaBuffer, mask, tmp, box, lastUnitIndex, firstUnitIndex, _screenWidth, transparent, xPos, yPos, _screenHeight, height2, viewport);
+	blitBoxFilledWithMaskedBitmap(src, _g348_bitmapScreen, mask, tmp, box, lastUnitIndex, firstUnitIndex, _screenWidth, transparent, xPos, yPos, _screenHeight, height2, viewport);
 }
 
 void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) {
@@ -1086,12 +1103,42 @@ byte* DisplayMan::getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int
 
 
 void DisplayMan::updateScreen() {
-	_vm->_system->copyRectToScreen(_vgaBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
+	_vm->_system->copyRectToScreen(_g348_bitmapScreen, _screenWidth, 0, 0, _screenWidth, _screenHeight);
 	_vm->_system->updateScreen();
 }
 
+void DisplayMan::f97_drawViewport(int16 palSwitchingRequestedState) {
+	static uint16 *gK10_dungeonViewCurrentPalette; // @ K0010_pui_DungeonViewCurrentPalette
+
+	// ignored code F0510_AMIGA_WaitBottomOfViewPort
+	if (palSwitchingRequestedState == k2_viewportAsBeforeSleepOrFreezeGame)
+		palSwitchingRequestedState = _g322_paletteSwitchingEnabled ? 1 : 0;
+
+	if (_g342_refreshDungeonViewPaleteRequested) {
+		gK10_dungeonViewCurrentPalette = g21_PalDungeonView[_g304_dungeonViewPaletteIndex];
+		_g342_refreshDungeonViewPaleteRequested = false;
+		if (palSwitchingRequestedState == k0_viewportNotDungeonView) {
+			_g322_paletteSwitchingEnabled = true;
+		} else {
+			_g322_paletteSwitchingEnabled = false;
+		}
+	}
+
+	if (palSwitchingRequestedState != (_g322_paletteSwitchingEnabled ? 1 : 0)) {
+		if (palSwitchingRequestedState) {
+			f565_viewportSetPalette(gK10_dungeonViewCurrentPalette, _g347_paletteTopAndBottomScreen);
+			_g322_paletteSwitchingEnabled = true;
+		} else {
+			f565_viewportSetPalette(_g347_paletteTopAndBottomScreen, _g347_paletteTopAndBottomScreen);
+			_g322_paletteSwitchingEnabled = false;
+		}
+	} else {
+		f565_viewportSetPalette(nullptr, nullptr);
+	}
+}
+
 byte *DisplayMan::getCurrentVgaBuffer() {
-	return _vgaBuffer;
+	return _g348_bitmapScreen;
 }
 
 uint16 DisplayMan::getWidth(uint16 index) {
@@ -1685,6 +1732,8 @@ void DisplayMan::loadCurrentMapGraphics() {
 		if (replColorOrdinal)
 			applyCreatureReplColors(10, _vm->ordinalToIndex(replColorOrdinal));
 	}
+
+	_g342_refreshDungeonViewPaleteRequested = true;
 }
 
 void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor) {
@@ -2965,7 +3014,7 @@ byte* DisplayMan::getDerivedBitmap(int16 derivedBitmapIndex) {
 void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) {
 	uint16 width = box._x2 - box._x1;
 	for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y)
-		memset(_vgaBuffer + y * _screenWidth + box._x1 + viewport._posX, color, sizeof(byte) * width);
+		memset(_g348_bitmapScreen + y * _screenWidth + box._x1 + viewport._posX, color, sizeof(byte) * width);
 }
 
 void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 2a30c53..5efa58a 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -408,13 +408,21 @@ extern Viewport g296_DungeonViewport;
 #define k15_DoorOrnDestroyedMask 15 // @ C15_DOOR_ORNAMENT_DESTROYED_MASK
 #define k16_DoorOrnThivesEyeMask 16 // @ C16_DOOR_ORNAMENT_THIEVES_EYE_MASK
 
+#define k0_viewportNotDungeonView 0 // @ C0_VIEWPORT_NOT_DUNGEON_VIEW               
+#define k1_viewportDungeonView 1 // @ C1_VIEWPORT_DUNGEON_VIEW                   
+#define k2_viewportAsBeforeSleepOrFreezeGame 2 // @ C2_VIEWPORT_AS_BEFORE_SLEEP_OR_FREEZE_GAME 
+
+
+#define k112_byteWidthViewport 112 // @ C112_BYTE_WIDTH_VIEWPORT
+#define k136_heightViewport 136 // @ C136_HEIGHT_VIEWPORT 
+
+#define k160_byteWidthScreen 160 // @ C160_BYTE_WIDTH_SCREEN
+#define k200_heightScreen 200 // @ C200_HEIGHT_SCREEN   
+
 class DisplayMan {
 	friend class DM::TextMan;
 
 	DMEngine *_vm;
-	uint16 _screenWidth;
-	uint16 _screenHeight;
-	byte *_vgaBuffer;
 
 	/// Related to graphics.dat file
 	uint16 _grapItemCount; // @ G0632_ui_GraphicCount
@@ -434,6 +442,9 @@ class DisplayMan {
 	void unpackGraphics();
 	void loadFNT1intoBitmap(uint16 index, byte *destBitmap);
 
+	void f565_viewportSetPalette(uint16 * middleScreenPalette, uint16 * topAndBottomScreen); // @ F0565_VIEWPORT_SetPalette
+	void f566_viewportBlitToScreen(); // @ F0566_VIEWPORT_BlitToScreen
+
 	void drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally
 	void drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap
 	void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap
@@ -513,9 +524,17 @@ class DisplayMan {
 
 	bool _g76_useFlippedWallAndFootprintsBitmap; // @ G0076_B_UseFlippedWallAndFootprintsBitmaps
 public:
+	uint16 _screenWidth;
+	uint16 _screenHeight;
+	byte *_g348_bitmapScreen; // @ G0348_pl_Bitmap_Screen
 	byte* _g296_bitmapViewport; // @ G0296_puc_Bitmap_Viewport
+
 	// some methods use this for a stratchpad, don't make assumptions about content between function calls
 	byte *_g74_tmpBitmap; // @ G0074_puc_Bitmap_Temporary
+	bool _g322_paletteSwitchingEnabled; // @ G0322_B_PaletteSwitchingEnabled
+	bool _g342_refreshDungeonViewPaleteRequested; // @ G0342_B_RefreshDungeonViewPaletteRequested
+	int16 _g304_dungeonViewPaletteIndex; // @ G0304_i_DungeonViewPaletteIndex
+	uint16 _g347_paletteTopAndBottomScreen[16]; // @ G0347_aui_Palette_TopAndBottomScreen
 
 	explicit DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
@@ -561,7 +580,7 @@ public:
 											   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
 											   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = g296_DungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
 
-	void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height);
+	void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
 	byte *getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap
 
@@ -570,6 +589,7 @@ public:
 	void clearScreenBox(Color color, Box &box, Viewport &viewport = gDefultViewPort); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox
 	void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
+	void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport
 
 	byte* getBitmap(uint16 index);
 	Common::MemoryReadStream getCompressedData(uint16 index);
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index f526faa..67ac123 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -66,7 +66,7 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16
 }
 
 void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text, Viewport &viewport) {
-	printTextToBitmap(_vm->_displayMan->_vgaBuffer, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight, viewport);
+	printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight, viewport);
 }
 
 void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) {
@@ -82,7 +82,7 @@ void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, in
 }
 
 void TextMan::printWithTrailingSpacesToScreen(int16 destX, int16 destY, Color textColor, Color bgColor, const char* text, int16 strLenght, Viewport& viewport) {
-	printWithTrailingSpaces(_vm->_displayMan->_vgaBuffer, _vm->_displayMan->_screenWidth, destX, destY,
+	printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY,
 							textColor, bgColor, text, strLenght, _vm->_displayMan->_screenHeight, viewport);
 }
 


Commit: 883370eb7d0dfdfbc1ef15ed9f0458cdc1423368
    https://github.com/scummvm/scummvm/commit/883370eb7d0dfdfbc1ef15ed9f0458cdc1423368
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove several blitting overloads

Changed paths:
    engines/dm/champion.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/objectman.cpp
    engines/dm/objectman.h
    engines/dm/text.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 5a85434..a708251 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -462,7 +462,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	{ // limit destBox scope
 		Box &destBox = gBoxChampionPortrait;
 		dispMan.blitToBitmap(dispMan.getBitmap(k26_ChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex),
-							 champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, k255_ColorNoTransparency);
+							 champ->_portrait, 32, destBox, k255_ColorNoTransparency);
 	}
 
 	champ->_actionIndex = k255_ChampionActionNone;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 25d4c46..d41bf49 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1019,34 +1019,41 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
 	}
 }
 
-void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
-							  byte *destBitmap, uint16 destWidth,
-							  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
-							  Color transparent, Viewport &destViewport) {
-	for (uint16 y = 0; y < destToY - destFromY; ++y)
-		for (uint16 x = 0; x < destToX - destFromX; ++x) {
+
+void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent, Viewport& viewport) {
+	for (uint16 y = 0; y < box._y2 - box._y1; ++y)
+		for (uint16 x = 0; x < box._x2 - box._x1; ++x) {
 			byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x];
 			if (srcPixel != transparent)
-				destBitmap[destWidth * (y + destFromY + destViewport._posY) + destFromX + x + destViewport._posX] = srcPixel;
+				destBitmap[destWidth * (y + box._y1 + viewport._posY) + box._x1 + x + viewport._posX] = srcPixel;
 		}
+
 }
 
-void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent, Viewport& viewport) {
-	blitToBitmap(srcBitmap, srcWidth, srcX, srcY, destBitmap, destWidth, box._x1, box._x2, box._y1, box._y2, transparent, viewport);
+void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX, uint16 destY) {
+	for (uint16 y = 0; y < srcHeight; ++y)
+		memcpy(destBitmap + destWidth*(y + destY) + destX, srcBitmap + y * srcWidth, sizeof(byte)* srcWidth);
+}
+
+void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) {
+	uint16 width = box._x2 - box._x1;
+	for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y)
+		memset(_g348_bitmapScreen + y * _screenWidth + box._x1 + viewport._posX, color, sizeof(byte) * width);
 }
 
 void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
-							  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
+							  Box &box,
 							  Color transparent, Viewport &viewport) {
-	blitToBitmap(srcBitmap, srcWidth, srcX, srcY,
-				 getCurrentVgaBuffer(), _screenWidth, destFromX, destToX, destFromY, destToY, transparent, viewport);
+	blitToBitmap(srcBitmap, srcWidth, srcX, srcY, _g348_bitmapScreen, k160_byteWidthScreen * 2, box, transparent, viewport);
 }
 
-void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX, uint16 destY) {
-	for (uint16 y = 0; y < srcHeight; ++y)
-		memcpy(destBitmap + destWidth*(y + destY) + destX, srcBitmap + y * srcWidth, sizeof(byte)* srcWidth);
+void DisplayMan::blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box,
+											   int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
+											   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport) {
+	warning("STUB FUNCTION: does nothing at all");
 }
 
+
 void DisplayMan::blitBoxFilledWithMaskedBitmapToScreen(byte* src, byte* mask, byte* tmp, Box& box,
 													   int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
 													   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport& viewport) {
@@ -1819,8 +1826,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 			if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
 				if (isInscription) {
 					Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C];
-					blitToScreen(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, g202_BoxWallPatchBehindInscription._x1, g202_BoxWallPatchBehindInscription._x2,
-								 g202_BoxWallPatchBehindInscription._y1, g202_BoxWallPatchBehindInscription._y2, k255_ColorNoTransparency, g296_DungeonViewport);
+					blitToScreen(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, g202_BoxWallPatchBehindInscription, k255_ColorNoTransparency, g296_DungeonViewport);
 
 					unsigned char *string = inscriptionString;
 					bitmapRed = _bitmaps[k120_InscriptionFontIndice];
@@ -1923,12 +1929,12 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 				coordinateSetA[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
 			}
 		}
-		blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, coordinateSetA[0], coordinateSetA[1], coordinateSetA[2], coordinateSetA[3], k10_ColorFlesh, g296_DungeonViewport);
+		blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, *(Box*)coordinateSetA, k10_ColorFlesh, g296_DungeonViewport);
 
 		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
 			Box &box = g109_BoxChampionPortraitOnWall;
-			blitToScreen(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29, box._x1, box._x2, box._y1, box._y2,
-						 k1_ColorDarkGary, g296_DungeonViewport);
+			blitToScreen(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29,
+						 box, k1_ColorDarkGary, g296_DungeonViewport);
 		}
 		return isAlcove;
 	}
@@ -2250,8 +2256,8 @@ void DisplayMan::cthulhu(Thing thingParam, direction directionParam, int16 mapXp
 	bool drawProjectileAsObject;
 
 	bool sqaureHasProjectile;
-	uint16 currentViewCellToDraw;
-	bool projectileFlipVertical;
+	uint16 currentViewCellToDraw = 0;
+	bool projectileFlipVertical = false;
 	bool projectileAspectTypeHasBackGraphicAndRotation;
 	bool flipVertical;
 	Explosion* explosion;
@@ -3011,22 +3017,5 @@ byte* DisplayMan::getDerivedBitmap(int16 derivedBitmapIndex) {
 	return _g638_derivedBitmaps[derivedBitmapIndex];
 }
 
-void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) {
-	uint16 width = box._x2 - box._x1;
-	for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y)
-		memset(_g348_bitmapScreen + y * _screenWidth + box._x1 + viewport._posX, color, sizeof(byte) * width);
-}
-
-void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
-							  Box &box,
-							  Color transparent, Viewport &viewport) {
-	blitToScreen(srcBitmap, srcWidth, srcX, srcY, box._x1, box._x2, box._y1, box._y2, transparent, viewport);
-}
-
-void DisplayMan::blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box,
-											   int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
-											   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport) {
-	warning("STUB FUNCTION: does nothing at all");
-}
 
 }
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 5efa58a..60f6cdb 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -438,7 +438,6 @@ class DisplayMan {
 
 	byte *getCurrentVgaBuffer();
 	// the original function has two position parameters, but they are always set to zero
-	void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap
 	void unpackGraphics();
 	void loadFNT1intoBitmap(uint16 index, byte *destBitmap);
 
@@ -542,6 +541,7 @@ public:
 	void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet
 	void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet
 
+	void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap
 	void setUpScreens(uint16 width, uint16 height);
 	void loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader, F0460_START_InitializeGraphicData
 	void initializeGraphicData(); // @ F0460_START_InitializeGraphicData
@@ -557,28 +557,22 @@ public:
 
 	void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height);
 
-	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
-					  byte *destBitmap, uint16 destWidth,
-					  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
-					  Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort);
+
 	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 					  byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort);
-	void blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight,
-										 byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
 
 	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0);
-	void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
-					  uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
-					  Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort);
-	void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
-					  Box &box,
-					  Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort);
 	void blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
 									   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
 									   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDefultViewPort); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
+	void blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight,
+										 byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
 	void blitBoxFilledWithMaskedBitmapToScreen(byte *src, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
 											   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
 											   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = g296_DungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
+	void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
+					  Box &box,
+					  Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort);
 
 	void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 1d7bd95..0455469 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -94,9 +94,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	}
 
 	champion = &cm._champions[championIndex];
-	int16 w = dm.getWidth(k17_InventoryGraphicIndice);
-	int16 h = dm.getHeight(k17_InventoryGraphicIndice);
-	dm.blitToScreen(dm.getBitmap(k17_InventoryGraphicIndice), w, 0, 0, 0, w, 0, h, k255_ColorNoTransparency, g296_DungeonViewport);
+	dm.loadIntoBitmap(k17_InventoryGraphicIndice, dm._g296_bitmapViewport);
 	if (cm._g299_candidateChampionOrdinal) {
 		dm.clearScreenBox(k12_ColorDarkestGray, g41_BoxFloppyZzzCross, g296_DungeonViewport);
 	}
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 890c8c0..b2ad003 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -64,7 +64,7 @@ void MenuMan::drawMovementArrows() {
 	Box &dest = g2_BoxMovementArrows;
 	uint16 w = disp.getWidth(k13_MovementArrowsIndice);
 
-	disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, k255_ColorNoTransparency);
+	disp.blitToScreen(arrowsBitmap, w, 0, 0, dest, k255_ColorNoTransparency);
 }
 void MenuMan::clearActingChampion() {
 	ChampionMan &cm = *_vm->_championMan;
@@ -113,7 +113,7 @@ T0386006:
 	box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that
 	box2._y1 = 95;
 	box2._y2 = 110 + 1;
-	dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2);
+	dm.blitToScreen(bitmapIcon, 16, 0, 0, box2);
 	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) {
 		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 	}
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 499ae9d..40dc4f2 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -195,7 +195,8 @@ void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 	byte *srcBitmap = _vm->_displayMan->getBitmap(k42_ObjectIcons_000_TO_031 + i);
 	iconIndex -= g26_IconGraphicFirstIndex[i];
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
-	_vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, 0, 16, 0, 16, k255_ColorNoTransparency);
+	Box box(0, 0, 15, 15);
+	_vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, box, k255_ColorNoTransparency);
 }
 
 void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index f0d2bed..e4ce2cf 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -60,7 +60,7 @@ public:
 
 	IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType
 	IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
-	void extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // F0036_OBJECT_ExtractIconFromBitmap
+	void extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // @ F0036_OBJECT_ExtractIconFromBitmap
 	void drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox
 	void drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName
 	IconIndice getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 67ac123..c313b1f 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -59,8 +59,11 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16
 		if (nextY + k6_LetterHeight >= (viewport._posY + viewport._height))
 			break;
 		uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
+
+		Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth, nextY, nextY + k6_LetterHeight);
 		_vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth,
-			(nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight, k255_ColorNoTransparency, viewport);
+			box, k255_ColorNoTransparency, viewport);
+
 		nextX += k5_LetterWidth + 1;
 	}
 }


Commit: ce1c52bceb661fafdd828bb89bdd34563a38124f
    https://github.com/scummvm/scummvm/commit/ce1c52bceb661fafdd828bb89bdd34563a38124f
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove blitToScreen overloads

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/objectman.cpp
    engines/dm/text.cpp
    engines/dm/text.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index a708251..62fff7f 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -751,7 +751,8 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			if (_g407_party._shieldDefense > 0)
 				nativeBitmapIndices[AL_0_borderCount++] = k37_BorderPartyShieldIndice;
 			while (AL_0_borderCount--) {
-				dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, k10_ColorFlesh);
+				dispMan.blitToBitmap(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0,
+									 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k10_ColorFlesh);
 			}
 			if (isInventoryChamp) {
 				invMan.drawStatusBoxPortrait(champIndex);
@@ -760,8 +761,9 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 				champAttributes |= (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand);
 			}
 		} else {
-			dispMan.blitToScreen(dispMan.getBitmap(k8_StatusBoxDeadChampion), 80, 0, 0, box, k255_ColorNoTransparency);
-			_vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, champ->_name);
+			dispMan.blitToBitmap(dispMan.getBitmap(k8_StatusBoxDeadChampion), 80, 0, 0,
+								 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
+			_vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, champ->_name);
 			menuMan.drawActionIcon(champIndex);
 			goto T0292042_green;
 		}
@@ -788,7 +790,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			box._x1 = champStatusBoxX;
 			box._x2 = box._x1 + 42 + 1;
 			dispMan.clearScreenBox(k1_ColorDarkGary, box);
-			_vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, k1_ColorDarkGary, champ->_name);
+			_vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, k1_ColorDarkGary, champ->_name);
 		}
 	}
 
@@ -802,7 +804,8 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			} else {
 				AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			}
-			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, k12_ColorDarkestGray, g296_DungeonViewport);
+			dispMan.blitToBitmap(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0,
+								 dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, gBoxMouth, k12_ColorDarkestGray);
 			AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			for (int16 AL_0_statisticIndex = k1_ChampionStatStrength; AL_0_statisticIndex <= k6_ChampionStatAntifire; AL_0_statisticIndex++) {
 				if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent)
@@ -811,7 +814,8 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 					break;
 				}
 			}
-			dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, k12_ColorDarkestGray, g296_DungeonViewport);
+			dispMan.blitToBitmap(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0,
+								 dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, gBoxEye, k12_ColorDarkestGray);
 			champAttributes |= k0x4000_ChampionAttributeViewport;
 		}
 	}
@@ -854,8 +858,8 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 
 		if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) {
 			dispMan.clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]);
-			dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0,
-								 g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray);
+			dispMan.blitToBitmap(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0,
+								 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray);
 		}
 	}
 
@@ -881,7 +885,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	}
 
 	if (champAttributes & k0x4000_ChampionAttributeViewport) {
-		warning("MISSGIN CODE: F0097_DUNGEONVIEW_DrawViewport");
+		dispMan.f97_drawViewport(k0_viewportNotDungeonView);
 	}
 
 
@@ -975,8 +979,13 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 
 	if (nativeBitmapIndex != -1) {
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		_vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0,
-									   box, k12_ColorDarkestGray, isInventoryChamp ? g296_DungeonViewport : gDefultViewPort);
+		if (isInventoryChamp) {
+		_vm->_displayMan->blitToBitmap(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0,
+									   _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, box, k12_ColorDarkestGray);
+		} else {
+		_vm->_displayMan->blitToBitmap(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0,
+									   _vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, box, k12_ColorDarkestGray);
+		}
 	}
 
 	_vm->_objectMan->drawIconInSlotBox(slotBoxIndex, iconIndex);
@@ -998,8 +1007,9 @@ void ChampionMan::renameChampion(Champion* champ) {
 	box._x1 = 3;
 	box._x2 = box._x1 + 167;
 
-	dispMan.clearScreenBox(k12_ColorDarkestGray, box, g296_DungeonViewport);
-	dispMan.blitToScreen(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, g32_BoxPanel, k4_ColorCyan, g296_DungeonViewport);
+	dispMan.f135_fillBoxBitmap(dispMan._g296_bitmapViewport, box, k12_ColorDarkestGray, k112_byteWidthViewport * 2, k136_heightViewport);
+	dispMan.blitToBitmap(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0,
+						 dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k4_ColorCyan);
 	textMan.printToViewport(177, 58, k13_ColorLightestGray, "_______");
 	textMan.printToViewport(105, 76, k13_ColorLightestGray, "___________________");
 	Common::Point clickPos;
@@ -1009,6 +1019,7 @@ void ChampionMan::renameChampion(Champion* champ) {
 		if (_vm->_eventMan->hasPendingClick(clickPos, k1_LeftMouseButton) && okButtonBox.isPointInside(clickPos)) {
 			return;
 		}
+		dispMan.f97_drawViewport(k0_viewportNotDungeonView);
 		dispMan.updateScreen();
 	}
 }
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index ec455c4..f7e9e8f 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -263,11 +263,14 @@ void DMEngine::gameloop() {
 
 		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
 			Box box(0, 224, 0, 126);
-			_displayMan->clearScreenBox(k0_ColorBlack, box, g296_DungeonViewport); // dummy code
+			_displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport * 2, k136_heightViewport); // dummy code
 			_displayMan->drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
 		}
-		// DUMMY CODE: next line
+
+		// DUMMY CODE: next 2 lines
 		_menuMan->drawMovementArrows();
+		_displayMan->f97_drawViewport(k1_viewportDungeonView);
+
 		_displayMan->updateScreen();
 		_system->delayMillis(10);
 	}
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index d439cfa..7837ac4 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -96,6 +96,9 @@ enum Cell {
 	k3_CellSouthWest = 3 // @ C03_CELL_SOUTHWEST 
 };
 
+#define kM1_mapIndexNone -1 // @ CM1_MAP_INDEX_NONE       
+#define k255_mapIndexEntrance 255 // @ C255_MAP_INDEX_ENTRANCE 
+
 class Thing {
 	uint16 _data;
 public:
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index d41bf49..f430222 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -577,8 +577,6 @@ byte g222_PalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0,
 
 
 
-Viewport gDefultViewPort(0, 0, 320, 200);
-Viewport g296_DungeonViewport(0, 33, 224, 136); // @ G0296_puc_Bitmap_Viewport
 
 byte g17_PalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges
 
@@ -955,7 +953,7 @@ void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* to
 
 void DisplayMan::f566_viewportBlitToScreen() {
 	warning("MISSING FUNCTIONALITY: using correct colorpalette");
-	Box box(0, 33, 223, 135);
+	Box box(0, 223, 33, 33 + 135);
 
 	blitToBitmap(_g296_bitmapViewport, k112_byteWidthViewport * 2, 0, 0, _g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
 }
@@ -1020,12 +1018,12 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
 }
 
 
-void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent, Viewport& viewport) {
+void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent) {
 	for (uint16 y = 0; y < box._y2 - box._y1; ++y)
 		for (uint16 x = 0; x < box._x2 - box._x1; ++x) {
 			byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x];
 			if (srcPixel != transparent)
-				destBitmap[destWidth * (y + box._y1 + viewport._posY) + box._x1 + x + viewport._posX] = srcPixel;
+				destBitmap[destWidth * (y + box._y1) + box._x1 + x] = srcPixel;
 		}
 
 }
@@ -1035,30 +1033,24 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight
 		memcpy(destBitmap + destWidth*(y + destY) + destX, srcBitmap + y * srcWidth, sizeof(byte)* srcWidth);
 }
 
-void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) {
+void DisplayMan::clearScreenBox(Color color, Box &box) {
 	uint16 width = box._x2 - box._x1;
-	for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y)
-		memset(_g348_bitmapScreen + y * _screenWidth + box._x1 + viewport._posX, color, sizeof(byte) * width);
+	for (int16 y = box._y1; y < box._y2; ++y)
+		memset(_g348_bitmapScreen + y * _screenWidth + box._x1, color, sizeof(byte) * width);
 }
 
-void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
-							  Box &box,
-							  Color transparent, Viewport &viewport) {
-	blitToBitmap(srcBitmap, srcWidth, srcX, srcY, _g348_bitmapScreen, k160_byteWidthScreen * 2, box, transparent, viewport);
+void DisplayMan::f135_fillBoxBitmap(byte* destBitmap, Box &box, Color color, int16 pixelWidth, int16 height) {
+	for (int16 y = box._y1; y < box._y2; ++y)
+		memset(destBitmap + y * pixelWidth + box._x1, color, sizeof(byte) * (box._x2 - box._x1));
 }
 
 void DisplayMan::blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box,
 											   int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
-											   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport) {
+											   int16 xPos, int16 yPos, int16 destHeight, int16 height2) {
 	warning("STUB FUNCTION: does nothing at all");
 }
 
 
-void DisplayMan::blitBoxFilledWithMaskedBitmapToScreen(byte* src, byte* mask, byte* tmp, Box& box,
-													   int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
-													   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport& viewport) {
-	blitBoxFilledWithMaskedBitmap(src, _g348_bitmapScreen, mask, tmp, box, lastUnitIndex, firstUnitIndex, _screenWidth, transparent, xPos, yPos, _screenHeight, height2, viewport);
-}
 
 void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) {
 	for (uint16 y = 0; y < height; ++y) {
@@ -1166,12 +1158,12 @@ void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitm
 
 void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
 	if (f._srcWidth)
-		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k255_ColorNoTransparency, g296_DungeonViewport);
+		blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k255_ColorNoTransparency);
 }
 
 void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) {
 	if (f._srcWidth)
-		blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, g296_DungeonViewport);
+		blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh);
 }
 
 
@@ -1578,6 +1570,7 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	}
 
 	delete[] tmpBitmap;
+	f97_drawViewport((_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance) ? 1 : 0);
 }
 
 void DisplayMan::clearScreen(Color color) {
@@ -1752,16 +1745,15 @@ void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor
 }
 
 void DisplayMan::drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
-	if (f._srcWidth) {
-		blitToScreen(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, g296_DungeonViewport);
-	}
+	if (f._srcWidth)
+		blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh);
 }
 
 void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) {
 	if (f._srcWidth) {
 		blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcHeight, _g74_tmpBitmap, f._srcWidth);
 		flipBitmapHorizontal(_g74_tmpBitmap, f._srcWidth, f._srcHeight);
-		blitToScreen(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, g296_DungeonViewport);
+		blitToBitmap(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh);
 	}
 }
 
@@ -1826,7 +1818,8 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 			if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
 				if (isInscription) {
 					Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C];
-					blitToScreen(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, g202_BoxWallPatchBehindInscription, k255_ColorNoTransparency, g296_DungeonViewport);
+					blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, _g296_bitmapViewport, k112_byteWidthViewport * 2,
+								 g202_BoxWallPatchBehindInscription, k255_ColorNoTransparency);
 
 					unsigned char *string = inscriptionString;
 					bitmapRed = _bitmaps[k120_InscriptionFontIndice];
@@ -1840,7 +1833,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 						frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7;
 						frame._box._y1 = (frame._box._y2 = g203_InscriptionLineY[textLineIndex++]) - 7;
 						while (characterCount--) {
-							blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._box, k10_ColorFlesh, g296_DungeonViewport);
+							blitToBitmap(bitmapRed, 288, (*string++) * 8, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, frame._box, k10_ColorFlesh);
 							frame._box._x1 += 8;
 							frame._box._x2 += 8;
 						}
@@ -1929,12 +1922,12 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 				coordinateSetA[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
 			}
 		}
-		blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, *(Box*)coordinateSetA, k10_ColorFlesh, g296_DungeonViewport);
+		blitToBitmap(bitmapGreen, coordinateSetA[4], var_X, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, *(Box*)coordinateSetA, k10_ColorFlesh);
 
 		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
 			Box &box = g109_BoxChampionPortraitOnWall;
-			blitToScreen(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29,
-						 box, k1_ColorDarkGary, g296_DungeonViewport);
+			blitToBitmap(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29,
+						 _g296_bitmapViewport, k112_byteWidthViewport * 2, box, k1_ColorDarkGary);
 		}
 		return isAlcove;
 	}
@@ -2441,7 +2434,7 @@ T0115015_DrawProjectileAsObject:
 					AL_6_bitmapRedBanana = bitmapGreenAnt;
 					dunMan._g292_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */
 				}
-				blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, g296_DungeonViewport);
+				blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh);
 
 				if (drawProjectileAsObject)
 					goto T0115171_BackFromT0115015_DrawProjectileAsObject;
@@ -2692,7 +2685,7 @@ T0115077_DrawSecondHalfSquareCreature:
 			AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1);
 		}
 		warning("SUPER WARNINIG: we might nee noralized with on byteWidth");
-		blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, boxByteGreen, (Color)transparentColor, g296_DungeonViewport);
+		blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, (Color)transparentColor);
 
 T0115126_CreatureNotVisible:
 		if (twoHalfSquareCreaturesFrontView) {
@@ -2827,7 +2820,7 @@ the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part
 screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
 						AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - projectilePosX - 1));
 					}
-					blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, g296_DungeonViewport);
+					blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh);
 				} else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */
 					useAlcoveObjectImage = false;
 					projectileCoordinates[0] = projectilePosX;
@@ -2914,9 +2907,9 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _g74_tmpBitmap, 48, 32, g212_PalChangeSmoke);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
-				blitBoxFilledWithMaskedBitmapToScreen(AL_6_bitmapRedBanana, nullptr, getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C,
-													  _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64),
-													  224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
+				blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, nullptr, getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C,
+											  _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64),
+											  224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
 				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 			} else {
@@ -2979,7 +2972,7 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP
 				if (flipVertical) {
 					flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 				}
-				blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, g296_DungeonViewport);
+				blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh);
 			}
 		}
 	} while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList);
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 60f6cdb..7166908 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -321,14 +321,6 @@ public:
 }; // @ FIELD_ASPECT
 
 
-class Viewport {
-public:
-	uint16 _posX, _posY;
-	uint16 _width, _height;
-	Viewport() {}
-	Viewport(uint16 posX, uint16 posY, uint16 width, uint16 height)
-		:_posX(posX), _posY(posY), _width(width), _height(height) {}
-};
 
 class CreatureAspect {
 public:
@@ -398,9 +390,6 @@ public:
 	byte _D3ReplacementColor;
 }; // @ CREATURE_REPLACEMENT_COLOR_SET
 
-extern Viewport gDefultViewPort;
-extern Viewport g296_DungeonViewport;
-
 
 #define k0_DoorButton 0 // @ C0_DOOR_BUTTON
 #define k0_WallOrnInscription 0 // @ C0_WALL_ORNAMENT_INSCRIPTION
@@ -559,20 +548,14 @@ public:
 
 
 	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
-					  byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort);
+					  byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency);
 
 	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0);
 	void blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
 									   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
-									   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDefultViewPort); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
+									   int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
 	void blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight,
 										 byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
-	void blitBoxFilledWithMaskedBitmapToScreen(byte *src, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
-											   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
-											   int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = g296_DungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
-	void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
-					  Box &box,
-					  Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort);
 
 	void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
@@ -580,7 +563,8 @@ public:
 
 	void f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color); // @ F0134_VIDEO_FillBitmap
 	void clearScreen(Color color);
-	void clearScreenBox(Color color, Box &box, Viewport &viewport = gDefultViewPort); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox
+	void clearScreenBox(Color color, Box &box); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox
+	void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 pixelWidth, int16 height);
 	void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
 	void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 0455469..8118356 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -96,7 +96,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	champion = &cm._champions[championIndex];
 	dm.loadIntoBitmap(k17_InventoryGraphicIndice, dm._g296_bitmapViewport);
 	if (cm._g299_candidateChampionOrdinal) {
-		dm.clearScreenBox(k12_ColorDarkestGray, g41_BoxFloppyZzzCross, g296_DungeonViewport);
+		dm.f135_fillBoxBitmap(dm._g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport * 2, k136_heightViewport);
 	}
 	_vm->_textMan->printToViewport(5, 116, k13_ColorLightestGray, "HEALTH");
 	_vm->_textMan->printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
@@ -128,7 +128,8 @@ void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) {
 	box._y2 = 28 + 1;
 	box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7;
 	box._x2 = box._x1 + 31 + 1;
-	dispMan.blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0, box, k255_ColorNoTransparency);
+	dispMan.blitToBitmap(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0,
+						 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
 }
 
 void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
@@ -161,11 +162,15 @@ void InventoryMan::drawPanelFoodWaterPoisoned() {
 	Champion &champ = _vm->_championMan->_champions[_g432_inventoryChampionOrdinal];
 	closeChest();
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed);
-	dispMan.blitToScreen(dispMan.getBitmap(k30_FoodLabelIndice), 48, 0, 0, g35_BoxFood, k12_ColorDarkestGray);
-	dispMan.blitToScreen(dispMan.getBitmap(k31_WaterLabelIndice), 48, 0, 0, g36_BoxWater, k12_ColorDarkestGray);
+	dispMan.blitToBitmap(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0,
+						 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g32_BoxPanel, k8_ColorRed);
+	dispMan.blitToBitmap(dispMan.getBitmap(k30_FoodLabelIndice), 48, 0, 0,
+						 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g35_BoxFood, k12_ColorDarkestGray);
+	dispMan.blitToBitmap(dispMan.getBitmap(k31_WaterLabelIndice), 48, 0, 0,
+						 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g36_BoxWater, k12_ColorDarkestGray);
 	if (champ._poisonEventCount) {
-		dispMan.blitToScreen(dispMan.getBitmap(k32_PoisionedLabelIndice), 96, 0, 0, g37_BoxPoisoned, k12_ColorDarkestGray);
+		dispMan.blitToBitmap(dispMan.getBitmap(k32_PoisionedLabelIndice), 96, 0, 0,
+							 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g37_BoxPoisoned, k12_ColorDarkestGray);
 	}
 	drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown);
 	drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue);
@@ -173,7 +178,8 @@ void InventoryMan::drawPanelFoodWaterPoisoned() {
 
 void InventoryMan::drawPanelResurrectReincarnate() {
 	_g424_panelContent = k5_PanelContentResurrectReincarnate;
-	_vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, g32_BoxPanel, k6_ColorDarkGreen, g296_DungeonViewport);
+	_vm->_displayMan->blitToBitmap(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0,
+								   _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k6_ColorDarkGreen);
 }
 
 void InventoryMan::drawPanel() {
@@ -256,7 +262,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) {
 		charRed++;
 	}
 	*charRed = '\0';
-	dispMan.blitToScreen(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed, g296_DungeonViewport);
+	dispMan.blitToBitmap(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k8_ColorRed);
 	int16 lineCount = 1;
 	charRed++;
 	char *charGreen = charRed; // first char of the second line
@@ -308,7 +314,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 	if (!isPressingEye) {
 		objMan.drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen);
 	}
-	dispMan.blitToScreen(dispMan.getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed);
+	dispMan.blitToBitmap(dispMan.getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g32_BoxPanel, k8_ColorRed);
 
 	int16 chestSlotIndex = 0;
 	Thing thing = chest->getSlot();
@@ -334,7 +340,8 @@ void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yP
 	box._x2 = (box._x1 = xPos) + 15 + 1;
 	box._y2 = (box._y1 = yPos) + 15 + 1;
 	_vm->_objectMan->extractIconFromBitmap(iconIndex, iconBitmap);
-	_vm->_displayMan->blitToScreen(iconBitmap, 16, 0, 0, box, k255_ColorNoTransparency, g296_DungeonViewport);
+	_vm->_displayMan->blitToBitmap(iconBitmap, 16, 0, 0, _vm->_displayMan->_g296_bitmapViewport,
+								   k112_byteWidthViewport * 2, box, k255_ColorNoTransparency);
 }
 
 void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) {
@@ -408,8 +415,8 @@ Box g33_BoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOr
 
 void InventoryMan::drawPanelArrowOrEye(bool pressingEye) {
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.blitToScreen(dispMan.getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice),
-						 16, 0, 0, g33_BoxArrowOrEye, k8_ColorRed, g296_DungeonViewport);
+	dispMan.blitToBitmap(dispMan.getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice),
+						 16, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g33_BoxArrowOrEye, k8_ColorRed);
 }
 
 
@@ -441,8 +448,10 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye);
 	} else {
 		IconIndice iconIndex = objMan.getIconIndex(thingToDraw);
-		dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed, g296_DungeonViewport);
-		dispMan.blitToScreen(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, g34_BoxObjectDescCircle, k12_ColorDarkestGray, g296_DungeonViewport);
+		dispMan.blitToBitmap(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0,
+							 dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k8_ColorRed);
+		dispMan.blitToBitmap(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0,
+							 dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g34_BoxObjectDescCircle, k12_ColorDarkestGray);
 
 		char *descString = nullptr;
 		char str[40];
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index b2ad003..a512a90 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -64,7 +64,7 @@ void MenuMan::drawMovementArrows() {
 	Box &dest = g2_BoxMovementArrows;
 	uint16 w = disp.getWidth(k13_MovementArrowsIndice);
 
-	disp.blitToScreen(arrowsBitmap, w, 0, 0, dest, k255_ColorNoTransparency);
+	disp.blitToBitmap(arrowsBitmap, w, 0, 0, disp._g348_bitmapScreen, k160_byteWidthScreen * 2, dest, k255_ColorNoTransparency);
 }
 void MenuMan::clearActingChampion() {
 	ChampionMan &cm = *_vm->_championMan;
@@ -113,7 +113,7 @@ T0386006:
 	box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that
 	box2._y1 = 95;
 	box2._y2 = 110 + 1;
-	dm.blitToScreen(bitmapIcon, 16, 0, 0, box2);
+	dm.blitToBitmap(bitmapIcon, 16, 0, 0, dm._g348_bitmapScreen, k160_byteWidthScreen * 2, box2);
 	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) {
 		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 	}
@@ -208,13 +208,13 @@ void MenuMan::drawActionArea() {
 			box = g500_BoxActionArea2ActionMenu;
 		if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone)
 			box = g501_BoxActionArea1ActionMenu;
-		dispMan.blitToScreen(dispMan.getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, box, k255_ColorNoTransparency);
-		textMan.printWithTrailingSpacesToScreen(235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name,
-												k7_ChampionNameMaximumLength);
+		dispMan.blitToBitmap(dispMan.getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
+		textMan.printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name,
+												k7_ChampionNameMaximumLength, k200_heightScreen);
 		for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) {
-			textMan.printWithTrailingSpacesToScreen(241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
+			textMan.printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
 													getActionName(_g713_actionList._actionIndices[actionListIndex]),
-													k12_ActionNameMaximumLength);
+													k12_ActionNameMaximumLength, k200_heightScreen);
 		}
 	}
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
@@ -253,7 +253,7 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
 	switch (champIndex) {
 	case k0_ChampionFirst:
 		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
-		textMan.printTextToScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
+		textMan.f53_printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		if (champCount) {
 			if (champCurrHealth[1]) {
 				warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
@@ -277,7 +277,7 @@ labelChamp3:
 			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		}
 		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
-		textMan.printTextToScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
+		textMan.f53_printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		goto labelChamp2;
 	case k2_ChampionThird:
 		if (champCurrHealth[0]) {
@@ -287,7 +287,7 @@ labelChamp3:
 			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		}
 		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
-		textMan.printTextToScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
+		textMan.f53_printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		goto labelChamp3;
 	case k3_ChampionFourth:
 		if (champCurrHealth[0]) {
@@ -300,7 +300,7 @@ labelChamp3:
 			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		}
 		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
-		textMan.printTextToScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
+		textMan.f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		break;
 	}
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
@@ -345,7 +345,7 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
 		return;
 	if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) {
 		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-		dispMan.blitToScreen(dispMan.getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, g0_BoxSpellArea);
+		dispMan.blitToBitmap(dispMan.getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g0_BoxSpellArea);
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 	}
 	if (champIndex == kM1_ChampionNone) {
@@ -361,9 +361,9 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 	drawSpellAreaControls((ChampionIndex)champIndex);
-	dispMan.blitToScreen(_gK72_bitmapSpellAreaLine, 96, 0, 0, gK75_BoxSpellAreaLine2);
+	dispMan.blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK75_BoxSpellAreaLine2);
 	buildSpellAreaLine(k3_SpellAreaChampionSymbols);
-	dispMan.blitToScreen(_gK72_bitmapSpellAreaLine, 96, 0, 0, gK76_BoxSpellAreaLine3);
+	dispMan.blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK76_BoxSpellAreaLine3);
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 }
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 40dc4f2..2ce67ac 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -224,11 +224,12 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) {
-		_vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
-									   box, k255_ColorNoTransparency, g296_DungeonViewport);
+		_vm->_displayMan->blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
+									   _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, box, k255_ColorNoTransparency);
+
 	} else {
-		_vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
-									   box, k255_ColorNoTransparency, gDefultViewPort);
+		_vm->_displayMan->blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
+									   _vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
 	}
 }
 
@@ -246,7 +247,8 @@ void ObjectMan::drawLeaderObjectName(Thing thing) {
 	} else {
 		objName = _g352_objectNames[iconIndex];
 	}
-	_vm->_textMan->printWithTrailingSpacesToScreen(233, 37, k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength);
+	_vm->_textMan->printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, 233, 37,
+										   k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength, k200_heightScreen);
 }
 
 IconIndice ObjectMan::getIconIndexInSlotBox(uint16 slotBoxIndex) {
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index c313b1f..ebda268 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -36,7 +36,7 @@ TextMan::TextMan(DMEngine* vm) : _vm(vm) {}
 #define k6_LetterHeight 6
 
 void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY,
-								Color textColor, Color bgColor, const char* text, uint16 destHeight, Viewport &viewport) {
+								Color textColor, Color bgColor, const char* text, uint16 destHeight) {
 	destX -= 1; // fixes missalignment, to be checked
 	destY -= 4; // fixes missalignment, to be checked
 
@@ -52,41 +52,36 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16
 	srcBitmap = tmp;
 
 	for (const char *begin = text, *end = text + textLength; begin != end; ++begin) {
-		if (nextX + k5_LetterWidth + 1 >= (viewport._posX + viewport._width) || (*begin == '\n')) {
+		if (nextX + k5_LetterWidth + 1 >= destPixelWidth || (*begin == '\n')) {
 			nextX = destX;
 			nextY += k6_LetterHeight + 1;
 		}
-		if (nextY + k6_LetterHeight >= (viewport._posY + viewport._height))
+		if (nextY + k6_LetterHeight >= destHeight)
 			break;
 		uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
 
-		Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth, nextY, nextY + k6_LetterHeight);
+		Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1);
 		_vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth,
-			box, k255_ColorNoTransparency, viewport);
+			box, k255_ColorNoTransparency);
 
 		nextX += k5_LetterWidth + 1;
 	}
 }
 
-void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text, Viewport &viewport) {
-	printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight, viewport);
+void TextMan::f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text) {
+	printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight);
 }
 
 void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) {
-	printTextToScreen(posX, posY, textColor, bgColor, text, g296_DungeonViewport);
+	printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, posX, posY, textColor, bgColor, text, k200_heightScreen);
 }
 
 void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor,
-									  Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight, Viewport& viewport) {
+									  Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight) {
 	Common::String str = text;
 	for (int16 i = str.size(); i < requiredTextLength; ++i)
 		str += ' ';
-	printTextToBitmap(destBitmap, destPixelWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight, viewport);
-}
-
-void TextMan::printWithTrailingSpacesToScreen(int16 destX, int16 destY, Color textColor, Color bgColor, const char* text, int16 strLenght, Viewport& viewport) {
-	printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY,
-							textColor, bgColor, text, strLenght, _vm->_displayMan->_screenHeight, viewport);
+	printTextToBitmap(destBitmap, destPixelWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight);
 }
 
 }
diff --git a/engines/dm/text.h b/engines/dm/text.h
index 48c2d6e..c71f196 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -38,13 +38,11 @@ class TextMan {
 public:
 	explicit TextMan(DMEngine *vm);
 	void printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY,
-						   Color textColor, Color bgColor, const char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print
-	void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, Viewport &viewport = gDefultViewPort); // @ F0053_TEXT_PrintToLogicalScreen
+						   Color textColor, Color bgColor, const char *text, uint16 destHeight); // @ F0040_TEXT_Print
+	void f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text); // @ F0053_TEXT_PrintToLogicalScreen
 	void printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport
 	void printWithTrailingSpaces(byte *destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, Color bgColor,
-								 const char *text, int16 strLenght, int16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0041_TEXT_PrintWithTrailingSpaces
-	void printWithTrailingSpacesToScreen(int16 destX, int16 destY, Color textColor, Color bgColor,
-								 const char *text, int16 strLenght, Viewport &viewport = gDefultViewPort); // @ F0041_TEXT_PrintWithTrailingSpaces
+								 const char *text, int16 strLenght, int16 destHeight); // @ F0041_TEXT_PrintWithTrailingSpaces
 };
 
 }


Commit: 31b10d6d0d416658ef12416fb134e85adec7ac56
    https://github.com/scummvm/scummvm/commit/31b10d6d0d416658ef12416fb134e85adec7ac56
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove blitToBitmap overload

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index f430222..18deb96 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1028,11 +1028,6 @@ void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uin
 
 }
 
-void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX, uint16 destY) {
-	for (uint16 y = 0; y < srcHeight; ++y)
-		memcpy(destBitmap + destWidth*(y + destY) + destX, srcBitmap + y * srcWidth, sizeof(byte)* srcWidth);
-}
-
 void DisplayMan::clearScreenBox(Color color, Box &box) {
 	uint16 width = box._x2 - box._x1;
 	for (int16 y = box._y1; y < box._y2; ++y)
@@ -1067,9 +1062,9 @@ void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) {
 	byte *tmp = new byte[width];
 
 	for (uint16 y = 0; y < height / 2; ++y) {
-		memcpy(tmp, bitmap + y * width, width);
-		memcpy(bitmap + y * width, bitmap + (height - 1 - y) * width, width);
-		memcpy(bitmap + (height - 1 - y) * width, tmp, width);
+		memmove(tmp, bitmap + y * width, width);
+		memmove(bitmap + y * width, bitmap + (height - 1 - y) * width, width);
+		memmove(bitmap + (height - 1 - y) * width, tmp, width);
 	}
 
 	delete[] tmp;
@@ -1152,7 +1147,7 @@ uint16 DisplayMan::getHeight(uint16 index) {
 
 // Note: has been screened for missing code
 void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitmap, uint16 pixelWidth, uint16 height) {
-	memcpy(destBitmap, srcBitmap, pixelWidth * height * sizeof(byte));
+	memmove(destBitmap, srcBitmap, pixelWidth * height * sizeof(byte));
 	flipBitmapHorizontal(destBitmap, pixelWidth, height);
 }
 
@@ -1247,7 +1242,7 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
 	case k17_ElementTypeDoorFront:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
 		cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
-		memcpy(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44);
+		memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44);
 		warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally");
 		if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
 			warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton");
@@ -1488,9 +1483,6 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	// TODO: this is a global variable, set from here
 	bool flippedFloorCeiling = true;
 
-	// NOTE: this can hold every bitmap, width and height is "flexible"
-	byte  *tmpBitmap = new byte[305 * 111];
-	f134_fillBitmap(tmpBitmap, 305, 111, k10_ColorFlesh);
 
 	for (int16 i = 0; i < 6; ++i)
 		_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i].setToZero();
@@ -1500,11 +1492,9 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	}
 
 	if (_g76_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1) {
-		uint16 w = gK13_FloorFrame._srcWidth, h = gK13_FloorFrame._srcHeight;
-		blitToBitmap(_g84_bitmapFloor, w, h, tmpBitmap, w);
-		flipBitmapHorizontal(tmpBitmap, w, h);
-		drawWallSetBitmap(tmpBitmap, gK13_FloorFrame);
 		drawWallSetBitmap(_g85_bitmapCeiling, gK12_CeilingFrame);
+		f99_copyBitmapAndFlipHorizontal(_g84_bitmapFloor, _g74_tmpBitmap, k112_byteWidthViewport * 2, 70);
+		drawWallSetBitmap(_g74_tmpBitmap, gK13_FloorFrame);
 
 		if (flippedFloorCeiling) {
 			_g698_bitmapWallSet_Wall_D3LCR = _g90_bitmapWall_D3LCR_Flipped;
@@ -1514,10 +1504,8 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 			_g702_bitmapWallSet_Wall_D0R = _g94_bitmapWall_D0R_Flipped;
 		}
 	} else {
-		uint16 w = gK12_CeilingFrame._srcWidth, h = gK12_CeilingFrame._srcHeight;
-		blitToBitmap(_g85_bitmapCeiling, w, h, tmpBitmap, w);
-		flipBitmapHorizontal(tmpBitmap, w, h);
-		drawWallSetBitmap(tmpBitmap, gK12_CeilingFrame);
+		f99_copyBitmapAndFlipHorizontal(_g85_bitmapCeiling, _g74_tmpBitmap, k112_byteWidthViewport * 2, 29);
+		drawWallSetBitmap(_g74_tmpBitmap, gK12_CeilingFrame);
 		drawWallSetBitmap(_g84_bitmapFloor, gK13_FloorFrame);
 	}
 
@@ -1569,7 +1557,6 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 		_g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native;
 	}
 
-	delete[] tmpBitmap;
 	f97_drawViewport((_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance) ? 1 : 0);
 }
 
@@ -1751,8 +1738,7 @@ void DisplayMan::drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
 
 void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) {
 	if (f._srcWidth) {
-		blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcHeight, _g74_tmpBitmap, f._srcWidth);
-		flipBitmapHorizontal(_g74_tmpBitmap, f._srcWidth, f._srcHeight);
+		f99_copyBitmapAndFlipHorizontal(getBitmap(nativeIndex), _g74_tmpBitmap, f._srcWidth, f._srcHeight);
 		blitToBitmap(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh);
 	}
 }
@@ -1859,8 +1845,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 			}
 			bitmapGreen = _bitmaps[nativeBitmapIndex];
 			if (viewWallIndex == k11_ViewWall_D1R_LEFT) {
-				blitToBitmap(bitmapGreen, coordinateSetA[4], coordinateSetA[5], _g74_tmpBitmap, coordinateSetA[4]);
-				flipBitmapHorizontal(_g74_tmpBitmap, coordinateSetA[4], coordinateSetA[5]);
+				f99_copyBitmapAndFlipHorizontal(bitmapGreen, _g74_tmpBitmap, coordinateSetA[4], coordinateSetA[5]);
 				bitmapGreen = _g74_tmpBitmap;
 			}
 			var_X = 0;
@@ -1888,9 +1873,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 			bitmapGreen = _bitmaps[nativeBitmapIndex];
 			var_X = pixelWidth;
 			if (flipHorizontal) {
-				if (bitmapGreen != _g74_tmpBitmap)
-					blitToBitmap(bitmapGreen, coordSetB[4], coordSetB[5], _g74_tmpBitmap, coordSetB[4]);
-				flipBitmapHorizontal(_g74_tmpBitmap, coordSetB[4], coordSetB[5]);
+				f99_copyBitmapAndFlipHorizontal(bitmapGreen, _g74_tmpBitmap, coordSetB[4], coordSetB[5]);
 				bitmapGreen = _g74_tmpBitmap;
 				var_X = 15 - (var_X & 0xF);
 			} else if (viewWallIndex == k7_ViewWall_D2L_FRONT) {
@@ -1975,7 +1958,7 @@ void DisplayMan::drawField(FieldAspect* fieldAspect, Box& box) {
 		bitmapMask = nullptr;
 	} else {
 		bitmapMask = dispMan._g74_tmpBitmap;
-		memcpy(bitmapMask, dispMan.getBitmap(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)),
+		memmove(bitmapMask, dispMan.getBitmap(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)),
 			   fieldAspect->_height * fieldAspect->_pixelWidth * sizeof(bitmapMask[0]));
 		if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask)) {
 			dispMan.flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height);
@@ -2345,7 +2328,7 @@ T0115015_DrawProjectileAsObject:
 					byteWidth = objectAspect->_width;
 					heightRedEagle = objectAspect->_height;
 					if (flipHorizontal) {
-						memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
+						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
 						flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
@@ -2590,7 +2573,7 @@ T0115077_DrawSecondHalfSquareCreature:
 			if (useCreatureSideBitmap) {
 				AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex);
 				if (creatureDirectionDelta == 1) {
-					memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
+					memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
 					flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
@@ -2598,7 +2581,7 @@ T0115077_DrawSecondHalfSquareCreature:
 				if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) {
 					AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex);
 					if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
-						memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
+						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
 						flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
@@ -2609,7 +2592,7 @@ T0115077_DrawSecondHalfSquareCreature:
 						bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex);
 						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) {
 							AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
-							memcpy(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * heightRedEagle * sizeof(byte));
+							memmove(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * heightRedEagle * sizeof(byte));
 							flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 						}
 						warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
@@ -2652,7 +2635,7 @@ T0115077_DrawSecondHalfSquareCreature:
 					AL_4_normalizdByteWidth = byteWidth;
 					warning("SUPER WARNING: we might need getNormalizedByteWidthM77");
 					if (!useFlippedHorizontallyCreatureFrontImage) {
-						memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte));
+						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte));
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
 					flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
@@ -2794,7 +2777,7 @@ continue;
 						warning("might need noralized bytewidth");
 						AL_4_normalizdByteWidth = byteWidth;
 						if (AL_6_bitmapRedBanana != _g74_tmpBitmap) {
-							memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte));
+							memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte));
 							AL_6_bitmapRedBanana = _g74_tmpBitmap;
 						}
 						if (flipVertical) {
@@ -2963,7 +2946,7 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP
 				warning("might need M77_NORMALIZED_BYTE_WIDTH");
 				byteWidth = byteWidth;
 				if (flipHorizontal || flipVertical) {
-					memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle);
+					memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
 				if (flipHorizontal) {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 7166908..df48bec 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -550,7 +550,6 @@ public:
 	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
 					  byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency);
 
-	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0);
 	void blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
 									   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
 									   int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap


Commit: d69236e67430ffe1e5ac07abc2015f6bbf36d580
    https://github.com/scummvm/scummvm/commit/d69236e67430ffe1e5ac07abc2015f6bbf36d580
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rename functions

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/group.cpp
    engines/dm/group.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/loadsave.cpp
    engines/dm/loadsave.h
    engines/dm/menus.cpp
    engines/dm/menus.h
    engines/dm/movesens.cpp
    engines/dm/movesens.h
    engines/dm/objectman.cpp
    engines/dm/objectman.h
    engines/dm/text.cpp
    engines/dm/text.h
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 62fff7f..7986650 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -93,22 +93,22 @@ Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_Champi
 ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
 	_g411_leaderIndex = kM1_ChampionNone;
 
-	_303_partyDead = false;
+	_g303_partyDead = false;
 	_g300_partyIsSleeping = false;
 	_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
 	_g415_leaderEmptyHanded = true;
 	_g514_magicCasterChampionIndex = kM1_ChampionNone;
 }
 
-uint16 ChampionMan::getChampionPortraitX(uint16 index) {
+uint16 ChampionMan::M27_getChampionPortraitX(uint16 index) {
 	return ((index) & 0x7) << 5;
 }
 
-uint16 ChampionMan::getChampionPortraitY(uint16 index) {
+uint16 ChampionMan::M28_getChampionPortraitY(uint16 index) {
 	return ((index) >> 3) * 29;
 }
 
-int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) {
+int16 ChampionMan::f279_getDecodedValue(char *string, uint16 characterCount) {
 	int val = 0;
 	for (uint16 i = 0; i < characterCount; ++i) {
 		val = (val << 4) + (string[i] - 'A');
@@ -116,19 +116,19 @@ int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) {
 	return val;
 }
 
-void ChampionMan::drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) {
-	Common::String tmp = getStringFromInteger(currVal, true, 3).c_str();
-	_vm->_textMan->printToViewport(55, posY, k13_ColorLightestGray, tmp.c_str());
-	_vm->_textMan->printToViewport(73, posY, k13_ColorLightestGray, "/");
-	tmp = getStringFromInteger(maxVal, true, 3);
-	_vm->_textMan->printToViewport(79, posY, k13_ColorLightestGray, tmp.c_str());
+void ChampionMan::f289_drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) {
+	Common::String tmp = f288_getStringFromInteger(currVal, true, 3).c_str();
+	_vm->_textMan->f52_printToViewport(55, posY, k13_ColorLightestGray, tmp.c_str());
+	_vm->_textMan->f52_printToViewport(73, posY, k13_ColorLightestGray, "/");
+	tmp = f288_getStringFromInteger(maxVal, true, 3);
+	_vm->_textMan->f52_printToViewport(79, posY, k13_ColorLightestGray, tmp.c_str());
 }
 
-uint16 ChampionMan::handSlotIndex(uint16 slotBoxIndex) {
+uint16 ChampionMan::M70_handSlotIndex(uint16 slotBoxIndex) {
 	return slotBoxIndex & 0x1;
 }
 
-Common::String ChampionMan::getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) {
+Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) {
 	using namespace Common;
 	String valToStr = String::format("%d", val);
 	String result;
@@ -138,15 +138,15 @@ Common::String ChampionMan::getStringFromInteger(uint16 val, bool padding, uint1
 	return result += valToStr;
 }
 
-void ChampionMan::applyModifiersToStatistics(Champion* champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing) {
+void ChampionMan::f299_pplyModifiersToStatistics(Champion* champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing) {
 	int16 statIndex;
 	int16 modifier = 0;
 	ThingType thingType = thing.getType();
 	if (((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType))
 		&& (slotIndex >= k0_ChampionSlotReadyHand)
 		&& (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) {
-		Weapon *weapon = (Weapon*)_vm->_dungeonMan->getThingData(thing);
-		Armour *armour = (Armour*)_vm->_dungeonMan->getThingData(thing);
+		Weapon *weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(thing);
+		Armour *armour = (Armour*)_vm->_dungeonMan->f156_getThingData(thing);
 		if (((thingType == k5_WeaponThingType) && weapon->getCursed())
 			|| ((thingType == k6_ArmourThingType) && armour->getCursed())) {
 			statIndex = k0_ChampionStatLuck;
@@ -273,20 +273,20 @@ T0299044_ApplyModifier:
 
 }
 
-bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) {
+bool ChampionMan::f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) {
 	ObjectMan &objMan = *_vm->_objectMan;
 
-	IconIndice currIconIndex = objMan.getIconIndexInSlotBox(slotBoxIndex);
+	IconIndice currIconIndex = objMan.f39_getIconIndexInSlotBox(slotBoxIndex);
 	if (((currIconIndex < k32_IconIndiceWeaponDagger) && (currIconIndex >= k0_IconIndiceJunkCompassNorth))
 		|| ((currIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (currIconIndex <= k163_IconIndicePotionWaterFlask))
 		|| (currIconIndex == k195_IconIndicePotionEmptyFlask)) {
-		IconIndice newIconIndex = objMan.getIconIndex(thing);
+		IconIndice newIconIndex = objMan.f33_getIconIndex(thing);
 		if (newIconIndex != currIconIndex) {
 			if ((slotBoxIndex < k8_SlotBoxInventoryFirstSlot) && !_g420_mousePointerHiddenToDrawChangedObjIconOnScreen) {
 				_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
 				warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 			}
-			objMan.drawIconInSlotBox(slotBoxIndex, newIconIndex);
+			objMan.f38_drawIconInSlotBox(slotBoxIndex, newIconIndex);
 			return true;
 		}
 	}
@@ -294,7 +294,7 @@ bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing)
 	return false;
 }
 
-void ChampionMan::drawChangedObjectIcons() {
+void ChampionMan::f296_drawChangedObjectIcons() {
 	InventoryMan &invMan = *_vm->_inventoryMan;
 	ObjectMan &objMan = *_vm->_objectMan;
 	MenuMan &menuMan = *_vm->_menuMan;
@@ -309,52 +309,52 @@ void ChampionMan::drawChangedObjectIcons() {
 	if (((leaderHandObjIconIndex < k32_IconIndiceWeaponDagger) && (leaderHandObjIconIndex >= k0_IconIndiceJunkCompassNorth))	// < instead of <= is correct
 		|| ((leaderHandObjIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= k163_IconIndicePotionWaterFlask))
 		|| (leaderHandObjIconIndex == k195_IconIndicePotionEmptyFlask)) {
-		IconIndice iconIndex = objMan.getIconIndex(_414_leaderHandObject);
+		IconIndice iconIndex = objMan.f33_getIconIndex(_g414_leaderHandObject);
 		if (iconIndex != leaderHandObjIconIndex) {
 			_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
 			warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-			objMan.extractIconFromBitmap(iconIndex, objMan._g412_objectIconForMousePointer);
+			objMan.f36_extractIconFromBitmap(iconIndex, objMan._g412_objectIconForMousePointer);
 			warning("MISSING CODE: F0068_MOUSE_SetPointerToObject");
 			_g413_leaderHandObjectIconIndex = iconIndex;
-			objMan.drawLeaderObjectName(_414_leaderHandObject);
+			objMan.f34_drawLeaderObjectName(_g414_leaderHandObject);
 		}
 	}
 
 	for (uint16 slotBoxIndex = 0; slotBoxIndex < (_g305_partyChampionCount * 2); ++slotBoxIndex) {
 		int16 champIndex = slotBoxIndex >> 1;
-		if (invChampOrdinal == _vm->indexToOrdinal(champIndex))
+		if (invChampOrdinal == _vm->M0_indexToOrdinal(champIndex))
 			continue;
 
-		if (hasObjectIconInSlotBoxChanged(slotBoxIndex, _champions[champIndex].getSlot((ChampionSlot)handSlotIndex(slotBoxIndex)))
-			&& (handSlotIndex(slotBoxIndex) == k1_ChampionSlotActionHand)) {
+		if (f295_hasObjectIconInSlotBoxChanged(slotBoxIndex, _gK71_champions[champIndex].getSlot((ChampionSlot)M70_handSlotIndex(slotBoxIndex)))
+			&& (M70_handSlotIndex(slotBoxIndex) == k1_ChampionSlotActionHand)) {
 
-			menuMan.drawActionIcon((ChampionIndex)champIndex);
+			menuMan.f386_drawActionIcon((ChampionIndex)champIndex);
 		}
 	}
 
 	if (invChampOrdinal) {
-		Champion *champ = &_champions[_vm->ordinalToIndex(invChampOrdinal)];
+		Champion *champ = &_gK71_champions[_vm->M1_ordinalToIndex(invChampOrdinal)];
 		Thing *thing = &champ->getSlot(k0_ChampionSlotReadyHand);
 		uint16 drawViewport = 0;
 
 		for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++, thing++) {
-			uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + k8_SlotBoxInventoryFirstSlot, *thing) ? 1 : 0;
+			uint16 objIconChanged = f295_hasObjectIconInSlotBoxChanged(slotIndex + k8_SlotBoxInventoryFirstSlot, *thing) ? 1 : 0;
 			drawViewport |= objIconChanged;
 			if (objIconChanged && (slotIndex == k1_ChampionSlotActionHand)) {
-				menuMan.drawActionIcon((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
+				menuMan.f386_drawActionIcon((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal));
 			}
 		}
 
 		if (invMan._g424_panelContent = k4_PanelContentChest) {
 			thing = invMan._g425_chestSlots;
 			for (int16 slotIndex = 0; slotIndex < 8; ++slotIndex, thing++) {
-				drawViewport |= (hasObjectIconInSlotBoxChanged(slotIndex + k38_SlotBoxChestFirstSlot, *thing) ? 1 : 0);
+				drawViewport |= (f295_hasObjectIconInSlotBoxChanged(slotIndex + k38_SlotBoxChestFirstSlot, *thing) ? 1 : 0);
 			}
 		}
 
 		if (drawViewport) {
 			champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
-			drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
+			f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal));
 		}
 	}
 
@@ -362,7 +362,7 @@ void ChampionMan::drawChangedObjectIcons() {
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 
-void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex) {
+void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex) {
 	InventoryMan &invMan = *_vm->_inventoryMan;
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 	ObjectMan &objMan = *_vm->_objectMan;
@@ -371,7 +371,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 	if (thing == Thing::_none)
 		return;
 
-	Champion *champ = &_champions[champIndex];
+	Champion *champ = &_gK71_champions[champIndex];
 
 	if (slotIndex >= k30_ChampionSlotChest_1) {
 		invMan._g425_chestSlots[slotIndex - k30_ChampionSlotChest_1] = thing;
@@ -379,30 +379,30 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 		champ->setSlot(slotIndex, thing);
 	}
 
-	champ->_load += dunMan.getObjectWeight(thing);
+	champ->_load += dunMan.f140_getObjectWeight(thing);
 	champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
-	IconIndice iconIndex = objMan.getIconIndex(thing);
-	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal);
-	applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
-	uint16 *rawObjPtr = dunMan.getThingData(thing);
+	IconIndice iconIndex = objMan.f33_getIconIndex(thing);
+	bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal);
+	f299_pplyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
+	uint16 *rawObjPtr = dunMan.f156_getThingData(thing);
 
 	if (slotIndex < k2_ChampionSlotHead) {
 
 		if (slotIndex == k1_ChampionSlotActionHand) {
 			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
-			if (_g506_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
-				menuMan.clearActingChampion();
+			if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))
+				menuMan.f388_clearActingChampion();
 
 			if ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)) {
 				((Scroll*)rawObjPtr)->setClosed(false);
-				drawChangedObjectIcons();
+				f296_drawChangedObjectIcons();
 			}
 		}
 
 		if (iconIndex = k4_IconIndiceWeaponTorchUnlit) {
 			((Weapon*)rawObjPtr)->setLit(true);
 			warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette");
-			drawChangedObjectIcons();
+			f296_drawChangedObjectIcons();
 		} else if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand) &&
 			((iconIndex == k144_IconIndiceContainerChestClosed) || ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)))) {
 			champ->setAttributeFlag(k0x0800_ChampionAttributePanel, true);
@@ -422,33 +422,33 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 
 	}
 
-	drawSlot(champIndex, slotIndex);
+	f291_drawSlot(champIndex, slotIndex);
 	if (isInventoryChampion)
 		champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
 }
 
-ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
+ChampionIndex ChampionMan::f285_getIndexInCell(ViewCell cell) {
 	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
-		if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
+		if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
 			return (ChampionIndex)i;
 	}
 
 	return kM1_ChampionNone;
 }
 
-void ChampionMan::resetDataToStartGame() {
+void ChampionMan::f278_resetDataToStartGame() {
 	if (!_vm->_g298_newGame) {
 		warning("MISSING CODE: stuff for resetting for loaded games");
 		assert(false);
 	}
 
-	_414_leaderHandObject = Thing::_none;
+	_g414_leaderHandObject = Thing::_none;
 	_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
 	_g415_leaderEmptyHanded = true;
 }
 
 
-void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
+void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 
@@ -456,12 +456,12 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 		return;
 
 	uint16 prevChampCount = _g305_partyChampionCount;
-	Champion *champ = &_champions[prevChampCount];
+	Champion *champ = &_gK71_champions[prevChampCount];
 	champ->resetToZero();
 	dispMan._g578_useByteBoxCoordinates = true;
 	{ // limit destBox scope
 		Box &destBox = gBoxChampionPortrait;
-		dispMan.blitToBitmap(dispMan.getBitmap(k26_ChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex),
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k26_ChampionPortraitsIndice), 256, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex),
 							 champ->_portrait, 32, destBox, k255_ColorNoTransparency);
 	}
 
@@ -470,7 +470,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	champ->_hideDamageReceivedIndex = -1;
 	champ->_dir = dunMan._g308_partyDir;
 	ViewCell AL_0_viewCell = k0_ViewCellFronLeft;
-	while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3)) != kM1_ChampionNone)
+	while (f285_getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3)) != kM1_ChampionNone)
 		AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
 	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3);
 	champ->clearAttributes(k0x0400_ChampionAttributeIcon);
@@ -481,13 +481,13 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) {
 		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none);
 	}
-	Thing thing = dunMan.getSquareFirstThing(dunMan._g306_partyMapX, dunMan._g307_partyMapY);
+	Thing thing = dunMan.f161_getSquareFirstThing(dunMan._g306_partyMapX, dunMan._g307_partyMapY);
 	while (thing.getType() != k2_TextstringType) {
-		thing = dunMan.getNextThing(thing);
+		thing = dunMan.f159_getNextThing(thing);
 	}
 	char decodedChampionText[77];
 	char* character_Green = decodedChampionText;
-	dunMan.decodeText(character_Green, thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
+	dunMan.f168_decodeText(character_Green, thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
 	int16 AL_0_characterIndex = 0;
 	uint16 AL_2_character;
 	while ((AL_2_character = *character_Green++) != '\n') {
@@ -511,18 +511,18 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 		champ->setAttributeFlag(k0x0010_ChampionAttributeMale, true);
 	}
 	character_Green++;
-	champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4);
+	champ->_currHealth = champ->_maxHealth = f279_getDecodedValue(character_Green, 4);
 	character_Green += 4;
-	champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4);
+	champ->_currStamina = champ->_maxStamina = f279_getDecodedValue(character_Green, 4);
 	character_Green += 4;
-	champ->_currMana = champ->_maxMana = getDecodedValue(character_Green, 4);
+	champ->_currMana = champ->_maxMana = f279_getDecodedValue(character_Green, 4);
 	character_Green += 4;
 	character_Green++;
 
 	int16 AL_0_statisticIndex;
 	for (AL_0_statisticIndex = k0_ChampionStatLuck; AL_0_statisticIndex <= k6_ChampionStatAntifire; ++AL_0_statisticIndex) {
 		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k2_ChampionStatMinimum, 30);
-		uint16 currMaxVal = getDecodedValue(character_Green, 2);
+		uint16 currMaxVal = f279_getDecodedValue(character_Green, 2);
 		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent, currMaxVal);
 		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k0_ChampionStatMaximum, currMaxVal);
 		character_Green += 2;
@@ -550,11 +550,11 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 
 	_g299_candidateChampionOrdinal = prevChampCount + 1;
 	if (++_g305_partyChampionCount == 1) {
-		_vm->_eventMan->commandSetLeader(k0_ChampionFirst);
+		_vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst);
 		_vm->_menuMan->_g508_refreshActionArea = true;
 	} else {
-		_vm->_menuMan->clearActingChampion();
-		_vm->_menuMan->drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1));
+		_vm->_menuMan->f388_clearActingChampion();
+		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1));
 	}
 
 	int16 mapX = _vm->_dungeonMan->_g306_partyMapX;
@@ -563,13 +563,13 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._g308_partyDir));
 	mapX += _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
 	mapY += _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
-	thing = dunMan.getSquareFirstThing(mapX, mapY);
+	thing = dunMan.f161_getSquareFirstThing(mapX, mapY);
 	AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1;
 	uint16 slotIndex_Green;
 	while (thing != Thing::_endOfList) {
 		ThingType AL_2_thingType = thing.getType();
 		if ((AL_2_thingType > k3_SensorThingType) && (thing.getCell() == championObjectsCell)) {
-			int16 objectAllowedSlots = g237_ObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots();
+			int16 objectAllowedSlots = g237_ObjectInfo[dunMan.f141_getObjectInfoIndex(thing)].getAllowedSlots();
 			switch (AL_2_thingType) {
 			case k6_ArmourThingType:
 				for (slotIndex_Green = k2_ChampionSlotHead; slotIndex_Green <= k5_ChampionSlotFeet; slotIndex_Green++) {
@@ -616,18 +616,18 @@ T0280048:
 			if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_none) {
 				goto T0280046;
 			}
-			addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green);
+			f301_addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green);
 		}
-		thing = dunMan.getNextThing(thing);
+		thing = dunMan.f159_getNextThing(thing);
 	}
 
-	_vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount);
-	_vm->_menuMan->drawDisabledMenu();
+	_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)prevChampCount);
+	_vm->_menuMan->f456_drawDisabledMenu();
 }
 
-void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
+void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
 
-	Champion *curChampion = &_champions[champIndex];
+	Champion *curChampion = &_gK71_champions[champIndex];
 	int16 barGraphIndex = 0;
 	int16 barGraphHeightArray[3];
 
@@ -676,12 +676,12 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
 		if (barGraphHeight < 25) {
 			box._y1 = 2;
 			box._y1 = 27 - barGraphHeight + 1;
-			_vm->_displayMan->clearScreenBox(g46_ChampionColor[champIndex], box);
+			_vm->_displayMan->D24_clearScreenBox(g46_ChampionColor[champIndex], box);
 		}
 		if (barGraphHeight) {
 			box._y1 = 27 - barGraphHeight;
 			box._y2 = 26 + 1;
-			_vm->_displayMan->clearScreenBox(g46_ChampionColor[champIndex], box);
+			_vm->_displayMan->D24_clearScreenBox(g46_ChampionColor[champIndex], box);
 		}
 		box._x1 += 7;
 		box._x2 += 7;
@@ -690,7 +690,7 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
 }
 
 
-uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) {
+uint16 ChampionMan::f306_getStaminaAdjustedValue(Champion *champ, int16 val) {
 	int16 currStamina = champ->_currStamina;
 	int16 halfMaxStamina = champ->_maxStamina / 2;
 	if (currStamina < halfMaxStamina) {
@@ -701,14 +701,14 @@ uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) {
 	return val;
 }
 
-uint16 ChampionMan::getMaximumLoad(Champion *champ) {
+uint16 ChampionMan::f309_getMaximumLoad(Champion *champ) {
 	uint16 maximumLoad = champ->getStatistic(k1_ChampionStatStrength, k1_ChampionStatCurrent) * 8 + 100;
-	maximumLoad = getStaminaAdjustedValue(champ, maximumLoad);
+	maximumLoad = f306_getStaminaAdjustedValue(champ, maximumLoad);
 	int16 wounds = champ->getWounds();
 	if (wounds) {
 		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(k0x0010_ChampionWoundLegs) ? 2 : 3);
 	}
-	if (_vm->_objectMan->getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == k119_IconIndiceArmourElvenBoots) {
+	if (_vm->_objectMan->f33_getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == k119_IconIndiceArmourElvenBoots) {
 		maximumLoad += maximumLoad * 16;
 	}
 	maximumLoad += 9;
@@ -716,7 +716,7 @@ uint16 ChampionMan::getMaximumLoad(Champion *champ) {
 	return maximumLoad;
 }
 
-void ChampionMan::drawChampionState(ChampionIndex champIndex) {
+void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 	InventoryMan &invMan = *_vm->_inventoryMan;
 	DisplayMan &dispMan = *_vm->_displayMan;
 	MenuMan &menuMan = *_vm->_menuMan;
@@ -724,14 +724,14 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 
 	Box box;
 	int16 champStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
-	Champion *champ = &_champions[champIndex];
+	Champion *champ = &_gK71_champions[champIndex];
 	uint16 champAttributes = champ->getAttributes();
 	if (!((champAttributes) & (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon |
 							   k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport |
 							   k0x8000_ChampionAttributeActionHand))) {
 		return;
 	}
-	bool isInventoryChamp = (_vm->indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal);
+	bool isInventoryChamp = (_vm->M0_indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal);
 	dispMan._g578_useByteBoxCoordinates = false;
 	if (champAttributes & k0x1000_ChampionAttributeStatusBox) {
 		box._y1 = 0;
@@ -739,7 +739,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		box._x1 = champStatusBoxX;
 		box._x2 = box._x1 + 66 + 1;
 		if (champ->_currHealth) {
-			dispMan.clearScreenBox(k12_ColorDarkestGray, box);
+			dispMan.D24_clearScreenBox(k12_ColorDarkestGray, box);
 			int16 nativeBitmapIndices[3];
 			for (int16 i = 0; i < 3; ++i)
 				nativeBitmapIndices[i] = 0;
@@ -751,20 +751,20 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			if (_g407_party._shieldDefense > 0)
 				nativeBitmapIndices[AL_0_borderCount++] = k37_BorderPartyShieldIndice;
 			while (AL_0_borderCount--) {
-				dispMan.blitToBitmap(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0,
+				dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0,
 									 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k10_ColorFlesh);
 			}
 			if (isInventoryChamp) {
-				invMan.drawStatusBoxPortrait(champIndex);
+				invMan.f354_drawStatusBoxPortrait(champIndex);
 				champAttributes |= k0x0100_ChampionAttributeStatistics;
 			} else {
 				champAttributes |= (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand);
 			}
 		} else {
-			dispMan.blitToBitmap(dispMan.getBitmap(k8_StatusBoxDeadChampion), 80, 0, 0,
+			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k8_StatusBoxDeadChampion), 80, 0, 0,
 								 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
 			_vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, champ->_name);
-			menuMan.drawActionIcon(champIndex);
+			menuMan.f386_drawActionIcon(champIndex);
 			goto T0292042_green;
 		}
 	}
@@ -776,35 +776,35 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		Color AL_0_colorIndex = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; // unused because of missing functions
 		if (isInventoryChamp) {
 			char *champName = champ->_name;
-			_vm->_textMan->printToViewport(3, 7, AL_0_colorIndex, champName);
+			_vm->_textMan->f52_printToViewport(3, 7, AL_0_colorIndex, champName);
 			int16 champTitleX = 6 * strlen(champName) + 3;
 			char champTitleFirstChar = champ->_title[0];
 			if ((champTitleFirstChar != ',') && (champTitleFirstChar != ';') && (champTitleFirstChar != '-')) {
 				champTitleX += 6;
 			}
-			_vm->_textMan->printToViewport(champTitleX, 7, AL_0_colorIndex, champ->_title);
+			_vm->_textMan->f52_printToViewport(champTitleX, 7, AL_0_colorIndex, champ->_title);
 			champAttributes |= k0x4000_ChampionAttributeViewport;
 		} else {
 			box._y1 = 0;
 			box._y2 = 6 + 1;
 			box._x1 = champStatusBoxX;
 			box._x2 = box._x1 + 42 + 1;
-			dispMan.clearScreenBox(k1_ColorDarkGary, box);
+			dispMan.D24_clearScreenBox(k1_ColorDarkGary, box);
 			_vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, k1_ColorDarkGary, champ->_name);
 		}
 	}
 
 	if (champAttributes & k0x0100_ChampionAttributeStatistics) {
-		drawChampionBarGraphs(champIndex);
+		f287_drawChampionBarGraphs(champIndex);
 		if (isInventoryChamp) {
-			drawHealthStaminaManaValues(champ);
+			f290_drawHealthStaminaManaValues(champ);
 			int16 AL_2_nativeBitmapIndex;
 			if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) {
 				AL_2_nativeBitmapIndex = k34_SlotBoxWoundedIndice;
 			} else {
 				AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			}
-			dispMan.blitToBitmap(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0,
+			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0,
 								 dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, gBoxMouth, k12_ColorDarkestGray);
 			AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			for (int16 AL_0_statisticIndex = k1_ChampionStatStrength; AL_0_statisticIndex <= k6_ChampionStatAntifire; AL_0_statisticIndex++) {
@@ -814,7 +814,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 					break;
 				}
 			}
-			dispMan.blitToBitmap(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0,
+			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0,
 								 dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, gBoxEye, k12_ColorDarkestGray);
 			champAttributes |= k0x4000_ChampionAttributeViewport;
 		}
@@ -822,7 +822,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 
 	if (champAttributes & k0x2000_ChampionAttributeWounds) {
 		for (int16 AL_0_slotIndex = isInventoryChamp ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL_0_slotIndex >= k0_ChampionSlotReadyHand; AL_0_slotIndex--) {
-			drawSlot(champIndex, (ChampionSlot)AL_0_slotIndex);
+			f291_drawSlot(champIndex, (ChampionSlot)AL_0_slotIndex);
 		}
 		if (isInventoryChamp) {
 			champAttributes |= k0x4000_ChampionAttributeViewport;
@@ -831,7 +831,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 
 	if ((champAttributes & k0x0200_ChampionAttributeLoad) && isInventoryChamp) {
 		Color loadColor;
-		int16 champMaxLoad = getMaximumLoad(champ);
+		int16 champMaxLoad = f309_getMaximumLoad(champ);
 		if (champ->_load > champMaxLoad) {
 			loadColor = k8_ColorRed;
 		} else if (((int32)champ->_load) * 8 > ((int32)champMaxLoad) * 5) {
@@ -839,46 +839,46 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		} else {
 			loadColor = k13_ColorLightestGray;
 		}
-		_vm->_textMan->printToViewport(104, 132, loadColor, "LOAD ");
+		_vm->_textMan->f52_printToViewport(104, 132, loadColor, "LOAD ");
 
 		int16 loadTmp = champ->_load / 10;
-		Common::String str = getStringFromInteger(loadTmp, true, 3);
+		Common::String str = f288_getStringFromInteger(loadTmp, true, 3);
 		str += '.';
 		loadTmp = champ->_load - (loadTmp * 10);
-		str += getStringFromInteger(loadTmp, false, 1);
+		str += f288_getStringFromInteger(loadTmp, false, 1);
 		str += '/';
-		loadTmp = (getMaximumLoad(champ) + 5) / 10;
+		loadTmp = (f309_getMaximumLoad(champ) + 5) / 10;
 		str += "KG";
-		_vm->_textMan->printToViewport(148, 132, loadColor, str.c_str());
+		_vm->_textMan->f52_printToViewport(148, 132, loadColor, str.c_str());
 		champAttributes |= k0x4000_ChampionAttributeViewport;
 	}
 
 	{ // block so goto won't skip AL_0_championIconIndex initialization 
-		int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_g308_partyDir);
+		int16 AL_0_championIconIndex = M26_championIconIndex(champ->_cell, _vm->_dungeonMan->_g308_partyDir);
 
-		if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) {
-			dispMan.clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]);
-			dispMan.blitToBitmap(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0,
+		if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL_0_championIconIndex))) {
+			dispMan.D24_clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]);
+			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k28_ChampionIcons), 80, M26_championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0,
 								 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray);
 		}
 	}
 
 	if ((champAttributes & k0x0800_ChampionAttributePanel) && isInventoryChamp) {
 		if (_vm->_g333_pressingMouth) {
-			invMan.drawPanelFoodWaterPoisoned();
+			invMan.f345_drawPanelFoodWaterPoisoned();
 		} else if (_vm->_g331_pressingEye) {
 			if (_g415_leaderEmptyHanded) {
 				warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics");
 			}
 		} else {
-			invMan.drawPanel();
+			invMan.f347_drawPanel();
 		}
 		champAttributes |= k0x4000_ChampionAttributeViewport;
 	}
 
 	if (champAttributes & k0x8000_ChampionAttributeActionHand) {
-		drawSlot(champIndex, k1_ChampionSlotActionHand);
-		menuMan.drawActionIcon(champIndex);
+		f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
+		menuMan.f386_drawActionIcon(champIndex);
 		if (isInventoryChamp) {
 			champAttributes |= k0x4000_ChampionAttributeViewport;
 		}
@@ -896,24 +896,24 @@ T0292042_green:
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 
-uint16 ChampionMan::championIconIndex(int16 val, direction dir) {
+uint16 ChampionMan::M26_championIconIndex(int16 val, direction dir) {
 	return ((val + 4 - dir) & 0x3);
 }
 
-void ChampionMan::drawHealthStaminaManaValues(Champion* champ) {
-	drawHealthOrStaminaOrManaValue(116, champ->_currHealth, champ->_maxHealth);
-	drawHealthOrStaminaOrManaValue(124, champ->_currStamina, champ->_maxStamina);
-	drawHealthOrStaminaOrManaValue(132, champ->_currMana, champ->_maxMana);
+void ChampionMan::f290_drawHealthStaminaManaValues(Champion* champ) {
+	f289_drawHealthOrStaminaOrManaValue(116, champ->_currHealth, champ->_maxHealth);
+	f289_drawHealthOrStaminaOrManaValue(124, champ->_currStamina, champ->_maxStamina);
+	f289_drawHealthOrStaminaOrManaValue(132, champ->_currMana, champ->_maxMana);
 }
 
-void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
+void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 	int16 nativeBitmapIndex = -1;
-	Champion *champ = &_champions[champIndex];
-	bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex));
+	Champion *champ = &_gK71_champions[champIndex];
+	bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex));
 
 	uint16 slotBoxIndex;
 	if (!isInventoryChamp) {  /* If drawing a slot for a champion other than the champion whose inventory is open */
-		if ((slotIndex > k1_ChampionSlotActionHand) || (_g299_candidateChampionOrdinal == _vm->indexToOrdinal(champIndex))) {
+		if ((slotIndex > k1_ChampionSlotActionHand) || (_g299_candidateChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))) {
 			return;
 		}
 		slotBoxIndex = (champIndex << 1) + slotIndex;
@@ -959,7 +959,7 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 		}
 	} else {
 		warning("BUG0_35");
-		iconIndex = _vm->_objectMan->getIconIndex(thing); // BUG0_35
+		iconIndex = _vm->_objectMan->f33_getIconIndex(thing); // BUG0_35
 		if (isInventoryChamp && (slotIndex == k1_ChampionSlotActionHand) && ((iconIndex == k144_IconIndiceContainerChestClosed) || (iconIndex == k30_IconIndiceScrollOpen))) {
 			warning("BUG2_00");
 			iconIndex++;
@@ -973,29 +973,29 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 		}
 	}
 
-	if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->indexToOrdinal(champIndex) == _g506_actingChampionOrdinal)) {
+	if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->M0_indexToOrdinal(champIndex) == _g506_actingChampionOrdinal)) {
 		nativeBitmapIndex = k35_SlotBoxActingHandIndice;
 	}
 
 	if (nativeBitmapIndex != -1) {
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		if (isInventoryChamp) {
-		_vm->_displayMan->blitToBitmap(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0,
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), 32, 0, 0,
 									   _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, box, k12_ColorDarkestGray);
 		} else {
-		_vm->_displayMan->blitToBitmap(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0,
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), 32, 0, 0,
 									   _vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, box, k12_ColorDarkestGray);
 		}
 	}
 
-	_vm->_objectMan->drawIconInSlotBox(slotBoxIndex, iconIndex);
+	_vm->_objectMan->f38_drawIconInSlotBox(slotBoxIndex, iconIndex);
 
 	if (!isInventoryChamp) {
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 	}
 }
 
-void ChampionMan::renameChampion(Champion* champ) {
+void ChampionMan::f281_renameChampion(Champion* champ) {
 	warning("STUB METHOD: Champion::renameChampion, F0281_CHAMPION_Rename");
 
 	DisplayMan &dispMan = *_vm->_displayMan;
@@ -1008,15 +1008,15 @@ void ChampionMan::renameChampion(Champion* champ) {
 	box._x2 = box._x1 + 167;
 
 	dispMan.f135_fillBoxBitmap(dispMan._g296_bitmapViewport, box, k12_ColorDarkestGray, k112_byteWidthViewport * 2, k136_heightViewport);
-	dispMan.blitToBitmap(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0,
+	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0,
 						 dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k4_ColorCyan);
-	textMan.printToViewport(177, 58, k13_ColorLightestGray, "_______");
-	textMan.printToViewport(105, 76, k13_ColorLightestGray, "___________________");
+	textMan.f52_printToViewport(177, 58, k13_ColorLightestGray, "_______");
+	textMan.f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________");
 	Common::Point clickPos;
 	static Box okButtonBox(197, 215, 147, 155); // inclusive boundaries, constructor adds +1
 	for (;;) {
 		_vm->_eventMan->processInput();
-		if (_vm->_eventMan->hasPendingClick(clickPos, k1_LeftMouseButton) && okButtonBox.isPointInside(clickPos)) {
+		if (_vm->_eventMan->f360_hasPendingClick(clickPos, k1_LeftMouseButton) && okButtonBox.isPointInside(clickPos)) {
 			return;
 		}
 		dispMan.f97_drawViewport(k0_viewportNotDungeonView);
@@ -1024,14 +1024,14 @@ void ChampionMan::renameChampion(Champion* champ) {
 	}
 }
 
-uint16 ChampionMan::getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex) {
+uint16 ChampionMan::f303_getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex) {
 	if (_g300_partyIsSleeping)
 		return 1;
 
 	bool ignoreTempExp = skillIndex & k0x8000_IgnoreTemporaryExperience;
 	bool ignoreObjModifiers = skillIndex & k0x4000_IgnoreObjectModifiers;
 	skillIndex = (ChampionSkill)(skillIndex & ~(ignoreTempExp | ignoreObjModifiers));
-	Champion *champ = &_champions[champIndex];
+	Champion *champ = &_gK71_champions[champIndex];
 	Skill *skill = &champ->getSkill(skillIndex);
 	int32 experience = skill->_experience;
 
@@ -1054,14 +1054,14 @@ uint16 ChampionMan::getSkillLevel(ChampionIndex champIndex, ChampionSkill skillI
 	}
 
 	if (!ignoreObjModifiers) {
-		IconIndice actionHandIconIndex = _vm->_objectMan->getIconIndex(champ->getSlot(k1_ChampionSlotActionHand));
+		IconIndice actionHandIconIndex = _vm->_objectMan->f33_getIconIndex(champ->getSlot(k1_ChampionSlotActionHand));
 		if (actionHandIconIndex == k27_IconIndiceWeaponTheFirestaff) {
 			skillLevel++;
 		} else if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete) {
 			skillLevel += 2;
 		}
 
-		IconIndice neckIconIndice = _vm->_objectMan->getIconIndex(champ->getSlot(k10_ChampionSlotNeck));
+		IconIndice neckIconIndice = _vm->_objectMan->f33_getIconIndex(champ->getSlot(k10_ChampionSlotNeck));
 		switch (skillIndex) {
 		case k3_ChampionSkillWizard:
 			if (neckIconIndice == k124_IconIndiceJunkPendantFeral)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index cd66946..1b7a4ff 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -426,18 +426,18 @@ public:
 class ChampionMan {
 	DMEngine *_vm;
 
-	uint16 getChampionPortraitX(uint16 index); // @ M27_PORTRAIT_X
-	uint16 getChampionPortraitY(uint16 index); // @ M28_PORTRAIT_Y
+	uint16 M27_getChampionPortraitX(uint16 index); // @ M27_PORTRAIT_X
+	uint16 M28_getChampionPortraitY(uint16 index); // @ M28_PORTRAIT_Y
 
-	ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell
-	int16 getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue
-	void drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue
-	uint16 handSlotIndex(uint16 slotBoxIndex);// @ M70_HAND_SLOT_INDEX
+	ChampionIndex f285_getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell
+	int16 f279_getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue
+	void f289_drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue
+	uint16 M70_handSlotIndex(uint16 slotBoxIndex);// @ M70_HAND_SLOT_INDEX
 public:
-	Champion _champions[4];
+	Champion _gK71_champions[4]; // @ K0071_as_Champions
 	uint16 _g305_partyChampionCount;	// @ G0305_ui_PartyChampionCount
-	bool _303_partyDead; // @ G0303_B_PartyDead
-	Thing _414_leaderHandObject; // @ G0414_T_LeaderHandObject
+	bool _g303_partyDead; // @ G0303_B_PartyDead
+	Thing _g414_leaderHandObject; // @ G0414_T_LeaderHandObject
 	ChampionIndex _g411_leaderIndex;	// @ G0411_i_LeaderIndex
 	uint16 _g299_candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal
 	bool _g300_partyIsSleeping; // @ G0300_B_PartyIsSleeping
@@ -449,23 +449,23 @@ public:
 	bool _g420_mousePointerHiddenToDrawChangedObjIconOnScreen; // @ G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen
 
 	explicit ChampionMan(DMEngine *vm);
-	void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
-	void addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty
-	void drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs
-	uint16 getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue
-	uint16 getMaximumLoad(Champion *champ); // @ F0309_CHAMPION_GetMaximumLoad
-	void drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState
-	uint16 championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX
-	void drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues
-	void drawSlot(uint16 champIndex, ChampionSlot slotIndex); // @ F0291_CHAMPION_DrawSlot
-	void renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename
-	uint16 getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex);// @ F0303_CHAMPION_GetSkillLevel
-	Common::String getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger
-	void applyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex,
+	void f278_resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
+	void f280_addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty
+	void f287_drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs
+	uint16 f306_getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue
+	uint16 f309_getMaximumLoad(Champion *champ); // @ F0309_CHAMPION_GetMaximumLoad
+	void f292_drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState
+	uint16 M26_championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX
+	void f290_drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues
+	void f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex); // @ F0291_CHAMPION_DrawSlot
+	void f281_renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename
+	uint16 f303_getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex);// @ F0303_CHAMPION_GetSkillLevel
+	Common::String f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger
+	void f299_pplyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex,
 									int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics
-	bool hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged
-	void drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons
-	void addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex); // @ F0301_CHAMPION_AddObjectInSlot
+	bool f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged
+	void f296_drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons
+	void f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex); // @ F0301_CHAMPION_AddObjectInSlot
 };
 
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index f7e9e8f..c5ff2f2 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -141,26 +141,26 @@ DMEngine::~DMEngine() {
 	DebugMan.clearAllDebugChannels();
 }
 
-void DMEngine::initializeGame() {
-	_displayMan->loadGraphics();
-	_displayMan->initializeGraphicData();
+void DMEngine::f463_initializeGame() {
+	_displayMan->f479_loadGraphics();
+	_displayMan->f460_initializeGraphicData();
 	// DUMMY CODE: next line
 	_displayMan->loadPalette(g19_PalCredits);
 	
 	_eventMan->initMouse();
 
-	while (_loadsaveMan->loadgame() != k1_LoadgameSuccess) {
+	while (_loadsaveMan->f435_loadgame() != k1_LoadgameSuccess) {
 		warning("TODO: F0441_STARTEND_ProcessEntrance");
 	}
 
-	_displayMan->loadFloorSet(k0_FloorSetStone);
-	_displayMan->loadWallSet(k0_WallSetStone);
+	_displayMan->f94_loadFloorSet(k0_FloorSetStone);
+	_displayMan->f95_loadWallSet(k0_WallSetStone);
 	_objectMan->loadObjectNames();
 
 	// There was some memory wizardy for the Amiga platform, I skipped that part
 	_displayMan->f461_allocateFlippedWallBitmaps();
 
-	startGame();
+	f462_startGame();
 	warning("MISSING CODE: F0267_MOVE_GetMoveResult_CPSCE (if newGame)");
 	_eventMan->showMouse(true);
 	warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
@@ -173,7 +173,7 @@ void DMEngine::initializeGame() {
 			_displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i];
 	}
 
-	void DMEngine::startGame() {
+	void DMEngine::f462_startGame() {
 	_g331_pressingEye = false;
 	_g332_stopPressingEye = false;
 	_g333_pressingMouth = false;
@@ -181,15 +181,15 @@ void DMEngine::initializeGame() {
 	_g340_highlightBoxInversionRequested = false;
 	_eventMan->_g341_highlightBoxEnabled = false;
 	_championMan->_g300_partyIsSleeping = false;
-	_championMan->_g506_actingChampionOrdinal = indexToOrdinal(kM1_ChampionNone);
+	_championMan->_g506_actingChampionOrdinal = M0_indexToOrdinal(kM1_ChampionNone);
 	_menuMan->_g509_actionAreaContainsIcons = true;
-	_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kM1_ChampionNone);
+	_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = M0_indexToOrdinal(kM1_ChampionNone);
 
 	_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface;
 	_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
 	warning("MISSING CODE: set primary/secondary keyboard input");
 
-	processNewPartyMap(_dungeonMan->_g309_partyMapIndex);
+	f3_processNewPartyMap(_dungeonMan->_g309_partyMapIndex);
 
 	if (!_g298_newGame) {
 		warning("TODO: loading game");
@@ -199,15 +199,15 @@ void DMEngine::initializeGame() {
 	}
 
 	warning("TODO: build copper");
-	_menuMan->drawMovementArrows();
-	_championMan->resetDataToStartGame();
+	_menuMan->f395_drawMovementArrows();
+	_championMan->f278_resetDataToStartGame();
 	_g301_gameTimeTicking = true;
 }
 
-void DMEngine::processNewPartyMap(uint16 mapIndex) {
+void DMEngine::f3_processNewPartyMap(uint16 mapIndex) {
 	warning("MISSING CODE: F0194_GROUP_RemoveAllActiveGroups");
-	_dungeonMan->setCurrentMapAndPartyMap(mapIndex);
-	_displayMan->loadCurrentMapGraphics();
+	_dungeonMan->f174_setCurrentMapAndPartyMap(mapIndex);
+	_displayMan->f96_loadCurrentMapGraphics();
 	warning("MISSING CODE: F0195_GROUP_AddAllActiveGroups");
 	warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette");
 }
@@ -232,16 +232,16 @@ Common::Error DMEngine::run() {
 	_timeline = new Timeline(this);
 	_displayMan->setUpScreens(320, 200);
 
-	initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
+	f463_initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
 	while (true) {
-		gameloop();
+		f2_gameloop();
 		warning("TODO: F0444_STARTEND_Endgame(G0303_B_PartyDead);");
 	}
 
 	return Common::kNoError;
 }
 
-void DMEngine::gameloop() {
+void DMEngine::f2_gameloop() {
 	warning("DUMMY CODE SETTING PARTY POS AND DIRECTION");
 	_dungeonMan->_g306_partyMapX = 10;
 	_dungeonMan->_g307_partyMapY = 4;
@@ -254,21 +254,21 @@ void DMEngine::gameloop() {
 	while (true) {
 		_g321_stopWaitingForPlayerInput = false;
 
-		_menuMan->refreshActionAreaAndSetChampDirMaxDamageReceived();
+		_menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived();
 
 		//do {
 		_eventMan->processInput();
-		_eventMan->processCommandQueue();
+		_eventMan->f380_processCommandQueue();
 		//} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking);
 
 		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
 			Box box(0, 224, 0, 126);
 			_displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport * 2, k136_heightViewport); // dummy code
-			_displayMan->drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
+			_displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
 		}
 
 		// DUMMY CODE: next 2 lines
-		_menuMan->drawMovementArrows();
+		_menuMan->f395_drawMovementArrows();
 		_displayMan->f97_drawViewport(k1_viewportDungeonView);
 
 		_displayMan->updateScreen();
@@ -276,11 +276,11 @@ void DMEngine::gameloop() {
 	}
 }
 
-int16 DMEngine::ordinalToIndex(int16 val) {
+int16 DMEngine::M1_ordinalToIndex(int16 val) {
 	return val - 1;
 }
 
-int16 DMEngine::indexToOrdinal(int16 val) {
+int16 DMEngine::M0_indexToOrdinal(int16 val) {
 	return val + 1;
 }
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 7837ac4..6ceedf9 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -142,19 +142,19 @@ enum {
 };
 
 class DMEngine : public Engine {
-	void startGame(); // @ F0462_START_StartGame_CPSF
-	void processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
-	void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
+	void f462_startGame(); // @ F0462_START_StartGame_CPSF
+	void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
+	void f463_initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
 	void f448_initMemoryManager(); // @ F0448_STARTUP1_InitializeMemoryManager_CPSADEF
-	void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF
+	void f2_gameloop(); // @ F0002_MAIN_GameLoop_CPSDF
 	void initArrays();
 
 public:
 	explicit DMEngine(OSystem *syst);
 	~DMEngine();
 
-	int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
-	int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
+	int16 M1_ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
+	int16 M0_indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
 	virtual Common::Error run(); // @ main
 
 private:
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index d75e92b..2a037a7 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -360,7 +360,7 @@ CreatureInfo g243_CreatureInfo[k27_CreatureTypeCount] = { // @ G0243_as_Graphic5
 	{25,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5},
 	{26,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}};
 
-void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
+void DungeonMan::f150_mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
 	posX += _vm->_dirIntoStepCountEast[dir] * stepsForward;
 	posY += _vm->_dirIntoStepCountNorth[dir] * stepsForward;
 	turnDirRight(dir);
@@ -438,7 +438,7 @@ DungeonMan::~DungeonMan() {
 	}
 }
 
-void DungeonMan::decompressDungeonFile() {
+void DungeonMan::f455_decompressDungeonFile() {
 	Common::File f;
 	f.open("Dungeon.dat");
 	if (f.readUint16BE() == 0x8104) {
@@ -550,9 +550,9 @@ const Thing Thing::_explRebirthStep1(0xFFE4); // @ C0xFFE4_THING_EXPLOSION_REBIR
 const Thing Thing::_explRebirthStep2(0xFFE5); // @ C0xFFE5_THING_EXPLOSION_REBIRTH_STEP2    
 const Thing Thing::_party(0xFFFF); // @ C0xFFFF_THING_PARTY          
 
-void DungeonMan::loadDungeonFile() {
+void DungeonMan::f434_loadDungeonFile() {
 	if (_vm->_g298_newGame)
-		decompressDungeonFile();
+		f455_decompressDungeonFile();
 
 	Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO);
 
@@ -728,7 +728,7 @@ void DungeonMan::loadDungeonFile() {
 	}
 }
 
-void DungeonMan::setCurrentMap(uint16 mapIndex) {
+void DungeonMan::f173_setCurrentMap(uint16 mapIndex) {
 	_g272_currMapIndex = mapIndex;
 	_g271_currMapData = _g279_dungeonMapData[mapIndex];
 	_g269_currMap = _g277_dungeonMaps + mapIndex;
@@ -738,8 +738,8 @@ void DungeonMan::setCurrentMap(uint16 mapIndex) {
 		= &_g280_dungeonColumnsCumulativeSquareThingCount[_g281_dungeonMapsFirstColumnIndex[mapIndex]];
 }
 
-void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) {
-	setCurrentMap(mapIndex);
+void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) {
+	f173_setCurrentMap(mapIndex);
 
 	byte *metaMapData = _g271_currMapData[_g273_currMapWidth - 1] + _g274_currMapHeight;
 	_vm->_displayMan->_g264_currMapAllowedCreatureTypes = metaMapData;
@@ -758,7 +758,7 @@ void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) {
 }
 
 
-Square DungeonMan::getSquare(int16 mapX, int16 mapY) {
+Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) {
 	bool isInXBounds = (mapX >= 0) && (mapX < _g273_currMapWidth);
 	bool isInYBounds = (mapY >= 0) && (mapY < _g274_currMapHeight);
 
@@ -788,12 +788,12 @@ Square DungeonMan::getSquare(int16 mapX, int16 mapY) {
 	return Square(k0_WallElemType);
 }
 
-Square DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
-	mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY);
-	return getSquare(posX, posY);
+Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
+	f150_mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY);
+	return f151_getSquare(posX, posY);
 }
 
-int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) {
+int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) {
 	if (mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight || !Square(_g271_currMapData[mapX][mapY]).get(k0x0010_ThingListPresent))
 		return -1;
 
@@ -807,8 +807,8 @@ int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) {
 	return index;
 }
 
-Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) {
-	int16 index = getSquareFirstThingIndex(mapX, mapY);
+Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) {
+	int16 index = f160_getSquareFirstThingIndex(mapX, mapY);
 	if (index == -1)
 		return Thing::_endOfList;
 	return _g283_squareFirstThings[index];
@@ -816,14 +816,14 @@ Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) {
 
 
 // TODO: get rid of the GOTOs
-void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) {	// complete, except where marked
+void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) {	// complete, except where marked
 	_vm->_displayMan->_g289_championPortraitOrdinal = 0; // BUG0_75, possible fix
 
 	for (uint16 i = 0; i < 5; ++i)
 		aspectArray[i] = 0;
 
-	Thing thing = getSquareFirstThing(mapX, mapY);
-	Square square = getSquare(mapX, mapY);
+	Thing thing = f161_getSquareFirstThing(mapX, mapY);
+	Square square = f151_getSquare(mapX, mapY);
 
 	aspectArray[k0_ElemAspect] = square.getType();
 
@@ -860,25 +860,25 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX,
 		}
 
 T0172010_ClosedFakeWall:
-		setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall);
+		f171_setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall);
 
 		while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) {
 			int16 sideIndex = (thing.getCell() - dir) & 3;
 			if (sideIndex) {
 				if (thing.getType() == k2_TextstringType) {
-					if (TextString(getThingData(thing)).isVisible()) {
+					if (TextString(f156_getThingData(thing)).isVisible()) {
 						aspectArray[sideIndex + 1] = _g265_currMapInscriptionWallOrnIndex + 1;
 						_vm->_displayMan->_g290_inscriptionThing = thing; // BUG0_76
 					}
 				} else {
-					Sensor sensor(getThingData(thing));
+					Sensor sensor(f156_getThingData(thing));
 					aspectArray[sideIndex + 1] = sensor.getOrnOrdinal();
 					if (sensor.getType() == k127_SensorWallChampionPortrait) {
-						_vm->_displayMan->_g289_championPortraitOrdinal = _vm->indexToOrdinal(sensor.getData());
+						_vm->_displayMan->_g289_championPortraitOrdinal = _vm->M0_indexToOrdinal(sensor.getData());
 					}
 				}
 			}
-			thing = getNextThing(thing);
+			thing = f159_getNextThing(thing);
 		}
 		if (squareIsFakeWall && (_g306_partyMapX != mapX) && (_g307_partyMapY != mapY)) {
 			aspectArray[k1_FirstGroupOrObjectAspect] = Thing::_endOfList.toUint16();
@@ -906,14 +906,14 @@ T0172010_ClosedFakeWall:
 		square = Square(footPrintsAllowed ? 8 : 0);
 		// intentional fallthrough
 	case k1_CorridorElemType:
-		aspectArray[k4_FloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(k0x0008_CorridorRandOrnAllowed), _g269_currMap->_randFloorOrnCount, mapX, mapY, 30);
+		aspectArray[k4_FloorOrnOrdAspect] = f170_getRandomOrnOrdinal(square.get(k0x0008_CorridorRandOrnAllowed), _g269_currMap->_randFloorOrnCount, mapX, mapY, 30);
 T0172029_Teleporter:
 		footPrintsAllowed = true;
 T0172030_Pit:
 		while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) {
 			if (thing.getType() == k3_SensorThingType)
-				aspectArray[k4_FloorOrnOrdAspect] = Sensor(getThingData(thing)).getOrnOrdinal();
-			thing = getNextThing(thing);
+				aspectArray[k4_FloorOrnOrdAspect] = Sensor(f156_getThingData(thing)).getOrnOrdinal();
+			thing = f159_getNextThing(thing);
 		}
 		goto T0172049_Footprints;
 	case k5_TeleporterElemType:
@@ -930,12 +930,12 @@ T0172030_Pit:
 		} else {
 			aspectArray[k0_ElemAspect] = k17_DoorFrontElemType;
 			aspectArray[k2_DoorStateAspect] = square.getDoorState();
-			aspectArray[k3_DoorThingIndexAspect] = getSquareFirstThing(mapX, mapY).getIndex();
+			aspectArray[k3_DoorThingIndexAspect] = f161_getSquareFirstThing(mapX, mapY).getIndex();
 		}
 		footPrintsAllowed = true;
 T0172046_Stairs:
 		while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType))
-			thing = getNextThing(thing);
+			thing = f159_getNextThing(thing);
 T0172049_Footprints:
 		unsigned char scentOrdinal; // see next line comment
 		if (footPrintsAllowed) // TODO: I skipped some party query code, must come back later and complete
@@ -947,36 +947,36 @@ T0172049_Footprints:
 	aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16();
 }
 
-void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
+void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
 											int16 mapX, int16 mapY, bool isFakeWall) {
 	int16 ornCount = _g269_currMap->_randWallOrnCount;
 
 	turnDirRight(dir);
-	aspectArray[k2_RightWallOrnOrdAspect] = getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
+	aspectArray[k2_RightWallOrnOrdAspect] = f170_getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
 	turnDirRight(dir);
-	aspectArray[k3_FrontWallOrnOrdAspect] = getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
+	aspectArray[k3_FrontWallOrnOrdAspect] = f170_getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
 	turnDirRight(dir);
-	aspectArray[k4_LeftWallOrnOrdAspect] = getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
+	aspectArray[k4_LeftWallOrnOrdAspect] = f170_getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
 
 	if (isFakeWall || mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight) {
 		for (uint16 i = k2_RightWallOrnOrdAspect; i <= k4_LeftWallOrnOrdAspect; ++i) {
-			if (isWallOrnAnAlcove(_vm->ordinalToIndex(aspectArray[i])))
+			if (f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[i])))
 				aspectArray[i] = 0;
 		}
 	}
 }
 
-int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) {
+int16 DungeonMan::f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) {
 	int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1)
 					+ (3000 + (_g272_currMapIndex << 6) + _g273_currMapWidth + _g274_currMapHeight) * 11
 					+ _g278_dungeonFileHeader._ornamentRandomSeed) >> 2) % modulo;
 	if (allowed && index < count)
-		return _vm->indexToOrdinal(index);
+		return _vm->M0_indexToOrdinal(index);
 	return 0;
 }
 
 
-bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) {
+bool DungeonMan::f149_isWallOrnAnAlcove(int16 wallOrnIndex) {
 	if (wallOrnIndex >= 0)
 		for (uint16 i = 0; i < k3_AlcoveOrnCount; ++i)
 			if (_vm->_displayMan->_g267_currMapAlcoveOrnIndices[i] == wallOrnIndex)
@@ -984,16 +984,16 @@ bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) {
 	return false;
 }
 
-uint16 *DungeonMan::getThingData(Thing thing) {
+uint16 *DungeonMan::f156_getThingData(Thing thing) {
 	return _g284_thingData[thing.getType()][thing.getIndex()];
 }
 
-uint16* DungeonMan::getSquareFirstThingData(int16 mapX, int16 mapY) {
-	return getThingData(getSquareFirstThing(mapX, mapY));
+uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) {
+	return f156_getThingData(f161_getSquareFirstThing(mapX, mapY));
 }
 
-Thing DungeonMan::getNextThing(Thing thing) {
-	return getThingData(thing)[0]; // :)
+Thing DungeonMan::f159_getNextThing(Thing thing) {
+	return Thing(f156_getThingData(thing)[0]); // :)
 }
 
 char g255_MessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings
@@ -1097,7 +1097,7 @@ char g257_InscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_
 	{0,  0,  0,  0, 0, 0, 0, 0}};
 
 
-void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
+void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) {
 	char sepChar;
 	TextString textString(_g284_thingData[k2_TextstringType][thing.getIndex()]);
 	if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) {
@@ -1165,7 +1165,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 }
 
 
-uint16 DungeonMan::getObjectWeight(Thing thing) {
+uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 	static const uint16 g241_junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo
 		// COMPASS - WATERSKIN - JEWEL SYMAL - ILLUMULET - ASHES
 		1, 3, 2, 2, 4,
@@ -1195,11 +1195,11 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 		return 0;
 	switch (thing.getType()) {
 	case k5_WeaponThingType:
-		return g238_WeaponInfo[Weapon(getThingData(thing)).getType()]._weight;
+		return g238_WeaponInfo[Weapon(f156_getThingData(thing)).getType()]._weight;
 	case k6_ArmourThingType:
-		return g239_ArmourInfo[Armour(getThingData(thing)).getType()]._weight;
+		return g239_ArmourInfo[Armour(f156_getThingData(thing)).getType()]._weight;
 	case k10_JunkThingType: {
-		Junk junk(getThingData(thing));
+		Junk junk(f156_getThingData(thing));
 		uint16 weight = g241_junkInfo[junk.getType()];
 		if (junk.getType() == k1_JunkTypeWaterskin)
 			weight += junk.getChargeCount() * 2;
@@ -1207,16 +1207,16 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 	}
 	case k9_ContainerThingType: {
 		uint16 weight = 50;
-		Container container(getThingData(thing));
+		Container container(f156_getThingData(thing));
 		Thing slotThing = container.getSlot();
 		while (slotThing != Thing::_endOfList) {
-			weight += getObjectWeight(slotThing);
-			slotThing = getNextThing(slotThing);
+			weight += f140_getObjectWeight(slotThing);
+			slotThing = f159_getNextThing(slotThing);
 		}
 		return weight;
 	}
 	case k8_PotionThingType:
-		if (Junk(getThingData(thing)).getType() == k20_PotionTypeEmptyFlask) {
+		if (Junk(f156_getThingData(thing)).getType() == k20_PotionTypeEmptyFlask) {
 			return 1;
 		} else {
 			return 3;
@@ -1232,8 +1232,8 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 }
 
 
-int16 DungeonMan::getObjectInfoIndex(Thing thing) {
-	uint16 *rawType = getThingData(thing);
+int16 DungeonMan::f141_getObjectInfoIndex(Thing thing) {
+	uint16 *rawType = f156_getThingData(thing);
 	switch (thing.getType()) {
 	case k7_ScrollThingType:
 		return k0_ObjectInfoIndexFirstScroll;
@@ -1252,17 +1252,17 @@ int16 DungeonMan::getObjectInfoIndex(Thing thing) {
 	}
 }
 
-void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) {
+void DungeonMan::f163_linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) {
 	if (thingToLink == Thing::_endOfList)
 		return;
 
-	uint16 *rawObjPtr = getThingData(thingToLink);
+	uint16 *rawObjPtr = f156_getThingData(thingToLink);
 	*rawObjPtr = Thing::_endOfList.toUint16();
 
 	if (mapX >= 0) {
 		Square *squarePtr = (Square*)&_g271_currMapData[mapX][mapY];
 		if (squarePtr->get(k0x0010_ThingListPresent)) {
-			thingInList = getSquareFirstThing(mapX, mapY);
+			thingInList = f161_getSquareFirstThing(mapX, mapY);
 		} else {
 			squarePtr->set(k0x0010_ThingListPresent);
 			uint16 *cumulativeCount = &_g270_currMapColCumulativeSquareFirstThingCount[mapX + 1];
@@ -1286,43 +1286,43 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map
 		}
 	}
 
-	Thing thing = getNextThing(thingInList);
+	Thing thing = f159_getNextThing(thingInList);
 	while (thing != Thing::_endOfList) {
-		thing = getNextThing(thing);
+		thing = f159_getNextThing(thing);
 		thingInList = thing;
 	}
-	rawObjPtr = getThingData(thingInList);
+	rawObjPtr = f156_getThingData(thingInList);
 	*rawObjPtr = thingToLink.toUint16();
 }
 
-WeaponInfo* DungeonMan::getWeaponInfo(Thing thing) {
-	Weapon* weapon = (Weapon*)getThingData(thing);
+WeaponInfo* DungeonMan::f158_getWeaponInfo(Thing thing) {
+	Weapon* weapon = (Weapon*)f156_getThingData(thing);
 	return &g238_WeaponInfo[weapon->getType()];
 }
 
-int16 DungeonMan::getProjectileAspect(Thing thing) {
+int16 DungeonMan::f142_getProjectileAspect(Thing thing) {
 	ThingType thingType;
 	int16 projAspOrd;
 	WeaponInfo *weaponInfo;
 
 	if ((thingType = thing.getType()) == k15_ExplosionThingType) {
 		if (thing == Thing::_explFireBall)
-			return -_vm->indexToOrdinal(k10_ProjectileAspectExplosionFireBall);
+			return -_vm->M0_indexToOrdinal(k10_ProjectileAspectExplosionFireBall);
 		if (thing == Thing::_explSlime)
-			return -_vm->indexToOrdinal(k12_ProjectileAspectExplosionSlime);
+			return -_vm->M0_indexToOrdinal(k12_ProjectileAspectExplosionSlime);
 		if (thing == Thing::_explLightningBolt)
-			return -_vm->indexToOrdinal(k3_ProjectileAspectExplosionLightningBolt);
+			return -_vm->M0_indexToOrdinal(k3_ProjectileAspectExplosionLightningBolt);
 		if ((thing == Thing::_explPoisonBolt) || (thing == Thing::_explPoisonCloud))
-			return -_vm->indexToOrdinal(k13_ProjectileAspectExplosionPoisonBoltCloud);
+			return -_vm->M0_indexToOrdinal(k13_ProjectileAspectExplosionPoisonBoltCloud);
 
-		return -_vm->indexToOrdinal(k11_ProjectileAspectExplosionDefault);
+		return -_vm->M0_indexToOrdinal(k11_ProjectileAspectExplosionDefault);
 	} else if (thingType == k5_WeaponThingType) {
-		weaponInfo = getWeaponInfo(thing);
+		weaponInfo = f158_getWeaponInfo(thing);
 		if (projAspOrd = weaponInfo->getProjectileAspectOrdinal())
 			return -projAspOrd;
 	}
 
-	return g237_ObjectInfo[getObjectInfoIndex(thing)]._objectAspectIndex;
+	return g237_ObjectInfo[f141_getObjectInfoIndex(thing)]._objectAspectIndex;
 }
 
 }
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 3b752bd..331c3c9 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -601,45 +601,45 @@ class DungeonMan {
 	DungeonMan(const DungeonMan &other); // no implementation on purpose
 	void operator=(const DungeonMan &rhs); // no implementation on purpose
 
-	Square getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare
-	Square getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare
+	Square f151_getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare
+	Square f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare
 
-	void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon
+	void f455_decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon
 
-	int16 getSquareFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex
+	int16 f160_getSquareFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex
 
-	int16 getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal
-	void setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
+	int16 f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal
+	void f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
 									int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals
 
-	void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
+	void f173_setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
 
 public:
 	explicit DungeonMan(DMEngine *dmEngine);
 	~DungeonMan();
 
-	Thing getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing
-	Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing)
-	uint16 *getThingData(Thing thing); // @ unsigned char* F0156_DUNGEON_GetThingData(register THING P0276_T_Thing)
-	uint16 *getSquareFirstThingData(int16 mapX, int16 mapY); // @ F0157_DUNGEON_GetSquareFirstThingData
+	Thing f161_getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing
+	Thing f159_getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing)
+	uint16 *f156_getThingData(Thing thing); // @ F0156_DUNGEON_GetThingData
+	uint16 *f157_getSquareFirstThingData(int16 mapX, int16 mapY); // @ F0157_DUNGEON_GetSquareFirstThingData
 
 	// TODO: this does stuff other than load the file!
-	void loadDungeonFile();	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
-	void setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap
+	void f434_loadDungeonFile();	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
+	void f174_setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap
 
-	bool isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove
-	void mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement
-	SquareType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
-		return Square(getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType();
+	bool f149_isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove
+	void f150_mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement
+	SquareType f153_getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
+		return Square(f152_getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType();
 	} // @ F0153_DUNGEON_GetRelativeSquareType
-	void setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect
-	void decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText
-
-	uint16 getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight
-	int16 getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex
-	void linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY); // @ F0163_DUNGEON_LinkThingToList
-	WeaponInfo *getWeaponInfo(Thing thing); // @ F0158_DUNGEON_GetWeaponInfo
-	int16 getProjectileAspect(Thing thing); // @ F0142_DUNGEON_GetProjectileAspect
+	void f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect
+	void f168_decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText
+
+	uint16 f140_getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight
+	int16 f141_getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex
+	void f163_linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY); // @ F0163_DUNGEON_LinkThingToList
+	WeaponInfo *f158_getWeaponInfo(Thing thing); // @ F0158_DUNGEON_GetWeaponInfo
+	int16 f142_getProjectileAspect(Thing thing); // @ F0142_DUNGEON_GetProjectileAspect
 
 	uint32 _rawDunFileDataSize;	 // @ probably NONE
 	byte *_rawDunFileData; // @ ???
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 2e6f473..226b616 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -316,16 +316,16 @@ void EventManager::processInput() {
 
 			switch (event.kbd.keycode) {
 			case Common::KEYCODE_w:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
+				dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 				break;
 			case Common::KEYCODE_a:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
+				dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 				break;
 			case Common::KEYCODE_s:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
+				dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 				break;
 			case Common::KEYCODE_d:
-				dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
+				dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 				break;
 			case Common::KEYCODE_q:
 				turnDirLeft(dungeonMan._g308_partyDir);
@@ -335,11 +335,11 @@ void EventManager::processInput() {
 				break;
 			case Common::KEYCODE_UP:
 				if (_dummyMapIndex < 13)
-					dungeonMan.setCurrentMapAndPartyMap(++_dummyMapIndex);
+					dungeonMan.f174_setCurrentMapAndPartyMap(++_dummyMapIndex);
 				break;
 			case Common::KEYCODE_DOWN:
 				if (_dummyMapIndex > 0)
-					dungeonMan.setCurrentMapAndPartyMap(--_dummyMapIndex);
+					dungeonMan.f174_setCurrentMapAndPartyMap(--_dummyMapIndex);
 				break;
 			default:
 				break;
@@ -359,19 +359,19 @@ void EventManager::processInput() {
 	}
 }
 
-void EventManager::processPendingClick() {
+void EventManager::f360_processPendingClick() {
 	if (_g436_pendingClickPresent) {
 		_g436_pendingClickPresent = false;
-		processClick(_g437_pendingClickPos, _g439_pendingClickButton);
+		f359_processClick(_g437_pendingClickPos, _g439_pendingClickButton);
 	}
 }
 
-void EventManager::processClick(Common::Point mousePos, MouseButton button) {
+void EventManager::f359_processClick(Common::Point mousePos, MouseButton button) {
 	CommandType commandType;
 
-	commandType = getCommandTypeFromMouseInput(_g441_primaryMouseInput, mousePos, button);
+	commandType = f358_getCommandTypeFromMouseInput(_g441_primaryMouseInput, mousePos, button);
 	if (commandType == k0_CommandNone)
-		commandType = getCommandTypeFromMouseInput(_g442_secondaryMouseInput, mousePos, button);
+		commandType = f358_getCommandTypeFromMouseInput(_g442_secondaryMouseInput, mousePos, button);
 
 	if (commandType != k0_CommandNone)
 		_commandQueue.push(Command(mousePos, commandType));
@@ -379,7 +379,7 @@ void EventManager::processClick(Common::Point mousePos, MouseButton button) {
 	_g435_isCommandQueueLocked = false;
 }
 
-CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button) {
+CommandType EventManager::f358_getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button) {
 	if (!input)
 		return k0_CommandNone;
 	CommandType commandType = k0_CommandNone;
@@ -393,11 +393,11 @@ CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common
 }
 
 
-void EventManager::processCommandQueue() {
+void EventManager::f380_processCommandQueue() {
 	_g435_isCommandQueueLocked = true;
 	if (_commandQueue.empty()) {
 		_g435_isCommandQueueLocked = false;
-		processPendingClick();
+		f360_processPendingClick();
 		return;
 	}
 
@@ -407,29 +407,29 @@ void EventManager::processCommandQueue() {
 	int16 commandY = cmd._pos.y;
 
 	_g435_isCommandQueueLocked = false;
-	processPendingClick();
+	f360_processPendingClick();
 
 	if ((cmd._type == k2_CommandTurnRight) || (cmd._type == k1_CommandTurnLeft)) {
-		commandTurnParty(cmd._type);
+		f365_commandTurnParty(cmd._type);
 		return;
 	}
 
 	if ((cmd._type >= k3_CommandMoveForward) && (cmd._type <= k6_CommandMoveLeft)) {
-		commandMoveParty(cmd._type);
+		f366_commandMoveParty(cmd._type);
 		return;
 	}
 
 	if (cmd._type == k80_CommandClickInDungeonView) {
-		commandProcessType80ClickInDungeonView(commandX, commandY);
+		f377_commandProcessType80ClickInDungeonView(commandX, commandY);
 	}
 	if (cmd._type == k81_CommandClickInPanel) {
-		commandProcess81ClickInPanel(commandX, commandY);
+		f378_commandProcess81ClickInPanel(commandX, commandY);
 	}
 
 	// MISSING CODE: the rest of the function
 }
 
-void EventManager::commandTurnParty(CommandType cmdType) {
+void EventManager::f365_commandTurnParty(CommandType cmdType) {
 	_vm->_g321_stopWaitingForPlayerInput = true;
 
 	// MISSING CODE: highlight turn left/right buttons
@@ -445,7 +445,7 @@ void EventManager::commandTurnParty(CommandType cmdType) {
 	// MISSING CODE: process sensors
 }
 
-void EventManager::commandMoveParty(CommandType cmdType) {
+void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	_vm->_g321_stopWaitingForPlayerInput = true;
 
 	// MISSING CODE: Lots of code
@@ -455,16 +455,16 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 
 	switch (cmdType) {
 	case k3_CommandMoveForward:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
+		dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 		break;
 	case k6_CommandMoveLeft:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
+		dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 		break;
 	case k5_CommandMoveBackward:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
+		dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 		break;
 	case k4_CommandMoveRight:
-		dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
+		dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
 		break;
 	default:
 		break;
@@ -473,46 +473,46 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 	// MISSING CODE: Lots of code
 }
 
-void EventManager::commandSetLeader(ChampionIndex champIndex) {
+void EventManager::f368_commandSetLeader(ChampionIndex champIndex) {
 	ChampionMan &cm = *_vm->_championMan;
 	ChampionIndex leaderIndex;
 
-	if ((cm._g411_leaderIndex == champIndex) || ((champIndex != kM1_ChampionNone) && !cm._champions[champIndex]._currHealth))
+	if ((cm._g411_leaderIndex == champIndex) || ((champIndex != kM1_ChampionNone) && !cm._gK71_champions[champIndex]._currHealth))
 		return;
 
 	if (cm._g411_leaderIndex != kM1_ChampionNone) {
 		leaderIndex = cm._g411_leaderIndex;
-		cm._champions[leaderIndex].setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
-		cm._champions[leaderIndex].setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
-		cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._414_leaderHandObject);
+		cm._gK71_champions[leaderIndex].setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
+		cm._gK71_champions[leaderIndex].setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
+		cm._gK71_champions[leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(cm._g414_leaderHandObject);
 		cm._g411_leaderIndex = kM1_ChampionNone;
-		cm.drawChampionState(leaderIndex);
+		cm.f292_drawChampionState(leaderIndex);
 	}
 	if (champIndex == kM1_ChampionNone) {
 		cm._g411_leaderIndex = kM1_ChampionNone;
 		return;
 	}
 	cm._g411_leaderIndex = champIndex;
-	Champion *champion = &cm._champions[cm._g411_leaderIndex];
+	Champion *champion = &cm._gK71_champions[cm._g411_leaderIndex];
 	champion->_dir = _vm->_dungeonMan->_g308_partyDir;
-	cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._414_leaderHandObject);
-	if (_vm->indexToOrdinal(champIndex) != cm._g299_candidateChampionOrdinal) {
+	cm._gK71_champions[champIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(cm._g414_leaderHandObject);
+	if (_vm->M0_indexToOrdinal(champIndex) != cm._g299_candidateChampionOrdinal) {
 		champion->setAttributeFlag(k0x0400_ChampionAttributeIcon, true);
 		champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
-		cm.drawChampionState(champIndex);
+		cm.f292_drawChampionState(champIndex);
 	}
 }
 
-void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() {
+void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() {
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 	int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
 	int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
 	if ((mapX >= 0) && (mapX < dunMan._g273_currMapWidth) && (mapY >= 0) && (mapY < dunMan._g274_currMapHeight)) {
-		_vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(dunMan._g308_partyDir));
+		_vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->f275_sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(dunMan._g308_partyDir));
 	}
 }
 
-void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY) {
+void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16 posY) {
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 	ChampionMan &champMan = *_vm->_championMan;
 
@@ -524,7 +524,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 			int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
 			int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
 
-			if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() &&
+			if (Door(dunMan.f157_getSquareFirstThingData(mapX, mapY)).hasButton() &&
 				dunMan._g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
 				_vm->_g321_stopWaitingForPlayerInput = true;
 				warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
@@ -541,7 +541,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 			if (dunMan._g291_dungeonViewClickableBoxes[viewCell].isPointInside(Common::Point(posX, posY - 33))) {
 				if (viewCell == k5_ViewCellDoorButtonOrWallOrn) {
 					if (!dunMan._g286_isFacingAlcove) {
-						commandProcessType80ClickInDungeonViewTouchFrontWall();
+						f372_commandProcessType80ClickInDungeonViewTouchFrontWall();
 					}
 				} else {
 					warning("MISSING CODE: F0373_COMMAND_ProcessType80_ClickInDungeonView_GrabLeaderHandObject");
@@ -550,8 +550,8 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 			}
 		}
 	} else {
-		Thing thing = champMan._414_leaderHandObject;
-		uint16 *rawThingPointer = dunMan.getThingData(thing);
+		Thing thing = champMan._g414_leaderHandObject;
+		uint16 *rawThingPointer = dunMan.f156_getThingData(thing);
 		if (dunMan._g285_squareAheadElement == k0_ElementTypeWall) {
 			for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k1_ViewCellFrontRight; ++viewCell) {
 				if (g462_BoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) {
@@ -565,8 +565,8 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 					warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject");
 				} else {
 					if (dunMan._g288_isFacingFountain) {
-						uint16 iconIndex = _vm->_objectMan->getIconIndex(thing);
-						int16 weight = dunMan.getObjectWeight(thing);
+						uint16 iconIndex = _vm->_objectMan->f33_getIconIndex(thing);
+						int16 weight = dunMan.f140_getObjectWeight(thing);
 						if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
 							((Junk*)rawThingPointer)->setChargeCount(3);
 						} else if (iconIndex == k195_IconIndicePotionEmptyFlask) {
@@ -574,11 +574,11 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 						} else {
 							goto T0377019;
 						}
-						champMan.drawChangedObjectIcons();
-						champMan._champions[champMan._g411_leaderIndex]._load += dunMan.getObjectWeight(thing) - weight;
+						champMan.f296_drawChangedObjectIcons();
+						champMan._gK71_champions[champMan._g411_leaderIndex]._load += dunMan.f140_getObjectWeight(thing) - weight;
 					}
 T0377019:
-					commandProcessType80ClickInDungeonViewTouchFrontWall();
+					f372_commandProcessType80ClickInDungeonViewTouchFrontWall();
 				}
 			}
 		} else {
@@ -593,19 +593,19 @@ T0377019:
 	}
 }
 
-void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType) {
+void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType) {
 	ChampionMan &champMan = *_vm->_championMan;
 	InventoryMan &invMan = *_vm->_inventoryMan;
 	DisplayMan &dispMan = *_vm->_displayMan;
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 
 	uint16 championIndex = champMan._g305_partyChampionCount - 1;
-	Champion *champ = &champMan._champions[championIndex];
+	Champion *champ = &champMan._gK71_champions[championIndex];
 	if (commandType == k162_CommandClickInPanelCancel) {
-		invMan.toggleInventory(k4_ChampionCloseInventory);
-		champMan._g299_candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
+		invMan.f355_toggleInventory(k4_ChampionCloseInventory);
+		champMan._g299_candidateChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
 		if (champMan._g305_partyChampionCount == 1) {
-			commandSetLeader(kM1_ChampionNone);
+			f368_commandSetLeader(kM1_ChampionNone);
 		}
 		champMan._g305_partyChampionCount--;
 		Box box;
@@ -614,14 +614,14 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 		box._x1 = championIndex * k69_ChampionStatusBoxSpacing;
 		box._x2 = box._x1 + 66 + 1;
 		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.clearScreenBox(k0_ColorBlack, box);
-		dispMan.clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2]);
+		dispMan.D24_clearScreenBox(k0_ColorBlack, box);
+		dispMan.D24_clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.M26_championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2]);
 		warning("F0457_START_DrawEnabledMenus_CPSF");
 		warning("F0078_MOUSE_ShowPointer");
 		return;
 	}
 
-	champMan._g299_candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
+	champMan._g299_candidateChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
 	int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
 	int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
 
@@ -631,17 +631,17 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 			warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList");
 		}
 	}
-	Thing thing = dunMan.getSquareFirstThing(mapX, mapY);
+	Thing thing = dunMan.f161_getSquareFirstThing(mapX, mapY);
 	for (;;) { // infinite
 		if (thing.getType() == k3_SensorThingType) {
-			((Sensor*)dunMan.getThingData(thing))->setTypeDisabled();
+			((Sensor*)dunMan.f156_getThingData(thing))->setTypeDisabled();
 			break;
 		}
-		thing = dunMan.getNextThing(thing);
+		thing = dunMan.f159_getNextThing(thing);
 	}
 
 	if (commandType == k161_CommandClickInPanelReincarnate) {
-		champMan.renameChampion(champ);
+		champMan.f281_renameChampion(champ);
 		champ->resetSkillsToZero();
 
 		for (uint16 i = 0; i < 12; i++) {
@@ -653,10 +653,10 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 
 	if (champMan._g305_partyChampionCount == 1) {
 		warning("MISSING CODE: setting time, G0362_l_LastPartyMovementTime , G0313_ul_GameTime");
-		commandSetLeader(k0_ChampionFirst);
-		_vm->_menuMan->setMagicCasterAndDrawSpellArea(k0_ChampionFirst);
+		f368_commandSetLeader(k0_ChampionFirst);
+		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(k0_ChampionFirst);
 	} else {
-		_vm->_menuMan->drawSpellAreaControls(champMan._g514_magicCasterChampionIndex);
+		_vm->_menuMan->f393_drawSpellAreaControls(champMan._g514_magicCasterChampionIndex);
 	}
 
 	warning("MISSING CODE: F0051_TEXT_MESSAGEAREA_PrintLineFeed");
@@ -664,12 +664,12 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage");
 	warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage");
 
-	invMan.toggleInventory(k4_ChampionCloseInventory);
+	invMan.f355_toggleInventory(k4_ChampionCloseInventory);
 	warning("MISSING CODE: F0457_START_DrawEnabledMenus_CPSF");
 	warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal");
 }
 
-void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) {
+void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) {
 	ChampionMan &champMan = *_vm->_championMan;
 	InventoryMan &invMan = *_vm->_inventoryMan;
 
@@ -678,23 +678,23 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) {
 	case k4_PanelContentChest:
 		if (champMan._g411_leaderIndex == kM1_ChampionNone) // if no leader
 			return;
-		commandType = getCommandTypeFromMouseInput(g456_MouseInput_PanelChest, Common::Point(x, y), k1_LeftMouseButton);
+		commandType = f358_getCommandTypeFromMouseInput(g456_MouseInput_PanelChest, Common::Point(x, y), k1_LeftMouseButton);
 		if (commandType != k0_CommandNone)
 			warning("MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox");
 		break;
 	case k5_PanelContentResurrectReincarnate:
 		if (!champMan._g415_leaderEmptyHanded)
 			break;
-		commandType = getCommandTypeFromMouseInput(g457_MouseInput_PanelResurrectReincarnateCancel, Common::Point(x, y), k1_LeftMouseButton);
+		commandType = f358_getCommandTypeFromMouseInput(g457_MouseInput_PanelResurrectReincarnateCancel, Common::Point(x, y), k1_LeftMouseButton);
 		if (commandType != k0_CommandNone)
-			commandProcessCommands160To162ClickInResurrectReincarnatePanel(commandType);
+			f282_commandProcessCommands160To162ClickInResurrectReincarnatePanel(commandType);
 		break;
 	default:
 		break;
 	}
 }
 
-bool EventManager::hasPendingClick(Common::Point& point, MouseButton button) {
+bool EventManager::f360_hasPendingClick(Common::Point& point, MouseButton button) {
 	if (_g439_pendingClickButton && button == _g439_pendingClickButton)
 		point = _g437_pendingClickPos;
 
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 35f8bd6..51f1761 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -225,8 +225,8 @@ class EventManager {
 	bool _g435_isCommandQueueLocked; // @ G0435_B_CommandQueueLocked
 	Common::Queue<Command> _commandQueue;
 
-	void commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty
-	void commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty
+	void f365_commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty
+	void f366_commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty
 public:
 	explicit EventManager(DMEngine *vm);
 
@@ -242,18 +242,18 @@ public:
 
 	void setMousePos(Common::Point pos);
 	void processInput(); // acknowledges mouse and keyboard input
-	void processPendingClick(); // @ F0360_COMMAND_ProcessPendingClick
-	void processClick(Common::Point mousePos, MouseButton button); // @	F0359_COMMAND_ProcessClick_CPSC
-	CommandType getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC
-	void processCommandQueue(); // @ F0380_COMMAND_ProcessQueue_CPSC
+	void f360_processPendingClick(); // @ F0360_COMMAND_ProcessPendingClick
+	void f359_processClick(Common::Point mousePos, MouseButton button); // @	F0359_COMMAND_ProcessClick_CPSC
+	CommandType f358_getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC
+	void f380_processCommandQueue(); // @ F0380_COMMAND_ProcessQueue_CPSC
 
-	void commandSetLeader(ChampionIndex index); // @ F0368_COMMAND_SetLeader
-	void commandProcessType80ClickInDungeonViewTouchFrontWall(); // @ F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall
-	void commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView
-	void commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType); // @ F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel
-	void commandProcess81ClickInPanel(int16 x, int16 y); // @ F0378_COMMAND_ProcessType81_ClickInPanel
+	void f368_commandSetLeader(ChampionIndex index); // @ F0368_COMMAND_SetLeader
+	void f372_commandProcessType80ClickInDungeonViewTouchFrontWall(); // @ F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall
+	void f377_commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView
+	void f282_commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType); // @ F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel
+	void f378_commandProcess81ClickInPanel(int16 x, int16 y); // @ F0378_COMMAND_ProcessType81_ClickInPanel
 
-	bool hasPendingClick(Common::Point &point, MouseButton button);
+	bool f360_hasPendingClick(Common::Point &point, MouseButton button); // @ F0360_COMMAND_ProcessPendingClick
 };
 
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 18deb96..a21d821 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -728,7 +728,7 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) {
 	clearScreen(k0_ColorBlack);
 }
 
-void DisplayMan::loadGraphics() {
+void DisplayMan::f479_loadGraphics() {
 	Common::File f;
 	f.open("graphics.dat");
 	_grapItemCount = f.readUint16BE();
@@ -749,7 +749,7 @@ void DisplayMan::loadGraphics() {
 	unpackGraphics();
 }
 
-void DisplayMan::initializeGraphicData() {
+void DisplayMan::f460_initializeGraphicData() {
 	_g85_bitmapCeiling = new byte[224 * 29];
 	_g84_bitmapFloor = new byte[224 * 70];
 	_g697_bitmapWallSet_Wall_D3L2 = new byte[16 * 49];
@@ -801,8 +801,8 @@ void DisplayMan::initializeGraphicData() {
 	for (int16 objectAspectIndex = 0; objectAspectIndex < k85_ObjAspectCount; ++objectAspectIndex, ++objectAspect) {
 		derivedBitmapIndex = k104_DerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex;
 
-		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k16_Scale_D3);
-		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k20_Scale_D2);
+		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k16_Scale_D3);
+		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k20_Scale_D2);
 
 		if (getFlag(objectAspect->_graphicInfo, k0x0001_ObjectFlipOnRightMask)) {
 			_g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2];
@@ -825,7 +825,7 @@ void DisplayMan::initializeGraphicData() {
 			derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + projectileAspect->_firstDerivedBitmapRelativeIndex;
 
 			for (int16 projectileScaleIndex = 0; projectileScaleIndex < 6; projectileScaleIndex++) {
-				int16 bitmapPixelCount = getScaledBitmapPixelCount(projectileAspect->_width, projectileAspect->_height, g215_ProjectileScales[projectileScaleIndex]);
+				int16 bitmapPixelCount = f459_getScaledBitmapPixelCount(projectileAspect->_width, projectileAspect->_height, g215_ProjectileScales[projectileScaleIndex]);
 				_g639_derivedBitmapByteCount[derivedBitmapIndex] = bitmapPixelCount;
 
 				if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k3_ProjectileAspectHasNone) {
@@ -847,7 +847,7 @@ void DisplayMan::initializeGraphicData() {
 	ExplosionAspect *expAsp = g211_ExplosionAspects;
 	for (uint16 expAspIndex = 0; expAspIndex < k4_ExplosionAspectCount; ++expAspIndex, expAsp++) {
 		for (int16 scale = 4; scale < 32; scale += 2)
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(expAsp->_pixelWidth, expAsp->_height, scale);
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(expAsp->_pixelWidth, expAsp->_height, scale);
 
 		if (expAspIndex == k3_ExplosionAspectSmoke) {
 			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = expAsp->_pixelWidth * expAsp->_height;
@@ -863,14 +863,14 @@ void DisplayMan::initializeGraphicData() {
 		creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex;
 
 		int16 creatureFrontBitmapD3PixelCount;
-		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
+		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
 
 		int16 creatureFrontBitmapD2PixelCount;
-		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
+		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
 
 		if (getFlag(creatureGraphicInfo, k0x0008_CreatureInfoGraphicMaskSide)) {
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k16_Scale_D3);
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k20_Scale_D2);
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k16_Scale_D3);
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k20_Scale_D2);
 		}
 
 		if (getFlag(creatureGraphicInfo, k0x0010_CreatureInfoGraphicMaskBack)) {
@@ -879,16 +879,16 @@ void DisplayMan::initializeGraphicData() {
 		}
 
 		if (getFlag(creatureGraphicInfo, k0x0020_CreatureInfoGraphicMaskAttack)) {
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k16_Scale_D3);
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k20_Scale_D2);
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k16_Scale_D3);
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k20_Scale_D2);
 		}
 
 		int16 additionalFronGraphicCount;
 		if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, k0x0003_CreatureInfoGraphicMaskAdditional)) {
 			do {
 				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront;
-				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
-				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
+				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
+				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
 			} while (--additionalFronGraphicCount);
 		}
 	}
@@ -908,15 +908,15 @@ void DisplayMan::unpackGraphics() {
 	}
 	_bitmaps = new byte*[575]; // largest graphic indice (i think)
 	_bitmaps[0] = new byte[unpackedBitmapsSize];
-	loadIntoBitmap(0, _bitmaps[0]);
+	f466_loadIntoBitmap(0, _bitmaps[0]);
 	for (uint16 i = 1; i <= 20; ++i) {
 		_bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1);
-		loadIntoBitmap(i, _bitmaps[i]);
+		f466_loadIntoBitmap(i, _bitmaps[i]);
 	}
 	_bitmaps[22] = _bitmaps[20] + getWidth(20) * getHeight(20);
 	for (uint16 i = 23; i <= 532; ++i) {
 		_bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1);
-		loadIntoBitmap(i, _bitmaps[i]);
+		f466_loadIntoBitmap(i, _bitmaps[i]);
 	}
 	_bitmaps[k557_FontGraphicIndice] = _bitmaps[532] + getWidth(532) * getHeight(532);
 	loadFNT1intoBitmap(k557_FontGraphicIndice, _bitmaps[k557_FontGraphicIndice]);
@@ -955,7 +955,7 @@ void DisplayMan::f566_viewportBlitToScreen() {
 	warning("MISSING FUNCTIONALITY: using correct colorpalette");
 	Box box(0, 223, 33, 33 + 135);
 
-	blitToBitmap(_g296_bitmapViewport, k112_byteWidthViewport * 2, 0, 0, _g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
+	f132_blitToBitmap(_g296_bitmapViewport, k112_byteWidthViewport * 2, 0, 0, _g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
 }
 
 void DisplayMan::loadPalette(uint16 *palette) {
@@ -969,7 +969,7 @@ void DisplayMan::loadPalette(uint16 *palette) {
 }
 
 
-void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
+void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) {
 	uint8 *data = _packedBitmaps + _packedItemPos[index];
 	uint16 width = READ_BE_UINT16(data);
 	uint16 height = READ_BE_UINT16(data + 2);
@@ -1018,7 +1018,7 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
 }
 
 
-void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent) {
+void DisplayMan::f132_blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent) {
 	for (uint16 y = 0; y < box._y2 - box._y1; ++y)
 		for (uint16 x = 0; x < box._x2 - box._x1; ++x) {
 			byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x];
@@ -1028,7 +1028,7 @@ void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uin
 
 }
 
-void DisplayMan::clearScreenBox(Color color, Box &box) {
+void DisplayMan::D24_clearScreenBox(Color color, Box &box) {
 	uint16 width = box._x2 - box._x1;
 	for (int16 y = box._y1; y < box._y2; ++y)
 		memset(_g348_bitmapScreen + y * _screenWidth + box._x1, color, sizeof(byte) * width);
@@ -1039,7 +1039,7 @@ void DisplayMan::f135_fillBoxBitmap(byte* destBitmap, Box &box, Color color, int
 		memset(destBitmap + y * pixelWidth + box._x1, color, sizeof(byte) * (box._x2 - box._x1));
 }
 
-void DisplayMan::blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box,
+void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box,
 											   int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
 											   int16 xPos, int16 yPos, int16 destHeight, int16 height2) {
 	warning("STUB FUNCTION: does nothing at all");
@@ -1047,7 +1047,7 @@ void DisplayMan::blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask
 
 
 
-void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) {
+void DisplayMan::f103_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) {
 	for (uint16 y = 0; y < height; ++y) {
 		for (uint16 x = 0; x < width / 2; ++x) {
 			byte tmp;
@@ -1070,22 +1070,22 @@ void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) {
 	delete[] tmp;
 }
 
-byte* DisplayMan::getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnPixelWidth, int16& returnHeight) {
+byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnPixelWidth, int16& returnHeight) {
 	ExplosionAspect *explAsp = &g211_ExplosionAspects[explosionAspIndex];
 	if (scale > 32)
 		scale = 32;
-	int16 pixelWidth = getScaledDimension(explAsp->_pixelWidth, scale);
-	int16 height = getScaledDimension(explAsp->_height, scale);
+	int16 pixelWidth = M78_getScaledDimension(explAsp->_pixelWidth, scale);
+	int16 height = M78_getScaledDimension(explAsp->_height, scale);
 	byte *bitmap;
 	int16 derBitmapIndex = (explosionAspIndex * 14) + scale / 2 + k438_DerivedBitmapFirstExplosion - 2;
 	if ((scale == 32) && (explosionAspIndex != k3_ExplosionAspectSmoke)) {
-		bitmap = getBitmap(explosionAspIndex + k348_FirstExplosionGraphicIndice);
-	} else if (isDerivedBitmapInCache(derBitmapIndex)) {
-		bitmap = getDerivedBitmap(derBitmapIndex);
+		bitmap = f489_getBitmap(explosionAspIndex + k348_FirstExplosionGraphicIndice);
+	} else if (f491_isDerivedBitmapInCache(derBitmapIndex)) {
+		bitmap = f492_getDerivedBitmap(derBitmapIndex);
 	} else {
-		byte *nativeBitmap = getBitmap(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice);
-		bitmap = getDerivedBitmap(derBitmapIndex);
-		blitToBitmapShrinkWithPalChange(nativeBitmap, explAsp->_pixelWidth, explAsp->_height, bitmap, pixelWidth, height,
+		byte *nativeBitmap = f489_getBitmap(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice);
+		bitmap = f492_getDerivedBitmap(derBitmapIndex);
+		f129_blitToBitmapShrinkWithPalChange(nativeBitmap, explAsp->_pixelWidth, explAsp->_height, bitmap, pixelWidth, height,
 			(explosionAspIndex == k3_ExplosionAspectSmoke) ? g212_PalChangeSmoke : g17_PalChangesNoChanges);
 		warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 	}
@@ -1148,37 +1148,37 @@ uint16 DisplayMan::getHeight(uint16 index) {
 // Note: has been screened for missing code
 void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitmap, uint16 pixelWidth, uint16 height) {
 	memmove(destBitmap, srcBitmap, pixelWidth * height * sizeof(byte));
-	flipBitmapHorizontal(destBitmap, pixelWidth, height);
+	f103_flipBitmapHorizontal(destBitmap, pixelWidth, height);
 }
 
-void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
+void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
 	if (f._srcWidth)
-		blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k255_ColorNoTransparency);
+		f132_blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k255_ColorNoTransparency);
 }
 
-void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) {
+void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) {
 	if (f._srcWidth)
-		blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh);
+		f132_blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh);
 }
 
 
 // NOTE: has been screened for missing code
-void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f116_drawSquareD3L(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	int16 order;
 
-	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_StairsFrontElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g110_FrameStairsUpFront_D3L);
+			f104_drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g110_FrameStairsUpFront_D3L);
 		else
-			drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g121_FrameStairsDownFront_D3L);
+			f104_drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g121_FrameStairsDownFront_D3L);
 		goto T0116015_redEagle;
 	case k0_WallElemType:
-		drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k1_ViewSquare_D3L]);
-		isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT);
-		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) {
+		f100_drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k1_ViewSquare_D3L]);
+		f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT);
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
 			goto T0116017_orangeElk;
 		}
@@ -1189,14 +1189,14 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) {
 		goto T0116016_blueToad;
 	case k17_ElementTypeDoorFront:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
-		cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
-		drawWallSetBitmap(_g705_bitmapWallSet_DoorFrameLeft_D3L, g164_Frame_DoorFrameLeft_D3L);
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
+		f100_drawWallSetBitmap(_g705_bitmapWallSet_DoorFrameLeft_D3L, g164_Frame_DoorFrameLeft_D3L);
 		warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor");
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0116017_orangeElk;
 	case k2_ElementTypePit:
 		if (!squareAspect[k2_PitInvisibleAspect]) {
-			drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, g140_FrameFloorPit_D3L);
+			f104_drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, g140_FrameFloorPit_D3L);
 		}
 	case k5_ElementTypeTeleporter:
 	case k1_ElementTypeCorridor:
@@ -1205,32 +1205,32 @@ T0116015_redEagle:
 T0116016_blueToad:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
 T0116017_orangeElk:
-		cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order);
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order);
 	}
 	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		drawField(&g188_FieldAspects[k1_ViewSquare_D3L], g163_FrameWalls[k1_ViewSquare_D3L]._box);
+		f113_drawField(&g188_FieldAspects[k1_ViewSquare_D3L], g163_FrameWalls[k1_ViewSquare_D3L]._box);
 	}
 }
 
 // NOTE: has been screened for missing code
-void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) {
 	int16 order;
 	uint16 squareAspect[5];
 
 
-	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g112_FrameStairsUpFront_D3R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g112_FrameStairsUpFront_D3R);
 		} else {
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g123_FrameStairsDownFront_D3R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g123_FrameStairsDownFront_D3R);
 		}
 		goto T0117016;
 	case k0_ElementTypeWall:
-		drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k2_ViewSquare_D3R]);
-		isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT);
-		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) {
+		f100_drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k2_ViewSquare_D3R]);
+		f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT);
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
 			goto T0117018;
 		}
@@ -1241,7 +1241,7 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
 		goto T0117017;
 	case k17_ElementTypeDoorFront:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
-		cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
 		memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44);
 		warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally");
 		if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
@@ -1252,7 +1252,7 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) {
 		goto T0117018;
 	case k2_ElementTypePit:
 		if (!squareAspect[k2_PitInvisibleAspect]) {
-			drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, g142_FrameFloorPit_D3R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, g142_FrameFloorPit_D3R);
 		}
 	case k5_ElementTypeTeleporter:
 	case k1_ElementTypeCorridor:
@@ -1261,26 +1261,26 @@ T0117016:
 T0117017:
 		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
 T0117018:
-		cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order);
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order);
 	}
 	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		drawField(&g188_FieldAspects[k2_ViewSquare_D3R], g163_FrameWalls[k2_ViewSquare_D3R]._box);
+		f113_drawField(&g188_FieldAspects[k2_ViewSquare_D3R], g163_FrameWalls[k2_ViewSquare_D3R]._box);
 	}
 }
 
-void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f118_drawSquareD3C(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
-	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
 	case k19_StairsFrontElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, g111_FrameStairsUpFront_D3C);
+			f104_drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, g111_FrameStairsUpFront_D3C);
 		else
-			drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, g122_FrameStairsDownFront_D3C);
+			f104_drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, g122_FrameStairsDownFront_D3C);
 		break;
 	case k0_WallElemType:
-		drawWallSetBitmapWithoutTransparency(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k0_ViewSquare_D3C]);
-		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) {
+		f101_drawWallSetBitmapWithoutTransparency(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k0_ViewSquare_D3C]);
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) {
 			//... missing code
 		}
 		break;
@@ -1288,67 +1288,67 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) {
 		break;
 	}
 }
-void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f119_drawSquareD2L(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
-	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
 	case k19_StairsFrontElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L);
+			f104_drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L);
 		else
-			drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L);
+			f104_drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L);
 		break;
 	case k0_WallElemType:
-		drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k4_ViewSquare_D2L]);
-		isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT);
-		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) {
+		f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k4_ViewSquare_D2L]);
+		f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT);
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) {
 			// ... missing code
 		}
 		break;
 	case k18_StairsSideElemType:
-		drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L);
+		f104_drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L);
 		break;
 	default:
 		break;
 	}
 }
-void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f120_drawSquareD2R(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
-	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
 	case k19_StairsFrontElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R);
 		else
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R);
 		break;
 	case k0_WallElemType:
-		drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k5_ViewSquare_D2R]);
-		isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT);
-		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) {
+		f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k5_ViewSquare_D2R]);
+		f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT);
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) {
 			// ... missing code
 		}
 		break;
 	case k18_StairsSideElemType:
-		drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R);
+		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R);
 		break;
 	default:
 		break;
 	}
 }
-void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f121_drawSquareD2C(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
-	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
 	case k19_StairsFrontElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, g114_FrameStairsUpFront_D2C);
+			f104_drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, g114_FrameStairsUpFront_D2C);
 		else
-			drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, g125_FrameStairsDownFront_D2C);
+			f104_drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, g125_FrameStairsDownFront_D2C);
 		break;
 	case k0_WallElemType:
-		drawWallSetBitmapWithoutTransparency(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k3_ViewSquare_D2C]);
-		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) {
+		f101_drawWallSetBitmapWithoutTransparency(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k3_ViewSquare_D2C]);
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) {
 			// ... missing code
 		}
 		break;
@@ -1356,70 +1356,70 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) {
 		break;
 	}
 }
-void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f122_drawSquareD1L(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
-	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
 	case k19_StairsFrontElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g116_FrameStairsUpFront_D1L);
+			f104_drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g116_FrameStairsUpFront_D1L);
 		else
-			drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g127_FrameStairsDownFront_D1L);
+			f104_drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g127_FrameStairsDownFront_D1L);
 		break;
 	case k0_WallElemType:
-		drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k7_ViewSquare_D1L]);
-		isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT);
+		f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k7_ViewSquare_D1L]);
+		f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT);
 		break;
 	case k18_StairsSideElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g134_FrameStairsUpSide_D1L);
+			f104_drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g134_FrameStairsUpSide_D1L);
 		else
-			drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g136_FrameStairsDownSide_D1L);
+			f104_drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g136_FrameStairsDownSide_D1L);
 		break;
 	default:
 		break;
 	}
 }
-void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f123_drawSquareD1R(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
-	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
 	case k19_StairsFrontElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g118_FrameStairsUpFront_D1R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g118_FrameStairsUpFront_D1R);
 		else
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g129_FrameStairsDownFront_D1R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g129_FrameStairsDownFront_D1R);
 		break;
 	case k0_WallElemType:
-		drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k8_ViewSquare_D1R]);
-		isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT);
+		f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k8_ViewSquare_D1R]);
+		f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT);
 		break;
 	case k18_StairsSideElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g135_FrameStairsUpSide_D1R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g135_FrameStairsUpSide_D1R);
 		else
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g137_FrameStairsDownSide_D1R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g137_FrameStairsDownSide_D1R);
 		break;
 	default:
 		break;
 	}
 }
-void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
-	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
 	case k19_StairsFrontElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, g117_FrameStairsUpFront_D1C);
+			f104_drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, g117_FrameStairsUpFront_D1C);
 		else
-			drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, g128_FrameStairsDownFront_D1C);
+			f104_drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, g128_FrameStairsDownFront_D1C);
 		break;
 	case k0_WallElemType:
 		_vm->_dungeonMan->_g286_isFacingAlcove = false;
 		_vm->_dungeonMan->_g287_isFacingViAltar = false;
 		_vm->_dungeonMan->_g288_isFacingFountain = false;
-		drawWallSetBitmapWithoutTransparency(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k6_ViewSquare_D1C]);
-		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) {
+		f101_drawWallSetBitmapWithoutTransparency(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k6_ViewSquare_D1C]);
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) {
 			// .... code not yet implemneted
 		}
 		break;
@@ -1428,49 +1428,49 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) {
 	}
 }
 
-void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f125_drawSquareD0L(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
-	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
 	case k18_StairsSideElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, g138_FrameStairsSide_D0L);
+			f104_drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, g138_FrameStairsSide_D0L);
 		break;
 	case k0_WallElemType:
-		drawWallSetBitmap(_g701_bitmapWallSet_Wall_D0L, g163_FrameWalls[k10_ViewSquare_D0L]);
+		f100_drawWallSetBitmap(_g701_bitmapWallSet_Wall_D0L, g163_FrameWalls[k10_ViewSquare_D0L]);
 		break;
 	default:
 		break;
 	}
 }
 
-void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f126_drawSquareD0R(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
-	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
 	case k18_StairsSideElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R);
 		return;
 	case k0_WallElemType:
-		drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, g163_FrameWalls[k11_ViewSquare_D0R]);
+		f100_drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, g163_FrameWalls[k11_ViewSquare_D0R]);
 		break;
 	default:
 		break;
 	}
 }
 
-void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
-	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
 	case k19_StairsFrontElemType:
 		if (squareAspect[k2_StairsUpAspect]) {
-			drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g119_FrameStairsUpFront_D0L);
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g120_FrameStairsUpFront_D0R);
+			f104_drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g119_FrameStairsUpFront_D0L);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g120_FrameStairsUpFront_D0R);
 		} else {
-			drawFloorPitOrStairsBitmap(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g130_FrameStairsDownFront_D0L);
-			drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g131_FrameStairsDownFront_D0R);
+			f104_drawFloorPitOrStairsBitmap(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g130_FrameStairsDownFront_D0L);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g131_FrameStairsDownFront_D0R);
 		}
 		break;
 	default:
@@ -1478,7 +1478,7 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) {
 	}
 }
 
-void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) {
 	loadPalette(g20_PalEntrance);
 	// TODO: this is a global variable, set from here
 	bool flippedFloorCeiling = true;
@@ -1492,9 +1492,9 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 	}
 
 	if (_g76_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1) {
-		drawWallSetBitmap(_g85_bitmapCeiling, gK12_CeilingFrame);
+		f100_drawWallSetBitmap(_g85_bitmapCeiling, gK12_CeilingFrame);
 		f99_copyBitmapAndFlipHorizontal(_g84_bitmapFloor, _g74_tmpBitmap, k112_byteWidthViewport * 2, 70);
-		drawWallSetBitmap(_g74_tmpBitmap, gK13_FloorFrame);
+		f100_drawWallSetBitmap(_g74_tmpBitmap, gK13_FloorFrame);
 
 		if (flippedFloorCeiling) {
 			_g698_bitmapWallSet_Wall_D3LCR = _g90_bitmapWall_D3LCR_Flipped;
@@ -1505,49 +1505,49 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) {
 		}
 	} else {
 		f99_copyBitmapAndFlipHorizontal(_g85_bitmapCeiling, _g74_tmpBitmap, k112_byteWidthViewport * 2, 29);
-		drawWallSetBitmap(_g74_tmpBitmap, gK12_CeilingFrame);
-		drawWallSetBitmap(_g84_bitmapFloor, gK13_FloorFrame);
+		f100_drawWallSetBitmap(_g74_tmpBitmap, gK12_CeilingFrame);
+		f100_drawWallSetBitmap(_g84_bitmapFloor, gK13_FloorFrame);
 	}
 
-	if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == k0_WallElemType)
-		drawWallSetBitmap(_g697_bitmapWallSet_Wall_D3L2, g711_FrameWall_D3L2);
-	if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == k0_WallElemType)
-		drawWallSetBitmap(_g696_bitmapWallSet_Wall_D3R2, g712_FrameWall_D3R2);
+	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, -2, posX, posY) == k0_WallElemType)
+		f100_drawWallSetBitmap(_g697_bitmapWallSet_Wall_D3L2, g711_FrameWall_D3L2);
+	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, 2, posX, posY) == k0_WallElemType)
+		f100_drawWallSetBitmap(_g696_bitmapWallSet_Wall_D3R2, g712_FrameWall_D3R2);
 
 	int16 tmpPosX = posX, tmpPosY = posY;
-	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY);
-	drawSquareD3L(dir, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY);
+	f116_drawSquareD3L(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX, tmpPosY = posY;
-	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, 1, tmpPosX, tmpPosY);
-	drawSquareD3R(dir, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 3, 1, tmpPosX, tmpPosY);
+	f117_drawSquareD3R(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX, tmpPosY = posY;
-	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, 0, tmpPosX, tmpPosY);
-	drawSquareD3C(dir, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 3, 0, tmpPosX, tmpPosY);
+	f118_drawSquareD3C(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX, tmpPosY = posY;
-	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, -1, tmpPosX, tmpPosY);
-	drawSquareD2L(dir, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 2, -1, tmpPosX, tmpPosY);
+	f119_drawSquareD2L(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX, tmpPosY = posY;
-	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, 1, tmpPosX, tmpPosY);
-	drawSquareD2R(dir, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 2, 1, tmpPosX, tmpPosY);
+	f120_drawSquareD2R(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX, tmpPosY = posY;
-	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, 0, tmpPosX, tmpPosY);
-	drawSquareD2C(dir, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 2, 0, tmpPosX, tmpPosY);
+	f121_drawSquareD2C(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX, tmpPosY = posY;
-	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, -1, tmpPosX, tmpPosY);
-	drawSquareD1L(dir, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 1, -1, tmpPosX, tmpPosY);
+	f122_drawSquareD1L(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX, tmpPosY = posY;
-	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, 1, tmpPosX, tmpPosY);
-	drawSquareD1R(dir, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 1, 1, tmpPosX, tmpPosY);
+	f123_drawSquareD1R(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX, tmpPosY = posY;
-	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, 0, tmpPosX, tmpPosY);
-	drawSquareD1C(dir, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 1, 0, tmpPosX, tmpPosY);
+	f124_drawSquareD1C(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX, tmpPosY = posY;
-	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 0, -1, tmpPosX, tmpPosY);
-	drawSquareD0L(dir, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 0, -1, tmpPosX, tmpPosY);
+	f125_drawSquareD0L(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX, tmpPosY = posY;
-	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 0, 1, tmpPosX, tmpPosY);
-	drawSquareD0R(dir, tmpPosX, tmpPosY);
-	drawSquareD0C(dir, posX, posY);
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 0, 1, tmpPosX, tmpPosY);
+	f126_drawSquareD0R(dir, tmpPosX, tmpPosY);
+	f127_drawSquareD0C(dir, posX, posY);
 
 	if (flippedFloorCeiling) {
 		_g698_bitmapWallSet_Wall_D3LCR = _g95_bitmapWall_D3LCR_Native;
@@ -1569,12 +1569,12 @@ void DisplayMan::f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Colo
 }
 
 // NOTE: has been screened for missing code
-void DisplayMan::loadFloorSet(FloorSet set) {
+void DisplayMan::f94_loadFloorSet(FloorSet set) {
 	if (_g230_currentFloorSet != set) {
 		_g230_currentFloorSet = set;
 		int16 index = (set * k2_FloorSetGraphicCount) + k75_FirstFloorSet;
-		loadIntoBitmap(index, _g84_bitmapFloor);
-		loadIntoBitmap(index + 1, _g85_bitmapCeiling);
+		f466_loadIntoBitmap(index, _g84_bitmapFloor);
+		f466_loadIntoBitmap(index + 1, _g85_bitmapCeiling);
 	}
 }
 
@@ -1582,25 +1582,25 @@ Box g161_BoxWallBitmap_D3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_W
 Box g162_BoxWallBitmap_D2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR
 
 // Note: has been screened for missing code
-void DisplayMan::loadWallSet(WallSet set) {
+void DisplayMan::f95_loadWallSet(WallSet set) {
 
 	if ((_g231_currentWallSet != set) || _vm->_g523_restartGameRequest) {
 		_g231_currentWallSet = set;
 		{
 			int16 graphicIndice = (set * k13_WallSetGraphicCount) + k77_FirstWallSet;
-			loadIntoBitmap(graphicIndice++, _g709_bitmapWallSet_DoorFrameFront);
-			loadIntoBitmap(graphicIndice++, _g708_bitmapWallSet_DoorFrameLeft_D1C);
-			loadIntoBitmap(graphicIndice++, _g707_bitmapWallSet_DoorFrameLeft_D2C);
-			loadIntoBitmap(graphicIndice++, _g706_bitmapWallSet_DoorFrameLeft_D3C);
-			loadIntoBitmap(graphicIndice++, _g705_bitmapWallSet_DoorFrameLeft_D3L);
-			loadIntoBitmap(graphicIndice++, _g704_bitmapWallSet_DoorFrameTop_D1LCR);
-			loadIntoBitmap(graphicIndice++, _g703_bitmapWallSet_DoorFrameTop_D2LCR);
-			loadIntoBitmap(graphicIndice++, _g702_bitmapWallSet_Wall_D0R);
-			loadIntoBitmap(graphicIndice++, _g701_bitmapWallSet_Wall_D0L);
-			loadIntoBitmap(graphicIndice++, _g700_bitmapWallSet_Wall_D1LCR);
-			loadIntoBitmap(graphicIndice++, _g699_bitmapWallSet_Wall_D2LCR);
-			loadIntoBitmap(graphicIndice++, _g698_bitmapWallSet_Wall_D3LCR);
-			loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2);
+			f466_loadIntoBitmap(graphicIndice++, _g709_bitmapWallSet_DoorFrameFront);
+			f466_loadIntoBitmap(graphicIndice++, _g708_bitmapWallSet_DoorFrameLeft_D1C);
+			f466_loadIntoBitmap(graphicIndice++, _g707_bitmapWallSet_DoorFrameLeft_D2C);
+			f466_loadIntoBitmap(graphicIndice++, _g706_bitmapWallSet_DoorFrameLeft_D3C);
+			f466_loadIntoBitmap(graphicIndice++, _g705_bitmapWallSet_DoorFrameLeft_D3L);
+			f466_loadIntoBitmap(graphicIndice++, _g704_bitmapWallSet_DoorFrameTop_D1LCR);
+			f466_loadIntoBitmap(graphicIndice++, _g703_bitmapWallSet_DoorFrameTop_D2LCR);
+			f466_loadIntoBitmap(graphicIndice++, _g702_bitmapWallSet_Wall_D0R);
+			f466_loadIntoBitmap(graphicIndice++, _g701_bitmapWallSet_Wall_D0L);
+			f466_loadIntoBitmap(graphicIndice++, _g700_bitmapWallSet_Wall_D1LCR);
+			f466_loadIntoBitmap(graphicIndice++, _g699_bitmapWallSet_Wall_D2LCR);
+			f466_loadIntoBitmap(graphicIndice++, _g698_bitmapWallSet_Wall_D3LCR);
+			f466_loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2);
 		}
 		f99_copyBitmapAndFlipHorizontal(_g708_bitmapWallSet_DoorFrameLeft_D1C, _g710_bitmapWallSet_DoorFrameRight_D1C,
 										g171_Frame_DoorFrameRight_D1C._srcWidth, g171_Frame_DoorFrameRight_D1C._srcHeight);
@@ -1610,9 +1610,9 @@ void DisplayMan::loadWallSet(WallSet set) {
 }
 
 
-void DisplayMan::loadCurrentMapGraphics() {
-	loadFloorSet(_vm->_dungeonMan->_g269_currMap->_floorSet);
-	loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet);
+void DisplayMan::f96_loadCurrentMapGraphics() {
+	f94_loadFloorSet(_vm->_dungeonMan->_g269_currMap->_floorSet);
+	f95_loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet);
 
 	{
 		_g74_tmpBitmap = new byte[_screenWidth * _screenHeight];
@@ -1621,12 +1621,12 @@ void DisplayMan::loadCurrentMapGraphics() {
 		f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap,
 										g163_FrameWalls[k0_ViewSquare_D3C]._srcWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight);
 		f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, 128, 51, k10_ColorFlesh);
-		blitToBitmap(_g74_tmpBitmap, 128, 11, 0, _g90_bitmapWall_D3LCR_Flipped, 128, g161_BoxWallBitmap_D3LCR, k255_ColorNoTransparency);
+		f132_blitToBitmap(_g74_tmpBitmap, 128, 11, 0, _g90_bitmapWall_D3LCR_Flipped, 128, g161_BoxWallBitmap_D3LCR, k255_ColorNoTransparency);
 
 		f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap,
 										g163_FrameWalls[k3_ViewSquare_D2C]._srcWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight);
 		f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, 144, 71, k10_ColorFlesh);
-		blitToBitmap(_g74_tmpBitmap, 144, 8, 0, _g91_bitmapWall_D2LCR_Flipped, 144, g162_BoxWallBitmap_D2LCR, k255_ColorNoTransparency);
+		f132_blitToBitmap(_g74_tmpBitmap, 144, 8, 0, _g91_bitmapWall_D2LCR_Flipped, 144, g162_BoxWallBitmap_D2LCR, k255_ColorNoTransparency);
 
 		f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped,
 										g163_FrameWalls[k6_ViewSquare_D1C]._srcWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight);
@@ -1707,23 +1707,23 @@ void DisplayMan::loadCurrentMapGraphics() {
 		_g103_currMapDoorOrnInfo[i][k1_CoordinateSet] = g196_DoorOrnCoordIndices[ornIndice];
 	}
 
-	applyCreatureReplColors(9, 8);
-	applyCreatureReplColors(10, 12);
+	f93_applyCreatureReplColors(9, 8);
+	f93_applyCreatureReplColors(10, 12);
 
 	for (uint16 creatureType = 0; creatureType < currMap._creatureTypeCount; ++creatureType) {
 		CreatureAspect &aspect = g219_CreatureAspects[_g264_currMapAllowedCreatureTypes[creatureType]];
 		uint16 replColorOrdinal = aspect.getReplColour9();
 		if (replColorOrdinal)
-			applyCreatureReplColors(9, _vm->ordinalToIndex(replColorOrdinal));
+			f93_applyCreatureReplColors(9, _vm->M1_ordinalToIndex(replColorOrdinal));
 		replColorOrdinal = aspect.getReplColour10();
 		if (replColorOrdinal)
-			applyCreatureReplColors(10, _vm->ordinalToIndex(replColorOrdinal));
+			f93_applyCreatureReplColors(10, _vm->M1_ordinalToIndex(replColorOrdinal));
 	}
 
 	_g342_refreshDungeonViewPaleteRequested = true;
 }
 
-void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor) {
+void DisplayMan::f93_applyCreatureReplColors(int replacedColor, int replacementColor) {
 	for (int16 i = 0; i < 6; ++i)
 		g21_PalDungeonView[i][replacedColor] = g220_CreatureReplColorSets[replacementColor]._RGBColor[i];
 
@@ -1731,15 +1731,15 @@ void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor
 	g221_PalChangesCreature_D3[replacedColor] = g220_CreatureReplColorSets[replacementColor]._D3ReplacementColor;
 }
 
-void DisplayMan::drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
+void DisplayMan::f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
 	if (f._srcWidth)
-		blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh);
+		f132_blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh);
 }
 
-void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) {
+void DisplayMan::f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) {
 	if (f._srcWidth) {
-		f99_copyBitmapAndFlipHorizontal(getBitmap(nativeIndex), _g74_tmpBitmap, f._srcWidth, f._srcHeight);
-		blitToBitmap(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh);
+		f99_copyBitmapAndFlipHorizontal(f489_getBitmap(nativeIndex), _g74_tmpBitmap, f._srcWidth, f._srcHeight);
+		f132_blitToBitmap(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh);
 	}
 }
 
@@ -1777,7 +1777,7 @@ byte g204_UnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_Unreadabl
 
 Box g109_BoxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall
 
-bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) {
+bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) {
 	byte *bitmapGreen;
 	byte *bitmapRed;
 	int16 coordinateSetOffset;
@@ -1794,17 +1794,17 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 		int16 nativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k0_NativeBitmapIndex];
 
 		uint16 *coordinateSetA = g205_WallOrnCoordSets[_g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]][viewWallIndex];
-		isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnIndex);
+		isAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(wallOrnIndex);
 		isInscription = (wallOrnIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex);
 		if (isInscription) {
-			_vm->_dungeonMan->decodeText((char*)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
+			_vm->_dungeonMan->f168_decodeText((char*)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
 		}
 
 		if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) {
 			if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
 				if (isInscription) {
 					Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C];
-					blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, _g296_bitmapViewport, k112_byteWidthViewport * 2,
+					f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, _g296_bitmapViewport, k112_byteWidthViewport * 2,
 								 g202_BoxWallPatchBehindInscription, k255_ColorNoTransparency);
 
 					unsigned char *string = inscriptionString;
@@ -1819,7 +1819,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 						frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7;
 						frame._box._y1 = (frame._box._y2 = g203_InscriptionLineY[textLineIndex++]) - 7;
 						while (characterCount--) {
-							blitToBitmap(bitmapRed, 288, (*string++) * 8, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, frame._box, k10_ColorFlesh);
+							f132_blitToBitmap(bitmapRed, 288, (*string++) * 8, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, frame._box, k10_ColorFlesh);
 							frame._box._x1 += 8;
 							frame._box._x2 += 8;
 						}
@@ -1868,7 +1868,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 				}
 			}
 			int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0];
-			blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], coordSetB[4] << 1, coordSetB[5], _g74_tmpBitmap, pixelWidth + 1, coordinateSetA[5],
+			f129_blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], coordSetB[4] << 1, coordSetB[5], _g74_tmpBitmap, pixelWidth + 1, coordinateSetA[5],
 				(viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
 			bitmapGreen = _bitmaps[nativeBitmapIndex];
 			var_X = pixelWidth;
@@ -1905,11 +1905,11 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 				coordinateSetA[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
 			}
 		}
-		blitToBitmap(bitmapGreen, coordinateSetA[4], var_X, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, *(Box*)coordinateSetA, k10_ColorFlesh);
+		f132_blitToBitmap(bitmapGreen, coordinateSetA[4], var_X, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, *(Box*)coordinateSetA, k10_ColorFlesh);
 
 		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
 			Box &box = g109_BoxChampionPortraitOnWall;
-			blitToBitmap(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29,
+			f132_blitToBitmap(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29,
 						 _g296_bitmapViewport, k112_byteWidthViewport * 2, box, k1_ColorDarkGary);
 		}
 		return isAlcove;
@@ -1918,7 +1918,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 }
 
 
-void DisplayMan::blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHeight, byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange) {
+void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHeight, byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange) {
 	double rateW = srcWidth / destWidth;
 	double rateH = srcHeight / destHeight;
 
@@ -1933,7 +1933,7 @@ void DisplayMan::blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth
 
 }
 
-byte* DisplayMan::getBitmap(uint16 index) {
+byte* DisplayMan::f489_getBitmap(uint16 index) {
 	return _bitmaps[index];
 }
 
@@ -1950,7 +1950,7 @@ uint32 DisplayMan::getCompressedDataSize(uint16 index) {
 #define kMaskFieldAspectIndex 0x007F // @ MASK0x007F_MASK_INDEX
 #define kMaskFieldAspectNoMask 255 // @ C255_NO_MASK            
 
-void DisplayMan::drawField(FieldAspect* fieldAspect, Box& box) {
+void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 
 	byte *bitmapMask;
@@ -1958,24 +1958,24 @@ void DisplayMan::drawField(FieldAspect* fieldAspect, Box& box) {
 		bitmapMask = nullptr;
 	} else {
 		bitmapMask = dispMan._g74_tmpBitmap;
-		memmove(bitmapMask, dispMan.getBitmap(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)),
+		memmove(bitmapMask, dispMan.f489_getBitmap(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)),
 			   fieldAspect->_height * fieldAspect->_pixelWidth * sizeof(bitmapMask[0]));
 		if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask)) {
-			dispMan.flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height);
+			dispMan.f103_flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height);
 		}
 	}
 
-	byte *bitmap = dispMan.getBitmap(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex);
+	byte *bitmap = dispMan.f489_getBitmap(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex);
 	warning("MISSING CODE: F0133_VIDEO_BlitBoxFilledWithMaskedBitmap");
 
 	warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache, F0493_CACHE_AddDerivedBitmap, F0480_CACHE_ReleaseBlock");
 }
 
-int16 DisplayMan::getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale) {
-	return getScaledDimension(pixelWidth, scale) * getScaledDimension(pixelHeight, scale);
+int16 DisplayMan::f459_getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale) {
+	return M78_getScaledDimension(pixelWidth, scale) * M78_getScaledDimension(pixelHeight, scale);
 }
 
-int16 DisplayMan::getScaledDimension(int16 dimension, int16 scale) {
+int16 DisplayMan::M78_getScaledDimension(int16 dimension, int16 scale) {
 	return (dimension * scale + scale / 2) / 32;
 }
 
@@ -2135,7 +2135,7 @@ int16 g225_CenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_Cen
 
 #define k0x0080_BlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK
 
-void DisplayMan::cthulhu(Thing thingParam, direction directionParam, int16 mapXpos,
+void DisplayMan::f115_cthulhu(Thing thingParam, direction directionParam, int16 mapXpos,
 						 int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) {
 
 	DungeonMan &dunMan = *_vm->_dungeonMan;
@@ -2276,7 +2276,7 @@ creatures are drawn in the right order and so that Fluxcages are not drawn twice
 			cellYellowBear = returnOppositeDir(directionParam); /* Alcove is on the opposite direction of the viewing direction */
 			objectShiftIndex = 2;
 		} else {
-			AL_2_viewCell = _vm->ordinalToIndex((int16)remainingViewCellOrdinalsToProcess & 0x000F); /* View cell is the index of coordinates to draw object */
+			AL_2_viewCell = _vm->M1_ordinalToIndex((int16)remainingViewCellOrdinalsToProcess & 0x000F); /* View cell is the index of coordinates to draw object */
 			currentViewCellToDraw = AL_2_viewCell;
 			remainingViewCellOrdinalsToProcess >>= 4; /* Proceed to the next cell ordinal */
 			cellCounter++;
@@ -2304,7 +2304,7 @@ creatures are drawn in the right order and so that Fluxcages are not drawn twice
 
 			/* Square where objects are visible and object is located on cell being processed */
 			if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) {
-				objectAspect = &(g209_ObjectAspects[g237_ObjectInfo[dunMan.getObjectInfoIndex(thingParam)]._objectAspectIndex]);
+				objectAspect = &(g209_ObjectAspects[g237_ObjectInfo[dunMan.f141_getObjectInfoIndex(thingParam)]._objectAspectIndex]);
 				AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex;
 				if (useAlcoveObjectImage = (drawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane)) {
 					AL_4_nativeBitmapIndex++;
@@ -2324,12 +2324,12 @@ T0115015_DrawProjectileAsObject:
 					/* If object is in the center lane (only D0C or D1C with condition above) and is not a projectile */
 					drawingGrabbableObject = (!viewLane && !drawProjectileAsObject);
 					AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
-					AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */
+					AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */
 					byteWidth = objectAspect->_width;
 					heightRedEagle = objectAspect->_height;
 					if (flipHorizontal) {
 						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
-						flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
+						f103_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
 				} else {
@@ -2338,13 +2338,13 @@ T0115015_DrawProjectileAsObject:
 					if ((viewSquareIndex >= k6_ViewSquare_D1C) || ((viewSquareIndex >= k3_ViewSquare_D2C) && (AL_2_viewCell >= k2_ViewCellBackRight))) {
 						derivedBitmapIndex++;
 						AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front;
-						byteWidth = getScaledDimension(objectAspect->_width, k20_Scale_D2);
-						heightRedEagle = getScaledDimension(objectAspect->_height, k20_Scale_D2);
+						byteWidth = M78_getScaledDimension(objectAspect->_width, k20_Scale_D2);
+						heightRedEagle = M78_getScaledDimension(objectAspect->_height, k20_Scale_D2);
 						paletteChanges = g214_PalChangesFloorOrn_D2;
 					} else {
 						AL_8_shiftSetIndex = k2_ShiftSet_D2BackD3Front;
-						byteWidth = getScaledDimension(objectAspect->_width, k16_Scale_D3);
-						heightRedEagle = getScaledDimension(objectAspect->_height, k16_Scale_D3);
+						byteWidth = M78_getScaledDimension(objectAspect->_width, k16_Scale_D3);
+						heightRedEagle = M78_getScaledDimension(objectAspect->_height, k16_Scale_D3);
 						paletteChanges = g213_PalChangesFloorOrn_D3;
 					}
 					if (flipHorizontal) {
@@ -2354,14 +2354,14 @@ T0115015_DrawProjectileAsObject:
 						derivedBitmapIndex += 4;
 					}
 
-					if (isDerivedBitmapInCache(derivedBitmapIndex)) {
-						AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
+					if (f491_isDerivedBitmapInCache(derivedBitmapIndex)) {
+						AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 					} else {
-						bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex);
-						blitToBitmapShrinkWithPalChange(bitmapGreenAnt, objectAspect->_width, objectAspect->_height, AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex),
+						bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex);
+						f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, objectAspect->_width, objectAspect->_height, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex),
 														byteWidth, heightRedEagle, paletteChanges);
 						if (flipHorizontal) {
-							flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
+							f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 						}
 						warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 					}
@@ -2417,12 +2417,12 @@ T0115015_DrawProjectileAsObject:
 					AL_6_bitmapRedBanana = bitmapGreenAnt;
 					dunMan._g292_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */
 				}
-				blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh);
+				f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh);
 
 				if (drawProjectileAsObject)
 					goto T0115171_BackFromT0115015_DrawProjectileAsObject;
 			}
-		} while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList);
+		} while ((thingParam = dunMan.f159_getNextThing(thingParam)) != Thing::_endOfList);
 		if (AL_2_viewCell == k4_ViewCellAlcove)
 			break; /* End of processing when drawing objects in an alcove */
 		if (viewSquareIndex < k0_ViewSquare_D3C)
@@ -2436,7 +2436,7 @@ T0115015_DrawProjectileAsObject:
 		if ((groupThing == Thing::_none) || drawCreaturesCompleted)
 			goto T0115129_DrawProjectiles; /* Skip code to draw creatures */
 		if (group == nullptr) { /* If all creature data and info has not already been gathered */
-			group = (Group*)dunMan.getThingData(groupThing);
+			group = (Group*)dunMan.f156_getThingData(groupThing);
 			activeGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
 			creatureInfo = &g243_CreatureInfo[group->_type];
 			creatureAspectStruct = &g219_CreatureAspects[creatureInfo->_creatureAspectIndex];
@@ -2444,7 +2444,7 @@ T0115015_DrawProjectileAsObject:
 			creatureGraphicInfoGreen = creatureInfo->_graphicInfo;
 		}
 		objectAspect = (ObjectAspect*)creatureAspectStruct;
-		if (AL_0_creatureIndexRed = _vm->_groupMan->getCreatureOrdinalInCell(group, cellYellowBear)) { /* If there is a creature on the cell being processed */
+		if (AL_0_creatureIndexRed = _vm->_groupMan->f176_getCreatureOrdinalInCell(group, cellYellowBear)) { /* If there is a creature on the cell being processed */
 			AL_0_creatureIndexRed--; /* Convert ordinal to index */
 			creatureIndexGreen = AL_0_creatureIndexRed;
 		} else if (creatureSize == k1_MaskCreatureSizeHalf) {
@@ -2454,7 +2454,7 @@ T0115015_DrawProjectileAsObject:
 			goto T0115129_DrawProjectiles; /* No creature to draw at cell, skip to projectiles */
 		}
 
-		creatureDirectionDelta = (directionParam - _vm->_groupMan->getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed)) % 3;
+		creatureDirectionDelta = (directionParam - _vm->_groupMan->M50_getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed)) % 3;
 		twoHalfSquareCreaturesFrontView = false;
 		if ((AL_4_groupCells = activeGroup->_cells) == k255_CreatureTypeSingleCenteredCreature) { /* If there is a single centered creature in the group */
 			if (remainingViewCellOrdinalsToProcess || (doorFrontViewDrawingPass == 1))
@@ -2487,7 +2487,7 @@ T0115015_DrawProjectileAsObject:
 						creatureIndexGreen = 0;
 					}
 					twoHalfSquareCreaturesFrontView = group->getCount();
-					if (((AL_4_groupCells = _vm->_groupMan->getCreatureValue(AL_4_groupCells, AL_0_creatureIndexRed)) == directionParam)
+					if (((AL_4_groupCells = _vm->_groupMan->M50_getCreatureValue(AL_4_groupCells, AL_0_creatureIndexRed)) == directionParam)
 						|| (AL_4_groupCells == returnPrevVal(directionParam))) {
 						AL_2_viewCell = k0_HalfSizedViewCell_LeftColumn;
 					} else {
@@ -2571,29 +2571,29 @@ T0115077_DrawSecondHalfSquareCreature:
 			AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
 			transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour();
 			if (useCreatureSideBitmap) {
-				AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex);
+				AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex);
 				if (creatureDirectionDelta == 1) {
 					memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
-					flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
+					f103_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
 			} else {
 				if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) {
-					AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex);
+					AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex);
 					if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
 						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
-						flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
+						f103_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
 				} else { /* Use first additional derived graphic: front D1 */
-					if (isDerivedBitmapInCache(derivedBitmapIndex)) { /* If derived graphic is already in memory */
-						AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
+					if (f491_isDerivedBitmapInCache(derivedBitmapIndex)) { /* If derived graphic is already in memory */
+						AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 					} else {
-						bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex);
+						bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex);
 						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) {
-							AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
+							AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 							memmove(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * heightRedEagle * sizeof(byte));
-							flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
+							f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 						}
 						warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 					}
@@ -2616,15 +2616,15 @@ T0115077_DrawSecondHalfSquareCreature:
 				paletteChanges = g221_PalChangesCreature_D3;
 				scale = k16_Scale_D3;
 			}
-			byteWidth = getScaledDimension(sourceByteWidth, scale);
-			heightRedEagle = getScaledDimension(sourceHeight, scale);
+			byteWidth = M78_getScaledDimension(sourceByteWidth, scale);
+			heightRedEagle = M78_getScaledDimension(sourceHeight, scale);
 			transparentColor = paletteChanges[((CreatureAspect*)objectAspect)->getTranspColour()] / 10;
-			if (derivedBitmapInCache = isDerivedBitmapInCache(derivedBitmapIndex)) {
-				AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
+			if (derivedBitmapInCache = f491_isDerivedBitmapInCache(derivedBitmapIndex)) {
+				AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 			} else {
-				bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex);
-				AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
-				blitToBitmapShrinkWithPalChange(bitmapGreenAnt, sourceByteWidth, sourceHeight, AL_6_bitmapRedBanana, byteWidth, heightRedEagle, paletteChanges);
+				bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex);
+				AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
+				f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, sourceByteWidth, sourceHeight, AL_6_bitmapRedBanana, byteWidth, heightRedEagle, paletteChanges);
 				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 			}
 			if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */
@@ -2633,12 +2633,12 @@ T0115077_DrawSecondHalfSquareCreature:
 				(useFlippedHorizontallyCreatureFrontImage && getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack))) { /* If the graphic should be flipped */
 				if (!useFlippedHorizontallyCreatureFrontImage || !derivedBitmapInCache) {
 					AL_4_normalizdByteWidth = byteWidth;
-					warning("SUPER WARNING: we might need getNormalizedByteWidthM77");
+					warning("SUPER WARNING: we might need M77_getNormalizedByteWidth");
 					if (!useFlippedHorizontallyCreatureFrontImage) {
 						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte));
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
-					flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
+					f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 				}
 				creaturePaddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1;
 			} else {
@@ -2646,11 +2646,11 @@ T0115077_DrawSecondHalfSquareCreature:
 			}
 		}
 		AL_4_yPos = coordinateSet[1];
-		AL_4_yPos += g223_ShiftSets[AL_8_shiftSetIndex][getVerticalOffsetM23(creatureAspectInt)];
+		AL_4_yPos += g223_ShiftSets[AL_8_shiftSetIndex][M23_getVerticalOffsetM23(creatureAspectInt)];
 		boxByteGreen._y2 = MIN(AL_4_yPos, (int16)135) + 1;
 		boxByteGreen._y1 = MIN(0, AL_4_yPos - (heightRedEagle - 1));
 		AL_4_xPos = coordinateSet[0];
-		AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][getHorizontalOffsetM22(creatureAspectInt)];
+		AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][M22_getHorizontalOffsetM22(creatureAspectInt)];
 		if (viewLane == k1_ViewLaneLeft) {
 			AL_4_xPos -= 100;
 		} else {
@@ -2668,7 +2668,7 @@ T0115077_DrawSecondHalfSquareCreature:
 			AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1);
 		}
 		warning("SUPER WARNINIG: we might nee noralized with on byteWidth");
-		blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, (Color)transparentColor);
+		f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, (Color)transparentColor);
 
 T0115126_CreatureNotVisible:
 		if (twoHalfSquareCreaturesFrontView) {
@@ -2692,9 +2692,9 @@ continue;
 
 		do {
 			if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) {
-				projectile = (Projectile*)dunMan.getThingData(thingParam);
-				if ((AL_4_projectileAspect = dunMan.getProjectileAspect(projectile->_object)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
-					objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)];
+				projectile = (Projectile*)dunMan.f156_getThingData(thingParam);
+				if ((AL_4_projectileAspect = dunMan.f142_getProjectileAspect(projectile->_object)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
+					objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-AL_4_projectileAspect)];
 					AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
 					projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
 					if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask))
@@ -2708,8 +2708,8 @@ continue;
 						if (!doNotScaleWithKineticEnergy) {
 							scale = (scale * MAX(96, projectile->_kineticEnergy + 1)) >> 8;
 						}
-						byteWidth = getScaledDimension(((ProjectileAspect*)objectAspect)->_width, scale);
-						heightRedEagle = getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale);
+						byteWidth = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_width, scale);
+						heightRedEagle = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale);
 					}
 					if (projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == k0_ProjectileAspectHasBackGraphicRotation)) {
 						projectileFlipVertical = ((mapXpos + mapYpos) & 0x0001);
@@ -2751,22 +2751,22 @@ continue;
 					AL_4_nativeBitmapIndex += projectileBitmapIndexData;
 					paddingPixelCount = 0;
 					if (!scale) {
-						AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex);
+						AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex);
 					} else {
 						if (flipHorizontal) {
 							paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1;
 						}
 						derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (projectileBitmapIndexData * 6);
-						if (doNotScaleWithKineticEnergy && isDerivedBitmapInCache(derivedBitmapIndex) + AL_8_projectileScaleIndex) {
-							AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
+						if (doNotScaleWithKineticEnergy && f491_isDerivedBitmapInCache(derivedBitmapIndex) + AL_8_projectileScaleIndex) {
+							AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 						} else {
-							bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex);
+							bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex);
 							if (doNotScaleWithKineticEnergy) {
-								AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
+								AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 							} else {
 								AL_6_bitmapRedBanana = _g74_tmpBitmap;
 							}
-							blitToBitmapShrinkWithPalChange(bitmapGreenAnt, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height,
+							f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height,
 															AL_6_bitmapRedBanana, byteWidth, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
 							if (doNotScaleWithKineticEnergy) {
 								warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap");
@@ -2784,7 +2784,7 @@ continue;
 							flipBitmapVertical(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 						}
 						if (flipHorizontal) {
-							flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
+							f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 						}
 					}
 					boxByteGreen._y2 = (heightRedEagle >> 1) + 47 + 1;
@@ -2803,7 +2803,7 @@ the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part
 screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
 						AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - projectilePosX - 1));
 					}
-					blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh);
+					f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh);
 				} else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */
 					useAlcoveObjectImage = false;
 					projectileCoordinates[0] = projectilePosX;
@@ -2817,7 +2817,7 @@ screen. To fix this bug, "+ paddingPixelCount" must be added to the second param
 				}
 			}
 T0115171_BackFromT0115015_DrawProjectileAsObject:;
-		} while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList);
+		} while ((thingParam = dunMan.f159_getNextThing(thingParam)) != Thing::_endOfList);
 
 	} while (remainingViewCellOrdinalsToProcess);
 
@@ -2832,7 +2832,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 	do {
 		if (thingParam.getType() == k15_ExplosionThingType) {
 			AL_2_cellPurpleMan = thingParam.getCell();
-			explosion = (Explosion*)dunMan.getThingData(thingParam);
+			explosion = (Explosion*)dunMan.f156_getThingData(thingParam);
 			if ((rebirthExplosion = ((unsigned int)(AL_4_explosionType = explosion->getType()) >= k100_ExplosionType_RebirthStep1))
 				&& ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion)
 					|| (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion)
@@ -2850,13 +2850,13 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 						AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke;
 					} else {
 						if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) {
-							objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->ordinalToIndex(-dunMan.getProjectileAspect(Thing::_explLightningBolt))];
-							AL_6_bitmapRedBanana = getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
+							objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-dunMan.f142_getProjectileAspect(Thing::_explLightningBolt))];
+							AL_6_bitmapRedBanana = f489_getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
 							explosionCoordinates = g228_RebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
-							byteWidth = getScaledDimension((((ProjectileAspect*)objectAspect)->_width), explosionCoordinates[2]);
-							heightRedEagle = getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
+							byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_width), explosionCoordinates[2]);
+							heightRedEagle = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
 							if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) {
-								blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana,
+								f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana,
 									((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, _g74_tmpBitmap,
 																byteWidth, heightRedEagle, g17_PalChangesNoChanges);
 								AL_6_bitmapRedBanana = _g74_tmpBitmap;
@@ -2885,12 +2885,12 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					}
 				}
 				warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache");
-				AL_6_bitmapRedBanana = getBitmap(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice);
+				AL_6_bitmapRedBanana = f489_getBitmap(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice);
 				if (smoke) {
-					blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _g74_tmpBitmap, 48, 32, g212_PalChangeSmoke);
+					f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _g74_tmpBitmap, 48, 32, g212_PalChangeSmoke);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
-				blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, nullptr, getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C,
+				f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, nullptr, f492_getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C,
 											  _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64),
 											  224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
 				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
@@ -2912,7 +2912,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					}
 					explosionScale = MAX(4, (MAX(48, explosion->getAttack() + 1) * g216_ExplosionBaseScales[explosionScaleIndex]) >> 8) & (int16)0xFFFE;
 				}
-				AL_6_bitmapRedBanana = getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle);
+				AL_6_bitmapRedBanana = f114_getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle);
 T0115200_DrawExplosion:
 				flipVertical = _vm->_rnd->getRandomNumber(2);
 				paddingPixelCount = 0;
@@ -2950,37 +2950,37 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
 				if (flipHorizontal) {
-					flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
+					f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 				}
 				if (flipVertical) {
 					flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 				}
-				blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh);
+				f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh);
 			}
 		}
-	} while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList);
+	} while ((thingParam = dunMan.f159_getNextThing(thingParam)) != Thing::_endOfList);
 /* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */
 	if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_g77_doNotDrawFluxcagesDuringEndgame) {
 		AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */
 		fieldAspect = g188_FieldAspects[viewSquareIndex];
 		(fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */
-		drawField(&fieldAspect, *(Box*)&g163_FrameWalls[viewSquareIndex]);
+		f113_drawField(&fieldAspect, *(Box*)&g163_FrameWalls[viewSquareIndex]);
 	}
 }
 
-uint16 DisplayMan::getNormalizedByteWidthM77(uint16 byteWidth) {
+uint16 DisplayMan::M77_getNormalizedByteWidth(uint16 byteWidth) {
 	return (byteWidth + 7) & 0xFFF8;
 }
 
-uint16 DisplayMan::getVerticalOffsetM23(uint16 val) {
+uint16 DisplayMan::M23_getVerticalOffsetM23(uint16 val) {
 	return (val >> 3) & 0x7;
 }
 
-uint16 DisplayMan::getHorizontalOffsetM22(uint16 val) {
+uint16 DisplayMan::M22_getHorizontalOffsetM22(uint16 val) {
 	return (val & 0x7);
 }
 
-bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) {
+bool DisplayMan::f491_isDerivedBitmapInCache(int16 derivedBitmapIndex) {
 	if (_g638_derivedBitmaps[derivedBitmapIndex] == nullptr) {
 		// * 2, because the original uses 4 bits instead of 8 bits to store a pixel
 		_g638_derivedBitmaps[derivedBitmapIndex] = new byte[_g639_derivedBitmapByteCount[derivedBitmapIndex] * 2];
@@ -2989,7 +2989,7 @@ bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) {
 		return true;
 }
 
-byte* DisplayMan::getDerivedBitmap(int16 derivedBitmapIndex) {
+byte* DisplayMan::f492_getDerivedBitmap(int16 derivedBitmapIndex) {
 	return _g638_derivedBitmaps[derivedBitmapIndex];
 }
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index df48bec..a0a61ba 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -433,27 +433,27 @@ class DisplayMan {
 	void f565_viewportSetPalette(uint16 * middleScreenPalette, uint16 * topAndBottomScreen); // @ F0565_VIEWPORT_SetPalette
 	void f566_viewportBlitToScreen(); // @ F0566_VIEWPORT_BlitToScreen
 
-	void drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally
-	void drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap
-	void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap
-	void drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency
-	void drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L
-	void drawSquareD3R(direction dir, int16 posX, int16 posY); // @ F0117_DUNGEONVIEW_DrawSquareD3R
-	void drawSquareD3C(direction dir, int16 posX, int16 posY); // @ F0118_DUNGEONVIEW_DrawSquareD3C_CPSF
-	void drawSquareD2L(direction dir, int16 posX, int16 posY); // @ F0119_DUNGEONVIEW_DrawSquareD2L
-	void drawSquareD2R(direction dir, int16 posX, int16 posY); // @ F0120_DUNGEONVIEW_DrawSquareD2R_CPSF
-	void drawSquareD2C(direction dir, int16 posX, int16 posY); // @ F0121_DUNGEONVIEW_DrawSquareD2C
-	void drawSquareD1L(direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1L
-	void drawSquareD1R(direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1R
-	void drawSquareD1C(direction dir, int16 posX, int16 posY); // @ F0124_DUNGEONVIEW_DrawSquareD1C
-	void drawSquareD0L(direction dir, int16 posX, int16 posY); // @ F0125_DUNGEONVIEW_DrawSquareD0L
-	void drawSquareD0R(direction dir, int16 posX, int16 posY); // @ F0126_DUNGEONVIEW_DrawSquareD0R
-	void drawSquareD0C(direction dir, int16 posX, int16 posY); // @ F0127_DUNGEONVIEW_DrawSquareD0C
-
-
-	void applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors
-
-	bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF
+	void f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally
+	void f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap
+	void f100_drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap
+	void f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency
+	void f116_drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L
+	void f117_drawSquareD3R(direction dir, int16 posX, int16 posY); // @ F0117_DUNGEONVIEW_DrawSquareD3R
+	void f118_drawSquareD3C(direction dir, int16 posX, int16 posY); // @ F0118_DUNGEONVIEW_DrawSquareD3C_CPSF
+	void f119_drawSquareD2L(direction dir, int16 posX, int16 posY); // @ F0119_DUNGEONVIEW_DrawSquareD2L
+	void f120_drawSquareD2R(direction dir, int16 posX, int16 posY); // @ F0120_DUNGEONVIEW_DrawSquareD2R_CPSF
+	void f121_drawSquareD2C(direction dir, int16 posX, int16 posY); // @ F0121_DUNGEONVIEW_DrawSquareD2C
+	void f122_drawSquareD1L(direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1L
+	void f123_drawSquareD1R(direction dir, int16 posX, int16 posY); // @ F0123_DUNGEONVIEW_DrawSquareD1R
+	void f124_drawSquareD1C(direction dir, int16 posX, int16 posY); // @ F0124_DUNGEONVIEW_DrawSquareD1C
+	void f125_drawSquareD0L(direction dir, int16 posX, int16 posY); // @ F0125_DUNGEONVIEW_DrawSquareD0L
+	void f126_drawSquareD0R(direction dir, int16 posX, int16 posY); // @ F0126_DUNGEONVIEW_DrawSquareD0R
+	void f127_drawSquareD0C(direction dir, int16 posX, int16 posY); // @ F0127_DUNGEONVIEW_DrawSquareD0C
+
+
+	void f93_applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors
+
+	bool f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF
 
 	uint16 *_g639_derivedBitmapByteCount; // @ G0639_pui_DerivedBitmapByteCount
 	byte **_g638_derivedBitmaps; // @ G0638_pui_DerivedBitmapBlockIndices
@@ -527,14 +527,14 @@ public:
 	explicit DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
 
-	void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet
-	void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet
+	void f95_loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet
+	void f94_loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet
 
-	void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap
+	void f466_loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap
 	void setUpScreens(uint16 width, uint16 height);
-	void loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader, F0460_START_InitializeGraphicData
-	void initializeGraphicData(); // @ F0460_START_InitializeGraphicData
-	void loadCurrentMapGraphics(); // @ F0096_DUNGEONVIEW_LoadCurrentMapGraphics_CPSDF
+	void f479_loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader	
+	void f460_initializeGraphicData(); // @ F0460_START_InitializeGraphicData
+	void f96_loadCurrentMapGraphics(); // @ F0096_DUNGEONVIEW_LoadCurrentMapGraphics_CPSDF
 	void loadPalette(uint16 *palette);
 	void f461_allocateFlippedWallBitmaps(); // @ F0461_START_AllocateFlippedWallBitmaps
 
@@ -547,40 +547,40 @@ public:
 	void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height);
 
 
-	void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
-					  byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency);
+	void f132_blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
+					  byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency); // @ F0132_VIDEO_Blit
 
-	void blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
+	void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
 									   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
 									   int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
-	void blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight,
+	void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight,
 										 byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
 
-	void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally
+	void f103_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
-	byte *getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap
+	byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap
 
 	void f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color); // @ F0134_VIDEO_FillBitmap
 	void clearScreen(Color color);
-	void clearScreenBox(Color color, Box &box); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox
+	void D24_clearScreenBox(Color color, Box &box); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox
 	void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 pixelWidth, int16 height);
-	void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
+	void f128_drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
 	void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport
 
-	byte* getBitmap(uint16 index);
+	byte* f489_getBitmap(uint16 index); // @ F0489_MEMORY_GetNativeBitmapOrGraphic
 	Common::MemoryReadStream getCompressedData(uint16 index);
 	uint32 getCompressedDataSize(uint16 index);
-	void drawField(FieldAspect *fieldAspect, Box &box); // @ F0113_DUNGEONVIEW_DrawField
+	void f113_drawField(FieldAspect *fieldAspect, Box &box); // @ F0113_DUNGEONVIEW_DrawField
 
-	int16 getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount
-	int16 getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION
-	void cthulhu(Thing thingParam, direction directionParam,
+	int16 f459_getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount
+	int16 M78_getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION
+	void f115_cthulhu(Thing thingParam, direction directionParam,
 				 int16 mapXpos, int16 mapYpos, int16 viewSquareIndex,
 				 uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
-	uint16 getNormalizedByteWidthM77(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH
-	uint16 getVerticalOffsetM23(uint16 val); // @ M23_VERTICAL_OFFSET
-	uint16 getHorizontalOffsetM22(uint16 val); // @ M22_HORIZONTAL_OFFSET
+	uint16 M77_getNormalizedByteWidth(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH
+	uint16 M23_getVerticalOffsetM23(uint16 val); // @ M23_VERTICAL_OFFSET
+	uint16 M22_getHorizontalOffsetM22(uint16 val); // @ M22_HORIZONTAL_OFFSET
 
 	int16 _g289_championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
 	int16 _g267_currMapAlcoveOrnIndices[k3_AlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
@@ -602,8 +602,8 @@ public:
 	bool _g578_useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates
 	bool _g77_doNotDrawFluxcagesDuringEndgame; // @ G0077_B_DoNotDrawFluxcagesDuringEndgame
 
-	bool isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
-	byte *getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap
+	bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
+	byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap
 
 
 
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 2cc2646..3fa8c4a 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -42,7 +42,7 @@ GroupMan::~GroupMan() {
 	delete[] _g375_activeGroups;
 }
 
-void GroupMan::initActiveGroups() {
+void GroupMan::f196_initActiveGroups() {
 	if (_vm->_g298_newGame)
 		_g376_maxActiveGroupCount = 60;
 	if (_g375_activeGroups)
@@ -52,7 +52,7 @@ void GroupMan::initActiveGroups() {
 		_g375_activeGroups[i]._groupThingIndex = -1;
 }
 
-uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) {
+uint16 GroupMan::f145_getGroupCells(Group* group, int16 mapIndex) {
 	byte cells;
 	cells = group->_cells;
 	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex)
@@ -62,39 +62,39 @@ uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) {
 
 byte gGroupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_GroupDirections
 
-uint16 GroupMan::getGroupDirections(Group* group, int16 mapIndex) {
+uint16 GroupMan::f147_getGroupDirections(Group* group, int16 mapIndex) {
 	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex)
 		return _g375_activeGroups[group->getActiveGroupIndex()]._directions;
 
 	return gGroupDirections[group->getDir()];
 }
 
-int16 GroupMan::getCreatureOrdinalInCell(Group* group, uint16 cell) {
+int16 GroupMan::f176_getCreatureOrdinalInCell(Group* group, uint16 cell) {
 	uint16 currMapIndex = _vm->_dungeonMan->_g272_currMapIndex;
-	byte groupCells = getGroupCells(group, currMapIndex);
+	byte groupCells = f145_getGroupCells(group, currMapIndex);
 	if (groupCells == k255_CreatureTypeSingleCenteredCreature)
-		return _vm->indexToOrdinal(0);
+		return _vm->M0_indexToOrdinal(0);
 
 	byte creatureIndex = group->getCount();
 	if (getFlag(g243_CreatureInfo[group->_type]._attributes, k0x0003_MaskCreatureInfo_size) == k1_MaskCreatureSizeHalf) {
-		if ((getGroupDirections(group, currMapIndex) & 1) == (cell & 1))
+		if ((f147_getGroupDirections(group, currMapIndex) & 1) == (cell & 1))
 			cell = returnPrevVal(cell);
 
 		do {
-			byte creatureCell = getCreatureValue(groupCells, creatureIndex);
+			byte creatureCell = M50_getCreatureValue(groupCells, creatureIndex);
 			if (creatureCell == cell || creatureCell == returnNextVal(cell))
-				return _vm->indexToOrdinal(creatureIndex);
+				return _vm->M0_indexToOrdinal(creatureIndex);
 		} while (creatureIndex--);
 	} else {
 		do {
-			if (getCreatureValue(groupCells, creatureIndex) == cell)
-				return _vm->indexToOrdinal(creatureIndex);
+			if (M50_getCreatureValue(groupCells, creatureIndex) == cell)
+				return _vm->M0_indexToOrdinal(creatureIndex);
 		} while (creatureIndex--);
 	}
 	return 0;
 }
 
-uint16 GroupMan::getCreatureValue(uint16 groupVal, uint16 creatureIndex) {
+uint16 GroupMan::M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex) {
 	return (groupVal >> (creatureIndex << 1)) & 0x3;
 }
 }
diff --git a/engines/dm/group.h b/engines/dm/group.h
index af7a4eb..76cb8b2 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -137,11 +137,11 @@ public:
 	ActiveGroup *_g375_activeGroups; // @ G0375_ps_ActiveGroups
 	GroupMan(DMEngine *vm);
 	~GroupMan();
-	void initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups
-	uint16 getGroupCells(Group *group, int16 mapIndex); // @ F0145_DUNGEON_GetGroupCells
-	uint16 getGroupDirections(Group *group, int16 mapIndex); // @ F0147_DUNGEON_GetGroupDirections
-	int16 getCreatureOrdinalInCell(Group *group, uint16 cell); // @ F0176_GROUP_GetCreatureOrdinalInCell
-	uint16 getCreatureValue(uint16 groupVal, uint16 creatureIndex); // @ M50_CREATURE_VALUE
+	void f196_initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups
+	uint16 f145_getGroupCells(Group *group, int16 mapIndex); // @ F0145_DUNGEON_GetGroupCells
+	uint16 f147_getGroupDirections(Group *group, int16 mapIndex); // @ F0147_DUNGEON_GetGroupDirections
+	int16 f176_getCreatureOrdinalInCell(Group *group, uint16 cell); // @ F0176_GROUP_GetCreatureOrdinalInCell
+	uint16 M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex); // @ M50_CREATURE_VALUE
 };
 
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 8118356..1d1eb5e 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -50,36 +50,36 @@ InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
 	_g426_openChest = Thing::_none;
 }
 
-void InventoryMan::toggleInventory(ChampionIndex championIndex) {
+void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	ChampionMan &cm = *_vm->_championMan;
 	EventManager &em = *_vm->_eventMan;
 	DisplayMan &dm = *_vm->_displayMan;
 
-	if ((championIndex != k4_ChampionCloseInventory) && !cm._champions[championIndex]._currHealth)
+	if ((championIndex != k4_ChampionCloseInventory) && !cm._gK71_champions[championIndex]._currHealth)
 		return;
 	if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth)
 		return;
 	_vm->_g321_stopWaitingForPlayerInput = true;
 	int16 invChampOrdinal = _g432_inventoryChampionOrdinal; // copy, as the original will be edited
-	if (_vm->indexToOrdinal(championIndex) == invChampOrdinal) {
+	if (_vm->M0_indexToOrdinal(championIndex) == invChampOrdinal) {
 		championIndex = k4_ChampionCloseInventory;
 	}
 
 	Champion *champion;
 	if (invChampOrdinal) {
-		_g432_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
-		closeChest();
-		champion = &cm._champions[_vm->ordinalToIndex(invChampOrdinal)];
+		_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+		f334_closeChest();
+		champion = &cm._gK71_champions[_vm->M1_ordinalToIndex(invChampOrdinal)];
 		if (champion->_currHealth && !cm._g299_candidateChampionOrdinal) {
 			champion->setAttributeFlag(k0x1000_ChampionAttributeStatusBox, true);
-			cm.drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
+			cm.f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal));
 		}
 		if (cm._g300_partyIsSleeping) {
 			return;
 		}
 		if (championIndex == k4_ChampionCloseInventory) {
 			em._g326_refreshMousePointerInMainLoop = true;
-			_vm->_menuMan->drawMovementArrows();
+			_vm->_menuMan->f395_drawMovementArrows();
 			em._g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
 			warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput");
 			warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
@@ -88,22 +88,22 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	}
 
 	dm._g578_useByteBoxCoordinates = false;
-	_g432_inventoryChampionOrdinal = _vm->indexToOrdinal(championIndex);
+	_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(championIndex);
 	if (!invChampOrdinal) {
 		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 	}
 
-	champion = &cm._champions[championIndex];
-	dm.loadIntoBitmap(k17_InventoryGraphicIndice, dm._g296_bitmapViewport);
+	champion = &cm._gK71_champions[championIndex];
+	dm.f466_loadIntoBitmap(k17_InventoryGraphicIndice, dm._g296_bitmapViewport);
 	if (cm._g299_candidateChampionOrdinal) {
 		dm.f135_fillBoxBitmap(dm._g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport * 2, k136_heightViewport);
 	}
-	_vm->_textMan->printToViewport(5, 116, k13_ColorLightestGray, "HEALTH");
-	_vm->_textMan->printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
-	_vm->_textMan->printToViewport(5, 132, k13_ColorLightestGray, "MANA");
+	_vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "HEALTH");
+	_vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
+	_vm->_textMan->f52_printToViewport(5, 132, k13_ColorLightestGray, "MANA");
 
 	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
-		_vm->_championMan->drawSlot(championIndex, (ChampionSlot)slotIndex);
+		_vm->_championMan->f291_drawSlot(championIndex, (ChampionSlot)slotIndex);
 	}
 
 	champion->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
@@ -113,14 +113,14 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	champion->setAttributeFlag(k0x0100_ChampionAttributeStatistics, true);
 	champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
 
-	cm.drawChampionState(championIndex);
+	cm.f292_drawChampionState(championIndex);
 	em._g598_mousePointerBitmapUpdated = true;
 	em._g442_secondaryMouseInput = g449_SecondaryMouseInput_ChampionInventory;
 	warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput");
 	warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
 }
 
-void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) {
+void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 	dispMan._g578_useByteBoxCoordinates = false;
 	Box box;
@@ -128,21 +128,21 @@ void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) {
 	box._y2 = 28 + 1;
 	box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7;
 	box._x2 = box._x1 + 31 + 1;
-	dispMan.blitToBitmap(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0,
+	dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, 32, 0, 0,
 						 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
 }
 
-void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
+void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
 	Box box;
 	box._x1 = x;
 	box._x2 = box._x1 + pixelWidth + 1;
 	box._y1 = y;
 	box._y2 = box._y1 + 6 + 1;
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_vm->_displayMan->clearScreenBox(color, box);
+	_vm->_displayMan->D24_clearScreenBox(color, box);
 }
 
-void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
+void InventoryMan::f344_drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
 	if (amount < -512) {
 		color = k8_ColorRed;
 	} else if (amount < 0) {
@@ -154,45 +154,45 @@ void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
 		pixelWidth = 3071;
 	}
 	pixelWidth /= 32;
-	drawPanelHorizontalBar(115, y + 2, pixelWidth, k0_ColorBlack);
-	drawPanelHorizontalBar(113, y, pixelWidth, color);
+	f343_drawPanelHorizontalBar(115, y + 2, pixelWidth, k0_ColorBlack);
+	f343_drawPanelHorizontalBar(113, y, pixelWidth, color);
 }
 
-void InventoryMan::drawPanelFoodWaterPoisoned() {
-	Champion &champ = _vm->_championMan->_champions[_g432_inventoryChampionOrdinal];
-	closeChest();
+void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
+	Champion &champ = _vm->_championMan->_gK71_champions[_g432_inventoryChampionOrdinal];
+	f334_closeChest();
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.blitToBitmap(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0,
+	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), 144, 0, 0,
 						 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g32_BoxPanel, k8_ColorRed);
-	dispMan.blitToBitmap(dispMan.getBitmap(k30_FoodLabelIndice), 48, 0, 0,
+	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k30_FoodLabelIndice), 48, 0, 0,
 						 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g35_BoxFood, k12_ColorDarkestGray);
-	dispMan.blitToBitmap(dispMan.getBitmap(k31_WaterLabelIndice), 48, 0, 0,
+	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k31_WaterLabelIndice), 48, 0, 0,
 						 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g36_BoxWater, k12_ColorDarkestGray);
 	if (champ._poisonEventCount) {
-		dispMan.blitToBitmap(dispMan.getBitmap(k32_PoisionedLabelIndice), 96, 0, 0,
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k32_PoisionedLabelIndice), 96, 0, 0,
 							 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g37_BoxPoisoned, k12_ColorDarkestGray);
 	}
-	drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown);
-	drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue);
+	f344_drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown);
+	f344_drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue);
 }
 
-void InventoryMan::drawPanelResurrectReincarnate() {
+void InventoryMan::f346_drawPanelResurrectReincarnate() {
 	_g424_panelContent = k5_PanelContentResurrectReincarnate;
-	_vm->_displayMan->blitToBitmap(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0,
+	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0,
 								   _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k6_ColorDarkGreen);
 }
 
-void InventoryMan::drawPanel() {
+void InventoryMan::f347_drawPanel() {
 	warning("possible reintroduction of BUG0_48");
-	closeChest(); // possibility of BUG0_48
+	f334_closeChest(); // possibility of BUG0_48
 
 	ChampionMan &cm = *_vm->_championMan;
 	if (cm._g299_candidateChampionOrdinal) {
-		drawPanelResurrectReincarnate();
+		f346_drawPanelResurrectReincarnate();
 		return;
 	}
 
-	Thing thing = cm._champions[_vm->ordinalToIndex(_g432_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand);
+	Thing thing = cm._gK71_champions[_vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand);
 
 	_g424_panelContent = k0_PanelContentFoodWaterPoisoned;
 	switch (thing.getType()) {
@@ -207,19 +207,19 @@ void InventoryMan::drawPanel() {
 		break;
 	}
 	if (thing == Thing::_none) {
-		drawPanelFoodWaterPoisoned();
+		f345_drawPanelFoodWaterPoisoned();
 	} else {
-		drawPanelObject(thing, false);
+		f342_drawPanelObject(thing, false);
 	}
 }
 
-void InventoryMan::closeChest() {
+void InventoryMan::f334_closeChest() {
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 
 	bool processFirstChestSlot = true;
 	if (_g426_openChest == Thing::_none)
 		return;
-	Container *container = (Container*)dunMan.getThingData(_g426_openChest);
+	Container *container = (Container*)dunMan.f156_getThingData(_g426_openChest);
 	_g426_openChest = Thing::_none;
 	container->getSlot() = Thing::_endOfList;
 	Thing prevThing;
@@ -230,17 +230,17 @@ void InventoryMan::closeChest() {
 
 			if (processFirstChestSlot) {
 				processFirstChestSlot = false;
-				*dunMan.getThingData(thing) = Thing::_endOfList.toUint16();
+				*dunMan.f156_getThingData(thing) = Thing::_endOfList.toUint16();
 				container->getSlot() = prevThing = thing;
 			} else {
-				dunMan.linkThingToList(thing, prevThing, kM1_MapXNotOnASquare, 0);
+				dunMan.f163_linkThingToList(thing, prevThing, kM1_MapXNotOnASquare, 0);
 				prevThing = thing;
 			}
 		}
 	}
 }
 
-void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) {
+void InventoryMan::f340_drawPanelScrollTextLine(int16 yPos, char* text) {
 	warning("CHANGE5_03_IMPROVEMENT");
 	for (char* iter = text; *iter != '\0'; ++iter) {
 		if ((*iter >= 'A') && (*iter <= 'Z')) {
@@ -249,20 +249,20 @@ void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) {
 			*iter -= 96;
 		}
 	}
-	_vm->_textMan->printToViewport(162 - (6 * strlen(text) / 2), yPos, k0_ColorBlack, text, k15_ColorWhite);
+	_vm->_textMan->f52_printToViewport(162 - (6 * strlen(text) / 2), yPos, k0_ColorBlack, text, k15_ColorWhite);
 }
 
-void InventoryMan::drawPanelScroll(Scroll* scroll) {
+void InventoryMan::f341_drawPanelScroll(Scroll* scroll) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 
 	char stringFirstLine[300];
-	_vm->_dungeonMan->decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
+	_vm->_dungeonMan->f168_decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
 	char *charRed = stringFirstLine;
 	while (*charRed && (*charRed != '\n')) {
 		charRed++;
 	}
 	*charRed = '\0';
-	dispMan.blitToBitmap(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k8_ColorRed);
+	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k8_ColorRed);
 	int16 lineCount = 1;
 	charRed++;
 	char *charGreen = charRed; // first char of the second line
@@ -283,7 +283,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) {
 		lineCount--;
 	}
 	int16 yPos = 92 - (7 * lineCount) / 2; // center the text vertically
-	drawPanelScrollTextLine(yPos, stringFirstLine);
+	f340_drawPanelScrollTextLine(yPos, stringFirstLine);
 	charGreen = charRed;
 	while (*charGreen) {
 		yPos += 7;
@@ -294,12 +294,12 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) {
 			charRed[1] = '\0';
 		}
 		*charRed++ = '\0';
-		drawPanelScrollTextLine(yPos, charGreen);
+		f340_drawPanelScrollTextLine(yPos, charGreen);
 		charGreen = charRed;
 	}
 }
 
-void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool isPressingEye) {
+void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bool isPressingEye) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 	ObjectMan &objMan = *_vm->_objectMan;
 
@@ -308,13 +308,13 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 
 	warning("CHANGE8_09_FIX");
 	if (_g426_openChest != Thing::_none)
-		closeChest(); // CHANGE8_09_FIX
+		f334_closeChest(); // CHANGE8_09_FIX
 
 	_g426_openChest = thingToOpen;
 	if (!isPressingEye) {
-		objMan.drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen);
+		objMan.f38_drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen);
 	}
-	dispMan.blitToBitmap(dispMan.getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g32_BoxPanel, k8_ColorRed);
+	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g32_BoxPanel, k8_ColorRed);
 
 	int16 chestSlotIndex = 0;
 	Thing thing = chest->getSlot();
@@ -324,27 +324,27 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 		if (++thingCount > 8)
 			break; // CHANGE8_08_FIX, make sure that no more than the first 8 objects in a chest are drawn
 
-		objMan.drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, objMan.getIconIndex(thing));
+		objMan.f38_drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, objMan.f33_getIconIndex(thing));
 		_g425_chestSlots[chestSlotIndex++] = thing;
-		thing = _vm->_dungeonMan->getNextThing(thing);
+		thing = _vm->_dungeonMan->f159_getNextThing(thing);
 	}
 	while (chestSlotIndex < 8) {
-		objMan.drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, kM1_IconIndiceNone);
+		objMan.f38_drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, kM1_IconIndiceNone);
 		_g425_chestSlots[chestSlotIndex++] = Thing::_none;
 	}
 }
 
-void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos) {
+void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos) {
 	static byte iconBitmap[16 * 16];
 	Box box;
 	box._x2 = (box._x1 = xPos) + 15 + 1;
 	box._y2 = (box._y1 = yPos) + 15 + 1;
-	_vm->_objectMan->extractIconFromBitmap(iconIndex, iconBitmap);
-	_vm->_displayMan->blitToBitmap(iconBitmap, 16, 0, 0, _vm->_displayMan->_g296_bitmapViewport,
+	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, iconBitmap);
+	_vm->_displayMan->f132_blitToBitmap(iconBitmap, 16, 0, 0, _vm->_displayMan->_g296_bitmapViewport,
 								   k112_byteWidthViewport * 2, box, k255_ColorNoTransparency);
 }
 
-void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) {
+void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) {
 	uint16 identicalBitCount = 0;
 	int16 attribMask = 1;
 	for (uint16 stringIndex = 0; stringIndex < 16; stringIndex++, attribMask <<= 1) {
@@ -375,7 +375,7 @@ void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 a
 	strcat(destString, suffixString);
 }
 
-void InventoryMan::drawPanelObjectDescriptionString(char* descString) {
+void InventoryMan::f335_drawPanelObjectDescriptionString(char* descString) {
 	if (descString[0] == '\f') { // form feed
 		descString++;
 		_g421_objDescTextXpos = 108;
@@ -399,7 +399,7 @@ void InventoryMan::drawPanelObjectDescriptionString(char* descString) {
 				severalLines = true;
 			}
 
-			_vm->_textMan->printToViewport(_g421_objDescTextXpos, _g422_objDescTextYpos, k13_ColorLightestGray, stringLine);
+			_vm->_textMan->f52_printToViewport(_g421_objDescTextXpos, _g422_objDescTextYpos, k13_ColorLightestGray, stringLine);
 			_g422_objDescTextYpos += 7;
 			if (severalLines) {
 				severalLines = false;
@@ -413,9 +413,9 @@ void InventoryMan::drawPanelObjectDescriptionString(char* descString) {
 
 Box g33_BoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye 
 
-void InventoryMan::drawPanelArrowOrEye(bool pressingEye) {
+void InventoryMan::f339_drawPanelArrowOrEye(bool pressingEye) {
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.blitToBitmap(dispMan.getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice),
+	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice),
 						 16, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g33_BoxArrowOrEye, k8_ColorRed);
 }
 
@@ -427,7 +427,7 @@ Box g34_BoxObjectDescCircle = Box(105, 136, 53, 79); // @ G0034_s_Graphic562_Box
 #define k0x0004_DescriptionMaskBroken 0x0004 // @ MASK0x0004_DESCRIPTION_BROKEN    
 #define k0x0008_DescriptionMaskCursed 0x0008 // @ MASK0x0008_DESCRIPTION_CURSED    
 
-void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
+void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 	ObjectMan &objMan = *_vm->_objectMan;
 	DisplayMan &dispMan = *_vm->_displayMan;
@@ -436,34 +436,34 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 
 	if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) {
 		warning("BUG0_48 The contents of a chest are reorganized when an object with a statistic modifier is placed or removed on a champion");
-		closeChest();
+		f334_closeChest();
 	}
 
-	uint16 *rawThingPtr = dunMan.getThingData(thingToDraw);
-	drawPanelObjectDescriptionString("\f"); // form feed
+	uint16 *rawThingPtr = dunMan.f156_getThingData(thingToDraw);
+	f335_drawPanelObjectDescriptionString("\f"); // form feed
 	ThingType thingType = thingToDraw.getType();
 	if (thingType == k7_ScrollThingType) {
-		drawPanelScroll((Scroll*)rawThingPtr);
+		f341_drawPanelScroll((Scroll*)rawThingPtr);
 	} else if (thingType == k9_ContainerThingType) {
-		openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye);
+		f333_openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye);
 	} else {
-		IconIndice iconIndex = objMan.getIconIndex(thingToDraw);
-		dispMan.blitToBitmap(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0,
+		IconIndice iconIndex = objMan.f33_getIconIndex(thingToDraw);
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), 144, 0, 0,
 							 dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k8_ColorRed);
-		dispMan.blitToBitmap(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0,
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0,
 							 dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g34_BoxObjectDescCircle, k12_ColorDarkestGray);
 
 		char *descString = nullptr;
 		char str[40];
 		if (iconIndex == k147_IconIndiceJunkChampionBones) {
-			strcpy(str, champMan._champions[((Junk*)rawThingPtr)->getChargeCount()]._name);  // TODO: localization
+			strcpy(str, champMan._gK71_champions[((Junk*)rawThingPtr)->getChargeCount()]._name);  // TODO: localization
 			strcat(str, " "); // TODO: localization
 			strcat(str, objMan._g352_objectNames[iconIndex]);  // TODO: localization
 
 			descString = str;
 		} else if ((thingType == k8_PotionThingType)
 				   && (iconIndex != k163_IconIndicePotionWaterFlask)
-				   && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_g432_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
+				   && (champMan.f303_getSkillLevel((ChampionIndex)_vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
 			str[0] = '_' + ((Potion*)rawThingPtr)->getPower() / 40;
 			str[1] = ' ';
 			str[2] = '\0';
@@ -473,8 +473,8 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			descString = objMan._g352_objectNames[iconIndex];
 		}
 
-		textMan.printToViewport(134, 68, k13_ColorLightestGray, descString);
-		drawIconToViewport(iconIndex, 111, 59);
+		textMan.f52_printToViewport(134, 68, k13_ColorLightestGray, descString);
+		f332_drawIconToViewport(iconIndex, 111, 59);
 
 		char *attribString[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"}; // TODO: localization
 
@@ -490,7 +490,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit)
 				&& (iconIndex <= k7_IconIndiceWeaponTorchLit)
 				&& (weapon->getChargeCount() == 0)) {
-				drawPanelObjectDescriptionString("(BURNT OUT)"); // TODO: localization
+				f335_drawPanelObjectDescriptionString("(BURNT OUT)"); // TODO: localization
 			}
 			break;
 		}
@@ -524,13 +524,13 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 					descString = "(FULL)"; // TODO: localization
 					break;
 				}
-				drawPanelObjectDescriptionString(descString);
+				f335_drawPanelObjectDescriptionString(descString);
 			} else if ((iconIndex >= k0_IconIndiceJunkCompassNorth) && (iconIndex <= k3_IconIndiceJunkCompassWest)) {
 				potentialAttribMask = 0;
 				strcpy(str, "PARTY FACING "); // TODO: localization
 				static char* directionName[4] = {"NORTH", "EAST", "SOUTH", "WEST"}; // G0430_apc_DirectionNames // TODO: localization
 				strcat(str, directionName[iconIndex]);
-				drawPanelObjectDescriptionString(str);
+				f335_drawPanelObjectDescriptionString(str);
 			} else {
 				potentialAttribMask = k0x0001_DescriptionMaskConsumable;
 				actualAttribMask = g237_ObjectInfo[k127_ObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots();
@@ -540,25 +540,25 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		} // end of switch 
 
 		if (potentialAttribMask) {
-			buildObjectAttributeString(potentialAttribMask, actualAttribMask, attribString, str, "(", ")");
-			drawPanelObjectDescriptionString(str);
+			f336_buildObjectAttributeString(potentialAttribMask, actualAttribMask, attribString, str, "(", ")");
+			f335_drawPanelObjectDescriptionString(str);
 		}
 
 		strcpy(str, "WEIGHS "); // TODO: localization
 
-		uint16 weight = dunMan.getObjectWeight(thingToDraw);
-		strcat(str, champMan.getStringFromInteger(weight / 10, false, 3).c_str());
+		uint16 weight = dunMan.f140_getObjectWeight(thingToDraw);
+		strcat(str, champMan.f288_getStringFromInteger(weight / 10, false, 3).c_str());
 
 		strcat(str, "."); // TODO: localization
 
 		weight -= (weight / 10) * 10;
-		strcat(str, champMan.getStringFromInteger(weight, false, 1).c_str()); 
+		strcat(str, champMan.f288_getStringFromInteger(weight, false, 1).c_str()); 
 
 		strcat(str, " KG."); // TODO: localization
 
-		drawPanelObjectDescriptionString(str);
+		f335_drawPanelObjectDescriptionString(str);
 	}
-	drawPanelArrowOrEye(pressingEye);
+	f339_drawPanelArrowOrEye(pressingEye);
 
 }
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 82865f5..df429af 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -61,23 +61,23 @@ public:
 	int16 _g421_objDescTextXpos; // @ G0421_i_ObjectDescriptionTextX
 	int16 _g422_objDescTextYpos; // @ G0422_i_ObjectDescriptionTextY
 
-	void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE
-	void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait
-	void drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar
-	void drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color); // @ F0344_INVENTORY_DrawPanel_FoodOrWaterBar 
-	void drawPanelFoodWaterPoisoned(); // @ F0345_INVENTORY_DrawPanel_FoodWaterPoisoned
-	void drawPanelResurrectReincarnate(); // @ F0346_INVENTORY_DrawPanel_ResurrectReincarnate
-	void drawPanel(); // @ F0347_INVENTORY_DrawPanel
-	void closeChest(); // @ F0334_INVENTORY_CloseChest
-	void drawPanelScrollTextLine(int16 yPos, char *text); // @ F0340_INVENTORY_DrawPanel_ScrollTextLine
-	void drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll
-	void openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye); // @ F0333_INVENTORY_OpenAndDrawChest
-	void drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos); // @ F0332_INVENTORY_DrawIconToViewport
-	void buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char ** attribStrings,
+	void f355_toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE
+	void f354_drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait
+	void f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar
+	void f344_drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color); // @ F0344_INVENTORY_DrawPanel_FoodOrWaterBar 
+	void f345_drawPanelFoodWaterPoisoned(); // @ F0345_INVENTORY_DrawPanel_FoodWaterPoisoned
+	void f346_drawPanelResurrectReincarnate(); // @ F0346_INVENTORY_DrawPanel_ResurrectReincarnate
+	void f347_drawPanel(); // @ F0347_INVENTORY_DrawPanel
+	void f334_closeChest(); // @ F0334_INVENTORY_CloseChest
+	void f340_drawPanelScrollTextLine(int16 yPos, char *text); // @ F0340_INVENTORY_DrawPanel_ScrollTextLine
+	void f341_drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll
+	void f333_openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye); // @ F0333_INVENTORY_OpenAndDrawChest
+	void f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos); // @ F0332_INVENTORY_DrawIconToViewport
+	void f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char ** attribStrings,
 									char *destString, char *prefixString, char *suffixString); // @ F0336_INVENTORY_DrawPanel_BuildObjectAttributesString
-	void drawPanelObjectDescriptionString(char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString
-	void drawPanelArrowOrEye(bool pressingEye); // @ F0339_INVENTORY_DrawPanel_ArrowOrEye
-	void drawPanelObject(Thing thingToDraw, bool pressingEye); // @ F0342_INVENTORY_DrawPanel_Object
+	void f335_drawPanelObjectDescriptionString(char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString
+	void f339_drawPanelArrowOrEye(bool pressingEye); // @ F0339_INVENTORY_DrawPanel_ArrowOrEye
+	void f342_drawPanelObject(Thing thingToDraw, bool pressingEye); // @ F0342_INVENTORY_DrawPanel_Object
 
 };
 
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index a0cd569..81a914c 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -38,30 +38,30 @@ namespace DM {
 LoadsaveMan::LoadsaveMan(DMEngine *vm) : _vm(vm) {}
 
 
-LoadgameResponse LoadsaveMan::loadgame() {
+LoadgameResponse LoadsaveMan::f435_loadgame() {
 	bool newGame = _vm->_g298_newGame;
 	ChampionMan &cm = *_vm->_championMan;
 
 	if (newGame) {
 		_vm->_g524_restartGameAllowed = false;
 		cm._g305_partyChampionCount = 0;
-		cm._414_leaderHandObject = Thing::_none;
+		cm._g414_leaderHandObject = Thing::_none;
 		_vm->_g525_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536);
 	} else {
 		assert(false);
 		// MISSING CODE: load game
 	}
-	_vm->_dungeonMan->loadDungeonFile();
+	_vm->_dungeonMan->f434_loadDungeonFile();
 
 
 	if (newGame) {
-		_vm->_timeline->initTimeline();
-		_vm->_groupMan->initActiveGroups();
+		_vm->_timeline->f233_initTimeline();
+		_vm->_groupMan->f196_initActiveGroups();
 	} else {
 		assert(false);
 		// MISSING CODE: load game
 	}
-	cm._303_partyDead = false;
+	cm._g303_partyDead = false;
 	return k1_LoadgameSuccess;
 }
 
diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h
index 0ee7118..c45b111 100644
--- a/engines/dm/loadsave.h
+++ b/engines/dm/loadsave.h
@@ -42,7 +42,7 @@ class LoadsaveMan {
 public:
 	explicit LoadsaveMan(DMEngine *vm);
 
-	LoadgameResponse loadgame(); // @ F0435_STARTEND_LoadGame_CPSF
+	LoadgameResponse f435_loadgame(); // @ F0435_STARTEND_LoadGame_CPSF
 };
 
 }
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index a512a90..1d93895 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -58,30 +58,30 @@ MenuMan::~MenuMan() {
 	delete[] _gK72_bitmapSpellAreaLine;
 }
 
-void MenuMan::drawMovementArrows() {
+void MenuMan::f395_drawMovementArrows() {
 	DisplayMan &disp = *_vm->_displayMan;
-	byte *arrowsBitmap = disp.getBitmap(k13_MovementArrowsIndice);
+	byte *arrowsBitmap = disp.f489_getBitmap(k13_MovementArrowsIndice);
 	Box &dest = g2_BoxMovementArrows;
 	uint16 w = disp.getWidth(k13_MovementArrowsIndice);
 
-	disp.blitToBitmap(arrowsBitmap, w, 0, 0, disp._g348_bitmapScreen, k160_byteWidthScreen * 2, dest, k255_ColorNoTransparency);
+	disp.f132_blitToBitmap(arrowsBitmap, w, 0, 0, disp._g348_bitmapScreen, k160_byteWidthScreen * 2, dest, k255_ColorNoTransparency);
 }
-void MenuMan::clearActingChampion() {
+void MenuMan::f388_clearActingChampion() {
 	ChampionMan &cm = *_vm->_championMan;
 	if (cm._g506_actingChampionOrdinal) {
 		cm._g506_actingChampionOrdinal--;
-		cm._champions[cm._g506_actingChampionOrdinal].setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
-		cm.drawChampionState((ChampionIndex)cm._g506_actingChampionOrdinal);
-		cm._g506_actingChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
+		cm._gK71_champions[cm._g506_actingChampionOrdinal].setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
+		cm.f292_drawChampionState((ChampionIndex)cm._g506_actingChampionOrdinal);
+		cm._g506_actingChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
 		_g508_refreshActionArea = true;
 	}
 }
 
-void MenuMan::drawActionIcon(ChampionIndex championIndex) {
+void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
 	if (!_g509_actionAreaContainsIcons)
 		return;
 	DisplayMan &dm = *_vm->_displayMan;
-	Champion &champion = _vm->_championMan->_champions[championIndex];
+	Champion &champion = _vm->_championMan->_gK71_champions[championIndex];
 
 	Box box;
 	box._x1 = championIndex * 22 + 233;
@@ -90,7 +90,7 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) {
 	box._y2 = 120 + 1;
 	dm._g578_useByteBoxCoordinates = false;
 	if (!champion._currHealth) {
-		dm.clearScreenBox(k0_ColorBlack, box);
+		dm.D24_clearScreenBox(k0_ColorBlack, box);
 		return;
 	}
 	byte *bitmapIcon = dm._g74_tmpBitmap;
@@ -98,34 +98,34 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) {
 	IconIndice iconIndex;
 	if (thing == Thing::_none) {
 		iconIndex = k201_IconIndiceActionEmptyHand;
-	} else if (g237_ObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
-		iconIndex = _vm->_objectMan->getIconIndex(thing);
+	} else if (g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thing)]._actionSetIndex) {
+		iconIndex = _vm->_objectMan->f33_getIconIndex(thing);
 	} else {
 		dm.f134_fillBitmap(bitmapIcon, 16, 16, k4_ColorCyan);
 		goto T0386006;
 	}
-	_vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon);
-	dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, g498_PalChangesActionAreaObjectIcon);
+	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, bitmapIcon);
+	dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, g498_PalChangesActionAreaObjectIcon);
 T0386006:
-	dm.clearScreenBox(k4_ColorCyan, box);
+	dm.D24_clearScreenBox(k4_ColorCyan, box);
 	Box box2;
 	box2._x1 = box._x1 + 2;
 	box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that
 	box2._y1 = 95;
 	box2._y2 = 110 + 1;
-	dm.blitToBitmap(bitmapIcon, 16, 0, 0, dm._g348_bitmapScreen, k160_byteWidthScreen * 2, box2);
+	dm.f132_blitToBitmap(bitmapIcon, 16, 0, 0, dm._g348_bitmapScreen, k160_byteWidthScreen * 2, box2);
 	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) {
 		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 	}
 }
 
-void MenuMan::drawDisabledMenu() {
+void MenuMan::f456_drawDisabledMenu() {
 	if (!_vm->_championMan->_g300_partyIsSleeping) {
 		warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 			if (_vm->_inventoryMan->_g424_panelContent == k4_PanelContentChest) {
-				_vm->_inventoryMan->closeChest();
+				_vm->_inventoryMan->f334_closeChest();
 			}
 		} else {
 			warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
@@ -136,7 +136,7 @@ void MenuMan::drawDisabledMenu() {
 	}
 }
 
-void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
+void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
 	ChampionMan &champMan = *_vm->_championMan;
 
 	if (!champMan._g305_partyChampionCount)
@@ -145,24 +145,24 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
 	Champion *champ = nullptr;
 	if (champMan._g300_partyIsSleeping || champMan._g299_candidateChampionOrdinal) {
 		if (champMan._g506_actingChampionOrdinal) {
-			clearActingChampion();
+			f388_clearActingChampion();
 			return;
 		}
 		if (!champMan._g299_candidateChampionOrdinal)
 			return;
 	} else {
-		champ = champMan._champions;
+		champ = champMan._gK71_champions;
 		int16 champIndex = k0_ChampionFirst;
 
 		do {
 			if ((champIndex != champMan._g411_leaderIndex)
-				&& (_vm->indexToOrdinal(champIndex) != champMan._g506_actingChampionOrdinal)
+				&& (_vm->M0_indexToOrdinal(champIndex) != champMan._g506_actingChampionOrdinal)
 				&& (champ->_maximumDamageReceived)
 				&& (champ->_dir != champ->_directionMaximumDamageReceived)) {
 
 				champ->_dir = (direction)champ->_directionMaximumDamageReceived;
 				champ->setAttributeFlag(k0x0400_ChampionAttributeIcon, true);
-				champMan.drawChampionState((ChampionIndex)champIndex);
+				champMan.f292_drawChampionState((ChampionIndex)champIndex);
 			}
 			champ->_maximumDamageReceived = 0;
 			champ++;
@@ -177,12 +177,12 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
 				_g513_actionDamage = 0;
 			} else {
 				_g509_actionAreaContainsIcons = true;
-				drawActionArea();
+				f387_drawActionArea();
 			}
 		} else {
 			_g509_actionAreaContainsIcons = false;
 			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
-			champMan.drawChampionState((ChampionIndex)_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal));
+			champMan.f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal));
 			warning("MISSING CODE: F0387_MENUS_DrawActionArea");
 		}
 	}
@@ -191,29 +191,29 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
 #define k7_ChampionNameMaximumLength 7 // @ C007_CHAMPION_NAME_MAXIMUM_LENGTH
 #define k12_ActionNameMaximumLength 12 // @ C012_ACTION_NAME_MAXIMUM_LENGTH
 
-void MenuMan::drawActionArea() {
+void MenuMan::f387_drawActionArea() {
 	DisplayMan &dispMan = *_vm->_displayMan;
 	ChampionMan &champMan = *_vm->_championMan;
 	TextMan &textMan = *_vm->_textMan;
 
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 	dispMan._g578_useByteBoxCoordinates = false;
-	dispMan.clearScreenBox(k0_ColorBlack, g1_BoxActionArea);
+	dispMan.D24_clearScreenBox(k0_ColorBlack, g1_BoxActionArea);
 	if (_g509_actionAreaContainsIcons) {
 		for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._g305_partyChampionCount; ++champIndex)
-			drawActionIcon((ChampionIndex)champIndex);
+			f386_drawActionIcon((ChampionIndex)champIndex);
 	} else if (champMan._g506_actingChampionOrdinal) {
 		Box box = g499_BoxActionArea3ActionMenu;
 		if (_g713_actionList._actionIndices[2] == k255_ChampionActionNone)
 			box = g500_BoxActionArea2ActionMenu;
 		if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone)
 			box = g501_BoxActionArea1ActionMenu;
-		dispMan.blitToBitmap(dispMan.getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
-		textMan.printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name,
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
+		textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 235, 83, k0_ColorBlack, k4_ColorCyan, champMan._gK71_champions[_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name,
 												k7_ChampionNameMaximumLength, k200_heightScreen);
 		for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) {
-			textMan.printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
-													getActionName(_g713_actionList._actionIndices[actionListIndex]),
+			textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
+													f384_getActionName(_g713_actionList._actionIndices[actionListIndex]),
 													k12_ActionNameMaximumLength, k200_heightScreen);
 		}
 	}
@@ -231,24 +231,24 @@ const char *g490_ChampionActionNames[44] = { // @ G0490_ac_Graphic560_ActionName
 	"FLUXCAGE", "HEAL", "CALM", "LIGHT", "WINDOW", "SPIT",
 	"BRANDISH", "THROW", "FUSE"};
 
-const char* MenuMan::getActionName(ChampionAction actionIndex) {
+const char* MenuMan::f384_getActionName(ChampionAction actionIndex) {
 	return (actionIndex == k255_ChampionActionNone) ? "" : g490_ChampionActionNames[actionIndex];
 }
 
 
 Box g504_BoxSpellAreaControls = Box(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls 
 
-void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
+void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) {
 	ChampionMan &champMan = *_vm->_championMan;
 	DisplayMan &dispMan = *_vm->_displayMan;
 	TextMan &textMan = *_vm->_textMan;
 
-	Champion &champ = champMan._champions[champIndex];
+	Champion &champ = champMan._gK71_champions[champIndex];
 	int16 champCurrHealth[4];
 	for (uint16 i = 0; i < 4; ++i)
-		champCurrHealth[i] = champMan._champions[i]._currHealth;
+		champCurrHealth[i] = champMan._gK71_champions[i]._currHealth;
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-	dispMan.clearScreenBox(k0_ColorBlack, g504_BoxSpellAreaControls);
+	dispMan.D24_clearScreenBox(k0_ColorBlack, g504_BoxSpellAreaControls);
 	int16 champCount = champMan._g305_partyChampionCount;
 	switch (champIndex) {
 	case k0_ChampionFirst:
@@ -309,61 +309,61 @@ labelChamp3:
 #define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
 #define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
 
-void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
+void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 
-	Champion &champ = _vm->_championMan->_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
+	Champion &champ = _vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
 	if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) {
 		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 12, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency);
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 12, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency);
 		int16 x = 1;
 		byte c = 96 + (6 * champ._symbolStep);
 		char spellSymbolString[2] = {'\0', '\0'};
 		for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
 			spellSymbolString[0] = c++;
-			_vm->_textMan->printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 14, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
+			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 14, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
 		}
 	} else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) {
 		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 24, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency);
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 24, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency);
 		char spellSymbolString[2] = {'\0', '\0'};
 		int16 x = 8;
 		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
 			if ((spellSymbolString[0] = champ._symbols[symbolIndex]) == '\0')
 				break;
-			_vm->_textMan->printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 9, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
+			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 9, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
 		}
 	}
 }
 
-void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
+void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	ChampionMan &champMan = *_vm->_championMan;
 	DisplayMan &dispMan = *_vm->_displayMan;
 
 	if ((champIndex == champMan._g514_magicCasterChampionIndex)
-		|| ((champIndex != kM1_ChampionNone) && !champMan._champions[champIndex]._currHealth))
+		|| ((champIndex != kM1_ChampionNone) && !champMan._gK71_champions[champIndex]._currHealth))
 		return;
 	if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) {
 		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-		dispMan.blitToBitmap(dispMan.getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g0_BoxSpellArea);
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g0_BoxSpellArea);
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 	}
 	if (champIndex == kM1_ChampionNone) {
 		champMan._g514_magicCasterChampionIndex = kM1_ChampionNone;
 		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.clearScreenBox(k0_ColorBlack, g0_BoxSpellArea);
+		dispMan.D24_clearScreenBox(k0_ColorBlack, g0_BoxSpellArea);
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 		return;
 	}
 
 	champMan._g514_magicCasterChampionIndex = (ChampionIndex)champIndex;
-	buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
+	f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-	drawSpellAreaControls((ChampionIndex)champIndex);
-	dispMan.blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK75_BoxSpellAreaLine2);
-	buildSpellAreaLine(k3_SpellAreaChampionSymbols);
-	dispMan.blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK76_BoxSpellAreaLine3);
+	f393_drawSpellAreaControls((ChampionIndex)champIndex);
+	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK75_BoxSpellAreaLine2);
+	f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols);
+	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK76_BoxSpellAreaLine3);
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 }
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 30bf01c..ef5f86d 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -60,17 +60,17 @@ public:
 	ActionList _g713_actionList; // @ G0713_s_ActionList
 	byte *_gK72_bitmapSpellAreaLine; // @ K0072_puc_Bitmap_SpellAreaLine
 
-	void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
-	void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon
+	void f388_clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
+	void f386_drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon
 
-	void drawMovementArrows(); // @ F0395_MENUS_DrawMovementArrows
-	void drawDisabledMenu(); // @ F0456_START_DrawDisabledMenus
-	void refreshActionAreaAndSetChampDirMaxDamageReceived(); // @ F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived
-	void drawActionArea(); // @ F0387_MENUS_DrawActionArea
-	const char* getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName
-	void drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls
-	void buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine
-	void setMagicCasterAndDrawSpellArea(int16 champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea
+	void f395_drawMovementArrows(); // @ F0395_MENUS_DrawMovementArrows
+	void f456_drawDisabledMenu(); // @ F0456_START_DrawDisabledMenus
+	void f390_refreshActionAreaAndSetChampDirMaxDamageReceived(); // @ F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived
+	void f387_drawActionArea(); // @ F0387_MENUS_DrawActionArea
+	const char* f384_getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName
+	void f393_drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls
+	void f392_buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine
+	void f394_setMagicCasterAndDrawSpellArea(int16 champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea
 };
 
 }
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 5d37884..9fab510 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -37,21 +37,21 @@ namespace DM {
 
 MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {}
 
-bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam) {
+bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam) {
 	ChampionMan &champMan = *_vm->_championMan;
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 	ObjectMan &objMan = *_vm->_objectMan;
 
 
 	bool atLeastOneSensorWasTriggered = false;
-	Thing leaderHandObject = champMan._414_leaderHandObject;
+	Thing leaderHandObject = champMan._g414_leaderHandObject;
 	int16 sensorCountToProcessPerCell[4];
 	uint16 cell;
 	for (cell = k0_CellNorthWest; cell < k3_CellSouthWest; ++cell) {
 		sensorCountToProcessPerCell[cell] = 0;
 	}
 	Thing squareFirstThing;
-	Thing thingBeingProcessed = squareFirstThing = dunMan.getSquareFirstThing(mapX, mapY);
+	Thing thingBeingProcessed = squareFirstThing = dunMan.f161_getSquareFirstThing(mapX, mapY);
 	ThingType thingType;
 	while (thingBeingProcessed != Thing::_endOfList) {
 		thingType = thingBeingProcessed.getType();
@@ -60,7 +60,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 		} else if (thingType >= k4_GroupThingType) {
 			break;
 		}
-		thingBeingProcessed = dunMan.getNextThing(thingBeingProcessed);
+		thingBeingProcessed = dunMan.f159_getNextThing(thingBeingProcessed);
 	}
 	Thing lastProcessedThing = thingBeingProcessed = squareFirstThing;
 
@@ -69,7 +69,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 		if (thingType == k3_SensorThingType) {
 			cell = thingBeingProcessed.getCell();
 			sensorCountToProcessPerCell[cell]--;
-			Sensor *sensor = (Sensor*)dunMan.getThingData(thingBeingProcessed); // IF YOU CHECK ME, I'LL CALL THE COPS!
+			Sensor *sensor = (Sensor*)dunMan.f156_getThingData(thingBeingProcessed); // IF YOU CHECK ME, I'LL CALL THE COPS!
 			SensorType sensorType = sensor->getType();
 			if (sensorType == k0_SensorDisabled)
 				goto T0275058_ProceedToNextThing;
@@ -96,11 +96,11 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 					goto T0275058_ProceedToNextThing;
 			case k3_SensorWallOrnClickWithSpecObj:
 			case k4_SensorWallOrnClickWithSpecObjRemoved:
-				doNotTriggerSensor = ((sensorData == objMan.getObjectType(leaderHandObject)) == sensor->getRevertEffectA());
+				doNotTriggerSensor = ((sensorData == objMan.f32_getObjectType(leaderHandObject)) == sensor->getRevertEffectA());
 				if (!doNotTriggerSensor && (sensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) {
 					if (lastProcessedThing == thingBeingProcessed)
 						break;
-					((Sensor*)dunMan.getThingData(lastProcessedThing))->setNextThing(sensor->getNextThing());
+					((Sensor*)dunMan.f156_getThingData(lastProcessedThing))->setNextThing(sensor->getNextThing());
 					sensor->setNextThing(Thing::_none);
 					thingBeingProcessed = lastProcessedThing;
 				}
@@ -137,8 +137,8 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 			case k16_SensorWallObjExchanger: {
 				if (sensorCountToProcessPerCell[cell])
 					goto T0275058_ProceedToNextThing;
-				Thing thingOnSquare = dunMan.getSquareFirstThing(mapX, mapY);
-				if ((objMan.getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_none))
+				Thing thingOnSquare = dunMan.f161_getSquareFirstThing(mapX, mapY);
+				if ((objMan.f32_getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_none))
 					goto T0275058_ProceedToNextThing;
 				warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList");
 				warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand");
@@ -148,7 +148,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 				break;
 			}
 			case k127_SensorWallChampionPortrait:
-				champMan.addCandidateChampionToParty(sensorData);
+				champMan.f280_addCandidateChampionToParty(sensorData);
 				goto T0275058_ProceedToNextThing;
 			default:
 				goto T0275058_ProceedToNextThing;
@@ -169,7 +169,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 					(sensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) ||
 					 (sensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
 
-					*((Thing*)dunMan.getThingData(leaderHandObject)) = Thing::_none;
+					*((Thing*)dunMan.f156_getThingData(leaderHandObject)) = Thing::_none;
 					warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand");
 					leaderHandObject = Thing::_none;
 				} else {
@@ -186,7 +186,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 			break;
 T0275058_ProceedToNextThing:
 		lastProcessedThing = thingBeingProcessed;
-		thingBeingProcessed = dunMan.getNextThing(thingBeingProcessed);
+		thingBeingProcessed = dunMan.f159_getNextThing(thingBeingProcessed);
 	}
 	warning("MISSING CODE: F0271_SENSOR_ProcessRotationEffect");
 	return atLeastOneSensorWasTriggered;
diff --git a/engines/dm/movesens.h b/engines/dm/movesens.h
index b73f727..6a8a53a 100644
--- a/engines/dm/movesens.h
+++ b/engines/dm/movesens.h
@@ -37,7 +37,7 @@ class MovesensMan {
 	DMEngine *_vm;
 public:
 	explicit MovesensMan(DMEngine *vm);
-	bool sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam); // @ F0275_SENSOR_IsTriggeredByClickOnWall
+	bool f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam); // @ F0275_SENSOR_IsTriggeredByClickOnWall
 };
 
 }
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 2ce67ac..251401f 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -121,11 +121,11 @@ void ObjectMan::loadObjectNames() {
 	}
 }
 
-IconIndice ObjectMan::getObjectType(Thing thing) {
+IconIndice ObjectMan::f32_getObjectType(Thing thing) {
 	if (thing == Thing::_none)
 		return kM1_IconIndiceNone;
 
-	int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing);
+	int16 objectInfoIndex = _vm->_dungeonMan->f141_getObjectInfoIndex(thing);
 	if (objectInfoIndex != -1) {
 		objectInfoIndex = g237_ObjectInfo[objectInfoIndex]._type;
 	}
@@ -134,15 +134,15 @@ IconIndice ObjectMan::getObjectType(Thing thing) {
 
 byte g29_ChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType
 
-IconIndice ObjectMan::getIconIndex(Thing thing) {
-	IconIndice iconIndex = getObjectType(thing);
+IconIndice ObjectMan::f33_getIconIndex(Thing thing) {
+	IconIndice iconIndex = f32_getObjectType(thing);
 
 	if ((iconIndex != kM1_IconIndiceNone) &&
 		(((iconIndex < k32_IconIndiceWeaponDagger) && (iconIndex >= k0_IconIndiceJunkCompassNorth)) || // < instead of <= is no error
 		((iconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (iconIndex <= k163_IconIndicePotionWaterFlask)) ||
 		 (iconIndex == k195_IconIndicePotionEmptyFlask))
 		) {
-		uint16 *rawType = _vm->_dungeonMan->getThingData(thing);
+		uint16 *rawType = _vm->_dungeonMan->f156_getThingData(thing);
 		switch (iconIndex) {
 		case k0_IconIndiceJunkCompassNorth:
 			iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_g308_partyDir);
@@ -184,7 +184,7 @@ IconIndice ObjectMan::getIconIndex(Thing thing) {
 	return iconIndex;
 }
 
-void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
+void ObjectMan::f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 	int16 i;
 	for (i = 0; i < 7; ++i) {
 		if (g26_IconGraphicFirstIndex[i] > iconIndex)
@@ -192,14 +192,14 @@ void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 	}
 
 	--i;
-	byte *srcBitmap = _vm->_displayMan->getBitmap(k42_ObjectIcons_000_TO_031 + i);
+	byte *srcBitmap = _vm->_displayMan->f489_getBitmap(k42_ObjectIcons_000_TO_031 + i);
 	iconIndex -= g26_IconGraphicFirstIndex[i];
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
 	Box box(0, 0, 15, 15);
-	_vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, box, k255_ColorNoTransparency);
+	_vm->_displayMan->f132_blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, box, k255_ColorNoTransparency);
 }
 
-void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
+void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 	SlotBox *slotBox = &_g30_slotBoxes[slotBoxIndex];
 	slotBox->_iconIndex = iconIndex; // yes, this modifies the global array
 	if (slotBox->_iconIndex == kM1_IconIndiceNone) {
@@ -219,39 +219,39 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 		}
 	}
 	iconGraphicIndex--;
-	byte *iconsBitmap = _vm->_displayMan->getBitmap(iconGraphicIndex + k42_ObjectIcons_000_TO_031);
+	byte *iconsBitmap = _vm->_displayMan->f489_getBitmap(iconGraphicIndex + k42_ObjectIcons_000_TO_031);
 	iconIndex -= g26_IconGraphicFirstIndex[iconGraphicIndex];
 
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) {
-		_vm->_displayMan->blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
+		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
 									   _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, box, k255_ColorNoTransparency);
 
 	} else {
-		_vm->_displayMan->blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
+		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
 									   _vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
 	}
 }
 
 #define k14_ObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH
 
-void ObjectMan::drawLeaderObjectName(Thing thing) {
-	IconIndice iconIndex = getIconIndex(thing);
+void ObjectMan::f34_drawLeaderObjectName(Thing thing) {
+	IconIndice iconIndex = f33_getIconIndex(thing);
 	char *objName;
 	char objectNameBuffer[16];
 	if (iconIndex == k147_IconIndiceJunkChampionBones) {
-		Junk *junk = (Junk*)_vm->_dungeonMan->getThingData(thing);
-		strcpy(objectNameBuffer, _vm->_championMan->_champions[junk->getChargeCount()]._name);
+		Junk *junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing);
+		strcpy(objectNameBuffer, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name);
 		strcat(objectNameBuffer, _g352_objectNames[iconIndex]);
 		objName = objectNameBuffer;
 	} else {
 		objName = _g352_objectNames[iconIndex];
 	}
-	_vm->_textMan->printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, 233, 37,
+	_vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, 233, 37,
 										   k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength, k200_heightScreen);
 }
 
-IconIndice ObjectMan::getIconIndexInSlotBox(uint16 slotBoxIndex) {
+IconIndice ObjectMan::f39_getIconIndexInSlotBox(uint16 slotBoxIndex) {
 	return (IconIndice)_g30_slotBoxes[slotBoxIndex]._iconIndex;
 }
 }
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index e4ce2cf..b01957d 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -58,12 +58,12 @@ public:
 	char *_g352_objectNames[k199_ObjectNameCount]; // @ G0352_apc_ObjectNames
 	byte *_g412_objectIconForMousePointer; // @ G0412_puc_Bitmap_ObjectIconForMousePointer
 
-	IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType
-	IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
-	void extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // @ F0036_OBJECT_ExtractIconFromBitmap
-	void drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox
-	void drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName
-	IconIndice getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox
+	IconIndice f32_getObjectType(Thing thing); // @ F0032_OBJECT_GetType
+	IconIndice f33_getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
+	void f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // @ F0036_OBJECT_ExtractIconFromBitmap
+	void f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox
+	void f34_drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName
+	IconIndice f39_getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox
 
 
 };
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index ebda268..a97060e 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -35,7 +35,7 @@ TextMan::TextMan(DMEngine* vm) : _vm(vm) {}
 #define k5_LetterWidth 5
 #define k6_LetterHeight 6
 
-void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY,
+void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY,
 								Color textColor, Color bgColor, const char* text, uint16 destHeight) {
 	destX -= 1; // fixes missalignment, to be checked
 	destY -= 4; // fixes missalignment, to be checked
@@ -43,7 +43,7 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16
 	uint16 textLength = strlen(text);
 	uint16 nextX = destX;
 	uint16 nextY = destY;
-	byte *srcBitmap = _vm->_displayMan->getBitmap(k557_FontGraphicIndice);
+	byte *srcBitmap = _vm->_displayMan->f489_getBitmap(k557_FontGraphicIndice);
 
 	byte *tmp = _vm->_displayMan->_g74_tmpBitmap;
 	for (uint16 i = 0; i < (k5_LetterWidth + 1) * k6_LetterHeight * 128; ++i) {
@@ -61,7 +61,7 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16
 		uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
 
 		Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1);
-		_vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth,
+		_vm->_displayMan->f132_blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth,
 			box, k255_ColorNoTransparency);
 
 		nextX += k5_LetterWidth + 1;
@@ -69,19 +69,19 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16
 }
 
 void TextMan::f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text) {
-	printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight);
+	f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight);
 }
 
-void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) {
-	printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, posX, posY, textColor, bgColor, text, k200_heightScreen);
+void TextMan::f52_printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) {
+	f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, posX, posY, textColor, bgColor, text, k200_heightScreen);
 }
 
-void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor,
+void TextMan::f41_printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor,
 									  Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight) {
 	Common::String str = text;
 	for (int16 i = str.size(); i < requiredTextLength; ++i)
 		str += ' ';
-	printTextToBitmap(destBitmap, destPixelWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight);
+	f40_printTextToBitmap(destBitmap, destPixelWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight);
 }
 
 }
diff --git a/engines/dm/text.h b/engines/dm/text.h
index c71f196..adfc426 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -37,11 +37,11 @@ class TextMan {
 	DMEngine *_vm;
 public:
 	explicit TextMan(DMEngine *vm);
-	void printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY,
+	void f40_printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY,
 						   Color textColor, Color bgColor, const char *text, uint16 destHeight); // @ F0040_TEXT_Print
 	void f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text); // @ F0053_TEXT_PrintToLogicalScreen
-	void printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport
-	void printWithTrailingSpaces(byte *destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, Color bgColor,
+	void f52_printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport
+	void f41_printWithTrailingSpaces(byte *destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, Color bgColor,
 								 const char *text, int16 strLenght, int16 destHeight); // @ F0041_TEXT_PrintWithTrailingSpaces
 };
 
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 9803032..4b5cfd4 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -41,7 +41,7 @@ Timeline::~Timeline() {
 	delete[] _g371_timeline;
 }
 
-void Timeline::initTimeline() {
+void Timeline::f233_initTimeline() {
 	_g370_events = new TimelineEvent[_g369_eventMaxCount];
 	_g371_timeline = new uint16[_g369_eventMaxCount];
 	if (_vm->_g298_newGame) {
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 47d339e..c2e06bc 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -153,7 +153,7 @@ public:
 
 	Timeline(DMEngine *vm);
 	~Timeline();
-	void initTimeline(); // @ F0233_TIMELINE_Initialize
+	void f233_initTimeline(); // @ F0233_TIMELINE_Initialize
 };
 
 


Commit: ec0b26ce795c9f5d7ecb12a642f444183b52348e
    https://github.com/scummvm/scummvm/commit/ec0b26ce795c9f5d7ecb12a642f444183b52348e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Reorder blitting method parameters

Changed paths:
    engines/dm/champion.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/objectman.cpp
    engines/dm/text.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 7986650..8cac2c7 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -48,7 +48,7 @@ Color g46_ChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14};
 int16 g39_LightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100};
 
 uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
-	/* 30 for champion inventory, 8 for chest */
+						   /* 30 for champion inventory, 8 for chest */
 	0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
 	0xFFFF,   /* Action Hand      Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
 	0x0002,   /* Head             Head */
@@ -414,10 +414,10 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 			((Junk*)rawObjPtr)->setChargeCount(1);
 			_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2];
 			warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette");
-			iconIndex = (IconIndice) (iconIndex + 1);
+			iconIndex = (IconIndice)(iconIndex + 1);
 		} else if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
 			((Junk*)rawObjPtr)->setChargeCount(1);
-			iconIndex = (IconIndice) (iconIndex + 1);
+			iconIndex = (IconIndice)(iconIndex + 1);
 		}
 
 	}
@@ -461,8 +461,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 	dispMan._g578_useByteBoxCoordinates = true;
 	{ // limit destBox scope
 		Box &destBox = gBoxChampionPortrait;
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k26_ChampionPortraitsIndice), 256, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex),
-							 champ->_portrait, 32, destBox, k255_ColorNoTransparency);
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k26_ChampionPortraitsIndice), champ->_portrait, destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 256, 32, k255_ColorNoTransparency);
 	}
 
 	champ->_actionIndex = k255_ChampionActionNone;
@@ -751,8 +750,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 			if (_g407_party._shieldDefense > 0)
 				nativeBitmapIndices[AL_0_borderCount++] = k37_BorderPartyShieldIndice;
 			while (AL_0_borderCount--) {
-				dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0,
-									 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k10_ColorFlesh);
+				dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(nativeBitmapIndices[AL_0_borderCount]), dispMan._g348_bitmapScreen, box, 0, 0, 80, k160_byteWidthScreen * 2, k10_ColorFlesh);
 			}
 			if (isInventoryChamp) {
 				invMan.f354_drawStatusBoxPortrait(champIndex);
@@ -761,8 +759,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 				champAttributes |= (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand);
 			}
 		} else {
-			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k8_StatusBoxDeadChampion), 80, 0, 0,
-								 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
+			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k8_StatusBoxDeadChampion), dispMan._g348_bitmapScreen, box, 0, 0, 80, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
 			_vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, champ->_name);
 			menuMan.f386_drawActionIcon(champIndex);
 			goto T0292042_green;
@@ -804,8 +801,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 			} else {
 				AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			}
-			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0,
-								 dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, gBoxMouth, k12_ColorDarkestGray);
+			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport, gBoxMouth, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray);
 			AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			for (int16 AL_0_statisticIndex = k1_ChampionStatStrength; AL_0_statisticIndex <= k6_ChampionStatAntifire; AL_0_statisticIndex++) {
 				if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent)
@@ -814,8 +810,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 					break;
 				}
 			}
-			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0,
-								 dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, gBoxEye, k12_ColorDarkestGray);
+			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport, gBoxEye, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray);
 			champAttributes |= k0x4000_ChampionAttributeViewport;
 		}
 	}
@@ -858,8 +853,11 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 
 		if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL_0_championIconIndex))) {
 			dispMan.D24_clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]);
-			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k28_ChampionIcons), 80, M26_championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0,
-								 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray);
+			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k28_ChampionIcons),
+									  dispMan._g348_bitmapScreen,
+									  g54_BoxChampionIcons[AL_0_championIconIndex << 2],
+									  M26_championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0,
+									  40 * 2, k160_byteWidthScreen * 2, k12_ColorDarkestGray);
 		}
 	}
 
@@ -980,11 +978,9 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 	if (nativeBitmapIndex != -1) {
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		if (isInventoryChamp) {
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), 32, 0, 0,
-									   _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, box, k12_ColorDarkestGray);
+			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray);
 		} else {
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), 32, 0, 0,
-									   _vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, box, k12_ColorDarkestGray);
+			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), _vm->_displayMan->_g348_bitmapScreen, box, 0, 0, 32, k160_byteWidthScreen * 2, k12_ColorDarkestGray);
 		}
 	}
 
@@ -1008,8 +1004,7 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 	box._x2 = box._x1 + 167;
 
 	dispMan.f135_fillBoxBitmap(dispMan._g296_bitmapViewport, box, k12_ColorDarkestGray, k112_byteWidthViewport * 2, k136_heightViewport);
-	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0,
-						 dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k4_ColorCyan);
+	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k27_PanelRenameChampionIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k4_ColorCyan);
 	textMan.f52_printToViewport(177, 58, k13_ColorLightestGray, "_______");
 	textMan.f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________");
 	Common::Point clickPos;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index a21d821..a91d6ee 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -955,7 +955,7 @@ void DisplayMan::f566_viewportBlitToScreen() {
 	warning("MISSING FUNCTIONALITY: using correct colorpalette");
 	Box box(0, 223, 33, 33 + 135);
 
-	f132_blitToBitmap(_g296_bitmapViewport, k112_byteWidthViewport * 2, 0, 0, _g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
+	f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport * 2, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
 }
 
 void DisplayMan::loadPalette(uint16 *palette) {
@@ -1017,15 +1017,14 @@ void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) {
 	}
 }
 
-
-void DisplayMan::f132_blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent) {
+void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth,
+					   uint16 destWidth, Color transparent) {
 	for (uint16 y = 0; y < box._y2 - box._y1; ++y)
 		for (uint16 x = 0; x < box._x2 - box._x1; ++x) {
 			byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x];
 			if (srcPixel != transparent)
 				destBitmap[destWidth * (y + box._y1) + box._x1 + x] = srcPixel;
 		}
-
 }
 
 void DisplayMan::D24_clearScreenBox(Color color, Box &box) {
@@ -1153,12 +1152,12 @@ void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitm
 
 void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
 	if (f._srcWidth)
-		f132_blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k255_ColorNoTransparency);
+		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k255_ColorNoTransparency);
 }
 
 void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) {
 	if (f._srcWidth)
-		f132_blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh);
+		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k10_ColorFlesh);
 }
 
 
@@ -1621,12 +1620,12 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 		f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap,
 										g163_FrameWalls[k0_ViewSquare_D3C]._srcWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight);
 		f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, 128, 51, k10_ColorFlesh);
-		f132_blitToBitmap(_g74_tmpBitmap, 128, 11, 0, _g90_bitmapWall_D3LCR_Flipped, 128, g161_BoxWallBitmap_D3LCR, k255_ColorNoTransparency);
+		f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, g161_BoxWallBitmap_D3LCR, 11, 0, 128, 128, k255_ColorNoTransparency);
 
 		f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap,
 										g163_FrameWalls[k3_ViewSquare_D2C]._srcWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight);
 		f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, 144, 71, k10_ColorFlesh);
-		f132_blitToBitmap(_g74_tmpBitmap, 144, 8, 0, _g91_bitmapWall_D2LCR_Flipped, 144, g162_BoxWallBitmap_D2LCR, k255_ColorNoTransparency);
+		f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, g162_BoxWallBitmap_D2LCR, 8, 0, 144, 144, k255_ColorNoTransparency);
 
 		f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped,
 										g163_FrameWalls[k6_ViewSquare_D1C]._srcWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight);
@@ -1733,13 +1732,13 @@ void DisplayMan::f93_applyCreatureReplColors(int replacedColor, int replacementC
 
 void DisplayMan::f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
 	if (f._srcWidth)
-		f132_blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh);
+		f132_blitToBitmap(_bitmaps[nativeIndex], _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k10_ColorFlesh);
 }
 
 void DisplayMan::f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) {
 	if (f._srcWidth) {
 		f99_copyBitmapAndFlipHorizontal(f489_getBitmap(nativeIndex), _g74_tmpBitmap, f._srcWidth, f._srcHeight);
-		f132_blitToBitmap(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh);
+		f132_blitToBitmap(_g74_tmpBitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k10_ColorFlesh);
 	}
 }
 
@@ -1804,8 +1803,8 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 			if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
 				if (isInscription) {
 					Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C];
-					f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, _g296_bitmapViewport, k112_byteWidthViewport * 2,
-								 g202_BoxWallPatchBehindInscription, k255_ColorNoTransparency);
+					f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, g202_BoxWallPatchBehindInscription, 94, 28,
+									  D1CFrame._srcWidth, k112_byteWidthViewport * 2, k255_ColorNoTransparency);
 
 					unsigned char *string = inscriptionString;
 					bitmapRed = _bitmaps[k120_InscriptionFontIndice];
@@ -1819,7 +1818,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 						frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7;
 						frame._box._y1 = (frame._box._y2 = g203_InscriptionLineY[textLineIndex++]) - 7;
 						while (characterCount--) {
-							f132_blitToBitmap(bitmapRed, 288, (*string++) * 8, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, frame._box, k10_ColorFlesh);
+							f132_blitToBitmap(bitmapRed, _g296_bitmapViewport, frame._box, (*string++) * 8, 0, 288, k112_byteWidthViewport * 2, k10_ColorFlesh);
 							frame._box._x1 += 8;
 							frame._box._x2 += 8;
 						}
@@ -1905,12 +1904,12 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 				coordinateSetA[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
 			}
 		}
-		f132_blitToBitmap(bitmapGreen, coordinateSetA[4], var_X, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, *(Box*)coordinateSetA, k10_ColorFlesh);
+		f132_blitToBitmap(bitmapGreen, _g296_bitmapViewport, *(Box*)coordinateSetA, var_X, 0, coordinateSetA[4], k112_byteWidthViewport * 2, k10_ColorFlesh);
 
 		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
 			Box &box = g109_BoxChampionPortraitOnWall;
-			f132_blitToBitmap(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29,
-						 _g296_bitmapViewport, k112_byteWidthViewport * 2, box, k1_ColorDarkGary);
+			f132_blitToBitmap(_bitmaps[k26_ChampionPortraitsIndice], _g296_bitmapViewport, box, (_g289_championPortraitOrdinal & 0x7) << 5,
+				(_g289_championPortraitOrdinal >> 3) * 29, 256, k112_byteWidthViewport * 2, k1_ColorDarkGary);
 		}
 		return isAlcove;
 	}
@@ -2417,7 +2416,7 @@ T0115015_DrawProjectileAsObject:
 					AL_6_bitmapRedBanana = bitmapGreenAnt;
 					dunMan._g292_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */
 				}
-				f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh);
+				f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport * 2, k10_ColorFlesh);
 
 				if (drawProjectileAsObject)
 					goto T0115171_BackFromT0115015_DrawProjectileAsObject;
@@ -2668,7 +2667,7 @@ T0115077_DrawSecondHalfSquareCreature:
 			AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1);
 		}
 		warning("SUPER WARNINIG: we might nee noralized with on byteWidth");
-		f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, (Color)transparentColor);
+		f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_0_creaturePosX, 0, byteWidth, k112_byteWidthViewport * 2, (Color)transparentColor);
 
 T0115126_CreatureNotVisible:
 		if (twoHalfSquareCreaturesFrontView) {
@@ -2803,7 +2802,7 @@ the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part
 screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
 						AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - projectilePosX - 1));
 					}
-					f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh);
+					f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport * 2, k10_ColorFlesh);
 				} else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */
 					useAlcoveObjectImage = false;
 					projectileCoordinates[0] = projectilePosX;
@@ -2955,7 +2954,7 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP
 				if (flipVertical) {
 					flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 				}
-				f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh);
+				f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport * 2, k10_ColorFlesh);
 			}
 		}
 	} while ((thingParam = dunMan.f159_getNextThing(thingParam)) != Thing::_endOfList);
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index a0a61ba..1305322 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -547,8 +547,8 @@ public:
 	void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height);
 
 
-	void f132_blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY,
-					  byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency); // @ F0132_VIDEO_Blit
+	void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth,
+					  uint16 destWidth, Color transparent = k255_ColorNoTransparency); // @ F0132_VIDEO_Blit
 
 	void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
 									   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 1d1eb5e..9718a57 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -128,8 +128,7 @@ void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) {
 	box._y2 = 28 + 1;
 	box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7;
 	box._x2 = box._x1 + 31 + 1;
-	dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, 32, 0, 0,
-						 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
+	dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, dispMan._g348_bitmapScreen, box, 0, 0, 32, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
 }
 
 void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
@@ -162,15 +161,11 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
 	Champion &champ = _vm->_championMan->_gK71_champions[_g432_inventoryChampionOrdinal];
 	f334_closeChest();
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), 144, 0, 0,
-						 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g32_BoxPanel, k8_ColorRed);
-	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k30_FoodLabelIndice), 48, 0, 0,
-						 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g35_BoxFood, k12_ColorDarkestGray);
-	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k31_WaterLabelIndice), 48, 0, 0,
-						 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g36_BoxWater, k12_ColorDarkestGray);
+	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 144, k160_byteWidthScreen * 2, k8_ColorRed);
+	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k30_FoodLabelIndice), dispMan._g348_bitmapScreen, g35_BoxFood, 0, 0, 48, k160_byteWidthScreen * 2, k12_ColorDarkestGray);
+	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k31_WaterLabelIndice), dispMan._g348_bitmapScreen, g36_BoxWater, 0, 0, 48, k160_byteWidthScreen * 2, k12_ColorDarkestGray);
 	if (champ._poisonEventCount) {
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k32_PoisionedLabelIndice), 96, 0, 0,
-							 dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g37_BoxPoisoned, k12_ColorDarkestGray);
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k32_PoisionedLabelIndice), dispMan._g348_bitmapScreen, g37_BoxPoisoned, 0, 0, 96, k160_byteWidthScreen * 2, k12_ColorDarkestGray);
 	}
 	f344_drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown);
 	f344_drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue);
@@ -178,8 +173,7 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
 
 void InventoryMan::f346_drawPanelResurrectReincarnate() {
 	_g424_panelContent = k5_PanelContentResurrectReincarnate;
-	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0,
-								   _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k6_ColorDarkGreen);
+	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(k40_PanelResurectReincaranteIndice), _vm->_displayMan->_g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k6_ColorDarkGreen);
 }
 
 void InventoryMan::f347_drawPanel() {
@@ -262,7 +256,7 @@ void InventoryMan::f341_drawPanelScroll(Scroll* scroll) {
 		charRed++;
 	}
 	*charRed = '\0';
-	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k8_ColorRed);
+	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k23_PanelOpenScrollIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k8_ColorRed);
 	int16 lineCount = 1;
 	charRed++;
 	char *charGreen = charRed; // first char of the second line
@@ -314,7 +308,7 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo
 	if (!isPressingEye) {
 		objMan.f38_drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen);
 	}
-	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g32_BoxPanel, k8_ColorRed);
+	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k25_PanelOpenChestIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 144, k160_byteWidthScreen * 2, k8_ColorRed);
 
 	int16 chestSlotIndex = 0;
 	Thing thing = chest->getSlot();
@@ -340,8 +334,7 @@ void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int
 	box._x2 = (box._x1 = xPos) + 15 + 1;
 	box._y2 = (box._y1 = yPos) + 15 + 1;
 	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, iconBitmap);
-	_vm->_displayMan->f132_blitToBitmap(iconBitmap, 16, 0, 0, _vm->_displayMan->_g296_bitmapViewport,
-								   k112_byteWidthViewport * 2, box, k255_ColorNoTransparency);
+	_vm->_displayMan->f132_blitToBitmap(iconBitmap, _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport * 2, k255_ColorNoTransparency);
 }
 
 void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) {
@@ -415,8 +408,7 @@ Box g33_BoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOr
 
 void InventoryMan::f339_drawPanelArrowOrEye(bool pressingEye) {
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice),
-						 16, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g33_BoxArrowOrEye, k8_ColorRed);
+	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice), dispMan._g296_bitmapViewport, g33_BoxArrowOrEye, 0, 0, 16, k112_byteWidthViewport * 2, k8_ColorRed);
 }
 
 
@@ -448,10 +440,8 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		f333_openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye);
 	} else {
 		IconIndice iconIndex = objMan.f33_getIconIndex(thingToDraw);
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), 144, 0, 0,
-							 dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k8_ColorRed);
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0,
-							 dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g34_BoxObjectDescCircle, k12_ColorDarkestGray);
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k8_ColorRed);
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k29_ObjectDescCircleIndice), dispMan._g296_bitmapViewport, g34_BoxObjectDescCircle, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray);
 
 		char *descString = nullptr;
 		char str[40];
@@ -552,7 +542,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		strcat(str, "."); // TODO: localization
 
 		weight -= (weight / 10) * 10;
-		strcat(str, champMan.f288_getStringFromInteger(weight, false, 1).c_str()); 
+		strcat(str, champMan.f288_getStringFromInteger(weight, false, 1).c_str());
 
 		strcat(str, " KG."); // TODO: localization
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 1d93895..ee023e7 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -64,7 +64,7 @@ void MenuMan::f395_drawMovementArrows() {
 	Box &dest = g2_BoxMovementArrows;
 	uint16 w = disp.getWidth(k13_MovementArrowsIndice);
 
-	disp.f132_blitToBitmap(arrowsBitmap, w, 0, 0, disp._g348_bitmapScreen, k160_byteWidthScreen * 2, dest, k255_ColorNoTransparency);
+	disp.f132_blitToBitmap(arrowsBitmap, disp._g348_bitmapScreen, dest, 0, 0, w, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
 }
 void MenuMan::f388_clearActingChampion() {
 	ChampionMan &cm = *_vm->_championMan;
@@ -113,7 +113,7 @@ T0386006:
 	box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that
 	box2._y1 = 95;
 	box2._y2 = 110 + 1;
-	dm.f132_blitToBitmap(bitmapIcon, 16, 0, 0, dm._g348_bitmapScreen, k160_byteWidthScreen * 2, box2);
+	dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 16, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
 	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) {
 		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 	}
@@ -208,13 +208,13 @@ void MenuMan::f387_drawActionArea() {
 			box = g500_BoxActionArea2ActionMenu;
 		if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone)
 			box = g501_BoxActionArea1ActionMenu;
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k10_MenuActionAreaIndice), dispMan._g348_bitmapScreen, box, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
 		textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 235, 83, k0_ColorBlack, k4_ColorCyan, champMan._gK71_champions[_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name,
-												k7_ChampionNameMaximumLength, k200_heightScreen);
+											k7_ChampionNameMaximumLength, k200_heightScreen);
 		for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) {
 			textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
-													f384_getActionName(_g713_actionList._actionIndices[actionListIndex]),
-													k12_ActionNameMaximumLength, k200_heightScreen);
+												f384_getActionName(_g713_actionList._actionIndices[actionListIndex]),
+												k12_ActionNameMaximumLength, k200_heightScreen);
 		}
 	}
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
@@ -315,7 +315,7 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
 	Champion &champ = _vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
 	if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) {
 		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 12, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency);
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 12, 96, 96, k255_ColorNoTransparency);
 		int16 x = 1;
 		byte c = 96 + (6 * champ._symbolStep);
 		char spellSymbolString[2] = {'\0', '\0'};
@@ -325,7 +325,7 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
 		}
 	} else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) {
 		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 24, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency);
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 24, 96, 96, k255_ColorNoTransparency);
 		char spellSymbolString[2] = {'\0', '\0'};
 		int16 x = 8;
 		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
@@ -345,7 +345,7 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 		return;
 	if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) {
 		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g0_BoxSpellArea);
+		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k9_MenuSpellAreaBackground), dispMan._g348_bitmapScreen, g0_BoxSpellArea, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 	}
 	if (champIndex == kM1_ChampionNone) {
@@ -361,9 +361,9 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 	f393_drawSpellAreaControls((ChampionIndex)champIndex);
-	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK75_BoxSpellAreaLine2);
+	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK75_BoxSpellAreaLine2, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
 	f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols);
-	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK76_BoxSpellAreaLine3);
+	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 }
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 251401f..2daf3e1 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -196,7 +196,7 @@ void ObjectMan::f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 	iconIndex -= g26_IconGraphicFirstIndex[i];
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
 	Box box(0, 0, 15, 15);
-	_vm->_displayMan->f132_blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, box, k255_ColorNoTransparency);
+	_vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 256, 16, k255_ColorNoTransparency);
 }
 
 void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
@@ -224,12 +224,10 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) {
-		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
-									   _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, box, k255_ColorNoTransparency);
+		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g296_bitmapViewport, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 256, k112_byteWidthViewport * 2, k255_ColorNoTransparency);
 
 	} else {
-		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0,
-									   _vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency);
+		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g348_bitmapScreen, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 256, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
 	}
 }
 
@@ -248,7 +246,7 @@ void ObjectMan::f34_drawLeaderObjectName(Thing thing) {
 		objName = _g352_objectNames[iconIndex];
 	}
 	_vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, 233, 37,
-										   k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength, k200_heightScreen);
+											   k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength, k200_heightScreen);
 }
 
 IconIndice ObjectMan::f39_getIconIndexInSlotBox(uint16 slotBoxIndex) {
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index a97060e..b29584e 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -61,8 +61,7 @@ void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uin
 		uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
 
 		Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1);
-		_vm->_displayMan->f132_blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth,
-			box, k255_ColorNoTransparency);
+		_vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128, destPixelWidth, k255_ColorNoTransparency);
 
 		nextX += k5_LetterWidth + 1;
 	}


Commit: c756d1755670ed26c0171b6207279e4c321293be
    https://github.com/scummvm/scummvm/commit/c756d1755670ed26c0171b6207279e4c321293be
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Reorder DisplayMan::D24_clearScrenBox parameters

Changed paths:
    engines/dm/champion.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/menus.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 8cac2c7..125bdde 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -675,12 +675,12 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
 		if (barGraphHeight < 25) {
 			box._y1 = 2;
 			box._y1 = 27 - barGraphHeight + 1;
-			_vm->_displayMan->D24_clearScreenBox(g46_ChampionColor[champIndex], box);
+			_vm->_displayMan->D24_fillScreenBox(box, g46_ChampionColor[champIndex]);
 		}
 		if (barGraphHeight) {
 			box._y1 = 27 - barGraphHeight;
 			box._y2 = 26 + 1;
-			_vm->_displayMan->D24_clearScreenBox(g46_ChampionColor[champIndex], box);
+			_vm->_displayMan->D24_fillScreenBox(box, g46_ChampionColor[champIndex]);
 		}
 		box._x1 += 7;
 		box._x2 += 7;
@@ -738,7 +738,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		box._x1 = champStatusBoxX;
 		box._x2 = box._x1 + 66 + 1;
 		if (champ->_currHealth) {
-			dispMan.D24_clearScreenBox(k12_ColorDarkestGray, box);
+			dispMan.D24_fillScreenBox(box, k12_ColorDarkestGray);
 			int16 nativeBitmapIndices[3];
 			for (int16 i = 0; i < 3; ++i)
 				nativeBitmapIndices[i] = 0;
@@ -786,7 +786,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 			box._y2 = 6 + 1;
 			box._x1 = champStatusBoxX;
 			box._x2 = box._x1 + 42 + 1;
-			dispMan.D24_clearScreenBox(k1_ColorDarkGary, box);
+			dispMan.D24_fillScreenBox(box, k1_ColorDarkGary);
 			_vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, k1_ColorDarkGary, champ->_name);
 		}
 	}
@@ -852,7 +852,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		int16 AL_0_championIconIndex = M26_championIconIndex(champ->_cell, _vm->_dungeonMan->_g308_partyDir);
 
 		if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL_0_championIconIndex))) {
-			dispMan.D24_clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]);
+			dispMan.D24_fillScreenBox(g54_BoxChampionIcons[AL_0_championIconIndex], g46_ChampionColor[champIndex]);
 			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k28_ChampionIcons),
 									  dispMan._g348_bitmapScreen,
 									  g54_BoxChampionIcons[AL_0_championIconIndex << 2],
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 226b616..a4d1b6d 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -614,8 +614,8 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 		box._x1 = championIndex * k69_ChampionStatusBoxSpacing;
 		box._x2 = box._x1 + 66 + 1;
 		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.D24_clearScreenBox(k0_ColorBlack, box);
-		dispMan.D24_clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.M26_championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2]);
+		dispMan.D24_fillScreenBox(box, k0_ColorBlack);
+		dispMan.D24_fillScreenBox(g54_BoxChampionIcons[champMan.M26_championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2], k0_ColorBlack);
 		warning("F0457_START_DrawEnabledMenus_CPSF");
 		warning("F0078_MOUSE_ShowPointer");
 		return;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index a91d6ee..79669a1 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -725,7 +725,7 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) {
 	delete[] _g74_tmpBitmap;
 	delete[] _g348_bitmapScreen;
 	_g348_bitmapScreen = new byte[_screenWidth * _screenHeight];
-	clearScreen(k0_ColorBlack);
+	fillScreen(k0_ColorBlack);
 }
 
 void DisplayMan::f479_loadGraphics() {
@@ -1027,7 +1027,7 @@ void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box,
 		}
 }
 
-void DisplayMan::D24_clearScreenBox(Color color, Box &box) {
+void DisplayMan::D24_fillScreenBox(Box &box, Color color) {
 	uint16 width = box._x2 - box._x1;
 	for (int16 y = box._y1; y < box._y2; ++y)
 		memset(_g348_bitmapScreen + y * _screenWidth + box._x1, color, sizeof(byte) * width);
@@ -1559,7 +1559,7 @@ void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) {
 	f97_drawViewport((_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance) ? 1 : 0);
 }
 
-void DisplayMan::clearScreen(Color color) {
+void DisplayMan::fillScreen(Color color) {
 	memset(getCurrentVgaBuffer(), color, sizeof(byte) * _screenWidth * _screenHeight);
 }
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 1305322..72f9fa6 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -561,9 +561,9 @@ public:
 	byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap
 
 	void f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color); // @ F0134_VIDEO_FillBitmap
-	void clearScreen(Color color);
-	void D24_clearScreenBox(Color color, Box &box); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox
-	void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 pixelWidth, int16 height);
+	void fillScreen(Color color);
+	void D24_fillScreenBox(Box &box, Color color); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox
+	void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 pixelWidth, int16 height); // @ F0135_VIDEO_FillBox
 	void f128_drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
 	void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 9718a57..527fea3 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -138,7 +138,7 @@ void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidt
 	box._y1 = y;
 	box._y2 = box._y1 + 6 + 1;
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_vm->_displayMan->D24_clearScreenBox(color, box);
+	_vm->_displayMan->D24_fillScreenBox(box, color);
 }
 
 void InventoryMan::f344_drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index ee023e7..38b974b 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -90,7 +90,7 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
 	box._y2 = 120 + 1;
 	dm._g578_useByteBoxCoordinates = false;
 	if (!champion._currHealth) {
-		dm.D24_clearScreenBox(k0_ColorBlack, box);
+		dm.D24_fillScreenBox(box, k0_ColorBlack);
 		return;
 	}
 	byte *bitmapIcon = dm._g74_tmpBitmap;
@@ -107,7 +107,7 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
 	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, bitmapIcon);
 	dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, g498_PalChangesActionAreaObjectIcon);
 T0386006:
-	dm.D24_clearScreenBox(k4_ColorCyan, box);
+	dm.D24_fillScreenBox(box, k4_ColorCyan);
 	Box box2;
 	box2._x1 = box._x1 + 2;
 	box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that
@@ -198,7 +198,7 @@ void MenuMan::f387_drawActionArea() {
 
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 	dispMan._g578_useByteBoxCoordinates = false;
-	dispMan.D24_clearScreenBox(k0_ColorBlack, g1_BoxActionArea);
+	dispMan.D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack);
 	if (_g509_actionAreaContainsIcons) {
 		for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._g305_partyChampionCount; ++champIndex)
 			f386_drawActionIcon((ChampionIndex)champIndex);
@@ -248,7 +248,7 @@ void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) {
 	for (uint16 i = 0; i < 4; ++i)
 		champCurrHealth[i] = champMan._gK71_champions[i]._currHealth;
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-	dispMan.D24_clearScreenBox(k0_ColorBlack, g504_BoxSpellAreaControls);
+	dispMan.D24_fillScreenBox(g504_BoxSpellAreaControls, k0_ColorBlack);
 	int16 champCount = champMan._g305_partyChampionCount;
 	switch (champIndex) {
 	case k0_ChampionFirst:
@@ -352,7 +352,7 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 		champMan._g514_magicCasterChampionIndex = kM1_ChampionNone;
 		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.D24_clearScreenBox(k0_ColorBlack, g0_BoxSpellArea);
+		dispMan.D24_fillScreenBox(g0_BoxSpellArea, k0_ColorBlack);
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 		return;
 	}


Commit: f01a03e91865a4cec1119bb83a5682d8f5f25553
    https://github.com/scummvm/scummvm/commit/f01a03e91865a4cec1119bb83a5682d8f5f25553
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add default parameters to DipslayMan::f132_blitToBitmap

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 79669a1..a9c555e 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1018,7 +1018,9 @@ void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) {
 }
 
 void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth,
-					   uint16 destWidth, Color transparent) {
+					   uint16 destWidth, Color transparent, int16 srcHeight, int16 destHight) {
+	// Note: if you want to use srcHeight and destHight parameters, remove the defaults values and 
+	// and complete the function calls at the callsites, otherwise their value can be the default -1
 	for (uint16 y = 0; y < box._y2 - box._y1; ++y)
 		for (uint16 x = 0; x < box._x2 - box._x1; ++x) {
 			byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x];
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 72f9fa6..1515229 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -547,8 +547,11 @@ public:
 	void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height);
 
 
+	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which 
+	does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters
+	match the original exatcly, if need arises for heights then we'll have to retrospectively add them in old function calls*/
 	void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth,
-					  uint16 destWidth, Color transparent = k255_ColorNoTransparency); // @ F0132_VIDEO_Blit
+					  uint16 destWidth, Color transparent = k255_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit
 
 	void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
 									   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,


Commit: bd06132072852e7695015cad4373c31893b04934
    https://github.com/scummvm/scummvm/commit/bd06132072852e7695015cad4373c31893b04934
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Box objects are not expected to conatain inclusive boundaries, blitting and other methods adapted

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/objectman.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 125bdde..44d783f 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -666,20 +666,20 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
 
 	Box box;
 	box._x1 = champIndex * k69_ChampionStatusBoxSpacing + 46;
-	box._x2 = box._x1 + 3 + 1;
+	box._x2 = box._x1 + 3;
 	box._y1 = 2;
-	box._y2 = 26 + 1;
+	box._y2 = 26;
 
 	for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) {
 		int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex];
 		if (barGraphHeight < 25) {
 			box._y1 = 2;
-			box._y1 = 27 - barGraphHeight + 1;
+			box._y1 = 27 - barGraphHeight;
 			_vm->_displayMan->D24_fillScreenBox(box, g46_ChampionColor[champIndex]);
 		}
 		if (barGraphHeight) {
 			box._y1 = 27 - barGraphHeight;
-			box._y2 = 26 + 1;
+			box._y2 = 26;
 			_vm->_displayMan->D24_fillScreenBox(box, g46_ChampionColor[champIndex]);
 		}
 		box._x1 += 7;
@@ -734,9 +734,9 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 	dispMan._g578_useByteBoxCoordinates = false;
 	if (champAttributes & k0x1000_ChampionAttributeStatusBox) {
 		box._y1 = 0;
-		box._y2 = 28 + 1;
+		box._y2 = 28;
 		box._x1 = champStatusBoxX;
-		box._x2 = box._x1 + 66 + 1;
+		box._x2 = box._x1 + 66;
 		if (champ->_currHealth) {
 			dispMan.D24_fillScreenBox(box, k12_ColorDarkestGray);
 			int16 nativeBitmapIndices[3];
@@ -783,9 +783,9 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 			champAttributes |= k0x4000_ChampionAttributeViewport;
 		} else {
 			box._y1 = 0;
-			box._y2 = 6 + 1;
+			box._y2 = 6;
 			box._x1 = champStatusBoxX;
-			box._x2 = box._x1 + 42 + 1;
+			box._x2 = box._x1 + 42;
 			dispMan.D24_fillScreenBox(box, k1_ColorDarkGary);
 			_vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, k1_ColorDarkGary, champ->_name);
 		}
@@ -930,8 +930,8 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 	Box box;
 	box._x1 = slotBox->_x - 1;
 	box._y1 = slotBox->_y - 1;
-	box._x2 = box._x1 + 17 + 1;
-	box._y2 = box._y1 + 17 + 1;
+	box._x2 = box._x1 + 17;
+	box._y2 = box._y1 + 17;
 
 
 	if (!isInventoryChamp) {
@@ -999,7 +999,7 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 
 	Box box;
 	box._y1 = 3;
-	box._y2 = 8 + 1;
+	box._y2 = 8;
 	box._x1 = 3;
 	box._x2 = box._x1 + 167;
 
@@ -1008,7 +1008,7 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 	textMan.f52_printToViewport(177, 58, k13_ColorLightestGray, "_______");
 	textMan.f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________");
 	Common::Point clickPos;
-	static Box okButtonBox(197, 215, 147, 155); // inclusive boundaries, constructor adds +1
+	static Box okButtonBox(197, 215, 147, 155);
 	for (;;) {
 		_vm->_eventMan->processInput();
 		if (_vm->_eventMan->f360_hasPendingClick(clickPos, k1_LeftMouseButton) && okButtonBox.isPointInside(clickPos)) {
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index c5ff2f2..7a3ce40 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -262,7 +262,7 @@ void DMEngine::f2_gameloop() {
 		//} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking);
 
 		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
-			Box box(0, 224, 0, 126);
+			Box box(0, 223, 0, 135);
 			_displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport * 2, k136_heightViewport); // dummy code
 			_displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
 		}
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index a4d1b6d..490449d 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -610,9 +610,9 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 		champMan._g305_partyChampionCount--;
 		Box box;
 		box._y1 = 0;
-		box._y2 = 28 + 1;
+		box._y2 = 28;
 		box._x1 = championIndex * k69_ChampionStatusBoxSpacing;
-		box._x2 = box._x1 + 66 + 1;
+		box._x2 = box._x1 + 66;
 		dispMan._g578_useByteBoxCoordinates = false;
 		dispMan.D24_fillScreenBox(box, k0_ColorBlack);
 		dispMan.D24_fillScreenBox(g54_BoxChampionIcons[champMan.M26_championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2], k0_ColorBlack);
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index a9c555e..d4229bd 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -120,7 +120,7 @@ FieldAspect g188_FieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects
 	FieldAspect(0, 63, 0x0A, 0x83, 16, 136,  0, 64),   /* D0L */
 	FieldAspect(0, 63, 0x0A, 0x03, 16, 136,  0, 64)}; /* D0R */
 
-Box g2_BoxMovementArrows = Box(224, 319, 124, 168);
+Box g2_BoxMovementArrows = Box(224, 319, 124, 168); // @ G0002_s_Graphic562_Box_MovementArrows
 
 byte g212_PalChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke
 
@@ -1021,8 +1021,8 @@ void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box,
 					   uint16 destWidth, Color transparent, int16 srcHeight, int16 destHight) {
 	// Note: if you want to use srcHeight and destHight parameters, remove the defaults values and 
 	// and complete the function calls at the callsites, otherwise their value can be the default -1
-	for (uint16 y = 0; y < box._y2 - box._y1; ++y)
-		for (uint16 x = 0; x < box._x2 - box._x1; ++x) {
+	for (uint16 y = 0; y < box._y2 + 1 - box._y1; ++y) // + 1 for inclusive boundaries
+		for (uint16 x = 0; x < box._x2 + 1 - box._x1; ++x) { // + 1 for inclusive boundaries
 			byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x];
 			if (srcPixel != transparent)
 				destBitmap[destWidth * (y + box._y1) + box._x1 + x] = srcPixel;
@@ -1030,19 +1030,20 @@ void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box,
 }
 
 void DisplayMan::D24_fillScreenBox(Box &box, Color color) {
-	uint16 width = box._x2 - box._x1;
-	for (int16 y = box._y1; y < box._y2; ++y)
+	uint16 width = box._x2 + 1 - box._x1; // + 1 for inclusive boundaries
+	for (int16 y = box._y1; y < box._y2 + 1; ++y) // + 1 for inclusive boundaries
 		memset(_g348_bitmapScreen + y * _screenWidth + box._x1, color, sizeof(byte) * width);
 }
 
 void DisplayMan::f135_fillBoxBitmap(byte* destBitmap, Box &box, Color color, int16 pixelWidth, int16 height) {
-	for (int16 y = box._y1; y < box._y2; ++y)
-		memset(destBitmap + y * pixelWidth + box._x1, color, sizeof(byte) * (box._x2 - box._x1));
+	for (int16 y = box._y1; y < box._y2 + 1; ++y) // + 1 for inclusive boundaries
+		memset(destBitmap + y * pixelWidth + box._x1, color, sizeof(byte) * (box._x2 - box._x1 + 1)); // + 1 for inclusive boundaries
 }
 
 void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box,
 											   int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
 											   int16 xPos, int16 yPos, int16 destHeight, int16 height2) {
+	// make sure to take care of inclusive boundaries
 	warning("STUB FUNCTION: does nothing at all");
 }
 
@@ -2368,7 +2369,7 @@ T0115015_DrawProjectileAsObject:
 					}
 				}
 				AL_4_xPos = coordinateSet[0];
-				boxByteGreen._y2 = coordinateSet[1] + 1;
+				boxByteGreen._y2 = coordinateSet[1];
 				if (!drawProjectileAsObject) { /* If drawing an object that is not a projectile */
 					AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][g217_ObjectPileShiftSetIndices[objectShiftIndex][0]];
 					boxByteGreen._y2 += g223_ShiftSets[AL_8_shiftSetIndex][g217_ObjectPileShiftSetIndices[objectShiftIndex][1]];
@@ -2381,12 +2382,12 @@ T0115015_DrawProjectileAsObject:
 						objectShiftIndex &= 0x000F;
 					}
 				}
-				boxByteGreen._y1 = boxByteGreen._y2 - (heightRedEagle - 1) - 1;
-				if (boxByteGreen._y2 > 136) {
-					boxByteGreen._y2 = 136;
+				boxByteGreen._y1 = boxByteGreen._y2 - (heightRedEagle - 1);
+				if (boxByteGreen._y2 > 135) {
+					boxByteGreen._y2 = 135;
 				}
-				boxByteGreen._x2 = MIN(224, AL_4_xPos + byteWidth);
-				if (boxByteGreen._x1 = MAX(0, AL_4_xPos - byteWidth + 1)) {
+				boxByteGreen._x2 = MIN(223, AL_4_xPos + byteWidth);
+				if (boxByteGreen._x1 = MAX(0, AL_4_xPos - byteWidth)) {
 					if (flipHorizontal) {
 						AL_4_xPos = paddingPixelCount;
 					} else {
@@ -2402,7 +2403,7 @@ T0115015_DrawProjectileAsObject:
 					if (AL_6_boxPtrRed->_x1 == 255) { /* If the grabbable object is the first */
 						*AL_6_boxPtrRed = boxByteGreen;
 
-						if ((heightGreenGoat = AL_6_boxPtrRed->_y2 - AL_6_boxPtrRed->_y1) < 15) { /* If the box is too small then enlarge it a little */
+						if ((heightGreenGoat = AL_6_boxPtrRed->_y2 - AL_6_boxPtrRed->_y1) < 14) { /* If the box is too small then enlarge it a little */
 							heightGreenGoat = heightGreenGoat >> 1;
 							AL_6_boxPtrRed->_y1 += heightGreenGoat - 7;
 							if (heightGreenGoat < 4) {
@@ -2648,7 +2649,7 @@ T0115077_DrawSecondHalfSquareCreature:
 		}
 		AL_4_yPos = coordinateSet[1];
 		AL_4_yPos += g223_ShiftSets[AL_8_shiftSetIndex][M23_getVerticalOffsetM23(creatureAspectInt)];
-		boxByteGreen._y2 = MIN(AL_4_yPos, (int16)135) + 1;
+		boxByteGreen._y2 = MIN(AL_4_yPos, (int16)135);
 		boxByteGreen._y1 = MIN(0, AL_4_yPos - (heightRedEagle - 1));
 		AL_4_xPos = coordinateSet[0];
 		AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][M22_getHorizontalOffsetM22(creatureAspectInt)];
@@ -2659,7 +2660,7 @@ T0115077_DrawSecondHalfSquareCreature:
 				AL_4_xPos += 100;
 			}
 		}
-		if (boxByteGreen._x2 = 1 + MIN(MAX(0, AL_4_xPos + byteWidth), 223) <= 1)
+		if (!(boxByteGreen._x2 = MIN(MAX(0, AL_4_xPos + byteWidth), 223)))
 			goto T0115126_CreatureNotVisible;
 		if (boxByteGreen._x1 = MIN(MAX(0, AL_4_xPos - byteWidth + 1), 223)) {
 			if (boxByteGreen._x1 == 223)
@@ -2788,9 +2789,9 @@ continue;
 							f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 						}
 					}
-					boxByteGreen._y2 = (heightRedEagle >> 1) + 47 + 1;
+					boxByteGreen._y2 = (heightRedEagle >> 1) + 47;
 					boxByteGreen._y1 = 47 - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001);
-					boxByteGreen._x2 = MIN(223, projectilePosX + byteWidth) + 1;
+					boxByteGreen._x2 = MIN(223, projectilePosX + byteWidth);
 					if (boxByteGreen._x1 = MAX(0, projectilePosX - byteWidth + 1)) {
 						if (flipHorizontal) {
 							AL_4_xPos = paddingPixelCount;
@@ -2920,14 +2921,14 @@ T0115200_DrawExplosion:
 				if (flipHorizontal = _vm->_rnd->getRandomNumber(2)) {
 					paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; /* Number of unused pixels in the units on the right of the bitmap */
 				}
-				boxByteGreen._y2 = MIN(135, explosionCoordinates[1] + (heightRedEagle >> 1)) + 1;
+				boxByteGreen._y2 = MIN(135, explosionCoordinates[1] + (heightRedEagle >> 1));
 				AL_4_yPos = MAX(0, explosionCoordinates[1] - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001));
 				if (AL_4_yPos >= 136)
 					continue;
 				boxByteGreen._y1 = AL_4_yPos;
 				if ((AL_4_xPos = MIN(223, explosionCoordinates[0] + byteWidth)) < 0)
 					continue;
-				boxByteGreen._x2 = AL_4_xPos + 1;
+				boxByteGreen._x2 = AL_4_xPos;
 				AL_4_xPos = explosionCoordinates[0];
 				if (boxByteGreen._x1 = MIN(MAX(0, AL_4_xPos - byteWidth + 1), 223)) {
 					AL_4_xPos = paddingPixelCount;
@@ -2942,7 +2943,7 @@ and may cause an incorrect bitmap to be drawn */
 only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is flipped horizontally (flipHorizontal = C1_TRUE)
 then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
 				}
-				if (boxByteGreen._x2 - 1 <= boxByteGreen._x1)
+				if (boxByteGreen._x2 <= boxByteGreen._x1)
 					continue;
 				warning("might need M77_NORMALIZED_BYTE_WIDTH");
 				byteWidth = byteWidth;
@@ -2965,7 +2966,7 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP
 		AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */
 		fieldAspect = g188_FieldAspects[viewSquareIndex];
 		(fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */
-		f113_drawField(&fieldAspect, *(Box*)&g163_FrameWalls[viewSquareIndex]);
+		f113_drawField(&fieldAspect, g163_FrameWalls[viewSquareIndex]._box);
 	}
 }
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 1515229..6bfb504 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -230,6 +230,8 @@ extern uint16 g19_PalCredits[16];  // @ G0019_aui_Graphic562_Palette_Credits
 extern uint16 g20_PalEntrance[16]; // @ G0020_aui_Graphic562_Palette_Entrance
 extern uint16 g21_PalDungeonView[6][16]; // @ G0021_aaui_Graphic562_Palette_DungeonView
 
+
+// in all cases, where a function takes a Box, it expects it to contain inclusive boundaries
 class Box {
 public:
 	uint16 _x1;
@@ -237,15 +239,15 @@ public:
 	uint16 _y1;
 	uint16 _y2;
 
-	Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2) : _x1(x1), _x2(x2 + 1), _y1(y1), _y2(y2 + 1) {}
+	Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2) : _x1(x1), _x2(x2), _y1(y1), _y2(y2) {}
 	Box() {}
 	bool isPointInside(Common::Point point) {
-		return (_x1 <= point.x) && (point.x < _x2) && (_y1 <= point.y) && (point.y < _y2);
+		return (_x1 <= point.x) && (point.x <= _x2) && (_y1 <= point.y) && (point.y <= _y2); // <= because incluseive boundaries
 	}
 	void setToZero() { _x1 = _x2 = _y1 = _y2 = 0; }
 }; // @ BOX_BYTE, BOX_WORD
 
-extern Box g2_BoxMovementArrows; // G0002_s_Graphic562_Box_MovementArrows
+extern Box g2_BoxMovementArrows; // @ G0002_s_Graphic562_Box_MovementArrows
 
 class Frame {
 public:
@@ -550,22 +552,24 @@ public:
 	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which 
 	does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters
 	match the original exatcly, if need arises for heights then we'll have to retrospectively add them in old function calls*/
+	/* Expects inclusive boundaries in box */
 	void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth,
 					  uint16 destWidth, Color transparent = k255_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit
-
+/* Expects inclusive boundaries in box */
 	void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
 									   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
 									   int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
 	void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight,
 										 byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
-
 	void f103_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
 	byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap
 
 	void f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color); // @ F0134_VIDEO_FillBitmap
 	void fillScreen(Color color);
+	/* Expects inclusive boundaries in box */
 	void D24_fillScreenBox(Box &box, Color color); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox
+/* Expects inclusive boundaries in box */
 	void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 pixelWidth, int16 height); // @ F0135_VIDEO_FillBox
 	void f128_drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 527fea3..77242c1 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -125,18 +125,18 @@ void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) {
 	dispMan._g578_useByteBoxCoordinates = false;
 	Box box;
 	box._y1 = 0;
-	box._y2 = 28 + 1;
+	box._y2 = 28;
 	box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7;
-	box._x2 = box._x1 + 31 + 1;
+	box._x2 = box._x1 + 31;
 	dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, dispMan._g348_bitmapScreen, box, 0, 0, 32, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
 }
 
 void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
 	Box box;
 	box._x1 = x;
-	box._x2 = box._x1 + pixelWidth + 1;
+	box._x2 = box._x1 + pixelWidth;
 	box._y1 = y;
-	box._y2 = box._y1 + 6 + 1;
+	box._y2 = box._y1 + 6;
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	_vm->_displayMan->D24_fillScreenBox(box, color);
 }
@@ -331,8 +331,8 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo
 void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos) {
 	static byte iconBitmap[16 * 16];
 	Box box;
-	box._x2 = (box._x1 = xPos) + 15 + 1;
-	box._y2 = (box._y1 = yPos) + 15 + 1;
+	box._x2 = (box._x1 = xPos) + 15;
+	box._y2 = (box._y1 = yPos) + 15;
 	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, iconBitmap);
 	_vm->_displayMan->f132_blitToBitmap(iconBitmap, _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport * 2, k255_ColorNoTransparency);
 }
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 38b974b..196fab7 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -85,9 +85,9 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
 
 	Box box;
 	box._x1 = championIndex * 22 + 233;
-	box._x2 = box._x1 + 19 + 1;
+	box._x2 = box._x1 + 19;
 	box._y1 = 86;
-	box._y2 = 120 + 1;
+	box._y2 = 120;
 	dm._g578_useByteBoxCoordinates = false;
 	if (!champion._currHealth) {
 		dm.D24_fillScreenBox(box, k0_ColorBlack);
@@ -110,9 +110,9 @@ T0386006:
 	dm.D24_fillScreenBox(box, k4_ColorCyan);
 	Box box2;
 	box2._x1 = box._x1 + 2;
-	box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that
+	box2._x2 = box._x2 - 2; 
 	box2._y1 = 95;
-	box2._y2 = 110 + 1;
+	box2._y2 = 110;
 	dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 16, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
 	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) {
 		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 2daf3e1..1d8b780 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -209,8 +209,8 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 	Box box;
 	box._x1 = slotBox->_x;
 	box._y1 = slotBox->_y;
-	box._x2 = box._x1 + 15 + 1;
-	box._y2 = box._y1 + 15 + 1;
+	box._x2 = box._x1 + 15;
+	box._y2 = box._y1 + 15;
 
 	uint16 iconGraphicIndex;
 	for (iconGraphicIndex = 0; iconGraphicIndex < 7; ++iconGraphicIndex) {


Commit: d7b0413be646e774d9b251bba30b34440fa50289
    https://github.com/scummvm/scummvm/commit/d7b0413be646e774d9b251bba30b34440fa50289
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Reorder blitshrink parameters

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/menus.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index d4229bd..33c9c6d 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1087,7 +1087,7 @@ byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale
 	} else {
 		byte *nativeBitmap = f489_getBitmap(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice);
 		bitmap = f492_getDerivedBitmap(derBitmapIndex);
-		f129_blitToBitmapShrinkWithPalChange(nativeBitmap, explAsp->_pixelWidth, explAsp->_height, bitmap, pixelWidth, height,
+		f129_blitToBitmapShrinkWithPalChange(nativeBitmap, bitmap, explAsp->_pixelWidth, explAsp->_height, pixelWidth, height,
 			(explosionAspIndex == k3_ExplosionAspectSmoke) ? g212_PalChangeSmoke : g17_PalChangesNoChanges);
 		warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 	}
@@ -1870,7 +1870,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 				}
 			}
 			int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0];
-			f129_blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], coordSetB[4] << 1, coordSetB[5], _g74_tmpBitmap, pixelWidth + 1, coordinateSetA[5],
+			f129_blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], _g74_tmpBitmap, coordSetB[4] << 1, coordSetB[5],pixelWidth + 1, coordinateSetA[5],
 				(viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
 			bitmapGreen = _bitmaps[nativeBitmapIndex];
 			var_X = pixelWidth;
@@ -1920,7 +1920,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 }
 
 
-void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHeight, byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange) {
+void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap, int16 srcWidth, int16 srcHeight, int16 destWidth, int16 destHeight, byte *palChange) {
 	double rateW = srcWidth / destWidth;
 	double rateH = srcHeight / destHeight;
 
@@ -2360,8 +2360,9 @@ T0115015_DrawProjectileAsObject:
 						AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 					} else {
 						bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex);
-						f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, objectAspect->_width, objectAspect->_height, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex),
-														byteWidth, heightRedEagle, paletteChanges);
+						f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex),
+															 objectAspect->_width, objectAspect->_height,
+															 byteWidth, heightRedEagle, paletteChanges);
 						if (flipHorizontal) {
 							f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 						}
@@ -2626,7 +2627,7 @@ T0115077_DrawSecondHalfSquareCreature:
 			} else {
 				bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex);
 				AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, sourceByteWidth, sourceHeight, AL_6_bitmapRedBanana, byteWidth, heightRedEagle, paletteChanges);
+				f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, sourceByteWidth, sourceHeight, byteWidth, heightRedEagle, paletteChanges);
 				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 			}
 			if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */
@@ -2768,8 +2769,8 @@ continue;
 							} else {
 								AL_6_bitmapRedBanana = _g74_tmpBitmap;
 							}
-							f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height,
-															AL_6_bitmapRedBanana, byteWidth, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
+							f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height,
+															 byteWidth, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
 							if (doNotScaleWithKineticEnergy) {
 								warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap");
 							}
@@ -2858,8 +2859,8 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 							byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_width), explosionCoordinates[2]);
 							heightRedEagle = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
 							if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) {
-								f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana,
-									((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, _g74_tmpBitmap,
+								f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap,
+									((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height,
 																byteWidth, heightRedEagle, g17_PalChangesNoChanges);
 								AL_6_bitmapRedBanana = _g74_tmpBitmap;
 							}
@@ -2889,7 +2890,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 				warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache");
 				AL_6_bitmapRedBanana = f489_getBitmap(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice);
 				if (smoke) {
-					f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _g74_tmpBitmap, 48, 32, g212_PalChangeSmoke);
+					f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, 48, 32, 48, 32, g212_PalChangeSmoke);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
 				f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, nullptr, f492_getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C,
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 6bfb504..92b14d1 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -559,8 +559,8 @@ public:
 	void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
 									   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
 									   int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
-	void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight,
-										 byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
+	void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
+											  int16 srcWidth, int16 srcHight, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
 	void f103_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
 	byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 196fab7..4f5b985 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -105,7 +105,7 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
 		goto T0386006;
 	}
 	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, bitmapIcon);
-	dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, g498_PalChangesActionAreaObjectIcon);
+	dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, bitmapIcon, 16, 16,  16, 16, g498_PalChangesActionAreaObjectIcon);
 T0386006:
 	dm.D24_fillScreenBox(box, k4_ColorCyan);
 	Box box2;


Commit: cb345ff614f431b7442aba590fd5d59a88dc1e4a
    https://github.com/scummvm/scummvm/commit/cb345ff614f431b7442aba590fd5d59a88dc1e4a
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Reorder fillBitmap parameters

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/menus.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 33c9c6d..2bfcb6c 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1018,9 +1018,9 @@ void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) {
 }
 
 void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth,
-					   uint16 destWidth, Color transparent, int16 srcHeight, int16 destHight) {
-	// Note: if you want to use srcHeight and destHight parameters, remove the defaults values and 
-	// and complete the function calls at the callsites, otherwise their value can be the default -1
+								   uint16 destWidth, Color transparent, int16 srcHeight, int16 destHight) {
+				// Note: if you want to use srcHeight and destHight parameters, remove the defaults values and 
+				// and complete the function calls at the callsites, otherwise their value can be the default -1
 	for (uint16 y = 0; y < box._y2 + 1 - box._y1; ++y) // + 1 for inclusive boundaries
 		for (uint16 x = 0; x < box._x2 + 1 - box._x1; ++x) { // + 1 for inclusive boundaries
 			byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x];
@@ -1041,15 +1041,15 @@ void DisplayMan::f135_fillBoxBitmap(byte* destBitmap, Box &box, Color color, int
 }
 
 void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box,
-											   int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
-											   int16 xPos, int16 yPos, int16 destHeight, int16 height2) {
-	// make sure to take care of inclusive boundaries
+													int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
+													int16 xPos, int16 yPos, int16 destHeight, int16 height2) {
+		 // make sure to take care of inclusive boundaries
 	warning("STUB FUNCTION: does nothing at all");
 }
 
 
 
-void DisplayMan::f103_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) {
+void DisplayMan::f130_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) {
 	for (uint16 y = 0; y < height; ++y) {
 		for (uint16 x = 0; x < width / 2; ++x) {
 			byte tmp;
@@ -1150,7 +1150,7 @@ uint16 DisplayMan::getHeight(uint16 index) {
 // Note: has been screened for missing code
 void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitmap, uint16 pixelWidth, uint16 height) {
 	memmove(destBitmap, srcBitmap, pixelWidth * height * sizeof(byte));
-	f103_flipBitmapHorizontal(destBitmap, pixelWidth, height);
+	f130_flipBitmapHorizontal(destBitmap, pixelWidth, height);
 }
 
 void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
@@ -1566,7 +1566,7 @@ void DisplayMan::fillScreen(Color color) {
 	memset(getCurrentVgaBuffer(), color, sizeof(byte) * _screenWidth * _screenHeight);
 }
 
-void DisplayMan::f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color) {
+void DisplayMan::f134_fillBitmap(byte *bitmap, Color color, uint16 width, uint16 height) {
 	memset(bitmap, color, sizeof(byte) * width * height);
 }
 
@@ -1622,12 +1622,12 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 
 		f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap,
 										g163_FrameWalls[k0_ViewSquare_D3C]._srcWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight);
-		f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, 128, 51, k10_ColorFlesh);
+		f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, k10_ColorFlesh, 128, 51);
 		f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, g161_BoxWallBitmap_D3LCR, 11, 0, 128, 128, k255_ColorNoTransparency);
 
 		f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap,
 										g163_FrameWalls[k3_ViewSquare_D2C]._srcWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight);
-		f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, 144, 71, k10_ColorFlesh);
+		f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, k10_ColorFlesh, 144, 71);
 		f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, g162_BoxWallBitmap_D2LCR, 8, 0, 144, 144, k255_ColorNoTransparency);
 
 		f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped,
@@ -1870,7 +1870,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 				}
 			}
 			int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0];
-			f129_blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], _g74_tmpBitmap, coordSetB[4] << 1, coordSetB[5],pixelWidth + 1, coordinateSetA[5],
+			f129_blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], _g74_tmpBitmap, coordSetB[4] << 1, coordSetB[5], pixelWidth + 1, coordinateSetA[5],
 				(viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
 			bitmapGreen = _bitmaps[nativeBitmapIndex];
 			var_X = pixelWidth;
@@ -1961,9 +1961,9 @@ void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) {
 	} else {
 		bitmapMask = dispMan._g74_tmpBitmap;
 		memmove(bitmapMask, dispMan.f489_getBitmap(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)),
-			   fieldAspect->_height * fieldAspect->_pixelWidth * sizeof(bitmapMask[0]));
+				fieldAspect->_height * fieldAspect->_pixelWidth * sizeof(bitmapMask[0]));
 		if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask)) {
-			dispMan.f103_flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height);
+			dispMan.f130_flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height);
 		}
 	}
 
@@ -2138,7 +2138,7 @@ int16 g225_CenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_Cen
 #define k0x0080_BlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK
 
 void DisplayMan::f115_cthulhu(Thing thingParam, direction directionParam, int16 mapXpos,
-						 int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) {
+							  int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) {
 
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 
@@ -2331,7 +2331,7 @@ T0115015_DrawProjectileAsObject:
 					heightRedEagle = objectAspect->_height;
 					if (flipHorizontal) {
 						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
-						f103_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
+						f130_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
 				} else {
@@ -2364,7 +2364,7 @@ T0115015_DrawProjectileAsObject:
 															 objectAspect->_width, objectAspect->_height,
 															 byteWidth, heightRedEagle, paletteChanges);
 						if (flipHorizontal) {
-							f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
+							f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 						}
 						warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 					}
@@ -2577,7 +2577,7 @@ T0115077_DrawSecondHalfSquareCreature:
 				AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex);
 				if (creatureDirectionDelta == 1) {
 					memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
-					f103_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
+					f130_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
 			} else {
@@ -2585,7 +2585,7 @@ T0115077_DrawSecondHalfSquareCreature:
 					AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex);
 					if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
 						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
-						f103_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
+						f130_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
 				} else { /* Use first additional derived graphic: front D1 */
@@ -2596,7 +2596,7 @@ T0115077_DrawSecondHalfSquareCreature:
 						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) {
 							AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 							memmove(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * heightRedEagle * sizeof(byte));
-							f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
+							f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 						}
 						warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 					}
@@ -2641,7 +2641,7 @@ T0115077_DrawSecondHalfSquareCreature:
 						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte));
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
-					f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
+					f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 				}
 				creaturePaddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1;
 			} else {
@@ -2770,7 +2770,7 @@ continue;
 								AL_6_bitmapRedBanana = _g74_tmpBitmap;
 							}
 							f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height,
-															 byteWidth, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
+																 byteWidth, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
 							if (doNotScaleWithKineticEnergy) {
 								warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap");
 							}
@@ -2787,7 +2787,7 @@ continue;
 							flipBitmapVertical(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 						}
 						if (flipHorizontal) {
-							f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
+							f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 						}
 					}
 					boxByteGreen._y2 = (heightRedEagle >> 1) + 47;
@@ -2861,7 +2861,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 							if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) {
 								f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap,
 									((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height,
-																byteWidth, heightRedEagle, g17_PalChangesNoChanges);
+																	 byteWidth, heightRedEagle, g17_PalChangesNoChanges);
 								AL_6_bitmapRedBanana = _g74_tmpBitmap;
 							}
 							goto T0115200_DrawExplosion;
@@ -2894,8 +2894,8 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
 				f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, nullptr, f492_getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C,
-											  _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64),
-											  224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
+												   _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64),
+												   224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
 				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 			} else {
@@ -2953,7 +2953,7 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
 				if (flipHorizontal) {
-					f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
+					f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 				}
 				if (flipVertical) {
 					flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 92b14d1..282dfc2 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -561,11 +561,11 @@ public:
 									   int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
 	void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
 											  int16 srcWidth, int16 srcHight, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
-	void f103_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally
+	void f130_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0130_VIDEO_FlipHorizontal
 	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
 	byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap
 
-	void f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color); // @ F0134_VIDEO_FillBitmap
+	void f134_fillBitmap(byte *bitmap, Color color, uint16 width, uint16 height); // @ F0134_VIDEO_FillBitmap
 	void fillScreen(Color color);
 	/* Expects inclusive boundaries in box */
 	void D24_fillScreenBox(Box &box, Color color); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 4f5b985..63ca90c 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -101,16 +101,16 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
 	} else if (g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thing)]._actionSetIndex) {
 		iconIndex = _vm->_objectMan->f33_getIconIndex(thing);
 	} else {
-		dm.f134_fillBitmap(bitmapIcon, 16, 16, k4_ColorCyan);
+		dm.f134_fillBitmap(bitmapIcon, k4_ColorCyan, 16, 16);
 		goto T0386006;
 	}
 	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, bitmapIcon);
-	dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, bitmapIcon, 16, 16,  16, 16, g498_PalChangesActionAreaObjectIcon);
+	dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, bitmapIcon, 16, 16, 16, 16, g498_PalChangesActionAreaObjectIcon);
 T0386006:
 	dm.D24_fillScreenBox(box, k4_ColorCyan);
 	Box box2;
 	box2._x1 = box._x1 + 2;
-	box2._x2 = box._x2 - 2; 
+	box2._x2 = box._x2 - 2;
 	box2._y1 = 95;
 	box2._y2 = 110;
 	dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 16, k160_byteWidthScreen * 2, k255_ColorNoTransparency);


Commit: 816319c65912a0274b1203dd9f8051b75706cbc0
    https://github.com/scummvm/scummvm/commit/816319c65912a0274b1203dd9f8051b75706cbc0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Revert to using byteWidths where the original does so as well

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/eventman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/objectman.cpp
    engines/dm/text.cpp
    engines/dm/text.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 44d783f..333243c 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -138,7 +138,7 @@ Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding,
 	return result += valToStr;
 }
 
-void ChampionMan::f299_pplyModifiersToStatistics(Champion* champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing) {
+void ChampionMan::f299_applyModifiersToStatistics(Champion* champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing) {
 	int16 statIndex;
 	int16 modifier = 0;
 	ThingType thingType = thing.getType();
@@ -383,7 +383,7 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 	champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
 	IconIndice iconIndex = objMan.f33_getIconIndex(thing);
 	bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal);
-	f299_pplyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
+	f299_applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
 	uint16 *rawObjPtr = dunMan.f156_getThingData(thing);
 
 	if (slotIndex < k2_ChampionSlotHead) {
@@ -461,7 +461,8 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 	dispMan._g578_useByteBoxCoordinates = true;
 	{ // limit destBox scope
 		Box &destBox = gBoxChampionPortrait;
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k26_ChampionPortraitsIndice), champ->_portrait, destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 256, 32, k255_ColorNoTransparency);
+		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), champ->_portrait,
+								  destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 128, 16, k255_ColorNoTransparency);
 	}
 
 	champ->_actionIndex = k255_ChampionActionNone;
@@ -750,7 +751,8 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 			if (_g407_party._shieldDefense > 0)
 				nativeBitmapIndices[AL_0_borderCount++] = k37_BorderPartyShieldIndice;
 			while (AL_0_borderCount--) {
-				dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(nativeBitmapIndices[AL_0_borderCount]), dispMan._g348_bitmapScreen, box, 0, 0, 80, k160_byteWidthScreen * 2, k10_ColorFlesh);
+				dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(nativeBitmapIndices[AL_0_borderCount]),
+										  dispMan._g348_bitmapScreen, box, 0, 0, 40, k160_byteWidthScreen, k10_ColorFlesh);
 			}
 			if (isInventoryChamp) {
 				invMan.f354_drawStatusBoxPortrait(champIndex);
@@ -759,7 +761,8 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 				champAttributes |= (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand);
 			}
 		} else {
-			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k8_StatusBoxDeadChampion), dispMan._g348_bitmapScreen, box, 0, 0, 80, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
+			dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), dispMan._g348_bitmapScreen,
+									  box, 0, 0, 40, k160_byteWidthScreen, k255_ColorNoTransparency);
 			_vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, champ->_name);
 			menuMan.f386_drawActionIcon(champIndex);
 			goto T0292042_green;
@@ -801,7 +804,8 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 			} else {
 				AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			}
-			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport, gBoxMouth, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray);
+			dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport,
+									  gBoxMouth, 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray);
 			AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			for (int16 AL_0_statisticIndex = k1_ChampionStatStrength; AL_0_statisticIndex <= k6_ChampionStatAntifire; AL_0_statisticIndex++) {
 				if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent)
@@ -810,7 +814,8 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 					break;
 				}
 			}
-			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport, gBoxEye, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray);
+			dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport, gBoxEye,
+									  0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray);
 			champAttributes |= k0x4000_ChampionAttributeViewport;
 		}
 	}
@@ -853,11 +858,11 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 
 		if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL_0_championIconIndex))) {
 			dispMan.D24_fillScreenBox(g54_BoxChampionIcons[AL_0_championIconIndex], g46_ChampionColor[champIndex]);
-			dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k28_ChampionIcons),
+			dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k28_ChampionIcons),
 									  dispMan._g348_bitmapScreen,
 									  g54_BoxChampionIcons[AL_0_championIconIndex << 2],
 									  M26_championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0,
-									  40 * 2, k160_byteWidthScreen * 2, k12_ColorDarkestGray);
+									  40, k160_byteWidthScreen, k12_ColorDarkestGray);
 		}
 	}
 
@@ -978,9 +983,11 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 	if (nativeBitmapIndex != -1) {
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		if (isInventoryChamp) {
-			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray);
+			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
+												_vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray);
 		} else {
-			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), _vm->_displayMan->_g348_bitmapScreen, box, 0, 0, 32, k160_byteWidthScreen * 2, k12_ColorDarkestGray);
+			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
+												_vm->_displayMan->_g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen, k12_ColorDarkestGray);
 		}
 	}
 
@@ -1003,8 +1010,9 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 	box._x1 = 3;
 	box._x2 = box._x1 + 167;
 
-	dispMan.f135_fillBoxBitmap(dispMan._g296_bitmapViewport, box, k12_ColorDarkestGray, k112_byteWidthViewport * 2, k136_heightViewport);
-	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k27_PanelRenameChampionIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k4_ColorCyan);
+	dispMan.f135_fillBoxBitmap(dispMan._g296_bitmapViewport, box, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
+	dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), dispMan._g296_bitmapViewport, g32_BoxPanel,
+							  0, 0, 72, k112_byteWidthViewport, k4_ColorCyan);
 	textMan.f52_printToViewport(177, 58, k13_ColorLightestGray, "_______");
 	textMan.f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________");
 	Common::Point clickPos;
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 1b7a4ff..cabf06f 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -461,7 +461,7 @@ public:
 	void f281_renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename
 	uint16 f303_getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex);// @ F0303_CHAMPION_GetSkillLevel
 	Common::String f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger
-	void f299_pplyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex,
+	void f299_applyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex,
 									int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics
 	bool f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged
 	void f296_drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 7a3ce40..ae7852d 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -263,7 +263,7 @@ void DMEngine::f2_gameloop() {
 
 		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
 			Box box(0, 223, 0, 135);
-			_displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport * 2, k136_heightViewport); // dummy code
+			_displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // dummy code
 			_displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
 		}
 
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 51f1761..c156eed 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -243,7 +243,7 @@ public:
 	void setMousePos(Common::Point pos);
 	void processInput(); // acknowledges mouse and keyboard input
 	void f360_processPendingClick(); // @ F0360_COMMAND_ProcessPendingClick
-	void f359_processClick(Common::Point mousePos, MouseButton button); // @	F0359_COMMAND_ProcessClick_CPSC
+	void f359_processClick(Common::Point mousePos, MouseButton button); // @ F0359_COMMAND_ProcessClick_CPSC
 	CommandType f358_getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC
 	void f380_processCommandQueue(); // @ F0380_COMMAND_ProcessQueue_CPSC
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 2bfcb6c..4aa9ea2 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -224,111 +224,111 @@ byte g195_FloorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnament
 	0}; /* Floor Ornament 08 Puddle */
 
 uint16 g205_WallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets
-	/* { X1, X2, Y1, Y2, PixelWidth, Height } */
-	{{80,  83, 41,  45,  8 * 2,   5},     /* D3L */
-	{140, 143, 41,  45,  8 * 2,   5},     /* D3R */
-	{16,  29, 39,  50,  8 * 2,  12},     /* D3L */
-	{107, 120, 39,  50,  8 * 2,  12},     /* D3C */
-	{187, 200, 39,  50,  8 * 2,  12},     /* D3R */
-	{67,  77, 40,  49,  8 * 2,  10},     /* D2L */
-	{146, 156, 40,  49,  8 * 2,  10},     /* D2R */
-	{0,  17, 38,  55, 16 * 2,  18},     /* D2L */
-	{102, 123, 38,  55, 16 * 2,  18},     /* D2C */
-	{206, 223, 38,  55, 16 * 2,  18},     /* D2R */
-	{48,  63, 38,  56,  8 * 2,  19},     /* D1L */
-	{160, 175, 38,  56,  8 * 2,  19},     /* D1R */
-	{96, 127, 36,  63, 16 * 2,  28}},   /* D1C */
-	{{74,  82, 41,  60,  8 * 2,  20},     /* D3L */
-	{141, 149, 41,  60,  8 * 2,  20},     /* D3R */
-	{1,  47, 37,  63, 24 * 2,  27},     /* D3L */
-	{88, 134, 37,  63, 24 * 2,  27},     /* D3C */
-	{171, 217, 37,  63, 24 * 2,  27},     /* D3R */
-	{61,  76, 38,  67,  8 * 2,  30},     /* D2L */
-	{147, 162, 38,  67,  8 * 2,  30},     /* D2R */
-	{0,  43, 37,  73, 32 * 2,  37},     /* D2L */
-	{80, 143, 37,  73, 32 * 2,  37},     /* D2C */
-	{180, 223, 37,  73, 32 * 2,  37},     /* D2R */
-	{32,  63, 36,  83, 16 * 2,  48},     /* D1L */
-	{160, 191, 36,  83, 16 * 2,  48},     /* D1R */
-	{64, 159, 36,  91, 48 * 2,  56}},   /* D1C */
-	{{80,  83, 66,  70,  8 * 2,   5},     /* D3L */
-	{140, 143, 66,  70,  8 * 2,   5},     /* D3R */
-	{16,  29, 64,  75,  8 * 2,  12},     /* D3L */
-	{106, 119, 64,  75,  8 * 2,  12},     /* D3C */
-	{187, 200, 64,  75,  8 * 2,  12},     /* D3R */
-	{67,  77, 74,  83,  8 * 2,  10},     /* D2L */
-	{146, 156, 74,  83,  8 * 2,  10},     /* D2R */
-	{0,  17, 73,  90, 16 * 2,  18},     /* D2L */
-	{100, 121, 73,  90, 16 * 2,  18},     /* D2C */
-	{206, 223, 73,  90, 16 * 2,  18},     /* D2R */
-	{48,  63, 84, 102,  8 * 2,  19},     /* D1L */
-	{160, 175, 84, 102,  8 * 2,  19},     /* D1R */
-	{96, 127, 92, 119, 16 * 2,  28}},   /* D1C */
-	{{80,  83, 49,  53,  8 * 2,   5},     /* D3L */
-	{140, 143, 49,  53,  8 * 2,   5},     /* D3R */
-	{16,  29, 50,  61,  8 * 2,  12},     /* D3L */
-	{106, 119, 50,  61,  8 * 2,  12},     /* D3C */
-	{187, 200, 50,  61,  8 * 2,  12},     /* D3R */
-	{67,  77, 53,  62,  8 * 2,  10},     /* D2L */
-	{146, 156, 53,  62,  8 * 2,  10},     /* D2R */
-	{0,  17, 55,  72, 16 * 2,  18},     /* D2L */
-	{100, 121, 55,  72, 16 * 2,  18},     /* D2C */
-	{206, 223, 55,  72, 16 * 2,  18},     /* D2R */
-	{48,  63, 57,  75,  8 * 2,  19},     /* D1L */
-	{160, 175, 57,  75,  8 * 2,  19},     /* D1R */
-	{96, 127, 64,  91, 16 * 2,  28}},   /* D1C */
-	{{75,  90, 40,  44,  8 * 2,   5},     /* D3L */
-	{133, 148, 40,  44,  8 * 2,   5},     /* D3R */
-	{1,  48, 44,  49, 24 * 2,   6},     /* D3L */
-	{88, 135, 44,  49, 24 * 2,   6},     /* D3C */
-	{171, 218, 44,  49, 24 * 2,   6},     /* D3R */
-	{60,  77, 40,  46, 16 * 2,   7},     /* D2L */
-	{146, 163, 40,  46, 16 * 2,   7},     /* D2R */
-	{0,  35, 43,  50, 32 * 2,   8},     /* D2L */
-	{80, 143, 43,  50, 32 * 2,   8},     /* D2C */
-	{184, 223, 43,  50, 32 * 2,   8},     /* D2R */
-	{32,  63, 41,  52, 16 * 2,  12},     /* D1L */
-	{160, 191, 41,  52, 16 * 2,  12},     /* D1R */
-	{64, 159, 41,  52, 48 * 2,  12}},   /* D1C */
-	{{78,  85, 36,  51,  8 * 2,  16},     /* D3L */
-	{138, 145, 36,  51,  8 * 2,  16},     /* D3R */
-	{10,  41, 34,  53, 16 * 2,  20},     /* D3L */
-	{98, 129, 34,  53, 16 * 2,  20},     /* D3C */
-	{179, 210, 34,  53, 16 * 2,  20},     /* D3R */
-	{66,  75, 34,  56,  8 * 2,  23},     /* D2L */
-	{148, 157, 34,  56,  8 * 2,  23},     /* D2R */
-	{0,  26, 33,  61, 24 * 2,  29},     /* D2L */
-	{91, 133, 33,  61, 24 * 2,  29},     /* D2C */
-	{194, 223, 33,  61, 24 * 2,  29},     /* D2R */
-	{41,  56, 31,  65,  8 * 2,  35},     /* D1L */
-	{167, 182, 31,  65,  8 * 2,  35},     /* D1R */
-	{80, 143, 29,  71, 32 * 2,  43}},   /* D1C */
-	{{75,  82, 25,  75,  8 * 2,  51},     /* D3L */
-	{142, 149, 25,  75,  8 * 2,  51},     /* D3R */
-	{12,  60, 25,  75, 32 * 2,  51},     /* D3L */
-	{88, 136, 25,  75, 32 * 2,  51},     /* D3C */
-	{163, 211, 25,  75, 32 * 2,  51},     /* D3R */
-	{64,  73, 20,  90,  8 * 2,  71},     /* D2L */
-	{150, 159, 20,  90,  8 * 2,  71},     /* D2R */
-	{0,  38, 20,  90, 32 * 2,  71},     /* D2L */
-	{82, 142, 20,  90, 32 * 2,  71},     /* D2C */
-	{184, 223, 20,  90, 32 * 2,  71},     /* D2R */
-	{41,  56,  9, 119,  8 * 2, 111},     /* D1L */
-	{169, 184,  9, 119,  8 * 2, 111},     /* D1R */
-	{64, 159,  9, 119, 48 * 2, 111}},   /* D1C */
-	{{74,  85, 25,  75,  8 * 2,  51},     /* D3L */
-	{137, 149, 25,  75,  8 * 2,  51},     /* D3R */
-	{0,  75, 25,  75, 40 * 2,  51},     /* D3L Atari ST: {   0,  83, 25,  75, 48*2,  51 } */
-	{74, 149, 25,  75, 40 * 2,  51},     /* D3C Atari ST: {  74, 149, 25,  75, 48*2,  51 } */
-	{148, 223, 25,  75, 40 * 2,  51},     /* D3R Atari ST: { 139, 223, 25,  75, 48*2,  51 } */
-	{60,  77, 20,  90, 16 * 2,  71},     /* D2L */
-	{146, 163, 20,  90, 16 * 2,  71},     /* D2R */
-	{0,  74, 20,  90, 56 * 2,  71},     /* D2L */
-	{60, 163, 20,  90, 56 * 2,  71},     /* D2C */
-	{149, 223, 20,  90, 56 * 2,  71},     /* D2R */
-	{32,  63,  9, 119, 16 * 2, 111},     /* D1L */
-	{160, 191,  9, 119, 16 * 2, 111},     /* D1R */
-	{32, 191,  9, 119, 80 * 2, 111}}}; /* D1C */
+										   /* { X1, X2, Y1, Y2, PixelWidth, Height } */
+	{{80,  83, 41,  45,  8,   5},     /* D3L */
+	{140, 143, 41,  45,  8,   5},     /* D3R */
+	{16,  29, 39,  50,  8,  12},     /* D3L */
+	{107, 120, 39,  50,  8,  12},     /* D3C */
+	{187, 200, 39,  50,  8,  12},     /* D3R */
+	{67,  77, 40,  49,  8,  10},     /* D2L */
+	{146, 156, 40,  49,  8,  10},     /* D2R */
+	{0,  17, 38,  55, 16,  18},     /* D2L */
+	{102, 123, 38,  55, 16,  18},     /* D2C */
+	{206, 223, 38,  55, 16,  18},     /* D2R */
+	{48,  63, 38,  56,  8,  19},     /* D1L */
+	{160, 175, 38,  56,  8,  19},     /* D1R */
+	{96, 127, 36,  63, 16,  28}},   /* D1C */
+	{{74,  82, 41,  60,  8,  20},     /* D3L */
+	{141, 149, 41,  60,  8,  20},     /* D3R */
+	{1,  47, 37,  63, 24,  27},     /* D3L */
+	{88, 134, 37,  63, 24,  27},     /* D3C */
+	{171, 217, 37,  63, 24,  27},     /* D3R */
+	{61,  76, 38,  67,  8,  30},     /* D2L */
+	{147, 162, 38,  67,  8,  30},     /* D2R */
+	{0,  43, 37,  73, 32,  37},     /* D2L */
+	{80, 143, 37,  73, 32,  37},     /* D2C */
+	{180, 223, 37,  73, 32,  37},     /* D2R */
+	{32,  63, 36,  83, 16,  48},     /* D1L */
+	{160, 191, 36,  83, 16,  48},     /* D1R */
+	{64, 159, 36,  91, 48,  56}},   /* D1C */
+	{{80,  83, 66,  70,  8,   5},     /* D3L */
+	{140, 143, 66,  70,  8,   5},     /* D3R */
+	{16,  29, 64,  75,  8,  12},     /* D3L */
+	{106, 119, 64,  75,  8,  12},     /* D3C */
+	{187, 200, 64,  75,  8,  12},     /* D3R */
+	{67,  77, 74,  83,  8,  10},     /* D2L */
+	{146, 156, 74,  83,  8,  10},     /* D2R */
+	{0,  17, 73,  90, 16,  18},     /* D2L */
+	{100, 121, 73,  90, 16,  18},     /* D2C */
+	{206, 223, 73,  90, 16,  18},     /* D2R */
+	{48,  63, 84, 102,  8,  19},     /* D1L */
+	{160, 175, 84, 102,  8,  19},     /* D1R */
+	{96, 127, 92, 119, 16,  28}},   /* D1C */
+	{{80,  83, 49,  53,  8,   5},     /* D3L */
+	{140, 143, 49,  53,  8,   5},     /* D3R */
+	{16,  29, 50,  61,  8,  12},     /* D3L */
+	{106, 119, 50,  61,  8,  12},     /* D3C */
+	{187, 200, 50,  61,  8,  12},     /* D3R */
+	{67,  77, 53,  62,  8,  10},     /* D2L */
+	{146, 156, 53,  62,  8,  10},     /* D2R */
+	{0,  17, 55,  72, 16,  18},     /* D2L */
+	{100, 121, 55,  72, 16,  18},     /* D2C */
+	{206, 223, 55,  72, 16,  18},     /* D2R */
+	{48,  63, 57,  75,  8,  19},     /* D1L */
+	{160, 175, 57,  75,  8,  19},     /* D1R */
+	{96, 127, 64,  91, 16,  28}},   /* D1C */
+	{{75,  90, 40,  44,  8,   5},     /* D3L */
+	{133, 148, 40,  44,  8,   5},     /* D3R */
+	{1,  48, 44,  49, 24,   6},     /* D3L */
+	{88, 135, 44,  49, 24,   6},     /* D3C */
+	{171, 218, 44,  49, 24,   6},     /* D3R */
+	{60,  77, 40,  46, 16,   7},     /* D2L */
+	{146, 163, 40,  46, 16,   7},     /* D2R */
+	{0,  35, 43,  50, 32,   8},     /* D2L */
+	{80, 143, 43,  50, 32,   8},     /* D2C */
+	{184, 223, 43,  50, 32,   8},     /* D2R */
+	{32,  63, 41,  52, 16,  12},     /* D1L */
+	{160, 191, 41,  52, 16,  12},     /* D1R */
+	{64, 159, 41,  52, 48,  12}},   /* D1C */
+	{{78,  85, 36,  51,  8,  16},     /* D3L */
+	{138, 145, 36,  51,  8,  16},     /* D3R */
+	{10,  41, 34,  53, 16,  20},     /* D3L */
+	{98, 129, 34,  53, 16,  20},     /* D3C */
+	{179, 210, 34,  53, 16,  20},     /* D3R */
+	{66,  75, 34,  56,  8,  23},     /* D2L */
+	{148, 157, 34,  56,  8,  23},     /* D2R */
+	{0,  26, 33,  61, 24,  29},     /* D2L */
+	{91, 133, 33,  61, 24,  29},     /* D2C */
+	{194, 223, 33,  61, 24,  29},     /* D2R */
+	{41,  56, 31,  65,  8,  35},     /* D1L */
+	{167, 182, 31,  65,  8,  35},     /* D1R */
+	{80, 143, 29,  71, 32,  43}},   /* D1C */
+	{{75,  82, 25,  75,  8,  51},     /* D3L */
+	{142, 149, 25,  75,  8,  51},     /* D3R */
+	{12,  60, 25,  75, 32,  51},     /* D3L */
+	{88, 136, 25,  75, 32,  51},     /* D3C */
+	{163, 211, 25,  75, 32,  51},     /* D3R */
+	{64,  73, 20,  90,  8,  71},     /* D2L */
+	{150, 159, 20,  90,  8,  71},     /* D2R */
+	{0,  38, 20,  90, 32,  71},     /* D2L */
+	{82, 142, 20,  90, 32,  71},     /* D2C */
+	{184, 223, 20,  90, 32,  71},     /* D2R */
+	{41,  56,  9, 119,  8, 111},     /* D1L */
+	{169, 184,  9, 119,  8, 111},     /* D1R */
+	{64, 159,  9, 119, 48, 111}},   /* D1C */
+	{{74,  85, 25,  75,  8,  51},     /* D3L */
+	{137, 149, 25,  75,  8,  51},     /* D3R */
+	{0,  75, 25,  75, 40,  51},     /* D3L Atari ST: {   0,  83, 25,  75, 48*2,  51 } */
+	{74, 149, 25,  75, 40,  51},     /* D3C Atari ST: {  74, 149, 25,  75, 48*2,  51 } */
+	{148, 223, 25,  75, 40,  51},     /* D3R Atari ST: { 139, 223, 25,  75, 48*2,  51 } */
+	{60,  77, 20,  90, 16,  71},     /* D2L */
+	{146, 163, 20,  90, 16,  71},     /* D2R */
+	{0,  74, 20,  90, 56,  71},     /* D2L */
+	{60, 163, 20,  90, 56,  71},     /* D2C */
+	{149, 223, 20,  90, 56,  71},     /* D2R */
+	{32,  63,  9, 119, 16, 111},     /* D1L */
+	{160, 191,  9, 119, 16, 111},     /* D1R */
+	{32, 191,  9, 119, 80, 111}}}; /* D1C */
 
 byte g194_WallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoordinateSetIndices
 	1,   /* Wall Ornament 00 Unreadable Inscription */
@@ -531,7 +531,6 @@ ProjectileAspect g210_ProjectileAspect[k14_ProjectileAspectCount] = { // @ G0210
 	ProjectileAspect(31, 156, 16, 24, 0x0103) /* Explosion Poison Bolt Poison Cloud */
 };
 
-// TODO: this is ONLY for the Amiga version, name will have to be refactored
 
 /* Identical to the palette at the end of the swoosh palette animation */
 uint16 gK57_PalSwoosh[16] = {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}; // @ K0057_aui_Palette_Swoosh
@@ -780,17 +779,17 @@ void DisplayMan::f460_initializeGraphicData() {
 			_g638_derivedBitmaps[i] = nullptr;
 	}
 
-	_g639_derivedBitmapByteCount[k0_DerivedBitmapViewport] = 224 * 136;
-	_g639_derivedBitmapByteCount[k1_DerivedBitmapThievesEyeVisibleArea] = 96 * 95;
-	_g639_derivedBitmapByteCount[k2_DerivedBitmapDamageToCreatureMedium] = 64 * 37;
-	_g639_derivedBitmapByteCount[k3_DerivedBitmapDamageToCreatureSmall] = 48 * 37;
+	_g639_derivedBitmapByteCount[k0_DerivedBitmapViewport] = 112 * 136;
+	_g639_derivedBitmapByteCount[k1_DerivedBitmapThievesEyeVisibleArea] = 48 * 95;
+	_g639_derivedBitmapByteCount[k2_DerivedBitmapDamageToCreatureMedium] = 32 * 37;
+	_g639_derivedBitmapByteCount[k3_DerivedBitmapDamageToCreatureSmall] = 24 * 37;
 
 	for (int16 doorOrnamentIndex = k15_DoorOrnDestroyedMask; doorOrnamentIndex <= k16_DoorOrnThivesEyeMask; doorOrnamentIndex++) {
 		_g103_currMapDoorOrnInfo[doorOrnamentIndex][k0_NativeBitmapIndex] = doorOrnamentIndex + (k301_DoorMaskDestroyedIndice - k15_DoorOrnDestroyedMask);
 		_g103_currMapDoorOrnInfo[doorOrnamentIndex][k1_CoordinateSet] = 1;
 
-		_g639_derivedBitmapByteCount[doorOrnamentIndex * 2 + k68_DerivedBitmapFirstDoorOrnament_D3] = 48 * 41;
-		_g639_derivedBitmapByteCount[doorOrnamentIndex * 2 + k69_DerivedBitmapFirstDoorOrnament_D2] = 64 * 61;
+		_g639_derivedBitmapByteCount[doorOrnamentIndex * 2 + k68_DerivedBitmapFirstDoorOrnament_D3] = 24 * 41;
+		_g639_derivedBitmapByteCount[doorOrnamentIndex * 2 + k69_DerivedBitmapFirstDoorOrnament_D2] = 32 * 61;
 	}
 
 	_g102_currMapFloorOrnInfo[k15_FloorOrnFootprints][k0_NativeBitmapIndex] = k241_FloorOrn_15_D3L_footprints;
@@ -801,8 +800,8 @@ void DisplayMan::f460_initializeGraphicData() {
 	for (int16 objectAspectIndex = 0; objectAspectIndex < k85_ObjAspectCount; ++objectAspectIndex, ++objectAspect) {
 		derivedBitmapIndex = k104_DerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex;
 
-		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k16_Scale_D3);
-		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k20_Scale_D2);
+		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(objectAspect->_byteWidth, objectAspect->_height, k16_Scale_D3);
+		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(objectAspect->_byteWidth, objectAspect->_height, k20_Scale_D2);
 
 		if (getFlag(objectAspect->_graphicInfo, k0x0001_ObjectFlipOnRightMask)) {
 			_g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2];
@@ -825,14 +824,14 @@ void DisplayMan::f460_initializeGraphicData() {
 			derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + projectileAspect->_firstDerivedBitmapRelativeIndex;
 
 			for (int16 projectileScaleIndex = 0; projectileScaleIndex < 6; projectileScaleIndex++) {
-				int16 bitmapPixelCount = f459_getScaledBitmapPixelCount(projectileAspect->_width, projectileAspect->_height, g215_ProjectileScales[projectileScaleIndex]);
-				_g639_derivedBitmapByteCount[derivedBitmapIndex] = bitmapPixelCount;
+				int16 bitmapByteCount = f459_getScaledBitmapByteCount(projectileAspect->_byteWidth, projectileAspect->_height, g215_ProjectileScales[projectileScaleIndex]);
+				_g639_derivedBitmapByteCount[derivedBitmapIndex] = bitmapByteCount;
 
 				if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k3_ProjectileAspectHasNone) {
-					_g639_derivedBitmapByteCount[derivedBitmapIndex + 6] = bitmapPixelCount;
+					_g639_derivedBitmapByteCount[derivedBitmapIndex + 6] = bitmapByteCount;
 
 					if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k2_ProjectileAspectHasRotation) {
-						_g639_derivedBitmapByteCount[derivedBitmapIndex + 12] = bitmapPixelCount;
+						_g639_derivedBitmapByteCount[derivedBitmapIndex + 12] = bitmapByteCount;
 					}
 				}
 			}
@@ -847,10 +846,10 @@ void DisplayMan::f460_initializeGraphicData() {
 	ExplosionAspect *expAsp = g211_ExplosionAspects;
 	for (uint16 expAspIndex = 0; expAspIndex < k4_ExplosionAspectCount; ++expAspIndex, expAsp++) {
 		for (int16 scale = 4; scale < 32; scale += 2)
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(expAsp->_pixelWidth, expAsp->_height, scale);
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(expAsp->_byteWidth, expAsp->_height, scale);
 
 		if (expAspIndex == k3_ExplosionAspectSmoke) {
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = expAsp->_pixelWidth * expAsp->_height;
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = expAsp->_byteWidth * expAsp->_height;
 		}
 	}
 
@@ -863,14 +862,16 @@ void DisplayMan::f460_initializeGraphicData() {
 		creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex;
 
 		int16 creatureFrontBitmapD3PixelCount;
-		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
+		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount
+			= f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
 
 		int16 creatureFrontBitmapD2PixelCount;
-		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
+		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount
+			= f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
 
 		if (getFlag(creatureGraphicInfo, k0x0008_CreatureInfoGraphicMaskSide)) {
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k16_Scale_D3);
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k20_Scale_D2);
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k16_Scale_D3);
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k20_Scale_D2);
 		}
 
 		if (getFlag(creatureGraphicInfo, k0x0010_CreatureInfoGraphicMaskBack)) {
@@ -879,16 +880,16 @@ void DisplayMan::f460_initializeGraphicData() {
 		}
 
 		if (getFlag(creatureGraphicInfo, k0x0020_CreatureInfoGraphicMaskAttack)) {
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k16_Scale_D3);
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k20_Scale_D2);
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k16_Scale_D3);
+			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k20_Scale_D2);
 		}
 
 		int16 additionalFronGraphicCount;
 		if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, k0x0003_CreatureInfoGraphicMaskAdditional)) {
 			do {
 				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront;
-				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
-				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
+				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
+				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
 			} while (--additionalFronGraphicCount);
 		}
 	}
@@ -897,9 +898,9 @@ void DisplayMan::f460_initializeGraphicData() {
 void DisplayMan::unpackGraphics() {
 	uint32 unpackedBitmapsSize = 0;
 	for (uint16 i = 0; i <= 20; ++i)
-		unpackedBitmapsSize += getWidth(i) * getHeight(i);
+		unpackedBitmapsSize += getPixelWidth(i) * getPixelHeight(i);
 	for (uint16 i = 22; i <= 532; ++i)
-		unpackedBitmapsSize += getWidth(i) * getHeight(i);
+		unpackedBitmapsSize += getPixelWidth(i) * getPixelHeight(i);
 	unpackedBitmapsSize += (5 + 1) * 6 * 128; // 5 x 6 characters, 128 of them, +1 for convenience padding
 	// graphics items go from 0-20 and 22-532 inclusive, _unpackedItemPos 21 and 22 are there for indexing convenience
 	if (_bitmaps) {
@@ -910,15 +911,15 @@ void DisplayMan::unpackGraphics() {
 	_bitmaps[0] = new byte[unpackedBitmapsSize];
 	f466_loadIntoBitmap(0, _bitmaps[0]);
 	for (uint16 i = 1; i <= 20; ++i) {
-		_bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1);
+		_bitmaps[i] = _bitmaps[i - 1] + getPixelWidth(i - 1) * getPixelHeight(i - 1);
 		f466_loadIntoBitmap(i, _bitmaps[i]);
 	}
-	_bitmaps[22] = _bitmaps[20] + getWidth(20) * getHeight(20);
+	_bitmaps[22] = _bitmaps[20] + getPixelWidth(20) * getPixelHeight(20);
 	for (uint16 i = 23; i <= 532; ++i) {
-		_bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1);
+		_bitmaps[i] = _bitmaps[i - 1] + getPixelWidth(i - 1) * getPixelHeight(i - 1);
 		f466_loadIntoBitmap(i, _bitmaps[i]);
 	}
-	_bitmaps[k557_FontGraphicIndice] = _bitmaps[532] + getWidth(532) * getHeight(532);
+	_bitmaps[k557_FontGraphicIndice] = _bitmaps[532] + getPixelWidth(532) * getPixelHeight(532);
 	loadFNT1intoBitmap(k557_FontGraphicIndice, _bitmaps[k557_FontGraphicIndice]);
 }
 
@@ -955,7 +956,7 @@ void DisplayMan::f566_viewportBlitToScreen() {
 	warning("MISSING FUNCTIONALITY: using correct colorpalette");
 	Box box(0, 223, 33, 33 + 135);
 
-	f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport * 2, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
+	f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport, k160_byteWidthScreen, k255_ColorNoTransparency);
 }
 
 void DisplayMan::loadPalette(uint16 *palette) {
@@ -1017,10 +1018,12 @@ void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) {
 	}
 }
 
-void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth,
-								   uint16 destWidth, Color transparent, int16 srcHeight, int16 destHight) {
+void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
+								   uint16 destByteWidth, Color transparent, int16 srcHeight, int16 destHight) {
 				// Note: if you want to use srcHeight and destHight parameters, remove the defaults values and 
 				// and complete the function calls at the callsites, otherwise their value can be the default -1
+	uint16 srcWidth = srcByteWidth * 2;
+	uint16 destWidth = destByteWidth * 2;
 	for (uint16 y = 0; y < box._y2 + 1 - box._y1; ++y) // + 1 for inclusive boundaries
 		for (uint16 x = 0; x < box._x2 + 1 - box._x1; ++x) { // + 1 for inclusive boundaries
 			byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x];
@@ -1035,13 +1038,13 @@ void DisplayMan::D24_fillScreenBox(Box &box, Color color) {
 		memset(_g348_bitmapScreen + y * _screenWidth + box._x1, color, sizeof(byte) * width);
 }
 
-void DisplayMan::f135_fillBoxBitmap(byte* destBitmap, Box &box, Color color, int16 pixelWidth, int16 height) {
+void DisplayMan::f135_fillBoxBitmap(byte* destBitmap, Box &box, Color color, int16 byteWidth, int16 height) {
 	for (int16 y = box._y1; y < box._y2 + 1; ++y) // + 1 for inclusive boundaries
-		memset(destBitmap + y * pixelWidth + box._x1, color, sizeof(byte) * (box._x2 - box._x1 + 1)); // + 1 for inclusive boundaries
+		memset(destBitmap + y * byteWidth * 2 + box._x1, color, sizeof(byte) * (box._x2 - box._x1 + 1)); // + 1 for inclusive boundaries
 }
 
 void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box,
-													int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
+													int16 lastUnitIndex, int16 firstUnitIndex, int16 destByteWidth, Color transparent,
 													int16 xPos, int16 yPos, int16 destHeight, int16 height2) {
 		 // make sure to take care of inclusive boundaries
 	warning("STUB FUNCTION: does nothing at all");
@@ -1049,7 +1052,8 @@ void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte*
 
 
 
-void DisplayMan::f130_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) {
+void DisplayMan::f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height) {
+	uint16 width = byteWidth * 2;
 	for (uint16 y = 0; y < height; ++y) {
 		for (uint16 x = 0; x < width / 2; ++x) {
 			byte tmp;
@@ -1060,7 +1064,8 @@ void DisplayMan::f130_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 he
 	}
 }
 
-void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) {
+void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 byteWidth, uint16 height) {
+	uint16 width = byteWidth * 2;
 	byte *tmp = new byte[width];
 
 	for (uint16 y = 0; y < height / 2; ++y) {
@@ -1072,27 +1077,27 @@ void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) {
 	delete[] tmp;
 }
 
-byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnPixelWidth, int16& returnHeight) {
+byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnByteWidth, int16& returnHeight) {
 	ExplosionAspect *explAsp = &g211_ExplosionAspects[explosionAspIndex];
 	if (scale > 32)
 		scale = 32;
-	int16 pixelWidth = M78_getScaledDimension(explAsp->_pixelWidth, scale);
+	int16 pixelWidth = M78_getScaledDimension(explAsp->_byteWidth, scale);
 	int16 height = M78_getScaledDimension(explAsp->_height, scale);
 	byte *bitmap;
 	int16 derBitmapIndex = (explosionAspIndex * 14) + scale / 2 + k438_DerivedBitmapFirstExplosion - 2;
 	if ((scale == 32) && (explosionAspIndex != k3_ExplosionAspectSmoke)) {
-		bitmap = f489_getBitmap(explosionAspIndex + k348_FirstExplosionGraphicIndice);
+		bitmap = f489_getNativeBitmapOrGraphic(explosionAspIndex + k348_FirstExplosionGraphicIndice);
 	} else if (f491_isDerivedBitmapInCache(derBitmapIndex)) {
 		bitmap = f492_getDerivedBitmap(derBitmapIndex);
 	} else {
-		byte *nativeBitmap = f489_getBitmap(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice);
+		byte *nativeBitmap = f489_getNativeBitmapOrGraphic(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice);
 		bitmap = f492_getDerivedBitmap(derBitmapIndex);
-		f129_blitToBitmapShrinkWithPalChange(nativeBitmap, bitmap, explAsp->_pixelWidth, explAsp->_height, pixelWidth, height,
+		f129_blitToBitmapShrinkWithPalChange(nativeBitmap, bitmap, explAsp->_byteWidth, explAsp->_height, pixelWidth * 2, height,
 			(explosionAspIndex == k3_ExplosionAspectSmoke) ? g212_PalChangeSmoke : g17_PalChangesNoChanges);
-		warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+		f493_addDerivedBitmap(derBitmapIndex);
 	}
 
-	returnPixelWidth = pixelWidth;
+	returnByteWidth = pixelWidth;
 	returnHeight = height;
 	return bitmap;
 }
@@ -1137,30 +1142,30 @@ byte *DisplayMan::getCurrentVgaBuffer() {
 	return _g348_bitmapScreen;
 }
 
-uint16 DisplayMan::getWidth(uint16 index) {
+uint16 DisplayMan::getPixelWidth(uint16 index) {
 	byte *data = _packedBitmaps + _packedItemPos[index];
 	return READ_BE_UINT16(data);
 }
 
-uint16 DisplayMan::getHeight(uint16 index) {
+uint16 DisplayMan::getPixelHeight(uint16 index) {
 	uint8 *data = _packedBitmaps + _packedItemPos[index];
 	return READ_BE_UINT16(data + 2);
 }
 
 // Note: has been screened for missing code
-void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitmap, uint16 pixelWidth, uint16 height) {
-	memmove(destBitmap, srcBitmap, pixelWidth * height * sizeof(byte));
-	f130_flipBitmapHorizontal(destBitmap, pixelWidth, height);
+void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitmap, uint16 byteWidth, uint16 height) {
+	memmove(destBitmap, srcBitmap, byteWidth * 2 * height * sizeof(byte));
+	f130_flipBitmapHorizontal(destBitmap, byteWidth, height);
 }
 
 void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
-	if (f._srcWidth)
-		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k255_ColorNoTransparency);
+	if (f._srcByteWidth)
+		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency);
 }
 
 void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) {
-	if (f._srcWidth)
-		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k10_ColorFlesh);
+	if (f._srcByteWidth)
+		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh);
 }
 
 
@@ -1495,7 +1500,7 @@ void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) {
 
 	if (_g76_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1) {
 		f100_drawWallSetBitmap(_g85_bitmapCeiling, gK12_CeilingFrame);
-		f99_copyBitmapAndFlipHorizontal(_g84_bitmapFloor, _g74_tmpBitmap, k112_byteWidthViewport * 2, 70);
+		f99_copyBitmapAndFlipHorizontal(_g84_bitmapFloor, _g74_tmpBitmap, k112_byteWidthViewport, 70);
 		f100_drawWallSetBitmap(_g74_tmpBitmap, gK13_FloorFrame);
 
 		if (flippedFloorCeiling) {
@@ -1506,7 +1511,7 @@ void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) {
 			_g702_bitmapWallSet_Wall_D0R = _g94_bitmapWall_D0R_Flipped;
 		}
 	} else {
-		f99_copyBitmapAndFlipHorizontal(_g85_bitmapCeiling, _g74_tmpBitmap, k112_byteWidthViewport * 2, 29);
+		f99_copyBitmapAndFlipHorizontal(_g85_bitmapCeiling, _g74_tmpBitmap, k112_byteWidthViewport, 29);
 		f100_drawWallSetBitmap(_g74_tmpBitmap, gK12_CeilingFrame);
 		f100_drawWallSetBitmap(_g84_bitmapFloor, gK13_FloorFrame);
 	}
@@ -1566,7 +1571,8 @@ void DisplayMan::fillScreen(Color color) {
 	memset(getCurrentVgaBuffer(), color, sizeof(byte) * _screenWidth * _screenHeight);
 }
 
-void DisplayMan::f134_fillBitmap(byte *bitmap, Color color, uint16 width, uint16 height) {
+void DisplayMan::f134_fillBitmap(byte *bitmap, Color color, uint16 byteWidth, uint16 height) {
+	uint16 width = byteWidth * 2;
 	memset(bitmap, color, sizeof(byte) * width * height);
 }
 
@@ -1605,9 +1611,9 @@ void DisplayMan::f95_loadWallSet(WallSet set) {
 			f466_loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2);
 		}
 		f99_copyBitmapAndFlipHorizontal(_g708_bitmapWallSet_DoorFrameLeft_D1C, _g710_bitmapWallSet_DoorFrameRight_D1C,
-										g171_Frame_DoorFrameRight_D1C._srcWidth, g171_Frame_DoorFrameRight_D1C._srcHeight);
+										g171_Frame_DoorFrameRight_D1C._srcByteWidth, g171_Frame_DoorFrameRight_D1C._srcHeight);
 		f99_copyBitmapAndFlipHorizontal(_g697_bitmapWallSet_Wall_D3L2, _g696_bitmapWallSet_Wall_D3R2,
-										g712_FrameWall_D3R2._srcWidth, g712_FrameWall_D3R2._srcHeight);
+										g712_FrameWall_D3R2._srcByteWidth, g712_FrameWall_D3R2._srcHeight);
 	}
 }
 
@@ -1621,21 +1627,21 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 		_g578_useByteBoxCoordinates = true;
 
 		f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap,
-										g163_FrameWalls[k0_ViewSquare_D3C]._srcWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight);
-		f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, k10_ColorFlesh, 128, 51);
-		f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, g161_BoxWallBitmap_D3LCR, 11, 0, 128, 128, k255_ColorNoTransparency);
+										g163_FrameWalls[k0_ViewSquare_D3C]._srcByteWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight);
+		f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, k10_ColorFlesh, 64, 51);
+		f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, g161_BoxWallBitmap_D3LCR, 11, 0, 64, 64, k255_ColorNoTransparency);
 
 		f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap,
-										g163_FrameWalls[k3_ViewSquare_D2C]._srcWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight);
-		f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, k10_ColorFlesh, 144, 71);
-		f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, g162_BoxWallBitmap_D2LCR, 8, 0, 144, 144, k255_ColorNoTransparency);
+										g163_FrameWalls[k3_ViewSquare_D2C]._srcByteWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight);
+		f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, k10_ColorFlesh, 72, 71);
+		f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, g162_BoxWallBitmap_D2LCR, 8, 0, 72, 72, k255_ColorNoTransparency);
 
 		f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped,
-										g163_FrameWalls[k6_ViewSquare_D1C]._srcWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight);
+										g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight);
 		f99_copyBitmapAndFlipHorizontal(_g98_bitmapWall_D0L_Native = _g701_bitmapWallSet_Wall_D0L, _g94_bitmapWall_D0R_Flipped,
-										g163_FrameWalls[k10_ViewSquare_D0L]._srcWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight);
+										g163_FrameWalls[k10_ViewSquare_D0L]._srcByteWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight);
 		f99_copyBitmapAndFlipHorizontal(_g99_bitmapWall_D0R_Native = _g702_bitmapWallSet_Wall_D0R, _g93_bitmapWall_D0L_Flipped,
-										g163_FrameWalls[k10_ViewSquare_D0L]._srcWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight);
+										g163_FrameWalls[k10_ViewSquare_D0L]._srcByteWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight);
 	}
 
 
@@ -1734,14 +1740,14 @@ void DisplayMan::f93_applyCreatureReplColors(int replacedColor, int replacementC
 }
 
 void DisplayMan::f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
-	if (f._srcWidth)
-		f132_blitToBitmap(_bitmaps[nativeIndex], _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k10_ColorFlesh);
+	if (f._srcByteWidth)
+		f132_blitToBitmap(_bitmaps[nativeIndex], _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh);
 }
 
 void DisplayMan::f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) {
-	if (f._srcWidth) {
-		f99_copyBitmapAndFlipHorizontal(f489_getBitmap(nativeIndex), _g74_tmpBitmap, f._srcWidth, f._srcHeight);
-		f132_blitToBitmap(_g74_tmpBitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k10_ColorFlesh);
+	if (f._srcByteWidth) {
+		f99_copyBitmapAndFlipHorizontal(f489_getNativeBitmapOrGraphic(nativeIndex), _g74_tmpBitmap, f._srcByteWidth, f._srcHeight);
+		f132_blitToBitmap(_g74_tmpBitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh);
 	}
 }
 
@@ -1807,7 +1813,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 				if (isInscription) {
 					Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C];
 					f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, g202_BoxWallPatchBehindInscription, 94, 28,
-									  D1CFrame._srcWidth, k112_byteWidthViewport * 2, k255_ColorNoTransparency);
+									  D1CFrame._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency);
 
 					unsigned char *string = inscriptionString;
 					bitmapRed = _bitmaps[k120_InscriptionFontIndice];
@@ -1821,7 +1827,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 						frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7;
 						frame._box._y1 = (frame._box._y2 = g203_InscriptionLineY[textLineIndex++]) - 7;
 						while (characterCount--) {
-							f132_blitToBitmap(bitmapRed, _g296_bitmapViewport, frame._box, (*string++) * 8, 0, 288, k112_byteWidthViewport * 2, k10_ColorFlesh);
+							f132_blitToBitmap(bitmapRed, _g296_bitmapViewport, frame._box, (*string++) * 8, 0, 144, k112_byteWidthViewport, k10_ColorFlesh);
 							frame._box._x1 += 8;
 							frame._box._x2 += 8;
 						}
@@ -1899,7 +1905,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 				frame._box._x2 = coordinateSetA[1];
 				frame._box._y1 = coordinateSetA[2];
 				frame._box._y2 = coordinateSetA[3];
-				frame._srcWidth = coordinateSetA[4];
+				frame._srcByteWidth = coordinateSetA[4];
 				frame._srcHeight = coordinateSetA[5];
 
 				coordinateSetA = (uint16*)&frame._box;
@@ -1907,12 +1913,12 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 				coordinateSetA[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
 			}
 		}
-		f132_blitToBitmap(bitmapGreen, _g296_bitmapViewport, *(Box*)coordinateSetA, var_X, 0, coordinateSetA[4], k112_byteWidthViewport * 2, k10_ColorFlesh);
+		f132_blitToBitmap(bitmapGreen, _g296_bitmapViewport, *(Box*)coordinateSetA, var_X, 0, coordinateSetA[4], k112_byteWidthViewport, k10_ColorFlesh);
 
 		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
 			Box &box = g109_BoxChampionPortraitOnWall;
 			f132_blitToBitmap(_bitmaps[k26_ChampionPortraitsIndice], _g296_bitmapViewport, box, (_g289_championPortraitOrdinal & 0x7) << 5,
-				(_g289_championPortraitOrdinal >> 3) * 29, 256, k112_byteWidthViewport * 2, k1_ColorDarkGary);
+				(_g289_championPortraitOrdinal >> 3) * 29, 128, k112_byteWidthViewport, k1_ColorDarkGary);
 		}
 		return isAlcove;
 	}
@@ -1920,22 +1926,22 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 }
 
 
-void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap, int16 srcWidth, int16 srcHeight, int16 destWidth, int16 destHeight, byte *palChange) {
-	double rateW = srcWidth / destWidth;
+void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap, int16 srcPixelWidth, int16 srcHeight, int16 destPixelWidth, int16 destHeight, byte *palChange) {
+	double rateW = srcPixelWidth / destPixelWidth;
 	double rateH = srcHeight / destHeight;
 
 	for (uint16 y = 0; y < destHeight; ++y) {
-		for (uint16 x = 0; x < destWidth; ++x) {
+		for (uint16 x = 0; x < destPixelWidth; ++x) {
 			if (palChange)
-				destBitmap[y * destWidth + x] = palChange[srcBitmap[(int)(y * rateH * srcWidth) + (int)(x * rateW)]];
+				destBitmap[y * destPixelWidth + x] = palChange[srcBitmap[(int)(y * rateH * srcPixelWidth) + (int)(x * rateW)]];
 			else
-				destBitmap[y * destWidth + x] = srcBitmap[(int)(y * rateH * srcWidth) + (int)(x * rateW)];
+				destBitmap[y * destPixelWidth + x] = srcBitmap[(int)(y * rateH * srcPixelWidth) + (int)(x * rateW)];
 		}
 	}
 
 }
 
-byte* DisplayMan::f489_getBitmap(uint16 index) {
+byte* DisplayMan::f489_getNativeBitmapOrGraphic(uint16 index) {
 	return _bitmaps[index];
 }
 
@@ -1960,21 +1966,21 @@ void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) {
 		bitmapMask = nullptr;
 	} else {
 		bitmapMask = dispMan._g74_tmpBitmap;
-		memmove(bitmapMask, dispMan.f489_getBitmap(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)),
-				fieldAspect->_height * fieldAspect->_pixelWidth * sizeof(bitmapMask[0]));
+		memmove(bitmapMask, dispMan.f489_getNativeBitmapOrGraphic(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)),
+				fieldAspect->_height * fieldAspect->_byteWidth * 2 * sizeof(bitmapMask[0]));
 		if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask)) {
-			dispMan.f130_flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height);
+			dispMan.f130_flipBitmapHorizontal(bitmapMask, fieldAspect->_byteWidth, fieldAspect->_height);
 		}
 	}
 
-	byte *bitmap = dispMan.f489_getBitmap(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex);
+	byte *bitmap = dispMan.f489_getNativeBitmapOrGraphic(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex);
 	warning("MISSING CODE: F0133_VIDEO_BlitBoxFilledWithMaskedBitmap");
 
 	warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache, F0493_CACHE_AddDerivedBitmap, F0480_CACHE_ReleaseBlock");
 }
 
-int16 DisplayMan::f459_getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale) {
-	return M78_getScaledDimension(pixelWidth, scale) * M78_getScaledDimension(pixelHeight, scale);
+int16 DisplayMan::f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale) {
+	return M77_getNormalizedByteWidth(M78_getScaledDimension(byteWidth, scale)) * M78_getScaledDimension(height, scale);
 }
 
 int16 DisplayMan::M78_getScaledDimension(int16 dimension, int16 scale) {
@@ -2326,11 +2332,11 @@ T0115015_DrawProjectileAsObject:
 					/* If object is in the center lane (only D0C or D1C with condition above) and is not a projectile */
 					drawingGrabbableObject = (!viewLane && !drawProjectileAsObject);
 					AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
-					AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */
-					byteWidth = objectAspect->_width;
+					AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */
+					byteWidth = objectAspect->_byteWidth;
 					heightRedEagle = objectAspect->_height;
 					if (flipHorizontal) {
-						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
+						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * 2 * heightRedEagle * sizeof(byte));
 						f130_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
@@ -2340,18 +2346,18 @@ T0115015_DrawProjectileAsObject:
 					if ((viewSquareIndex >= k6_ViewSquare_D1C) || ((viewSquareIndex >= k3_ViewSquare_D2C) && (AL_2_viewCell >= k2_ViewCellBackRight))) {
 						derivedBitmapIndex++;
 						AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front;
-						byteWidth = M78_getScaledDimension(objectAspect->_width, k20_Scale_D2);
+						byteWidth = M78_getScaledDimension(objectAspect->_byteWidth, k20_Scale_D2);
 						heightRedEagle = M78_getScaledDimension(objectAspect->_height, k20_Scale_D2);
 						paletteChanges = g214_PalChangesFloorOrn_D2;
 					} else {
 						AL_8_shiftSetIndex = k2_ShiftSet_D2BackD3Front;
-						byteWidth = M78_getScaledDimension(objectAspect->_width, k16_Scale_D3);
+						byteWidth = M78_getScaledDimension(objectAspect->_byteWidth, k16_Scale_D3);
 						heightRedEagle = M78_getScaledDimension(objectAspect->_height, k16_Scale_D3);
 						paletteChanges = g213_PalChangesFloorOrn_D3;
 					}
 					if (flipHorizontal) {
 						derivedBitmapIndex += 2;
-						paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1;
+						paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1;
 					} else if (useAlcoveObjectImage) {
 						derivedBitmapIndex += 4;
 					}
@@ -2359,12 +2365,12 @@ T0115015_DrawProjectileAsObject:
 					if (f491_isDerivedBitmapInCache(derivedBitmapIndex)) {
 						AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 					} else {
-						bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex);
+						bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 						f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex),
-															 objectAspect->_width, objectAspect->_height,
-															 byteWidth, heightRedEagle, paletteChanges);
+															 objectAspect->_byteWidth * 2, objectAspect->_height,
+															 byteWidth * 2, heightRedEagle, paletteChanges);
 						if (flipHorizontal) {
-							f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
+							f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, M77_getNormalizedByteWidth(byteWidth), heightRedEagle);
 						}
 						warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 					}
@@ -2413,14 +2419,14 @@ T0115015_DrawProjectileAsObject:
 						}
 					} else { /* If there are several grabbable objects then enlarge the box so it includes all objects */
 						AL_6_boxPtrRed->_x1 = MIN(AL_6_boxPtrRed->_x1, boxByteGreen._x1);
-						AL_6_boxPtrRed->_x2 = MIN(AL_6_boxPtrRed->_x2, boxByteGreen._x2);
+						AL_6_boxPtrRed->_x2 = MAX(AL_6_boxPtrRed->_x2, boxByteGreen._x2);
 						AL_6_boxPtrRed->_y1 = MIN(AL_6_boxPtrRed->_y1, boxByteGreen._y1);
-						AL_6_boxPtrRed->_y2 = MIN(AL_6_boxPtrRed->_y2, boxByteGreen._y2);
+						AL_6_boxPtrRed->_y2 = MAX(AL_6_boxPtrRed->_y2, boxByteGreen._y2);
 					}
 					AL_6_bitmapRedBanana = bitmapGreenAnt;
 					dunMan._g292_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */
 				}
-				f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport * 2, k10_ColorFlesh);
+				f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh);
 
 				if (drawProjectileAsObject)
 					goto T0115171_BackFromT0115015_DrawProjectileAsObject;
@@ -2574,17 +2580,17 @@ T0115077_DrawSecondHalfSquareCreature:
 			AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
 			transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour();
 			if (useCreatureSideBitmap) {
-				AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex);
+				AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 				if (creatureDirectionDelta == 1) {
-					memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
+					memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * 2 * heightRedEagle * sizeof(byte));
 					f130_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
 			} else {
 				if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) {
-					AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex);
+					AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 					if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
-						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte));
+						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * 2 * heightRedEagle * sizeof(byte));
 						f130_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
@@ -2592,10 +2598,10 @@ T0115077_DrawSecondHalfSquareCreature:
 					if (f491_isDerivedBitmapInCache(derivedBitmapIndex)) { /* If derived graphic is already in memory */
 						AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 					} else {
-						bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex);
+						bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) {
 							AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
-							memmove(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * heightRedEagle * sizeof(byte));
+							memmove(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * 2 * heightRedEagle * sizeof(byte));
 							f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 						}
 						warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
@@ -2625,9 +2631,9 @@ T0115077_DrawSecondHalfSquareCreature:
 			if (derivedBitmapInCache = f491_isDerivedBitmapInCache(derivedBitmapIndex)) {
 				AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 			} else {
-				bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex);
+				bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 				AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, sourceByteWidth, sourceHeight, byteWidth, heightRedEagle, paletteChanges);
+				f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, sourceByteWidth * 2, sourceHeight, byteWidth * 2, heightRedEagle, paletteChanges);
 				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 			}
 			if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */
@@ -2635,15 +2641,14 @@ T0115077_DrawSecondHalfSquareCreature:
 				(useCreatureSpecialD2FrontBitmap && getFlag(AL_0_creatureGraphicInfoRed, k0x0100_CreatureInfoGraphicMaskSpecialD2FrontIsFlipped)) ||
 				(useFlippedHorizontallyCreatureFrontImage && getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack))) { /* If the graphic should be flipped */
 				if (!useFlippedHorizontallyCreatureFrontImage || !derivedBitmapInCache) {
-					AL_4_normalizdByteWidth = byteWidth;
-					warning("SUPER WARNING: we might need M77_getNormalizedByteWidth");
+					AL_4_normalizdByteWidth = M77_getNormalizedByteWidth(byteWidth);
 					if (!useFlippedHorizontallyCreatureFrontImage) {
-						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte));
+						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * 2 * heightRedEagle * sizeof(byte));
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
 					f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 				}
-				creaturePaddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1;
+				creaturePaddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1;
 			} else {
 				creaturePaddingPixelCount = 0;
 			}
@@ -2651,7 +2656,7 @@ T0115077_DrawSecondHalfSquareCreature:
 		AL_4_yPos = coordinateSet[1];
 		AL_4_yPos += g223_ShiftSets[AL_8_shiftSetIndex][M23_getVerticalOffsetM23(creatureAspectInt)];
 		boxByteGreen._y2 = MIN(AL_4_yPos, (int16)135);
-		boxByteGreen._y1 = MIN(0, AL_4_yPos - (heightRedEagle - 1));
+		boxByteGreen._y1 = MAX(0, AL_4_yPos - (heightRedEagle - 1));
 		AL_4_xPos = coordinateSet[0];
 		AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][M22_getHorizontalOffsetM22(creatureAspectInt)];
 		if (viewLane == k1_ViewLaneLeft) {
@@ -2670,8 +2675,7 @@ T0115077_DrawSecondHalfSquareCreature:
 		} else {
 			AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1);
 		}
-		warning("SUPER WARNINIG: we might nee noralized with on byteWidth");
-		f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_0_creaturePosX, 0, byteWidth, k112_byteWidthViewport * 2, (Color)transparentColor);
+		f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_0_creaturePosX, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, (Color)transparentColor);
 
 T0115126_CreatureNotVisible:
 		if (twoHalfSquareCreaturesFrontView) {
@@ -2703,7 +2707,7 @@ continue;
 					if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask))
 						 || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == k9_ViewSquare_D0C)) {
 						scale = 0; /* Use native bitmap without resizing */
-						byteWidth = ((ProjectileAspect*)objectAspect)->_width;
+						byteWidth = ((ProjectileAspect*)objectAspect)->_byteWidth;
 						heightRedEagle = ((ProjectileAspect*)objectAspect)->_height;
 					} else {
 						AL_8_projectileScaleIndex = ((viewSquareIndex / 3) << 1) + (AL_2_viewCell >> 1);
@@ -2711,7 +2715,7 @@ continue;
 						if (!doNotScaleWithKineticEnergy) {
 							scale = (scale * MAX(96, projectile->_kineticEnergy + 1)) >> 8;
 						}
-						byteWidth = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_width, scale);
+						byteWidth = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_byteWidth, scale);
 						heightRedEagle = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale);
 					}
 					if (projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == k0_ProjectileAspectHasBackGraphicRotation)) {
@@ -2754,33 +2758,32 @@ continue;
 					AL_4_nativeBitmapIndex += projectileBitmapIndexData;
 					paddingPixelCount = 0;
 					if (!scale) {
-						AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex);
+						AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 					} else {
 						if (flipHorizontal) {
-							paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1;
+							paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1;
 						}
 						derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (projectileBitmapIndexData * 6);
 						if (doNotScaleWithKineticEnergy && f491_isDerivedBitmapInCache(derivedBitmapIndex) + AL_8_projectileScaleIndex) {
 							AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 						} else {
-							bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex);
+							bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 							if (doNotScaleWithKineticEnergy) {
 								AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 							} else {
 								AL_6_bitmapRedBanana = _g74_tmpBitmap;
 							}
-							f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height,
-																 byteWidth, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
+							f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_byteWidth * 2, ((ProjectileAspect*)objectAspect)->_height,
+																 byteWidth * 2, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
 							if (doNotScaleWithKineticEnergy) {
 								warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap");
 							}
 						}
 					}
 					if (flipHorizontal || flipVertical) {
-						warning("might need noralized bytewidth");
-						AL_4_normalizdByteWidth = byteWidth;
+						AL_4_normalizdByteWidth = M77_getNormalizedByteWidth(byteWidth);
 						if (AL_6_bitmapRedBanana != _g74_tmpBitmap) {
-							memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte));
+							memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * 2 * heightRedEagle * sizeof(byte));
 							AL_6_bitmapRedBanana = _g74_tmpBitmap;
 						}
 						if (flipVertical) {
@@ -2806,7 +2809,7 @@ the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part
 screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
 						AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - projectilePosX - 1));
 					}
-					f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport * 2, k10_ColorFlesh);
+					f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh);
 				} else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */
 					useAlcoveObjectImage = false;
 					projectileCoordinates[0] = projectilePosX;
@@ -2854,14 +2857,14 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					} else {
 						if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) {
 							objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-dunMan.f142_getProjectileAspect(Thing::_explLightningBolt))];
-							AL_6_bitmapRedBanana = f489_getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
+							AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
 							explosionCoordinates = g228_RebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
-							byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_width), explosionCoordinates[2]);
+							byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_byteWidth), explosionCoordinates[2]);
 							heightRedEagle = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
 							if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) {
 								f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap,
-									((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height,
-																	 byteWidth, heightRedEagle, g17_PalChangesNoChanges);
+									((ProjectileAspect*)objectAspect)->_byteWidth * 2, ((ProjectileAspect*)objectAspect)->_height,
+																	 byteWidth * 2, heightRedEagle, g17_PalChangesNoChanges);
 								AL_6_bitmapRedBanana = _g74_tmpBitmap;
 							}
 							goto T0115200_DrawExplosion;
@@ -2888,7 +2891,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					}
 				}
 				warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache");
-				AL_6_bitmapRedBanana = f489_getBitmap(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice);
+				AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice);
 				if (smoke) {
 					f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, 48, 32, 48, 32, g212_PalChangeSmoke);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
@@ -2920,7 +2923,7 @@ T0115200_DrawExplosion:
 				flipVertical = _vm->_rnd->getRandomNumber(2);
 				paddingPixelCount = 0;
 				if (flipHorizontal = _vm->_rnd->getRandomNumber(2)) {
-					paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; /* Number of unused pixels in the units on the right of the bitmap */
+					paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1; /* Number of unused pixels in the units on the right of the bitmap */
 				}
 				boxByteGreen._y2 = MIN(135, explosionCoordinates[1] + (heightRedEagle >> 1));
 				AL_4_yPos = MAX(0, explosionCoordinates[1] - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001));
@@ -2938,7 +2941,7 @@ T0115200_DrawExplosion:
 left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is not flipped horizontally (flipHorizontal = C0_FALSE) then the
 variable paddingPixelCount is not set before being used here. Its previous value (defined while drawing something else) is used
 and may cause an incorrect bitmap to be drawn */
-					AL_4_xPos = MIN(paddingPixelCount, (int16)(byteWidth / 2 - AL_4_xPos - 1));
+					AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - AL_4_xPos - 1));
 
 /* BUG0_06 Graphical glitch when drawing projectiles or explosions. If a projectile or explosion bitmap is cropped because it is
 only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is flipped horizontally (flipHorizontal = C1_TRUE)
@@ -2946,10 +2949,9 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP
 				}
 				if (boxByteGreen._x2 <= boxByteGreen._x1)
 					continue;
-				warning("might need M77_NORMALIZED_BYTE_WIDTH");
-				byteWidth = byteWidth;
+				byteWidth = M77_getNormalizedByteWidth(byteWidth);
 				if (flipHorizontal || flipVertical) {
-					memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle);
+					memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * 2 * heightRedEagle);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
 				if (flipHorizontal) {
@@ -2958,7 +2960,7 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP
 				if (flipVertical) {
 					flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 				}
-				f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport * 2, k10_ColorFlesh);
+				f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport, k10_ColorFlesh);
 			}
 		}
 	} while ((thingParam = dunMan.f159_getNextThing(thingParam)) != Thing::_endOfList);
@@ -2996,5 +2998,8 @@ byte* DisplayMan::f492_getDerivedBitmap(int16 derivedBitmapIndex) {
 	return _g638_derivedBitmaps[derivedBitmapIndex];
 }
 
+void DisplayMan::f493_addDerivedBitmap(int16 derivedBitmapIndex) {
+	warning("f493_addDerivedBitmap DOES NOTHING");
+}
 
 }
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 282dfc2..50a6d5e 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -111,10 +111,10 @@ namespace DM {
 
 class ExplosionAspect {
 public:
-	uint16 _pixelWidth;
+	uint16 _byteWidth;
 	uint16 _height;
 
-	ExplosionAspect(uint16 byteWidth, uint16 height) :_pixelWidth(byteWidth * 2), _height(height) {}
+	ExplosionAspect(uint16 byteWidth, uint16 height) :_byteWidth(byteWidth), _height(height) {}
 }; // @ EXPLOSION_ASPECT
 
 extern ExplosionAspect g211_ExplosionAspects[k4_ExplosionAspectCount]; // @ G0211_as_Graphic558_ExplosionAspects
@@ -252,14 +252,14 @@ extern Box g2_BoxMovementArrows; // @ G0002_s_Graphic562_Box_MovementArrows
 class Frame {
 public:
 	Box _box;
-	uint16 _srcWidth, _srcHeight;
+	uint16 _srcByteWidth, _srcHeight;
 	uint16 _srcX, _srcY;
 
 	Frame() {}
 	Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY,
 		  uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) :
 		_box(destFromX, destToX, destFromY, destToY),
-		_srcWidth(srcWidth * 2), _srcHeight(srcHeight), _srcX(srcX), _srcY(srcY) {}
+		_srcByteWidth(srcWidth), _srcHeight(srcHeight), _srcX(srcX), _srcY(srcY) {}
 };
 
 enum WallSet {
@@ -312,13 +312,13 @@ public:
 	uint16 _baseStartUnitIndex; /* Index of the unit (16 pixels = 8 bytes) in bitmap where blit will start from. A random value of 0 or 1 is added to this base index */
 	uint16 _transparentColor; /* Bit 7: Do not use mask if set, Bits 6-0: Transparent color index. 0xFF = no transparency */
 	byte _mask; /* Bit 7: Flip, Bits 6-0: Mask index. 0xFF = no mask */
-	uint16 _pixelWidth;
+	uint16 _byteWidth;
 	uint16 _height;
 	uint16 _xPos;
 	uint16 _bitplaneWordCount;
 	FieldAspect(uint16 native, uint16 base, uint16 transparent, byte mask, uint16 byteWidth, uint16 height, uint16 xPos, uint16 bitplane)
 		: _nativeBitmapRelativeIndex(native), _baseStartUnitIndex(base), _transparentColor(transparent), _mask(mask),
-		_pixelWidth(byteWidth * 2), _height(height), _xPos(xPos), _bitplaneWordCount(bitplane) {}
+		_byteWidth(byteWidth), _height(height), _xPos(xPos), _bitplaneWordCount(bitplane) {}
 	FieldAspect() {}
 }; // @ FIELD_ASPECT
 
@@ -342,11 +342,11 @@ public:
 	CreatureAspect(uint16 uint161, uint16 uint162, byte byte0, byte byte1, byte byte2, byte byte3, byte byte4, byte byte5, byte byte6, byte byte7)
 		: _firstNativeBitmapRelativeIndex(uint161),
 		_firstDerivedBitmapIndex(uint162),
-		_byteWidthFront(byte0 * 2),
+		_byteWidthFront(byte0),
 		_heightFront(byte1),
-		_byteWidthSide(byte2 * 2),
+		_byteWidthSide(byte2),
 		_heightSide(byte3),
-		_byteWidthAttack(byte4 * 2),
+		_byteWidthAttack(byte4),
 		_heightAttack(byte5),
 		_coordinateSet_TransparentColor(byte6),
 		_replacementColorSetIndices(byte7) {}
@@ -355,34 +355,32 @@ public:
 	byte getTranspColour() { return  _coordinateSet_TransparentColor & 0xF; } // @ M72_TRANSPARENT_COLOR
 	byte getReplColour10() { return (_replacementColorSetIndices >> 4) & 0xF; } // @ M74_COLOR_10_REPLACEMENT_COLOR_SET
 	byte getReplColour9() { return _replacementColorSetIndices & 0xF; } // @ M73_COLOR_09_REPLACEMENT_COLOR_SET
-
-
 }; // @ CREATURE_ASPECT
 
 class ObjectAspect {
 public:
 	byte _firstNativeBitmapRelativeIndex;
 	byte _firstDerivedBitmapRelativeIndex;
-	byte _width;
+	byte _byteWidth;
 	byte _height;
 	byte _graphicInfo; /* Bits 7-5 and 3-1 Unreferenced */
 	byte _coordinateSet;
 	ObjectAspect(byte firstN, byte firstD, byte byteWidth, byte h, byte grap, byte coord) :
 		_firstNativeBitmapRelativeIndex(firstN), _firstDerivedBitmapRelativeIndex(firstD),
-		_width(byteWidth * 2), _height(h), _graphicInfo(grap), _coordinateSet(coord) {}
+		_byteWidth(byteWidth), _height(h), _graphicInfo(grap), _coordinateSet(coord) {}
 }; // @ OBJECT_ASPECT
 
 class ProjectileAspect {
 public:
 	byte _firstNativeBitmapRelativeIndex;
 	byte _firstDerivedBitmapRelativeIndex;
-	byte _width;
+	byte _byteWidth;
 	byte _height;
 	uint16 _graphicInfo; /* Bits 15-9, 7-5 and 3-2 Unreferenced */
 
 	ProjectileAspect(byte firstN, byte firstD, byte byteWidth, byte h, uint16 grap) :
 		_firstNativeBitmapRelativeIndex(firstN), _firstDerivedBitmapRelativeIndex(firstD),
-		_width(byteWidth * 2), _height(h), _graphicInfo(grap) {}
+		_byteWidth(byteWidth), _height(h), _graphicInfo(grap) {}
 }; // @ PROJECTIL_ASPECT
 
 class CreatureReplColorSet {
@@ -541,9 +539,9 @@ public:
 	void f461_allocateFlippedWallBitmaps(); // @ F0461_START_AllocateFlippedWallBitmaps
 
 	/// Gives the width of an IMG0 type item
-	uint16 getWidth(uint16 index);
+	uint16 getPixelWidth(uint16 index);
 	/// Gives the height of an IMG1 type item
-	uint16 getHeight(uint16 index);
+	uint16 getPixelHeight(uint16 index);
 
 
 	void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height);
@@ -553,34 +551,35 @@ public:
 	does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters
 	match the original exatcly, if need arises for heights then we'll have to retrospectively add them in old function calls*/
 	/* Expects inclusive boundaries in box */
-	void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth,
-					  uint16 destWidth, Color transparent = k255_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit
+	void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
+					  uint16 destByteWidth, Color transparent = k255_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit
 /* Expects inclusive boundaries in box */
 	void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
-									   int16 firstUnitIndex, int16 destPixelWidth, Color transparent,
+									   int16 firstUnitIndex, int16 destByteWidth, Color transparent,
 									   int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
+	// this function takes pixel widths
 	void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
-											  int16 srcWidth, int16 srcHight, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
-	void f130_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0130_VIDEO_FlipHorizontal
-	void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height);
-	byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap
+											  int16 srcPixelWidth, int16 srcHight, int16 destPixelWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
+	void f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height); // @ F0130_VIDEO_FlipHorizontal
+	void flipBitmapVertical(byte *bitmap, uint16 byteWidth, uint16 height);
+	byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnByteWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap
 
-	void f134_fillBitmap(byte *bitmap, Color color, uint16 width, uint16 height); // @ F0134_VIDEO_FillBitmap
+	void f134_fillBitmap(byte *bitmap, Color color, uint16 byteWidth, uint16 height); // @ F0134_VIDEO_FillBitmap
 	void fillScreen(Color color);
 	/* Expects inclusive boundaries in box */
 	void D24_fillScreenBox(Box &box, Color color); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox
 /* Expects inclusive boundaries in box */
-	void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 pixelWidth, int16 height); // @ F0135_VIDEO_FillBox
+	void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 byteWidth, int16 height); // @ F0135_VIDEO_FillBox
 	void f128_drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void updateScreen();
 	void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport
 
-	byte* f489_getBitmap(uint16 index); // @ F0489_MEMORY_GetNativeBitmapOrGraphic
+	byte* f489_getNativeBitmapOrGraphic(uint16 index); // @ F0489_MEMORY_GetNativeBitmapOrGraphic
 	Common::MemoryReadStream getCompressedData(uint16 index);
 	uint32 getCompressedDataSize(uint16 index);
 	void f113_drawField(FieldAspect *fieldAspect, Box &box); // @ F0113_DUNGEONVIEW_DrawField
 
-	int16 f459_getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount
+	int16 f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale); // @ F0459_START_GetScaledBitmapByteCount
 	int16 M78_getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION
 	void f115_cthulhu(Thing thingParam, direction directionParam,
 				 int16 mapXpos, int16 mapYpos, int16 viewSquareIndex,
@@ -611,6 +610,7 @@ public:
 
 	bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
 	byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap
+	void f493_addDerivedBitmap(int16 derivedBitmapIndex); // @ F0493_CACHE_AddDerivedBitmap
 
 
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 77242c1..1583c6f 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -96,7 +96,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	champion = &cm._gK71_champions[championIndex];
 	dm.f466_loadIntoBitmap(k17_InventoryGraphicIndice, dm._g296_bitmapViewport);
 	if (cm._g299_candidateChampionOrdinal) {
-		dm.f135_fillBoxBitmap(dm._g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport * 2, k136_heightViewport);
+		dm.f135_fillBoxBitmap(dm._g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
 	}
 	_vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "HEALTH");
 	_vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
@@ -128,7 +128,7 @@ void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) {
 	box._y2 = 28;
 	box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7;
 	box._x2 = box._x1 + 31;
-	dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, dispMan._g348_bitmapScreen, box, 0, 0, 32, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
+	dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, dispMan._g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen, k255_ColorNoTransparency);
 }
 
 void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
@@ -161,11 +161,11 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
 	Champion &champ = _vm->_championMan->_gK71_champions[_g432_inventoryChampionOrdinal];
 	f334_closeChest();
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 144, k160_byteWidthScreen * 2, k8_ColorRed);
-	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k30_FoodLabelIndice), dispMan._g348_bitmapScreen, g35_BoxFood, 0, 0, 48, k160_byteWidthScreen * 2, k12_ColorDarkestGray);
-	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k31_WaterLabelIndice), dispMan._g348_bitmapScreen, g36_BoxWater, 0, 0, 48, k160_byteWidthScreen * 2, k12_ColorDarkestGray);
+	dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 72, k160_byteWidthScreen, k8_ColorRed);
+	dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k30_FoodLabelIndice), dispMan._g348_bitmapScreen, g35_BoxFood, 0, 0, 24, k160_byteWidthScreen, k12_ColorDarkestGray);
+	dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k31_WaterLabelIndice), dispMan._g348_bitmapScreen, g36_BoxWater, 0, 0, 24, k160_byteWidthScreen, k12_ColorDarkestGray);
 	if (champ._poisonEventCount) {
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k32_PoisionedLabelIndice), dispMan._g348_bitmapScreen, g37_BoxPoisoned, 0, 0, 96, k160_byteWidthScreen * 2, k12_ColorDarkestGray);
+		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k32_PoisionedLabelIndice), dispMan._g348_bitmapScreen, g37_BoxPoisoned, 0, 0, 48, k160_byteWidthScreen, k12_ColorDarkestGray);
 	}
 	f344_drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown);
 	f344_drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue);
@@ -173,7 +173,8 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
 
 void InventoryMan::f346_drawPanelResurrectReincarnate() {
 	_g424_panelContent = k5_PanelContentResurrectReincarnate;
-	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(k40_PanelResurectReincaranteIndice), _vm->_displayMan->_g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k6_ColorDarkGreen);
+	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k40_PanelResurectReincaranteIndice),
+										_vm->_displayMan->_g296_bitmapViewport, g32_BoxPanel, 0, 0, 72, k112_byteWidthViewport, k6_ColorDarkGreen);
 }
 
 void InventoryMan::f347_drawPanel() {
@@ -256,7 +257,7 @@ void InventoryMan::f341_drawPanelScroll(Scroll* scroll) {
 		charRed++;
 	}
 	*charRed = '\0';
-	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k23_PanelOpenScrollIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k8_ColorRed);
+	dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k23_PanelOpenScrollIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 72, k112_byteWidthViewport, k8_ColorRed);
 	int16 lineCount = 1;
 	charRed++;
 	char *charGreen = charRed; // first char of the second line
@@ -308,7 +309,7 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo
 	if (!isPressingEye) {
 		objMan.f38_drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen);
 	}
-	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k25_PanelOpenChestIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 144, k160_byteWidthScreen * 2, k8_ColorRed);
+	dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k25_PanelOpenChestIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 72, k160_byteWidthScreen, k8_ColorRed);
 
 	int16 chestSlotIndex = 0;
 	Thing thing = chest->getSlot();
@@ -334,7 +335,7 @@ void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int
 	box._x2 = (box._x1 = xPos) + 15;
 	box._y2 = (box._y1 = yPos) + 15;
 	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, iconBitmap);
-	_vm->_displayMan->f132_blitToBitmap(iconBitmap, _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport * 2, k255_ColorNoTransparency);
+	_vm->_displayMan->f132_blitToBitmap(iconBitmap, _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 8, k112_byteWidthViewport, k255_ColorNoTransparency);
 }
 
 void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) {
@@ -408,7 +409,8 @@ Box g33_BoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOr
 
 void InventoryMan::f339_drawPanelArrowOrEye(bool pressingEye) {
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice), dispMan._g296_bitmapViewport, g33_BoxArrowOrEye, 0, 0, 16, k112_byteWidthViewport * 2, k8_ColorRed);
+	dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice),
+							  dispMan._g296_bitmapViewport, g33_BoxArrowOrEye, 0, 0, 8, k112_byteWidthViewport, k8_ColorRed);
 }
 
 
@@ -440,8 +442,10 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		f333_openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye);
 	} else {
 		IconIndice iconIndex = objMan.f33_getIconIndex(thingToDraw);
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k8_ColorRed);
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k29_ObjectDescCircleIndice), dispMan._g296_bitmapViewport, g34_BoxObjectDescCircle, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray);
+		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), dispMan._g296_bitmapViewport,
+								  g32_BoxPanel, 0, 0, 72, k112_byteWidthViewport, k8_ColorRed);
+		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k29_ObjectDescCircleIndice), dispMan._g296_bitmapViewport,
+								  g34_BoxObjectDescCircle, 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray);
 
 		char *descString = nullptr;
 		char str[40];
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 63ca90c..376b629 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -60,11 +60,11 @@ MenuMan::~MenuMan() {
 
 void MenuMan::f395_drawMovementArrows() {
 	DisplayMan &disp = *_vm->_displayMan;
-	byte *arrowsBitmap = disp.f489_getBitmap(k13_MovementArrowsIndice);
+	byte *arrowsBitmap = disp.f489_getNativeBitmapOrGraphic(k13_MovementArrowsIndice);
 	Box &dest = g2_BoxMovementArrows;
-	uint16 w = disp.getWidth(k13_MovementArrowsIndice);
+	uint16 byteWidth = disp.getPixelWidth(k13_MovementArrowsIndice) / 2;
 
-	disp.f132_blitToBitmap(arrowsBitmap, disp._g348_bitmapScreen, dest, 0, 0, w, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
+	disp.f132_blitToBitmap(arrowsBitmap, disp._g348_bitmapScreen, dest, 0, 0, byteWidth, k160_byteWidthScreen, k255_ColorNoTransparency);
 }
 void MenuMan::f388_clearActingChampion() {
 	ChampionMan &cm = *_vm->_championMan;
@@ -113,7 +113,7 @@ T0386006:
 	box2._x2 = box._x2 - 2;
 	box2._y1 = 95;
 	box2._y2 = 110;
-	dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 16, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
+	dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 8, k160_byteWidthScreen, k255_ColorNoTransparency);
 	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) {
 		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 	}
@@ -208,11 +208,13 @@ void MenuMan::f387_drawActionArea() {
 			box = g500_BoxActionArea2ActionMenu;
 		if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone)
 			box = g501_BoxActionArea1ActionMenu;
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k10_MenuActionAreaIndice), dispMan._g348_bitmapScreen, box, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
-		textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 235, 83, k0_ColorBlack, k4_ColorCyan, champMan._gK71_champions[_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name,
+		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k10_MenuActionAreaIndice), dispMan._g348_bitmapScreen,
+								  box, 0, 0, 48, k160_byteWidthScreen, k255_ColorNoTransparency);
+		textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen,
+											235, 83, k0_ColorBlack, k4_ColorCyan, champMan._gK71_champions[_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name,
 											k7_ChampionNameMaximumLength, k200_heightScreen);
 		for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) {
-			textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
+			textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
 												f384_getActionName(_g713_actionList._actionIndices[actionListIndex]),
 												k12_ActionNameMaximumLength, k200_heightScreen);
 		}
@@ -315,23 +317,25 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
 	Champion &champ = _vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
 	if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) {
 		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 12, 96, 96, k255_ColorNoTransparency);
+		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine,
+								  gK74_BoxSpellAreaLine, 0, 12, 48, 48, k255_ColorNoTransparency);
 		int16 x = 1;
 		byte c = 96 + (6 * champ._symbolStep);
 		char spellSymbolString[2] = {'\0', '\0'};
 		for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
 			spellSymbolString[0] = c++;
-			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 14, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
+			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 14, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
 		}
 	} else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) {
 		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 24, 96, 96, k255_ColorNoTransparency);
+		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine,
+								  gK74_BoxSpellAreaLine, 0, 24, 48, 48, k255_ColorNoTransparency);
 		char spellSymbolString[2] = {'\0', '\0'};
 		int16 x = 8;
 		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
 			if ((spellSymbolString[0] = champ._symbols[symbolIndex]) == '\0')
 				break;
-			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 9, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
+			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 9, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
 		}
 	}
 }
@@ -345,7 +349,8 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 		return;
 	if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) {
 		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-		dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k9_MenuSpellAreaBackground), dispMan._g348_bitmapScreen, g0_BoxSpellArea, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
+		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), dispMan._g348_bitmapScreen, g0_BoxSpellArea, 0, 0,
+								  48, k160_byteWidthScreen, k255_ColorNoTransparency);
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 	}
 	if (champIndex == kM1_ChampionNone) {
@@ -361,9 +366,9 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 	f393_drawSpellAreaControls((ChampionIndex)champIndex);
-	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK75_BoxSpellAreaLine2, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
+	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK75_BoxSpellAreaLine2, 0, 0, 48, k160_byteWidthScreen, k255_ColorNoTransparency);
 	f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols);
-	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
+	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 48, k160_byteWidthScreen, k255_ColorNoTransparency);
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 }
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 1d8b780..ff7ff4d 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -192,11 +192,11 @@ void ObjectMan::f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 	}
 
 	--i;
-	byte *srcBitmap = _vm->_displayMan->f489_getBitmap(k42_ObjectIcons_000_TO_031 + i);
+	byte *srcBitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k42_ObjectIcons_000_TO_031 + i);
 	iconIndex -= g26_IconGraphicFirstIndex[i];
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
 	Box box(0, 0, 15, 15);
-	_vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 256, 16, k255_ColorNoTransparency);
+	_vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, k255_ColorNoTransparency);
 }
 
 void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
@@ -219,15 +219,15 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 		}
 	}
 	iconGraphicIndex--;
-	byte *iconsBitmap = _vm->_displayMan->f489_getBitmap(iconGraphicIndex + k42_ObjectIcons_000_TO_031);
+	byte *iconsBitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(iconGraphicIndex + k42_ObjectIcons_000_TO_031);
 	iconIndex -= g26_IconGraphicFirstIndex[iconGraphicIndex];
 
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) {
-		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g296_bitmapViewport, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 256, k112_byteWidthViewport * 2, k255_ColorNoTransparency);
+		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g296_bitmapViewport, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k112_byteWidthViewport, k255_ColorNoTransparency);
 
 	} else {
-		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g348_bitmapScreen, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 256, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
+		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g348_bitmapScreen, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k160_byteWidthScreen, k255_ColorNoTransparency);
 	}
 }
 
@@ -245,7 +245,7 @@ void ObjectMan::f34_drawLeaderObjectName(Thing thing) {
 	} else {
 		objName = _g352_objectNames[iconIndex];
 	}
-	_vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, 233, 37,
+	_vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, 233, 37,
 											   k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength, k200_heightScreen);
 }
 
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index b29584e..5426dd0 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -35,15 +35,17 @@ TextMan::TextMan(DMEngine* vm) : _vm(vm) {}
 #define k5_LetterWidth 5
 #define k6_LetterHeight 6
 
-void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY,
+void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, uint16 destX, uint16 destY,
 								Color textColor, Color bgColor, const char* text, uint16 destHeight) {
 	destX -= 1; // fixes missalignment, to be checked
 	destY -= 4; // fixes missalignment, to be checked
 
+	uint16 destPixelWidth = destByteWidth * 2;
+
 	uint16 textLength = strlen(text);
 	uint16 nextX = destX;
 	uint16 nextY = destY;
-	byte *srcBitmap = _vm->_displayMan->f489_getBitmap(k557_FontGraphicIndice);
+	byte *srcBitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k557_FontGraphicIndice);
 
 	byte *tmp = _vm->_displayMan->_g74_tmpBitmap;
 	for (uint16 i = 0; i < (k5_LetterWidth + 1) * k6_LetterHeight * 128; ++i) {
@@ -61,26 +63,26 @@ void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uin
 		uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
 
 		Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1);
-		_vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128, destPixelWidth, k255_ColorNoTransparency);
+		_vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128 / 2, destByteWidth, k255_ColorNoTransparency);
 
 		nextX += k5_LetterWidth + 1;
 	}
 }
 
 void TextMan::f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text) {
-	f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight);
+	f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth / 2, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight);
 }
 
 void TextMan::f52_printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) {
-	f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, posX, posY, textColor, bgColor, text, k200_heightScreen);
+	f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, posX, posY, textColor, bgColor, text, k200_heightScreen);
 }
 
-void TextMan::f41_printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor,
+void TextMan::f41_printWithTrailingSpaces(byte* destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor,
 									  Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight) {
 	Common::String str = text;
 	for (int16 i = str.size(); i < requiredTextLength; ++i)
 		str += ' ';
-	f40_printTextToBitmap(destBitmap, destPixelWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight);
+	f40_printTextToBitmap(destBitmap, destByteWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight);
 }
 
 }
diff --git a/engines/dm/text.h b/engines/dm/text.h
index adfc426..31344e2 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -37,11 +37,11 @@ class TextMan {
 	DMEngine *_vm;
 public:
 	explicit TextMan(DMEngine *vm);
-	void f40_printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY,
+	void f40_printTextToBitmap(byte *destBitmap, uint16 destByteWidth, uint16 destX, uint16 destY,
 						   Color textColor, Color bgColor, const char *text, uint16 destHeight); // @ F0040_TEXT_Print
 	void f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text); // @ F0053_TEXT_PrintToLogicalScreen
 	void f52_printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport
-	void f41_printWithTrailingSpaces(byte *destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, Color bgColor,
+	void f41_printWithTrailingSpaces(byte *destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor, Color bgColor,
 								 const char *text, int16 strLenght, int16 destHeight); // @ F0041_TEXT_PrintWithTrailingSpaces
 };
 


Commit: 01ed61e06642b506ba2c471002a410bbbb659167
    https://github.com/scummvm/scummvm/commit/01ed61e06642b506ba2c471002a410bbbb659167
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some comments

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dm.h
    engines/dm/gfx.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 72d6057..5ef225f 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -25,4 +25,7 @@ Todo:
 	
 Refactoring
 	Add constructor to CreatureInfo
-	
\ No newline at end of file
+
+Forgot to add number to name:
+	gBoxChampionPortrait, gBoxEye, gBoxMouth, gSlotMasks
+		
\ No newline at end of file
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 6ceedf9..0fc2bd3 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -178,7 +178,7 @@ public:
 	bool _g298_newGame; // @ G0298_B_NewGame
 	bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested
 
-	bool _g321_stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput
+	bool _g321_stopWaitingForPlayerInput; // @ G0321_B_StopWaitingForPlayerInput
 	bool _g301_gameTimeTicking; // @ G0301_B_GameTimeTicking
 	bool _g524_restartGameAllowed; // @ G0524_B_RestartGameAllowed
 	uint32 _g525_gameId; // @ G0525_l_GameID, probably useless here
@@ -189,8 +189,8 @@ public:
 	bool _g340_highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested
 
 	// TODO: refactor direction into a class
-	int8 _dirIntoStepCountEast[4];
-	int8 _dirIntoStepCountNorth[4];
+	int8 _dirIntoStepCountEast[4]; // @ G0233_ai_Graphic559_DirectionToStepEastCount
+	int8 _dirIntoStepCountNorth[4]; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
 };
 
 class Console : public GUI::Debugger {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 50a6d5e..785899b 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -544,7 +544,7 @@ public:
 	uint16 getPixelHeight(uint16 index);
 
 
-	void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height);
+	void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); // @ F0099_DUNGEONVIEW_CopyBitmapAndFlipHorizontal
 
 
 	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which 


Commit: 94c878143e75e872ba8c82b31a5564c9b4e6437c
    https://github.com/scummvm/scummvm/commit/94c878143e75e872ba8c82b31a5564c9b4e6437c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0108_DUNGEONVIEW_DrawFloorOrnament

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index ae7852d..7de740d 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -72,12 +72,16 @@ uint16 getFlag(uint16 val, uint16 mask) {
 	return val & mask;
 }
 
-void setFlag(uint16 &val, uint16 mask) {
-	val |= mask;
+uint16 setFlag(uint16 &val, uint16 mask) {
+	return val |= mask;
 }
 
-void clearFlag(uint16 &val, uint16 mask) {
-	val &= ~mask;
+uint16 clearFlag(uint16 &val, uint16 mask) {
+	return val &= ~mask;
+}
+
+uint16 toggleFlag(uint16& val, uint16 mask) {
+	return val ^= mask;
 }
 
 DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
@@ -146,7 +150,7 @@ void DMEngine::f463_initializeGame() {
 	_displayMan->f460_initializeGraphicData();
 	// DUMMY CODE: next line
 	_displayMan->loadPalette(g19_PalCredits);
-	
+
 	_eventMan->initMouse();
 
 	while (_loadsaveMan->f435_loadgame() != k1_LoadgameSuccess) {
@@ -166,14 +170,13 @@ void DMEngine::f463_initializeGame() {
 	warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
 }
 
-	void DMEngine::f448_initMemoryManager()
-	{
-		warning("STUB FUNCTION");
-		for (uint16 i = 0; i < 16; ++i)
-			_displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i];
-	}
+void DMEngine::f448_initMemoryManager() {
+	warning("STUB FUNCTION");
+	for (uint16 i = 0; i < 16; ++i)
+		_displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i];
+}
 
-	void DMEngine::f462_startGame() {
+void DMEngine::f462_startGame() {
 	_g331_pressingEye = false;
 	_g332_stopPressingEye = false;
 	_g333_pressingMouth = false;
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 0fc2bd3..207416c 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -65,9 +65,10 @@ uint16 returnNextVal(uint16 val); // @ M17_NEXT
 bool isOrientedWestEast(direction dir);	// @ M16_IS_ORIENTED_WEST_EAST
 
 
-uint16 getFlag(uint16 val, uint16 mask);
-void setFlag(uint16 &val, uint16 mask);
-void clearFlag(uint16 &val, uint16 mask);
+uint16 getFlag(uint16 val, uint16 mask); // @ M07_GET
+uint16 setFlag(uint16 &val, uint16 mask); // @ M08_SET
+uint16 clearFlag(uint16 &val, uint16 mask);	// @ M09_CLEAR
+uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE
 
 
 enum ThingType {
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 4aa9ea2..45a6368 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1158,6 +1158,82 @@ void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitm
 	f130_flipBitmapHorizontal(destBitmap, byteWidth, height);
 }
 
+void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloorIndex) {
+#define AP0118_ui_FloorOrnamentIndex floorOrnOrdinal
+	int16 nativeBitmapIndex;
+	bool drawFootprints;
+	byte* bitmap;
+	uint16* coordSets;
+
+
+	static byte g191_floorOrnNativeBitmapndexInc[9] = { // @ G0191_auc_Graphic558_FloorOrnamentNativeBitmapIndexIncrements
+		0,   /* D3L */
+		1,   /* D3C */
+		0,   /* D3R */
+		2,   /* D2L */
+		3,   /* D2C */
+		2,   /* D2R */
+		4,   /* D1L */
+		5,   /* D1C */
+		4}; /* D1R */
+
+	static uint16 g206_floorOrnCoordSets[3][9][6] = { // @ G0206_aaauc_Graphic558_FloorOrnamentCoordinateSets
+		/* { X1, X2, Y1, Y2, ByteWidth, Height } */
+		{{32,  79, 66,  71, 24,  6},     /* D3L */
+		{96, 127, 66,  71, 16,  6},     /* D3C */
+		{144, 191, 66,  71, 24,  6},     /* D3R */
+		{0,  63, 77,  87, 32, 11},     /* D2L */
+		{80, 143, 77,  87, 32, 11},     /* D2C */
+		{160, 223, 77,  87, 32, 11},     /* D2R */
+		{0,  31, 92, 116, 16, 25},     /* D1L */
+		{80, 143, 92, 116, 32, 25},     /* D1C */
+		{192, 223, 92, 116, 16, 25}},   /* D1R */
+		{{0,  95, 66,  74, 48,  9},     /* D3L */
+		{64, 159, 66,  74, 48,  9},     /* D3C */
+		{128, 223, 66,  74, 48,  9},     /* D3R */
+		{0,  79, 75,  89, 40, 15},     /* D2L */
+		{56, 167, 75,  89, 56, 15},     /* D2C */
+		{144, 223, 75,  89, 40, 15},     /* D2R */
+		{0,  63, 90, 118, 32, 29},     /* D1L */
+		{32, 191, 90, 118, 80, 29},     /* D1C */
+		{160, 223, 90, 118, 32, 29}},   /* D1R */
+		{{42,  57, 68,  72,  8,  5},     /* D3L */
+		{104, 119, 68,  72,  8,  5},     /* D3C */
+		{166, 181, 68,  72,  8,  5},     /* D3R */
+		{9,  40, 80,  85, 16,  6},     /* D2L */
+		{96, 127, 80,  85, 16,  6},     /* D2C */
+		{183, 214, 80,  85, 16,  6},     /* D2R */
+		{0,  15, 97, 108,  8, 12},     /* D1L */
+		{96, 127, 97, 108, 16, 12},     /* D1C	*/
+		{208, 223, 97, 108,  8, 12}}}; /* D1R */
+
+	if (floorOrnOrdinal) {
+		if (drawFootprints = getFlag(floorOrnOrdinal, k0x8000_FootprintsAspect)) {
+			if (!clearFlag(floorOrnOrdinal, k0x8000_FootprintsAspect))
+				goto T0108005;
+		}
+		floorOrnOrdinal--;
+		nativeBitmapIndex = _vm->_displayMan->_g102_currMapFloorOrnInfo[AP0118_ui_FloorOrnamentIndex][k0_NativeBitmapIndex]
+			+ g191_floorOrnNativeBitmapndexInc[viewFloorIndex];
+		coordSets = g206_floorOrnCoordSets[_vm->_displayMan->_g102_currMapFloorOrnInfo[AP0118_ui_FloorOrnamentIndex][k1_CoordinateSet]][viewFloorIndex];
+		if ((viewFloorIndex == k8_viewFloor_D1R) || (viewFloorIndex == k5_viewFloor_D2R)
+			|| (viewFloorIndex == k2_viewFloor_D3R)
+			|| ((AP0118_ui_FloorOrnamentIndex == k15_FloorOrnFootprints) && _vm->_displayMan->_g76_useFlippedWallAndFootprintsBitmap &&
+			((viewFloorIndex == k7_viewFloor_D1C) || (viewFloorIndex == k4_viewFloor_D2C) || (viewFloorIndex == k1_viewFloor_D3C)))) {
+			_vm->_displayMan->f99_copyBitmapAndFlipHorizontal(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
+															  bitmap = _vm->_displayMan->_g74_tmpBitmap, coordSets[4], coordSets[5]);
+		} else {
+			bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+		}
+		_vm->_displayMan->f132_blitToBitmap(bitmap, _vm->_displayMan->_g296_bitmapViewport,
+			*(Box*)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport);
+T0108005:
+		if (drawFootprints) {
+			f108_drawFloorOrnament(_vm->M0_indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex);
+		}
+	}
+}
+
 void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
 	if (f._srcByteWidth)
 		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency);
@@ -1195,7 +1271,7 @@ void DisplayMan::f116_drawSquareD3L(direction dir, int16 posX, int16 posY) {
 		order = k0x0321_CellOrder_BackLeft_BackRight_FrontRight;
 		goto T0116016_blueToad;
 	case k17_ElementTypeDoorFront:
-		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
 		f100_drawWallSetBitmap(_g705_bitmapWallSet_DoorFrameLeft_D3L, g164_Frame_DoorFrameLeft_D3L);
 		warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor");
@@ -1210,7 +1286,8 @@ void DisplayMan::f116_drawSquareD3L(direction dir, int16 posX, int16 posY) {
 T0116015_redEagle:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
 T0116016_blueToad:
-		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
+/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L); 
 T0116017_orangeElk:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order);
 	}
@@ -1247,7 +1324,7 @@ void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) {
 		order = k0x0412_CellOrder_BackRight_BackLeft_FrontLeft;
 		goto T0117017;
 	case k17_ElementTypeDoorFront:
-		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
 		memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44);
 		warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally");
@@ -1266,7 +1343,8 @@ void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) {
 T0117016:
 		order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft;
 T0117017:
-		warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament");
+ /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
 T0117018:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order);
 	}
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 785899b..5b75676 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -36,6 +36,16 @@
 
 namespace DM {
 
+#define k0_viewFloor_D3L 0 // @ C0_VIEW_FLOOR_D3L
+#define k1_viewFloor_D3C 1 // @ C1_VIEW_FLOOR_D3C
+#define k2_viewFloor_D3R 2 // @ C2_VIEW_FLOOR_D3R
+#define k3_viewFloor_D2L 3 // @ C3_VIEW_FLOOR_D2L
+#define k4_viewFloor_D2C 4 // @ C4_VIEW_FLOOR_D2C
+#define k5_viewFloor_D2R 5 // @ C5_VIEW_FLOOR_D2R
+#define k6_viewFloor_D1L 6 // @ C6_VIEW_FLOOR_D1L
+#define k7_viewFloor_D1C 7 // @ C7_VIEW_FLOOR_D1C
+#define k8_viewFloor_D1R 8 // @ C8_VIEW_FLOOR_D1R
+
 #define k2_FloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT
 #define k13_WallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT
 #define k18_StairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT
@@ -545,6 +555,7 @@ public:
 
 
 	void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); // @ F0099_DUNGEONVIEW_CopyBitmapAndFlipHorizontal
+	void f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloorIndex); // @ F0108_DUNGEONVIEW_DrawFloorOrnament
 
 
 	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which 


Commit: 7fef7b83127f532781fec64eea3229d56c080902
    https://github.com/scummvm/scummvm/commit/7fef7b83127f532781fec64eea3229d56c080902
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add paritial drawing of doors

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 7de740d..7fa1eea 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -84,6 +84,10 @@ uint16 toggleFlag(uint16& val, uint16 mask) {
 	return val ^= mask;
 }
 
+uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height) {
+	return pixelWidth / 2 * height;
+}
+
 DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 // Do not load data files
 // Do not initialize graphics here
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 207416c..8133fd2 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -69,6 +69,7 @@ uint16 getFlag(uint16 val, uint16 mask); // @ M07_GET
 uint16 setFlag(uint16 &val, uint16 mask); // @ M08_SET
 uint16 clearFlag(uint16 &val, uint16 mask);	// @ M09_CLEAR
 uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE
+uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height);  // @ M75_BITMAP_BYTE_COUNT
 
 
 enum ThingType {
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 2a037a7..0cecd04 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -384,7 +384,7 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL
 	_g306_partyMapX = 0;
 	_g307_partyMapY = 0;
 	_g309_partyMapIndex = 0;
-	_g272_currMapIndex = 0;
+	_g272_currMapIndex = kM1_mapIndexNone;
 	_g273_currMapWidth = 0;
 	_g274_currMapHeight = 0;
 
@@ -729,11 +729,22 @@ void DungeonMan::f434_loadDungeonFile() {
 }
 
 void DungeonMan::f173_setCurrentMap(uint16 mapIndex) {
+	static DoorInfo g254_doorInfo[4] = { // @ G0254_as_Graphic559_DoorInfo
+		/* { Attributes, Defense } */
+		DoorInfo(3, 110),   /* Door type 0 Portcullis */
+		DoorInfo(0,  42),   /* Door type 1 Wooden door */
+		DoorInfo(0, 230),   /* Door type 2 Iron door */
+		DoorInfo(5, 255)}; /* Door type 3 Ra door */
+
+	if (_g272_currMapIndex == mapIndex)
+		return;
 	_g272_currMapIndex = mapIndex;
 	_g271_currMapData = _g279_dungeonMapData[mapIndex];
 	_g269_currMap = _g277_dungeonMaps + mapIndex;
 	_g273_currMapWidth = _g277_dungeonMaps[mapIndex]._width + 1;
 	_g274_currMapHeight = _g277_dungeonMaps[mapIndex]._height + 1;
+	_g275_currMapDoorInfo[0] = g254_doorInfo[_g269_currMap->_doorSet0];
+	_g275_currMapDoorInfo[1] = g254_doorInfo[_g269_currMap->_doorSet1];
 	_g270_currMapColCumulativeSquareFirstThingCount
 		= &_g280_dungeonColumnsCumulativeSquareThingCount[_g281_dungeonMapsFirstColumnIndex[mapIndex]];
 }
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 331c3c9..d2a82ac 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -594,6 +594,14 @@ struct Map {
 }; // @ MAP
 
 
+class DoorInfo {
+public:
+	byte _attributes;
+	byte _defense;
+	DoorInfo(byte b1, byte b2): _attributes(b1), _defense(b2){}
+	DoorInfo() {}
+}; // @ DOOR_INFO
+
 
 class DungeonMan {
 	DMEngine *_vm;
@@ -659,7 +667,7 @@ public:
 	int16 _g306_partyMapX; // @ G0306_i_PartyMapX
 	int16 _g307_partyMapY; // @ G0307_i_PartyMapY
 	uint8 _g309_partyMapIndex; // @ G0309_i_PartyMapIndex
-	uint8 _g272_currMapIndex; // @ G0272_i_CurrentMapIndex
+	int16 _g272_currMapIndex; // @ G0272_i_CurrentMapIndex
 	byte **_g271_currMapData; // @ G0271_ppuc_CurrentMapData
 	Map *_g269_currMap; // @ G0269_ps_CurrentMap
 	uint16 _g273_currMapWidth; // @ G0273_i_CurrentMapWidth
@@ -678,6 +686,7 @@ public:
 	bool _g288_isFacingFountain; // @ G0288_B_FacingFountain
 	ElementType _g285_squareAheadElement; // @ G0285_i_SquareAheadElement 
 	Thing _g292_pileTopObject[5]; // @ G0292_aT_PileTopObject
+	DoorInfo _g275_currMapDoorInfo[2]; // @ G0275_as_CurrentMapDoorInfo
 };
 
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 45a6368..2a9a90d 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -35,10 +35,136 @@
 #include "dungeonman.h"
 #include "group.h"
 #include "timeline.h"
+#include "champion.h"
 
 
 namespace DM {
 
+DoorFrames g179_doorFrame_D3L = { // @ G0179_s_Graphic558_Frames_Door_D3L
+								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+	Frame(24, 71, 28, 67, 24, 41,  0,  0),     /* Closed Or Destroyed */
+	Frame(24, 71, 28, 38, 24, 41,  0, 30),     /* Vertical Closed one fourth */
+	Frame(24, 71, 28, 48, 24, 41,  0, 20),     /* Vertical Closed half */
+	Frame(24, 71, 28, 58, 24, 41,  0, 10),   /* Vertical Closed three fourth */
+	Frame(24, 29, 28, 67, 24, 41, 18,  0),     /* Left Horizontal Closed one fourth */
+	Frame(24, 35, 28, 67, 24, 41, 12,  0),     /* Left Horizontal Closed half */
+	Frame(24, 41, 28, 67, 24, 41,  6,  0),   /* Left Horizontal Closed three fourth */
+	Frame(66, 71, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed one fourth */
+	Frame(60, 71, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed half */
+	Frame(54, 71, 28, 67, 24, 41, 24,  0)}; /* Right Horizontal Closed three fourth */
+DoorFrames g180_doorFrame_D3C = { // @ G0180_s_Graphic558_Frames_Door_D3C
+								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+	Frame(88, 135, 28, 67, 24, 41,  0,  0),     /* Closed Or Destroyed */
+	Frame(88, 135, 28, 38, 24, 41,  0, 30),     /* Vertical Closed one fourth */
+	Frame(88, 135, 28, 48, 24, 41,  0, 20),     /* Vertical Closed half */
+	Frame(88, 135, 28, 58, 24, 41,  0, 10),   /* Vertical Closed three fourth */
+	Frame(88,  93, 28, 67, 24, 41, 18,  0),     /* Left Horizontal Closed one fourth */
+	Frame(88,  99, 28, 67, 24, 41, 12,  0),     /* Left Horizontal Closed half */
+	Frame(88, 105, 28, 67, 24, 41,  6,  0),   /* Left Horizontal Closed three fourth */
+	Frame(130, 135, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed one fourth */
+	Frame(124, 135, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed half */
+	Frame(118, 135, 28, 67, 24, 41, 24,  0)}; /* Right Horizontal Closed three fourth */
+DoorFrames g181_doorFrame_D3R = { // @ G0181_s_Graphic558_Frames_Door_D3R
+								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+	Frame(150, 197, 28, 67, 24, 41,  0,  0),     /* Closed Or Destroyed */
+	Frame(150, 197, 28, 38, 24, 41,  0, 30),     /* Vertical Closed one fourth */
+	Frame(150, 197, 28, 48, 24, 41,  0, 20),     /* Vertical Closed half */
+	Frame(150, 197, 28, 58, 24, 41,  0, 10),   /* Vertical Closed three fourth */
+	Frame(150, 153, 28, 67, 24, 41, 18,  0),     /* Left Horizontal Closed one fourth */
+	Frame(150, 161, 28, 67, 24, 41, 12,  0),     /* Left Horizontal Closed half */
+	Frame(150, 167, 28, 67, 24, 41,  6,  0),   /* Left Horizontal Closed three fourth */
+	Frame(192, 197, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed one fourth */
+	Frame(186, 197, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed half */
+	Frame(180, 197, 28, 67, 24, 41, 24,  0)}; /* Right Horizontal Closed three fourth */
+DoorFrames g182_doorFrame_D2L = { // @ G0182_s_Graphic558_Frames_Door_D2L
+								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+	Frame(0, 63, 24, 82, 32, 61,  0,  0),     /* Closed Or Destroyed */
+	Frame(0, 63, 24, 39, 32, 61,  0, 45),     /* Vertical Closed one fourth */
+	Frame(0, 63, 24, 54, 32, 61,  0, 30),     /* Vertical Closed half */
+	Frame(0, 63, 24, 69, 32, 61,  0, 15),   /* Vertical Closed three fourth */
+	Frame(0,  7, 24, 82, 32, 61, 24,  0),     /* Left Horizontal Closed one fourth */
+	Frame(0, 15, 24, 82, 32, 61, 16,  0),     /* Left Horizontal Closed half */
+	Frame(0, 23, 24, 82, 32, 61,  8,  0),   /* Left Horizontal Closed three fourth */
+	Frame(56, 63, 24, 82, 32, 61, 32,  0),     /* Right Horizontal Closed one fourth */
+	Frame(48, 63, 24, 82, 32, 61, 32,  0),     /* Right Horizontal Closed half */
+	Frame(40, 63, 24, 82, 32, 61, 32,  0)}; /* Right Horizontal Closed three fourth */
+DoorFrames g183_doorFrame_D2C = { // @ G0183_s_Graphic558_Frames_Door_D2C
+								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+	Frame(80, 143, 24, 82, 32, 61,  0,  0),     /* Closed Or Destroyed */
+	Frame(80, 143, 24, 39, 32, 61,  0, 45),     /* Vertical Closed one fourth */
+	Frame(80, 143, 24, 54, 32, 61,  0, 30),     /* Vertical Closed half */
+	Frame(80, 143, 24, 69, 32, 61,  0, 15),   /* Vertical Closed three fourth */
+	Frame(80,  87, 24, 82, 32, 61, 24,  0),     /* Left Horizontal Closed one fourth */
+	Frame(80,  95, 24, 82, 32, 61, 16,  0),     /* Left Horizontal Closed half */
+	Frame(80, 103, 24, 82, 32, 61,  8,  0),   /* Left Horizontal Closed three fourth */
+	Frame(136, 143, 24, 82, 32, 61, 32,  0),     /* Right Horizontal Closed one fourth */
+	Frame(128, 143, 24, 82, 32, 61, 32,  0),     /* Right Horizontal Closed half */
+	Frame(120, 143, 24, 82, 32, 61, 32,  0)}; /* Right Horizontal Closed three fourth */
+DoorFrames g184_doorFrame_D2R = { // @ G0184_s_Graphic558_Frames_Door_D2R
+								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+	Frame(160, 223, 24, 82, 32, 61,  0,  0),     /* Closed Or Destroyed */
+	Frame(160, 223, 24, 39, 32, 61,  0, 45),     /* Vertical Closed one fourth */
+	Frame(160, 223, 24, 54, 32, 61,  0, 30),     /* Vertical Closed half */
+	Frame(160, 223, 24, 69, 32, 61,  0, 15),   /* Vertical Closed three fourth */
+	Frame(160, 167, 24, 82, 32, 61, 24,  0),     /* Left Horizontal Closed one fourth */
+	Frame(160, 175, 24, 82, 32, 61, 16,  0),     /* Left Horizontal Closed half */
+	Frame(160, 183, 24, 82, 32, 61,  8,  0),   /* Left Horizontal Closed three fourth */
+	Frame(216, 223, 24, 82, 32, 61, 32,  0),     /* Right Horizontal Closed one fourth */
+	Frame(208, 223, 24, 82, 32, 61, 32,  0),     /* Right Horizontal Closed half */
+	Frame(200, 223, 24, 82, 32, 61, 32,  0)}; /* Right Horizontal Closed three fourth */
+DoorFrames g185_doorFrame_D1L = { // @ G0185_s_Graphic558_Frames_Door_D1L
+								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+	Frame(0, 31, 17, 102, 48, 88, 64,  0),     /* Closed Or Destroyed */
+	Frame(0, 31, 17,  38, 48, 88, 64, 66),     /* Vertical Closed one fourth */
+	Frame(0, 31, 17,  60, 48, 88, 64, 44),     /* Vertical Closed half */
+	Frame(0, 31, 17,  82, 48, 88, 64, 22),   /* Vertical Closed three fourth */
+	Frame(0,  0,  0,   0,  0,  0,  0,  0),     /* Left Horizontal Closed one fourth */
+	Frame(0,  0,  0,   0,  0,  0,  0,  0),     /* Left Horizontal Closed half */
+	Frame(0,  0,  0,   0,  0,  0,  0,  0),   /* Left Horizontal Closed three fourth */
+	Frame(20, 31, 17, 102, 48, 88, 48,  0),     /* Right Horizontal Closed one fourth */
+	Frame(8, 31, 17, 102, 48, 88, 48,  0),     /* Right Horizontal Closed half */
+	Frame(0, 31, 17, 102, 48, 88, 52,  0)}; /* Right Horizontal Closed three fourth */
+DoorFrames g186_doorFrame_D1C = { // @ G0186_s_Graphic558_Frames_Door_D1C
+								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+	Frame(64, 159, 17, 102, 48, 88,  0,  0),     /* Closed Or Destroyed */
+	Frame(64, 159, 17,  38, 48, 88,  0, 66),     /* Vertical Closed one fourth */
+	Frame(64, 159, 17,  60, 48, 88,  0, 44),     /* Vertical Closed half */
+	Frame(64, 159, 17,  82, 48, 88,  0, 22),   /* Vertical Closed three fourth */
+	Frame(64,  75, 17, 102, 48, 88, 36,  0),     /* Left Horizontal Closed one fourth */
+	Frame(64,  87, 17, 102, 48, 88, 24,  0),     /* Left Horizontal Closed half */
+	Frame(64,  99, 17, 102, 48, 88, 12,  0),   /* Left Horizontal Closed three fourth */
+	Frame(148, 159, 17, 102, 48, 88, 48,  0),     /* Right Horizontal Closed one fourth */
+	Frame(136, 159, 17, 102, 48, 88, 48,  0),     /* Right Horizontal Closed half */
+	Frame(124, 159, 17, 102, 48, 88, 48,  0)}; /* Right Horizontal Closed three fourth */
+DoorFrames g187_doorFrame_D1R = { // @ G0187_s_Graphic558_Frames_Door_D1R
+								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+	Frame(192, 223, 17, 102, 48, 88,  0,  0),     /* Closed Or Destroyed */
+	Frame(192, 223, 17,  38, 48, 88,  0, 66),     /* Vertical Closed one fourth */
+	Frame(192, 223, 17,  60, 48, 88,  0, 44),     /* Vertical Closed half */
+	Frame(192, 223, 17,  82, 48, 88,  0, 22),   /* Vertical Closed three fourth */
+	Frame(192, 203, 17, 102, 48, 88, 36,  0),     /* Left Horizontal Closed one fourth */
+	Frame(192, 215, 17, 102, 48, 88, 24,  0),     /* Left Horizontal Closed half */
+	Frame(192, 223, 17, 102, 48, 88, 12,  0),   /* Left Horizontal Closed three fourth */
+	Frame(0,   0,  0,   0,  0,  0,  0,  0),     /* Right Horizontal Closed one fourth */
+	Frame(0,   0,  0,   0,  0,  0,  0,  0),     /* Right Horizontal Closed half */
+	Frame(0,   0,  0,   0,  0,  0,  0,  0)}; /* Right Horizontal Closed three fourth */
+
+uint16 g207_doorOrnCoordSets[4][3][6] = { // @ G0207_aaauc_Graphic558_DoorOrnamentCoordinateSets
+	/* { X1, X2, Y1, Y2, ByteWidth, Height } */
+	{{17, 31,  8, 17,  8, 10},     /* D3LCR */
+	{22, 42, 11, 23, 16, 13},     /* D2LCR */
+	{32, 63, 13, 31, 16, 19}},   /* D1LCR */
+	{{0, 47,  0, 40, 24, 41},     /* D3LCR */
+	{0, 63,  0, 60, 32, 61},     /* D2LCR */
+	{0, 95,  0, 87, 48, 88}},   /* D1LCR */
+	{{17, 31, 15, 24,  8, 10},     /* D3LCR */
+	{22, 42, 22, 34, 16, 13},     /* D2LCR */
+	{32, 63, 31, 49, 16, 19}},   /* D1LCR */
+	{{23, 35, 31, 39,  8,  9},     /* D3LCR */
+	{30, 48, 41, 52, 16, 12},     /* D2LCR */
+	{44, 75, 61, 79, 16, 19}}}; /* D1LCR */
+
+
 Frame g164_Frame_DoorFrameLeft_D3L = Frame(0, 31, 28, 70, 16, 43, 0, 0); // @ G0164_s_Graphic558_Frame_DoorFrameLeft_D3L
 Frame g165_Frame_DoorFrameRight_D3R = Frame(192, 223, 28, 70, 16, 43, 0, 0); // @ G0165_s_Graphic558_Frame_DoorFrameRight_D3R
 Frame g166_Frame_DoorFrameLeft_D3C = Frame(64, 95, 27, 70, 16, 44, 0, 0); // @ G0166_s_Graphic558_Frame_DoorFrameLeft_D3C
@@ -945,6 +1071,14 @@ void DisplayMan::f461_allocateFlippedWallBitmaps() {
 	_g94_bitmapWall_D0R_Flipped = new byte[32 * 136];
 }
 
+void DisplayMan::f102_drawDoorBitmap(Frame* frame) {
+	if (frame->_srcByteWidth) {
+		f132_blitToBitmap(_vm->_displayMan->_g74_tmpBitmap,
+						  _vm->_displayMan->_g296_bitmapViewport,
+						  frame->_box, frame->_srcX, frame->_srcY, frame->_srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, frame->_srcHeight, k136_heightViewport);
+	}
+}
+
 void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* topAndBottomScreen) {
 	if (middleScreenPalette && topAndBottomScreen)
 		debugC(kDMDebugOftenCalledWarning, "MISSING CODE: F0508_AMIGA_BuildPaletteChangeCopperList");
@@ -1064,7 +1198,7 @@ void DisplayMan::f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint1
 	}
 }
 
-void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 byteWidth, uint16 height) {
+void DisplayMan::f131_flipVertical(byte *bitmap, uint16 byteWidth, uint16 height) {
 	uint16 width = byteWidth * 2;
 	byte *tmp = new byte[width];
 
@@ -1159,7 +1293,7 @@ void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitm
 }
 
 void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloorIndex) {
-#define AP0118_ui_FloorOrnamentIndex floorOrnOrdinal
+	uint16 floorOrnIndex;
 	int16 nativeBitmapIndex;
 	bool drawFootprints;
 	byte* bitmap;
@@ -1213,12 +1347,13 @@ void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloor
 				goto T0108005;
 		}
 		floorOrnOrdinal--;
-		nativeBitmapIndex = _vm->_displayMan->_g102_currMapFloorOrnInfo[AP0118_ui_FloorOrnamentIndex][k0_NativeBitmapIndex]
+		floorOrnIndex = floorOrnOrdinal;
+		nativeBitmapIndex = _vm->_displayMan->_g102_currMapFloorOrnInfo[floorOrnIndex][k0_NativeBitmapIndex]
 			+ g191_floorOrnNativeBitmapndexInc[viewFloorIndex];
-		coordSets = g206_floorOrnCoordSets[_vm->_displayMan->_g102_currMapFloorOrnInfo[AP0118_ui_FloorOrnamentIndex][k1_CoordinateSet]][viewFloorIndex];
+		coordSets = g206_floorOrnCoordSets[_vm->_displayMan->_g102_currMapFloorOrnInfo[floorOrnIndex][k1_CoordinateSet]][viewFloorIndex];
 		if ((viewFloorIndex == k8_viewFloor_D1R) || (viewFloorIndex == k5_viewFloor_D2R)
 			|| (viewFloorIndex == k2_viewFloor_D3R)
-			|| ((AP0118_ui_FloorOrnamentIndex == k15_FloorOrnFootprints) && _vm->_displayMan->_g76_useFlippedWallAndFootprintsBitmap &&
+			|| ((floorOrnIndex == k15_FloorOrnFootprints) && _vm->_displayMan->_g76_useFlippedWallAndFootprintsBitmap &&
 			((viewFloorIndex == k7_viewFloor_D1C) || (viewFloorIndex == k4_viewFloor_D2C) || (viewFloorIndex == k1_viewFloor_D3C)))) {
 			_vm->_displayMan->f99_copyBitmapAndFlipHorizontal(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
 															  bitmap = _vm->_displayMan->_g74_tmpBitmap, coordSets[4], coordSets[5]);
@@ -1226,7 +1361,7 @@ void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloor
 			bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
 		}
 		_vm->_displayMan->f132_blitToBitmap(bitmap, _vm->_displayMan->_g296_bitmapViewport,
-			*(Box*)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport);
+											*(Box*)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport);
 T0108005:
 		if (drawFootprints) {
 			f108_drawFloorOrnament(_vm->M0_indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex);
@@ -1234,6 +1369,96 @@ T0108005:
 	}
 }
 
+void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* doorNativeBitmapIndices, int16 byteCount, int16 viewDoorOrnIndex, DoorFrames* doorFrames) {
+	uint16 doorType;
+	DoorFrames* doorFramesTemp;
+	Door* door;
+
+
+	doorFramesTemp = doorFrames;
+	if (doorState != k0_doorState_OPEN) {
+		door = (Door*)(_vm->_dungeonMan->_g284_thingData[k0_DoorThingType]) + doorThingIndex;
+		memmove(_g74_tmpBitmap, f489_getNativeBitmapOrGraphic(doorNativeBitmapIndices[doorType = door->getType()]), byteCount * 2);
+		f109_drawDoorOrnament(door->getOrnOrdinal(), viewDoorOrnIndex);
+		if (getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[doorType]._attributes, k0x0004_MaskDoorInfo_Animated)) {
+			if (_vm->_rnd->getRandomNumber(1)) {
+				_vm->_displayMan->f130_flipBitmapHorizontal(_vm->_displayMan->_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
+			}
+			if (_vm->_rnd->getRandomNumber(1)) {
+				f131_flipVertical(_vm->_displayMan->_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
+			}
+		}
+		if ((doorFramesTemp == &g186_doorFrame_D1C) && _vm->_championMan->_g407_party._event73Count_ThievesEye) {
+			f109_drawDoorOrnament(_vm->M0_indexToOrdinal(k16_DoorOrnThivesEyeMask), k2_ViewDoorOrnament_D1LCR);
+		}
+		if (doorState == k4_doorState_CLOSED) {
+			f102_drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed);
+		} else {
+			if (doorState == k5_doorState_DESTROYED) {
+				f109_drawDoorOrnament(_vm->M0_indexToOrdinal(k15_DoorOrnDestroyedMask), viewDoorOrnIndex);
+				f102_drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed);
+			} else {
+				doorState--;
+				if (door->opensVertically()) {
+					f102_drawDoorBitmap(&doorFramesTemp->_vertical[doorState]);
+				} else {
+					f102_drawDoorBitmap(&doorFramesTemp->_leftHorizontal[doorState]);
+					f102_drawDoorBitmap(&doorFramesTemp->_rightHorizontal[doorState]);
+				}
+			}
+		}
+	}
+}
+
+void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIndex) {
+	static byte g200_palChangesDoorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 0, 130}; // @ G0200_auc_Graphic558_PaletteChanges_DoorOrnament_D3
+	static byte g201PalChangesDoorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0201_auc_Graphic558_PaletteChanges_DoorOrnament_D2
+
+
+#define height doorOrnOrdinal
+#define byteWidth viewDoorOrnIndex
+	int16 nativeBitmapIndex;
+	int16 coordSetGreenToad;
+	uint16* coordSetOrangeElk;
+	byte* L0107_puc_Multiple;
+#define bitmap        L0107_puc_Multiple
+	byte* bitmapNative;
+
+
+	if (doorOrnOrdinal) {
+		doorOrnOrdinal--;
+		nativeBitmapIndex = _vm->_displayMan->_g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex];
+		coordSetOrangeElk = g207_doorOrnCoordSets[coordSetGreenToad = _vm->_displayMan->_g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]][viewDoorOrnIndex];
+		if (viewDoorOrnIndex == k2_ViewDoorOrnament_D1LCR) {
+			bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+			byteWidth = 48;
+			height = 88;
+		} else {
+			if (!_vm->_displayMan->f491_isDerivedBitmapInCache(doorOrnOrdinal = k68_DerivedBitmapFirstDoorOrnament_D3 + (doorOrnOrdinal * 2) + viewDoorOrnIndex)) {
+				uint16 *coordSetRedEagle = g207_doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR];
+				bitmapNative = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+				_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmapNative,
+																	   f492_getDerivedBitmap(doorOrnOrdinal),
+																	   coordSetRedEagle[4] << 1, coordSetRedEagle[5],
+																	   coordSetOrangeElk[2] - coordSetOrangeElk[0] + 1,
+																	   coordSetOrangeElk[5],
+																	   (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2);
+				_vm->_displayMan->f493_addDerivedBitmap(doorOrnOrdinal);
+			}
+			bitmap = _vm->_displayMan->f492_getDerivedBitmap(doorOrnOrdinal);
+			if (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) {
+				byteWidth = 24;
+				height = 41;
+			} else {
+				byteWidth = 32;
+				height = 61;
+			}
+		}
+		_vm->_displayMan->f132_blitToBitmap(bitmap, _vm->_displayMan->_g74_tmpBitmap,
+											*(Box*)coordSetOrangeElk, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height);
+	}
+}
+
 void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
 	if (f._srcByteWidth)
 		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency);
@@ -1274,7 +1499,8 @@ void DisplayMan::f116_drawSquareD3L(direction dir, int16 posX, int16 posY) {
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
 		f100_drawWallSetBitmap(_g705_bitmapWallSet_DoorFrameLeft_D3L, g164_Frame_DoorFrameLeft_D3L);
-		warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor");
+		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
+					  _g693_doorNativeBitmapIndex_Front_D3LCR, M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &g179_doorFrame_D3L);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0116017_orangeElk;
 	case k2_ElementTypePit:
@@ -1287,7 +1513,7 @@ T0116015_redEagle:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
 T0116016_blueToad:
 /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L); 
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
 T0116017_orangeElk:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order);
 	}
@@ -1331,8 +1557,9 @@ void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) {
 		if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
 			warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton");
 		}
-		warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor");
-		order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft;
+		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect],
+					  squareAspect[k2_DoorStateAspect], _g693_doorNativeBitmapIndex_Front_D3LCR,
+					  M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &g181_doorFrame_D3R);
 		goto T0117018;
 	case k2_ElementTypePit:
 		if (!squareAspect[k2_PitInvisibleAspect]) {
@@ -1750,8 +1977,17 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 	for (int16 i = 0; i < k1_FountainOrnCount; ++i)
 		_g268_currMapFountainOrnIndices[i] = -1;
 
-
-
+	{
+		uint16 doorSets[2];
+		doorSets[0] = _vm->_dungeonMan->_g269_currMap->_doorSet0;
+		doorSets[1] = _vm->_dungeonMan->_g269_currMap->_doorSet1;
+		for (uint16 doorSet = 0; doorSet <= 1; doorSet++) {
+			int16 counter = k108_FirstDoorSet + (doorSets[doorSet] * k3_DoorSetGraphicsCount);
+			_g693_doorNativeBitmapIndex_Front_D3LCR[doorSet] = counter++;
+			_g694_doorNativeBitmapIndex_Front_D2LCR[doorSet] = counter++;
+			_g695_doorNativeBitmapIndex_Front_D1LCR[doorSet] = counter++;
+		}
+	}
 
 	uint16 alcoveCount = 0;
 	uint16 fountainCount = 0;
@@ -2865,7 +3101,7 @@ continue;
 							AL_6_bitmapRedBanana = _g74_tmpBitmap;
 						}
 						if (flipVertical) {
-							flipBitmapVertical(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
+							f131_flipVertical(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 						}
 						if (flipHorizontal) {
 							f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
@@ -3036,7 +3272,7 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP
 					f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 				}
 				if (flipVertical) {
-					flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
+					f131_flipVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 				}
 				f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport, k10_ColorFlesh);
 			}
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 5b75676..1db5990 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -46,6 +46,22 @@ namespace DM {
 #define k7_viewFloor_D1C 7 // @ C7_VIEW_FLOOR_D1C
 #define k8_viewFloor_D1R 8 // @ C8_VIEW_FLOOR_D1R
 
+#define k0_doorState_OPEN 0 // @ C0_DOOR_STATE_OPEN 
+#define k1_doorState_FOURTH 1 // @ C1_DOOR_STATE_CLOSED_ONE_FOURTH 
+#define k2_doorState_HALF 2 // @ k2_DoorStateAspect_CLOSED_HALF 
+#define k3_doorState_FOURTH 3 // @ C3_DOOR_STATE_CLOSED_THREE_FOURTH
+#define k4_doorState_CLOSED 4 // @ C4_DOOR_STATE_CLOSED 
+#define k5_doorState_DESTROYED 5 // @ C5_DOOR_STATE_DESTROYED 
+
+#define k0_ViewDoorOrnament_D3LCR 0 // @ C0_VIEW_DOOR_ORNAMENT_D3LCR
+#define k1_ViewDoorOrnament_D2LCR 1 // @ C1_VIEW_DOOR_ORNAMENT_D2LCR
+#define k2_ViewDoorOrnament_D1LCR 2 // @ C2_VIEW_DOOR_ORNAMENT_D1LCR
+
+#define k0x0001_MaskDoorInfo_CraturesCanSeeThrough 0x0001 // @ MASK0x0001_CREATURES_CAN_SEE_THROUGH   
+#define k0x0002_MaskDoorInfo_ProjectilesCanPassThrough 0x0002 // @ MASK0x0002_PROJECTILES_CAN_PASS_THROUGH
+#define k0x0004_MaskDoorInfo_Animated 0x0004 // @ MASK0x0004_ANIMATED                    
+
+
 #define k2_FloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT
 #define k13_WallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT
 #define k18_StairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT
@@ -418,6 +434,28 @@ public:
 #define k160_byteWidthScreen 160 // @ C160_BYTE_WIDTH_SCREEN
 #define k200_heightScreen 200 // @ C200_HEIGHT_SCREEN   
 
+class DoorFrames {
+public:
+	Frame _closedOrDestroyed;
+	Frame _vertical[3];
+	Frame _leftHorizontal[3];
+	Frame _rightHorizontal[3];
+	DoorFrames(Frame f1, Frame f2_1, Frame f2_2, Frame f2_3,
+			   Frame f3_1, Frame f3_2, Frame f3_3,
+			   Frame f4_1, Frame f4_2, Frame f4_3) {
+		_closedOrDestroyed = f1;
+		_vertical[0] = f2_1;
+		_vertical[1] = f2_2;
+		_vertical[2] = f2_3;
+		_leftHorizontal[0] = f3_1;
+		_leftHorizontal[1] = f3_2;
+		_leftHorizontal[2] = f3_3;
+		_rightHorizontal[0] = f4_1;
+		_rightHorizontal[1] = f4_2;
+		_rightHorizontal[2] = f4_3;
+	}
+}; // @ DOOR_FRAMES
+
 class DisplayMan {
 	friend class DM::TextMan;
 
@@ -521,6 +559,10 @@ class DisplayMan {
 	int16 _g230_currentFloorSet;// @ G0230_i_CurrentFloorSet
 
 	bool _g76_useFlippedWallAndFootprintsBitmap; // @ G0076_B_UseFlippedWallAndFootprintsBitmaps
+
+	int16 _g693_doorNativeBitmapIndex_Front_D3LCR[2]; // @ G0693_ai_DoorNativeBitmapIndex_Front_D3LCR
+	int16 _g694_doorNativeBitmapIndex_Front_D2LCR[2]; // @ G0694_ai_DoorNativeBitmapIndex_Front_D2LCR
+	int16 _g695_doorNativeBitmapIndex_Front_D1LCR[2]; // @ G0695_ai_DoorNativeBitmapIndex_Front_D1LCR
 public:
 	uint16 _screenWidth;
 	uint16 _screenHeight;
@@ -547,6 +589,7 @@ public:
 	void f96_loadCurrentMapGraphics(); // @ F0096_DUNGEONVIEW_LoadCurrentMapGraphics_CPSDF
 	void loadPalette(uint16 *palette);
 	void f461_allocateFlippedWallBitmaps(); // @ F0461_START_AllocateFlippedWallBitmaps
+	void f102_drawDoorBitmap(Frame *frame);// @ F0102_DUNGEONVIEW_DrawDoorBitmap
 
 	/// Gives the width of an IMG0 type item
 	uint16 getPixelWidth(uint16 index);
@@ -556,6 +599,9 @@ public:
 
 	void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); // @ F0099_DUNGEONVIEW_CopyBitmapAndFlipHorizontal
 	void f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloorIndex); // @ F0108_DUNGEONVIEW_DrawFloorOrnament
+	void f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16 *doorNativeBitmapIndices, int16 byteCount,
+					   int16 viewDoorOrnIndex, DoorFrames *doorFrames); // @ F0111_DUNGEONVIEW_DrawDoor
+	void f109_drawDoorOrnament(int16 doorOrnOdinal, int16 viewDoorOrnIndex); // @ F0109_DUNGEONVIEW_DrawDoorOrnament
 
 
 	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which 
@@ -572,7 +618,7 @@ public:
 	void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
 											  int16 srcPixelWidth, int16 srcHight, int16 destPixelWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
 	void f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height); // @ F0130_VIDEO_FlipHorizontal
-	void flipBitmapVertical(byte *bitmap, uint16 byteWidth, uint16 height);
+	void f131_flipVertical(byte *bitmap, uint16 byteWidth, uint16 height);
 	byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnByteWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap
 
 	void f134_fillBitmap(byte *bitmap, Color color, uint16 byteWidth, uint16 height); // @ F0134_VIDEO_FillBitmap


Commit: 411ad40ca43b900e3bdb9804ca39b10b25d6fa4b
    https://github.com/scummvm/scummvm/commit/411ad40ca43b900e3bdb9804ca39b10b25d6fa4b
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing code to several display functions

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 333243c..b35e0d8 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -427,6 +427,28 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 		champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
 }
 
+int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) {
+	uint16 searchedScentRedEagle;
+	int16 scentIndex;
+	Scent* scent;
+	Scent searchedScent;
+
+
+	if (scentIndex = _g407_party._scentCount) {
+		searchedScent.setMapX(mapX);
+		searchedScent.setMapY(mapY);
+		searchedScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex);
+		searchedScentRedEagle = searchedScent.toUint16();
+		scent = &_g407_party._scents[scentIndex--];
+		do {
+			if ((*(--scent)).toUint16() == searchedScentRedEagle) {
+				return _vm->M0_indexToOrdinal(scentIndex);
+			}
+		} while (scentIndex--);
+	}
+	return 0;
+}
+
 ChampionIndex ChampionMan::f285_getIndexInCell(ViewCell cell) {
 	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
 		if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index cabf06f..43e976e 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -55,6 +55,8 @@ public:
 	void setMapX(uint16 val) { _scent = (_scent & ~0x1F) & (val & 0x1F); }
 	void setMapY(uint16 val) { _scent = (_scent & ~(0x1F << 5)) & (val & 0x1F); }
 	void setMapIndex(uint16 val) { _scent = (_scent & ~(0x1F << 10)) & (val & 0x3F); }
+
+	uint16 toUint16() { return _scent; }
 }; // @ SCENT
 
 class Party {
@@ -466,6 +468,8 @@ public:
 	bool f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged
 	void f296_drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons
 	void f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex); // @ F0301_CHAMPION_AddObjectInSlot
+	int16 f315_getScentOrdinal(int16 mapX, int16 mapY); // @ F0315_CHAMPION_GetScentOrdinal
+
 };
 
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 7fa1eea..d824cf3 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -88,6 +88,10 @@ uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height) {
 	return pixelWidth / 2 * height;
 }
 
+uint16 M21_normalizeModulo4(uint16 val) {
+	return val & 3;
+}
+
 DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 // Do not load data files
 // Do not initialize graphics here
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 8133fd2..c4fe3c5 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -70,6 +70,7 @@ uint16 setFlag(uint16 &val, uint16 mask); // @ M08_SET
 uint16 clearFlag(uint16 &val, uint16 mask);	// @ M09_CLEAR
 uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE
 uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height);  // @ M75_BITMAP_BYTE_COUNT
+uint16 M21_normalizeModulo4(uint16 val); // @ M21_NORMALIZE
 
 
 enum ThingType {
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 0cecd04..fa0e72c 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -30,6 +30,7 @@
 
 #include "dungeonman.h"
 #include "timeline.h"
+#include "champion.h"
 
 
 
@@ -512,7 +513,7 @@ byte g236_AdditionalThingCounts[16] = { // @ G0236_auc_Graphic559_AdditionalThin
 	0,    /* Unused */
 	60,   /* Projectile */
 	50    /* Explosion */
-}; 
+};
 
 // this is the number of uint16s the data has to be stored, not the length of the data in dungeon.dat!
 byte g235_ThingDataWordCount[16] = { // @ G0235_auc_Graphic559_ThingDataByteCount
@@ -532,7 +533,7 @@ byte g235_ThingDataWordCount[16] = { // @ G0235_auc_Graphic559_ThingDataByteCoun
 	0,   /* Unused */
 	5,   /* Projectile */
 	2    /* Explosion */
-}; 
+};
 
 const Thing Thing::_none(0); // @ C0xFFFF_THING_NONE
 const Thing Thing::_endOfList(0xFFFE); // @ C0xFFFE_THING_ENDOFLIST
@@ -826,140 +827,154 @@ Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) {
 }
 
 
-// TODO: get rid of the GOTOs
+// TODO: produce more GOTOs
 void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) {	// complete, except where marked
-	_vm->_displayMan->_g289_championPortraitOrdinal = 0; // BUG0_75, possible fix
+#define thingType dir
+	byte L0307_uc_Multiple;
+#define square            L0307_uc_Multiple
+#define footprintsAllowed L0307_uc_Multiple
+#define scentOrdinal      L0307_uc_Multiple
+	Sensor* sensor;
+	bool leftRandWallOrnAllowed;
+	int16 L0310_i_Multiple;
+#define frontRandWallOrnAllowed L0310_i_Multiple
+#define sideIndex                      L0310_i_Multiple
+	bool rightRandWallOrnAllowed;
+	int16 thingTypeRedEagle;
+	bool squreIsFakeWall;
+	Thing thing;
+
 
 	for (uint16 i = 0; i < 5; ++i)
 		aspectArray[i] = 0;
 
-	Thing thing = f161_getSquareFirstThing(mapX, mapY);
-	Square square = f151_getSquare(mapX, mapY);
-
-	aspectArray[k0_ElemAspect] = square.getType();
-
-	bool leftOrnAllowed = false;
-	bool rightOrnAllowed = false;
-	bool frontOrnAllowed = false;
-	bool squareIsFakeWall = false;
-	bool footPrintsAllowed = false;
-	switch (square.getType()) {
-	case k0_WallElemType:
+	thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
+	square = _vm->_dungeonMan->f151_getSquare(mapX, mapY).toByte();
+	switch (aspectArray[k0_ElemAspect] = Square(square).getType()) {
+	case k0_ElementTypeWall:
 		switch (dir) {
 		case kDirNorth:
-			leftOrnAllowed = square.get(k0x0004_WallEastRandOrnAllowed);
-			frontOrnAllowed = square.get(k0x0002_WallSouthRandOrnAllowed);
-			rightOrnAllowed = square.get(k0x0001_WallWestRandOrnAllowed);
+			leftRandWallOrnAllowed = getFlag(square, k0x0004_WallEastRandOrnAllowed);
+			frontRandWallOrnAllowed = getFlag(square, k0x0002_WallSouthRandOrnAllowed);
+			rightRandWallOrnAllowed = getFlag(square, k0x0001_WallWestRandOrnAllowed);
 			break;
 		case kDirEast:
-			leftOrnAllowed = square.get(k0x0002_WallSouthRandOrnAllowed);
-			frontOrnAllowed = square.get(k0x0001_WallWestRandOrnAllowed);
-			rightOrnAllowed = square.get(k0x0008_WallNorthRandOrnAllowed);
+			leftRandWallOrnAllowed = getFlag(square, k0x0002_WallSouthRandOrnAllowed);
+			frontRandWallOrnAllowed = getFlag(square, k0x0001_WallWestRandOrnAllowed);
+			rightRandWallOrnAllowed = getFlag(square, k0x0008_WallNorthRandOrnAllowed);
 			break;
 		case kDirSouth:
-			leftOrnAllowed = square.get(k0x0001_WallWestRandOrnAllowed);
-			frontOrnAllowed = square.get(k0x0008_WallNorthRandOrnAllowed);
-			rightOrnAllowed = square.get(k0x0004_WallEastRandOrnAllowed);
+			leftRandWallOrnAllowed = getFlag(square, k0x0001_WallWestRandOrnAllowed);
+			frontRandWallOrnAllowed = getFlag(square, k0x0008_WallNorthRandOrnAllowed);
+			rightRandWallOrnAllowed = getFlag(square, k0x0004_WallEastRandOrnAllowed);
 			break;
 		case kDirWest:
-			leftOrnAllowed = square.get(k0x0008_WallNorthRandOrnAllowed);
-			frontOrnAllowed = square.get(k0x0004_WallEastRandOrnAllowed);
-			rightOrnAllowed = square.get(k0x0002_WallSouthRandOrnAllowed);
-			break;
-		default:
-			break;
+			leftRandWallOrnAllowed = getFlag(square, k0x0008_WallNorthRandOrnAllowed);
+			frontRandWallOrnAllowed = getFlag(square, k0x0004_WallEastRandOrnAllowed);
+			rightRandWallOrnAllowed = getFlag(square, k0x0002_WallSouthRandOrnAllowed);
 		}
-
+ /* BUG0_75 Multiple champion portraits are drawn (one at a time) then the game crashes. This variable is only
+ reset to 0 when at least one square in the dungeon view is a wall. If the party is in front of a wall with a
+ champion portrait and the next time the dungeon view is drawn there is no wall square in the view and the
+ square in front of the party is a fake wall with a random ornament then the same champion portrait will be
+ drawn again because the variable was not reset to 0. Each time _vm->_displayMan->f107_isDrawnWallOrnAnAlcove
+ draws the portrait, _vm->_displayMan->_g289_championPortraitOrdinal is decremented so that the portait is
+ different each time the dungeon view is drawn until the game crashes */
+		_vm->_displayMan->_g289_championPortraitOrdinal = 0;
+		squreIsFakeWall = false;
 T0172010_ClosedFakeWall:
-		f171_setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall);
-
-		while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) {
-			int16 sideIndex = (thing.getCell() - dir) & 3;
-			if (sideIndex) {
-				if (thing.getType() == k2_TextstringType) {
-					if (TextString(f156_getThingData(thing)).isVisible()) {
-						aspectArray[sideIndex + 1] = _g265_currMapInscriptionWallOrnIndex + 1;
-						_vm->_displayMan->_g290_inscriptionThing = thing; // BUG0_76
+		_vm->_dungeonMan->f171_setSquareAspectOrnOrdinals(aspectArray,
+														  leftRandWallOrnAllowed, frontRandWallOrnAllowed, rightRandWallOrnAllowed, dir, mapX, mapY, squreIsFakeWall);
+		while ((thing != Thing::_endOfList) && ((thingTypeRedEagle = thing.getType()) <= k3_SensorThingType)) {
+			if (sideIndex = M21_normalizeModulo4(thing.getCell() - dir)) { /* Invisible on the back wall if 0 */
+				sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(thing);
+				if (thingTypeRedEagle == k2_TextstringType) {
+					if (((TextString*)sensor)->isVisible()) {
+						aspectArray[sideIndex + 1] = _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex + 1;
+/* BUG0_76 The same text is drawn on multiple sides of a wall square. The engine stores only a
+single text to draw on a wall in a global variable. Even if different texts are placed on
+differents sides of the wall, the same text is drawn on each affected side */
+						_vm->_displayMan->_g290_inscriptionThing = thing;
 					}
 				} else {
-					Sensor sensor(f156_getThingData(thing));
-					aspectArray[sideIndex + 1] = sensor.getOrnOrdinal();
-					if (sensor.getType() == k127_SensorWallChampionPortrait) {
-						_vm->_displayMan->_g289_championPortraitOrdinal = _vm->M0_indexToOrdinal(sensor.getData());
+					aspectArray[sideIndex + 1] = sensor->getOrnOrdinal();
+					if (sensor->getType() == k127_SensorWallChampionPortrait) {
+						_vm->_displayMan->_g289_championPortraitOrdinal = _vm->M0_indexToOrdinal(sensor->getData());
 					}
 				}
 			}
-			thing = f159_getNextThing(thing);
+			thing = _vm->_dungeonMan->f159_getNextThing(thing);
 		}
-		if (squareIsFakeWall && (_g306_partyMapX != mapX) && (_g307_partyMapY != mapY)) {
+		if (squreIsFakeWall && (_vm->_dungeonMan->_g306_partyMapX != mapX) && (_vm->_dungeonMan->_g307_partyMapY != mapY)) {
 			aspectArray[k1_FirstGroupOrObjectAspect] = Thing::_endOfList.toUint16();
 			return;
 		}
 		break;
-	case k2_PitElemType:
-		if (square.get(k0x0008_PitOpen)) {
-			aspectArray[k2_PitInvisibleAspect] = square.get(k0x0004_PitInvisible);
-			footPrintsAllowed = square.toByte() & 1;
+	case k2_ElementTypePit:
+		if (getFlag(square, k0x0008_PitOpen)) {
+			aspectArray[k2_PitInvisibleAspect] = getFlag(square, k0x0004_PitInvisible);
+			footprintsAllowed &= 0x0001;
 		} else {
 			aspectArray[k0_ElemAspect] = k1_CorridorElemType;
-			footPrintsAllowed = true;
+			footprintsAllowed = true;
 		}
 		goto T0172030_Pit;
-	case k6_FakeWallElemType:
-		if (!square.get(k0x0004_FakeWallOpen)) {
-			aspectArray[k0_ElemAspect] = k0_WallElemType;
-			leftOrnAllowed = rightOrnAllowed = frontOrnAllowed = square.get(k0x0008_FakeWallRandOrnOrFootPAllowed);
-			squareIsFakeWall = true;
+	case k6_ElementTypeFakeWall:
+		if (!getFlag(square, k0x0004_FakeWallOpen)) {
+			aspectArray[k0_ElemAspect] = k0_ElementTypeWall;
+			leftRandWallOrnAllowed = rightRandWallOrnAllowed = frontRandWallOrnAllowed = getFlag(square, k0x0008_FakeWallRandOrnOrFootPAllowed);
+			squreIsFakeWall = true;
 			goto T0172010_ClosedFakeWall;
 		}
-		aspectArray[k0_WallElemType] = k1_CorridorElemType;
-		footPrintsAllowed = square.get(k0x0008_FakeWallRandOrnOrFootPAllowed);
-		square = Square(footPrintsAllowed ? 8 : 0);
-		// intentional fallthrough
+		aspectArray[k0_ElemAspect] = k1_CorridorElemType;
+		footprintsAllowed = getFlag(square, k0x0008_FakeWallRandOrnOrFootPAllowed) ? 8 : 0;
 	case k1_CorridorElemType:
-		aspectArray[k4_FloorOrnOrdAspect] = f170_getRandomOrnOrdinal(square.get(k0x0008_CorridorRandOrnAllowed), _g269_currMap->_randFloorOrnCount, mapX, mapY, 30);
+		aspectArray[k4_FloorOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(getFlag(square, k0x0008_CorridorRandOrnAllowed),
+																					   _vm->_dungeonMan->_g269_currMap->_randFloorOrnCount, mapX, mapY, 30);
 T0172029_Teleporter:
-		footPrintsAllowed = true;
+		footprintsAllowed = true;
 T0172030_Pit:
-		while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) {
-			if (thing.getType() == k3_SensorThingType)
-				aspectArray[k4_FloorOrnOrdAspect] = Sensor(f156_getThingData(thing)).getOrnOrdinal();
-			thing = f159_getNextThing(thing);
+		while ((thing != Thing::_endOfList) && ((thingType = (direction)thing.getType()) <= k3_SensorThingType)) {
+			if (thingType == k3_SensorThingType) {
+				sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(thing);
+				aspectArray[k4_FloorOrnOrdAspect] = sensor->getOrnOrdinal();
+			}
+			thing = _vm->_dungeonMan->f159_getNextThing(thing);
 		}
 		goto T0172049_Footprints;
-	case k5_TeleporterElemType:
-		aspectArray[k2_TeleporterVisibleAspect] = square.get(k0x0008_TeleporterOpen) && square.get(k0x0004_TeleporterVisible);
+	case k5_ElementTypeTeleporter:
+		aspectArray[k2_TeleporterVisibleAspect] = getFlag(square, k0x0008_TeleporterOpen) && getFlag(square, k0x0004_TeleporterVisible);
 		goto T0172029_Teleporter;
-	case k3_StairsElemType:
-		aspectArray[k0_ElemAspect] = ((square.get(k0x0008_StairsNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) ? k18_StairsSideElemType : k19_StairsFrontElemType;
-		aspectArray[k2_StairsUpAspect] = square.get(k0x0004_StairsUp);
-		footPrintsAllowed = false;
+	case k3_ElementTypeStairs:
+		aspectArray[k0_ElemAspect] = ((getFlag(square, k0x0008_StairsNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront;
+		aspectArray[k2_StairsUpAspect] = getFlag(square, k0x0004_StairsUp);
+		footprintsAllowed = false;
 		goto T0172046_Stairs;
 	case k4_DoorElemType:
-		if ((square.get(k0x0008_DoorNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) {
+		if ((getFlag(square, k0x0008_DoorNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) {
 			aspectArray[k0_ElemAspect] = k16_DoorSideElemType;
 		} else {
 			aspectArray[k0_ElemAspect] = k17_DoorFrontElemType;
-			aspectArray[k2_DoorStateAspect] = square.getDoorState();
-			aspectArray[k3_DoorThingIndexAspect] = f161_getSquareFirstThing(mapX, mapY).getIndex();
+			aspectArray[k2_DoorStateAspect] = Square(square).getDoorState();
+			aspectArray[k3_DoorThingIndexAspect] = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY).getIndex();
 		}
-		footPrintsAllowed = true;
+		footprintsAllowed = true;
 T0172046_Stairs:
-		while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType))
-			thing = f159_getNextThing(thing);
+		while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) {
+			thing = _vm->_dungeonMan->f159_getNextThing(thing);
+		}
 T0172049_Footprints:
-		unsigned char scentOrdinal; // see next line comment
-		if (footPrintsAllowed) // TODO: I skipped some party query code, must come back later and complete
-			aspectArray[k4_FloorOrnOrdAspect] &= k0x8000_FootprintsAspect;
-		break;
-	default:
-		break;
+		if (footprintsAllowed && (scentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapX, mapY))
+			&& (--scentOrdinal >= _vm->_championMan->_g407_party._firstScentIndex)
+			&& (scentOrdinal < _vm->_championMan->_g407_party._lastScentIndex)) {
+			setFlag(aspectArray[k4_FloorOrnOrdAspect], k0x8000_FootprintsAspect);
+		}
 	}
 	aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16();
 }
 
 void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
-											int16 mapX, int16 mapY, bool isFakeWall) {
+												 int16 mapX, int16 mapY, bool isFakeWall) {
 	int16 ornCount = _g269_currMap->_randWallOrnCount;
 
 	turnDirRight(dir);
@@ -1336,4 +1351,34 @@ int16 DungeonMan::f142_getProjectileAspect(Thing thing) {
 	return g237_ObjectInfo[f141_getObjectInfoIndex(thing)]._objectAspectIndex;
 }
 
+int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16* mapX, int16* mapY) {
+	int16 newMapX;
+	int16 newMapY;
+	int16 newLevel;
+	int16 offset;
+	Map* map;
+	int16 targetMapIndex;
+
+
+	if (_vm->_dungeonMan->_g309_partyMapIndex == k255_mapIndexEntrance) {
+		return kM1_mapIndexNone;
+	}
+	map = _vm->_dungeonMan->_g277_dungeonMaps + mapIndex;
+	newMapX = map->_offsetMapX + *mapX;
+	newMapY = map->_offsetMapY + *mapY;
+	newLevel = map->_level + levelDelta;
+	map = _vm->_dungeonMan->_g277_dungeonMaps;
+	for (targetMapIndex = 0; targetMapIndex < _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount; targetMapIndex++) {
+		if ((map->_level == newLevel)
+			&& (newMapX >= (offset = map->_offsetMapX))
+			&& (newMapX <= (offset + map->_width))
+			&& (newMapY >= (offset = map->_offsetMapY)) && (newMapY <= (offset + map->_height))) {
+			*mapY = newMapY - offset;
+			*mapX = newMapX - map->_offsetMapX;
+			return targetMapIndex;
+		}
+		map++;
+	}
+	return kM1_mapIndexNone;
+}
 }
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index d2a82ac..a32edcf 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -648,6 +648,7 @@ public:
 	void f163_linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY); // @ F0163_DUNGEON_LinkThingToList
 	WeaponInfo *f158_getWeaponInfo(Thing thing); // @ F0158_DUNGEON_GetWeaponInfo
 	int16 f142_getProjectileAspect(Thing thing); // @ F0142_DUNGEON_GetProjectileAspect
+	int16 f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16 *mapX, int16 *mapY); // @ F0154_DUNGEON_GetLocationAfterLevelChange
 
 	uint32 _rawDunFileDataSize;	 // @ probably NONE
 	byte *_rawDunFileData; // @ ???
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 2a9a90d..460e7b5 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -40,6 +40,19 @@
 
 namespace DM {
 
+Box g106_BoxThievesEye_ViewPortVisibleArea(64, 159, 19, 113); // @ G0106_s_Graphic558_Box_ThievesEye_ViewportVisibleArea 
+byte g198_PalChangesDoorButtonAndWallOrn_D3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3
+byte g199_PalChangesDoorButtonAndWallOrn_D2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2
+
+byte g197_doorButtonCoordSet[1] = {0}; // @ G0197_auc_Graphic558_DoorButtonCoordinateSet
+
+uint16 g208_doorButtonCoordSets[1][4][6] = { // @ G0208_aaauc_Graphic558_DoorButtonCoordinateSets
+	/* X1, X2, Y1, Y2, ByteWidth, Height */
+	{{199, 204, 41, 44, 8, 4},     /* D3R */
+	{136, 141, 41, 44, 8, 4},     /* D3C */
+	{144, 155, 42, 47, 8, 6},     /* D2C */
+	{160, 175, 44, 52, 8, 9}}}; /* D1C */
+
 DoorFrames g179_doorFrame_D3L = { // @ G0179_s_Graphic558_Frames_Door_D3L
 								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
 	Frame(24, 71, 28, 67, 24, 41,  0,  0),     /* Closed Or Destroyed */
@@ -1073,12 +1086,57 @@ void DisplayMan::f461_allocateFlippedWallBitmaps() {
 
 void DisplayMan::f102_drawDoorBitmap(Frame* frame) {
 	if (frame->_srcByteWidth) {
-		f132_blitToBitmap(_vm->_displayMan->_g74_tmpBitmap,
-						  _vm->_displayMan->_g296_bitmapViewport,
+		f132_blitToBitmap(_g74_tmpBitmap,
+						  _g296_bitmapViewport,
 						  frame->_box, frame->_srcX, frame->_srcY, frame->_srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, frame->_srcHeight, k136_heightViewport);
 	}
 }
 
+void DisplayMan::f103_drawDoorFrameBitmapFlippedHorizontally(byte* bitmap, Frame* frame) {
+	if (frame->_srcByteWidth) {
+		f130_flipBitmapHorizontal(bitmap, frame->_srcByteWidth, frame->_srcHeight);
+		f132_blitToBitmap(bitmap, _g296_bitmapViewport, frame->_box, frame->_srcX, frame->_srcY,
+						  frame->_srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, frame->_srcHeight, k136_heightViewport);
+	}
+}
+
+void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButtonIndex) {
+	int16 nativeBitmapIndex;
+	int coordSet;
+	uint16* coordSetRedEagle;
+	byte* bitmap;
+	byte* bitmapNative;
+
+	if (doorButtonOrdinal) {
+		doorButtonOrdinal--;
+		nativeBitmapIndex = doorButtonOrdinal + k315_firstDoorButton_GraphicIndice;
+		coordSetRedEagle = g208_doorButtonCoordSets[coordSet = g197_doorButtonCoordSet[doorButtonOrdinal]][viewDoorButtonIndex];
+		if (viewDoorButtonIndex == k3_viewDoorButton_D1C) {
+			bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+
+			_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordSetRedEagle[0];
+			_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordSetRedEagle[1];
+			_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordSetRedEagle[2];
+			_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordSetRedEagle[3];
+		} else {
+			if (!f491_isDerivedBitmapInCache(doorButtonOrdinal = k102_DerivedBitmapFirstDoorButton + (doorButtonOrdinal * 2) + ((!viewDoorButtonIndex) ? 0 : viewDoorButtonIndex - 1))) {
+				uint16* coordSetBlueGoat = g208_doorButtonCoordSets[coordSet][k3_viewDoorButton_D1C];
+				bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+				f129_blitToBitmapShrinkWithPalChange(bitmapNative, f492_getDerivedBitmap(doorButtonOrdinal),
+													 coordSetBlueGoat[4] << 1, coordSetBlueGoat[5],
+													 coordSetRedEagle[1] - coordSetRedEagle[0] + 1,
+													 coordSetRedEagle[5],
+													 (viewDoorButtonIndex == k2_viewDoorButton_D2C) ? g199_PalChangesDoorButtonAndWallOrn_D2 : g198_PalChangesDoorButtonAndWallOrn_D3);
+
+				f493_addDerivedBitmap(doorButtonOrdinal);
+			}
+			bitmap = f492_getDerivedBitmap(doorButtonOrdinal);
+		}
+		f132_blitToBitmap(bitmap, _g296_bitmapViewport, *(Box*)coordSetRedEagle, 0, 0,
+						  coordSetRedEagle[4], k112_byteWidthViewport, k10_ColorFlesh, coordSetRedEagle[5], k136_heightViewport);
+	}
+}
+
 void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* topAndBottomScreen) {
 	if (middleScreenPalette && topAndBottomScreen)
 		debugC(kDMDebugOftenCalledWarning, "MISSING CODE: F0508_AMIGA_BuildPaletteChangeCopperList");
@@ -1348,20 +1406,20 @@ void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloor
 		}
 		floorOrnOrdinal--;
 		floorOrnIndex = floorOrnOrdinal;
-		nativeBitmapIndex = _vm->_displayMan->_g102_currMapFloorOrnInfo[floorOrnIndex][k0_NativeBitmapIndex]
+		nativeBitmapIndex = _g102_currMapFloorOrnInfo[floorOrnIndex][k0_NativeBitmapIndex]
 			+ g191_floorOrnNativeBitmapndexInc[viewFloorIndex];
-		coordSets = g206_floorOrnCoordSets[_vm->_displayMan->_g102_currMapFloorOrnInfo[floorOrnIndex][k1_CoordinateSet]][viewFloorIndex];
+		coordSets = g206_floorOrnCoordSets[_g102_currMapFloorOrnInfo[floorOrnIndex][k1_CoordinateSet]][viewFloorIndex];
 		if ((viewFloorIndex == k8_viewFloor_D1R) || (viewFloorIndex == k5_viewFloor_D2R)
 			|| (viewFloorIndex == k2_viewFloor_D3R)
-			|| ((floorOrnIndex == k15_FloorOrnFootprints) && _vm->_displayMan->_g76_useFlippedWallAndFootprintsBitmap &&
+			|| ((floorOrnIndex == k15_FloorOrnFootprints) && _g76_useFlippedWallAndFootprintsBitmap &&
 			((viewFloorIndex == k7_viewFloor_D1C) || (viewFloorIndex == k4_viewFloor_D2C) || (viewFloorIndex == k1_viewFloor_D3C)))) {
-			_vm->_displayMan->f99_copyBitmapAndFlipHorizontal(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
-															  bitmap = _vm->_displayMan->_g74_tmpBitmap, coordSets[4], coordSets[5]);
+			f99_copyBitmapAndFlipHorizontal(f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
+											bitmap = _g74_tmpBitmap, coordSets[4], coordSets[5]);
 		} else {
-			bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+			bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
 		}
-		_vm->_displayMan->f132_blitToBitmap(bitmap, _vm->_displayMan->_g296_bitmapViewport,
-											*(Box*)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport);
+		f132_blitToBitmap(bitmap, _g296_bitmapViewport,
+						  *(Box*)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport);
 T0108005:
 		if (drawFootprints) {
 			f108_drawFloorOrnament(_vm->M0_indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex);
@@ -1382,10 +1440,10 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d
 		f109_drawDoorOrnament(door->getOrnOrdinal(), viewDoorOrnIndex);
 		if (getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[doorType]._attributes, k0x0004_MaskDoorInfo_Animated)) {
 			if (_vm->_rnd->getRandomNumber(1)) {
-				_vm->_displayMan->f130_flipBitmapHorizontal(_vm->_displayMan->_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
+				f130_flipBitmapHorizontal(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
 			}
 			if (_vm->_rnd->getRandomNumber(1)) {
-				f131_flipVertical(_vm->_displayMan->_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
+				f131_flipVertical(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
 			}
 		}
 		if ((doorFramesTemp == &g186_doorFrame_D1C) && _vm->_championMan->_g407_party._event73Count_ThievesEye) {
@@ -1427,25 +1485,25 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn
 
 	if (doorOrnOrdinal) {
 		doorOrnOrdinal--;
-		nativeBitmapIndex = _vm->_displayMan->_g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex];
-		coordSetOrangeElk = g207_doorOrnCoordSets[coordSetGreenToad = _vm->_displayMan->_g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]][viewDoorOrnIndex];
+		nativeBitmapIndex = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex];
+		coordSetOrangeElk = g207_doorOrnCoordSets[coordSetGreenToad = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]][viewDoorOrnIndex];
 		if (viewDoorOrnIndex == k2_ViewDoorOrnament_D1LCR) {
-			bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+			bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
 			byteWidth = 48;
 			height = 88;
 		} else {
-			if (!_vm->_displayMan->f491_isDerivedBitmapInCache(doorOrnOrdinal = k68_DerivedBitmapFirstDoorOrnament_D3 + (doorOrnOrdinal * 2) + viewDoorOrnIndex)) {
+			if (!f491_isDerivedBitmapInCache(doorOrnOrdinal = k68_DerivedBitmapFirstDoorOrnament_D3 + (doorOrnOrdinal * 2) + viewDoorOrnIndex)) {
 				uint16 *coordSetRedEagle = g207_doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR];
-				bitmapNative = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
-				_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmapNative,
-																	   f492_getDerivedBitmap(doorOrnOrdinal),
-																	   coordSetRedEagle[4] << 1, coordSetRedEagle[5],
-																	   coordSetOrangeElk[2] - coordSetOrangeElk[0] + 1,
-																	   coordSetOrangeElk[5],
-																	   (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2);
-				_vm->_displayMan->f493_addDerivedBitmap(doorOrnOrdinal);
+				bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+				f129_blitToBitmapShrinkWithPalChange(bitmapNative,
+													 f492_getDerivedBitmap(doorOrnOrdinal),
+													 coordSetRedEagle[4] << 1, coordSetRedEagle[5],
+													 coordSetOrangeElk[2] - coordSetOrangeElk[0] + 1,
+													 coordSetOrangeElk[5],
+													 (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2);
+				f493_addDerivedBitmap(doorOrnOrdinal);
 			}
-			bitmap = _vm->_displayMan->f492_getDerivedBitmap(doorOrnOrdinal);
+			bitmap = f492_getDerivedBitmap(doorOrnOrdinal);
 			if (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) {
 				byteWidth = 24;
 				height = 41;
@@ -1454,8 +1512,25 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn
 				height = 61;
 			}
 		}
-		_vm->_displayMan->f132_blitToBitmap(bitmap, _vm->_displayMan->_g74_tmpBitmap,
-											*(Box*)coordSetOrangeElk, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height);
+		f132_blitToBitmap(bitmap, _g74_tmpBitmap,
+						  *(Box*)coordSetOrangeElk, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height);
+	}
+}
+
+void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame* frame, int16 mapX, int16 mapY, bool flipHorizontal) {
+	int16 L0117_i_Multiple;
+#define AL0117_i_MapIndex L0117_i_Multiple
+#define AL0117_i_Square   L0117_i_Multiple
+
+
+	if (((AL0117_i_MapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g272_currMapIndex, -1, &mapX, &mapY)) >= 0) &&
+		(Square(AL0117_i_Square = _vm->_dungeonMan->_g279_dungeonMapData[AL0117_i_MapIndex][mapX][mapY]).getType() == k2_ElementTypePit) &&
+		getFlag(AL0117_i_Square, k0x0008_PitOpen)) {
+		if (flipHorizontal) {
+			_vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(nativeBitmapIndex, *frame);
+		} else {
+			_vm->_displayMan->f104_drawFloorPitOrStairsBitmap(nativeBitmapIndex, *frame);
+		}
 	}
 }
 
@@ -1553,9 +1628,9 @@ void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) {
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
 		memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44);
-		warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally");
+		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g165_Frame_DoorFrameRight_D3R);
 		if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
-			warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton");
+			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k0_viewDoorButton_D3R);
 		}
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect],
 					  squareAspect[k2_DoorStateAspect], _g693_doorNativeBitmapIndex_Front_D3LCR,
@@ -1581,162 +1656,393 @@ T0117018:
 }
 
 void DisplayMan::f118_drawSquareD3C(direction dir, int16 posX, int16 posY) {
-	uint16 squareAspect[5];
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[0]) {
-	case k19_StairsFrontElemType:
-		if (squareAspect[k2_StairsUpAspect])
+	int16 order;
+	int16 squareAspect[5];
+
+
+	_vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY);
+	switch (squareAspect[k0_ElemAspect]) {
+	case k19_ElementTypeStaisFront:
+		if (squareAspect[k2_StairsUpAspect]) {
 			f104_drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, g111_FrameStairsUpFront_D3C);
-		else
+		} else {
 			f104_drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, g122_FrameStairsDownFront_D3C);
-		break;
-	case k0_WallElemType:
+		}
+		goto T0118027;
+	case k0_ElementTypeWall:
 		f101_drawWallSetBitmapWithoutTransparency(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k0_ViewSquare_D3C]);
 		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) {
-			//... missing code
+			order = k0x0000_CellOrder_Alcove;
+			goto T0118028;
 		}
-		break;
-	default:
-		break;
+		return;
+	case k17_DoorFrontElemType:
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C);
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
+		f100_drawWallSetBitmap(_g706_bitmapWallSet_DoorFrameLeft_D3C, g166_Frame_DoorFrameLeft_D3C);
+		memmove(_g74_tmpBitmap, _g706_bitmapWallSet_DoorFrameLeft_D3C, 32 * 44);
+		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g167_Frame_DoorFrameRight_D3C);
+		if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
+			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k1_ViewDoorOrnament_D2LCR);
+		}
+		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
+					  _g693_doorNativeBitmapIndex_Front_D3LCR, M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &g180_doorFrame_D3C);
+		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
+		goto T0118028;
+	case k2_ElementTypePit:
+		if (!squareAspect[k2_PitInvisibleAspect]) {
+			f104_drawFloorPitOrStairsBitmap(k50_FloorPit_D3C_GraphicIndice, g141_FrameFloorPit_D3C);
+		}
+	case k5_ElementTypeTeleporter:
+	case k1_CorridorElemType:
+T0118027:
+		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+T0118028:
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, order);
+	}
+	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+		f113_drawField(&g188_FieldAspects[k0_ViewSquare_D3C], g163_FrameWalls[k0_ViewSquare_D3C]._box);
 	}
 }
 void DisplayMan::f119_drawSquareD2L(direction dir, int16 posX, int16 posY) {
-	uint16 squareAspect[5];
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[0]) {
-	case k19_StairsFrontElemType:
-		if (squareAspect[k2_StairsUpAspect])
-			f104_drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L);
-		else
-			f104_drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L);
-		break;
-	case k0_WallElemType:
-		f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k4_ViewSquare_D2L]);
-		f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) {
-			// ... missing code
+	int16 order;
+	int16 squareAspect[5];
+
+
+	_vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY);
+	switch (squareAspect[k0_ElemAspect]) {
+	case k19_ElementTypeStaisFront:
+		if (squareAspect[k2_StairsUpAspect]) {
+			_vm->_displayMan->f104_drawFloorPitOrStairsBitmap(_vm->_displayMan->_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L);
+		} else {
+			_vm->_displayMan->f104_drawFloorPitOrStairsBitmap(_vm->_displayMan->_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L);
 		}
-		break;
-	case k18_StairsSideElemType:
-		f104_drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L);
-		break;
-	default:
-		break;
+		goto T0119018;
+	case k0_ElementTypeWall:
+		_vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k4_ViewSquare_D2L]);
+		_vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT);
+		if (_vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) {
+			order = k0x0000_CellOrder_Alcove;
+			goto T0119020;
+		}
+		return;
+	case k18_ElementTypeStairsSide:
+		_vm->_displayMan->f104_drawFloorPitOrStairsBitmap(_vm->_displayMan->_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L);
+	case k16_DoorSideElemType:
+		order = k0x0342_CellOrder_BackRight_FrontLeft_FrontRight;
+		goto T0119019;
+	case k17_DoorFrontElemType:
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L);
+		_vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
+		_vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g703_bitmapWallSet_DoorFrameTop_D2LCR, g173_Frame_DoorFrameTop_D2L);
+		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], _g694_doorNativeBitmapIndex_Front_D2LCR,
+					  M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &g182_doorFrame_D2L);
+		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
+		goto T0119020;
+	case k2_ElementTypePit:
+		_vm->_displayMan->f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice,
+														  g143_FrameFloorPit_D2L);
+	case k5_ElementTypeTeleporter:
+	case k1_CorridorElemType:
+T0119018:
+		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
+T0119019:
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+T0119020:
+		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &g152_FrameFloorPit_D2L, posX, posY, false);
+		_vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, order);
+	}
+	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+		_vm->_displayMan->f113_drawField(&g188_FieldAspects[k4_ViewSquare_D2L], g163_FrameWalls[k4_ViewSquare_D2L]._box);
 	}
 }
 void DisplayMan::f120_drawSquareD2R(direction dir, int16 posX, int16 posY) {
-	uint16 squareAspect[5];
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[0]) {
-	case k19_StairsFrontElemType:
-		if (squareAspect[k2_StairsUpAspect])
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R);
-		else
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R);
-		break;
-	case k0_WallElemType:
-		f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k5_ViewSquare_D2R]);
-		f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) {
-			// ... missing code
+	int16 order;
+	int16 squareAspect[5];
+
+
+	_vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY);
+	switch (squareAspect[k0_ElemAspect]) {
+	case k19_ElementTypeStaisFront:
+		if (squareAspect[k2_StairsUpAspect]) {
+			_vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_vm->_displayMan->_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R);
+		} else {
+			_vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_vm->_displayMan->_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R);
 		}
-		break;
-	case k18_StairsSideElemType:
-		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R);
-		break;
-	default:
-		break;
+		goto T0120027;
+	case k0_ElementTypeWall:
+		_vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k5_ViewSquare_D2R]);
+		_vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT);
+		if (_vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) {
+			order = k0x0000_CellOrder_Alcove;
+			goto T0120029;
+		}
+		return;
+	case k18_ElementTypeStairsSide:
+		_vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_vm->_displayMan->_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R);
+	case k16_DoorSideElemType:
+		order = k0x0431_CellOrder_BackLeft_FrontRight_FrontLeft;
+		goto T0120028;
+	case k17_DoorFrontElemType:
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_ViewSquare_D2R);
+		_vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
+		_vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g703_bitmapWallSet_DoorFrameTop_D2LCR, g175_Frame_DoorFrameTop_D2R);
+		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
+					  _g694_doorNativeBitmapIndex_Front_D2LCR, M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &g184_doorFrame_D2R);
+		order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft;
+		goto T0120029;
+	case k2_ElementTypePit:
+		_vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect]
+																			 ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice, g145_FrameFloorPit_D2R);
+	case k5_ElementTypeTeleporter:
+	case k1_CorridorElemType:
+T0120027:
+		order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft;
+T0120028:
+/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_viewFloor_D2R);
+		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &g154_FrameFloorPit_D2R, posX, posY, true);
+T0120029:
+		_vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, order);
+	}
+	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+		_vm->_displayMan->f113_drawField(&g188_FieldAspects[k5_ViewSquare_D2R], g163_FrameWalls[k5_ViewSquare_D2R]._box);
 	}
 }
 void DisplayMan::f121_drawSquareD2C(direction dir, int16 posX, int16 posY) {
-	uint16 squareAspect[5];
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[0]) {
-	case k19_StairsFrontElemType:
-		if (squareAspect[k2_StairsUpAspect])
+	int16 order;
+	int16 squareAspect[5];
+
+
+	_vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY);
+	switch (squareAspect[k0_ElemAspect]) {
+	case k19_ElementTypeStaisFront:
+		if (squareAspect[k2_StairsUpAspect]) {
 			f104_drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, g114_FrameStairsUpFront_D2C);
-		else
+		} else {
 			f104_drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, g125_FrameStairsDownFront_D2C);
-		break;
-	case k0_WallElemType:
+		}
+		goto T0121015;
+	case k0_ElementTypeWall:
 		f101_drawWallSetBitmapWithoutTransparency(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k3_ViewSquare_D2C]);
 		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) {
-			// ... missing code
+			order = k0x0000_CellOrder_Alcove;
+			goto T0121016;
 		}
-		break;
-	default:
-		break;
+		return;
+	case k17_DoorFrontElemType:
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C);
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
+		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, g174_Frame_DoorFrameTop_D2C);
+		f100_drawWallSetBitmap(_g707_bitmapWallSet_DoorFrameLeft_D2C, g168_Frame_DoorFrameLeft_D2C);
+		memcpy(_g74_tmpBitmap, _g707_bitmapWallSet_DoorFrameLeft_D2C, 48 * 65);
+		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g169_Frame_DoorFrameRight_D2C);
+		if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
+			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k2_viewDoorButton_D2C);
+		}
+		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
+					  _g694_doorNativeBitmapIndex_Front_D2LCR, M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &g183_doorFrame_D2C);
+		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
+		goto T0121016;
+	case k2_ElementTypePit:
+		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k58_FloorPit_invisible_D2C_GraphicIndice : k52_FloorPit_D2C_GraphicIndice, g144_FrameFloorPit_D2C);
+	case k5_ElementTypeTeleporter:
+	case k1_CorridorElemType:
+T0121015:
+		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
+ /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C);
+		f112_drawCeilingPit(k64_ceilingPitD2C_GraphicIndice, &g153_FrameFloorPit_D2C, posX, posY, false);
+T0121016:
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, order);
+	}
+	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+		f113_drawField(&g188_FieldAspects[k3_ViewSquare_D2C], g163_FrameWalls[k3_ViewSquare_D2C]._box);
 	}
 }
+
 void DisplayMan::f122_drawSquareD1L(direction dir, int16 posX, int16 posY) {
-	uint16 squareAspect[5];
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[0]) {
-	case k19_StairsFrontElemType:
-		if (squareAspect[k2_StairsUpAspect])
+	int16 order;
+	int16 squareAspect[5];
+
+
+	_vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY);
+	switch (squareAspect[k0_ElemAspect]) {
+	case k19_ElementTypeStaisFront:
+		if (squareAspect[k2_StairsUpAspect]) {
 			f104_drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g116_FrameStairsUpFront_D1L);
-		else
+		} else {
 			f104_drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g127_FrameStairsDownFront_D1L);
-		break;
-	case k0_WallElemType:
+		}
+		goto T0122019;
+	case k0_ElementTypeWall:
 		f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k7_ViewSquare_D1L]);
 		f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT);
-		break;
-	case k18_StairsSideElemType:
-		if (squareAspect[k2_StairsUpAspect])
+		return;
+	case k18_ElementTypeStairsSide:
+		if (squareAspect[k2_StairsUpAspect]) {
 			f104_drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g134_FrameStairsUpSide_D1L);
-		else
+		} else {
 			f104_drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g136_FrameStairsDownSide_D1L);
-		break;
-	default:
-		break;
+		}
+	case k16_DoorSideElemType:
+		order = k0x0032_CellOrder_BackRight_FrontRight;
+		goto T0122020;
+	case k17_DoorFrontElemType:
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, k0x0028_CellOrder_DoorPass1_BackRight);
+		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, g176_Frame_DoorFrameTop_D1L);
+		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
+					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &g185_doorFrame_D1L);
+		order = k0x0039_CellOrder_DoorPass2_FrontRight;
+		goto T0122021;
+	case k2_ElementTypePit:
+		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k59_floorPit_invisible_D1L_GraphicIndice : k53_FloorPit_D1L_GraphicIndice, g146_FrameFloorPit_D1L);
+	case k5_ElementTypeTeleporter:
+	case k1_CorridorElemType:
+T0122019:
+		order = k0x0032_CellOrder_BackRight_FrontRight;
+T0122020:
+		 /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
+		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &g155_FrameFloorPit_D1L, posX, posY, false);
+T0122021:
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, order);
+	}
+	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+		f113_drawField(&g188_FieldAspects[k7_ViewSquare_D1L], g163_FrameWalls[k7_ViewSquare_D1L]._box);
 	}
 }
 void DisplayMan::f123_drawSquareD1R(direction dir, int16 posX, int16 posY) {
-	uint16 squareAspect[5];
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[0]) {
-	case k19_StairsFrontElemType:
-		if (squareAspect[k2_StairsUpAspect])
+	int16 order;
+	int16 squareAspect[5];
+
+
+	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
+	switch (squareAspect[k0_ElemAspect]) {
+	case k19_ElementTypeStaisFront:
+		if (squareAspect[k2_StairsUpAspect]) {
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g118_FrameStairsUpFront_D1R);
-		else
+		} else {
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g129_FrameStairsDownFront_D1R);
-		break;
-	case k0_WallElemType:
+		}
+		goto T0123019;
+	case k0_ElementTypeWall:
 		f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k8_ViewSquare_D1R]);
 		f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT);
-		break;
-	case k18_StairsSideElemType:
-		if (squareAspect[k2_StairsUpAspect])
+		return;
+	case k18_ElementTypeStairsSide:
+		if (squareAspect[k2_StairsUpAspect]) {
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g135_FrameStairsUpSide_D1R);
-		else
+		} else {
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g137_FrameStairsDownSide_D1R);
-		break;
-	default:
-		break;
+		}
+	case k16_DoorSideElemType:
+		order = k0x0041_CellOrder_BackLeft_FrontLeft;
+		goto T0123020;
+	case k17_DoorFrontElemType:
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R);
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, k0x0018_CellOrder_DoorPass1_BackLeft);
+		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, g178_Frame_DoorFrameTop_D1R);
+		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
+					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &g187_doorFrame_D1R);
+		order = k0x0049_CellOrder_DoorPass2_FrontLeft;
+		goto T0123021;
+	case k2_ElementTypePit:
+		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect] ? k59_floorPit_invisible_D1L_GraphicIndice
+														   : k53_FloorPit_D1L_GraphicIndice, g148_FrameFloorPit_D1R);
+	case k5_ElementTypeTeleporter:
+	case k1_CorridorElemType:
+T0123019:
+		order = k0x0041_CellOrder_BackLeft_FrontLeft;
+T0123020:
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &g157_FrameFloorPit_D1R, posX, posY, true);
+T0123021:
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, order);
+	}
+	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+		f113_drawField(&g188_FieldAspects[k8_ViewSquare_D1R], g163_FrameWalls[k8_ViewSquare_D1R]._box);
 	}
 }
 void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) {
-	uint16 squareAspect[5];
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[0]) {
-	case k19_StairsFrontElemType:
-		if (squareAspect[k2_StairsUpAspect])
+	static Box g107_BoxThievesEyeVisibleArea(0, 95, 0, 94); // @ G0107_s_Graphic558_Box_ThievesEye_VisibleArea 
+	int16 order;
+	int16 squareAspect[5];
+	byte* bitmap;
+
+
+	_vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY);
+	switch (_vm->_dungeonMan->_g285_squareAheadElement = (ElementType)squareAspect[k0_ElemAspect]) {
+	case k19_ElementTypeStaisFront:
+		if (squareAspect[k2_StairsUpAspect]) {
 			f104_drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, g117_FrameStairsUpFront_D1C);
-		else
+		} else {
 			f104_drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, g128_FrameStairsDownFront_D1C);
-		break;
-	case k0_WallElemType:
+		}
+		goto T0124017;
+	case k0_ElementTypeWall:
 		_vm->_dungeonMan->_g286_isFacingAlcove = false;
 		_vm->_dungeonMan->_g287_isFacingViAltar = false;
 		_vm->_dungeonMan->_g288_isFacingFountain = false;
+		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
+			f491_isDerivedBitmapInCache(k1_DerivedBitmapThievesEyeVisibleArea);
+			f132_blitToBitmap(_g296_bitmapViewport, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
+							  g107_BoxThievesEyeVisibleArea,
+							  g106_BoxThievesEye_ViewPortVisibleArea._x1,
+							  g106_BoxThievesEye_ViewPortVisibleArea._y1,
+							  k112_byteWidthViewport, 48, k255_ColorNoTransparency, 136, 95);
+			bitmap = f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice);
+ /* BUG0_74 Creatures are drawn with wrong colors when viewed through a wall with the 'Thieve's Eye' spell. The 'hole in wall'
+ graphic is applied to the visible area with transparency on color 10. However the visible area may contain creature graphics
+ that use color 9. When the bitmap is drawn below with transparency on color 9 then the creature graphic is alterated: pixels
+ using color 9 are transparent and the background wall is visible through the creature graphic (grey/white pixels).
+ To fix this bug, the 'hole in wall' graphic should be applied to the wall graphic first (in a temporary buffer) and
+ then the wall with the hole should be drawn over the visible area */
+			f132_blitToBitmap(bitmap, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
+							  g107_BoxThievesEyeVisibleArea,
+							  0, 0, 48, 48, k10_ColorFlesh, 95, 95);
+		}
 		f101_drawWallSetBitmapWithoutTransparency(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k6_ViewSquare_D1C]);
 		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) {
-			// .... code not yet implemneted
+			f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, k0x0000_CellOrder_Alcove);
 		}
-		break;
-	default:
-		break;
+		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
+			f132_blitToBitmap(f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
+				_g296_bitmapViewport, g106_BoxThievesEye_ViewPortVisibleArea, 0, 0,
+							  48, k112_byteWidthViewport, k9_ColorGold, 95, k136_heightViewport); /* BUG0_74 */
+			f493_addDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea);
+			warning("MISSING CODE: F0480_CACHE_ReleaseBlock");
+		}
+		return;
+	case k17_DoorFrontElemType:
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C);
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
+		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, g177_Frame_DoorFrameTop_D1C);
+		f100_drawWallSetBitmap(_g708_bitmapWallSet_DoorFrameLeft_D1C, g170_Frame_DoorFrameLeft_D1C);
+		f100_drawWallSetBitmap(_g710_bitmapWallSet_DoorFrameRight_D1C, g171_Frame_DoorFrameRight_D1C);
+		if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
+			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C);
+		}
+		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
+					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &g186_doorFrame_D1C);
+		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
+		goto T0124018;
+	case k2_ElementTypePit:
+		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k60_floorPitInvisibleD1C_GraphicIndice : k54_FloorPit_D1C_GraphicIndice, g147_FrameFloorPit_D1C);
+	case k5_ElementTypeTeleporter:
+	case k1_CorridorElemType:
+T0124017:
+		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
+/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C); 
+		f112_drawCeilingPit(k66_ceilingPitD1C_GraphicIndice, &g156_FrameFloorPit_D1C, posX, posY, false);
+T0124018:
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, order);
+	}
+	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+		f113_drawField(&g188_FieldAspects[k6_ViewSquare_D1C], g163_FrameWalls[k6_ViewSquare_D1C]._box);
 	}
 }
 
@@ -1757,26 +2063,51 @@ void DisplayMan::f125_drawSquareD0L(direction dir, int16 posX, int16 posY) {
 }
 
 void DisplayMan::f126_drawSquareD0R(direction dir, int16 posX, int16 posY) {
-	uint16 squareAspect[5];
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[0]) {
-	case k18_StairsSideElemType:
-		if (squareAspect[k2_StairsUpAspect])
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R);
+	int16 squareAspect[5];
+
+
+	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
+	switch (squareAspect[k0_ElemAspect]) {
+	case k18_ElementTypeStairsSide:
+		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R);
 		return;
-	case k0_WallElemType:
-		f100_drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, g163_FrameWalls[k11_ViewSquare_D0R]);
-		break;
-	default:
+	case k2_ElementTypePit:
+		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect] ? k61_floorPitInvisibleD0L_GraphicIndice
+														   : k55_FloorPit_D0L_GraphicIndice, g151_FrameFloorPit_D0R);
+	case k1_CorridorElemType:
+	case k16_DoorSideElemType:
+	case k5_ElementTypeTeleporter:
+		f112_drawCeilingPit(k67_ceilingPitD0L_grahicIndice, &g160_FrameFloorPit_D0R, posX, posY, true);
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k11_ViewSquare_D0R, k0x0001_CellOrder_BackLeft);
 		break;
+	case k0_ElementTypeWall:
+		f100_drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, g163_FrameWalls[k11_ViewSquare_D0R]);
+		return;
+	}
+	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+		f113_drawField(&g188_FieldAspects[k11_ViewSquare_D0R], g163_FrameWalls[k11_ViewSquare_D0R]._box);
 	}
 }
 
 void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) {
-	uint16 squareAspect[5];
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[0]) {
-	case k19_StairsFrontElemType:
+	static Box g108_BoxThievesEyeHoleInDoorFrame(0, 31, 19, 113); // @ G0108_s_Graphic558_Box_ThievesEye_HoleInDoorFrame 
+
+	int16 squareAspect[5];
+
+	_vm->_dungeonMan->f172_setSquareAspect((uint16*) squareAspect, dir, posX, posY);
+	switch (squareAspect[k0_ElemAspect]) {
+	case k16_DoorSideElemType:
+		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
+			memmove(_g74_tmpBitmap, _g709_bitmapWallSet_DoorFrameFront, 32 * 123);
+			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice),
+				_g74_tmpBitmap, g108_BoxThievesEyeHoleInDoorFrame, g172_Frame_DoorFrame_D0C._box._x1 - g106_BoxThievesEye_ViewPortVisibleArea._x1,
+							  0, 48, 16, k9_ColorGold, 95, 123);
+			f100_drawWallSetBitmap(_g74_tmpBitmap, g172_Frame_DoorFrame_D0C);
+		} else {
+			f100_drawWallSetBitmap(_g709_bitmapWallSet_DoorFrameFront, g172_Frame_DoorFrame_D0C);
+		}
+		break;
+	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
 			f104_drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g119_FrameStairsUpFront_D0L);
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g120_FrameStairsUpFront_D0R);
@@ -1785,8 +2116,13 @@ void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) {
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g131_FrameStairsDownFront_D0R);
 		}
 		break;
-	default:
-		break;
+	case k2_ElementTypePit:
+		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k62_flootPitInvisibleD0C_graphicIndice : k56_FloorPit_D0C_GraphicIndice, g150_FrameFloorPit_D0C);
+	}
+	f112_drawCeilingPit(k68_ceilingPitD0C_graphicIndice, &g159_FrameFloorPit_D0C, posX, posY, false);
+	f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k9_ViewSquare_D0C, k0x0021_CellOrder_BackLeft_BackRight);
+	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+		f113_drawField(&g188_FieldAspects[k9_ViewSquare_D0C], g163_FrameWalls[k9_ViewSquare_D0C]._box);
 	}
 }
 
@@ -2086,8 +2422,6 @@ byte g190_WallOrnDerivedBitmapIndexIncrement[12] = { // @ G0190_auc_Graphic558_W
 	4,   /* D1L Right */
 	4}; /* D1R Left */
 
-byte g198_PalChangesDoorButtonAndWallOrn_D3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3
-byte g199_PalChangesDoorButtonAndWallOrn_D2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2
 
 byte g204_UnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableInscriptionBoxY2
 	/* { Y for 1 line, Y for 2 lines, Y for 3 lines } */
@@ -2100,141 +2434,168 @@ byte g204_UnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_Unreadabl
 Box g109_BoxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall
 
 bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) {
-	byte *bitmapGreen;
-	byte *bitmapRed;
-	int16 coordinateSetOffset;
-	bool flipHorizontal;
-	bool isInscription;
-	bool isAlcove;
-	Frame frame;
-	unsigned char inscriptionString[70];
+#define AP0116_i_CharacterCount    wallOrnOrd
+#define AP0116_i_WallOrnamentIndex wallOrnOrd
+	int16 L0088_i_Multiple;
+#define AL0088_i_NativeBitmapIndex       L0088_i_Multiple
+#define AL0088_i_UnreadableTextLineCount L0088_i_Multiple
+	int16 L0089_i_Multiple;
+#define AL0089_i_WallOrnamentCoordinateSetIndex L0089_i_Multiple
+#define AL0089_i_FountainOrnamentIndex          L0089_i_Multiple
+#define AL0089_i_PixelWidth                     L0089_i_Multiple
+#define AL0089_i_X                              L0089_i_Multiple
+
+	uint16 *AL0090_puc_CoordinateSet = nullptr;
+
+	byte* L0091_puc_Multiple;
+#define AL0091_puc_Character     L0091_puc_Multiple
+#define AL0091_puc_Bitmap        L0091_puc_Multiple
+	byte* L0092_puc_Bitmap;
+	int16 L0093_i_CoordinateSetOffset;
+	bool L0094_B_FlipHorizontal;
+	bool L0095_B_IsInscription;
+	bool L0096_B_IsAlcove;
+	int16 L0097_i_TextLineIndex;
+	uint16 tmp[6];
+	byte L0099_auc_InscriptionString[70];
 
 
 	if (wallOrnOrd) {
-		int16 var_X;
-		int16 wallOrnIndex = wallOrnOrd - 1;
-		int16 nativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k0_NativeBitmapIndex];
+		wallOrnOrd--;
+		AL0088_i_NativeBitmapIndex = _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k0_NativeBitmapIndex];
 
-		uint16 *coordinateSetA = g205_WallOrnCoordSets[_g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]][viewWallIndex];
-		isAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(wallOrnIndex);
-		isInscription = (wallOrnIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex);
-		if (isInscription) {
-			_vm->_dungeonMan->f168_decodeText((char*)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
-		}
+		AL0090_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex = 
+			_g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k1_CoordinateSet]][viewWallIndex];
 
+		L0096_B_IsAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(AP0116_i_WallOrnamentIndex);
+		if (L0095_B_IsInscription = (AP0116_i_WallOrnamentIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex)) {
+			_vm->_dungeonMan->f168_decodeText((char *)L0099_auc_InscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
+		}
 		if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) {
 			if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
-				if (isInscription) {
-					Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C];
-					f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, g202_BoxWallPatchBehindInscription, 94, 28,
-									  D1CFrame._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency);
-
-					unsigned char *string = inscriptionString;
-					bitmapRed = _bitmaps[k120_InscriptionFontIndice];
-					int16 textLineIndex = 0;
+				if (L0095_B_IsInscription) {
+					f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR,_g296_bitmapViewport,
+									  g202_BoxWallPatchBehindInscription, 94, 28,
+									  g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth,
+									  k112_byteWidthViewport, k255_ColorNoTransparency, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport);
+					byte *AL0090_puc_String = L0099_auc_InscriptionString;
+					L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont);
+					L0097_i_TextLineIndex = 0;
 					do {
-						int16 characterCount = 0;
-						unsigned char *character = string;
-						while (*character++ < 0x80) {
-							characterCount++;
+						AP0116_i_CharacterCount = 0;
+						AL0091_puc_Character = AL0090_puc_String;
+						while (*AL0091_puc_Character++ < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
+							AP0116_i_CharacterCount++;
 						}
-						frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7;
-						frame._box._y1 = (frame._box._y2 = g203_InscriptionLineY[textLineIndex++]) - 7;
-						while (characterCount--) {
-							f132_blitToBitmap(bitmapRed, _g296_bitmapViewport, frame._box, (*string++) * 8, 0, 144, k112_byteWidthViewport, k10_ColorFlesh);
-							frame._box._x1 += 8;
-							frame._box._x2 += 8;
+						Frame L0098_s_Frame;
+						L0098_s_Frame._box._x2 = (L0098_s_Frame._box._x1 = 112 - (AP0116_i_CharacterCount << 2)) + 7;
+						L0098_s_Frame._box._y1 = (L0098_s_Frame._box._y2 = g203_InscriptionLineY[L0097_i_TextLineIndex++]) - 7;
+						while (AP0116_i_CharacterCount--) {
+							f132_blitToBitmap(L0092_puc_Bitmap, _g296_bitmapViewport, L0098_s_Frame._box,
+											  *AL0090_puc_String++ << 3, 0, 144, k112_byteWidthViewport, k10_ColorFlesh, 8, k136_heightViewport);
+							L0098_s_Frame._box._x1 += 8;
+							L0098_s_Frame._box._x2 += 8;
 						}
-					} while (*string++ != 0x81);
-					return isAlcove;
+					} while (*AL0090_puc_String++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
+					goto T0107031;
 				}
-				nativeBitmapIndex++;
-
-				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordinateSetA[0];
-				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordinateSetA[1];
-				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordinateSetA[2];
-				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordinateSetA[3];
-
-				_vm->_dungeonMan->_g286_isFacingAlcove = isAlcove;
-				_vm->_dungeonMan->_g287_isFacingViAltar = (wallOrnIndex == _g266_currMapViAltarIndex);
+				AL0088_i_NativeBitmapIndex++;
+				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = AL0090_puc_CoordinateSet[0];
+				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = AL0090_puc_CoordinateSet[1];
+				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = AL0090_puc_CoordinateSet[2];
+				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = AL0090_puc_CoordinateSet[3];
+
+				_vm->_dungeonMan->_g286_isFacingAlcove = L0096_B_IsAlcove;
+				_vm->_dungeonMan->_g287_isFacingViAltar =
+					(AP0116_i_WallOrnamentIndex == _g266_currMapViAltarIndex);
 				_vm->_dungeonMan->_g288_isFacingFountain = false;
-				for (int16 fountainOrnIndex = 0; fountainOrnIndex < k1_FountainOrnCount; ++fountainOrnIndex) {
-					if (_g268_currMapFountainOrnIndices[fountainOrnIndex] == wallOrnIndex) {
+				for (AL0089_i_FountainOrnamentIndex = 0; AL0089_i_FountainOrnamentIndex < k1_FountainOrnCount; AL0089_i_FountainOrnamentIndex++) {
+					if (_g268_currMapFountainOrnIndices[AL0089_i_FountainOrnamentIndex] == AP0116_i_WallOrnamentIndex) {
 						_vm->_dungeonMan->_g288_isFacingFountain = true;
 						break;
 					}
 				}
 			}
-			bitmapGreen = _bitmaps[nativeBitmapIndex];
+			AL0091_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
 			if (viewWallIndex == k11_ViewWall_D1R_LEFT) {
-				f99_copyBitmapAndFlipHorizontal(bitmapGreen, _g74_tmpBitmap, coordinateSetA[4], coordinateSetA[5]);
-				bitmapGreen = _g74_tmpBitmap;
+				f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]);
+				AL0091_puc_Bitmap = _g74_tmpBitmap;
 			}
-			var_X = 0;
+			AL0089_i_X = 0;
 		} else {
-			coordinateSetOffset = 0;
-			uint16 *coordSetB;
-			int16 wallOrnCoordSetIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet];
-			flipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT);
-			if (flipHorizontal) {
-				coordSetB = g205_WallOrnCoordSets[wallOrnCoordSetIndex][k11_ViewWall_D1R_LEFT];
-			} else if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT)) {
-				coordSetB = g205_WallOrnCoordSets[wallOrnCoordSetIndex][k10_ViewWall_D1L_RIGHT];
+			uint16 *AL0091_puc_CoordinateSet;
+			L0093_i_CoordinateSetOffset = 0;
+			if (L0094_B_FlipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT)) {
+				AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k11_ViewWall_D1R_LEFT];
 			} else {
-				nativeBitmapIndex++;
-				coordSetB = g205_WallOrnCoordSets[wallOrnCoordSetIndex][k12_ViewWall_D1C_FRONT];
-				if (viewWallIndex == k7_ViewWall_D2L_FRONT) {
-					coordinateSetOffset = 6;
-				} else if (viewWallIndex == k9_ViewWall_D2R_FRONT) {
-					coordinateSetOffset = -6;
+				if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT)) {
+					AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k10_ViewWall_D1L_RIGHT];
+				} else {
+					AL0088_i_NativeBitmapIndex++;
+					AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k12_ViewWall_D1C_FRONT];
+					if (viewWallIndex == k7_ViewWall_D2L_FRONT) {
+						L0093_i_CoordinateSetOffset = 6;
+					} else {
+						if (viewWallIndex == k9_ViewWall_D2R_FRONT) {
+							L0093_i_CoordinateSetOffset = -6;
+						}
+					}
 				}
 			}
-			int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0];
-			f129_blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], _g74_tmpBitmap, coordSetB[4] << 1, coordSetB[5], pixelWidth + 1, coordinateSetA[5],
-				(viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
-			bitmapGreen = _bitmaps[nativeBitmapIndex];
-			var_X = pixelWidth;
-			if (flipHorizontal) {
-				f99_copyBitmapAndFlipHorizontal(bitmapGreen, _g74_tmpBitmap, coordSetB[4], coordSetB[5]);
-				bitmapGreen = _g74_tmpBitmap;
-				var_X = 15 - (var_X & 0xF);
-			} else if (viewWallIndex == k7_ViewWall_D2L_FRONT) {
-				var_X -= coordinateSetA[1] - coordinateSetA[0];
+			AL0089_i_PixelWidth = (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[1] - (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[0];
+			if (!f491_isDerivedBitmapInCache(AP0116_i_WallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + 
+				(AP0116_i_WallOrnamentIndex << 2) + g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex])) {
+				L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
+				f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex),
+													 AL0091_puc_CoordinateSet[4] << 1,
+													 AL0091_puc_CoordinateSet[5], AL0089_i_PixelWidth + 1,
+													 AL0090_puc_CoordinateSet[5],
+													 (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
+				f493_addDerivedBitmap(AP0116_i_WallOrnamentIndex);
+			}
+			AL0091_puc_Bitmap = f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex);
+			if (L0094_B_FlipHorizontal) {
+				f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]);
+				AL0091_puc_Bitmap = _g74_tmpBitmap;
+				AL0089_i_X = 15 - (AL0089_i_X & 0x000F);
 			} else {
-				var_X = 0;
+				if (viewWallIndex == k7_ViewWall_D2L_FRONT) {
+					AL0089_i_X -= AL0090_puc_CoordinateSet[1] - AL0090_puc_CoordinateSet[0];
+				} else {
+					AL0089_i_X = 0;
+				}
 			}
 		}
-		if (isInscription) {
-			unsigned char *string = inscriptionString;
-			int16 unreadableTextLineCount = 0;
+		if (L0095_B_IsInscription) {
+			byte *AL0090_puc_String = L0099_auc_InscriptionString;
+			AL0088_i_UnreadableTextLineCount = 0;
 			do {
-				while (*string < 0x80) {
-					string++;
+				while (*AL0090_puc_String < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
+					AL0090_puc_String++;
 				}
-				unreadableTextLineCount++;
-			} while (*string++ != 0x81);
-
-			if (unreadableTextLineCount < 4) {
-				frame._box._x1 = coordinateSetA[0];
-				frame._box._x2 = coordinateSetA[1];
-				frame._box._y1 = coordinateSetA[2];
-				frame._box._y2 = coordinateSetA[3];
-				frame._srcByteWidth = coordinateSetA[4];
-				frame._srcHeight = coordinateSetA[5];
-
-				coordinateSetA = (uint16*)&frame._box;
-
-				coordinateSetA[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
+				AL0088_i_UnreadableTextLineCount++;
+			} while (*AL0090_puc_String++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
+			if (AL0088_i_UnreadableTextLineCount < 4) {
+				for (uint16 i = 0; i < 6; ++i)
+					tmp[i] = AL0090_puc_CoordinateSet[i];
+				AL0090_puc_CoordinateSet = tmp;
+				AL0090_puc_CoordinateSet[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + AL0088_i_UnreadableTextLineCount - 1];
 			}
 		}
-		f132_blitToBitmap(bitmapGreen, _g296_bitmapViewport, *(Box*)coordinateSetA, var_X, 0, coordinateSetA[4], k112_byteWidthViewport, k10_ColorFlesh);
-
-		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
-			Box &box = g109_BoxChampionPortraitOnWall;
-			f132_blitToBitmap(_bitmaps[k26_ChampionPortraitsIndice], _g296_bitmapViewport, box, (_g289_championPortraitOrdinal & 0x7) << 5,
-				(_g289_championPortraitOrdinal >> 3) * 29, 128, k112_byteWidthViewport, k1_ColorDarkGary);
+		f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport,
+			*(Box*)AL0090_puc_CoordinateSet, AL0089_i_X, 0,
+						  AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport);
+/* BUG0_05 A champion portrait sensor on a wall square is visible on all sides of the wall. 
+If there is another sensor with a wall ornament on one side of the wall then the champion portrait is drawn over that wall ornament */
+		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { 
+/* A portrait is 32x29 pixels */
+			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice),
+				_g296_bitmapViewport, g109_BoxChampionPortraitOnWall,
+							  (_g289_championPortraitOrdinal & 0x0007) << 5,
+							  (_g289_championPortraitOrdinal >> 3) * 29, 128, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); 
 		}
-		return isAlcove;
+T0107031:
+		return L0096_B_IsAlcove;
 	}
 	return false;
 }
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 1db5990..cfe2710 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -57,6 +57,11 @@ namespace DM {
 #define k1_ViewDoorOrnament_D2LCR 1 // @ C1_VIEW_DOOR_ORNAMENT_D2LCR
 #define k2_ViewDoorOrnament_D1LCR 2 // @ C2_VIEW_DOOR_ORNAMENT_D1LCR
 
+#define k0_viewDoorButton_D3R 0 // @ C0_VIEW_DOOR_BUTTON_D3R
+#define k1_viewDoorButton_D3C 1 // @ C1_VIEW_DOOR_BUTTON_D3C
+#define k2_viewDoorButton_D2C 2 // @ C2_VIEW_DOOR_BUTTON_D2C
+#define k3_viewDoorButton_D1C 3 // @ C3_VIEW_DOOR_BUTTON_D1C
+
 #define k0x0001_MaskDoorInfo_CraturesCanSeeThrough 0x0001 // @ MASK0x0001_CREATURES_CAN_SEE_THROUGH   
 #define k0x0002_MaskDoorInfo_ProjectilesCanPassThrough 0x0002 // @ MASK0x0002_PROJECTILES_CAN_PASS_THROUGH
 #define k0x0004_MaskDoorInfo_Animated 0x0004 // @ MASK0x0004_ANIMATED                    
@@ -222,6 +227,7 @@ enum GraphicIndice {
 	k38_BorderPartyFireshieldIndice = 38, // @ C038_GRAPHIC_BORDER_PARTY_FIRESHIELD
 	k39_BorderPartySpellshieldIndice = 39, // @ C039_GRAPHIC_BORDER_PARTY_SPELLSHIELD
 	k40_PanelResurectReincaranteIndice = 40, // @ C040_GRAPHIC_PANEL_RESURRECT_REINCARNATE 
+	k41_holeInWall_GraphicIndice = 41, // @ C041_GRAPHIC_HOLE_IN_WALL
 	k42_ObjectIcons_000_TO_031 = 42, // @ C042_GRAPHIC_OBJECT_ICONS_000_TO_031
 	k43_ObjectIcons_032_TO_063 = 43, // @ C043_GRAPHIC_OBJECT_ICONS_032_TO_063
 	k44_ObjectIcons_064_TO_095 = 44, // @ C044_GRAPHIC_OBJECT_ICONS_064_TO_095
@@ -237,11 +243,24 @@ enum GraphicIndice {
 	k54_FloorPit_D1C_GraphicIndice = 54, // @ C054_GRAPHIC_FLOOR_PIT_D1C
 	k55_FloorPit_D0L_GraphicIndice = 55, // @ C055_GRAPHIC_FLOOR_PIT_D0L
 	k56_FloorPit_D0C_GraphicIndice = 56, // @ C056_GRAPHIC_FLOOR_PIT_D0C
+	k57_FloorPir_Invisible_D2L_GraphicIndice = 57, // @ C057_GRAPHIC_FLOOR_PIT_INVISIBLE_D2L
+	k58_FloorPit_invisible_D2C_GraphicIndice = 58, // @ C058_GRAPHIC_FLOOR_PIT_INVISIBLE_D2C
+	k59_floorPit_invisible_D1L_GraphicIndice = 59, // @ C059_GRAPHIC_FLOOR_PIT_INVISIBLE_D1L
+	k60_floorPitInvisibleD1C_GraphicIndice = 60, // @ C060_GRAPHIC_FLOOR_PIT_INVISIBLE_D1C
+	k61_floorPitInvisibleD0L_GraphicIndice = 61, // @ C061_GRAPHIC_FLOOR_PIT_INVISIBLE_D0L
+	k62_flootPitInvisibleD0C_graphicIndice = 62, // @ C062_GRAPHIC_FLOOR_PIT_INVISIBLE_D0C
+	k63_ceilingPit_D2L_GraphicIndice = 63, // @ C063_GRAPHIC_CEILING_PIT_D2L
+	k64_ceilingPitD2C_GraphicIndice = 64, // @ C064_GRAPHIC_CEILING_PIT_D2C
+	k65_ceilingPitD1L_GraphicIndice = 65, // @ C065_GRAPHIC_CEILING_PIT_D1L
+	k66_ceilingPitD1C_GraphicIndice = 66, // @ C066_GRAPHIC_CEILING_PIT_D1C
+	k67_ceilingPitD0L_grahicIndice = 67, // @ C067_GRAPHIC_CEILING_PIT_D0L
+	k68_ceilingPitD0C_graphicIndice = 68, // @ C068_GRAPHIC_CEILING_PIT_D0C
 	k69_FieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R
 	k73_FieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER
 	k120_InscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT
 	k241_FloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS
 	k301_DoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
+	k315_firstDoorButton_GraphicIndice = 315, // @ C315_GRAPHIC_FIRST_DOOR_BUTTON
 	k316_FirstProjectileGraphicIndice = 316, // @ C316_GRAPHIC_FIRST_PROJECTILE 
 	k348_FirstExplosionGraphicIndice = 348, // @ C348_GRAPHIC_FIRST_EXPLOSION
 	k351_FirstExplosionPatternGraphicIndice = 351, // @ C351_GRAPHIC_FIRST_EXPLOSION_PATTERN 
@@ -590,6 +609,8 @@ public:
 	void loadPalette(uint16 *palette);
 	void f461_allocateFlippedWallBitmaps(); // @ F0461_START_AllocateFlippedWallBitmaps
 	void f102_drawDoorBitmap(Frame *frame);// @ F0102_DUNGEONVIEW_DrawDoorBitmap
+	void f103_drawDoorFrameBitmapFlippedHorizontally(byte *bitmap, Frame *frame); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally
+	void f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButtonIndex); // @ F0110_DUNGEONVIEW_DrawDoorButton
 
 	/// Gives the width of an IMG0 type item
 	uint16 getPixelWidth(uint16 index);
@@ -602,6 +623,8 @@ public:
 	void f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16 *doorNativeBitmapIndices, int16 byteCount,
 					   int16 viewDoorOrnIndex, DoorFrames *doorFrames); // @ F0111_DUNGEONVIEW_DrawDoor
 	void f109_drawDoorOrnament(int16 doorOrnOdinal, int16 viewDoorOrnIndex); // @ F0109_DUNGEONVIEW_DrawDoorOrnament
+	void f112_drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int16 mapX, int16 mapY, bool flipHorizontal); // @ F0112_DUNGEONVIEW_DrawCeilingPit
+
 
 
 	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which 


Commit: c95b23317ce179fe168a20f39a132b4cd9ec4f32
    https://github.com/scummvm/scummvm/commit/c95b23317ce179fe168a20f39a132b4cd9ec4f32
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add some missing code

Changed paths:
  A engines/dm/projexpl.cpp
  A engines/dm/projexpl.h
    engines/dm/TODOs/todo.txt
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dmglobals.cpp
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/group.cpp
    engines/dm/group.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/menus.cpp
    engines/dm/menus.h
    engines/dm/module.mk
    engines/dm/movesens.cpp
    engines/dm/movesens.h
    engines/dm/objectman.cpp
    engines/dm/objectman.h
    engines/dm/text.cpp
    engines/dm/text.h
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 5ef225f..183889e 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -7,7 +7,7 @@ Bugs:
 		Command gui is broken
 	Logic:
 		Game crashes when reincaranting a fourth champion and trying to copy his portrait
-
+e
 
 
 Todo:
@@ -18,7 +18,7 @@ Todo:
 	Attend to sev's notes on github
 	Double check enums with hex literals, I think I screwed the regex when processing them
 	Double check strcat, strstr usages, I might have messed them up in many places
-	I forgot to add a bunch of warning for show/hide mouse pointer
+	I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions
 
 	Missing functions:
 		 Add missing  F0163_DUNGEON_LinkThingToList in MovesensMan::sensorIsTriggeredByClickOnWall (I don't think it's safe yet)
@@ -26,6 +26,3 @@ Todo:
 Refactoring
 	Add constructor to CreatureInfo
 
-Forgot to add number to name:
-	gBoxChampionPortrait, gBoxEye, gBoxMouth, gSlotMasks
-		
\ No newline at end of file
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index b35e0d8..5c1f546 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -32,10 +32,15 @@
 #include "inventory.h"
 #include "objectman.h"
 #include "text.h"
+#include "timeline.h"
+#include "projexpl.h"
+#include "group.h"
 
 
 namespace DM {
 
+const char *g417_baseSkillName[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"};
+
 Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
 Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
 Box g54_BoxChampionIcons[4] = {
@@ -98,6 +103,81 @@ ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
 	_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
 	_g415_leaderEmptyHanded = true;
 	_g514_magicCasterChampionIndex = kM1_ChampionNone;
+	for (uint16 i = 0; i < 4; ++i) {
+		_g409_championPendingDamage[i] = 0;
+		_g410_championPendingWounds[i] = 0;
+	}
+
+}
+
+bool ChampionMan::f329_isLeaderHandObjectThrown(int16 side) {
+	if (_g411_leaderIndex == kM1_ChampionNone) {
+		return false;
+	}
+	return f328_isObjectThrown(_g411_leaderIndex, kM1_ChampionSlotLeaderHand, side);
+}
+
+bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side) {
+	int16 L0993_i_KineticEnergy;
+	int16 L0994_i_Multiple;
+#define AL0994_i_Experience L0994_i_Multiple
+#define AL0994_i_Attack     L0994_i_Multiple
+	int16 L0995_i_Multiple;
+#define AL0995_i_WeaponKineticEnergy L0995_i_Multiple
+#define AL0995_i_SkillLevel          L0995_i_Multiple
+#define AL0995_i_StepEnergy          L0995_i_Multiple
+	Thing L0996_T_Thing;
+	Champion* L0997_ps_Champion = nullptr;
+	WeaponInfo* L0998_ps_WeaponInfo;
+	Thing L0999_T_ActionHandThing;
+	bool L1000_B_ThrowingLeaderHandObject;
+
+
+	L1000_B_ThrowingLeaderHandObject = false;
+	if (slotIndex < 0) { /* Throw object in leader hand, which is temporarily placed in action hand */
+		if (_g415_leaderEmptyHanded) {
+			return false;
+		}
+		L0996_T_Thing = f298_getObjectRemovedFromLeaderHand();
+		L0997_ps_Champion = &_gK71_champions[champIndex];
+		L0999_T_ActionHandThing = L0997_ps_Champion->getSlot(k1_ChampionSlotActionHand);
+		L0997_ps_Champion->setSlot(k1_ChampionSlotActionHand, L0996_T_Thing);
+		slotIndex = k1_ChampionSlotActionHand;
+		L1000_B_ThrowingLeaderHandObject = true;
+	}
+	L0993_i_KineticEnergy = f312_getStrength(champIndex, slotIndex);
+	if (L1000_B_ThrowingLeaderHandObject) {
+		L0997_ps_Champion->setSlot((ChampionSlot)slotIndex, L0999_T_ActionHandThing);
+	} else {
+		if ((L0996_T_Thing = f300_getObjectRemovedFromSlot(champIndex, slotIndex)) == Thing::_none) {
+			return false;
+		}
+	}
+	warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+	f325_decrementStamine(champIndex, f305_getThrowingStaminaCost(L0996_T_Thing));
+	f330_disableAction(champIndex, 4);
+	AL0994_i_Experience = 8;
+	AL0995_i_WeaponKineticEnergy = 1;
+	if (L0996_T_Thing.getType() == k5_WeaponThingType) {
+		AL0994_i_Experience += 4;
+		L0998_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0996_T_Thing);
+		if (L0998_ps_WeaponInfo->_class <= k12_WeaponClassPoisinDart) {
+			AL0994_i_Experience += (AL0995_i_WeaponKineticEnergy = L0998_ps_WeaponInfo->_kineticEnergy) >> 2;
+		}
+	}
+	f304_addSkillExperience(champIndex, k10_ChampionSkillThrow, AL0994_i_Experience);
+	L0993_i_KineticEnergy += AL0995_i_WeaponKineticEnergy;
+	AL0995_i_SkillLevel = f303_getSkillLevel((ChampionIndex)champIndex, k10_ChampionSkillThrow);
+	L0993_i_KineticEnergy += _vm->_rnd->getRandomNumber(16) + (L0993_i_KineticEnergy >> 1) + AL0995_i_SkillLevel;
+	AL0994_i_Attack = f26_getBoundedValue((uint16)40, (uint16)((AL0995_i_SkillLevel << 3) + _vm->_rnd->getRandomNumber(31)), (uint16)200);
+	AL0995_i_StepEnergy = MAX(5, 11 - AL0995_i_SkillLevel);
+	_vm->_projexpl->f212_projectileCreate(L0996_T_Thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY,
+							M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + side),
+							_vm->_dungeonMan->_g308_partyDir, L0993_i_KineticEnergy, AL0994_i_Attack, AL0995_i_StepEnergy);
+	_vm->_g311_projectileDisableMovementTicks = 4;
+	_vm->_g312_lastProjectileDisabledMovementDirection = _vm->_dungeonMan->_g308_partyDir;
+	f292_drawChampionState((ChampionIndex)champIndex);
+	return true;
 }
 
 uint16 ChampionMan::M27_getChampionPortraitX(uint16 index) {
@@ -138,7 +218,7 @@ Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding,
 	return result += valToStr;
 }
 
-void ChampionMan::f299_applyModifiersToStatistics(Champion* champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing) {
+void ChampionMan::f299_applyModifiersToStatistics(Champion* champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing) {
 	int16 statIndex;
 	int16 modifier = 0;
 	ThingType thingType = thing.getType();
@@ -266,7 +346,6 @@ T0299044_ApplyModifier:
 		} else if (statIndex < k6_ChampionStatAntifire + 1) {
 			for (uint16 statValIndex = k0_ChampionStatMaximum; statValIndex <= k2_ChampionStatMinimum; ++statValIndex) {
 				champ->getStatistic((ChampionStatisticType)statIndex, (ChampionStatisticValue)statValIndex) += modifier;
-				warning("BUG0_38");
 			}
 		}
 	}
@@ -284,7 +363,7 @@ bool ChampionMan::f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing t
 		if (newIconIndex != currIconIndex) {
 			if ((slotBoxIndex < k8_SlotBoxInventoryFirstSlot) && !_g420_mousePointerHiddenToDrawChangedObjIconOnScreen) {
 				_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
-				warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+				_vm->_eventMan->f77_hideMouse();
 			}
 			objMan.f38_drawIconInSlotBox(slotBoxIndex, newIconIndex);
 			return true;
@@ -312,9 +391,9 @@ void ChampionMan::f296_drawChangedObjectIcons() {
 		IconIndice iconIndex = objMan.f33_getIconIndex(_g414_leaderHandObject);
 		if (iconIndex != leaderHandObjIconIndex) {
 			_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
-			warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+			_vm->_eventMan->f77_hideMouse();
 			objMan.f36_extractIconFromBitmap(iconIndex, objMan._g412_objectIconForMousePointer);
-			warning("MISSING CODE: F0068_MOUSE_SetPointerToObject");
+			_vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
 			_g413_leaderHandObjectIconIndex = iconIndex;
 			objMan.f34_drawLeaderObjectName(_g414_leaderHandObject);
 		}
@@ -359,7 +438,7 @@ void ChampionMan::f296_drawChangedObjectIcons() {
 	}
 
 	if (_g420_mousePointerHiddenToDrawChangedObjIconOnScreen)
-		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+		_vm->_eventMan->f78_showMouse();
 }
 
 void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex) {
@@ -401,7 +480,7 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 
 		if (iconIndex = k4_IconIndiceWeaponTorchUnlit) {
 			((Weapon*)rawObjPtr)->setLit(true);
-			warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette");
+			_vm->_inventoryMan->f337_setDungeonViewPalette();
 			f296_drawChangedObjectIcons();
 		} else if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand) &&
 			((iconIndex == k144_IconIndiceContainerChestClosed) || ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)))) {
@@ -413,7 +492,7 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 		if ((iconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (iconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
 			((Junk*)rawObjPtr)->setChargeCount(1);
 			_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2];
-			warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette");
+			_vm->_inventoryMan->f337_setDungeonViewPalette();
 			iconIndex = (IconIndice)(iconIndex + 1);
 		} else if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
 			((Junk*)rawObjPtr)->setChargeCount(1);
@@ -449,7 +528,627 @@ int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) {
 	return 0;
 }
 
-ChampionIndex ChampionMan::f285_getIndexInCell(ViewCell cell) {
+Thing ChampionMan::f298_getObjectRemovedFromLeaderHand() {
+	Thing L0890_T_LeaderHandObject;
+
+
+	_g415_leaderEmptyHanded = true;
+	if ((L0890_T_LeaderHandObject = _g414_leaderHandObject) != Thing::_none) {
+		_g414_leaderHandObject = Thing::_none;
+		_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
+		_vm->_eventMan->f78_showMouse();
+		_vm->_objectMan->f35_clearLeaderObjectName();
+		_vm->_eventMan->f69_setMousePointer();
+		_vm->_eventMan->f77_hideMouse();
+		if (_g411_leaderIndex != kM1_ChampionNone) {
+			_gK71_champions[_g411_leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(L0890_T_LeaderHandObject);
+			setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
+			f292_drawChampionState(_g411_leaderIndex);
+		}
+	}
+	return L0890_T_LeaderHandObject;
+}
+
+uint16 ChampionMan::f312_getStrength(int16 champIndex, int16 slotIndex) {
+	int16 L0935_i_Strength;
+	uint16 L0936_ui_Multiple;
+#define AL0936_ui_ObjectWeight L0936_ui_Multiple
+#define AL0936_ui_SkillLevel   L0936_ui_Multiple
+	uint16 L0937_ui_Multiple;
+#define AL0937_ui_OneSixteenthMaximumLoad L0937_ui_Multiple
+#define AL0937_ui_Class                   L0937_ui_Multiple
+	Thing L0938_T_Thing;
+	Champion* L0939_ps_Champion;
+	WeaponInfo* L0940_ps_WeaponInfo;
+	int16 L0941_i_LoadThreshold;
+
+
+	L0939_ps_Champion = &_gK71_champions[champIndex];
+	L0935_i_Strength = _vm->_rnd->getRandomNumber(15) + L0939_ps_Champion->_statistics[k1_ChampionStatStrength][k1_ChampionStatCurrent];
+	L0938_T_Thing = L0939_ps_Champion->_slots[slotIndex];
+	if ((AL0936_ui_ObjectWeight = _vm->_dungeonMan->f140_getObjectWeight(L0938_T_Thing)) <= (AL0937_ui_OneSixteenthMaximumLoad = f309_getMaximumLoad(L0939_ps_Champion) >> 4)) {
+		L0935_i_Strength += AL0936_ui_ObjectWeight - 12;
+	} else {
+		if (AL0936_ui_ObjectWeight <= (L0941_i_LoadThreshold = AL0937_ui_OneSixteenthMaximumLoad + ((AL0937_ui_OneSixteenthMaximumLoad - 12) >> 1))) {
+			L0935_i_Strength += (AL0936_ui_ObjectWeight - AL0937_ui_OneSixteenthMaximumLoad) >> 1;
+		} else {
+			L0935_i_Strength -= (AL0936_ui_ObjectWeight - L0941_i_LoadThreshold) << 1;
+		}
+	}
+	if (L0938_T_Thing.getType() == k5_WeaponThingType) {
+		L0940_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0938_T_Thing);
+		L0935_i_Strength += L0940_ps_WeaponInfo->_strength;
+		AL0936_ui_SkillLevel = 0;
+		AL0937_ui_Class = L0940_ps_WeaponInfo->_class;
+		if ((AL0937_ui_Class == k0_WeaponClassSwingWeapon) || (AL0937_ui_Class == k2_WeaponClassDaggerAndAxes)) {
+			AL0936_ui_SkillLevel = f303_getSkillLevel(champIndex, k4_ChampionSkillSwing);
+		}
+		if ((AL0937_ui_Class != k0_WeaponClassSwingWeapon) && (AL0937_ui_Class < k16_WeaponClassFirstBow)) {
+			AL0936_ui_SkillLevel += f303_getSkillLevel(champIndex, k10_ChampionSkillThrow);
+		}
+		if ((AL0937_ui_Class >= k16_WeaponClassFirstBow) && (AL0937_ui_Class < k112_WeaponClassFirstMagicWeapon)) {
+			AL0936_ui_SkillLevel += f303_getSkillLevel(champIndex, k11_ChampionSkillShoot);
+		}
+		L0935_i_Strength += AL0936_ui_SkillLevel << 1;
+	}
+	L0935_i_Strength = f306_getStaminaAdjustedValue(L0939_ps_Champion, L0935_i_Strength);
+	if (getFlag(L0939_ps_Champion->_wounds, (slotIndex == k0_ChampionSlotReadyHand) ? k0x0001_ChampionWoundReadHand : k0x0002_ChampionWoundActionHand)) {
+		L0935_i_Strength >>= 1;
+	}
+	MAX(1, 2);
+	return f26_getBoundedValue(0, L0935_i_Strength >> 1, 100);
+}
+
+Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) {
+	Thing L0894_T_Thing;
+	int16 L0895_i_IconIndex;
+	Champion* L0896_ps_Champion;
+	Weapon* L0897_ps_Weapon;
+	bool L0898_B_IsInventoryChampion;
+
+
+	L0896_ps_Champion = &_gK71_champions[champIndex];
+	if (slotIndex >= k30_ChampionSlotChest_1) {
+		L0894_T_Thing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
+		_vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1] = Thing::_none;
+	} else {
+		L0894_T_Thing = L0896_ps_Champion->_slots[slotIndex];
+		L0896_ps_Champion->_slots[slotIndex] = Thing::_none;
+	}
+	if (L0894_T_Thing == Thing::_none) {
+		return Thing::_none;
+	}
+	L0898_B_IsInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+	L0895_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0894_T_Thing);
+	f299_applyModifiersToStatistics(L0896_ps_Champion, slotIndex, L0895_i_IconIndex, -1, L0894_T_Thing); /* Remove objet modifiers */
+	L0897_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0894_T_Thing);
+	if (slotIndex == k10_ChampionSlotNeck) {
+		if ((L0895_i_IconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (L0895_i_IconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
+			((Junk*)L0897_ps_Weapon)->setChargeCount(0);
+			_g407_party._magicalLightAmount -= g39_LightPowerToLightAmount[2];
+			_vm->_inventoryMan->f337_setDungeonViewPalette();
+		} else {
+			if ((L0895_i_IconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (L0895_i_IconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
+				((Junk*)L0897_ps_Weapon)->setChargeCount(0);
+			}
+		}
+	}
+	f291_drawSlot(champIndex, slotIndex);
+	if (L0898_B_IsInventoryChampion) {
+		setFlag(L0896_ps_Champion->_attributes, k0x4000_ChampionAttributeViewport);
+	}
+	if (slotIndex < k2_ChampionSlotHead) {
+		if (slotIndex == k1_ChampionSlotActionHand) {
+			setFlag(L0896_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand);
+			if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)) {
+				_vm->_menuMan->f388_clearActingChampion();
+			}
+			if ((L0895_i_IconIndex >= k30_IconIndiceScrollOpen) && (L0895_i_IconIndex <= k31_IconIndiceScrollClosed)) {
+				((Scroll*)L0897_ps_Weapon)->setClosed(true);
+				f296_drawChangedObjectIcons();
+			}
+		}
+		if ((L0895_i_IconIndex >= k4_IconIndiceWeaponTorchUnlit) && (L0895_i_IconIndex <= k7_IconIndiceWeaponTorchLit)) {
+			L0897_ps_Weapon->setLit(false);
+			_vm->_inventoryMan->f337_setDungeonViewPalette();
+			f296_drawChangedObjectIcons();
+		}
+		if (L0898_B_IsInventoryChampion && (slotIndex == k1_ChampionSlotActionHand)) {
+			if (L0895_i_IconIndex == k144_IconIndiceContainerChestClosed) {
+				_vm->_inventoryMan->f334_closeChest();
+				goto T0300011;
+			}
+			if ((L0895_i_IconIndex >= k30_IconIndiceScrollOpen) && (L0895_i_IconIndex <= k31_IconIndiceScrollClosed)) {
+T0300011:
+				setFlag(L0896_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
+			}
+		}
+	}
+	L0896_ps_Champion->_load -= _vm->_dungeonMan->f140_getObjectWeight(L0894_T_Thing);
+	setFlag(L0896_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad);
+	return L0894_T_Thing;
+}
+
+void ChampionMan::f325_decrementStamine(int16 championIndex, int16 decrement) {
+	int16 L0988_i_Stamina;
+	Champion* L0989_ps_Champion;
+
+
+	if (championIndex == kM1_ChampionNone) {
+		return;
+	}
+	L0989_ps_Champion = &_gK71_champions[championIndex];
+	if ((L0988_i_Stamina = (L0989_ps_Champion->_currStamina -= decrement)) <= 0) {
+		L0989_ps_Champion->_currStamina = 0;
+		f321_addPendingDamageAndWounds_getDamage(championIndex, (-L0988_i_Stamina) >> 1, k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
+	} else {
+		if (L0988_i_Stamina > L0989_ps_Champion->_maxStamina) {
+			L0989_ps_Champion->_currStamina = L0989_ps_Champion->_maxStamina;
+		}
+	}
+	setFlag(L0989_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics);
+}
+
+int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds, uint16 attackType) {
+	int16 L0976_i_Multiple;
+#define AL0976_i_WoundIndex     L0976_i_Multiple
+#define AL0976_i_WisdomFactor   L0976_i_Multiple
+#define AL0976_i_AdjustedAttack L0976_i_Multiple
+	uint16 L0977_ui_Defense;
+	uint16 L0978_ui_WoundCount;
+	Champion* L0979_ps_Champion;
+
+	if (attack <= 0)
+		return 0;
+
+	L0979_ps_Champion = &_gK71_champions[champIndex];
+	if (!L0979_ps_Champion->_currHealth) {
+T0321004:
+		return 0;
+	}
+	if (attackType != k0_attackType_NORMAL) {
+		for (L0978_ui_WoundCount = 0, AL0976_i_WoundIndex = k0_ChampionSlotReadyHand, L0977_ui_Defense = 0; AL0976_i_WoundIndex <= k5_ChampionSlotFeet; AL0976_i_WoundIndex++) {
+			if (allowedWounds & (1 << AL0976_i_WoundIndex)) {
+				L0978_ui_WoundCount++;
+				L0977_ui_Defense += f313_getWoundDefense(champIndex, AL0976_i_WoundIndex | ((attackType == k4_attackType_SHARP) ? k0x8000_maskUseSharpDefense : k0x0000_maskDoNotUseSharpDefense));
+			}
+		}
+		if (L0978_ui_WoundCount) {
+			L0977_ui_Defense /= L0978_ui_WoundCount;
+		}
+		switch (attackType) {
+		case k6_attackType_PSYCHIC:
+			if ((AL0976_i_WisdomFactor = 115 - L0979_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent]) <= 0) {
+				attack = 0;
+			} else {
+				attack = _vm->f30_getScaledProduct(attack, 6, AL0976_i_WisdomFactor);
+			}
+			goto T0321024;
+		case k5_attackType_MAGIC:
+			attack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k5_ChampionStatAntimagic, attack);
+			attack -= _g407_party._spellShieldDefense;
+			goto T0321024;
+		case k1_attackType_FIRE:
+			attack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k6_ChampionStatAntifire, attack);
+			attack -= _g407_party._fireShieldDefense;
+			break;
+		case k2_attackType_SELF:
+			L0977_ui_Defense >>= 1;
+		case k3_attackType_BLUNT:
+		case k4_attackType_SHARP:
+		case k7_attackType_LIGHTNING:
+			;
+		}
+		if (attack <= 0)
+			goto T0321004;
+		attack = _vm->f30_getScaledProduct(attack, 6, 130 - L0977_ui_Defense);
+		/* BUG0_44 A champion may take much more damage than expected after a Black Flame attack or an impact
+	with a Fireball projectile. If the party has a fire shield defense value higher than the fire attack value then the resulting intermediary
+	attack value is negative and damage should be 0. However, the negative value is still used for further computations and the result may be a very
+	high positive attack value which may kill a champion. This can occur only for k1_attackType_FIRE and if attack is negative before calling F0030_MAIN_GetScaledProduct */
+T0321024:
+		if (attack <= 0)
+			goto T0321004;
+		if (attack > (AL0976_i_AdjustedAttack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k4_ChampionStatVitality, _vm->_rnd->getRandomNumber(127) + 10))) { /* BUG0_45 This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the probability of being wounded. However if it was fixed, the behavior would be the opposite of what it should: the higher the vitality of a champion, the lower the result of F0307_CHAMPION_GetStatisticAdjustedAttack and the more likely the champion could get wounded (because of more iterations in the loop below) */
+			do {
+				setFlag(*(uint16*)&_g410_championPendingWounds[champIndex], (1 << _vm->_rnd->getRandomNumber(7)) & allowedWounds);
+			} while ((attack > (AL0976_i_AdjustedAttack <<= 1)) && AL0976_i_AdjustedAttack);
+		}
+		if (_g300_partyIsSleeping) {
+			f314_wakeUp();
+		}
+	}
+	_g409_championPendingDamage[champIndex] += attack;
+	return attack;
+}
+
+int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
+	static byte g50_woundDefenseFactor[6] = {5, 5, 4, 6, 3, 1}; // @ G0050_auc_Graphic562_WoundDefenseFactor
+
+	int16 L0942_i_Multiple;
+#define AL0942_i_SlotIndex    L0942_i_Multiple
+#define AL0942_i_WoundDefense L0942_i_Multiple
+	uint16 L0943_ui_ArmourShieldDefense;
+	bool L0944_B_UseSharpDefense;
+	Thing L0945_T_Thing;
+	Champion* L0946_ps_Champion;
+	ArmourInfo* L0947_ps_ArmourInfo;
+
+
+	L0946_ps_Champion = &_gK71_champions[champIndex];
+	if (L0944_B_UseSharpDefense = getFlag(woundIndex, k0x8000_maskUseSharpDefense)) {
+		clearFlag(woundIndex, k0x8000_maskUseSharpDefense);
+	}
+	for (L0943_ui_ArmourShieldDefense = 0, AL0942_i_SlotIndex = k0_ChampionSlotReadyHand; AL0942_i_SlotIndex <= k1_ChampionSlotActionHand; AL0942_i_SlotIndex++) {
+		if ((L0945_T_Thing = L0946_ps_Champion->_slots[AL0942_i_SlotIndex]).getType() == k6_ArmourThingType) {
+			L0947_ps_ArmourInfo = (ArmourInfo*)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing);
+			L0947_ps_ArmourInfo = &g239_ArmourInfo[((Armour*)L0947_ps_ArmourInfo)->getType()];
+			if (getFlag(L0947_ps_ArmourInfo->_attributes, k0x0080_ArmourAttributeIsAShield)) {
+				L0943_ui_ArmourShieldDefense += ((f312_getStrength(champIndex, AL0942_i_SlotIndex) + _vm->_dungeonMan->f143_getArmourDefense(L0947_ps_ArmourInfo, L0944_B_UseSharpDefense)) * g50_woundDefenseFactor[woundIndex]) >> ((AL0942_i_SlotIndex == woundIndex) ? 4 : 5);
+			}
+		}
+	}
+	AL0942_i_WoundDefense = _vm->getRandomNumber((L0946_ps_Champion->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] >> 3) + 1);
+	if (L0944_B_UseSharpDefense) {
+		AL0942_i_WoundDefense >>= 1;
+	}
+	AL0942_i_WoundDefense += L0946_ps_Champion->_actionDefense + L0946_ps_Champion->_shieldDefense + _g407_party._shieldDefense + L0943_ui_ArmourShieldDefense;
+	if ((woundIndex > k1_ChampionSlotActionHand) && ((L0945_T_Thing = L0946_ps_Champion->_slots[woundIndex]).getType() == k6_ArmourThingType)) {
+		L0947_ps_ArmourInfo = (ArmourInfo*)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing);
+		AL0942_i_WoundDefense += _vm->_dungeonMan->f143_getArmourDefense(&g239_ArmourInfo[((Armour*)L0947_ps_ArmourInfo)->getType()], L0944_B_UseSharpDefense);
+	}
+	if (getFlag(L0946_ps_Champion->_wounds, 1 << woundIndex)) {
+		AL0942_i_WoundDefense -= 8 + _vm->getRandomNumber(4);
+	}
+	if (_g300_partyIsSleeping) {
+		AL0942_i_WoundDefense >>= 1;
+	}
+	return f26_getBoundedValue(0, AL0942_i_WoundDefense >> 1, 100);
+}
+
+uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion* champ, uint16 statIndex, uint16 attack) {
+	int16 L0927_i_Factor;
+
+	if ((L0927_i_Factor = 170 - champ->_statistics[statIndex][k1_ChampionStatCurrent]) < 16) { /* BUG0_41 The Antifire and Antimagic statistics are completely ignored. The Vitality statistic is ignored against poison and to determine the probability of being wounded. Vitality is still used normally to compute the defense against wounds and the speed of health regeneration. A bug in the Megamax C compiler produces wrong machine code for this statement. It always returns 0 for the current statistic value so that L0927_i_Factor = 170 in all cases */
+		return attack >> 3;
+	}
+	return _vm->f30_getScaledProduct(attack, 7, L0927_i_Factor);
+}
+
+void ChampionMan::f314_wakeUp() {
+	_vm->_g321_stopWaitingForPlayerInput = true;
+	_g300_partyIsSleeping = false;
+	_vm->waitMs(10);
+	_vm->_displayMan->f98_drawFloorAndCeiling();
+	_vm->_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface;
+	_vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
+	warning("MISSING CODE: set G0443_ps_PrimaryKeyboardInput");
+	warning("MISSING CODE: G0444_ps_SecondaryKeyboardInput");
+	_vm->_eventMan->f357_discardAllInput();
+	_vm->_menuMan->f457_drawEnabledMenus();
+}
+
+int16 ChampionMan::f305_getThrowingStaminaCost(Thing thing) {
+	int16 L0923_i_Weight;
+	int16 L0924_i_StaminaCost;
+
+
+	L0924_i_StaminaCost = f26_getBoundedValue((int16)1, L0923_i_Weight = _vm->_dungeonMan->f140_getObjectWeight(thing) >> 1, (int16)10);
+	while ((L0923_i_Weight -= 10) > 0) {
+		L0924_i_StaminaCost += L0923_i_Weight >> 1;
+	}
+	return L0924_i_StaminaCost;
+}
+
+void ChampionMan::f330_disableAction(uint16 champIndex, uint16 ticks) {
+	int32 L1001_l_UpdatedEnableActionEventTime;
+	int32 L1002_l_CurrentEnableActionEventTime;
+	int16 L1003_i_EventIndex;
+	Champion* L1004_ps_Champion;
+	TimelineEvent L1005_s_Event;
+
+
+	L1004_ps_Champion = &_gK71_champions[champIndex];
+	L1001_l_UpdatedEnableActionEventTime = _vm->_g313_gameTime + ticks;
+	L1005_s_Event._type = k11_TMEventTypeEnableChampionAction;
+	L1005_s_Event._priority = champIndex;
+	L1005_s_Event._B._slotOrdinal = 0;
+	if ((L1003_i_EventIndex = L1004_ps_Champion->_enableActionEventIndex) >= 0) {
+		L1002_l_CurrentEnableActionEventTime = M30_time(_vm->_timeline->_g370_events[L1003_i_EventIndex]._mapTime);
+		if (L1001_l_UpdatedEnableActionEventTime >= L1002_l_CurrentEnableActionEventTime) {
+			L1001_l_UpdatedEnableActionEventTime += (L1002_l_CurrentEnableActionEventTime - _vm->_g313_gameTime) >> 1;
+		} else {
+			L1001_l_UpdatedEnableActionEventTime = L1002_l_CurrentEnableActionEventTime + (ticks >> 1);
+		}
+		_vm->_timeline->f237_deleteEvent(L1003_i_EventIndex);
+	} else {
+		setFlag(L1004_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand | k0x0008_ChampionAttributeDisableAction);
+		f292_drawChampionState((ChampionIndex)champIndex);
+	}
+	M33_setMapAndTime(L1005_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, L1001_l_UpdatedEnableActionEventTime);
+	L1004_ps_Champion->_enableActionEventIndex = _vm->_timeline->f238_addEventGetEventIndex(&L1005_s_Event);
+}
+
+void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp) {
+#define AP0638_ui_SkillLevelAfter exp
+#define AP0638_ui_ChampionColor   exp
+	uint16 L0915_ui_Multiple;
+#define AL0915_ui_MapDifficulty    L0915_ui_Multiple
+#define AL0915_ui_SkillLevelBefore L0915_ui_Multiple
+#define AL0915_ui_VitalityAmount   L0915_ui_Multiple
+#define AL0915_ui_StaminaAmount    L0915_ui_Multiple
+	uint16 L0916_ui_BaseSkillIndex;
+	Skill* L0918_ps_Skill;
+	Champion* L0919_ps_Champion;
+	int16 L0920_i_MinorStatisticIncrease;
+	int16 L0921_i_MajorStatisticIncrease;
+	int16 L0922_i_BaseSkillLevel;
+
+
+	warning("potaneitally dangerous cast of uint32 below");
+	if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && ((uint32)_vm->_projexpl->_g361_lastCreatureAttackTime < (_vm->_g313_gameTime - 150))) {
+		exp >>= 1;
+	}
+	if (exp) {
+		if (AL0915_ui_MapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty) {
+			exp *= AL0915_ui_MapDifficulty;
+		}
+		L0919_ps_Champion = &_gK71_champions[champIndex];
+		if (skillIndex >= k4_ChampionSkillSwing) {
+			L0916_ui_BaseSkillIndex = (skillIndex - k4_ChampionSkillSwing) >> 2;
+		} else {
+			L0916_ui_BaseSkillIndex = skillIndex;
+		}
+		AL0915_ui_SkillLevelBefore = f303_getSkillLevel(champIndex, L0916_ui_BaseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
+		warning("potentially dangerous cast of uint32 below");
+		if ((skillIndex >= k4_ChampionSkillSwing) && ((uint32)_vm->_projexpl->_g361_lastCreatureAttackTime > (_vm->_g313_gameTime - 25))) {
+			exp <<= 1;
+		}
+		L0918_ps_Skill = &L0919_ps_Champion->_skills[skillIndex];
+		L0918_ps_Skill->_experience += exp;
+		if (L0918_ps_Skill->_temporaryExperience < 32000) {
+			L0918_ps_Skill->_temporaryExperience += f26_getBoundedValue(1, exp >> 3, 100);
+		}
+		L0918_ps_Skill = &L0919_ps_Champion->_skills[L0916_ui_BaseSkillIndex];
+		if (skillIndex >= k4_ChampionSkillSwing) {
+			L0918_ps_Skill->_experience += exp;
+		}
+		AP0638_ui_SkillLevelAfter = f303_getSkillLevel(champIndex, L0916_ui_BaseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
+		if (AP0638_ui_SkillLevelAfter > AL0915_ui_SkillLevelBefore) {
+			L0922_i_BaseSkillLevel = AP0638_ui_SkillLevelAfter;
+			L0920_i_MinorStatisticIncrease = _vm->getRandomNumber(2);
+			L0921_i_MajorStatisticIncrease = 1 + _vm->getRandomNumber(2);
+			AL0915_ui_VitalityAmount = _vm->getRandomNumber(2); /* For Priest skill, the amount is 0 or 1 for all skill levels */
+			if (L0916_ui_BaseSkillIndex != k2_ChampionSkillPriest) {
+				AL0915_ui_VitalityAmount &= AP0638_ui_SkillLevelAfter; /* For non Priest skills the amount is 0 for even skill levels. The amount is 0 or 1 for odd skill levels */
+			}
+			L0919_ps_Champion->_statistics[k4_ChampionStatVitality][k0_ChampionStatMaximum] += AL0915_ui_VitalityAmount;
+			AL0915_ui_StaminaAmount = L0919_ps_Champion->_maxStamina;
+			L0919_ps_Champion->_statistics[k6_ChampionStatAntifire][k0_ChampionStatMaximum] += _vm->getRandomNumber(2) & ~AP0638_ui_SkillLevelAfter; /* The amount is 0 for odd skill levels. The amount is 0 or 1 for even skill levels */
+			switch (L0916_ui_BaseSkillIndex) {
+			case k0_ChampionSkillFighter:
+				AL0915_ui_StaminaAmount >>= 4;
+				AP0638_ui_SkillLevelAfter *= 3;
+				L0919_ps_Champion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += L0921_i_MajorStatisticIncrease;
+				L0919_ps_Champion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += L0920_i_MinorStatisticIncrease;
+				break;
+			case k1_ChampionSkillNinja:
+				AL0915_ui_StaminaAmount /= 21;
+				AP0638_ui_SkillLevelAfter <<= 1;
+				L0919_ps_Champion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += L0920_i_MinorStatisticIncrease;
+				L0919_ps_Champion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += L0921_i_MajorStatisticIncrease;
+				break;
+			case k3_ChampionSkillWizard:
+				AL0915_ui_StaminaAmount >>= 5;
+				L0919_ps_Champion->_maxMana += AP0638_ui_SkillLevelAfter + (AP0638_ui_SkillLevelAfter >> 1);
+				L0919_ps_Champion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += L0921_i_MajorStatisticIncrease;
+				goto T0304016;
+			case k2_ChampionSkillPriest:
+				AL0915_ui_StaminaAmount /= 25;
+				L0919_ps_Champion->_maxMana += AP0638_ui_SkillLevelAfter;
+				AP0638_ui_SkillLevelAfter += (AP0638_ui_SkillLevelAfter + 1) >> 1;
+				L0919_ps_Champion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += L0920_i_MinorStatisticIncrease;
+T0304016:
+				if ((L0919_ps_Champion->_maxMana += MIN(_vm->getRandomNumber(4), (uint16)(L0922_i_BaseSkillLevel - 1))) > 900) {
+					L0919_ps_Champion->_maxMana = 900;
+				}
+				L0919_ps_Champion->_statistics[k5_ChampionStatAntimagic][k0_ChampionStatMaximum] += _vm->getRandomNumber(3);
+			}
+			if ((L0919_ps_Champion->_maxHealth += AP0638_ui_SkillLevelAfter + _vm->getRandomNumber((AP0638_ui_SkillLevelAfter >> 1) + 1)) > 999) {
+				L0919_ps_Champion->_maxHealth = 999;
+			}
+			if ((L0919_ps_Champion->_maxStamina += AL0915_ui_StaminaAmount + _vm->getRandomNumber((AL0915_ui_StaminaAmount >> 1) + 1)) > 9999) {
+				L0919_ps_Champion->_maxStamina = 9999;
+			}
+			setFlag(L0919_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+			f292_drawChampionState((ChampionIndex)champIndex);
+			_vm->_textMan->f51_messageAreaPrintLineFeed();
+			_vm->_textMan->f47_messageAreaPrintMessage((Color)(AP0638_ui_ChampionColor = g46_ChampionColor[champIndex]), L0919_ps_Champion->_name);
+			// TODO: localization
+			_vm->_textMan->f47_messageAreaPrintMessage((Color)AP0638_ui_ChampionColor, " JUST GAINED A ");
+			_vm->_textMan->f47_messageAreaPrintMessage((Color)AP0638_ui_ChampionColor, g417_baseSkillName[L0916_ui_BaseSkillIndex]);
+			_vm->_textMan->f47_messageAreaPrintMessage((Color)AP0638_ui_ChampionColor, " LEVEL!");
+		}
+	}
+}
+
+int16 ChampionMan::f324_damageAll_getDamagedChampionCount(uint16 attack, int16 wounds, int16 attackType) {
+	int16 L0984_i_ChampionIndex;
+	int16 L0985_i_RandomAttack;
+	int16 L0986_i_DamagedChampionCount;
+
+	attack -= (L0985_i_RandomAttack = (attack >> 3) + 1);
+	L0985_i_RandomAttack <<= 1;
+	for (L0986_i_DamagedChampionCount = 0, L0984_i_ChampionIndex = k0_ChampionFirst; L0984_i_ChampionIndex < _g305_partyChampionCount; L0984_i_ChampionIndex++) {
+		if (f321_addPendingDamageAndWounds_getDamage(L0984_i_ChampionIndex, MAX(1, attack + _vm->getRandomNumber(L0985_i_RandomAttack)), wounds, attackType)) { /* Actual attack is attack +/- (attack / 8) */
+			L0986_i_DamagedChampionCount++;
+		}
+	}
+	return L0986_i_DamagedChampionCount;
+}
+
+int16 ChampionMan::f286_getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) {
+	uint16 L0838_ui_Counter;
+	int16 L0839_i_ChampionIndex;
+	signed char L0840_auc_OrderedCellsToAttack[4];
+
+
+	if (_g305_partyChampionCount && (M38_distance(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)) {
+		_vm->_groupMan->f229_setOrderedCellsToAttack(L0840_auc_OrderedCellsToAttack, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, mapX, mapY, cell);
+		for (L0838_ui_Counter = 0; L0838_ui_Counter < 4; L0838_ui_Counter++) {
+			if ((L0839_i_ChampionIndex = f285_getIndexInCell(L0840_auc_OrderedCellsToAttack[L0838_ui_Counter])) >= 0) {
+				return L0839_i_ChampionIndex;
+			}
+		}
+	}
+	return kM1_ChampionNone;
+}
+
+int16 ChampionMan::f311_getDexterity(Champion* champ) {
+	int16 L0934_i_Dexterity;
+
+
+	L0934_i_Dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent];
+	L0934_i_Dexterity -= ((int32)(L0934_i_Dexterity >> 1) * (int32)champ->_load) / f309_getMaximumLoad(champ);
+	if (_g300_partyIsSleeping) {
+		L0934_i_Dexterity >>= 1;
+	}
+	return f26_getBoundedValue(1 + _vm->getRandomNumber(8), L0934_i_Dexterity >> 1, 100 - _vm->getRandomNumber(8));
+}
+
+bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) {
+#define AP0646_ui_IsLucky percentage
+	register unsigned char* L0928_puc_Statistic;
+
+
+	if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage)) {
+		return true;
+	}
+	L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck];
+	AP0646_ui_IsLucky = (_vm->getRandomNumber(L0928_puc_Statistic[k1_ChampionStatCurrent]) > percentage);
+	L0928_puc_Statistic[k1_ChampionStatCurrent] = f26_getBoundedValue((int32)L0928_puc_Statistic[k2_ChampionStatMinimum], (int32)L0928_puc_Statistic[k1_ChampionStatCurrent] + (AP0646_ui_IsLucky ? -2 : 2), (int32)L0928_puc_Statistic[k0_ChampionStatMaximum]);
+	return AP0646_ui_IsLucky;
+}
+
+void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) {
+	TimelineEvent L0980_s_Event;
+	Champion* L0981_ps_Champion;
+
+
+	if ((champIndex == kM1_ChampionNone) || (_vm->M0_indexToOrdinal(champIndex) == _g299_candidateChampionOrdinal)) {
+		return;
+	}
+	L0981_ps_Champion = &_gK71_champions[champIndex];
+	f321_addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
+	setFlag(L0981_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+	if ((_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) && (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
+		setFlag(L0981_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
+	}
+	if (--attack) {
+		L0981_ps_Champion->_poisonEventCount++;
+		L0980_s_Event._type = k75_TMEventTypePoisonChampion;
+		L0980_s_Event._priority = champIndex;
+		M33_setMapAndTime(L0980_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 36);
+		L0980_s_Event._B._attack = attack;
+		_vm->_timeline->f238_addEventGetEventIndex(&L0980_s_Event);
+	}
+	f292_drawChampionState((ChampionIndex)champIndex);
+}
+
+void ChampionMan::f284_setPartyDirection(int16 dir) {
+	int16 L0833_i_ChampionIndex;
+	int16 L0834_i_Delta;
+	Champion* L0835_ps_Champion;
+
+
+	if (dir == _vm->_dungeonMan->_g308_partyDir) {
+		return;
+	}
+	if ((L0834_i_Delta = dir - _vm->_dungeonMan->_g308_partyDir) < 0) {
+		L0834_i_Delta += 4;
+	}
+	L0835_ps_Champion = _gK71_champions;
+	for (L0833_i_ChampionIndex = k0_ChampionFirst; L0833_i_ChampionIndex < _g305_partyChampionCount; L0833_i_ChampionIndex++) {
+		L0835_ps_Champion->_cell = (ViewCell)M21_normalizeModulo4(L0835_ps_Champion->_cell + L0834_i_Delta);
+		L0835_ps_Champion->_dir = (direction)M21_normalizeModulo4(L0835_ps_Champion->_dir + L0834_i_Delta);
+		L0835_ps_Champion++;
+	}
+	_vm->_dungeonMan->_g308_partyDir = (direction)dir;
+	f296_drawChangedObjectIcons();
+}
+
+void ChampionMan::f316_deleteScent(uint16 scentIndex) {
+	uint16 L0953_ui_Count;
+
+	if (L0953_ui_Count = --_g407_party._scentCount - scentIndex) {
+		for (uint16 i = 0; i < L0953_ui_Count; ++i) {
+			_g407_party._scents[scentIndex + i] = _g407_party._scents[scentIndex + i + 1];
+			_g407_party._scentStrengths[scentIndex + i] = _g407_party._scentStrengths[scentIndex + i + 1];
+		}
+	}
+	if (scentIndex < _g407_party._firstScentIndex) {
+		_g407_party._firstScentIndex--;
+	}
+	if (scentIndex < _g407_party._lastScentIndex) {
+		_g407_party._lastScentIndex--;
+	}
+}
+
+void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount) {
+	int16 L0954_i_ScentIndex;
+	bool L0955_B_Merge;
+	bool L0956_B_CycleCountDefined;
+	Scent* L0957_ps_Scent; /* BUG0_00 Useless code */
+	Scent L0958_s_Scent; /* BUG0_00 Useless code */
+
+
+	if (L0954_i_ScentIndex = _vm->_championMan->_g407_party._scentCount) {
+		if (L0955_B_Merge = getFlag(cycleCount, k0x8000_mergeCycles)) {
+			clearFlag(cycleCount, k0x8000_mergeCycles);
+		}
+		L0958_s_Scent.setMapX(mapX); /* BUG0_00 Useless code */
+		L0958_s_Scent.setMapY(mapY); /* BUG0_00 Useless code */
+		L0958_s_Scent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */
+		L0957_ps_Scent = _vm->_championMan->_g407_party._scents; /* BUG0_00 Useless code */
+		L0956_B_CycleCountDefined = false;
+		while (L0954_i_ScentIndex--) {
+			if (&*L0957_ps_Scent++ == &L0958_s_Scent) {
+				if (!L0956_B_CycleCountDefined) {
+					L0956_B_CycleCountDefined = true;
+					if (L0955_B_Merge) {
+						cycleCount = MAX((int32)_vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount);
+					} else {
+						cycleCount = MIN(80, _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount);
+					}
+				}
+				_vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount;
+			}
+		}
+	}
+}
+
+void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) {
+	if (thing == Thing::_none) {
+		return;
+	}
+	_vm->_championMan->_g415_leaderEmptyHanded = false;
+	_vm->_objectMan->f36_extractIconFromBitmap(_vm->_championMan->_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_vm->_championMan->_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
+	_vm->_eventMan->f78_showMouse();
+	_vm->_objectMan->f34_drawLeaderObjectName(thing);
+	if (setMousePointer) {
+		_vm->_g325_setMousePointerToObjectInMainLoop = true;
+	} else {
+		_vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
+	}
+	_vm->_eventMan->f77_hideMouse();
+	if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) {
+		_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing);
+		setFlag(_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
+		_vm->_championMan->f292_drawChampionState(_vm->_championMan->_g411_leaderIndex);
+	}
+}
+
+ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
 	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
 		if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
 			return (ChampionIndex)i;
@@ -685,7 +1384,7 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
 	} else {
 		barGraphHeightArray[barGraphIndex++] = 0;
 	}
-	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+	_vm->_eventMan->f78_showMouse();
 
 	Box box;
 	box._x1 = champIndex * k69_ChampionStatusBoxSpacing + 46;
@@ -708,7 +1407,7 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
 		box._x1 += 7;
 		box._x2 += 7;
 	}
-	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+	_vm->_eventMan->f77_hideMouse();
 }
 
 
@@ -918,7 +1617,7 @@ T0292042_green:
 	champ->setAttributeFlag((ChampionAttribute)(k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon |
 												k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport |
 												k0x8000_ChampionAttributeActionHand), false);
-	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+	_vm->_eventMan->f78_showMouse();
 }
 
 uint16 ChampionMan::M26_championIconIndex(int16 val, direction dir) {
@@ -931,7 +1630,7 @@ void ChampionMan::f290_drawHealthStaminaManaValues(Champion* champ) {
 	f289_drawHealthOrStaminaOrManaValue(132, champ->_currMana, champ->_maxMana);
 }
 
-void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
+void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
 	int16 nativeBitmapIndex = -1;
 	Champion *champ = &_gK71_champions[champIndex];
 	bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex));
@@ -950,7 +1649,7 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 	if (slotIndex >= k30_ChampionSlotChest_1) {
 		thing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
 	} else {
-		thing = champ->getSlot(slotIndex);
+		thing = champ->getSlot((ChampionSlot)slotIndex);
 	}
 
 	SlotBox *slotBox = &_vm->_objectMan->_g30_slotBoxes[slotBoxIndex];
@@ -962,7 +1661,7 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 
 
 	if (!isInventoryChamp) {
-		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+		_vm->_eventMan->f77_hideMouse();
 	}
 
 	int16 iconIndex;
@@ -983,10 +1682,8 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 			}
 		}
 	} else {
-		warning("BUG0_35");
 		iconIndex = _vm->_objectMan->f33_getIconIndex(thing); // BUG0_35
 		if (isInventoryChamp && (slotIndex == k1_ChampionSlotActionHand) && ((iconIndex == k144_IconIndiceContainerChestClosed) || (iconIndex == k30_IconIndiceScrollOpen))) {
-			warning("BUG2_00");
 			iconIndex++;
 		} // BUG2_00
 		if (slotIndex <= k5_ChampionSlotFeet) {
@@ -1016,7 +1713,7 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) {
 	_vm->_objectMan->f38_drawIconInSlotBox(slotBoxIndex, iconIndex);
 
 	if (!isInventoryChamp) {
-		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+		_vm->_eventMan->f78_showMouse();
 	}
 }
 
@@ -1049,7 +1746,7 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 	}
 }
 
-uint16 ChampionMan::f303_getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex) {
+uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, int16 skillIndex) {
 	if (_g300_partyIsSleeping)
 		return 1;
 
@@ -1057,7 +1754,7 @@ uint16 ChampionMan::f303_getSkillLevel(ChampionIndex champIndex, ChampionSkill s
 	bool ignoreObjModifiers = skillIndex & k0x4000_IgnoreObjectModifiers;
 	skillIndex = (ChampionSkill)(skillIndex & ~(ignoreTempExp | ignoreObjModifiers));
 	Champion *champ = &_gK71_champions[champIndex];
-	Skill *skill = &champ->getSkill(skillIndex);
+	Skill *skill = &champ->getSkill((ChampionSkill)skillIndex);
 	int32 experience = skill->_experience;
 
 	if (!ignoreTempExp)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 43e976e..282889d 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -328,6 +328,14 @@ enum ChampionAction {
 	k255_ChampionActionNone = 255 // @ C255_ACTION_NONE
 };
 
+#define k0_attackType_NORMAL 0 // @ C0_ATTACK_NORMAL
+#define k1_attackType_FIRE 1 // @ C1_ATTACK_FIRE
+#define k2_attackType_SELF 2 // @ C2_ATTACK_SELF
+#define k3_attackType_BLUNT 3 // @ C3_ATTACK_BLUNT
+#define k4_attackType_SHARP 4 // @ C4_ATTACK_SHARP
+#define k5_attackType_MAGIC 5 // @ C5_ATTACK_MAGIC
+#define k6_attackType_PSYCHIC 6 // @ C6_ATTACK_PSYCHIC
+#define k7_attackType_LIGHTNING 7 // @ C7_ATTACK_LIGHTNING
 
 class Skill {
 public:
@@ -338,12 +346,12 @@ public:
 }; // @ SKILL
 
 class Champion {
-	Thing _slots[30];
-	Skill _skills[20];
+public:
 	uint16 _attributes;
-	byte _statistics[7][3];
 	uint16 _wounds;
-public:
+	byte _statistics[7][3];
+	Thing _slots[30];
+	Skill _skills[20];
 	char _name[8];
 	char _title[20];
 	direction _dir;
@@ -425,16 +433,23 @@ public:
 	}
 }; // @ CHAMPION_INCLUDING_PORTRAIT
 
+#define k0x0000_maskDoNotUseSharpDefense 0x0000 // @ MASK0x0000_DO_NOT_USE_SHARP_DEFENSE 
+#define k0x8000_maskUseSharpDefense 0x8000 // @ MASK0x8000_USE_SHARP_DEFENSE        
+
+#define k0x8000_mergeCycles 0x8000 // @ MASK0x8000_MERGE_CYCLES
+extern const char *g417_baseSkillName[4];
+
 class ChampionMan {
 	DMEngine *_vm;
 
 	uint16 M27_getChampionPortraitX(uint16 index); // @ M27_PORTRAIT_X
 	uint16 M28_getChampionPortraitY(uint16 index); // @ M28_PORTRAIT_Y
 
-	ChampionIndex f285_getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell
 	int16 f279_getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue
 	void f289_drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue
 	uint16 M70_handSlotIndex(uint16 slotBoxIndex);// @ M70_HAND_SLOT_INDEX
+	int16 _g410_championPendingWounds[4]; // @ G0410_ai_ChampionPendingWounds
+	int16 _g409_championPendingDamage[4]; // @ G0409_ai_ChampionPendingDamage
 public:
 	Champion _gK71_champions[4]; // @ K0071_as_Champions
 	uint16 _g305_partyChampionCount;	// @ G0305_ui_PartyChampionCount
@@ -451,6 +466,9 @@ public:
 	bool _g420_mousePointerHiddenToDrawChangedObjIconOnScreen; // @ G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen
 
 	explicit ChampionMan(DMEngine *vm);
+	ChampionIndex f285_getIndexInCell(int16 cell); // @ F0285_CHAMPION_GetIndexInCell
+	bool f329_isLeaderHandObjectThrown(int16 side); // @ F0329_CHAMPION_IsLeaderHandObjectThrown
+	bool f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side); // @ F0328_CHAMPION_IsObjectThrown
 	void f278_resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
 	void f280_addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty
 	void f287_drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs
@@ -459,16 +477,42 @@ public:
 	void f292_drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState
 	uint16 M26_championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX
 	void f290_drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues
-	void f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex); // @ F0291_CHAMPION_DrawSlot
+	void f291_drawSlot(uint16 champIndex, int16 slotIndex); // @ F0291_CHAMPION_DrawSlot
 	void f281_renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename
-	uint16 f303_getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex);// @ F0303_CHAMPION_GetSkillLevel
+	uint16 f303_getSkillLevel(int16 champIndex, int16 skillIndex);// @ F0303_CHAMPION_GetSkillLevel
 	Common::String f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger
-	void f299_applyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex,
+	void f299_applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex,
 									int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics
 	bool f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged
 	void f296_drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons
 	void f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex); // @ F0301_CHAMPION_AddObjectInSlot
 	int16 f315_getScentOrdinal(int16 mapX, int16 mapY); // @ F0315_CHAMPION_GetScentOrdinal
+	Thing f298_getObjectRemovedFromLeaderHand(); // @ F0298_CHAMPION_GetObjectRemovedFromLeaderHand
+	uint16 f312_getStrength(int16 champIndex, int16 slotIndex); // @ F0312_CHAMPION_GetStrength 
+	Thing f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex); // @ F0300_CHAMPION_GetObjectRemovedFromSlot
+	void f325_decrementStamine(int16 championIndex, int16 decrement); // @ F0325_CHAMPION_DecrementStamina
+	int16 f321_addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds,
+												   uint16 attackType); // @ F0321_CHAMPION_AddPendingDamageAndWounds_GetDamage
+	int16 f313_getWoundDefense(int16 champIndex, uint16 woundIndex); // @ F0313_CHAMPION_GetWoundDefense
+	uint16 f307_getStatisticAdjustedAttack(Champion *champ, uint16 statIndex, uint16 attack); // @ F0307_CHAMPION_GetStatisticAdjustedAttack
+	void f314_wakeUp(); // @ F0314_CHAMPION_WakeUp
+	int16 f305_getThrowingStaminaCost(Thing thing);// @ F0305_CHAMPION_GetThrowingStaminaCost
+	void f330_disableAction(uint16 champIndex, uint16 ticks); // @ F0330_CHAMPION_DisableAction
+	void f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp);// @ F0304_CHAMPION_AddSkillExperience
+	int16 f324_damageAll_getDamagedChampionCount(uint16 attack, int16 wounds,
+												 int16 attackType); // @ F0324_CHAMPION_DamageAll_GetDamagedChampionCount
+	int16 f286_getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell); // @ F0286_CHAMPION_GetTargetChampionIndex
+	int16 f311_getDexterity(Champion *champ); // @ F0311_CHAMPION_GetDexterity
+	bool f308_isLucky(Champion *champ, uint16 percentage); // @ F0308_CHAMPION_IsLucky
+	void f322_championPoison(int16 championIndex, uint16 attack); // @ F0322_CHAMPION_Poison
+	void f284_setPartyDirection(int16 dir); // @ F0284_CHAMPION_SetPartyDirection
+	void f316_deleteScent(uint16 scentIndex); // @ F0316_CHAMPION_DeleteScent
+	void f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount); // @ F0317_CHAMPION_AddScentStrength
+	void f297_putObjectInLeaderHand(Thing thing, bool setMousePointer); // @ F0297_CHAMPION_PutObjectInLeaderHand
+
+
+
+
 
 };
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index d824cf3..51b33c3 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -51,6 +51,7 @@
 #include "movesens.h"
 #include "group.h"
 #include "timeline.h"
+#include "projexpl.h"
 
 namespace DM {
 
@@ -68,18 +69,11 @@ uint16 returnNextVal(uint16 val) {
 
 bool isOrientedWestEast(direction dir) { return dir & 1; }
 
-uint16 getFlag(uint16 val, uint16 mask) {
-	return val & mask;
-}
 
 uint16 setFlag(uint16 &val, uint16 mask) {
 	return val |= mask;
 }
 
-uint16 clearFlag(uint16 &val, uint16 mask) {
-	return val &= ~mask;
-}
-
 uint16 toggleFlag(uint16& val, uint16 mask) {
 	return val ^= mask;
 }
@@ -92,6 +86,26 @@ uint16 M21_normalizeModulo4(uint16 val) {
 	return val & 3;
 }
 
+int32 M30_time(int32 map_time) {
+	return map_time & 0x00FFFFFF;
+}
+
+int32 M33_setMapAndTime(int32 &map_time, uint32 map, uint32 time) {
+	return (map_time) = ((time) | (((long)(map)) << 24));
+}
+
+uint16 M29_map(int32 map_time) {
+	return ((uint16)((map_time) >> 24));
+}
+
+Thing M15_thingWithNewCell(Thing thing, int16 cell) {
+	return Thing(((thing.toUint16()) & 0x3FFF) | ((cell) << 14));
+}
+
+int16 M38_distance(int16 mapx1, int16 mapy1, int16 mapx2, int16 mapy2) {
+	return ABS(mapx1 - mapx2) + ABS(mapy1 - mapy2);
+}
+
 DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 // Do not load data files
 // Do not initialize graphics here
@@ -118,6 +132,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_movsens = nullptr;
 	_groupMan = nullptr;
 	_timeline = nullptr;
+	_projexpl = nullptr;
 	_g321_stopWaitingForPlayerInput = false;
 	_g301_gameTimeTicking = false;
 	_g524_restartGameAllowed = false;
@@ -126,6 +141,9 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_g332_stopPressingEye = false;
 	_g334_stopPressingMouth = false;
 	_g340_highlightBoxInversionRequested = false;
+	_g313_gameTime = 0;
+	_g302_gameWon = false;
+	_g327_newPartyMapIndex = kM1_mapIndexNone;
 
 	debug("DMEngine::DMEngine");
 }
@@ -148,11 +166,20 @@ DMEngine::~DMEngine() {
 	delete _movsens;
 	delete _groupMan;
 	delete _timeline;
+	delete _projexpl;
 
 	// clear debug channels
 	DebugMan.clearAllDebugChannels();
 }
 
+void DMEngine::waitMs(uint16 ms) {
+	_system->delayMillis(ms * 20);
+}
+
+uint16 DMEngine::f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2) {
+	return ((uint32)val * vale2) >> scale;
+}
+
 void DMEngine::f463_initializeGame() {
 	_displayMan->f479_loadGraphics();
 	_displayMan->f460_initializeGraphicData();
@@ -174,8 +201,8 @@ void DMEngine::f463_initializeGame() {
 
 	f462_startGame();
 	warning("MISSING CODE: F0267_MOVE_GetMoveResult_CPSCE (if newGame)");
-	_eventMan->showMouse(true);
-	warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
+	_eventMan->f78_showMouse();
+	_eventMan->f357_discardAllInput();
 }
 
 void DMEngine::f448_initMemoryManager() {
@@ -220,7 +247,7 @@ void DMEngine::f3_processNewPartyMap(uint16 mapIndex) {
 	_dungeonMan->f174_setCurrentMapAndPartyMap(mapIndex);
 	_displayMan->f96_loadCurrentMapGraphics();
 	warning("MISSING CODE: F0195_GROUP_AddAllActiveGroups");
-	warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette");
+	_inventoryMan->f337_setDungeonViewPalette();
 }
 
 Common::Error DMEngine::run() {
@@ -241,6 +268,7 @@ Common::Error DMEngine::run() {
 	_movsens = new MovesensMan(this);
 	_groupMan = new GroupMan(this);
 	_timeline = new Timeline(this);
+	_projexpl = new ProjExpl(this);
 	_displayMan->setUpScreens(320, 200);
 
 	f463_initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
@@ -257,16 +285,19 @@ void DMEngine::f2_gameloop() {
 	_dungeonMan->_g306_partyMapX = 10;
 	_dungeonMan->_g307_partyMapY = 4;
 	_dungeonMan->_g308_partyDir = kDirNorth;
-
-
 	warning("DUMMY CODE: setting InventoryMan::_g432_inventoryChampionOrdinal to zero");
 	_inventoryMan->_g432_inventoryChampionOrdinal = 0;
 	warning("DUMMY CODE: clearing screen to black"); // in loop below
+
 	while (true) {
-		_g321_stopWaitingForPlayerInput = false;
 
+		_g313_gameTime++;
 		_menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived();
 
+		if (_g311_projectileDisableMovementTicks)
+			_g311_projectileDisableMovementTicks--;
+
+		_g321_stopWaitingForPlayerInput = false;
 		//do {
 		_eventMan->processInput();
 		_eventMan->f380_processCommandQueue();
@@ -278,12 +309,8 @@ void DMEngine::f2_gameloop() {
 			_displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
 		}
 
-		// DUMMY CODE: next 2 lines
-		_menuMan->f395_drawMovementArrows();
-		_displayMan->f97_drawViewport(k1_viewportDungeonView);
-
 		_displayMan->updateScreen();
-		_system->delayMillis(10);
+		_system->delayMillis(18);
 	}
 }
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index c4fe3c5..9ace815 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -48,6 +48,8 @@ class TextMan;
 class MovesensMan;
 class GroupMan;
 class Timeline;
+class ProjExpl;
+
 
 
 enum direction {
@@ -57,50 +59,26 @@ enum direction {
 	kDirWest = 3
 };
 
-void turnDirRight(direction &dir);
-void turnDirLeft(direction &dir);
-direction returnOppositeDir(direction dir);	// @ M18_OPPOSITE
-uint16 returnPrevVal(uint16 val); // @ M19_PREVIOUS
-uint16 returnNextVal(uint16 val); // @ M17_NEXT
-bool isOrientedWestEast(direction dir);	// @ M16_IS_ORIENTED_WEST_EAST
-
-
-uint16 getFlag(uint16 val, uint16 mask); // @ M07_GET
-uint16 setFlag(uint16 &val, uint16 mask); // @ M08_SET
-uint16 clearFlag(uint16 &val, uint16 mask);	// @ M09_CLEAR
-uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE
-uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height);  // @ M75_BITMAP_BYTE_COUNT
-uint16 M21_normalizeModulo4(uint16 val); // @ M21_NORMALIZE
 
 
 enum ThingType {
-	kM1_PartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value
-	k0_DoorThingType = 0,
-	k1_TeleporterThingType = 1,
-	k2_TextstringType = 2,
-	k3_SensorThingType = 3,
-	k4_GroupThingType = 4,
-	k5_WeaponThingType = 5,
-	k6_ArmourThingType = 6,
-	k7_ScrollThingType = 7,
-	k8_PotionThingType = 8,
-	k9_ContainerThingType = 9,
-	k10_JunkThingType = 10,
-	k14_ProjectileThingType = 14,
-	k15_ExplosionThingType = 15,
+	kM1_PartyThingType = -1,  // @ CM1_THING_TYPE_PARTY
+	k0_DoorThingType = 0, // @ C00_THING_TYPE_DOOR       
+	k1_TeleporterThingType = 1, // @ C01_THING_TYPE_TELEPORTER 
+	k2_TextstringType = 2, // @ C02_THING_TYPE_TEXTSTRING 
+	k3_SensorThingType = 3,  // @ C03_THING_TYPE_SENSOR     
+	k4_GroupThingType = 4, // @ C04_THING_TYPE_GROUP 
+	k5_WeaponThingType = 5, // @ C05_THING_TYPE_WEAPON
+	k6_ArmourThingType = 6, // @ C06_THING_TYPE_ARMOUR
+	k7_ScrollThingType = 7,  // @ C07_THING_TYPE_SCROLL     
+	k8_PotionThingType = 8,  // @ C08_THING_TYPE_POTION     
+	k9_ContainerThingType = 9,  // @ C09_THING_TYPE_CONTAINER  
+	k10_JunkThingType = 10,  // @ C10_THING_TYPE_JUNK      
+	k14_ProjectileThingType = 14,  // @ C14_THING_TYPE_PROJECTILE
+	k15_ExplosionThingType = 15,  // @ C15_THING_TYPE_EXPLOSION 
 	k16_ThingTypeTotal = 16 // +1 than the last (explosionThingType)
 }; // @ C[00..15]_THING_TYPE_...
 
-enum Cell {
-	kM1_CellAny = -1, // @ CM1_CELL_ANY      
-	k0_CellNorthWest = 0, // @ C00_CELL_NORTHWEST 
-	k1_CellNorthEast = 1, // @ C01_CELL_NORTHEAST 
-	k2_CellSouthEast = 2, // @ C02_CELL_SOUTHEAST 
-	k3_CellSouthWest = 3 // @ C03_CELL_SOUTHWEST 
-};
-
-#define kM1_mapIndexNone -1 // @ CM1_MAP_INDEX_NONE       
-#define k255_mapIndexEntrance 255 // @ C255_MAP_INDEX_ENTRANCE 
 
 class Thing {
 	uint16 _data;
@@ -131,12 +109,52 @@ public:
 	byte getCell() const { return _data >> 14; }
 	ThingType getType() const { return (ThingType)((_data >> 10) & 0xF); }
 	uint16 getIndex() const { return _data & 0x3FF; }
+	uint16 getTypeAndIndex() { return _data & 0x3FFF; }
 	uint16 toUint16() const { return _data; } // I don't like 'em cast operators
 	bool operator==(const Thing &rhs) const { return _data == rhs._data; }
 	bool operator!=(const Thing &rhs) const { return _data != rhs._data; }
 }; // @ THING
 
 
+
+void turnDirRight(direction &dir);
+void turnDirLeft(direction &dir);
+direction returnOppositeDir(direction dir);	// @ M18_OPPOSITE
+uint16 returnPrevVal(uint16 val); // @ M19_PREVIOUS
+uint16 returnNextVal(uint16 val); // @ M17_NEXT
+bool isOrientedWestEast(direction dir);	// @ M16_IS_ORIENTED_WEST_EAST
+
+
+uint16 setFlag(uint16 &val, uint16 mask); // @ M08_SET
+
+
+#define getFlag(val, mask) ((val) & (mask))
+
+
+#define clearFlag(val, mask) ((val) &= (~(mask))) // @ M09_CLEAR
+
+uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE
+uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height);  // @ M75_BITMAP_BYTE_COUNT
+uint16 M21_normalizeModulo4(uint16 val); // @ M21_NORMALIZE
+int32 M30_time(int32 map_time); // @ M30_TIME
+int32 M33_setMapAndTime(int32 &map_time, uint32 map, uint32 time); // @ M33_SET_MAP_AND_TIME
+uint16 M29_map(int32 map_time); // @ M29_MAP
+Thing M15_thingWithNewCell(Thing thing, int16 cell); // @ M15_THING_WITH_NEW_CELL
+int16 M38_distance(int16 mapx1, int16 mapy1, int16 mapx2, int16 mapy2);// @ M38_DISTANCE
+
+
+enum Cell {
+	kM1_CellAny = -1, // @ CM1_CELL_ANY      
+	k0_CellNorthWest = 0, // @ C00_CELL_NORTHWEST 
+	k1_CellNorthEast = 1, // @ C01_CELL_NORTHEAST 
+	k2_CellSouthEast = 2, // @ C02_CELL_SOUTHEAST 
+	k3_CellSouthWest = 3 // @ C03_CELL_SOUTHWEST 
+};
+
+#define kM1_mapIndexNone -1 // @ CM1_MAP_INDEX_NONE       
+#define k255_mapIndexEntrance 255 // @ C255_MAP_INDEX_ENTRANCE 
+
+
 enum {
 	// engine debug channels
 	kDMDebugExample = 1 << 0,
@@ -144,6 +162,17 @@ enum {
 	kDMDebugOftenCalledWarning = 2 << 2
 };
 
+
+
+
+template<typename T>
+inline T f26_getBoundedValue(T min, T val, T max) {
+	return MIN(MAX(min, val), max);
+} // @ F0026_MAIN_GetBoundedValue
+
+#define CALL_MEMBER_FN(object,ptrToMember)  ((object).*(ptrToMember))
+
+
 class DMEngine : public Engine {
 	void f462_startGame(); // @ F0462_START_StartGame_CPSF
 	void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
@@ -156,8 +185,12 @@ public:
 	explicit DMEngine(OSystem *syst);
 	~DMEngine();
 
+	void waitMs(uint16 ms);
+	uint16 f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2); // @ F0030_MAIN_GetScaledProduct
+	uint16 getRandomNumber(uint32 max) { return _rnd->getRandomNumber(max - 1); }
 	int16 M1_ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
 	int16 M0_indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
+	void f19_displayErrorAndStop(int16 errorIndex); // @ F0019_MAIN_DisplayErrorAndStop
 	virtual Common::Error run(); // @ main
 
 private:
@@ -176,6 +209,7 @@ public:
 	MovesensMan *_movsens;
 	GroupMan *_groupMan;
 	Timeline *_timeline;
+	ProjExpl *_projexpl;
 
 
 	bool _g298_newGame; // @ G0298_B_NewGame
@@ -190,10 +224,17 @@ public:
 	bool _g333_pressingMouth; // @ G0333_B_PressingMouth
 	bool _g334_stopPressingMouth; // @ G0334_B_StopPressingMouth
 	bool _g340_highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested
+	int16 _g311_projectileDisableMovementTicks; // @ G0311_i_ProjectileDisabledMovementTicks
+	int16 _g312_lastProjectileDisabledMovementDirection; // @ G0312_i_LastProjectileDisabledMovementDirection
+	bool _g302_gameWon; // @ G0302_B_GameWon
+	int16 _g327_newPartyMapIndex; // @ G0327_i_NewPartyMapIndex
+	bool _g325_setMousePointerToObjectInMainLoop; // @ G0325_B_SetMousePointerToObjectInMainLoop
 
 	// TODO: refactor direction into a class
 	int8 _dirIntoStepCountEast[4]; // @ G0233_ai_Graphic559_DirectionToStepEastCount
 	int8 _dirIntoStepCountNorth[4]; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
+	uint32 _g313_gameTime; // @ G0313_ul_GameTime
+	char _g353_stringBuildBuffer[128]; // @ G0353_ac_StringBuildBuffer
 };
 
 class Console : public GUI::Debugger {
diff --git a/engines/dm/dmglobals.cpp b/engines/dm/dmglobals.cpp
index c138453..044659a 100644
--- a/engines/dm/dmglobals.cpp
+++ b/engines/dm/dmglobals.cpp
@@ -25,6 +25,7 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
+#include "common/system.h"
 #include "dm/dm.h"
 #include "gfx.h"
 #include "dungeonman.h"
@@ -36,6 +37,8 @@
 #include "inventory.h"
 #include "text.h"
 #include "movesens.h"
+#include "string.h"
+
 
 namespace DM {
 
@@ -52,4 +55,12 @@ void DMEngine::initArrays() {
 	_dirIntoStepCountNorth[2] = 1;  // West
 	_dirIntoStepCountNorth[3] = 0;  // South
 }
+
+void DMEngine::f19_displayErrorAndStop(int16 errorIndex) {
+	debug("Stuff hit the fun: ");
+	debug(Common::String::format("%d", errorIndex).c_str());
+	Common::Event event;
+	while (_system->getEventManager()->pollEvent(event) || true)
+		;
+}
 } // End of namespace DM
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index fa0e72c..ca77856 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -31,7 +31,9 @@
 #include "dungeonman.h"
 #include "timeline.h"
 #include "champion.h"
-
+#include "group.h"
+#include "movesens.h"
+#include "projexpl.h"
 
 
 namespace DM {
@@ -835,11 +837,11 @@ void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, direction dir, int16
 #define footprintsAllowed L0307_uc_Multiple
 #define scentOrdinal      L0307_uc_Multiple
 	Sensor* sensor;
-	bool leftRandWallOrnAllowed;
-	int16 L0310_i_Multiple;
+	bool leftRandWallOrnAllowed = false;
+	int16 L0310_i_Multiple = 0;
 #define frontRandWallOrnAllowed L0310_i_Multiple
 #define sideIndex                      L0310_i_Multiple
-	bool rightRandWallOrnAllowed;
+	bool rightRandWallOrnAllowed = false;
 	int16 thingTypeRedEagle;
 	bool squreIsFakeWall;
 	Thing thing;
@@ -946,12 +948,12 @@ T0172030_Pit:
 		aspectArray[k2_TeleporterVisibleAspect] = getFlag(square, k0x0008_TeleporterOpen) && getFlag(square, k0x0004_TeleporterVisible);
 		goto T0172029_Teleporter;
 	case k3_ElementTypeStairs:
-		aspectArray[k0_ElemAspect] = ((getFlag(square, k0x0008_StairsNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront;
+		aspectArray[k0_ElemAspect] = (((getFlag(square, k0x0008_StairsNorthSouthOrient) >> 3) ? true : false) == isOrientedWestEast(dir)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront;
 		aspectArray[k2_StairsUpAspect] = getFlag(square, k0x0004_StairsUp);
 		footprintsAllowed = false;
 		goto T0172046_Stairs;
 	case k4_DoorElemType:
-		if ((getFlag(square, k0x0008_DoorNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) {
+		if (((getFlag(square, k0x0008_DoorNorthSouthOrient) >> 3) ? true : false) == isOrientedWestEast(dir)) {
 			aspectArray[k0_ElemAspect] = k16_DoorSideElemType;
 		} else {
 			aspectArray[k0_ElemAspect] = k17_DoorFrontElemType;
@@ -1190,6 +1192,45 @@ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) {
 	*destString = ((type == k0_TextTypeInscription) ? 0x81 : '\0');
 }
 
+Thing DungeonMan::f166_getUnusedThing(uint16 thingType) {
+	int16 L0288_i_ThingIndex;
+	int16 L0289_i_ThingDataByteCount;
+	int16 L0290_i_ThingCount;
+	Thing* L0291_ps_Generic;
+	Thing L0292_T_Thing;
+
+
+	L0290_i_ThingCount = _vm->_dungeonMan->_g278_dungeonFileHeader._thingCounts[getFlag(thingType, k0x7FFF_thingType)];
+	if (thingType == (k0x8000_championBones | k10_JunkThingType)) {
+		thingType = k10_JunkThingType;
+	} else {
+		if (thingType == k10_JunkThingType) {
+			L0290_i_ThingCount -= 3; /* Always keep 3 unused JUNK things for the bones of dead champions */
+		}
+	}
+	L0288_i_ThingIndex = L0290_i_ThingCount;
+	L0289_i_ThingDataByteCount = g235_ThingDataWordCount[thingType] >> 1;
+	L0291_ps_Generic = (Thing*)_vm->_dungeonMan->_g284_thingData[thingType];
+	for (;;) { /*_Infinite loop_*/
+		if (*L0291_ps_Generic == Thing::_none) { /* If thing data is unused */
+			L0292_T_Thing = Thing((thingType << 10) | (L0290_i_ThingCount - L0288_i_ThingIndex));
+			break;
+		}
+		if (--L0288_i_ThingIndex) { /* If there are thing data left to process */
+			L0291_ps_Generic += L0289_i_ThingDataByteCount; /* Proceed to the next thing data */
+		} else {
+			if ((L0292_T_Thing = f165_getDiscardTHing(thingType)) == Thing::_none) {
+				return Thing::_none;
+			}
+			L0291_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0292_T_Thing);
+			break;
+		}
+	}
+	memset(L0291_ps_Generic, 0, L0289_i_ThingDataByteCount * 2);
+
+	*L0291_ps_Generic = Thing::_endOfList;
+	return L0292_T_Thing;
+}
 
 uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 	static const uint16 g241_junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo
@@ -1381,4 +1422,293 @@ int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDe
 	}
 	return kM1_mapIndexNone;
 }
+
+Thing DungeonMan::f162_getSquareFirstObject(int16 mapX, int16 mapY) {
+	Thing thing = f161_getSquareFirstThing(mapX, mapY);
+	while ((thing != Thing::_endOfList) && (thing.getType() < k4_GroupThingType)) {
+		thing = f159_getNextThing(thing);
+	}
+	return thing;
+}
+
+uint16 DungeonMan::f143_getArmourDefense(ArmourInfo* armourInfo, bool useSharpDefense) {
+	uint16 L0244_ui_Defense;
+
+	L0244_ui_Defense = armourInfo->_defense;
+	if (useSharpDefense) {
+		L0244_ui_Defense = _vm->f30_getScaledProduct(L0244_ui_Defense, 3, getFlag(armourInfo->_attributes, k0x0007_ArmourAttributeSharpDefense) + 4);
+	}
+	return L0244_ui_Defense;
+}
+
+Thing DungeonMan::f165_getDiscardTHing(uint16 thingType) {
+	uint16 L0276_ui_MapX;
+	uint16 L0277_ui_MapY;
+	Thing L0278_T_Thing;
+	uint16 L0279_ui_MapIndex;
+	byte* L0280_puc_Square;
+	Thing* L0281_pT_SquareFirstThing;
+	Thing* L0282_ps_Generic;
+	uint16 L0283_ui_DiscardThingMapIndex;
+	int L0284_i_CurrentMapIndex;
+	uint16 L0285_ui_MapWidth;
+	uint16 L0286_ui_MapHeight;
+	int L0287_i_ThingType;
+	static unsigned char G0294_auc_LastDiscardedThingMapIndex[16];
+
+
+	if (thingType == k15_ExplosionThingType) {
+		return Thing::_none;
+	}
+	L0284_i_CurrentMapIndex = _vm->_dungeonMan->_g272_currMapIndex;
+	if (((L0279_ui_MapIndex = G0294_auc_LastDiscardedThingMapIndex[thingType]) == _vm->_dungeonMan->_g309_partyMapIndex) && (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount)) {
+		L0279_ui_MapIndex = 0;
+	}
+	L0283_ui_DiscardThingMapIndex = L0279_ui_MapIndex;
+	for (;;) { /*_Infinite loop_*/
+		L0285_ui_MapWidth = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._width;
+		L0286_ui_MapHeight = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._height;
+		L0280_puc_Square = _vm->_dungeonMan->_g279_dungeonMapData[L0279_ui_MapIndex][0];
+		L0281_pT_SquareFirstThing = &_vm->_dungeonMan->_g283_squareFirstThings[_vm->_dungeonMan->_g280_dungeonColumnsCumulativeSquareThingCount[_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[L0279_ui_MapIndex]]];
+		for (L0276_ui_MapX = 0; L0276_ui_MapX <= L0285_ui_MapWidth; L0276_ui_MapX++) {
+			for (L0277_ui_MapY = 0; L0277_ui_MapY <= L0286_ui_MapHeight; L0277_ui_MapY++) {
+				if (getFlag(*L0280_puc_Square++, k0x0010_ThingListPresent)) {
+					L0278_T_Thing = *L0281_pT_SquareFirstThing++;
+					if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && ((L0276_ui_MapX - _vm->_dungeonMan->_g306_partyMapX + 5) <= 10) && ((L0277_ui_MapY - _vm->_dungeonMan->_g307_partyMapY + 5) <= 10)) /* If square is too close to the party */
+						goto T0165029;
+					do {
+						if ((L0287_i_ThingType = (L0278_T_Thing).getType()) == k3_SensorThingType) {
+							L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing);
+							if (((Sensor*)L0282_ps_Generic)->getType()) /* If sensor is not disabled */
+								break;
+						} else {
+							if (L0287_i_ThingType == thingType) {
+								L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing);
+								switch (thingType) {
+								case k4_GroupThingType:
+									if (((Group*)L0282_ps_Generic)->getDoNotDiscard())
+										continue;
+								case k14_ProjectileThingType:
+									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
+									if (thingType == k4_GroupThingType) {
+										_vm->_groupMan->f188_dropGroupPossessions(L0276_ui_MapX, L0277_ui_MapY, L0278_T_Thing, kM1_soundModeDoNotPlaySound);
+										_vm->_groupMan->f189_delete(L0276_ui_MapX, L0277_ui_MapY);
+									} else {
+										_vm->_projexpl->f214_projectileDeleteEvent(L0278_T_Thing);
+										f164_unlinkThingFromList(L0278_T_Thing, Thing(0), L0276_ui_MapX, L0277_ui_MapY);
+										_vm->_projexpl->f215_projectileDelete(L0278_T_Thing, 0, L0276_ui_MapX, L0277_ui_MapY);
+									}
+									break;
+								case k6_ArmourThingType:
+									if (((Armour*)L0282_ps_Generic)->getDoNotDiscard())
+										continue;
+									goto T0165026;
+								case k5_WeaponThingType:
+									if (((Weapon*)L0282_ps_Generic)->getDoNotDiscard())
+										continue;
+									goto T0165026;
+								case k10_JunkThingType:
+									if (((Junk*)L0282_ps_Generic)->getDoNotDiscard())
+										continue;
+									goto T0165026;
+								case k8_PotionThingType:
+									if (((Potion*)L0282_ps_Generic)->getDoNotDiscard())
+										continue;
+T0165026:
+									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
+									_vm->_movsens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0);
+								}
+								_vm->_dungeonMan->f173_setCurrentMap(L0284_i_CurrentMapIndex);
+								G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex;
+								return Thing((L0278_T_Thing).getTypeAndIndex());
+							}
+						}
+					} while ((L0278_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0278_T_Thing)) != Thing::_endOfList);
+T0165029:
+					;
+				}
+			}
+		}
+		if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) || (_vm->_dungeonMan->_g278_dungeonFileHeader._mapCount <= 1)) {
+			G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex;
+			return Thing::_none;
+		}
+		do {
+			if (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount) {
+				L0279_ui_MapIndex = 0;
+			}
+		} while (L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex);
+		if (L0279_ui_MapIndex == L0283_ui_DiscardThingMapIndex) {
+			L0279_ui_MapIndex = _vm->_dungeonMan->_g309_partyMapIndex;
+		}
+	}
+}
+
+uint16 DungeonMan::f144_getCreatureAttributes(Thing thing) {
+	Group* L0245_ps_Group;
+
+	L0245_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing);
+	return g243_CreatureInfo[L0245_ps_Group->_type]._attributes;
+}
+
+void DungeonMan::f146_setGroupCells(Group* group, uint16 cells, uint16 mapIndex) {
+	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) {
+		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._cells = cells;
+	} else {
+		group->_cells = cells;
+	}
+}
+
+void DungeonMan::f148_setGroupDirections(Group* group, int16 dir, uint16 mapIndex) {
+	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) {
+		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (direction)dir;
+	} else {
+		group->setDir(M21_normalizeModulo4(dir));
+	}
+}
+
+bool DungeonMan::f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) {
+	int16 L0234_i_Counter;
+	int16 L0235_i_CreatureType;
+	byte* L0236_puc_Multiple;
+#define AL0236_puc_Group               L0236_puc_Multiple
+#define AL0236_puc_AllowedCreatureType L0236_puc_Multiple
+	Map* L0237_ps_Map;
+
+	L0235_i_CreatureType = ((Group*)_vm->_dungeonMan->f156_getThingData(thing))->_type;
+	L0237_ps_Map = &_vm->_dungeonMan->_g277_dungeonMaps[mapIndex];
+	AL0236_puc_AllowedCreatureType = _vm->_dungeonMan->_g279_dungeonMapData[mapIndex][L0237_ps_Map->_width] + L0237_ps_Map->_height + 1;
+	for (L0234_i_Counter = L0237_ps_Map->_creatureTypeCount; L0234_i_Counter > 0; L0234_i_Counter--) {
+		if (*AL0236_puc_AllowedCreatureType++ == L0235_i_CreatureType) {
+			return true;
+		}
+	}
+	return false;
+}
+
+void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY) {
+	uint16 L0271_ui_SquareFirstThingIndex;
+	uint16 L0272_ui_Multiple;
+#define AL0272_ui_SquareFirstThingIndex L0272_ui_Multiple
+#define AL0272_ui_Column                L0272_ui_Multiple
+	Thing L0273_T_Thing;
+	Thing* L0274_ps_Generic = nullptr;
+	Thing* L0275_pui_Multiple = nullptr;
+#define AL0275_pT_Thing                      L0275_pui_Multiple
+#define AL0275_pui_CumulativeFirstThingCount L0275_pui_Multiple
+
+
+	if (thingToUnlink == Thing::_endOfList) {
+		return;
+	}
+
+	{
+		uint16 tmp = thingToUnlink.toUint16();
+		clearFlag(tmp, 0xC000);
+		thingToUnlink = Thing(tmp);
+	}
+
+	if (mapX >= 0) {
+		L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink);
+		AL0275_pT_Thing = &_vm->_dungeonMan->_g283_squareFirstThings[L0271_ui_SquareFirstThingIndex = _vm->_dungeonMan->f160_getSquareFirstThingIndex(mapX, mapY)]; /* BUG0_01 Coding error without consequence. The engine does not check that there are things at the specified square coordinates. _vm->_dungeonMan->f160_getSquareFirstThingIndex would return -1 for an empty square. No consequence as the function is never called with the coordinates of an empty square (except in the case of BUG0_59) */
+		if ((*L0274_ps_Generic == Thing::_endOfList) && (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16())) { /* If the thing to unlink is the last thing on the square */
+			clearFlag(_vm->_dungeonMan->_g271_currMapData[mapX][mapY], k0x0010_ThingListPresent);
+			AL0272_ui_SquareFirstThingIndex = _vm->_dungeonMan->_g278_dungeonFileHeader._squareFirstThingCount - 1;
+			for (uint16 i = 0; i < AL0272_ui_SquareFirstThingIndex - L0271_ui_SquareFirstThingIndex; ++i)
+				AL0275_pT_Thing[i] = AL0275_pT_Thing[i + 1];
+
+			_vm->_dungeonMan->_g283_squareFirstThings[AL0272_ui_SquareFirstThingIndex] = Thing::_none;
+			AL0275_pui_CumulativeFirstThingCount = (Thing*)_vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount + mapX + 1;
+			AL0272_ui_Column = _vm->_dungeonMan->_g282_dungeonColumCount - (_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[_vm->_dungeonMan->_g272_currMapIndex] + mapX) - 1;
+			while (AL0272_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is unlinked */
+				(*(uint16*)AL0275_pui_CumulativeFirstThingCount++)--; /* Decrement the cumulative first thing count */
+			}
+			goto T0164011;
+		}
+		if (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16()) {
+			*AL0275_pT_Thing = *L0274_ps_Generic;
+			goto T0164011;
+		}
+		thingInList = *AL0275_pT_Thing;
+	}
+	L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList);
+	while (L0273_T_Thing.getTypeAndIndex() != thingToUnlink.toUint16()) {
+		if ((L0273_T_Thing == Thing::_endOfList) || (L0273_T_Thing == Thing::_none)) {
+			goto T0164011;
+		}
+		L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList = L0273_T_Thing);
+	}
+	L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingInList);
+	*L0274_ps_Generic = _vm->_dungeonMan->f159_getNextThing(L0273_T_Thing);
+	L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink);
+T0164011:
+	*L0274_ps_Generic = Thing::_endOfList;
+}
+
+int16 DungeonMan::f155_getStairsExitDirection(int16 mapX, int16 mapY) {
+	int16 L0256_i_SquareType;
+	bool L0257_B_NorthSouthOrientedStairs;
+
+
+	if (L0257_B_NorthSouthOrientedStairs = !getFlag(_vm->_dungeonMan->f151_getSquare(mapX, mapY).toByte(), k0x0008_StairsNorthSouthOrient)) {
+		mapX = mapX + _vm->_dirIntoStepCountEast[kDirEast];
+		mapY = mapY + _vm->_dirIntoStepCountNorth[kDirEast];
+	} else {
+		mapX = mapX + _vm->_dirIntoStepCountEast[kDirNorth];
+		mapY = mapY + _vm->_dirIntoStepCountNorth[kDirNorth];
+	}
+	return ((((L0256_i_SquareType = Square(_vm->_dungeonMan->f151_getSquare(mapX, mapY)).getType()) == k0_ElementTypeWall) || (L0256_i_SquareType == k3_ElementTypeStairs)) << 1) + L0257_B_NorthSouthOrientedStairs;
+
+}
+
+Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {
+	int16 L0293_i_Type;
+	int16 L0294_i_ThingType;
+	Thing L0295_T_Thing;
+	Junk* L0296_ps_Junk;
+
+
+	L0294_i_ThingType = k5_WeaponThingType;
+	if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit)) {
+		iconIndex = k4_IconIndiceWeaponTorchUnlit;
+	}
+	switch (iconIndex) {
+	case k54_IconIndiceWeaponRock:
+		L0293_i_Type = k30_WeaponTypeRock;
+		break;
+	case k128_IconIndiceJunkBoulder:
+		L0293_i_Type = k25_JunkTypeBoulder;
+		L0294_i_ThingType = k10_JunkThingType;
+		break;
+	case k51_IconIndiceWeaponArrow:
+		L0293_i_Type = k27_WeaponTypeArrow;
+		break;
+	case k52_IconIndiceWeaponSlayer:
+		L0293_i_Type = k28_WeaponTypeSlayer;
+		break;
+	case k55_IconIndiceWeaponPoisonDart:
+		L0293_i_Type = k31_WeaponTypePoisonDart;
+		break;
+	case k56_IconIndiceWeaponThrowingStar:
+		L0293_i_Type = k32_WeaponTypeThrowingStar;
+		break;
+	case k32_IconIndiceWeaponDagger:
+		L0293_i_Type = k8_WeaponTypeDagger;
+		break;
+	case k4_IconIndiceWeaponTorchUnlit:
+		L0293_i_Type = k2_WeaponTypeTorch;
+		break;
+	default:
+		return Thing::_none;
+	}
+	if ((L0295_T_Thing = f166_getUnusedThing(L0294_i_ThingType)) == Thing::_none) {
+		return Thing::_none;
+	}
+	L0296_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0295_T_Thing);
+	L0296_ps_Junk->setType(L0293_i_Type); /* Also works for WEAPON in cases other than Boulder */
+	if ((iconIndex == k4_IconIndiceWeaponTorchUnlit) && ((Weapon*)L0296_ps_Junk)->isLit()) { /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */
+		((Weapon*)L0296_ps_Junk)->setChargeCount(15);
+	}
+	return L0295_T_Thing;
+}
 }
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index a32edcf..c591881 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -107,9 +107,7 @@ class ArmourInfo {
 public:
 	uint16 _weight;
 	uint16 _defense;
-private:
 	uint16 _attributes;
-public:
 	ArmourInfo(uint16 weight, uint16 defense, uint16 attributes)
 		:_weight(weight), _defense(defense), _attributes(attributes) {}
 
@@ -178,8 +176,9 @@ enum SquareAspectIndice {
 };
 
 
-               
 
+#define k15_immuneToFire 15 // @ C15_IMMUNE_TO_FIRE   
+#define k15_immuneToPoison 15 // @ C15_IMMUNE_TO_POISON 
 
 class CreatureInfo {
 public:
@@ -200,6 +199,17 @@ public:
 	uint16 _animationTicks; /* Bits 15-12 Unreferenced */
 	uint16 _woundProbabilities; /* Contains 4 probabilities to wound a champion's Head (Bits 15-12), Legs (Bits 11-8), Torso (Bits 7-4) and Feet (Bits 3-0) */
 	byte _attackType;
+
+	uint16 M57_getFearResistance() { return (_properties >> 4) & 0xF; }
+	uint16 M58_getExperience() { return (_properties >> 8) & 0xF; }
+	uint16 M59_getWariness() { return (_properties >> 12) & 0xF; }
+	uint16 M60_getFireResistance() { return (_resistances >> 4) & 0xF; }
+	uint16 M61_poisonResistance() { return (_resistances >> 8) & 0xF; }
+	uint16 M51_height() { return (_attributes >> 7) & 0x3; }
+
+	uint16 M54_getSightRange() { return (_ranges) & 0xF; }
+	uint16 M55_getSmellRange() { return  (_ranges >> 8) & 0xF; }
+	uint16 M56_getAttackRange() { return (_ranges >> 12) & 0xF; }
 }; // @ CREATURE_INFO
 
 
@@ -232,13 +242,13 @@ class Teleporter {
 public:
 	explicit Teleporter(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]), _destMapIndex(rawDat[2]) {}
 	Thing getNextThing() { return _nextThing; }
-	bool makesSound() { return (_attributes >> 15) & 1; }
+	bool isAudible() { return (_attributes >> 15) & 1; }
 	TeleporterScope getScope() { return (TeleporterScope)((_attributes >> 13) & 1); }
-	bool absRotation() { return (_attributes >> 12) & 1; }
-	direction getRotationDir() { return (direction)((_attributes >> 10) & 1); }
-	byte getDestY() { return (_attributes >> 5) & 0xF; }
-	byte getDestX() { return _attributes & 0xF; }
-	uint16 getDestMapIndex() { return _destMapIndex >> 8; }
+	bool getAbsoluteRotation() { return (_attributes >> 12) & 1; }
+	direction getRotation() { return (direction)((_attributes >> 10) & 1); }
+	byte getTargetMapY() { return (_attributes >> 5) & 0xF; }
+	byte getTargetMapX() { return _attributes & 0xF; }
+	uint16 getTargetMapIndex() { return _destMapIndex >> 8; }
 }; // @ TELEPORTER
 
 
@@ -311,26 +321,30 @@ public:
 	uint16 getDataMask2() { return (_datAndType >> 11) & 0xF; } // @ M43_MASK2
 	void setData(int16 dat) { _datAndType = (_datAndType & 0x7F) | (dat << 7); } // @ M41_SET_DATA
 	void setTypeDisabled() { _datAndType &= 0xFF80; } // @ M44_SET_TYPE_DISABLED
-	uint16 getOrnOrdinal() { return _attributes >> 12; }
-	bool isLocalAction() { return (_attributes >> 11) & 1; }
-	uint16 getDelay() { return (_attributes >> 7) & 0xF; }
-	bool hasSound() { return (_attributes >> 6) & 1; }
-	bool shouldRevert() { return (_attributes >> 5) & 1; }
-	SensorActionType getActionType() { return (SensorActionType)((_attributes >> 3) & 3); }
-	bool isSingleUse() { return (_attributes >> 2) & 1; }
-	uint16 getRemoteMapY() { return (_action >> 11); }
-	uint16 getRemoteMapX() { return (_action >> 6) & 0x1F; }
-	direction getRemoteDir() { return (direction)((_action >> 4) & 3); }
-	uint16 getLocalAction() { return (_action >> 4); }
+
+
+
+	bool getOnlyOnce() { return (_attributes >> 2) & 1; }
 	uint16 getEffectA() { return (_attributes >> 3) & 0x3; }
 	bool getRevertEffectA() { return (_attributes >> 5) & 0x1; }
 	bool getAudibleA() { return (_attributes >> 6) & 0x1; }
+	uint16 getValue() { return (_attributes >> 7) & 0xF; }
+	bool getLocalEffect() { return (_attributes >> 11) & 1; }
+	uint16 getOrnOrdinal() { return _attributes >> 12; }
+
+	uint16 getTargetMapY() { return (_action >> 11); }
+	uint16 getTargetMapX() { return (_action >> 6) & 0x1F; }
+	direction getTargetCell() { return (direction)((_action >> 4) & 3); }
+	uint16 M49_localEffect() { return (_action >> 4); }
 
 
 	// some macros missing, i got bored
 }; // @ SENSOR
 
 
+#define k0x8000_randomDrop 0x8000 // @ MASK0x8000_RANDOM_DROP 
+
+
 enum WeaponType {
 	k2_WeaponTypeTorch = 2, // @ C02_WEAPON_TORCH
 	k8_WeaponTypeDagger = 8, // @ C08_WEAPON_DAGGER
@@ -351,6 +365,7 @@ public:
 	explicit Weapon(uint16 *rawDat) : _nextThing(rawDat[0]), _desc(rawDat[1]) {}
 
 	WeaponType getType() { return (WeaponType)(_desc & 0x7F); }
+	void setType(uint16 val) { _desc = (_desc & ~0x7F) | (val & 0x7F); }
 	bool isLit() { return (_desc >> 15) & 1; }
 	void setLit(bool val) {
 		if (val)
@@ -359,10 +374,13 @@ public:
 			_desc &= (~(1 << 15));
 	}
 	uint16 getChargeCount() { return (_desc >> 10) & 0xF; }
+	void setChargeCount(uint16 val) { _desc = (_desc & ~(0xF << 10)) | ((val & 0xF) << 10); }
 	Thing getNextThing() { return _nextThing; }
 	uint16 getCursed() { return (_desc >> 8) & 1; }
+	void setCursed(uint16 val) { _desc = (_desc & ~(1 << 8)) | ((val & 1) << 8); }
 	uint16 getPoisoned() { return (_desc >> 9) & 1; }
 	uint16 getBroken() { return (_desc >> 14) & 1; }
+	uint16 getDoNotDiscard() { return (_desc >> 7) & 1; }
 }; // @ WEAPON
 
 enum ArmourType {
@@ -382,6 +400,7 @@ public:
 	Thing getNextThing() { return _nextThing; }
 	uint16 getCursed() { return (_attributes >> 8) & 1; }
 	uint16 getBroken() { return (_attributes >> 13) & 1; }
+	uint16 getDoNotDiscard() { return (_attributes >> 7) & 1; }
 }; // @ ARMOUR
 
 class Scroll {
@@ -420,15 +439,16 @@ enum PotionType {
 	k20_PotionTypeEmptyFlask = 20 // @ C20_POTION_EMPTY_FLASK,
 };
 class Potion {
+public:
 	Thing _nextThing;
 	uint16 _attributes;
-public:
 	explicit Potion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 
 	PotionType getType() { return (PotionType)((_attributes >> 8) & 0x7F); }
 	void setType(PotionType val) { _attributes = (_attributes & ~(0x7F << 8)) | ((val & 0x7F) << 8); }
 	Thing getNextThing() { return _nextThing; }
 	uint16 getPower() { return _attributes & 0xFF; }
+	uint16 getDoNotDiscard() { return (_attributes >> 15) & 1; }
 }; // @ POTION
 
 class Container {
@@ -463,23 +483,29 @@ public:
 	explicit Junk(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 
 	JunkType getType() { return (JunkType)(_attributes & 0x7F); }
+	void setType(uint16 val) { _attributes = (_attributes & ~0x7F) | (val & 0x7F); }
 	uint16 getChargeCount() { return (_attributes >> 14) & 0x3; }
 	void setChargeCount(uint16 val) { _attributes = (_attributes & ~(0x3 << 14)) | ((val & 0x3) << 14); }
+	uint16 getDoNotDiscard() { return (_attributes >> 7) & 1; }
 
 	Thing getNextThing() { return _nextThing; }
 }; // @ JUNK
 
+#define kM1_soundModeDoNotPlaySound -1 // @ CM1_MODE_DO_NOT_PLAY_SOUND  
+#define k0_soundModePlayImmediately 0 // @ C00_MODE_PLAY_IMMEDIATELY    
+#define k1_soundModePlayIfPrioritized 1 // @ C01_MODE_PLAY_IF_PRIORITIZED 
+#define k2_soundModePlayOneTickLater 2 // @ C02_MODE_PLAY_ONE_TICK_LATER 
+
 class Projectile {
 public:
 	Thing _nextThing;
-	Thing _object;
-	byte _kineticEnergy;
-	byte _damageEnergy;
-	uint16 _timerIndex;
-	explicit Projectile(uint16 *rawDat) : _nextThing(rawDat[0]), _object(rawDat[1]), _kineticEnergy(rawDat[2]),
-		_damageEnergy(rawDat[3]), _timerIndex(rawDat[4]) {}
+	Thing _slot;
+	uint16 _kineticEnergy;
+	uint16 _attack;
+	uint16 _eventIndex;
+	explicit Projectile(uint16 *rawDat) : _nextThing(rawDat[0]), _slot(rawDat[1]), _kineticEnergy(rawDat[2]),
+		_attack(rawDat[3]), _eventIndex(rawDat[4]) {}
 
-	Thing getNextThing() { return _nextThing; }
 }; // @ PROJECTILE
 
 #define k0_ExplosionType_Fireball 0 // @ C000_EXPLOSION_FIREBALL           
@@ -502,8 +528,11 @@ public:
 
 	Thing getNextThing() { return _nextThing; }
 	uint16 getType() { return _attributes & 0x7F; }
+	uint16 setType(uint16 val) { _attributes = (_attributes & ~0x7F) | (val & 0x7F); return (val & 0x7F); }
 	uint16 getAttack() { return (_attributes >> 8) & 0xFF; }
-	uint16 getCentered() { return (_attributes >> 7) & 0x1;  }
+	void setAttack(uint16 val) { _attributes = (_attributes & ~(0xFF << 8)) | ((val & 0xFF) << 8); }
+	uint16 getCentered() { return (_attributes >> 7) & 0x1; }
+	void setCentered(uint16 val) { _attributes = (_attributes & ~(1 << 7)) | ((val & 1) << 7); }
 }; // @ EXPLOSION
 
 
@@ -544,6 +573,9 @@ enum SquareType {
 	k19_StairsFrontElemType = 19 // @ C19_ELEMENT_STAIRS_FRONT 
 }; // @ C[-2..19]_ELEMENT_...
 
+#define k0x8000_championBones 0x8000 // @ MASK0x8000_CHAMPION_BONES 
+#define k0x7FFF_thingType 0x7FFF // @ MASK0x7FFF_THING_TYPE     
+
 class Square {
 	byte _data;
 public:
@@ -598,10 +630,11 @@ class DoorInfo {
 public:
 	byte _attributes;
 	byte _defense;
-	DoorInfo(byte b1, byte b2): _attributes(b1), _defense(b2){}
+	DoorInfo(byte b1, byte b2) : _attributes(b1), _defense(b2) {}
 	DoorInfo() {}
 }; // @ DOOR_INFO
 
+class Group;
 
 class DungeonMan {
 	DMEngine *_vm;
@@ -618,14 +651,14 @@ class DungeonMan {
 
 	int16 f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal
 	void f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
-									int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals
+										 int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals
 
-	void f173_setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
 
 public:
 	explicit DungeonMan(DMEngine *dmEngine);
 	~DungeonMan();
 
+	void f173_setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
 	Thing f161_getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing
 	Thing f159_getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing)
 	uint16 *f156_getThingData(Thing thing); // @ F0156_DUNGEON_GetThingData
@@ -642,6 +675,8 @@ public:
 	} // @ F0153_DUNGEON_GetRelativeSquareType
 	void f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect
 	void f168_decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText
+	Thing f166_getUnusedThing(uint16 thingType); // @ F0166_DUNGEON_GetUnusedThing
+
 
 	uint16 f140_getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight
 	int16 f141_getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex
@@ -649,6 +684,17 @@ public:
 	WeaponInfo *f158_getWeaponInfo(Thing thing); // @ F0158_DUNGEON_GetWeaponInfo
 	int16 f142_getProjectileAspect(Thing thing); // @ F0142_DUNGEON_GetProjectileAspect
 	int16 f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16 *mapX, int16 *mapY); // @ F0154_DUNGEON_GetLocationAfterLevelChange
+	Thing f162_getSquareFirstObject(int16 mapX, int16 mapY); // @ F0162_DUNGEON_GetSquareFirstObject
+	uint16 f143_getArmourDefense(ArmourInfo *armourInfo, bool useSharpDefense); // @ F0143_DUNGEON_GetArmourDefense
+	Thing f165_getDiscardTHing(uint16 thingType); // @ F0165_DUNGEON_GetDiscardedThing
+	uint16 f144_getCreatureAttributes(Thing thing); // @ F0144_DUNGEON_GetCreatureAttributes
+	void f146_setGroupCells(Group *group, uint16 cells, uint16 mapIndex); // @ F0146_DUNGEON_SetGroupCells
+	void f148_setGroupDirections(Group *group, int16 dir, uint16 mapIndex); // @ F0148_DUNGEON_SetGroupDirections
+	bool f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex); // @ F0139_DUNGEON_IsCreatureAllowedOnMap
+	void f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY); // @ F0164_DUNGEON_UnlinkThingFromList
+	int16 f155_getStairsExitDirection(int16 mapX, int16 mapY); // @ F0155_DUNGEON_GetStairsExitDirection
+	Thing f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex); // @ F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator
+
 
 	uint32 _rawDunFileDataSize;	 // @ probably NONE
 	byte *_rawDunFileData; // @ ???
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 490449d..0104883 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -34,12 +34,53 @@
 #include "objectman.h"
 #include "inventory.h"
 #include "menus.h"
-
-
+#include "timeline.h"
+#include "projexpl.h"
+#include "text.h"
+#include "group.h"
 
 
 namespace DM {
 
+byte g42_bitmapArrowPointer[576] = { // @ G0042_auc_Graphic562_Bitmap_ArrowPointer
+	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x7, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x7, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x6, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x8, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x3, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xA, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0xC, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x0, 0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
+byte g43_bitmapHanPointer[576] = { // @ G0043_auc_Graphic562_Bitmap_HandPointer
+	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x3, 0x5, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xA, 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xD, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE, 0xA, 0x8, 0x0, 0x0, 0x0, 0x0,
+	0x0, 0x7, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0xC, 0x7, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x6, 0x7, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x7, 0x7, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0,
+	0x3, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x3, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x1, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0,
+	0x0, 0x1, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0xA, 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x5, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x1, 0x2, 0xA, 0x8, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x5, 0x4, 0x0, 0x0, 0x0, 0x0, 0xC, 0x8, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x2, 0x8, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0,
+	0x9, 0x8, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x8, 0x8, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0,
+	0x2, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+	0x7, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xF, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0x1, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0,
+	0xC, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0xE, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0,
+	0x7, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x3, 0xF, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x1, 0xF, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0,
+	0x0, 0x7, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
+
 Box g462_BoxObjectPiles[4] = { // @ G0462_as_Graphic561_Box_ObjectPiles
 	/* { X1, X2, Y1, Y2 } */
 	Box(24, 111, 148, 168),   /* Front left */
@@ -260,44 +301,179 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 
 	_dummyMapIndex = 0;
 	_g439_pendingClickButton = k0_NoneMouseButton;
+	_g615_mousePointerOriginalColorsObject = nullptr;
+	_g613_mousePointerOriginalColorsChampionIcon = nullptr;
+	_gK190_mousePointerTempBuffer = nullptr;
 }
 
+EventManager::~EventManager() {
+	delete[] _g615_mousePointerOriginalColorsObject;
+	delete[] _gK190_mousePointerTempBuffer;
+	delete[] _g613_mousePointerOriginalColorsChampionIcon;
+}
 
-// dummy data
-static const byte mouseData[] = {
-	1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
-	1, 7, 1, 0, 0, 0, 0, 0, 0, 0,
-	1, 7, 7, 1, 0, 0, 0, 0, 0, 0,
-	1, 7, 7, 7, 1, 0, 0, 0, 0, 0,
-	1, 7, 7, 7, 7, 1, 0, 0, 0, 0,
-	1, 7, 7, 7, 7, 7, 1, 0, 0, 0,
-	1, 7, 7, 7, 7, 7, 7, 1, 0, 0,
-	1, 7, 7, 7, 7, 7, 7, 7, 1, 0,
-	1, 7, 7, 7, 7, 7, 1, 1, 1, 1,
-	1, 7, 7, 1, 7, 7, 1, 0, 0, 0,
-	1, 7, 1, 0, 1, 7, 7, 1, 0, 0,
-	1, 1, 0, 0, 1, 7, 7, 1, 0, 0,
-	0, 0, 0, 0, 0, 1, 7, 7, 1, 0,
-	0, 0, 0, 0, 0, 1, 7, 7, 1, 0,
-	0, 0, 0, 0, 0, 0, 1, 1, 0, 0
-};
-#define MOUSE_WIDTH 10
-#define MOUSE_HEIGHT 15
+void EventManager::initMouse() {
+	if (!_g615_mousePointerOriginalColorsObject)
+		_g615_mousePointerOriginalColorsObject = new byte[32 * 18];
+	if (!_gK190_mousePointerTempBuffer)
+		_gK190_mousePointerTempBuffer = new byte[32 * 18];
+	if (!_g613_mousePointerOriginalColorsChampionIcon)
+		_g613_mousePointerOriginalColorsChampionIcon = new byte[32 * 18];
 
+	_gK104_mousePointerType = k0_pointerArrow;
+	_gK105_previousMousePointerType = k1_pointerHand;
 
-void EventManager::initMouse() {
 	_mousePos = Common::Point(0, 0);
-	CursorMan.pushCursor(mouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
+	CursorMan.pushCursor(g42_bitmapArrowPointer, 32, 18, 0, 0, 0);
 	CursorMan.showMouse(false);
 
+
 	setMousePos(Common::Point(320 / 2, 200 / 2));
-	// TODO: add cursor creatin, set to hidden
 }
 
-void EventManager::showMouse(bool visibility) {
-	CursorMan.showMouse(visibility);
+void EventManager::f67_setMousePointerToNormal(int16 mousePointer) {
+	_gK100_preventBuildPointerScreenArea = true;
+	_g600_useObjectAsMousePointerBitmap = false;
+	_g601_useHandAsMousePointerBitmap = (mousePointer == k1_pointerHand);
+	_g598_mousePointerBitmapUpdated = true;
+	_gK100_preventBuildPointerScreenArea = false;
+	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
+}
+
+void EventManager::f68_setPointerToObject(byte* bitmap) {
+	static byte gK27_palChangesMousepointerOjbectIconShadow[16] = {120, 120, 120, 120, 120, 120, 120, 120,
+		120, 120, 120, 120, 0, 120, 120, 120}; // @ K0027_auc_PaletteChanges_MousePointerObjectIconShadow
+	static byte g44_palChangesMousePointerIcon[16] = {120, 10, 20, 30, 40, 50, 60, 70, 80, 90,
+		100, 110, 0, 130, 140, 150}; // @ G0044_auc_Graphic562_PaletteChanges_MousePointerIcon
+	static Box g619_BoxMousePointerObjectShadow(2, 17, 2, 17); // @ G0619_s_Box_MousePointer_ObjectShadow 
+	static Box g620_BoxMousePointerObject(0, 15, 0, 15); // @ G0620_s_Box_MousePointer_Object 
+	byte* L0051_puc_Bitmap;
+
+	_gK100_preventBuildPointerScreenArea = true;
+	_g600_useObjectAsMousePointerBitmap = true;
+	_g601_useHandAsMousePointerBitmap = false;
+	_g598_mousePointerBitmapUpdated = true;
+	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
+	L0051_puc_Bitmap = _g615_mousePointerOriginalColorsObject;
+	memset(L0051_puc_Bitmap, 0, 32 * 18);
+	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, gK27_palChangesMousepointerOjbectIconShadow);
+	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, k255_ColorNoTransparency, 16, 18);
+	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, g44_palChangesMousePointerIcon);
+	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
+	_gK100_preventBuildPointerScreenArea = false;
+	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
+}
+
+void EventManager::f71_mouseDropChampionIcon() {
+	bool L0057_B_UseByteBoxCoordinatesBackup;
+	uint16 L0058_ui_ChampionIconIndex;
+
+
+	_gK100_preventBuildPointerScreenArea = true;
+	L0058_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap);
+	_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+	_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
+	L0057_B_UseByteBoxCoordinatesBackup = _vm->_displayMan->_g578_useByteBoxCoordinates;
+	_vm->_displayMan->f21_blitToScreen(_g613_mousePointerOriginalColorsChampionIcon, &g54_BoxChampionIcons[L0058_ui_ChampionIconIndex << 2], 16, k12_ColorDarkestGray, 18);
+	_vm->_displayMan->_g578_useByteBoxCoordinates = L0057_B_UseByteBoxCoordinatesBackup;
+	_gK100_preventBuildPointerScreenArea = false;
+}
+
+void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY) {
+	uint16 L1577_i_ChampionIndex;
+	int16 L1578_i_XOverChampionStatusBox;
+
+
+	if (_gK100_preventBuildPointerScreenArea)
+		return;
+
+	_gK100_preventBuildPointerScreenArea = true;
+	if (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
+		if ((mousePosY > 28) || (mousePosX < 274)) {
+			_gK104_mousePointerType = k4_pointerTypeAutoselect;
+			f71_mouseDropChampionIcon();
+		} else {
+			_gK104_mousePointerType = k2_pointerTypeChampionIcon;
+		}
+	} else {
+		if (mousePosY >= 169) {
+			_gK104_mousePointerType = k0_pointerTypeArrow;
+		} else {
+			if (mousePosX >= 274) {
+				_gK104_mousePointerType = k0_pointerTypeArrow;
+			} else {
+				if (mousePosY <= 28) {
+					L1577_i_ChampionIndex = mousePosX / 69;
+					L1578_i_XOverChampionStatusBox = mousePosX % 69;
+					if (L1577_i_ChampionIndex >= _vm->_championMan->_g305_partyChampionCount) {
+						_gK104_mousePointerType = k4_pointerTypeAutoselect;
+					} else {
+						if (L1578_i_XOverChampionStatusBox > 42) {
+							_gK104_mousePointerType = k4_pointerTypeAutoselect;
+						} else {
+							L1577_i_ChampionIndex++;
+							if (L1577_i_ChampionIndex == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+								_gK104_mousePointerType = k0_pointerTypeArrow;
+							} else {
+								if (mousePosY <= 6) {
+									_gK104_mousePointerType = k0_pointerTypeArrow;
+								} else {
+									_gK104_mousePointerType = k4_pointerTypeAutoselect;
+								}
+							}
+						}
+					}
+				} else {
+					if (mousePosX >= 224) {
+						_gK104_mousePointerType = k0_pointerTypeArrow;
+					} else {
+						_gK104_mousePointerType = k4_pointerTypeAutoselect;
+					}
+				}
+			}
+		}
+	}
+	if (_gK104_mousePointerType == k4_pointerTypeAutoselect) {
+		_gK104_mousePointerType = (_g600_useObjectAsMousePointerBitmap) ? k1_pointerTypeObjectIcon : (_g601_useHandAsMousePointerBitmap) ? k3_pointerTypeHand : k0_pointerTypeArrow;
+	}
+	if (_vm->_eventMan->_g598_mousePointerBitmapUpdated || (_gK104_mousePointerType != _gK105_previousMousePointerType)) {
+		_vm->_eventMan->_g598_mousePointerBitmapUpdated = false;
+		switch (_gK104_mousePointerType) {
+		case k0_pointerTypeArrow:
+			CursorMan.pushCursor(g42_bitmapArrowPointer, 32, 18, 0, 0, 0);
+			break;
+		case k1_pointerTypeObjectIcon:
+			CursorMan.pushCursor(_g615_mousePointerOriginalColorsObject, 32, 18, 0, 0, 0);
+			break;
+		case k2_pointerTypeChampionIcon:
+			CursorMan.pushCursor(_g613_mousePointerOriginalColorsChampionIcon, 32, 18, 0, 0, 0);
+			break;
+		case k3_pointerTypeHand:
+			CursorMan.pushCursor(g43_bitmapHanPointer, 32, 18, 0, 0, 0);
+			break;
+		}
+	}
+	_gK105_previousMousePointerType = _gK104_mousePointerType;
+	_gK100_preventBuildPointerScreenArea = false;
+}
+
+void EventManager::f69_setMousePointer() {
+	if (_vm->_championMan->_g415_leaderEmptyHanded) {
+		f67_setMousePointerToNormal((_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
+	} else {
+		f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
+	}
+}
+
+void EventManager::f78_showMouse() {
+	CursorMan.showMouse(true);
+}
+
+void EventManager::f77_hideMouse() {
+	CursorMan.showMouse(false);
 }
 
+
 void EventManager::setMousePos(Common::Point pos) {
 	_vm->_system->warpMouse(pos.x, pos.y);
 }
@@ -473,6 +649,48 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	// MISSING CODE: Lots of code
 }
 
+bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int16 posX, int16 posY) {
+	bool L1149_B_ObjectThrown;
+
+
+#define k0_sideLeft 0 // @ C0_SIDE_LEFT 
+#define k1_sideRight 1 // @ C0_SIDE_LEFT 
+
+	if ((posY < 47) || (posY > 102)) {
+		return false;
+	}
+	if (posX <= 111) {
+		if (_vm->_dungeonMan->_g285_squareAheadElement == k17_DoorFrontElemType) {
+			if (posX < 64) {
+				return false;
+			}
+		} else {
+			if (posX < 32) {
+				return false;
+			}
+		}
+		// Strangerke: Only poresent in CSB2.1... But it fixes a bug so we keep it
+		L1149_B_ObjectThrown = _vm->_championMan->f329_isLeaderHandObjectThrown(k0_sideLeft);
+	} else {
+		if (_vm->_dungeonMan->_g285_squareAheadElement == k17_DoorFrontElemType) {
+			if (posX > 163) {
+				return false;
+			}
+		} else {
+			if (posX > 191) {
+				return false;
+			}
+		}
+		L1149_B_ObjectThrown = _vm->_championMan->f329_isLeaderHandObjectThrown(k1_sideRight);
+	}
+	if (L1149_B_ObjectThrown) {
+		_vm->_g321_stopWaitingForPlayerInput = true;
+	}
+	return L1149_B_ObjectThrown;
+}
+
+
+
 void EventManager::f368_commandSetLeader(ChampionIndex champIndex) {
 	ChampionMan &cm = *_vm->_championMan;
 	ChampionIndex leaderIndex;
@@ -513,79 +731,88 @@ void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() {
 }
 
 void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16 posY) {
-	DungeonMan &dunMan = *_vm->_dungeonMan;
-	ChampionMan &champMan = *_vm->_championMan;
-
-	if (dunMan._g285_squareAheadElement == k17_ElementTypeDoorFront) {
-		if (champMan._g411_leaderIndex == kM1_ChampionNone)
+	uint16 L1150_ui_ViewCell;
+	Junk* L1151_ps_Junk;
+	Thing L1152_T_Thing;
+	uint16 L1153_ui_IconIndex;
+	uint16 L1154_ui_Weight;
+	int16 L1155_i_MapX;
+	int16 L1156_i_MapY;
+
+	if (_vm->_dungeonMan->_g285_squareAheadElement == k17_DoorFrontElemType) {
+		if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) {
 			return;
-
-		if (champMan._g415_leaderEmptyHanded) {
-			int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
-			int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
-
-			if (Door(dunMan.f157_getSquareFirstThingData(mapX, mapY)).hasButton() &&
-				dunMan._g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
+		}
+		L1155_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
+		L1156_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+		L1155_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1156_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+		if (_vm->_championMan->_g415_leaderEmptyHanded) {
+			L1151_ps_Junk = (Junk*)_vm->_dungeonMan->f157_getSquareFirstThingData(L1155_i_MapX, L1156_i_MapY);
+			if ((((Door*)L1151_ps_Junk)->hasButton()) && _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
 				_vm->_g321_stopWaitingForPlayerInput = true;
 				warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
-				warning("MISSING CODE: F0268_SENSOR_AddEvent");
+				_vm->_movsens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1);
+				return;
+			}
+		} else {
+			if (f375_processType80_clickDungeonView_isLeaderHandObjThrown(posX, posY)) {
 				return;
 			}
-
-			warning("MISSING CODE: F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown in elseif condition");
 		}
 	}
-
-	if (champMan._g415_leaderEmptyHanded) {
-		for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k5_ViewCellDoorButtonOrWallOrn; viewCell++) {
-			if (dunMan._g291_dungeonViewClickableBoxes[viewCell].isPointInside(Common::Point(posX, posY - 33))) {
-				if (viewCell == k5_ViewCellDoorButtonOrWallOrn) {
-					if (!dunMan._g286_isFacingAlcove) {
+	if (_vm->_championMan->_g415_leaderEmptyHanded) {
+		for (L1150_ui_ViewCell = k0_ViewCellFronLeft; L1150_ui_ViewCell < k5_ViewCellDoorButtonOrWallOrn + 1; L1150_ui_ViewCell++) {
+			if (_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[L1150_ui_ViewCell].isPointInside(posX, posY - 33)) {
+				if (L1150_ui_ViewCell == k5_ViewCellDoorButtonOrWallOrn) {
+					if (!_vm->_dungeonMan->_g286_isFacingAlcove) {
 						f372_commandProcessType80ClickInDungeonViewTouchFrontWall();
 					}
 				} else {
-					warning("MISSING CODE: F0373_COMMAND_ProcessType80_ClickInDungeonView_GrabLeaderHandObject");
+					f373_processType80_clickInDungeonView_grabLeaderHandObject(L1150_ui_ViewCell);
 				}
 				return;
 			}
 		}
 	} else {
-		Thing thing = champMan._g414_leaderHandObject;
-		uint16 *rawThingPointer = dunMan.f156_getThingData(thing);
-		if (dunMan._g285_squareAheadElement == k0_ElementTypeWall) {
-			for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k1_ViewCellFrontRight; ++viewCell) {
-				if (g462_BoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) {
-					warning("F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject");
+		L1152_T_Thing = _vm->_championMan->_g414_leaderHandObject;
+		L1151_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1152_T_Thing);
+		if (_vm->_dungeonMan->_g285_squareAheadElement == k0_ElementTypeWall) {
+			for (L1150_ui_ViewCell = k0_ViewCellFronLeft; L1150_ui_ViewCell < k1_ViewCellFrontRight + 1; L1150_ui_ViewCell++) {
+				if (g462_BoxObjectPiles[L1150_ui_ViewCell].isPointInside(posX, posY)) {
+					f374_processType80_clickInDungeonViewDropLeaderHandObject(L1150_ui_ViewCell);
 					return;
 				}
 			}
-
-			if (dunMan._g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) {
-				if (dunMan._g286_isFacingAlcove) {
-					warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject");
+			if (_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
+				if (_vm->_dungeonMan->_g286_isFacingAlcove) {
+					f374_processType80_clickInDungeonViewDropLeaderHandObject(k4_ViewCellAlcove);
 				} else {
-					if (dunMan._g288_isFacingFountain) {
-						uint16 iconIndex = _vm->_objectMan->f33_getIconIndex(thing);
-						int16 weight = dunMan.f140_getObjectWeight(thing);
-						if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
-							((Junk*)rawThingPointer)->setChargeCount(3);
-						} else if (iconIndex == k195_IconIndicePotionEmptyFlask) {
-							((Potion*)rawThingPointer)->setType(k15_PotionTypeWaterFlask);
+					if (_vm->_dungeonMan->_g288_isFacingFountain) {
+						L1153_ui_IconIndex = _vm->_objectMan->f33_getIconIndex(L1152_T_Thing);
+						L1154_ui_Weight = _vm->_dungeonMan->f140_getObjectWeight(L1152_T_Thing);
+						if ((L1153_ui_IconIndex >= k8_IconIndiceJunkWater) && (L1153_ui_IconIndex <= k9_IconIndiceJunkWaterSkin)) {
+							L1151_ps_Junk->setChargeCount(3); /* Full */
 						} else {
-							goto T0377019;
+							if (L1153_ui_IconIndex == k195_IconIndicePotionEmptyFlask) {
+								((Potion*)L1151_ps_Junk)->setType(k15_PotionTypeWaterFlask);
+							} else {
+								goto T0377019;
+							}
 						}
-						champMan.f296_drawChangedObjectIcons();
-						champMan._gK71_champions[champMan._g411_leaderIndex]._load += dunMan.f140_getObjectWeight(thing) - weight;
+						_vm->_championMan->f296_drawChangedObjectIcons();
+						_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(L1152_T_Thing) - L1154_ui_Weight;
 					}
 T0377019:
 					f372_commandProcessType80ClickInDungeonViewTouchFrontWall();
 				}
 			}
 		} else {
-			warning("MISSING CODE: F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown in if branch");
-			for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k3_ViewCellBackLeft; viewCell++) {
-				if (g462_BoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) {
-					warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject");
+			if (f375_processType80_clickDungeonView_isLeaderHandObjThrown(posX, posY)) {
+				return;
+			}
+			for (L1150_ui_ViewCell = k0_ViewCellFronLeft; L1150_ui_ViewCell < k3_ViewCellBackLeft + 1; L1150_ui_ViewCell++) {
+				if (g462_BoxObjectPiles[L1150_ui_ViewCell].isPointInside(posX, posY)) {
+					f374_processType80_clickInDungeonViewDropLeaderHandObject(L1150_ui_ViewCell);
 					return;
 				}
 			}
@@ -616,8 +843,8 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 		dispMan._g578_useByteBoxCoordinates = false;
 		dispMan.D24_fillScreenBox(box, k0_ColorBlack);
 		dispMan.D24_fillScreenBox(g54_BoxChampionIcons[champMan.M26_championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2], k0_ColorBlack);
-		warning("F0457_START_DrawEnabledMenus_CPSF");
-		warning("F0078_MOUSE_ShowPointer");
+		_vm->_menuMan->f457_drawEnabledMenus();
+		_vm->_eventMan->f78_showMouse();
 		return;
 	}
 
@@ -628,7 +855,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
 		Thing thing = champ->getSlot((ChampionSlot)slotIndex);
 		if (thing != Thing::_none) {
-			warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList");
+			_vm->_dungeonMan->f164_unlinkThingFromList(thing, Thing(0), mapX, mapY);
 		}
 	}
 	Thing thing = dunMan.f161_getSquareFirstThing(mapX, mapY);
@@ -652,21 +879,21 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 	}
 
 	if (champMan._g305_partyChampionCount == 1) {
-		warning("MISSING CODE: setting time, G0362_l_LastPartyMovementTime , G0313_ul_GameTime");
+		_vm->_projexpl->_g362_lastPartyMovementTime = _vm->_g313_gameTime;
 		f368_commandSetLeader(k0_ChampionFirst);
 		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(k0_ChampionFirst);
 	} else {
 		_vm->_menuMan->f393_drawSpellAreaControls(champMan._g514_magicCasterChampionIndex);
 	}
 
-	warning("MISSING CODE: F0051_TEXT_MESSAGEAREA_PrintLineFeed");
-	Color champColor = g46_ChampionColor[championIndex]; // unreferenced because of missing code
-	warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage");
-	warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage");
+	_vm->_textMan->f51_messageAreaPrintLineFeed();
+	Color champColor = g46_ChampionColor[championIndex];
+	_vm->_textMan->f47_messageAreaPrintMessage(champColor, champ->_name);
+	_vm->_textMan->f47_messageAreaPrintMessage(champColor, (commandType == k160_CommandClickInPanelResurrect) ? " RESURRECTED." : " REINCARNATED."); // TODO: localization
 
 	invMan.f355_toggleInventory(k4_ChampionCloseInventory);
-	warning("MISSING CODE: F0457_START_DrawEnabledMenus_CPSF");
-	warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal");
+	_vm->_menuMan->f457_drawEnabledMenus();
+	_vm->_eventMan->f67_setMousePointerToNormal((_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
 }
 
 void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) {
@@ -694,6 +921,72 @@ void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) {
 	}
 }
 
+void EventManager::f373_processType80_clickInDungeonView_grabLeaderHandObject(uint16 viewCell) {
+	int16 L1137_i_MapX;
+	int16 L1138_i_MapY;
+	Thing L1139_T_Thing;
+
+
+	if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) {
+		return;
+	}
+	L1137_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
+	L1138_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+	if (viewCell >= k2_ViewCellBackRight) {
+		L1137_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1138_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+		if (((L1139_T_Thing = _vm->_groupMan->f175_groupGetThing(L1137_i_MapX, L1138_i_MapY)) != Thing::_endOfList) &&
+			!_vm->_movsens->f264_isLevitating(L1139_T_Thing) &&
+			_vm->_groupMan->f176_getCreatureOrdinalInCell((Group*)_vm->_dungeonMan->f156_getThingData(L1139_T_Thing), M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir))) {
+			return; /* It is not possible to grab an object on floor if there is a non levitating creature on its cell */
+		}
+	}
+	L1139_T_Thing = _vm->_dungeonMan->_g292_pileTopObject[viewCell];
+	if (_vm->_objectMan->f33_getIconIndex(L1139_T_Thing) != kM1_IconIndiceNone) {
+		_vm->_movsens->f267_getMoveResult(L1139_T_Thing, L1137_i_MapX, L1138_i_MapY, kM1_MapXNotOnASquare, 0);
+		_vm->_championMan->f297_putObjectInLeaderHand(L1139_T_Thing, true);
+	}
+	_vm->_g321_stopWaitingForPlayerInput = true;
+}
+
+void EventManager::f374_processType80_clickInDungeonViewDropLeaderHandObject(uint16 viewCell) {
+	int16 L1140_i_MapX;
+	int16 L1141_i_MapY;
+	Thing L1142_T_Thing;
+	Junk* L1143_ps_Junk;
+	int16 L1144_i_IconIndex;
+	uint16 L1145_ui_Cell;
+	bool L1146_B_DroppingIntoAnAlcove;
+	TimelineEvent L1147_s_Event;
+
+
+	if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) {
+		return;
+	}
+	L1140_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
+	L1141_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+	if (L1146_B_DroppingIntoAnAlcove = (viewCell == k4_ViewCellAlcove)) {
+		viewCell = k2_ViewCellBackRight;
+	}
+	if (viewCell > k1_ViewCellFrontRight) {
+		L1140_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1141_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+	}
+	L1145_ui_Cell = M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + viewCell);
+	L1142_T_Thing = _vm->_championMan->f298_getObjectRemovedFromLeaderHand();
+	_vm->_movsens->f267_getMoveResult(M15_thingWithNewCell(L1142_T_Thing, L1145_ui_Cell), kM1_MapXNotOnASquare, 0, L1140_i_MapX, L1141_i_MapY);
+	if (L1146_B_DroppingIntoAnAlcove && _vm->_dungeonMan->_g287_isFacingViAltar && ((L1144_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L1142_T_Thing)) == k147_IconIndiceJunkChampionBones)) {
+		L1143_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1142_T_Thing);
+		M33_setMapAndTime(L1147_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 1);
+		L1147_s_Event._type = k13_TMEventTypeViAltarRebirth;
+		L1147_s_Event._priority = L1143_ps_Junk->getChargeCount();
+		L1147_s_Event._B._location._mapX = L1140_i_MapX;
+		L1147_s_Event._B._location._mapY = L1141_i_MapY;
+		L1147_s_Event._C.A._cell = L1145_ui_Cell;
+		L1147_s_Event._C.A._effect = k2_SensorEffToggle;
+		_vm->_timeline->f238_addEventGetEventIndex(&L1147_s_Event);
+	}
+	_vm->_g321_stopWaitingForPlayerInput = true;
+}
+
 bool EventManager::f360_hasPendingClick(Common::Point& point, MouseButton button) {
 	if (_g439_pendingClickButton && button == _g439_pendingClickButton)
 		point = _g437_pendingClickPos;
@@ -701,4 +994,15 @@ bool EventManager::f360_hasPendingClick(Common::Point& point, MouseButton button
 	return _g436_pendingClickPresent;
 }
 
+void EventManager::f379_drawSleepScreen() {
+	_vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 224, 136); // TODO: localization
+}
+
+void EventManager::f357_discardAllInput() {
+	Common::Event event;
+	while (_vm->_system->getEventManager()->pollEvent(event))
+		;
+	_commandQueue.clear();
+}
+
 } // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index c156eed..d1ded67 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -211,6 +211,16 @@ public:
 
 class DMEngine;
 
+#define k0_pointerArrow 0 // @ C0_POINTER_ARROW 
+#define k1_pointerHand 1 // @ C1_POINTER_HAND  
+
+#define k0_pointerTypeArrow 0 // @ C0_POINTER_TYPE_ARROW         
+#define k1_pointerTypeObjectIcon 1 // @ C1_POINTER_TYPE_OBJECT_ICON   
+#define k2_pointerTypeChampionIcon 2 // @ C2_POINTER_TYPE_CHAMPION_ICON 
+#define k3_pointerTypeHand 3 // @ C3_POINTER_TYPE_HAND          
+#define k4_pointerTypeAutoselect 4 // @ C4_POINTER_TYPE_AUTOSELECT    
+
+
 class EventManager {
 	DMEngine *_vm;
 
@@ -220,6 +230,14 @@ class EventManager {
 	bool _g436_pendingClickPresent; // G0436_B_PendingClickPresent
 	Common::Point _g437_pendingClickPos; // @ G0437_i_PendingClickX, G0438_i_PendingClickY
 	MouseButton _g439_pendingClickButton; // @ G0439_i_PendingClickButtonsStatus
+	bool _g600_useObjectAsMousePointerBitmap; // @ G0600_B_UseObjectAsMousePointerBitmap
+	bool _g601_useHandAsMousePointerBitmap; // @ G0601_B_UseHandAsMousePointerBitmap
+	bool _gK100_preventBuildPointerScreenArea; // @ K0100_B_PreventBuildPointerScreenArea
+	byte *_g615_mousePointerOriginalColorsObject; // @ G0615_puc_Bitmap_MousePointerOriginalColorsObject
+	byte *_g613_mousePointerOriginalColorsChampionIcon; // @ G0613_puc_Bitmap_MousePointerOriginalColorsChampionIcon
+	byte *_gK190_mousePointerTempBuffer; // @ K0190_puc_Bitmap_MousePointerTemporaryBuffer
+	int16 _gK104_mousePointerType; // @ K0104_i_MousePointerType
+	int16 _gK105_previousMousePointerType; // @ K0105_i_PreviousMousePointerType
 
 // this doesn't seem to be used anywhere at all
 	bool _g435_isCommandQueueLocked; // @ G0435_B_CommandQueueLocked
@@ -227,8 +245,12 @@ class EventManager {
 
 	void f365_commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty
 	void f366_commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty
+	bool f375_processType80_clickDungeonView_isLeaderHandObjThrown(int16 posX, int16 posY); // @ F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown
+
+
 public:
 	explicit EventManager(DMEngine *vm);
+	~EventManager();
 
 	MouseInput* _g441_primaryMouseInput;// @ G0441_ps_PrimaryMouseInput
 	MouseInput* _g442_secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput
@@ -238,7 +260,13 @@ public:
 	uint16 _g599_useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap
 
 	void initMouse();
-	void showMouse(bool visibility);
+	void f67_setMousePointerToNormal(int16 mousePointer); // @ F0067_MOUSE_SetPointerToNormal
+	void f68_setPointerToObject(byte *bitmap); // @ F0068_MOUSE_SetPointerToObject
+	void f71_mouseDropChampionIcon(); // @ F0071_MOUSE_DropChampionIcon
+	void f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY); // @ F0073_MOUSE_BuildPointerScreenArea
+	void f69_setMousePointer(); // @ F0069_MOUSE_SetPointer
+	void f78_showMouse(); // @ F0077_MOUSE_HidePointer_CPSE
+	void f77_hideMouse(); // @ F0078_MOUSE_ShowPointer
 
 	void setMousePos(Common::Point pos);
 	void processInput(); // acknowledges mouse and keyboard input
@@ -252,8 +280,12 @@ public:
 	void f377_commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView
 	void f282_commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType); // @ F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel
 	void f378_commandProcess81ClickInPanel(int16 x, int16 y); // @ F0378_COMMAND_ProcessType81_ClickInPanel
+	void f373_processType80_clickInDungeonView_grabLeaderHandObject(uint16 viewCell); // @ F0373_COMMAND_ProcessType80_ClickInDungeonView_GrabLeaderHandObject
+	void f374_processType80_clickInDungeonViewDropLeaderHandObject(uint16 viewCell); // @ F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject
 
 	bool f360_hasPendingClick(Common::Point &point, MouseButton button); // @ F0360_COMMAND_ProcessPendingClick
+	void f379_drawSleepScreen(); // @ F0379_COMMAND_DrawSleepScreen
+	void f357_discardAllInput(); // @ F0357_COMMAND_DiscardAllInput
 };
 
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 460e7b5..05c8f17 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -745,6 +745,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_screenWidth = _screenHeight = 0;
 	_g289_championPortraitOrdinal = 0;
 	_g266_currMapViAltarIndex = 0;
+	_g297_drawFloorAndCeilingRequested = true;
 
 
 	for (int i = 0; i < 4; i++)
@@ -1534,6 +1535,16 @@ void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame* frame, int1
 	}
 }
 
+void DisplayMan::f21_blitToScreen(byte *bitmap, int16* box, int16 byteWidth, Color transparent, int16 height) {
+	Box actualBox(box[0], box[1], box[2], box[3]);
+	f21_blitToScreen(bitmap, &actualBox, byteWidth, transparent, height);
+}
+
+void DisplayMan::f21_blitToScreen(byte* bitmap, Box* box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal) {
+	_g578_useByteBoxCoordinates = false;
+	f132_blitToBitmap(bitmap, _g348_bitmapScreen, *box, 0, 0, byteWidth, k112_byteWidthViewport, transparent, height, k136_heightViewport);
+}
+
 void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
 	if (f._srcByteWidth)
 		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency);
@@ -1597,7 +1608,6 @@ T0116017_orangeElk:
 	}
 }
 
-// NOTE: has been screened for missing code
 void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) {
 	int16 order;
 	uint16 squareAspect[5];
@@ -2010,7 +2020,7 @@ void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) {
 		}
 		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
 			f132_blitToBitmap(f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
-				_g296_bitmapViewport, g106_BoxThievesEye_ViewPortVisibleArea, 0, 0,
+							  _g296_bitmapViewport, g106_BoxThievesEye_ViewPortVisibleArea, 0, 0,
 							  48, k112_byteWidthViewport, k9_ColorGold, 95, k136_heightViewport); /* BUG0_74 */
 			f493_addDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea);
 			warning("MISSING CODE: F0480_CACHE_ReleaseBlock");
@@ -2036,7 +2046,7 @@ void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) {
 T0124017:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
 /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C); 
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C);
 		f112_drawCeilingPit(k66_ceilingPitD1C_GraphicIndice, &g156_FrameFloorPit_D1C, posX, posY, false);
 T0124018:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, order);
@@ -2094,13 +2104,13 @@ void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) {
 
 	int16 squareAspect[5];
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16*) squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k16_DoorSideElemType:
 		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
 			memmove(_g74_tmpBitmap, _g709_bitmapWallSet_DoorFrameFront, 32 * 123);
 			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice),
-				_g74_tmpBitmap, g108_BoxThievesEyeHoleInDoorFrame, g172_Frame_DoorFrame_D0C._box._x1 - g106_BoxThievesEye_ViewPortVisibleArea._x1,
+							  _g74_tmpBitmap, g108_BoxThievesEyeHoleInDoorFrame, g172_Frame_DoorFrame_D0C._box._x1 - g106_BoxThievesEye_ViewPortVisibleArea._x1,
 							  0, 48, 16, k9_ColorGold, 95, 123);
 			f100_drawWallSetBitmap(_g74_tmpBitmap, g172_Frame_DoorFrame_D0C);
 		} else {
@@ -2127,16 +2137,17 @@ void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) {
 }
 
 void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) {
-	loadPalette(g20_PalEntrance);
-	// TODO: this is a global variable, set from here
-	bool flippedFloorCeiling = true;
+	loadPalette(g20_PalEntrance); // dummy code
 
 
+	if (_g297_drawFloorAndCeilingRequested)
+		f98_drawFloorAndCeiling();
+	_g578_useByteBoxCoordinates = true;
 	for (int16 i = 0; i < 6; ++i)
 		_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i].setToZero();
 
 	for (uint16 i = 0; i < 6; ++i) {
-		_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i]._x1 = 255 + 1;
+		_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i]._x1 = 255;
 	}
 
 	if (_g76_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1) {
@@ -2144,68 +2155,96 @@ void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) {
 		f99_copyBitmapAndFlipHorizontal(_g84_bitmapFloor, _g74_tmpBitmap, k112_byteWidthViewport, 70);
 		f100_drawWallSetBitmap(_g74_tmpBitmap, gK13_FloorFrame);
 
-		if (flippedFloorCeiling) {
-			_g698_bitmapWallSet_Wall_D3LCR = _g90_bitmapWall_D3LCR_Flipped;
-			_g699_bitmapWallSet_Wall_D2LCR = _g91_bitmapWall_D2LCR_Flipped;
-			_g700_bitmapWallSet_Wall_D1LCR = _g92_bitmapWall_D1LCR_Flipped;
-			_g701_bitmapWallSet_Wall_D0L = _g93_bitmapWall_D0L_Flipped;
-			_g702_bitmapWallSet_Wall_D0R = _g94_bitmapWall_D0R_Flipped;
-		}
+		_g698_bitmapWallSet_Wall_D3LCR = _g90_bitmapWall_D3LCR_Flipped;
+		_g699_bitmapWallSet_Wall_D2LCR = _g91_bitmapWall_D2LCR_Flipped;
+		_g700_bitmapWallSet_Wall_D1LCR = _g92_bitmapWall_D1LCR_Flipped;
+		_g701_bitmapWallSet_Wall_D0L = _g93_bitmapWall_D0L_Flipped;
+		_g702_bitmapWallSet_Wall_D0R = _g94_bitmapWall_D0R_Flipped;
 	} else {
 		f99_copyBitmapAndFlipHorizontal(_g85_bitmapCeiling, _g74_tmpBitmap, k112_byteWidthViewport, 29);
 		f100_drawWallSetBitmap(_g74_tmpBitmap, gK12_CeilingFrame);
 		f100_drawWallSetBitmap(_g84_bitmapFloor, gK13_FloorFrame);
 	}
 
-	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, -2, posX, posY) == k0_WallElemType)
+	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, -2, posX, posY) == k0_ElementTypeWall) {
 		f100_drawWallSetBitmap(_g697_bitmapWallSet_Wall_D3L2, g711_FrameWall_D3L2);
-	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, 2, posX, posY) == k0_WallElemType)
+	}
+	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, 2, posX, posY) == k0_ElementTypeWall) {
 		f100_drawWallSetBitmap(_g696_bitmapWallSet_Wall_D3R2, g712_FrameWall_D3R2);
+	}
 
-	int16 tmpPosX = posX, tmpPosY = posY;
+	int16 tmpPosX = posX;
+	int16 tmpPosY = posY;
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 4, -1, tmpPosX, tmpPosY);
+	f115_cthulhu(_vm->_dungeonMan->f162_getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM2_ViewSquare_D4L, k0x0001_CellOrder_BackLeft);
+	tmpPosX = posX;
+	tmpPosY = posY;
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 4, 1, tmpPosX, tmpPosY);
+	f115_cthulhu(_vm->_dungeonMan->f162_getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM1_ViewSquare_D4R, k0x0001_CellOrder_BackLeft);
+	tmpPosX = posX;
+	tmpPosY = posY;
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 4, 0, tmpPosX, tmpPosY);
+	f115_cthulhu(_vm->_dungeonMan->f162_getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM3_ViewSquare_D4C, k0x0001_CellOrder_BackLeft);
+	tmpPosX = posX;
+	tmpPosY = posY;
 	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY);
 	f116_drawSquareD3L(dir, tmpPosX, tmpPosY);
-	tmpPosX = posX, tmpPosY = posY;
+	tmpPosX = posX;
+	tmpPosY = posY;
 	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 3, 1, tmpPosX, tmpPosY);
 	f117_drawSquareD3R(dir, tmpPosX, tmpPosY);
-	tmpPosX = posX, tmpPosY = posY;
+	tmpPosX = posX;
+	tmpPosY = posY;
 	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 3, 0, tmpPosX, tmpPosY);
 	f118_drawSquareD3C(dir, tmpPosX, tmpPosY);
-	tmpPosX = posX, tmpPosY = posY;
+	tmpPosX = posX;
+	tmpPosY = posY;
 	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 2, -1, tmpPosX, tmpPosY);
 	f119_drawSquareD2L(dir, tmpPosX, tmpPosY);
-	tmpPosX = posX, tmpPosY = posY;
+	tmpPosX = posX;
+	tmpPosY = posY;
 	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 2, 1, tmpPosX, tmpPosY);
 	f120_drawSquareD2R(dir, tmpPosX, tmpPosY);
-	tmpPosX = posX, tmpPosY = posY;
+	tmpPosX = posX;
+	tmpPosY = posY;
 	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 2, 0, tmpPosX, tmpPosY);
 	f121_drawSquareD2C(dir, tmpPosX, tmpPosY);
-	tmpPosX = posX, tmpPosY = posY;
+	tmpPosX = posX;
+	tmpPosY = posY;
 	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 1, -1, tmpPosX, tmpPosY);
 	f122_drawSquareD1L(dir, tmpPosX, tmpPosY);
-	tmpPosX = posX, tmpPosY = posY;
+	tmpPosX = posX;
+	tmpPosY = posY;
 	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 1, 1, tmpPosX, tmpPosY);
 	f123_drawSquareD1R(dir, tmpPosX, tmpPosY);
-	tmpPosX = posX, tmpPosY = posY;
+	tmpPosX = posX;
+	tmpPosY = posY;
 	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 1, 0, tmpPosX, tmpPosY);
 	f124_drawSquareD1C(dir, tmpPosX, tmpPosY);
-	tmpPosX = posX, tmpPosY = posY;
+	tmpPosX = posX;
+	tmpPosY = posY;
 	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 0, -1, tmpPosX, tmpPosY);
 	f125_drawSquareD0L(dir, tmpPosX, tmpPosY);
-	tmpPosX = posX, tmpPosY = posY;
+	tmpPosX = posX;
+	tmpPosY = posY;
 	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 0, 1, tmpPosX, tmpPosY);
 	f126_drawSquareD0R(dir, tmpPosX, tmpPosY);
 	f127_drawSquareD0C(dir, posX, posY);
 
-	if (flippedFloorCeiling) {
-		_g698_bitmapWallSet_Wall_D3LCR = _g95_bitmapWall_D3LCR_Native;
-		_g699_bitmapWallSet_Wall_D2LCR = _g96_bitmapWall_D2LCR_Native;
-		_g700_bitmapWallSet_Wall_D1LCR = _g97_bitmapWall_D1LCR_Native;
-		_g701_bitmapWallSet_Wall_D0L = _g98_bitmapWall_D0L_Native;
-		_g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native;
-	}
+	_g698_bitmapWallSet_Wall_D3LCR = _g95_bitmapWall_D3LCR_Native;
+	_g699_bitmapWallSet_Wall_D2LCR = _g96_bitmapWall_D2LCR_Native;
+	_g700_bitmapWallSet_Wall_D1LCR = _g97_bitmapWall_D1LCR_Native;
+	_g701_bitmapWallSet_Wall_D0L = _g98_bitmapWall_D0L_Native;
+	_g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native;
 
 	f97_drawViewport((_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance) ? 1 : 0);
+	if (_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance)
+		f98_drawFloorAndCeiling();
+}
+
+void DisplayMan::f98_drawFloorAndCeiling() {
+	warning("f98_drawFloorAndCeiling doesn't do anything");
+	_g297_drawFloorAndCeilingRequested = false;
 }
 
 void DisplayMan::fillScreen(Color color) {
@@ -2378,6 +2417,7 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 			f93_applyCreatureReplColors(10, _vm->M1_ordinalToIndex(replColorOrdinal));
 	}
 
+	_g297_drawFloorAndCeilingRequested = true;
 	_g342_refreshDungeonViewPaleteRequested = true;
 }
 
@@ -2464,7 +2504,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 		wallOrnOrd--;
 		AL0088_i_NativeBitmapIndex = _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k0_NativeBitmapIndex];
 
-		AL0090_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex = 
+		AL0090_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex =
 			_g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k1_CoordinateSet]][viewWallIndex];
 
 		L0096_B_IsAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(AP0116_i_WallOrnamentIndex);
@@ -2474,7 +2514,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 		if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) {
 			if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
 				if (L0095_B_IsInscription) {
-					f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR,_g296_bitmapViewport,
+					f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport,
 									  g202_BoxWallPatchBehindInscription, 94, 28,
 									  g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth,
 									  k112_byteWidthViewport, k255_ColorNoTransparency, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport);
@@ -2543,7 +2583,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 				}
 			}
 			AL0089_i_PixelWidth = (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[1] - (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[0];
-			if (!f491_isDerivedBitmapInCache(AP0116_i_WallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + 
+			if (!f491_isDerivedBitmapInCache(AP0116_i_WallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament +
 				(AP0116_i_WallOrnamentIndex << 2) + g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex])) {
 				L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
 				f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex),
@@ -2583,16 +2623,16 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 			}
 		}
 		f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport,
-			*(Box*)AL0090_puc_CoordinateSet, AL0089_i_X, 0,
+						  *(Box*)AL0090_puc_CoordinateSet, AL0089_i_X, 0,
 						  AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport);
-/* BUG0_05 A champion portrait sensor on a wall square is visible on all sides of the wall. 
+/* BUG0_05 A champion portrait sensor on a wall square is visible on all sides of the wall.
 If there is another sensor with a wall ornament on one side of the wall then the champion portrait is drawn over that wall ornament */
-		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { 
+		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
 /* A portrait is 32x29 pixels */
 			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice),
-				_g296_bitmapViewport, g109_BoxChampionPortraitOnWall,
+							  _g296_bitmapViewport, g109_BoxChampionPortraitOnWall,
 							  (_g289_championPortraitOrdinal & 0x0007) << 5,
-							  (_g289_championPortraitOrdinal >> 3) * 29, 128, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); 
+							  (_g289_championPortraitOrdinal >> 3) * 29, 128, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport);
 		}
 T0107031:
 		return L0096_B_IsAlcove;
@@ -2648,7 +2688,7 @@ void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) {
 		}
 	}
 
-	byte *bitmap = dispMan.f489_getNativeBitmapOrGraphic(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex);
+	// byte *bitmap = dispMan.f489_getNativeBitmapOrGraphic(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex);
 	warning("MISSING CODE: F0133_VIDEO_BlitBoxFilledWithMaskedBitmap");
 
 	warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache, F0493_CACHE_AddDerivedBitmap, F0480_CACHE_ReleaseBlock");
@@ -3375,7 +3415,7 @@ continue;
 		do {
 			if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) {
 				projectile = (Projectile*)dunMan.f156_getThingData(thingParam);
-				if ((AL_4_projectileAspect = dunMan.f142_getProjectileAspect(projectile->_object)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
+				if ((AL_4_projectileAspect = dunMan.f142_getProjectileAspect(projectile->_slot)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
 					objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-AL_4_projectileAspect)];
 					AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
 					projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
@@ -3400,7 +3440,7 @@ continue;
 						projectileBitmapIndexData = 0;
 						flipVertical = flipHorizontal = false;
 					} else {
-						if (isOrientedWestEast((direction)(projectileDirection = _vm->_timeline->_g370_events[projectile->_timerIndex]._C._projectile.getDir()))
+						if (isOrientedWestEast((direction)(projectileDirection = _vm->_timeline->_g370_events[projectile->_eventIndex]._C._projectile.getDir()))
 							!= isOrientedWestEast(directionParam)) {
 							if (projectileAspectType == k2_ProjectileAspectHasRotation) {
 								projectileBitmapIndexData = 1;
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index cfe2710..4cdf613 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -286,9 +286,16 @@ public:
 
 	Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2) : _x1(x1), _x2(x2), _y1(y1), _y2(y2) {}
 	Box() {}
+	explicit Box(uint16 *ptr) {
+		_x1 = *ptr++;
+		_x2 = *ptr++;
+		_y1 = *ptr++;
+		_y2 = *ptr++;
+	}
 	bool isPointInside(Common::Point point) {
 		return (_x1 <= point.x) && (point.x <= _x2) && (_y1 <= point.y) && (point.y <= _y2); // <= because incluseive boundaries
 	}
+	bool isPointInside(int16 x, int16 y) { return isPointInside(Common::Point(x, y));  }
 	void setToZero() { _x1 = _x2 = _y1 = _y2 = 0; }
 }; // @ BOX_BYTE, BOX_WORD
 
@@ -453,6 +460,18 @@ public:
 #define k160_byteWidthScreen 160 // @ C160_BYTE_WIDTH_SCREEN
 #define k200_heightScreen 200 // @ C200_HEIGHT_SCREEN   
 
+#define k8_byteWidth 8 // @ C008_BYTE_WIDTH
+#define k16_byteWidth 16 // @ C016_BYTE_WIDTH
+#define k24_byteWidth 24 // @ C024_BYTE_WIDTH
+#define k32_byteWidth 32 // @ C032_BYTE_WIDTH
+#define k40_byteWidth 40 // @ C040_BYTE_WIDTH
+#define k48_byteWidth 48 // @ C048_BYTE_WIDTH
+#define k64_byteWidth 64 // @ C064_BYTE_WIDTH
+#define k72_byteWidth 72 // @ C072_BYTE_WIDTH
+#define k128_byteWidth 128 // @ C128_BYTE_WIDTH
+#define k144_byteWidth 144 // @ C144_BYTE_WIDTH
+
+
 class DoorFrames {
 public:
 	Frame _closedOrDestroyed;
@@ -626,6 +645,9 @@ public:
 	void f112_drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int16 mapX, int16 mapY, bool flipHorizontal); // @ F0112_DUNGEONVIEW_DrawCeilingPit
 
 
+	void f21_blitToScreen(byte* bitmap, int16 *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen
+	void f21_blitToScreen(byte* bitmap, Box *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen
+	
 
 	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which 
 	does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters
@@ -651,6 +673,7 @@ public:
 /* Expects inclusive boundaries in box */
 	void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 byteWidth, int16 height); // @ F0135_VIDEO_FillBox
 	void f128_drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
+	void f98_drawFloorAndCeiling(); // @ F0098_DUNGEONVIEW_DrawFloorAndCeiling
 	void updateScreen();
 	void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport
 
@@ -683,6 +706,8 @@ public:
 
 	Thing _g290_inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing
 
+	bool _g297_drawFloorAndCeilingRequested; // @ G0297_B_DrawFloorAndCeilingRequested
+
 	// This tells blitting functions wther to assume a BYTE_BOX or a WORD_BOX has been passed to them,
 	// I only use WORD_BOX, so this will probably deem useless
 	bool _g578_useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 3fa8c4a..7f845c6 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -28,14 +28,19 @@
 #include "group.h"
 #include "dungeonman.h"
 #include "champion.h"
-
+#include "movesens.h"
+#include "projexpl.h"
+#include "timeline.h"
 
 
 namespace DM {
-
+int32 M32_setTime(int32 &map_time, int32 time) {
+	return map_time = (map_time & 0xFF000000) | time;
+}
 
 GroupMan::GroupMan(DMEngine* vm) : _vm(vm) {
 	_g375_activeGroups = nullptr;
+	_g377_currActiveGroupCount = 0;
 }
 
 GroupMan::~GroupMan() {
@@ -97,4 +102,1634 @@ int16 GroupMan::f176_getCreatureOrdinalInCell(Group* group, uint16 cell) {
 uint16 GroupMan::M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex) {
 	return (groupVal >> (creatureIndex << 1)) & 0x3;
 }
+
+void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode) {
+	Thing L0365_T_CurrentThing;
+	Thing L0366_T_NextThing;
+	Group* L0367_ps_Group;
+	uint16 L0368_ui_CreatureType;
+	int16 L0369_i_CreatureIndex;
+	uint16 L0370_ui_GroupCells;
+	bool L0371_B_WeaponDropped;
+
+
+	L0367_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(groupThing);
+	if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[L0368_ui_CreatureType = L0367_ps_Group->_type]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
+		L0369_i_CreatureIndex = L0367_ps_Group->getCount();
+		L0370_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(L0367_ps_Group, _vm->_dungeonMan->_g272_currMapIndex);
+		do {
+			_vm->_groupMan->f186_dropCreatureFixedPossessions(L0368_ui_CreatureType, mapX, mapY, (L0370_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0370_ui_GroupCells, L0369_i_CreatureIndex), mode);
+		} while (L0369_i_CreatureIndex--);
+	}
+	if ((L0365_T_CurrentThing = L0367_ps_Group->_slot) != Thing::_endOfList) {
+		L0371_B_WeaponDropped = false;
+		do {
+			L0366_T_NextThing = _vm->_dungeonMan->f159_getNextThing(L0365_T_CurrentThing);
+			L0365_T_CurrentThing = M15_thingWithNewCell(L0365_T_CurrentThing, _vm->getRandomNumber(4));
+			if ((L0365_T_CurrentThing).getType() == k5_WeaponThingType) {
+				L0371_B_WeaponDropped = true;
+			}
+			_vm->_movsens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
+		} while ((L0365_T_CurrentThing = L0366_T_NextThing) != Thing::_endOfList);
+		if (mode >= k0_soundModePlayImmediately) {
+			warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+		}
+	}
+}
+
+void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int16 mapY, uint16 cell, int16 mode) {
+	static uint16 g245FixedPossessionCreature_12Skeleton[3] = { // @ G0245_aui_Graphic559_FixedPossessionsCreature12Skeleton
+		k23_ObjectInfoIndexFirstWeapon + k9_WeaponTypeFalchion,
+		k69_ObjectInfoIndexFirstArmour + k30_ArmourTypeWoodenShield, 0};
+	static uint16 g246FixedPossessionCreature_9StoneGolem[2] = { // @ G0246_aui_Graphic559_FixedPossessionsCreature09StoneGolem
+		k23_ObjectInfoIndexFirstWeapon + k24_WeaponTypeStoneClub, 0};
+	static uint16 g247FixedPossessionCreature_16TrolinAntman[2] = { // @ G0247_aui_Graphic559_FixedPossessionsCreature16Trolin_Antman
+		k23_ObjectInfoIndexFirstWeapon + k23_WeaponTypeClub, 0};
+	static uint16 g248FixedPossessionCreature_18AnimatedArmourDethKnight[7] = { // @ G0248_aui_Graphic559_FixedPossessionsCreature18AnimatedArmour_DethKnight
+		k69_ObjectInfoIndexFirstArmour + k41_ArmourTypeFootPlate,
+		k69_ObjectInfoIndexFirstArmour + k40_ArmourTypeLegPlate,
+		k69_ObjectInfoIndexFirstArmour + k39_ArmourTypeTorsoPlate,
+		k23_ObjectInfoIndexFirstWeapon + k10_WeaponTypeSword,
+		k69_ObjectInfoIndexFirstArmour + k38_ArmourTypeArmet,
+		k23_ObjectInfoIndexFirstWeapon + k10_WeaponTypeSword, 0};
+	static uint16 g249FixedPossessionCreature_7rockRockPile[5] = { // @ G0249_aui_Graphic559_FixedPossessionsCreature07Rock_RockPile
+		k127_ObjectInfoIndexFirstJunk + k25_JunkTypeBoulder,
+		k127_ObjectInfoIndexFirstJunk + k25_JunkTypeBoulder | k0x8000_randomDrop,
+		k23_ObjectInfoIndexFirstWeapon + k30_WeaponTypeRock | k0x8000_randomDrop,
+		k23_ObjectInfoIndexFirstWeapon + k30_WeaponTypeRock | k0x8000_randomDrop, 0};
+	static uint16 g250FixedPossessionCreature_4PainRatHellHound[3] = { // @ G0250_aui_Graphic559_FixedPossessionsCreature04PainRat_Hellhound
+		k127_ObjectInfoIndexFirstJunk + k35_JunkTypeDrumstickShank,
+		k127_ObjectInfoIndexFirstJunk + k35_JunkTypeDrumstickShank | k0x8000_randomDrop, 0};
+	static uint16 g251FixedPossessionCreature_6screamer[3] = { // @ G0251_aui_Graphic559_FixedPossessionsCreature06Screamer
+		k127_ObjectInfoIndexFirstJunk + k33_JunkTypeScreamerSlice,
+		k127_ObjectInfoIndexFirstJunk + k33_JunkTypeScreamerSlice | k0x8000_randomDrop, 0};
+	static uint16 g252FixedPossessionCreature_15MagnetaWormWorm[4] = { // @ G0252_aui_Graphic559_FixedPossessionsCreature15MagentaWorm_Worm
+		k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound,
+		k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound | k0x8000_randomDrop,
+		k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound | k0x8000_randomDrop, 0};
+	static uint16 g253FixedPossessionCreature_24RedDragon[11] = { // @ G0253_aui_Graphic559_FixedPossessionsCreature24RedDragon
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop, 0};
+
+	uint16 L0356_ui_FixedPossession;
+	int16 L0357_i_ThingType;
+	Thing L0358_T_Thing;
+	uint16* L0359_pui_FixedPossessions;
+	Weapon* L0360_ps_Weapon;
+	bool L0361_B_Cursed;
+	bool L0362_B_WeaponDropped;
+
+
+	L0361_B_Cursed = false;
+	L0362_B_WeaponDropped = false;
+	switch (creatureType) {
+	default:
+		return;
+	case k12_CreatureTypeSkeleton:
+		L0359_pui_FixedPossessions = g245FixedPossessionCreature_12Skeleton;
+		break;
+	case k9_CreatureTypeStoneGolem:
+		L0359_pui_FixedPossessions = g246FixedPossessionCreature_9StoneGolem;
+		break;
+	case k16_CreatureTypeTrolinAntman:
+		L0359_pui_FixedPossessions = g247FixedPossessionCreature_16TrolinAntman;
+		break;
+	case k18_CreatureTypeAnimatedArmourDethKnight:
+		L0361_B_Cursed = true;
+		L0359_pui_FixedPossessions = g248FixedPossessionCreature_18AnimatedArmourDethKnight;
+		break;
+	case k7_CreatureTypeRockpile:
+		L0359_pui_FixedPossessions = g249FixedPossessionCreature_7rockRockPile;
+		break;
+	case k4_CreatureTypePainRatHellHound:
+		L0359_pui_FixedPossessions = g250FixedPossessionCreature_4PainRatHellHound;
+		break;
+	case k6_CreatureTypeScreamer:
+		L0359_pui_FixedPossessions = g251FixedPossessionCreature_6screamer;
+		break;
+	case k15_CreatureTypeMagnetaWormWorm:
+		L0359_pui_FixedPossessions = g252FixedPossessionCreature_15MagnetaWormWorm;
+		break;
+	case k24_CreatureTypeRedDragon:
+		L0359_pui_FixedPossessions = g253FixedPossessionCreature_24RedDragon;
+	}
+	while (L0356_ui_FixedPossession = *L0359_pui_FixedPossessions++) {
+		if (getFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) && _vm->getRandomNumber(2))
+			continue;
+		if (clearFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) >= k127_ObjectInfoIndexFirstJunk) {
+			L0357_i_ThingType = k10_JunkThingType;
+			L0356_ui_FixedPossession -= k127_ObjectInfoIndexFirstJunk;
+		} else {
+			if (L0356_ui_FixedPossession >= k69_ObjectInfoIndexFirstArmour) {
+				L0357_i_ThingType = k6_ArmourThingType;
+				L0356_ui_FixedPossession -= k69_ObjectInfoIndexFirstArmour;
+			} else {
+				L0362_B_WeaponDropped = true;
+				L0357_i_ThingType = k5_WeaponThingType;
+				L0356_ui_FixedPossession -= k23_ObjectInfoIndexFirstWeapon;
+			}
+		}
+		if ((L0358_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(L0357_i_ThingType)) == Thing::_none) {
+			continue;
+		}
+		L0360_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0358_T_Thing);
+/* The same pointer type is used no matter the actual type k5_WeaponThingType, k6_ArmourThingType or k10_JunkThingType */
+		L0360_ps_Weapon->setType(L0356_ui_FixedPossession);
+		L0360_ps_Weapon->setCursed(L0361_B_Cursed);
+		L0358_T_Thing = M15_thingWithNewCell(L0358_T_Thing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell);
+		_vm->_movsens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY);
+	}
+	warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+}
+
+int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
+#define AP0483_i_PrimaryDirection srcMapX
+	int16 L0556_i_Direction;
+
+
+	if (srcMapX == destMapX) {
+		_vm->_projexpl->_g363_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 1; /* Resulting direction may be 1 or 3 (East or West) */
+		if (srcMapY > destMapY) {
+			return kDirNorth;
+		}
+		return kDirSouth;
+	}
+	if (srcMapY == destMapY) {
+		_vm->_projexpl->_g363_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 0; /* Resulting direction may be 0 or 2 (North or South) */
+		if (srcMapX > destMapX) {
+			return kDirWest;
+		}
+		return kDirEast;
+	}
+	L0556_i_Direction = kDirNorth;
+	for (;;) {
+		if (f227_isDestVisibleFromSource(L0556_i_Direction, srcMapX, srcMapY, destMapX, destMapY)) {
+			if (!f227_isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
+				if ((L0556_i_Direction != kDirNorth) || !f227_isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnPrevVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
+					_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + L0556_i_Direction);
+					return L0556_i_Direction;
+				}
+			}
+			if (_vm->getRandomNumber(2)) {
+				AP0483_i_PrimaryDirection = _vm->_projexpl->_g363_secondaryDirToOrFromParty;
+				_vm->_projexpl->_g363_secondaryDirToOrFromParty = L0556_i_Direction;
+				return AP0483_i_PrimaryDirection;
+			}
+			return L0556_i_Direction;
+		}
+		L0556_i_Direction++;
+	}
+}
+
+bool GroupMan::f227_isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
+	int L1637_i_Temp;
+
+	switch (dir) { /* If direction is not 'West' then swap variables so that the same test as for west can be applied */
+	case kDirSouth:
+		L1637_i_Temp = srcMapX;
+		srcMapX = destMapY;
+		destMapY = L1637_i_Temp;
+		L1637_i_Temp = destMapX;
+		destMapX = srcMapY;
+		srcMapY = L1637_i_Temp;
+		break;
+	case kDirEast:
+		L1637_i_Temp = srcMapX;
+		srcMapX = destMapX;
+		destMapX = L1637_i_Temp;
+		L1637_i_Temp = destMapY;
+		destMapY = srcMapY;
+		srcMapY = L1637_i_Temp;
+		break;
+	case kDirNorth:
+		L1637_i_Temp = srcMapX;
+		srcMapX = srcMapY;
+		srcMapY = L1637_i_Temp;
+		L1637_i_Temp = destMapX;
+		destMapX = destMapY;
+		destMapY = L1637_i_Temp;
+	}
+	return ((srcMapX -= (destMapX - 1)) > 0) && ((((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY) <= srcMapX);
+}
+
+bool GroupMan::f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack, bool magicAttack, int16 ticks) {
+	Door* L0573_ps_Door;
+	byte* L0574_puc_Square;
+	TimelineEvent L0575_s_Event;
+
+	L0573_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY);
+	if ((magicAttack && !L0573_ps_Door->isMagicDestructible()) || (!magicAttack && !L0573_ps_Door->isMeleeDestructible())) {
+		return false;
+	}
+	if (attack >= _vm->_dungeonMan->_g275_currMapDoorInfo[L0573_ps_Door->getType()]._defense) {
+		L0574_puc_Square = &_vm->_dungeonMan->_g271_currMapData[mapX][mapY];
+		if (Square(*L0574_puc_Square).getDoorState() == k4_doorState_CLOSED) {
+			if (ticks) {
+				M33_setMapAndTime(L0575_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ticks);
+				L0575_s_Event._type = k2_TMEventTypeDoorDestruction;
+				L0575_s_Event._priority = 0;
+				L0575_s_Event._B._location._mapX = mapX;
+				L0575_s_Event._B._location._mapY = mapY;
+				_vm->_timeline->f238_addEventGetEventIndex(&L0575_s_Event);
+			} else {
+				((Square*)L0574_puc_Square)->setDoorState(k5_doorState_DESTROYED);
+			}
+			return true;
+		}
+	}
+	return false;
+}
+
+Thing GroupMan::f175_groupGetThing(int16 mapX, int16 mapY) {
+	Thing L0317_T_Thing;
+
+	L0317_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
+	while ((L0317_T_Thing != Thing::_endOfList) && ((L0317_T_Thing).getType() != k4_GroupThingType)) {
+		L0317_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0317_T_Thing);
+	}
+	return L0317_T_Thing;
+}
+
+int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group* group, uint16 creatureIndex, int16 mapX, int16 mapY, int16 damage, bool notMoving) {
+	uint16 L0374_ui_Multiple;
+#define AL0374_ui_EventIndex    L0374_ui_Multiple
+#define AL0374_ui_CreatureIndex L0374_ui_Multiple
+#define AL0374_ui_CreatureSize  L0374_ui_Multiple
+#define AL0374_ui_Attack        L0374_ui_Multiple
+	uint16 L0375_ui_Multiple;
+#define AL0375_ui_Outcome           L0375_ui_Multiple
+#define AL0375_ui_EventType         L0375_ui_Multiple
+#define AL0375_ui_NextCreatureIndex L0375_ui_Multiple
+	CreatureInfo* L0376_ps_CreatureInfo;
+	TimelineEvent* L0377_ps_Event;
+	ActiveGroup* L0378_ps_ActiveGroup = nullptr;
+	uint16 L0379_ui_CreatureCount;
+	uint16 L0380_ui_Multiple = 0;
+#define AL0380_ui_CreatureType   L0380_ui_Multiple
+#define AL0380_ui_FearResistance L0380_ui_Multiple
+	uint16 L0381_ui_GroupCells;
+	uint16 L0382_ui_GroupDirections;
+	bool L0383_B_CurrentMapIsPartyMap;
+	uint16 L0384_ui_Cell;
+
+
+	L0376_ps_CreatureInfo = &g243_CreatureInfo[AL0380_ui_CreatureType = group->_type];
+	if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) /* Lord Chaos cannot be damaged */
+		goto T0190024;
+	if (group->_health[creatureIndex] <= damage) {
+		L0381_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(group, _vm->_dungeonMan->_g272_currMapIndex);
+		L0384_ui_Cell = (L0381_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0381_ui_GroupCells, creatureIndex);
+		if (!(L0379_ui_CreatureCount = group->getCount())) { /* If there is a single creature in the group */
+			if (notMoving) {
+				f188_dropGroupPossessions(mapX, mapY, _vm->_groupMan->f175_groupGetThing(mapX, mapY), k2_soundModePlayOneTickLater);
+				f189_delete(mapX, mapY);
+			}
+			AL0375_ui_Outcome = k2_outcomeKilledAllCreaturesInGroup;
+		} else { /* If there are several creatures in the group */
+			L0382_ui_GroupDirections = _vm->_groupMan->f147_getGroupDirections(group, _vm->_dungeonMan->_g272_currMapIndex);
+			if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
+				if (notMoving) {
+					f186_dropCreatureFixedPossessions(AL0380_ui_CreatureType, mapX, mapY, L0384_ui_Cell, k2_soundModePlayOneTickLater);
+				} else {
+					_g392_dropMovingCreatureFixedPossessionsCell[_g391_dropMovingCreatureFixedPossCellCount++] = L0384_ui_Cell;
+				}
+			}
+			if (L0383_B_CurrentMapIsPartyMap = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) {
+				L0378_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
+			}
+			if (group->getBehaviour() == k6_behavior_ATTACK) {
+				L0377_ps_Event = _vm->_timeline->_g370_events;
+				for (AL0374_ui_EventIndex = 0; AL0374_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; AL0374_ui_EventIndex++) {
+					if ((M29_map(L0377_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) &&
+						(L0377_ps_Event->_B._location._mapX == mapX) &&
+						(L0377_ps_Event->_B._location._mapY == mapY) &&
+						((AL0375_ui_EventType = L0377_ps_Event->_type) > k32_TMEventTypeUpdateAspectGroup) &&
+						(AL0375_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1)) {
+						if (AL0375_ui_EventType < k37_TMEventTypeUpdateBehaviourGroup) {
+							AL0375_ui_EventType -= k33_TMEventTypeUpdateAspectCreature_0; /* Get creature index for events 33 to 36 */
+						} else {
+							AL0375_ui_EventType -= k38_TMEventTypeUpdateBehaviour_0; /* Get creature index for events 38 to 41 */
+						}
+						if (AL0375_ui_NextCreatureIndex == creatureIndex) {
+							_vm->_timeline->f237_deleteEvent(AL0374_ui_EventIndex);
+						} else {
+							if (AL0375_ui_NextCreatureIndex > creatureIndex) {
+								L0377_ps_Event->_type -= 1;
+								_vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(AL0374_ui_EventIndex));
+							}
+						}
+					}
+					L0377_ps_Event++;
+				}
+				if (L0383_B_CurrentMapIsPartyMap && ((AL0380_ui_FearResistance = L0376_ps_CreatureInfo->M57_getFearResistance()) != k15_immuneToFear) && ((AL0380_ui_FearResistance += L0379_ui_CreatureCount - 1) < (_vm->getRandomNumber(16)))) { /* Test if the death of a creature frigthens the remaining creatures in the group */
+					L0378_ps_ActiveGroup->_delayFleeingFromTarget = _vm->getRandomNumber(100 - (AL0380_ui_FearResistance << 2)) + 20;
+					group->setBehaviour(k5_behavior_FLEE);
+				}
+			}
+			for (AL0375_ui_NextCreatureIndex = AL0374_ui_CreatureIndex = creatureIndex; AL0374_ui_CreatureIndex < L0379_ui_CreatureCount; AL0374_ui_CreatureIndex++) {
+				AL0375_ui_NextCreatureIndex++;
+				group->_health[AL0374_ui_CreatureIndex] = group->_health[AL0375_ui_NextCreatureIndex];
+				L0382_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0382_ui_GroupDirections, AL0374_ui_CreatureIndex, _vm->_groupMan->M50_getCreatureValue(L0382_ui_GroupDirections, AL0375_ui_NextCreatureIndex));
+				L0381_ui_GroupCells = f178_getGroupValueUpdatedWithCreatureValue(L0381_ui_GroupCells, AL0374_ui_CreatureIndex, _vm->_groupMan->M50_getCreatureValue(L0381_ui_GroupCells, AL0375_ui_NextCreatureIndex));
+				if (L0383_B_CurrentMapIsPartyMap) {
+					L0378_ps_ActiveGroup->_aspect[AL0374_ui_CreatureIndex] = L0378_ps_ActiveGroup->_aspect[AL0375_ui_NextCreatureIndex];
+				}
+			}
+			L0381_ui_GroupCells &= 0x003F;
+			_vm->_dungeonMan->f146_setGroupCells(group, L0381_ui_GroupCells, _vm->_dungeonMan->_g272_currMapIndex);
+			_vm->_dungeonMan->f148_setGroupDirections(group, L0382_ui_GroupDirections, _vm->_dungeonMan->_g272_currMapIndex);
+			group->setCount(group->getCount() - 1);
+			AL0375_ui_Outcome = k1_outcomeKilledSomeCreaturesInGroup;
+		}
+		if ((AL0374_ui_CreatureSize = getFlag(L0376_ps_CreatureInfo->_attributes, k0x0003_MaskCreatureInfo_size)) == k0_MaskCreatureSizeQuarter) {
+			AL0374_ui_Attack = 110;
+		} else {
+			if (AL0374_ui_CreatureSize == k1_MaskCreatureSizeHalf) {
+				AL0374_ui_Attack = 190;
+			} else {
+				AL0374_ui_Attack = 255;
+			}
+		}
+		_vm->_projexpl->f213_explosionCreate(Thing::_explSmoke, AL0374_ui_Attack, mapX, mapY, L0384_ui_Cell); /* BUG0_66 Smoke is placed on the source map instead of the destination map when a creature dies by falling through a pit. The game has a special case to correctly drop the creature possessions on the destination map but there is no such special case for the smoke. Note that the death must be caused by the damage of the fall (there is no smoke if the creature is removed because its type is not allowed on the destination map). However this bug has no visible consequence because of BUG0_26: the smoke explosion falls in the pit right after being placed in the dungeon and before being drawn on screen so it is only visible on the destination square */
+		return AL0375_ui_Outcome;
+	}
+	if (damage > 0) {
+		group->_health[creatureIndex] -= damage;
+	}
+T0190024:
+	return k0_outcomeKilledNoCreaturesInGroup;
+}
+
+void GroupMan::f189_delete(int16 mapX, int16 mapY) {
+	Thing L0372_T_GroupThing;
+	Group* L0373_ps_Group;
+
+
+	if ((L0372_T_GroupThing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) {
+		return;
+	}
+	L0373_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0372_T_GroupThing);
+	for (uint16 i = 0; i < 4; ++i)
+		L0373_ps_Group->_health[i] = 0;
+	_vm->_movsens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
+	L0373_ps_Group->_nextThing = Thing::_none;
+	if (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) {
+		_vm->_groupMan->_g375_activeGroups[L0373_ps_Group->getActiveGroupIndex()]._groupThingIndex = -1;
+		_g377_currActiveGroupCount--;
+	}
+	f181_groupDeleteEvents(mapX, mapY);
+}
+
+void GroupMan::f181_groupDeleteEvents(int16 mapX, int16 mapY) {
+	int16 L0334_i_EventIndex;
+	uint16 L0335_ui_EventType;
+	TimelineEvent* L0336_ps_Event;
+
+
+	L0336_ps_Event = _vm->_timeline->_g370_events;
+	for (L0334_i_EventIndex = 0; L0334_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0334_i_EventIndex++) {
+		if ((M29_map(L0336_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) &&
+			((L0335_ui_EventType = L0336_ps_Event->_type) > k29_TMEventTypeGroupReactionDangerOnSquare - 1) && (L0335_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1) &&
+			(L0336_ps_Event->_B._location._mapX == mapX) && (L0336_ps_Event->_B._location._mapY == mapY)) {
+			_vm->_timeline->f237_deleteEvent(L0334_i_EventIndex);
+		}
+		L0336_ps_Event++;
+	}
+}
+
+uint16 GroupMan::f178_getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatreVal) {
+	creatreVal &= 0x0003;
+	creatreVal <<= (creatureIndex <<= 1);
+	return creatreVal | (groupVal & ~(3 << creatreVal));
+}
+
+int16 GroupMan::f191_getDamageAllCreaturesOutcome(Group* group, int16 mapX, int16 mapY, int16 attack, bool notMoving) {
+	uint16 L0385_ui_RandomAttack;
+	int16 L0386_i_CreatureIndex;
+	int16 L0387_i_Outcome;
+	bool L0388_B_KilledSomeCreatures;
+	bool L0389_B_KilledAllCreatures;
+
+
+	L0388_B_KilledSomeCreatures = false;
+	L0389_B_KilledAllCreatures = true;
+	_g391_dropMovingCreatureFixedPossCellCount = 0;
+	if (attack > 0) {
+		L0386_i_CreatureIndex = group->getCount();
+		attack -= (L0385_ui_RandomAttack = (attack >> 3) + 1);
+		L0385_ui_RandomAttack <<= 1;
+		do {
+			L0389_B_KilledAllCreatures = (L0387_i_Outcome = f190_groupGetDamageCreatureOutcome(group, L0386_i_CreatureIndex, mapX, mapY, attack + _vm->getRandomNumber(L0385_ui_RandomAttack), notMoving)) && L0389_B_KilledAllCreatures;
+			L0388_B_KilledSomeCreatures = L0388_B_KilledSomeCreatures || L0387_i_Outcome;
+		} while (L0386_i_CreatureIndex--);
+		if (L0389_B_KilledAllCreatures) {
+			return k2_outcomeKilledAllCreaturesInGroup;
+		}
+		if (L0388_B_KilledSomeCreatures) {
+			return k1_outcomeKilledSomeCreaturesInGroup;
+		}
+		return k0_outcomeKilledNoCreaturesInGroup;
+	} else {
+		return k0_outcomeKilledNoCreaturesInGroup;
+	}
+}
+
+int16 GroupMan::f192_groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack) {
+	int16 L0390_i_PoisonResistance;
+
+
+	if (!poisonAttack || ((L0390_i_PoisonResistance = g243_CreatureInfo[creatreType].M61_poisonResistance()) == k15_immuneToPoison)) {
+		return 0;
+	}
+	return ((poisonAttack + _vm->getRandomNumber(4)) << 3) / ++L0390_i_PoisonResistance;
+}
+
+void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks) {
+	Group* L0444_ps_Group;
+	ActiveGroup* L0445_ps_ActiveGroup;
+	int16 L0446_i_Multiple;
+#define AL0446_i_EventType           L0446_i_Multiple
+#define AL0446_i_Direction           L0446_i_Multiple
+#define AL0446_i_Ticks               L0446_i_Multiple
+#define AL0446_i_Distance            L0446_i_Multiple
+#define AL0446_i_Behavior2Or3        L0446_i_Multiple
+#define AL0446_i_CreatureAspectIndex L0446_i_Multiple
+#define AL0446_i_Range               L0446_i_Multiple
+#define AL0446_i_CreatureAttributes  L0446_i_Multiple
+#define AL0446_i_Cell                L0446_i_Multiple
+#define AL0446_i_GroupCellsCriteria  L0446_i_Multiple
+	int16 L0447_i_Multiple;
+#define AL0447_i_Behavior           L0447_i_Multiple
+#define AL0447_i_CreatureIndex      L0447_i_Multiple
+#define AL0447_i_ReferenceDirection L0447_i_Multiple
+#define AL0447_i_Ticks              L0447_i_Multiple
+	CreatureInfo L0448_s_CreatureInfo;
+	Thing L0449_T_GroupThing;
+	int16 L0450_i_Multiple;
+#define AL0450_i_DestinationMapX  L0450_i_Multiple
+#define AL0450_i_DistanceXToParty L0450_i_Multiple
+#define AL0450_i_TargetMapX       L0450_i_Multiple
+	int16 L0451_i_Multiple;
+#define AL0451_i_DestinationMapY  L0451_i_Multiple
+#define AL0451_i_DistanceYToParty L0451_i_Multiple
+#define AL0451_i_TargetMapY       L0451_i_Multiple
+	int16 L0452_i_DistanceToVisibleParty = 0;
+	bool L0453_B_NewGroupDirectionFound;
+	int16 L0454_i_PrimaryDirectionToOrFromParty;
+	bool L0455_B_CurrentEventTypeIsNotUpdateBehavior;
+	bool L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls;
+	bool L0457_B_MoveToPriorLocation;
+	bool L0458_B_SetBehavior7_ApproachAfterReaction = false;
+	int16 L0459_i_CreatureSize;
+	uint16 L0460_ui_CreatureCount;
+	int16 L0461_i_MovementTicks;
+	int16 L0462_i_TicksSinceLastMove;
+	bool L0463_B_Archenemy;
+	int32 L0464_l_NextAspectUpdateTime;
+	TimelineEvent L0465_s_NextEvent;
+
+
+	/* If the party is not on the map specified in the event and the event type is not one of 32, 33, 37, 38 then the event is ignored */
+	if ((_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) && ((AL0446_i_EventType = eventType) != k37_TMEventTypeUpdateBehaviourGroup) && (AL0446_i_EventType != k32_TMEventTypeUpdateAspectGroup) && (AL0446_i_EventType != k38_TMEventTypeUpdateBehaviour_0) && (AL0446_i_EventType != k33_TMEventTypeUpdateAspectCreature_0))
+		goto T0209139_Return;
+	/* If there is no creature at the location specified in the event then the event is ignored */
+	if ((L0449_T_GroupThing = _vm->_groupMan->f175_groupGetThing(eventMapX, eventMapY)) == Thing::_endOfList) {
+		goto T0209139_Return;
+	}
+	L0444_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0449_T_GroupThing);
+	L0448_s_CreatureInfo = g243_CreatureInfo[L0444_ps_Group->_type];
+	/* Update the event */
+	M33_setMapAndTime(L0465_s_NextEvent._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime);
+	L0465_s_NextEvent._priority = 255 - L0448_s_CreatureInfo._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
+	L0465_s_NextEvent._B._location._mapX = eventMapX;
+	L0465_s_NextEvent._B._location._mapY = eventMapY;
+	/* If the creature is not on the party map then try and move the creature in a random direction and place a new event 37 in the timeline for the next creature movement */
+	if (_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) {
+		if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->getRandomNumber(4), false)) { /* BUG0_67 A group that is not on the party map may wrongly move or not move into a teleporter. Normally, a creature type with Wariness >= 10 (Vexirk, Materializer / Zytaz, Demon, Lord Chaos, Red Dragon / Dragon) would only move into a teleporter if the creature type is allowed on the destination map. However, the variable G0380_T_CurrentGroupThing identifying the group is not set before being used by F0139_DUNGEON_IsCreatureAllowedOnMap called by f202_isMovementPossible so the check to see if the creature type is allowed may operate on another creature type and thus return an incorrect result, causing the creature to teleport while it should not, or not to teleport while it should */
+			AL0450_i_DestinationMapX = eventMapX;
+			AL0451_i_DestinationMapY = eventMapY;
+			AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
+			if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
+				goto T0209139_Return;
+			L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX;
+			L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY;
+		}
+		L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup;
+		AL0446_i_Ticks = MAX(ABS(_vm->_dungeonMan->_g272_currMapIndex - _vm->_dungeonMan->_g309_partyMapIndex) << 4, L0448_s_CreatureInfo._movementTicks << 1);
+		/* BUG0_68 A group moves or acts with a wrong timing. Event is added below but L0465_s_NextEvent.C.Ticks has not been initialized. No consequence while the group is not on the party map. When the party enters the group map the first group event may have a wrong timing */
+T0209005_AddEventAndReturn:
+		L0465_s_NextEvent._mapTime += AL0446_i_Ticks;
+		_vm->_timeline->f238_addEventGetEventIndex(&L0465_s_NextEvent);
+		goto T0209139_Return;
+	}
+	/* If the creature is Lord Chaos then ignore the event if the game is won. Initialize data to analyze Fluxcages */
+	if (L0463_B_Archenemy = getFlag(L0448_s_CreatureInfo._attributes, k0x2000_MaskCreatureInfo_archenemy)) {
+		if (_vm->_g302_gameWon) {
+			goto T0209139_Return;
+		}
+		_g386_fluxCageCount = 0;
+		_g385_fluxCages[0] = 0;
+	}
+	L0445_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[L0444_ps_Group->getActiveGroupIndex()];
+	if ((L0462_i_TicksSinceLastMove = (unsigned char)_vm->_g313_gameTime - L0445_ps_ActiveGroup->_lastMoveTime) < 0) {
+		L0462_i_TicksSinceLastMove += 256;
+	}
+	if ((L0461_i_MovementTicks = L0448_s_CreatureInfo._movementTicks) == k255_immobile) {
+		L0461_i_MovementTicks = 100;
+	}
+	if (_vm->_championMan->_g407_party._freezeLifeTicks && !L0463_B_Archenemy) { /* If life is frozen and the creature is not Lord Chaos (Lord Chaos is immune to Freeze Life) then reschedule the event later (except for reactions which are ignored when life if frozen) */
+		if (eventType < 0)
+			goto T0209139_Return;
+		L0465_s_NextEvent._type = eventType;
+		L0465_s_NextEvent._C._ticks = ticks;
+		AL0446_i_Ticks = 4; /* Retry in 4 ticks */
+		goto T0209005_AddEventAndReturn;
+	}
+	/* If the specified event type is a 'reaction' instead of a real event from the timeline then create the corresponding reaction event with a delay:
+	For event kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, the reaction time is 1 tick
+	For event kM2_TMEventTypeCreateReactionEvent30HitByProjectile and kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, the reaction time may be 1 tick or slower: slow moving creatures react more slowly. The more recent is the last creature move, the slower the reaction */
+	if (eventType < 0) {
+		L0465_s_NextEvent._type = eventType + k32_TMEventTypeUpdateAspectGroup;
+		if ((eventType == kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) || ((AL0446_i_Ticks = ((L0461_i_MovementTicks + 2) >> 2) - L0462_i_TicksSinceLastMove) < 1)) { /* AL0446_i_Ticks is the reaction time */
+			AL0446_i_Ticks = 1; /* Retry in 1 tick */
+		}
+		goto T0209005_AddEventAndReturn; /* BUG0_68 A group moves or acts with a wrong timing. Event is added but L0465_s_NextEvent.C.Ticks has not been initialized */
+	}
+	AL0447_i_Behavior = L0444_ps_Group->getBehaviour();
+	L0460_ui_CreatureCount = L0444_ps_Group->getCount();
+	L0459_i_CreatureSize = getFlag(L0448_s_CreatureInfo._attributes, k0x0003_MaskCreatureInfo_size);
+	AL0450_i_DistanceXToParty = ((AL0446_i_Distance = eventMapX - _vm->_dungeonMan->_g306_partyMapX) < 0) ? -AL0446_i_Distance : AL0446_i_Distance;
+	AL0451_i_DistanceYToParty = ((AL0446_i_Distance = eventMapY - _vm->_dungeonMan->_g307_partyMapY) < 0) ? -AL0446_i_Distance : AL0446_i_Distance;
+	_g378_currentGroupMapX = eventMapX;
+	_g379_currentGroupMapY = eventMapY;
+	_g380_currGroupThing = L0449_T_GroupThing;
+	_g384_groupMovementTestedDirections[0] = 0;
+	_g381_currGroupDistanceToParty = f226_getDistanceBetweenSquares(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+	_g382_currGroupPrimaryDirToParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+	_g383_currGroupSecondaryDirToParty = _vm->_projexpl->_g363_secondaryDirToOrFromParty;
+	L0464_l_NextAspectUpdateTime = 0;
+	L0455_B_CurrentEventTypeIsNotUpdateBehavior = true;
+	if (eventType <= k31_TMEventTypeGroupReactionPartyIsAdjecent) { /* Process Reaction events 29 to 31 */
+		switch (eventType = eventType - k32_TMEventTypeUpdateAspectGroup) {
+		case kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent: /* This event is used when the party bumps into a group or attacks a group physically (not with a spell). It causes the creature behavior to change to attack if it is not already attacking the party or fleeing from target */
+			if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) {
+				f181_groupDeleteEvents(eventMapX, eventMapY);
+				goto T0209044_SetBehavior6_Attack;
+			}
+			L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
+			L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+			goto T0209139_Return;
+		case kM2_TMEventTypeCreateReactionEvent30HitByProjectile: /* This event is used for the reaction of a group after a projectile impacted with one creature in the group (some creatures may have been killed) */
+			if ((AL0447_i_Behavior == k6_behavior_ATTACK) || (AL0447_i_Behavior == k5_behavior_FLEE)) /* If the creature is attacking the party or fleeing from the target then there is no reaction */
+				goto T0209139_Return;
+			if ((AL0446_i_Behavior2Or3 = ((AL0447_i_Behavior == k3_behavior_USELESS) || (AL0447_i_Behavior == k2_behavior_USELESS))) || (_vm->getRandomNumber(4))) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances */
+				if (!f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { /* If the group cannot see the party then look in a random direction to try and search for the party */
+					L0458_B_SetBehavior7_ApproachAfterReaction = L0453_B_NewGroupDirectionFound = false;
+					goto T0209073_SetDirectionGroup;
+				}
+				if (AL0446_i_Behavior2Or3 || (_vm->getRandomNumber(4))) /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances then no reaction */
+					goto T0209139_Return;
+			} /* No 'break': proceed to instruction after the next 'case' below. Reaction is to move in a random direction to try and avoid other projectiles */
+		case kM3_TMEventTypeCreateReactionEvent29DangerOnSquare: /* This event is used when some creatures in the group were killed by a Poison Cloud or by a closing door or if Lord Chaos is surrounded by 3 Fluxcages. It causes the creature to move in a random direction to avoid the danger */
+			L0458_B_SetBehavior7_ApproachAfterReaction = (AL0447_i_Behavior == k6_behavior_ATTACK); /* If the creature behavior is 'Attack' and it has to move to avoid danger then it will change its behavior to 'Approach' after the movement */
+			L0453_B_NewGroupDirectionFound = false;
+			goto T0209058_MoveInRandomDirection;
+		}
+	}
+	if (eventType < k37_TMEventTypeUpdateBehaviourGroup) { /* Process Update Aspect events 32 to 36 */
+		L0465_s_NextEvent._type = eventType + 5;
+		if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+			if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) {
+				if (M38_distance(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, eventMapX, eventMapY) <= 1)
+					goto T0209044_SetBehavior6_Attack;
+				if (((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k3_behavior_USELESS)) && (AL0447_i_Behavior != k7_behavior_APPROACH)) /* BUG0_00 Useless code. Behavior cannot be 3 because this value is never used. Moreover, the second condition in the && is redundant (if the value is 0 or 3, it cannot be 7). The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */
+					goto T0209054_SetBehavior7_Approach;
+			}
+			L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
+			L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+		}
+		if (AL0447_i_Behavior == k6_behavior_ATTACK) {
+			AL0446_i_CreatureAspectIndex = eventType - k33_TMEventTypeUpdateAspectCreature_0; /* Value -1 for event 32, meaning aspect will be updated for all creatures in the group */
+			L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0446_i_CreatureAspectIndex, getFlag(L0445_ps_ActiveGroup->_aspect[AL0446_i_CreatureAspectIndex], k0x0080_MaskActiveGroupIsAttacking));
+			goto T0209136;
+		}
+		if ((AL0450_i_DistanceXToParty > 3) || (AL0451_i_DistanceYToParty > 3)) {
+			L0464_l_NextAspectUpdateTime = _vm->_g313_gameTime + ((L0448_s_CreatureInfo._animationTicks >> 4) & 0xF);
+			goto T0209136;
+		}
+	} else { /* Process Update Behavior events 37 to 41 */
+		L0455_B_CurrentEventTypeIsNotUpdateBehavior = false;
+		if (ticks) {
+			L0464_l_NextAspectUpdateTime = _vm->_g313_gameTime;
+		}
+		if (eventType == k37_TMEventTypeUpdateBehaviourGroup) { /* Process event 37, Update Group Behavior */
+			if ((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k2_behavior_USELESS) || (AL0447_i_Behavior == k3_behavior_USELESS)) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */
+				if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+					if ((L0452_i_DistanceToVisibleParty <= (L0448_s_CreatureInfo.M56_getAttackRange())) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) { /* If the creature is in range for attack and on the same row or column as the party on the map */
+T0209044_SetBehavior6_Attack:
+						if (eventType == kM2_TMEventTypeCreateReactionEvent30HitByProjectile) {
+							f181_groupDeleteEvents(eventMapX, eventMapY);
+						}
+						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
+						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+						L0444_ps_Group->setBehaviour(k6_behavior_ATTACK);
+						AL0446_i_Direction = _g382_currGroupPrimaryDirToParty;
+						for (AL0447_i_CreatureIndex = L0460_ui_CreatureCount; AL0447_i_CreatureIndex >= 0; AL0447_i_CreatureIndex--) {
+							if ((_vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) != AL0446_i_Direction) &&
+								((!AL0447_i_CreatureIndex) || (!_vm->getRandomNumber(2)))) {
+								f205_setDirection(L0445_ps_ActiveGroup, AL0446_i_Direction, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
+								M32_setTime(L0465_s_NextEvent._mapTime, _vm->_g313_gameTime + _vm->getRandomNumber(4) + 2); /* Random delay represents the time for the creature to turn */
+							} else {
+								M32_setTime(L0465_s_NextEvent._mapTime, _vm->_g313_gameTime + 1);
+							}
+							if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) {
+								L0465_s_NextEvent._mapTime += MIN((uint16)((L0448_s_CreatureInfo._attackTicks >> 1) + _vm->getRandomNumber(4)), ticks);
+							}
+							L0465_s_NextEvent._type = k38_TMEventTypeUpdateBehaviour_0 + AL0447_i_CreatureIndex;
+							f208_groupAddEvent(&L0465_s_NextEvent, f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false));
+						}
+						goto T0209139_Return;
+					}
+					if (AL0447_i_Behavior != k2_behavior_USELESS) { /* BUG0_00 Useless code. Behavior cannot be 2 because this value is never used */
+T0209054_SetBehavior7_Approach:
+						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
+						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
+						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+						L0465_s_NextEvent._mapTime += 1;
+						goto T0209134_SetEvent37;
+					}
+				} else {
+					if (AL0447_i_Behavior == k0_behavior_WANDER) {
+						if (L0454_i_PrimaryDirectionToOrFromParty = f201_getSmelledPartyPrimaryDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY)) {
+							L0454_i_PrimaryDirectionToOrFromParty--;
+							L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = false;
+							goto T0209085_SingleSquareMove;
+						}
+						L0453_B_NewGroupDirectionFound = false;
+						if (_vm->getRandomNumber(2)) {
+T0209058_MoveInRandomDirection:
+							AL0446_i_Direction = _vm->getRandomNumber(4);
+							AL0447_i_ReferenceDirection = AL0446_i_Direction;
+							L0457_B_MoveToPriorLocation = false;
+							do {
+								AL0450_i_DestinationMapX = eventMapX;
+								AL0451_i_DestinationMapY = eventMapY;
+								AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
+								if (((L0445_ps_ActiveGroup->_priorMapX != AL0450_i_DestinationMapX) ||
+									(L0445_ps_ActiveGroup->_priorMapY != AL0451_i_DestinationMapY) ||
+									 (L0457_B_MoveToPriorLocation = !_vm->getRandomNumber(4))) /* 1/4 chance of moving back to the square that the creature comes from */
+									&& f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction, false)) {
+T0209061_MoveGroup:
+									if (L0453_B_NewGroupDirectionFound = ((AL0447_i_Ticks = (L0461_i_MovementTicks >> 1) - L0462_i_TicksSinceLastMove) <= 0)) {
+										if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
+											goto T0209139_Return;
+										L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX;
+										L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY;;
+										L0445_ps_ActiveGroup->_priorMapX = eventMapX;
+										L0445_ps_ActiveGroup->_priorMapY = eventMapY;
+										L0445_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime;
+									} else {
+										L0461_i_MovementTicks = AL0447_i_Ticks;
+										L0462_i_TicksSinceLastMove = -1;
+									}
+									break;
+								}
+								if (_g390_groupMovementBlockedByParty) {
+									if ((eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) &&
+										((L0444_ps_Group->getBehaviour() != k5_behavior_FLEE) ||
+										 !f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false) ||
+										 _vm->getRandomNumber(2)))
+										goto T0209044_SetBehavior6_Attack;
+									L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
+									L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+								}
+							} while ((AL0446_i_Direction = returnNextVal(AL0446_i_Direction)) != AL0447_i_ReferenceDirection);
+						}
+						if (!L0453_B_NewGroupDirectionFound &&
+							(L0462_i_TicksSinceLastMove != -1) &&
+							L0463_B_Archenemy &&
+							((eventType == kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) || !_vm->getRandomNumber(4))) { /* BUG0_15 The game hangs when you close a door on Lord Chaos. A condition is missing in the code to manage creatures and this may create an infinite loop between two parts in the code */
+							_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0454_i_PrimaryDirectionToOrFromParty = _vm->getRandomNumber(4));
+							goto T0209089_DoubleSquareMove; /* BUG0_69 Memory corruption when you close a door on Lord Chaos. The local variable (L0454_i_PrimaryDirectionToOrFromParty) containing the direction where Lord Chaos tries to move may be used as an array index without being initialized and cause memory corruption */
+						}
+						if (L0453_B_NewGroupDirectionFound || ((!_vm->getRandomNumber(4) || (L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.M55_getSmellRange())) && (eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare))) {
+T0209073_SetDirectionGroup:
+							if (!L0453_B_NewGroupDirectionFound && (L0462_i_TicksSinceLastMove >= 0)) { /* If direction is not found yet then look around in a random direction */
+								AL0446_i_Direction = _vm->getRandomNumber(4);
+							}
+							f206_groupSetDirGroup(L0445_ps_ActiveGroup, AL0446_i_Direction, L0460_ui_CreatureCount, L0459_i_CreatureSize);
+						}
+						/* If event is kM3_TMEventTypeCreateReactionEvent29DangerOnSquare or kM2_TMEventTypeCreateReactionEvent30HitByProjectile */
+						if (eventType < kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) {
+							if (!L0453_B_NewGroupDirectionFound)
+								goto T0209139_Return;
+							if (L0458_B_SetBehavior7_ApproachAfterReaction) {
+								L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
+							}
+							f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+						}
+					}
+				}
+			} else {
+				if (AL0447_i_Behavior == k7_behavior_APPROACH) {
+					if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+						if ((L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.M56_getAttackRange()) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) /* If the creature is in range for attack and on the same row or column as the party on the map */
+							goto T0209044_SetBehavior6_Attack;
+T0209081_RunTowardParty:
+						L0461_i_MovementTicks++;
+						L0461_i_MovementTicks = L0461_i_MovementTicks >> 1; /* Running speed is half the movement ticks */
+						AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX);
+						AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY);
+					} else {
+T0209082_WalkTowardTarget:
+						AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_targetMapX;
+						AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY;
+						/* If the creature reached its target but the party is not there anymore */
+						if ((eventMapX == AL0450_i_TargetMapX) && (eventMapY == AL0451_i_TargetMapY)) {
+							L0453_B_NewGroupDirectionFound = false;
+							L0444_ps_Group->setBehaviour(k0_behavior_WANDER);
+							goto T0209073_SetDirectionGroup;
+						}
+					}
+					L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true;
+T0209084_SingleSquareMoveTowardParty:
+					L0454_i_PrimaryDirectionToOrFromParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY);
+T0209085_SingleSquareMove:
+					if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls) ||
+						f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls && _vm->getRandomNumber(2)) ||
+						f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction), false) ||
+						(!_vm->getRandomNumber(4) && f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty), false))) {
+						AL0450_i_DestinationMapX = eventMapX;
+						AL0451_i_DestinationMapY = eventMapY;
+						AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
+						goto T0209061_MoveGroup;
+					}
+					if (L0463_B_Archenemy) {
+T0209089_DoubleSquareMove:
+						f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false); /* BUG0_00 Useless code. Returned value is ignored. When Lord Chaos teleports two squares away the ability to move to the first square is ignored which means Lord Chaos can teleport through walls or any other obstacle */
+						if (f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty) ||
+							f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty) ||
+							(_g386_fluxCageCount && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction))) ||
+							((_g386_fluxCageCount >= 2) && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty)))) {
+							AL0450_i_DestinationMapX = eventMapX;
+							AL0451_i_DestinationMapY = eventMapY;
+							AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2;
+							warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+							goto T0209061_MoveGroup;
+						}
+					}
+					f206_groupSetDirGroup(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, L0460_ui_CreatureCount, L0459_i_CreatureSize);
+				} else {
+					if (AL0447_i_Behavior == k5_behavior_FLEE) {
+T0209094_FleeFromTarget:
+						L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true;
+						/* If the creature can see the party then update target coordinates */
+						if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+							AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX);
+							AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY);
+						} else {
+							if (!(--(L0445_ps_ActiveGroup->_delayFleeingFromTarget))) { /* If the creature is not afraid anymore then stop fleeing from target */
+T0209096_SetBehavior0_Wander:
+								L0453_B_NewGroupDirectionFound = false;
+								L0444_ps_Group->setBehaviour(k0_behavior_WANDER);
+								goto T0209073_SetDirectionGroup;
+							}
+							if (_vm->getRandomNumber(2)) {
+								/* If the creature cannot move and the party is adjacent then stop fleeing */
+								if (!f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false)) {
+									if (M38_distance(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)
+										goto T0209096_SetBehavior0_Wander;
+								}
+								/* Set creature target to the home square where the creature was located when the party entered the map */
+								AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_homeMapX;
+								AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_homeMapY;
+								goto T0209084_SingleSquareMoveTowardParty;
+							}
+							AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_targetMapX;
+							AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY;
+						}
+						/* Try and flee from the party (opposite direction) */
+						L0454_i_PrimaryDirectionToOrFromParty = returnOppositeDir((direction)f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY));
+						_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnOppositeDir((direction)_vm->_projexpl->_g363_secondaryDirToOrFromParty);
+						L0461_i_MovementTicks -= (L0461_i_MovementTicks >> 2);
+						goto T0209085_SingleSquareMove;
+					}
+				}
+			}
+		} else { /* Process events 38 to 41, Update Creature Behavior */
+			if (AL0447_i_Behavior == k5_behavior_FLEE) {
+				if (L0460_ui_CreatureCount) {
+					f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+				}
+				goto T0209094_FleeFromTarget;
+			}
+			/* If the creature is attacking, then compute the next aspect update time and the next attack time */
+			if (getFlag(L0445_ps_ActiveGroup->_aspect[AL0447_i_CreatureIndex = eventType - k38_TMEventTypeUpdateBehaviour_0], k0x0080_MaskActiveGroupIsAttacking)) {
+				L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false);
+				L0465_s_NextEvent._mapTime += ((AL0447_i_Ticks = L0448_s_CreatureInfo._attackTicks) + _vm->getRandomNumber(4) - 1);
+				if (AL0447_i_Ticks > 15) {
+					L0465_s_NextEvent._mapTime += _vm->getRandomNumber(8) - 2;
+				}
+			} else { /* If the creature is not attacking, then try attacking if possible */
+				if (AL0447_i_CreatureIndex > L0460_ui_CreatureCount) { /* Ignore event if it is for a creature that is not in the group */
+					goto T0209139_Return;
+				}
+				L0454_i_PrimaryDirectionToOrFromParty = _g382_currGroupPrimaryDirToParty;
+				/* If the party is visible, update the target coordinates */
+				if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, AL0447_i_CreatureIndex, eventMapX, eventMapY)) {
+					L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
+					L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+				}
+				/* If there is a single creature in the group that is not full square sized and 1/4 chance */
+				if (!L0460_ui_CreatureCount && (L0459_i_CreatureSize != k2_MaskCreatureSizeFull) && !((AL0446_i_GroupCellsCriteria = _vm->getRandomNumber(65536)) & 0x00C0)) {
+					if (L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) {
+						/* If the creature is not already on the center of the square then change its cell */
+						if (AL0446_i_GroupCellsCriteria & 0x0038) { /* 7/8 chances of changing cell to the center of the square */
+							L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature;
+						} else { /* 1/8 chance of changing cell to the next or previous cell on the square */
+							AL0446_i_GroupCellsCriteria = M21_normalizeModulo4(M21_normalizeModulo4(L0445_ps_ActiveGroup->_cells) + ((AL0446_i_GroupCellsCriteria & 0x0001) ? 1 : -1));
+						}
+					}
+					/* If 1/8 chance and the creature is not adjacent to the party and is a quarter square sized creature then process projectile impacts and update the creature cell if still alive. When the creature is not in front of the party, it has 7/8 chances of dodging a projectile by moving to another cell or staying in the center of the square */
+					if (!(AL0446_i_GroupCellsCriteria & 0x0038) && (L0452_i_DistanceToVisibleParty != 1) && (L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter)) {
+						if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* This call to F0218_PROJECTILE_GetImpactCount works fine because there is a single creature in the group so L0445_ps_ActiveGroup->Cells contains only one cell index */
+							goto T0209139_Return;
+						L0445_ps_ActiveGroup->_cells = M21_normalizeModulo4(AL0446_i_GroupCellsCriteria);
+					}
+				}
+				/* If the creature can see the party and is looking in the party direction or can attack in all direction */
+				if (L0452_i_DistanceToVisibleParty &&
+					(getFlag(L0448_s_CreatureInfo._attributes, k0x0004_MaskCreatureInfo_sideAttack) ||
+					 _vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) == L0454_i_PrimaryDirectionToOrFromParty)) {
+					/* If the creature is in range to attack the party and random test succeeds */
+					if ((L0452_i_DistanceToVisibleParty <= (AL0446_i_Range = L0448_s_CreatureInfo.M56_getAttackRange())) &&
+						(!AL0450_i_DistanceXToParty || !AL0451_i_DistanceYToParty) &&
+						(AL0446_i_Range <= (_vm->getRandomNumber(16) + 1))) {
+						if ((AL0446_i_Range == 1) &&
+							(!getFlag(AL0446_i_CreatureAttributes = L0448_s_CreatureInfo._attributes, k0x0008_MaskCreatureInfo_preferBackRow) || !_vm->getRandomNumber(4) || !getFlag(AL0446_i_CreatureAttributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) &&
+							(L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter) &&
+							(L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) &&
+							((AL0446_i_Cell = _vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex)) != L0454_i_PrimaryDirectionToOrFromParty) &&
+							(AL0446_i_Cell != returnNextVal(L0454_i_PrimaryDirectionToOrFromParty))) { /* If the creature cannot cast spells (range = 1) and is not on a cell where it can attack the party directly and is a quarter square sized creature not in the center of the square then the creature moves to another cell and attack does not occur immediately */
+							if (!L0460_ui_CreatureCount && _vm->getRandomNumber(2)) {
+								L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature;
+							} else {
+								if ((L0454_i_PrimaryDirectionToOrFromParty & 0x0001) == (AL0446_i_Cell & 0x0001)) {
+									AL0446_i_Cell--;
+								} else {
+									AL0446_i_Cell++;
+								}
+								if (!_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = M21_normalizeModulo4(AL0446_i_Cell)) ||
+									(_vm->getRandomNumber(2) && !_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */
+									if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* BUG0_70 A projectile impact on a creature may be ignored. The function F0218_PROJECTILE_GetImpactCount to detect projectile impacts when a quarter square sized creature moves inside a group (to another cell on the same square) may fail if there are several creatures in the group because the function expects a single cell index for its last parameter. The function should be called once for each cell where there is a creature */
+										goto T0209139_Return;
+									if (_vm->_projexpl->_g364_creatureDamageOutcome != k1_outcomeKilledSomeCreaturesInGroup) {
+										L0445_ps_ActiveGroup->_cells = f178_getGroupValueUpdatedWithCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex, AL0446_i_Cell);
+									}
+								}
+							}
+							L0465_s_NextEvent._mapTime += MAX(1, (L0448_s_CreatureInfo._movementTicks >> 1) + _vm->getRandomNumber(2)); /* Time for the creature to change cell */
+							L0465_s_NextEvent._type = eventType;
+							goto T0209135;
+						}
+						L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, f207_isCreatureAttacking(L0444_ps_Group, eventMapX, eventMapY, AL0447_i_CreatureIndex));
+						L0465_s_NextEvent._mapTime += (L0448_s_CreatureInfo._animationTicks & 0xF) + _vm->getRandomNumber(2);
+					} else {
+						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
+						if (L0460_ui_CreatureCount) {
+							f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+						}
+						goto T0209081_RunTowardParty;
+					}
+				} else {
+					/* If the party is visible, update target coordinates */
+					if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
+						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+						f205_setDirection(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
+						L0465_s_NextEvent._mapTime += 2;
+						L0464_l_NextAspectUpdateTime = M30_time(L0465_s_NextEvent._mapTime);
+					} else { /* If the party is not visible, move to the target (last known party location) */
+						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
+						if (L0460_ui_CreatureCount) {
+							f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+						}
+						goto T0209082_WalkTowardTarget;
+					}
+				}
+			}
+			L0465_s_NextEvent._type = eventType;
+			goto T0209136;
+		}
+		L0465_s_NextEvent._mapTime += MAX(1, _vm->getRandomNumber(4) + L0461_i_MovementTicks - 1);
+T0209134_SetEvent37:
+		L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup;
+	}
+T0209135:
+	if (!L0464_l_NextAspectUpdateTime) {
+		L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, kM1_wholeCreatureGroup, false);
+	}
+T0209136:
+	if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) {
+		L0465_s_NextEvent._mapTime += ticks;
+	} else {
+		L0464_l_NextAspectUpdateTime += ticks;
+	}
+	f208_groupAddEvent(&L0465_s_NextEvent, L0464_l_NextAspectUpdateTime);
+T0209139_Return:
+	;
+}
+
+bool GroupMan::f202_isMovementPossible(CreatureInfo* creatureInfo, int16 mapX, int16 mapY, uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls) {
+	int16 L0428_i_MapX;
+	int16 L0429_i_MapY;
+	uint16 L0430_ui_Square = 0;
+	int16 L0431_i_SquareType = 0;
+	Teleporter* L0432_ps_Teleporter;
+	Thing L0433_T_Thing;
+
+
+	_g384_groupMovementTestedDirections[dir] = true;
+	_g388_groupMovementBlockedByGroupThing = Thing::_endOfList;
+	_g389_groupMovementBlockedByDoor = false;
+	_g390_groupMovementBlockedByParty = false;
+	if (creatureInfo->_movementTicks == k255_immobile) {
+		return false;
+	}
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement((direction)dir, 1, 0, mapX, mapY);
+	L0428_i_MapX = mapX;
+	L0429_i_MapY = mapY;
+	if (_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter =
+		!(((L0428_i_MapX >= 0) && (L0428_i_MapX < _vm->_dungeonMan->_g273_currMapWidth)) &&
+		((L0429_i_MapY >= 0) && (L0429_i_MapY < _vm->_dungeonMan->_g274_currMapHeight)) &&
+		  ((L0431_i_SquareType = Square(L0430_ui_Square = _vm->_dungeonMan->_g271_currMapData[L0428_i_MapX][L0429_i_MapY]).getType()) != k0_ElementTypeWall) &&
+		  (L0431_i_SquareType != k3_ElementTypeStairs) &&
+		  ((L0431_i_SquareType != k2_ElementTypePit) || (getFlag(L0430_ui_Square, k0x0001_PitImaginary) && allowMovementOverImaginaryPitsAndFakeWalls) || !getFlag(L0430_ui_Square, k0x0008_PitOpen) || getFlag(creatureInfo->_attributes, k0x0020_MaskCreatureInfo_levitation)) &&
+		  ((L0431_i_SquareType != k6_ElementTypeFakeWall) || getFlag(L0430_ui_Square, k0x0004_FakeWallOpen) || (getFlag(L0430_ui_Square, k0x0001_FakeWallImaginary) && allowMovementOverImaginaryPitsAndFakeWalls)))) {
+		return false;
+	}
+	if (getFlag(creatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) {
+		L0433_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0428_i_MapX, L0429_i_MapY);
+		while (L0433_T_Thing != Thing::_endOfList) {
+			if ((L0433_T_Thing).getType() == k15_ExplosionThingType) {
+				L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(L0433_T_Thing);
+				if (((Explosion*)L0432_ps_Teleporter)->setType(k50_ExplosionType_Fluxcage)) {
+					_g385_fluxCages[dir] = true;
+					_g386_fluxCageCount++;
+					_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
+					return false;
+				}
+			}
+			L0433_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0433_T_Thing);
+		}
+	}
+	if ((L0431_i_SquareType == k5_ElementTypeTeleporter) && getFlag(L0430_ui_Square, k0x0008_TeleporterOpen) && (creatureInfo->M59_getWariness() >= 10)) {
+		L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
+		if (getFlag(L0432_ps_Teleporter->getScope(), k0x0001_TelepScopeCreatures) && !_vm->_dungeonMan->f139_isCreatureAllowedOnMap(_g380_currGroupThing, L0432_ps_Teleporter->getTargetMapIndex())) {
+			_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
+			return false;
+		}
+	}
+	if (_g390_groupMovementBlockedByParty = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0428_i_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0429_i_MapY == _vm->_dungeonMan->_g307_partyMapY)) {
+		return false;
+	}
+	if (L0431_i_SquareType == k4_DoorElemType) {
+		L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
+		if (((Square(L0430_ui_Square).getDoorState()) > (((Door*)L0432_ps_Teleporter)->opensVertically() ? creatureInfo->M51_height() : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
+			_g389_groupMovementBlockedByDoor = true;
+			return false;
+		}
+	}
+	return (_g388_groupMovementBlockedByGroupThing = _vm->_groupMan->f175_groupGetThing(L0428_i_MapX, L0429_i_MapY)) == Thing::_endOfList;
+}
+
+int16 GroupMan::f226_getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
+	return ((((srcMapX -= destMapX) < 0) ? -srcMapX : srcMapX) +
+		(((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY));
+}
+
+int16 GroupMan::f200_groupGetDistanceToVisibleParty(Group* group, int16 creatureIndex, int16 mapX, int16 mapY) {
+	int16 L0420_i_CreatureDirection;
+	int16 L0421_i_CreatureViewDirectionCount; /* Count of directions to test in L0425_ai_CreatureViewDirections */
+	int16 L0422_i_Multiple;
+#define AL0422_i_Counter    L0422_i_Multiple
+#define AL0422_i_SightRange L0422_i_Multiple
+	uint16 L0423_ui_GroupDirections;
+	CreatureInfo* L0424_ps_CreatureInfo;
+	int16 L0425_ai_CreatureViewDirections[4]; /* List of directions to test */
+
+
+	L0424_ps_CreatureInfo = &g243_CreatureInfo[group->_type];
+	if (_vm->_championMan->_g407_party._event71Count_Invisibility && !getFlag(L0424_ps_CreatureInfo->_attributes, k0x0800_MaskCreatureInfo_seeInvisible)) {
+		return 0;
+	}
+	if (getFlag(L0424_ps_CreatureInfo->_attributes, k0x0004_MaskCreatureInfo_sideAttack)) /* If creature can see in all directions */
+		goto T0200011;
+	L0423_ui_GroupDirections = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions;
+	if (creatureIndex < 0) { /* Negative index means test if each creature in the group can see the party in their respective direction */
+		L0421_i_CreatureViewDirectionCount = 0;
+		for (creatureIndex = group->getCount(); creatureIndex >= 0; creatureIndex--) {
+			L0420_i_CreatureDirection = M21_normalizeModulo4(L0423_ui_GroupDirections >> (creatureIndex << 1));
+			AL0422_i_Counter = L0421_i_CreatureViewDirectionCount;
+			while (AL0422_i_Counter--) {
+				if (L0425_ai_CreatureViewDirections[AL0422_i_Counter] == L0420_i_CreatureDirection) /* If the creature looks in the same direction as another one in the group */
+					goto T0200006;
+			}
+			L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount++] = L0420_i_CreatureDirection;
+T0200006:
+			;
+		}
+	} else { /* Positive index means test only if the specified creature in the group can see the party in its direction */
+		L0425_ai_CreatureViewDirections[0] = _vm->_groupMan->M50_getCreatureValue(L0423_ui_GroupDirections, creatureIndex);
+		L0421_i_CreatureViewDirectionCount = 1;
+	}
+	while (L0421_i_CreatureViewDirectionCount--) {
+		if (f227_isDestVisibleFromSource(L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount], mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY)) {
+T0200011:
+			AL0422_i_SightRange = L0424_ps_CreatureInfo->M54_getSightRange();
+			if (!getFlag(L0424_ps_CreatureInfo->_attributes, k0x1000_MaskCreatureInfo_nightVision)) {
+				AL0422_i_SightRange -= _vm->_displayMan->_g304_dungeonViewPaletteIndex >> 1;
+			}
+			if (_g381_currGroupDistanceToParty > MAX((int16)1, AL0422_i_SightRange)) {
+				return 0;
+			}
+			return f199_getDistanceBetweenUnblockedSquares(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f197_isViewPartyBlocked);
+		}
+	}
+	return 0;
+}
+
+int16 GroupMan::f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 srcMapY,
+														int16 destMapX, int16 destMapY, bool (GroupMan::*isBlocked)(uint16, uint16)) {
+	int16 L0410_i_XAxisStep;
+	int16 L0411_i_YAxisStep;
+	int16 L0412_i_Multiple;
+#define AL0412_i_DistanceX L0412_i_Multiple
+#define AL0412_i_PathMapX  L0412_i_Multiple
+	int16 L0413_i_Multiple;
+#define AL0413_i_DistanceY L0413_i_Multiple
+#define AL0413_i_PathMapY  L0413_i_Multiple
+	int16 L0414_i_LargestAxisDistance;
+	bool L0415_B_DistanceXSmallerThanDistanceY;
+	int16 L0416_i_ValueA;
+	int16 L0417_i_ValueB;
+	bool L0418_B_DistanceXEqualsDistanceY;
+	int16 L0419_i_ValueC;
+
+
+	if (M38_distance(srcMapX, srcMapY, destMapX, destMapY) <= 1) {
+		return 1;
+	}
+	L0415_B_DistanceXSmallerThanDistanceY = (AL0412_i_DistanceX = ((AL0412_i_DistanceX = destMapX - srcMapX) < 0) ? -AL0412_i_DistanceX : AL0412_i_DistanceX) < (AL0413_i_DistanceY = ((AL0413_i_DistanceY = destMapY - srcMapY) < 0) ? -AL0413_i_DistanceY : AL0413_i_DistanceY);
+	L0418_B_DistanceXEqualsDistanceY = (AL0412_i_DistanceX == AL0413_i_DistanceY);
+	L0410_i_XAxisStep = (((AL0412_i_PathMapX = destMapX) - srcMapX) > 0) ? -1 : 1;
+	L0411_i_YAxisStep = (((AL0413_i_PathMapY = destMapY) - srcMapY) > 0) ? -1 : 1;
+	L0419_i_ValueC = L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY - srcMapY) ? ((AL0412_i_PathMapX - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128)
+		: ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX - srcMapX) ? ((AL0413_i_PathMapY - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128);
+	/* 128 when the creature is on the same row or column as the party */
+	do {
+		if (L0418_B_DistanceXEqualsDistanceY) {
+			if (((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY) && (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX, AL0413_i_PathMapY + L0411_i_YAxisStep)) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX = AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY = AL0413_i_PathMapY + L0411_i_YAxisStep)) {
+				return 0;
+			}
+		} else {
+			if ((L0416_i_ValueA = ((L0414_i_LargestAxisDistance = (L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY - srcMapY) ? ((AL0412_i_PathMapX + L0410_i_XAxisStep - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX + L0410_i_XAxisStep - srcMapX) ? ((AL0413_i_PathMapY - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128)) - L0419_i_ValueC) < 0) ? -L0414_i_LargestAxisDistance : L0414_i_LargestAxisDistance) < (L0417_i_ValueB = ((L0414_i_LargestAxisDistance = (L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY + L0411_i_YAxisStep - srcMapY) ? ((AL0412_i_PathMapX - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX - srcMapX) ? ((AL0413_i_PathMapY + L0411_i_YAxisStep - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128)) - L0419_i_ValueC) < 0) ? -L0414_i_LargestAxisDistance : L0414_i_LargestAxisDistance)) {
+				AL0412_i_PathMapX += L0410_i_XAxisStep;
+			} else {
+				AL0413_i_PathMapY += L0411_i_YAxisStep;
+			}
+			if ((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX, AL0413_i_PathMapY) && ((L0416_i_ValueA != L0417_i_ValueB) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX = AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY = AL0413_i_PathMapY - L0411_i_YAxisStep))) {
+				return 0;
+			}
+		}
+	} while (M38_distance(AL0412_i_PathMapX, AL0413_i_PathMapY, srcMapX, srcMapY) > 1);
+	return f226_getDistanceBetweenSquares(srcMapX, srcMapY, destMapX, destMapY);
+}
+
+bool GroupMan::f197_isViewPartyBlocked(uint16 mapX, uint16 mapY) {
+	uint16 L0404_ui_Square;
+	int16 L0405_i_SquareType;
+	int16 L0406_i_DoorState;
+	Door* L0407_ps_Door;
+
+	if ((L0405_i_SquareType = Square(L0404_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k4_DoorElemType) {
+		L0407_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY);
+		return (((L0406_i_DoorState = Square(L0404_ui_Square).getDoorState()) == k3_doorState_FOURTH) || (L0406_i_DoorState == k4_doorState_CLOSED)) && !getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[L0407_ps_Door->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough);
+	}
+	return (L0405_i_SquareType == k0_ElementTypeWall) || ((L0405_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0404_ui_Square, k0x0004_FakeWallOpen));
+}
+
+int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup* activeGroup, int16 creatureIndex, bool isAttacking) {
+	uint16 L0326_ui_Multiple;
+#define AL0326_ui_Aspect         L0326_ui_Multiple
+#define AL0326_ui_AnimationTicks L0326_ui_Multiple
+	uint16 L0327_ui_CreatureGraphicInfo;
+	int16 L0328_i_Offset;
+	Group* L0329_ps_Group;
+	bool L0330_B_ProcessGroup;
+	uint16 L0331_ui_CreatureType;
+	uint16 L1635_ui_SoundIndex;
+
+	L0329_ps_Group = &(((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]);
+	L0327_ui_CreatureGraphicInfo = g243_CreatureInfo[L0331_ui_CreatureType = L0329_ps_Group->_type]._graphicInfo;
+	if (L0330_B_ProcessGroup = (creatureIndex < 0)) { /* If the creature index is negative then all creatures in the group are processed */
+		creatureIndex = L0329_ps_Group->getCount();
+	}
+	do {
+		AL0326_ui_Aspect = activeGroup->_aspect[creatureIndex];
+		AL0326_ui_Aspect &= k0x0080_MaskActiveGroupIsAttacking | k0x0040_MaskActiveGroupFlipBitmap;
+		if (L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 12) & 0x3)) {
+			L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset);
+			if (_vm->getRandomNumber(2)) {
+				L0328_i_Offset = (-L0328_i_Offset) & 0x0007;
+			}
+			AL0326_ui_Aspect |= L0328_i_Offset;
+		}
+		if (L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 14) & 0x3)) {
+			L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset);
+			if (_vm->getRandomNumber(2)) {
+				L0328_i_Offset = (-L0328_i_Offset) & 0x0007;
+			}
+			AL0326_ui_Aspect |= (L0328_i_Offset << 3);
+		}
+		if (isAttacking) {
+			if (getFlag(L0327_ui_CreatureGraphicInfo, k0x0200_CreatureInfoGraphicMaskFlipAttack)) {
+				if (getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) && (L0331_ui_CreatureType == k18_CreatureTypeAnimatedArmourDethKnight)) {
+					if (_vm->getRandomNumber(2)) {
+						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+						warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+					}
+				} else {
+					if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) {
+						if (_vm->getRandomNumber(2)) {
+							setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+						} else {
+							clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+						}
+					}
+				}
+			} else {
+				clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+			}
+			setFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking);
+		} else {
+			if (getFlag(L0327_ui_CreatureGraphicInfo, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) {
+				if (L0331_ui_CreatureType == k13_CreatureTypeCouatl) {
+					if (_vm->getRandomNumber(2)) {
+						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+						L1635_ui_SoundIndex = _vm->_movsens->f514_getSound(k13_CreatureTypeCouatl);
+						if (L1635_ui_SoundIndex <= k34_D13_soundCount) {
+							warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+						}
+					}
+				} else {
+					if (_vm->getRandomNumber(2)) {
+						setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+					} else {
+						clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+					}
+				}
+			} else {
+				clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+			}
+			clearFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking);
+		}
+		activeGroup->_aspect[creatureIndex] = AL0326_ui_Aspect;
+	} while (L0330_B_ProcessGroup && (creatureIndex--));
+	AL0326_ui_AnimationTicks = g243_CreatureInfo[L0329_ps_Group->_type]._animationTicks;
+	return _vm->_g313_gameTime + (isAttacking ? ((AL0326_ui_AnimationTicks >> 8) & 0xF) : ((AL0326_ui_AnimationTicks >> 4) & 0xF)) + _vm->getRandomNumber(2);
+}
+
+void GroupMan::f205_setDirection(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) {
+	uint16 L0435_ui_GroupDirections;
+	static long G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime; /* These two variables are used to prevent setting direction of half square sized creatures twice at the same game time */
+	static ActiveGroup* G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup;
+
+
+	warning("potentially dangerous cast to uint32 below");
+	if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == (uint32)G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) {
+		return;
+	}
+	if (M21_normalizeModulo4(_vm->_groupMan->M50_getCreatureValue(L0435_ui_GroupDirections = activeGroup->_directions, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */
+		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + dir));
+	} else {
+		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir);
+	}
+	if (twoHalfSquareSizedCreatures) {
+		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex ^ 1, dir); /* Set direction of the second half square sized creature */
+		G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime = _vm->_g313_gameTime;
+		G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup = activeGroup;
+	}
+	activeGroup->_directions = (direction)L0435_ui_GroupDirections;
+}
+
+void GroupMan::f208_groupAddEvent(TimelineEvent* event, uint32 time) {
+	warning("potentially dangerous cast to uint32 below");
+	if (time < (uint32)M30_time(event->_mapTime)) {
+		event->_type -= 5;
+		event->_C._ticks = M30_time(event->_mapTime) - time;
+		M32_setTime(event->_mapTime, time);
+	} else {
+		event->_C._ticks = time - M30_time(event->_mapTime);
+	}
+	_vm->_timeline->f238_addEventGetEventIndex(event);
+}
+
+int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo* creatureInfo, int16 mapY, int16 mapX) {
+
+	uint16 L0426_ui_SmellRange;
+	int16 L0427_i_ScentOrdinal;
+
+
+	if (!(L0426_ui_SmellRange = creatureInfo->M55_getSmellRange())) {
+		return 0;
+	}
+	if ((((L0426_ui_SmellRange + 1) >> 1) >= _g381_currGroupDistanceToParty) && f199_getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f198_isSmellPartyBlocked)) {
+		_vm->_projexpl->_g363_secondaryDirToOrFromParty = _g383_currGroupSecondaryDirToParty;
+		return _vm->M0_indexToOrdinal(_g382_currGroupPrimaryDirToParty);
+	}
+	if ((L0427_i_ScentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapY, mapX)) && ((_vm->_championMan->_g407_party._scentStrengths[_vm->M1_ordinalToIndex(L0427_i_ScentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (L0426_ui_SmellRange << 1)))) { /* If there is a fresh enough party scent on the group square */
+		return _vm->M0_indexToOrdinal(f228_getDirsWhereDestIsVisibleFromSource(mapY, mapX, _vm->_championMan->_g407_party._scents[L0427_i_ScentOrdinal].getMapX(), _vm->_championMan->_g407_party._scents[L0427_i_ScentOrdinal].getMapY()));
+	}
+	return 0;
+}
+
+bool GroupMan::f198_isSmellPartyBlocked(uint16 mapX, uint16 mapY) {
+	uint16 L0408_ui_Square;
+	int16 L0409_i_SquareType;
+
+	return ((L0409_i_SquareType = Square(L0408_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k0_ElementTypeWall) || ((L0409_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0408_ui_Square, k0x0004_FakeWallOpen));
+}
+
+int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo* info, int16 mapX, int16 mapY, bool allowMovementOverImaginaryPitsAndFakeWalls) {
+	int16 L0434_i_Direction;
+
+
+	for (L0434_i_Direction = kDirNorth; L0434_i_Direction <= kDirWest; L0434_i_Direction++) {
+		if ((!_g384_groupMovementTestedDirections[L0434_i_Direction]) && f202_isMovementPossible(info, mapX, mapY, L0434_i_Direction, allowMovementOverImaginaryPitsAndFakeWalls)) {
+			return _vm->M0_indexToOrdinal(L0434_i_Direction);
+		}
+	}
+	return 0;
+}
+
+void GroupMan::f206_groupSetDirGroup(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, int16 creatureSize) {
+	bool L0436_B_TwoHalfSquareSizedCreatures;
+
+
+	if (L0436_B_TwoHalfSquareSizedCreatures = creatureIndex && (creatureSize == k1_MaskCreatureSizeHalf)) {
+		creatureIndex--;
+	}
+	do {
+		if (!creatureIndex || _vm->getRandomNumber(2)) {
+			f205_setDirection(activeGroup, dir, creatureIndex, L0436_B_TwoHalfSquareSizedCreatures);
+		}
+	} while (creatureIndex--);
+}
+
+void GroupMan::f182_stopAttacking(ActiveGroup* group, int16 mapX, int16 mapY) {
+	int16 L0337_i_CreatureIndex;
+
+	for (L0337_i_CreatureIndex = 0; L0337_i_CreatureIndex < 4; clearFlag(group->_aspect[L0337_i_CreatureIndex++], k0x0080_MaskActiveGroupIsAttacking));
+	f181_groupDeleteEvents(mapX, mapY);
+
+}
+
+bool GroupMan::f204_isArchenemyDoubleMovementPossible(CreatureInfo* info, int16 mapX, int16 mapY, uint16 dir) {
+	if (_g385_fluxCages[dir]) {
+		return false;
+	}
+	mapX += _vm->_dirIntoStepCountEast[dir], mapY += _vm->_dirIntoStepCountNorth[dir];
+	return f202_isMovementPossible(info, mapX, mapY, dir, false);
+}
+
+bool GroupMan::f207_isCreatureAttacking(Group* group, int16 mapX, int16 mapY, uint16 creatureIndex) {
+	uint16 L0437_ui_Multiple;
+#define AL0437_ui_CreatureType L0437_ui_Multiple
+#define AL0437_T_Thing         L0437_ui_Multiple
+	uint16 L0438_ui_PrimaryDirectionToParty;
+	int16 L0439_i_Multiple;
+#define AL0439_i_GroupCells    L0439_i_Multiple
+#define AL0439_i_TargetCell    L0439_i_Multiple
+#define AL0439_i_ChampionIndex L0439_i_Multiple
+	int16 L0440_i_Multiple;
+#define AL0440_i_KineticEnergy      L0440_i_Multiple
+#define AL0440_i_Counter            L0440_i_Multiple
+#define AL0440_i_Damage             L0440_i_Multiple
+#define AL0440_i_AttackSoundOrdinal L0440_i_Multiple
+	CreatureInfo* L0441_ps_CreatureInfo;
+	Champion* L0442_ps_Champion;
+	ActiveGroup L0443_s_ActiveGroup;
+
+
+	_vm->_projexpl->_g361_lastCreatureAttackTime = _vm->_g313_gameTime;
+	L0443_s_ActiveGroup = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
+	L0441_ps_CreatureInfo = &g243_CreatureInfo[AL0437_ui_CreatureType = group->_type];
+	L0438_ui_PrimaryDirectionToParty = _g382_currGroupPrimaryDirToParty;
+	if ((AL0439_i_GroupCells = L0443_s_ActiveGroup._cells) == k255_CreatureTypeSingleCenteredCreature) {
+		AL0439_i_TargetCell = _vm->getRandomNumber(2);
+	} else {
+		AL0439_i_TargetCell = ((_vm->_groupMan->M50_getCreatureValue(AL0439_i_GroupCells, creatureIndex) + 5 - L0438_ui_PrimaryDirectionToParty) & 0x0002) >> 1;
+	}
+	AL0439_i_TargetCell += L0438_ui_PrimaryDirectionToParty;
+	AL0439_i_TargetCell &= 0x0003;
+	if ((L0441_ps_CreatureInfo->M56_getAttackRange() > 1) && ((_g381_currGroupDistanceToParty > 1) || _vm->getRandomNumber(2))) {
+		switch (AL0437_ui_CreatureType) {
+		case k14_CreatureTypeVexirk:
+		case k23_CreatureTypeLordChaos:
+			if (_vm->getRandomNumber(2)) {
+				AL0437_T_Thing = Thing::_explFireBall.toUint16();
+			} else {
+				switch (_vm->getRandomNumber(4)) {
+				case 0:
+					AL0437_T_Thing = Thing::_explHarmNonMaterial.toUint16();
+					break;
+				case 1:
+					AL0437_T_Thing = Thing::_explLightningBolt.toUint16();
+					break;
+				case 2:
+					AL0437_T_Thing = Thing::_explPoisonCloud.toUint16();
+					break;
+				case 3:
+					AL0437_T_Thing = Thing::_explOpenDoor.toUint16();
+				}
+			}
+			break;
+		case k1_CreatureTypeSwampSlimeSlime:
+			AL0437_T_Thing = Thing::_explSlime.toUint16();
+			break;
+		case k3_CreatureTypeWizardEyeFlyingEye:
+			if (_vm->getRandomNumber(8)) {
+				AL0437_T_Thing = Thing::_explLightningBolt.toUint16();
+			} else {
+				AL0437_T_Thing = Thing::_explOpenDoor.toUint16();
+			}
+			break;
+		case k19_CreatureTypeMaterializerZytaz:
+			if (_vm->getRandomNumber(2)) {
+				AL0437_T_Thing = Thing::_explPoisonCloud.toUint16();
+				break;
+			}
+		case k22_CreatureTypeDemon:
+		case k24_CreatureTypeRedDragon:
+			AL0437_T_Thing = Thing::_explFireBall.toUint16();
+		} /* BUG0_13 The game may crash when 'Lord Order' or 'Grey Lord' cast spells. This cannot happen with the original dungeons as they do not contain any groups of these types. 'Lord Order' and 'Grey Lord' creatures can cast spells (attack range > 1) but no projectile type is defined for them in the code. If these creatures are present in a dungeon they will cast projectiles containing undefined things because the variable is not initialized */
+		AL0440_i_KineticEnergy = (L0441_ps_CreatureInfo->_attack >> 2) + 1;
+		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
+		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
+		warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+		_vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
+	} else {
+		if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) {
+			AL0439_i_ChampionIndex = _vm->getRandomNumber(4);
+			for (AL0440_i_Counter = 0; (AL0440_i_Counter < 4) && !_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex]._currHealth; AL0440_i_Counter++) {
+				AL0439_i_ChampionIndex = returnNextVal(AL0439_i_ChampionIndex);
+			}
+			if (AL0440_i_Counter == 4) {
+				return false;
+			}
+		} else {
+			if ((AL0439_i_ChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(mapX, mapY, AL0439_i_TargetCell)) < 0) {
+				return false;
+			}
+		}
+		if (AL0437_ui_CreatureType == k2_CreatureTypeGiggler) {
+			f193_stealFromChampion(group, AL0439_i_ChampionIndex);
+		} else {
+			AL0440_i_Damage = f230_getChampionDamage(group, AL0439_i_ChampionIndex) + 1;
+			L0442_ps_Champion = &_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex];
+			if (AL0440_i_Damage > L0442_ps_Champion->_maximumDamageReceived) {
+				L0442_ps_Champion->_maximumDamageReceived = AL0440_i_Damage;
+				L0442_ps_Champion->_directionMaximumDamageReceived = returnOppositeDir((direction)L0438_ui_PrimaryDirectionToParty);
+			}
+		}
+	}
+	if (AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal) {
+		warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+	}
+	return true;
+}
+
+void GroupMan::f229_setOrderedCellsToAttack(signed char* orderedCellsToAttack, int16 targetMapX, int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource) {
+	static signed char g23_orderedCellsToAttack[8][4] = { // @ G0023_aac_Graphic562_OrderedCellsToAttack
+		{0, 1, 3, 2},   /* Attack South from position Northwest or Southwest */
+		{1, 0, 2, 3},   /* Attack South from position Northeast or Southeast */
+		{1, 2, 0, 3},   /* Attack West from position Northwest or Northeast */
+		{2, 1, 3, 0},   /* Attack West from position Southeast or Southwest */
+		{3, 2, 0, 1},   /* Attack North from position Northwest or Southwest */
+		{2, 3, 1, 0},   /* Attack North from position Southeast or Northeast */
+		{0, 3, 1, 2},   /* Attack East from position Northwest or Northeast */
+		{3, 0, 2, 1}}; /* Attack East from position Southeast or Southwest */
+	uint16 L0557_ui_OrderedCellsToAttackIndex;
+
+
+	if (!((L0557_ui_OrderedCellsToAttackIndex = f228_getDirsWhereDestIsVisibleFromSource(targetMapX, targetMapY, attackerMapX, attackerMapY) << 1) & 0x0002)) {
+		cellSource++;
+	}
+	L0557_ui_OrderedCellsToAttackIndex += (cellSource >> 1) & 0x0001;
+	for (uint16 i = 0; i < 4; ++i)
+		orderedCellsToAttack[i] = g23_orderedCellsToAttack[L0557_ui_OrderedCellsToAttackIndex][i];
+}
+
+void GroupMan::f193_stealFromChampion(Group* group, uint16 championIndex) {
+	int16 L0391_i_Percentage;
+	uint16 L0392_ui_StealFromSlotIndex;
+	uint16 L0393_ui_Counter;
+	Thing L0394_T_Thing;
+	Champion* L0395_ps_Champion;
+	bool L0396_B_ObjectStolen;
+	static unsigned char G0394_auc_StealFromSlotIndices[8]; /* Initialized with 0 bytes by C loader */
+
+
+	L0396_B_ObjectStolen = false;
+	L0391_i_Percentage = 100 - _vm->_championMan->f311_getDexterity(L0395_ps_Champion = &_vm->_championMan->_gK71_champions[championIndex]);
+	L0393_ui_Counter = _vm->getRandomNumber(8);
+	while ((L0391_i_Percentage > 0) && !_vm->_championMan->f308_isLucky(L0395_ps_Champion, L0391_i_Percentage)) {
+		if ((L0392_ui_StealFromSlotIndex = G0394_auc_StealFromSlotIndices[L0393_ui_Counter]) == k13_ChampionSlotBackpackLine_1_1) {
+			L0392_ui_StealFromSlotIndex += _vm->getRandomNumber(17); /* Select a random slot in the backpack */
+		}
+		if (((L0394_T_Thing = L0395_ps_Champion->_slots[L0392_ui_StealFromSlotIndex]) != Thing::_none)) {
+			L0396_B_ObjectStolen = true;
+			L0394_T_Thing = _vm->_championMan->f300_getObjectRemovedFromSlot(championIndex, L0392_ui_StealFromSlotIndex);
+			if (group->_slot == Thing::_endOfList) {
+				group->_slot = L0394_T_Thing; /* BUG0_12 An object is cloned and appears at two different locations in the dungeon and/or inventory. The game may crash when interacting with this object. If a Giggler with no possessions steals an object that was previously in a chest and was not the last object in the chest then the objects that followed it are cloned. In the chest, the object is part of a linked list of objects that is not reset when the object is removed from the chest and placed in the inventory (but not in the dungeon), nor when it is stolen and added as the first Giggler possession. If the Giggler already has a possession before stealing the object then this does not create a cloned object.
+											 The following statement is missing: L0394_T_Thing->Next = Thing::_endOfList;
+											 This creates cloned things if L0394_T_Thing->Next is not Thing::_endOfList which is the case when the object comes from a chest in which it was not the last object */
+			} else {
+				_vm->_dungeonMan->f163_linkThingToList(L0394_T_Thing, group->_slot, kM1_MapXNotOnASquare, 0);
+			}
+			_vm->_championMan->f292_drawChampionState((ChampionIndex)championIndex);
+		}
+		++L0393_ui_Counter;
+		L0393_ui_Counter &= 0x0007;
+		L0391_i_Percentage -= 20;
+	}
+	if (!_vm->getRandomNumber(8) || (L0396_B_ObjectStolen && _vm->getRandomNumber(2))) {
+		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._delayFleeingFromTarget = _vm->getRandomNumber(64) + 20;
+		group->setBehaviour(k5_behavior_FLEE);
+	}
+}
+
+int16 GroupMan::f230_getChampionDamage(Group* group, uint16 champIndex) {
+	unsigned char g24_woundProbabilityIndexToWoundMask[4] = {32, 16, 8, 4}; // @ G0024_auc_Graphic562_WoundProbabilityIndexToWoundMask
+
+	Champion* L0562_ps_Champion;
+	int16 L0558_i_Multiple;
+#define AL0558_i_Attack L0558_i_Multiple
+#define AL0558_i_Damage L0558_i_Multiple
+	uint16 L0559_ui_Multiple;
+#define AL0559_ui_WoundTest          L0559_ui_Multiple
+#define AL0559_ui_PoisonAttack       L0559_ui_Multiple
+#define AL0559_ui_CreatureDifficulty L0559_ui_Multiple
+	uint16 L0560_ui_WoundProbabilities;
+	uint16 L0561_ui_Multiple;
+#define AL0561_ui_WoundProbabilityIndex L0561_ui_Multiple
+#define AL0561_ui_AllowedWound          L0561_ui_Multiple
+	int16 L0563_i_DoubledMapDifficulty;
+	CreatureInfo L0564_s_CreatureInfo;
+
+
+	L0562_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
+		return 0;
+	}
+	if (!L0562_ps_Champion->_currHealth) {
+		return 0;
+	}
+	if (_vm->_championMan->_g300_partyIsSleeping) {
+		_vm->_championMan->f314_wakeUp();
+	}
+	L0563_i_DoubledMapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty << 1;
+	L0564_s_CreatureInfo = g243_CreatureInfo[group->_type];
+	_vm->_championMan->f304_addSkillExperience(champIndex, k7_ChampionSkillParry, L0564_s_CreatureInfo.M58_getExperience());
+	if (_vm->_championMan->_g300_partyIsSleeping || (((_vm->_championMan->f311_getDexterity(L0562_ps_Champion) < (_vm->getRandomNumber(32) + L0564_s_CreatureInfo._dexterity + L0563_i_DoubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !_vm->_championMan->f308_isLucky(L0562_ps_Champion, 60))) {
+		if ((AL0559_ui_WoundTest = _vm->getRandomNumber(65536)) & 0x0070) {
+			AL0559_ui_WoundTest &= 0x000F;
+			L0560_ui_WoundProbabilities = L0564_s_CreatureInfo._woundProbabilities;
+			for (AL0561_ui_WoundProbabilityIndex = 0; AL0559_ui_WoundTest > (L0560_ui_WoundProbabilities & 0x000F); L0560_ui_WoundProbabilities >>= 4) {
+				AL0561_ui_WoundProbabilityIndex++;
+			}
+			AL0561_ui_AllowedWound = g24_woundProbabilityIndexToWoundMask[AL0561_ui_WoundProbabilityIndex];
+		} else {
+			AL0561_ui_AllowedWound = AL0559_ui_WoundTest & 0x0001; /* 0 (Ready hand) or 1 (action hand) */
+		}
+		if ((AL0558_i_Attack = (_vm->getRandomNumber(16) + L0564_s_CreatureInfo._attack + L0563_i_DoubledMapDifficulty) - (_vm->_championMan->f303_getSkillLevel(champIndex, k7_ChampionSkillParry) << 1)) <= 1) {
+			if (_vm->getRandomNumber(2)) {
+				goto T0230014;
+			}
+			AL0558_i_Attack = _vm->getRandomNumber(4) + 2;
+		}
+		AL0558_i_Attack >>= 1;
+		AL0558_i_Attack += _vm->getRandomNumber(AL0558_i_Attack) + _vm->getRandomNumber(4);
+		AL0558_i_Attack += _vm->getRandomNumber(AL0558_i_Attack);
+		AL0558_i_Attack >>= 2;
+		AL0558_i_Attack += _vm->getRandomNumber(4) + 1;
+		if (_vm->getRandomNumber(2)) {
+			AL0558_i_Attack -= _vm->getRandomNumber((AL0558_i_Attack >> 1) + 1) - 1;
+		}
+		if (AL0558_i_Damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType)) {
+			warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			if ((AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack) && _vm->getRandomNumber(2) && ((AL0559_ui_PoisonAttack = _vm->_championMan->f307_getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack)) >= 0)) {
+				_vm->_championMan->f322_championPoison(champIndex, AL0559_ui_PoisonAttack);
+			}
+			return AL0558_i_Damage;
+		}
+	}
+T0230014:
+	return 0;
+}
+
+void GroupMan::f187_dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY) {
+	Group* L0363_ps_Group;
+	int16 L0364_i_CreatureType;
+
+
+	if (_g391_dropMovingCreatureFixedPossCellCount) {
+		L0363_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing);
+		L0364_i_CreatureType = L0363_ps_Group->_type;
+		while (_g391_dropMovingCreatureFixedPossCellCount) {
+			f186_dropCreatureFixedPossessions(L0364_i_CreatureType, mapX, mapY, _g392_dropMovingCreatureFixedPossessionsCell[--_g391_dropMovingCreatureFixedPossCellCount], k2_soundModePlayOneTickLater);
+		}
+	}
+}
+
+void GroupMan::f180_startWanedring(int16 mapX, int16 mapY) {
+	Group* L0332_ps_Group;
+	TimelineEvent L0333_s_Event;
+
+
+	L0332_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(mapX, mapY));
+	if (L0332_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
+		L0332_ps_Group->setBehaviour(k0_behavior_WANDER);
+	}
+	M33_setMapAndTime(L0333_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, (_vm->_g313_gameTime + 1));
+	L0333_s_Event._type = k37_TMEventTypeUpdateBehaviourGroup;
+	L0333_s_Event._priority = 255 - g243_CreatureInfo[L0332_ps_Group->_type]._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
+	L0333_s_Event._C._ticks = 0;
+	L0333_s_Event._B._location._mapX = mapX;
+	L0333_s_Event._B._location._mapY = mapY;
+	_vm->_timeline->f238_addEventGetEventIndex(&L0333_s_Event);
+}
+
+void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
+	uint16 L0339_ui_CreatureIndex;
+	Group* L0340_ps_Group;
+	ActiveGroup* L0341_ps_ActiveGroup;
+	int16 L0344_i_ActiveGroupIndex;
+
+
+	L0341_ps_ActiveGroup = _vm->_groupMan->_g375_activeGroups;
+	L0344_i_ActiveGroupIndex = 0;
+	while (L0341_ps_ActiveGroup->_groupThingIndex >= 0) {
+		if (++L0344_i_ActiveGroupIndex >= _vm->_groupMan->_g376_maxActiveGroupCount) {
+			return; /* BUG0_11 Data corruption in memory. Each group located on the same map as the party has additional associated data but there is only provision for 60 instances (_vm->_groupMan->_g376_maxActiveGroupCount). If there are more groups at the same time then some of them do not get their instance and when the game accesses this information it will corrupt other data in memory (either the instance of another group, parts of the timeline or events). This situation cannot occur in the original Dungeon Master and Chaos Strikes Back dungeons for the following reasons (but it may occur in custom dungeons if they are not designed carefully): there is no map with already more than 60 groups in the original dungeons and none of the following 3 possible ways to move a group into a map can increase the number of instances above the maximum of 60:
+					- A group generator sensor is triggered: the game never generates a group on the party map if there are less than 5 instances available. This limits the actual number of groups on a map to 55 in most cases.
+					- A group falls through a pit from the map above (the creature type must be allowed on the target map): a group will never willingly move to an open pit square. It may move to a closed pit square and fall if the pit is then open (either automatically or triggered by the party on the map below). There are no such pits in the original dungeons.
+					- A group is teleported from another map (the creature type must be allowed on the target map): in the original dungeons, all teleporters whose scope include groups and target another map are either inaccessible to groups or the groups are not allowed on the target map. The only exception is for some Gigglers in the Chaos Strikes Back dungeon but there are not enough to use the 5 reserved instances.
+
+					This code returns immediately if all ACTIVE_GROUP entries are already in use, which avoids an out of bounds access into _vm->_groupMan->_g375_activeGroups below (through L0341_ps_ActiveGroup). However in this case the specified group ends up without an associated ACTIVE_GROUP structure which is assumed everywhere in the code to be present for groups on the same map as the party. If there are more than 60 groups on the party map at any given time then this will corrupt memory (in _vm->_timeline->_g370_events and _vm->_timeline->_g371_timeline allocated in _vm->_timeline->f233_initTimeline before _vm->_groupMan->_g375_activeGroups) because of read and write operations at incorrect memory addresses (the 'Cells' value of the GROUP will be used as an index in _vm->_groupMan->_g375_activeGroups even though that value was not replaced by the index of an ACTIVE_GROUP in this function) */
+		}
+		L0341_ps_ActiveGroup++;
+	}
+	_g377_currActiveGroupCount++;
+	L0340_ps_Group = ((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType());
+	L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells;
+	L0340_ps_Group->getActiveGroupIndex() = L0344_i_ActiveGroupIndex;
+	L0341_ps_ActiveGroup->_priorMapX = L0341_ps_ActiveGroup->_homeMapX = mapX;
+	L0341_ps_ActiveGroup->_priorMapY = L0341_ps_ActiveGroup->_homeMapY = mapY;
+	L0341_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime - 127;
+	L0339_ui_CreatureIndex = L0340_ps_Group->getCount();
+	do {
+		L0341_ps_ActiveGroup->_directions = (direction)f178_getGroupValueUpdatedWithCreatureValue(L0341_ps_ActiveGroup->_directions, L0339_ui_CreatureIndex, L0340_ps_Group->getDir());
+		L0341_ps_ActiveGroup->_aspect[L0339_ui_CreatureIndex] = 0;
+	} while (L0339_ui_CreatureIndex--);
+	f179_getCreatureAspectUpdateTime(L0341_ps_ActiveGroup, kM1_wholeCreatureGroup, false);
+}
+
+void GroupMan::f184_removeActiveGroup(uint16 activeGroupIndex) {
+	ActiveGroup* L0347_ps_ActiveGroup;
+	Group* L0348_ps_Group;
+
+
+	if ((activeGroupIndex > _vm->_groupMan->_g376_maxActiveGroupCount) || (_vm->_groupMan->_g375_activeGroups[activeGroupIndex]._groupThingIndex < 0)) {
+		return;
+	}
+	L0347_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[activeGroupIndex];
+	L0348_ps_Group = &((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex];
+	_g377_currActiveGroupCount--;
+	L0348_ps_Group->_cells = L0347_ps_ActiveGroup->_cells;
+	L0348_ps_Group->setDir(M21_normalizeModulo4(L0347_ps_ActiveGroup->_directions));
+	if (L0348_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
+		L0348_ps_Group->setBehaviour(k0_behavior_WANDER);
+	}
+	L0347_ps_ActiveGroup->_groupThingIndex = -1;
+}
 }
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 76cb8b2..151594a 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -32,7 +32,10 @@
 #include "dm.h"
 
 namespace DM {
-// this doesn't seem to be used anywhere at all
+	class TimelineEvent;
+	class CreatureInfo;
+
+	// this doesn't seem to be used anywhere at all
 /* Creature types */
 enum CreatureType {
 	k0_CreatureTypeGiantScorpionScorpion = 0, // @ C00_CREATURE_GIANT_SCORPION_SCORPION     
@@ -107,8 +110,8 @@ class Group {
 public:
 	Thing _nextThing;
 	Thing _slot;
-	byte _type;
-	byte _cells;
+	uint16 _type;
+	uint16 _cells;
 	uint16 _health[4];
 private:
 	uint16 _flags;
@@ -121,20 +124,57 @@ public:
 		_health[3] = rawDat[7];
 	}
 
-	byte &getActiveGroupIndex() { return _cells; }
+	byte &getActiveGroupIndex() { return *(byte*)&_cells; }
 
 	uint16 getBehaviour() { return _flags & 0xF; }
+	uint16 setBehaviour(uint16 val) { _flags = (_flags & ~0xF) | (val & 0xF); return (val & 0xF); }
 	uint16 getCount() { return (_flags >> 5) & 0x3; }
+	void setCount(uint16 val) { _flags = (_flags & ~(0x3 << 5)) | ((val & 0x3) << 5); }
 	direction getDir() { return (direction)((_flags >> 8) & 0x3); }
+	void setDir(uint16 val) { _flags = (_flags & ~(0x3 << 8)) | ((val & 0x3) << 8); }
 	uint16 getDoNotDiscard() { return (_flags >> 10) & 0x1; }
 }; // @ GROUP
 
+#define k0_behavior_WANDER 0 // @ C0_BEHAVIOR_WANDER
+#define k2_behavior_USELESS 2 // @ C2_BEHAVIOR_USELESS
+#define k3_behavior_USELESS 3 // @ C3_BEHAVIOR_USELESS
+#define k4_behavior_USELESS 4 // @ C4_BEHAVIOR_USELESS
+#define k5_behavior_FLEE 5 // @ C5_BEHAVIOR_FLEE
+#define k6_behavior_ATTACK 6 // @ C6_BEHAVIOR_ATTACK
+#define k7_behavior_APPROACH 7 // @ C7_BEHAVIOR_APPROACH
+
+#define k15_immuneToFear 15 // @ C15_IMMUNE_TO_FEAR
+
+#define k255_immobile 255 // @ C255_IMMOBILE
+#define kM1_wholeCreatureGroup -1 // @ CM1_WHOLE_CREATURE_GROUP 
+
+#define k34_D13_soundCount 34 // @ D13_SOUND_COUNT
+
+int32 M32_setTime(int32 &map_time, int32 time); // @ M32_SET_TIME
+
 
 class GroupMan {
 	DMEngine *_vm;
+	byte _g392_dropMovingCreatureFixedPossessionsCell[4]; // @ G0392_auc_DropMovingCreatureFixedPossessionsCells
+	uint16 _g391_dropMovingCreatureFixedPossCellCount; // @ G0391_ui_DropMovingCreatureFixedPossessionsCellCount
+	uint16 _g386_fluxCageCount; // @ G0386_ui_FluxCageCount
+	int16 _g385_fluxCages[4]; // @ G0385_ac_FluxCages
+	int16 _g378_currentGroupMapX; // @ G0378_i_CurrentGroupMapX
+	int16 _g379_currentGroupMapY; // @ G0379_i_CurrentGroupMapY
+	Thing _g380_currGroupThing; // @ G0380_T_CurrentGroupThing
+	int16 _g384_groupMovementTestedDirections[4]; // @ G0384_auc_GroupMovementTestedDirections
+	uint16 _g381_currGroupDistanceToParty; // @ G0381_ui_CurrentGroupDistanceToParty
+	int16 _g382_currGroupPrimaryDirToParty; // @ G0382_i_CurrentGroupPrimaryDirectionToParty
+	int16 _g383_currGroupSecondaryDirToParty; // @ G0383_i_CurrentGroupSecondaryDirectionToParty
+
+	Thing _g388_groupMovementBlockedByGroupThing; // @ G0388_T_GroupMovementBlockedByGroupThing
+	bool _g389_groupMovementBlockedByDoor; // @ G0389_B_GroupMovementBlockedByDoor
+	bool _g390_groupMovementBlockedByParty; // @ G0390_B_GroupMovementBlockedByParty
+	bool _g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter; // @ G0387_B_GroupMovementBlockedByWallStairsPitFakeWallFluxcageTeleporter
 public:
 	uint16 _g376_maxActiveGroupCount = 60; // @ G0376_ui_MaximumActiveGroupCount
 	ActiveGroup *_g375_activeGroups; // @ G0375_ps_ActiveGroups
+	uint16 _g377_currActiveGroupCount; // @ G0377_ui_CurrentActiveGroupCount
 	GroupMan(DMEngine *vm);
 	~GroupMan();
 	void f196_initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups
@@ -142,6 +182,61 @@ public:
 	uint16 f147_getGroupDirections(Group *group, int16 mapIndex); // @ F0147_DUNGEON_GetGroupDirections
 	int16 f176_getCreatureOrdinalInCell(Group *group, uint16 cell); // @ F0176_GROUP_GetCreatureOrdinalInCell
 	uint16 M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex); // @ M50_CREATURE_VALUE
+	void f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode); // @ F0188_GROUP_DropGroupPossessions
+	void f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int16 mapY, uint16 cell,
+										   int16 mode); // @ F0186_GROUP_DropCreatureFixedPossessions
+	int16 f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY,
+												   int16 destMapX, int16 destMapY); // @ F0228_GROUP_GetDirectionsWhereDestinationIsVisibleFromSource
+	bool f227_isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 srcMapY, int16 destMapX,
+									  int16 destMapY); // @ F0227_GROUP_IsDestinationVisibleFromSource
+	bool f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack,
+										   bool magicAttack, int16 ticks); // @ F0232_GROUP_IsDoorDestroyedByAttack
+	Thing f175_groupGetThing(int16 mapX, int16 mapY); // @ F0175_GROUP_GetThing
+	int16 f190_groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex,
+											 int16 mapX, int16 mapY, int16 damage, bool notMoving); // @ F0190_GROUP_GetDamageCreatureOutcome
+	void f189_delete(int16 mapX, int16 mapY); // @ F0189_GROUP_Delete
+	void f181_groupDeleteEvents(int16 mapX, int16 mapY); // @ F0181_GROUP_DeleteEvents
+	uint16 f178_getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatreVal); // @ F0178_GROUP_GetGroupValueUpdatedWithCreatureValue
+	int16 f191_getDamageAllCreaturesOutcome(Group *group, int16 mapX, int16 mapY, int16 attack, bool notMoving); // @ F0191_GROUP_GetDamageAllCreaturesOutcome
+	int16 f192_groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack); // @ F0192_GROUP_GetResistanceAdjustedPoisonAttack
+	void f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks); // @ F0209_GROUP_ProcessEvents29to41
+	bool f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, int16 mapY,
+								 uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls); // @ F0202_GROUP_IsMovementPossible
+	int16 f226_getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 destMapX,
+										 int16 destMapY); // @ F0226_GROUP_GetDistanceBetweenSquares
+
+	int16 f200_groupGetDistanceToVisibleParty(Group *group, int16 creatureIndex, int16 mapX, int16 mapY); // @ F0200_GROUP_GetDistanceToVisibleParty
+	int16 f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 srcMapY,
+												  int16 destMapX, int16 destMapY, bool (GroupMan::*isBlocked)(uint16, uint16)); // @ F0199_GROUP_GetDistanceBetweenUnblockedSquares
+	bool f197_isViewPartyBlocked(uint16 mapX, uint16 mapY); // @ F0197_GROUP_IsViewPartyBlocked
+	int32 f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 creatureIndex,
+										   bool isAttacking); // @ F0179_GROUP_GetCreatureAspectUpdateTime
+	void f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures); // @ F0205_GROUP_SetDirection
+	void f208_groupAddEvent(TimelineEvent *event, uint32 time); // @ F0208_GROUP_AddEvent
+	int16 f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo, int16 mapY, int16 mapX); // @ F0201_GROUP_GetSmelledPartyPrimaryDirectionOrdinal
+	bool f198_isSmellPartyBlocked(uint16 mapX, uint16 mapY); // @ F0198_GROUP_IsSmellPartyBlocked
+	int16 f203_getFirstPossibleMovementDirOrdinal(CreatureInfo *info, int16 mapX, int16 mapY,
+												  bool allowMovementOverImaginaryPitsAndFakeWalls); // @ F0203_GROUP_GetFirstPossibleMovementDirectionOrdinal
+	void f206_groupSetDirGroup(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex,
+							   int16 creatureSize); // @ F0206_GROUP_SetDirectionGroup
+	void f182_stopAttacking(ActiveGroup *group, int16 mapX, int16 mapY);// @ F0182_GROUP_StopAttacking
+	bool f204_isArchenemyDoubleMovementPossible(CreatureInfo *info, int16 mapX, int16 mapY, uint16 dir); // @ F0204_GROUP_IsArchenemyDoubleMovementPossible
+	bool f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 creatureIndex); // @ F0207_GROUP_IsCreatureAttacking
+	void f229_setOrderedCellsToAttack(signed char * orderedCellsToAttack, int16 targetMapX,
+	                                  int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource); // @ F0229_GROUP_SetOrderedCellsToAttack
+	void f193_stealFromChampion(Group *group, uint16 championIndex); // @ F0193_GROUP_StealFromChampion
+	int16 f230_getChampionDamage(Group *group, uint16 champIndex); // @ F0230_GROUP_GetChampionDamage
+	void f187_dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY); // @ F0187_GROUP_DropMovingCreatureFixedPossessions
+	void f180_startWanedring(int16 mapX, int16 mapY); // @ F0180_GROUP_StartWandering
+	void f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY); // @ F0183_GROUP_AddActiveGroup
+	void f184_removeActiveGroup(uint16 activeGroupIndex); // @ F0184_GROUP_RemoveActiveGroup
+
+
+
+
+
+
+
 };
 
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 1583c6f..b8b0ba8 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -82,7 +82,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 			_vm->_menuMan->f395_drawMovementArrows();
 			em._g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
 			warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput");
-			warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
+			_vm->_eventMan->f357_discardAllInput();
 			return;
 		}
 	}
@@ -117,7 +117,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	em._g598_mousePointerBitmapUpdated = true;
 	em._g442_secondaryMouseInput = g449_SecondaryMouseInput_ChampionInventory;
 	warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput");
-	warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
+	_vm->_eventMan->f357_discardAllInput();
 }
 
 void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) {
@@ -555,4 +555,92 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 	f339_drawPanelArrowOrEye(pressingEye);
 
 }
+
+void InventoryMan::f337_setDungeonViewPalette() {
+	int16 L1036_i_TotalLightAmount;
+	uint16 L1037_ui_TorchLightAmountMultiplier;
+	int16 L1038_i_Counter;
+	uint16 L1039_ui_Multiple;
+#define AL1039_ui_SlotIndex    L1039_ui_Multiple
+#define AL1039_ui_PaletteIndex L1039_ui_Multiple
+#define AL1039_ui_Counter      L1039_ui_Multiple
+	int16* L1040_pi_Multiple;
+#define AL1040_pi_TorchLightPower L1040_pi_Multiple
+#define AL1040_pi_LightAmount     L1040_pi_Multiple
+	int16* L1041_pi_TorchLightPower;
+	Weapon* L1042_ps_Weapon;
+	Champion* L1043_ps_Champion;
+	uint16 L1044_ui_Multiple;
+#define AL1044_T_Thing            L1044_ui_Multiple
+#define AL1044_ui_TorchLightPower L1044_ui_Multiple
+	int16 L1045_ai_TorchesLightPower[8];
+
+	int16 g40_palIndexToLightAmmount[6] = {99, 75, 50, 25, 1, 0}; // @ G0040_ai_Graphic562_PaletteIndexToLightAmount
+
+	if (_vm->_dungeonMan->_g269_currMap->_difficulty == 0) {
+		_vm->_displayMan->_g304_dungeonViewPaletteIndex = 0; /* Brightest color palette index */
+	} else {
+		/* Get torch light power from both hands of each champion in the party */
+		L1038_i_Counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and _vm->_objectMan->f32_getObjectType then returns -1 */
+		L1043_ps_Champion = _vm->_championMan->_gK71_champions;
+		AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
+		while (L1038_i_Counter--) {
+			AL1039_ui_SlotIndex = k1_ChampionSlotActionHand + 1;
+			while (AL1039_ui_SlotIndex--) {
+				if ((_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16())) >= k4_IconIndiceWeaponTorchUnlit) &&
+					(_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16())) <= k7_IconIndiceWeaponTorchLit)) {
+					L1042_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(Thing(AL1044_T_Thing));
+					*AL1040_pi_TorchLightPower = L1042_ps_Weapon->getChargeCount();
+				} else {
+					*AL1040_pi_TorchLightPower = 0;
+				}
+				AL1040_pi_TorchLightPower++;
+			}
+			L1043_ps_Champion++;
+		}
+		/* Sort torch light power values so that the four highest values are in the first four entries in the array L1045_ai_TorchesLightPower in decreasing order. The last four entries contain the smallest values but they are not sorted */
+		AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
+		AL1039_ui_Counter = 0;
+		while (AL1039_ui_Counter != 4) {
+			L1038_i_Counter = 7 - AL1039_ui_Counter;
+			L1041_pi_TorchLightPower = &L1045_ai_TorchesLightPower[AL1039_ui_Counter + 1];
+			while (L1038_i_Counter--) {
+				if (*L1041_pi_TorchLightPower > *AL1040_pi_TorchLightPower) {
+					AL1044_ui_TorchLightPower = *L1041_pi_TorchLightPower;
+					*L1041_pi_TorchLightPower = *AL1040_pi_TorchLightPower;
+					*AL1040_pi_TorchLightPower = AL1044_ui_TorchLightPower;
+				}
+				L1041_pi_TorchLightPower++;
+			}
+			AL1040_pi_TorchLightPower++;
+			AL1039_ui_Counter++;
+		}
+		/* Get total light amount provided by the four torches with the highest light power values and by the fifth torch in the array which may be any one of the four torches with the smallest ligh power values */
+		L1037_ui_TorchLightAmountMultiplier = 6;
+		AL1039_ui_Counter = 5;
+		L1036_i_TotalLightAmount = 0;
+		AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
+		while (AL1039_ui_Counter--) {
+			if (*AL1040_pi_TorchLightPower) {
+				L1036_i_TotalLightAmount += (g39_LightPowerToLightAmount[*AL1040_pi_TorchLightPower] << L1037_ui_TorchLightAmountMultiplier) >> 6;
+				L1037_ui_TorchLightAmountMultiplier = MAX(0, L1037_ui_TorchLightAmountMultiplier - 1);
+			}
+			AL1040_pi_TorchLightPower++;
+		}
+		L1036_i_TotalLightAmount += _vm->_championMan->_g407_party._magicalLightAmount;
+		/* Select palette corresponding to the total light amount */
+		AL1040_pi_LightAmount = g40_palIndexToLightAmmount;
+		if (L1036_i_TotalLightAmount > 0) {
+			AL1039_ui_PaletteIndex = 0; /* Brightest color palette index */
+			while (*AL1040_pi_LightAmount++ > L1036_i_TotalLightAmount) {
+				AL1039_ui_PaletteIndex++;
+			}
+		} else {
+			AL1039_ui_PaletteIndex = 5; /* Darkest color palette index */
+		}
+		_vm->_displayMan->_g304_dungeonViewPaletteIndex = AL1039_ui_PaletteIndex;
+	}
+
+	_vm->_displayMan->_g342_refreshDungeonViewPaleteRequested = true;
+}
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index df429af..aa9b215 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -78,6 +78,7 @@ public:
 	void f335_drawPanelObjectDescriptionString(char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString
 	void f339_drawPanelArrowOrEye(bool pressingEye); // @ F0339_INVENTORY_DrawPanel_ArrowOrEye
 	void f342_drawPanelObject(Thing thingToDraw, bool pressingEye); // @ F0342_INVENTORY_DrawPanel_Object
+	void f337_setDungeonViewPalette(); // @ F0337_INVENTORY_SetDungeonViewPalette
 
 };
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 376b629..66b293a 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -32,6 +32,7 @@
 #include "objectman.h"
 #include "inventory.h"
 #include "text.h"
+#include "eventman.h"
 
 
 namespace DM {
@@ -371,4 +372,33 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 48, k160_byteWidthScreen, k255_ColorNoTransparency);
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
+
+void MenuMan::f457_drawEnabledMenus() {
+	int16 L1462_i_Multiple;
+#define AL1462_i_MagicCasterChampionIndex L1462_i_Multiple
+#define AL1462_i_InventoryChampionOrdinal L1462_i_Multiple
+
+
+	if (_vm->_championMan->_g300_partyIsSleeping) {
+		_vm->_eventMan->f379_drawSleepScreen();
+		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+	} else {
+		AL1462_i_MagicCasterChampionIndex = _vm->_championMan->_g514_magicCasterChampionIndex;
+		_vm->_championMan->_g514_magicCasterChampionIndex = kM1_ChampionNone; /* Force next function to draw the spell area */
+		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(AL1462_i_MagicCasterChampionIndex);
+		if (!_vm->_championMan->_g506_actingChampionOrdinal) {
+			_vm->_menuMan->_g509_actionAreaContainsIcons = true;
+		}
+		_vm->_menuMan->f387_drawActionArea();
+		if (AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+			_vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+			_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)_vm->M1_ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
+		} else {
+			_vm->_displayMan->f98_drawFloorAndCeiling();
+			_vm->_menuMan->f395_drawMovementArrows();
+		}
+		_vm->_eventMan->f69_setMousePointer();
+	}
+}
+
 }
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index ef5f86d..4e03242 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -71,6 +71,7 @@ public:
 	void f393_drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls
 	void f392_buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine
 	void f394_setMagicCasterAndDrawSpellArea(int16 champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea
+	void f457_drawEnabledMenus(); // @ F0457_START_DrawEnabledMenus_CPSF
 };
 
 }
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index a1460ae..50a8364 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -42,6 +42,7 @@ MODULE_OBJS := \
 	menus.o \
 	movesens.o \
 	objectman.o \
+	projexpl.o \
 	text.o \
 	timeline.o
 
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 9fab510..70f8cc8 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -31,6 +31,10 @@
 #include "inventory.h"
 #include "dungeonman.h"
 #include "objectman.h"
+#include "timeline.h"
+#include "group.h"
+#include "projexpl.h"
+#include "text.h"
 
 
 namespace DM {
@@ -38,158 +42,1042 @@ namespace DM {
 MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {}
 
 bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam) {
-	ChampionMan &champMan = *_vm->_championMan;
-	DungeonMan &dunMan = *_vm->_dungeonMan;
-	ObjectMan &objMan = *_vm->_objectMan;
-
-
-	bool atLeastOneSensorWasTriggered = false;
-	Thing leaderHandObject = champMan._g414_leaderHandObject;
-	int16 sensorCountToProcessPerCell[4];
-	uint16 cell;
-	for (cell = k0_CellNorthWest; cell < k3_CellSouthWest; ++cell) {
-		sensorCountToProcessPerCell[cell] = 0;
-	}
-	Thing squareFirstThing;
-	Thing thingBeingProcessed = squareFirstThing = dunMan.f161_getSquareFirstThing(mapX, mapY);
-	ThingType thingType;
-	while (thingBeingProcessed != Thing::_endOfList) {
-		thingType = thingBeingProcessed.getType();
-		if (thingType == k3_SensorThingType) {
-			sensorCountToProcessPerCell[thingBeingProcessed.getCell()]++;
-		} else if (thingType >= k4_GroupThingType) {
-			break;
+	Thing L0750_T_ThingBeingProcessed;
+	uint16 L0751_ui_ThingType;
+	uint16 L0752_ui_Cell;
+	bool L0753_B_DoNotTriggerSensor;
+	Thing* L0754_ps_Generic;
+	Sensor* L0755_ps_Sensor;
+	int16 L0756_i_SensorEffect;
+	uint16 L0757_ui_SensorType;
+	int16 L0758_i_SensorData;
+	bool L0759_B_AtLeastOneSensorWasTriggered;
+	int16 L0760_ai_SensorCountToProcessPerCell[4];
+	Thing L0761_T_LeaderHandObject;
+	Thing L0762_T_ThingOnSquare;
+	Thing L0763_T_LastProcessedThing;
+	Thing L0764_T_SquareFirstThing;
+	Sensor* L0765_ps_Sensor;
+
+
+	L0759_B_AtLeastOneSensorWasTriggered = false;
+	L0761_T_LeaderHandObject = _vm->_championMan->_g414_leaderHandObject;
+	for (L0752_ui_Cell = k0_CellNorthWest; L0752_ui_Cell < k3_CellSouthWest + 1; L0752_ui_Cell++) {
+		L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell] = 0;
+	}
+	L0764_T_SquareFirstThing = L0750_T_ThingBeingProcessed = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
+	while (L0750_T_ThingBeingProcessed != Thing::_endOfList) {
+		if ((L0751_ui_ThingType = (L0750_T_ThingBeingProcessed).getType()) == k3_SensorThingType) {
+			L0760_ai_SensorCountToProcessPerCell[(L0750_T_ThingBeingProcessed).getCell()]++;
+		} else {
+			if (L0751_ui_ThingType >= k4_GroupThingType)
+				break;
 		}
-		thingBeingProcessed = dunMan.f159_getNextThing(thingBeingProcessed);
+		L0750_T_ThingBeingProcessed = _vm->_dungeonMan->f159_getNextThing(L0750_T_ThingBeingProcessed);
 	}
-	Thing lastProcessedThing = thingBeingProcessed = squareFirstThing;
-
-	while (thingBeingProcessed != Thing::_endOfList) {
-		thingType = thingBeingProcessed.getType();
-		if (thingType == k3_SensorThingType) {
-			cell = thingBeingProcessed.getCell();
-			sensorCountToProcessPerCell[cell]--;
-			Sensor *sensor = (Sensor*)dunMan.f156_getThingData(thingBeingProcessed); // IF YOU CHECK ME, I'LL CALL THE COPS!
-			SensorType sensorType = sensor->getType();
-			if (sensorType == k0_SensorDisabled)
+	L0763_T_LastProcessedThing = L0750_T_ThingBeingProcessed = L0764_T_SquareFirstThing;
+	while (L0750_T_ThingBeingProcessed != Thing::_endOfList) {
+		if ((L0751_ui_ThingType = (L0750_T_ThingBeingProcessed).getType()) == k3_SensorThingType) {
+			L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell = (L0750_T_ThingBeingProcessed).getCell()]--;
+			L0755_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0750_T_ThingBeingProcessed);
+			if ((L0757_ui_SensorType = (L0755_ps_Sensor)->getType()) == k0_SensorDisabled)
 				goto T0275058_ProceedToNextThing;
-			if ((champMan._g411_leaderIndex == kM1_ChampionNone) && (sensorType != k127_SensorWallChampionPortrait))
+			if ((_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) && (L0757_ui_SensorType != k127_SensorWallChampionPortrait))
 				goto T0275058_ProceedToNextThing;
-			if (cell != cellParam)
+			if (L0752_ui_Cell != cellParam)
 				goto T0275058_ProceedToNextThing;
-			int16 sensorData = sensor->getData();
-			int16 sensorEffect = sensor->getEffectA();
-			bool doNotTriggerSensor;
-			switch (sensorType) {
+			L0758_i_SensorData = L0755_ps_Sensor->getData();
+			L0756_i_SensorEffect = L0755_ps_Sensor->getEffectA();
+			switch (L0757_ui_SensorType) {
 			case k1_SensorWallOrnClick:
-				doNotTriggerSensor = false;
-				if (sensor->getEffectA() == k3_SensorEffHold) {
+				L0753_B_DoNotTriggerSensor = false;
+				if (L0755_ps_Sensor->getEffectA() == k3_SensorEffHold) {
 					goto T0275058_ProceedToNextThing;
 				}
 				break;
 			case k2_SensorWallOrnClickWithAnyObj:
-				doNotTriggerSensor = (champMan._g415_leaderEmptyHanded != sensor->getRevertEffectA());
+				L0753_B_DoNotTriggerSensor = (_vm->_championMan->_g415_leaderEmptyHanded != L0755_ps_Sensor->getRevertEffectA());
 				break;
 			case k17_SensorWallOrnClickWithSpecObjRemovedSensor:
 			case k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors:
-				if (sensorCountToProcessPerCell[cell])
+				if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */
 					goto T0275058_ProceedToNextThing;
 			case k3_SensorWallOrnClickWithSpecObj:
 			case k4_SensorWallOrnClickWithSpecObjRemoved:
-				doNotTriggerSensor = ((sensorData == objMan.f32_getObjectType(leaderHandObject)) == sensor->getRevertEffectA());
-				if (!doNotTriggerSensor && (sensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) {
-					if (lastProcessedThing == thingBeingProcessed)
+				L0753_B_DoNotTriggerSensor = ((L0758_i_SensorData == _vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject)) == L0755_ps_Sensor->getRevertEffectA());
+				if (!L0753_B_DoNotTriggerSensor && (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) {
+					if (L0763_T_LastProcessedThing == L0750_T_ThingBeingProcessed) /* If the sensor is the only one of its type on the cell */
 						break;
-					((Sensor*)dunMan.f156_getThingData(lastProcessedThing))->setNextThing(sensor->getNextThing());
-					sensor->setNextThing(Thing::_none);
-					thingBeingProcessed = lastProcessedThing;
+					L0765_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0763_T_LastProcessedThing);
+					L0765_ps_Sensor->setNextThing(L0755_ps_Sensor->getNextThing());
+					L0755_ps_Sensor->setNextThing(Thing::_none);
+					L0750_T_ThingBeingProcessed = L0763_T_LastProcessedThing;
 				}
-				if (!doNotTriggerSensor && (sensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors)) {
-					warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect");
+				if (!L0753_B_DoNotTriggerSensor && (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors)) {
+					f270_sensorTriggetLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
 				}
 				break;
 			case k12_SensorWallObjGeneratorRotateSensors:
-				if (sensorCountToProcessPerCell[cell])
+				if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */
 					goto T0275058_ProceedToNextThing;
-				doNotTriggerSensor = !champMan._g415_leaderEmptyHanded;
-				if (!doNotTriggerSensor) {
-					warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect");
+				L0753_B_DoNotTriggerSensor = !_vm->_championMan->_g415_leaderEmptyHanded;
+				if (!L0753_B_DoNotTriggerSensor) {
+					f270_sensorTriggetLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
 				}
 				break;
 			case k13_SensorWallSingleObjStorageRotateSensors:
-				if (champMan._g415_leaderEmptyHanded) {
-					warning("MISSING CODE: F0273_SENSOR_GetObjectOfTypeInCell");
-					warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList");
-					warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand");
+				if (_vm->_championMan->_g415_leaderEmptyHanded) {
+					if ((L0761_T_LeaderHandObject = f273_sensorGetObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData)) == Thing::_none)
+						goto T0275058_ProceedToNextThing;
+					_vm->_dungeonMan->f164_unlinkThingFromList(L0761_T_LeaderHandObject, Thing(0), mapX, mapY);
+					_vm->_championMan->f297_putObjectInLeaderHand(L0761_T_LeaderHandObject, true);
 				} else {
-					warning("MISSING CODE: F0273_SENSOR_GetObjectOfTypeInCell");
-					warning(("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand"));
-					warning("MISSING CODE: F0163_DUNGEON_LinkThingToList");
-					leaderHandObject = Thing::_none;
-				}
-				warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect");
-				if ((sensorEffect == k3_SensorEffHold) && !champMan._g415_leaderEmptyHanded) {
-					doNotTriggerSensor = true;
+					if ((_vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (f273_sensorGetObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData) != Thing::_none))
+						goto T0275058_ProceedToNextThing;
+					_vm->_championMan->f298_getObjectRemovedFromLeaderHand();
+					_vm->_dungeonMan->f163_linkThingToList(M15_thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
+					L0761_T_LeaderHandObject = Thing::_none;
+				}
+				f270_sensorTriggetLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
+				if ((L0756_i_SensorEffect == k3_SensorEffHold) && !_vm->_championMan->_g415_leaderEmptyHanded) {
+					L0753_B_DoNotTriggerSensor = true;
 				} else {
-					doNotTriggerSensor = false;
+					L0753_B_DoNotTriggerSensor = false;
 				}
 				break;
-			case k16_SensorWallObjExchanger: {
-				if (sensorCountToProcessPerCell[cell])
+			case k16_SensorWallObjExchanger:
+				if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */
 					goto T0275058_ProceedToNextThing;
-				Thing thingOnSquare = dunMan.f161_getSquareFirstThing(mapX, mapY);
-				if ((objMan.f32_getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_none))
+				L0762_T_ThingOnSquare = _vm->_dungeonMan->f162_getSquareFirstObject(mapX, mapY);
+				if ((_vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (L0762_T_ThingOnSquare == Thing::_none))
 					goto T0275058_ProceedToNextThing;
-				warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList");
-				warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand");
-				warning("MISSING CODE: F0163_DUNGEON_LinkThingToList");
-				warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand");
-				doNotTriggerSensor = false;
+				_vm->_dungeonMan->f164_unlinkThingFromList(L0762_T_ThingOnSquare, Thing(0), mapX, mapY);
+				_vm->_championMan->f298_getObjectRemovedFromLeaderHand();
+				_vm->_dungeonMan->f163_linkThingToList(M15_thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
+				_vm->_championMan->f297_putObjectInLeaderHand(L0762_T_ThingOnSquare, true);
+				L0753_B_DoNotTriggerSensor = false;
 				break;
-			}
 			case k127_SensorWallChampionPortrait:
-				champMan.f280_addCandidateChampionToParty(sensorData);
+				_vm->_championMan->f280_addCandidateChampionToParty(L0758_i_SensorData);
 				goto T0275058_ProceedToNextThing;
 			default:
 				goto T0275058_ProceedToNextThing;
 			}
-
-			if (sensorEffect == k3_SensorEffHold) {
-				sensorEffect = doNotTriggerSensor ? k1_SensorEffClear : k0_SensorEffSet;
-				doNotTriggerSensor = false;
+			if (L0756_i_SensorEffect == k3_SensorEffHold) {
+				L0756_i_SensorEffect = L0753_B_DoNotTriggerSensor ? k1_SensorEffClear : k0_SensorEffSet;
+				L0753_B_DoNotTriggerSensor = false;
 			}
-
-			if (!doNotTriggerSensor) {
-				atLeastOneSensorWasTriggered = true;
-				if (sensor->getAudibleA()) {
+			if (!L0753_B_DoNotTriggerSensor) {
+				L0759_B_AtLeastOneSensorWasTriggered = true;
+				if (L0755_ps_Sensor->getAudibleA()) {
 					warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 				}
-				if (!champMan._g415_leaderEmptyHanded &&
-					((sensorType == k4_SensorWallOrnClickWithSpecObjRemoved) ||
-					(sensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) ||
-					 (sensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
-
-					*((Thing*)dunMan.f156_getThingData(leaderHandObject)) = Thing::_none;
-					warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand");
-					leaderHandObject = Thing::_none;
+				if (!_vm->_championMan->_g415_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
+					L0754_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0761_T_LeaderHandObject);
+					*L0754_ps_Generic = Thing::_none;
+					_vm->_championMan->f298_getObjectRemovedFromLeaderHand();
+					L0761_T_LeaderHandObject = Thing::_none;
 				} else {
-					warning("MISSING CODE: (leaderHandObject = F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator(sensorData)");
-					if (champMan._g415_leaderEmptyHanded && (sensorType == k12_SensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_none)) {
-						warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand");
+					if (_vm->_championMan->_g415_leaderEmptyHanded &&
+						(L0757_ui_SensorType == k12_SensorWallObjGeneratorRotateSensors) &&
+						((L0761_T_LeaderHandObject = _vm->_dungeonMan->f167_getObjForProjectileLaucherOrObjGen(L0758_i_SensorData)) != Thing::_none)) {
+						_vm->_championMan->f297_putObjectInLeaderHand(L0761_T_LeaderHandObject, true);
 					}
 				}
-				warning("MISSING CODE: F0272_SENSOR_TriggerEffect");
+				f272_sensorTriggerEffect(L0755_ps_Sensor, L0756_i_SensorEffect, mapX, mapY, L0752_ui_Cell);
 			}
 			goto T0275058_ProceedToNextThing;
 		}
-		if (thingType >= k4_GroupThingType)
+		if (L0751_ui_ThingType >= k4_GroupThingType)
 			break;
 T0275058_ProceedToNextThing:
-		lastProcessedThing = thingBeingProcessed;
-		thingBeingProcessed = dunMan.f159_getNextThing(thingBeingProcessed);
+		L0763_T_LastProcessedThing = L0750_T_ThingBeingProcessed;
+		L0750_T_ThingBeingProcessed = _vm->_dungeonMan->f159_getNextThing(L0750_T_ThingBeingProcessed);
+	}
+	f271_processRotationEffect();
+	return L0759_B_AtLeastOneSensorWasTriggered;
+}
+
+bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destMapX, int16 destMapY) {
+	int16 L0708_i_Multiple = 0;
+#define AL0708_i_DestinationSquare L0708_i_Multiple
+#define AL0708_i_ScentIndex        L0708_i_Multiple
+#define AL0708_i_ActiveGroupIndex  L0708_i_Multiple
+	int16 L0709_i_Multiple;
+#define AL0709_i_DestinationSquareType L0709_i_Multiple
+#define AL0709_i_ChampionIndex         L0709_i_Multiple
+	int16 L0710_i_ThingType;
+	Champion* L0711_ps_Champion;
+	Teleporter* L0712_ps_Teleporter;
+	bool L0713_B_ThingLevitates;
+	uint16 L0714_ui_MapIndexSource = 0;
+	uint16 L0715_ui_MapIndexDestination = 0;
+	uint16 L0716_ui_Direction = 0;
+	uint16 L0717_ui_ThingCell = 0;
+	int16 L0718_i_RequiredTeleporterScope;
+	// Strangerke: Only present in v2.1, but it fixes a bug, so I propose to keep it
+	int16 L0719_i_TraversedPitCount;
+	uint16 L0720_ui_MoveGroupResult;
+	bool L0721_B_GroupOnPartyMap;
+	bool L0722_B_FallKilledGroup;
+	bool L0723_B_DrawDungeonViewWhileFalling;
+	bool L0724_B_DestinationIsTeleporterTarget;
+	bool L0725_B_PartySquare;
+	bool L0726_B_Audible;
+	uint16 L0727_ui_Multiple;
+#define AL0727_ui_ThingCell L0727_ui_Multiple
+#define AL0727_ui_Outcome   L0727_ui_Multiple
+#define AL0727_ui_Backup    L0727_ui_Multiple
+	int16 L0728_i_ChainedMoveCount;
+	uint16 L1638_ui_MovementSoundIndex;
+
+	L0710_i_ThingType = kM1_PartyThingType;
+	L0713_B_ThingLevitates = false;
+	L0719_i_TraversedPitCount = 0;
+	L0720_ui_MoveGroupResult = 0;
+	L0721_B_GroupOnPartyMap = false;
+	L0722_B_FallKilledGroup = false;
+	L0723_B_DrawDungeonViewWhileFalling = false;
+	L0724_B_DestinationIsTeleporterTarget = false;
+	L0725_B_PartySquare = false;
+	L0726_B_Audible = false;
+	if (thing != Thing::_party) {
+		L0710_i_ThingType = (thing).getType();
+		L0717_ui_ThingCell = (thing).getCell();
+		L0713_B_ThingLevitates = f264_isLevitating(thing);
+	}
+	/* If moving the party or a creature on the party map from a dungeon square then check for a projectile impact */
+	if ((mapX >= 0) && ((thing == Thing::_party) || ((L0710_i_ThingType == k4_GroupThingType) && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)))) {
+		if (f266_moveIsKilledByProjectileImpact(mapX, mapY, destMapX, destMapY, thing)) {
+			return true; /* The specified group thing cannot be moved because it was killed by a projectile impact */
+		}
+	}
+	if (destMapX >= 0) {
+		L0714_ui_MapIndexSource = L0715_ui_MapIndexDestination = _vm->_dungeonMan->_g272_currMapIndex;
+		L0721_B_GroupOnPartyMap = (L0714_ui_MapIndexSource == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX >= 0);
+		if (thing == Thing::_party) {
+			_vm->_dungeonMan->_g306_partyMapX = destMapX;
+			_vm->_dungeonMan->_g307_partyMapY = destMapY;
+			L0718_i_RequiredTeleporterScope = k0x0002_TelepScopeObjOrParty;
+			L0723_B_DrawDungeonViewWhileFalling = !_vm->_inventoryMan->_g432_inventoryChampionOrdinal && !_vm->_championMan->_g300_partyIsSleeping;
+			L0716_ui_Direction = _vm->_dungeonMan->_g308_partyDir;
+		} else {
+			if (L0710_i_ThingType == k4_GroupThingType) {
+				L0718_i_RequiredTeleporterScope = k0x0001_TelepScopeCreatures;
+			} else {
+				L0718_i_RequiredTeleporterScope = (k0x0001_TelepScopeCreatures | k0x0002_TelepScopeObjOrParty);
+			}
+		}
+		if (L0710_i_ThingType == k14_ProjectileThingType) {
+			L0712_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(thing);
+			_g400_moveResultDir = (_vm->_timeline->_g370_events[((Projectile*)L0712_ps_Teleporter)->_eventIndex])._C._projectile.getDir();
+		}
+		for (L0728_i_ChainedMoveCount = 1000; --L0728_i_ChainedMoveCount; ) { /* No more than 1000 chained moves at once (in a chain of teleporters and pits for example) */
+			AL0708_i_DestinationSquare = _vm->_dungeonMan->_g271_currMapData[destMapX][destMapY];
+			if ((AL0709_i_DestinationSquareType = Square(AL0708_i_DestinationSquare).getType()) == k5_ElementTypeTeleporter) {
+				if (!getFlag(AL0708_i_DestinationSquare, k0x0008_TeleporterOpen))
+					break;
+				L0712_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(destMapX, destMapY);
+				if ((L0712_ps_Teleporter->getScope() == k0x0001_TelepScopeCreatures) && (L0710_i_ThingType != k4_GroupThingType))
+					break;
+				if ((L0718_i_RequiredTeleporterScope != (k0x0001_TelepScopeCreatures | k0x0002_TelepScopeObjOrParty)) && !getFlag(L0712_ps_Teleporter->getScope(), L0718_i_RequiredTeleporterScope))
+					break;
+				L0724_B_DestinationIsTeleporterTarget = (destMapX == L0712_ps_Teleporter->getTargetMapX()) && (destMapY == L0712_ps_Teleporter->getTargetMapY()) && (L0715_ui_MapIndexDestination == L0712_ps_Teleporter->getTargetMapIndex());
+				destMapX = L0712_ps_Teleporter->getTargetMapX();
+				destMapY = L0712_ps_Teleporter->getTargetMapY();
+				L0726_B_Audible = L0712_ps_Teleporter->isAudible();
+				_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination = L0712_ps_Teleporter->getTargetMapIndex());
+				if (thing == Thing::_party) {
+					_vm->_dungeonMan->_g306_partyMapX = destMapX;
+					_vm->_dungeonMan->_g307_partyMapY = destMapY;
+					if (L0712_ps_Teleporter->isAudible()) {
+						warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+					}
+					L0723_B_DrawDungeonViewWhileFalling = true;
+					if (L0712_ps_Teleporter->getAbsoluteRotation()) {
+						_vm->_championMan->f284_setPartyDirection(L0712_ps_Teleporter->getRotation());
+					} else {
+						_vm->_championMan->f284_setPartyDirection(M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + L0712_ps_Teleporter->getRotation()));
+					}
+				} else {
+					if (L0710_i_ThingType == k4_GroupThingType) {
+						if (L0712_ps_Teleporter->isAudible()) {
+							warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+						}
+						L0720_ui_MoveGroupResult = f262_getTeleporterRotatedGroupResult(L0712_ps_Teleporter, thing, L0714_ui_MapIndexSource);
+					} else {
+						if (L0710_i_ThingType == k14_ProjectileThingType) {
+							thing = f263_getTeleporterRotatedProjectileThing(L0712_ps_Teleporter, thing);
+						} else {
+							if (!(L0712_ps_Teleporter->getAbsoluteRotation()) && (mapX != -2)) {
+								thing = M15_thingWithNewCell(thing, M21_normalizeModulo4((thing).getCell() + L0712_ps_Teleporter->getRotation()));
+							}
+						}
+					}
+				}
+				if (L0724_B_DestinationIsTeleporterTarget)
+					break;
+			} else {
+				if ((AL0709_i_DestinationSquareType == k2_ElementTypePit) && !L0713_B_ThingLevitates && getFlag(AL0708_i_DestinationSquare, k0x0008_PitOpen) && !getFlag(AL0708_i_DestinationSquare, k0x0001_PitImaginary)) {
+					if (L0723_B_DrawDungeonViewWhileFalling && !_g402_useRopeToClimbDownPit) {
+						L0723_B_DrawDungeonViewWhileFalling = true;
+						if (L0719_i_TraversedPitCount) {
+							_vm->_dungeonMan->f174_setCurrentMapAndPartyMap(L0715_ui_MapIndexDestination);
+							_vm->_displayMan->f96_loadCurrentMapGraphics();
+						}
+						L0719_i_TraversedPitCount++;
+						_vm->_displayMan->f128_drawDungeon(_vm->_dungeonMan->_g308_partyDir, destMapX, destMapY); /* BUG0_28 When falling through multiple pits the dungeon view is updated to show each traversed map but the graphics used for creatures, wall and floor ornaments may not be correct. The dungeon view is drawn for each map by using the graphics loaded for the source map. Therefore the graphics for creatures, wall and floor ornaments may not look like what they should */
+																												  /* BUG0_71 Some timings are too short on fast computers. When the party falls in a series of pits, the dungeon view is refreshed too quickly because the execution speed is not limited */
+																												  /* BUG0_01 While drawing creatures the engine will read invalid ACTIVE_GROUP data in _vm->_groupMan->_g375_activeGroups because the data is for the creatures on the source map and not the map being drawn. The only consequence is that creatures may be drawn with incorrect bitmaps and/or directions */
+					}
+					L0715_ui_MapIndexDestination = _vm->_dungeonMan->f154_getLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &destMapX, &destMapY);
+					_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination);
+					if (thing == Thing::_party) {
+						_vm->_dungeonMan->_g306_partyMapX = destMapX;
+						_vm->_dungeonMan->_g307_partyMapY = destMapY;
+						if (_vm->_championMan->_g305_partyChampionCount > 0) {
+							if (_g402_useRopeToClimbDownPit) {
+								for (AL0709_i_ChampionIndex = k0_ChampionFirst, L0711_ps_Champion = _vm->_championMan->_gK71_champions; AL0709_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL0709_i_ChampionIndex++, L0711_ps_Champion++) {
+									if (L0711_ps_Champion->_currHealth) {
+										_vm->_championMan->f325_decrementStamine(AL0709_i_ChampionIndex, ((L0711_ps_Champion->_load * 25) / _vm->_championMan->f309_getMaximumLoad(L0711_ps_Champion)) + 1);
+									}
+								}
+							} else {
+								if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF)) {
+									warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+								}
+							}
+						}
+						_g402_useRopeToClimbDownPit = false;
+					} else {
+						if (L0710_i_ThingType == k4_GroupThingType) {
+							_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
+							AL0727_ui_Outcome = _vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group*)_vm->_dungeonMan->f156_getThingData(thing), mapX, mapY, 20, false);
+							_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination);
+							if (L0722_B_FallKilledGroup = (AL0727_ui_Outcome == k2_outcomeKilledAllCreaturesInGroup))
+								break;
+							if (AL0727_ui_Outcome == k1_outcomeKilledSomeCreaturesInGroup) {
+								_vm->_groupMan->f187_dropMovingCreatureFixedPossession(thing, destMapX, destMapY);
+							}
+						}
+					}
+				} else {
+					if ((AL0709_i_DestinationSquareType == k3_ElementTypeStairs) && (thing != Thing::_party) && (L0710_i_ThingType != k14_ProjectileThingType)) {
+						if (!getFlag(AL0708_i_DestinationSquare, k0x0004_StairsUp)) {
+							L0715_ui_MapIndexDestination = _vm->_dungeonMan->f154_getLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &destMapX, &destMapY);
+							_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination);
+						}
+						L0716_ui_Direction = _vm->_dungeonMan->f155_getStairsExitDirection(destMapX, destMapY);
+						destMapX += _vm->_dirIntoStepCountEast[L0716_ui_Direction], destMapY += _vm->_dirIntoStepCountNorth[L0716_ui_Direction];
+						L0716_ui_Direction = returnOppositeDir((direction)L0716_ui_Direction);
+						AL0727_ui_ThingCell = (thing).getCell();
+						AL0727_ui_ThingCell = M21_normalizeModulo4((((AL0727_ui_ThingCell - L0716_ui_Direction + 1) & 0x0002) >> 1) + L0716_ui_Direction);
+						thing = M15_thingWithNewCell(thing, AL0727_ui_ThingCell);
+					} else
+						break;
+				}
+			}
+		}
+		if ((L0710_i_ThingType == k4_GroupThingType) && (L0722_B_FallKilledGroup || !_vm->_dungeonMan->f139_isCreatureAllowedOnMap(thing, L0715_ui_MapIndexDestination))) {
+			_vm->_groupMan->f187_dropMovingCreatureFixedPossession(thing, destMapX, destMapY);
+			_vm->_groupMan->f188_dropGroupPossessions(destMapX, destMapY, thing, k2_soundModePlayOneTickLater);
+			_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
+			if (mapX >= 0) {
+				_vm->_groupMan->f189_delete(mapX, mapY);
+			}
+			return true; /* The specified group thing cannot be moved because it was killed by a fall or because it is not allowed on the destination map */
+		}
+		_g397_moveResultMapX = destMapX;
+		_g398_moveResultMapY = destMapY;
+		_g399_moveResultMapIndex = L0715_ui_MapIndexDestination;
+		_g401_moveResultCell = (thing).getCell();
+		L0725_B_PartySquare = (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) && (destMapX == mapX) && (destMapY == mapY);
+		if (L0725_B_PartySquare) {
+			if (thing == Thing::_party) {
+				if (_vm->_dungeonMan->_g308_partyDir == L0716_ui_Direction) {
+					return false;
+				}
+			} else {
+				if ((_g401_moveResultCell == L0717_ui_ThingCell) && (L0710_i_ThingType != k14_ProjectileThingType)) {
+					return false;
+				}
+			}
+		} else {
+			if ((thing == Thing::_party) && _vm->_championMan->_g305_partyChampionCount) {
+				AL0727_ui_Backup = AL0708_i_DestinationSquare;
+				AL0708_i_ScentIndex = _vm->_championMan->_g407_party._scentCount;
+				while (AL0708_i_ScentIndex >= 24) {
+					_vm->_championMan->f316_deleteScent(0);
+					AL0708_i_ScentIndex--;
+				}
+				if (AL0708_i_ScentIndex) {
+					_vm->_championMan->f317_addScentStrength(mapX, mapY, (int)(_vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime));
+				}
+				_vm->_projexpl->_g362_lastPartyMovementTime = _vm->_g313_gameTime;
+				_vm->_championMan->_g407_party._scentCount++;
+				if (_vm->_championMan->_g407_party._event79Count_Footprints) {
+					_vm->_championMan->_g407_party._lastScentIndex = _vm->_championMan->_g407_party._scentCount;
+				}
+				_vm->_championMan->_g407_party._scents[AL0708_i_ScentIndex].setMapX(destMapX);
+				_vm->_championMan->_g407_party._scents[AL0708_i_ScentIndex].setMapY(destMapY);
+				_vm->_championMan->_g407_party._scents[AL0708_i_ScentIndex].setMapIndex(L0715_ui_MapIndexDestination);
+				_vm->_championMan->_g407_party._scentStrengths[AL0708_i_ScentIndex] = 0;
+				_vm->_championMan->f317_addScentStrength(destMapX, destMapY, k0x8000_mergeCycles | 24);
+				AL0708_i_DestinationSquare = AL0727_ui_Backup;
+			}
+			if (L0715_ui_MapIndexDestination != L0714_ui_MapIndexSource) {
+				_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
+			}
+		}
+	}
+	if (mapX >= 0) {
+		if (thing == Thing::_party) {
+			f276_sensorProcessThingAdditionOrRemoval(mapX, mapY, Thing::_party, L0725_B_PartySquare, false);
+		} else {
+			if (L0713_B_ThingLevitates) {
+				_vm->_dungeonMan->f164_unlinkThingFromList(thing, Thing(0), mapX, mapY);
+			} else {
+				f276_sensorProcessThingAdditionOrRemoval(mapX, mapY, thing, (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX == _vm->_dungeonMan->_g306_partyMapX) && (mapY == _vm->_dungeonMan->_g307_partyMapY), false);
+			}
+		}
+	}
+	if (destMapX >= 0) {
+		if (thing == Thing::_party) {
+			_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination);
+			if ((thing = _vm->_groupMan->f175_groupGetThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY)) != Thing::_endOfList) { /* Delete group if party moves onto its square */
+				_vm->_groupMan->f188_dropGroupPossessions(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, thing, k1_soundModePlayIfPrioritized);
+				_vm->_groupMan->f189_delete(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+			}
+			if (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) {
+				f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, L0725_B_PartySquare, true);
+			} else {
+				_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
+				_vm->_g327_newPartyMapIndex = L0715_ui_MapIndexDestination;
+			}
+		} else {
+			if (L0710_i_ThingType == k4_GroupThingType) {
+				_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination);
+				L0712_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(thing);
+				AL0708_i_ActiveGroupIndex = ((Group*)L0712_ps_Teleporter)->getActiveGroupIndex();
+				if (((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_g309_partyMapIndex) && (destMapX == _vm->_dungeonMan->_g306_partyMapX) && (destMapY == _vm->_dungeonMan->_g307_partyMapY)) || (_vm->_groupMan->f175_groupGetThing(destMapX, destMapY) != Thing::_endOfList)) { /* If a group tries to move to the party square or over another group then create an event to move the group later */
+					_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
+					if (mapX >= 0) {
+						_vm->_groupMan->f181_groupDeleteEvents(mapX, mapY);
+					}
+					if (L0721_B_GroupOnPartyMap) {
+						_vm->_groupMan->f184_removeActiveGroup(AL0708_i_ActiveGroupIndex);
+					}
+					f265_createEvent60to61_moveGroup(thing, destMapX, destMapY, L0715_ui_MapIndexDestination, L0726_B_Audible);
+					return true; /* The specified group thing cannot be moved because the party or another group is on the destination square */
+				}
+				L1638_ui_MovementSoundIndex = f514_getSound(((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[(thing).getIndex()]._type);
+				if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) {
+					warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+				}
+				if (L0721_B_GroupOnPartyMap && (L0715_ui_MapIndexDestination != _vm->_dungeonMan->_g309_partyMapIndex)) { /* If the group leaves the party map */
+					_vm->_groupMan->f184_removeActiveGroup(AL0708_i_ActiveGroupIndex);
+					L0720_ui_MoveGroupResult = true;
+				} else {
+					if ((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_g309_partyMapIndex) && (!L0721_B_GroupOnPartyMap)) { /* If the group arrives on the party map */
+						_vm->_groupMan->f183_addActiveGroup(thing, destMapX, destMapY);
+						L0720_ui_MoveGroupResult = true;
+					}
+				}
+				if (L0713_B_ThingLevitates) {
+					_vm->_dungeonMan->f163_linkThingToList(thing, Thing(0), destMapX, destMapY);
+				} else {
+					f276_sensorProcessThingAdditionOrRemoval(destMapX, destMapY, thing, false, true);
+				}
+				if (L0720_ui_MoveGroupResult || (mapX < 0)) { /* If group moved from one map to another or if it was just placed on a square */
+					_vm->_groupMan->f180_startWanedring(destMapX, destMapY);
+				}
+				_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
+				if (mapX >= 0) {
+					if (L0720_ui_MoveGroupResult > 1) { /* If the group behavior was C6_BEHAVIOR_ATTACK before being teleported from and to the party map */
+						_vm->_groupMan->f182_stopAttacking(&_vm->_groupMan->_g375_activeGroups[L0720_ui_MoveGroupResult - 2], mapX, mapY);
+					} else {
+						if (L0720_ui_MoveGroupResult) { /* If the group was teleported or leaved the party map or entered the party map */
+							_vm->_groupMan->f181_groupDeleteEvents(mapX, mapY);
+						}
+					}
+				}
+				return L0720_ui_MoveGroupResult;
+			}
+			_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination);
+			if (L0710_i_ThingType == k14_ProjectileThingType) { /* BUG0_29 An explosion can trigger a floor sensor. Explosions do not trigger floor sensors on the square where they are created. However, if an explosion is moved by a teleporter (or by falling into a pit, see BUG0_26) after it was created, it can trigger floor sensors on the destination square. This is because explosions are not considered as levitating in the code, while projectiles are. The condition here should be (L0713_B_ThingLevitates) so that explosions would not start sensor processing on their destination square as they should be Levitating. This would work if F0264_MOVE_IsLevitating returned true for explosions (see BUG0_26) */
+				_vm->_dungeonMan->f163_linkThingToList(thing, Thing(0), destMapX, destMapY);
+			} else {
+				f276_sensorProcessThingAdditionOrRemoval(destMapX, destMapY, thing, (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (destMapX == _vm->_dungeonMan->_g306_partyMapX) && (destMapY == _vm->_dungeonMan->_g307_partyMapY), true);
+			}
+			_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
+		}
+	}
+	return false;
+}
+
+bool MovesensMan::f264_isLevitating(Thing thing) {
+	int16 L0695_i_ThingType;
+
+
+	if ((L0695_i_ThingType = (thing).getType()) == k4_GroupThingType) {
+		return getFlag(_vm->_dungeonMan->f144_getCreatureAttributes(thing), k0x0020_MaskCreatureInfo_levitation);
+	}
+	if (L0695_i_ThingType == k14_ProjectileThingType) { /* BUG0_26 An explosion may fall in a pit. If a pit is opened while there is an explosion above then the explosion falls into the pit in F0267_MOVE_GetMoveResult_CPSCE. Explosions are not considered as levitating so they are moved when the pit is opened. This function should return true for explosions */
+		return true;
+	}
+	return false;
+}
+
+bool MovesensMan::f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY, Thing thing) {
+	Thing L0697_T_Thing;
+	uint16 L0699_ui_Multiple;
+#define AL0699_ui_Cell                      L0699_ui_Multiple
+#define AL0699_ui_PrimaryDirection          L0699_ui_Multiple
+#define AL0699_ui_ChampionOrCreatureOrdinal L0699_ui_Multiple
+	int16 L0700_i_Multiple;
+#define AL0700_B_CreatureAlive      L0700_i_Multiple
+#define AL0700_i_Distance           L0700_i_Multiple
+#define AL0700_i_SecondaryDirection L0700_i_Multiple
+	Group* L0701_ps_Group;
+	int16 L0702_i_ImpactType;
+	bool L0703_B_CheckDestinationSquareProjectileImpacts;
+	uint16 L0704_ui_ProjectileMapX;
+	uint16 L0705_ui_ProjectileMapY;
+	byte L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[4]; /* This array is used only when moving between two adjacent squares and is used to test projectile impacts when the party or group is in the 'intermediary' step between the two squares. Without this test, in the example below no impact would be detected. In this example, the party moves from the source square on the left (which contains a single champion at cell 2) to the destination square on the right (which contains a single projectile at cell 3).
+																			Party:      Projectiles on target square:   Incorrect result without the test for the intermediary step (the champion would have passed through the projectile without impact):
+																			00    ->    00                         00
+																			01          P0                         P1 */
+	byte L0707_auc_ChampionOrCreatureOrdinalInCell[4]; /* This array has an entry for each cell on the source square, containing the ordinal of the champion or creature (0 if there is no champion or creature at this cell) */
+
+
+	L0703_B_CheckDestinationSquareProjectileImpacts = false;
+	for (int16 i = 0; i < 4; ++i)
+		L0707_auc_ChampionOrCreatureOrdinalInCell[i] = 0;
+	if (thing == Thing::_party) {
+		L0702_i_ImpactType = kM2_ChampionElemType;
+		for (AL0699_ui_Cell = k0_CellNorthWest; AL0699_ui_Cell < k3_CellSouthWest + 1; AL0699_ui_Cell++) {
+			if (_vm->_championMan->f285_getIndexInCell((ViewCell)AL0699_ui_Cell) >= 0) {
+				L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = _vm->M0_indexToOrdinal(AL0699_ui_Cell);
+			}
+		}
+	} else {
+		L0702_i_ImpactType = kM1_CreatureElemType;
+		L0701_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing);
+		for (AL0699_ui_Cell = k0_CellNorthWest, AL0700_B_CreatureAlive = false; AL0699_ui_Cell < k3_CellSouthWest + 1; AL0699_ui_Cell++) {
+			AL0700_B_CreatureAlive |= L0701_ps_Group->_health[AL0699_ui_Cell];
+			if (_vm->_groupMan->f176_getCreatureOrdinalInCell(L0701_ps_Group, AL0699_ui_Cell)) {
+				L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = _vm->M0_indexToOrdinal(AL0699_ui_Cell);
+			}
+		}
+		if (!AL0700_B_CreatureAlive) {
+			return false;
+		}
+	}
+	if ((destMapX >= 0) && (((((AL0700_i_Distance = srcMapX - destMapX) < 0) ? -AL0700_i_Distance : AL0700_i_Distance) + (((AL0700_i_Distance = srcMapY - destMapY) < 0) ? -AL0700_i_Distance : AL0700_i_Distance)) == 1)) { /* If source and destination squares are adjacent (if party or group is not being teleported) */
+		AL0699_ui_PrimaryDirection = _vm->_groupMan->f228_getDirsWhereDestIsVisibleFromSource(srcMapX, srcMapY, destMapX, destMapY);
+		AL0700_i_SecondaryDirection = returnNextVal(AL0699_ui_PrimaryDirection);
+		for (int16 i = 0; i < 4; ++i)
+			L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[i] = 0;
+		if (L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnPrevVal(AL0699_ui_PrimaryDirection)] = L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection]) {
+			L0703_B_CheckDestinationSquareProjectileImpacts = true;
+		}
+		if (L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnNextVal(AL0700_i_SecondaryDirection)] = L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection]) {
+			L0703_B_CheckDestinationSquareProjectileImpacts = true;
+		}
+		if (!L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection]) {
+			L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection] = L0707_auc_ChampionOrCreatureOrdinalInCell[returnPrevVal(AL0699_ui_PrimaryDirection)];
+		}
+		if (!L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection]) {
+			L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection] = L0707_auc_ChampionOrCreatureOrdinalInCell[returnNextVal(AL0700_i_SecondaryDirection)];
+		}
+	}
+	L0704_ui_ProjectileMapX = srcMapX; /* Check impacts with projectiles on the source square */
+	L0705_ui_ProjectileMapY = srcMapY;
+T0266017_CheckProjectileImpacts:
+	L0697_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0704_ui_ProjectileMapX, L0705_ui_ProjectileMapY);
+	while (L0697_T_Thing != Thing::_endOfList) {
+		if (((L0697_T_Thing).getType() == k14_ProjectileThingType) &&
+			(_vm->_timeline->_g370_events[(((Projectile*)_vm->_dungeonMan->_g284_thingData[k14_ProjectileThingType])[(L0697_T_Thing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts) && (AL0699_ui_ChampionOrCreatureOrdinal = L0707_auc_ChampionOrCreatureOrdinalInCell[(L0697_T_Thing).getCell()]) &&
+			_vm->_projexpl->f217_projectileHasImpactOccurred(L0702_i_ImpactType, srcMapX, srcMapY, _vm->M1_ordinalToIndex(AL0699_ui_ChampionOrCreatureOrdinal), L0697_T_Thing)) {
+			_vm->_projexpl->f214_projectileDeleteEvent(L0697_T_Thing);
+			if (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup) {
+				return true;
+			}
+			goto T0266017_CheckProjectileImpacts;
+		}
+		L0697_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0697_T_Thing);
+	}
+	if (L0703_B_CheckDestinationSquareProjectileImpacts) {
+		srcMapX |= ((L0704_ui_ProjectileMapX = destMapX) + 1) << 8; /* Check impacts with projectiles on the destination square */
+		srcMapY |= (L0705_ui_ProjectileMapY = destMapY) << 8;
+		for (uint16 i = 0; i < 4; ++i)
+			L0707_auc_ChampionOrCreatureOrdinalInCell[i] = L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[i];
+		L0703_B_CheckDestinationSquareProjectileImpacts = false;
+		goto T0266017_CheckProjectileImpacts;
+	}
+	return false;
+}
+
+void MovesensMan::f268_addEvent(byte type, byte mapX, byte mapY, byte cell, byte effect, int32 time) {
+	TimelineEvent L0729_s_Event;
+
+
+	M33_setMapAndTime(L0729_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, time);
+	L0729_s_Event._type = type;
+	L0729_s_Event._priority = 0;
+	L0729_s_Event._B._location._mapX = mapX;
+	L0729_s_Event._B._location._mapY = mapY;
+	L0729_s_Event._C.A._cell = cell;
+	L0729_s_Event._C.A._effect = effect;
+	_vm->_timeline->f238_addEventGetEventIndex(&L0729_s_Event);
+}
+
+int16 MovesensMan::f514_getSound(byte creatureType) {
+	if (_vm->_championMan->_g300_partyIsSleeping) {
+		return 35;
+	}
+
+	switch (creatureType) {
+	case k3_CreatureTypeWizardEyeFlyingEye:
+	case k8_CreatureTypeGhostRive:
+	case k11_CreatureTypeBlackFlame:
+	case k19_CreatureTypeMaterializerZytaz:
+	case k23_CreatureTypeLordChaos:
+	case k25_CreatureTypeLordOrder:
+	case k26_CreatureTypeGreyLord:
+		return 35;
+	case k2_CreatureTypeGiggler:
+	case k9_CreatureTypeStoneGolem:
+	case k10_CreatureTypeMummy:
+	case k14_CreatureTypeVexirk:
+	case k16_CreatureTypeTrolinAntman:
+	case k22_CreatureTypeDemon:
+		return k24_soundMOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON;
+	case k0_CreatureTypeGiantScorpionScorpion:
+	case k4_CreatureTypePainRatHellHound:
+	case k5_CreatureTypeRuster:
+	case k6_CreatureTypeScreamer:
+	case k7_CreatureTypeRockpile:
+	case k15_CreatureTypeMagnetaWormWorm:
+	case k21_CreatureTypeOitu:
+		return k26_soundMOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU;
+	case k24_CreatureTypeRedDragon:
+		return k32_soundMOVE_RED_DRAGON;
+	case k12_CreatureTypeSkeleton:
+		return k33_soundMOVE_SKELETON;
+	case k18_CreatureTypeAnimatedArmourDethKnight:
+		return k22_soundMOVE_ANIMATED_ARMOUR_DETH_KNIGHT;
+	case k1_CreatureTypeSwampSlimeSlime:
+	case k20_CreatureTypeWaterElemental:
+		return k27_soundMOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL;
+	case k13_CreatureTypeCouatl:
+	case k17_CreatureTypeGiantWaspMuncher:
+		return k23_soundMOVE_COUATL_GIANT_WASP_MUNCHER;
+	}
+	return -1000; // if this is returned, it's an error, this should break it good
+}
+
+int16 MovesensMan::f262_getTeleporterRotatedGroupResult(Teleporter* teleporter, Thing thing, uint16 mapIndex) {
+	int16 L0683_i_Rotation;
+	uint16 L0684_ui_GroupDirections;
+	uint16 L0685_ui_UpdatedGroupDirections;
+	Group* L0686_ps_Group;
+	uint16 L0687_ui_UpdatedGroupCells;
+	int16 L0688_i_CreatureIndex;
+	bool L0689_B_AbsoluteRotation;
+	uint16 L0690_ui_GroupCells;
+	int16 L0691_i_CreatureSize;
+	int16 L0692_i_RelativeRotation;
+
+	L0686_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing);
+	L0683_i_Rotation = teleporter->getRotation();
+	L0684_ui_GroupDirections = _vm->_groupMan->f147_getGroupDirections(L0686_ps_Group, mapIndex);
+	if (L0689_B_AbsoluteRotation = teleporter->getAbsoluteRotation()) {
+		L0685_ui_UpdatedGroupDirections = L0683_i_Rotation;
+	} else {
+		L0685_ui_UpdatedGroupDirections = M21_normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation);
+	}
+	if ((L0687_ui_UpdatedGroupCells = _vm->_groupMan->f145_getGroupCells(L0686_ps_Group, mapIndex)) != k255_CreatureTypeSingleCenteredCreature) {
+		L0690_ui_GroupCells = L0687_ui_UpdatedGroupCells;
+		L0691_i_CreatureSize = getFlag(g243_CreatureInfo[L0686_ps_Group->_type]._attributes, k0x0003_MaskCreatureInfo_size);
+		L0692_i_RelativeRotation = M21_normalizeModulo4(4 + L0685_ui_UpdatedGroupDirections - L0684_ui_GroupDirections);
+		for (L0688_i_CreatureIndex = 0; L0688_i_CreatureIndex <= L0686_ps_Group->getCount(); L0688_i_CreatureIndex++) {
+			L0685_ui_UpdatedGroupDirections = _vm->_groupMan->f178_getGroupValueUpdatedWithCreatureValue(L0685_ui_UpdatedGroupDirections, L0688_i_CreatureIndex, L0689_B_AbsoluteRotation ? L0683_i_Rotation : M21_normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation));
+			if ((L0691_i_CreatureSize == k0_MaskCreatureSizeQuarter) && (L0692_i_RelativeRotation = !L0689_B_AbsoluteRotation)) {
+				L0692_i_RelativeRotation = L0683_i_Rotation;
+			}
+			if (L0692_i_RelativeRotation) {
+				L0687_ui_UpdatedGroupCells = _vm->_groupMan->f178_getGroupValueUpdatedWithCreatureValue(L0687_ui_UpdatedGroupCells, L0688_i_CreatureIndex, M21_normalizeModulo4(L0690_ui_GroupCells + L0692_i_RelativeRotation));
+			}
+			L0684_ui_GroupDirections >>= 2;
+			L0690_ui_GroupCells >>= 2;
+		}
+	}
+	_vm->_dungeonMan->f148_setGroupDirections(L0686_ps_Group, L0685_ui_UpdatedGroupDirections, mapIndex);
+	_vm->_dungeonMan->f146_setGroupCells(L0686_ps_Group, L0687_ui_UpdatedGroupCells, mapIndex);
+	if ((mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0686_ps_Group->setBehaviour(k6_behavior_ATTACK))) {
+		return L0686_ps_Group->getActiveGroupIndex() + 2;
+	}
+	return 1;
+}
+
+Thing MovesensMan::f263_getTeleporterRotatedProjectileThing(Teleporter* teleporter, Thing projectileThing) {
+	int16 L0693_i_UpdatedDirection;
+	int16 L0694_i_Rotation;
+
+
+	L0693_i_UpdatedDirection = _g400_moveResultDir;
+	L0694_i_Rotation = teleporter->getRotation();
+	if (teleporter->getAbsoluteRotation()) {
+		L0693_i_UpdatedDirection = L0694_i_Rotation;
+	} else {
+		L0693_i_UpdatedDirection = M21_normalizeModulo4(L0693_i_UpdatedDirection + L0694_i_Rotation);
+		projectileThing = M15_thingWithNewCell(projectileThing, M21_normalizeModulo4((projectileThing).getCell() + L0694_i_Rotation));
+	}
+	_g400_moveResultDir = L0693_i_UpdatedDirection;
+	return projectileThing;
+}
+
+void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing thing, bool partySquare, bool addThing) {
+	Thing L0766_T_Thing;
+	int16 L0767_i_ThingType;
+	bool L0768_B_TriggerSensor;
+	Sensor* L0769_ps_Sensor;
+	uint16 L0770_ui_SensorTriggeredCell;
+	uint16 L0771_ui_ThingType;
+	bool L0772_B_SquareContainsObject;
+	bool L0773_B_SquareContainsGroup;
+	int16 L0774_i_ObjectType;
+	bool L0775_B_SquareContainsThingOfSameType;
+	bool L0776_B_SquareContainsThingOfDifferentType;
+	uint16 L0777_ui_Square;
+	int16 L0778_i_Effect;
+	int16 L0779_i_SensorData;
+
+
+	if (thing != Thing::_party) {
+		L0767_i_ThingType = (thing).getType();
+		L0774_i_ObjectType = _vm->_objectMan->f32_getObjectType(thing);
+	} else {
+		L0767_i_ThingType = kM1_PartyThingType;
+		L0774_i_ObjectType = kM1_IconIndiceNone;
+	}
+	if ((!addThing) && (L0767_i_ThingType != kM1_PartyThingType)) {
+		_vm->_dungeonMan->f164_unlinkThingFromList(thing, Thing(0), mapX, mapY);
+	}
+	if (Square(L0777_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType() == k0_ElementTypeWall) {
+		L0770_ui_SensorTriggeredCell = (thing).getCell();
+	} else {
+		L0770_ui_SensorTriggeredCell = (uint16)kM1_CellAny; // this will wrap around
+	}
+	L0772_B_SquareContainsObject = L0773_B_SquareContainsGroup = L0775_B_SquareContainsThingOfSameType = L0776_B_SquareContainsThingOfDifferentType = false;
+	L0766_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
+	if (L0770_ui_SensorTriggeredCell == kM1_CellAny) {
+		while (L0766_T_Thing != Thing::_endOfList) {
+			if ((L0771_ui_ThingType = (L0766_T_Thing).getType()) == k4_GroupThingType) {
+				L0773_B_SquareContainsGroup = true;
+			} else {
+				if ((L0771_ui_ThingType == k2_TextstringType) && (L0767_i_ThingType == kM1_PartyThingType) && addThing && !partySquare) {
+					_vm->_dungeonMan->f168_decodeText(_vm->_g353_stringBuildBuffer, L0766_T_Thing, k1_TextTypeMessage);
+					_vm->_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, _vm->_g353_stringBuildBuffer);
+				} else {
+					if ((L0771_ui_ThingType > k4_GroupThingType) && (L0771_ui_ThingType < k14_ProjectileThingType)) {
+						L0772_B_SquareContainsObject = true;
+						L0775_B_SquareContainsThingOfSameType |= (_vm->_objectMan->f32_getObjectType(L0766_T_Thing) == L0774_i_ObjectType);
+						L0776_B_SquareContainsThingOfDifferentType |= (_vm->_objectMan->f32_getObjectType(L0766_T_Thing) != L0774_i_ObjectType);
+					}
+				}
+			}
+			L0766_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0766_T_Thing);
+		}
+	} else {
+		while (L0766_T_Thing != Thing::_endOfList) {
+			if ((L0770_ui_SensorTriggeredCell == (L0766_T_Thing).getCell()) && ((L0766_T_Thing).getType() > k4_GroupThingType)) {
+				L0772_B_SquareContainsObject = true;
+				L0775_B_SquareContainsThingOfSameType |= (_vm->_objectMan->f32_getObjectType(L0766_T_Thing) == L0774_i_ObjectType);
+				L0776_B_SquareContainsThingOfDifferentType |= (_vm->_objectMan->f32_getObjectType(L0766_T_Thing) != L0774_i_ObjectType);
+			}
+			L0766_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0766_T_Thing);
+		}
+	}
+	if (addThing && (L0767_i_ThingType != kM1_PartyThingType)) {
+		_vm->_dungeonMan->f163_linkThingToList(thing, Thing(0), mapX, mapY);
+	}
+	L0766_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
+	while (L0766_T_Thing != Thing::_endOfList) {
+		if ((L0771_ui_ThingType = (L0766_T_Thing).getType()) == k3_SensorThingType) {
+			L0769_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0766_T_Thing);
+			if ((L0769_ps_Sensor)->getType() == k0_SensorDisabled)
+				goto T0276079;
+			L0779_i_SensorData = L0769_ps_Sensor->getData();
+			L0768_B_TriggerSensor = addThing;
+			if (L0770_ui_SensorTriggeredCell == kM1_CellAny) {
+				switch (L0769_ps_Sensor->getType()) {
+				case k1_SensorFloorTheronPartyCreatureObj:
+					if (partySquare || L0772_B_SquareContainsObject || L0773_B_SquareContainsGroup) /* BUG0_30 A floor sensor is not triggered when you put an object on the floor if a levitating creature is present on the same square. The condition to determine if the sensor should be triggered checks if there is a creature on the square but does not check whether the creature is levitating. While it is normal not to trigger the sensor if there is a non levitating creature on the square (because it was already triggered by the creature itself), a levitating creature should not prevent triggering the sensor with an object. */
+						goto T0276079;
+					break;
+				case k2_SensorFloorTheronPartyCreature:
+					if ((L0767_i_ThingType > k4_GroupThingType) || partySquare || L0773_B_SquareContainsGroup)
+						goto T0276079;
+					break;
+				case k3_SensorFloorParty:
+					if ((L0767_i_ThingType != kM1_PartyThingType) || (_vm->_championMan->_g305_partyChampionCount == 0))
+						goto T0276079;
+					if (L0779_i_SensorData == 0) {
+						if (partySquare)
+							goto T0276079;
+					} else {
+						if (!addThing) {
+							L0768_B_TriggerSensor = false;
+						} else {
+							L0768_B_TriggerSensor = (L0779_i_SensorData == _vm->M0_indexToOrdinal(_vm->_dungeonMan->_g308_partyDir));
+						}
+					}
+					break;
+				case k4_SensorFloorObj:
+					if ((L0779_i_SensorData != _vm->_objectMan->f32_getObjectType(thing)) || L0775_B_SquareContainsThingOfSameType)
+						goto T0276079;
+					break;
+				case k5_SensorFloorPartyOnStairs:
+					// Strangerke: Only present in v2.1, but it fixes a bug so we'll keep it.
+#ifdef COMPILE52_CSB21EN /* CHANGE8_05_FIX The wrong variable is replaced by the correct variable in the condition. The test should not be on L0771_ui_ThingType but on L0767_i_ThingType */
+					if ((L0767_i_ThingType != kM1_PartyThingType) || (M34_SQUARE_TYPE(L0777_ui_Square) != k3_ElementTypeStairs))
+#endif
+						goto T0276079;
+					break;
+				case k6_SensorFloorGroupGenerator:
+					goto T0276079;
+				case k7_SensorFloorCreature:
+					if ((L0767_i_ThingType > k4_GroupThingType) || (L0767_i_ThingType == kM1_PartyThingType) || L0773_B_SquareContainsGroup)
+						goto T0276079;
+					break;
+				case k8_SensorFloorPartyPossession:
+					if (L0767_i_ThingType != kM1_PartyThingType)
+						goto T0276079;
+					L0768_B_TriggerSensor = f274_sensorIsObjcetInPartyPossession(L0779_i_SensorData);
+					break;
+				case k9_SensorFloorVersionChecker:
+					if ((L0767_i_ThingType != kM1_PartyThingType) || !addThing || partySquare)
+						goto T0276079;
+					// Strangerke: 20 is a harcoded version of the game. later version uses 21. Not present in the original dungeons anyway.
+					L0768_B_TriggerSensor = (L0779_i_SensorData <= 20);
+					break;
+				default:
+					goto T0276079;
+				}
+			} else {
+				if (L0770_ui_SensorTriggeredCell != (L0766_T_Thing).getCell())
+					goto T0276079;
+				switch (L0769_ps_Sensor->getType()) {
+				case k1_SensorWallOrnClick:
+					if (L0772_B_SquareContainsObject)
+						goto T0276079;
+					break;
+				case k2_SensorWallOrnClickWithAnyObj:
+					if (L0775_B_SquareContainsThingOfSameType || (L0769_ps_Sensor->getData() != _vm->_objectMan->f32_getObjectType(thing)))
+						goto T0276079;
+					break;
+				case k3_SensorWallOrnClickWithSpecObj:
+					if (L0776_B_SquareContainsThingOfDifferentType || (L0769_ps_Sensor->getData() == _vm->_objectMan->f32_getObjectType(thing)))
+						goto T0276079;
+					break;
+				default:
+					goto T0276079;
+				}
+			}
+			L0768_B_TriggerSensor ^= L0769_ps_Sensor->getRevertEffectA();
+			if ((L0778_i_Effect = L0769_ps_Sensor->getEffectA()) == k3_SensorEffHold) {
+				L0778_i_Effect = L0768_B_TriggerSensor ? k0_SensorEffSet : k1_SensorEffClear;
+			} else {
+				if (!L0768_B_TriggerSensor)
+					goto T0276079;
+			}
+			if (L0769_ps_Sensor->getAudibleA()) {
+				warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			}
+			f272_sensorTriggerEffect(L0769_ps_Sensor, L0778_i_Effect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
+			goto T0276079;
+		}
+		if (L0771_ui_ThingType >= k4_GroupThingType)
+			break;
+T0276079:
+		L0766_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0766_T_Thing);
+	}
+	f271_processRotationEffect();
+}
+
+bool MovesensMan::f274_sensorIsObjcetInPartyPossession(int16 objectType) {
+	int16 L0742_i_ChampionIndex;
+	uint16 L0743_ui_SlotIndex = 0;
+	Thing L0744_T_Thing = Thing::_none;
+	Champion* L0745_ps_Champion;
+	Thing* L0746_pT_Thing = nullptr;
+	int16 L0747_i_ObjectType;
+	bool L0748_B_LeaderHandObjectProcessed;
+	Container* L0749_ps_Container;
+
+
+	L0748_B_LeaderHandObjectProcessed = false;
+	for (L0742_i_ChampionIndex = k0_ChampionFirst, L0745_ps_Champion = _vm->_championMan->_gK71_champions; L0742_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0742_i_ChampionIndex++, L0745_ps_Champion++) {
+		if (L0745_ps_Champion->_currHealth) {
+			L0746_pT_Thing = L0745_ps_Champion->_slots;
+			for (L0743_ui_SlotIndex = k0_ChampionSlotReadyHand; (L0743_ui_SlotIndex < k30_ChampionSlotChest_1) && !L0748_B_LeaderHandObjectProcessed; L0743_ui_SlotIndex++) {
+				L0744_T_Thing = *L0746_pT_Thing++;
+T0274003:
+				if ((L0747_i_ObjectType = _vm->_objectMan->f32_getObjectType(L0744_T_Thing)) == objectType) {
+					return true;
+				}
+				if (L0747_i_ObjectType == k144_IconIndiceContainerChestClosed) {
+					L0749_ps_Container = (Container*)_vm->_dungeonMan->f156_getThingData(L0744_T_Thing);
+					L0744_T_Thing = L0749_ps_Container->getSlot();
+					while (L0744_T_Thing != Thing::_endOfList) {
+						if (_vm->_objectMan->f32_getObjectType(L0744_T_Thing) == objectType) {
+							return true;
+						}
+						L0744_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0744_T_Thing);
+					}
+				}
+			}
+		}
+	}
+	if (!L0748_B_LeaderHandObjectProcessed) {
+		L0748_B_LeaderHandObjectProcessed = true;
+		L0744_T_Thing = _vm->_championMan->_g414_leaderHandObject;
+		goto T0274003;
+	}
+	return false;
+}
+
+void MovesensMan::f272_sensorTriggerEffect(Sensor* sensor, int16 effect, int16 mapX, int16 mapY, uint16 cell) {
+	byte g59_squareTypeToEventType[7] = { // @ G0059_auc_Graphic562_SquareTypeToEventType
+		k6_TMEventTypeWall,
+		k5_TMEventTypeCorridor,
+		k9_TMEventTypePit,
+		k0_TMEventTypeNone,
+		k10_TMEventTypeDoor,
+		k8_TMEventTypeTeleporter,
+		k7_TMEventTypeFakeWall}; /* 1 byte of padding inserted by compiler */
+
+	int16 L0736_i_TargetMapX;
+	int16 L0737_i_TargetMapY;
+	register long L0738_l_Time;
+	uint16 L0739_ui_SquareType;
+	uint16 L0740_ui_TargetCell;
+
+
+	if (sensor->getOnlyOnce()) {
+		sensor->setTypeDisabled();
+	}
+	L0738_l_Time = _vm->_g313_gameTime + sensor->getValue();
+	if (sensor->getLocalEffect()) {
+		f270_sensorTriggetLocalEffect(sensor->M49_localEffect(), mapX, mapY, cell);
+	} else {
+		L0736_i_TargetMapX = sensor->getTargetMapX();
+		L0737_i_TargetMapY = sensor->getTargetMapY();
+		L0739_ui_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[L0736_i_TargetMapX][L0737_i_TargetMapY]).getType();
+		if (L0739_ui_SquareType == k0_ElementTypeWall) {
+			L0740_ui_TargetCell = sensor->getTargetCell();
+		} else {
+			L0740_ui_TargetCell = k0_CellNorthWest;
+		}
+		f268_addEvent(g59_squareTypeToEventType[L0739_ui_SquareType], L0736_i_TargetMapX, L0737_i_TargetMapY, L0740_ui_TargetCell, effect, L0738_l_Time);
+	}
+}
+
+void MovesensMan::f270_sensorTriggetLocalEffect(int16 localEffect, int16 effX, int16 effY, int16 effCell) {
+	if (localEffect == k10_SensorEffAddExp) {
+		f269_sensorAddSkillExperience(k8_ChampionSkillSteal, 300, localEffect != kM1_CellAny);
+		return;
 	}
-	warning("MISSING CODE: F0271_SENSOR_ProcessRotationEffect");
-	return atLeastOneSensorWasTriggered;
+	_g403_sensorRotationEffect = localEffect;
+	_g404_sensorRotationEffMapX = effX;
+	_g405_sensorRotationEffMapY = effY;
+	_g406_sensorRotationEffCell = effCell;
 }
 
+void MovesensMan::f269_sensorAddSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly) {
+	int16 L0730_i_ChampionIndex;
+	Champion* L0731_ps_Champion;
+
+	if (leaderOnly) {
+		if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) {
+			_vm->_championMan->f304_addSkillExperience(_vm->_championMan->_g411_leaderIndex, skillIndex, exp);
+		}
+	} else {
+		exp /= _vm->_championMan->_g305_partyChampionCount;
+		for (L0730_i_ChampionIndex = k0_ChampionFirst, L0731_ps_Champion = _vm->_championMan->_gK71_champions; L0730_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0730_i_ChampionIndex++, L0731_ps_Champion++) {
+			if (L0731_ps_Champion->_currHealth) {
+				_vm->_championMan->f304_addSkillExperience(L0730_i_ChampionIndex, skillIndex, exp);
+			}
+		}
+	}
+}
+
+void MovesensMan::f271_processRotationEffect() {
+	Thing L0732_T_FirstSensorThing;
+	Thing L0733_T_LastSensorThing;
+	Sensor* L0734_ps_FirstSensor;
+	Sensor* L0735_ps_LastSensor;
+
+
+	if (_g403_sensorRotationEffect == kM1_SensorEffNone) {
+		return;
+	}
+	switch (_g403_sensorRotationEffect) {
+	case k1_SensorEffClear:
+	case k2_SensorEffToggle:
+		L0732_T_FirstSensorThing = _vm->_dungeonMan->f161_getSquareFirstThing(_g404_sensorRotationEffMapX, _g405_sensorRotationEffMapY);
+		while (((L0732_T_FirstSensorThing).getType() != k3_SensorThingType) || ((_g406_sensorRotationEffCell != kM1_CellAny) && ((L0732_T_FirstSensorThing).getCell() != _g406_sensorRotationEffCell))) {
+			L0732_T_FirstSensorThing = _vm->_dungeonMan->f159_getNextThing(L0732_T_FirstSensorThing);
+		}
+		L0734_ps_FirstSensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0732_T_FirstSensorThing);
+		L0733_T_LastSensorThing = L0734_ps_FirstSensor->getNextThing();
+		while ((L0733_T_LastSensorThing != Thing::_endOfList) && (((L0733_T_LastSensorThing).getType() != k3_SensorThingType) || ((_g406_sensorRotationEffCell != kM1_CellAny) && ((L0733_T_LastSensorThing).getCell() != _g406_sensorRotationEffCell)))) {
+			L0733_T_LastSensorThing = _vm->_dungeonMan->f159_getNextThing(L0733_T_LastSensorThing);
+		}
+		if (L0733_T_LastSensorThing == Thing::_endOfList)
+			break;
+		_vm->_dungeonMan->f164_unlinkThingFromList(L0732_T_FirstSensorThing, Thing(0), _g404_sensorRotationEffMapX, _g405_sensorRotationEffMapY);
+		L0735_ps_LastSensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0733_T_LastSensorThing);
+		L0733_T_LastSensorThing = _vm->_dungeonMan->f159_getNextThing(L0733_T_LastSensorThing);
+		while (((L0733_T_LastSensorThing != Thing::_endOfList) && ((L0733_T_LastSensorThing).getType() == k3_SensorThingType))) {
+			if ((_g406_sensorRotationEffCell == kM1_CellAny) || ((L0733_T_LastSensorThing).getCell() == _g406_sensorRotationEffCell)) {
+				L0735_ps_LastSensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0733_T_LastSensorThing);
+			}
+			L0733_T_LastSensorThing = _vm->_dungeonMan->f159_getNextThing(L0733_T_LastSensorThing);
+		}
+		L0734_ps_FirstSensor->setNextThing(L0735_ps_LastSensor->getNextThing());
+		L0735_ps_LastSensor->setNextThing(L0732_T_FirstSensorThing);
+	}
+	_g403_sensorRotationEffect = kM1_SensorEffNone;
+}
+
+void MovesensMan::f265_createEvent60to61_moveGroup(Thing groupThing, int16 mapX, int16 mapY, int16 mapIndex, bool audible) {
+	TimelineEvent L0696_s_Event;
+
+	M33_setMapAndTime(L0696_s_Event._mapTime, mapIndex, _vm->_g313_gameTime + 5);
+	L0696_s_Event._type = audible ? k61_TMEventTypeMoveGroupAudible : k60_TMEventTypeMoveGroupSilent;
+	L0696_s_Event._priority = 0;
+	L0696_s_Event._B._location._mapX = mapX;
+	L0696_s_Event._B._location._mapY = mapY;
+	L0696_s_Event._C._slot = groupThing;
+	_vm->_timeline->f238_addEventGetEventIndex(&L0696_s_Event);
+}
+
+Thing MovesensMan::f273_sensorGetObjectOfTypeInCell(int16 mapX, int16 mapY, int16 cell, int16 objectType) {
+	Thing L0741_T_Thing;
+
+
+	L0741_T_Thing = _vm->_dungeonMan->f162_getSquareFirstObject(mapX, mapY);
+	while (L0741_T_Thing != Thing::_endOfList) {
+		if (_vm->_objectMan->f32_getObjectType(L0741_T_Thing) == objectType) {
+			if ((cell == kM1_CellAny) || ((L0741_T_Thing.getCell()) == cell)) {
+				return L0741_T_Thing;
+			}
+		}
+		L0741_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0741_T_Thing);
+	}
+	return Thing::_none;
+}
 }
diff --git a/engines/dm/movesens.h b/engines/dm/movesens.h
index 6a8a53a..79a1fa9 100644
--- a/engines/dm/movesens.h
+++ b/engines/dm/movesens.h
@@ -32,12 +32,43 @@
 #include "dm.h"
 
 namespace DM {
+	class Sensor;
+	class Teleporter;
 
-class MovesensMan {
+	class MovesensMan {
 	DMEngine *_vm;
 public:
+	int16 _g397_moveResultMapX; // @ G0397_i_MoveResultMapX
+	int16 _g398_moveResultMapY; // @ G0398_i_MoveResultMapY
+	uint16 _g399_moveResultMapIndex; // @ G0399_ui_MoveResultMapIndex
+	int16 _g400_moveResultDir; // @ G0400_i_MoveResultDirection
+	uint16 _g401_moveResultCell; // @ G0401_ui_MoveResultCell
+	bool _g402_useRopeToClimbDownPit; // @ G0402_B_UseRopeToClimbDownPit
+	int16 _g403_sensorRotationEffect; // @ G0403_i_SensorRotationEffect
+	int16 _g404_sensorRotationEffMapX; // @ G0404_i_SensorRotationEffectMapX
+	int16 _g405_sensorRotationEffMapY; // @ G0405_i_SensorRotationEffectMapY
+	int16 _g406_sensorRotationEffCell; // @ G0406_i_SensorRotationEffectCell
 	explicit MovesensMan(DMEngine *vm);
 	bool f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam); // @ F0275_SENSOR_IsTriggeredByClickOnWall
+	bool f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destMapX, int16 destMapY); // @ F0267_MOVE_GetMoveResult_CPSCE
+	bool f264_isLevitating(Thing thing); // @ F0264_MOVE_IsLevitating
+	bool f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY, Thing thing); // @ F0266_MOVE_IsKilledByProjectileImpact
+	void f268_addEvent(byte type, byte mapX, byte mapY, byte cell, byte effect, int32 time); // @ F0268_SENSOR_AddEvent
+	int16 f514_getSound(byte creatureType); // @ F0514_MOVE_GetSound
+	int16 f262_getTeleporterRotatedGroupResult(Teleporter *teleporter, Thing thing, uint16 mapIndex);// @ F0262_MOVE_GetTeleporterRotatedGroupResult
+	Thing f263_getTeleporterRotatedProjectileThing(Teleporter *teleporter, Thing projectileThing); // @ F0263_MOVE_GetTeleporterRotatedProjectileThing
+	void f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing thing, bool partySquare, bool addThing);// @ F0276_SENSOR_ProcessThingAdditionOrRemoval
+	bool f274_sensorIsObjcetInPartyPossession(int16 objectType); // @ F0274_SENSOR_IsObjectInPartyPossession
+	void f272_sensorTriggerEffect(Sensor *sensor, int16 effect, int16 mapX, int16 mapY, uint16 cell); // @ F0272_SENSOR_TriggerEffect
+	void f270_sensorTriggetLocalEffect(int16 localEffect, int16 effX, int16 effY, int16 effCell); // @ F0270_SENSOR_TriggerLocalEffect
+	void f269_sensorAddSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly); // @ F0269_SENSOR_AddSkillExperience
+	void f271_processRotationEffect();// @ F0271_SENSOR_ProcessRotationEffect
+	void f265_createEvent60to61_moveGroup(Thing groupThing, int16 mapX, int16 mapY, int16 mapIndex, bool audible); // @ F0265_MOVE_CreateEvent60To61_MoveGroup
+	Thing f273_sensorGetObjectOfTypeInCell(int16 mapX, int16 mapY, int16 cell, int16 objectType); // @ F0273_SENSOR_GetObjectOfTypeInCell
+
+
+
+
 };
 
 }
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index ff7ff4d..157cfd8 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -252,4 +252,10 @@ void ObjectMan::f34_drawLeaderObjectName(Thing thing) {
 IconIndice ObjectMan::f39_getIconIndexInSlotBox(uint16 slotBoxIndex) {
 	return (IconIndice)_g30_slotBoxes[slotBoxIndex]._iconIndex;
 }
+
+void ObjectMan::f35_clearLeaderObjectName() {
+	static Box g28_BoxLeaderHandObjectName(233, 319, 33, 38); // @ G0028_s_Graphic562_Box_LeaderHandObjectName 
+	_vm->_displayMan->D24_fillScreenBox(g28_BoxLeaderHandObjectName, k0_ColorBlack);
+}
+
 }
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index b01957d..3f90f80 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -64,6 +64,7 @@ public:
 	void f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox
 	void f34_drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName
 	IconIndice f39_getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox
+	void f35_clearLeaderObjectName(); // @ F0035_OBJECT_ClearLeaderHandObjectName
 
 
 };
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
new file mode 100644
index 0000000..95d40bb
--- /dev/null
+++ b/engines/dm/projexpl.cpp
@@ -0,0 +1,418 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+
+#include "projexpl.h"
+#include "dungeonman.h"
+#include "timeline.h"
+#include "group.h"
+#include "objectman.h"
+#include "movesens.h"
+
+namespace DM {
+
+ProjExpl::ProjExpl(DMEngine* vm) : _vm(vm) {
+	_g361_lastCreatureAttackTime = -200;
+}
+
+void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, direction dir, byte kineticEnergy, byte attack, byte stepEnergy) {
+	Thing L0466_T_ProjectileThing;
+	Projectile* L0467_ps_Projectile;
+	TimelineEvent L0468_s_Event;
+
+
+	if ((L0466_T_ProjectileThing = _vm->_dungeonMan->f166_getUnusedThing(k14_ProjectileThingType)) == Thing::_none) { /* BUG0_16 If the game cannot create a projectile thing because it has run out of such things (60 maximum) then the object being thrown/shot/launched is orphaned. If the game has run out of projectile things it will try to remove a projectile from elsewhere in the dungeon, except in an area of 11x11 squares centered around the party (to make sure the player cannot actually see the thing disappear on screen) */
+		return;
+	}
+	L0466_T_ProjectileThing = M15_thingWithNewCell(L0466_T_ProjectileThing, cell);
+	L0467_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(L0466_T_ProjectileThing);
+	L0467_ps_Projectile->_slot = thing;
+	L0467_ps_Projectile->_kineticEnergy = MIN((int16)kineticEnergy, (int16)255);
+	L0467_ps_Projectile->_attack = attack;
+	_vm->_dungeonMan->f163_linkThingToList(L0466_T_ProjectileThing, Thing(0), mapX, mapY); /* Projectiles are added on the square and not 'moved' onto the square. In the case of a projectile launcher sensor, this means that the new projectile traverses the square in front of the launcher without any trouble: there is no impact if it is a wall, the projectile direction is not changed if it is a teleporter. Impacts with creatures and champions are still processed */
+	M33_setMapAndTime(L0468_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + 1);
+	if (_g365_createLanucherProjectile) {
+		L0468_s_Event._type = k49_TMEventTypeMoveProjectile; /* Launcher projectiles can impact immediately */
+	} else {
+		L0468_s_Event._type = k48_TMEventTypeMoveProjectileIgnoreImpacts; /* Projectiles created by champions or creatures ignore impacts on their first movement */
+	}
+	L0468_s_Event._priority = 0;
+	L0468_s_Event._B._slot = L0466_T_ProjectileThing;
+	L0468_s_Event._C._projectile.setMapX(mapX);
+	L0468_s_Event._C._projectile.setMapY(mapY);
+	L0468_s_Event._C._projectile.setStepEnergy(stepEnergy);
+	L0468_s_Event._C._projectile.setDir(dir);
+	L0467_ps_Projectile->_eventIndex = _vm->_timeline->f238_addEventGetEventIndex(&L0468_s_Event);
+}
+
+bool ProjExpl::f217_projectileHasImpactOccurred(int16 impactType, int16 mapXCombo, int16 mapYCombo, int16 cell, Thing projectileThing) {
+#define AP0454_i_ProjectileTargetMapX mapXCombo
+#define AP0455_i_ProjectileTargetMapY mapYCombo
+#define AP0456_i_ChampionIndex cell
+	Projectile* L0490_ps_Projectile;
+	Group* L0491_ps_Group;
+	Thing L0486_T_ProjectileAssociatedThing;
+	int16 L0487_i_Multiple;
+#define AL0487_i_DoorState  L0487_i_Multiple
+#define AL0487_i_IconIndex  L0487_i_Multiple
+#define AL0487_i_Outcome    L0487_i_Multiple
+#define AL0487_i_WeaponType L0487_i_Multiple
+	int16 L0488_i_Attack = 0;
+	Potion* L0492_ps_Potion = nullptr;
+	CreatureInfo* L0493_ps_CreatureInfo;
+	Door* L0494_ps_Door;
+	Weapon* L0495_ps_Weapon;
+	uint16* L0496_pui_CreatureHealth;
+	Thing* L0497_pT_GroupSlot;
+	Thing L0498_T_ExplosionThing;
+	int16 L0499_i_ProjectileMapX;
+	int16 L0500_i_ProjectileMapY;
+	int16 L0501_i_MapXCombo;
+	int16 L0502_i_MapYCombo;
+	byte L0503_uc_Square;
+	bool L0505_B_CreateExplosionOnImpact;
+	int16 L0489_i_ChampionAttack;
+	uint16 L0507_ui_Multiple;
+#define AL0507_ui_ExplosionAttack L0507_ui_Multiple
+#define AL0507_ui_SoundIndex      L0507_ui_Multiple
+	int16 L0508_i_PotionPower = 0;
+	bool L0509_B_RemovePotion;
+	int16 L0510_i_ProjectileAssociatedThingType;
+	uint16 L0511_ui_CreatureType;
+	uint16 L0512_ui_CreatureIndex;
+
+	L0490_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(Thing(projectileThing));
+	L0501_i_MapXCombo = mapXCombo;
+	L0502_i_MapYCombo = mapYCombo;
+	L0509_B_RemovePotion = false;
+	_g364_creatureDamageOutcome = k0_outcomeKilledNoCreaturesInGroup;
+	if ((L0510_i_ProjectileAssociatedThingType = (L0486_T_ProjectileAssociatedThing = L0490_ps_Projectile->_slot).getType()) == k8_PotionThingType) {
+		L0491_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0486_T_ProjectileAssociatedThing);
+		switch (((Potion*)L0491_ps_Group)->getType()) {
+		case k3_PotionTypeVen:
+			L0498_T_ExplosionThing = Thing::_explPoisonCloud;
+			goto T0217004;
+		case k19_PotionTypeFulBomb:
+			L0498_T_ExplosionThing = Thing::_explFireBall;
+T0217004:
+			L0509_B_RemovePotion = true;
+			L0508_i_PotionPower = ((Potion*)L0491_ps_Group)->getPower();
+			L0492_ps_Potion = (Potion*)L0491_ps_Group;
+		}
+	}
+	L0505_B_CreateExplosionOnImpact = (L0510_i_ProjectileAssociatedThingType == k15_ExplosionThingType) && (L0486_T_ProjectileAssociatedThing != Thing::_explSlime) && (L0486_T_ProjectileAssociatedThing != Thing::_explPoisonBolt);
+	L0497_pT_GroupSlot = NULL;
+	L0489_i_ChampionAttack = 0;
+	if (mapXCombo <= 255) {
+		L0499_i_ProjectileMapX = mapXCombo;
+		L0500_i_ProjectileMapY = mapYCombo;
+	} else {
+		L0499_i_ProjectileMapX = (mapXCombo >> 8) - 1;
+		L0500_i_ProjectileMapY = (mapYCombo >> 8);
+		AP0454_i_ProjectileTargetMapX &= 0x00FF;
+		AP0455_i_ProjectileTargetMapY &= 0x00FF;
+	}
+	switch (impactType) {
+	case k4_DoorElemType:
+		AL0487_i_DoorState = Square(L0503_uc_Square = _vm->_dungeonMan->_g271_currMapData[AP0454_i_ProjectileTargetMapX][AP0455_i_ProjectileTargetMapY]).getDoorState();
+		L0494_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY);
+		if ((AL0487_i_DoorState != k5_doorState_DESTROYED) && (L0486_T_ProjectileAssociatedThing == Thing::_explOpenDoor)) {
+			if (L0494_ps_Door->hasButton()) {
+				_vm->_movsens->f268_addEvent(k10_TMEventTypeDoor, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1);
+			}
+			break;
+		}
+		if ((AL0487_i_DoorState == k5_doorState_DESTROYED) ||
+			(AL0487_i_DoorState <= k1_doorState_FOURTH) ||
+			(getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[L0494_ps_Door->getType()]._attributes, k0x0002_MaskDoorInfo_ProjectilesCanPassThrough) &&
+			((L0510_i_ProjectileAssociatedThingType == k15_ExplosionThingType) ?
+			 (L0486_T_ProjectileAssociatedThing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) :
+			 ((L0490_ps_Projectile->_attack > _vm->getRandomNumber(128)) &&
+			  getFlag(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0486_T_ProjectileAssociatedThing)].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)
+			  && ((L0510_i_ProjectileAssociatedThingType != k10_JunkThingType) ||
+			  ((AL0487_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0486_T_ProjectileAssociatedThing)) < 0) ||
+				  (!((AL0487_i_IconIndex >= k176_IconIndiceJunkIronKey) && (AL0487_i_IconIndex <= k191_IconIndiceJunkMasterKey))))
+			  )))) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
+			return false;
+		}
+		L0488_i_Attack = f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing) + 1;
+		_vm->_groupMan->f232_groupIsDoorDestoryedByAttack(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, L0488_i_Attack + _vm->getRandomNumber(L0488_i_Attack), false, 0);
+		break;
+	case kM2_ChampionElemType:
+		if ((AP0456_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(cell)) < 0) {
+			return false;
+		}
+		L0489_i_ChampionAttack = L0488_i_Attack = f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing);
+		break;
+	case kM1_CreatureElemType:
+		L0491_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY));
+		if (!(L0512_ui_CreatureIndex = _vm->_groupMan->f176_getCreatureOrdinalInCell(L0491_ps_Group, cell))) {
+			return false;
+		}
+		L0512_ui_CreatureIndex--;
+		L0493_ps_CreatureInfo = &g243_CreatureInfo[L0511_ui_CreatureType = L0491_ps_Group->_type];
+		if ((L0486_T_ProjectileAssociatedThing == Thing::_explFireBall) && (L0511_ui_CreatureType == k11_CreatureTypeBlackFlame)) {
+			L0496_pui_CreatureHealth = &L0491_ps_Group->_health[L0512_ui_CreatureIndex];
+			*L0496_pui_CreatureHealth = MIN(1000, *L0496_pui_CreatureHealth + f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing));
+			goto T0217044;
+		}
+		if (getFlag(L0493_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) && (L0486_T_ProjectileAssociatedThing != Thing::_explHarmNonMaterial)) {
+			return false;
+		}
+		if (L0488_i_Attack = (uint16)((unsigned long)f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing) << 6) / L0493_ps_CreatureInfo->_defense) {
+			if ((AL0487_i_Outcome = _vm->_groupMan->f190_groupGetDamageCreatureOutcome(L0491_ps_Group, L0512_ui_CreatureIndex, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, L0488_i_Attack + _vm->_groupMan->f192_groupGetResistanceAdjustedPoisonAttack(L0511_ui_CreatureType, _g366_projectilePoisonAttack), true)) != k0_outcomeKilledNoCreaturesInGroup) {
+				_vm->_groupMan->f209_processEvents29to41(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, kM2_TMEventTypeCreateReactionEvent30HitByProjectile, 0);
+			}
+			_g364_creatureDamageOutcome = AL0487_i_Outcome;
+			if (!L0505_B_CreateExplosionOnImpact &&
+				(AL0487_i_Outcome == k0_outcomeKilledNoCreaturesInGroup) &&
+				(L0510_i_ProjectileAssociatedThingType == k5_WeaponThingType) &&
+				getFlag(L0493_ps_CreatureInfo->_attributes, k0x0400_MaskCreatureInfo_keepThrownSharpWeapon)) {
+				L0495_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0486_T_ProjectileAssociatedThing);
+				AL0487_i_WeaponType = L0495_ps_Weapon->getType();
+				if ((AL0487_i_WeaponType == k8_WeaponTypeDagger) || (AL0487_i_WeaponType == k27_WeaponTypeArrow) || (AL0487_i_WeaponType == k28_WeaponTypeSlayer) || (AL0487_i_WeaponType == k31_WeaponTypePoisonDart) || (AL0487_i_WeaponType == k32_WeaponTypeThrowingStar)) {
+					L0497_pT_GroupSlot = &L0491_ps_Group->_slot;
+				}
+			}
+		}
+	}
+	if (L0489_i_ChampionAttack && _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(AP0456_i_ChampionIndex, L0488_i_Attack, k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso, _g367_projectileAttackType) && _g366_projectilePoisonAttack && _vm->getRandomNumber(2)) {
+		_vm->_championMan->f322_championPoison(AP0456_i_ChampionIndex, _g366_projectilePoisonAttack);
+	}
+	if (L0505_B_CreateExplosionOnImpact || L0509_B_RemovePotion
+		) {
+		if (L0509_B_RemovePotion) {
+			L0486_T_ProjectileAssociatedThing = L0498_T_ExplosionThing;
+			AL0507_ui_ExplosionAttack = L0508_i_PotionPower;
+		} else {
+			AL0507_ui_ExplosionAttack = L0490_ps_Projectile->_kineticEnergy;
+		}
+		if ((L0486_T_ProjectileAssociatedThing == Thing::_explLightningBolt) && !(AL0507_ui_ExplosionAttack >>= 1))
+			goto T0217044;
+		f213_explosionCreate(L0486_T_ProjectileAssociatedThing, AL0507_ui_ExplosionAttack, L0501_i_MapXCombo, L0502_i_MapYCombo, (L0486_T_ProjectileAssociatedThing == Thing::_explPoisonCloud) ? k255_CreatureTypeSingleCenteredCreature : cell);
+	} else {
+		if ((L0486_T_ProjectileAssociatedThing).getType() == k5_WeaponThingType) {
+			AL0507_ui_SoundIndex = k00_soundMETALLIC_THUD;
+		} else {
+			if (L0486_T_ProjectileAssociatedThing == Thing::_explPoisonBolt) {
+				AL0507_ui_SoundIndex = k13_soundSPELL;
+			} else {
+				AL0507_ui_SoundIndex = k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM;
+			}
+		}
+		warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+	}
+T0217044:
+	if (L0509_B_RemovePotion) {
+		L0492_ps_Potion->_nextThing = Thing::_none;
+		L0490_ps_Projectile->_slot = L0498_T_ExplosionThing;
+	}
+	_vm->_dungeonMan->f164_unlinkThingFromList(projectileThing, Thing(0), L0499_i_ProjectileMapX, L0500_i_ProjectileMapY);
+	f215_projectileDelete(projectileThing, L0497_pT_GroupSlot, L0499_i_ProjectileMapX, L0500_i_ProjectileMapY);
+	return true;
+}
+
+uint16 ProjExpl::f216_projectileGetImpactAttack(Projectile* projectile, Thing thing) {
+	WeaponInfo* L0485_ps_WeaponInfo;
+	uint16 L0483_ui_Multiple;
+#define AL0483_ui_ThingType L0483_ui_Multiple
+#define AL0483_ui_Attack    L0483_ui_Multiple
+	uint16 L0484_ui_KineticEnergy;
+
+
+	_g366_projectilePoisonAttack = 0;
+	_g367_projectileAttackType = k3_attackType_BLUNT;
+
+	L0484_ui_KineticEnergy = projectile->_kineticEnergy;
+	if ((AL0483_ui_ThingType = (thing).getType()) != k15_ExplosionThingType) {
+		if (AL0483_ui_ThingType == k5_WeaponThingType) {
+			L0485_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(thing);
+			AL0483_ui_Attack = L0485_ps_WeaponInfo->_kineticEnergy;
+			_g367_projectileAttackType = k3_attackType_BLUNT;
+		} else {
+			AL0483_ui_Attack = _vm->getRandomNumber(4);
+		}
+		AL0483_ui_Attack += _vm->_dungeonMan->f140_getObjectWeight(thing) >> 1;
+	} else {
+		if (thing == Thing::_explSlime) {
+			AL0483_ui_Attack = _vm->getRandomNumber(16);
+			_g366_projectilePoisonAttack = AL0483_ui_Attack + 10;
+			AL0483_ui_Attack += _vm->getRandomNumber(32);
+		} else {
+			if (thing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) {
+				_g367_projectileAttackType = k5_attackType_MAGIC;
+				if (thing == Thing::_explPoisonBolt) {
+					_g366_projectilePoisonAttack = L0484_ui_KineticEnergy;
+					return 1;
+				}
+				return 0;
+			}
+			_g367_projectileAttackType = k1_attackType_FIRE;
+			AL0483_ui_Attack = _vm->getRandomNumber(16) + _vm->getRandomNumber(16) + 10;
+			if (thing == Thing::_explLightningBolt) {
+				_g367_projectileAttackType = k7_attackType_LIGHTNING;
+				AL0483_ui_Attack *= 5;
+			}
+		}
+	}
+	AL0483_ui_Attack = ((AL0483_ui_Attack + L0484_ui_KineticEnergy) >> 4) + 1;
+	AL0483_ui_Attack += _vm->getRandomNumber((AL0483_ui_Attack >> 1) + 1) + _vm->getRandomNumber(4);
+	AL0483_ui_Attack = MAX(AL0483_ui_Attack >> 1, AL0483_ui_Attack - (32 - (projectile->_attack >> 3)));
+	return AL0483_ui_Attack;
+}
+
+void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXCombo, uint16 mapYCombo, uint16 cell) {
+#define AP0443_ui_ProjectileMapX mapXCombo
+#define AP0444_ui_ProjectileMapY mapYCombo
+	Explosion* L0470_ps_Explosion;
+	CreatureInfo* L0471_ps_CreatureInfo;
+	Group* L0472_ps_Group;
+	Thing L0473_T_Thing;
+	int16 L0474_i_ProjectileTargetMapX;
+	int16 L0475_i_ProjectileTargetMapY;
+	int16 L0469_i_CreatureFireResistance;
+	TimelineEvent L0476_s_Event;
+
+
+	if ((L0473_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k15_ExplosionThingType)) == Thing::_none) {
+		return;
+	}
+	L0470_ps_Explosion = &((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[(L0473_T_Thing).getIndex()];
+	if (mapXCombo <= 255) {
+		L0474_i_ProjectileTargetMapX = mapXCombo;
+		L0475_i_ProjectileTargetMapY = mapYCombo;
+	} else {
+		L0474_i_ProjectileTargetMapX = mapXCombo & 0x00FF;
+		L0475_i_ProjectileTargetMapY = mapYCombo & 0x00FF;
+		AP0443_ui_ProjectileMapX >>= 8;
+		AP0443_ui_ProjectileMapX--;
+		AP0444_ui_ProjectileMapY >>= 8;
+	}
+	if (cell == k255_CreatureTypeSingleCenteredCreature) {
+		L0470_ps_Explosion->setCentered(true);
+	} else {
+		L0470_ps_Explosion->setCentered(false);
+		L0473_T_Thing = M15_thingWithNewCell(L0473_T_Thing, cell);
+	}
+	L0470_ps_Explosion->setType(explThing.toUint16() - Thing::_firstExplosion.toUint16());
+	L0470_ps_Explosion->setAttack(attack);
+	if (explThing.toUint16() < Thing::_explHarmNonMaterial.toUint16()) {
+		warning("MISING CODE: F0064_SOUND_RequestPlay_CPSD");
+	} else {
+		if (explThing != Thing::_explSmoke) {
+			warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+		}
+	}
+	_vm->_dungeonMan->f163_linkThingToList(L0473_T_Thing, Thing(0), AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY);
+	M33_setMapAndTime(L0476_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ((explThing == Thing::_explRebirthStep1) ? 5 : 1));
+	L0476_s_Event._type = k25_TMEventTypeExplosion;
+	L0476_s_Event._priority = 0;
+	L0476_s_Event._C._slot = L0473_T_Thing;
+	L0476_s_Event._B._location._mapX = AP0443_ui_ProjectileMapX;
+	L0476_s_Event._B._location._mapY = AP0444_ui_ProjectileMapY;
+	_vm->_timeline->f238_addEventGetEventIndex(&L0476_s_Event);
+	if ((explThing == Thing::_explLightningBolt) || (explThing == Thing::_explFireBall)) {
+		AP0443_ui_ProjectileMapX = L0474_i_ProjectileTargetMapX;
+		AP0444_ui_ProjectileMapY = L0475_i_ProjectileTargetMapY;
+		attack = (attack >> 1) + 1;
+		attack += _vm->getRandomNumber(attack) + 1;
+		if ((explThing == Thing::_explFireBall) || (attack >>= 1)) {
+			if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (AP0443_ui_ProjectileMapX == _vm->_dungeonMan->_g306_partyMapX) && (AP0444_ui_ProjectileMapY == _vm->_dungeonMan->_g307_partyMapY)) {
+				_vm->_championMan->f324_damageAll_getDamagedChampionCount(attack, k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand | k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k1_attackType_FIRE);
+			} else {
+				if ((L0473_T_Thing = _vm->_groupMan->f175_groupGetThing(AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY)) != Thing::_endOfList) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
+					L0472_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0473_T_Thing);
+					L0471_ps_CreatureInfo = &g243_CreatureInfo[L0472_ps_Group->_type];
+					if ((L0469_i_CreatureFireResistance = (L0471_ps_CreatureInfo->M60_getFireResistance())) != k15_immuneToFire) {
+						if (getFlag(L0471_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
+							attack >>= 2;
+						}
+						if ((attack -= _vm->getRandomNumber((L0469_i_CreatureFireResistance << 1) + 1)) > 0) {
+							_g364_creatureDamageOutcome = _vm->_groupMan->f191_getDamageAllCreaturesOutcome(L0472_ps_Group, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, attack, true);
+						}
+					}
+				}
+			}
+		}
+	}
+}
+
+int16 ProjExpl::f218_projectileGetImpactCount(int16 impactType, int16 mapX, int16 mapY, int16 cell) {
+	Thing L0513_T_Thing;
+	int16 L0514_i_ImpactCount;
+
+
+	L0514_i_ImpactCount = 0;
+	_g364_creatureDamageOutcome = k0_outcomeKilledNoCreaturesInGroup;
+T0218001:
+	L0513_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
+	while (L0513_T_Thing != Thing::_endOfList) {
+		if (((L0513_T_Thing).getType() == k14_ProjectileThingType) &&
+			((L0513_T_Thing).getCell() == cell) &&
+			f217_projectileHasImpactOccurred(impactType, mapX, mapY, cell, L0513_T_Thing)) {
+			f214_projectileDeleteEvent(L0513_T_Thing);
+			L0514_i_ImpactCount++;
+			if ((impactType == kM1_CreatureElemType) && (_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup))
+				break;
+			goto T0218001;
+		}
+		L0513_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0513_T_Thing);
+	}
+	return L0514_i_ImpactCount;
+}
+
+void ProjExpl::f214_projectileDeleteEvent(Thing thing) {
+	Projectile* L0477_ps_Projectile;
+
+
+	L0477_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(thing);
+	_vm->_timeline->f237_deleteEvent(L0477_ps_Projectile->_eventIndex);
+}
+
+void ProjExpl::f215_projectileDelete(Thing projectileThing, Thing* groupSlot, int16 mapX, int16 mapY) {
+	Thing L0478_T_PreviousThing;
+	Thing L0479_T_Thing;
+	Projectile* L0480_ps_Projectile;
+	Thing* L0481_ps_Generic;
+
+	L0480_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(projectileThing);
+	if ((L0479_T_Thing = L0480_ps_Projectile->_slot).getType() != k15_ExplosionThingType) {
+		if (groupSlot != NULL) {
+			if ((L0478_T_PreviousThing = *groupSlot) == Thing::_endOfList) {
+				L0481_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0479_T_Thing);
+				*L0481_ps_Generic = Thing::_endOfList;
+				*groupSlot = L0479_T_Thing;
+			} else {
+				_vm->_dungeonMan->f163_linkThingToList(L0479_T_Thing, L0478_T_PreviousThing, kM1_MapXNotOnASquare, 0);
+			}
+		} else {
+			_vm->_movsens->f267_getMoveResult(Thing((L0479_T_Thing).getTypeAndIndex() | getFlag(projectileThing.toUint16(), 0xC)), -2, 0, mapX, mapY);
+		}
+	}
+	L0480_ps_Projectile->_nextThing = Thing::_none;
+}
+}
diff --git a/engines/dm/projexpl.h b/engines/dm/projexpl.h
new file mode 100644
index 0000000..15f7454
--- /dev/null
+++ b/engines/dm/projexpl.h
@@ -0,0 +1,101 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+#ifndef DM_PROJEXPL_H
+#define DM_PROJEXPL_H
+
+#include "dm.h"
+
+
+#define k0_outcomeKilledNoCreaturesInGroup 0 // @ C0_OUTCOME_KILLED_NO_CREATURES_IN_GROUP   
+#define k1_outcomeKilledSomeCreaturesInGroup 1 // @ C1_OUTCOME_KILLED_SOME_CREATURES_IN_GROUP 
+#define k2_outcomeKilledAllCreaturesInGroup 2 // @ C2_OUTCOME_KILLED_ALL_CREATURES_IN_GROUP  
+
+#define k00_soundMETALLIC_THUD 0 // @ C00_SOUND_METALLIC_THUD
+#define k01_soundSWITCH 1 // @ C01_SOUND_SWITCH
+#define k02_soundDOOR_RATTLE 2 // @ C02_SOUND_DOOR_RATTLE
+#define k03_soundATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON 3 // @ C03_SOUND_ATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON
+#define k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM 4 // @ C04_SOUND_WOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM
+#define k05_soundSTRONG_EXPLOSION 5 // @ C05_SOUND_STRONG_EXPLOSION
+#define k06_soundSCREAM 6 // @ C06_SOUND_SCREAM
+#define k07_soundATTACK_MUMMY_GHOST_RIVE 7 // @ C07_SOUND_ATTACK_MUMMY_GHOST_RIVE
+#define k08_soundSWALLOW 8 // @ C08_SOUND_SWALLOW
+#define k09_soundCHAMPION_0_DAMAGED 9 // @ C09_SOUND_CHAMPION_0_DAMAGED
+#define k10_soundCHAMPION_1_DAMAGED 10 // @ C10_SOUND_CHAMPION_1_DAMAGED
+#define k11_soundCHAMPION_2_DAMAGED 11 // @ C11_SOUND_CHAMPION_2_DAMAGED
+#define k12_soundCHAMPION_3_DAMAGED 12 // @ C12_SOUND_CHAMPION_3_DAMAGED
+#define k13_soundSPELL 13 // @ C13_SOUND_SPELL
+#define k14_soundATTACK_SCREAMER_OITU 14 // @ C14_SOUND_ATTACK_SCREAMER_OITU
+#define k15_soundATTACK_GIANT_SCORPION_SCORPION 15 // @ C15_SOUND_ATTACK_GIANT_SCORPION_SCORPION
+#define k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT 16 // @ C16_SOUND_COMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT
+#define k17_soundBUZZ 17 // @ C17_SOUND_BUZZ
+#define k18_soundPARTY_DAMAGED 18 // @ C18_SOUND_PARTY_DAMAGED
+#define k19_soundATTACK_MAGENTA_WORM_WORM 19 // @ C19_SOUND_ATTACK_MAGENTA_WORM_WORM
+#define k20_soundWEAK_EXPLOSION 20 // @ C20_SOUND_WEAK_EXPLOSION
+#define k21_soundATTACK_GIGGLER 21 // @ C21_SOUND_ATTACK_GIGGLER
+#define k22_soundMOVE_ANIMATED_ARMOUR_DETH_KNIGHT 22 // @ C22_SOUND_MOVE_ANIMATED_ARMOUR_DETH_KNIGHT
+#define k23_soundMOVE_COUATL_GIANT_WASP_MUNCHER 23 // @ C23_SOUND_MOVE_COUATL_GIANT_WASP_MUNCHER
+#define k24_soundMOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON 24 // @ C24_SOUND_MOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON
+#define k25_soundBLOW_HORN 25 // @ C25_SOUND_BLOW_HORN
+#define k26_soundMOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU 26 // @ C26_SOUND_MOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU
+#define k27_soundMOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL 27 // @ C27_SOUND_MOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL
+#define k28_soundWAR_CRY 28 // @ C28_SOUND_WAR_CRY
+#define k29_soundATTACK_ROCK_ROCKPILE 29 // @ C29_SOUND_ATTACK_ROCK_ROCKPILE
+#define k30_soundATTACK_WATER_ELEMENTAL 30 // @ C30_SOUND_ATTACK_WATER_ELEMENTAL
+#define k31_soundATTACK_COUATL 31 // @ C31_SOUND_ATTACK_COUATL
+#define k32_soundMOVE_RED_DRAGON 32 // @ C32_SOUND_MOVE_RED_DRAGON
+#define k33_soundMOVE_SKELETON 33 // @ C33_SOUND_MOVE_SKELETON
+
+
+namespace DM {
+	class Projectile;
+
+	class ProjExpl {
+	DMEngine *_vm;
+public:
+	int16 _g364_creatureDamageOutcome; // @ G0364_i_CreatureDamageOutcome
+	int16 _g363_secondaryDirToOrFromParty; // @ G0363_i_SecondaryDirectionToOrFromParty
+	int32 _g361_lastCreatureAttackTime; // @ G0361_l_LastCreatureAttackTime
+	bool _g365_createLanucherProjectile; // @ G0365_B_CreateLauncherProjectile
+	int16 _g366_projectilePoisonAttack; // @ G0366_i_ProjectilePoisonAttack
+	int16 _g367_projectileAttackType; // @ G0367_i_ProjectileAttackType
+	int32 _g362_lastPartyMovementTime; // @ G0362_l_LastPartyMovementTime
+	ProjExpl(DMEngine *vm);
+	void f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, direction dir,
+							   byte kineticEnergy, byte attack, byte stepEnergy); // @ F0212_PROJECTILE_Create
+	bool f217_projectileHasImpactOccurred(int16 impactType, int16 mapXCombo, int16 mapYCombo,
+										  int16 cell, Thing projectileThing); // @ F0217_PROJECTILE_HasImpactOccured
+	uint16 f216_projectileGetImpactAttack(Projectile *projectile, Thing thing); // @ F0216_PROJECTILE_GetImpactAttack
+	void f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXCombo,
+							  uint16 mapYCombo, uint16 cell); // @ F0213_EXPLOSION_Create
+	int16 f218_projectileGetImpactCount(int16 impactType, int16 mapX, int16 mapY, int16 cell); // @ F0218_PROJECTILE_GetImpactCount
+	void f214_projectileDeleteEvent(Thing thing); // @ F0214_PROJECTILE_DeleteEvent
+	void f215_projectileDelete(Thing projectileThing, Thing *groupSlot, int16 mapX, int16 mapY); // @ F0215_PROJECTILE_Delete
+};
+
+}
+
+#endif
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 5426dd0..d9ca4b7 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -30,13 +30,19 @@
 
 namespace DM {
 
-TextMan::TextMan(DMEngine* vm) : _vm(vm) {}
+TextMan::TextMan(DMEngine* vm) : _vm(vm) {
+	_g356_bitmapMessageAreaNewRow = new byte[320 * 7];
+}
+
+TextMan::~TextMan() {
+	delete[] _g356_bitmapMessageAreaNewRow;
+}
 
 #define k5_LetterWidth 5
 #define k6_LetterHeight 6
 
 void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, uint16 destX, uint16 destY,
-								Color textColor, Color bgColor, const char* text, uint16 destHeight) {
+									Color textColor, Color bgColor, const char* text, uint16 destHeight) {
 	destX -= 1; // fixes missalignment, to be checked
 	destY -= 4; // fixes missalignment, to be checked
 
@@ -78,11 +84,81 @@ void TextMan::f52_printToViewport(int16 posX, int16 posY, Color textColor, const
 }
 
 void TextMan::f41_printWithTrailingSpaces(byte* destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor,
-									  Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight) {
+										  Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight) {
 	Common::String str = text;
 	for (int16 i = str.size(); i < requiredTextLength; ++i)
 		str += ' ';
 	f40_printTextToBitmap(destBitmap, destByteWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight);
 }
 
+void TextMan::f51_messageAreaPrintLineFeed() {
+	f47_messageAreaPrintMessage(k0_ColorBlack, "\n");
+}
+
+void TextMan::f47_messageAreaPrintMessage(Color color, const char* string) {
+	uint16 L0031_ui_CharacterIndex;
+	char L0033_ac_String[54];
+
+
+	while (*string) {
+		if (*string == '\n') { /* New line */
+			string++;
+			if ((_g359_messageAreaCursorColumn != 0) || (_g358_messageAreaCursorRow != 0)) {
+				_g359_messageAreaCursorColumn = 0;
+				f45_messageAreaCreateNewRow();
+			}
+		} else {
+			if (*string == ' ') {
+				string++;
+				if (_g359_messageAreaCursorColumn != 53) {
+					f46_messageAreaPrintString(color, " "); // TODO: I'm not sure this is like the original
+				}
+			} else {
+				L0031_ui_CharacterIndex = 0;
+				do {
+					L0033_ac_String[L0031_ui_CharacterIndex++] = *string++;
+				} while (*string && (*string != ' ') && (*string != '\n')); /* End of string, space or New line */
+				L0033_ac_String[L0031_ui_CharacterIndex] = '\0';
+				if (_g359_messageAreaCursorColumn + L0031_ui_CharacterIndex > 53) {
+					_g359_messageAreaCursorColumn = 2;
+					f45_messageAreaCreateNewRow();
+				}
+				f46_messageAreaPrintString(color, L0033_ac_String);
+			}
+		}
+	}
+}
+
+void TextMan::f45_messageAreaCreateNewRow() {
+	uint16 L0029_ui_RowIndex;
+
+	if (_g358_messageAreaCursorRow == 3) {
+		warning("MISSING CODE: F0561_SCROLLER_IsTextScrolling");
+		memset(_g356_bitmapMessageAreaNewRow, k0_ColorBlack, 320 * 7);
+		warning("MISSING CODE: F0560_SCROLLER_SetCommand");
+		for (L0029_ui_RowIndex = 0; L0029_ui_RowIndex < 3; L0029_ui_RowIndex++) {
+			_g360_messageAreaRowExpirationTime[L0029_ui_RowIndex] = _g360_messageAreaRowExpirationTime[L0029_ui_RowIndex + 1];
+		}
+		_g360_messageAreaRowExpirationTime[3] = -1;
+	} else {
+		_g358_messageAreaCursorRow++;
+	}
+}
+
+void TextMan::f46_messageAreaPrintString(Color color, const char* string) {
+	int16 L0030_i_StringLength;
+
+	L0030_i_StringLength = strlen(string);
+	warning("MISSING CODE: F0561_SCROLLER_IsTextScrolling");
+	if (true) { // there is a test here with F0561_SCROLLER_IsTextScrolling
+		_vm->_textMan->f53_printToLogicalScreen(_g359_messageAreaCursorColumn * 6, (_g358_messageAreaCursorRow * 7) + 177, color, k0_ColorBlack, string);
+	} else {
+		f40_printTextToBitmap(_g356_bitmapMessageAreaNewRow, k160_byteWidthScreen, _g359_messageAreaCursorColumn * 6, 5, color, k0_ColorBlack, string, 7);
+		warning("MISSING CODE: F0561_SCROLLER_IsTextScrolling");
+		warning("MISSING CODE: F0560_SCROLLER_SetCommand");
+	}
+	_g359_messageAreaCursorColumn += L0030_i_StringLength;
+	_g360_messageAreaRowExpirationTime[_g358_messageAreaCursorRow] = _vm->_g313_gameTime + 200;
+}
+
 }
diff --git a/engines/dm/text.h b/engines/dm/text.h
index 31344e2..b0ecb48 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -35,14 +35,25 @@ namespace DM {
 
 class TextMan {
 	DMEngine *_vm;
+	int16 _g359_messageAreaCursorColumn; // @ G0359_i_MessageAreaCursorColumn
+	int16 _g358_messageAreaCursorRow; // @ G0358_i_MessageAreaCursorRow
+	int32 _g360_messageAreaRowExpirationTime[4]; // @ G0360_al_MessageAreaRowExpirationTime
+	byte *_g356_bitmapMessageAreaNewRow; // @ G0356_puc_Bitmap_MessageAreaNewRow
 public:
 	explicit TextMan(DMEngine *vm);
+	~TextMan();
 	void f40_printTextToBitmap(byte *destBitmap, uint16 destByteWidth, uint16 destX, uint16 destY,
 						   Color textColor, Color bgColor, const char *text, uint16 destHeight); // @ F0040_TEXT_Print
 	void f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text); // @ F0053_TEXT_PrintToLogicalScreen
 	void f52_printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport
 	void f41_printWithTrailingSpaces(byte *destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor, Color bgColor,
 								 const char *text, int16 strLenght, int16 destHeight); // @ F0041_TEXT_PrintWithTrailingSpaces
+	void f51_messageAreaPrintLineFeed(); // @ F0051_TEXT_MESSAGEAREA_PrintLineFeed
+	void f47_messageAreaPrintMessage(Color color, const char *string); // @ F0047_TEXT_MESSAGEAREA_PrintMessage
+	void f45_messageAreaCreateNewRow(); // @ F0045_TEXT_MESSAGEAREA_CreateNewRow
+	void f46_messageAreaPrintString(Color color, const char* string);// @ F0046_TEXT_MESSAGEAREA_PrintString
+
+
 };
 
 }
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 4b5cfd4..2b58203 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -52,4 +52,157 @@ void Timeline::f233_initTimeline() {
 	}
 }
 
+void Timeline::f237_deleteEvent(uint16 eventIndex) {
+	uint16 L0586_ui_TimelineIndex;
+	uint16 L0587_ui_EventCount;
+
+
+	_vm->_timeline->_g370_events[eventIndex]._type = k0_TMEventTypeNone;
+	if (eventIndex < _vm->_timeline->_g373_firstUnusedEventIndex) {
+		_vm->_timeline->_g373_firstUnusedEventIndex = eventIndex;
+	}
+	_vm->_timeline->_g372_eventCount--;
+	if ((L0587_ui_EventCount = _vm->_timeline->_g372_eventCount) == 0) {
+		return;
+	}
+	L0586_ui_TimelineIndex = f235_getIndex(eventIndex);
+	if (L0586_ui_TimelineIndex == L0587_ui_EventCount) {
+		return;
+	}
+	_vm->_timeline->_g371_timeline[L0586_ui_TimelineIndex] = _vm->_timeline->_g371_timeline[L0587_ui_EventCount];
+	f236_fixChronology(L0586_ui_TimelineIndex);
+}
+
+void Timeline::f236_fixChronology(uint16 timelineIndex) {
+	uint16 L0581_ui_TimelineIndex;
+	uint16 L0582_ui_EventIndex;
+	uint16 L0583_ui_EventCount;
+	TimelineEvent* L0584_ps_Event;
+	bool L0585_B_ChronologyFixed;
+
+
+	if ((L0583_ui_EventCount = _vm->_timeline->_g372_eventCount) == 1) {
+		return;
+	}
+
+	L0584_ps_Event = &_vm->_timeline->_g370_events[L0582_ui_EventIndex = _vm->_timeline->_g371_timeline[timelineIndex]];
+	L0585_B_ChronologyFixed = false;
+	while (timelineIndex > 0) { /* Check if the event should be moved earlier in the timeline */
+		L0581_ui_TimelineIndex = (timelineIndex - 1) >> 1;
+		if (f234_isEventABeforeB(L0584_ps_Event, &_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex]])) {
+			_vm->_timeline->_g371_timeline[timelineIndex] = _vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex];
+			timelineIndex = L0581_ui_TimelineIndex;
+			L0585_B_ChronologyFixed = true;
+		} else {
+			break;
+		}
+	}
+	if (L0585_B_ChronologyFixed)
+		goto T0236011;
+	L0583_ui_EventCount = ((L0583_ui_EventCount - 1) - 1) >> 1;
+	while (timelineIndex <= L0583_ui_EventCount) { /* Check if the event should be moved later in the timeline */
+		L0581_ui_TimelineIndex = (timelineIndex << 1) + 1;
+		if (((L0581_ui_TimelineIndex + 1) < _vm->_timeline->_g372_eventCount) && (f234_isEventABeforeB(&_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex + 1]], &_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex]]))) {
+			L0581_ui_TimelineIndex++;
+		}
+		if (f234_isEventABeforeB(&_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex]], L0584_ps_Event)) {
+			_vm->_timeline->_g371_timeline[timelineIndex] = _vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex];
+			timelineIndex = L0581_ui_TimelineIndex;
+		} else {
+			break;
+		}
+	}
+T0236011:
+	_vm->_timeline->_g371_timeline[timelineIndex] = L0582_ui_EventIndex;
+}
+
+bool Timeline::f234_isEventABeforeB(TimelineEvent* eventA, TimelineEvent* eventB) {
+	bool L0578_B_Simultaneous;
+
+	return (M30_time(eventA->_mapTime) < M30_time(eventB->_mapTime)) ||
+		((L0578_B_Simultaneous = (M30_time(eventA->_mapTime) == M30_time(eventB->_mapTime))) && (eventA->getTypePriority() > eventB->getTypePriority())) ||
+		(L0578_B_Simultaneous && (eventA->getTypePriority() == eventB->getTypePriority()) && (eventA <= eventB));
+}
+
+uint16 Timeline::f235_getIndex(uint16 eventIndex) {
+	uint16 L0579_ui_TimelineIndex;
+	uint16* L0580_pui_TimelineEntry;
+
+
+	for (L0579_ui_TimelineIndex = 0, L0580_pui_TimelineEntry = _vm->_timeline->_g371_timeline; L0579_ui_TimelineIndex < _vm->_timeline->_g369_eventMaxCount; L0579_ui_TimelineIndex++) {
+		if (*L0580_pui_TimelineEntry++ == eventIndex)
+			break;
+	}
+	if (L0579_ui_TimelineIndex >= _vm->_timeline->_g369_eventMaxCount) { /* BUG0_00 Useless code. The function is always called with event indices that are in the timeline */
+		L0579_ui_TimelineIndex = 0; /* BUG0_01 Coding error without consequence. Wrong return value. If the specified event index is not found in the timeline the function returns 0 which is the same value that is returned if the event index is found in the first timeline entry. No consequence because this code is never executed */
+	}
+	return L0579_ui_TimelineIndex;
+}
+
+uint16 Timeline::f238_addEventGetEventIndex(TimelineEvent* event) {
+	uint16 L0588_ui_EventIndex;
+	uint16 L0590_ui_NewEventIndex;
+	TimelineEvent* L0591_ps_Event;
+
+
+	if (_vm->_timeline->_g372_eventCount == _vm->_timeline->_g369_eventMaxCount) {
+		_vm->f19_displayErrorAndStop(45);
+	}
+	if ((event->_type >= k5_TMEventTypeCorridor) && (event->_type <= k10_TMEventTypeDoor)) {
+		for (L0588_ui_EventIndex = 0, L0591_ps_Event = _vm->_timeline->_g370_events; L0588_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
+			if ((L0591_ps_Event->_type >= k5_TMEventTypeCorridor) && (L0591_ps_Event->_type <= k10_TMEventTypeDoor)) {
+				if ((event->_mapTime == L0591_ps_Event->_mapTime) && (event->getMapXY() == L0591_ps_Event->getMapXY()) && ((L0591_ps_Event->_type != k6_TMEventTypeWall) || (L0591_ps_Event->_C.A._cell == event->_C.A._cell))) {
+					L0591_ps_Event->_C.A._effect = event->_C.A._effect;
+					return L0588_ui_EventIndex;
+				}
+				continue;
+			} else {
+				if ((L0591_ps_Event->_type == k1_TMEventTypeDoorAnimation) && (event->_mapTime == L0591_ps_Event->_mapTime) && (event->getMapXY() == L0591_ps_Event->getMapXY())) {
+					if (event->_C.A._effect == k2_SensorEffToggle) {
+						event->_C.A._effect = 1 - L0591_ps_Event->_C.A._effect;
+					}
+					f237_deleteEvent(L0588_ui_EventIndex);
+					break;
+				}
+			}
+		}
+	} else {
+		if (event->_type == k1_TMEventTypeDoorAnimation) {
+			for (L0588_ui_EventIndex = 0, L0591_ps_Event = _vm->_timeline->_g370_events; L0588_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
+				if ((event->_mapTime == L0591_ps_Event->_mapTime) && (event->getMapXY() == L0591_ps_Event->getMapXY())) {
+					if (L0591_ps_Event->_type == k10_TMEventTypeDoor) {
+						if (L0591_ps_Event->_C.A._effect == k2_SensorEffToggle) {
+							L0591_ps_Event->_C.A._effect = 1 - event->_C.A._effect;
+						}
+						return L0588_ui_EventIndex;
+					}
+					if (L0591_ps_Event->_type == k1_TMEventTypeDoorAnimation) {
+						L0591_ps_Event->_C.A._effect = event->_C.A._effect;
+						return L0588_ui_EventIndex;
+					}
+				}
+			}
+		} else {
+			if (event->_type == k2_TMEventTypeDoorDestruction) {
+				for (L0588_ui_EventIndex = 0, L0591_ps_Event = _vm->_timeline->_g370_events; L0588_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
+					if ((event->getMapXY() == L0591_ps_Event->getMapXY()) && (M29_map(event->_mapTime) == M29_map(L0591_ps_Event->_mapTime))) {
+						if ((L0591_ps_Event->_type == k1_TMEventTypeDoorAnimation) || (L0591_ps_Event->_type == k10_TMEventTypeDoor)) {
+							f237_deleteEvent(L0588_ui_EventIndex);
+						}
+					}
+				}
+			}
+		}
+	}
+	_vm->_timeline->_g370_events[L0590_ui_NewEventIndex = _vm->_timeline->_g373_firstUnusedEventIndex] = *event; /* Copy the event data (Megamax C can assign structures) */
+	do {
+		if (_vm->_timeline->_g373_firstUnusedEventIndex == _vm->_timeline->_g369_eventMaxCount)
+			break;
+		_vm->_timeline->_g373_firstUnusedEventIndex++;
+	} while ((_vm->_timeline->_g370_events[_vm->_timeline->_g373_firstUnusedEventIndex])._type != k0_TMEventTypeNone);
+	_vm->_timeline->_g371_timeline[_vm->_timeline->_g372_eventCount] = L0590_ui_NewEventIndex;
+	f236_fixChronology(_vm->_timeline->_g372_eventCount++);
+	return L0590_ui_NewEventIndex;
+}
+
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index c2e06bc..1c184e3 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -154,6 +154,12 @@ public:
 	Timeline(DMEngine *vm);
 	~Timeline();
 	void f233_initTimeline(); // @ F0233_TIMELINE_Initialize
+	void f237_deleteEvent(uint16 eventIndex);// @ F0237_TIMELINE_DeleteEvent
+	void f236_fixChronology(uint16 timelineIndex); // @ F0236_TIMELINE_FixChronology
+	bool f234_isEventABeforeB(TimelineEvent *eventA, TimelineEvent *eventB); // @ F0234_TIMELINE_IsEventABeforeEventB
+	uint16 f235_getIndex(uint16 eventIndex); // @ F0235_TIMELINE_GetIndex
+	uint16 f238_addEventGetEventIndex(TimelineEvent *event); // @ F0238_TIMELINE_AddEvent_GetEventIndex_CPSE
+
 };
 
 


Commit: f33b4f38770843ac1096ba3db8a83698fa2a865e
    https://github.com/scummvm/scummvm/commit/f33b4f38770843ac1096ba3db8a83698fa2a865e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some compilation errors using MSVC9

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/group.cpp
    engines/dm/group.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index ca77856..c7f59b7 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -31,9 +31,7 @@
 #include "dungeonman.h"
 #include "timeline.h"
 #include "champion.h"
-#include "group.h"
-#include "movesens.h"
-#include "projexpl.h"
+
 
 
 namespace DM {
@@ -837,11 +835,11 @@ void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, direction dir, int16
 #define footprintsAllowed L0307_uc_Multiple
 #define scentOrdinal      L0307_uc_Multiple
 	Sensor* sensor;
-	bool leftRandWallOrnAllowed = false;
-	int16 L0310_i_Multiple = 0;
+	bool leftRandWallOrnAllowed;
+	int16 L0310_i_Multiple;
 #define frontRandWallOrnAllowed L0310_i_Multiple
 #define sideIndex                      L0310_i_Multiple
-	bool rightRandWallOrnAllowed = false;
+	bool rightRandWallOrnAllowed;
 	int16 thingTypeRedEagle;
 	bool squreIsFakeWall;
 	Thing thing;
@@ -948,12 +946,12 @@ T0172030_Pit:
 		aspectArray[k2_TeleporterVisibleAspect] = getFlag(square, k0x0008_TeleporterOpen) && getFlag(square, k0x0004_TeleporterVisible);
 		goto T0172029_Teleporter;
 	case k3_ElementTypeStairs:
-		aspectArray[k0_ElemAspect] = (((getFlag(square, k0x0008_StairsNorthSouthOrient) >> 3) ? true : false) == isOrientedWestEast(dir)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront;
+		aspectArray[k0_ElemAspect] = ((getFlag(square, k0x0008_StairsNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront;
 		aspectArray[k2_StairsUpAspect] = getFlag(square, k0x0004_StairsUp);
 		footprintsAllowed = false;
 		goto T0172046_Stairs;
 	case k4_DoorElemType:
-		if (((getFlag(square, k0x0008_DoorNorthSouthOrient) >> 3) ? true : false) == isOrientedWestEast(dir)) {
+		if ((getFlag(square, k0x0008_DoorNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) {
 			aspectArray[k0_ElemAspect] = k16_DoorSideElemType;
 		} else {
 			aspectArray[k0_ElemAspect] = k17_DoorFrontElemType;
@@ -1192,45 +1190,6 @@ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) {
 	*destString = ((type == k0_TextTypeInscription) ? 0x81 : '\0');
 }
 
-Thing DungeonMan::f166_getUnusedThing(uint16 thingType) {
-	int16 L0288_i_ThingIndex;
-	int16 L0289_i_ThingDataByteCount;
-	int16 L0290_i_ThingCount;
-	Thing* L0291_ps_Generic;
-	Thing L0292_T_Thing;
-
-
-	L0290_i_ThingCount = _vm->_dungeonMan->_g278_dungeonFileHeader._thingCounts[getFlag(thingType, k0x7FFF_thingType)];
-	if (thingType == (k0x8000_championBones | k10_JunkThingType)) {
-		thingType = k10_JunkThingType;
-	} else {
-		if (thingType == k10_JunkThingType) {
-			L0290_i_ThingCount -= 3; /* Always keep 3 unused JUNK things for the bones of dead champions */
-		}
-	}
-	L0288_i_ThingIndex = L0290_i_ThingCount;
-	L0289_i_ThingDataByteCount = g235_ThingDataWordCount[thingType] >> 1;
-	L0291_ps_Generic = (Thing*)_vm->_dungeonMan->_g284_thingData[thingType];
-	for (;;) { /*_Infinite loop_*/
-		if (*L0291_ps_Generic == Thing::_none) { /* If thing data is unused */
-			L0292_T_Thing = Thing((thingType << 10) | (L0290_i_ThingCount - L0288_i_ThingIndex));
-			break;
-		}
-		if (--L0288_i_ThingIndex) { /* If there are thing data left to process */
-			L0291_ps_Generic += L0289_i_ThingDataByteCount; /* Proceed to the next thing data */
-		} else {
-			if ((L0292_T_Thing = f165_getDiscardTHing(thingType)) == Thing::_none) {
-				return Thing::_none;
-			}
-			L0291_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0292_T_Thing);
-			break;
-		}
-	}
-	memset(L0291_ps_Generic, 0, L0289_i_ThingDataByteCount * 2);
-
-	*L0291_ps_Generic = Thing::_endOfList;
-	return L0292_T_Thing;
-}
 
 uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 	static const uint16 g241_junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo
@@ -1422,293 +1381,4 @@ int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDe
 	}
 	return kM1_mapIndexNone;
 }
-
-Thing DungeonMan::f162_getSquareFirstObject(int16 mapX, int16 mapY) {
-	Thing thing = f161_getSquareFirstThing(mapX, mapY);
-	while ((thing != Thing::_endOfList) && (thing.getType() < k4_GroupThingType)) {
-		thing = f159_getNextThing(thing);
-	}
-	return thing;
-}
-
-uint16 DungeonMan::f143_getArmourDefense(ArmourInfo* armourInfo, bool useSharpDefense) {
-	uint16 L0244_ui_Defense;
-
-	L0244_ui_Defense = armourInfo->_defense;
-	if (useSharpDefense) {
-		L0244_ui_Defense = _vm->f30_getScaledProduct(L0244_ui_Defense, 3, getFlag(armourInfo->_attributes, k0x0007_ArmourAttributeSharpDefense) + 4);
-	}
-	return L0244_ui_Defense;
-}
-
-Thing DungeonMan::f165_getDiscardTHing(uint16 thingType) {
-	uint16 L0276_ui_MapX;
-	uint16 L0277_ui_MapY;
-	Thing L0278_T_Thing;
-	uint16 L0279_ui_MapIndex;
-	byte* L0280_puc_Square;
-	Thing* L0281_pT_SquareFirstThing;
-	Thing* L0282_ps_Generic;
-	uint16 L0283_ui_DiscardThingMapIndex;
-	int L0284_i_CurrentMapIndex;
-	uint16 L0285_ui_MapWidth;
-	uint16 L0286_ui_MapHeight;
-	int L0287_i_ThingType;
-	static unsigned char G0294_auc_LastDiscardedThingMapIndex[16];
-
-
-	if (thingType == k15_ExplosionThingType) {
-		return Thing::_none;
-	}
-	L0284_i_CurrentMapIndex = _vm->_dungeonMan->_g272_currMapIndex;
-	if (((L0279_ui_MapIndex = G0294_auc_LastDiscardedThingMapIndex[thingType]) == _vm->_dungeonMan->_g309_partyMapIndex) && (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount)) {
-		L0279_ui_MapIndex = 0;
-	}
-	L0283_ui_DiscardThingMapIndex = L0279_ui_MapIndex;
-	for (;;) { /*_Infinite loop_*/
-		L0285_ui_MapWidth = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._width;
-		L0286_ui_MapHeight = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._height;
-		L0280_puc_Square = _vm->_dungeonMan->_g279_dungeonMapData[L0279_ui_MapIndex][0];
-		L0281_pT_SquareFirstThing = &_vm->_dungeonMan->_g283_squareFirstThings[_vm->_dungeonMan->_g280_dungeonColumnsCumulativeSquareThingCount[_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[L0279_ui_MapIndex]]];
-		for (L0276_ui_MapX = 0; L0276_ui_MapX <= L0285_ui_MapWidth; L0276_ui_MapX++) {
-			for (L0277_ui_MapY = 0; L0277_ui_MapY <= L0286_ui_MapHeight; L0277_ui_MapY++) {
-				if (getFlag(*L0280_puc_Square++, k0x0010_ThingListPresent)) {
-					L0278_T_Thing = *L0281_pT_SquareFirstThing++;
-					if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && ((L0276_ui_MapX - _vm->_dungeonMan->_g306_partyMapX + 5) <= 10) && ((L0277_ui_MapY - _vm->_dungeonMan->_g307_partyMapY + 5) <= 10)) /* If square is too close to the party */
-						goto T0165029;
-					do {
-						if ((L0287_i_ThingType = (L0278_T_Thing).getType()) == k3_SensorThingType) {
-							L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing);
-							if (((Sensor*)L0282_ps_Generic)->getType()) /* If sensor is not disabled */
-								break;
-						} else {
-							if (L0287_i_ThingType == thingType) {
-								L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing);
-								switch (thingType) {
-								case k4_GroupThingType:
-									if (((Group*)L0282_ps_Generic)->getDoNotDiscard())
-										continue;
-								case k14_ProjectileThingType:
-									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
-									if (thingType == k4_GroupThingType) {
-										_vm->_groupMan->f188_dropGroupPossessions(L0276_ui_MapX, L0277_ui_MapY, L0278_T_Thing, kM1_soundModeDoNotPlaySound);
-										_vm->_groupMan->f189_delete(L0276_ui_MapX, L0277_ui_MapY);
-									} else {
-										_vm->_projexpl->f214_projectileDeleteEvent(L0278_T_Thing);
-										f164_unlinkThingFromList(L0278_T_Thing, Thing(0), L0276_ui_MapX, L0277_ui_MapY);
-										_vm->_projexpl->f215_projectileDelete(L0278_T_Thing, 0, L0276_ui_MapX, L0277_ui_MapY);
-									}
-									break;
-								case k6_ArmourThingType:
-									if (((Armour*)L0282_ps_Generic)->getDoNotDiscard())
-										continue;
-									goto T0165026;
-								case k5_WeaponThingType:
-									if (((Weapon*)L0282_ps_Generic)->getDoNotDiscard())
-										continue;
-									goto T0165026;
-								case k10_JunkThingType:
-									if (((Junk*)L0282_ps_Generic)->getDoNotDiscard())
-										continue;
-									goto T0165026;
-								case k8_PotionThingType:
-									if (((Potion*)L0282_ps_Generic)->getDoNotDiscard())
-										continue;
-T0165026:
-									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
-									_vm->_movsens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0);
-								}
-								_vm->_dungeonMan->f173_setCurrentMap(L0284_i_CurrentMapIndex);
-								G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex;
-								return Thing((L0278_T_Thing).getTypeAndIndex());
-							}
-						}
-					} while ((L0278_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0278_T_Thing)) != Thing::_endOfList);
-T0165029:
-					;
-				}
-			}
-		}
-		if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) || (_vm->_dungeonMan->_g278_dungeonFileHeader._mapCount <= 1)) {
-			G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex;
-			return Thing::_none;
-		}
-		do {
-			if (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount) {
-				L0279_ui_MapIndex = 0;
-			}
-		} while (L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex);
-		if (L0279_ui_MapIndex == L0283_ui_DiscardThingMapIndex) {
-			L0279_ui_MapIndex = _vm->_dungeonMan->_g309_partyMapIndex;
-		}
-	}
-}
-
-uint16 DungeonMan::f144_getCreatureAttributes(Thing thing) {
-	Group* L0245_ps_Group;
-
-	L0245_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing);
-	return g243_CreatureInfo[L0245_ps_Group->_type]._attributes;
-}
-
-void DungeonMan::f146_setGroupCells(Group* group, uint16 cells, uint16 mapIndex) {
-	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) {
-		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._cells = cells;
-	} else {
-		group->_cells = cells;
-	}
-}
-
-void DungeonMan::f148_setGroupDirections(Group* group, int16 dir, uint16 mapIndex) {
-	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) {
-		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (direction)dir;
-	} else {
-		group->setDir(M21_normalizeModulo4(dir));
-	}
-}
-
-bool DungeonMan::f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) {
-	int16 L0234_i_Counter;
-	int16 L0235_i_CreatureType;
-	byte* L0236_puc_Multiple;
-#define AL0236_puc_Group               L0236_puc_Multiple
-#define AL0236_puc_AllowedCreatureType L0236_puc_Multiple
-	Map* L0237_ps_Map;
-
-	L0235_i_CreatureType = ((Group*)_vm->_dungeonMan->f156_getThingData(thing))->_type;
-	L0237_ps_Map = &_vm->_dungeonMan->_g277_dungeonMaps[mapIndex];
-	AL0236_puc_AllowedCreatureType = _vm->_dungeonMan->_g279_dungeonMapData[mapIndex][L0237_ps_Map->_width] + L0237_ps_Map->_height + 1;
-	for (L0234_i_Counter = L0237_ps_Map->_creatureTypeCount; L0234_i_Counter > 0; L0234_i_Counter--) {
-		if (*AL0236_puc_AllowedCreatureType++ == L0235_i_CreatureType) {
-			return true;
-		}
-	}
-	return false;
-}
-
-void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY) {
-	uint16 L0271_ui_SquareFirstThingIndex;
-	uint16 L0272_ui_Multiple;
-#define AL0272_ui_SquareFirstThingIndex L0272_ui_Multiple
-#define AL0272_ui_Column                L0272_ui_Multiple
-	Thing L0273_T_Thing;
-	Thing* L0274_ps_Generic = nullptr;
-	Thing* L0275_pui_Multiple = nullptr;
-#define AL0275_pT_Thing                      L0275_pui_Multiple
-#define AL0275_pui_CumulativeFirstThingCount L0275_pui_Multiple
-
-
-	if (thingToUnlink == Thing::_endOfList) {
-		return;
-	}
-
-	{
-		uint16 tmp = thingToUnlink.toUint16();
-		clearFlag(tmp, 0xC000);
-		thingToUnlink = Thing(tmp);
-	}
-
-	if (mapX >= 0) {
-		L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink);
-		AL0275_pT_Thing = &_vm->_dungeonMan->_g283_squareFirstThings[L0271_ui_SquareFirstThingIndex = _vm->_dungeonMan->f160_getSquareFirstThingIndex(mapX, mapY)]; /* BUG0_01 Coding error without consequence. The engine does not check that there are things at the specified square coordinates. _vm->_dungeonMan->f160_getSquareFirstThingIndex would return -1 for an empty square. No consequence as the function is never called with the coordinates of an empty square (except in the case of BUG0_59) */
-		if ((*L0274_ps_Generic == Thing::_endOfList) && (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16())) { /* If the thing to unlink is the last thing on the square */
-			clearFlag(_vm->_dungeonMan->_g271_currMapData[mapX][mapY], k0x0010_ThingListPresent);
-			AL0272_ui_SquareFirstThingIndex = _vm->_dungeonMan->_g278_dungeonFileHeader._squareFirstThingCount - 1;
-			for (uint16 i = 0; i < AL0272_ui_SquareFirstThingIndex - L0271_ui_SquareFirstThingIndex; ++i)
-				AL0275_pT_Thing[i] = AL0275_pT_Thing[i + 1];
-
-			_vm->_dungeonMan->_g283_squareFirstThings[AL0272_ui_SquareFirstThingIndex] = Thing::_none;
-			AL0275_pui_CumulativeFirstThingCount = (Thing*)_vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount + mapX + 1;
-			AL0272_ui_Column = _vm->_dungeonMan->_g282_dungeonColumCount - (_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[_vm->_dungeonMan->_g272_currMapIndex] + mapX) - 1;
-			while (AL0272_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is unlinked */
-				(*(uint16*)AL0275_pui_CumulativeFirstThingCount++)--; /* Decrement the cumulative first thing count */
-			}
-			goto T0164011;
-		}
-		if (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16()) {
-			*AL0275_pT_Thing = *L0274_ps_Generic;
-			goto T0164011;
-		}
-		thingInList = *AL0275_pT_Thing;
-	}
-	L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList);
-	while (L0273_T_Thing.getTypeAndIndex() != thingToUnlink.toUint16()) {
-		if ((L0273_T_Thing == Thing::_endOfList) || (L0273_T_Thing == Thing::_none)) {
-			goto T0164011;
-		}
-		L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList = L0273_T_Thing);
-	}
-	L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingInList);
-	*L0274_ps_Generic = _vm->_dungeonMan->f159_getNextThing(L0273_T_Thing);
-	L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink);
-T0164011:
-	*L0274_ps_Generic = Thing::_endOfList;
-}
-
-int16 DungeonMan::f155_getStairsExitDirection(int16 mapX, int16 mapY) {
-	int16 L0256_i_SquareType;
-	bool L0257_B_NorthSouthOrientedStairs;
-
-
-	if (L0257_B_NorthSouthOrientedStairs = !getFlag(_vm->_dungeonMan->f151_getSquare(mapX, mapY).toByte(), k0x0008_StairsNorthSouthOrient)) {
-		mapX = mapX + _vm->_dirIntoStepCountEast[kDirEast];
-		mapY = mapY + _vm->_dirIntoStepCountNorth[kDirEast];
-	} else {
-		mapX = mapX + _vm->_dirIntoStepCountEast[kDirNorth];
-		mapY = mapY + _vm->_dirIntoStepCountNorth[kDirNorth];
-	}
-	return ((((L0256_i_SquareType = Square(_vm->_dungeonMan->f151_getSquare(mapX, mapY)).getType()) == k0_ElementTypeWall) || (L0256_i_SquareType == k3_ElementTypeStairs)) << 1) + L0257_B_NorthSouthOrientedStairs;
-
-}
-
-Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {
-	int16 L0293_i_Type;
-	int16 L0294_i_ThingType;
-	Thing L0295_T_Thing;
-	Junk* L0296_ps_Junk;
-
-
-	L0294_i_ThingType = k5_WeaponThingType;
-	if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit)) {
-		iconIndex = k4_IconIndiceWeaponTorchUnlit;
-	}
-	switch (iconIndex) {
-	case k54_IconIndiceWeaponRock:
-		L0293_i_Type = k30_WeaponTypeRock;
-		break;
-	case k128_IconIndiceJunkBoulder:
-		L0293_i_Type = k25_JunkTypeBoulder;
-		L0294_i_ThingType = k10_JunkThingType;
-		break;
-	case k51_IconIndiceWeaponArrow:
-		L0293_i_Type = k27_WeaponTypeArrow;
-		break;
-	case k52_IconIndiceWeaponSlayer:
-		L0293_i_Type = k28_WeaponTypeSlayer;
-		break;
-	case k55_IconIndiceWeaponPoisonDart:
-		L0293_i_Type = k31_WeaponTypePoisonDart;
-		break;
-	case k56_IconIndiceWeaponThrowingStar:
-		L0293_i_Type = k32_WeaponTypeThrowingStar;
-		break;
-	case k32_IconIndiceWeaponDagger:
-		L0293_i_Type = k8_WeaponTypeDagger;
-		break;
-	case k4_IconIndiceWeaponTorchUnlit:
-		L0293_i_Type = k2_WeaponTypeTorch;
-		break;
-	default:
-		return Thing::_none;
-	}
-	if ((L0295_T_Thing = f166_getUnusedThing(L0294_i_ThingType)) == Thing::_none) {
-		return Thing::_none;
-	}
-	L0296_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0295_T_Thing);
-	L0296_ps_Junk->setType(L0293_i_Type); /* Also works for WEAPON in cases other than Boulder */
-	if ((iconIndex == k4_IconIndiceWeaponTorchUnlit) && ((Weapon*)L0296_ps_Junk)->isLit()) { /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */
-		((Weapon*)L0296_ps_Junk)->setChargeCount(15);
-	}
-	return L0295_T_Thing;
-}
 }
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 7f845c6..b4e89e0 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -28,19 +28,15 @@
 #include "group.h"
 #include "dungeonman.h"
 #include "champion.h"
-#include "movesens.h"
-#include "projexpl.h"
-#include "timeline.h"
+
 
 
 namespace DM {
-int32 M32_setTime(int32 &map_time, int32 time) {
-	return map_time = (map_time & 0xFF000000) | time;
-}
+
 
 GroupMan::GroupMan(DMEngine* vm) : _vm(vm) {
 	_g375_activeGroups = nullptr;
-	_g377_currActiveGroupCount = 0;
+	_g376_maxActiveGroupCount = 60;
 }
 
 GroupMan::~GroupMan() {
@@ -102,1634 +98,4 @@ int16 GroupMan::f176_getCreatureOrdinalInCell(Group* group, uint16 cell) {
 uint16 GroupMan::M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex) {
 	return (groupVal >> (creatureIndex << 1)) & 0x3;
 }
-
-void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode) {
-	Thing L0365_T_CurrentThing;
-	Thing L0366_T_NextThing;
-	Group* L0367_ps_Group;
-	uint16 L0368_ui_CreatureType;
-	int16 L0369_i_CreatureIndex;
-	uint16 L0370_ui_GroupCells;
-	bool L0371_B_WeaponDropped;
-
-
-	L0367_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(groupThing);
-	if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[L0368_ui_CreatureType = L0367_ps_Group->_type]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
-		L0369_i_CreatureIndex = L0367_ps_Group->getCount();
-		L0370_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(L0367_ps_Group, _vm->_dungeonMan->_g272_currMapIndex);
-		do {
-			_vm->_groupMan->f186_dropCreatureFixedPossessions(L0368_ui_CreatureType, mapX, mapY, (L0370_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0370_ui_GroupCells, L0369_i_CreatureIndex), mode);
-		} while (L0369_i_CreatureIndex--);
-	}
-	if ((L0365_T_CurrentThing = L0367_ps_Group->_slot) != Thing::_endOfList) {
-		L0371_B_WeaponDropped = false;
-		do {
-			L0366_T_NextThing = _vm->_dungeonMan->f159_getNextThing(L0365_T_CurrentThing);
-			L0365_T_CurrentThing = M15_thingWithNewCell(L0365_T_CurrentThing, _vm->getRandomNumber(4));
-			if ((L0365_T_CurrentThing).getType() == k5_WeaponThingType) {
-				L0371_B_WeaponDropped = true;
-			}
-			_vm->_movsens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
-		} while ((L0365_T_CurrentThing = L0366_T_NextThing) != Thing::_endOfList);
-		if (mode >= k0_soundModePlayImmediately) {
-			warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
-		}
-	}
-}
-
-void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int16 mapY, uint16 cell, int16 mode) {
-	static uint16 g245FixedPossessionCreature_12Skeleton[3] = { // @ G0245_aui_Graphic559_FixedPossessionsCreature12Skeleton
-		k23_ObjectInfoIndexFirstWeapon + k9_WeaponTypeFalchion,
-		k69_ObjectInfoIndexFirstArmour + k30_ArmourTypeWoodenShield, 0};
-	static uint16 g246FixedPossessionCreature_9StoneGolem[2] = { // @ G0246_aui_Graphic559_FixedPossessionsCreature09StoneGolem
-		k23_ObjectInfoIndexFirstWeapon + k24_WeaponTypeStoneClub, 0};
-	static uint16 g247FixedPossessionCreature_16TrolinAntman[2] = { // @ G0247_aui_Graphic559_FixedPossessionsCreature16Trolin_Antman
-		k23_ObjectInfoIndexFirstWeapon + k23_WeaponTypeClub, 0};
-	static uint16 g248FixedPossessionCreature_18AnimatedArmourDethKnight[7] = { // @ G0248_aui_Graphic559_FixedPossessionsCreature18AnimatedArmour_DethKnight
-		k69_ObjectInfoIndexFirstArmour + k41_ArmourTypeFootPlate,
-		k69_ObjectInfoIndexFirstArmour + k40_ArmourTypeLegPlate,
-		k69_ObjectInfoIndexFirstArmour + k39_ArmourTypeTorsoPlate,
-		k23_ObjectInfoIndexFirstWeapon + k10_WeaponTypeSword,
-		k69_ObjectInfoIndexFirstArmour + k38_ArmourTypeArmet,
-		k23_ObjectInfoIndexFirstWeapon + k10_WeaponTypeSword, 0};
-	static uint16 g249FixedPossessionCreature_7rockRockPile[5] = { // @ G0249_aui_Graphic559_FixedPossessionsCreature07Rock_RockPile
-		k127_ObjectInfoIndexFirstJunk + k25_JunkTypeBoulder,
-		k127_ObjectInfoIndexFirstJunk + k25_JunkTypeBoulder | k0x8000_randomDrop,
-		k23_ObjectInfoIndexFirstWeapon + k30_WeaponTypeRock | k0x8000_randomDrop,
-		k23_ObjectInfoIndexFirstWeapon + k30_WeaponTypeRock | k0x8000_randomDrop, 0};
-	static uint16 g250FixedPossessionCreature_4PainRatHellHound[3] = { // @ G0250_aui_Graphic559_FixedPossessionsCreature04PainRat_Hellhound
-		k127_ObjectInfoIndexFirstJunk + k35_JunkTypeDrumstickShank,
-		k127_ObjectInfoIndexFirstJunk + k35_JunkTypeDrumstickShank | k0x8000_randomDrop, 0};
-	static uint16 g251FixedPossessionCreature_6screamer[3] = { // @ G0251_aui_Graphic559_FixedPossessionsCreature06Screamer
-		k127_ObjectInfoIndexFirstJunk + k33_JunkTypeScreamerSlice,
-		k127_ObjectInfoIndexFirstJunk + k33_JunkTypeScreamerSlice | k0x8000_randomDrop, 0};
-	static uint16 g252FixedPossessionCreature_15MagnetaWormWorm[4] = { // @ G0252_aui_Graphic559_FixedPossessionsCreature15MagentaWorm_Worm
-		k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound,
-		k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound | k0x8000_randomDrop,
-		k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound | k0x8000_randomDrop, 0};
-	static uint16 g253FixedPossessionCreature_24RedDragon[11] = { // @ G0253_aui_Graphic559_FixedPossessionsCreature24RedDragon
-		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
-		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
-		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
-		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
-		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
-		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
-		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
-		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
-		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop,
-		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop, 0};
-
-	uint16 L0356_ui_FixedPossession;
-	int16 L0357_i_ThingType;
-	Thing L0358_T_Thing;
-	uint16* L0359_pui_FixedPossessions;
-	Weapon* L0360_ps_Weapon;
-	bool L0361_B_Cursed;
-	bool L0362_B_WeaponDropped;
-
-
-	L0361_B_Cursed = false;
-	L0362_B_WeaponDropped = false;
-	switch (creatureType) {
-	default:
-		return;
-	case k12_CreatureTypeSkeleton:
-		L0359_pui_FixedPossessions = g245FixedPossessionCreature_12Skeleton;
-		break;
-	case k9_CreatureTypeStoneGolem:
-		L0359_pui_FixedPossessions = g246FixedPossessionCreature_9StoneGolem;
-		break;
-	case k16_CreatureTypeTrolinAntman:
-		L0359_pui_FixedPossessions = g247FixedPossessionCreature_16TrolinAntman;
-		break;
-	case k18_CreatureTypeAnimatedArmourDethKnight:
-		L0361_B_Cursed = true;
-		L0359_pui_FixedPossessions = g248FixedPossessionCreature_18AnimatedArmourDethKnight;
-		break;
-	case k7_CreatureTypeRockpile:
-		L0359_pui_FixedPossessions = g249FixedPossessionCreature_7rockRockPile;
-		break;
-	case k4_CreatureTypePainRatHellHound:
-		L0359_pui_FixedPossessions = g250FixedPossessionCreature_4PainRatHellHound;
-		break;
-	case k6_CreatureTypeScreamer:
-		L0359_pui_FixedPossessions = g251FixedPossessionCreature_6screamer;
-		break;
-	case k15_CreatureTypeMagnetaWormWorm:
-		L0359_pui_FixedPossessions = g252FixedPossessionCreature_15MagnetaWormWorm;
-		break;
-	case k24_CreatureTypeRedDragon:
-		L0359_pui_FixedPossessions = g253FixedPossessionCreature_24RedDragon;
-	}
-	while (L0356_ui_FixedPossession = *L0359_pui_FixedPossessions++) {
-		if (getFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) && _vm->getRandomNumber(2))
-			continue;
-		if (clearFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) >= k127_ObjectInfoIndexFirstJunk) {
-			L0357_i_ThingType = k10_JunkThingType;
-			L0356_ui_FixedPossession -= k127_ObjectInfoIndexFirstJunk;
-		} else {
-			if (L0356_ui_FixedPossession >= k69_ObjectInfoIndexFirstArmour) {
-				L0357_i_ThingType = k6_ArmourThingType;
-				L0356_ui_FixedPossession -= k69_ObjectInfoIndexFirstArmour;
-			} else {
-				L0362_B_WeaponDropped = true;
-				L0357_i_ThingType = k5_WeaponThingType;
-				L0356_ui_FixedPossession -= k23_ObjectInfoIndexFirstWeapon;
-			}
-		}
-		if ((L0358_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(L0357_i_ThingType)) == Thing::_none) {
-			continue;
-		}
-		L0360_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0358_T_Thing);
-/* The same pointer type is used no matter the actual type k5_WeaponThingType, k6_ArmourThingType or k10_JunkThingType */
-		L0360_ps_Weapon->setType(L0356_ui_FixedPossession);
-		L0360_ps_Weapon->setCursed(L0361_B_Cursed);
-		L0358_T_Thing = M15_thingWithNewCell(L0358_T_Thing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell);
-		_vm->_movsens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY);
-	}
-	warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
-}
-
-int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
-#define AP0483_i_PrimaryDirection srcMapX
-	int16 L0556_i_Direction;
-
-
-	if (srcMapX == destMapX) {
-		_vm->_projexpl->_g363_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 1; /* Resulting direction may be 1 or 3 (East or West) */
-		if (srcMapY > destMapY) {
-			return kDirNorth;
-		}
-		return kDirSouth;
-	}
-	if (srcMapY == destMapY) {
-		_vm->_projexpl->_g363_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 0; /* Resulting direction may be 0 or 2 (North or South) */
-		if (srcMapX > destMapX) {
-			return kDirWest;
-		}
-		return kDirEast;
-	}
-	L0556_i_Direction = kDirNorth;
-	for (;;) {
-		if (f227_isDestVisibleFromSource(L0556_i_Direction, srcMapX, srcMapY, destMapX, destMapY)) {
-			if (!f227_isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
-				if ((L0556_i_Direction != kDirNorth) || !f227_isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnPrevVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
-					_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + L0556_i_Direction);
-					return L0556_i_Direction;
-				}
-			}
-			if (_vm->getRandomNumber(2)) {
-				AP0483_i_PrimaryDirection = _vm->_projexpl->_g363_secondaryDirToOrFromParty;
-				_vm->_projexpl->_g363_secondaryDirToOrFromParty = L0556_i_Direction;
-				return AP0483_i_PrimaryDirection;
-			}
-			return L0556_i_Direction;
-		}
-		L0556_i_Direction++;
-	}
-}
-
-bool GroupMan::f227_isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
-	int L1637_i_Temp;
-
-	switch (dir) { /* If direction is not 'West' then swap variables so that the same test as for west can be applied */
-	case kDirSouth:
-		L1637_i_Temp = srcMapX;
-		srcMapX = destMapY;
-		destMapY = L1637_i_Temp;
-		L1637_i_Temp = destMapX;
-		destMapX = srcMapY;
-		srcMapY = L1637_i_Temp;
-		break;
-	case kDirEast:
-		L1637_i_Temp = srcMapX;
-		srcMapX = destMapX;
-		destMapX = L1637_i_Temp;
-		L1637_i_Temp = destMapY;
-		destMapY = srcMapY;
-		srcMapY = L1637_i_Temp;
-		break;
-	case kDirNorth:
-		L1637_i_Temp = srcMapX;
-		srcMapX = srcMapY;
-		srcMapY = L1637_i_Temp;
-		L1637_i_Temp = destMapX;
-		destMapX = destMapY;
-		destMapY = L1637_i_Temp;
-	}
-	return ((srcMapX -= (destMapX - 1)) > 0) && ((((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY) <= srcMapX);
-}
-
-bool GroupMan::f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack, bool magicAttack, int16 ticks) {
-	Door* L0573_ps_Door;
-	byte* L0574_puc_Square;
-	TimelineEvent L0575_s_Event;
-
-	L0573_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY);
-	if ((magicAttack && !L0573_ps_Door->isMagicDestructible()) || (!magicAttack && !L0573_ps_Door->isMeleeDestructible())) {
-		return false;
-	}
-	if (attack >= _vm->_dungeonMan->_g275_currMapDoorInfo[L0573_ps_Door->getType()]._defense) {
-		L0574_puc_Square = &_vm->_dungeonMan->_g271_currMapData[mapX][mapY];
-		if (Square(*L0574_puc_Square).getDoorState() == k4_doorState_CLOSED) {
-			if (ticks) {
-				M33_setMapAndTime(L0575_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ticks);
-				L0575_s_Event._type = k2_TMEventTypeDoorDestruction;
-				L0575_s_Event._priority = 0;
-				L0575_s_Event._B._location._mapX = mapX;
-				L0575_s_Event._B._location._mapY = mapY;
-				_vm->_timeline->f238_addEventGetEventIndex(&L0575_s_Event);
-			} else {
-				((Square*)L0574_puc_Square)->setDoorState(k5_doorState_DESTROYED);
-			}
-			return true;
-		}
-	}
-	return false;
-}
-
-Thing GroupMan::f175_groupGetThing(int16 mapX, int16 mapY) {
-	Thing L0317_T_Thing;
-
-	L0317_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
-	while ((L0317_T_Thing != Thing::_endOfList) && ((L0317_T_Thing).getType() != k4_GroupThingType)) {
-		L0317_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0317_T_Thing);
-	}
-	return L0317_T_Thing;
-}
-
-int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group* group, uint16 creatureIndex, int16 mapX, int16 mapY, int16 damage, bool notMoving) {
-	uint16 L0374_ui_Multiple;
-#define AL0374_ui_EventIndex    L0374_ui_Multiple
-#define AL0374_ui_CreatureIndex L0374_ui_Multiple
-#define AL0374_ui_CreatureSize  L0374_ui_Multiple
-#define AL0374_ui_Attack        L0374_ui_Multiple
-	uint16 L0375_ui_Multiple;
-#define AL0375_ui_Outcome           L0375_ui_Multiple
-#define AL0375_ui_EventType         L0375_ui_Multiple
-#define AL0375_ui_NextCreatureIndex L0375_ui_Multiple
-	CreatureInfo* L0376_ps_CreatureInfo;
-	TimelineEvent* L0377_ps_Event;
-	ActiveGroup* L0378_ps_ActiveGroup = nullptr;
-	uint16 L0379_ui_CreatureCount;
-	uint16 L0380_ui_Multiple = 0;
-#define AL0380_ui_CreatureType   L0380_ui_Multiple
-#define AL0380_ui_FearResistance L0380_ui_Multiple
-	uint16 L0381_ui_GroupCells;
-	uint16 L0382_ui_GroupDirections;
-	bool L0383_B_CurrentMapIsPartyMap;
-	uint16 L0384_ui_Cell;
-
-
-	L0376_ps_CreatureInfo = &g243_CreatureInfo[AL0380_ui_CreatureType = group->_type];
-	if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) /* Lord Chaos cannot be damaged */
-		goto T0190024;
-	if (group->_health[creatureIndex] <= damage) {
-		L0381_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(group, _vm->_dungeonMan->_g272_currMapIndex);
-		L0384_ui_Cell = (L0381_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0381_ui_GroupCells, creatureIndex);
-		if (!(L0379_ui_CreatureCount = group->getCount())) { /* If there is a single creature in the group */
-			if (notMoving) {
-				f188_dropGroupPossessions(mapX, mapY, _vm->_groupMan->f175_groupGetThing(mapX, mapY), k2_soundModePlayOneTickLater);
-				f189_delete(mapX, mapY);
-			}
-			AL0375_ui_Outcome = k2_outcomeKilledAllCreaturesInGroup;
-		} else { /* If there are several creatures in the group */
-			L0382_ui_GroupDirections = _vm->_groupMan->f147_getGroupDirections(group, _vm->_dungeonMan->_g272_currMapIndex);
-			if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
-				if (notMoving) {
-					f186_dropCreatureFixedPossessions(AL0380_ui_CreatureType, mapX, mapY, L0384_ui_Cell, k2_soundModePlayOneTickLater);
-				} else {
-					_g392_dropMovingCreatureFixedPossessionsCell[_g391_dropMovingCreatureFixedPossCellCount++] = L0384_ui_Cell;
-				}
-			}
-			if (L0383_B_CurrentMapIsPartyMap = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) {
-				L0378_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
-			}
-			if (group->getBehaviour() == k6_behavior_ATTACK) {
-				L0377_ps_Event = _vm->_timeline->_g370_events;
-				for (AL0374_ui_EventIndex = 0; AL0374_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; AL0374_ui_EventIndex++) {
-					if ((M29_map(L0377_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) &&
-						(L0377_ps_Event->_B._location._mapX == mapX) &&
-						(L0377_ps_Event->_B._location._mapY == mapY) &&
-						((AL0375_ui_EventType = L0377_ps_Event->_type) > k32_TMEventTypeUpdateAspectGroup) &&
-						(AL0375_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1)) {
-						if (AL0375_ui_EventType < k37_TMEventTypeUpdateBehaviourGroup) {
-							AL0375_ui_EventType -= k33_TMEventTypeUpdateAspectCreature_0; /* Get creature index for events 33 to 36 */
-						} else {
-							AL0375_ui_EventType -= k38_TMEventTypeUpdateBehaviour_0; /* Get creature index for events 38 to 41 */
-						}
-						if (AL0375_ui_NextCreatureIndex == creatureIndex) {
-							_vm->_timeline->f237_deleteEvent(AL0374_ui_EventIndex);
-						} else {
-							if (AL0375_ui_NextCreatureIndex > creatureIndex) {
-								L0377_ps_Event->_type -= 1;
-								_vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(AL0374_ui_EventIndex));
-							}
-						}
-					}
-					L0377_ps_Event++;
-				}
-				if (L0383_B_CurrentMapIsPartyMap && ((AL0380_ui_FearResistance = L0376_ps_CreatureInfo->M57_getFearResistance()) != k15_immuneToFear) && ((AL0380_ui_FearResistance += L0379_ui_CreatureCount - 1) < (_vm->getRandomNumber(16)))) { /* Test if the death of a creature frigthens the remaining creatures in the group */
-					L0378_ps_ActiveGroup->_delayFleeingFromTarget = _vm->getRandomNumber(100 - (AL0380_ui_FearResistance << 2)) + 20;
-					group->setBehaviour(k5_behavior_FLEE);
-				}
-			}
-			for (AL0375_ui_NextCreatureIndex = AL0374_ui_CreatureIndex = creatureIndex; AL0374_ui_CreatureIndex < L0379_ui_CreatureCount; AL0374_ui_CreatureIndex++) {
-				AL0375_ui_NextCreatureIndex++;
-				group->_health[AL0374_ui_CreatureIndex] = group->_health[AL0375_ui_NextCreatureIndex];
-				L0382_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0382_ui_GroupDirections, AL0374_ui_CreatureIndex, _vm->_groupMan->M50_getCreatureValue(L0382_ui_GroupDirections, AL0375_ui_NextCreatureIndex));
-				L0381_ui_GroupCells = f178_getGroupValueUpdatedWithCreatureValue(L0381_ui_GroupCells, AL0374_ui_CreatureIndex, _vm->_groupMan->M50_getCreatureValue(L0381_ui_GroupCells, AL0375_ui_NextCreatureIndex));
-				if (L0383_B_CurrentMapIsPartyMap) {
-					L0378_ps_ActiveGroup->_aspect[AL0374_ui_CreatureIndex] = L0378_ps_ActiveGroup->_aspect[AL0375_ui_NextCreatureIndex];
-				}
-			}
-			L0381_ui_GroupCells &= 0x003F;
-			_vm->_dungeonMan->f146_setGroupCells(group, L0381_ui_GroupCells, _vm->_dungeonMan->_g272_currMapIndex);
-			_vm->_dungeonMan->f148_setGroupDirections(group, L0382_ui_GroupDirections, _vm->_dungeonMan->_g272_currMapIndex);
-			group->setCount(group->getCount() - 1);
-			AL0375_ui_Outcome = k1_outcomeKilledSomeCreaturesInGroup;
-		}
-		if ((AL0374_ui_CreatureSize = getFlag(L0376_ps_CreatureInfo->_attributes, k0x0003_MaskCreatureInfo_size)) == k0_MaskCreatureSizeQuarter) {
-			AL0374_ui_Attack = 110;
-		} else {
-			if (AL0374_ui_CreatureSize == k1_MaskCreatureSizeHalf) {
-				AL0374_ui_Attack = 190;
-			} else {
-				AL0374_ui_Attack = 255;
-			}
-		}
-		_vm->_projexpl->f213_explosionCreate(Thing::_explSmoke, AL0374_ui_Attack, mapX, mapY, L0384_ui_Cell); /* BUG0_66 Smoke is placed on the source map instead of the destination map when a creature dies by falling through a pit. The game has a special case to correctly drop the creature possessions on the destination map but there is no such special case for the smoke. Note that the death must be caused by the damage of the fall (there is no smoke if the creature is removed because its type is not allowed on the destination map). However this bug has no visible consequence because of BUG0_26: the smoke explosion falls in the pit right after being placed in the dungeon and before being drawn on screen so it is only visible on the destination square */
-		return AL0375_ui_Outcome;
-	}
-	if (damage > 0) {
-		group->_health[creatureIndex] -= damage;
-	}
-T0190024:
-	return k0_outcomeKilledNoCreaturesInGroup;
-}
-
-void GroupMan::f189_delete(int16 mapX, int16 mapY) {
-	Thing L0372_T_GroupThing;
-	Group* L0373_ps_Group;
-
-
-	if ((L0372_T_GroupThing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) {
-		return;
-	}
-	L0373_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0372_T_GroupThing);
-	for (uint16 i = 0; i < 4; ++i)
-		L0373_ps_Group->_health[i] = 0;
-	_vm->_movsens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
-	L0373_ps_Group->_nextThing = Thing::_none;
-	if (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) {
-		_vm->_groupMan->_g375_activeGroups[L0373_ps_Group->getActiveGroupIndex()]._groupThingIndex = -1;
-		_g377_currActiveGroupCount--;
-	}
-	f181_groupDeleteEvents(mapX, mapY);
-}
-
-void GroupMan::f181_groupDeleteEvents(int16 mapX, int16 mapY) {
-	int16 L0334_i_EventIndex;
-	uint16 L0335_ui_EventType;
-	TimelineEvent* L0336_ps_Event;
-
-
-	L0336_ps_Event = _vm->_timeline->_g370_events;
-	for (L0334_i_EventIndex = 0; L0334_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0334_i_EventIndex++) {
-		if ((M29_map(L0336_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) &&
-			((L0335_ui_EventType = L0336_ps_Event->_type) > k29_TMEventTypeGroupReactionDangerOnSquare - 1) && (L0335_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1) &&
-			(L0336_ps_Event->_B._location._mapX == mapX) && (L0336_ps_Event->_B._location._mapY == mapY)) {
-			_vm->_timeline->f237_deleteEvent(L0334_i_EventIndex);
-		}
-		L0336_ps_Event++;
-	}
-}
-
-uint16 GroupMan::f178_getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatreVal) {
-	creatreVal &= 0x0003;
-	creatreVal <<= (creatureIndex <<= 1);
-	return creatreVal | (groupVal & ~(3 << creatreVal));
-}
-
-int16 GroupMan::f191_getDamageAllCreaturesOutcome(Group* group, int16 mapX, int16 mapY, int16 attack, bool notMoving) {
-	uint16 L0385_ui_RandomAttack;
-	int16 L0386_i_CreatureIndex;
-	int16 L0387_i_Outcome;
-	bool L0388_B_KilledSomeCreatures;
-	bool L0389_B_KilledAllCreatures;
-
-
-	L0388_B_KilledSomeCreatures = false;
-	L0389_B_KilledAllCreatures = true;
-	_g391_dropMovingCreatureFixedPossCellCount = 0;
-	if (attack > 0) {
-		L0386_i_CreatureIndex = group->getCount();
-		attack -= (L0385_ui_RandomAttack = (attack >> 3) + 1);
-		L0385_ui_RandomAttack <<= 1;
-		do {
-			L0389_B_KilledAllCreatures = (L0387_i_Outcome = f190_groupGetDamageCreatureOutcome(group, L0386_i_CreatureIndex, mapX, mapY, attack + _vm->getRandomNumber(L0385_ui_RandomAttack), notMoving)) && L0389_B_KilledAllCreatures;
-			L0388_B_KilledSomeCreatures = L0388_B_KilledSomeCreatures || L0387_i_Outcome;
-		} while (L0386_i_CreatureIndex--);
-		if (L0389_B_KilledAllCreatures) {
-			return k2_outcomeKilledAllCreaturesInGroup;
-		}
-		if (L0388_B_KilledSomeCreatures) {
-			return k1_outcomeKilledSomeCreaturesInGroup;
-		}
-		return k0_outcomeKilledNoCreaturesInGroup;
-	} else {
-		return k0_outcomeKilledNoCreaturesInGroup;
-	}
-}
-
-int16 GroupMan::f192_groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack) {
-	int16 L0390_i_PoisonResistance;
-
-
-	if (!poisonAttack || ((L0390_i_PoisonResistance = g243_CreatureInfo[creatreType].M61_poisonResistance()) == k15_immuneToPoison)) {
-		return 0;
-	}
-	return ((poisonAttack + _vm->getRandomNumber(4)) << 3) / ++L0390_i_PoisonResistance;
-}
-
-void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks) {
-	Group* L0444_ps_Group;
-	ActiveGroup* L0445_ps_ActiveGroup;
-	int16 L0446_i_Multiple;
-#define AL0446_i_EventType           L0446_i_Multiple
-#define AL0446_i_Direction           L0446_i_Multiple
-#define AL0446_i_Ticks               L0446_i_Multiple
-#define AL0446_i_Distance            L0446_i_Multiple
-#define AL0446_i_Behavior2Or3        L0446_i_Multiple
-#define AL0446_i_CreatureAspectIndex L0446_i_Multiple
-#define AL0446_i_Range               L0446_i_Multiple
-#define AL0446_i_CreatureAttributes  L0446_i_Multiple
-#define AL0446_i_Cell                L0446_i_Multiple
-#define AL0446_i_GroupCellsCriteria  L0446_i_Multiple
-	int16 L0447_i_Multiple;
-#define AL0447_i_Behavior           L0447_i_Multiple
-#define AL0447_i_CreatureIndex      L0447_i_Multiple
-#define AL0447_i_ReferenceDirection L0447_i_Multiple
-#define AL0447_i_Ticks              L0447_i_Multiple
-	CreatureInfo L0448_s_CreatureInfo;
-	Thing L0449_T_GroupThing;
-	int16 L0450_i_Multiple;
-#define AL0450_i_DestinationMapX  L0450_i_Multiple
-#define AL0450_i_DistanceXToParty L0450_i_Multiple
-#define AL0450_i_TargetMapX       L0450_i_Multiple
-	int16 L0451_i_Multiple;
-#define AL0451_i_DestinationMapY  L0451_i_Multiple
-#define AL0451_i_DistanceYToParty L0451_i_Multiple
-#define AL0451_i_TargetMapY       L0451_i_Multiple
-	int16 L0452_i_DistanceToVisibleParty = 0;
-	bool L0453_B_NewGroupDirectionFound;
-	int16 L0454_i_PrimaryDirectionToOrFromParty;
-	bool L0455_B_CurrentEventTypeIsNotUpdateBehavior;
-	bool L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls;
-	bool L0457_B_MoveToPriorLocation;
-	bool L0458_B_SetBehavior7_ApproachAfterReaction = false;
-	int16 L0459_i_CreatureSize;
-	uint16 L0460_ui_CreatureCount;
-	int16 L0461_i_MovementTicks;
-	int16 L0462_i_TicksSinceLastMove;
-	bool L0463_B_Archenemy;
-	int32 L0464_l_NextAspectUpdateTime;
-	TimelineEvent L0465_s_NextEvent;
-
-
-	/* If the party is not on the map specified in the event and the event type is not one of 32, 33, 37, 38 then the event is ignored */
-	if ((_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) && ((AL0446_i_EventType = eventType) != k37_TMEventTypeUpdateBehaviourGroup) && (AL0446_i_EventType != k32_TMEventTypeUpdateAspectGroup) && (AL0446_i_EventType != k38_TMEventTypeUpdateBehaviour_0) && (AL0446_i_EventType != k33_TMEventTypeUpdateAspectCreature_0))
-		goto T0209139_Return;
-	/* If there is no creature at the location specified in the event then the event is ignored */
-	if ((L0449_T_GroupThing = _vm->_groupMan->f175_groupGetThing(eventMapX, eventMapY)) == Thing::_endOfList) {
-		goto T0209139_Return;
-	}
-	L0444_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0449_T_GroupThing);
-	L0448_s_CreatureInfo = g243_CreatureInfo[L0444_ps_Group->_type];
-	/* Update the event */
-	M33_setMapAndTime(L0465_s_NextEvent._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime);
-	L0465_s_NextEvent._priority = 255 - L0448_s_CreatureInfo._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
-	L0465_s_NextEvent._B._location._mapX = eventMapX;
-	L0465_s_NextEvent._B._location._mapY = eventMapY;
-	/* If the creature is not on the party map then try and move the creature in a random direction and place a new event 37 in the timeline for the next creature movement */
-	if (_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) {
-		if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->getRandomNumber(4), false)) { /* BUG0_67 A group that is not on the party map may wrongly move or not move into a teleporter. Normally, a creature type with Wariness >= 10 (Vexirk, Materializer / Zytaz, Demon, Lord Chaos, Red Dragon / Dragon) would only move into a teleporter if the creature type is allowed on the destination map. However, the variable G0380_T_CurrentGroupThing identifying the group is not set before being used by F0139_DUNGEON_IsCreatureAllowedOnMap called by f202_isMovementPossible so the check to see if the creature type is allowed may operate on another creature type and thus return an incorrect result, causing the creature to teleport while it should not, or not to teleport while it should */
-			AL0450_i_DestinationMapX = eventMapX;
-			AL0451_i_DestinationMapY = eventMapY;
-			AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
-			if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
-				goto T0209139_Return;
-			L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX;
-			L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY;
-		}
-		L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup;
-		AL0446_i_Ticks = MAX(ABS(_vm->_dungeonMan->_g272_currMapIndex - _vm->_dungeonMan->_g309_partyMapIndex) << 4, L0448_s_CreatureInfo._movementTicks << 1);
-		/* BUG0_68 A group moves or acts with a wrong timing. Event is added below but L0465_s_NextEvent.C.Ticks has not been initialized. No consequence while the group is not on the party map. When the party enters the group map the first group event may have a wrong timing */
-T0209005_AddEventAndReturn:
-		L0465_s_NextEvent._mapTime += AL0446_i_Ticks;
-		_vm->_timeline->f238_addEventGetEventIndex(&L0465_s_NextEvent);
-		goto T0209139_Return;
-	}
-	/* If the creature is Lord Chaos then ignore the event if the game is won. Initialize data to analyze Fluxcages */
-	if (L0463_B_Archenemy = getFlag(L0448_s_CreatureInfo._attributes, k0x2000_MaskCreatureInfo_archenemy)) {
-		if (_vm->_g302_gameWon) {
-			goto T0209139_Return;
-		}
-		_g386_fluxCageCount = 0;
-		_g385_fluxCages[0] = 0;
-	}
-	L0445_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[L0444_ps_Group->getActiveGroupIndex()];
-	if ((L0462_i_TicksSinceLastMove = (unsigned char)_vm->_g313_gameTime - L0445_ps_ActiveGroup->_lastMoveTime) < 0) {
-		L0462_i_TicksSinceLastMove += 256;
-	}
-	if ((L0461_i_MovementTicks = L0448_s_CreatureInfo._movementTicks) == k255_immobile) {
-		L0461_i_MovementTicks = 100;
-	}
-	if (_vm->_championMan->_g407_party._freezeLifeTicks && !L0463_B_Archenemy) { /* If life is frozen and the creature is not Lord Chaos (Lord Chaos is immune to Freeze Life) then reschedule the event later (except for reactions which are ignored when life if frozen) */
-		if (eventType < 0)
-			goto T0209139_Return;
-		L0465_s_NextEvent._type = eventType;
-		L0465_s_NextEvent._C._ticks = ticks;
-		AL0446_i_Ticks = 4; /* Retry in 4 ticks */
-		goto T0209005_AddEventAndReturn;
-	}
-	/* If the specified event type is a 'reaction' instead of a real event from the timeline then create the corresponding reaction event with a delay:
-	For event kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, the reaction time is 1 tick
-	For event kM2_TMEventTypeCreateReactionEvent30HitByProjectile and kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, the reaction time may be 1 tick or slower: slow moving creatures react more slowly. The more recent is the last creature move, the slower the reaction */
-	if (eventType < 0) {
-		L0465_s_NextEvent._type = eventType + k32_TMEventTypeUpdateAspectGroup;
-		if ((eventType == kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) || ((AL0446_i_Ticks = ((L0461_i_MovementTicks + 2) >> 2) - L0462_i_TicksSinceLastMove) < 1)) { /* AL0446_i_Ticks is the reaction time */
-			AL0446_i_Ticks = 1; /* Retry in 1 tick */
-		}
-		goto T0209005_AddEventAndReturn; /* BUG0_68 A group moves or acts with a wrong timing. Event is added but L0465_s_NextEvent.C.Ticks has not been initialized */
-	}
-	AL0447_i_Behavior = L0444_ps_Group->getBehaviour();
-	L0460_ui_CreatureCount = L0444_ps_Group->getCount();
-	L0459_i_CreatureSize = getFlag(L0448_s_CreatureInfo._attributes, k0x0003_MaskCreatureInfo_size);
-	AL0450_i_DistanceXToParty = ((AL0446_i_Distance = eventMapX - _vm->_dungeonMan->_g306_partyMapX) < 0) ? -AL0446_i_Distance : AL0446_i_Distance;
-	AL0451_i_DistanceYToParty = ((AL0446_i_Distance = eventMapY - _vm->_dungeonMan->_g307_partyMapY) < 0) ? -AL0446_i_Distance : AL0446_i_Distance;
-	_g378_currentGroupMapX = eventMapX;
-	_g379_currentGroupMapY = eventMapY;
-	_g380_currGroupThing = L0449_T_GroupThing;
-	_g384_groupMovementTestedDirections[0] = 0;
-	_g381_currGroupDistanceToParty = f226_getDistanceBetweenSquares(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
-	_g382_currGroupPrimaryDirToParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
-	_g383_currGroupSecondaryDirToParty = _vm->_projexpl->_g363_secondaryDirToOrFromParty;
-	L0464_l_NextAspectUpdateTime = 0;
-	L0455_B_CurrentEventTypeIsNotUpdateBehavior = true;
-	if (eventType <= k31_TMEventTypeGroupReactionPartyIsAdjecent) { /* Process Reaction events 29 to 31 */
-		switch (eventType = eventType - k32_TMEventTypeUpdateAspectGroup) {
-		case kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent: /* This event is used when the party bumps into a group or attacks a group physically (not with a spell). It causes the creature behavior to change to attack if it is not already attacking the party or fleeing from target */
-			if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) {
-				f181_groupDeleteEvents(eventMapX, eventMapY);
-				goto T0209044_SetBehavior6_Attack;
-			}
-			L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
-			L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
-			goto T0209139_Return;
-		case kM2_TMEventTypeCreateReactionEvent30HitByProjectile: /* This event is used for the reaction of a group after a projectile impacted with one creature in the group (some creatures may have been killed) */
-			if ((AL0447_i_Behavior == k6_behavior_ATTACK) || (AL0447_i_Behavior == k5_behavior_FLEE)) /* If the creature is attacking the party or fleeing from the target then there is no reaction */
-				goto T0209139_Return;
-			if ((AL0446_i_Behavior2Or3 = ((AL0447_i_Behavior == k3_behavior_USELESS) || (AL0447_i_Behavior == k2_behavior_USELESS))) || (_vm->getRandomNumber(4))) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances */
-				if (!f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { /* If the group cannot see the party then look in a random direction to try and search for the party */
-					L0458_B_SetBehavior7_ApproachAfterReaction = L0453_B_NewGroupDirectionFound = false;
-					goto T0209073_SetDirectionGroup;
-				}
-				if (AL0446_i_Behavior2Or3 || (_vm->getRandomNumber(4))) /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances then no reaction */
-					goto T0209139_Return;
-			} /* No 'break': proceed to instruction after the next 'case' below. Reaction is to move in a random direction to try and avoid other projectiles */
-		case kM3_TMEventTypeCreateReactionEvent29DangerOnSquare: /* This event is used when some creatures in the group were killed by a Poison Cloud or by a closing door or if Lord Chaos is surrounded by 3 Fluxcages. It causes the creature to move in a random direction to avoid the danger */
-			L0458_B_SetBehavior7_ApproachAfterReaction = (AL0447_i_Behavior == k6_behavior_ATTACK); /* If the creature behavior is 'Attack' and it has to move to avoid danger then it will change its behavior to 'Approach' after the movement */
-			L0453_B_NewGroupDirectionFound = false;
-			goto T0209058_MoveInRandomDirection;
-		}
-	}
-	if (eventType < k37_TMEventTypeUpdateBehaviourGroup) { /* Process Update Aspect events 32 to 36 */
-		L0465_s_NextEvent._type = eventType + 5;
-		if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
-			if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) {
-				if (M38_distance(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, eventMapX, eventMapY) <= 1)
-					goto T0209044_SetBehavior6_Attack;
-				if (((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k3_behavior_USELESS)) && (AL0447_i_Behavior != k7_behavior_APPROACH)) /* BUG0_00 Useless code. Behavior cannot be 3 because this value is never used. Moreover, the second condition in the && is redundant (if the value is 0 or 3, it cannot be 7). The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */
-					goto T0209054_SetBehavior7_Approach;
-			}
-			L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
-			L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
-		}
-		if (AL0447_i_Behavior == k6_behavior_ATTACK) {
-			AL0446_i_CreatureAspectIndex = eventType - k33_TMEventTypeUpdateAspectCreature_0; /* Value -1 for event 32, meaning aspect will be updated for all creatures in the group */
-			L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0446_i_CreatureAspectIndex, getFlag(L0445_ps_ActiveGroup->_aspect[AL0446_i_CreatureAspectIndex], k0x0080_MaskActiveGroupIsAttacking));
-			goto T0209136;
-		}
-		if ((AL0450_i_DistanceXToParty > 3) || (AL0451_i_DistanceYToParty > 3)) {
-			L0464_l_NextAspectUpdateTime = _vm->_g313_gameTime + ((L0448_s_CreatureInfo._animationTicks >> 4) & 0xF);
-			goto T0209136;
-		}
-	} else { /* Process Update Behavior events 37 to 41 */
-		L0455_B_CurrentEventTypeIsNotUpdateBehavior = false;
-		if (ticks) {
-			L0464_l_NextAspectUpdateTime = _vm->_g313_gameTime;
-		}
-		if (eventType == k37_TMEventTypeUpdateBehaviourGroup) { /* Process event 37, Update Group Behavior */
-			if ((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k2_behavior_USELESS) || (AL0447_i_Behavior == k3_behavior_USELESS)) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */
-				if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
-					if ((L0452_i_DistanceToVisibleParty <= (L0448_s_CreatureInfo.M56_getAttackRange())) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) { /* If the creature is in range for attack and on the same row or column as the party on the map */
-T0209044_SetBehavior6_Attack:
-						if (eventType == kM2_TMEventTypeCreateReactionEvent30HitByProjectile) {
-							f181_groupDeleteEvents(eventMapX, eventMapY);
-						}
-						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
-						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
-						L0444_ps_Group->setBehaviour(k6_behavior_ATTACK);
-						AL0446_i_Direction = _g382_currGroupPrimaryDirToParty;
-						for (AL0447_i_CreatureIndex = L0460_ui_CreatureCount; AL0447_i_CreatureIndex >= 0; AL0447_i_CreatureIndex--) {
-							if ((_vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) != AL0446_i_Direction) &&
-								((!AL0447_i_CreatureIndex) || (!_vm->getRandomNumber(2)))) {
-								f205_setDirection(L0445_ps_ActiveGroup, AL0446_i_Direction, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
-								M32_setTime(L0465_s_NextEvent._mapTime, _vm->_g313_gameTime + _vm->getRandomNumber(4) + 2); /* Random delay represents the time for the creature to turn */
-							} else {
-								M32_setTime(L0465_s_NextEvent._mapTime, _vm->_g313_gameTime + 1);
-							}
-							if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) {
-								L0465_s_NextEvent._mapTime += MIN((uint16)((L0448_s_CreatureInfo._attackTicks >> 1) + _vm->getRandomNumber(4)), ticks);
-							}
-							L0465_s_NextEvent._type = k38_TMEventTypeUpdateBehaviour_0 + AL0447_i_CreatureIndex;
-							f208_groupAddEvent(&L0465_s_NextEvent, f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false));
-						}
-						goto T0209139_Return;
-					}
-					if (AL0447_i_Behavior != k2_behavior_USELESS) { /* BUG0_00 Useless code. Behavior cannot be 2 because this value is never used */
-T0209054_SetBehavior7_Approach:
-						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
-						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
-						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
-						L0465_s_NextEvent._mapTime += 1;
-						goto T0209134_SetEvent37;
-					}
-				} else {
-					if (AL0447_i_Behavior == k0_behavior_WANDER) {
-						if (L0454_i_PrimaryDirectionToOrFromParty = f201_getSmelledPartyPrimaryDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY)) {
-							L0454_i_PrimaryDirectionToOrFromParty--;
-							L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = false;
-							goto T0209085_SingleSquareMove;
-						}
-						L0453_B_NewGroupDirectionFound = false;
-						if (_vm->getRandomNumber(2)) {
-T0209058_MoveInRandomDirection:
-							AL0446_i_Direction = _vm->getRandomNumber(4);
-							AL0447_i_ReferenceDirection = AL0446_i_Direction;
-							L0457_B_MoveToPriorLocation = false;
-							do {
-								AL0450_i_DestinationMapX = eventMapX;
-								AL0451_i_DestinationMapY = eventMapY;
-								AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
-								if (((L0445_ps_ActiveGroup->_priorMapX != AL0450_i_DestinationMapX) ||
-									(L0445_ps_ActiveGroup->_priorMapY != AL0451_i_DestinationMapY) ||
-									 (L0457_B_MoveToPriorLocation = !_vm->getRandomNumber(4))) /* 1/4 chance of moving back to the square that the creature comes from */
-									&& f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction, false)) {
-T0209061_MoveGroup:
-									if (L0453_B_NewGroupDirectionFound = ((AL0447_i_Ticks = (L0461_i_MovementTicks >> 1) - L0462_i_TicksSinceLastMove) <= 0)) {
-										if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
-											goto T0209139_Return;
-										L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX;
-										L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY;;
-										L0445_ps_ActiveGroup->_priorMapX = eventMapX;
-										L0445_ps_ActiveGroup->_priorMapY = eventMapY;
-										L0445_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime;
-									} else {
-										L0461_i_MovementTicks = AL0447_i_Ticks;
-										L0462_i_TicksSinceLastMove = -1;
-									}
-									break;
-								}
-								if (_g390_groupMovementBlockedByParty) {
-									if ((eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) &&
-										((L0444_ps_Group->getBehaviour() != k5_behavior_FLEE) ||
-										 !f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false) ||
-										 _vm->getRandomNumber(2)))
-										goto T0209044_SetBehavior6_Attack;
-									L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
-									L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
-								}
-							} while ((AL0446_i_Direction = returnNextVal(AL0446_i_Direction)) != AL0447_i_ReferenceDirection);
-						}
-						if (!L0453_B_NewGroupDirectionFound &&
-							(L0462_i_TicksSinceLastMove != -1) &&
-							L0463_B_Archenemy &&
-							((eventType == kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) || !_vm->getRandomNumber(4))) { /* BUG0_15 The game hangs when you close a door on Lord Chaos. A condition is missing in the code to manage creatures and this may create an infinite loop between two parts in the code */
-							_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0454_i_PrimaryDirectionToOrFromParty = _vm->getRandomNumber(4));
-							goto T0209089_DoubleSquareMove; /* BUG0_69 Memory corruption when you close a door on Lord Chaos. The local variable (L0454_i_PrimaryDirectionToOrFromParty) containing the direction where Lord Chaos tries to move may be used as an array index without being initialized and cause memory corruption */
-						}
-						if (L0453_B_NewGroupDirectionFound || ((!_vm->getRandomNumber(4) || (L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.M55_getSmellRange())) && (eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare))) {
-T0209073_SetDirectionGroup:
-							if (!L0453_B_NewGroupDirectionFound && (L0462_i_TicksSinceLastMove >= 0)) { /* If direction is not found yet then look around in a random direction */
-								AL0446_i_Direction = _vm->getRandomNumber(4);
-							}
-							f206_groupSetDirGroup(L0445_ps_ActiveGroup, AL0446_i_Direction, L0460_ui_CreatureCount, L0459_i_CreatureSize);
-						}
-						/* If event is kM3_TMEventTypeCreateReactionEvent29DangerOnSquare or kM2_TMEventTypeCreateReactionEvent30HitByProjectile */
-						if (eventType < kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) {
-							if (!L0453_B_NewGroupDirectionFound)
-								goto T0209139_Return;
-							if (L0458_B_SetBehavior7_ApproachAfterReaction) {
-								L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
-							}
-							f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
-						}
-					}
-				}
-			} else {
-				if (AL0447_i_Behavior == k7_behavior_APPROACH) {
-					if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
-						if ((L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.M56_getAttackRange()) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) /* If the creature is in range for attack and on the same row or column as the party on the map */
-							goto T0209044_SetBehavior6_Attack;
-T0209081_RunTowardParty:
-						L0461_i_MovementTicks++;
-						L0461_i_MovementTicks = L0461_i_MovementTicks >> 1; /* Running speed is half the movement ticks */
-						AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX);
-						AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY);
-					} else {
-T0209082_WalkTowardTarget:
-						AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_targetMapX;
-						AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY;
-						/* If the creature reached its target but the party is not there anymore */
-						if ((eventMapX == AL0450_i_TargetMapX) && (eventMapY == AL0451_i_TargetMapY)) {
-							L0453_B_NewGroupDirectionFound = false;
-							L0444_ps_Group->setBehaviour(k0_behavior_WANDER);
-							goto T0209073_SetDirectionGroup;
-						}
-					}
-					L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true;
-T0209084_SingleSquareMoveTowardParty:
-					L0454_i_PrimaryDirectionToOrFromParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY);
-T0209085_SingleSquareMove:
-					if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls) ||
-						f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls && _vm->getRandomNumber(2)) ||
-						f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction), false) ||
-						(!_vm->getRandomNumber(4) && f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty), false))) {
-						AL0450_i_DestinationMapX = eventMapX;
-						AL0451_i_DestinationMapY = eventMapY;
-						AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
-						goto T0209061_MoveGroup;
-					}
-					if (L0463_B_Archenemy) {
-T0209089_DoubleSquareMove:
-						f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false); /* BUG0_00 Useless code. Returned value is ignored. When Lord Chaos teleports two squares away the ability to move to the first square is ignored which means Lord Chaos can teleport through walls or any other obstacle */
-						if (f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty) ||
-							f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty) ||
-							(_g386_fluxCageCount && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction))) ||
-							((_g386_fluxCageCount >= 2) && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty)))) {
-							AL0450_i_DestinationMapX = eventMapX;
-							AL0451_i_DestinationMapY = eventMapY;
-							AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2;
-							warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
-							goto T0209061_MoveGroup;
-						}
-					}
-					f206_groupSetDirGroup(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, L0460_ui_CreatureCount, L0459_i_CreatureSize);
-				} else {
-					if (AL0447_i_Behavior == k5_behavior_FLEE) {
-T0209094_FleeFromTarget:
-						L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true;
-						/* If the creature can see the party then update target coordinates */
-						if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
-							AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX);
-							AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY);
-						} else {
-							if (!(--(L0445_ps_ActiveGroup->_delayFleeingFromTarget))) { /* If the creature is not afraid anymore then stop fleeing from target */
-T0209096_SetBehavior0_Wander:
-								L0453_B_NewGroupDirectionFound = false;
-								L0444_ps_Group->setBehaviour(k0_behavior_WANDER);
-								goto T0209073_SetDirectionGroup;
-							}
-							if (_vm->getRandomNumber(2)) {
-								/* If the creature cannot move and the party is adjacent then stop fleeing */
-								if (!f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false)) {
-									if (M38_distance(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)
-										goto T0209096_SetBehavior0_Wander;
-								}
-								/* Set creature target to the home square where the creature was located when the party entered the map */
-								AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_homeMapX;
-								AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_homeMapY;
-								goto T0209084_SingleSquareMoveTowardParty;
-							}
-							AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_targetMapX;
-							AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY;
-						}
-						/* Try and flee from the party (opposite direction) */
-						L0454_i_PrimaryDirectionToOrFromParty = returnOppositeDir((direction)f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY));
-						_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnOppositeDir((direction)_vm->_projexpl->_g363_secondaryDirToOrFromParty);
-						L0461_i_MovementTicks -= (L0461_i_MovementTicks >> 2);
-						goto T0209085_SingleSquareMove;
-					}
-				}
-			}
-		} else { /* Process events 38 to 41, Update Creature Behavior */
-			if (AL0447_i_Behavior == k5_behavior_FLEE) {
-				if (L0460_ui_CreatureCount) {
-					f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
-				}
-				goto T0209094_FleeFromTarget;
-			}
-			/* If the creature is attacking, then compute the next aspect update time and the next attack time */
-			if (getFlag(L0445_ps_ActiveGroup->_aspect[AL0447_i_CreatureIndex = eventType - k38_TMEventTypeUpdateBehaviour_0], k0x0080_MaskActiveGroupIsAttacking)) {
-				L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false);
-				L0465_s_NextEvent._mapTime += ((AL0447_i_Ticks = L0448_s_CreatureInfo._attackTicks) + _vm->getRandomNumber(4) - 1);
-				if (AL0447_i_Ticks > 15) {
-					L0465_s_NextEvent._mapTime += _vm->getRandomNumber(8) - 2;
-				}
-			} else { /* If the creature is not attacking, then try attacking if possible */
-				if (AL0447_i_CreatureIndex > L0460_ui_CreatureCount) { /* Ignore event if it is for a creature that is not in the group */
-					goto T0209139_Return;
-				}
-				L0454_i_PrimaryDirectionToOrFromParty = _g382_currGroupPrimaryDirToParty;
-				/* If the party is visible, update the target coordinates */
-				if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, AL0447_i_CreatureIndex, eventMapX, eventMapY)) {
-					L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
-					L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
-				}
-				/* If there is a single creature in the group that is not full square sized and 1/4 chance */
-				if (!L0460_ui_CreatureCount && (L0459_i_CreatureSize != k2_MaskCreatureSizeFull) && !((AL0446_i_GroupCellsCriteria = _vm->getRandomNumber(65536)) & 0x00C0)) {
-					if (L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) {
-						/* If the creature is not already on the center of the square then change its cell */
-						if (AL0446_i_GroupCellsCriteria & 0x0038) { /* 7/8 chances of changing cell to the center of the square */
-							L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature;
-						} else { /* 1/8 chance of changing cell to the next or previous cell on the square */
-							AL0446_i_GroupCellsCriteria = M21_normalizeModulo4(M21_normalizeModulo4(L0445_ps_ActiveGroup->_cells) + ((AL0446_i_GroupCellsCriteria & 0x0001) ? 1 : -1));
-						}
-					}
-					/* If 1/8 chance and the creature is not adjacent to the party and is a quarter square sized creature then process projectile impacts and update the creature cell if still alive. When the creature is not in front of the party, it has 7/8 chances of dodging a projectile by moving to another cell or staying in the center of the square */
-					if (!(AL0446_i_GroupCellsCriteria & 0x0038) && (L0452_i_DistanceToVisibleParty != 1) && (L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter)) {
-						if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* This call to F0218_PROJECTILE_GetImpactCount works fine because there is a single creature in the group so L0445_ps_ActiveGroup->Cells contains only one cell index */
-							goto T0209139_Return;
-						L0445_ps_ActiveGroup->_cells = M21_normalizeModulo4(AL0446_i_GroupCellsCriteria);
-					}
-				}
-				/* If the creature can see the party and is looking in the party direction or can attack in all direction */
-				if (L0452_i_DistanceToVisibleParty &&
-					(getFlag(L0448_s_CreatureInfo._attributes, k0x0004_MaskCreatureInfo_sideAttack) ||
-					 _vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) == L0454_i_PrimaryDirectionToOrFromParty)) {
-					/* If the creature is in range to attack the party and random test succeeds */
-					if ((L0452_i_DistanceToVisibleParty <= (AL0446_i_Range = L0448_s_CreatureInfo.M56_getAttackRange())) &&
-						(!AL0450_i_DistanceXToParty || !AL0451_i_DistanceYToParty) &&
-						(AL0446_i_Range <= (_vm->getRandomNumber(16) + 1))) {
-						if ((AL0446_i_Range == 1) &&
-							(!getFlag(AL0446_i_CreatureAttributes = L0448_s_CreatureInfo._attributes, k0x0008_MaskCreatureInfo_preferBackRow) || !_vm->getRandomNumber(4) || !getFlag(AL0446_i_CreatureAttributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) &&
-							(L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter) &&
-							(L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) &&
-							((AL0446_i_Cell = _vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex)) != L0454_i_PrimaryDirectionToOrFromParty) &&
-							(AL0446_i_Cell != returnNextVal(L0454_i_PrimaryDirectionToOrFromParty))) { /* If the creature cannot cast spells (range = 1) and is not on a cell where it can attack the party directly and is a quarter square sized creature not in the center of the square then the creature moves to another cell and attack does not occur immediately */
-							if (!L0460_ui_CreatureCount && _vm->getRandomNumber(2)) {
-								L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature;
-							} else {
-								if ((L0454_i_PrimaryDirectionToOrFromParty & 0x0001) == (AL0446_i_Cell & 0x0001)) {
-									AL0446_i_Cell--;
-								} else {
-									AL0446_i_Cell++;
-								}
-								if (!_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = M21_normalizeModulo4(AL0446_i_Cell)) ||
-									(_vm->getRandomNumber(2) && !_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */
-									if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* BUG0_70 A projectile impact on a creature may be ignored. The function F0218_PROJECTILE_GetImpactCount to detect projectile impacts when a quarter square sized creature moves inside a group (to another cell on the same square) may fail if there are several creatures in the group because the function expects a single cell index for its last parameter. The function should be called once for each cell where there is a creature */
-										goto T0209139_Return;
-									if (_vm->_projexpl->_g364_creatureDamageOutcome != k1_outcomeKilledSomeCreaturesInGroup) {
-										L0445_ps_ActiveGroup->_cells = f178_getGroupValueUpdatedWithCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex, AL0446_i_Cell);
-									}
-								}
-							}
-							L0465_s_NextEvent._mapTime += MAX(1, (L0448_s_CreatureInfo._movementTicks >> 1) + _vm->getRandomNumber(2)); /* Time for the creature to change cell */
-							L0465_s_NextEvent._type = eventType;
-							goto T0209135;
-						}
-						L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, f207_isCreatureAttacking(L0444_ps_Group, eventMapX, eventMapY, AL0447_i_CreatureIndex));
-						L0465_s_NextEvent._mapTime += (L0448_s_CreatureInfo._animationTicks & 0xF) + _vm->getRandomNumber(2);
-					} else {
-						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
-						if (L0460_ui_CreatureCount) {
-							f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
-						}
-						goto T0209081_RunTowardParty;
-					}
-				} else {
-					/* If the party is visible, update target coordinates */
-					if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
-						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
-						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
-						f205_setDirection(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
-						L0465_s_NextEvent._mapTime += 2;
-						L0464_l_NextAspectUpdateTime = M30_time(L0465_s_NextEvent._mapTime);
-					} else { /* If the party is not visible, move to the target (last known party location) */
-						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
-						if (L0460_ui_CreatureCount) {
-							f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
-						}
-						goto T0209082_WalkTowardTarget;
-					}
-				}
-			}
-			L0465_s_NextEvent._type = eventType;
-			goto T0209136;
-		}
-		L0465_s_NextEvent._mapTime += MAX(1, _vm->getRandomNumber(4) + L0461_i_MovementTicks - 1);
-T0209134_SetEvent37:
-		L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup;
-	}
-T0209135:
-	if (!L0464_l_NextAspectUpdateTime) {
-		L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, kM1_wholeCreatureGroup, false);
-	}
-T0209136:
-	if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) {
-		L0465_s_NextEvent._mapTime += ticks;
-	} else {
-		L0464_l_NextAspectUpdateTime += ticks;
-	}
-	f208_groupAddEvent(&L0465_s_NextEvent, L0464_l_NextAspectUpdateTime);
-T0209139_Return:
-	;
-}
-
-bool GroupMan::f202_isMovementPossible(CreatureInfo* creatureInfo, int16 mapX, int16 mapY, uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls) {
-	int16 L0428_i_MapX;
-	int16 L0429_i_MapY;
-	uint16 L0430_ui_Square = 0;
-	int16 L0431_i_SquareType = 0;
-	Teleporter* L0432_ps_Teleporter;
-	Thing L0433_T_Thing;
-
-
-	_g384_groupMovementTestedDirections[dir] = true;
-	_g388_groupMovementBlockedByGroupThing = Thing::_endOfList;
-	_g389_groupMovementBlockedByDoor = false;
-	_g390_groupMovementBlockedByParty = false;
-	if (creatureInfo->_movementTicks == k255_immobile) {
-		return false;
-	}
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement((direction)dir, 1, 0, mapX, mapY);
-	L0428_i_MapX = mapX;
-	L0429_i_MapY = mapY;
-	if (_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter =
-		!(((L0428_i_MapX >= 0) && (L0428_i_MapX < _vm->_dungeonMan->_g273_currMapWidth)) &&
-		((L0429_i_MapY >= 0) && (L0429_i_MapY < _vm->_dungeonMan->_g274_currMapHeight)) &&
-		  ((L0431_i_SquareType = Square(L0430_ui_Square = _vm->_dungeonMan->_g271_currMapData[L0428_i_MapX][L0429_i_MapY]).getType()) != k0_ElementTypeWall) &&
-		  (L0431_i_SquareType != k3_ElementTypeStairs) &&
-		  ((L0431_i_SquareType != k2_ElementTypePit) || (getFlag(L0430_ui_Square, k0x0001_PitImaginary) && allowMovementOverImaginaryPitsAndFakeWalls) || !getFlag(L0430_ui_Square, k0x0008_PitOpen) || getFlag(creatureInfo->_attributes, k0x0020_MaskCreatureInfo_levitation)) &&
-		  ((L0431_i_SquareType != k6_ElementTypeFakeWall) || getFlag(L0430_ui_Square, k0x0004_FakeWallOpen) || (getFlag(L0430_ui_Square, k0x0001_FakeWallImaginary) && allowMovementOverImaginaryPitsAndFakeWalls)))) {
-		return false;
-	}
-	if (getFlag(creatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) {
-		L0433_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0428_i_MapX, L0429_i_MapY);
-		while (L0433_T_Thing != Thing::_endOfList) {
-			if ((L0433_T_Thing).getType() == k15_ExplosionThingType) {
-				L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(L0433_T_Thing);
-				if (((Explosion*)L0432_ps_Teleporter)->setType(k50_ExplosionType_Fluxcage)) {
-					_g385_fluxCages[dir] = true;
-					_g386_fluxCageCount++;
-					_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
-					return false;
-				}
-			}
-			L0433_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0433_T_Thing);
-		}
-	}
-	if ((L0431_i_SquareType == k5_ElementTypeTeleporter) && getFlag(L0430_ui_Square, k0x0008_TeleporterOpen) && (creatureInfo->M59_getWariness() >= 10)) {
-		L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
-		if (getFlag(L0432_ps_Teleporter->getScope(), k0x0001_TelepScopeCreatures) && !_vm->_dungeonMan->f139_isCreatureAllowedOnMap(_g380_currGroupThing, L0432_ps_Teleporter->getTargetMapIndex())) {
-			_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
-			return false;
-		}
-	}
-	if (_g390_groupMovementBlockedByParty = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0428_i_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0429_i_MapY == _vm->_dungeonMan->_g307_partyMapY)) {
-		return false;
-	}
-	if (L0431_i_SquareType == k4_DoorElemType) {
-		L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
-		if (((Square(L0430_ui_Square).getDoorState()) > (((Door*)L0432_ps_Teleporter)->opensVertically() ? creatureInfo->M51_height() : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
-			_g389_groupMovementBlockedByDoor = true;
-			return false;
-		}
-	}
-	return (_g388_groupMovementBlockedByGroupThing = _vm->_groupMan->f175_groupGetThing(L0428_i_MapX, L0429_i_MapY)) == Thing::_endOfList;
-}
-
-int16 GroupMan::f226_getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
-	return ((((srcMapX -= destMapX) < 0) ? -srcMapX : srcMapX) +
-		(((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY));
-}
-
-int16 GroupMan::f200_groupGetDistanceToVisibleParty(Group* group, int16 creatureIndex, int16 mapX, int16 mapY) {
-	int16 L0420_i_CreatureDirection;
-	int16 L0421_i_CreatureViewDirectionCount; /* Count of directions to test in L0425_ai_CreatureViewDirections */
-	int16 L0422_i_Multiple;
-#define AL0422_i_Counter    L0422_i_Multiple
-#define AL0422_i_SightRange L0422_i_Multiple
-	uint16 L0423_ui_GroupDirections;
-	CreatureInfo* L0424_ps_CreatureInfo;
-	int16 L0425_ai_CreatureViewDirections[4]; /* List of directions to test */
-
-
-	L0424_ps_CreatureInfo = &g243_CreatureInfo[group->_type];
-	if (_vm->_championMan->_g407_party._event71Count_Invisibility && !getFlag(L0424_ps_CreatureInfo->_attributes, k0x0800_MaskCreatureInfo_seeInvisible)) {
-		return 0;
-	}
-	if (getFlag(L0424_ps_CreatureInfo->_attributes, k0x0004_MaskCreatureInfo_sideAttack)) /* If creature can see in all directions */
-		goto T0200011;
-	L0423_ui_GroupDirections = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions;
-	if (creatureIndex < 0) { /* Negative index means test if each creature in the group can see the party in their respective direction */
-		L0421_i_CreatureViewDirectionCount = 0;
-		for (creatureIndex = group->getCount(); creatureIndex >= 0; creatureIndex--) {
-			L0420_i_CreatureDirection = M21_normalizeModulo4(L0423_ui_GroupDirections >> (creatureIndex << 1));
-			AL0422_i_Counter = L0421_i_CreatureViewDirectionCount;
-			while (AL0422_i_Counter--) {
-				if (L0425_ai_CreatureViewDirections[AL0422_i_Counter] == L0420_i_CreatureDirection) /* If the creature looks in the same direction as another one in the group */
-					goto T0200006;
-			}
-			L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount++] = L0420_i_CreatureDirection;
-T0200006:
-			;
-		}
-	} else { /* Positive index means test only if the specified creature in the group can see the party in its direction */
-		L0425_ai_CreatureViewDirections[0] = _vm->_groupMan->M50_getCreatureValue(L0423_ui_GroupDirections, creatureIndex);
-		L0421_i_CreatureViewDirectionCount = 1;
-	}
-	while (L0421_i_CreatureViewDirectionCount--) {
-		if (f227_isDestVisibleFromSource(L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount], mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY)) {
-T0200011:
-			AL0422_i_SightRange = L0424_ps_CreatureInfo->M54_getSightRange();
-			if (!getFlag(L0424_ps_CreatureInfo->_attributes, k0x1000_MaskCreatureInfo_nightVision)) {
-				AL0422_i_SightRange -= _vm->_displayMan->_g304_dungeonViewPaletteIndex >> 1;
-			}
-			if (_g381_currGroupDistanceToParty > MAX((int16)1, AL0422_i_SightRange)) {
-				return 0;
-			}
-			return f199_getDistanceBetweenUnblockedSquares(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f197_isViewPartyBlocked);
-		}
-	}
-	return 0;
-}
-
-int16 GroupMan::f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 srcMapY,
-														int16 destMapX, int16 destMapY, bool (GroupMan::*isBlocked)(uint16, uint16)) {
-	int16 L0410_i_XAxisStep;
-	int16 L0411_i_YAxisStep;
-	int16 L0412_i_Multiple;
-#define AL0412_i_DistanceX L0412_i_Multiple
-#define AL0412_i_PathMapX  L0412_i_Multiple
-	int16 L0413_i_Multiple;
-#define AL0413_i_DistanceY L0413_i_Multiple
-#define AL0413_i_PathMapY  L0413_i_Multiple
-	int16 L0414_i_LargestAxisDistance;
-	bool L0415_B_DistanceXSmallerThanDistanceY;
-	int16 L0416_i_ValueA;
-	int16 L0417_i_ValueB;
-	bool L0418_B_DistanceXEqualsDistanceY;
-	int16 L0419_i_ValueC;
-
-
-	if (M38_distance(srcMapX, srcMapY, destMapX, destMapY) <= 1) {
-		return 1;
-	}
-	L0415_B_DistanceXSmallerThanDistanceY = (AL0412_i_DistanceX = ((AL0412_i_DistanceX = destMapX - srcMapX) < 0) ? -AL0412_i_DistanceX : AL0412_i_DistanceX) < (AL0413_i_DistanceY = ((AL0413_i_DistanceY = destMapY - srcMapY) < 0) ? -AL0413_i_DistanceY : AL0413_i_DistanceY);
-	L0418_B_DistanceXEqualsDistanceY = (AL0412_i_DistanceX == AL0413_i_DistanceY);
-	L0410_i_XAxisStep = (((AL0412_i_PathMapX = destMapX) - srcMapX) > 0) ? -1 : 1;
-	L0411_i_YAxisStep = (((AL0413_i_PathMapY = destMapY) - srcMapY) > 0) ? -1 : 1;
-	L0419_i_ValueC = L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY - srcMapY) ? ((AL0412_i_PathMapX - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128)
-		: ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX - srcMapX) ? ((AL0413_i_PathMapY - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128);
-	/* 128 when the creature is on the same row or column as the party */
-	do {
-		if (L0418_B_DistanceXEqualsDistanceY) {
-			if (((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY) && (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX, AL0413_i_PathMapY + L0411_i_YAxisStep)) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX = AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY = AL0413_i_PathMapY + L0411_i_YAxisStep)) {
-				return 0;
-			}
-		} else {
-			if ((L0416_i_ValueA = ((L0414_i_LargestAxisDistance = (L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY - srcMapY) ? ((AL0412_i_PathMapX + L0410_i_XAxisStep - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX + L0410_i_XAxisStep - srcMapX) ? ((AL0413_i_PathMapY - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128)) - L0419_i_ValueC) < 0) ? -L0414_i_LargestAxisDistance : L0414_i_LargestAxisDistance) < (L0417_i_ValueB = ((L0414_i_LargestAxisDistance = (L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY + L0411_i_YAxisStep - srcMapY) ? ((AL0412_i_PathMapX - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX - srcMapX) ? ((AL0413_i_PathMapY + L0411_i_YAxisStep - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128)) - L0419_i_ValueC) < 0) ? -L0414_i_LargestAxisDistance : L0414_i_LargestAxisDistance)) {
-				AL0412_i_PathMapX += L0410_i_XAxisStep;
-			} else {
-				AL0413_i_PathMapY += L0411_i_YAxisStep;
-			}
-			if ((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX, AL0413_i_PathMapY) && ((L0416_i_ValueA != L0417_i_ValueB) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX = AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY = AL0413_i_PathMapY - L0411_i_YAxisStep))) {
-				return 0;
-			}
-		}
-	} while (M38_distance(AL0412_i_PathMapX, AL0413_i_PathMapY, srcMapX, srcMapY) > 1);
-	return f226_getDistanceBetweenSquares(srcMapX, srcMapY, destMapX, destMapY);
-}
-
-bool GroupMan::f197_isViewPartyBlocked(uint16 mapX, uint16 mapY) {
-	uint16 L0404_ui_Square;
-	int16 L0405_i_SquareType;
-	int16 L0406_i_DoorState;
-	Door* L0407_ps_Door;
-
-	if ((L0405_i_SquareType = Square(L0404_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k4_DoorElemType) {
-		L0407_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY);
-		return (((L0406_i_DoorState = Square(L0404_ui_Square).getDoorState()) == k3_doorState_FOURTH) || (L0406_i_DoorState == k4_doorState_CLOSED)) && !getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[L0407_ps_Door->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough);
-	}
-	return (L0405_i_SquareType == k0_ElementTypeWall) || ((L0405_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0404_ui_Square, k0x0004_FakeWallOpen));
-}
-
-int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup* activeGroup, int16 creatureIndex, bool isAttacking) {
-	uint16 L0326_ui_Multiple;
-#define AL0326_ui_Aspect         L0326_ui_Multiple
-#define AL0326_ui_AnimationTicks L0326_ui_Multiple
-	uint16 L0327_ui_CreatureGraphicInfo;
-	int16 L0328_i_Offset;
-	Group* L0329_ps_Group;
-	bool L0330_B_ProcessGroup;
-	uint16 L0331_ui_CreatureType;
-	uint16 L1635_ui_SoundIndex;
-
-	L0329_ps_Group = &(((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]);
-	L0327_ui_CreatureGraphicInfo = g243_CreatureInfo[L0331_ui_CreatureType = L0329_ps_Group->_type]._graphicInfo;
-	if (L0330_B_ProcessGroup = (creatureIndex < 0)) { /* If the creature index is negative then all creatures in the group are processed */
-		creatureIndex = L0329_ps_Group->getCount();
-	}
-	do {
-		AL0326_ui_Aspect = activeGroup->_aspect[creatureIndex];
-		AL0326_ui_Aspect &= k0x0080_MaskActiveGroupIsAttacking | k0x0040_MaskActiveGroupFlipBitmap;
-		if (L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 12) & 0x3)) {
-			L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset);
-			if (_vm->getRandomNumber(2)) {
-				L0328_i_Offset = (-L0328_i_Offset) & 0x0007;
-			}
-			AL0326_ui_Aspect |= L0328_i_Offset;
-		}
-		if (L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 14) & 0x3)) {
-			L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset);
-			if (_vm->getRandomNumber(2)) {
-				L0328_i_Offset = (-L0328_i_Offset) & 0x0007;
-			}
-			AL0326_ui_Aspect |= (L0328_i_Offset << 3);
-		}
-		if (isAttacking) {
-			if (getFlag(L0327_ui_CreatureGraphicInfo, k0x0200_CreatureInfoGraphicMaskFlipAttack)) {
-				if (getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) && (L0331_ui_CreatureType == k18_CreatureTypeAnimatedArmourDethKnight)) {
-					if (_vm->getRandomNumber(2)) {
-						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-						warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
-					}
-				} else {
-					if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) {
-						if (_vm->getRandomNumber(2)) {
-							setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-						} else {
-							clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-						}
-					}
-				}
-			} else {
-				clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-			}
-			setFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking);
-		} else {
-			if (getFlag(L0327_ui_CreatureGraphicInfo, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) {
-				if (L0331_ui_CreatureType == k13_CreatureTypeCouatl) {
-					if (_vm->getRandomNumber(2)) {
-						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-						L1635_ui_SoundIndex = _vm->_movsens->f514_getSound(k13_CreatureTypeCouatl);
-						if (L1635_ui_SoundIndex <= k34_D13_soundCount) {
-							warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
-						}
-					}
-				} else {
-					if (_vm->getRandomNumber(2)) {
-						setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-					} else {
-						clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-					}
-				}
-			} else {
-				clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-			}
-			clearFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking);
-		}
-		activeGroup->_aspect[creatureIndex] = AL0326_ui_Aspect;
-	} while (L0330_B_ProcessGroup && (creatureIndex--));
-	AL0326_ui_AnimationTicks = g243_CreatureInfo[L0329_ps_Group->_type]._animationTicks;
-	return _vm->_g313_gameTime + (isAttacking ? ((AL0326_ui_AnimationTicks >> 8) & 0xF) : ((AL0326_ui_AnimationTicks >> 4) & 0xF)) + _vm->getRandomNumber(2);
-}
-
-void GroupMan::f205_setDirection(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) {
-	uint16 L0435_ui_GroupDirections;
-	static long G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime; /* These two variables are used to prevent setting direction of half square sized creatures twice at the same game time */
-	static ActiveGroup* G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup;
-
-
-	warning("potentially dangerous cast to uint32 below");
-	if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == (uint32)G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) {
-		return;
-	}
-	if (M21_normalizeModulo4(_vm->_groupMan->M50_getCreatureValue(L0435_ui_GroupDirections = activeGroup->_directions, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */
-		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + dir));
-	} else {
-		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir);
-	}
-	if (twoHalfSquareSizedCreatures) {
-		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex ^ 1, dir); /* Set direction of the second half square sized creature */
-		G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime = _vm->_g313_gameTime;
-		G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup = activeGroup;
-	}
-	activeGroup->_directions = (direction)L0435_ui_GroupDirections;
-}
-
-void GroupMan::f208_groupAddEvent(TimelineEvent* event, uint32 time) {
-	warning("potentially dangerous cast to uint32 below");
-	if (time < (uint32)M30_time(event->_mapTime)) {
-		event->_type -= 5;
-		event->_C._ticks = M30_time(event->_mapTime) - time;
-		M32_setTime(event->_mapTime, time);
-	} else {
-		event->_C._ticks = time - M30_time(event->_mapTime);
-	}
-	_vm->_timeline->f238_addEventGetEventIndex(event);
-}
-
-int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo* creatureInfo, int16 mapY, int16 mapX) {
-
-	uint16 L0426_ui_SmellRange;
-	int16 L0427_i_ScentOrdinal;
-
-
-	if (!(L0426_ui_SmellRange = creatureInfo->M55_getSmellRange())) {
-		return 0;
-	}
-	if ((((L0426_ui_SmellRange + 1) >> 1) >= _g381_currGroupDistanceToParty) && f199_getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f198_isSmellPartyBlocked)) {
-		_vm->_projexpl->_g363_secondaryDirToOrFromParty = _g383_currGroupSecondaryDirToParty;
-		return _vm->M0_indexToOrdinal(_g382_currGroupPrimaryDirToParty);
-	}
-	if ((L0427_i_ScentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapY, mapX)) && ((_vm->_championMan->_g407_party._scentStrengths[_vm->M1_ordinalToIndex(L0427_i_ScentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (L0426_ui_SmellRange << 1)))) { /* If there is a fresh enough party scent on the group square */
-		return _vm->M0_indexToOrdinal(f228_getDirsWhereDestIsVisibleFromSource(mapY, mapX, _vm->_championMan->_g407_party._scents[L0427_i_ScentOrdinal].getMapX(), _vm->_championMan->_g407_party._scents[L0427_i_ScentOrdinal].getMapY()));
-	}
-	return 0;
-}
-
-bool GroupMan::f198_isSmellPartyBlocked(uint16 mapX, uint16 mapY) {
-	uint16 L0408_ui_Square;
-	int16 L0409_i_SquareType;
-
-	return ((L0409_i_SquareType = Square(L0408_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k0_ElementTypeWall) || ((L0409_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0408_ui_Square, k0x0004_FakeWallOpen));
-}
-
-int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo* info, int16 mapX, int16 mapY, bool allowMovementOverImaginaryPitsAndFakeWalls) {
-	int16 L0434_i_Direction;
-
-
-	for (L0434_i_Direction = kDirNorth; L0434_i_Direction <= kDirWest; L0434_i_Direction++) {
-		if ((!_g384_groupMovementTestedDirections[L0434_i_Direction]) && f202_isMovementPossible(info, mapX, mapY, L0434_i_Direction, allowMovementOverImaginaryPitsAndFakeWalls)) {
-			return _vm->M0_indexToOrdinal(L0434_i_Direction);
-		}
-	}
-	return 0;
-}
-
-void GroupMan::f206_groupSetDirGroup(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, int16 creatureSize) {
-	bool L0436_B_TwoHalfSquareSizedCreatures;
-
-
-	if (L0436_B_TwoHalfSquareSizedCreatures = creatureIndex && (creatureSize == k1_MaskCreatureSizeHalf)) {
-		creatureIndex--;
-	}
-	do {
-		if (!creatureIndex || _vm->getRandomNumber(2)) {
-			f205_setDirection(activeGroup, dir, creatureIndex, L0436_B_TwoHalfSquareSizedCreatures);
-		}
-	} while (creatureIndex--);
-}
-
-void GroupMan::f182_stopAttacking(ActiveGroup* group, int16 mapX, int16 mapY) {
-	int16 L0337_i_CreatureIndex;
-
-	for (L0337_i_CreatureIndex = 0; L0337_i_CreatureIndex < 4; clearFlag(group->_aspect[L0337_i_CreatureIndex++], k0x0080_MaskActiveGroupIsAttacking));
-	f181_groupDeleteEvents(mapX, mapY);
-
-}
-
-bool GroupMan::f204_isArchenemyDoubleMovementPossible(CreatureInfo* info, int16 mapX, int16 mapY, uint16 dir) {
-	if (_g385_fluxCages[dir]) {
-		return false;
-	}
-	mapX += _vm->_dirIntoStepCountEast[dir], mapY += _vm->_dirIntoStepCountNorth[dir];
-	return f202_isMovementPossible(info, mapX, mapY, dir, false);
-}
-
-bool GroupMan::f207_isCreatureAttacking(Group* group, int16 mapX, int16 mapY, uint16 creatureIndex) {
-	uint16 L0437_ui_Multiple;
-#define AL0437_ui_CreatureType L0437_ui_Multiple
-#define AL0437_T_Thing         L0437_ui_Multiple
-	uint16 L0438_ui_PrimaryDirectionToParty;
-	int16 L0439_i_Multiple;
-#define AL0439_i_GroupCells    L0439_i_Multiple
-#define AL0439_i_TargetCell    L0439_i_Multiple
-#define AL0439_i_ChampionIndex L0439_i_Multiple
-	int16 L0440_i_Multiple;
-#define AL0440_i_KineticEnergy      L0440_i_Multiple
-#define AL0440_i_Counter            L0440_i_Multiple
-#define AL0440_i_Damage             L0440_i_Multiple
-#define AL0440_i_AttackSoundOrdinal L0440_i_Multiple
-	CreatureInfo* L0441_ps_CreatureInfo;
-	Champion* L0442_ps_Champion;
-	ActiveGroup L0443_s_ActiveGroup;
-
-
-	_vm->_projexpl->_g361_lastCreatureAttackTime = _vm->_g313_gameTime;
-	L0443_s_ActiveGroup = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
-	L0441_ps_CreatureInfo = &g243_CreatureInfo[AL0437_ui_CreatureType = group->_type];
-	L0438_ui_PrimaryDirectionToParty = _g382_currGroupPrimaryDirToParty;
-	if ((AL0439_i_GroupCells = L0443_s_ActiveGroup._cells) == k255_CreatureTypeSingleCenteredCreature) {
-		AL0439_i_TargetCell = _vm->getRandomNumber(2);
-	} else {
-		AL0439_i_TargetCell = ((_vm->_groupMan->M50_getCreatureValue(AL0439_i_GroupCells, creatureIndex) + 5 - L0438_ui_PrimaryDirectionToParty) & 0x0002) >> 1;
-	}
-	AL0439_i_TargetCell += L0438_ui_PrimaryDirectionToParty;
-	AL0439_i_TargetCell &= 0x0003;
-	if ((L0441_ps_CreatureInfo->M56_getAttackRange() > 1) && ((_g381_currGroupDistanceToParty > 1) || _vm->getRandomNumber(2))) {
-		switch (AL0437_ui_CreatureType) {
-		case k14_CreatureTypeVexirk:
-		case k23_CreatureTypeLordChaos:
-			if (_vm->getRandomNumber(2)) {
-				AL0437_T_Thing = Thing::_explFireBall.toUint16();
-			} else {
-				switch (_vm->getRandomNumber(4)) {
-				case 0:
-					AL0437_T_Thing = Thing::_explHarmNonMaterial.toUint16();
-					break;
-				case 1:
-					AL0437_T_Thing = Thing::_explLightningBolt.toUint16();
-					break;
-				case 2:
-					AL0437_T_Thing = Thing::_explPoisonCloud.toUint16();
-					break;
-				case 3:
-					AL0437_T_Thing = Thing::_explOpenDoor.toUint16();
-				}
-			}
-			break;
-		case k1_CreatureTypeSwampSlimeSlime:
-			AL0437_T_Thing = Thing::_explSlime.toUint16();
-			break;
-		case k3_CreatureTypeWizardEyeFlyingEye:
-			if (_vm->getRandomNumber(8)) {
-				AL0437_T_Thing = Thing::_explLightningBolt.toUint16();
-			} else {
-				AL0437_T_Thing = Thing::_explOpenDoor.toUint16();
-			}
-			break;
-		case k19_CreatureTypeMaterializerZytaz:
-			if (_vm->getRandomNumber(2)) {
-				AL0437_T_Thing = Thing::_explPoisonCloud.toUint16();
-				break;
-			}
-		case k22_CreatureTypeDemon:
-		case k24_CreatureTypeRedDragon:
-			AL0437_T_Thing = Thing::_explFireBall.toUint16();
-		} /* BUG0_13 The game may crash when 'Lord Order' or 'Grey Lord' cast spells. This cannot happen with the original dungeons as they do not contain any groups of these types. 'Lord Order' and 'Grey Lord' creatures can cast spells (attack range > 1) but no projectile type is defined for them in the code. If these creatures are present in a dungeon they will cast projectiles containing undefined things because the variable is not initialized */
-		AL0440_i_KineticEnergy = (L0441_ps_CreatureInfo->_attack >> 2) + 1;
-		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
-		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
-		warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
-		_vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
-	} else {
-		if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) {
-			AL0439_i_ChampionIndex = _vm->getRandomNumber(4);
-			for (AL0440_i_Counter = 0; (AL0440_i_Counter < 4) && !_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex]._currHealth; AL0440_i_Counter++) {
-				AL0439_i_ChampionIndex = returnNextVal(AL0439_i_ChampionIndex);
-			}
-			if (AL0440_i_Counter == 4) {
-				return false;
-			}
-		} else {
-			if ((AL0439_i_ChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(mapX, mapY, AL0439_i_TargetCell)) < 0) {
-				return false;
-			}
-		}
-		if (AL0437_ui_CreatureType == k2_CreatureTypeGiggler) {
-			f193_stealFromChampion(group, AL0439_i_ChampionIndex);
-		} else {
-			AL0440_i_Damage = f230_getChampionDamage(group, AL0439_i_ChampionIndex) + 1;
-			L0442_ps_Champion = &_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex];
-			if (AL0440_i_Damage > L0442_ps_Champion->_maximumDamageReceived) {
-				L0442_ps_Champion->_maximumDamageReceived = AL0440_i_Damage;
-				L0442_ps_Champion->_directionMaximumDamageReceived = returnOppositeDir((direction)L0438_ui_PrimaryDirectionToParty);
-			}
-		}
-	}
-	if (AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal) {
-		warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
-	}
-	return true;
-}
-
-void GroupMan::f229_setOrderedCellsToAttack(signed char* orderedCellsToAttack, int16 targetMapX, int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource) {
-	static signed char g23_orderedCellsToAttack[8][4] = { // @ G0023_aac_Graphic562_OrderedCellsToAttack
-		{0, 1, 3, 2},   /* Attack South from position Northwest or Southwest */
-		{1, 0, 2, 3},   /* Attack South from position Northeast or Southeast */
-		{1, 2, 0, 3},   /* Attack West from position Northwest or Northeast */
-		{2, 1, 3, 0},   /* Attack West from position Southeast or Southwest */
-		{3, 2, 0, 1},   /* Attack North from position Northwest or Southwest */
-		{2, 3, 1, 0},   /* Attack North from position Southeast or Northeast */
-		{0, 3, 1, 2},   /* Attack East from position Northwest or Northeast */
-		{3, 0, 2, 1}}; /* Attack East from position Southeast or Southwest */
-	uint16 L0557_ui_OrderedCellsToAttackIndex;
-
-
-	if (!((L0557_ui_OrderedCellsToAttackIndex = f228_getDirsWhereDestIsVisibleFromSource(targetMapX, targetMapY, attackerMapX, attackerMapY) << 1) & 0x0002)) {
-		cellSource++;
-	}
-	L0557_ui_OrderedCellsToAttackIndex += (cellSource >> 1) & 0x0001;
-	for (uint16 i = 0; i < 4; ++i)
-		orderedCellsToAttack[i] = g23_orderedCellsToAttack[L0557_ui_OrderedCellsToAttackIndex][i];
-}
-
-void GroupMan::f193_stealFromChampion(Group* group, uint16 championIndex) {
-	int16 L0391_i_Percentage;
-	uint16 L0392_ui_StealFromSlotIndex;
-	uint16 L0393_ui_Counter;
-	Thing L0394_T_Thing;
-	Champion* L0395_ps_Champion;
-	bool L0396_B_ObjectStolen;
-	static unsigned char G0394_auc_StealFromSlotIndices[8]; /* Initialized with 0 bytes by C loader */
-
-
-	L0396_B_ObjectStolen = false;
-	L0391_i_Percentage = 100 - _vm->_championMan->f311_getDexterity(L0395_ps_Champion = &_vm->_championMan->_gK71_champions[championIndex]);
-	L0393_ui_Counter = _vm->getRandomNumber(8);
-	while ((L0391_i_Percentage > 0) && !_vm->_championMan->f308_isLucky(L0395_ps_Champion, L0391_i_Percentage)) {
-		if ((L0392_ui_StealFromSlotIndex = G0394_auc_StealFromSlotIndices[L0393_ui_Counter]) == k13_ChampionSlotBackpackLine_1_1) {
-			L0392_ui_StealFromSlotIndex += _vm->getRandomNumber(17); /* Select a random slot in the backpack */
-		}
-		if (((L0394_T_Thing = L0395_ps_Champion->_slots[L0392_ui_StealFromSlotIndex]) != Thing::_none)) {
-			L0396_B_ObjectStolen = true;
-			L0394_T_Thing = _vm->_championMan->f300_getObjectRemovedFromSlot(championIndex, L0392_ui_StealFromSlotIndex);
-			if (group->_slot == Thing::_endOfList) {
-				group->_slot = L0394_T_Thing; /* BUG0_12 An object is cloned and appears at two different locations in the dungeon and/or inventory. The game may crash when interacting with this object. If a Giggler with no possessions steals an object that was previously in a chest and was not the last object in the chest then the objects that followed it are cloned. In the chest, the object is part of a linked list of objects that is not reset when the object is removed from the chest and placed in the inventory (but not in the dungeon), nor when it is stolen and added as the first Giggler possession. If the Giggler already has a possession before stealing the object then this does not create a cloned object.
-											 The following statement is missing: L0394_T_Thing->Next = Thing::_endOfList;
-											 This creates cloned things if L0394_T_Thing->Next is not Thing::_endOfList which is the case when the object comes from a chest in which it was not the last object */
-			} else {
-				_vm->_dungeonMan->f163_linkThingToList(L0394_T_Thing, group->_slot, kM1_MapXNotOnASquare, 0);
-			}
-			_vm->_championMan->f292_drawChampionState((ChampionIndex)championIndex);
-		}
-		++L0393_ui_Counter;
-		L0393_ui_Counter &= 0x0007;
-		L0391_i_Percentage -= 20;
-	}
-	if (!_vm->getRandomNumber(8) || (L0396_B_ObjectStolen && _vm->getRandomNumber(2))) {
-		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._delayFleeingFromTarget = _vm->getRandomNumber(64) + 20;
-		group->setBehaviour(k5_behavior_FLEE);
-	}
-}
-
-int16 GroupMan::f230_getChampionDamage(Group* group, uint16 champIndex) {
-	unsigned char g24_woundProbabilityIndexToWoundMask[4] = {32, 16, 8, 4}; // @ G0024_auc_Graphic562_WoundProbabilityIndexToWoundMask
-
-	Champion* L0562_ps_Champion;
-	int16 L0558_i_Multiple;
-#define AL0558_i_Attack L0558_i_Multiple
-#define AL0558_i_Damage L0558_i_Multiple
-	uint16 L0559_ui_Multiple;
-#define AL0559_ui_WoundTest          L0559_ui_Multiple
-#define AL0559_ui_PoisonAttack       L0559_ui_Multiple
-#define AL0559_ui_CreatureDifficulty L0559_ui_Multiple
-	uint16 L0560_ui_WoundProbabilities;
-	uint16 L0561_ui_Multiple;
-#define AL0561_ui_WoundProbabilityIndex L0561_ui_Multiple
-#define AL0561_ui_AllowedWound          L0561_ui_Multiple
-	int16 L0563_i_DoubledMapDifficulty;
-	CreatureInfo L0564_s_CreatureInfo;
-
-
-	L0562_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
-	if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
-		return 0;
-	}
-	if (!L0562_ps_Champion->_currHealth) {
-		return 0;
-	}
-	if (_vm->_championMan->_g300_partyIsSleeping) {
-		_vm->_championMan->f314_wakeUp();
-	}
-	L0563_i_DoubledMapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty << 1;
-	L0564_s_CreatureInfo = g243_CreatureInfo[group->_type];
-	_vm->_championMan->f304_addSkillExperience(champIndex, k7_ChampionSkillParry, L0564_s_CreatureInfo.M58_getExperience());
-	if (_vm->_championMan->_g300_partyIsSleeping || (((_vm->_championMan->f311_getDexterity(L0562_ps_Champion) < (_vm->getRandomNumber(32) + L0564_s_CreatureInfo._dexterity + L0563_i_DoubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !_vm->_championMan->f308_isLucky(L0562_ps_Champion, 60))) {
-		if ((AL0559_ui_WoundTest = _vm->getRandomNumber(65536)) & 0x0070) {
-			AL0559_ui_WoundTest &= 0x000F;
-			L0560_ui_WoundProbabilities = L0564_s_CreatureInfo._woundProbabilities;
-			for (AL0561_ui_WoundProbabilityIndex = 0; AL0559_ui_WoundTest > (L0560_ui_WoundProbabilities & 0x000F); L0560_ui_WoundProbabilities >>= 4) {
-				AL0561_ui_WoundProbabilityIndex++;
-			}
-			AL0561_ui_AllowedWound = g24_woundProbabilityIndexToWoundMask[AL0561_ui_WoundProbabilityIndex];
-		} else {
-			AL0561_ui_AllowedWound = AL0559_ui_WoundTest & 0x0001; /* 0 (Ready hand) or 1 (action hand) */
-		}
-		if ((AL0558_i_Attack = (_vm->getRandomNumber(16) + L0564_s_CreatureInfo._attack + L0563_i_DoubledMapDifficulty) - (_vm->_championMan->f303_getSkillLevel(champIndex, k7_ChampionSkillParry) << 1)) <= 1) {
-			if (_vm->getRandomNumber(2)) {
-				goto T0230014;
-			}
-			AL0558_i_Attack = _vm->getRandomNumber(4) + 2;
-		}
-		AL0558_i_Attack >>= 1;
-		AL0558_i_Attack += _vm->getRandomNumber(AL0558_i_Attack) + _vm->getRandomNumber(4);
-		AL0558_i_Attack += _vm->getRandomNumber(AL0558_i_Attack);
-		AL0558_i_Attack >>= 2;
-		AL0558_i_Attack += _vm->getRandomNumber(4) + 1;
-		if (_vm->getRandomNumber(2)) {
-			AL0558_i_Attack -= _vm->getRandomNumber((AL0558_i_Attack >> 1) + 1) - 1;
-		}
-		if (AL0558_i_Damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType)) {
-			warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
-			if ((AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack) && _vm->getRandomNumber(2) && ((AL0559_ui_PoisonAttack = _vm->_championMan->f307_getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack)) >= 0)) {
-				_vm->_championMan->f322_championPoison(champIndex, AL0559_ui_PoisonAttack);
-			}
-			return AL0558_i_Damage;
-		}
-	}
-T0230014:
-	return 0;
-}
-
-void GroupMan::f187_dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY) {
-	Group* L0363_ps_Group;
-	int16 L0364_i_CreatureType;
-
-
-	if (_g391_dropMovingCreatureFixedPossCellCount) {
-		L0363_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing);
-		L0364_i_CreatureType = L0363_ps_Group->_type;
-		while (_g391_dropMovingCreatureFixedPossCellCount) {
-			f186_dropCreatureFixedPossessions(L0364_i_CreatureType, mapX, mapY, _g392_dropMovingCreatureFixedPossessionsCell[--_g391_dropMovingCreatureFixedPossCellCount], k2_soundModePlayOneTickLater);
-		}
-	}
-}
-
-void GroupMan::f180_startWanedring(int16 mapX, int16 mapY) {
-	Group* L0332_ps_Group;
-	TimelineEvent L0333_s_Event;
-
-
-	L0332_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(mapX, mapY));
-	if (L0332_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
-		L0332_ps_Group->setBehaviour(k0_behavior_WANDER);
-	}
-	M33_setMapAndTime(L0333_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, (_vm->_g313_gameTime + 1));
-	L0333_s_Event._type = k37_TMEventTypeUpdateBehaviourGroup;
-	L0333_s_Event._priority = 255 - g243_CreatureInfo[L0332_ps_Group->_type]._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
-	L0333_s_Event._C._ticks = 0;
-	L0333_s_Event._B._location._mapX = mapX;
-	L0333_s_Event._B._location._mapY = mapY;
-	_vm->_timeline->f238_addEventGetEventIndex(&L0333_s_Event);
-}
-
-void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
-	uint16 L0339_ui_CreatureIndex;
-	Group* L0340_ps_Group;
-	ActiveGroup* L0341_ps_ActiveGroup;
-	int16 L0344_i_ActiveGroupIndex;
-
-
-	L0341_ps_ActiveGroup = _vm->_groupMan->_g375_activeGroups;
-	L0344_i_ActiveGroupIndex = 0;
-	while (L0341_ps_ActiveGroup->_groupThingIndex >= 0) {
-		if (++L0344_i_ActiveGroupIndex >= _vm->_groupMan->_g376_maxActiveGroupCount) {
-			return; /* BUG0_11 Data corruption in memory. Each group located on the same map as the party has additional associated data but there is only provision for 60 instances (_vm->_groupMan->_g376_maxActiveGroupCount). If there are more groups at the same time then some of them do not get their instance and when the game accesses this information it will corrupt other data in memory (either the instance of another group, parts of the timeline or events). This situation cannot occur in the original Dungeon Master and Chaos Strikes Back dungeons for the following reasons (but it may occur in custom dungeons if they are not designed carefully): there is no map with already more than 60 groups in the original dungeons and none of the following 3 possible ways to move a group into a map can increase the number of instances above the maximum of 60:
-					- A group generator sensor is triggered: the game never generates a group on the party map if there are less than 5 instances available. This limits the actual number of groups on a map to 55 in most cases.
-					- A group falls through a pit from the map above (the creature type must be allowed on the target map): a group will never willingly move to an open pit square. It may move to a closed pit square and fall if the pit is then open (either automatically or triggered by the party on the map below). There are no such pits in the original dungeons.
-					- A group is teleported from another map (the creature type must be allowed on the target map): in the original dungeons, all teleporters whose scope include groups and target another map are either inaccessible to groups or the groups are not allowed on the target map. The only exception is for some Gigglers in the Chaos Strikes Back dungeon but there are not enough to use the 5 reserved instances.
-
-					This code returns immediately if all ACTIVE_GROUP entries are already in use, which avoids an out of bounds access into _vm->_groupMan->_g375_activeGroups below (through L0341_ps_ActiveGroup). However in this case the specified group ends up without an associated ACTIVE_GROUP structure which is assumed everywhere in the code to be present for groups on the same map as the party. If there are more than 60 groups on the party map at any given time then this will corrupt memory (in _vm->_timeline->_g370_events and _vm->_timeline->_g371_timeline allocated in _vm->_timeline->f233_initTimeline before _vm->_groupMan->_g375_activeGroups) because of read and write operations at incorrect memory addresses (the 'Cells' value of the GROUP will be used as an index in _vm->_groupMan->_g375_activeGroups even though that value was not replaced by the index of an ACTIVE_GROUP in this function) */
-		}
-		L0341_ps_ActiveGroup++;
-	}
-	_g377_currActiveGroupCount++;
-	L0340_ps_Group = ((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType());
-	L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells;
-	L0340_ps_Group->getActiveGroupIndex() = L0344_i_ActiveGroupIndex;
-	L0341_ps_ActiveGroup->_priorMapX = L0341_ps_ActiveGroup->_homeMapX = mapX;
-	L0341_ps_ActiveGroup->_priorMapY = L0341_ps_ActiveGroup->_homeMapY = mapY;
-	L0341_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime - 127;
-	L0339_ui_CreatureIndex = L0340_ps_Group->getCount();
-	do {
-		L0341_ps_ActiveGroup->_directions = (direction)f178_getGroupValueUpdatedWithCreatureValue(L0341_ps_ActiveGroup->_directions, L0339_ui_CreatureIndex, L0340_ps_Group->getDir());
-		L0341_ps_ActiveGroup->_aspect[L0339_ui_CreatureIndex] = 0;
-	} while (L0339_ui_CreatureIndex--);
-	f179_getCreatureAspectUpdateTime(L0341_ps_ActiveGroup, kM1_wholeCreatureGroup, false);
-}
-
-void GroupMan::f184_removeActiveGroup(uint16 activeGroupIndex) {
-	ActiveGroup* L0347_ps_ActiveGroup;
-	Group* L0348_ps_Group;
-
-
-	if ((activeGroupIndex > _vm->_groupMan->_g376_maxActiveGroupCount) || (_vm->_groupMan->_g375_activeGroups[activeGroupIndex]._groupThingIndex < 0)) {
-		return;
-	}
-	L0347_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[activeGroupIndex];
-	L0348_ps_Group = &((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex];
-	_g377_currActiveGroupCount--;
-	L0348_ps_Group->_cells = L0347_ps_ActiveGroup->_cells;
-	L0348_ps_Group->setDir(M21_normalizeModulo4(L0347_ps_ActiveGroup->_directions));
-	if (L0348_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
-		L0348_ps_Group->setBehaviour(k0_behavior_WANDER);
-	}
-	L0347_ps_ActiveGroup->_groupThingIndex = -1;
-}
 }
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 151594a..3530765 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -172,11 +172,12 @@ class GroupMan {
 	bool _g390_groupMovementBlockedByParty; // @ G0390_B_GroupMovementBlockedByParty
 	bool _g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter; // @ G0387_B_GroupMovementBlockedByWallStairsPitFakeWallFluxcageTeleporter
 public:
-	uint16 _g376_maxActiveGroupCount = 60; // @ G0376_ui_MaximumActiveGroupCount
+	uint16 _g376_maxActiveGroupCount; // @ G0376_ui_MaximumActiveGroupCount
 	ActiveGroup *_g375_activeGroups; // @ G0375_ps_ActiveGroups
 	uint16 _g377_currActiveGroupCount; // @ G0377_ui_CurrentActiveGroupCount
 	GroupMan(DMEngine *vm);
 	~GroupMan();
+
 	void f196_initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups
 	uint16 f145_getGroupCells(Group *group, int16 mapIndex); // @ F0145_DUNGEON_GetGroupCells
 	uint16 f147_getGroupDirections(Group *group, int16 mapIndex); // @ F0147_DUNGEON_GetGroupDirections


Commit: c74c4f362ec358a650c292954bc57f2932e001b8
    https://github.com/scummvm/scummvm/commit/c74c4f362ec358a650c292954bc57f2932e001b8
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Make some arrays static and local

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 05c8f17..799ff45 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -53,90 +53,6 @@ uint16 g208_doorButtonCoordSets[1][4][6] = { // @ G0208_aaauc_Graphic558_DoorBut
 	{144, 155, 42, 47, 8, 6},     /* D2C */
 	{160, 175, 44, 52, 8, 9}}}; /* D1C */
 
-DoorFrames g179_doorFrame_D3L = { // @ G0179_s_Graphic558_Frames_Door_D3L
-								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-	Frame(24, 71, 28, 67, 24, 41,  0,  0),     /* Closed Or Destroyed */
-	Frame(24, 71, 28, 38, 24, 41,  0, 30),     /* Vertical Closed one fourth */
-	Frame(24, 71, 28, 48, 24, 41,  0, 20),     /* Vertical Closed half */
-	Frame(24, 71, 28, 58, 24, 41,  0, 10),   /* Vertical Closed three fourth */
-	Frame(24, 29, 28, 67, 24, 41, 18,  0),     /* Left Horizontal Closed one fourth */
-	Frame(24, 35, 28, 67, 24, 41, 12,  0),     /* Left Horizontal Closed half */
-	Frame(24, 41, 28, 67, 24, 41,  6,  0),   /* Left Horizontal Closed three fourth */
-	Frame(66, 71, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed one fourth */
-	Frame(60, 71, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed half */
-	Frame(54, 71, 28, 67, 24, 41, 24,  0)}; /* Right Horizontal Closed three fourth */
-DoorFrames g180_doorFrame_D3C = { // @ G0180_s_Graphic558_Frames_Door_D3C
-								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-	Frame(88, 135, 28, 67, 24, 41,  0,  0),     /* Closed Or Destroyed */
-	Frame(88, 135, 28, 38, 24, 41,  0, 30),     /* Vertical Closed one fourth */
-	Frame(88, 135, 28, 48, 24, 41,  0, 20),     /* Vertical Closed half */
-	Frame(88, 135, 28, 58, 24, 41,  0, 10),   /* Vertical Closed three fourth */
-	Frame(88,  93, 28, 67, 24, 41, 18,  0),     /* Left Horizontal Closed one fourth */
-	Frame(88,  99, 28, 67, 24, 41, 12,  0),     /* Left Horizontal Closed half */
-	Frame(88, 105, 28, 67, 24, 41,  6,  0),   /* Left Horizontal Closed three fourth */
-	Frame(130, 135, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed one fourth */
-	Frame(124, 135, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed half */
-	Frame(118, 135, 28, 67, 24, 41, 24,  0)}; /* Right Horizontal Closed three fourth */
-DoorFrames g181_doorFrame_D3R = { // @ G0181_s_Graphic558_Frames_Door_D3R
-								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-	Frame(150, 197, 28, 67, 24, 41,  0,  0),     /* Closed Or Destroyed */
-	Frame(150, 197, 28, 38, 24, 41,  0, 30),     /* Vertical Closed one fourth */
-	Frame(150, 197, 28, 48, 24, 41,  0, 20),     /* Vertical Closed half */
-	Frame(150, 197, 28, 58, 24, 41,  0, 10),   /* Vertical Closed three fourth */
-	Frame(150, 153, 28, 67, 24, 41, 18,  0),     /* Left Horizontal Closed one fourth */
-	Frame(150, 161, 28, 67, 24, 41, 12,  0),     /* Left Horizontal Closed half */
-	Frame(150, 167, 28, 67, 24, 41,  6,  0),   /* Left Horizontal Closed three fourth */
-	Frame(192, 197, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed one fourth */
-	Frame(186, 197, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed half */
-	Frame(180, 197, 28, 67, 24, 41, 24,  0)}; /* Right Horizontal Closed three fourth */
-DoorFrames g182_doorFrame_D2L = { // @ G0182_s_Graphic558_Frames_Door_D2L
-								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-	Frame(0, 63, 24, 82, 32, 61,  0,  0),     /* Closed Or Destroyed */
-	Frame(0, 63, 24, 39, 32, 61,  0, 45),     /* Vertical Closed one fourth */
-	Frame(0, 63, 24, 54, 32, 61,  0, 30),     /* Vertical Closed half */
-	Frame(0, 63, 24, 69, 32, 61,  0, 15),   /* Vertical Closed three fourth */
-	Frame(0,  7, 24, 82, 32, 61, 24,  0),     /* Left Horizontal Closed one fourth */
-	Frame(0, 15, 24, 82, 32, 61, 16,  0),     /* Left Horizontal Closed half */
-	Frame(0, 23, 24, 82, 32, 61,  8,  0),   /* Left Horizontal Closed three fourth */
-	Frame(56, 63, 24, 82, 32, 61, 32,  0),     /* Right Horizontal Closed one fourth */
-	Frame(48, 63, 24, 82, 32, 61, 32,  0),     /* Right Horizontal Closed half */
-	Frame(40, 63, 24, 82, 32, 61, 32,  0)}; /* Right Horizontal Closed three fourth */
-DoorFrames g183_doorFrame_D2C = { // @ G0183_s_Graphic558_Frames_Door_D2C
-								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-	Frame(80, 143, 24, 82, 32, 61,  0,  0),     /* Closed Or Destroyed */
-	Frame(80, 143, 24, 39, 32, 61,  0, 45),     /* Vertical Closed one fourth */
-	Frame(80, 143, 24, 54, 32, 61,  0, 30),     /* Vertical Closed half */
-	Frame(80, 143, 24, 69, 32, 61,  0, 15),   /* Vertical Closed three fourth */
-	Frame(80,  87, 24, 82, 32, 61, 24,  0),     /* Left Horizontal Closed one fourth */
-	Frame(80,  95, 24, 82, 32, 61, 16,  0),     /* Left Horizontal Closed half */
-	Frame(80, 103, 24, 82, 32, 61,  8,  0),   /* Left Horizontal Closed three fourth */
-	Frame(136, 143, 24, 82, 32, 61, 32,  0),     /* Right Horizontal Closed one fourth */
-	Frame(128, 143, 24, 82, 32, 61, 32,  0),     /* Right Horizontal Closed half */
-	Frame(120, 143, 24, 82, 32, 61, 32,  0)}; /* Right Horizontal Closed three fourth */
-DoorFrames g184_doorFrame_D2R = { // @ G0184_s_Graphic558_Frames_Door_D2R
-								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-	Frame(160, 223, 24, 82, 32, 61,  0,  0),     /* Closed Or Destroyed */
-	Frame(160, 223, 24, 39, 32, 61,  0, 45),     /* Vertical Closed one fourth */
-	Frame(160, 223, 24, 54, 32, 61,  0, 30),     /* Vertical Closed half */
-	Frame(160, 223, 24, 69, 32, 61,  0, 15),   /* Vertical Closed three fourth */
-	Frame(160, 167, 24, 82, 32, 61, 24,  0),     /* Left Horizontal Closed one fourth */
-	Frame(160, 175, 24, 82, 32, 61, 16,  0),     /* Left Horizontal Closed half */
-	Frame(160, 183, 24, 82, 32, 61,  8,  0),   /* Left Horizontal Closed three fourth */
-	Frame(216, 223, 24, 82, 32, 61, 32,  0),     /* Right Horizontal Closed one fourth */
-	Frame(208, 223, 24, 82, 32, 61, 32,  0),     /* Right Horizontal Closed half */
-	Frame(200, 223, 24, 82, 32, 61, 32,  0)}; /* Right Horizontal Closed three fourth */
-DoorFrames g185_doorFrame_D1L = { // @ G0185_s_Graphic558_Frames_Door_D1L
-								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-	Frame(0, 31, 17, 102, 48, 88, 64,  0),     /* Closed Or Destroyed */
-	Frame(0, 31, 17,  38, 48, 88, 64, 66),     /* Vertical Closed one fourth */
-	Frame(0, 31, 17,  60, 48, 88, 64, 44),     /* Vertical Closed half */
-	Frame(0, 31, 17,  82, 48, 88, 64, 22),   /* Vertical Closed three fourth */
-	Frame(0,  0,  0,   0,  0,  0,  0,  0),     /* Left Horizontal Closed one fourth */
-	Frame(0,  0,  0,   0,  0,  0,  0,  0),     /* Left Horizontal Closed half */
-	Frame(0,  0,  0,   0,  0,  0,  0,  0),   /* Left Horizontal Closed three fourth */
-	Frame(20, 31, 17, 102, 48, 88, 48,  0),     /* Right Horizontal Closed one fourth */
-	Frame(8, 31, 17, 102, 48, 88, 48,  0),     /* Right Horizontal Closed half */
-	Frame(0, 31, 17, 102, 48, 88, 52,  0)}; /* Right Horizontal Closed three fourth */
 DoorFrames g186_doorFrame_D1C = { // @ G0186_s_Graphic558_Frames_Door_D1C
 								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
 	Frame(64, 159, 17, 102, 48, 88,  0,  0),     /* Closed Or Destroyed */
@@ -149,18 +65,6 @@ DoorFrames g186_doorFrame_D1C = { // @ G0186_s_Graphic558_Frames_Door_D1C
 	Frame(148, 159, 17, 102, 48, 88, 48,  0),     /* Right Horizontal Closed one fourth */
 	Frame(136, 159, 17, 102, 48, 88, 48,  0),     /* Right Horizontal Closed half */
 	Frame(124, 159, 17, 102, 48, 88, 48,  0)}; /* Right Horizontal Closed three fourth */
-DoorFrames g187_doorFrame_D1R = { // @ G0187_s_Graphic558_Frames_Door_D1R
-								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-	Frame(192, 223, 17, 102, 48, 88,  0,  0),     /* Closed Or Destroyed */
-	Frame(192, 223, 17,  38, 48, 88,  0, 66),     /* Vertical Closed one fourth */
-	Frame(192, 223, 17,  60, 48, 88,  0, 44),     /* Vertical Closed half */
-	Frame(192, 223, 17,  82, 48, 88,  0, 22),   /* Vertical Closed three fourth */
-	Frame(192, 203, 17, 102, 48, 88, 36,  0),     /* Left Horizontal Closed one fourth */
-	Frame(192, 215, 17, 102, 48, 88, 24,  0),     /* Left Horizontal Closed half */
-	Frame(192, 223, 17, 102, 48, 88, 12,  0),   /* Left Horizontal Closed three fourth */
-	Frame(0,   0,  0,   0,  0,  0,  0,  0),     /* Right Horizontal Closed one fourth */
-	Frame(0,   0,  0,   0,  0,  0,  0,  0),     /* Right Horizontal Closed half */
-	Frame(0,   0,  0,   0,  0,  0,  0,  0)}; /* Right Horizontal Closed three fourth */
 
 uint16 g207_doorOrnCoordSets[4][3][6] = { // @ G0207_aaauc_Graphic558_DoorOrnamentCoordinateSets
 	/* { X1, X2, Y1, Y2, ByteWidth, Height } */
@@ -1558,6 +1462,20 @@ void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) {
 
 // NOTE: has been screened for missing code
 void DisplayMan::f116_drawSquareD3L(direction dir, int16 posX, int16 posY) {
+	static DoorFrames g179_doorFrame_D3L = DoorFrames( // @ G0179_s_Graphic558_Frames_Door_D3L
+		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+		Frame(24, 71, 28, 67, 24, 41,  0,  0),     /* Closed Or Destroyed */
+		Frame(24, 71, 28, 38, 24, 41,  0, 30),     /* Vertical Closed one fourth */
+		Frame(24, 71, 28, 48, 24, 41,  0, 20),     /* Vertical Closed half */
+		Frame(24, 71, 28, 58, 24, 41,  0, 10),   /* Vertical Closed three fourth */
+		Frame(24, 29, 28, 67, 24, 41, 18,  0),     /* Left Horizontal Closed one fourth */
+		Frame(24, 35, 28, 67, 24, 41, 12,  0),     /* Left Horizontal Closed half */
+		Frame(24, 41, 28, 67, 24, 41,  6,  0),   /* Left Horizontal Closed three fourth */
+		Frame(66, 71, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed one fourth */
+		Frame(60, 71, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed half */
+		Frame(54, 71, 28, 67, 24, 41, 24,  0)
+	); /* Right Horizontal Closed three fourth */
+
 	uint16 squareAspect[5];
 	int16 order;
 
@@ -1609,6 +1527,20 @@ T0116017_orangeElk:
 }
 
 void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) {
+	static DoorFrames g181_doorFrame_D3R = DoorFrames( // @ G0181_s_Graphic558_Frames_Door_D3R
+		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+		Frame(150, 197, 28, 67, 24, 41,  0,  0),	/* Closed Or Destroyed */
+		Frame(150, 197, 28, 38, 24, 41,  0, 30),	/* Vertical Closed one fourth */
+		Frame(150, 197, 28, 48, 24, 41,  0, 20),	/* Vertical Closed half */
+		Frame(150, 197, 28, 58, 24, 41,  0, 10),	/* Vertical Closed three fourth */
+		Frame(150, 153, 28, 67, 24, 41, 18,  0),	/* Left Horizontal Closed one fourth */
+		Frame(150, 161, 28, 67, 24, 41, 12,  0),	/* Left Horizontal Closed half */
+		Frame(150, 167, 28, 67, 24, 41,  6,  0),	/* Left Horizontal Closed three fourth */
+		Frame(192, 197, 28, 67, 24, 41, 24,  0),	/* Right Horizontal Closed one fourth */
+		Frame(186, 197, 28, 67, 24, 41, 24,  0),	/* Right Horizontal Closed half */
+		Frame(180, 197, 28, 67, 24, 41, 24,  0)		/* Right Horizontal Closed three fourth */
+	);
+
 	int16 order;
 	uint16 squareAspect[5];
 
@@ -1666,6 +1598,19 @@ T0117018:
 }
 
 void DisplayMan::f118_drawSquareD3C(direction dir, int16 posX, int16 posY) {
+	static DoorFrames g180_doorFrame_D3C = DoorFrames( // @ G0180_s_Graphic558_Frames_Door_D3C
+		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+		Frame(88, 135, 28, 67, 24, 41,  0,  0),		/* Closed Or Destroyed */
+		Frame(88, 135, 28, 38, 24, 41,  0, 30),		/* Vertical Closed one fourth */
+		Frame(88, 135, 28, 48, 24, 41,  0, 20),		/* Vertical Closed half */
+		Frame(88, 135, 28, 58, 24, 41,  0, 10),		/* Vertical Closed three fourth */
+		Frame(88,  93, 28, 67, 24, 41, 18,  0),		/* Left Horizontal Closed one fourth */
+		Frame(88,  99, 28, 67, 24, 41, 12,  0),		/* Left Horizontal Closed half */
+		Frame(88, 105, 28, 67, 24, 41,  6,  0),		/* Left Horizontal Closed three fourth */
+		Frame(130, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed one fourth */
+		Frame(124, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed half */
+		Frame(118, 135, 28, 67, 24, 41, 24, 0)		/* Right Horizontal Closed three fourth */
+	);
 	int16 order;
 	int16 squareAspect[5];
 
@@ -1715,11 +1660,25 @@ T0118028:
 		f113_drawField(&g188_FieldAspects[k0_ViewSquare_D3C], g163_FrameWalls[k0_ViewSquare_D3C]._box);
 	}
 }
+
 void DisplayMan::f119_drawSquareD2L(direction dir, int16 posX, int16 posY) {
+	static DoorFrames g182_doorFrame_D2L = DoorFrames( // @ G0182_s_Graphic558_Frames_Door_D2L
+		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+		Frame(0, 63, 24, 82, 32, 61,  0,  0),	/* Closed Or Destroyed */
+		Frame(0, 63, 24, 39, 32, 61,  0, 45),	/* Vertical Closed one fourth */
+		Frame(0, 63, 24, 54, 32, 61,  0, 30),	/* Vertical Closed half */
+		Frame(0, 63, 24, 69, 32, 61,  0, 15),	/* Vertical Closed three fourth */
+		Frame(0,  7, 24, 82, 32, 61, 24,  0),	/* Left Horizontal Closed one fourth */
+		Frame(0, 15, 24, 82, 32, 61, 16,  0),	/* Left Horizontal Closed half */
+		Frame(0, 23, 24, 82, 32, 61,  8,  0),	/* Left Horizontal Closed three fourth */
+		Frame(56, 63, 24, 82, 32, 61, 32,  0),	/* Right Horizontal Closed one fourth */
+		Frame(48, 63, 24, 82, 32, 61, 32,  0),	/* Right Horizontal Closed half */
+		Frame(40, 63, 24, 82, 32, 61, 32,  0)	/* Right Horizontal Closed three fourth */
+	);
+
 	int16 order;
 	int16 squareAspect[5];
 
-
 	_vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
@@ -1767,7 +1726,22 @@ T0119020:
 		_vm->_displayMan->f113_drawField(&g188_FieldAspects[k4_ViewSquare_D2L], g163_FrameWalls[k4_ViewSquare_D2L]._box);
 	}
 }
+
 void DisplayMan::f120_drawSquareD2R(direction dir, int16 posX, int16 posY) {
+	static DoorFrames g184_doorFrame_D2R = DoorFrames( // @ G0184_s_Graphic558_Frames_Door_D2R
+		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+		Frame(160, 223, 24, 82, 32, 61,  0,  0),	/* Closed Or Destroyed */
+		Frame(160, 223, 24, 39, 32, 61,  0, 45),	/* Vertical Closed one fourth */
+		Frame(160, 223, 24, 54, 32, 61,  0, 30),	/* Vertical Closed half */
+		Frame(160, 223, 24, 69, 32, 61,  0, 15),	/* Vertical Closed three fourth */
+		Frame(160, 167, 24, 82, 32, 61, 24,  0),	/* Left Horizontal Closed one fourth */
+		Frame(160, 175, 24, 82, 32, 61, 16,  0),	/* Left Horizontal Closed half */
+		Frame(160, 183, 24, 82, 32, 61,  8,  0),	/* Left Horizontal Closed three fourth */
+		Frame(216, 223, 24, 82, 32, 61, 32,  0),	/* Right Horizontal Closed one fourth */
+		Frame(208, 223, 24, 82, 32, 61, 32,  0),	/* Right Horizontal Closed half */
+		Frame(200, 223, 24, 82, 32, 61, 32,  0)		/* Right Horizontal Closed three fourth */
+	);
+
 	int16 order;
 	int16 squareAspect[5];
 
@@ -1820,7 +1794,22 @@ T0120029:
 		_vm->_displayMan->f113_drawField(&g188_FieldAspects[k5_ViewSquare_D2R], g163_FrameWalls[k5_ViewSquare_D2R]._box);
 	}
 }
+
 void DisplayMan::f121_drawSquareD2C(direction dir, int16 posX, int16 posY) {
+	static DoorFrames g183_doorFrame_D2C = DoorFrames( // @ G0183_s_Graphic558_Frames_Door_D2C
+		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+		Frame(80, 143, 24, 82, 32, 61,  0,  0),		/* Closed Or Destroyed */
+		Frame(80, 143, 24, 39, 32, 61,  0, 45),		/* Vertical Closed one fourth */
+		Frame(80, 143, 24, 54, 32, 61,  0, 30),		/* Vertical Closed half */
+		Frame(80, 143, 24, 69, 32, 61,  0, 15),		/* Vertical Closed three fourth */
+		Frame(80,  87, 24, 82, 32, 61, 24,  0),		/* Left Horizontal Closed one fourth */
+		Frame(80,  95, 24, 82, 32, 61, 16,  0),		/* Left Horizontal Closed half */
+		Frame(80, 103, 24, 82, 32, 61,  8,  0),		/* Left Horizontal Closed three fourth */
+		Frame(136, 143, 24, 82, 32, 61, 32,  0),	/* Right Horizontal Closed one fourth */
+		Frame(128, 143, 24, 82, 32, 61, 32,  0),	/* Right Horizontal Closed half */
+		Frame(120, 143, 24, 82, 32, 61, 32,  0)		/* Right Horizontal Closed three fourth */
+	);
+
 	int16 order;
 	int16 squareAspect[5];
 
@@ -1873,6 +1862,20 @@ T0121016:
 }
 
 void DisplayMan::f122_drawSquareD1L(direction dir, int16 posX, int16 posY) {
+	static DoorFrames g185_doorFrame_D1L = DoorFrames( // @ G0185_s_Graphic558_Frames_Door_D1L
+		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+		Frame(0, 31, 17, 102, 48, 88, 64,  0),	/* Closed Or Destroyed */
+		Frame(0, 31, 17,  38, 48, 88, 64, 66),	/* Vertical Closed one fourth */
+		Frame(0, 31, 17,  60, 48, 88, 64, 44),	/* Vertical Closed half */
+		Frame(0, 31, 17,  82, 48, 88, 64, 22),	/* Vertical Closed three fourth */
+		Frame(0,  0,  0,   0,  0,  0,  0,  0),	/* Left Horizontal Closed one fourth */
+		Frame(0,  0,  0,   0,  0,  0,  0,  0),	/* Left Horizontal Closed half */
+		Frame(0,  0,  0,   0,  0,  0,  0,  0),	/* Left Horizontal Closed three fourth */
+		Frame(20, 31, 17, 102, 48, 88, 48,  0),	/* Right Horizontal Closed one fourth */
+		Frame(8, 31, 17, 102, 48, 88, 48,  0),	/* Right Horizontal Closed half */
+		Frame(0, 31, 17, 102, 48, 88, 52,  0)	/* Right Horizontal Closed three fourth */
+	);
+
 	int16 order;
 	int16 squareAspect[5];
 
@@ -1924,7 +1927,22 @@ T0122021:
 		f113_drawField(&g188_FieldAspects[k7_ViewSquare_D1L], g163_FrameWalls[k7_ViewSquare_D1L]._box);
 	}
 }
+
 void DisplayMan::f123_drawSquareD1R(direction dir, int16 posX, int16 posY) {
+	static DoorFrames g187_doorFrame_D1R = DoorFrames( // @ G0187_s_Graphic558_Frames_Door_D1R
+		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+		Frame(192, 223, 17, 102, 48, 88,  0,  0),     /* Closed Or Destroyed */
+		Frame(192, 223, 17,  38, 48, 88,  0, 66),     /* Vertical Closed one fourth */
+		Frame(192, 223, 17,  60, 48, 88,  0, 44),     /* Vertical Closed half */
+		Frame(192, 223, 17,  82, 48, 88,  0, 22),   /* Vertical Closed three fourth */
+		Frame(192, 203, 17, 102, 48, 88, 36,  0),     /* Left Horizontal Closed one fourth */
+		Frame(192, 215, 17, 102, 48, 88, 24,  0),     /* Left Horizontal Closed half */
+		Frame(192, 223, 17, 102, 48, 88, 12,  0),   /* Left Horizontal Closed three fourth */
+		Frame(0,   0,  0,   0,  0,  0,  0,  0),     /* Right Horizontal Closed one fourth */
+		Frame(0,   0,  0,   0,  0,  0,  0,  0),     /* Right Horizontal Closed half */
+		Frame(0,   0,  0,   0,  0,  0,  0,  0)
+	); /* Right Horizontal Closed three fourth */
+
 	int16 order;
 	int16 squareAspect[5];
 


Commit: e02d165fceedec6aff32cc9529b72b07cf8d103a
    https://github.com/scummvm/scummvm/commit/e02d165fceedec6aff32cc9529b72b07cf8d103a
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Move g186_doorFrame_D1C to DisplayMan

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 799ff45..7411f0c 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -53,19 +53,6 @@ uint16 g208_doorButtonCoordSets[1][4][6] = { // @ G0208_aaauc_Graphic558_DoorBut
 	{144, 155, 42, 47, 8, 6},     /* D2C */
 	{160, 175, 44, 52, 8, 9}}}; /* D1C */
 
-DoorFrames g186_doorFrame_D1C = { // @ G0186_s_Graphic558_Frames_Door_D1C
-								   /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-	Frame(64, 159, 17, 102, 48, 88,  0,  0),     /* Closed Or Destroyed */
-	Frame(64, 159, 17,  38, 48, 88,  0, 66),     /* Vertical Closed one fourth */
-	Frame(64, 159, 17,  60, 48, 88,  0, 44),     /* Vertical Closed half */
-	Frame(64, 159, 17,  82, 48, 88,  0, 22),   /* Vertical Closed three fourth */
-	Frame(64,  75, 17, 102, 48, 88, 36,  0),     /* Left Horizontal Closed one fourth */
-	Frame(64,  87, 17, 102, 48, 88, 24,  0),     /* Left Horizontal Closed half */
-	Frame(64,  99, 17, 102, 48, 88, 12,  0),   /* Left Horizontal Closed three fourth */
-	Frame(148, 159, 17, 102, 48, 88, 48,  0),     /* Right Horizontal Closed one fourth */
-	Frame(136, 159, 17, 102, 48, 88, 48,  0),     /* Right Horizontal Closed half */
-	Frame(124, 159, 17, 102, 48, 88, 48,  0)}; /* Right Horizontal Closed three fourth */
-
 uint16 g207_doorOrnCoordSets[4][3][6] = { // @ G0207_aaauc_Graphic558_DoorOrnamentCoordinateSets
 	/* { X1, X2, Y1, Y2, ByteWidth, Height } */
 	{{17, 31,  8, 17,  8, 10},     /* D3LCR */
@@ -718,6 +705,20 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_g322_paletteSwitchingEnabled = false;
 	warning("DUMMY CODE: setting _g304_dungeonViewPaletteIndex");
 	_g304_dungeonViewPaletteIndex = 0;
+
+	g186_doorFrame_D1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
+		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+		Frame(64, 159, 17, 102, 48, 88,  0,  0),	/* Closed Or Destroyed */
+		Frame(64, 159, 17,  38, 48, 88,  0, 66),	/* Vertical Closed one fourth */
+		Frame(64, 159, 17,  60, 48, 88,  0, 44),	/* Vertical Closed half */
+		Frame(64, 159, 17,  82, 48, 88,  0, 22),	/* Vertical Closed three fourth */
+		Frame(64,  75, 17, 102, 48, 88, 36,  0),	/* Left Horizontal Closed one fourth */
+		Frame(64,  87, 17, 102, 48, 88, 24,  0),	/* Left Horizontal Closed half */
+		Frame(64,  99, 17, 102, 48, 88, 12,  0),	/* Left Horizontal Closed three fourth */
+		Frame(148, 159, 17, 102, 48, 88, 48,  0),	/* Right Horizontal Closed one fourth */
+		Frame(136, 159, 17, 102, 48, 88, 48,  0),	/* Right Horizontal Closed half */
+		Frame(124, 159, 17, 102, 48, 88, 48,  0)	/* Right Horizontal Closed three fourth */
+	);
 }
 
 DisplayMan::~DisplayMan() {
@@ -760,6 +761,8 @@ DisplayMan::~DisplayMan() {
 	delete[] _g92_bitmapWall_D1LCR_Flipped;
 	delete[] _g93_bitmapWall_D0L_Flipped;
 	delete[] _g94_bitmapWall_D0R_Flipped;
+
+	delete g186_doorFrame_D1C;
 }
 
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
@@ -1351,7 +1354,7 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d
 				f131_flipVertical(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
 			}
 		}
-		if ((doorFramesTemp == &g186_doorFrame_D1C) && _vm->_championMan->_g407_party._event73Count_ThievesEye) {
+		if ((doorFramesTemp == g186_doorFrame_D1C) && _vm->_championMan->_g407_party._event73Count_ThievesEye) {
 			f109_drawDoorOrnament(_vm->M0_indexToOrdinal(k16_DoorOrnThivesEyeMask), k2_ViewDoorOrnament_D1LCR);
 		}
 		if (doorState == k4_doorState_CLOSED) {
@@ -2054,7 +2057,7 @@ void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) {
 			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C);
 		}
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &g186_doorFrame_D1C);
+					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, g186_doorFrame_D1C);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0124018;
 	case k2_ElementTypePit:
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 4cdf613..2fc01fb 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -504,7 +504,7 @@ class DisplayMan {
 	uint32 *_packedItemPos;
 	byte *_packedBitmaps;
 	byte **_bitmaps;
-
+	DoorFrames *g186_doorFrame_D1C;
 	// pointers are not owned by these fields
 	byte *_g75_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile
 


Commit: 723c96fffe2d0eb1775983f3059828ac58354a0e
    https://github.com/scummvm/scummvm/commit/723c96fffe2d0eb1775983f3059828ac58354a0e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Clean up some initialization

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/group.cpp
    engines/dm/group.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/menus.cpp
    engines/dm/menus.h
    engines/dm/movesens.cpp
    engines/dm/objectman.cpp
    engines/dm/projexpl.cpp
    engines/dm/text.cpp
    engines/dm/text.h
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 5c1f546..6449140 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -96,18 +96,22 @@ uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
 Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
 
 ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
-	_g411_leaderIndex = kM1_ChampionNone;
-
-	_g303_partyDead = false;
-	_g300_partyIsSleeping = false;
-	_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
-	_g415_leaderEmptyHanded = true;
-	_g514_magicCasterChampionIndex = kM1_ChampionNone;
 	for (uint16 i = 0; i < 4; ++i) {
 		_g409_championPendingDamage[i] = 0;
 		_g410_championPendingWounds[i] = 0;
+		_gK71_champions[i].resetToZero();
 	}
-
+	_g305_partyChampionCount = 0;
+	_g303_partyDead = false;
+	_g414_leaderHandObject = Thing(0);
+	_g411_leaderIndex = kM1_ChampionNone;
+	_g300_partyIsSleeping = false;
+	_g506_actingChampionOrdinal = 0;
+	_g413_leaderHandObjectIconIndex = (IconIndice)0;
+	_g415_leaderEmptyHanded = false;
+	_g407_party.resetToZero();
+	_g514_magicCasterChampionIndex = kM1_ChampionNone;
+	_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
 }
 
 bool ChampionMan::f329_isLeaderHandObjectThrown(int16 side) {
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 282889d..a17f92e 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -62,11 +62,7 @@ public:
 class Party {
 public:
 	Party() {
-		_magicalLightAmount = _event73Count_ThievesEye = _event79Count_Footprints = _shieldDefense = 0;
-		_fireShieldDefense = _spellShieldDefense = _scentCount = _freezeLifeTicks = _firstScentIndex = 0;
-		_lastScentIndex = _event71Count_Invisibility = 0;
-		for (int16 i = 0; i < 24; ++i)
-			_scentStrengths[i] = 0;
+		resetToZero();
 	}
 	int16 _magicalLightAmount;
 	byte _event73Count_ThievesEye;
@@ -83,6 +79,21 @@ public:
 	Scent _scents[24]; // if I remember correctly, user defined default constructors are always called
 	byte _scentStrengths[24];
 	byte _event71Count_Invisibility;
+	void resetToZero() {
+		_magicalLightAmount = 0;
+		_event73Count_ThievesEye = 0;
+		_event79Count_Footprints = 0;
+		_shieldDefense = 0;
+
+		_fireShieldDefense = 0;
+		_spellShieldDefense = 0;
+		_scentCount = 0;
+		_freezeLifeTicks = 0;
+		_firstScentIndex = 0;
+		for (int16 i = 0; i < 24; ++i)
+			_scentStrengths[i] = 0;
+		_event71Count_Invisibility = 0;
+	}
 }; // @  PARTY
 
 enum IconIndice {
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 51b33c3..aa47af2 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -133,19 +133,31 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_groupMan = nullptr;
 	_timeline = nullptr;
 	_projexpl = nullptr;
-	_g321_stopWaitingForPlayerInput = false;
+
+	_g298_newGame = false;
+	_g523_restartGameRequest = false;
+	_g321_stopWaitingForPlayerInput = true;
 	_g301_gameTimeTicking = false;
 	_g524_restartGameAllowed = false;
+	_g525_gameId = 0;
 	_g331_pressingEye = false;
-	_g333_pressingMouth = false;
 	_g332_stopPressingEye = false;
+	_g333_pressingMouth = false;
 	_g334_stopPressingMouth = false;
 	_g340_highlightBoxInversionRequested = false;
-	_g313_gameTime = 0;
+	_g311_projectileDisableMovementTicks = 0;
+	_g312_lastProjectileDisabledMovementDirection = 0;
 	_g302_gameWon = false;
 	_g327_newPartyMapIndex = kM1_mapIndexNone;
-
+	_g325_setMousePointerToObjectInMainLoop = false;
+	_g310_disabledMovementTicks = 0;
+	_g313_gameTime = 0;
+	_g353_stringBuildBuffer[0] = '\0';
 	debug("DMEngine::DMEngine");
+
+
+	warning("DUMMY CODE: setting _g298_newGame to true, should be in processEntrance");
+	_g298_newGame = true;
 }
 
 DMEngine::~DMEngine() {
@@ -184,23 +196,26 @@ void DMEngine::f463_initializeGame() {
 	_displayMan->f479_loadGraphics();
 	_displayMan->f460_initializeGraphicData();
 	// DUMMY CODE: next line
-	_displayMan->loadPalette(g19_PalCredits);
+	_displayMan->loadPalette(g21_PalDungeonView[0]);
+	_displayMan->f94_loadFloorSet(k0_FloorSetStone);
+	_displayMan->f95_loadWallSet(k0_WallSetStone);
 
+	_textMan->f54_textInitialize();
+	_objectMan->loadObjectNames();
 	_eventMan->initMouse();
-
+	//F0441_STARTEND_ProcessEntrance();
 	while (_loadsaveMan->f435_loadgame() != k1_LoadgameSuccess) {
 		warning("TODO: F0441_STARTEND_ProcessEntrance");
 	}
+	//F0396_MENUS_LoadSpellAreaLinesBitmap() is not needed, every bitmap has been loaded
 
-	_displayMan->f94_loadFloorSet(k0_FloorSetStone);
-	_displayMan->f95_loadWallSet(k0_WallSetStone);
-	_objectMan->loadObjectNames();
 
 	// There was some memory wizardy for the Amiga platform, I skipped that part
 	_displayMan->f461_allocateFlippedWallBitmaps();
 
 	f462_startGame();
-	warning("MISSING CODE: F0267_MOVE_GetMoveResult_CPSCE (if newGame)");
+	if (_g298_newGame)
+		_movsens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
 	_eventMan->f78_showMouse();
 	_eventMan->f357_discardAllInput();
 }
@@ -212,6 +227,11 @@ void DMEngine::f448_initMemoryManager() {
 }
 
 void DMEngine::f462_startGame() {
+	static Box g61_boxScreenTop(0, 319, 0, 32); // @ G0061_s_Graphic562_Box_ScreenTop
+	static Box g62_boxScreenRight(224, 319, 33, 169); // @ G0062_s_Graphic562_Box_ScreenRight
+	static Box g63_boxScreenBottom(0, 319, 169, 199); // @ G0063_s_Graphic562_Box_ScreenBottom
+
+
 	_g331_pressingEye = false;
 	_g332_stopPressingEye = false;
 	_g333_pressingMouth = false;
@@ -231,9 +251,12 @@ void DMEngine::f462_startGame() {
 
 	if (!_g298_newGame) {
 		warning("TODO: loading game");
+		assert(false);
 	} else {
 		_displayMan->_g578_useByteBoxCoordinates = false;
-		warning("TODO: clear screen");
+		_displayMan->D24_fillScreenBox(g61_boxScreenTop, k0_ColorBlack);
+		_displayMan->D24_fillScreenBox(g62_boxScreenRight, k0_ColorBlack);
+		_displayMan->D24_fillScreenBox(g63_boxScreenBottom, k0_ColorBlack);
 	}
 
 	warning("TODO: build copper");
@@ -243,10 +266,10 @@ void DMEngine::f462_startGame() {
 }
 
 void DMEngine::f3_processNewPartyMap(uint16 mapIndex) {
-	warning("MISSING CODE: F0194_GROUP_RemoveAllActiveGroups");
+	_groupMan->f194_removeAllActiveGroups();
 	_dungeonMan->f174_setCurrentMapAndPartyMap(mapIndex);
 	_displayMan->f96_loadCurrentMapGraphics();
-	warning("MISSING CODE: F0195_GROUP_AddAllActiveGroups");
+	_groupMan->f195_addAllActiveGroups();
 	_inventoryMan->f337_setDungeonViewPalette();
 }
 
@@ -290,8 +313,31 @@ void DMEngine::f2_gameloop() {
 	warning("DUMMY CODE: clearing screen to black"); // in loop below
 
 	while (true) {
+		if (_g327_newPartyMapIndex != kM1_mapIndexNone) {
+			T0002002:
+			f3_processNewPartyMap(_g327_newPartyMapIndex);
+			_movsens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
+			_g327_newPartyMapIndex = kM1_mapIndexNone;
+			_eventMan->f357_discardAllInput();
+		}
 
+		// MISSING: F0261_TIMELINE_Process_CPSEF
+
+		if (_g327_newPartyMapIndex != kM1_mapIndexNone)
+			goto T0002002;
+
+		if (_championMan->_g303_partyDead)
+			break;
 		_g313_gameTime++;
+
+		if (!(_g313_gameTime & 511))
+			_inventoryMan->f338_decreaseTorchesLightPower();
+		if (_g310_disabledMovementTicks) {
+			_g310_disabledMovementTicks--;
+		}
+		if (_championMan->_g407_party._freezeLifeTicks) {
+			_championMan->_g407_party._freezeLifeTicks -= 1;
+		}
 		_menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived();
 
 		if (_g311_projectileDisableMovementTicks)
@@ -299,9 +345,9 @@ void DMEngine::f2_gameloop() {
 
 		_g321_stopWaitingForPlayerInput = false;
 		//do {
-		_eventMan->processInput();
-		_eventMan->f380_processCommandQueue();
-		//} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking);
+			_eventMan->processInput();
+			_eventMan->f380_processCommandQueue();
+		//} while (!_g321_stopWaitingForPlayerInput /*|| !_g301_gameTimeTicking */);
 
 		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
 			Box box(0, 223, 0, 135);
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 9ace815..3f7f558 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -180,7 +180,6 @@ class DMEngine : public Engine {
 	void f448_initMemoryManager(); // @ F0448_STARTUP1_InitializeMemoryManager_CPSADEF
 	void f2_gameloop(); // @ F0002_MAIN_GameLoop_CPSDF
 	void initArrays();
-
 public:
 	explicit DMEngine(OSystem *syst);
 	~DMEngine();
@@ -218,7 +217,7 @@ public:
 	bool _g321_stopWaitingForPlayerInput; // @ G0321_B_StopWaitingForPlayerInput
 	bool _g301_gameTimeTicking; // @ G0301_B_GameTimeTicking
 	bool _g524_restartGameAllowed; // @ G0524_B_RestartGameAllowed
-	uint32 _g525_gameId; // @ G0525_l_GameID, probably useless here
+	int32 _g525_gameId; // @ G0525_l_GameID, probably useless here
 	bool _g331_pressingEye; // @ G0331_B_PressingEye
 	bool _g332_stopPressingEye; // @ G0332_B_StopPressingEye
 	bool _g333_pressingMouth; // @ G0333_B_PressingMouth
@@ -229,8 +228,8 @@ public:
 	bool _g302_gameWon; // @ G0302_B_GameWon
 	int16 _g327_newPartyMapIndex; // @ G0327_i_NewPartyMapIndex
 	bool _g325_setMousePointerToObjectInMainLoop; // @ G0325_B_SetMousePointerToObjectInMainLoop
+	int16 _g310_disabledMovementTicks; // @ G0310_i_DisabledMovementTicks
 
-	// TODO: refactor direction into a class
 	int8 _dirIntoStepCountEast[4]; // @ G0233_ai_Graphic559_DirectionToStepEastCount
 	int8 _dirIntoStepCountNorth[4]; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
 	uint32 _g313_gameTime; // @ G0313_ul_GameTime
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index c7f59b7..b4cd964 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -369,59 +369,43 @@ void DungeonMan::f150_mapCoordsAfterRelMovement(direction dir, int16 stepsForwar
 	posY += _vm->_dirIntoStepCountNorth[dir] * stepsRight;
 }
 
-DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _g277_dungeonMaps(NULL), _g276_dungeonRawMapData(NULL) {
+DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine) {
+	_rawDunFileDataSize = 0;
+	_rawDunFileData = nullptr;
 	_g282_dungeonColumCount = 0;
-
 	_g281_dungeonMapsFirstColumnIndex = nullptr;
+
+
+	_g282_dungeonColumCount = 0;
 	_g280_dungeonColumnsCumulativeSquareThingCount = nullptr;
 	_g283_squareFirstThings = nullptr;
 	_g260_dungeonTextData = nullptr;
-	_g279_dungeonMapData = nullptr;
-
-	for (int i = 0; i < 16; i++)
+	for (uint16 i = 0; i < 16; ++i)
 		_g284_thingData[i] = nullptr;
-
-	_g308_partyDir = kDirNorth;
+	_g279_dungeonMapData = nullptr;
+	_g308_partyDir = (direction)0;
 	_g306_partyMapX = 0;
 	_g307_partyMapY = 0;
 	_g309_partyMapIndex = 0;
 	_g272_currMapIndex = kM1_mapIndexNone;
-	_g273_currMapWidth = 0;
-	_g274_currMapHeight = 0;
-
 	_g271_currMapData = nullptr;
 	_g269_currMap = nullptr;
+	_g273_currMapWidth = 0;
+	_g274_currMapHeight = 0;
 	_g270_currMapColCumulativeSquareFirstThingCount = nullptr;
-
-	_vm->_g298_newGame = true;
-	_vm->_g523_restartGameRequest = false;
-
-	_rawDunFileDataSize = 0;
-	_rawDunFileData = nullptr;
-
-	_g278_dungeonFileHeader._dungeonId = 0;
-	_g278_dungeonFileHeader._ornamentRandomSeed = 0;
-	_g278_dungeonFileHeader._rawMapDataSize = 0;
-	_g278_dungeonFileHeader._mapCount = 0;
-	_g278_dungeonFileHeader._textDataWordCount = 0;
-	_g278_dungeonFileHeader._partyStartDir = kDirNorth;
-	_g278_dungeonFileHeader._partyStartPosX = 0;
-	_g278_dungeonFileHeader._partyStartPosY = 0;
-	_g278_dungeonFileHeader._squareFirstThingCount = 0;
-
-	for (int i = 0; i < 16; i++)
-		_g278_dungeonFileHeader._thingCounts[i] = 0;
-
 	_g277_dungeonMaps = nullptr;
 	_g276_dungeonRawMapData = nullptr;
-
 	_g265_currMapInscriptionWallOrnIndex = 0;
+	for (uint16 i = 0; i < 6; ++i)
+		_g291_dungeonViewClickableBoxes[i].setToZero();
 	_g286_isFacingAlcove = false;
 	_g287_isFacingViAltar = false;
 	_g288_isFacingFountain = false;
-
-	for (int j = 0; j < 6; j++)
-		_g291_dungeonViewClickableBoxes[j].setToZero();
+	_g285_squareAheadElement = (ElementType)0;
+	for (uint16 i = 0; i < 5; ++i)
+		_g292_pileTopObject[i] = Thing(0);
+	for (uint16 i = 0; i < 2; ++i)
+		_g275_currMapDoorInfo[i].resetToZero();
 }
 
 DungeonMan::~DungeonMan() {
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index c591881..26841a2 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -51,6 +51,7 @@ enum ElementType {
 	k1_ElementTypeCorridor = 1, // @ C01_ELEMENT_CORRIDOR
 	k2_ElementTypePit = 2, // @ C02_ELEMENT_PIT
 	k3_ElementTypeStairs = 3, // @ C03_ELEMENT_STAIRS
+	// TODO: refactor direction into a class
 	k4_ElementTypeDoor = 4, // @ C04_ELEMENT_DOOR
 	k5_ElementTypeTeleporter = 5, // @ C05_ELEMENT_TELEPORTER
 	k6_ElementTypeFakeWall = 6, // @ C06_ELEMENT_FAKEWALL
@@ -374,13 +375,14 @@ public:
 			_desc &= (~(1 << 15));
 	}
 	uint16 getChargeCount() { return (_desc >> 10) & 0xF; }
-	void setChargeCount(uint16 val) { _desc = (_desc & ~(0xF << 10)) | ((val & 0xF) << 10); }
+	uint16 setChargeCount(uint16 val) { _desc = (_desc & ~(0xF << 10)) | ((val & 0xF) << 10); return (val & 0xF); }
 	Thing getNextThing() { return _nextThing; }
 	uint16 getCursed() { return (_desc >> 8) & 1; }
 	void setCursed(uint16 val) { _desc = (_desc & ~(1 << 8)) | ((val & 1) << 8); }
 	uint16 getPoisoned() { return (_desc >> 9) & 1; }
 	uint16 getBroken() { return (_desc >> 14) & 1; }
 	uint16 getDoNotDiscard() { return (_desc >> 7) & 1; }
+	void setDoNotDiscard(uint16 val) { _desc = (_desc & ~(1 << 7)) | ((val & 1) << 7); }
 }; // @ WEAPON
 
 enum ArmourType {
@@ -631,7 +633,8 @@ public:
 	byte _attributes;
 	byte _defense;
 	DoorInfo(byte b1, byte b2) : _attributes(b1), _defense(b2) {}
-	DoorInfo() {}
+	DoorInfo() { resetToZero(); }
+	void resetToZero() { _attributes = _defense = 0; }
 }; // @ DOOR_INFO
 
 class Group;
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 0104883..99a0e17 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -290,20 +290,22 @@ MouseInput* g480_PrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryM
 
 
 EventManager::EventManager(DMEngine *vm) : _vm(vm) {
-	_g441_primaryMouseInput = nullptr;
-	_g442_secondaryMouseInput = nullptr;
-
-	_g436_pendingClickPresent = false;
-	_g435_isCommandQueueLocked = true;
-	_g598_mousePointerBitmapUpdated = false;
-	_g326_refreshMousePointerInMainLoop = false;
-	_g341_highlightBoxEnabled = false;
-
+	_mousePos = Common::Point(0, 0);
 	_dummyMapIndex = 0;
-	_g439_pendingClickButton = k0_NoneMouseButton;
+	_g436_pendingClickPresent = false;
+	_g437_pendingClickPos = Common::Point(0, 0);
 	_g615_mousePointerOriginalColorsObject = nullptr;
 	_g613_mousePointerOriginalColorsChampionIcon = nullptr;
 	_gK190_mousePointerTempBuffer = nullptr;
+	_g435_isCommandQueueLocked = true;
+	_gK104_mousePointerType = 0;
+	_gK105_previousMousePointerType = 0;
+	_g441_primaryMouseInput = nullptr;
+	_g442_secondaryMouseInput = nullptr;
+	_g598_mousePointerBitmapUpdated = true;
+	_g326_refreshMousePointerInMainLoop = false;
+	_g341_highlightBoxEnabled = false;
+	_g599_useChampionIconOrdinalAsMousePointerBitmap = 0;
 }
 
 EventManager::~EventManager() {
@@ -324,7 +326,7 @@ void EventManager::initMouse() {
 	_gK105_previousMousePointerType = k1_pointerHand;
 
 	_mousePos = Common::Point(0, 0);
-	CursorMan.pushCursor(g42_bitmapArrowPointer, 32, 18, 0, 0, 0);
+	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
 	CursorMan.showMouse(false);
 
 
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index b4e89e0..f12ef8e 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -28,15 +28,38 @@
 #include "group.h"
 #include "dungeonman.h"
 #include "champion.h"
-
+#include "movesens.h"
+#include "projexpl.h"
+#include "timeline.h"
 
 
 namespace DM {
-
+int32 M32_setTime(int32 &map_time, int32 time) {
+	return map_time = (map_time & 0xFF000000) | time;
+}
 
 GroupMan::GroupMan(DMEngine* vm) : _vm(vm) {
-	_g375_activeGroups = nullptr;
+	for (uint16 i = 0; i < 4; ++i)
+		_g392_dropMovingCreatureFixedPossessionsCell[i] = 0;
+	_g391_dropMovingCreatureFixedPossCellCount = 0;
+	_g386_fluxCageCount = 0;
+	for (uint16 i = 0; i < 4; ++i)
+		_g385_fluxCages[i] = 0;
+	_g378_currentGroupMapX = 0;
+	_g379_currentGroupMapY = 0;
+	_g380_currGroupThing = Thing(0);
+	for (uint16 i = 0; i < 4; ++i)
+		_g384_groupMovementTestedDirections[i] = 0;
+	_g381_currGroupDistanceToParty = 0;
+	_g382_currGroupPrimaryDirToParty = 0;
+	_g383_currGroupSecondaryDirToParty = 0;
+	_g388_groupMovementBlockedByGroupThing = Thing(0);
+	_g389_groupMovementBlockedByDoor = false;
+	_g390_groupMovementBlockedByParty = false;
+	_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = false;
 	_g376_maxActiveGroupCount = 60;
+	_g375_activeGroups = nullptr;
+	_g377_currActiveGroupCount = 0;
 }
 
 GroupMan::~GroupMan() {
@@ -98,4 +121,1669 @@ int16 GroupMan::f176_getCreatureOrdinalInCell(Group* group, uint16 cell) {
 uint16 GroupMan::M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex) {
 	return (groupVal >> (creatureIndex << 1)) & 0x3;
 }
+
+void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode) {
+	Thing L0365_T_CurrentThing;
+	Thing L0366_T_NextThing;
+	Group* L0367_ps_Group;
+	uint16 L0368_ui_CreatureType;
+	int16 L0369_i_CreatureIndex;
+	uint16 L0370_ui_GroupCells;
+	bool L0371_B_WeaponDropped;
+
+
+	L0367_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(groupThing);
+	if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[L0368_ui_CreatureType = L0367_ps_Group->_type]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
+		L0369_i_CreatureIndex = L0367_ps_Group->getCount();
+		L0370_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(L0367_ps_Group, _vm->_dungeonMan->_g272_currMapIndex);
+		do {
+			_vm->_groupMan->f186_dropCreatureFixedPossessions(L0368_ui_CreatureType, mapX, mapY, (L0370_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0370_ui_GroupCells, L0369_i_CreatureIndex), mode);
+		} while (L0369_i_CreatureIndex--);
+	}
+	if ((L0365_T_CurrentThing = L0367_ps_Group->_slot) != Thing::_endOfList) {
+		L0371_B_WeaponDropped = false;
+		do {
+			L0366_T_NextThing = _vm->_dungeonMan->f159_getNextThing(L0365_T_CurrentThing);
+			L0365_T_CurrentThing = M15_thingWithNewCell(L0365_T_CurrentThing, _vm->getRandomNumber(4));
+			if ((L0365_T_CurrentThing).getType() == k5_WeaponThingType) {
+				L0371_B_WeaponDropped = true;
+			}
+			_vm->_movsens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
+		} while ((L0365_T_CurrentThing = L0366_T_NextThing) != Thing::_endOfList);
+		if (mode >= k0_soundModePlayImmediately) {
+			warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+		}
+	}
+}
+
+void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int16 mapY, uint16 cell, int16 mode) {
+	static uint16 g245FixedPossessionCreature_12Skeleton[3] = { // @ G0245_aui_Graphic559_FixedPossessionsCreature12Skeleton
+		k23_ObjectInfoIndexFirstWeapon + k9_WeaponTypeFalchion,
+		k69_ObjectInfoIndexFirstArmour + k30_ArmourTypeWoodenShield, 0};
+	static uint16 g246FixedPossessionCreature_9StoneGolem[2] = { // @ G0246_aui_Graphic559_FixedPossessionsCreature09StoneGolem
+		k23_ObjectInfoIndexFirstWeapon + k24_WeaponTypeStoneClub, 0};
+	static uint16 g247FixedPossessionCreature_16TrolinAntman[2] = { // @ G0247_aui_Graphic559_FixedPossessionsCreature16Trolin_Antman
+		k23_ObjectInfoIndexFirstWeapon + k23_WeaponTypeClub, 0};
+	static uint16 g248FixedPossessionCreature_18AnimatedArmourDethKnight[7] = { // @ G0248_aui_Graphic559_FixedPossessionsCreature18AnimatedArmour_DethKnight
+		k69_ObjectInfoIndexFirstArmour + k41_ArmourTypeFootPlate,
+		k69_ObjectInfoIndexFirstArmour + k40_ArmourTypeLegPlate,
+		k69_ObjectInfoIndexFirstArmour + k39_ArmourTypeTorsoPlate,
+		k23_ObjectInfoIndexFirstWeapon + k10_WeaponTypeSword,
+		k69_ObjectInfoIndexFirstArmour + k38_ArmourTypeArmet,
+		k23_ObjectInfoIndexFirstWeapon + k10_WeaponTypeSword, 0};
+	static uint16 g249FixedPossessionCreature_7rockRockPile[5] = { // @ G0249_aui_Graphic559_FixedPossessionsCreature07Rock_RockPile
+		k127_ObjectInfoIndexFirstJunk + k25_JunkTypeBoulder,
+		k127_ObjectInfoIndexFirstJunk + k25_JunkTypeBoulder | k0x8000_randomDrop,
+		k23_ObjectInfoIndexFirstWeapon + k30_WeaponTypeRock | k0x8000_randomDrop,
+		k23_ObjectInfoIndexFirstWeapon + k30_WeaponTypeRock | k0x8000_randomDrop, 0};
+	static uint16 g250FixedPossessionCreature_4PainRatHellHound[3] = { // @ G0250_aui_Graphic559_FixedPossessionsCreature04PainRat_Hellhound
+		k127_ObjectInfoIndexFirstJunk + k35_JunkTypeDrumstickShank,
+		k127_ObjectInfoIndexFirstJunk + k35_JunkTypeDrumstickShank | k0x8000_randomDrop, 0};
+	static uint16 g251FixedPossessionCreature_6screamer[3] = { // @ G0251_aui_Graphic559_FixedPossessionsCreature06Screamer
+		k127_ObjectInfoIndexFirstJunk + k33_JunkTypeScreamerSlice,
+		k127_ObjectInfoIndexFirstJunk + k33_JunkTypeScreamerSlice | k0x8000_randomDrop, 0};
+	static uint16 g252FixedPossessionCreature_15MagnetaWormWorm[4] = { // @ G0252_aui_Graphic559_FixedPossessionsCreature15MagentaWorm_Worm
+		k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound,
+		k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound | k0x8000_randomDrop,
+		k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound | k0x8000_randomDrop, 0};
+	static uint16 g253FixedPossessionCreature_24RedDragon[11] = { // @ G0253_aui_Graphic559_FixedPossessionsCreature24RedDragon
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop,
+		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop, 0};
+
+	uint16 L0356_ui_FixedPossession;
+	int16 L0357_i_ThingType;
+	Thing L0358_T_Thing;
+	uint16* L0359_pui_FixedPossessions;
+	Weapon* L0360_ps_Weapon;
+	bool L0361_B_Cursed;
+	bool L0362_B_WeaponDropped;
+
+
+	L0361_B_Cursed = false;
+	L0362_B_WeaponDropped = false;
+	switch (creatureType) {
+	default:
+		return;
+	case k12_CreatureTypeSkeleton:
+		L0359_pui_FixedPossessions = g245FixedPossessionCreature_12Skeleton;
+		break;
+	case k9_CreatureTypeStoneGolem:
+		L0359_pui_FixedPossessions = g246FixedPossessionCreature_9StoneGolem;
+		break;
+	case k16_CreatureTypeTrolinAntman:
+		L0359_pui_FixedPossessions = g247FixedPossessionCreature_16TrolinAntman;
+		break;
+	case k18_CreatureTypeAnimatedArmourDethKnight:
+		L0361_B_Cursed = true;
+		L0359_pui_FixedPossessions = g248FixedPossessionCreature_18AnimatedArmourDethKnight;
+		break;
+	case k7_CreatureTypeRockpile:
+		L0359_pui_FixedPossessions = g249FixedPossessionCreature_7rockRockPile;
+		break;
+	case k4_CreatureTypePainRatHellHound:
+		L0359_pui_FixedPossessions = g250FixedPossessionCreature_4PainRatHellHound;
+		break;
+	case k6_CreatureTypeScreamer:
+		L0359_pui_FixedPossessions = g251FixedPossessionCreature_6screamer;
+		break;
+	case k15_CreatureTypeMagnetaWormWorm:
+		L0359_pui_FixedPossessions = g252FixedPossessionCreature_15MagnetaWormWorm;
+		break;
+	case k24_CreatureTypeRedDragon:
+		L0359_pui_FixedPossessions = g253FixedPossessionCreature_24RedDragon;
+	}
+	while (L0356_ui_FixedPossession = *L0359_pui_FixedPossessions++) {
+		if (getFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) && _vm->getRandomNumber(2))
+			continue;
+		if (clearFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) >= k127_ObjectInfoIndexFirstJunk) {
+			L0357_i_ThingType = k10_JunkThingType;
+			L0356_ui_FixedPossession -= k127_ObjectInfoIndexFirstJunk;
+		} else {
+			if (L0356_ui_FixedPossession >= k69_ObjectInfoIndexFirstArmour) {
+				L0357_i_ThingType = k6_ArmourThingType;
+				L0356_ui_FixedPossession -= k69_ObjectInfoIndexFirstArmour;
+			} else {
+				L0362_B_WeaponDropped = true;
+				L0357_i_ThingType = k5_WeaponThingType;
+				L0356_ui_FixedPossession -= k23_ObjectInfoIndexFirstWeapon;
+			}
+		}
+		if ((L0358_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(L0357_i_ThingType)) == Thing::_none) {
+			continue;
+		}
+		L0360_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0358_T_Thing);
+/* The same pointer type is used no matter the actual type k5_WeaponThingType, k6_ArmourThingType or k10_JunkThingType */
+		L0360_ps_Weapon->setType(L0356_ui_FixedPossession);
+		L0360_ps_Weapon->setCursed(L0361_B_Cursed);
+		L0358_T_Thing = M15_thingWithNewCell(L0358_T_Thing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell);
+		_vm->_movsens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY);
+	}
+	warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+}
+
+int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
+#define AP0483_i_PrimaryDirection srcMapX
+	int16 L0556_i_Direction;
+
+
+	if (srcMapX == destMapX) {
+		_vm->_projexpl->_g363_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 1; /* Resulting direction may be 1 or 3 (East or West) */
+		if (srcMapY > destMapY) {
+			return kDirNorth;
+		}
+		return kDirSouth;
+	}
+	if (srcMapY == destMapY) {
+		_vm->_projexpl->_g363_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 0; /* Resulting direction may be 0 or 2 (North or South) */
+		if (srcMapX > destMapX) {
+			return kDirWest;
+		}
+		return kDirEast;
+	}
+	L0556_i_Direction = kDirNorth;
+	for (;;) {
+		if (f227_isDestVisibleFromSource(L0556_i_Direction, srcMapX, srcMapY, destMapX, destMapY)) {
+			if (!f227_isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
+				if ((L0556_i_Direction != kDirNorth) || !f227_isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnPrevVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
+					_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + L0556_i_Direction);
+					return L0556_i_Direction;
+				}
+			}
+			if (_vm->getRandomNumber(2)) {
+				AP0483_i_PrimaryDirection = _vm->_projexpl->_g363_secondaryDirToOrFromParty;
+				_vm->_projexpl->_g363_secondaryDirToOrFromParty = L0556_i_Direction;
+				return AP0483_i_PrimaryDirection;
+			}
+			return L0556_i_Direction;
+		}
+		L0556_i_Direction++;
+	}
+}
+
+bool GroupMan::f227_isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
+	int L1637_i_Temp;
+
+	switch (dir) { /* If direction is not 'West' then swap variables so that the same test as for west can be applied */
+	case kDirSouth:
+		L1637_i_Temp = srcMapX;
+		srcMapX = destMapY;
+		destMapY = L1637_i_Temp;
+		L1637_i_Temp = destMapX;
+		destMapX = srcMapY;
+		srcMapY = L1637_i_Temp;
+		break;
+	case kDirEast:
+		L1637_i_Temp = srcMapX;
+		srcMapX = destMapX;
+		destMapX = L1637_i_Temp;
+		L1637_i_Temp = destMapY;
+		destMapY = srcMapY;
+		srcMapY = L1637_i_Temp;
+		break;
+	case kDirNorth:
+		L1637_i_Temp = srcMapX;
+		srcMapX = srcMapY;
+		srcMapY = L1637_i_Temp;
+		L1637_i_Temp = destMapX;
+		destMapX = destMapY;
+		destMapY = L1637_i_Temp;
+	}
+	return ((srcMapX -= (destMapX - 1)) > 0) && ((((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY) <= srcMapX);
+}
+
+bool GroupMan::f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack, bool magicAttack, int16 ticks) {
+	Door* L0573_ps_Door;
+	byte* L0574_puc_Square;
+	TimelineEvent L0575_s_Event;
+
+	L0573_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY);
+	if ((magicAttack && !L0573_ps_Door->isMagicDestructible()) || (!magicAttack && !L0573_ps_Door->isMeleeDestructible())) {
+		return false;
+	}
+	if (attack >= _vm->_dungeonMan->_g275_currMapDoorInfo[L0573_ps_Door->getType()]._defense) {
+		L0574_puc_Square = &_vm->_dungeonMan->_g271_currMapData[mapX][mapY];
+		if (Square(*L0574_puc_Square).getDoorState() == k4_doorState_CLOSED) {
+			if (ticks) {
+				M33_setMapAndTime(L0575_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ticks);
+				L0575_s_Event._type = k2_TMEventTypeDoorDestruction;
+				L0575_s_Event._priority = 0;
+				L0575_s_Event._B._location._mapX = mapX;
+				L0575_s_Event._B._location._mapY = mapY;
+				_vm->_timeline->f238_addEventGetEventIndex(&L0575_s_Event);
+			} else {
+				((Square*)L0574_puc_Square)->setDoorState(k5_doorState_DESTROYED);
+			}
+			return true;
+		}
+	}
+	return false;
+}
+
+Thing GroupMan::f175_groupGetThing(int16 mapX, int16 mapY) {
+	Thing L0317_T_Thing;
+
+	L0317_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
+	while ((L0317_T_Thing != Thing::_endOfList) && ((L0317_T_Thing).getType() != k4_GroupThingType)) {
+		L0317_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0317_T_Thing);
+	}
+	return L0317_T_Thing;
+}
+
+int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group* group, uint16 creatureIndex, int16 mapX, int16 mapY, int16 damage, bool notMoving) {
+	uint16 L0374_ui_Multiple;
+#define AL0374_ui_EventIndex    L0374_ui_Multiple
+#define AL0374_ui_CreatureIndex L0374_ui_Multiple
+#define AL0374_ui_CreatureSize  L0374_ui_Multiple
+#define AL0374_ui_Attack        L0374_ui_Multiple
+	uint16 L0375_ui_Multiple;
+#define AL0375_ui_Outcome           L0375_ui_Multiple
+#define AL0375_ui_EventType         L0375_ui_Multiple
+#define AL0375_ui_NextCreatureIndex L0375_ui_Multiple
+	CreatureInfo* L0376_ps_CreatureInfo;
+	TimelineEvent* L0377_ps_Event;
+	ActiveGroup* L0378_ps_ActiveGroup = nullptr;
+	uint16 L0379_ui_CreatureCount;
+	uint16 L0380_ui_Multiple = 0;
+#define AL0380_ui_CreatureType   L0380_ui_Multiple
+#define AL0380_ui_FearResistance L0380_ui_Multiple
+	uint16 L0381_ui_GroupCells;
+	uint16 L0382_ui_GroupDirections;
+	bool L0383_B_CurrentMapIsPartyMap;
+	uint16 L0384_ui_Cell;
+
+
+	L0376_ps_CreatureInfo = &g243_CreatureInfo[AL0380_ui_CreatureType = group->_type];
+	if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) /* Lord Chaos cannot be damaged */
+		goto T0190024;
+	if (group->_health[creatureIndex] <= damage) {
+		L0381_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(group, _vm->_dungeonMan->_g272_currMapIndex);
+		L0384_ui_Cell = (L0381_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0381_ui_GroupCells, creatureIndex);
+		if (!(L0379_ui_CreatureCount = group->getCount())) { /* If there is a single creature in the group */
+			if (notMoving) {
+				f188_dropGroupPossessions(mapX, mapY, _vm->_groupMan->f175_groupGetThing(mapX, mapY), k2_soundModePlayOneTickLater);
+				f189_delete(mapX, mapY);
+			}
+			AL0375_ui_Outcome = k2_outcomeKilledAllCreaturesInGroup;
+		} else { /* If there are several creatures in the group */
+			L0382_ui_GroupDirections = _vm->_groupMan->f147_getGroupDirections(group, _vm->_dungeonMan->_g272_currMapIndex);
+			if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
+				if (notMoving) {
+					f186_dropCreatureFixedPossessions(AL0380_ui_CreatureType, mapX, mapY, L0384_ui_Cell, k2_soundModePlayOneTickLater);
+				} else {
+					_g392_dropMovingCreatureFixedPossessionsCell[_g391_dropMovingCreatureFixedPossCellCount++] = L0384_ui_Cell;
+				}
+			}
+			if (L0383_B_CurrentMapIsPartyMap = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) {
+				L0378_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
+			}
+			if (group->getBehaviour() == k6_behavior_ATTACK) {
+				L0377_ps_Event = _vm->_timeline->_g370_events;
+				for (AL0374_ui_EventIndex = 0; AL0374_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; AL0374_ui_EventIndex++) {
+					if ((M29_map(L0377_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) &&
+						(L0377_ps_Event->_B._location._mapX == mapX) &&
+						(L0377_ps_Event->_B._location._mapY == mapY) &&
+						((AL0375_ui_EventType = L0377_ps_Event->_type) > k32_TMEventTypeUpdateAspectGroup) &&
+						(AL0375_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1)) {
+						if (AL0375_ui_EventType < k37_TMEventTypeUpdateBehaviourGroup) {
+							AL0375_ui_EventType -= k33_TMEventTypeUpdateAspectCreature_0; /* Get creature index for events 33 to 36 */
+						} else {
+							AL0375_ui_EventType -= k38_TMEventTypeUpdateBehaviour_0; /* Get creature index for events 38 to 41 */
+						}
+						if (AL0375_ui_NextCreatureIndex == creatureIndex) {
+							_vm->_timeline->f237_deleteEvent(AL0374_ui_EventIndex);
+						} else {
+							if (AL0375_ui_NextCreatureIndex > creatureIndex) {
+								L0377_ps_Event->_type -= 1;
+								_vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(AL0374_ui_EventIndex));
+							}
+						}
+					}
+					L0377_ps_Event++;
+				}
+				if (L0383_B_CurrentMapIsPartyMap && ((AL0380_ui_FearResistance = L0376_ps_CreatureInfo->M57_getFearResistance()) != k15_immuneToFear) && ((AL0380_ui_FearResistance += L0379_ui_CreatureCount - 1) < (_vm->getRandomNumber(16)))) { /* Test if the death of a creature frigthens the remaining creatures in the group */
+					L0378_ps_ActiveGroup->_delayFleeingFromTarget = _vm->getRandomNumber(100 - (AL0380_ui_FearResistance << 2)) + 20;
+					group->setBehaviour(k5_behavior_FLEE);
+				}
+			}
+			for (AL0375_ui_NextCreatureIndex = AL0374_ui_CreatureIndex = creatureIndex; AL0374_ui_CreatureIndex < L0379_ui_CreatureCount; AL0374_ui_CreatureIndex++) {
+				AL0375_ui_NextCreatureIndex++;
+				group->_health[AL0374_ui_CreatureIndex] = group->_health[AL0375_ui_NextCreatureIndex];
+				L0382_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0382_ui_GroupDirections, AL0374_ui_CreatureIndex, _vm->_groupMan->M50_getCreatureValue(L0382_ui_GroupDirections, AL0375_ui_NextCreatureIndex));
+				L0381_ui_GroupCells = f178_getGroupValueUpdatedWithCreatureValue(L0381_ui_GroupCells, AL0374_ui_CreatureIndex, _vm->_groupMan->M50_getCreatureValue(L0381_ui_GroupCells, AL0375_ui_NextCreatureIndex));
+				if (L0383_B_CurrentMapIsPartyMap) {
+					L0378_ps_ActiveGroup->_aspect[AL0374_ui_CreatureIndex] = L0378_ps_ActiveGroup->_aspect[AL0375_ui_NextCreatureIndex];
+				}
+			}
+			L0381_ui_GroupCells &= 0x003F;
+			_vm->_dungeonMan->f146_setGroupCells(group, L0381_ui_GroupCells, _vm->_dungeonMan->_g272_currMapIndex);
+			_vm->_dungeonMan->f148_setGroupDirections(group, L0382_ui_GroupDirections, _vm->_dungeonMan->_g272_currMapIndex);
+			group->setCount(group->getCount() - 1);
+			AL0375_ui_Outcome = k1_outcomeKilledSomeCreaturesInGroup;
+		}
+		if ((AL0374_ui_CreatureSize = getFlag(L0376_ps_CreatureInfo->_attributes, k0x0003_MaskCreatureInfo_size)) == k0_MaskCreatureSizeQuarter) {
+			AL0374_ui_Attack = 110;
+		} else {
+			if (AL0374_ui_CreatureSize == k1_MaskCreatureSizeHalf) {
+				AL0374_ui_Attack = 190;
+			} else {
+				AL0374_ui_Attack = 255;
+			}
+		}
+		_vm->_projexpl->f213_explosionCreate(Thing::_explSmoke, AL0374_ui_Attack, mapX, mapY, L0384_ui_Cell); /* BUG0_66 Smoke is placed on the source map instead of the destination map when a creature dies by falling through a pit. The game has a special case to correctly drop the creature possessions on the destination map but there is no such special case for the smoke. Note that the death must be caused by the damage of the fall (there is no smoke if the creature is removed because its type is not allowed on the destination map). However this bug has no visible consequence because of BUG0_26: the smoke explosion falls in the pit right after being placed in the dungeon and before being drawn on screen so it is only visible on the destination square */
+		return AL0375_ui_Outcome;
+	}
+	if (damage > 0) {
+		group->_health[creatureIndex] -= damage;
+	}
+T0190024:
+	return k0_outcomeKilledNoCreaturesInGroup;
+}
+
+void GroupMan::f189_delete(int16 mapX, int16 mapY) {
+	Thing L0372_T_GroupThing;
+	Group* L0373_ps_Group;
+
+
+	if ((L0372_T_GroupThing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) {
+		return;
+	}
+	L0373_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0372_T_GroupThing);
+	for (uint16 i = 0; i < 4; ++i)
+		L0373_ps_Group->_health[i] = 0;
+	_vm->_movsens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
+	L0373_ps_Group->_nextThing = Thing::_none;
+	if (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) {
+		_vm->_groupMan->_g375_activeGroups[L0373_ps_Group->getActiveGroupIndex()]._groupThingIndex = -1;
+		_g377_currActiveGroupCount--;
+	}
+	f181_groupDeleteEvents(mapX, mapY);
+}
+
+void GroupMan::f181_groupDeleteEvents(int16 mapX, int16 mapY) {
+	int16 L0334_i_EventIndex;
+	uint16 L0335_ui_EventType;
+	TimelineEvent* L0336_ps_Event;
+
+
+	L0336_ps_Event = _vm->_timeline->_g370_events;
+	for (L0334_i_EventIndex = 0; L0334_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0334_i_EventIndex++) {
+		if ((M29_map(L0336_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) &&
+			((L0335_ui_EventType = L0336_ps_Event->_type) > k29_TMEventTypeGroupReactionDangerOnSquare - 1) && (L0335_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1) &&
+			(L0336_ps_Event->_B._location._mapX == mapX) && (L0336_ps_Event->_B._location._mapY == mapY)) {
+			_vm->_timeline->f237_deleteEvent(L0334_i_EventIndex);
+		}
+		L0336_ps_Event++;
+	}
+}
+
+uint16 GroupMan::f178_getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatreVal) {
+	creatreVal &= 0x0003;
+	creatreVal <<= (creatureIndex <<= 1);
+	return creatreVal | (groupVal & ~(3 << creatreVal));
+}
+
+int16 GroupMan::f191_getDamageAllCreaturesOutcome(Group* group, int16 mapX, int16 mapY, int16 attack, bool notMoving) {
+	uint16 L0385_ui_RandomAttack;
+	int16 L0386_i_CreatureIndex;
+	int16 L0387_i_Outcome;
+	bool L0388_B_KilledSomeCreatures;
+	bool L0389_B_KilledAllCreatures;
+
+
+	L0388_B_KilledSomeCreatures = false;
+	L0389_B_KilledAllCreatures = true;
+	_g391_dropMovingCreatureFixedPossCellCount = 0;
+	if (attack > 0) {
+		L0386_i_CreatureIndex = group->getCount();
+		attack -= (L0385_ui_RandomAttack = (attack >> 3) + 1);
+		L0385_ui_RandomAttack <<= 1;
+		do {
+			L0389_B_KilledAllCreatures = (L0387_i_Outcome = f190_groupGetDamageCreatureOutcome(group, L0386_i_CreatureIndex, mapX, mapY, attack + _vm->getRandomNumber(L0385_ui_RandomAttack), notMoving)) && L0389_B_KilledAllCreatures;
+			L0388_B_KilledSomeCreatures = L0388_B_KilledSomeCreatures || L0387_i_Outcome;
+		} while (L0386_i_CreatureIndex--);
+		if (L0389_B_KilledAllCreatures) {
+			return k2_outcomeKilledAllCreaturesInGroup;
+		}
+		if (L0388_B_KilledSomeCreatures) {
+			return k1_outcomeKilledSomeCreaturesInGroup;
+		}
+		return k0_outcomeKilledNoCreaturesInGroup;
+	} else {
+		return k0_outcomeKilledNoCreaturesInGroup;
+	}
+}
+
+int16 GroupMan::f192_groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack) {
+	int16 L0390_i_PoisonResistance;
+
+
+	if (!poisonAttack || ((L0390_i_PoisonResistance = g243_CreatureInfo[creatreType].M61_poisonResistance()) == k15_immuneToPoison)) {
+		return 0;
+	}
+	return ((poisonAttack + _vm->getRandomNumber(4)) << 3) / ++L0390_i_PoisonResistance;
+}
+
+void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks) {
+	Group* L0444_ps_Group;
+	ActiveGroup* L0445_ps_ActiveGroup;
+	int16 L0446_i_Multiple;
+#define AL0446_i_EventType           L0446_i_Multiple
+#define AL0446_i_Direction           L0446_i_Multiple
+#define AL0446_i_Ticks               L0446_i_Multiple
+#define AL0446_i_Distance            L0446_i_Multiple
+#define AL0446_i_Behavior2Or3        L0446_i_Multiple
+#define AL0446_i_CreatureAspectIndex L0446_i_Multiple
+#define AL0446_i_Range               L0446_i_Multiple
+#define AL0446_i_CreatureAttributes  L0446_i_Multiple
+#define AL0446_i_Cell                L0446_i_Multiple
+#define AL0446_i_GroupCellsCriteria  L0446_i_Multiple
+	int16 L0447_i_Multiple;
+#define AL0447_i_Behavior           L0447_i_Multiple
+#define AL0447_i_CreatureIndex      L0447_i_Multiple
+#define AL0447_i_ReferenceDirection L0447_i_Multiple
+#define AL0447_i_Ticks              L0447_i_Multiple
+	CreatureInfo L0448_s_CreatureInfo;
+	Thing L0449_T_GroupThing;
+	int16 L0450_i_Multiple;
+#define AL0450_i_DestinationMapX  L0450_i_Multiple
+#define AL0450_i_DistanceXToParty L0450_i_Multiple
+#define AL0450_i_TargetMapX       L0450_i_Multiple
+	int16 L0451_i_Multiple;
+#define AL0451_i_DestinationMapY  L0451_i_Multiple
+#define AL0451_i_DistanceYToParty L0451_i_Multiple
+#define AL0451_i_TargetMapY       L0451_i_Multiple
+	int16 L0452_i_DistanceToVisibleParty = 0;
+	bool L0453_B_NewGroupDirectionFound;
+	int16 L0454_i_PrimaryDirectionToOrFromParty;
+	bool L0455_B_CurrentEventTypeIsNotUpdateBehavior;
+	bool L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls;
+	bool L0457_B_MoveToPriorLocation;
+	bool L0458_B_SetBehavior7_ApproachAfterReaction = false;
+	int16 L0459_i_CreatureSize;
+	uint16 L0460_ui_CreatureCount;
+	int16 L0461_i_MovementTicks;
+	int16 L0462_i_TicksSinceLastMove;
+	bool L0463_B_Archenemy;
+	int32 L0464_l_NextAspectUpdateTime;
+	TimelineEvent L0465_s_NextEvent;
+
+
+	/* If the party is not on the map specified in the event and the event type is not one of 32, 33, 37, 38 then the event is ignored */
+	if ((_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) && ((AL0446_i_EventType = eventType) != k37_TMEventTypeUpdateBehaviourGroup) && (AL0446_i_EventType != k32_TMEventTypeUpdateAspectGroup) && (AL0446_i_EventType != k38_TMEventTypeUpdateBehaviour_0) && (AL0446_i_EventType != k33_TMEventTypeUpdateAspectCreature_0))
+		goto T0209139_Return;
+	/* If there is no creature at the location specified in the event then the event is ignored */
+	if ((L0449_T_GroupThing = _vm->_groupMan->f175_groupGetThing(eventMapX, eventMapY)) == Thing::_endOfList) {
+		goto T0209139_Return;
+	}
+	L0444_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0449_T_GroupThing);
+	L0448_s_CreatureInfo = g243_CreatureInfo[L0444_ps_Group->_type];
+	/* Update the event */
+	M33_setMapAndTime(L0465_s_NextEvent._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime);
+	L0465_s_NextEvent._priority = 255 - L0448_s_CreatureInfo._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
+	L0465_s_NextEvent._B._location._mapX = eventMapX;
+	L0465_s_NextEvent._B._location._mapY = eventMapY;
+	/* If the creature is not on the party map then try and move the creature in a random direction and place a new event 37 in the timeline for the next creature movement */
+	if (_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) {
+		if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->getRandomNumber(4), false)) { /* BUG0_67 A group that is not on the party map may wrongly move or not move into a teleporter. Normally, a creature type with Wariness >= 10 (Vexirk, Materializer / Zytaz, Demon, Lord Chaos, Red Dragon / Dragon) would only move into a teleporter if the creature type is allowed on the destination map. However, the variable G0380_T_CurrentGroupThing identifying the group is not set before being used by F0139_DUNGEON_IsCreatureAllowedOnMap called by f202_isMovementPossible so the check to see if the creature type is allowed may operate on another creature type and thus return an incorrect result, causing the creature to teleport while it should not, or not to teleport while it should */
+			AL0450_i_DestinationMapX = eventMapX;
+			AL0451_i_DestinationMapY = eventMapY;
+			AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
+			if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
+				goto T0209139_Return;
+			L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX;
+			L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY;
+		}
+		L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup;
+		AL0446_i_Ticks = MAX(ABS(_vm->_dungeonMan->_g272_currMapIndex - _vm->_dungeonMan->_g309_partyMapIndex) << 4, L0448_s_CreatureInfo._movementTicks << 1);
+		/* BUG0_68 A group moves or acts with a wrong timing. Event is added below but L0465_s_NextEvent.C.Ticks has not been initialized. No consequence while the group is not on the party map. When the party enters the group map the first group event may have a wrong timing */
+T0209005_AddEventAndReturn:
+		L0465_s_NextEvent._mapTime += AL0446_i_Ticks;
+		_vm->_timeline->f238_addEventGetEventIndex(&L0465_s_NextEvent);
+		goto T0209139_Return;
+	}
+	/* If the creature is Lord Chaos then ignore the event if the game is won. Initialize data to analyze Fluxcages */
+	if (L0463_B_Archenemy = getFlag(L0448_s_CreatureInfo._attributes, k0x2000_MaskCreatureInfo_archenemy)) {
+		if (_vm->_g302_gameWon) {
+			goto T0209139_Return;
+		}
+		_g386_fluxCageCount = 0;
+		_g385_fluxCages[0] = 0;
+	}
+	L0445_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[L0444_ps_Group->getActiveGroupIndex()];
+	if ((L0462_i_TicksSinceLastMove = (unsigned char)_vm->_g313_gameTime - L0445_ps_ActiveGroup->_lastMoveTime) < 0) {
+		L0462_i_TicksSinceLastMove += 256;
+	}
+	if ((L0461_i_MovementTicks = L0448_s_CreatureInfo._movementTicks) == k255_immobile) {
+		L0461_i_MovementTicks = 100;
+	}
+	if (_vm->_championMan->_g407_party._freezeLifeTicks && !L0463_B_Archenemy) { /* If life is frozen and the creature is not Lord Chaos (Lord Chaos is immune to Freeze Life) then reschedule the event later (except for reactions which are ignored when life if frozen) */
+		if (eventType < 0)
+			goto T0209139_Return;
+		L0465_s_NextEvent._type = eventType;
+		L0465_s_NextEvent._C._ticks = ticks;
+		AL0446_i_Ticks = 4; /* Retry in 4 ticks */
+		goto T0209005_AddEventAndReturn;
+	}
+	/* If the specified event type is a 'reaction' instead of a real event from the timeline then create the corresponding reaction event with a delay:
+	For event kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, the reaction time is 1 tick
+	For event kM2_TMEventTypeCreateReactionEvent30HitByProjectile and kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, the reaction time may be 1 tick or slower: slow moving creatures react more slowly. The more recent is the last creature move, the slower the reaction */
+	if (eventType < 0) {
+		L0465_s_NextEvent._type = eventType + k32_TMEventTypeUpdateAspectGroup;
+		if ((eventType == kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) || ((AL0446_i_Ticks = ((L0461_i_MovementTicks + 2) >> 2) - L0462_i_TicksSinceLastMove) < 1)) { /* AL0446_i_Ticks is the reaction time */
+			AL0446_i_Ticks = 1; /* Retry in 1 tick */
+		}
+		goto T0209005_AddEventAndReturn; /* BUG0_68 A group moves or acts with a wrong timing. Event is added but L0465_s_NextEvent.C.Ticks has not been initialized */
+	}
+	AL0447_i_Behavior = L0444_ps_Group->getBehaviour();
+	L0460_ui_CreatureCount = L0444_ps_Group->getCount();
+	L0459_i_CreatureSize = getFlag(L0448_s_CreatureInfo._attributes, k0x0003_MaskCreatureInfo_size);
+	AL0450_i_DistanceXToParty = ((AL0446_i_Distance = eventMapX - _vm->_dungeonMan->_g306_partyMapX) < 0) ? -AL0446_i_Distance : AL0446_i_Distance;
+	AL0451_i_DistanceYToParty = ((AL0446_i_Distance = eventMapY - _vm->_dungeonMan->_g307_partyMapY) < 0) ? -AL0446_i_Distance : AL0446_i_Distance;
+	_g378_currentGroupMapX = eventMapX;
+	_g379_currentGroupMapY = eventMapY;
+	_g380_currGroupThing = L0449_T_GroupThing;
+	_g384_groupMovementTestedDirections[0] = 0;
+	_g381_currGroupDistanceToParty = f226_getDistanceBetweenSquares(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+	_g382_currGroupPrimaryDirToParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+	_g383_currGroupSecondaryDirToParty = _vm->_projexpl->_g363_secondaryDirToOrFromParty;
+	L0464_l_NextAspectUpdateTime = 0;
+	L0455_B_CurrentEventTypeIsNotUpdateBehavior = true;
+	if (eventType <= k31_TMEventTypeGroupReactionPartyIsAdjecent) { /* Process Reaction events 29 to 31 */
+		switch (eventType = eventType - k32_TMEventTypeUpdateAspectGroup) {
+		case kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent: /* This event is used when the party bumps into a group or attacks a group physically (not with a spell). It causes the creature behavior to change to attack if it is not already attacking the party or fleeing from target */
+			if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) {
+				f181_groupDeleteEvents(eventMapX, eventMapY);
+				goto T0209044_SetBehavior6_Attack;
+			}
+			L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
+			L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+			goto T0209139_Return;
+		case kM2_TMEventTypeCreateReactionEvent30HitByProjectile: /* This event is used for the reaction of a group after a projectile impacted with one creature in the group (some creatures may have been killed) */
+			if ((AL0447_i_Behavior == k6_behavior_ATTACK) || (AL0447_i_Behavior == k5_behavior_FLEE)) /* If the creature is attacking the party or fleeing from the target then there is no reaction */
+				goto T0209139_Return;
+			if ((AL0446_i_Behavior2Or3 = ((AL0447_i_Behavior == k3_behavior_USELESS) || (AL0447_i_Behavior == k2_behavior_USELESS))) || (_vm->getRandomNumber(4))) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances */
+				if (!f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { /* If the group cannot see the party then look in a random direction to try and search for the party */
+					L0458_B_SetBehavior7_ApproachAfterReaction = L0453_B_NewGroupDirectionFound = false;
+					goto T0209073_SetDirectionGroup;
+				}
+				if (AL0446_i_Behavior2Or3 || (_vm->getRandomNumber(4))) /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances then no reaction */
+					goto T0209139_Return;
+			} /* No 'break': proceed to instruction after the next 'case' below. Reaction is to move in a random direction to try and avoid other projectiles */
+		case kM3_TMEventTypeCreateReactionEvent29DangerOnSquare: /* This event is used when some creatures in the group were killed by a Poison Cloud or by a closing door or if Lord Chaos is surrounded by 3 Fluxcages. It causes the creature to move in a random direction to avoid the danger */
+			L0458_B_SetBehavior7_ApproachAfterReaction = (AL0447_i_Behavior == k6_behavior_ATTACK); /* If the creature behavior is 'Attack' and it has to move to avoid danger then it will change its behavior to 'Approach' after the movement */
+			L0453_B_NewGroupDirectionFound = false;
+			goto T0209058_MoveInRandomDirection;
+		}
+	}
+	if (eventType < k37_TMEventTypeUpdateBehaviourGroup) { /* Process Update Aspect events 32 to 36 */
+		L0465_s_NextEvent._type = eventType + 5;
+		if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+			if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) {
+				if (M38_distance(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, eventMapX, eventMapY) <= 1)
+					goto T0209044_SetBehavior6_Attack;
+				if (((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k3_behavior_USELESS)) && (AL0447_i_Behavior != k7_behavior_APPROACH)) /* BUG0_00 Useless code. Behavior cannot be 3 because this value is never used. Moreover, the second condition in the && is redundant (if the value is 0 or 3, it cannot be 7). The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */
+					goto T0209054_SetBehavior7_Approach;
+			}
+			L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
+			L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+		}
+		if (AL0447_i_Behavior == k6_behavior_ATTACK) {
+			AL0446_i_CreatureAspectIndex = eventType - k33_TMEventTypeUpdateAspectCreature_0; /* Value -1 for event 32, meaning aspect will be updated for all creatures in the group */
+			L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0446_i_CreatureAspectIndex, getFlag(L0445_ps_ActiveGroup->_aspect[AL0446_i_CreatureAspectIndex], k0x0080_MaskActiveGroupIsAttacking));
+			goto T0209136;
+		}
+		if ((AL0450_i_DistanceXToParty > 3) || (AL0451_i_DistanceYToParty > 3)) {
+			L0464_l_NextAspectUpdateTime = _vm->_g313_gameTime + ((L0448_s_CreatureInfo._animationTicks >> 4) & 0xF);
+			goto T0209136;
+		}
+	} else { /* Process Update Behavior events 37 to 41 */
+		L0455_B_CurrentEventTypeIsNotUpdateBehavior = false;
+		if (ticks) {
+			L0464_l_NextAspectUpdateTime = _vm->_g313_gameTime;
+		}
+		if (eventType == k37_TMEventTypeUpdateBehaviourGroup) { /* Process event 37, Update Group Behavior */
+			if ((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k2_behavior_USELESS) || (AL0447_i_Behavior == k3_behavior_USELESS)) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */
+				if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+					if ((L0452_i_DistanceToVisibleParty <= (L0448_s_CreatureInfo.M56_getAttackRange())) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) { /* If the creature is in range for attack and on the same row or column as the party on the map */
+T0209044_SetBehavior6_Attack:
+						if (eventType == kM2_TMEventTypeCreateReactionEvent30HitByProjectile) {
+							f181_groupDeleteEvents(eventMapX, eventMapY);
+						}
+						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
+						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+						L0444_ps_Group->setBehaviour(k6_behavior_ATTACK);
+						AL0446_i_Direction = _g382_currGroupPrimaryDirToParty;
+						for (AL0447_i_CreatureIndex = L0460_ui_CreatureCount; AL0447_i_CreatureIndex >= 0; AL0447_i_CreatureIndex--) {
+							if ((_vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) != AL0446_i_Direction) &&
+								((!AL0447_i_CreatureIndex) || (!_vm->getRandomNumber(2)))) {
+								f205_setDirection(L0445_ps_ActiveGroup, AL0446_i_Direction, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
+								M32_setTime(L0465_s_NextEvent._mapTime, _vm->_g313_gameTime + _vm->getRandomNumber(4) + 2); /* Random delay represents the time for the creature to turn */
+							} else {
+								M32_setTime(L0465_s_NextEvent._mapTime, _vm->_g313_gameTime + 1);
+							}
+							if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) {
+								L0465_s_NextEvent._mapTime += MIN((uint16)((L0448_s_CreatureInfo._attackTicks >> 1) + _vm->getRandomNumber(4)), ticks);
+							}
+							L0465_s_NextEvent._type = k38_TMEventTypeUpdateBehaviour_0 + AL0447_i_CreatureIndex;
+							f208_groupAddEvent(&L0465_s_NextEvent, f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false));
+						}
+						goto T0209139_Return;
+					}
+					if (AL0447_i_Behavior != k2_behavior_USELESS) { /* BUG0_00 Useless code. Behavior cannot be 2 because this value is never used */
+T0209054_SetBehavior7_Approach:
+						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
+						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
+						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+						L0465_s_NextEvent._mapTime += 1;
+						goto T0209134_SetEvent37;
+					}
+				} else {
+					if (AL0447_i_Behavior == k0_behavior_WANDER) {
+						if (L0454_i_PrimaryDirectionToOrFromParty = f201_getSmelledPartyPrimaryDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY)) {
+							L0454_i_PrimaryDirectionToOrFromParty--;
+							L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = false;
+							goto T0209085_SingleSquareMove;
+						}
+						L0453_B_NewGroupDirectionFound = false;
+						if (_vm->getRandomNumber(2)) {
+T0209058_MoveInRandomDirection:
+							AL0446_i_Direction = _vm->getRandomNumber(4);
+							AL0447_i_ReferenceDirection = AL0446_i_Direction;
+							L0457_B_MoveToPriorLocation = false;
+							do {
+								AL0450_i_DestinationMapX = eventMapX;
+								AL0451_i_DestinationMapY = eventMapY;
+								AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
+								if (((L0445_ps_ActiveGroup->_priorMapX != AL0450_i_DestinationMapX) ||
+									(L0445_ps_ActiveGroup->_priorMapY != AL0451_i_DestinationMapY) ||
+									 (L0457_B_MoveToPriorLocation = !_vm->getRandomNumber(4))) /* 1/4 chance of moving back to the square that the creature comes from */
+									&& f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction, false)) {
+T0209061_MoveGroup:
+									if (L0453_B_NewGroupDirectionFound = ((AL0447_i_Ticks = (L0461_i_MovementTicks >> 1) - L0462_i_TicksSinceLastMove) <= 0)) {
+										if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
+											goto T0209139_Return;
+										L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX;
+										L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY;;
+										L0445_ps_ActiveGroup->_priorMapX = eventMapX;
+										L0445_ps_ActiveGroup->_priorMapY = eventMapY;
+										L0445_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime;
+									} else {
+										L0461_i_MovementTicks = AL0447_i_Ticks;
+										L0462_i_TicksSinceLastMove = -1;
+									}
+									break;
+								}
+								if (_g390_groupMovementBlockedByParty) {
+									if ((eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) &&
+										((L0444_ps_Group->getBehaviour() != k5_behavior_FLEE) ||
+										 !f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false) ||
+										 _vm->getRandomNumber(2)))
+										goto T0209044_SetBehavior6_Attack;
+									L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
+									L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+								}
+							} while ((AL0446_i_Direction = returnNextVal(AL0446_i_Direction)) != AL0447_i_ReferenceDirection);
+						}
+						if (!L0453_B_NewGroupDirectionFound &&
+							(L0462_i_TicksSinceLastMove != -1) &&
+							L0463_B_Archenemy &&
+							((eventType == kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) || !_vm->getRandomNumber(4))) { /* BUG0_15 The game hangs when you close a door on Lord Chaos. A condition is missing in the code to manage creatures and this may create an infinite loop between two parts in the code */
+							_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0454_i_PrimaryDirectionToOrFromParty = _vm->getRandomNumber(4));
+							goto T0209089_DoubleSquareMove; /* BUG0_69 Memory corruption when you close a door on Lord Chaos. The local variable (L0454_i_PrimaryDirectionToOrFromParty) containing the direction where Lord Chaos tries to move may be used as an array index without being initialized and cause memory corruption */
+						}
+						if (L0453_B_NewGroupDirectionFound || ((!_vm->getRandomNumber(4) || (L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.M55_getSmellRange())) && (eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare))) {
+T0209073_SetDirectionGroup:
+							if (!L0453_B_NewGroupDirectionFound && (L0462_i_TicksSinceLastMove >= 0)) { /* If direction is not found yet then look around in a random direction */
+								AL0446_i_Direction = _vm->getRandomNumber(4);
+							}
+							f206_groupSetDirGroup(L0445_ps_ActiveGroup, AL0446_i_Direction, L0460_ui_CreatureCount, L0459_i_CreatureSize);
+						}
+						/* If event is kM3_TMEventTypeCreateReactionEvent29DangerOnSquare or kM2_TMEventTypeCreateReactionEvent30HitByProjectile */
+						if (eventType < kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) {
+							if (!L0453_B_NewGroupDirectionFound)
+								goto T0209139_Return;
+							if (L0458_B_SetBehavior7_ApproachAfterReaction) {
+								L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
+							}
+							f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+						}
+					}
+				}
+			} else {
+				if (AL0447_i_Behavior == k7_behavior_APPROACH) {
+					if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+						if ((L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.M56_getAttackRange()) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) /* If the creature is in range for attack and on the same row or column as the party on the map */
+							goto T0209044_SetBehavior6_Attack;
+T0209081_RunTowardParty:
+						L0461_i_MovementTicks++;
+						L0461_i_MovementTicks = L0461_i_MovementTicks >> 1; /* Running speed is half the movement ticks */
+						AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX);
+						AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY);
+					} else {
+T0209082_WalkTowardTarget:
+						AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_targetMapX;
+						AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY;
+						/* If the creature reached its target but the party is not there anymore */
+						if ((eventMapX == AL0450_i_TargetMapX) && (eventMapY == AL0451_i_TargetMapY)) {
+							L0453_B_NewGroupDirectionFound = false;
+							L0444_ps_Group->setBehaviour(k0_behavior_WANDER);
+							goto T0209073_SetDirectionGroup;
+						}
+					}
+					L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true;
+T0209084_SingleSquareMoveTowardParty:
+					L0454_i_PrimaryDirectionToOrFromParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY);
+T0209085_SingleSquareMove:
+					if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls) ||
+						f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls && _vm->getRandomNumber(2)) ||
+						f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction), false) ||
+						(!_vm->getRandomNumber(4) && f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty), false))) {
+						AL0450_i_DestinationMapX = eventMapX;
+						AL0451_i_DestinationMapY = eventMapY;
+						AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
+						goto T0209061_MoveGroup;
+					}
+					if (L0463_B_Archenemy) {
+T0209089_DoubleSquareMove:
+						f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false); /* BUG0_00 Useless code. Returned value is ignored. When Lord Chaos teleports two squares away the ability to move to the first square is ignored which means Lord Chaos can teleport through walls or any other obstacle */
+						if (f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty) ||
+							f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty) ||
+							(_g386_fluxCageCount && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction))) ||
+							((_g386_fluxCageCount >= 2) && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty)))) {
+							AL0450_i_DestinationMapX = eventMapX;
+							AL0451_i_DestinationMapY = eventMapY;
+							AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2;
+							warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+							goto T0209061_MoveGroup;
+						}
+					}
+					f206_groupSetDirGroup(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, L0460_ui_CreatureCount, L0459_i_CreatureSize);
+				} else {
+					if (AL0447_i_Behavior == k5_behavior_FLEE) {
+T0209094_FleeFromTarget:
+						L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true;
+						/* If the creature can see the party then update target coordinates */
+						if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+							AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX);
+							AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY);
+						} else {
+							if (!(--(L0445_ps_ActiveGroup->_delayFleeingFromTarget))) { /* If the creature is not afraid anymore then stop fleeing from target */
+T0209096_SetBehavior0_Wander:
+								L0453_B_NewGroupDirectionFound = false;
+								L0444_ps_Group->setBehaviour(k0_behavior_WANDER);
+								goto T0209073_SetDirectionGroup;
+							}
+							if (_vm->getRandomNumber(2)) {
+								/* If the creature cannot move and the party is adjacent then stop fleeing */
+								if (!f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false)) {
+									if (M38_distance(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)
+										goto T0209096_SetBehavior0_Wander;
+								}
+								/* Set creature target to the home square where the creature was located when the party entered the map */
+								AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_homeMapX;
+								AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_homeMapY;
+								goto T0209084_SingleSquareMoveTowardParty;
+							}
+							AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_targetMapX;
+							AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY;
+						}
+						/* Try and flee from the party (opposite direction) */
+						L0454_i_PrimaryDirectionToOrFromParty = returnOppositeDir((direction)f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY));
+						_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnOppositeDir((direction)_vm->_projexpl->_g363_secondaryDirToOrFromParty);
+						L0461_i_MovementTicks -= (L0461_i_MovementTicks >> 2);
+						goto T0209085_SingleSquareMove;
+					}
+				}
+			}
+		} else { /* Process events 38 to 41, Update Creature Behavior */
+			if (AL0447_i_Behavior == k5_behavior_FLEE) {
+				if (L0460_ui_CreatureCount) {
+					f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+				}
+				goto T0209094_FleeFromTarget;
+			}
+			/* If the creature is attacking, then compute the next aspect update time and the next attack time */
+			if (getFlag(L0445_ps_ActiveGroup->_aspect[AL0447_i_CreatureIndex = eventType - k38_TMEventTypeUpdateBehaviour_0], k0x0080_MaskActiveGroupIsAttacking)) {
+				L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false);
+				L0465_s_NextEvent._mapTime += ((AL0447_i_Ticks = L0448_s_CreatureInfo._attackTicks) + _vm->getRandomNumber(4) - 1);
+				if (AL0447_i_Ticks > 15) {
+					L0465_s_NextEvent._mapTime += _vm->getRandomNumber(8) - 2;
+				}
+			} else { /* If the creature is not attacking, then try attacking if possible */
+				if (AL0447_i_CreatureIndex > L0460_ui_CreatureCount) { /* Ignore event if it is for a creature that is not in the group */
+					goto T0209139_Return;
+				}
+				L0454_i_PrimaryDirectionToOrFromParty = _g382_currGroupPrimaryDirToParty;
+				/* If the party is visible, update the target coordinates */
+				if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, AL0447_i_CreatureIndex, eventMapX, eventMapY)) {
+					L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
+					L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+				}
+				/* If there is a single creature in the group that is not full square sized and 1/4 chance */
+				if (!L0460_ui_CreatureCount && (L0459_i_CreatureSize != k2_MaskCreatureSizeFull) && !((AL0446_i_GroupCellsCriteria = _vm->getRandomNumber(65536)) & 0x00C0)) {
+					if (L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) {
+						/* If the creature is not already on the center of the square then change its cell */
+						if (AL0446_i_GroupCellsCriteria & 0x0038) { /* 7/8 chances of changing cell to the center of the square */
+							L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature;
+						} else { /* 1/8 chance of changing cell to the next or previous cell on the square */
+							AL0446_i_GroupCellsCriteria = M21_normalizeModulo4(M21_normalizeModulo4(L0445_ps_ActiveGroup->_cells) + ((AL0446_i_GroupCellsCriteria & 0x0001) ? 1 : -1));
+						}
+					}
+					/* If 1/8 chance and the creature is not adjacent to the party and is a quarter square sized creature then process projectile impacts and update the creature cell if still alive. When the creature is not in front of the party, it has 7/8 chances of dodging a projectile by moving to another cell or staying in the center of the square */
+					if (!(AL0446_i_GroupCellsCriteria & 0x0038) && (L0452_i_DistanceToVisibleParty != 1) && (L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter)) {
+						if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* This call to F0218_PROJECTILE_GetImpactCount works fine because there is a single creature in the group so L0445_ps_ActiveGroup->Cells contains only one cell index */
+							goto T0209139_Return;
+						L0445_ps_ActiveGroup->_cells = M21_normalizeModulo4(AL0446_i_GroupCellsCriteria);
+					}
+				}
+				/* If the creature can see the party and is looking in the party direction or can attack in all direction */
+				if (L0452_i_DistanceToVisibleParty &&
+					(getFlag(L0448_s_CreatureInfo._attributes, k0x0004_MaskCreatureInfo_sideAttack) ||
+					 _vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) == L0454_i_PrimaryDirectionToOrFromParty)) {
+					/* If the creature is in range to attack the party and random test succeeds */
+					if ((L0452_i_DistanceToVisibleParty <= (AL0446_i_Range = L0448_s_CreatureInfo.M56_getAttackRange())) &&
+						(!AL0450_i_DistanceXToParty || !AL0451_i_DistanceYToParty) &&
+						(AL0446_i_Range <= (_vm->getRandomNumber(16) + 1))) {
+						if ((AL0446_i_Range == 1) &&
+							(!getFlag(AL0446_i_CreatureAttributes = L0448_s_CreatureInfo._attributes, k0x0008_MaskCreatureInfo_preferBackRow) || !_vm->getRandomNumber(4) || !getFlag(AL0446_i_CreatureAttributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) &&
+							(L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter) &&
+							(L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) &&
+							((AL0446_i_Cell = _vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex)) != L0454_i_PrimaryDirectionToOrFromParty) &&
+							(AL0446_i_Cell != returnNextVal(L0454_i_PrimaryDirectionToOrFromParty))) { /* If the creature cannot cast spells (range = 1) and is not on a cell where it can attack the party directly and is a quarter square sized creature not in the center of the square then the creature moves to another cell and attack does not occur immediately */
+							if (!L0460_ui_CreatureCount && _vm->getRandomNumber(2)) {
+								L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature;
+							} else {
+								if ((L0454_i_PrimaryDirectionToOrFromParty & 0x0001) == (AL0446_i_Cell & 0x0001)) {
+									AL0446_i_Cell--;
+								} else {
+									AL0446_i_Cell++;
+								}
+								if (!_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = M21_normalizeModulo4(AL0446_i_Cell)) ||
+									(_vm->getRandomNumber(2) && !_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */
+									if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* BUG0_70 A projectile impact on a creature may be ignored. The function F0218_PROJECTILE_GetImpactCount to detect projectile impacts when a quarter square sized creature moves inside a group (to another cell on the same square) may fail if there are several creatures in the group because the function expects a single cell index for its last parameter. The function should be called once for each cell where there is a creature */
+										goto T0209139_Return;
+									if (_vm->_projexpl->_g364_creatureDamageOutcome != k1_outcomeKilledSomeCreaturesInGroup) {
+										L0445_ps_ActiveGroup->_cells = f178_getGroupValueUpdatedWithCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex, AL0446_i_Cell);
+									}
+								}
+							}
+							L0465_s_NextEvent._mapTime += MAX(1, (L0448_s_CreatureInfo._movementTicks >> 1) + _vm->getRandomNumber(2)); /* Time for the creature to change cell */
+							L0465_s_NextEvent._type = eventType;
+							goto T0209135;
+						}
+						L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, f207_isCreatureAttacking(L0444_ps_Group, eventMapX, eventMapY, AL0447_i_CreatureIndex));
+						L0465_s_NextEvent._mapTime += (L0448_s_CreatureInfo._animationTicks & 0xF) + _vm->getRandomNumber(2);
+					} else {
+						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
+						if (L0460_ui_CreatureCount) {
+							f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+						}
+						goto T0209081_RunTowardParty;
+					}
+				} else {
+					/* If the party is visible, update target coordinates */
+					if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
+						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+						f205_setDirection(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
+						L0465_s_NextEvent._mapTime += 2;
+						L0464_l_NextAspectUpdateTime = M30_time(L0465_s_NextEvent._mapTime);
+					} else { /* If the party is not visible, move to the target (last known party location) */
+						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
+						if (L0460_ui_CreatureCount) {
+							f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+						}
+						goto T0209082_WalkTowardTarget;
+					}
+				}
+			}
+			L0465_s_NextEvent._type = eventType;
+			goto T0209136;
+		}
+		L0465_s_NextEvent._mapTime += MAX(1, _vm->getRandomNumber(4) + L0461_i_MovementTicks - 1);
+T0209134_SetEvent37:
+		L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup;
+	}
+T0209135:
+	if (!L0464_l_NextAspectUpdateTime) {
+		L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, kM1_wholeCreatureGroup, false);
+	}
+T0209136:
+	if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) {
+		L0465_s_NextEvent._mapTime += ticks;
+	} else {
+		L0464_l_NextAspectUpdateTime += ticks;
+	}
+	f208_groupAddEvent(&L0465_s_NextEvent, L0464_l_NextAspectUpdateTime);
+T0209139_Return:
+	;
+}
+
+bool GroupMan::f202_isMovementPossible(CreatureInfo* creatureInfo, int16 mapX, int16 mapY, uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls) {
+	int16 L0428_i_MapX;
+	int16 L0429_i_MapY;
+	uint16 L0430_ui_Square = 0;
+	int16 L0431_i_SquareType = 0;
+	Teleporter* L0432_ps_Teleporter;
+	Thing L0433_T_Thing;
+
+
+	_g384_groupMovementTestedDirections[dir] = true;
+	_g388_groupMovementBlockedByGroupThing = Thing::_endOfList;
+	_g389_groupMovementBlockedByDoor = false;
+	_g390_groupMovementBlockedByParty = false;
+	if (creatureInfo->_movementTicks == k255_immobile) {
+		return false;
+	}
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement((direction)dir, 1, 0, mapX, mapY);
+	L0428_i_MapX = mapX;
+	L0429_i_MapY = mapY;
+	if (_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter =
+		!(((L0428_i_MapX >= 0) && (L0428_i_MapX < _vm->_dungeonMan->_g273_currMapWidth)) &&
+		((L0429_i_MapY >= 0) && (L0429_i_MapY < _vm->_dungeonMan->_g274_currMapHeight)) &&
+		  ((L0431_i_SquareType = Square(L0430_ui_Square = _vm->_dungeonMan->_g271_currMapData[L0428_i_MapX][L0429_i_MapY]).getType()) != k0_ElementTypeWall) &&
+		  (L0431_i_SquareType != k3_ElementTypeStairs) &&
+		  ((L0431_i_SquareType != k2_ElementTypePit) || (getFlag(L0430_ui_Square, k0x0001_PitImaginary) && allowMovementOverImaginaryPitsAndFakeWalls) || !getFlag(L0430_ui_Square, k0x0008_PitOpen) || getFlag(creatureInfo->_attributes, k0x0020_MaskCreatureInfo_levitation)) &&
+		  ((L0431_i_SquareType != k6_ElementTypeFakeWall) || getFlag(L0430_ui_Square, k0x0004_FakeWallOpen) || (getFlag(L0430_ui_Square, k0x0001_FakeWallImaginary) && allowMovementOverImaginaryPitsAndFakeWalls)))) {
+		return false;
+	}
+	if (getFlag(creatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) {
+		L0433_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0428_i_MapX, L0429_i_MapY);
+		while (L0433_T_Thing != Thing::_endOfList) {
+			if ((L0433_T_Thing).getType() == k15_ExplosionThingType) {
+				L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(L0433_T_Thing);
+				if (((Explosion*)L0432_ps_Teleporter)->setType(k50_ExplosionType_Fluxcage)) {
+					_g385_fluxCages[dir] = true;
+					_g386_fluxCageCount++;
+					_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
+					return false;
+				}
+			}
+			L0433_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0433_T_Thing);
+		}
+	}
+	if ((L0431_i_SquareType == k5_ElementTypeTeleporter) && getFlag(L0430_ui_Square, k0x0008_TeleporterOpen) && (creatureInfo->M59_getWariness() >= 10)) {
+		L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
+		if (getFlag(L0432_ps_Teleporter->getScope(), k0x0001_TelepScopeCreatures) && !_vm->_dungeonMan->f139_isCreatureAllowedOnMap(_g380_currGroupThing, L0432_ps_Teleporter->getTargetMapIndex())) {
+			_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
+			return false;
+		}
+	}
+	if (_g390_groupMovementBlockedByParty = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0428_i_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0429_i_MapY == _vm->_dungeonMan->_g307_partyMapY)) {
+		return false;
+	}
+	if (L0431_i_SquareType == k4_DoorElemType) {
+		L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
+		if (((Square(L0430_ui_Square).getDoorState()) > (((Door*)L0432_ps_Teleporter)->opensVertically() ? creatureInfo->M51_height() : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
+			_g389_groupMovementBlockedByDoor = true;
+			return false;
+		}
+	}
+	return (_g388_groupMovementBlockedByGroupThing = _vm->_groupMan->f175_groupGetThing(L0428_i_MapX, L0429_i_MapY)) == Thing::_endOfList;
+}
+
+int16 GroupMan::f226_getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
+	return ((((srcMapX -= destMapX) < 0) ? -srcMapX : srcMapX) +
+		(((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY));
+}
+
+int16 GroupMan::f200_groupGetDistanceToVisibleParty(Group* group, int16 creatureIndex, int16 mapX, int16 mapY) {
+	int16 L0420_i_CreatureDirection;
+	int16 L0421_i_CreatureViewDirectionCount; /* Count of directions to test in L0425_ai_CreatureViewDirections */
+	int16 L0422_i_Multiple;
+#define AL0422_i_Counter    L0422_i_Multiple
+#define AL0422_i_SightRange L0422_i_Multiple
+	uint16 L0423_ui_GroupDirections;
+	CreatureInfo* L0424_ps_CreatureInfo;
+	int16 L0425_ai_CreatureViewDirections[4]; /* List of directions to test */
+
+
+	L0424_ps_CreatureInfo = &g243_CreatureInfo[group->_type];
+	if (_vm->_championMan->_g407_party._event71Count_Invisibility && !getFlag(L0424_ps_CreatureInfo->_attributes, k0x0800_MaskCreatureInfo_seeInvisible)) {
+		return 0;
+	}
+	if (getFlag(L0424_ps_CreatureInfo->_attributes, k0x0004_MaskCreatureInfo_sideAttack)) /* If creature can see in all directions */
+		goto T0200011;
+	L0423_ui_GroupDirections = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions;
+	if (creatureIndex < 0) { /* Negative index means test if each creature in the group can see the party in their respective direction */
+		L0421_i_CreatureViewDirectionCount = 0;
+		for (creatureIndex = group->getCount(); creatureIndex >= 0; creatureIndex--) {
+			L0420_i_CreatureDirection = M21_normalizeModulo4(L0423_ui_GroupDirections >> (creatureIndex << 1));
+			AL0422_i_Counter = L0421_i_CreatureViewDirectionCount;
+			while (AL0422_i_Counter--) {
+				if (L0425_ai_CreatureViewDirections[AL0422_i_Counter] == L0420_i_CreatureDirection) /* If the creature looks in the same direction as another one in the group */
+					goto T0200006;
+			}
+			L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount++] = L0420_i_CreatureDirection;
+T0200006:
+			;
+		}
+	} else { /* Positive index means test only if the specified creature in the group can see the party in its direction */
+		L0425_ai_CreatureViewDirections[0] = _vm->_groupMan->M50_getCreatureValue(L0423_ui_GroupDirections, creatureIndex);
+		L0421_i_CreatureViewDirectionCount = 1;
+	}
+	while (L0421_i_CreatureViewDirectionCount--) {
+		if (f227_isDestVisibleFromSource(L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount], mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY)) {
+T0200011:
+			AL0422_i_SightRange = L0424_ps_CreatureInfo->M54_getSightRange();
+			if (!getFlag(L0424_ps_CreatureInfo->_attributes, k0x1000_MaskCreatureInfo_nightVision)) {
+				AL0422_i_SightRange -= _vm->_displayMan->_g304_dungeonViewPaletteIndex >> 1;
+			}
+			if (_g381_currGroupDistanceToParty > MAX((int16)1, AL0422_i_SightRange)) {
+				return 0;
+			}
+			return f199_getDistanceBetweenUnblockedSquares(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f197_isViewPartyBlocked);
+		}
+	}
+	return 0;
+}
+
+int16 GroupMan::f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 srcMapY,
+														int16 destMapX, int16 destMapY, bool (GroupMan::*isBlocked)(uint16, uint16)) {
+	int16 L0410_i_XAxisStep;
+	int16 L0411_i_YAxisStep;
+	int16 L0412_i_Multiple;
+#define AL0412_i_DistanceX L0412_i_Multiple
+#define AL0412_i_PathMapX  L0412_i_Multiple
+	int16 L0413_i_Multiple;
+#define AL0413_i_DistanceY L0413_i_Multiple
+#define AL0413_i_PathMapY  L0413_i_Multiple
+	int16 L0414_i_LargestAxisDistance;
+	bool L0415_B_DistanceXSmallerThanDistanceY;
+	int16 L0416_i_ValueA;
+	int16 L0417_i_ValueB;
+	bool L0418_B_DistanceXEqualsDistanceY;
+	int16 L0419_i_ValueC;
+
+
+	if (M38_distance(srcMapX, srcMapY, destMapX, destMapY) <= 1) {
+		return 1;
+	}
+	L0415_B_DistanceXSmallerThanDistanceY = (AL0412_i_DistanceX = ((AL0412_i_DistanceX = destMapX - srcMapX) < 0) ? -AL0412_i_DistanceX : AL0412_i_DistanceX) < (AL0413_i_DistanceY = ((AL0413_i_DistanceY = destMapY - srcMapY) < 0) ? -AL0413_i_DistanceY : AL0413_i_DistanceY);
+	L0418_B_DistanceXEqualsDistanceY = (AL0412_i_DistanceX == AL0413_i_DistanceY);
+	L0410_i_XAxisStep = (((AL0412_i_PathMapX = destMapX) - srcMapX) > 0) ? -1 : 1;
+	L0411_i_YAxisStep = (((AL0413_i_PathMapY = destMapY) - srcMapY) > 0) ? -1 : 1;
+	L0419_i_ValueC = L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY - srcMapY) ? ((AL0412_i_PathMapX - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128)
+		: ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX - srcMapX) ? ((AL0413_i_PathMapY - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128);
+	/* 128 when the creature is on the same row or column as the party */
+	do {
+		if (L0418_B_DistanceXEqualsDistanceY) {
+			if (((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY) && (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX, AL0413_i_PathMapY + L0411_i_YAxisStep)) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX = AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY = AL0413_i_PathMapY + L0411_i_YAxisStep)) {
+				return 0;
+			}
+		} else {
+			if ((L0416_i_ValueA = ((L0414_i_LargestAxisDistance = (L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY - srcMapY) ? ((AL0412_i_PathMapX + L0410_i_XAxisStep - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX + L0410_i_XAxisStep - srcMapX) ? ((AL0413_i_PathMapY - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128)) - L0419_i_ValueC) < 0) ? -L0414_i_LargestAxisDistance : L0414_i_LargestAxisDistance) < (L0417_i_ValueB = ((L0414_i_LargestAxisDistance = (L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY + L0411_i_YAxisStep - srcMapY) ? ((AL0412_i_PathMapX - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX - srcMapX) ? ((AL0413_i_PathMapY + L0411_i_YAxisStep - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128)) - L0419_i_ValueC) < 0) ? -L0414_i_LargestAxisDistance : L0414_i_LargestAxisDistance)) {
+				AL0412_i_PathMapX += L0410_i_XAxisStep;
+			} else {
+				AL0413_i_PathMapY += L0411_i_YAxisStep;
+			}
+			if ((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX, AL0413_i_PathMapY) && ((L0416_i_ValueA != L0417_i_ValueB) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX = AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY = AL0413_i_PathMapY - L0411_i_YAxisStep))) {
+				return 0;
+			}
+		}
+	} while (M38_distance(AL0412_i_PathMapX, AL0413_i_PathMapY, srcMapX, srcMapY) > 1);
+	return f226_getDistanceBetweenSquares(srcMapX, srcMapY, destMapX, destMapY);
+}
+
+bool GroupMan::f197_isViewPartyBlocked(uint16 mapX, uint16 mapY) {
+	uint16 L0404_ui_Square;
+	int16 L0405_i_SquareType;
+	int16 L0406_i_DoorState;
+	Door* L0407_ps_Door;
+
+	if ((L0405_i_SquareType = Square(L0404_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k4_DoorElemType) {
+		L0407_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY);
+		return (((L0406_i_DoorState = Square(L0404_ui_Square).getDoorState()) == k3_doorState_FOURTH) || (L0406_i_DoorState == k4_doorState_CLOSED)) && !getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[L0407_ps_Door->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough);
+	}
+	return (L0405_i_SquareType == k0_ElementTypeWall) || ((L0405_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0404_ui_Square, k0x0004_FakeWallOpen));
+}
+
+int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup* activeGroup, int16 creatureIndex, bool isAttacking) {
+	uint16 L0326_ui_Multiple;
+#define AL0326_ui_Aspect         L0326_ui_Multiple
+#define AL0326_ui_AnimationTicks L0326_ui_Multiple
+	uint16 L0327_ui_CreatureGraphicInfo;
+	int16 L0328_i_Offset;
+	Group* L0329_ps_Group;
+	bool L0330_B_ProcessGroup;
+	uint16 L0331_ui_CreatureType;
+	uint16 L1635_ui_SoundIndex;
+
+	L0329_ps_Group = &(((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]);
+	L0327_ui_CreatureGraphicInfo = g243_CreatureInfo[L0331_ui_CreatureType = L0329_ps_Group->_type]._graphicInfo;
+	if (L0330_B_ProcessGroup = (creatureIndex < 0)) { /* If the creature index is negative then all creatures in the group are processed */
+		creatureIndex = L0329_ps_Group->getCount();
+	}
+	do {
+		AL0326_ui_Aspect = activeGroup->_aspect[creatureIndex];
+		AL0326_ui_Aspect &= k0x0080_MaskActiveGroupIsAttacking | k0x0040_MaskActiveGroupFlipBitmap;
+		if (L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 12) & 0x3)) {
+			L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset);
+			if (_vm->getRandomNumber(2)) {
+				L0328_i_Offset = (-L0328_i_Offset) & 0x0007;
+			}
+			AL0326_ui_Aspect |= L0328_i_Offset;
+		}
+		if (L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 14) & 0x3)) {
+			L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset);
+			if (_vm->getRandomNumber(2)) {
+				L0328_i_Offset = (-L0328_i_Offset) & 0x0007;
+			}
+			AL0326_ui_Aspect |= (L0328_i_Offset << 3);
+		}
+		if (isAttacking) {
+			if (getFlag(L0327_ui_CreatureGraphicInfo, k0x0200_CreatureInfoGraphicMaskFlipAttack)) {
+				if (getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) && (L0331_ui_CreatureType == k18_CreatureTypeAnimatedArmourDethKnight)) {
+					if (_vm->getRandomNumber(2)) {
+						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+						warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+					}
+				} else {
+					if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) {
+						if (_vm->getRandomNumber(2)) {
+							setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+						} else {
+							clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+						}
+					}
+				}
+			} else {
+				clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+			}
+			setFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking);
+		} else {
+			if (getFlag(L0327_ui_CreatureGraphicInfo, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) {
+				if (L0331_ui_CreatureType == k13_CreatureTypeCouatl) {
+					if (_vm->getRandomNumber(2)) {
+						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+						L1635_ui_SoundIndex = _vm->_movsens->f514_getSound(k13_CreatureTypeCouatl);
+						if (L1635_ui_SoundIndex <= k34_D13_soundCount) {
+							warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+						}
+					}
+				} else {
+					if (_vm->getRandomNumber(2)) {
+						setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+					} else {
+						clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+					}
+				}
+			} else {
+				clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+			}
+			clearFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking);
+		}
+		activeGroup->_aspect[creatureIndex] = AL0326_ui_Aspect;
+	} while (L0330_B_ProcessGroup && (creatureIndex--));
+	AL0326_ui_AnimationTicks = g243_CreatureInfo[L0329_ps_Group->_type]._animationTicks;
+	return _vm->_g313_gameTime + (isAttacking ? ((AL0326_ui_AnimationTicks >> 8) & 0xF) : ((AL0326_ui_AnimationTicks >> 4) & 0xF)) + _vm->getRandomNumber(2);
+}
+
+void GroupMan::f205_setDirection(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) {
+	uint16 L0435_ui_GroupDirections;
+	static long G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime; /* These two variables are used to prevent setting direction of half square sized creatures twice at the same game time */
+	static ActiveGroup* G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup;
+
+
+	warning("potentially dangerous cast to uint32 below");
+	if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == (uint32)G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) {
+		return;
+	}
+	if (M21_normalizeModulo4(_vm->_groupMan->M50_getCreatureValue(L0435_ui_GroupDirections = activeGroup->_directions, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */
+		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + dir));
+	} else {
+		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir);
+	}
+	if (twoHalfSquareSizedCreatures) {
+		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex ^ 1, dir); /* Set direction of the second half square sized creature */
+		G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime = _vm->_g313_gameTime;
+		G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup = activeGroup;
+	}
+	activeGroup->_directions = (direction)L0435_ui_GroupDirections;
+}
+
+void GroupMan::f208_groupAddEvent(TimelineEvent* event, uint32 time) {
+	warning("potentially dangerous cast to uint32 below");
+	if (time < (uint32)M30_time(event->_mapTime)) {
+		event->_type -= 5;
+		event->_C._ticks = M30_time(event->_mapTime) - time;
+		M32_setTime(event->_mapTime, time);
+	} else {
+		event->_C._ticks = time - M30_time(event->_mapTime);
+	}
+	_vm->_timeline->f238_addEventGetEventIndex(event);
+}
+
+int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo* creatureInfo, int16 mapY, int16 mapX) {
+
+	uint16 L0426_ui_SmellRange;
+	int16 L0427_i_ScentOrdinal;
+
+
+	if (!(L0426_ui_SmellRange = creatureInfo->M55_getSmellRange())) {
+		return 0;
+	}
+	if ((((L0426_ui_SmellRange + 1) >> 1) >= _g381_currGroupDistanceToParty) && f199_getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f198_isSmellPartyBlocked)) {
+		_vm->_projexpl->_g363_secondaryDirToOrFromParty = _g383_currGroupSecondaryDirToParty;
+		return _vm->M0_indexToOrdinal(_g382_currGroupPrimaryDirToParty);
+	}
+	if ((L0427_i_ScentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapY, mapX)) && ((_vm->_championMan->_g407_party._scentStrengths[_vm->M1_ordinalToIndex(L0427_i_ScentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (L0426_ui_SmellRange << 1)))) { /* If there is a fresh enough party scent on the group square */
+		return _vm->M0_indexToOrdinal(f228_getDirsWhereDestIsVisibleFromSource(mapY, mapX, _vm->_championMan->_g407_party._scents[L0427_i_ScentOrdinal].getMapX(), _vm->_championMan->_g407_party._scents[L0427_i_ScentOrdinal].getMapY()));
+	}
+	return 0;
+}
+
+bool GroupMan::f198_isSmellPartyBlocked(uint16 mapX, uint16 mapY) {
+	uint16 L0408_ui_Square;
+	int16 L0409_i_SquareType;
+
+	return ((L0409_i_SquareType = Square(L0408_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k0_ElementTypeWall) || ((L0409_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0408_ui_Square, k0x0004_FakeWallOpen));
+}
+
+int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo* info, int16 mapX, int16 mapY, bool allowMovementOverImaginaryPitsAndFakeWalls) {
+	int16 L0434_i_Direction;
+
+
+	for (L0434_i_Direction = kDirNorth; L0434_i_Direction <= kDirWest; L0434_i_Direction++) {
+		if ((!_g384_groupMovementTestedDirections[L0434_i_Direction]) && f202_isMovementPossible(info, mapX, mapY, L0434_i_Direction, allowMovementOverImaginaryPitsAndFakeWalls)) {
+			return _vm->M0_indexToOrdinal(L0434_i_Direction);
+		}
+	}
+	return 0;
+}
+
+void GroupMan::f206_groupSetDirGroup(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, int16 creatureSize) {
+	bool L0436_B_TwoHalfSquareSizedCreatures;
+
+
+	if (L0436_B_TwoHalfSquareSizedCreatures = creatureIndex && (creatureSize == k1_MaskCreatureSizeHalf)) {
+		creatureIndex--;
+	}
+	do {
+		if (!creatureIndex || _vm->getRandomNumber(2)) {
+			f205_setDirection(activeGroup, dir, creatureIndex, L0436_B_TwoHalfSquareSizedCreatures);
+		}
+	} while (creatureIndex--);
+}
+
+void GroupMan::f182_stopAttacking(ActiveGroup* group, int16 mapX, int16 mapY) {
+	int16 L0337_i_CreatureIndex;
+
+	for (L0337_i_CreatureIndex = 0; L0337_i_CreatureIndex < 4; clearFlag(group->_aspect[L0337_i_CreatureIndex++], k0x0080_MaskActiveGroupIsAttacking));
+	f181_groupDeleteEvents(mapX, mapY);
+
+}
+
+bool GroupMan::f204_isArchenemyDoubleMovementPossible(CreatureInfo* info, int16 mapX, int16 mapY, uint16 dir) {
+	if (_g385_fluxCages[dir]) {
+		return false;
+	}
+	mapX += _vm->_dirIntoStepCountEast[dir], mapY += _vm->_dirIntoStepCountNorth[dir];
+	return f202_isMovementPossible(info, mapX, mapY, dir, false);
+}
+
+bool GroupMan::f207_isCreatureAttacking(Group* group, int16 mapX, int16 mapY, uint16 creatureIndex) {
+	uint16 L0437_ui_Multiple;
+#define AL0437_ui_CreatureType L0437_ui_Multiple
+#define AL0437_T_Thing         L0437_ui_Multiple
+	uint16 L0438_ui_PrimaryDirectionToParty;
+	int16 L0439_i_Multiple;
+#define AL0439_i_GroupCells    L0439_i_Multiple
+#define AL0439_i_TargetCell    L0439_i_Multiple
+#define AL0439_i_ChampionIndex L0439_i_Multiple
+	int16 L0440_i_Multiple;
+#define AL0440_i_KineticEnergy      L0440_i_Multiple
+#define AL0440_i_Counter            L0440_i_Multiple
+#define AL0440_i_Damage             L0440_i_Multiple
+#define AL0440_i_AttackSoundOrdinal L0440_i_Multiple
+	CreatureInfo* L0441_ps_CreatureInfo;
+	Champion* L0442_ps_Champion;
+	ActiveGroup L0443_s_ActiveGroup;
+
+
+	_vm->_projexpl->_g361_lastCreatureAttackTime = _vm->_g313_gameTime;
+	L0443_s_ActiveGroup = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
+	L0441_ps_CreatureInfo = &g243_CreatureInfo[AL0437_ui_CreatureType = group->_type];
+	L0438_ui_PrimaryDirectionToParty = _g382_currGroupPrimaryDirToParty;
+	if ((AL0439_i_GroupCells = L0443_s_ActiveGroup._cells) == k255_CreatureTypeSingleCenteredCreature) {
+		AL0439_i_TargetCell = _vm->getRandomNumber(2);
+	} else {
+		AL0439_i_TargetCell = ((_vm->_groupMan->M50_getCreatureValue(AL0439_i_GroupCells, creatureIndex) + 5 - L0438_ui_PrimaryDirectionToParty) & 0x0002) >> 1;
+	}
+	AL0439_i_TargetCell += L0438_ui_PrimaryDirectionToParty;
+	AL0439_i_TargetCell &= 0x0003;
+	if ((L0441_ps_CreatureInfo->M56_getAttackRange() > 1) && ((_g381_currGroupDistanceToParty > 1) || _vm->getRandomNumber(2))) {
+		switch (AL0437_ui_CreatureType) {
+		case k14_CreatureTypeVexirk:
+		case k23_CreatureTypeLordChaos:
+			if (_vm->getRandomNumber(2)) {
+				AL0437_T_Thing = Thing::_explFireBall.toUint16();
+			} else {
+				switch (_vm->getRandomNumber(4)) {
+				case 0:
+					AL0437_T_Thing = Thing::_explHarmNonMaterial.toUint16();
+					break;
+				case 1:
+					AL0437_T_Thing = Thing::_explLightningBolt.toUint16();
+					break;
+				case 2:
+					AL0437_T_Thing = Thing::_explPoisonCloud.toUint16();
+					break;
+				case 3:
+					AL0437_T_Thing = Thing::_explOpenDoor.toUint16();
+				}
+			}
+			break;
+		case k1_CreatureTypeSwampSlimeSlime:
+			AL0437_T_Thing = Thing::_explSlime.toUint16();
+			break;
+		case k3_CreatureTypeWizardEyeFlyingEye:
+			if (_vm->getRandomNumber(8)) {
+				AL0437_T_Thing = Thing::_explLightningBolt.toUint16();
+			} else {
+				AL0437_T_Thing = Thing::_explOpenDoor.toUint16();
+			}
+			break;
+		case k19_CreatureTypeMaterializerZytaz:
+			if (_vm->getRandomNumber(2)) {
+				AL0437_T_Thing = Thing::_explPoisonCloud.toUint16();
+				break;
+			}
+		case k22_CreatureTypeDemon:
+		case k24_CreatureTypeRedDragon:
+			AL0437_T_Thing = Thing::_explFireBall.toUint16();
+		} /* BUG0_13 The game may crash when 'Lord Order' or 'Grey Lord' cast spells. This cannot happen with the original dungeons as they do not contain any groups of these types. 'Lord Order' and 'Grey Lord' creatures can cast spells (attack range > 1) but no projectile type is defined for them in the code. If these creatures are present in a dungeon they will cast projectiles containing undefined things because the variable is not initialized */
+		AL0440_i_KineticEnergy = (L0441_ps_CreatureInfo->_attack >> 2) + 1;
+		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
+		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
+		warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+		_vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
+	} else {
+		if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) {
+			AL0439_i_ChampionIndex = _vm->getRandomNumber(4);
+			for (AL0440_i_Counter = 0; (AL0440_i_Counter < 4) && !_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex]._currHealth; AL0440_i_Counter++) {
+				AL0439_i_ChampionIndex = returnNextVal(AL0439_i_ChampionIndex);
+			}
+			if (AL0440_i_Counter == 4) {
+				return false;
+			}
+		} else {
+			if ((AL0439_i_ChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(mapX, mapY, AL0439_i_TargetCell)) < 0) {
+				return false;
+			}
+		}
+		if (AL0437_ui_CreatureType == k2_CreatureTypeGiggler) {
+			f193_stealFromChampion(group, AL0439_i_ChampionIndex);
+		} else {
+			AL0440_i_Damage = f230_getChampionDamage(group, AL0439_i_ChampionIndex) + 1;
+			L0442_ps_Champion = &_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex];
+			if (AL0440_i_Damage > L0442_ps_Champion->_maximumDamageReceived) {
+				L0442_ps_Champion->_maximumDamageReceived = AL0440_i_Damage;
+				L0442_ps_Champion->_directionMaximumDamageReceived = returnOppositeDir((direction)L0438_ui_PrimaryDirectionToParty);
+			}
+		}
+	}
+	if (AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal) {
+		warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+	}
+	return true;
+}
+
+void GroupMan::f229_setOrderedCellsToAttack(signed char* orderedCellsToAttack, int16 targetMapX, int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource) {
+	static signed char g23_orderedCellsToAttack[8][4] = { // @ G0023_aac_Graphic562_OrderedCellsToAttack
+		{0, 1, 3, 2},   /* Attack South from position Northwest or Southwest */
+		{1, 0, 2, 3},   /* Attack South from position Northeast or Southeast */
+		{1, 2, 0, 3},   /* Attack West from position Northwest or Northeast */
+		{2, 1, 3, 0},   /* Attack West from position Southeast or Southwest */
+		{3, 2, 0, 1},   /* Attack North from position Northwest or Southwest */
+		{2, 3, 1, 0},   /* Attack North from position Southeast or Northeast */
+		{0, 3, 1, 2},   /* Attack East from position Northwest or Northeast */
+		{3, 0, 2, 1}}; /* Attack East from position Southeast or Southwest */
+	uint16 L0557_ui_OrderedCellsToAttackIndex;
+
+
+	if (!((L0557_ui_OrderedCellsToAttackIndex = f228_getDirsWhereDestIsVisibleFromSource(targetMapX, targetMapY, attackerMapX, attackerMapY) << 1) & 0x0002)) {
+		cellSource++;
+	}
+	L0557_ui_OrderedCellsToAttackIndex += (cellSource >> 1) & 0x0001;
+	for (uint16 i = 0; i < 4; ++i)
+		orderedCellsToAttack[i] = g23_orderedCellsToAttack[L0557_ui_OrderedCellsToAttackIndex][i];
+}
+
+void GroupMan::f193_stealFromChampion(Group* group, uint16 championIndex) {
+	int16 L0391_i_Percentage;
+	uint16 L0392_ui_StealFromSlotIndex;
+	uint16 L0393_ui_Counter;
+	Thing L0394_T_Thing;
+	Champion* L0395_ps_Champion;
+	bool L0396_B_ObjectStolen;
+	static unsigned char G0394_auc_StealFromSlotIndices[8]; /* Initialized with 0 bytes by C loader */
+
+
+	L0396_B_ObjectStolen = false;
+	L0391_i_Percentage = 100 - _vm->_championMan->f311_getDexterity(L0395_ps_Champion = &_vm->_championMan->_gK71_champions[championIndex]);
+	L0393_ui_Counter = _vm->getRandomNumber(8);
+	while ((L0391_i_Percentage > 0) && !_vm->_championMan->f308_isLucky(L0395_ps_Champion, L0391_i_Percentage)) {
+		if ((L0392_ui_StealFromSlotIndex = G0394_auc_StealFromSlotIndices[L0393_ui_Counter]) == k13_ChampionSlotBackpackLine_1_1) {
+			L0392_ui_StealFromSlotIndex += _vm->getRandomNumber(17); /* Select a random slot in the backpack */
+		}
+		if (((L0394_T_Thing = L0395_ps_Champion->_slots[L0392_ui_StealFromSlotIndex]) != Thing::_none)) {
+			L0396_B_ObjectStolen = true;
+			L0394_T_Thing = _vm->_championMan->f300_getObjectRemovedFromSlot(championIndex, L0392_ui_StealFromSlotIndex);
+			if (group->_slot == Thing::_endOfList) {
+				group->_slot = L0394_T_Thing; /* BUG0_12 An object is cloned and appears at two different locations in the dungeon and/or inventory. The game may crash when interacting with this object. If a Giggler with no possessions steals an object that was previously in a chest and was not the last object in the chest then the objects that followed it are cloned. In the chest, the object is part of a linked list of objects that is not reset when the object is removed from the chest and placed in the inventory (but not in the dungeon), nor when it is stolen and added as the first Giggler possession. If the Giggler already has a possession before stealing the object then this does not create a cloned object.
+											 The following statement is missing: L0394_T_Thing->Next = Thing::_endOfList;
+											 This creates cloned things if L0394_T_Thing->Next is not Thing::_endOfList which is the case when the object comes from a chest in which it was not the last object */
+			} else {
+				_vm->_dungeonMan->f163_linkThingToList(L0394_T_Thing, group->_slot, kM1_MapXNotOnASquare, 0);
+			}
+			_vm->_championMan->f292_drawChampionState((ChampionIndex)championIndex);
+		}
+		++L0393_ui_Counter;
+		L0393_ui_Counter &= 0x0007;
+		L0391_i_Percentage -= 20;
+	}
+	if (!_vm->getRandomNumber(8) || (L0396_B_ObjectStolen && _vm->getRandomNumber(2))) {
+		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._delayFleeingFromTarget = _vm->getRandomNumber(64) + 20;
+		group->setBehaviour(k5_behavior_FLEE);
+	}
+}
+
+int16 GroupMan::f230_getChampionDamage(Group* group, uint16 champIndex) {
+	unsigned char g24_woundProbabilityIndexToWoundMask[4] = {32, 16, 8, 4}; // @ G0024_auc_Graphic562_WoundProbabilityIndexToWoundMask
+
+	Champion* L0562_ps_Champion;
+	int16 L0558_i_Multiple;
+#define AL0558_i_Attack L0558_i_Multiple
+#define AL0558_i_Damage L0558_i_Multiple
+	uint16 L0559_ui_Multiple;
+#define AL0559_ui_WoundTest          L0559_ui_Multiple
+#define AL0559_ui_PoisonAttack       L0559_ui_Multiple
+#define AL0559_ui_CreatureDifficulty L0559_ui_Multiple
+	uint16 L0560_ui_WoundProbabilities;
+	uint16 L0561_ui_Multiple;
+#define AL0561_ui_WoundProbabilityIndex L0561_ui_Multiple
+#define AL0561_ui_AllowedWound          L0561_ui_Multiple
+	int16 L0563_i_DoubledMapDifficulty;
+	CreatureInfo L0564_s_CreatureInfo;
+
+
+	L0562_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
+		return 0;
+	}
+	if (!L0562_ps_Champion->_currHealth) {
+		return 0;
+	}
+	if (_vm->_championMan->_g300_partyIsSleeping) {
+		_vm->_championMan->f314_wakeUp();
+	}
+	L0563_i_DoubledMapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty << 1;
+	L0564_s_CreatureInfo = g243_CreatureInfo[group->_type];
+	_vm->_championMan->f304_addSkillExperience(champIndex, k7_ChampionSkillParry, L0564_s_CreatureInfo.M58_getExperience());
+	if (_vm->_championMan->_g300_partyIsSleeping || (((_vm->_championMan->f311_getDexterity(L0562_ps_Champion) < (_vm->getRandomNumber(32) + L0564_s_CreatureInfo._dexterity + L0563_i_DoubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !_vm->_championMan->f308_isLucky(L0562_ps_Champion, 60))) {
+		if ((AL0559_ui_WoundTest = _vm->getRandomNumber(65536)) & 0x0070) {
+			AL0559_ui_WoundTest &= 0x000F;
+			L0560_ui_WoundProbabilities = L0564_s_CreatureInfo._woundProbabilities;
+			for (AL0561_ui_WoundProbabilityIndex = 0; AL0559_ui_WoundTest > (L0560_ui_WoundProbabilities & 0x000F); L0560_ui_WoundProbabilities >>= 4) {
+				AL0561_ui_WoundProbabilityIndex++;
+			}
+			AL0561_ui_AllowedWound = g24_woundProbabilityIndexToWoundMask[AL0561_ui_WoundProbabilityIndex];
+		} else {
+			AL0561_ui_AllowedWound = AL0559_ui_WoundTest & 0x0001; /* 0 (Ready hand) or 1 (action hand) */
+		}
+		if ((AL0558_i_Attack = (_vm->getRandomNumber(16) + L0564_s_CreatureInfo._attack + L0563_i_DoubledMapDifficulty) - (_vm->_championMan->f303_getSkillLevel(champIndex, k7_ChampionSkillParry) << 1)) <= 1) {
+			if (_vm->getRandomNumber(2)) {
+				goto T0230014;
+			}
+			AL0558_i_Attack = _vm->getRandomNumber(4) + 2;
+		}
+		AL0558_i_Attack >>= 1;
+		AL0558_i_Attack += _vm->getRandomNumber(AL0558_i_Attack) + _vm->getRandomNumber(4);
+		AL0558_i_Attack += _vm->getRandomNumber(AL0558_i_Attack);
+		AL0558_i_Attack >>= 2;
+		AL0558_i_Attack += _vm->getRandomNumber(4) + 1;
+		if (_vm->getRandomNumber(2)) {
+			AL0558_i_Attack -= _vm->getRandomNumber((AL0558_i_Attack >> 1) + 1) - 1;
+		}
+		if (AL0558_i_Damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType)) {
+			warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			if ((AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack) && _vm->getRandomNumber(2) && ((AL0559_ui_PoisonAttack = _vm->_championMan->f307_getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack)) >= 0)) {
+				_vm->_championMan->f322_championPoison(champIndex, AL0559_ui_PoisonAttack);
+			}
+			return AL0558_i_Damage;
+		}
+	}
+T0230014:
+	return 0;
+}
+
+void GroupMan::f187_dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY) {
+	Group* L0363_ps_Group;
+	int16 L0364_i_CreatureType;
+
+
+	if (_g391_dropMovingCreatureFixedPossCellCount) {
+		L0363_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing);
+		L0364_i_CreatureType = L0363_ps_Group->_type;
+		while (_g391_dropMovingCreatureFixedPossCellCount) {
+			f186_dropCreatureFixedPossessions(L0364_i_CreatureType, mapX, mapY, _g392_dropMovingCreatureFixedPossessionsCell[--_g391_dropMovingCreatureFixedPossCellCount], k2_soundModePlayOneTickLater);
+		}
+	}
+}
+
+void GroupMan::f180_startWanedring(int16 mapX, int16 mapY) {
+	Group* L0332_ps_Group;
+	TimelineEvent L0333_s_Event;
+
+
+	L0332_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(mapX, mapY));
+	if (L0332_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
+		L0332_ps_Group->setBehaviour(k0_behavior_WANDER);
+	}
+	M33_setMapAndTime(L0333_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, (_vm->_g313_gameTime + 1));
+	L0333_s_Event._type = k37_TMEventTypeUpdateBehaviourGroup;
+	L0333_s_Event._priority = 255 - g243_CreatureInfo[L0332_ps_Group->_type]._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
+	L0333_s_Event._C._ticks = 0;
+	L0333_s_Event._B._location._mapX = mapX;
+	L0333_s_Event._B._location._mapY = mapY;
+	_vm->_timeline->f238_addEventGetEventIndex(&L0333_s_Event);
+}
+
+void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
+	uint16 L0339_ui_CreatureIndex;
+	Group* L0340_ps_Group;
+	ActiveGroup* L0341_ps_ActiveGroup;
+	int16 L0344_i_ActiveGroupIndex;
+
+
+	L0341_ps_ActiveGroup = _vm->_groupMan->_g375_activeGroups;
+	L0344_i_ActiveGroupIndex = 0;
+	while (L0341_ps_ActiveGroup->_groupThingIndex >= 0) {
+		if (++L0344_i_ActiveGroupIndex >= _vm->_groupMan->_g376_maxActiveGroupCount) {
+			return; /* BUG0_11 Data corruption in memory. Each group located on the same map as the party has additional associated data but there is only provision for 60 instances (_vm->_groupMan->_g376_maxActiveGroupCount). If there are more groups at the same time then some of them do not get their instance and when the game accesses this information it will corrupt other data in memory (either the instance of another group, parts of the timeline or events). This situation cannot occur in the original Dungeon Master and Chaos Strikes Back dungeons for the following reasons (but it may occur in custom dungeons if they are not designed carefully): there is no map with already more than 60 groups in the original dungeons and none of the following 3 possible ways to move a group into a map can increase the number of instances above the maximum of 60:
+					- A group generator sensor is triggered: the game never generates a group on the party map if there are less than 5 instances available. This limits the actual number of groups on a map to 55 in most cases.
+					- A group falls through a pit from the map above (the creature type must be allowed on the target map): a group will never willingly move to an open pit square. It may move to a closed pit square and fall if the pit is then open (either automatically or triggered by the party on the map below). There are no such pits in the original dungeons.
+					- A group is teleported from another map (the creature type must be allowed on the target map): in the original dungeons, all teleporters whose scope include groups and target another map are either inaccessible to groups or the groups are not allowed on the target map. The only exception is for some Gigglers in the Chaos Strikes Back dungeon but there are not enough to use the 5 reserved instances.
+
+					This code returns immediately if all ACTIVE_GROUP entries are already in use, which avoids an out of bounds access into _vm->_groupMan->_g375_activeGroups below (through L0341_ps_ActiveGroup). However in this case the specified group ends up without an associated ACTIVE_GROUP structure which is assumed everywhere in the code to be present for groups on the same map as the party. If there are more than 60 groups on the party map at any given time then this will corrupt memory (in _vm->_timeline->_g370_events and _vm->_timeline->_g371_timeline allocated in _vm->_timeline->f233_initTimeline before _vm->_groupMan->_g375_activeGroups) because of read and write operations at incorrect memory addresses (the 'Cells' value of the GROUP will be used as an index in _vm->_groupMan->_g375_activeGroups even though that value was not replaced by the index of an ACTIVE_GROUP in this function) */
+		}
+		L0341_ps_ActiveGroup++;
+	}
+	_g377_currActiveGroupCount++;
+	L0340_ps_Group = ((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType());
+	L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells;
+	L0340_ps_Group->getActiveGroupIndex() = L0344_i_ActiveGroupIndex;
+	L0341_ps_ActiveGroup->_priorMapX = L0341_ps_ActiveGroup->_homeMapX = mapX;
+	L0341_ps_ActiveGroup->_priorMapY = L0341_ps_ActiveGroup->_homeMapY = mapY;
+	L0341_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime - 127;
+	L0339_ui_CreatureIndex = L0340_ps_Group->getCount();
+	do {
+		L0341_ps_ActiveGroup->_directions = (direction)f178_getGroupValueUpdatedWithCreatureValue(L0341_ps_ActiveGroup->_directions, L0339_ui_CreatureIndex, L0340_ps_Group->getDir());
+		L0341_ps_ActiveGroup->_aspect[L0339_ui_CreatureIndex] = 0;
+	} while (L0339_ui_CreatureIndex--);
+	f179_getCreatureAspectUpdateTime(L0341_ps_ActiveGroup, kM1_wholeCreatureGroup, false);
+}
+
+void GroupMan::f184_removeActiveGroup(uint16 activeGroupIndex) {
+	ActiveGroup* L0347_ps_ActiveGroup;
+	Group* L0348_ps_Group;
+
+
+	if ((activeGroupIndex > _vm->_groupMan->_g376_maxActiveGroupCount) || (_vm->_groupMan->_g375_activeGroups[activeGroupIndex]._groupThingIndex < 0)) {
+		return;
+	}
+	L0347_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[activeGroupIndex];
+	L0348_ps_Group = &((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex];
+	_g377_currActiveGroupCount--;
+	L0348_ps_Group->_cells = L0347_ps_ActiveGroup->_cells;
+	L0348_ps_Group->setDir(M21_normalizeModulo4(L0347_ps_ActiveGroup->_directions));
+	if (L0348_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
+		L0348_ps_Group->setBehaviour(k0_behavior_WANDER);
+	}
+	L0347_ps_ActiveGroup->_groupThingIndex = -1;
+}
+
+void GroupMan::f194_removeAllActiveGroups() {
+	for (int16 L0397_ui_ActiveGroupIndex = 0; _g377_currActiveGroupCount > 0; L0397_ui_ActiveGroupIndex++) {
+		if (_vm->_groupMan->_g375_activeGroups[L0397_ui_ActiveGroupIndex]._groupThingIndex >= 0) {
+			f184_removeActiveGroup(L0397_ui_ActiveGroupIndex);
+		}
+	}
+}
+
+void GroupMan::f195_addAllActiveGroups() {
+	uint16 L0398_ui_MapX;
+	uint16 L0399_ui_MapY;
+	Thing L0400_T_Thing;
+	byte* L0401_puc_Square;
+	Thing* L0402_pT_SquareFirstThing;
+
+
+	L0401_puc_Square = _vm->_dungeonMan->_g271_currMapData[0];
+	L0402_pT_SquareFirstThing = &_vm->_dungeonMan->_g283_squareFirstThings[_vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount[0]];
+	for (L0398_ui_MapX = 0; L0398_ui_MapX < _vm->_dungeonMan->_g273_currMapWidth; L0398_ui_MapX++) {
+		for (L0399_ui_MapY = 0; L0399_ui_MapY < _vm->_dungeonMan->_g274_currMapHeight; L0399_ui_MapY++) {
+			if (getFlag(*L0401_puc_Square++, k0x0010_ThingListPresent)) {
+				L0400_T_Thing = *L0402_pT_SquareFirstThing++;
+				do {
+					if (L0400_T_Thing.getType() == k4_GroupThingType) {
+						f181_groupDeleteEvents(L0398_ui_MapX, L0399_ui_MapY);
+						f183_addActiveGroup(L0400_T_Thing, L0398_ui_MapX, L0399_ui_MapY);
+						f180_startWanedring(L0398_ui_MapX, L0399_ui_MapY);
+						break;
+					}
+				} while ((L0400_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0400_T_Thing)) != Thing::_endOfList);
+			}
+		}
+	}
+}
 }
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 3530765..f9aa038 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -231,7 +231,8 @@ public:
 	void f180_startWanedring(int16 mapX, int16 mapY); // @ F0180_GROUP_StartWandering
 	void f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY); // @ F0183_GROUP_AddActiveGroup
 	void f184_removeActiveGroup(uint16 activeGroupIndex); // @ F0184_GROUP_RemoveActiveGroup
-
+	void f194_removeAllActiveGroups(); // @ F0194_GROUP_RemoveAllActiveGroups
+	void f195_addAllActiveGroups(); // @ F0195_GROUP_AddAllActiveGroups
 
 
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index b8b0ba8..35bdf21 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -43,11 +43,13 @@ Box g36_BoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
 Box g37_BoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
 
 InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
+	_g432_inventoryChampionOrdinal = 0;
 	_g424_panelContent = k0_PanelContentFoodWaterPoisoned;
 	for (uint16 i = 0; i < 8; ++i)
-		_g425_chestSlots[i] = Thing::_none;
-	_g426_openChest = Thing::_none;
+		_g425_chestSlots[i] = Thing(0);
 	_g426_openChest = Thing::_none;
+	_g421_objDescTextXpos = 0;
+	_g422_objDescTextYpos = 0;
 }
 
 void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
@@ -643,4 +645,41 @@ void InventoryMan::f337_setDungeonViewPalette() {
 
 	_vm->_displayMan->_g342_refreshDungeonViewPaleteRequested = true;
 }
+
+void InventoryMan::f338_decreaseTorchesLightPower() {
+	int16 L1046_i_ChampionCount;
+	int16 L1047_i_SlotIndex;
+	bool L1048_B_TorchChargeCountChanged;
+	int16 L1049_i_IconIndex;
+	Champion* L1050_ps_Champion;
+	Weapon* L1051_ps_Weapon;
+
+
+	L1048_B_TorchChargeCountChanged = false;
+	L1046_i_ChampionCount = _vm->_championMan->_g305_partyChampionCount;
+	if (_vm->_championMan->_g299_candidateChampionOrdinal) {
+		L1046_i_ChampionCount--;
+	}
+	L1050_ps_Champion = _vm->_championMan->_gK71_champions;
+	while (L1046_i_ChampionCount--) {
+		L1047_i_SlotIndex = k1_ChampionSlotActionHand + 1;
+		while (L1047_i_SlotIndex--) {
+			L1049_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L1050_ps_Champion->_slots[L1047_i_SlotIndex]);
+			if ((L1049_i_IconIndex >= k4_IconIndiceWeaponTorchUnlit) && (L1049_i_IconIndex <= k7_IconIndiceWeaponTorchLit)) {
+				L1051_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L1050_ps_Champion->_slots[L1047_i_SlotIndex]);
+				if (L1051_ps_Weapon->getChargeCount()) {
+					if (L1051_ps_Weapon->setChargeCount(L1051_ps_Weapon->getChargeCount() - 1) == 0) {
+						L1051_ps_Weapon->setDoNotDiscard(false);
+					}
+					L1048_B_TorchChargeCountChanged = true;
+				}
+			}
+		}
+		L1050_ps_Champion++;
+	}
+	if (L1048_B_TorchChargeCountChanged) {
+		f337_setDungeonViewPalette();
+		_vm->_championMan->f296_drawChangedObjectIcons();
+	}
+}
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index aa9b215..35a76c4 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -79,6 +79,7 @@ public:
 	void f339_drawPanelArrowOrEye(bool pressingEye); // @ F0339_INVENTORY_DrawPanel_ArrowOrEye
 	void f342_drawPanelObject(Thing thingToDraw, bool pressingEye); // @ F0342_INVENTORY_DrawPanel_Object
 	void f337_setDungeonViewPalette(); // @ F0337_INVENTORY_SetDungeonViewPalette
+	void f338_decreaseTorchesLightPower(); // @ F0338_INVENTORY_DecreaseTorchesLightPower_CPSE
 
 };
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 66b293a..f42d955 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -52,6 +52,7 @@ MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
 	_g508_refreshActionArea = false;
 	_g509_actionAreaContainsIcons = false;
 	_g513_actionDamage = 0;
+	_g713_actionList.resetToZero();
 	_gK72_bitmapSpellAreaLine = new byte[96 * 12];
 }
 
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 4e03242..9c93fd0 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -40,10 +40,11 @@ class ActionList {
 public:
 	byte _minimumSkillLevel[3]; /* Bit 7: requires charge, Bit 6-0: minimum skill level. */
 	ChampionAction _actionIndices[3];
-	ActionList() {
+	ActionList() { resetToZero(); }
+	void resetToZero() {
 		for (uint16 i = 0; i < 3; ++i) {
 			_minimumSkillLevel[i] = 0;
-			_actionIndices[i] = k255_ChampionActionNone;
+			_actionIndices[i] = (ChampionAction)0;
 		}
 	}
 }; // @ ACTION_LIST
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 70f8cc8..2da2ee0 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -39,7 +39,18 @@
 
 namespace DM {
 
-MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {}
+MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {
+	_g397_moveResultMapX = 0;
+	_g398_moveResultMapY = 0;
+	_g399_moveResultMapIndex = 0;
+	_g400_moveResultDir = 0;
+	_g401_moveResultCell = 0;
+	_g402_useRopeToClimbDownPit = false;
+	_g403_sensorRotationEffect = 0;
+	_g404_sensorRotationEffMapX = 0;
+	_g405_sensorRotationEffMapY = 0;
+	_g406_sensorRotationEffCell = 0;
+}
 
 bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam) {
 	Thing L0750_T_ThingBeingProcessed;
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 157cfd8..976e671 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -91,6 +91,9 @@ ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {
 	_g30_slotBoxes[44] = SlotBox(179, 104, 0); /* Chest 7 */
 	_g30_slotBoxes[45] = SlotBox(196, 105, 0); /* Chest 8 */
 
+	for (uint16 i = 0; i < k199_ObjectNameCount; ++i)
+		_g352_objectNames[i] = nullptr;
+
 	_g412_objectIconForMousePointer = nullptr;
 }
 
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 95d40bb..5ce7b20 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -36,7 +36,13 @@
 namespace DM {
 
 ProjExpl::ProjExpl(DMEngine* vm) : _vm(vm) {
+	_g364_creatureDamageOutcome = 0;
+	_g363_secondaryDirToOrFromParty = 0;
 	_g361_lastCreatureAttackTime = -200;
+	_g365_createLanucherProjectile = false;
+	_g366_projectilePoisonAttack = 0;
+	_g367_projectileAttackType = 0;
+	_g362_lastPartyMovementTime = 0;
 }
 
 void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, direction dir, byte kineticEnergy, byte attack, byte stepEnergy) {
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index d9ca4b7..06a10b2 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -31,6 +31,10 @@
 namespace DM {
 
 TextMan::TextMan(DMEngine* vm) : _vm(vm) {
+	_g359_messageAreaCursorColumn = 0;
+	_g358_messageAreaCursorRow = 0;
+	for (uint16 i = 0; i < 4; ++i)
+		_g360_messageAreaRowExpirationTime[i] = 0;
 	_g356_bitmapMessageAreaNewRow = new byte[320 * 7];
 }
 
@@ -161,4 +165,28 @@ void TextMan::f46_messageAreaPrintString(Color color, const char* string) {
 	_g360_messageAreaRowExpirationTime[_g358_messageAreaCursorRow] = _vm->_g313_gameTime + 200;
 }
 
+void TextMan::f54_textInitialize() {
+	f42_messageAreaMoveCursor(0, 3);
+	for (uint16 i = 0; i < 4; ++i)
+		_g360_messageAreaRowExpirationTime[i] = -1;
+}
+
+void TextMan::f42_messageAreaMoveCursor(int16 column, int16 row) {
+	if (column < 0) {
+		column = 0;
+	} else {
+		if (column >= 53) {
+			column = 52;
+		}
+	}
+	_g359_messageAreaCursorColumn = column;
+	if (row < 0) {
+		row = 0;
+	} else {
+		if (row >= 4) {
+			row = 3;
+		}
+	}
+	_g358_messageAreaCursorRow = row;
+}
 }
diff --git a/engines/dm/text.h b/engines/dm/text.h
index b0ecb48..ce38c55 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -52,6 +52,9 @@ public:
 	void f47_messageAreaPrintMessage(Color color, const char *string); // @ F0047_TEXT_MESSAGEAREA_PrintMessage
 	void f45_messageAreaCreateNewRow(); // @ F0045_TEXT_MESSAGEAREA_CreateNewRow
 	void f46_messageAreaPrintString(Color color, const char* string);// @ F0046_TEXT_MESSAGEAREA_PrintString
+	void f54_textInitialize(); // @ F0054_TEXT_Initialize
+	void f42_messageAreaMoveCursor(int16 column, int16 row); // @ F0042_TEXT_MESSAGEAREA_MoveCursor
+
 
 
 };
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 2b58203..8b26210 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -32,8 +32,11 @@
 namespace DM {
 
 Timeline::Timeline(DMEngine* vm) : _vm(vm) {
+	_g369_eventMaxCount = 0;
 	_g370_events = nullptr;
+	_g372_eventCount = 0;
 	_g371_timeline = nullptr;
+	_g373_firstUnusedEventIndex = 0;
 }
 
 Timeline::~Timeline() {


Commit: 0d4b09980e7b7bb3cb0a63b9df6de7e01067a977
    https://github.com/scummvm/scummvm/commit/0d4b09980e7b7bb3cb0a63b9df6de7e01067a977
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Replace ChampionMan::f292_drawChampionState with original

Changed paths:
    engines/dm/champion.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/menus.cpp
    engines/dm/objectman.cpp
    engines/dm/text.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 6449140..96604e3 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1187,7 +1187,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 	{ // limit destBox scope
 		Box &destBox = gBoxChampionPortrait;
 		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), champ->_portrait,
-								  destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 128, 16, k255_ColorNoTransparency);
+								  destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 128, 16, kM1_ColorNoTransparency);
 	}
 
 	champ->_actionIndex = k255_ChampionActionNone;
@@ -1442,186 +1442,175 @@ uint16 ChampionMan::f309_getMaximumLoad(Champion *champ) {
 }
 
 void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
-	InventoryMan &invMan = *_vm->_inventoryMan;
-	DisplayMan &dispMan = *_vm->_displayMan;
-	MenuMan &menuMan = *_vm->_menuMan;
-	EventManager &eventMan = *_vm->_eventMan;
-
-	Box box;
-	int16 champStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
-	Champion *champ = &_gK71_champions[champIndex];
-	uint16 champAttributes = champ->getAttributes();
-	if (!((champAttributes) & (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon |
-							   k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport |
-							   k0x8000_ChampionAttributeActionHand))) {
+	uint16 L0862_ui_ChampionAttributes;
+	bool L0863_B_IsInventoryChampion;
+	int16 L0864_i_Multiple;
+#define AL0864_i_BorderCount       L0864_i_Multiple
+#define AL0864_i_ColorIndex        L0864_i_Multiple
+#define AL0864_i_Load              L0864_i_Multiple
+#define AL0864_i_ChampionIconIndex L0864_i_Multiple
+#define AL0864_i_StatisticIndex    L0864_i_Multiple
+#define AL0864_i_SlotIndex         L0864_i_Multiple
+	Champion* L0865_ps_Champion;
+	char* L0866_pc_ChampionName;
+	char L0867_c_ChampionTitleFirstCharacter;
+	int16 L0868_i_ChampionStatusBoxX;
+	int16 L0869_i_ChampionTitleX;
+	int16 L0870_i_Multiple;
+#define AL0870_i_NativeBitmapIndex L0870_i_Multiple
+#define AL0870_i_Color             L0870_i_Multiple
+	Box L0871_s_Box;
+	int16 L0872_ai_NativeBitmapIndices[3];
+
+
+	L0868_i_ChampionStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
+	L0865_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	L0862_ui_ChampionAttributes = L0865_ps_Champion->_attributes;
+	if (!getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand)) {
 		return;
 	}
-	bool isInventoryChamp = (_vm->M0_indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal);
-	dispMan._g578_useByteBoxCoordinates = false;
-	if (champAttributes & k0x1000_ChampionAttributeStatusBox) {
-		box._y1 = 0;
-		box._y2 = 28;
-		box._x1 = champStatusBoxX;
-		box._x2 = box._x1 + 66;
-		if (champ->_currHealth) {
-			dispMan.D24_fillScreenBox(box, k12_ColorDarkestGray);
-			int16 nativeBitmapIndices[3];
-			for (int16 i = 0; i < 3; ++i)
-				nativeBitmapIndices[i] = 0;
-			int16 AL_0_borderCount = 0;
-			if (_g407_party._fireShieldDefense > 0)
-				nativeBitmapIndices[AL_0_borderCount++] = k38_BorderPartyFireshieldIndice;
-			if (_g407_party._spellShieldDefense > 0)
-				nativeBitmapIndices[AL_0_borderCount++] = k39_BorderPartySpellshieldIndice;
-			if (_g407_party._shieldDefense > 0)
-				nativeBitmapIndices[AL_0_borderCount++] = k37_BorderPartyShieldIndice;
-			while (AL_0_borderCount--) {
-				dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(nativeBitmapIndices[AL_0_borderCount]),
-										  dispMan._g348_bitmapScreen, box, 0, 0, 40, k160_byteWidthScreen, k10_ColorFlesh);
+	L0863_B_IsInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	_vm->_eventMan->f78_showMouse();
+	if (getFlag(L0862_ui_ChampionAttributes, k0x1000_ChampionAttributeStatusBox)) {
+		L0871_s_Box._y1 = 0;
+		L0871_s_Box._y2 = 28;
+		L0871_s_Box._x2 = (L0871_s_Box._x1 = L0868_i_ChampionStatusBoxX) + 66;
+		if (L0865_ps_Champion->_currHealth) {
+			_vm->_displayMan->D24_fillScreenBox(L0871_s_Box, k12_ColorDarkestGray);
+			for (uint16 i = 0; i < 3; ++i)
+				L0872_ai_NativeBitmapIndices[i] = 0;
+			AL0864_i_BorderCount = 0;
+			if (_vm->_championMan->_g407_party._fireShieldDefense > 0) {
+				L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k38_BorderPartyFireshieldIndice;
+			}
+			if (_vm->_championMan->_g407_party._spellShieldDefense > 0) {
+				L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k39_BorderPartySpellshieldIndice;
+			}
+			if ((_vm->_championMan->_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) {
+				L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k37_BorderPartyShieldIndice;
 			}
-			if (isInventoryChamp) {
-				invMan.f354_drawStatusBoxPortrait(champIndex);
-				champAttributes |= k0x0100_ChampionAttributeStatistics;
+			while (AL0864_i_BorderCount--) {
+				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount]), &L0871_s_Box, k40_byteWidth, k10_ColorFlesh, 29);
+			}
+			if (L0863_B_IsInventoryChampion) {
+				_vm->_inventoryMan->f354_drawStatusBoxPortrait(champIndex);
+				setFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics);
 			} else {
-				champAttributes |= (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand);
+				setFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand);
 			}
 		} else {
-			dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), dispMan._g348_bitmapScreen,
-									  box, 0, 0, 40, k160_byteWidthScreen, k255_ColorNoTransparency);
-			_vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, champ->_name);
-			menuMan.f386_drawActionIcon(champIndex);
-			goto T0292042_green;
-		}
-	}
-
-	if (!champ->_currHealth)
-		goto T0292042_green;
-
-	if (champAttributes & k0x0080_ChampionAttributeNameTitle) {
-		Color AL_0_colorIndex = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; // unused because of missing functions
-		if (isInventoryChamp) {
-			char *champName = champ->_name;
-			_vm->_textMan->f52_printToViewport(3, 7, AL_0_colorIndex, champName);
-			int16 champTitleX = 6 * strlen(champName) + 3;
-			char champTitleFirstChar = champ->_title[0];
-			if ((champTitleFirstChar != ',') && (champTitleFirstChar != ';') && (champTitleFirstChar != '-')) {
-				champTitleX += 6;
+			_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), &L0871_s_Box, k40_byteWidth, kM1_ColorNoTransparency, 29);
+			_vm->_textMan->f53_printToLogicalScreen(L0868_i_ChampionStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, L0865_ps_Champion->_name);
+			_vm->_menuMan->f386_drawActionIcon(champIndex);
+			goto T0292042;
+		}
+	}
+	if (!(L0865_ps_Champion->_currHealth))
+		goto T0292042;
+	if (getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle)) {
+		AL0864_i_ColorIndex = (champIndex == _vm->_championMan->_g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
+		if (L0863_B_IsInventoryChampion) {
+			_vm->_textMan->f52_printToViewport(3, 7, (Color)AL0864_i_ColorIndex, L0866_pc_ChampionName = L0865_ps_Champion->_name);
+			L0869_i_ChampionTitleX = 6 * strlen(L0866_pc_ChampionName) + 3;
+			L0867_c_ChampionTitleFirstCharacter = L0865_ps_Champion->_title[0];
+			if ((L0867_c_ChampionTitleFirstCharacter != ',') && (L0867_c_ChampionTitleFirstCharacter != ';') && (L0867_c_ChampionTitleFirstCharacter != '-')) {
+				L0869_i_ChampionTitleX += 6;
 			}
-			_vm->_textMan->f52_printToViewport(champTitleX, 7, AL_0_colorIndex, champ->_title);
-			champAttributes |= k0x4000_ChampionAttributeViewport;
+			_vm->_textMan->f52_printToViewport(L0869_i_ChampionTitleX, 7, (Color)AL0864_i_ColorIndex, L0865_ps_Champion->_title);
+			setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
 		} else {
-			box._y1 = 0;
-			box._y2 = 6;
-			box._x1 = champStatusBoxX;
-			box._x2 = box._x1 + 42;
-			dispMan.D24_fillScreenBox(box, k1_ColorDarkGary);
-			_vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, k1_ColorDarkGary, champ->_name);
-		}
-	}
-
-	if (champAttributes & k0x0100_ChampionAttributeStatistics) {
-		f287_drawChampionBarGraphs(champIndex);
-		if (isInventoryChamp) {
-			f290_drawHealthStaminaManaValues(champ);
-			int16 AL_2_nativeBitmapIndex;
-			if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) {
-				AL_2_nativeBitmapIndex = k34_SlotBoxWoundedIndice;
+			L0871_s_Box._y1 = 0;
+			L0871_s_Box._y2 = 6;
+			L0871_s_Box._x2 = (L0871_s_Box._x1 = L0868_i_ChampionStatusBoxX) + 42;
+			_vm->_displayMan->D24_fillScreenBox(L0871_s_Box, k1_ColorDarkGary);
+			_vm->_textMan->f53_printToLogicalScreen(L0868_i_ChampionStatusBoxX + 1, 5, (Color)AL0864_i_ColorIndex, k1_ColorDarkGary, L0865_ps_Champion->_name);
+		}
+	}
+	if (getFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics)) {
+		_vm->_championMan->f287_drawChampionBarGraphs(champIndex);
+		if (L0863_B_IsInventoryChampion) {
+			_vm->_championMan->f290_drawHealthStaminaManaValues(L0865_ps_Champion);
+			if ((L0865_ps_Champion->_food < 0) || (L0865_ps_Champion->_water < 0) || (L0865_ps_Champion->_poisonEventCount)) {
+				AL0870_i_NativeBitmapIndex = k34_SlotBoxWoundedIndice;
 			} else {
-				AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice;
+				AL0870_i_NativeBitmapIndex = k33_SlotBoxNormalIndice;
 			}
-			dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport,
-									  gBoxMouth, 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray);
-			AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice;
-			for (int16 AL_0_statisticIndex = k1_ChampionStatStrength; AL_0_statisticIndex <= k6_ChampionStatAntifire; AL_0_statisticIndex++) {
-				if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent)
-					< champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, k0_ChampionStatMaximum)) {
-					AL_2_nativeBitmapIndex = k34_SlotBoxWoundedIndice;
+			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(AL0870_i_NativeBitmapIndex), gBoxMouth, k16_byteWidth, k12_ColorDarkestGray, 18);
+			AL0870_i_NativeBitmapIndex = k33_SlotBoxNormalIndice;
+			for (AL0864_i_StatisticIndex = k1_ChampionStatStrength; AL0864_i_StatisticIndex <= k6_ChampionStatAntifire; AL0864_i_StatisticIndex++) {
+				if ((L0865_ps_Champion->_statistics[AL0864_i_StatisticIndex][k1_ChampionStatCurrent] < L0865_ps_Champion->_statistics[AL0864_i_StatisticIndex][k0_ChampionStatMaximum])) {
+					AL0870_i_NativeBitmapIndex = k34_SlotBoxWoundedIndice;
 					break;
 				}
 			}
-			dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport, gBoxEye,
-									  0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray);
-			champAttributes |= k0x4000_ChampionAttributeViewport;
+			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(AL0870_i_NativeBitmapIndex), gBoxEye, k16_byteWidth, k12_ColorDarkestGray, 18);
+			setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
 		}
 	}
-
-	if (champAttributes & k0x2000_ChampionAttributeWounds) {
-		for (int16 AL_0_slotIndex = isInventoryChamp ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL_0_slotIndex >= k0_ChampionSlotReadyHand; AL_0_slotIndex--) {
-			f291_drawSlot(champIndex, (ChampionSlot)AL_0_slotIndex);
+	if (getFlag(L0862_ui_ChampionAttributes, k0x2000_ChampionAttributeWounds)) {
+		for (AL0864_i_SlotIndex = L0863_B_IsInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL0864_i_SlotIndex >= k0_ChampionSlotReadyHand; AL0864_i_SlotIndex--) {
+			_vm->_championMan->f291_drawSlot(champIndex, AL0864_i_SlotIndex);
 		}
-		if (isInventoryChamp) {
-			champAttributes |= k0x4000_ChampionAttributeViewport;
+		if (L0863_B_IsInventoryChampion) {
+			setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
 		}
 	}
-
-	if ((champAttributes & k0x0200_ChampionAttributeLoad) && isInventoryChamp) {
-		Color loadColor;
-		int16 champMaxLoad = f309_getMaximumLoad(champ);
-		if (champ->_load > champMaxLoad) {
-			loadColor = k8_ColorRed;
-		} else if (((int32)champ->_load) * 8 > ((int32)champMaxLoad) * 5) {
-			loadColor = k11_ColorYellow;
+	if (getFlag(L0862_ui_ChampionAttributes, k0x0200_ChampionAttributeLoad) && L0863_B_IsInventoryChampion) {
+		if (L0865_ps_Champion->_load > (AL0864_i_Load = _vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion))) {
+			AL0870_i_Color = k8_ColorRed;
 		} else {
-			loadColor = k13_ColorLightestGray;
-		}
-		_vm->_textMan->f52_printToViewport(104, 132, loadColor, "LOAD ");
-
-		int16 loadTmp = champ->_load / 10;
-		Common::String str = f288_getStringFromInteger(loadTmp, true, 3);
-		str += '.';
-		loadTmp = champ->_load - (loadTmp * 10);
-		str += f288_getStringFromInteger(loadTmp, false, 1);
-		str += '/';
-		loadTmp = (f309_getMaximumLoad(champ) + 5) / 10;
-		str += "KG";
-		_vm->_textMan->f52_printToViewport(148, 132, loadColor, str.c_str());
-		champAttributes |= k0x4000_ChampionAttributeViewport;
-	}
-
-	{ // block so goto won't skip AL_0_championIconIndex initialization 
-		int16 AL_0_championIconIndex = M26_championIconIndex(champ->_cell, _vm->_dungeonMan->_g308_partyDir);
-
-		if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL_0_championIconIndex))) {
-			dispMan.D24_fillScreenBox(g54_BoxChampionIcons[AL_0_championIconIndex], g46_ChampionColor[champIndex]);
-			dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k28_ChampionIcons),
-									  dispMan._g348_bitmapScreen,
-									  g54_BoxChampionIcons[AL_0_championIconIndex << 2],
-									  M26_championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0,
-									  40, k160_byteWidthScreen, k12_ColorDarkestGray);
+			if (((long)L0865_ps_Champion->_load << 3) > ((long)AL0864_i_Load * 5)) {
+				AL0870_i_Color = k11_ColorYellow;
+			} else {
+				AL0870_i_Color = k13_ColorLightestGray;
+			}
 		}
-	}
-
-	if ((champAttributes & k0x0800_ChampionAttributePanel) && isInventoryChamp) {
+		_vm->_textMan->f52_printToViewport(104, 132, (Color)AL0870_i_Color, "LOAD ");
+		AL0864_i_Load = L0865_ps_Champion->_load / 10;
+		strcpy(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
+		strcat(_vm->_g353_stringBuildBuffer, ".");
+		AL0864_i_Load = L0865_ps_Champion->_load - (AL0864_i_Load * 10);
+		strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str());
+		strcat(_vm->_g353_stringBuildBuffer, "/");
+		AL0864_i_Load = (_vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10;
+		strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
+		strcat(_vm->_g353_stringBuildBuffer, " KG");
+		_vm->_textMan->f52_printToViewport(148, 132, (Color)AL0870_i_Color, _vm->_g353_stringBuildBuffer);
+		setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
+	}
+	AL0864_i_ChampionIconIndex = _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir);
+	if (getFlag(L0862_ui_ChampionAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL0864_i_ChampionIconIndex))) {
+		_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], g46_ChampionColor[champIndex]);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
+	}
+	if (getFlag(L0862_ui_ChampionAttributes, k0x0800_ChampionAttributePanel) && L0863_B_IsInventoryChampion) {
 		if (_vm->_g333_pressingMouth) {
-			invMan.f345_drawPanelFoodWaterPoisoned();
-		} else if (_vm->_g331_pressingEye) {
-			if (_g415_leaderEmptyHanded) {
-				warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics");
-			}
+			_vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned();
 		} else {
-			invMan.f347_drawPanel();
+			if (_vm->_g331_pressingEye) {
+				if (_vm->_championMan->_g415_leaderEmptyHanded) {
+					_vm->_inventoryMan->f351_drawChampionSkillsAndStatistics();
+				}
+			} else {
+				_vm->_inventoryMan->f347_drawPanel();
+			}
 		}
-		champAttributes |= k0x4000_ChampionAttributeViewport;
+		setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
 	}
-
-	if (champAttributes & k0x8000_ChampionAttributeActionHand) {
-		f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
-		menuMan.f386_drawActionIcon(champIndex);
-		if (isInventoryChamp) {
-			champAttributes |= k0x4000_ChampionAttributeViewport;
+	if (getFlag(L0862_ui_ChampionAttributes, k0x8000_ChampionAttributeActionHand)) {
+		_vm->_championMan->f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
+		_vm->_menuMan->f386_drawActionIcon(champIndex);
+		if (L0863_B_IsInventoryChampion) {
+			setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
 		}
 	}
-
-	if (champAttributes & k0x4000_ChampionAttributeViewport) {
-		dispMan.f97_drawViewport(k0_viewportNotDungeonView);
+	if (getFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport)) {
+		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
 	}
-
-
-T0292042_green:
-	champ->setAttributeFlag((ChampionAttribute)(k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon |
-												k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport |
-												k0x8000_ChampionAttributeActionHand), false);
-	_vm->_eventMan->f78_showMouse();
+T0292042:
+	clearFlag(L0865_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
+	_vm->_eventMan->f77_hideMouse();
 }
 
 uint16 ChampionMan::M26_championIconIndex(int16 val, direction dir) {
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 99a0e17..2fbefb1 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -359,7 +359,7 @@ void EventManager::f68_setPointerToObject(byte* bitmap) {
 	L0051_puc_Bitmap = _g615_mousePointerOriginalColorsObject;
 	memset(L0051_puc_Bitmap, 0, 32 * 18);
 	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, gK27_palChangesMousepointerOjbectIconShadow);
-	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, k255_ColorNoTransparency, 16, 18);
+	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
 	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, g44_palChangesMousePointerIcon);
 	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
 	_gK100_preventBuildPointerScreenArea = false;
@@ -472,7 +472,7 @@ void EventManager::f78_showMouse() {
 }
 
 void EventManager::f77_hideMouse() {
-	CursorMan.showMouse(false);
+	// CursorMan.showMouse(false);
 }
 
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 7411f0c..25f0e4b 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -708,16 +708,16 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 
 	g186_doorFrame_D1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(64, 159, 17, 102, 48, 88,  0,  0),	/* Closed Or Destroyed */
-		Frame(64, 159, 17,  38, 48, 88,  0, 66),	/* Vertical Closed one fourth */
-		Frame(64, 159, 17,  60, 48, 88,  0, 44),	/* Vertical Closed half */
-		Frame(64, 159, 17,  82, 48, 88,  0, 22),	/* Vertical Closed three fourth */
-		Frame(64,  75, 17, 102, 48, 88, 36,  0),	/* Left Horizontal Closed one fourth */
-		Frame(64,  87, 17, 102, 48, 88, 24,  0),	/* Left Horizontal Closed half */
-		Frame(64,  99, 17, 102, 48, 88, 12,  0),	/* Left Horizontal Closed three fourth */
-		Frame(148, 159, 17, 102, 48, 88, 48,  0),	/* Right Horizontal Closed one fourth */
-		Frame(136, 159, 17, 102, 48, 88, 48,  0),	/* Right Horizontal Closed half */
-		Frame(124, 159, 17, 102, 48, 88, 48,  0)	/* Right Horizontal Closed three fourth */
+										Frame(64, 159, 17, 102, 48, 88, 0, 0),	/* Closed Or Destroyed */
+										Frame(64, 159, 17, 38, 48, 88, 0, 66),	/* Vertical Closed one fourth */
+										Frame(64, 159, 17, 60, 48, 88, 0, 44),	/* Vertical Closed half */
+										Frame(64, 159, 17, 82, 48, 88, 0, 22),	/* Vertical Closed three fourth */
+										Frame(64, 75, 17, 102, 48, 88, 36, 0),	/* Left Horizontal Closed one fourth */
+										Frame(64, 87, 17, 102, 48, 88, 24, 0),	/* Left Horizontal Closed half */
+										Frame(64, 99, 17, 102, 48, 88, 12, 0),	/* Left Horizontal Closed three fourth */
+										Frame(148, 159, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed one fourth */
+										Frame(136, 159, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed half */
+										Frame(124, 159, 17, 102, 48, 88, 48, 0)	/* Right Horizontal Closed three fourth */
 	);
 }
 
@@ -1056,7 +1056,7 @@ void DisplayMan::f566_viewportBlitToScreen() {
 	warning("MISSING FUNCTIONALITY: using correct colorpalette");
 	Box box(0, 223, 33, 33 + 135);
 
-	f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport, k160_byteWidthScreen, k255_ColorNoTransparency);
+	f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport, k160_byteWidthScreen, kM1_ColorNoTransparency);
 }
 
 void DisplayMan::loadPalette(uint16 *palette) {
@@ -1442,6 +1442,15 @@ void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame* frame, int1
 	}
 }
 
+void DisplayMan::f20_blitToViewport(byte* bitmap, Box& box, int16 byteWidth, Color transparent, int16 height) {
+	f132_blitToBitmap(bitmap, _g296_bitmapViewport, box, 0, 0, byteWidth, k112_byteWidthViewport, transparent, height, k136_heightViewport);
+}
+
+void DisplayMan::f20_blitToViewport(byte* bitmap, int16* box, int16 byteWidth, Color transparent, int16 height) {
+	Box actualBox(box[0], box[1], box[2], box[3]);
+	f20_blitToViewport(bitmap, actualBox, byteWidth, transparent, height);
+}
+
 void DisplayMan::f21_blitToScreen(byte *bitmap, int16* box, int16 byteWidth, Color transparent, int16 height) {
 	Box actualBox(box[0], box[1], box[2], box[3]);
 	f21_blitToScreen(bitmap, &actualBox, byteWidth, transparent, height);
@@ -1454,7 +1463,7 @@ void DisplayMan::f21_blitToScreen(byte* bitmap, Box* box, int16 viewDoorOrnIndex
 
 void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
 	if (f._srcByteWidth)
-		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency);
+		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency);
 }
 
 void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) {
@@ -1467,16 +1476,16 @@ void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) {
 void DisplayMan::f116_drawSquareD3L(direction dir, int16 posX, int16 posY) {
 	static DoorFrames g179_doorFrame_D3L = DoorFrames( // @ G0179_s_Graphic558_Frames_Door_D3L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(24, 71, 28, 67, 24, 41,  0,  0),     /* Closed Or Destroyed */
-		Frame(24, 71, 28, 38, 24, 41,  0, 30),     /* Vertical Closed one fourth */
-		Frame(24, 71, 28, 48, 24, 41,  0, 20),     /* Vertical Closed half */
-		Frame(24, 71, 28, 58, 24, 41,  0, 10),   /* Vertical Closed three fourth */
-		Frame(24, 29, 28, 67, 24, 41, 18,  0),     /* Left Horizontal Closed one fourth */
-		Frame(24, 35, 28, 67, 24, 41, 12,  0),     /* Left Horizontal Closed half */
-		Frame(24, 41, 28, 67, 24, 41,  6,  0),   /* Left Horizontal Closed three fourth */
-		Frame(66, 71, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed one fourth */
-		Frame(60, 71, 28, 67, 24, 41, 24,  0),     /* Right Horizontal Closed half */
-		Frame(54, 71, 28, 67, 24, 41, 24,  0)
+													  Frame(24, 71, 28, 67, 24, 41, 0, 0),     /* Closed Or Destroyed */
+													  Frame(24, 71, 28, 38, 24, 41, 0, 30),     /* Vertical Closed one fourth */
+													  Frame(24, 71, 28, 48, 24, 41, 0, 20),     /* Vertical Closed half */
+													  Frame(24, 71, 28, 58, 24, 41, 0, 10),   /* Vertical Closed three fourth */
+													  Frame(24, 29, 28, 67, 24, 41, 18, 0),     /* Left Horizontal Closed one fourth */
+													  Frame(24, 35, 28, 67, 24, 41, 12, 0),     /* Left Horizontal Closed half */
+													  Frame(24, 41, 28, 67, 24, 41, 6, 0),   /* Left Horizontal Closed three fourth */
+													  Frame(66, 71, 28, 67, 24, 41, 24, 0),     /* Right Horizontal Closed one fourth */
+													  Frame(60, 71, 28, 67, 24, 41, 24, 0),     /* Right Horizontal Closed half */
+													  Frame(54, 71, 28, 67, 24, 41, 24, 0)
 	); /* Right Horizontal Closed three fourth */
 
 	uint16 squareAspect[5];
@@ -1532,16 +1541,16 @@ T0116017_orangeElk:
 void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) {
 	static DoorFrames g181_doorFrame_D3R = DoorFrames( // @ G0181_s_Graphic558_Frames_Door_D3R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(150, 197, 28, 67, 24, 41,  0,  0),	/* Closed Or Destroyed */
-		Frame(150, 197, 28, 38, 24, 41,  0, 30),	/* Vertical Closed one fourth */
-		Frame(150, 197, 28, 48, 24, 41,  0, 20),	/* Vertical Closed half */
-		Frame(150, 197, 28, 58, 24, 41,  0, 10),	/* Vertical Closed three fourth */
-		Frame(150, 153, 28, 67, 24, 41, 18,  0),	/* Left Horizontal Closed one fourth */
-		Frame(150, 161, 28, 67, 24, 41, 12,  0),	/* Left Horizontal Closed half */
-		Frame(150, 167, 28, 67, 24, 41,  6,  0),	/* Left Horizontal Closed three fourth */
-		Frame(192, 197, 28, 67, 24, 41, 24,  0),	/* Right Horizontal Closed one fourth */
-		Frame(186, 197, 28, 67, 24, 41, 24,  0),	/* Right Horizontal Closed half */
-		Frame(180, 197, 28, 67, 24, 41, 24,  0)		/* Right Horizontal Closed three fourth */
+													  Frame(150, 197, 28, 67, 24, 41, 0, 0),	/* Closed Or Destroyed */
+													  Frame(150, 197, 28, 38, 24, 41, 0, 30),	/* Vertical Closed one fourth */
+													  Frame(150, 197, 28, 48, 24, 41, 0, 20),	/* Vertical Closed half */
+													  Frame(150, 197, 28, 58, 24, 41, 0, 10),	/* Vertical Closed three fourth */
+													  Frame(150, 153, 28, 67, 24, 41, 18, 0),	/* Left Horizontal Closed one fourth */
+													  Frame(150, 161, 28, 67, 24, 41, 12, 0),	/* Left Horizontal Closed half */
+													  Frame(150, 167, 28, 67, 24, 41, 6, 0),	/* Left Horizontal Closed three fourth */
+													  Frame(192, 197, 28, 67, 24, 41, 24, 0),	/* Right Horizontal Closed one fourth */
+													  Frame(186, 197, 28, 67, 24, 41, 24, 0),	/* Right Horizontal Closed half */
+													  Frame(180, 197, 28, 67, 24, 41, 24, 0)		/* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
@@ -1603,16 +1612,16 @@ T0117018:
 void DisplayMan::f118_drawSquareD3C(direction dir, int16 posX, int16 posY) {
 	static DoorFrames g180_doorFrame_D3C = DoorFrames( // @ G0180_s_Graphic558_Frames_Door_D3C
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(88, 135, 28, 67, 24, 41,  0,  0),		/* Closed Or Destroyed */
-		Frame(88, 135, 28, 38, 24, 41,  0, 30),		/* Vertical Closed one fourth */
-		Frame(88, 135, 28, 48, 24, 41,  0, 20),		/* Vertical Closed half */
-		Frame(88, 135, 28, 58, 24, 41,  0, 10),		/* Vertical Closed three fourth */
-		Frame(88,  93, 28, 67, 24, 41, 18,  0),		/* Left Horizontal Closed one fourth */
-		Frame(88,  99, 28, 67, 24, 41, 12,  0),		/* Left Horizontal Closed half */
-		Frame(88, 105, 28, 67, 24, 41,  6,  0),		/* Left Horizontal Closed three fourth */
-		Frame(130, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed one fourth */
-		Frame(124, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed half */
-		Frame(118, 135, 28, 67, 24, 41, 24, 0)		/* Right Horizontal Closed three fourth */
+													  Frame(88, 135, 28, 67, 24, 41, 0, 0),		/* Closed Or Destroyed */
+													  Frame(88, 135, 28, 38, 24, 41, 0, 30),		/* Vertical Closed one fourth */
+													  Frame(88, 135, 28, 48, 24, 41, 0, 20),		/* Vertical Closed half */
+													  Frame(88, 135, 28, 58, 24, 41, 0, 10),		/* Vertical Closed three fourth */
+													  Frame(88, 93, 28, 67, 24, 41, 18, 0),		/* Left Horizontal Closed one fourth */
+													  Frame(88, 99, 28, 67, 24, 41, 12, 0),		/* Left Horizontal Closed half */
+													  Frame(88, 105, 28, 67, 24, 41, 6, 0),		/* Left Horizontal Closed three fourth */
+													  Frame(130, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed one fourth */
+													  Frame(124, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed half */
+													  Frame(118, 135, 28, 67, 24, 41, 24, 0)		/* Right Horizontal Closed three fourth */
 	);
 	int16 order;
 	int16 squareAspect[5];
@@ -1667,16 +1676,16 @@ T0118028:
 void DisplayMan::f119_drawSquareD2L(direction dir, int16 posX, int16 posY) {
 	static DoorFrames g182_doorFrame_D2L = DoorFrames( // @ G0182_s_Graphic558_Frames_Door_D2L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(0, 63, 24, 82, 32, 61,  0,  0),	/* Closed Or Destroyed */
-		Frame(0, 63, 24, 39, 32, 61,  0, 45),	/* Vertical Closed one fourth */
-		Frame(0, 63, 24, 54, 32, 61,  0, 30),	/* Vertical Closed half */
-		Frame(0, 63, 24, 69, 32, 61,  0, 15),	/* Vertical Closed three fourth */
-		Frame(0,  7, 24, 82, 32, 61, 24,  0),	/* Left Horizontal Closed one fourth */
-		Frame(0, 15, 24, 82, 32, 61, 16,  0),	/* Left Horizontal Closed half */
-		Frame(0, 23, 24, 82, 32, 61,  8,  0),	/* Left Horizontal Closed three fourth */
-		Frame(56, 63, 24, 82, 32, 61, 32,  0),	/* Right Horizontal Closed one fourth */
-		Frame(48, 63, 24, 82, 32, 61, 32,  0),	/* Right Horizontal Closed half */
-		Frame(40, 63, 24, 82, 32, 61, 32,  0)	/* Right Horizontal Closed three fourth */
+													  Frame(0, 63, 24, 82, 32, 61, 0, 0),	/* Closed Or Destroyed */
+													  Frame(0, 63, 24, 39, 32, 61, 0, 45),	/* Vertical Closed one fourth */
+													  Frame(0, 63, 24, 54, 32, 61, 0, 30),	/* Vertical Closed half */
+													  Frame(0, 63, 24, 69, 32, 61, 0, 15),	/* Vertical Closed three fourth */
+													  Frame(0, 7, 24, 82, 32, 61, 24, 0),	/* Left Horizontal Closed one fourth */
+													  Frame(0, 15, 24, 82, 32, 61, 16, 0),	/* Left Horizontal Closed half */
+													  Frame(0, 23, 24, 82, 32, 61, 8, 0),	/* Left Horizontal Closed three fourth */
+													  Frame(56, 63, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed one fourth */
+													  Frame(48, 63, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed half */
+													  Frame(40, 63, 24, 82, 32, 61, 32, 0)	/* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
@@ -1733,16 +1742,16 @@ T0119020:
 void DisplayMan::f120_drawSquareD2R(direction dir, int16 posX, int16 posY) {
 	static DoorFrames g184_doorFrame_D2R = DoorFrames( // @ G0184_s_Graphic558_Frames_Door_D2R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(160, 223, 24, 82, 32, 61,  0,  0),	/* Closed Or Destroyed */
-		Frame(160, 223, 24, 39, 32, 61,  0, 45),	/* Vertical Closed one fourth */
-		Frame(160, 223, 24, 54, 32, 61,  0, 30),	/* Vertical Closed half */
-		Frame(160, 223, 24, 69, 32, 61,  0, 15),	/* Vertical Closed three fourth */
-		Frame(160, 167, 24, 82, 32, 61, 24,  0),	/* Left Horizontal Closed one fourth */
-		Frame(160, 175, 24, 82, 32, 61, 16,  0),	/* Left Horizontal Closed half */
-		Frame(160, 183, 24, 82, 32, 61,  8,  0),	/* Left Horizontal Closed three fourth */
-		Frame(216, 223, 24, 82, 32, 61, 32,  0),	/* Right Horizontal Closed one fourth */
-		Frame(208, 223, 24, 82, 32, 61, 32,  0),	/* Right Horizontal Closed half */
-		Frame(200, 223, 24, 82, 32, 61, 32,  0)		/* Right Horizontal Closed three fourth */
+													  Frame(160, 223, 24, 82, 32, 61, 0, 0),	/* Closed Or Destroyed */
+													  Frame(160, 223, 24, 39, 32, 61, 0, 45),	/* Vertical Closed one fourth */
+													  Frame(160, 223, 24, 54, 32, 61, 0, 30),	/* Vertical Closed half */
+													  Frame(160, 223, 24, 69, 32, 61, 0, 15),	/* Vertical Closed three fourth */
+													  Frame(160, 167, 24, 82, 32, 61, 24, 0),	/* Left Horizontal Closed one fourth */
+													  Frame(160, 175, 24, 82, 32, 61, 16, 0),	/* Left Horizontal Closed half */
+													  Frame(160, 183, 24, 82, 32, 61, 8, 0),	/* Left Horizontal Closed three fourth */
+													  Frame(216, 223, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed one fourth */
+													  Frame(208, 223, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed half */
+													  Frame(200, 223, 24, 82, 32, 61, 32, 0)		/* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
@@ -1801,16 +1810,16 @@ T0120029:
 void DisplayMan::f121_drawSquareD2C(direction dir, int16 posX, int16 posY) {
 	static DoorFrames g183_doorFrame_D2C = DoorFrames( // @ G0183_s_Graphic558_Frames_Door_D2C
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(80, 143, 24, 82, 32, 61,  0,  0),		/* Closed Or Destroyed */
-		Frame(80, 143, 24, 39, 32, 61,  0, 45),		/* Vertical Closed one fourth */
-		Frame(80, 143, 24, 54, 32, 61,  0, 30),		/* Vertical Closed half */
-		Frame(80, 143, 24, 69, 32, 61,  0, 15),		/* Vertical Closed three fourth */
-		Frame(80,  87, 24, 82, 32, 61, 24,  0),		/* Left Horizontal Closed one fourth */
-		Frame(80,  95, 24, 82, 32, 61, 16,  0),		/* Left Horizontal Closed half */
-		Frame(80, 103, 24, 82, 32, 61,  8,  0),		/* Left Horizontal Closed three fourth */
-		Frame(136, 143, 24, 82, 32, 61, 32,  0),	/* Right Horizontal Closed one fourth */
-		Frame(128, 143, 24, 82, 32, 61, 32,  0),	/* Right Horizontal Closed half */
-		Frame(120, 143, 24, 82, 32, 61, 32,  0)		/* Right Horizontal Closed three fourth */
+													  Frame(80, 143, 24, 82, 32, 61, 0, 0),		/* Closed Or Destroyed */
+													  Frame(80, 143, 24, 39, 32, 61, 0, 45),		/* Vertical Closed one fourth */
+													  Frame(80, 143, 24, 54, 32, 61, 0, 30),		/* Vertical Closed half */
+													  Frame(80, 143, 24, 69, 32, 61, 0, 15),		/* Vertical Closed three fourth */
+													  Frame(80, 87, 24, 82, 32, 61, 24, 0),		/* Left Horizontal Closed one fourth */
+													  Frame(80, 95, 24, 82, 32, 61, 16, 0),		/* Left Horizontal Closed half */
+													  Frame(80, 103, 24, 82, 32, 61, 8, 0),		/* Left Horizontal Closed three fourth */
+													  Frame(136, 143, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed one fourth */
+													  Frame(128, 143, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed half */
+													  Frame(120, 143, 24, 82, 32, 61, 32, 0)		/* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
@@ -1867,16 +1876,16 @@ T0121016:
 void DisplayMan::f122_drawSquareD1L(direction dir, int16 posX, int16 posY) {
 	static DoorFrames g185_doorFrame_D1L = DoorFrames( // @ G0185_s_Graphic558_Frames_Door_D1L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(0, 31, 17, 102, 48, 88, 64,  0),	/* Closed Or Destroyed */
-		Frame(0, 31, 17,  38, 48, 88, 64, 66),	/* Vertical Closed one fourth */
-		Frame(0, 31, 17,  60, 48, 88, 64, 44),	/* Vertical Closed half */
-		Frame(0, 31, 17,  82, 48, 88, 64, 22),	/* Vertical Closed three fourth */
-		Frame(0,  0,  0,   0,  0,  0,  0,  0),	/* Left Horizontal Closed one fourth */
-		Frame(0,  0,  0,   0,  0,  0,  0,  0),	/* Left Horizontal Closed half */
-		Frame(0,  0,  0,   0,  0,  0,  0,  0),	/* Left Horizontal Closed three fourth */
-		Frame(20, 31, 17, 102, 48, 88, 48,  0),	/* Right Horizontal Closed one fourth */
-		Frame(8, 31, 17, 102, 48, 88, 48,  0),	/* Right Horizontal Closed half */
-		Frame(0, 31, 17, 102, 48, 88, 52,  0)	/* Right Horizontal Closed three fourth */
+													  Frame(0, 31, 17, 102, 48, 88, 64, 0),	/* Closed Or Destroyed */
+													  Frame(0, 31, 17, 38, 48, 88, 64, 66),	/* Vertical Closed one fourth */
+													  Frame(0, 31, 17, 60, 48, 88, 64, 44),	/* Vertical Closed half */
+													  Frame(0, 31, 17, 82, 48, 88, 64, 22),	/* Vertical Closed three fourth */
+													  Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed one fourth */
+													  Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed half */
+													  Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed three fourth */
+													  Frame(20, 31, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed one fourth */
+													  Frame(8, 31, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed half */
+													  Frame(0, 31, 17, 102, 48, 88, 52, 0)	/* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
@@ -1934,16 +1943,16 @@ T0122021:
 void DisplayMan::f123_drawSquareD1R(direction dir, int16 posX, int16 posY) {
 	static DoorFrames g187_doorFrame_D1R = DoorFrames( // @ G0187_s_Graphic558_Frames_Door_D1R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(192, 223, 17, 102, 48, 88,  0,  0),     /* Closed Or Destroyed */
-		Frame(192, 223, 17,  38, 48, 88,  0, 66),     /* Vertical Closed one fourth */
-		Frame(192, 223, 17,  60, 48, 88,  0, 44),     /* Vertical Closed half */
-		Frame(192, 223, 17,  82, 48, 88,  0, 22),   /* Vertical Closed three fourth */
-		Frame(192, 203, 17, 102, 48, 88, 36,  0),     /* Left Horizontal Closed one fourth */
-		Frame(192, 215, 17, 102, 48, 88, 24,  0),     /* Left Horizontal Closed half */
-		Frame(192, 223, 17, 102, 48, 88, 12,  0),   /* Left Horizontal Closed three fourth */
-		Frame(0,   0,  0,   0,  0,  0,  0,  0),     /* Right Horizontal Closed one fourth */
-		Frame(0,   0,  0,   0,  0,  0,  0,  0),     /* Right Horizontal Closed half */
-		Frame(0,   0,  0,   0,  0,  0,  0,  0)
+													  Frame(192, 223, 17, 102, 48, 88, 0, 0),     /* Closed Or Destroyed */
+													  Frame(192, 223, 17, 38, 48, 88, 0, 66),     /* Vertical Closed one fourth */
+													  Frame(192, 223, 17, 60, 48, 88, 0, 44),     /* Vertical Closed half */
+													  Frame(192, 223, 17, 82, 48, 88, 0, 22),   /* Vertical Closed three fourth */
+													  Frame(192, 203, 17, 102, 48, 88, 36, 0),     /* Left Horizontal Closed one fourth */
+													  Frame(192, 215, 17, 102, 48, 88, 24, 0),     /* Left Horizontal Closed half */
+													  Frame(192, 223, 17, 102, 48, 88, 12, 0),   /* Left Horizontal Closed three fourth */
+													  Frame(0, 0, 0, 0, 0, 0, 0, 0),     /* Right Horizontal Closed one fourth */
+													  Frame(0, 0, 0, 0, 0, 0, 0, 0),     /* Right Horizontal Closed half */
+													  Frame(0, 0, 0, 0, 0, 0, 0, 0)
 	); /* Right Horizontal Closed three fourth */
 
 	int16 order;
@@ -2023,7 +2032,7 @@ void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) {
 							  g107_BoxThievesEyeVisibleArea,
 							  g106_BoxThievesEye_ViewPortVisibleArea._x1,
 							  g106_BoxThievesEye_ViewPortVisibleArea._y1,
-							  k112_byteWidthViewport, 48, k255_ColorNoTransparency, 136, 95);
+							  k112_byteWidthViewport, 48, kM1_ColorNoTransparency, 136, 95);
 			bitmap = f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice);
  /* BUG0_74 Creatures are drawn with wrong colors when viewed through a wall with the 'Thieve's Eye' spell. The 'hole in wall'
  graphic is applied to the visible area with transparency on color 10. However the visible area may contain creature graphics
@@ -2330,12 +2339,12 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 		f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap,
 										g163_FrameWalls[k0_ViewSquare_D3C]._srcByteWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight);
 		f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, k10_ColorFlesh, 64, 51);
-		f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, g161_BoxWallBitmap_D3LCR, 11, 0, 64, 64, k255_ColorNoTransparency);
+		f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, g161_BoxWallBitmap_D3LCR, 11, 0, 64, 64, kM1_ColorNoTransparency);
 
 		f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap,
 										g163_FrameWalls[k3_ViewSquare_D2C]._srcByteWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight);
 		f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, k10_ColorFlesh, 72, 71);
-		f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, g162_BoxWallBitmap_D2LCR, 8, 0, 72, 72, k255_ColorNoTransparency);
+		f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, g162_BoxWallBitmap_D2LCR, 8, 0, 72, 72, kM1_ColorNoTransparency);
 
 		f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped,
 										g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight);
@@ -2538,7 +2547,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 					f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport,
 									  g202_BoxWallPatchBehindInscription, 94, 28,
 									  g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth,
-									  k112_byteWidthViewport, k255_ColorNoTransparency, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport);
+									  k112_byteWidthViewport, kM1_ColorNoTransparency, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport);
 					byte *AL0090_puc_String = L0099_auc_InscriptionString;
 					L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont);
 					L0097_i_TextLineIndex = 0;
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 2fc01fb..2ca77b9 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -339,7 +339,7 @@ enum ViewWall {
 };
 
 enum Color {
-	k255_ColorNoTransparency = 255,
+	kM1_ColorNoTransparency = -1,
 	k0_ColorBlack = 0,
 	k1_ColorDarkGary = 1,
 	k2_ColorLightGray = 2,
@@ -644,7 +644,8 @@ public:
 	void f109_drawDoorOrnament(int16 doorOrnOdinal, int16 viewDoorOrnIndex); // @ F0109_DUNGEONVIEW_DrawDoorOrnament
 	void f112_drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int16 mapX, int16 mapY, bool flipHorizontal); // @ F0112_DUNGEONVIEW_DrawCeilingPit
 
-
+	void f20_blitToViewport(byte *bitmap, Box &box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
+	void f20_blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
 	void f21_blitToScreen(byte* bitmap, int16 *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen
 	void f21_blitToScreen(byte* bitmap, Box *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen
 	
@@ -654,7 +655,7 @@ public:
 	match the original exatcly, if need arises for heights then we'll have to retrospectively add them in old function calls*/
 	/* Expects inclusive boundaries in box */
 	void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
-					  uint16 destByteWidth, Color transparent = k255_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit
+					  uint16 destByteWidth, Color transparent = kM1_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit
 /* Expects inclusive boundaries in box */
 	void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
 									   int16 firstUnitIndex, int16 destByteWidth, Color transparent,
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 35bdf21..30bb05c 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -130,7 +130,7 @@ void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) {
 	box._y2 = 28;
 	box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7;
 	box._x2 = box._x1 + 31;
-	dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, dispMan._g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen, k255_ColorNoTransparency);
+	dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, dispMan._g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen, kM1_ColorNoTransparency);
 }
 
 void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
@@ -337,7 +337,7 @@ void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int
 	box._x2 = (box._x1 = xPos) + 15;
 	box._y2 = (box._y1 = yPos) + 15;
 	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, iconBitmap);
-	_vm->_displayMan->f132_blitToBitmap(iconBitmap, _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 8, k112_byteWidthViewport, k255_ColorNoTransparency);
+	_vm->_displayMan->f132_blitToBitmap(iconBitmap, _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 8, k112_byteWidthViewport, kM1_ColorNoTransparency);
 }
 
 void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) {
@@ -682,4 +682,64 @@ void InventoryMan::f338_decreaseTorchesLightPower() {
 		_vm->_championMan->f296_drawChangedObjectIcons();
 	}
 }
+
+void InventoryMan::f351_drawChampionSkillsAndStatistics() {
+	uint16 L1090_ui_Multiple;
+#define AL1090_ui_SkillIndex     L1090_ui_Multiple
+#define AL1090_ui_StatisticIndex L1090_ui_Multiple
+	int16 L1091_i_Y;
+	int16 L1092_i_Multiple;
+#define AL1092_i_SkillLevel            L1092_i_Multiple
+#define AL1092_i_StatisticCurrentValue L1092_i_Multiple
+	uint16 L1093_ui_ChampionIndex;
+	Champion* L1094_ps_Champion;
+	int16 L1095_i_StatisticColor;
+	uint16 L1096_ui_StatisticMaximumValue;
+	char L1097_ac_String[20];
+	// TODO: localization
+	static char* G0431_apc_StatisticNames[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"};
+
+
+	_vm->_inventoryMan->f334_closeChest();
+	L1094_ps_Champion = &_vm->_championMan->_gK71_champions[L1093_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal)];
+	_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
+	L1091_i_Y = 58;
+	for (AL1090_ui_SkillIndex = k0_ChampionSkillFighter; AL1090_ui_SkillIndex <= k3_ChampionSkillWizard; AL1090_ui_SkillIndex++) {
+		AL1092_i_SkillLevel = MIN((uint16)16, _vm->_championMan->f303_getSkillLevel(L1093_ui_ChampionIndex, AL1090_ui_SkillIndex | k0x8000_IgnoreTemporaryExperience));
+		if (AL1092_i_SkillLevel == 1)
+			continue;
+#ifdef COMPILE17_DM10aEN_DM10bEN_DM11EN_DM12EN_CSB20EN_CSB21EN_DMDEMO20EN_DM20EN_DM21EN_DM22EN /* CHANGE4_00_LOCALIZATION Translation to German language */
+		strcpy(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]);
+		strcat(L1097_ac_String, " ");
+		strcat(L1097_ac_String, G0417_apc_BaseSkillNames[AL1090_ui_SkillIndex]);
+#endif
+#ifdef COMPILE36_DM12GE_DM13aFR_DM13bFR_DM20GE_DM20FR_DM22GE /* CHANGE4_00_LOCALIZATION Translation to German language */
+		strcpy(L1097_ac_String, G0417_apc_BaseSkillNames[AL1090_ui_SkillIndex]);
+		strcat(L1097_ac_String, " ");
+		strcat(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]);
+#endif
+		_vm->_textMan->f52_printToViewport(108, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String);
+		L1091_i_Y += 7;
+	}
+	L1091_i_Y = 86;
+	for (AL1090_ui_StatisticIndex = k1_ChampionStatStrength; AL1090_ui_StatisticIndex <= k6_ChampionStatAntifire; AL1090_ui_StatisticIndex++) {
+		_vm->_textMan->f52_printToViewport(108, L1091_i_Y, k13_ColorLightestGray, G0431_apc_StatisticNames[AL1090_ui_StatisticIndex]);
+		AL1092_i_StatisticCurrentValue = L1094_ps_Champion->_statistics[AL1090_ui_StatisticIndex][k1_ChampionStatCurrent];
+		L1096_ui_StatisticMaximumValue = L1094_ps_Champion->_statistics[AL1090_ui_StatisticIndex][k0_ChampionStatMaximum];
+		if (AL1092_i_StatisticCurrentValue < L1096_ui_StatisticMaximumValue) {
+			L1095_i_StatisticColor = k8_ColorRed;
+		} else {
+			if (AL1092_i_StatisticCurrentValue > L1096_ui_StatisticMaximumValue) {
+				L1095_i_StatisticColor = k7_ColorLightGreen;
+			} else {
+				L1095_i_StatisticColor = k13_ColorLightestGray;
+			}
+		}
+		_vm->_textMan->f52_printToViewport(174, L1091_i_Y, (Color)L1095_i_StatisticColor, _vm->_championMan->f288_getStringFromInteger(AL1092_i_StatisticCurrentValue, true, 3).c_str());
+		strcpy(L1097_ac_String, "/");
+		strcat(L1097_ac_String, _vm->_championMan->f288_getStringFromInteger(L1096_ui_StatisticMaximumValue, true, 3).c_str());
+		_vm->_textMan->f52_printToViewport(192, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String);
+		L1091_i_Y += 7;
+	}
+}
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 35a76c4..93bb17f 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -80,6 +80,7 @@ public:
 	void f342_drawPanelObject(Thing thingToDraw, bool pressingEye); // @ F0342_INVENTORY_DrawPanel_Object
 	void f337_setDungeonViewPalette(); // @ F0337_INVENTORY_SetDungeonViewPalette
 	void f338_decreaseTorchesLightPower(); // @ F0338_INVENTORY_DecreaseTorchesLightPower_CPSE
+	void f351_drawChampionSkillsAndStatistics(); // @ F0351_INVENTORY_DrawChampionSkillsAndStatistics
 
 };
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index f42d955..1338130 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -66,7 +66,7 @@ void MenuMan::f395_drawMovementArrows() {
 	Box &dest = g2_BoxMovementArrows;
 	uint16 byteWidth = disp.getPixelWidth(k13_MovementArrowsIndice) / 2;
 
-	disp.f132_blitToBitmap(arrowsBitmap, disp._g348_bitmapScreen, dest, 0, 0, byteWidth, k160_byteWidthScreen, k255_ColorNoTransparency);
+	disp.f132_blitToBitmap(arrowsBitmap, disp._g348_bitmapScreen, dest, 0, 0, byteWidth, k160_byteWidthScreen, kM1_ColorNoTransparency);
 }
 void MenuMan::f388_clearActingChampion() {
 	ChampionMan &cm = *_vm->_championMan;
@@ -115,7 +115,7 @@ T0386006:
 	box2._x2 = box._x2 - 2;
 	box2._y1 = 95;
 	box2._y2 = 110;
-	dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 8, k160_byteWidthScreen, k255_ColorNoTransparency);
+	dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 8, k160_byteWidthScreen, kM1_ColorNoTransparency);
 	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) {
 		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 	}
@@ -211,7 +211,7 @@ void MenuMan::f387_drawActionArea() {
 		if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone)
 			box = g501_BoxActionArea1ActionMenu;
 		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k10_MenuActionAreaIndice), dispMan._g348_bitmapScreen,
-								  box, 0, 0, 48, k160_byteWidthScreen, k255_ColorNoTransparency);
+								  box, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency);
 		textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen,
 											235, 83, k0_ColorBlack, k4_ColorCyan, champMan._gK71_champions[_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name,
 											k7_ChampionNameMaximumLength, k200_heightScreen);
@@ -320,7 +320,7 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
 	if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) {
 		dispMan._g578_useByteBoxCoordinates = false;
 		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine,
-								  gK74_BoxSpellAreaLine, 0, 12, 48, 48, k255_ColorNoTransparency);
+								  gK74_BoxSpellAreaLine, 0, 12, 48, 48, kM1_ColorNoTransparency);
 		int16 x = 1;
 		byte c = 96 + (6 * champ._symbolStep);
 		char spellSymbolString[2] = {'\0', '\0'};
@@ -331,7 +331,7 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
 	} else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) {
 		dispMan._g578_useByteBoxCoordinates = false;
 		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine,
-								  gK74_BoxSpellAreaLine, 0, 24, 48, 48, k255_ColorNoTransparency);
+								  gK74_BoxSpellAreaLine, 0, 24, 48, 48, kM1_ColorNoTransparency);
 		char spellSymbolString[2] = {'\0', '\0'};
 		int16 x = 8;
 		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
@@ -352,7 +352,7 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) {
 		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), dispMan._g348_bitmapScreen, g0_BoxSpellArea, 0, 0,
-								  48, k160_byteWidthScreen, k255_ColorNoTransparency);
+								  48, k160_byteWidthScreen, kM1_ColorNoTransparency);
 		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 	}
 	if (champIndex == kM1_ChampionNone) {
@@ -368,9 +368,9 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
 	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 	f393_drawSpellAreaControls((ChampionIndex)champIndex);
-	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK75_BoxSpellAreaLine2, 0, 0, 48, k160_byteWidthScreen, k255_ColorNoTransparency);
+	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK75_BoxSpellAreaLine2, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency);
 	f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols);
-	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 48, k160_byteWidthScreen, k255_ColorNoTransparency);
+	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency);
 	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 976e671..6ab49fb 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -199,7 +199,7 @@ void ObjectMan::f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 	iconIndex -= g26_IconGraphicFirstIndex[i];
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
 	Box box(0, 0, 15, 15);
-	_vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, k255_ColorNoTransparency);
+	_vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, kM1_ColorNoTransparency);
 }
 
 void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
@@ -227,10 +227,10 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) {
-		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g296_bitmapViewport, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k112_byteWidthViewport, k255_ColorNoTransparency);
+		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g296_bitmapViewport, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k112_byteWidthViewport, kM1_ColorNoTransparency);
 
 	} else {
-		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g348_bitmapScreen, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k160_byteWidthScreen, k255_ColorNoTransparency);
+		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g348_bitmapScreen, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k160_byteWidthScreen, kM1_ColorNoTransparency);
 	}
 }
 
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 06a10b2..4329cb3 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -73,7 +73,7 @@ void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, uint
 		uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
 
 		Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1);
-		_vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128 / 2, destByteWidth, k255_ColorNoTransparency);
+		_vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128 / 2, destByteWidth, kM1_ColorNoTransparency);
 
 		nextX += k5_LetterWidth + 1;
 	}


Commit: 92a3ccb4a7d1eafb16ae5f469c271f277d1261a3
    https://github.com/scummvm/scummvm/commit/92a3ccb4a7d1eafb16ae5f469c271f277d1261a3
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Replace InventoryMan::f355_toggleInventory with original

Changed paths:
    engines/dm/inventory.cpp



diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 30bb05c..b72be8a 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -53,71 +53,68 @@ InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
 }
 
 void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
-	ChampionMan &cm = *_vm->_championMan;
-	EventManager &em = *_vm->_eventMan;
-	DisplayMan &dm = *_vm->_displayMan;
+	uint16 L1102_ui_Multiple;
+#define AL1102_ui_InventoryChampionOrdinal L1102_ui_Multiple
+#define AL1102_ui_SlotIndex                L1102_ui_Multiple
+	Champion* L1103_ps_Champion;
+
 
-	if ((championIndex != k4_ChampionCloseInventory) && !cm._gK71_champions[championIndex]._currHealth)
+	if ((championIndex != k4_ChampionCloseInventory) && !_vm->_championMan->_gK71_champions[championIndex]._currHealth) {
 		return;
-	if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth)
+	}
+	if (_vm->_g333_pressingMouth || _vm->_g331_pressingEye) {
 		return;
+	}
 	_vm->_g321_stopWaitingForPlayerInput = true;
-	int16 invChampOrdinal = _g432_inventoryChampionOrdinal; // copy, as the original will be edited
-	if (_vm->M0_indexToOrdinal(championIndex) == invChampOrdinal) {
+	AL1102_ui_InventoryChampionOrdinal = _vm->_inventoryMan->_g432_inventoryChampionOrdinal;
+	if (_vm->M0_indexToOrdinal(championIndex) == AL1102_ui_InventoryChampionOrdinal) {
 		championIndex = k4_ChampionCloseInventory;
 	}
-
-	Champion *champion;
-	if (invChampOrdinal) {
-		_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
-		f334_closeChest();
-		champion = &cm._gK71_champions[_vm->M1_ordinalToIndex(invChampOrdinal)];
-		if (champion->_currHealth && !cm._g299_candidateChampionOrdinal) {
-			champion->setAttributeFlag(k0x1000_ChampionAttributeStatusBox, true);
-			cm.f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal));
+	_vm->_eventMan->f78_showMouse();
+	if (AL1102_ui_InventoryChampionOrdinal) {
+		_vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+		_vm->_inventoryMan->f334_closeChest();
+		L1103_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(AL1102_ui_InventoryChampionOrdinal)];
+		if (L1103_ps_Champion->_currHealth && !_vm->_championMan->_g299_candidateChampionOrdinal) {
+			setFlag(L1103_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox);
+			_vm->_championMan->f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(AL1102_ui_InventoryChampionOrdinal));
 		}
-		if (cm._g300_partyIsSleeping) {
+		if (_vm->_championMan->_g300_partyIsSleeping) {
+			_vm->_eventMan->f77_hideMouse();
 			return;
 		}
 		if (championIndex == k4_ChampionCloseInventory) {
-			em._g326_refreshMousePointerInMainLoop = true;
+			_vm->_eventMan->_g326_refreshMousePointerInMainLoop = true;
 			_vm->_menuMan->f395_drawMovementArrows();
-			em._g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
-			warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput");
+			_vm->_eventMan->f77_hideMouse();
+			_vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
+			warning("MISSING CODE: setting G0444_ps_SecondaryKeyboardInput");
 			_vm->_eventMan->f357_discardAllInput();
+			_vm->_displayMan->f98_drawFloorAndCeiling();
 			return;
 		}
 	}
-
-	dm._g578_useByteBoxCoordinates = false;
-	_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(championIndex);
-	if (!invChampOrdinal) {
+	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	_vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(championIndex);
+	if (!AL1102_ui_InventoryChampionOrdinal) {
 		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 	}
-
-	champion = &cm._gK71_champions[championIndex];
-	dm.f466_loadIntoBitmap(k17_InventoryGraphicIndice, dm._g296_bitmapViewport);
-	if (cm._g299_candidateChampionOrdinal) {
-		dm.f135_fillBoxBitmap(dm._g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
+	L1103_ps_Champion = &_vm->_championMan->_gK71_champions[championIndex];
+	_vm->_displayMan->f466_loadIntoBitmap(k17_InventoryGraphicIndice, _vm->_displayMan->_g296_bitmapViewport);
+	if (_vm->_championMan->_g299_candidateChampionOrdinal) {
+		_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
 	}
 	_vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "HEALTH");
 	_vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
 	_vm->_textMan->f52_printToViewport(5, 132, k13_ColorLightestGray, "MANA");
-
-	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
-		_vm->_championMan->f291_drawSlot(championIndex, (ChampionSlot)slotIndex);
-	}
-
-	champion->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
-	champion->setAttributeFlag(k0x1000_ChampionAttributeStatusBox, true);
-	champion->setAttributeFlag(k0x0800_ChampionAttributePanel, true);
-	champion->setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
-	champion->setAttributeFlag(k0x0100_ChampionAttributeStatistics, true);
-	champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
-
-	cm.f292_drawChampionState(championIndex);
-	em._g598_mousePointerBitmapUpdated = true;
-	em._g442_secondaryMouseInput = g449_SecondaryMouseInput_ChampionInventory;
+	for (AL1102_ui_SlotIndex = k0_ChampionSlotReadyHand; AL1102_ui_SlotIndex < k30_ChampionSlotChest_1; AL1102_ui_SlotIndex++) {
+		_vm->_championMan->f291_drawSlot(championIndex, AL1102_ui_SlotIndex);
+	}
+	setFlag(L1103_ps_Champion->_attributes, k0x4000_ChampionAttributeViewport | k0x1000_ChampionAttributeStatusBox | k0x0800_ChampionAttributePanel | k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics | k0x0080_ChampionAttributeNameTitle);
+	_vm->_championMan->f292_drawChampionState(championIndex);
+	_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
+	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->_g442_secondaryMouseInput = g449_SecondaryMouseInput_ChampionInventory;
 	warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput");
 	_vm->_eventMan->f357_discardAllInput();
 }


Commit: 89473344d872962dc4ac2c828f6a1c7dfc17867d
    https://github.com/scummvm/scummvm/commit/89473344d872962dc4ac2c828f6a1c7dfc17867d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix several bugs realted to dungeon thing management and item handling

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/objectman.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 183889e..1d08b44 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -2,12 +2,11 @@ Bugs:
 	Display:
 		Broken colour palette
 		Portraits, alcoves etc. look broken from afar
-		Ornaments are not displayed if looked at from certain angles
-		Ornaments are displayed where they should not be, probably error in the pseudo RNG
-		Command gui is broken
+		Arrow and hand display is messed up
+
 	Logic:
-		Game crashes when reincaranting a fourth champion and trying to copy his portrait
-e
+		When object are put on the right side of the current square, they disappear
+
 
 
 Todo:
@@ -20,9 +19,4 @@ Todo:
 	Double check strcat, strstr usages, I might have messed them up in many places
 	I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions
 
-	Missing functions:
-		 Add missing  F0163_DUNGEON_LinkThingToList in MovesensMan::sensorIsTriggeredByClickOnWall (I don't think it's safe yet)
-	
-Refactoring
-	Add constructor to CreatureInfo
 
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 96604e3..90dbbf9 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1106,26 +1106,26 @@ void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount
 	Scent L0958_s_Scent; /* BUG0_00 Useless code */
 
 
-	if (L0954_i_ScentIndex = _vm->_championMan->_g407_party._scentCount) {
+	if (L0954_i_ScentIndex = _g407_party._scentCount) {
 		if (L0955_B_Merge = getFlag(cycleCount, k0x8000_mergeCycles)) {
 			clearFlag(cycleCount, k0x8000_mergeCycles);
 		}
 		L0958_s_Scent.setMapX(mapX); /* BUG0_00 Useless code */
 		L0958_s_Scent.setMapY(mapY); /* BUG0_00 Useless code */
 		L0958_s_Scent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */
-		L0957_ps_Scent = _vm->_championMan->_g407_party._scents; /* BUG0_00 Useless code */
+		L0957_ps_Scent = _g407_party._scents; /* BUG0_00 Useless code */
 		L0956_B_CycleCountDefined = false;
 		while (L0954_i_ScentIndex--) {
 			if (&*L0957_ps_Scent++ == &L0958_s_Scent) {
 				if (!L0956_B_CycleCountDefined) {
 					L0956_B_CycleCountDefined = true;
 					if (L0955_B_Merge) {
-						cycleCount = MAX((int32)_vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount);
+						cycleCount = MAX((int32)_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount);
 					} else {
-						cycleCount = MIN(80, _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount);
+						cycleCount = MIN(80, _g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount);
 					}
 				}
-				_vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount;
+				_g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount;
 			}
 		}
 	}
@@ -1135,8 +1135,10 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer)
 	if (thing == Thing::_none) {
 		return;
 	}
-	_vm->_championMan->_g415_leaderEmptyHanded = false;
-	_vm->_objectMan->f36_extractIconFromBitmap(_vm->_championMan->_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_vm->_championMan->_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
+	_g415_leaderEmptyHanded = false;
+	_vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
+
+	
 	_vm->_eventMan->f78_showMouse();
 	_vm->_objectMan->f34_drawLeaderObjectName(thing);
 	if (setMousePointer) {
@@ -1145,10 +1147,10 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer)
 		_vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
 	}
 	_vm->_eventMan->f77_hideMouse();
-	if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) {
-		_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing);
-		setFlag(_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
-		_vm->_championMan->f292_drawChampionState(_vm->_championMan->_g411_leaderIndex);
+	if (_g411_leaderIndex != kM1_ChampionNone) {
+		_gK71_champions[_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing);
+		setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
+		f292_drawChampionState(_g411_leaderIndex);
 	}
 }
 
@@ -1174,180 +1176,180 @@ void ChampionMan::f278_resetDataToStartGame() {
 
 
 void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) {
-	DisplayMan &dispMan = *_vm->_displayMan;
-	DungeonMan &dunMan = *_vm->_dungeonMan;
-
-	if (!_g415_leaderEmptyHanded || _g305_partyChampionCount == 4)
+	Thing L0793_T_Thing;
+	uint16 L0794_ui_Multiple;
+#define AL0794_ui_ViewCell       L0794_ui_Multiple
+#define AL0794_ui_SlotIndex      L0794_ui_Multiple
+#define AL0794_ui_CharacterIndex L0794_ui_Multiple
+#define AL0794_ui_StatisticIndex L0794_ui_Multiple
+#define AL0794_ui_SkillIndex     L0794_ui_Multiple
+	int16 L0795_i_HiddenSkillIndex;
+	uint16 L0796_ui_Multiple;
+#define AL0796_ui_Character  L0796_ui_Multiple
+#define AL0796_ui_SkillValue L0796_ui_Multiple
+#define AL0796_ui_ThingType  L0796_ui_Multiple
+	Champion* L0797_ps_Champion;
+	char* L0798_pc_Character;
+	uint16 L0799_ui_PreviousPartyChampionCount;
+	uint16 L0800_ui_Multiple;
+#define AL0800_B_ChampionTitleCopied L0800_ui_Multiple
+#define AL0800_ui_HiddenSkillCounter L0800_ui_Multiple
+	uint16 L0801_ui_SlotIndex;
+	int16 L0802_i_MapX;
+	int16 L0803_i_MapY;
+	uint16 L0804_ui_ChampionObjectsCell;
+	int16 L0805_i_ObjectAllowedSlots;
+	int32 L0806_l_BaseSkillExperience;
+	char L0807_ac_DecodedChampionText[77];
+
+	if (!_vm->_championMan->_g415_leaderEmptyHanded) {
 		return;
-
-	uint16 prevChampCount = _g305_partyChampionCount;
-	Champion *champ = &_gK71_champions[prevChampCount];
-	champ->resetToZero();
-	dispMan._g578_useByteBoxCoordinates = true;
-	{ // limit destBox scope
-		Box &destBox = gBoxChampionPortrait;
-		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), champ->_portrait,
-								  destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 128, 16, kM1_ColorNoTransparency);
-	}
-
-	champ->_actionIndex = k255_ChampionActionNone;
-	champ->_enableActionEventIndex = -1;
-	champ->_hideDamageReceivedIndex = -1;
-	champ->_dir = dunMan._g308_partyDir;
-	ViewCell AL_0_viewCell = k0_ViewCellFronLeft;
-	while (f285_getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3)) != kM1_ChampionNone)
-		AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
-	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3);
-	champ->clearAttributes(k0x0400_ChampionAttributeIcon);
-	champ->_directionMaximumDamageReceived = dunMan._g308_partyDir;
-	champ->_food = 1500 + _vm->_rnd->getRandomNumber(256);
-	champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
-	int16 AL_0_slotIndex_Red;
-	for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) {
-		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none);
-	}
-	Thing thing = dunMan.f161_getSquareFirstThing(dunMan._g306_partyMapX, dunMan._g307_partyMapY);
-	while (thing.getType() != k2_TextstringType) {
-		thing = dunMan.f159_getNextThing(thing);
-	}
-	char decodedChampionText[77];
-	char* character_Green = decodedChampionText;
-	dunMan.f168_decodeText(character_Green, thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
-	int16 AL_0_characterIndex = 0;
-	uint16 AL_2_character;
-	while ((AL_2_character = *character_Green++) != '\n') {
-		champ->_name[AL_0_characterIndex++] = AL_2_character;
-	}
-	champ->_name[AL_0_characterIndex] = '\0';
-	AL_0_characterIndex = 0;
-	bool AL_4_champTitleCopied = false;
-	for (;;) { // infinite
-		AL_2_character = *character_Green++;
-		if (AL_2_character == '\n') {
-			if (AL_4_champTitleCopied)
-				break;
-			AL_4_champTitleCopied = true;
-		} else {
-			champ->_title[AL_0_characterIndex++] = AL_2_character;
-		}
-	}
-	champ->_title[AL_0_characterIndex] = '\0';
-	if (*character_Green++ == 'M') {
-		champ->setAttributeFlag(k0x0010_ChampionAttributeMale, true);
-	}
-	character_Green++;
-	champ->_currHealth = champ->_maxHealth = f279_getDecodedValue(character_Green, 4);
-	character_Green += 4;
-	champ->_currStamina = champ->_maxStamina = f279_getDecodedValue(character_Green, 4);
-	character_Green += 4;
-	champ->_currMana = champ->_maxMana = f279_getDecodedValue(character_Green, 4);
-	character_Green += 4;
-	character_Green++;
-
-	int16 AL_0_statisticIndex;
-	for (AL_0_statisticIndex = k0_ChampionStatLuck; AL_0_statisticIndex <= k6_ChampionStatAntifire; ++AL_0_statisticIndex) {
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k2_ChampionStatMinimum, 30);
-		uint16 currMaxVal = f279_getDecodedValue(character_Green, 2);
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent, currMaxVal);
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k0_ChampionStatMaximum, currMaxVal);
-		character_Green += 2;
-	}
-
-	champ->setStatistic(k0_ChampionStatLuck, k2_ChampionStatMinimum, 10);
-	character_Green++;
-
-	int16 AL_0_skillIndex;
-	int16 AL_2_skillValue;
-	for (AL_0_skillIndex = k4_ChampionSkillSwing; AL_0_skillIndex <= k19_ChampionSkillWater; AL_0_skillIndex++) {
-		if ((AL_2_skillValue = *character_Green++ - 'A') > 0) {
-			champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue);
-		}
 	}
-
-	for (AL_0_skillIndex = k0_ChampionSkillFighter; AL_0_skillIndex <= k3_ChampionSkillWizard; ++AL_0_skillIndex) {
-		int32 baseSkillExp = 0;
-		int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2;
-		for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) {
-			baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience;
-		}
-		champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp);
+	if (_vm->_championMan->_g305_partyChampionCount == 4) {
+		return;
 	}
-
-	_g299_candidateChampionOrdinal = prevChampCount + 1;
-	if (++_g305_partyChampionCount == 1) {
+	L0797_ps_Champion = &_vm->_championMan->_gK71_champions[L0799_ui_PreviousPartyChampionCount = _vm->_championMan->_g305_partyChampionCount];
+	L0797_ps_Champion->resetToZero();
+	// Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portaits could be missing in the data)
+	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
+	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), L0797_ps_Champion->_portrait, gBoxChampionPortrait, _vm->_championMan->M27_getChampionPortraitX(championPortraitIndex), _vm->_championMan->M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency);
+	L0797_ps_Champion->_actionIndex = k255_ChampionActionNone;
+	L0797_ps_Champion->_enableActionEventIndex = -1;
+	L0797_ps_Champion->_hideDamageReceivedIndex = -1;
+	L0797_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
+	AL0794_ui_ViewCell = k0_ViewCellFronLeft;
+	while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone) {
+		AL0794_ui_ViewCell++;
+	}
+	L0797_ps_Champion->_cell = (ViewCell)M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir);
+	L0797_ps_Champion->_attributes = k0x0400_ChampionAttributeIcon;
+	L0797_ps_Champion->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir;
+	L0797_ps_Champion->_food = 1500 + _vm->getRandomNumber(256);
+	L0797_ps_Champion->_water = 1500 + _vm->getRandomNumber(256);
+	for (AL0794_ui_SlotIndex = k0_ChampionSlotReadyHand; AL0794_ui_SlotIndex < k30_ChampionSlotChest_1; AL0794_ui_SlotIndex++) {
+		L0797_ps_Champion->_slots[AL0794_ui_SlotIndex] = Thing::_none;
+	}
+	L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+	while ((L0793_T_Thing.getType()) != k2_TextstringType) {
+		L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing);
+	}
+	_vm->_dungeonMan->f168_decodeText(L0798_pc_Character = L0807_ac_DecodedChampionText, L0793_T_Thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
+	AL0794_ui_CharacterIndex = 0;
+	while ((AL0796_ui_Character = *L0798_pc_Character++) != '\n') { /* New line */
+		L0797_ps_Champion->_name[AL0794_ui_CharacterIndex++] = AL0796_ui_Character;
+	}
+	L0797_ps_Champion->_name[AL0794_ui_CharacterIndex] = '\0';
+	AL0794_ui_CharacterIndex = 0;
+	AL0800_B_ChampionTitleCopied = false;
+	for (;;) { /*_Infinite loop_*/
+		AL0796_ui_Character = *L0798_pc_Character++;
+		if (AL0796_ui_Character == '\n') { /* New line */
+			if (AL0800_B_ChampionTitleCopied)
+				break;
+			AL0800_B_ChampionTitleCopied = true;
+		} else {
+			L0797_ps_Champion->_title[AL0794_ui_CharacterIndex++] = AL0796_ui_Character;
+		}
+	}
+	L0797_ps_Champion->_title[AL0794_ui_CharacterIndex] = '\0';
+	if (*L0798_pc_Character++ == 'M') {
+		setFlag(L0797_ps_Champion->_attributes, k0x0010_ChampionAttributeMale);
+	}
+	L0798_pc_Character++;
+	L0797_ps_Champion->_currHealth = L0797_ps_Champion->_maxHealth = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4);
+	L0798_pc_Character += 4;
+	L0797_ps_Champion->_currStamina = L0797_ps_Champion->_maxStamina = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4);
+	L0798_pc_Character += 4;
+	L0797_ps_Champion->_currMana = L0797_ps_Champion->_maxMana = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4);
+	L0798_pc_Character += 4;
+	L0798_pc_Character++;
+	for (AL0794_ui_StatisticIndex = k0_ChampionStatLuck; AL0794_ui_StatisticIndex <= k6_ChampionStatAntifire; AL0794_ui_StatisticIndex++) {
+		L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k2_ChampionStatMinimum] = 30;
+		L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k1_ChampionStatCurrent] = L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k0_ChampionStatMaximum] = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 2);
+		L0798_pc_Character += 2;
+	}
+	L0797_ps_Champion->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10;
+	L0798_pc_Character++;
+	for (AL0794_ui_SkillIndex = k4_ChampionSkillSwing; AL0794_ui_SkillIndex <= k19_ChampionSkillWater; AL0794_ui_SkillIndex++) {
+		if ((AL0796_ui_SkillValue = *L0798_pc_Character++ - 'A') > 0) {
+			L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = 125L << AL0796_ui_SkillValue;
+		}
+	}
+	for (AL0794_ui_SkillIndex = k0_ChampionSkillFighter; AL0794_ui_SkillIndex <= k3_ChampionSkillWizard; AL0794_ui_SkillIndex++) {
+		L0806_l_BaseSkillExperience = 0;
+		L0795_i_HiddenSkillIndex = (AL0794_ui_SkillIndex + 1) << 2;
+		for (AL0800_ui_HiddenSkillCounter = 0; AL0800_ui_HiddenSkillCounter < 4; AL0800_ui_HiddenSkillCounter++) {
+			L0806_l_BaseSkillExperience += L0797_ps_Champion->_skills[L0795_i_HiddenSkillIndex + AL0800_ui_HiddenSkillCounter]._experience;
+		}
+		L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = L0806_l_BaseSkillExperience;
+	}
+	_vm->_championMan->_g299_candidateChampionOrdinal = L0799_ui_PreviousPartyChampionCount + 1;
+	if (++_vm->_championMan->_g305_partyChampionCount == 1) {
 		_vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst);
 		_vm->_menuMan->_g508_refreshActionArea = true;
-	} else {
+	} else { 
 		_vm->_menuMan->f388_clearActingChampion();
-		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1));
-	}
-
-	int16 mapX = _vm->_dungeonMan->_g306_partyMapX;
-	int16 mapY = _vm->_dungeonMan->_g307_partyMapY;
-
-	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._g308_partyDir));
-	mapX += _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
-	mapY += _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
-	thing = dunMan.f161_getSquareFirstThing(mapX, mapY);
-	AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1;
-	uint16 slotIndex_Green;
-	while (thing != Thing::_endOfList) {
-		ThingType AL_2_thingType = thing.getType();
-		if ((AL_2_thingType > k3_SensorThingType) && (thing.getCell() == championObjectsCell)) {
-			int16 objectAllowedSlots = g237_ObjectInfo[dunMan.f141_getObjectInfoIndex(thing)].getAllowedSlots();
-			switch (AL_2_thingType) {
+		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_vm->_championMan->_g305_partyChampionCount - 1)); 
+	}
+	L0802_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
+	L0803_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+	L0804_ui_ChampionObjectsCell = returnOppositeDir(_vm->_dungeonMan->_g308_partyDir);
+	L0802_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L0803_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+	L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0802_i_MapX, L0803_i_MapY);
+	AL0794_ui_SlotIndex = k13_ChampionSlotBackpackLine_1_1;
+	while (L0793_T_Thing != Thing::_endOfList) {
+		if (((AL0796_ui_ThingType = (L0793_T_Thing.getType())) > k3_SensorThingType) && ((L0793_T_Thing.getCell()) == L0804_ui_ChampionObjectsCell)) {
+			L0805_i_ObjectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0793_T_Thing)]._allowedSlots;
+			switch (AL0796_ui_ThingType) {
 			case k6_ArmourThingType:
-				for (slotIndex_Green = k2_ChampionSlotHead; slotIndex_Green <= k5_ChampionSlotFeet; slotIndex_Green++) {
-					if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
+				for (L0801_ui_SlotIndex = k2_ChampionSlotHead; L0801_ui_SlotIndex <= k5_ChampionSlotFeet; L0801_ui_SlotIndex++) {
+					if (L0805_i_ObjectAllowedSlots & gSlotMasks[L0801_ui_SlotIndex])
 						goto T0280048;
 				}
-				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) {
-					slotIndex_Green = k10_ChampionSlotNeck;
+				if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
+					L0801_ui_SlotIndex = k10_ChampionSlotNeck;
 				} else {
 					goto T0280046;
 				}
 				break;
 			case k5_WeaponThingType:
-				if (champ->getSlot(k1_ChampionSlotActionHand) == Thing::_none) {
-					slotIndex_Green = k1_ChampionSlotActionHand;
+				if (L0797_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) {
+					L0801_ui_SlotIndex = k1_ChampionSlotActionHand;
 				} else {
 					goto T0280046;
 				}
 				break;
 			case k7_ScrollThingType:
 			case k8_PotionThingType:
-				if (champ->getSlot(k11_ChampionSlotPouch_1) == Thing::_none) {
-					slotIndex_Green = k11_ChampionSlotPouch_1;
-				} else if (champ->getSlot(k6_ChampionSlotPouch_2) == Thing::_none) {
-					slotIndex_Green = k6_ChampionSlotPouch_2;
+				if (L0797_ps_Champion->_slots[k11_ChampionSlotPouch_1] == Thing::_none) {
+					L0801_ui_SlotIndex = k11_ChampionSlotPouch_1;
 				} else {
-					goto T0280046;
+					if (L0797_ps_Champion->_slots[k6_ChampionSlotPouch_2] == Thing::_none) {
+						L0801_ui_SlotIndex = k6_ChampionSlotPouch_2;
+					} else {
+						goto T0280046;
+					}
 				}
 				break;
 			case k9_ContainerThingType:
 			case k10_JunkThingType:
 T0280046:
-				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) {
-					slotIndex_Green = k10_ChampionSlotNeck;
+				if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
+					L0801_ui_SlotIndex = k10_ChampionSlotNeck;
 				} else {
-					slotIndex_Green = AL_0_slotIndex_Red++;
+					L0801_ui_SlotIndex = AL0794_ui_SlotIndex++;
 				}
-				break;
-
-			default:
-				break;
 			}
 T0280048:
-			if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_none) {
+			if (L0797_ps_Champion->_slots[L0801_ui_SlotIndex] != Thing::_none) {
 				goto T0280046;
 			}
-			f301_addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green);
+			_vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0799_ui_PreviousPartyChampionCount, L0793_T_Thing, (ChampionSlot)L0801_ui_SlotIndex);
 		}
-		thing = dunMan.f159_getNextThing(thing);
+		L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing);
 	}
-
-	_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)prevChampCount);
-	_vm->_menuMan->f456_drawDisabledMenu();
+	_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)L0799_ui_PreviousPartyChampionCount);
+	_vm->_menuMan->f456_drawDisabledMenu();;
 }
 
 void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
@@ -1464,7 +1466,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 
 
 	L0868_i_ChampionStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
-	L0865_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	L0865_ps_Champion = &_gK71_champions[champIndex];
 	L0862_ui_ChampionAttributes = L0865_ps_Champion->_attributes;
 	if (!getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand)) {
 		return;
@@ -1481,13 +1483,13 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 			for (uint16 i = 0; i < 3; ++i)
 				L0872_ai_NativeBitmapIndices[i] = 0;
 			AL0864_i_BorderCount = 0;
-			if (_vm->_championMan->_g407_party._fireShieldDefense > 0) {
+			if (_g407_party._fireShieldDefense > 0) {
 				L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k38_BorderPartyFireshieldIndice;
 			}
-			if (_vm->_championMan->_g407_party._spellShieldDefense > 0) {
+			if (_g407_party._spellShieldDefense > 0) {
 				L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k39_BorderPartySpellshieldIndice;
 			}
-			if ((_vm->_championMan->_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) {
+			if ((_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) {
 				L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k37_BorderPartyShieldIndice;
 			}
 			while (AL0864_i_BorderCount--) {
@@ -1509,7 +1511,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 	if (!(L0865_ps_Champion->_currHealth))
 		goto T0292042;
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle)) {
-		AL0864_i_ColorIndex = (champIndex == _vm->_championMan->_g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
+		AL0864_i_ColorIndex = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
 		if (L0863_B_IsInventoryChampion) {
 			_vm->_textMan->f52_printToViewport(3, 7, (Color)AL0864_i_ColorIndex, L0866_pc_ChampionName = L0865_ps_Champion->_name);
 			L0869_i_ChampionTitleX = 6 * strlen(L0866_pc_ChampionName) + 3;
@@ -1528,9 +1530,9 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		}
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics)) {
-		_vm->_championMan->f287_drawChampionBarGraphs(champIndex);
+		f287_drawChampionBarGraphs(champIndex);
 		if (L0863_B_IsInventoryChampion) {
-			_vm->_championMan->f290_drawHealthStaminaManaValues(L0865_ps_Champion);
+			f290_drawHealthStaminaManaValues(L0865_ps_Champion);
 			if ((L0865_ps_Champion->_food < 0) || (L0865_ps_Champion->_water < 0) || (L0865_ps_Champion->_poisonEventCount)) {
 				AL0870_i_NativeBitmapIndex = k34_SlotBoxWoundedIndice;
 			} else {
@@ -1550,14 +1552,14 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x2000_ChampionAttributeWounds)) {
 		for (AL0864_i_SlotIndex = L0863_B_IsInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL0864_i_SlotIndex >= k0_ChampionSlotReadyHand; AL0864_i_SlotIndex--) {
-			_vm->_championMan->f291_drawSlot(champIndex, AL0864_i_SlotIndex);
+			f291_drawSlot(champIndex, AL0864_i_SlotIndex);
 		}
 		if (L0863_B_IsInventoryChampion) {
 			setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
 		}
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0200_ChampionAttributeLoad) && L0863_B_IsInventoryChampion) {
-		if (L0865_ps_Champion->_load > (AL0864_i_Load = _vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion))) {
+		if (L0865_ps_Champion->_load > (AL0864_i_Load = f309_getMaximumLoad(L0865_ps_Champion))) {
 			AL0870_i_Color = k8_ColorRed;
 		} else {
 			if (((long)L0865_ps_Champion->_load << 3) > ((long)AL0864_i_Load * 5)) {
@@ -1568,28 +1570,28 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		}
 		_vm->_textMan->f52_printToViewport(104, 132, (Color)AL0870_i_Color, "LOAD ");
 		AL0864_i_Load = L0865_ps_Champion->_load / 10;
-		strcpy(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
+		strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
 		strcat(_vm->_g353_stringBuildBuffer, ".");
 		AL0864_i_Load = L0865_ps_Champion->_load - (AL0864_i_Load * 10);
-		strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str());
+		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str());
 		strcat(_vm->_g353_stringBuildBuffer, "/");
-		AL0864_i_Load = (_vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10;
-		strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
+		AL0864_i_Load = (f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10;
+		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
 		strcat(_vm->_g353_stringBuildBuffer, " KG");
 		_vm->_textMan->f52_printToViewport(148, 132, (Color)AL0870_i_Color, _vm->_g353_stringBuildBuffer);
 		setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
 	}
-	AL0864_i_ChampionIconIndex = _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir);
+	AL0864_i_ChampionIconIndex = M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir);
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL0864_i_ChampionIconIndex))) {
 		_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], g46_ChampionColor[champIndex]);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0800_ChampionAttributePanel) && L0863_B_IsInventoryChampion) {
 		if (_vm->_g333_pressingMouth) {
 			_vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned();
 		} else {
 			if (_vm->_g331_pressingEye) {
-				if (_vm->_championMan->_g415_leaderEmptyHanded) {
+				if (_g415_leaderEmptyHanded) {
 					_vm->_inventoryMan->f351_drawChampionSkillsAndStatistics();
 				}
 			} else {
@@ -1599,7 +1601,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x8000_ChampionAttributeActionHand)) {
-		_vm->_championMan->f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
+		f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
 		_vm->_menuMan->f386_drawActionIcon(champIndex);
 		if (L0863_B_IsInventoryChampion) {
 			setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index a17f92e..2dc4579 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -386,7 +386,7 @@ public:
 	int16 _water;
 	uint16 _load;
 	int16 _shieldDefense;
-	byte _portrait[464]; // 32 x 29 pixel portrait
+	byte _portrait[928]; // 32 x 29 pixel portrait
 
 	Thing &getSlot(ChampionSlot slot) { return _slots[slot]; }
 	void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; }
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index aa47af2..f591399 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -69,11 +69,6 @@ uint16 returnNextVal(uint16 val) {
 
 bool isOrientedWestEast(direction dir) { return dir & 1; }
 
-
-uint16 setFlag(uint16 &val, uint16 mask) {
-	return val |= mask;
-}
-
 uint16 toggleFlag(uint16& val, uint16 mask) {
 	return val ^= mask;
 }
@@ -314,7 +309,7 @@ void DMEngine::f2_gameloop() {
 
 	while (true) {
 		if (_g327_newPartyMapIndex != kM1_mapIndexNone) {
-			T0002002:
+T0002002:
 			f3_processNewPartyMap(_g327_newPartyMapIndex);
 			_movsens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
 			_g327_newPartyMapIndex = kM1_mapIndexNone;
@@ -326,15 +321,34 @@ void DMEngine::f2_gameloop() {
 		if (_g327_newPartyMapIndex != kM1_mapIndexNone)
 			goto T0002002;
 
+		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
+			Box box(0, 223, 0, 135);
+			_displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // dummy code
+			_displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
+			if (_g325_setMousePointerToObjectInMainLoop) {
+				_g325_setMousePointerToObjectInMainLoop = false;
+				_eventMan->f78_showMouse();
+				_eventMan->f68_setPointerToObject(_objectMan->_g412_objectIconForMousePointer);
+				_eventMan->f77_hideMouse();
+				
+			}
+			if (_eventMan->_g326_refreshMousePointerInMainLoop) {
+				_eventMan->_g326_refreshMousePointerInMainLoop = false;
+				_eventMan->_g598_mousePointerBitmapUpdated = true;
+				_eventMan->f78_showMouse();
+				_eventMan->f77_hideMouse();
+			}
+		}
+
 		if (_championMan->_g303_partyDead)
 			break;
 		_g313_gameTime++;
 
 		if (!(_g313_gameTime & 511))
-			_inventoryMan->f338_decreaseTorchesLightPower();
-		if (_g310_disabledMovementTicks) {
-			_g310_disabledMovementTicks--;
-		}
+			//_inventoryMan->f338_decreaseTorchesLightPower();
+			if (_g310_disabledMovementTicks) {
+				_g310_disabledMovementTicks--;
+			}
 		if (_championMan->_g407_party._freezeLifeTicks) {
 			_championMan->_g407_party._freezeLifeTicks -= 1;
 		}
@@ -345,15 +359,10 @@ void DMEngine::f2_gameloop() {
 
 		_g321_stopWaitingForPlayerInput = false;
 		//do {
-			_eventMan->processInput();
-			_eventMan->f380_processCommandQueue();
-		//} while (!_g321_stopWaitingForPlayerInput /*|| !_g301_gameTimeTicking */);
+		_eventMan->processInput();
+		_eventMan->f380_processCommandQueue();
+	//} while (!_g321_stopWaitingForPlayerInput /*|| !_g301_gameTimeTicking */);
 
-		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
-			Box box(0, 223, 0, 135);
-			_displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // dummy code
-			_displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
-		}
 
 		_displayMan->updateScreen();
 		_system->delayMillis(18);
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 3f7f558..d0bc378 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -125,7 +125,7 @@ uint16 returnNextVal(uint16 val); // @ M17_NEXT
 bool isOrientedWestEast(direction dir);	// @ M16_IS_ORIENTED_WEST_EAST
 
 
-uint16 setFlag(uint16 &val, uint16 mask); // @ M08_SET
+#define setFlag(val, mask) ((val) |= (mask))
 
 
 #define getFlag(val, mask) ((val) & (mask))
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index b4cd964..8a49d95 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -31,7 +31,9 @@
 #include "dungeonman.h"
 #include "timeline.h"
 #include "champion.h"
-
+#include "group.h"
+#include "movesens.h"
+#include "projexpl.h"
 
 
 namespace DM {
@@ -417,8 +419,6 @@ DungeonMan::~DungeonMan() {
 	delete[] _g260_dungeonTextData;
 	delete[] _g279_dungeonMapData;
 	for (uint16 i = 0; i < 16; ++i) {
-		if (_g284_thingData[i])
-			delete[] _g284_thingData[i][0];
 		delete[] _g284_thingData[i];
 	}
 }
@@ -651,34 +651,34 @@ void DungeonMan::f434_loadDungeonFile() {
 			continue;
 
 		if (_g284_thingData[thingType]) {
-			delete[] _g284_thingData[thingType][0];
 			delete[] _g284_thingData[thingType];
 		}
-		_g284_thingData[thingType] = new uint16*[_g278_dungeonFileHeader._thingCounts[thingType]];
-		_g284_thingData[thingType][0] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount];
-		for (uint16 i = 0; i < _g278_dungeonFileHeader._thingCounts[thingType]; ++i)
-			_g284_thingData[thingType][i] = _g284_thingData[thingType][0] + i * thingStoreWordCount;
+		_g284_thingData[thingType] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount];
 
 		if (thingType == k4_GroupThingType) {
-			for (uint16 i = 0; i < thingCount; ++i)
+			for (uint16 i = 0; i < thingCount; ++i) {
+				uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount;
 				for (uint16 j = 0; j < thingStoreWordCount; ++j) {
 					if (j == 2 || j == 3)
-						_g284_thingData[thingType][i][j] = dunDataStream.readByte();
+						nextSlot[j] = dunDataStream.readByte();
 					else
-						_g284_thingData[thingType][i][j] = dunDataStream.readUint16BE();
+						nextSlot[j] = dunDataStream.readUint16BE();
 				}
+			}
 		} else if (thingType == k14_ProjectileThingType) {
 			for (uint16 i = 0; i < thingCount; ++i) {
-				_g284_thingData[thingType][i][0] = dunDataStream.readUint16BE();
-				_g284_thingData[thingType][i][1] = dunDataStream.readUint16BE();
-				_g284_thingData[thingType][i][2] = dunDataStream.readByte();
-				_g284_thingData[thingType][i][3] = dunDataStream.readByte();
-				_g284_thingData[thingType][i][4] = dunDataStream.readUint16BE();
+				uint16 *nextSlot = _g284_thingData[thingType] + i * thingStoreWordCount;
+				nextSlot[0] = dunDataStream.readUint16BE();
+				nextSlot[1] = dunDataStream.readUint16BE();
+				nextSlot[2] = dunDataStream.readByte();
+				nextSlot[3] = dunDataStream.readByte();
+				nextSlot[4] = dunDataStream.readUint16BE();
 			}
 		} else {
 			for (uint16 i = 0; i < thingCount; ++i) {
+				uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount;
 				for (uint16 j = 0; j < thingStoreWordCount; ++j)
-					_g284_thingData[thingType][i][j] = dunDataStream.readUint16BE();
+					nextSlot[j] = dunDataStream.readUint16BE();
 			}
 		}
 
@@ -686,7 +686,7 @@ void DungeonMan::f434_loadDungeonFile() {
 			if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType)
 				_vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType];
 			for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) {
-				_g284_thingData[thingType][thingCount + i][0] = Thing::_none.toUint16();
+				(_g284_thingData[thingType] + (thingCount + i) * thingStoreWordCount)[0] = Thing::_none.toUint16();
 			}
 		}
 	}
@@ -755,33 +755,36 @@ void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) {
 
 
 Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) {
-	bool isInXBounds = (mapX >= 0) && (mapX < _g273_currMapWidth);
-	bool isInYBounds = (mapY >= 0) && (mapY < _g274_currMapHeight);
-
-	if (isInXBounds && isInYBounds)
-		return Square(_g271_currMapData[mapX][mapY]);
-
-
-	Square tmpSquare;
-	if (isInYBounds) {
-		tmpSquare.set(_g271_currMapData[0][mapY]);
-		if (mapX == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
-			return Square(k0_WallElemType).set(k0x0004_WallEastRandOrnAllowed);
-
-		tmpSquare.set(_g271_currMapData[_g273_currMapWidth - 1][mapY]);
-		if (mapX == _g273_currMapWidth && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
-			return Square(k0_WallElemType).set(k0x0001_WallWestRandOrnAllowed);
-	} else if (isInXBounds) {
-		tmpSquare.set(_g271_currMapData[mapX][0]);
-		if (mapY == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
-			return Square(k0_WallElemType).set(k0x0002_WallSouthRandOrnAllowed);
-
-		tmpSquare.set(_g271_currMapData[mapX][_g274_currMapHeight - 1]);
-		if (mapY == _g274_currMapHeight && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
-			return Square((k0_WallElemType << 5) | k0x0008_WallNorthRandOrnAllowed);
+	int16 L0248_i_Multiple;
+#define AL0248_B_IsMapXInBounds L0248_i_Multiple
+#define AL0248_i_SquareType     L0248_i_Multiple
+	int16 L0249_i_Multiple;
+#define AL0249_B_IsMapYInBounds L0249_i_Multiple
+#define AL0249_i_SquareType     L0249_i_Multiple
+
+	AL0249_B_IsMapYInBounds = (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight);
+	if ((AL0248_B_IsMapXInBounds = (mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth)) && AL0249_B_IsMapYInBounds) {
+		return Square(_vm->_dungeonMan->_g271_currMapData[mapX][mapY]);
 	}
 
-	return Square(k0_WallElemType);
+	if (AL0249_B_IsMapYInBounds) {
+		if (((mapX == -1) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[0][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) {
+			return Square(k0_ElementTypeWall, k0x0004_WallEastRandOrnAllowed);
+		}
+		if (((mapX == _vm->_dungeonMan->_g273_currMapWidth) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[_vm->_dungeonMan->_g273_currMapWidth - 1][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) {
+			return Square(k0_ElementTypeWall, k0x0001_WallWestRandOrnAllowed);
+		}
+	} else {
+		if (AL0248_B_IsMapXInBounds) {
+			if (((mapY == -1) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][0]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) {
+				return Square(k0_ElementTypeWall, k0x0002_WallSouthRandOrnAllowed);
+			}
+			if (((mapY == _vm->_dungeonMan->_g274_currMapHeight) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][_vm->_dungeonMan->_g274_currMapHeight - 1]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) {
+				return Square(k0_ElementTypeWall, k0x0008_WallNorthRandOrnAllowed);
+			}
+		}
+	}
+	return Square(k0_ElementTypeWall, 0);
 }
 
 Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
@@ -790,17 +793,23 @@ Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 st
 }
 
 int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) {
-	if (mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight || !Square(_g271_currMapData[mapX][mapY]).get(k0x0010_ThingListPresent))
-		return -1;
+	uint16 L0260_ui_ThingIndex;
+	int16 L0261_i_MapY;
+	register unsigned char* L0262_puc_Square;
 
-	int16 y = 0;
-	uint16 index = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
-	byte* square = _g271_currMapData[mapX];
-	while (y++ != mapY)
-		if (Square(*square++).get(k0x0010_ThingListPresent))
-			index++;
 
-	return index;
+	L0262_puc_Square = _vm->_dungeonMan->_g271_currMapData[mapX];
+	if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight) || !getFlag(L0262_puc_Square[mapY], k0x0010_ThingListPresent)) {
+		return -1;
+	}
+	L0261_i_MapY = 0;
+	L0260_ui_ThingIndex = _vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount[mapX];
+	while (L0261_i_MapY++ != mapY) {
+		if (getFlag(*L0262_puc_Square++, k0x0010_ThingListPresent)) {
+			L0260_ui_ThingIndex++;
+		}
+	}
+	return L0260_ui_ThingIndex;
 }
 
 Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) {
@@ -819,11 +828,11 @@ void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, direction dir, int16
 #define footprintsAllowed L0307_uc_Multiple
 #define scentOrdinal      L0307_uc_Multiple
 	Sensor* sensor;
-	bool leftRandWallOrnAllowed;
-	int16 L0310_i_Multiple;
+	bool leftRandWallOrnAllowed = false;
+	int16 L0310_i_Multiple = 0;
 #define frontRandWallOrnAllowed L0310_i_Multiple
 #define sideIndex                      L0310_i_Multiple
-	bool rightRandWallOrnAllowed;
+	bool rightRandWallOrnAllowed = false;
 	int16 thingTypeRedEagle;
 	bool squreIsFakeWall;
 	Thing thing;
@@ -957,31 +966,33 @@ T0172049_Footprints:
 	aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16();
 }
 
-void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
+void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir,
 												 int16 mapX, int16 mapY, bool isFakeWall) {
-	int16 ornCount = _g269_currMap->_randWallOrnCount;
-
-	turnDirRight(dir);
-	aspectArray[k2_RightWallOrnOrdAspect] = f170_getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
-	turnDirRight(dir);
-	aspectArray[k3_FrontWallOrnOrdAspect] = f170_getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
-	turnDirRight(dir);
-	aspectArray[k4_LeftWallOrnOrdAspect] = f170_getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
-
-	if (isFakeWall || mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight) {
-		for (uint16 i = k2_RightWallOrnOrdAspect; i <= k4_LeftWallOrnOrdAspect; ++i) {
-			if (f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[i])))
-				aspectArray[i] = 0;
+	int16 L0306_i_Multiple;
+#define AL0306_i_RandomWallOrnamentCount L0306_i_Multiple
+#define AL0306_i_SideIndex               L0306_i_Multiple
+
+
+	AL0306_i_RandomWallOrnamentCount = _vm->_dungeonMan->_g269_currMap->_randWallOrnCount;
+	aspectArray[k2_RightWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(leftAllowed, AL0306_i_RandomWallOrnamentCount, mapX, ++mapY * (M21_normalizeModulo4(++dir) + 1), 30);
+	aspectArray[k3_FrontWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(frontAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY * (M21_normalizeModulo4(++dir) + 1), 30);
+	aspectArray[k4_LeftWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(rightAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY-- * (M21_normalizeModulo4(++dir) + 1), 30);
+	if (isFakeWall || (mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight)) { /* If square is a fake wall or is out of map bounds */
+		for (AL0306_i_SideIndex = k2_RightWallOrnOrdAspect; AL0306_i_SideIndex <= k4_LeftWallOrnOrdAspect; AL0306_i_SideIndex++) { /* Loop to remove any random ornament that is an alcove */
+			if (_vm->_dungeonMan->f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[AL0306_i_SideIndex]))) {
+				aspectArray[AL0306_i_SideIndex] = 0;
+			}
 		}
 	}
 }
 
 int16 DungeonMan::f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) {
-	int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1)
-					+ (3000 + (_g272_currMapIndex << 6) + _g273_currMapWidth + _g274_currMapHeight) * 11
-					+ _g278_dungeonFileHeader._ornamentRandomSeed) >> 2) % modulo;
-	if (allowed && index < count)
-		return _vm->M0_indexToOrdinal(index);
+	int16 L0305_i_RandomOrnamentIndex;
+
+
+	if (allowed && ((L0305_i_RandomOrnamentIndex = f169_getRandomOrnamentIndex((int16)2000 + (mapX << 5) + mapY, (int16)3000 + (_vm->_dungeonMan->_g272_currMapIndex << (int16)6) + _vm->_dungeonMan->_g273_currMapWidth + _vm->_dungeonMan->_g274_currMapHeight, modulo)) < count)) {
+		return _vm->M0_indexToOrdinal(L0305_i_RandomOrnamentIndex);
+	}
 	return 0;
 }
 
@@ -995,7 +1006,7 @@ bool DungeonMan::f149_isWallOrnAnAlcove(int16 wallOrnIndex) {
 }
 
 uint16 *DungeonMan::f156_getThingData(Thing thing) {
-	return _g284_thingData[thing.getType()][thing.getIndex()];
+	return _g284_thingData[thing.getType()] + thing.getIndex() * g235_ThingDataWordCount[thing.getType()];
 }
 
 uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) {
@@ -1003,7 +1014,7 @@ uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) {
 }
 
 Thing DungeonMan::f159_getNextThing(Thing thing) {
-	return Thing(f156_getThingData(thing)[0]); // :)
+	return Thing(f156_getThingData(thing)[0]);
 }
 
 char g255_MessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings
@@ -1109,7 +1120,7 @@ char g257_InscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_
 
 void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) {
 	char sepChar;
-	TextString textString(_g284_thingData[k2_TextstringType][thing.getIndex()]);
+	TextString textString(_g284_thingData[k2_TextstringType] + thing.getIndex() * g235_ThingDataWordCount[k2_TextstringType]);
 	if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) {
 		type = (TextType)(type & ~k0x8000_DecodeEvenIfInvisible);
 		if (type == k1_TextTypeMessage) {
@@ -1174,6 +1185,45 @@ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) {
 	*destString = ((type == k0_TextTypeInscription) ? 0x81 : '\0');
 }
 
+Thing DungeonMan::f166_getUnusedThing(uint16 thingType) {
+	int16 L0288_i_ThingIndex;
+	int16 L0289_i_ThingDataByteCount;
+	int16 L0290_i_ThingCount;
+	Thing* L0291_ps_Generic;
+	Thing L0292_T_Thing;
+
+
+	L0290_i_ThingCount = _vm->_dungeonMan->_g278_dungeonFileHeader._thingCounts[getFlag(thingType, k0x7FFF_thingType)];
+	if (thingType == (k0x8000_championBones | k10_JunkThingType)) {
+		thingType = k10_JunkThingType;
+	} else {
+		if (thingType == k10_JunkThingType) {
+			L0290_i_ThingCount -= 3; /* Always keep 3 unused JUNK things for the bones of dead champions */
+		}
+	}
+	L0288_i_ThingIndex = L0290_i_ThingCount;
+	L0289_i_ThingDataByteCount = g235_ThingDataWordCount[thingType] >> 1;
+	L0291_ps_Generic = (Thing*)_vm->_dungeonMan->_g284_thingData[thingType];
+	for (;;) { /*_Infinite loop_*/
+		if (*L0291_ps_Generic == Thing::_none) { /* If thing data is unused */
+			L0292_T_Thing = Thing((thingType << 10) | (L0290_i_ThingCount - L0288_i_ThingIndex));
+			break;
+		}
+		if (--L0288_i_ThingIndex) { /* If there are thing data left to process */
+			L0291_ps_Generic += L0289_i_ThingDataByteCount; /* Proceed to the next thing data */
+		} else {
+			if ((L0292_T_Thing = f165_getDiscardTHing(thingType)) == Thing::_none) {
+				return Thing::_none;
+			}
+			L0291_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0292_T_Thing);
+			break;
+		}
+	}
+	memset(L0291_ps_Generic, 0, L0289_i_ThingDataByteCount * 2);
+
+	*L0291_ps_Generic = Thing::_endOfList;
+	return L0292_T_Thing;
+}
 
 uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 	static const uint16 g241_junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo
@@ -1263,46 +1313,56 @@ int16 DungeonMan::f141_getObjectInfoIndex(Thing thing) {
 }
 
 void DungeonMan::f163_linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) {
-	if (thingToLink == Thing::_endOfList)
-		return;
+	Thing L0265_T_Thing;
+	uint16 L0266_ui_Multiple;
+#define AL0266_ui_Column                L0266_ui_Multiple
+#define AL0266_ui_SquareFirstThingIndex L0266_ui_Multiple
+	Thing* L0267_pT_Thing;
+	byte* L0268_puc_Square;
+	Thing* L0269_ps_Generic;
+	uint16 L0270_ui_MapY;
 
-	uint16 *rawObjPtr = f156_getThingData(thingToLink);
-	*rawObjPtr = Thing::_endOfList.toUint16();
 
+	if (thingToLink == Thing::_endOfList) {
+		return;
+	}
+	L0269_ps_Generic = (Thing*)f156_getThingData(thingToLink);
+	*L0269_ps_Generic = Thing::_endOfList;
+	/* If mapX >= 0 then the thing is linked to the list of things on the specified square else it is linked at the end of the specified thing list */
 	if (mapX >= 0) {
-		Square *squarePtr = (Square*)&_g271_currMapData[mapX][mapY];
-		if (squarePtr->get(k0x0010_ThingListPresent)) {
+		L0268_puc_Square = &_g271_currMapData[mapX][mapY];
+		if (getFlag(*L0268_puc_Square, k0x0010_ThingListPresent)) {
 			thingInList = f161_getSquareFirstThing(mapX, mapY);
 		} else {
-			squarePtr->set(k0x0010_ThingListPresent);
-			uint16 *cumulativeCount = &_g270_currMapColCumulativeSquareFirstThingCount[mapX + 1];
-			uint16 column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1;
-			while (column--) {
-				(*cumulativeCount++)++;
+			setFlag(*L0268_puc_Square, k0x0010_ThingListPresent);
+			uint16 * tmp = _g270_currMapColCumulativeSquareFirstThingCount + mapX + 1;
+			AL0266_ui_Column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1;
+			while (AL0266_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is added */
+				(*tmp++)++; /* Increment the cumulative first thing count */
 			}
-			uint16 mapYStep = 0;
-			squarePtr -= mapY;
-			uint16 squareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
-			while (mapYStep++ != mapY) {
-				if (squarePtr->get(k0x0010_ThingListPresent)) {
-					squareFirstThingIndex++;
+			L0270_ui_MapY = 0;
+			L0268_puc_Square -= mapY;
+			AL0266_ui_SquareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
+			while (L0270_ui_MapY++ != mapY) {
+				if (getFlag(*L0268_puc_Square++, k0x0010_ThingListPresent)) {
+					AL0266_ui_SquareFirstThingIndex++;
 				}
-				squarePtr++;
 			}
-			Thing* thingPtr = &_g283_squareFirstThings[squareFirstThingIndex];
-			memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_g278_dungeonFileHeader._squareFirstThingCount - squareFirstThingIndex - 1));
-			*thingPtr = thingToLink;
+			L0267_pT_Thing = &_g283_squareFirstThings[AL0266_ui_SquareFirstThingIndex];
+			// the second '- 1' is for the loop initialization, > 0 is because we are copying from one behind
+			for (int16 i = _g278_dungeonFileHeader._squareFirstThingCount - AL0266_ui_SquareFirstThingIndex - 1 - 1; i > 0; --i)
+				L0267_pT_Thing[i] = L0267_pT_Thing[i - 1];
+
+			*L0267_pT_Thing = thingToLink;
 			return;
 		}
 	}
-
-	Thing thing = f159_getNextThing(thingInList);
-	while (thing != Thing::_endOfList) {
-		thing = f159_getNextThing(thing);
-		thingInList = thing;
+	L0265_T_Thing = f159_getNextThing(thingInList);
+	while (L0265_T_Thing != Thing::_endOfList) {
+		L0265_T_Thing = f159_getNextThing(thingInList = L0265_T_Thing);
 	}
-	rawObjPtr = f156_getThingData(thingInList);
-	*rawObjPtr = thingToLink.toUint16();
+	L0269_ps_Generic = (Thing*)f156_getThingData(thingInList);
+	*L0269_ps_Generic = thingToLink;
 }
 
 WeaponInfo* DungeonMan::f158_getWeaponInfo(Thing thing) {
@@ -1365,4 +1425,299 @@ int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDe
 	}
 	return kM1_mapIndexNone;
 }
+
+Thing DungeonMan::f162_getSquareFirstObject(int16 mapX, int16 mapY) {
+	Thing thing = f161_getSquareFirstThing(mapX, mapY);
+	while ((thing != Thing::_endOfList) && (thing.getType() < k4_GroupThingType)) {
+		thing = f159_getNextThing(thing);
+	}
+	return thing;
+}
+
+uint16 DungeonMan::f143_getArmourDefense(ArmourInfo* armourInfo, bool useSharpDefense) {
+	uint16 L0244_ui_Defense;
+
+	L0244_ui_Defense = armourInfo->_defense;
+	if (useSharpDefense) {
+		L0244_ui_Defense = _vm->f30_getScaledProduct(L0244_ui_Defense, 3, getFlag(armourInfo->_attributes, k0x0007_ArmourAttributeSharpDefense) + 4);
+	}
+	return L0244_ui_Defense;
+}
+
+Thing DungeonMan::f165_getDiscardTHing(uint16 thingType) {
+	uint16 L0276_ui_MapX;
+	uint16 L0277_ui_MapY;
+	Thing L0278_T_Thing;
+	uint16 L0279_ui_MapIndex;
+	byte* L0280_puc_Square;
+	Thing* L0281_pT_SquareFirstThing;
+	Thing* L0282_ps_Generic;
+	uint16 L0283_ui_DiscardThingMapIndex;
+	int L0284_i_CurrentMapIndex;
+	uint16 L0285_ui_MapWidth;
+	uint16 L0286_ui_MapHeight;
+	int L0287_i_ThingType;
+	static unsigned char G0294_auc_LastDiscardedThingMapIndex[16];
+
+
+	if (thingType == k15_ExplosionThingType) {
+		return Thing::_none;
+	}
+	L0284_i_CurrentMapIndex = _vm->_dungeonMan->_g272_currMapIndex;
+	if (((L0279_ui_MapIndex = G0294_auc_LastDiscardedThingMapIndex[thingType]) == _vm->_dungeonMan->_g309_partyMapIndex) && (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount)) {
+		L0279_ui_MapIndex = 0;
+	}
+	L0283_ui_DiscardThingMapIndex = L0279_ui_MapIndex;
+	for (;;) { /*_Infinite loop_*/
+		L0285_ui_MapWidth = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._width;
+		L0286_ui_MapHeight = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._height;
+		L0280_puc_Square = _vm->_dungeonMan->_g279_dungeonMapData[L0279_ui_MapIndex][0];
+		L0281_pT_SquareFirstThing = &_vm->_dungeonMan->_g283_squareFirstThings[_vm->_dungeonMan->_g280_dungeonColumnsCumulativeSquareThingCount[_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[L0279_ui_MapIndex]]];
+		for (L0276_ui_MapX = 0; L0276_ui_MapX <= L0285_ui_MapWidth; L0276_ui_MapX++) {
+			for (L0277_ui_MapY = 0; L0277_ui_MapY <= L0286_ui_MapHeight; L0277_ui_MapY++) {
+				if (getFlag(*L0280_puc_Square++, k0x0010_ThingListPresent)) {
+					L0278_T_Thing = *L0281_pT_SquareFirstThing++;
+					if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && ((L0276_ui_MapX - _vm->_dungeonMan->_g306_partyMapX + 5) <= 10) && ((L0277_ui_MapY - _vm->_dungeonMan->_g307_partyMapY + 5) <= 10)) /* If square is too close to the party */
+						goto T0165029;
+					do {
+						if ((L0287_i_ThingType = (L0278_T_Thing).getType()) == k3_SensorThingType) {
+							L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing);
+							if (((Sensor*)L0282_ps_Generic)->getType()) /* If sensor is not disabled */
+								break;
+						} else {
+							if (L0287_i_ThingType == thingType) {
+								L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing);
+								switch (thingType) {
+								case k4_GroupThingType:
+									if (((Group*)L0282_ps_Generic)->getDoNotDiscard())
+										continue;
+								case k14_ProjectileThingType:
+									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
+									if (thingType == k4_GroupThingType) {
+										_vm->_groupMan->f188_dropGroupPossessions(L0276_ui_MapX, L0277_ui_MapY, L0278_T_Thing, kM1_soundModeDoNotPlaySound);
+										_vm->_groupMan->f189_delete(L0276_ui_MapX, L0277_ui_MapY);
+									} else {
+										_vm->_projexpl->f214_projectileDeleteEvent(L0278_T_Thing);
+										f164_unlinkThingFromList(L0278_T_Thing, Thing(0), L0276_ui_MapX, L0277_ui_MapY);
+										_vm->_projexpl->f215_projectileDelete(L0278_T_Thing, 0, L0276_ui_MapX, L0277_ui_MapY);
+									}
+									break;
+								case k6_ArmourThingType:
+									if (((Armour*)L0282_ps_Generic)->getDoNotDiscard())
+										continue;
+									goto T0165026;
+								case k5_WeaponThingType:
+									if (((Weapon*)L0282_ps_Generic)->getDoNotDiscard())
+										continue;
+									goto T0165026;
+								case k10_JunkThingType:
+									if (((Junk*)L0282_ps_Generic)->getDoNotDiscard())
+										continue;
+									goto T0165026;
+								case k8_PotionThingType:
+									if (((Potion*)L0282_ps_Generic)->getDoNotDiscard())
+										continue;
+T0165026:
+									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
+									_vm->_movsens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0);
+								}
+								_vm->_dungeonMan->f173_setCurrentMap(L0284_i_CurrentMapIndex);
+								G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex;
+								return Thing((L0278_T_Thing).getTypeAndIndex());
+							}
+						}
+					} while ((L0278_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0278_T_Thing)) != Thing::_endOfList);
+T0165029:
+					;
+				}
+			}
+		}
+		if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) || (_vm->_dungeonMan->_g278_dungeonFileHeader._mapCount <= 1)) {
+			G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex;
+			return Thing::_none;
+		}
+		do {
+			if (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount) {
+				L0279_ui_MapIndex = 0;
+			}
+		} while (L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex);
+		if (L0279_ui_MapIndex == L0283_ui_DiscardThingMapIndex) {
+			L0279_ui_MapIndex = _vm->_dungeonMan->_g309_partyMapIndex;
+		}
+	}
+}
+
+uint16 DungeonMan::f144_getCreatureAttributes(Thing thing) {
+	Group* L0245_ps_Group;
+
+	L0245_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing);
+	return g243_CreatureInfo[L0245_ps_Group->_type]._attributes;
+}
+
+void DungeonMan::f146_setGroupCells(Group* group, uint16 cells, uint16 mapIndex) {
+	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) {
+		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._cells = cells;
+	} else {
+		group->_cells = cells;
+	}
+}
+
+void DungeonMan::f148_setGroupDirections(Group* group, int16 dir, uint16 mapIndex) {
+	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) {
+		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (direction)dir;
+	} else {
+		group->setDir(M21_normalizeModulo4(dir));
+	}
+}
+
+bool DungeonMan::f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) {
+	int16 L0234_i_Counter;
+	int16 L0235_i_CreatureType;
+	byte* L0236_puc_Multiple;
+#define AL0236_puc_Group               L0236_puc_Multiple
+#define AL0236_puc_AllowedCreatureType L0236_puc_Multiple
+	Map* L0237_ps_Map;
+
+	L0235_i_CreatureType = ((Group*)_vm->_dungeonMan->f156_getThingData(thing))->_type;
+	L0237_ps_Map = &_vm->_dungeonMan->_g277_dungeonMaps[mapIndex];
+	AL0236_puc_AllowedCreatureType = _vm->_dungeonMan->_g279_dungeonMapData[mapIndex][L0237_ps_Map->_width] + L0237_ps_Map->_height + 1;
+	for (L0234_i_Counter = L0237_ps_Map->_creatureTypeCount; L0234_i_Counter > 0; L0234_i_Counter--) {
+		if (*AL0236_puc_AllowedCreatureType++ == L0235_i_CreatureType) {
+			return true;
+		}
+	}
+	return false;
+}
+
+void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY) {
+	uint16 L0271_ui_SquareFirstThingIndex;
+	uint16 L0272_ui_Multiple;
+#define AL0272_ui_SquareFirstThingIndex L0272_ui_Multiple
+#define AL0272_ui_Column                L0272_ui_Multiple
+	Thing L0273_T_Thing;
+	Thing* L0274_ps_Generic = nullptr;
+	Thing* L0275_pui_Multiple = nullptr;
+#define AL0275_pT_Thing                      L0275_pui_Multiple
+#define AL0275_pui_CumulativeFirstThingCount L0275_pui_Multiple
+
+
+	if (thingToUnlink == Thing::_endOfList) {
+		return;
+	}
+
+	{
+		uint16 tmp = thingToUnlink.toUint16();
+		clearFlag(tmp, 0xC000);
+		thingToUnlink = Thing(tmp);
+	}
+
+	if (mapX >= 0) {
+		L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink);
+		AL0275_pT_Thing = &_vm->_dungeonMan->_g283_squareFirstThings[L0271_ui_SquareFirstThingIndex = _vm->_dungeonMan->f160_getSquareFirstThingIndex(mapX, mapY)]; /* BUG0_01 Coding error without consequence. The engine does not check that there are things at the specified square coordinates. _vm->_dungeonMan->f160_getSquareFirstThingIndex would return -1 for an empty square. No consequence as the function is never called with the coordinates of an empty square (except in the case of BUG0_59) */
+		if ((*L0274_ps_Generic == Thing::_endOfList) && (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16())) { /* If the thing to unlink is the last thing on the square */
+			clearFlag(_vm->_dungeonMan->_g271_currMapData[mapX][mapY], k0x0010_ThingListPresent);
+			AL0272_ui_SquareFirstThingIndex = _vm->_dungeonMan->_g278_dungeonFileHeader._squareFirstThingCount - 1;
+			for (uint16 i = 0; i < AL0272_ui_SquareFirstThingIndex - L0271_ui_SquareFirstThingIndex; ++i)
+				AL0275_pT_Thing[i] = AL0275_pT_Thing[i + 1];
+
+			_vm->_dungeonMan->_g283_squareFirstThings[AL0272_ui_SquareFirstThingIndex] = Thing::_none;
+			AL0275_pui_CumulativeFirstThingCount = (Thing*)_vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount + mapX + 1;
+			AL0272_ui_Column = _vm->_dungeonMan->_g282_dungeonColumCount - (_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[_vm->_dungeonMan->_g272_currMapIndex] + mapX) - 1;
+			while (AL0272_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is unlinked */
+				(*(uint16*)AL0275_pui_CumulativeFirstThingCount++)--; /* Decrement the cumulative first thing count */
+			}
+			goto T0164011;
+		}
+		if (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16()) {
+			*AL0275_pT_Thing = *L0274_ps_Generic;
+			goto T0164011;
+		}
+		thingInList = *AL0275_pT_Thing;
+	}
+	L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList);
+	while (L0273_T_Thing.getTypeAndIndex() != thingToUnlink.toUint16()) {
+		if ((L0273_T_Thing == Thing::_endOfList) || (L0273_T_Thing == Thing::_none)) {
+			goto T0164011;
+		}
+		L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList = L0273_T_Thing);
+	}
+	L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingInList);
+	*L0274_ps_Generic = _vm->_dungeonMan->f159_getNextThing(L0273_T_Thing);
+	L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink);
+T0164011:
+	*L0274_ps_Generic = Thing::_endOfList;
+}
+
+int16 DungeonMan::f155_getStairsExitDirection(int16 mapX, int16 mapY) {
+	int16 L0256_i_SquareType;
+	bool L0257_B_NorthSouthOrientedStairs;
+
+
+	if (L0257_B_NorthSouthOrientedStairs = !getFlag(_vm->_dungeonMan->f151_getSquare(mapX, mapY).toByte(), k0x0008_StairsNorthSouthOrient)) {
+		mapX = mapX + _vm->_dirIntoStepCountEast[kDirEast];
+		mapY = mapY + _vm->_dirIntoStepCountNorth[kDirEast];
+	} else {
+		mapX = mapX + _vm->_dirIntoStepCountEast[kDirNorth];
+		mapY = mapY + _vm->_dirIntoStepCountNorth[kDirNorth];
+	}
+	return ((((L0256_i_SquareType = Square(_vm->_dungeonMan->f151_getSquare(mapX, mapY)).getType()) == k0_ElementTypeWall) || (L0256_i_SquareType == k3_ElementTypeStairs)) << 1) + L0257_B_NorthSouthOrientedStairs;
+
+}
+
+Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {
+	int16 L0293_i_Type;
+	int16 L0294_i_ThingType;
+	Thing L0295_T_Thing;
+	Junk* L0296_ps_Junk;
+
+
+	L0294_i_ThingType = k5_WeaponThingType;
+	if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit)) {
+		iconIndex = k4_IconIndiceWeaponTorchUnlit;
+	}
+	switch (iconIndex) {
+	case k54_IconIndiceWeaponRock:
+		L0293_i_Type = k30_WeaponTypeRock;
+		break;
+	case k128_IconIndiceJunkBoulder:
+		L0293_i_Type = k25_JunkTypeBoulder;
+		L0294_i_ThingType = k10_JunkThingType;
+		break;
+	case k51_IconIndiceWeaponArrow:
+		L0293_i_Type = k27_WeaponTypeArrow;
+		break;
+	case k52_IconIndiceWeaponSlayer:
+		L0293_i_Type = k28_WeaponTypeSlayer;
+		break;
+	case k55_IconIndiceWeaponPoisonDart:
+		L0293_i_Type = k31_WeaponTypePoisonDart;
+		break;
+	case k56_IconIndiceWeaponThrowingStar:
+		L0293_i_Type = k32_WeaponTypeThrowingStar;
+		break;
+	case k32_IconIndiceWeaponDagger:
+		L0293_i_Type = k8_WeaponTypeDagger;
+		break;
+	case k4_IconIndiceWeaponTorchUnlit:
+		L0293_i_Type = k2_WeaponTypeTorch;
+		break;
+	default:
+		return Thing::_none;
+	}
+	if ((L0295_T_Thing = f166_getUnusedThing(L0294_i_ThingType)) == Thing::_none) {
+		return Thing::_none;
+	}
+	L0296_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0295_T_Thing);
+	L0296_ps_Junk->setType(L0293_i_Type); /* Also works for WEAPON in cases other than Boulder */
+	if ((iconIndex == k4_IconIndiceWeaponTorchUnlit) && ((Weapon*)L0296_ps_Junk)->isLit()) { /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */
+		((Weapon*)L0296_ps_Junk)->setChargeCount(15);
+	}
+	return L0295_T_Thing;
+}
+
+int16 DungeonMan::f169_getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo) {
+	return ((((((val1 * 31417) & 0xFFFF) >> 1) + ((val2 * 11) & 0xFFFF)
+			  + _vm->_dungeonMan->_g278_dungeonFileHeader._ornamentRandomSeed) & 0xFFFF) >> 2) % modulo; /* Pseudorandom number generator */
+}
+
 }
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 26841a2..f9e21d4 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -81,9 +81,7 @@ public:
 	int16 _type;
 	uint16 _objectAspectIndex;
 	uint16 _actionSetIndex;
-private:
 	uint16 _allowedSlots;
-public:
 	ObjectInfo(int16 type, uint16 objectAspectIndex, uint16 actionSetIndex, uint16 allowedSlots)
 		: _type(type), _objectAspectIndex(objectAspectIndex), _actionSetIndex(actionSetIndex), _allowedSlots(allowedSlots) {}
 	bool getAllowedSlot(ObjectAllowedSlot slot) { return _allowedSlots & slot; }
@@ -583,6 +581,7 @@ class Square {
 public:
 	explicit Square(byte dat = 0) : _data(dat) {}
 	explicit Square(SquareType type) { setType(type); }
+	explicit Square(byte element, byte mask) : _data((element << 5) | mask) {}
 	Square &set(byte dat) { this->_data = dat; return *this; }
 	Square &set(SquareMask mask) { _data |= mask; return *this; }
 	byte get(SquareMask mask) { return _data & mask; }
@@ -653,8 +652,8 @@ class DungeonMan {
 	int16 f160_getSquareFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex
 
 	int16 f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal
-	void f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
-										 int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals
+	void f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir,
+	                                     int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals
 
 
 public:
@@ -697,6 +696,7 @@ public:
 	void f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY); // @ F0164_DUNGEON_UnlinkThingFromList
 	int16 f155_getStairsExitDirection(int16 mapX, int16 mapY); // @ F0155_DUNGEON_GetStairsExitDirection
 	Thing f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex); // @ F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator
+	int16 f169_getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo); // @ F0169_DUNGEON_GetRandomOrnamentIndex
 
 
 	uint32 _rawDunFileDataSize;	 // @ probably NONE
@@ -709,7 +709,7 @@ public:
 	uint16 *_g280_dungeonColumnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
 	Thing *_g283_squareFirstThings; // @ G0283_pT_SquareFirstThings
 	uint16 *_g260_dungeonTextData; // @ G0260_pui_DungeonTextData
-	uint16 **_g284_thingData[16]; // @ G0284_apuc_ThingData
+	uint16 *_g284_thingData[16]; // @ G0284_apuc_ThingData
 	byte ***_g279_dungeonMapData; // @ G0279_pppuc_DungeonMapData
 
 
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 2fbefb1..86b30d5 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -41,7 +41,6 @@
 
 
 namespace DM {
-
 byte g42_bitmapArrowPointer[576] = { // @ G0042_auc_Graphic562_Bitmap_ArrowPointer
 	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
 	0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
@@ -329,7 +328,6 @@ void EventManager::initMouse() {
 	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
 	CursorMan.showMouse(false);
 
-
 	setMousePos(Common::Point(320 / 2, 200 / 2));
 }
 
@@ -358,10 +356,17 @@ void EventManager::f68_setPointerToObject(byte* bitmap) {
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
 	L0051_puc_Bitmap = _g615_mousePointerOriginalColorsObject;
 	memset(L0051_puc_Bitmap, 0, 32 * 18);
+
+	/*
 	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, gK27_palChangesMousepointerOjbectIconShadow);
 	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
 	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, g44_palChangesMousePointerIcon);
 	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
+	*/
+	// dummy code
+	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
+	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
+	
 	_gK100_preventBuildPointerScreenArea = false;
 	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
 }
@@ -386,8 +391,8 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY)
 	int16 L1578_i_XOverChampionStatusBox;
 
 
-	if (_gK100_preventBuildPointerScreenArea)
-		return;
+	// if (_gK100_preventBuildPointerScreenArea)
+	//	return;
 
 	_gK100_preventBuildPointerScreenArea = true;
 	if (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
@@ -442,16 +447,16 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY)
 		_vm->_eventMan->_g598_mousePointerBitmapUpdated = false;
 		switch (_gK104_mousePointerType) {
 		case k0_pointerTypeArrow:
-			CursorMan.pushCursor(g42_bitmapArrowPointer, 32, 18, 0, 0, 0);
+			CursorMan.replaceCursor(g42_bitmapArrowPointer, 32, 18, 0, 0, 0);
 			break;
 		case k1_pointerTypeObjectIcon:
-			CursorMan.pushCursor(_g615_mousePointerOriginalColorsObject, 32, 18, 0, 0, 0);
+			CursorMan.replaceCursor(_g615_mousePointerOriginalColorsObject, 32, 18, 0, 0, 0);
 			break;
 		case k2_pointerTypeChampionIcon:
-			CursorMan.pushCursor(_g613_mousePointerOriginalColorsChampionIcon, 32, 18, 0, 0, 0);
+			CursorMan.replaceCursor(_g613_mousePointerOriginalColorsChampionIcon, 32, 18, 0, 0, 0);
 			break;
 		case k3_pointerTypeHand:
-			CursorMan.pushCursor(g43_bitmapHanPointer, 32, 18, 0, 0, 0);
+			CursorMan.replaceCursor(g43_bitmapHanPointer, 32, 18, 0, 0, 0);
 			break;
 		}
 	}
@@ -724,11 +729,15 @@ void EventManager::f368_commandSetLeader(ChampionIndex champIndex) {
 }
 
 void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() {
-	DungeonMan &dunMan = *_vm->_dungeonMan;
-	int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
-	int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
-	if ((mapX >= 0) && (mapX < dunMan._g273_currMapWidth) && (mapY >= 0) && (mapY < dunMan._g274_currMapHeight)) {
-		_vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->f275_sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(dunMan._g308_partyDir));
+	uint16 L1135_ui_MapX;
+	uint16 L1136_ui_MapY;
+
+
+	L1135_ui_MapX = _vm->_dungeonMan->_g306_partyMapX;
+	L1136_ui_MapY = _vm->_dungeonMan->_g307_partyMapY;
+	L1135_ui_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1136_ui_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+	if ((L1135_ui_MapX >= 0) && (L1135_ui_MapX < _vm->_dungeonMan->_g273_currMapWidth) && (L1136_ui_MapY >= 0) && (L1136_ui_MapY < _vm->_dungeonMan->_g274_currMapHeight)) {
+		_vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->f275_sensorIsTriggeredByClickOnWall(L1135_ui_MapX, L1136_ui_MapY, returnOppositeDir(_vm->_dungeonMan->_g308_partyDir));
 	}
 }
 
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 6ab49fb..05a86de 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -138,100 +138,102 @@ IconIndice ObjectMan::f32_getObjectType(Thing thing) {
 byte g29_ChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType
 
 IconIndice ObjectMan::f33_getIconIndex(Thing thing) {
-	IconIndice iconIndex = f32_getObjectType(thing);
-
-	if ((iconIndex != kM1_IconIndiceNone) &&
-		(((iconIndex < k32_IconIndiceWeaponDagger) && (iconIndex >= k0_IconIndiceJunkCompassNorth)) || // < instead of <= is no error
-		((iconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (iconIndex <= k163_IconIndicePotionWaterFlask)) ||
-		 (iconIndex == k195_IconIndicePotionEmptyFlask))
-		) {
-		uint16 *rawType = _vm->_dungeonMan->f156_getThingData(thing);
-		switch (iconIndex) {
-		case k0_IconIndiceJunkCompassNorth:
-			iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_g308_partyDir);
-			break;
-		case k4_IconIndiceWeaponTorchUnlit: {
-			Weapon weapon(rawType);
-			if (weapon.isLit()) {
-				iconIndex = (IconIndice)(iconIndex + g29_ChargeCountToTorchType[weapon.getChargeCount()]);
+	int16 L0005_i_IconIndex;
+	Junk* L0006_ps_Junk;
+
+
+	if ((L0005_i_IconIndex = _vm->_objectMan->f32_getObjectType(thing)) != kM1_IconIndiceNone) {
+		if (((L0005_i_IconIndex < k32_IconIndiceWeaponDagger) && (L0005_i_IconIndex >= k0_IconIndiceJunkCompassNorth)) ||
+			((L0005_i_IconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (L0005_i_IconIndex <= k163_IconIndicePotionWaterFlask)) ||
+			(L0005_i_IconIndex == k195_IconIndicePotionEmptyFlask)) {
+			L0006_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing);
+			switch (L0005_i_IconIndex) {
+			case k0_IconIndiceJunkCompassNorth:
+				L0005_i_IconIndex += _vm->_dungeonMan->_g308_partyDir;
+				break;
+			case k4_IconIndiceWeaponTorchUnlit:
+				if (((Weapon*)L0006_ps_Junk)->isLit()) {
+					L0005_i_IconIndex += g29_ChargeCountToTorchType[((Weapon*)L0006_ps_Junk)->getChargeCount()];
+				}
+				break;
+			case k30_IconIndiceScrollOpen:
+				if (((Scroll*)L0006_ps_Junk)->getClosed()) {
+					L0005_i_IconIndex++;
+				}
+				break;
+			case k8_IconIndiceJunkWater:
+			case k12_IconIndiceJunkIllumuletUnequipped:
+			case k10_IconIndiceJunkJewelSymalUnequipped:
+				if (L0006_ps_Junk->getChargeCount()) {
+					L0005_i_IconIndex++;
+				}
+				break;
+			case k23_IconIndiceWeaponBoltBladeStormEmpty:
+			case k14_IconIndiceWeaponFlamittEmpty:
+			case k18_IconIndiceWeaponStormringEmpty:
+			case k25_IconIndiceWeaponFuryRaBladeEmpty:
+			case k16_IconIndiceWeaponEyeOfTimeEmpty:
+			case k20_IconIndiceWeaponStaffOfClawsEmpty:
+				if (((Weapon*)L0006_ps_Junk)->getChargeCount()) {
+					L0005_i_IconIndex++;
+				}
 			}
-			break;
-		}
-		case k30_IconIndiceScrollOpen:
-			if (Scroll(rawType).getClosed()) {
-				iconIndex = (IconIndice)(iconIndex + 1);
-			}
-			break;
-		case k8_IconIndiceJunkWater:
-		case k12_IconIndiceJunkIllumuletUnequipped:
-		case k10_IconIndiceJunkJewelSymalUnequipped:
-			if (Junk(rawType).getChargeCount()) {
-				iconIndex = (IconIndice)(iconIndex + 1);
-			}
-			break;
-		case k23_IconIndiceWeaponBoltBladeStormEmpty:
-		case k14_IconIndiceWeaponFlamittEmpty:
-		case k18_IconIndiceWeaponStormringEmpty:
-		case k25_IconIndiceWeaponFuryRaBladeEmpty:
-		case k16_IconIndiceWeaponEyeOfTimeEmpty:
-		case k20_IconIndiceWeaponStaffOfClawsEmpty:
-			if (Weapon(rawType).getChargeCount()) {
-				iconIndex = (IconIndice)(iconIndex + 1);
-			}
-			break;
-		default:
-			break;
 		}
 	}
-
-	return iconIndex;
+	return (IconIndice)L0005_i_IconIndex;
 }
 
 void ObjectMan::f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
-	int16 i;
-	for (i = 0; i < 7; ++i) {
-		if (g26_IconGraphicFirstIndex[i] > iconIndex)
+	uint16 L0011_ui_Counter;
+	byte* L0012_pl_Bitmap_Icon;
+	Box L1568_s_Box;
+
+	for (L0011_ui_Counter = 0; L0011_ui_Counter < 7; L0011_ui_Counter++) {
+		if (g26_IconGraphicFirstIndex[L0011_ui_Counter] > iconIndex)
 			break;
 	}
-
-	--i;
-	byte *srcBitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k42_ObjectIcons_000_TO_031 + i);
-	iconIndex -= g26_IconGraphicFirstIndex[i];
+	L0012_pl_Bitmap_Icon = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k42_ObjectIcons_000_TO_031 + --L0011_ui_Counter);
+	iconIndex -= g26_IconGraphicFirstIndex[L0011_ui_Counter];
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
-	Box box(0, 0, 15, 15);
-	_vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, kM1_ColorNoTransparency);
+	L1568_s_Box._y1 = 0;
+	L1568_s_Box._x1 = 0;
+	L1568_s_Box._y2 = 15;
+	L1568_s_Box._x2 = 15;
+	_vm->_displayMan->f132_blitToBitmap(L0012_pl_Bitmap_Icon, destBitmap, L1568_s_Box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, kM1_ColorNoTransparency, gK77_IconGraphicHeight[L0011_ui_Counter], 16);
 }
 
 void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
-	SlotBox *slotBox = &_g30_slotBoxes[slotBoxIndex];
-	slotBox->_iconIndex = iconIndex; // yes, this modifies the global array
-	if (slotBox->_iconIndex == kM1_IconIndiceNone) {
+	uint16 L0015_ui_IconGraphicIndex;
+	int16 L0016_i_ByteWidth;
+	SlotBox* L0017_ps_SlotBox;
+	byte* L0018_puc_Bitmap_Icons;
+	Box L0019_s_Box;
+	byte* L0020_puc_Bitmap_Destination;
+	int16 L1569_i_Width;
+
+	L0017_ps_SlotBox = &_vm->_objectMan->_g30_slotBoxes[slotBoxIndex];
+	if ((L0017_ps_SlotBox->_iconIndex = iconIndex) == kM1_IconIndiceNone) {
 		return;
 	}
-
-	Box box;
-	box._x1 = slotBox->_x;
-	box._y1 = slotBox->_y;
-	box._x2 = box._x1 + 15;
-	box._y2 = box._y1 + 15;
-
-	uint16 iconGraphicIndex;
-	for (iconGraphicIndex = 0; iconGraphicIndex < 7; ++iconGraphicIndex) {
-		if (g26_IconGraphicFirstIndex[iconGraphicIndex] > iconIndex) {
+	L0019_s_Box._x2 = (L0019_s_Box._x1 = L0017_ps_SlotBox->_x) + 15;
+	L0019_s_Box._y2 = (L0019_s_Box._y1 = L0017_ps_SlotBox->_y) + 15;
+	for (L0015_ui_IconGraphicIndex = 0; L0015_ui_IconGraphicIndex < 7; L0015_ui_IconGraphicIndex++) {
+		if (g26_IconGraphicFirstIndex[L0015_ui_IconGraphicIndex] > iconIndex)
 			break;
-		}
 	}
-	iconGraphicIndex--;
-	byte *iconsBitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(iconGraphicIndex + k42_ObjectIcons_000_TO_031);
-	iconIndex -= g26_IconGraphicFirstIndex[iconGraphicIndex];
-
-	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	L0015_ui_IconGraphicIndex--;
+	L0018_puc_Bitmap_Icons = _vm->_displayMan->f489_getNativeBitmapOrGraphic(L0015_ui_IconGraphicIndex + k42_ObjectIcons_000_TO_031);
+	iconIndex -= g26_IconGraphicFirstIndex[L0015_ui_IconGraphicIndex];
 	if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) {
-		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g296_bitmapViewport, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k112_byteWidthViewport, kM1_ColorNoTransparency);
-
+		L0020_puc_Bitmap_Destination = _vm->_displayMan->_g296_bitmapViewport;
+		L0016_i_ByteWidth = k112_byteWidthViewport;
+		L1569_i_Width = 136;
 	} else {
-		_vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g348_bitmapScreen, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k160_byteWidthScreen, kM1_ColorNoTransparency);
+		L0020_puc_Bitmap_Destination = (unsigned char*)_vm->_displayMan->_g348_bitmapScreen;
+		L0016_i_ByteWidth = k160_byteWidthScreen;
+		L1569_i_Width = 200;
 	}
+	_vm->_displayMan->_g578_useByteBoxCoordinates = false, _vm->_displayMan->f132_blitToBitmap(L0018_puc_Bitmap_Icons, L0020_puc_Bitmap_Destination, L0019_s_Box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, k128_byteWidth, L0016_i_ByteWidth, kM1_ColorNoTransparency, gK77_IconGraphicHeight[L0015_ui_IconGraphicIndex], L1569_i_Width);
 }
 
 #define k14_ObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH


Commit: 0a0e79357d2495e376e3be408e0272072a96d233
    https://github.com/scummvm/scummvm/commit/0a0e79357d2495e376e3be408e0272072a96d233
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix compilation using MSVC9

Changed paths:
    engines/dm/movesens.cpp
    engines/dm/projexpl.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 2da2ee0..80cc1cc 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -1072,7 +1072,7 @@ void MovesensMan::f265_createEvent60to61_moveGroup(Thing groupThing, int16 mapX,
 	L0696_s_Event._priority = 0;
 	L0696_s_Event._B._location._mapX = mapX;
 	L0696_s_Event._B._location._mapY = mapY;
-	L0696_s_Event._C._slot = groupThing;
+	L0696_s_Event._C._slot = groupThing.toUint16();
 	_vm->_timeline->f238_addEventGetEventIndex(&L0696_s_Event);
 }
 
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 5ce7b20..f773ffb 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -67,7 +67,7 @@ void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16
 		L0468_s_Event._type = k48_TMEventTypeMoveProjectileIgnoreImpacts; /* Projectiles created by champions or creatures ignore impacts on their first movement */
 	}
 	L0468_s_Event._priority = 0;
-	L0468_s_Event._B._slot = L0466_T_ProjectileThing;
+	L0468_s_Event._B._slot = L0466_T_ProjectileThing.toUint16();
 	L0468_s_Event._C._projectile.setMapX(mapX);
 	L0468_s_Event._C._projectile.setMapY(mapY);
 	L0468_s_Event._C._projectile.setStepEnergy(stepEnergy);
@@ -337,7 +337,7 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 	M33_setMapAndTime(L0476_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ((explThing == Thing::_explRebirthStep1) ? 5 : 1));
 	L0476_s_Event._type = k25_TMEventTypeExplosion;
 	L0476_s_Event._priority = 0;
-	L0476_s_Event._C._slot = L0473_T_Thing;
+	L0476_s_Event._C._slot = L0473_T_Thing.toUint16();
 	L0476_s_Event._B._location._mapX = AP0443_ui_ProjectileMapX;
 	L0476_s_Event._B._location._mapY = AP0444_ui_ProjectileMapY;
 	_vm->_timeline->f238_addEventGetEventIndex(&L0476_s_Event);
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 1c184e3..5cf3f85 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -109,7 +109,7 @@ public:
 		int16 _attack;
 		int16 _defense;
 		int16 _lightPower;
-		Thing _slot;
+		uint16 _slot; // Thing
 		int16 _slotOrdinal;
 		B_unionTimelineEvent() {}
 	} _B;
@@ -135,7 +135,7 @@ public:
 			void setStepEnergy(uint16 val) { _backing = (_backing & ~(0xF << 12)) | ((val & 0xF) << 12); }
 		} _projectile;
 
-		Thing _slot;
+		uint16 _slot;
 		int16 _soundIndex;
 		byte _ticks;
 		C_uionTimelineEvent() {}


Commit: 8504f944e07d4a73f570e642476ae1819eb28568
    https://github.com/scummvm/scummvm/commit/8504f944e07d4a73f570e642476ae1819eb28568
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix style used for pointer casts

Changed paths:
    engines/dm/champion.cpp
    engines/dm/gfx.cpp
    engines/dm/movesens.cpp
    engines/dm/projexpl.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 90dbbf9..24cfda9 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -229,8 +229,8 @@ void ChampionMan::f299_applyModifiersToStatistics(Champion* champ, int16 slotInd
 	if (((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType))
 		&& (slotIndex >= k0_ChampionSlotReadyHand)
 		&& (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) {
-		Weapon *weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(thing);
-		Armour *armour = (Armour*)_vm->_dungeonMan->f156_getThingData(thing);
+		Weapon *weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(thing);
+		Armour *armour = (Armour *)_vm->_dungeonMan->f156_getThingData(thing);
 		if (((thingType == k5_WeaponThingType) && weapon->getCursed())
 			|| ((thingType == k6_ArmourThingType) && armour->getCursed())) {
 			statIndex = k0_ChampionStatLuck;
@@ -477,13 +477,13 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 				menuMan.f388_clearActingChampion();
 
 			if ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)) {
-				((Scroll*)rawObjPtr)->setClosed(false);
+				((Scroll *)rawObjPtr)->setClosed(false);
 				f296_drawChangedObjectIcons();
 			}
 		}
 
 		if (iconIndex = k4_IconIndiceWeaponTorchUnlit) {
-			((Weapon*)rawObjPtr)->setLit(true);
+			((Weapon *)rawObjPtr)->setLit(true);
 			_vm->_inventoryMan->f337_setDungeonViewPalette();
 			f296_drawChangedObjectIcons();
 		} else if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand) &&
@@ -494,12 +494,12 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 	} else if (slotIndex == k10_ChampionSlotNeck) {
 
 		if ((iconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (iconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
-			((Junk*)rawObjPtr)->setChargeCount(1);
+			((Junk *)rawObjPtr)->setChargeCount(1);
 			_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2];
 			_vm->_inventoryMan->f337_setDungeonViewPalette();
 			iconIndex = (IconIndice)(iconIndex + 1);
 		} else if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
-			((Junk*)rawObjPtr)->setChargeCount(1);
+			((Junk *)rawObjPtr)->setChargeCount(1);
 			iconIndex = (IconIndice)(iconIndex + 1);
 		}
 
@@ -625,15 +625,15 @@ Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotI
 	L0898_B_IsInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
 	L0895_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0894_T_Thing);
 	f299_applyModifiersToStatistics(L0896_ps_Champion, slotIndex, L0895_i_IconIndex, -1, L0894_T_Thing); /* Remove objet modifiers */
-	L0897_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0894_T_Thing);
+	L0897_ps_Weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(L0894_T_Thing);
 	if (slotIndex == k10_ChampionSlotNeck) {
 		if ((L0895_i_IconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (L0895_i_IconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
-			((Junk*)L0897_ps_Weapon)->setChargeCount(0);
+			((Junk *)L0897_ps_Weapon)->setChargeCount(0);
 			_g407_party._magicalLightAmount -= g39_LightPowerToLightAmount[2];
 			_vm->_inventoryMan->f337_setDungeonViewPalette();
 		} else {
 			if ((L0895_i_IconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (L0895_i_IconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
-				((Junk*)L0897_ps_Weapon)->setChargeCount(0);
+				((Junk *)L0897_ps_Weapon)->setChargeCount(0);
 			}
 		}
 	}
@@ -648,7 +648,7 @@ Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotI
 				_vm->_menuMan->f388_clearActingChampion();
 			}
 			if ((L0895_i_IconIndex >= k30_IconIndiceScrollOpen) && (L0895_i_IconIndex <= k31_IconIndiceScrollClosed)) {
-				((Scroll*)L0897_ps_Weapon)->setClosed(true);
+				((Scroll *)L0897_ps_Weapon)->setClosed(true);
 				f296_drawChangedObjectIcons();
 			}
 		}
@@ -755,7 +755,7 @@ T0321024:
 			goto T0321004;
 		if (attack > (AL0976_i_AdjustedAttack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k4_ChampionStatVitality, _vm->_rnd->getRandomNumber(127) + 10))) { /* BUG0_45 This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the probability of being wounded. However if it was fixed, the behavior would be the opposite of what it should: the higher the vitality of a champion, the lower the result of F0307_CHAMPION_GetStatisticAdjustedAttack and the more likely the champion could get wounded (because of more iterations in the loop below) */
 			do {
-				setFlag(*(uint16*)&_g410_championPendingWounds[champIndex], (1 << _vm->_rnd->getRandomNumber(7)) & allowedWounds);
+				setFlag(*(uint16 *)&_g410_championPendingWounds[champIndex], (1 << _vm->_rnd->getRandomNumber(7)) & allowedWounds);
 			} while ((attack > (AL0976_i_AdjustedAttack <<= 1)) && AL0976_i_AdjustedAttack);
 		}
 		if (_g300_partyIsSleeping) {
@@ -785,8 +785,8 @@ int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
 	}
 	for (L0943_ui_ArmourShieldDefense = 0, AL0942_i_SlotIndex = k0_ChampionSlotReadyHand; AL0942_i_SlotIndex <= k1_ChampionSlotActionHand; AL0942_i_SlotIndex++) {
 		if ((L0945_T_Thing = L0946_ps_Champion->_slots[AL0942_i_SlotIndex]).getType() == k6_ArmourThingType) {
-			L0947_ps_ArmourInfo = (ArmourInfo*)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing);
-			L0947_ps_ArmourInfo = &g239_ArmourInfo[((Armour*)L0947_ps_ArmourInfo)->getType()];
+			L0947_ps_ArmourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing);
+			L0947_ps_ArmourInfo = &g239_ArmourInfo[((Armour *)L0947_ps_ArmourInfo)->getType()];
 			if (getFlag(L0947_ps_ArmourInfo->_attributes, k0x0080_ArmourAttributeIsAShield)) {
 				L0943_ui_ArmourShieldDefense += ((f312_getStrength(champIndex, AL0942_i_SlotIndex) + _vm->_dungeonMan->f143_getArmourDefense(L0947_ps_ArmourInfo, L0944_B_UseSharpDefense)) * g50_woundDefenseFactor[woundIndex]) >> ((AL0942_i_SlotIndex == woundIndex) ? 4 : 5);
 			}
@@ -798,8 +798,8 @@ int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
 	}
 	AL0942_i_WoundDefense += L0946_ps_Champion->_actionDefense + L0946_ps_Champion->_shieldDefense + _g407_party._shieldDefense + L0943_ui_ArmourShieldDefense;
 	if ((woundIndex > k1_ChampionSlotActionHand) && ((L0945_T_Thing = L0946_ps_Champion->_slots[woundIndex]).getType() == k6_ArmourThingType)) {
-		L0947_ps_ArmourInfo = (ArmourInfo*)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing);
-		AL0942_i_WoundDefense += _vm->_dungeonMan->f143_getArmourDefense(&g239_ArmourInfo[((Armour*)L0947_ps_ArmourInfo)->getType()], L0944_B_UseSharpDefense);
+		L0947_ps_ArmourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing);
+		AL0942_i_WoundDefense += _vm->_dungeonMan->f143_getArmourDefense(&g239_ArmourInfo[((Armour *)L0947_ps_ArmourInfo)->getType()], L0944_B_UseSharpDefense);
 	}
 	if (getFlag(L0946_ps_Champion->_wounds, 1 << woundIndex)) {
 		AL0942_i_WoundDefense -= 8 + _vm->getRandomNumber(4);
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 25f0e4b..a6dd087 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1040,7 +1040,7 @@ void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButt
 			}
 			bitmap = f492_getDerivedBitmap(doorButtonOrdinal);
 		}
-		f132_blitToBitmap(bitmap, _g296_bitmapViewport, *(Box*)coordSetRedEagle, 0, 0,
+		f132_blitToBitmap(bitmap, _g296_bitmapViewport, *(Box *)coordSetRedEagle, 0, 0,
 						  coordSetRedEagle[4], k112_byteWidthViewport, k10_ColorFlesh, coordSetRedEagle[5], k136_heightViewport);
 	}
 }
@@ -1327,7 +1327,7 @@ void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloor
 			bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
 		}
 		f132_blitToBitmap(bitmap, _g296_bitmapViewport,
-						  *(Box*)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport);
+						  *(Box *)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport);
 T0108005:
 		if (drawFootprints) {
 			f108_drawFloorOrnament(_vm->M0_indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex);
@@ -1343,7 +1343,7 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d
 
 	doorFramesTemp = doorFrames;
 	if (doorState != k0_doorState_OPEN) {
-		door = (Door*)(_vm->_dungeonMan->_g284_thingData[k0_DoorThingType]) + doorThingIndex;
+		door = (Door *)(_vm->_dungeonMan->_g284_thingData[k0_DoorThingType]) + doorThingIndex;
 		memmove(_g74_tmpBitmap, f489_getNativeBitmapOrGraphic(doorNativeBitmapIndices[doorType = door->getType()]), byteCount * 2);
 		f109_drawDoorOrnament(door->getOrnOrdinal(), viewDoorOrnIndex);
 		if (getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[doorType]._attributes, k0x0004_MaskDoorInfo_Animated)) {
@@ -1421,7 +1421,7 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn
 			}
 		}
 		f132_blitToBitmap(bitmap, _g74_tmpBitmap,
-						  *(Box*)coordSetOrangeElk, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height);
+						  *(Box *)coordSetOrangeElk, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height);
 	}
 }
 
@@ -1583,7 +1583,7 @@ void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) {
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
 		memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44);
 		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g165_Frame_DoorFrameRight_D3R);
-		if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
+		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
 			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k0_viewDoorButton_D3R);
 		}
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect],
@@ -1627,7 +1627,7 @@ void DisplayMan::f118_drawSquareD3C(direction dir, int16 posX, int16 posY) {
 	int16 squareAspect[5];
 
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
@@ -1649,7 +1649,7 @@ void DisplayMan::f118_drawSquareD3C(direction dir, int16 posX, int16 posY) {
 		f100_drawWallSetBitmap(_g706_bitmapWallSet_DoorFrameLeft_D3C, g166_Frame_DoorFrameLeft_D3C);
 		memmove(_g74_tmpBitmap, _g706_bitmapWallSet_DoorFrameLeft_D3C, 32 * 44);
 		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g167_Frame_DoorFrameRight_D3C);
-		if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
+		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
 			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k1_ViewDoorOrnament_D2LCR);
 		}
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
@@ -1691,7 +1691,7 @@ void DisplayMan::f119_drawSquareD2L(direction dir, int16 posX, int16 posY) {
 	int16 order;
 	int16 squareAspect[5];
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
@@ -1758,7 +1758,7 @@ void DisplayMan::f120_drawSquareD2R(direction dir, int16 posX, int16 posY) {
 	int16 squareAspect[5];
 
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
@@ -1826,7 +1826,7 @@ void DisplayMan::f121_drawSquareD2C(direction dir, int16 posX, int16 posY) {
 	int16 squareAspect[5];
 
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
@@ -1849,7 +1849,7 @@ void DisplayMan::f121_drawSquareD2C(direction dir, int16 posX, int16 posY) {
 		f100_drawWallSetBitmap(_g707_bitmapWallSet_DoorFrameLeft_D2C, g168_Frame_DoorFrameLeft_D2C);
 		memcpy(_g74_tmpBitmap, _g707_bitmapWallSet_DoorFrameLeft_D2C, 48 * 65);
 		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g169_Frame_DoorFrameRight_D2C);
-		if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
+		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
 			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k2_viewDoorButton_D2C);
 		}
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
@@ -1892,7 +1892,7 @@ void DisplayMan::f122_drawSquareD1L(direction dir, int16 posX, int16 posY) {
 	int16 squareAspect[5];
 
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
@@ -2013,7 +2013,7 @@ void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) {
 	byte* bitmap;
 
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
 	switch (_vm->_dungeonMan->_g285_squareAheadElement = (ElementType)squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
@@ -2062,7 +2062,7 @@ void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) {
 		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, g177_Frame_DoorFrameTop_D1C);
 		f100_drawWallSetBitmap(_g708_bitmapWallSet_DoorFrameLeft_D1C, g170_Frame_DoorFrameLeft_D1C);
 		f100_drawWallSetBitmap(_g710_bitmapWallSet_DoorFrameRight_D1C, g171_Frame_DoorFrameRight_D1C);
-		if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
+		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
 			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C);
 		}
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
@@ -2134,7 +2134,7 @@ void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) {
 
 	int16 squareAspect[5];
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k16_DoorSideElemType:
 		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
@@ -2653,7 +2653,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 			}
 		}
 		f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport,
-						  *(Box*)AL0090_puc_CoordinateSet, AL0089_i_X, 0,
+						  *(Box *)AL0090_puc_CoordinateSet, AL0089_i_X, 0,
 						  AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport);
 /* BUG0_05 A champion portrait sensor on a wall square is visible on all sides of the wall.
 If there is another sensor with a wall ornament on one side of the wall then the champion portrait is drawn over that wall ornament */
@@ -2894,9 +2894,9 @@ void DisplayMan::f115_cthulhu(Thing thingParam, direction directionParam, int16
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 
 	// AL_0 shared
-	uint16 &AL_0_creatureIndexRed = *(uint16*)&thingParam;
-	uint16 &AL_0_creatureGraphicInfoRed = *(uint16*)&thingParam;
-	uint16 &AL_0_creaturePosX = *(uint16*)&thingParam;
+	uint16 &AL_0_creatureIndexRed = *(uint16 *)&thingParam;
+	uint16 &AL_0_creatureGraphicInfoRed = *(uint16 *)&thingParam;
+	uint16 &AL_0_creaturePosX = *(uint16 *)&thingParam;
 	// AL_1 shared
 	int16 &AL_1_viewSquareExplosionIndex = viewSquareIndex;
 	// AL_2 shared
@@ -3190,14 +3190,14 @@ T0115015_DrawProjectileAsObject:
 		if ((groupThing == Thing::_none) || drawCreaturesCompleted)
 			goto T0115129_DrawProjectiles; /* Skip code to draw creatures */
 		if (group == nullptr) { /* If all creature data and info has not already been gathered */
-			group = (Group*)dunMan.f156_getThingData(groupThing);
+			group = (Group *)dunMan.f156_getThingData(groupThing);
 			activeGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
 			creatureInfo = &g243_CreatureInfo[group->_type];
 			creatureAspectStruct = &g219_CreatureAspects[creatureInfo->_creatureAspectIndex];
 			creatureSize = getFlag(creatureInfo->_attributes, k0x0003_MaskCreatureInfo_size);
 			creatureGraphicInfoGreen = creatureInfo->_graphicInfo;
 		}
-		objectAspect = (ObjectAspect*)creatureAspectStruct;
+		objectAspect = (ObjectAspect *)creatureAspectStruct;
 		if (AL_0_creatureIndexRed = _vm->_groupMan->f176_getCreatureOrdinalInCell(group, cellYellowBear)) { /* If there is a creature on the cell being processed */
 			AL_0_creatureIndexRed--; /* Convert ordinal to index */
 			creatureIndexGreen = AL_0_creatureIndexRed;
@@ -3261,26 +3261,26 @@ T0115015_DrawProjectileAsObject:
 			viewSquareIndex--;
 		}
 T0115077_DrawSecondHalfSquareCreature:
-		coordinateSet = g224_CreatureCoordinateSets[((CreatureAspect*)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell];
+		coordinateSet = g224_CreatureCoordinateSets[((CreatureAspect *)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell];
 		if (!coordinateSet[1])
 			goto T0115126_CreatureNotVisible;
 		AL_0_creatureGraphicInfoRed = creatureGraphicInfoGreen;
-		AL_4_nativeBitmapIndex = k446_FirstCreatureGraphicIndice + ((CreatureAspect*)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */
-		derivedBitmapIndex = ((CreatureAspect*)objectAspect)->_firstDerivedBitmapIndex;
+		AL_4_nativeBitmapIndex = k446_FirstCreatureGraphicIndice + ((CreatureAspect *)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */
+		derivedBitmapIndex = ((CreatureAspect *)objectAspect)->_firstDerivedBitmapIndex;
 		if (useCreatureSideBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide) && (creatureDirectionDelta & 0x0001)) {
 			useCreatureAttackBitmap = useFlippedHorizontallyCreatureFrontImage = useCreatureBackBitmap = false;
 			AL_4_nativeBitmapIndex++; /* Skip the front image. Side image is right after the front image */
 			derivedBitmapIndex += 2;
-			sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthSide;
-			sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightSide;
+			sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthSide;
+			sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightSide;
 		} else {
 			useCreatureBackBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack) && (creatureDirectionDelta == 0);
 			if (useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, k0x0080_MaskActiveGroupIsAttacking)
 				&& getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack)) {
 
 				useFlippedHorizontallyCreatureFrontImage = false;
-				sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthAttack;
-				sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightAttack;
+				sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthAttack;
+				sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightAttack;
 				AL_4_nativeBitmapIndex++; /* Skip the front image */
 				derivedBitmapIndex += 2;
 				if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) {
@@ -3292,8 +3292,8 @@ T0115077_DrawSecondHalfSquareCreature:
 					derivedBitmapIndex += 2;
 				}
 			} else {
-				sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthFront;
-				sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightFront;
+				sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthFront;
+				sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightFront;
 				if (useCreatureBackBitmap) {
 					useFlippedHorizontallyCreatureFrontImage = false;
 					if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) {
@@ -3323,7 +3323,7 @@ T0115077_DrawSecondHalfSquareCreature:
 		if (viewSquareIndex >= k6_ViewSquare_D1C) { /* Creature is on D1 */
 			creaturePaddingPixelCount = 0;
 			AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
-			transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour();
+			transparentColor = ((CreatureAspect *)objectAspect)->getTranspColour();
 			if (useCreatureSideBitmap) {
 				AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 				if (creatureDirectionDelta == 1) {
@@ -3372,7 +3372,7 @@ T0115077_DrawSecondHalfSquareCreature:
 			}
 			byteWidth = M78_getScaledDimension(sourceByteWidth, scale);
 			heightRedEagle = M78_getScaledDimension(sourceHeight, scale);
-			transparentColor = paletteChanges[((CreatureAspect*)objectAspect)->getTranspColour()] / 10;
+			transparentColor = paletteChanges[((CreatureAspect *)objectAspect)->getTranspColour()] / 10;
 			if (derivedBitmapInCache = f491_isDerivedBitmapInCache(derivedBitmapIndex)) {
 				AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 			} else {
@@ -3444,24 +3444,24 @@ continue;
 
 		do {
 			if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) {
-				projectile = (Projectile*)dunMan.f156_getThingData(thingParam);
+				projectile = (Projectile *)dunMan.f156_getThingData(thingParam);
 				if ((AL_4_projectileAspect = dunMan.f142_getProjectileAspect(projectile->_slot)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
-					objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-AL_4_projectileAspect)];
-					AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
-					projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
-					if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask))
+					objectAspect = (ObjectAspect *)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-AL_4_projectileAspect)];
+					AL_4_nativeBitmapIndex = ((ProjectileAspect *)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
+					projectileAspectType = getFlag(((ProjectileAspect *)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
+					if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect *)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask))
 						 || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == k9_ViewSquare_D0C)) {
 						scale = 0; /* Use native bitmap without resizing */
-						byteWidth = ((ProjectileAspect*)objectAspect)->_byteWidth;
-						heightRedEagle = ((ProjectileAspect*)objectAspect)->_height;
+						byteWidth = ((ProjectileAspect *)objectAspect)->_byteWidth;
+						heightRedEagle = ((ProjectileAspect *)objectAspect)->_height;
 					} else {
 						AL_8_projectileScaleIndex = ((viewSquareIndex / 3) << 1) + (AL_2_viewCell >> 1);
 						scale = g215_ProjectileScales[AL_8_projectileScaleIndex];
 						if (!doNotScaleWithKineticEnergy) {
 							scale = (scale * MAX(96, projectile->_kineticEnergy + 1)) >> 8;
 						}
-						byteWidth = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_byteWidth, scale);
-						heightRedEagle = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale);
+						byteWidth = M78_getScaledDimension(((ProjectileAspect *)objectAspect)->_byteWidth, scale);
+						heightRedEagle = M78_getScaledDimension(((ProjectileAspect *)objectAspect)->_height, scale);
 					}
 					if (projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == k0_ProjectileAspectHasBackGraphicRotation)) {
 						projectileFlipVertical = ((mapXpos + mapYpos) & 0x0001);
@@ -3496,7 +3496,7 @@ continue;
 								projectileBitmapIndexData = 1;
 							}
 							flipVertical = projectileAspectTypeHasBackGraphicAndRotation && (AL_2_viewCell < k2_ViewCellBackRight);
-							flipHorizontal = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0010_ProjectileSideMask)
+							flipHorizontal = getFlag(((ProjectileAspect *)objectAspect)->_graphicInfo, k0x0010_ProjectileSideMask)
 								&& !((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight))));
 						}
 					}
@@ -3508,7 +3508,7 @@ continue;
 						if (flipHorizontal) {
 							paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1;
 						}
-						derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (projectileBitmapIndexData * 6);
+						derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect *)objectAspect)->_firstNativeBitmapRelativeIndex + (projectileBitmapIndexData * 6);
 						if (doNotScaleWithKineticEnergy && f491_isDerivedBitmapInCache(derivedBitmapIndex) + AL_8_projectileScaleIndex) {
 							AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 						} else {
@@ -3518,7 +3518,7 @@ continue;
 							} else {
 								AL_6_bitmapRedBanana = _g74_tmpBitmap;
 							}
-							f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_byteWidth * 2, ((ProjectileAspect*)objectAspect)->_height,
+							f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect *)objectAspect)->_byteWidth * 2, ((ProjectileAspect *)objectAspect)->_height,
 																 byteWidth * 2, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
 							if (doNotScaleWithKineticEnergy) {
 								warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap");
@@ -3583,7 +3583,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 	do {
 		if (thingParam.getType() == k15_ExplosionThingType) {
 			AL_2_cellPurpleMan = thingParam.getCell();
-			explosion = (Explosion*)dunMan.f156_getThingData(thingParam);
+			explosion = (Explosion *)dunMan.f156_getThingData(thingParam);
 			if ((rebirthExplosion = ((unsigned int)(AL_4_explosionType = explosion->getType()) >= k100_ExplosionType_RebirthStep1))
 				&& ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion)
 					|| (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion)
@@ -3601,14 +3601,14 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 						AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke;
 					} else {
 						if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) {
-							objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-dunMan.f142_getProjectileAspect(Thing::_explLightningBolt))];
-							AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
+							objectAspect = (ObjectAspect *)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-dunMan.f142_getProjectileAspect(Thing::_explLightningBolt))];
+							AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(((ProjectileAspect *)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
 							explosionCoordinates = g228_RebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
-							byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_byteWidth), explosionCoordinates[2]);
-							heightRedEagle = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
+							byteWidth = M78_getScaledDimension((((ProjectileAspect *)objectAspect)->_byteWidth), explosionCoordinates[2]);
+							heightRedEagle = M78_getScaledDimension((((ProjectileAspect *)objectAspect)->_height), explosionCoordinates[2]);
 							if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) {
 								f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap,
-									((ProjectileAspect*)objectAspect)->_byteWidth * 2, ((ProjectileAspect*)objectAspect)->_height,
+									((ProjectileAspect *)objectAspect)->_byteWidth * 2, ((ProjectileAspect *)objectAspect)->_height,
 																	 byteWidth * 2, heightRedEagle, g17_PalChangesNoChanges);
 								AL_6_bitmapRedBanana = _g74_tmpBitmap;
 							}
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 80cc1cc..cb73d3f 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -90,7 +90,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 	while (L0750_T_ThingBeingProcessed != Thing::_endOfList) {
 		if ((L0751_ui_ThingType = (L0750_T_ThingBeingProcessed).getType()) == k3_SensorThingType) {
 			L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell = (L0750_T_ThingBeingProcessed).getCell()]--;
-			L0755_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0750_T_ThingBeingProcessed);
+			L0755_ps_Sensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0750_T_ThingBeingProcessed);
 			if ((L0757_ui_SensorType = (L0755_ps_Sensor)->getType()) == k0_SensorDisabled)
 				goto T0275058_ProceedToNextThing;
 			if ((_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) && (L0757_ui_SensorType != k127_SensorWallChampionPortrait))
@@ -119,7 +119,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 				if (!L0753_B_DoNotTriggerSensor && (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) {
 					if (L0763_T_LastProcessedThing == L0750_T_ThingBeingProcessed) /* If the sensor is the only one of its type on the cell */
 						break;
-					L0765_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0763_T_LastProcessedThing);
+					L0765_ps_Sensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0763_T_LastProcessedThing);
 					L0765_ps_Sensor->setNextThing(L0755_ps_Sensor->getNextThing());
 					L0755_ps_Sensor->setNextThing(Thing::_none);
 					L0750_T_ThingBeingProcessed = L0763_T_LastProcessedThing;
@@ -184,7 +184,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 					warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 				}
 				if (!_vm->_championMan->_g415_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
-					L0754_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0761_T_LeaderHandObject);
+					L0754_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0761_T_LeaderHandObject);
 					*L0754_ps_Generic = Thing::_none;
 					_vm->_championMan->f298_getObjectRemovedFromLeaderHand();
 					L0761_T_LeaderHandObject = Thing::_none;
@@ -280,15 +280,15 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 			}
 		}
 		if (L0710_i_ThingType == k14_ProjectileThingType) {
-			L0712_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(thing);
-			_g400_moveResultDir = (_vm->_timeline->_g370_events[((Projectile*)L0712_ps_Teleporter)->_eventIndex])._C._projectile.getDir();
+			L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f156_getThingData(thing);
+			_g400_moveResultDir = (_vm->_timeline->_g370_events[((Projectile *)L0712_ps_Teleporter)->_eventIndex])._C._projectile.getDir();
 		}
 		for (L0728_i_ChainedMoveCount = 1000; --L0728_i_ChainedMoveCount; ) { /* No more than 1000 chained moves at once (in a chain of teleporters and pits for example) */
 			AL0708_i_DestinationSquare = _vm->_dungeonMan->_g271_currMapData[destMapX][destMapY];
 			if ((AL0709_i_DestinationSquareType = Square(AL0708_i_DestinationSquare).getType()) == k5_ElementTypeTeleporter) {
 				if (!getFlag(AL0708_i_DestinationSquare, k0x0008_TeleporterOpen))
 					break;
-				L0712_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(destMapX, destMapY);
+				L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f157_getSquareFirstThingData(destMapX, destMapY);
 				if ((L0712_ps_Teleporter->getScope() == k0x0001_TelepScopeCreatures) && (L0710_i_ThingType != k4_GroupThingType))
 					break;
 				if ((L0718_i_RequiredTeleporterScope != (k0x0001_TelepScopeCreatures | k0x0002_TelepScopeObjOrParty)) && !getFlag(L0712_ps_Teleporter->getScope(), L0718_i_RequiredTeleporterScope))
@@ -363,7 +363,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					} else {
 						if (L0710_i_ThingType == k4_GroupThingType) {
 							_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
-							AL0727_ui_Outcome = _vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group*)_vm->_dungeonMan->f156_getThingData(thing), mapX, mapY, 20, false);
+							AL0727_ui_Outcome = _vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group *)_vm->_dungeonMan->f156_getThingData(thing), mapX, mapY, 20, false);
 							_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination);
 							if (L0722_B_FallKilledGroup = (AL0727_ui_Outcome == k2_outcomeKilledAllCreaturesInGroup))
 								break;
@@ -468,8 +468,8 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 		} else {
 			if (L0710_i_ThingType == k4_GroupThingType) {
 				_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination);
-				L0712_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(thing);
-				AL0708_i_ActiveGroupIndex = ((Group*)L0712_ps_Teleporter)->getActiveGroupIndex();
+				L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f156_getThingData(thing);
+				AL0708_i_ActiveGroupIndex = ((Group *)L0712_ps_Teleporter)->getActiveGroupIndex();
 				if (((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_g309_partyMapIndex) && (destMapX == _vm->_dungeonMan->_g306_partyMapX) && (destMapY == _vm->_dungeonMan->_g307_partyMapY)) || (_vm->_groupMan->f175_groupGetThing(destMapX, destMapY) != Thing::_endOfList)) { /* If a group tries to move to the party square or over another group then create an event to move the group later */
 					_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
 					if (mapX >= 0) {
@@ -481,7 +481,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					f265_createEvent60to61_moveGroup(thing, destMapX, destMapY, L0715_ui_MapIndexDestination, L0726_B_Audible);
 					return true; /* The specified group thing cannot be moved because the party or another group is on the destination square */
 				}
-				L1638_ui_MovementSoundIndex = f514_getSound(((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[(thing).getIndex()]._type);
+				L1638_ui_MovementSoundIndex = f514_getSound(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[(thing).getIndex()]._type);
 				if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) {
 					warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 				}
@@ -573,7 +573,7 @@ bool MovesensMan::f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMa
 		}
 	} else {
 		L0702_i_ImpactType = kM1_CreatureElemType;
-		L0701_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing);
+		L0701_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(thing);
 		for (AL0699_ui_Cell = k0_CellNorthWest, AL0700_B_CreatureAlive = false; AL0699_ui_Cell < k3_CellSouthWest + 1; AL0699_ui_Cell++) {
 			AL0700_B_CreatureAlive |= L0701_ps_Group->_health[AL0699_ui_Cell];
 			if (_vm->_groupMan->f176_getCreatureOrdinalInCell(L0701_ps_Group, AL0699_ui_Cell)) {
@@ -608,7 +608,7 @@ T0266017_CheckProjectileImpacts:
 	L0697_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0704_ui_ProjectileMapX, L0705_ui_ProjectileMapY);
 	while (L0697_T_Thing != Thing::_endOfList) {
 		if (((L0697_T_Thing).getType() == k14_ProjectileThingType) &&
-			(_vm->_timeline->_g370_events[(((Projectile*)_vm->_dungeonMan->_g284_thingData[k14_ProjectileThingType])[(L0697_T_Thing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts) && (AL0699_ui_ChampionOrCreatureOrdinal = L0707_auc_ChampionOrCreatureOrdinalInCell[(L0697_T_Thing).getCell()]) &&
+			(_vm->_timeline->_g370_events[(((Projectile *)_vm->_dungeonMan->_g284_thingData[k14_ProjectileThingType])[(L0697_T_Thing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts) && (AL0699_ui_ChampionOrCreatureOrdinal = L0707_auc_ChampionOrCreatureOrdinalInCell[(L0697_T_Thing).getCell()]) &&
 			_vm->_projexpl->f217_projectileHasImpactOccurred(L0702_i_ImpactType, srcMapX, srcMapY, _vm->M1_ordinalToIndex(AL0699_ui_ChampionOrCreatureOrdinal), L0697_T_Thing)) {
 			_vm->_projexpl->f214_projectileDeleteEvent(L0697_T_Thing);
 			if (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup) {
@@ -700,7 +700,7 @@ int16 MovesensMan::f262_getTeleporterRotatedGroupResult(Teleporter* teleporter,
 	int16 L0691_i_CreatureSize;
 	int16 L0692_i_RelativeRotation;
 
-	L0686_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing);
+	L0686_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(thing);
 	L0683_i_Rotation = teleporter->getRotation();
 	L0684_ui_GroupDirections = _vm->_groupMan->f147_getGroupDirections(L0686_ps_Group, mapIndex);
 	if (L0689_B_AbsoluteRotation = teleporter->getAbsoluteRotation()) {
@@ -817,7 +817,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 	L0766_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
 	while (L0766_T_Thing != Thing::_endOfList) {
 		if ((L0771_ui_ThingType = (L0766_T_Thing).getType()) == k3_SensorThingType) {
-			L0769_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0766_T_Thing);
+			L0769_ps_Sensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0766_T_Thing);
 			if ((L0769_ps_Sensor)->getType() == k0_SensorDisabled)
 				goto T0276079;
 			L0779_i_SensorData = L0769_ps_Sensor->getData();
@@ -940,7 +940,7 @@ T0274003:
 					return true;
 				}
 				if (L0747_i_ObjectType == k144_IconIndiceContainerChestClosed) {
-					L0749_ps_Container = (Container*)_vm->_dungeonMan->f156_getThingData(L0744_T_Thing);
+					L0749_ps_Container = (Container *)_vm->_dungeonMan->f156_getThingData(L0744_T_Thing);
 					L0744_T_Thing = L0749_ps_Container->getSlot();
 					while (L0744_T_Thing != Thing::_endOfList) {
 						if (_vm->_objectMan->f32_getObjectType(L0744_T_Thing) == objectType) {
@@ -1042,7 +1042,7 @@ void MovesensMan::f271_processRotationEffect() {
 		while (((L0732_T_FirstSensorThing).getType() != k3_SensorThingType) || ((_g406_sensorRotationEffCell != kM1_CellAny) && ((L0732_T_FirstSensorThing).getCell() != _g406_sensorRotationEffCell))) {
 			L0732_T_FirstSensorThing = _vm->_dungeonMan->f159_getNextThing(L0732_T_FirstSensorThing);
 		}
-		L0734_ps_FirstSensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0732_T_FirstSensorThing);
+		L0734_ps_FirstSensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0732_T_FirstSensorThing);
 		L0733_T_LastSensorThing = L0734_ps_FirstSensor->getNextThing();
 		while ((L0733_T_LastSensorThing != Thing::_endOfList) && (((L0733_T_LastSensorThing).getType() != k3_SensorThingType) || ((_g406_sensorRotationEffCell != kM1_CellAny) && ((L0733_T_LastSensorThing).getCell() != _g406_sensorRotationEffCell)))) {
 			L0733_T_LastSensorThing = _vm->_dungeonMan->f159_getNextThing(L0733_T_LastSensorThing);
@@ -1050,11 +1050,11 @@ void MovesensMan::f271_processRotationEffect() {
 		if (L0733_T_LastSensorThing == Thing::_endOfList)
 			break;
 		_vm->_dungeonMan->f164_unlinkThingFromList(L0732_T_FirstSensorThing, Thing(0), _g404_sensorRotationEffMapX, _g405_sensorRotationEffMapY);
-		L0735_ps_LastSensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0733_T_LastSensorThing);
+		L0735_ps_LastSensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0733_T_LastSensorThing);
 		L0733_T_LastSensorThing = _vm->_dungeonMan->f159_getNextThing(L0733_T_LastSensorThing);
 		while (((L0733_T_LastSensorThing != Thing::_endOfList) && ((L0733_T_LastSensorThing).getType() == k3_SensorThingType))) {
 			if ((_g406_sensorRotationEffCell == kM1_CellAny) || ((L0733_T_LastSensorThing).getCell() == _g406_sensorRotationEffCell)) {
-				L0735_ps_LastSensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0733_T_LastSensorThing);
+				L0735_ps_LastSensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0733_T_LastSensorThing);
 			}
 			L0733_T_LastSensorThing = _vm->_dungeonMan->f159_getNextThing(L0733_T_LastSensorThing);
 		}
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index f773ffb..4c08214 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -55,7 +55,7 @@ void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16
 		return;
 	}
 	L0466_T_ProjectileThing = M15_thingWithNewCell(L0466_T_ProjectileThing, cell);
-	L0467_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(L0466_T_ProjectileThing);
+	L0467_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(L0466_T_ProjectileThing);
 	L0467_ps_Projectile->_slot = thing;
 	L0467_ps_Projectile->_kineticEnergy = MIN((int16)kineticEnergy, (int16)255);
 	L0467_ps_Projectile->_attack = attack;
@@ -111,14 +111,14 @@ bool ProjExpl::f217_projectileHasImpactOccurred(int16 impactType, int16 mapXComb
 	uint16 L0511_ui_CreatureType;
 	uint16 L0512_ui_CreatureIndex;
 
-	L0490_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(Thing(projectileThing));
+	L0490_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(Thing(projectileThing));
 	L0501_i_MapXCombo = mapXCombo;
 	L0502_i_MapYCombo = mapYCombo;
 	L0509_B_RemovePotion = false;
 	_g364_creatureDamageOutcome = k0_outcomeKilledNoCreaturesInGroup;
 	if ((L0510_i_ProjectileAssociatedThingType = (L0486_T_ProjectileAssociatedThing = L0490_ps_Projectile->_slot).getType()) == k8_PotionThingType) {
-		L0491_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0486_T_ProjectileAssociatedThing);
-		switch (((Potion*)L0491_ps_Group)->getType()) {
+		L0491_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0486_T_ProjectileAssociatedThing);
+		switch (((Potion *)L0491_ps_Group)->getType()) {
 		case k3_PotionTypeVen:
 			L0498_T_ExplosionThing = Thing::_explPoisonCloud;
 			goto T0217004;
@@ -126,8 +126,8 @@ bool ProjExpl::f217_projectileHasImpactOccurred(int16 impactType, int16 mapXComb
 			L0498_T_ExplosionThing = Thing::_explFireBall;
 T0217004:
 			L0509_B_RemovePotion = true;
-			L0508_i_PotionPower = ((Potion*)L0491_ps_Group)->getPower();
-			L0492_ps_Potion = (Potion*)L0491_ps_Group;
+			L0508_i_PotionPower = ((Potion *)L0491_ps_Group)->getPower();
+			L0492_ps_Potion = (Potion *)L0491_ps_Group;
 		}
 	}
 	L0505_B_CreateExplosionOnImpact = (L0510_i_ProjectileAssociatedThingType == k15_ExplosionThingType) && (L0486_T_ProjectileAssociatedThing != Thing::_explSlime) && (L0486_T_ProjectileAssociatedThing != Thing::_explPoisonBolt);
@@ -145,7 +145,7 @@ T0217004:
 	switch (impactType) {
 	case k4_DoorElemType:
 		AL0487_i_DoorState = Square(L0503_uc_Square = _vm->_dungeonMan->_g271_currMapData[AP0454_i_ProjectileTargetMapX][AP0455_i_ProjectileTargetMapY]).getDoorState();
-		L0494_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY);
+		L0494_ps_Door = (Door *)_vm->_dungeonMan->f157_getSquareFirstThingData(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY);
 		if ((AL0487_i_DoorState != k5_doorState_DESTROYED) && (L0486_T_ProjectileAssociatedThing == Thing::_explOpenDoor)) {
 			if (L0494_ps_Door->hasButton()) {
 				_vm->_movsens->f268_addEvent(k10_TMEventTypeDoor, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1);
@@ -175,7 +175,7 @@ T0217004:
 		L0489_i_ChampionAttack = L0488_i_Attack = f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing);
 		break;
 	case kM1_CreatureElemType:
-		L0491_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY));
+		L0491_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY));
 		if (!(L0512_ui_CreatureIndex = _vm->_groupMan->f176_getCreatureOrdinalInCell(L0491_ps_Group, cell))) {
 			return false;
 		}
@@ -198,7 +198,7 @@ T0217004:
 				(AL0487_i_Outcome == k0_outcomeKilledNoCreaturesInGroup) &&
 				(L0510_i_ProjectileAssociatedThingType == k5_WeaponThingType) &&
 				getFlag(L0493_ps_CreatureInfo->_attributes, k0x0400_MaskCreatureInfo_keepThrownSharpWeapon)) {
-				L0495_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0486_T_ProjectileAssociatedThing);
+				L0495_ps_Weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(L0486_T_ProjectileAssociatedThing);
 				AL0487_i_WeaponType = L0495_ps_Weapon->getType();
 				if ((AL0487_i_WeaponType == k8_WeaponTypeDagger) || (AL0487_i_WeaponType == k27_WeaponTypeArrow) || (AL0487_i_WeaponType == k28_WeaponTypeSlayer) || (AL0487_i_WeaponType == k31_WeaponTypePoisonDart) || (AL0487_i_WeaponType == k32_WeaponTypeThrowingStar)) {
 					L0497_pT_GroupSlot = &L0491_ps_Group->_slot;
@@ -307,7 +307,7 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 	if ((L0473_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k15_ExplosionThingType)) == Thing::_none) {
 		return;
 	}
-	L0470_ps_Explosion = &((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[(L0473_T_Thing).getIndex()];
+	L0470_ps_Explosion = &((Explosion *)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[(L0473_T_Thing).getIndex()];
 	if (mapXCombo <= 255) {
 		L0474_i_ProjectileTargetMapX = mapXCombo;
 		L0475_i_ProjectileTargetMapY = mapYCombo;
@@ -351,7 +351,7 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 				_vm->_championMan->f324_damageAll_getDamagedChampionCount(attack, k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand | k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k1_attackType_FIRE);
 			} else {
 				if ((L0473_T_Thing = _vm->_groupMan->f175_groupGetThing(AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY)) != Thing::_endOfList) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
-					L0472_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0473_T_Thing);
+					L0472_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0473_T_Thing);
 					L0471_ps_CreatureInfo = &g243_CreatureInfo[L0472_ps_Group->_type];
 					if ((L0469_i_CreatureFireResistance = (L0471_ps_CreatureInfo->M60_getFireResistance())) != k15_immuneToFire) {
 						if (getFlag(L0471_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
@@ -395,7 +395,7 @@ void ProjExpl::f214_projectileDeleteEvent(Thing thing) {
 	Projectile* L0477_ps_Projectile;
 
 
-	L0477_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(thing);
+	L0477_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(thing);
 	_vm->_timeline->f237_deleteEvent(L0477_ps_Projectile->_eventIndex);
 }
 
@@ -405,11 +405,11 @@ void ProjExpl::f215_projectileDelete(Thing projectileThing, Thing* groupSlot, in
 	Projectile* L0480_ps_Projectile;
 	Thing* L0481_ps_Generic;
 
-	L0480_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(projectileThing);
+	L0480_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(projectileThing);
 	if ((L0479_T_Thing = L0480_ps_Projectile->_slot).getType() != k15_ExplosionThingType) {
 		if (groupSlot != NULL) {
 			if ((L0478_T_PreviousThing = *groupSlot) == Thing::_endOfList) {
-				L0481_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0479_T_Thing);
+				L0481_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0479_T_Thing);
 				*L0481_ps_Generic = Thing::_endOfList;
 				*groupSlot = L0479_T_Thing;
 			} else {


Commit: 3447af80f8a48413958f64e60890138c9dbe12da
    https://github.com/scummvm/scummvm/commit/3447af80f8a48413958f64e60890138c9dbe12da
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some soft refactoring in champion.cpp

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 24cfda9..823a37f 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -511,18 +511,15 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 }
 
 int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) {
-	uint16 searchedScentRedEagle;
-	int16 scentIndex;
-	Scent* scent;
-	Scent searchedScent;
+	int16 scentIndex = _g407_party._scentCount;
 
-
-	if (scentIndex = _g407_party._scentCount) {
+	if (scentIndex) {
+		Scent searchedScent;
 		searchedScent.setMapX(mapX);
 		searchedScent.setMapY(mapY);
 		searchedScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex);
-		searchedScentRedEagle = searchedScent.toUint16();
-		scent = &_g407_party._scents[scentIndex--];
+		uint16 searchedScentRedEagle = searchedScent.toUint16();
+		Scent* scent = &_g407_party._scents[scentIndex--];
 		do {
 			if ((*(--scent)).toUint16() == searchedScentRedEagle) {
 				return _vm->M0_indexToOrdinal(scentIndex);
@@ -992,27 +989,20 @@ int16 ChampionMan::f324_damageAll_getDamagedChampionCount(uint16 attack, int16 w
 }
 
 int16 ChampionMan::f286_getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) {
-	uint16 L0838_ui_Counter;
-	int16 L0839_i_ChampionIndex;
-	signed char L0840_auc_OrderedCellsToAttack[4];
-
-
 	if (_g305_partyChampionCount && (M38_distance(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)) {
+		signed char L0840_auc_OrderedCellsToAttack[4];
 		_vm->_groupMan->f229_setOrderedCellsToAttack(L0840_auc_OrderedCellsToAttack, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, mapX, mapY, cell);
-		for (L0838_ui_Counter = 0; L0838_ui_Counter < 4; L0838_ui_Counter++) {
-			if ((L0839_i_ChampionIndex = f285_getIndexInCell(L0840_auc_OrderedCellsToAttack[L0838_ui_Counter])) >= 0) {
+		for (uint16 L0838_ui_Counter = 0; L0838_ui_Counter < 4; L0838_ui_Counter++) {
+			int16 L0839_i_ChampionIndex = f285_getIndexInCell(L0840_auc_OrderedCellsToAttack[L0838_ui_Counter]);
+			if (L0839_i_ChampionIndex >= 0)
 				return L0839_i_ChampionIndex;
-			}
 		}
 	}
 	return kM1_ChampionNone;
 }
 
 int16 ChampionMan::f311_getDexterity(Champion* champ) {
-	int16 L0934_i_Dexterity;
-
-
-	L0934_i_Dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent];
+	int16 L0934_i_Dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent];
 	L0934_i_Dexterity -= ((int32)(L0934_i_Dexterity >> 1) * (int32)champ->_load) / f309_getMaximumLoad(champ);
 	if (_g300_partyIsSleeping) {
 		L0934_i_Dexterity >>= 1;
@@ -1022,27 +1012,21 @@ int16 ChampionMan::f311_getDexterity(Champion* champ) {
 
 bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) {
 #define AP0646_ui_IsLucky percentage
-	register unsigned char* L0928_puc_Statistic;
-
 
 	if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage)) {
 		return true;
 	}
-	L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck];
+	register unsigned char* L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck];
 	AP0646_ui_IsLucky = (_vm->getRandomNumber(L0928_puc_Statistic[k1_ChampionStatCurrent]) > percentage);
 	L0928_puc_Statistic[k1_ChampionStatCurrent] = f26_getBoundedValue((int32)L0928_puc_Statistic[k2_ChampionStatMinimum], (int32)L0928_puc_Statistic[k1_ChampionStatCurrent] + (AP0646_ui_IsLucky ? -2 : 2), (int32)L0928_puc_Statistic[k0_ChampionStatMaximum]);
 	return AP0646_ui_IsLucky;
 }
 
 void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) {
-	TimelineEvent L0980_s_Event;
-	Champion* L0981_ps_Champion;
-
-
-	if ((champIndex == kM1_ChampionNone) || (_vm->M0_indexToOrdinal(champIndex) == _g299_candidateChampionOrdinal)) {
+	if ((champIndex == kM1_ChampionNone) || (_vm->M0_indexToOrdinal(champIndex) == _g299_candidateChampionOrdinal))
 		return;
-	}
-	L0981_ps_Champion = &_gK71_champions[champIndex];
+
+	Champion* L0981_ps_Champion = &_gK71_champions[champIndex];
 	f321_addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
 	setFlag(L0981_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
 	if ((_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) && (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
@@ -1050,6 +1034,7 @@ void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) {
 	}
 	if (--attack) {
 		L0981_ps_Champion->_poisonEventCount++;
+		TimelineEvent L0980_s_Event;
 		L0980_s_Event._type = k75_TMEventTypePoisonChampion;
 		L0980_s_Event._priority = champIndex;
 		M33_setMapAndTime(L0980_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 36);
@@ -1099,33 +1084,29 @@ void ChampionMan::f316_deleteScent(uint16 scentIndex) {
 }
 
 void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount) {
-	int16 L0954_i_ScentIndex;
-	bool L0955_B_Merge;
-	bool L0956_B_CycleCountDefined;
-	Scent* L0957_ps_Scent; /* BUG0_00 Useless code */
-	Scent L0958_s_Scent; /* BUG0_00 Useless code */
-
-
-	if (L0954_i_ScentIndex = _g407_party._scentCount) {
-		if (L0955_B_Merge = getFlag(cycleCount, k0x8000_mergeCycles)) {
+	int16 L0954_i_ScentIndex = _vm->_championMan->_g407_party._scentCount;
+	if (L0954_i_ScentIndex) {
+		bool L0955_B_Merge = getFlag(cycleCount, k0x8000_mergeCycles);
+		if (L0955_B_Merge) {
 			clearFlag(cycleCount, k0x8000_mergeCycles);
 		}
+		Scent L0958_s_Scent; /* BUG0_00 Useless code */
 		L0958_s_Scent.setMapX(mapX); /* BUG0_00 Useless code */
 		L0958_s_Scent.setMapY(mapY); /* BUG0_00 Useless code */
 		L0958_s_Scent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */
-		L0957_ps_Scent = _g407_party._scents; /* BUG0_00 Useless code */
-		L0956_B_CycleCountDefined = false;
+		Scent* L0957_ps_Scent = _vm->_championMan->_g407_party._scents; /* BUG0_00 Useless code */
+		bool L0956_B_CycleCountDefined = false;
 		while (L0954_i_ScentIndex--) {
 			if (&*L0957_ps_Scent++ == &L0958_s_Scent) {
 				if (!L0956_B_CycleCountDefined) {
 					L0956_B_CycleCountDefined = true;
 					if (L0955_B_Merge) {
-						cycleCount = MAX((int32)_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount);
+						cycleCount = MAX((int32)_vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount);
 					} else {
-						cycleCount = MIN(80, _g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount);
+						cycleCount = MIN(80, _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount);
 					}
 				}
-				_g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount;
+				_vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount;
 			}
 		}
 	}
@@ -1135,10 +1116,8 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer)
 	if (thing == Thing::_none) {
 		return;
 	}
-	_g415_leaderEmptyHanded = false;
-	_vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
-
-	
+	_vm->_championMan->_g415_leaderEmptyHanded = false;
+	_vm->_objectMan->f36_extractIconFromBitmap(_vm->_championMan->_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_vm->_championMan->_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
 	_vm->_eventMan->f78_showMouse();
 	_vm->_objectMan->f34_drawLeaderObjectName(thing);
 	if (setMousePointer) {
@@ -1147,10 +1126,10 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer)
 		_vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
 	}
 	_vm->_eventMan->f77_hideMouse();
-	if (_g411_leaderIndex != kM1_ChampionNone) {
-		_gK71_champions[_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing);
-		setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
-		f292_drawChampionState(_g411_leaderIndex);
+	if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) {
+		_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing);
+		setFlag(_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
+		_vm->_championMan->f292_drawChampionState(_vm->_championMan->_g411_leaderIndex);
 	}
 }
 
@@ -1176,180 +1155,180 @@ void ChampionMan::f278_resetDataToStartGame() {
 
 
 void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) {
-	Thing L0793_T_Thing;
-	uint16 L0794_ui_Multiple;
-#define AL0794_ui_ViewCell       L0794_ui_Multiple
-#define AL0794_ui_SlotIndex      L0794_ui_Multiple
-#define AL0794_ui_CharacterIndex L0794_ui_Multiple
-#define AL0794_ui_StatisticIndex L0794_ui_Multiple
-#define AL0794_ui_SkillIndex     L0794_ui_Multiple
-	int16 L0795_i_HiddenSkillIndex;
-	uint16 L0796_ui_Multiple;
-#define AL0796_ui_Character  L0796_ui_Multiple
-#define AL0796_ui_SkillValue L0796_ui_Multiple
-#define AL0796_ui_ThingType  L0796_ui_Multiple
-	Champion* L0797_ps_Champion;
-	char* L0798_pc_Character;
-	uint16 L0799_ui_PreviousPartyChampionCount;
-	uint16 L0800_ui_Multiple;
-#define AL0800_B_ChampionTitleCopied L0800_ui_Multiple
-#define AL0800_ui_HiddenSkillCounter L0800_ui_Multiple
-	uint16 L0801_ui_SlotIndex;
-	int16 L0802_i_MapX;
-	int16 L0803_i_MapY;
-	uint16 L0804_ui_ChampionObjectsCell;
-	int16 L0805_i_ObjectAllowedSlots;
-	int32 L0806_l_BaseSkillExperience;
-	char L0807_ac_DecodedChampionText[77];
-
-	if (!_vm->_championMan->_g415_leaderEmptyHanded) {
-		return;
-	}
-	if (_vm->_championMan->_g305_partyChampionCount == 4) {
+	DisplayMan &dispMan = *_vm->_displayMan;
+	DungeonMan &dunMan = *_vm->_dungeonMan;
+
+	if (!_g415_leaderEmptyHanded || _g305_partyChampionCount == 4)
 		return;
-	}
-	L0797_ps_Champion = &_vm->_championMan->_gK71_champions[L0799_ui_PreviousPartyChampionCount = _vm->_championMan->_g305_partyChampionCount];
-	L0797_ps_Champion->resetToZero();
-	// Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portaits could be missing in the data)
-	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
-	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), L0797_ps_Champion->_portrait, gBoxChampionPortrait, _vm->_championMan->M27_getChampionPortraitX(championPortraitIndex), _vm->_championMan->M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency);
-	L0797_ps_Champion->_actionIndex = k255_ChampionActionNone;
-	L0797_ps_Champion->_enableActionEventIndex = -1;
-	L0797_ps_Champion->_hideDamageReceivedIndex = -1;
-	L0797_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
-	AL0794_ui_ViewCell = k0_ViewCellFronLeft;
-	while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone) {
-		AL0794_ui_ViewCell++;
-	}
-	L0797_ps_Champion->_cell = (ViewCell)M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir);
-	L0797_ps_Champion->_attributes = k0x0400_ChampionAttributeIcon;
-	L0797_ps_Champion->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir;
-	L0797_ps_Champion->_food = 1500 + _vm->getRandomNumber(256);
-	L0797_ps_Champion->_water = 1500 + _vm->getRandomNumber(256);
-	for (AL0794_ui_SlotIndex = k0_ChampionSlotReadyHand; AL0794_ui_SlotIndex < k30_ChampionSlotChest_1; AL0794_ui_SlotIndex++) {
-		L0797_ps_Champion->_slots[AL0794_ui_SlotIndex] = Thing::_none;
-	}
-	L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
-	while ((L0793_T_Thing.getType()) != k2_TextstringType) {
-		L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing);
-	}
-	_vm->_dungeonMan->f168_decodeText(L0798_pc_Character = L0807_ac_DecodedChampionText, L0793_T_Thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
-	AL0794_ui_CharacterIndex = 0;
-	while ((AL0796_ui_Character = *L0798_pc_Character++) != '\n') { /* New line */
-		L0797_ps_Champion->_name[AL0794_ui_CharacterIndex++] = AL0796_ui_Character;
-	}
-	L0797_ps_Champion->_name[AL0794_ui_CharacterIndex] = '\0';
-	AL0794_ui_CharacterIndex = 0;
-	AL0800_B_ChampionTitleCopied = false;
-	for (;;) { /*_Infinite loop_*/
-		AL0796_ui_Character = *L0798_pc_Character++;
-		if (AL0796_ui_Character == '\n') { /* New line */
-			if (AL0800_B_ChampionTitleCopied)
+
+	uint16 prevChampCount = _g305_partyChampionCount;
+	Champion *champ = &_gK71_champions[prevChampCount];
+	champ->resetToZero();
+	dispMan._g578_useByteBoxCoordinates = true;
+	{ // limit destBox scope
+		Box &destBox = gBoxChampionPortrait;
+		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), champ->_portrait,
+								  destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 128, 16, kM1_ColorNoTransparency);
+	}
+
+	champ->_actionIndex = k255_ChampionActionNone;
+	champ->_enableActionEventIndex = -1;
+	champ->_hideDamageReceivedIndex = -1;
+	champ->_dir = dunMan._g308_partyDir;
+	ViewCell AL_0_viewCell = k0_ViewCellFronLeft;
+	while (f285_getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3)) != kM1_ChampionNone)
+		AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
+	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3);
+	champ->clearAttributes(k0x0400_ChampionAttributeIcon);
+	champ->_directionMaximumDamageReceived = dunMan._g308_partyDir;
+	champ->_food = 1500 + _vm->_rnd->getRandomNumber(256);
+	champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
+	int16 AL_0_slotIndex_Red;
+	for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) {
+		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none);
+	}
+	Thing thing = dunMan.f161_getSquareFirstThing(dunMan._g306_partyMapX, dunMan._g307_partyMapY);
+	while (thing.getType() != k2_TextstringType) {
+		thing = dunMan.f159_getNextThing(thing);
+	}
+	char decodedChampionText[77];
+	char* character_Green = decodedChampionText;
+	dunMan.f168_decodeText(character_Green, thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
+	int16 AL_0_characterIndex = 0;
+	uint16 AL_2_character;
+	while ((AL_2_character = *character_Green++) != '\n') {
+		champ->_name[AL_0_characterIndex++] = AL_2_character;
+	}
+	champ->_name[AL_0_characterIndex] = '\0';
+	AL_0_characterIndex = 0;
+	bool AL_4_champTitleCopied = false;
+	for (;;) { // infinite
+		AL_2_character = *character_Green++;
+		if (AL_2_character == '\n') {
+			if (AL_4_champTitleCopied)
 				break;
-			AL0800_B_ChampionTitleCopied = true;
+			AL_4_champTitleCopied = true;
 		} else {
-			L0797_ps_Champion->_title[AL0794_ui_CharacterIndex++] = AL0796_ui_Character;
-		}
-	}
-	L0797_ps_Champion->_title[AL0794_ui_CharacterIndex] = '\0';
-	if (*L0798_pc_Character++ == 'M') {
-		setFlag(L0797_ps_Champion->_attributes, k0x0010_ChampionAttributeMale);
-	}
-	L0798_pc_Character++;
-	L0797_ps_Champion->_currHealth = L0797_ps_Champion->_maxHealth = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4);
-	L0798_pc_Character += 4;
-	L0797_ps_Champion->_currStamina = L0797_ps_Champion->_maxStamina = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4);
-	L0798_pc_Character += 4;
-	L0797_ps_Champion->_currMana = L0797_ps_Champion->_maxMana = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4);
-	L0798_pc_Character += 4;
-	L0798_pc_Character++;
-	for (AL0794_ui_StatisticIndex = k0_ChampionStatLuck; AL0794_ui_StatisticIndex <= k6_ChampionStatAntifire; AL0794_ui_StatisticIndex++) {
-		L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k2_ChampionStatMinimum] = 30;
-		L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k1_ChampionStatCurrent] = L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k0_ChampionStatMaximum] = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 2);
-		L0798_pc_Character += 2;
-	}
-	L0797_ps_Champion->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10;
-	L0798_pc_Character++;
-	for (AL0794_ui_SkillIndex = k4_ChampionSkillSwing; AL0794_ui_SkillIndex <= k19_ChampionSkillWater; AL0794_ui_SkillIndex++) {
-		if ((AL0796_ui_SkillValue = *L0798_pc_Character++ - 'A') > 0) {
-			L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = 125L << AL0796_ui_SkillValue;
-		}
-	}
-	for (AL0794_ui_SkillIndex = k0_ChampionSkillFighter; AL0794_ui_SkillIndex <= k3_ChampionSkillWizard; AL0794_ui_SkillIndex++) {
-		L0806_l_BaseSkillExperience = 0;
-		L0795_i_HiddenSkillIndex = (AL0794_ui_SkillIndex + 1) << 2;
-		for (AL0800_ui_HiddenSkillCounter = 0; AL0800_ui_HiddenSkillCounter < 4; AL0800_ui_HiddenSkillCounter++) {
-			L0806_l_BaseSkillExperience += L0797_ps_Champion->_skills[L0795_i_HiddenSkillIndex + AL0800_ui_HiddenSkillCounter]._experience;
-		}
-		L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = L0806_l_BaseSkillExperience;
-	}
-	_vm->_championMan->_g299_candidateChampionOrdinal = L0799_ui_PreviousPartyChampionCount + 1;
-	if (++_vm->_championMan->_g305_partyChampionCount == 1) {
+			champ->_title[AL_0_characterIndex++] = AL_2_character;
+		}
+	}
+	champ->_title[AL_0_characterIndex] = '\0';
+	if (*character_Green++ == 'M') {
+		champ->setAttributeFlag(k0x0010_ChampionAttributeMale, true);
+	}
+	character_Green++;
+	champ->_currHealth = champ->_maxHealth = f279_getDecodedValue(character_Green, 4);
+	character_Green += 4;
+	champ->_currStamina = champ->_maxStamina = f279_getDecodedValue(character_Green, 4);
+	character_Green += 4;
+	champ->_currMana = champ->_maxMana = f279_getDecodedValue(character_Green, 4);
+	character_Green += 4;
+	character_Green++;
+
+	int16 AL_0_statisticIndex;
+	for (AL_0_statisticIndex = k0_ChampionStatLuck; AL_0_statisticIndex <= k6_ChampionStatAntifire; ++AL_0_statisticIndex) {
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k2_ChampionStatMinimum, 30);
+		uint16 currMaxVal = f279_getDecodedValue(character_Green, 2);
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent, currMaxVal);
+		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k0_ChampionStatMaximum, currMaxVal);
+		character_Green += 2;
+	}
+
+	champ->setStatistic(k0_ChampionStatLuck, k2_ChampionStatMinimum, 10);
+	character_Green++;
+
+	int16 AL_0_skillIndex;
+	int16 AL_2_skillValue;
+	for (AL_0_skillIndex = k4_ChampionSkillSwing; AL_0_skillIndex <= k19_ChampionSkillWater; AL_0_skillIndex++) {
+		if ((AL_2_skillValue = *character_Green++ - 'A') > 0) {
+			champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue);
+		}
+	}
+
+	for (AL_0_skillIndex = k0_ChampionSkillFighter; AL_0_skillIndex <= k3_ChampionSkillWizard; ++AL_0_skillIndex) {
+		int32 baseSkillExp = 0;
+		int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2;
+		for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) {
+			baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience;
+		}
+		champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp);
+	}
+
+	_g299_candidateChampionOrdinal = prevChampCount + 1;
+	if (++_g305_partyChampionCount == 1) {
 		_vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst);
 		_vm->_menuMan->_g508_refreshActionArea = true;
-	} else { 
+	} else {
 		_vm->_menuMan->f388_clearActingChampion();
-		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_vm->_championMan->_g305_partyChampionCount - 1)); 
-	}
-	L0802_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
-	L0803_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
-	L0804_ui_ChampionObjectsCell = returnOppositeDir(_vm->_dungeonMan->_g308_partyDir);
-	L0802_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L0803_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
-	L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0802_i_MapX, L0803_i_MapY);
-	AL0794_ui_SlotIndex = k13_ChampionSlotBackpackLine_1_1;
-	while (L0793_T_Thing != Thing::_endOfList) {
-		if (((AL0796_ui_ThingType = (L0793_T_Thing.getType())) > k3_SensorThingType) && ((L0793_T_Thing.getCell()) == L0804_ui_ChampionObjectsCell)) {
-			L0805_i_ObjectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0793_T_Thing)]._allowedSlots;
-			switch (AL0796_ui_ThingType) {
+		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1));
+	}
+
+	int16 mapX = _vm->_dungeonMan->_g306_partyMapX;
+	int16 mapY = _vm->_dungeonMan->_g307_partyMapY;
+
+	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._g308_partyDir));
+	mapX += _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
+	mapY += _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
+	thing = dunMan.f161_getSquareFirstThing(mapX, mapY);
+	AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1;
+	uint16 slotIndex_Green;
+	while (thing != Thing::_endOfList) {
+		ThingType AL_2_thingType = thing.getType();
+		if ((AL_2_thingType > k3_SensorThingType) && (thing.getCell() == championObjectsCell)) {
+			int16 objectAllowedSlots = g237_ObjectInfo[dunMan.f141_getObjectInfoIndex(thing)].getAllowedSlots();
+			switch (AL_2_thingType) {
 			case k6_ArmourThingType:
-				for (L0801_ui_SlotIndex = k2_ChampionSlotHead; L0801_ui_SlotIndex <= k5_ChampionSlotFeet; L0801_ui_SlotIndex++) {
-					if (L0805_i_ObjectAllowedSlots & gSlotMasks[L0801_ui_SlotIndex])
+				for (slotIndex_Green = k2_ChampionSlotHead; slotIndex_Green <= k5_ChampionSlotFeet; slotIndex_Green++) {
+					if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
 						goto T0280048;
 				}
-				if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
-					L0801_ui_SlotIndex = k10_ChampionSlotNeck;
+				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) {
+					slotIndex_Green = k10_ChampionSlotNeck;
 				} else {
 					goto T0280046;
 				}
 				break;
 			case k5_WeaponThingType:
-				if (L0797_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) {
-					L0801_ui_SlotIndex = k1_ChampionSlotActionHand;
+				if (champ->getSlot(k1_ChampionSlotActionHand) == Thing::_none) {
+					slotIndex_Green = k1_ChampionSlotActionHand;
 				} else {
 					goto T0280046;
 				}
 				break;
 			case k7_ScrollThingType:
 			case k8_PotionThingType:
-				if (L0797_ps_Champion->_slots[k11_ChampionSlotPouch_1] == Thing::_none) {
-					L0801_ui_SlotIndex = k11_ChampionSlotPouch_1;
+				if (champ->getSlot(k11_ChampionSlotPouch_1) == Thing::_none) {
+					slotIndex_Green = k11_ChampionSlotPouch_1;
+				} else if (champ->getSlot(k6_ChampionSlotPouch_2) == Thing::_none) {
+					slotIndex_Green = k6_ChampionSlotPouch_2;
 				} else {
-					if (L0797_ps_Champion->_slots[k6_ChampionSlotPouch_2] == Thing::_none) {
-						L0801_ui_SlotIndex = k6_ChampionSlotPouch_2;
-					} else {
-						goto T0280046;
-					}
+					goto T0280046;
 				}
 				break;
 			case k9_ContainerThingType:
 			case k10_JunkThingType:
 T0280046:
-				if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
-					L0801_ui_SlotIndex = k10_ChampionSlotNeck;
+				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) {
+					slotIndex_Green = k10_ChampionSlotNeck;
 				} else {
-					L0801_ui_SlotIndex = AL0794_ui_SlotIndex++;
+					slotIndex_Green = AL_0_slotIndex_Red++;
 				}
+				break;
+
+			default:
+				break;
 			}
 T0280048:
-			if (L0797_ps_Champion->_slots[L0801_ui_SlotIndex] != Thing::_none) {
+			if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_none) {
 				goto T0280046;
 			}
-			_vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0799_ui_PreviousPartyChampionCount, L0793_T_Thing, (ChampionSlot)L0801_ui_SlotIndex);
+			f301_addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green);
 		}
-		L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing);
+		thing = dunMan.f159_getNextThing(thing);
 	}
-	_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)L0799_ui_PreviousPartyChampionCount);
-	_vm->_menuMan->f456_drawDisabledMenu();;
+
+	_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)prevChampCount);
+	_vm->_menuMan->f456_drawDisabledMenu();
 }
 
 void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
@@ -1466,7 +1445,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 
 
 	L0868_i_ChampionStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
-	L0865_ps_Champion = &_gK71_champions[champIndex];
+	L0865_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
 	L0862_ui_ChampionAttributes = L0865_ps_Champion->_attributes;
 	if (!getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand)) {
 		return;
@@ -1483,13 +1462,13 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 			for (uint16 i = 0; i < 3; ++i)
 				L0872_ai_NativeBitmapIndices[i] = 0;
 			AL0864_i_BorderCount = 0;
-			if (_g407_party._fireShieldDefense > 0) {
+			if (_vm->_championMan->_g407_party._fireShieldDefense > 0) {
 				L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k38_BorderPartyFireshieldIndice;
 			}
-			if (_g407_party._spellShieldDefense > 0) {
+			if (_vm->_championMan->_g407_party._spellShieldDefense > 0) {
 				L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k39_BorderPartySpellshieldIndice;
 			}
-			if ((_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) {
+			if ((_vm->_championMan->_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) {
 				L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k37_BorderPartyShieldIndice;
 			}
 			while (AL0864_i_BorderCount--) {
@@ -1511,7 +1490,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 	if (!(L0865_ps_Champion->_currHealth))
 		goto T0292042;
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle)) {
-		AL0864_i_ColorIndex = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
+		AL0864_i_ColorIndex = (champIndex == _vm->_championMan->_g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
 		if (L0863_B_IsInventoryChampion) {
 			_vm->_textMan->f52_printToViewport(3, 7, (Color)AL0864_i_ColorIndex, L0866_pc_ChampionName = L0865_ps_Champion->_name);
 			L0869_i_ChampionTitleX = 6 * strlen(L0866_pc_ChampionName) + 3;
@@ -1530,9 +1509,9 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		}
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics)) {
-		f287_drawChampionBarGraphs(champIndex);
+		_vm->_championMan->f287_drawChampionBarGraphs(champIndex);
 		if (L0863_B_IsInventoryChampion) {
-			f290_drawHealthStaminaManaValues(L0865_ps_Champion);
+			_vm->_championMan->f290_drawHealthStaminaManaValues(L0865_ps_Champion);
 			if ((L0865_ps_Champion->_food < 0) || (L0865_ps_Champion->_water < 0) || (L0865_ps_Champion->_poisonEventCount)) {
 				AL0870_i_NativeBitmapIndex = k34_SlotBoxWoundedIndice;
 			} else {
@@ -1552,14 +1531,14 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x2000_ChampionAttributeWounds)) {
 		for (AL0864_i_SlotIndex = L0863_B_IsInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL0864_i_SlotIndex >= k0_ChampionSlotReadyHand; AL0864_i_SlotIndex--) {
-			f291_drawSlot(champIndex, AL0864_i_SlotIndex);
+			_vm->_championMan->f291_drawSlot(champIndex, AL0864_i_SlotIndex);
 		}
 		if (L0863_B_IsInventoryChampion) {
 			setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
 		}
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0200_ChampionAttributeLoad) && L0863_B_IsInventoryChampion) {
-		if (L0865_ps_Champion->_load > (AL0864_i_Load = f309_getMaximumLoad(L0865_ps_Champion))) {
+		if (L0865_ps_Champion->_load > (AL0864_i_Load = _vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion))) {
 			AL0870_i_Color = k8_ColorRed;
 		} else {
 			if (((long)L0865_ps_Champion->_load << 3) > ((long)AL0864_i_Load * 5)) {
@@ -1570,28 +1549,28 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		}
 		_vm->_textMan->f52_printToViewport(104, 132, (Color)AL0870_i_Color, "LOAD ");
 		AL0864_i_Load = L0865_ps_Champion->_load / 10;
-		strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
+		strcpy(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
 		strcat(_vm->_g353_stringBuildBuffer, ".");
 		AL0864_i_Load = L0865_ps_Champion->_load - (AL0864_i_Load * 10);
-		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str());
+		strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str());
 		strcat(_vm->_g353_stringBuildBuffer, "/");
-		AL0864_i_Load = (f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10;
-		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
+		AL0864_i_Load = (_vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10;
+		strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
 		strcat(_vm->_g353_stringBuildBuffer, " KG");
 		_vm->_textMan->f52_printToViewport(148, 132, (Color)AL0870_i_Color, _vm->_g353_stringBuildBuffer);
 		setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
 	}
-	AL0864_i_ChampionIconIndex = M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir);
+	AL0864_i_ChampionIconIndex = _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir);
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL0864_i_ChampionIconIndex))) {
 		_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], g46_ChampionColor[champIndex]);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0800_ChampionAttributePanel) && L0863_B_IsInventoryChampion) {
 		if (_vm->_g333_pressingMouth) {
 			_vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned();
 		} else {
 			if (_vm->_g331_pressingEye) {
-				if (_g415_leaderEmptyHanded) {
+				if (_vm->_championMan->_g415_leaderEmptyHanded) {
 					_vm->_inventoryMan->f351_drawChampionSkillsAndStatistics();
 				}
 			} else {
@@ -1601,7 +1580,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x8000_ChampionAttributeActionHand)) {
-		f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
+		_vm->_championMan->f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
 		_vm->_menuMan->f386_drawActionIcon(champIndex);
 		if (L0863_B_IsInventoryChampion) {
 			setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);


Commit: dce7465ad53fcf3179b47099e873b7d2b858b1d1
    https://github.com/scummvm/scummvm/commit/dce7465ad53fcf3179b47099e873b7d2b858b1d1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Silent some more CppCheck warnings

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/group.h
    engines/dm/projexpl.h
    engines/dm/timeline.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 8a49d95..3b009c2 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -419,6 +419,8 @@ DungeonMan::~DungeonMan() {
 	delete[] _g260_dungeonTextData;
 	delete[] _g279_dungeonMapData;
 	for (uint16 i = 0; i < 16; ++i) {
+		if (_g284_thingData[i])
+			delete[] _g284_thingData[i][0];
 		delete[] _g284_thingData[i];
 	}
 }
@@ -651,34 +653,34 @@ void DungeonMan::f434_loadDungeonFile() {
 			continue;
 
 		if (_g284_thingData[thingType]) {
+			delete[] _g284_thingData[thingType][0];
 			delete[] _g284_thingData[thingType];
 		}
-		_g284_thingData[thingType] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount];
+		_g284_thingData[thingType] = new uint16*[_g278_dungeonFileHeader._thingCounts[thingType]];
+		_g284_thingData[thingType][0] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount];
+		for (uint16 i = 0; i < _g278_dungeonFileHeader._thingCounts[thingType]; ++i)
+			_g284_thingData[thingType][i] = _g284_thingData[thingType][0] + i * thingStoreWordCount;
 
 		if (thingType == k4_GroupThingType) {
-			for (uint16 i = 0; i < thingCount; ++i) {
-				uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount;
+			for (uint16 i = 0; i < thingCount; ++i)
 				for (uint16 j = 0; j < thingStoreWordCount; ++j) {
 					if (j == 2 || j == 3)
-						nextSlot[j] = dunDataStream.readByte();
+						_g284_thingData[thingType][i][j] = dunDataStream.readByte();
 					else
-						nextSlot[j] = dunDataStream.readUint16BE();
+						_g284_thingData[thingType][i][j] = dunDataStream.readUint16BE();
 				}
-			}
 		} else if (thingType == k14_ProjectileThingType) {
 			for (uint16 i = 0; i < thingCount; ++i) {
-				uint16 *nextSlot = _g284_thingData[thingType] + i * thingStoreWordCount;
-				nextSlot[0] = dunDataStream.readUint16BE();
-				nextSlot[1] = dunDataStream.readUint16BE();
-				nextSlot[2] = dunDataStream.readByte();
-				nextSlot[3] = dunDataStream.readByte();
-				nextSlot[4] = dunDataStream.readUint16BE();
+				_g284_thingData[thingType][i][0] = dunDataStream.readUint16BE();
+				_g284_thingData[thingType][i][1] = dunDataStream.readUint16BE();
+				_g284_thingData[thingType][i][2] = dunDataStream.readByte();
+				_g284_thingData[thingType][i][3] = dunDataStream.readByte();
+				_g284_thingData[thingType][i][4] = dunDataStream.readUint16BE();
 			}
 		} else {
 			for (uint16 i = 0; i < thingCount; ++i) {
-				uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount;
 				for (uint16 j = 0; j < thingStoreWordCount; ++j)
-					nextSlot[j] = dunDataStream.readUint16BE();
+					_g284_thingData[thingType][i][j] = dunDataStream.readUint16BE();
 			}
 		}
 
@@ -686,7 +688,7 @@ void DungeonMan::f434_loadDungeonFile() {
 			if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType)
 				_vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType];
 			for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) {
-				(_g284_thingData[thingType] + (thingCount + i) * thingStoreWordCount)[0] = Thing::_none.toUint16();
+				_g284_thingData[thingType][thingCount + i][0] = Thing::_none.toUint16();
 			}
 		}
 	}
@@ -755,36 +757,33 @@ void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) {
 
 
 Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) {
-	int16 L0248_i_Multiple;
-#define AL0248_B_IsMapXInBounds L0248_i_Multiple
-#define AL0248_i_SquareType     L0248_i_Multiple
-	int16 L0249_i_Multiple;
-#define AL0249_B_IsMapYInBounds L0249_i_Multiple
-#define AL0249_i_SquareType     L0249_i_Multiple
-
-	AL0249_B_IsMapYInBounds = (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight);
-	if ((AL0248_B_IsMapXInBounds = (mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth)) && AL0249_B_IsMapYInBounds) {
-		return Square(_vm->_dungeonMan->_g271_currMapData[mapX][mapY]);
+	bool isInXBounds = (mapX >= 0) && (mapX < _g273_currMapWidth);
+	bool isInYBounds = (mapY >= 0) && (mapY < _g274_currMapHeight);
+
+	if (isInXBounds && isInYBounds)
+		return Square(_g271_currMapData[mapX][mapY]);
+
+
+	Square tmpSquare;
+	if (isInYBounds) {
+		tmpSquare.set(_g271_currMapData[0][mapY]);
+		if (mapX == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
+			return Square(k0_WallElemType).set(k0x0004_WallEastRandOrnAllowed);
+
+		tmpSquare.set(_g271_currMapData[_g273_currMapWidth - 1][mapY]);
+		if (mapX == _g273_currMapWidth && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
+			return Square(k0_WallElemType).set(k0x0001_WallWestRandOrnAllowed);
+	} else if (isInXBounds) {
+		tmpSquare.set(_g271_currMapData[mapX][0]);
+		if (mapY == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
+			return Square(k0_WallElemType).set(k0x0002_WallSouthRandOrnAllowed);
+
+		tmpSquare.set(_g271_currMapData[mapX][_g274_currMapHeight - 1]);
+		if (mapY == _g274_currMapHeight && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
+			return Square((k0_WallElemType << 5) | k0x0008_WallNorthRandOrnAllowed);
 	}
 
-	if (AL0249_B_IsMapYInBounds) {
-		if (((mapX == -1) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[0][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) {
-			return Square(k0_ElementTypeWall, k0x0004_WallEastRandOrnAllowed);
-		}
-		if (((mapX == _vm->_dungeonMan->_g273_currMapWidth) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[_vm->_dungeonMan->_g273_currMapWidth - 1][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) {
-			return Square(k0_ElementTypeWall, k0x0001_WallWestRandOrnAllowed);
-		}
-	} else {
-		if (AL0248_B_IsMapXInBounds) {
-			if (((mapY == -1) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][0]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) {
-				return Square(k0_ElementTypeWall, k0x0002_WallSouthRandOrnAllowed);
-			}
-			if (((mapY == _vm->_dungeonMan->_g274_currMapHeight) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][_vm->_dungeonMan->_g274_currMapHeight - 1]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) {
-				return Square(k0_ElementTypeWall, k0x0008_WallNorthRandOrnAllowed);
-			}
-		}
-	}
-	return Square(k0_ElementTypeWall, 0);
+	return Square(k0_WallElemType);
 }
 
 Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
@@ -793,23 +792,17 @@ Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 st
 }
 
 int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) {
-	uint16 L0260_ui_ThingIndex;
-	int16 L0261_i_MapY;
-	register unsigned char* L0262_puc_Square;
+	if (mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight || !Square(_g271_currMapData[mapX][mapY]).get(k0x0010_ThingListPresent))
+		return -1;
 
+	int16 y = 0;
+	uint16 index = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
+	byte* square = _g271_currMapData[mapX];
+	while (y++ != mapY)
+		if (Square(*square++).get(k0x0010_ThingListPresent))
+			index++;
 
-	L0262_puc_Square = _vm->_dungeonMan->_g271_currMapData[mapX];
-	if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight) || !getFlag(L0262_puc_Square[mapY], k0x0010_ThingListPresent)) {
-		return -1;
-	}
-	L0261_i_MapY = 0;
-	L0260_ui_ThingIndex = _vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount[mapX];
-	while (L0261_i_MapY++ != mapY) {
-		if (getFlag(*L0262_puc_Square++, k0x0010_ThingListPresent)) {
-			L0260_ui_ThingIndex++;
-		}
-	}
-	return L0260_ui_ThingIndex;
+	return index;
 }
 
 Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) {
@@ -966,33 +959,31 @@ T0172049_Footprints:
 	aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16();
 }
 
-void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir,
+void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
 												 int16 mapX, int16 mapY, bool isFakeWall) {
-	int16 L0306_i_Multiple;
-#define AL0306_i_RandomWallOrnamentCount L0306_i_Multiple
-#define AL0306_i_SideIndex               L0306_i_Multiple
-
-
-	AL0306_i_RandomWallOrnamentCount = _vm->_dungeonMan->_g269_currMap->_randWallOrnCount;
-	aspectArray[k2_RightWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(leftAllowed, AL0306_i_RandomWallOrnamentCount, mapX, ++mapY * (M21_normalizeModulo4(++dir) + 1), 30);
-	aspectArray[k3_FrontWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(frontAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY * (M21_normalizeModulo4(++dir) + 1), 30);
-	aspectArray[k4_LeftWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(rightAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY-- * (M21_normalizeModulo4(++dir) + 1), 30);
-	if (isFakeWall || (mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight)) { /* If square is a fake wall or is out of map bounds */
-		for (AL0306_i_SideIndex = k2_RightWallOrnOrdAspect; AL0306_i_SideIndex <= k4_LeftWallOrnOrdAspect; AL0306_i_SideIndex++) { /* Loop to remove any random ornament that is an alcove */
-			if (_vm->_dungeonMan->f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[AL0306_i_SideIndex]))) {
-				aspectArray[AL0306_i_SideIndex] = 0;
-			}
+	int16 ornCount = _g269_currMap->_randWallOrnCount;
+
+	turnDirRight(dir);
+	aspectArray[k2_RightWallOrnOrdAspect] = f170_getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
+	turnDirRight(dir);
+	aspectArray[k3_FrontWallOrnOrdAspect] = f170_getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
+	turnDirRight(dir);
+	aspectArray[k4_LeftWallOrnOrdAspect] = f170_getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
+
+	if (isFakeWall || mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight) {
+		for (uint16 i = k2_RightWallOrnOrdAspect; i <= k4_LeftWallOrnOrdAspect; ++i) {
+			if (f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[i])))
+				aspectArray[i] = 0;
 		}
 	}
 }
 
 int16 DungeonMan::f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) {
-	int16 L0305_i_RandomOrnamentIndex;
-
-
-	if (allowed && ((L0305_i_RandomOrnamentIndex = f169_getRandomOrnamentIndex((int16)2000 + (mapX << 5) + mapY, (int16)3000 + (_vm->_dungeonMan->_g272_currMapIndex << (int16)6) + _vm->_dungeonMan->_g273_currMapWidth + _vm->_dungeonMan->_g274_currMapHeight, modulo)) < count)) {
-		return _vm->M0_indexToOrdinal(L0305_i_RandomOrnamentIndex);
-	}
+	int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1)
+					+ (3000 + (_g272_currMapIndex << 6) + _g273_currMapWidth + _g274_currMapHeight) * 11
+					+ _g278_dungeonFileHeader._ornamentRandomSeed) >> 2) % modulo;
+	if (allowed && index < count)
+		return _vm->M0_indexToOrdinal(index);
 	return 0;
 }
 
@@ -1006,7 +997,7 @@ bool DungeonMan::f149_isWallOrnAnAlcove(int16 wallOrnIndex) {
 }
 
 uint16 *DungeonMan::f156_getThingData(Thing thing) {
-	return _g284_thingData[thing.getType()] + thing.getIndex() * g235_ThingDataWordCount[thing.getType()];
+	return _g284_thingData[thing.getType()][thing.getIndex()];
 }
 
 uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) {
@@ -1014,7 +1005,7 @@ uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) {
 }
 
 Thing DungeonMan::f159_getNextThing(Thing thing) {
-	return Thing(f156_getThingData(thing)[0]);
+	return Thing(f156_getThingData(thing)[0]); // :)
 }
 
 char g255_MessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings
@@ -1119,10 +1110,10 @@ char g257_InscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_
 
 
 void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) {
-	char sepChar;
-	TextString textString(_g284_thingData[k2_TextstringType] + thing.getIndex() * g235_ThingDataWordCount[k2_TextstringType]);
+	TextString textString(_g284_thingData[k2_TextstringType][thing.getIndex()]);
 	if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) {
 		type = (TextType)(type & ~k0x8000_DecodeEvenIfInvisible);
+		char sepChar;
 		if (type == k1_TextTypeMessage) {
 			*destString++ = '\n';
 			sepChar = ' ';
@@ -1313,56 +1304,46 @@ int16 DungeonMan::f141_getObjectInfoIndex(Thing thing) {
 }
 
 void DungeonMan::f163_linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) {
-	Thing L0265_T_Thing;
-	uint16 L0266_ui_Multiple;
-#define AL0266_ui_Column                L0266_ui_Multiple
-#define AL0266_ui_SquareFirstThingIndex L0266_ui_Multiple
-	Thing* L0267_pT_Thing;
-	byte* L0268_puc_Square;
-	Thing* L0269_ps_Generic;
-	uint16 L0270_ui_MapY;
+	if (thingToLink == Thing::_endOfList)
+		return;
 
+	uint16 *rawObjPtr = f156_getThingData(thingToLink);
+	*rawObjPtr = Thing::_endOfList.toUint16();
 
-	if (thingToLink == Thing::_endOfList) {
-		return;
-	}
-	L0269_ps_Generic = (Thing*)f156_getThingData(thingToLink);
-	*L0269_ps_Generic = Thing::_endOfList;
-	/* If mapX >= 0 then the thing is linked to the list of things on the specified square else it is linked at the end of the specified thing list */
 	if (mapX >= 0) {
-		L0268_puc_Square = &_g271_currMapData[mapX][mapY];
-		if (getFlag(*L0268_puc_Square, k0x0010_ThingListPresent)) {
+		Square *squarePtr = (Square*)&_g271_currMapData[mapX][mapY];
+		if (squarePtr->get(k0x0010_ThingListPresent)) {
 			thingInList = f161_getSquareFirstThing(mapX, mapY);
 		} else {
-			setFlag(*L0268_puc_Square, k0x0010_ThingListPresent);
-			uint16 * tmp = _g270_currMapColCumulativeSquareFirstThingCount + mapX + 1;
-			AL0266_ui_Column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1;
-			while (AL0266_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is added */
-				(*tmp++)++; /* Increment the cumulative first thing count */
+			squarePtr->set(k0x0010_ThingListPresent);
+			uint16 *cumulativeCount = &_g270_currMapColCumulativeSquareFirstThingCount[mapX + 1];
+			uint16 column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1;
+			while (column--) {
+				(*cumulativeCount++)++;
 			}
-			L0270_ui_MapY = 0;
-			L0268_puc_Square -= mapY;
-			AL0266_ui_SquareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
-			while (L0270_ui_MapY++ != mapY) {
-				if (getFlag(*L0268_puc_Square++, k0x0010_ThingListPresent)) {
-					AL0266_ui_SquareFirstThingIndex++;
+			uint16 mapYStep = 0;
+			squarePtr -= mapY;
+			uint16 squareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
+			while (mapYStep++ != mapY) {
+				if (squarePtr->get(k0x0010_ThingListPresent)) {
+					squareFirstThingIndex++;
 				}
+				squarePtr++;
 			}
-			L0267_pT_Thing = &_g283_squareFirstThings[AL0266_ui_SquareFirstThingIndex];
-			// the second '- 1' is for the loop initialization, > 0 is because we are copying from one behind
-			for (int16 i = _g278_dungeonFileHeader._squareFirstThingCount - AL0266_ui_SquareFirstThingIndex - 1 - 1; i > 0; --i)
-				L0267_pT_Thing[i] = L0267_pT_Thing[i - 1];
-
-			*L0267_pT_Thing = thingToLink;
+			Thing* thingPtr = &_g283_squareFirstThings[squareFirstThingIndex];
+			memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_g278_dungeonFileHeader._squareFirstThingCount - squareFirstThingIndex - 1));
+			*thingPtr = thingToLink;
 			return;
 		}
 	}
-	L0265_T_Thing = f159_getNextThing(thingInList);
-	while (L0265_T_Thing != Thing::_endOfList) {
-		L0265_T_Thing = f159_getNextThing(thingInList = L0265_T_Thing);
+
+	Thing thing = f159_getNextThing(thingInList);
+	while (thing != Thing::_endOfList) {
+		thing = f159_getNextThing(thing);
+		thingInList = thing;
 	}
-	L0269_ps_Generic = (Thing*)f156_getThingData(thingInList);
-	*L0269_ps_Generic = thingToLink;
+	rawObjPtr = f156_getThingData(thingInList);
+	*rawObjPtr = thingToLink.toUint16();
 }
 
 WeaponInfo* DungeonMan::f158_getWeaponInfo(Thing thing) {
@@ -1714,10 +1695,4 @@ Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {
 	}
 	return L0295_T_Thing;
 }
-
-int16 DungeonMan::f169_getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo) {
-	return ((((((val1 * 31417) & 0xFFFF) >> 1) + ((val2 * 11) & 0xFFFF)
-			  + _vm->_dungeonMan->_g278_dungeonFileHeader._ornamentRandomSeed) & 0xFFFF) >> 2) % modulo; /* Pseudorandom number generator */
-}
-
 }
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 86b30d5..204a296 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -305,6 +305,10 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 	_g326_refreshMousePointerInMainLoop = false;
 	_g341_highlightBoxEnabled = false;
 	_g599_useChampionIconOrdinalAsMousePointerBitmap = 0;
+	_g439_pendingClickButton = k0_NoneMouseButton;
+	_g600_useObjectAsMousePointerBitmap = false;
+	_g601_useHandAsMousePointerBitmap = false;
+	_gK100_preventBuildPointerScreenArea = false;
 }
 
 EventManager::~EventManager() {
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index a6dd087..e90b3a3 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1009,16 +1009,13 @@ void DisplayMan::f103_drawDoorFrameBitmapFlippedHorizontally(byte* bitmap, Frame
 }
 
 void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButtonIndex) {
-	int16 nativeBitmapIndex;
-	int coordSet;
-	uint16* coordSetRedEagle;
-	byte* bitmap;
-	byte* bitmapNative;
-
 	if (doorButtonOrdinal) {
 		doorButtonOrdinal--;
-		nativeBitmapIndex = doorButtonOrdinal + k315_firstDoorButton_GraphicIndice;
-		coordSetRedEagle = g208_doorButtonCoordSets[coordSet = g197_doorButtonCoordSet[doorButtonOrdinal]][viewDoorButtonIndex];
+		int16 nativeBitmapIndex = doorButtonOrdinal + k315_firstDoorButton_GraphicIndice;
+		int coordSet = g197_doorButtonCoordSet[doorButtonOrdinal];
+		uint16 *coordSetRedEagle = g208_doorButtonCoordSets[coordSet][viewDoorButtonIndex];
+
+		byte* bitmap = nullptr;
 		if (viewDoorButtonIndex == k3_viewDoorButton_D1C) {
 			bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
 
@@ -1028,8 +1025,8 @@ void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButt
 			_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordSetRedEagle[3];
 		} else {
 			if (!f491_isDerivedBitmapInCache(doorButtonOrdinal = k102_DerivedBitmapFirstDoorButton + (doorButtonOrdinal * 2) + ((!viewDoorButtonIndex) ? 0 : viewDoorButtonIndex - 1))) {
-				uint16* coordSetBlueGoat = g208_doorButtonCoordSets[coordSet][k3_viewDoorButton_D1C];
-				bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+				uint16 *coordSetBlueGoat = g208_doorButtonCoordSets[coordSet][k3_viewDoorButton_D1C];
+				byte *bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
 				f129_blitToBitmapShrinkWithPalChange(bitmapNative, f492_getDerivedBitmap(doorButtonOrdinal),
 													 coordSetBlueGoat[4] << 1, coordSetBlueGoat[5],
 													 coordSetRedEagle[1] - coordSetRedEagle[0] + 1,
@@ -1383,18 +1380,13 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn
 
 #define height doorOrnOrdinal
 #define byteWidth viewDoorOrnIndex
-	int16 nativeBitmapIndex;
-	int16 coordSetGreenToad;
-	uint16* coordSetOrangeElk;
-	byte* L0107_puc_Multiple;
-#define bitmap        L0107_puc_Multiple
-	byte* bitmapNative;
-
 
 	if (doorOrnOrdinal) {
 		doorOrnOrdinal--;
-		nativeBitmapIndex = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex];
-		coordSetOrangeElk = g207_doorOrnCoordSets[coordSetGreenToad = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]][viewDoorOrnIndex];
+		int16 nativeBitmapIndex = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex];
+		int16 coordSetGreenToad = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet];
+		uint16 *coordSetOrangeElk = g207_doorOrnCoordSets[coordSetGreenToad][viewDoorOrnIndex];
+		byte *bitmap = nullptr;
 		if (viewDoorOrnIndex == k2_ViewDoorOrnament_D1LCR) {
 			bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
 			byteWidth = 48;
@@ -1402,7 +1394,7 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn
 		} else {
 			if (!f491_isDerivedBitmapInCache(doorOrnOrdinal = k68_DerivedBitmapFirstDoorOrnament_D3 + (doorOrnOrdinal * 2) + viewDoorOrnIndex)) {
 				uint16 *coordSetRedEagle = g207_doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR];
-				bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+				byte* bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
 				f129_blitToBitmapShrinkWithPalChange(bitmapNative,
 													 f492_getDerivedBitmap(doorOrnOrdinal),
 													 coordSetRedEagle[4] << 1, coordSetRedEagle[5],
diff --git a/engines/dm/group.h b/engines/dm/group.h
index f9aa038..ca7cb52 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -175,7 +175,7 @@ public:
 	uint16 _g376_maxActiveGroupCount; // @ G0376_ui_MaximumActiveGroupCount
 	ActiveGroup *_g375_activeGroups; // @ G0375_ps_ActiveGroups
 	uint16 _g377_currActiveGroupCount; // @ G0377_ui_CurrentActiveGroupCount
-	GroupMan(DMEngine *vm);
+	explicit GroupMan(DMEngine *vm);
 	~GroupMan();
 
 	void f196_initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups
diff --git a/engines/dm/projexpl.h b/engines/dm/projexpl.h
index 15f7454..32829f1 100644
--- a/engines/dm/projexpl.h
+++ b/engines/dm/projexpl.h
@@ -83,7 +83,7 @@ public:
 	int16 _g366_projectilePoisonAttack; // @ G0366_i_ProjectilePoisonAttack
 	int16 _g367_projectileAttackType; // @ G0367_i_ProjectileAttackType
 	int32 _g362_lastPartyMovementTime; // @ G0362_l_LastPartyMovementTime
-	ProjExpl(DMEngine *vm);
+	explicit ProjExpl(DMEngine *vm);
 	void f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, direction dir,
 							   byte kineticEnergy, byte attack, byte stepEnergy); // @ F0212_PROJECTILE_Create
 	bool f217_projectileHasImpactOccurred(int16 impactType, int16 mapXCombo, int16 mapYCombo,
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 5cf3f85..b77c0d1 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -151,7 +151,7 @@ public:
 	uint16 *_g371_timeline; // @ G0371_pui_Timeline
 	uint16 _g373_firstUnusedEventIndex; // @ G0373_ui_FirstUnusedEventIndex
 
-	Timeline(DMEngine *vm);
+	explicit Timeline(DMEngine *vm);
 	~Timeline();
 	void f233_initTimeline(); // @ F0233_TIMELINE_Initialize
 	void f237_deleteEvent(uint16 eventIndex);// @ F0237_TIMELINE_DeleteEvent


Commit: 2edabfae994014bcc27fb6f45760b5f67175ba6e
    https://github.com/scummvm/scummvm/commit/2edabfae994014bcc27fb6f45760b5f67175ba6e
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some rework in group.cpp

Changed paths:
    engines/dm/group.cpp



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index f12ef8e..f2b2fda 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -38,7 +38,7 @@ int32 M32_setTime(int32 &map_time, int32 time) {
 	return map_time = (map_time & 0xFF000000) | time;
 }
 
-GroupMan::GroupMan(DMEngine* vm) : _vm(vm) {
+GroupMan::GroupMan(DMEngine *vm) : _vm(vm) {
 	for (uint16 i = 0; i < 4; ++i)
 		_g392_dropMovingCreatureFixedPossessionsCell[i] = 0;
 	_g391_dropMovingCreatureFixedPossCellCount = 0;
@@ -76,7 +76,7 @@ void GroupMan::f196_initActiveGroups() {
 		_g375_activeGroups[i]._groupThingIndex = -1;
 }
 
-uint16 GroupMan::f145_getGroupCells(Group* group, int16 mapIndex) {
+uint16 GroupMan::f145_getGroupCells(Group *group, int16 mapIndex) {
 	byte cells;
 	cells = group->_cells;
 	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex)
@@ -86,14 +86,14 @@ uint16 GroupMan::f145_getGroupCells(Group* group, int16 mapIndex) {
 
 byte gGroupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_GroupDirections
 
-uint16 GroupMan::f147_getGroupDirections(Group* group, int16 mapIndex) {
+uint16 GroupMan::f147_getGroupDirections(Group *group, int16 mapIndex) {
 	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex)
 		return _g375_activeGroups[group->getActiveGroupIndex()]._directions;
 
 	return gGroupDirections[group->getDir()];
 }
 
-int16 GroupMan::f176_getCreatureOrdinalInCell(Group* group, uint16 cell) {
+int16 GroupMan::f176_getCreatureOrdinalInCell(Group *group, uint16 cell) {
 	uint16 currMapIndex = _vm->_dungeonMan->_g272_currMapIndex;
 	byte groupCells = f145_getGroupCells(group, currMapIndex);
 	if (groupCells == k255_CreatureTypeSingleCenteredCreature)
@@ -123,25 +123,19 @@ uint16 GroupMan::M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex) {
 }
 
 void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode) {
-	Thing L0365_T_CurrentThing;
-	Thing L0366_T_NextThing;
-	Group* L0367_ps_Group;
-	uint16 L0368_ui_CreatureType;
-	int16 L0369_i_CreatureIndex;
-	uint16 L0370_ui_GroupCells;
-	bool L0371_B_WeaponDropped;
-
-
-	L0367_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(groupThing);
-	if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[L0368_ui_CreatureType = L0367_ps_Group->_type]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
-		L0369_i_CreatureIndex = L0367_ps_Group->getCount();
-		L0370_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(L0367_ps_Group, _vm->_dungeonMan->_g272_currMapIndex);
+	Group *L0367_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(groupThing);
+	uint16 L0368_ui_CreatureType = L0367_ps_Group->_type;
+	if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[L0368_ui_CreatureType]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
+		int16 L0369_i_CreatureIndex = L0367_ps_Group->getCount();
+		uint16 L0370_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(L0367_ps_Group, _vm->_dungeonMan->_g272_currMapIndex);
 		do {
 			_vm->_groupMan->f186_dropCreatureFixedPossessions(L0368_ui_CreatureType, mapX, mapY, (L0370_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0370_ui_GroupCells, L0369_i_CreatureIndex), mode);
 		} while (L0369_i_CreatureIndex--);
 	}
-	if ((L0365_T_CurrentThing = L0367_ps_Group->_slot) != Thing::_endOfList) {
-		L0371_B_WeaponDropped = false;
+	Thing L0365_T_CurrentThing = L0367_ps_Group->_slot;
+	if ((L0365_T_CurrentThing) != Thing::_endOfList) {
+		bool L0371_B_WeaponDropped = false;
+		Thing L0366_T_NextThing;
 		do {
 			L0366_T_NextThing = _vm->_dungeonMan->f159_getNextThing(L0365_T_CurrentThing);
 			L0365_T_CurrentThing = M15_thingWithNewCell(L0365_T_CurrentThing, _vm->getRandomNumber(4));
@@ -198,17 +192,9 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX
 		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop,
 		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop, 0};
 
-	uint16 L0356_ui_FixedPossession;
-	int16 L0357_i_ThingType;
-	Thing L0358_T_Thing;
-	uint16* L0359_pui_FixedPossessions;
-	Weapon* L0360_ps_Weapon;
-	bool L0361_B_Cursed;
-	bool L0362_B_WeaponDropped;
-
+	uint16 *L0359_pui_FixedPossessions;
 
-	L0361_B_Cursed = false;
-	L0362_B_WeaponDropped = false;
+	bool L0361_B_Cursed = false;
 	switch (creatureType) {
 	default:
 		return;
@@ -240,9 +226,12 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX
 	case k24_CreatureTypeRedDragon:
 		L0359_pui_FixedPossessions = g253FixedPossessionCreature_24RedDragon;
 	}
+	uint16 L0356_ui_FixedPossession;
 	while (L0356_ui_FixedPossession = *L0359_pui_FixedPossessions++) {
 		if (getFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) && _vm->getRandomNumber(2))
 			continue;
+		int16 L0357_i_ThingType;
+		bool L0362_B_WeaponDropped = false;
 		if (clearFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) >= k127_ObjectInfoIndexFirstJunk) {
 			L0357_i_ThingType = k10_JunkThingType;
 			L0356_ui_FixedPossession -= k127_ObjectInfoIndexFirstJunk;
@@ -256,10 +245,11 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX
 				L0356_ui_FixedPossession -= k23_ObjectInfoIndexFirstWeapon;
 			}
 		}
-		if ((L0358_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(L0357_i_ThingType)) == Thing::_none) {
+		Thing L0358_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(L0357_i_ThingType);
+		if ((L0358_T_Thing) == Thing::_none)
 			continue;
-		}
-		L0360_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0358_T_Thing);
+
+		Weapon *L0360_ps_Weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(L0358_T_Thing);
 /* The same pointer type is used no matter the actual type k5_WeaponThingType, k6_ArmourThingType or k10_JunkThingType */
 		L0360_ps_Weapon->setType(L0356_ui_FixedPossession);
 		L0360_ps_Weapon->setCursed(L0361_B_Cursed);
@@ -340,18 +330,15 @@ bool GroupMan::f227_isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 src
 }
 
 bool GroupMan::f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack, bool magicAttack, int16 ticks) {
-	Door* L0573_ps_Door;
-	byte* L0574_puc_Square;
-	TimelineEvent L0575_s_Event;
-
-	L0573_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY);
+	Door *L0573_ps_Door = (Door *)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY);
 	if ((magicAttack && !L0573_ps_Door->isMagicDestructible()) || (!magicAttack && !L0573_ps_Door->isMeleeDestructible())) {
 		return false;
 	}
 	if (attack >= _vm->_dungeonMan->_g275_currMapDoorInfo[L0573_ps_Door->getType()]._defense) {
-		L0574_puc_Square = &_vm->_dungeonMan->_g271_currMapData[mapX][mapY];
+		byte *L0574_puc_Square = &_vm->_dungeonMan->_g271_currMapData[mapX][mapY];
 		if (Square(*L0574_puc_Square).getDoorState() == k4_doorState_CLOSED) {
 			if (ticks) {
+				TimelineEvent L0575_s_Event;
 				M33_setMapAndTime(L0575_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ticks);
 				L0575_s_Event._type = k2_TMEventTypeDoorDestruction;
 				L0575_s_Event._priority = 0;
@@ -359,7 +346,7 @@ bool GroupMan::f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16
 				L0575_s_Event._B._location._mapY = mapY;
 				_vm->_timeline->f238_addEventGetEventIndex(&L0575_s_Event);
 			} else {
-				((Square*)L0574_puc_Square)->setDoorState(k5_doorState_DESTROYED);
+				((Square *)L0574_puc_Square)->setDoorState(k5_doorState_DESTROYED);
 			}
 			return true;
 		}
@@ -377,7 +364,7 @@ Thing GroupMan::f175_groupGetThing(int16 mapX, int16 mapY) {
 	return L0317_T_Thing;
 }
 
-int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group* group, uint16 creatureIndex, int16 mapX, int16 mapY, int16 damage, bool notMoving) {
+int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex, int16 mapX, int16 mapY, int16 damage, bool notMoving) {
 	uint16 L0374_ui_Multiple;
 #define AL0374_ui_EventIndex    L0374_ui_Multiple
 #define AL0374_ui_CreatureIndex L0374_ui_Multiple
@@ -387,9 +374,9 @@ int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group* group, uint16 creature
 #define AL0375_ui_Outcome           L0375_ui_Multiple
 #define AL0375_ui_EventType         L0375_ui_Multiple
 #define AL0375_ui_NextCreatureIndex L0375_ui_Multiple
-	CreatureInfo* L0376_ps_CreatureInfo;
-	TimelineEvent* L0377_ps_Event;
-	ActiveGroup* L0378_ps_ActiveGroup = nullptr;
+	CreatureInfo *L0376_ps_CreatureInfo;
+	TimelineEvent *L0377_ps_Event;
+	ActiveGroup *L0378_ps_ActiveGroup = nullptr;
 	uint16 L0379_ui_CreatureCount;
 	uint16 L0380_ui_Multiple = 0;
 #define AL0380_ui_CreatureType   L0380_ui_Multiple
@@ -489,13 +476,13 @@ T0190024:
 
 void GroupMan::f189_delete(int16 mapX, int16 mapY) {
 	Thing L0372_T_GroupThing;
-	Group* L0373_ps_Group;
+	Group *L0373_ps_Group;
 
 
 	if ((L0372_T_GroupThing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) {
 		return;
 	}
-	L0373_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0372_T_GroupThing);
+	L0373_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0372_T_GroupThing);
 	for (uint16 i = 0; i < 4; ++i)
 		L0373_ps_Group->_health[i] = 0;
 	_vm->_movsens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
@@ -510,7 +497,7 @@ void GroupMan::f189_delete(int16 mapX, int16 mapY) {
 void GroupMan::f181_groupDeleteEvents(int16 mapX, int16 mapY) {
 	int16 L0334_i_EventIndex;
 	uint16 L0335_ui_EventType;
-	TimelineEvent* L0336_ps_Event;
+	TimelineEvent *L0336_ps_Event;
 
 
 	L0336_ps_Event = _vm->_timeline->_g370_events;
@@ -530,7 +517,7 @@ uint16 GroupMan::f178_getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uin
 	return creatreVal | (groupVal & ~(3 << creatreVal));
 }
 
-int16 GroupMan::f191_getDamageAllCreaturesOutcome(Group* group, int16 mapX, int16 mapY, int16 attack, bool notMoving) {
+int16 GroupMan::f191_getDamageAllCreaturesOutcome(Group *group, int16 mapX, int16 mapY, int16 attack, bool notMoving) {
 	uint16 L0385_ui_RandomAttack;
 	int16 L0386_i_CreatureIndex;
 	int16 L0387_i_Outcome;
@@ -572,8 +559,8 @@ int16 GroupMan::f192_groupGetResistanceAdjustedPoisonAttack(uint16 creatreType,
 }
 
 void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks) {
-	Group* L0444_ps_Group;
-	ActiveGroup* L0445_ps_ActiveGroup;
+	Group *L0444_ps_Group;
+	ActiveGroup *L0445_ps_ActiveGroup;
 	int16 L0446_i_Multiple;
 #define AL0446_i_EventType           L0446_i_Multiple
 #define AL0446_i_Direction           L0446_i_Multiple
@@ -623,7 +610,7 @@ void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16
 	if ((L0449_T_GroupThing = _vm->_groupMan->f175_groupGetThing(eventMapX, eventMapY)) == Thing::_endOfList) {
 		goto T0209139_Return;
 	}
-	L0444_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0449_T_GroupThing);
+	L0444_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0449_T_GroupThing);
 	L0448_s_CreatureInfo = g243_CreatureInfo[L0444_ps_Group->_type];
 	/* Update the event */
 	M33_setMapAndTime(L0465_s_NextEvent._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime);
@@ -1067,12 +1054,12 @@ T0209139_Return:
 	;
 }
 
-bool GroupMan::f202_isMovementPossible(CreatureInfo* creatureInfo, int16 mapX, int16 mapY, uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls) {
+bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, int16 mapY, uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls) {
 	int16 L0428_i_MapX;
 	int16 L0429_i_MapY;
 	uint16 L0430_ui_Square = 0;
 	int16 L0431_i_SquareType = 0;
-	Teleporter* L0432_ps_Teleporter;
+	Teleporter *L0432_ps_Teleporter;
 	Thing L0433_T_Thing;
 
 
@@ -1099,8 +1086,8 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo* creatureInfo, int16 mapX, i
 		L0433_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0428_i_MapX, L0429_i_MapY);
 		while (L0433_T_Thing != Thing::_endOfList) {
 			if ((L0433_T_Thing).getType() == k15_ExplosionThingType) {
-				L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(L0433_T_Thing);
-				if (((Explosion*)L0432_ps_Teleporter)->setType(k50_ExplosionType_Fluxcage)) {
+				L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f156_getThingData(L0433_T_Thing);
+				if (((Explosion *)L0432_ps_Teleporter)->setType(k50_ExplosionType_Fluxcage)) {
 					_g385_fluxCages[dir] = true;
 					_g386_fluxCageCount++;
 					_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
@@ -1111,7 +1098,7 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo* creatureInfo, int16 mapX, i
 		}
 	}
 	if ((L0431_i_SquareType == k5_ElementTypeTeleporter) && getFlag(L0430_ui_Square, k0x0008_TeleporterOpen) && (creatureInfo->M59_getWariness() >= 10)) {
-		L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
+		L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
 		if (getFlag(L0432_ps_Teleporter->getScope(), k0x0001_TelepScopeCreatures) && !_vm->_dungeonMan->f139_isCreatureAllowedOnMap(_g380_currGroupThing, L0432_ps_Teleporter->getTargetMapIndex())) {
 			_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
 			return false;
@@ -1121,8 +1108,8 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo* creatureInfo, int16 mapX, i
 		return false;
 	}
 	if (L0431_i_SquareType == k4_DoorElemType) {
-		L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
-		if (((Square(L0430_ui_Square).getDoorState()) > (((Door*)L0432_ps_Teleporter)->opensVertically() ? creatureInfo->M51_height() : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
+		L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
+		if (((Square(L0430_ui_Square).getDoorState()) > (((Door *)L0432_ps_Teleporter)->opensVertically() ? creatureInfo->M51_height() : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
 			_g389_groupMovementBlockedByDoor = true;
 			return false;
 		}
@@ -1135,14 +1122,14 @@ int16 GroupMan::f226_getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int
 		(((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY));
 }
 
-int16 GroupMan::f200_groupGetDistanceToVisibleParty(Group* group, int16 creatureIndex, int16 mapX, int16 mapY) {
+int16 GroupMan::f200_groupGetDistanceToVisibleParty(Group *group, int16 creatureIndex, int16 mapX, int16 mapY) {
 	int16 L0420_i_CreatureDirection;
 	int16 L0421_i_CreatureViewDirectionCount; /* Count of directions to test in L0425_ai_CreatureViewDirections */
 	int16 L0422_i_Multiple;
 #define AL0422_i_Counter    L0422_i_Multiple
 #define AL0422_i_SightRange L0422_i_Multiple
 	uint16 L0423_ui_GroupDirections;
-	CreatureInfo* L0424_ps_CreatureInfo;
+	CreatureInfo *L0424_ps_CreatureInfo;
 	int16 L0425_ai_CreatureViewDirections[4]; /* List of directions to test */
 
 
@@ -1234,30 +1221,28 @@ int16 GroupMan::f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 src
 }
 
 bool GroupMan::f197_isViewPartyBlocked(uint16 mapX, uint16 mapY) {
-	uint16 L0404_ui_Square;
-	int16 L0405_i_SquareType;
-	int16 L0406_i_DoorState;
-	Door* L0407_ps_Door;
-
-	if ((L0405_i_SquareType = Square(L0404_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k4_DoorElemType) {
-		L0407_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY);
-		return (((L0406_i_DoorState = Square(L0404_ui_Square).getDoorState()) == k3_doorState_FOURTH) || (L0406_i_DoorState == k4_doorState_CLOSED)) && !getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[L0407_ps_Door->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough);
+	uint16 L0404_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY];
+	int16 L0405_i_SquareType = Square(L0404_ui_Square).getType();
+	if (L0405_i_SquareType == k4_DoorElemType) {
+		Door *L0407_ps_Door = (Door *)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY);
+		int16 L0406_i_DoorState = Square(L0404_ui_Square).getDoorState();
+		return ((L0406_i_DoorState == k3_doorState_FOURTH) || (L0406_i_DoorState == k4_doorState_CLOSED)) && !getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[L0407_ps_Door->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough);
 	}
 	return (L0405_i_SquareType == k0_ElementTypeWall) || ((L0405_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0404_ui_Square, k0x0004_FakeWallOpen));
 }
 
-int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup* activeGroup, int16 creatureIndex, bool isAttacking) {
+int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 creatureIndex, bool isAttacking) {
 	uint16 L0326_ui_Multiple;
 #define AL0326_ui_Aspect         L0326_ui_Multiple
 #define AL0326_ui_AnimationTicks L0326_ui_Multiple
 	uint16 L0327_ui_CreatureGraphicInfo;
 	int16 L0328_i_Offset;
-	Group* L0329_ps_Group;
+	Group *L0329_ps_Group;
 	bool L0330_B_ProcessGroup;
 	uint16 L0331_ui_CreatureType;
 	uint16 L1635_ui_SoundIndex;
 
-	L0329_ps_Group = &(((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]);
+	L0329_ps_Group = &(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]);
 	L0327_ui_CreatureGraphicInfo = g243_CreatureInfo[L0331_ui_CreatureType = L0329_ps_Group->_type]._graphicInfo;
 	if (L0330_B_ProcessGroup = (creatureIndex < 0)) { /* If the creature index is negative then all creatures in the group are processed */
 		creatureIndex = L0329_ps_Group->getCount();
@@ -1327,10 +1312,10 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup* activeGroup, int16
 	return _vm->_g313_gameTime + (isAttacking ? ((AL0326_ui_AnimationTicks >> 8) & 0xF) : ((AL0326_ui_AnimationTicks >> 4) & 0xF)) + _vm->getRandomNumber(2);
 }
 
-void GroupMan::f205_setDirection(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) {
+void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) {
 	uint16 L0435_ui_GroupDirections;
 	static long G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime; /* These two variables are used to prevent setting direction of half square sized creatures twice at the same game time */
-	static ActiveGroup* G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup;
+	static ActiveGroup *G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup;
 
 
 	warning("potentially dangerous cast to uint32 below");
@@ -1350,7 +1335,7 @@ void GroupMan::f205_setDirection(ActiveGroup* activeGroup, int16 dir, int16 crea
 	activeGroup->_directions = (direction)L0435_ui_GroupDirections;
 }
 
-void GroupMan::f208_groupAddEvent(TimelineEvent* event, uint32 time) {
+void GroupMan::f208_groupAddEvent(TimelineEvent *event, uint32 time) {
 	warning("potentially dangerous cast to uint32 below");
 	if (time < (uint32)M30_time(event->_mapTime)) {
 		event->_type -= 5;
@@ -1362,7 +1347,7 @@ void GroupMan::f208_groupAddEvent(TimelineEvent* event, uint32 time) {
 	_vm->_timeline->f238_addEventGetEventIndex(event);
 }
 
-int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo* creatureInfo, int16 mapY, int16 mapX) {
+int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo, int16 mapY, int16 mapX) {
 
 	uint16 L0426_ui_SmellRange;
 	int16 L0427_i_ScentOrdinal;
@@ -1388,7 +1373,7 @@ bool GroupMan::f198_isSmellPartyBlocked(uint16 mapX, uint16 mapY) {
 	return ((L0409_i_SquareType = Square(L0408_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k0_ElementTypeWall) || ((L0409_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0408_ui_Square, k0x0004_FakeWallOpen));
 }
 
-int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo* info, int16 mapX, int16 mapY, bool allowMovementOverImaginaryPitsAndFakeWalls) {
+int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo *info, int16 mapX, int16 mapY, bool allowMovementOverImaginaryPitsAndFakeWalls) {
 	int16 L0434_i_Direction;
 
 
@@ -1400,7 +1385,7 @@ int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo* info, int1
 	return 0;
 }
 
-void GroupMan::f206_groupSetDirGroup(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, int16 creatureSize) {
+void GroupMan::f206_groupSetDirGroup(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, int16 creatureSize) {
 	bool L0436_B_TwoHalfSquareSizedCreatures;
 
 
@@ -1414,7 +1399,7 @@ void GroupMan::f206_groupSetDirGroup(ActiveGroup* activeGroup, int16 dir, int16
 	} while (creatureIndex--);
 }
 
-void GroupMan::f182_stopAttacking(ActiveGroup* group, int16 mapX, int16 mapY) {
+void GroupMan::f182_stopAttacking(ActiveGroup *group, int16 mapX, int16 mapY) {
 	int16 L0337_i_CreatureIndex;
 
 	for (L0337_i_CreatureIndex = 0; L0337_i_CreatureIndex < 4; clearFlag(group->_aspect[L0337_i_CreatureIndex++], k0x0080_MaskActiveGroupIsAttacking));
@@ -1422,7 +1407,7 @@ void GroupMan::f182_stopAttacking(ActiveGroup* group, int16 mapX, int16 mapY) {
 
 }
 
-bool GroupMan::f204_isArchenemyDoubleMovementPossible(CreatureInfo* info, int16 mapX, int16 mapY, uint16 dir) {
+bool GroupMan::f204_isArchenemyDoubleMovementPossible(CreatureInfo *info, int16 mapX, int16 mapY, uint16 dir) {
 	if (_g385_fluxCages[dir]) {
 		return false;
 	}
@@ -1430,11 +1415,10 @@ bool GroupMan::f204_isArchenemyDoubleMovementPossible(CreatureInfo* info, int16
 	return f202_isMovementPossible(info, mapX, mapY, dir, false);
 }
 
-bool GroupMan::f207_isCreatureAttacking(Group* group, int16 mapX, int16 mapY, uint16 creatureIndex) {
+bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 creatureIndex) {
 	uint16 L0437_ui_Multiple;
 #define AL0437_ui_CreatureType L0437_ui_Multiple
 #define AL0437_T_Thing         L0437_ui_Multiple
-	uint16 L0438_ui_PrimaryDirectionToParty;
 	int16 L0439_i_Multiple;
 #define AL0439_i_GroupCells    L0439_i_Multiple
 #define AL0439_i_TargetCell    L0439_i_Multiple
@@ -1444,15 +1428,11 @@ bool GroupMan::f207_isCreatureAttacking(Group* group, int16 mapX, int16 mapY, ui
 #define AL0440_i_Counter            L0440_i_Multiple
 #define AL0440_i_Damage             L0440_i_Multiple
 #define AL0440_i_AttackSoundOrdinal L0440_i_Multiple
-	CreatureInfo* L0441_ps_CreatureInfo;
-	Champion* L0442_ps_Champion;
-	ActiveGroup L0443_s_ActiveGroup;
-
 
 	_vm->_projexpl->_g361_lastCreatureAttackTime = _vm->_g313_gameTime;
-	L0443_s_ActiveGroup = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
-	L0441_ps_CreatureInfo = &g243_CreatureInfo[AL0437_ui_CreatureType = group->_type];
-	L0438_ui_PrimaryDirectionToParty = _g382_currGroupPrimaryDirToParty;
+	ActiveGroup L0443_s_ActiveGroup = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
+	CreatureInfo *L0441_ps_CreatureInfo = &g243_CreatureInfo[AL0437_ui_CreatureType = group->_type];
+	uint16 L0438_ui_PrimaryDirectionToParty = _g382_currGroupPrimaryDirToParty;
 	if ((AL0439_i_GroupCells = L0443_s_ActiveGroup._cells) == k255_CreatureTypeSingleCenteredCreature) {
 		AL0439_i_TargetCell = _vm->getRandomNumber(2);
 	} else {
@@ -1524,7 +1504,7 @@ bool GroupMan::f207_isCreatureAttacking(Group* group, int16 mapX, int16 mapY, ui
 			f193_stealFromChampion(group, AL0439_i_ChampionIndex);
 		} else {
 			AL0440_i_Damage = f230_getChampionDamage(group, AL0439_i_ChampionIndex) + 1;
-			L0442_ps_Champion = &_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex];
+			Champion *L0442_ps_Champion = &_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex];
 			if (AL0440_i_Damage > L0442_ps_Champion->_maximumDamageReceived) {
 				L0442_ps_Champion->_maximumDamageReceived = AL0440_i_Damage;
 				L0442_ps_Champion->_directionMaximumDamageReceived = returnOppositeDir((direction)L0438_ui_PrimaryDirectionToParty);
@@ -1537,7 +1517,7 @@ bool GroupMan::f207_isCreatureAttacking(Group* group, int16 mapX, int16 mapY, ui
 	return true;
 }
 
-void GroupMan::f229_setOrderedCellsToAttack(signed char* orderedCellsToAttack, int16 targetMapX, int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource) {
+void GroupMan::f229_setOrderedCellsToAttack(signed char *orderedCellsToAttack, int16 targetMapX, int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource) {
 	static signed char g23_orderedCellsToAttack[8][4] = { // @ G0023_aac_Graphic562_OrderedCellsToAttack
 		{0, 1, 3, 2},   /* Attack South from position Northwest or Southwest */
 		{1, 0, 2, 3},   /* Attack South from position Northeast or Southeast */
@@ -1558,12 +1538,12 @@ void GroupMan::f229_setOrderedCellsToAttack(signed char* orderedCellsToAttack, i
 		orderedCellsToAttack[i] = g23_orderedCellsToAttack[L0557_ui_OrderedCellsToAttackIndex][i];
 }
 
-void GroupMan::f193_stealFromChampion(Group* group, uint16 championIndex) {
+void GroupMan::f193_stealFromChampion(Group *group, uint16 championIndex) {
 	int16 L0391_i_Percentage;
 	uint16 L0392_ui_StealFromSlotIndex;
 	uint16 L0393_ui_Counter;
 	Thing L0394_T_Thing;
-	Champion* L0395_ps_Champion;
+	Champion *L0395_ps_Champion;
 	bool L0396_B_ObjectStolen;
 	static unsigned char G0394_auc_StealFromSlotIndices[8]; /* Initialized with 0 bytes by C loader */
 
@@ -1597,10 +1577,10 @@ void GroupMan::f193_stealFromChampion(Group* group, uint16 championIndex) {
 	}
 }
 
-int16 GroupMan::f230_getChampionDamage(Group* group, uint16 champIndex) {
+int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) {
 	unsigned char g24_woundProbabilityIndexToWoundMask[4] = {32, 16, 8, 4}; // @ G0024_auc_Graphic562_WoundProbabilityIndexToWoundMask
 
-	Champion* L0562_ps_Champion;
+	Champion *L0562_ps_Champion;
 	int16 L0558_i_Multiple;
 #define AL0558_i_Attack L0558_i_Multiple
 #define AL0558_i_Damage L0558_i_Multiple
@@ -1667,12 +1647,12 @@ T0230014:
 }
 
 void GroupMan::f187_dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY) {
-	Group* L0363_ps_Group;
+	Group *L0363_ps_Group;
 	int16 L0364_i_CreatureType;
 
 
 	if (_g391_dropMovingCreatureFixedPossCellCount) {
-		L0363_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing);
+		L0363_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(thing);
 		L0364_i_CreatureType = L0363_ps_Group->_type;
 		while (_g391_dropMovingCreatureFixedPossCellCount) {
 			f186_dropCreatureFixedPossessions(L0364_i_CreatureType, mapX, mapY, _g392_dropMovingCreatureFixedPossessionsCell[--_g391_dropMovingCreatureFixedPossCellCount], k2_soundModePlayOneTickLater);
@@ -1681,11 +1661,11 @@ void GroupMan::f187_dropMovingCreatureFixedPossession(Thing thing, int16 mapX, i
 }
 
 void GroupMan::f180_startWanedring(int16 mapX, int16 mapY) {
-	Group* L0332_ps_Group;
+	Group *L0332_ps_Group;
 	TimelineEvent L0333_s_Event;
 
 
-	L0332_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(mapX, mapY));
+	L0332_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(mapX, mapY));
 	if (L0332_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
 		L0332_ps_Group->setBehaviour(k0_behavior_WANDER);
 	}
@@ -1700,8 +1680,8 @@ void GroupMan::f180_startWanedring(int16 mapX, int16 mapY) {
 
 void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
 	uint16 L0339_ui_CreatureIndex;
-	Group* L0340_ps_Group;
-	ActiveGroup* L0341_ps_ActiveGroup;
+	Group *L0340_ps_Group;
+	ActiveGroup *L0341_ps_ActiveGroup;
 	int16 L0344_i_ActiveGroupIndex;
 
 
@@ -1719,7 +1699,7 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
 		L0341_ps_ActiveGroup++;
 	}
 	_g377_currActiveGroupCount++;
-	L0340_ps_Group = ((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType());
+	L0340_ps_Group = ((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType());
 	L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells;
 	L0340_ps_Group->getActiveGroupIndex() = L0344_i_ActiveGroupIndex;
 	L0341_ps_ActiveGroup->_priorMapX = L0341_ps_ActiveGroup->_homeMapX = mapX;
@@ -1734,15 +1714,15 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
 }
 
 void GroupMan::f184_removeActiveGroup(uint16 activeGroupIndex) {
-	ActiveGroup* L0347_ps_ActiveGroup;
-	Group* L0348_ps_Group;
+	ActiveGroup *L0347_ps_ActiveGroup;
+	Group *L0348_ps_Group;
 
 
 	if ((activeGroupIndex > _vm->_groupMan->_g376_maxActiveGroupCount) || (_vm->_groupMan->_g375_activeGroups[activeGroupIndex]._groupThingIndex < 0)) {
 		return;
 	}
 	L0347_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[activeGroupIndex];
-	L0348_ps_Group = &((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex];
+	L0348_ps_Group = &((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex];
 	_g377_currActiveGroupCount--;
 	L0348_ps_Group->_cells = L0347_ps_ActiveGroup->_cells;
 	L0348_ps_Group->setDir(M21_normalizeModulo4(L0347_ps_ActiveGroup->_directions));
@@ -1764,8 +1744,8 @@ void GroupMan::f195_addAllActiveGroups() {
 	uint16 L0398_ui_MapX;
 	uint16 L0399_ui_MapY;
 	Thing L0400_T_Thing;
-	byte* L0401_puc_Square;
-	Thing* L0402_pT_SquareFirstThing;
+	byte *L0401_puc_Square;
+	Thing *L0402_pT_SquareFirstThing;
 
 
 	L0401_puc_Square = _vm->_dungeonMan->_g271_currMapData[0];


Commit: 2c860f106977677f59c3843312ea19b24bfe5d31
    https://github.com/scummvm/scummvm/commit/2c860f106977677f59c3843312ea19b24bfe5d31
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some soft refactoring, in order to silent some CppCheck warnings

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/inventory.cpp
    engines/dm/movesens.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 3b009c2..545b11f 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -419,8 +419,6 @@ DungeonMan::~DungeonMan() {
 	delete[] _g260_dungeonTextData;
 	delete[] _g279_dungeonMapData;
 	for (uint16 i = 0; i < 16; ++i) {
-		if (_g284_thingData[i])
-			delete[] _g284_thingData[i][0];
 		delete[] _g284_thingData[i];
 	}
 }
@@ -653,34 +651,34 @@ void DungeonMan::f434_loadDungeonFile() {
 			continue;
 
 		if (_g284_thingData[thingType]) {
-			delete[] _g284_thingData[thingType][0];
 			delete[] _g284_thingData[thingType];
 		}
-		_g284_thingData[thingType] = new uint16*[_g278_dungeonFileHeader._thingCounts[thingType]];
-		_g284_thingData[thingType][0] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount];
-		for (uint16 i = 0; i < _g278_dungeonFileHeader._thingCounts[thingType]; ++i)
-			_g284_thingData[thingType][i] = _g284_thingData[thingType][0] + i * thingStoreWordCount;
+		_g284_thingData[thingType] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount];
 
 		if (thingType == k4_GroupThingType) {
-			for (uint16 i = 0; i < thingCount; ++i)
+			for (uint16 i = 0; i < thingCount; ++i) {
+				uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount;
 				for (uint16 j = 0; j < thingStoreWordCount; ++j) {
 					if (j == 2 || j == 3)
-						_g284_thingData[thingType][i][j] = dunDataStream.readByte();
+						nextSlot[j] = dunDataStream.readByte();
 					else
-						_g284_thingData[thingType][i][j] = dunDataStream.readUint16BE();
+						nextSlot[j] = dunDataStream.readUint16BE();
 				}
+			}
 		} else if (thingType == k14_ProjectileThingType) {
 			for (uint16 i = 0; i < thingCount; ++i) {
-				_g284_thingData[thingType][i][0] = dunDataStream.readUint16BE();
-				_g284_thingData[thingType][i][1] = dunDataStream.readUint16BE();
-				_g284_thingData[thingType][i][2] = dunDataStream.readByte();
-				_g284_thingData[thingType][i][3] = dunDataStream.readByte();
-				_g284_thingData[thingType][i][4] = dunDataStream.readUint16BE();
+				uint16 *nextSlot = _g284_thingData[thingType] + i * thingStoreWordCount;
+				nextSlot[0] = dunDataStream.readUint16BE();
+				nextSlot[1] = dunDataStream.readUint16BE();
+				nextSlot[2] = dunDataStream.readByte();
+				nextSlot[3] = dunDataStream.readByte();
+				nextSlot[4] = dunDataStream.readUint16BE();
 			}
 		} else {
 			for (uint16 i = 0; i < thingCount; ++i) {
+				uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount;
 				for (uint16 j = 0; j < thingStoreWordCount; ++j)
-					_g284_thingData[thingType][i][j] = dunDataStream.readUint16BE();
+					nextSlot[j] = dunDataStream.readUint16BE();
 			}
 		}
 
@@ -688,7 +686,7 @@ void DungeonMan::f434_loadDungeonFile() {
 			if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType)
 				_vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType];
 			for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) {
-				_g284_thingData[thingType][thingCount + i][0] = Thing::_none.toUint16();
+				(_g284_thingData[thingType] + (thingCount + i) * thingStoreWordCount)[0] = Thing::_none.toUint16();
 			}
 		}
 	}
@@ -757,33 +755,36 @@ void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) {
 
 
 Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) {
-	bool isInXBounds = (mapX >= 0) && (mapX < _g273_currMapWidth);
-	bool isInYBounds = (mapY >= 0) && (mapY < _g274_currMapHeight);
-
-	if (isInXBounds && isInYBounds)
-		return Square(_g271_currMapData[mapX][mapY]);
-
-
-	Square tmpSquare;
-	if (isInYBounds) {
-		tmpSquare.set(_g271_currMapData[0][mapY]);
-		if (mapX == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
-			return Square(k0_WallElemType).set(k0x0004_WallEastRandOrnAllowed);
-
-		tmpSquare.set(_g271_currMapData[_g273_currMapWidth - 1][mapY]);
-		if (mapX == _g273_currMapWidth && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
-			return Square(k0_WallElemType).set(k0x0001_WallWestRandOrnAllowed);
-	} else if (isInXBounds) {
-		tmpSquare.set(_g271_currMapData[mapX][0]);
-		if (mapY == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
-			return Square(k0_WallElemType).set(k0x0002_WallSouthRandOrnAllowed);
-
-		tmpSquare.set(_g271_currMapData[mapX][_g274_currMapHeight - 1]);
-		if (mapY == _g274_currMapHeight && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType))
-			return Square((k0_WallElemType << 5) | k0x0008_WallNorthRandOrnAllowed);
+	int16 L0248_i_Multiple;
+#define AL0248_B_IsMapXInBounds L0248_i_Multiple
+#define AL0248_i_SquareType     L0248_i_Multiple
+	int16 L0249_i_Multiple;
+#define AL0249_B_IsMapYInBounds L0249_i_Multiple
+#define AL0249_i_SquareType     L0249_i_Multiple
+
+	AL0249_B_IsMapYInBounds = (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight);
+	if ((AL0248_B_IsMapXInBounds = (mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth)) && AL0249_B_IsMapYInBounds) {
+		return Square(_vm->_dungeonMan->_g271_currMapData[mapX][mapY]);
 	}
 
-	return Square(k0_WallElemType);
+	if (AL0249_B_IsMapYInBounds) {
+		if (((mapX == -1) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[0][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) {
+			return Square(k0_ElementTypeWall, k0x0004_WallEastRandOrnAllowed);
+		}
+		if (((mapX == _vm->_dungeonMan->_g273_currMapWidth) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[_vm->_dungeonMan->_g273_currMapWidth - 1][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) {
+			return Square(k0_ElementTypeWall, k0x0001_WallWestRandOrnAllowed);
+		}
+	} else {
+		if (AL0248_B_IsMapXInBounds) {
+			if (((mapY == -1) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][0]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) {
+				return Square(k0_ElementTypeWall, k0x0002_WallSouthRandOrnAllowed);
+			}
+			if (((mapY == _vm->_dungeonMan->_g274_currMapHeight) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][_vm->_dungeonMan->_g274_currMapHeight - 1]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) {
+				return Square(k0_ElementTypeWall, k0x0008_WallNorthRandOrnAllowed);
+			}
+		}
+	}
+	return Square(k0_ElementTypeWall, 0);
 }
 
 Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
@@ -792,17 +793,23 @@ Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 st
 }
 
 int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) {
-	if (mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight || !Square(_g271_currMapData[mapX][mapY]).get(k0x0010_ThingListPresent))
-		return -1;
+	uint16 L0260_ui_ThingIndex;
+	int16 L0261_i_MapY;
+	register unsigned char* L0262_puc_Square;
 
-	int16 y = 0;
-	uint16 index = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
-	byte* square = _g271_currMapData[mapX];
-	while (y++ != mapY)
-		if (Square(*square++).get(k0x0010_ThingListPresent))
-			index++;
 
-	return index;
+	L0262_puc_Square = _vm->_dungeonMan->_g271_currMapData[mapX];
+	if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight) || !getFlag(L0262_puc_Square[mapY], k0x0010_ThingListPresent)) {
+		return -1;
+	}
+	L0261_i_MapY = 0;
+	L0260_ui_ThingIndex = _vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount[mapX];
+	while (L0261_i_MapY++ != mapY) {
+		if (getFlag(*L0262_puc_Square++, k0x0010_ThingListPresent)) {
+			L0260_ui_ThingIndex++;
+		}
+	}
+	return L0260_ui_ThingIndex;
 }
 
 Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) {
@@ -959,31 +966,33 @@ T0172049_Footprints:
 	aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16();
 }
 
-void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir,
+void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir,
 												 int16 mapX, int16 mapY, bool isFakeWall) {
-	int16 ornCount = _g269_currMap->_randWallOrnCount;
-
-	turnDirRight(dir);
-	aspectArray[k2_RightWallOrnOrdAspect] = f170_getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
-	turnDirRight(dir);
-	aspectArray[k3_FrontWallOrnOrdAspect] = f170_getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
-	turnDirRight(dir);
-	aspectArray[k4_LeftWallOrnOrdAspect] = f170_getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30);
-
-	if (isFakeWall || mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight) {
-		for (uint16 i = k2_RightWallOrnOrdAspect; i <= k4_LeftWallOrnOrdAspect; ++i) {
-			if (f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[i])))
-				aspectArray[i] = 0;
+	int16 L0306_i_Multiple;
+#define AL0306_i_RandomWallOrnamentCount L0306_i_Multiple
+#define AL0306_i_SideIndex               L0306_i_Multiple
+
+
+	AL0306_i_RandomWallOrnamentCount = _vm->_dungeonMan->_g269_currMap->_randWallOrnCount;
+	aspectArray[k2_RightWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(leftAllowed, AL0306_i_RandomWallOrnamentCount, mapX, ++mapY * (M21_normalizeModulo4(++dir) + 1), 30);
+	aspectArray[k3_FrontWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(frontAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY * (M21_normalizeModulo4(++dir) + 1), 30);
+	aspectArray[k4_LeftWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(rightAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY-- * (M21_normalizeModulo4(++dir) + 1), 30);
+	if (isFakeWall || (mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight)) { /* If square is a fake wall or is out of map bounds */
+		for (AL0306_i_SideIndex = k2_RightWallOrnOrdAspect; AL0306_i_SideIndex <= k4_LeftWallOrnOrdAspect; AL0306_i_SideIndex++) { /* Loop to remove any random ornament that is an alcove */
+			if (_vm->_dungeonMan->f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[AL0306_i_SideIndex]))) {
+				aspectArray[AL0306_i_SideIndex] = 0;
+			}
 		}
 	}
 }
 
 int16 DungeonMan::f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) {
-	int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1)
-					+ (3000 + (_g272_currMapIndex << 6) + _g273_currMapWidth + _g274_currMapHeight) * 11
-					+ _g278_dungeonFileHeader._ornamentRandomSeed) >> 2) % modulo;
-	if (allowed && index < count)
-		return _vm->M0_indexToOrdinal(index);
+	int16 L0305_i_RandomOrnamentIndex;
+
+
+	if (allowed && ((L0305_i_RandomOrnamentIndex = f169_getRandomOrnamentIndex((int16)2000 + (mapX << 5) + mapY, (int16)3000 + (_vm->_dungeonMan->_g272_currMapIndex << (int16)6) + _vm->_dungeonMan->_g273_currMapWidth + _vm->_dungeonMan->_g274_currMapHeight, modulo)) < count)) {
+		return _vm->M0_indexToOrdinal(L0305_i_RandomOrnamentIndex);
+	}
 	return 0;
 }
 
@@ -997,7 +1006,7 @@ bool DungeonMan::f149_isWallOrnAnAlcove(int16 wallOrnIndex) {
 }
 
 uint16 *DungeonMan::f156_getThingData(Thing thing) {
-	return _g284_thingData[thing.getType()][thing.getIndex()];
+	return _g284_thingData[thing.getType()] + thing.getIndex() * g235_ThingDataWordCount[thing.getType()];
 }
 
 uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) {
@@ -1005,7 +1014,7 @@ uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) {
 }
 
 Thing DungeonMan::f159_getNextThing(Thing thing) {
-	return Thing(f156_getThingData(thing)[0]); // :)
+	return Thing(f156_getThingData(thing)[0]);
 }
 
 char g255_MessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings
@@ -1110,7 +1119,7 @@ char g257_InscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_
 
 
 void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) {
-	TextString textString(_g284_thingData[k2_TextstringType][thing.getIndex()]);
+	TextString textString(_g284_thingData[k2_TextstringType] + thing.getIndex() * g235_ThingDataWordCount[k2_TextstringType]);
 	if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) {
 		type = (TextType)(type & ~k0x8000_DecodeEvenIfInvisible);
 		char sepChar;
@@ -1307,43 +1316,43 @@ void DungeonMan::f163_linkThingToList(Thing thingToLink, Thing thingInList, int1
 	if (thingToLink == Thing::_endOfList)
 		return;
 
-	uint16 *rawObjPtr = f156_getThingData(thingToLink);
-	*rawObjPtr = Thing::_endOfList.toUint16();
-
+	Thing *L0269_ps_Generic = (Thing *)f156_getThingData(thingToLink);
+	*L0269_ps_Generic = Thing::_endOfList;
+	/* If mapX >= 0 then the thing is linked to the list of things on the specified square else it is linked at the end of the specified thing list */
 	if (mapX >= 0) {
-		Square *squarePtr = (Square*)&_g271_currMapData[mapX][mapY];
-		if (squarePtr->get(k0x0010_ThingListPresent)) {
+		byte *L0268_puc_Square = &_g271_currMapData[mapX][mapY];
+		if (getFlag(*L0268_puc_Square, k0x0010_ThingListPresent)) {
 			thingInList = f161_getSquareFirstThing(mapX, mapY);
 		} else {
-			squarePtr->set(k0x0010_ThingListPresent);
-			uint16 *cumulativeCount = &_g270_currMapColCumulativeSquareFirstThingCount[mapX + 1];
-			uint16 column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1;
-			while (column--) {
-				(*cumulativeCount++)++;
+			setFlag(*L0268_puc_Square, k0x0010_ThingListPresent);
+			uint16 * tmp = _g270_currMapColCumulativeSquareFirstThingCount + mapX + 1;
+			uint16 AL0266_ui_Column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1;
+			while (AL0266_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is added */
+				(*tmp++)++; /* Increment the cumulative first thing count */
 			}
-			uint16 mapYStep = 0;
-			squarePtr -= mapY;
-			uint16 squareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
-			while (mapYStep++ != mapY) {
-				if (squarePtr->get(k0x0010_ThingListPresent)) {
-					squareFirstThingIndex++;
+			uint16 L0270_ui_MapY = 0;
+			L0268_puc_Square -= mapY;
+			uint16 AL0266_ui_SquareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
+			while (L0270_ui_MapY++ != mapY) {
+				if (getFlag(*L0268_puc_Square++, k0x0010_ThingListPresent)) {
+					AL0266_ui_SquareFirstThingIndex++;
 				}
-				squarePtr++;
 			}
-			Thing* thingPtr = &_g283_squareFirstThings[squareFirstThingIndex];
-			memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_g278_dungeonFileHeader._squareFirstThingCount - squareFirstThingIndex - 1));
-			*thingPtr = thingToLink;
+			Thing *L0267_pT_Thing = &_g283_squareFirstThings[AL0266_ui_SquareFirstThingIndex];
+			// the second '- 1' is for the loop initialization, > 0 is because we are copying from one behind
+			for (int16 i = _g278_dungeonFileHeader._squareFirstThingCount - AL0266_ui_SquareFirstThingIndex - 1 - 1; i > 0; --i)
+				L0267_pT_Thing[i] = L0267_pT_Thing[i - 1];
+
+			*L0267_pT_Thing = thingToLink;
 			return;
 		}
 	}
-
-	Thing thing = f159_getNextThing(thingInList);
-	while (thing != Thing::_endOfList) {
-		thing = f159_getNextThing(thing);
-		thingInList = thing;
+	Thing L0265_T_Thing = f159_getNextThing(thingInList);
+	while (L0265_T_Thing != Thing::_endOfList) {
+		L0265_T_Thing = f159_getNextThing(thingInList = L0265_T_Thing);
 	}
-	rawObjPtr = f156_getThingData(thingInList);
-	*rawObjPtr = thingToLink.toUint16();
+	L0269_ps_Generic = (Thing *)f156_getThingData(thingInList);
+	*L0269_ps_Generic = thingToLink;
 }
 
 WeaponInfo* DungeonMan::f158_getWeaponInfo(Thing thing) {
@@ -1695,4 +1704,10 @@ Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {
 	}
 	return L0295_T_Thing;
 }
+
+int16 DungeonMan::f169_getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo) {
+	return ((((((val1 * 31417) & 0xFFFF) >> 1) + ((val2 * 11) & 0xFFFF)
+			  + _vm->_dungeonMan->_g278_dungeonFileHeader._ornamentRandomSeed) & 0xFFFF) >> 2) % modulo; /* Pseudorandom number generator */
+}
+
 }
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 204a296..da7da40 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -351,14 +351,13 @@ void EventManager::f68_setPointerToObject(byte* bitmap) {
 		100, 110, 0, 130, 140, 150}; // @ G0044_auc_Graphic562_PaletteChanges_MousePointerIcon
 	static Box g619_BoxMousePointerObjectShadow(2, 17, 2, 17); // @ G0619_s_Box_MousePointer_ObjectShadow 
 	static Box g620_BoxMousePointerObject(0, 15, 0, 15); // @ G0620_s_Box_MousePointer_Object 
-	byte* L0051_puc_Bitmap;
 
 	_gK100_preventBuildPointerScreenArea = true;
 	_g600_useObjectAsMousePointerBitmap = true;
 	_g601_useHandAsMousePointerBitmap = false;
 	_g598_mousePointerBitmapUpdated = true;
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
-	L0051_puc_Bitmap = _g615_mousePointerOriginalColorsObject;
+	byte *L0051_puc_Bitmap = _g615_mousePointerOriginalColorsObject;
 	memset(L0051_puc_Bitmap, 0, 32 * 18);
 
 	/*
@@ -367,6 +366,7 @@ void EventManager::f68_setPointerToObject(byte* bitmap) {
 	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, g44_palChangesMousePointerIcon);
 	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
 	*/
+	warning("TODO - Call f129_blitToBitmapShrinkWithPalChange");
 	// dummy code
 	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
 	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
@@ -376,15 +376,11 @@ void EventManager::f68_setPointerToObject(byte* bitmap) {
 }
 
 void EventManager::f71_mouseDropChampionIcon() {
-	bool L0057_B_UseByteBoxCoordinatesBackup;
-	uint16 L0058_ui_ChampionIconIndex;
-
-
 	_gK100_preventBuildPointerScreenArea = true;
-	L0058_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap);
+	uint16 L0058_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap);
 	_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
 	_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
-	L0057_B_UseByteBoxCoordinatesBackup = _vm->_displayMan->_g578_useByteBoxCoordinates;
+	bool L0057_B_UseByteBoxCoordinatesBackup = _vm->_displayMan->_g578_useByteBoxCoordinates;
 	_vm->_displayMan->f21_blitToScreen(_g613_mousePointerOriginalColorsChampionIcon, &g54_BoxChampionIcons[L0058_ui_ChampionIconIndex << 2], 16, k12_ColorDarkestGray, 18);
 	_vm->_displayMan->_g578_useByteBoxCoordinates = L0057_B_UseByteBoxCoordinatesBackup;
 	_gK100_preventBuildPointerScreenArea = false;
@@ -394,7 +390,6 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY)
 	uint16 L1577_i_ChampionIndex;
 	int16 L1578_i_XOverChampionStatusBox;
 
-
 	// if (_gK100_preventBuildPointerScreenArea)
 	//	return;
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index b72be8a..c1d2aed 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -556,9 +556,6 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 }
 
 void InventoryMan::f337_setDungeonViewPalette() {
-	int16 L1036_i_TotalLightAmount;
-	uint16 L1037_ui_TorchLightAmountMultiplier;
-	int16 L1038_i_Counter;
 	uint16 L1039_ui_Multiple;
 #define AL1039_ui_SlotIndex    L1039_ui_Multiple
 #define AL1039_ui_PaletteIndex L1039_ui_Multiple
@@ -566,9 +563,6 @@ void InventoryMan::f337_setDungeonViewPalette() {
 	int16* L1040_pi_Multiple;
 #define AL1040_pi_TorchLightPower L1040_pi_Multiple
 #define AL1040_pi_LightAmount     L1040_pi_Multiple
-	int16* L1041_pi_TorchLightPower;
-	Weapon* L1042_ps_Weapon;
-	Champion* L1043_ps_Champion;
 	uint16 L1044_ui_Multiple;
 #define AL1044_T_Thing            L1044_ui_Multiple
 #define AL1044_ui_TorchLightPower L1044_ui_Multiple
@@ -580,15 +574,15 @@ void InventoryMan::f337_setDungeonViewPalette() {
 		_vm->_displayMan->_g304_dungeonViewPaletteIndex = 0; /* Brightest color palette index */
 	} else {
 		/* Get torch light power from both hands of each champion in the party */
-		L1038_i_Counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and _vm->_objectMan->f32_getObjectType then returns -1 */
-		L1043_ps_Champion = _vm->_championMan->_gK71_champions;
+		int16 L1038_i_Counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and _vm->_objectMan->f32_getObjectType then returns -1 */
+		Champion *L1043_ps_Champion = _vm->_championMan->_gK71_champions;
 		AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
 		while (L1038_i_Counter--) {
 			AL1039_ui_SlotIndex = k1_ChampionSlotActionHand + 1;
 			while (AL1039_ui_SlotIndex--) {
 				if ((_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16())) >= k4_IconIndiceWeaponTorchUnlit) &&
 					(_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16())) <= k7_IconIndiceWeaponTorchLit)) {
-					L1042_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(Thing(AL1044_T_Thing));
+					Weapon *L1042_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(Thing(AL1044_T_Thing));
 					*AL1040_pi_TorchLightPower = L1042_ps_Weapon->getChargeCount();
 				} else {
 					*AL1040_pi_TorchLightPower = 0;
@@ -602,7 +596,7 @@ void InventoryMan::f337_setDungeonViewPalette() {
 		AL1039_ui_Counter = 0;
 		while (AL1039_ui_Counter != 4) {
 			L1038_i_Counter = 7 - AL1039_ui_Counter;
-			L1041_pi_TorchLightPower = &L1045_ai_TorchesLightPower[AL1039_ui_Counter + 1];
+			int16 *L1041_pi_TorchLightPower = &L1045_ai_TorchesLightPower[AL1039_ui_Counter + 1];
 			while (L1038_i_Counter--) {
 				if (*L1041_pi_TorchLightPower > *AL1040_pi_TorchLightPower) {
 					AL1044_ui_TorchLightPower = *L1041_pi_TorchLightPower;
@@ -615,9 +609,9 @@ void InventoryMan::f337_setDungeonViewPalette() {
 			AL1039_ui_Counter++;
 		}
 		/* Get total light amount provided by the four torches with the highest light power values and by the fifth torch in the array which may be any one of the four torches with the smallest ligh power values */
-		L1037_ui_TorchLightAmountMultiplier = 6;
+		uint16 L1037_ui_TorchLightAmountMultiplier = 6;
 		AL1039_ui_Counter = 5;
-		L1036_i_TotalLightAmount = 0;
+		int16 L1036_i_TotalLightAmount = 0;
 		AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
 		while (AL1039_ui_Counter--) {
 			if (*AL1040_pi_TorchLightPower) {
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index cb73d3f..93d78ed 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -1008,8 +1008,6 @@ void MovesensMan::f270_sensorTriggetLocalEffect(int16 localEffect, int16 effX, i
 }
 
 void MovesensMan::f269_sensorAddSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly) {
-	int16 L0730_i_ChampionIndex;
-	Champion* L0731_ps_Champion;
 
 	if (leaderOnly) {
 		if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) {
@@ -1017,7 +1015,8 @@ void MovesensMan::f269_sensorAddSkillExperience(int16 skillIndex, uint16 exp, bo
 		}
 	} else {
 		exp /= _vm->_championMan->_g305_partyChampionCount;
-		for (L0730_i_ChampionIndex = k0_ChampionFirst, L0731_ps_Champion = _vm->_championMan->_gK71_champions; L0730_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0730_i_ChampionIndex++, L0731_ps_Champion++) {
+		Champion *L0731_ps_Champion = _vm->_championMan->_gK71_champions;
+		for (int16 L0730_i_ChampionIndex = k0_ChampionFirst; L0730_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0730_i_ChampionIndex++, L0731_ps_Champion++) {
 			if (L0731_ps_Champion->_currHealth) {
 				_vm->_championMan->f304_addSkillExperience(L0730_i_ChampionIndex, skillIndex, exp);
 			}


Commit: af42277a93bfb9286c6487f0820d45899547f55f
    https://github.com/scummvm/scummvm/commit/af42277a93bfb9286c6487f0820d45899547f55f
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Reduce some variable scopes, silent CppCheck warnings

Changed paths:
    engines/dm/objectman.cpp
    engines/dm/projexpl.cpp



diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 05a86de..ea07c58 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -138,15 +138,12 @@ IconIndice ObjectMan::f32_getObjectType(Thing thing) {
 byte g29_ChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType
 
 IconIndice ObjectMan::f33_getIconIndex(Thing thing) {
-	int16 L0005_i_IconIndex;
-	Junk* L0006_ps_Junk;
-
-
-	if ((L0005_i_IconIndex = _vm->_objectMan->f32_getObjectType(thing)) != kM1_IconIndiceNone) {
+	int16 L0005_i_IconIndex = _vm->_objectMan->f32_getObjectType(thing);
+	if (L0005_i_IconIndex != kM1_IconIndiceNone) {
 		if (((L0005_i_IconIndex < k32_IconIndiceWeaponDagger) && (L0005_i_IconIndex >= k0_IconIndiceJunkCompassNorth)) ||
 			((L0005_i_IconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (L0005_i_IconIndex <= k163_IconIndicePotionWaterFlask)) ||
 			(L0005_i_IconIndex == k195_IconIndicePotionEmptyFlask)) {
-			L0006_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing);
+			Junk *L0006_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing);
 			switch (L0005_i_IconIndex) {
 			case k0_IconIndiceJunkCompassNorth:
 				L0005_i_IconIndex += _vm->_dungeonMan->_g308_partyDir;
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 4c08214..c312be1 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -294,20 +294,14 @@ uint16 ProjExpl::f216_projectileGetImpactAttack(Projectile* projectile, Thing th
 void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXCombo, uint16 mapYCombo, uint16 cell) {
 #define AP0443_ui_ProjectileMapX mapXCombo
 #define AP0444_ui_ProjectileMapY mapYCombo
-	Explosion* L0470_ps_Explosion;
-	CreatureInfo* L0471_ps_CreatureInfo;
-	Group* L0472_ps_Group;
-	Thing L0473_T_Thing;
-	int16 L0474_i_ProjectileTargetMapX;
-	int16 L0475_i_ProjectileTargetMapY;
-	int16 L0469_i_CreatureFireResistance;
-	TimelineEvent L0476_s_Event;
-
-
-	if ((L0473_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k15_ExplosionThingType)) == Thing::_none) {
+	Thing L0473_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k15_ExplosionThingType);
+	if (L0473_T_Thing == Thing::_none) {
 		return;
 	}
-	L0470_ps_Explosion = &((Explosion *)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[(L0473_T_Thing).getIndex()];
+
+	Explosion *L0470_ps_Explosion = &((Explosion *)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[(L0473_T_Thing).getIndex()];
+	int16 L0474_i_ProjectileTargetMapX;
+	int16 L0475_i_ProjectileTargetMapY;
 	if (mapXCombo <= 255) {
 		L0474_i_ProjectileTargetMapX = mapXCombo;
 		L0475_i_ProjectileTargetMapY = mapYCombo;
@@ -334,6 +328,7 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 		}
 	}
 	_vm->_dungeonMan->f163_linkThingToList(L0473_T_Thing, Thing(0), AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY);
+	TimelineEvent L0476_s_Event;
 	M33_setMapAndTime(L0476_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ((explThing == Thing::_explRebirthStep1) ? 5 : 1));
 	L0476_s_Event._type = k25_TMEventTypeExplosion;
 	L0476_s_Event._priority = 0;
@@ -351,9 +346,10 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 				_vm->_championMan->f324_damageAll_getDamagedChampionCount(attack, k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand | k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k1_attackType_FIRE);
 			} else {
 				if ((L0473_T_Thing = _vm->_groupMan->f175_groupGetThing(AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY)) != Thing::_endOfList) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
-					L0472_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0473_T_Thing);
-					L0471_ps_CreatureInfo = &g243_CreatureInfo[L0472_ps_Group->_type];
-					if ((L0469_i_CreatureFireResistance = (L0471_ps_CreatureInfo->M60_getFireResistance())) != k15_immuneToFire) {
+					Group *L0472_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0473_T_Thing);
+					CreatureInfo *L0471_ps_CreatureInfo = &g243_CreatureInfo[L0472_ps_Group->_type];
+					int16 L0469_i_CreatureFireResistance = L0471_ps_CreatureInfo->M60_getFireResistance();
+					if (L0469_i_CreatureFireResistance != k15_immuneToFire) {
 						if (getFlag(L0471_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
 							attack >>= 2;
 						}
@@ -400,16 +396,13 @@ void ProjExpl::f214_projectileDeleteEvent(Thing thing) {
 }
 
 void ProjExpl::f215_projectileDelete(Thing projectileThing, Thing* groupSlot, int16 mapX, int16 mapY) {
-	Thing L0478_T_PreviousThing;
-	Thing L0479_T_Thing;
-	Projectile* L0480_ps_Projectile;
-	Thing* L0481_ps_Generic;
-
-	L0480_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(projectileThing);
-	if ((L0479_T_Thing = L0480_ps_Projectile->_slot).getType() != k15_ExplosionThingType) {
+	Projectile *L0480_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(projectileThing);
+	Thing L0479_T_Thing = L0480_ps_Projectile->_slot;
+	if (L0479_T_Thing.getType() != k15_ExplosionThingType) {
 		if (groupSlot != NULL) {
-			if ((L0478_T_PreviousThing = *groupSlot) == Thing::_endOfList) {
-				L0481_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0479_T_Thing);
+			Thing L0478_T_PreviousThing = *groupSlot;
+			if (L0478_T_PreviousThing == Thing::_endOfList) {
+				Thing *L0481_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0479_T_Thing);
 				*L0481_ps_Generic = Thing::_endOfList;
 				*groupSlot = L0479_T_Thing;
 			} else {


Commit: 9c4236d0392f8e8c844566d8af9cb514d91b56d0
    https://github.com/scummvm/scummvm/commit/9c4236d0392f8e8c844566d8af9cb514d91b56d0
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove extra parenthesis

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/movesens.cpp
    engines/dm/projexpl.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 545b11f..3c03749 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1470,7 +1470,7 @@ Thing DungeonMan::f165_getDiscardTHing(uint16 thingType) {
 					if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && ((L0276_ui_MapX - _vm->_dungeonMan->_g306_partyMapX + 5) <= 10) && ((L0277_ui_MapY - _vm->_dungeonMan->_g307_partyMapY + 5) <= 10)) /* If square is too close to the party */
 						goto T0165029;
 					do {
-						if ((L0287_i_ThingType = (L0278_T_Thing).getType()) == k3_SensorThingType) {
+						if ((L0287_i_ThingType = L0278_T_Thing.getType()) == k3_SensorThingType) {
 							L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing);
 							if (((Sensor*)L0282_ps_Generic)->getType()) /* If sensor is not disabled */
 								break;
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 93d78ed..da8c5e5 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -220,21 +220,10 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 	int16 L0710_i_ThingType;
 	Champion* L0711_ps_Champion;
 	Teleporter* L0712_ps_Teleporter;
-	bool L0713_B_ThingLevitates;
-	uint16 L0714_ui_MapIndexSource = 0;
-	uint16 L0715_ui_MapIndexDestination = 0;
-	uint16 L0716_ui_Direction = 0;
-	uint16 L0717_ui_ThingCell = 0;
 	int16 L0718_i_RequiredTeleporterScope;
 	// Strangerke: Only present in v2.1, but it fixes a bug, so I propose to keep it
 	int16 L0719_i_TraversedPitCount;
 	uint16 L0720_ui_MoveGroupResult;
-	bool L0721_B_GroupOnPartyMap;
-	bool L0722_B_FallKilledGroup;
-	bool L0723_B_DrawDungeonViewWhileFalling;
-	bool L0724_B_DestinationIsTeleporterTarget;
-	bool L0725_B_PartySquare;
-	bool L0726_B_Audible;
 	uint16 L0727_ui_Multiple;
 #define AL0727_ui_ThingCell L0727_ui_Multiple
 #define AL0727_ui_Outcome   L0727_ui_Multiple
@@ -243,18 +232,20 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 	uint16 L1638_ui_MovementSoundIndex;
 
 	L0710_i_ThingType = kM1_PartyThingType;
-	L0713_B_ThingLevitates = false;
+	bool L0713_B_ThingLevitates = false;
 	L0719_i_TraversedPitCount = 0;
 	L0720_ui_MoveGroupResult = 0;
-	L0721_B_GroupOnPartyMap = false;
-	L0722_B_FallKilledGroup = false;
-	L0723_B_DrawDungeonViewWhileFalling = false;
-	L0724_B_DestinationIsTeleporterTarget = false;
-	L0725_B_PartySquare = false;
-	L0726_B_Audible = false;
+	bool L0721_B_GroupOnPartyMap = false;
+	bool L0722_B_FallKilledGroup = false;
+	bool L0723_B_DrawDungeonViewWhileFalling = false;
+	bool L0724_B_DestinationIsTeleporterTarget = false;
+	bool L0725_B_PartySquare = false;
+	bool L0726_B_Audible = false;
+
+	uint16 L0717_ui_ThingCell = 0;
 	if (thing != Thing::_party) {
-		L0710_i_ThingType = (thing).getType();
-		L0717_ui_ThingCell = (thing).getCell();
+		L0710_i_ThingType = thing.getType();
+		L0717_ui_ThingCell = thing.getCell();
 		L0713_B_ThingLevitates = f264_isLevitating(thing);
 	}
 	/* If moving the party or a creature on the party map from a dungeon square then check for a projectile impact */
@@ -263,9 +254,12 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 			return true; /* The specified group thing cannot be moved because it was killed by a projectile impact */
 		}
 	}
+	uint16 L0714_ui_MapIndexSource = 0;
+	uint16 L0715_ui_MapIndexDestination = 0;
 	if (destMapX >= 0) {
 		L0714_ui_MapIndexSource = L0715_ui_MapIndexDestination = _vm->_dungeonMan->_g272_currMapIndex;
 		L0721_B_GroupOnPartyMap = (L0714_ui_MapIndexSource == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX >= 0);
+		uint16 L0716_ui_Direction = 0;
 		if (thing == Thing::_party) {
 			_vm->_dungeonMan->_g306_partyMapX = destMapX;
 			_vm->_dungeonMan->_g307_partyMapY = destMapY;
@@ -321,7 +315,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 							thing = f263_getTeleporterRotatedProjectileThing(L0712_ps_Teleporter, thing);
 						} else {
 							if (!(L0712_ps_Teleporter->getAbsoluteRotation()) && (mapX != -2)) {
-								thing = M15_thingWithNewCell(thing, M21_normalizeModulo4((thing).getCell() + L0712_ps_Teleporter->getRotation()));
+								thing = M15_thingWithNewCell(thing, M21_normalizeModulo4(thing.getCell() + L0712_ps_Teleporter->getRotation()));
 							}
 						}
 					}
@@ -381,7 +375,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 						L0716_ui_Direction = _vm->_dungeonMan->f155_getStairsExitDirection(destMapX, destMapY);
 						destMapX += _vm->_dirIntoStepCountEast[L0716_ui_Direction], destMapY += _vm->_dirIntoStepCountNorth[L0716_ui_Direction];
 						L0716_ui_Direction = returnOppositeDir((direction)L0716_ui_Direction);
-						AL0727_ui_ThingCell = (thing).getCell();
+						AL0727_ui_ThingCell = thing.getCell();
 						AL0727_ui_ThingCell = M21_normalizeModulo4((((AL0727_ui_ThingCell - L0716_ui_Direction + 1) & 0x0002) >> 1) + L0716_ui_Direction);
 						thing = M15_thingWithNewCell(thing, AL0727_ui_ThingCell);
 					} else
@@ -401,7 +395,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 		_g397_moveResultMapX = destMapX;
 		_g398_moveResultMapY = destMapY;
 		_g399_moveResultMapIndex = L0715_ui_MapIndexDestination;
-		_g401_moveResultCell = (thing).getCell();
+		_g401_moveResultCell = thing.getCell();
 		L0725_B_PartySquare = (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) && (destMapX == mapX) && (destMapY == mapY);
 		if (L0725_B_PartySquare) {
 			if (thing == Thing::_party) {
@@ -481,7 +475,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					f265_createEvent60to61_moveGroup(thing, destMapX, destMapY, L0715_ui_MapIndexDestination, L0726_B_Audible);
 					return true; /* The specified group thing cannot be moved because the party or another group is on the destination square */
 				}
-				L1638_ui_MovementSoundIndex = f514_getSound(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[(thing).getIndex()]._type);
+				L1638_ui_MovementSoundIndex = f514_getSound(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[thing.getIndex()]._type);
 				if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) {
 					warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 				}
@@ -530,7 +524,7 @@ bool MovesensMan::f264_isLevitating(Thing thing) {
 	int16 L0695_i_ThingType;
 
 
-	if ((L0695_i_ThingType = (thing).getType()) == k4_GroupThingType) {
+	if ((L0695_i_ThingType = thing.getType()) == k4_GroupThingType) {
 		return getFlag(_vm->_dungeonMan->f144_getCreatureAttributes(thing), k0x0020_MaskCreatureInfo_levitation);
 	}
 	if (L0695_i_ThingType == k14_ProjectileThingType) { /* BUG0_26 An explosion may fall in a pit. If a pit is opened while there is an explosion above then the explosion falls into the pit in F0267_MOVE_GetMoveResult_CPSCE. Explosions are not considered as levitating so they are moved when the pit is opened. This function should return true for explosions */
@@ -767,7 +761,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 
 
 	if (thing != Thing::_party) {
-		L0767_i_ThingType = (thing).getType();
+		L0767_i_ThingType = thing.getType();
 		L0774_i_ObjectType = _vm->_objectMan->f32_getObjectType(thing);
 	} else {
 		L0767_i_ThingType = kM1_PartyThingType;
@@ -777,7 +771,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 		_vm->_dungeonMan->f164_unlinkThingFromList(thing, Thing(0), mapX, mapY);
 	}
 	if (Square(L0777_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType() == k0_ElementTypeWall) {
-		L0770_ui_SensorTriggeredCell = (thing).getCell();
+		L0770_ui_SensorTriggeredCell = thing.getCell();
 	} else {
 		L0770_ui_SensorTriggeredCell = (uint16)kM1_CellAny; // this will wrap around
 	}
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index c312be1..97240bc 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -254,7 +254,7 @@ uint16 ProjExpl::f216_projectileGetImpactAttack(Projectile* projectile, Thing th
 	_g367_projectileAttackType = k3_attackType_BLUNT;
 
 	L0484_ui_KineticEnergy = projectile->_kineticEnergy;
-	if ((AL0483_ui_ThingType = (thing).getType()) != k15_ExplosionThingType) {
+	if ((AL0483_ui_ThingType = thing.getType()) != k15_ExplosionThingType) {
 		if (AL0483_ui_ThingType == k5_WeaponThingType) {
 			L0485_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(thing);
 			AL0483_ui_Attack = L0485_ps_WeaponInfo->_kineticEnergy;


Commit: c8f6666480361e972032fe3f12a618b08815bc4f
    https://github.com/scummvm/scummvm/commit/c8f6666480361e972032fe3f12a618b08815bc4f
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove some more extra parenthesis, remove a useless call to c_str()

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 823a37f..1177034 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -201,7 +201,7 @@ int16 ChampionMan::f279_getDecodedValue(char *string, uint16 characterCount) {
 }
 
 void ChampionMan::f289_drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) {
-	Common::String tmp = f288_getStringFromInteger(currVal, true, 3).c_str();
+	Common::String tmp = f288_getStringFromInteger(currVal, true, 3);
 	_vm->_textMan->f52_printToViewport(55, posY, k13_ColorLightestGray, tmp.c_str());
 	_vm->_textMan->f52_printToViewport(73, posY, k13_ColorLightestGray, "/");
 	tmp = f288_getStringFromInteger(maxVal, true, 3);
@@ -781,7 +781,8 @@ int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
 		clearFlag(woundIndex, k0x8000_maskUseSharpDefense);
 	}
 	for (L0943_ui_ArmourShieldDefense = 0, AL0942_i_SlotIndex = k0_ChampionSlotReadyHand; AL0942_i_SlotIndex <= k1_ChampionSlotActionHand; AL0942_i_SlotIndex++) {
-		if ((L0945_T_Thing = L0946_ps_Champion->_slots[AL0942_i_SlotIndex]).getType() == k6_ArmourThingType) {
+		L0945_T_Thing = L0946_ps_Champion->_slots[AL0942_i_SlotIndex];
+		if (L0945_T_Thing.getType() == k6_ArmourThingType) {
 			L0947_ps_ArmourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing);
 			L0947_ps_ArmourInfo = &g239_ArmourInfo[((Armour *)L0947_ps_ArmourInfo)->getType()];
 			if (getFlag(L0947_ps_ArmourInfo->_attributes, k0x0080_ArmourAttributeIsAShield)) {
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 3c03749..8cb1496 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1513,7 +1513,7 @@ T0165026:
 								}
 								_vm->_dungeonMan->f173_setCurrentMap(L0284_i_CurrentMapIndex);
 								G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex;
-								return Thing((L0278_T_Thing).getTypeAndIndex());
+								return Thing(L0278_T_Thing.getTypeAndIndex());
 							}
 						}
 					} while ((L0278_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0278_T_Thing)) != Thing::_endOfList);


Commit: 9272b18329de0a13a095f26b27a18c4a9023f485
    https://github.com/scummvm/scummvm/commit/9272b18329de0a13a095f26b27a18c4a9023f485
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix typo in comment

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 8cb1496..e1a964f 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -886,7 +886,7 @@ T0172010_ClosedFakeWall:
 						aspectArray[sideIndex + 1] = _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex + 1;
 /* BUG0_76 The same text is drawn on multiple sides of a wall square. The engine stores only a
 single text to draw on a wall in a global variable. Even if different texts are placed on
-differents sides of the wall, the same text is drawn on each affected side */
+different sides of the wall, the same text is drawn on each affected side */
 						_vm->_displayMan->_g290_inscriptionThing = thing;
 					}
 				} else {


Commit: 1f73323113c4194a8bc0ef41fcce88a1b8e37bd8
    https://github.com/scummvm/scummvm/commit/1f73323113c4194a8bc0ef41fcce88a1b8e37bd8
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add proper keyboard input handling

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/inventory.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 1177034..2a2047e 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -824,8 +824,8 @@ void ChampionMan::f314_wakeUp() {
 	_vm->_displayMan->f98_drawFloorAndCeiling();
 	_vm->_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface;
 	_vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
-	warning("MISSING CODE: set G0443_ps_PrimaryKeyboardInput");
-	warning("MISSING CODE: G0444_ps_SecondaryKeyboardInput");
+	_vm->_eventMan->_g443_primaryKeyboardInput = g458_primaryKeyboardInput_interface;
+	_vm->_eventMan->_g444_secondaryKeyboardInput = g459_secondaryKeyboardInput_movement;
 	_vm->_eventMan->f357_discardAllInput();
 	_vm->_menuMan->f457_drawEnabledMenus();
 }
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index f591399..d6a4a26 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -240,7 +240,8 @@ void DMEngine::f462_startGame() {
 
 	_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface;
 	_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
-	warning("MISSING CODE: set primary/secondary keyboard input");
+	_eventMan->_g443_primaryKeyboardInput = g458_primaryKeyboardInput_interface;
+	_eventMan->_g444_secondaryKeyboardInput = g459_secondaryKeyboardInput_movement;
 
 	f3_processNewPartyMap(_dungeonMan->_g309_partyMapIndex);
 
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index da7da40..e5db995 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -87,6 +87,50 @@ Box g462_BoxObjectPiles[4] = { // @ G0462_as_Graphic561_Box_ObjectPiles
 	Box(112, 183, 122, 147),   /* Back right */
 	Box(40, 111, 122, 147)}; /* Back left */
 
+
+KeyboardInput g458_primaryKeyboardInput_interface[7] = { // @ G0458_as_Graphic561_PrimaryKeyboardInput_Interface
+														 /* { Command, Code } */
+	KeyboardInput(k7_CommandToggleInventoryChampion_0, Common::KEYCODE_F1, 0), /* F1 (<CSI>1~) Atari ST: Code = 0x3B00 */
+	KeyboardInput(k8_CommandToggleInventoryChampion_1, Common::KEYCODE_F2, 0), /* F2 (<CSI>2~) Atari ST: Code = 0x3C00 */
+	KeyboardInput(k9_CommandToggleInventoryChampion_2, Common::KEYCODE_F3, 0), /* F3 (<CSI>3~) Atari ST: Code = 0x3D00 */
+	KeyboardInput(k10_CommandToggleInventoryChampion_3, Common::KEYCODE_F4, 0), /* F4 (<CSI>4~) Atari ST: Code = 0x3E00 */
+	KeyboardInput(k140_CommandSaveGame, Common::KEYCODE_s, Common::KBD_CTRL), /* CTRL-S       Atari ST: Code = 0x0013 */
+	KeyboardInput(k147_CommandFreezeGame, Common::KEYCODE_ESCAPE, 0), /* Esc (0x1B)   Atari ST: Code = 0x001B */
+	KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)};
+
+
+KeyboardInput g459_secondaryKeyboardInput_movement[19] = { // @ G0459_as_Graphic561_SecondaryKeyboardInput_Movement
+														   /* { Command, Code } */
+	KeyboardInput(k1_CommandTurnLeft, Common::KEYCODE_KP4, 0), /* Numeric pad 4 Atari ST: Code = 0x5200 */
+	KeyboardInput(k3_CommandMoveForward, Common::KEYCODE_KP5, 0), /* Numeric pad 5 Atari ST: Code = 0x4800 */
+	KeyboardInput(k2_CommandTurnRight, Common::KEYCODE_KP6, 0), /* Numeric pad 6 Atari ST: Code = 0x4700 */
+	KeyboardInput(k6_CommandMoveLeft, Common::KEYCODE_KP1, 0), /* Numeric pad 1 Atari ST: Code = 0x4B00 */
+	KeyboardInput(k5_CommandMoveBackward, Common::KEYCODE_KP2, 0), /* Numeric pad 2 Atari ST: Code = 0x5000 */
+	KeyboardInput(k4_CommandMoveRight, Common::KEYCODE_KP3, 0), /* Numeric pad 3 Atari ST: Code = 0x4D00. Remaining entries below not present */
+	KeyboardInput(k3_CommandMoveForward, Common::KEYCODE_w, 0), /* Up Arrow (<CSI>A) */ /*Differs for testing convenience*/
+	KeyboardInput(k3_CommandMoveForward, Common::KEYCODE_w, Common::KBD_SHIFT), /* Shift Up Arrow (<CSI>T) */ /*Differs for testing convenience*/
+	KeyboardInput(k6_CommandMoveLeft, Common::KEYCODE_a, 0), /* Backward Arrow (<CSI>D) */ /*Differs for testing convenience*/
+	KeyboardInput(k6_CommandMoveLeft, Common::KEYCODE_a, Common::KBD_SHIFT), /* Shift Forward Arrow (<CSI> A) */ /*Differs for testing convenience*/
+	KeyboardInput(k4_CommandMoveRight, Common::KEYCODE_d, 0), /* Forward Arrow (<CSI>C) */ /*Differs for testing convenience*/
+	KeyboardInput(k4_CommandMoveRight, Common::KEYCODE_d, Common::KBD_SHIFT), /* Shift Backward Arrow (<CSI> @) */ /*Differs for testing convenience*/
+	KeyboardInput(k5_CommandMoveBackward, Common::KEYCODE_s, 0), /* Down arrow (<CSI>B) */ /*Differs for testing convenience*/
+	KeyboardInput(k5_CommandMoveBackward, Common::KEYCODE_s, Common::KBD_SHIFT), /* Shift Down arrow (<CSI>S) */ /*Differs for testing convenience*/
+	KeyboardInput(k1_CommandTurnLeft, Common::KEYCODE_q, 0), /* Del (0x7F) */ /*Differs for testing convenience*/
+	KeyboardInput(k1_CommandTurnLeft, Common::KEYCODE_q, Common::KBD_SHIFT), /* Shift Del (0x7F) */ /*Differs for testing convenience*/
+	KeyboardInput(k2_CommandTurnRight, Common::KEYCODE_e, 0), /* Help (<CSI>?~) */ /*Differs for testing convenience*/
+	KeyboardInput(k2_CommandTurnRight, Common::KEYCODE_e, Common::KBD_SHIFT), /* Shift Help (<CSI>?~) */ /*Differs for testing convenience*/
+	KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)};
+KeyboardInput g460_primaryKeyboardInput_partySleeping[3] = { // @ G0460_as_Graphic561_PrimaryKeyboardInput_PartySleeping
+															 /* { Command, Code } */
+	KeyboardInput(k146_CommandWakeUp, Common::KEYCODE_RETURN, 0), /* Return */
+	KeyboardInput(k147_CommandFreezeGame, Common::KEYCODE_ESCAPE, 0), /* Esc */
+	KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)};
+KeyboardInput g461_primaryKeyboardInput_frozenGame[2] = { // @ G0461_as_Graphic561_PrimaryKeyboardInput_FrozenGame
+														  /* { Command, Code } */
+	KeyboardInput(k148_CommandUnfreezeGame, Common::KEYCODE_ESCAPE, 0), /* Esc */
+	KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)};
+
+
 MouseInput g445_PrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
 												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(k200_CommandEntranceEnterDungeon, 244, 298,  45,  58, k1_LeftMouseButton),
@@ -309,6 +353,8 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 	_g600_useObjectAsMousePointerBitmap = false;
 	_g601_useHandAsMousePointerBitmap = false;
 	_gK100_preventBuildPointerScreenArea = false;
+	_g443_primaryKeyboardInput = nullptr;
+	_g444_secondaryKeyboardInput = nullptr;
 }
 
 EventManager::~EventManager() {
@@ -486,45 +532,36 @@ void EventManager::setMousePos(Common::Point pos) {
 
 
 void EventManager::processInput() {
-	DungeonMan &dungeonMan = *_vm->_dungeonMan;
-
 	Common::Event event;
 	while (_vm->_system->getEventManager()->pollEvent(event)) {
 		switch (event.type) {
-		// DUMMY CODE: case EVENT_KEYDOWN, only for testing
-		case Common::EVENT_KEYDOWN:
+		case Common::EVENT_KEYDOWN: {
 			if (event.synthetic)
 				break;
-
-			switch (event.kbd.keycode) {
-			case Common::KEYCODE_w:
-				dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
-				break;
-			case Common::KEYCODE_a:
-				dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
-				break;
-			case Common::KEYCODE_s:
-				dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
-				break;
-			case Common::KEYCODE_d:
-				dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
-				break;
-			case Common::KEYCODE_q:
-				turnDirLeft(dungeonMan._g308_partyDir);
-				break;
-			case Common::KEYCODE_e:
-				turnDirRight(dungeonMan._g308_partyDir);
-				break;
-			case Common::KEYCODE_UP:
-				if (_dummyMapIndex < 13)
-					dungeonMan.f174_setCurrentMapAndPartyMap(++_dummyMapIndex);
-				break;
-			case Common::KEYCODE_DOWN:
-				if (_dummyMapIndex > 0)
-					dungeonMan.f174_setCurrentMapAndPartyMap(--_dummyMapIndex);
-				break;
-			default:
-				break;
+			if (_g443_primaryKeyboardInput) {
+				KeyboardInput *input = _g443_primaryKeyboardInput;
+				while (input->_commandToIssue != k0_CommandNone) {
+					if ((input->_key == event.kbd.keycode) && (input->_modifiers == (event.kbd.flags & input->_modifiers))) {
+						f360_processPendingClick(); // possible fix to BUG0_73
+						_commandQueue.push(Command(Common::Point(-1, -1), input->_commandToIssue));
+						break;
+					}
+					input++;
+				}
+			}
+			
+			if (_g444_secondaryKeyboardInput) {
+				KeyboardInput *input = _g444_secondaryKeyboardInput;
+				while (input->_commandToIssue != k0_CommandNone) {
+					if ((input->_key == event.kbd.keycode) && (input->_modifiers == (event.kbd.flags & input->_modifiers))) {
+						f360_processPendingClick(); // possible fix to BUG0_73
+						_commandQueue.push(Command(Common::Point(-1, -1), input->_commandToIssue));
+						break;
+					}
+					input++;
+				}
+			}
+			
 			}
 		case Common::EVENT_MOUSEMOVE:
 			_mousePos = event.mouse;
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index d1ded67..eafb64e 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -202,13 +202,21 @@ extern MouseInput* g480_PrimaryMouseInput_DialogSets[2][4]; // @ G0480_aaps_Prim
 
 class KeyboardInput {
 public:
-	Command _commandToIssue;
+	CommandType _commandToIssue;
 	Common::KeyCode _key;
 	byte _modifiers;
 
-	KeyboardInput(Command command, Common::KeyCode keycode, byte modifierFlags) : _commandToIssue(command), _key(keycode), _modifiers(modifierFlags) {}
+	KeyboardInput(CommandType command, Common::KeyCode keycode, byte modifierFlags) : _commandToIssue(command), _key(keycode), _modifiers(modifierFlags) {}
 }; // @ KEYBOARD_INPUT
 
+
+
+extern KeyboardInput g458_primaryKeyboardInput_interface[7];
+extern KeyboardInput g459_secondaryKeyboardInput_movement[19];
+extern KeyboardInput g460_primaryKeyboardInput_partySleeping[3];
+extern KeyboardInput g461_primaryKeyboardInput_frozenGame[2];
+
+
 class DMEngine;
 
 #define k0_pointerArrow 0 // @ C0_POINTER_ARROW 
@@ -258,6 +266,8 @@ public:
 	bool _g326_refreshMousePointerInMainLoop; // @ G0326_B_RefreshMousePointerInMainLoop
 	bool _g341_highlightBoxEnabled; // @ G0341_B_HighlightBoxEnabled
 	uint16 _g599_useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap
+	KeyboardInput *_g443_primaryKeyboardInput; // @ G0443_ps_PrimaryKeyboardInput
+	KeyboardInput *_g444_secondaryKeyboardInput; // @ G0444_ps_SecondaryKeyboardInput
 
 	void initMouse();
 	void f67_setMousePointerToNormal(int16 mousePointer); // @ F0067_MOUSE_SetPointerToNormal
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index c1d2aed..3da4956 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -88,7 +88,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 			_vm->_menuMan->f395_drawMovementArrows();
 			_vm->_eventMan->f77_hideMouse();
 			_vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
-			warning("MISSING CODE: setting G0444_ps_SecondaryKeyboardInput");
+			_vm->_eventMan->_g444_secondaryKeyboardInput = g459_secondaryKeyboardInput_movement;
 			_vm->_eventMan->f357_discardAllInput();
 			_vm->_displayMan->f98_drawFloorAndCeiling();
 			return;
@@ -115,7 +115,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
 	_vm->_eventMan->f77_hideMouse();
 	_vm->_eventMan->_g442_secondaryMouseInput = g449_SecondaryMouseInput_ChampionInventory;
-	warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput");
+	_vm->_eventMan->_g444_secondaryKeyboardInput = nullptr;
 	_vm->_eventMan->f357_discardAllInput();
 }
 


Commit: 14bef5326a0c9939c3a8d669ffba7e2d86ddf295
    https://github.com/scummvm/scummvm/commit/14bef5326a0c9939c3a8d669ffba7e2d86ddf295
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add warning with repeat parameter

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/projexpl.cpp
    engines/dm/text.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 2a2047e..dc77567 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -157,7 +157,7 @@ bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16
 			return false;
 		}
 	}
-	warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+	warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 	f325_decrementStamine(champIndex, f305_getThrowingStaminaCost(L0996_T_Thing));
 	f330_disableAction(champIndex, 4);
 	AL0994_i_Experience = 8;
@@ -887,7 +887,7 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex,
 	int16 L0922_i_BaseSkillLevel;
 
 
-	warning("potaneitally dangerous cast of uint32 below");
+	warning(false, "potaneitally dangerous cast of uint32 below");
 	if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && ((uint32)_vm->_projexpl->_g361_lastCreatureAttackTime < (_vm->_g313_gameTime - 150))) {
 		exp >>= 1;
 	}
@@ -902,7 +902,7 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex,
 			L0916_ui_BaseSkillIndex = skillIndex;
 		}
 		AL0915_ui_SkillLevelBefore = f303_getSkillLevel(champIndex, L0916_ui_BaseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
-		warning("potentially dangerous cast of uint32 below");
+		warning(false, "potentially dangerous cast of uint32 below");
 		if ((skillIndex >= k4_ChampionSkillSwing) && ((uint32)_vm->_projexpl->_g361_lastCreatureAttackTime > (_vm->_g313_gameTime - 25))) {
 			exp <<= 1;
 		}
@@ -1145,7 +1145,7 @@ ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
 
 void ChampionMan::f278_resetDataToStartGame() {
 	if (!_vm->_g298_newGame) {
-		warning("MISSING CODE: stuff for resetting for loaded games");
+		warning(false, "MISSING CODE: stuff for resetting for loaded games");
 		assert(false);
 	}
 
@@ -1401,7 +1401,7 @@ uint16 ChampionMan::f306_getStaminaAdjustedValue(Champion *champ, int16 val) {
 	int16 currStamina = champ->_currStamina;
 	int16 halfMaxStamina = champ->_maxStamina / 2;
 	if (currStamina < halfMaxStamina) {
-		warning("Possible undefined behavior in the original code");
+		warning(false, "Possible undefined behavior in the original code");
 		val /= 2;
 		return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina;
 	}
@@ -1693,7 +1693,7 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
 }
 
 void ChampionMan::f281_renameChampion(Champion* champ) {
-	warning("STUB METHOD: Champion::renameChampion, F0281_CHAMPION_Rename");
+	warning(false, "STUB METHOD: Champion::renameChampion, F0281_CHAMPION_Rename");
 
 	DisplayMan &dispMan = *_vm->_displayMan;
 	TextMan &textMan = *_vm->_textMan;
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index d6a4a26..cf75acb 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -37,6 +37,8 @@
 #include "graphics/palette.h"
 #include "common/file.h"
 #include "common/events.h"
+#include "common/array.h"
+#include "common/algorithm.h"
 
 #include "dm/dm.h"
 #include "gfx.h"
@@ -54,6 +56,24 @@
 #include "projexpl.h"
 
 namespace DM {
+void warning(bool repeat, const char* s, ...) {
+	va_list va;
+
+	va_start(va, s);
+	Common::String output = Common::String::vformat(s, va);
+	va_end(va);
+
+	if (repeat) {
+		::warning(output.c_str());
+	} else {
+		static Common::Array<Common::String> stringsPrinted;
+
+		if (Common::find(stringsPrinted.begin(), stringsPrinted.end(), s) == stringsPrinted.end()) {
+			stringsPrinted.push_back(output);
+			::warning(output.c_str());
+		}
+	}
+}
 
 void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
 void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); }
@@ -151,7 +171,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	debug("DMEngine::DMEngine");
 
 
-	warning("DUMMY CODE: setting _g298_newGame to true, should be in processEntrance");
+	warning(false, "DUMMY CODE: setting _g298_newGame to true, should be in processEntrance");
 	_g298_newGame = true;
 }
 
@@ -200,7 +220,7 @@ void DMEngine::f463_initializeGame() {
 	_eventMan->initMouse();
 	//F0441_STARTEND_ProcessEntrance();
 	while (_loadsaveMan->f435_loadgame() != k1_LoadgameSuccess) {
-		warning("TODO: F0441_STARTEND_ProcessEntrance");
+		warning(false, "TODO: F0441_STARTEND_ProcessEntrance");
 	}
 	//F0396_MENUS_LoadSpellAreaLinesBitmap() is not needed, every bitmap has been loaded
 
@@ -216,7 +236,7 @@ void DMEngine::f463_initializeGame() {
 }
 
 void DMEngine::f448_initMemoryManager() {
-	warning("STUB FUNCTION");
+	warning(false, "STUB FUNCTION");
 	for (uint16 i = 0; i < 16; ++i)
 		_displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i];
 }
@@ -246,7 +266,7 @@ void DMEngine::f462_startGame() {
 	f3_processNewPartyMap(_dungeonMan->_g309_partyMapIndex);
 
 	if (!_g298_newGame) {
-		warning("TODO: loading game");
+		warning(false, "TODO: loading game");
 		assert(false);
 	} else {
 		_displayMan->_g578_useByteBoxCoordinates = false;
@@ -255,7 +275,7 @@ void DMEngine::f462_startGame() {
 		_displayMan->D24_fillScreenBox(g63_boxScreenBottom, k0_ColorBlack);
 	}
 
-	warning("TODO: build copper");
+	warning(false, "TODO: build copper");
 	_menuMan->f395_drawMovementArrows();
 	_championMan->f278_resetDataToStartGame();
 	_g301_gameTimeTicking = true;
@@ -293,20 +313,20 @@ Common::Error DMEngine::run() {
 	f463_initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
 	while (true) {
 		f2_gameloop();
-		warning("TODO: F0444_STARTEND_Endgame(G0303_B_PartyDead);");
+		warning(false, "TODO: F0444_STARTEND_Endgame(G0303_B_PartyDead);");
 	}
 
 	return Common::kNoError;
 }
 
 void DMEngine::f2_gameloop() {
-	warning("DUMMY CODE SETTING PARTY POS AND DIRECTION");
+	warning(false, "DUMMY CODE SETTING PARTY POS AND DIRECTION");
 	_dungeonMan->_g306_partyMapX = 10;
 	_dungeonMan->_g307_partyMapY = 4;
 	_dungeonMan->_g308_partyDir = kDirNorth;
-	warning("DUMMY CODE: setting InventoryMan::_g432_inventoryChampionOrdinal to zero");
+	warning(false, "DUMMY CODE: setting InventoryMan::_g432_inventoryChampionOrdinal to zero");
 	_inventoryMan->_g432_inventoryChampionOrdinal = 0;
-	warning("DUMMY CODE: clearing screen to black"); // in loop below
+	warning(false, "DUMMY CODE: clearing screen to black"); // in loop below
 
 	while (true) {
 		if (_g327_newPartyMapIndex != kM1_mapIndexNone) {
@@ -331,7 +351,7 @@ T0002002:
 				_eventMan->f78_showMouse();
 				_eventMan->f68_setPointerToObject(_objectMan->_g412_objectIconForMousePointer);
 				_eventMan->f77_hideMouse();
-				
+
 			}
 			if (_eventMan->_g326_refreshMousePointerInMainLoop) {
 				_eventMan->_g326_refreshMousePointerInMainLoop = false;
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index d0bc378..1b4850a 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -50,7 +50,7 @@ class GroupMan;
 class Timeline;
 class ProjExpl;
 
-
+void warning(bool repeat, const char *s, ...);
 
 enum direction {
 	kDirNorth = 0,
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index e1a964f..8100139 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -475,7 +475,7 @@ void DungeonMan::f455_decompressDungeonFile() {
 			}
 		}
 	} else {
-		warning("TODO: if the dungeon is uncompressed, read it here");
+		warning(false, "TODO: if the dungeon is uncompressed, read it here");
 	}
 	f.close();
 }
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index e5db995..ad6bd30 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -412,7 +412,7 @@ void EventManager::f68_setPointerToObject(byte* bitmap) {
 	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, g44_palChangesMousePointerIcon);
 	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
 	*/
-	warning("TODO - Call f129_blitToBitmapShrinkWithPalChange");
+	warning(false, "TODO - Call f129_blitToBitmapShrinkWithPalChange");
 	// dummy code
 	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
 	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
@@ -797,7 +797,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 			L1151_ps_Junk = (Junk*)_vm->_dungeonMan->f157_getSquareFirstThingData(L1155_i_MapX, L1156_i_MapY);
 			if ((((Door*)L1151_ps_Junk)->hasButton()) && _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
 				_vm->_g321_stopWaitingForPlayerInput = true;
-				warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+				warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 				_vm->_movsens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1);
 				return;
 			}
@@ -954,7 +954,7 @@ void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) {
 			return;
 		commandType = f358_getCommandTypeFromMouseInput(g456_MouseInput_PanelChest, Common::Point(x, y), k1_LeftMouseButton);
 		if (commandType != k0_CommandNone)
-			warning("MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox");
+			warning(false, "MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox");
 		break;
 	case k5_PanelContentResurrectReincarnate:
 		if (!champMan._g415_leaderEmptyHanded)
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index e90b3a3..bf07cd6 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -703,7 +703,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_g99_bitmapWall_D0R_Native = nullptr;
 
 	_g322_paletteSwitchingEnabled = false;
-	warning("DUMMY CODE: setting _g304_dungeonViewPaletteIndex");
+	warning(false, "DUMMY CODE: setting _g304_dungeonViewPaletteIndex");
 	_g304_dungeonViewPaletteIndex = 0;
 
 	g186_doorFrame_D1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
@@ -815,8 +815,8 @@ void DisplayMan::f460_initializeGraphicData() {
 	_g709_bitmapWallSet_DoorFrameFront = new byte[32 * 123];
 	_g296_bitmapViewport = new byte[224 * 136];
 
-	warning("SKIPPED CODE: G0086_puc_Bitmap_ViewportBlackArea it is useless");
-	warning("SKIPPED CODE: G0087_puc_Bitmap_ViewportFloorArea it is useless");
+	warning(false, "SKIPPED CODE: G0086_puc_Bitmap_ViewportBlackArea it is useless");
+	warning(false, "SKIPPED CODE: G0087_puc_Bitmap_ViewportFloorArea it is useless");
 
 	if (!_g639_derivedBitmapByteCount)
 		_g639_derivedBitmapByteCount = new uint16[k730_DerivedBitmapMaximumCount];
@@ -1050,7 +1050,7 @@ void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* to
 }
 
 void DisplayMan::f566_viewportBlitToScreen() {
-	warning("MISSING FUNCTIONALITY: using correct colorpalette");
+	warning(false, "MISSING FUNCTIONALITY: using correct colorpalette");
 	Box box(0, 223, 33, 33 + 135);
 
 	f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport, k160_byteWidthScreen, kM1_ColorNoTransparency);
@@ -1144,7 +1144,7 @@ void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte*
 													int16 lastUnitIndex, int16 firstUnitIndex, int16 destByteWidth, Color transparent,
 													int16 xPos, int16 yPos, int16 destHeight, int16 height2) {
 		 // make sure to take care of inclusive boundaries
-	warning("STUB FUNCTION: does nothing at all");
+	warning(false, "STUB FUNCTION: does nothing at all");
 }
 
 
@@ -2045,7 +2045,7 @@ void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) {
 							  _g296_bitmapViewport, g106_BoxThievesEye_ViewPortVisibleArea, 0, 0,
 							  48, k112_byteWidthViewport, k9_ColorGold, 95, k136_heightViewport); /* BUG0_74 */
 			f493_addDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea);
-			warning("MISSING CODE: F0480_CACHE_ReleaseBlock");
+			warning(false, "MISSING CODE: F0480_CACHE_ReleaseBlock");
 		}
 		return;
 	case k17_DoorFrontElemType:
@@ -2265,7 +2265,7 @@ void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) {
 }
 
 void DisplayMan::f98_drawFloorAndCeiling() {
-	warning("f98_drawFloorAndCeiling doesn't do anything");
+	warning(false, "f98_drawFloorAndCeiling doesn't do anything");
 	_g297_drawFloorAndCeilingRequested = false;
 }
 
@@ -2711,9 +2711,9 @@ void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) {
 	}
 
 	// byte *bitmap = dispMan.f489_getNativeBitmapOrGraphic(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex);
-	warning("MISSING CODE: F0133_VIDEO_BlitBoxFilledWithMaskedBitmap");
+	warning(false, "MISSING CODE: F0133_VIDEO_BlitBoxFilledWithMaskedBitmap");
 
-	warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache, F0493_CACHE_AddDerivedBitmap, F0480_CACHE_ReleaseBlock");
+	warning(false, "IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache, F0493_CACHE_AddDerivedBitmap, F0480_CACHE_ReleaseBlock");
 }
 
 int16 DisplayMan::f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale) {
@@ -3109,7 +3109,7 @@ T0115015_DrawProjectileAsObject:
 						if (flipHorizontal) {
 							f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, M77_getNormalizedByteWidth(byteWidth), heightRedEagle);
 						}
-						warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+						warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 					}
 				}
 				AL_4_xPos = coordinateSet[0];
@@ -3341,7 +3341,7 @@ T0115077_DrawSecondHalfSquareCreature:
 							memmove(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * 2 * heightRedEagle * sizeof(byte));
 							f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 						}
-						warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+						warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 					}
 				}
 			}
@@ -3371,7 +3371,7 @@ T0115077_DrawSecondHalfSquareCreature:
 				bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 				AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 				f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, sourceByteWidth * 2, sourceHeight, byteWidth * 2, heightRedEagle, paletteChanges);
-				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+				warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 			}
 			if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */
 				(useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) ||
@@ -3513,7 +3513,7 @@ continue;
 							f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect *)objectAspect)->_byteWidth * 2, ((ProjectileAspect *)objectAspect)->_height,
 																 byteWidth * 2, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
 							if (doNotScaleWithKineticEnergy) {
-								warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap");
+								warning(false, "IGNORED CODE F0493_CACHE_AddDerivedBitmap");
 							}
 						}
 					}
@@ -3627,7 +3627,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 						AL_4_explosionAspectIndex++; /* Use third graphic in the pattern for large explosion attack */
 					}
 				}
-				warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache");
+				warning(false, "IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache");
 				AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice);
 				if (smoke) {
 					f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, 48, 32, 48, 32, g212_PalChangeSmoke);
@@ -3636,8 +3636,8 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 				f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, nullptr, f492_getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C,
 												   _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64),
 												   224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
-				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
-				warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+				warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+				warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 			} else {
 				if (rebirthExplosion) {
 					explosionCoordinates = g227_RebirthStep2ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
@@ -3736,7 +3736,7 @@ byte* DisplayMan::f492_getDerivedBitmap(int16 derivedBitmapIndex) {
 }
 
 void DisplayMan::f493_addDerivedBitmap(int16 derivedBitmapIndex) {
-	warning("f493_addDerivedBitmap DOES NOTHING");
+	warning(false, "f493_addDerivedBitmap DOES NOTHING");
 }
 
 }
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index f2b2fda..ffd466f 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -145,7 +145,7 @@ void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThin
 			_vm->_movsens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
 		} while ((L0365_T_CurrentThing = L0366_T_NextThing) != Thing::_endOfList);
 		if (mode >= k0_soundModePlayImmediately) {
-			warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 		}
 	}
 }
@@ -256,7 +256,7 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX
 		L0358_T_Thing = M15_thingWithNewCell(L0358_T_Thing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell);
 		_vm->_movsens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY);
 	}
-	warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+	warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 }
 
 int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
@@ -888,7 +888,7 @@ T0209089_DoubleSquareMove:
 							AL0450_i_DestinationMapX = eventMapX;
 							AL0451_i_DestinationMapY = eventMapY;
 							AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2;
-							warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+							warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 							goto T0209061_MoveGroup;
 						}
 					}
@@ -1269,7 +1269,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 				if (getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) && (L0331_ui_CreatureType == k18_CreatureTypeAnimatedArmourDethKnight)) {
 					if (_vm->getRandomNumber(2)) {
 						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-						warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+						warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 					}
 				} else {
 					if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) {
@@ -1291,7 +1291,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
 						L1635_ui_SoundIndex = _vm->_movsens->f514_getSound(k13_CreatureTypeCouatl);
 						if (L1635_ui_SoundIndex <= k34_D13_soundCount) {
-							warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+							warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 						}
 					}
 				} else {
@@ -1318,7 +1318,7 @@ void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 crea
 	static ActiveGroup *G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup;
 
 
-	warning("potentially dangerous cast to uint32 below");
+	warning(false, "potentially dangerous cast to uint32 below");
 	if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == (uint32)G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) {
 		return;
 	}
@@ -1336,7 +1336,7 @@ void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 crea
 }
 
 void GroupMan::f208_groupAddEvent(TimelineEvent *event, uint32 time) {
-	warning("potentially dangerous cast to uint32 below");
+	warning(false, "potentially dangerous cast to uint32 below");
 	if (time < (uint32)M30_time(event->_mapTime)) {
 		event->_type -= 5;
 		event->_C._ticks = M30_time(event->_mapTime) - time;
@@ -1484,7 +1484,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 		AL0440_i_KineticEnergy = (L0441_ps_CreatureInfo->_attack >> 2) + 1;
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
-		warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+		warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 		_vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
 	} else {
 		if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) {
@@ -1512,7 +1512,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 		}
 	}
 	if (AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal) {
-		warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+		warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 	}
 	return true;
 }
@@ -1635,7 +1635,7 @@ int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) {
 			AL0558_i_Attack -= _vm->getRandomNumber((AL0558_i_Attack >> 1) + 1) - 1;
 		}
 		if (AL0558_i_Damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType)) {
-			warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 			if ((AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack) && _vm->getRandomNumber(2) && ((AL0559_ui_PoisonAttack = _vm->_championMan->f307_getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack)) >= 0)) {
 				_vm->_championMan->f322_championPoison(champIndex, AL0559_ui_PoisonAttack);
 			}
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 3da4956..41e325a 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -97,7 +97,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	_vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(championIndex);
 	if (!AL1102_ui_InventoryChampionOrdinal) {
-		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+		warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 	}
 	L1103_ps_Champion = &_vm->_championMan->_gK71_champions[championIndex];
 	_vm->_displayMan->f466_loadIntoBitmap(k17_InventoryGraphicIndice, _vm->_displayMan->_g296_bitmapViewport);
@@ -177,7 +177,7 @@ void InventoryMan::f346_drawPanelResurrectReincarnate() {
 }
 
 void InventoryMan::f347_drawPanel() {
-	warning("possible reintroduction of BUG0_48");
+	warning(false, "possible reintroduction of BUG0_48");
 	f334_closeChest(); // possibility of BUG0_48
 
 	ChampionMan &cm = *_vm->_championMan;
@@ -235,7 +235,7 @@ void InventoryMan::f334_closeChest() {
 }
 
 void InventoryMan::f340_drawPanelScrollTextLine(int16 yPos, char* text) {
-	warning("CHANGE5_03_IMPROVEMENT");
+	warning(false, "CHANGE5_03_IMPROVEMENT");
 	for (char* iter = text; *iter != '\0'; ++iter) {
 		if ((*iter >= 'A') && (*iter <= 'Z')) {
 			*iter -= 64;
@@ -261,7 +261,7 @@ void InventoryMan::f341_drawPanelScroll(Scroll* scroll) {
 	charRed++;
 	char *charGreen = charRed; // first char of the second line
 	while (*charGreen) {
-		warning("BUG0_47");
+		warning(false, "BUG0_47");
 		/* BUG0_47 Graphical glitch when you open a scroll. If there is a single line of text in a scroll
 		(with no carriage return) then charGreen points to undefined data. This may result in a graphical
 		glitch and also corrupt other memory. This is not an issue in the original dungeons where all
@@ -300,7 +300,7 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo
 	if (_g426_openChest == thingToOpen)
 		return;
 
-	warning("CHANGE8_09_FIX");
+	warning(false, "CHANGE8_09_FIX");
 	if (_g426_openChest != Thing::_none)
 		f334_closeChest(); // CHANGE8_09_FIX
 
@@ -314,7 +314,7 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo
 	Thing thing = chest->getSlot();
 	int16 thingCount = 0;
 	while (thing != Thing::_endOfList) {
-		warning("CHANGE8_08_FIX");
+		warning(false, "CHANGE8_08_FIX");
 		if (++thingCount > 8)
 			break; // CHANGE8_08_FIX, make sure that no more than the first 8 objects in a chest are drawn
 
@@ -428,7 +428,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 	TextMan &textMan = *_vm->_textMan;
 
 	if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) {
-		warning("BUG0_48 The contents of a chest are reorganized when an object with a statistic modifier is placed or removed on a champion");
+		warning(false, "BUG0_48 The contents of a chest are reorganized when an object with a statistic modifier is placed or removed on a champion");
 		f334_closeChest();
 	}
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 1338130..d63cab0 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -117,24 +117,24 @@ T0386006:
 	box2._y2 = 110;
 	dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 8, k160_byteWidthScreen, kM1_ColorNoTransparency);
 	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) {
-		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+		warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 	}
 }
 
 void MenuMan::f456_drawDisabledMenu() {
 	if (!_vm->_championMan->_g300_partyIsSleeping) {
-		warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
+		warning(false, "MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 			if (_vm->_inventoryMan->_g424_panelContent == k4_PanelContentChest) {
 				_vm->_inventoryMan->f334_closeChest();
 			}
 		} else {
-			warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+			warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 		}
-		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
-		warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
-		warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal");
+		warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+		warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+		warning(false, "MISSING CODE: F0067_MOUSE_SetPointerToNormal");
 	}
 }
 
@@ -175,7 +175,7 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
 	if (_g508_refreshActionArea) {
 		if (!champMan._g506_actingChampionOrdinal) {
 			if (_g513_actionDamage) {
-				warning("MISSING CODE: F0385_MENUS_DrawActionDamage");
+				warning(false, "MISSING CODE: F0385_MENUS_DrawActionDamage");
 				_g513_actionDamage = 0;
 			} else {
 				_g509_actionAreaContainsIcons = true;
@@ -185,7 +185,7 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
 			_g509_actionAreaContainsIcons = false;
 			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
 			champMan.f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal));
-			warning("MISSING CODE: F0387_MENUS_DrawActionArea");
+			warning(false, "MISSING CODE: F0387_MENUS_DrawActionArea");
 		}
 	}
 }
@@ -198,7 +198,7 @@ void MenuMan::f387_drawActionArea() {
 	ChampionMan &champMan = *_vm->_championMan;
 	TextMan &textMan = *_vm->_textMan;
 
-	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+	warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 	dispMan._g578_useByteBoxCoordinates = false;
 	dispMan.D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack);
 	if (_g509_actionAreaContainsIcons) {
@@ -221,7 +221,7 @@ void MenuMan::f387_drawActionArea() {
 												k12_ActionNameMaximumLength, k200_heightScreen);
 		}
 	}
-	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+	warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer");
 	_g508_refreshActionArea = false;
 }
 
@@ -251,26 +251,26 @@ void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) {
 	int16 champCurrHealth[4];
 	for (uint16 i = 0; i < 4; ++i)
 		champCurrHealth[i] = champMan._gK71_champions[i]._currHealth;
-	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+	warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 	dispMan.D24_fillScreenBox(g504_BoxSpellAreaControls, k0_ColorBlack);
 	int16 champCount = champMan._g305_partyChampionCount;
 	switch (champIndex) {
 	case k0_ChampionFirst:
-		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		textMan.f53_printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		if (champCount) {
 			if (champCurrHealth[1]) {
-				warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+				warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
 			}
 labelChamp2:
 			if (champCount > 2) {
 				if (champCurrHealth[2]) {
-					warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+					warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
 				}
 labelChamp3:
 				if (champCount > 3) {
 					if (champCurrHealth[3]) {
-						warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+						warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
 					}
 				}
 			}
@@ -278,36 +278,36 @@ labelChamp3:
 		break;
 	case k1_ChampionSecond:
 		if (champCurrHealth[0]) {
-			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+			warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		}
-		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		textMan.f53_printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		goto labelChamp2;
 	case k2_ChampionThird:
 		if (champCurrHealth[0]) {
-			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+			warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		}
 		if (champCurrHealth[1]) {
-			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+			warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		}
-		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		textMan.f53_printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		goto labelChamp3;
 	case k3_ChampionFourth:
 		if (champCurrHealth[0]) {
-			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+			warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		}
 		if (champCurrHealth[1]) {
-			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+			warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		}
 		if (champCurrHealth[2]) {
-			warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+			warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		}
-		warning("MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
 		textMan.f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		break;
 	}
-	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+	warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 
 #define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
@@ -350,28 +350,28 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 		|| ((champIndex != kM1_ChampionNone) && !champMan._gK71_champions[champIndex]._currHealth))
 		return;
 	if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) {
-		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+		warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), dispMan._g348_bitmapScreen, g0_BoxSpellArea, 0, 0,
 								  48, k160_byteWidthScreen, kM1_ColorNoTransparency);
-		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+		warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer");
 	}
 	if (champIndex == kM1_ChampionNone) {
 		champMan._g514_magicCasterChampionIndex = kM1_ChampionNone;
-		warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+		warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 		dispMan._g578_useByteBoxCoordinates = false;
 		dispMan.D24_fillScreenBox(g0_BoxSpellArea, k0_ColorBlack);
-		warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+		warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer");
 		return;
 	}
 
 	champMan._g514_magicCasterChampionIndex = (ChampionIndex)champIndex;
 	f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
-	warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+	warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
 	f393_drawSpellAreaControls((ChampionIndex)champIndex);
 	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK75_BoxSpellAreaLine2, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency);
 	f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols);
 	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency);
-	warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+	warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer");
 }
 
 void MenuMan::f457_drawEnabledMenus() {
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index da8c5e5..f154053 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -181,7 +181,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 			if (!L0753_B_DoNotTriggerSensor) {
 				L0759_B_AtLeastOneSensorWasTriggered = true;
 				if (L0755_ps_Sensor->getAudibleA()) {
-					warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+					warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 				}
 				if (!_vm->_championMan->_g415_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
 					L0754_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0761_T_LeaderHandObject);
@@ -296,7 +296,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					_vm->_dungeonMan->_g306_partyMapX = destMapX;
 					_vm->_dungeonMan->_g307_partyMapY = destMapY;
 					if (L0712_ps_Teleporter->isAudible()) {
-						warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+						warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 					}
 					L0723_B_DrawDungeonViewWhileFalling = true;
 					if (L0712_ps_Teleporter->getAbsoluteRotation()) {
@@ -307,7 +307,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				} else {
 					if (L0710_i_ThingType == k4_GroupThingType) {
 						if (L0712_ps_Teleporter->isAudible()) {
-							warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+							warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 						}
 						L0720_ui_MoveGroupResult = f262_getTeleporterRotatedGroupResult(L0712_ps_Teleporter, thing, L0714_ui_MapIndexSource);
 					} else {
@@ -349,7 +349,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 								}
 							} else {
 								if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF)) {
-									warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+									warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 								}
 							}
 						}
@@ -477,7 +477,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				}
 				L1638_ui_MovementSoundIndex = f514_getSound(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[thing.getIndex()]._type);
 				if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) {
-					warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+					warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 				}
 				if (L0721_B_GroupOnPartyMap && (L0715_ui_MapIndexDestination != _vm->_dungeonMan->_g309_partyMapIndex)) { /* If the group leaves the party map */
 					_vm->_groupMan->f184_removeActiveGroup(AL0708_i_ActiveGroupIndex);
@@ -899,7 +899,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 					goto T0276079;
 			}
 			if (L0769_ps_Sensor->getAudibleA()) {
-				warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+				warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 			}
 			f272_sensorTriggerEffect(L0769_ps_Sensor, L0778_i_Effect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
 			goto T0276079;
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 97240bc..94d9d21 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -230,7 +230,7 @@ T0217004:
 				AL0507_ui_SoundIndex = k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM;
 			}
 		}
-		warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+		warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 	}
 T0217044:
 	if (L0509_B_RemovePotion) {
@@ -321,10 +321,10 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 	L0470_ps_Explosion->setType(explThing.toUint16() - Thing::_firstExplosion.toUint16());
 	L0470_ps_Explosion->setAttack(attack);
 	if (explThing.toUint16() < Thing::_explHarmNonMaterial.toUint16()) {
-		warning("MISING CODE: F0064_SOUND_RequestPlay_CPSD");
+		warning(false, "MISING CODE: F0064_SOUND_RequestPlay_CPSD");
 	} else {
 		if (explThing != Thing::_explSmoke) {
-			warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 		}
 	}
 	_vm->_dungeonMan->f163_linkThingToList(L0473_T_Thing, Thing(0), AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY);
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 4329cb3..eff2447 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -137,9 +137,9 @@ void TextMan::f45_messageAreaCreateNewRow() {
 	uint16 L0029_ui_RowIndex;
 
 	if (_g358_messageAreaCursorRow == 3) {
-		warning("MISSING CODE: F0561_SCROLLER_IsTextScrolling");
+		warning(false, "MISSING CODE: F0561_SCROLLER_IsTextScrolling");
 		memset(_g356_bitmapMessageAreaNewRow, k0_ColorBlack, 320 * 7);
-		warning("MISSING CODE: F0560_SCROLLER_SetCommand");
+		warning(false, "MISSING CODE: F0560_SCROLLER_SetCommand");
 		for (L0029_ui_RowIndex = 0; L0029_ui_RowIndex < 3; L0029_ui_RowIndex++) {
 			_g360_messageAreaRowExpirationTime[L0029_ui_RowIndex] = _g360_messageAreaRowExpirationTime[L0029_ui_RowIndex + 1];
 		}
@@ -153,13 +153,13 @@ void TextMan::f46_messageAreaPrintString(Color color, const char* string) {
 	int16 L0030_i_StringLength;
 
 	L0030_i_StringLength = strlen(string);
-	warning("MISSING CODE: F0561_SCROLLER_IsTextScrolling");
+	warning(false, "MISSING CODE: F0561_SCROLLER_IsTextScrolling");
 	if (true) { // there is a test here with F0561_SCROLLER_IsTextScrolling
 		_vm->_textMan->f53_printToLogicalScreen(_g359_messageAreaCursorColumn * 6, (_g358_messageAreaCursorRow * 7) + 177, color, k0_ColorBlack, string);
 	} else {
 		f40_printTextToBitmap(_g356_bitmapMessageAreaNewRow, k160_byteWidthScreen, _g359_messageAreaCursorColumn * 6, 5, color, k0_ColorBlack, string, 7);
-		warning("MISSING CODE: F0561_SCROLLER_IsTextScrolling");
-		warning("MISSING CODE: F0560_SCROLLER_SetCommand");
+		warning(false, "MISSING CODE: F0561_SCROLLER_IsTextScrolling");
+		warning(false, "MISSING CODE: F0560_SCROLLER_SetCommand");
 	}
 	_g359_messageAreaCursorColumn += L0030_i_StringLength;
 	_g360_messageAreaRowExpirationTime[_g358_messageAreaCursorRow] = _vm->_g313_gameTime + 200;


Commit: 9c79d02a1fb7c30cd47a8c0392b05642f2be12a3
    https://github.com/scummvm/scummvm/commit/9c79d02a1fb7c30cd47a8c0392b05642f2be12a3
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing code to command move party

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index dc77567..6973d0f 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -176,8 +176,8 @@ bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16
 	AL0994_i_Attack = f26_getBoundedValue((uint16)40, (uint16)((AL0995_i_SkillLevel << 3) + _vm->_rnd->getRandomNumber(31)), (uint16)200);
 	AL0995_i_StepEnergy = MAX(5, 11 - AL0995_i_SkillLevel);
 	_vm->_projexpl->f212_projectileCreate(L0996_T_Thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY,
-							M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + side),
-							_vm->_dungeonMan->_g308_partyDir, L0993_i_KineticEnergy, AL0994_i_Attack, AL0995_i_StepEnergy);
+										  M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + side),
+										  _vm->_dungeonMan->_g308_partyDir, L0993_i_KineticEnergy, AL0994_i_Attack, AL0995_i_StepEnergy);
 	_vm->_g311_projectileDisableMovementTicks = 4;
 	_vm->_g312_lastProjectileDisabledMovementDirection = _vm->_dungeonMan->_g308_partyDir;
 	f292_drawChampionState((ChampionIndex)champIndex);
@@ -1102,12 +1102,12 @@ void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount
 				if (!L0956_B_CycleCountDefined) {
 					L0956_B_CycleCountDefined = true;
 					if (L0955_B_Merge) {
-						cycleCount = MAX((int32)_vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount);
+						cycleCount = MAX((int32)_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount);
 					} else {
-						cycleCount = MIN(80, _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount);
+						cycleCount = MIN(80, _g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount);
 					}
 				}
-				_vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount;
+				_g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount;
 			}
 		}
 	}
@@ -1117,8 +1117,10 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer)
 	if (thing == Thing::_none) {
 		return;
 	}
-	_vm->_championMan->_g415_leaderEmptyHanded = false;
-	_vm->_objectMan->f36_extractIconFromBitmap(_vm->_championMan->_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_vm->_championMan->_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
+	_g415_leaderEmptyHanded = false;
+	_vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
+
+
 	_vm->_eventMan->f78_showMouse();
 	_vm->_objectMan->f34_drawLeaderObjectName(thing);
 	if (setMousePointer) {
@@ -1127,11 +1129,38 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer)
 		_vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
 	}
 	_vm->_eventMan->f77_hideMouse();
-	if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) {
-		_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing);
-		setFlag(_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
-		_vm->_championMan->f292_drawChampionState(_vm->_championMan->_g411_leaderIndex);
+	if (_g411_leaderIndex != kM1_ChampionNone) {
+		_gK71_champions[_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing);
+		setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
+		f292_drawChampionState(_g411_leaderIndex);
+	}
+}
+
+int16 ChampionMan::f310_getMovementTicks(Champion* champ) {
+	uint16 L0931_ui_Multiple;
+#define AL0931_ui_Load       L0931_ui_Multiple
+#define AL0931_ui_WoundTicks L0931_ui_Multiple
+	uint16 L0932_ui_MaximumLoad;
+	int16 L0933_i_Ticks;
+
+
+	if ((L0932_ui_MaximumLoad = _vm->_championMan->f309_getMaximumLoad(champ)) > (AL0931_ui_Load = champ->_load)) { /* BUG0_72 The party moves very slowly even though no champion 'Load' value is drawn in red. When the Load of a champion has exactly the maximum value he can carry then the Load is drawn in yellow but the speed is the same as when the champion is overloaded (when the Load is drawn in red). The comparison operator should be >= instead of > */
+		L0933_i_Ticks = 2;
+		if (((int32)AL0931_ui_Load << 3) > ((int32)L0932_ui_MaximumLoad * 5)) {
+			L0933_i_Ticks++;
+		}
+		AL0931_ui_WoundTicks = 1;
+	} else {
+		L0933_i_Ticks = 4 + (((AL0931_ui_Load - L0932_ui_MaximumLoad) << 2) / L0932_ui_MaximumLoad);
+		AL0931_ui_WoundTicks = 2;
 	}
+	if (getFlag(champ->_wounds, k0x0020_ChampionWoundFeet)) {
+		L0933_i_Ticks += AL0931_ui_WoundTicks;
+	}
+	if (_vm->_objectMan->f33_getIconIndex(champ->_slots[k5_ChampionSlotFeet]) == k194_IconIndiceArmourBootOfSpeed) {
+		L0933_i_Ticks--;
+	}
+	return L0933_i_Ticks;
 }
 
 ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
@@ -1156,180 +1185,180 @@ void ChampionMan::f278_resetDataToStartGame() {
 
 
 void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) {
-	DisplayMan &dispMan = *_vm->_displayMan;
-	DungeonMan &dunMan = *_vm->_dungeonMan;
-
-	if (!_g415_leaderEmptyHanded || _g305_partyChampionCount == 4)
+	Thing L0793_T_Thing;
+	uint16 L0794_ui_Multiple;
+#define AL0794_ui_ViewCell       L0794_ui_Multiple
+#define AL0794_ui_SlotIndex      L0794_ui_Multiple
+#define AL0794_ui_CharacterIndex L0794_ui_Multiple
+#define AL0794_ui_StatisticIndex L0794_ui_Multiple
+#define AL0794_ui_SkillIndex     L0794_ui_Multiple
+	int16 L0795_i_HiddenSkillIndex;
+	uint16 L0796_ui_Multiple;
+#define AL0796_ui_Character  L0796_ui_Multiple
+#define AL0796_ui_SkillValue L0796_ui_Multiple
+#define AL0796_ui_ThingType  L0796_ui_Multiple
+	Champion* L0797_ps_Champion;
+	char* L0798_pc_Character;
+	uint16 L0799_ui_PreviousPartyChampionCount;
+	uint16 L0800_ui_Multiple;
+#define AL0800_B_ChampionTitleCopied L0800_ui_Multiple
+#define AL0800_ui_HiddenSkillCounter L0800_ui_Multiple
+	uint16 L0801_ui_SlotIndex;
+	int16 L0802_i_MapX;
+	int16 L0803_i_MapY;
+	uint16 L0804_ui_ChampionObjectsCell;
+	int16 L0805_i_ObjectAllowedSlots;
+	int32 L0806_l_BaseSkillExperience;
+	char L0807_ac_DecodedChampionText[77];
+
+	if (!_vm->_championMan->_g415_leaderEmptyHanded) {
 		return;
-
-	uint16 prevChampCount = _g305_partyChampionCount;
-	Champion *champ = &_gK71_champions[prevChampCount];
-	champ->resetToZero();
-	dispMan._g578_useByteBoxCoordinates = true;
-	{ // limit destBox scope
-		Box &destBox = gBoxChampionPortrait;
-		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), champ->_portrait,
-								  destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 128, 16, kM1_ColorNoTransparency);
-	}
-
-	champ->_actionIndex = k255_ChampionActionNone;
-	champ->_enableActionEventIndex = -1;
-	champ->_hideDamageReceivedIndex = -1;
-	champ->_dir = dunMan._g308_partyDir;
-	ViewCell AL_0_viewCell = k0_ViewCellFronLeft;
-	while (f285_getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3)) != kM1_ChampionNone)
-		AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
-	champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3);
-	champ->clearAttributes(k0x0400_ChampionAttributeIcon);
-	champ->_directionMaximumDamageReceived = dunMan._g308_partyDir;
-	champ->_food = 1500 + _vm->_rnd->getRandomNumber(256);
-	champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
-	int16 AL_0_slotIndex_Red;
-	for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) {
-		champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none);
-	}
-	Thing thing = dunMan.f161_getSquareFirstThing(dunMan._g306_partyMapX, dunMan._g307_partyMapY);
-	while (thing.getType() != k2_TextstringType) {
-		thing = dunMan.f159_getNextThing(thing);
-	}
-	char decodedChampionText[77];
-	char* character_Green = decodedChampionText;
-	dunMan.f168_decodeText(character_Green, thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
-	int16 AL_0_characterIndex = 0;
-	uint16 AL_2_character;
-	while ((AL_2_character = *character_Green++) != '\n') {
-		champ->_name[AL_0_characterIndex++] = AL_2_character;
-	}
-	champ->_name[AL_0_characterIndex] = '\0';
-	AL_0_characterIndex = 0;
-	bool AL_4_champTitleCopied = false;
-	for (;;) { // infinite
-		AL_2_character = *character_Green++;
-		if (AL_2_character == '\n') {
-			if (AL_4_champTitleCopied)
-				break;
-			AL_4_champTitleCopied = true;
-		} else {
-			champ->_title[AL_0_characterIndex++] = AL_2_character;
-		}
-	}
-	champ->_title[AL_0_characterIndex] = '\0';
-	if (*character_Green++ == 'M') {
-		champ->setAttributeFlag(k0x0010_ChampionAttributeMale, true);
 	}
-	character_Green++;
-	champ->_currHealth = champ->_maxHealth = f279_getDecodedValue(character_Green, 4);
-	character_Green += 4;
-	champ->_currStamina = champ->_maxStamina = f279_getDecodedValue(character_Green, 4);
-	character_Green += 4;
-	champ->_currMana = champ->_maxMana = f279_getDecodedValue(character_Green, 4);
-	character_Green += 4;
-	character_Green++;
-
-	int16 AL_0_statisticIndex;
-	for (AL_0_statisticIndex = k0_ChampionStatLuck; AL_0_statisticIndex <= k6_ChampionStatAntifire; ++AL_0_statisticIndex) {
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k2_ChampionStatMinimum, 30);
-		uint16 currMaxVal = f279_getDecodedValue(character_Green, 2);
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent, currMaxVal);
-		champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k0_ChampionStatMaximum, currMaxVal);
-		character_Green += 2;
-	}
-
-	champ->setStatistic(k0_ChampionStatLuck, k2_ChampionStatMinimum, 10);
-	character_Green++;
-
-	int16 AL_0_skillIndex;
-	int16 AL_2_skillValue;
-	for (AL_0_skillIndex = k4_ChampionSkillSwing; AL_0_skillIndex <= k19_ChampionSkillWater; AL_0_skillIndex++) {
-		if ((AL_2_skillValue = *character_Green++ - 'A') > 0) {
-			champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue);
-		}
-	}
-
-	for (AL_0_skillIndex = k0_ChampionSkillFighter; AL_0_skillIndex <= k3_ChampionSkillWizard; ++AL_0_skillIndex) {
-		int32 baseSkillExp = 0;
-		int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2;
-		for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) {
-			baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience;
-		}
-		champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp);
+	if (_vm->_championMan->_g305_partyChampionCount == 4) {
+		return;
 	}
-
-	_g299_candidateChampionOrdinal = prevChampCount + 1;
-	if (++_g305_partyChampionCount == 1) {
+	L0797_ps_Champion = &_vm->_championMan->_gK71_champions[L0799_ui_PreviousPartyChampionCount = _vm->_championMan->_g305_partyChampionCount];
+	L0797_ps_Champion->resetToZero();
+	// Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portaits could be missing in the data)
+	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
+	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), L0797_ps_Champion->_portrait, gBoxChampionPortrait, _vm->_championMan->M27_getChampionPortraitX(championPortraitIndex), _vm->_championMan->M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency);
+	L0797_ps_Champion->_actionIndex = k255_ChampionActionNone;
+	L0797_ps_Champion->_enableActionEventIndex = -1;
+	L0797_ps_Champion->_hideDamageReceivedIndex = -1;
+	L0797_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
+	AL0794_ui_ViewCell = k0_ViewCellFronLeft;
+	while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone) {
+		AL0794_ui_ViewCell++;
+	}
+	L0797_ps_Champion->_cell = (ViewCell)M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir);
+	L0797_ps_Champion->_attributes = k0x0400_ChampionAttributeIcon;
+	L0797_ps_Champion->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir;
+	L0797_ps_Champion->_food = 1500 + _vm->getRandomNumber(256);
+	L0797_ps_Champion->_water = 1500 + _vm->getRandomNumber(256);
+	for (AL0794_ui_SlotIndex = k0_ChampionSlotReadyHand; AL0794_ui_SlotIndex < k30_ChampionSlotChest_1; AL0794_ui_SlotIndex++) {
+		L0797_ps_Champion->_slots[AL0794_ui_SlotIndex] = Thing::_none;
+	}
+	L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+	while ((L0793_T_Thing.getType()) != k2_TextstringType) {
+		L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing);
+	}
+	_vm->_dungeonMan->f168_decodeText(L0798_pc_Character = L0807_ac_DecodedChampionText, L0793_T_Thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
+	AL0794_ui_CharacterIndex = 0;
+	while ((AL0796_ui_Character = *L0798_pc_Character++) != '\n') { /* New line */
+		L0797_ps_Champion->_name[AL0794_ui_CharacterIndex++] = AL0796_ui_Character;
+	}
+	L0797_ps_Champion->_name[AL0794_ui_CharacterIndex] = '\0';
+	AL0794_ui_CharacterIndex = 0;
+	AL0800_B_ChampionTitleCopied = false;
+	for (;;) { /*_Infinite loop_*/
+		AL0796_ui_Character = *L0798_pc_Character++;
+		if (AL0796_ui_Character == '\n') { /* New line */
+			if (AL0800_B_ChampionTitleCopied)
+				break;
+			AL0800_B_ChampionTitleCopied = true;
+		} else {
+			L0797_ps_Champion->_title[AL0794_ui_CharacterIndex++] = AL0796_ui_Character;
+		}
+	}
+	L0797_ps_Champion->_title[AL0794_ui_CharacterIndex] = '\0';
+	if (*L0798_pc_Character++ == 'M') {
+		setFlag(L0797_ps_Champion->_attributes, k0x0010_ChampionAttributeMale);
+	}
+	L0798_pc_Character++;
+	L0797_ps_Champion->_currHealth = L0797_ps_Champion->_maxHealth = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4);
+	L0798_pc_Character += 4;
+	L0797_ps_Champion->_currStamina = L0797_ps_Champion->_maxStamina = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4);
+	L0798_pc_Character += 4;
+	L0797_ps_Champion->_currMana = L0797_ps_Champion->_maxMana = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4);
+	L0798_pc_Character += 4;
+	L0798_pc_Character++;
+	for (AL0794_ui_StatisticIndex = k0_ChampionStatLuck; AL0794_ui_StatisticIndex <= k6_ChampionStatAntifire; AL0794_ui_StatisticIndex++) {
+		L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k2_ChampionStatMinimum] = 30;
+		L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k1_ChampionStatCurrent] = L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k0_ChampionStatMaximum] = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 2);
+		L0798_pc_Character += 2;
+	}
+	L0797_ps_Champion->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10;
+	L0798_pc_Character++;
+	for (AL0794_ui_SkillIndex = k4_ChampionSkillSwing; AL0794_ui_SkillIndex <= k19_ChampionSkillWater; AL0794_ui_SkillIndex++) {
+		if ((AL0796_ui_SkillValue = *L0798_pc_Character++ - 'A') > 0) {
+			L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = 125L << AL0796_ui_SkillValue;
+		}
+	}
+	for (AL0794_ui_SkillIndex = k0_ChampionSkillFighter; AL0794_ui_SkillIndex <= k3_ChampionSkillWizard; AL0794_ui_SkillIndex++) {
+		L0806_l_BaseSkillExperience = 0;
+		L0795_i_HiddenSkillIndex = (AL0794_ui_SkillIndex + 1) << 2;
+		for (AL0800_ui_HiddenSkillCounter = 0; AL0800_ui_HiddenSkillCounter < 4; AL0800_ui_HiddenSkillCounter++) {
+			L0806_l_BaseSkillExperience += L0797_ps_Champion->_skills[L0795_i_HiddenSkillIndex + AL0800_ui_HiddenSkillCounter]._experience;
+		}
+		L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = L0806_l_BaseSkillExperience;
+	}
+	_vm->_championMan->_g299_candidateChampionOrdinal = L0799_ui_PreviousPartyChampionCount + 1;
+	if (++_vm->_championMan->_g305_partyChampionCount == 1) {
 		_vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst);
 		_vm->_menuMan->_g508_refreshActionArea = true;
 	} else {
 		_vm->_menuMan->f388_clearActingChampion();
-		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1));
-	}
-
-	int16 mapX = _vm->_dungeonMan->_g306_partyMapX;
-	int16 mapY = _vm->_dungeonMan->_g307_partyMapY;
-
-	uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._g308_partyDir));
-	mapX += _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
-	mapY += _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
-	thing = dunMan.f161_getSquareFirstThing(mapX, mapY);
-	AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1;
-	uint16 slotIndex_Green;
-	while (thing != Thing::_endOfList) {
-		ThingType AL_2_thingType = thing.getType();
-		if ((AL_2_thingType > k3_SensorThingType) && (thing.getCell() == championObjectsCell)) {
-			int16 objectAllowedSlots = g237_ObjectInfo[dunMan.f141_getObjectInfoIndex(thing)].getAllowedSlots();
-			switch (AL_2_thingType) {
+		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_vm->_championMan->_g305_partyChampionCount - 1));
+	}
+	L0802_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
+	L0803_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+	L0804_ui_ChampionObjectsCell = returnOppositeDir(_vm->_dungeonMan->_g308_partyDir);
+	L0802_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L0803_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+	L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0802_i_MapX, L0803_i_MapY);
+	AL0794_ui_SlotIndex = k13_ChampionSlotBackpackLine_1_1;
+	while (L0793_T_Thing != Thing::_endOfList) {
+		if (((AL0796_ui_ThingType = (L0793_T_Thing.getType())) > k3_SensorThingType) && ((L0793_T_Thing.getCell()) == L0804_ui_ChampionObjectsCell)) {
+			L0805_i_ObjectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0793_T_Thing)]._allowedSlots;
+			switch (AL0796_ui_ThingType) {
 			case k6_ArmourThingType:
-				for (slotIndex_Green = k2_ChampionSlotHead; slotIndex_Green <= k5_ChampionSlotFeet; slotIndex_Green++) {
-					if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
+				for (L0801_ui_SlotIndex = k2_ChampionSlotHead; L0801_ui_SlotIndex <= k5_ChampionSlotFeet; L0801_ui_SlotIndex++) {
+					if (L0805_i_ObjectAllowedSlots & gSlotMasks[L0801_ui_SlotIndex])
 						goto T0280048;
 				}
-				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) {
-					slotIndex_Green = k10_ChampionSlotNeck;
+				if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
+					L0801_ui_SlotIndex = k10_ChampionSlotNeck;
 				} else {
 					goto T0280046;
 				}
 				break;
 			case k5_WeaponThingType:
-				if (champ->getSlot(k1_ChampionSlotActionHand) == Thing::_none) {
-					slotIndex_Green = k1_ChampionSlotActionHand;
+				if (L0797_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) {
+					L0801_ui_SlotIndex = k1_ChampionSlotActionHand;
 				} else {
 					goto T0280046;
 				}
 				break;
 			case k7_ScrollThingType:
 			case k8_PotionThingType:
-				if (champ->getSlot(k11_ChampionSlotPouch_1) == Thing::_none) {
-					slotIndex_Green = k11_ChampionSlotPouch_1;
-				} else if (champ->getSlot(k6_ChampionSlotPouch_2) == Thing::_none) {
-					slotIndex_Green = k6_ChampionSlotPouch_2;
+				if (L0797_ps_Champion->_slots[k11_ChampionSlotPouch_1] == Thing::_none) {
+					L0801_ui_SlotIndex = k11_ChampionSlotPouch_1;
 				} else {
-					goto T0280046;
+					if (L0797_ps_Champion->_slots[k6_ChampionSlotPouch_2] == Thing::_none) {
+						L0801_ui_SlotIndex = k6_ChampionSlotPouch_2;
+					} else {
+						goto T0280046;
+					}
 				}
 				break;
 			case k9_ContainerThingType:
 			case k10_JunkThingType:
 T0280046:
-				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) {
-					slotIndex_Green = k10_ChampionSlotNeck;
+				if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
+					L0801_ui_SlotIndex = k10_ChampionSlotNeck;
 				} else {
-					slotIndex_Green = AL_0_slotIndex_Red++;
+					L0801_ui_SlotIndex = AL0794_ui_SlotIndex++;
 				}
-				break;
-
-			default:
-				break;
 			}
 T0280048:
-			if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_none) {
+			if (L0797_ps_Champion->_slots[L0801_ui_SlotIndex] != Thing::_none) {
 				goto T0280046;
 			}
-			f301_addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green);
+			_vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0799_ui_PreviousPartyChampionCount, L0793_T_Thing, (ChampionSlot)L0801_ui_SlotIndex);
 		}
-		thing = dunMan.f159_getNextThing(thing);
+		L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing);
 	}
-
-	_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)prevChampCount);
-	_vm->_menuMan->f456_drawDisabledMenu();
+	_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)L0799_ui_PreviousPartyChampionCount);
+	_vm->_menuMan->f456_drawDisabledMenu();;
 }
 
 void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
@@ -1446,7 +1475,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 
 
 	L0868_i_ChampionStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
-	L0865_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	L0865_ps_Champion = &_gK71_champions[champIndex];
 	L0862_ui_ChampionAttributes = L0865_ps_Champion->_attributes;
 	if (!getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand)) {
 		return;
@@ -1463,13 +1492,13 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 			for (uint16 i = 0; i < 3; ++i)
 				L0872_ai_NativeBitmapIndices[i] = 0;
 			AL0864_i_BorderCount = 0;
-			if (_vm->_championMan->_g407_party._fireShieldDefense > 0) {
+			if (_g407_party._fireShieldDefense > 0) {
 				L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k38_BorderPartyFireshieldIndice;
 			}
-			if (_vm->_championMan->_g407_party._spellShieldDefense > 0) {
+			if (_g407_party._spellShieldDefense > 0) {
 				L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k39_BorderPartySpellshieldIndice;
 			}
-			if ((_vm->_championMan->_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) {
+			if ((_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) {
 				L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k37_BorderPartyShieldIndice;
 			}
 			while (AL0864_i_BorderCount--) {
@@ -1491,7 +1520,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 	if (!(L0865_ps_Champion->_currHealth))
 		goto T0292042;
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle)) {
-		AL0864_i_ColorIndex = (champIndex == _vm->_championMan->_g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
+		AL0864_i_ColorIndex = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
 		if (L0863_B_IsInventoryChampion) {
 			_vm->_textMan->f52_printToViewport(3, 7, (Color)AL0864_i_ColorIndex, L0866_pc_ChampionName = L0865_ps_Champion->_name);
 			L0869_i_ChampionTitleX = 6 * strlen(L0866_pc_ChampionName) + 3;
@@ -1510,9 +1539,9 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		}
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics)) {
-		_vm->_championMan->f287_drawChampionBarGraphs(champIndex);
+		f287_drawChampionBarGraphs(champIndex);
 		if (L0863_B_IsInventoryChampion) {
-			_vm->_championMan->f290_drawHealthStaminaManaValues(L0865_ps_Champion);
+			f290_drawHealthStaminaManaValues(L0865_ps_Champion);
 			if ((L0865_ps_Champion->_food < 0) || (L0865_ps_Champion->_water < 0) || (L0865_ps_Champion->_poisonEventCount)) {
 				AL0870_i_NativeBitmapIndex = k34_SlotBoxWoundedIndice;
 			} else {
@@ -1532,14 +1561,14 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x2000_ChampionAttributeWounds)) {
 		for (AL0864_i_SlotIndex = L0863_B_IsInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL0864_i_SlotIndex >= k0_ChampionSlotReadyHand; AL0864_i_SlotIndex--) {
-			_vm->_championMan->f291_drawSlot(champIndex, AL0864_i_SlotIndex);
+			f291_drawSlot(champIndex, AL0864_i_SlotIndex);
 		}
 		if (L0863_B_IsInventoryChampion) {
 			setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
 		}
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0200_ChampionAttributeLoad) && L0863_B_IsInventoryChampion) {
-		if (L0865_ps_Champion->_load > (AL0864_i_Load = _vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion))) {
+		if (L0865_ps_Champion->_load > (AL0864_i_Load = f309_getMaximumLoad(L0865_ps_Champion))) {
 			AL0870_i_Color = k8_ColorRed;
 		} else {
 			if (((long)L0865_ps_Champion->_load << 3) > ((long)AL0864_i_Load * 5)) {
@@ -1550,28 +1579,28 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		}
 		_vm->_textMan->f52_printToViewport(104, 132, (Color)AL0870_i_Color, "LOAD ");
 		AL0864_i_Load = L0865_ps_Champion->_load / 10;
-		strcpy(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
+		strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
 		strcat(_vm->_g353_stringBuildBuffer, ".");
 		AL0864_i_Load = L0865_ps_Champion->_load - (AL0864_i_Load * 10);
-		strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str());
+		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str());
 		strcat(_vm->_g353_stringBuildBuffer, "/");
-		AL0864_i_Load = (_vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10;
-		strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
+		AL0864_i_Load = (f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10;
+		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
 		strcat(_vm->_g353_stringBuildBuffer, " KG");
 		_vm->_textMan->f52_printToViewport(148, 132, (Color)AL0870_i_Color, _vm->_g353_stringBuildBuffer);
 		setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
 	}
-	AL0864_i_ChampionIconIndex = _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir);
+	AL0864_i_ChampionIconIndex = M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir);
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL0864_i_ChampionIconIndex))) {
 		_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], g46_ChampionColor[champIndex]);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0800_ChampionAttributePanel) && L0863_B_IsInventoryChampion) {
 		if (_vm->_g333_pressingMouth) {
 			_vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned();
 		} else {
 			if (_vm->_g331_pressingEye) {
-				if (_vm->_championMan->_g415_leaderEmptyHanded) {
+				if (_g415_leaderEmptyHanded) {
 					_vm->_inventoryMan->f351_drawChampionSkillsAndStatistics();
 				}
 			} else {
@@ -1581,7 +1610,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x8000_ChampionAttributeActionHand)) {
-		_vm->_championMan->f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
+		f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
 		_vm->_menuMan->f386_drawActionIcon(champIndex);
 		if (L0863_B_IsInventoryChampion) {
 			setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 2dc4579..16c53c8 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -520,6 +520,7 @@ public:
 	void f316_deleteScent(uint16 scentIndex); // @ F0316_CHAMPION_DeleteScent
 	void f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount); // @ F0317_CHAMPION_AddScentStrength
 	void f297_putObjectInLeaderHand(Thing thing, bool setMousePointer); // @ F0297_CHAMPION_PutObjectInLeaderHand
+	int16 f310_getMovementTicks(Champion *champ); // @ F0310_CHAMPION_GetMovementTicks
 
 
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index cf75acb..fa94f25 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -326,7 +326,6 @@ void DMEngine::f2_gameloop() {
 	_dungeonMan->_g308_partyDir = kDirNorth;
 	warning(false, "DUMMY CODE: setting InventoryMan::_g432_inventoryChampionOrdinal to zero");
 	_inventoryMan->_g432_inventoryChampionOrdinal = 0;
-	warning(false, "DUMMY CODE: clearing screen to black"); // in loop below
 
 	while (true) {
 		if (_g327_newPartyMapIndex != kM1_mapIndexNone) {
@@ -337,13 +336,14 @@ T0002002:
 			_eventMan->f357_discardAllInput();
 		}
 
-		// MISSING: F0261_TIMELINE_Process_CPSEF
+		warning(false, "MISSING CODE: F0261_TIMELINE_Process_CPSEF");
 
 		if (_g327_newPartyMapIndex != kM1_mapIndexNone)
 			goto T0002002;
 
 		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
 			Box box(0, 223, 0, 135);
+			warning(false, "DUMMY CODE: clearing screen to black");
 			_displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // dummy code
 			_displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
 			if (_g325_setMousePointerToObjectInMainLoop) {
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index f9e21d4..0b01a44 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -644,7 +644,6 @@ class DungeonMan {
 	DungeonMan(const DungeonMan &other); // no implementation on purpose
 	void operator=(const DungeonMan &rhs); // no implementation on purpose
 
-	Square f151_getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare
 	Square f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare
 
 	void f455_decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon
@@ -660,6 +659,7 @@ public:
 	explicit DungeonMan(DMEngine *dmEngine);
 	~DungeonMan();
 
+	Square f151_getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare
 	void f173_setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
 	Thing f161_getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing
 	Thing f159_getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing)
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index ad6bd30..f57f986 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -416,7 +416,7 @@ void EventManager::f68_setPointerToObject(byte* bitmap) {
 	// dummy code
 	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
 	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
-	
+
 	_gK100_preventBuildPointerScreenArea = false;
 	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
 }
@@ -549,7 +549,7 @@ void EventManager::processInput() {
 					input++;
 				}
 			}
-			
+
 			if (_g444_secondaryKeyboardInput) {
 				KeyboardInput *input = _g444_secondaryKeyboardInput;
 				while (input->_commandToIssue != k0_CommandNone) {
@@ -561,8 +561,8 @@ void EventManager::processInput() {
 					input++;
 				}
 			}
-			
-			}
+
+		}
 		case Common::EVENT_MOUSEMOVE:
 			_mousePos = event.mouse;
 			break;
@@ -665,31 +665,114 @@ void EventManager::f365_commandTurnParty(CommandType cmdType) {
 }
 
 void EventManager::f366_commandMoveParty(CommandType cmdType) {
-	_vm->_g321_stopWaitingForPlayerInput = true;
-
-	// MISSING CODE: Lots of code
+	static Box g463_BoxMovementArrows[4] = { // @ G0463_as_Graphic561_Box_MovementArrows
+		/* { X1, X2, Y1, Y2 } */
+		Box(263, 289, 125, 145),   /* Forward */
+		Box(291, 318, 147, 167),   /* Right */
+		Box(263, 289, 147, 167),   /* Backward */
+		Box(234, 261, 147, 167)}; /* Left */
+
+	static int16 g465_movementArrowToStepForwardCount[4] = { // @ G0465_ai_Graphic561_MovementArrowToStepForwardCount
+		1,   /* Forward */
+		0,   /* Right */
+		-1,  /* Backward */
+		0}; /* Left */
+	static int16 g466_movementArrowToSepRightCount[4] = { // @ G0466_ai_Graphic561_MovementArrowToStepRightCount
+		0,    /* Forward */
+		1,    /* Right */
+		0,    /* Backward */
+		-1}; /* Left */
+
+	uint16 L1115_ui_Multiple;
+#define AL1115_ui_Square L1115_ui_Multiple
+#define AL1115_ui_Ticks  L1115_ui_Multiple
+	int16 L1116_i_SquareType;
+	int16 L1117_B_MovementBlocked;
+	uint16 L1118_ui_Multiple;
+#define AL1118_ui_ChampionIndex      L1118_ui_Multiple
+#define AL1118_ui_MovementArrowIndex L1118_ui_Multiple
+	Champion* L1119_ps_Champion;
+	Box* L1120_ps_Box;
+	int16 L1121_i_MapX;
+	int16 L1122_i_MapY;
+	bool L1123_B_StairsSquare;
+	int16 L1124_i_FirstDamagedChampionIndex;
+	int16 L1125_i_SecondDamagedChampionIndex;
 
-	// DUMMY CODE:
-	DungeonMan &dungeonMan = *_vm->_dungeonMan;
 
-	switch (cmdType) {
-	case k3_CommandMoveForward:
-		dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
-		break;
-	case k6_CommandMoveLeft:
-		dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
-		break;
-	case k5_CommandMoveBackward:
-		dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
-		break;
-	case k4_CommandMoveRight:
-		dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY);
-		break;
-	default:
-		break;
+	_vm->_g321_stopWaitingForPlayerInput = true;
+	L1119_ps_Champion = _vm->_championMan->_gK71_champions;
+	for (AL1118_ui_ChampionIndex = k0_ChampionFirst; AL1118_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL1118_ui_ChampionIndex++) {
+		_vm->_championMan->f325_decrementStamine(AL1118_ui_ChampionIndex, ((L1119_ps_Champion->_load * 3) / _vm->_championMan->f309_getMaximumLoad(L1119_ps_Champion)) + 1); /* BUG0_50 When a champion is brought back to life at a Vi Altar, his current stamina is lower than what it was before dying. Each time the party moves the current stamina of all champions is decreased, including for dead champions, by an amount that depends on the current load of the champion. For a dead champion the load before he died is used */
+		L1119_ps_Champion++;
 	}
-
-	// MISSING CODE: Lots of code
+	AL1118_ui_MovementArrowIndex = cmdType - k3_CommandMoveForward;
+	L1120_ps_Box = &g463_BoxMovementArrows[AL1118_ui_MovementArrowIndex];
+	warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+	L1123_B_StairsSquare = (Square(AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(L1121_i_MapX = _vm->_dungeonMan->_g306_partyMapX, L1122_i_MapY = _vm->_dungeonMan->_g307_partyMapY).toByte()).getType() == k3_ElementTypeStairs);
+	if (L1123_B_StairsSquare && (AL1118_ui_MovementArrowIndex == 2)) { /* If moving backward while in stairs */
+		f364_commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp));
+		return;
+	}
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(_vm->_dungeonMan->_g308_partyDir, g465_movementArrowToStepForwardCount[AL1118_ui_MovementArrowIndex], g466_movementArrowToSepRightCount[AL1118_ui_MovementArrowIndex], L1121_i_MapX, L1122_i_MapY);
+	L1116_i_SquareType = Square(AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(L1121_i_MapX, L1122_i_MapY).toByte()).getType();
+	if (L1116_i_SquareType == k3_ElementTypeStairs) {
+		_vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0);
+		_vm->_dungeonMan->_g306_partyMapX = L1121_i_MapX;
+		_vm->_dungeonMan->_g307_partyMapY = L1122_i_MapY;
+		f364_commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp));
+		return;
+	}
+	L1117_B_MovementBlocked = false;
+	if (L1116_i_SquareType == k0_ElementTypeWall) {
+		L1117_B_MovementBlocked = true;
+	} else {
+		if (L1116_i_SquareType == k4_DoorElemType) {
+			L1117_B_MovementBlocked = Square(AL1115_ui_Square).getDoorState();
+			L1117_B_MovementBlocked = (L1117_B_MovementBlocked != k0_doorState_OPEN) && (L1117_B_MovementBlocked != k1_doorState_FOURTH) && (L1117_B_MovementBlocked != k5_doorState_DESTROYED);
+		} else {
+			if (L1116_i_SquareType == k6_ElementTypeFakeWall) {
+				L1117_B_MovementBlocked = (!getFlag(AL1115_ui_Square, k0x0004_FakeWallOpen) && !getFlag(AL1115_ui_Square, k0x0001_FakeWallImaginary));
+			}
+		}
+	}
+	if (_vm->_championMan->_g305_partyChampionCount == 0) {
+	} else {
+		if (L1117_B_MovementBlocked) {
+			L1117_B_MovementBlocked = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(L1121_i_MapX, L1122_i_MapY, M21_normalizeModulo4(AL1118_ui_MovementArrowIndex += (_vm->_dungeonMan->_g308_partyDir + 2))), 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
+			if (L1124_i_FirstDamagedChampionIndex != (L1125_i_SecondDamagedChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(L1121_i_MapX, L1122_i_MapY, returnNextVal(AL1118_ui_MovementArrowIndex)))) {
+				L1117_B_MovementBlocked |= _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
+			}
+			if (L1117_B_MovementBlocked) {
+				warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			}
+		} else {
+			if (L1117_B_MovementBlocked = (_vm->_groupMan->f175_groupGetThing(L1121_i_MapX, L1122_i_MapY) != Thing::_endOfList)) {
+				_vm->_groupMan->f209_processEvents29to41(L1121_i_MapX, L1122_i_MapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
+			}
+		}
+	}
+	if (L1117_B_MovementBlocked) {
+		f357_discardAllInput();
+		_vm->_g321_stopWaitingForPlayerInput = false;
+		return;
+	}
+	if (L1123_B_StairsSquare) {
+		_vm->_movsens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, L1121_i_MapX, L1122_i_MapY);
+	} else {
+		_vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1121_i_MapX, L1122_i_MapY);
+	}
+	AL1115_ui_Ticks = 1;
+	L1119_ps_Champion = _vm->_championMan->_gK71_champions;
+	for (AL1118_ui_ChampionIndex = k0_ChampionFirst; AL1118_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL1118_ui_ChampionIndex++) {
+		if (L1119_ps_Champion->_currHealth) {
+			warning(false, "possibly dangerous cast to uint16");
+			AL1115_ui_Ticks = MAX(AL1115_ui_Ticks, (uint16)_vm->_championMan->f310_getMovementTicks(L1119_ps_Champion));
+		}
+		L1119_ps_Champion++;
+	}
+	_vm->_g310_disabledMovementTicks = AL1115_ui_Ticks;
+	_vm->_g311_projectileDisableMovementTicks = 0;
 }
 
 bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int16 posX, int16 posY) {
@@ -1052,4 +1135,11 @@ void EventManager::f357_discardAllInput() {
 	_commandQueue.clear();
 }
 
+void EventManager::f364_commandTakeStairs(bool stairsGoDown) {
+	_vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0);
+	_vm->_g327_newPartyMapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g309_partyMapIndex, stairsGoDown ? -1 : 1, &_vm->_dungeonMan->_g306_partyMapX, &_vm->_dungeonMan->_g307_partyMapY);
+	_vm->_dungeonMan->f173_setCurrentMap(_vm->_g327_newPartyMapIndex);
+	_vm->_championMan->f284_setPartyDirection(_vm->_dungeonMan->f155_getStairsExitDirection(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY));
+	_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
+}
 } // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index eafb64e..2c61d3e 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -296,6 +296,8 @@ public:
 	bool f360_hasPendingClick(Common::Point &point, MouseButton button); // @ F0360_COMMAND_ProcessPendingClick
 	void f379_drawSleepScreen(); // @ F0379_COMMAND_DrawSleepScreen
 	void f357_discardAllInput(); // @ F0357_COMMAND_DiscardAllInput
+	void f364_commandTakeStairs(bool stairsGoDown);// @ F0364_COMMAND_TakeStairs
+
 };
 
 }


Commit: 1baf135c2f3ea0214f539242935aa8a8d0705f1d
    https://github.com/scummvm/scummvm/commit/1baf135c2f3ea0214f539242935aa8a8d0705f1d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing code to command turn party

Changed paths:
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index f57f986..4f3ffc5 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -649,19 +649,20 @@ void EventManager::f380_processCommandQueue() {
 }
 
 void EventManager::f365_commandTurnParty(CommandType cmdType) {
-	_vm->_g321_stopWaitingForPlayerInput = true;
-
-	// MISSING CODE: highlight turn left/right buttons
-
-	// MISSING CODE: processing stairs
-
-	// MISSING CODE: process sensors
-
-	// DUMMY CODE: should call F0284_CHAMPION_SetPartyDirection instead
-	direction &partyDir = _vm->_dungeonMan->_g308_partyDir;
-	(cmdType == k1_CommandTurnLeft) ? turnDirLeft(partyDir) : turnDirRight(partyDir);
+	uint16 L1114_ui_Square;
 
-	// MISSING CODE: process sensors
+	_vm->_g321_stopWaitingForPlayerInput = true;
+	if (cmdType == k1_CommandTurnLeft) {
+		warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+	} else {
+	}
+	if (Square(L1114_ui_Square = _vm->_dungeonMan->f151_getSquare(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY).toByte()).getType() == k3_ElementTypeStairs) {
+		f364_commandTakeStairs(getFlag(L1114_ui_Square, k0x0004_StairsUp));
+		return;
+	}
+	_vm->_movsens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, false);
+	_vm->_championMan->f284_setPartyDirection(M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + ((cmdType == k2_CommandTurnRight) ? 1 : 3)));
+	_vm->_movsens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, true);
 }
 
 void EventManager::f366_commandMoveParty(CommandType cmdType) {
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index bf07cd6..8535718 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1376,44 +1376,44 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d
 void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIndex) {
 	static byte g200_palChangesDoorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 0, 130}; // @ G0200_auc_Graphic558_PaletteChanges_DoorOrnament_D3
 	static byte g201PalChangesDoorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0201_auc_Graphic558_PaletteChanges_DoorOrnament_D2
+#define AP0120_i_Height doorOrnOrdinal
+#define AP0121_i_ByteWidth viewDoorOrnIndex
+	int16 L0104_i_NativeBitmapIndex;
+	int16 coordSetGreenToad;
+	uint16* coordSetOrangeElk;
+	byte* L0107_puc_Multiple;
+#define AL0107_puc_Bitmap        L0107_puc_Multiple
+	byte* L0108_puc_Bitmap_Native;
 
 
-#define height doorOrnOrdinal
-#define byteWidth viewDoorOrnIndex
-
 	if (doorOrnOrdinal) {
 		doorOrnOrdinal--;
-		int16 nativeBitmapIndex = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex];
-		int16 coordSetGreenToad = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet];
-		uint16 *coordSetOrangeElk = g207_doorOrnCoordSets[coordSetGreenToad][viewDoorOrnIndex];
-		byte *bitmap = nullptr;
+		L0104_i_NativeBitmapIndex = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex];
+		coordSetOrangeElk = &g207_doorOrnCoordSets[coordSetGreenToad = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]][viewDoorOrnIndex][0];
 		if (viewDoorOrnIndex == k2_ViewDoorOrnament_D1LCR) {
-			bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
-			byteWidth = 48;
-			height = 88;
+			AL0107_puc_Bitmap = f489_getNativeBitmapOrGraphic(L0104_i_NativeBitmapIndex);
+			AP0121_i_ByteWidth = k48_byteWidth;
+			AP0120_i_Height = 88;
 		} else {
 			if (!f491_isDerivedBitmapInCache(doorOrnOrdinal = k68_DerivedBitmapFirstDoorOrnament_D3 + (doorOrnOrdinal * 2) + viewDoorOrnIndex)) {
-				uint16 *coordSetRedEagle = g207_doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR];
-				byte* bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(bitmapNative,
-													 f492_getDerivedBitmap(doorOrnOrdinal),
-													 coordSetRedEagle[4] << 1, coordSetRedEagle[5],
-													 coordSetOrangeElk[2] - coordSetOrangeElk[0] + 1,
-													 coordSetOrangeElk[5],
-													 (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2);
+				uint16 *coordSetRedEagle = &g207_doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR][0];
+				L0108_puc_Bitmap_Native = f489_getNativeBitmapOrGraphic(L0104_i_NativeBitmapIndex);
+				f129_blitToBitmapShrinkWithPalChange(L0108_puc_Bitmap_Native, f492_getDerivedBitmap(doorOrnOrdinal), coordSetRedEagle[4] << 1, coordSetRedEagle[5], coordSetOrangeElk[1] - coordSetOrangeElk[0] + 1, coordSetOrangeElk[5], (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2);
 				f493_addDerivedBitmap(doorOrnOrdinal);
 			}
-			bitmap = f492_getDerivedBitmap(doorOrnOrdinal);
+			AL0107_puc_Bitmap = f492_getDerivedBitmap(doorOrnOrdinal);
 			if (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) {
-				byteWidth = 24;
-				height = 41;
+				AP0121_i_ByteWidth = k24_byteWidth;
+				AP0120_i_Height = 41;
 			} else {
-				byteWidth = 32;
-				height = 61;
+				AP0121_i_ByteWidth = k32_byteWidth;
+				AP0120_i_Height = 61;
 			}
 		}
-		f132_blitToBitmap(bitmap, _g74_tmpBitmap,
-						  *(Box *)coordSetOrangeElk, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height);
+		{
+			Box box(coordSetOrangeElk[0], coordSetOrangeElk[1], coordSetOrangeElk[2], coordSetOrangeElk[3]);
+			f132_blitToBitmap(AL0107_puc_Bitmap, _g74_tmpBitmap, box, 0, 0, coordSetOrangeElk[4], AP0121_i_ByteWidth, k9_ColorGold, coordSetOrangeElk[5], AP0120_i_Height);
+		}
 	}
 }
 
@@ -1448,7 +1448,7 @@ void DisplayMan::f21_blitToScreen(byte *bitmap, int16* box, int16 byteWidth, Col
 	f21_blitToScreen(bitmap, &actualBox, byteWidth, transparent, height);
 }
 
-void DisplayMan::f21_blitToScreen(byte* bitmap, Box* box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal) {
+void DisplayMan::f21_blitToScreen(byte* bitmap, Box* box, int16 byteWidth, Color transparent, int16 height) {
 	_g578_useByteBoxCoordinates = false;
 	f132_blitToBitmap(bitmap, _g348_bitmapScreen, *box, 0, 0, byteWidth, k112_byteWidthViewport, transparent, height, k136_heightViewport);
 }


Commit: 9d1afe3022c607a47f73033371411b259114609d
    https://github.com/scummvm/scummvm/commit/9d1afe3022c607a47f73033371411b259114609d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix broken display of the leftmost champion

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 6973d0f..4a1508f 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1592,8 +1592,8 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 	}
 	AL0864_i_ChampionIconIndex = M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir);
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL0864_i_ChampionIconIndex))) {
-		_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], g46_ChampionColor[champIndex]);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
+		_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0864_i_ChampionIconIndex], g46_ChampionColor[champIndex]);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex], _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
 	}
 	if (getFlag(L0862_ui_ChampionAttributes, k0x0800_ChampionAttributePanel) && L0863_B_IsInventoryChampion) {
 		if (_vm->_g333_pressingMouth) {


Commit: 8c7760bd610173740e623eeac02bf0728488b1c4
    https://github.com/scummvm/scummvm/commit/8c7760bd610173740e623eeac02bf0728488b1c4
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add F0239_TIMELINE_ExtractFirstEvent

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dungeonman.h
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index fa94f25..86e7000 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -335,8 +335,7 @@ T0002002:
 			_g327_newPartyMapIndex = kM1_mapIndexNone;
 			_eventMan->f357_discardAllInput();
 		}
-
-		warning(false, "MISSING CODE: F0261_TIMELINE_Process_CPSEF");
+		_timeline->f261_processTimeline();
 
 		if (_g327_newPartyMapIndex != kM1_mapIndexNone)
 			goto T0002002;
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 0b01a44..a5c6ae2 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -527,6 +527,7 @@ public:
 	explicit Explosion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
 
 	Thing getNextThing() { return _nextThing; }
+	Thing setNextThing(Thing val) { return _nextThing = val; }
 	uint16 getType() { return _attributes & 0x7F; }
 	uint16 setType(uint16 val) { _attributes = (_attributes & ~0x7F) | (val & 0x7F); return (val & 0x7F); }
 	uint16 getAttack() { return (_attributes >> 8) & 0xFF; }
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 8b26210..8f07157 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -27,6 +27,8 @@
 
 #include "timeline.h"
 #include "dungeonman.h"
+#include "champion.h"
+#include "inventory.h"
 
 
 namespace DM {
@@ -208,4 +210,132 @@ uint16 Timeline::f238_addEventGetEventIndex(TimelineEvent* event) {
 	return L0590_ui_NewEventIndex;
 }
 
+void Timeline::f261_processTimeline() {
+	uint16 L0680_ui_Multiple;
+#define AL0680_ui_EventType     L0680_ui_Multiple
+#define AL0680_ui_ChampionIndex L0680_ui_Multiple
+	TimelineEvent* L0681_ps_Event;
+	TimelineEvent L0682_s_Event;
+
+
+	while (f240_isFirstEventExpiered()) {
+		L0681_ps_Event = &L0682_s_Event;
+		f239_timelineExtractFirstEvent(L0681_ps_Event);
+		_vm->_dungeonMan->f173_setCurrentMap(M29_map(L0682_s_Event._mapTime));
+		AL0680_ui_EventType = L0682_s_Event._type;
+		if ((AL0680_ui_EventType > (k29_TMEventTypeGroupReactionDangerOnSquare - 1)) && (AL0680_ui_EventType < (k41_TMEventTypeUpdateBehaviour_3 + 1))) {
+			//F0209_GROUP_ProcessEvents29to41(L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, AL0680_ui_EventType, L0682_s_Event._C._ticks);
+		} else {
+			switch (AL0680_ui_EventType) {
+			case k48_TMEventTypeMoveProjectileIgnoreImpacts:
+			case k49_TMEventTypeMoveProjectile:
+				//F0219_PROJECTILE_ProcessEvents48To49_Projectile(L0681_ps_Event);
+				break;
+			case k1_TMEventTypeDoorAnimation:
+				//F0241_TIMELINE_ProcessEvent1_DoorAnimation(L0681_ps_Event);
+				break;
+			case k25_TMEventTypeExplosion:
+				//F0220_EXPLOSION_ProcessEvent25_Explosion(L0681_ps_Event);
+				break;
+			case k7_TMEventTypeFakeWall:
+				//F0242_TIMELINE_ProcessEvent7_Square_FakeWall(L0681_ps_Event);
+				break;
+			case k2_TMEventTypeDoorDestruction:
+				//F0243_TIMELINE_ProcessEvent2_DoorDestruction(L0681_ps_Event);
+				break;
+			case k10_TMEventTypeDoor:
+				//F0244_TIMELINE_ProcessEvent10_Square_Door(L0681_ps_Event);
+				break;
+			case k9_TMEventTypePit:
+				//F0251_TIMELINE_ProcessEvent9_Square_Pit(L0681_ps_Event);
+				break;
+			case k8_TMEventTypeTeleporter:
+				//F0250_TIMELINE_ProcessEvent8_Square_Teleporter(L0681_ps_Event);
+				break;
+			case k6_TMEventTypeWall:
+				//F0248_TIMELINE_ProcessEvent6_Square_Wall(L0681_ps_Event);
+				break;
+			case k5_TMEventTypeCorridor:
+				//F0245_TIMELINE_ProcessEvent5_Square_Corridor(L0681_ps_Event);
+				break;
+			case k60_TMEventTypeMoveGroupSilent:
+			case k61_TMEventTypeMoveGroupAudible:
+				//F0252_TIMELINE_ProcessEvents60to61_MoveGroup(L0681_ps_Event);
+				break;
+			case k65_TMEventTypeEnableGroupGenerator:
+				//F0246_TIMELINE_ProcessEvent65_EnableGroupGenerator(L0681_ps_Event);
+				break;
+			case k20_TMEventTypePlaySound:
+				warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+				break;
+			case k24_TMEventTypeRemoveFluxcage:
+				if (!_vm->_g302_gameWon) {
+					_vm->_dungeonMan->f164_unlinkThingFromList(Thing(L0682_s_Event._C._slot), Thing(0), L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY);
+					L0681_ps_Event = (TimelineEvent*)_vm->_dungeonMan->f156_getThingData(Thing(L0682_s_Event._C._slot));
+					((Explosion*)L0681_ps_Event)->setNextThing(Thing::_none);
+				}
+				break;
+			case k11_TMEventTypeEnableChampionAction:
+				//F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction(L0682_s_Event._priority);
+				if (L0682_s_Event._B._slotOrdinal) {
+					//F0259_TIMELINE_ProcessEvent11Part2_MoveWeaponFromQuiverToSlot(L0682_s_Event._priority, _vm->M1_ordinalToIndex(L0682_s_Event._B._slotOrdinal));
+				}
+				goto T0261048;
+			case k12_TMEventTypeHideDamageReceived:
+				//F0254_TIMELINE_ProcessEvent12_HideDamageReceived(L0682_s_Event._priority);
+				break;
+			case k70_TMEventTypeLight:
+				_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
+				//F0257_TIMELINE_ProcessEvent70_Light(L0681_ps_Event);
+				_vm->_inventoryMan->f337_setDungeonViewPalette();
+				break;
+			case k71_TMEventTypeInvisibility:
+				_vm->_championMan->_g407_party._event71Count_Invisibility--;
+				break;
+			case k72_TMEventTypeChampionShield:
+				_vm->_championMan->_gK71_champions[L0682_s_Event._priority]._shieldDefense -= L0682_s_Event._B._defense;
+				setFlag(_vm->_championMan->_gK71_champions[L0682_s_Event._priority]._attributes, k0x1000_ChampionAttributeStatusBox);
+T0261048:
+				_vm->_championMan->f292_drawChampionState((ChampionIndex)L0682_s_Event._priority);
+				break;
+			case k73_TMEventTypeThievesEye:
+				_vm->_championMan->_g407_party._event73Count_ThievesEye--;
+				break;
+			case k74_TMEventTypePartyShield:
+				_vm->_championMan->_g407_party._shieldDefense -= L0682_s_Event._B._defense;
+T0261053:
+				//F0260_TIMELINE_RefreshAllChampionStatusBoxes();
+				break;
+			case k77_TMEventTypeSpellShield:
+				_vm->_championMan->_g407_party._spellShieldDefense -= L0682_s_Event._B._defense;
+				goto T0261053;
+			case k78_TMEventTypeFireShield:
+				_vm->_championMan->_g407_party._fireShieldDefense -= L0682_s_Event._B._defense;
+				goto T0261053;
+			case k75_TMEventTypePoisonChampion:
+				_vm->_championMan->_gK71_champions[AL0680_ui_ChampionIndex = L0682_s_Event._priority]._poisonEventCount--;
+				_vm->_championMan->f322_championPoison(AL0680_ui_ChampionIndex, L0682_s_Event._B._attack);
+				break;
+			case k13_TMEventTypeViAltarRebirth:
+				//F0255_TIMELINE_ProcessEvent13_ViAltarRebirth(L0681_ps_Event);
+				break;
+			case k79_TMEventTypeFootprints:
+				_vm->_championMan->_g407_party._event79Count_Footprints--;
+			}
+		}
+		_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
+	}
+}
+
+bool Timeline::f240_isFirstEventExpiered() {
+	return (_vm->_timeline->_g372_eventCount && (M30_time(_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime));
+}
+
+void Timeline::f239_timelineExtractFirstEvent(TimelineEvent* event) {
+	uint16 L0592_ui_EventIndex;
+
+	*event = _vm->_timeline->_g370_events[L0592_ui_EventIndex = _vm->_timeline->_g371_timeline[0]];
+	f237_deleteEvent(L0592_ui_EventIndex);
+}
+
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index b77c0d1..b5728a0 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -159,6 +159,9 @@ public:
 	bool f234_isEventABeforeB(TimelineEvent *eventA, TimelineEvent *eventB); // @ F0234_TIMELINE_IsEventABeforeEventB
 	uint16 f235_getIndex(uint16 eventIndex); // @ F0235_TIMELINE_GetIndex
 	uint16 f238_addEventGetEventIndex(TimelineEvent *event); // @ F0238_TIMELINE_AddEvent_GetEventIndex_CPSE
+	void f261_processTimeline(); // @ F0261_TIMELINE_Process_CPSEF
+	bool f240_isFirstEventExpiered(); // @ F0240_TIMELINE_IsFirstEventExpired_CPSE
+	void f239_timelineExtractFirstEvent(TimelineEvent *event); // @ F0239_TIMELINE_ExtractFirstEvent
 
 };
 


Commit: dd3f12c7d5b85cb8bd6644a8c9de9fe49ca4166a
    https://github.com/scummvm/scummvm/commit/dd3f12c7d5b85cb8bd6644a8c9de9fe49ca4166a
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Complete main gameloop

Changed paths:
    engines/dm/dm.cpp
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 86e7000..fd3c30e 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -378,13 +378,27 @@ T0002002:
 			_g311_projectileDisableMovementTicks--;
 
 		_g321_stopWaitingForPlayerInput = false;
-		//do {
-		_eventMan->processInput();
-		_eventMan->f380_processCommandQueue();
-	//} while (!_g321_stopWaitingForPlayerInput /*|| !_g301_gameTimeTicking */);
 
+		do {
+			_eventMan->processInput();
+
+			if (_g332_stopPressingEye) {
+				_g331_pressingEye = false;
+				_g332_stopPressingEye = false;
+				_inventoryMan->f353_drawStopPressingEye();
+			} else if (_g334_stopPressingMouth) {
+				_g333_pressingMouth = false;
+				_g334_stopPressingMouth = false;
+				_inventoryMan->f350_drawStopPressingMouth();
+			}
+
+			_eventMan->f380_processCommandQueue();
+			_displayMan->updateScreen();
+			// if (!_vm->_g321_stopWaitingForPlayerInput) {
+			warning(false, "MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
+			// }
+		} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking);
 
-		_displayMan->updateScreen();
 		_system->delayMillis(18);
 	}
 }
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 41e325a..3d61270 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -733,4 +733,23 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 		L1091_i_Y += 7;
 	}
 }
+
+void InventoryMan::f350_drawStopPressingMouth() {
+	_vm->_inventoryMan->f347_drawPanel();
+	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+	warning(false, "Ignored code: G0587_i_HideMousePointerRequestCount");
+	_vm->_eventMan->f77_hideMouse();
+}
+
+void InventoryMan::f353_drawStopPressingEye() {
+	Thing L1100_T_LeaderHandObject;
+
+	_vm->_inventoryMan->f332_drawIconToViewport(k202_IconIndiceEyeNotLooking, 12, 13);
+	_vm->_inventoryMan->f347_drawPanel();
+	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+	if ((L1100_T_LeaderHandObject = _vm->_championMan->_g414_leaderHandObject) != Thing::_none) {
+		_vm->_objectMan->f34_drawLeaderObjectName(L1100_T_LeaderHandObject);
+	}
+	_vm->_eventMan->f77_hideMouse();
+}
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 93bb17f..106e4cd 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -81,6 +81,8 @@ public:
 	void f337_setDungeonViewPalette(); // @ F0337_INVENTORY_SetDungeonViewPalette
 	void f338_decreaseTorchesLightPower(); // @ F0338_INVENTORY_DecreaseTorchesLightPower_CPSE
 	void f351_drawChampionSkillsAndStatistics(); // @ F0351_INVENTORY_DrawChampionSkillsAndStatistics
+	void f350_drawStopPressingMouth(); // @ F0350_INVENTORY_DrawStopPressingMouth
+	void f353_drawStopPressingEye();// @ F0353_INVENTORY_DrawStopPressingEye
 
 };
 


Commit: 12f06fd1d9460524ba8e9307a89edc1454516c27
    https://github.com/scummvm/scummvm/commit/12f06fd1d9460524ba8e9307a89edc1454516c27
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f219_processEvents48To49_projectile

Changed paths:
    engines/dm/dm.cpp
    engines/dm/projexpl.cpp
    engines/dm/projexpl.h
    engines/dm/timeline.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index fd3c30e..8a49b23 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -365,7 +365,7 @@ T0002002:
 		_g313_gameTime++;
 
 		if (!(_g313_gameTime & 511))
-			//_inventoryMan->f338_decreaseTorchesLightPower();
+			_inventoryMan->f338_decreaseTorchesLightPower();
 			if (_g310_disabledMovementTicks) {
 				_g310_disabledMovementTicks--;
 			}
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 94d9d21..53b3f3a 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -414,4 +414,90 @@ void ProjExpl::f215_projectileDelete(Thing projectileThing, Thing* groupSlot, in
 	}
 	L0480_ps_Projectile->_nextThing = Thing::_none;
 }
+
+void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
+	TimelineEvent* L0519_ps_Event;
+	Projectile* L0520_ps_Projectile;
+	Thing L0515_T_ProjectileThingNewCell;
+	uint16 L0516_ui_Multiple;
+#define AL0516_ui_StepEnergy L0516_ui_Multiple
+#define AL0516_ui_Square     L0516_ui_Multiple
+	Thing L0521_T_ProjectileThing;
+	uint16 L0517_ui_ProjectileDirection;
+	bool L0522_B_ProjectileMovesToOtherSquare;
+	int16 L0523_i_DestinationMapX;
+	int16 L0524_i_DestinationMapY;
+	uint16 L0518_ui_Cell;
+	int16 L0525_i_SourceMapX;
+	int16 L0526_i_SourceMapY;
+	TimelineEvent L0527_s_Event;
+
+
+	L0527_s_Event = *event;
+	L0519_ps_Event = &L0527_s_Event;
+	L0520_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(L0521_T_ProjectileThing = L0515_T_ProjectileThingNewCell = Thing(L0519_ps_Event->_B._slot));
+	L0523_i_DestinationMapX = L0519_ps_Event->_C._projectile.getMapX();
+	L0524_i_DestinationMapY = L0519_ps_Event->_C._projectile.getMapY();
+	if (L0519_ps_Event->_type == k48_TMEventTypeMoveProjectileIgnoreImpacts) {
+		L0519_ps_Event->_type = k49_TMEventTypeMoveProjectile;
+	} else {
+		L0518_ui_Cell = (L0515_T_ProjectileThingNewCell).getCell();
+		if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0523_i_DestinationMapX == _vm->_dungeonMan->_g306_partyMapX) && (L0524_i_DestinationMapY == _vm->_dungeonMan->_g307_partyMapY) && f217_projectileHasImpactOccurred(kM2_ChampionElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
+			return;
+		}
+		if ((_vm->_groupMan->f175_groupGetThing(L0523_i_DestinationMapX, L0524_i_DestinationMapY) != Thing::_endOfList) && f217_projectileHasImpactOccurred(kM1_CreatureElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
+			return;
+		}
+		if (L0520_ps_Projectile->_kineticEnergy <= (AL0516_ui_StepEnergy = L0519_ps_Event->_C._projectile.getStepEnergy())) {
+			_vm->_dungeonMan->f164_unlinkThingFromList(L0515_T_ProjectileThingNewCell = L0521_T_ProjectileThing, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+			f215_projectileDelete(L0515_T_ProjectileThingNewCell, NULL, L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+			return;
+		}
+		L0520_ps_Projectile->_kineticEnergy -= AL0516_ui_StepEnergy;
+		if (L0520_ps_Projectile->_attack < AL0516_ui_StepEnergy) {
+			L0520_ps_Projectile->_attack = 0;
+		} else {
+			L0520_ps_Projectile->_attack -= AL0516_ui_StepEnergy;
+		}
+	}
+	if (L0522_B_ProjectileMovesToOtherSquare = ((L0517_ui_ProjectileDirection = L0519_ps_Event->_C._projectile.getDir()) == (L0518_ui_Cell = (L0515_T_ProjectileThingNewCell = Thing(L0519_ps_Event->_B._slot)).getCell())) || (returnNextVal(L0517_ui_ProjectileDirection) == L0518_ui_Cell)) {
+		L0525_i_SourceMapX = L0523_i_DestinationMapX;
+		L0526_i_SourceMapY = L0524_i_DestinationMapY;
+		L0523_i_DestinationMapX += _vm->_dirIntoStepCountEast[L0517_ui_ProjectileDirection], L0524_i_DestinationMapY += _vm->_dirIntoStepCountNorth[L0517_ui_ProjectileDirection];
+		if ((Square(AL0516_ui_Square = _vm->_dungeonMan->f151_getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY).toByte()).getType() == k0_ElementTypeWall) ||
+			((Square(AL0516_ui_Square).getType() == k6_ElementTypeFakeWall) && !getFlag(AL0516_ui_Square, (k0x0001_FakeWallImaginary | k0x0004_FakeWallOpen))) ||
+			((Square(AL0516_ui_Square).getType() == k3_ElementTypeStairs) && (Square(_vm->_dungeonMan->_g271_currMapData[L0525_i_SourceMapX][L0526_i_SourceMapY]).getType() == k3_ElementTypeStairs))) {
+			if (f217_projectileHasImpactOccurred(Square(AL0516_ui_Square).getType(), L0525_i_SourceMapX, L0526_i_SourceMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
+				return;
+			}
+		}
+	}
+	if ((L0517_ui_ProjectileDirection & 0x0001) == (L0518_ui_Cell & 0x0001)) {
+		L0518_ui_Cell--;
+	} else {
+		L0518_ui_Cell++;
+	}
+	L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, L0518_ui_Cell &= 0x0003);
+	if (L0522_B_ProjectileMovesToOtherSquare) {
+		_vm->_movsens->f267_getMoveResult(L0515_T_ProjectileThingNewCell, L0525_i_SourceMapX, L0526_i_SourceMapY, L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+		L0519_ps_Event->_C._projectile.setMapX(_vm->_movsens->_g397_moveResultMapX);
+		L0519_ps_Event->_C._projectile.setMapY(_vm->_movsens->_g398_moveResultMapY);
+		L0519_ps_Event->_C._projectile.setDir((direction)_vm->_movsens->_g400_moveResultDir);
+		L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_movsens->_g401_moveResultCell);
+		M31_setMap(L0519_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex);
+	} else {
+		if ((Square(_vm->_dungeonMan->f151_getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY)).getType() == k4_DoorElemType) && f217_projectileHasImpactOccurred(k4_DoorElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
+			return;
+		}
+		_vm->_dungeonMan->f164_unlinkThingFromList(L0515_T_ProjectileThingNewCell, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+		_vm->_dungeonMan->f163_linkThingToList(L0515_T_ProjectileThingNewCell, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+	}
+	L0519_ps_Event->_mapTime += (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) ? 1 : 3;
+	//Strangerke: CHECKME: Maybe we should keep that piece of code too as it sounds like it's fixing a weird behavior of projectiles on different maps
+#ifdef COMPILE42_CSB20EN_CSB21EN /* CHANGE7_20_IMPROVEMENT Projectiles now move at the same speed on all maps instead of moving slower on maps other than the party map */
+	L0519_ps_Event->Map_Time++;
+#endif
+	L0519_ps_Event->_B._slot = L0515_T_ProjectileThingNewCell.toUint16();
+	L0520_ps_Projectile->_eventIndex = _vm->_timeline->f238_addEventGetEventIndex(L0519_ps_Event);
+}
 }
diff --git a/engines/dm/projexpl.h b/engines/dm/projexpl.h
index 32829f1..125bd8e 100644
--- a/engines/dm/projexpl.h
+++ b/engines/dm/projexpl.h
@@ -30,6 +30,8 @@
 #include "dm.h"
 
 
+namespace DM {
+
 #define k0_outcomeKilledNoCreaturesInGroup 0 // @ C0_OUTCOME_KILLED_NO_CREATURES_IN_GROUP   
 #define k1_outcomeKilledSomeCreaturesInGroup 1 // @ C1_OUTCOME_KILLED_SOME_CREATURES_IN_GROUP 
 #define k2_outcomeKilledAllCreaturesInGroup 2 // @ C2_OUTCOME_KILLED_ALL_CREATURES_IN_GROUP  
@@ -70,10 +72,12 @@
 #define k33_soundMOVE_SKELETON 33 // @ C33_SOUND_MOVE_SKELETON
 
 
-namespace DM {
-	class Projectile;
+#define M31_setMap(map_time, map) ((map_time) = (((map_time) & 0x00FFFFFF) | (((int32)(map)) << 24)))
 
-	class ProjExpl {
+class TimelineEvent;
+class Projectile;
+
+class ProjExpl {
 	DMEngine *_vm;
 public:
 	int16 _g364_creatureDamageOutcome; // @ G0364_i_CreatureDamageOutcome
@@ -94,6 +98,8 @@ public:
 	int16 f218_projectileGetImpactCount(int16 impactType, int16 mapX, int16 mapY, int16 cell); // @ F0218_PROJECTILE_GetImpactCount
 	void f214_projectileDeleteEvent(Thing thing); // @ F0214_PROJECTILE_DeleteEvent
 	void f215_projectileDelete(Thing projectileThing, Thing *groupSlot, int16 mapX, int16 mapY); // @ F0215_PROJECTILE_Delete
+	void f219_processEvents48To49_projectile(TimelineEvent *event); // @ F0219_PROJECTILE_ProcessEvents48To49_Projectile
+
 };
 
 }
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 8f07157..c98338c 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -29,6 +29,8 @@
 #include "dungeonman.h"
 #include "champion.h"
 #include "inventory.h"
+#include "group.h"
+#include "projexpl.h"
 
 
 namespace DM {
@@ -224,12 +226,12 @@ void Timeline::f261_processTimeline() {
 		_vm->_dungeonMan->f173_setCurrentMap(M29_map(L0682_s_Event._mapTime));
 		AL0680_ui_EventType = L0682_s_Event._type;
 		if ((AL0680_ui_EventType > (k29_TMEventTypeGroupReactionDangerOnSquare - 1)) && (AL0680_ui_EventType < (k41_TMEventTypeUpdateBehaviour_3 + 1))) {
-			//F0209_GROUP_ProcessEvents29to41(L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, AL0680_ui_EventType, L0682_s_Event._C._ticks);
+			_vm->_groupMan->f209_processEvents29to41(L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, AL0680_ui_EventType, L0682_s_Event._C._ticks);
 		} else {
 			switch (AL0680_ui_EventType) {
 			case k48_TMEventTypeMoveProjectileIgnoreImpacts:
 			case k49_TMEventTypeMoveProjectile:
-				//F0219_PROJECTILE_ProcessEvents48To49_Projectile(L0681_ps_Event);
+				_vm->_projexpl->f219_processEvents48To49_projectile(L0681_ps_Event);
 				break;
 			case k1_TMEventTypeDoorAnimation:
 				//F0241_TIMELINE_ProcessEvent1_DoorAnimation(L0681_ps_Event);


Commit: 953f7909fcc1c3b5f699bd9add53ec0a2640e00f
    https://github.com/scummvm/scummvm/commit/953f7909fcc1c3b5f699bd9add53ec0a2640e00f
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f241_timelineProcessEvent1_doorAnimation

Changed paths:
    engines/dm/dungeonman.h
    engines/dm/group.cpp
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index a5c6ae2..2763906 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -204,8 +204,7 @@ public:
 	uint16 M59_getWariness() { return (_properties >> 12) & 0xF; }
 	uint16 M60_getFireResistance() { return (_resistances >> 4) & 0xF; }
 	uint16 M61_poisonResistance() { return (_resistances >> 8) & 0xF; }
-	uint16 M51_height() { return (_attributes >> 7) & 0x3; }
-
+	static uint16 M51_height(uint16 attrib) { return (attrib >> 7) & 0x3; }
 	uint16 M54_getSightRange() { return (_ranges) & 0xF; }
 	uint16 M55_getSmellRange() { return  (_ranges >> 8) & 0xF; }
 	uint16 M56_getAttackRange() { return (_ranges >> 12) & 0xF; }
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index ffd466f..a39065b 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1109,7 +1109,7 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 	}
 	if (L0431_i_SquareType == k4_DoorElemType) {
 		L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
-		if (((Square(L0430_ui_Square).getDoorState()) > (((Door *)L0432_ps_Teleporter)->opensVertically() ? creatureInfo->M51_height() : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
+		if (((Square(L0430_ui_Square).getDoorState()) > (((Door *)L0432_ps_Teleporter)->opensVertically() ? CreatureInfo::M51_height(creatureInfo->_attributes) : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
 			_g389_groupMovementBlockedByDoor = true;
 			return false;
 		}
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index c98338c..2bb578e 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -234,7 +234,7 @@ void Timeline::f261_processTimeline() {
 				_vm->_projexpl->f219_processEvents48To49_projectile(L0681_ps_Event);
 				break;
 			case k1_TMEventTypeDoorAnimation:
-				//F0241_TIMELINE_ProcessEvent1_DoorAnimation(L0681_ps_Event);
+				f241_timelineProcessEvent1_doorAnimation(L0681_ps_Event);
 				break;
 			case k25_TMEventTypeExplosion:
 				//F0220_EXPLOSION_ProcessEvent25_Explosion(L0681_ps_Event);
@@ -330,7 +330,8 @@ T0261053:
 }
 
 bool Timeline::f240_isFirstEventExpiered() {
-	return (_vm->_timeline->_g372_eventCount && (M30_time(_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime));
+	warning(false, "possibly dangerous cast to int32");
+	return (_vm->_timeline->_g372_eventCount && ((int32)M30_time(_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime));
 }
 
 void Timeline::f239_timelineExtractFirstEvent(TimelineEvent* event) {
@@ -340,4 +341,74 @@ void Timeline::f239_timelineExtractFirstEvent(TimelineEvent* event) {
 	f237_deleteEvent(L0592_ui_EventIndex);
 }
 
+void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
+	uint16 L0593_ui_MapX;
+	uint16 L0594_ui_MapY;
+	int16 L0595_i_Effect;
+	int16 L0596_i_DoorState;
+	Square* L0597_puc_Square;
+	Door* L0598_ps_Door;
+	Thing L0599_T_GroupThing;
+	uint16 L0600_ui_CreatureAttributes;
+	uint16 L0602_ui_Multiple;
+#define AL0602_ui_VerticalDoor L0602_ui_Multiple
+#define AL0602_ui_Height       L0602_ui_Multiple
+
+	L0597_puc_Square = (Square*)&_vm->_dungeonMan->_g271_currMapData[L0593_ui_MapX = event->_B._location._mapX][L0594_ui_MapY = event->_B._location._mapY];
+	if ((L0596_i_DoorState = Square(*L0597_puc_Square).getDoorState()) == k5_doorState_DESTROYED) {
+		return;
+	}
+	event->_mapTime++;
+	L0595_i_Effect = event->_C.A._effect;
+	if (L0595_i_Effect == k1_SensorEffClear) {
+		L0598_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0593_ui_MapX, L0594_ui_MapY);
+		AL0602_ui_VerticalDoor = L0598_ps_Door->opensVertically();
+		if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0593_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0594_ui_MapY == _vm->_dungeonMan->_g307_partyMapY) && (L0596_i_DoorState != k0_doorState_OPEN)) {
+			if (_vm->_championMan->_g305_partyChampionCount > 0) {
+				L0597_puc_Square->setDoorState(k0_doorState_OPEN);
+
+				// Strangerke
+				// Original bug fixed - A closing horizontal door wounds champions to the head instead of to the hands. Missing parenthesis in the condition cause all doors to wound the head in addition to the torso
+				// See BUG0_78
+				if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(5, k0x0008_ChampionWoundTorso | (AL0602_ui_VerticalDoor ? k0x0004_ChampionWoundHead : k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand), k2_attackType_SELF)) {
+					warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+				}
+			}
+			event->_mapTime++;
+			_vm->_timeline->f238_addEventGetEventIndex(event);
+			return;
+		}
+		if (((L0599_T_GroupThing = _vm->_groupMan->f175_groupGetThing(L0593_ui_MapX, L0594_ui_MapY)) != Thing::_endOfList) && !getFlag(L0600_ui_CreatureAttributes = _vm->_dungeonMan->f144_getCreatureAttributes(L0599_T_GroupThing), k0x0040_MaskCreatureInfo_nonMaterial)) {
+			if (L0596_i_DoorState >= (AL0602_ui_Height ? CreatureInfo::M51_height(L0600_ui_CreatureAttributes) : 1)) { /* Creature height or 1 */
+				if (_vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group*)_vm->_dungeonMan->f156_getThingData(L0599_T_GroupThing), L0593_ui_MapX, L0594_ui_MapY, 5, true) != k2_outcomeKilledAllCreaturesInGroup) {
+					_vm->_groupMan->f209_processEvents29to41(L0593_ui_MapX, L0594_ui_MapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
+				}
+				L0596_i_DoorState = (L0596_i_DoorState == k0_doorState_OPEN) ? k0_doorState_OPEN : (L0596_i_DoorState - 1);
+				L0597_puc_Square->setDoorState(L0596_i_DoorState);
+				warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+				event->_mapTime++;
+				_vm->_timeline->f238_addEventGetEventIndex(event);
+				return;
+			}
+		}
+	}
+	if (((L0595_i_Effect == k0_SensorEffSet) && (L0596_i_DoorState == k0_doorState_OPEN)) || ((L0595_i_Effect == k1_SensorEffClear) && (L0596_i_DoorState == k4_doorState_CLOSED))) {
+		goto T0241020_Return;
+	}
+	L0596_i_DoorState += (L0595_i_Effect == k0_SensorEffSet) ? -1 : 1;
+	L0597_puc_Square->setDoorState(L0596_i_DoorState);
+	warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+	if (L0595_i_Effect == k0_SensorEffSet) {
+		if (L0596_i_DoorState == k0_doorState_OPEN) {
+			return;
+		}
+	} else {
+		if (L0596_i_DoorState == k4_doorState_CLOSED) {
+			return;
+		}
+	}
+	_vm->_timeline->f238_addEventGetEventIndex(event);
+T0241020_Return:
+	;
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index b5728a0..7e94ed7 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -162,6 +162,7 @@ public:
 	void f261_processTimeline(); // @ F0261_TIMELINE_Process_CPSEF
 	bool f240_isFirstEventExpiered(); // @ F0240_TIMELINE_IsFirstEventExpired_CPSE
 	void f239_timelineExtractFirstEvent(TimelineEvent *event); // @ F0239_TIMELINE_ExtractFirstEvent
+	void f241_timelineProcessEvent1_doorAnimation(TimelineEvent *event); // @ F0241_TIMELINE_ProcessEvent1_DoorAnimation
 
 };
 


Commit: cc5f1ab478e21d99ac3edeba621fea73bf591ea5
    https://github.com/scummvm/scummvm/commit/cc5f1ab478e21d99ac3edeba621fea73bf591ea5
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f220_explosionProcessEvent25_explosion

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dm.h
    engines/dm/projexpl.cpp
    engines/dm/projexpl.h
    engines/dm/timeline.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 1d08b44..78a5e9c 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -6,6 +6,7 @@ Bugs:
 
 	Logic:
 		When object are put on the right side of the current square, they disappear
+		Drawing door ornaments segfaults when going back to the start 
 
 
 
@@ -19,4 +20,6 @@ Todo:
 	Double check strcat, strstr usages, I might have messed them up in many places
 	I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions
 
+Finish stuff:
+	f261_processTimeline
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 1b4850a..5b8061c 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -81,8 +81,8 @@ enum ThingType {
 
 
 class Thing {
-	uint16 _data;
 public:
+	uint16 _data;
 	static const Thing _none; // @ C0xFFFF_THING_NONE
 	static const Thing _endOfList; // @ C0xFFFE_THING_ENDOFLIST
 	static const Thing _firstExplosion; // @ C0xFF80_THING_FIRST_EXPLOSION            
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 53b3f3a..e8464aa 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -500,4 +500,96 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 	L0519_ps_Event->_B._slot = L0515_T_ProjectileThingNewCell.toUint16();
 	L0520_ps_Projectile->_eventIndex = _vm->_timeline->f238_addEventGetEventIndex(L0519_ps_Event);
 }
+
+void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) {
+	Explosion* L0532_ps_Explosion;
+	Group* L0533_ps_Group;
+	CreatureInfo* L0534_ps_CreatureInfo;
+	uint16 L0528_ui_MapX;
+	uint16 L0529_ui_MapY;
+	int16 L0530_i_Attack;
+	int16 L0531_i_Multiple;
+#define AL0531_i_SquareType    L0531_i_Multiple
+#define AL0531_i_CreatureCount L0531_i_Multiple
+	Thing L0535_T_GroupThing;
+	Thing L0536_T_ExplosionThing;
+	uint16 L0537_ui_Multiple;
+#define AL0537_ui_CreatureType                L0537_ui_Multiple
+#define AL0537_ui_NonMaterialAdditionalAttack L0537_ui_Multiple
+	bool L0538_B_ExplosionOnPartySquare;
+	TimelineEvent L0539_s_Event;
+
+	L0528_ui_MapX = event->_B._location._mapX;
+	L0529_ui_MapY = event->_B._location._mapY;
+	L0532_ps_Explosion = &((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[Thing((event->_C._slot)).getIndex()];
+	AL0531_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[L0528_ui_MapX][L0529_ui_MapY]).getType();
+	L0538_B_ExplosionOnPartySquare = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0528_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0529_ui_MapY == _vm->_dungeonMan->_g307_partyMapY);
+	if ((L0535_T_GroupThing = _vm->_groupMan->f175_groupGetThing(L0528_ui_MapX, L0529_ui_MapY)) != Thing::_endOfList) {
+		L0533_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0535_T_GroupThing);
+		L0534_ps_CreatureInfo = &g243_CreatureInfo[AL0537_ui_CreatureType = L0533_ps_Group->_type];
+	}
+	if ((L0536_T_ExplosionThing = Thing(Thing::_firstExplosion.toUint16() + L0532_ps_Explosion->getType())) == Thing::_explPoisonCloud) {
+		L0530_i_Attack = MAX(1, MIN(L0532_ps_Explosion->getAttack() >> 5, 4) + _vm->getRandomNumber(2)); /* Value between 1 and 5 */
+	} else {
+		L0530_i_Attack = (L0532_ps_Explosion->getAttack() >> 1) + 1;
+		L0530_i_Attack += _vm->getRandomNumber(L0530_i_Attack) + 1;
+	}
+
+
+	switch (L0536_T_ExplosionThing.toUint16()) {
+	case 0xFF82:
+		if (!(L0530_i_Attack >>= 1))
+			break;
+	case 0xFF80:
+		if (AL0531_i_SquareType == k4_DoorElemType) {
+			_vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true, 0);
+		}
+		break;
+	case 0xFF83:
+		if ((L0535_T_GroupThing != Thing::_endOfList) && getFlag(L0534_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
+			if ((AL0537_ui_CreatureType == k19_CreatureTypeMaterializerZytaz) && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
+				L0530_i_Attack -= (AL0537_ui_NonMaterialAdditionalAttack = L0530_i_Attack >> 3);
+				AL0537_ui_NonMaterialAdditionalAttack <<= 1;
+				AL0537_ui_NonMaterialAdditionalAttack++;
+				AL0531_i_CreatureCount = L0533_ps_Group->getCount();
+				do {
+					if (getFlag(_vm->_groupMan->_g375_activeGroups[L0533_ps_Group->getActiveGroupIndex()]._aspect[AL0531_i_CreatureCount], k0x0080_MaskActiveGroupIsAttacking)) { /* Materializer / Zytaz can only be damaged while they are attacking */
+						_vm->_groupMan->f190_groupGetDamageCreatureOutcome(L0533_ps_Group, AL0531_i_CreatureCount, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack + _vm->getRandomNumber(AL0537_ui_NonMaterialAdditionalAttack) + _vm->getRandomNumber(4), true);
+					}
+				} while (--AL0531_i_CreatureCount >= 0);
+			} else {
+				_vm->_groupMan->f191_getDamageAllCreaturesOutcome(L0533_ps_Group, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true);
+			}
+		}
+		break;
+	case 0xFFE4:
+		L0532_ps_Explosion->setType(L0532_ps_Explosion->getType() + 1);
+		warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+		goto T0220026;
+	case 0xFFA8:
+		if (L0532_ps_Explosion->getAttack() > 55) {
+			L0532_ps_Explosion->setAttack(L0532_ps_Explosion->getAttack() - 40);
+			goto T0220026;
+		}
+		break;
+	case 0xFF87:
+		if (L0538_B_ExplosionOnPartySquare) {
+			_vm->_championMan->f324_damageAll_getDamagedChampionCount(L0530_i_Attack, k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
+		} else {
+			if ((L0535_T_GroupThing != Thing::_endOfList) && (L0530_i_Attack = _vm->_groupMan->f192_groupGetResistanceAdjustedPoisonAttack(AL0537_ui_CreatureType, L0530_i_Attack)) && (_vm->_groupMan->f191_getDamageAllCreaturesOutcome(L0533_ps_Group, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true) != k2_outcomeKilledAllCreaturesInGroup) && (L0530_i_Attack > 2)) {
+				_vm->_groupMan->f209_processEvents29to41(L0528_ui_MapX, L0529_ui_MapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
+			}
+		}
+		if (L0532_ps_Explosion->getAttack() >= 6) {
+			L0532_ps_Explosion->setAttack(L0532_ps_Explosion->getAttack() - 3);
+T0220026:
+			L0539_s_Event = *event;
+			L0539_s_Event._mapTime++;
+			_vm->_timeline->f238_addEventGetEventIndex(&L0539_s_Event);
+			return;
+		}
+	}
+	_vm->_dungeonMan->f164_unlinkThingFromList(Thing(event->_C._slot), Thing(0), L0528_ui_MapX, L0529_ui_MapY);
+	L0532_ps_Explosion->setNextThing(Thing::_none);
+}
 }
diff --git a/engines/dm/projexpl.h b/engines/dm/projexpl.h
index 125bd8e..d0e030f 100644
--- a/engines/dm/projexpl.h
+++ b/engines/dm/projexpl.h
@@ -99,7 +99,7 @@ public:
 	void f214_projectileDeleteEvent(Thing thing); // @ F0214_PROJECTILE_DeleteEvent
 	void f215_projectileDelete(Thing projectileThing, Thing *groupSlot, int16 mapX, int16 mapY); // @ F0215_PROJECTILE_Delete
 	void f219_processEvents48To49_projectile(TimelineEvent *event); // @ F0219_PROJECTILE_ProcessEvents48To49_Projectile
-
+	void f220_explosionProcessEvent25_explosion(TimelineEvent *event); // @ F0220_EXPLOSION_ProcessEvent25_Explosion
 };
 
 }
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 2bb578e..55a80cf 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -237,7 +237,7 @@ void Timeline::f261_processTimeline() {
 				f241_timelineProcessEvent1_doorAnimation(L0681_ps_Event);
 				break;
 			case k25_TMEventTypeExplosion:
-				//F0220_EXPLOSION_ProcessEvent25_Explosion(L0681_ps_Event);
+				_vm->_projexpl->f220_explosionProcessEvent25_explosion(L0681_ps_Event);
 				break;
 			case k7_TMEventTypeFakeWall:
 				//F0242_TIMELINE_ProcessEvent7_Square_FakeWall(L0681_ps_Event);


Commit: 12dff65535144968005e1765b235ffc0b9408177
    https://github.com/scummvm/scummvm/commit/12dff65535144968005e1765b235ffc0b9408177
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f242_timelineProcessEvent7_squareFakewall

Changed paths:
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 55a80cf..c8a3103 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -240,7 +240,7 @@ void Timeline::f261_processTimeline() {
 				_vm->_projexpl->f220_explosionProcessEvent25_explosion(L0681_ps_Event);
 				break;
 			case k7_TMEventTypeFakeWall:
-				//F0242_TIMELINE_ProcessEvent7_Square_FakeWall(L0681_ps_Event);
+				f242_timelineProcessEvent7_squareFakewall(L0681_ps_Event);
 				break;
 			case k2_TMEventTypeDoorDestruction:
 				//F0243_TIMELINE_ProcessEvent2_DoorDestruction(L0681_ps_Event);
@@ -411,4 +411,34 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 T0241020_Return:
 	;
 }
+
+void Timeline::f242_timelineProcessEvent7_squareFakewall(TimelineEvent* event) {
+	uint16 L0603_ui_MapX;
+	uint16 L0604_ui_MapY;
+	int16 L0605_i_Effect;
+	Thing L0606_T_Thing;
+	Square* L0607_puc_Square;
+
+
+	L0607_puc_Square = (Square*)&_vm->_dungeonMan->_g271_currMapData[L0603_ui_MapX = event->_B._location._mapX][L0604_ui_MapY = event->_B._location._mapY];
+	L0605_i_Effect = event->_C.A._effect;
+	if (L0605_i_Effect == k2_SensorEffToggle) {
+		L0605_i_Effect = L0607_puc_Square->get(k0x0004_FakeWallOpen) ? k1_SensorEffClear : k0_SensorEffSet;
+	}
+	if (L0605_i_Effect == k1_SensorEffClear) {
+		if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0603_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0604_ui_MapY == _vm->_dungeonMan->_g307_partyMapY)) {
+			event->_mapTime++;
+			_vm->_timeline->f238_addEventGetEventIndex(event);
+		} else {
+			if (((L0606_T_Thing = _vm->_groupMan->f175_groupGetThing(L0603_ui_MapX, L0604_ui_MapY)) != Thing::_endOfList) && !getFlag(_vm->_dungeonMan->f144_getCreatureAttributes(L0606_T_Thing), k0x0040_MaskCreatureInfo_nonMaterial)) {
+				event->_mapTime++;
+				_vm->_timeline->f238_addEventGetEventIndex(event);
+			} else {
+				L0607_puc_Square->set(k0x0004_FakeWallOpen);
+			}
+		}
+	} else {
+		L0607_puc_Square->set(k0x0004_FakeWallOpen);
+	}
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 7e94ed7..b34a98b 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -163,6 +163,7 @@ public:
 	bool f240_isFirstEventExpiered(); // @ F0240_TIMELINE_IsFirstEventExpired_CPSE
 	void f239_timelineExtractFirstEvent(TimelineEvent *event); // @ F0239_TIMELINE_ExtractFirstEvent
 	void f241_timelineProcessEvent1_doorAnimation(TimelineEvent *event); // @ F0241_TIMELINE_ProcessEvent1_DoorAnimation
+	void f242_timelineProcessEvent7_squareFakewall(TimelineEvent *event); // @ F0242_TIMELINE_ProcessEvent7_Square_FakeWall
 
 };
 


Commit: d1f0281e9d870b5caf8be492868be20519928df3
    https://github.com/scummvm/scummvm/commit/d1f0281e9d870b5caf8be492868be20519928df3
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f243_timelineProcessEvent2_doorDestruction

Changed paths:
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index c8a3103..073eeb0 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -243,7 +243,7 @@ void Timeline::f261_processTimeline() {
 				f242_timelineProcessEvent7_squareFakewall(L0681_ps_Event);
 				break;
 			case k2_TMEventTypeDoorDestruction:
-				//F0243_TIMELINE_ProcessEvent2_DoorDestruction(L0681_ps_Event);
+				f243_timelineProcessEvent2_doorDestruction(L0681_ps_Event);
 				break;
 			case k10_TMEventTypeDoor:
 				//F0244_TIMELINE_ProcessEvent10_Square_Door(L0681_ps_Event);
@@ -441,4 +441,11 @@ void Timeline::f242_timelineProcessEvent7_squareFakewall(TimelineEvent* event) {
 		L0607_puc_Square->set(k0x0004_FakeWallOpen);
 	}
 }
+
+void Timeline::f243_timelineProcessEvent2_doorDestruction(TimelineEvent* event) {
+	Square* L0608_puc_Square;
+
+	L0608_puc_Square = (Square*)&_vm->_dungeonMan->_g271_currMapData[event->_B._location._mapX][event->_B._location._mapY];
+	L0608_puc_Square->set(k5_doorState_DESTROYED);
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index b34a98b..aeb9cc7 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -164,6 +164,7 @@ public:
 	void f239_timelineExtractFirstEvent(TimelineEvent *event); // @ F0239_TIMELINE_ExtractFirstEvent
 	void f241_timelineProcessEvent1_doorAnimation(TimelineEvent *event); // @ F0241_TIMELINE_ProcessEvent1_DoorAnimation
 	void f242_timelineProcessEvent7_squareFakewall(TimelineEvent *event); // @ F0242_TIMELINE_ProcessEvent7_Square_FakeWall
+	void f243_timelineProcessEvent2_doorDestruction(TimelineEvent *event); // @ F0243_TIMELINE_ProcessEvent2_DoorDestruction
 
 };
 


Commit: ad11a4f48ce9fbc3547a69870ba7a08dbeff2c08
    https://github.com/scummvm/scummvm/commit/ad11a4f48ce9fbc3547a69870ba7a08dbeff2c08
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f244_timelineProcessEvent10_squareDoor

Changed paths:
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 073eeb0..ed3b330 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -246,7 +246,7 @@ void Timeline::f261_processTimeline() {
 				f243_timelineProcessEvent2_doorDestruction(L0681_ps_Event);
 				break;
 			case k10_TMEventTypeDoor:
-				//F0244_TIMELINE_ProcessEvent10_Square_Door(L0681_ps_Event);
+				f244_timelineProcessEvent10_squareDoor(L0681_ps_Event);
 				break;
 			case k9_TMEventTypePit:
 				//F0251_TIMELINE_ProcessEvent9_Square_Pit(L0681_ps_Event);
@@ -448,4 +448,28 @@ void Timeline::f243_timelineProcessEvent2_doorDestruction(TimelineEvent* event)
 	L0608_puc_Square = (Square*)&_vm->_dungeonMan->_g271_currMapData[event->_B._location._mapX][event->_B._location._mapY];
 	L0608_puc_Square->set(k5_doorState_DESTROYED);
 }
+
+void Timeline::f244_timelineProcessEvent10_squareDoor(TimelineEvent* event) {
+	int16 L0609_i_DoorState;
+
+
+	if ((L0609_i_DoorState = Square(_vm->_dungeonMan->_g271_currMapData[event->_B._location._mapX][event->_B._location._mapY]).getDoorState()) == k5_doorState_DESTROYED) {
+		return;
+	}
+	if (event->_C.A._effect == k2_SensorEffToggle) {
+		event->_C.A._effect = (L0609_i_DoorState == k0_doorState_OPEN) ? k1_SensorEffClear : k0_SensorEffSet;
+	} else {
+		if (event->_C.A._effect == k0_SensorEffSet) {
+			if (L0609_i_DoorState == k0_doorState_OPEN) {
+				return;
+			}
+		} else {
+			if (L0609_i_DoorState == k4_doorState_CLOSED) {
+				return;
+			}
+		}
+	}
+	event->_type = k1_TMEventTypeDoorAnimation;
+	_vm->_timeline->f238_addEventGetEventIndex(event);
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index aeb9cc7..533a317 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -165,6 +165,7 @@ public:
 	void f241_timelineProcessEvent1_doorAnimation(TimelineEvent *event); // @ F0241_TIMELINE_ProcessEvent1_DoorAnimation
 	void f242_timelineProcessEvent7_squareFakewall(TimelineEvent *event); // @ F0242_TIMELINE_ProcessEvent7_Square_FakeWall
 	void f243_timelineProcessEvent2_doorDestruction(TimelineEvent *event); // @ F0243_TIMELINE_ProcessEvent2_DoorDestruction
+	void f244_timelineProcessEvent10_squareDoor(TimelineEvent *event); // @ F0244_TIMELINE_ProcessEvent10_Square_Door
 
 };
 


Commit: 81a8c8cf742314d12850163ff7ffba48f1837bac
    https://github.com/scummvm/scummvm/commit/81a8c8cf742314d12850163ff7ffba48f1837bac
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Clear some warnings

Changed paths:
    engines/dm/projexpl.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index e8464aa..7d99b97 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -428,8 +428,8 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 	int16 L0523_i_DestinationMapX;
 	int16 L0524_i_DestinationMapY;
 	uint16 L0518_ui_Cell;
-	int16 L0525_i_SourceMapX;
-	int16 L0526_i_SourceMapY;
+	int16 L0525_i_SourceMapX = -1;
+	int16 L0526_i_SourceMapY = -1;
 	TimelineEvent L0527_s_Event;
 
 
@@ -503,8 +503,8 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 
 void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) {
 	Explosion* L0532_ps_Explosion;
-	Group* L0533_ps_Group;
-	CreatureInfo* L0534_ps_CreatureInfo;
+	Group* L0533_ps_Group = nullptr;
+	CreatureInfo* L0534_ps_CreatureInfo = nullptr;
 	uint16 L0528_ui_MapX;
 	uint16 L0529_ui_MapY;
 	int16 L0530_i_Attack;
@@ -513,7 +513,7 @@ void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) {
 #define AL0531_i_CreatureCount L0531_i_Multiple
 	Thing L0535_T_GroupThing;
 	Thing L0536_T_ExplosionThing;
-	uint16 L0537_ui_Multiple;
+	uint16 L0537_ui_Multiple = 0;
 #define AL0537_ui_CreatureType                L0537_ui_Multiple
 #define AL0537_ui_NonMaterialAdditionalAttack L0537_ui_Multiple
 	bool L0538_B_ExplosionOnPartySquare;
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index ed3b330..2e2a249 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -330,8 +330,8 @@ T0261053:
 }
 
 bool Timeline::f240_isFirstEventExpiered() {
-	warning(false, "possibly dangerous cast to int32");
-	return (_vm->_timeline->_g372_eventCount && ((int32)M30_time(_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime));
+	warning(false, "possibly dangerous cast to uint32");
+	return (_vm->_timeline->_g372_eventCount && ((uint32)M30_time(_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime));
 }
 
 void Timeline::f239_timelineExtractFirstEvent(TimelineEvent* event) {


Commit: f6dea6c73e064d69d9fdc64c9dedb9959e004385
    https://github.com/scummvm/scummvm/commit/f6dea6c73e064d69d9fdc64c9dedb9959e004385
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f251_timelineProcessEvent9_squarePit

Changed paths:
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 2e2a249..76582af 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -31,6 +31,7 @@
 #include "inventory.h"
 #include "group.h"
 #include "projexpl.h"
+#include "movesens.h"
 
 
 namespace DM {
@@ -249,7 +250,7 @@ void Timeline::f261_processTimeline() {
 				f244_timelineProcessEvent10_squareDoor(L0681_ps_Event);
 				break;
 			case k9_TMEventTypePit:
-				//F0251_TIMELINE_ProcessEvent9_Square_Pit(L0681_ps_Event);
+				f251_timelineProcessEvent9_squarePit(L0681_ps_Event);
 				break;
 			case k8_TMEventTypeTeleporter:
 				//F0250_TIMELINE_ProcessEvent8_Square_Teleporter(L0681_ps_Event);
@@ -417,13 +418,13 @@ void Timeline::f242_timelineProcessEvent7_squareFakewall(TimelineEvent* event) {
 	uint16 L0604_ui_MapY;
 	int16 L0605_i_Effect;
 	Thing L0606_T_Thing;
-	Square* L0607_puc_Square;
+	byte* L0607_puc_Square;
 
 
-	L0607_puc_Square = (Square*)&_vm->_dungeonMan->_g271_currMapData[L0603_ui_MapX = event->_B._location._mapX][L0604_ui_MapY = event->_B._location._mapY];
+	L0607_puc_Square = &_vm->_dungeonMan->_g271_currMapData[L0603_ui_MapX = event->_B._location._mapX][L0604_ui_MapY = event->_B._location._mapY];
 	L0605_i_Effect = event->_C.A._effect;
 	if (L0605_i_Effect == k2_SensorEffToggle) {
-		L0605_i_Effect = L0607_puc_Square->get(k0x0004_FakeWallOpen) ? k1_SensorEffClear : k0_SensorEffSet;
+		L0605_i_Effect = getFlag(*L0607_puc_Square, k0x0004_FakeWallOpen) ? k1_SensorEffClear : k0_SensorEffSet;
 	}
 	if (L0605_i_Effect == k1_SensorEffClear) {
 		if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0603_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0604_ui_MapY == _vm->_dungeonMan->_g307_partyMapY)) {
@@ -434,11 +435,11 @@ void Timeline::f242_timelineProcessEvent7_squareFakewall(TimelineEvent* event) {
 				event->_mapTime++;
 				_vm->_timeline->f238_addEventGetEventIndex(event);
 			} else {
-				L0607_puc_Square->set(k0x0004_FakeWallOpen);
+				clearFlag(*L0607_puc_Square, k0x0004_FakeWallOpen);
 			}
 		}
 	} else {
-		L0607_puc_Square->set(k0x0004_FakeWallOpen);
+		setFlag(*L0607_puc_Square, k0x0004_FakeWallOpen);
 	}
 }
 
@@ -446,7 +447,7 @@ void Timeline::f243_timelineProcessEvent2_doorDestruction(TimelineEvent* event)
 	Square* L0608_puc_Square;
 
 	L0608_puc_Square = (Square*)&_vm->_dungeonMan->_g271_currMapData[event->_B._location._mapX][event->_B._location._mapY];
-	L0608_puc_Square->set(k5_doorState_DESTROYED);
+	L0608_puc_Square->setDoorState(k5_doorState_DESTROYED);
 }
 
 void Timeline::f244_timelineProcessEvent10_squareDoor(TimelineEvent* event) {
@@ -472,4 +473,81 @@ void Timeline::f244_timelineProcessEvent10_squareDoor(TimelineEvent* event) {
 	event->_type = k1_TMEventTypeDoorAnimation;
 	_vm->_timeline->f238_addEventGetEventIndex(event);
 }
+
+void Timeline::f251_timelineProcessEvent9_squarePit(TimelineEvent* event) {
+	uint16 L0653_ui_MapX;
+	uint16 L0654_ui_MapY;
+	byte* L0655_puc_Square;
+
+
+	L0655_puc_Square = &_vm->_dungeonMan->_g271_currMapData[L0653_ui_MapX = event->_B._location._mapX][L0654_ui_MapY = event->_B._location._mapY];
+	if (event->_C.A._effect == k2_SensorEffToggle) {
+		event->_C.A._effect = getFlag(*L0655_puc_Square, k0x0008_PitOpen) ? k1_SensorEffClear : k0_SensorEffSet;
+	}
+	if (event->_C.A._effect == k0_SensorEffSet) {
+		setFlag(*L0655_puc_Square, k0x0008_PitOpen);
+		f249_moveTeleporterOrPitSquareThings(L0653_ui_MapX, L0654_ui_MapY);
+	} else {
+		clearFlag(*L0655_puc_Square, k0x0008_PitOpen);
+	}
+}
+
+void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
+	uint16 L0644_ui_Multiple;
+#define AL0644_ui_ThingType  L0644_ui_Multiple
+#define AL0644_ui_EventIndex L0644_ui_Multiple
+	Thing L0645_T_Thing;
+	Projectile* L0646_ps_Projectile;
+	TimelineEvent* L0647_ps_Event;
+	Thing L0648_T_NextThing;
+	int16 L0649_i_ThingsToMoveCount;
+
+
+	if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX == _vm->_dungeonMan->_g306_partyMapX) && (mapY == _vm->_dungeonMan->_g307_partyMapY)) {
+		_vm->_movsens->f267_getMoveResult(Thing::_party, mapX, mapY, mapX, mapY);
+		_vm->_championMan->f296_drawChangedObjectIcons();
+	}
+	if ((L0645_T_Thing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) != Thing::_endOfList) {
+		_vm->_movsens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
+	}
+	L0645_T_Thing = _vm->_dungeonMan->f162_getSquareFirstObject(mapX, mapY);
+	L0648_T_NextThing = L0645_T_Thing;
+	L0649_i_ThingsToMoveCount = 0;
+	while (L0645_T_Thing != Thing::_endOfList) {
+		if (L0645_T_Thing.getType() > k4_GroupThingType) {
+			L0649_i_ThingsToMoveCount++;
+		}
+		L0645_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0645_T_Thing);
+	}
+	L0645_T_Thing = L0648_T_NextThing;
+	while ((L0645_T_Thing != Thing::_endOfList) && L0649_i_ThingsToMoveCount) {
+		L0649_i_ThingsToMoveCount--;
+		L0648_T_NextThing = _vm->_dungeonMan->f159_getNextThing(L0645_T_Thing);
+		AL0644_ui_ThingType = L0645_T_Thing.getType();
+		if (AL0644_ui_ThingType > k4_GroupThingType) {
+			_vm->_movsens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
+		}
+		if (AL0644_ui_ThingType == k14_ProjectileThingType) {
+			L0646_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(L0645_T_Thing);
+			L0647_ps_Event = &_vm->_timeline->_g370_events[L0646_ps_Projectile->_eventIndex];
+			L0647_ps_Event->_C._projectile.setMapX(_vm->_movsens->_g397_moveResultMapX);
+			L0647_ps_Event->_C._projectile.setMapY(_vm->_movsens->_g398_moveResultMapY);
+			L0647_ps_Event->_C._projectile.setDir((direction)_vm->_movsens->_g400_moveResultDir);
+			L0647_ps_Event->_B._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_movsens->_g401_moveResultCell).toUint16();
+			M31_setMap(L0647_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex);
+		} else {
+			if (AL0644_ui_ThingType == k15_ExplosionThingType) {
+				for (AL0644_ui_EventIndex = 0, L0647_ps_Event = _vm->_timeline->_g370_events; AL0644_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0647_ps_Event++, AL0644_ui_EventIndex++) {
+					if ((L0647_ps_Event->_type== k25_TMEventTypeExplosion) && (L0647_ps_Event->_C._slot == L0645_T_Thing.toUint16())) { /* BUG0_23 A Fluxcage explosion remains on a square forever. If you open a pit or teleporter on a square where there is a Fluxcage explosion, the Fluxcage explosion is moved but the associated event is not updated (because Fluxcage explosions do not use k25_TMEventTypeExplosion but rather k24_TMEventTypeRemoveFluxcage) causing the Fluxcage explosion to remain in the dungeon forever on its destination square. When the k24_TMEventTypeRemoveFluxcage expires the explosion thing is not removed, but it is marked as unused. Consequently, any objects placed on the Fluxcage square after it was moved but before it expires become orphans upon expiration. After expiration, any object placed on the fluxcage square is cloned when picked up */
+						L0647_ps_Event->_B._location._mapX = _vm->_movsens->_g397_moveResultMapX;
+						L0647_ps_Event->_B._location._mapY = _vm->_movsens->_g398_moveResultMapY;
+						L0647_ps_Event->_C._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_movsens->_g401_moveResultCell).toUint16();
+						M31_setMap(L0647_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex);
+					}
+				}
+			}
+		}
+		L0645_T_Thing = L0648_T_NextThing;
+	}
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 533a317..b6c728f 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -166,6 +166,8 @@ public:
 	void f242_timelineProcessEvent7_squareFakewall(TimelineEvent *event); // @ F0242_TIMELINE_ProcessEvent7_Square_FakeWall
 	void f243_timelineProcessEvent2_doorDestruction(TimelineEvent *event); // @ F0243_TIMELINE_ProcessEvent2_DoorDestruction
 	void f244_timelineProcessEvent10_squareDoor(TimelineEvent *event); // @ F0244_TIMELINE_ProcessEvent10_Square_Door
+	void f251_timelineProcessEvent9_squarePit(TimelineEvent *event); // @ F0251_TIMELINE_ProcessEvent9_Square_Pit
+	void f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY); // @ F0249_TIMELINE_MoveTeleporterOrPitSquareThings
 
 };
 


Commit: d77ffceff9cc8266c9fea4ab33c90b5c78341ec7
    https://github.com/scummvm/scummvm/commit/d77ffceff9cc8266c9fea4ab33c90b5c78341ec7
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f250_timelineProcessEvent8_squareTeleporter

Changed paths:
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 76582af..5b2d137 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -253,7 +253,7 @@ void Timeline::f261_processTimeline() {
 				f251_timelineProcessEvent9_squarePit(L0681_ps_Event);
 				break;
 			case k8_TMEventTypeTeleporter:
-				//F0250_TIMELINE_ProcessEvent8_Square_Teleporter(L0681_ps_Event);
+				f250_timelineProcessEvent8_squareTeleporter(L0681_ps_Event);
 				break;
 			case k6_TMEventTypeWall:
 				//F0248_TIMELINE_ProcessEvent6_Square_Wall(L0681_ps_Event);
@@ -538,7 +538,7 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 		} else {
 			if (AL0644_ui_ThingType == k15_ExplosionThingType) {
 				for (AL0644_ui_EventIndex = 0, L0647_ps_Event = _vm->_timeline->_g370_events; AL0644_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0647_ps_Event++, AL0644_ui_EventIndex++) {
-					if ((L0647_ps_Event->_type== k25_TMEventTypeExplosion) && (L0647_ps_Event->_C._slot == L0645_T_Thing.toUint16())) { /* BUG0_23 A Fluxcage explosion remains on a square forever. If you open a pit or teleporter on a square where there is a Fluxcage explosion, the Fluxcage explosion is moved but the associated event is not updated (because Fluxcage explosions do not use k25_TMEventTypeExplosion but rather k24_TMEventTypeRemoveFluxcage) causing the Fluxcage explosion to remain in the dungeon forever on its destination square. When the k24_TMEventTypeRemoveFluxcage expires the explosion thing is not removed, but it is marked as unused. Consequently, any objects placed on the Fluxcage square after it was moved but before it expires become orphans upon expiration. After expiration, any object placed on the fluxcage square is cloned when picked up */
+					if ((L0647_ps_Event->_type == k25_TMEventTypeExplosion) && (L0647_ps_Event->_C._slot == L0645_T_Thing.toUint16())) { /* BUG0_23 A Fluxcage explosion remains on a square forever. If you open a pit or teleporter on a square where there is a Fluxcage explosion, the Fluxcage explosion is moved but the associated event is not updated (because Fluxcage explosions do not use k25_TMEventTypeExplosion but rather k24_TMEventTypeRemoveFluxcage) causing the Fluxcage explosion to remain in the dungeon forever on its destination square. When the k24_TMEventTypeRemoveFluxcage expires the explosion thing is not removed, but it is marked as unused. Consequently, any objects placed on the Fluxcage square after it was moved but before it expires become orphans upon expiration. After expiration, any object placed on the fluxcage square is cloned when picked up */
 						L0647_ps_Event->_B._location._mapX = _vm->_movsens->_g397_moveResultMapX;
 						L0647_ps_Event->_B._location._mapY = _vm->_movsens->_g398_moveResultMapY;
 						L0647_ps_Event->_C._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_movsens->_g401_moveResultCell).toUint16();
@@ -550,4 +550,22 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 		L0645_T_Thing = L0648_T_NextThing;
 	}
 }
+
+void Timeline::f250_timelineProcessEvent8_squareTeleporter(TimelineEvent* event) {
+	uint16 L0650_ui_MapX;
+	uint16 L0651_ui_MapY;
+	byte* L0652_puc_Square;
+
+
+	L0652_puc_Square = &_vm->_dungeonMan->_g271_currMapData[L0650_ui_MapX = event->_B._location._mapX][L0651_ui_MapY = event->_B._location._mapY];
+	if (event->_C.A._effect == k2_SensorEffToggle) {
+		event->_C.A._effect = getFlag(*L0652_puc_Square, k0x0008_TeleporterOpen) ? k1_SensorEffClear : k0_SensorEffSet;
+	}
+	if (event->_C.A._effect == k0_SensorEffSet) {
+		setFlag(*L0652_puc_Square, k0x0008_TeleporterOpen);
+		f249_moveTeleporterOrPitSquareThings(L0650_ui_MapX, L0651_ui_MapY);
+	} else {
+		clearFlag(*L0652_puc_Square, k0x0008_TeleporterOpen);
+	}
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index b6c728f..a0d2877 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -168,6 +168,7 @@ public:
 	void f244_timelineProcessEvent10_squareDoor(TimelineEvent *event); // @ F0244_TIMELINE_ProcessEvent10_Square_Door
 	void f251_timelineProcessEvent9_squarePit(TimelineEvent *event); // @ F0251_TIMELINE_ProcessEvent9_Square_Pit
 	void f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY); // @ F0249_TIMELINE_MoveTeleporterOrPitSquareThings
+	void f250_timelineProcessEvent8_squareTeleporter(TimelineEvent *event); // @ F0250_TIMELINE_ProcessEvent8_Square_Teleporter
 
 };
 


Commit: 536e9c1bb9e603e420843647a092b50f7668a996
    https://github.com/scummvm/scummvm/commit/536e9c1bb9e603e420843647a092b50f7668a996
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f248_timelineProcessEvent6_squareWall

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.h
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 4a1508f..a968411 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -820,7 +820,7 @@ uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion* champ, uint16 stat
 void ChampionMan::f314_wakeUp() {
 	_vm->_g321_stopWaitingForPlayerInput = true;
 	_g300_partyIsSleeping = false;
-	_vm->waitMs(10);
+	_vm->f22_delay(10);
 	_vm->_displayMan->f98_drawFloorAndCeiling();
 	_vm->_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface;
 	_vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 8a49b23..932de5a 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -199,8 +199,8 @@ DMEngine::~DMEngine() {
 	DebugMan.clearAllDebugChannels();
 }
 
-void DMEngine::waitMs(uint16 ms) {
-	_system->delayMillis(ms * 20);
+void DMEngine::f22_delay(uint16 verticalBlank) {
+	_system->delayMillis(verticalBlank * 20); // Google says most Amiga games had a refreshrate of 50 hz
 }
 
 uint16 DMEngine::f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2) {
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 5b8061c..1e1fc6a 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -184,7 +184,7 @@ public:
 	explicit DMEngine(OSystem *syst);
 	~DMEngine();
 
-	void waitMs(uint16 ms);
+	void f22_delay(uint16 ms); // @ F0022_MAIN_Delay
 	uint16 f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2); // @ F0030_MAIN_GetScaledProduct
 	uint16 getRandomNumber(uint32 max) { return _rnd->getRandomNumber(max - 1); }
 	int16 M1_ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 2763906..e0a1d8f 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -260,6 +260,7 @@ public:
 	Thing getNextThing() { return _nextThing; }
 	uint16 getWordOffset() { return _textDataRef >> 3; }
 	bool isVisible() { return _textDataRef & 1; }
+	void setVisible(bool visible) { _textDataRef = (_textDataRef & ~1) | (visible ? 1 : 0); }
 }; // @ TEXTSTRING
 
 enum SensorActionType {
@@ -306,8 +307,8 @@ enum SensorType {
 class Sensor {
 	Thing _nextThing;
 	uint16 _datAndType;
-	uint16 _attributes;
-	uint16 _action;
+	uint16 _attributes; // A
+	uint16 _action; // B
 public:
 	explicit Sensor(uint16 *rawDat) : _nextThing(rawDat[0]), _datAndType(rawDat[1]), _attributes(rawDat[2]), _action(rawDat[3]) {}
 
@@ -315,8 +316,8 @@ public:
 	void setNextThing(Thing thing) { _nextThing = thing; }
 	SensorType getType() { return (SensorType)(_datAndType & 0x7F); } // @ M39_TYPE
 	uint16 getData() { return _datAndType >> 7; } // @ M40_DATA
-	uint16 getDataMask1() { return (_datAndType >> 7) & 0xF; } // @ M42_MASK1
-	uint16 getDataMask2() { return (_datAndType >> 11) & 0xF; } // @ M43_MASK2
+	static uint16 getDataMask1(uint16 data) { return (data >> 7) & 0xF; } // @ M42_MASK1
+	static uint16 getDataMask2(uint16 data) { return (data >> 11) & 0xF; } // @ M43_MASK2
 	void setData(int16 dat) { _datAndType = (_datAndType & 0x7F) | (dat << 7); } // @ M41_SET_DATA
 	void setTypeDisabled() { _datAndType &= 0xFF80; } // @ M44_SET_TYPE_DISABLED
 
@@ -333,6 +334,8 @@ public:
 	uint16 getTargetMapY() { return (_action >> 11); }
 	uint16 getTargetMapX() { return (_action >> 6) & 0x1F; }
 	direction getTargetCell() { return (direction)((_action >> 4) & 3); }
+	uint16 M47_kineticEnergy() { return (_action & 0xFF); }// @ M47_KINETIC_ENERGY
+	uint16 M48_stepEnergy() { return (_action >> 8) & 0xFF; }// @ M48_STEP_ENERGY
 	uint16 M49_localEffect() { return (_action >> 4); }
 
 
@@ -652,7 +655,7 @@ class DungeonMan {
 
 	int16 f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal
 	void f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir,
-	                                     int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals
+										 int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals
 
 
 public:
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 5b2d137..524b5a5 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -256,7 +256,7 @@ void Timeline::f261_processTimeline() {
 				f250_timelineProcessEvent8_squareTeleporter(L0681_ps_Event);
 				break;
 			case k6_TMEventTypeWall:
-				//F0248_TIMELINE_ProcessEvent6_Square_Wall(L0681_ps_Event);
+				f248_timelineProcessEvent6_squareWall(L0681_ps_Event);
 				break;
 			case k5_TMEventTypeCorridor:
 				//F0245_TIMELINE_ProcessEvent5_Square_Corridor(L0681_ps_Event);
@@ -568,4 +568,177 @@ void Timeline::f250_timelineProcessEvent8_squareTeleporter(TimelineEvent* event)
 		clearFlag(*L0652_puc_Square, k0x0008_TeleporterOpen);
 	}
 }
+
+void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
+	Thing L0634_T_Thing;
+	int16 L0635_i_ThingType;
+	int16 L0636_i_Multiple;
+#define AL0636_B_TriggerSetEffect L0636_i_Multiple
+#define AL0636_i_BitMask          L0636_i_Multiple
+	uint16 L0637_ui_SensorData;
+	Sensor* L0638_ps_Sensor;
+	TextString* L0639_ps_TextString;
+	uint16 L0640_ui_SensorType;
+	int16 L0641_i_MapX;
+	int16 L0642_i_MapY;
+	uint16 L0643_ui_Cell;
+
+
+	L0634_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0641_i_MapX = event->_B._location._mapX, L0642_i_MapY = event->_B._location._mapY);
+	L0643_ui_Cell = event->_C.A._cell;
+	while (L0634_T_Thing != Thing::_endOfList) {
+		if (((L0635_i_ThingType = L0634_T_Thing.getType()) == k2_TextstringType) && (L0634_T_Thing.getCell() == event->_C.A._cell)) {
+			L0639_ps_TextString = (TextString*)_vm->_dungeonMan->f156_getThingData(L0634_T_Thing);
+			if (event->_C.A._effect == k2_SensorEffToggle) {
+				L0639_ps_TextString->setVisible(!L0639_ps_TextString->isVisible());
+			} else {
+				L0639_ps_TextString->setVisible(event->_C.A._effect == k0_SensorEffSet);
+			}
+		} else {
+			if (L0635_i_ThingType == k3_SensorThingType) {
+				L0638_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0634_T_Thing);
+				L0640_ui_SensorType = L0638_ps_Sensor->getType();
+				L0637_ui_SensorData = L0638_ps_Sensor->getData();
+				if (L0640_ui_SensorType == k6_SensorWallCountdown) {
+					if (L0637_ui_SensorData > 0) {
+						if (event->_C.A._effect == k0_SensorEffSet) {
+							if (L0637_ui_SensorData < 511) {
+								L0637_ui_SensorData++;
+							}
+						} else {
+							L0637_ui_SensorData--;
+						}
+						L0638_ps_Sensor->setData(L0637_ui_SensorData);
+						if (L0638_ps_Sensor->getEffectA() == k3_SensorEffHold) {
+							AL0636_B_TriggerSetEffect = ((L0637_ui_SensorData == 0) != L0638_ps_Sensor->getRevertEffectA());
+							_vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
+						} else {
+							if (L0637_ui_SensorData == 0) {
+								_vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
+							}
+						}
+					}
+				} else {
+					if (L0640_ui_SensorType == k5_SensorWallAndOrGate) {
+						AL0636_i_BitMask = 1 << (event->_C.A._cell);
+						if (event->_C.A._effect == k2_SensorEffToggle) {
+							if (getFlag(L0637_ui_SensorData, AL0636_i_BitMask)) {
+								clearFlag(L0637_ui_SensorData, AL0636_i_BitMask);
+							} else {
+								setFlag(L0637_ui_SensorData, AL0636_i_BitMask);
+							}
+						} else {
+							if (event->_C.A._effect) {
+								clearFlag(L0637_ui_SensorData, AL0636_i_BitMask);
+							} else {
+								setFlag(L0637_ui_SensorData, AL0636_i_BitMask);
+							}
+						}
+						L0638_ps_Sensor->setData(L0637_ui_SensorData);
+						AL0636_B_TriggerSetEffect = (Sensor::getDataMask1(L0637_ui_SensorData) == Sensor::getDataMask2(L0637_ui_SensorData)) != L0638_ps_Sensor->getRevertEffectA();
+						if (L0638_ps_Sensor->getEffectA() == k3_SensorEffHold) {
+							_vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
+						} else {
+							if (AL0636_B_TriggerSetEffect) {
+								_vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
+							}
+						}
+					} else {
+						if ((((L0640_ui_SensorType >= k7_SensorWallSingleProjLauncherNewObj) && (L0640_ui_SensorType <= k10_SensorWallDoubleProjLauncherExplosion)) || (L0640_ui_SensorType == k14_SensorWallSingleProjLauncherSquareObj) || (L0640_ui_SensorType == k15_SensorWallDoubleProjLauncherSquareObj)) && (L0634_T_Thing.getCell() == event->_C.A._cell)) {
+							f247_triggerProjectileLauncher(L0638_ps_Sensor, event);
+							if (L0638_ps_Sensor->getOnlyOnce()) {
+								L0638_ps_Sensor->setTypeDisabled();
+							}
+						} else {
+							if (L0640_ui_SensorType == k18_SensorWallEndGame) {
+								_vm->f22_delay(60 * L0638_ps_Sensor->getValue());
+								_vm->_g524_restartGameAllowed = false;
+								_vm->_g302_gameWon = true;
+								warning(false, "MISSING CODE: F0444_STARTEND_Endgame");
+							}
+						}
+					}
+				}
+			}
+		}
+		L0634_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0634_T_Thing);
+	}
+	_vm->_movsens->f271_processRotationEffect();
+}
+
+void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* event) {
+	Thing L0622_T_FirstProjectileAssociatedThing;
+	Thing L0623_T_SecondProjectileAssociatedThing;
+	uint16 L0624_ui_Cell;
+	int16 L0625_i_SensorType;
+	int16 L0626_i_MapX;
+	int16 L0627_i_MapY;
+	uint16 L0628_ui_ProjectileCell;
+	int16 L0629_i_SensorData;
+	int16 L0630_i_KineticEnergy;
+	int16 L0631_i_StepEnergy;
+	bool L0632_B_LaunchSingleProjectile;
+	uint16 L0633_ui_ThingCell;
+
+
+	L0626_i_MapX = event->_B._location._mapX;
+	L0627_i_MapY = event->_B._location._mapY;
+	L0624_ui_Cell = event->_C.A._cell;
+	L0628_ui_ProjectileCell = returnOppositeDir((direction)L0624_ui_Cell);
+	L0625_i_SensorType = sensor->getType();
+	L0629_i_SensorData = sensor->getData();
+	L0630_i_KineticEnergy = sensor->M47_kineticEnergy();
+	L0631_i_StepEnergy = sensor->M48_stepEnergy();
+	L0632_B_LaunchSingleProjectile = (L0625_i_SensorType == k7_SensorWallSingleProjLauncherNewObj) ||
+		(L0625_i_SensorType == k8_SensorWallSingleProjLauncherExplosion) ||
+		(L0625_i_SensorType == k14_SensorWallSingleProjLauncherSquareObj);
+	if ((L0625_i_SensorType == k8_SensorWallSingleProjLauncherExplosion) || (L0625_i_SensorType == k10_SensorWallDoubleProjLauncherExplosion)) {
+		L0622_T_FirstProjectileAssociatedThing = L0623_T_SecondProjectileAssociatedThing = Thing(L0629_i_SensorData + Thing::_firstExplosion.toUint16());
+	} else {
+		if ((L0625_i_SensorType == k14_SensorWallSingleProjLauncherSquareObj) || (L0625_i_SensorType == k15_SensorWallDoubleProjLauncherSquareObj)) {
+			L0622_T_FirstProjectileAssociatedThing = _vm->_dungeonMan->f161_getSquareFirstThing(L0626_i_MapX, L0627_i_MapY);
+			while (L0622_T_FirstProjectileAssociatedThing != Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList. If there are no more objects on the square then this loop may return an undefined value, this can crash the game. In the original DM and CSB dungeons, the number of times that these sensors are triggered is always controlled to be equal to the number of available objects (with a countdown sensor or a number of once only sensors) */
+				L0633_ui_ThingCell = L0622_T_FirstProjectileAssociatedThing.getCell();
+				if ((L0622_T_FirstProjectileAssociatedThing.getType() > k3_SensorThingType) && ((L0633_ui_ThingCell == L0624_ui_Cell) || (L0633_ui_ThingCell == returnNextVal(L0624_ui_Cell))))
+					break;
+				L0622_T_FirstProjectileAssociatedThing = _vm->_dungeonMan->f159_getNextThing(L0622_T_FirstProjectileAssociatedThing);
+			}
+			if (L0622_T_FirstProjectileAssociatedThing == Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList */
+				return;
+			}
+			_vm->_dungeonMan->f164_unlinkThingFromList(L0622_T_FirstProjectileAssociatedThing, Thing(0), L0626_i_MapX, L0627_i_MapY); /* The object is removed without triggering any sensor effects */
+			if (!L0632_B_LaunchSingleProjectile) {
+				L0623_T_SecondProjectileAssociatedThing = _vm->_dungeonMan->f161_getSquareFirstThing(L0626_i_MapX, L0627_i_MapY);
+				while (L0623_T_SecondProjectileAssociatedThing != Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList. If there are no more objects on the square then this loop may return an undefined value, this can crash the game */
+					L0633_ui_ThingCell = L0623_T_SecondProjectileAssociatedThing.getCell();
+					if ((L0623_T_SecondProjectileAssociatedThing.getType() > k3_SensorThingType) && ((L0633_ui_ThingCell == L0624_ui_Cell) || (L0633_ui_ThingCell == returnNextVal(L0624_ui_Cell))))
+						break;
+					L0623_T_SecondProjectileAssociatedThing = _vm->_dungeonMan->f159_getNextThing(L0623_T_SecondProjectileAssociatedThing);
+				}
+				if (L0623_T_SecondProjectileAssociatedThing == Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList */
+					L0632_B_LaunchSingleProjectile = true;
+				} else {
+					_vm->_dungeonMan->f164_unlinkThingFromList(L0623_T_SecondProjectileAssociatedThing, Thing(0), L0626_i_MapX, L0627_i_MapY); /* The object is removed without triggering any sensor effects */
+				}
+			}
+		} else {
+			if ((L0622_T_FirstProjectileAssociatedThing = _vm->_dungeonMan->f167_getObjForProjectileLaucherOrObjGen(L0629_i_SensorData)) == Thing::_none) {
+				return;
+			}
+			if (!L0632_B_LaunchSingleProjectile && ((L0623_T_SecondProjectileAssociatedThing = _vm->_dungeonMan->f167_getObjForProjectileLaucherOrObjGen(L0629_i_SensorData)) == Thing::_none)) {
+				L0632_B_LaunchSingleProjectile = true;
+			}
+		}
+	}
+	if (L0632_B_LaunchSingleProjectile) {
+		L0628_ui_ProjectileCell = M21_normalizeModulo4(L0628_ui_ProjectileCell + _vm->getRandomNumber(2));
+	}
+	L0626_i_MapX += _vm->_dirIntoStepCountEast[L0624_ui_Cell], L0627_i_MapY += _vm->_dirIntoStepCountNorth[L0624_ui_Cell]; /* BUG0_20 The game crashes if the launcher sensor is on a map boundary and shoots in a direction outside the map */
+	_vm->_projexpl->_g365_createLanucherProjectile = true;
+	_vm->_projexpl->f212_projectileCreate(L0622_T_FirstProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, L0628_ui_ProjectileCell, (direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy);
+	if (!L0632_B_LaunchSingleProjectile) {
+		_vm->_projexpl->f212_projectileCreate(L0623_T_SecondProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, returnNextVal(L0628_ui_ProjectileCell), (direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy);
+	}
+	_vm->_projexpl->_g365_createLanucherProjectile = false;
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index a0d2877..a11b26c 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -31,8 +31,9 @@
 #include "dm.h"
 
 namespace DM {
+	class Sensor;
 
-/* Event types */
+	/* Event types */
 enum TimelineEventType {
 /* Used when a creature in a group was damaged or killed by a Poison Cloud or by a closing door or if Lord Chaos is surrounded by = 3, Fluxcages */
 kM3_TMEventTypeCreateReactionEvent29DangerOnSquare = -3, // @ CM3_EVENT_CREATE_REACTION_EVENT_29_DANGER_ON_SQUARE 
@@ -169,7 +170,8 @@ public:
 	void f251_timelineProcessEvent9_squarePit(TimelineEvent *event); // @ F0251_TIMELINE_ProcessEvent9_Square_Pit
 	void f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY); // @ F0249_TIMELINE_MoveTeleporterOrPitSquareThings
 	void f250_timelineProcessEvent8_squareTeleporter(TimelineEvent *event); // @ F0250_TIMELINE_ProcessEvent8_Square_Teleporter
-
+	void f248_timelineProcessEvent6_squareWall(TimelineEvent *event); // @ F0248_TIMELINE_ProcessEvent6_Square_Wall
+	void f247_triggerProjectileLauncher(Sensor *sensor, TimelineEvent *event); // @ F0247_TIMELINE_TriggerProjectileLauncher
 };
 
 


Commit: 8ae94ec075278b2f7b77b0232400fb9a9a579581
    https://github.com/scummvm/scummvm/commit/8ae94ec075278b2f7b77b0232400fb9a9a579581
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f111 and f112

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 8535718..f05a8ca 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1376,33 +1376,30 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d
 void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIndex) {
 	static byte g200_palChangesDoorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 0, 130}; // @ G0200_auc_Graphic558_PaletteChanges_DoorOrnament_D3
 	static byte g201PalChangesDoorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0201_auc_Graphic558_PaletteChanges_DoorOrnament_D2
-#define AP0120_i_Height doorOrnOrdinal
-#define AP0121_i_ByteWidth viewDoorOrnIndex
-	int16 L0104_i_NativeBitmapIndex;
-	int16 coordSetGreenToad;
-	uint16* coordSetOrangeElk;
-	byte* L0107_puc_Multiple;
-#define AL0107_puc_Bitmap        L0107_puc_Multiple
-	byte* L0108_puc_Bitmap_Native;
-
-
-	if (doorOrnOrdinal) {
-		doorOrnOrdinal--;
-		L0104_i_NativeBitmapIndex = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex];
-		coordSetOrangeElk = &g207_doorOrnCoordSets[coordSetGreenToad = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]][viewDoorOrnIndex][0];
-		if (viewDoorOrnIndex == k2_ViewDoorOrnament_D1LCR) {
+
+	int16 AP0120_i_Height = doorOrnOrdinal;
+	int16 AP0121_i_ByteWidth = viewDoorOrnIndex;
+
+	if (AP0120_i_Height) {
+		AP0120_i_Height--;
+		int16 L0104_i_NativeBitmapIndex = _g103_currMapDoorOrnInfo[AP0120_i_Height][k0_NativeBitmapIndex];
+		int16 coordSetGreenToad = _g103_currMapDoorOrnInfo[AP0120_i_Height][k1_CoordinateSet];
+		uint16 *coordSetOrangeElk = &g207_doorOrnCoordSets[coordSetGreenToad][AP0121_i_ByteWidth][0];
+		byte *AL0107_puc_Bitmap;
+		if (AP0121_i_ByteWidth == k2_ViewDoorOrnament_D1LCR) {
 			AL0107_puc_Bitmap = f489_getNativeBitmapOrGraphic(L0104_i_NativeBitmapIndex);
 			AP0121_i_ByteWidth = k48_byteWidth;
 			AP0120_i_Height = 88;
 		} else {
-			if (!f491_isDerivedBitmapInCache(doorOrnOrdinal = k68_DerivedBitmapFirstDoorOrnament_D3 + (doorOrnOrdinal * 2) + viewDoorOrnIndex)) {
+			AP0120_i_Height = k68_DerivedBitmapFirstDoorOrnament_D3 + (AP0120_i_Height * 2) + AP0121_i_ByteWidth;
+			if (!f491_isDerivedBitmapInCache(AP0120_i_Height)) {
 				uint16 *coordSetRedEagle = &g207_doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR][0];
-				L0108_puc_Bitmap_Native = f489_getNativeBitmapOrGraphic(L0104_i_NativeBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(L0108_puc_Bitmap_Native, f492_getDerivedBitmap(doorOrnOrdinal), coordSetRedEagle[4] << 1, coordSetRedEagle[5], coordSetOrangeElk[1] - coordSetOrangeElk[0] + 1, coordSetOrangeElk[5], (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2);
-				f493_addDerivedBitmap(doorOrnOrdinal);
+				byte *L0108_puc_Bitmap_Native = f489_getNativeBitmapOrGraphic(L0104_i_NativeBitmapIndex);
+				f129_blitToBitmapShrinkWithPalChange(L0108_puc_Bitmap_Native, f492_getDerivedBitmap(AP0120_i_Height), coordSetRedEagle[4] << 1, coordSetRedEagle[5], coordSetOrangeElk[1] - coordSetOrangeElk[0] + 1, coordSetOrangeElk[5], (AP0121_i_ByteWidth == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2);
+				f493_addDerivedBitmap(AP0120_i_Height);
 			}
-			AL0107_puc_Bitmap = f492_getDerivedBitmap(doorOrnOrdinal);
-			if (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) {
+			AL0107_puc_Bitmap = f492_getDerivedBitmap(AP0120_i_Height);
+			if (AP0121_i_ByteWidth == k0_ViewDoorOrnament_D3LCR) {
 				AP0121_i_ByteWidth = k24_byteWidth;
 				AP0120_i_Height = 41;
 			} else {
@@ -1410,22 +1407,20 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn
 				AP0120_i_Height = 61;
 			}
 		}
-		{
-			Box box(coordSetOrangeElk[0], coordSetOrangeElk[1], coordSetOrangeElk[2], coordSetOrangeElk[3]);
-			f132_blitToBitmap(AL0107_puc_Bitmap, _g74_tmpBitmap, box, 0, 0, coordSetOrangeElk[4], AP0121_i_ByteWidth, k9_ColorGold, coordSetOrangeElk[5], AP0120_i_Height);
-		}
+
+		Box box(coordSetOrangeElk[0], coordSetOrangeElk[1], coordSetOrangeElk[2], coordSetOrangeElk[3]);
+		f132_blitToBitmap(AL0107_puc_Bitmap, _g74_tmpBitmap, box, 0, 0, coordSetOrangeElk[4], AP0121_i_ByteWidth, k9_ColorGold, coordSetOrangeElk[5], AP0120_i_Height);
 	}
 }
 
 void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame* frame, int16 mapX, int16 mapY, bool flipHorizontal) {
-	int16 L0117_i_Multiple;
-#define AL0117_i_MapIndex L0117_i_Multiple
-#define AL0117_i_Square   L0117_i_Multiple
+	int16 AL0117_i_MapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g272_currMapIndex, -1, &mapX, &mapY);
 
+	if (AL0117_i_MapIndex < 0)
+		return;
 
-	if (((AL0117_i_MapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g272_currMapIndex, -1, &mapX, &mapY)) >= 0) &&
-		(Square(AL0117_i_Square = _vm->_dungeonMan->_g279_dungeonMapData[AL0117_i_MapIndex][mapX][mapY]).getType() == k2_ElementTypePit) &&
-		getFlag(AL0117_i_Square, k0x0008_PitOpen)) {
+	int16 AL0117_i_Square = _vm->_dungeonMan->_g279_dungeonMapData[AL0117_i_MapIndex][mapX][mapY];
+	if ((Square(AL0117_i_Square).getType() == k2_ElementTypePit) && getFlag(AL0117_i_Square, k0x0008_PitOpen)) {
 		if (flipHorizontal) {
 			_vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(nativeBitmapIndex, *frame);
 		} else {


Commit: e8342f2d2abe58f03788c6db3302f6b29ac1bfe4
    https://github.com/scummvm/scummvm/commit/e8342f2d2abe58f03788c6db3302f6b29ac1bfe4
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix a bug in drawPanelObject, fix some casts formatting

Changed paths:
    engines/dm/inventory.cpp



diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 3d61270..a0c6e57 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -438,7 +438,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 	if (thingType == k7_ScrollThingType) {
 		f341_drawPanelScroll((Scroll*)rawThingPtr);
 	} else if (thingType == k9_ContainerThingType) {
-		f333_openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye);
+		f333_openAndDrawChest(thingToDraw, (Container *)rawThingPtr, pressingEye);
 	} else {
 		IconIndice iconIndex = objMan.f33_getIconIndex(thingToDraw);
 		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), dispMan._g296_bitmapViewport,
@@ -449,7 +449,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		char *descString = nullptr;
 		char str[40];
 		if (iconIndex == k147_IconIndiceJunkChampionBones) {
-			strcpy(str, champMan._gK71_champions[((Junk*)rawThingPtr)->getChargeCount()]._name);  // TODO: localization
+			strcpy(str, champMan._gK71_champions[((Junk *)rawThingPtr)->getChargeCount()]._name);  // TODO: localization
 			strcat(str, " "); // TODO: localization
 			strcat(str, objMan._g352_objectNames[iconIndex]);  // TODO: localization
 
@@ -457,7 +457,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		} else if ((thingType == k8_PotionThingType)
 				   && (iconIndex != k163_IconIndicePotionWaterFlask)
 				   && (champMan.f303_getSkillLevel((ChampionIndex)_vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
-			str[0] = '_' + ((Potion*)rawThingPtr)->getPower() / 40;
+			str[0] = '_' + ((Potion *)rawThingPtr)->getPower() / 40;
 			str[1] = ' ';
 			str[2] = '\0';
 			strcat(str, objMan._g352_objectNames[iconIndex]);
@@ -478,7 +478,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		switch (thingType) {
 		case k5_WeaponThingType: {
 			potentialAttribMask = k0x0008_DescriptionMaskCursed | k0x0002_DescriptionMaskPoisoned | k0x0004_DescriptionMaskBroken;
-			Weapon *weapon = (Weapon*)rawThingPtr;
+			Weapon *weapon = (Weapon *)rawThingPtr;
 			actualAttribMask = (weapon->getCursed() << 3) | (weapon->getPoisoned() << 1) | (weapon->getBroken() << 2);
 			if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit)
 				&& (iconIndex <= k7_IconIndiceWeaponTorchLit)
@@ -489,18 +489,18 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		}
 		case k6_ArmourThingType: {
 			potentialAttribMask = k0x0008_DescriptionMaskCursed | k0x0004_DescriptionMaskBroken;
-			Armour *armour = (Armour*)rawThingPtr;
+			Armour *armour = (Armour *)rawThingPtr;
 			actualAttribMask = (armour->getCursed() << 3) | (armour->getBroken() << 2);
 			break;
 		}
 		case k8_PotionThingType: {
-			actualAttribMask = k0x0001_DescriptionMaskConsumable;
-			Potion *potion = (Potion*)rawThingPtr;
+			potentialAttribMask = k0x0001_DescriptionMaskConsumable;
+			Potion *potion = (Potion *)rawThingPtr;
 			actualAttribMask = g237_ObjectInfo[k2_ObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots();
 			break;
 		}
 		case k10_JunkThingType: {
-			Junk *junk = (Junk*)rawThingPtr;
+			Junk *junk = (Junk *)rawThingPtr;
 			if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
 				potentialAttribMask = 0;
 				switch (junk->getChargeCount()) {


Commit: 9aa6c28fabd95d3aeaf5840386fb5d3327247d62
    https://github.com/scummvm/scummvm/commit/9aa6c28fabd95d3aeaf5840386fb5d3327247d62
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f245_timlineProcessEvent5_squareCorridor

Changed paths:
    engines/dm/dungeonman.h
    engines/dm/group.cpp
    engines/dm/group.h
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index e0a1d8f..049c8ea 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -336,7 +336,9 @@ public:
 	direction getTargetCell() { return (direction)((_action >> 4) & 3); }
 	uint16 M47_kineticEnergy() { return (_action & 0xFF); }// @ M47_KINETIC_ENERGY
 	uint16 M48_stepEnergy() { return (_action >> 8) & 0xFF; }// @ M48_STEP_ENERGY
-	uint16 M49_localEffect() { return (_action >> 4); }
+	uint16 M49_localEffect() { return _action; } // @ M49_LOCAL_EFFECT
+	uint16 M45_healthMultiplier() { return (_action & 0xF); } // @ M45_HEALTH_MULTIPLIER
+	uint16 M46_ticks() { return (_action >> 4) & 0xFFF; } // @ M46_TICKS
 
 
 	// some macros missing, i got bored
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index a39065b..73c2119 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1766,4 +1766,47 @@ void GroupMan::f195_addAllActiveGroups() {
 		}
 	}
 }
+
+Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, direction dir, int16 mapX, int16 mapY) {
+	Thing L0349_T_GroupThing;
+	uint16 L0350_ui_BaseHealth;
+	uint16 L0351_ui_Cell = 0;
+	uint16 L0352_ui_GroupCells = 0;
+	Group* L0353_ps_Group;
+	CreatureInfo* L0354_ps_CreatureInfo;
+	bool L0355_B_SeveralCreaturesInGroup;
+
+
+	if (((_g377_currActiveGroupCount >= (_vm->_groupMan->_g376_maxActiveGroupCount - 5)) && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) || ((L0349_T_GroupThing = _vm->_dungeonMan->f166_getUnusedThing(k4_GroupThingType)) == Thing::_none)) {
+		return Thing::_none;
+	}
+	L0353_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0349_T_GroupThing);
+	L0353_ps_Group->_slot = Thing::_endOfList;
+	L0353_ps_Group->setDoNotDiscard(false);
+	L0353_ps_Group->setDir(dir);
+	L0353_ps_Group->setCount(creatureCount);
+	if (L0355_B_SeveralCreaturesInGroup = creatureCount) {
+		L0351_ui_Cell = _vm->getRandomNumber(4);
+	} else {
+		L0352_ui_GroupCells = k255_CreatureTypeSingleCenteredCreature;
+	}
+	L0354_ps_CreatureInfo = &g243_CreatureInfo[L0353_ps_Group->_type = creatureType];
+	L0350_ui_BaseHealth = L0354_ps_CreatureInfo->_baseHealth;
+	do {
+		L0353_ps_Group->_health[creatureCount] = (L0350_ui_BaseHealth * healthMultiplier) + _vm->getRandomNumber((L0350_ui_BaseHealth >> 2) + 1);
+		if (L0355_B_SeveralCreaturesInGroup) {
+			L0352_ui_GroupCells = f178_getGroupValueUpdatedWithCreatureValue(L0352_ui_GroupCells, creatureCount, L0351_ui_Cell++);
+			if (getFlag(L0354_ps_CreatureInfo->_attributes, k0x0003_MaskCreatureInfo_size) == k1_MaskCreatureSizeHalf) {
+				L0351_ui_Cell++;
+			}
+			L0351_ui_Cell &= 0x0003;
+		}
+	} while (creatureCount--);
+	L0353_ps_Group->_cells = L0352_ui_GroupCells;
+	if (_vm->_movsens->f267_getMoveResult(L0349_T_GroupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) { /* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile impact (in which case the thing data was marked as unused) or the party is on the destination square and an event is created to move the creature into the dungeon later (in which case the thing is referenced in the event) */
+		return Thing::_none;
+	}
+	warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+	return L0349_T_GroupThing;
+}
 }
diff --git a/engines/dm/group.h b/engines/dm/group.h
index ca7cb52..6153d51 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -133,6 +133,7 @@ public:
 	direction getDir() { return (direction)((_flags >> 8) & 0x3); }
 	void setDir(uint16 val) { _flags = (_flags & ~(0x3 << 8)) | ((val & 0x3) << 8); }
 	uint16 getDoNotDiscard() { return (_flags >> 10) & 0x1; }
+	void setDoNotDiscard(bool val) { _flags = (_flags & ~(1 << 10)) | ((val & 1) << 10); }
 }; // @ GROUP
 
 #define k0_behavior_WANDER 0 // @ C0_BEHAVIOR_WANDER
@@ -233,6 +234,7 @@ public:
 	void f184_removeActiveGroup(uint16 activeGroupIndex); // @ F0184_GROUP_RemoveActiveGroup
 	void f194_removeAllActiveGroups(); // @ F0194_GROUP_RemoveAllActiveGroups
 	void f195_addAllActiveGroups(); // @ F0195_GROUP_AddAllActiveGroups
+	Thing f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated
 
 
 
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 524b5a5..1737648 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -32,6 +32,7 @@
 #include "group.h"
 #include "projexpl.h"
 #include "movesens.h"
+#include "text.h"
 
 
 namespace DM {
@@ -259,7 +260,7 @@ void Timeline::f261_processTimeline() {
 				f248_timelineProcessEvent6_squareWall(L0681_ps_Event);
 				break;
 			case k5_TMEventTypeCorridor:
-				//F0245_TIMELINE_ProcessEvent5_Square_Corridor(L0681_ps_Event);
+				f245_timlineProcessEvent5_squareCorridor(L0681_ps_Event);
 				break;
 			case k60_TMEventTypeMoveGroupSilent:
 			case k61_TMEventTypeMoveGroupAudible:
@@ -741,4 +742,77 @@ void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* eve
 	}
 	_vm->_projexpl->_g365_createLanucherProjectile = false;
 }
+
+void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
+#define k0x0008_randomizeGeneratedCreatureCount 0x0008 // @ MASK0x0008_RANDOMIZE_GENERATED_CREATURE_COUNT
+#define k0x0007_generatedCreatureCount 0x0007	// @ MASK0x0007_GENERATED_CREATURE_COUNT
+
+	int16 L0610_i_ThingType;
+	bool L0611_B_TextCurrentlyVisible;
+	int16 L0612_i_CreatureCount;
+	Thing L0613_T_Thing;
+	Sensor* L0614_ps_Sensor;
+	TextString* L0615_ps_TextString;
+	uint16 L0616_ui_MapX;
+	uint16 L0617_ui_MapY;
+	uint16 L0618_ui_Multiple;
+#define AL0618_ui_HealthMultiplier L0618_ui_Multiple
+#define AL0618_ui_Ticks            L0618_ui_Multiple
+	TimelineEvent L0619_s_Event;
+
+
+	L0613_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0616_ui_MapX = event->_B._location._mapX, L0617_ui_MapY = event->_B._location._mapY);
+	while (L0613_T_Thing != Thing::_endOfList) {
+		if ((L0610_i_ThingType = L0613_T_Thing.getType()) == k2_TextstringType) {
+			L0615_ps_TextString = (TextString*)_vm->_dungeonMan->f156_getThingData(L0613_T_Thing);
+			L0611_B_TextCurrentlyVisible = L0615_ps_TextString->isVisible();
+			if (event->_C.A._effect == k2_SensorEffToggle) {
+				L0615_ps_TextString->setVisible(!L0611_B_TextCurrentlyVisible);
+			} else {
+				L0615_ps_TextString->setVisible((event->_C.A._effect == k0_SensorEffSet));
+			}
+			if (!L0611_B_TextCurrentlyVisible && L0615_ps_TextString->isVisible() && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0616_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0617_ui_MapY == _vm->_dungeonMan->_g307_partyMapY)) {
+				_vm->_dungeonMan->f168_decodeText(_vm->_g353_stringBuildBuffer, L0613_T_Thing, k1_TextTypeMessage);
+				_vm->_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, _vm->_g353_stringBuildBuffer);
+			}
+		} else {
+			if (L0610_i_ThingType == k3_SensorThingType) {
+				L0614_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0613_T_Thing);
+				if (L0614_ps_Sensor->getType() == k6_SensorFloorGroupGenerator) {
+					L0612_i_CreatureCount = L0614_ps_Sensor->getValue();
+					if (getFlag(L0612_i_CreatureCount, k0x0008_randomizeGeneratedCreatureCount)) {
+						L0612_i_CreatureCount = _vm->getRandomNumber(getFlag(L0612_i_CreatureCount, k0x0007_generatedCreatureCount));
+					} else {
+						L0612_i_CreatureCount--;
+					}
+					if ((AL0618_ui_HealthMultiplier = L0614_ps_Sensor->M45_healthMultiplier()) == 0) {
+						AL0618_ui_HealthMultiplier = _vm->_dungeonMan->_g269_currMap->_difficulty;
+					}
+					_vm->_groupMan->f185_groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY);
+					if (L0614_ps_Sensor->getAudibleA()) {
+						warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+					}
+					if (L0614_ps_Sensor->getOnlyOnce()) {
+						L0614_ps_Sensor->setTypeDisabled();
+					} else {
+						if ((AL0618_ui_Ticks = L0614_ps_Sensor->M46_ticks()) != 0) {
+							L0614_ps_Sensor->setTypeDisabled();
+							if (AL0618_ui_Ticks > 127) {
+								AL0618_ui_Ticks = (AL0618_ui_Ticks - 126) << 6;
+							}
+							L0619_s_Event._type = k65_TMEventTypeEnableGroupGenerator;
+							M33_setMapAndTime(L0619_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + AL0618_ui_Ticks);
+							L0619_s_Event._priority = 0;
+							L0619_s_Event._B._location._mapX = L0616_ui_MapX;
+							L0619_s_Event._B._location._mapY = L0617_ui_MapY;
+							L0619_s_Event._B._location._mapY = L0617_ui_MapY;
+							_vm->_timeline->f238_addEventGetEventIndex(&L0619_s_Event);
+						}
+					}
+				}
+			}
+		}
+		L0613_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0613_T_Thing);
+	}
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index a11b26c..3e5cbcd 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -172,6 +172,7 @@ public:
 	void f250_timelineProcessEvent8_squareTeleporter(TimelineEvent *event); // @ F0250_TIMELINE_ProcessEvent8_Square_Teleporter
 	void f248_timelineProcessEvent6_squareWall(TimelineEvent *event); // @ F0248_TIMELINE_ProcessEvent6_Square_Wall
 	void f247_triggerProjectileLauncher(Sensor *sensor, TimelineEvent *event); // @ F0247_TIMELINE_TriggerProjectileLauncher
+	void f245_timlineProcessEvent5_squareCorridor(TimelineEvent *event); // @ F0245_TIMELINE_ProcessEvent5_Square_Corridor
 };
 
 


Commit: 278e0b6647bd9cc46818771da86a2fadb30cd123
    https://github.com/scummvm/scummvm/commit/278e0b6647bd9cc46818771da86a2fadb30cd123
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f252_timelineProcessEvents60to61_moveGroup

Changed paths:
    engines/dm/group.cpp
    engines/dm/group.h
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 73c2119..49ac924 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1809,4 +1809,12 @@ Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplie
 	warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
 	return L0349_T_GroupThing;
 }
+
+bool GroupMan::f223_isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY) {
+	int16 L0544_i_SquareType;
+
+	return (((L0544_i_SquareType = Square(_vm->_dungeonMan->f151_getSquare(mapX, mapY)).getType()) == k1_CorridorElemType)
+			|| (L0544_i_SquareType == k5_ElementTypeTeleporter) || (L0544_i_SquareType == k2_ElementTypePit) || (L0544_i_SquareType == k4_DoorElemType));
+}
+
 }
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 6153d51..242e527 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -235,11 +235,7 @@ public:
 	void f194_removeAllActiveGroups(); // @ F0194_GROUP_RemoveAllActiveGroups
 	void f195_addAllActiveGroups(); // @ F0195_GROUP_AddAllActiveGroups
 	Thing f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated
-
-
-
-
-
+	bool f223_isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY); // @ F0223_GROUP_IsSquareACorridorTeleporterPitOrDoor
 
 };
 
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 1737648..2bb96e0 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -264,7 +264,7 @@ void Timeline::f261_processTimeline() {
 				break;
 			case k60_TMEventTypeMoveGroupSilent:
 			case k61_TMEventTypeMoveGroupAudible:
-				//F0252_TIMELINE_ProcessEvents60to61_MoveGroup(L0681_ps_Event);
+				f252_timelineProcessEvents60to61_moveGroup(L0681_ps_Event);
 				break;
 			case k65_TMEventTypeEnableGroupGenerator:
 				//F0246_TIMELINE_ProcessEvent65_EnableGroupGenerator(L0681_ps_Event);
@@ -815,4 +815,48 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 		L0613_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0613_T_Thing);
 	}
 }
+
+void Timeline::f252_timelineProcessEvents60to61_moveGroup(TimelineEvent* event) {
+	uint16 L0656_ui_MapX;
+	uint16 L0657_ui_MapY;
+	Group* L0658_ps_Group;
+	bool L0659_B_RandomDirectionMoveRetried;
+
+
+	L0659_B_RandomDirectionMoveRetried = false;
+	L0656_ui_MapX = event->_B._location._mapX;
+	L0657_ui_MapY = event->_B._location._mapY;
+	L0657_ui_MapY = event->_B._location._mapY;
+T0252001:
+	if (((_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) || (L0656_ui_MapX != _vm->_dungeonMan->_g306_partyMapX) || (L0657_ui_MapY != _vm->_dungeonMan->_g307_partyMapY)) && (_vm->_groupMan->f175_groupGetThing(L0656_ui_MapX, L0657_ui_MapY) == Thing::_endOfList)) { /* BUG0_24 Lord Chaos may teleport into one of the Black Flames and become invisible until the Black Flame is killed. In this case, _vm->_groupMan->f175_groupGetThing returns the Black Flame thing and the Lord Chaos thing is not moved into the dungeon until the Black Flame is killed */
+		if (event->_type == k61_TMEventTypeMoveGroupAudible) {
+			warning(false, "F0064_SOUND_RequestPlay_CPSD");
+		}
+		_vm->_movsens->f267_getMoveResult(Thing(event->_C._slot), kM1_MapXNotOnASquare, 0, L0656_ui_MapX, L0657_ui_MapY);
+	} else {
+		if (!L0659_B_RandomDirectionMoveRetried) {
+			L0659_B_RandomDirectionMoveRetried = true;
+			L0658_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(Thing(event->_C._slot));
+			if ((L0658_ps_Group->_type == k23_CreatureTypeLordChaos) && !_vm->getRandomNumber(4)) {
+				switch (_vm->getRandomNumber(4)) {
+				case 0:
+					L0656_ui_MapX--;
+					break;
+				case 1:
+					L0656_ui_MapX++;
+					break;
+				case 2:
+					L0657_ui_MapY--;
+					break;
+				case 3:
+					L0657_ui_MapY++;
+				}
+				if (_vm->_groupMan->f223_isSquareACorridorTeleporterPitOrDoor(L0656_ui_MapX, L0657_ui_MapY))
+					goto T0252001;
+			}
+		}
+		event->_mapTime += 5;
+		_vm->_timeline->f238_addEventGetEventIndex(event);
+	}
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 3e5cbcd..c56db55 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -173,6 +173,7 @@ public:
 	void f248_timelineProcessEvent6_squareWall(TimelineEvent *event); // @ F0248_TIMELINE_ProcessEvent6_Square_Wall
 	void f247_triggerProjectileLauncher(Sensor *sensor, TimelineEvent *event); // @ F0247_TIMELINE_TriggerProjectileLauncher
 	void f245_timlineProcessEvent5_squareCorridor(TimelineEvent *event); // @ F0245_TIMELINE_ProcessEvent5_Square_Corridor
+	void f252_timelineProcessEvents60to61_moveGroup(TimelineEvent *event); // @ F0252_TIMELINE_ProcessEvents60to61_MoveGroup
 };
 
 


Commit: 3b917d35c4dfc962aeb4786bd84fc54bdee3f24e
    https://github.com/scummvm/scummvm/commit/3b917d35c4dfc962aeb4786bd84fc54bdee3f24e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f246_timelineProcesEvent65_enableGroupGenerator

Changed paths:
    engines/dm/dungeonman.h
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 049c8ea..2a6a8b7 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -340,8 +340,8 @@ public:
 	uint16 M45_healthMultiplier() { return (_action & 0xF); } // @ M45_HEALTH_MULTIPLIER
 	uint16 M46_ticks() { return (_action >> 4) & 0xFFF; } // @ M46_TICKS
 
+	void setDatAndTypeWithOr(uint16 val) { _datAndType |= val;  }
 
-	// some macros missing, i got bored
 }; // @ SENSOR
 
 
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 2bb96e0..a34fc49 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -267,7 +267,7 @@ void Timeline::f261_processTimeline() {
 				f252_timelineProcessEvents60to61_moveGroup(L0681_ps_Event);
 				break;
 			case k65_TMEventTypeEnableGroupGenerator:
-				//F0246_TIMELINE_ProcessEvent65_EnableGroupGenerator(L0681_ps_Event);
+				f246_timelineProcesEvent65_enableGroupGenerator(L0681_ps_Event);
 				break;
 			case k20_TMEventTypePlaySound:
 				warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
@@ -859,4 +859,22 @@ T0252001:
 		_vm->_timeline->f238_addEventGetEventIndex(event);
 	}
 }
+
+void Timeline::f246_timelineProcesEvent65_enableGroupGenerator(TimelineEvent* event) {
+	Thing L0620_T_Thing;
+	Sensor* L0621_ps_Sensor;
+
+	L0620_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(event->_B._location._mapX, event->_B._location._mapY);
+	L0620_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(event->_B._location._mapX, event->_B._location._mapY);
+	while (L0620_T_Thing != Thing::_none) {
+		if ((L0620_T_Thing.getType()) == k3_SensorThingType) {
+			L0621_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0620_T_Thing);
+			if (L0621_ps_Sensor->getType() == k0_SensorDisabled) {
+				L0621_ps_Sensor->setDatAndTypeWithOr(k6_SensorFloorGroupGenerator);
+				return;
+			}
+		}
+		L0620_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0620_T_Thing);
+	}
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index c56db55..02e13a5 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -174,6 +174,7 @@ public:
 	void f247_triggerProjectileLauncher(Sensor *sensor, TimelineEvent *event); // @ F0247_TIMELINE_TriggerProjectileLauncher
 	void f245_timlineProcessEvent5_squareCorridor(TimelineEvent *event); // @ F0245_TIMELINE_ProcessEvent5_Square_Corridor
 	void f252_timelineProcessEvents60to61_moveGroup(TimelineEvent *event); // @ F0252_TIMELINE_ProcessEvents60to61_MoveGroup
+	void f246_timelineProcesEvent65_enableGroupGenerator(TimelineEvent *event); // @ F0246_TIMELINE_ProcessEvent65_EnableGroupGenerator
 };
 
 


Commit: 4818eaaf55bb40164fd3d0ca00dbbaa09a7e789d
    https://github.com/scummvm/scummvm/commit/4818eaaf55bb40164fd3d0ca00dbbaa09a7e789d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f253_timelineProcessEvent11Part1_enableChampionAction

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index a968411..a84ccb8 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1163,6 +1163,32 @@ int16 ChampionMan::f310_getMovementTicks(Champion* champ) {
 	return L0933_i_Ticks;
 }
 
+bool ChampionMan::f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex, uint16 ammunitionSlotIndex) {
+	Champion* L0874_ps_Champion;
+	WeaponInfo* L0875_ps_WeaponInfo;
+	Thing L0878_T_Thing;
+	int16 L0879_i_WeaponClass;
+
+	L0874_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	L0878_T_Thing = L0874_ps_Champion->_slots[weaponSlotIndex];
+	if (L0878_T_Thing.getType() != k5_WeaponThingType) {
+		return false;
+	}
+	L0875_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0878_T_Thing);
+	if ((L0875_ps_WeaponInfo->_class >= k16_WeaponClassFirstBow) && (L0875_ps_WeaponInfo->_class <= k31_WeaponClassLastBow)) {
+		L0879_i_WeaponClass = k10_WeaponClassBowAmmunition;
+	} else {
+		if ((L0875_ps_WeaponInfo->_class >= k32_WeaponClassFirstSling) && (L0875_ps_WeaponInfo->_class <= k47_WeaponClassLastSling)) {
+			L0879_i_WeaponClass = k11_WeaponClassSlingAmmunition;
+		} else {
+			return false;
+		}
+	}
+	L0878_T_Thing = L0874_ps_Champion->_slots[ammunitionSlotIndex];
+	L0875_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0878_T_Thing);
+	return ((L0878_T_Thing.getType() == k5_WeaponThingType) && (L0875_ps_WeaponInfo->_class == L0879_i_WeaponClass));
+}
+
 ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
 	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
 		if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 16c53c8..17686f9 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -521,7 +521,8 @@ public:
 	void f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount); // @ F0317_CHAMPION_AddScentStrength
 	void f297_putObjectInLeaderHand(Thing thing, bool setMousePointer); // @ F0297_CHAMPION_PutObjectInLeaderHand
 	int16 f310_getMovementTicks(Champion *champ); // @ F0310_CHAMPION_GetMovementTicks
-
+	bool f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex,
+											   uint16 ammunitionSlotIndex); // @ F0294_CHAMPION_IsAmmunitionCompatibleWithWeapon
 
 
 
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index a34fc49..85aadcb 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -37,6 +37,52 @@
 
 namespace DM {
 
+signed char g495_actionDefense[44] = { // @ G0495_ac_Graphic560_ActionDefense
+	0,   /* N */
+	36,  /* BLOCK */
+	0,   /* CHOP */
+	0,   /* X */
+	-4,  /* BLOW HORN */
+	-10, /* FLIP */
+	-10, /* PUNCH */
+	-5,  /* KICK */
+	4,   /* WAR CRY */
+	-20, /* STAB */
+	-15, /* CLIMB DOWN */
+	-10, /* FREEZE LIFE */
+	16,  /* HIT */
+	5,   /* SWING */
+	-15, /* STAB */
+	-17, /* THRUST */
+	-5,  /* JAB */
+	29,  /* PARRY */
+	10,  /* HACK */
+	-10, /* BERZERK */
+	-7,  /* FIREBALL */
+	-7,  /* DISPELL */
+	-7,  /* CONFUSE */
+	-7,  /* LIGHTNING */
+	-7,  /* DISRUPT */
+	-5,  /* MELEE */
+	-15, /* X */
+	-9,  /* INVOKE */
+	4,   /* SLASH */
+	0,   /* CLEAVE */
+	0,   /* BASH */
+	5,   /* STUN */
+	-15, /* SHOOT */
+	-7,  /* SPELLSHIELD */
+	-7,  /* FIRESHIELD */
+	8,   /* FLUXCAGE */
+	-20, /* HEAL */
+	-5,  /* CALM */
+	0,   /* LIGHT */
+	-15, /* WINDOW */
+	-7,  /* SPIT */
+	-4,  /* BRANDISH */
+	0,   /* THROW */
+	8};  /* FUSE */
+
 Timeline::Timeline(DMEngine* vm) : _vm(vm) {
 	_g369_eventMaxCount = 0;
 	_g370_events = nullptr;
@@ -280,7 +326,7 @@ void Timeline::f261_processTimeline() {
 				}
 				break;
 			case k11_TMEventTypeEnableChampionAction:
-				//F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction(L0682_s_Event._priority);
+				f253_timelineProcessEvent11Part1_enableChampionAction(L0682_s_Event._priority);
 				if (L0682_s_Event._B._slotOrdinal) {
 					//F0259_TIMELINE_ProcessEvent11Part2_MoveWeaponFromQuiverToSlot(L0682_s_Event._priority, _vm->M1_ordinalToIndex(L0682_s_Event._B._slotOrdinal));
 				}
@@ -877,4 +923,33 @@ void Timeline::f246_timelineProcesEvent65_enableGroupGenerator(TimelineEvent* ev
 		L0620_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0620_T_Thing);
 	}
 }
+
+void Timeline::f253_timelineProcessEvent11Part1_enableChampionAction(uint16 champIndex) {
+	int16 L0660_i_SlotIndex;
+	int16 L0661_i_QuiverSlotIndex;
+	Champion* L0662_ps_Champion;
+
+	L0662_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	L0662_ps_Champion->_enableActionEventIndex = -1;
+	clearFlag(L0662_ps_Champion->_attributes, k0x0008_ChampionAttributeDisableAction);
+	if (L0662_ps_Champion->_actionIndex != k255_ChampionActionNone) {
+		L0662_ps_Champion->_actionDefense -= g495_actionDefense[L0662_ps_Champion->_actionDefense];
+	}
+	if (L0662_ps_Champion->_currHealth) {
+		if ((L0662_ps_Champion->_actionIndex == k32_ChampionActionShoot) && (L0662_ps_Champion->_slots[k0_ChampionSlotReadyHand] == Thing::_none)) {
+			if (_vm->_championMan->f294_isAmmunitionCompatibleWithWeapon(champIndex, k1_ChampionSlotActionHand, L0660_i_SlotIndex = k12_ChampionSlotQuiverLine_1_1)) {
+T0253002:
+				_vm->_championMan->f301_addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, L0660_i_SlotIndex), k0_ChampionSlotReadyHand);
+			} else {
+				for (L0661_i_QuiverSlotIndex = 0; L0661_i_QuiverSlotIndex < 3; L0661_i_QuiverSlotIndex++) {
+					if (_vm->_championMan->f294_isAmmunitionCompatibleWithWeapon(champIndex, k1_ChampionSlotActionHand, L0660_i_SlotIndex = L0661_i_QuiverSlotIndex + k7_ChampionSlotQuiverLine_2_1))
+						goto T0253002;
+				}
+			}
+		}
+		setFlag(L0662_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand);
+		_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+	}
+	L0662_ps_Champion->_actionIndex = k255_ChampionActionNone;
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 02e13a5..f6f61ee 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -94,6 +94,8 @@ k82_TMEventTypeMagicMap_C82 = 82, // @ C82_EVENT_MAGIC_MAP
 k83_TMEventTypeMagicMap_C83 = 83  // @ C83_EVENT_MAGIC_MAP    
 };
 
+extern signed char g495_actionDefense[44];
+
 class TimelineEvent {
 public:
 	int32 _mapTime;
@@ -175,6 +177,7 @@ public:
 	void f245_timlineProcessEvent5_squareCorridor(TimelineEvent *event); // @ F0245_TIMELINE_ProcessEvent5_Square_Corridor
 	void f252_timelineProcessEvents60to61_moveGroup(TimelineEvent *event); // @ F0252_TIMELINE_ProcessEvents60to61_MoveGroup
 	void f246_timelineProcesEvent65_enableGroupGenerator(TimelineEvent *event); // @ F0246_TIMELINE_ProcessEvent65_EnableGroupGenerator
+	void f253_timelineProcessEvent11Part1_enableChampionAction(uint16 champIndex); // @ F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction
 };
 
 


Commit: c62029211dbd377b240bce8687175a5ed40cd8da
    https://github.com/scummvm/scummvm/commit/c62029211dbd377b240bce8687175a5ed40cd8da
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot

Changed paths:
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 85aadcb..f8725a2 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -328,7 +328,7 @@ void Timeline::f261_processTimeline() {
 			case k11_TMEventTypeEnableChampionAction:
 				f253_timelineProcessEvent11Part1_enableChampionAction(L0682_s_Event._priority);
 				if (L0682_s_Event._B._slotOrdinal) {
-					//F0259_TIMELINE_ProcessEvent11Part2_MoveWeaponFromQuiverToSlot(L0682_s_Event._priority, _vm->M1_ordinalToIndex(L0682_s_Event._B._slotOrdinal));
+					f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(L0682_s_Event._priority, _vm->M1_ordinalToIndex(L0682_s_Event._B._slotOrdinal));
 				}
 				goto T0261048;
 			case k12_TMEventTypeHideDamageReceived:
@@ -952,4 +952,30 @@ T0253002:
 	}
 	L0662_ps_Champion->_actionIndex = k255_ChampionActionNone;
 }
+
+void Timeline::f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(uint16 champIndex, uint16 slotIndex) {
+	uint16 L0677_ui_SlotIndex;
+	Champion* L0678_ps_Champion;
+
+	L0678_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	if (L0678_ps_Champion->_slots[slotIndex] != Thing::_none) {
+		return;
+	}
+	if (f258_timelineHasWeaponMovedSlot(champIndex, L0678_ps_Champion, k12_ChampionSlotQuiverLine_1_1, slotIndex)) {
+		return;
+	}
+	for (L0677_ui_SlotIndex = k7_ChampionSlotQuiverLine_2_1; L0677_ui_SlotIndex <= k9_ChampionSlotQuiverLine_2_2; L0677_ui_SlotIndex++) {
+		if (f258_timelineHasWeaponMovedSlot(champIndex, L0678_ps_Champion, L0677_ui_SlotIndex, slotIndex))
+			break;
+	}
+}
+
+bool Timeline::f258_timelineHasWeaponMovedSlot(int16 champIndex, Champion* champ, uint16 sourceSlotIndex, int16 destSlotIndex) {
+	if (Thing(champ->_slots[sourceSlotIndex]).getType() == k5_WeaponThingType) {
+		_vm->_championMan->f301_addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, sourceSlotIndex),
+												(ChampionSlot)destSlotIndex);
+		return true;
+	}
+	return false;
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index f6f61ee..021889d 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -31,6 +31,7 @@
 #include "dm.h"
 
 namespace DM {
+	class Champion;
 	class Sensor;
 
 	/* Event types */
@@ -178,6 +179,10 @@ public:
 	void f252_timelineProcessEvents60to61_moveGroup(TimelineEvent *event); // @ F0252_TIMELINE_ProcessEvents60to61_MoveGroup
 	void f246_timelineProcesEvent65_enableGroupGenerator(TimelineEvent *event); // @ F0246_TIMELINE_ProcessEvent65_EnableGroupGenerator
 	void f253_timelineProcessEvent11Part1_enableChampionAction(uint16 champIndex); // @ F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction
+	void f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(uint16 champIndex,
+																	 uint16 slotIndex);// @ F0259_TIMELINE_ProcessEvent11Part2_MoveWeaponFromQuiverToSlot
+	bool f258_timelineHasWeaponMovedSlot(int16 champIndex, Champion *champ,
+										 uint16 sourceSlotIndex, int16 destSlotIndex); // @ F0258_TIMELINE_HasWeaponMovedToSlot
 };
 
 


Commit: 639fd36f38742669a03814e034bf4dce981d2fea
    https://github.com/scummvm/scummvm/commit/639fd36f38742669a03814e034bf4dce981d2fea
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f254_timelineProcessEvent12_hideDamageReceived

Changed paths:
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index f8725a2..0f36220 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -33,6 +33,7 @@
 #include "projexpl.h"
 #include "movesens.h"
 #include "text.h"
+#include "eventman.h"
 
 
 namespace DM {
@@ -332,7 +333,7 @@ void Timeline::f261_processTimeline() {
 				}
 				goto T0261048;
 			case k12_TMEventTypeHideDamageReceived:
-				//F0254_TIMELINE_ProcessEvent12_HideDamageReceived(L0682_s_Event._priority);
+				f254_timelineProcessEvent12_hideDamageReceived(L0682_s_Event._priority);
 				break;
 			case k70_TMEventTypeLight:
 				_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
@@ -973,9 +974,28 @@ void Timeline::f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(uint1
 bool Timeline::f258_timelineHasWeaponMovedSlot(int16 champIndex, Champion* champ, uint16 sourceSlotIndex, int16 destSlotIndex) {
 	if (Thing(champ->_slots[sourceSlotIndex]).getType() == k5_WeaponThingType) {
 		_vm->_championMan->f301_addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, sourceSlotIndex),
-												(ChampionSlot)destSlotIndex);
+			(ChampionSlot)destSlotIndex);
 		return true;
 	}
 	return false;
 }
+
+void Timeline::f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex) {
+	Champion* L0663_ps_Champion;
+
+
+	L0663_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	L0663_ps_Champion->_hideDamageReceivedIndex = -1;
+	if (!L0663_ps_Champion->_currHealth) {
+		return;
+	}
+	if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+		_vm->_eventMan->f78_showMouse();
+		_vm->_inventoryMan->f354_drawStatusBoxPortrait((ChampionIndex)champIndex);
+		_vm->_eventMan->f77_hideMouse();
+	} else {
+		setFlag(L0663_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle);
+		_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+	}
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 021889d..636d62d 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -183,6 +183,7 @@ public:
 																	 uint16 slotIndex);// @ F0259_TIMELINE_ProcessEvent11Part2_MoveWeaponFromQuiverToSlot
 	bool f258_timelineHasWeaponMovedSlot(int16 champIndex, Champion *champ,
 										 uint16 sourceSlotIndex, int16 destSlotIndex); // @ F0258_TIMELINE_HasWeaponMovedToSlot
+	void f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex); // @ F0254_TIMELINE_ProcessEvent12_HideDamageReceived
 };
 
 


Commit: f7e4486d84929b85cc5c82c6a6366eb37f5766de
    https://github.com/scummvm/scummvm/commit/f7e4486d84929b85cc5c82c6a6366eb37f5766de
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f257_timelineProcessEvent70_light

Changed paths:
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 0f36220..8141280 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -337,7 +337,7 @@ void Timeline::f261_processTimeline() {
 				break;
 			case k70_TMEventTypeLight:
 				_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
-				//F0257_TIMELINE_ProcessEvent70_Light(L0681_ps_Event);
+				f257_timelineProcessEvent70_light(L0681_ps_Event);
 				_vm->_inventoryMan->f337_setDungeonViewPalette();
 				break;
 			case k71_TMEventTypeInvisibility:
@@ -998,4 +998,35 @@ void Timeline::f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex)
 		_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
 	}
 }
+
+void Timeline::f257_timelineProcessEvent70_light(TimelineEvent* event) {
+	int16 L0673_i_WeakerLightPower;
+	int16 L0674_i_Multiple;
+#define AL0674_i_LightPower  L0674_i_Multiple
+#define AL0674_i_LightAmount L0674_i_Multiple
+	bool L0675_B_NegativeLightPower;
+	TimelineEvent L0676_s_Event;
+
+
+	if ((AL0674_i_LightPower = event->_B._lightPower) == 0) {
+		return;
+	}
+	if (L0675_B_NegativeLightPower = (AL0674_i_LightPower < 0)) {
+		AL0674_i_LightPower = -AL0674_i_LightPower;
+	}
+	L0673_i_WeakerLightPower = AL0674_i_LightPower - 1;
+	AL0674_i_LightAmount = g39_LightPowerToLightAmount[AL0674_i_LightPower] - g39_LightPowerToLightAmount[L0673_i_WeakerLightPower];
+	if (L0675_B_NegativeLightPower) {
+		AL0674_i_LightAmount = -AL0674_i_LightAmount;
+		L0673_i_WeakerLightPower = -L0673_i_WeakerLightPower;
+	}
+	_vm->_championMan->_g407_party._magicalLightAmount += AL0674_i_LightAmount;
+	if (L0673_i_WeakerLightPower) {
+		L0676_s_Event._type = k70_TMEventTypeLight;
+		L0676_s_Event._B._lightPower = L0673_i_WeakerLightPower;
+		M33_setMapAndTime(L0676_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 4);
+		L0676_s_Event._priority = 0;
+		_vm->_timeline->f238_addEventGetEventIndex(&L0676_s_Event);
+	}
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 636d62d..ed0a5ab 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -184,6 +184,7 @@ public:
 	bool f258_timelineHasWeaponMovedSlot(int16 champIndex, Champion *champ,
 										 uint16 sourceSlotIndex, int16 destSlotIndex); // @ F0258_TIMELINE_HasWeaponMovedToSlot
 	void f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex); // @ F0254_TIMELINE_ProcessEvent12_HideDamageReceived
+	void f257_timelineProcessEvent70_light(TimelineEvent *event); // @ F0257_TIMELINE_ProcessEvent70_Light
 };
 
 


Commit: 800100e2bc0a325f81bebc8993e95ded17c6fb76
    https://github.com/scummvm/scummvm/commit/800100e2bc0a325f81bebc8993e95ded17c6fb76
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f260_timelineRefreshAllChampionStatusBoxes

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index a84ccb8..1fd31ea 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1189,6 +1189,13 @@ bool ChampionMan::f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint1
 	return ((L0878_T_Thing.getType() == k5_WeaponThingType) && (L0875_ps_WeaponInfo->_class == L0879_i_WeaponClass));
 }
 
+void ChampionMan::f293_drawAllChampionStates() {
+	int16 L0873_i_ChampionIndex;
+	for (L0873_i_ChampionIndex = k0_ChampionFirst; L0873_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0873_i_ChampionIndex++) {
+		_vm->_championMan->f292_drawChampionState((ChampionIndex)L0873_i_ChampionIndex);
+	}
+}
+
 ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
 	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
 		if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 17686f9..35aaff6 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -523,6 +523,7 @@ public:
 	int16 f310_getMovementTicks(Champion *champ); // @ F0310_CHAMPION_GetMovementTicks
 	bool f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex,
 											   uint16 ammunitionSlotIndex); // @ F0294_CHAMPION_IsAmmunitionCompatibleWithWeapon
+	void f293_drawAllChampionStates(); // @ F0293_CHAMPION_DrawAllChampionStates
 
 
 
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 8141280..717870f 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -355,7 +355,7 @@ T0261048:
 			case k74_TMEventTypePartyShield:
 				_vm->_championMan->_g407_party._shieldDefense -= L0682_s_Event._B._defense;
 T0261053:
-				//F0260_TIMELINE_RefreshAllChampionStatusBoxes();
+				f260_timelineRefreshAllChampionStatusBoxes();
 				break;
 			case k77_TMEventTypeSpellShield:
 				_vm->_championMan->_g407_party._spellShieldDefense -= L0682_s_Event._B._defense;
@@ -1029,4 +1029,13 @@ void Timeline::f257_timelineProcessEvent70_light(TimelineEvent* event) {
 		_vm->_timeline->f238_addEventGetEventIndex(&L0676_s_Event);
 	}
 }
+
+void Timeline::f260_timelineRefreshAllChampionStatusBoxes() {
+	uint16 L0679_ui_ChampionIndex;
+
+	for (L0679_ui_ChampionIndex = k0_ChampionFirst; L0679_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0679_ui_ChampionIndex++) {
+		setFlag(_vm->_championMan->_gK71_champions[L0679_ui_ChampionIndex]._attributes, k0x1000_ChampionAttributeStatusBox);
+	}
+	_vm->_championMan->f293_drawAllChampionStates();
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index ed0a5ab..253bf81 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -185,6 +185,7 @@ public:
 										 uint16 sourceSlotIndex, int16 destSlotIndex); // @ F0258_TIMELINE_HasWeaponMovedToSlot
 	void f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex); // @ F0254_TIMELINE_ProcessEvent12_HideDamageReceived
 	void f257_timelineProcessEvent70_light(TimelineEvent *event); // @ F0257_TIMELINE_ProcessEvent70_Light
+	void f260_timelineRefreshAllChampionStatusBoxes(); // @ F0260_TIMELINE_RefreshAllChampionStatusBoxes
 };
 
 


Commit: 3e40cc46e3de279f83ef4037ad3462b24eb395fd
    https://github.com/scummvm/scummvm/commit/3e40cc46e3de279f83ef4037ad3462b24eb395fd
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f255_timelineProcessEvent13_ViAltarRebirth

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dungeonman.h
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 1fd31ea..443b764 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1196,6 +1196,28 @@ void ChampionMan::f293_drawAllChampionStates() {
 	}
 }
 
+void ChampionMan::f283_viAltarRebirth(uint16 champIndex) {
+	uint16 L0831_ui_Multiple;
+#define AL0831_ui_Cell          L0831_ui_Multiple
+#define AL0831_ui_MaximumHealth L0831_ui_Multiple
+	Champion* L0832_ps_Champion;
+
+	L0832_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	if (_vm->_championMan->f285_getIndexInCell(L0832_ps_Champion->_cell) != kM1_ChampionNone) {
+		AL0831_ui_Cell = k0_CellNorthWest;
+		while (_vm->_championMan->f285_getIndexInCell(AL0831_ui_Cell) != kM1_ChampionNone) {
+			AL0831_ui_Cell++;
+		}
+		L0832_ps_Champion->_cell = (ViewCell)AL0831_ui_Cell;
+	}
+	AL0831_ui_MaximumHealth = L0832_ps_Champion->_maxHealth;
+	L0832_ps_Champion->_currHealth = (L0832_ps_Champion->_maxHealth = MAX(25, AL0831_ui_MaximumHealth - (AL0831_ui_MaximumHealth >> 6) - 1)) >> 1;
+	_vm->_menuMan->f393_drawSpellAreaControls(_vm->_championMan->_g514_magicCasterChampionIndex);
+	L0832_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
+	setFlag(L0832_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
+	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+}
+
 ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
 	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
 		if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 35aaff6..7d78789 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -524,6 +524,7 @@ public:
 	bool f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex,
 											   uint16 ammunitionSlotIndex); // @ F0294_CHAMPION_IsAmmunitionCompatibleWithWeapon
 	void f293_drawAllChampionStates(); // @ F0293_CHAMPION_DrawAllChampionStates
+	void f283_viAltarRebirth(uint16 champIndex); // @ F0283_CHAMPION_ViAltarRebirth
 
 
 
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 2a6a8b7..ca01034 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -493,6 +493,7 @@ public:
 	uint16 getDoNotDiscard() { return (_attributes >> 7) & 1; }
 
 	Thing getNextThing() { return _nextThing; }
+	void setNextThing(Thing thing) { _nextThing = thing; }
 }; // @ JUNK
 
 #define kM1_soundModeDoNotPlaySound -1 // @ CM1_MODE_DO_NOT_PLAY_SOUND  
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 717870f..55c1e4b 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -34,6 +34,7 @@
 #include "movesens.h"
 #include "text.h"
 #include "eventman.h"
+#include "objectman.h"
 
 
 namespace DM {
@@ -368,7 +369,7 @@ T0261053:
 				_vm->_championMan->f322_championPoison(AL0680_ui_ChampionIndex, L0682_s_Event._B._attack);
 				break;
 			case k13_TMEventTypeViAltarRebirth:
-				//F0255_TIMELINE_ProcessEvent13_ViAltarRebirth(L0681_ps_Event);
+				f255_timelineProcessEvent13_ViAltarRebirth(L0681_ps_Event);
 				break;
 			case k79_TMEventTypeFootprints:
 				_vm->_championMan->_g407_party._event79Count_Footprints--;
@@ -1038,4 +1039,52 @@ void Timeline::f260_timelineRefreshAllChampionStatusBoxes() {
 	}
 	_vm->_championMan->f293_drawAllChampionStates();
 }
+
+void Timeline::f255_timelineProcessEvent13_ViAltarRebirth(TimelineEvent* event) {
+	int16 L0664_i_MapX;
+	int16 L0665_i_MapY;
+	uint16 L0666_ui_Cell;
+	Thing L0667_T_Thing;
+	Junk* L0668_ps_Junk;
+	int16 L0669_i_IconIndex;
+	uint16 L0670_ui_Step;
+	uint16 L0671_ui_ChampionIndex;
+
+
+	L0664_i_MapX = event->_B._location._mapX;
+	L0665_i_MapY = event->_B._location._mapY;
+	L0665_i_MapY = event->_B._location._mapY;
+	L0666_ui_Cell = event->_C.A._cell;
+	L0671_ui_ChampionIndex = event->_priority;
+	switch (L0670_ui_Step = event->_C.A._effect) { /* Rebirth is a 3 steps process (Step 2 -> Step 1 -> Step 0). Step is stored in the Effect value of the event */
+	case 2:
+		_vm->_projexpl->f213_explosionCreate(Thing::_explRebirthStep1, 0, L0664_i_MapX, L0665_i_MapY, L0666_ui_Cell);
+		event->_mapTime += 5;
+T0255002:
+		L0670_ui_Step--;
+		event->_C.A._effect = L0670_ui_Step;
+		_vm->_timeline->f238_addEventGetEventIndex(event);
+		break;
+	case 1:
+		L0667_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0664_i_MapX, L0665_i_MapY);
+		while (L0667_T_Thing != Thing::_endOfList) {
+			if ((L0667_T_Thing.getCell() == L0666_ui_Cell) && (L0667_T_Thing.getType() == k10_JunkThingType)) {
+				L0669_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0667_T_Thing);
+				if (L0669_i_IconIndex == k147_IconIndiceJunkChampionBones) {
+					L0668_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0667_T_Thing);
+					if (L0668_ps_Junk->getChargeCount() == L0671_ui_ChampionIndex) {
+						_vm->_dungeonMan->f164_unlinkThingFromList(L0667_T_Thing, Thing(0), L0664_i_MapX, L0665_i_MapY); /* BUG0_25 When a champion dies, no bones object is created so it is not possible to bring the champion back to life at an altar of Vi. Each time a champion is brought back to life, the bones object is removed from the dungeon but it is not marked as unused and thus becomes an orphan. After a large number of champion deaths, all JUNK things are exhausted and the game cannot create any more. This also affects the creation of JUNK things dropped by some creatures when they die (Screamer, Rockpile, Magenta Worm, Pain Rat, Red Dragon) */
+						L0668_ps_Junk->setNextThing(Thing::_none);
+						event->_mapTime += 1;
+						goto T0255002;
+					}
+				}
+			}
+			L0667_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0667_T_Thing);
+		}
+		break;
+	case 0:
+		_vm->_championMan->f283_viAltarRebirth(event->_priority);
+	}
+}
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 253bf81..49a7ca4 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -186,6 +186,7 @@ public:
 	void f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex); // @ F0254_TIMELINE_ProcessEvent12_HideDamageReceived
 	void f257_timelineProcessEvent70_light(TimelineEvent *event); // @ F0257_TIMELINE_ProcessEvent70_Light
 	void f260_timelineRefreshAllChampionStatusBoxes(); // @ F0260_TIMELINE_RefreshAllChampionStatusBoxes
+	void f255_timelineProcessEvent13_ViAltarRebirth(TimelineEvent *event); // @ F0255_TIMELINE_ProcessEvent13_ViAltarRebirth
 };
 
 


Commit: 0f76448e5794bea0097f1c806c67623093c79cf8
    https://github.com/scummvm/scummvm/commit/0f76448e5794bea0097f1c806c67623093c79cf8
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix up main loop

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 932de5a..dbf7a95 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -324,8 +324,6 @@ void DMEngine::f2_gameloop() {
 	_dungeonMan->_g306_partyMapX = 10;
 	_dungeonMan->_g307_partyMapY = 4;
 	_dungeonMan->_g308_partyDir = kDirNorth;
-	warning(false, "DUMMY CODE: setting InventoryMan::_g432_inventoryChampionOrdinal to zero");
-	_inventoryMan->_g432_inventoryChampionOrdinal = 0;
 
 	while (true) {
 		if (_g327_newPartyMapIndex != kM1_mapIndexNone) {
@@ -359,23 +357,32 @@ T0002002:
 				_eventMan->f77_hideMouse();
 			}
 		}
-
+		// F0363_COMMAND_HighlightBoxDisable();
+		// F0065_SOUND_PlayPendingSound_CPSD();
+		// F0320_CHAMPION_ApplyAndDrawPendingDamageAndWounds
 		if (_championMan->_g303_partyDead)
 			break;
 		_g313_gameTime++;
 
 		if (!(_g313_gameTime & 511))
 			_inventoryMan->f338_decreaseTorchesLightPower();
-			if (_g310_disabledMovementTicks) {
-				_g310_disabledMovementTicks--;
-			}
-		if (_championMan->_g407_party._freezeLifeTicks) {
+
+		if (_g310_disabledMovementTicks)
+			_g310_disabledMovementTicks--;
+
+		if (_championMan->_g407_party._freezeLifeTicks)
 			_championMan->_g407_party._freezeLifeTicks -= 1;
-		}
+
 		_menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived();
 
-		if (_g311_projectileDisableMovementTicks)
-			_g311_projectileDisableMovementTicks--;
+		// if (!((int)_vm->_g313_gameTime & (_vm->_championMan->_g300_partyIsSleeping ? 15 : 63))) {
+		//		F0331_CHAMPION_ApplyTimeEffects_CPSF();
+		// }
+
+		if (_g310_disabledMovementTicks)
+			_g310_disabledMovementTicks--;
+
+		// F0044_TEXT_MESSAGEAREA_ClearExpiredRows();
 
 		_g321_stopWaitingForPlayerInput = false;
 
@@ -395,7 +402,7 @@ T0002002:
 			_eventMan->f380_processCommandQueue();
 			_displayMan->updateScreen();
 			// if (!_vm->_g321_stopWaitingForPlayerInput) {
-			warning(false, "MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
+			//		F0363_COMMAND_HighlightBoxDisable();
 			// }
 		} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking);
 


Commit: 42cbf35b0bbe821b7127a0a883b4248c4da9f90a
    https://github.com/scummvm/scummvm/commit/42cbf35b0bbe821b7127a0a883b4248c4da9f90a
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Clean up f380_processCommandQueue, add _g318_waitForInputMaxVerticalBlankCount

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/eventman.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 78a5e9c..26aa333 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -21,5 +21,8 @@ Todo:
 	I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions
 
 Finish stuff:
-	f261_processTimeline
-
+	f380_processCommandQueue
+	Missing main loop methods
+	F0577_VBLANK_Handler, if enought time passes, takes the player's chance to act
+		- TODO: implement it
+		- NOTE: _g318_waitForInputMaxVerticalBlankCount is already included in the engine
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 443b764..3745924 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -820,6 +820,7 @@ uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion* champ, uint16 stat
 void ChampionMan::f314_wakeUp() {
 	_vm->_g321_stopWaitingForPlayerInput = true;
 	_g300_partyIsSleeping = false;
+	_vm->_g318_waitForInputMaxVerticalBlankCount = 10;
 	_vm->f22_delay(10);
 	_vm->_displayMan->f98_drawFloorAndCeiling();
 	_vm->_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface;
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index dbf7a95..194bfa2 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -168,6 +168,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_g310_disabledMovementTicks = 0;
 	_g313_gameTime = 0;
 	_g353_stringBuildBuffer[0] = '\0';
+	_g318_waitForInputMaxVerticalBlankCount = 0;
 	debug("DMEngine::DMEngine");
 
 
@@ -320,11 +321,12 @@ Common::Error DMEngine::run() {
 }
 
 void DMEngine::f2_gameloop() {
-	warning(false, "DUMMY CODE SETTING PARTY POS AND DIRECTION");
+	warning(false, "DUMMY CODE: SETTING PARTY POS AND DIRECTION");
 	_dungeonMan->_g306_partyMapX = 10;
 	_dungeonMan->_g307_partyMapY = 4;
 	_dungeonMan->_g308_partyDir = kDirNorth;
 
+	_g318_waitForInputMaxVerticalBlankCount = 10;
 	while (true) {
 		if (_g327_newPartyMapIndex != kM1_mapIndexNone) {
 T0002002:
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 1e1fc6a..dce88f1 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -172,6 +172,10 @@ inline T f26_getBoundedValue(T min, T val, T max) {
 
 #define CALL_MEMBER_FN(object,ptrToMember)  ((object).*(ptrToMember))
 
+#define k0_modeLoadSavedGame 0 // @ C000_MODE_LOAD_SAVED_GAME        
+#define k1_modeLoadDungeon 1 // @ C001_MODE_LOAD_DUNGEON           
+#define k99_modeWaitingOnEntrance 99 // @ C099_MODE_WAITING_ON_ENTRANCE   
+#define k202_modeEntranceDrawCredits 202 // @ C202_MODE_ENTRANCE_DRAW_CREDITS 
 
 class DMEngine : public Engine {
 	void f462_startGame(); // @ F0462_START_StartGame_CPSF
@@ -234,6 +238,7 @@ public:
 	int8 _dirIntoStepCountNorth[4]; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
 	uint32 _g313_gameTime; // @ G0313_ul_GameTime
 	char _g353_stringBuildBuffer[128]; // @ G0353_ac_StringBuildBuffer
+	int16 _g318_waitForInputMaxVerticalBlankCount; // @ G0318_i_WaitForInputMaximumVerticalBlankCount
 };
 
 class Console : public GUI::Debugger {
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 4f3ffc5..9045c62 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -613,39 +613,179 @@ CommandType EventManager::f358_getCommandTypeFromMouseInput(MouseInput *input, C
 
 
 void EventManager::f380_processCommandQueue() {
-	_g435_isCommandQueueLocked = true;
-	if (_commandQueue.empty()) {
-		_g435_isCommandQueueLocked = false;
-		f360_processPendingClick();
+	int16 AL1159_i_ChampionIndex;
+	CommandType cmdType;
+	int16 L1161_i_CommandX;
+	int16 L1162_i_CommandY;
+	static KeyboardInput* G0481_ps_PrimaryKeyboardInputBackup;
+	static KeyboardInput* G0482_ps_SecondaryKeyboardInputBackup;
+	static MouseInput* G0483_ps_PrimaryMouseInputBackup;
+	static MouseInput* G0484_ps_SecondaryMouseInputBackup;
+
+
+	_vm->_eventMan->_g435_isCommandQueueLocked = true;
+	if (_commandQueue.empty()) { /* If the command queue is empty */
+		_vm->_eventMan->_g435_isCommandQueueLocked = false;
+		_vm->_eventMan->f360_processPendingClick();
 		return;
 	}
 
 	Command cmd = _commandQueue.pop();
-
-	int16 commandX = cmd._pos.x;
-	int16 commandY = cmd._pos.y;
-
-	_g435_isCommandQueueLocked = false;
-	f360_processPendingClick();
-
-	if ((cmd._type == k2_CommandTurnRight) || (cmd._type == k1_CommandTurnLeft)) {
-		f365_commandTurnParty(cmd._type);
+	cmdType = cmd._type;
+	if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft) && (_vm->_g310_disabledMovementTicks || (_vm->_g311_projectileDisableMovementTicks && (_vm->_g312_lastProjectileDisabledMovementDirection == (M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + cmdType - k3_CommandMoveForward)))))) { /* If movement is disabled */
+		_vm->_eventMan->_g435_isCommandQueueLocked = false;
+		_vm->_eventMan->f360_processPendingClick();
+		return;
+	}
+	L1161_i_CommandX = cmd._pos.x;
+	L1162_i_CommandY = cmd._pos.y;
+	_vm->_eventMan->_g435_isCommandQueueLocked = false;
+	_vm->_eventMan->f360_processPendingClick();
+	if ((cmdType == k2_CommandTurnRight) || (cmdType == k1_CommandTurnLeft)) {
+		_vm->_eventMan->f365_commandTurnParty(cmdType);
+		return;
+	}
+	if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft)) {
+		_vm->_eventMan->f366_commandMoveParty(cmdType);
+		return;
+	}
+	if ((cmdType >= k12_CommandClickInChampion_0_StatusBox) && (cmdType <= k15_CommandClickInChampion_3_StatusBox)) {
+		if (((AL1159_i_ChampionIndex = cmdType - k12_CommandClickInChampion_0_StatusBox) < _vm->_championMan->_g305_partyChampionCount) && !_vm->_championMan->_g299_candidateChampionOrdinal) {
+			warning(false, "MISSING CODE: F0367_COMMAND_ProcessTypes12To27_ClickInChampionStatusBox(AL1159_i_ChampionIndex, L1161_i_CommandX, L1162_i_CommandY);");
+		}
+		return;
+	}
+	if ((cmdType >= k125_CommandClickOnChamptionIcon_Top_Left) && (cmdType <= k128_CommandClickOnChamptionIcon_Lower_Left)) {
+		warning(false, "MISSING CODE: F0070_MOUSE_ProcessCommands125To128_ClickOnChampionIcon(cmdType - k125_CommandClickOnChamptionIcon_Top_Left);");
+		return;
+	}
+	if ((cmdType >= k28_CommandClickOnSlotBoxInventoryReadyHand) && (cmdType < (k65_CommandClickOnSlotBoxChest_8 + 1))) {
+		if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) {
+			warning(false, "MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox(cmdType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);");
+		}
+		return;
+	}
+	if ((cmdType >= k7_CommandToggleInventoryChampion_0) && (cmdType <= k11_CommandCloseInventory)) {
+		if ((((AL1159_i_ChampionIndex = cmdType - k7_CommandToggleInventoryChampion_0) == k4_ChampionCloseInventory) || (AL1159_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount)) && !_vm->_championMan->_g299_candidateChampionOrdinal) {
+			_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)AL1159_i_ChampionIndex);
+		}
+		return;
+	}
+	if (cmdType == k83_CommandToggleInventoryLeader) {
+		if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) {
+			_vm->_inventoryMan->f355_toggleInventory(_vm->_championMan->_g411_leaderIndex);
+		}
+		return;
+	}
+	if (cmdType == k100_CommandClickInSpellArea) {
+		if ((!_vm->_championMan->_g299_candidateChampionOrdinal) && (_vm->_championMan->_g514_magicCasterChampionIndex != kM1_ChampionNone)) {
+			warning(false, "MISSING CODE: F0370_COMMAND_ProcessType100_ClickInSpellArea(L1161_i_CommandX, L1162_i_CommandY);");
+		}
+		return;
+	}
+	if (cmdType == k111_CommandClickInActionArea) {
+		if (!_vm->_championMan->_g299_candidateChampionOrdinal) {
+			warning(false, "MISSING CODE: F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE(L1161_i_CommandX, L1162_i_CommandY);");
+		}
+		return;
+	}
+	if (cmdType == k70_CommandClickOnMouth) {
+		warning(false, "MISSING CODE: F0349_INVENTORY_ProcessCommand70_ClickOnMouth();");
+		return;
+	}
+	if (cmdType == k71_CommandClickOnEye) {
+		warning(false, "MISSING CODE: F0352_INVENTORY_ProcessCommand71_ClickOnEye();");
+		return;
+	}
+	if (cmdType == k80_CommandClickInDungeonView) {
+		_vm->_eventMan->f377_commandProcessType80ClickInDungeonView(L1161_i_CommandX, L1162_i_CommandY);
+		return;
+	}
+	if (cmdType == k81_CommandClickInPanel) {
+		_vm->_eventMan->f378_commandProcess81ClickInPanel(L1161_i_CommandX, L1162_i_CommandY);
 		return;
 	}
 
-	if ((cmd._type >= k3_CommandMoveForward) && (cmd._type <= k6_CommandMoveLeft)) {
-		f366_commandMoveParty(cmd._type);
+	if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) {
 		return;
 	}
 
-	if (cmd._type == k80_CommandClickInDungeonView) {
-		f377_commandProcessType80ClickInDungeonView(commandX, commandY);
+	if (cmdType == k145_CommandSleep) {
+		if (!_vm->_championMan->_g299_candidateChampionOrdinal) {
+			if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+				_vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
+			}
+			_vm->_menuMan->f456_drawDisabledMenu();
+			_vm->_championMan->_g300_partyIsSleeping = true;
+			warning(false, "MISSING CODE: F0379_COMMAND_DrawSleepScreen();");
+			_vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
+			_vm->_g318_waitForInputMaxVerticalBlankCount = 0;
+			_vm->_eventMan->_g441_primaryMouseInput = g450_PrimaryMouseInput_PartySleeping;
+			_vm->_eventMan->_g442_secondaryMouseInput = 0;
+			_g443_primaryKeyboardInput = g460_primaryKeyboardInput_partySleeping;
+			_g444_secondaryKeyboardInput = nullptr;
+			f357_discardAllInput();
+		}
+		return;
 	}
-	if (cmd._type == k81_CommandClickInPanel) {
-		f378_commandProcess81ClickInPanel(commandX, commandY);
+	if (cmdType == k146_CommandWakeUp) {
+		_vm->_championMan->f314_wakeUp();
+		return;
+	}
+	if (cmdType == k140_CommandSaveGame) {
+		if ((_vm->_championMan->_g305_partyChampionCount > 0) && !_vm->_championMan->_g299_candidateChampionOrdinal) {
+			warning(false, "MISSING CODE: F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF();");
+		}
+		return;
+	}
+	if (cmdType == k147_CommandFreezeGame) {
+		_vm->_g301_gameTimeTicking = false;
+		_vm->_menuMan->f456_drawDisabledMenu();
+		_vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 224, 136);
+		// TODO: localization
+		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 81, 69, k4_ColorCyan, k0_ColorBlack,
+											 "GAME FROZEN", k136_heightViewport);
+		_vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
+		G0483_ps_PrimaryMouseInputBackup = _vm->_eventMan->_g441_primaryMouseInput;
+		G0484_ps_SecondaryMouseInputBackup = _vm->_eventMan->_g442_secondaryMouseInput;
+		G0481_ps_PrimaryKeyboardInputBackup = _g443_primaryKeyboardInput;
+		G0482_ps_SecondaryKeyboardInputBackup = _g444_secondaryKeyboardInput;
+		_vm->_eventMan->_g441_primaryMouseInput = g451_PrimaryMouseInput_FrozenGame;
+		_vm->_eventMan->_g442_secondaryMouseInput = 0;
+		_g443_primaryKeyboardInput = g461_primaryKeyboardInput_frozenGame;
+		_g444_secondaryKeyboardInput = nullptr;
+		f357_discardAllInput();
+		return;
+	}
+	if (cmdType == k148_CommandUnfreezeGame) {
+		_vm->_g301_gameTimeTicking = true;
+		_vm->_menuMan->f457_drawEnabledMenus();
+		_vm->_eventMan->_g441_primaryMouseInput = G0483_ps_PrimaryMouseInputBackup;
+		_vm->_eventMan->_g442_secondaryMouseInput = G0484_ps_SecondaryMouseInputBackup;
+		_g443_primaryKeyboardInput = G0481_ps_PrimaryKeyboardInputBackup;
+		_g444_secondaryKeyboardInput = G0482_ps_SecondaryKeyboardInputBackup;
+		f357_discardAllInput();
+		return;
+	}
+	if (cmdType == k200_CommandEntranceEnterDungeon) {
+		_vm->_g298_newGame = k1_modeLoadDungeon;
+		return;
+	}
+	if (cmdType == k201_CommandEntranceResume) {
+		_vm->_g298_newGame = k0_modeLoadSavedGame;
+		return;
+	}
+	if (cmdType == k202_CommandEntranceDrawCredits) {
+		warning(false, "MISSING CODE: F0442_STARTEND_ProcessCommand202_EntranceDrawCredits()");
+		return;
+	}
+	if ((cmdType >= k210_CommandClickOnDialogChoice_1) && (cmdType <= k213_CommandClickOnDialogChoice_4)) {
+		warning(false, "MISSING CODE:G0335_ui_SelectedDialogChoice = cmdType - (k210_CommandClickOnDialogChoice_1 - 1);");
+		return;
+	}
+	if (cmdType == k215_CommandRestartGame) {
+		_vm->_g523_restartGameRequest = true;
 	}
-
-	// MISSING CODE: the rest of the function
 }
 
 void EventManager::f365_commandTurnParty(CommandType cmdType) {


Commit: 4d3c9d99f169efb3991866318d04a644b5de0217
    https://github.com/scummvm/scummvm/commit/4d3c9d99f169efb3991866318d04a644b5de0217
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f367_commandProcessTypes12to27_clickInChampionStatusBox

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/eventman.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 26aa333..4839d2d 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -8,8 +8,10 @@ Bugs:
 		When object are put on the right side of the current square, they disappear
 		Drawing door ornaments segfaults when going back to the start 
 
-
-
+Possible bugs:
+	- k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON
+	- possible garbage value return in f140_getObjectWeight
+	
 Todo:
 	Add wiki entry for DM
 	Rename GraphicIndice enum entires and have their name include GraphicIndice
@@ -26,3 +28,4 @@ Finish stuff:
 	F0577_VBLANK_Handler, if enought time passes, takes the player's chance to act
 		- TODO: implement it
 		- NOTE: _g318_waitForInputMaxVerticalBlankCount is already included in the engine
+
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 3745924..fdbdc09 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -39,6 +39,47 @@
 
 namespace DM {
 
+uint16 g38_slotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks
+	/* 30 for champion inventory, 8 for chest */
+	0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Action Hand      Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0x0002,   /* Head             Head */
+	0x0008,   /* Torso            Torso */
+	0x0010,   /* Legs             Legs */
+	0x0020,   /* Feet             Feet */
+	0x0100,   /* Pouch 2          Pouch */
+	0x0080,   /* Quiver Line2 1   Quiver 2 */
+	0x0080,   /* Quiver Line1 2   Quiver 2 */
+	0x0080,   /* Quiver Line2 2   Quiver 2 */
+	0x0004,   /* Neck             Neck */
+	0x0100,   /* Pouch 1          Pouch */
+	0x0040,   /* Quiver Line1 1   Quiver 1 */
+	0xFFFF,   /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0x0400,   /* Chest 1          Chest */
+	0x0400,   /* Chest 2          Chest */
+	0x0400,   /* Chest 3          Chest */
+	0x0400,   /* Chest 4          Chest */
+	0x0400,   /* Chest 5          Chest */
+	0x0400,   /* Chest 6          Chest */
+	0x0400,   /* Chest 7          Chest */
+	0x0400}; /* Chest 8          Chest */
+
 const char *g417_baseSkillName[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"};
 
 Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
@@ -1219,6 +1260,53 @@ void ChampionMan::f283_viAltarRebirth(uint16 champIndex) {
 	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
 }
 
+void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex) {
+	uint16 L0903_ui_ChampionIndex;
+	uint16 L0904_ui_SlotIndex;
+	Thing L0905_T_LeaderHandObject;
+	Thing L0906_T_SlotThing;
+
+
+	if (slotBoxIndex < k8_SlotBoxInventoryFirstSlot) {
+		if (_vm->_championMan->_g299_candidateChampionOrdinal) {
+			return;
+		}
+		L0903_ui_ChampionIndex = slotBoxIndex >> 1;
+		if ((L0903_ui_ChampionIndex >= _vm->_championMan->_g305_partyChampionCount) || (_vm->M0_indexToOrdinal(L0903_ui_ChampionIndex) == (int)_vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_vm->_championMan->_gK71_champions[L0903_ui_ChampionIndex]._currHealth) {
+			return;
+		}
+		L0904_ui_SlotIndex = _vm->_championMan->M70_handSlotIndex(slotBoxIndex);
+	} else {
+		L0903_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+		L0904_ui_SlotIndex = slotBoxIndex - k8_SlotBoxInventoryFirstSlot;
+	}
+	L0905_T_LeaderHandObject = _vm->_championMan->_g414_leaderHandObject;
+	if (L0904_ui_SlotIndex >= k30_ChampionSlotChest_1) {
+		L0906_T_SlotThing = _vm->_inventoryMan->_g425_chestSlots[L0904_ui_SlotIndex - k30_ChampionSlotChest_1];
+	} else {
+		L0906_T_SlotThing = _vm->_championMan->_gK71_champions[L0903_ui_ChampionIndex]._slots[L0904_ui_SlotIndex];
+	}
+	if ((L0906_T_SlotThing == Thing::_none) && (L0905_T_LeaderHandObject == Thing::_none)) {
+		return;
+	}
+	if ((L0905_T_LeaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0905_T_LeaderHandObject)]._allowedSlots & g38_slotMasks[L0904_ui_SlotIndex]))) {
+		return;
+	}
+	_vm->_eventMan->f78_showMouse();
+	if (L0905_T_LeaderHandObject != Thing::_none) {
+		f298_getObjectRemovedFromLeaderHand();
+	}
+	if (L0906_T_SlotThing != Thing::_none) {
+		f300_getObjectRemovedFromSlot(L0903_ui_ChampionIndex, L0904_ui_SlotIndex);
+		f297_putObjectInLeaderHand(L0906_T_SlotThing, false); 
+	}
+	if (L0905_T_LeaderHandObject != Thing::_none) {
+		_vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0903_ui_ChampionIndex, L0905_T_LeaderHandObject, (ChampionSlot)L0904_ui_SlotIndex);
+	}
+	_vm->_championMan->f292_drawChampionState((ChampionIndex)L0903_ui_ChampionIndex);
+	_vm->_eventMan->f77_hideMouse();
+}
+
 ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
 	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
 		if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 7d78789..37ca363 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -525,7 +525,7 @@ public:
 											   uint16 ammunitionSlotIndex); // @ F0294_CHAMPION_IsAmmunitionCompatibleWithWeapon
 	void f293_drawAllChampionStates(); // @ F0293_CHAMPION_DrawAllChampionStates
 	void f283_viAltarRebirth(uint16 champIndex); // @ F0283_CHAMPION_ViAltarRebirth
-
+	void f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex); // @ F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox
 
 
 
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 8100139..d88363a 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1251,44 +1251,46 @@ uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 		2, 0, 8
 	};
 
+	Junk* junk;
+	uint16 weight;
+
 	if (thing == Thing::_none)
 		return 0;
+
+	junk = (Junk*)f156_getThingData(thing);
 	switch (thing.getType()) {
 	case k5_WeaponThingType:
-		return g238_WeaponInfo[Weapon(f156_getThingData(thing)).getType()]._weight;
+		weight = g238_WeaponInfo[((Weapon*)junk)->getType()]._weight;
+		break;
 	case k6_ArmourThingType:
-		return g239_ArmourInfo[Armour(f156_getThingData(thing)).getType()]._weight;
-	case k10_JunkThingType: {
-		Junk junk(f156_getThingData(thing));
-		uint16 weight = g241_junkInfo[junk.getType()];
-		if (junk.getType() == k1_JunkTypeWaterskin)
-			weight += junk.getChargeCount() * 2;
-		return weight;
-	}
-	case k9_ContainerThingType: {
-		uint16 weight = 50;
-		Container container(f156_getThingData(thing));
-		Thing slotThing = container.getSlot();
-		while (slotThing != Thing::_endOfList) {
-			weight += f140_getObjectWeight(slotThing);
-			slotThing = f159_getNextThing(slotThing);
+		weight = g239_ArmourInfo[((Armour*)junk)->getType()]._weight;
+		break;
+	case k10_JunkThingType:
+		weight = g241_junkInfo[junk->getType()];
+		if (junk->getType() == k1_JunkTypeWaterskin) {
+			weight += junk->getChargeCount() << 1;
 		}
-		return weight;
-	}
+		break;
+	case k9_ContainerThingType:
+		weight = 50;
+		thing = ((Container*)junk)->getSlot();
+		while (thing != Thing::_endOfList) {
+			weight += f140_getObjectWeight(thing);
+			thing = f159_getNextThing(thing);
+		}
+		break;
 	case k8_PotionThingType:
-		if (Junk(f156_getThingData(thing)).getType() == k20_PotionTypeEmptyFlask) {
-			return 1;
+		if (((Potion*)junk)->getType() == k20_PotionTypeEmptyFlask) {
+			weight = 1;
 		} else {
-			return 3;
+			weight = 3;
 		}
-	case k7_ScrollThingType:
-		return 1;
-	default:
 		break;
+	case k7_ScrollThingType:
+		weight = 1;
 	}
 
-	assert(false); // this should never be taken
-	return 0; // dummy
+	return weight; // this is garbage if none of the branches were taken
 }
 
 
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 9045c62..c19ed70 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -651,7 +651,7 @@ void EventManager::f380_processCommandQueue() {
 	}
 	if ((cmdType >= k12_CommandClickInChampion_0_StatusBox) && (cmdType <= k15_CommandClickInChampion_3_StatusBox)) {
 		if (((AL1159_i_ChampionIndex = cmdType - k12_CommandClickInChampion_0_StatusBox) < _vm->_championMan->_g305_partyChampionCount) && !_vm->_championMan->_g299_candidateChampionOrdinal) {
-			warning(false, "MISSING CODE: F0367_COMMAND_ProcessTypes12To27_ClickInChampionStatusBox(AL1159_i_ChampionIndex, L1161_i_CommandX, L1162_i_CommandY);");
+			f367_commandProcessTypes12to27_clickInChampionStatusBox(AL1159_i_ChampionIndex, L1161_i_CommandX, L1162_i_CommandY);
 		}
 		return;
 	}
@@ -1283,4 +1283,21 @@ void EventManager::f364_commandTakeStairs(bool stairsGoDown) {
 	_vm->_championMan->f284_setPartyDirection(_vm->_dungeonMan->f155_getStairsExitDirection(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY));
 	_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
 }
+
+void EventManager::f367_commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX, int16 posY) {
+	uint16 L1126_ui_Command;
+
+	if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+		_vm->_eventMan->f368_commandSetLeader((ChampionIndex)champIndex);
+	} else {
+		L1126_ui_Command = _vm->_eventMan->f358_getCommandTypeFromMouseInput(g455_MouseInput_ChampionNamesHands, Common::Point(posX, posY), k1_LeftMouseButton);
+		if ((L1126_ui_Command >= k16_CommandSetLeaderChampion_0) && (L1126_ui_Command <= k19_CommandSetLeaderChampion_3)) {
+			_vm->_eventMan->f368_commandSetLeader((ChampionIndex)(L1126_ui_Command - k16_CommandSetLeaderChampion_0));
+		} else {
+			if ((L1126_ui_Command >= k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand) && (L1126_ui_Command <= k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand)) {
+				_vm->_championMan->f302_processCommands28to65_clickOnSlotBox(L1126_ui_Command - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
+			}
+		}
+	}
+}
 } // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 2c61d3e..fb983bf 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -297,6 +297,8 @@ public:
 	void f379_drawSleepScreen(); // @ F0379_COMMAND_DrawSleepScreen
 	void f357_discardAllInput(); // @ F0357_COMMAND_DiscardAllInput
 	void f364_commandTakeStairs(bool stairsGoDown);// @ F0364_COMMAND_TakeStairs
+	void f367_commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX,
+																 int16 posY); // @ F0367_COMMAND_ProcessTypes12To27_ClickInChampionStatusBox
 
 };
 


Commit: 0f107cead2b59c9e67fc50996df49d4e86918f48
    https://github.com/scummvm/scummvm/commit/0f107cead2b59c9e67fc50996df49d4e86918f48
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f70_mouseProcessCommands125To128_clickOnChampionIcon

Changed paths:
    engines/dm/eventman.cpp
    engines/dm/eventman.h



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index c19ed70..f74c806 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -656,7 +656,7 @@ void EventManager::f380_processCommandQueue() {
 		return;
 	}
 	if ((cmdType >= k125_CommandClickOnChamptionIcon_Top_Left) && (cmdType <= k128_CommandClickOnChamptionIcon_Lower_Left)) {
-		warning(false, "MISSING CODE: F0070_MOUSE_ProcessCommands125To128_ClickOnChampionIcon(cmdType - k125_CommandClickOnChamptionIcon_Top_Left);");
+		f70_mouseProcessCommands125To128_clickOnChampionIcon(cmdType - k125_CommandClickOnChamptionIcon_Top_Left);
 		return;
 	}
 	if ((cmdType >= k28_CommandClickOnSlotBoxInventoryReadyHand) && (cmdType < (k65_CommandClickOnSlotBoxChest_8 + 1))) {
@@ -1300,4 +1300,63 @@ void EventManager::f367_commandProcessTypes12to27_clickInChampionStatusBox(uint1
 		}
 	}
 }
+
+void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex) {
+	static Box G0621_s_Box_MousePointer_ChampionIconShadow = Box(2, 20, 2, 15);
+	static Box G0622_s_Box_MousePointer_ChampionIcon = Box(0, 18, 0, 13);
+	static byte G0045_auc_Graphic562_PaletteChanges_MousePointerIconShadow[16] = {0, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 0, 120, 120, 120}; 
+
+	uint16 L0052_ui_ChampionIconIndex;
+	int16 L0053_i_ChampionIndex;
+	int16 L0054_i_ChampionIndex;
+	Box* L0055_pi_ChampionIconBox;
+	register unsigned char* L0056_puc_Bitmap;
+
+
+	_gK100_preventBuildPointerScreenArea = true;
+	if (!_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
+		if (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir)) == kM1_ChampionNone) {
+			_gK100_preventBuildPointerScreenArea = false;
+			return;
+		}
+		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
+		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = true;
+		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+		L0056_puc_Bitmap = _gK190_mousePointerTempBuffer;
+		memset(L0056_puc_Bitmap, 0, 32 * 18);
+		L0055_pi_ChampionIconBox = &g54_BoxChampionIcons[champIconIndex];
+
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, L0056_puc_Bitmap, G0621_s_Box_MousePointer_ChampionIconShadow, L0055_pi_ChampionIconBox->_x1, L0055_pi_ChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
+
+		_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(L0056_puc_Bitmap, _g613_mousePointerOriginalColorsChampionIcon, 32, 18, 32, 18, G0045_auc_Graphic562_PaletteChanges_MousePointerIconShadow);
+
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, _g613_mousePointerOriginalColorsChampionIcon, G0622_s_Box_MousePointer_ChampionIcon, L0055_pi_ChampionIconBox->_x1, L0055_pi_ChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
+
+		_vm->_displayMan->D24_fillScreenBox(*L0055_pi_ChampionIconBox, k0_ColorBlack);
+		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(champIconIndex);
+	} else {
+		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
+		L0052_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap);
+		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+		L0054_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(L0052_ui_ChampionIconIndex + _vm->_dungeonMan->_g308_partyDir));
+		if (L0052_ui_ChampionIconIndex == champIconIndex) {
+			setFlag(_vm->_championMan->_gK71_champions[L0054_i_ChampionIndex]._attributes, k0x0400_ChampionAttributeIcon);
+			_vm->_championMan->f292_drawChampionState((ChampionIndex)L0054_i_ChampionIndex);
+		} else {
+			L0053_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir));
+			if (L0053_i_ChampionIndex >= 0) {
+				_vm->_championMan->_gK71_champions[L0053_i_ChampionIndex]._cell = (ViewCell)M21_normalizeModulo4(L0052_ui_ChampionIconIndex + _vm->_dungeonMan->_g308_partyDir);
+				setFlag(_vm->_championMan->_gK71_champions[L0053_i_ChampionIndex]._attributes, k0x0400_ChampionAttributeIcon);
+				_vm->_championMan->f292_drawChampionState((ChampionIndex)L0053_i_ChampionIndex);
+			} else {
+				_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[L0052_ui_ChampionIconIndex], k0_ColorBlack);
+			}
+			_vm->_championMan->_gK71_champions[L0054_i_ChampionIndex]._cell = (ViewCell)M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir);
+			setFlag(_vm->_championMan->_gK71_champions[L0054_i_ChampionIndex]._attributes, k0x0400_ChampionAttributeIcon);
+			_vm->_championMan->f292_drawChampionState((ChampionIndex)L0054_i_ChampionIndex);
+		}
+	}
+	_gK100_preventBuildPointerScreenArea = false;
+	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
+}
 } // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index fb983bf..7425826 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -299,6 +299,7 @@ public:
 	void f364_commandTakeStairs(bool stairsGoDown);// @ F0364_COMMAND_TakeStairs
 	void f367_commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX,
 																 int16 posY); // @ F0367_COMMAND_ProcessTypes12To27_ClickInChampionStatusBox
+	void f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex); // @ F0070_MOUSE_ProcessCommands125To128_ClickOnChampionIcon
 
 };
 


Commit: 1e8dfd7bb6b86ce5d4d2827bf692b217afbb07b1
    https://github.com/scummvm/scummvm/commit/1e8dfd7bb6b86ce5d4d2827bf692b217afbb07b1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f370_commandProcessType100_clickInSpellArea

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/menus.h
    engines/dm/movesens.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index fdbdc09..906c95b 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1298,7 +1298,7 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex)
 	}
 	if (L0906_T_SlotThing != Thing::_none) {
 		f300_getObjectRemovedFromSlot(L0903_ui_ChampionIndex, L0904_ui_SlotIndex);
-		f297_putObjectInLeaderHand(L0906_T_SlotThing, false); 
+		f297_putObjectInLeaderHand(L0906_T_SlotThing, false);
 	}
 	if (L0905_T_LeaderHandObject != Thing::_none) {
 		_vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0903_ui_ChampionIndex, L0905_T_LeaderHandObject, (ChampionSlot)L0904_ui_SlotIndex);
@@ -1307,6 +1307,34 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex)
 	_vm->_eventMan->f77_hideMouse();
 }
 
+bool ChampionMan::f327_isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount) {
+	int16 L0991_i_StepEnergy;
+	Champion* L0992_ps_Champion;
+
+	L0992_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	if (L0992_ps_Champion->_currMana < requiredManaAmount) {
+		return false;
+	}
+	L0992_ps_Champion->_currMana -= requiredManaAmount;
+	setFlag(L0992_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+	L0991_i_StepEnergy = 10 - MIN(8, L0992_ps_Champion->_maxMana >> 3);
+	if (kineticEnergy < (L0991_i_StepEnergy << 2)) {
+		kineticEnergy += 3;
+		L0991_i_StepEnergy--;
+	}
+	f326_championShootProjectile(L0992_ps_Champion, thing, kineticEnergy, 90, L0991_i_StepEnergy);
+	return true; // fix BUG_01
+}
+
+void ChampionMan::f326_championShootProjectile(Champion* champ, Thing thing, int16 kineticEnergy, int16 attack, int16 stepEnergy) {
+	uint16 L0990_ui_Direction;
+
+	L0990_ui_Direction = champ->_dir;
+	_vm->_projexpl->f212_projectileCreate(thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, M21_normalizeModulo4((((champ->_cell - L0990_ui_Direction + 1) & 0x0002) >> 1) + L0990_ui_Direction), (direction)L0990_ui_Direction, kineticEnergy, attack, stepEnergy);
+	_vm->_g311_projectileDisableMovementTicks = 4;
+	_vm->_g312_lastProjectileDisabledMovementDirection = L0990_ui_Direction;
+}
+
 ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
 	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
 		if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 37ca363..2bae7c5 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -448,7 +448,53 @@ public:
 #define k0x8000_maskUseSharpDefense 0x8000 // @ MASK0x8000_USE_SHARP_DEFENSE        
 
 #define k0x8000_mergeCycles 0x8000 // @ MASK0x8000_MERGE_CYCLES
-extern const char *g417_baseSkillName[4];
+// TODO: localization
+extern const char *g417_baseSkillName[4]; // @ G0417_apc_BaseSkillNames
+
+#define k0_spellCastFailure 0 // @ C0_SPELL_CAST_FAILURE             
+#define k1_spellCastSuccess 1 // @ C1_SPELL_CAST_SUCCESS             
+#define k3_spellCastFailureNeedsFlask 3 // @ C3_SPELL_CAST_FAILURE_NEEDS_FLASK 
+
+#define k0_failureNeedsMorePractice 0 // @ C00_FAILURE_NEEDS_MORE_PRACTICE      
+#define k1_failureMeaninglessSpell 1 // @ C01_FAILURE_MEANINGLESS_SPELL        
+#define k10_failureNeedsFlaskInHand 10 // @ C10_FAILURE_NEEDS_FLASK_IN_HAND     
+#define k11_failureNeedsMagicMapInHand 11 // @ C11_FAILURE_NEEDS_MAGIC_MAP_IN_HAND 
+
+#define k1_spellKindPotion 1 // @ C1_SPELL_KIND_POTION    
+#define k2_spellKindProjectile 2 // @ C2_SPELL_KIND_PROJECTILE
+#define k3_spellKindOther 3 // @ C3_SPELL_KIND_OTHER     
+#define k4_spellKindMagicMap 4 // @ C4_SPELL_KIND_MAGIC_MAP 
+
+#define k4_spellType_projectileOpenDoor 4 // @ C4_SPELL_TYPE_PROJECTILE_OPEN_DOOR
+#define k0_spellType_otherLight 0 // @ C0_SPELL_TYPE_OTHER_LIGHT         
+#define k1_spellType_otherDarkness 1 // @ C1_SPELL_TYPE_OTHER_DARKNESS      
+#define k2_spellType_otherThievesEye 2 // @ C2_SPELL_TYPE_OTHER_THIEVES_EYE   
+#define k3_spellType_otherInvisibility 3 // @ C3_SPELL_TYPE_OTHER_INVISIBILITY  
+#define k4_spellType_otherPartyShield 4 // @ C4_SPELL_TYPE_OTHER_PARTY_SHIELD  
+#define k5_spellType_otherMagicTorch 5 // @ C5_SPELL_TYPE_OTHER_MAGIC_TORCH   
+#define k6_spellType_otherFootprints 6 // @ C6_SPELL_TYPE_OTHER_FOOTPRINTS    
+#define k7_spellType_otherZokathra 7 // @ C7_SPELL_TYPE_OTHER_ZOKATHRA      
+#define k8_spellType_otherFireshield 8 // @ C8_SPELL_TYPE_OTHER_FIRESHIELD    
+#define k0_spellType_magicMap0 0 // @ C0_SPELL_TYPE_MAGIC_MAP           
+#define k1_spellType_magicMap1 1 // @ C1_SPELL_TYPE_MAGIC_MAP           
+#define k2_spellType_magicMap2 2 // @ C2_SPELL_TYPE_MAGIC_MAP           
+#define k3_spellType_magicMap3 3 // @ C3_SPELL_TYPE_MAGIC_MAP           
+
+class Spell {
+public:
+	Spell() {}
+	Spell(int32 symbols, byte baseSkillReq, byte skillIndex, uint16 attributes)
+	: _symbols(symbols), _baseRequiredSkillLevel(baseSkillReq), _skillIndex(skillIndex), _attributes(attributes) {}
+
+	int32 _symbols; /* Most significant byte: 0 (spell definition does not include power symbol) / not 0 (spell definition includes power symbol) */
+	byte _baseRequiredSkillLevel;
+	byte _skillIndex;
+	uint16 _attributes; /* Bits 15-10: Duration, Bits 9-4: Type, Bits 3-0: Kind */
+
+	uint16 M67_spellKind() { return _attributes & 0xF; } // @ M67_SPELL_KIND
+	uint16 M68_spellType() { return (_attributes >> 4) & 0x3F; } // @ M68_SPELL_TYPE
+	uint16 M69_spellDurration() { return (_attributes >> 10) & 0x3F; } // @ M69_SPELL_DURATION
+}; // @ SPELL
 
 class ChampionMan {
 	DMEngine *_vm;
@@ -526,8 +572,9 @@ public:
 	void f293_drawAllChampionStates(); // @ F0293_CHAMPION_DrawAllChampionStates
 	void f283_viAltarRebirth(uint16 champIndex); // @ F0283_CHAMPION_ViAltarRebirth
 	void f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex); // @ F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox
-
-
+	bool f327_isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount); // @ F0327_CHAMPION_IsProjectileSpellCast
+	void f326_championShootProjectile(Champion *champ, Thing thing, int16 kineticEnergy,
+									  int16 attack, int16 stepEnergy); // @ F0326_CHAMPION_ShootProjectile
 
 };
 
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index d88363a..7d91619 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1252,7 +1252,7 @@ uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 	};
 
 	Junk* junk;
-	uint16 weight;
+	uint16 weight = (uint16)-1; // initialization is not present in original
 
 	if (thing == Thing::_none)
 		return 0;
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index ca01034..305a921 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -452,6 +452,7 @@ public:
 	void setType(PotionType val) { _attributes = (_attributes & ~(0x7F << 8)) | ((val & 0x7F) << 8); }
 	Thing getNextThing() { return _nextThing; }
 	uint16 getPower() { return _attributes & 0xFF; }
+	void setPower(uint16 val) { _attributes = (_attributes & ~0xFF) | (val & 0xFF); }
 	uint16 getDoNotDiscard() { return (_attributes >> 15) & 1; }
 }; // @ POTION
 
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index f74c806..6be06e6 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -661,7 +661,7 @@ void EventManager::f380_processCommandQueue() {
 	}
 	if ((cmdType >= k28_CommandClickOnSlotBoxInventoryReadyHand) && (cmdType < (k65_CommandClickOnSlotBoxChest_8 + 1))) {
 		if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) {
-			warning(false, "MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox(cmdType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);");
+			_vm->_championMan->f302_processCommands28to65_clickOnSlotBox(cmdType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
 		}
 		return;
 	}
@@ -679,7 +679,7 @@ void EventManager::f380_processCommandQueue() {
 	}
 	if (cmdType == k100_CommandClickInSpellArea) {
 		if ((!_vm->_championMan->_g299_candidateChampionOrdinal) && (_vm->_championMan->_g514_magicCasterChampionIndex != kM1_ChampionNone)) {
-			warning(false, "MISSING CODE: F0370_COMMAND_ProcessType100_ClickInSpellArea(L1161_i_CommandX, L1162_i_CommandY);");
+			f370_commandProcessType100_clickInSpellArea(L1161_i_CommandX, L1162_i_CommandY);
 		}
 		return;
 	}
@@ -1304,7 +1304,7 @@ void EventManager::f367_commandProcessTypes12to27_clickInChampionStatusBox(uint1
 void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex) {
 	static Box G0621_s_Box_MousePointer_ChampionIconShadow = Box(2, 20, 2, 15);
 	static Box G0622_s_Box_MousePointer_ChampionIcon = Box(0, 18, 0, 13);
-	static byte G0045_auc_Graphic562_PaletteChanges_MousePointerIconShadow[16] = {0, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 0, 120, 120, 120}; 
+	static byte G0045_auc_Graphic562_PaletteChanges_MousePointerIconShadow[16] = {0, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 0, 120, 120, 120};
 
 	uint16 L0052_ui_ChampionIconIndex;
 	int16 L0053_i_ChampionIndex;
@@ -1359,4 +1359,110 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 	_gK100_preventBuildPointerScreenArea = false;
 	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
 }
+
+void EventManager::f370_commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY) {
+	int16 L1132_i_Command;
+	int16 L1133_i_ChampionIndex;
+
+
+	L1133_i_ChampionIndex = kM1_ChampionNone;
+	if (posY <= 48) {
+		switch (_vm->_championMan->_g514_magicCasterChampionIndex) {
+		case 0:
+			if ((posX >= 280) && (posX <= 291)) {
+				L1133_i_ChampionIndex = 1;
+			} else {
+				if ((posX >= 294) && (posX <= 305)) {
+					L1133_i_ChampionIndex = 2;
+				} else {
+					if (posX >= 308) {
+						L1133_i_ChampionIndex = 3;
+					}
+				}
+			}
+			break;
+		case 1:
+			if ((posX >= 233) && (posX <= 244)) {
+				L1133_i_ChampionIndex = 0;
+			} else {
+				if ((posX >= 294) && (posX <= 305)) {
+					L1133_i_ChampionIndex = 2;
+				} else {
+					if (posX >= 308) {
+						L1133_i_ChampionIndex = 3;
+					}
+				}
+			}
+			break;
+		case 2:
+			if ((posX >= 233) && (posX <= 244)) {
+				L1133_i_ChampionIndex = 0;
+			} else {
+				if ((posX >= 247) && (posX <= 258)) {
+					L1133_i_ChampionIndex = 1;
+				} else {
+					if (posX >= 308) {
+						L1133_i_ChampionIndex = 3;
+					}
+				}
+			}
+			break;
+		case 3:
+			if ((posX >= 247) && (posX <= 258)) {
+				L1133_i_ChampionIndex = 1;
+			} else {
+				if ((posX >= 261) && (posX <= 272)) {
+					L1133_i_ChampionIndex = 2;
+				} else {
+					if (posX <= 244) {
+						L1133_i_ChampionIndex = 0;
+					}
+				}
+			}
+		}
+		if ((L1133_i_ChampionIndex != kM1_ChampionNone) && (L1133_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount)) {
+			_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(L1133_i_ChampionIndex);
+		}
+		return;
+	}
+	L1132_i_Command = _vm->_eventMan->f358_getCommandTypeFromMouseInput(g454_MouseInput_SpellArea, Common::Point(posX, posY), k1_LeftMouseButton);
+	if (L1132_i_Command != k0_CommandNone) {
+		f369_commandProcessTypes101To108_clickInSpellSymbolsArea((CommandType)L1132_i_Command);
+	}
+}
+
+void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType) {
+	static Box G0464_as_Graphic561_Box_SpellSymbolsAndDelete[7] = {
+		/* { X1, X2, Y1, Y2 } */
+		Box(235, 247, 51, 61),   /* Symbol 1 */
+		Box(249, 261, 51, 61),   /* Symbol 2 */
+		Box(263, 275, 51, 61),   /* Symbol 3 */
+		Box(277, 289, 51, 61),   /* Symbol 4 */
+		Box(291, 303, 51, 61),   /* Symbol 5 */
+		Box(305, 317, 51, 61),   /* Symbol 6 */
+		Box(305, 318, 63, 73)}; /* Delete */
+
+	uint16 L1130_ui_SymbolIndex;
+	Box* L1131_ps_Box;
+
+
+	if (cmdType == k108_CommandClickInSpeallAreaCastSpell) {
+		if (_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex]._symbols[0] == '\0') {
+			return;
+		}
+		warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+		_vm->_g321_stopWaitingForPlayerInput = _vm->_menuMan->f408_getClickOnSpellCastResult();
+		return;
+	}
+	L1130_ui_SymbolIndex = cmdType - k101_CommandClickInSpellAreaSymbol_1;
+	L1131_ps_Box = &G0464_as_Graphic561_Box_SpellSymbolsAndDelete[L1130_ui_SymbolIndex];
+	warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+	_vm->f22_delay(1);
+	warning(false, "MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
+	if (L1130_ui_SymbolIndex < 6) {
+		_vm->_menuMan->f399_addChampionSymbol(L1130_ui_SymbolIndex);
+	} else {
+		_vm->_menuMan->f400_deleteChampionSymbol();
+	}
+}
 } // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 7425826..7ad24a7 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -300,6 +300,8 @@ public:
 	void f367_commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX,
 																 int16 posY); // @ F0367_COMMAND_ProcessTypes12To27_ClickInChampionStatusBox
 	void f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex); // @ F0070_MOUSE_ProcessCommands125To128_ClickOnChampionIcon
+	void f370_commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY); // @ F0370_COMMAND_ProcessType100_ClickInSpellArea
+	void f369_commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType); // @ F0369_COMMAND_ProcessTypes101To108_ClickInSpellSymbolsArea_CPSE
 
 };
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index a0c6e57..1a15d44 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -675,6 +675,24 @@ void InventoryMan::f338_decreaseTorchesLightPower() {
 }
 
 void InventoryMan::f351_drawChampionSkillsAndStatistics() {
+	// TODO: localization
+	static char* G0428_apc_SkillLevelNames[15] = {
+		"NEOPHYTE",
+		"NOVICE",
+		"APPRENTICE",
+		"JOURNEYMAN",
+		"CRAFTSMAN",
+		"ARTISAN",
+		"ADEPT",
+		"EXPERT",
+		"` MASTER",
+		"a MASTER",
+		"b MASTER",
+		"c MASTER",
+		"d MASTER",
+		"e MASTER",
+		"ARCHMASTER"};
+
 	uint16 L1090_ui_Multiple;
 #define AL1090_ui_SkillIndex     L1090_ui_Multiple
 #define AL1090_ui_StatisticIndex L1090_ui_Multiple
@@ -699,16 +717,9 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 		AL1092_i_SkillLevel = MIN((uint16)16, _vm->_championMan->f303_getSkillLevel(L1093_ui_ChampionIndex, AL1090_ui_SkillIndex | k0x8000_IgnoreTemporaryExperience));
 		if (AL1092_i_SkillLevel == 1)
 			continue;
-#ifdef COMPILE17_DM10aEN_DM10bEN_DM11EN_DM12EN_CSB20EN_CSB21EN_DMDEMO20EN_DM20EN_DM21EN_DM22EN /* CHANGE4_00_LOCALIZATION Translation to German language */
 		strcpy(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]);
 		strcat(L1097_ac_String, " ");
-		strcat(L1097_ac_String, G0417_apc_BaseSkillNames[AL1090_ui_SkillIndex]);
-#endif
-#ifdef COMPILE36_DM12GE_DM13aFR_DM13bFR_DM20GE_DM20FR_DM22GE /* CHANGE4_00_LOCALIZATION Translation to German language */
-		strcpy(L1097_ac_String, G0417_apc_BaseSkillNames[AL1090_ui_SkillIndex]);
-		strcat(L1097_ac_String, " ");
-		strcat(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]);
-#endif
+		strcat(L1097_ac_String, g417_baseSkillName[AL1090_ui_SkillIndex]);
 		_vm->_textMan->f52_printToViewport(108, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String);
 		L1091_i_Y += 7;
 	}
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index d63cab0..d35ec75 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -33,6 +33,8 @@
 #include "inventory.h"
 #include "text.h"
 #include "eventman.h"
+#include "timeline.h"
+#include "movesens.h"
 
 
 namespace DM {
@@ -402,4 +404,413 @@ void MenuMan::f457_drawEnabledMenus() {
 	}
 }
 
+int16 MenuMan::f408_getClickOnSpellCastResult() {
+	int16 L1259_i_SpellCastResult;
+	Champion* L1260_ps_Champion;
+
+
+	L1260_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
+	_vm->_eventMan->f78_showMouse();
+	warning(false, "MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
+	if ((L1259_i_SpellCastResult = f412_getChampionSpellCastResult(_vm->_championMan->_g514_magicCasterChampionIndex)) != k3_spellCastFailureNeedsFlask) {
+		L1260_ps_Champion->_symbols[0] = '\0';
+		f397_drawAvailableSymbols(L1260_ps_Champion->_symbolStep = 0);
+		f398_drawChampionSymbols(L1260_ps_Champion);
+	} else {
+		L1259_i_SpellCastResult = k0_spellCastFailure;
+	}
+	_vm->_eventMan->f77_hideMouse();
+	return L1259_i_SpellCastResult;
+}
+
+int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
+	uint16 L1267_ui_Multiple;
+#define AL1267_ui_SkillLevel L1267_ui_Multiple
+#define AL1267_ui_LightPower L1267_ui_Multiple
+#define AL1267_ui_SpellPower L1267_ui_Multiple
+#define AL1267_ui_Ticks      L1267_ui_Multiple
+	int16 L1268_i_PowerSymbolOrdinal;
+	uint16 L1269_ui_Multiple;
+#define AL1269_ui_RequiredSkillLevel L1269_ui_Multiple
+#define AL1269_ui_EmptyFlaskWeight   L1269_ui_Multiple
+#define AL1269_ui_Ticks              L1269_ui_Multiple
+	Champion* L1270_ps_Champion;
+	Spell* L1271_ps_Spell;
+	Thing L1272_T_Object;
+	uint16 L1273_ui_Experience;
+	int16 L1274_i_MissingSkillLevelCount;
+	Potion* L1275_ps_Potion;
+	TimelineEvent L1276_s_Event;
+	Junk* L1277_ps_Junk;
+
+
+	if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
+		return k0_spellCastFailure;
+	}
+	L1270_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	if (!(L1270_ps_Champion->_currHealth)) {
+		return k0_spellCastFailure;
+	}
+	if ((L1271_ps_Spell = f409_getSpellFromSymbols((unsigned char *)L1270_ps_Champion->_symbols)) == 0) {
+		f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k1_spellCastSuccess, 0);
+		return k0_spellCastFailure;
+	}
+	L1268_i_PowerSymbolOrdinal = L1270_ps_Champion->_symbols[0] - '_'; /* Values 1 to 6 */
+	L1273_ui_Experience = _vm->getRandomNumber(8) + ((AL1269_ui_RequiredSkillLevel = L1271_ps_Spell->_baseRequiredSkillLevel + L1268_i_PowerSymbolOrdinal) << 4) + ((_vm->M1_ordinalToIndex(L1268_i_PowerSymbolOrdinal) * L1271_ps_Spell->_baseRequiredSkillLevel) << 3) + (AL1269_ui_RequiredSkillLevel * AL1269_ui_RequiredSkillLevel);
+	AL1267_ui_SkillLevel = _vm->_championMan->f303_getSkillLevel(champIndex, L1271_ps_Spell->_skillIndex);
+	if (AL1267_ui_SkillLevel < AL1269_ui_RequiredSkillLevel) {
+		L1274_i_MissingSkillLevelCount = AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel;
+		while (L1274_i_MissingSkillLevelCount--) {
+			if (_vm->getRandomNumber(128) > MIN(L1270_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + 15, 115)) {
+				_vm->_championMan->f304_addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience >> (AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel));
+				f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k0_failureNeedsMorePractice, L1271_ps_Spell->_skillIndex);
+				return k0_spellCastFailure;
+			}
+		}
+	}
+	switch (L1271_ps_Spell->M67_spellKind()) {
+	case k1_spellKindPotion:
+		if ((L1275_ps_Potion = f411_getEmptyFlaskInHand(L1270_ps_Champion, &L1272_T_Object)) == NULL) {
+			f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k10_failureNeedsFlaskInHand, 0);
+			return k3_spellCastFailureNeedsFlask;
+		}
+		AL1269_ui_EmptyFlaskWeight = _vm->_dungeonMan->f140_getObjectWeight(L1272_T_Object);
+		L1275_ps_Potion->setType((PotionType)L1271_ps_Spell->M68_spellType());
+		L1275_ps_Potion->setPower(_vm->getRandomNumber(16) + (L1268_i_PowerSymbolOrdinal * 40));
+		L1270_ps_Champion->_load += _vm->_dungeonMan->f140_getObjectWeight(L1272_T_Object) - AL1269_ui_EmptyFlaskWeight;
+		_vm->_championMan->f296_drawChangedObjectIcons();
+		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)) {
+			setFlag(L1270_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad);
+			_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+		}
+		break;
+	case k2_spellKindProjectile:
+		if (L1270_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) {
+			L1270_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
+			setFlag(L1270_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon);
+			_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+		}
+		if (L1271_ps_Spell->M68_spellType() == k4_spellType_projectileOpenDoor) {
+			AL1267_ui_SkillLevel <<= 1;
+		}
+		_vm->_championMan->f327_isProjectileSpellCast(champIndex, Thing(L1271_ps_Spell->M68_spellType() + Thing::_firstExplosion.toUint16()), f26_getBoundedValue(21, (L1268_i_PowerSymbolOrdinal + 2) * (4 + (AL1267_ui_SkillLevel << 1)), 255), 0);
+		break;
+	case k3_spellKindOther:
+		L1276_s_Event._priority = 0;
+		AL1267_ui_SpellPower = (L1268_i_PowerSymbolOrdinal + 1) << 2;
+		switch (L1271_ps_Spell->M68_spellType()) {
+		case k0_spellType_otherLight:
+			AL1269_ui_Ticks = 10000 + ((AL1267_ui_SpellPower - 8) << 9);
+			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 1);
+			AL1267_ui_LightPower--;
+			goto T0412019;
+		case k5_spellType_otherMagicTorch:
+			AL1269_ui_Ticks = 2000 + ((AL1267_ui_SpellPower - 3) << 7);
+			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
+			AL1267_ui_LightPower++;
+T0412019:
+			_vm->_championMan->_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[AL1267_ui_LightPower];
+			f404_createEvent70_light(-AL1267_ui_LightPower, AL1269_ui_Ticks);
+			break;
+		case k1_spellType_otherDarkness:
+			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
+			_vm->_championMan->_g407_party._magicalLightAmount -= g39_LightPowerToLightAmount[AL1267_ui_LightPower];
+			f404_createEvent70_light(AL1267_ui_LightPower, 98);
+			break;
+		case k2_spellType_otherThievesEye:
+			L1276_s_Event._type = k73_TMEventTypeThievesEye;
+			_vm->_championMan->_g407_party._event73Count_ThievesEye++;
+			AL1267_ui_SpellPower = (AL1267_ui_SpellPower >> 1);
+			goto T0412032;
+		case k3_spellType_otherInvisibility:
+			L1276_s_Event._type = k71_TMEventTypeInvisibility;
+			_vm->_championMan->_g407_party._event71Count_Invisibility++;
+			goto T0412033;
+		case k4_spellType_otherPartyShield:
+			L1276_s_Event._type = k74_TMEventTypePartyShield;
+			L1276_s_Event._B._defense = AL1267_ui_SpellPower;
+			if (_vm->_championMan->_g407_party._shieldDefense > 50) {
+				L1276_s_Event._B._defense >>= 2;
+			}
+			_vm->_championMan->_g407_party._shieldDefense += L1276_s_Event._B._defense;
+			_vm->_timeline->f260_timelineRefreshAllChampionStatusBoxes();
+			goto T0412032;
+		case k6_spellType_otherFootprints:
+			L1276_s_Event._type = k79_TMEventTypeFootprints;
+			_vm->_championMan->_g407_party._event79Count_Footprints++;
+			_vm->_championMan->_g407_party._firstScentIndex = _vm->_championMan->_g407_party._scentCount;
+			if (L1268_i_PowerSymbolOrdinal < 3) {
+				_vm->_championMan->_g407_party._lastScentIndex = _vm->_championMan->_g407_party._firstScentIndex;
+			} else {
+				_vm->_championMan->_g407_party._lastScentIndex = 0;
+			}
+T0412032:
+			AL1267_ui_Ticks = AL1267_ui_SpellPower * AL1267_ui_SpellPower;
+T0412033:
+			M33_setMapAndTime(L1276_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + AL1267_ui_Ticks);
+			_vm->_timeline->f238_addEventGetEventIndex(&L1276_s_Event);
+			break;
+		case k7_spellType_otherZokathra:
+			if ((L1272_T_Object = _vm->_dungeonMan->f166_getUnusedThing(k10_JunkThingType)) == Thing::_none)
+				break;
+			L1277_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1272_T_Object);
+			L1277_ps_Junk->setType(k51_JunkTypeZokathra);
+			ChampionSlot AL1267_ui_SlotIndex;
+			if (L1270_ps_Champion->_slots[k0_ChampionSlotReadyHand] == Thing::_none) {
+				AL1267_ui_SlotIndex = k0_ChampionSlotReadyHand;
+			} else {
+				if (L1270_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) {
+					AL1267_ui_SlotIndex = k1_ChampionSlotActionHand;
+				} else {
+					AL1267_ui_SlotIndex = kM1_ChampionSlotLeaderHand;
+				}
+			}
+			if ((AL1267_ui_SlotIndex == k0_ChampionSlotReadyHand) || (AL1267_ui_SlotIndex == k1_ChampionSlotActionHand)) {
+				_vm->_championMan->f301_addObjectInSlot((ChampionIndex)champIndex, L1272_T_Object, AL1267_ui_SlotIndex);
+				_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+			} else {
+				_vm->_movsens->f267_getMoveResult(L1272_T_Object, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+			}
+			break;
+		case k8_spellType_otherFireshield:
+			f403_isPartySpellOrFireShieldSuccessful(L1270_ps_Champion, false, (AL1267_ui_SpellPower * AL1267_ui_SpellPower) + 100, false);
+		}
+	}
+	_vm->_championMan->f304_addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience);
+	_vm->_championMan->f330_disableAction(champIndex, L1271_ps_Spell->M69_spellDurration());
+	return k1_spellCastSuccess;
+}
+
+Spell* MenuMan::f409_getSpellFromSymbols(byte* symbols) {
+	static Spell G0487_as_Graphic560_Spells[25] = {
+		/* { Symbols, BaseRequiredSkillLevel, SkillIndex, Attributes } */
+		Spell(0x00666F00, 2, 15, 0x7843),
+		Spell(0x00667073, 1, 18, 0x4863),
+		Spell(0x00686D77, 3, 17, 0xB433),
+		Spell(0x00686C00, 3, 19, 0x6C72),
+		Spell(0x00686D76, 3, 18, 0x8423),
+		Spell(0x00686E76, 4, 17, 0x7822),
+		Spell(0x00686F76, 4, 17, 0x5803),
+		Spell(0x00690000, 1, 16, 0x3C53),
+		Spell(0x00696F00, 3, 16, 0xA802),
+		Spell(0x00697072, 4, 13, 0x3C71),
+		Spell(0x00697075, 4, 15, 0x7083),
+		Spell(0x006A6D00, 1, 18, 0x5032),
+		Spell(0x006A6C00, 1, 19, 0x4062),
+		Spell(0x006A6F77, 1, 15, 0x3013),
+		Spell(0x006B0000, 1, 17, 0x3C42),
+		Spell(0x00667000, 2, 15, 0x64C1),
+		Spell(0x00660000, 2, 13, 0x3CB1),
+		Spell(0x00667074, 4, 13, 0x3C81),
+		Spell(0x00667075, 4, 13, 0x3C91),
+		Spell(0x00670000, 1, 13, 0x80E1),
+		Spell(0x00677000, 1, 13, 0x68A1),
+		Spell(0x00687073, 4, 13, 0x3C61),
+		Spell(0x006B7076, 3,  2, 0xFCD1),
+		Spell(0x006B6C00, 2, 19, 0x7831),
+		Spell(0x006B6E76, 0,  3, 0x3C73)};
+
+
+	int32 L1261_l_Symbols;
+	int16 L1262_i_Multiple;
+#define AL1262_i_BitShiftCount L1262_i_Multiple
+#define AL1262_i_SpellIndex    L1262_i_Multiple
+	Spell* L1263_ps_Spell;
+
+
+	if (*(symbols + 1)) {
+		AL1262_i_BitShiftCount = 24;
+		L1261_l_Symbols = 0;
+		do {
+			L1261_l_Symbols |= (long)*symbols++ << AL1262_i_BitShiftCount;
+		} while (*symbols && ((AL1262_i_BitShiftCount -= 8) >= 0));
+		L1263_ps_Spell = G0487_as_Graphic560_Spells;
+		AL1262_i_SpellIndex = 25;
+		while (AL1262_i_SpellIndex--) {
+			if (L1263_ps_Spell->_symbols & 0xFF000000) { /* If byte 1 of spell is not 0 then the spell includes the power symbol */
+				if (L1261_l_Symbols == L1263_ps_Spell->_symbols) { /* Compare champion symbols, including power symbol, with spell (never used with actual spells) */
+					return L1263_ps_Spell;
+				}
+			} else {
+				if ((L1261_l_Symbols & 0x00FFFFFF) == L1263_ps_Spell->_symbols) { /* Compare champion symbols, except power symbol, with spell */
+					return L1263_ps_Spell;
+				}
+			}
+			L1263_ps_Spell++;
+		}
+	}
+	return NULL;
+}
+
+void MenuMan::f410_menusPrintSpellFailureMessage(Champion* champ, uint16 failureType, uint16 skillIndex) {
+	char* L1264_pc_Message = nullptr;
+
+	if (skillIndex > k3_ChampionSkillWizard) {
+		skillIndex = (skillIndex - 4) / 4;
+	}
+	_vm->_textMan->f51_messageAreaPrintLineFeed();
+	_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, champ->_name);
+	switch (failureType) {
+	case k0_failureNeedsMorePractice:
+		// TODO: localization
+		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, " NEEDS MORE PRACTICE WITH THIS ");
+		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, g417_baseSkillName[skillIndex]);
+		L1264_pc_Message = " SPELL.";
+		break;
+	case k1_failureMeaninglessSpell:
+		L1264_pc_Message = " MUMBLES A MEANINGLESS SPELL."; // TODO: localization
+		break;
+	case k10_failureNeedsFlaskInHand:
+		L1264_pc_Message = " NEEDS AN EMPTY FLASK IN HAND FOR POTION."; // TODO: localization
+		break;
+	}
+	_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, L1264_pc_Message);
+}
+
+Potion* MenuMan::f411_getEmptyFlaskInHand(Champion* champ, Thing* potionThing) {
+	Thing L1265_T_Thing;
+	int16 L1266_i_SlotIndex;
+
+	for (L1266_i_SlotIndex = k2_ChampionSlotHead; --L1266_i_SlotIndex >= k0_ChampionSlotReadyHand; ) {
+		if (((L1265_T_Thing = champ->_slots[L1266_i_SlotIndex]) != Thing::_none) && (_vm->_objectMan->f33_getIconIndex(L1265_T_Thing) == k195_IconIndicePotionEmptyFlask)) {
+			*potionThing = L1265_T_Thing;
+			return (Potion*)_vm->_dungeonMan->f156_getThingData(L1265_T_Thing);
+		}
+	}
+	return nullptr;
+}
+
+void MenuMan::f404_createEvent70_light(int16 lightPower, int16 ticks) {
+	TimelineEvent L1241_s_Event;
+
+	L1241_s_Event._type = k70_TMEventTypeLight;
+	L1241_s_Event._B._lightPower = lightPower;
+	M33_setMapAndTime(L1241_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + ticks);
+	L1241_s_Event._priority = 0;
+	_vm->_timeline->f238_addEventGetEventIndex(&L1241_s_Event);
+	_vm->_inventoryMan->f337_setDungeonViewPalette();
+}
+
+bool MenuMan::f403_isPartySpellOrFireShieldSuccessful(Champion* champ, bool spellShield, uint16 ticks, bool useMana) {
+	bool L1239_B_IsPartySpellOrFireShieldSuccessful;
+	TimelineEvent L1240_s_Event;
+
+
+	L1239_B_IsPartySpellOrFireShieldSuccessful = true;
+	if (useMana) {
+		if (champ->_currMana == 0) {
+			return false;
+		}
+		if (champ->_currMana < 4) {
+			ticks >>= 1;
+			champ->_currMana = 0;
+			L1239_B_IsPartySpellOrFireShieldSuccessful = false;
+		} else {
+			champ->_currMana -= 4;
+		}
+	}
+	L1240_s_Event._B._defense = ticks >> 5;
+	if (spellShield) {
+		L1240_s_Event._type = k77_TMEventTypeSpellShield;
+		if (_vm->_championMan->_g407_party._spellShieldDefense > 50) {
+			L1240_s_Event._B._defense >>= 2;
+		}
+		_vm->_championMan->_g407_party._spellShieldDefense += L1240_s_Event._B._defense;
+	} else {
+		L1240_s_Event._type = k78_TMEventTypeFireShield;
+		if (_vm->_championMan->_g407_party._fireShieldDefense > 50) {
+			L1240_s_Event._B._defense >>= 2;
+		}
+		_vm->_championMan->_g407_party._fireShieldDefense += L1240_s_Event._B._defense;
+	}
+	L1240_s_Event._priority = 0;
+	M33_setMapAndTime(L1240_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + ticks);
+	_vm->_timeline->f238_addEventGetEventIndex(&L1240_s_Event);
+	_vm->_timeline->f260_timelineRefreshAllChampionStatusBoxes();
+	return L1239_B_IsPartySpellOrFireShieldSuccessful;
+}
+
+void MenuMan::f397_drawAvailableSymbols(uint16 symbolStep) {
+	uint16 L1214_ui_Counter;
+	int16 L1215_i_X;
+	char L1216_c_Character;
+	char L1217_ac_String[2];
+
+	L1217_ac_String[1] = '\0';
+	L1216_c_Character = 96 + 6 * symbolStep;
+	L1215_i_X = 225;
+	for (L1214_ui_Counter = 0; L1214_ui_Counter < 6; L1214_ui_Counter++) {
+		L1217_ac_String[0] = L1216_c_Character++;
+		_vm->_textMan->f53_printToLogicalScreen(L1215_i_X += 14, 58, k4_ColorCyan, k0_ColorBlack, L1217_ac_String);
+	}
+}
+
+void MenuMan::f398_drawChampionSymbols(Champion* champ) {
+	uint16 L1218_ui_SymbolIndex;
+	int16 L1219_i_X;
+	uint16 L1220_ui_SymbolCount;
+	char L1221_ac_String[2];
+
+
+	L1220_ui_SymbolCount = strlen(champ->_symbols);
+	L1219_i_X = 232;
+	L1221_ac_String[1] = '\0';
+	for (L1218_ui_SymbolIndex = 0; L1218_ui_SymbolIndex < 4; L1218_ui_SymbolIndex++) {
+		if (L1218_ui_SymbolIndex >= L1220_ui_SymbolCount) {
+			L1221_ac_String[0] = ' ';
+		} else {
+			L1221_ac_String[0] = champ->_symbols[L1218_ui_SymbolIndex];
+		}
+		_vm->_textMan->f53_printToLogicalScreen(L1219_i_X += 9, 70, k4_ColorCyan, k0_ColorBlack, L1221_ac_String);
+	}
+}
+
+void MenuMan::f399_addChampionSymbol(int16 symbolIndex) {
+	static byte G0485_aauc_Graphic560_SymbolBaseManaCost[4][6] = {
+		{1, 2, 3, 4, 5, 6},   /* Power 1 */
+		{2, 3, 4, 5, 6, 7},   /* Power 2 */
+		{4, 5, 6, 7, 7, 9},   /* Power 3 */
+		{2, 2, 3, 4, 6, 7}}; /* Power 4 */
+	static byte G0486_auc_Graphic560_SymbolManaCostMultiplier[6] = {8, 12, 16, 20, 24, 28};
+
+	uint16 L1222_ui_SymbolStep;
+	uint16 L1223_ui_ManaCost;
+	uint16 L1224_ui_SymbolIndex;
+	Champion* L1225_ps_Champion;
+
+	L1225_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
+	L1222_ui_SymbolStep = L1225_ps_Champion->_symbolStep;
+	L1223_ui_ManaCost = G0485_aauc_Graphic560_SymbolBaseManaCost[L1222_ui_SymbolStep][symbolIndex];
+	if (L1222_ui_SymbolStep) {
+		L1223_ui_ManaCost = (L1223_ui_ManaCost * G0486_auc_Graphic560_SymbolManaCostMultiplier[L1224_ui_SymbolIndex = L1225_ps_Champion->_symbols[0] - 96]) >> 3;
+	}
+	if (L1223_ui_ManaCost <= L1225_ps_Champion->_currMana) {
+		L1225_ps_Champion->_currMana -= L1223_ui_ManaCost;
+		setFlag(L1225_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+		L1225_ps_Champion->_symbols[L1222_ui_SymbolStep] = 96 + (L1222_ui_SymbolStep * 6) + symbolIndex;
+		L1225_ps_Champion->_symbols[L1222_ui_SymbolStep + 1] = '\0';
+		L1225_ps_Champion->_symbolStep = L1222_ui_SymbolStep = returnNextVal(L1222_ui_SymbolStep);
+		_vm->_eventMan->f78_showMouse();
+		f397_drawAvailableSymbols(L1222_ui_SymbolStep);
+		f398_drawChampionSymbols(L1225_ps_Champion);
+		_vm->_championMan->f292_drawChampionState(_vm->_championMan->_g514_magicCasterChampionIndex);
+		_vm->_eventMan->f77_hideMouse();
+	}
+}
+
+void MenuMan::f400_deleteChampionSymbol() {
+	int16 L1226_ui_SymbolStep;
+	Champion* L1228_ps_Champion;
+
+	L1228_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
+	if (!strlen(L1228_ps_Champion->_symbols)) {
+		return;
+	}
+	L1228_ps_Champion->_symbolStep = L1226_ui_SymbolStep = returnPrevVal(L1228_ps_Champion->_symbolStep);
+	L1228_ps_Champion->_symbols[L1226_ui_SymbolStep] = '\0';
+	_vm->_eventMan->f78_showMouse();
+	f397_drawAvailableSymbols(L1226_ui_SymbolStep);
+	f398_drawChampionSymbols(L1228_ps_Champion);
+	_vm->_eventMan->f77_hideMouse();
+}
 }
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 9c93fd0..0aabcab 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -30,6 +30,7 @@
 
 #include "dm.h"
 #include "champion.h"
+#include "dungeonman.h"
 
 namespace DM {
 
@@ -73,6 +74,17 @@ public:
 	void f392_buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine
 	void f394_setMagicCasterAndDrawSpellArea(int16 champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea
 	void f457_drawEnabledMenus(); // @ F0457_START_DrawEnabledMenus_CPSF
+	int16 f408_getClickOnSpellCastResult(); // @ F0408_MENUS_GetClickOnSpellCastResult
+	int16 f412_getChampionSpellCastResult(uint16 champIndex); // @ F0412_MENUS_GetChampionSpellCastResult
+	Spell *f409_getSpellFromSymbols(byte *symbols); // @ F0409_MENUS_GetSpellFromSymbols
+	void f410_menusPrintSpellFailureMessage(Champion *champ, uint16 failureType, uint16 skillIndex); // @ F0410_MENUS_PrintSpellFailureMessage
+	Potion *f411_getEmptyFlaskInHand(Champion *champ, Thing *potionThing); // @ F0411_MENUS_GetEmptyFlaskInHand
+	void f404_createEvent70_light(int16 lightPower, int16 ticks); // @ F0404_MENUS_CreateEvent70_Light
+	bool f403_isPartySpellOrFireShieldSuccessful(Champion *champ, bool spellShield, uint16 ticks, bool useMana); // @ F0403_MENUS_IsPartySpellOrFireShieldSuccessful
+	void f397_drawAvailableSymbols(uint16 symbolStep); // @ F0397_MENUS_DrawAvailableSymbols
+	void f398_drawChampionSymbols(Champion *champ); // @ F0398_MENUS_DrawChampionSymbols
+	void f399_addChampionSymbol(int16 symbolIndex); // @ F0399_MENUS_AddChampionSymbol
+	void f400_deleteChampionSymbol(); // @ F0400_MENUS_DeleteChampionSymbol
 };
 
 }
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index f154053..6cb159a 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -845,10 +845,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 						goto T0276079;
 					break;
 				case k5_SensorFloorPartyOnStairs:
-					// Strangerke: Only present in v2.1, but it fixes a bug so we'll keep it.
-#ifdef COMPILE52_CSB21EN /* CHANGE8_05_FIX The wrong variable is replaced by the correct variable in the condition. The test should not be on L0771_ui_ThingType but on L0767_i_ThingType */
-					if ((L0767_i_ThingType != kM1_PartyThingType) || (M34_SQUARE_TYPE(L0777_ui_Square) != k3_ElementTypeStairs))
-#endif
+					if ((L0767_i_ThingType != kM1_PartyThingType) || (Square(L0777_ui_Square).getType() != k3_ElementTypeStairs))
 						goto T0276079;
 					break;
 				case k6_SensorFloorGroupGenerator:


Commit: b4bebaa845ecd729576e143818fcc7b378262b5b
    https://github.com/scummvm/scummvm/commit/b4bebaa845ecd729576e143818fcc7b378262b5b
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f371_commandProcessType111To115_ClickInActionArea and it's dependencies

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/champion.cpp
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/group.cpp
    engines/dm/group.h
    engines/dm/menus.cpp
    engines/dm/menus.h
    engines/dm/movesens.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 4839d2d..9137975 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -6,7 +6,9 @@ Bugs:
 
 	Logic:
 		When object are put on the right side of the current square, they disappear
-		Drawing door ornaments segfaults when going back to the start 
+		Drawing door ornaments segfaults when going back to the start
+	  !! It seems that that deleted events' _type fields are not getting set to 0, when looking for available slots, the code looks for events with 0 _type fields, 
+	  		this results in segfaults
 
 Possible bugs:
 	- k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 906c95b..b9c286a 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1059,7 +1059,7 @@ bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) {
 	if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage)) {
 		return true;
 	}
-	register unsigned char* L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck];
+	unsigned char* L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck];
 	AP0646_ui_IsLucky = (_vm->getRandomNumber(L0928_puc_Statistic[k1_ChampionStatCurrent]) > percentage);
 	L0928_puc_Statistic[k1_ChampionStatCurrent] = f26_getBoundedValue((int32)L0928_puc_Statistic[k2_ChampionStatMinimum], (int32)L0928_puc_Statistic[k1_ChampionStatCurrent] + (AP0646_ui_IsLucky ? -2 : 2), (int32)L0928_puc_Statistic[k0_ChampionStatMaximum]);
 	return AP0646_ui_IsLucky;
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 7d91619..3d1f931 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -795,7 +795,7 @@ Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 st
 int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) {
 	uint16 L0260_ui_ThingIndex;
 	int16 L0261_i_MapY;
-	register unsigned char* L0262_puc_Square;
+	unsigned char* L0262_puc_Square;
 
 
 	L0262_puc_Square = _vm->_dungeonMan->_g271_currMapData[mapX];
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 305a921..515ef93 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -379,6 +379,7 @@ public:
 	uint16 getChargeCount() { return (_desc >> 10) & 0xF; }
 	uint16 setChargeCount(uint16 val) { _desc = (_desc & ~(0xF << 10)) | ((val & 0xF) << 10); return (val & 0xF); }
 	Thing getNextThing() { return _nextThing; }
+	void setNextThing(Thing val) { _nextThing = val;  }
 	uint16 getCursed() { return (_desc >> 8) & 1; }
 	void setCursed(uint16 val) { _desc = (_desc & ~(1 << 8)) | ((val & 1) << 8); }
 	uint16 getPoisoned() { return (_desc >> 9) & 1; }
@@ -405,6 +406,8 @@ public:
 	uint16 getCursed() { return (_attributes >> 8) & 1; }
 	uint16 getBroken() { return (_attributes >> 13) & 1; }
 	uint16 getDoNotDiscard() { return (_attributes >> 7) & 1; }
+	uint16 getChargeCount() { return (_attributes >> 9) & 0xF; }
+	void setChargeCount(uint16 val) { _attributes = (_attributes & ~(0xF << 9)) | ((val & 0xF) << 9); }
 }; // @ ARMOUR
 
 class Scroll {
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 6be06e6..b1ffe30 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -685,7 +685,7 @@ void EventManager::f380_processCommandQueue() {
 	}
 	if (cmdType == k111_CommandClickInActionArea) {
 		if (!_vm->_championMan->_g299_candidateChampionOrdinal) {
-			warning(false, "MISSING CODE: F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE(L1161_i_CommandX, L1162_i_CommandY);");
+			f371_commandProcessType111To115_ClickInActionArea(L1161_i_CommandX, L1162_i_CommandY);
 		}
 		return;
 	}
@@ -1310,7 +1310,7 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 	int16 L0053_i_ChampionIndex;
 	int16 L0054_i_ChampionIndex;
 	Box* L0055_pi_ChampionIconBox;
-	register unsigned char* L0056_puc_Bitmap;
+	byte* L0056_puc_Bitmap;
 
 
 	_gK100_preventBuildPointerScreenArea = true;
@@ -1465,4 +1465,41 @@ void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(Comm
 		_vm->_menuMan->f400_deleteChampionSymbol();
 	}
 }
+
+void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY) {
+	uint16 L1134_ui_Command;
+
+
+	if (_vm->_championMan->_g506_actingChampionOrdinal) {
+		L1134_ui_Command = _vm->_eventMan->f358_getCommandTypeFromMouseInput(g452_MouseInput_ActionAreaNames, Common::Point(posX, posY), k1_LeftMouseButton);
+		if (L1134_ui_Command != k0_CommandNone) {
+			if (L1134_ui_Command == k112_CommandClickInActionAreaPass) {
+				warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+				_vm->_menuMan->f391_didClickTriggerAction(-1);
+			} else {
+				if ((L1134_ui_Command - k112_CommandClickInActionAreaPass) <= _vm->_menuMan->_g507_actionCount) {
+					if (L1134_ui_Command == k113_CommandClickInActionAreaAction_0) {
+						warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+					} else {
+						if (L1134_ui_Command == k114_CommandClickInActionAreaAction_1) {
+							warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+						} else {
+							warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+						}
+					}
+					_vm->_g321_stopWaitingForPlayerInput = _vm->_menuMan->f391_didClickTriggerAction(L1134_ui_Command - k113_CommandClickInActionAreaAction_0);
+				}
+			}
+		}
+	} else {
+		if (_vm->_menuMan->_g509_actionAreaContainsIcons) {
+			L1134_ui_Command = _vm->_eventMan->f358_getCommandTypeFromMouseInput(g453_MouseInput_ActionAreaIcons, Common::Point(posX, posY), k1_LeftMouseButton);
+			if (L1134_ui_Command != k0_CommandNone) {
+				if ((L1134_ui_Command = L1134_ui_Command - k116_CommandClickInActionAreaChampion_0_Action) < _vm->_championMan->_g305_partyChampionCount) {
+					_vm->_menuMan->f389_processCommands116To119_setActingChampion(L1134_ui_Command);
+				}
+			}
+		}
+	}
+}
 } // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 7ad24a7..24fca0f 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -302,6 +302,7 @@ public:
 	void f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex); // @ F0070_MOUSE_ProcessCommands125To128_ClickOnChampionIcon
 	void f370_commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY); // @ F0370_COMMAND_ProcessType100_ClickInSpellArea
 	void f369_commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType); // @ F0369_COMMAND_ProcessTypes101To108_ClickInSpellSymbolsArea_CPSE
+	void f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY); // @ F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE
 
 };
 
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 49ac924..617735e 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -31,6 +31,8 @@
 #include "movesens.h"
 #include "projexpl.h"
 #include "timeline.h"
+#include "objectman.h"
+#include "menus.h"
 
 
 namespace DM {
@@ -1817,4 +1819,242 @@ bool GroupMan::f223_isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY)
 			|| (L0544_i_SquareType == k5_ElementTypeTeleporter) || (L0544_i_SquareType == k2_ElementTypePit) || (L0544_i_SquareType == k4_DoorElemType));
 }
 
+int16 GroupMan::f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 partyY, uint16 champCell) {
+	uint16 L0321_ui_Counter;
+	int16 L0322_i_CreatureOrdinal;
+	Thing L0323_T_GroupThing;
+	Group* L0324_ps_Group;
+	signed char L0325_auc_OrderedCellsToAttack[4];
+
+
+	if ((L0323_T_GroupThing = _vm->_groupMan->f175_groupGetThing(groupX, groupY)) == Thing::_endOfList) {
+		return 0;
+	}
+	L0324_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0323_T_GroupThing);
+	f229_setOrderedCellsToAttack(L0325_auc_OrderedCellsToAttack, groupX, groupY, partyX, partyY, champCell);
+	L0321_ui_Counter = 0;
+	for (;;) { /*_Infinite loop_*/
+		if (L0322_i_CreatureOrdinal = _vm->_groupMan->f176_getCreatureOrdinalInCell(L0324_ps_Group, L0325_auc_OrderedCellsToAttack[L0321_ui_Counter])) {
+			return L0322_i_CreatureOrdinal;
+		}
+		L0321_ui_Counter++;
+	}
+}
+
+int16 GroupMan::f231_getMeleeActionDamage(Champion* champ, int16 champIndex, Group* group, int16 creatureIndex, int16 mapX, int16 mapXóY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex) {
+	int16 L0565_i_Damage = 0;
+	int16 L0566_i_Damage = 0;
+	int16 L0567_i_DoubledMapDifficulty;
+	int16 L0568_i_Defense;
+	int16 L0569_i_Outcome;
+	bool L0570_B_ActionHitsNonMaterialCreatures;
+	int16 L0571_i_ActionHandObjectIconIndex;
+	CreatureInfo* L0572_ps_CreatureInfo;
+
+	if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
+		return 0;
+	}
+	if (!champ->_currHealth) {
+		return 0;
+	}
+	L0567_i_DoubledMapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty << 1;
+	L0572_ps_CreatureInfo = &g243_CreatureInfo[group->_type];
+	L0571_i_ActionHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
+	if (L0570_B_ActionHitsNonMaterialCreatures = getFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures)) {
+		clearFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
+	}
+	if ((!getFlag(L0572_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) || L0570_B_ActionHitsNonMaterialCreatures) &&
+		((_vm->_championMan->f311_getDexterity(champ) > (_vm->getRandomNumber(32) + L0572_ps_CreatureInfo->_dexterity + L0567_i_DoubledMapDifficulty - 16)) ||
+		(!_vm->getRandomNumber(4)) ||
+		 (_vm->_championMan->f308_isLucky(champ, 75 - actionHitProbability)))) {
+		if (!(L0565_i_Damage = _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand))) {
+			goto T0231009;
+		}
+		L0565_i_Damage += _vm->getRandomNumber((L0565_i_Damage >> 1) + 1);
+		L0565_i_Damage = ((long)L0565_i_Damage * (long)actionDamageFactor) >> 5;
+		L0568_i_Defense = _vm->getRandomNumber(32) + L0572_ps_CreatureInfo->_defense + L0567_i_DoubledMapDifficulty;
+		if (L0571_i_ActionHandObjectIconIndex == k39_IconIndiceWeaponDiamondEdge) {
+			L0568_i_Defense -= L0568_i_Defense >> 2;
+		} else {
+			if (L0571_i_ActionHandObjectIconIndex == k43_IconIndiceWeaponHardcleaveExecutioner) {
+				L0568_i_Defense -= L0568_i_Defense >> 3;
+			}
+		}
+		if ((L0566_i_Damage = L0565_i_Damage = _vm->getRandomNumber(32) + L0565_i_Damage - L0568_i_Defense) <= 1) {
+T0231009:
+			if (!(L0565_i_Damage = _vm->getRandomNumber(4))) {
+				goto T0231015;
+			}
+			L0565_i_Damage++;
+			if (((L0566_i_Damage += _vm->getRandomNumber(16)) > 0) || (_vm->getRandomNumber(2))) {
+				L0565_i_Damage += _vm->getRandomNumber(4);
+				if (!_vm->getRandomNumber(4)) {
+					L0565_i_Damage += MAX(0, L0566_i_Damage + _vm->getRandomNumber(16));
+				}
+			}
+		}
+		L0565_i_Damage >>= 1;
+		L0565_i_Damage += _vm->getRandomNumber(L0565_i_Damage) + _vm->getRandomNumber(4);
+		L0565_i_Damage += _vm->getRandomNumber(L0565_i_Damage);
+		L0565_i_Damage >>= 2;
+		L0565_i_Damage += _vm->getRandomNumber(4) + 1;
+		if ((L0571_i_ActionHandObjectIconIndex == k40_IconIndiceWeaponVorpalBlade) && !getFlag(L0572_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) && !(L0565_i_Damage >>= 1))
+			goto T0231015;
+		if (_vm->getRandomNumber(64) < _vm->_championMan->f303_getSkillLevel(champIndex, skillIndex)) {
+			L0565_i_Damage += L0565_i_Damage + 10;
+		}
+		L0569_i_Outcome = f190_groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapXóY, L0565_i_Damage, true);
+		_vm->_championMan->f304_addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * L0572_ps_CreatureInfo->M58_getExperience() >> 4) + 3);
+		_vm->_championMan->f325_decrementStamine(champIndex, _vm->getRandomNumber(4) + 4);
+		goto T0231016;
+	}
+T0231015:
+	L0565_i_Damage = 0;
+	L0569_i_Outcome = k0_outcomeKilledNoCreaturesInGroup;
+	_vm->_championMan->f325_decrementStamine(champIndex, _vm->getRandomNumber(2) + 2);
+T0231016:
+	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+	if (L0569_i_Outcome != k2_outcomeKilledAllCreaturesInGroup) {
+		f209_processEvents29to41(mapX, mapXóY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
+	}
+	return L0565_i_Damage;
+}
+
+void GroupMan::f224_fluxCageAction(int16 mapX, int16 mapY) {
+	Thing L0545_T_Thing;
+	int16 L0546_i_Multiple;
+#define AL0546_i_SquareType    L0546_i_Multiple
+#define AL0546_i_FluxcageCount L0546_i_Multiple
+	TimelineEvent L0547_s_Event;
+
+
+	if (((AL0546_i_SquareType = _vm->_dungeonMan->f151_getSquare(mapX, mapY).getType()) == k0_ElementTypeWall) || (AL0546_i_SquareType == k3_ElementTypeStairs)) {
+		return;
+	}
+	if ((L0545_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k15_ExplosionThingType)) == Thing::_none) {
+		return;
+	}
+	_vm->_dungeonMan->f163_linkThingToList(L0545_T_Thing, Thing(0), mapX, mapY);
+	(((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[L0545_T_Thing.getIndex()]).setType(k50_ExplosionType_Fluxcage);
+	M33_setMapAndTime(L0547_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + 100);
+	L0547_s_Event._type = k24_TMEventTypeRemoveFluxcage;
+	L0547_s_Event._priority = 0;
+	L0547_s_Event._C._slot = L0545_T_Thing.toUint16();
+	L0547_s_Event._B._location._mapX = mapX;
+	L0547_s_Event._B._location._mapY = mapY;
+	L0547_s_Event._B._location._mapY = mapY;
+	_vm->_timeline->f238_addEventGetEventIndex(&L0547_s_Event);
+	if (f222_isLordChaosOnSquare(mapX, mapY - 1)) {
+		mapY--;
+		AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX + 1, mapY);
+		goto T0224005;
+	}
+	if (f222_isLordChaosOnSquare(mapX - 1, mapY)) {
+		mapX--;
+		AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX, mapY + 1);
+T0224005:
+		AL0546_i_FluxcageCount += f221_isFluxcageOnSquare(mapX, mapY - 1) + f221_isFluxcageOnSquare(mapX - 1, mapY);
+	} else {
+		if (f222_isLordChaosOnSquare(mapX + 1, mapY)) {
+			mapX++;
+			AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX, mapY - 1);
+			goto T0224008;
+		}
+		if (f222_isLordChaosOnSquare(mapX, mapY + 1)) {
+			mapY++;
+			AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX - 1, mapY);
+T0224008:
+			AL0546_i_FluxcageCount += f221_isFluxcageOnSquare(mapX, mapY + 1) + f221_isFluxcageOnSquare(mapX + 1, mapY);
+		} else {
+			AL0546_i_FluxcageCount = 0;
+		}
+	}
+	if (AL0546_i_FluxcageCount == 2) {
+		f209_processEvents29to41(mapX, mapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
+	}
+}
+
+uint16 GroupMan::f222_isLordChaosOnSquare(int16 mapX, int16 mapY) {
+	Thing L0542_T_Thing;
+	Group* L0543_ps_Group;
+
+	if ((L0542_T_Thing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) {
+		return 0;
+	}
+	L0543_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0542_T_Thing);
+	if (L0543_ps_Group->_type == k23_CreatureTypeLordChaos) {
+		return L0542_T_Thing.toUint16();
+	}
+	return 0;
+}
+
+bool GroupMan::f221_isFluxcageOnSquare(int16 mapX, int16 mapY) {
+	Thing L0540_T_Thing;
+	int16 L0541_i_SquareType;
+
+	if (((L0541_i_SquareType = _vm->_dungeonMan->f151_getSquare(mapX, mapY).getType()) == k0_ElementTypeWall) || (L0541_i_SquareType == k3_ElementTypeStairs)) {
+		return false;
+	}
+	L0540_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
+	while (L0540_T_Thing != Thing::_endOfList) {
+		if ((L0540_T_Thing.getType() == k15_ExplosionThingType) && (((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[L0540_T_Thing.getIndex()].getType() == k50_ExplosionType_Fluxcage)) {
+			return true;
+		}
+		L0540_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0540_T_Thing);
+	}
+	return false;
+}
+
+void GroupMan::f225_fuseAction(uint16 mapX, uint16 mapY) {
+	int16 L0548_i_MapX;
+	int16 L0549_i_MapY;
+	uint16 L0551_ui_FluxcageCount;
+	uint16 L0552_ui_FluxcageIndex;
+	uint16 L0553_ui_Counter;
+	bool L0554_aB_Fluxcages[4];
+	Thing L0555_T_LordChaosThing;
+
+	if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight)) {
+		return;
+	}
+
+	_vm->_projexpl->f213_explosionCreate(Thing::_explHarmNonMaterial, 255, mapX, mapY, k255_CreatureTypeSingleCenteredCreature); /* BUG0_17 The game crashes after the Fuse action is performed while looking at a wall on a map boundary. An explosion thing is created on the square in front of the party but there is no check to ensure the square coordinates are in the map bounds. This corrupts a memory location and leads to a game crash */
+	if ((L0555_T_LordChaosThing = Thing(f222_isLordChaosOnSquare(mapX, mapY))).toUint16()) {
+		L0551_ui_FluxcageCount = (L0554_aB_Fluxcages[0] = f221_isFluxcageOnSquare(mapX - 1, mapY)) +
+			(L0554_aB_Fluxcages[1] = f221_isFluxcageOnSquare(mapX + 1, mapY)) +
+			(L0554_aB_Fluxcages[2] = f221_isFluxcageOnSquare(mapX, mapY - 1)) +
+			(L0554_aB_Fluxcages[3] = f221_isFluxcageOnSquare(mapX, mapY + 1));
+		while (L0551_ui_FluxcageCount++ < 4) {
+			L0548_i_MapX = mapX;
+			L0549_i_MapY = mapY;
+			L0552_ui_FluxcageIndex = _vm->getRandomNumber(4);
+			for (L0553_ui_Counter = 5; --L0553_ui_Counter; L0552_ui_FluxcageIndex = returnNextVal(L0552_ui_FluxcageIndex)) {
+				if (!L0554_aB_Fluxcages[L0552_ui_FluxcageIndex]) {
+					L0554_aB_Fluxcages[L0552_ui_FluxcageIndex] = true;
+					switch (L0552_ui_FluxcageIndex) {
+					case 0:
+						L0548_i_MapX--;
+						break;
+					case 1:
+						L0548_i_MapX++;
+						break;
+					case 2:
+						L0549_i_MapY--;
+						break;
+					case 3:
+						L0549_i_MapY++;
+					}
+					break;
+				}
+			}
+			if (f223_isSquareACorridorTeleporterPitOrDoor(L0548_i_MapX, L0549_i_MapY)) {
+				if (!_vm->_movsens->f267_getMoveResult(L0555_T_LordChaosThing, mapX, mapY, L0548_i_MapX, L0549_i_MapY)) {
+					f180_startWanedring(L0548_i_MapX, L0549_i_MapY);
+				}
+				return;
+			}
+		}
+		warning(false, "F0446_STARTEND_FuseSequence()");
+	}
+}
 }
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 242e527..fd7d98a 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -32,6 +32,7 @@
 #include "dm.h"
 
 namespace DM {
+	class Champion;
 	class TimelineEvent;
 	class CreatureInfo;
 
@@ -236,7 +237,14 @@ public:
 	void f195_addAllActiveGroups(); // @ F0195_GROUP_AddAllActiveGroups
 	Thing f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated
 	bool f223_isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY); // @ F0223_GROUP_IsSquareACorridorTeleporterPitOrDoor
-
+	int16 f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 paryY,
+											 uint16 champCell); // @ F0177_GROUP_GetMeleeTargetCreatureOrdinal
+	int16 f231_getMeleeActionDamage(Champion *champ, int16 champIndex, Group *group, int16 creatureIndex,
+									int16 mapX, int16 mapXóY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex); // @ F0231_GROUP_GetMeleeActionDamage
+	void f224_fluxCageAction(int16 mapX, int16 mapY); // @ F0224_GROUP_FluxCageAction
+	uint16 f222_isLordChaosOnSquare(int16 mapX, int16 mapY); // @ F0222_GROUP_IsLordChaosOnSquare
+	bool f221_isFluxcageOnSquare(int16 mapX, int16 mapY); // @ F0221_GROUP_IsFluxcageOnSquare
+	void f225_fuseAction(uint16 mapX, uint16 mapY); // @ F0225_GROUP_FuseAction
 };
 
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index d35ec75..06a286c 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -35,10 +35,59 @@
 #include "eventman.h"
 #include "timeline.h"
 #include "movesens.h"
+#include "group.h"
+#include "projexpl.h"
 
 
 namespace DM {
 
+unsigned char g496_ActionSkillIndex[44] = { // @ G0496_auc_Graphic560_ActionSkillIndex
+	0,  /* N */
+	7,  /* BLOCK */
+	6,  /* CHOP */
+	0,  /* X */
+	14, /* BLOW HORN */
+	12, /* FLIP */
+	9,  /* PUNCH */
+	9,  /* KICK */
+	7,  /* WAR CRY Atari ST Versions 1.0 1987-12-08 1987-12-11 1.1: 14 */
+	9,  /* STAB */
+	8,  /* CLIMB DOWN */
+	14, /* FREEZE LIFE */
+	9,  /* HIT */
+	4,  /* SWING */
+	5,  /* STAB */
+	5,  /* THRUST */
+	5,  /* JAB */
+	7,  /* PARRY */
+	4,  /* HACK */
+	4,  /* BERZERK */
+	16, /* FIREBALL */
+	17, /* DISPELL */
+	14, /* CONFUSE */
+	17, /* LIGHTNING */
+	17, /* DISRUPT */
+	6,  /* MELEE */
+	8,  /* X */
+	3,  /* INVOKE */
+	4,  /* SLASH */
+	4,  /* CLEAVE */
+	6,  /* BASH */
+	6,  /* STUN */
+	11, /* SHOOT */
+	15, /* SPELLSHIELD */
+	15, /* FIRESHIELD */
+	3,  /* FLUXCAGE */
+	13, /* HEAL */
+	14, /* CALM */
+	17, /* LIGHT */
+	18, /* WINDOW */
+	16, /* SPIT */
+	14, /* BRANDISH */
+	10, /* THROW */
+	3}; /* FUSE */
+
+
 Box  g499_BoxActionArea3ActionMenu = Box(224, 319, 77, 121); // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu
 Box  g500_BoxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
 Box  g501_BoxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
@@ -56,6 +105,8 @@ MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
 	_g513_actionDamage = 0;
 	_g713_actionList.resetToZero();
 	_gK72_bitmapSpellAreaLine = new byte[96 * 12];
+	_g517_actionTargetGroupThing = Thing(0);
+	_g507_actionCount = 0;
 }
 
 MenuMan::~MenuMan() {
@@ -813,4 +864,817 @@ void MenuMan::f400_deleteChampionSymbol() {
 	f398_drawChampionSymbols(L1228_ps_Champion);
 	_vm->_eventMan->f77_hideMouse();
 }
+
+bool MenuMan::f391_didClickTriggerAction(int16 actionListIndex) {
+	uint16 L1196_ui_ChampionIndex;
+	uint16 L1197_ui_ActionIndex;
+	bool L1198_B_ClickTriggeredAction;
+	Champion* L1199_ps_Champion;
+
+
+	if (!_vm->_championMan->_g506_actingChampionOrdinal || (actionListIndex != -1 && (_vm->_menuMan->_g713_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone)))
+		return false;
+
+	L1199_ps_Champion = &_vm->_championMan->_gK71_champions[L1196_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)];
+	if (actionListIndex == -1) {
+		warning(false, "possible bug in f391_didClickTriggerAction");
+		// L1198_B_ClickTriggeredAction is set to -1 since booleans are stored in int16 in the original
+		L1198_B_ClickTriggeredAction = true;
+	} else {
+		L1197_ui_ActionIndex = _vm->_menuMan->_g713_actionList._actionIndices[actionListIndex];
+		L1199_ps_Champion->_actionDefense += g495_actionDefense[L1197_ui_ActionIndex]; /* BUG0_54 The defense modifier of an action is permanent.
+																									 Each action has an associated defense modifier value and a number of ticks while the champion cannot perform another action because the action icon is grayed out. If an action has a non zero defense modifier and a zero value for the number of ticks then the defense modifier is applied but it is never removed. This causes no issue in the original games because there are no actions in this case but it may occur in a version where data is customized. This statement should only be executed if the value for the action in G0491_auc_Graphic560_ActionDisabledTicks is not 0 otherwise the action is not disabled at the end of F0407_MENUS_IsActionPerformed and thus not enabled later in F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction where the defense modifier is also removed */
+		setFlag(L1199_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+		L1198_B_ClickTriggeredAction = f407_isActionPerformed(L1196_ui_ChampionIndex, L1197_ui_ActionIndex);
+		L1199_ps_Champion->_actionIndex = (ChampionAction)L1197_ui_ActionIndex;
+	}
+	_vm->_menuMan->f388_clearActingChampion();
+	return L1198_B_ClickTriggeredAction;
+}
+
+bool MenuMan::f407_isActionPerformed(uint16 champIndex, int16 actionIndex) {
+	static unsigned char G0491_auc_Graphic560_ActionDisabledTicks[44] = {
+		0,  /* N */
+		6,  /* BLOCK */
+		8,  /* CHOP */
+		0,  /* X */
+		6,  /* BLOW HORN */
+		3,  /* FLIP */
+		1,  /* PUNCH */
+		5,  /* KICK */
+		3,  /* WAR CRY */
+		5,  /* STAB */
+		35, /* CLIMB DOWN */
+		20, /* FREEZE LIFE */
+		4,  /* HIT */
+		6,  /* SWING */
+		10, /* STAB */
+		16, /* THRUST */
+		2,  /* JAB */
+		18, /* PARRY */
+		8,  /* HACK */
+		30, /* BERZERK */
+		42, /* FIREBALL */
+		31, /* DISPELL */
+		10, /* CONFUSE */
+		38, /* LIGHTNING */
+		9,  /* DISRUPT */
+		20, /* MELEE */
+		10, /* X */
+		16, /* INVOKE */
+		4,  /* SLASH */
+		12, /* CLEAVE */
+		20, /* BASH */
+		7,  /* STUN */
+		14, /* SHOOT */
+		30, /* SPELLSHIELD */
+		35, /* FIRESHIELD */
+		2,  /* FLUXCAGE */
+		19, /* HEAL */
+		9,  /* CALM */
+		10, /* LIGHT */
+		15, /* WINDOW */
+		22, /* SPIT */
+		10, /* BRANDISH */
+		0,  /* THROW */
+		2}; /* FUSE */
+	static unsigned char G0494_auc_Graphic560_ActionStamina[44] = {
+		0,  /* N */
+		4,  /* BLOCK */
+		10, /* CHOP */
+		0,  /* X */
+		1,  /* BLOW HORN */
+		0,  /* FLIP */
+		1,  /* PUNCH */
+		3,  /* KICK */
+		1,  /* WAR CRY */
+		3,  /* STAB */
+		40, /* CLIMB DOWN */
+		3,  /* FREEZE LIFE */
+		3,  /* HIT */
+		2,  /* SWING */
+		4,  /* STAB */
+		17, /* THRUST */
+		3,  /* JAB */
+		1,  /* PARRY */
+		6,  /* HACK */
+		40, /* BERZERK */
+		5,  /* FIREBALL */
+		2,  /* DISPELL */
+		2,  /* CONFUSE */
+		4,  /* LIGHTNING */
+		5,  /* DISRUPT */
+		25, /* MELEE */
+		1,  /* X */
+		2,  /* INVOKE */
+		2,  /* SLASH */
+		10, /* CLEAVE */
+		9,  /* BASH */
+		2,  /* STUN */
+		3,  /* SHOOT */
+		1,  /* SPELLSHIELD */
+		2,  /* FIRESHIELD */
+		6,  /* FLUXCAGE */
+		1,  /* HEAL */
+		1,  /* CALM */
+		3,  /* LIGHT */
+		2,  /* WINDOW */
+		3,  /* SPIT */
+		2,  /* BRANDISH */
+		0,  /* THROW */
+		2}; /* FUSE */
+	unsigned char G0497_auc_Graphic560_ActionExperienceGain[44] = {
+		0,  /* N */
+		8,  /* BLOCK */
+		10, /* CHOP */
+		0,  /* X */
+		0,  /* BLOW HORN */
+		0,  /* FLIP */
+		8,  /* PUNCH */
+		13, /* KICK */
+		7,  /* WAR CRY */
+		15, /* STAB */
+		15, /* CLIMB DOWN */
+		22, /* FREEZE LIFE */
+		10, /* HIT */
+		6,  /* SWING */
+		12, /* STAB */
+		19, /* THRUST */
+		11, /* JAB */
+		17, /* PARRY */
+		9,  /* HACK */
+		40, /* BERZERK */
+		35, /* FIREBALL */
+		25, /* DISPELL */
+		0,  /* CONFUSE */
+		30, /* LIGHTNING */
+		10, /* DISRUPT */
+		24, /* MELEE */
+		0,  /* X */
+		25, /* INVOKE */
+		9,  /* SLASH */
+		12, /* CLEAVE */
+		11, /* BASH */
+		10, /* STUN */
+		20, /* SHOOT Atari ST Versions 1.0 1987-12-08 1987-12-11: 9 */
+		20, /* SPELLSHIELD */
+		20, /* FIRESHIELD */
+		12, /* FLUXCAGE */
+		0,  /* HEAL */
+		0,  /* CALM */
+		20, /* LIGHT */
+		30, /* WINDOW */
+		25, /* SPIT */
+		0,  /* BRANDISH */
+		5,  /* THROW */
+		1}; /* FUSE */
+	uint16 L1244_ui_Multiple;
+#define AL1244_ui_TargetSquare  L1244_ui_Multiple
+#define AL1244_ui_HealingAmount L1244_ui_Multiple
+#define AL1244_ui_ManaCost      L1244_ui_Multiple
+	int16 L1245_i_Multiple;
+#define AL1245_T_ExplosionThing  L1245_i_Multiple
+#define AL1245_B_ActionPerformed L1245_i_Multiple
+	int16 L1246_i_Multiple;
+#define AL1246_i_RequiredManaAmount    L1246_i_Multiple
+#define AL1246_i_ActionHandWeaponClass L1246_i_Multiple
+#define AL1246_i_StepEnergy            L1246_i_Multiple
+#define AL1246_i_HealingCapability     L1246_i_Multiple
+#define AL1246_i_Ticks                 L1246_i_Multiple
+	Champion* L1247_ps_Champion;
+	Weapon* L1248_ps_Weapon;
+	uint16 L1249_ui_ActionDisabledTicks;
+	int16 L1250_i_Multiple;
+#define AL1250_i_KineticEnergy        L1250_i_Multiple
+#define AL1250_i_ReadyHandWeaponClass L1250_i_Multiple
+#define AL1250_i_MissingHealth        L1250_i_Multiple
+#define AL1250_i_HealingAmount        L1250_i_Multiple
+	int16 L1251_i_MapX;
+	int16 L1252_i_MapY;
+	int16 L1253_i_ActionStamina;
+	int16 L1254_i_ActionSkillIndex;
+	int16 L1255_i_ActionExperienceGain;
+	WeaponInfo* L1256_ps_WeaponInfoActionHand;
+	WeaponInfo* L1257_ps_WeaponInfoReadyHand;
+	TimelineEvent L1258_s_Event;
+
+
+	if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
+		return false;
+	}
+	L1247_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	L1248_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L1247_ps_Champion->_slots[k1_ChampionSlotActionHand]);
+	if (!L1247_ps_Champion->_currHealth) {
+		return false;
+	}
+	L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
+	L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+	L1251_i_MapX += _vm->_dirIntoStepCountEast[L1247_ps_Champion->_dir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[L1247_ps_Champion->_dir];
+	_g517_actionTargetGroupThing = _vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY);
+	L1249_ui_ActionDisabledTicks = G0491_auc_Graphic560_ActionDisabledTicks[actionIndex];
+	L1254_i_ActionSkillIndex = g496_ActionSkillIndex[actionIndex];
+	L1253_i_ActionStamina = G0494_auc_Graphic560_ActionStamina[actionIndex] + _vm->getRandomNumber(2);
+	L1255_i_ActionExperienceGain = G0497_auc_Graphic560_ActionExperienceGain[actionIndex];
+	AL1244_ui_TargetSquare = _vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).toByte();
+	AL1245_B_ActionPerformed = true;
+	if (((L1254_i_ActionSkillIndex >= k16_ChampionSkillFire) && (L1254_i_ActionSkillIndex <= k19_ChampionSkillWater)) || (L1254_i_ActionSkillIndex == k3_ChampionSkillWizard)) {
+		AL1246_i_RequiredManaAmount = 7 - MIN((uint16)6, _vm->_championMan->f303_getSkillLevel(champIndex, L1254_i_ActionSkillIndex));
+	}
+	switch (actionIndex) {
+	case k23_ChampionActionLightning:
+		AL1250_i_KineticEnergy = 180;
+		AL1245_T_ExplosionThing = Thing::_explLightningBolt.toUint16();
+		goto T0407014;
+	case k21_ChampionActionDispel:
+		AL1250_i_KineticEnergy = 150;
+		AL1245_T_ExplosionThing = Thing::_explHarmNonMaterial.toUint16();
+		goto T0407014;
+	case k20_ChampionActionFireball:
+		AL1250_i_KineticEnergy = 150;
+		goto T0407013;
+	case k40_ChampionActionSpit:
+		AL1250_i_KineticEnergy = 250;
+T0407013:
+		AL1245_T_ExplosionThing = Thing::_explFireBall.toUint16();
+T0407014:
+		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+		if (L1247_ps_Champion->_currMana < AL1246_i_RequiredManaAmount) {
+			AL1250_i_KineticEnergy = MAX(2, L1247_ps_Champion->_currMana * AL1250_i_KineticEnergy / AL1246_i_RequiredManaAmount);
+			AL1246_i_RequiredManaAmount = L1247_ps_Champion->_currMana;
+		}
+		if (!(AL1245_B_ActionPerformed = _vm->_championMan->f327_isProjectileSpellCast(champIndex, Thing(AL1245_T_ExplosionThing), AL1250_i_KineticEnergy, AL1246_i_RequiredManaAmount))) {
+			L1255_i_ActionExperienceGain >>= 1;
+		}
+		f405_decrementCharges(L1247_ps_Champion);
+		break;
+	case k30_ChampionActionBash:
+	case k18_ChampionActionHack:
+	case k19_ChampionActionBerzerk:
+	case k7_ChampionActionKick:
+	case k13_ChampionActionSwing:
+	case k2_ChampionActionChop:
+		if ((Square(AL1244_ui_TargetSquare).getType() == k4_DoorElemType) && (Square(AL1244_ui_TargetSquare).getDoorState() == k4_doorState_CLOSED)) {
+			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			L1249_ui_ActionDisabledTicks = 6;
+			_vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
+			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			break;
+		}
+	case k24_ChampionActionDisrupt:
+	case k16_ChampionActionJab:
+	case k17_ChampionActionParry:
+	case k14_ChampionActionStab_C014:
+	case k9_ChampionActionStab_C009:
+	case k31_ChampionActionStun:
+	case k15_ChampionActionThrust:
+	case k25_ChampionActionMelee:
+	case k28_ChampionActionSlash:
+	case k29_ChampionActionCleave:
+	case k6_ChampionActionPunch:
+		if (!(AL1245_B_ActionPerformed = f402_isMeleeActionPerformed(champIndex, L1247_ps_Champion, actionIndex, L1251_i_MapX, L1252_i_MapY, L1254_i_ActionSkillIndex))) {
+			L1255_i_ActionExperienceGain >>= 1;
+			L1249_ui_ActionDisabledTicks >>= 1;
+		}
+		break;
+	case k22_ChampionActionConfuse:
+		f405_decrementCharges(L1247_ps_Champion);
+	case k8_ChampionActionWarCry:
+	case k37_ChampionActionCalm:
+	case k41_ChampionActionBrandish:
+	case k4_ChampionActionBlowHorn:
+		if (actionIndex == k8_ChampionActionWarCry) {
+			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+		}
+		if (actionIndex == k4_ChampionActionBlowHorn) {
+			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+		}
+		AL1245_B_ActionPerformed = f401_isGroupFrightenedByAction(champIndex, actionIndex, L1251_i_MapX, L1252_i_MapY);
+		break;
+	case k32_ChampionActionShoot:
+		if (Thing(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]).getType() != k5_WeaponThingType)
+			goto T0407032;
+		L1256_ps_WeaponInfoActionHand = &g238_WeaponInfo[L1248_ps_Weapon->getType()];
+		L1257_ps_WeaponInfoReadyHand = _vm->_dungeonMan->f158_getWeaponInfo(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]);
+		AL1246_i_ActionHandWeaponClass = L1256_ps_WeaponInfoActionHand->_class;
+		AL1250_i_ReadyHandWeaponClass = L1257_ps_WeaponInfoReadyHand->_class;
+		if ((AL1246_i_ActionHandWeaponClass >= k16_WeaponClassFirstBow) && (AL1246_i_ActionHandWeaponClass <= k31_WeaponClassLastBow)) {
+			if (AL1250_i_ReadyHandWeaponClass != k10_WeaponClassBowAmmunition)
+				goto T0407032;
+			AL1246_i_StepEnergy -= k16_WeaponClassFirstBow;
+		} else {
+			if ((AL1246_i_ActionHandWeaponClass >= k32_WeaponClassFirstSling) && (AL1246_i_ActionHandWeaponClass <= k47_WeaponClassLastSling)) {
+				if (AL1250_i_ReadyHandWeaponClass != k11_WeaponClassSlingAmmunition) {
+T0407032:
+					_vm->_menuMan->_g513_actionDamage = kM2_damageNoAmmunition;
+					L1255_i_ActionExperienceGain = 0;
+					AL1245_B_ActionPerformed = false;
+					break;
+				}
+				AL1246_i_StepEnergy -= k32_WeaponClassFirstSling;
+			}
+		}
+		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+		{ // so gotos won't skip init
+			Thing AL1250_T_Object = _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
+			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			_vm->_championMan->f326_championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->f303_getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy);
+		}
+		break;
+	case k5_ChampionActionFlip:
+		// TODO: localization
+		if (_vm->getRandomNumber(2)) {
+			f381_printMessageAfterReplacements("IT COMES UP HEADS.");
+		} else {
+			f381_printMessageAfterReplacements("IT COMES UP TAILS.");
+		}
+		break;
+	case k33_ChampionActionSpellshield:
+	case k34_ChampionActionFireshield:
+		if (!f403_isPartySpellOrFireShieldSuccessful(L1247_ps_Champion, actionIndex == k33_ChampionActionSpellshield, 280, true)) {
+			L1255_i_ActionExperienceGain >>= 2;
+			L1249_ui_ActionDisabledTicks >>= 1;
+		} else {
+			f405_decrementCharges(L1247_ps_Champion);
+		}
+		break;
+	case k27_ChampionActionInvoke:
+		AL1250_i_KineticEnergy = _vm->getRandomNumber(128) + 100;
+		switch (_vm->getRandomNumber(6)) {
+		case 0:
+			AL1245_T_ExplosionThing = Thing::_explPoisonBolt.toUint16();
+			goto T0407014;
+		case 1:
+			AL1245_T_ExplosionThing = Thing::_explPoisonCloud.toUint16();
+			goto T0407014;
+		case 2:
+			AL1245_T_ExplosionThing = Thing::_explHarmNonMaterial.toUint16();
+			goto T0407014;
+		default:
+			goto T0407013;
+		}
+	case k35_ChampionActionFluxcage:
+		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+		_vm->_groupMan->f224_fluxCageAction(L1251_i_MapX, L1252_i_MapY);
+		break;
+	case k43_ChampionActionFuse:
+		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+		L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
+		L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+		_vm->_groupMan->f225_fuseAction(L1251_i_MapX, L1252_i_MapY);
+		break;
+	case k36_ChampionActionHeal:
+		/* CHANGE2_17_IMPROVEMENT Heal action is much more effective
+		Heal cycles occur as long as the champion has missing health and enough mana. Cycle count = Min(Current Mana / 2, Missing health / Min(10, Heal skill level))
+		Healing amount is Min(Missing health, Min(10, Heal skill level)) * heal cycle count
+		Mana cost is 2 * heal cycle count
+		Experience gain is 2 + 2 * heal cycle count */
+		if (((AL1250_i_MissingHealth = L1247_ps_Champion->_maxHealth - L1247_ps_Champion->_currHealth) > 0) && L1247_ps_Champion->_currMana) {
+			AL1246_i_HealingCapability = MIN((uint16)10, _vm->_championMan->f303_getSkillLevel(champIndex, k13_ChampionSkillHeal));
+			L1255_i_ActionExperienceGain = 2;
+			do {
+				AL1244_ui_HealingAmount = MIN(AL1250_i_MissingHealth, AL1246_i_HealingCapability);
+				L1247_ps_Champion->_currHealth += AL1244_ui_HealingAmount;
+				L1255_i_ActionExperienceGain += 2;
+			} while (((L1247_ps_Champion->_currMana = L1247_ps_Champion->_currMana - 2) > 0) && (AL1250_i_MissingHealth = AL1250_i_MissingHealth - AL1244_ui_HealingAmount));
+			if (L1247_ps_Champion->_currMana < 0) {
+				L1247_ps_Champion->_currMana = 0;
+			}
+			setFlag(L1247_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+			AL1245_B_ActionPerformed = true;
+		}
+		break;
+	case k39_ChampionActionWindow:
+		AL1246_i_Ticks = _vm->getRandomNumber(_vm->_championMan->f303_getSkillLevel(champIndex, L1254_i_ActionSkillIndex) + 8) + 5;
+		L1258_s_Event._priority = 0;
+		L1258_s_Event._type = k73_TMEventTypeThievesEye;
+		M33_setMapAndTime(L1258_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + AL1246_i_Ticks);
+		_vm->_timeline->f238_addEventGetEventIndex(&L1258_s_Event);
+		_vm->_championMan->_g407_party._event73Count_ThievesEye++;
+		goto T0407076;
+	case k10_ChampionActionClimbDown:
+		L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
+		L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+		/* CHANGE6_00_FIX The presence of a group over the pit is checked so that you cannot climb down a pit with the rope if there is a group levitating over it */
+		if ((_vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_ElementTypePit) && (_vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY) == Thing::_endOfList)) {
+			/* BUG0_77 The party moves forward when using the rope in front of a closed pit. The engine does not check whether the pit is open before moving the party over the pit. This is not consistent with the behavior when using the rope in front of a corridor where nothing happens */
+			_vm->_movsens->_g402_useRopeToClimbDownPit = true;
+			_vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1251_i_MapX, L1252_i_MapY);
+			_vm->_movsens->_g402_useRopeToClimbDownPit = false;
+		} else {
+			L1249_ui_ActionDisabledTicks = 0;
+		}
+		break;
+	case k11_ChampionActionFreezeLife:
+		if (L1248_ps_Weapon->getType() == k42_JunkTypeMagicalBoxBlue) {
+			AL1246_i_Ticks = 30;
+			goto T0407071;
+		}
+		if (L1248_ps_Weapon->getType() == k43_JunkTypeMagicalBoxGreen) {
+			AL1246_i_Ticks = 125;
+T0407071:
+			_vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k1_ChampionSlotActionHand);
+			L1248_ps_Weapon->setNextThing(Thing::_none);
+		} else {
+			AL1246_i_Ticks = 70;
+			f405_decrementCharges(L1247_ps_Champion);
+		}
+		_vm->_championMan->_g407_party._freezeLifeTicks = MIN(200, _vm->_championMan->_g407_party._freezeLifeTicks + AL1246_i_Ticks);
+		break;
+	case k38_ChampionActionLight:
+		_vm->_championMan->_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2];
+		f404_createEvent70_light(-2, 2500);
+T0407076:
+		f405_decrementCharges(L1247_ps_Champion);
+		break;
+	case k42_ChampionActionThrow:
+		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+		if (AL1245_B_ActionPerformed = _vm->_championMan->f328_isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_g308_partyDir)) || (L1247_ps_Champion->_cell == returnOppositeDir(_vm->_dungeonMan->_g308_partyDir)))) {
+			_vm->_timeline->_g370_events[L1247_ps_Champion->_enableActionEventIndex]._B._slotOrdinal = _vm->M0_indexToOrdinal(k1_ChampionSlotActionHand);
+		}
+	}
+	if (L1249_ui_ActionDisabledTicks) {
+		_vm->_championMan->f330_disableAction(champIndex, L1249_ui_ActionDisabledTicks);
+	}
+	if (L1253_i_ActionStamina) {
+		_vm->_championMan->f325_decrementStamine(champIndex, L1253_i_ActionStamina);
+	}
+	if (L1255_i_ActionExperienceGain) {
+		_vm->_championMan->f304_addSkillExperience(champIndex, L1254_i_ActionSkillIndex, L1255_i_ActionExperienceGain);
+	}
+	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+	return AL1245_B_ActionPerformed;
+}
+
+void MenuMan::f406_setChampionDirectionToPartyDirection(Champion* champ) {
+	if (champ->_dir != _vm->_dungeonMan->_g308_partyDir) {
+		champ->_dir = _vm->_dungeonMan->_g308_partyDir;
+		setFlag(champ->_attributes, k0x0400_ChampionAttributeIcon);
+	}
+}
+
+void MenuMan::f405_decrementCharges(Champion* champ) {
+	Thing L1242_T_Thing;
+	Junk* L1243_ps_Junk;
+
+	L1243_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1242_T_Thing = champ->_slots[k1_ChampionSlotActionHand]);
+	switch (L1242_T_Thing.getType()) {
+	case k5_WeaponThingType:
+		if (((Weapon*)L1243_ps_Junk)->getChargeCount()) {
+			((Weapon*)L1243_ps_Junk)->setChargeCount(((Weapon*)L1243_ps_Junk)->getChargeCount() - 1);
+		}
+		break;
+	case k6_ArmourThingType:
+		if (((Armour*)L1243_ps_Junk)->getChargeCount()) {
+			((Armour*)L1243_ps_Junk)->setChargeCount(((Armour*)L1243_ps_Junk)->getChargeCount() - 1);
+		}
+		break;
+	case k10_JunkThingType:
+		if (L1243_ps_Junk->getChargeCount()) {
+			L1243_ps_Junk->setChargeCount(L1243_ps_Junk->getChargeCount() - 1);
+		}
+	}
+	_vm->_championMan->f296_drawChangedObjectIcons();
+}
+
+bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int16 actionIndex, int16 targetMapX, int16 targetMapY, int16 skillIndex) {
+	static unsigned char G0492_auc_Graphic560_ActionDamageFactor[44] = {
+		0,  /* N */
+		15, /* BLOCK */
+		48, /* CHOP */
+		0,  /* X */
+		0,  /* BLOW HORN */
+		0,  /* FLIP */
+		32, /* PUNCH */
+		48, /* KICK */
+		0,  /* WAR CRY */
+		48, /* STAB */
+		0,  /* CLIMB DOWN */
+		0,  /* FREEZE LIFE */
+		20, /* HIT */
+		16, /* SWING */
+		60, /* STAB */
+		66, /* THRUST */
+		8,  /* JAB */
+		8,  /* PARRY */
+		25, /* HACK */
+		96, /* BERZERK */
+		0,  /* FIREBALL */
+		0,  /* DISPELL */
+		0,  /* CONFUSE */
+		0,  /* LIGHTNING */
+		55, /* DISRUPT */
+		60, /* MELEE */
+		0,  /* X */
+		0,  /* INVOKE */
+		16, /* SLASH */
+		48, /* CLEAVE */
+		50, /* BASH */
+		16, /* STUN */
+		0,  /* SHOOT */
+		0,  /* SPELLSHIELD */
+		0,  /* FIRESHIELD */
+		0,  /* FLUXCAGE */
+		0,  /* HEAL */
+		0,  /* CALM */
+		0,  /* LIGHT */
+		0,  /* WINDOW */
+		0,  /* SPIT */
+		0,  /* BRANDISH */
+		0,  /* THROW */
+		0}; /* FUSE */
+	static unsigned char G0493_auc_Graphic560_ActionHitProbability[44] = {
+		0,  /* N */
+		22, /* BLOCK */
+		48, /* CHOP */
+		0,  /* X */
+		0,  /* BLOW HORN */
+		0,  /* FLIP */
+		38, /* PUNCH */
+		28, /* KICK */
+		0,  /* WAR CRY */
+		30, /* STAB */
+		0,  /* CLIMB DOWN */
+		0,  /* FREEZE LIFE */
+		20, /* HIT */
+		32, /* SWING */
+		42, /* STAB */
+		57, /* THRUST */
+		70, /* JAB */
+		18, /* PARRY */
+		27, /* HACK */
+		46, /* BERZERK */
+		0,  /* FIREBALL */
+		0,  /* DISPELL */
+		0,  /* CONFUSE */
+		0,  /* LIGHTNING */
+		46, /* DISRUPT */
+		64, /* MELEE */
+		0,  /* X */
+		0,  /* INVOKE */
+		26, /* SLASH */
+		40, /* CLEAVE */
+		32, /* BASH */
+		50, /* STUN */
+		0,  /* SHOOT */
+		0,  /* SPELLSHIELD */
+		0,  /* FIRESHIELD */
+		0,  /* FLUXCAGE */
+		0,  /* HEAL */
+		0,  /* CALM */
+		0,  /* LIGHT */
+		0,  /* WINDOW */
+		0,  /* SPIT */
+		0,  /* BRANDISH */
+		0,  /* THROW */
+		0}; /* FUSE */
+
+	uint16 L1236_ui_Multiple;
+#define AL1236_ui_ChampionCell       L1236_ui_Multiple
+#define AL1236_ui_ActionDamageFactor L1236_ui_Multiple
+	uint16 L1237_ui_Multiple;
+#define AL1237_ui_Direction            L1237_ui_Multiple
+#define AL1237_ui_CellDelta            L1237_ui_Multiple
+#define AL1237_ui_ActionHitProbability L1237_ui_Multiple
+	int16 L1238_i_CreatureOrdinal;
+
+
+	warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+	if (_g517_actionTargetGroupThing == Thing::_endOfList)
+		goto T0402010;
+	if (L1238_i_CreatureOrdinal = _vm->_groupMan->f177_getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, AL1236_ui_ChampionCell = champ->_cell)) {
+		switch (M21_normalizeModulo4(AL1236_ui_ChampionCell + 4 - champ->_dir)) {
+		case k2_ViewCellBackRight: /* Champion is on the back right of the square and tries to attack a creature in the front right of its square */
+			AL1237_ui_CellDelta = 3;
+			goto T0402005;
+		case k3_ViewCellBackLeft: /* Champion is on the back left of the square and tries to attack a creature in the front left of its square */
+			AL1237_ui_CellDelta = 1;
+T0402005: /* Check if there is another champion in front */
+			if (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL1236_ui_ChampionCell + AL1237_ui_CellDelta)) != kM1_ChampionNone) {
+				_vm->_menuMan->_g513_actionDamage = kM1_damageCantReach;
+				goto T0402010;
+			}
+		}
+		if ((actionIndex == k24_ChampionActionDisrupt) && !getFlag(_vm->_dungeonMan->f144_getCreatureAttributes(_g517_actionTargetGroupThing), k0x0040_MaskCreatureInfo_nonMaterial))
+			goto T0402010;
+		AL1237_ui_ActionHitProbability = G0493_auc_Graphic560_ActionHitProbability[actionIndex];
+		AL1236_ui_ActionDamageFactor = G0492_auc_Graphic560_ActionDamageFactor[actionIndex];
+		if ((_vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
+			setFlag(AL1237_ui_ActionHitProbability, k0x8000_hitNonMaterialCreatures);
+		}
+		_vm->_menuMan->_g513_actionDamage = _vm->_groupMan->f231_getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing), _vm->M1_ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
+		return true;
+	}
+T0402010:
+	return false;
+}
+
+bool MenuMan::f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, int16 mapX, int16 mapY) {
+	int16 L1229_i_FrightAmount = 0;
+	uint16 L1230_ui_FearResistance;
+	uint16 L1231_ui_Experience = 0;
+	bool L1232_B_IsGroupFrightenedByAction;
+	Group* L1233_ps_Group;
+	CreatureInfo* L1234_ps_CreatureInfo;
+	ActiveGroup* L1235_ps_ActiveGroup;
+
+
+	L1232_B_IsGroupFrightenedByAction = false;
+	if (_g517_actionTargetGroupThing == Thing::_endOfList)
+		goto T0401016;
+	switch (actionIndex) {
+	case k8_ChampionActionWarCry:
+		L1229_i_FrightAmount = 3;
+		L1231_ui_Experience = 12; /* War Cry gives experience in priest skill k14_ChampionSkillInfluence below. The War Cry action also has an experience gain of 7 defined in G0497_auc_Graphic560_ActionExperienceGain in the same skill (versions 1.1 and below) or in the fighter skill k7_ChampionSkillParry (versions 1.2 and above). In versions 1.2 and above, this is the only action that gives experience in two skills */
+		break;
+	case k37_ChampionActionCalm:
+		L1229_i_FrightAmount = 7;
+		L1231_ui_Experience = 35;
+		break;
+	case k41_ChampionActionBrandish:
+		L1229_i_FrightAmount = 6;
+		L1231_ui_Experience = 30;
+		break;
+	case k4_ChampionActionBlowHorn:
+		L1229_i_FrightAmount = 6;
+		L1231_ui_Experience = 20;
+		break;
+	case k22_ChampionActionConfuse:
+		L1229_i_FrightAmount = 12;
+		L1231_ui_Experience = 45;
+	}
+	L1229_i_FrightAmount += _vm->_championMan->f303_getSkillLevel(champIndex, k14_ChampionSkillInfluence);
+	L1233_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing);
+	L1234_ps_CreatureInfo = &g243_CreatureInfo[L1233_ps_Group->_type];
+	if (((L1230_ui_FearResistance = L1234_ps_CreatureInfo->M57_getFearResistance()) > _vm->getRandomNumber(L1229_i_FrightAmount)) || (L1230_ui_FearResistance == k15_immuneToFear)) {
+		L1231_ui_Experience >>= 1;
+	} else {
+		L1235_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[L1233_ps_Group->getActiveGroupIndex()];
+		if (L1233_ps_Group->getBehaviour() == k6_behavior_ATTACK) {
+			_vm->_groupMan->f182_stopAttacking(L1235_ps_ActiveGroup, mapX, mapY);
+			_vm->_groupMan->f180_startWanedring(mapX, mapY);
+		}
+		L1233_ps_Group->setBehaviour(k5_behavior_FLEE);
+		L1235_ps_ActiveGroup->_delayFleeingFromTarget = ((16 - L1230_ui_FearResistance) << 2) / L1234_ps_CreatureInfo->_movementTicks;
+		L1232_B_IsGroupFrightenedByAction = true;
+	}
+	_vm->_championMan->f304_addSkillExperience(champIndex, k14_ChampionSkillInfluence, L1231_ui_Experience);
+T0401016:
+	return L1232_B_IsGroupFrightenedByAction;
+}
+
+void MenuMan::f381_printMessageAfterReplacements(char* str) {
+	char* L1164_pc_Character;
+	char* L1165_pc_ReplacementString;
+	char L1166_ac_OutputString[128];
+
+
+	L1164_pc_Character = L1166_ac_OutputString;
+	*L1164_pc_Character++ = '\n'; /* New line */
+	do {
+		if (*str == '@') {
+			str++;
+			if (*(L1164_pc_Character - 1) != '\n') { /* New line */
+				*L1164_pc_Character++ = ' ';
+			}
+			switch (*str) {
+			case 'p': /* '@p' in the source string is replaced by the champion name followed by a space */
+				L1165_pc_ReplacementString = _vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)]._name;
+			}
+			*L1164_pc_Character = '\0';
+			strcat(L1166_ac_OutputString, L1165_pc_ReplacementString);
+			L1164_pc_Character += strlen(L1165_pc_ReplacementString);
+			*L1164_pc_Character++ = ' ';
+		} else {
+			*L1164_pc_Character++ = *str;
+		}
+	} while (*str++);
+	*L1164_pc_Character = '\0';
+	if (L1166_ac_OutputString[1]) { /* If the string is not empty (the first character is a new line \n) */
+		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, L1166_ac_OutputString);
+	}
+}
+
+void MenuMan::f389_processCommands116To119_setActingChampion(uint16 champIndex) {
+	static ActionSet G0489_as_Graphic560_ActionSets[44] = {
+		/* { ActionIndices[0], ActionIndices[1], ActionIndices[2], ActionProperties[0], ActionProperties[1], Useless } */
+		ActionSet(255, 255, 255, 0x00, 0x00),
+		ActionSet(27,  43,  35, 0x00, 0x00),
+		ActionSet(6,   7,   8, 0x00, 0x00),
+		ActionSet(0,   0,   0, 0x00, 0x00),
+		ActionSet(0,   0,   0, 0x00, 0x00),
+		ActionSet(13, 255, 255, 0x00, 0x00),
+		ActionSet(13,  20, 255, 0x87, 0x00),
+		ActionSet(13,  23, 255, 0x83, 0x00),
+		ActionSet(28,  41,  22, 0x02, 0x83),
+		ActionSet(16,   2,  23, 0x00, 0x84),
+		ActionSet(2,  25,  20, 0x02, 0x86),
+		ActionSet(17,  41,  34, 0x03, 0x05),
+		ActionSet(42,   9,  28, 0x00, 0x02),
+		ActionSet(13,  17,   2, 0x02, 0x03),
+		ActionSet(16,  17,  15, 0x01, 0x05),
+		ActionSet(28,  17,  25, 0x01, 0x05),
+		ActionSet(2,  25,  15, 0x05, 0x06),
+		ActionSet(9,   2,  29, 0x02, 0x05),
+		ActionSet(16,  29,  24, 0x02, 0x04),
+		ActionSet(13,  15,  19, 0x05, 0x07),
+		ActionSet(13,   2,  25, 0x00, 0x05),
+		ActionSet(2,  29,  19, 0x03, 0x08),
+		ActionSet(13,  30,  31, 0x02, 0x04),
+		ActionSet(13,  31,  25, 0x03, 0x06),
+		ActionSet(42,  30, 255, 0x00, 0x00),
+		ActionSet(0,   0,   0, 0x00, 0x00),
+		ActionSet(42,   9, 255, 0x00, 0x00),
+		ActionSet(32, 255, 255, 0x00, 0x00),
+		ActionSet(37,  33,  36, 0x82, 0x03),
+		ActionSet(37,  33,  34, 0x83, 0x84),
+		ActionSet(17,  38,  21, 0x80, 0x83),
+		ActionSet(13,  21,  34, 0x83, 0x84),
+		ActionSet(36,  37,  41, 0x02, 0x03),
+		ActionSet(13,  23,  39, 0x82, 0x84),
+		ActionSet(13,  17,  40, 0x00, 0x83),
+		ActionSet(17,  36,  38, 0x03, 0x84),
+		ActionSet(4, 255, 255, 0x00, 0x00),
+		ActionSet(5, 255, 255, 0x00, 0x00),
+		ActionSet(11, 255, 255, 0x00, 0x00),
+		ActionSet(10, 255, 255, 0x00, 0x00),
+		ActionSet(42,   9, 255, 0x00, 0x00),
+		ActionSet(1,  12, 255, 0x02, 0x00),
+		ActionSet(42, 255, 255, 0x00, 0x00),
+		ActionSet(6,  11, 255, 0x80, 0x00)};
+	uint16 L1188_ui_ActionSetIndex;
+	Thing L1189_T_Thing;
+	Champion* L1190_ps_Champion;
+	ActionSet* L1191_ps_ActionSet;
+
+
+	L1190_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	if (getFlag(L1190_ps_Champion->_attributes, k0x0008_ChampionAttributeDisableAction) || !L1190_ps_Champion->_currHealth) {
+		return;
+	}
+	if ((L1189_T_Thing = L1190_ps_Champion->_slots[k1_ChampionSlotActionHand]) == Thing::_none) {
+		L1188_ui_ActionSetIndex = 2; /* Actions Punck, Kick and War Cry */
+	} else {
+		if ((L1188_ui_ActionSetIndex = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1189_T_Thing)]._actionSetIndex) == 0) {
+			return;
+		}
+	}
+	L1191_ps_ActionSet = &G0489_as_Graphic560_ActionSets[L1188_ui_ActionSetIndex];
+	_vm->_championMan->_g506_actingChampionOrdinal = _vm->M0_indexToOrdinal(champIndex);
+	f383_setActionList(L1191_ps_ActionSet);
+	_vm->_menuMan->_g509_actionAreaContainsIcons = false;
+	setFlag(L1190_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand);
+	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+	_vm->_menuMan->f387_drawActionArea();
+	_vm->_menuMan->f387_drawActionArea();
+}
+
+void MenuMan::f383_setActionList(ActionSet* actionSet) {
+
+#define k0x0080_actionRequiresCharge 0x0080 // @ MASK0x0080_ACTION_REQUIRES_CHARGE 
+
+	uint16 L1169_ui_ActionListIndex;
+	uint16 L1170_ui_NextAvailableActionListIndex;
+	uint16 L1171_ui_ActionIndex;
+	uint16 L1172_ui_MinimumSkillLevel;
+
+	_vm->_menuMan->_g713_actionList._actionIndices[0] = (ChampionAction)actionSet->_actionIndices[0];
+	_vm->_menuMan->_g713_actionList._minimumSkillLevel[0] = 1;
+	L1170_ui_NextAvailableActionListIndex = 1;
+	for (L1169_ui_ActionListIndex = 1; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) {
+		if ((L1171_ui_ActionIndex = actionSet->_actionIndices[L1169_ui_ActionListIndex]) == k255_ChampionActionNone)
+			continue;
+		if (getFlag(L1172_ui_MinimumSkillLevel = actionSet->_actionProperties[L1169_ui_ActionListIndex - 1], k0x0080_actionRequiresCharge) && !f382_getActionObjectChargeCount())
+			continue;
+		clearFlag(L1172_ui_MinimumSkillLevel, k0x0080_actionRequiresCharge);
+		if (_vm->_championMan->f303_getSkillLevel(_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal), g496_ActionSkillIndex[L1171_ui_ActionIndex]) >= L1172_ui_MinimumSkillLevel) {
+			_vm->_menuMan->_g713_actionList._actionIndices[L1170_ui_NextAvailableActionListIndex] = (ChampionAction)L1171_ui_ActionIndex;
+			_vm->_menuMan->_g713_actionList._minimumSkillLevel[L1170_ui_NextAvailableActionListIndex] = L1172_ui_MinimumSkillLevel;
+			L1170_ui_NextAvailableActionListIndex++;
+		}
+	}
+	_g507_actionCount = L1170_ui_NextAvailableActionListIndex;
+	for (L1169_ui_ActionListIndex = L1170_ui_NextAvailableActionListIndex; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) {
+		_vm->_menuMan->_g713_actionList._actionIndices[L1169_ui_ActionListIndex] = k255_ChampionActionNone;
+	}
+}
+
+int16 MenuMan::f382_getActionObjectChargeCount() {
+	Thing L1167_T_Thing;
+	Junk* L1168_ps_Junk;
+
+
+	L1168_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1167_T_Thing = _vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand]);
+	switch (L1167_T_Thing.getType()) {
+	case k5_WeaponThingType:
+		return ((Weapon*)L1168_ps_Junk)->getChargeCount();
+	case k6_ArmourThingType:
+		return ((Armour*)L1168_ps_Junk)->getChargeCount();
+	case k10_JunkThingType:
+		return L1168_ps_Junk->getChargeCount();
+	default:
+		return 1;
+	}
+}
 }
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 0aabcab..f0a1c2b 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -34,6 +34,11 @@
 
 namespace DM {
 
+#define kM1_damageCantReach -1 // @ CM1_DAMAGE_CANT_REACH    
+#define kM2_damageNoAmmunition -2 // @ CM2_DAMAGE_NO_AMMUNITION 
+
+#define k0x8000_hitNonMaterialCreatures 0x8000 // @ MASK0x8000_HIT_NON_MATERIAL_CREATURES 
+
 extern Box g1_BoxActionArea; // @ G0001_s_Graphic562_Box_ActionArea
 extern Box g0_BoxSpellArea; // @ G0000_s_Graphic562_Box_SpellArea
 
@@ -50,6 +55,19 @@ public:
 	}
 }; // @ ACTION_LIST
 
+class ActionSet {
+public:
+	byte _actionIndices[3]; /* 1 byte of padding inserted by compiler on Atari ST, not on Amiga */
+	byte _actionProperties[2]; /* Bit 7: requires charge, Bit 6-0: minimum skill level */
+	ActionSet(byte a1, byte a2, byte a3, byte b1, byte b2) {
+		_actionIndices[0] = a1;
+		_actionIndices[1] = a2;
+		_actionIndices[2] = a3;
+		_actionProperties[0] = b1;
+		_actionProperties[1] = b2;
+	}
+}; // @ ACTION_SET
+
 class MenuMan {
 	DMEngine *_vm;
 public:
@@ -61,6 +79,8 @@ public:
 	int16 _g513_actionDamage; // @ G0513_i_ActionDamage
 	ActionList _g713_actionList; // @ G0713_s_ActionList
 	byte *_gK72_bitmapSpellAreaLine; // @ K0072_puc_Bitmap_SpellAreaLine
+	Thing _g517_actionTargetGroupThing; // @ G0517_T_ActionTargetGroupThing
+	uint16 _g507_actionCount; // @ G0507_ui_ActionCount
 
 	void f388_clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
 	void f386_drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon
@@ -85,6 +105,17 @@ public:
 	void f398_drawChampionSymbols(Champion *champ); // @ F0398_MENUS_DrawChampionSymbols
 	void f399_addChampionSymbol(int16 symbolIndex); // @ F0399_MENUS_AddChampionSymbol
 	void f400_deleteChampionSymbol(); // @ F0400_MENUS_DeleteChampionSymbol
+	bool f391_didClickTriggerAction(int16 actionListIndex); // @ F0391_MENUS_DidClickTriggerAction
+	bool f407_isActionPerformed(uint16 champIndex, int16 actionIndex); // @ F0407_MENUS_IsActionPerformed
+	void f406_setChampionDirectionToPartyDirection(Champion *champ); // @ F0406_MENUS_SetChampionDirectionToPartyDirection
+	void f405_decrementCharges(Champion *champ); // @ F0405_MENUS_DecrementCharges
+	bool f402_isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 actionIndex, int16 targetMapX,
+									 int16 targetMapY, int16 skillIndex); // @ F0402_MENUS_IsMeleeActionPerformed
+	bool  f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, int16 mapX, int16 mapY); // @ F0401_MENUS_IsGroupFrightenedByAction
+	void f381_printMessageAfterReplacements(char *str); // @ F0381_MENUS_PrintMessageAfterReplacements
+	void f389_processCommands116To119_setActingChampion(uint16 champIndex); // @ F0389_MENUS_ProcessCommands116To119_SetActingChampion
+	void f383_setActionList(ActionSet *actionSet); // @ F0383_MENUS_SetActionList
+	int16 f382_getActionObjectChargeCount(); // @ F0382_MENUS_GetActionObjectChargeCount
 };
 
 }
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 6cb159a..34e83ca 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -963,7 +963,7 @@ void MovesensMan::f272_sensorTriggerEffect(Sensor* sensor, int16 effect, int16 m
 
 	int16 L0736_i_TargetMapX;
 	int16 L0737_i_TargetMapY;
-	register long L0738_l_Time;
+	int32 L0738_l_Time;
 	uint16 L0739_ui_SquareType;
 	uint16 L0740_ui_TargetCell;
 
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 49a7ca4..08c6ce1 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -95,7 +95,7 @@ k82_TMEventTypeMagicMap_C82 = 82, // @ C82_EVENT_MAGIC_MAP
 k83_TMEventTypeMagicMap_C83 = 83  // @ C83_EVENT_MAGIC_MAP    
 };
 
-extern signed char g495_actionDefense[44];
+extern signed char g495_actionDefense[44]; // @ G0495_ac_Graphic560_ActionDefense
 
 class TimelineEvent {
 public:


Commit: 5602d07f966ed16c5c74d014fe596ef15bcf825d
    https://github.com/scummvm/scummvm/commit/5602d07f966ed16c5c74d014fe596ef15bcf825d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix Timeline _g370_events initialization

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/timeline.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 9137975..d8821e6 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -7,8 +7,7 @@ Bugs:
 	Logic:
 		When object are put on the right side of the current square, they disappear
 		Drawing door ornaments segfaults when going back to the start
-	  !! It seems that that deleted events' _type fields are not getting set to 0, when looking for available slots, the code looks for events with 0 _type fields, 
-	  		this results in segfaults
+
 
 Possible bugs:
 	- k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 55c1e4b..3858ad5 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -103,7 +103,7 @@ void Timeline::f233_initTimeline() {
 	_g371_timeline = new uint16[_g369_eventMaxCount];
 	if (_vm->_g298_newGame) {
 		for (int16 i = 0; i < _g369_eventMaxCount; ++i)
-			_g370_events->_type = k0_TMEventTypeNone;
+			_g370_events[i]._type = k0_TMEventTypeNone;
 		_g372_eventCount = 0;
 		_g373_firstUnusedEventIndex = 0;
 	}


Commit: b092e74be9c275db8adb04a98c5146a6923e4f43
    https://github.com/scummvm/scummvm/commit/b092e74be9c275db8adb04a98c5146a6923e4f43
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix broken ChampionMan::f303_getSkillLevel

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index b9c286a..52be549 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1922,62 +1922,62 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 	}
 }
 
-uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, int16 skillIndex) {
-	if (_g300_partyIsSleeping)
+uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, uint16 skillIndex) {
+	if (_vm->_championMan->_g300_partyIsSleeping) {
 		return 1;
-
-	bool ignoreTempExp = skillIndex & k0x8000_IgnoreTemporaryExperience;
-	bool ignoreObjModifiers = skillIndex & k0x4000_IgnoreObjectModifiers;
-	skillIndex = (ChampionSkill)(skillIndex & ~(ignoreTempExp | ignoreObjModifiers));
-	Champion *champ = &_gK71_champions[champIndex];
-	Skill *skill = &champ->getSkill((ChampionSkill)skillIndex);
-	int32 experience = skill->_experience;
-
-	if (!ignoreTempExp)
-		experience += skill->_temporaryExperience;
-
-	if (skillIndex > k3_ChampionSkillWizard) { // hidden skill
-		skill = &champ->getSkill((ChampionSkill)((skillIndex - k4_ChampionSkillSwing) / 4));
-		experience += skill->_experience; // add exp to the base skill
-		if (!ignoreTempExp)
-			experience += skill->_temporaryExperience;
-
-		experience /= 2; // halve the exp to get avarage of base skill + hidden skill exp
 	}
-
+	bool ignoreTmpExp = getFlag(skillIndex, k0x8000_IgnoreTemporaryExperience);
+	bool ignoreObjModifiers = getFlag(skillIndex, k0x4000_IgnoreObjectModifiers);
+	clearFlag(skillIndex, k0x8000_IgnoreTemporaryExperience | k0x4000_IgnoreObjectModifiers);
+	Champion *champ = &_vm->_championMan->_gK71_champions[champIndex];
+	Skill *skill = &champ->_skills[skillIndex];
+	int32 exp = skill->_experience;
+	if (!ignoreTmpExp) {
+		exp += skill->_temporaryExperience;
+	}
+	if (skillIndex > k3_ChampionSkillWizard) { /* Hidden skill */
+		skill = &champ->_skills[(skillIndex - k4_ChampionSkillSwing) >> 2];
+		exp += skill->_experience; /* Add experience in the base skill */
+		if (!ignoreTmpExp) {
+			exp += skill->_temporaryExperience;
+		}
+		exp >>= 1; /* Halve experience to get average of base skill + hidden skill experience */
+	}
 	int16 skillLevel = 1;
-	while (experience >= 500) {
-		experience /= 2;
+	while (exp >= 500) {
+		exp >>= 1;
 		skillLevel++;
 	}
-
 	if (!ignoreObjModifiers) {
-		IconIndice actionHandIconIndex = _vm->_objectMan->f33_getIconIndex(champ->getSlot(k1_ChampionSlotActionHand));
-		if (actionHandIconIndex == k27_IconIndiceWeaponTheFirestaff) {
+		int16 actionHandIconIndex;
+		if ((actionHandIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand])) == k27_IconIndiceWeaponTheFirestaff) {
 			skillLevel++;
-		} else if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete) {
-			skillLevel += 2;
+		} else {
+			if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete) {
+				skillLevel += 2;
+			}
 		}
-
-		IconIndice neckIconIndice = _vm->_objectMan->f33_getIconIndex(champ->getSlot(k10_ChampionSlotNeck));
+		int16 neckIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k10_ChampionSlotNeck]);
 		switch (skillIndex) {
 		case k3_ChampionSkillWizard:
-			if (neckIconIndice == k124_IconIndiceJunkPendantFeral)
-				skillLevel++;
+			if (neckIconIndex == k124_IconIndiceJunkPendantFeral) {
+				skillLevel += 1;
+			}
 			break;
 		case k15_ChampionSkillDefend:
-			if (neckIconIndice == k121_IconIndiceJunkEkkhardCross)
-				skillLevel++;
+			if (neckIconIndex == k121_IconIndiceJunkEkkhardCross) {
+				skillLevel += 1;
+			}
 			break;
 		case k13_ChampionSkillHeal:
-			// these two are not cummulative
-			if ((neckIconIndice == k120_IconIndiceJunkGemOfAges) || (neckIconIndice == k66_IconIndiceWeaponSceptreOfLyf))
-				skillLevel++;
+			if ((neckIconIndex == k120_IconIndiceJunkGemOfAges) || (actionHandIconIndex == k66_IconIndiceWeaponSceptreOfLyf)) { /* The skill modifiers of these two objects are not cumulative */
+				skillLevel += 1;
+			}
 			break;
 		case k14_ChampionSkillInfluence:
-			if (neckIconIndice == k122_IconIndiceJunkMoonstone)
-				skillLevel++;
-			break;
+			if (neckIconIndex == k122_IconIndiceJunkMoonstone) {
+				skillLevel += 1;
+			}
 		}
 	}
 	return skillLevel;
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 2bae7c5..5d98ecb 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -536,7 +536,7 @@ public:
 	void f290_drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues
 	void f291_drawSlot(uint16 champIndex, int16 slotIndex); // @ F0291_CHAMPION_DrawSlot
 	void f281_renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename
-	uint16 f303_getSkillLevel(int16 champIndex, int16 skillIndex);// @ F0303_CHAMPION_GetSkillLevel
+	uint16 f303_getSkillLevel(int16 champIndex, uint16 skillIndex);// @ F0303_CHAMPION_GetSkillLevel
 	Common::String f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger
 	void f299_applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex,
 									int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics


Commit: 75fe72b27cd2a76a2ecee8f0476a9ef089e6d857
    https://github.com/scummvm/scummvm/commit/75fe72b27cd2a76a2ecee8f0476a9ef089e6d857
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add input timeout and fix movement after throwing a projectile

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 194bfa2..6a50e3e 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -369,9 +369,6 @@ T0002002:
 		if (!(_g313_gameTime & 511))
 			_inventoryMan->f338_decreaseTorchesLightPower();
 
-		if (_g310_disabledMovementTicks)
-			_g310_disabledMovementTicks--;
-
 		if (_championMan->_g407_party._freezeLifeTicks)
 			_championMan->_g407_party._freezeLifeTicks -= 1;
 
@@ -384,10 +381,12 @@ T0002002:
 		if (_g310_disabledMovementTicks)
 			_g310_disabledMovementTicks--;
 
-		// F0044_TEXT_MESSAGEAREA_ClearExpiredRows();
+		if (_g311_projectileDisableMovementTicks)
+			_g311_projectileDisableMovementTicks--;
 
+		// F0044_TEXT_MESSAGEAREA_ClearExpiredRows();
 		_g321_stopWaitingForPlayerInput = false;
-
+		uint16 vblankCounter = 0;
 		do {
 			_eventMan->processInput();
 
@@ -406,9 +405,12 @@ T0002002:
 			// if (!_vm->_g321_stopWaitingForPlayerInput) {
 			//		F0363_COMMAND_HighlightBoxDisable();
 			// }
-		} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking);
 
-		_system->delayMillis(18);
+			_system->delayMillis(2);
+			if (++vblankCounter >= _g318_waitForInputMaxVerticalBlankCount * 5)
+				_g321_stopWaitingForPlayerInput = true;
+
+		} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking);
 	}
 }
 


Commit: 3a654ff91e8548caf4365c657d5110b9d4a36c3e
    https://github.com/scummvm/scummvm/commit/3a654ff91e8548caf4365c657d5110b9d4a36c3e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add ChampionMan::f320_applyAndDrawPendingDamageAndWounds()

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 52be549..b9bb5e3 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -35,6 +35,7 @@
 #include "timeline.h"
 #include "projexpl.h"
 #include "group.h"
+#include "movesens.h"
 
 
 namespace DM {
@@ -1335,6 +1336,224 @@ void ChampionMan::f326_championShootProjectile(Champion* champ, Thing thing, int
 	_vm->_g312_lastProjectileDisabledMovementDirection = L0990_ui_Direction;
 }
 
+void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() {
+	uint16 L0967_ui_ChampionIndex;
+	uint16 L0968_ui_PendingDamage;
+	int16 L0969_i_Multiple;
+#define AL0969_i_Health     L0969_i_Multiple
+#define AL0969_i_X          L0969_i_Multiple
+#define AL0969_i_EventIndex L0969_i_Multiple
+	int16 L0970_i_PendingWounds;
+	Champion* L0971_ps_Champion;
+	TimelineEvent* L0972_ps_Event;
+	int16 L0973_i_Y;
+	TimelineEvent L0974_s_Event;
+	Box L0975_s_Box;
+
+
+	L0971_ps_Champion = _vm->_championMan->_gK71_champions;
+	for (L0967_ui_ChampionIndex = k0_ChampionFirst; L0967_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0967_ui_ChampionIndex++, L0971_ps_Champion++) {
+		setFlag(L0971_ps_Champion->_wounds, L0970_i_PendingWounds = _g410_championPendingWounds[L0967_ui_ChampionIndex]);
+		_g410_championPendingWounds[L0967_ui_ChampionIndex] = 0;
+		if (!(L0968_ui_PendingDamage = _g409_championPendingDamage[L0967_ui_ChampionIndex]))
+			continue;
+		_g409_championPendingDamage[L0967_ui_ChampionIndex] = 0;
+		if (!(AL0969_i_Health = L0971_ps_Champion->_currHealth))
+			continue;
+		if ((AL0969_i_Health = AL0969_i_Health - L0968_ui_PendingDamage) <= 0) {
+			_vm->_championMan->f319_championKill(L0967_ui_ChampionIndex);
+		} else {
+			L0971_ps_Champion->_currHealth = AL0969_i_Health;
+			setFlag(L0971_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+			if (L0970_i_PendingWounds) {
+				setFlag(L0971_ps_Champion->_attributes, k0x2000_ChampionAttributeWounds);
+			}
+			AL0969_i_X = L0967_ui_ChampionIndex * k69_ChampionStatusBoxSpacing;
+			L0975_s_Box._y1 = 0;
+			_vm->_eventMan->f78_showMouse();
+			if (_vm->M0_indexToOrdinal(L0967_ui_ChampionIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+				L0975_s_Box._y2 = 28;
+				L0975_s_Box._x2 = (L0975_s_Box._x1 = AL0969_i_X + 7) + 31; /* Box is over the champion portrait in the status box */
+				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k16_damageToChampionBig), &L0975_s_Box, k16_byteWidth, k10_ColorFlesh, 29);
+				if (L0968_ui_PendingDamage < 10) { /* 1 digit */
+					AL0969_i_X += 21;
+				} else {
+					if (L0968_ui_PendingDamage < 100) { /* 2 digits */
+						AL0969_i_X += 18;
+					} else { /* 3 digits */
+						AL0969_i_X += 15;
+					}
+				}
+				L0973_i_Y = 16;
+			} else {
+				L0975_s_Box._y2 = 6;
+				L0975_s_Box._x2 = (L0975_s_Box._x1 = AL0969_i_X) + 47; /* Box is over the champion name in the status box */
+				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k15_damageToChampionSmallIndice), &L0975_s_Box, k24_byteWidth, k10_ColorFlesh, 7);
+				if (L0968_ui_PendingDamage < 10) { /* 1 digit */
+					AL0969_i_X += 19;
+				} else {
+					if (L0968_ui_PendingDamage < 100) { /* 2 digits */
+						AL0969_i_X += 16;
+					} else { /* 3 digits */
+						AL0969_i_X += 13;
+					}
+				}
+				L0973_i_Y = 5;
+			}
+			_vm->_textMan->f53_printToLogicalScreen(AL0969_i_X, L0973_i_Y, k15_ColorWhite, k8_ColorRed, _vm->_championMan->f288_getStringFromInteger(L0968_ui_PendingDamage, false, 3).c_str());
+			if ((AL0969_i_EventIndex = L0971_ps_Champion->_hideDamageReceivedIndex) == -1) {
+				L0974_s_Event._type = k12_TMEventTypeHideDamageReceived;
+				M33_setMapAndTime(L0974_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
+				L0974_s_Event._priority = L0967_ui_ChampionIndex;
+				L0971_ps_Champion->_hideDamageReceivedIndex = _vm->_timeline->f238_addEventGetEventIndex(&L0974_s_Event);
+			} else {
+				L0972_ps_Event = &_vm->_timeline->_g370_events[AL0969_i_EventIndex];
+				M33_setMapAndTime(L0972_ps_Event->_mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
+				_vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(AL0969_i_EventIndex));
+			}
+			_vm->_championMan->f292_drawChampionState((ChampionIndex)L0967_ui_ChampionIndex);
+			_vm->_eventMan->f77_hideMouse();
+		}
+	}
+}
+
+void ChampionMan::f319_championKill(uint16 champIndex) {
+	uint16 L0962_ui_Multiple = 0;
+#define AL0962_ui_Cell              L0962_ui_Multiple
+#define AL0962_ui_ChampionIconIndex L0962_ui_Multiple
+	int16 L0963_i_AliveChampionIndex;
+	Thing L0964_T_Thing;
+	Champion* L0965_ps_Champion;
+	Junk* L0966_ps_Junk;
+
+
+	L0965_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	L0965_ps_Champion->_currHealth = 0;
+	setFlag(L0965_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox);
+	if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+		if (_vm->_g331_pressingEye) {
+			_vm->_g331_pressingEye = false;
+			_vm->_eventMan->_g597_ignoreMouseMovements = false;
+			if (!_vm->_championMan->_g415_leaderEmptyHanded) {
+				_vm->_objectMan->f34_drawLeaderObjectName(_vm->_championMan->_g414_leaderHandObject);
+			}
+			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
+			_vm->_eventMan->f77_hideMouse();
+		} else {
+			if (_vm->_g333_pressingMouth) {
+				_vm->_g333_pressingMouth = false;
+				_vm->_eventMan->_g597_ignoreMouseMovements = false;
+				_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
+				_vm->_eventMan->f77_hideMouse();
+			}
+		}
+		_vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
+	}
+	f318_dropAllObjects(champIndex);
+	L0964_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k0x8000_championBones | k10_JunkThingType);
+	if (L0964_T_Thing == Thing::_none) {
+	} else {
+		L0966_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0964_T_Thing);
+		L0966_ps_Junk->setType(k5_JunkTypeBones);
+		L0966_ps_Junk->setDoNotDiscard(true);
+		L0966_ps_Junk->setChargeCount(champIndex);
+		AL0962_ui_Cell = L0965_ps_Champion->_cell;
+		_vm->_movsens->f267_getMoveResult(M15_thingWithNewCell(L0964_T_Thing, AL0962_ui_Cell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+	}
+	L0965_ps_Champion->_symbolStep = 0;
+	L0965_ps_Champion->_symbols[0] = '\0';
+	L0965_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
+	L0965_ps_Champion->_maximumDamageReceived = 0;
+	AL0962_ui_ChampionIconIndex = _vm->_championMan->M26_championIconIndex(AL0962_ui_Cell, _vm->_dungeonMan->_g308_partyDir);
+	if (_vm->M0_indexToOrdinal(AL0962_ui_ChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
+		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
+		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+		warning(false, "IGNORED CODE:G0592_B_BuildMousePointerScreenAreaRequested = true");
+	}
+	if (L0965_ps_Champion->_poisonEventCount) {
+		f323_unpoison(champIndex);
+	}
+	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0962_ui_ChampionIconIndex << 2], k0_ColorBlack);
+	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+	for (L0963_i_AliveChampionIndex = k0_ChampionFirst, L0965_ps_Champion = _vm->_championMan->_gK71_champions; L0963_i_AliveChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0963_i_AliveChampionIndex++, L0965_ps_Champion++) {
+		if (L0965_ps_Champion->_currHealth)
+			break;
+	}
+	if (L0963_i_AliveChampionIndex == _vm->_championMan->_g305_partyChampionCount) { /* BUG0_43 The game does not end if the last living champion in the party is killed while looking at a candidate champion in a portrait. The condition to end the game when the whole party is killed is not true because the code considers the candidate champion as alive (in the loop above) */
+		_vm->_championMan->_g303_partyDead = true;
+		return;
+	}
+	if (champIndex == _vm->_championMan->_g411_leaderIndex) {
+		_vm->_eventMan->f368_commandSetLeader((ChampionIndex)L0963_i_AliveChampionIndex);
+	}
+	if (champIndex == _vm->_championMan->_g514_magicCasterChampionIndex) {
+		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(L0963_i_AliveChampionIndex);
+	} else {
+		_vm->_menuMan->f393_drawSpellAreaControls(_vm->_championMan->_g514_magicCasterChampionIndex);
+	}
+}
+
+void ChampionMan::f318_dropAllObjects(uint16 champIndex) {
+	static int16 G0057_ai_Graphic562_SlotDropOrder[30] = {
+		k5_ChampionSlotFeet,
+		k4_ChampionSlotLegs,
+		k9_ChampionSlotQuiverLine_2_2,
+		k8_ChampionSlotQuiverLine_1_2,
+		k7_ChampionSlotQuiverLine_2_1,
+		k12_ChampionSlotQuiverLine_1_1,
+		k6_ChampionSlotPouch_2,
+		k11_ChampionSlotPouch_1,
+		k3_ChampionSlotTorso,
+		k13_ChampionSlotBackpackLine_1_1,
+		k14_ChampionSlotBackpackLine_2_2,
+		k15_ChampionSlotBackpackLine_2_3,
+		k16_ChampionSlotBackpackLine_2_4,
+		k17_ChampionSlotBackpackLine_2_5,
+		k18_ChampionSlotBackpackLine_2_6,
+		k19_ChampionSlotBackpackLine_2_7,
+		k20_ChampionSlotBackpackLine_2_8,
+		k21_ChampionSlotBackpackLine_2_9,
+		k22_ChampionSlotBackpackLine_1_2,
+		k23_ChampionSlotBackpackLine_1_3,
+		k24_ChampionSlotBackpackLine_1_4,
+		k25_ChampionSlotBackpackLine_1_5,
+		k26_ChampionSlotBackpackLine_1_6,
+		k27_ChampionSlotBackpackLine_1_7,
+		k28_ChampionSlotBackpackLine_1_8,
+		k29_ChampionSlotBackpackLine_1_9,
+		k10_ChampionSlotNeck,
+		k2_ChampionSlotHead,
+		k0_ChampionSlotReadyHand,
+		k1_ChampionSlotActionHand};
+
+	uint16 L0959_ui_Cell;
+	Thing L0960_T_Thing;
+	uint16 L0961_ui_SlotIndex;
+
+	L0959_ui_Cell = _vm->_championMan->_gK71_champions[champIndex]._cell;
+	for (L0961_ui_SlotIndex = k0_ChampionSlotReadyHand; L0961_ui_SlotIndex < k30_ChampionSlotChest_1; L0961_ui_SlotIndex++) {
+		if ((L0960_T_Thing = f300_getObjectRemovedFromSlot(champIndex, G0057_ai_Graphic562_SlotDropOrder[L0961_ui_SlotIndex])) != Thing::_none) {
+			_vm->_movsens->f267_getMoveResult(M15_thingWithNewCell(L0960_T_Thing, L0959_ui_Cell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+		}
+	}
+}
+
+void ChampionMan::f323_unpoison(int16 champIndex) {
+	int16 L0982_i_EventIndex;
+	TimelineEvent* L0983_ps_Event;
+
+	if (champIndex == kM1_ChampionNone) {
+		return;
+	}
+	for (L0982_i_EventIndex = 0, L0983_ps_Event = _vm->_timeline->_g370_events; L0982_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0983_ps_Event++, L0982_i_EventIndex++) {
+		if ((L0983_ps_Event->_type== k75_TMEventTypePoisonChampion) && (L0983_ps_Event->_priority == champIndex)) {
+			_vm->_timeline->f237_deleteEvent(L0982_i_EventIndex);
+		}
+	}
+	_vm->_championMan->_gK71_champions[champIndex]._poisonEventCount = 0;
+}
+
 ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
 	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
 		if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 5d98ecb..2bb2380 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -575,7 +575,10 @@ public:
 	bool f327_isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount); // @ F0327_CHAMPION_IsProjectileSpellCast
 	void f326_championShootProjectile(Champion *champ, Thing thing, int16 kineticEnergy,
 									  int16 attack, int16 stepEnergy); // @ F0326_CHAMPION_ShootProjectile
-
+	void f320_applyAndDrawPendingDamageAndWounds(); // @ F0320_CHAMPION_ApplyAndDrawPendingDamageAndWounds
+	void f319_championKill(uint16 champIndex); // @ F0319_CHAMPION_Kill
+	void f318_dropAllObjects(uint16 champIndex); // @ F0318_CHAMPION_DropAllObjects
+	void f323_unpoison(int16 champIndex); // @ F0323_CHAMPION_Unpoison
 };
 
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 6a50e3e..317508a 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -361,7 +361,7 @@ T0002002:
 		}
 		// F0363_COMMAND_HighlightBoxDisable();
 		// F0065_SOUND_PlayPendingSound_CPSD();
-		// F0320_CHAMPION_ApplyAndDrawPendingDamageAndWounds
+		_championMan->f320_applyAndDrawPendingDamageAndWounds();
 		if (_championMan->_g303_partyDead)
 			break;
 		_g313_gameTime++;
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 515ef93..a9bc369 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -495,6 +495,7 @@ public:
 	uint16 getChargeCount() { return (_attributes >> 14) & 0x3; }
 	void setChargeCount(uint16 val) { _attributes = (_attributes & ~(0x3 << 14)) | ((val & 0x3) << 14); }
 	uint16 getDoNotDiscard() { return (_attributes >> 7) & 1; }
+	void setDoNotDiscard(uint16 val) { _attributes = (_attributes & ~(1 << 7)) | ((val & 1) << 7); }
 
 	Thing getNextThing() { return _nextThing; }
 	void setNextThing(Thing thing) { _nextThing = thing; }
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index b1ffe30..5fe80e2 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -355,6 +355,8 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 	_gK100_preventBuildPointerScreenArea = false;
 	_g443_primaryKeyboardInput = nullptr;
 	_g444_secondaryKeyboardInput = nullptr;
+	_g597_ignoreMouseMovements = false;
+	_g587_hideMousePointerRequestCount = 0;
 }
 
 EventManager::~EventManager() {
@@ -518,10 +520,12 @@ void EventManager::f69_setMousePointer() {
 }
 
 void EventManager::f78_showMouse() {
+	//if(_g587_hideMousePointerRequestCount++ == 0)
 	CursorMan.showMouse(true);
 }
 
 void EventManager::f77_hideMouse() {
+	// if(_g587_hideMousePointerRequestCount-- == 1)
 	// CursorMan.showMouse(false);
 }
 
@@ -564,7 +568,8 @@ void EventManager::processInput() {
 
 		}
 		case Common::EVENT_MOUSEMOVE:
-			_mousePos = event.mouse;
+			if (!_g597_ignoreMouseMovements)
+				_mousePos = event.mouse;
 			break;
 		case Common::EVENT_LBUTTONDOWN:
 		case Common::EVENT_RBUTTONDOWN:
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 24fca0f..0a77cf8 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -268,6 +268,8 @@ public:
 	uint16 _g599_useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap
 	KeyboardInput *_g443_primaryKeyboardInput; // @ G0443_ps_PrimaryKeyboardInput
 	KeyboardInput *_g444_secondaryKeyboardInput; // @ G0444_ps_SecondaryKeyboardInput
+	bool _g597_ignoreMouseMovements;// @ G0597_B_IgnoreMouseMovements
+	int16 _g587_hideMousePointerRequestCount; // @ G0587_i_HideMousePointerRequestCount
 
 	void initMouse();
 	void f67_setMousePointerToNormal(int16 mousePointer); // @ F0067_MOUSE_SetPointerToNormal
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 2ca77b9..d1cc5b7 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -207,6 +207,8 @@ enum GraphicIndice {
 	k10_MenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA
 	k11_MenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES
 	k13_MovementArrowsIndice = 13, // @ C013_GRAPHIC_MOVEMENT_ARROWS
+	k15_damageToChampionSmallIndice = 15, // @ C015_GRAPHIC_DAMAGE_TO_CHAMPION_SMALL
+	k16_damageToChampionBig = 16, // @ C016_GRAPHIC_DAMAGE_TO_CHAMPION_BIG
 	k17_InventoryGraphicIndice = 17, // @ C017_GRAPHIC_INVENTORY
 	k18_ArrowForChestContentIndice = 18, // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT
 	k19_EyeForObjectDescriptionIndice = 19, // @ C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION


Commit: 3f01beea8aff2177c90dda0a5195f7c348e71baa
    https://github.com/scummvm/scummvm/commit/3f01beea8aff2177c90dda0a5195f7c348e71baa
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add ChampionMan::f331_applyTimeEffects

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index b9bb5e3..717e182 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1547,13 +1547,165 @@ void ChampionMan::f323_unpoison(int16 champIndex) {
 		return;
 	}
 	for (L0982_i_EventIndex = 0, L0983_ps_Event = _vm->_timeline->_g370_events; L0982_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0983_ps_Event++, L0982_i_EventIndex++) {
-		if ((L0983_ps_Event->_type== k75_TMEventTypePoisonChampion) && (L0983_ps_Event->_priority == champIndex)) {
+		if ((L0983_ps_Event->_type == k75_TMEventTypePoisonChampion) && (L0983_ps_Event->_priority == champIndex)) {
 			_vm->_timeline->f237_deleteEvent(L0982_i_EventIndex);
 		}
 	}
 	_vm->_championMan->_gK71_champions[champIndex]._poisonEventCount = 0;
 }
 
+void ChampionMan::f331_applyTimeEffects() {
+	uint16 L1006_ui_Multiple;
+#define AL1006_ui_GameTime      L1006_ui_Multiple
+#define AL1006_ui_ChampionIndex L1006_ui_Multiple
+	uint16 L1007_ui_Multiple;
+#define AL1007_ui_ScentIndex            L1007_ui_Multiple
+#define AL1007_ui_ManaGain              L1007_ui_Multiple
+#define AL1007_ui_StaminaGainCycleCount L1007_ui_Multiple
+#define AL1007_ui_StatisticIndex        L1007_ui_Multiple
+	uint16 L1008_ui_Multiple;
+#define AL1008_ui_WizardSkillLevel L1008_ui_Multiple
+#define AL1008_ui_Delay            L1008_ui_Multiple
+#define AL1008_ui_StaminaAboveHalf L1008_ui_Multiple
+#define AL1008_ui_StatisticMaximum L1008_ui_Multiple
+	int16 L1009_i_Multiple;
+#define AL1009_i_SkillIndex       L1009_i_Multiple
+#define AL1009_i_StaminaMagnitude L1009_i_Multiple
+#define AL1009_i_StaminaLoss      L1009_i_Multiple
+	Champion* L1010_ps_Champion;
+	unsigned char* L1011_puc_Statistic;
+	uint16 L1012_ui_TimeCriteria;
+	int16 L1013_i_Multiple;
+#define AL1013_i_StaminaAmount L1013_i_Multiple
+#define AL1013_i_HealthGain    L1013_i_Multiple
+	Scent L1014_s_Scent;
+
+
+	if (!_vm->_championMan->_g305_partyChampionCount) {
+		return;
+	}
+	L1014_s_Scent.setMapX(_vm->_dungeonMan->_g306_partyMapX);
+	L1014_s_Scent.setMapY(_vm->_dungeonMan->_g307_partyMapY);
+	L1014_s_Scent.setMapIndex(_vm->_dungeonMan->_g309_partyMapIndex);
+	AL1007_ui_ScentIndex = 0;
+	while ((int16)AL1007_ui_ScentIndex < (int16)(_vm->_championMan->_g407_party._scentCount - 1)) {
+		if (&_vm->_championMan->_g407_party._scents[AL1007_ui_ScentIndex] != &L1014_s_Scent) {
+			if (!(_vm->_championMan->_g407_party._scentStrengths[AL1007_ui_ScentIndex] = MAX(0, _vm->_championMan->_g407_party._scentStrengths[AL1007_ui_ScentIndex] - 1)) && !AL1007_ui_ScentIndex) {
+				f316_deleteScent(0);
+				continue;
+			}
+		}
+		AL1007_ui_ScentIndex++;
+	}
+	AL1006_ui_GameTime = _vm->_g313_gameTime;
+	L1012_ui_TimeCriteria = (((AL1006_ui_GameTime & 0x0080) + ((AL1006_ui_GameTime & 0x0100) >> 2)) + ((AL1006_ui_GameTime & 0x0040) << 2)) >> 2;
+	for (AL1006_ui_ChampionIndex = k0_ChampionFirst, L1010_ps_Champion = _vm->_championMan->_gK71_champions; AL1006_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL1006_ui_ChampionIndex++, L1010_ps_Champion++) {
+		if (L1010_ps_Champion->_currHealth && (_vm->M0_indexToOrdinal(AL1006_ui_ChampionIndex) != _vm->_championMan->_g299_candidateChampionOrdinal)) {
+			if ((L1010_ps_Champion->_currMana < L1010_ps_Champion->_maxMana) && (L1012_ui_TimeCriteria < (L1010_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + (AL1008_ui_WizardSkillLevel = _vm->_championMan->f303_getSkillLevel(AL1006_ui_ChampionIndex, k3_ChampionSkillWizard) + _vm->_championMan->f303_getSkillLevel(AL1006_ui_ChampionIndex, k2_ChampionSkillPriest))))) {
+				AL1007_ui_ManaGain = L1010_ps_Champion->_maxMana / 40;
+				if (_vm->_championMan->_g300_partyIsSleeping) {
+					AL1007_ui_ManaGain = AL1007_ui_ManaGain << 1;
+				}
+				AL1007_ui_ManaGain++;
+				f325_decrementStamine(AL1006_ui_ChampionIndex, AL1007_ui_ManaGain * MAX(7, 16 - AL1008_ui_WizardSkillLevel));
+				L1010_ps_Champion->_currMana += MIN(AL1007_ui_ManaGain, (uint16)(L1010_ps_Champion->_maxMana - L1010_ps_Champion->_currMana));
+			} else {
+				if (L1010_ps_Champion->_currMana > L1010_ps_Champion->_maxMana) {
+					L1010_ps_Champion->_currMana--;
+				}
+			}
+			for (AL1009_i_SkillIndex = k19_ChampionSkillWater; AL1009_i_SkillIndex >= k0_ChampionSkillFighter; AL1009_i_SkillIndex--) {
+				if (L1010_ps_Champion->_skills[AL1009_i_SkillIndex]._temporaryExperience > 0) {
+					L1010_ps_Champion->_skills[AL1009_i_SkillIndex]._temporaryExperience--;
+				}
+			}
+			AL1007_ui_StaminaGainCycleCount = 4;
+			AL1009_i_StaminaMagnitude = L1010_ps_Champion->_maxStamina;
+			while (L1010_ps_Champion->_currStamina < (AL1009_i_StaminaMagnitude >>= 1)) {
+				AL1007_ui_StaminaGainCycleCount += 2;
+			}
+			AL1009_i_StaminaLoss = 0;
+			AL1013_i_StaminaAmount = f26_getBoundedValue(1, (L1010_ps_Champion->_maxStamina >> 8) - 1, 6);
+			if (_vm->_championMan->_g300_partyIsSleeping) {
+				AL1013_i_StaminaAmount <<= 1;
+			}
+			if ((AL1008_ui_Delay = (_vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime)) > 80) {
+				AL1013_i_StaminaAmount++;
+				if (AL1008_ui_Delay > 250) {
+					AL1013_i_StaminaAmount++;
+				}
+			}
+			do {
+				AL1008_ui_StaminaAboveHalf = (AL1007_ui_StaminaGainCycleCount <= 4);
+				if (L1010_ps_Champion->_food < -512) {
+					if (AL1008_ui_StaminaAboveHalf) {
+						AL1009_i_StaminaLoss += AL1013_i_StaminaAmount;
+						L1010_ps_Champion->_food -= 2;
+					}
+				} else {
+					if (L1010_ps_Champion->_food >= 0) {
+						AL1009_i_StaminaLoss -= AL1013_i_StaminaAmount;
+					}
+					L1010_ps_Champion->_food -= AL1008_ui_StaminaAboveHalf ? 2 : AL1007_ui_StaminaGainCycleCount >> 1;
+				}
+				if (L1010_ps_Champion->_water < -512) {
+					if (AL1008_ui_StaminaAboveHalf) {
+						AL1009_i_StaminaLoss += AL1013_i_StaminaAmount;
+						L1010_ps_Champion->_water -= 1;
+					}
+				} else {
+					if (L1010_ps_Champion->_water >= 0) {
+						AL1009_i_StaminaLoss -= AL1013_i_StaminaAmount;
+					}
+					L1010_ps_Champion->_water -= AL1008_ui_StaminaAboveHalf ? 1 : AL1007_ui_StaminaGainCycleCount >> 2;
+				}
+			} while (--AL1007_ui_StaminaGainCycleCount && ((L1010_ps_Champion->_currStamina - AL1009_i_StaminaLoss) < L1010_ps_Champion->_maxStamina));
+			f325_decrementStamine(AL1006_ui_ChampionIndex, AL1009_i_StaminaLoss);
+			if (L1010_ps_Champion->_food < -1024) {
+				L1010_ps_Champion->_food = -1024;
+			}
+			if (L1010_ps_Champion->_water < -1024) {
+				L1010_ps_Champion->_water = -1024;
+			}
+			if ((L1010_ps_Champion->_currHealth < L1010_ps_Champion->_maxHealth) && (L1010_ps_Champion->_currStamina >= (L1010_ps_Champion->_maxStamina >> 2)) && (L1012_ui_TimeCriteria < (L1010_ps_Champion->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] + 12))) {
+				AL1013_i_HealthGain = (L1010_ps_Champion->_maxHealth >> 7) + 1;
+				if (_vm->_championMan->_g300_partyIsSleeping) {
+					AL1013_i_HealthGain <<= 1;
+				}
+				if (_vm->_objectMan->f33_getIconIndex(L1010_ps_Champion->_slots[k10_ChampionSlotNeck]) == k121_IconIndiceJunkEkkhardCross) {
+					AL1013_i_HealthGain += (AL1013_i_HealthGain >> 1) + 1;
+				}
+				L1010_ps_Champion->_currHealth += MIN(AL1013_i_HealthGain, (int16)(L1010_ps_Champion->_maxHealth - L1010_ps_Champion->_currHealth));
+			}
+			if (!((int)_vm->_g313_gameTime & (_vm->_championMan->_g300_partyIsSleeping ? 63 : 255))) {
+				for (AL1007_ui_StatisticIndex = k0_ChampionStatLuck; AL1007_ui_StatisticIndex <= k6_ChampionStatAntifire; AL1007_ui_StatisticIndex++) {
+					L1011_puc_Statistic = L1010_ps_Champion->_statistics[AL1007_ui_StatisticIndex];
+					AL1008_ui_StatisticMaximum = L1011_puc_Statistic[k0_ChampionStatMaximum];
+					if (L1011_puc_Statistic[k1_ChampionStatCurrent] < AL1008_ui_StatisticMaximum) {
+						L1011_puc_Statistic[k1_ChampionStatCurrent]++;
+					} else {
+						if (L1011_puc_Statistic[k1_ChampionStatCurrent] > AL1008_ui_StatisticMaximum) {
+							L1011_puc_Statistic[k1_ChampionStatCurrent] -= L1011_puc_Statistic[k1_ChampionStatCurrent] / AL1008_ui_StatisticMaximum;
+						}
+					}
+				}
+			}
+			if (!_vm->_championMan->_g300_partyIsSleeping && (L1010_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime < (_vm->_g313_gameTime - 60))) {
+				L1010_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
+				L1010_ps_Champion->_maximumDamageReceived = 0;
+				setFlag(L1010_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon);
+			}
+			setFlag(L1010_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+			if (_vm->M0_indexToOrdinal(AL1006_ui_ChampionIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+				if (_vm->_g333_pressingMouth || _vm->_g331_pressingEye || (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
+					setFlag(L1010_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
+				}
+			}
+		}
+	}
+	f293_drawAllChampionStates();
+}
+
 ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
 	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
 		if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 2bb2380..d4491d5 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -579,6 +579,7 @@ public:
 	void f319_championKill(uint16 champIndex); // @ F0319_CHAMPION_Kill
 	void f318_dropAllObjects(uint16 champIndex); // @ F0318_CHAMPION_DropAllObjects
 	void f323_unpoison(int16 champIndex); // @ F0323_CHAMPION_Unpoison
+	void f331_applyTimeEffects(); // @ F0331_CHAMPION_ApplyTimeEffects_CPSF
 };
 
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 317508a..2bd4a2e 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -374,9 +374,9 @@ T0002002:
 
 		_menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived();
 
-		// if (!((int)_vm->_g313_gameTime & (_vm->_championMan->_g300_partyIsSleeping ? 15 : 63))) {
-		//		F0331_CHAMPION_ApplyTimeEffects_CPSF();
-		// }
+		if (!((int32)_g313_gameTime & (_championMan->_g300_partyIsSleeping ? 15 : 63))) {
+			_championMan->f331_applyTimeEffects();
+		}
 
 		if (_g310_disabledMovementTicks)
 			_g310_disabledMovementTicks--;


Commit: 78cf0030e3545eabe254a9643c1c9570d5e1068d
    https://github.com/scummvm/scummvm/commit/78cf0030e3545eabe254a9643c1c9570d5e1068d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix missing messages at the bottom of the screen

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dm.cpp
    engines/dm/text.cpp
    engines/dm/text.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index d8821e6..70c0008 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -7,6 +7,8 @@ Bugs:
 	Logic:
 		When object are put on the right side of the current square, they disappear
 		Drawing door ornaments segfaults when going back to the start
+		Stepping onto the plate next doesn't open the grated gate on the 0th level
+		Walking into walls corrupts memory
 
 
 Possible bugs:
@@ -26,7 +28,4 @@ Todo:
 Finish stuff:
 	f380_processCommandQueue
 	Missing main loop methods
-	F0577_VBLANK_Handler, if enought time passes, takes the player's chance to act
-		- TODO: implement it
-		- NOTE: _g318_waitForInputMaxVerticalBlankCount is already included in the engine
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 2bd4a2e..b3018ba 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -384,7 +384,7 @@ T0002002:
 		if (_g311_projectileDisableMovementTicks)
 			_g311_projectileDisableMovementTicks--;
 
-		// F0044_TEXT_MESSAGEAREA_ClearExpiredRows();
+		_textMan->f44_messageAreaClearExpiredRows();
 		_g321_stopWaitingForPlayerInput = false;
 		uint16 vblankCounter = 0;
 		do {
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index eff2447..993cc8e 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -45,10 +45,12 @@ TextMan::~TextMan() {
 #define k5_LetterWidth 5
 #define k6_LetterHeight 6
 
-void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, uint16 destX, uint16 destY,
+void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int16 destX, int16 destY,
 									Color textColor, Color bgColor, const char* text, uint16 destHeight) {
-	destX -= 1; // fixes missalignment, to be checked
-	destY -= 4; // fixes missalignment, to be checked
+	if ((destX -= 1) < 0) // fixes missalignment, to be checked
+		destX = 0;
+	if ((destY -= 4) < 0) // fixes missalignment, to be checked
+		destY = 0;
 
 	uint16 destPixelWidth = destByteWidth * 2;
 
@@ -155,7 +157,7 @@ void TextMan::f46_messageAreaPrintString(Color color, const char* string) {
 	L0030_i_StringLength = strlen(string);
 	warning(false, "MISSING CODE: F0561_SCROLLER_IsTextScrolling");
 	if (true) { // there is a test here with F0561_SCROLLER_IsTextScrolling
-		_vm->_textMan->f53_printToLogicalScreen(_g359_messageAreaCursorColumn * 6, (_g358_messageAreaCursorRow * 7) + 177, color, k0_ColorBlack, string);
+		_vm->_textMan->f53_printToLogicalScreen(_g359_messageAreaCursorColumn * 6, (_g358_messageAreaCursorRow * 7 - 6) + 177, color, k0_ColorBlack, string);
 	} else {
 		f40_printTextToBitmap(_g356_bitmapMessageAreaNewRow, k160_byteWidthScreen, _g359_messageAreaCursorColumn * 6, 5, color, k0_ColorBlack, string, 7);
 		warning(false, "MISSING CODE: F0561_SCROLLER_IsTextScrolling");
@@ -163,6 +165,7 @@ void TextMan::f46_messageAreaPrintString(Color color, const char* string) {
 	}
 	_g359_messageAreaCursorColumn += L0030_i_StringLength;
 	_g360_messageAreaRowExpirationTime[_g358_messageAreaCursorRow] = _vm->_g313_gameTime + 200;
+
 }
 
 void TextMan::f54_textInitialize() {
@@ -189,4 +192,23 @@ void TextMan::f42_messageAreaMoveCursor(int16 column, int16 row) {
 	}
 	_g358_messageAreaCursorRow = row;
 }
+
+void TextMan::f44_messageAreaClearExpiredRows() {
+	uint16 L0026_ui_RowIndex;
+	int32 L0027_l_ExpirationTime;
+	Box L0028_s_Box;
+
+	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	L0028_s_Box._x1 = 0;
+	L0028_s_Box._x2 = 319;
+	for (L0026_ui_RowIndex = 0; L0026_ui_RowIndex < 4; L0026_ui_RowIndex++) {
+		L0027_l_ExpirationTime = _g360_messageAreaRowExpirationTime[L0026_ui_RowIndex];
+		if ((L0027_l_ExpirationTime == -1) || (L0027_l_ExpirationTime > _vm->_g313_gameTime))
+			continue;
+		L0028_s_Box._y2 = (L0028_s_Box._y1 = 172 + (L0026_ui_RowIndex * 7)) + 6;
+		warning(false, "MISSING CODE:F0561_SCROLLER_IsTextScrolling(&K0060_s_TextScroller, true);");
+		_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g348_bitmapScreen, L0028_s_Box, k0_ColorBlack, k160_byteWidthScreen, k200_heightScreen);
+		_g360_messageAreaRowExpirationTime[L0026_ui_RowIndex] = -1;
+	}
+}
 }
diff --git a/engines/dm/text.h b/engines/dm/text.h
index ce38c55..c07b8f2 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -42,7 +42,7 @@ class TextMan {
 public:
 	explicit TextMan(DMEngine *vm);
 	~TextMan();
-	void f40_printTextToBitmap(byte *destBitmap, uint16 destByteWidth, uint16 destX, uint16 destY,
+	void f40_printTextToBitmap(byte *destBitmap, uint16 destByteWidth, int16 destX, int16 destY,
 						   Color textColor, Color bgColor, const char *text, uint16 destHeight); // @ F0040_TEXT_Print
 	void f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text); // @ F0053_TEXT_PrintToLogicalScreen
 	void f52_printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport
@@ -54,7 +54,7 @@ public:
 	void f46_messageAreaPrintString(Color color, const char* string);// @ F0046_TEXT_MESSAGEAREA_PrintString
 	void f54_textInitialize(); // @ F0054_TEXT_Initialize
 	void f42_messageAreaMoveCursor(int16 column, int16 row); // @ F0042_TEXT_MESSAGEAREA_MoveCursor
-
+	void f44_messageAreaClearExpiredRows(); // @ F0044_TEXT_MESSAGEAREA_ClearExpiredRows
 
 
 };


Commit: 9f9ac99b3198c09e58767ab2fe3eb71d03a5647e
    https://github.com/scummvm/scummvm/commit/9f9ac99b3198c09e58767ab2fe3eb71d03a5647e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix broken damage display

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/gfx.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 70c0008..47416c5 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -8,7 +8,7 @@ Bugs:
 		When object are put on the right side of the current square, they disappear
 		Drawing door ornaments segfaults when going back to the start
 		Stepping onto the plate next doesn't open the grated gate on the 0th level
-		Walking into walls corrupts memory
+		Damage to a champion's health is not getting reflected in the bar graphs, only when opening the inventory (maybe health is not getting set correctly)
 
 
 Possible bugs:
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index f05a8ca..5efb3f0 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1445,7 +1445,7 @@ void DisplayMan::f21_blitToScreen(byte *bitmap, int16* box, int16 byteWidth, Col
 
 void DisplayMan::f21_blitToScreen(byte* bitmap, Box* box, int16 byteWidth, Color transparent, int16 height) {
 	_g578_useByteBoxCoordinates = false;
-	f132_blitToBitmap(bitmap, _g348_bitmapScreen, *box, 0, 0, byteWidth, k112_byteWidthViewport, transparent, height, k136_heightViewport);
+	f132_blitToBitmap(bitmap, _g348_bitmapScreen, *box, 0, 0, byteWidth, k160_byteWidthScreen, transparent, height, k200_heightScreen);
 }
 
 void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {


Commit: 665ea3beff7be4d9240ff89b671d8e77038a0990
    https://github.com/scummvm/scummvm/commit/665ea3beff7be4d9240ff89b671d8e77038a0990
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix champion bar graphs

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/champion.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 47416c5..229ed8c 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -8,8 +8,6 @@ Bugs:
 		When object are put on the right side of the current square, they disappear
 		Drawing door ornaments segfaults when going back to the start
 		Stepping onto the plate next doesn't open the grated gate on the 0th level
-		Damage to a champion's health is not getting reflected in the bar graphs, only when opening the inventory (maybe health is not getting set correctly)
-
 
 Possible bugs:
 	- k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 717e182..1590699 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1905,57 +1905,57 @@ T0280048:
 }
 
 void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
-
-	Champion *curChampion = &_gK71_champions[champIndex];
-	int16 barGraphIndex = 0;
-	int16 barGraphHeightArray[3];
-
-	if (curChampion->_currHealth > 0) {
-		uint32 barGraphHeight = (((uint32)(curChampion->_currHealth) << 10) * 25) / curChampion->_maxHealth;
-		if (barGraphHeight & 0x3FF) {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
+	int16 barGraphHeights[3];
+	Champion *champ = &_vm->_championMan->_gK71_champions[champIndex];
+	int16 AL0842_i_BarGraphIndex = 0;
+	if (champ->_currHealth > 0) {
+		int32 barGraphHeight = (((int32)champ->_currHealth << 10) * 25) / champ->_maxHealth;
+		if (barGraphHeight & 0x000003FF) {
+			barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10) + 1;
 		} else {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
+			barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10);
 		}
 	} else {
-		barGraphHeightArray[barGraphIndex++] = 0;
+		barGraphHeights[AL0842_i_BarGraphIndex++] = 0;
 	}
-
-	if (curChampion->_currStamina > 0) {
-		uint32 barGraphHeight = (((uint32)(curChampion->_currStamina) << 10) * 25) / curChampion->_maxStamina;
-		if (barGraphHeight & 0x3FF) {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
+	if (champ->_currStamina > 0) {
+		int32 barGraphHeight = (((int32)champ->_currStamina << 10) * 25) / champ->_maxStamina;
+		if (barGraphHeight & 0x000003FF) {
+			barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10) + 1;
 		} else {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
+			barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10);
 		}
 	} else {
-		barGraphHeightArray[barGraphIndex++] = 0;
+		barGraphHeights[AL0842_i_BarGraphIndex++] = 0;
 	}
-
-	if (curChampion->_currMana > 0) {
-		uint32 barGraphHeight = (((uint32)(curChampion->_currMana) << 10) * 25) / curChampion->_maxMana;
-		if (barGraphHeight & 0x3FF) {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1;
+	if (champ->_currMana > 0) {
+		if (champ->_currMana > champ->_maxMana) {
+			barGraphHeights[AL0842_i_BarGraphIndex] = 25;
 		} else {
-			barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10);
+			int32 barGraphHeight = (((int32)champ->_currMana << 10) * 25) / champ->_maxMana;
+			if (barGraphHeight & 0x000003FF) {
+				barGraphHeights[AL0842_i_BarGraphIndex] = (barGraphHeight >> 10) + 1;
+			} else {
+				barGraphHeights[AL0842_i_BarGraphIndex] = (barGraphHeight >> 10);
+			}
 		}
 	} else {
-		barGraphHeightArray[barGraphIndex++] = 0;
+		barGraphHeights[AL0842_i_BarGraphIndex] = 0;
 	}
 	_vm->_eventMan->f78_showMouse();
 
+	// Strangerke - TO CHECK: if portraits, maybe the old (assembly) code is required for older versions
 	Box box;
 	box._x1 = champIndex * k69_ChampionStatusBoxSpacing + 46;
 	box._x2 = box._x1 + 3;
 	box._y1 = 2;
 	box._y2 = 26;
-
-	for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) {
-		int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex];
+	for (int16 barGraphIndex = 0; barGraphIndex < 3; barGraphIndex++) {
+		int16 barGraphHeight = barGraphHeights[barGraphIndex];
 		if (barGraphHeight < 25) {
 			box._y1 = 2;
-			box._y1 = 27 - barGraphHeight;
-			_vm->_displayMan->D24_fillScreenBox(box, g46_ChampionColor[champIndex]);
+			box._y2 = 27 - barGraphHeight;
+			_vm->_displayMan->D24_fillScreenBox(box, k12_ColorDarkestGray);
 		}
 		if (barGraphHeight) {
 			box._y1 = 27 - barGraphHeight;


Commit: d7c7f110c1f63ec91c0837e09e9a614b6eee3cb2
    https://github.com/scummvm/scummvm/commit/d7c7f110c1f63ec91c0837e09e9a614b6eee3cb2
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix pressure plate on level 0

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dm.cpp
    engines/dm/dungeonman.h
    engines/dm/movesens.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 229ed8c..71b8aa1 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -7,7 +7,7 @@ Bugs:
 	Logic:
 		When object are put on the right side of the current square, they disappear
 		Drawing door ornaments segfaults when going back to the start
-		Stepping onto the plate next doesn't open the grated gate on the 0th level
+		Placing one of the play icons from the top right corner into one of the champions' hands will crash the engine
 
 Possible bugs:
 	- k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index b3018ba..526b60e 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -322,9 +322,9 @@ Common::Error DMEngine::run() {
 
 void DMEngine::f2_gameloop() {
 	warning(false, "DUMMY CODE: SETTING PARTY POS AND DIRECTION");
-	_dungeonMan->_g306_partyMapX = 10;
-	_dungeonMan->_g307_partyMapY = 4;
-	_dungeonMan->_g308_partyDir = kDirNorth;
+	_dungeonMan->_g306_partyMapX = 9;
+	_dungeonMan->_g307_partyMapY = 9;
+	_dungeonMan->_g308_partyDir = kDirWest;
 
 	_g318_waitForInputMaxVerticalBlankCount = 10;
 	while (true) {
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index a9bc369..1a91d5d 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -315,7 +315,7 @@ public:
 	Thing getNextThing() { return _nextThing; }
 	void setNextThing(Thing thing) { _nextThing = thing; }
 	SensorType getType() { return (SensorType)(_datAndType & 0x7F); } // @ M39_TYPE
-	uint16 getData() { return _datAndType >> 7; } // @ M40_DATA
+	uint16 getData() { return (_datAndType >> 7) & 0x1FF; } // @ M40_DATA
 	static uint16 getDataMask1(uint16 data) { return (data >> 7) & 0xF; } // @ M42_MASK1
 	static uint16 getDataMask2(uint16 data) { return (data >> 11) & 0xF; } // @ M43_MASK2
 	void setData(int16 dat) { _datAndType = (_datAndType & 0x7F) | (dat << 7); } // @ M41_SET_DATA
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 34e83ca..65742e6 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -748,7 +748,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 	int16 L0767_i_ThingType;
 	bool L0768_B_TriggerSensor;
 	Sensor* L0769_ps_Sensor;
-	uint16 L0770_ui_SensorTriggeredCell;
+	int16 L0770_ui_SensorTriggeredCell;
 	uint16 L0771_ui_ThingType;
 	bool L0772_B_SquareContainsObject;
 	bool L0773_B_SquareContainsGroup;
@@ -773,7 +773,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 	if (Square(L0777_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType() == k0_ElementTypeWall) {
 		L0770_ui_SensorTriggeredCell = thing.getCell();
 	} else {
-		L0770_ui_SensorTriggeredCell = (uint16)kM1_CellAny; // this will wrap around
+		L0770_ui_SensorTriggeredCell = kM1_CellAny; // this will wrap around
 	}
 	L0772_B_SquareContainsObject = L0773_B_SquareContainsGroup = L0775_B_SquareContainsThingOfSameType = L0776_B_SquareContainsThingOfDifferentType = false;
 	L0766_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);


Commit: 247b9210e1280aef243000b954e880054b4cfaa0
    https://github.com/scummvm/scummvm/commit/247b9210e1280aef243000b954e880054b4cfaa0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some refactoring

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/champion.cpp
    engines/dm/objectman.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 71b8aa1..5dd2caf 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -8,6 +8,11 @@ Bugs:
 		When object are put on the right side of the current square, they disappear
 		Drawing door ornaments segfaults when going back to the start
 		Placing one of the play icons from the top right corner into one of the champions' hands will crash the engine
+		Sometimes putting stuff in the player's hand segfaults
+		Footprints are everywhere
+		Object display is a bit mixed up with regards to which cell is it drawn in
+		Taking the stairs teleports the player to the wrong position
+
 
 Possible bugs:
 	- k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 1590699..7b2dc00 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1162,8 +1162,6 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer)
 	}
 	_g415_leaderEmptyHanded = false;
 	_vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
-
-
 	_vm->_eventMan->f78_showMouse();
 	_vm->_objectMan->f34_drawLeaderObjectName(thing);
 	if (setMousePointer) {
@@ -1262,49 +1260,47 @@ void ChampionMan::f283_viAltarRebirth(uint16 champIndex) {
 }
 
 void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex) {
-	uint16 L0903_ui_ChampionIndex;
-	uint16 L0904_ui_SlotIndex;
-	Thing L0905_T_LeaderHandObject;
-	Thing L0906_T_SlotThing;
-
+	uint16 champIndex;
+	uint16 slotIndex;
 
 	if (slotBoxIndex < k8_SlotBoxInventoryFirstSlot) {
-		if (_vm->_championMan->_g299_candidateChampionOrdinal) {
+		if (_g299_candidateChampionOrdinal) {
 			return;
 		}
-		L0903_ui_ChampionIndex = slotBoxIndex >> 1;
-		if ((L0903_ui_ChampionIndex >= _vm->_championMan->_g305_partyChampionCount) || (_vm->M0_indexToOrdinal(L0903_ui_ChampionIndex) == (int)_vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_vm->_championMan->_gK71_champions[L0903_ui_ChampionIndex]._currHealth) {
+		champIndex = slotBoxIndex >> 1;
+		if ((champIndex >= _g305_partyChampionCount) || (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_gK71_champions[champIndex]._currHealth) {
 			return;
 		}
-		L0904_ui_SlotIndex = _vm->_championMan->M70_handSlotIndex(slotBoxIndex);
+		slotIndex = M70_handSlotIndex(slotBoxIndex);
 	} else {
-		L0903_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal);
-		L0904_ui_SlotIndex = slotBoxIndex - k8_SlotBoxInventoryFirstSlot;
+		champIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+		slotIndex = slotBoxIndex - k8_SlotBoxInventoryFirstSlot;
 	}
-	L0905_T_LeaderHandObject = _vm->_championMan->_g414_leaderHandObject;
-	if (L0904_ui_SlotIndex >= k30_ChampionSlotChest_1) {
-		L0906_T_SlotThing = _vm->_inventoryMan->_g425_chestSlots[L0904_ui_SlotIndex - k30_ChampionSlotChest_1];
+	Thing leaderHandObject = _g414_leaderHandObject;
+	Thing slotThing;
+	if (slotIndex >= k30_ChampionSlotChest_1) {
+		slotThing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
 	} else {
-		L0906_T_SlotThing = _vm->_championMan->_gK71_champions[L0903_ui_ChampionIndex]._slots[L0904_ui_SlotIndex];
+		slotThing = _gK71_champions[champIndex]._slots[slotIndex];
 	}
-	if ((L0906_T_SlotThing == Thing::_none) && (L0905_T_LeaderHandObject == Thing::_none)) {
+	if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none)) {
 		return;
 	}
-	if ((L0905_T_LeaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0905_T_LeaderHandObject)]._allowedSlots & g38_slotMasks[L0904_ui_SlotIndex]))) {
+	if ((leaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & g38_slotMasks[slotIndex]))) {
 		return;
 	}
 	_vm->_eventMan->f78_showMouse();
-	if (L0905_T_LeaderHandObject != Thing::_none) {
+	if (leaderHandObject != Thing::_none) {
 		f298_getObjectRemovedFromLeaderHand();
 	}
-	if (L0906_T_SlotThing != Thing::_none) {
-		f300_getObjectRemovedFromSlot(L0903_ui_ChampionIndex, L0904_ui_SlotIndex);
-		f297_putObjectInLeaderHand(L0906_T_SlotThing, false);
+	if (slotThing != Thing::_none) {
+		f300_getObjectRemovedFromSlot(champIndex, slotIndex);
+		f297_putObjectInLeaderHand(slotThing, false); 
 	}
-	if (L0905_T_LeaderHandObject != Thing::_none) {
-		_vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0903_ui_ChampionIndex, L0905_T_LeaderHandObject, (ChampionSlot)L0904_ui_SlotIndex);
+	if (leaderHandObject != Thing::_none) {
+		f301_addObjectInSlot((ChampionIndex)champIndex, leaderHandObject, (ChampionSlot) slotIndex);
 	}
-	_vm->_championMan->f292_drawChampionState((ChampionIndex)L0903_ui_ChampionIndex);
+	f292_drawChampionState((ChampionIndex)champIndex);
 	_vm->_eventMan->f77_hideMouse();
 }
 
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index ea07c58..40c650b 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -236,19 +236,18 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 #define k14_ObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH
 
 void ObjectMan::f34_drawLeaderObjectName(Thing thing) {
-	IconIndice iconIndex = f33_getIconIndex(thing);
-	char *objName;
-	char objectNameBuffer[16];
-	if (iconIndex == k147_IconIndiceJunkChampionBones) {
+	char* objectName = nullptr;
+	int16 L0007_i_IconIndex = _vm->_objectMan->f33_getIconIndex(thing);
+	if (L0007_i_IconIndex == k147_IconIndiceJunkChampionBones) {
 		Junk *junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing);
-		strcpy(objectNameBuffer, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name);
-		strcat(objectNameBuffer, _g352_objectNames[iconIndex]);
-		objName = objectNameBuffer;
+		char champBonesName[16];
+		strcpy(champBonesName, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name);
+		strcat(champBonesName, _vm->_objectMan->_g352_objectNames[L0007_i_IconIndex]);
+		objectName = champBonesName;
 	} else {
-		objName = _g352_objectNames[iconIndex];
+		objectName = _vm->_objectMan->_g352_objectNames[L0007_i_IconIndex];
 	}
-	_vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, 233, 37,
-											   k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength, k200_heightScreen);
+	_vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, 233, 37, k4_ColorCyan, k0_ColorBlack, objectName, k14_ObjectNameMaximumLength, k200_heightScreen);
 }
 
 IconIndice ObjectMan::f39_getIconIndexInSlotBox(uint16 slotBoxIndex) {


Commit: ac1b49496d13f173bc08274808b1c1878e743a11
    https://github.com/scummvm/scummvm/commit/ac1b49496d13f173bc08274808b1c1878e743a11
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix setting _g309_partyMapIndex when moving between levels

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 5dd2caf..d49ec22 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -11,7 +11,7 @@ Bugs:
 		Sometimes putting stuff in the player's hand segfaults
 		Footprints are everywhere
 		Object display is a bit mixed up with regards to which cell is it drawn in
-		Taking the stairs teleports the player to the wrong position
+		Activegroup index segfaults when aknig the stairs
 
 
 Possible bugs:
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 3d1f931..063ccd0 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -735,7 +735,7 @@ void DungeonMan::f173_setCurrentMap(uint16 mapIndex) {
 }
 
 void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) {
-	f173_setCurrentMap(mapIndex);
+	f173_setCurrentMap(_g309_partyMapIndex = mapIndex);
 
 	byte *metaMapData = _g271_currMapData[_g273_currMapWidth - 1] + _g274_currMapHeight;
 	_vm->_displayMan->_g264_currMapAllowedCreatureTypes = metaMapData;


Commit: bd9fa3eb87a08dd7ba6387ac7c2d911a040cd9c4
    https://github.com/scummvm/scummvm/commit/bd9fa3eb87a08dd7ba6387ac7c2d911a040cd9c4
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Engine now correctly set's the activeGroupIndex of groups

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dungeonman.cpp
    engines/dm/group.cpp
    engines/dm/group.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index d49ec22..4aa4d36 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -11,7 +11,7 @@ Bugs:
 		Sometimes putting stuff in the player's hand segfaults
 		Footprints are everywhere
 		Object display is a bit mixed up with regards to which cell is it drawn in
-		Activegroup index segfaults when aknig the stairs
+		The last resurrected character can't have stuff in their left hand, segfaults if I try to put stuff into it
 
 
 Possible bugs:
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 063ccd0..956232b 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1396,19 +1396,16 @@ int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDe
 	int16 targetMapIndex;
 
 
-	if (_vm->_dungeonMan->_g309_partyMapIndex == k255_mapIndexEntrance) {
+	if (_g309_partyMapIndex == k255_mapIndexEntrance) {
 		return kM1_mapIndexNone;
 	}
-	map = _vm->_dungeonMan->_g277_dungeonMaps + mapIndex;
+	map = _g277_dungeonMaps + mapIndex;
 	newMapX = map->_offsetMapX + *mapX;
 	newMapY = map->_offsetMapY + *mapY;
 	newLevel = map->_level + levelDelta;
-	map = _vm->_dungeonMan->_g277_dungeonMaps;
-	for (targetMapIndex = 0; targetMapIndex < _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount; targetMapIndex++) {
-		if ((map->_level == newLevel)
-			&& (newMapX >= (offset = map->_offsetMapX))
-			&& (newMapX <= (offset + map->_width))
-			&& (newMapY >= (offset = map->_offsetMapY)) && (newMapY <= (offset + map->_height))) {
+	map = _g277_dungeonMaps;
+	for (targetMapIndex = 0; targetMapIndex < _g278_dungeonFileHeader._mapCount; targetMapIndex++) {
+		if ((map->_level == newLevel) && (newMapX >= (offset = map->_offsetMapX)) && (newMapX <= (offset + map->_width)) && (newMapY >= (offset = map->_offsetMapY)) && (newMapY <= (offset + map->_height))) {
 			*mapY = newMapY - offset;
 			*mapX = newMapX - map->_offsetMapX;
 			return targetMapIndex;
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 617735e..edb6056 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1691,17 +1691,16 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
 	L0344_i_ActiveGroupIndex = 0;
 	while (L0341_ps_ActiveGroup->_groupThingIndex >= 0) {
 		if (++L0344_i_ActiveGroupIndex >= _vm->_groupMan->_g376_maxActiveGroupCount) {
-			return; /* BUG0_11 Data corruption in memory. Each group located on the same map as the party has additional associated data but there is only provision for 60 instances (_vm->_groupMan->_g376_maxActiveGroupCount). If there are more groups at the same time then some of them do not get their instance and when the game accesses this information it will corrupt other data in memory (either the instance of another group, parts of the timeline or events). This situation cannot occur in the original Dungeon Master and Chaos Strikes Back dungeons for the following reasons (but it may occur in custom dungeons if they are not designed carefully): there is no map with already more than 60 groups in the original dungeons and none of the following 3 possible ways to move a group into a map can increase the number of instances above the maximum of 60:
-					- A group generator sensor is triggered: the game never generates a group on the party map if there are less than 5 instances available. This limits the actual number of groups on a map to 55 in most cases.
-					- A group falls through a pit from the map above (the creature type must be allowed on the target map): a group will never willingly move to an open pit square. It may move to a closed pit square and fall if the pit is then open (either automatically or triggered by the party on the map below). There are no such pits in the original dungeons.
-					- A group is teleported from another map (the creature type must be allowed on the target map): in the original dungeons, all teleporters whose scope include groups and target another map are either inaccessible to groups or the groups are not allowed on the target map. The only exception is for some Gigglers in the Chaos Strikes Back dungeon but there are not enough to use the 5 reserved instances.
-
-					This code returns immediately if all ACTIVE_GROUP entries are already in use, which avoids an out of bounds access into _vm->_groupMan->_g375_activeGroups below (through L0341_ps_ActiveGroup). However in this case the specified group ends up without an associated ACTIVE_GROUP structure which is assumed everywhere in the code to be present for groups on the same map as the party. If there are more than 60 groups on the party map at any given time then this will corrupt memory (in _vm->_timeline->_g370_events and _vm->_timeline->_g371_timeline allocated in _vm->_timeline->f233_initTimeline before _vm->_groupMan->_g375_activeGroups) because of read and write operations at incorrect memory addresses (the 'Cells' value of the GROUP will be used as an index in _vm->_groupMan->_g375_activeGroups even though that value was not replaced by the index of an ACTIVE_GROUP in this function) */
+			return; 
 		}
 		L0341_ps_ActiveGroup++;
 	}
 	_g377_currActiveGroupCount++;
-	L0340_ps_Group = ((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType());
+
+	warning(false, "Code differs from the original in GroupMan::f183_addActiveGroup");
+	//L0340_ps_Group = ((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType());
+	L0340_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(f175_groupGetThing(mapX, mapY));
+
 	L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells;
 	L0340_ps_Group->getActiveGroupIndex() = L0344_i_ActiveGroupIndex;
 	L0341_ps_ActiveGroup->_priorMapX = L0341_ps_ActiveGroup->_homeMapX = mapX;
diff --git a/engines/dm/group.h b/engines/dm/group.h
index fd7d98a..6578a20 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -114,7 +114,6 @@ public:
 	uint16 _type;
 	uint16 _cells;
 	uint16 _health[4];
-private:
 	uint16 _flags;
 public:
 	explicit Group(uint16 *rawDat) : _nextThing(rawDat[0]), _slot(rawDat[1]), _type(rawDat[2]),
@@ -125,7 +124,7 @@ public:
 		_health[3] = rawDat[7];
 	}
 
-	byte &getActiveGroupIndex() { return *(byte*)&_cells; }
+	uint16 &getActiveGroupIndex() { return _cells; }
 
 	uint16 getBehaviour() { return _flags & 0xF; }
 	uint16 setBehaviour(uint16 val) { _flags = (_flags & ~0xF) | (val & 0xF); return (val & 0xF); }


Commit: 11704d0c509c1fc5af73c22bd64be60572ff4b8c
    https://github.com/scummvm/scummvm/commit/11704d0c509c1fc5af73c22bd64be60572ff4b8c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add savegame functions

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.h
    engines/dm/group.cpp
    engines/dm/group.h
    engines/dm/loadsave.cpp
    engines/dm/loadsave.h
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 7b2dc00..f22d4dd 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1295,10 +1295,10 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex)
 	}
 	if (slotThing != Thing::_none) {
 		f300_getObjectRemovedFromSlot(champIndex, slotIndex);
-		f297_putObjectInLeaderHand(slotThing, false); 
+		f297_putObjectInLeaderHand(slotThing, false);
 	}
 	if (leaderHandObject != Thing::_none) {
-		f301_addObjectInSlot((ChampionIndex)champIndex, leaderHandObject, (ChampionSlot) slotIndex);
+		f301_addObjectInSlot((ChampionIndex)champIndex, leaderHandObject, (ChampionSlot)slotIndex);
 	}
 	f292_drawChampionState((ChampionIndex)champIndex);
 	_vm->_eventMan->f77_hideMouse();
@@ -1702,6 +1702,68 @@ void ChampionMan::f331_applyTimeEffects() {
 	f293_drawAllChampionStates();
 }
 
+void ChampionMan::save2_PartyPart(Common::OutSaveFile* file) {
+	for (uint16 i = 0; i < 4; ++i) {
+		Champion *champ = &_gK71_champions[i];
+		file->writeUint16BE(champ->_attributes);
+		file->writeUint16BE(champ->_wounds);
+		for (uint16 y = 0; y < 7; ++y)
+			for (uint16 x = 0; x < 3; ++x)
+				file->writeByte(champ->_statistics[y][x]);
+		for (uint16 j = 0; j < 30; ++j)
+			file->writeUint16BE(champ->_slots[j].toUint16());
+		for (uint16 j = 0; j < 20; ++j) {
+			file->writeSint16BE(champ->_skills[j]._temporaryExperience);
+			file->writeSint32BE(champ->_skills[j]._experience);
+		}
+		for (uint16 j = 0; j < 8; ++j)
+			file->writeByte(champ->_name[j]);
+		for (uint16 j = 0; j < 20; ++j)
+			file->writeByte(champ->_title[j]);
+		file->writeUint16BE(champ->_dir);
+		file->writeUint16BE(champ->_cell);
+		file->writeUint16BE(champ->_actionIndex);
+		file->writeUint16BE(champ->_symbolStep);
+		for(uint16 j = 0; j < 5; ++j)
+			file->writeByte(champ->_symbols[j]);
+		file->writeUint16BE(champ->_directionMaximumDamageReceived);
+		file->writeUint16BE(champ->_maximumDamageReceived);
+		file->writeUint16BE(champ->_poisonEventCount);
+		file->writeSint16BE(champ->_enableActionEventIndex);
+		file->writeSint16BE(champ->_hideDamageReceivedIndex);
+		file->writeSint16BE(champ->_currHealth);
+		file->writeSint16BE(champ->_maxHealth);
+		file->writeSint16BE(champ->_currStamina);
+		file->writeSint16BE(champ->_maxStamina);
+		file->writeSint16BE(champ->_currMana);
+		file->writeSint16BE(champ->_maxMana);
+		file->writeSint16BE(champ->_actionDefense);
+		file->writeSint16BE(champ->_food);
+		file->writeSint16BE(champ->_water);
+		file->writeUint16BE(champ->_load);
+		file->writeSint16BE(champ->_shieldDefense);
+		for (uint16 j = 0; j < 928; ++j)
+			file->writeByte(champ->_portrait[j]);
+	}
+
+	Party &party = _g407_party;
+	file->writeSint16BE(party._magicalLightAmount);
+	file->writeByte(party._event73Count_ThievesEye);
+	file->writeByte(party._event79Count_Footprints);
+	file->writeSint16BE(party._shieldDefense);
+	file->writeSint16BE(party._fireShieldDefense);
+	file->writeSint16BE(party._spellShieldDefense);
+	file->writeByte(party._scentCount);
+	file->writeByte(party._freezeLifeTicks);
+	file->writeByte(party._firstScentIndex);
+	file->writeByte(party._lastScentIndex);
+	for(uint16 i = 0; i < 24; ++i)
+		file->writeUint16BE(party._scents[i].toUint16());
+	for (uint16 i = 0; i < 24; ++i)
+		file->writeByte(party._scentStrengths[i]);
+	file->writeByte(party._event71Count_Invisibility);
+}
+
 ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
 	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
 		if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index d4491d5..85afd6f 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -580,6 +580,7 @@ public:
 	void f318_dropAllObjects(uint16 champIndex); // @ F0318_CHAMPION_DropAllObjects
 	void f323_unpoison(int16 champIndex); // @ F0323_CHAMPION_Unpoison
 	void f331_applyTimeEffects(); // @ F0331_CHAMPION_ApplyTimeEffects_CPSF
+	void save2_PartyPart(Common::OutSaveFile *file);
 };
 
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 526b60e..d401c7b 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -140,7 +140,6 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_eventMan = nullptr;
 	_menuMan = nullptr;
 	_championMan = nullptr;
-	_loadsaveMan = nullptr;
 	_objectMan = nullptr;
 	_inventoryMan = nullptr;
 	_textMan = nullptr;
@@ -149,6 +148,10 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_timeline = nullptr;
 	_projexpl = nullptr;
 
+	_g528_saveFormat = 0;
+	_g527_platform = 0;
+	_g526_dungeonId = 0;
+
 	_g298_newGame = false;
 	_g523_restartGameRequest = false;
 	_g321_stopWaitingForPlayerInput = true;
@@ -187,7 +190,6 @@ DMEngine::~DMEngine() {
 	delete _eventMan;
 	delete _menuMan;
 	delete _championMan;
-	delete _loadsaveMan;
 	delete _objectMan;
 	delete _inventoryMan;
 	delete _textMan;
@@ -220,7 +222,7 @@ void DMEngine::f463_initializeGame() {
 	_objectMan->loadObjectNames();
 	_eventMan->initMouse();
 	//F0441_STARTEND_ProcessEntrance();
-	while (_loadsaveMan->f435_loadgame() != k1_LoadgameSuccess) {
+	while (f435_loadgame() != k1_LoadgameSuccess) {
 		warning(false, "TODO: F0441_STARTEND_ProcessEntrance");
 	}
 	//F0396_MENUS_LoadSpellAreaLinesBitmap() is not needed, every bitmap has been loaded
@@ -301,7 +303,6 @@ Common::Error DMEngine::run() {
 	_eventMan = new EventManager(this);
 	_menuMan = new MenuMan(this);
 	_championMan = new ChampionMan(this);
-	_loadsaveMan = new LoadsaveMan(this);
 	_objectMan = new ObjectMan(this);
 	_inventoryMan = new InventoryMan(this);
 	_textMan = new TextMan(this);
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index dce88f1..dfc7b4c 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -31,6 +31,8 @@
 #include "common/random.h"
 #include "engines/engine.h"
 #include "gui/debugger.h"
+#include "common/savefile.h"
+#include "common/str.h"
 
 
 namespace DM {
@@ -41,7 +43,6 @@ class DungeonMan;
 class EventManager;
 class MenuMan;
 class ChampionMan;
-class LoadsaveMan;
 class ObjectMan;
 class InventoryMan;
 class TextMan;
@@ -50,6 +51,7 @@ class GroupMan;
 class Timeline;
 class ProjExpl;
 
+
 void warning(bool repeat, const char *s, ...);
 
 enum direction {
@@ -177,6 +179,11 @@ inline T f26_getBoundedValue(T min, T val, T max) {
 #define k99_modeWaitingOnEntrance 99 // @ C099_MODE_WAITING_ON_ENTRANCE   
 #define k202_modeEntranceDrawCredits 202 // @ C202_MODE_ENTRANCE_DRAW_CREDITS 
 
+enum LoadgameResponse {
+	kM1_LoadgameFailure = -1, // @ CM1_LOAD_GAME_FAILURE
+	k1_LoadgameSuccess = 1// @ C01_LOAD_GAME_SUCCESS
+};
+
 class DMEngine : public Engine {
 	void f462_startGame(); // @ F0462_START_StartGame_CPSF
 	void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
@@ -184,6 +191,8 @@ class DMEngine : public Engine {
 	void f448_initMemoryManager(); // @ F0448_STARTUP1_InitializeMemoryManager_CPSADEF
 	void f2_gameloop(); // @ F0002_MAIN_GameLoop_CPSDF
 	void initArrays();
+	Common::String getSavefileName(uint16 slot);
+	void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
 public:
 	explicit DMEngine(OSystem *syst);
 	~DMEngine();
@@ -195,8 +204,13 @@ public:
 	int16 M0_indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
 	void f19_displayErrorAndStop(int16 errorIndex); // @ F0019_MAIN_DisplayErrorAndStop
 	virtual Common::Error run(); // @ main
+	void f433_processCommand140_saveGame(uint16 slot, const Common::String desc); // @ F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF
+	LoadgameResponse f435_loadgame(); // @ F0435_STARTEND_LoadGame_CPSF
 
 private:
+	int16 _g528_saveFormat; // @ G0528_i_Format
+	int16 _g527_platform; // @ G0527_i_Platform
+	uint16 _g526_dungeonId; // @ G0526_ui_DungeonID
 	Console *_console;
 public:
 	Common::RandomSource *_rnd;
@@ -205,7 +219,6 @@ public:
 	EventManager *_eventMan;
 	MenuMan *_menuMan;
 	ChampionMan *_championMan;
-	LoadsaveMan *_loadsaveMan;
 	ObjectMan *_objectMan;
 	InventoryMan *_inventoryMan;
 	TextMan *_textMan;
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 1a91d5d..b3e4194 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -604,7 +604,7 @@ public:
 }; // wrapper for bytes which are used as squares
 
 struct DungeonFileHeader {
-	uint16 _dungeonId; // @ G0526_ui_DungeonID
+	uint16 _dungeonId;
 	// equal to dungeonId
 	uint16 _ornamentRandomSeed;
 	uint32 _rawMapDataSize;
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index edb6056..5961f7c 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1691,7 +1691,7 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
 	L0344_i_ActiveGroupIndex = 0;
 	while (L0341_ps_ActiveGroup->_groupThingIndex >= 0) {
 		if (++L0344_i_ActiveGroupIndex >= _vm->_groupMan->_g376_maxActiveGroupCount) {
-			return; 
+			return;
 		}
 		L0341_ps_ActiveGroup++;
 	}
@@ -2056,4 +2056,24 @@ void GroupMan::f225_fuseAction(uint16 mapX, uint16 mapY) {
 		warning(false, "F0446_STARTEND_FuseSequence()");
 	}
 }
+
+void GroupMan::save1_ActiveGroupPart(Common::OutSaveFile* file) {
+	for (uint16 i = 0; i < _g376_maxActiveGroupCount; ++i) {
+		ActiveGroup *group = &_g375_activeGroups[i];
+		file->writeUint16BE(group->_groupThingIndex);
+		file->writeUint16BE(group->_directions);
+		file->writeByte(group->_cells);
+		file->writeByte(group->_lastMoveTime);
+		file->writeByte(group->_delayFleeingFromTarget);
+		file->writeByte(group->_targetMapX);
+		file->writeByte(group->_targetMapY);
+		file->writeByte(group->_priorMapX);
+		file->writeByte(group->_priorMapY);
+		file->writeByte(group->_homeMapX);
+		file->writeByte(group->_homeMapY);
+		for (uint16 j = 0; j < 4; ++j)
+			file->writeByte(group->_aspect[j]);
+	}
+}
+
 }
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 6578a20..2ad2d8d 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -92,7 +92,7 @@ enum CreatureType {
 
 class ActiveGroup {
 public:
-	int _groupThingIndex;
+	int16 _groupThingIndex;
 	direction _directions;
 	byte _cells;
 	byte _lastMoveTime;
@@ -244,6 +244,7 @@ public:
 	uint16 f222_isLordChaosOnSquare(int16 mapX, int16 mapY); // @ F0222_GROUP_IsLordChaosOnSquare
 	bool f221_isFluxcageOnSquare(int16 mapX, int16 mapY); // @ F0221_GROUP_IsFluxcageOnSquare
 	void f225_fuseAction(uint16 mapX, uint16 mapY); // @ F0225_GROUP_FuseAction
+	void save1_ActiveGroupPart(Common::OutSaveFile *file);
 };
 
 
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 81a914c..9d705ef 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -24,39 +24,45 @@
 * Based on the Reverse Engineering work of Christophe Fontanel,
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
+#include "common/system.h"
+#include "common/savefile.h"
+#include "graphics/thumbnail.h"
 
-#include "loadsave.h"
+#include "dm.h"
 #include "dungeonman.h"
-#include "champion.h"
-#include "group.h"
 #include "timeline.h"
-
+#include "group.h"
+#include "champion.h"
+#include "menus.h"
+#include "eventman.h"
+#include "projexpl.h"
 
 
 namespace DM {
-
-LoadsaveMan::LoadsaveMan(DMEngine *vm) : _vm(vm) {}
-
-
-LoadgameResponse LoadsaveMan::f435_loadgame() {
-	bool newGame = _vm->_g298_newGame;
-	ChampionMan &cm = *_vm->_championMan;
-
+#define C2_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST 2
+#define C3_PLATFORM_AMIGA 3
+#define C10_DUNGEON_DM 10
+LoadgameResponse DMEngine::f435_loadgame() {
+	bool newGame = _g298_newGame;
+	ChampionMan &cm = *_championMan;
+	_g528_saveFormat = C2_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST;
+	_g527_platform = C3_PLATFORM_AMIGA;
+	_g526_dungeonId = C10_DUNGEON_DM;
 	if (newGame) {
-		_vm->_g524_restartGameAllowed = false;
+		_g524_restartGameAllowed = false;
 		cm._g305_partyChampionCount = 0;
 		cm._g414_leaderHandObject = Thing::_none;
-		_vm->_g525_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536);
+		_g525_gameId = _rnd->getRandomNumber(65536) * _rnd->getRandomNumber(65536);
 	} else {
 		assert(false);
 		// MISSING CODE: load game
 	}
-	_vm->_dungeonMan->f434_loadDungeonFile();
+	_dungeonMan->f434_loadDungeonFile();
 
 
 	if (newGame) {
-		_vm->_timeline->f233_initTimeline();
-		_vm->_groupMan->f196_initActiveGroups();
+		_timeline->f233_initTimeline();
+		_groupMan->f196_initActiveGroups();
 	} else {
 		assert(false);
 		// MISSING CODE: load game
@@ -65,4 +71,110 @@ LoadgameResponse LoadsaveMan::f435_loadgame() {
 	return k1_LoadgameSuccess;
 }
 
-}
\ No newline at end of file
+
+void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String desc) {
+	char *message = nullptr;
+
+	_menuMan->f456_drawDisabledMenu();
+	_eventMan->f78_showMouse();
+
+	// do {
+	//		ask the play what he wants
+	// while 
+
+	// F0427_DIALOG_Draw(0, G0551_pc_SAVINGGAME, 0, 0, 0, 0, false, false, false);
+
+	uint16 champHandObjWeight;
+	if (!_championMan->_g415_leaderEmptyHanded) {
+		champHandObjWeight = _dungeonMan->f140_getObjectWeight(_championMan->_g414_leaderHandObject);
+		_championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load -= champHandObjWeight;
+	}
+
+
+	Common::String savefileName = getSavefileName(slot);
+	Common::SaveFileManager *saveFileManager = _system->getSavefileManager();
+	Common::OutSaveFile *file = saveFileManager->openForSaving(savefileName);
+
+	if (!file)
+		return; // TODO: silent fail
+
+	writeSaveGameHeader(file, desc);
+
+	// write C0_SAVE_PART_GLOBAL_DATA part
+	file->writeUint32BE(_g313_gameTime);
+	//L1348_s_GlobalData.LastRandomNumber = G0349_ul_LastRandomNumber;
+	file->writeUint16BE(_championMan->_g305_partyChampionCount);
+	file->writeSint16BE(_dungeonMan->_g306_partyMapX);
+	file->writeSint16BE(_dungeonMan->_g307_partyMapY);
+	file->writeUint16BE(_dungeonMan->_g308_partyDir);
+	file->writeByte(_dungeonMan->_g309_partyMapIndex);
+	file->writeSint16BE(_championMan->_g411_leaderIndex);
+	file->writeSint16BE(_championMan->_g514_magicCasterChampionIndex);
+	file->writeUint16BE(_timeline->_g372_eventCount);
+	file->writeUint16BE(_timeline->_g373_firstUnusedEventIndex);
+	file->writeUint16BE(_timeline->_g369_eventMaxCount);
+	file->writeUint16BE(_groupMan->_g377_currActiveGroupCount);
+	file->writeSint32BE(_projexpl->_g361_lastCreatureAttackTime);
+	file->writeSint32BE(_projexpl->_g362_lastPartyMovementTime);
+	file->writeSint16BE(_g310_disabledMovementTicks);
+	file->writeSint16BE(_g311_projectileDisableMovementTicks);
+	file->writeSint16BE(_g312_lastProjectileDisabledMovementDirection);
+	file->writeUint16BE(_championMan->_g414_leaderHandObject.toUint16());
+	file->writeUint16BE(_groupMan->_g376_maxActiveGroupCount);
+
+	// write C1_SAVE_PART_ACTIVE_GROUP part
+	_groupMan->save1_ActiveGroupPart(file);
+	// write C2_SAVE_PART_PARTY part
+	_championMan->save2_PartyPart(file);
+	// write C3_SAVE_PART_EVENTS part
+	_timeline->save3_eventsPart(file);
+	// write C4_SAVE_PART_TIMELINE part
+	_timeline->save4_timelinePart(file);
+
+	file->writeSint32BE(_g525_gameId);
+	file->writeSint16BE(_g528_saveFormat);
+	file->writeSint16BE(_g527_platform);
+	file->writeUint16BE(_g526_dungeonId);
+
+	warning(false, "MISSING CODE in save game");
+
+	file->flush();
+	file->finalize();
+	delete file;
+}
+
+Common::String DMEngine::getSavefileName(uint16 slot) {
+	return Common::String::format("%s.%03u", _targetName.c_str(), slot);
+}
+
+#define SAVEGAME_ID       MKTAG('D', 'M', 'D', 'M')
+#define SAVEGAME_VERSION  1
+
+void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::String& saveName) {
+	out->writeUint32BE(SAVEGAME_ID);
+
+	// Write version
+	out->writeByte(SAVEGAME_VERSION);
+
+	// Write savegame name
+	out->writeString(saveName);
+	out->writeByte(0);
+
+	// Save the game thumbnail
+	Graphics::saveThumbnail(*out);
+
+	// Creation date/time
+	TimeDate curTime;
+	_system->getTimeAndDate(curTime);
+
+	uint32 saveDate = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
+	uint16 saveTime = ((curTime.tm_hour & 0xFF) << 8) | ((curTime.tm_min) & 0xFF);
+	uint32 playTime = getTotalPlayTime() / 1000;
+
+	out->writeUint32BE(saveDate);
+	out->writeUint16BE(saveTime);
+	out->writeUint32BE(playTime);
+}
+
+
+}
diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h
index c45b111..85ed8a0 100644
--- a/engines/dm/loadsave.h
+++ b/engines/dm/loadsave.h
@@ -32,17 +32,13 @@
 
 namespace DM {
 
-enum LoadgameResponse {
-	kM1_LoadgameFailure = -1, // @ CM1_LOAD_GAME_FAILURE
-	k1_LoadgameSuccess = 1// @ C01_LOAD_GAME_SUCCESS
-};
+;
 
 class LoadsaveMan {
 	DMEngine *_vm;
 public:
 	explicit LoadsaveMan(DMEngine *vm);
 
-	LoadgameResponse f435_loadgame(); // @ F0435_STARTEND_LoadGame_CPSF
 };
 
 }
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 3858ad5..afeb577 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -1087,4 +1087,23 @@ T0255002:
 		_vm->_championMan->f283_viAltarRebirth(event->_priority);
 	}
 }
+
+void Timeline::save3_eventsPart(Common::OutSaveFile* file) {
+	for (uint16 i = 0; i < _g369_eventMaxCount; ++i) {
+		TimelineEvent *event = &_g370_events[i];
+		file->writeSint32BE(event->_mapTime);
+		file->writeByte(event->_type);
+		file->writeByte(event->_priority);
+		file->writeByte(event->_B._location._mapX); // writing bytes of the union I think should preserve the union's identity
+		file->writeByte(event->_B._location._mapY);
+		file->writeUint16BE(event->_C.A._cell); // writing bytes of the union I think should preserve the union's identity
+		file->writeUint16BE(event->_C.A._effect);
+	}
+}
+
+void Timeline::save4_timelinePart(Common::OutSaveFile* file) {
+	for (uint16 i = 0; i < _g369_eventMaxCount; ++i)
+		file->writeUint16BE(_g371_timeline[i]);
+}
+
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 08c6ce1..8f68c35 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -187,6 +187,8 @@ public:
 	void f257_timelineProcessEvent70_light(TimelineEvent *event); // @ F0257_TIMELINE_ProcessEvent70_Light
 	void f260_timelineRefreshAllChampionStatusBoxes(); // @ F0260_TIMELINE_RefreshAllChampionStatusBoxes
 	void f255_timelineProcessEvent13_ViAltarRebirth(TimelineEvent *event); // @ F0255_TIMELINE_ProcessEvent13_ViAltarRebirth
+	void save3_eventsPart(Common::OutSaveFile *file);
+	void save4_timelinePart(Common::OutSaveFile *file);
 };
 
 


Commit: aacecd6c06b08c719077130cfd113f302b51923b
    https://github.com/scummvm/scummvm/commit/aacecd6c06b08c719077130cfd113f302b51923b
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add entrance processing

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/detection.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/loadsave.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 4aa4d36..d416272 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -31,4 +31,5 @@ Todo:
 Finish stuff:
 	f380_processCommandQueue
 	Missing main loop methods
+	Save file f433_processCommand140_saveGame fails silently
 
diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp
index 1d31a74..7d1c463 100644
--- a/engines/dm/detection.cpp
+++ b/engines/dm/detection.cpp
@@ -83,7 +83,7 @@ public:
 	}
 
 	virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { return gameDescriptions; }
-	virtual bool hasFeature(MetaEngineFeature f) const { return false; }
+
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
 		if(desc)
 			*engine = new DM::DMEngine(syst);
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index d401c7b..2861cf1 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -172,6 +172,9 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_g313_gameTime = 0;
 	_g353_stringBuildBuffer[0] = '\0';
 	_g318_waitForInputMaxVerticalBlankCount = 0;
+	for (uint16 i = 0; i < 10; ++i)
+		_g562_entranceDoorAnimSteps[i] = nullptr;
+	_g564_interfaceCredits = nullptr;
 	debug("DMEngine::DMEngine");
 
 
@@ -202,6 +205,12 @@ DMEngine::~DMEngine() {
 	DebugMan.clearAllDebugChannels();
 }
 
+bool DMEngine::hasFeature(EngineFeature f) const {
+	return
+		(f == kSupportsSavingDuringRuntime) ||
+		(f == kSupportsLoadingDuringRuntime);
+}
+
 void DMEngine::f22_delay(uint16 verticalBlank) {
 	_system->delayMillis(verticalBlank * 20); // Google says most Amiga games had a refreshrate of 50 hz
 }
@@ -221,9 +230,9 @@ void DMEngine::f463_initializeGame() {
 	_textMan->f54_textInitialize();
 	_objectMan->loadObjectNames();
 	_eventMan->initMouse();
-	//F0441_STARTEND_ProcessEntrance();
+	f441_processEntrance();
 	while (f435_loadgame() != k1_LoadgameSuccess) {
-		warning(false, "TODO: F0441_STARTEND_ProcessEntrance");
+		f441_processEntrance();
 	}
 	//F0396_MENUS_LoadSpellAreaLinesBitmap() is not needed, every bitmap has been loaded
 
@@ -423,4 +432,103 @@ int16 DMEngine::M0_indexToOrdinal(int16 val) {
 	return val + 1;
 }
 
+
+void DMEngine::f441_processEntrance() {
+	uint16 L1402_ui_AnimationStep;
+	Box L1405_s_Box;
+
+	_eventMan->_g441_primaryMouseInput = g445_PrimaryMouseInput_Entrance;
+	_eventMan->_g442_secondaryMouseInput = nullptr;
+	_eventMan->_g443_primaryKeyboardInput = nullptr;
+	_eventMan->_g444_secondaryKeyboardInput = nullptr;
+	_g562_entranceDoorAnimSteps[0] = new byte[128 * 161 * 12];
+	for (L1402_ui_AnimationStep = 1; L1402_ui_AnimationStep < 8; L1402_ui_AnimationStep++) {
+		_g562_entranceDoorAnimSteps[L1402_ui_AnimationStep] = _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep - 1] + 128 * 161;
+	}
+	_g562_entranceDoorAnimSteps[8] = _g562_entranceDoorAnimSteps[7] + 128 * 161;
+	_g562_entranceDoorAnimSteps[9] = _g562_entranceDoorAnimSteps[8] + 128 * 161 * 2;
+
+	_displayMan->f466_loadIntoBitmap(k3_entranceRightDoorGraphicIndice, _g562_entranceDoorAnimSteps[4]);
+	_displayMan->f466_loadIntoBitmap(k2_entranceLeftDoorGraphicIndice, _g562_entranceDoorAnimSteps[0]);
+	_g564_interfaceCredits = _displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice);
+	_displayMan->_g578_useByteBoxCoordinates = false;
+	L1405_s_Box._x1 = 0;
+	L1405_s_Box._x2 = 100;
+	L1405_s_Box._y1 = 0;
+	L1405_s_Box._y2 = 160;
+	for (L1402_ui_AnimationStep = 1; L1402_ui_AnimationStep < 4; L1402_ui_AnimationStep++) {
+		_displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[0], _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep], L1405_s_Box, L1402_ui_AnimationStep << 2, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161);
+		L1405_s_Box._x2 -= 4;
+	}
+	L1405_s_Box._x2 = 127;
+	for (L1402_ui_AnimationStep = 5; L1402_ui_AnimationStep < 8; L1402_ui_AnimationStep++) {
+		L1405_s_Box._x1 += 4;
+		_displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[4], _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep], L1405_s_Box, 0, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161);
+	}
+	do {
+		f439_drawEntrance();
+		//_eventMan->f77_hideMouse();
+		//_eventMan->f77_hideMouse();
+		_eventMan->f78_showMouse();
+		_eventMan->f357_discardAllInput();
+		_g298_newGame = k99_modeWaitingOnEntrance;
+		do {
+			_eventMan->processInput();
+			_eventMan->f380_processCommandQueue();
+			_displayMan->updateScreen();
+		} while (_g298_newGame == k99_modeWaitingOnEntrance);
+	} while (_g298_newGame == k202_CommandEntranceDrawCredits);
+	//Strangerke: CHECKME: Earlier versions were using G0566_puc_Graphic534_Sound01Switch
+	warning(false, "MISSING CODE: F0060_SOUND_Play");
+	f22_delay(20);
+	_eventMan->f78_showMouse();
+	if (_g298_newGame) {
+		warning(false, "MISSING CODE: F0438_STARTEND_OpenEntranceDoors();");
+	}
+	delete[] _g562_entranceDoorAnimSteps[0];
+	for (uint16 i = 0; i < 10; ++i)
+		_g562_entranceDoorAnimSteps[i] = nullptr;
+}
+
+
+void DMEngine::f439_drawEntrance() {
+	static Box K0079_s_Box_Entrance_DoorsUpperHalf = {0, 231, 0, 80};
+	static Box K0152_s_Box_Entrance_DoorsLowerHalf = {0, 231, 81, 160};
+	static Box G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft = {0, 104, 30, 190};
+	static Box G0011_s_Graphic562_Box_Entrance_ClosedDoorRight = {105, 231, 30, 190};
+
+	uint16 L1397_ui_ColumnIndex;
+	byte* L1398_apuc_MicroDungeonCurrentMapData[32];
+	Square L1399_auc_MicroDungeonSquares[25];
+
+	_dungeonMan->_g309_partyMapIndex = k255_mapIndexEntrance;
+	_displayMan->_g297_drawFloorAndCeilingRequested = true;
+	_dungeonMan->_g273_currMapWidth = 5;
+	_dungeonMan->_g274_currMapHeight = 5;
+	_dungeonMan->_g271_currMapData = L1398_apuc_MicroDungeonCurrentMapData;
+
+	Map map; // uninitialized, won't be used
+	_dungeonMan->_g269_currMap = ↦ 
+	for (uint16 i = 0; i < 25; ++i)
+		L1399_auc_MicroDungeonSquares[i] = Square(k0_ElementTypeWall, 0);
+	for (L1397_ui_ColumnIndex = 0; L1397_ui_ColumnIndex < 5; L1397_ui_ColumnIndex++) {
+		L1398_apuc_MicroDungeonCurrentMapData[L1397_ui_ColumnIndex] = (byte*)&L1399_auc_MicroDungeonSquares[L1397_ui_ColumnIndex * 5];
+		L1399_auc_MicroDungeonSquares[L1397_ui_ColumnIndex + 10] = Square(k1_CorridorElemType, 0);
+	}
+	L1399_auc_MicroDungeonSquares[7] = Square(k1_CorridorElemType, 0);
+	warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(G0345_aui_BlankBuffer);");
+
+	// note, a global variable is used here in the original
+	_displayMan->f466_loadIntoBitmap(k4_entranceGraphicIndice, _displayMan->_g348_bitmapScreen);
+	_displayMan->f128_drawDungeon(kDirSouth, 2, 0);
+	warning(false, "IGNORED CODE: G0324_B_DrawViewportRequested = false;");
+
+	_displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], K0079_s_Box_Entrance_DoorsUpperHalf, 0, 30, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
+	_displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], K0152_s_Box_Entrance_DoorsLowerHalf, 0, 111, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
+
+	_displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[0], &G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft, k64_byteWidth, kM1_ColorNoTransparency, 161);
+	_displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[4], &G0011_s_Graphic562_Box_Entrance_ClosedDoorRight, k64_byteWidth, kM1_ColorNoTransparency, 161);
+	warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(g20_PalEntrance);");
+}
+
 } // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index dfc7b4c..cbc0bd3 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -193,11 +193,13 @@ class DMEngine : public Engine {
 	void initArrays();
 	Common::String getSavefileName(uint16 slot);
 	void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
+	void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance
 public:
 	explicit DMEngine(OSystem *syst);
 	~DMEngine();
+	virtual bool hasFeature(EngineFeature f) const;
 
-	void f22_delay(uint16 ms); // @ F0022_MAIN_Delay
+	void f22_delay(uint16 verticalBlank); // @ F0022_MAIN_Delay
 	uint16 f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2); // @ F0030_MAIN_GetScaledProduct
 	uint16 getRandomNumber(uint32 max) { return _rnd->getRandomNumber(max - 1); }
 	int16 M1_ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
@@ -206,12 +208,15 @@ public:
 	virtual Common::Error run(); // @ main
 	void f433_processCommand140_saveGame(uint16 slot, const Common::String desc); // @ F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF
 	LoadgameResponse f435_loadgame(); // @ F0435_STARTEND_LoadGame_CPSF
+	void f441_processEntrance(); // @ F0441_STARTEND_ProcessEntrance
 
 private:
 	int16 _g528_saveFormat; // @ G0528_i_Format
 	int16 _g527_platform; // @ G0527_i_Platform
 	uint16 _g526_dungeonId; // @ G0526_ui_DungeonID
 	Console *_console;
+	byte *_g562_entranceDoorAnimSteps[10]; // @ G0562_apuc_Bitmap_EntranceDoorAnimationSteps
+	byte *_g564_interfaceCredits; // @ G0564_puc_Graphic5_InterfaceCredits
 public:
 	Common::RandomSource *_rnd;
 	DisplayMan *_displayMan;
@@ -228,7 +233,7 @@ public:
 	ProjExpl *_projexpl;
 
 
-	bool _g298_newGame; // @ G0298_B_NewGame
+	int16 _g298_newGame; // @ G0298_B_NewGame
 	bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested
 
 	bool _g321_stopWaitingForPlayerInput; // @ G0321_B_StopWaitingForPlayerInput
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 5fe80e2..6e868f7 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -740,6 +740,7 @@ void EventManager::f380_processCommandQueue() {
 	if (cmdType == k140_CommandSaveGame) {
 		if ((_vm->_championMan->_g305_partyChampionCount > 0) && !_vm->_championMan->_g299_candidateChampionOrdinal) {
 			warning(false, "MISSING CODE: F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF();");
+			_vm->f433_processCommand140_saveGame(1, "Nice save:)");
 		}
 		return;
 	}
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 5efb3f0..dae3400 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -772,6 +772,8 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) {
 	delete[] _g348_bitmapScreen;
 	_g348_bitmapScreen = new byte[_screenWidth * _screenHeight];
 	fillScreen(k0_ColorBlack);
+
+	_g74_tmpBitmap = new byte[_screenWidth * _screenHeight];
 }
 
 void DisplayMan::f479_loadGraphics() {
@@ -2248,11 +2250,13 @@ void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) {
 	f126_drawSquareD0R(dir, tmpPosX, tmpPosY);
 	f127_drawSquareD0C(dir, posX, posY);
 
-	_g698_bitmapWallSet_Wall_D3LCR = _g95_bitmapWall_D3LCR_Native;
-	_g699_bitmapWallSet_Wall_D2LCR = _g96_bitmapWall_D2LCR_Native;
-	_g700_bitmapWallSet_Wall_D1LCR = _g97_bitmapWall_D1LCR_Native;
-	_g701_bitmapWallSet_Wall_D0L = _g98_bitmapWall_D0L_Native;
-	_g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native;
+	if (_g76_useFlippedWallAndFootprintsBitmap) {
+		_g698_bitmapWallSet_Wall_D3LCR = _g95_bitmapWall_D3LCR_Native;
+		_g699_bitmapWallSet_Wall_D2LCR = _g96_bitmapWall_D2LCR_Native;
+		_g700_bitmapWallSet_Wall_D1LCR = _g97_bitmapWall_D1LCR_Native;
+		_g701_bitmapWallSet_Wall_D0L = _g98_bitmapWall_D0L_Native;
+		_g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native;
+	}
 
 	f97_drawViewport((_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance) ? 1 : 0);
 	if (_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance)
@@ -2320,7 +2324,6 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 	f95_loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet);
 
 	{
-		_g74_tmpBitmap = new byte[_screenWidth * _screenHeight];
 		_g578_useByteBoxCoordinates = true;
 
 		f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap,
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index d1cc5b7..2a18b39 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -202,6 +202,10 @@ enum ViewCell {
 };
 
 enum GraphicIndice {
+	k2_entranceLeftDoorGraphicIndice = 2, // @ C002_GRAPHIC_ENTRANCE_LEFT_DOOR
+	k3_entranceRightDoorGraphicIndice = 3, // @ C003_GRAPHIC_ENTRANCE_RIGHT_DOOR
+	k4_entranceGraphicIndice = 4, // @ C004_GRAPHIC_ENTRANCE
+	k5_creditsGraphicIndice = 5, // @ C005_GRAPHIC_CREDITS
 	k8_StatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION
 	k9_MenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND
 	k10_MenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 9d705ef..28b57f2 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -176,5 +176,4 @@ void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::Strin
 	out->writeUint32BE(playTime);
 }
 
-
 }


Commit: e8249722455321a67ee5edf831be1c6bb76a8b65
    https://github.com/scummvm/scummvm/commit/e8249722455321a67ee5edf831be1c6bb76a8b65
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix activeGroup removal

Changed paths:
    engines/dm/group.cpp



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 5961f7c..e59a6e7 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1699,6 +1699,7 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
 
 	warning(false, "Code differs from the original in GroupMan::f183_addActiveGroup");
 	//L0340_ps_Group = ((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType());
+	L0341_ps_ActiveGroup->_groupThingIndex = thing.getType();
 	L0340_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(f175_groupGetThing(mapX, mapY));
 
 	L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells;


Commit: aa92c3ba2067a011743ddfbb4db8d2376e92aceb
    https://github.com/scummvm/scummvm/commit/aa92c3ba2067a011743ddfbb4db8d2376e92aceb
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix footprints everywhere

Changed paths:
    engines/dm/champion.h
    engines/dm/eventman.cpp



diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 85afd6f..15a07be 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -55,6 +55,7 @@ public:
 	void setMapX(uint16 val) { _scent = (_scent & ~0x1F) & (val & 0x1F); }
 	void setMapY(uint16 val) { _scent = (_scent & ~(0x1F << 5)) & (val & 0x1F); }
 	void setMapIndex(uint16 val) { _scent = (_scent & ~(0x1F << 10)) & (val & 0x3F); }
+	void setVal(uint16 val) { _scent = val; }
 
 	uint16 toUint16() { return _scent; }
 }; // @ SCENT
@@ -90,8 +91,12 @@ public:
 		_scentCount = 0;
 		_freezeLifeTicks = 0;
 		_firstScentIndex = 0;
-		for (int16 i = 0; i < 24; ++i)
+
+		_lastScentIndex = 0;
+		for (int16 i = 0; i < 24; ++i) {
+			_scents[i].setVal(0);
 			_scentStrengths[i] = 0;
+		}
 		_event71Count_Invisibility = 0;
 	}
 }; // @  PARTY
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 6e868f7..d6790b4 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -747,7 +747,7 @@ void EventManager::f380_processCommandQueue() {
 	if (cmdType == k147_CommandFreezeGame) {
 		_vm->_g301_gameTimeTicking = false;
 		_vm->_menuMan->f456_drawDisabledMenu();
-		_vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 224, 136);
+		_vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 112, 136);
 		// TODO: localization
 		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 81, 69, k4_ColorCyan, k0_ColorBlack,
 											 "GAME FROZEN", k136_heightViewport);


Commit: ee3973aa153f5fba6485515cf1f51c1659fd31c4
    https://github.com/scummvm/scummvm/commit/ee3973aa153f5fba6485515cf1f51c1659fd31c4
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add code for loading the save files

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/group.cpp
    engines/dm/group.h
    engines/dm/loadsave.cpp
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index f22d4dd..aac5584 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1724,7 +1724,7 @@ void ChampionMan::save2_PartyPart(Common::OutSaveFile* file) {
 		file->writeUint16BE(champ->_cell);
 		file->writeUint16BE(champ->_actionIndex);
 		file->writeUint16BE(champ->_symbolStep);
-		for(uint16 j = 0; j < 5; ++j)
+		for (uint16 j = 0; j < 5; ++j)
 			file->writeByte(champ->_symbols[j]);
 		file->writeUint16BE(champ->_directionMaximumDamageReceived);
 		file->writeUint16BE(champ->_maximumDamageReceived);
@@ -1757,13 +1757,75 @@ void ChampionMan::save2_PartyPart(Common::OutSaveFile* file) {
 	file->writeByte(party._freezeLifeTicks);
 	file->writeByte(party._firstScentIndex);
 	file->writeByte(party._lastScentIndex);
-	for(uint16 i = 0; i < 24; ++i)
+	for (uint16 i = 0; i < 24; ++i)
 		file->writeUint16BE(party._scents[i].toUint16());
 	for (uint16 i = 0; i < 24; ++i)
 		file->writeByte(party._scentStrengths[i]);
 	file->writeByte(party._event71Count_Invisibility);
 }
 
+void ChampionMan::load2_PartyPart(Common::InSaveFile* file) {
+	for (uint16 i = 0; i < 4; ++i) {
+		Champion *champ = &_gK71_champions[i];
+		champ->_attributes = file->readUint16BE();
+		champ->_wounds = file->readUint16BE();
+		for (uint16 y = 0; y < 7; ++y)
+			for (uint16 x = 0; x < 3; ++x)
+				champ->_statistics[y][x] = file->readByte();
+		for (uint16 j = 0; j < 30; ++j)
+			champ->_slots[j] = Thing(file->readUint16BE());
+			for (uint16 j = 0; j < 20; ++j) {
+				champ->_skills[j]._temporaryExperience = file->readSint16BE();
+				champ->_skills[j]._experience = file->readSint32BE();
+			}
+		for (uint16 j = 0; j < 8; ++j)
+			champ->_name[j] = file->readByte();
+		for (uint16 j = 0; j < 20; ++j)
+			champ->_title[j] = file->readByte();
+		champ->_dir = (direction)file->readUint16BE();
+		champ->_cell = (ViewCell)file->readUint16BE();
+		champ->_actionIndex = (ChampionAction)file->readUint16BE();
+		champ->_symbolStep = file->readUint16BE();
+		for (uint16 j = 0; j < 5; ++j)
+			champ->_symbols[j] = file->readByte();
+		champ->_directionMaximumDamageReceived = file->readUint16BE();
+		champ->_maximumDamageReceived = file->readUint16BE();
+		champ->_poisonEventCount = file->readUint16BE();
+		champ->_enableActionEventIndex = file->readSint16BE();
+		champ->_hideDamageReceivedIndex = file->readSint16BE();
+		champ->_currHealth = file->readSint16BE();
+		champ->_maxHealth = file->readSint16BE();
+		champ->_currStamina = file->readSint16BE();
+		champ->_maxStamina = file->readSint16BE();
+		champ->_currMana = file->readSint16BE();
+		champ->_maxMana = file->readSint16BE();
+		champ->_actionDefense = file->readSint16BE();
+		champ->_food = file->readSint16BE();
+		champ->_water = file->readSint16BE();
+		champ->_load = file->readUint16BE();
+		champ->_shieldDefense = file->readSint16BE();
+		for (uint16 j = 0; j < 928; ++j)
+			champ->_portrait[j] = file->readByte();
+	}
+
+	Party &party = _g407_party;
+	party._magicalLightAmount = file->readSint16BE();
+	party._event73Count_ThievesEye = file->readByte();
+	party._event79Count_Footprints = file->readByte();
+	party._shieldDefense = file->readSint16BE();
+	party._fireShieldDefense = file->readSint16BE();
+	party._spellShieldDefense = file->readSint16BE();
+	party._scentCount = file->readByte();
+	party._freezeLifeTicks = file->readByte();
+	party._firstScentIndex = file->readByte();
+	party._lastScentIndex = file->readByte();
+	for (uint16 i = 0; i < 24; ++i)
+		party._scents[i] = Scent(file->readUint16BE());
+	for (uint16 i = 0; i < 24; ++i)
+		party._scentStrengths[i] = file->readByte();
+	party._event71Count_Invisibility = file->readByte();
+}
+
 ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
 	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
 		if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 15a07be..17d8831 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -586,6 +586,7 @@ public:
 	void f323_unpoison(int16 champIndex); // @ F0323_CHAMPION_Unpoison
 	void f331_applyTimeEffects(); // @ F0331_CHAMPION_ApplyTimeEffects_CPSF
 	void save2_PartyPart(Common::OutSaveFile *file);
+	void load2_PartyPart(Common::InSaveFile* file);
 };
 
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 2861cf1..0aade77 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -177,9 +177,6 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_g564_interfaceCredits = nullptr;
 	debug("DMEngine::DMEngine");
 
-
-	warning(false, "DUMMY CODE: setting _g298_newGame to true, should be in processEntrance");
-	_g298_newGame = true;
 }
 
 DMEngine::~DMEngine() {
@@ -222,7 +219,7 @@ uint16 DMEngine::f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2) {
 void DMEngine::f463_initializeGame() {
 	_displayMan->f479_loadGraphics();
 	_displayMan->f460_initializeGraphicData();
-	// DUMMY CODE: next line
+	warning(false, "Dummy code in f463_initializeGame, setting palette");
 	_displayMan->loadPalette(g21_PalDungeonView[0]);
 	_displayMan->f94_loadFloorSet(k0_FloorSetStone);
 	_displayMan->f95_loadWallSet(k0_WallSetStone);
@@ -231,12 +228,11 @@ void DMEngine::f463_initializeGame() {
 	_objectMan->loadObjectNames();
 	_eventMan->initMouse();
 	f441_processEntrance();
-	while (f435_loadgame() != k1_LoadgameSuccess) {
+	while (f435_loadgame(1) != k1_LoadgameSuccess) {
 		f441_processEntrance();
 	}
 	//F0396_MENUS_LoadSpellAreaLinesBitmap() is not needed, every bitmap has been loaded
 
-
 	// There was some memory wizardy for the Amiga platform, I skipped that part
 	_displayMan->f461_allocateFlippedWallBitmaps();
 
@@ -321,7 +317,7 @@ Common::Error DMEngine::run() {
 	_projexpl = new ProjExpl(this);
 	_displayMan->setUpScreens(320, 200);
 
-	f463_initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
+	f463_initializeGame();
 	while (true) {
 		f2_gameloop();
 		warning(false, "TODO: F0444_STARTEND_Endgame(G0303_B_PartyDead);");
@@ -490,7 +486,6 @@ void DMEngine::f441_processEntrance() {
 		_g562_entranceDoorAnimSteps[i] = nullptr;
 }
 
-
 void DMEngine::f439_drawEntrance() {
 	static Box K0079_s_Box_Entrance_DoorsUpperHalf = {0, 231, 0, 80};
 	static Box K0152_s_Box_Entrance_DoorsLowerHalf = {0, 231, 81, 160};
@@ -508,7 +503,7 @@ void DMEngine::f439_drawEntrance() {
 	_dungeonMan->_g271_currMapData = L1398_apuc_MicroDungeonCurrentMapData;
 
 	Map map; // uninitialized, won't be used
-	_dungeonMan->_g269_currMap = ↦ 
+	_dungeonMan->_g269_currMap = ↦
 	for (uint16 i = 0; i < 25; ++i)
 		L1399_auc_MicroDungeonSquares[i] = Square(k0_ElementTypeWall, 0);
 	for (L1397_ui_ColumnIndex = 0; L1397_ui_ColumnIndex < 5; L1397_ui_ColumnIndex++) {
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index cbc0bd3..279144b 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -33,6 +33,8 @@
 #include "gui/debugger.h"
 #include "common/savefile.h"
 #include "common/str.h"
+#include "engines/savestate.h"
+
 
 
 namespace DM {
@@ -184,6 +186,13 @@ enum LoadgameResponse {
 	k1_LoadgameSuccess = 1// @ C01_LOAD_GAME_SUCCESS
 };
 
+
+struct SaveGameHeader {
+	byte _version;
+	SaveStateDescriptor _descr;
+};
+
+
 class DMEngine : public Engine {
 	void f462_startGame(); // @ F0462_START_StartGame_CPSF
 	void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
@@ -193,6 +202,7 @@ class DMEngine : public Engine {
 	void initArrays();
 	Common::String getSavefileName(uint16 slot);
 	void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
+	bool readSaveGameHeader(Common::InSaveFile *file, SaveGameHeader *header);
 	void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance
 public:
 	explicit DMEngine(OSystem *syst);
@@ -207,7 +217,7 @@ public:
 	void f19_displayErrorAndStop(int16 errorIndex); // @ F0019_MAIN_DisplayErrorAndStop
 	virtual Common::Error run(); // @ main
 	void f433_processCommand140_saveGame(uint16 slot, const Common::String desc); // @ F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF
-	LoadgameResponse f435_loadgame(); // @ F0435_STARTEND_LoadGame_CPSF
+	LoadgameResponse f435_loadgame(int16 slot); // @ F0435_STARTEND_LoadGame_CPSF
 	void f441_processEntrance(); // @ F0441_STARTEND_ProcessEntrance
 
 private:
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index e59a6e7..6f6991e 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -2077,4 +2077,22 @@ void GroupMan::save1_ActiveGroupPart(Common::OutSaveFile* file) {
 	}
 }
 
+void GroupMan::load1_ActiveGroupPart(Common::InSaveFile* file) {
+	for (uint16 i = 0; i < _g376_maxActiveGroupCount; ++i) {
+		ActiveGroup *group = &_g375_activeGroups[i];
+		group->_groupThingIndex = file->readUint16BE();
+		group->_directions = (direction)file->readUint16BE();
+		group->_cells = file->readByte();
+		group->_lastMoveTime = file->readByte();
+		group->_delayFleeingFromTarget = file->readByte();
+		group->_targetMapX = file->readByte();
+		group->_targetMapY = file->readByte();
+		group->_priorMapX = file->readByte();
+		group->_priorMapY = file->readByte();
+		group->_homeMapX = file->readByte();
+		group->_homeMapY = file->readByte();
+		for (uint16 j = 0; j < 4; ++j)
+			group->_aspect[j] = file->readByte();
+	}
+}
 }
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 2ad2d8d..699f195 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -245,6 +245,7 @@ public:
 	bool f221_isFluxcageOnSquare(int16 mapX, int16 mapY); // @ F0221_GROUP_IsFluxcageOnSquare
 	void f225_fuseAction(uint16 mapX, uint16 mapY); // @ F0225_GROUP_FuseAction
 	void save1_ActiveGroupPart(Common::OutSaveFile *file);
+	void load1_ActiveGroupPart(Common::InSaveFile* file);
 };
 
 
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 28b57f2..9b50351 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -42,32 +42,96 @@ namespace DM {
 #define C2_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST 2
 #define C3_PLATFORM_AMIGA 3
 #define C10_DUNGEON_DM 10
-LoadgameResponse DMEngine::f435_loadgame() {
-	bool newGame = _g298_newGame;
-	ChampionMan &cm = *_championMan;
+LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
+	Common::String fileName;
+	Common::SaveFileManager *saveFileManager = nullptr;
+	Common::InSaveFile *file = nullptr;
+
+	if (!_g298_newGame) {
+		fileName = getSavefileName(slot);
+		saveFileManager = _system->getSavefileManager();
+		file = saveFileManager->openForLoading(fileName);
+	}
+
 	_g528_saveFormat = C2_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST;
 	_g527_platform = C3_PLATFORM_AMIGA;
 	_g526_dungeonId = C10_DUNGEON_DM;
-	if (newGame) {
+	if (_g298_newGame) {
+		//L1366_B_FadePalette = !F0428_DIALOG_RequireGameDiskInDrive_NoDialogDrawn(C0_DO_NOT_FORCE_DIALOG_DM_CSB, true);
+T0435002:
 		_g524_restartGameAllowed = false;
-		cm._g305_partyChampionCount = 0;
-		cm._g414_leaderHandObject = Thing::_none;
-		_g525_gameId = _rnd->getRandomNumber(65536) * _rnd->getRandomNumber(65536);
+		_championMan->_g305_partyChampionCount = 0;
+		_championMan->_g414_leaderHandObject = Thing::_none;
+		_g525_gameId = ((int32)getRandomNumber(65536)) * getRandomNumber(65536);
 	} else {
-		assert(false);
-		// MISSING CODE: load game
-	}
-	_dungeonMan->f434_loadDungeonFile();
+		warning(false, "MISSING CODE: missing check for matching _g525_gameId in f435_loadgame");
+		/*if (_vm->_g523_restartGameRequest && (L1372_s_SaveHeader.GameID != _vm->_g525_gameId)) {
+			L1367_pc_Message = G0546_pc_THATSNOTTHESAMEGAME;
+			goto T0435004;
+		}*/
+
+		SaveGameHeader header;
+		readSaveGameHeader(file, &header);
+
+		warning(false, "MISSING CODE: missing check for matching format and platform in save in f435_loadgame");
+
 
+		_g313_gameTime = file->readUint32BE();
+		// G0349_ul_LastRandomNumber = L1371_s_GlobalData.LastRandomNumber;
+		_championMan->_g305_partyChampionCount = file->readUint16BE();
+		_dungeonMan->_g306_partyMapX = file->readSint16BE();
+		_dungeonMan->_g307_partyMapY = file->readSint16BE();
+		_dungeonMan->_g308_partyDir = (direction)file->readUint16BE();
+		_dungeonMan->_g309_partyMapIndex = file->readByte();
+		_championMan->_g411_leaderIndex = (ChampionIndex)file->readSint16BE();
+		_championMan->_g514_magicCasterChampionIndex = (ChampionIndex)file->readSint16BE();
+		_timeline->_g372_eventCount = file->readUint16BE();
+		_timeline->_g373_firstUnusedEventIndex = file->readUint16BE();
+		_timeline->_g369_eventMaxCount = file->readUint16BE();
+		_groupMan->_g377_currActiveGroupCount = file->readUint16BE();
+		_projexpl->_g361_lastCreatureAttackTime = file->readSint32BE();
+		_projexpl->_g362_lastPartyMovementTime = file->readSint32BE();
+		_g310_disabledMovementTicks = file->readSint16BE();
+		_g311_projectileDisableMovementTicks = file->readSint16BE();
+		_g312_lastProjectileDisabledMovementDirection = file->readSint16BE();
+		_championMan->_g414_leaderHandObject = Thing(file->readUint16BE());
+		_groupMan->_g376_maxActiveGroupCount = file->readUint16BE();
+		if (!_g523_restartGameRequest) {
+			_timeline->f233_initTimeline();
+			_groupMan->f196_initActiveGroups();
+		}
 
-	if (newGame) {
+		_groupMan->load1_ActiveGroupPart(file);
+		_championMan->load2_PartyPart(file);
+		_timeline->load3_eventsPart(file);
+		_timeline->load4_timelinePart(file);
+
+		_g525_gameId = file->readSint32BE();
+	}
+
+	_dungeonMan->f434_loadDungeonFile();
+	if (_g298_newGame) {
 		_timeline->f233_initTimeline();
 		_groupMan->f196_initActiveGroups();
+		warning(false, "MISSING CODE: missing fadePlette stuff in f435_loadgame on newGame");
+		/*
+		if (L1366_B_FadePalette) {
+			F0436_STARTEND_FadeToPalette(G0345_aui_BlankBuffer);
+			D26_WaitForVerticalBlank();
+			D18_FillScreenBlack();
+			F0436_STARTEND_FadeToPalette(_vm->_displayMan->_g347_paletteTopAndBottomScreen);
+		}*/
 	} else {
-		assert(false);
-		// MISSING CODE: load game
+		_g528_saveFormat = file->readSint16BE();
+		_g527_platform = file->readSint16BE();
+		_g526_dungeonId = file->readUint16BE();
+
+		_g524_restartGameAllowed = true;
+		warning(false, "MISSING CDOE: F0427_DIALOG_Draw in f435_loadgame");
 	}
-	cm._g303_partyDead = false;
+	_championMan->_g303_partyDead = false;
+
+	delete file;
 	return k1_LoadgameSuccess;
 }
 
@@ -176,4 +240,50 @@ void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::Strin
 	out->writeUint32BE(playTime);
 }
 
+
+bool DMEngine::readSaveGameHeader(Common::InSaveFile* in, SaveGameHeader* header) {
+	uint32 id = in->readUint32BE();
+
+	// Check if it's a valid ScummVM savegame
+	if (id != SAVEGAME_ID)
+		return false;
+
+	// Read in the version
+	header->_version = in->readByte();
+
+	// Check that the save version isn't newer than this binary
+	if (header->_version > SAVEGAME_VERSION)
+		return false;
+
+	// Read in the save name
+	Common::String saveName;
+	char ch;
+	while ((ch = (char)in->readByte()) != '\0')
+		saveName += ch;
+	header->_descr.setDescription(saveName);
+
+	// Get the thumbnail
+	header->_descr.setThumbnail(Graphics::loadThumbnail(*in));
+
+	uint32 saveDate = in->readUint32BE();
+	uint16 saveTime = in->readUint16BE();
+	uint32 playTime = in->readUint32BE();
+
+	int day = (saveDate >> 24) & 0xFF;
+	int month = (saveDate >> 16) & 0xFF;
+	int year = saveDate & 0xFFFF;
+	header->_descr.setSaveDate(year, month, day);
+
+	int hour = (saveTime >> 8) & 0xFF;
+	int minutes = saveTime & 0xFF;
+	header->_descr.setSaveTime(hour, minutes);
+
+	header->_descr.setPlayTime(playTime * 1000);
+	if (g_engine)
+		g_engine->setTotalPlayTime(playTime * 1000);
+
+	return true;
 }
+
+}
+
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index afeb577..37eb880 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -1106,4 +1106,22 @@ void Timeline::save4_timelinePart(Common::OutSaveFile* file) {
 		file->writeUint16BE(_g371_timeline[i]);
 }
 
+void Timeline::load3_eventsPart(Common::InSaveFile* file) {
+	for (uint16 i = 0; i < _g369_eventMaxCount; ++i) {
+		TimelineEvent *event = &_g370_events[i];
+		event->_mapTime = file->readSint32BE();
+		event->_type = file->readByte();
+		event->_priority = file->readByte();
+		event->_B._location._mapX = file->readByte();
+		event->_B._location._mapY = file->readByte();
+		event->_C.A._cell = file->readUint16BE();
+		event->_C.A._effect = file->readUint16BE();
+	}
+}
+
+void Timeline::load4_timelinePart(Common::InSaveFile* file) {
+	for (uint16 i = 0; i < _g369_eventMaxCount; ++i)
+		_g371_timeline[i] = file->readUint16BE();
+}
+
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 8f68c35..2d722d5 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -189,6 +189,8 @@ public:
 	void f255_timelineProcessEvent13_ViAltarRebirth(TimelineEvent *event); // @ F0255_TIMELINE_ProcessEvent13_ViAltarRebirth
 	void save3_eventsPart(Common::OutSaveFile *file);
 	void save4_timelinePart(Common::OutSaveFile *file);
+	void load3_eventsPart(Common::InSaveFile* file);
+	void load4_timelinePart(Common::InSaveFile* file);
 };
 
 


Commit: 0f02cc5b0210e6cdc460770d6493a7eb675ce04e
    https://github.com/scummvm/scummvm/commit/0f02cc5b0210e6cdc460770d6493a7eb675ce04e
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix compilation using MSVC9

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 0aade77..92cb402 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -487,10 +487,10 @@ void DMEngine::f441_processEntrance() {
 }
 
 void DMEngine::f439_drawEntrance() {
-	static Box K0079_s_Box_Entrance_DoorsUpperHalf = {0, 231, 0, 80};
-	static Box K0152_s_Box_Entrance_DoorsLowerHalf = {0, 231, 81, 160};
-	static Box G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft = {0, 104, 30, 190};
-	static Box G0011_s_Graphic562_Box_Entrance_ClosedDoorRight = {105, 231, 30, 190};
+	static Box K0079_s_Box_Entrance_DoorsUpperHalf = Box(0, 231, 0, 80);
+	static Box K0152_s_Box_Entrance_DoorsLowerHalf = Box(0, 231, 81, 160);
+	static Box G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft = Box(0, 104, 30, 190);
+	static Box G0011_s_Graphic562_Box_Entrance_ClosedDoorRight = Box(105, 231, 30, 190);
 
 	uint16 L1397_ui_ColumnIndex;
 	byte* L1398_apuc_MicroDungeonCurrentMapData[32];


Commit: 877b1b051b746c44baec9f4b2114d9aedc1e07a9
    https://github.com/scummvm/scummvm/commit/877b1b051b746c44baec9f4b2114d9aedc1e07a9
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove a broken character in the definition of f231_getMeleeActionDamage

Changed paths:
    engines/dm/group.h



diff --git a/engines/dm/group.h b/engines/dm/group.h
index 699f195..1447783 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -239,7 +239,7 @@ public:
 	int16 f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 paryY,
 											 uint16 champCell); // @ F0177_GROUP_GetMeleeTargetCreatureOrdinal
 	int16 f231_getMeleeActionDamage(Champion *champ, int16 champIndex, Group *group, int16 creatureIndex,
-									int16 mapX, int16 mapXóY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex); // @ F0231_GROUP_GetMeleeActionDamage
+									int16 mapX, int16 mapY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex); // @ F0231_GROUP_GetMeleeActionDamage
 	void f224_fluxCageAction(int16 mapX, int16 mapY); // @ F0224_GROUP_FluxCageAction
 	uint16 f222_isLordChaosOnSquare(int16 mapX, int16 mapY); // @ F0222_GROUP_IsLordChaosOnSquare
 	bool f221_isFluxcageOnSquare(int16 mapX, int16 mapY); // @ F0221_GROUP_IsFluxcageOnSquare


Commit: 33aac99beeca9f101857aab326a4fc3e0647dc66
    https://github.com/scummvm/scummvm/commit/33aac99beeca9f101857aab326a4fc3e0647dc66
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Reduce the scope of a couple of variables

Changed paths:
    engines/dm/champion.cpp
    engines/dm/inventory.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index aac5584..464aee7 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1420,8 +1420,6 @@ void ChampionMan::f319_championKill(uint16 champIndex) {
 	int16 L0963_i_AliveChampionIndex;
 	Thing L0964_T_Thing;
 	Champion* L0965_ps_Champion;
-	Junk* L0966_ps_Junk;
-
 
 	L0965_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
 	L0965_ps_Champion->_currHealth = 0;
@@ -1449,7 +1447,7 @@ void ChampionMan::f319_championKill(uint16 champIndex) {
 	L0964_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k0x8000_championBones | k10_JunkThingType);
 	if (L0964_T_Thing == Thing::_none) {
 	} else {
-		L0966_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0964_T_Thing);
+		Junk* L0966_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0964_T_Thing);
 		L0966_ps_Junk->setType(k5_JunkTypeBones);
 		L0966_ps_Junk->setDoNotDiscard(true);
 		L0966_ps_Junk->setChargeCount(champIndex);
@@ -1686,7 +1684,7 @@ void ChampionMan::f331_applyTimeEffects() {
 					}
 				}
 			}
-			if (!_vm->_championMan->_g300_partyIsSleeping && (L1010_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime < (_vm->_g313_gameTime - 60))) {
+			if (!_vm->_championMan->_g300_partyIsSleeping && (L1010_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < (int32)_vm->_g313_gameTime)) {
 				L1010_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
 				L1010_ps_Champion->_maximumDamageReceived = 0;
 				setFlag(L1010_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon);
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 1a15d44..c33524a 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -566,7 +566,6 @@ void InventoryMan::f337_setDungeonViewPalette() {
 	uint16 L1044_ui_Multiple;
 #define AL1044_T_Thing            L1044_ui_Multiple
 #define AL1044_ui_TorchLightPower L1044_ui_Multiple
-	int16 L1045_ai_TorchesLightPower[8];
 
 	int16 g40_palIndexToLightAmmount[6] = {99, 75, 50, 25, 1, 0}; // @ G0040_ai_Graphic562_PaletteIndexToLightAmount
 
@@ -576,6 +575,7 @@ void InventoryMan::f337_setDungeonViewPalette() {
 		/* Get torch light power from both hands of each champion in the party */
 		int16 L1038_i_Counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and _vm->_objectMan->f32_getObjectType then returns -1 */
 		Champion *L1043_ps_Champion = _vm->_championMan->_gK71_champions;
+		int16 L1045_ai_TorchesLightPower[8];
 		AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
 		while (L1038_i_Counter--) {
 			AL1039_ui_SlotIndex = k1_ChampionSlotActionHand + 1;
@@ -638,26 +638,18 @@ void InventoryMan::f337_setDungeonViewPalette() {
 }
 
 void InventoryMan::f338_decreaseTorchesLightPower() {
-	int16 L1046_i_ChampionCount;
-	int16 L1047_i_SlotIndex;
-	bool L1048_B_TorchChargeCountChanged;
-	int16 L1049_i_IconIndex;
-	Champion* L1050_ps_Champion;
-	Weapon* L1051_ps_Weapon;
-
-
-	L1048_B_TorchChargeCountChanged = false;
-	L1046_i_ChampionCount = _vm->_championMan->_g305_partyChampionCount;
+	bool L1048_B_TorchChargeCountChanged = false;
+	int16 L1046_i_ChampionCount = _vm->_championMan->_g305_partyChampionCount;
 	if (_vm->_championMan->_g299_candidateChampionOrdinal) {
 		L1046_i_ChampionCount--;
 	}
-	L1050_ps_Champion = _vm->_championMan->_gK71_champions;
+	Champion *L1050_ps_Champion = _vm->_championMan->_gK71_champions;
 	while (L1046_i_ChampionCount--) {
-		L1047_i_SlotIndex = k1_ChampionSlotActionHand + 1;
+		int16 L1047_i_SlotIndex = k1_ChampionSlotActionHand + 1;
 		while (L1047_i_SlotIndex--) {
-			L1049_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L1050_ps_Champion->_slots[L1047_i_SlotIndex]);
+			int16 L1049_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L1050_ps_Champion->_slots[L1047_i_SlotIndex]);
 			if ((L1049_i_IconIndex >= k4_IconIndiceWeaponTorchUnlit) && (L1049_i_IconIndex <= k7_IconIndiceWeaponTorchLit)) {
-				L1051_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L1050_ps_Champion->_slots[L1047_i_SlotIndex]);
+				Weapon *L1051_ps_Weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(L1050_ps_Champion->_slots[L1047_i_SlotIndex]);
 				if (L1051_ps_Weapon->getChargeCount()) {
 					if (L1051_ps_Weapon->setChargeCount(L1051_ps_Weapon->getChargeCount() - 1) == 0) {
 						L1051_ps_Weapon->setDoNotDiscard(false);


Commit: 185588f098d3982399c74729ad731a68fa1c2454
    https://github.com/scummvm/scummvm/commit/185588f098d3982399c74729ad731a68fa1c2454
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Silent some CppCheck warnings in eventman.cpp

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index d6790b4..dadc931 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1312,13 +1312,6 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 	static Box G0622_s_Box_MousePointer_ChampionIcon = Box(0, 18, 0, 13);
 	static byte G0045_auc_Graphic562_PaletteChanges_MousePointerIconShadow[16] = {0, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 0, 120, 120, 120};
 
-	uint16 L0052_ui_ChampionIconIndex;
-	int16 L0053_i_ChampionIndex;
-	int16 L0054_i_ChampionIndex;
-	Box* L0055_pi_ChampionIconBox;
-	byte* L0056_puc_Bitmap;
-
-
 	_gK100_preventBuildPointerScreenArea = true;
 	if (!_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
 		if (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir)) == kM1_ChampionNone) {
@@ -1328,9 +1321,9 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
 		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = true;
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		L0056_puc_Bitmap = _gK190_mousePointerTempBuffer;
+		byte *L0056_puc_Bitmap = _gK190_mousePointerTempBuffer;
 		memset(L0056_puc_Bitmap, 0, 32 * 18);
-		L0055_pi_ChampionIconBox = &g54_BoxChampionIcons[champIconIndex];
+		Box *L0055_pi_ChampionIconBox = &g54_BoxChampionIcons[champIconIndex];
 
 		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, L0056_puc_Bitmap, G0621_s_Box_MousePointer_ChampionIconShadow, L0055_pi_ChampionIconBox->_x1, L0055_pi_ChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
 
@@ -1342,14 +1335,14 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(champIconIndex);
 	} else {
 		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
-		L0052_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap);
+		uint16 L0052_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap);
 		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
-		L0054_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(L0052_ui_ChampionIconIndex + _vm->_dungeonMan->_g308_partyDir));
+		int16 L0054_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(L0052_ui_ChampionIconIndex + _vm->_dungeonMan->_g308_partyDir));
 		if (L0052_ui_ChampionIconIndex == champIconIndex) {
 			setFlag(_vm->_championMan->_gK71_champions[L0054_i_ChampionIndex]._attributes, k0x0400_ChampionAttributeIcon);
 			_vm->_championMan->f292_drawChampionState((ChampionIndex)L0054_i_ChampionIndex);
 		} else {
-			L0053_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir));
+			int16 L0053_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir));
 			if (L0053_i_ChampionIndex >= 0) {
 				_vm->_championMan->_gK71_champions[L0053_i_ChampionIndex]._cell = (ViewCell)M21_normalizeModulo4(L0052_ui_ChampionIconIndex + _vm->_dungeonMan->_g308_partyDir);
 				setFlag(_vm->_championMan->_gK71_champions[L0053_i_ChampionIndex]._attributes, k0x0400_ChampionAttributeIcon);


Commit: c15c5a16f4a5df540b599ff7270f01829d5041fd
    https://github.com/scummvm/scummvm/commit/c15c5a16f4a5df540b599ff7270f01829d5041fd
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove broken characters in f231_getMeleeActionDamage body

Changed paths:
    engines/dm/group.cpp



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 6f6991e..e132685 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1841,7 +1841,7 @@ int16 GroupMan::f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, i
 	}
 }
 
-int16 GroupMan::f231_getMeleeActionDamage(Champion* champ, int16 champIndex, Group* group, int16 creatureIndex, int16 mapX, int16 mapXóY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex) {
+int16 GroupMan::f231_getMeleeActionDamage(Champion* champ, int16 champIndex, Group* group, int16 creatureIndex, int16 mapX, int16 mapY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex) {
 	int16 L0565_i_Damage = 0;
 	int16 L0566_i_Damage = 0;
 	int16 L0567_i_DoubledMapDifficulty;
@@ -1903,7 +1903,7 @@ T0231009:
 		if (_vm->getRandomNumber(64) < _vm->_championMan->f303_getSkillLevel(champIndex, skillIndex)) {
 			L0565_i_Damage += L0565_i_Damage + 10;
 		}
-		L0569_i_Outcome = f190_groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapXóY, L0565_i_Damage, true);
+		L0569_i_Outcome = f190_groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapY, L0565_i_Damage, true);
 		_vm->_championMan->f304_addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * L0572_ps_CreatureInfo->M58_getExperience() >> 4) + 3);
 		_vm->_championMan->f325_decrementStamine(champIndex, _vm->getRandomNumber(4) + 4);
 		goto T0231016;
@@ -1915,7 +1915,7 @@ T0231015:
 T0231016:
 	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
 	if (L0569_i_Outcome != k2_outcomeKilledAllCreaturesInGroup) {
-		f209_processEvents29to41(mapX, mapXóY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
+		f209_processEvents29to41(mapX, mapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
 	}
 	return L0565_i_Damage;
 }


Commit: 2f3c9b7c7862d2c424a43d805f791b1176867eaf
    https://github.com/scummvm/scummvm/commit/2f3c9b7c7862d2c424a43d805f791b1176867eaf
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove variable redefinition in f337_setDungeonViewPalette, reduce some scopes

Changed paths:
    engines/dm/inventory.cpp



diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index c33524a..86b78bd 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -552,22 +552,10 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		f335_drawPanelObjectDescriptionString(str);
 	}
 	f339_drawPanelArrowOrEye(pressingEye);
-
 }
 
 void InventoryMan::f337_setDungeonViewPalette() {
-	uint16 L1039_ui_Multiple;
-#define AL1039_ui_SlotIndex    L1039_ui_Multiple
-#define AL1039_ui_PaletteIndex L1039_ui_Multiple
-#define AL1039_ui_Counter      L1039_ui_Multiple
-	int16* L1040_pi_Multiple;
-#define AL1040_pi_TorchLightPower L1040_pi_Multiple
-#define AL1040_pi_LightAmount     L1040_pi_Multiple
-	uint16 L1044_ui_Multiple;
-#define AL1044_T_Thing            L1044_ui_Multiple
-#define AL1044_ui_TorchLightPower L1044_ui_Multiple
-
-	int16 g40_palIndexToLightAmmount[6] = {99, 75, 50, 25, 1, 0}; // @ G0040_ai_Graphic562_PaletteIndexToLightAmount
+	static const int16 g40_palIndexToLightAmmount[6] = {99, 75, 50, 25, 1, 0}; // @ G0040_ai_Graphic562_PaletteIndexToLightAmount
 
 	if (_vm->_dungeonMan->_g269_currMap->_difficulty == 0) {
 		_vm->_displayMan->_g304_dungeonViewPaletteIndex = 0; /* Brightest color palette index */
@@ -576,12 +564,13 @@ void InventoryMan::f337_setDungeonViewPalette() {
 		int16 L1038_i_Counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and _vm->_objectMan->f32_getObjectType then returns -1 */
 		Champion *L1043_ps_Champion = _vm->_championMan->_gK71_champions;
 		int16 L1045_ai_TorchesLightPower[8];
-		AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
+		int16 *AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
 		while (L1038_i_Counter--) {
-			AL1039_ui_SlotIndex = k1_ChampionSlotActionHand + 1;
+			uint16 AL1039_ui_SlotIndex = k1_ChampionSlotActionHand + 1;
 			while (AL1039_ui_SlotIndex--) {
-				if ((_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16())) >= k4_IconIndiceWeaponTorchUnlit) &&
-					(_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16())) <= k7_IconIndiceWeaponTorchLit)) {
+				uint16 AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16();
+				if ((_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing)) >= k4_IconIndiceWeaponTorchUnlit) &&
+					(_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing)) <= k7_IconIndiceWeaponTorchLit)) {
 					Weapon *L1042_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(Thing(AL1044_T_Thing));
 					*AL1040_pi_TorchLightPower = L1042_ps_Weapon->getChargeCount();
 				} else {
@@ -593,13 +582,13 @@ void InventoryMan::f337_setDungeonViewPalette() {
 		}
 		/* Sort torch light power values so that the four highest values are in the first four entries in the array L1045_ai_TorchesLightPower in decreasing order. The last four entries contain the smallest values but they are not sorted */
 		AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
-		AL1039_ui_Counter = 0;
+		int16 AL1039_ui_Counter = 0;
 		while (AL1039_ui_Counter != 4) {
 			L1038_i_Counter = 7 - AL1039_ui_Counter;
 			int16 *L1041_pi_TorchLightPower = &L1045_ai_TorchesLightPower[AL1039_ui_Counter + 1];
 			while (L1038_i_Counter--) {
 				if (*L1041_pi_TorchLightPower > *AL1040_pi_TorchLightPower) {
-					AL1044_ui_TorchLightPower = *L1041_pi_TorchLightPower;
+					int16 AL1044_ui_TorchLightPower = *L1041_pi_TorchLightPower;
 					*L1041_pi_TorchLightPower = *AL1040_pi_TorchLightPower;
 					*AL1040_pi_TorchLightPower = AL1044_ui_TorchLightPower;
 				}
@@ -622,7 +611,8 @@ void InventoryMan::f337_setDungeonViewPalette() {
 		}
 		L1036_i_TotalLightAmount += _vm->_championMan->_g407_party._magicalLightAmount;
 		/* Select palette corresponding to the total light amount */
-		AL1040_pi_LightAmount = g40_palIndexToLightAmmount;
+		const int16 *AL1040_pi_LightAmount = g40_palIndexToLightAmmount;
+		int16 AL1039_ui_PaletteIndex;
 		if (L1036_i_TotalLightAmount > 0) {
 			AL1039_ui_PaletteIndex = 0; /* Brightest color palette index */
 			while (*AL1040_pi_LightAmount++ > L1036_i_TotalLightAmount) {


Commit: ebd672770ada3685c2e84299368c9586d944ba2a
    https://github.com/scummvm/scummvm/commit/ebd672770ada3685c2e84299368c9586d944ba2a
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Properly stub f064_SOUND_RequestPlay_CPSD

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.h
    engines/dm/eventman.cpp
    engines/dm/group.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/projexpl.cpp
    engines/dm/text.h
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 464aee7..8c3aacd 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -199,7 +199,7 @@ bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16
 			return false;
 		}
 	}
-	warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+	_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 	f325_decrementStamine(champIndex, f305_getThrowingStaminaCost(L0996_T_Thing));
 	f330_disableAction(champIndex, 4);
 	AL0994_i_Experience = 8;
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 279144b..128dfaf 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -220,6 +220,8 @@ public:
 	LoadgameResponse f435_loadgame(int16 slot); // @ F0435_STARTEND_LoadGame_CPSF
 	void f441_processEntrance(); // @ F0441_STARTEND_ProcessEntrance
 
+	void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode) { warning(true, "STUB: f064_SOUND_RequestPlay_CPSD"); }
+
 private:
 	int16 _g528_saveFormat; // @ G0528_i_Format
 	int16 _g527_platform; // @ G0527_i_Platform
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index dadc931..946c1fb 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -891,7 +891,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 				L1117_B_MovementBlocked |= _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
 			}
 			if (L1117_B_MovementBlocked) {
-				warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+				_vm->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, L1121_i_MapX, L1122_i_MapY, k0_soundModePlayImmediately);
 			}
 		} else {
 			if (L1117_B_MovementBlocked = (_vm->_groupMan->f175_groupGetThing(L1121_i_MapX, L1122_i_MapY) != Thing::_endOfList)) {
@@ -1027,7 +1027,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 			L1151_ps_Junk = (Junk*)_vm->_dungeonMan->f157_getSquareFirstThingData(L1155_i_MapX, L1156_i_MapY);
 			if ((((Door*)L1151_ps_Junk)->hasButton()) && _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
 				_vm->_g321_stopWaitingForPlayerInput = true;
-				warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+				_vm->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 				_vm->_movsens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1);
 				return;
 			}
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index e132685..05f4b5a 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -147,7 +147,7 @@ void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThin
 			_vm->_movsens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
 		} while ((L0365_T_CurrentThing = L0366_T_NextThing) != Thing::_endOfList);
 		if (mode >= k0_soundModePlayImmediately) {
-			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			_vm->f064_SOUND_RequestPlay_CPSD(L0371_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
 		}
 	}
 }
@@ -229,11 +229,11 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX
 		L0359_pui_FixedPossessions = g253FixedPossessionCreature_24RedDragon;
 	}
 	uint16 L0356_ui_FixedPossession;
+	bool L0362_B_WeaponDropped = false;
 	while (L0356_ui_FixedPossession = *L0359_pui_FixedPossessions++) {
 		if (getFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) && _vm->getRandomNumber(2))
 			continue;
 		int16 L0357_i_ThingType;
-		bool L0362_B_WeaponDropped = false;
 		if (clearFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) >= k127_ObjectInfoIndexFirstJunk) {
 			L0357_i_ThingType = k10_JunkThingType;
 			L0356_ui_FixedPossession -= k127_ObjectInfoIndexFirstJunk;
@@ -258,7 +258,7 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX
 		L0358_T_Thing = M15_thingWithNewCell(L0358_T_Thing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell);
 		_vm->_movsens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY);
 	}
-	warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+	_vm->f064_SOUND_RequestPlay_CPSD(L0362_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
 }
 
 int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
@@ -890,7 +890,7 @@ T0209089_DoubleSquareMove:
 							AL0450_i_DestinationMapX = eventMapX;
 							AL0451_i_DestinationMapY = eventMapY;
 							AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2;
-							warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+							_vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY, k1_soundModePlayIfPrioritized);
 							goto T0209061_MoveGroup;
 						}
 					}
@@ -1271,7 +1271,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 				if (getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) && (L0331_ui_CreatureType == k18_CreatureTypeAnimatedArmourDethKnight)) {
 					if (_vm->getRandomNumber(2)) {
 						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-						warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+						_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized);
 					}
 				} else {
 					if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) {
@@ -1293,7 +1293,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
 						L1635_ui_SoundIndex = _vm->_movsens->f514_getSound(k13_CreatureTypeCouatl);
 						if (L1635_ui_SoundIndex <= k34_D13_soundCount) {
-							warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+							_vm->f064_SOUND_RequestPlay_CPSD(L1635_ui_SoundIndex, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized);
 						}
 					}
 				} else {
@@ -1418,6 +1418,8 @@ bool GroupMan::f204_isArchenemyDoubleMovementPossible(CreatureInfo *info, int16
 }
 
 bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 creatureIndex) {
+	static const uint8 G0244_auc_Graphic559_CreatureAttackSounds[11] = { 3, 7, 14, 15, 19, 21, 29, 30, 31, 4, 16 }; /* Atari ST: { 3, 7, 14, 15, 19, 21, 4, 16 } */
+
 	uint16 L0437_ui_Multiple;
 #define AL0437_ui_CreatureType L0437_ui_Multiple
 #define AL0437_T_Thing         L0437_ui_Multiple
@@ -1486,7 +1488,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 		AL0440_i_KineticEnergy = (L0441_ps_CreatureInfo->_attack >> 2) + 1;
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
-		warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+		_vm->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, mapX, mapY, k0_soundModePlayImmediately);
 		_vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
 	} else {
 		if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) {
@@ -1514,7 +1516,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 		}
 	}
 	if (AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal) {
-		warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+		_vm->f064_SOUND_RequestPlay_CPSD(G0244_auc_Graphic559_CreatureAttackSounds[--AL0440_i_AttackSoundOrdinal], mapX, mapY, k1_soundModePlayIfPrioritized);
 	}
 	return true;
 }
@@ -1637,7 +1639,7 @@ int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) {
 			AL0558_i_Attack -= _vm->getRandomNumber((AL0558_i_Attack >> 1) + 1) - 1;
 		}
 		if (AL0558_i_Damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType)) {
-			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			_vm->f064_SOUND_RequestPlay_CPSD(k09_soundCHAMPION_0_DAMAGED + champIndex, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater);
 			if ((AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack) && _vm->getRandomNumber(2) && ((AL0559_ui_PoisonAttack = _vm->_championMan->f307_getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack)) >= 0)) {
 				_vm->_championMan->f322_championPoison(champIndex, AL0559_ui_PoisonAttack);
 			}
@@ -1808,7 +1810,7 @@ Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplie
 	if (_vm->_movsens->f267_getMoveResult(L0349_T_GroupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) { /* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile impact (in which case the thing data was marked as unused) or the party is on the destination square and an event is created to move the creature into the dungeon later (in which case the thing is referenced in the event) */
 		return Thing::_none;
 	}
-	warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+	_vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, mapX, mapY, k1_soundModePlayIfPrioritized);
 	return L0349_T_GroupThing;
 }
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 06a286c..146a75e 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -1114,10 +1114,10 @@ T0407014:
 	case k13_ChampionActionSwing:
 	case k2_ChampionActionChop:
 		if ((Square(AL1244_ui_TargetSquare).getType() == k4_DoorElemType) && (Square(AL1244_ui_TargetSquare).getDoorState() == k4_doorState_CLOSED)) {
-			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 			L1249_ui_ActionDisabledTicks = 6;
 			_vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
-			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			_vm->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater);
 			break;
 		}
 	case k24_ChampionActionDisrupt:
@@ -1143,10 +1143,10 @@ T0407014:
 	case k41_ChampionActionBrandish:
 	case k4_ChampionActionBlowHorn:
 		if (actionIndex == k8_ChampionActionWarCry) {
-			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			_vm->f064_SOUND_RequestPlay_CPSD(k28_soundWAR_CRY, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
 		}
 		if (actionIndex == k4_ChampionActionBlowHorn) {
-			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			_vm->f064_SOUND_RequestPlay_CPSD(k25_soundBLOW_HORN, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
 		}
 		AL1245_B_ActionPerformed = f401_isGroupFrightenedByAction(champIndex, actionIndex, L1251_i_MapX, L1252_i_MapY);
 		break;
@@ -1176,7 +1176,7 @@ T0407032:
 		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
 		{ // so gotos won't skip init
 			Thing AL1250_T_Object = _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
-			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 			_vm->_championMan->f326_championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->f303_getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy);
 		}
 		break;
@@ -1439,8 +1439,7 @@ bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int
 #define AL1237_ui_ActionHitProbability L1237_ui_Multiple
 	int16 L1238_i_CreatureOrdinal;
 
-
-	warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+	_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 	if (_g517_actionTargetGroupThing == Thing::_endOfList)
 		goto T0402010;
 	if (L1238_i_CreatureOrdinal = _vm->_groupMan->f177_getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, AL1236_ui_ChampionCell = champ->_cell)) {
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 65742e6..7541380 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -181,7 +181,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 			if (!L0753_B_DoNotTriggerSensor) {
 				L0759_B_AtLeastOneSensorWasTriggered = true;
 				if (L0755_ps_Sensor->getAudibleA()) {
-					warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+					_vm->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 				}
 				if (!_vm->_championMan->_g415_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
 					L0754_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0761_T_LeaderHandObject);
@@ -296,7 +296,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					_vm->_dungeonMan->_g306_partyMapX = destMapX;
 					_vm->_dungeonMan->_g307_partyMapY = destMapY;
 					if (L0712_ps_Teleporter->isAudible()) {
-						warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+						_vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
 					}
 					L0723_B_DrawDungeonViewWhileFalling = true;
 					if (L0712_ps_Teleporter->getAbsoluteRotation()) {
@@ -307,7 +307,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				} else {
 					if (L0710_i_ThingType == k4_GroupThingType) {
 						if (L0712_ps_Teleporter->isAudible()) {
-							warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+							_vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, destMapX, destMapY, k1_soundModePlayIfPrioritized);
 						}
 						L0720_ui_MoveGroupResult = f262_getTeleporterRotatedGroupResult(L0712_ps_Teleporter, thing, L0714_ui_MapIndexSource);
 					} else {
@@ -349,7 +349,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 								}
 							} else {
 								if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF)) {
-									warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+									_vm->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
 								}
 							}
 						}
@@ -477,7 +477,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				}
 				L1638_ui_MovementSoundIndex = f514_getSound(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[thing.getIndex()]._type);
 				if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) {
-					warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+					_vm->f064_SOUND_RequestPlay_CPSD(L1638_ui_MovementSoundIndex, destMapX, destMapY, k1_soundModePlayIfPrioritized);
 				}
 				if (L0721_B_GroupOnPartyMap && (L0715_ui_MapIndexDestination != _vm->_dungeonMan->_g309_partyMapIndex)) { /* If the group leaves the party map */
 					_vm->_groupMan->f184_removeActiveGroup(AL0708_i_ActiveGroupIndex);
@@ -896,7 +896,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 					goto T0276079;
 			}
 			if (L0769_ps_Sensor->getAudibleA()) {
-				warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+				_vm->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized);
 			}
 			f272_sensorTriggerEffect(L0769_ps_Sensor, L0778_i_Effect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
 			goto T0276079;
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 7d99b97..8996693 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -230,7 +230,7 @@ T0217004:
 				AL0507_ui_SoundIndex = k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM;
 			}
 		}
-		warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+		_vm->f064_SOUND_RequestPlay_CPSD(AL0507_ui_SoundIndex, L0499_i_ProjectileMapX, L0500_i_ProjectileMapY, k1_soundModePlayIfPrioritized);
 	}
 T0217044:
 	if (L0509_B_RemovePotion) {
@@ -321,10 +321,10 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 	L0470_ps_Explosion->setType(explThing.toUint16() - Thing::_firstExplosion.toUint16());
 	L0470_ps_Explosion->setAttack(attack);
 	if (explThing.toUint16() < Thing::_explHarmNonMaterial.toUint16()) {
-		warning(false, "MISING CODE: F0064_SOUND_RequestPlay_CPSD");
+		_vm->f064_SOUND_RequestPlay_CPSD((attack > 80) ? k05_soundSTRONG_EXPLOSION : k20_soundWEAK_EXPLOSION, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized);
 	} else {
 		if (explThing != Thing::_explSmoke) {
-			warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+			_vm->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized);
 		}
 	}
 	_vm->_dungeonMan->f163_linkThingToList(L0473_T_Thing, Thing(0), AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY);
@@ -564,7 +564,7 @@ void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) {
 		break;
 	case 0xFFE4:
 		L0532_ps_Explosion->setType(L0532_ps_Explosion->getType() + 1);
-		warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+		_vm->f064_SOUND_RequestPlay_CPSD(k05_soundSTRONG_EXPLOSION, L0528_ui_MapX, L0529_ui_MapY, k1_soundModePlayIfPrioritized);
 		goto T0220026;
 	case 0xFFA8:
 		if (L0532_ps_Explosion->getAttack() > 55) {
diff --git a/engines/dm/text.h b/engines/dm/text.h
index c07b8f2..e0f5e7a 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -56,9 +56,7 @@ public:
 	void f42_messageAreaMoveCursor(int16 column, int16 row); // @ F0042_TEXT_MESSAGEAREA_MoveCursor
 	void f44_messageAreaClearExpiredRows(); // @ F0044_TEXT_MESSAGEAREA_ClearExpiredRows
 
-
 };
 
 }
-
 #endif
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 37eb880..09e31bf 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -318,7 +318,7 @@ void Timeline::f261_processTimeline() {
 				f246_timelineProcesEvent65_enableGroupGenerator(L0681_ps_Event);
 				break;
 			case k20_TMEventTypePlaySound:
-				warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+				_vm->f064_SOUND_RequestPlay_CPSD(L0682_s_Event._C._soundIndex, L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, k1_soundModePlayIfPrioritized);
 				break;
 			case k24_TMEventTypeRemoveFluxcage:
 				if (!_vm->_g302_gameWon) {
@@ -421,7 +421,7 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 				// Original bug fixed - A closing horizontal door wounds champions to the head instead of to the hands. Missing parenthesis in the condition cause all doors to wound the head in addition to the torso
 				// See BUG0_78
 				if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(5, k0x0008_ChampionWoundTorso | (AL0602_ui_VerticalDoor ? k0x0004_ChampionWoundHead : k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand), k2_attackType_SELF)) {
-					warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+					_vm->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
 				}
 			}
 			event->_mapTime++;
@@ -435,7 +435,7 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 				}
 				L0596_i_DoorState = (L0596_i_DoorState == k0_doorState_OPEN) ? k0_doorState_OPEN : (L0596_i_DoorState - 1);
 				L0597_puc_Square->setDoorState(L0596_i_DoorState);
-				warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+				_vm->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
 				event->_mapTime++;
 				_vm->_timeline->f238_addEventGetEventIndex(event);
 				return;
@@ -447,7 +447,8 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 	}
 	L0596_i_DoorState += (L0595_i_Effect == k0_SensorEffSet) ? -1 : 1;
 	L0597_puc_Square->setDoorState(L0596_i_DoorState);
-	warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+	_vm->f064_SOUND_RequestPlay_CPSD(k02_soundDOOR_RATTLE, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
+
 	if (L0595_i_Effect == k0_SensorEffSet) {
 		if (L0596_i_DoorState == k0_doorState_OPEN) {
 			return;
@@ -838,7 +839,7 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 					}
 					_vm->_groupMan->f185_groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY);
 					if (L0614_ps_Sensor->getAudibleA()) {
-						warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+						_vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0616_ui_MapX, L0617_ui_MapY, k1_soundModePlayIfPrioritized);
 					}
 					if (L0614_ps_Sensor->getOnlyOnce()) {
 						L0614_ps_Sensor->setTypeDisabled();
@@ -878,7 +879,7 @@ void Timeline::f252_timelineProcessEvents60to61_moveGroup(TimelineEvent* event)
 T0252001:
 	if (((_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) || (L0656_ui_MapX != _vm->_dungeonMan->_g306_partyMapX) || (L0657_ui_MapY != _vm->_dungeonMan->_g307_partyMapY)) && (_vm->_groupMan->f175_groupGetThing(L0656_ui_MapX, L0657_ui_MapY) == Thing::_endOfList)) { /* BUG0_24 Lord Chaos may teleport into one of the Black Flames and become invisible until the Black Flame is killed. In this case, _vm->_groupMan->f175_groupGetThing returns the Black Flame thing and the Lord Chaos thing is not moved into the dungeon until the Black Flame is killed */
 		if (event->_type == k61_TMEventTypeMoveGroupAudible) {
-			warning(false, "F0064_SOUND_RequestPlay_CPSD");
+			_vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0656_ui_MapX, L0657_ui_MapY, k1_soundModePlayIfPrioritized);
 		}
 		_vm->_movsens->f267_getMoveResult(Thing(event->_C._slot), kM1_MapXNotOnASquare, 0, L0656_ui_MapX, L0657_ui_MapY);
 	} else {


Commit: 5418c2288b9a8e34f528f0d6f59dec5e7b959e5f
    https://github.com/scummvm/scummvm/commit/5418c2288b9a8e34f528f0d6f59dec5e7b959e5f
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some more CppCheck warnings

Changed paths:
    engines/dm/menus.cpp
    engines/dm/movesens.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 146a75e..f2c372c 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -659,24 +659,17 @@ Spell* MenuMan::f409_getSpellFromSymbols(byte* symbols) {
 		Spell(0x00687073, 4, 13, 0x3C61),
 		Spell(0x006B7076, 3,  2, 0xFCD1),
 		Spell(0x006B6C00, 2, 19, 0x7831),
-		Spell(0x006B6E76, 0,  3, 0x3C73)};
-
-
-	int32 L1261_l_Symbols;
-	int16 L1262_i_Multiple;
-#define AL1262_i_BitShiftCount L1262_i_Multiple
-#define AL1262_i_SpellIndex    L1262_i_Multiple
-	Spell* L1263_ps_Spell;
-
+		Spell(0x006B6E76, 0,  3, 0x3C73)
+	};
 
 	if (*(symbols + 1)) {
-		AL1262_i_BitShiftCount = 24;
-		L1261_l_Symbols = 0;
+		int16 AL1262_i_BitShiftCount = 24;
+		int32 L1261_l_Symbols = 0;
 		do {
 			L1261_l_Symbols |= (long)*symbols++ << AL1262_i_BitShiftCount;
 		} while (*symbols && ((AL1262_i_BitShiftCount -= 8) >= 0));
-		L1263_ps_Spell = G0487_as_Graphic560_Spells;
-		AL1262_i_SpellIndex = 25;
+		Spell *L1263_ps_Spell = G0487_as_Graphic560_Spells;
+		int16 AL1262_i_SpellIndex = 25;
 		while (AL1262_i_SpellIndex--) {
 			if (L1263_ps_Spell->_symbols & 0xFF000000) { /* If byte 1 of spell is not 0 then the spell includes the power symbol */
 				if (L1261_l_Symbols == L1263_ps_Spell->_symbols) { /* Compare champion symbols, including power symbol, with spell (never used with actual spells) */
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 7541380..d8337bc 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -232,17 +232,12 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 	uint16 L1638_ui_MovementSoundIndex;
 
 	L0710_i_ThingType = kM1_PartyThingType;
-	bool L0713_B_ThingLevitates = false;
 	L0719_i_TraversedPitCount = 0;
 	L0720_ui_MoveGroupResult = 0;
-	bool L0721_B_GroupOnPartyMap = false;
-	bool L0722_B_FallKilledGroup = false;
-	bool L0723_B_DrawDungeonViewWhileFalling = false;
-	bool L0724_B_DestinationIsTeleporterTarget = false;
-	bool L0725_B_PartySquare = false;
-	bool L0726_B_Audible = false;
 
 	uint16 L0717_ui_ThingCell = 0;
+
+	bool L0713_B_ThingLevitates = false;
 	if (thing != Thing::_party) {
 		L0710_i_ThingType = thing.getType();
 		L0717_ui_ThingCell = thing.getCell();
@@ -254,12 +249,20 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 			return true; /* The specified group thing cannot be moved because it was killed by a projectile impact */
 		}
 	}
+
 	uint16 L0714_ui_MapIndexSource = 0;
 	uint16 L0715_ui_MapIndexDestination = 0;
+	bool L0721_B_GroupOnPartyMap = false;
+	bool L0725_B_PartySquare = false;
+	bool L0726_B_Audible = false;
+
 	if (destMapX >= 0) {
 		L0714_ui_MapIndexSource = L0715_ui_MapIndexDestination = _vm->_dungeonMan->_g272_currMapIndex;
 		L0721_B_GroupOnPartyMap = (L0714_ui_MapIndexSource == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX >= 0);
 		uint16 L0716_ui_Direction = 0;
+		bool L0722_B_FallKilledGroup = false;
+		bool L0723_B_DrawDungeonViewWhileFalling = false;
+		bool L0724_B_DestinationIsTeleporterTarget = false;
 		if (thing == Thing::_party) {
 			_vm->_dungeonMan->_g306_partyMapX = destMapX;
 			_vm->_dungeonMan->_g307_partyMapY = destMapY;


Commit: 5cef0e66be1a905d35f09d2984d0ce743eb0bfd0
    https://github.com/scummvm/scummvm/commit/5cef0e66be1a905d35f09d2984d0ce743eb0bfd0
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Light refactoring and renaming of local variables in f328_isObjectThrown

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 8c3aacd..8925187 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -164,62 +164,55 @@ bool ChampionMan::f329_isLeaderHandObjectThrown(int16 side) {
 }
 
 bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side) {
-	int16 L0993_i_KineticEnergy;
-	int16 L0994_i_Multiple;
-#define AL0994_i_Experience L0994_i_Multiple
-#define AL0994_i_Attack     L0994_i_Multiple
-	int16 L0995_i_Multiple;
-#define AL0995_i_WeaponKineticEnergy L0995_i_Multiple
-#define AL0995_i_SkillLevel          L0995_i_Multiple
-#define AL0995_i_StepEnergy          L0995_i_Multiple
-	Thing L0996_T_Thing;
-	Champion* L0997_ps_Champion = nullptr;
-	WeaponInfo* L0998_ps_WeaponInfo;
-	Thing L0999_T_ActionHandThing;
-	bool L1000_B_ThrowingLeaderHandObject;
-
-
-	L1000_B_ThrowingLeaderHandObject = false;
+	bool throwingLeaderHandObjectFl = false;
+	Thing curThing;
+	Champion *curChampion = nullptr;
+	Thing actionHandThing;
+
 	if (slotIndex < 0) { /* Throw object in leader hand, which is temporarily placed in action hand */
-		if (_g415_leaderEmptyHanded) {
+		if (_g415_leaderEmptyHanded)
 			return false;
-		}
-		L0996_T_Thing = f298_getObjectRemovedFromLeaderHand();
-		L0997_ps_Champion = &_gK71_champions[champIndex];
-		L0999_T_ActionHandThing = L0997_ps_Champion->getSlot(k1_ChampionSlotActionHand);
-		L0997_ps_Champion->setSlot(k1_ChampionSlotActionHand, L0996_T_Thing);
+
+		curThing = f298_getObjectRemovedFromLeaderHand();
+		curChampion = &_gK71_champions[champIndex];
+		actionHandThing = curChampion->getSlot(k1_ChampionSlotActionHand);
+		curChampion->setSlot(k1_ChampionSlotActionHand, curThing);
 		slotIndex = k1_ChampionSlotActionHand;
-		L1000_B_ThrowingLeaderHandObject = true;
+		throwingLeaderHandObjectFl = true;
 	}
-	L0993_i_KineticEnergy = f312_getStrength(champIndex, slotIndex);
-	if (L1000_B_ThrowingLeaderHandObject) {
-		L0997_ps_Champion->setSlot((ChampionSlot)slotIndex, L0999_T_ActionHandThing);
+
+	int16 kineticEnergy = f312_getStrength(champIndex, slotIndex);
+	if (throwingLeaderHandObjectFl) {
+		// In this case, curChampion and actionHandThing are set.
+		curChampion->setSlot((ChampionSlot)slotIndex, actionHandThing);
 	} else {
-		if ((L0996_T_Thing = f300_getObjectRemovedFromSlot(champIndex, slotIndex)) == Thing::_none) {
+		curThing = f300_getObjectRemovedFromSlot(champIndex, slotIndex);
+		if (curThing == Thing::_none)
 			return false;
-		}
 	}
+
 	_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
-	f325_decrementStamine(champIndex, f305_getThrowingStaminaCost(L0996_T_Thing));
+	f325_decrementStamine(champIndex, f305_getThrowingStaminaCost(curThing));
 	f330_disableAction(champIndex, 4);
-	AL0994_i_Experience = 8;
-	AL0995_i_WeaponKineticEnergy = 1;
-	if (L0996_T_Thing.getType() == k5_WeaponThingType) {
-		AL0994_i_Experience += 4;
-		L0998_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0996_T_Thing);
-		if (L0998_ps_WeaponInfo->_class <= k12_WeaponClassPoisinDart) {
-			AL0994_i_Experience += (AL0995_i_WeaponKineticEnergy = L0998_ps_WeaponInfo->_kineticEnergy) >> 2;
-		}
-	}
-	f304_addSkillExperience(champIndex, k10_ChampionSkillThrow, AL0994_i_Experience);
-	L0993_i_KineticEnergy += AL0995_i_WeaponKineticEnergy;
-	AL0995_i_SkillLevel = f303_getSkillLevel((ChampionIndex)champIndex, k10_ChampionSkillThrow);
-	L0993_i_KineticEnergy += _vm->_rnd->getRandomNumber(16) + (L0993_i_KineticEnergy >> 1) + AL0995_i_SkillLevel;
-	AL0994_i_Attack = f26_getBoundedValue((uint16)40, (uint16)((AL0995_i_SkillLevel << 3) + _vm->_rnd->getRandomNumber(31)), (uint16)200);
-	AL0995_i_StepEnergy = MAX(5, 11 - AL0995_i_SkillLevel);
-	_vm->_projexpl->f212_projectileCreate(L0996_T_Thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY,
+	int16 experience = 8;
+	int16 weaponKineticEnergy = 1;
+	if (curThing.getType() == k5_WeaponThingType) {
+		experience += 4;
+		WeaponInfo *curWeapon = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
+		if (curWeapon->_class <= k12_WeaponClassPoisinDart) {
+			weaponKineticEnergy = curWeapon->_kineticEnergy;
+			experience += weaponKineticEnergy >> 2;
+		}
+	}
+	f304_addSkillExperience(champIndex, k10_ChampionSkillThrow, experience);
+	kineticEnergy += weaponKineticEnergy;
+	int16 skillLevel = f303_getSkillLevel((ChampionIndex)champIndex, k10_ChampionSkillThrow);
+	kineticEnergy += _vm->_rnd->getRandomNumber(16) + (kineticEnergy >> 1) + skillLevel;
+	int16 attack = f26_getBoundedValue((uint16)40, (uint16)((skillLevel << 3) + _vm->_rnd->getRandomNumber(31)), (uint16)200);
+	int16 stepEnergy = MAX(5, 11 - skillLevel);
+	_vm->_projexpl->f212_projectileCreate(curThing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY,
 										  M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + side),
-										  _vm->_dungeonMan->_g308_partyDir, L0993_i_KineticEnergy, AL0994_i_Attack, AL0995_i_StepEnergy);
+										  _vm->_dungeonMan->_g308_partyDir, kineticEnergy, attack, stepEnergy);
 	_vm->_g311_projectileDisableMovementTicks = 4;
 	_vm->_g312_lastProjectileDisabledMovementDirection = _vm->_dungeonMan->_g308_partyDir;
 	f292_drawChampionState((ChampionIndex)champIndex);
@@ -255,9 +248,8 @@ uint16 ChampionMan::M70_handSlotIndex(uint16 slotBoxIndex) {
 }
 
 Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) {
-	using namespace Common;
-	String valToStr = String::format("%d", val);
-	String result;
+	Common::String valToStr = Common::String::format("%d", val);
+	Common::String result;
 	for (int16 i = 0, end = paddingCharCount - valToStr.size(); i < end; ++i)
 		result += ' ';
 


Commit: 9d5b3f53c8fac7db5530f3c0a5a4ab0987859a2e
    https://github.com/scummvm/scummvm/commit/9d5b3f53c8fac7db5530f3c0a5a4ab0987859a2e
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix a bug in f288_getStringFromInteger

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 8925187..b44a808 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -250,8 +250,11 @@ uint16 ChampionMan::M70_handSlotIndex(uint16 slotBoxIndex) {
 Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) {
 	Common::String valToStr = Common::String::format("%d", val);
 	Common::String result;
-	for (int16 i = 0, end = paddingCharCount - valToStr.size(); i < end; ++i)
-		result += ' ';
+
+	if (padding) {
+		for (int16 i = 0, end = paddingCharCount - valToStr.size(); i < end; ++i)
+			result += ' ';
+	}
 
 	return result += valToStr;
 }


Commit: a46d815617606ee5bd3d468b679f04d33e2207b7
    https://github.com/scummvm/scummvm/commit/a46d815617606ee5bd3d468b679f04d33e2207b7
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f299_applyModifiersToStatistics, remove a GOTO.

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index b44a808..a7c6ce5 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -260,128 +260,140 @@ Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding,
 }
 
 void ChampionMan::f299_applyModifiersToStatistics(Champion* champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing) {
-	int16 statIndex;
+	int16 statIndex = k0_ChampionStatLuck;
 	int16 modifier = 0;
 	ThingType thingType = thing.getType();
-	if (((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType))
-		&& (slotIndex >= k0_ChampionSlotReadyHand)
-		&& (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) {
-		Weapon *weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(thing);
-		Armour *armour = (Armour *)_vm->_dungeonMan->f156_getThingData(thing);
-		if (((thingType == k5_WeaponThingType) && weapon->getCursed())
-			|| ((thingType == k6_ArmourThingType) && armour->getCursed())) {
+
+	bool cursed = false;
+	if (   ((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType))
+		&& (slotIndex >= k0_ChampionSlotReadyHand) && (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) {
+		if (thingType == k5_WeaponThingType) {
+			Weapon *weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(thing);
+			cursed = weapon->getCursed();
+		} else {
+			// k6_ArmourThingType
+			Armour *armour = (Armour *)_vm->_dungeonMan->f156_getThingData(thing);
+			cursed = armour->getCursed();
+		}
+
+		if (cursed) {
 			statIndex = k0_ChampionStatLuck;
 			modifier = -3;
-			goto T0299044_ApplyModifier;
 		}
 	}
 
-	statIndex = (ChampionStatisticType)thingType; // variable sharing
+	if (!cursed) {
+		statIndex = (ChampionStatisticType)thingType; // variable sharing
 
-	if ((iconIndex == k137_IconIndiceJunkRabbitsFoot) && (slotIndex < k30_ChampionSlotChest_1)) {
-		statIndex = k0_ChampionStatLuck;
-		modifier = 10;
-	} else if (slotIndex == k1_ChampionSlotActionHand) {
-
-		if (iconIndex == k45_IconIndiceWeaponMaceOfOrder) {
-			statIndex = k1_ChampionStatStrength;
-			modifier = 5;
-		} else {
-
-			statIndex = k8_ChampionStatMana;
-			if ((iconIndex >= k20_IconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= k22_IconIndiceWeaponStaffOfClawsFull)) {
-				modifier = 4;
-			} else if ((iconIndex >= k58_IconIndiceWeaponStaff) && (iconIndex <= k66_IconIndiceWeaponSceptreOfLyf)) {
-				switch (iconIndex) {
-				case k58_IconIndiceWeaponStaff:
-					modifier = 2;
-					break;
-				case k59_IconIndiceWeaponWand:
-					modifier = 1;
-					break;
-				case k60_IconIndiceWeaponTeowand:
-					modifier = 6;
-					break;
-				case k61_IconIndiceWeaponYewStaff:
-					modifier = 4;
-					break;
-				case k62_IconIndiceWeaponStaffOfManarStaffOfIrra:
-					modifier = 10;
-					break;
-				case k63_IconIndiceWeaponSnakeStaffCrossOfNeta:
-					modifier = 8;
-					break;
-				case k64_IconIndiceWeaponTheConduitSerpentStaff:
-					modifier = 16;
-					break;
-				case k65_IconIndiceWeaponDragonSpit:
-					modifier = 7;
-					break;
-				case k66_IconIndiceWeaponSceptreOfLyf:
-					modifier = 5;
-					break;
-				}
+		if ((iconIndex == k137_IconIndiceJunkRabbitsFoot) && (slotIndex < k30_ChampionSlotChest_1)) {
+			statIndex = k0_ChampionStatLuck;
+			modifier = 10;
+		} else if (slotIndex == k1_ChampionSlotActionHand) {
+			if (iconIndex == k45_IconIndiceWeaponMaceOfOrder) {
+				statIndex = k1_ChampionStatStrength;
+				modifier = 5;
 			} else {
-				switch (iconIndex) {
-				case k38_IconIndiceWeaponDeltaSideSplitter:
-					modifier = 1;
-					break;
-				case k41_IconIndiceWeaponTheInquisitorDragonFang:
-					modifier = 2;
-					break;
-				case k40_IconIndiceWeaponVorpalBlade:
+				statIndex = k8_ChampionStatMana;
+				if ((iconIndex >= k20_IconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= k22_IconIndiceWeaponStaffOfClawsFull)) {
 					modifier = 4;
-					break;
+				} else {
+					switch (iconIndex) {
+					case k38_IconIndiceWeaponDeltaSideSplitter:
+						modifier = 1;
+						break;
+					case k41_IconIndiceWeaponTheInquisitorDragonFang:
+						modifier = 2;
+						break;
+					case k40_IconIndiceWeaponVorpalBlade:
+						modifier = 4;
+						break;
+					case k58_IconIndiceWeaponStaff:
+						modifier = 2;
+						break;
+					case k59_IconIndiceWeaponWand:
+						modifier = 1;
+						break;
+					case k60_IconIndiceWeaponTeowand:
+						modifier = 6;
+						break;
+					case k61_IconIndiceWeaponYewStaff:
+						modifier = 4;
+						break;
+					case k62_IconIndiceWeaponStaffOfManarStaffOfIrra:
+						modifier = 10;
+						break;
+					case k63_IconIndiceWeaponSnakeStaffCrossOfNeta:
+						modifier = 8;
+						break;
+					case k64_IconIndiceWeaponTheConduitSerpentStaff:
+						modifier = 16;
+						break;
+					case k65_IconIndiceWeaponDragonSpit:
+						modifier = 7;
+						break;
+					case k66_IconIndiceWeaponSceptreOfLyf:
+						modifier = 5;
+						break;
+					default:
+						break;
+					}
 				}
-			} // end of else
-
-		}
-
-	} else if (slotIndex == k4_ChampionSlotLegs) {
-
-		if (iconIndex == k142_IconIndiceArmourPowertowers) {
-			statIndex = k1_ChampionStatStrength;
-			modifier = 10;
-		}
-
-	} else if (slotIndex == k2_ChampionSlotHead) {
-
-		if (iconIndex == k104_IconIndiceArmourCrownOfNerra) {
-			statIndex = k3_ChampionStatWisdom;
-			modifier = 10;
-		} else if (iconIndex == k140_IconIndiceArmourDexhelm) {
-			statIndex = k2_ChampionStatDexterity;
-			modifier = 10;
-		}
-
-	} else if (slotIndex == k3_ChampionSlotTorso) {
-
-		if (iconIndex == k141_IconIndiceArmourFlamebain) {
-			statIndex = k6_ChampionStatAntifire;
-			modifier = 12;
-		} else if (iconIndex == k81_IconIndiceArmourCloakOfNight) {
-			statIndex = k2_ChampionStatDexterity;
-			modifier = 8;
-		}
-
-	} else if (slotIndex == k10_ChampionSlotNeck) {
-
-		if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
-			statIndex = k5_ChampionStatAntimagic;
-			modifier = 15;
-		} else if (iconIndex == k81_IconIndiceArmourCloakOfNight) {
-			statIndex = k2_ChampionStatDexterity;
-			modifier = 8;
-		} else if (iconIndex == k122_IconIndiceJunkMoonstone) {
-			statIndex = k8_ChampionStatMana;
-			modifier = 3;
+			}
+		} else if (slotIndex == k4_ChampionSlotLegs) {
+			if (iconIndex == k142_IconIndiceArmourPowertowers) {
+				statIndex = k1_ChampionStatStrength;
+				modifier = 10;
+			}
+		} else if (slotIndex == k2_ChampionSlotHead) {
+			switch (iconIndex) {
+			case k104_IconIndiceArmourCrownOfNerra:
+				statIndex = k3_ChampionStatWisdom;
+				modifier = 10;
+				break;
+			case k140_IconIndiceArmourDexhelm:
+				statIndex = k2_ChampionStatDexterity;
+				modifier = 10;
+				break;
+			default:
+				break;
+			}
+		} else if (slotIndex == k3_ChampionSlotTorso) {
+			switch (iconIndex) {
+			case k141_IconIndiceArmourFlamebain:
+				statIndex = k6_ChampionStatAntifire;
+				modifier = 12;
+				break;
+			case k81_IconIndiceArmourCloakOfNight:
+				statIndex = k2_ChampionStatDexterity;
+				modifier = 8;
+				break;
+			default:
+				break;
+			}
+		} else if (slotIndex == k10_ChampionSlotNeck) {
+			switch (iconIndex) {
+			case k10_IconIndiceJunkJewelSymalUnequipped:
+			case k11_IconIndiceJunkJewelSymalEquipped:
+				statIndex = k5_ChampionStatAntimagic;
+				modifier = 15;
+				break;
+			case k81_IconIndiceArmourCloakOfNight:
+				statIndex = k2_ChampionStatDexterity;
+				modifier = 8;
+				break;
+			case k122_IconIndiceJunkMoonstone:
+				statIndex = k8_ChampionStatMana;
+				modifier = 3;
+				break;
+			default:
+				break;
+			}
 		}
-
 	}
 
-T0299044_ApplyModifier:
 	if (modifier) {
 		modifier *= modifierFactor;
+		//statIndex is set when modifier is set
 		if (statIndex == k8_ChampionStatMana) {
 			champ->_maxMana += modifier;
 		} else if (statIndex < k6_ChampionStatAntifire + 1) {
@@ -390,7 +402,6 @@ T0299044_ApplyModifier:
 			}
 		}
 	}
-
 }
 
 bool ChampionMan::f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) {


Commit: 18ea37f5fb28df27826f10e3d0f003e593f661b0
    https://github.com/scummvm/scummvm/commit/18ea37f5fb28df27826f10e3d0f003e593f661b0
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some renaming in f298_getObjectRemovedFromLeaderHand, refactor f312_getStrength

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index a7c6ce5..6b43126 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -259,7 +259,7 @@ Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding,
 	return result += valToStr;
 }
 
-void ChampionMan::f299_applyModifiersToStatistics(Champion* champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing) {
+void ChampionMan::f299_applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing) {
 	int16 statIndex = k0_ChampionStatLuck;
 	int16 modifier = 0;
 	ThingType thingType = thing.getType();
@@ -518,7 +518,6 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 	uint16 *rawObjPtr = dunMan.f156_getThingData(thing);
 
 	if (slotIndex < k2_ChampionSlotHead) {
-
 		if (slotIndex == k1_ChampionSlotActionHand) {
 			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
 			if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))
@@ -538,9 +537,7 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 			((iconIndex == k144_IconIndiceContainerChestClosed) || ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)))) {
 			champ->setAttributeFlag(k0x0800_ChampionAttributePanel, true);
 		}
-
 	} else if (slotIndex == k10_ChampionSlotNeck) {
-
 		if ((iconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (iconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
 			((Junk *)rawObjPtr)->setChargeCount(1);
 			_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2];
@@ -550,7 +547,6 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 			((Junk *)rawObjPtr)->setChargeCount(1);
 			iconIndex = (IconIndice)(iconIndex + 1);
 		}
-
 	}
 
 	f291_drawSlot(champIndex, slotIndex);
@@ -567,7 +563,7 @@ int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) {
 		searchedScent.setMapY(mapY);
 		searchedScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex);
 		uint16 searchedScentRedEagle = searchedScent.toUint16();
-		Scent* scent = &_g407_party._scents[scentIndex--];
+		Scent *scent = &_g407_party._scents[scentIndex--];
 		do {
 			if ((*(--scent)).toUint16() == searchedScentRedEagle) {
 				return _vm->M0_indexToOrdinal(scentIndex);
@@ -578,11 +574,10 @@ int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) {
 }
 
 Thing ChampionMan::f298_getObjectRemovedFromLeaderHand() {
-	Thing L0890_T_LeaderHandObject;
-
-
 	_g415_leaderEmptyHanded = true;
-	if ((L0890_T_LeaderHandObject = _g414_leaderHandObject) != Thing::_none) {
+	Thing leaderHandObject = _g414_leaderHandObject;
+
+	if (leaderHandObject != Thing::_none) {
 		_g414_leaderHandObject = Thing::_none;
 		_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
 		_vm->_eventMan->f78_showMouse();
@@ -590,69 +585,59 @@ Thing ChampionMan::f298_getObjectRemovedFromLeaderHand() {
 		_vm->_eventMan->f69_setMousePointer();
 		_vm->_eventMan->f77_hideMouse();
 		if (_g411_leaderIndex != kM1_ChampionNone) {
-			_gK71_champions[_g411_leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(L0890_T_LeaderHandObject);
+			_gK71_champions[_g411_leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(leaderHandObject);
 			setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
 			f292_drawChampionState(_g411_leaderIndex);
 		}
 	}
-	return L0890_T_LeaderHandObject;
+	return leaderHandObject;
 }
 
 uint16 ChampionMan::f312_getStrength(int16 champIndex, int16 slotIndex) {
-	int16 L0935_i_Strength;
-	uint16 L0936_ui_Multiple;
-#define AL0936_ui_ObjectWeight L0936_ui_Multiple
-#define AL0936_ui_SkillLevel   L0936_ui_Multiple
-	uint16 L0937_ui_Multiple;
-#define AL0937_ui_OneSixteenthMaximumLoad L0937_ui_Multiple
-#define AL0937_ui_Class                   L0937_ui_Multiple
-	Thing L0938_T_Thing;
-	Champion* L0939_ps_Champion;
-	WeaponInfo* L0940_ps_WeaponInfo;
-	int16 L0941_i_LoadThreshold;
-
-
-	L0939_ps_Champion = &_gK71_champions[champIndex];
-	L0935_i_Strength = _vm->_rnd->getRandomNumber(15) + L0939_ps_Champion->_statistics[k1_ChampionStatStrength][k1_ChampionStatCurrent];
-	L0938_T_Thing = L0939_ps_Champion->_slots[slotIndex];
-	if ((AL0936_ui_ObjectWeight = _vm->_dungeonMan->f140_getObjectWeight(L0938_T_Thing)) <= (AL0937_ui_OneSixteenthMaximumLoad = f309_getMaximumLoad(L0939_ps_Champion) >> 4)) {
-		L0935_i_Strength += AL0936_ui_ObjectWeight - 12;
+	Champion *curChampion = &_gK71_champions[champIndex];
+	int16 strength = _vm->_rnd->getRandomNumber(15) + curChampion->_statistics[k1_ChampionStatStrength][k1_ChampionStatCurrent];
+	Thing curThing = curChampion->_slots[slotIndex];
+	uint16 objectWeight = _vm->_dungeonMan->f140_getObjectWeight(curThing);
+	uint16 oneSixteenthMaximumLoad = f309_getMaximumLoad(curChampion) >> 4;
+
+	if (objectWeight <= oneSixteenthMaximumLoad) {
+		strength += objectWeight - 12;
 	} else {
-		if (AL0936_ui_ObjectWeight <= (L0941_i_LoadThreshold = AL0937_ui_OneSixteenthMaximumLoad + ((AL0937_ui_OneSixteenthMaximumLoad - 12) >> 1))) {
-			L0935_i_Strength += (AL0936_ui_ObjectWeight - AL0937_ui_OneSixteenthMaximumLoad) >> 1;
+		int16 loadThreshold = oneSixteenthMaximumLoad + ((oneSixteenthMaximumLoad - 12) >> 1);
+		if (objectWeight <= loadThreshold) {
+			strength += (objectWeight - oneSixteenthMaximumLoad) >> 1;
 		} else {
-			L0935_i_Strength -= (AL0936_ui_ObjectWeight - L0941_i_LoadThreshold) << 1;
+			strength -= (objectWeight - loadThreshold) << 1;
 		}
 	}
-	if (L0938_T_Thing.getType() == k5_WeaponThingType) {
-		L0940_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0938_T_Thing);
-		L0935_i_Strength += L0940_ps_WeaponInfo->_strength;
-		AL0936_ui_SkillLevel = 0;
-		AL0937_ui_Class = L0940_ps_WeaponInfo->_class;
-		if ((AL0937_ui_Class == k0_WeaponClassSwingWeapon) || (AL0937_ui_Class == k2_WeaponClassDaggerAndAxes)) {
-			AL0936_ui_SkillLevel = f303_getSkillLevel(champIndex, k4_ChampionSkillSwing);
+	if (curThing.getType() == k5_WeaponThingType) {
+		WeaponInfo *weaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
+		strength += weaponInfo->_strength;
+		uint16 skillLevel = 0;
+		uint16 weaponClass = weaponInfo->_class;
+		if ((weaponClass == k0_WeaponClassSwingWeapon) || (weaponClass == k2_WeaponClassDaggerAndAxes)) {
+			skillLevel = f303_getSkillLevel(champIndex, k4_ChampionSkillSwing);
 		}
-		if ((AL0937_ui_Class != k0_WeaponClassSwingWeapon) && (AL0937_ui_Class < k16_WeaponClassFirstBow)) {
-			AL0936_ui_SkillLevel += f303_getSkillLevel(champIndex, k10_ChampionSkillThrow);
+		if ((weaponClass != k0_WeaponClassSwingWeapon) && (weaponClass < k16_WeaponClassFirstBow)) {
+			skillLevel += f303_getSkillLevel(champIndex, k10_ChampionSkillThrow);
 		}
-		if ((AL0937_ui_Class >= k16_WeaponClassFirstBow) && (AL0937_ui_Class < k112_WeaponClassFirstMagicWeapon)) {
-			AL0936_ui_SkillLevel += f303_getSkillLevel(champIndex, k11_ChampionSkillShoot);
+		if ((weaponClass >= k16_WeaponClassFirstBow) && (weaponClass < k112_WeaponClassFirstMagicWeapon)) {
+			skillLevel += f303_getSkillLevel(champIndex, k11_ChampionSkillShoot);
 		}
-		L0935_i_Strength += AL0936_ui_SkillLevel << 1;
+		strength += skillLevel << 1;
 	}
-	L0935_i_Strength = f306_getStaminaAdjustedValue(L0939_ps_Champion, L0935_i_Strength);
-	if (getFlag(L0939_ps_Champion->_wounds, (slotIndex == k0_ChampionSlotReadyHand) ? k0x0001_ChampionWoundReadHand : k0x0002_ChampionWoundActionHand)) {
-		L0935_i_Strength >>= 1;
+	strength = f306_getStaminaAdjustedValue(curChampion, strength);
+	if (getFlag(curChampion->_wounds, (slotIndex == k0_ChampionSlotReadyHand) ? k0x0001_ChampionWoundReadHand : k0x0002_ChampionWoundActionHand)) {
+		strength >>= 1;
 	}
-	MAX(1, 2);
-	return f26_getBoundedValue(0, L0935_i_Strength >> 1, 100);
+	return f26_getBoundedValue(0, strength >> 1, 100);
 }
 
 Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) {
 	Thing L0894_T_Thing;
 	int16 L0895_i_IconIndex;
-	Champion* L0896_ps_Champion;
-	Weapon* L0897_ps_Weapon;
+	Champion *L0896_ps_Champion;
+	Weapon *L0897_ps_Weapon;
 	bool L0898_B_IsInventoryChampion;
 
 


Commit: 9d0541035bca7f1cf2ef420200f13cd6109e7f5e
    https://github.com/scummvm/scummvm/commit/9d0541035bca7f1cf2ef420200f13cd6109e7f5e
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rename f325_decrementStamina, refactor f300_getObjectRemovedFromSlot and f325_decrementStamina

Also remove a couple of GOTOs in f321_addPendingDamageAndWounds_getDamage

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/eventman.cpp
    engines/dm/group.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 6b43126..181850f 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -192,7 +192,7 @@ bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16
 	}
 
 	_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
-	f325_decrementStamine(champIndex, f305_getThrowingStaminaCost(curThing));
+	f325_decrementStamina(champIndex, f305_getThrowingStaminaCost(curThing));
 	f330_disableAction(champIndex, 4);
 	int16 experience = 8;
 	int16 weaponKineticEnergy = 1;
@@ -634,93 +634,93 @@ uint16 ChampionMan::f312_getStrength(int16 champIndex, int16 slotIndex) {
 }
 
 Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) {
-	Thing L0894_T_Thing;
-	int16 L0895_i_IconIndex;
-	Champion *L0896_ps_Champion;
-	Weapon *L0897_ps_Weapon;
-	bool L0898_B_IsInventoryChampion;
-
+	Champion *curChampion = &_gK71_champions[champIndex];
+	Thing curThing;
 
-	L0896_ps_Champion = &_gK71_champions[champIndex];
 	if (slotIndex >= k30_ChampionSlotChest_1) {
-		L0894_T_Thing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
+		curThing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
 		_vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1] = Thing::_none;
 	} else {
-		L0894_T_Thing = L0896_ps_Champion->_slots[slotIndex];
-		L0896_ps_Champion->_slots[slotIndex] = Thing::_none;
+		curThing = curChampion->_slots[slotIndex];
+		curChampion->_slots[slotIndex] = Thing::_none;
 	}
-	if (L0894_T_Thing == Thing::_none) {
+
+	if (curThing == Thing::_none)
 		return Thing::_none;
-	}
-	L0898_B_IsInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
-	L0895_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0894_T_Thing);
-	f299_applyModifiersToStatistics(L0896_ps_Champion, slotIndex, L0895_i_IconIndex, -1, L0894_T_Thing); /* Remove objet modifiers */
-	L0897_ps_Weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(L0894_T_Thing);
+
+	bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+	int16 curIconIndex = _vm->_objectMan->f33_getIconIndex(curThing);
+	// Remove object modifiers
+	f299_applyModifiersToStatistics(curChampion, slotIndex, curIconIndex, -1, curThing);
+
+	Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(curThing);
 	if (slotIndex == k10_ChampionSlotNeck) {
-		if ((L0895_i_IconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (L0895_i_IconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
-			((Junk *)L0897_ps_Weapon)->setChargeCount(0);
+		if ((curIconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (curIconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
+			((Junk *)curWeapon)->setChargeCount(0);
 			_g407_party._magicalLightAmount -= g39_LightPowerToLightAmount[2];
 			_vm->_inventoryMan->f337_setDungeonViewPalette();
-		} else {
-			if ((L0895_i_IconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (L0895_i_IconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
-				((Junk *)L0897_ps_Weapon)->setChargeCount(0);
-			}
+		} else if ((curIconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (curIconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
+			((Junk *)curWeapon)->setChargeCount(0);
 		}
 	}
+
 	f291_drawSlot(champIndex, slotIndex);
-	if (L0898_B_IsInventoryChampion) {
-		setFlag(L0896_ps_Champion->_attributes, k0x4000_ChampionAttributeViewport);
-	}
+	if (isInventoryChampion)
+		setFlag(curChampion->_attributes, k0x4000_ChampionAttributeViewport);
+
 	if (slotIndex < k2_ChampionSlotHead) {
 		if (slotIndex == k1_ChampionSlotActionHand) {
-			setFlag(L0896_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand);
-			if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)) {
+			setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand);
+			if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))
 				_vm->_menuMan->f388_clearActingChampion();
-			}
-			if ((L0895_i_IconIndex >= k30_IconIndiceScrollOpen) && (L0895_i_IconIndex <= k31_IconIndiceScrollClosed)) {
-				((Scroll *)L0897_ps_Weapon)->setClosed(true);
+
+			if ((curIconIndex >= k30_IconIndiceScrollOpen) && (curIconIndex <= k31_IconIndiceScrollClosed)) {
+				((Scroll *)curWeapon)->setClosed(true);
 				f296_drawChangedObjectIcons();
 			}
 		}
-		if ((L0895_i_IconIndex >= k4_IconIndiceWeaponTorchUnlit) && (L0895_i_IconIndex <= k7_IconIndiceWeaponTorchLit)) {
-			L0897_ps_Weapon->setLit(false);
+
+		if ((curIconIndex >= k4_IconIndiceWeaponTorchUnlit) && (curIconIndex <= k7_IconIndiceWeaponTorchLit)) {
+			curWeapon->setLit(false);
 			_vm->_inventoryMan->f337_setDungeonViewPalette();
 			f296_drawChangedObjectIcons();
 		}
-		if (L0898_B_IsInventoryChampion && (slotIndex == k1_ChampionSlotActionHand)) {
-			if (L0895_i_IconIndex == k144_IconIndiceContainerChestClosed) {
+
+		if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand)) {
+			switch (curIconIndex) {
+			case k144_IconIndiceContainerChestClosed:
 				_vm->_inventoryMan->f334_closeChest();
-				goto T0300011;
-			}
-			if ((L0895_i_IconIndex >= k30_IconIndiceScrollOpen) && (L0895_i_IconIndex <= k31_IconIndiceScrollClosed)) {
-T0300011:
-				setFlag(L0896_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
+			// No break on purpose
+			case k30_IconIndiceScrollOpen:
+			case k31_IconIndiceScrollClosed:
+				setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel);
+				break;
+			default:
+				break;
 			}
 		}
 	}
-	L0896_ps_Champion->_load -= _vm->_dungeonMan->f140_getObjectWeight(L0894_T_Thing);
-	setFlag(L0896_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad);
-	return L0894_T_Thing;
+	curChampion->_load -= _vm->_dungeonMan->f140_getObjectWeight(curThing);
+	setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad);
+	return curThing;
 }
 
-void ChampionMan::f325_decrementStamine(int16 championIndex, int16 decrement) {
-	int16 L0988_i_Stamina;
-	Champion* L0989_ps_Champion;
+void ChampionMan::f325_decrementStamina(int16 championIndex, int16 decrement) {
+	if (championIndex == kM1_ChampionNone)
+		return;
 
+	Champion *curChampion = &_gK71_champions[championIndex];
+	curChampion->_currStamina -= decrement;
 
-	if (championIndex == kM1_ChampionNone) {
-		return;
+	int16 stamina = curChampion->_currStamina;
+	if (stamina <= 0) {
+		curChampion->_currStamina = 0;
+		f321_addPendingDamageAndWounds_getDamage(championIndex, (-stamina) >> 1, k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
+	} else if (stamina > curChampion->_maxStamina) {
+		curChampion->_currStamina = curChampion->_maxStamina;
 	}
-	L0989_ps_Champion = &_gK71_champions[championIndex];
-	if ((L0988_i_Stamina = (L0989_ps_Champion->_currStamina -= decrement)) <= 0) {
-		L0989_ps_Champion->_currStamina = 0;
-		f321_addPendingDamageAndWounds_getDamage(championIndex, (-L0988_i_Stamina) >> 1, k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
-	} else {
-		if (L0988_i_Stamina > L0989_ps_Champion->_maxStamina) {
-			L0989_ps_Champion->_currStamina = L0989_ps_Champion->_maxStamina;
-		}
-	}
-	setFlag(L0989_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics);
+
+	setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics);
 }
 
 int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds, uint16 attackType) {
@@ -736,10 +736,9 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 		return 0;
 
 	L0979_ps_Champion = &_gK71_champions[champIndex];
-	if (!L0979_ps_Champion->_currHealth) {
-T0321004:
+	if (!L0979_ps_Champion->_currHealth)
 		return 0;
-	}
+
 	if (attackType != k0_attackType_NORMAL) {
 		for (L0978_ui_WoundCount = 0, AL0976_i_WoundIndex = k0_ChampionSlotReadyHand, L0977_ui_Defense = 0; AL0976_i_WoundIndex <= k5_ChampionSlotFeet; AL0976_i_WoundIndex++) {
 			if (allowedWounds & (1 << AL0976_i_WoundIndex)) {
@@ -774,7 +773,8 @@ T0321004:
 			;
 		}
 		if (attack <= 0)
-			goto T0321004;
+			return 0;
+
 		attack = _vm->f30_getScaledProduct(attack, 6, 130 - L0977_ui_Defense);
 		/* BUG0_44 A champion may take much more damage than expected after a Black Flame attack or an impact
 	with a Fireball projectile. If the party has a fire shield defense value higher than the fire attack value then the resulting intermediary
@@ -782,7 +782,8 @@ T0321004:
 	high positive attack value which may kill a champion. This can occur only for k1_attackType_FIRE and if attack is negative before calling F0030_MAIN_GetScaledProduct */
 T0321024:
 		if (attack <= 0)
-			goto T0321004;
+			return 0;
+
 		if (attack > (AL0976_i_AdjustedAttack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k4_ChampionStatVitality, _vm->_rnd->getRandomNumber(127) + 10))) { /* BUG0_45 This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the probability of being wounded. However if it was fixed, the behavior would be the opposite of what it should: the higher the vitality of a champion, the lower the result of F0307_CHAMPION_GetStatisticAdjustedAttack and the more likely the champion could get wounded (because of more iterations in the loop below) */
 			do {
 				setFlag(*(uint16 *)&_g410_championPendingWounds[champIndex], (1 << _vm->_rnd->getRandomNumber(7)) & allowedWounds);
@@ -1592,7 +1593,7 @@ void ChampionMan::f331_applyTimeEffects() {
 					AL1007_ui_ManaGain = AL1007_ui_ManaGain << 1;
 				}
 				AL1007_ui_ManaGain++;
-				f325_decrementStamine(AL1006_ui_ChampionIndex, AL1007_ui_ManaGain * MAX(7, 16 - AL1008_ui_WizardSkillLevel));
+				f325_decrementStamina(AL1006_ui_ChampionIndex, AL1007_ui_ManaGain * MAX(7, 16 - AL1008_ui_WizardSkillLevel));
 				L1010_ps_Champion->_currMana += MIN(AL1007_ui_ManaGain, (uint16)(L1010_ps_Champion->_maxMana - L1010_ps_Champion->_currMana));
 			} else {
 				if (L1010_ps_Champion->_currMana > L1010_ps_Champion->_maxMana) {
@@ -1645,7 +1646,7 @@ void ChampionMan::f331_applyTimeEffects() {
 					L1010_ps_Champion->_water -= AL1008_ui_StaminaAboveHalf ? 1 : AL1007_ui_StaminaGainCycleCount >> 2;
 				}
 			} while (--AL1007_ui_StaminaGainCycleCount && ((L1010_ps_Champion->_currStamina - AL1009_i_StaminaLoss) < L1010_ps_Champion->_maxStamina));
-			f325_decrementStamine(AL1006_ui_ChampionIndex, AL1009_i_StaminaLoss);
+			f325_decrementStamina(AL1006_ui_ChampionIndex, AL1009_i_StaminaLoss);
 			if (L1010_ps_Champion->_food < -1024) {
 				L1010_ps_Champion->_food = -1024;
 			}
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 17d8831..e2956c1 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -552,7 +552,7 @@ public:
 	Thing f298_getObjectRemovedFromLeaderHand(); // @ F0298_CHAMPION_GetObjectRemovedFromLeaderHand
 	uint16 f312_getStrength(int16 champIndex, int16 slotIndex); // @ F0312_CHAMPION_GetStrength 
 	Thing f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex); // @ F0300_CHAMPION_GetObjectRemovedFromSlot
-	void f325_decrementStamine(int16 championIndex, int16 decrement); // @ F0325_CHAMPION_DecrementStamina
+	void f325_decrementStamina(int16 championIndex, int16 decrement); // @ F0325_CHAMPION_DecrementStamina
 	int16 f321_addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds,
 												   uint16 attackType); // @ F0321_CHAMPION_AddPendingDamageAndWounds_GetDamage
 	int16 f313_getWoundDefense(int16 champIndex, uint16 woundIndex); // @ F0313_CHAMPION_GetWoundDefense
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 946c1fb..8851e28 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -850,7 +850,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	_vm->_g321_stopWaitingForPlayerInput = true;
 	L1119_ps_Champion = _vm->_championMan->_gK71_champions;
 	for (AL1118_ui_ChampionIndex = k0_ChampionFirst; AL1118_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL1118_ui_ChampionIndex++) {
-		_vm->_championMan->f325_decrementStamine(AL1118_ui_ChampionIndex, ((L1119_ps_Champion->_load * 3) / _vm->_championMan->f309_getMaximumLoad(L1119_ps_Champion)) + 1); /* BUG0_50 When a champion is brought back to life at a Vi Altar, his current stamina is lower than what it was before dying. Each time the party moves the current stamina of all champions is decreased, including for dead champions, by an amount that depends on the current load of the champion. For a dead champion the load before he died is used */
+		_vm->_championMan->f325_decrementStamina(AL1118_ui_ChampionIndex, ((L1119_ps_Champion->_load * 3) / _vm->_championMan->f309_getMaximumLoad(L1119_ps_Champion)) + 1); /* BUG0_50 When a champion is brought back to life at a Vi Altar, his current stamina is lower than what it was before dying. Each time the party moves the current stamina of all champions is decreased, including for dead champions, by an amount that depends on the current load of the champion. For a dead champion the load before he died is used */
 		L1119_ps_Champion++;
 	}
 	AL1118_ui_MovementArrowIndex = cmdType - k3_CommandMoveForward;
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 05f4b5a..2bb6948 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1907,13 +1907,13 @@ T0231009:
 		}
 		L0569_i_Outcome = f190_groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapY, L0565_i_Damage, true);
 		_vm->_championMan->f304_addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * L0572_ps_CreatureInfo->M58_getExperience() >> 4) + 3);
-		_vm->_championMan->f325_decrementStamine(champIndex, _vm->getRandomNumber(4) + 4);
+		_vm->_championMan->f325_decrementStamina(champIndex, _vm->getRandomNumber(4) + 4);
 		goto T0231016;
 	}
 T0231015:
 	L0565_i_Damage = 0;
 	L0569_i_Outcome = k0_outcomeKilledNoCreaturesInGroup;
-	_vm->_championMan->f325_decrementStamine(champIndex, _vm->getRandomNumber(2) + 2);
+	_vm->_championMan->f325_decrementStamina(champIndex, _vm->getRandomNumber(2) + 2);
 T0231016:
 	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
 	if (L0569_i_Outcome != k2_outcomeKilledAllCreaturesInGroup) {
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index f2c372c..5a4c874 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -1291,7 +1291,7 @@ T0407076:
 		_vm->_championMan->f330_disableAction(champIndex, L1249_ui_ActionDisabledTicks);
 	}
 	if (L1253_i_ActionStamina) {
-		_vm->_championMan->f325_decrementStamine(champIndex, L1253_i_ActionStamina);
+		_vm->_championMan->f325_decrementStamina(champIndex, L1253_i_ActionStamina);
 	}
 	if (L1255_i_ActionExperienceGain) {
 		_vm->_championMan->f304_addSkillExperience(champIndex, L1254_i_ActionSkillIndex, L1255_i_ActionExperienceGain);
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index d8337bc..6e53b7e 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -347,7 +347,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 							if (_g402_useRopeToClimbDownPit) {
 								for (AL0709_i_ChampionIndex = k0_ChampionFirst, L0711_ps_Champion = _vm->_championMan->_gK71_champions; AL0709_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL0709_i_ChampionIndex++, L0711_ps_Champion++) {
 									if (L0711_ps_Champion->_currHealth) {
-										_vm->_championMan->f325_decrementStamine(AL0709_i_ChampionIndex, ((L0711_ps_Champion->_load * 25) / _vm->_championMan->f309_getMaximumLoad(L0711_ps_Champion)) + 1);
+										_vm->_championMan->f325_decrementStamina(AL0709_i_ChampionIndex, ((L0711_ps_Champion->_load * 25) / _vm->_championMan->f309_getMaximumLoad(L0711_ps_Champion)) + 1);
 									}
 								}
 							} else {


Commit: 9b12ddd6a9c8e9666287914c216b2ae0fcd6c86d
    https://github.com/scummvm/scummvm/commit/9b12ddd6a9c8e9666287914c216b2ae0fcd6c86d
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some refactoring in f321_addPendingDamageAndWounds_getDamage

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 181850f..1aef47d 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -724,81 +724,90 @@ void ChampionMan::f325_decrementStamina(int16 championIndex, int16 decrement) {
 }
 
 int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds, uint16 attackType) {
-	int16 L0976_i_Multiple;
-#define AL0976_i_WoundIndex     L0976_i_Multiple
-#define AL0976_i_WisdomFactor   L0976_i_Multiple
-#define AL0976_i_AdjustedAttack L0976_i_Multiple
-	uint16 L0977_ui_Defense;
-	uint16 L0978_ui_WoundCount;
-	Champion* L0979_ps_Champion;
-
 	if (attack <= 0)
 		return 0;
 
-	L0979_ps_Champion = &_gK71_champions[champIndex];
-	if (!L0979_ps_Champion->_currHealth)
+	Champion *curChampion = &_gK71_champions[champIndex];
+	if (!curChampion->_currHealth)
 		return 0;
 
 	if (attackType != k0_attackType_NORMAL) {
-		for (L0978_ui_WoundCount = 0, AL0976_i_WoundIndex = k0_ChampionSlotReadyHand, L0977_ui_Defense = 0; AL0976_i_WoundIndex <= k5_ChampionSlotFeet; AL0976_i_WoundIndex++) {
-			if (allowedWounds & (1 << AL0976_i_WoundIndex)) {
-				L0978_ui_WoundCount++;
-				L0977_ui_Defense += f313_getWoundDefense(champIndex, AL0976_i_WoundIndex | ((attackType == k4_attackType_SHARP) ? k0x8000_maskUseSharpDefense : k0x0000_maskDoNotUseSharpDefense));
+		uint16 defense = 0;
+		uint16 woundCount = 0;
+		for (int16 woundIndex = k0_ChampionSlotReadyHand; woundIndex <= k5_ChampionSlotFeet; woundIndex++) {
+			if (allowedWounds & (1 << woundIndex)) {
+				woundCount++;
+				defense += f313_getWoundDefense(champIndex, woundIndex | ((attackType == k4_attackType_SHARP) ? k0x8000_maskUseSharpDefense : k0x0000_maskDoNotUseSharpDefense));
 			}
 		}
-		if (L0978_ui_WoundCount) {
-			L0977_ui_Defense /= L0978_ui_WoundCount;
-		}
+		if (woundCount)
+			defense /= woundCount;
+
 		switch (attackType) {
-		case k6_attackType_PSYCHIC:
-			if ((AL0976_i_WisdomFactor = 115 - L0979_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent]) <= 0) {
-				attack = 0;
-			} else {
-				attack = _vm->f30_getScaledProduct(attack, 6, AL0976_i_WisdomFactor);
+		case k6_attackType_PSYCHIC: 
+			{
+				int16 wisdomFactor = 115 - curChampion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent];
+				if (wisdomFactor <= 0) {
+					attack = 0;
+				} else {
+					attack = _vm->f30_getScaledProduct(attack, 6, wisdomFactor);
+				}
 			}
 			goto T0321024;
 		case k5_attackType_MAGIC:
-			attack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k5_ChampionStatAntimagic, attack);
+			attack = f307_getStatisticAdjustedAttack(curChampion, k5_ChampionStatAntimagic, attack);
 			attack -= _g407_party._spellShieldDefense;
 			goto T0321024;
 		case k1_attackType_FIRE:
-			attack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k6_ChampionStatAntifire, attack);
+			attack = f307_getStatisticAdjustedAttack(curChampion, k6_ChampionStatAntifire, attack);
 			attack -= _g407_party._fireShieldDefense;
 			break;
 		case k2_attackType_SELF:
-			L0977_ui_Defense >>= 1;
-		case k3_attackType_BLUNT:
-		case k4_attackType_SHARP:
-		case k7_attackType_LIGHTNING:
-			;
+			defense >>= 1;
+			break;
+		default:
+			break;
 		}
+
 		if (attack <= 0)
 			return 0;
 
-		attack = _vm->f30_getScaledProduct(attack, 6, 130 - L0977_ui_Defense);
-		/* BUG0_44 A champion may take much more damage than expected after a Black Flame attack or an impact
-	with a Fireball projectile. If the party has a fire shield defense value higher than the fire attack value then the resulting intermediary
-	attack value is negative and damage should be 0. However, the negative value is still used for further computations and the result may be a very
-	high positive attack value which may kill a champion. This can occur only for k1_attackType_FIRE and if attack is negative before calling F0030_MAIN_GetScaledProduct */
+		attack = _vm->f30_getScaledProduct(attack, 6, 130 - defense);
+		/* BUG0_44 
+			A champion may take much more damage than expected after a Black Flame attack or an impact
+			with a Fireball projectile. If the party has a fire shield defense value higher than the fire
+			attack value then the resulting intermediary attack value is negative and damage should be 0. 
+			However, the negative value is still used for further computations and the result may be a very
+			high positive attack value which may kill a champion. This can occur only for k1_attackType_FIRE
+			and if attack is negative before calling F0030_MAIN_GetScaledProduct
+		*/
 T0321024:
 		if (attack <= 0)
 			return 0;
 
-		if (attack > (AL0976_i_AdjustedAttack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k4_ChampionStatVitality, _vm->_rnd->getRandomNumber(127) + 10))) { /* BUG0_45 This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the probability of being wounded. However if it was fixed, the behavior would be the opposite of what it should: the higher the vitality of a champion, the lower the result of F0307_CHAMPION_GetStatisticAdjustedAttack and the more likely the champion could get wounded (because of more iterations in the loop below) */
+		int16 adjustedAttack = f307_getStatisticAdjustedAttack(curChampion, k4_ChampionStatVitality, _vm->_rnd->getRandomNumber(127) + 10);
+		if (attack > adjustedAttack) {
+		/* BUG0_45
+			This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the
+			probability of being wounded. However if it was fixed, the behavior would be the opposite
+			of what it should: the higher the vitality of a champion, the lower the result of
+			F0307_CHAMPION_GetStatisticAdjustedAttack and the more likely the champion could get
+			wounded (because of more iterations in the loop below)
+		*/
 			do {
 				setFlag(*(uint16 *)&_g410_championPendingWounds[champIndex], (1 << _vm->_rnd->getRandomNumber(7)) & allowedWounds);
-			} while ((attack > (AL0976_i_AdjustedAttack <<= 1)) && AL0976_i_AdjustedAttack);
+			} while ((attack > (adjustedAttack <<= 1)) && adjustedAttack);
 		}
-		if (_g300_partyIsSleeping) {
+
+		if (_g300_partyIsSleeping)
 			f314_wakeUp();
-		}
 	}
 	_g409_championPendingDamage[champIndex] += attack;
 	return attack;
 }
 
 int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
-	static byte g50_woundDefenseFactor[6] = {5, 5, 4, 6, 3, 1}; // @ G0050_auc_Graphic562_WoundDefenseFactor
+	static const byte g50_woundDefenseFactor[6] = {5, 5, 4, 6, 3, 1}; // @ G0050_auc_Graphic562_WoundDefenseFactor
 
 	int16 L0942_i_Multiple;
 #define AL0942_i_SlotIndex    L0942_i_Multiple


Commit: eab5879ef57e2d6d614bb198c2dfbc7a7ca5582e
    https://github.com/scummvm/scummvm/commit/eab5879ef57e2d6d614bb198c2dfbc7a7ca5582e
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Get rid of a GOTO in f321_addPendingDamageAndWounds_getDamage

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 1aef47d..20e76c9 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -731,6 +731,7 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 	if (!curChampion->_currHealth)
 		return 0;
 
+	bool skipScaling = false;
 	if (attackType != k0_attackType_NORMAL) {
 		uint16 defense = 0;
 		uint16 woundCount = 0;
@@ -752,12 +753,15 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 				} else {
 					attack = _vm->f30_getScaledProduct(attack, 6, wisdomFactor);
 				}
+
+				skipScaling = true;
 			}
-			goto T0321024;
+			break;
 		case k5_attackType_MAGIC:
 			attack = f307_getStatisticAdjustedAttack(curChampion, k5_ChampionStatAntimagic, attack);
 			attack -= _g407_party._spellShieldDefense;
-			goto T0321024;
+			skipScaling = true;
+			break;
 		case k1_attackType_FIRE:
 			attack = f307_getStatisticAdjustedAttack(curChampion, k6_ChampionStatAntifire, attack);
 			attack -= _g407_party._fireShieldDefense;
@@ -769,10 +773,12 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 			break;
 		}
 
-		if (attack <= 0)
-			return 0;
+		if (!skipScaling) {
+			if (attack <= 0)
+				return 0;
 
-		attack = _vm->f30_getScaledProduct(attack, 6, 130 - defense);
+			attack = _vm->f30_getScaledProduct(attack, 6, 130 - defense);
+		}
 		/* BUG0_44 
 			A champion may take much more damage than expected after a Black Flame attack or an impact
 			with a Fireball projectile. If the party has a fire shield defense value higher than the fire
@@ -781,7 +787,7 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 			high positive attack value which may kill a champion. This can occur only for k1_attackType_FIRE
 			and if attack is negative before calling F0030_MAIN_GetScaledProduct
 		*/
-T0321024:
+
 		if (attack <= 0)
 			return 0;
 


Commit: 76667176f432fac51ff4e72de4b22a04df28f0e0
    https://github.com/scummvm/scummvm/commit/76667176f432fac51ff4e72de4b22a04df28f0e0
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f313_getWoundDefense

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 20e76c9..512acec 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -813,48 +813,44 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 }
 
 int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
-	static const byte g50_woundDefenseFactor[6] = {5, 5, 4, 6, 3, 1}; // @ G0050_auc_Graphic562_WoundDefenseFactor
+	static const byte woundDefenseFactor[6] = {5, 5, 4, 6, 3, 1}; // @ G0050_auc_Graphic562_WoundDefenseFactor
 
-	int16 L0942_i_Multiple;
-#define AL0942_i_SlotIndex    L0942_i_Multiple
-#define AL0942_i_WoundDefense L0942_i_Multiple
-	uint16 L0943_ui_ArmourShieldDefense;
-	bool L0944_B_UseSharpDefense;
-	Thing L0945_T_Thing;
-	Champion* L0946_ps_Champion;
-	ArmourInfo* L0947_ps_ArmourInfo;
-
-
-	L0946_ps_Champion = &_gK71_champions[champIndex];
-	if (L0944_B_UseSharpDefense = getFlag(woundIndex, k0x8000_maskUseSharpDefense)) {
+	Champion *curChampion = &_gK71_champions[champIndex];
+	bool useSharpDefense = getFlag(woundIndex, k0x8000_maskUseSharpDefense);
+	if (useSharpDefense)
 		clearFlag(woundIndex, k0x8000_maskUseSharpDefense);
-	}
-	for (L0943_ui_ArmourShieldDefense = 0, AL0942_i_SlotIndex = k0_ChampionSlotReadyHand; AL0942_i_SlotIndex <= k1_ChampionSlotActionHand; AL0942_i_SlotIndex++) {
-		L0945_T_Thing = L0946_ps_Champion->_slots[AL0942_i_SlotIndex];
-		if (L0945_T_Thing.getType() == k6_ArmourThingType) {
-			L0947_ps_ArmourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing);
-			L0947_ps_ArmourInfo = &g239_ArmourInfo[((Armour *)L0947_ps_ArmourInfo)->getType()];
-			if (getFlag(L0947_ps_ArmourInfo->_attributes, k0x0080_ArmourAttributeIsAShield)) {
-				L0943_ui_ArmourShieldDefense += ((f312_getStrength(champIndex, AL0942_i_SlotIndex) + _vm->_dungeonMan->f143_getArmourDefense(L0947_ps_ArmourInfo, L0944_B_UseSharpDefense)) * g50_woundDefenseFactor[woundIndex]) >> ((AL0942_i_SlotIndex == woundIndex) ? 4 : 5);
-			}
+
+	uint16 armorShieldDefense = 0;
+	for (int16 slotIndex = k0_ChampionSlotReadyHand; slotIndex <= k1_ChampionSlotActionHand; slotIndex++) {
+		Thing curThing = curChampion->_slots[slotIndex];
+		if (curThing.getType() == k6_ArmourThingType) {
+			ArmourInfo *armorInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(curThing);
+			armorInfo = &g239_ArmourInfo[((Armour *)armorInfo)->getType()];
+			if (getFlag(armorInfo->_attributes, k0x0080_ArmourAttributeIsAShield))
+				armorShieldDefense += ((f312_getStrength(champIndex, slotIndex) + _vm->_dungeonMan->f143_getArmourDefense(armorInfo, useSharpDefense)) * woundDefenseFactor[woundIndex]) >> ((slotIndex == woundIndex) ? 4 : 5);
 		}
 	}
-	AL0942_i_WoundDefense = _vm->getRandomNumber((L0946_ps_Champion->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] >> 3) + 1);
-	if (L0944_B_UseSharpDefense) {
-		AL0942_i_WoundDefense >>= 1;
-	}
-	AL0942_i_WoundDefense += L0946_ps_Champion->_actionDefense + L0946_ps_Champion->_shieldDefense + _g407_party._shieldDefense + L0943_ui_ArmourShieldDefense;
-	if ((woundIndex > k1_ChampionSlotActionHand) && ((L0945_T_Thing = L0946_ps_Champion->_slots[woundIndex]).getType() == k6_ArmourThingType)) {
-		L0947_ps_ArmourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing);
-		AL0942_i_WoundDefense += _vm->_dungeonMan->f143_getArmourDefense(&g239_ArmourInfo[((Armour *)L0947_ps_ArmourInfo)->getType()], L0944_B_UseSharpDefense);
-	}
-	if (getFlag(L0946_ps_Champion->_wounds, 1 << woundIndex)) {
-		AL0942_i_WoundDefense -= 8 + _vm->getRandomNumber(4);
-	}
-	if (_g300_partyIsSleeping) {
-		AL0942_i_WoundDefense >>= 1;
+
+	int16 woundDefense = _vm->getRandomNumber((curChampion->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] >> 3) + 1);
+	if (useSharpDefense)
+		woundDefense >>= 1;
+
+	woundDefense += curChampion->_actionDefense + curChampion->_shieldDefense + _g407_party._shieldDefense + armorShieldDefense;
+	if (woundIndex > k1_ChampionSlotActionHand)  {
+		Thing curThing = curChampion->_slots[woundIndex];
+		if (curThing.getType() == k6_ArmourThingType) {
+			ArmourInfo *armourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(curThing);
+			woundDefense += _vm->_dungeonMan->f143_getArmourDefense(&g239_ArmourInfo[((Armour *)armourInfo)->getType()], useSharpDefense);
+		}
 	}
-	return f26_getBoundedValue(0, AL0942_i_WoundDefense >> 1, 100);
+
+	if (getFlag(curChampion->_wounds, 1 << woundIndex))
+		woundDefense -= 8 + _vm->getRandomNumber(4);
+
+	if (_g300_partyIsSleeping)
+		woundDefense >>= 1;
+
+	return f26_getBoundedValue(0, woundDefense >> 1, 100);
 }
 
 uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion* champ, uint16 statIndex, uint16 attack) {


Commit: 710464c5d23f9ef51f0a932ef6c61c1594cbb2c7
    https://github.com/scummvm/scummvm/commit/710464c5d23f9ef51f0a932ef6c61c1594cbb2c7
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f307_getStatisticAdjustedAttack, f305_getThrowingStaminaCost and f330_disableAction

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 512acec..297605a 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -853,13 +853,20 @@ int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
 	return f26_getBoundedValue(0, woundDefense >> 1, 100);
 }
 
-uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion* champ, uint16 statIndex, uint16 attack) {
-	int16 L0927_i_Factor;
-
-	if ((L0927_i_Factor = 170 - champ->_statistics[statIndex][k1_ChampionStatCurrent]) < 16) { /* BUG0_41 The Antifire and Antimagic statistics are completely ignored. The Vitality statistic is ignored against poison and to determine the probability of being wounded. Vitality is still used normally to compute the defense against wounds and the speed of health regeneration. A bug in the Megamax C compiler produces wrong machine code for this statement. It always returns 0 for the current statistic value so that L0927_i_Factor = 170 in all cases */
+uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion *champ, uint16 statIndex, uint16 attack) {
+	int16 factor = 170 - champ->_statistics[statIndex][k1_ChampionStatCurrent];
+
+	/* BUG0_41
+		The Antifire and Antimagic statistics are completely ignored. The Vitality statistic is ignored
+		against poison and to determine the probability of being wounded. Vitality is still used normally
+		to compute the defense against wounds and the speed of health regeneration. A bug in the Megamax C
+		compiler produces wrong machine code for this statement. It always returns 0 for the current statistic
+		value so that factor = 170 in all cases
+	*/
+	if (factor < 16)
 		return attack >> 3;
-	}
-	return _vm->f30_getScaledProduct(attack, 7, L0927_i_Factor);
+
+	return _vm->f30_getScaledProduct(attack, 7, factor);
 }
 
 void ChampionMan::f314_wakeUp() {
@@ -877,44 +884,39 @@ void ChampionMan::f314_wakeUp() {
 }
 
 int16 ChampionMan::f305_getThrowingStaminaCost(Thing thing) {
-	int16 L0923_i_Weight;
-	int16 L0924_i_StaminaCost;
+	int16 weight = _vm->_dungeonMan->f140_getObjectWeight(thing) >> 1;
+	int16 staminaCost = f26_getBoundedValue<int16>(1, weight, 10);
 
+	while ((weight -= 10) > 0)
+		staminaCost += weight >> 1;
 
-	L0924_i_StaminaCost = f26_getBoundedValue((int16)1, L0923_i_Weight = _vm->_dungeonMan->f140_getObjectWeight(thing) >> 1, (int16)10);
-	while ((L0923_i_Weight -= 10) > 0) {
-		L0924_i_StaminaCost += L0923_i_Weight >> 1;
-	}
-	return L0924_i_StaminaCost;
+	return staminaCost;
 }
 
 void ChampionMan::f330_disableAction(uint16 champIndex, uint16 ticks) {
-	int32 L1001_l_UpdatedEnableActionEventTime;
-	int32 L1002_l_CurrentEnableActionEventTime;
-	int16 L1003_i_EventIndex;
-	Champion* L1004_ps_Champion;
-	TimelineEvent L1005_s_Event;
-
-
-	L1004_ps_Champion = &_gK71_champions[champIndex];
-	L1001_l_UpdatedEnableActionEventTime = _vm->_g313_gameTime + ticks;
-	L1005_s_Event._type = k11_TMEventTypeEnableChampionAction;
-	L1005_s_Event._priority = champIndex;
-	L1005_s_Event._B._slotOrdinal = 0;
-	if ((L1003_i_EventIndex = L1004_ps_Champion->_enableActionEventIndex) >= 0) {
-		L1002_l_CurrentEnableActionEventTime = M30_time(_vm->_timeline->_g370_events[L1003_i_EventIndex]._mapTime);
-		if (L1001_l_UpdatedEnableActionEventTime >= L1002_l_CurrentEnableActionEventTime) {
-			L1001_l_UpdatedEnableActionEventTime += (L1002_l_CurrentEnableActionEventTime - _vm->_g313_gameTime) >> 1;
+	Champion *curChampion = &_gK71_champions[champIndex];
+	int32 updatedEnableActionEventTime = _vm->_g313_gameTime + ticks;
+
+	TimelineEvent curEvent;
+	curEvent._type = k11_TMEventTypeEnableChampionAction;
+	curEvent._priority = champIndex;
+	curEvent._B._slotOrdinal = 0;
+
+	int16 eventIndex = curChampion->_enableActionEventIndex;
+	if (eventIndex >= 0) {
+		int32 currentEnableActionEventTime = M30_time(_vm->_timeline->_g370_events[eventIndex]._mapTime);
+		if (updatedEnableActionEventTime >= currentEnableActionEventTime) {
+			updatedEnableActionEventTime += (currentEnableActionEventTime - _vm->_g313_gameTime) >> 1;
 		} else {
-			L1001_l_UpdatedEnableActionEventTime = L1002_l_CurrentEnableActionEventTime + (ticks >> 1);
+			updatedEnableActionEventTime = currentEnableActionEventTime + (ticks >> 1);
 		}
-		_vm->_timeline->f237_deleteEvent(L1003_i_EventIndex);
+		_vm->_timeline->f237_deleteEvent(eventIndex);
 	} else {
-		setFlag(L1004_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand | k0x0008_ChampionAttributeDisableAction);
+		setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x0008_ChampionAttributeDisableAction);
 		f292_drawChampionState((ChampionIndex)champIndex);
 	}
-	M33_setMapAndTime(L1005_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, L1001_l_UpdatedEnableActionEventTime);
-	L1004_ps_Champion->_enableActionEventIndex = _vm->_timeline->f238_addEventGetEventIndex(&L1005_s_Event);
+	M33_setMapAndTime(curEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, updatedEnableActionEventTime);
+	curChampion->_enableActionEventIndex = _vm->_timeline->f238_addEventGetEventIndex(&curEvent);
 }
 
 void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp) {
@@ -933,7 +935,7 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex,
 	int16 L0922_i_BaseSkillLevel;
 
 
-	warning(false, "potaneitally dangerous cast of uint32 below");
+	warning(false, "Potentially dangerous cast of uint32 below");
 	if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && ((uint32)_vm->_projexpl->_g361_lastCreatureAttackTime < (_vm->_g313_gameTime - 150))) {
 		exp >>= 1;
 	}


Commit: 831eca5c42b375870b1d6063a43c7f9cbf7df3ce
    https://github.com/scummvm/scummvm/commit/831eca5c42b375870b1d6063a43c7f9cbf7df3ce
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f304_addSkillExperience, change _g313_gameTime to int32

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/group.cpp
    engines/dm/loadsave.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 297605a..6c3b331 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -920,104 +920,97 @@ void ChampionMan::f330_disableAction(uint16 champIndex, uint16 ticks) {
 }
 
 void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp) {
-#define AP0638_ui_SkillLevelAfter exp
-#define AP0638_ui_ChampionColor   exp
-	uint16 L0915_ui_Multiple;
-#define AL0915_ui_MapDifficulty    L0915_ui_Multiple
-#define AL0915_ui_SkillLevelBefore L0915_ui_Multiple
-#define AL0915_ui_VitalityAmount   L0915_ui_Multiple
-#define AL0915_ui_StaminaAmount    L0915_ui_Multiple
-	uint16 L0916_ui_BaseSkillIndex;
-	Skill* L0918_ps_Skill;
-	Champion* L0919_ps_Champion;
-	int16 L0920_i_MinorStatisticIncrease;
-	int16 L0921_i_MajorStatisticIncrease;
-	int16 L0922_i_BaseSkillLevel;
-
-
-	warning(false, "Potentially dangerous cast of uint32 below");
-	if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && ((uint32)_vm->_projexpl->_g361_lastCreatureAttackTime < (_vm->_g313_gameTime - 150))) {
+	if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && (_vm->_projexpl->_g361_lastCreatureAttackTime < _vm->_g313_gameTime - 150))
 		exp >>= 1;
-	}
+
 	if (exp) {
-		if (AL0915_ui_MapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty) {
-			exp *= AL0915_ui_MapDifficulty;
-		}
-		L0919_ps_Champion = &_gK71_champions[champIndex];
-		if (skillIndex >= k4_ChampionSkillSwing) {
-			L0916_ui_BaseSkillIndex = (skillIndex - k4_ChampionSkillSwing) >> 2;
-		} else {
-			L0916_ui_BaseSkillIndex = skillIndex;
-		}
-		AL0915_ui_SkillLevelBefore = f303_getSkillLevel(champIndex, L0916_ui_BaseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
-		warning(false, "potentially dangerous cast of uint32 below");
-		if ((skillIndex >= k4_ChampionSkillSwing) && ((uint32)_vm->_projexpl->_g361_lastCreatureAttackTime > (_vm->_g313_gameTime - 25))) {
+		if (_vm->_dungeonMan->_g269_currMap->_difficulty)
+			exp *= _vm->_dungeonMan->_g269_currMap->_difficulty;
+
+		Champion *curChampion = &_gK71_champions[champIndex];
+		uint16 baseSkillIndex;
+		if (skillIndex >= k4_ChampionSkillSwing)
+			baseSkillIndex = (skillIndex - k4_ChampionSkillSwing) >> 2;
+		else
+			baseSkillIndex = skillIndex;
+
+		uint16 skillLevelBefore = f303_getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
+
+		if ((skillIndex >= k4_ChampionSkillSwing) && (_vm->_projexpl->_g361_lastCreatureAttackTime > _vm->_g313_gameTime - 25))
 			exp <<= 1;
-		}
-		L0918_ps_Skill = &L0919_ps_Champion->_skills[skillIndex];
-		L0918_ps_Skill->_experience += exp;
-		if (L0918_ps_Skill->_temporaryExperience < 32000) {
-			L0918_ps_Skill->_temporaryExperience += f26_getBoundedValue(1, exp >> 3, 100);
-		}
-		L0918_ps_Skill = &L0919_ps_Champion->_skills[L0916_ui_BaseSkillIndex];
-		if (skillIndex >= k4_ChampionSkillSwing) {
-			L0918_ps_Skill->_experience += exp;
-		}
-		AP0638_ui_SkillLevelAfter = f303_getSkillLevel(champIndex, L0916_ui_BaseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
-		if (AP0638_ui_SkillLevelAfter > AL0915_ui_SkillLevelBefore) {
-			L0922_i_BaseSkillLevel = AP0638_ui_SkillLevelAfter;
-			L0920_i_MinorStatisticIncrease = _vm->getRandomNumber(2);
-			L0921_i_MajorStatisticIncrease = 1 + _vm->getRandomNumber(2);
-			AL0915_ui_VitalityAmount = _vm->getRandomNumber(2); /* For Priest skill, the amount is 0 or 1 for all skill levels */
-			if (L0916_ui_BaseSkillIndex != k2_ChampionSkillPriest) {
-				AL0915_ui_VitalityAmount &= AP0638_ui_SkillLevelAfter; /* For non Priest skills the amount is 0 for even skill levels. The amount is 0 or 1 for odd skill levels */
+
+		Skill *curSkill = &curChampion->_skills[skillIndex];
+		curSkill->_experience += exp;
+		if (curSkill->_temporaryExperience < 32000)
+			curSkill->_temporaryExperience += f26_getBoundedValue(1, exp >> 3, 100);
+
+		curSkill = &curChampion->_skills[baseSkillIndex];
+		if (skillIndex >= k4_ChampionSkillSwing)
+			curSkill->_experience += exp;
+
+		uint16 skillLevelAfter = f303_getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
+		if (skillLevelAfter > skillLevelBefore) {
+			int16 newBaseSkillLevel = skillLevelAfter;
+			int16 minorStatIncrease = _vm->getRandomNumber(2);
+			int16 majorStatIncrease = 1 + _vm->getRandomNumber(2);
+			uint16 vitalityAmount = _vm->getRandomNumber(2); /* For Priest skill, the amount is 0 or 1 for all skill levels */
+			if (baseSkillIndex != k2_ChampionSkillPriest) {
+				vitalityAmount &= skillLevelAfter; /* For non Priest skills the amount is 0 for even skill levels. The amount is 0 or 1 for odd skill levels */
 			}
-			L0919_ps_Champion->_statistics[k4_ChampionStatVitality][k0_ChampionStatMaximum] += AL0915_ui_VitalityAmount;
-			AL0915_ui_StaminaAmount = L0919_ps_Champion->_maxStamina;
-			L0919_ps_Champion->_statistics[k6_ChampionStatAntifire][k0_ChampionStatMaximum] += _vm->getRandomNumber(2) & ~AP0638_ui_SkillLevelAfter; /* The amount is 0 for odd skill levels. The amount is 0 or 1 for even skill levels */
-			switch (L0916_ui_BaseSkillIndex) {
+			curChampion->_statistics[k4_ChampionStatVitality][k0_ChampionStatMaximum] += vitalityAmount;
+			uint16 staminaAmount = curChampion->_maxStamina;
+			curChampion->_statistics[k6_ChampionStatAntifire][k0_ChampionStatMaximum] += _vm->getRandomNumber(2) & ~skillLevelAfter; /* The amount is 0 for odd skill levels. The amount is 0 or 1 for even skill levels */
+			bool increaseManaFl = false;
+			switch (baseSkillIndex) {
 			case k0_ChampionSkillFighter:
-				AL0915_ui_StaminaAmount >>= 4;
-				AP0638_ui_SkillLevelAfter *= 3;
-				L0919_ps_Champion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += L0921_i_MajorStatisticIncrease;
-				L0919_ps_Champion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += L0920_i_MinorStatisticIncrease;
+				staminaAmount >>= 4;
+				skillLevelAfter *= 3;
+				curChampion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += majorStatIncrease;
+				curChampion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += minorStatIncrease;
 				break;
 			case k1_ChampionSkillNinja:
-				AL0915_ui_StaminaAmount /= 21;
-				AP0638_ui_SkillLevelAfter <<= 1;
-				L0919_ps_Champion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += L0920_i_MinorStatisticIncrease;
-				L0919_ps_Champion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += L0921_i_MajorStatisticIncrease;
+				staminaAmount /= 21;
+				skillLevelAfter <<= 1;
+				curChampion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += minorStatIncrease;
+				curChampion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += majorStatIncrease;
 				break;
 			case k3_ChampionSkillWizard:
-				AL0915_ui_StaminaAmount >>= 5;
-				L0919_ps_Champion->_maxMana += AP0638_ui_SkillLevelAfter + (AP0638_ui_SkillLevelAfter >> 1);
-				L0919_ps_Champion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += L0921_i_MajorStatisticIncrease;
-				goto T0304016;
+				staminaAmount >>= 5;
+				curChampion->_maxMana += skillLevelAfter + (skillLevelAfter >> 1);
+				curChampion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += majorStatIncrease;
+				increaseManaFl = true;
+				break;
 			case k2_ChampionSkillPriest:
-				AL0915_ui_StaminaAmount /= 25;
-				L0919_ps_Champion->_maxMana += AP0638_ui_SkillLevelAfter;
-				AP0638_ui_SkillLevelAfter += (AP0638_ui_SkillLevelAfter + 1) >> 1;
-				L0919_ps_Champion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += L0920_i_MinorStatisticIncrease;
-T0304016:
-				if ((L0919_ps_Champion->_maxMana += MIN(_vm->getRandomNumber(4), (uint16)(L0922_i_BaseSkillLevel - 1))) > 900) {
-					L0919_ps_Champion->_maxMana = 900;
-				}
-				L0919_ps_Champion->_statistics[k5_ChampionStatAntimagic][k0_ChampionStatMaximum] += _vm->getRandomNumber(3);
-			}
-			if ((L0919_ps_Champion->_maxHealth += AP0638_ui_SkillLevelAfter + _vm->getRandomNumber((AP0638_ui_SkillLevelAfter >> 1) + 1)) > 999) {
-				L0919_ps_Champion->_maxHealth = 999;
+				staminaAmount /= 25;
+				curChampion->_maxMana += skillLevelAfter;
+				skillLevelAfter += (skillLevelAfter + 1) >> 1;
+				curChampion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += minorStatIncrease;
+				increaseManaFl = true;
+				break;
+			default:
+				break;
 			}
-			if ((L0919_ps_Champion->_maxStamina += AL0915_ui_StaminaAmount + _vm->getRandomNumber((AL0915_ui_StaminaAmount >> 1) + 1)) > 9999) {
-				L0919_ps_Champion->_maxStamina = 9999;
+			if (increaseManaFl) {
+				if ((curChampion->_maxMana += MIN(_vm->getRandomNumber(4), (uint16)(newBaseSkillLevel - 1))) > 900)
+					curChampion->_maxMana = 900;
+				curChampion->_statistics[k5_ChampionStatAntimagic][k0_ChampionStatMaximum] += _vm->getRandomNumber(3);
 			}
-			setFlag(L0919_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+
+			if ((curChampion->_maxHealth += skillLevelAfter + _vm->getRandomNumber((skillLevelAfter >> 1) + 1)) > 999)
+				curChampion->_maxHealth = 999;
+
+			if ((curChampion->_maxStamina += staminaAmount + _vm->getRandomNumber((staminaAmount >> 1) + 1)) > 9999)
+				curChampion->_maxStamina = 9999;
+
+			setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
 			f292_drawChampionState((ChampionIndex)champIndex);
 			_vm->_textMan->f51_messageAreaPrintLineFeed();
-			_vm->_textMan->f47_messageAreaPrintMessage((Color)(AP0638_ui_ChampionColor = g46_ChampionColor[champIndex]), L0919_ps_Champion->_name);
+			Color curChampionColor = g46_ChampionColor[champIndex];
+			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, curChampion->_name);
 			// TODO: localization
-			_vm->_textMan->f47_messageAreaPrintMessage((Color)AP0638_ui_ChampionColor, " JUST GAINED A ");
-			_vm->_textMan->f47_messageAreaPrintMessage((Color)AP0638_ui_ChampionColor, g417_baseSkillName[L0916_ui_BaseSkillIndex]);
-			_vm->_textMan->f47_messageAreaPrintMessage((Color)AP0638_ui_ChampionColor, " LEVEL!");
+			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " JUST GAINED A ");
+			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, g417_baseSkillName[baseSkillIndex]);
+			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " LEVEL!");
 		}
 	}
 }
@@ -1689,7 +1682,7 @@ void ChampionMan::f331_applyTimeEffects() {
 					}
 				}
 			}
-			if (!_vm->_championMan->_g300_partyIsSleeping && (L1010_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < (int32)_vm->_g313_gameTime)) {
+			if (!_vm->_championMan->_g300_partyIsSleeping && (L1010_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_g313_gameTime)) {
 				L1010_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
 				L1010_ps_Champion->_maximumDamageReceived = 0;
 				setFlag(L1010_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon);
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 92cb402..55a2b6e 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -380,7 +380,7 @@ T0002002:
 
 		_menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived();
 
-		if (!((int32)_g313_gameTime & (_championMan->_g300_partyIsSleeping ? 15 : 63))) {
+		if (!(_g313_gameTime & (_championMan->_g300_partyIsSleeping ? 15 : 63))) {
 			_championMan->f331_applyTimeEffects();
 		}
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 128dfaf..1b1f8a7 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -266,7 +266,7 @@ public:
 
 	int8 _dirIntoStepCountEast[4]; // @ G0233_ai_Graphic559_DirectionToStepEastCount
 	int8 _dirIntoStepCountNorth[4]; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
-	uint32 _g313_gameTime; // @ G0313_ul_GameTime
+	int32 _g313_gameTime; // @ G0313_ul_GameTime
 	char _g353_stringBuildBuffer[128]; // @ G0353_ac_StringBuildBuffer
 	int16 _g318_waitForInputMaxVerticalBlankCount; // @ G0318_i_WaitForInputMaximumVerticalBlankCount
 };
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 2bb6948..235bfe4 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1316,12 +1316,11 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 
 void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) {
 	uint16 L0435_ui_GroupDirections;
-	static long G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime; /* These two variables are used to prevent setting direction of half square sized creatures twice at the same game time */
+	static int32 G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime; /* These two variables are used to prevent setting direction of half square sized creatures twice at the same game time */
 	static ActiveGroup *G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup;
 
-
-	warning(false, "potentially dangerous cast to uint32 below");
-	if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == (uint32)G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) {
+	warning(false, "TODO: Move G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime to GroupMan so it's properly initialized");
+	if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) {
 		return;
 	}
 	if (M21_normalizeModulo4(_vm->_groupMan->M50_getCreatureValue(L0435_ui_GroupDirections = activeGroup->_directions, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 9b50351..19df8bf 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -76,7 +76,7 @@ T0435002:
 		warning(false, "MISSING CODE: missing check for matching format and platform in save in f435_loadgame");
 
 
-		_g313_gameTime = file->readUint32BE();
+		_g313_gameTime = file->readSint32BE();
 		// G0349_ul_LastRandomNumber = L1371_s_GlobalData.LastRandomNumber;
 		_championMan->_g305_partyChampionCount = file->readUint16BE();
 		_dungeonMan->_g306_partyMapX = file->readSint16BE();
@@ -165,7 +165,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 	writeSaveGameHeader(file, desc);
 
 	// write C0_SAVE_PART_GLOBAL_DATA part
-	file->writeUint32BE(_g313_gameTime);
+	file->writeSint32BE(_g313_gameTime);
 	//L1348_s_GlobalData.LastRandomNumber = G0349_ul_LastRandomNumber;
 	file->writeUint16BE(_championMan->_g305_partyChampionCount);
 	file->writeSint16BE(_dungeonMan->_g306_partyMapX);


Commit: d5d41f455935af876815d003f5aa3684ccd50df1
    https://github.com/scummvm/scummvm/commit/d5d41f455935af876815d003f5aa3684ccd50df1
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f324_damageAll_getDamagedChampionCount, f286_getTargetChampionIndex, f311_getDexterity and f308_isLucky

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 6c3b331..6bc4e70 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1016,52 +1016,50 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex,
 }
 
 int16 ChampionMan::f324_damageAll_getDamagedChampionCount(uint16 attack, int16 wounds, int16 attackType) {
-	int16 L0984_i_ChampionIndex;
-	int16 L0985_i_RandomAttack;
-	int16 L0986_i_DamagedChampionCount;
+	int16 randomMax = (attack >> 3) + 1;
+	uint16 reducedAttack = attack - randomMax;
+	randomMax <<= 1;
 
-	attack -= (L0985_i_RandomAttack = (attack >> 3) + 1);
-	L0985_i_RandomAttack <<= 1;
-	for (L0986_i_DamagedChampionCount = 0, L0984_i_ChampionIndex = k0_ChampionFirst; L0984_i_ChampionIndex < _g305_partyChampionCount; L0984_i_ChampionIndex++) {
-		if (f321_addPendingDamageAndWounds_getDamage(L0984_i_ChampionIndex, MAX(1, attack + _vm->getRandomNumber(L0985_i_RandomAttack)), wounds, attackType)) { /* Actual attack is attack +/- (attack / 8) */
-			L0986_i_DamagedChampionCount++;
-		}
+	int16 damagedChampionCount = 0;
+	for (int16 championIndex = k0_ChampionFirst; championIndex < _g305_partyChampionCount; championIndex++) {
+		// Actual attack is attack +/- (attack / 8)
+		if (f321_addPendingDamageAndWounds_getDamage(championIndex, MAX(1, reducedAttack + _vm->getRandomNumber(randomMax)), wounds, attackType))
+			damagedChampionCount++;
 	}
-	return L0986_i_DamagedChampionCount;
+
+	return damagedChampionCount;
 }
 
 int16 ChampionMan::f286_getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) {
 	if (_g305_partyChampionCount && (M38_distance(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)) {
-		signed char L0840_auc_OrderedCellsToAttack[4];
-		_vm->_groupMan->f229_setOrderedCellsToAttack(L0840_auc_OrderedCellsToAttack, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, mapX, mapY, cell);
-		for (uint16 L0838_ui_Counter = 0; L0838_ui_Counter < 4; L0838_ui_Counter++) {
-			int16 L0839_i_ChampionIndex = f285_getIndexInCell(L0840_auc_OrderedCellsToAttack[L0838_ui_Counter]);
-			if (L0839_i_ChampionIndex >= 0)
-				return L0839_i_ChampionIndex;
+		signed char orderedCellsToAttack[4];
+		_vm->_groupMan->f229_setOrderedCellsToAttack(orderedCellsToAttack, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, mapX, mapY, cell);
+		for (uint16 i = 0; i < 4; i++) {
+			int16 championIndex = f285_getIndexInCell(orderedCellsToAttack[i]);
+			if (championIndex >= 0)
+				return championIndex;
 		}
 	}
 	return kM1_ChampionNone;
 }
 
 int16 ChampionMan::f311_getDexterity(Champion* champ) {
-	int16 L0934_i_Dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent];
-	L0934_i_Dexterity -= ((int32)(L0934_i_Dexterity >> 1) * (int32)champ->_load) / f309_getMaximumLoad(champ);
-	if (_g300_partyIsSleeping) {
-		L0934_i_Dexterity >>= 1;
-	}
-	return f26_getBoundedValue(1 + _vm->getRandomNumber(8), L0934_i_Dexterity >> 1, 100 - _vm->getRandomNumber(8));
+	int16 dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent];
+	dexterity -= ((int32)(dexterity >> 1) * (int32)champ->_load) / f309_getMaximumLoad(champ);
+	if (_g300_partyIsSleeping)
+		dexterity >>= 1;
+
+	return f26_getBoundedValue(1 + _vm->getRandomNumber(8), dexterity >> 1, 100 - _vm->getRandomNumber(8));
 }
 
 bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) {
-#define AP0646_ui_IsLucky percentage
-
-	if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage)) {
+	if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage))
 		return true;
-	}
-	unsigned char* L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck];
-	AP0646_ui_IsLucky = (_vm->getRandomNumber(L0928_puc_Statistic[k1_ChampionStatCurrent]) > percentage);
-	L0928_puc_Statistic[k1_ChampionStatCurrent] = f26_getBoundedValue((int32)L0928_puc_Statistic[k2_ChampionStatMinimum], (int32)L0928_puc_Statistic[k1_ChampionStatCurrent] + (AP0646_ui_IsLucky ? -2 : 2), (int32)L0928_puc_Statistic[k0_ChampionStatMaximum]);
-	return AP0646_ui_IsLucky;
+
+	unsigned char* curStat = champ->_statistics[k0_ChampionStatLuck];
+	bool isLucky = (_vm->getRandomNumber(curStat[k1_ChampionStatCurrent]) > percentage);
+	curStat[k1_ChampionStatCurrent] = f26_getBoundedValue<char>(curStat[k2_ChampionStatMinimum], curStat[k1_ChampionStatCurrent] + (isLucky ? -2 : 2), curStat[k0_ChampionStatMaximum]);
+	return isLucky;
 }
 
 void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) {


Commit: af84d233d0d97f11d8d7241e4ed4a751ed6c5a64
    https://github.com/scummvm/scummvm/commit/af84d233d0d97f11d8d7241e4ed4a751ed6c5a64
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f322_championPoison, f284_setPartyDirection, f316_deleteScent, f317_addScentStrength, f310_getMovementTicks and f294_isAmmunitionCompatibleWithWeapon

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.h
    engines/dm/loadsave.cpp
    engines/dm/movesens.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 6bc4e70..c759231 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1056,7 +1056,7 @@ bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) {
 	if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage))
 		return true;
 
-	unsigned char* curStat = champ->_statistics[k0_ChampionStatLuck];
+	unsigned char *curStat = champ->_statistics[k0_ChampionStatLuck];
 	bool isLucky = (_vm->getRandomNumber(curStat[k1_ChampionStatCurrent]) > percentage);
 	curStat[k1_ChampionStatCurrent] = f26_getBoundedValue<char>(curStat[k2_ChampionStatMinimum], curStat[k1_ChampionStatCurrent] + (isLucky ? -2 : 2), curStat[k0_ChampionStatMaximum]);
 	return isLucky;
@@ -1066,105 +1066,106 @@ void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) {
 	if ((champIndex == kM1_ChampionNone) || (_vm->M0_indexToOrdinal(champIndex) == _g299_candidateChampionOrdinal))
 		return;
 
-	Champion* L0981_ps_Champion = &_gK71_champions[champIndex];
+	Champion *curChampion = &_gK71_champions[champIndex];
 	f321_addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
-	setFlag(L0981_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+	setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
 	if ((_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) && (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
-		setFlag(L0981_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
+		setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel);
 	}
+
 	if (--attack) {
-		L0981_ps_Champion->_poisonEventCount++;
-		TimelineEvent L0980_s_Event;
-		L0980_s_Event._type = k75_TMEventTypePoisonChampion;
-		L0980_s_Event._priority = champIndex;
-		M33_setMapAndTime(L0980_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 36);
-		L0980_s_Event._B._attack = attack;
-		_vm->_timeline->f238_addEventGetEventIndex(&L0980_s_Event);
+		curChampion->_poisonEventCount++;
+		TimelineEvent newEvent;
+		newEvent._type = k75_TMEventTypePoisonChampion;
+		newEvent._priority = champIndex;
+		M33_setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 36);
+		newEvent._B._attack = attack;
+		_vm->_timeline->f238_addEventGetEventIndex(&newEvent);
 	}
+
 	f292_drawChampionState((ChampionIndex)champIndex);
 }
 
 void ChampionMan::f284_setPartyDirection(int16 dir) {
-	int16 L0833_i_ChampionIndex;
-	int16 L0834_i_Delta;
-	Champion* L0835_ps_Champion;
-
-
-	if (dir == _vm->_dungeonMan->_g308_partyDir) {
+	if (dir == _vm->_dungeonMan->_g308_partyDir)
 		return;
-	}
-	if ((L0834_i_Delta = dir - _vm->_dungeonMan->_g308_partyDir) < 0) {
+
+	int16 L0834_i_Delta = dir - _vm->_dungeonMan->_g308_partyDir;
+	if (L0834_i_Delta < 0)
 		L0834_i_Delta += 4;
+
+	Champion *curChampion = _gK71_champions;
+	for (int16 i = k0_ChampionFirst; i < _g305_partyChampionCount; i++) {
+		curChampion->_cell = (ViewCell)M21_normalizeModulo4(curChampion->_cell + L0834_i_Delta);
+		curChampion->_dir = (direction)M21_normalizeModulo4(curChampion->_dir + L0834_i_Delta);
+		curChampion++;
 	}
-	L0835_ps_Champion = _gK71_champions;
-	for (L0833_i_ChampionIndex = k0_ChampionFirst; L0833_i_ChampionIndex < _g305_partyChampionCount; L0833_i_ChampionIndex++) {
-		L0835_ps_Champion->_cell = (ViewCell)M21_normalizeModulo4(L0835_ps_Champion->_cell + L0834_i_Delta);
-		L0835_ps_Champion->_dir = (direction)M21_normalizeModulo4(L0835_ps_Champion->_dir + L0834_i_Delta);
-		L0835_ps_Champion++;
-	}
+
 	_vm->_dungeonMan->_g308_partyDir = (direction)dir;
 	f296_drawChangedObjectIcons();
 }
 
 void ChampionMan::f316_deleteScent(uint16 scentIndex) {
-	uint16 L0953_ui_Count;
+	uint16 count = --_g407_party._scentCount - scentIndex;
 
-	if (L0953_ui_Count = --_g407_party._scentCount - scentIndex) {
-		for (uint16 i = 0; i < L0953_ui_Count; ++i) {
+	if (count) {
+		for (uint16 i = 0; i < count; ++i) {
 			_g407_party._scents[scentIndex + i] = _g407_party._scents[scentIndex + i + 1];
 			_g407_party._scentStrengths[scentIndex + i] = _g407_party._scentStrengths[scentIndex + i + 1];
 		}
 	}
-	if (scentIndex < _g407_party._firstScentIndex) {
+
+	if (scentIndex < _g407_party._firstScentIndex)
 		_g407_party._firstScentIndex--;
-	}
-	if (scentIndex < _g407_party._lastScentIndex) {
+
+	if (scentIndex < _g407_party._lastScentIndex)
 		_g407_party._lastScentIndex--;
-	}
 }
 
 void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount) {
-	int16 L0954_i_ScentIndex = _vm->_championMan->_g407_party._scentCount;
-	if (L0954_i_ScentIndex) {
-		bool L0955_B_Merge = getFlag(cycleCount, k0x8000_mergeCycles);
-		if (L0955_B_Merge) {
+	int16 scentIndex = _vm->_championMan->_g407_party._scentCount;
+	if (scentIndex) {
+		bool mergeFl = getFlag(cycleCount, k0x8000_mergeCycles);
+		if (mergeFl)
 			clearFlag(cycleCount, k0x8000_mergeCycles);
-		}
-		Scent L0958_s_Scent; /* BUG0_00 Useless code */
-		L0958_s_Scent.setMapX(mapX); /* BUG0_00 Useless code */
-		L0958_s_Scent.setMapY(mapY); /* BUG0_00 Useless code */
-		L0958_s_Scent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */
-		Scent* L0957_ps_Scent = _vm->_championMan->_g407_party._scents; /* BUG0_00 Useless code */
-		bool L0956_B_CycleCountDefined = false;
-		while (L0954_i_ScentIndex--) {
-			if (&*L0957_ps_Scent++ == &L0958_s_Scent) {
-				if (!L0956_B_CycleCountDefined) {
-					L0956_B_CycleCountDefined = true;
-					if (L0955_B_Merge) {
-						cycleCount = MAX((int32)_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount);
+
+		Scent newScent; /* BUG0_00 Useless code */
+		newScent.setMapX(mapX); /* BUG0_00 Useless code */
+		newScent.setMapY(mapY); /* BUG0_00 Useless code */
+		newScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */
+
+		Scent *curScent = _vm->_championMan->_g407_party._scents; /* BUG0_00 Useless code */
+		bool cycleCountDefined = false;
+		while (scentIndex--) {
+			if (&*curScent++ == &newScent) {
+				if (!cycleCountDefined) {
+					cycleCountDefined = true;
+					if (mergeFl) {
+						cycleCount = MAX<int32>(_g407_party._scentStrengths[scentIndex], cycleCount);
 					} else {
-						cycleCount = MIN(80, _g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount);
+						cycleCount = MIN<int32>(80, _g407_party._scentStrengths[scentIndex] + cycleCount);
 					}
 				}
-				_g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount;
+				_g407_party._scentStrengths[scentIndex] = cycleCount;
 			}
 		}
 	}
 }
 
 void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) {
-	if (thing == Thing::_none) {
+	if (thing == Thing::_none)
 		return;
-	}
+
 	_g415_leaderEmptyHanded = false;
 	_vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
 	_vm->_eventMan->f78_showMouse();
 	_vm->_objectMan->f34_drawLeaderObjectName(thing);
-	if (setMousePointer) {
+
+	if (setMousePointer)
 		_vm->_g325_setMousePointerToObjectInMainLoop = true;
-	} else {
+	else
 		_vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
-	}
+
 	_vm->_eventMan->f77_hideMouse();
 	if (_g411_leaderIndex != kM1_ChampionNone) {
 		_gK71_champions[_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing);
@@ -1173,57 +1174,57 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer)
 	}
 }
 
-int16 ChampionMan::f310_getMovementTicks(Champion* champ) {
-	uint16 L0931_ui_Multiple;
-#define AL0931_ui_Load       L0931_ui_Multiple
-#define AL0931_ui_WoundTicks L0931_ui_Multiple
-	uint16 L0932_ui_MaximumLoad;
-	int16 L0933_i_Ticks;
-
+int16 ChampionMan::f310_getMovementTicks(Champion *champ) {
+	uint16 maximumLoad = _vm->_championMan->f309_getMaximumLoad(champ);
+	uint16 curLoad = champ->_load;
+	uint16 woundTicks;
+	int16 ticks;
+	/* BUG0_72 - Fixed
+		The party moves very slowly even though no champion 'Load' value is drawn in red.
+		When the Load of a champion has exactly the maximum value he can carry then the Load
+		is drawn in yellow but the speed is the same as when the champion is overloaded
+		(when the Load is drawn in red). The comparison operator should be >= instead of >
+	*/
+	if (maximumLoad >= curLoad) {
+		ticks = 2;
+		if (((int32)curLoad << 3) > ((int32)maximumLoad * 5))
+			ticks++;
 
-	if ((L0932_ui_MaximumLoad = _vm->_championMan->f309_getMaximumLoad(champ)) > (AL0931_ui_Load = champ->_load)) { /* BUG0_72 The party moves very slowly even though no champion 'Load' value is drawn in red. When the Load of a champion has exactly the maximum value he can carry then the Load is drawn in yellow but the speed is the same as when the champion is overloaded (when the Load is drawn in red). The comparison operator should be >= instead of > */
-		L0933_i_Ticks = 2;
-		if (((int32)AL0931_ui_Load << 3) > ((int32)L0932_ui_MaximumLoad * 5)) {
-			L0933_i_Ticks++;
-		}
-		AL0931_ui_WoundTicks = 1;
+		woundTicks = 1;
 	} else {
-		L0933_i_Ticks = 4 + (((AL0931_ui_Load - L0932_ui_MaximumLoad) << 2) / L0932_ui_MaximumLoad);
-		AL0931_ui_WoundTicks = 2;
+		ticks = 4 + (((curLoad - maximumLoad) << 2) / maximumLoad);
+		woundTicks = 2;
 	}
-	if (getFlag(champ->_wounds, k0x0020_ChampionWoundFeet)) {
-		L0933_i_Ticks += AL0931_ui_WoundTicks;
-	}
-	if (_vm->_objectMan->f33_getIconIndex(champ->_slots[k5_ChampionSlotFeet]) == k194_IconIndiceArmourBootOfSpeed) {
-		L0933_i_Ticks--;
-	}
-	return L0933_i_Ticks;
+
+	if (getFlag(champ->_wounds, k0x0020_ChampionWoundFeet))
+		ticks += woundTicks;
+
+	if (_vm->_objectMan->f33_getIconIndex(champ->_slots[k5_ChampionSlotFeet]) == k194_IconIndiceArmourBootOfSpeed)
+		ticks--;
+
+	return ticks;
 }
 
 bool ChampionMan::f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex, uint16 ammunitionSlotIndex) {
-	Champion* L0874_ps_Champion;
-	WeaponInfo* L0875_ps_WeaponInfo;
-	Thing L0878_T_Thing;
-	int16 L0879_i_WeaponClass;
-
-	L0874_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
-	L0878_T_Thing = L0874_ps_Champion->_slots[weaponSlotIndex];
-	if (L0878_T_Thing.getType() != k5_WeaponThingType) {
+	Champion *curChampion = &_vm->_championMan->_gK71_champions[champIndex];
+	Thing curThing = curChampion->_slots[weaponSlotIndex];
+	if (curThing.getType() != k5_WeaponThingType)
 		return false;
-	}
-	L0875_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0878_T_Thing);
-	if ((L0875_ps_WeaponInfo->_class >= k16_WeaponClassFirstBow) && (L0875_ps_WeaponInfo->_class <= k31_WeaponClassLastBow)) {
-		L0879_i_WeaponClass = k10_WeaponClassBowAmmunition;
-	} else {
-		if ((L0875_ps_WeaponInfo->_class >= k32_WeaponClassFirstSling) && (L0875_ps_WeaponInfo->_class <= k47_WeaponClassLastSling)) {
-			L0879_i_WeaponClass = k11_WeaponClassSlingAmmunition;
-		} else {
-			return false;
-		}
-	}
-	L0878_T_Thing = L0874_ps_Champion->_slots[ammunitionSlotIndex];
-	L0875_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0878_T_Thing);
-	return ((L0878_T_Thing.getType() == k5_WeaponThingType) && (L0875_ps_WeaponInfo->_class == L0879_i_WeaponClass));
+
+	WeaponInfo *weaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
+	int16 weaponClass = kM1_WeaponClassNone;
+
+	if ((weaponInfo->_class >= k16_WeaponClassFirstBow) && (weaponInfo->_class <= k31_WeaponClassLastBow))
+		weaponClass = k10_WeaponClassBowAmmunition;
+	else if ((weaponInfo->_class >= k32_WeaponClassFirstSling) && (weaponInfo->_class <= k47_WeaponClassLastSling))
+		weaponClass = k11_WeaponClassSlingAmmunition;
+
+	if (weaponClass == kM1_WeaponClassNone)
+		return false;
+
+	curThing = curChampion->_slots[ammunitionSlotIndex];
+	weaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
+	return ((curThing.getType() == k5_WeaponThingType) && (weaponInfo->_class == weaponClass));
 }
 
 void ChampionMan::f293_drawAllChampionStates() {
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 1b1f8a7..653afb5 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -168,10 +168,10 @@ enum {
 
 
 
-
+//TODO: Directly use CLIP
 template<typename T>
 inline T f26_getBoundedValue(T min, T val, T max) {
-	return MIN(MAX(min, val), max);
+	return CLIP<T>(min, val, max);
 } // @ F0026_MAIN_GetBoundedValue
 
 #define CALL_MEMBER_FN(object,ptrToMember)  ((object).*(ptrToMember))
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index b3e4194..16af8b3 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -116,6 +116,7 @@ public:
 
 extern ArmourInfo g239_ArmourInfo[58]; // G0239_as_Graphic559_ArmourInfo
 
+#define kM1_WeaponClassNone					-1
 /* Class 0: SWING weapons */
 #define k0_WeaponClassSwingWeapon			0 // @ C000_CLASS_SWING_WEAPON 
 /* Class 1 to 15: THROW weapons */
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 19df8bf..3a075bd 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -143,7 +143,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 	_eventMan->f78_showMouse();
 
 	// do {
-	//		ask the play what he wants
+	//		ask the player what he wants
 	// while 
 
 	// F0427_DIALOG_Draw(0, G0551_pc_SAVINGGAME, 0, 0, 0, 0, false, false, false);
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 6e53b7e..89b3693 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -629,7 +629,6 @@ T0266017_CheckProjectileImpacts:
 void MovesensMan::f268_addEvent(byte type, byte mapX, byte mapY, byte cell, byte effect, int32 time) {
 	TimelineEvent L0729_s_Event;
 
-
 	M33_setMapAndTime(L0729_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, time);
 	L0729_s_Event._type = type;
 	L0729_s_Event._priority = 0;
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 2d722d5..bb9b781 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -101,7 +101,7 @@ class TimelineEvent {
 public:
 	int32 _mapTime;
 	byte _type;
-	byte _priority;
+	byte _priority; // CHECKME: byte? or int16? Inconsistency in the code
 
 	uint16 getTypePriority() { return (_type << 8) + _priority; }
 


Commit: 02c8f286e79cbcf4e3b6ad383567c3ac08d4fe1c
    https://github.com/scummvm/scummvm/commit/02c8f286e79cbcf4e3b6ad383567c3ac08d4fe1c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix segfault with resume game

Changed paths:
    engines/dm/loadsave.cpp



diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 3a075bd..138f9fd 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -58,7 +58,6 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 	_g526_dungeonId = C10_DUNGEON_DM;
 	if (_g298_newGame) {
 		//L1366_B_FadePalette = !F0428_DIALOG_RequireGameDiskInDrive_NoDialogDrawn(C0_DO_NOT_FORCE_DIALOG_DM_CSB, true);
-T0435002:
 		_g524_restartGameAllowed = false;
 		_championMan->_g305_partyChampionCount = 0;
 		_championMan->_g414_leaderHandObject = Thing::_none;
@@ -70,6 +69,9 @@ T0435002:
 			goto T0435004;
 		}*/
 
+		warning(false, "DUMMY CODE in f435_loadgame setting _g298_newGame to k1_modeLoadDungeon");
+		_g298_newGame = k1_modeLoadDungeon;
+
 		SaveGameHeader header;
 		readSaveGameHeader(file, &header);
 


Commit: e8bdaee8bf1404f42203c69def0a1f834f2ad386
    https://github.com/scummvm/scummvm/commit/e8bdaee8bf1404f42203c69def0a1f834f2ad386
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add DialogMan

Changed paths:
  A engines/dm/dialog.cpp
  A engines/dm/dialog.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/module.mk



diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
new file mode 100644
index 0000000..87bf7d5
--- /dev/null
+++ b/engines/dm/dialog.cpp
@@ -0,0 +1,36 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#include "dialog.h"
+
+
+namespace DM {
+
+DialogMan::DialogMan(DMEngine* vm): _vm(vm) {}
+
+
+}
\ No newline at end of file
diff --git a/engines/dm/dialog.h b/engines/dm/dialog.h
new file mode 100644
index 0000000..1cd5a6f
--- /dev/null
+++ b/engines/dm/dialog.h
@@ -0,0 +1,39 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#include "dm.h"
+
+
+namespace DM {
+
+class DialogMan {
+	DMEngine *_vm;
+public:
+	explicit DialogMan(DMEngine *vm);
+};
+
+}
\ No newline at end of file
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 55a2b6e..e7bb4a7 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -54,6 +54,7 @@
 #include "group.h"
 #include "timeline.h"
 #include "projexpl.h"
+#include "dialog.h"
 
 namespace DM {
 void warning(bool repeat, const char* s, ...) {
@@ -147,6 +148,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_groupMan = nullptr;
 	_timeline = nullptr;
 	_projexpl = nullptr;
+	_displayMan = nullptr;
 
 	_g528_saveFormat = 0;
 	_g527_platform = 0;
@@ -197,6 +199,7 @@ DMEngine::~DMEngine() {
 	delete _groupMan;
 	delete _timeline;
 	delete _projexpl;
+	delete _dialog;
 
 	// clear debug channels
 	DebugMan.clearAllDebugChannels();
@@ -315,6 +318,7 @@ Common::Error DMEngine::run() {
 	_groupMan = new GroupMan(this);
 	_timeline = new Timeline(this);
 	_projexpl = new ProjExpl(this);
+	_dialog = new DialogMan(this);
 	_displayMan->setUpScreens(320, 200);
 
 	f463_initializeGame();
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 653afb5..4d48c94 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -52,6 +52,7 @@ class MovesensMan;
 class GroupMan;
 class Timeline;
 class ProjExpl;
+class DialogMan;
 
 
 void warning(bool repeat, const char *s, ...);
@@ -243,6 +244,7 @@ public:
 	GroupMan *_groupMan;
 	Timeline *_timeline;
 	ProjExpl *_projexpl;
+	DialogMan *_dialog;
 
 
 	int16 _g298_newGame; // @ G0298_B_NewGame
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 956232b..6f13c9b 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -536,7 +536,8 @@ const Thing Thing::_explRebirthStep2(0xFFE5); // @ C0xFFE5_THING_EXPLOSION_REBIR
 const Thing Thing::_party(0xFFFF); // @ C0xFFFF_THING_PARTY          
 
 void DungeonMan::f434_loadDungeonFile() {
-	if (_vm->_g298_newGame)
+
+	if(!_rawDunFileData)
 		f455_decompressDungeonFile();
 
 	Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO);
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index 50a8364..75b4385 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -31,6 +31,7 @@ MODULE := engines/dm
 MODULE_OBJS := \
 	champion.o \
 	detection.o \
+	dialog.o \
 	dm.o \
 	dmglobals.o \
 	dungeonman.o \


Commit: 63fc9fb27d684d69770cb626963d341c2f1aab77
    https://github.com/scummvm/scummvm/commit/63fc9fb27d684d69770cb626963d341c2f1aab77
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f427_dialogDraw, f425_printCenteredChoice, f426_isMessageOnTwoLines

Changed paths:
    engines/dm/dialog.cpp
    engines/dm/dialog.h
    engines/dm/gfx.h



diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index 87bf7d5..d9408fc 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -26,11 +26,146 @@
 */
 
 #include "dialog.h"
+#include "gfx.h"
+#include "text.h"
+#include "eventman.h"
 
 
 namespace DM {
 
-DialogMan::DialogMan(DMEngine* vm): _vm(vm) {}
+DialogMan::DialogMan(DMEngine* vm) : _vm(vm) {}
 
+void DialogMan::f427_dialogDraw(char* msg1, char* msg2, char* choice1, char* choice2, char* choice3, char* choice4, bool screenDialog, bool clearScreen, bool fading) {
+	static Box K0068_s_Box1 = {0, 223, 101, 125};
+	static Box K0069_s_Box2 = {0, 223,  76, 100};
+	static Box K0070_s_Box3 = {0, 223,  51,  75};
+	static Box G0469_s_Graphic561_Box_Dialog2ChoicesPatch = {102, 122, 89, 125};
+	static Box G0470_s_Graphic561_Box_Dialog4ChoicesPatch = {102, 122, 62, 97};
 
-}
\ No newline at end of file
+	int16 L1308_i_X;
+	int16 L1309_i_Y;
+	int16 L1310_i_ChoiceCount;
+	char L1312_ac_StringPart1[70];
+	char L1313_ac_StringPart2[70];
+	Box L1314_s_Box;
+
+
+	_vm->_displayMan->f466_loadIntoBitmap(k0_dialogBoxGraphicIndice, _vm->_displayMan->_g296_bitmapViewport);
+	//Strangerke: the version should be replaced by a ScummVM/RogueVM (?) string
+	// TODO: replace with ScummVM version string
+	_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 192, 7, k2_ColorLightGray, k1_ColorDarkGary, "V2.2", k136_heightViewport);
+	L1310_i_ChoiceCount = 1;
+	if (choice2 != nullptr) {
+		L1310_i_ChoiceCount++;
+	}
+	if (choice3 != nullptr) {
+		L1310_i_ChoiceCount++;
+	}
+	if (choice4 != nullptr) {
+		L1310_i_ChoiceCount++;
+	}
+	if (fading) {
+		warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette in f427_dialogDraw");
+	}
+	if (clearScreen) {
+		_vm->_displayMan->fillScreen(k0_ColorBlack);
+	}
+	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	if (L1310_i_ChoiceCount == 1) {
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, K0068_s_Box1, 0, 64, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, K0069_s_Box2, 0, 39, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, K0070_s_Box3, 0, 14, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
+		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 114);
+	} else {
+		if (L1310_i_ChoiceCount == 2) {
+			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, G0469_s_Graphic561_Box_Dialog2ChoicesPatch, 102, 52, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
+			f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77);
+			f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 112, 114);
+		} else {
+			if (L1310_i_ChoiceCount == 3) {
+				f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77);
+				f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 59, 114);
+				f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 166, 114);
+			} else {
+				if (L1310_i_ChoiceCount == 4) {
+					_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, G0470_s_Graphic561_Box_Dialog4ChoicesPatch, 102, 99, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
+					f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 59, 77);
+					f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 166, 77);
+					f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 59, 114);
+					f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice4, 166, 114);
+				}
+			}
+		}
+	}
+	L1309_i_Y = 29;
+	if (msg1 != nullptr) {
+		if (f426_isMessageOnTwoLines(msg1, L1312_ac_StringPart1, L1313_ac_StringPart2)) {
+			L1309_i_Y = 21;
+			L1308_i_X = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k11_ColorYellow, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
+			L1309_i_Y += 8;
+			L1308_i_X = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k11_ColorYellow, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport);
+			L1309_i_Y += 8;
+		} else {
+			L1308_i_X = 113 - ((strlen(msg1) * 6) >> 1);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k11_ColorYellow, k5_ColorLightBrown, msg1, k136_heightViewport);
+			L1309_i_Y += 8;
+		}
+	}
+	if (msg2 != nullptr) {
+		if (f426_isMessageOnTwoLines(msg2, L1312_ac_StringPart1, L1313_ac_StringPart2)) {
+			L1308_i_X = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k9_ColorGold, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
+			L1309_i_Y += 8;
+			L1308_i_X = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k9_ColorGold, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport);
+		} else {
+			L1308_i_X = 113 - ((strlen(msg2) * 6) >> 1);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k9_ColorGold, k5_ColorLightBrown, msg2, k136_heightViewport);
+		}
+	}
+	if (screenDialog) {
+		L1314_s_Box._y1 = 33;
+		L1314_s_Box._y2 = 168;
+		L1314_s_Box._x1 = 47;
+		L1314_s_Box._x2 = 270;
+		_vm->_eventMan->f78_showMouse();
+		_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->_g296_bitmapViewport, &L1314_s_Box, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport);
+		_vm->_eventMan->f77_hideMouse();
+	} else {
+		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+		_vm->f22_delay(1);
+	}
+	if (fading) {
+		warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette in f427_dialogDraw");
+	}
+	_vm->_displayMan->_g297_drawFloorAndCeilingRequested = true;
+}
+
+void DialogMan::f425_printCenteredChoice(byte* bitmap, char* str, int16 posX, int16 posY) {
+	if (str) {
+		posX -= (strlen(str) * 6) >> 1;
+		_vm->_textMan->f40_printTextToBitmap(bitmap, k112_byteWidthViewport, posX, posY, k9_ColorGold, k5_ColorLightBrown, str, k136_heightViewport);
+	}
+}
+
+bool DialogMan::f426_isMessageOnTwoLines(char* str, char* part1, char* part2) {
+	uint16 L1305_ui_StringLength;
+	uint16 L1306_ui_SplitPosition;
+
+
+	L1305_ui_StringLength = strlen(str);
+	if (L1305_ui_StringLength <= 30) {
+		return false;
+	}
+	strcpy(part1, str);
+	L1306_ui_SplitPosition = L1305_ui_StringLength >> 1;
+	while ((part1[L1306_ui_SplitPosition] != ' ') && L1306_ui_SplitPosition < L1305_ui_StringLength) {
+		L1306_ui_SplitPosition++;
+	}
+	part1[L1306_ui_SplitPosition] = '\0';
+	strcpy(part2, &part1[L1306_ui_SplitPosition + 1]);
+	return true;
+}
+}
diff --git a/engines/dm/dialog.h b/engines/dm/dialog.h
index 1cd5a6f..2dd3e5b 100644
--- a/engines/dm/dialog.h
+++ b/engines/dm/dialog.h
@@ -34,6 +34,10 @@ class DialogMan {
 	DMEngine *_vm;
 public:
 	explicit DialogMan(DMEngine *vm);
+	void f427_dialogDraw(char *msg1, char *msg2, char *choice1, char *choice2,
+						 char *choice3, char *choice4, bool screenDialog, bool clearScreen, bool fading); // @ F0427_DIALOG_Draw
+	void f425_printCenteredChoice(byte *bitmap, char *str, int16 posX, int16 posY); // @ F0425_DIALOG_PrintCenteredChoice
+	bool f426_isMessageOnTwoLines(char *str, char *part1, char *part2); // @ F0426_DIALOG_IsMessageOnTwoLines
 };
 
 }
\ No newline at end of file
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 2a18b39..1a1ad49 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -202,6 +202,7 @@ enum ViewCell {
 };
 
 enum GraphicIndice {
+	k0_dialogBoxGraphicIndice = 0, // @ C000_GRAPHIC_DIALOG_BOX
 	k2_entranceLeftDoorGraphicIndice = 2, // @ C002_GRAPHIC_ENTRANCE_LEFT_DOOR
 	k3_entranceRightDoorGraphicIndice = 3, // @ C003_GRAPHIC_ENTRANCE_RIGHT_DOOR
 	k4_entranceGraphicIndice = 4, // @ C004_GRAPHIC_ENTRANCE


Commit: b174331e71f4c63b2847762acddcf8d20a712cb8
    https://github.com/scummvm/scummvm/commit/b174331e71f4c63b2847762acddcf8d20a712cb8
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: refact f293_drawAllChampionStates, f283_viAltarRebirth, f327_isProjectileSpellCast and f326_championShootProjectile. Rename Direction.

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/group.cpp
    engines/dm/group.h
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/projexpl.cpp
    engines/dm/projexpl.h
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index c759231..3c0d08a 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1097,11 +1097,11 @@ void ChampionMan::f284_setPartyDirection(int16 dir) {
 	Champion *curChampion = _gK71_champions;
 	for (int16 i = k0_ChampionFirst; i < _g305_partyChampionCount; i++) {
 		curChampion->_cell = (ViewCell)M21_normalizeModulo4(curChampion->_cell + L0834_i_Delta);
-		curChampion->_dir = (direction)M21_normalizeModulo4(curChampion->_dir + L0834_i_Delta);
+		curChampion->_dir = (Direction)M21_normalizeModulo4(curChampion->_dir + L0834_i_Delta);
 		curChampion++;
 	}
 
-	_vm->_dungeonMan->_g308_partyDir = (direction)dir;
+	_vm->_dungeonMan->_g308_partyDir = (Direction)dir;
 	f296_drawChangedObjectIcons();
 }
 
@@ -1228,31 +1228,26 @@ bool ChampionMan::f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint1
 }
 
 void ChampionMan::f293_drawAllChampionStates() {
-	int16 L0873_i_ChampionIndex;
-	for (L0873_i_ChampionIndex = k0_ChampionFirst; L0873_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0873_i_ChampionIndex++) {
-		_vm->_championMan->f292_drawChampionState((ChampionIndex)L0873_i_ChampionIndex);
-	}
+	for (int16 i = k0_ChampionFirst; i < _vm->_championMan->_g305_partyChampionCount; i++)
+		_vm->_championMan->f292_drawChampionState((ChampionIndex)i);
 }
 
 void ChampionMan::f283_viAltarRebirth(uint16 champIndex) {
-	uint16 L0831_ui_Multiple;
-#define AL0831_ui_Cell          L0831_ui_Multiple
-#define AL0831_ui_MaximumHealth L0831_ui_Multiple
-	Champion* L0832_ps_Champion;
+	Champion *curChampion = &_vm->_championMan->_gK71_champions[champIndex];
+	if (_vm->_championMan->f285_getIndexInCell(curChampion->_cell) != kM1_ChampionNone) {
+		uint16 numCell = k0_CellNorthWest;
+		while (_vm->_championMan->f285_getIndexInCell(numCell) != kM1_ChampionNone)
+			numCell++;
 
-	L0832_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
-	if (_vm->_championMan->f285_getIndexInCell(L0832_ps_Champion->_cell) != kM1_ChampionNone) {
-		AL0831_ui_Cell = k0_CellNorthWest;
-		while (_vm->_championMan->f285_getIndexInCell(AL0831_ui_Cell) != kM1_ChampionNone) {
-			AL0831_ui_Cell++;
-		}
-		L0832_ps_Champion->_cell = (ViewCell)AL0831_ui_Cell;
+		curChampion->_cell = (ViewCell)numCell;
 	}
-	AL0831_ui_MaximumHealth = L0832_ps_Champion->_maxHealth;
-	L0832_ps_Champion->_currHealth = (L0832_ps_Champion->_maxHealth = MAX(25, AL0831_ui_MaximumHealth - (AL0831_ui_MaximumHealth >> 6) - 1)) >> 1;
+	
+	uint16 maximumHealth = curChampion->_maxHealth;
+	curChampion->_maxHealth = MAX(25, maximumHealth - (maximumHealth >> 6) - 1);
+	curChampion->_currHealth = curChampion->_maxHealth >> 1;
 	_vm->_menuMan->f393_drawSpellAreaControls(_vm->_championMan->_g514_magicCasterChampionIndex);
-	L0832_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
-	setFlag(L0832_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
+	curChampion->_dir = _vm->_dungeonMan->_g308_partyDir;
+	setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
 	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
 }
 
@@ -1261,18 +1256,19 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex)
 	uint16 slotIndex;
 
 	if (slotBoxIndex < k8_SlotBoxInventoryFirstSlot) {
-		if (_g299_candidateChampionOrdinal) {
+		if (_g299_candidateChampionOrdinal)
 			return;
-		}
+
 		champIndex = slotBoxIndex >> 1;
-		if ((champIndex >= _g305_partyChampionCount) || (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_gK71_champions[champIndex]._currHealth) {
+		if ((champIndex >= _g305_partyChampionCount) || (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_gK71_champions[champIndex]._currHealth)
 			return;
-		}
+
 		slotIndex = M70_handSlotIndex(slotBoxIndex);
 	} else {
 		champIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal);
 		slotIndex = slotBoxIndex - k8_SlotBoxInventoryFirstSlot;
 	}
+
 	Thing leaderHandObject = _g414_leaderHandObject;
 	Thing slotThing;
 	if (slotIndex >= k30_ChampionSlotChest_1) {
@@ -1280,53 +1276,51 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex)
 	} else {
 		slotThing = _gK71_champions[champIndex]._slots[slotIndex];
 	}
-	if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none)) {
+
+	if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none))
 		return;
-	}
-	if ((leaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & g38_slotMasks[slotIndex]))) {
+
+	if ((leaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & g38_slotMasks[slotIndex])))
 		return;
-	}
+
 	_vm->_eventMan->f78_showMouse();
-	if (leaderHandObject != Thing::_none) {
+	if (leaderHandObject != Thing::_none)
 		f298_getObjectRemovedFromLeaderHand();
-	}
+
 	if (slotThing != Thing::_none) {
 		f300_getObjectRemovedFromSlot(champIndex, slotIndex);
 		f297_putObjectInLeaderHand(slotThing, false);
 	}
-	if (leaderHandObject != Thing::_none) {
+
+	if (leaderHandObject != Thing::_none)
 		f301_addObjectInSlot((ChampionIndex)champIndex, leaderHandObject, (ChampionSlot)slotIndex);
-	}
+
 	f292_drawChampionState((ChampionIndex)champIndex);
 	_vm->_eventMan->f77_hideMouse();
 }
 
 bool ChampionMan::f327_isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount) {
-	int16 L0991_i_StepEnergy;
-	Champion* L0992_ps_Champion;
-
-	L0992_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
-	if (L0992_ps_Champion->_currMana < requiredManaAmount) {
+	Champion *curChampion = &_vm->_championMan->_gK71_champions[champIndex];
+	if (curChampion->_currMana < requiredManaAmount)
 		return false;
-	}
-	L0992_ps_Champion->_currMana -= requiredManaAmount;
-	setFlag(L0992_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
-	L0991_i_StepEnergy = 10 - MIN(8, L0992_ps_Champion->_maxMana >> 3);
-	if (kineticEnergy < (L0991_i_StepEnergy << 2)) {
+
+	curChampion->_currMana -= requiredManaAmount;
+	setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+	int16 stepEnergy = 10 - MIN(8, curChampion->_maxMana >> 3);
+	if (kineticEnergy < (stepEnergy << 2)) {
 		kineticEnergy += 3;
-		L0991_i_StepEnergy--;
+		stepEnergy--;
 	}
-	f326_championShootProjectile(L0992_ps_Champion, thing, kineticEnergy, 90, L0991_i_StepEnergy);
+
+	f326_championShootProjectile(curChampion, thing, kineticEnergy, 90, stepEnergy);
 	return true; // fix BUG_01
 }
 
 void ChampionMan::f326_championShootProjectile(Champion* champ, Thing thing, int16 kineticEnergy, int16 attack, int16 stepEnergy) {
-	uint16 L0990_ui_Direction;
-
-	L0990_ui_Direction = champ->_dir;
-	_vm->_projexpl->f212_projectileCreate(thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, M21_normalizeModulo4((((champ->_cell - L0990_ui_Direction + 1) & 0x0002) >> 1) + L0990_ui_Direction), (direction)L0990_ui_Direction, kineticEnergy, attack, stepEnergy);
+	Direction newDirection = champ->_dir;
+	_vm->_projexpl->f212_projectileCreate(thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, M21_normalizeModulo4((((champ->_cell - newDirection + 1) & 0x0002) >> 1) + newDirection), newDirection, kineticEnergy, attack, stepEnergy);
 	_vm->_g311_projectileDisableMovementTicks = 4;
-	_vm->_g312_lastProjectileDisabledMovementDirection = L0990_ui_Direction;
+	_vm->_g312_lastProjectileDisabledMovementDirection = newDirection;
 }
 
 void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() {
@@ -1777,7 +1771,7 @@ void ChampionMan::load2_PartyPart(Common::InSaveFile* file) {
 			champ->_name[j] = file->readByte();
 		for (uint16 j = 0; j < 20; ++j)
 			champ->_title[j] = file->readByte();
-		champ->_dir = (direction)file->readUint16BE();
+		champ->_dir = (Direction)file->readUint16BE();
 		champ->_cell = (ViewCell)file->readUint16BE();
 		champ->_actionIndex = (ChampionAction)file->readUint16BE();
 		champ->_symbolStep = file->readUint16BE();
@@ -2282,7 +2276,7 @@ T0292042:
 	_vm->_eventMan->f77_hideMouse();
 }
 
-uint16 ChampionMan::M26_championIconIndex(int16 val, direction dir) {
+uint16 ChampionMan::M26_championIconIndex(int16 val, Direction dir) {
 	return ((val + 4 - dir) & 0x3);
 }
 
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index e2956c1..04ab769 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -370,7 +370,7 @@ public:
 	Skill _skills[20];
 	char _name[8];
 	char _title[20];
-	direction _dir;
+	Direction _dir;
 	ViewCell _cell;
 	ChampionAction _actionIndex;
 	uint16 _symbolStep;
@@ -537,7 +537,7 @@ public:
 	uint16 f306_getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue
 	uint16 f309_getMaximumLoad(Champion *champ); // @ F0309_CHAMPION_GetMaximumLoad
 	void f292_drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState
-	uint16 M26_championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX
+	uint16 M26_championIconIndex(int16 val, Direction dir); // @ M26_CHAMPION_ICON_INDEX
 	void f290_drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues
 	void f291_drawSlot(uint16 champIndex, int16 slotIndex); // @ F0291_CHAMPION_DrawSlot
 	void f281_renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index e7bb4a7..5d003b7 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -76,19 +76,19 @@ void warning(bool repeat, const char* s, ...) {
 	}
 }
 
-void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
-void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); }
-direction returnOppositeDir(direction dir) { return (direction)((dir + 2) & 3); }
+void turnDirRight(Direction &dir) { dir = (Direction)((dir + 1) & 3); }
+void turnDirLeft(Direction &dir) { dir = (Direction)((dir - 1) & 3); }
+Direction returnOppositeDir(Direction dir) { return (Direction)((dir + 2) & 3); }
 
 uint16 returnPrevVal(uint16 val) {
-	return (direction)((val + 3) & 3);
+	return (Direction)((val + 3) & 3);
 }
 
 uint16 returnNextVal(uint16 val) {
 	return (val + 1) & 0x3;
 }
 
-bool isOrientedWestEast(direction dir) { return dir & 1; }
+bool isOrientedWestEast(Direction dir) { return dir & 1; }
 
 uint16 toggleFlag(uint16& val, uint16 mask) {
 	return val ^= mask;
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 4d48c94..c1881a0 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -57,7 +57,7 @@ class DialogMan;
 
 void warning(bool repeat, const char *s, ...);
 
-enum direction {
+enum Direction {
 	kDirNorth = 0,
 	kDirEast = 1,
 	kDirSouth = 2,
@@ -122,12 +122,12 @@ public:
 
 
 
-void turnDirRight(direction &dir);
-void turnDirLeft(direction &dir);
-direction returnOppositeDir(direction dir);	// @ M18_OPPOSITE
+void turnDirRight(Direction &dir);
+void turnDirLeft(Direction &dir);
+Direction returnOppositeDir(Direction dir);	// @ M18_OPPOSITE
 uint16 returnPrevVal(uint16 val); // @ M19_PREVIOUS
 uint16 returnNextVal(uint16 val); // @ M17_NEXT
-bool isOrientedWestEast(direction dir);	// @ M16_IS_ORIENTED_WEST_EAST
+bool isOrientedWestEast(Direction dir);	// @ M16_IS_ORIENTED_WEST_EAST
 
 
 #define setFlag(val, mask) ((val) |= (mask))
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 6f13c9b..e01a154 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -363,7 +363,7 @@ CreatureInfo g243_CreatureInfo[k27_CreatureTypeCount] = { // @ G0243_as_Graphic5
 	{25,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5},
 	{26,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}};
 
-void DungeonMan::f150_mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
+void DungeonMan::f150_mapCoordsAfterRelMovement(Direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
 	posX += _vm->_dirIntoStepCountEast[dir] * stepsForward;
 	posY += _vm->_dirIntoStepCountNorth[dir] * stepsForward;
 	turnDirRight(dir);
@@ -385,7 +385,7 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	for (uint16 i = 0; i < 16; ++i)
 		_g284_thingData[i] = nullptr;
 	_g279_dungeonMapData = nullptr;
-	_g308_partyDir = (direction)0;
+	_g308_partyDir = (Direction)0;
 	_g306_partyMapX = 0;
 	_g307_partyMapY = 0;
 	_g309_partyMapIndex = 0;
@@ -549,7 +549,7 @@ void DungeonMan::f434_loadDungeonFile() {
 	dunDataStream.readByte(); // discard 1 byte
 	_g278_dungeonFileHeader._textDataWordCount = dunDataStream.readUint16BE();
 	uint16 partyPosition = dunDataStream.readUint16BE();
-	_g278_dungeonFileHeader._partyStartDir = (direction)((partyPosition >> 10) & 3);
+	_g278_dungeonFileHeader._partyStartDir = (Direction)((partyPosition >> 10) & 3);
 	_g278_dungeonFileHeader._partyStartPosY = (partyPosition >> 5) & 0x1F;
 	_g278_dungeonFileHeader._partyStartPosX = (partyPosition >> 0) & 0x1F;
 	_g278_dungeonFileHeader._squareFirstThingCount = dunDataStream.readUint16BE();
@@ -788,7 +788,7 @@ Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) {
 	return Square(k0_ElementTypeWall, 0);
 }
 
-Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
+Square DungeonMan::f152_getRelSquare(Direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
 	f150_mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY);
 	return f151_getSquare(posX, posY);
 }
@@ -822,7 +822,7 @@ Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) {
 
 
 // TODO: produce more GOTOs
-void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) {	// complete, except where marked
+void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX, int16 mapY) {	// complete, except where marked
 #define thingType dir
 	byte L0307_uc_Multiple;
 #define square            L0307_uc_Multiple
@@ -928,7 +928,7 @@ different sides of the wall, the same text is drawn on each affected side */
 T0172029_Teleporter:
 		footprintsAllowed = true;
 T0172030_Pit:
-		while ((thing != Thing::_endOfList) && ((thingType = (direction)thing.getType()) <= k3_SensorThingType)) {
+		while ((thing != Thing::_endOfList) && ((thingType = (Direction)thing.getType()) <= k3_SensorThingType)) {
 			if (thingType == k3_SensorThingType) {
 				sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(thing);
 				aspectArray[k4_FloorOrnOrdAspect] = sensor->getOrnOrdinal();
@@ -1554,7 +1554,7 @@ void DungeonMan::f146_setGroupCells(Group* group, uint16 cells, uint16 mapIndex)
 
 void DungeonMan::f148_setGroupDirections(Group* group, int16 dir, uint16 mapIndex) {
 	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) {
-		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (direction)dir;
+		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (Direction)dir;
 	} else {
 		group->setDir(M21_normalizeModulo4(dir));
 	}
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 16af8b3..95f8a1a 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -244,7 +244,7 @@ public:
 	bool isAudible() { return (_attributes >> 15) & 1; }
 	TeleporterScope getScope() { return (TeleporterScope)((_attributes >> 13) & 1); }
 	bool getAbsoluteRotation() { return (_attributes >> 12) & 1; }
-	direction getRotation() { return (direction)((_attributes >> 10) & 1); }
+	Direction getRotation() { return (Direction)((_attributes >> 10) & 1); }
 	byte getTargetMapY() { return (_attributes >> 5) & 0xF; }
 	byte getTargetMapX() { return _attributes & 0xF; }
 	uint16 getTargetMapIndex() { return _destMapIndex >> 8; }
@@ -334,7 +334,7 @@ public:
 
 	uint16 getTargetMapY() { return (_action >> 11); }
 	uint16 getTargetMapX() { return (_action >> 6) & 0x1F; }
-	direction getTargetCell() { return (direction)((_action >> 4) & 3); }
+	Direction getTargetCell() { return (Direction)((_action >> 4) & 3); }
 	uint16 M47_kineticEnergy() { return (_action & 0xFF); }// @ M47_KINETIC_ENERGY
 	uint16 M48_stepEnergy() { return (_action >> 8) & 0xFF; }// @ M48_STEP_ENERGY
 	uint16 M49_localEffect() { return _action; } // @ M49_LOCAL_EFFECT
@@ -611,7 +611,7 @@ struct DungeonFileHeader {
 	uint32 _rawMapDataSize;
 	uint8 _mapCount;
 	uint16 _textDataWordCount;
-	direction _partyStartDir; // @ InitialPartyLocation
+	Direction _partyStartDir; // @ InitialPartyLocation
 	uint16 _partyStartPosX, _partyStartPosY;
 	uint16 _squareFirstThingCount; // @ SquareFirstThingCount
 	uint16 _thingCounts[16]; // @ ThingCount[16]
@@ -656,7 +656,7 @@ class DungeonMan {
 	DungeonMan(const DungeonMan &other); // no implementation on purpose
 	void operator=(const DungeonMan &rhs); // no implementation on purpose
 
-	Square f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare
+	Square f152_getRelSquare(Direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare
 
 	void f455_decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon
 
@@ -683,11 +683,11 @@ public:
 	void f174_setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap
 
 	bool f149_isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove
-	void f150_mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement
-	SquareType f153_getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
+	void f150_mapCoordsAfterRelMovement(Direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement
+	SquareType f153_getRelSquareType(Direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
 		return Square(f152_getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType();
 	} // @ F0153_DUNGEON_GetRelativeSquareType
-	void f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect
+	void f172_setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect
 	void f168_decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText
 	Thing f166_getUnusedThing(uint16 thingType); // @ F0166_DUNGEON_GetUnusedThing
 
@@ -725,7 +725,7 @@ public:
 	byte ***_g279_dungeonMapData; // @ G0279_pppuc_DungeonMapData
 
 
-	direction _g308_partyDir; // @ G0308_i_PartyDirection
+	Direction _g308_partyDir; // @ G0308_i_PartyDirection
 	int16 _g306_partyMapX; // @ G0306_i_PartyMapX
 	int16 _g307_partyMapY; // @ G0307_i_PartyMapY
 	uint8 _g309_partyMapIndex; // @ G0309_i_PartyMapIndex
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index dae3400..d264bf1 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1462,7 +1462,7 @@ void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) {
 
 
 // NOTE: has been screened for missing code
-void DisplayMan::f116_drawSquareD3L(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 	static DoorFrames g179_doorFrame_D3L = DoorFrames( // @ G0179_s_Graphic558_Frames_Door_D3L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
 													  Frame(24, 71, 28, 67, 24, 41, 0, 0),     /* Closed Or Destroyed */
@@ -1527,7 +1527,7 @@ T0116017_orangeElk:
 	}
 }
 
-void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 	static DoorFrames g181_doorFrame_D3R = DoorFrames( // @ G0181_s_Graphic558_Frames_Door_D3R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
 													  Frame(150, 197, 28, 67, 24, 41, 0, 0),	/* Closed Or Destroyed */
@@ -1598,7 +1598,7 @@ T0117018:
 	}
 }
 
-void DisplayMan::f118_drawSquareD3C(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 	static DoorFrames g180_doorFrame_D3C = DoorFrames( // @ G0180_s_Graphic558_Frames_Door_D3C
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
 													  Frame(88, 135, 28, 67, 24, 41, 0, 0),		/* Closed Or Destroyed */
@@ -1662,7 +1662,7 @@ T0118028:
 	}
 }
 
-void DisplayMan::f119_drawSquareD2L(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 	static DoorFrames g182_doorFrame_D2L = DoorFrames( // @ G0182_s_Graphic558_Frames_Door_D2L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
 													  Frame(0, 63, 24, 82, 32, 61, 0, 0),	/* Closed Or Destroyed */
@@ -1728,7 +1728,7 @@ T0119020:
 	}
 }
 
-void DisplayMan::f120_drawSquareD2R(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
 	static DoorFrames g184_doorFrame_D2R = DoorFrames( // @ G0184_s_Graphic558_Frames_Door_D2R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
 													  Frame(160, 223, 24, 82, 32, 61, 0, 0),	/* Closed Or Destroyed */
@@ -1796,7 +1796,7 @@ T0120029:
 	}
 }
 
-void DisplayMan::f121_drawSquareD2C(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 	static DoorFrames g183_doorFrame_D2C = DoorFrames( // @ G0183_s_Graphic558_Frames_Door_D2C
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
 													  Frame(80, 143, 24, 82, 32, 61, 0, 0),		/* Closed Or Destroyed */
@@ -1862,7 +1862,7 @@ T0121016:
 	}
 }
 
-void DisplayMan::f122_drawSquareD1L(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
 	static DoorFrames g185_doorFrame_D1L = DoorFrames( // @ G0185_s_Graphic558_Frames_Door_D1L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
 													  Frame(0, 31, 17, 102, 48, 88, 64, 0),	/* Closed Or Destroyed */
@@ -1929,7 +1929,7 @@ T0122021:
 	}
 }
 
-void DisplayMan::f123_drawSquareD1R(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {
 	static DoorFrames g187_doorFrame_D1R = DoorFrames( // @ G0187_s_Graphic558_Frames_Door_D1R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
 													  Frame(192, 223, 17, 102, 48, 88, 0, 0),     /* Closed Or Destroyed */
@@ -1995,7 +1995,7 @@ T0123021:
 		f113_drawField(&g188_FieldAspects[k8_ViewSquare_D1R], g163_FrameWalls[k8_ViewSquare_D1R]._box);
 	}
 }
-void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 	static Box g107_BoxThievesEyeVisibleArea(0, 95, 0, 94); // @ G0107_s_Graphic558_Box_ThievesEye_VisibleArea 
 	int16 order;
 	int16 squareAspect[5];
@@ -2075,7 +2075,7 @@ T0124018:
 	}
 }
 
-void DisplayMan::f125_drawSquareD0L(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f125_drawSquareD0L(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
@@ -2091,7 +2091,7 @@ void DisplayMan::f125_drawSquareD0L(direction dir, int16 posX, int16 posY) {
 	}
 }
 
-void DisplayMan::f126_drawSquareD0R(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
 	int16 squareAspect[5];
 
 
@@ -2118,7 +2118,7 @@ void DisplayMan::f126_drawSquareD0R(direction dir, int16 posX, int16 posY) {
 	}
 }
 
-void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 	static Box g108_BoxThievesEyeHoleInDoorFrame(0, 31, 19, 113); // @ G0108_s_Graphic558_Box_ThievesEye_HoleInDoorFrame 
 
 	int16 squareAspect[5];
@@ -2155,7 +2155,7 @@ void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) {
 	}
 }
 
-void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) {
+void DisplayMan::f128_drawDungeon(Direction dir, int16 posX, int16 posY) {
 	loadPalette(g20_PalEntrance); // dummy code
 
 
@@ -2878,7 +2878,7 @@ int16 g225_CenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_Cen
 
 #define k0x0080_BlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK
 
-void DisplayMan::f115_cthulhu(Thing thingParam, direction directionParam, int16 mapXpos,
+void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16 mapXpos,
 							  int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) {
 
 	DungeonMan &dunMan = *_vm->_dungeonMan;
@@ -3460,7 +3460,7 @@ continue;
 						projectileBitmapIndexData = 0;
 						flipVertical = flipHorizontal = false;
 					} else {
-						if (isOrientedWestEast((direction)(projectileDirection = _vm->_timeline->_g370_events[projectile->_eventIndex]._C._projectile.getDir()))
+						if (isOrientedWestEast((Direction)(projectileDirection = _vm->_timeline->_g370_events[projectile->_eventIndex]._C._projectile.getDir()))
 							!= isOrientedWestEast(directionParam)) {
 							if (projectileAspectType == k2_ProjectileAspectHasRotation) {
 								projectileBitmapIndexData = 1;
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 1a1ad49..3af375d 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -530,18 +530,18 @@ class DisplayMan {
 	void f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap
 	void f100_drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap
 	void f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency
-	void f116_drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L
-	void f117_drawSquareD3R(direction dir, int16 posX, int16 posY); // @ F0117_DUNGEONVIEW_DrawSquareD3R
-	void f118_drawSquareD3C(direction dir, int16 posX, int16 posY); // @ F0118_DUNGEONVIEW_DrawSquareD3C_CPSF
-	void f119_drawSquareD2L(direction dir, int16 posX, int16 posY); // @ F0119_DUNGEONVIEW_DrawSquareD2L
-	void f120_drawSquareD2R(direction dir, int16 posX, int16 posY); // @ F0120_DUNGEONVIEW_DrawSquareD2R_CPSF
-	void f121_drawSquareD2C(direction dir, int16 posX, int16 posY); // @ F0121_DUNGEONVIEW_DrawSquareD2C
-	void f122_drawSquareD1L(direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1L
-	void f123_drawSquareD1R(direction dir, int16 posX, int16 posY); // @ F0123_DUNGEONVIEW_DrawSquareD1R
-	void f124_drawSquareD1C(direction dir, int16 posX, int16 posY); // @ F0124_DUNGEONVIEW_DrawSquareD1C
-	void f125_drawSquareD0L(direction dir, int16 posX, int16 posY); // @ F0125_DUNGEONVIEW_DrawSquareD0L
-	void f126_drawSquareD0R(direction dir, int16 posX, int16 posY); // @ F0126_DUNGEONVIEW_DrawSquareD0R
-	void f127_drawSquareD0C(direction dir, int16 posX, int16 posY); // @ F0127_DUNGEONVIEW_DrawSquareD0C
+	void f116_drawSquareD3L(Direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L
+	void f117_drawSquareD3R(Direction dir, int16 posX, int16 posY); // @ F0117_DUNGEONVIEW_DrawSquareD3R
+	void f118_drawSquareD3C(Direction dir, int16 posX, int16 posY); // @ F0118_DUNGEONVIEW_DrawSquareD3C_CPSF
+	void f119_drawSquareD2L(Direction dir, int16 posX, int16 posY); // @ F0119_DUNGEONVIEW_DrawSquareD2L
+	void f120_drawSquareD2R(Direction dir, int16 posX, int16 posY); // @ F0120_DUNGEONVIEW_DrawSquareD2R_CPSF
+	void f121_drawSquareD2C(Direction dir, int16 posX, int16 posY); // @ F0121_DUNGEONVIEW_DrawSquareD2C
+	void f122_drawSquareD1L(Direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1L
+	void f123_drawSquareD1R(Direction dir, int16 posX, int16 posY); // @ F0123_DUNGEONVIEW_DrawSquareD1R
+	void f124_drawSquareD1C(Direction dir, int16 posX, int16 posY); // @ F0124_DUNGEONVIEW_DrawSquareD1C
+	void f125_drawSquareD0L(Direction dir, int16 posX, int16 posY); // @ F0125_DUNGEONVIEW_DrawSquareD0L
+	void f126_drawSquareD0R(Direction dir, int16 posX, int16 posY); // @ F0126_DUNGEONVIEW_DrawSquareD0R
+	void f127_drawSquareD0C(Direction dir, int16 posX, int16 posY); // @ F0127_DUNGEONVIEW_DrawSquareD0C
 
 
 	void f93_applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors
@@ -680,7 +680,7 @@ public:
 	void D24_fillScreenBox(Box &box, Color color); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox
 /* Expects inclusive boundaries in box */
 	void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 byteWidth, int16 height); // @ F0135_VIDEO_FillBox
-	void f128_drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
+	void f128_drawDungeon(Direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void f98_drawFloorAndCeiling(); // @ F0098_DUNGEONVIEW_DrawFloorAndCeiling
 	void updateScreen();
 	void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport
@@ -692,7 +692,7 @@ public:
 
 	int16 f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale); // @ F0459_START_GetScaledBitmapByteCount
 	int16 M78_getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION
-	void f115_cthulhu(Thing thingParam, direction directionParam,
+	void f115_cthulhu(Thing thingParam, Direction directionParam,
 				 int16 mapXpos, int16 mapYpos, int16 viewSquareIndex,
 				 uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 	uint16 M77_getNormalizedByteWidth(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 235bfe4..ec2090c 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -873,8 +873,8 @@ T0209084_SingleSquareMoveTowardParty:
 T0209085_SingleSquareMove:
 					if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls) ||
 						f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls && _vm->getRandomNumber(2)) ||
-						f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction), false) ||
-						(!_vm->getRandomNumber(4) && f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty), false))) {
+						f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)AL0446_i_Direction), false) ||
+						(!_vm->getRandomNumber(4) && f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)L0454_i_PrimaryDirectionToOrFromParty), false))) {
 						AL0450_i_DestinationMapX = eventMapX;
 						AL0451_i_DestinationMapY = eventMapY;
 						AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
@@ -885,8 +885,8 @@ T0209089_DoubleSquareMove:
 						f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false); /* BUG0_00 Useless code. Returned value is ignored. When Lord Chaos teleports two squares away the ability to move to the first square is ignored which means Lord Chaos can teleport through walls or any other obstacle */
 						if (f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty) ||
 							f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty) ||
-							(_g386_fluxCageCount && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction))) ||
-							((_g386_fluxCageCount >= 2) && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty)))) {
+							(_g386_fluxCageCount && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)AL0446_i_Direction))) ||
+							((_g386_fluxCageCount >= 2) && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)L0454_i_PrimaryDirectionToOrFromParty)))) {
 							AL0450_i_DestinationMapX = eventMapX;
 							AL0451_i_DestinationMapY = eventMapY;
 							AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2;
@@ -925,8 +925,8 @@ T0209096_SetBehavior0_Wander:
 							AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY;
 						}
 						/* Try and flee from the party (opposite direction) */
-						L0454_i_PrimaryDirectionToOrFromParty = returnOppositeDir((direction)f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY));
-						_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnOppositeDir((direction)_vm->_projexpl->_g363_secondaryDirToOrFromParty);
+						L0454_i_PrimaryDirectionToOrFromParty = returnOppositeDir((Direction)f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY));
+						_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnOppositeDir((Direction)_vm->_projexpl->_g363_secondaryDirToOrFromParty);
 						L0461_i_MovementTicks -= (L0461_i_MovementTicks >> 2);
 						goto T0209085_SingleSquareMove;
 					}
@@ -996,7 +996,7 @@ T0209096_SetBehavior0_Wander:
 									AL0446_i_Cell++;
 								}
 								if (!_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = M21_normalizeModulo4(AL0446_i_Cell)) ||
-									(_vm->getRandomNumber(2) && !_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */
+									(_vm->getRandomNumber(2) && !_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((Direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */
 									if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* BUG0_70 A projectile impact on a creature may be ignored. The function F0218_PROJECTILE_GetImpactCount to detect projectile impacts when a quarter square sized creature moves inside a group (to another cell on the same square) may fail if there are several creatures in the group because the function expects a single cell index for its last parameter. The function should be called once for each cell where there is a creature */
 										goto T0209139_Return;
 									if (_vm->_projexpl->_g364_creatureDamageOutcome != k1_outcomeKilledSomeCreaturesInGroup) {
@@ -1072,7 +1072,7 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 	if (creatureInfo->_movementTicks == k255_immobile) {
 		return false;
 	}
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement((direction)dir, 1, 0, mapX, mapY);
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement((Direction)dir, 1, 0, mapX, mapY);
 	L0428_i_MapX = mapX;
 	L0429_i_MapY = mapY;
 	if (_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter =
@@ -1333,7 +1333,7 @@ void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 crea
 		G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime = _vm->_g313_gameTime;
 		G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup = activeGroup;
 	}
-	activeGroup->_directions = (direction)L0435_ui_GroupDirections;
+	activeGroup->_directions = (Direction)L0435_ui_GroupDirections;
 }
 
 void GroupMan::f208_groupAddEvent(TimelineEvent *event, uint32 time) {
@@ -1488,7 +1488,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
 		_vm->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, mapX, mapY, k0_soundModePlayImmediately);
-		_vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
+		_vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (Direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
 	} else {
 		if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) {
 			AL0439_i_ChampionIndex = _vm->getRandomNumber(4);
@@ -1510,7 +1510,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 			Champion *L0442_ps_Champion = &_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex];
 			if (AL0440_i_Damage > L0442_ps_Champion->_maximumDamageReceived) {
 				L0442_ps_Champion->_maximumDamageReceived = AL0440_i_Damage;
-				L0442_ps_Champion->_directionMaximumDamageReceived = returnOppositeDir((direction)L0438_ui_PrimaryDirectionToParty);
+				L0442_ps_Champion->_directionMaximumDamageReceived = returnOppositeDir((Direction)L0438_ui_PrimaryDirectionToParty);
 			}
 		}
 	}
@@ -1710,7 +1710,7 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
 	L0341_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime - 127;
 	L0339_ui_CreatureIndex = L0340_ps_Group->getCount();
 	do {
-		L0341_ps_ActiveGroup->_directions = (direction)f178_getGroupValueUpdatedWithCreatureValue(L0341_ps_ActiveGroup->_directions, L0339_ui_CreatureIndex, L0340_ps_Group->getDir());
+		L0341_ps_ActiveGroup->_directions = (Direction)f178_getGroupValueUpdatedWithCreatureValue(L0341_ps_ActiveGroup->_directions, L0339_ui_CreatureIndex, L0340_ps_Group->getDir());
 		L0341_ps_ActiveGroup->_aspect[L0339_ui_CreatureIndex] = 0;
 	} while (L0339_ui_CreatureIndex--);
 	f179_getCreatureAspectUpdateTime(L0341_ps_ActiveGroup, kM1_wholeCreatureGroup, false);
@@ -1770,7 +1770,7 @@ void GroupMan::f195_addAllActiveGroups() {
 	}
 }
 
-Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, direction dir, int16 mapX, int16 mapY) {
+Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, Direction dir, int16 mapX, int16 mapY) {
 	Thing L0349_T_GroupThing;
 	uint16 L0350_ui_BaseHealth;
 	uint16 L0351_ui_Cell = 0;
@@ -2082,7 +2082,7 @@ void GroupMan::load1_ActiveGroupPart(Common::InSaveFile* file) {
 	for (uint16 i = 0; i < _g376_maxActiveGroupCount; ++i) {
 		ActiveGroup *group = &_g375_activeGroups[i];
 		group->_groupThingIndex = file->readUint16BE();
-		group->_directions = (direction)file->readUint16BE();
+		group->_directions = (Direction)file->readUint16BE();
 		group->_cells = file->readByte();
 		group->_lastMoveTime = file->readByte();
 		group->_delayFleeingFromTarget = file->readByte();
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 1447783..5194b90 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -93,7 +93,7 @@ enum CreatureType {
 class ActiveGroup {
 public:
 	int16 _groupThingIndex;
-	direction _directions;
+	Direction _directions;
 	byte _cells;
 	byte _lastMoveTime;
 	byte _delayFleeingFromTarget;
@@ -130,7 +130,7 @@ public:
 	uint16 setBehaviour(uint16 val) { _flags = (_flags & ~0xF) | (val & 0xF); return (val & 0xF); }
 	uint16 getCount() { return (_flags >> 5) & 0x3; }
 	void setCount(uint16 val) { _flags = (_flags & ~(0x3 << 5)) | ((val & 0x3) << 5); }
-	direction getDir() { return (direction)((_flags >> 8) & 0x3); }
+	Direction getDir() { return (Direction)((_flags >> 8) & 0x3); }
 	void setDir(uint16 val) { _flags = (_flags & ~(0x3 << 8)) | ((val & 0x3) << 8); }
 	uint16 getDoNotDiscard() { return (_flags >> 10) & 0x1; }
 	void setDoNotDiscard(bool val) { _flags = (_flags & ~(1 << 10)) | ((val & 1) << 10); }
@@ -234,7 +234,7 @@ public:
 	void f184_removeActiveGroup(uint16 activeGroupIndex); // @ F0184_GROUP_RemoveActiveGroup
 	void f194_removeAllActiveGroups(); // @ F0194_GROUP_RemoveAllActiveGroups
 	void f195_addAllActiveGroups(); // @ F0195_GROUP_AddAllActiveGroups
-	Thing f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated
+	Thing f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, Direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated
 	bool f223_isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY); // @ F0223_GROUP_IsSquareACorridorTeleporterPitOrDoor
 	int16 f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 paryY,
 											 uint16 champCell); // @ F0177_GROUP_GetMeleeTargetCreatureOrdinal
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 138f9fd..a19cef2 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -83,7 +83,7 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		_championMan->_g305_partyChampionCount = file->readUint16BE();
 		_dungeonMan->_g306_partyMapX = file->readSint16BE();
 		_dungeonMan->_g307_partyMapY = file->readSint16BE();
-		_dungeonMan->_g308_partyDir = (direction)file->readUint16BE();
+		_dungeonMan->_g308_partyDir = (Direction)file->readUint16BE();
 		_dungeonMan->_g309_partyMapIndex = file->readByte();
 		_championMan->_g411_leaderIndex = (ChampionIndex)file->readSint16BE();
 		_championMan->_g514_magicCasterChampionIndex = (ChampionIndex)file->readSint16BE();
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 5a4c874..54ce632 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -215,7 +215,7 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
 				&& (champ->_maximumDamageReceived)
 				&& (champ->_dir != champ->_directionMaximumDamageReceived)) {
 
-				champ->_dir = (direction)champ->_directionMaximumDamageReceived;
+				champ->_dir = (Direction)champ->_directionMaximumDamageReceived;
 				champ->setAttributeFlag(k0x0400_ChampionAttributeIcon, true);
 				champMan.f292_drawChampionState((ChampionIndex)champIndex);
 			}
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 89b3693..1011b42 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -377,7 +377,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 						}
 						L0716_ui_Direction = _vm->_dungeonMan->f155_getStairsExitDirection(destMapX, destMapY);
 						destMapX += _vm->_dirIntoStepCountEast[L0716_ui_Direction], destMapY += _vm->_dirIntoStepCountNorth[L0716_ui_Direction];
-						L0716_ui_Direction = returnOppositeDir((direction)L0716_ui_Direction);
+						L0716_ui_Direction = returnOppositeDir((Direction)L0716_ui_Direction);
 						AL0727_ui_ThingCell = thing.getCell();
 						AL0727_ui_ThingCell = M21_normalizeModulo4((((AL0727_ui_ThingCell - L0716_ui_Direction + 1) & 0x0002) >> 1) + L0716_ui_Direction);
 						thing = M15_thingWithNewCell(thing, AL0727_ui_ThingCell);
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 8996693..06ba83a 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -45,7 +45,7 @@ ProjExpl::ProjExpl(DMEngine* vm) : _vm(vm) {
 	_g362_lastPartyMovementTime = 0;
 }
 
-void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, direction dir, byte kineticEnergy, byte attack, byte stepEnergy) {
+void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, Direction dir, byte kineticEnergy, byte attack, byte stepEnergy) {
 	Thing L0466_T_ProjectileThing;
 	Projectile* L0467_ps_Projectile;
 	TimelineEvent L0468_s_Event;
@@ -482,7 +482,7 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 		_vm->_movsens->f267_getMoveResult(L0515_T_ProjectileThingNewCell, L0525_i_SourceMapX, L0526_i_SourceMapY, L0523_i_DestinationMapX, L0524_i_DestinationMapY);
 		L0519_ps_Event->_C._projectile.setMapX(_vm->_movsens->_g397_moveResultMapX);
 		L0519_ps_Event->_C._projectile.setMapY(_vm->_movsens->_g398_moveResultMapY);
-		L0519_ps_Event->_C._projectile.setDir((direction)_vm->_movsens->_g400_moveResultDir);
+		L0519_ps_Event->_C._projectile.setDir((Direction)_vm->_movsens->_g400_moveResultDir);
 		L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_movsens->_g401_moveResultCell);
 		M31_setMap(L0519_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex);
 	} else {
diff --git a/engines/dm/projexpl.h b/engines/dm/projexpl.h
index d0e030f..0d6f3b6 100644
--- a/engines/dm/projexpl.h
+++ b/engines/dm/projexpl.h
@@ -88,7 +88,7 @@ public:
 	int16 _g367_projectileAttackType; // @ G0367_i_ProjectileAttackType
 	int32 _g362_lastPartyMovementTime; // @ G0362_l_LastPartyMovementTime
 	explicit ProjExpl(DMEngine *vm);
-	void f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, direction dir,
+	void f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, Direction dir,
 							   byte kineticEnergy, byte attack, byte stepEnergy); // @ F0212_PROJECTILE_Create
 	bool f217_projectileHasImpactOccurred(int16 impactType, int16 mapXCombo, int16 mapYCombo,
 										  int16 cell, Thing projectileThing); // @ F0217_PROJECTILE_HasImpactOccured
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 09e31bf..33bfc61 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -582,7 +582,7 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 			L0647_ps_Event = &_vm->_timeline->_g370_events[L0646_ps_Projectile->_eventIndex];
 			L0647_ps_Event->_C._projectile.setMapX(_vm->_movsens->_g397_moveResultMapX);
 			L0647_ps_Event->_C._projectile.setMapY(_vm->_movsens->_g398_moveResultMapY);
-			L0647_ps_Event->_C._projectile.setDir((direction)_vm->_movsens->_g400_moveResultDir);
+			L0647_ps_Event->_C._projectile.setDir((Direction)_vm->_movsens->_g400_moveResultDir);
 			L0647_ps_Event->_B._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_movsens->_g401_moveResultCell).toUint16();
 			M31_setMap(L0647_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex);
 		} else {
@@ -734,7 +734,7 @@ void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* eve
 	L0626_i_MapX = event->_B._location._mapX;
 	L0627_i_MapY = event->_B._location._mapY;
 	L0624_ui_Cell = event->_C.A._cell;
-	L0628_ui_ProjectileCell = returnOppositeDir((direction)L0624_ui_Cell);
+	L0628_ui_ProjectileCell = returnOppositeDir((Direction)L0624_ui_Cell);
 	L0625_i_SensorType = sensor->getType();
 	L0629_i_SensorData = sensor->getData();
 	L0630_i_KineticEnergy = sensor->M47_kineticEnergy();
@@ -785,9 +785,9 @@ void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* eve
 	}
 	L0626_i_MapX += _vm->_dirIntoStepCountEast[L0624_ui_Cell], L0627_i_MapY += _vm->_dirIntoStepCountNorth[L0624_ui_Cell]; /* BUG0_20 The game crashes if the launcher sensor is on a map boundary and shoots in a direction outside the map */
 	_vm->_projexpl->_g365_createLanucherProjectile = true;
-	_vm->_projexpl->f212_projectileCreate(L0622_T_FirstProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, L0628_ui_ProjectileCell, (direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy);
+	_vm->_projexpl->f212_projectileCreate(L0622_T_FirstProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, L0628_ui_ProjectileCell, (Direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy);
 	if (!L0632_B_LaunchSingleProjectile) {
-		_vm->_projexpl->f212_projectileCreate(L0623_T_SecondProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, returnNextVal(L0628_ui_ProjectileCell), (direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy);
+		_vm->_projexpl->f212_projectileCreate(L0623_T_SecondProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, returnNextVal(L0628_ui_ProjectileCell), (Direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy);
 	}
 	_vm->_projexpl->_g365_createLanucherProjectile = false;
 }
@@ -837,7 +837,7 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 					if ((AL0618_ui_HealthMultiplier = L0614_ps_Sensor->M45_healthMultiplier()) == 0) {
 						AL0618_ui_HealthMultiplier = _vm->_dungeonMan->_g269_currMap->_difficulty;
 					}
-					_vm->_groupMan->f185_groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY);
+					_vm->_groupMan->f185_groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (Direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY);
 					if (L0614_ps_Sensor->getAudibleA()) {
 						_vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0616_ui_MapX, L0617_ui_MapY, k1_soundModePlayIfPrioritized);
 					}
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index bb9b781..ffc6cc7 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -131,11 +131,11 @@ public:
 		public:
 			uint16 getMapX() { return _backing & 0x1F; }
 			uint16 getMapY() { return (_backing >> 5) & 0x1F; }
-			direction getDir() { return (direction)((_backing >> 10) & 0x3); }
+			Direction getDir() { return (Direction)((_backing >> 10) & 0x3); }
 			uint16 getStepEnergy() { return (_backing >> 12) & 0xF; }
 			void setMapX(uint16 val) { _backing = (_backing & ~0x1F) | (val & 0x1F); }
 			void setMapY(uint16 val) { _backing = (_backing & ~(0x1F << 5)) | ((val & 0x1F) << 5); }
-			void setDir(direction val) { _backing = (_backing & ~(0x3 << 10)) | ((val & 0x3) << 10); }
+			void setDir(Direction val) { _backing = (_backing & ~(0x3 << 10)) | ((val & 0x3) << 10); }
 			void setStepEnergy(uint16 val) { _backing = (_backing & ~(0xF << 12)) | ((val & 0xF) << 12); }
 		} _projectile;
 


Commit: 58d82353442ff5cef4d17510a9610b87e5a0b9ee
    https://github.com/scummvm/scummvm/commit/58d82353442ff5cef4d17510a9610b87e5a0b9ee
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f320_applyAndDrawPendingDamageAndWounds

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 3c0d08a..3fdc9ec 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1324,81 +1324,81 @@ void ChampionMan::f326_championShootProjectile(Champion* champ, Thing thing, int
 }
 
 void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() {
-	uint16 L0967_ui_ChampionIndex;
-	uint16 L0968_ui_PendingDamage;
-	int16 L0969_i_Multiple;
-#define AL0969_i_Health     L0969_i_Multiple
-#define AL0969_i_X          L0969_i_Multiple
-#define AL0969_i_EventIndex L0969_i_Multiple
-	int16 L0970_i_PendingWounds;
-	Champion* L0971_ps_Champion;
-	TimelineEvent* L0972_ps_Event;
-	int16 L0973_i_Y;
-	TimelineEvent L0974_s_Event;
-	Box L0975_s_Box;
-
-
-	L0971_ps_Champion = _vm->_championMan->_gK71_champions;
-	for (L0967_ui_ChampionIndex = k0_ChampionFirst; L0967_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0967_ui_ChampionIndex++, L0971_ps_Champion++) {
-		setFlag(L0971_ps_Champion->_wounds, L0970_i_PendingWounds = _g410_championPendingWounds[L0967_ui_ChampionIndex]);
-		_g410_championPendingWounds[L0967_ui_ChampionIndex] = 0;
-		if (!(L0968_ui_PendingDamage = _g409_championPendingDamage[L0967_ui_ChampionIndex]))
+	Champion *championPtr = _vm->_championMan->_gK71_champions;
+	for (uint16 championIndex = k0_ChampionFirst; championIndex < _vm->_championMan->_g305_partyChampionCount; championIndex++, championPtr++) {
+		int16 pendingWounds = _g410_championPendingWounds[championIndex];
+		setFlag(championPtr->_wounds, pendingWounds);
+		_g410_championPendingWounds[championIndex] = 0;
+		uint16 pendingDamage = _g409_championPendingDamage[championIndex];
+		if (!pendingDamage)
 			continue;
-		_g409_championPendingDamage[L0967_ui_ChampionIndex] = 0;
-		if (!(AL0969_i_Health = L0971_ps_Champion->_currHealth))
+
+		_g409_championPendingDamage[championIndex] = 0;
+		int16 curHealth = championPtr->_currHealth;
+		if (!curHealth)
 			continue;
-		if ((AL0969_i_Health = AL0969_i_Health - L0968_ui_PendingDamage) <= 0) {
-			_vm->_championMan->f319_championKill(L0967_ui_ChampionIndex);
+
+		curHealth -= pendingDamage;
+		if (curHealth <= 0) {
+			_vm->_championMan->f319_championKill(championIndex);
 		} else {
-			L0971_ps_Champion->_currHealth = AL0969_i_Health;
-			setFlag(L0971_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
-			if (L0970_i_PendingWounds) {
-				setFlag(L0971_ps_Champion->_attributes, k0x2000_ChampionAttributeWounds);
+			championPtr->_currHealth = curHealth;
+			setFlag(championPtr->_attributes, k0x0100_ChampionAttributeStatistics);
+			if (pendingWounds) {
+				setFlag(championPtr->_attributes, k0x2000_ChampionAttributeWounds);
 			}
-			AL0969_i_X = L0967_ui_ChampionIndex * k69_ChampionStatusBoxSpacing;
-			L0975_s_Box._y1 = 0;
+
+			int16 textPosX = championIndex * k69_ChampionStatusBoxSpacing;
+			int16 textPosY;
+
+			Box blitBox;
+			blitBox._y1 = 0;
 			_vm->_eventMan->f78_showMouse();
-			if (_vm->M0_indexToOrdinal(L0967_ui_ChampionIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
-				L0975_s_Box._y2 = 28;
-				L0975_s_Box._x2 = (L0975_s_Box._x1 = AL0969_i_X + 7) + 31; /* Box is over the champion portrait in the status box */
-				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k16_damageToChampionBig), &L0975_s_Box, k16_byteWidth, k10_ColorFlesh, 29);
-				if (L0968_ui_PendingDamage < 10) { /* 1 digit */
-					AL0969_i_X += 21;
-				} else {
-					if (L0968_ui_PendingDamage < 100) { /* 2 digits */
-						AL0969_i_X += 18;
-					} else { /* 3 digits */
-						AL0969_i_X += 15;
-					}
-				}
-				L0973_i_Y = 16;
+
+			if (_vm->M0_indexToOrdinal(championIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+				blitBox._y2 = 28;
+				blitBox._x1 = textPosX + 7;
+				blitBox._x2 = blitBox._x1 + 31; /* Box is over the champion portrait in the status box */
+				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k16_damageToChampionBig), &blitBox, k16_byteWidth, k10_ColorFlesh, 29);
+				// Check the number of digits and sets the position accordingly.
+				if (pendingDamage < 10) // 1 digit
+					textPosX += 21;
+				else if (pendingDamage < 100)  // 2 digits
+					textPosX += 18;
+				else // 3 digits
+					textPosX += 15;
+
+				textPosY = 16;
 			} else {
-				L0975_s_Box._y2 = 6;
-				L0975_s_Box._x2 = (L0975_s_Box._x1 = AL0969_i_X) + 47; /* Box is over the champion name in the status box */
-				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k15_damageToChampionSmallIndice), &L0975_s_Box, k24_byteWidth, k10_ColorFlesh, 7);
-				if (L0968_ui_PendingDamage < 10) { /* 1 digit */
-					AL0969_i_X += 19;
-				} else {
-					if (L0968_ui_PendingDamage < 100) { /* 2 digits */
-						AL0969_i_X += 16;
-					} else { /* 3 digits */
-						AL0969_i_X += 13;
-					}
-				}
-				L0973_i_Y = 5;
+				blitBox._y2 = 6;
+				blitBox._x1 = textPosX;
+				blitBox._x2 = blitBox._x1 + 47; /* Box is over the champion name in the status box */
+				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k15_damageToChampionSmallIndice), &blitBox, k24_byteWidth, k10_ColorFlesh, 7);
+				// Check the number of digits and sets the position accordingly.
+				if (pendingDamage < 10) // 1 digit
+					textPosX += 19;
+				else if (pendingDamage < 100) // 2 digits
+					textPosX += 16;
+				else //3 digits
+					textPosX += 13;
+
+				textPosY = 5;
 			}
-			_vm->_textMan->f53_printToLogicalScreen(AL0969_i_X, L0973_i_Y, k15_ColorWhite, k8_ColorRed, _vm->_championMan->f288_getStringFromInteger(L0968_ui_PendingDamage, false, 3).c_str());
-			if ((AL0969_i_EventIndex = L0971_ps_Champion->_hideDamageReceivedIndex) == -1) {
-				L0974_s_Event._type = k12_TMEventTypeHideDamageReceived;
-				M33_setMapAndTime(L0974_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
-				L0974_s_Event._priority = L0967_ui_ChampionIndex;
-				L0971_ps_Champion->_hideDamageReceivedIndex = _vm->_timeline->f238_addEventGetEventIndex(&L0974_s_Event);
+			_vm->_textMan->f53_printToLogicalScreen(textPosX, textPosY, k15_ColorWhite, k8_ColorRed, _vm->_championMan->f288_getStringFromInteger(pendingDamage, false, 3).c_str());
+
+			int16 eventIndex = championPtr->_hideDamageReceivedIndex;
+			if (eventIndex == -1) {
+				TimelineEvent newEvent;
+				newEvent._type = k12_TMEventTypeHideDamageReceived;
+				M33_setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
+				newEvent._priority = championIndex;
+				championPtr->_hideDamageReceivedIndex = _vm->_timeline->f238_addEventGetEventIndex(&newEvent);
 			} else {
-				L0972_ps_Event = &_vm->_timeline->_g370_events[AL0969_i_EventIndex];
-				M33_setMapAndTime(L0972_ps_Event->_mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
-				_vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(AL0969_i_EventIndex));
+				TimelineEvent *curEvent = &_vm->_timeline->_g370_events[eventIndex];
+				M33_setMapAndTime(curEvent->_mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
+				_vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(eventIndex));
 			}
-			_vm->_championMan->f292_drawChampionState((ChampionIndex)L0967_ui_ChampionIndex);
+			_vm->_championMan->f292_drawChampionState((ChampionIndex)championIndex);
 			_vm->_eventMan->f77_hideMouse();
 		}
 	}


Commit: cdbbc15e5623f47a0e93e5d9113ac64b709cf6de
    https://github.com/scummvm/scummvm/commit/cdbbc15e5623f47a0e93e5d9113ac64b709cf6de
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f318_dropAllObjects, f319_championKill and f323_unpoison. Rename _moveSens

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/group.cpp
    engines/dm/menus.cpp
    engines/dm/projexpl.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 3fdc9ec..9b14993 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1405,16 +1405,9 @@ void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() {
 }
 
 void ChampionMan::f319_championKill(uint16 champIndex) {
-	uint16 L0962_ui_Multiple = 0;
-#define AL0962_ui_Cell              L0962_ui_Multiple
-#define AL0962_ui_ChampionIconIndex L0962_ui_Multiple
-	int16 L0963_i_AliveChampionIndex;
-	Thing L0964_T_Thing;
-	Champion* L0965_ps_Champion;
-
-	L0965_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
-	L0965_ps_Champion->_currHealth = 0;
-	setFlag(L0965_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox);
+	Champion *curChampion = &_vm->_championMan->_gK71_champions[champIndex];
+	curChampion->_currHealth = 0;
+	setFlag(curChampion->_attributes, k0x1000_ChampionAttributeStatusBox);
 	if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 		if (_vm->_g331_pressingEye) {
 			_vm->_g331_pressingEye = false;
@@ -1424,63 +1417,65 @@ void ChampionMan::f319_championKill(uint16 champIndex) {
 			}
 			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
 			_vm->_eventMan->f77_hideMouse();
-		} else {
-			if (_vm->_g333_pressingMouth) {
-				_vm->_g333_pressingMouth = false;
-				_vm->_eventMan->_g597_ignoreMouseMovements = false;
-				_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
-				_vm->_eventMan->f77_hideMouse();
-			}
+		} else if (_vm->_g333_pressingMouth) {
+			_vm->_g333_pressingMouth = false;
+			_vm->_eventMan->_g597_ignoreMouseMovements = false;
+			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
+			_vm->_eventMan->f77_hideMouse();
 		}
 		_vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
 	}
 	f318_dropAllObjects(champIndex);
-	L0964_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k0x8000_championBones | k10_JunkThingType);
-	if (L0964_T_Thing == Thing::_none) {
-	} else {
-		Junk* L0966_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0964_T_Thing);
+	Thing unusedThing = _vm->_dungeonMan->f166_getUnusedThing(k0x8000_championBones | k10_JunkThingType);
+	uint16 curCell = 0;
+	if (unusedThing != Thing::_none) {
+		Junk *L0966_ps_Junk = (Junk *)_vm->_dungeonMan->f156_getThingData(unusedThing);
 		L0966_ps_Junk->setType(k5_JunkTypeBones);
 		L0966_ps_Junk->setDoNotDiscard(true);
 		L0966_ps_Junk->setChargeCount(champIndex);
-		AL0962_ui_Cell = L0965_ps_Champion->_cell;
-		_vm->_movsens->f267_getMoveResult(M15_thingWithNewCell(L0964_T_Thing, AL0962_ui_Cell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
-	}
-	L0965_ps_Champion->_symbolStep = 0;
-	L0965_ps_Champion->_symbols[0] = '\0';
-	L0965_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
-	L0965_ps_Champion->_maximumDamageReceived = 0;
-	AL0962_ui_ChampionIconIndex = _vm->_championMan->M26_championIconIndex(AL0962_ui_Cell, _vm->_dungeonMan->_g308_partyDir);
-	if (_vm->M0_indexToOrdinal(AL0962_ui_ChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
+		curCell = curChampion->_cell;
+		_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(unusedThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+	}
+	curChampion->_symbolStep = 0;
+	curChampion->_symbols[0] = '\0';
+	curChampion->_dir = _vm->_dungeonMan->_g308_partyDir;
+	curChampion->_maximumDamageReceived = 0;
+	uint16 curChampionIconIndex = _vm->_championMan->M26_championIconIndex(curCell, _vm->_dungeonMan->_g308_partyDir);
+	if (_vm->M0_indexToOrdinal(curChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
 		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
 		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
 		warning(false, "IGNORED CODE:G0592_B_BuildMousePointerScreenAreaRequested = true");
 	}
-	if (L0965_ps_Champion->_poisonEventCount) {
+
+	if (curChampion->_poisonEventCount)
 		f323_unpoison(champIndex);
-	}
+
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0962_ui_ChampionIconIndex << 2], k0_ColorBlack);
+	_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[curChampionIconIndex << 2], k0_ColorBlack);
 	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
-	for (L0963_i_AliveChampionIndex = k0_ChampionFirst, L0965_ps_Champion = _vm->_championMan->_gK71_champions; L0963_i_AliveChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0963_i_AliveChampionIndex++, L0965_ps_Champion++) {
-		if (L0965_ps_Champion->_currHealth)
+	
+	int16 aliveChampionIndex;
+	for (aliveChampionIndex = k0_ChampionFirst, curChampion = _vm->_championMan->_gK71_champions; aliveChampionIndex < _vm->_championMan->_g305_partyChampionCount; aliveChampionIndex++, curChampion++) {
+		if (curChampion->_currHealth)
 			break;
 	}
-	if (L0963_i_AliveChampionIndex == _vm->_championMan->_g305_partyChampionCount) { /* BUG0_43 The game does not end if the last living champion in the party is killed while looking at a candidate champion in a portrait. The condition to end the game when the whole party is killed is not true because the code considers the candidate champion as alive (in the loop above) */
+
+	if (aliveChampionIndex == _vm->_championMan->_g305_partyChampionCount) { /* BUG0_43 The game does not end if the last living champion in the party is killed while looking at a candidate champion in a portrait. The condition to end the game when the whole party is killed is not true because the code considers the candidate champion as alive (in the loop above) */
 		_vm->_championMan->_g303_partyDead = true;
 		return;
 	}
-	if (champIndex == _vm->_championMan->_g411_leaderIndex) {
-		_vm->_eventMan->f368_commandSetLeader((ChampionIndex)L0963_i_AliveChampionIndex);
-	}
-	if (champIndex == _vm->_championMan->_g514_magicCasterChampionIndex) {
-		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(L0963_i_AliveChampionIndex);
-	} else {
+
+	if (champIndex == _vm->_championMan->_g411_leaderIndex)
+		_vm->_eventMan->f368_commandSetLeader((ChampionIndex)aliveChampionIndex);
+
+	if (champIndex == _vm->_championMan->_g514_magicCasterChampionIndex)
+		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(aliveChampionIndex);
+	else
 		_vm->_menuMan->f393_drawSpellAreaControls(_vm->_championMan->_g514_magicCasterChampionIndex);
-	}
 }
 
 void ChampionMan::f318_dropAllObjects(uint16 champIndex) {
-	static int16 G0057_ai_Graphic562_SlotDropOrder[30] = {
+	static const int16 slotDropOrder[30] = {
 		k5_ChampionSlotFeet,
 		k4_ChampionSlotLegs,
 		k9_ChampionSlotQuiverLine_2_2,
@@ -1510,31 +1505,26 @@ void ChampionMan::f318_dropAllObjects(uint16 champIndex) {
 		k10_ChampionSlotNeck,
 		k2_ChampionSlotHead,
 		k0_ChampionSlotReadyHand,
-		k1_ChampionSlotActionHand};
-
-	uint16 L0959_ui_Cell;
-	Thing L0960_T_Thing;
-	uint16 L0961_ui_SlotIndex;
+		k1_ChampionSlotActionHand
+	};
 
-	L0959_ui_Cell = _vm->_championMan->_gK71_champions[champIndex]._cell;
-	for (L0961_ui_SlotIndex = k0_ChampionSlotReadyHand; L0961_ui_SlotIndex < k30_ChampionSlotChest_1; L0961_ui_SlotIndex++) {
-		if ((L0960_T_Thing = f300_getObjectRemovedFromSlot(champIndex, G0057_ai_Graphic562_SlotDropOrder[L0961_ui_SlotIndex])) != Thing::_none) {
-			_vm->_movsens->f267_getMoveResult(M15_thingWithNewCell(L0960_T_Thing, L0959_ui_Cell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+	uint16 curCell = _vm->_championMan->_gK71_champions[champIndex]._cell;
+	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
+		Thing curThing = f300_getObjectRemovedFromSlot(champIndex, slotDropOrder[slotIndex]);
+		if (curThing != Thing::_none) {
+			_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(curThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
 		}
 	}
 }
 
 void ChampionMan::f323_unpoison(int16 champIndex) {
-	int16 L0982_i_EventIndex;
-	TimelineEvent* L0983_ps_Event;
-
-	if (champIndex == kM1_ChampionNone) {
+	if (champIndex == kM1_ChampionNone)
 		return;
-	}
-	for (L0982_i_EventIndex = 0, L0983_ps_Event = _vm->_timeline->_g370_events; L0982_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0983_ps_Event++, L0982_i_EventIndex++) {
-		if ((L0983_ps_Event->_type == k75_TMEventTypePoisonChampion) && (L0983_ps_Event->_priority == champIndex)) {
-			_vm->_timeline->f237_deleteEvent(L0982_i_EventIndex);
-		}
+
+	TimelineEvent *eventPtr = _vm->_timeline->_g370_events;
+	for (uint16 eventIndex = 0; eventIndex < _vm->_timeline->_g369_eventMaxCount; eventPtr++, eventIndex++) {
+		if ((eventPtr->_type == k75_TMEventTypePoisonChampion) && (eventPtr->_priority == champIndex))
+			_vm->_timeline->f237_deleteEvent(eventIndex);
 	}
 	_vm->_championMan->_gK71_champions[champIndex]._poisonEventCount = 0;
 }
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 5d003b7..5671fc6 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -144,7 +144,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_objectMan = nullptr;
 	_inventoryMan = nullptr;
 	_textMan = nullptr;
-	_movsens = nullptr;
+	_moveSens = nullptr;
 	_groupMan = nullptr;
 	_timeline = nullptr;
 	_projexpl = nullptr;
@@ -195,7 +195,7 @@ DMEngine::~DMEngine() {
 	delete _objectMan;
 	delete _inventoryMan;
 	delete _textMan;
-	delete _movsens;
+	delete _moveSens;
 	delete _groupMan;
 	delete _timeline;
 	delete _projexpl;
@@ -241,7 +241,7 @@ void DMEngine::f463_initializeGame() {
 
 	f462_startGame();
 	if (_g298_newGame)
-		_movsens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
+		_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
 	_eventMan->f78_showMouse();
 	_eventMan->f357_discardAllInput();
 }
@@ -314,7 +314,7 @@ Common::Error DMEngine::run() {
 	_objectMan = new ObjectMan(this);
 	_inventoryMan = new InventoryMan(this);
 	_textMan = new TextMan(this);
-	_movsens = new MovesensMan(this);
+	_moveSens = new MovesensMan(this);
 	_groupMan = new GroupMan(this);
 	_timeline = new Timeline(this);
 	_projexpl = new ProjExpl(this);
@@ -341,7 +341,7 @@ void DMEngine::f2_gameloop() {
 		if (_g327_newPartyMapIndex != kM1_mapIndexNone) {
 T0002002:
 			f3_processNewPartyMap(_g327_newPartyMapIndex);
-			_movsens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
+			_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
 			_g327_newPartyMapIndex = kM1_mapIndexNone;
 			_eventMan->f357_discardAllInput();
 		}
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index c1881a0..7d2f925 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -240,7 +240,7 @@ public:
 	ObjectMan *_objectMan;
 	InventoryMan *_inventoryMan;
 	TextMan *_textMan;
-	MovesensMan *_movsens;
+	MovesensMan *_moveSens;
 	GroupMan *_groupMan;
 	Timeline *_timeline;
 	ProjExpl *_projexpl;
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index e01a154..38658ce 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1509,7 +1509,7 @@ Thing DungeonMan::f165_getDiscardTHing(uint16 thingType) {
 										continue;
 T0165026:
 									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
-									_vm->_movsens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0);
+									_vm->_moveSens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0);
 								}
 								_vm->_dungeonMan->f173_setCurrentMap(L0284_i_CurrentMapIndex);
 								G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex;
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 8851e28..7ccf647 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -806,9 +806,9 @@ void EventManager::f365_commandTurnParty(CommandType cmdType) {
 		f364_commandTakeStairs(getFlag(L1114_ui_Square, k0x0004_StairsUp));
 		return;
 	}
-	_vm->_movsens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, false);
+	_vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, false);
 	_vm->_championMan->f284_setPartyDirection(M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + ((cmdType == k2_CommandTurnRight) ? 1 : 3)));
-	_vm->_movsens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, true);
+	_vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, true);
 }
 
 void EventManager::f366_commandMoveParty(CommandType cmdType) {
@@ -864,7 +864,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(_vm->_dungeonMan->_g308_partyDir, g465_movementArrowToStepForwardCount[AL1118_ui_MovementArrowIndex], g466_movementArrowToSepRightCount[AL1118_ui_MovementArrowIndex], L1121_i_MapX, L1122_i_MapY);
 	L1116_i_SquareType = Square(AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(L1121_i_MapX, L1122_i_MapY).toByte()).getType();
 	if (L1116_i_SquareType == k3_ElementTypeStairs) {
-		_vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0);
+		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0);
 		_vm->_dungeonMan->_g306_partyMapX = L1121_i_MapX;
 		_vm->_dungeonMan->_g307_partyMapY = L1122_i_MapY;
 		f364_commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp));
@@ -905,9 +905,9 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 		return;
 	}
 	if (L1123_B_StairsSquare) {
-		_vm->_movsens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, L1121_i_MapX, L1122_i_MapY);
+		_vm->_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, L1121_i_MapX, L1122_i_MapY);
 	} else {
-		_vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1121_i_MapX, L1122_i_MapY);
+		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1121_i_MapX, L1122_i_MapY);
 	}
 	AL1115_ui_Ticks = 1;
 	L1119_ps_Champion = _vm->_championMan->_gK71_champions;
@@ -1003,7 +1003,7 @@ void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() {
 	L1136_ui_MapY = _vm->_dungeonMan->_g307_partyMapY;
 	L1135_ui_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1136_ui_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
 	if ((L1135_ui_MapX >= 0) && (L1135_ui_MapX < _vm->_dungeonMan->_g273_currMapWidth) && (L1136_ui_MapY >= 0) && (L1136_ui_MapY < _vm->_dungeonMan->_g274_currMapHeight)) {
-		_vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->f275_sensorIsTriggeredByClickOnWall(L1135_ui_MapX, L1136_ui_MapY, returnOppositeDir(_vm->_dungeonMan->_g308_partyDir));
+		_vm->_g321_stopWaitingForPlayerInput = _vm->_moveSens->f275_sensorIsTriggeredByClickOnWall(L1135_ui_MapX, L1136_ui_MapY, returnOppositeDir(_vm->_dungeonMan->_g308_partyDir));
 	}
 }
 
@@ -1028,7 +1028,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 			if ((((Door*)L1151_ps_Junk)->hasButton()) && _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
 				_vm->_g321_stopWaitingForPlayerInput = true;
 				_vm->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
-				_vm->_movsens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1);
+				_vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1);
 				return;
 			}
 		} else {
@@ -1212,14 +1212,14 @@ void EventManager::f373_processType80_clickInDungeonView_grabLeaderHandObject(ui
 	if (viewCell >= k2_ViewCellBackRight) {
 		L1137_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1138_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
 		if (((L1139_T_Thing = _vm->_groupMan->f175_groupGetThing(L1137_i_MapX, L1138_i_MapY)) != Thing::_endOfList) &&
-			!_vm->_movsens->f264_isLevitating(L1139_T_Thing) &&
+			!_vm->_moveSens->f264_isLevitating(L1139_T_Thing) &&
 			_vm->_groupMan->f176_getCreatureOrdinalInCell((Group*)_vm->_dungeonMan->f156_getThingData(L1139_T_Thing), M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir))) {
 			return; /* It is not possible to grab an object on floor if there is a non levitating creature on its cell */
 		}
 	}
 	L1139_T_Thing = _vm->_dungeonMan->_g292_pileTopObject[viewCell];
 	if (_vm->_objectMan->f33_getIconIndex(L1139_T_Thing) != kM1_IconIndiceNone) {
-		_vm->_movsens->f267_getMoveResult(L1139_T_Thing, L1137_i_MapX, L1138_i_MapY, kM1_MapXNotOnASquare, 0);
+		_vm->_moveSens->f267_getMoveResult(L1139_T_Thing, L1137_i_MapX, L1138_i_MapY, kM1_MapXNotOnASquare, 0);
 		_vm->_championMan->f297_putObjectInLeaderHand(L1139_T_Thing, true);
 	}
 	_vm->_g321_stopWaitingForPlayerInput = true;
@@ -1249,7 +1249,7 @@ void EventManager::f374_processType80_clickInDungeonViewDropLeaderHandObject(uin
 	}
 	L1145_ui_Cell = M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + viewCell);
 	L1142_T_Thing = _vm->_championMan->f298_getObjectRemovedFromLeaderHand();
-	_vm->_movsens->f267_getMoveResult(M15_thingWithNewCell(L1142_T_Thing, L1145_ui_Cell), kM1_MapXNotOnASquare, 0, L1140_i_MapX, L1141_i_MapY);
+	_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(L1142_T_Thing, L1145_ui_Cell), kM1_MapXNotOnASquare, 0, L1140_i_MapX, L1141_i_MapY);
 	if (L1146_B_DroppingIntoAnAlcove && _vm->_dungeonMan->_g287_isFacingViAltar && ((L1144_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L1142_T_Thing)) == k147_IconIndiceJunkChampionBones)) {
 		L1143_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1142_T_Thing);
 		M33_setMapAndTime(L1147_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 1);
@@ -1283,7 +1283,7 @@ void EventManager::f357_discardAllInput() {
 }
 
 void EventManager::f364_commandTakeStairs(bool stairsGoDown) {
-	_vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0);
+	_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0);
 	_vm->_g327_newPartyMapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g309_partyMapIndex, stairsGoDown ? -1 : 1, &_vm->_dungeonMan->_g306_partyMapX, &_vm->_dungeonMan->_g307_partyMapY);
 	_vm->_dungeonMan->f173_setCurrentMap(_vm->_g327_newPartyMapIndex);
 	_vm->_championMan->f284_setPartyDirection(_vm->_dungeonMan->f155_getStairsExitDirection(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY));
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index ec2090c..1d8fc18 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -144,7 +144,7 @@ void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThin
 			if ((L0365_T_CurrentThing).getType() == k5_WeaponThingType) {
 				L0371_B_WeaponDropped = true;
 			}
-			_vm->_movsens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
+			_vm->_moveSens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
 		} while ((L0365_T_CurrentThing = L0366_T_NextThing) != Thing::_endOfList);
 		if (mode >= k0_soundModePlayImmediately) {
 			_vm->f064_SOUND_RequestPlay_CPSD(L0371_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
@@ -256,7 +256,7 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX
 		L0360_ps_Weapon->setType(L0356_ui_FixedPossession);
 		L0360_ps_Weapon->setCursed(L0361_B_Cursed);
 		L0358_T_Thing = M15_thingWithNewCell(L0358_T_Thing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell);
-		_vm->_movsens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY);
+		_vm->_moveSens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY);
 	}
 	_vm->f064_SOUND_RequestPlay_CPSD(L0362_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
 }
@@ -487,7 +487,7 @@ void GroupMan::f189_delete(int16 mapX, int16 mapY) {
 	L0373_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0372_T_GroupThing);
 	for (uint16 i = 0; i < 4; ++i)
 		L0373_ps_Group->_health[i] = 0;
-	_vm->_movsens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
+	_vm->_moveSens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
 	L0373_ps_Group->_nextThing = Thing::_none;
 	if (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) {
 		_vm->_groupMan->_g375_activeGroups[L0373_ps_Group->getActiveGroupIndex()]._groupThingIndex = -1;
@@ -625,10 +625,10 @@ void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16
 			AL0450_i_DestinationMapX = eventMapX;
 			AL0451_i_DestinationMapY = eventMapY;
 			AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
-			if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
+			if (_vm->_moveSens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
 				goto T0209139_Return;
-			L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX;
-			L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY;
+			L0465_s_NextEvent._B._location._mapX = _vm->_moveSens->_g397_moveResultMapX;
+			L0465_s_NextEvent._B._location._mapY = _vm->_moveSens->_g398_moveResultMapY;
 		}
 		L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup;
 		AL0446_i_Ticks = MAX(ABS(_vm->_dungeonMan->_g272_currMapIndex - _vm->_dungeonMan->_g309_partyMapIndex) << 4, L0448_s_CreatureInfo._movementTicks << 1);
@@ -797,10 +797,10 @@ T0209058_MoveInRandomDirection:
 									&& f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction, false)) {
 T0209061_MoveGroup:
 									if (L0453_B_NewGroupDirectionFound = ((AL0447_i_Ticks = (L0461_i_MovementTicks >> 1) - L0462_i_TicksSinceLastMove) <= 0)) {
-										if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
+										if (_vm->_moveSens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
 											goto T0209139_Return;
-										L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX;
-										L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY;;
+										L0465_s_NextEvent._B._location._mapX = _vm->_moveSens->_g397_moveResultMapX;
+										L0465_s_NextEvent._B._location._mapY = _vm->_moveSens->_g398_moveResultMapY;;
 										L0445_ps_ActiveGroup->_priorMapX = eventMapX;
 										L0445_ps_ActiveGroup->_priorMapY = eventMapY;
 										L0445_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime;
@@ -1291,7 +1291,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 				if (L0331_ui_CreatureType == k13_CreatureTypeCouatl) {
 					if (_vm->getRandomNumber(2)) {
 						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-						L1635_ui_SoundIndex = _vm->_movsens->f514_getSound(k13_CreatureTypeCouatl);
+						L1635_ui_SoundIndex = _vm->_moveSens->f514_getSound(k13_CreatureTypeCouatl);
 						if (L1635_ui_SoundIndex <= k34_D13_soundCount) {
 							_vm->f064_SOUND_RequestPlay_CPSD(L1635_ui_SoundIndex, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized);
 						}
@@ -1806,7 +1806,7 @@ Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplie
 		}
 	} while (creatureCount--);
 	L0353_ps_Group->_cells = L0352_ui_GroupCells;
-	if (_vm->_movsens->f267_getMoveResult(L0349_T_GroupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) { /* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile impact (in which case the thing data was marked as unused) or the party is on the destination square and an event is created to move the creature into the dungeon later (in which case the thing is referenced in the event) */
+	if (_vm->_moveSens->f267_getMoveResult(L0349_T_GroupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) { /* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile impact (in which case the thing data was marked as unused) or the party is on the destination square and an event is created to move the creature into the dungeon later (in which case the thing is referenced in the event) */
 		return Thing::_none;
 	}
 	_vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, mapX, mapY, k1_soundModePlayIfPrioritized);
@@ -2049,7 +2049,7 @@ void GroupMan::f225_fuseAction(uint16 mapX, uint16 mapY) {
 				}
 			}
 			if (f223_isSquareACorridorTeleporterPitOrDoor(L0548_i_MapX, L0549_i_MapY)) {
-				if (!_vm->_movsens->f267_getMoveResult(L0555_T_LordChaosThing, mapX, mapY, L0548_i_MapX, L0549_i_MapY)) {
+				if (!_vm->_moveSens->f267_getMoveResult(L0555_T_LordChaosThing, mapX, mapY, L0548_i_MapX, L0549_i_MapY)) {
 					f180_startWanedring(L0548_i_MapX, L0549_i_MapY);
 				}
 				return;
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 54ce632..b63717d 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -620,7 +620,7 @@ T0412033:
 				_vm->_championMan->f301_addObjectInSlot((ChampionIndex)champIndex, L1272_T_Object, AL1267_ui_SlotIndex);
 				_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
 			} else {
-				_vm->_movsens->f267_getMoveResult(L1272_T_Object, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+				_vm->_moveSens->f267_getMoveResult(L1272_T_Object, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
 			}
 			break;
 		case k8_spellType_otherFireshield:
@@ -1252,9 +1252,9 @@ T0407032:
 		/* CHANGE6_00_FIX The presence of a group over the pit is checked so that you cannot climb down a pit with the rope if there is a group levitating over it */
 		if ((_vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_ElementTypePit) && (_vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY) == Thing::_endOfList)) {
 			/* BUG0_77 The party moves forward when using the rope in front of a closed pit. The engine does not check whether the pit is open before moving the party over the pit. This is not consistent with the behavior when using the rope in front of a corridor where nothing happens */
-			_vm->_movsens->_g402_useRopeToClimbDownPit = true;
-			_vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1251_i_MapX, L1252_i_MapY);
-			_vm->_movsens->_g402_useRopeToClimbDownPit = false;
+			_vm->_moveSens->_g402_useRopeToClimbDownPit = true;
+			_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1251_i_MapX, L1252_i_MapY);
+			_vm->_moveSens->_g402_useRopeToClimbDownPit = false;
 		} else {
 			L1249_ui_ActionDisabledTicks = 0;
 		}
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 06ba83a..937e144 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -148,7 +148,7 @@ T0217004:
 		L0494_ps_Door = (Door *)_vm->_dungeonMan->f157_getSquareFirstThingData(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY);
 		if ((AL0487_i_DoorState != k5_doorState_DESTROYED) && (L0486_T_ProjectileAssociatedThing == Thing::_explOpenDoor)) {
 			if (L0494_ps_Door->hasButton()) {
-				_vm->_movsens->f268_addEvent(k10_TMEventTypeDoor, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1);
+				_vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1);
 			}
 			break;
 		}
@@ -409,7 +409,7 @@ void ProjExpl::f215_projectileDelete(Thing projectileThing, Thing* groupSlot, in
 				_vm->_dungeonMan->f163_linkThingToList(L0479_T_Thing, L0478_T_PreviousThing, kM1_MapXNotOnASquare, 0);
 			}
 		} else {
-			_vm->_movsens->f267_getMoveResult(Thing((L0479_T_Thing).getTypeAndIndex() | getFlag(projectileThing.toUint16(), 0xC)), -2, 0, mapX, mapY);
+			_vm->_moveSens->f267_getMoveResult(Thing((L0479_T_Thing).getTypeAndIndex() | getFlag(projectileThing.toUint16(), 0xC)), -2, 0, mapX, mapY);
 		}
 	}
 	L0480_ps_Projectile->_nextThing = Thing::_none;
@@ -479,12 +479,12 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 	}
 	L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, L0518_ui_Cell &= 0x0003);
 	if (L0522_B_ProjectileMovesToOtherSquare) {
-		_vm->_movsens->f267_getMoveResult(L0515_T_ProjectileThingNewCell, L0525_i_SourceMapX, L0526_i_SourceMapY, L0523_i_DestinationMapX, L0524_i_DestinationMapY);
-		L0519_ps_Event->_C._projectile.setMapX(_vm->_movsens->_g397_moveResultMapX);
-		L0519_ps_Event->_C._projectile.setMapY(_vm->_movsens->_g398_moveResultMapY);
-		L0519_ps_Event->_C._projectile.setDir((Direction)_vm->_movsens->_g400_moveResultDir);
-		L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_movsens->_g401_moveResultCell);
-		M31_setMap(L0519_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex);
+		_vm->_moveSens->f267_getMoveResult(L0515_T_ProjectileThingNewCell, L0525_i_SourceMapX, L0526_i_SourceMapY, L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+		L0519_ps_Event->_C._projectile.setMapX(_vm->_moveSens->_g397_moveResultMapX);
+		L0519_ps_Event->_C._projectile.setMapY(_vm->_moveSens->_g398_moveResultMapY);
+		L0519_ps_Event->_C._projectile.setDir((Direction)_vm->_moveSens->_g400_moveResultDir);
+		L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_moveSens->_g401_moveResultCell);
+		M31_setMap(L0519_ps_Event->_mapTime, _vm->_moveSens->_g399_moveResultMapIndex);
 	} else {
 		if ((Square(_vm->_dungeonMan->f151_getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY)).getType() == k4_DoorElemType) && f217_projectileHasImpactOccurred(k4_DoorElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
 			return;
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 33bfc61..8baddf0 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -554,11 +554,11 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 
 
 	if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX == _vm->_dungeonMan->_g306_partyMapX) && (mapY == _vm->_dungeonMan->_g307_partyMapY)) {
-		_vm->_movsens->f267_getMoveResult(Thing::_party, mapX, mapY, mapX, mapY);
+		_vm->_moveSens->f267_getMoveResult(Thing::_party, mapX, mapY, mapX, mapY);
 		_vm->_championMan->f296_drawChangedObjectIcons();
 	}
 	if ((L0645_T_Thing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) != Thing::_endOfList) {
-		_vm->_movsens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
+		_vm->_moveSens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
 	}
 	L0645_T_Thing = _vm->_dungeonMan->f162_getSquareFirstObject(mapX, mapY);
 	L0648_T_NextThing = L0645_T_Thing;
@@ -575,24 +575,24 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 		L0648_T_NextThing = _vm->_dungeonMan->f159_getNextThing(L0645_T_Thing);
 		AL0644_ui_ThingType = L0645_T_Thing.getType();
 		if (AL0644_ui_ThingType > k4_GroupThingType) {
-			_vm->_movsens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
+			_vm->_moveSens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
 		}
 		if (AL0644_ui_ThingType == k14_ProjectileThingType) {
 			L0646_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(L0645_T_Thing);
 			L0647_ps_Event = &_vm->_timeline->_g370_events[L0646_ps_Projectile->_eventIndex];
-			L0647_ps_Event->_C._projectile.setMapX(_vm->_movsens->_g397_moveResultMapX);
-			L0647_ps_Event->_C._projectile.setMapY(_vm->_movsens->_g398_moveResultMapY);
-			L0647_ps_Event->_C._projectile.setDir((Direction)_vm->_movsens->_g400_moveResultDir);
-			L0647_ps_Event->_B._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_movsens->_g401_moveResultCell).toUint16();
-			M31_setMap(L0647_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex);
+			L0647_ps_Event->_C._projectile.setMapX(_vm->_moveSens->_g397_moveResultMapX);
+			L0647_ps_Event->_C._projectile.setMapY(_vm->_moveSens->_g398_moveResultMapY);
+			L0647_ps_Event->_C._projectile.setDir((Direction)_vm->_moveSens->_g400_moveResultDir);
+			L0647_ps_Event->_B._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_moveSens->_g401_moveResultCell).toUint16();
+			M31_setMap(L0647_ps_Event->_mapTime, _vm->_moveSens->_g399_moveResultMapIndex);
 		} else {
 			if (AL0644_ui_ThingType == k15_ExplosionThingType) {
 				for (AL0644_ui_EventIndex = 0, L0647_ps_Event = _vm->_timeline->_g370_events; AL0644_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0647_ps_Event++, AL0644_ui_EventIndex++) {
 					if ((L0647_ps_Event->_type == k25_TMEventTypeExplosion) && (L0647_ps_Event->_C._slot == L0645_T_Thing.toUint16())) { /* BUG0_23 A Fluxcage explosion remains on a square forever. If you open a pit or teleporter on a square where there is a Fluxcage explosion, the Fluxcage explosion is moved but the associated event is not updated (because Fluxcage explosions do not use k25_TMEventTypeExplosion but rather k24_TMEventTypeRemoveFluxcage) causing the Fluxcage explosion to remain in the dungeon forever on its destination square. When the k24_TMEventTypeRemoveFluxcage expires the explosion thing is not removed, but it is marked as unused. Consequently, any objects placed on the Fluxcage square after it was moved but before it expires become orphans upon expiration. After expiration, any object placed on the fluxcage square is cloned when picked up */
-						L0647_ps_Event->_B._location._mapX = _vm->_movsens->_g397_moveResultMapX;
-						L0647_ps_Event->_B._location._mapY = _vm->_movsens->_g398_moveResultMapY;
-						L0647_ps_Event->_C._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_movsens->_g401_moveResultCell).toUint16();
-						M31_setMap(L0647_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex);
+						L0647_ps_Event->_B._location._mapX = _vm->_moveSens->_g397_moveResultMapX;
+						L0647_ps_Event->_B._location._mapY = _vm->_moveSens->_g398_moveResultMapY;
+						L0647_ps_Event->_C._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_moveSens->_g401_moveResultCell).toUint16();
+						M31_setMap(L0647_ps_Event->_mapTime, _vm->_moveSens->_g399_moveResultMapIndex);
 					}
 				}
 			}
@@ -661,10 +661,10 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
 						L0638_ps_Sensor->setData(L0637_ui_SensorData);
 						if (L0638_ps_Sensor->getEffectA() == k3_SensorEffHold) {
 							AL0636_B_TriggerSetEffect = ((L0637_ui_SensorData == 0) != L0638_ps_Sensor->getRevertEffectA());
-							_vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
+							_vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
 						} else {
 							if (L0637_ui_SensorData == 0) {
-								_vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
+								_vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
 							}
 						}
 					}
@@ -687,10 +687,10 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
 						L0638_ps_Sensor->setData(L0637_ui_SensorData);
 						AL0636_B_TriggerSetEffect = (Sensor::getDataMask1(L0637_ui_SensorData) == Sensor::getDataMask2(L0637_ui_SensorData)) != L0638_ps_Sensor->getRevertEffectA();
 						if (L0638_ps_Sensor->getEffectA() == k3_SensorEffHold) {
-							_vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
+							_vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
 						} else {
 							if (AL0636_B_TriggerSetEffect) {
-								_vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
+								_vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
 							}
 						}
 					} else {
@@ -713,7 +713,7 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
 		}
 		L0634_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0634_T_Thing);
 	}
-	_vm->_movsens->f271_processRotationEffect();
+	_vm->_moveSens->f271_processRotationEffect();
 }
 
 void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* event) {
@@ -881,7 +881,7 @@ T0252001:
 		if (event->_type == k61_TMEventTypeMoveGroupAudible) {
 			_vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0656_ui_MapX, L0657_ui_MapY, k1_soundModePlayIfPrioritized);
 		}
-		_vm->_movsens->f267_getMoveResult(Thing(event->_C._slot), kM1_MapXNotOnASquare, 0, L0656_ui_MapX, L0657_ui_MapY);
+		_vm->_moveSens->f267_getMoveResult(Thing(event->_C._slot), kM1_MapXNotOnASquare, 0, L0656_ui_MapX, L0657_ui_MapY);
 	} else {
 		if (!L0659_B_RandomDirectionMoveRetried) {
 			L0659_B_RandomDirectionMoveRetried = true;


Commit: a21c6778314a17e56d9faf5c5d6693a63cc634e5
    https://github.com/scummvm/scummvm/commit/a21c6778314a17e56d9faf5c5d6693a63cc634e5
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove useless cast and the associated obsolete comment

Changed paths:
    engines/dm/timeline.cpp



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 8baddf0..33a99c9 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -380,8 +380,7 @@ T0261053:
 }
 
 bool Timeline::f240_isFirstEventExpiered() {
-	warning(false, "possibly dangerous cast to uint32");
-	return (_vm->_timeline->_g372_eventCount && ((uint32)M30_time(_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime));
+	return (_vm->_timeline->_g372_eventCount && (M30_time(_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime));
 }
 
 void Timeline::f239_timelineExtractFirstEvent(TimelineEvent* event) {


Commit: e8e1a54ceadd1d02d860ef750f0b9a44db72e971
    https://github.com/scummvm/scummvm/commit/e8e1a54ceadd1d02d860ef750f0b9a44db72e971
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rename mapTime in dm.cpp

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 5671fc6..cd69479 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -102,16 +102,16 @@ uint16 M21_normalizeModulo4(uint16 val) {
 	return val & 3;
 }
 
-int32 M30_time(int32 map_time) {
-	return map_time & 0x00FFFFFF;
+int32 M30_time(int32 mapTime) {
+	return mapTime & 0x00FFFFFF;
 }
 
-int32 M33_setMapAndTime(int32 &map_time, uint32 map, uint32 time) {
-	return (map_time) = ((time) | (((long)(map)) << 24));
+int32 M33_setMapAndTime(int32 &mapTime, uint32 map, uint32 time) {
+	return (mapTime) = ((time) | (((long)(map)) << 24));
 }
 
-uint16 M29_map(int32 map_time) {
-	return ((uint16)((map_time) >> 24));
+uint16 M29_map(int32 mapTime) {
+	return ((uint16)((mapTime) >> 24));
 }
 
 Thing M15_thingWithNewCell(Thing thing, int16 cell) {


Commit: e0219fd6f7f53c926ba8272b41ad9d00590d40ce
    https://github.com/scummvm/scummvm/commit/e0219fd6f7f53c926ba8272b41ad9d00590d40ce
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f331_applyTimeEffects

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 9b14993..92f23ac 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1511,9 +1511,8 @@ void ChampionMan::f318_dropAllObjects(uint16 champIndex) {
 	uint16 curCell = _vm->_championMan->_gK71_champions[champIndex]._cell;
 	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
 		Thing curThing = f300_getObjectRemovedFromSlot(champIndex, slotDropOrder[slotIndex]);
-		if (curThing != Thing::_none) {
+		if (curThing != Thing::_none)
 			_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(curThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
-		}
 	}
 }
 
@@ -1530,150 +1529,123 @@ void ChampionMan::f323_unpoison(int16 champIndex) {
 }
 
 void ChampionMan::f331_applyTimeEffects() {
-	uint16 L1006_ui_Multiple;
-#define AL1006_ui_GameTime      L1006_ui_Multiple
-#define AL1006_ui_ChampionIndex L1006_ui_Multiple
-	uint16 L1007_ui_Multiple;
-#define AL1007_ui_ScentIndex            L1007_ui_Multiple
-#define AL1007_ui_ManaGain              L1007_ui_Multiple
-#define AL1007_ui_StaminaGainCycleCount L1007_ui_Multiple
-#define AL1007_ui_StatisticIndex        L1007_ui_Multiple
-	uint16 L1008_ui_Multiple;
-#define AL1008_ui_WizardSkillLevel L1008_ui_Multiple
-#define AL1008_ui_Delay            L1008_ui_Multiple
-#define AL1008_ui_StaminaAboveHalf L1008_ui_Multiple
-#define AL1008_ui_StatisticMaximum L1008_ui_Multiple
-	int16 L1009_i_Multiple;
-#define AL1009_i_SkillIndex       L1009_i_Multiple
-#define AL1009_i_StaminaMagnitude L1009_i_Multiple
-#define AL1009_i_StaminaLoss      L1009_i_Multiple
-	Champion* L1010_ps_Champion;
-	unsigned char* L1011_puc_Statistic;
-	uint16 L1012_ui_TimeCriteria;
-	int16 L1013_i_Multiple;
-#define AL1013_i_StaminaAmount L1013_i_Multiple
-#define AL1013_i_HealthGain    L1013_i_Multiple
-	Scent L1014_s_Scent;
-
-
-	if (!_vm->_championMan->_g305_partyChampionCount) {
+	if (!_vm->_championMan->_g305_partyChampionCount)
 		return;
-	}
-	L1014_s_Scent.setMapX(_vm->_dungeonMan->_g306_partyMapX);
-	L1014_s_Scent.setMapY(_vm->_dungeonMan->_g307_partyMapY);
-	L1014_s_Scent.setMapIndex(_vm->_dungeonMan->_g309_partyMapIndex);
-	AL1007_ui_ScentIndex = 0;
-	while ((int16)AL1007_ui_ScentIndex < (int16)(_vm->_championMan->_g407_party._scentCount - 1)) {
-		if (&_vm->_championMan->_g407_party._scents[AL1007_ui_ScentIndex] != &L1014_s_Scent) {
-			if (!(_vm->_championMan->_g407_party._scentStrengths[AL1007_ui_ScentIndex] = MAX(0, _vm->_championMan->_g407_party._scentStrengths[AL1007_ui_ScentIndex] - 1)) && !AL1007_ui_ScentIndex) {
+
+	Scent checkScent;
+	checkScent.setMapX(_vm->_dungeonMan->_g306_partyMapX);
+	checkScent.setMapY(_vm->_dungeonMan->_g307_partyMapY);
+	checkScent.setMapIndex(_vm->_dungeonMan->_g309_partyMapIndex);
+
+	for (byte loopScentIndex = 0; loopScentIndex + 1 < _vm->_championMan->_g407_party._scentCount; loopScentIndex++) {
+		if (&_vm->_championMan->_g407_party._scents[loopScentIndex] != &checkScent) {
+			_vm->_championMan->_g407_party._scentStrengths[loopScentIndex] = MAX(0, _vm->_championMan->_g407_party._scentStrengths[loopScentIndex] - 1);
+			if (!_vm->_championMan->_g407_party._scentStrengths[loopScentIndex] && !loopScentIndex) {
 				f316_deleteScent(0);
 				continue;
 			}
 		}
-		AL1007_ui_ScentIndex++;
 	}
-	AL1006_ui_GameTime = _vm->_g313_gameTime;
-	L1012_ui_TimeCriteria = (((AL1006_ui_GameTime & 0x0080) + ((AL1006_ui_GameTime & 0x0100) >> 2)) + ((AL1006_ui_GameTime & 0x0040) << 2)) >> 2;
-	for (AL1006_ui_ChampionIndex = k0_ChampionFirst, L1010_ps_Champion = _vm->_championMan->_gK71_champions; AL1006_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL1006_ui_ChampionIndex++, L1010_ps_Champion++) {
-		if (L1010_ps_Champion->_currHealth && (_vm->M0_indexToOrdinal(AL1006_ui_ChampionIndex) != _vm->_championMan->_g299_candidateChampionOrdinal)) {
-			if ((L1010_ps_Champion->_currMana < L1010_ps_Champion->_maxMana) && (L1012_ui_TimeCriteria < (L1010_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + (AL1008_ui_WizardSkillLevel = _vm->_championMan->f303_getSkillLevel(AL1006_ui_ChampionIndex, k3_ChampionSkillWizard) + _vm->_championMan->f303_getSkillLevel(AL1006_ui_ChampionIndex, k2_ChampionSkillPriest))))) {
-				AL1007_ui_ManaGain = L1010_ps_Champion->_maxMana / 40;
-				if (_vm->_championMan->_g300_partyIsSleeping) {
-					AL1007_ui_ManaGain = AL1007_ui_ManaGain << 1;
-				}
-				AL1007_ui_ManaGain++;
-				f325_decrementStamina(AL1006_ui_ChampionIndex, AL1007_ui_ManaGain * MAX(7, 16 - AL1008_ui_WizardSkillLevel));
-				L1010_ps_Champion->_currMana += MIN(AL1007_ui_ManaGain, (uint16)(L1010_ps_Champion->_maxMana - L1010_ps_Champion->_currMana));
-			} else {
-				if (L1010_ps_Champion->_currMana > L1010_ps_Champion->_maxMana) {
-					L1010_ps_Champion->_currMana--;
-				}
-			}
-			for (AL1009_i_SkillIndex = k19_ChampionSkillWater; AL1009_i_SkillIndex >= k0_ChampionSkillFighter; AL1009_i_SkillIndex--) {
-				if (L1010_ps_Champion->_skills[AL1009_i_SkillIndex]._temporaryExperience > 0) {
-					L1010_ps_Champion->_skills[AL1009_i_SkillIndex]._temporaryExperience--;
-				}
-			}
-			AL1007_ui_StaminaGainCycleCount = 4;
-			AL1009_i_StaminaMagnitude = L1010_ps_Champion->_maxStamina;
-			while (L1010_ps_Champion->_currStamina < (AL1009_i_StaminaMagnitude >>= 1)) {
-				AL1007_ui_StaminaGainCycleCount += 2;
-			}
-			AL1009_i_StaminaLoss = 0;
-			AL1013_i_StaminaAmount = f26_getBoundedValue(1, (L1010_ps_Champion->_maxStamina >> 8) - 1, 6);
-			if (_vm->_championMan->_g300_partyIsSleeping) {
-				AL1013_i_StaminaAmount <<= 1;
+
+	uint16 gameTime = _vm->_g313_gameTime & 0xFFFF;
+	uint16 timeCriteria = (((gameTime & 0x0080) + ((gameTime & 0x0100) >> 2)) + ((gameTime & 0x0040) << 2)) >> 2;
+	Champion *championPtr = _vm->_championMan->_gK71_champions;
+	for (uint16 championIndex = k0_ChampionFirst; championIndex < _vm->_championMan->_g305_partyChampionCount; championIndex++, championPtr++) {
+		if (championPtr->_currHealth && (_vm->M0_indexToOrdinal(championIndex) != _vm->_championMan->_g299_candidateChampionOrdinal)) {
+			uint16 wizardSkillLevel = _vm->_championMan->f303_getSkillLevel(championIndex, k3_ChampionSkillWizard) + _vm->_championMan->f303_getSkillLevel(championIndex, k2_ChampionSkillPriest);
+			if ((championPtr->_currMana < championPtr->_maxMana)
+			&&  (timeCriteria < championPtr->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + wizardSkillLevel)) {
+				int16 manaGain = championPtr->_maxMana / 40;
+				if (_vm->_championMan->_g300_partyIsSleeping)
+					manaGain <<= 1;
+
+				manaGain++;
+				f325_decrementStamina(championIndex, manaGain * MAX(7, 16 - wizardSkillLevel));
+				championPtr->_currMana += MIN<int16>(manaGain, championPtr->_maxMana - championPtr->_currMana);
+			} else if (championPtr->_currMana > championPtr->_maxMana)
+				championPtr->_currMana--;
+
+			for (int16 idx = k19_ChampionSkillWater; idx >= k0_ChampionSkillFighter; idx--) {
+				if (championPtr->_skills[idx]._temporaryExperience > 0)
+					championPtr->_skills[idx]._temporaryExperience--;
 			}
-			if ((AL1008_ui_Delay = (_vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime)) > 80) {
-				AL1013_i_StaminaAmount++;
-				if (AL1008_ui_Delay > 250) {
-					AL1013_i_StaminaAmount++;
-				}
+			uint16 staminaGainCycleCount = 4;
+			int16 staminaMagnitude = championPtr->_maxStamina;
+			while (championPtr->_currStamina < (staminaMagnitude >>= 1))
+				staminaGainCycleCount += 2;
+
+			int16 staminaLoss = 0;
+			int16 staminaAmount = f26_getBoundedValue(1, (championPtr->_maxStamina >> 8) - 1, 6);
+			if (_vm->_championMan->_g300_partyIsSleeping)
+				staminaAmount <<= 1;
+
+			int32 compDelay = _vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime;
+			if (compDelay > 80) {
+				staminaAmount++;
+				if (compDelay > 250)
+					staminaAmount++;
 			}
 			do {
-				AL1008_ui_StaminaAboveHalf = (AL1007_ui_StaminaGainCycleCount <= 4);
-				if (L1010_ps_Champion->_food < -512) {
-					if (AL1008_ui_StaminaAboveHalf) {
-						AL1009_i_StaminaLoss += AL1013_i_StaminaAmount;
-						L1010_ps_Champion->_food -= 2;
+				bool staminaAboveHalf = (staminaGainCycleCount <= 4);
+				if (championPtr->_food < -512) {
+					if (staminaAboveHalf) {
+						staminaLoss += staminaAmount;
+						championPtr->_food -= 2;
 					}
 				} else {
-					if (L1010_ps_Champion->_food >= 0) {
-						AL1009_i_StaminaLoss -= AL1013_i_StaminaAmount;
-					}
-					L1010_ps_Champion->_food -= AL1008_ui_StaminaAboveHalf ? 2 : AL1007_ui_StaminaGainCycleCount >> 1;
+					if (championPtr->_food >= 0)
+						staminaLoss -= staminaAmount;
+
+					championPtr->_food -= staminaAboveHalf ? 2 : staminaGainCycleCount >> 1;
 				}
-				if (L1010_ps_Champion->_water < -512) {
-					if (AL1008_ui_StaminaAboveHalf) {
-						AL1009_i_StaminaLoss += AL1013_i_StaminaAmount;
-						L1010_ps_Champion->_water -= 1;
+				if (championPtr->_water < -512) {
+					if (staminaAboveHalf) {
+						staminaLoss += staminaAmount;
+						championPtr->_water -= 1;
 					}
 				} else {
-					if (L1010_ps_Champion->_water >= 0) {
-						AL1009_i_StaminaLoss -= AL1013_i_StaminaAmount;
-					}
-					L1010_ps_Champion->_water -= AL1008_ui_StaminaAboveHalf ? 1 : AL1007_ui_StaminaGainCycleCount >> 2;
-				}
-			} while (--AL1007_ui_StaminaGainCycleCount && ((L1010_ps_Champion->_currStamina - AL1009_i_StaminaLoss) < L1010_ps_Champion->_maxStamina));
-			f325_decrementStamina(AL1006_ui_ChampionIndex, AL1009_i_StaminaLoss);
-			if (L1010_ps_Champion->_food < -1024) {
-				L1010_ps_Champion->_food = -1024;
-			}
-			if (L1010_ps_Champion->_water < -1024) {
-				L1010_ps_Champion->_water = -1024;
-			}
-			if ((L1010_ps_Champion->_currHealth < L1010_ps_Champion->_maxHealth) && (L1010_ps_Champion->_currStamina >= (L1010_ps_Champion->_maxStamina >> 2)) && (L1012_ui_TimeCriteria < (L1010_ps_Champion->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] + 12))) {
-				AL1013_i_HealthGain = (L1010_ps_Champion->_maxHealth >> 7) + 1;
-				if (_vm->_championMan->_g300_partyIsSleeping) {
-					AL1013_i_HealthGain <<= 1;
-				}
-				if (_vm->_objectMan->f33_getIconIndex(L1010_ps_Champion->_slots[k10_ChampionSlotNeck]) == k121_IconIndiceJunkEkkhardCross) {
-					AL1013_i_HealthGain += (AL1013_i_HealthGain >> 1) + 1;
+					if (championPtr->_water >= 0)
+						staminaLoss -= staminaAmount;
+
+					championPtr->_water -= staminaAboveHalf ? 1 : staminaGainCycleCount >> 2;
 				}
-				L1010_ps_Champion->_currHealth += MIN(AL1013_i_HealthGain, (int16)(L1010_ps_Champion->_maxHealth - L1010_ps_Champion->_currHealth));
+			} while (--staminaGainCycleCount && ((championPtr->_currStamina - staminaLoss) < championPtr->_maxStamina));
+			f325_decrementStamina(championIndex, staminaLoss);
+			if (championPtr->_food < -1024)
+				championPtr->_food = -1024;
+
+			if (championPtr->_water < -1024)
+				championPtr->_water = -1024;
+
+			if ((championPtr->_currHealth < championPtr->_maxHealth) && (championPtr->_currStamina >= (championPtr->_maxStamina >> 2)) && (timeCriteria < (championPtr->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] + 12))) {
+				int16 healthGain = (championPtr->_maxHealth >> 7) + 1;
+				if (_vm->_championMan->_g300_partyIsSleeping)
+					healthGain <<= 1;
+
+				if (_vm->_objectMan->f33_getIconIndex(championPtr->_slots[k10_ChampionSlotNeck]) == k121_IconIndiceJunkEkkhardCross)
+					healthGain += (healthGain >> 1) + 1;
+
+				championPtr->_currHealth += MIN(healthGain, (int16)(championPtr->_maxHealth - championPtr->_currHealth));
 			}
 			if (!((int)_vm->_g313_gameTime & (_vm->_championMan->_g300_partyIsSleeping ? 63 : 255))) {
-				for (AL1007_ui_StatisticIndex = k0_ChampionStatLuck; AL1007_ui_StatisticIndex <= k6_ChampionStatAntifire; AL1007_ui_StatisticIndex++) {
-					L1011_puc_Statistic = L1010_ps_Champion->_statistics[AL1007_ui_StatisticIndex];
-					AL1008_ui_StatisticMaximum = L1011_puc_Statistic[k0_ChampionStatMaximum];
-					if (L1011_puc_Statistic[k1_ChampionStatCurrent] < AL1008_ui_StatisticMaximum) {
-						L1011_puc_Statistic[k1_ChampionStatCurrent]++;
-					} else {
-						if (L1011_puc_Statistic[k1_ChampionStatCurrent] > AL1008_ui_StatisticMaximum) {
-							L1011_puc_Statistic[k1_ChampionStatCurrent] -= L1011_puc_Statistic[k1_ChampionStatCurrent] / AL1008_ui_StatisticMaximum;
-						}
-					}
+				for (uint16 i = k0_ChampionStatLuck; i <= k6_ChampionStatAntifire; i++) {
+					byte *curStatistic = championPtr->_statistics[i];
+					uint16 statisticMaximum = curStatistic[k0_ChampionStatMaximum];
+					if (curStatistic[k1_ChampionStatCurrent] < statisticMaximum)
+						curStatistic[k1_ChampionStatCurrent]++;
+					else if (curStatistic[k1_ChampionStatCurrent] > statisticMaximum)
+						curStatistic[k1_ChampionStatCurrent] -= curStatistic[k1_ChampionStatCurrent] / statisticMaximum;
 				}
 			}
-			if (!_vm->_championMan->_g300_partyIsSleeping && (L1010_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_g313_gameTime)) {
-				L1010_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
-				L1010_ps_Champion->_maximumDamageReceived = 0;
-				setFlag(L1010_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon);
+			if (!_vm->_championMan->_g300_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_g313_gameTime)) {
+				championPtr->_dir = _vm->_dungeonMan->_g308_partyDir;
+				championPtr->_maximumDamageReceived = 0;
+				setFlag(championPtr->_attributes, k0x0400_ChampionAttributeIcon);
 			}
-			setFlag(L1010_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
-			if (_vm->M0_indexToOrdinal(AL1006_ui_ChampionIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+			setFlag(championPtr->_attributes, k0x0100_ChampionAttributeStatistics);
+			if (_vm->M0_indexToOrdinal(championIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 				if (_vm->_g333_pressingMouth || _vm->_g331_pressingEye || (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
-					setFlag(L1010_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
+					setFlag(championPtr->_attributes, k0x0800_ChampionAttributePanel);
 				}
 			}
 		}


Commit: 42f7f17c099312e45457432d68fc7e5424ed7ff5
    https://github.com/scummvm/scummvm/commit/42f7f17c099312e45457432d68fc7e5424ed7ff5
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix compilation on MSVC9

Changed paths:
    engines/dm/dialog.cpp



diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index d9408fc..71ff8dc 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -36,11 +36,11 @@ namespace DM {
 DialogMan::DialogMan(DMEngine* vm) : _vm(vm) {}
 
 void DialogMan::f427_dialogDraw(char* msg1, char* msg2, char* choice1, char* choice2, char* choice3, char* choice4, bool screenDialog, bool clearScreen, bool fading) {
-	static Box K0068_s_Box1 = {0, 223, 101, 125};
-	static Box K0069_s_Box2 = {0, 223,  76, 100};
-	static Box K0070_s_Box3 = {0, 223,  51,  75};
-	static Box G0469_s_Graphic561_Box_Dialog2ChoicesPatch = {102, 122, 89, 125};
-	static Box G0470_s_Graphic561_Box_Dialog4ChoicesPatch = {102, 122, 62, 97};
+	static Box K0068_s_Box1 = Box(0, 223, 101, 125);
+	static Box K0069_s_Box2 = Box(0, 223,  76, 100);
+	static Box K0070_s_Box3 = Box(0, 223,  51,  75);
+	static Box G0469_s_Graphic561_Box_Dialog2ChoicesPatch = Box(102, 122, 89, 125);
+	static Box G0470_s_Graphic561_Box_Dialog4ChoicesPatch = Box(102, 122, 62, 97);
 
 	int16 L1308_i_X;
 	int16 L1309_i_Y;


Commit: afaaa4d58e8acfa6ad269223d5f8eca91447e0e4
    https://github.com/scummvm/scummvm/commit/afaaa4d58e8acfa6ad269223d5f8eca91447e0e4
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Use error() in f278_resetDataToStartGame

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 92f23ac..508605b 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1787,10 +1787,8 @@ ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
 }
 
 void ChampionMan::f278_resetDataToStartGame() {
-	if (!_vm->_g298_newGame) {
-		warning(false, "MISSING CODE: stuff for resetting for loaded games");
-		assert(false);
-	}
+	if (!_vm->_g298_newGame)
+		error("MISSING CODE: stuff for resetting for loaded games");
 
 	_g414_leaderHandObject = Thing::_none;
 	_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;


Commit: 9fd7c561986357ea539391cb0d4be238b27ac96d
    https://github.com/scummvm/scummvm/commit/9fd7c561986357ea539391cb0d4be238b27ac96d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Finish f433_processCommand140_saveGame

Changed paths:
    engines/dm/dungeonman.h
    engines/dm/loadsave.cpp



diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 95f8a1a..34aef8d 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -650,6 +650,8 @@ public:
 
 class Group;
 
+extern byte g235_ThingDataWordCount[16];
+
 class DungeonMan {
 	DMEngine *_vm;
 
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index a19cef2..86060d5 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -139,6 +139,8 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 
 
 void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String desc) {
+	warning(false, "DUMMY CODE in f433_processCommand140_saveGame, saveAndPlayChoice is always 0");
+	int16 saveAndPlayChoice = 0;
 	char *message = nullptr;
 
 	_menuMan->f456_drawDisabledMenu();
@@ -150,7 +152,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 
 	// F0427_DIALOG_Draw(0, G0551_pc_SAVINGGAME, 0, 0, 0, 0, false, false, false);
 
-	uint16 champHandObjWeight;
+	uint16 champHandObjWeight = 0;
 	if (!_championMan->_g415_leaderEmptyHanded) {
 		champHandObjWeight = _dungeonMan->f140_getObjectWeight(_championMan->_g414_leaderHandObject);
 		_championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load -= champHandObjWeight;
@@ -202,11 +204,81 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 	file->writeSint16BE(_g527_platform);
 	file->writeUint16BE(_g526_dungeonId);
 
-	warning(false, "MISSING CODE in save game");
+	file->writeSint16BE(saveAndPlayChoice);
+
+	// save _g278_dungeonFileHeader
+	{
+		DungeonFileHeader &header = _dungeonMan->_g278_dungeonFileHeader;
+		file->writeUint16BE(header._dungeonId);
+		file->writeUint16BE(header._ornamentRandomSeed);
+		file->writeUint32BE(header._rawMapDataSize);
+		file->writeByte(header._mapCount);
+		file->writeUint16BE(header._textDataWordCount);
+		file->writeUint16BE(header._partyStartDir);
+		file->writeUint16BE(header._partyStartPosX);
+		file->writeUint16BE(header._partyStartPosY);
+		file->writeUint16BE(header._squareFirstThingCount);
+		for (uint16 i = 0; i < 16; ++i)
+			file->writeUint16BE(header._thingCounts[i]);
+	}
+
+	 // save _g277_dungeonMaps
+	for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._mapCount; ++i) {
+		Map &map = _dungeonMan->_g277_dungeonMaps[i];
+		file->writeUint32BE(map._rawDunDataOffset);
+		file->writeByte(map._offsetMapX);
+		file->writeByte(map._offsetMapY);
+		file->writeByte(map._level);
+		file->writeByte(map._width);
+		file->writeByte(map._height);
+		file->writeByte(map._wallOrnCount);
+		file->writeByte(map._randWallOrnCount);
+		file->writeByte(map._floorOrnCount);
+		file->writeByte(map._randFloorOrnCount);
+		file->writeByte(map._doorOrnCount);
+		file->writeByte(map._creatureTypeCount);
+		file->writeByte(map._difficulty);
+		file->writeSint16BE(map._floorSet);
+		file->writeSint16BE(map._wallSet);
+		file->writeByte(map._doorSet0);
+		file->writeByte(map._doorSet1);
+	}
+
+// save _g280_dungeonColumnsCumulativeSquareThingCount
+	for (uint16 i = 0; i < _dungeonMan->_g282_dungeonColumCount; ++i)
+		file->writeUint16BE(_dungeonMan->_g280_dungeonColumnsCumulativeSquareThingCount[i]);
+
+	// save _g283_squareFirstThings
+	for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._squareFirstThingCount; ++i)
+		file->writeUint16BE(_dungeonMan->_g283_squareFirstThings[i].toUint16());
+
+	// save _g260_dungeonTextData
+	for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._textDataWordCount; ++i)
+		file->writeUint16BE(_dungeonMan->_g260_dungeonTextData[i]);
+
+	// save _g284_thingData
+	for (uint16 thingIndex = 0; thingIndex < 16; ++thingIndex)
+		for (uint16 i = 0; i < g235_ThingDataWordCount[thingIndex] * _dungeonMan->_g278_dungeonFileHeader._thingCounts[thingIndex]; ++i)
+			file->writeUint16BE(_dungeonMan->_g284_thingData[thingIndex][i]);
+
+	// save _g276_dungeonRawMapData
+	for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._rawMapDataSize; ++i)
+		file->writeByte(_dungeonMan->_g276_dungeonRawMapData[i]);
 
 	file->flush();
 	file->finalize();
 	delete file;
+
+	if (!saveAndPlayChoice) {
+		_eventMan->f77_hideMouse();
+		warning(false, "MISSING CODE: F0444_STARTEND_Endgame");
+	}
+	if (!_championMan->_g415_leaderEmptyHanded) {
+		_championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load += champHandObjWeight;
+	}
+	_g524_restartGameAllowed = true;
+	_menuMan->f457_drawEnabledMenus();
+	_eventMan->f77_hideMouse();
 }
 
 Common::String DMEngine::getSavefileName(uint16 slot) {


Commit: 715ef2d404994737f72de13fd4824ca1ec1708c1
    https://github.com/scummvm/scummvm/commit/715ef2d404994737f72de13fd4824ca1ec1708c1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Debug loading savegames, add missing save loading parts

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/loadsave.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 508605b..a9cfe7a 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1787,8 +1787,32 @@ ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
 }
 
 void ChampionMan::f278_resetDataToStartGame() {
-	if (!_vm->_g298_newGame)
-		error("MISSING CODE: stuff for resetting for loaded games");
+	if (!_vm->_g298_newGame) {
+		Thing L0787_T_Thing;
+		if ((L0787_T_Thing = _g414_leaderHandObject) == Thing::_none) {
+			_g415_leaderEmptyHanded = true;
+			_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
+			_vm->_eventMan->f69_setMousePointer();
+		} else {
+			f297_putObjectInLeaderHand(L0787_T_Thing, true); /* This call will add the weight of the leader hand object to the Load of the leader a first time */
+		}
+		Champion *L0788_ps_Champion = _gK71_champions;
+		int16 L0785_i_ChampionIndex;
+		for (L0785_i_ChampionIndex = k0_ChampionFirst; L0785_i_ChampionIndex < _g305_partyChampionCount; L0785_i_ChampionIndex++, L0788_ps_Champion++) {
+			clearFlag(L0788_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
+			setFlag(L0788_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
+		}
+		f293_drawAllChampionStates();
+		if ((L0785_i_ChampionIndex = _g411_leaderIndex) != kM1_ChampionNone) {
+			_g411_leaderIndex = kM1_ChampionNone;
+			_vm->_eventMan->f368_commandSetLeader((ChampionIndex)L0785_i_ChampionIndex);
+		}
+		if ((L0785_i_ChampionIndex = _g514_magicCasterChampionIndex) != kM1_ChampionNone) {
+			_g514_magicCasterChampionIndex = kM1_ChampionNone;
+			_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(L0785_i_ChampionIndex);
+		}
+		return;
+	}
 
 	_g414_leaderHandObject = Thing::_none;
 	_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index cd69479..dc778aa 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -277,8 +277,11 @@ void DMEngine::f462_startGame() {
 	f3_processNewPartyMap(_dungeonMan->_g309_partyMapIndex);
 
 	if (!_g298_newGame) {
-		warning(false, "TODO: loading game");
-		assert(false);
+		_displayMan->_g578_useByteBoxCoordinates = false;
+		f22_delay(1);
+		_displayMan->D24_fillScreenBox(g61_boxScreenTop, k0_ColorBlack);
+		_displayMan->D24_fillScreenBox(g62_boxScreenRight, k0_ColorBlack);
+		_displayMan->D24_fillScreenBox(g63_boxScreenBottom, k0_ColorBlack);
 	} else {
 		_displayMan->_g578_useByteBoxCoordinates = false;
 		_displayMan->D24_fillScreenBox(g61_boxScreenTop, k0_ColorBlack);
@@ -331,10 +334,12 @@ Common::Error DMEngine::run() {
 }
 
 void DMEngine::f2_gameloop() {
-	warning(false, "DUMMY CODE: SETTING PARTY POS AND DIRECTION");
-	_dungeonMan->_g306_partyMapX = 9;
-	_dungeonMan->_g307_partyMapY = 9;
-	_dungeonMan->_g308_partyDir = kDirWest;
+	if (_g298_newGame) {
+		warning(false, "DUMMY CODE: SETTING PARTY POS AND DIRECTION");
+		_dungeonMan->_g306_partyMapX = 9;
+		_dungeonMan->_g307_partyMapY = 9;
+		_dungeonMan->_g308_partyDir = kDirWest;
+	}
 
 	_g318_waitForInputMaxVerticalBlankCount = 10;
 	while (true) {
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 38658ce..da7d2da 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -421,6 +421,7 @@ DungeonMan::~DungeonMan() {
 	for (uint16 i = 0; i < 16; ++i) {
 		delete[] _g284_thingData[i];
 	}
+	delete[] _g276_dungeonRawMapData;
 }
 
 void DungeonMan::f455_decompressDungeonFile() {
@@ -535,108 +536,119 @@ const Thing Thing::_explRebirthStep1(0xFFE4); // @ C0xFFE4_THING_EXPLOSION_REBIR
 const Thing Thing::_explRebirthStep2(0xFFE5); // @ C0xFFE5_THING_EXPLOSION_REBIRTH_STEP2    
 const Thing Thing::_party(0xFFFF); // @ C0xFFFF_THING_PARTY          
 
-void DungeonMan::f434_loadDungeonFile() {
-
-	if(!_rawDunFileData)
+void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
+	if (_vm->_g298_newGame)
 		f455_decompressDungeonFile();
 
-	Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO);
+
+	Common::ReadStream *dunDataStream = nullptr;
+	if (file) { // if loading a save 
+		dunDataStream = file;
+	} else { // else read dungeon.dat
+		assert(_rawDunFileData && _rawDunFileDataSize);
+		dunDataStream = new Common::MemoryReadStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO);
+	}
 
 	// initialize _g278_dungeonFileHeader
-	_g278_dungeonFileHeader._dungeonId = _g278_dungeonFileHeader._ornamentRandomSeed = dunDataStream.readUint16BE();
-	_g278_dungeonFileHeader._rawMapDataSize = dunDataStream.readUint16BE();
-	_g278_dungeonFileHeader._mapCount = dunDataStream.readByte();
-	dunDataStream.readByte(); // discard 1 byte
-	_g278_dungeonFileHeader._textDataWordCount = dunDataStream.readUint16BE();
-	uint16 partyPosition = dunDataStream.readUint16BE();
-	_g278_dungeonFileHeader._partyStartDir = (Direction)((partyPosition >> 10) & 3);
-	_g278_dungeonFileHeader._partyStartPosY = (partyPosition >> 5) & 0x1F;
-	_g278_dungeonFileHeader._partyStartPosX = (partyPosition >> 0) & 0x1F;
-	_g278_dungeonFileHeader._squareFirstThingCount = dunDataStream.readUint16BE();
+	_g278_dungeonFileHeader._ornamentRandomSeed = dunDataStream->readUint16BE();
+	_g278_dungeonFileHeader._rawMapDataSize = dunDataStream->readUint16BE();
+	_g278_dungeonFileHeader._mapCount = dunDataStream->readByte();
+	dunDataStream->readByte(); // discard 1 byte
+	_g278_dungeonFileHeader._textDataWordCount = dunDataStream->readUint16BE();
+	_g278_dungeonFileHeader._partyStartLocation = dunDataStream->readUint16BE();
+	_g278_dungeonFileHeader._squareFirstThingCount = dunDataStream->readUint16BE();
 	for (uint16 i = 0; i < k16_ThingTypeTotal; ++i)
-		_g278_dungeonFileHeader._thingCounts[i] = dunDataStream.readUint16BE();
+		_g278_dungeonFileHeader._thingCounts[i] = dunDataStream->readUint16BE();
 
 	// init party position and mapindex
 	if (_vm->_g298_newGame) {
-		_g308_partyDir = _g278_dungeonFileHeader._partyStartDir;
-		_g306_partyMapX = _g278_dungeonFileHeader._partyStartPosX;
-		_g307_partyMapY = _g278_dungeonFileHeader._partyStartPosY;
+		uint16 startLoc = _g278_dungeonFileHeader._partyStartLocation;
+		_g308_partyDir = (Direction)((startLoc >> 10) & 3);
+		_g306_partyMapX = startLoc & 0x1F;
+		_g307_partyMapY = (startLoc >> 5) & 0x1F;
 		_g309_partyMapIndex = 0;
 	}
 
 	// load map data
-	delete[] _g277_dungeonMaps;
-	_g277_dungeonMaps = new Map[_g278_dungeonFileHeader._mapCount];
-	for (uint16 i = 0; i < _g278_dungeonFileHeader._mapCount; ++i) {
-		_g277_dungeonMaps[i]._rawDunDataOffset = dunDataStream.readUint16BE();
-		dunDataStream.readUint32BE(); // discard 4 bytes
-		_g277_dungeonMaps[i]._offsetMapX = dunDataStream.readByte();
-		_g277_dungeonMaps[i]._offsetMapY = dunDataStream.readByte();
+	if (!_vm->_g523_restartGameRequest) {
+		delete[] _g277_dungeonMaps;
+		_g277_dungeonMaps = new Map[_g278_dungeonFileHeader._mapCount];
+	}
 
-		uint16 tmp = dunDataStream.readUint16BE();
+	for (uint16 i = 0; i < _g278_dungeonFileHeader._mapCount; ++i) {
+		_g277_dungeonMaps[i]._rawDunDataOffset = dunDataStream->readUint16BE();
+		dunDataStream->readUint32BE(); // discard 4 bytes
+		_g277_dungeonMaps[i]._offsetMapX = dunDataStream->readByte();
+		_g277_dungeonMaps[i]._offsetMapY = dunDataStream->readByte();
+		
+		uint16 tmp = dunDataStream->readUint16BE();
 		_g277_dungeonMaps[i]._height = tmp >> 11;
 		_g277_dungeonMaps[i]._width = (tmp >> 6) & 0x1F;
-		_g277_dungeonMaps[i]._level = tmp & 0x1F; // Only used in DMII
+		_g277_dungeonMaps[i]._level = tmp & 0x3F; // Only used in DMII
 
-		tmp = dunDataStream.readUint16BE();
+		tmp = dunDataStream->readUint16BE();
 		_g277_dungeonMaps[i]._randFloorOrnCount = tmp >> 12;
 		_g277_dungeonMaps[i]._floorOrnCount = (tmp >> 8) & 0xF;
 		_g277_dungeonMaps[i]._randWallOrnCount = (tmp >> 4) & 0xF;
 		_g277_dungeonMaps[i]._wallOrnCount = tmp & 0xF;
 
-		tmp = dunDataStream.readUint16BE();
+		tmp = dunDataStream->readUint16BE();
 		_g277_dungeonMaps[i]._difficulty = tmp >> 12;
 		_g277_dungeonMaps[i]._creatureTypeCount = (tmp >> 4) & 0xF;
 		_g277_dungeonMaps[i]._doorOrnCount = tmp & 0xF;
 
-		tmp = dunDataStream.readUint16BE();
+		tmp = dunDataStream->readUint16BE();
 		_g277_dungeonMaps[i]._doorSet1 = (tmp >> 12) & 0xF;
 		_g277_dungeonMaps[i]._doorSet0 = (tmp >> 8) & 0xF;
 		_g277_dungeonMaps[i]._wallSet = (WallSet)((tmp >> 4) & 0xF);
 		_g277_dungeonMaps[i]._floorSet = (FloorSet)(tmp & 0xF);
 	}
 
-	// TODO: ??? is this - begin
-	delete[] _g281_dungeonMapsFirstColumnIndex;
-	_g281_dungeonMapsFirstColumnIndex = new uint16[_g278_dungeonFileHeader._mapCount];
+	// load column stuff thingy
+	if (!_vm->_g523_restartGameRequest) {
+		delete[] _g281_dungeonMapsFirstColumnIndex;
+		_g281_dungeonMapsFirstColumnIndex = new uint16[_g278_dungeonFileHeader._mapCount];
+	}
 	uint16 columCount = 0;
 	for (uint16 i = 0; i < _g278_dungeonFileHeader._mapCount; ++i) {
 		_g281_dungeonMapsFirstColumnIndex[i] = columCount;
 		columCount += _g277_dungeonMaps[i]._width + 1;
 	}
 	_g282_dungeonColumCount = columCount;
-	// TODO: ??? is this - end
-
 
 	uint32 actualSquareFirstThingCount = _g278_dungeonFileHeader._squareFirstThingCount;
-	if (_vm->_g298_newGame) // TODO: what purpose does this serve?
+	if (_vm->_g298_newGame)
 		_g278_dungeonFileHeader._squareFirstThingCount += 300;
 
-	// TODO: ??? is this - begin
-	delete[] _g280_dungeonColumnsCumulativeSquareThingCount;
-	_g280_dungeonColumnsCumulativeSquareThingCount = new uint16[columCount];
+	if (!_vm->_g523_restartGameRequest) {
+		delete[] _g280_dungeonColumnsCumulativeSquareThingCount;
+		_g280_dungeonColumnsCumulativeSquareThingCount = new uint16[columCount];
+	}
 	for (uint16 i = 0; i < columCount; ++i)
-		_g280_dungeonColumnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE();
-	// TODO: ??? is this - end
+		_g280_dungeonColumnsCumulativeSquareThingCount[i] = dunDataStream->readUint16BE();
 
-	// TODO: ??? is this - begin
-	delete[] _g283_squareFirstThings;
-	_g283_squareFirstThings = new Thing[_g278_dungeonFileHeader._squareFirstThingCount];
+
+	// load sqaure first things
+	if (!_vm->_g523_restartGameRequest) {
+		delete[] _g283_squareFirstThings;
+		_g283_squareFirstThings = new Thing[_g278_dungeonFileHeader._squareFirstThingCount];
+	}
 	for (uint16 i = 0; i < actualSquareFirstThingCount; ++i)
-		_g283_squareFirstThings[i].set(dunDataStream.readUint16BE());
+		_g283_squareFirstThings[i].set(dunDataStream->readUint16BE());
 	if (_vm->_g298_newGame)
 		for (uint16 i = 0; i < 300; ++i)
 			_g283_squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none;
 
-	// TODO: ??? is this - end
 
 	// load text data
-	delete[] _g260_dungeonTextData;
-	_g260_dungeonTextData = new uint16[_g278_dungeonFileHeader._textDataWordCount];
+	if (!_vm->_g523_restartGameRequest) {
+		delete[] _g260_dungeonTextData;
+		_g260_dungeonTextData = new uint16[_g278_dungeonFileHeader._textDataWordCount];
+	}
 	for (uint16 i = 0; i < _g278_dungeonFileHeader._textDataWordCount; ++i)
-		_g260_dungeonTextData[i] = dunDataStream.readUint16BE();
+		_g260_dungeonTextData[i] = dunDataStream->readUint16BE();
+
 
-	// TODO: ??? what this
 	if (_vm->_g298_newGame)
 		_vm->_timeline->_g369_eventMaxCount = 100;
 
@@ -651,35 +663,26 @@ void DungeonMan::f434_loadDungeonFile() {
 		if (thingStoreWordCount == 0)
 			continue;
 
-		if (_g284_thingData[thingType]) {
+		if (!_vm->_g523_restartGameRequest) {
 			delete[] _g284_thingData[thingType];
+			_g284_thingData[thingType] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount];
 		}
-		_g284_thingData[thingType] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount];
 
-		if (thingType == k4_GroupThingType) {
+		if ((thingType == k4_GroupThingType || thingType == k14_ProjectileThingType) && !file) { // !file because save files have diff. structure than dungeon.dat 
 			for (uint16 i = 0; i < thingCount; ++i) {
 				uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount;
 				for (uint16 j = 0; j < thingStoreWordCount; ++j) {
 					if (j == 2 || j == 3)
-						nextSlot[j] = dunDataStream.readByte();
+						nextSlot[j] = dunDataStream->readByte();
 					else
-						nextSlot[j] = dunDataStream.readUint16BE();
+						nextSlot[j] = dunDataStream->readUint16BE();
 				}
 			}
-		} else if (thingType == k14_ProjectileThingType) {
-			for (uint16 i = 0; i < thingCount; ++i) {
-				uint16 *nextSlot = _g284_thingData[thingType] + i * thingStoreWordCount;
-				nextSlot[0] = dunDataStream.readUint16BE();
-				nextSlot[1] = dunDataStream.readUint16BE();
-				nextSlot[2] = dunDataStream.readByte();
-				nextSlot[3] = dunDataStream.readByte();
-				nextSlot[4] = dunDataStream.readUint16BE();
-			}
 		} else {
 			for (uint16 i = 0; i < thingCount; ++i) {
 				uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount;
 				for (uint16 j = 0; j < thingStoreWordCount; ++j)
-					nextSlot[j] = dunDataStream.readUint16BE();
+					nextSlot[j] = dunDataStream->readUint16BE();
 			}
 		}
 
@@ -693,8 +696,13 @@ void DungeonMan::f434_loadDungeonFile() {
 	}
 
 	// load map data
-	if (!_vm->_g523_restartGameRequest)
-		_g276_dungeonRawMapData = _rawDunFileData + dunDataStream.pos();
+	if (!_vm->_g523_restartGameRequest) {
+		delete[] _g276_dungeonRawMapData;
+		_g276_dungeonRawMapData = new byte[_g278_dungeonFileHeader._rawMapDataSize];
+	}
+
+	for (uint32 i = 0; i < _g278_dungeonFileHeader._rawMapDataSize; ++i)
+		_g276_dungeonRawMapData[i] = dunDataStream->readByte();
 
 
 	if (!_vm->_g523_restartGameRequest) {
@@ -712,6 +720,10 @@ void DungeonMan::f434_loadDungeonFile() {
 			}
 		}
 	}
+
+	if (!file) { // this means that we created a new MemoryReadStream
+		delete file;
+	} // the deletion of the function parameter 'file' happens elsewhere
 }
 
 void DungeonMan::f173_setCurrentMap(uint16 mapIndex) {
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 34aef8d..6fed184 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -605,14 +605,11 @@ public:
 }; // wrapper for bytes which are used as squares
 
 struct DungeonFileHeader {
-	uint16 _dungeonId;
-	// equal to dungeonId
 	uint16 _ornamentRandomSeed;
-	uint32 _rawMapDataSize;
+	uint16 _rawMapDataSize;
 	uint8 _mapCount;
 	uint16 _textDataWordCount;
-	Direction _partyStartDir; // @ InitialPartyLocation
-	uint16 _partyStartPosX, _partyStartPosY;
+	uint16 _partyStartLocation;
 	uint16 _squareFirstThingCount; // @ SquareFirstThingCount
 	uint16 _thingCounts[16]; // @ ThingCount[16]
 }; // @ DUNGEON_HEADER
@@ -681,7 +678,7 @@ public:
 	uint16 *f157_getSquareFirstThingData(int16 mapX, int16 mapY); // @ F0157_DUNGEON_GetSquareFirstThingData
 
 	// TODO: this does stuff other than load the file!
-	void f434_loadDungeonFile();	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
+	void f434_loadDungeonFile(Common::InSaveFile *file);	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
 	void f174_setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap
 
 	bool f149_isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove
@@ -740,7 +737,6 @@ public:
 
 
 	Map *_g277_dungeonMaps; // @ G0277_ps_DungeonMaps
-	// does not have to be freed
 	byte *_g276_dungeonRawMapData; // @ G0276_puc_DungeonRawMapData
 
 	int16 _g265_currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 86060d5..ddacff5 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -42,11 +42,20 @@ namespace DM {
 #define C2_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST 2
 #define C3_PLATFORM_AMIGA 3
 #define C10_DUNGEON_DM 10
+
 LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 	Common::String fileName;
 	Common::SaveFileManager *saveFileManager = nullptr;
 	Common::InSaveFile *file = nullptr;
 
+	struct {
+		int16 _g528_saveFormat = 0;
+		int16 saveAndPlayChoice = 0;
+		int32 _g525_gameId = 0;
+		int16 _g527_platform = 0;
+		uint16 _g526_dungeonId = 0;
+	} dmSaveHeader;
+
 	if (!_g298_newGame) {
 		fileName = getSavefileName(slot);
 		saveFileManager = _system->getSavefileManager();
@@ -69,8 +78,6 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 			goto T0435004;
 		}*/
 
-		warning(false, "DUMMY CODE in f435_loadgame setting _g298_newGame to k1_modeLoadDungeon");
-		_g298_newGame = k1_modeLoadDungeon;
 
 		SaveGameHeader header;
 		readSaveGameHeader(file, &header);
@@ -78,6 +85,14 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		warning(false, "MISSING CODE: missing check for matching format and platform in save in f435_loadgame");
 
 
+		dmSaveHeader._g528_saveFormat = file->readSint16BE();
+		dmSaveHeader.saveAndPlayChoice = file->readSint16BE();
+		dmSaveHeader._g525_gameId = file->readSint32BE();
+		dmSaveHeader._g527_platform = file->readSint16BE();
+		dmSaveHeader._g526_dungeonId = file->readUint16BE();
+
+		_g525_gameId = dmSaveHeader._g525_gameId;
+
 		_g313_gameTime = file->readSint32BE();
 		// G0349_ul_LastRandomNumber = L1371_s_GlobalData.LastRandomNumber;
 		_championMan->_g305_partyChampionCount = file->readUint16BE();
@@ -108,10 +123,14 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		_timeline->load3_eventsPart(file);
 		_timeline->load4_timelinePart(file);
 
-		_g525_gameId = file->readSint32BE();
+		// read sentinel
+		uint32 sentinel = file->readUint32BE();
+		assert(sentinel == 0x6f85e3d3);
 	}
 
-	_dungeonMan->f434_loadDungeonFile();
+	_dungeonMan->f434_loadDungeonFile(file);
+	delete file;
+
 	if (_g298_newGame) {
 		_timeline->f233_initTimeline();
 		_groupMan->f196_initActiveGroups();
@@ -124,16 +143,15 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 			F0436_STARTEND_FadeToPalette(_vm->_displayMan->_g347_paletteTopAndBottomScreen);
 		}*/
 	} else {
-		_g528_saveFormat = file->readSint16BE();
-		_g527_platform = file->readSint16BE();
-		_g526_dungeonId = file->readUint16BE();
+		_g528_saveFormat = dmSaveHeader._g528_saveFormat;
+		_g527_platform = dmSaveHeader._g527_platform;
+		_g526_dungeonId = dmSaveHeader._g526_dungeonId;
 
-		_g524_restartGameAllowed = true;
+			_g524_restartGameAllowed = true;
 		warning(false, "MISSING CDOE: F0427_DIALOG_Draw in f435_loadgame");
 	}
 	_championMan->_g303_partyDead = false;
 
-	delete file;
 	return k1_LoadgameSuccess;
 }
 
@@ -168,6 +186,12 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 
 	writeSaveGameHeader(file, desc);
 
+	file->writeSint16BE(_g528_saveFormat);
+	file->writeSint16BE(saveAndPlayChoice);
+	file->writeSint32BE(_g525_gameId);
+	file->writeSint16BE(_g527_platform);
+	file->writeUint16BE(_g526_dungeonId);
+
 	// write C0_SAVE_PART_GLOBAL_DATA part
 	file->writeSint32BE(_g313_gameTime);
 	//L1348_s_GlobalData.LastRandomNumber = G0349_ul_LastRandomNumber;
@@ -199,24 +223,18 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 	// write C4_SAVE_PART_TIMELINE part
 	_timeline->save4_timelinePart(file);
 
-	file->writeSint32BE(_g525_gameId);
-	file->writeSint16BE(_g528_saveFormat);
-	file->writeSint16BE(_g527_platform);
-	file->writeUint16BE(_g526_dungeonId);
-
-	file->writeSint16BE(saveAndPlayChoice);
+	// write sentinel
+	file->writeUint32BE(0x6f85e3d3);
 
 	// save _g278_dungeonFileHeader
 	{
 		DungeonFileHeader &header = _dungeonMan->_g278_dungeonFileHeader;
-		file->writeUint16BE(header._dungeonId);
 		file->writeUint16BE(header._ornamentRandomSeed);
-		file->writeUint32BE(header._rawMapDataSize);
+		file->writeUint16BE(header._rawMapDataSize);
 		file->writeByte(header._mapCount);
+		file->writeByte(0); // to match the structure of dungeon.dat, will be discarded
 		file->writeUint16BE(header._textDataWordCount);
-		file->writeUint16BE(header._partyStartDir);
-		file->writeUint16BE(header._partyStartPosX);
-		file->writeUint16BE(header._partyStartPosY);
+		file->writeUint16BE(header._partyStartLocation);
 		file->writeUint16BE(header._squareFirstThingCount);
 		for (uint16 i = 0; i < 16; ++i)
 			file->writeUint16BE(header._thingCounts[i]);
@@ -225,23 +243,26 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 	 // save _g277_dungeonMaps
 	for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._mapCount; ++i) {
 		Map &map = _dungeonMan->_g277_dungeonMaps[i];
-		file->writeUint32BE(map._rawDunDataOffset);
+		uint16 tmp;
+
+		file->writeUint16BE(map._rawDunDataOffset);
+		file->writeUint32BE(0); // to match the structure of dungeon.dat, will be discarded
 		file->writeByte(map._offsetMapX);
 		file->writeByte(map._offsetMapY);
-		file->writeByte(map._level);
-		file->writeByte(map._width);
-		file->writeByte(map._height);
-		file->writeByte(map._wallOrnCount);
-		file->writeByte(map._randWallOrnCount);
-		file->writeByte(map._floorOrnCount);
-		file->writeByte(map._randFloorOrnCount);
-		file->writeByte(map._doorOrnCount);
-		file->writeByte(map._creatureTypeCount);
-		file->writeByte(map._difficulty);
-		file->writeSint16BE(map._floorSet);
-		file->writeSint16BE(map._wallSet);
-		file->writeByte(map._doorSet0);
-		file->writeByte(map._doorSet1);
+
+		tmp = ((map._height & 0x1F) << 11) | ((map._width & 0x1F) << 6) | (map._level & 0x3F);
+		file->writeUint16BE(tmp);
+
+		tmp = ((map._randFloorOrnCount & 0xF) << 12) | ((map._floorOrnCount & 0xF) << 8)
+			| ((map._randWallOrnCount & 0xF) << 4) | (map._wallOrnCount & 0xF);
+		file->writeUint16BE(tmp);
+
+		tmp = ((map._difficulty & 0xF) << 12) | ((map._creatureTypeCount & 0xF) << 4) | (map._doorOrnCount & 0xF);
+		file->writeUint16BE(tmp);
+
+		tmp = ((map._doorSet1 & 0xF) << 12) | ((map._doorSet0 & 0xF) << 8) 
+			| ((map._wallSet & 0xF) << 4) | (map._floorSet & 0xF);
+		file->writeUint16BE(tmp);
 	}
 
 // save _g280_dungeonColumnsCumulativeSquareThingCount
@@ -262,7 +283,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 			file->writeUint16BE(_dungeonMan->_g284_thingData[thingIndex][i]);
 
 	// save _g276_dungeonRawMapData
-	for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._rawMapDataSize; ++i)
+	for (uint32 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._rawMapDataSize; ++i)
 		file->writeByte(_dungeonMan->_g276_dungeonRawMapData[i]);
 
 	file->flush();


Commit: 4de7ff5703f9cff9df242aaabf6ac1d88ce4a5c2
    https://github.com/scummvm/scummvm/commit/4de7ff5703f9cff9df242aaabf6ac1d88ce4a5c2
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: First pass of refactoring in f280_addCandidateChampionToParty

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index a9cfe7a..3c8d3a5 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1819,116 +1819,95 @@ void ChampionMan::f278_resetDataToStartGame() {
 	_g415_leaderEmptyHanded = true;
 }
 
-
 void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) {
-	Thing L0793_T_Thing;
-	uint16 L0794_ui_Multiple;
-#define AL0794_ui_ViewCell       L0794_ui_Multiple
-#define AL0794_ui_SlotIndex      L0794_ui_Multiple
-#define AL0794_ui_CharacterIndex L0794_ui_Multiple
-#define AL0794_ui_StatisticIndex L0794_ui_Multiple
-#define AL0794_ui_SkillIndex     L0794_ui_Multiple
-	int16 L0795_i_HiddenSkillIndex;
-	uint16 L0796_ui_Multiple;
-#define AL0796_ui_Character  L0796_ui_Multiple
-#define AL0796_ui_SkillValue L0796_ui_Multiple
-#define AL0796_ui_ThingType  L0796_ui_Multiple
-	Champion* L0797_ps_Champion;
-	char* L0798_pc_Character;
-	uint16 L0799_ui_PreviousPartyChampionCount;
-	uint16 L0800_ui_Multiple;
-#define AL0800_B_ChampionTitleCopied L0800_ui_Multiple
-#define AL0800_ui_HiddenSkillCounter L0800_ui_Multiple
-	uint16 L0801_ui_SlotIndex;
-	int16 L0802_i_MapX;
-	int16 L0803_i_MapY;
-	uint16 L0804_ui_ChampionObjectsCell;
-	int16 L0805_i_ObjectAllowedSlots;
-	int32 L0806_l_BaseSkillExperience;
-	char L0807_ac_DecodedChampionText[77];
-
-	if (!_vm->_championMan->_g415_leaderEmptyHanded) {
+	if (!_vm->_championMan->_g415_leaderEmptyHanded)
 		return;
-	}
-	if (_vm->_championMan->_g305_partyChampionCount == 4) {
+
+	if (_vm->_championMan->_g305_partyChampionCount == 4)
 		return;
-	}
-	L0797_ps_Champion = &_vm->_championMan->_gK71_champions[L0799_ui_PreviousPartyChampionCount = _vm->_championMan->_g305_partyChampionCount];
-	L0797_ps_Champion->resetToZero();
+
+	uint16 previousPartyChampionCount = _vm->_championMan->_g305_partyChampionCount;
+	Champion *championPtr = &_vm->_championMan->_gK71_champions[previousPartyChampionCount];
+	championPtr->resetToZero();
 	// Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portaits could be missing in the data)
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
-	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), L0797_ps_Champion->_portrait, gBoxChampionPortrait, _vm->_championMan->M27_getChampionPortraitX(championPortraitIndex), _vm->_championMan->M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency);
-	L0797_ps_Champion->_actionIndex = k255_ChampionActionNone;
-	L0797_ps_Champion->_enableActionEventIndex = -1;
-	L0797_ps_Champion->_hideDamageReceivedIndex = -1;
-	L0797_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
-	AL0794_ui_ViewCell = k0_ViewCellFronLeft;
-	while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone) {
-		AL0794_ui_ViewCell++;
-	}
-	L0797_ps_Champion->_cell = (ViewCell)M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir);
-	L0797_ps_Champion->_attributes = k0x0400_ChampionAttributeIcon;
-	L0797_ps_Champion->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir;
-	L0797_ps_Champion->_food = 1500 + _vm->getRandomNumber(256);
-	L0797_ps_Champion->_water = 1500 + _vm->getRandomNumber(256);
-	for (AL0794_ui_SlotIndex = k0_ChampionSlotReadyHand; AL0794_ui_SlotIndex < k30_ChampionSlotChest_1; AL0794_ui_SlotIndex++) {
-		L0797_ps_Champion->_slots[AL0794_ui_SlotIndex] = Thing::_none;
-	}
-	L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
-	while ((L0793_T_Thing.getType()) != k2_TextstringType) {
-		L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing);
-	}
-	_vm->_dungeonMan->f168_decodeText(L0798_pc_Character = L0807_ac_DecodedChampionText, L0793_T_Thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
-	AL0794_ui_CharacterIndex = 0;
-	while ((AL0796_ui_Character = *L0798_pc_Character++) != '\n') { /* New line */
-		L0797_ps_Champion->_name[AL0794_ui_CharacterIndex++] = AL0796_ui_Character;
-	}
-	L0797_ps_Champion->_name[AL0794_ui_CharacterIndex] = '\0';
-	AL0794_ui_CharacterIndex = 0;
-	AL0800_B_ChampionTitleCopied = false;
+	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, gBoxChampionPortrait, _vm->_championMan->M27_getChampionPortraitX(championPortraitIndex), _vm->_championMan->M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency);
+	championPtr->_actionIndex = k255_ChampionActionNone;
+	championPtr->_enableActionEventIndex = -1;
+	championPtr->_hideDamageReceivedIndex = -1;
+	championPtr->_dir = _vm->_dungeonMan->_g308_partyDir;
+	uint16 viewCell = k0_ViewCellFronLeft;
+	while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone) {
+		viewCell++;
+	}
+	championPtr->_cell = (ViewCell)M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir);
+	championPtr->_attributes = k0x0400_ChampionAttributeIcon;
+	championPtr->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir;
+	championPtr->_food = 1500 + _vm->getRandomNumber(256);
+	championPtr->_water = 1500 + _vm->getRandomNumber(256);
+	for (int16 slotIdx = k0_ChampionSlotReadyHand; slotIdx < k30_ChampionSlotChest_1; slotIdx++)
+		championPtr->_slots[slotIdx] = Thing::_none;
+
+	Thing curThing = _vm->_dungeonMan->f161_getSquareFirstThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+	while (curThing.getType() != k2_TextstringType)
+		curThing = _vm->_dungeonMan->f159_getNextThing(curThing);
+
+	char L0807_ac_DecodedChampionText[77];
+	char *decodedStringPtr = L0807_ac_DecodedChampionText;
+	_vm->_dungeonMan->f168_decodeText(decodedStringPtr, curThing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
+
+	uint16 charIdx = 0;
+	char tmpChar;
+	while ((tmpChar = *decodedStringPtr++) != '\n') { /* New line */
+		championPtr->_name[charIdx++] = tmpChar;
+	}
+
+	championPtr->_name[charIdx] = '\0';
+	charIdx = 0;
+	bool championTitleCopiedFl = false;
 	for (;;) { /*_Infinite loop_*/
-		AL0796_ui_Character = *L0798_pc_Character++;
-		if (AL0796_ui_Character == '\n') { /* New line */
-			if (AL0800_B_ChampionTitleCopied)
+		tmpChar = *decodedStringPtr++;
+		if (tmpChar == '\n') { /* New line */
+			if (championTitleCopiedFl)
 				break;
-			AL0800_B_ChampionTitleCopied = true;
+			championTitleCopiedFl = true;
 		} else {
-			L0797_ps_Champion->_title[AL0794_ui_CharacterIndex++] = AL0796_ui_Character;
-		}
-	}
-	L0797_ps_Champion->_title[AL0794_ui_CharacterIndex] = '\0';
-	if (*L0798_pc_Character++ == 'M') {
-		setFlag(L0797_ps_Champion->_attributes, k0x0010_ChampionAttributeMale);
-	}
-	L0798_pc_Character++;
-	L0797_ps_Champion->_currHealth = L0797_ps_Champion->_maxHealth = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4);
-	L0798_pc_Character += 4;
-	L0797_ps_Champion->_currStamina = L0797_ps_Champion->_maxStamina = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4);
-	L0798_pc_Character += 4;
-	L0797_ps_Champion->_currMana = L0797_ps_Champion->_maxMana = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4);
-	L0798_pc_Character += 4;
-	L0798_pc_Character++;
-	for (AL0794_ui_StatisticIndex = k0_ChampionStatLuck; AL0794_ui_StatisticIndex <= k6_ChampionStatAntifire; AL0794_ui_StatisticIndex++) {
-		L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k2_ChampionStatMinimum] = 30;
-		L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k1_ChampionStatCurrent] = L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k0_ChampionStatMaximum] = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 2);
-		L0798_pc_Character += 2;
-	}
-	L0797_ps_Champion->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10;
-	L0798_pc_Character++;
-	for (AL0794_ui_SkillIndex = k4_ChampionSkillSwing; AL0794_ui_SkillIndex <= k19_ChampionSkillWater; AL0794_ui_SkillIndex++) {
-		if ((AL0796_ui_SkillValue = *L0798_pc_Character++ - 'A') > 0) {
-			L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = 125L << AL0796_ui_SkillValue;
-		}
-	}
-	for (AL0794_ui_SkillIndex = k0_ChampionSkillFighter; AL0794_ui_SkillIndex <= k3_ChampionSkillWizard; AL0794_ui_SkillIndex++) {
-		L0806_l_BaseSkillExperience = 0;
-		L0795_i_HiddenSkillIndex = (AL0794_ui_SkillIndex + 1) << 2;
-		for (AL0800_ui_HiddenSkillCounter = 0; AL0800_ui_HiddenSkillCounter < 4; AL0800_ui_HiddenSkillCounter++) {
-			L0806_l_BaseSkillExperience += L0797_ps_Champion->_skills[L0795_i_HiddenSkillIndex + AL0800_ui_HiddenSkillCounter]._experience;
-		}
-		L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = L0806_l_BaseSkillExperience;
-	}
-	_vm->_championMan->_g299_candidateChampionOrdinal = L0799_ui_PreviousPartyChampionCount + 1;
+			championPtr->_title[charIdx++] = tmpChar;
+		}
+	}
+	championPtr->_title[charIdx] = '\0';
+	if (*decodedStringPtr++ == 'M') {
+		setFlag(championPtr->_attributes, k0x0010_ChampionAttributeMale);
+	}
+	decodedStringPtr++;
+	championPtr->_currHealth = championPtr->_maxHealth = _vm->_championMan->f279_getDecodedValue(decodedStringPtr, 4);
+	decodedStringPtr += 4;
+	championPtr->_currStamina = championPtr->_maxStamina = _vm->_championMan->f279_getDecodedValue(decodedStringPtr, 4);
+	decodedStringPtr += 4;
+	championPtr->_currMana = championPtr->_maxMana = _vm->_championMan->f279_getDecodedValue(decodedStringPtr, 4);
+	decodedStringPtr += 4;
+	decodedStringPtr++;
+	for (int16 statIdx = k0_ChampionStatLuck; statIdx <= k6_ChampionStatAntifire; statIdx++) {
+		championPtr->_statistics[statIdx][k2_ChampionStatMinimum] = 30;
+		championPtr->_statistics[statIdx][k1_ChampionStatCurrent] = championPtr->_statistics[statIdx][k0_ChampionStatMaximum] = _vm->_championMan->f279_getDecodedValue(decodedStringPtr, 2);
+		decodedStringPtr += 2;
+	}
+	championPtr->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10;
+	decodedStringPtr++;
+	for (uint16 skillIdx = k4_ChampionSkillSwing; skillIdx <= k19_ChampionSkillWater; skillIdx++) {
+		int skillValue = *decodedStringPtr++ - 'A';
+		if (skillValue > 0)
+			championPtr->_skills[skillIdx]._experience = 125L << skillValue;
+	}
+	for (uint16 skillIdx = k0_ChampionSkillFighter; skillIdx <= k3_ChampionSkillWizard; skillIdx++) {
+		int32 baseSkillExperience = 0;
+		int16 hiddenSkillIndex = (skillIdx + 1) << 2;
+		for (uint16 hiddenIdx = 0; hiddenIdx < 4; hiddenIdx++)
+			baseSkillExperience += championPtr->_skills[hiddenSkillIndex + hiddenIdx]._experience;
+
+		championPtr->_skills[skillIdx]._experience = baseSkillExperience;
+	}
+	_vm->_championMan->_g299_candidateChampionOrdinal = previousPartyChampionCount + 1;
 	if (++_vm->_championMan->_g305_partyChampionCount == 1) {
 		_vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst);
 		_vm->_menuMan->_g508_refreshActionArea = true;
@@ -1936,41 +1915,44 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 		_vm->_menuMan->f388_clearActingChampion();
 		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_vm->_championMan->_g305_partyChampionCount - 1));
 	}
-	L0802_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
-	L0803_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
-	L0804_ui_ChampionObjectsCell = returnOppositeDir(_vm->_dungeonMan->_g308_partyDir);
-	L0802_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L0803_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
-	L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0802_i_MapX, L0803_i_MapY);
-	AL0794_ui_SlotIndex = k13_ChampionSlotBackpackLine_1_1;
-	while (L0793_T_Thing != Thing::_endOfList) {
-		if (((AL0796_ui_ThingType = (L0793_T_Thing.getType())) > k3_SensorThingType) && ((L0793_T_Thing.getCell()) == L0804_ui_ChampionObjectsCell)) {
-			L0805_i_ObjectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0793_T_Thing)]._allowedSlots;
-			switch (AL0796_ui_ThingType) {
+
+	int16 curMapX = _vm->_dungeonMan->_g306_partyMapX;
+	int16 curMapY = _vm->_dungeonMan->_g307_partyMapY;
+	uint16 championObjectsCell = returnOppositeDir(_vm->_dungeonMan->_g308_partyDir);
+	curMapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], curMapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+	curThing = _vm->_dungeonMan->f161_getSquareFirstThing(curMapX, curMapY);
+	int16 slotIdx = k13_ChampionSlotBackpackLine_1_1;
+	while (curThing != Thing::_endOfList) {
+		ThingType thingType = curThing.getType();
+		if ((thingType > k3_SensorThingType) && (curThing.getCell() == championObjectsCell)) {
+			int16 objectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(curThing)]._allowedSlots;
+			uint16 curSlotIndex;
+			switch (thingType) {
 			case k6_ArmourThingType:
-				for (L0801_ui_SlotIndex = k2_ChampionSlotHead; L0801_ui_SlotIndex <= k5_ChampionSlotFeet; L0801_ui_SlotIndex++) {
-					if (L0805_i_ObjectAllowedSlots & gSlotMasks[L0801_ui_SlotIndex])
+				for (curSlotIndex = k2_ChampionSlotHead; curSlotIndex <= k5_ChampionSlotFeet; curSlotIndex++) {
+					if (objectAllowedSlots & gSlotMasks[curSlotIndex])
 						goto T0280048;
 				}
-				if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
-					L0801_ui_SlotIndex = k10_ChampionSlotNeck;
+				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
+					curSlotIndex = k10_ChampionSlotNeck;
 				} else {
 					goto T0280046;
 				}
 				break;
 			case k5_WeaponThingType:
-				if (L0797_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) {
-					L0801_ui_SlotIndex = k1_ChampionSlotActionHand;
+				if (championPtr->_slots[k1_ChampionSlotActionHand] == Thing::_none) {
+					curSlotIndex = k1_ChampionSlotActionHand;
 				} else {
 					goto T0280046;
 				}
 				break;
 			case k7_ScrollThingType:
 			case k8_PotionThingType:
-				if (L0797_ps_Champion->_slots[k11_ChampionSlotPouch_1] == Thing::_none) {
-					L0801_ui_SlotIndex = k11_ChampionSlotPouch_1;
+				if (championPtr->_slots[k11_ChampionSlotPouch_1] == Thing::_none) {
+					curSlotIndex = k11_ChampionSlotPouch_1;
 				} else {
-					if (L0797_ps_Champion->_slots[k6_ChampionSlotPouch_2] == Thing::_none) {
-						L0801_ui_SlotIndex = k6_ChampionSlotPouch_2;
+					if (championPtr->_slots[k6_ChampionSlotPouch_2] == Thing::_none) {
+						curSlotIndex = k6_ChampionSlotPouch_2;
 					} else {
 						goto T0280046;
 					}
@@ -1979,21 +1961,21 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 			case k9_ContainerThingType:
 			case k10_JunkThingType:
 T0280046:
-				if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
-					L0801_ui_SlotIndex = k10_ChampionSlotNeck;
+				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
+					curSlotIndex = k10_ChampionSlotNeck;
 				} else {
-					L0801_ui_SlotIndex = AL0794_ui_SlotIndex++;
+					curSlotIndex = slotIdx++;
 				}
 			}
 T0280048:
-			if (L0797_ps_Champion->_slots[L0801_ui_SlotIndex] != Thing::_none) {
+			if (championPtr->_slots[curSlotIndex] != Thing::_none) {
 				goto T0280046;
 			}
-			_vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0799_ui_PreviousPartyChampionCount, L0793_T_Thing, (ChampionSlot)L0801_ui_SlotIndex);
+			_vm->_championMan->f301_addObjectInSlot((ChampionIndex)previousPartyChampionCount, curThing, (ChampionSlot)curSlotIndex);
 		}
-		L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing);
+		curThing = _vm->_dungeonMan->f159_getNextThing(curThing);
 	}
-	_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)L0799_ui_PreviousPartyChampionCount);
+	_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)previousPartyChampionCount);
 	_vm->_menuMan->f456_drawDisabledMenu();;
 }
 


Commit: 698eb12770eae71b2e0f14df36573bf86cb6b62e
    https://github.com/scummvm/scummvm/commit/698eb12770eae71b2e0f14df36573bf86cb6b62e
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rename a variable in f287_drawChampionBarGraphs

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 3c8d3a5..5d1d664 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1982,40 +1982,40 @@ T0280048:
 void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
 	int16 barGraphHeights[3];
 	Champion *champ = &_vm->_championMan->_gK71_champions[champIndex];
-	int16 AL0842_i_BarGraphIndex = 0;
+	int16 barGraphIdx = 0;
 	if (champ->_currHealth > 0) {
 		int32 barGraphHeight = (((int32)champ->_currHealth << 10) * 25) / champ->_maxHealth;
 		if (barGraphHeight & 0x000003FF) {
-			barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10) + 1;
+			barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + 1;
 		} else {
-			barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10);
+			barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10);
 		}
 	} else {
-		barGraphHeights[AL0842_i_BarGraphIndex++] = 0;
+		barGraphHeights[barGraphIdx++] = 0;
 	}
 	if (champ->_currStamina > 0) {
 		int32 barGraphHeight = (((int32)champ->_currStamina << 10) * 25) / champ->_maxStamina;
 		if (barGraphHeight & 0x000003FF) {
-			barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10) + 1;
+			barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + 1;
 		} else {
-			barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10);
+			barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10);
 		}
 	} else {
-		barGraphHeights[AL0842_i_BarGraphIndex++] = 0;
+		barGraphHeights[barGraphIdx++] = 0;
 	}
 	if (champ->_currMana > 0) {
 		if (champ->_currMana > champ->_maxMana) {
-			barGraphHeights[AL0842_i_BarGraphIndex] = 25;
+			barGraphHeights[barGraphIdx] = 25;
 		} else {
 			int32 barGraphHeight = (((int32)champ->_currMana << 10) * 25) / champ->_maxMana;
 			if (barGraphHeight & 0x000003FF) {
-				barGraphHeights[AL0842_i_BarGraphIndex] = (barGraphHeight >> 10) + 1;
+				barGraphHeights[barGraphIdx] = (barGraphHeight >> 10) + 1;
 			} else {
-				barGraphHeights[AL0842_i_BarGraphIndex] = (barGraphHeight >> 10);
+				barGraphHeights[barGraphIdx] = (barGraphHeight >> 10);
 			}
 		}
 	} else {
-		barGraphHeights[AL0842_i_BarGraphIndex] = 0;
+		barGraphHeights[barGraphIdx] = 0;
 	}
 	_vm->_eventMan->f78_showMouse();
 


Commit: 133404c635620fcfb4a0e19c026e97217b4e1374
    https://github.com/scummvm/scummvm/commit/133404c635620fcfb4a0e19c026e97217b4e1374
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix compilation with MSVC9, some light renaming

Changed paths:
    engines/dm/loadsave.cpp
    engines/dm/loadsave.h



diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index ddacff5..7440653 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -49,13 +49,19 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 	Common::InSaveFile *file = nullptr;
 
 	struct {
-		int16 _g528_saveFormat = 0;
-		int16 saveAndPlayChoice = 0;
-		int32 _g525_gameId = 0;
-		int16 _g527_platform = 0;
-		uint16 _g526_dungeonId = 0;
+		int16 _saveFormat;
+		int16 _saveAndPlayChoice;
+		int32 _gameId;
+		int16 _platform;
+		uint16 _dungeonId;
 	} dmSaveHeader;
 
+	dmSaveHeader._saveFormat = 0;
+	dmSaveHeader._saveAndPlayChoice = 0;
+	dmSaveHeader._gameId = 0;
+	dmSaveHeader._platform = 0;
+	dmSaveHeader._dungeonId = 0;
+
 	if (!_g298_newGame) {
 		fileName = getSavefileName(slot);
 		saveFileManager = _system->getSavefileManager();
@@ -85,13 +91,13 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		warning(false, "MISSING CODE: missing check for matching format and platform in save in f435_loadgame");
 
 
-		dmSaveHeader._g528_saveFormat = file->readSint16BE();
-		dmSaveHeader.saveAndPlayChoice = file->readSint16BE();
-		dmSaveHeader._g525_gameId = file->readSint32BE();
-		dmSaveHeader._g527_platform = file->readSint16BE();
-		dmSaveHeader._g526_dungeonId = file->readUint16BE();
+		dmSaveHeader._saveFormat = file->readSint16BE();
+		dmSaveHeader._saveAndPlayChoice = file->readSint16BE();
+		dmSaveHeader._gameId = file->readSint32BE();
+		dmSaveHeader._platform = file->readSint16BE();
+		dmSaveHeader._dungeonId = file->readUint16BE();
 
-		_g525_gameId = dmSaveHeader._g525_gameId;
+		_g525_gameId = dmSaveHeader._gameId;
 
 		_g313_gameTime = file->readSint32BE();
 		// G0349_ul_LastRandomNumber = L1371_s_GlobalData.LastRandomNumber;
@@ -143,9 +149,9 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 			F0436_STARTEND_FadeToPalette(_vm->_displayMan->_g347_paletteTopAndBottomScreen);
 		}*/
 	} else {
-		_g528_saveFormat = dmSaveHeader._g528_saveFormat;
-		_g527_platform = dmSaveHeader._g527_platform;
-		_g526_dungeonId = dmSaveHeader._g526_dungeonId;
+		_g528_saveFormat = dmSaveHeader._saveFormat;
+		_g527_platform = dmSaveHeader._platform;
+		_g526_dungeonId = dmSaveHeader._dungeonId;
 
 			_g524_restartGameAllowed = true;
 		warning(false, "MISSING CDOE: F0427_DIALOG_Draw in f435_loadgame");
diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h
index 85ed8a0..a224966 100644
--- a/engines/dm/loadsave.h
+++ b/engines/dm/loadsave.h
@@ -32,8 +32,6 @@
 
 namespace DM {
 
-;
-
 class LoadsaveMan {
 	DMEngine *_vm;
 public:


Commit: 4b066bf6f54bdb70738e3ce3afaff49556c77b28
    https://github.com/scummvm/scummvm/commit/4b066bf6f54bdb70738e3ce3afaff49556c77b28
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Update todos

Changed paths:
    engines/dm/TODOs/methodtree.txt
    engines/dm/TODOs/todo.txt



diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index f790d50..cbd8d1f 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -1,3 +1,5 @@
+# This file is obsolete
+
 F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 	F0113_DUNGEONVIEW_DrawField // stub method
 		F0133_VIDEO_BlitBoxFilledWithMaskedBitmap // dummy
diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index d416272..e5cca0a 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -9,23 +9,22 @@ Bugs:
 		Drawing door ornaments segfaults when going back to the start
 		Placing one of the play icons from the top right corner into one of the champions' hands will crash the engine
 		Sometimes putting stuff in the player's hand segfaults
-		Footprints are everywhere
 		Object display is a bit mixed up with regards to which cell is it drawn in
-		The last resurrected character can't have stuff in their left hand, segfaults if I try to put stuff into it
+		Method cthulu messes up the callstack
 
 
 Possible bugs:
 	- k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON
 	- possible garbage value return in f140_getObjectWeight
+	- After loading, creatures are in the wrong cells of a square
+
 	
 Todo:
 	Add wiki entry for DM
-	Rename GraphicIndice enum entires and have their name include GraphicIndice
+	
 	I forgot to add localization warnings
-	Attend to Arnaud's notes on github
-	Attend to sev's notes on github
-	Double check enums with hex literals, I think I screwed the regex when processing them
-	Double check strcat, strstr usages, I might have messed them up in many places
+	Double check enums with hex literals
+	Double check strcat, strstr usages
 	I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions
 
 Finish stuff:


Commit: c8ab7843303710b8784a3a6525978fcbd1ea98f0
    https://github.com/scummvm/scummvm/commit/c8ab7843303710b8784a3a6525978fcbd1ea98f0
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Get rid of labels and GOTOs in f280_addCandidateChampionToParty

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 5d1d664..6695611 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1928,48 +1928,60 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 			int16 objectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(curThing)]._allowedSlots;
 			uint16 curSlotIndex;
 			switch (thingType) {
-			case k6_ArmourThingType:
+			case k6_ArmourThingType: {
+				bool skipCheck = false;
 				for (curSlotIndex = k2_ChampionSlotHead; curSlotIndex <= k5_ChampionSlotFeet; curSlotIndex++) {
-					if (objectAllowedSlots & gSlotMasks[curSlotIndex])
-						goto T0280048;
+					if (objectAllowedSlots & gSlotMasks[curSlotIndex]) {
+						skipCheck = true;
+						break;
+					}
 				}
-				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
+
+				if (skipCheck)
+					break;
+
+				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
 					curSlotIndex = k10_ChampionSlotNeck;
-				} else {
-					goto T0280046;
-				}
+				else
+					curSlotIndex = slotIdx++;
+
 				break;
+				}
 			case k5_WeaponThingType:
-				if (championPtr->_slots[k1_ChampionSlotActionHand] == Thing::_none) {
+				if (championPtr->_slots[k1_ChampionSlotActionHand] == Thing::_none)
 					curSlotIndex = k1_ChampionSlotActionHand;
-				} else {
-					goto T0280046;
-				}
+				else if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
+					curSlotIndex = k10_ChampionSlotNeck;
+				else
+					curSlotIndex = slotIdx++;
 				break;
 			case k7_ScrollThingType:
 			case k8_PotionThingType:
-				if (championPtr->_slots[k11_ChampionSlotPouch_1] == Thing::_none) {
+				if (championPtr->_slots[k11_ChampionSlotPouch_1] == Thing::_none)
 					curSlotIndex = k11_ChampionSlotPouch_1;
-				} else {
-					if (championPtr->_slots[k6_ChampionSlotPouch_2] == Thing::_none) {
-						curSlotIndex = k6_ChampionSlotPouch_2;
-					} else {
-						goto T0280046;
-					}
-				}
+				else if (championPtr->_slots[k6_ChampionSlotPouch_2] == Thing::_none)
+					curSlotIndex = k6_ChampionSlotPouch_2;
+				else if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
+					curSlotIndex = k10_ChampionSlotNeck;
+				else
+					curSlotIndex = slotIdx++;
 				break;
 			case k9_ContainerThingType:
 			case k10_JunkThingType:
-T0280046:
-				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
+				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
 					curSlotIndex = k10_ChampionSlotNeck;
-				} else {
+				else
 					curSlotIndex = slotIdx++;
-				}
+
+				break;
+			default:break;
 			}
-T0280048:
-			if (championPtr->_slots[curSlotIndex] != Thing::_none) {
-				goto T0280046;
+
+			while (championPtr->_slots[curSlotIndex] != Thing::_none) {
+				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
+					curSlotIndex = k10_ChampionSlotNeck;
+				else
+					curSlotIndex = slotIdx++;
 			}
 			_vm->_championMan->f301_addObjectInSlot((ChampionIndex)previousPartyChampionCount, curThing, (ChampionSlot)curSlotIndex);
 		}
@@ -2059,12 +2071,12 @@ uint16 ChampionMan::f309_getMaximumLoad(Champion *champ) {
 	uint16 maximumLoad = champ->getStatistic(k1_ChampionStatStrength, k1_ChampionStatCurrent) * 8 + 100;
 	maximumLoad = f306_getStaminaAdjustedValue(champ, maximumLoad);
 	int16 wounds = champ->getWounds();
-	if (wounds) {
+	if (wounds)
 		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(k0x0010_ChampionWoundLegs) ? 2 : 3);
-	}
-	if (_vm->_objectMan->f33_getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == k119_IconIndiceArmourElvenBoots) {
+
+	if (_vm->_objectMan->f33_getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == k119_IconIndiceArmourElvenBoots)
 		maximumLoad += maximumLoad * 16;
-	}
+
 	maximumLoad += 9;
 	maximumLoad -= maximumLoad % 10;
 	return maximumLoad;


Commit: dfc2d7e769ef16db0a86b889e02b0fb6d37ccaf6
    https://github.com/scummvm/scummvm/commit/dfc2d7e769ef16db0a86b889e02b0fb6d37ccaf6
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix broken champion action hand slots

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/eventman.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index e5cca0a..b2bac2a 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -3,12 +3,12 @@ Bugs:
 		Broken colour palette
 		Portraits, alcoves etc. look broken from afar
 		Arrow and hand display is messed up
+		Items are displayed in the wrong cells
+		Levers look the same after pulling them
 
 	Logic:
 		When object are put on the right side of the current square, they disappear
 		Drawing door ornaments segfaults when going back to the start
-		Placing one of the play icons from the top right corner into one of the champions' hands will crash the engine
-		Sometimes putting stuff in the player's hand segfaults
 		Object display is a bit mixed up with regards to which cell is it drawn in
 		Method cthulu messes up the callstack
 
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 7ccf647..ec25758 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1149,7 +1149,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 		champ->resetSkillsToZero();
 
 		for (uint16 i = 0; i < 12; i++) {
-			uint16 statIndex = _vm->_rnd->getRandomNumber(7);
+			uint16 statIndex = _vm->getRandomNumber(7);
 			champ->getStatistic((ChampionStatisticType)statIndex, k1_ChampionStatCurrent)++; // returns reference
 			champ->getStatistic((ChampionStatisticType)statIndex, k0_ChampionStatMaximum)++; // returns reference
 		}


Commit: f0a916197a6776ea5af733f2b0bdb2a0c731a19b
    https://github.com/scummvm/scummvm/commit/f0a916197a6776ea5af733f2b0bdb2a0c731a19b
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Use ternary operator in f287_drawChampionBarGraphs to reduce code duplication

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 6695611..4b9809d 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1974,7 +1974,8 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 					curSlotIndex = slotIdx++;
 
 				break;
-			default:break;
+			default:
+				break;
 			}
 
 			while (championPtr->_slots[curSlotIndex] != Thing::_none) {
@@ -1997,34 +1998,22 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
 	int16 barGraphIdx = 0;
 	if (champ->_currHealth > 0) {
 		int32 barGraphHeight = (((int32)champ->_currHealth << 10) * 25) / champ->_maxHealth;
-		if (barGraphHeight & 0x000003FF) {
-			barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + 1;
-		} else {
-			barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10);
-		}
-	} else {
+		barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + (barGraphHeight & 0x000003FF) ? 1 : 0;
+	} else
 		barGraphHeights[barGraphIdx++] = 0;
-	}
+
 	if (champ->_currStamina > 0) {
 		int32 barGraphHeight = (((int32)champ->_currStamina << 10) * 25) / champ->_maxStamina;
-		if (barGraphHeight & 0x000003FF) {
-			barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + 1;
-		} else {
-			barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10);
-		}
-	} else {
+		barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + (barGraphHeight & 0x000003FF) ? 1 : 0;
+	} else
 		barGraphHeights[barGraphIdx++] = 0;
-	}
+
 	if (champ->_currMana > 0) {
-		if (champ->_currMana > champ->_maxMana) {
+		if (champ->_currMana > champ->_maxMana)
 			barGraphHeights[barGraphIdx] = 25;
-		} else {
+		else {
 			int32 barGraphHeight = (((int32)champ->_currMana << 10) * 25) / champ->_maxMana;
-			if (barGraphHeight & 0x000003FF) {
-				barGraphHeights[barGraphIdx] = (barGraphHeight >> 10) + 1;
-			} else {
-				barGraphHeights[barGraphIdx] = (barGraphHeight >> 10);
-			}
+			barGraphHeights[barGraphIdx] = (barGraphHeight >> 10) + (barGraphHeight & 0x000003FF) ? 1 : 0;
 		}
 	} else {
 		barGraphHeights[barGraphIdx] = 0;


Commit: 700c4327d3f957a839bfc4dbb4f425f163553d1c
    https://github.com/scummvm/scummvm/commit/700c4327d3f957a839bfc4dbb4f425f163553d1c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Move DMEngine::_rnd to private, fix erroneous ranges with random number generations

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/champion.cpp
    engines/dm/dm.h
    engines/dm/gfx.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index b2bac2a..65e7251 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -8,9 +8,8 @@ Bugs:
 
 	Logic:
 		When object are put on the right side of the current square, they disappear
-		Drawing door ornaments segfaults when going back to the start
 		Object display is a bit mixed up with regards to which cell is it drawn in
-		Method cthulu messes up the callstack
+
 
 
 Possible bugs:
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 4b9809d..a7d27d1 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -207,8 +207,8 @@ bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16
 	f304_addSkillExperience(champIndex, k10_ChampionSkillThrow, experience);
 	kineticEnergy += weaponKineticEnergy;
 	int16 skillLevel = f303_getSkillLevel((ChampionIndex)champIndex, k10_ChampionSkillThrow);
-	kineticEnergy += _vm->_rnd->getRandomNumber(16) + (kineticEnergy >> 1) + skillLevel;
-	int16 attack = f26_getBoundedValue((uint16)40, (uint16)((skillLevel << 3) + _vm->_rnd->getRandomNumber(31)), (uint16)200);
+	kineticEnergy += _vm->getRandomNumber(16) + (kineticEnergy >> 1) + skillLevel;
+	int16 attack = f26_getBoundedValue((uint16)40, (uint16)((skillLevel << 3) + _vm->getRandomNumber(32)), (uint16)200);
 	int16 stepEnergy = MAX(5, 11 - skillLevel);
 	_vm->_projexpl->f212_projectileCreate(curThing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY,
 										  M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + side),
@@ -595,7 +595,7 @@ Thing ChampionMan::f298_getObjectRemovedFromLeaderHand() {
 
 uint16 ChampionMan::f312_getStrength(int16 champIndex, int16 slotIndex) {
 	Champion *curChampion = &_gK71_champions[champIndex];
-	int16 strength = _vm->_rnd->getRandomNumber(15) + curChampion->_statistics[k1_ChampionStatStrength][k1_ChampionStatCurrent];
+	int16 strength = _vm->getRandomNumber(16) + curChampion->_statistics[k1_ChampionStatStrength][k1_ChampionStatCurrent];
 	Thing curThing = curChampion->_slots[slotIndex];
 	uint16 objectWeight = _vm->_dungeonMan->f140_getObjectWeight(curThing);
 	uint16 oneSixteenthMaximumLoad = f309_getMaximumLoad(curChampion) >> 4;
@@ -791,7 +791,7 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 		if (attack <= 0)
 			return 0;
 
-		int16 adjustedAttack = f307_getStatisticAdjustedAttack(curChampion, k4_ChampionStatVitality, _vm->_rnd->getRandomNumber(127) + 10);
+		int16 adjustedAttack = f307_getStatisticAdjustedAttack(curChampion, k4_ChampionStatVitality, _vm->getRandomNumber(128) + 10);
 		if (attack > adjustedAttack) {
 		/* BUG0_45
 			This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the
@@ -801,7 +801,7 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 			wounded (because of more iterations in the loop below)
 		*/
 			do {
-				setFlag(*(uint16 *)&_g410_championPendingWounds[champIndex], (1 << _vm->_rnd->getRandomNumber(7)) & allowedWounds);
+				setFlag(*(uint16 *)&_g410_championPendingWounds[champIndex], (1 << _vm->getRandomNumber(8)) & allowedWounds);
 			} while ((attack > (adjustedAttack <<= 1)) && adjustedAttack);
 		}
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 7d2f925..007f22c 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -230,8 +230,8 @@ private:
 	Console *_console;
 	byte *_g562_entranceDoorAnimSteps[10]; // @ G0562_apuc_Bitmap_EntranceDoorAnimationSteps
 	byte *_g564_interfaceCredits; // @ G0564_puc_Graphic5_InterfaceCredits
-public:
 	Common::RandomSource *_rnd;
+public:
 	DisplayMan *_displayMan;
 	DungeonMan *_dungeonMan;
 	EventManager *_eventMan;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index d264bf1..eb9012e 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1346,10 +1346,10 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d
 		memmove(_g74_tmpBitmap, f489_getNativeBitmapOrGraphic(doorNativeBitmapIndices[doorType = door->getType()]), byteCount * 2);
 		f109_drawDoorOrnament(door->getOrnOrdinal(), viewDoorOrnIndex);
 		if (getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[doorType]._attributes, k0x0004_MaskDoorInfo_Animated)) {
-			if (_vm->_rnd->getRandomNumber(1)) {
+			if (_vm->getRandomNumber(2)) {
 				f130_flipBitmapHorizontal(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
 			}
-			if (_vm->_rnd->getRandomNumber(1)) {
+			if (_vm->getRandomNumber(2)) {
 				f131_flipVertical(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
 			}
 		}
@@ -3632,7 +3632,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
 				f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, nullptr, f492_getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C,
-												   _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64),
+												   _vm->getRandomNumber(4) + 87, _vm->getRandomNumber(64),
 												   224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
 				warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
 				warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
@@ -3655,9 +3655,9 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 				}
 				AL_6_bitmapRedBanana = f114_getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle);
 T0115200_DrawExplosion:
-				flipVertical = _vm->_rnd->getRandomNumber(2);
+				flipVertical = _vm->getRandomNumber(2);
 				paddingPixelCount = 0;
-				if (flipHorizontal = _vm->_rnd->getRandomNumber(2)) {
+				if (flipHorizontal = _vm->getRandomNumber(2)) {
 					paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1; /* Number of unused pixels in the units on the right of the bitmap */
 				}
 				boxByteGreen._y2 = MIN(135, explosionCoordinates[1] + (heightRedEagle >> 1));


Commit: 111d5ddc3836e9fb6f94a42bb76ae1db4bcfef59
    https://github.com/scummvm/scummvm/commit/111d5ddc3836e9fb6f94a42bb76ae1db4bcfef59
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix champion bargraphs

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/champion.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 65e7251..1ef449d 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -9,7 +9,8 @@ Bugs:
 	Logic:
 		When object are put on the right side of the current square, they disappear
 		Object display is a bit mixed up with regards to which cell is it drawn in
-
+		Method cthulu messes up the callstack sometimes
+		
 
 
 Possible bugs:
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index a7d27d1..b600f28 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1998,13 +1998,13 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
 	int16 barGraphIdx = 0;
 	if (champ->_currHealth > 0) {
 		int32 barGraphHeight = (((int32)champ->_currHealth << 10) * 25) / champ->_maxHealth;
-		barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + (barGraphHeight & 0x000003FF) ? 1 : 0;
+		barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + ((barGraphHeight & 0x000003FF) ? 1 : 0);
 	} else
 		barGraphHeights[barGraphIdx++] = 0;
 
 	if (champ->_currStamina > 0) {
 		int32 barGraphHeight = (((int32)champ->_currStamina << 10) * 25) / champ->_maxStamina;
-		barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + (barGraphHeight & 0x000003FF) ? 1 : 0;
+		barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + ((barGraphHeight & 0x000003FF) ? 1 : 0);
 	} else
 		barGraphHeights[barGraphIdx++] = 0;
 
@@ -2013,7 +2013,7 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
 			barGraphHeights[barGraphIdx] = 25;
 		else {
 			int32 barGraphHeight = (((int32)champ->_currMana << 10) * 25) / champ->_maxMana;
-			barGraphHeights[barGraphIdx] = (barGraphHeight >> 10) + (barGraphHeight & 0x000003FF) ? 1 : 0;
+			barGraphHeights[barGraphIdx] = (barGraphHeight >> 10) + ((barGraphHeight & 0x000003FF) ? 1 : 0);
 		}
 	} else {
 		barGraphHeights[barGraphIdx] = 0;


Commit: 571a6b7a07e60468516318286cf733a7de948f1b
    https://github.com/scummvm/scummvm/commit/571a6b7a07e60468516318286cf733a7de948f1b
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactoring of f292_drawChampionState, including removing its GOTOs

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index b600f28..2db6481 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1829,7 +1829,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 	uint16 previousPartyChampionCount = _vm->_championMan->_g305_partyChampionCount;
 	Champion *championPtr = &_vm->_championMan->_gK71_champions[previousPartyChampionCount];
 	championPtr->resetToZero();
-	// Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portaits could be missing in the data)
+	// Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portraits could be missing in the data)
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
 	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, gBoxChampionPortrait, _vm->_championMan->M27_getChampionPortraitX(championPortraitIndex), _vm->_championMan->M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency);
 	championPtr->_actionIndex = k255_ChampionActionNone;
@@ -1837,9 +1837,9 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 	championPtr->_hideDamageReceivedIndex = -1;
 	championPtr->_dir = _vm->_dungeonMan->_g308_partyDir;
 	uint16 viewCell = k0_ViewCellFronLeft;
-	while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone) {
+	while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone)
 		viewCell++;
-	}
+
 	championPtr->_cell = (ViewCell)M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir);
 	championPtr->_attributes = k0x0400_ChampionAttributeIcon;
 	championPtr->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir;
@@ -1858,9 +1858,8 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 
 	uint16 charIdx = 0;
 	char tmpChar;
-	while ((tmpChar = *decodedStringPtr++) != '\n') { /* New line */
+	while ((tmpChar = *decodedStringPtr++) != '\n')
 		championPtr->_name[charIdx++] = tmpChar;
-	}
 
 	championPtr->_name[charIdx] = '\0';
 	charIdx = 0;
@@ -1871,14 +1870,13 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 			if (championTitleCopiedFl)
 				break;
 			championTitleCopiedFl = true;
-		} else {
+		} else
 			championPtr->_title[charIdx++] = tmpChar;
-		}
 	}
 	championPtr->_title[charIdx] = '\0';
-	if (*decodedStringPtr++ == 'M') {
+	if (*decodedStringPtr++ == 'M')
 		setFlag(championPtr->_attributes, k0x0010_ChampionAttributeMale);
-	}
+
 	decodedStringPtr++;
 	championPtr->_currHealth = championPtr->_maxHealth = _vm->_championMan->f279_getDecodedValue(decodedStringPtr, 4);
 	decodedStringPtr += 4;
@@ -2072,174 +2070,161 @@ uint16 ChampionMan::f309_getMaximumLoad(Champion *champ) {
 }
 
 void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
-	uint16 L0862_ui_ChampionAttributes;
-	bool L0863_B_IsInventoryChampion;
-	int16 L0864_i_Multiple;
-#define AL0864_i_BorderCount       L0864_i_Multiple
-#define AL0864_i_ColorIndex        L0864_i_Multiple
-#define AL0864_i_Load              L0864_i_Multiple
-#define AL0864_i_ChampionIconIndex L0864_i_Multiple
-#define AL0864_i_StatisticIndex    L0864_i_Multiple
-#define AL0864_i_SlotIndex         L0864_i_Multiple
-	Champion* L0865_ps_Champion;
-	char* L0866_pc_ChampionName;
-	char L0867_c_ChampionTitleFirstCharacter;
-	int16 L0868_i_ChampionStatusBoxX;
-	int16 L0869_i_ChampionTitleX;
-	int16 L0870_i_Multiple;
-#define AL0870_i_NativeBitmapIndex L0870_i_Multiple
-#define AL0870_i_Color             L0870_i_Multiple
-	Box L0871_s_Box;
-	int16 L0872_ai_NativeBitmapIndices[3];
-
-
-	L0868_i_ChampionStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
-	L0865_ps_Champion = &_gK71_champions[champIndex];
-	L0862_ui_ChampionAttributes = L0865_ps_Champion->_attributes;
-	if (!getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand)) {
+	int16 championStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
+	Champion *curChampion = &_gK71_champions[champIndex];
+	uint16 championAttributes = curChampion->_attributes;
+	if (!getFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand))
 		return;
-	}
-	L0863_B_IsInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+
+	bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	_vm->_eventMan->f78_showMouse();
-	if (getFlag(L0862_ui_ChampionAttributes, k0x1000_ChampionAttributeStatusBox)) {
-		L0871_s_Box._y1 = 0;
-		L0871_s_Box._y2 = 28;
-		L0871_s_Box._x2 = (L0871_s_Box._x1 = L0868_i_ChampionStatusBoxX) + 66;
-		if (L0865_ps_Champion->_currHealth) {
-			_vm->_displayMan->D24_fillScreenBox(L0871_s_Box, k12_ColorDarkestGray);
+	if (getFlag(championAttributes, k0x1000_ChampionAttributeStatusBox)) {
+		Box box;
+		box._y1 = 0;
+		box._y2 = 28;
+		box._x1 = championStatusBoxX;
+		box._x2 = box._x1 + 66;
+		if (curChampion->_currHealth) {
+			_vm->_displayMan->D24_fillScreenBox(box, k12_ColorDarkestGray);
+			int16 nativeBitmapIndices[3];
 			for (uint16 i = 0; i < 3; ++i)
-				L0872_ai_NativeBitmapIndices[i] = 0;
-			AL0864_i_BorderCount = 0;
-			if (_g407_party._fireShieldDefense > 0) {
-				L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k38_BorderPartyFireshieldIndice;
-			}
-			if (_g407_party._spellShieldDefense > 0) {
-				L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k39_BorderPartySpellshieldIndice;
-			}
-			if ((_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) {
-				L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k37_BorderPartyShieldIndice;
-			}
-			while (AL0864_i_BorderCount--) {
-				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount]), &L0871_s_Box, k40_byteWidth, k10_ColorFlesh, 29);
-			}
-			if (L0863_B_IsInventoryChampion) {
+				nativeBitmapIndices[i] = 0;
+
+			uint16 borderCount = 0;
+			if (_g407_party._fireShieldDefense > 0)
+				nativeBitmapIndices[borderCount++] = k38_BorderPartyFireshieldIndice;
+
+			if (_g407_party._spellShieldDefense > 0)
+				nativeBitmapIndices[borderCount++] = k39_BorderPartySpellshieldIndice;
+
+			if ((_g407_party._shieldDefense > 0) || curChampion->_shieldDefense)
+				nativeBitmapIndices[borderCount++] = k37_BorderPartyShieldIndice;
+
+			while (borderCount--)
+				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndices[borderCount]), &box, k40_byteWidth, k10_ColorFlesh, 29);
+
+			if (isInventoryChampion) {
 				_vm->_inventoryMan->f354_drawStatusBoxPortrait(champIndex);
-				setFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics);
-			} else {
-				setFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand);
-			}
+				setFlag(championAttributes, k0x0100_ChampionAttributeStatistics);
+			} else
+				setFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand);
 		} else {
-			_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), &L0871_s_Box, k40_byteWidth, kM1_ColorNoTransparency, 29);
-			_vm->_textMan->f53_printToLogicalScreen(L0868_i_ChampionStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, L0865_ps_Champion->_name);
+			_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), &box, k40_byteWidth, kM1_ColorNoTransparency, 29);
+			_vm->_textMan->f53_printToLogicalScreen(championStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, curChampion->_name);
 			_vm->_menuMan->f386_drawActionIcon(champIndex);
-			goto T0292042;
+
+			clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
+			_vm->_eventMan->f77_hideMouse();
+			return;
 		}
 	}
-	if (!(L0865_ps_Champion->_currHealth))
-		goto T0292042;
-	if (getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle)) {
-		AL0864_i_ColorIndex = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
-		if (L0863_B_IsInventoryChampion) {
-			_vm->_textMan->f52_printToViewport(3, 7, (Color)AL0864_i_ColorIndex, L0866_pc_ChampionName = L0865_ps_Champion->_name);
-			L0869_i_ChampionTitleX = 6 * strlen(L0866_pc_ChampionName) + 3;
-			L0867_c_ChampionTitleFirstCharacter = L0865_ps_Champion->_title[0];
-			if ((L0867_c_ChampionTitleFirstCharacter != ',') && (L0867_c_ChampionTitleFirstCharacter != ';') && (L0867_c_ChampionTitleFirstCharacter != '-')) {
-				L0869_i_ChampionTitleX += 6;
-			}
-			_vm->_textMan->f52_printToViewport(L0869_i_ChampionTitleX, 7, (Color)AL0864_i_ColorIndex, L0865_ps_Champion->_title);
-			setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
+	if (!(curChampion->_currHealth)) {
+		clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
+		_vm->_eventMan->f77_hideMouse();
+		return;
+	}
+
+	if (getFlag(championAttributes, k0x0080_ChampionAttributeNameTitle)) {
+		Color nameColor = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
+		if (isInventoryChampion) {
+			char *championName = curChampion->_name;
+			_vm->_textMan->f52_printToViewport(3, 7, nameColor, championName);
+			int16 championTitleX = 6 * strlen(championName) + 3;
+			char titleFirstCharacter = curChampion->_title[0];
+			if ((titleFirstCharacter != ',') && (titleFirstCharacter != ';') && (titleFirstCharacter != '-'))
+				championTitleX += 6;
+
+			_vm->_textMan->f52_printToViewport(championTitleX, 7, nameColor, curChampion->_title);
+			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 		} else {
-			L0871_s_Box._y1 = 0;
-			L0871_s_Box._y2 = 6;
-			L0871_s_Box._x2 = (L0871_s_Box._x1 = L0868_i_ChampionStatusBoxX) + 42;
-			_vm->_displayMan->D24_fillScreenBox(L0871_s_Box, k1_ColorDarkGary);
-			_vm->_textMan->f53_printToLogicalScreen(L0868_i_ChampionStatusBoxX + 1, 5, (Color)AL0864_i_ColorIndex, k1_ColorDarkGary, L0865_ps_Champion->_name);
+			Box box;
+			box._y1 = 0;
+			box._y2 = 6;
+			box._x1 = championStatusBoxX;
+			box._x2 = box._x1 + 42;
+			_vm->_displayMan->D24_fillScreenBox(box, k1_ColorDarkGary);
+			_vm->_textMan->f53_printToLogicalScreen(championStatusBoxX + 1, 5, nameColor, k1_ColorDarkGary, curChampion->_name);
 		}
 	}
-	if (getFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics)) {
+	if (getFlag(championAttributes, k0x0100_ChampionAttributeStatistics)) {
 		f287_drawChampionBarGraphs(champIndex);
-		if (L0863_B_IsInventoryChampion) {
-			f290_drawHealthStaminaManaValues(L0865_ps_Champion);
-			if ((L0865_ps_Champion->_food < 0) || (L0865_ps_Champion->_water < 0) || (L0865_ps_Champion->_poisonEventCount)) {
-				AL0870_i_NativeBitmapIndex = k34_SlotBoxWoundedIndice;
-			} else {
-				AL0870_i_NativeBitmapIndex = k33_SlotBoxNormalIndice;
-			}
-			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(AL0870_i_NativeBitmapIndex), gBoxMouth, k16_byteWidth, k12_ColorDarkestGray, 18);
-			AL0870_i_NativeBitmapIndex = k33_SlotBoxNormalIndice;
-			for (AL0864_i_StatisticIndex = k1_ChampionStatStrength; AL0864_i_StatisticIndex <= k6_ChampionStatAntifire; AL0864_i_StatisticIndex++) {
-				if ((L0865_ps_Champion->_statistics[AL0864_i_StatisticIndex][k1_ChampionStatCurrent] < L0865_ps_Champion->_statistics[AL0864_i_StatisticIndex][k0_ChampionStatMaximum])) {
-					AL0870_i_NativeBitmapIndex = k34_SlotBoxWoundedIndice;
+		if (isInventoryChampion) {
+			f290_drawHealthStaminaManaValues(curChampion);
+			int16 nativeBitmapIndex;
+			if ((curChampion->_food < 0) || (curChampion->_water < 0) || (curChampion->_poisonEventCount))
+				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
+			else
+				nativeBitmapIndex = k33_SlotBoxNormalIndice;
+
+			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), gBoxMouth, k16_byteWidth, k12_ColorDarkestGray, 18);
+			nativeBitmapIndex = k33_SlotBoxNormalIndice;
+			for (int i = k1_ChampionStatStrength; i <= k6_ChampionStatAntifire; i++) {
+				if ((curChampion->_statistics[i][k1_ChampionStatCurrent] < curChampion->_statistics[i][k0_ChampionStatMaximum])) {
+					nativeBitmapIndex = k34_SlotBoxWoundedIndice;
 					break;
 				}
 			}
-			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(AL0870_i_NativeBitmapIndex), gBoxEye, k16_byteWidth, k12_ColorDarkestGray, 18);
-			setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
+			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), gBoxEye, k16_byteWidth, k12_ColorDarkestGray, 18);
+			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 		}
 	}
-	if (getFlag(L0862_ui_ChampionAttributes, k0x2000_ChampionAttributeWounds)) {
-		for (AL0864_i_SlotIndex = L0863_B_IsInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL0864_i_SlotIndex >= k0_ChampionSlotReadyHand; AL0864_i_SlotIndex--) {
-			f291_drawSlot(champIndex, AL0864_i_SlotIndex);
-		}
-		if (L0863_B_IsInventoryChampion) {
-			setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
-		}
+	if (getFlag(championAttributes, k0x2000_ChampionAttributeWounds)) {
+		for (int i = isInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; i >= k0_ChampionSlotReadyHand; i--)
+			f291_drawSlot(champIndex, i);
+
+		if (isInventoryChampion)
+			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
-	if (getFlag(L0862_ui_ChampionAttributes, k0x0200_ChampionAttributeLoad) && L0863_B_IsInventoryChampion) {
-		if (L0865_ps_Champion->_load > (AL0864_i_Load = f309_getMaximumLoad(L0865_ps_Champion))) {
-			AL0870_i_Color = k8_ColorRed;
-		} else {
-			if (((long)L0865_ps_Champion->_load << 3) > ((long)AL0864_i_Load * 5)) {
-				AL0870_i_Color = k11_ColorYellow;
-			} else {
-				AL0870_i_Color = k13_ColorLightestGray;
-			}
-		}
-		_vm->_textMan->f52_printToViewport(104, 132, (Color)AL0870_i_Color, "LOAD ");
-		AL0864_i_Load = L0865_ps_Champion->_load / 10;
-		strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
+	if (getFlag(championAttributes, k0x0200_ChampionAttributeLoad) && isInventoryChampion) {
+		uint16 maxLoad = f309_getMaximumLoad(curChampion);
+		Color loadColor;
+		if (curChampion->_load > maxLoad)
+			loadColor = k8_ColorRed;
+		else if (((long)curChampion->_load << 3) > ((long)maxLoad * 5))
+			loadColor = k11_ColorYellow;
+		else
+			loadColor = k13_ColorLightestGray;
+
+		_vm->_textMan->f52_printToViewport(104, 132, loadColor, "LOAD ");
+		maxLoad = curChampion->_load / 10;
+		strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, true, 3).c_str());
 		strcat(_vm->_g353_stringBuildBuffer, ".");
-		AL0864_i_Load = L0865_ps_Champion->_load - (AL0864_i_Load * 10);
-		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str());
+		maxLoad = curChampion->_load - (maxLoad * 10);
+		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, false, 1).c_str());
 		strcat(_vm->_g353_stringBuildBuffer, "/");
-		AL0864_i_Load = (f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10;
-		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
+		maxLoad = (f309_getMaximumLoad(curChampion) + 5) / 10;
+		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, true, 3).c_str());
 		strcat(_vm->_g353_stringBuildBuffer, " KG");
-		_vm->_textMan->f52_printToViewport(148, 132, (Color)AL0870_i_Color, _vm->_g353_stringBuildBuffer);
-		setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
+		_vm->_textMan->f52_printToViewport(148, 132, loadColor, _vm->_g353_stringBuildBuffer);
+		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
-	AL0864_i_ChampionIconIndex = M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir);
-	if (getFlag(L0862_ui_ChampionAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL0864_i_ChampionIconIndex))) {
-		_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0864_i_ChampionIconIndex], g46_ChampionColor[champIndex]);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex], _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
+	uint16 championIconIndex = M26_championIconIndex(curChampion->_cell, _vm->_dungeonMan->_g308_partyDir);
+	if (getFlag(championAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(championIconIndex))) {
+		_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[championIconIndex], g46_ChampionColor[champIndex]);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[championIconIndex], _vm->_championMan->M26_championIconIndex(curChampion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
 	}
-	if (getFlag(L0862_ui_ChampionAttributes, k0x0800_ChampionAttributePanel) && L0863_B_IsInventoryChampion) {
-		if (_vm->_g333_pressingMouth) {
+	if (getFlag(championAttributes, k0x0800_ChampionAttributePanel) && isInventoryChampion) {
+		if (_vm->_g333_pressingMouth)
 			_vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned();
-		} else {
-			if (_vm->_g331_pressingEye) {
-				if (_g415_leaderEmptyHanded) {
-					_vm->_inventoryMan->f351_drawChampionSkillsAndStatistics();
-				}
-			} else {
-				_vm->_inventoryMan->f347_drawPanel();
-			}
-		}
-		setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
+		else if (_vm->_g331_pressingEye) {
+			if (_g415_leaderEmptyHanded)
+				_vm->_inventoryMan->f351_drawChampionSkillsAndStatistics();
+		} else
+			_vm->_inventoryMan->f347_drawPanel();
+
+		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
-	if (getFlag(L0862_ui_ChampionAttributes, k0x8000_ChampionAttributeActionHand)) {
+	if (getFlag(championAttributes, k0x8000_ChampionAttributeActionHand)) {
 		f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
 		_vm->_menuMan->f386_drawActionIcon(champIndex);
-		if (L0863_B_IsInventoryChampion) {
-			setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
-		}
+		if (isInventoryChampion)
+			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
-	if (getFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport)) {
+	if (getFlag(championAttributes, k0x4000_ChampionAttributeViewport))
 		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
-	}
-T0292042:
-	clearFlag(L0865_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
+
+	clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
 	_vm->_eventMan->f77_hideMouse();
 }
 
@@ -2260,20 +2245,17 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
 
 	uint16 slotBoxIndex;
 	if (!isInventoryChamp) {  /* If drawing a slot for a champion other than the champion whose inventory is open */
-		if ((slotIndex > k1_ChampionSlotActionHand) || (_g299_candidateChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))) {
+		if ((slotIndex > k1_ChampionSlotActionHand) || (_g299_candidateChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)))
 			return;
-		}
 		slotBoxIndex = (champIndex << 1) + slotIndex;
-	} else {
+	} else
 		slotBoxIndex = k8_SlotBoxInventoryFirstSlot + slotIndex;
-	}
 
 	Thing thing;
-	if (slotIndex >= k30_ChampionSlotChest_1) {
+	if (slotIndex >= k30_ChampionSlotChest_1)
 		thing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
-	} else {
+	else
 		thing = champ->getSlot((ChampionSlot)slotIndex);
-	}
 
 	SlotBox *slotBox = &_vm->_objectMan->_g30_slotBoxes[slotBoxIndex];
 	Box box;
@@ -2282,10 +2264,8 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
 	box._x2 = box._x1 + 17;
 	box._y2 = box._y1 + 17;
 
-
-	if (!isInventoryChamp) {
+	if (!isInventoryChamp)
 		_vm->_eventMan->f77_hideMouse();
-	}
 
 	int16 iconIndex;
 	if (thing == Thing::_none) {
@@ -2294,15 +2274,13 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
 			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) {
 				iconIndex++;
 				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
-			} else {
+			} else
 				nativeBitmapIndex = k33_SlotBoxNormalIndice;
-			}
 		} else {
-			if ((slotIndex >= k10_ChampionSlotNeck) && (slotIndex <= k13_ChampionSlotBackpackLine_1_1)) {
+			if ((slotIndex >= k10_ChampionSlotNeck) && (slotIndex <= k13_ChampionSlotBackpackLine_1_1))
 				iconIndex = k208_IconIndiceNeck + (slotIndex - k10_ChampionSlotNeck);
-			} else {
+			else
 				iconIndex = k204_IconIndiceEmptyBox;
-			}
 		}
 	} else {
 		iconIndex = _vm->_objectMan->f33_getIconIndex(thing); // BUG0_35
@@ -2310,17 +2288,15 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
 			iconIndex++;
 		} // BUG2_00
 		if (slotIndex <= k5_ChampionSlotFeet) {
-			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) {
+			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex)))
 				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
-			} else {
+			else
 				nativeBitmapIndex = k33_SlotBoxNormalIndice;
-			}
 		}
 	}
 
-	if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->M0_indexToOrdinal(champIndex) == _g506_actingChampionOrdinal)) {
+	if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->M0_indexToOrdinal(champIndex) == _g506_actingChampionOrdinal))
 		nativeBitmapIndex = k35_SlotBoxActingHandIndice;
-	}
 
 	if (nativeBitmapIndex != -1) {
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
@@ -2335,9 +2311,8 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
 
 	_vm->_objectMan->f38_drawIconInSlotBox(slotBoxIndex, iconIndex);
 
-	if (!isInventoryChamp) {
+	if (!isInventoryChamp)
 		_vm->_eventMan->f78_showMouse();
-	}
 }
 
 void ChampionMan::f281_renameChampion(Champion* champ) {


Commit: 2cb7938c52147966e81bc0803e5a0f68cfef551c
    https://github.com/scummvm/scummvm/commit/2cb7938c52147966e81bc0803e5a0f68cfef551c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix broken champion after loading

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 2db6481..c2bfc47 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -147,6 +147,7 @@ ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
 	_g303_partyDead = false;
 	_g414_leaderHandObject = Thing(0);
 	_g411_leaderIndex = kM1_ChampionNone;
+	_g299_candidateChampionOrdinal = 0;
 	_g300_partyIsSleeping = false;
 	_g506_actingChampionOrdinal = 0;
 	_g413_leaderHandObjectIconIndex = (IconIndice)0;


Commit: 2cd9c90e17b1ac5b22dce45bbb44fcdd05ea9d17
    https://github.com/scummvm/scummvm/commit/2cd9c90e17b1ac5b22dce45bbb44fcdd05ea9d17
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Revert from using DisplayMan::_bitmaps directly

Changed paths:
    engines/dm/dm.h
    engines/dm/gfx.cpp



diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 007f22c..e2c8923 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -105,6 +105,7 @@ public:
 	static const Thing _party; // @ C0xFFFF_THING_PARTY  
 
 	Thing() : _data(0) {}
+	Thing(const Thing &other) { set(other._data); }
 	explicit Thing(uint16 d) { set(d); }
 
 	void set(uint16 d) {
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index eb9012e..2d7a99f 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2023,12 +2023,6 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 							  g106_BoxThievesEye_ViewPortVisibleArea._y1,
 							  k112_byteWidthViewport, 48, kM1_ColorNoTransparency, 136, 95);
 			bitmap = f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice);
- /* BUG0_74 Creatures are drawn with wrong colors when viewed through a wall with the 'Thieve's Eye' spell. The 'hole in wall'
- graphic is applied to the visible area with transparency on color 10. However the visible area may contain creature graphics
- that use color 9. When the bitmap is drawn below with transparency on color 9 then the creature graphic is alterated: pixels
- using color 9 are transparent and the background wall is visible through the creature graphic (grey/white pixels).
- To fix this bug, the 'hole in wall' graphic should be applied to the wall graphic first (in a temporary buffer) and
- then the wall with the hole should be drawn over the visible area */
 			f132_blitToBitmap(bitmap, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
 							  g107_BoxThievesEyeVisibleArea,
 							  0, 0, 48, 48, k10_ColorFlesh, 95, 95);
@@ -2451,7 +2445,7 @@ void DisplayMan::f93_applyCreatureReplColors(int replacedColor, int replacementC
 
 void DisplayMan::f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
 	if (f._srcByteWidth)
-		f132_blitToBitmap(_bitmaps[nativeIndex], _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh);
+		f132_blitToBitmap(f489_getNativeBitmapOrGraphic(nativeIndex), _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh);
 }
 
 void DisplayMan::f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) {
@@ -2645,10 +2639,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 		f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport,
 						  *(Box *)AL0090_puc_CoordinateSet, AL0089_i_X, 0,
 						  AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport);
-/* BUG0_05 A champion portrait sensor on a wall square is visible on all sides of the wall.
-If there is another sensor with a wall ornament on one side of the wall then the champion portrait is drawn over that wall ornament */
 		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
-/* A portrait is 32x29 pixels */
 			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice),
 							  _g296_bitmapViewport, g109_BoxChampionPortraitOnWall,
 							  (_g289_championPortraitOrdinal & 0x0007) << 5,


Commit: 572d3bf82206e8db5fb2e113cb5bbce211514f33
    https://github.com/scummvm/scummvm/commit/572d3bf82206e8db5fb2e113cb5bbce211514f33
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix torch, lever bug and fix several Sensor methods

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dungeonman.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 1ef449d..cefa603 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -4,7 +4,7 @@ Bugs:
 		Portraits, alcoves etc. look broken from afar
 		Arrow and hand display is messed up
 		Items are displayed in the wrong cells
-		Levers look the same after pulling them
+
 
 	Logic:
 		When object are put on the right side of the current square, they disappear
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 6fed184..bbd1499 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -319,7 +319,7 @@ public:
 	uint16 getData() { return (_datAndType >> 7) & 0x1FF; } // @ M40_DATA
 	static uint16 getDataMask1(uint16 data) { return (data >> 7) & 0xF; } // @ M42_MASK1
 	static uint16 getDataMask2(uint16 data) { return (data >> 11) & 0xF; } // @ M43_MASK2
-	void setData(int16 dat) { _datAndType = (_datAndType & 0x7F) | (dat << 7); } // @ M41_SET_DATA
+	void setData(uint16 dat) { _datAndType = dat; } // @ M41_SET_DATA
 	void setTypeDisabled() { _datAndType &= 0xFF80; } // @ M44_SET_TYPE_DISABLED
 
 
@@ -335,11 +335,11 @@ public:
 	uint16 getTargetMapY() { return (_action >> 11); }
 	uint16 getTargetMapX() { return (_action >> 6) & 0x1F; }
 	Direction getTargetCell() { return (Direction)((_action >> 4) & 3); }
-	uint16 M47_kineticEnergy() { return (_action & 0xFF); }// @ M47_KINETIC_ENERGY
-	uint16 M48_stepEnergy() { return (_action >> 8) & 0xFF; }// @ M48_STEP_ENERGY
-	uint16 M49_localEffect() { return _action; } // @ M49_LOCAL_EFFECT
-	uint16 M45_healthMultiplier() { return (_action & 0xF); } // @ M45_HEALTH_MULTIPLIER
-	uint16 M46_ticks() { return (_action >> 4) & 0xFFF; } // @ M46_TICKS
+	uint16 M45_healthMultiplier() { return ((_action >> 4) & 0xF); } // @ M45_HEALTH_MULTIPLIER
+	uint16 M46_ticks() { return ((_action >> 4) >> 4) & 0xFFF; } // @ M46_TICKS
+	uint16 M47_kineticEnergy() { return ((_action >> 4) & 0xFF); }// @ M47_KINETIC_ENERGY
+	uint16 M48_stepEnergy() { return ((_action >> 4) >> 8) & 0xFF; }// @ M48_STEP_ENERGY
+	uint16 M49_localEffect() { return (_action >> 4); } // @ M49_LOCAL_EFFECT
 
 	void setDatAndTypeWithOr(uint16 val) { _datAndType |= val;  }
 


Commit: 040a02003b9dc8a245dae25eb9a63294fd1d2700
    https://github.com/scummvm/scummvm/commit/040a02003b9dc8a245dae25eb9a63294fd1d2700
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Complete ChampionMan::f281_renameChampion

Changed paths:
    engines/dm/champion.cpp
    engines/dm/eventman.cpp
    engines/dm/eventman.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index c2bfc47..de0ed3e 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -266,7 +266,7 @@ void ChampionMan::f299_applyModifiersToStatistics(Champion *champ, int16 slotInd
 	ThingType thingType = thing.getType();
 
 	bool cursed = false;
-	if (   ((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType))
+	if (((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType))
 		&& (slotIndex >= k0_ChampionSlotReadyHand) && (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) {
 		if (thingType == k5_WeaponThingType) {
 			Weapon *weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(thing);
@@ -746,18 +746,18 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 			defense /= woundCount;
 
 		switch (attackType) {
-		case k6_attackType_PSYCHIC: 
-			{
-				int16 wisdomFactor = 115 - curChampion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent];
-				if (wisdomFactor <= 0) {
-					attack = 0;
-				} else {
-					attack = _vm->f30_getScaledProduct(attack, 6, wisdomFactor);
-				}
-
-				skipScaling = true;
+		case k6_attackType_PSYCHIC:
+		{
+			int16 wisdomFactor = 115 - curChampion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent];
+			if (wisdomFactor <= 0) {
+				attack = 0;
+			} else {
+				attack = _vm->f30_getScaledProduct(attack, 6, wisdomFactor);
 			}
-			break;
+
+			skipScaling = true;
+		}
+		break;
 		case k5_attackType_MAGIC:
 			attack = f307_getStatisticAdjustedAttack(curChampion, k5_ChampionStatAntimagic, attack);
 			attack -= _g407_party._spellShieldDefense;
@@ -780,10 +780,10 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 
 			attack = _vm->f30_getScaledProduct(attack, 6, 130 - defense);
 		}
-		/* BUG0_44 
+		/* BUG0_44
 			A champion may take much more damage than expected after a Black Flame attack or an impact
 			with a Fireball projectile. If the party has a fire shield defense value higher than the fire
-			attack value then the resulting intermediary attack value is negative and damage should be 0. 
+			attack value then the resulting intermediary attack value is negative and damage should be 0.
 			However, the negative value is still used for further computations and the result may be a very
 			high positive attack value which may kill a champion. This can occur only for k1_attackType_FIRE
 			and if attack is negative before calling F0030_MAIN_GetScaledProduct
@@ -837,7 +837,7 @@ int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
 		woundDefense >>= 1;
 
 	woundDefense += curChampion->_actionDefense + curChampion->_shieldDefense + _g407_party._shieldDefense + armorShieldDefense;
-	if (woundIndex > k1_ChampionSlotActionHand)  {
+	if (woundIndex > k1_ChampionSlotActionHand) {
 		Thing curThing = curChampion->_slots[woundIndex];
 		if (curThing.getType() == k6_ArmourThingType) {
 			ArmourInfo *armourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(curThing);
@@ -1242,7 +1242,7 @@ void ChampionMan::f283_viAltarRebirth(uint16 champIndex) {
 
 		curChampion->_cell = (ViewCell)numCell;
 	}
-	
+
 	uint16 maximumHealth = curChampion->_maxHealth;
 	curChampion->_maxHealth = MAX(25, maximumHealth - (maximumHealth >> 6) - 1);
 	curChampion->_currHealth = curChampion->_maxHealth >> 1;
@@ -1454,7 +1454,7 @@ void ChampionMan::f319_championKill(uint16 champIndex) {
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[curChampionIconIndex << 2], k0_ColorBlack);
 	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
-	
+
 	int16 aliveChampionIndex;
 	for (aliveChampionIndex = k0_ChampionFirst, curChampion = _vm->_championMan->_gK71_champions; aliveChampionIndex < _vm->_championMan->_g305_partyChampionCount; aliveChampionIndex++, curChampion++) {
 		if (curChampion->_currHealth)
@@ -1555,7 +1555,7 @@ void ChampionMan::f331_applyTimeEffects() {
 		if (championPtr->_currHealth && (_vm->M0_indexToOrdinal(championIndex) != _vm->_championMan->_g299_candidateChampionOrdinal)) {
 			uint16 wizardSkillLevel = _vm->_championMan->f303_getSkillLevel(championIndex, k3_ChampionSkillWizard) + _vm->_championMan->f303_getSkillLevel(championIndex, k2_ChampionSkillPriest);
 			if ((championPtr->_currMana < championPtr->_maxMana)
-			&&  (timeCriteria < championPtr->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + wizardSkillLevel)) {
+				&& (timeCriteria < championPtr->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + wizardSkillLevel)) {
 				int16 manaGain = championPtr->_maxMana / 40;
 				if (_vm->_championMan->_g300_partyIsSleeping)
 					manaGain <<= 1;
@@ -1726,10 +1726,10 @@ void ChampionMan::load2_PartyPart(Common::InSaveFile* file) {
 				champ->_statistics[y][x] = file->readByte();
 		for (uint16 j = 0; j < 30; ++j)
 			champ->_slots[j] = Thing(file->readUint16BE());
-			for (uint16 j = 0; j < 20; ++j) {
-				champ->_skills[j]._temporaryExperience = file->readSint16BE();
-				champ->_skills[j]._experience = file->readSint32BE();
-			}
+		for (uint16 j = 0; j < 20; ++j) {
+			champ->_skills[j]._temporaryExperience = file->readSint16BE();
+			champ->_skills[j]._experience = file->readSint32BE();
+		}
 		for (uint16 j = 0; j < 8; ++j)
 			champ->_name[j] = file->readByte();
 		for (uint16 j = 0; j < 20; ++j)
@@ -1945,7 +1945,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 					curSlotIndex = slotIdx++;
 
 				break;
-				}
+			}
 			case k5_WeaponThingType:
 				if (championPtr->_slots[k1_ChampionSlotActionHand] == Thing::_none)
 					curSlotIndex = k1_ChampionSlotActionHand;
@@ -2317,31 +2317,162 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
 }
 
 void ChampionMan::f281_renameChampion(Champion* champ) {
-	warning(false, "STUB METHOD: Champion::renameChampion, F0281_CHAMPION_Rename");
+#define k1_RENAME_CHAMPION_NAME 1
+#define k2_RENAME_CHAMPION_TITLE 2
+	static char G0051_ac_Graphic562_UnderscoreCharacterString[2] = "_";
+	static char G0052_ac_Graphic562_RenameChampionInputCharacterString[2] = " ";
+	static char G0053_ac_Graphic562_ReincarnateSpecialCharacters[6] = {',', '.', ';', ':', ' '};
+
+	uint16 L0808_ui_Multiple;
+#define AL0808_ui_CharacterIndex L0808_ui_Multiple
+#define AL0808_ui_ChampionIndex  L0808_ui_Multiple
+	int16 L0809_i_RenamedChampionString;
+	int16 L0810_i_Character;
+	bool L0811_B_ChampionTitleIsFull;
+	char* L0812_pc_RenamedChampionString;
+	int16 L0813_i_X;
+	int16 L0814_i_Y;
+	Box L0815_s_Box;
+	int16 L0820_i_CharacterIndexBackup;
+	char L0821_ac_ChampionNameBackupString[8];
+
+
+	L0815_s_Box._y1 = 3;
+	L0815_s_Box._y2 = 8;
+	L0815_s_Box._x2 = (L0815_s_Box._x1 = 3) + 167;
+	_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, L0815_s_Box, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
+	_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), g32_BoxPanel, k72_byteWidth, k4_ColorCyan, 73);
+	_vm->_textMan->f52_printToViewport(177, 58, k13_ColorLightestGray, "_______");
+	_vm->_textMan->f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________");
+	_vm->_eventMan->f78_showMouse();
+	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+	_vm->_eventMan->f67_setMousePointerToNormal(k0_pointerArrow);
+	_vm->_eventMan->f77_hideMouse();
+	champ->_name[AL0808_ui_CharacterIndex = 0] = '\0';
+	champ->_title[0] = '\0';
+	L0809_i_RenamedChampionString = k1_RENAME_CHAMPION_NAME;
+	L0812_pc_RenamedChampionString = champ->_name;
+	L0813_i_X = 177;
+	L0814_i_Y = 91;
 
-	DisplayMan &dispMan = *_vm->_displayMan;
-	TextMan &textMan = *_vm->_textMan;
+	for (;;) { /*_Infinite loop_*/
+		if (!(L0811_B_ChampionTitleIsFull = ((L0809_i_RenamedChampionString == k2_RENAME_CHAMPION_TITLE) && (AL0808_ui_CharacterIndex == 19)))) {
+			_vm->_eventMan->f78_showMouse();
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k9_ColorGold, k12_ColorDarkestGray, G0051_ac_Graphic562_UnderscoreCharacterString, k200_heightScreen);
+			_vm->_eventMan->f77_hideMouse();
+		}
+		L0810_i_Character = 256;
+		while (L0810_i_Character == 256) {
+			Common::Event event;
+			Common::EventType eventType;
+			{
+				eventType = _vm->_eventMan->processInput(&event, &event);
+				_vm->_displayMan->updateScreen();
+				_vm->f22_delay(1);
+			}
+			if (eventType == Common::EVENT_LBUTTONDOWN) { /* If left mouse button status has changed */
+				Common::Point mousePos = _vm->_eventMan->getMousePos();
+				if ((L0809_i_RenamedChampionString == k2_RENAME_CHAMPION_TITLE || (AL0808_ui_CharacterIndex > 0)) && (mousePos.x >= 197) && (mousePos.x <= 215) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'OK' button */
+					L0820_i_CharacterIndexBackup = AL0808_ui_CharacterIndex;
+					strcpy(L0821_ac_ChampionNameBackupString, L0812_pc_RenamedChampionString = champ->_name);
+					AL0808_ui_CharacterIndex = strlen(L0812_pc_RenamedChampionString);
+					while (L0812_pc_RenamedChampionString[--AL0808_ui_CharacterIndex] == ' ') { /* Replace space characters on the right of the champion name by '\0' characters */
+						L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex] = '\0';
+					}
+					for (AL0808_ui_ChampionIndex = k0_ChampionFirst; AL0808_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount - 1; AL0808_ui_ChampionIndex++) {
+						if (!strcmp(_vm->_championMan->_gK71_champions[AL0808_ui_ChampionIndex]._name, L0812_pc_RenamedChampionString)) /* If an existing champion already has the specified name for the new champion */
+							goto T0281011_ContinueRename;
+					}
+					return;
+T0281011_ContinueRename:
+					if (L0809_i_RenamedChampionString == k2_RENAME_CHAMPION_TITLE) {
+						L0812_pc_RenamedChampionString = champ->_title;
+					}
+					strcpy(L0812_pc_RenamedChampionString = champ->_name, L0821_ac_ChampionNameBackupString);
+					AL0808_ui_CharacterIndex = L0820_i_CharacterIndexBackup;
+				} else {
+					if ((mousePos.x >= 107) && (mousePos.x <= 175) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'BACKSPACE' button */
+						L0810_i_Character = '\b';
+						break;
+					}
+					if ((mousePos.x < 107) || (mousePos.x > 215) || (mousePos.y < 116) || (mousePos.y > 144)) {/* Coordinates of table of all other characters */
+						//goto T0281023;
+					}
+					if (!((mousePos.x + 4) % 10) || (!((mousePos.y + 5) % 10) && ((mousePos.x < 207) || (mousePos.y != 135)))) {
+						//goto T0281023;
+					}
+					L0810_i_Character = 'A' + (11 * ((mousePos.y - 116) / 10)) + ((mousePos.x - 107) / 10);
+					if ((L0810_i_Character == 86) || (L0810_i_Character == 97)) { /* The 'Return' button occupies two cells in the table */
+						L0810_i_Character = '\r'; /* Carriage return */
+						break;
+					}
+					if (L0810_i_Character >= 87) { /* Compensate for the first cell occupied by 'Return' button */
+						L0810_i_Character--;
+					}
+					if (L0810_i_Character > 'Z') {
+						L0810_i_Character = G0053_ac_Graphic562_ReincarnateSpecialCharacters[(L0810_i_Character - 'Z') - 1];
+					}
+					break;
+				}
+			} else if (eventType == Common::EVENT_KEYDOWN) {
+				L0810_i_Character = event.kbd.ascii;
+			}
+		}
 
-	Box box;
-	box._y1 = 3;
-	box._y2 = 8;
-	box._x1 = 3;
-	box._x2 = box._x1 + 167;
-
-	dispMan.f135_fillBoxBitmap(dispMan._g296_bitmapViewport, box, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
-	dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), dispMan._g296_bitmapViewport, g32_BoxPanel,
-							  0, 0, 72, k112_byteWidthViewport, k4_ColorCyan);
-	textMan.f52_printToViewport(177, 58, k13_ColorLightestGray, "_______");
-	textMan.f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________");
-	Common::Point clickPos;
-	static Box okButtonBox(197, 215, 147, 155);
-	for (;;) {
-		_vm->_eventMan->processInput();
-		if (_vm->_eventMan->f360_hasPendingClick(clickPos, k1_LeftMouseButton) && okButtonBox.isPointInside(clickPos)) {
-			return;
+		if ((L0810_i_Character >= 'a') && (L0810_i_Character <= 'z')) {
+			L0810_i_Character -= 32; /* Convert to uppercase */
+		}
+		if (((L0810_i_Character >= 'A') && (L0810_i_Character <= 'Z')) || (L0810_i_Character == '.') || (L0810_i_Character == ',') || (L0810_i_Character == ';') || (L0810_i_Character == ':') || (L0810_i_Character == ' ')) {
+			if ((L0810_i_Character == ' ') && AL0808_ui_CharacterIndex == 0) {
+			} else {
+				if (!L0811_B_ChampionTitleIsFull) {
+					G0052_ac_Graphic562_RenameChampionInputCharacterString[0] = L0810_i_Character;
+					_vm->_eventMan->f78_showMouse();
+					_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k13_ColorLightestGray, k12_ColorDarkestGray, G0052_ac_Graphic562_RenameChampionInputCharacterString, k200_heightScreen);
+					_vm->_eventMan->f77_hideMouse();
+					L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex++] = L0810_i_Character;
+					L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex] = '\0';
+					L0813_i_X += 6;
+					if ((L0809_i_RenamedChampionString == k1_RENAME_CHAMPION_NAME) && (AL0808_ui_CharacterIndex == 7))
+						goto T0281033_ProceedToTitle;
+				}
+			}
+		} else {
+			if (L0810_i_Character == '\r') { /* Carriage return */
+				if ((L0809_i_RenamedChampionString == k1_RENAME_CHAMPION_NAME) && (AL0808_ui_CharacterIndex > 0)) {
+					_vm->_eventMan->f78_showMouse();
+					_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k13_ColorLightestGray, k12_ColorDarkestGray, G0051_ac_Graphic562_UnderscoreCharacterString, k200_heightScreen);
+					_vm->_eventMan->f77_hideMouse();
+T0281033_ProceedToTitle:
+					L0809_i_RenamedChampionString = k2_RENAME_CHAMPION_TITLE;
+					L0812_pc_RenamedChampionString = champ->_title;
+					L0813_i_X = 105;
+					L0814_i_Y = 109;
+					AL0808_ui_CharacterIndex = 0;
+				}
+			} else {
+				if (L0810_i_Character == '\b') { /* Backspace */
+					if ((L0809_i_RenamedChampionString == k1_RENAME_CHAMPION_NAME) && (AL0808_ui_CharacterIndex == 0))
+						continue;
+					if (!L0811_B_ChampionTitleIsFull) {
+						_vm->_eventMan->f78_showMouse();
+						_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k13_ColorLightestGray, k12_ColorDarkestGray, G0051_ac_Graphic562_UnderscoreCharacterString, k200_heightScreen);
+						_vm->_eventMan->f77_hideMouse();
+					}
+					if (AL0808_ui_CharacterIndex == 0) {
+						L0812_pc_RenamedChampionString = champ->_name;
+						AL0808_ui_CharacterIndex = strlen(L0812_pc_RenamedChampionString) - 1;
+						L0809_i_RenamedChampionString = k1_RENAME_CHAMPION_NAME;
+						L0813_i_X = 177 + (AL0808_ui_CharacterIndex * 6);
+						L0814_i_Y = 91;
+					} else {
+						AL0808_ui_CharacterIndex--;
+						L0813_i_X -= 6;
+					}
+					L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex] = '\0';
+				}
+			}
 		}
-		dispMan.f97_drawViewport(k0_viewportNotDungeonView);
-		dispMan.updateScreen();
 	}
 }
 
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index ec25758..fbfc6e0 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -535,13 +535,17 @@ void EventManager::setMousePos(Common::Point pos) {
 }
 
 
-void EventManager::processInput() {
+Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Event *grabMouseClick) {
 	Common::Event event;
 	while (_vm->_system->getEventManager()->pollEvent(event)) {
 		switch (event.type) {
 		case Common::EVENT_KEYDOWN: {
 			if (event.synthetic)
 				break;
+			if (grabKey) {
+				*grabKey = event;
+				return event.type;
+			}
 			if (_g443_primaryKeyboardInput) {
 				KeyboardInput *input = _g443_primaryKeyboardInput;
 				while (input->_commandToIssue != k0_CommandNone) {
@@ -565,7 +569,7 @@ void EventManager::processInput() {
 					input++;
 				}
 			}
-
+			break;
 		}
 		case Common::EVENT_MOUSEMOVE:
 			if (!_g597_ignoreMouseMovements)
@@ -573,6 +577,10 @@ void EventManager::processInput() {
 			break;
 		case Common::EVENT_LBUTTONDOWN:
 		case Common::EVENT_RBUTTONDOWN:
+			if (grabMouseClick) {
+				*grabMouseClick = event;
+				return event.type;
+			}
 			_g436_pendingClickPresent = true;
 			_g437_pendingClickPos = _mousePos;
 			_g439_pendingClickButton = (event.type == Common::EVENT_LBUTTONDOWN) ? k1_LeftMouseButton : k2_RightMouseButton;
@@ -581,8 +589,10 @@ void EventManager::processInput() {
 			break;
 		}
 	}
+	return Common::EVENT_INVALID;
 }
 
+
 void EventManager::f360_processPendingClick() {
 	if (_g436_pendingClickPresent) {
 		_g436_pendingClickPresent = false;
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 0a77cf8..731044e 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -30,6 +30,7 @@
 
 #include "common/events.h"
 #include "common/queue.h"
+#include "common/array.h"
 
 #include "dm.h"
 #include "gfx.h"
@@ -229,6 +230,8 @@ class DMEngine;
 #define k4_pointerTypeAutoselect 4 // @ C4_POINTER_TYPE_AUTOSELECT    
 
 
+
+
 class EventManager {
 	DMEngine *_vm;
 
@@ -281,7 +284,14 @@ public:
 	void f77_hideMouse(); // @ F0078_MOUSE_ShowPointer
 
 	void setMousePos(Common::Point pos);
-	void processInput(); // acknowledges mouse and keyboard input
+	Common::Point getMousePos() { return _mousePos; }
+	/**
+	* Upon encountering an event type for which the grab parameter is not null, the function
+	* will return with the event type, passes the event to the grab desitination and returns without
+	* processing the rest of the events into commands accoring to the current keyboard and mouse input.
+	* If there are no more events, it returns with Common::EVENT_INVALID.
+	*/
+	Common::EventType processInput(Common::Event *grabKey = nullptr, Common::Event *grabMouseClick = nullptr);
 	void f360_processPendingClick(); // @ F0360_COMMAND_ProcessPendingClick
 	void f359_processClick(Common::Point mousePos, MouseButton button); // @ F0359_COMMAND_ProcessClick_CPSC
 	CommandType f358_getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC


Commit: 356f80af5028645de22230e6b365d955afdd081d
    https://github.com/scummvm/scummvm/commit/356f80af5028645de22230e6b365d955afdd081d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix bug where code crashed if trying to display a doorfront in square R3

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/gfx.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index cefa603..db6733a 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -9,7 +9,7 @@ Bugs:
 	Logic:
 		When object are put on the right side of the current square, they disappear
 		Object display is a bit mixed up with regards to which cell is it drawn in
-		Method cthulu messes up the callstack sometimes
+
 		
 
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 2d7a99f..0f274bf 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -809,7 +809,7 @@ void DisplayMan::f460_initializeGraphicData() {
 	_g702_bitmapWallSet_Wall_D0R = new byte[32 * 136];
 	_g703_bitmapWallSet_DoorFrameTop_D2LCR = new byte[96 * 3];
 	_g704_bitmapWallSet_DoorFrameTop_D1LCR = new byte[128 * 4];
-	_g705_bitmapWallSet_DoorFrameLeft_D3L = new byte[32 * 43];
+	_g705_bitmapWallSet_DoorFrameLeft_D3L = new byte[32 * 44];
 	_g706_bitmapWallSet_DoorFrameLeft_D3C = new byte[32 * 44];
 	_g707_bitmapWallSet_DoorFrameLeft_D2C = new byte[48 * 65];
 	_g708_bitmapWallSet_DoorFrameLeft_D1C = new byte[32 * 94];


Commit: e0d89afbc30a36d5825e637a06da0e695a91b57a
    https://github.com/scummvm/scummvm/commit/e0d89afbc30a36d5825e637a06da0e695a91b57a
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add some missing code warnings to function calls

Changed paths:
    engines/dm/menus.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index b63717d..f0db59b 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -238,7 +238,7 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
 			_g509_actionAreaContainsIcons = false;
 			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
 			champMan.f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal));
-			warning(false, "MISSING CODE: F0387_MENUS_DrawActionArea");
+			f387_drawActionArea();
 		}
 	}
 }
@@ -251,7 +251,7 @@ void MenuMan::f387_drawActionArea() {
 	ChampionMan &champMan = *_vm->_championMan;
 	TextMan &textMan = *_vm->_textMan;
 
-	warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+	_vm->_eventMan->f77_hideMouse();
 	dispMan._g578_useByteBoxCoordinates = false;
 	dispMan.D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack);
 	if (_g509_actionAreaContainsIcons) {
@@ -274,7 +274,7 @@ void MenuMan::f387_drawActionArea() {
 												k12_ActionNameMaximumLength, k200_heightScreen);
 		}
 	}
-	warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer");
+	_vm->_eventMan->f78_showMouse();
 	_g508_refreshActionArea = false;
 }
 


Commit: e9622e27b16fda6c5e87d092f2ad477c35966fc1
    https://github.com/scummvm/scummvm/commit/e9622e27b16fda6c5e87d092f2ad477c35966fc1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f349_processCommand70_clickOnMouth

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/menus.cpp
    engines/dm/objectman.cpp
    engines/dm/objectman.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index db6733a..3bbcf6b 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -5,6 +5,9 @@ Bugs:
 		Arrow and hand display is messed up
 		Items are displayed in the wrong cells
 
+		Gui is messed up by drawn spell area line on startup
+		Spellcasting tabs are displayed inproperly, switching between them is possible tho
+
 
 	Logic:
 		When object are put on the right side of the current square, they disappear
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index fbfc6e0..83e07eb 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -357,6 +357,7 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 	_g444_secondaryKeyboardInput = nullptr;
 	_g597_ignoreMouseMovements = false;
 	_g587_hideMousePointerRequestCount = 0;
+	_g558_mouseButtonStatus = 0;
 }
 
 EventManager::~EventManager() {
@@ -529,6 +530,9 @@ void EventManager::f77_hideMouse() {
 	// CursorMan.showMouse(false);
 }
 
+bool EventManager::isMouseButtonDown(MouseButton button) {
+	return (button != k0_NoneMouseButton) ? (_g558_mouseButtonStatus & button) : (_g558_mouseButtonStatus == 0);
+}
 
 void EventManager::setMousePos(Common::Point pos) {
 	_vm->_system->warpMouse(pos.x, pos.y);
@@ -576,15 +580,24 @@ Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Eve
 				_mousePos = event.mouse;
 			break;
 		case Common::EVENT_LBUTTONDOWN:
-		case Common::EVENT_RBUTTONDOWN:
+		case Common::EVENT_RBUTTONDOWN: {
+			MouseButton button = (event.type == Common::EVENT_LBUTTONDOWN) ? k1_LeftMouseButton : k2_RightMouseButton;
+			_g558_mouseButtonStatus |= button;
 			if (grabMouseClick) {
 				*grabMouseClick = event;
 				return event.type;
 			}
 			_g436_pendingClickPresent = true;
 			_g437_pendingClickPos = _mousePos;
-			_g439_pendingClickButton = (event.type == Common::EVENT_LBUTTONDOWN) ? k1_LeftMouseButton : k2_RightMouseButton;
+			_g439_pendingClickButton = button;
+			break;
+		}
+		case Common::EVENT_LBUTTONUP:
+		case Common::EVENT_RBUTTONUP: {
+			MouseButton button = (event.type == Common::EVENT_LBUTTONDOWN) ? k1_LeftMouseButton : k2_RightMouseButton;
+			_g558_mouseButtonStatus &= ~button;
 			break;
+		}
 		default:
 			break;
 		}
@@ -705,7 +718,7 @@ void EventManager::f380_processCommandQueue() {
 		return;
 	}
 	if (cmdType == k70_CommandClickOnMouth) {
-		warning(false, "MISSING CODE: F0349_INVENTORY_ProcessCommand70_ClickOnMouth();");
+		_vm->_inventoryMan->f349_processCommand70_clickOnMouth();
 		return;
 	}
 	if (cmdType == k71_CommandClickOnEye) {
@@ -749,7 +762,6 @@ void EventManager::f380_processCommandQueue() {
 	}
 	if (cmdType == k140_CommandSaveGame) {
 		if ((_vm->_championMan->_g305_partyChampionCount > 0) && !_vm->_championMan->_g299_candidateChampionOrdinal) {
-			warning(false, "MISSING CODE: F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF();");
 			_vm->f433_processCommand140_saveGame(1, "Nice save:)");
 		}
 		return;
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 731044e..a12cc2e 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -249,6 +249,7 @@ class EventManager {
 	byte *_gK190_mousePointerTempBuffer; // @ K0190_puc_Bitmap_MousePointerTemporaryBuffer
 	int16 _gK104_mousePointerType; // @ K0104_i_MousePointerType
 	int16 _gK105_previousMousePointerType; // @ K0105_i_PreviousMousePointerType
+	uint16 _g558_mouseButtonStatus;// @ G0588_i_MouseButtonsStatus
 
 // this doesn't seem to be used anywhere at all
 	bool _g435_isCommandQueueLocked; // @ G0435_B_CommandQueueLocked
@@ -258,7 +259,6 @@ class EventManager {
 	void f366_commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty
 	bool f375_processType80_clickDungeonView_isLeaderHandObjThrown(int16 posX, int16 posY); // @ F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown
 
-
 public:
 	explicit EventManager(DMEngine *vm);
 	~EventManager();
@@ -282,6 +282,7 @@ public:
 	void f69_setMousePointer(); // @ F0069_MOUSE_SetPointer
 	void f78_showMouse(); // @ F0077_MOUSE_HidePointer_CPSE
 	void f77_hideMouse(); // @ F0078_MOUSE_ShowPointer
+	bool isMouseButtonDown(MouseButton button);
 
 	void setMousePos(Common::Point pos);
 	Common::Point getMousePos() { return _mousePos; }
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 86b78bd..52e70d4 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -32,6 +32,8 @@
 #include "gfx.h"
 #include "text.h"
 #include "objectman.h"
+#include "timeline.h"
+#include "projexpl.h"
 
 
 namespace DM {
@@ -745,4 +747,196 @@ void InventoryMan::f353_drawStopPressingEye() {
 	}
 	_vm->_eventMan->f77_hideMouse();
 }
+
+void InventoryMan::f349_processCommand70_clickOnMouth() {
+	static int16 G0242_ai_Graphic559_FoodAmounts[8] = {
+		500,    /* Apple */
+		600,    /* Corn */
+		650,    /* Bread */
+		820,    /* Cheese */
+		550,    /* Screamer Slice */
+		350,    /* Worm round */
+		990,    /* Drumstick / Shank */
+		1400}; /* Dragon steak */
+
+	Thing L1078_T_Thing;
+	uint16 L1079_ui_IconIndex;
+	uint16 L1080_ui_ChampionIndex;
+	bool L1081_B_RemoveObjectFromLeaderHand;
+	Junk* L1082_ps_Junk;
+	Champion* L1083_ps_Champion;
+	TimelineEvent L1084_s_Event;
+	uint16 L1085_ui_Multiple;
+#define AL1085_ui_PotionPower         L1085_ui_Multiple
+#define AL1085_ui_AdjustedPotionPower L1085_ui_Multiple
+#define AL1085_ui_Counter             L1085_ui_Multiple
+	uint16 L1086_ui_Counter;
+	int16 L1087_i_Wounds;
+	uint16 L1088_ui_Multiple;
+#define AL1088_ui_ThingType               L1088_ui_Multiple
+#define AL1088_ui_Mana                    L1088_ui_Multiple
+#define AL1088_ui_HealWoundIterationCount L1088_ui_Multiple
+	uint16 L1089_ui_Weight;
+
+
+	if (_vm->_championMan->_g415_leaderEmptyHanded) {
+		if (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned) {
+			return;
+		}
+		_vm->_eventMan->_g597_ignoreMouseMovements = true;
+		_vm->_g333_pressingMouth = true;
+		if (!_vm->_eventMan->isMouseButtonDown(k1_LeftMouseButton)) {
+			_vm->_eventMan->_g597_ignoreMouseMovements = false;
+			_vm->_g333_pressingMouth = false;
+			_vm->_g334_stopPressingMouth = false;
+		} else {
+			_vm->_eventMan->f78_showMouse();
+			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
+			_vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned();
+			_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+		}
+		return;
+	}
+	if (_vm->_championMan->_g299_candidateChampionOrdinal) {
+		return;
+	}
+	if (!getFlag(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1078_T_Thing = _vm->_championMan->_g414_leaderHandObject)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) {
+		return;
+	}
+	L1079_ui_IconIndex = _vm->_objectMan->f33_getIconIndex(L1078_T_Thing);
+	AL1088_ui_ThingType = L1078_T_Thing.getType();
+	L1089_ui_Weight = _vm->_dungeonMan->f140_getObjectWeight(L1078_T_Thing);
+	L1083_ps_Champion = &_vm->_championMan->_gK71_champions[L1080_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal)];
+	L1082_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1078_T_Thing);
+	if ((L1079_ui_IconIndex >= k8_IconIndiceJunkWater) && (L1079_ui_IconIndex <= k9_IconIndiceJunkWaterSkin)) {
+		if (!(L1082_ps_Junk->getChargeCount())) {
+			return;
+		}
+		L1083_ps_Champion->_water = MIN(L1083_ps_Champion->_water + 800, 2048);
+		L1082_ps_Junk->setChargeCount(L1082_ps_Junk->getChargeCount() - 1);
+		L1081_B_RemoveObjectFromLeaderHand = false;
+	} else {
+		if (AL1088_ui_ThingType == k8_PotionThingType) {
+			L1081_B_RemoveObjectFromLeaderHand = false;
+		} else {
+			L1082_ps_Junk->setNextThing(Thing::_none);
+			L1081_B_RemoveObjectFromLeaderHand = true;
+		}
+	}
+	_vm->_eventMan->f78_showMouse();
+	if (L1081_B_RemoveObjectFromLeaderHand) {
+		_vm->_championMan->f298_getObjectRemovedFromLeaderHand();
+	}
+	if (AL1088_ui_ThingType == k8_PotionThingType) {
+		AL1085_ui_PotionPower = ((Potion*)L1082_ps_Junk)->getPower();
+		L1086_ui_Counter = ((511 - AL1085_ui_PotionPower) / (32 + (AL1085_ui_PotionPower + 1) / 8)) >> 1;
+		AL1085_ui_AdjustedPotionPower = (AL1085_ui_PotionPower / 25) + 8; /* Value between 8 and 18 */
+		switch (((Potion*)L1082_ps_Junk)->getType()) {
+		case k6_PotionTypeRos:
+			f348_adjustStatisticCurrentValue(L1083_ps_Champion, k2_ChampionStatDexterity, AL1085_ui_AdjustedPotionPower);
+			break;
+		case k7_PotionTypeKu:
+			f348_adjustStatisticCurrentValue(L1083_ps_Champion, k1_ChampionStatStrength, (((Potion*)L1082_ps_Junk)->getPower() / 35) + 5); /* Value between 5 and 12 */
+			break;
+		case k8_PotionTypeDane:
+			f348_adjustStatisticCurrentValue(L1083_ps_Champion, k3_ChampionStatWisdom, AL1085_ui_AdjustedPotionPower);
+			break;
+		case k9_PotionTypeNeta:
+			f348_adjustStatisticCurrentValue(L1083_ps_Champion, k4_ChampionStatVitality, AL1085_ui_AdjustedPotionPower);
+			break;
+		case k10_PotionTypeAntivenin:
+			_vm->_championMan->f323_unpoison(L1080_ui_ChampionIndex);
+			break;
+		case k11_PotionTypeMon:
+			L1083_ps_Champion->_currStamina += MIN(L1083_ps_Champion->_maxStamina - L1083_ps_Champion->_currStamina, L1083_ps_Champion->_maxStamina / L1086_ui_Counter);
+			break;
+		case k12_PotionTypeYa:
+			AL1085_ui_AdjustedPotionPower += AL1085_ui_AdjustedPotionPower >> 1;
+			if (L1083_ps_Champion->_shieldDefense > 50) {
+				AL1085_ui_AdjustedPotionPower >>= 2;
+			}
+			L1083_ps_Champion->_shieldDefense += AL1085_ui_AdjustedPotionPower;
+			L1084_s_Event._type = k72_TMEventTypeChampionShield;
+			M33_setMapAndTime(L1084_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + (AL1085_ui_AdjustedPotionPower * AL1085_ui_AdjustedPotionPower));
+			L1084_s_Event._priority = L1080_ui_ChampionIndex;
+			L1084_s_Event._B._defense = AL1085_ui_AdjustedPotionPower;
+			_vm->_timeline->f238_addEventGetEventIndex(&L1084_s_Event);
+			setFlag(L1083_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox);
+			break;
+		case k13_PotionTypeEe:
+			AL1088_ui_Mana = MIN(900, (L1083_ps_Champion->_currMana + AL1085_ui_AdjustedPotionPower) + (AL1085_ui_AdjustedPotionPower - 8));
+			if (AL1088_ui_Mana > L1083_ps_Champion->_maxMana) {
+				AL1088_ui_Mana -= (AL1088_ui_Mana - MAX(L1083_ps_Champion->_currMana, L1083_ps_Champion->_maxMana)) >> 1;
+			}
+			L1083_ps_Champion->_currMana = AL1088_ui_Mana;
+			break;
+		case k14_PotionTypeVi:
+			AL1088_ui_HealWoundIterationCount = MAX(1, (((Potion*)L1082_ps_Junk)->getPower() / 42));
+			L1083_ps_Champion->_currHealth += L1083_ps_Champion->_maxHealth / L1086_ui_Counter;
+			if (L1087_i_Wounds = L1083_ps_Champion->_wounds) { /* If the champion is wounded */
+				L1086_ui_Counter = 10;
+				do {
+					for (AL1085_ui_Counter = 0; AL1085_ui_Counter < AL1088_ui_HealWoundIterationCount; AL1085_ui_Counter++) {
+						L1083_ps_Champion->_wounds &= _vm->getRandomNumber(65536);
+					}
+					AL1088_ui_HealWoundIterationCount = 1;
+				} while ((L1087_i_Wounds == L1083_ps_Champion->_wounds) && --L1086_ui_Counter); /* Loop until at least one wound is healed or there are no more heal iterations */
+			}
+			setFlag(L1083_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad | k0x2000_ChampionAttributeWounds);
+			break;
+		case k15_PotionTypeWaterFlask:
+			L1083_ps_Champion->_water = MIN(L1083_ps_Champion->_water + 1600, 2048);
+		}
+		((Potion*)L1082_ps_Junk)->setType(k20_PotionTypeEmptyFlask);
+	} else {
+		if ((L1079_ui_IconIndex >= k168_IconIndiceJunkApple) && (L1079_ui_IconIndex < k176_IconIndiceJunkIronKey)) {
+			L1083_ps_Champion->_food = MIN(L1083_ps_Champion->_food + G0242_ai_Graphic559_FoodAmounts[L1079_ui_IconIndex - k168_IconIndiceJunkApple], 2048);
+		}
+	}
+	if (L1083_ps_Champion->_currStamina > L1083_ps_Champion->_maxStamina) {
+		L1083_ps_Champion->_currStamina = L1083_ps_Champion->_maxStamina;
+	}
+	if (L1083_ps_Champion->_currHealth > L1083_ps_Champion->_maxHealth) {
+		L1083_ps_Champion->_currHealth = L1083_ps_Champion->_maxHealth;
+	}
+	if (L1081_B_RemoveObjectFromLeaderHand) {
+		for (L1086_ui_Counter = 5; --L1086_ui_Counter; _vm->f22_delay(8)) { /* Animate mouth icon */
+			_vm->_objectMan->f37_drawIconToScreen(k205_IconIndiceMouthOpen + !(L1086_ui_Counter & 0x0001), 56, 46);
+			_vm->_eventMan->processInput();
+			_vm->_displayMan->updateScreen();
+		}
+	} else {
+		_vm->_championMan->f296_drawChangedObjectIcons();
+		_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(L1078_T_Thing) - L1089_ui_Weight;
+		setFlag(_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
+	}
+	_vm->f064_SOUND_RequestPlay_CPSD(k08_soundSWALLOW, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
+	setFlag(L1083_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+	if (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned) {
+		setFlag(L1083_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
+	}
+	_vm->_championMan->f292_drawChampionState((ChampionIndex)L1080_ui_ChampionIndex);
+	_vm->_eventMan->f77_hideMouse();
+}
+
+void InventoryMan::f348_adjustStatisticCurrentValue(Champion* champ, uint16 statIndex, int16 valueDelta) {
+	int16 L1077_i_Multiple;
+#define AL1077_i_CurrentValue L1077_i_Multiple
+#define AL1077_i_Delta        L1077_i_Multiple
+
+	if (valueDelta >= 0) {
+		if ((AL1077_i_CurrentValue = champ->_statistics[statIndex][k1_ChampionStatCurrent]) > 120) {
+			valueDelta >>= 1;
+			if (AL1077_i_CurrentValue > 150) {
+				valueDelta >>= 1;
+			}
+			valueDelta++;
+		}
+		AL1077_i_Delta = MIN(valueDelta, (int16)(170 - AL1077_i_CurrentValue));
+	} else { /* BUG0_00 Useless code. The function is always called with valueDelta having a positive value */
+		AL1077_i_Delta = MAX(valueDelta, int16(champ->_statistics[statIndex][k2_ChampionStatMinimum] - champ->_statistics[statIndex][k1_ChampionStatCurrent]));
+	}
+	champ->_statistics[statIndex][k1_ChampionStatCurrent] += AL1077_i_Delta;
+}
+
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 106e4cd..a115c98 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -83,6 +83,8 @@ public:
 	void f351_drawChampionSkillsAndStatistics(); // @ F0351_INVENTORY_DrawChampionSkillsAndStatistics
 	void f350_drawStopPressingMouth(); // @ F0350_INVENTORY_DrawStopPressingMouth
 	void f353_drawStopPressingEye();// @ F0353_INVENTORY_DrawStopPressingEye
+	void f349_processCommand70_clickOnMouth(); // @ F0349_INVENTORY_ProcessCommand70_ClickOnMouth
+	void f348_adjustStatisticCurrentValue(Champion *champ, uint16 statIndex, int16 valueDelta); // @ F0348_INVENTORY_AdjustStatisticCurrentValue
 
 };
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index f0db59b..2931253 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -396,35 +396,32 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
 }
 
 void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
-	ChampionMan &champMan = *_vm->_championMan;
-	DisplayMan &dispMan = *_vm->_displayMan;
+	Champion* L1213_ps_Champion;
 
-	if ((champIndex == champMan._g514_magicCasterChampionIndex)
-		|| ((champIndex != kM1_ChampionNone) && !champMan._gK71_champions[champIndex]._currHealth))
+	if ((champIndex == _vm->_championMan->_g514_magicCasterChampionIndex) || ((champIndex != kM1_ChampionNone) && !_vm->_championMan->_gK71_champions[champIndex]._currHealth)) {
 		return;
-	if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) {
-		warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), dispMan._g348_bitmapScreen, g0_BoxSpellArea, 0, 0,
-								  48, k160_byteWidthScreen, kM1_ColorNoTransparency);
-		warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer");
+	}
+	if (_vm->_championMan->_g514_magicCasterChampionIndex == kM1_ChampionNone) {
+		_vm->_eventMan->f78_showMouse();
+		_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &g0_BoxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33); 
+		_vm->_eventMan->f77_hideMouse();
 	}
 	if (champIndex == kM1_ChampionNone) {
-		champMan._g514_magicCasterChampionIndex = kM1_ChampionNone;
-		warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.D24_fillScreenBox(g0_BoxSpellArea, k0_ColorBlack);
-		warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer");
+		_vm->_championMan->_g514_magicCasterChampionIndex = kM1_ChampionNone;
+		_vm->_eventMan->f78_showMouse();
+		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+		_vm->_displayMan->D24_fillScreenBox(g0_BoxSpellArea, k0_ColorBlack);
+		_vm->_eventMan->f77_hideMouse();
 		return;
 	}
-
-	champMan._g514_magicCasterChampionIndex = (ChampionIndex)champIndex;
-	f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
-	warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
-	f393_drawSpellAreaControls((ChampionIndex)champIndex);
-	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK75_BoxSpellAreaLine2, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency);
-	f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols);
-	dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency);
-	warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer");
+	L1213_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex = (ChampionIndex)champIndex];
+	_vm->_menuMan->f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
+	_vm->_eventMan->f78_showMouse();
+	_vm->_menuMan->f393_drawSpellAreaControls((ChampionIndex)champIndex);
+	_vm->_displayMan->f21_blitToScreen(_vm->_menuMan->_gK72_bitmapSpellAreaLine, &gK75_BoxSpellAreaLine2, k48_byteWidth, kM1_ColorNoTransparency, 12);
+	_vm->_menuMan->f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols);
+	_vm->_displayMan->f21_blitToScreen(_vm->_menuMan->_gK72_bitmapSpellAreaLine, &gK76_BoxSpellAreaLine3, k48_byteWidth, kM1_ColorNoTransparency, 12);
+	_vm->_eventMan->f77_hideMouse();
 }
 
 void MenuMan::f457_drawEnabledMenus() {
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 40c650b..192e661 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -259,4 +259,13 @@ void ObjectMan::f35_clearLeaderObjectName() {
 	_vm->_displayMan->D24_fillScreenBox(g28_BoxLeaderHandObjectName, k0_ColorBlack);
 }
 
+void ObjectMan::f37_drawIconToScreen(int16 iconIndex, int16 posX, int16 posY) {
+	static byte L0013_puc_Bitmap_Icon[16 * 16];
+	Box L0014_s_Box;
+
+	L0014_s_Box._x2 = (L0014_s_Box._x1 = posX) + 15;
+	L0014_s_Box._y2 = (L0014_s_Box._y1 = posY) + 15;
+	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, L0013_puc_Bitmap_Icon);
+	_vm->_displayMan->f21_blitToScreen(L0013_puc_Bitmap_Icon, &L0014_s_Box, k8_byteWidth, kM1_ColorNoTransparency, 16);
+}
 }
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index 3f90f80..3b55e19 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -65,7 +65,7 @@ public:
 	void f34_drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName
 	IconIndice f39_getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox
 	void f35_clearLeaderObjectName(); // @ F0035_OBJECT_ClearLeaderHandObjectName
-
+	void f37_drawIconToScreen(int16 iconIndex, int16 posX, int16 posY); // @ F0037_OBJECT_DrawIconToScreen
 
 };
 


Commit: 78f716e1c189f4c944efa2aa6a7817e4f66a7280
    https://github.com/scummvm/scummvm/commit/78f716e1c189f4c944efa2aa6a7817e4f66a7280
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some refactoring in gfx.cpp, refactoring of f107_isDrawnWallOrnAnAlcove

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 0f274bf..38c1e5d 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2281,30 +2281,26 @@ void DisplayMan::f94_loadFloorSet(FloorSet set) {
 	}
 }
 
-Box g161_BoxWallBitmap_D3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR
-Box g162_BoxWallBitmap_D2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR
-
 // Note: has been screened for missing code
 void DisplayMan::f95_loadWallSet(WallSet set) {
-
 	if ((_g231_currentWallSet != set) || _vm->_g523_restartGameRequest) {
 		_g231_currentWallSet = set;
-		{
-			int16 graphicIndice = (set * k13_WallSetGraphicCount) + k77_FirstWallSet;
-			f466_loadIntoBitmap(graphicIndice++, _g709_bitmapWallSet_DoorFrameFront);
-			f466_loadIntoBitmap(graphicIndice++, _g708_bitmapWallSet_DoorFrameLeft_D1C);
-			f466_loadIntoBitmap(graphicIndice++, _g707_bitmapWallSet_DoorFrameLeft_D2C);
-			f466_loadIntoBitmap(graphicIndice++, _g706_bitmapWallSet_DoorFrameLeft_D3C);
-			f466_loadIntoBitmap(graphicIndice++, _g705_bitmapWallSet_DoorFrameLeft_D3L);
-			f466_loadIntoBitmap(graphicIndice++, _g704_bitmapWallSet_DoorFrameTop_D1LCR);
-			f466_loadIntoBitmap(graphicIndice++, _g703_bitmapWallSet_DoorFrameTop_D2LCR);
-			f466_loadIntoBitmap(graphicIndice++, _g702_bitmapWallSet_Wall_D0R);
-			f466_loadIntoBitmap(graphicIndice++, _g701_bitmapWallSet_Wall_D0L);
-			f466_loadIntoBitmap(graphicIndice++, _g700_bitmapWallSet_Wall_D1LCR);
-			f466_loadIntoBitmap(graphicIndice++, _g699_bitmapWallSet_Wall_D2LCR);
-			f466_loadIntoBitmap(graphicIndice++, _g698_bitmapWallSet_Wall_D3LCR);
-			f466_loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2);
-		}
+
+		int16 graphicIndice = (set * k13_WallSetGraphicCount) + k77_FirstWallSet;
+		f466_loadIntoBitmap(graphicIndice++, _g709_bitmapWallSet_DoorFrameFront);
+		f466_loadIntoBitmap(graphicIndice++, _g708_bitmapWallSet_DoorFrameLeft_D1C);
+		f466_loadIntoBitmap(graphicIndice++, _g707_bitmapWallSet_DoorFrameLeft_D2C);
+		f466_loadIntoBitmap(graphicIndice++, _g706_bitmapWallSet_DoorFrameLeft_D3C);
+		f466_loadIntoBitmap(graphicIndice++, _g705_bitmapWallSet_DoorFrameLeft_D3L);
+		f466_loadIntoBitmap(graphicIndice++, _g704_bitmapWallSet_DoorFrameTop_D1LCR);
+		f466_loadIntoBitmap(graphicIndice++, _g703_bitmapWallSet_DoorFrameTop_D2LCR);
+		f466_loadIntoBitmap(graphicIndice++, _g702_bitmapWallSet_Wall_D0R);
+		f466_loadIntoBitmap(graphicIndice++, _g701_bitmapWallSet_Wall_D0L);
+		f466_loadIntoBitmap(graphicIndice++, _g700_bitmapWallSet_Wall_D1LCR);
+		f466_loadIntoBitmap(graphicIndice++, _g699_bitmapWallSet_Wall_D2LCR);
+		f466_loadIntoBitmap(graphicIndice++, _g698_bitmapWallSet_Wall_D3LCR);
+		f466_loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2);
+
 		f99_copyBitmapAndFlipHorizontal(_g708_bitmapWallSet_DoorFrameLeft_D1C, _g710_bitmapWallSet_DoorFrameRight_D1C,
 										g171_Frame_DoorFrameRight_D1C._srcByteWidth, g171_Frame_DoorFrameRight_D1C._srcHeight);
 		f99_copyBitmapAndFlipHorizontal(_g697_bitmapWallSet_Wall_D3L2, _g696_bitmapWallSet_Wall_D3R2,
@@ -2314,68 +2310,65 @@ void DisplayMan::f95_loadWallSet(WallSet set) {
 
 
 void DisplayMan::f96_loadCurrentMapGraphics() {
+	Box BoxWallD3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR
+	Box BoxWallD2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR
+
 	f94_loadFloorSet(_vm->_dungeonMan->_g269_currMap->_floorSet);
 	f95_loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet);
 
-	{
-		_g578_useByteBoxCoordinates = true;
-
-		f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap,
-										g163_FrameWalls[k0_ViewSquare_D3C]._srcByteWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight);
-		f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, k10_ColorFlesh, 64, 51);
-		f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, g161_BoxWallBitmap_D3LCR, 11, 0, 64, 64, kM1_ColorNoTransparency);
-
-		f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap,
-										g163_FrameWalls[k3_ViewSquare_D2C]._srcByteWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight);
-		f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, k10_ColorFlesh, 72, 71);
-		f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, g162_BoxWallBitmap_D2LCR, 8, 0, 72, 72, kM1_ColorNoTransparency);
-
-		f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped,
-										g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight);
-		f99_copyBitmapAndFlipHorizontal(_g98_bitmapWall_D0L_Native = _g701_bitmapWallSet_Wall_D0L, _g94_bitmapWall_D0R_Flipped,
-										g163_FrameWalls[k10_ViewSquare_D0L]._srcByteWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight);
-		f99_copyBitmapAndFlipHorizontal(_g99_bitmapWall_D0R_Native = _g702_bitmapWallSet_Wall_D0R, _g93_bitmapWall_D0L_Flipped,
-										g163_FrameWalls[k10_ViewSquare_D0L]._srcByteWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight);
-	}
-
-
-	{
-		int16 val = _vm->_dungeonMan->_g269_currMap->_wallSet * k18_StairsGraphicCount + k90_FirstStairs;
-		_g675_stairsNativeBitmapIndex_Up_Front_D3L = val++;
-		_g676_stairsNativeBitmapIndex_Up_Front_D3C = val++;
-		_g677_stairsNativeBitmapIndex_Up_Front_D2L = val++;
-		_g678_stairsNativeBitmapIndex_Up_Front_D2C = val++;
-		_g679_stairsNativeBitmapIndex_Up_Front_D1L = val++;
-		_g680_stairsNativeBitmapIndex_Up_Front_D1C = val++;
-		_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left = val++;
-		_g682_stairsNativeBitmapIndex_Down_Front_D3L = val++;
-		_g683_stairsNativeBitmapIndex_Down_Front_D3C = val++;
-		_g684_stairsNativeBitmapIndex_Down_Front_D2L = val++;
-		_g685_stairsNativeBitmapIndex_Down_Front_D2C = val++;
-		_g686_stairsNativeBitmapIndex_Down_Front_D1L = val++;
-		_g687_stairsNativeBitmapIndex_Down_Front_D1C = val++;
-		_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left = val++;
-		_g689_stairsNativeBitmapIndex_Side_D2L = val++;
-		_g690_stairsNativeBitmapIndex_Up_Side_D1L = val++;
-		_g691_stairsNativeBitmapIndex_Down_Side_D1L = val++;
-		_g692_stairsNativeBitmapIndex_Side_D0L = val++;
-	}
+	_g578_useByteBoxCoordinates = true;
+
+	f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap,
+									g163_FrameWalls[k0_ViewSquare_D3C]._srcByteWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight);
+	f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, k10_ColorFlesh, 64, 51);
+	f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, BoxWallD3LCR, 11, 0, 64, 64, kM1_ColorNoTransparency);
+
+	f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap,
+									g163_FrameWalls[k3_ViewSquare_D2C]._srcByteWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight);
+	f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, k10_ColorFlesh, 72, 71);
+	f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, BoxWallD2LCR, 8, 0, 72, 72, kM1_ColorNoTransparency);
+
+	f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped,
+									g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight);
+	f99_copyBitmapAndFlipHorizontal(_g98_bitmapWall_D0L_Native = _g701_bitmapWallSet_Wall_D0L, _g94_bitmapWall_D0R_Flipped,
+									g163_FrameWalls[k10_ViewSquare_D0L]._srcByteWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight);
+	f99_copyBitmapAndFlipHorizontal(_g99_bitmapWall_D0R_Native = _g702_bitmapWallSet_Wall_D0R, _g93_bitmapWall_D0L_Flipped,
+									g163_FrameWalls[k10_ViewSquare_D0L]._srcByteWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight);
+
+	int16 val = _vm->_dungeonMan->_g269_currMap->_wallSet * k18_StairsGraphicCount + k90_FirstStairs;
+	_g675_stairsNativeBitmapIndex_Up_Front_D3L = val++;
+	_g676_stairsNativeBitmapIndex_Up_Front_D3C = val++;
+	_g677_stairsNativeBitmapIndex_Up_Front_D2L = val++;
+	_g678_stairsNativeBitmapIndex_Up_Front_D2C = val++;
+	_g679_stairsNativeBitmapIndex_Up_Front_D1L = val++;
+	_g680_stairsNativeBitmapIndex_Up_Front_D1C = val++;
+	_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left = val++;
+	_g682_stairsNativeBitmapIndex_Down_Front_D3L = val++;
+	_g683_stairsNativeBitmapIndex_Down_Front_D3C = val++;
+	_g684_stairsNativeBitmapIndex_Down_Front_D2L = val++;
+	_g685_stairsNativeBitmapIndex_Down_Front_D2C = val++;
+	_g686_stairsNativeBitmapIndex_Down_Front_D1L = val++;
+	_g687_stairsNativeBitmapIndex_Down_Front_D1C = val++;
+	_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left = val++;
+	_g689_stairsNativeBitmapIndex_Side_D2L = val++;
+	_g690_stairsNativeBitmapIndex_Up_Side_D1L = val++;
+	_g691_stairsNativeBitmapIndex_Down_Side_D1L = val++;
+	_g692_stairsNativeBitmapIndex_Side_D0L = val++;
 
 	for (int16 i = 0; i < k3_AlcoveOrnCount; ++i)
 		_g267_currMapAlcoveOrnIndices[i] = -1;
+
 	for (int16 i = 0; i < k1_FountainOrnCount; ++i)
 		_g268_currMapFountainOrnIndices[i] = -1;
 
-	{
-		uint16 doorSets[2];
-		doorSets[0] = _vm->_dungeonMan->_g269_currMap->_doorSet0;
-		doorSets[1] = _vm->_dungeonMan->_g269_currMap->_doorSet1;
-		for (uint16 doorSet = 0; doorSet <= 1; doorSet++) {
-			int16 counter = k108_FirstDoorSet + (doorSets[doorSet] * k3_DoorSetGraphicsCount);
-			_g693_doorNativeBitmapIndex_Front_D3LCR[doorSet] = counter++;
-			_g694_doorNativeBitmapIndex_Front_D2LCR[doorSet] = counter++;
-			_g695_doorNativeBitmapIndex_Front_D1LCR[doorSet] = counter++;
-		}
+	uint16 doorSets[2];
+	doorSets[0] = _vm->_dungeonMan->_g269_currMap->_doorSet0;
+	doorSets[1] = _vm->_dungeonMan->_g269_currMap->_doorSet1;
+	for (uint16 doorSet = 0; doorSet <= 1; doorSet++) {
+		int16 counter = k108_FirstDoorSet + (doorSets[doorSet] * k3_DoorSetGraphicsCount);
+		_g693_doorNativeBitmapIndex_Front_D3LCR[doorSet] = counter++;
+		_g694_doorNativeBitmapIndex_Front_D2LCR[doorSet] = counter++;
+		_g695_doorNativeBitmapIndex_Front_D1LCR[doorSet] = counter++;
 	}
 
 	uint16 alcoveCount = 0;
@@ -2397,9 +2390,10 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 			}
 		}
 
-		for (uint16 ornCounter = 0; ornCounter < k1_FountainOrnCount; ++ornCounter)
+		for (uint16 ornCounter = 0; ornCounter < k1_FountainOrnCount; ++ornCounter) {
 			if (ornIndice == g193_FountainOrnIndices[ornCounter])
 				_g268_currMapFountainOrnIndices[fountainCount++] = i;
+		}
 
 		_g101_currMapWallOrnInfo[i][k1_CoordinateSet] = g194_WallOrnCoordSetIndices[ornIndice];
 	}
@@ -2426,6 +2420,7 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 		uint16 replColorOrdinal = aspect.getReplColour9();
 		if (replColorOrdinal)
 			f93_applyCreatureReplColors(9, _vm->M1_ordinalToIndex(replColorOrdinal));
+
 		replColorOrdinal = aspect.getReplColour10();
 		if (replColorOrdinal)
 			f93_applyCreatureReplColors(10, _vm->M1_ordinalToIndex(replColorOrdinal));
@@ -2455,198 +2450,169 @@ void DisplayMan::f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativ
 	}
 }
 
-
-Box g202_BoxWallPatchBehindInscription = Box(110, 113, 37, 63); // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription 
-byte g203_InscriptionLineY[4] = { // @ G0203_auc_Graphic558_InscriptionLineY
-	48,   /* 1 Line  */
-	59,   /* 2 lines */
-	75,   /* 3 lines */
-	86}; /* 4 lines */
-byte g190_WallOrnDerivedBitmapIndexIncrement[12] = { // @ G0190_auc_Graphic558_WallOrnamentDerivedBitmapIndexIncrement
-	0,   /* D3L Right */
-	0,   /* D3R Left */
-	1,   /* D3L Front */
-	1,   /* D3C Front */
-	1,   /* D3R Front */
-	2,   /* D2L Right */
-	2,   /* D2R Left */
-	3,   /* D2L Front */
-	3,   /* D2C Front */
-	3,   /* D2R Front */
-	4,   /* D1L Right */
-	4}; /* D1R Left */
-
-
-byte g204_UnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableInscriptionBoxY2
-	/* { Y for 1 line, Y for 2 lines, Y for 3 lines } */
-	45, 48, 53,   /* D3L Right, D3R Left */
-	43, 49, 56,   /* D3L Front, D3C Front, D3R Front */
-	42, 49, 56,   /* D2L Right, D2R Left */
-	46, 53, 63,   /* D2L Front, D2C Front, D2R Front */
-	46, 57, 68}; /* D1L Right, D1R Left */
-
-Box g109_BoxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall
-
 bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) {
-#define AP0116_i_CharacterCount    wallOrnOrd
-#define AP0116_i_WallOrnamentIndex wallOrnOrd
-	int16 L0088_i_Multiple;
-#define AL0088_i_NativeBitmapIndex       L0088_i_Multiple
-#define AL0088_i_UnreadableTextLineCount L0088_i_Multiple
-	int16 L0089_i_Multiple;
-#define AL0089_i_WallOrnamentCoordinateSetIndex L0089_i_Multiple
-#define AL0089_i_FountainOrnamentIndex          L0089_i_Multiple
-#define AL0089_i_PixelWidth                     L0089_i_Multiple
-#define AL0089_i_X                              L0089_i_Multiple
-
-	uint16 *AL0090_puc_CoordinateSet = nullptr;
-
-	byte* L0091_puc_Multiple;
-#define AL0091_puc_Character     L0091_puc_Multiple
-#define AL0091_puc_Bitmap        L0091_puc_Multiple
-	byte* L0092_puc_Bitmap;
-	int16 L0093_i_CoordinateSetOffset;
-	bool L0094_B_FlipHorizontal;
-	bool L0095_B_IsInscription;
-	bool L0096_B_IsAlcove;
-	int16 L0097_i_TextLineIndex;
-	uint16 tmp[6];
-	byte L0099_auc_InscriptionString[70];
-
+	static const Box boxWallPatchBehindInscription = Box(110, 113, 37, 63); // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription 
+	static const byte inscriptionLineY[4] = { // @ G0203_auc_Graphic558_InscriptionLineY
+		48,   /* 1 Line  */
+		59,   /* 2 lines */
+		75,   /* 3 lines */
+		86    /* 4 lines */
+	};
+	static const byte wallOrnDerivedBitmapIndexIncrement[12] = { // @ G0190_auc_Graphic558_WallOrnamentDerivedBitmapIndexIncrement
+		0,   /* D3L Right */
+		0,   /* D3R Left */
+		1,   /* D3L Front */
+		1,   /* D3C Front */
+		1,   /* D3R Front */
+		2,   /* D2L Right */
+		2,   /* D2R Left */
+		3,   /* D2L Front */
+		3,   /* D2C Front */
+		3,   /* D2R Front */
+		4,   /* D1L Right */
+		4    /* D1R Left */
+	};
+
+	static const byte unreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableInscriptionBoxY2
+		/* { Y for 1 line, Y for 2 lines, Y for 3 lines } */
+		45, 48, 53,   /* D3L Right, D3R Left */
+		43, 49, 56,   /* D3L Front, D3C Front, D3R Front */
+		42, 49, 56,   /* D2L Right, D2R Left */
+		46, 53, 63,   /* D2L Front, D2C Front, D2R Front */
+		46, 57, 68    /* D1L Right, D1R Left */
+	};
+
+	static const Box boxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall
 
 	if (wallOrnOrd) {
-		wallOrnOrd--;
-		AL0088_i_NativeBitmapIndex = _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k0_NativeBitmapIndex];
-
-		AL0090_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex =
-			_g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k1_CoordinateSet]][viewWallIndex];
-
-		L0096_B_IsAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(AP0116_i_WallOrnamentIndex);
-		if (L0095_B_IsInscription = (AP0116_i_WallOrnamentIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex)) {
-			_vm->_dungeonMan->f168_decodeText((char *)L0099_auc_InscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
-		}
+		int16 wallOrnamentIndex = wallOrnOrd - 1;
+		int16 nativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnamentIndex][k0_NativeBitmapIndex];
+		int16 wallOrnamentCoordinateSetIndex = _g101_currMapWallOrnInfo[wallOrnamentIndex][k1_CoordinateSet];
+		uint16 *coordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][viewWallIndex];
+
+		bool isAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(wallOrnamentIndex);
+		bool isInscription = (wallOrnamentIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex);
+		byte inscriptionString[70];
+		if (isInscription)
+			_vm->_dungeonMan->f168_decodeText((char *)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
+
+		byte *displayBitmap;
+		int16 boxSrcX;
 		if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) {
 			if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
-				if (L0095_B_IsInscription) {
+				if (isInscription) {
 					f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport,
-									  g202_BoxWallPatchBehindInscription, 94, 28,
+									  (Box &)boxWallPatchBehindInscription, 94, 28,
 									  g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth,
 									  k112_byteWidthViewport, kM1_ColorNoTransparency, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport);
-					byte *AL0090_puc_String = L0099_auc_InscriptionString;
-					L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont);
-					L0097_i_TextLineIndex = 0;
+					byte *tmpString = inscriptionString;
+					byte *fontBitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont);
+					int16 textLineIndex = 0;
 					do {
-						AP0116_i_CharacterCount = 0;
-						AL0091_puc_Character = AL0090_puc_String;
-						while (*AL0091_puc_Character++ < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
-							AP0116_i_CharacterCount++;
+						int16 characterCount = 0;
+						byte *curCharacter = tmpString;
+						while (*curCharacter++ < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
+							characterCount++;
 						}
-						Frame L0098_s_Frame;
-						L0098_s_Frame._box._x2 = (L0098_s_Frame._box._x1 = 112 - (AP0116_i_CharacterCount << 2)) + 7;
-						L0098_s_Frame._box._y1 = (L0098_s_Frame._box._y2 = g203_InscriptionLineY[L0097_i_TextLineIndex++]) - 7;
-						while (AP0116_i_CharacterCount--) {
-							f132_blitToBitmap(L0092_puc_Bitmap, _g296_bitmapViewport, L0098_s_Frame._box,
-											  *AL0090_puc_String++ << 3, 0, 144, k112_byteWidthViewport, k10_ColorFlesh, 8, k136_heightViewport);
-							L0098_s_Frame._box._x1 += 8;
-							L0098_s_Frame._box._x2 += 8;
+						Frame curFrame;
+						curFrame._box._x2 = (curFrame._box._x1 = 112 - (characterCount << 2)) + 7;
+						curFrame._box._y1 = (curFrame._box._y2 = inscriptionLineY[textLineIndex++]) - 7;
+						while (characterCount--) {
+							f132_blitToBitmap(fontBitmap, _g296_bitmapViewport, curFrame._box,
+											  *tmpString++ << 3, 0, 144, k112_byteWidthViewport, k10_ColorFlesh, 8, k136_heightViewport);
+							curFrame._box._x1 += 8;
+							curFrame._box._x2 += 8;
 						}
-					} while (*AL0090_puc_String++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
-					goto T0107031;
+					} while (*tmpString++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
+					return isAlcove;
 				}
-				AL0088_i_NativeBitmapIndex++;
-				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = AL0090_puc_CoordinateSet[0];
-				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = AL0090_puc_CoordinateSet[1];
-				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = AL0090_puc_CoordinateSet[2];
-				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = AL0090_puc_CoordinateSet[3];
+				nativeBitmapIndex++;
+				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordinateSet[0];
+				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordinateSet[1];
+				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordinateSet[2];
+				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordinateSet[3];
 
-				_vm->_dungeonMan->_g286_isFacingAlcove = L0096_B_IsAlcove;
+				_vm->_dungeonMan->_g286_isFacingAlcove = isAlcove;
 				_vm->_dungeonMan->_g287_isFacingViAltar =
-					(AP0116_i_WallOrnamentIndex == _g266_currMapViAltarIndex);
+					(wallOrnamentIndex == _g266_currMapViAltarIndex);
 				_vm->_dungeonMan->_g288_isFacingFountain = false;
-				for (AL0089_i_FountainOrnamentIndex = 0; AL0089_i_FountainOrnamentIndex < k1_FountainOrnCount; AL0089_i_FountainOrnamentIndex++) {
-					if (_g268_currMapFountainOrnIndices[AL0089_i_FountainOrnamentIndex] == AP0116_i_WallOrnamentIndex) {
+				for (int16 idx = 0; idx < k1_FountainOrnCount; idx++) {
+					if (_g268_currMapFountainOrnIndices[idx] == wallOrnamentIndex) {
 						_vm->_dungeonMan->_g288_isFacingFountain = true;
 						break;
 					}
 				}
 			}
-			AL0091_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
+			displayBitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
 			if (viewWallIndex == k11_ViewWall_D1R_LEFT) {
-				f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]);
-				AL0091_puc_Bitmap = _g74_tmpBitmap;
+				f99_copyBitmapAndFlipHorizontal(displayBitmap, _g74_tmpBitmap, coordinateSet[4], coordinateSet[5]);
+				displayBitmap = _g74_tmpBitmap;
 			}
-			AL0089_i_X = 0;
+			boxSrcX = 0;
 		} else {
-			uint16 *AL0091_puc_CoordinateSet;
-			L0093_i_CoordinateSetOffset = 0;
-			if (L0094_B_FlipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT)) {
-				AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k11_ViewWall_D1R_LEFT];
-			} else {
-				if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT)) {
-					AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k10_ViewWall_D1L_RIGHT];
-				} else {
-					AL0088_i_NativeBitmapIndex++;
-					AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k12_ViewWall_D1C_FRONT];
-					if (viewWallIndex == k7_ViewWall_D2L_FRONT) {
-						L0093_i_CoordinateSetOffset = 6;
-					} else {
-						if (viewWallIndex == k9_ViewWall_D2R_FRONT) {
-							L0093_i_CoordinateSetOffset = -6;
-						}
-					}
-				}
+			uint16 *coordinateSet;
+			int16 coordinateSetOffset = 0;
+			bool flipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT);
+			if (flipHorizontal || (viewWallIndex == k1_ViewWall_D3R_LEFT)) {
+				coordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k11_ViewWall_D1R_LEFT];
+			} else if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT))
+				coordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k10_ViewWall_D1L_RIGHT];
+			else {
+				nativeBitmapIndex++;
+				coordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k12_ViewWall_D1C_FRONT];
+				if (viewWallIndex == k7_ViewWall_D2L_FRONT)
+					coordinateSetOffset = 6;
+				else if (viewWallIndex == k9_ViewWall_D2R_FRONT)
+					coordinateSetOffset = -6;
 			}
-			AL0089_i_PixelWidth = (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[1] - (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[0];
-			if (!f491_isDerivedBitmapInCache(AP0116_i_WallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament +
-				(AP0116_i_WallOrnamentIndex << 2) + g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex])) {
-				L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex),
-													 AL0091_puc_CoordinateSet[4] << 1,
-													 AL0091_puc_CoordinateSet[5], AL0089_i_PixelWidth + 1,
-													 AL0090_puc_CoordinateSet[5],
+			int16 pixelWidth = (coordinateSet + coordinateSetOffset)[1] - (coordinateSet + coordinateSetOffset)[0];
+			wallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + (wallOrnamentIndex << 2) + wallOrnDerivedBitmapIndexIncrement[viewWallIndex];
+			if (!f491_isDerivedBitmapInCache(wallOrnamentIndex)) {
+				byte *L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+				f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(wallOrnamentIndex),
+													 coordinateSet[4] << 1,
+													 coordinateSet[5], pixelWidth + 1,
+													 coordinateSet[5],
 													 (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
-				f493_addDerivedBitmap(AP0116_i_WallOrnamentIndex);
-			}
-			AL0091_puc_Bitmap = f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex);
-			if (L0094_B_FlipHorizontal) {
-				f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]);
-				AL0091_puc_Bitmap = _g74_tmpBitmap;
-				AL0089_i_X = 15 - (AL0089_i_X & 0x000F);
-			} else {
-				if (viewWallIndex == k7_ViewWall_D2L_FRONT) {
-					AL0089_i_X -= AL0090_puc_CoordinateSet[1] - AL0090_puc_CoordinateSet[0];
-				} else {
-					AL0089_i_X = 0;
-				}
+				f493_addDerivedBitmap(wallOrnamentIndex);
 			}
+			displayBitmap = f492_getDerivedBitmap(wallOrnamentIndex);
+			if (flipHorizontal) {
+				f99_copyBitmapAndFlipHorizontal(displayBitmap, _g74_tmpBitmap, coordinateSet[4], coordinateSet[5]);
+				displayBitmap = _g74_tmpBitmap;
+				boxSrcX = 15 - (boxSrcX & 0x000F);
+			} else if (viewWallIndex == k7_ViewWall_D2L_FRONT)
+				boxSrcX = pixelWidth - (coordinateSet[1] - coordinateSet[0]);
+			else
+				boxSrcX = 0;
 		}
-		if (L0095_B_IsInscription) {
-			byte *AL0090_puc_String = L0099_auc_InscriptionString;
-			AL0088_i_UnreadableTextLineCount = 0;
+		if (isInscription) {
+			byte *tmpString = inscriptionString;
+			int16 unreadableTextLineCount = 0;
 			do {
-				while (*AL0090_puc_String < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
-					AL0090_puc_String++;
+				while (*tmpString < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
+					tmpString++;
 				}
-				AL0088_i_UnreadableTextLineCount++;
-			} while (*AL0090_puc_String++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
-			if (AL0088_i_UnreadableTextLineCount < 4) {
+				unreadableTextLineCount++;
+			} while (*tmpString++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
+			if (unreadableTextLineCount < 4) {
+				uint16 tmp[6];
 				for (uint16 i = 0; i < 6; ++i)
-					tmp[i] = AL0090_puc_CoordinateSet[i];
-				AL0090_puc_CoordinateSet = tmp;
-				AL0090_puc_CoordinateSet[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + AL0088_i_UnreadableTextLineCount - 1];
+					tmp[i] = coordinateSet[i];
+				coordinateSet = tmp;
+				coordinateSet[3] = unreadableInscriptionBoxY2[wallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
 			}
 		}
-		f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport,
-						  *(Box *)AL0090_puc_CoordinateSet, AL0089_i_X, 0,
-						  AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport);
+		f132_blitToBitmap(displayBitmap, _g296_bitmapViewport,
+						  *(Box *)coordinateSet, boxSrcX, 0,
+						  coordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, coordinateSet[5], k136_heightViewport);
 		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
 			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice),
-							  _g296_bitmapViewport, g109_BoxChampionPortraitOnWall,
+							  _g296_bitmapViewport, (Box &)boxChampionPortraitOnWall,
 							  (_g289_championPortraitOrdinal & 0x0007) << 5,
 							  (_g289_championPortraitOrdinal >> 3) * 29, 128, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport);
 		}
-T0107031:
-		return L0096_B_IsAlcove;
+		return isAlcove;
 	}
 	return false;
 }


Commit: 800aec5d57375b4f23d071ead1d52d7700e2e36a
    https://github.com/scummvm/scummvm/commit/800aec5d57375b4f23d071ead1d52d7700e2e36a
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove duplicate array

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index de0ed3e..143aa42 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -40,47 +40,6 @@
 
 namespace DM {
 
-uint16 g38_slotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks
-	/* 30 for champion inventory, 8 for chest */
-	0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Action Hand      Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0x0002,   /* Head             Head */
-	0x0008,   /* Torso            Torso */
-	0x0010,   /* Legs             Legs */
-	0x0020,   /* Feet             Feet */
-	0x0100,   /* Pouch 2          Pouch */
-	0x0080,   /* Quiver Line2 1   Quiver 2 */
-	0x0080,   /* Quiver Line1 2   Quiver 2 */
-	0x0080,   /* Quiver Line2 2   Quiver 2 */
-	0x0004,   /* Neck             Neck */
-	0x0100,   /* Pouch 1          Pouch */
-	0x0040,   /* Quiver Line1 1   Quiver 1 */
-	0xFFFF,   /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0x0400,   /* Chest 1          Chest */
-	0x0400,   /* Chest 2          Chest */
-	0x0400,   /* Chest 3          Chest */
-	0x0400,   /* Chest 4          Chest */
-	0x0400,   /* Chest 5          Chest */
-	0x0400,   /* Chest 6          Chest */
-	0x0400,   /* Chest 7          Chest */
-	0x0400}; /* Chest 8          Chest */
-
 const char *g417_baseSkillName[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"};
 
 Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
@@ -1281,7 +1240,7 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex)
 	if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none))
 		return;
 
-	if ((leaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & g38_slotMasks[slotIndex])))
+	if ((leaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & gSlotMasks[slotIndex])))
 		return;
 
 	_vm->_eventMan->f78_showMouse();


Commit: 8540fdc800976e67039cfa253673b8a32a8879d2
    https://github.com/scummvm/scummvm/commit/8540fdc800976e67039cfa253673b8a32a8879d2
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some rework in f303_getSkillLevel

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 143aa42..b88864f 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -2436,24 +2436,24 @@ T0281033_ProceedToTitle:
 }
 
 uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, uint16 skillIndex) {
-	if (_vm->_championMan->_g300_partyIsSleeping) {
+	if (_vm->_championMan->_g300_partyIsSleeping)
 		return 1;
-	}
+
 	bool ignoreTmpExp = getFlag(skillIndex, k0x8000_IgnoreTemporaryExperience);
 	bool ignoreObjModifiers = getFlag(skillIndex, k0x4000_IgnoreObjectModifiers);
 	clearFlag(skillIndex, k0x8000_IgnoreTemporaryExperience | k0x4000_IgnoreObjectModifiers);
 	Champion *champ = &_vm->_championMan->_gK71_champions[champIndex];
 	Skill *skill = &champ->_skills[skillIndex];
 	int32 exp = skill->_experience;
-	if (!ignoreTmpExp) {
+	if (!ignoreTmpExp)
 		exp += skill->_temporaryExperience;
-	}
+
 	if (skillIndex > k3_ChampionSkillWizard) { /* Hidden skill */
 		skill = &champ->_skills[(skillIndex - k4_ChampionSkillSwing) >> 2];
 		exp += skill->_experience; /* Add experience in the base skill */
-		if (!ignoreTmpExp) {
+		if (!ignoreTmpExp)
 			exp += skill->_temporaryExperience;
-		}
+
 		exp >>= 1; /* Halve experience to get average of base skill + hidden skill experience */
 	}
 	int16 skillLevel = 1;
@@ -2462,35 +2462,33 @@ uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, uint16 skillIndex) {
 		skillLevel++;
 	}
 	if (!ignoreObjModifiers) {
-		int16 actionHandIconIndex;
-		if ((actionHandIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand])) == k27_IconIndiceWeaponTheFirestaff) {
+		int16 actionHandIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
+		if (actionHandIconIndex == k27_IconIndiceWeaponTheFirestaff)
 			skillLevel++;
-		} else {
-			if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete) {
-				skillLevel += 2;
-			}
-		}
+		else if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete)
+			skillLevel += 2;
+
 		int16 neckIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k10_ChampionSlotNeck]);
 		switch (skillIndex) {
 		case k3_ChampionSkillWizard:
-			if (neckIconIndex == k124_IconIndiceJunkPendantFeral) {
+			if (neckIconIndex == k124_IconIndiceJunkPendantFeral)
 				skillLevel += 1;
-			}
-			break;
-		case k15_ChampionSkillDefend:
-			if (neckIconIndex == k121_IconIndiceJunkEkkhardCross) {
-				skillLevel += 1;
-			}
 			break;
 		case k13_ChampionSkillHeal:
-			if ((neckIconIndex == k120_IconIndiceJunkGemOfAges) || (actionHandIconIndex == k66_IconIndiceWeaponSceptreOfLyf)) { /* The skill modifiers of these two objects are not cumulative */
+			// The skill modifiers of these two objects are not cumulative
+			if ((neckIconIndex == k120_IconIndiceJunkGemOfAges) || (actionHandIconIndex == k66_IconIndiceWeaponSceptreOfLyf)) 
 				skillLevel += 1;
-			}
 			break;
 		case k14_ChampionSkillInfluence:
-			if (neckIconIndex == k122_IconIndiceJunkMoonstone) {
+			if (neckIconIndex == k122_IconIndiceJunkMoonstone)
 				skillLevel += 1;
-			}
+			break;
+		case k15_ChampionSkillDefend:
+			if (neckIconIndex == k121_IconIndiceJunkEkkhardCross)
+				skillLevel += 1;
+			break;
+		default:
+			break;
 		}
 	}
 	return skillLevel;


Commit: 6e9fbffce30763f52c9634c5217ea96788904f6e
    https://github.com/scummvm/scummvm/commit/6e9fbffce30763f52c9634c5217ea96788904f6e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f352_processCommand71_clickOnEye, setting _g597_ignoreMouseMovements now prevents mouse movement

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.cpp
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 3bbcf6b..3a91564 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -35,3 +35,5 @@ Finish stuff:
 	Missing main loop methods
 	Save file f433_processCommand140_saveGame fails silently
 
+Refactoring
+	Places implementing mini mainloop and where input doesn't really matter should call discardInput instead of processInput
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 83e07eb..16bfe4d 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -596,12 +596,15 @@ Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Eve
 		case Common::EVENT_RBUTTONUP: {
 			MouseButton button = (event.type == Common::EVENT_LBUTTONDOWN) ? k1_LeftMouseButton : k2_RightMouseButton;
 			_g558_mouseButtonStatus &= ~button;
+			f544_resetPressingEyeOrMouth();
 			break;
 		}
 		default:
 			break;
 		}
 	}
+	if (_g597_ignoreMouseMovements)
+		setMousePos(_mousePos);
 	return Common::EVENT_INVALID;
 }
 
@@ -722,7 +725,7 @@ void EventManager::f380_processCommandQueue() {
 		return;
 	}
 	if (cmdType == k71_CommandClickOnEye) {
-		warning(false, "MISSING CODE: F0352_INVENTORY_ProcessCommand71_ClickOnEye();");
+		_vm->_inventoryMan->f352_processCommand71_clickOnEye();
 		return;
 	}
 	if (cmdType == k80_CommandClickInDungeonView) {
@@ -1523,4 +1526,15 @@ void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX,
 		}
 	}
 }
+
+void EventManager::f544_resetPressingEyeOrMouth() {
+	if (_vm->_g331_pressingEye) {
+		_g597_ignoreMouseMovements = false;
+		_vm->_g332_stopPressingEye = true;
+	}
+	if (_vm->_g333_pressingMouth) {
+		_g597_ignoreMouseMovements = false;
+		_vm->_g334_stopPressingMouth = true;
+	}
+}
 } // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index a12cc2e..3cf5478 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -316,7 +316,7 @@ public:
 	void f370_commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY); // @ F0370_COMMAND_ProcessType100_ClickInSpellArea
 	void f369_commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType); // @ F0369_COMMAND_ProcessTypes101To108_ClickInSpellSymbolsArea_CPSE
 	void f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY); // @ F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE
-
+	void f544_resetPressingEyeOrMouth();// @ F0544_INPUT_ResetPressingEyeOrMouth
 };
 
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 38c1e5d..ef2118f 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1235,6 +1235,7 @@ void DisplayMan::f97_drawViewport(int16 palSwitchingRequestedState) {
 	} else {
 		f565_viewportSetPalette(nullptr, nullptr);
 	}
+	updateScreen();
 }
 
 byte *DisplayMan::getCurrentVgaBuffer() {
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 52e70d4..9ecfed1 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -939,4 +939,26 @@ void InventoryMan::f348_adjustStatisticCurrentValue(Champion* champ, uint16 stat
 	champ->_statistics[statIndex][k1_ChampionStatCurrent] += AL1077_i_Delta;
 }
 
+void InventoryMan::f352_processCommand71_clickOnEye() {
+	_vm->_eventMan->_g597_ignoreMouseMovements = true;
+	_vm->_g331_pressingEye = true;
+	if (!_vm->_eventMan->isMouseButtonDown(k1_LeftMouseButton)) {
+		_vm->_eventMan->_g597_ignoreMouseMovements = false;
+		_vm->_g331_pressingEye = false;
+		_vm->_g332_stopPressingEye = false;
+		return;
+	}
+	_vm->_eventMan->f357_discardAllInput();
+	_vm->_eventMan->f78_showMouse();
+	_vm->f22_delay(8);
+	_vm->_inventoryMan->f332_drawIconToViewport(k203_IconIndiceEyeLooking, 12, 13);
+	if (_vm->_championMan->_g415_leaderEmptyHanded) {
+		f351_drawChampionSkillsAndStatistics();
+	} else {
+		_vm->_objectMan->f35_clearLeaderObjectName();
+		_vm->_inventoryMan->f342_drawPanelObject(_vm->_championMan->_g414_leaderHandObject, true);
+	}
+	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+
+}
 }
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index a115c98..7617a9d 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -85,6 +85,7 @@ public:
 	void f353_drawStopPressingEye();// @ F0353_INVENTORY_DrawStopPressingEye
 	void f349_processCommand70_clickOnMouth(); // @ F0349_INVENTORY_ProcessCommand70_ClickOnMouth
 	void f348_adjustStatisticCurrentValue(Champion *champ, uint16 statIndex, int16 valueDelta); // @ F0348_INVENTORY_AdjustStatisticCurrentValue
+	void f352_processCommand71_clickOnEye(); // @ F0352_INVENTORY_ProcessCommand71_ClickOnEye
 
 };
 


Commit: 6bbd68199c002fb4a9532f1e87ac182b2d9b386f
    https://github.com/scummvm/scummvm/commit/6bbd68199c002fb4a9532f1e87ac182b2d9b386f
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing call to f379_drawSleepScreen, fix bytewidth bug in f379_drawSleepScreen

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 16bfe4d..b30292e 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -748,7 +748,7 @@ void EventManager::f380_processCommandQueue() {
 			}
 			_vm->_menuMan->f456_drawDisabledMenu();
 			_vm->_championMan->_g300_partyIsSleeping = true;
-			warning(false, "MISSING CODE: F0379_COMMAND_DrawSleepScreen();");
+			f379_drawSleepScreen();
 			_vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
 			_vm->_g318_waitForInputMaxVerticalBlankCount = 0;
 			_vm->_eventMan->_g441_primaryMouseInput = g450_PrimaryMouseInput_PartySleeping;
@@ -1297,7 +1297,7 @@ bool EventManager::f360_hasPendingClick(Common::Point& point, MouseButton button
 }
 
 void EventManager::f379_drawSleepScreen() {
-	_vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 224, 136); // TODO: localization
+	_vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 112, 136); // TODO: localization
 }
 
 void EventManager::f357_discardAllInput() {


Commit: ac9f4d7d4473e871db3e55c044eb109b339d08c3
    https://github.com/scummvm/scummvm/commit/ac9f4d7d4473e871db3e55c044eb109b339d08c3
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add some missing calls to already implemented methods

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/menus.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 3a91564..4fb935f 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -34,6 +34,15 @@ Finish stuff:
 	f380_processCommandQueue
 	Missing main loop methods
 	Save file f433_processCommand140_saveGame fails silently
+	Sounds
+	F0438_STARTEND_OpenEntranceDoors
+	F0442_STARTEND_ProcessCommand202_EntranceDrawCredits
+	G0335_ui_SelectedDialogChoice
+	Add dialogs
+	Add failcheck to saveing and loading
+	F0444_STARTEND_Endgame
+	F0385_MENUS_DrawActionDamage
 
 Refactoring
 	Places implementing mini mainloop and where input doesn't really matter should call discardInput instead of processInput
+	While reanming a champion, the mouse lags
\ No newline at end of file
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index b30292e..90f2205 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1209,7 +1209,7 @@ void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) {
 			return;
 		commandType = f358_getCommandTypeFromMouseInput(g456_MouseInput_PanelChest, Common::Point(x, y), k1_LeftMouseButton);
 		if (commandType != k0_CommandNone)
-			warning(false, "MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox");
+			_vm->_championMan->f302_processCommands28to65_clickOnSlotBox(commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand); 
 		break;
 	case k5_PanelContentResurrectReincarnate:
 		if (!champMan._g415_leaderEmptyHanded)
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index ef2118f..b76792b 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1252,7 +1252,6 @@ uint16 DisplayMan::getPixelHeight(uint16 index) {
 	return READ_BE_UINT16(data + 2);
 }
 
-// Note: has been screened for missing code
 void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitmap, uint16 byteWidth, uint16 height) {
 	memmove(destBitmap, srcBitmap, byteWidth * 2 * height * sizeof(byte));
 	f130_flipBitmapHorizontal(destBitmap, byteWidth, height);
@@ -1462,7 +1461,6 @@ void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) {
 }
 
 
-// NOTE: has been screened for missing code
 void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 	static DoorFrames g179_doorFrame_D3L = DoorFrames( // @ G0179_s_Graphic558_Frames_Door_D3L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
@@ -2272,7 +2270,6 @@ void DisplayMan::f134_fillBitmap(byte *bitmap, Color color, uint16 byteWidth, ui
 	memset(bitmap, color, sizeof(byte) * width * height);
 }
 
-// NOTE: has been screened for missing code
 void DisplayMan::f94_loadFloorSet(FloorSet set) {
 	if (_g230_currentFloorSet != set) {
 		_g230_currentFloorSet = set;
@@ -2282,7 +2279,6 @@ void DisplayMan::f94_loadFloorSet(FloorSet set) {
 	}
 }
 
-// Note: has been screened for missing code
 void DisplayMan::f95_loadWallSet(WallSet set) {
 	if ((_g231_currentWallSet != set) || _vm->_g523_restartGameRequest) {
 		_g231_currentWallSet = set;
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 2931253..0f4bde5 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -187,7 +187,7 @@ void MenuMan::f456_drawDisabledMenu() {
 		}
 		warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 		warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox");
-		warning(false, "MISSING CODE: F0067_MOUSE_SetPointerToNormal");
+		_vm->_eventMan->f67_setMousePointerToNormal(k0_pointerArrow);
 	}
 }
 
@@ -304,7 +304,7 @@ void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) {
 	int16 champCurrHealth[4];
 	for (uint16 i = 0; i < 4; ++i)
 		champCurrHealth[i] = champMan._gK71_champions[i]._currHealth;
-	warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+	_vm->_eventMan->f77_hideMouse();
 	dispMan.D24_fillScreenBox(g504_BoxSpellAreaControls, k0_ColorBlack);
 	int16 champCount = champMan._g305_partyChampionCount;
 	switch (champIndex) {
@@ -360,7 +360,7 @@ labelChamp3:
 		textMan.f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		break;
 	}
-	warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer");
+	_vm->_eventMan->f78_showMouse();
 }
 
 #define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS


Commit: 734abf8d48a1a0d9c00d27801d6be9e54854d702
    https://github.com/scummvm/scummvm/commit/734abf8d48a1a0d9c00d27801d6be9e54854d702
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Adjust idle delay when renaming champion

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/champion.cpp
    engines/dm/dm.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 4fb935f..b6e3ad8 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -45,4 +45,3 @@ Finish stuff:
 
 Refactoring
 	Places implementing mini mainloop and where input doesn't really matter should call discardInput instead of processInput
-	While reanming a champion, the mouse lags
\ No newline at end of file
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index b88864f..9dcb199 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -2327,7 +2327,7 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 			{
 				eventType = _vm->_eventMan->processInput(&event, &event);
 				_vm->_displayMan->updateScreen();
-				_vm->f22_delay(1);
+				//_vm->f22_delay(1);
 			}
 			if (eventType == Common::EVENT_LBUTTONDOWN) { /* If left mouse button status has changed */
 				Common::Point mousePos = _vm->_eventMan->getMousePos();
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index dc778aa..33cfe2f 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -472,8 +472,6 @@ void DMEngine::f441_processEntrance() {
 	}
 	do {
 		f439_drawEntrance();
-		//_eventMan->f77_hideMouse();
-		//_eventMan->f77_hideMouse();
 		_eventMan->f78_showMouse();
 		_eventMan->f357_discardAllInput();
 		_g298_newGame = k99_modeWaitingOnEntrance;


Commit: ec28573a3b8dac8728f89cf7d9f221f901812388
    https://github.com/scummvm/scummvm/commit/ec28573a3b8dac8728f89cf7d9f221f901812388
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f385_drawActionDamage

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/gfx.h
    engines/dm/menus.cpp
    engines/dm/menus.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index b6e3ad8..46928ac 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -41,7 +41,7 @@ Finish stuff:
 	Add dialogs
 	Add failcheck to saveing and loading
 	F0444_STARTEND_Endgame
-	F0385_MENUS_DrawActionDamage
+
 
 Refactoring
 	Places implementing mini mainloop and where input doesn't really matter should call discardInput instead of processInput
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 3af375d..5721698 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -212,6 +212,7 @@ enum GraphicIndice {
 	k10_MenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA
 	k11_MenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES
 	k13_MovementArrowsIndice = 13, // @ C013_GRAPHIC_MOVEMENT_ARROWS
+	k14_damageToCreatureIndice = 14, // @ C014_GRAPHIC_DAMAGE_TO_CREATURE
 	k15_damageToChampionSmallIndice = 15, // @ C015_GRAPHIC_DAMAGE_TO_CHAMPION_SMALL
 	k16_damageToChampionBig = 16, // @ C016_GRAPHIC_DAMAGE_TO_CHAMPION_BIG
 	k17_InventoryGraphicIndice = 17, // @ C017_GRAPHIC_INVENTORY
@@ -276,6 +277,7 @@ enum GraphicIndice {
 	k557_FontGraphicIndice = 557 // @ C557_GRAPHIC_FONT 
 };
 
+extern byte g17_PalChangesNoChanges[16];
 extern uint16 gK57_PalSwoosh[16]; // @ K0057_aui_Palette_Swoosh
 extern uint16 gK150_PalMousePointer[16];	// @ K0150_aui_Palette_MousePointer
 extern uint16 g19_PalCredits[16];  // @ G0019_aui_Graphic562_Palette_Credits
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 0f4bde5..513b8fb 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -228,7 +228,7 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
 	if (_g508_refreshActionArea) {
 		if (!champMan._g506_actingChampionOrdinal) {
 			if (_g513_actionDamage) {
-				warning(false, "MISSING CODE: F0385_MENUS_DrawActionDamage");
+				f385_drawActionDamage(_g513_actionDamage);
 				_g513_actionDamage = 0;
 			} else {
 				_g509_actionAreaContainsIcons = true;
@@ -403,7 +403,7 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	}
 	if (_vm->_championMan->_g514_magicCasterChampionIndex == kM1_ChampionNone) {
 		_vm->_eventMan->f78_showMouse();
-		_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &g0_BoxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33); 
+		_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &g0_BoxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33);
 		_vm->_eventMan->f77_hideMouse();
 	}
 	if (champIndex == kM1_ChampionNone) {
@@ -1666,4 +1666,76 @@ int16 MenuMan::f382_getActionObjectChargeCount() {
 		return 1;
 	}
 }
+
+void MenuMan::f385_drawActionDamage(int16 damage) {
+	static Box G0502_s_Graphic560_Box_ActionAreaMediumDamage = {242, 305, 81, 117};
+	static Box G0503_s_Graphic560_Box_ActionAreaSmallDamage = {251, 292, 81, 117};
+
+	uint16 L1174_ui_Multiple;
+#define AL1174_ui_DerivedBitmapIndex L1174_ui_Multiple
+#define AL1174_ui_CharacterIndex     L1174_ui_Multiple
+	int16 L1175_i_ByteWidth;
+	int16 L1176_i_Multiple;
+#define AL1176_i_X          L1176_i_Multiple
+#define AL1176_i_PixelWidth L1176_i_Multiple
+	byte* L1177_puc_Bitmap;
+	unsigned char* L1178_puc_Multiple;
+#define AL1178_puc_String L1178_puc_Multiple
+#define AL1178_puc_Bitmap L1178_puc_Multiple
+	char L1179_ac_String[6];
+	Box* L1180_ps_Box;
+	int16 L1643_i_Width;
+
+	_vm->_eventMan->f78_showMouse();
+	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	_vm->_displayMan->D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack);
+	if (damage < 0) {
+		if (damage == kM1_damageCantReach) {
+			AL1176_i_X = 242;
+			AL1178_puc_String = (unsigned char*)"CAN'T REACH"; // TODO: localization
+		} else {
+			AL1176_i_X = 248;
+			AL1178_puc_String = (unsigned char*)"NEED AMMO"; // TODO: localization
+		}
+		_vm->_textMan->f53_printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, (char *)AL1178_puc_String);
+	} else {
+		if (damage > 40) {
+			L1180_ps_Box = &g499_BoxActionArea3ActionMenu;
+			L1177_puc_Bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
+			L1175_i_ByteWidth = k48_byteWidth;
+			L1643_i_Width = 45;
+		} else {
+			if (damage > 15) {
+				AL1174_ui_DerivedBitmapIndex = k2_DerivedBitmapDamageToCreatureMedium;
+				AL1176_i_PixelWidth = 64;
+				L1175_i_ByteWidth = k32_byteWidth;
+				L1180_ps_Box = &G0502_s_Graphic560_Box_ActionAreaMediumDamage;
+			} else {
+				AL1174_ui_DerivedBitmapIndex = k3_DerivedBitmapDamageToCreatureSmall;
+				AL1176_i_PixelWidth = 42;
+				L1175_i_ByteWidth = k24_byteWidth;
+				L1180_ps_Box = &G0503_s_Graphic560_Box_ActionAreaSmallDamage;
+			}
+			L1643_i_Width = 37;
+			if (!_vm->_displayMan->f491_isDerivedBitmapInCache(AL1174_ui_DerivedBitmapIndex)) {
+				AL1178_puc_Bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
+				_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(AL1178_puc_Bitmap, L1177_puc_Bitmap = _vm->_displayMan->f492_getDerivedBitmap(AL1174_ui_DerivedBitmapIndex), 96, 45, AL1176_i_PixelWidth, 37, g17_PalChangesNoChanges);
+				_vm->_displayMan->f493_addDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
+			} else {
+				L1177_puc_Bitmap = _vm->_displayMan->f492_getDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
+			}
+		}
+		_vm->_displayMan->f21_blitToScreen(L1177_puc_Bitmap, L1180_ps_Box, L1175_i_ByteWidth, kM1_ColorNoTransparency, L1643_i_Width);
+		/* Convert damage value to string */
+		AL1174_ui_CharacterIndex = 5;
+		AL1176_i_X = 274;
+		L1179_ac_String[5] = '\0';
+		do {
+			L1179_ac_String[--AL1174_ui_CharacterIndex] = '0' + (damage % 10);
+			AL1176_i_X -= 3;
+		} while (damage /= 10);
+		_vm->_textMan->f53_printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, &L1179_ac_String[AL1174_ui_CharacterIndex]);
+	}
+	_vm->_eventMan->f77_hideMouse();
+}
 }
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index f0a1c2b..6652fdc 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -116,6 +116,7 @@ public:
 	void f389_processCommands116To119_setActingChampion(uint16 champIndex); // @ F0389_MENUS_ProcessCommands116To119_SetActingChampion
 	void f383_setActionList(ActionSet *actionSet); // @ F0383_MENUS_SetActionList
 	int16 f382_getActionObjectChargeCount(); // @ F0382_MENUS_GetActionObjectChargeCount
+	void f385_drawActionDamage(int16 damage); // @ F0385_MENUS_DrawActionDamage
 };
 
 }


Commit: 2b2a0283322ba1d3852feb59b4cf2a4bcf5ed891
    https://github.com/scummvm/scummvm/commit/2b2a0283322ba1d3852feb59b4cf2a4bcf5ed891
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f444_endGame and checks for Common::EVENT_QUIT

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/loadsave.cpp
    engines/dm/text.cpp
    engines/dm/text.h
    engines/dm/timeline.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 46928ac..8c05efa 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -31,6 +31,9 @@ Todo:
 	I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions
 
 Finish stuff:
+	F0444_STARTEND_Endgame
+	Make missing code warnings to STUB methods
+	Add quit resuest from scummvm
 	f380_processCommandQueue
 	Missing main loop methods
 	Save file f433_processCommand140_saveGame fails silently
@@ -40,7 +43,7 @@ Finish stuff:
 	G0335_ui_SelectedDialogChoice
 	Add dialogs
 	Add failcheck to saveing and loading
-	F0444_STARTEND_Endgame
+	
 
 
 Refactoring
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 9dcb199..a2ff439 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -2326,6 +2326,8 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 			Common::EventType eventType;
 			{
 				eventType = _vm->_eventMan->processInput(&event, &event);
+				if (_vm->_engineShouldQuit)
+					return;
 				_vm->_displayMan->updateScreen();
 				//_vm->f22_delay(1);
 			}
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 33cfe2f..8521450 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -150,6 +150,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_projexpl = nullptr;
 	_displayMan = nullptr;
 
+	_engineShouldQuit = false;
 	_g528_saveFormat = 0;
 	_g527_platform = 0;
 	_g526_dungeonId = 0;
@@ -230,10 +231,11 @@ void DMEngine::f463_initializeGame() {
 	_textMan->f54_textInitialize();
 	_objectMan->loadObjectNames();
 	_eventMan->initMouse();
-	f441_processEntrance();
-	while (f435_loadgame(1) != k1_LoadgameSuccess) {
+	do {
 		f441_processEntrance();
-	}
+		if (_engineShouldQuit)
+			return;
+	} while (f435_loadgame(1) != k1_LoadgameSuccess);
 	//F0396_MENUS_LoadSpellAreaLinesBitmap() is not needed, every bitmap has been loaded
 
 	// There was some memory wizardy for the Amiga platform, I skipped that part
@@ -327,7 +329,9 @@ Common::Error DMEngine::run() {
 	f463_initializeGame();
 	while (true) {
 		f2_gameloop();
-		warning(false, "TODO: F0444_STARTEND_Endgame(G0303_B_PartyDead);");
+		if (_engineShouldQuit)
+			return Common::kNoError;
+		f444_endGame(_championMan->_g303_partyDead);
 	}
 
 	return Common::kNoError;
@@ -343,6 +347,8 @@ void DMEngine::f2_gameloop() {
 
 	_g318_waitForInputMaxVerticalBlankCount = 10;
 	while (true) {
+		if (_engineShouldQuit)
+			return;
 		if (_g327_newPartyMapIndex != kM1_mapIndexNone) {
 T0002002:
 			f3_processNewPartyMap(_g327_newPartyMapIndex);
@@ -416,8 +422,10 @@ T0002002:
 			}
 
 			_eventMan->f380_processCommandQueue();
+			if (_engineShouldQuit)
+				return;
 			_displayMan->updateScreen();
-			// if (!_vm->_g321_stopWaitingForPlayerInput) {
+			// if (!_g321_stopWaitingForPlayerInput) {
 			//		F0363_COMMAND_HighlightBoxDisable();
 			// }
 
@@ -477,6 +485,8 @@ void DMEngine::f441_processEntrance() {
 		_g298_newGame = k99_modeWaitingOnEntrance;
 		do {
 			_eventMan->processInput();
+			if (_engineShouldQuit)
+				return;
 			_eventMan->f380_processCommandQueue();
 			_displayMan->updateScreen();
 		} while (_g298_newGame == k99_modeWaitingOnEntrance);
@@ -493,6 +503,161 @@ void DMEngine::f441_processEntrance() {
 		_g562_entranceDoorAnimSteps[i] = nullptr;
 }
 
+void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
+	// TODO: localization
+	static Box G0013_s_Graphic562_Box_Endgame_Restart_Outer = {103, 217, 145, 159};
+	static Box G0014_s_Graphic562_Box_Endgame_Restart_Inner = {105, 215, 147, 157};
+	static Box G0012_s_Graphic562_Box_Endgame_TheEnd = {120, 199, 95, 108};
+	static Box G0015_s_Graphic562_Box_Endgame_ChampionMirror = {11, 74, 7, 49};
+	static Box G0016_s_Graphic562_Box_Endgame_ChampionPortrait = {27, 58, 13, 41};
+	int16 L1409_i_Multiple;
+#define AL1409_i_Color              L1409_i_Multiple
+#define AL1409_i_ChampionIndex      L1409_i_Multiple
+#define AL1409_i_VerticalBlankCount L1409_i_Multiple
+	int16 L1410_i_Multiple;
+#define AL1410_i_Counter L1410_i_Multiple
+#define AL1410_i_Y       L1410_i_Multiple
+	int16 L1411_i_Multiple;
+#define AL1411_i_X          L1411_i_Multiple
+#define AL1411_i_SkillIndex L1411_i_Multiple
+	int16 L1412_i_SkillLevel;
+	char L1415_c_ChampionTitleFirstCharacter;
+	Champion* L1416_ps_Champion;
+	uint16 L1419_aui_Palette[16];
+	uint16 L1420_aui_Palette_TopAndBottomScreen[16];
+	uint16 L1421_aui_Palette_DarkBlue[16];
+	char L1422_ac_String[20];
+	// Strangerke: Not so sure it's useless. 
+	bool L1423_B_WaitBeforeDrawingRestart; /* BUG0_00 Useless code */
+	L1423_B_WaitBeforeDrawingRestart = true; /* BUG0_00 Useless code */
+
+	_eventMan->f67_setMousePointerToNormal(k0_pointerArrow);
+	_eventMan->f78_showMouse();
+	_eventMan->_g441_primaryMouseInput = nullptr;
+	_eventMan->_g442_secondaryMouseInput = nullptr;
+	_eventMan->_g443_primaryKeyboardInput = nullptr;
+	_eventMan->_g444_secondaryKeyboardInput = nullptr;
+	if (doNotDrawCreditsOnly && !_g302_gameWon) {
+		f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
+		f22_delay(240);
+	}
+	
+	if (_displayMan->_g322_paletteSwitchingEnabled) {
+		for (uint16 i = 0; i < 16; ++i)
+			L1420_aui_Palette_TopAndBottomScreen[i] = _displayMan->_g347_paletteTopAndBottomScreen[i];
+		for (AL1410_i_Counter = 0; AL1410_i_Counter <= 7; AL1410_i_Counter++) {
+			f22_delay(1);
+			for (AL1409_i_Color = 0; AL1409_i_Color < 16; AL1409_i_Color++) {
+				_displayMan->_g346_paletteMiddleScreen[AL1409_i_Color] = _displayMan->f431_getDarkenedColor(_displayMan->_g346_paletteMiddleScreen[AL1409_i_Color]);
+				_displayMan->_g347_paletteTopAndBottomScreen[AL1409_i_Color] = _displayMan->f431_getDarkenedColor(_displayMan->_g347_paletteTopAndBottomScreen[AL1409_i_Color]);
+			}
+		}
+		_displayMan->_g322_paletteSwitchingEnabled = false;
+		f22_delay(1);
+		for (uint16 i = 0; i < 16; ++i)
+			_displayMan->_g347_paletteTopAndBottomScreen[i] = L1420_aui_Palette_TopAndBottomScreen[i];
+	} else {
+		warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(G0345_aui_BlankBuffer)");
+	}
+	if (doNotDrawCreditsOnly) {
+		if (_g302_gameWon) {
+			// Strangerke: Related to portraits. Game data could be missing for earlier versions of the game.
+			_displayMan->fillScreen(k12_ColorDarkestGray);
+			for (AL1409_i_ChampionIndex = k0_ChampionFirst; AL1409_i_ChampionIndex < _championMan->_g305_partyChampionCount; AL1409_i_ChampionIndex++) {
+				AL1410_i_Y = AL1409_i_ChampionIndex * 48;
+				L1416_ps_Champion = &_championMan->_gK71_champions[AL1409_i_ChampionIndex];
+				_displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k208_wallOrn_43_champMirror), &G0015_s_Graphic562_Box_Endgame_ChampionMirror, k32_byteWidth, k10_ColorFlesh, 43);
+				_displayMan->f21_blitToScreen(L1416_ps_Champion->_portrait, &G0016_s_Graphic562_Box_Endgame_ChampionPortrait, k16_byteWidth, k1_ColorDarkGary, 29);
+				_textMan->f443_endgamePrintString(87, AL1410_i_Y += 14, k9_ColorGold, L1416_ps_Champion->_name);
+				AL1411_i_X = (6 * strlen(L1416_ps_Champion->_name)) + 87;
+				L1415_c_ChampionTitleFirstCharacter = L1416_ps_Champion->_title[0];
+				if ((L1415_c_ChampionTitleFirstCharacter != ',') && (L1415_c_ChampionTitleFirstCharacter != ';') && (L1415_c_ChampionTitleFirstCharacter != '-')) {
+					AL1411_i_X += 6;
+				}
+				_textMan->f443_endgamePrintString(AL1411_i_X, AL1410_i_Y++, k9_ColorGold, L1416_ps_Champion->_title);
+				for (AL1411_i_SkillIndex = k0_ChampionSkillFighter; AL1411_i_SkillIndex <= k3_ChampionSkillWizard; AL1411_i_SkillIndex++) {
+					L1412_i_SkillLevel = MIN((uint16)16, _championMan->f303_getSkillLevel(AL1409_i_ChampionIndex, AL1411_i_SkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience)));
+					if (L1412_i_SkillLevel == 1)
+						continue;
+					strcpy(L1422_ac_String, G0428_apc_SkillLevelNames[L1412_i_SkillLevel - 2]);
+					strcat(L1422_ac_String, " ");
+					strcat(L1422_ac_String, g417_baseSkillName[AL1411_i_SkillIndex]);
+					_textMan->f443_endgamePrintString(105, AL1410_i_Y = AL1410_i_Y + 8, k13_ColorLightestGray, L1422_ac_String);
+				}
+				G0015_s_Graphic562_Box_Endgame_ChampionMirror._y1 += 48;
+				G0015_s_Graphic562_Box_Endgame_ChampionMirror._y2 += 48;
+				G0016_s_Graphic562_Box_Endgame_ChampionPortrait._y1 += 48;
+				G0016_s_Graphic562_Box_Endgame_ChampionPortrait._y1 += 48;
+			}
+			warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);");
+			_engineShouldQuit = true;
+			return;
+		}
+T0444017:
+		_displayMan->fillScreen(k0_ColorBlack);
+		_displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k6_theEndIndice), &G0012_s_Graphic562_Box_Endgame_TheEnd, k40_byteWidth, kM1_ColorNoTransparency, 14);
+		for (uint16 i = 0; i < 16; ++i)
+			L1421_aui_Palette_DarkBlue[i] = D01_RGB_DARK_BLUE;
+		for (uint16 i = 0; i < 16; ++i)
+			L1419_aui_Palette[i] = L1421_aui_Palette_DarkBlue[i];
+		L1419_aui_Palette[15] = D09_RGB_WHITE;
+		warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(L1419_aui_Palette);");
+		if (L1423_B_WaitBeforeDrawingRestart) { /* BUG0_00 Useless code */
+			f22_delay(300);
+		} /* BUG0_00 Useless code */
+
+		if (_g524_restartGameAllowed) {
+			_displayMan->_g578_useByteBoxCoordinates = false;
+			_displayMan->D24_fillScreenBox(G0013_s_Graphic562_Box_Endgame_Restart_Outer, k12_ColorDarkestGray);
+			_displayMan->D24_fillScreenBox(G0014_s_Graphic562_Box_Endgame_Restart_Inner, k0_ColorBlack);
+			_textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RESTART THIS GAME");
+			L1419_aui_Palette[1] = D03_RGB_PINK;
+			L1419_aui_Palette[4] = D09_RGB_WHITE;
+			_eventMan->_g441_primaryMouseInput = g446_PrimaryMouseInput_RestartGame;
+			_eventMan->f357_discardAllInput();
+			_eventMan->f77_hideMouse();
+			warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette");
+			for (AL1409_i_VerticalBlankCount = 900; --AL1409_i_VerticalBlankCount && !_g523_restartGameRequest; f22_delay(1)) {
+				_eventMan->f380_processCommandQueue();
+			}
+			_eventMan->f78_showMouse();
+			if (_g523_restartGameRequest) {
+				warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette");
+				_displayMan->fillScreen(k0_ColorBlack);
+				warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette");
+				_g298_newGame = k0_modeLoadSavedGame;
+				if (f435_loadgame(1) != kM1_LoadgameFailure) {
+					f462_startGame();
+					_g523_restartGameRequest = false;
+					_eventMan->f77_hideMouse();
+					_eventMan->f357_discardAllInput();
+					return;
+				}
+			}
+		}
+
+		warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette");
+	}
+	{
+		Box box(0, 319, 0, 199);
+		_displayMan->f132_blitToBitmap(_displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice), _displayMan->_g348_bitmapScreen, box, 0, 0, 160, 160, kM1_ColorNoTransparency);
+	}
+	warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette");
+	_eventMan->f541_waitForMouseOrKeyActivity();
+	if (_engineShouldQuit)
+		return;
+
+	if (_g524_restartGameAllowed && doNotDrawCreditsOnly) {
+		L1423_B_WaitBeforeDrawingRestart = false;
+		warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette");
+		goto T0444017;
+	}
+
+	_engineShouldQuit = true;
+	return;
+}
+
+
 void DMEngine::f439_drawEntrance() {
 	static Box K0079_s_Box_Entrance_DoorsUpperHalf = Box(0, 231, 0, 80);
 	static Box K0152_s_Box_Entrance_DoorsLowerHalf = Box(0, 231, 81, 160);
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index e2c8923..cb7d07f 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -221,6 +221,7 @@ public:
 	void f433_processCommand140_saveGame(uint16 slot, const Common::String desc); // @ F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF
 	LoadgameResponse f435_loadgame(int16 slot); // @ F0435_STARTEND_LoadGame_CPSF
 	void f441_processEntrance(); // @ F0441_STARTEND_ProcessEntrance
+	void f444_endGame(bool doNotDrawCreditsOnly); // @ F0444_STARTEND_Endgame
 
 	void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode) { warning(true, "STUB: f064_SOUND_RequestPlay_CPSD"); }
 
@@ -248,6 +249,8 @@ public:
 	DialogMan *_dialog;
 
 
+	bool _engineShouldQuit;
+
 	int16 _g298_newGame; // @ G0298_B_NewGame
 	bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested
 
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 90f2205..2c95049 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -599,6 +599,9 @@ Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Eve
 			f544_resetPressingEyeOrMouth();
 			break;
 		}
+		case Common::EVENT_QUIT:
+			_vm->_engineShouldQuit = true;
+			break;
 		default:
 			break;
 		}
@@ -1171,6 +1174,8 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 
 	if (commandType == k161_CommandClickInPanelReincarnate) {
 		champMan.f281_renameChampion(champ);
+		if (_vm->_engineShouldQuit)
+			return;
 		champ->resetSkillsToZero();
 
 		for (uint16 i = 0; i < 12; i++) {
@@ -1209,7 +1214,7 @@ void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) {
 			return;
 		commandType = f358_getCommandTypeFromMouseInput(g456_MouseInput_PanelChest, Common::Point(x, y), k1_LeftMouseButton);
 		if (commandType != k0_CommandNone)
-			_vm->_championMan->f302_processCommands28to65_clickOnSlotBox(commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand); 
+			_vm->_championMan->f302_processCommands28to65_clickOnSlotBox(commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
 		break;
 	case k5_PanelContentResurrectReincarnate:
 		if (!champMan._g415_leaderEmptyHanded)
@@ -1302,8 +1307,10 @@ void EventManager::f379_drawSleepScreen() {
 
 void EventManager::f357_discardAllInput() {
 	Common::Event event;
-	while (_vm->_system->getEventManager()->pollEvent(event))
-		;
+	while (_vm->_system->getEventManager()->pollEvent(event) && !_vm->_engineShouldQuit) {
+		if (event.type == Common::EVENT_QUIT)
+			_vm->_engineShouldQuit = true;
+	}
 	_commandQueue.clear();
 }
 
@@ -1537,4 +1544,22 @@ void EventManager::f544_resetPressingEyeOrMouth() {
 		_vm->_g334_stopPressingMouth = true;
 	}
 }
+
+void EventManager::f541_waitForMouseOrKeyActivity() {
+	Common::Event event;
+	while (true) {
+		if (_vm->_system->getEventManager()->pollEvent(event)) {
+			switch (event.type) {
+			case Common::EVENT_QUIT:
+				_vm->_engineShouldQuit = true;
+			case Common::EVENT_KEYDOWN: // Intentional fall through
+			case Common::EVENT_LBUTTONDOWN:
+			case Common::EVENT_RBUTTONDOWN:
+				return;
+			}
+		}
+		_vm->f22_delay(1);
+		_vm->_displayMan->updateScreen();
+	}
+}
 } // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 3cf5478..d04b1c7 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -316,7 +316,8 @@ public:
 	void f370_commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY); // @ F0370_COMMAND_ProcessType100_ClickInSpellArea
 	void f369_commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType); // @ F0369_COMMAND_ProcessTypes101To108_ClickInSpellSymbolsArea_CPSE
 	void f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY); // @ F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE
-	void f544_resetPressingEyeOrMouth();// @ F0544_INPUT_ResetPressingEyeOrMouth
+	void f544_resetPressingEyeOrMouth(); // @ F0544_INPUT_ResetPressingEyeOrMouth
+	void f541_waitForMouseOrKeyActivity(); // @ F0541_INPUT_WaitForMouseOrKeyboardActivity
 };
 
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index b76792b..6384302 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -719,6 +719,10 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 										Frame(136, 159, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed half */
 										Frame(124, 159, 17, 102, 48, 88, 48, 0)	/* Right Horizontal Closed three fourth */
 	);
+	for (uint16 i = 0; i < 16; ++i) {
+		_g347_paletteTopAndBottomScreen[i] = 0;
+		_g346_paletteMiddleScreen[i] = 0;
+	}
 }
 
 DisplayMan::~DisplayMan() {
@@ -3691,4 +3695,17 @@ void DisplayMan::f493_addDerivedBitmap(int16 derivedBitmapIndex) {
 	warning(false, "f493_addDerivedBitmap DOES NOTHING");
 }
 
+uint16 DisplayMan::f431_getDarkenedColor(uint16 RGBcolor) {
+	if (getFlag(RGBcolor, D12_MASK_BLUE_COMPONENT)) {
+		RGBcolor--;
+	}
+	if (getFlag(RGBcolor, D11_MASK_GREEN_COMPONENT)) {
+		RGBcolor -= 16;
+	}
+	if (getFlag(RGBcolor, D10_MASK_RED_COMPONENT)) {
+		RGBcolor -= 256;
+	}
+	return RGBcolor;
+}
+
 }
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 5721698..0d9017d 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -207,6 +207,7 @@ enum GraphicIndice {
 	k3_entranceRightDoorGraphicIndice = 3, // @ C003_GRAPHIC_ENTRANCE_RIGHT_DOOR
 	k4_entranceGraphicIndice = 4, // @ C004_GRAPHIC_ENTRANCE
 	k5_creditsGraphicIndice = 5, // @ C005_GRAPHIC_CREDITS
+	k6_theEndIndice = 6, // @ C006_GRAPHIC_THE_END
 	k8_StatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION
 	k9_MenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND
 	k10_MenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA
@@ -266,6 +267,7 @@ enum GraphicIndice {
 	k69_FieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R
 	k73_FieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER
 	k120_InscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT
+	k208_wallOrn_43_champMirror = 208, // @ C208_GRAPHIC_WALL_ORNAMENT_43_CHAMPION_MIRROR
 	k241_FloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS
 	k301_DoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
 	k315_firstDoorButton_GraphicIndice = 315, // @ C315_GRAPHIC_FIRST_DOOR_BUTTON
@@ -304,7 +306,7 @@ public:
 	bool isPointInside(Common::Point point) {
 		return (_x1 <= point.x) && (point.x <= _x2) && (_y1 <= point.y) && (point.y <= _y2); // <= because incluseive boundaries
 	}
-	bool isPointInside(int16 x, int16 y) { return isPointInside(Common::Point(x, y));  }
+	bool isPointInside(int16 x, int16 y) { return isPointInside(Common::Point(x, y)); }
 	void setToZero() { _x1 = _x2 = _y1 = _y2 = 0; }
 }; // @ BOX_BYTE, BOX_WORD
 
@@ -503,6 +505,21 @@ public:
 	}
 }; // @ DOOR_FRAMES
 
+#define D00_RGB_BLACK                                0x0000
+#define D01_RGB_DARK_BLUE                            0x0004
+#define D02_RGB_LIGHT_BROWN                          0x0842
+#define D03_RGB_PINK                                 0x086F
+#define D04_RGB_LIGHTER_BROWN                        0x0A62
+#define D05_RGB_DARK_GOLD                            0x0A82
+#define D06_RGB_GOLD                                 0x0CA2
+#define D07_RGB_RED                                  0x0F00
+#define D08_RGB_YELLOW                               0x0FF4
+#define D09_RGB_WHITE                                0x0FFF
+#define D10_MASK_RED_COMPONENT                       0x0F00
+#define D10_MASK_RED_COMPONENT 0x0F00
+#define D11_MASK_GREEN_COMPONENT 0x00F0
+#define D12_MASK_BLUE_COMPONENT 0x000F
+
 class DisplayMan {
 	friend class DM::TextMan;
 
@@ -579,7 +596,9 @@ class DisplayMan {
 	byte *_g696_bitmapWallSet_Wall_D3R2; // @ G0696_puc_Bitmap_WallSet_Wall_D3R2
 	byte *_g698_bitmapWallSet_Wall_D3LCR; // @ G0698_puc_Bitmap_WallSet_Wall_D3LCR
 	byte *_g699_bitmapWallSet_Wall_D2LCR; // @ G0699_puc_Bitmap_WallSet_Wall_D2LCR
+public:
 	byte *_g700_bitmapWallSet_Wall_D1LCR; // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR
+private:
 	byte *_g701_bitmapWallSet_Wall_D0L; // @ G0701_puc_Bitmap_WallSet_Wall_D0L
 	byte *_g702_bitmapWallSet_Wall_D0R; // @ G0702_puc_Bitmap_WallSet_Wall_D0R
 	byte *_g703_bitmapWallSet_DoorFrameTop_D2LCR; // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR
@@ -611,6 +630,7 @@ class DisplayMan {
 	int16 _g694_doorNativeBitmapIndex_Front_D2LCR[2]; // @ G0694_ai_DoorNativeBitmapIndex_Front_D2LCR
 	int16 _g695_doorNativeBitmapIndex_Front_D1LCR[2]; // @ G0695_ai_DoorNativeBitmapIndex_Front_D1LCR
 public:
+
 	uint16 _screenWidth;
 	uint16 _screenHeight;
 	byte *_g348_bitmapScreen; // @ G0348_pl_Bitmap_Screen
@@ -622,6 +642,7 @@ public:
 	bool _g342_refreshDungeonViewPaleteRequested; // @ G0342_B_RefreshDungeonViewPaletteRequested
 	int16 _g304_dungeonViewPaletteIndex; // @ G0304_i_DungeonViewPaletteIndex
 	uint16 _g347_paletteTopAndBottomScreen[16]; // @ G0347_aui_Palette_TopAndBottomScreen
+	uint16 _g346_paletteMiddleScreen[16]; // @ G0346_aui_Palette_MiddleScreen
 
 	explicit DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
@@ -657,19 +678,19 @@ public:
 	void f20_blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
 	void f21_blitToScreen(byte* bitmap, int16 *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen
 	void f21_blitToScreen(byte* bitmap, Box *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen
-	
 
-	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which 
+
+	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which
 	does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters
 	match the original exatcly, if need arises for heights then we'll have to retrospectively add them in old function calls*/
 	/* Expects inclusive boundaries in box */
 	void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
-					  uint16 destByteWidth, Color transparent = kM1_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit
-/* Expects inclusive boundaries in box */
+						   uint16 destByteWidth, Color transparent = kM1_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit
+	 /* Expects inclusive boundaries in box */
 	void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
-									   int16 firstUnitIndex, int16 destByteWidth, Color transparent,
-									   int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
-	// this function takes pixel widths
+											int16 firstUnitIndex, int16 destByteWidth, Color transparent,
+											int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
+		 // this function takes pixel widths
 	void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
 											  int16 srcPixelWidth, int16 srcHight, int16 destPixelWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
 	void f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height); // @ F0130_VIDEO_FlipHorizontal
@@ -695,8 +716,8 @@ public:
 	int16 f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale); // @ F0459_START_GetScaledBitmapByteCount
 	int16 M78_getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION
 	void f115_cthulhu(Thing thingParam, Direction directionParam,
-				 int16 mapXpos, int16 mapYpos, int16 viewSquareIndex,
-				 uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
+					  int16 mapXpos, int16 mapYpos, int16 viewSquareIndex,
+					  uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 	uint16 M77_getNormalizedByteWidth(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH
 	uint16 M23_getVerticalOffsetM23(uint16 val); // @ M23_VERTICAL_OFFSET
 	uint16 M22_getHorizontalOffsetM22(uint16 val); // @ M22_HORIZONTAL_OFFSET
@@ -726,10 +747,7 @@ public:
 	bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
 	byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap
 	void f493_addDerivedBitmap(int16 derivedBitmapIndex); // @ F0493_CACHE_AddDerivedBitmap
-
-
-
-
+	uint16 f431_getDarkenedColor(uint16 RGBcolor);
 };
 
 }
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 9ecfed1..da59e70 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -44,6 +44,24 @@ Box g35_BoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food
 Box g36_BoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
 Box g37_BoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
 
+// TODO: localization
+char* G0428_apc_SkillLevelNames[15] = { // @ G0428_apc_SkillLevelNames
+	"NEOPHYTE",
+	"NOVICE",
+	"APPRENTICE",
+	"JOURNEYMAN",
+	"CRAFTSMAN",
+	"ARTISAN",
+	"ADEPT",
+	"EXPERT",
+	"` MASTER",
+	"a MASTER",
+	"b MASTER",
+	"c MASTER",
+	"d MASTER",
+	"e MASTER",
+	"ARCHMASTER"};
+
 InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
 	_g432_inventoryChampionOrdinal = 0;
 	_g424_panelContent = k0_PanelContentFoodWaterPoisoned;
@@ -659,23 +677,6 @@ void InventoryMan::f338_decreaseTorchesLightPower() {
 }
 
 void InventoryMan::f351_drawChampionSkillsAndStatistics() {
-	// TODO: localization
-	static char* G0428_apc_SkillLevelNames[15] = {
-		"NEOPHYTE",
-		"NOVICE",
-		"APPRENTICE",
-		"JOURNEYMAN",
-		"CRAFTSMAN",
-		"ARTISAN",
-		"ADEPT",
-		"EXPERT",
-		"` MASTER",
-		"a MASTER",
-		"b MASTER",
-		"c MASTER",
-		"d MASTER",
-		"e MASTER",
-		"ARCHMASTER"};
 
 	uint16 L1090_ui_Multiple;
 #define AL1090_ui_SkillIndex     L1090_ui_Multiple
@@ -902,7 +903,9 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 	if (L1081_B_RemoveObjectFromLeaderHand) {
 		for (L1086_ui_Counter = 5; --L1086_ui_Counter; _vm->f22_delay(8)) { /* Animate mouth icon */
 			_vm->_objectMan->f37_drawIconToScreen(k205_IconIndiceMouthOpen + !(L1086_ui_Counter & 0x0001), 56, 46);
-			_vm->_eventMan->processInput();
+			_vm->_eventMan->f357_discardAllInput();
+			if (_vm->_engineShouldQuit)
+				return;
 			_vm->_displayMan->updateScreen();
 		}
 	} else {
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 7617a9d..7a35439 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -47,7 +47,7 @@ enum PanelContent {
 	k5_PanelContentResurrectReincarnate = 5 // @ C05_PANEL_RESURRECT_REINCARNATE
 };
 
-
+extern char* G0428_apc_SkillLevelNames[15];
 
 class InventoryMan {
 	DMEngine *_vm;
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 7440653..85b3691 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -298,7 +298,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 
 	if (!saveAndPlayChoice) {
 		_eventMan->f77_hideMouse();
-		warning(false, "MISSING CODE: F0444_STARTEND_Endgame");
+		f444_endGame(false);
 	}
 	if (!_championMan->_g415_leaderEmptyHanded) {
 		_championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load += champHandObjWeight;
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 993cc8e..d55ebca 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -211,4 +211,18 @@ void TextMan::f44_messageAreaClearExpiredRows() {
 		_g360_messageAreaRowExpirationTime[L0026_ui_RowIndex] = -1;
 	}
 }
+
+void TextMan::f443_endgamePrintString(int16 x, int16 y, Color textColor, char* text) {
+	char* L1407_pc_Character;
+	char L1408_ac_ModifiedString[50];
+
+	L1407_pc_Character = L1408_ac_ModifiedString;
+	while (*L1407_pc_Character = *text++) {
+		if ((*L1407_pc_Character >= 'A') && (*L1407_pc_Character <= 'Z')) {
+			*L1407_pc_Character -= 64; /* Use the same font as the one used for scrolls */
+		}
+		L1407_pc_Character++;
+	}
+	_vm->_textMan->f53_printToLogicalScreen(x, y, textColor, k12_ColorDarkestGray, L1408_ac_ModifiedString);
+}
 }
diff --git a/engines/dm/text.h b/engines/dm/text.h
index e0f5e7a..3a41274 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -55,6 +55,7 @@ public:
 	void f54_textInitialize(); // @ F0054_TEXT_Initialize
 	void f42_messageAreaMoveCursor(int16 column, int16 row); // @ F0042_TEXT_MESSAGEAREA_MoveCursor
 	void f44_messageAreaClearExpiredRows(); // @ F0044_TEXT_MESSAGEAREA_ClearExpiredRows
+	void f443_endgamePrintString(int16 x, int16 y, Color textColor, char *text); // @ F0443_STARTEND_EndgamePrintString
 
 };
 
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 33a99c9..e2b3f5f 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -703,7 +703,7 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
 								_vm->f22_delay(60 * L0638_ps_Sensor->getValue());
 								_vm->_g524_restartGameAllowed = false;
 								_vm->_g302_gameWon = true;
-								warning(false, "MISSING CODE: F0444_STARTEND_Endgame");
+								_vm->f444_endGame(true);
 							}
 						}
 					}


Commit: 084b1df8f392500ce5ed5cd654e856bb391aa7da
    https://github.com/scummvm/scummvm/commit/084b1df8f392500ce5ed5cd654e856bb391aa7da
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f281_renameChampion

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index a2ff439..c4809cb 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -2278,28 +2278,17 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
 void ChampionMan::f281_renameChampion(Champion* champ) {
 #define k1_RENAME_CHAMPION_NAME 1
 #define k2_RENAME_CHAMPION_TITLE 2
-	static char G0051_ac_Graphic562_UnderscoreCharacterString[2] = "_";
-	static char G0052_ac_Graphic562_RenameChampionInputCharacterString[2] = " ";
-	static char G0053_ac_Graphic562_ReincarnateSpecialCharacters[6] = {',', '.', ';', ':', ' '};
-
-	uint16 L0808_ui_Multiple;
-#define AL0808_ui_CharacterIndex L0808_ui_Multiple
-#define AL0808_ui_ChampionIndex  L0808_ui_Multiple
-	int16 L0809_i_RenamedChampionString;
-	int16 L0810_i_Character;
-	bool L0811_B_ChampionTitleIsFull;
-	char* L0812_pc_RenamedChampionString;
-	int16 L0813_i_X;
-	int16 L0814_i_Y;
-	Box L0815_s_Box;
-	int16 L0820_i_CharacterIndexBackup;
-	char L0821_ac_ChampionNameBackupString[8];
-
-
-	L0815_s_Box._y1 = 3;
-	L0815_s_Box._y2 = 8;
-	L0815_s_Box._x2 = (L0815_s_Box._x1 = 3) + 167;
-	_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, L0815_s_Box, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
+	static const char underscoreCharacterString[2] = "_";
+	static char renameChampionInputCharacterString[2] = " ";
+	static const char reincarnateSpecialCharacters[6] = {',', '.', ';', ':', ' '};
+
+	Box displayBox;
+	displayBox._y1 = 3;
+	displayBox._y2 = 8;
+	displayBox._x1 = 3;
+	displayBox._x2 = displayBox._x1 + 167;
+
+	_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, displayBox, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
 	_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), g32_BoxPanel, k72_byteWidth, k4_ColorCyan, 73);
 	_vm->_textMan->f52_printToViewport(177, 58, k13_ColorLightestGray, "_______");
 	_vm->_textMan->f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________");
@@ -2307,53 +2296,60 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
 	_vm->_eventMan->f67_setMousePointerToNormal(k0_pointerArrow);
 	_vm->_eventMan->f77_hideMouse();
-	champ->_name[AL0808_ui_CharacterIndex = 0] = '\0';
+	uint16 curCharacterIndex = 0;
+	champ->_name[curCharacterIndex] = '\0';
 	champ->_title[0] = '\0';
-	L0809_i_RenamedChampionString = k1_RENAME_CHAMPION_NAME;
-	L0812_pc_RenamedChampionString = champ->_name;
-	L0813_i_X = 177;
-	L0814_i_Y = 91;
+	int16 renamedChampionStringMode = k1_RENAME_CHAMPION_NAME;
+	char *renamedChampionString = champ->_name;
+	int16 textPosX = 177;
+	int16 textPosY = 91;
 
 	for (;;) { /*_Infinite loop_*/
-		if (!(L0811_B_ChampionTitleIsFull = ((L0809_i_RenamedChampionString == k2_RENAME_CHAMPION_TITLE) && (AL0808_ui_CharacterIndex == 19)))) {
+		bool championTitleIsFull = ((renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE) && (curCharacterIndex == 19));
+		if (!championTitleIsFull) {
 			_vm->_eventMan->f78_showMouse();
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k9_ColorGold, k12_ColorDarkestGray, G0051_ac_Graphic562_UnderscoreCharacterString, k200_heightScreen);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k9_ColorGold, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
 			_vm->_eventMan->f77_hideMouse();
 		}
-		L0810_i_Character = 256;
-		while (L0810_i_Character == 256) {
+
+		int16 curCharacter = 256;
+		while (curCharacter == 256) {
 			Common::Event event;
-			Common::EventType eventType;
-			{
-				eventType = _vm->_eventMan->processInput(&event, &event);
-				if (_vm->_engineShouldQuit)
-					return;
-				_vm->_displayMan->updateScreen();
-				//_vm->f22_delay(1);
-			}
+			Common::EventType eventType = _vm->_eventMan->processInput(&event, &event);
+			_vm->_displayMan->updateScreen();
+			_vm->f22_delay(1);
+
 			if (eventType == Common::EVENT_LBUTTONDOWN) { /* If left mouse button status has changed */
 				Common::Point mousePos = _vm->_eventMan->getMousePos();
-				if ((L0809_i_RenamedChampionString == k2_RENAME_CHAMPION_TITLE || (AL0808_ui_CharacterIndex > 0)) && (mousePos.x >= 197) && (mousePos.x <= 215) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'OK' button */
-					L0820_i_CharacterIndexBackup = AL0808_ui_CharacterIndex;
-					strcpy(L0821_ac_ChampionNameBackupString, L0812_pc_RenamedChampionString = champ->_name);
-					AL0808_ui_CharacterIndex = strlen(L0812_pc_RenamedChampionString);
-					while (L0812_pc_RenamedChampionString[--AL0808_ui_CharacterIndex] == ' ') { /* Replace space characters on the right of the champion name by '\0' characters */
-						L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex] = '\0';
-					}
-					for (AL0808_ui_ChampionIndex = k0_ChampionFirst; AL0808_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount - 1; AL0808_ui_ChampionIndex++) {
-						if (!strcmp(_vm->_championMan->_gK71_champions[AL0808_ui_ChampionIndex]._name, L0812_pc_RenamedChampionString)) /* If an existing champion already has the specified name for the new champion */
-							goto T0281011_ContinueRename;
+				if ((renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE || (curCharacterIndex > 0)) && (mousePos.x >= 197) && (mousePos.x <= 215) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'OK' button */
+					int16 characterIndexBackup = curCharacterIndex;
+					char L0821_ac_ChampionNameBackupString[8];
+					renamedChampionString = champ->_name;
+					strcpy(L0821_ac_ChampionNameBackupString, renamedChampionString);
+					curCharacterIndex = strlen(renamedChampionString);
+					while (renamedChampionString[--curCharacterIndex] == ' ')
+					// Replace space characters on the right of the champion name by '\0' characters
+						renamedChampionString[curCharacterIndex] = '\0';
+
+					bool found = false;
+					for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_g305_partyChampionCount - 1; idx++) {
+						if (!strcmp(_vm->_championMan->_gK71_champions[idx]._name, renamedChampionString)) {
+						// If an existing champion already has the specified name for the new champion
+							found = true;
+							break;
+						}
 					}
-					return;
-T0281011_ContinueRename:
-					if (L0809_i_RenamedChampionString == k2_RENAME_CHAMPION_TITLE) {
-						L0812_pc_RenamedChampionString = champ->_title;
-					}
-					strcpy(L0812_pc_RenamedChampionString = champ->_name, L0821_ac_ChampionNameBackupString);
-					AL0808_ui_CharacterIndex = L0820_i_CharacterIndexBackup;
+					if (!found)
+						return;
+
+					if (renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE)
+						renamedChampionString = champ->_title;
+
+					strcpy(renamedChampionString = champ->_name, L0821_ac_ChampionNameBackupString);
+					curCharacterIndex = characterIndexBackup;
 				} else {
 					if ((mousePos.x >= 107) && (mousePos.x <= 175) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'BACKSPACE' button */
-						L0810_i_Character = '\b';
+						curCharacter = '\b';
 						break;
 					}
 					if ((mousePos.x < 107) || (mousePos.x > 215) || (mousePos.y < 116) || (mousePos.y > 144)) {/* Coordinates of table of all other characters */
@@ -2362,77 +2358,76 @@ T0281011_ContinueRename:
 					if (!((mousePos.x + 4) % 10) || (!((mousePos.y + 5) % 10) && ((mousePos.x < 207) || (mousePos.y != 135)))) {
 						//goto T0281023;
 					}
-					L0810_i_Character = 'A' + (11 * ((mousePos.y - 116) / 10)) + ((mousePos.x - 107) / 10);
-					if ((L0810_i_Character == 86) || (L0810_i_Character == 97)) { /* The 'Return' button occupies two cells in the table */
-						L0810_i_Character = '\r'; /* Carriage return */
+					curCharacter = 'A' + (11 * ((mousePos.y - 116) / 10)) + ((mousePos.x - 107) / 10);
+					if ((curCharacter == 86) || (curCharacter == 97)) { /* The 'Return' button occupies two cells in the table */
+						curCharacter = '\r'; /* Carriage return */
 						break;
 					}
-					if (L0810_i_Character >= 87) { /* Compensate for the first cell occupied by 'Return' button */
-						L0810_i_Character--;
-					}
-					if (L0810_i_Character > 'Z') {
-						L0810_i_Character = G0053_ac_Graphic562_ReincarnateSpecialCharacters[(L0810_i_Character - 'Z') - 1];
-					}
+					if (curCharacter >= 87) // Compensate for the first cell occupied by 'Return' button
+						curCharacter--;
+
+					if (curCharacter > 'Z')
+						curCharacter = reincarnateSpecialCharacters[(curCharacter - 'Z') - 1];
+
 					break;
 				}
-			} else if (eventType == Common::EVENT_KEYDOWN) {
-				L0810_i_Character = event.kbd.ascii;
-			}
+			} else if (eventType == Common::EVENT_KEYDOWN)
+				curCharacter = event.kbd.ascii;
 		}
 
-		if ((L0810_i_Character >= 'a') && (L0810_i_Character <= 'z')) {
-			L0810_i_Character -= 32; /* Convert to uppercase */
-		}
-		if (((L0810_i_Character >= 'A') && (L0810_i_Character <= 'Z')) || (L0810_i_Character == '.') || (L0810_i_Character == ',') || (L0810_i_Character == ';') || (L0810_i_Character == ':') || (L0810_i_Character == ' ')) {
-			if ((L0810_i_Character == ' ') && AL0808_ui_CharacterIndex == 0) {
-			} else {
-				if (!L0811_B_ChampionTitleIsFull) {
-					G0052_ac_Graphic562_RenameChampionInputCharacterString[0] = L0810_i_Character;
+		if ((curCharacter >= 'a') && (curCharacter <= 'z'))
+			curCharacter -= 32; // Convert to uppercase
+
+		if (((curCharacter >= 'A') && (curCharacter <= 'Z')) || (curCharacter == '.') || (curCharacter == ',') || (curCharacter == ';') || (curCharacter == ':') || (curCharacter == ' ')) {
+			if ((curCharacter != ' ') || curCharacterIndex != 0) {
+				if (!championTitleIsFull) {
+					renameChampionInputCharacterString[0] = curCharacter;
 					_vm->_eventMan->f78_showMouse();
-					_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k13_ColorLightestGray, k12_ColorDarkestGray, G0052_ac_Graphic562_RenameChampionInputCharacterString, k200_heightScreen);
+					_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, renameChampionInputCharacterString, k200_heightScreen);
 					_vm->_eventMan->f77_hideMouse();
-					L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex++] = L0810_i_Character;
-					L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex] = '\0';
-					L0813_i_X += 6;
-					if ((L0809_i_RenamedChampionString == k1_RENAME_CHAMPION_NAME) && (AL0808_ui_CharacterIndex == 7))
-						goto T0281033_ProceedToTitle;
+					renamedChampionString[curCharacterIndex++] = curCharacter;
+					renamedChampionString[curCharacterIndex] = '\0';
+					textPosX += 6;
+					if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex == 7)) {
+						renamedChampionStringMode = k2_RENAME_CHAMPION_TITLE;
+						renamedChampionString = champ->_title;
+						textPosX = 105;
+						textPosY = 109;
+						curCharacterIndex = 0;
+					}
 				}
 			}
-		} else {
-			if (L0810_i_Character == '\r') { /* Carriage return */
-				if ((L0809_i_RenamedChampionString == k1_RENAME_CHAMPION_NAME) && (AL0808_ui_CharacterIndex > 0)) {
-					_vm->_eventMan->f78_showMouse();
-					_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k13_ColorLightestGray, k12_ColorDarkestGray, G0051_ac_Graphic562_UnderscoreCharacterString, k200_heightScreen);
-					_vm->_eventMan->f77_hideMouse();
-T0281033_ProceedToTitle:
-					L0809_i_RenamedChampionString = k2_RENAME_CHAMPION_TITLE;
-					L0812_pc_RenamedChampionString = champ->_title;
-					L0813_i_X = 105;
-					L0814_i_Y = 109;
-					AL0808_ui_CharacterIndex = 0;
-				}
+		} else if (curCharacter == '\r') { /* Carriage return */
+			if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex > 0)) {
+				_vm->_eventMan->f78_showMouse();
+				_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
+				_vm->_eventMan->f77_hideMouse();
+				renamedChampionStringMode = k2_RENAME_CHAMPION_TITLE;
+				renamedChampionString = champ->_title;
+				textPosX = 105;
+				textPosY = 109;
+				curCharacterIndex = 0;
+			}
+		} else if (curCharacter == '\b') { /* Backspace */
+			if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex == 0))
+				continue;
+
+			if (!championTitleIsFull) {
+				_vm->_eventMan->f78_showMouse();
+				_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
+				_vm->_eventMan->f77_hideMouse();
+			}
+			if (curCharacterIndex == 0) {
+				renamedChampionString = champ->_name;
+				curCharacterIndex = strlen(renamedChampionString) - 1;
+				renamedChampionStringMode = k1_RENAME_CHAMPION_NAME;
+				textPosX = 177 + (curCharacterIndex * 6);
+				textPosY = 91;
 			} else {
-				if (L0810_i_Character == '\b') { /* Backspace */
-					if ((L0809_i_RenamedChampionString == k1_RENAME_CHAMPION_NAME) && (AL0808_ui_CharacterIndex == 0))
-						continue;
-					if (!L0811_B_ChampionTitleIsFull) {
-						_vm->_eventMan->f78_showMouse();
-						_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k13_ColorLightestGray, k12_ColorDarkestGray, G0051_ac_Graphic562_UnderscoreCharacterString, k200_heightScreen);
-						_vm->_eventMan->f77_hideMouse();
-					}
-					if (AL0808_ui_CharacterIndex == 0) {
-						L0812_pc_RenamedChampionString = champ->_name;
-						AL0808_ui_CharacterIndex = strlen(L0812_pc_RenamedChampionString) - 1;
-						L0809_i_RenamedChampionString = k1_RENAME_CHAMPION_NAME;
-						L0813_i_X = 177 + (AL0808_ui_CharacterIndex * 6);
-						L0814_i_Y = 91;
-					} else {
-						AL0808_ui_CharacterIndex--;
-						L0813_i_X -= 6;
-					}
-					L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex] = '\0';
-				}
+				curCharacterIndex--;
+				textPosX -= 6;
 			}
+			renamedChampionString[curCharacterIndex] = '\0';
 		}
 	}
 }


Commit: b87d7620870c80b93bb13779bfa78a02d5359384
    https://github.com/scummvm/scummvm/commit/b87d7620870c80b93bb13779bfa78a02d5359384
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix compilation using MSVC9

Changed paths:
    engines/dm/menus.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 513b8fb..b6db53d 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -1668,8 +1668,8 @@ int16 MenuMan::f382_getActionObjectChargeCount() {
 }
 
 void MenuMan::f385_drawActionDamage(int16 damage) {
-	static Box G0502_s_Graphic560_Box_ActionAreaMediumDamage = {242, 305, 81, 117};
-	static Box G0503_s_Graphic560_Box_ActionAreaSmallDamage = {251, 292, 81, 117};
+	static const Box G0502_s_Graphic560_Box_ActionAreaMediumDamage = Box(242, 305, 81, 117);
+	static const Box G0503_s_Graphic560_Box_ActionAreaSmallDamage = Box(251, 292, 81, 117);
 
 	uint16 L1174_ui_Multiple;
 #define AL1174_ui_DerivedBitmapIndex L1174_ui_Multiple
@@ -1683,7 +1683,7 @@ void MenuMan::f385_drawActionDamage(int16 damage) {
 #define AL1178_puc_String L1178_puc_Multiple
 #define AL1178_puc_Bitmap L1178_puc_Multiple
 	char L1179_ac_String[6];
-	Box* L1180_ps_Box;
+	const Box* L1180_ps_Box;
 	int16 L1643_i_Width;
 
 	_vm->_eventMan->f78_showMouse();
@@ -1725,7 +1725,7 @@ void MenuMan::f385_drawActionDamage(int16 damage) {
 				L1177_puc_Bitmap = _vm->_displayMan->f492_getDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
 			}
 		}
-		_vm->_displayMan->f21_blitToScreen(L1177_puc_Bitmap, L1180_ps_Box, L1175_i_ByteWidth, kM1_ColorNoTransparency, L1643_i_Width);
+		_vm->_displayMan->f21_blitToScreen(L1177_puc_Bitmap, (int16 *)L1180_ps_Box, L1175_i_ByteWidth, kM1_ColorNoTransparency, L1643_i_Width);
 		/* Convert damage value to string */
 		AL1174_ui_CharacterIndex = 5;
 		AL1176_i_X = 274;


Commit: a80ae5537962d6e34fb263e619bd93fbf037d193
    https://github.com/scummvm/scummvm/commit/a80ae5537962d6e34fb263e619bd93fbf037d193
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: some minor changes in f291_drawSlot and f281_renameChampion

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index c4809cb..f79c60c 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -2204,7 +2204,8 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
 	bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex));
 
 	uint16 slotBoxIndex;
-	if (!isInventoryChamp) {  /* If drawing a slot for a champion other than the champion whose inventory is open */
+	if (!isInventoryChamp) {
+		// If drawing a slot for a champion other than the champion whose inventory is open
 		if ((slotIndex > k1_ChampionSlotActionHand) || (_g299_candidateChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)))
 			return;
 		slotBoxIndex = (champIndex << 1) + slotIndex;
@@ -2260,13 +2261,12 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
 
 	if (nativeBitmapIndex != -1) {
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		if (isInventoryChamp) {
+		if (isInventoryChamp)
 			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
 												_vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray);
-		} else {
+		else
 			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
 												_vm->_displayMan->_g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen, k12_ColorDarkestGray);
-		}
 	}
 
 	_vm->_objectMan->f38_drawIconInSlotBox(slotBoxIndex, iconIndex);
@@ -2319,7 +2319,8 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 			_vm->_displayMan->updateScreen();
 			_vm->f22_delay(1);
 
-			if (eventType == Common::EVENT_LBUTTONDOWN) { /* If left mouse button status has changed */
+			if (eventType == Common::EVENT_LBUTTONDOWN) {
+				// If left mouse button status has changed
 				Common::Point mousePos = _vm->_eventMan->getMousePos();
 				if ((renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE || (curCharacterIndex > 0)) && (mousePos.x >= 197) && (mousePos.x <= 215) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'OK' button */
 					int16 characterIndexBackup = curCharacterIndex;
@@ -2327,14 +2328,14 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 					renamedChampionString = champ->_name;
 					strcpy(L0821_ac_ChampionNameBackupString, renamedChampionString);
 					curCharacterIndex = strlen(renamedChampionString);
-					while (renamedChampionString[--curCharacterIndex] == ' ')
 					// Replace space characters on the right of the champion name by '\0' characters
+					while (renamedChampionString[--curCharacterIndex] == ' ')
 						renamedChampionString[curCharacterIndex] = '\0';
 
 					bool found = false;
 					for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_g305_partyChampionCount - 1; idx++) {
 						if (!strcmp(_vm->_championMan->_gK71_champions[idx]._name, renamedChampionString)) {
-						// If an existing champion already has the specified name for the new champion
+							// If an existing champion already has the specified name for the new champion
 							found = true;
 							break;
 						}
@@ -2352,18 +2353,23 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 						curCharacter = '\b';
 						break;
 					}
+#if 0
 					if ((mousePos.x < 107) || (mousePos.x > 215) || (mousePos.y < 116) || (mousePos.y > 144)) {/* Coordinates of table of all other characters */
 						//goto T0281023;
 					}
 					if (!((mousePos.x + 4) % 10) || (!((mousePos.y + 5) % 10) && ((mousePos.x < 207) || (mousePos.y != 135)))) {
 						//goto T0281023;
 					}
+#endif
 					curCharacter = 'A' + (11 * ((mousePos.y - 116) / 10)) + ((mousePos.x - 107) / 10);
-					if ((curCharacter == 86) || (curCharacter == 97)) { /* The 'Return' button occupies two cells in the table */
+					if ((curCharacter == 86) || (curCharacter == 97)) {
+						// The 'Return' button occupies two cells in the table
 						curCharacter = '\r'; /* Carriage return */
 						break;
 					}
-					if (curCharacter >= 87) // Compensate for the first cell occupied by 'Return' button
+
+					if (curCharacter >= 87)
+						// Compensate for the first cell occupied by 'Return' button
 						curCharacter--;
 
 					if (curCharacter > 'Z')
@@ -2397,7 +2403,7 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 					}
 				}
 			}
-		} else if (curCharacter == '\r') { /* Carriage return */
+		} else if (curCharacter == '\r') { // Carriage return
 			if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex > 0)) {
 				_vm->_eventMan->f78_showMouse();
 				_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
@@ -2408,7 +2414,7 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 				textPosY = 109;
 				curCharacterIndex = 0;
 			}
-		} else if (curCharacter == '\b') { /* Backspace */
+		} else if (curCharacter == '\b') { // Backspace
 			if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex == 0))
 				continue;
 
@@ -2445,13 +2451,14 @@ uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, uint16 skillIndex) {
 	if (!ignoreTmpExp)
 		exp += skill->_temporaryExperience;
 
-	if (skillIndex > k3_ChampionSkillWizard) { /* Hidden skill */
+	if (skillIndex > k3_ChampionSkillWizard) {
+		// Hidden skill
 		skill = &champ->_skills[(skillIndex - k4_ChampionSkillSwing) >> 2];
-		exp += skill->_experience; /* Add experience in the base skill */
+		exp += skill->_experience; // Add experience in the base skill
 		if (!ignoreTmpExp)
 			exp += skill->_temporaryExperience;
 
-		exp >>= 1; /* Halve experience to get average of base skill + hidden skill experience */
+		exp >>= 1; // Halve experience to get average of base skill + hidden skill experience
 	}
 	int16 skillLevel = 1;
 	while (exp >= 500) {
@@ -2492,5 +2499,3 @@ uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, uint16 skillIndex) {
 }
 
 }
-
-


Commit: f52469ce05ea962b16a9f9b01e34966e49e4bb1c
    https://github.com/scummvm/scummvm/commit/f52469ce05ea962b16a9f9b01e34966e49e4bb1c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add a stub for f436_STARTEND_FadeToPalette

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 6384302..8ca6caf 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -155,11 +155,12 @@ Box g2_BoxMovementArrows = Box(224, 319, 124, 168); // @ G0002_s_Graphic562_Box_
 byte g212_PalChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke
 
 ExplosionAspect g211_ExplosionAspects[k4_ExplosionAspectCount] = { // @ G0211_as_Graphic558_ExplosionAspects
-	/* { ByteWidth, Height } */
-	ExplosionAspect(80, 111),   /* Fire   */
-ExplosionAspect(64,  97),   /* Spell  */
-ExplosionAspect(80,  91),   /* Poison */
-ExplosionAspect(80,  91)}; /* Death  */
+	// ByteWidth, Height 
+	ExplosionAspect(80, 111),   // Fire
+	ExplosionAspect(64,  97),   // Spell
+	ExplosionAspect(80,  91),   // Poison
+	ExplosionAspect(80,  91)    // Death
+};
 
 #define k730_DerivedBitmapMaximumCount 730 // @ C730_DERIVED_BITMAP_MAXIMUM_COUNT
 
@@ -708,21 +709,20 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 
 	g186_doorFrame_D1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-										Frame(64, 159, 17, 102, 48, 88, 0, 0),	/* Closed Or Destroyed */
-										Frame(64, 159, 17, 38, 48, 88, 0, 66),	/* Vertical Closed one fourth */
-										Frame(64, 159, 17, 60, 48, 88, 0, 44),	/* Vertical Closed half */
-										Frame(64, 159, 17, 82, 48, 88, 0, 22),	/* Vertical Closed three fourth */
-										Frame(64, 75, 17, 102, 48, 88, 36, 0),	/* Left Horizontal Closed one fourth */
-										Frame(64, 87, 17, 102, 48, 88, 24, 0),	/* Left Horizontal Closed half */
-										Frame(64, 99, 17, 102, 48, 88, 12, 0),	/* Left Horizontal Closed three fourth */
-										Frame(148, 159, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed one fourth */
-										Frame(136, 159, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed half */
-										Frame(124, 159, 17, 102, 48, 88, 48, 0)	/* Right Horizontal Closed three fourth */
+		Frame(64, 159, 17, 102, 48, 88, 0, 0),	/* Closed Or Destroyed */
+		Frame(64, 159, 17, 38, 48, 88, 0, 66),	/* Vertical Closed one fourth */
+		Frame(64, 159, 17, 60, 48, 88, 0, 44),	/* Vertical Closed half */
+		Frame(64, 159, 17, 82, 48, 88, 0, 22),	/* Vertical Closed three fourth */
+		Frame(64, 75, 17, 102, 48, 88, 36, 0),	/* Left Horizontal Closed one fourth */
+		Frame(64, 87, 17, 102, 48, 88, 24, 0),	/* Left Horizontal Closed half */
+		Frame(64, 99, 17, 102, 48, 88, 12, 0),	/* Left Horizontal Closed three fourth */
+		Frame(148, 159, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed one fourth */
+		Frame(136, 159, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed half */
+		Frame(124, 159, 17, 102, 48, 88, 48, 0)	/* Right Horizontal Closed three fourth */
 	);
-	for (uint16 i = 0; i < 16; ++i) {
-		_g347_paletteTopAndBottomScreen[i] = 0;
-		_g346_paletteMiddleScreen[i] = 0;
-	}
+
+	for (uint16 i = 0; i < 32; i++)
+		_g345_aui_BlankBuffer[i] = 0;
 }
 
 DisplayMan::~DisplayMan() {
@@ -3695,17 +3695,4 @@ void DisplayMan::f493_addDerivedBitmap(int16 derivedBitmapIndex) {
 	warning(false, "f493_addDerivedBitmap DOES NOTHING");
 }
 
-uint16 DisplayMan::f431_getDarkenedColor(uint16 RGBcolor) {
-	if (getFlag(RGBcolor, D12_MASK_BLUE_COMPONENT)) {
-		RGBcolor--;
-	}
-	if (getFlag(RGBcolor, D11_MASK_GREEN_COMPONENT)) {
-		RGBcolor -= 16;
-	}
-	if (getFlag(RGBcolor, D10_MASK_RED_COMPONENT)) {
-		RGBcolor -= 256;
-	}
-	return RGBcolor;
-}
-
 }
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 0d9017d..dfd458e 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -207,7 +207,6 @@ enum GraphicIndice {
 	k3_entranceRightDoorGraphicIndice = 3, // @ C003_GRAPHIC_ENTRANCE_RIGHT_DOOR
 	k4_entranceGraphicIndice = 4, // @ C004_GRAPHIC_ENTRANCE
 	k5_creditsGraphicIndice = 5, // @ C005_GRAPHIC_CREDITS
-	k6_theEndIndice = 6, // @ C006_GRAPHIC_THE_END
 	k8_StatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION
 	k9_MenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND
 	k10_MenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA
@@ -267,7 +266,6 @@ enum GraphicIndice {
 	k69_FieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R
 	k73_FieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER
 	k120_InscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT
-	k208_wallOrn_43_champMirror = 208, // @ C208_GRAPHIC_WALL_ORNAMENT_43_CHAMPION_MIRROR
 	k241_FloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS
 	k301_DoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
 	k315_firstDoorButton_GraphicIndice = 315, // @ C315_GRAPHIC_FIRST_DOOR_BUTTON
@@ -306,7 +304,7 @@ public:
 	bool isPointInside(Common::Point point) {
 		return (_x1 <= point.x) && (point.x <= _x2) && (_y1 <= point.y) && (point.y <= _y2); // <= because incluseive boundaries
 	}
-	bool isPointInside(int16 x, int16 y) { return isPointInside(Common::Point(x, y)); }
+	bool isPointInside(int16 x, int16 y) { return isPointInside(Common::Point(x, y));  }
 	void setToZero() { _x1 = _x2 = _y1 = _y2 = 0; }
 }; // @ BOX_BYTE, BOX_WORD
 
@@ -505,21 +503,6 @@ public:
 	}
 }; // @ DOOR_FRAMES
 
-#define D00_RGB_BLACK                                0x0000
-#define D01_RGB_DARK_BLUE                            0x0004
-#define D02_RGB_LIGHT_BROWN                          0x0842
-#define D03_RGB_PINK                                 0x086F
-#define D04_RGB_LIGHTER_BROWN                        0x0A62
-#define D05_RGB_DARK_GOLD                            0x0A82
-#define D06_RGB_GOLD                                 0x0CA2
-#define D07_RGB_RED                                  0x0F00
-#define D08_RGB_YELLOW                               0x0FF4
-#define D09_RGB_WHITE                                0x0FFF
-#define D10_MASK_RED_COMPONENT                       0x0F00
-#define D10_MASK_RED_COMPONENT 0x0F00
-#define D11_MASK_GREEN_COMPONENT 0x00F0
-#define D12_MASK_BLUE_COMPONENT 0x000F
-
 class DisplayMan {
 	friend class DM::TextMan;
 
@@ -596,9 +579,7 @@ class DisplayMan {
 	byte *_g696_bitmapWallSet_Wall_D3R2; // @ G0696_puc_Bitmap_WallSet_Wall_D3R2
 	byte *_g698_bitmapWallSet_Wall_D3LCR; // @ G0698_puc_Bitmap_WallSet_Wall_D3LCR
 	byte *_g699_bitmapWallSet_Wall_D2LCR; // @ G0699_puc_Bitmap_WallSet_Wall_D2LCR
-public:
 	byte *_g700_bitmapWallSet_Wall_D1LCR; // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR
-private:
 	byte *_g701_bitmapWallSet_Wall_D0L; // @ G0701_puc_Bitmap_WallSet_Wall_D0L
 	byte *_g702_bitmapWallSet_Wall_D0R; // @ G0702_puc_Bitmap_WallSet_Wall_D0R
 	byte *_g703_bitmapWallSet_DoorFrameTop_D2LCR; // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR
@@ -630,7 +611,6 @@ private:
 	int16 _g694_doorNativeBitmapIndex_Front_D2LCR[2]; // @ G0694_ai_DoorNativeBitmapIndex_Front_D2LCR
 	int16 _g695_doorNativeBitmapIndex_Front_D1LCR[2]; // @ G0695_ai_DoorNativeBitmapIndex_Front_D1LCR
 public:
-
 	uint16 _screenWidth;
 	uint16 _screenHeight;
 	byte *_g348_bitmapScreen; // @ G0348_pl_Bitmap_Screen
@@ -641,8 +621,8 @@ public:
 	bool _g322_paletteSwitchingEnabled; // @ G0322_B_PaletteSwitchingEnabled
 	bool _g342_refreshDungeonViewPaleteRequested; // @ G0342_B_RefreshDungeonViewPaletteRequested
 	int16 _g304_dungeonViewPaletteIndex; // @ G0304_i_DungeonViewPaletteIndex
+	uint16 _g345_aui_BlankBuffer[32]; // @G0345_aui_BlankBuffer
 	uint16 _g347_paletteTopAndBottomScreen[16]; // @ G0347_aui_Palette_TopAndBottomScreen
-	uint16 _g346_paletteMiddleScreen[16]; // @ G0346_aui_Palette_MiddleScreen
 
 	explicit DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
@@ -666,7 +646,6 @@ public:
 	/// Gives the height of an IMG1 type item
 	uint16 getPixelHeight(uint16 index);
 
-
 	void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); // @ F0099_DUNGEONVIEW_CopyBitmapAndFlipHorizontal
 	void f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloorIndex); // @ F0108_DUNGEONVIEW_DrawFloorOrnament
 	void f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16 *doorNativeBitmapIndices, int16 byteCount,
@@ -678,19 +657,19 @@ public:
 	void f20_blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
 	void f21_blitToScreen(byte* bitmap, int16 *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen
 	void f21_blitToScreen(byte* bitmap, Box *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen
+	
 
-
-	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which
+	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which 
 	does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters
 	match the original exatcly, if need arises for heights then we'll have to retrospectively add them in old function calls*/
 	/* Expects inclusive boundaries in box */
 	void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
-						   uint16 destByteWidth, Color transparent = kM1_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit
-	 /* Expects inclusive boundaries in box */
+					  uint16 destByteWidth, Color transparent = kM1_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit
+/* Expects inclusive boundaries in box */
 	void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
-											int16 firstUnitIndex, int16 destByteWidth, Color transparent,
-											int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
-		 // this function takes pixel widths
+									   int16 firstUnitIndex, int16 destByteWidth, Color transparent,
+									   int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
+	// this function takes pixel widths
 	void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
 											  int16 srcPixelWidth, int16 srcHight, int16 destPixelWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
 	void f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height); // @ F0130_VIDEO_FlipHorizontal
@@ -716,8 +695,8 @@ public:
 	int16 f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale); // @ F0459_START_GetScaledBitmapByteCount
 	int16 M78_getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION
 	void f115_cthulhu(Thing thingParam, Direction directionParam,
-					  int16 mapXpos, int16 mapYpos, int16 viewSquareIndex,
-					  uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
+				 int16 mapXpos, int16 mapYpos, int16 viewSquareIndex,
+				 uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 	uint16 M77_getNormalizedByteWidth(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH
 	uint16 M23_getVerticalOffsetM23(uint16 val); // @ M23_VERTICAL_OFFSET
 	uint16 M22_getHorizontalOffsetM22(uint16 val); // @ M22_HORIZONTAL_OFFSET
@@ -747,7 +726,9 @@ public:
 	bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
 	byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap
 	void f493_addDerivedBitmap(int16 derivedBitmapIndex); // @ F0493_CACHE_AddDerivedBitmap
-	uint16 f431_getDarkenedColor(uint16 RGBcolor);
+
+	void f436_STARTEND_FadeToPalette(uint16 *P0849_pui_Palette) { warning(false, "STUB: f436_STARTEND_FadeToPalette"); }
+
 };
 
 }


Commit: e29d843cfae8f399800c4c077e10976da9e26c57
    https://github.com/scummvm/scummvm/commit/e29d843cfae8f399800c4c077e10976da9e26c57
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f427_dialogDraw

Changed paths:
    engines/dm/dialog.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index 71ff8dc..6a99ee5 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -36,110 +36,104 @@ namespace DM {
 DialogMan::DialogMan(DMEngine* vm) : _vm(vm) {}
 
 void DialogMan::f427_dialogDraw(char* msg1, char* msg2, char* choice1, char* choice2, char* choice3, char* choice4, bool screenDialog, bool clearScreen, bool fading) {
-	static Box K0068_s_Box1 = Box(0, 223, 101, 125);
-	static Box K0069_s_Box2 = Box(0, 223,  76, 100);
-	static Box K0070_s_Box3 = Box(0, 223,  51,  75);
-	static Box G0469_s_Graphic561_Box_Dialog2ChoicesPatch = Box(102, 122, 89, 125);
-	static Box G0470_s_Graphic561_Box_Dialog4ChoicesPatch = Box(102, 122, 62, 97);
-
-	int16 L1308_i_X;
-	int16 L1309_i_Y;
-	int16 L1310_i_ChoiceCount;
-	char L1312_ac_StringPart1[70];
-	char L1313_ac_StringPart2[70];
-	Box L1314_s_Box;
-
+	static Box constBox1 = Box(0, 223, 101, 125);
+	static Box constBox2 = Box(0, 223,  76, 100);
+	static Box constBox3 = Box(0, 223,  51,  75);
+	static Box dialog2ChoicesPatch = Box(102, 122, 89, 125);
+	static Box dialog4ChoicesPatch = Box(102, 122, 62, 97);
 
 	_vm->_displayMan->f466_loadIntoBitmap(k0_dialogBoxGraphicIndice, _vm->_displayMan->_g296_bitmapViewport);
 	//Strangerke: the version should be replaced by a ScummVM/RogueVM (?) string
 	// TODO: replace with ScummVM version string
 	_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 192, 7, k2_ColorLightGray, k1_ColorDarkGary, "V2.2", k136_heightViewport);
-	L1310_i_ChoiceCount = 1;
-	if (choice2 != nullptr) {
-		L1310_i_ChoiceCount++;
-	}
-	if (choice3 != nullptr) {
-		L1310_i_ChoiceCount++;
-	}
-	if (choice4 != nullptr) {
-		L1310_i_ChoiceCount++;
-	}
-	if (fading) {
-		warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette in f427_dialogDraw");
-	}
-	if (clearScreen) {
+	int16 choiceCount = 1;
+	if (choice2)
+		choiceCount++;
+
+	if (choice3)
+		choiceCount++;
+
+	if (choice4)
+		choiceCount++;
+
+	if (fading)
+		_vm->_displayMan->f436_STARTEND_FadeToPalette(_vm->_displayMan->_g345_aui_BlankBuffer);
+
+	if (clearScreen)
 		_vm->_displayMan->fillScreen(k0_ColorBlack);
-	}
+
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	if (L1310_i_ChoiceCount == 1) {
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, K0068_s_Box1, 0, 64, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, K0069_s_Box2, 0, 39, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, K0070_s_Box3, 0, 14, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
+	if (choiceCount == 1) {
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, constBox1, 0, 64, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, constBox2, 0, 39, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, constBox3, 0, 14, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
 		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 114);
-	} else {
-		if (L1310_i_ChoiceCount == 2) {
-			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, G0469_s_Graphic561_Box_Dialog2ChoicesPatch, 102, 52, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
-			f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77);
-			f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 112, 114);
-		} else {
-			if (L1310_i_ChoiceCount == 3) {
-				f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77);
-				f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 59, 114);
-				f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 166, 114);
-			} else {
-				if (L1310_i_ChoiceCount == 4) {
-					_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, G0470_s_Graphic561_Box_Dialog4ChoicesPatch, 102, 99, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
-					f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 59, 77);
-					f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 166, 77);
-					f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 59, 114);
-					f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice4, 166, 114);
-				}
-			}
-		}
+	} else if (choiceCount == 2) {
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, dialog2ChoicesPatch, 102, 52, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
+		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77);
+		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 112, 114);
+	} else if (choiceCount == 3) {
+		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77);
+		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 59, 114);
+		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 166, 114);
+	} else if (choiceCount == 4) {
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, dialog4ChoicesPatch, 102, 99, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
+		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 59, 77);
+		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 166, 77);
+		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 59, 114);
+		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice4, 166, 114);
 	}
-	L1309_i_Y = 29;
-	if (msg1 != nullptr) {
+
+	int16 textPosX;
+	int16 textPosY = 29;
+	if (msg1) {
+		char L1312_ac_StringPart1[70];
+		char L1313_ac_StringPart2[70];
 		if (f426_isMessageOnTwoLines(msg1, L1312_ac_StringPart1, L1313_ac_StringPart2)) {
-			L1309_i_Y = 21;
-			L1308_i_X = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k11_ColorYellow, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
-			L1309_i_Y += 8;
-			L1308_i_X = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k11_ColorYellow, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport);
-			L1309_i_Y += 8;
+			textPosY = 21;
+			textPosX = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
+			textPosY += 8;
+			textPosX = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport);
+			textPosY += 8;
 		} else {
-			L1308_i_X = 113 - ((strlen(msg1) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k11_ColorYellow, k5_ColorLightBrown, msg1, k136_heightViewport);
-			L1309_i_Y += 8;
+			textPosX = 113 - ((strlen(msg1) * 6) >> 1);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, msg1, k136_heightViewport);
+			textPosY += 8;
 		}
 	}
-	if (msg2 != nullptr) {
+	if (msg2) {
+		char L1312_ac_StringPart1[70];
+		char L1313_ac_StringPart2[70];
 		if (f426_isMessageOnTwoLines(msg2, L1312_ac_StringPart1, L1313_ac_StringPart2)) {
-			L1308_i_X = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k9_ColorGold, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
-			L1309_i_Y += 8;
-			L1308_i_X = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k9_ColorGold, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport);
+			textPosX = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
+			textPosY += 8;
+			textPosX = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport);
 		} else {
-			L1308_i_X = 113 - ((strlen(msg2) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k9_ColorGold, k5_ColorLightBrown, msg2, k136_heightViewport);
+			textPosX = 113 - ((strlen(msg2) * 6) >> 1);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, msg2, k136_heightViewport);
 		}
 	}
 	if (screenDialog) {
-		L1314_s_Box._y1 = 33;
-		L1314_s_Box._y2 = 168;
-		L1314_s_Box._x1 = 47;
-		L1314_s_Box._x2 = 270;
+		Box displayBox;
+		displayBox._y1 = 33;
+		displayBox._y2 = 168;
+		displayBox._x1 = 47;
+		displayBox._x2 = 270;
 		_vm->_eventMan->f78_showMouse();
-		_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->_g296_bitmapViewport, &L1314_s_Box, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport);
+		_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->_g296_bitmapViewport, &displayBox, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport);
 		_vm->_eventMan->f77_hideMouse();
 	} else {
 		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
 		_vm->f22_delay(1);
 	}
-	if (fading) {
-		warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette in f427_dialogDraw");
-	}
+
+	if (fading)
+		_vm->_displayMan->f436_STARTEND_FadeToPalette(_vm->_displayMan->_g347_paletteTopAndBottomScreen);
+
 	_vm->_displayMan->_g297_drawFloorAndCeilingRequested = true;
 }
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index dfd458e..387a73d 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -718,7 +718,7 @@ public:
 
 	bool _g297_drawFloorAndCeilingRequested; // @ G0297_B_DrawFloorAndCeilingRequested
 
-	// This tells blitting functions wther to assume a BYTE_BOX or a WORD_BOX has been passed to them,
+	// This tells blitting functions whether to assume a BYTE_BOX or a WORD_BOX has been passed to them,
 	// I only use WORD_BOX, so this will probably deem useless
 	bool _g578_useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates
 	bool _g77_doNotDrawFluxcagesDuringEndgame; // @ G0077_B_DoNotDrawFluxcagesDuringEndgame


Commit: 22d6973de5814a6229fb665a43882df1eb140048
    https://github.com/scummvm/scummvm/commit/22d6973de5814a6229fb665a43882df1eb140048
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add sound loading

Changed paths:
  A engines/dm/sounds.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/gfx.cpp
    engines/dm/group.h
    engines/dm/module.mk



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 8521450..50afa43 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -202,6 +202,9 @@ DMEngine::~DMEngine() {
 	delete _projexpl;
 	delete _dialog;
 
+	for (uint16 i = 0; i < k34_D13_soundCount; ++i)
+		delete[] _gK24_soundData[i]._firstSample;
+
 	// clear debug channels
 	DebugMan.clearAllDebugChannels();
 }
@@ -227,7 +230,8 @@ void DMEngine::f463_initializeGame() {
 	_displayMan->loadPalette(g21_PalDungeonView[0]);
 	_displayMan->f94_loadFloorSet(k0_FloorSetStone);
 	_displayMan->f95_loadWallSet(k0_WallSetStone);
-
+	f503_loadSounds();
+	warning(false, "MISSING CODE: F0437_STARTEND_DrawTitle");
 	_textMan->f54_textInitialize();
 	_objectMan->loadObjectNames();
 	_eventMan->initMouse();
@@ -697,5 +701,4 @@ void DMEngine::f439_drawEntrance() {
 	_displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[4], &G0011_s_Graphic562_Box_Entrance_ClosedDoorRight, k64_byteWidth, kM1_ColorNoTransparency, 161);
 	warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(g20_PalEntrance);");
 }
-
 } // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index cb7d07f..a6d2fe6 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -195,6 +195,16 @@ struct SaveGameHeader {
 };
 
 
+#define k34_D13_soundCount 34 // @ D13_SOUND_COUNT
+
+class SoundData {
+public:
+	uint32 _byteCount;
+	byte* _firstSample;
+	uint32 _sampleCount;
+	SoundData(): _byteCount(0), _firstSample(nullptr), _sampleCount(0) {}
+}; // @ SOUND_DATA
+
 class DMEngine : public Engine {
 	void f462_startGame(); // @ F0462_START_StartGame_CPSF
 	void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
@@ -206,6 +216,7 @@ class DMEngine : public Engine {
 	void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
 	bool readSaveGameHeader(Common::InSaveFile *file, SaveGameHeader *header);
 	void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance
+	void f503_loadSounds(); // @ F0503_SOUND_LoadAll
 public:
 	explicit DMEngine(OSystem *syst);
 	~DMEngine();
@@ -233,6 +244,7 @@ private:
 	byte *_g562_entranceDoorAnimSteps[10]; // @ G0562_apuc_Bitmap_EntranceDoorAnimationSteps
 	byte *_g564_interfaceCredits; // @ G0564_puc_Graphic5_InterfaceCredits
 	Common::RandomSource *_rnd;
+	SoundData _gK24_soundData[k34_D13_soundCount]; // @ K0024_as_SoundData
 public:
 	DisplayMan *_displayMan;
 	DungeonMan *_dungeonMan;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 8ca6caf..515bca2 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2642,10 +2642,12 @@ Common::MemoryReadStream DisplayMan::getCompressedData(uint16 index) {
 	return Common::MemoryReadStream(_packedBitmaps + _packedItemPos[index], getCompressedDataSize(index), DisposeAfterUse::NO);
 }
 
+
 uint32 DisplayMan::getCompressedDataSize(uint16 index) {
 	return _packedItemPos[index + 1] - _packedItemPos[index];
 }
 
+
 /* Field Aspect Mask */
 #define kMaskFieldAspectFlipMask 0x0080 // @ MASK0x0080_FLIP_MASK 
 #define kMaskFieldAspectIndex 0x007F // @ MASK0x007F_MASK_INDEX
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 5194b90..804b562 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -149,7 +149,6 @@ public:
 #define k255_immobile 255 // @ C255_IMMOBILE
 #define kM1_wholeCreatureGroup -1 // @ CM1_WHOLE_CREATURE_GROUP 
 
-#define k34_D13_soundCount 34 // @ D13_SOUND_COUNT
 
 int32 M32_setTime(int32 &map_time, int32 time); // @ M32_SET_TIME
 
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index 75b4385..bf1cef8 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -44,6 +44,7 @@ MODULE_OBJS := \
 	movesens.o \
 	objectman.o \
 	projexpl.o \
+	sounds.o \
 	text.o \
 	timeline.o
 
diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp
new file mode 100644
index 0000000..681ff6d
--- /dev/null
+++ b/engines/dm/sounds.cpp
@@ -0,0 +1,99 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#include "audio/audiostream.h"
+#include "audio/decoders/raw.h"
+
+#include "dm.h"
+#include "gfx.h"
+
+
+namespace DM {
+
+class Sound {
+public:
+	int16 _graphicIndex;
+	byte _period;
+	byte _priority;
+	byte _loudDistance;
+	byte _softDistance;
+	Sound(int16 index, byte period, byte priority, byte loudDist, byte softDist) :
+		_graphicIndex(index), _period(period), _priority(priority), _loudDistance(loudDist), _softDistance(softDist) {}
+}; // @ Sound
+
+
+Sound G0060_as_Graphic562_Sounds[k34_D13_soundCount] = {
+	Sound(533, 112,  11, 3, 6), /* k00_soundMETALLIC_THUD 0 */
+	Sound(534, 112,  15, 0, 3), /* k01_soundSWITCH 1 */
+	Sound(535, 112,  72, 3, 6), /* k02_soundDOOR_RATTLE 2 */
+	Sound(550, 112,  60, 3, 5), /* k03_soundATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON 3 */
+	Sound(536, 112,  10, 3, 6), /* k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM 4 */
+	Sound(537, 112,  99, 3, 7), /* k05_soundSTRONG_EXPLOSION 5 */
+	Sound(539, 112, 110, 3, 6), /* k06_soundSCREAM 6 */
+	Sound(551, 112,  55, 3, 5), /* k07_soundATTACK_MUMMY_GHOST_RIVE 7 */
+	Sound(540, 112,   2, 3, 6), /* k08_soundSWALLOW 8 */
+	Sound(541, 112,  80, 3, 6), /* k09_soundCHAMPION_0_DAMAGED 9 */
+	Sound(542, 112,  82, 3, 6), /* k10_soundCHAMPION_1_DAMAGED 10 */
+	Sound(543, 112,  84, 3, 6), /* k11_soundCHAMPION_2_DAMAGED 11 */
+	Sound(544, 112,  86, 3, 6), /* k12_soundCHAMPION_3_DAMAGED 12 */
+	Sound(545, 112,  95, 3, 6), /* k13_soundSPELL 13 */
+	Sound(552, 112,  57, 3, 5), /* k14_soundATTACK_SCREAMER_OITU 14 */
+	Sound(553, 112,  52, 3, 5), /* k15_soundATTACK_GIANT_SCORPION_SCORPION 15 */
+	Sound(546, 112,  40, 2, 4), /* k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT 16 */
+	Sound(547, 112,  70, 1, 4), /* k17_soundBUZZ 17 */
+	Sound(549, 138,  75, 3, 6), /* k18_soundPARTY_DAMAGED 18 */
+	Sound(554, 112,  50, 3, 5), /* k19_soundATTACK_MAGENTA_WORM_WORM 19 */
+	Sound(537, 112,  98, 0, 4), /* k20_soundWEAK_EXPLOSION 20 */
+	Sound(555, 112,  96, 2, 4), /* k21_soundATTACK_GIGGLER 21 */
+	Sound(563, 138,  24, 0, 4), /* k22_soundMOVE_ANIMATED_ARMOUR_DETH_KNIGHT 22 Atari ST: not present */
+	Sound(564, 138,  21, 0, 4), /* k23_soundMOVE_COUATL_GIANT_WASP_MUNCHER 23 Atari ST: not present */
+	Sound(565, 138,  23, 0, 4), /* k24_soundMOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON 24 Atari ST: not present */
+	Sound(566, 138, 105, 0, 4), /* k25_soundBLOW_HORN 25 Atari ST: not present */
+	Sound(567, 138,  27, 0, 4), /* k26_soundMOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU 26 Atari ST: not present */
+	Sound(568, 138,  28, 0, 4), /* k27_soundMOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL 27 Atari ST: not present */
+	Sound(569, 138, 106, 0, 4), /* k28_soundWAR_CRY 28 Atari ST: not present */
+	Sound(570, 138,  56, 0, 4), /* k29_soundATTACK_ROCK_ROCKPILE 29 Atari ST: not present */
+	Sound(571, 138,  58, 0, 4), /* k30_soundATTACK_WATER_ELEMENTAL 30 Atari ST: not present */
+	Sound(572, 112,  53, 0, 4), /* k31_soundATTACK_COUATL 31 Atari ST: not present */
+	Sound(573, 138,  29, 0, 4), /* k32_soundMOVE_RED_DRAGON 32 Atari ST: not present */
+	Sound(574, 150,  22, 0, 4)}; /* k33_soundMOVE_SKELETON 33 Atari ST: not present */
+
+void DMEngine::f503_loadSounds() {
+	for (uint16 soundIndex = 0; soundIndex < k34_D13_soundCount; ++soundIndex) {
+		SoundData *soundData = _gK24_soundData + soundIndex;
+
+		uint16 graphicIndex = G0060_as_Graphic562_Sounds[soundIndex]._graphicIndex;
+		soundData->_byteCount = _displayMan->getCompressedDataSize(graphicIndex) - 2; // the header is 2 bytes long
+		soundData->_firstSample = new byte[soundData->_byteCount];
+
+		Common::MemoryReadStream stream = _displayMan->getCompressedData(graphicIndex);
+		soundData->_sampleCount = stream.readUint16BE();
+		stream.read(soundData->_firstSample, soundData->_byteCount);
+	}
+}
+
+}


Commit: ba46060b13e7106e524fd1a56086e4e88c0b9fb4
    https://github.com/scummvm/scummvm/commit/ba46060b13e7106e524fd1a56086e4e88c0b9fb4
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix compilation using MSVC9

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 50afa43..3b23028 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -509,11 +509,11 @@ void DMEngine::f441_processEntrance() {
 
 void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 	// TODO: localization
-	static Box G0013_s_Graphic562_Box_Endgame_Restart_Outer = {103, 217, 145, 159};
-	static Box G0014_s_Graphic562_Box_Endgame_Restart_Inner = {105, 215, 147, 157};
-	static Box G0012_s_Graphic562_Box_Endgame_TheEnd = {120, 199, 95, 108};
-	static Box G0015_s_Graphic562_Box_Endgame_ChampionMirror = {11, 74, 7, 49};
-	static Box G0016_s_Graphic562_Box_Endgame_ChampionPortrait = {27, 58, 13, 41};
+	static Box G0013_s_Graphic562_Box_Endgame_Restart_Outer = Box(103, 217, 145, 159);
+	static Box G0014_s_Graphic562_Box_Endgame_Restart_Inner = Box(105, 215, 147, 157);
+	static Box G0012_s_Graphic562_Box_Endgame_TheEnd = Box(120, 199, 95, 108);
+	static Box G0015_s_Graphic562_Box_Endgame_ChampionMirror = Box(11, 74, 7, 49);
+	static Box G0016_s_Graphic562_Box_Endgame_ChampionPortrait = Box(27, 58, 13, 41);
 	int16 L1409_i_Multiple;
 #define AL1409_i_Color              L1409_i_Multiple
 #define AL1409_i_ChampionIndex      L1409_i_Multiple


Commit: 16c3757dcddeeff00b8d66e1d3308b59c8c62098
    https://github.com/scummvm/scummvm/commit/16c3757dcddeeff00b8d66e1d3308b59c8c62098
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f426_isMessageOnTwoLines

Changed paths:
    engines/dm/dialog.cpp



diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index 6a99ee5..fc610c6 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -145,21 +145,17 @@ void DialogMan::f425_printCenteredChoice(byte* bitmap, char* str, int16 posX, in
 }
 
 bool DialogMan::f426_isMessageOnTwoLines(char* str, char* part1, char* part2) {
-	uint16 L1305_ui_StringLength;
-	uint16 L1306_ui_SplitPosition;
-
-
-	L1305_ui_StringLength = strlen(str);
-	if (L1305_ui_StringLength <= 30) {
+	uint16 strLength = strlen(str);
+	if (strLength <= 30)
 		return false;
-	}
+
 	strcpy(part1, str);
-	L1306_ui_SplitPosition = L1305_ui_StringLength >> 1;
-	while ((part1[L1306_ui_SplitPosition] != ' ') && L1306_ui_SplitPosition < L1305_ui_StringLength) {
-		L1306_ui_SplitPosition++;
-	}
-	part1[L1306_ui_SplitPosition] = '\0';
-	strcpy(part2, &part1[L1306_ui_SplitPosition + 1]);
+	uint16 splitPosition = strLength >> 1;
+	while ((part1[splitPosition] != ' ') && (splitPosition < strLength))
+		splitPosition++;
+
+	part1[splitPosition] = '\0';
+	strcpy(part2, &part1[splitPosition + 1]);
 	return true;
 }
 }


Commit: f0e037e305917bfd372254b4050315a66e1588c3
    https://github.com/scummvm/scummvm/commit/f0e037e305917bfd372254b4050315a66e1588c3
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some renaming, add a couple of STUBS

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/loadsave.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 3b23028..3f13bb5 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -179,7 +179,6 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 		_g562_entranceDoorAnimSteps[i] = nullptr;
 	_g564_interfaceCredits = nullptr;
 	debug("DMEngine::DMEngine");
-
 }
 
 DMEngine::~DMEngine() {
@@ -259,10 +258,9 @@ void DMEngine::f448_initMemoryManager() {
 }
 
 void DMEngine::f462_startGame() {
-	static Box g61_boxScreenTop(0, 319, 0, 32); // @ G0061_s_Graphic562_Box_ScreenTop
-	static Box g62_boxScreenRight(224, 319, 33, 169); // @ G0062_s_Graphic562_Box_ScreenRight
-	static Box g63_boxScreenBottom(0, 319, 169, 199); // @ G0063_s_Graphic562_Box_ScreenBottom
-
+	static Box boxScreenTop(0, 319, 0, 32); // @ G0061_s_Graphic562_Box_ScreenTop
+	static Box boxScreenRight(224, 319, 33, 169); // @ G0062_s_Graphic562_Box_ScreenRight
+	static Box boxScreenBottom(0, 319, 169, 199); // @ G0063_s_Graphic562_Box_ScreenBottom
 
 	_g331_pressingEye = false;
 	_g332_stopPressingEye = false;
@@ -285,14 +283,14 @@ void DMEngine::f462_startGame() {
 	if (!_g298_newGame) {
 		_displayMan->_g578_useByteBoxCoordinates = false;
 		f22_delay(1);
-		_displayMan->D24_fillScreenBox(g61_boxScreenTop, k0_ColorBlack);
-		_displayMan->D24_fillScreenBox(g62_boxScreenRight, k0_ColorBlack);
-		_displayMan->D24_fillScreenBox(g63_boxScreenBottom, k0_ColorBlack);
+		_displayMan->D24_fillScreenBox(boxScreenTop, k0_ColorBlack);
+		_displayMan->D24_fillScreenBox(boxScreenRight, k0_ColorBlack);
+		_displayMan->D24_fillScreenBox(boxScreenBottom, k0_ColorBlack);
 	} else {
 		_displayMan->_g578_useByteBoxCoordinates = false;
-		_displayMan->D24_fillScreenBox(g61_boxScreenTop, k0_ColorBlack);
-		_displayMan->D24_fillScreenBox(g62_boxScreenRight, k0_ColorBlack);
-		_displayMan->D24_fillScreenBox(g63_boxScreenBottom, k0_ColorBlack);
+		_displayMan->D24_fillScreenBox(boxScreenTop, k0_ColorBlack);
+		_displayMan->D24_fillScreenBox(boxScreenRight, k0_ColorBlack);
+		_displayMan->D24_fillScreenBox(boxScreenBottom, k0_ColorBlack);
 	}
 
 	warning(false, "TODO: build copper");
@@ -399,9 +397,8 @@ T0002002:
 
 		_menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived();
 
-		if (!(_g313_gameTime & (_championMan->_g300_partyIsSleeping ? 15 : 63))) {
+		if (!(_g313_gameTime & (_championMan->_g300_partyIsSleeping ? 15 : 63)))
 			_championMan->f331_applyTimeEffects();
-		}
 
 		if (_g310_disabledMovementTicks)
 			_g310_disabledMovementTicks--;
@@ -451,17 +448,14 @@ int16 DMEngine::M0_indexToOrdinal(int16 val) {
 
 
 void DMEngine::f441_processEntrance() {
-	uint16 L1402_ui_AnimationStep;
-	Box L1405_s_Box;
-
 	_eventMan->_g441_primaryMouseInput = g445_PrimaryMouseInput_Entrance;
 	_eventMan->_g442_secondaryMouseInput = nullptr;
 	_eventMan->_g443_primaryKeyboardInput = nullptr;
 	_eventMan->_g444_secondaryKeyboardInput = nullptr;
 	_g562_entranceDoorAnimSteps[0] = new byte[128 * 161 * 12];
-	for (L1402_ui_AnimationStep = 1; L1402_ui_AnimationStep < 8; L1402_ui_AnimationStep++) {
-		_g562_entranceDoorAnimSteps[L1402_ui_AnimationStep] = _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep - 1] + 128 * 161;
-	}
+	for (uint16 idx = 1; idx < 8; idx++)
+		_g562_entranceDoorAnimSteps[idx] = _g562_entranceDoorAnimSteps[idx - 1] + 128 * 161;
+
 	_g562_entranceDoorAnimSteps[8] = _g562_entranceDoorAnimSteps[7] + 128 * 161;
 	_g562_entranceDoorAnimSteps[9] = _g562_entranceDoorAnimSteps[8] + 128 * 161 * 2;
 
@@ -469,19 +463,21 @@ void DMEngine::f441_processEntrance() {
 	_displayMan->f466_loadIntoBitmap(k2_entranceLeftDoorGraphicIndice, _g562_entranceDoorAnimSteps[0]);
 	_g564_interfaceCredits = _displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice);
 	_displayMan->_g578_useByteBoxCoordinates = false;
-	L1405_s_Box._x1 = 0;
-	L1405_s_Box._x2 = 100;
-	L1405_s_Box._y1 = 0;
-	L1405_s_Box._y2 = 160;
-	for (L1402_ui_AnimationStep = 1; L1402_ui_AnimationStep < 4; L1402_ui_AnimationStep++) {
-		_displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[0], _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep], L1405_s_Box, L1402_ui_AnimationStep << 2, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161);
-		L1405_s_Box._x2 -= 4;
+	Box displayBox;
+	displayBox._x1 = 0;
+	displayBox._x2 = 100;
+	displayBox._y1 = 0;
+	displayBox._y2 = 160;
+	for (uint16 idx = 1; idx < 4; idx++) {
+		_displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[0], _g562_entranceDoorAnimSteps[idx], displayBox, idx << 2, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161);
+		displayBox._x2 -= 4;
 	}
-	L1405_s_Box._x2 = 127;
-	for (L1402_ui_AnimationStep = 5; L1402_ui_AnimationStep < 8; L1402_ui_AnimationStep++) {
-		L1405_s_Box._x1 += 4;
-		_displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[4], _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep], L1405_s_Box, 0, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161);
+	displayBox._x2 = 127;
+	for (uint16 idx = 5; idx < 8; idx++) {
+		displayBox._x1 += 4;
+		_displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[4], _g562_entranceDoorAnimSteps[idx], displayBox, 0, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161);
 	}
+
 	do {
 		f439_drawEntrance();
 		_eventMan->f78_showMouse();
@@ -496,12 +492,12 @@ void DMEngine::f441_processEntrance() {
 		} while (_g298_newGame == k99_modeWaitingOnEntrance);
 	} while (_g298_newGame == k202_CommandEntranceDrawCredits);
 	//Strangerke: CHECKME: Earlier versions were using G0566_puc_Graphic534_Sound01Switch
-	warning(false, "MISSING CODE: F0060_SOUND_Play");
+	f060_SOUND_Play(k01_soundSWITCH, 112, 0x40, 0x40);
 	f22_delay(20);
 	_eventMan->f78_showMouse();
-	if (_g298_newGame) {
-		warning(false, "MISSING CODE: F0438_STARTEND_OpenEntranceDoors();");
-	}
+	if (_g298_newGame)
+		f438_STARTEND_OpenEntranceDoors();
+
 	delete[] _g562_entranceDoorAnimSteps[0];
 	for (uint16 i = 0; i < 10; ++i)
 		_g562_entranceDoorAnimSteps[i] = nullptr;
@@ -560,9 +556,9 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 		f22_delay(1);
 		for (uint16 i = 0; i < 16; ++i)
 			_displayMan->_g347_paletteTopAndBottomScreen[i] = L1420_aui_Palette_TopAndBottomScreen[i];
-	} else {
-		warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(G0345_aui_BlankBuffer)");
-	}
+	} else
+		_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
+
 	if (doNotDrawCreditsOnly) {
 		if (_g302_gameWon) {
 			// Strangerke: Related to portraits. Game data could be missing for earlier versions of the game.
@@ -593,7 +589,7 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 				G0016_s_Graphic562_Box_Endgame_ChampionPortrait._y1 += 48;
 				G0016_s_Graphic562_Box_Endgame_ChampionPortrait._y1 += 48;
 			}
-			warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);");
+			_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);
 			_engineShouldQuit = true;
 			return;
 		}
@@ -605,7 +601,7 @@ T0444017:
 		for (uint16 i = 0; i < 16; ++i)
 			L1419_aui_Palette[i] = L1421_aui_Palette_DarkBlue[i];
 		L1419_aui_Palette[15] = D09_RGB_WHITE;
-		warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(L1419_aui_Palette);");
+		_displayMan->f436_STARTEND_FadeToPalette(L1419_aui_Palette);
 		if (L1423_B_WaitBeforeDrawingRestart) { /* BUG0_00 Useless code */
 			f22_delay(300);
 		} /* BUG0_00 Useless code */
@@ -620,15 +616,15 @@ T0444017:
 			_eventMan->_g441_primaryMouseInput = g446_PrimaryMouseInput_RestartGame;
 			_eventMan->f357_discardAllInput();
 			_eventMan->f77_hideMouse();
-			warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette");
+			_displayMan->f436_STARTEND_FadeToPalette(L1419_aui_Palette);
 			for (AL1409_i_VerticalBlankCount = 900; --AL1409_i_VerticalBlankCount && !_g523_restartGameRequest; f22_delay(1)) {
 				_eventMan->f380_processCommandQueue();
 			}
 			_eventMan->f78_showMouse();
 			if (_g523_restartGameRequest) {
-				warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette");
+				_displayMan->f436_STARTEND_FadeToPalette(L1421_aui_Palette_DarkBlue);
 				_displayMan->fillScreen(k0_ColorBlack);
-				warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette");
+				_displayMan->f436_STARTEND_FadeToPalette(g21_PalDungeonView[0]);
 				_g298_newGame = k0_modeLoadSavedGame;
 				if (f435_loadgame(1) != kM1_LoadgameFailure) {
 					f462_startGame();
@@ -640,20 +636,19 @@ T0444017:
 			}
 		}
 
-		warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette");
+		_displayMan->f436_STARTEND_FadeToPalette(L1421_aui_Palette_DarkBlue);
 	}
-	{
-		Box box(0, 319, 0, 199);
-		_displayMan->f132_blitToBitmap(_displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice), _displayMan->_g348_bitmapScreen, box, 0, 0, 160, 160, kM1_ColorNoTransparency);
-	}
-	warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette");
+	Box box(0, 319, 0, 199);
+	_displayMan->f132_blitToBitmap(_displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice), _displayMan->_g348_bitmapScreen, box, 0, 0, 160, 160, kM1_ColorNoTransparency);
+
+	_displayMan->f436_STARTEND_FadeToPalette(g19_PalCredits);
 	_eventMan->f541_waitForMouseOrKeyActivity();
 	if (_engineShouldQuit)
 		return;
 
 	if (_g524_restartGameAllowed && doNotDrawCreditsOnly) {
 		L1423_B_WaitBeforeDrawingRestart = false;
-		warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette");
+		_displayMan->f436_STARTEND_FadeToPalette(L1421_aui_Palette_DarkBlue);
 		goto T0444017;
 	}
 
@@ -687,7 +682,7 @@ void DMEngine::f439_drawEntrance() {
 		L1399_auc_MicroDungeonSquares[L1397_ui_ColumnIndex + 10] = Square(k1_CorridorElemType, 0);
 	}
 	L1399_auc_MicroDungeonSquares[7] = Square(k1_CorridorElemType, 0);
-	warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(G0345_aui_BlankBuffer);");
+	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
 
 	// note, a global variable is used here in the original
 	_displayMan->f466_loadIntoBitmap(k4_entranceGraphicIndice, _displayMan->_g348_bitmapScreen);
@@ -699,6 +694,6 @@ void DMEngine::f439_drawEntrance() {
 
 	_displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[0], &G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft, k64_byteWidth, kM1_ColorNoTransparency, 161);
 	_displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[4], &G0011_s_Graphic562_Box_Entrance_ClosedDoorRight, k64_byteWidth, kM1_ColorNoTransparency, 161);
-	warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(g20_PalEntrance);");
+	_displayMan->f436_STARTEND_FadeToPalette(g20_PalEntrance);
 }
 } // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index a6d2fe6..33c3b03 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -235,6 +235,8 @@ public:
 	void f444_endGame(bool doNotDrawCreditsOnly); // @ F0444_STARTEND_Endgame
 
 	void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode) { warning(true, "STUB: f064_SOUND_RequestPlay_CPSD"); }
+	void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol) { warning(true, "STUB: f060_SOUND_Play"); }
+	void f438_STARTEND_OpenEntranceDoors() { warning(true, "STUB: f438_STARTEND_OpenEntranceDoors"); }
 
 private:
 	int16 _g528_saveFormat; // @ G0528_i_Format
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 85b3691..24e1a15 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -140,20 +140,22 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 	if (_g298_newGame) {
 		_timeline->f233_initTimeline();
 		_groupMan->f196_initActiveGroups();
-		warning(false, "MISSING CODE: missing fadePlette stuff in f435_loadgame on newGame");
-		/*
+
+#if 0
+		// always false?
 		if (L1366_B_FadePalette) {
-			F0436_STARTEND_FadeToPalette(G0345_aui_BlankBuffer);
+			_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
 			D26_WaitForVerticalBlank();
 			D18_FillScreenBlack();
-			F0436_STARTEND_FadeToPalette(_vm->_displayMan->_g347_paletteTopAndBottomScreen);
-		}*/
+			_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);
+		}
+#endif
 	} else {
 		_g528_saveFormat = dmSaveHeader._saveFormat;
 		_g527_platform = dmSaveHeader._platform;
 		_g526_dungeonId = dmSaveHeader._dungeonId;
 
-			_g524_restartGameAllowed = true;
+		_g524_restartGameAllowed = true;
 		warning(false, "MISSING CDOE: F0427_DIALOG_Draw in f435_loadgame");
 	}
 	_championMan->_g303_partyDead = false;


Commit: ef34e8bb39238530048645c3654c91a21f1248cc
    https://github.com/scummvm/scummvm/commit/ef34e8bb39238530048645c3654c91a21f1248cc
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Apply coding conventions to a couple of oneliner functions, remove a GOTO

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 3f13bb5..1ac9a32 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -76,9 +76,17 @@ void warning(bool repeat, const char* s, ...) {
 	}
 }
 
-void turnDirRight(Direction &dir) { dir = (Direction)((dir + 1) & 3); }
-void turnDirLeft(Direction &dir) { dir = (Direction)((dir - 1) & 3); }
-Direction returnOppositeDir(Direction dir) { return (Direction)((dir + 2) & 3); }
+void turnDirRight(Direction &dir) {
+	dir = (Direction)((dir + 1) & 3);
+}
+
+void turnDirLeft(Direction &dir) {
+	dir = (Direction)((dir - 1) & 3);
+}
+
+Direction returnOppositeDir(Direction dir) {
+	return (Direction)((dir + 2) & 3);
+}
 
 uint16 returnPrevVal(uint16 val) {
 	return (Direction)((val + 3) & 3);
@@ -88,7 +96,9 @@ uint16 returnNextVal(uint16 val) {
 	return (val + 1) & 0x3;
 }
 
-bool isOrientedWestEast(Direction dir) { return dir & 1; }
+bool isOrientedWestEast(Direction dir) {
+	return dir & 1;
+}
 
 uint16 toggleFlag(uint16& val, uint16 mask) {
 	return val ^= mask;
@@ -134,7 +144,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	DebugMan.addDebugChannel(kDMDebugExample, "example", "example desc");
 
 	// register random source
-	_rnd = new Common::RandomSource("quux");
+	_rnd = new Common::RandomSource("dm");
 
 	_dungeonMan = nullptr;
 	_displayMan = nullptr;
@@ -351,17 +361,19 @@ void DMEngine::f2_gameloop() {
 	while (true) {
 		if (_engineShouldQuit)
 			return;
-		if (_g327_newPartyMapIndex != kM1_mapIndexNone) {
-T0002002:
-			f3_processNewPartyMap(_g327_newPartyMapIndex);
-			_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
-			_g327_newPartyMapIndex = kM1_mapIndexNone;
-			_eventMan->f357_discardAllInput();
-		}
-		_timeline->f261_processTimeline();
 
-		if (_g327_newPartyMapIndex != kM1_mapIndexNone)
-			goto T0002002;
+		for (;;) {
+			if (_g327_newPartyMapIndex != kM1_mapIndexNone) {
+				f3_processNewPartyMap(_g327_newPartyMapIndex);
+				_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
+				_g327_newPartyMapIndex = kM1_mapIndexNone;
+				_eventMan->f357_discardAllInput();
+			}
+			_timeline->f261_processTimeline();
+
+			if (_g327_newPartyMapIndex == kM1_mapIndexNone)
+				break;
+		}
 
 		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
 			Box box(0, 223, 0, 135);


Commit: a2b495e0e57a42527bbb58414359c056473036af
    https://github.com/scummvm/scummvm/commit/a2b495e0e57a42527bbb58414359c056473036af
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f444_endGame

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 1ac9a32..58097e7 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -350,6 +350,7 @@ Common::Error DMEngine::run() {
 }
 
 void DMEngine::f2_gameloop() {
+	//HACK: Remove this block to get real starting position in the Hall of Champions
 	if (_g298_newGame) {
 		warning(false, "DUMMY CODE: SETTING PARTY POS AND DIRECTION");
 		_dungeonMan->_g306_partyMapX = 9;
@@ -399,6 +400,7 @@ void DMEngine::f2_gameloop() {
 		_championMan->f320_applyAndDrawPendingDamageAndWounds();
 		if (_championMan->_g303_partyDead)
 			break;
+
 		_g313_gameTime++;
 
 		if (!(_g313_gameTime & 511))
@@ -458,7 +460,6 @@ int16 DMEngine::M0_indexToOrdinal(int16 val) {
 	return val + 1;
 }
 
-
 void DMEngine::f441_processEntrance() {
 	_eventMan->_g441_primaryMouseInput = g445_PrimaryMouseInput_Entrance;
 	_eventMan->_g442_secondaryMouseInput = nullptr;
@@ -503,6 +504,7 @@ void DMEngine::f441_processEntrance() {
 			_displayMan->updateScreen();
 		} while (_g298_newGame == k99_modeWaitingOnEntrance);
 	} while (_g298_newGame == k202_CommandEntranceDrawCredits);
+
 	//Strangerke: CHECKME: Earlier versions were using G0566_puc_Graphic534_Sound01Switch
 	f060_SOUND_Play(k01_soundSWITCH, 112, 0x40, 0x40);
 	f22_delay(20);
@@ -517,31 +519,13 @@ void DMEngine::f441_processEntrance() {
 
 void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 	// TODO: localization
-	static Box G0013_s_Graphic562_Box_Endgame_Restart_Outer = Box(103, 217, 145, 159);
-	static Box G0014_s_Graphic562_Box_Endgame_Restart_Inner = Box(105, 215, 147, 157);
-	static Box G0012_s_Graphic562_Box_Endgame_TheEnd = Box(120, 199, 95, 108);
-	static Box G0015_s_Graphic562_Box_Endgame_ChampionMirror = Box(11, 74, 7, 49);
-	static Box G0016_s_Graphic562_Box_Endgame_ChampionPortrait = Box(27, 58, 13, 41);
-	int16 L1409_i_Multiple;
-#define AL1409_i_Color              L1409_i_Multiple
-#define AL1409_i_ChampionIndex      L1409_i_Multiple
-#define AL1409_i_VerticalBlankCount L1409_i_Multiple
-	int16 L1410_i_Multiple;
-#define AL1410_i_Counter L1410_i_Multiple
-#define AL1410_i_Y       L1410_i_Multiple
-	int16 L1411_i_Multiple;
-#define AL1411_i_X          L1411_i_Multiple
-#define AL1411_i_SkillIndex L1411_i_Multiple
-	int16 L1412_i_SkillLevel;
-	char L1415_c_ChampionTitleFirstCharacter;
-	Champion* L1416_ps_Champion;
-	uint16 L1419_aui_Palette[16];
-	uint16 L1420_aui_Palette_TopAndBottomScreen[16];
-	uint16 L1421_aui_Palette_DarkBlue[16];
-	char L1422_ac_String[20];
-	// Strangerke: Not so sure it's useless. 
-	bool L1423_B_WaitBeforeDrawingRestart; /* BUG0_00 Useless code */
-	L1423_B_WaitBeforeDrawingRestart = true; /* BUG0_00 Useless code */
+	static Box restartOuterBox = Box(103, 217, 145, 159);
+	static Box restartInnerBox = Box(105, 215, 147, 157);
+	static Box theEndBox = Box(120, 199, 95, 108);
+	static Box championMirrorBox = Box(11, 74, 7, 49);
+	static Box championPortraitBox = Box(27, 58, 13, 41);
+
+	bool waitBeforeDrawingRestart = true;
 
 	_eventMan->f67_setMousePointerToNormal(k0_pointerArrow);
 	_eventMan->f78_showMouse();
@@ -555,51 +539,55 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 	}
 	
 	if (_displayMan->_g322_paletteSwitchingEnabled) {
+		uint16 oldPalTopAndBottomScreen[16];
 		for (uint16 i = 0; i < 16; ++i)
-			L1420_aui_Palette_TopAndBottomScreen[i] = _displayMan->_g347_paletteTopAndBottomScreen[i];
-		for (AL1410_i_Counter = 0; AL1410_i_Counter <= 7; AL1410_i_Counter++) {
+			oldPalTopAndBottomScreen[i] = _displayMan->_g347_paletteTopAndBottomScreen[i];
+		for (int i = 0; i <= 7; i++) {
 			f22_delay(1);
-			for (AL1409_i_Color = 0; AL1409_i_Color < 16; AL1409_i_Color++) {
-				_displayMan->_g346_paletteMiddleScreen[AL1409_i_Color] = _displayMan->f431_getDarkenedColor(_displayMan->_g346_paletteMiddleScreen[AL1409_i_Color]);
-				_displayMan->_g347_paletteTopAndBottomScreen[AL1409_i_Color] = _displayMan->f431_getDarkenedColor(_displayMan->_g347_paletteTopAndBottomScreen[AL1409_i_Color]);
+			for (int colIdx = 0; colIdx < 16; colIdx++) {
+				_displayMan->_g346_paletteMiddleScreen[colIdx] = _displayMan->f431_getDarkenedColor(_displayMan->_g346_paletteMiddleScreen[colIdx]);
+				_displayMan->_g347_paletteTopAndBottomScreen[colIdx] = _displayMan->f431_getDarkenedColor(_displayMan->_g347_paletteTopAndBottomScreen[colIdx]);
 			}
 		}
 		_displayMan->_g322_paletteSwitchingEnabled = false;
 		f22_delay(1);
 		for (uint16 i = 0; i < 16; ++i)
-			_displayMan->_g347_paletteTopAndBottomScreen[i] = L1420_aui_Palette_TopAndBottomScreen[i];
+			_displayMan->_g347_paletteTopAndBottomScreen[i] = oldPalTopAndBottomScreen[i];
 	} else
 		_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
 
+	uint16 darkBluePalette[16];
 	if (doNotDrawCreditsOnly) {
 		if (_g302_gameWon) {
 			// Strangerke: Related to portraits. Game data could be missing for earlier versions of the game.
 			_displayMan->fillScreen(k12_ColorDarkestGray);
-			for (AL1409_i_ChampionIndex = k0_ChampionFirst; AL1409_i_ChampionIndex < _championMan->_g305_partyChampionCount; AL1409_i_ChampionIndex++) {
-				AL1410_i_Y = AL1409_i_ChampionIndex * 48;
-				L1416_ps_Champion = &_championMan->_gK71_champions[AL1409_i_ChampionIndex];
-				_displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k208_wallOrn_43_champMirror), &G0015_s_Graphic562_Box_Endgame_ChampionMirror, k32_byteWidth, k10_ColorFlesh, 43);
-				_displayMan->f21_blitToScreen(L1416_ps_Champion->_portrait, &G0016_s_Graphic562_Box_Endgame_ChampionPortrait, k16_byteWidth, k1_ColorDarkGary, 29);
-				_textMan->f443_endgamePrintString(87, AL1410_i_Y += 14, k9_ColorGold, L1416_ps_Champion->_name);
-				AL1411_i_X = (6 * strlen(L1416_ps_Champion->_name)) + 87;
-				L1415_c_ChampionTitleFirstCharacter = L1416_ps_Champion->_title[0];
-				if ((L1415_c_ChampionTitleFirstCharacter != ',') && (L1415_c_ChampionTitleFirstCharacter != ';') && (L1415_c_ChampionTitleFirstCharacter != '-')) {
-					AL1411_i_X += 6;
-				}
-				_textMan->f443_endgamePrintString(AL1411_i_X, AL1410_i_Y++, k9_ColorGold, L1416_ps_Champion->_title);
-				for (AL1411_i_SkillIndex = k0_ChampionSkillFighter; AL1411_i_SkillIndex <= k3_ChampionSkillWizard; AL1411_i_SkillIndex++) {
-					L1412_i_SkillLevel = MIN((uint16)16, _championMan->f303_getSkillLevel(AL1409_i_ChampionIndex, AL1411_i_SkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience)));
-					if (L1412_i_SkillLevel == 1)
+			for (int16 championIndex = k0_ChampionFirst; championIndex < _championMan->_g305_partyChampionCount; championIndex++) {
+				int16 textPosY = championIndex * 48;
+				Champion *curChampion = &_championMan->_gK71_champions[championIndex];
+				_displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k208_wallOrn_43_champMirror), &championMirrorBox, k32_byteWidth, k10_ColorFlesh, 43);
+				_displayMan->f21_blitToScreen(curChampion->_portrait, &championPortraitBox, k16_byteWidth, k1_ColorDarkGary, 29);
+				_textMan->f443_endgamePrintString(87, textPosY += 14, k9_ColorGold, curChampion->_name);
+				int textPosX = (6 * strlen(curChampion->_name)) + 87;
+				char championTitleFirstCharacter = curChampion->_title[0];
+				if ((championTitleFirstCharacter != ',') && (championTitleFirstCharacter != ';') && (championTitleFirstCharacter != '-'))
+					textPosX += 6;
+
+				_textMan->f443_endgamePrintString(textPosX, textPosY++, k9_ColorGold, curChampion->_title);
+				for (int16 idx = k0_ChampionSkillFighter; idx <= k3_ChampionSkillWizard; idx++) {
+					uint16 skillLevel = MIN<uint16>(16, _championMan->f303_getSkillLevel(championIndex, idx | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience)));
+					if (skillLevel == 1)
 						continue;
-					strcpy(L1422_ac_String, G0428_apc_SkillLevelNames[L1412_i_SkillLevel - 2]);
-					strcat(L1422_ac_String, " ");
-					strcat(L1422_ac_String, g417_baseSkillName[AL1411_i_SkillIndex]);
-					_textMan->f443_endgamePrintString(105, AL1410_i_Y = AL1410_i_Y + 8, k13_ColorLightestGray, L1422_ac_String);
+
+					char displStr[20];
+					strcpy(displStr, G0428_apc_SkillLevelNames[skillLevel - 2]);
+					strcat(displStr, " ");
+					strcat(displStr, g417_baseSkillName[idx]);
+					_textMan->f443_endgamePrintString(105, textPosY = textPosY + 8, k13_ColorLightestGray, displStr);
 				}
-				G0015_s_Graphic562_Box_Endgame_ChampionMirror._y1 += 48;
-				G0015_s_Graphic562_Box_Endgame_ChampionMirror._y2 += 48;
-				G0016_s_Graphic562_Box_Endgame_ChampionPortrait._y1 += 48;
-				G0016_s_Graphic562_Box_Endgame_ChampionPortrait._y1 += 48;
+				championMirrorBox._y1 += 48;
+				championMirrorBox._y2 += 48;
+				championPortraitBox._y1 += 48;
+				championPortraitBox._y1 += 48;
 			}
 			_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);
 			_engineShouldQuit = true;
@@ -607,34 +595,34 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 		}
 T0444017:
 		_displayMan->fillScreen(k0_ColorBlack);
-		_displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k6_theEndIndice), &G0012_s_Graphic562_Box_Endgame_TheEnd, k40_byteWidth, kM1_ColorNoTransparency, 14);
-		for (uint16 i = 0; i < 16; ++i)
-			L1421_aui_Palette_DarkBlue[i] = D01_RGB_DARK_BLUE;
+		_displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k6_theEndIndice), &theEndBox, k40_byteWidth, kM1_ColorNoTransparency, 14);
 		for (uint16 i = 0; i < 16; ++i)
-			L1419_aui_Palette[i] = L1421_aui_Palette_DarkBlue[i];
-		L1419_aui_Palette[15] = D09_RGB_WHITE;
-		_displayMan->f436_STARTEND_FadeToPalette(L1419_aui_Palette);
-		if (L1423_B_WaitBeforeDrawingRestart) { /* BUG0_00 Useless code */
+			darkBluePalette[i] = D01_RGB_DARK_BLUE;
+		uint16 curPalette[16];
+		for (uint16 i = 0; i < 15; ++i)
+			curPalette[i] = darkBluePalette[i];
+		curPalette[15] = D09_RGB_WHITE;
+		_displayMan->f436_STARTEND_FadeToPalette(curPalette);
+		if (waitBeforeDrawingRestart)
 			f22_delay(300);
-		} /* BUG0_00 Useless code */
 
 		if (_g524_restartGameAllowed) {
 			_displayMan->_g578_useByteBoxCoordinates = false;
-			_displayMan->D24_fillScreenBox(G0013_s_Graphic562_Box_Endgame_Restart_Outer, k12_ColorDarkestGray);
-			_displayMan->D24_fillScreenBox(G0014_s_Graphic562_Box_Endgame_Restart_Inner, k0_ColorBlack);
+			_displayMan->D24_fillScreenBox(restartOuterBox, k12_ColorDarkestGray);
+			_displayMan->D24_fillScreenBox(restartInnerBox, k0_ColorBlack);
 			_textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RESTART THIS GAME");
-			L1419_aui_Palette[1] = D03_RGB_PINK;
-			L1419_aui_Palette[4] = D09_RGB_WHITE;
+			curPalette[1] = D03_RGB_PINK;
+			curPalette[4] = D09_RGB_WHITE;
 			_eventMan->_g441_primaryMouseInput = g446_PrimaryMouseInput_RestartGame;
 			_eventMan->f357_discardAllInput();
 			_eventMan->f77_hideMouse();
-			_displayMan->f436_STARTEND_FadeToPalette(L1419_aui_Palette);
-			for (AL1409_i_VerticalBlankCount = 900; --AL1409_i_VerticalBlankCount && !_g523_restartGameRequest; f22_delay(1)) {
+			_displayMan->f436_STARTEND_FadeToPalette(curPalette);
+			for (int16 verticalBlankCount = 900; --verticalBlankCount && !_g523_restartGameRequest; f22_delay(1))
 				_eventMan->f380_processCommandQueue();
-			}
+
 			_eventMan->f78_showMouse();
 			if (_g523_restartGameRequest) {
-				_displayMan->f436_STARTEND_FadeToPalette(L1421_aui_Palette_DarkBlue);
+				_displayMan->f436_STARTEND_FadeToPalette(darkBluePalette);
 				_displayMan->fillScreen(k0_ColorBlack);
 				_displayMan->f436_STARTEND_FadeToPalette(g21_PalDungeonView[0]);
 				_g298_newGame = k0_modeLoadSavedGame;
@@ -648,7 +636,7 @@ T0444017:
 			}
 		}
 
-		_displayMan->f436_STARTEND_FadeToPalette(L1421_aui_Palette_DarkBlue);
+		_displayMan->f436_STARTEND_FadeToPalette(darkBluePalette);
 	}
 	Box box(0, 319, 0, 199);
 	_displayMan->f132_blitToBitmap(_displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice), _displayMan->_g348_bitmapScreen, box, 0, 0, 160, 160, kM1_ColorNoTransparency);
@@ -659,8 +647,8 @@ T0444017:
 		return;
 
 	if (_g524_restartGameAllowed && doNotDrawCreditsOnly) {
-		L1423_B_WaitBeforeDrawingRestart = false;
-		_displayMan->f436_STARTEND_FadeToPalette(L1421_aui_Palette_DarkBlue);
+		waitBeforeDrawingRestart = false;
+		_displayMan->f436_STARTEND_FadeToPalette(darkBluePalette);
 		goto T0444017;
 	}
 


Commit: db164ae9d67e8be14b349a76fcac279604e646f9
    https://github.com/scummvm/scummvm/commit/db164ae9d67e8be14b349a76fcac279604e646f9
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f439_drawEntrance

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 58097e7..e825ead2 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -658,30 +658,30 @@ T0444017:
 
 
 void DMEngine::f439_drawEntrance() {
-	static Box K0079_s_Box_Entrance_DoorsUpperHalf = Box(0, 231, 0, 80);
-	static Box K0152_s_Box_Entrance_DoorsLowerHalf = Box(0, 231, 81, 160);
-	static Box G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft = Box(0, 104, 30, 190);
-	static Box G0011_s_Graphic562_Box_Entrance_ClosedDoorRight = Box(105, 231, 30, 190);
+	static Box doorsUpperHalfBox = Box(0, 231, 0, 80);
+	static Box doorsLowerHalfBox = Box(0, 231, 81, 160);
+	static Box closedDoorLeftBox = Box(0, 104, 30, 190);
+	static Box closedDoorRightBox = Box(105, 231, 30, 190);
 
-	uint16 L1397_ui_ColumnIndex;
-	byte* L1398_apuc_MicroDungeonCurrentMapData[32];
-	Square L1399_auc_MicroDungeonSquares[25];
+	byte *microDungeonCurrentMapData[32];
 
 	_dungeonMan->_g309_partyMapIndex = k255_mapIndexEntrance;
 	_displayMan->_g297_drawFloorAndCeilingRequested = true;
 	_dungeonMan->_g273_currMapWidth = 5;
 	_dungeonMan->_g274_currMapHeight = 5;
-	_dungeonMan->_g271_currMapData = L1398_apuc_MicroDungeonCurrentMapData;
+	_dungeonMan->_g271_currMapData = microDungeonCurrentMapData;
 
 	Map map; // uninitialized, won't be used
 	_dungeonMan->_g269_currMap = ↦
+	Square microDungeonSquares[25];
 	for (uint16 i = 0; i < 25; ++i)
-		L1399_auc_MicroDungeonSquares[i] = Square(k0_ElementTypeWall, 0);
-	for (L1397_ui_ColumnIndex = 0; L1397_ui_ColumnIndex < 5; L1397_ui_ColumnIndex++) {
-		L1398_apuc_MicroDungeonCurrentMapData[L1397_ui_ColumnIndex] = (byte*)&L1399_auc_MicroDungeonSquares[L1397_ui_ColumnIndex * 5];
-		L1399_auc_MicroDungeonSquares[L1397_ui_ColumnIndex + 10] = Square(k1_CorridorElemType, 0);
+		microDungeonSquares[i] = Square(k0_ElementTypeWall, 0);
+
+	for (int16 idx = 0; idx < 5; idx++) {
+		microDungeonCurrentMapData[idx] = (byte*)&microDungeonSquares[idx * 5];
+		microDungeonSquares[idx + 10] = Square(k1_CorridorElemType, 0);
 	}
-	L1399_auc_MicroDungeonSquares[7] = Square(k1_CorridorElemType, 0);
+	microDungeonSquares[7] = Square(k1_CorridorElemType, 0);
 	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
 
 	// note, a global variable is used here in the original
@@ -689,11 +689,11 @@ void DMEngine::f439_drawEntrance() {
 	_displayMan->f128_drawDungeon(kDirSouth, 2, 0);
 	warning(false, "IGNORED CODE: G0324_B_DrawViewportRequested = false;");
 
-	_displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], K0079_s_Box_Entrance_DoorsUpperHalf, 0, 30, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
-	_displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], K0152_s_Box_Entrance_DoorsLowerHalf, 0, 111, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
+	_displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], doorsUpperHalfBox, 0, 30, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
+	_displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], doorsLowerHalfBox, 0, 111, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
 
-	_displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[0], &G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft, k64_byteWidth, kM1_ColorNoTransparency, 161);
-	_displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[4], &G0011_s_Graphic562_Box_Entrance_ClosedDoorRight, k64_byteWidth, kM1_ColorNoTransparency, 161);
+	_displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[0], &closedDoorLeftBox, k64_byteWidth, kM1_ColorNoTransparency, 161);
+	_displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[4], &closedDoorRightBox, k64_byteWidth, kM1_ColorNoTransparency, 161);
 	_displayMan->f436_STARTEND_FadeToPalette(g20_PalEntrance);
 }
 } // End of namespace DM


Commit: 19317e631c464e00522b4f24c9d98f77ee771985
    https://github.com/scummvm/scummvm/commit/19317e631c464e00522b4f24c9d98f77ee771985
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some renaming in f173_setCurrentMap

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index da7d2da..684e81d 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -377,13 +377,13 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_g282_dungeonColumCount = 0;
 	_g281_dungeonMapsFirstColumnIndex = nullptr;
 
-
 	_g282_dungeonColumCount = 0;
 	_g280_dungeonColumnsCumulativeSquareThingCount = nullptr;
 	_g283_squareFirstThings = nullptr;
 	_g260_dungeonTextData = nullptr;
 	for (uint16 i = 0; i < 16; ++i)
 		_g284_thingData[i] = nullptr;
+
 	_g279_dungeonMapData = nullptr;
 	_g308_partyDir = (Direction)0;
 	_g306_partyMapX = 0;
@@ -540,7 +540,6 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 	if (_vm->_g298_newGame)
 		f455_decompressDungeonFile();
 
-
 	Common::ReadStream *dunDataStream = nullptr;
 	if (file) { // if loading a save 
 		dunDataStream = file;
@@ -627,37 +626,38 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 	for (uint16 i = 0; i < columCount; ++i)
 		_g280_dungeonColumnsCumulativeSquareThingCount[i] = dunDataStream->readUint16BE();
 
-
-	// load sqaure first things
+	// load square first things
 	if (!_vm->_g523_restartGameRequest) {
 		delete[] _g283_squareFirstThings;
 		_g283_squareFirstThings = new Thing[_g278_dungeonFileHeader._squareFirstThingCount];
 	}
+
 	for (uint16 i = 0; i < actualSquareFirstThingCount; ++i)
 		_g283_squareFirstThings[i].set(dunDataStream->readUint16BE());
-	if (_vm->_g298_newGame)
+
+	if (_vm->_g298_newGame) {
 		for (uint16 i = 0; i < 300; ++i)
 			_g283_squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none;
-
+	}
 
 	// load text data
 	if (!_vm->_g523_restartGameRequest) {
 		delete[] _g260_dungeonTextData;
 		_g260_dungeonTextData = new uint16[_g278_dungeonFileHeader._textDataWordCount];
 	}
+
 	for (uint16 i = 0; i < _g278_dungeonFileHeader._textDataWordCount; ++i)
 		_g260_dungeonTextData[i] = dunDataStream->readUint16BE();
 
-
 	if (_vm->_g298_newGame)
 		_vm->_timeline->_g369_eventMaxCount = 100;
 
 	// load things
 	for (uint16 thingType = k0_DoorThingType; thingType < k16_ThingTypeTotal; ++thingType) {
 		uint16 thingCount = _g278_dungeonFileHeader._thingCounts[thingType];
-		if (_vm->_g298_newGame) {
+		if (_vm->_g298_newGame)
 			_g278_dungeonFileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + g236_AdditionalThingCounts[thingType]);
-		}
+
 		uint16 thingStoreWordCount = g235_ThingDataWordCount[thingType];
 
 		if (thingStoreWordCount == 0)
@@ -689,9 +689,9 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 		if (_vm->_g298_newGame) {
 			if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType)
 				_vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType];
-			for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) {
+
+			for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i)
 				(_g284_thingData[thingType] + (thingCount + i) * thingStoreWordCount)[0] = Thing::_none.toUint16();
-			}
 		}
 	}
 
@@ -704,7 +704,6 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 	for (uint32 i = 0; i < _g278_dungeonFileHeader._rawMapDataSize; ++i)
 		_g276_dungeonRawMapData[i] = dunDataStream->readByte();
 
-
 	if (!_vm->_g523_restartGameRequest) {
 		uint8 mapCount = _g278_dungeonFileHeader._mapCount;
 		delete[] _g279_dungeonMapData;
@@ -727,7 +726,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 }
 
 void DungeonMan::f173_setCurrentMap(uint16 mapIndex) {
-	static DoorInfo g254_doorInfo[4] = { // @ G0254_as_Graphic559_DoorInfo
+	static const DoorInfo doorInfo[4] = { // @ G0254_as_Graphic559_DoorInfo
 		/* { Attributes, Defense } */
 		DoorInfo(3, 110),   /* Door type 0 Portcullis */
 		DoorInfo(0,  42),   /* Door type 1 Wooden door */
@@ -736,15 +735,15 @@ void DungeonMan::f173_setCurrentMap(uint16 mapIndex) {
 
 	if (_g272_currMapIndex == mapIndex)
 		return;
+
 	_g272_currMapIndex = mapIndex;
 	_g271_currMapData = _g279_dungeonMapData[mapIndex];
 	_g269_currMap = _g277_dungeonMaps + mapIndex;
 	_g273_currMapWidth = _g277_dungeonMaps[mapIndex]._width + 1;
 	_g274_currMapHeight = _g277_dungeonMaps[mapIndex]._height + 1;
-	_g275_currMapDoorInfo[0] = g254_doorInfo[_g269_currMap->_doorSet0];
-	_g275_currMapDoorInfo[1] = g254_doorInfo[_g269_currMap->_doorSet1];
-	_g270_currMapColCumulativeSquareFirstThingCount
-		= &_g280_dungeonColumnsCumulativeSquareThingCount[_g281_dungeonMapsFirstColumnIndex[mapIndex]];
+	_g275_currMapDoorInfo[0] = doorInfo[_g269_currMap->_doorSet0];
+	_g275_currMapDoorInfo[1] = doorInfo[_g269_currMap->_doorSet1];
+	_g270_currMapColCumulativeSquareFirstThingCount = &_g280_dungeonColumnsCumulativeSquareThingCount[_g281_dungeonMapsFirstColumnIndex[mapIndex]];
 }
 
 void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) {


Commit: 03db641f251891760a8c54426110d902d45186a3
    https://github.com/scummvm/scummvm/commit/03db641f251891760a8c54426110d902d45186a3
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f151_getSquare

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 684e81d..c91412a 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -767,34 +767,28 @@ void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) {
 
 
 Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) {
-	int16 L0248_i_Multiple;
-#define AL0248_B_IsMapXInBounds L0248_i_Multiple
-#define AL0248_i_SquareType     L0248_i_Multiple
-	int16 L0249_i_Multiple;
-#define AL0249_B_IsMapYInBounds L0249_i_Multiple
-#define AL0249_i_SquareType     L0249_i_Multiple
-
-	AL0249_B_IsMapYInBounds = (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight);
-	if ((AL0248_B_IsMapXInBounds = (mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth)) && AL0249_B_IsMapYInBounds) {
+	bool isMapYInBounds = (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight);
+	bool isMapXInBounds = (mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth);
+
+	if (isMapXInBounds && isMapYInBounds)
 		return Square(_vm->_dungeonMan->_g271_currMapData[mapX][mapY]);
-	}
 
-	if (AL0249_B_IsMapYInBounds) {
-		if (((mapX == -1) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[0][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) {
+	if (isMapYInBounds) {
+		SquareType squareType = Square(_vm->_dungeonMan->_g271_currMapData[0][mapY]).getType();
+		if (((mapX == -1) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit))
 			return Square(k0_ElementTypeWall, k0x0004_WallEastRandOrnAllowed);
-		}
-		if (((mapX == _vm->_dungeonMan->_g273_currMapWidth) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[_vm->_dungeonMan->_g273_currMapWidth - 1][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) {
+
+		squareType = Square(_vm->_dungeonMan->_g271_currMapData[_vm->_dungeonMan->_g273_currMapWidth - 1][mapY]).getType();
+		if (((mapX == _vm->_dungeonMan->_g273_currMapWidth) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit))
 			return Square(k0_ElementTypeWall, k0x0001_WallWestRandOrnAllowed);
-		}
-	} else {
-		if (AL0248_B_IsMapXInBounds) {
-			if (((mapY == -1) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][0]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) {
-				return Square(k0_ElementTypeWall, k0x0002_WallSouthRandOrnAllowed);
-			}
-			if (((mapY == _vm->_dungeonMan->_g274_currMapHeight) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][_vm->_dungeonMan->_g274_currMapHeight - 1]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) {
-				return Square(k0_ElementTypeWall, k0x0008_WallNorthRandOrnAllowed);
-			}
-		}
+	} else if (isMapXInBounds) {
+		SquareType squareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][0]).getType();
+		if (((mapY == -1) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit))
+			return Square(k0_ElementTypeWall, k0x0002_WallSouthRandOrnAllowed);
+
+		squareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][_vm->_dungeonMan->_g274_currMapHeight - 1]).getType();
+		if (((mapY == _vm->_dungeonMan->_g274_currMapHeight) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit))
+			return Square(k0_ElementTypeWall, k0x0008_WallNorthRandOrnAllowed);
 	}
 	return Square(k0_ElementTypeWall, 0);
 }


Commit: a387f45d57241dbc8f96e214bb0b90a6069a75bb
    https://github.com/scummvm/scummvm/commit/a387f45d57241dbc8f96e214bb0b90a6069a75bb
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add f60_playSound

Changed paths:
    engines/dm/dm.h
    engines/dm/sounds.cpp



diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 33c3b03..02def01 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -205,6 +205,8 @@ public:
 	SoundData(): _byteCount(0), _firstSample(nullptr), _sampleCount(0) {}
 }; // @ SOUND_DATA
 
+
+
 class DMEngine : public Engine {
 	void f462_startGame(); // @ F0462_START_StartGame_CPSF
 	void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
@@ -235,7 +237,7 @@ public:
 	void f444_endGame(bool doNotDrawCreditsOnly); // @ F0444_STARTEND_Endgame
 
 	void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode) { warning(true, "STUB: f064_SOUND_RequestPlay_CPSD"); }
-	void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol) { warning(true, "STUB: f060_SOUND_Play"); }
+	void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol);
 	void f438_STARTEND_OpenEntranceDoors() { warning(true, "STUB: f438_STARTEND_OpenEntranceDoors"); }
 
 private:
diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp
index 681ff6d..cdbed46 100644
--- a/engines/dm/sounds.cpp
+++ b/engines/dm/sounds.cpp
@@ -30,6 +30,7 @@
 
 #include "dm.h"
 #include "gfx.h"
+#include <audio/mixer.h>
 
 
 namespace DM {
@@ -96,4 +97,15 @@ void DMEngine::f503_loadSounds() {
 	}
 }
 
+void DMEngine::f060_SOUND_Play(uint16 soundIndex, uint16 period, uint8 leftVolume, uint8 rightVolume) {
+	byte soundFlags = Audio::FLAG_STEREO;
+	SoundData *sound = &_gK24_soundData[soundIndex];
+	Audio::AudioStream *stream = Audio::makeRawStream(sound->_firstSample, sound->_byteCount, 72800 / period, soundFlags, DisposeAfterUse::NO);
+
+	signed char balance = ((int16)rightVolume - (int16)leftVolume) / 2;
+
+	Audio::SoundHandle handle;
+	_mixer->playStream(Audio::Mixer::kSFXSoundType, &handle, stream, - 1, 127, balance);
+}
+
 }


Commit: 79c0a0adc99a53df663b469be8a05fa6825383c1
    https://github.com/scummvm/scummvm/commit/79c0a0adc99a53df663b469be8a05fa6825383c1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add  f064_SOUND_RequestPlay_CPSD, f65_playPendingSound, f505_soundGetVolume

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/sounds.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index e825ead2..0381f34 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -396,7 +396,7 @@ void DMEngine::f2_gameloop() {
 			}
 		}
 		// F0363_COMMAND_HighlightBoxDisable();
-		// F0065_SOUND_PlayPendingSound_CPSD();
+		f65_playPendingSound();
 		_championMan->f320_applyAndDrawPendingDamageAndWounds();
 		if (_championMan->_g303_partyDead)
 			break;
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 02def01..1c18702 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -205,7 +205,25 @@ public:
 	SoundData(): _byteCount(0), _firstSample(nullptr), _sampleCount(0) {}
 }; // @ SOUND_DATA
 
-
+class Sound {
+public:
+	int16 _graphicIndex;
+	byte _period;
+	byte _priority;
+	byte _loudDistance;
+	byte _softDistance;
+	Sound(int16 index, byte period, byte priority, byte loudDist, byte softDist) :
+		_graphicIndex(index), _period(period), _priority(priority), _loudDistance(loudDist), _softDistance(softDist) {}
+}; // @ Sound
+
+class PendingSound {
+public:
+	uint8 _leftVolume;
+	uint8 _rightVolume;
+	int16 _soundIndex;
+	PendingSound(uint8 leftVolume, uint8 rightVolume, int16 soundIndex):
+		_leftVolume(leftVolume), _rightVolume(rightVolume), _soundIndex(soundIndex) {}
+};
 
 class DMEngine : public Engine {
 	void f462_startGame(); // @ F0462_START_StartGame_CPSF
@@ -236,9 +254,11 @@ public:
 	void f441_processEntrance(); // @ F0441_STARTEND_ProcessEntrance
 	void f444_endGame(bool doNotDrawCreditsOnly); // @ F0444_STARTEND_Endgame
 
-	void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode) { warning(true, "STUB: f064_SOUND_RequestPlay_CPSD"); }
-	void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol);
-	void f438_STARTEND_OpenEntranceDoors() { warning(true, "STUB: f438_STARTEND_OpenEntranceDoors"); }
+	void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode); // @ F0064_SOUND_RequestPlay_CPSD
+	void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol); // @ F0060_SOUND_Play
+	void f65_playPendingSound(); // @ F0065_SOUND_PlayPendingSound_CPSD
+	bool f505_soundGetVolume(int16 mapX, int16 mapY, uint8 *leftVolume, uint8 *rightVolume); // @ F0505_SOUND_GetVolume
+	void f438_STARTEND_OpenEntranceDoors() { warning(true, "STUB: f438_STARTEND_OpenEntranceDoors"); } // @ F0438_STARTEND_OpenEntranceDoors
 
 private:
 	int16 _g528_saveFormat; // @ G0528_i_Format
@@ -249,6 +269,7 @@ private:
 	byte *_g564_interfaceCredits; // @ G0564_puc_Graphic5_InterfaceCredits
 	Common::RandomSource *_rnd;
 	SoundData _gK24_soundData[k34_D13_soundCount]; // @ K0024_as_SoundData
+	Common::Queue<PendingSound> _pendingSounds;
 public:
 	DisplayMan *_displayMan;
 	DungeonMan *_dungeonMan;
diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp
index cdbed46..b44e97b 100644
--- a/engines/dm/sounds.cpp
+++ b/engines/dm/sounds.cpp
@@ -31,23 +31,15 @@
 #include "dm.h"
 #include "gfx.h"
 #include <audio/mixer.h>
+#include "timeline.h"
+#include "dungeonman.h"
 
 
 namespace DM {
 
-class Sound {
-public:
-	int16 _graphicIndex;
-	byte _period;
-	byte _priority;
-	byte _loudDistance;
-	byte _softDistance;
-	Sound(int16 index, byte period, byte priority, byte loudDist, byte softDist) :
-		_graphicIndex(index), _period(period), _priority(priority), _loudDistance(loudDist), _softDistance(softDist) {}
-}; // @ Sound
 
 
-Sound G0060_as_Graphic562_Sounds[k34_D13_soundCount] = {
+Sound g60_sounds[k34_D13_soundCount] = {
 	Sound(533, 112,  11, 3, 6), /* k00_soundMETALLIC_THUD 0 */
 	Sound(534, 112,  15, 0, 3), /* k01_soundSWITCH 1 */
 	Sound(535, 112,  72, 3, 6), /* k02_soundDOOR_RATTLE 2 */
@@ -87,7 +79,7 @@ void DMEngine::f503_loadSounds() {
 	for (uint16 soundIndex = 0; soundIndex < k34_D13_soundCount; ++soundIndex) {
 		SoundData *soundData = _gK24_soundData + soundIndex;
 
-		uint16 graphicIndex = G0060_as_Graphic562_Sounds[soundIndex]._graphicIndex;
+		uint16 graphicIndex = g60_sounds[soundIndex]._graphicIndex;
 		soundData->_byteCount = _displayMan->getCompressedDataSize(graphicIndex) - 2; // the header is 2 bytes long
 		soundData->_firstSample = new byte[soundData->_byteCount];
 
@@ -98,14 +90,115 @@ void DMEngine::f503_loadSounds() {
 }
 
 void DMEngine::f060_SOUND_Play(uint16 soundIndex, uint16 period, uint8 leftVolume, uint8 rightVolume) {
-	byte soundFlags = Audio::FLAG_STEREO;
 	SoundData *sound = &_gK24_soundData[soundIndex];
-	Audio::AudioStream *stream = Audio::makeRawStream(sound->_firstSample, sound->_byteCount, 72800 / period, soundFlags, DisposeAfterUse::NO);
+	Audio::AudioStream *stream = Audio::makeRawStream(sound->_firstSample, sound->_byteCount, (72800 / period) * 8, 0, DisposeAfterUse::NO);
 
 	signed char balance = ((int16)rightVolume - (int16)leftVolume) / 2;
 
 	Audio::SoundHandle handle;
-	_mixer->playStream(Audio::Mixer::kSFXSoundType, &handle, stream, - 1, 127, balance);
+	_mixer->playStream(Audio::Mixer::kSFXSoundType, &handle, stream, -1, 127, balance);
+}
+
+void DMEngine::f65_playPendingSound() {
+	while (!_pendingSounds.empty()) {
+		PendingSound pendingSound = _pendingSounds.pop();
+		f060_SOUND_Play(pendingSound._soundIndex, g60_sounds[pendingSound._soundIndex]._period, pendingSound._leftVolume, pendingSound._rightVolume);
+	}
+}
+
+bool DMEngine::f505_soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, uint8* rightVolume) {
+	static byte K0030_aauc_DistanceToSoundVolume[25][25] = {
+		{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4,  5,  5,  5,  5,  5,  5,  5, 5, 4, 4, 4, 4, 4},
+		{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 5,  6,  6,  6,  6,  5,  5,  5, 5, 5, 5, 4, 4, 4},
+		{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 5,  6,  6,  6,  6,  6,  6,  5, 5, 5, 5, 5, 4, 4},
+		{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 5,  7,  7,  7,  7,  6,  6,  6, 6, 5, 5, 5, 5, 4},
+		{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 5,  8,  8,  7,  7,  7,  7,  6, 6, 6, 5, 5, 5, 4},
+		{1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 4, 6,  9,  9,  8,  8,  8,  7,  7, 6, 6, 6, 5, 5, 5},
+		{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 6, 10, 10, 10,  9,  8,  8,  7, 7, 6, 6, 5, 5, 5},
+		{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 7, 12, 12, 11, 10,  9,  9,  8, 7, 7, 6, 6, 5, 5},
+		{1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4, 7, 15, 14, 13, 12, 11,  9,  8, 8, 7, 6, 6, 5, 5},
+		{1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4, 8, 20, 19, 16, 14, 12, 10,  9, 8, 7, 7, 6, 6, 5},
+		{1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4, 8, 29, 26, 21, 16, 13, 11, 10, 8, 7, 7, 6, 6, 5},
+		{1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 4, 8, 58, 41, 26, 19, 14, 12, 10, 9, 8, 7, 6, 6, 5},
+		{1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 6, 64, 58, 29, 20, 15, 12, 10, 9, 8, 7, 6, 6, 5},
+		{0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 3, 6, 41, 29, 19, 13, 10,  8,  7, 6, 6, 5, 5, 4, 4},
+		{0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 3, 6, 21, 19, 15, 12, 10,  8,  7, 6, 5, 5, 4, 4, 4},
+		{0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 3, 6, 14, 13, 12, 10,  9,  7,  7, 6, 5, 5, 4, 4, 4},
+		{0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 5, 11, 10, 10,  9,  8,  7,  6, 6, 5, 5, 4, 4, 4},
+		{0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 5,  9,  8,  8,  7,  7,  6,  6, 5, 5, 4, 4, 4, 4},
+		{0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 5,  7,  7,  7,  7,  6,  6,  5, 5, 5, 4, 4, 4, 4},
+		{0, 1, 1, 1, 1, 1, 1, 2, 2, 1, 3, 4,  6,  6,  6,  6,  6,  5,  5, 5, 4, 4, 4, 4, 3},
+		{1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4,  6,  6,  5,  5,  5,  5,  5, 4, 4, 4, 4, 3, 3},
+		{1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4,  5,  5,  5,  5,  5,  4,  4, 4, 4, 4, 3, 3, 3},
+		{1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3,  5,  5,  4,  4,  4,  4,  4, 4, 4, 3, 3, 3, 3},
+		{1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3,  4,  4,  4,  4,  4,  4,  4, 4, 3, 3, 3, 3, 3},
+		{1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3,  4,  4,  4,  4,  4,  4,  4, 3, 3, 3, 3, 3, 3}};
+
+	int16 L1678_i_RightVolumeColumnIndex = 0;
+	int16 L1679_i_LineIndex = 0;
+	int16 L1680_i_LeftVolumeColumnIndex = 0;
+
+
+	switch (_dungeonMan->_g308_partyDir) {
+	case kDirNorth:
+		L1678_i_RightVolumeColumnIndex = mapX - _dungeonMan->_g306_partyMapX;
+		L1679_i_LineIndex = mapY - _dungeonMan->_g307_partyMapY;
+		break;
+	case kDirEast:
+		L1678_i_RightVolumeColumnIndex = mapY - _dungeonMan->_g307_partyMapY;
+		L1679_i_LineIndex = -(mapX - _dungeonMan->_g306_partyMapX);
+		break;
+	case kDirSouth:
+		L1678_i_RightVolumeColumnIndex = -(mapX - _dungeonMan->_g306_partyMapX);
+		L1679_i_LineIndex = -(mapY - _dungeonMan->_g307_partyMapY);
+		break;
+	case kDirWest:
+		L1678_i_RightVolumeColumnIndex = -(mapY - _dungeonMan->_g307_partyMapY);
+		L1679_i_LineIndex = mapX - _dungeonMan->_g306_partyMapX;
+		break;
+	}
+	if ((L1678_i_RightVolumeColumnIndex < -12) || (L1678_i_RightVolumeColumnIndex > 12)) { /* Sound is not audible if source is more than 12 squares away from the party */
+		return false;
+	}
+	if ((L1679_i_LineIndex < -12) || (L1679_i_LineIndex > 12)) { /* Sound is not audible if source is more than 12 squares away from the party */
+		return false;
+	}
+	L1680_i_LeftVolumeColumnIndex = -L1678_i_RightVolumeColumnIndex + 12;
+	L1678_i_RightVolumeColumnIndex += 12;
+	L1679_i_LineIndex += 12;
+	*rightVolume = K0030_aauc_DistanceToSoundVolume[L1679_i_LineIndex][L1678_i_RightVolumeColumnIndex];
+	*leftVolume = K0030_aauc_DistanceToSoundVolume[L1679_i_LineIndex][L1680_i_LeftVolumeColumnIndex];
+	return true;
+}
+
+void DMEngine::f064_SOUND_RequestPlay_CPSD(uint16 soundIndex, int16 mapX, int16 mapY, uint16 mode) {
+	Sound* sound;
+	uint8 leftVolume, rightVolume;
+
+	if (mode && (_dungeonMan->_g272_currMapIndex != _dungeonMan->_g309_partyMapIndex))
+		return;
+
+	sound = &g60_sounds[soundIndex];
+	if (mode > k1_soundModePlayIfPrioritized) { /* Add an event in the timeline to play the sound (mode - 1) ticks later */
+		TimelineEvent event;
+		M33_setMapAndTime(event._mapTime, _dungeonMan->_g272_currMapIndex, _g313_gameTime + mode - 1);
+		event._type = k20_TMEventTypePlaySound;
+		event._priority = sound->_priority;
+		event._C._soundIndex = soundIndex;
+		event._B._location._mapX = mapX;
+		event._B._location._mapY = mapY;
+		_timeline->f238_addEventGetEventIndex(&event);
+		return;
+	}
+
+	if (!f505_soundGetVolume(mapX, mapY, &leftVolume, &rightVolume)) {
+		return;
+	}
+	if (!mode) { /* Play the sound immediately */
+		f060_SOUND_Play(soundIndex, sound->_period, leftVolume, rightVolume);
+		return;
+	}
+	_pendingSounds.push(PendingSound(leftVolume, rightVolume, soundIndex));
 }
 
 }


Commit: 2e2732df3990e88b697021239e7a531c9dad8a54
    https://github.com/scummvm/scummvm/commit/2e2732df3990e88b697021239e7a531c9dad8a54
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Partially fix drawing of shrunk bitmaps

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 8c05efa..8ae9df2 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -37,7 +37,7 @@ Finish stuff:
 	f380_processCommandQueue
 	Missing main loop methods
 	Save file f433_processCommand140_saveGame fails silently
-	Sounds
+	
 	F0438_STARTEND_OpenEntranceDoors
 	F0442_STARTEND_ProcessCommand202_EntranceDrawCredits
 	G0335_ui_SelectedDialogChoice
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 515bca2..6d6163c 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -254,7 +254,7 @@ byte g195_FloorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnament
 	2,   /* Floor Ornament 07 Tiny Pressure Pad */
 	0}; /* Floor Ornament 08 Puddle */
 
-uint16 g205_WallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets
+byte g205_WallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets
 										   /* { X1, X2, Y1, Y2, PixelWidth, Height } */
 	{{80,  83, 41,  45,  8,   5},     /* D3L */
 	{140, 143, 41,  45,  8,   5},     /* D3R */
@@ -709,16 +709,16 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 
 	g186_doorFrame_D1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(64, 159, 17, 102, 48, 88, 0, 0),	/* Closed Or Destroyed */
-		Frame(64, 159, 17, 38, 48, 88, 0, 66),	/* Vertical Closed one fourth */
-		Frame(64, 159, 17, 60, 48, 88, 0, 44),	/* Vertical Closed half */
-		Frame(64, 159, 17, 82, 48, 88, 0, 22),	/* Vertical Closed three fourth */
-		Frame(64, 75, 17, 102, 48, 88, 36, 0),	/* Left Horizontal Closed one fourth */
-		Frame(64, 87, 17, 102, 48, 88, 24, 0),	/* Left Horizontal Closed half */
-		Frame(64, 99, 17, 102, 48, 88, 12, 0),	/* Left Horizontal Closed three fourth */
-		Frame(148, 159, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed one fourth */
-		Frame(136, 159, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed half */
-		Frame(124, 159, 17, 102, 48, 88, 48, 0)	/* Right Horizontal Closed three fourth */
+										Frame(64, 159, 17, 102, 48, 88, 0, 0),	/* Closed Or Destroyed */
+										Frame(64, 159, 17, 38, 48, 88, 0, 66),	/* Vertical Closed one fourth */
+										Frame(64, 159, 17, 60, 48, 88, 0, 44),	/* Vertical Closed half */
+										Frame(64, 159, 17, 82, 48, 88, 0, 22),	/* Vertical Closed three fourth */
+										Frame(64, 75, 17, 102, 48, 88, 36, 0),	/* Left Horizontal Closed one fourth */
+										Frame(64, 87, 17, 102, 48, 88, 24, 0),	/* Left Horizontal Closed half */
+										Frame(64, 99, 17, 102, 48, 88, 12, 0),	/* Left Horizontal Closed three fourth */
+										Frame(148, 159, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed one fourth */
+										Frame(136, 159, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed half */
+										Frame(124, 159, 17, 102, 48, 88, 48, 0)	/* Right Horizontal Closed three fourth */
 	);
 
 	for (uint16 i = 0; i < 32; i++)
@@ -2452,7 +2452,7 @@ void DisplayMan::f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativ
 }
 
 bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) {
-	static const Box boxWallPatchBehindInscription = Box(110, 113, 37, 63); // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription 
+	static Box boxWallPatchBehindInscription = Box(110, 113, 37, 63); // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription 
 	static const byte inscriptionLineY[4] = { // @ G0203_auc_Graphic558_InscriptionLineY
 		48,   /* 1 Line  */
 		59,   /* 2 lines */
@@ -2474,7 +2474,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 		4    /* D1R Left */
 	};
 
-	static const byte unreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableInscriptionBoxY2
+	static byte unreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableInscriptionBoxY2
 		/* { Y for 1 line, Y for 2 lines, Y for 3 lines } */
 		45, 48, 53,   /* D3L Right, D3R Left */
 		43, 49, 56,   /* D3L Front, D3C Front, D3R Front */
@@ -2483,155 +2483,174 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 		46, 57, 68    /* D1L Right, D1R Left */
 	};
 
-	static const Box boxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall
+	static Box boxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall
+
+#define AP0116_i_CharacterCount    wallOrnOrd
+#define AP0116_i_WallOrnamentIndex wallOrnOrd
+	int16 L0088_i_Multiple;
+#define AL0088_i_NativeBitmapIndex       L0088_i_Multiple
+#define AL0088_i_UnreadableTextLineCount L0088_i_Multiple
+	int16 L0089_i_Multiple;
+#define AL0089_i_WallOrnamentCoordinateSetIndex L0089_i_Multiple
+#define AL0089_i_FountainOrnamentIndex          L0089_i_Multiple
+#define AL0089_i_PixelWidth                     L0089_i_Multiple
+#define AL0089_i_X                              L0089_i_Multiple
+	byte* L0090_puc_Multiple;
+#define AL0090_puc_String        L0090_puc_Multiple
+#define AL0090_puc_CoordinateSet L0090_puc_Multiple
+	byte* L0091_puc_Multiple;
+#define AL0091_puc_Character     L0091_puc_Multiple
+#define AL0091_puc_Bitmap        L0091_puc_Multiple
+#define AL0091_puc_CoordinateSet L0091_puc_Multiple
+	byte* L0092_puc_Bitmap;
+	int16 L0093_i_CoordinateSetOffset;
+	bool L0094_B_FlipHorizontal;
+	bool L0095_B_IsInscription;
+	bool L0096_B_IsAlcove;
+	int16 L0097_i_TextLineIndex;
+	Frame L0098_s_Frame;
+	byte tmpCoordSet[6];
+	unsigned char L0099_auc_InscriptionString[70];
+
 
 	if (wallOrnOrd) {
-		int16 wallOrnamentIndex = wallOrnOrd - 1;
-		int16 nativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnamentIndex][k0_NativeBitmapIndex];
-		int16 wallOrnamentCoordinateSetIndex = _g101_currMapWallOrnInfo[wallOrnamentIndex][k1_CoordinateSet];
-		uint16 *coordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][viewWallIndex];
-
-		bool isAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(wallOrnamentIndex);
-		bool isInscription = (wallOrnamentIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex);
-		byte inscriptionString[70];
-		if (isInscription)
-			_vm->_dungeonMan->f168_decodeText((char *)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
-
-		byte *displayBitmap;
-		int16 boxSrcX;
+		wallOrnOrd--;
+		AL0088_i_NativeBitmapIndex = _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k0_NativeBitmapIndex];
+		AL0090_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex = _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k1_CoordinateSet]][viewWallIndex];
+		L0096_B_IsAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(AP0116_i_WallOrnamentIndex);
+		if (L0095_B_IsInscription = (AP0116_i_WallOrnamentIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex)) {
+			_vm->_dungeonMan->f168_decodeText((char *)L0099_auc_InscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
+		}
 		if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) {
 			if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
-				if (isInscription) {
-					f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport,
-									  (Box &)boxWallPatchBehindInscription, 94, 28,
-									  g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth,
-									  k112_byteWidthViewport, kM1_ColorNoTransparency, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport);
-					byte *tmpString = inscriptionString;
-					byte *fontBitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont);
-					int16 textLineIndex = 0;
+				if (L0095_B_IsInscription) {
+					f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, boxWallPatchBehindInscription, 94, 28, g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport);
+					AL0090_puc_String = L0099_auc_InscriptionString;
+					L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont);
+					L0097_i_TextLineIndex = 0;
 					do {
-						int16 characterCount = 0;
-						byte *curCharacter = tmpString;
-						while (*curCharacter++ < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
-							characterCount++;
+						AP0116_i_CharacterCount = 0;
+						AL0091_puc_Character = AL0090_puc_String;
+						while (*AL0091_puc_Character++ < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
+							AP0116_i_CharacterCount++;
 						}
-						Frame curFrame;
-						curFrame._box._x2 = (curFrame._box._x1 = 112 - (characterCount << 2)) + 7;
-						curFrame._box._y1 = (curFrame._box._y2 = inscriptionLineY[textLineIndex++]) - 7;
-						while (characterCount--) {
-							f132_blitToBitmap(fontBitmap, _g296_bitmapViewport, curFrame._box,
-											  *tmpString++ << 3, 0, 144, k112_byteWidthViewport, k10_ColorFlesh, 8, k136_heightViewport);
-							curFrame._box._x1 += 8;
-							curFrame._box._x2 += 8;
+						L0098_s_Frame._box._x2 = (L0098_s_Frame._box._x1 = 112 - (AP0116_i_CharacterCount << 2)) + 7;
+						L0098_s_Frame._box._y1 = (L0098_s_Frame._box._y2 = inscriptionLineY[L0097_i_TextLineIndex++]) - 7;
+						while (AP0116_i_CharacterCount--) {
+							f132_blitToBitmap(L0092_puc_Bitmap, _g296_bitmapViewport, L0098_s_Frame._box, *AL0090_puc_String++ << 3, 0, k144_byteWidth, k112_byteWidthViewport, k10_ColorFlesh, 8, k136_heightViewport);
+							L0098_s_Frame._box._x1 += 8;
+							L0098_s_Frame._box._x2 += 8;
 						}
-					} while (*tmpString++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
-					return isAlcove;
+					} while (*AL0090_puc_String++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
+					goto T0107031;
 				}
-				nativeBitmapIndex++;
-				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordinateSet[0];
-				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordinateSet[1];
-				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordinateSet[2];
-				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordinateSet[3];
-
-				_vm->_dungeonMan->_g286_isFacingAlcove = isAlcove;
+				AL0088_i_NativeBitmapIndex++;
+				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn] = Box(AL0090_puc_CoordinateSet);
+				_vm->_dungeonMan->_g286_isFacingAlcove = L0096_B_IsAlcove;
 				_vm->_dungeonMan->_g287_isFacingViAltar =
-					(wallOrnamentIndex == _g266_currMapViAltarIndex);
+					(AP0116_i_WallOrnamentIndex == _g266_currMapViAltarIndex);
 				_vm->_dungeonMan->_g288_isFacingFountain = false;
-				for (int16 idx = 0; idx < k1_FountainOrnCount; idx++) {
-					if (_g268_currMapFountainOrnIndices[idx] == wallOrnamentIndex) {
+				for (AL0089_i_FountainOrnamentIndex = 0; AL0089_i_FountainOrnamentIndex < k1_FountainOrnCount; AL0089_i_FountainOrnamentIndex++) {
+					if (_g268_currMapFountainOrnIndices[AL0089_i_FountainOrnamentIndex] == AP0116_i_WallOrnamentIndex) {
 						_vm->_dungeonMan->_g288_isFacingFountain = true;
 						break;
 					}
 				}
 			}
-			displayBitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+			AL0091_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
 			if (viewWallIndex == k11_ViewWall_D1R_LEFT) {
-				f99_copyBitmapAndFlipHorizontal(displayBitmap, _g74_tmpBitmap, coordinateSet[4], coordinateSet[5]);
-				displayBitmap = _g74_tmpBitmap;
+				f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]);
+				AL0091_puc_Bitmap = _g74_tmpBitmap;
 			}
-			boxSrcX = 0;
+			AL0089_i_X = 0;
 		} else {
-			uint16 *coordinateSet;
-			int16 coordinateSetOffset = 0;
-			bool flipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT);
-			if (flipHorizontal || (viewWallIndex == k1_ViewWall_D3R_LEFT)) {
-				coordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k11_ViewWall_D1R_LEFT];
-			} else if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT))
-				coordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k10_ViewWall_D1L_RIGHT];
-			else {
-				nativeBitmapIndex++;
-				coordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k12_ViewWall_D1C_FRONT];
-				if (viewWallIndex == k7_ViewWall_D2L_FRONT)
-					coordinateSetOffset = 6;
-				else if (viewWallIndex == k9_ViewWall_D2R_FRONT)
-					coordinateSetOffset = -6;
+			L0093_i_CoordinateSetOffset = 0;
+			if (L0094_B_FlipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT)) {
+				AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k11_ViewWall_D1R_LEFT];
+			} else {
+				if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT)) {
+					AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k10_ViewWall_D1L_RIGHT];
+				} else {
+					AL0088_i_NativeBitmapIndex++;
+					AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k12_ViewWall_D1C_FRONT];
+					if (viewWallIndex == k7_ViewWall_D2L_FRONT) {
+						L0093_i_CoordinateSetOffset = 6;
+					} else {
+						if (viewWallIndex == k9_ViewWall_D2R_FRONT) {
+							L0093_i_CoordinateSetOffset = -6;
+						}
+					}
+				}
 			}
-			int16 pixelWidth = (coordinateSet + coordinateSetOffset)[1] - (coordinateSet + coordinateSetOffset)[0];
-			wallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + (wallOrnamentIndex << 2) + wallOrnDerivedBitmapIndexIncrement[viewWallIndex];
-			if (!f491_isDerivedBitmapInCache(wallOrnamentIndex)) {
-				byte *L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(wallOrnamentIndex),
-													 coordinateSet[4] << 1,
-													 coordinateSet[5], pixelWidth + 1,
-													 coordinateSet[5],
-													 (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
-				f493_addDerivedBitmap(wallOrnamentIndex);
+			AL0089_i_PixelWidth = (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[1] - (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[0];
+			if (!f491_isDerivedBitmapInCache(AP0116_i_WallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + (AP0116_i_WallOrnamentIndex << 2) + wallOrnDerivedBitmapIndexIncrement[viewWallIndex])) {
+				L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
+				f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex), AL0091_puc_CoordinateSet[4] << 1, AL0091_puc_CoordinateSet[5], AL0089_i_PixelWidth + 1, AL0090_puc_CoordinateSet[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
+				f493_addDerivedBitmap(AP0116_i_WallOrnamentIndex);
+			}
+			AL0091_puc_Bitmap = f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex);
+			if (L0094_B_FlipHorizontal) {
+				f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]);
+				AL0091_puc_Bitmap = _g74_tmpBitmap;
+				AL0089_i_X = 15 - (AL0089_i_X & 0x000F);
+			} else {
+				if (viewWallIndex == k7_ViewWall_D2L_FRONT) {
+					AL0089_i_X -= AL0090_puc_CoordinateSet[1] - AL0090_puc_CoordinateSet[0];
+				} else {
+					AL0089_i_X = 0;
+				}
 			}
-			displayBitmap = f492_getDerivedBitmap(wallOrnamentIndex);
-			if (flipHorizontal) {
-				f99_copyBitmapAndFlipHorizontal(displayBitmap, _g74_tmpBitmap, coordinateSet[4], coordinateSet[5]);
-				displayBitmap = _g74_tmpBitmap;
-				boxSrcX = 15 - (boxSrcX & 0x000F);
-			} else if (viewWallIndex == k7_ViewWall_D2L_FRONT)
-				boxSrcX = pixelWidth - (coordinateSet[1] - coordinateSet[0]);
-			else
-				boxSrcX = 0;
 		}
-		if (isInscription) {
-			byte *tmpString = inscriptionString;
-			int16 unreadableTextLineCount = 0;
+		if (L0095_B_IsInscription) {
+			L0092_puc_Bitmap = AL0090_puc_CoordinateSet;
+			AL0090_puc_String = L0099_auc_InscriptionString;
+			AL0088_i_UnreadableTextLineCount = 0;
 			do {
-				while (*tmpString < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
-					tmpString++;
+				while (*AL0090_puc_String < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
+					AL0090_puc_String++;
 				}
-				unreadableTextLineCount++;
-			} while (*tmpString++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
-			if (unreadableTextLineCount < 4) {
-				uint16 tmp[6];
+				AL0088_i_UnreadableTextLineCount++;
+			} while (*AL0090_puc_String++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
+			AL0090_puc_CoordinateSet = L0092_puc_Bitmap;
+			if (AL0088_i_UnreadableTextLineCount < 4) {
 				for (uint16 i = 0; i < 6; ++i)
-					tmp[i] = coordinateSet[i];
-				coordinateSet = tmp;
-				coordinateSet[3] = unreadableInscriptionBoxY2[wallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
+					tmpCoordSet[i] = AL0090_puc_CoordinateSet[i];
+				AL0090_puc_CoordinateSet = tmpCoordSet;
+				AL0090_puc_CoordinateSet[3] = unreadableInscriptionBoxY2[wallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + AL0088_i_UnreadableTextLineCount - 1];
 			}
 		}
-		f132_blitToBitmap(displayBitmap, _g296_bitmapViewport,
-						  *(Box *)coordinateSet, boxSrcX, 0,
-						  coordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, coordinateSet[5], k136_heightViewport);
-		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
-			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice),
-							  _g296_bitmapViewport, (Box &)boxChampionPortraitOnWall,
-							  (_g289_championPortraitOrdinal & 0x0007) << 5,
-							  (_g289_championPortraitOrdinal >> 3) * 29, 128, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport);
+		{
+			Box tmpBox(AL0090_puc_CoordinateSet);
+			f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport, tmpBox, AL0089_i_X, 0, AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport);
 		}
-		return isAlcove;
+		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { /* BUG0_05 A champion portrait sensor on a wall square is visible on all sides of the wall. If there is another sensor with a wall ornament on one side of the wall then the champion portrait is drawn over that wall ornament */
+			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), _g296_bitmapViewport, boxChampionPortraitOnWall, (_g289_championPortraitOrdinal & 0x0007) << 5, (_g289_championPortraitOrdinal >> 3) * 29, k128_byteWidth, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); /* A portrait is 32x29 pixels */
+		}
+T0107031:
+		return L0096_B_IsAlcove;
 	}
 	return false;
 }
 
 
-void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap, int16 srcPixelWidth, int16 srcHeight, int16 destPixelWidth, int16 destHeight, byte *palChange) {
-	double rateW = srcPixelWidth / destPixelWidth;
-	double rateH = srcHeight / destHeight;
+void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
+													  int16 srcPixelWidth, int16 srcHeight,
+													  int16 destPixelWidth, int16 destHeight, byte *palChange) {
+	const uint32 SCALE_THRESHOLD = 32768;
+	uint32 scaleX = (SCALE_THRESHOLD * srcPixelWidth) / destPixelWidth;
+	uint32 scaleY = (SCALE_THRESHOLD * srcHeight) / destHeight;
 
-	for (uint16 y = 0; y < destHeight; ++y) {
-		for (uint16 x = 0; x < destPixelWidth; ++x) {
-			if (palChange)
-				destBitmap[y * destPixelWidth + x] = palChange[srcBitmap[(int)(y * rateH * srcPixelWidth) + (int)(x * rateW)]];
-			else
-				destBitmap[y * destPixelWidth + x] = srcBitmap[(int)(y * rateH * srcPixelWidth) + (int)(x * rateW)];
+	// Loop through drawing output lines
+	for (uint32 destY = 0, scaleYCtr = 0; destY < destHeight; ++destY, scaleYCtr += scaleY) {
+
+		const byte *srcLine = &srcBitmap[(scaleYCtr / SCALE_THRESHOLD) * srcPixelWidth];
+		byte *destLine = &destBitmap[destY * destPixelWidth];
+
+		// Loop through drawing the pixels of the row
+		for (uint32 destX = 0, xCtr = 0, scaleXCtr = 0; destX < destPixelWidth; ++destX, ++xCtr, scaleXCtr += scaleX) {
+			destLine[xCtr] = srcLine[scaleXCtr / SCALE_THRESHOLD];
 		}
 	}
-
 }
 
 byte* DisplayMan::f489_getNativeBitmapOrGraphic(uint16 index) {
@@ -3685,8 +3704,10 @@ bool DisplayMan::f491_isDerivedBitmapInCache(int16 derivedBitmapIndex) {
 		// * 2, because the original uses 4 bits instead of 8 bits to store a pixel
 		_g638_derivedBitmaps[derivedBitmapIndex] = new byte[_g639_derivedBitmapByteCount[derivedBitmapIndex] * 2];
 		return false;
-	} else
-		return true;
+	} else {
+		warning(false, "f491_isDerivedBitmapInCache always returns false");
+		return false;
+	}
 }
 
 byte* DisplayMan::f492_getDerivedBitmap(int16 derivedBitmapIndex) {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 387a73d..4dd1694 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -295,7 +295,8 @@ public:
 
 	Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2) : _x1(x1), _x2(x2), _y1(y1), _y2(y2) {}
 	Box() {}
-	explicit Box(uint16 *ptr) {
+	template <typename T>
+	explicit Box(T *ptr) {
 		_x1 = *ptr++;
 		_x2 = *ptr++;
 		_y1 = *ptr++;


Commit: 483f05206f8286a69943ce0783fed53bbef7977a
    https://github.com/scummvm/scummvm/commit/483f05206f8286a69943ce0783fed53bbef7977a
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix drawing of some wall oranments

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 6d6163c..59f8f1c 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2640,6 +2640,12 @@ void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *des
 	uint32 scaleX = (SCALE_THRESHOLD * srcPixelWidth) / destPixelWidth;
 	uint32 scaleY = (SCALE_THRESHOLD * srcHeight) / destHeight;
 
+	warning(false, "MISSING CODE: No palette change takes place in f129_blitToBitmapShrinkWithPalChange");
+
+	// HACK
+	if (destPixelWidth % 2)
+		destPixelWidth++;
+
 	// Loop through drawing output lines
 	for (uint32 destY = 0, scaleYCtr = 0; destY < destHeight; ++destY, scaleYCtr += scaleY) {
 


Commit: 1a96af48c52b9efe8a8d5a4ceee1dd8d5f0ca3b1
    https://github.com/scummvm/scummvm/commit/1a96af48c52b9efe8a8d5a4ceee1dd8d5f0ca3b1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix portrait drawing

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 59f8f1c..347bb5d 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2585,7 +2585,12 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 			AL0089_i_PixelWidth = (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[1] - (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[0];
 			if (!f491_isDerivedBitmapInCache(AP0116_i_WallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + (AP0116_i_WallOrnamentIndex << 2) + wallOrnDerivedBitmapIndexIncrement[viewWallIndex])) {
 				L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex), AL0091_puc_CoordinateSet[4] << 1, AL0091_puc_CoordinateSet[5], AL0089_i_PixelWidth + 1, AL0090_puc_CoordinateSet[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
+				// HACK: originally AL0089_i_PixelWidth + 1 is passed as the 5th parameter, but then later  AL0090_puc_CoordinateSet[4]'s value is used
+				//		to get the width of the shrunk bitmap, dunno why that is
+				f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex),
+													 AL0091_puc_CoordinateSet[4] << 1, AL0091_puc_CoordinateSet[5],
+													 AL0090_puc_CoordinateSet[4] << 1, AL0090_puc_CoordinateSet[5],
+													 (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
 				f493_addDerivedBitmap(AP0116_i_WallOrnamentIndex);
 			}
 			AL0091_puc_Bitmap = f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex);


Commit: d02a66d5ee75d16f553c424986c92b905813460a
    https://github.com/scummvm/scummvm/commit/d02a66d5ee75d16f553c424986c92b905813460a
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove hack from f107_isDrawnWallOrnAnAlcove

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 347bb5d..2103a5e 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2484,7 +2484,6 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 	};
 
 	static Box boxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall
-
 #define AP0116_i_CharacterCount    wallOrnOrd
 #define AP0116_i_WallOrnamentIndex wallOrnOrd
 	int16 L0088_i_Multiple;
@@ -2509,7 +2508,6 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 	bool L0096_B_IsAlcove;
 	int16 L0097_i_TextLineIndex;
 	Frame L0098_s_Frame;
-	byte tmpCoordSet[6];
 	unsigned char L0099_auc_InscriptionString[70];
 
 
@@ -2519,7 +2517,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 		AL0090_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex = _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k1_CoordinateSet]][viewWallIndex];
 		L0096_B_IsAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(AP0116_i_WallOrnamentIndex);
 		if (L0095_B_IsInscription = (AP0116_i_WallOrnamentIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex)) {
-			_vm->_dungeonMan->f168_decodeText((char *)L0099_auc_InscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
+			_vm->_dungeonMan->f168_decodeText((char*)L0099_auc_InscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
 		}
 		if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) {
 			if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
@@ -2545,7 +2543,10 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 					goto T0107031;
 				}
 				AL0088_i_NativeBitmapIndex++;
-				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn] = Box(AL0090_puc_CoordinateSet);
+				{
+					Box tmpBox(AL0090_puc_CoordinateSet);
+					_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn] = tmpBox;
+				}
 				_vm->_dungeonMan->_g286_isFacingAlcove = L0096_B_IsAlcove;
 				_vm->_dungeonMan->_g287_isFacingViAltar =
 					(AP0116_i_WallOrnamentIndex == _g266_currMapViAltarIndex);
@@ -2557,7 +2558,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 					}
 				}
 			}
-			AL0091_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
+			AL0091_puc_Bitmap =f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
 			if (viewWallIndex == k11_ViewWall_D1R_LEFT) {
 				f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]);
 				AL0091_puc_Bitmap = _g74_tmpBitmap;
@@ -2585,12 +2586,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 			AL0089_i_PixelWidth = (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[1] - (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[0];
 			if (!f491_isDerivedBitmapInCache(AP0116_i_WallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + (AP0116_i_WallOrnamentIndex << 2) + wallOrnDerivedBitmapIndexIncrement[viewWallIndex])) {
 				L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
-				// HACK: originally AL0089_i_PixelWidth + 1 is passed as the 5th parameter, but then later  AL0090_puc_CoordinateSet[4]'s value is used
-				//		to get the width of the shrunk bitmap, dunno why that is
-				f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex),
-													 AL0091_puc_CoordinateSet[4] << 1, AL0091_puc_CoordinateSet[5],
-													 AL0090_puc_CoordinateSet[4] << 1, AL0090_puc_CoordinateSet[5],
-													 (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
+				f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex), AL0091_puc_CoordinateSet[4] << 1, AL0091_puc_CoordinateSet[5], AL0089_i_PixelWidth + 1, AL0090_puc_CoordinateSet[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
 				f493_addDerivedBitmap(AP0116_i_WallOrnamentIndex);
 			}
 			AL0091_puc_Bitmap = f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex);
@@ -2606,6 +2602,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 				}
 			}
 		}
+		byte byteFrame[6];
 		if (L0095_B_IsInscription) {
 			L0092_puc_Bitmap = AL0090_puc_CoordinateSet;
 			AL0090_puc_String = L0099_auc_InscriptionString;
@@ -2619,8 +2616,8 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 			AL0090_puc_CoordinateSet = L0092_puc_Bitmap;
 			if (AL0088_i_UnreadableTextLineCount < 4) {
 				for (uint16 i = 0; i < 6; ++i)
-					tmpCoordSet[i] = AL0090_puc_CoordinateSet[i];
-				AL0090_puc_CoordinateSet = tmpCoordSet;
+					byteFrame[i] = AL0090_puc_CoordinateSet[i];
+				AL0090_puc_CoordinateSet = byteFrame;
 				AL0090_puc_CoordinateSet[3] = unreadableInscriptionBoxY2[wallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + AL0088_i_UnreadableTextLineCount - 1];
 			}
 		}
@@ -2628,8 +2625,10 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 			Box tmpBox(AL0090_puc_CoordinateSet);
 			f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport, tmpBox, AL0089_i_X, 0, AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport);
 		}
-		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { /* BUG0_05 A champion portrait sensor on a wall square is visible on all sides of the wall. If there is another sensor with a wall ornament on one side of the wall then the champion portrait is drawn over that wall ornament */
-			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), _g296_bitmapViewport, boxChampionPortraitOnWall, (_g289_championPortraitOrdinal & 0x0007) << 5, (_g289_championPortraitOrdinal >> 3) * 29, k128_byteWidth, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); /* A portrait is 32x29 pixels */
+
+		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { 
+			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), _g296_bitmapViewport, boxChampionPortraitOnWall,
+				(_g289_championPortraitOrdinal & 0x0007) << 5, (_g289_championPortraitOrdinal >> 3) * 29, k128_byteWidth, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); /* A portrait is 32x29 pixels */
 		}
 T0107031:
 		return L0096_B_IsAlcove;


Commit: 65e40980801b346f8dff4fa5afff281b61202614
    https://github.com/scummvm/scummvm/commit/65e40980801b346f8dff4fa5afff281b61202614
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Improve on broken display

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/gfx.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index c91412a..61b222c 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -827,149 +827,137 @@ Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) {
 
 
 // TODO: produce more GOTOs
-void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX, int16 mapY) {	// complete, except where marked
-#define thingType dir
-	byte L0307_uc_Multiple;
-#define square            L0307_uc_Multiple
-#define footprintsAllowed L0307_uc_Multiple
-#define scentOrdinal      L0307_uc_Multiple
-	Sensor* sensor;
-	bool leftRandWallOrnAllowed = false;
+void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX, int16 mapY) {	
+#define AP0318_i_ThingType dir
+	unsigned char L0307_uc_Multiple;
+#define AL0307_uc_Square            L0307_uc_Multiple
+#define AL0307_uc_FootprintsAllowed L0307_uc_Multiple
+#define AL0307_uc_ScentOrdinal      L0307_uc_Multiple
+	Sensor* L0308_ps_Sensor;
+	bool L0309_B_LeftRandomWallOrnamentAllowed = 0;
 	int16 L0310_i_Multiple = 0;
-#define frontRandWallOrnAllowed L0310_i_Multiple
-#define sideIndex                      L0310_i_Multiple
-	bool rightRandWallOrnAllowed = false;
-	int16 thingTypeRedEagle;
-	bool squreIsFakeWall;
-	Thing thing;
+#define AL0310_B_FrontRandomWallOrnamentAllowed L0310_i_Multiple
+#define AL0310_i_SideIndex                      L0310_i_Multiple
+	bool L0311_B_RightRandomWallOrnamentAllowed = 0;
+	int16 L0312_i_ThingType;
+	bool L0313_B_SquareIsFakeWall;
+	Thing L0314_T_Thing;
 
 
 	for (uint16 i = 0; i < 5; ++i)
 		aspectArray[i] = 0;
-
-	thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
-	square = _vm->_dungeonMan->f151_getSquare(mapX, mapY).toByte();
-	switch (aspectArray[k0_ElemAspect] = Square(square).getType()) {
+	L0314_T_Thing = f161_getSquareFirstThing(mapX, mapY);
+	AL0307_uc_Square = f151_getSquare(mapX, mapY).toByte();
+	switch (aspectArray[k0_ElemAspect] = Square(AL0307_uc_Square).getType()) {
 	case k0_ElementTypeWall:
 		switch (dir) {
 		case kDirNorth:
-			leftRandWallOrnAllowed = getFlag(square, k0x0004_WallEastRandOrnAllowed);
-			frontRandWallOrnAllowed = getFlag(square, k0x0002_WallSouthRandOrnAllowed);
-			rightRandWallOrnAllowed = getFlag(square, k0x0001_WallWestRandOrnAllowed);
+			L0309_B_LeftRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0004_WallEastRandOrnAllowed);
+			AL0310_B_FrontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0002_WallSouthRandOrnAllowed);
+			L0311_B_RightRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0001_WallWestRandOrnAllowed);
 			break;
 		case kDirEast:
-			leftRandWallOrnAllowed = getFlag(square, k0x0002_WallSouthRandOrnAllowed);
-			frontRandWallOrnAllowed = getFlag(square, k0x0001_WallWestRandOrnAllowed);
-			rightRandWallOrnAllowed = getFlag(square, k0x0008_WallNorthRandOrnAllowed);
+			L0309_B_LeftRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0002_WallSouthRandOrnAllowed);
+			AL0310_B_FrontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0001_WallWestRandOrnAllowed);
+			L0311_B_RightRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0008_WallNorthRandOrnAllowed);
 			break;
 		case kDirSouth:
-			leftRandWallOrnAllowed = getFlag(square, k0x0001_WallWestRandOrnAllowed);
-			frontRandWallOrnAllowed = getFlag(square, k0x0008_WallNorthRandOrnAllowed);
-			rightRandWallOrnAllowed = getFlag(square, k0x0004_WallEastRandOrnAllowed);
+			L0309_B_LeftRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0001_WallWestRandOrnAllowed);
+			AL0310_B_FrontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0008_WallNorthRandOrnAllowed);
+			L0311_B_RightRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0004_WallEastRandOrnAllowed);
 			break;
 		case kDirWest:
-			leftRandWallOrnAllowed = getFlag(square, k0x0008_WallNorthRandOrnAllowed);
-			frontRandWallOrnAllowed = getFlag(square, k0x0004_WallEastRandOrnAllowed);
-			rightRandWallOrnAllowed = getFlag(square, k0x0002_WallSouthRandOrnAllowed);
+			L0309_B_LeftRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0008_WallNorthRandOrnAllowed);
+			AL0310_B_FrontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0004_WallEastRandOrnAllowed);
+			L0311_B_RightRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0002_WallSouthRandOrnAllowed);
+			break;
+		default:
+			assert(false);
 		}
- /* BUG0_75 Multiple champion portraits are drawn (one at a time) then the game crashes. This variable is only
- reset to 0 when at least one square in the dungeon view is a wall. If the party is in front of a wall with a
- champion portrait and the next time the dungeon view is drawn there is no wall square in the view and the
- square in front of the party is a fake wall with a random ornament then the same champion portrait will be
- drawn again because the variable was not reset to 0. Each time _vm->_displayMan->f107_isDrawnWallOrnAnAlcove
- draws the portrait, _vm->_displayMan->_g289_championPortraitOrdinal is decremented so that the portait is
- different each time the dungeon view is drawn until the game crashes */
-		_vm->_displayMan->_g289_championPortraitOrdinal = 0;
-		squreIsFakeWall = false;
+		_vm->_displayMan->_g289_championPortraitOrdinal = 0; 
+		L0313_B_SquareIsFakeWall = false;
 T0172010_ClosedFakeWall:
-		_vm->_dungeonMan->f171_setSquareAspectOrnOrdinals(aspectArray,
-														  leftRandWallOrnAllowed, frontRandWallOrnAllowed, rightRandWallOrnAllowed, dir, mapX, mapY, squreIsFakeWall);
-		while ((thing != Thing::_endOfList) && ((thingTypeRedEagle = thing.getType()) <= k3_SensorThingType)) {
-			if (sideIndex = M21_normalizeModulo4(thing.getCell() - dir)) { /* Invisible on the back wall if 0 */
-				sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(thing);
-				if (thingTypeRedEagle == k2_TextstringType) {
-					if (((TextString*)sensor)->isVisible()) {
-						aspectArray[sideIndex + 1] = _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex + 1;
-/* BUG0_76 The same text is drawn on multiple sides of a wall square. The engine stores only a
-single text to draw on a wall in a global variable. Even if different texts are placed on
-different sides of the wall, the same text is drawn on each affected side */
-						_vm->_displayMan->_g290_inscriptionThing = thing;
+		f171_setSquareAspectOrnOrdinals(aspectArray, L0309_B_LeftRandomWallOrnamentAllowed, AL0310_B_FrontRandomWallOrnamentAllowed, L0311_B_RightRandomWallOrnamentAllowed, dir, mapX, mapY, L0313_B_SquareIsFakeWall);
+		while ((L0314_T_Thing != Thing::_endOfList) && ((L0312_i_ThingType = L0314_T_Thing.getType()) <= k3_SensorThingType)) {
+			if (AL0310_i_SideIndex = M21_normalizeModulo4(L0314_T_Thing.getCell() - dir)) { /* Invisible on the back wall if 0 */
+				L0308_ps_Sensor = (Sensor*)f156_getThingData(L0314_T_Thing);
+				if (L0312_i_ThingType == k2_TextstringType) {
+					if (((TextString*)L0308_ps_Sensor)->isVisible()) {
+						aspectArray[AL0310_i_SideIndex + 1] = _g265_currMapInscriptionWallOrnIndex + 1;
+						_vm->_displayMan->_g290_inscriptionThing = L0314_T_Thing; /* BUG0_76 The same text is drawn on multiple sides of a wall square. The engine stores only a single text to draw on a wall in a global variable. Even if different texts are placed on differents sides of the wall, the same text is drawn on each affected side */
 					}
 				} else {
-					aspectArray[sideIndex + 1] = sensor->getOrnOrdinal();
-					if (sensor->getType() == k127_SensorWallChampionPortrait) {
-						_vm->_displayMan->_g289_championPortraitOrdinal = _vm->M0_indexToOrdinal(sensor->getData());
+					aspectArray[AL0310_i_SideIndex + 1] = L0308_ps_Sensor->getOrnOrdinal();
+					if (L0308_ps_Sensor->getType() == k127_SensorWallChampionPortrait) {
+						_vm->_displayMan->_g289_championPortraitOrdinal = _vm->M0_indexToOrdinal(L0308_ps_Sensor->getData());
 					}
 				}
 			}
-			thing = _vm->_dungeonMan->f159_getNextThing(thing);
+			L0314_T_Thing = f159_getNextThing(L0314_T_Thing);
 		}
-		if (squreIsFakeWall && (_vm->_dungeonMan->_g306_partyMapX != mapX) && (_vm->_dungeonMan->_g307_partyMapY != mapY)) {
+		if (L0313_B_SquareIsFakeWall && (_g306_partyMapX != mapX) && (_g307_partyMapY != mapY)) {
 			aspectArray[k1_FirstGroupOrObjectAspect] = Thing::_endOfList.toUint16();
 			return;
 		}
 		break;
 	case k2_ElementTypePit:
-		if (getFlag(square, k0x0008_PitOpen)) {
-			aspectArray[k2_PitInvisibleAspect] = getFlag(square, k0x0004_PitInvisible);
-			footprintsAllowed &= 0x0001;
+		if (getFlag(AL0307_uc_Square, k0x0008_PitOpen)) {
+			aspectArray[k2_PitInvisibleAspect] = getFlag(AL0307_uc_Square, k0x0004_PitInvisible);
+			AL0307_uc_FootprintsAllowed &= 0x0001;
 		} else {
 			aspectArray[k0_ElemAspect] = k1_CorridorElemType;
-			footprintsAllowed = true;
+			AL0307_uc_FootprintsAllowed = true;
 		}
 		goto T0172030_Pit;
 	case k6_ElementTypeFakeWall:
-		if (!getFlag(square, k0x0004_FakeWallOpen)) {
+		if (!getFlag(AL0307_uc_Square, k0x0004_FakeWallOpen)) {
 			aspectArray[k0_ElemAspect] = k0_ElementTypeWall;
-			leftRandWallOrnAllowed = rightRandWallOrnAllowed = frontRandWallOrnAllowed = getFlag(square, k0x0008_FakeWallRandOrnOrFootPAllowed);
-			squreIsFakeWall = true;
+			L0309_B_LeftRandomWallOrnamentAllowed = L0311_B_RightRandomWallOrnamentAllowed = AL0310_B_FrontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0008_FakeWallRandOrnOrFootPAllowed);
+			L0313_B_SquareIsFakeWall = true;
 			goto T0172010_ClosedFakeWall;
 		}
 		aspectArray[k0_ElemAspect] = k1_CorridorElemType;
-		footprintsAllowed = getFlag(square, k0x0008_FakeWallRandOrnOrFootPAllowed) ? 8 : 0;
+		AL0307_uc_FootprintsAllowed = getFlag(AL0307_uc_Square, k0x0008_FakeWallRandOrnOrFootPAllowed) ? 8 : 0;
 	case k1_CorridorElemType:
-		aspectArray[k4_FloorOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(getFlag(square, k0x0008_CorridorRandOrnAllowed),
-																					   _vm->_dungeonMan->_g269_currMap->_randFloorOrnCount, mapX, mapY, 30);
+		aspectArray[k4_FloorOrnOrdAspect] = f170_getRandomOrnOrdinal(getFlag(AL0307_uc_Square, k0x0008_CorridorRandOrnAllowed), _g269_currMap->_randFloorOrnCount, mapX, mapY, 30);
 T0172029_Teleporter:
-		footprintsAllowed = true;
+		AL0307_uc_FootprintsAllowed = true;
 T0172030_Pit:
-		while ((thing != Thing::_endOfList) && ((thingType = (Direction)thing.getType()) <= k3_SensorThingType)) {
-			if (thingType == k3_SensorThingType) {
-				sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(thing);
-				aspectArray[k4_FloorOrnOrdAspect] = sensor->getOrnOrdinal();
+		while ((L0314_T_Thing != Thing::_endOfList) && ((AP0318_i_ThingType = (Direction)L0314_T_Thing.getType()) <= k3_SensorThingType)) {
+			if (AP0318_i_ThingType == k3_SensorThingType) {
+				L0308_ps_Sensor = (Sensor*)f156_getThingData(L0314_T_Thing);
+				aspectArray[k4_FloorOrnOrdAspect] = L0308_ps_Sensor->getOrnOrdinal();
 			}
-			thing = _vm->_dungeonMan->f159_getNextThing(thing);
+			L0314_T_Thing = f159_getNextThing(L0314_T_Thing);
 		}
 		goto T0172049_Footprints;
 	case k5_ElementTypeTeleporter:
-		aspectArray[k2_TeleporterVisibleAspect] = getFlag(square, k0x0008_TeleporterOpen) && getFlag(square, k0x0004_TeleporterVisible);
+		aspectArray[k2_TeleporterVisibleAspect] = getFlag(AL0307_uc_Square, k0x0008_TeleporterOpen) && getFlag(AL0307_uc_Square, k0x0004_TeleporterVisible);
 		goto T0172029_Teleporter;
 	case k3_ElementTypeStairs:
-		aspectArray[k0_ElemAspect] = ((getFlag(square, k0x0008_StairsNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront;
-		aspectArray[k2_StairsUpAspect] = getFlag(square, k0x0004_StairsUp);
-		footprintsAllowed = false;
+		aspectArray[k0_ElemAspect] = (bool((getFlag(AL0307_uc_Square, k0x0008_StairsNorthSouthOrient) >> 3)) == isOrientedWestEast(dir)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront;
+		aspectArray[k2_StairsUpAspect] = getFlag(AL0307_uc_Square, k0x0004_StairsUp);
+		AL0307_uc_FootprintsAllowed = false;
 		goto T0172046_Stairs;
 	case k4_DoorElemType:
-		if ((getFlag(square, k0x0008_DoorNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) {
+		if (bool((getFlag(AL0307_uc_Square, k0x0008_DoorNorthSouthOrient) >> 3)) == isOrientedWestEast(dir)) {
 			aspectArray[k0_ElemAspect] = k16_DoorSideElemType;
 		} else {
 			aspectArray[k0_ElemAspect] = k17_DoorFrontElemType;
-			aspectArray[k2_DoorStateAspect] = Square(square).getDoorState();
-			aspectArray[k3_DoorThingIndexAspect] = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY).getIndex();
+			aspectArray[k2_DoorStateAspect] = Square(AL0307_uc_Square).getDoorState();
+			aspectArray[k3_DoorThingIndexAspect] = f161_getSquareFirstThing(mapX, mapY).getIndex();
 		}
-		footprintsAllowed = true;
+		AL0307_uc_FootprintsAllowed = true;
 T0172046_Stairs:
-		while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) {
-			thing = _vm->_dungeonMan->f159_getNextThing(thing);
+		while ((L0314_T_Thing != Thing::_endOfList) && (L0314_T_Thing.getType() <= k3_SensorThingType)) {
+			L0314_T_Thing = f159_getNextThing(L0314_T_Thing);
 		}
 T0172049_Footprints:
-		if (footprintsAllowed && (scentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapX, mapY))
-			&& (--scentOrdinal >= _vm->_championMan->_g407_party._firstScentIndex)
-			&& (scentOrdinal < _vm->_championMan->_g407_party._lastScentIndex)) {
+		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapX, mapY)) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_g407_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_g407_party._lastScentIndex)) {
 			setFlag(aspectArray[k4_FloorOrnOrdAspect], k0x8000_FootprintsAspect);
 		}
 	}
-	aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16();
+	aspectArray[k1_FirstGroupOrObjectAspect] = L0314_T_Thing.toUint16();
 }
 
 void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir,
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 2103a5e..1824189 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -255,7 +255,7 @@ byte g195_FloorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnament
 	0}; /* Floor Ornament 08 Puddle */
 
 byte g205_WallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets
-										   /* { X1, X2, Y1, Y2, PixelWidth, Height } */
+										 /* { X1, X2, Y1, Y2, ByteWidth, Height } */
 	{{80,  83, 41,  45,  8,   5},     /* D3L */
 	{140, 143, 41,  45,  8,   5},     /* D3R */
 	{16,  29, 39,  50,  8,  12},     /* D3L */
@@ -349,9 +349,9 @@ byte g205_WallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamen
 	{64, 159,  9, 119, 48, 111}},   /* D1C */
 	{{74,  85, 25,  75,  8,  51},     /* D3L */
 	{137, 149, 25,  75,  8,  51},     /* D3R */
-	{0,  75, 25,  75, 40,  51},     /* D3L Atari ST: {   0,  83, 25,  75, 48*2,  51 } */
-	{74, 149, 25,  75, 40,  51},     /* D3C Atari ST: {  74, 149, 25,  75, 48*2,  51 } */
-	{148, 223, 25,  75, 40,  51},     /* D3R Atari ST: { 139, 223, 25,  75, 48*2,  51 } */
+	{0,  75, 25,  75, 40,  51},     /* D3L Atari ST: {   0,  83, 25,  75, 48,  51 } */
+	{74, 149, 25,  75, 40,  51},     /* D3C Atari ST: {  74, 149, 25,  75, 48,  51 } */
+	{148, 223, 25,  75, 40,  51},     /* D3R Atari ST: { 139, 223, 25,  75, 48,  51 } */
 	{60,  77, 20,  90, 16,  71},     /* D2L */
 	{146, 163, 20,  90, 16,  71},     /* D2R */
 	{0,  74, 20,  90, 56,  71},     /* D2L */
@@ -1616,10 +1616,10 @@ void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 													  Frame(118, 135, 28, 67, 24, 41, 24, 0)		/* Right Horizontal Closed three fourth */
 	);
 	int16 order;
-	int16 squareAspect[5];
+	uint16 squareAspect[5];
 
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
@@ -1681,9 +1681,9 @@ void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 	);
 
 	int16 order;
-	int16 squareAspect[5];
+	uint16 squareAspect[5];
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
@@ -1747,10 +1747,10 @@ void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
 	);
 
 	int16 order;
-	int16 squareAspect[5];
+	uint16 squareAspect[5];
 
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
@@ -1815,10 +1815,10 @@ void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 	);
 
 	int16 order;
-	int16 squareAspect[5];
+	uint16 squareAspect[5];
 
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
@@ -1881,10 +1881,10 @@ void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
 	);
 
 	int16 order;
-	int16 squareAspect[5];
+	uint16 squareAspect[5];
 
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
@@ -1948,10 +1948,10 @@ void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {
 	); /* Right Horizontal Closed three fourth */
 
 	int16 order;
-	int16 squareAspect[5];
+	uint16 squareAspect[5];
 
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
@@ -2001,11 +2001,11 @@ T0123021:
 void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 	static Box g107_BoxThievesEyeVisibleArea(0, 95, 0, 94); // @ G0107_s_Graphic558_Box_ThievesEye_VisibleArea 
 	int16 order;
-	int16 squareAspect[5];
+	uint16 squareAspect[5];
 	byte* bitmap;
 
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (_vm->_dungeonMan->_g285_squareAheadElement = (ElementType)squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
@@ -2089,10 +2089,10 @@ void DisplayMan::f125_drawSquareD0L(Direction dir, int16 posX, int16 posY) {
 }
 
 void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
-	int16 squareAspect[5];
+	uint16 squareAspect[5];
 
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k18_ElementTypeStairsSide:
 		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R);
@@ -2118,9 +2118,9 @@ void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
 void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 	static Box g108_BoxThievesEyeHoleInDoorFrame(0, 31, 19, 113); // @ G0108_s_Graphic558_Box_ThievesEye_HoleInDoorFrame 
 
-	int16 squareAspect[5];
+	uint16 squareAspect[5];
 
-	_vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k16_DoorSideElemType:
 		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
@@ -2378,27 +2378,28 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 
 	_g266_currMapViAltarIndex = -1;
 
-	for (uint16 i = 0; i < currMap._wallOrnCount; ++i) {
-		uint16 ornIndice = _g261_currMapWallOrnIndices[i];
-		uint16 nativeIndice = k121_FirstWallOrn + ornIndice * 2;
-
-		_g101_currMapWallOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice;
-		for (uint16 ornCounter = 0; ornCounter < k3_AlcoveOrnCount; ++ornCounter) {
-			if (ornIndice == g192_AlcoveOrnIndices[ornCounter]) {
-				_g267_currMapAlcoveOrnIndices[alcoveCount++] = i;
-				if (ornIndice == 2)
-					_g266_currMapViAltarIndex = i;
+	for (int16 ornamentIndex = 0; ornamentIndex <= currMap._wallOrnCount; ornamentIndex++) {
+		int16 greenOrn = _g261_currMapWallOrnIndices[ornamentIndex];
+		int16 counter = k121_FirstWallOrn + greenOrn * 2; /* Each wall ornament has 2 graphics */
+		_g101_currMapWallOrnInfo[ornamentIndex][k0_NativeBitmapIndex] = counter;
+		for (int16 ornamentCounter = 0; ornamentCounter < k3_AlcoveOrnCount; ornamentCounter++) {
+			if (greenOrn == g192_AlcoveOrnIndices[ornamentCounter]) {
+				_g267_currMapAlcoveOrnIndices[alcoveCount++] = ornamentIndex;
+				if (greenOrn == 2) { /* Wall ornament #2 is the Vi Altar */
+					_g266_currMapViAltarIndex = ornamentIndex;
+				}
 			}
 		}
-
-		for (uint16 ornCounter = 0; ornCounter < k1_FountainOrnCount; ++ornCounter) {
-			if (ornIndice == g193_FountainOrnIndices[ornCounter])
-				_g268_currMapFountainOrnIndices[fountainCount++] = i;
+		for (int16 ornamentCounter = 0; ornamentCounter < k1_FountainOrnCount; ornamentCounter++) {
+			if (greenOrn == g193_FountainOrnIndices[ornamentCounter]) {
+				_g268_currMapFountainOrnIndices[fountainCount++] = ornamentIndex;
+			}
 		}
 
-		_g101_currMapWallOrnInfo[i][k1_CoordinateSet] = g194_WallOrnCoordSetIndices[ornIndice];
+		_g101_currMapWallOrnInfo[ornamentIndex][k1_CoordinateSet] = g194_WallOrnCoordSetIndices[greenOrn];
 	}
 
+
 	for (uint16 i = 0; i < currMap._floorOrnCount; ++i) {
 		uint16 ornIndice = _g262_currMapFloorOrnIndices[i];
 		uint16 nativeIndice = k247_FirstFloorOrn + ornIndice * 6;
@@ -2586,7 +2587,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 			AL0089_i_PixelWidth = (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[1] - (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[0];
 			if (!f491_isDerivedBitmapInCache(AP0116_i_WallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + (AP0116_i_WallOrnamentIndex << 2) + wallOrnDerivedBitmapIndexIncrement[viewWallIndex])) {
 				L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex), AL0091_puc_CoordinateSet[4] << 1, AL0091_puc_CoordinateSet[5], AL0089_i_PixelWidth + 1, AL0090_puc_CoordinateSet[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
+				f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex), AL0091_puc_CoordinateSet[4] << 1, AL0091_puc_CoordinateSet[5], AL0090_puc_CoordinateSet[4] << 1, AL0090_puc_CoordinateSet[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
 				f493_addDerivedBitmap(AP0116_i_WallOrnamentIndex);
 			}
 			AL0091_puc_Bitmap = f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex);
@@ -2623,12 +2624,15 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 		}
 		{
 			Box tmpBox(AL0090_puc_CoordinateSet);
-			f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport, tmpBox, AL0089_i_X, 0, AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport);
+			f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport, tmpBox,
+							  AL0089_i_X, 0,
+							  AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport);
 		}
 
 		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { 
 			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), _g296_bitmapViewport, boxChampionPortraitOnWall,
-				(_g289_championPortraitOrdinal & 0x0007) << 5, (_g289_championPortraitOrdinal >> 3) * 29, k128_byteWidth, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); /* A portrait is 32x29 pixels */
+				(_g289_championPortraitOrdinal & 0x0007) << 5, (_g289_championPortraitOrdinal >> 3) * 29,
+							  k128_byteWidth, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); /* A portrait is 32x29 pixels */
 		}
 T0107031:
 		return L0096_B_IsAlcove;
@@ -2646,18 +2650,17 @@ void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *des
 
 	warning(false, "MISSING CODE: No palette change takes place in f129_blitToBitmapShrinkWithPalChange");
 
-	// HACK
 	if (destPixelWidth % 2)
 		destPixelWidth++;
 
 	// Loop through drawing output lines
-	for (uint32 destY = 0, scaleYCtr = 0; destY < destHeight; ++destY, scaleYCtr += scaleY) {
+	for (uint32 destY = 0, scaleYCtr = 0; destY < (uint32)destHeight; ++destY, scaleYCtr += scaleY) {
 
 		const byte *srcLine = &srcBitmap[(scaleYCtr / SCALE_THRESHOLD) * srcPixelWidth];
 		byte *destLine = &destBitmap[destY * destPixelWidth];
 
 		// Loop through drawing the pixels of the row
-		for (uint32 destX = 0, xCtr = 0, scaleXCtr = 0; destX < destPixelWidth; ++destX, ++xCtr, scaleXCtr += scaleX) {
+		for (uint32 destX = 0, xCtr = 0, scaleXCtr = 0; destX < (uint32)destPixelWidth; ++destX, ++xCtr, scaleXCtr += scaleX) {
 			destLine[xCtr] = srcLine[scaleXCtr / SCALE_THRESHOLD];
 		}
 	}


Commit: 9cd5732b039c0b2ff34e10a898739cebb478263c
    https://github.com/scummvm/scummvm/commit/9cd5732b039c0b2ff34e10a898739cebb478263c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Improve upon blitShrink

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 1824189..b2cf89a 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1035,7 +1035,8 @@ void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButt
 				byte *bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
 				f129_blitToBitmapShrinkWithPalChange(bitmapNative, f492_getDerivedBitmap(doorButtonOrdinal),
 													 coordSetBlueGoat[4] << 1, coordSetBlueGoat[5],
-													 coordSetRedEagle[1] - coordSetRedEagle[0] + 1,
+													 // modified code line
+													 coordSetRedEagle[4] << 1,
 													 coordSetRedEagle[5],
 													 (viewDoorButtonIndex == k2_viewDoorButton_D2C) ? g199_PalChangesDoorButtonAndWallOrn_D2 : g198_PalChangesDoorButtonAndWallOrn_D3);
 
@@ -2644,15 +2645,15 @@ T0107031:
 void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
 													  int16 srcPixelWidth, int16 srcHeight,
 													  int16 destPixelWidth, int16 destHeight, byte *palChange) {
+	if (destPixelWidth % 8)
+		destPixelWidth = (destPixelWidth / 8) * 8 + 8;
+
 	const uint32 SCALE_THRESHOLD = 32768;
 	uint32 scaleX = (SCALE_THRESHOLD * srcPixelWidth) / destPixelWidth;
 	uint32 scaleY = (SCALE_THRESHOLD * srcHeight) / destHeight;
 
 	warning(false, "MISSING CODE: No palette change takes place in f129_blitToBitmapShrinkWithPalChange");
 
-	if (destPixelWidth % 2)
-		destPixelWidth++;
-
 	// Loop through drawing output lines
 	for (uint32 destY = 0, scaleYCtr = 0; destY < (uint32)destHeight; ++destY, scaleYCtr += scaleY) {
 


Commit: da7c739d71eaf570a345611e9e8f65fbf45ce60c
    https://github.com/scummvm/scummvm/commit/da7c739d71eaf570a345611e9e8f65fbf45ce60c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix cursor data decoding

Changed paths:
    engines/dm/eventman.cpp
    engines/dm/eventman.h



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 2c95049..3ecba11 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -41,44 +41,44 @@
 
 
 namespace DM {
-byte g42_bitmapArrowPointer[576] = { // @ G0042_auc_Graphic562_Bitmap_ArrowPointer
-	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x7, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x7, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x6, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x8, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x3, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xA, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0xC, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x0, 0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
-byte g43_bitmapHanPointer[576] = { // @ G0043_auc_Graphic562_Bitmap_HandPointer
-	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x3, 0x5, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xA, 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xD, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE, 0xA, 0x8, 0x0, 0x0, 0x0, 0x0,
-	0x0, 0x7, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0xC, 0x7, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x6, 0x7, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x7, 0x7, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0,
-	0x3, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x3, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x1, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0,
-	0x0, 0x1, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0xA, 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x5, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x1, 0x2, 0xA, 0x8, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x5, 0x4, 0x0, 0x0, 0x0, 0x0, 0xC, 0x8, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x2, 0x8, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0,
-	0x9, 0x8, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x8, 0x8, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0,
-	0x2, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-	0x7, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xF, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0x1, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0,
-	0xC, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0xE, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0,
-	0x7, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x3, 0xF, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x1, 0xF, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0,
-	0x0, 0x7, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
+unsigned char g42_bitmapArrowPointer[288] = { // @ G0042_auc_Graphic562_Bitmap_ArrowPointer
+	0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+	0x78, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00,
+	0x7F, 0x80, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00,
+	0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+	0x60, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00,
+	0x7E, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00,
+	0x6C, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+	0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0xC0, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00,
+	0x84, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
+	0x80, 0x40, 0x00, 0x00, 0x83, 0xC0, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0xA9, 0x00, 0x00, 0x00,
+	0xC9, 0x00, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00,
+	0xF0, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00,
+	0xFF, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00,
+	0xFE, 0x00, 0x00, 0x00, 0xEF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00,
+	0x07, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+unsigned char g43_bitmapHanPointer[288] = { // @ G0043_auc_Graphic562_Bitmap_HandPointer
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x6A, 0x00, 0x00, 0x00,
+	0x35, 0x40, 0x00, 0x00, 0x1A, 0xA0, 0x00, 0x00, 0x0D, 0x50, 0x00, 0x00, 0x0E, 0xA8, 0x00, 0x00,
+	0x07, 0xF8, 0x00, 0x00, 0xC7, 0xFC, 0x00, 0x00, 0x67, 0xFC, 0x00, 0x00, 0x77, 0xFC, 0x00, 0x00,
+	0x3F, 0xFC, 0x00, 0x00, 0x3F, 0xFC, 0x00, 0x00, 0x1F, 0xFE, 0x00, 0x00, 0x07, 0xFF, 0x00, 0x00,
+	0x01, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x20, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x4A, 0xA0, 0x00, 0x00, 0x25, 0x50, 0x00, 0x00,
+	0x12, 0xA8, 0x00, 0x00, 0x11, 0x54, 0x00, 0x00, 0xC8, 0x04, 0x00, 0x00, 0x28, 0x02, 0x00, 0x00,
+	0x98, 0x02, 0x00, 0x00, 0x88, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00,
+	0x20, 0x01, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
+	0x7F, 0xE0, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x1F, 0xFC, 0x00, 0x00,
+	0xCF, 0xFC, 0x00, 0x00, 0xEF, 0xFE, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00,
+	0x7F, 0xFE, 0x00, 0x00, 0x7F, 0xFE, 0x00, 0x00, 0x3F, 0xFF, 0x00, 0x00, 0x1F, 0xFF, 0x00, 0x00,
+	0x07, 0xFF, 0x00, 0x00, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
 
 Box g462_BoxObjectPiles[4] = { // @ G0462_as_Graphic561_Box_ObjectPiles
 	/* { X1, X2, Y1, Y2 } */
@@ -495,7 +495,7 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY)
 		_vm->_eventMan->_g598_mousePointerBitmapUpdated = false;
 		switch (_gK104_mousePointerType) {
 		case k0_pointerTypeArrow:
-			CursorMan.replaceCursor(g42_bitmapArrowPointer, 32, 18, 0, 0, 0);
+			setMousePointerFromSpriteData(g42_bitmapArrowPointer);
 			break;
 		case k1_pointerTypeObjectIcon:
 			CursorMan.replaceCursor(_g615_mousePointerOriginalColorsObject, 32, 18, 0, 0, 0);
@@ -504,7 +504,7 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY)
 			CursorMan.replaceCursor(_g613_mousePointerOriginalColorsChampionIcon, 32, 18, 0, 0, 0);
 			break;
 		case k3_pointerTypeHand:
-			CursorMan.replaceCursor(g43_bitmapHanPointer, 32, 18, 0, 0, 0);
+			setMousePointerFromSpriteData(g43_bitmapHanPointer);
 			break;
 		}
 	}
@@ -990,7 +990,21 @@ bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int
 	return L1149_B_ObjectThrown;
 }
 
+void EventManager::setMousePointerFromSpriteData(byte* mouseSprite) {
+	byte bitmap[16 * 18];
+	memset(bitmap, 0, 16 * 18);
+	for (int16 imgPart = 0; imgPart < 4; ++imgPart) {
+		for (byte *line = mouseSprite + 72 * imgPart, *pixel = bitmap; line < mouseSprite + 72 * (imgPart + 1); line += 4) {
+			uint16 words[2];
+			words[0] = READ_BE_UINT16(line);
+			words[1] = READ_BE_UINT16(line + 2);
+			for (int16 i = 15; i >= 0; --i)
+				*pixel++ = ((words[0] >> i) & 1) | (((words[1] >> i) & 1) << 1);
+		}
+	}
 
+	CursorMan.replaceCursor(bitmap, 16, 32, 0, 0, 0);
+}
 
 void EventManager::f368_commandSetLeader(ChampionIndex champIndex) {
 	ChampionMan &cm = *_vm->_championMan;
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index d04b1c7..891b0e4 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -258,6 +258,7 @@ class EventManager {
 	void f365_commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty
 	void f366_commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty
 	bool f375_processType80_clickDungeonView_isLeaderHandObjThrown(int16 posX, int16 posY); // @ F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown
+	void setMousePointerFromSpriteData(byte* mouseSprite); 
 
 public:
 	explicit EventManager(DMEngine *vm);


Commit: 15918a00cba74c470375e9c1cf52ebb7e575fce1
    https://github.com/scummvm/scummvm/commit/15918a00cba74c470375e9c1cf52ebb7e575fce1
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some refactoring in dungeonman.cpp

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 61b222c..e447868 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -418,9 +418,9 @@ DungeonMan::~DungeonMan() {
 	delete[] _g283_squareFirstThings;
 	delete[] _g260_dungeonTextData;
 	delete[] _g279_dungeonMapData;
-	for (uint16 i = 0; i < 16; ++i) {
+	for (uint16 i = 0; i < 16; ++i)
 		delete[] _g284_thingData[i];
-	}
+
 	delete[] _g276_dungeonRawMapData;
 }
 
@@ -481,25 +481,6 @@ void DungeonMan::f455_decompressDungeonFile() {
 	f.close();
 }
 
-byte g236_AdditionalThingCounts[16] = { // @ G0236_auc_Graphic559_AdditionalThingCounts{
-	0,    /* Door */
-	0,    /* Teleporter */
-	0,    /* Text String */
-	0,    /* Sensor */
-	75,   /* Group */
-	100,  /* Weapon */
-	120,  /* Armour */
-	0,    /* Scroll */
-	5,    /* Potion */
-	0,    /* Container */
-	140,  /* Junk */
-	0,    /* Unused */
-	0,    /* Unused */
-	0,    /* Unused */
-	60,   /* Projectile */
-	50    /* Explosion */
-};
-
 // this is the number of uint16s the data has to be stored, not the length of the data in dungeon.dat!
 byte g235_ThingDataWordCount[16] = { // @ G0235_auc_Graphic559_ThingDataByteCount
 	2,   /* Door */
@@ -537,13 +518,34 @@ const Thing Thing::_explRebirthStep2(0xFFE5); // @ C0xFFE5_THING_EXPLOSION_REBIR
 const Thing Thing::_party(0xFFFF); // @ C0xFFFF_THING_PARTY          
 
 void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
+	static const byte additionalThingCounts[16] = { // @ G0236_auc_Graphic559_AdditionalThingCounts{
+		0,    /* Door */
+		0,    /* Teleporter */
+		0,    /* Text String */
+		0,    /* Sensor */
+		75,   /* Group */
+		100,  /* Weapon */
+		120,  /* Armour */
+		0,    /* Scroll */
+		5,    /* Potion */
+		0,    /* Container */
+		140,  /* Junk */
+		0,    /* Unused */
+		0,    /* Unused */
+		0,    /* Unused */
+		60,   /* Projectile */
+		50    /* Explosion */
+	};
+
 	if (_vm->_g298_newGame)
 		f455_decompressDungeonFile();
 
 	Common::ReadStream *dunDataStream = nullptr;
-	if (file) { // if loading a save 
+	if (file) {
+		// if loading a save 
 		dunDataStream = file;
-	} else { // else read dungeon.dat
+	} else {
+		// else read dungeon.dat
 		assert(_rawDunFileData && _rawDunFileDataSize);
 		dunDataStream = new Common::MemoryReadStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO);
 	}
@@ -656,7 +658,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 	for (uint16 thingType = k0_DoorThingType; thingType < k16_ThingTypeTotal; ++thingType) {
 		uint16 thingCount = _g278_dungeonFileHeader._thingCounts[thingType];
 		if (_vm->_g298_newGame)
-			_g278_dungeonFileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + g236_AdditionalThingCounts[thingType]);
+			_g278_dungeonFileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + additionalThingCounts[thingType]);
 
 		uint16 thingStoreWordCount = g235_ThingDataWordCount[thingType];
 
@@ -690,7 +692,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 			if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType)
 				_vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType];
 
-			for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i)
+			for (uint16 i = 0; i < additionalThingCounts[thingType]; ++i)
 				(_g284_thingData[thingType] + (thingCount + i) * thingStoreWordCount)[0] = Thing::_none.toUint16();
 		}
 	}
@@ -731,7 +733,8 @@ void DungeonMan::f173_setCurrentMap(uint16 mapIndex) {
 		DoorInfo(3, 110),   /* Door type 0 Portcullis */
 		DoorInfo(0,  42),   /* Door type 1 Wooden door */
 		DoorInfo(0, 230),   /* Door type 2 Iron door */
-		DoorInfo(5, 255)}; /* Door type 3 Ra door */
+		DoorInfo(5, 255)    /* Door type 3 Ra door */
+	};
 
 	if (_g272_currMapIndex == mapIndex)
 		return;
@@ -799,23 +802,17 @@ Square DungeonMan::f152_getRelSquare(Direction dir, int16 stepsForward, int16 st
 }
 
 int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) {
-	uint16 L0260_ui_ThingIndex;
-	int16 L0261_i_MapY;
-	unsigned char* L0262_puc_Square;
-
-
-	L0262_puc_Square = _vm->_dungeonMan->_g271_currMapData[mapX];
-	if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight) || !getFlag(L0262_puc_Square[mapY], k0x0010_ThingListPresent)) {
+	unsigned char *curSquare = _vm->_dungeonMan->_g271_currMapData[mapX];
+	if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight) || !getFlag(curSquare[mapY], k0x0010_ThingListPresent))
 		return -1;
+
+	int16 curMapY = 0;
+	uint16 thingIndex = _vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount[mapX];
+	while (curMapY++ != mapY) {
+		if (getFlag(*curSquare++, k0x0010_ThingListPresent))
+			thingIndex++;
 	}
-	L0261_i_MapY = 0;
-	L0260_ui_ThingIndex = _vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount[mapX];
-	while (L0261_i_MapY++ != mapY) {
-		if (getFlag(*L0262_puc_Square++, k0x0010_ThingListPresent)) {
-			L0260_ui_ThingIndex++;
-		}
-	}
-	return L0260_ui_ThingIndex;
+	return thingIndex;
 }
 
 Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) {
@@ -825,7 +822,6 @@ Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) {
 	return _g283_squareFirstThings[index];
 }
 
-
 // TODO: produce more GOTOs
 void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX, int16 mapY) {	
 #define AP0318_i_ThingType dir
@@ -962,40 +958,37 @@ T0172049_Footprints:
 
 void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir,
 												 int16 mapX, int16 mapY, bool isFakeWall) {
-	int16 L0306_i_Multiple;
-#define AL0306_i_RandomWallOrnamentCount L0306_i_Multiple
-#define AL0306_i_SideIndex               L0306_i_Multiple
-
 
-	AL0306_i_RandomWallOrnamentCount = _vm->_dungeonMan->_g269_currMap->_randWallOrnCount;
-	aspectArray[k2_RightWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(leftAllowed, AL0306_i_RandomWallOrnamentCount, mapX, ++mapY * (M21_normalizeModulo4(++dir) + 1), 30);
-	aspectArray[k3_FrontWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(frontAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY * (M21_normalizeModulo4(++dir) + 1), 30);
-	aspectArray[k4_LeftWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(rightAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY-- * (M21_normalizeModulo4(++dir) + 1), 30);
+	int16 randomWallOrnamentCount = _vm->_dungeonMan->_g269_currMap->_randWallOrnCount;
+	aspectArray[k2_RightWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(leftAllowed, randomWallOrnamentCount, mapX, ++mapY * (M21_normalizeModulo4(++dir) + 1), 30);
+	aspectArray[k3_FrontWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(frontAllowed, randomWallOrnamentCount, mapX, mapY * (M21_normalizeModulo4(++dir) + 1), 30);
+	aspectArray[k4_LeftWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(rightAllowed, randomWallOrnamentCount, mapX, mapY-- * (M21_normalizeModulo4(++dir) + 1), 30);
 	if (isFakeWall || (mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight)) { /* If square is a fake wall or is out of map bounds */
-		for (AL0306_i_SideIndex = k2_RightWallOrnOrdAspect; AL0306_i_SideIndex <= k4_LeftWallOrnOrdAspect; AL0306_i_SideIndex++) { /* Loop to remove any random ornament that is an alcove */
-			if (_vm->_dungeonMan->f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[AL0306_i_SideIndex]))) {
-				aspectArray[AL0306_i_SideIndex] = 0;
-			}
+		for (int16 sideIndex = k2_RightWallOrnOrdAspect; sideIndex <= k4_LeftWallOrnOrdAspect; sideIndex++) { /* Loop to remove any random ornament that is an alcove */
+			if (_vm->_dungeonMan->f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[sideIndex])))
+				aspectArray[sideIndex] = 0;
 		}
 	}
 }
 
 int16 DungeonMan::f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) {
-	int16 L0305_i_RandomOrnamentIndex;
+	int16 randomOrnamentIndex = f169_getRandomOrnamentIndex((int16)2000 + (mapX << 5) + mapY, (int16)3000 + (_vm->_dungeonMan->_g272_currMapIndex << (int16)6) + _vm->_dungeonMan->_g273_currMapWidth + _vm->_dungeonMan->_g274_currMapHeight, modulo);
 
+	if (allowed && (randomOrnamentIndex < count))
+		return _vm->M0_indexToOrdinal(randomOrnamentIndex);
 
-	if (allowed && ((L0305_i_RandomOrnamentIndex = f169_getRandomOrnamentIndex((int16)2000 + (mapX << 5) + mapY, (int16)3000 + (_vm->_dungeonMan->_g272_currMapIndex << (int16)6) + _vm->_dungeonMan->_g273_currMapWidth + _vm->_dungeonMan->_g274_currMapHeight, modulo)) < count)) {
-		return _vm->M0_indexToOrdinal(L0305_i_RandomOrnamentIndex);
-	}
 	return 0;
 }
 
 
 bool DungeonMan::f149_isWallOrnAnAlcove(int16 wallOrnIndex) {
-	if (wallOrnIndex >= 0)
-		for (uint16 i = 0; i < k3_AlcoveOrnCount; ++i)
+	if (wallOrnIndex >= 0) {
+		for (uint16 i = 0; i < k3_AlcoveOrnCount; ++i) {
 			if (_vm->_displayMan->_g267_currMapAlcoveOrnIndices[i] == wallOrnIndex)
 				return true;
+		}
+	}
+
 	return false;
 }
 


Commit: 5ff8c3d92df0dd3152d537f1fb7eb0de74937d53
    https://github.com/scummvm/scummvm/commit/5ff8c3d92df0dd3152d537f1fb7eb0de74937d53
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: First pass of refactoring in f161_getSquareFirstThing

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index e447868..7347fe3 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -824,74 +824,71 @@ Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) {
 
 // TODO: produce more GOTOs
 void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX, int16 mapY) {	
-#define AP0318_i_ThingType dir
 	unsigned char L0307_uc_Multiple;
 #define AL0307_uc_Square            L0307_uc_Multiple
 #define AL0307_uc_FootprintsAllowed L0307_uc_Multiple
 #define AL0307_uc_ScentOrdinal      L0307_uc_Multiple
-	Sensor* L0308_ps_Sensor;
-	bool L0309_B_LeftRandomWallOrnamentAllowed = 0;
-	int16 L0310_i_Multiple = 0;
-#define AL0310_B_FrontRandomWallOrnamentAllowed L0310_i_Multiple
-#define AL0310_i_SideIndex                      L0310_i_Multiple
-	bool L0311_B_RightRandomWallOrnamentAllowed = 0;
-	int16 L0312_i_ThingType;
-	bool L0313_B_SquareIsFakeWall;
-	Thing L0314_T_Thing;
-
 
 	for (uint16 i = 0; i < 5; ++i)
 		aspectArray[i] = 0;
-	L0314_T_Thing = f161_getSquareFirstThing(mapX, mapY);
+
+	Thing curThing = f161_getSquareFirstThing(mapX, mapY);
 	AL0307_uc_Square = f151_getSquare(mapX, mapY).toByte();
+	bool leftRandomWallOrnamentAllowed = false;
+	bool rightRandomWallOrnamentAllowed = false;
+	bool frontRandomWallOrnamentAllowed = false;
+	bool squareIsFakeWall;
+
 	switch (aspectArray[k0_ElemAspect] = Square(AL0307_uc_Square).getType()) {
 	case k0_ElementTypeWall:
 		switch (dir) {
 		case kDirNorth:
-			L0309_B_LeftRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0004_WallEastRandOrnAllowed);
-			AL0310_B_FrontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0002_WallSouthRandOrnAllowed);
-			L0311_B_RightRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0001_WallWestRandOrnAllowed);
+			leftRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0004_WallEastRandOrnAllowed);
+			frontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0002_WallSouthRandOrnAllowed);
+			rightRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0001_WallWestRandOrnAllowed);
 			break;
 		case kDirEast:
-			L0309_B_LeftRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0002_WallSouthRandOrnAllowed);
-			AL0310_B_FrontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0001_WallWestRandOrnAllowed);
-			L0311_B_RightRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0008_WallNorthRandOrnAllowed);
+			leftRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0002_WallSouthRandOrnAllowed);
+			frontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0001_WallWestRandOrnAllowed);
+			rightRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0008_WallNorthRandOrnAllowed);
 			break;
 		case kDirSouth:
-			L0309_B_LeftRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0001_WallWestRandOrnAllowed);
-			AL0310_B_FrontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0008_WallNorthRandOrnAllowed);
-			L0311_B_RightRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0004_WallEastRandOrnAllowed);
+			leftRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0001_WallWestRandOrnAllowed);
+			frontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0008_WallNorthRandOrnAllowed);
+			rightRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0004_WallEastRandOrnAllowed);
 			break;
 		case kDirWest:
-			L0309_B_LeftRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0008_WallNorthRandOrnAllowed);
-			AL0310_B_FrontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0004_WallEastRandOrnAllowed);
-			L0311_B_RightRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0002_WallSouthRandOrnAllowed);
+			leftRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0008_WallNorthRandOrnAllowed);
+			frontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0004_WallEastRandOrnAllowed);
+			rightRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0002_WallSouthRandOrnAllowed);
 			break;
 		default:
 			assert(false);
 		}
 		_vm->_displayMan->_g289_championPortraitOrdinal = 0; 
-		L0313_B_SquareIsFakeWall = false;
+		squareIsFakeWall = false;
 T0172010_ClosedFakeWall:
-		f171_setSquareAspectOrnOrdinals(aspectArray, L0309_B_LeftRandomWallOrnamentAllowed, AL0310_B_FrontRandomWallOrnamentAllowed, L0311_B_RightRandomWallOrnamentAllowed, dir, mapX, mapY, L0313_B_SquareIsFakeWall);
-		while ((L0314_T_Thing != Thing::_endOfList) && ((L0312_i_ThingType = L0314_T_Thing.getType()) <= k3_SensorThingType)) {
-			if (AL0310_i_SideIndex = M21_normalizeModulo4(L0314_T_Thing.getCell() - dir)) { /* Invisible on the back wall if 0 */
-				L0308_ps_Sensor = (Sensor*)f156_getThingData(L0314_T_Thing);
-				if (L0312_i_ThingType == k2_TextstringType) {
-					if (((TextString*)L0308_ps_Sensor)->isVisible()) {
+		f171_setSquareAspectOrnOrdinals(aspectArray, leftRandomWallOrnamentAllowed, frontRandomWallOrnamentAllowed, rightRandomWallOrnamentAllowed, dir, mapX, mapY, squareIsFakeWall);
+		while ((curThing != Thing::_endOfList) && (curThing.getType() <= k3_SensorThingType)) {
+			ThingType curThingType = curThing.getType();
+			int16 AL0310_i_SideIndex = M21_normalizeModulo4(curThing.getCell() - dir);
+			if (AL0310_i_SideIndex) { /* Invisible on the back wall if 0 */
+				Sensor *curSensor = (Sensor*)f156_getThingData(curThing);
+				if (curThingType == k2_TextstringType) {
+					if (((TextString*)curSensor)->isVisible()) {
 						aspectArray[AL0310_i_SideIndex + 1] = _g265_currMapInscriptionWallOrnIndex + 1;
-						_vm->_displayMan->_g290_inscriptionThing = L0314_T_Thing; /* BUG0_76 The same text is drawn on multiple sides of a wall square. The engine stores only a single text to draw on a wall in a global variable. Even if different texts are placed on differents sides of the wall, the same text is drawn on each affected side */
+						_vm->_displayMan->_g290_inscriptionThing = curThing; /* BUG0_76 The same text is drawn on multiple sides of a wall square. The engine stores only a single text to draw on a wall in a global variable. Even if different texts are placed on different sides of the wall, the same text is drawn on each affected side */
 					}
 				} else {
-					aspectArray[AL0310_i_SideIndex + 1] = L0308_ps_Sensor->getOrnOrdinal();
-					if (L0308_ps_Sensor->getType() == k127_SensorWallChampionPortrait) {
-						_vm->_displayMan->_g289_championPortraitOrdinal = _vm->M0_indexToOrdinal(L0308_ps_Sensor->getData());
+					aspectArray[AL0310_i_SideIndex + 1] = curSensor->getOrnOrdinal();
+					if (curSensor->getType() == k127_SensorWallChampionPortrait) {
+						_vm->_displayMan->_g289_championPortraitOrdinal = _vm->M0_indexToOrdinal(curSensor->getData());
 					}
 				}
 			}
-			L0314_T_Thing = f159_getNextThing(L0314_T_Thing);
+			curThing = f159_getNextThing(curThing);
 		}
-		if (L0313_B_SquareIsFakeWall && (_g306_partyMapX != mapX) && (_g307_partyMapY != mapY)) {
+		if (squareIsFakeWall && (_g306_partyMapX != mapX) && (_g307_partyMapY != mapY)) {
 			aspectArray[k1_FirstGroupOrObjectAspect] = Thing::_endOfList.toUint16();
 			return;
 		}
@@ -908,8 +905,8 @@ T0172010_ClosedFakeWall:
 	case k6_ElementTypeFakeWall:
 		if (!getFlag(AL0307_uc_Square, k0x0004_FakeWallOpen)) {
 			aspectArray[k0_ElemAspect] = k0_ElementTypeWall;
-			L0309_B_LeftRandomWallOrnamentAllowed = L0311_B_RightRandomWallOrnamentAllowed = AL0310_B_FrontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0008_FakeWallRandOrnOrFootPAllowed);
-			L0313_B_SquareIsFakeWall = true;
+			leftRandomWallOrnamentAllowed = rightRandomWallOrnamentAllowed = frontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0008_FakeWallRandOrnOrFootPAllowed);
+			squareIsFakeWall = true;
 			goto T0172010_ClosedFakeWall;
 		}
 		aspectArray[k0_ElemAspect] = k1_CorridorElemType;
@@ -919,12 +916,12 @@ T0172010_ClosedFakeWall:
 T0172029_Teleporter:
 		AL0307_uc_FootprintsAllowed = true;
 T0172030_Pit:
-		while ((L0314_T_Thing != Thing::_endOfList) && ((AP0318_i_ThingType = (Direction)L0314_T_Thing.getType()) <= k3_SensorThingType)) {
-			if (AP0318_i_ThingType == k3_SensorThingType) {
-				L0308_ps_Sensor = (Sensor*)f156_getThingData(L0314_T_Thing);
-				aspectArray[k4_FloorOrnOrdAspect] = L0308_ps_Sensor->getOrnOrdinal();
+		while ((curThing != Thing::_endOfList) && ((Direction)curThing.getType() <= k3_SensorThingType)) {
+			if (curThing.getType() == k3_SensorThingType) {
+				Sensor *curSensor = (Sensor*)f156_getThingData(curThing);
+				aspectArray[k4_FloorOrnOrdAspect] = curSensor->getOrnOrdinal();
 			}
-			L0314_T_Thing = f159_getNextThing(L0314_T_Thing);
+			curThing = f159_getNextThing(curThing);
 		}
 		goto T0172049_Footprints;
 	case k5_ElementTypeTeleporter:
@@ -945,15 +942,15 @@ T0172030_Pit:
 		}
 		AL0307_uc_FootprintsAllowed = true;
 T0172046_Stairs:
-		while ((L0314_T_Thing != Thing::_endOfList) && (L0314_T_Thing.getType() <= k3_SensorThingType)) {
-			L0314_T_Thing = f159_getNextThing(L0314_T_Thing);
+		while ((curThing != Thing::_endOfList) && (curThing.getType() <= k3_SensorThingType)) {
+			curThing = f159_getNextThing(curThing);
 		}
 T0172049_Footprints:
 		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapX, mapY)) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_g407_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_g407_party._lastScentIndex)) {
 			setFlag(aspectArray[k4_FloorOrnOrdAspect], k0x8000_FootprintsAspect);
 		}
 	}
-	aspectArray[k1_FirstGroupOrObjectAspect] = L0314_T_Thing.toUint16();
+	aspectArray[k1_FirstGroupOrObjectAspect] = curThing.toUint16();
 }
 
 void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir,


Commit: af5e50a837d344d6420338c66315c43d5313e654
    https://github.com/scummvm/scummvm/commit/af5e50a837d344d6420338c66315c43d5313e654
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove some GOTOs in f172_setSquareAspect

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 7347fe3..057e04c 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -839,7 +839,8 @@ void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, Direction dir, int16
 	bool frontRandomWallOrnamentAllowed = false;
 	bool squareIsFakeWall;
 
-	switch (aspectArray[k0_ElemAspect] = Square(AL0307_uc_Square).getType()) {
+	aspectArray[k0_ElemAspect] = Square(AL0307_uc_Square).getType();
+	switch (aspectArray[k0_ElemAspect]) {
 	case k0_ElementTypeWall:
 		switch (dir) {
 		case kDirNorth:
@@ -893,15 +894,6 @@ T0172010_ClosedFakeWall:
 			return;
 		}
 		break;
-	case k2_ElementTypePit:
-		if (getFlag(AL0307_uc_Square, k0x0008_PitOpen)) {
-			aspectArray[k2_PitInvisibleAspect] = getFlag(AL0307_uc_Square, k0x0004_PitInvisible);
-			AL0307_uc_FootprintsAllowed &= 0x0001;
-		} else {
-			aspectArray[k0_ElemAspect] = k1_CorridorElemType;
-			AL0307_uc_FootprintsAllowed = true;
-		}
-		goto T0172030_Pit;
 	case k6_ElementTypeFakeWall:
 		if (!getFlag(AL0307_uc_Square, k0x0004_FakeWallOpen)) {
 			aspectArray[k0_ElemAspect] = k0_ElementTypeWall;
@@ -912,10 +904,24 @@ T0172010_ClosedFakeWall:
 		aspectArray[k0_ElemAspect] = k1_CorridorElemType;
 		AL0307_uc_FootprintsAllowed = getFlag(AL0307_uc_Square, k0x0008_FakeWallRandOrnOrFootPAllowed) ? 8 : 0;
 	case k1_CorridorElemType:
-		aspectArray[k4_FloorOrnOrdAspect] = f170_getRandomOrnOrdinal(getFlag(AL0307_uc_Square, k0x0008_CorridorRandOrnAllowed), _g269_currMap->_randFloorOrnCount, mapX, mapY, 30);
-T0172029_Teleporter:
-		AL0307_uc_FootprintsAllowed = true;
-T0172030_Pit:
+	case k2_ElementTypePit:
+	case k5_ElementTypeTeleporter:
+		if (aspectArray[k0_ElemAspect] == k1_CorridorElemType) {
+			aspectArray[k4_FloorOrnOrdAspect] = f170_getRandomOrnOrdinal(getFlag(AL0307_uc_Square, k0x0008_CorridorRandOrnAllowed), _g269_currMap->_randFloorOrnCount, mapX, mapY, 30);
+			AL0307_uc_FootprintsAllowed = true;
+		} else if (aspectArray[k0_ElemAspect] == k2_ElementTypePit) {
+			if (getFlag(AL0307_uc_Square, k0x0008_PitOpen)) {
+				aspectArray[k2_PitInvisibleAspect] = getFlag(AL0307_uc_Square, k0x0004_PitInvisible);
+				AL0307_uc_FootprintsAllowed &= 0x0001;
+			} else {
+				aspectArray[k0_ElemAspect] = k1_CorridorElemType;
+				AL0307_uc_FootprintsAllowed = true;
+			}
+		} else { // k5_ElementTypeTeleporter
+			aspectArray[k2_TeleporterVisibleAspect] = getFlag(AL0307_uc_Square, k0x0008_TeleporterOpen) && getFlag(AL0307_uc_Square, k0x0004_TeleporterVisible);
+			AL0307_uc_FootprintsAllowed = true;
+		}
+
 		while ((curThing != Thing::_endOfList) && ((Direction)curThing.getType() <= k3_SensorThingType)) {
 			if (curThing.getType() == k3_SensorThingType) {
 				Sensor *curSensor = (Sensor*)f156_getThingData(curThing);
@@ -924,9 +930,6 @@ T0172030_Pit:
 			curThing = f159_getNextThing(curThing);
 		}
 		goto T0172049_Footprints;
-	case k5_ElementTypeTeleporter:
-		aspectArray[k2_TeleporterVisibleAspect] = getFlag(AL0307_uc_Square, k0x0008_TeleporterOpen) && getFlag(AL0307_uc_Square, k0x0004_TeleporterVisible);
-		goto T0172029_Teleporter;
 	case k3_ElementTypeStairs:
 		aspectArray[k0_ElemAspect] = (bool((getFlag(AL0307_uc_Square, k0x0008_StairsNorthSouthOrient) >> 3)) == isOrientedWestEast(dir)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront;
 		aspectArray[k2_StairsUpAspect] = getFlag(AL0307_uc_Square, k0x0004_StairsUp);


Commit: 6122e199fe6c952661ab7a6884963991094b6bcc
    https://github.com/scummvm/scummvm/commit/6122e199fe6c952661ab7a6884963991094b6bcc
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: remove some more GOTOs in f172_setSquareAspect

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 057e04c..dd70813 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -822,7 +822,6 @@ Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) {
 	return _g283_squareFirstThings[index];
 }
 
-// TODO: produce more GOTOs
 void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX, int16 mapY) {	
 	unsigned char L0307_uc_Multiple;
 #define AL0307_uc_Square            L0307_uc_Multiple
@@ -903,6 +902,7 @@ T0172010_ClosedFakeWall:
 		}
 		aspectArray[k0_ElemAspect] = k1_CorridorElemType;
 		AL0307_uc_FootprintsAllowed = getFlag(AL0307_uc_Square, k0x0008_FakeWallRandOrnOrFootPAllowed) ? 8 : 0;
+		// No break on purpose
 	case k1_CorridorElemType:
 	case k2_ElementTypePit:
 	case k5_ElementTypeTeleporter:
@@ -929,12 +929,18 @@ T0172010_ClosedFakeWall:
 			}
 			curThing = f159_getNextThing(curThing);
 		}
-		goto T0172049_Footprints;
+
+		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapX, mapY)) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_g407_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_g407_party._lastScentIndex))
+			setFlag(aspectArray[k4_FloorOrnOrdAspect], k0x8000_FootprintsAspect);
+
+		break;
 	case k3_ElementTypeStairs:
 		aspectArray[k0_ElemAspect] = (bool((getFlag(AL0307_uc_Square, k0x0008_StairsNorthSouthOrient) >> 3)) == isOrientedWestEast(dir)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront;
 		aspectArray[k2_StairsUpAspect] = getFlag(AL0307_uc_Square, k0x0004_StairsUp);
 		AL0307_uc_FootprintsAllowed = false;
-		goto T0172046_Stairs;
+		while ((curThing != Thing::_endOfList) && (curThing.getType() <= k3_SensorThingType))
+			curThing = f159_getNextThing(curThing);
+		break;
 	case k4_DoorElemType:
 		if (bool((getFlag(AL0307_uc_Square, k0x0008_DoorNorthSouthOrient) >> 3)) == isOrientedWestEast(dir)) {
 			aspectArray[k0_ElemAspect] = k16_DoorSideElemType;
@@ -944,14 +950,12 @@ T0172010_ClosedFakeWall:
 			aspectArray[k3_DoorThingIndexAspect] = f161_getSquareFirstThing(mapX, mapY).getIndex();
 		}
 		AL0307_uc_FootprintsAllowed = true;
-T0172046_Stairs:
-		while ((curThing != Thing::_endOfList) && (curThing.getType() <= k3_SensorThingType)) {
+
+		while ((curThing != Thing::_endOfList) && (curThing.getType() <= k3_SensorThingType))
 			curThing = f159_getNextThing(curThing);
-		}
-T0172049_Footprints:
-		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapX, mapY)) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_g407_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_g407_party._lastScentIndex)) {
+
+		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapX, mapY)) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_g407_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_g407_party._lastScentIndex))
 			setFlag(aspectArray[k4_FloorOrnOrdAspect], k0x8000_FootprintsAspect);
-		}
 	}
 	aspectArray[k1_FirstGroupOrObjectAspect] = curThing.toUint16();
 }


Commit: dd418e439fb77c8a816a201c7c4c5db80dd563a1
    https://github.com/scummvm/scummvm/commit/dd418e439fb77c8a816a201c7c4c5db80dd563a1
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Move 3 arrays to f168_decodeText, some refactoring in f166_getUnusedThing and f140_getObjectWeight

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index dd70813..d0243df 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -956,6 +956,7 @@ T0172010_ClosedFakeWall:
 
 		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapX, mapY)) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_g407_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_g407_party._lastScentIndex))
 			setFlag(aspectArray[k4_FloorOrnOrdAspect], k0x8000_FootprintsAspect);
+		break;
 	}
 	aspectArray[k1_FirstGroupOrObjectAspect] = curThing.toUint16();
 }
@@ -1008,108 +1009,88 @@ Thing DungeonMan::f159_getNextThing(Thing thing) {
 	return Thing(f156_getThingData(thing)[0]);
 }
 
-char g255_MessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings
-	{'x',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '?',  0,  0,  0, 0, 0, 0, 0 }, */
-	{'y',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '!',  0,  0,  0, 0, 0, 0, 0 }, */
-	{'T','H','E',' ', 0, 0, 0, 0},
-	{'Y','O','U',' ', 0, 0, 0, 0},
-	{'z',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
-	{'{',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
-	{'|',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
-	{'}',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
-	{'~',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
-	{'',  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0}};
-char g256_EscReplacementCharacters[32][2] = { // @ G0256_aac_Graphic559_EscapeReplacementCharacters
-	{'a', 0},
-	{'b', 0},
-	{'c', 0},
-	{'d', 0},
-	{'e', 0},
-	{'f', 0},
-	{'g', 0},
-	{'h', 0},
-	{'i', 0},
-	{'j', 0},
-	{'k', 0},
-	{'l', 0},
-	{'m', 0},
-	{'n', 0},
-	{'o', 0},
-	{'p', 0},
-	{'q', 0},
-	{'r', 0},
-	{'s', 0},
-	{'t', 0},
-	{'u', 0},
-	{'v', 0},
-	{'w', 0},
-	{'x', 0},
-	{'0', 0},
-	{'1', 0},
-	{'2', 0},
-	{'3', 0},
-	{'4', 0},
-	{'5', 0},
-	{'6', 0},
-	{'7', 0}};
-char g257_InscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_InscriptionEscapeReplacementStrings
-	{28,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
-	{29,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
-	{19,  7,  4, 26, 0, 0, 0, 0},
-	{24, 14, 20, 26, 0, 0, 0, 0},
-	{30,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
-	{31,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
-	{32,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
-	{33,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
-	{34,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
-	{35,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0},
-	{0,  0,  0,  0, 0, 0, 0, 0}};
+void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) {
+	static char messageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings
+		{'x',   0,   0,   0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '?',  0,  0,  0, 0, 0, 0, 0 }, */
+		{'y',   0,   0,   0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '!',  0,  0,  0, 0, 0, 0, 0 }, */
+		{'T', 'H', 'E', ' ', 0, 0, 0, 0},
+		{'Y', 'O', 'U', ' ', 0, 0, 0, 0},
+		{'z',   0,   0,   0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+		{'{',   0,   0,   0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+		{'|',   0,   0,   0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+		{'}',   0,   0,   0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+		{'~',   0,   0,   0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+		{'',   0,   0,   0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0},
+		{0,     0,   0,   0, 0, 0, 0, 0}
+	};
+
+	static char escReplacementCharacters[32][2] = { // @ G0256_aac_Graphic559_EscapeReplacementCharacters
+		{'a', 0}, {'b', 0}, {'c', 0}, {'d', 0},
+		{'e', 0}, {'f', 0}, {'g', 0}, {'h', 0},
+		{'i', 0}, {'j', 0}, {'k', 0}, {'l', 0},
+		{'m', 0}, {'n', 0}, {'o', 0}, {'p', 0},
+		{'q', 0}, {'r', 0}, {'s', 0}, {'t', 0},
+		{'u', 0}, {'v', 0}, {'w', 0}, {'x', 0},
+		{'0', 0}, {'1', 0}, {'2', 0}, {'3', 0},
+		{'4', 0}, {'5', 0}, {'6', 0}, {'7', 0}
+	};
 
+	static char inscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_InscriptionEscapeReplacementStrings
+		{28,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+		{29,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+		{19,  7,  4, 26, 0, 0, 0, 0},
+		{24, 14, 20, 26, 0, 0, 0, 0},
+		{30,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+		{31,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+		{32,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+		{33,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+		{34,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+		{35,  0,  0,  0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0},
+		{0,   0,  0,  0, 0, 0, 0, 0}
+	};
 
-void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) {
 	TextString textString(_g284_thingData[k2_TextstringType] + thing.getIndex() * g235_ThingDataWordCount[k2_TextstringType]);
 	if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) {
 		type = (TextType)(type & ~k0x8000_DecodeEvenIfInvisible);
@@ -1142,82 +1123,73 @@ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) {
 			if (escChar) {
 				*destString = '\0';
 				if (escChar == 30) {
-					if (type != k0_TextTypeInscription) {
-						escReplString = g255_MessageAndScrollEscReplacementStrings[code];
-					} else {
-						escReplString = g257_InscriptionEscReplacementStrings[code];
-					}
-				} else {
-					escReplString = g256_EscReplacementCharacters[code];
-				}
+					if (type != k0_TextTypeInscription)
+						escReplString = messageAndScrollEscReplacementStrings[code];
+					else
+						escReplString = inscriptionEscReplacementStrings[code];
+				} else
+					escReplString = escReplacementCharacters[code];
+
 				strcat(destString, escReplString);
 				destString += strlen(escReplString);
 				escChar = 0;
 			} else if (code < 28) {
 				if (type != k0_TextTypeInscription) {
-					if (code == 26) {
+					if (code == 26)
 						code = ' ';
-					} else if (code == 27) {
+					else if (code == 27)
 						code = '.';
-					} else {
+					else
 						code += 'A';
-					}
 				}
 				*destString++ = code;
-			} else if (code == 28) {
+			} else if (code == 28)
 				*destString++ = sepChar;
-			} else if (code <= 30) {
+			else if (code <= 30)
 				escChar = code;
-			} else {
+			else
 				break;
-			}
 		}
 	}
 	*destString = ((type == k0_TextTypeInscription) ? 0x81 : '\0');
 }
 
 Thing DungeonMan::f166_getUnusedThing(uint16 thingType) {
-	int16 L0288_i_ThingIndex;
-	int16 L0289_i_ThingDataByteCount;
-	int16 L0290_i_ThingCount;
-	Thing* L0291_ps_Generic;
-	Thing L0292_T_Thing;
-
-
-	L0290_i_ThingCount = _vm->_dungeonMan->_g278_dungeonFileHeader._thingCounts[getFlag(thingType, k0x7FFF_thingType)];
+	int16 thingCount = _vm->_dungeonMan->_g278_dungeonFileHeader._thingCounts[getFlag(thingType, k0x7FFF_thingType)];
 	if (thingType == (k0x8000_championBones | k10_JunkThingType)) {
 		thingType = k10_JunkThingType;
-	} else {
-		if (thingType == k10_JunkThingType) {
-			L0290_i_ThingCount -= 3; /* Always keep 3 unused JUNK things for the bones of dead champions */
-		}
-	}
-	L0288_i_ThingIndex = L0290_i_ThingCount;
-	L0289_i_ThingDataByteCount = g235_ThingDataWordCount[thingType] >> 1;
-	L0291_ps_Generic = (Thing*)_vm->_dungeonMan->_g284_thingData[thingType];
+	} else if (thingType == k10_JunkThingType)
+		thingCount -= 3; /* Always keep 3 unused JUNK things for the bones of dead champions */
+
+	int16 thingIdx = thingCount;
+	int16 thingDataByteCount = g235_ThingDataWordCount[thingType] >> 1;
+	Thing *thingPtr = (Thing *)_vm->_dungeonMan->_g284_thingData[thingType];
+
+	Thing curThing;
 	for (;;) { /*_Infinite loop_*/
-		if (*L0291_ps_Generic == Thing::_none) { /* If thing data is unused */
-			L0292_T_Thing = Thing((thingType << 10) | (L0290_i_ThingCount - L0288_i_ThingIndex));
+		if (*thingPtr == Thing::_none) { /* If thing data is unused */
+			curThing = Thing((thingType << 10) | (thingCount - thingIdx));
 			break;
 		}
-		if (--L0288_i_ThingIndex) { /* If there are thing data left to process */
-			L0291_ps_Generic += L0289_i_ThingDataByteCount; /* Proceed to the next thing data */
+		if (--thingIdx) { /* If there are thing data left to process */
+			thingPtr += thingDataByteCount; /* Proceed to the next thing data */
 		} else {
-			if ((L0292_T_Thing = f165_getDiscardTHing(thingType)) == Thing::_none) {
+			curThing = f165_getDiscardTHing(thingType);
+			if (curThing == Thing::_none)
 				return Thing::_none;
-			}
-			L0291_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0292_T_Thing);
+
+			thingPtr = (Thing *)_vm->_dungeonMan->f156_getThingData(curThing);
 			break;
 		}
 	}
-	memset(L0291_ps_Generic, 0, L0289_i_ThingDataByteCount * 2);
+	memset(thingPtr, 0, thingDataByteCount * 2);
 
-	*L0291_ps_Generic = Thing::_endOfList;
-	return L0292_T_Thing;
+	*thingPtr = Thing::_endOfList;
+	return curThing;
 }
 
 uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
-	static const uint16 g241_junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo
+	static const uint16 junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo
 		// COMPASS - WATERSKIN - JEWEL SYMAL - ILLUMULET - ASHES
 		1, 3, 2, 2, 4,
 		// BONES - COPPER COIN - SILVER COIN - GOLD COIN - IRON KEY
@@ -1242,13 +1214,14 @@ uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 		2, 0, 8
 	};
 
-	Junk* junk;
-	uint16 weight = (uint16)-1; // initialization is not present in original
-
 	if (thing == Thing::_none)
 		return 0;
 
-	junk = (Junk*)f156_getThingData(thing);
+	// Initialization is not present in original
+	// Set to 0 by default as it's the default value used for Thing::_none
+	uint16 weight = 0;
+	Junk *junk = (Junk*)f156_getThingData(thing);
+
 	switch (thing.getType()) {
 	case k5_WeaponThingType:
 		weight = g238_WeaponInfo[((Weapon*)junk)->getType()]._weight;
@@ -1257,10 +1230,10 @@ uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 		weight = g239_ArmourInfo[((Armour*)junk)->getType()]._weight;
 		break;
 	case k10_JunkThingType:
-		weight = g241_junkInfo[junk->getType()];
-		if (junk->getType() == k1_JunkTypeWaterskin) {
+		weight = junkInfo[junk->getType()];
+		if (junk->getType() == k1_JunkTypeWaterskin)
 			weight += junk->getChargeCount() << 1;
-		}
+
 		break;
 	case k9_ContainerThingType:
 		weight = 50;
@@ -1271,14 +1244,14 @@ uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 		}
 		break;
 	case k8_PotionThingType:
-		if (((Potion*)junk)->getType() == k20_PotionTypeEmptyFlask) {
+		if (((Potion*)junk)->getType() == k20_PotionTypeEmptyFlask)
 			weight = 1;
-		} else {
+		else
 			weight = 3;
-		}
 		break;
 	case k7_ScrollThingType:
 		weight = 1;
+		break;
 	}
 
 	return weight; // this is garbage if none of the branches were taken


Commit: f92ba7f55d34c3e24fc6fcbe63087b060eab7f77
    https://github.com/scummvm/scummvm/commit/f92ba7f55d34c3e24fc6fcbe63087b060eab7f77
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactoring of f163_linkThingToList, f142_getProjectileAspect and f154_getLocationAfterLevelChange

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index d0243df..db7ff6f 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1220,14 +1220,14 @@ uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 	// Initialization is not present in original
 	// Set to 0 by default as it's the default value used for Thing::_none
 	uint16 weight = 0;
-	Junk *junk = (Junk*)f156_getThingData(thing);
+	Junk *junk = (Junk *)f156_getThingData(thing);
 
 	switch (thing.getType()) {
 	case k5_WeaponThingType:
-		weight = g238_WeaponInfo[((Weapon*)junk)->getType()]._weight;
+		weight = g238_WeaponInfo[((Weapon *)junk)->getType()]._weight;
 		break;
 	case k6_ArmourThingType:
-		weight = g239_ArmourInfo[((Armour*)junk)->getType()]._weight;
+		weight = g239_ArmourInfo[((Armour *)junk)->getType()]._weight;
 		break;
 	case k10_JunkThingType:
 		weight = junkInfo[junk->getType()];
@@ -1257,7 +1257,6 @@ uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 	return weight; // this is garbage if none of the branches were taken
 }
 
-
 int16 DungeonMan::f141_getObjectInfoIndex(Thing thing) {
 	uint16 *rawType = f156_getThingData(thing);
 	switch (thing.getType()) {
@@ -1282,43 +1281,42 @@ void DungeonMan::f163_linkThingToList(Thing thingToLink, Thing thingInList, int1
 	if (thingToLink == Thing::_endOfList)
 		return;
 
-	Thing *L0269_ps_Generic = (Thing *)f156_getThingData(thingToLink);
-	*L0269_ps_Generic = Thing::_endOfList;
+	Thing *thingPtr = (Thing *)f156_getThingData(thingToLink);
+	*thingPtr = Thing::_endOfList;
 	/* If mapX >= 0 then the thing is linked to the list of things on the specified square else it is linked at the end of the specified thing list */
 	if (mapX >= 0) {
-		byte *L0268_puc_Square = &_g271_currMapData[mapX][mapY];
-		if (getFlag(*L0268_puc_Square, k0x0010_ThingListPresent)) {
+		byte *currSquare = &_g271_currMapData[mapX][mapY];
+		if (getFlag(*currSquare, k0x0010_ThingListPresent)) {
 			thingInList = f161_getSquareFirstThing(mapX, mapY);
 		} else {
-			setFlag(*L0268_puc_Square, k0x0010_ThingListPresent);
+			setFlag(*currSquare, k0x0010_ThingListPresent);
 			uint16 * tmp = _g270_currMapColCumulativeSquareFirstThingCount + mapX + 1;
-			uint16 AL0266_ui_Column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1;
-			while (AL0266_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is added */
+			uint16 currColumn = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1;
+			while (currColumn--) { /* For each column starting from and after the column containing the square where the thing is added */
 				(*tmp++)++; /* Increment the cumulative first thing count */
 			}
-			uint16 L0270_ui_MapY = 0;
-			L0268_puc_Square -= mapY;
-			uint16 AL0266_ui_SquareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
-			while (L0270_ui_MapY++ != mapY) {
-				if (getFlag(*L0268_puc_Square++, k0x0010_ThingListPresent)) {
-					AL0266_ui_SquareFirstThingIndex++;
-				}
+			uint16 currMapY = 0;
+			currSquare -= mapY;
+			uint16 currSquareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
+			while (currMapY++ != mapY) {
+				if (getFlag(*currSquare++, k0x0010_ThingListPresent))
+					currSquareFirstThingIndex++;
 			}
-			Thing *L0267_pT_Thing = &_g283_squareFirstThings[AL0266_ui_SquareFirstThingIndex];
+			Thing *currThing = &_g283_squareFirstThings[currSquareFirstThingIndex];
 			// the second '- 1' is for the loop initialization, > 0 is because we are copying from one behind
-			for (int16 i = _g278_dungeonFileHeader._squareFirstThingCount - AL0266_ui_SquareFirstThingIndex - 1 - 1; i > 0; --i)
-				L0267_pT_Thing[i] = L0267_pT_Thing[i - 1];
+			for (int16 i = _g278_dungeonFileHeader._squareFirstThingCount - currSquareFirstThingIndex - 1 - 1; i > 0; --i)
+				currThing[i] = currThing[i - 1];
 
-			*L0267_pT_Thing = thingToLink;
+			*currThing = thingToLink;
 			return;
 		}
 	}
-	Thing L0265_T_Thing = f159_getNextThing(thingInList);
-	while (L0265_T_Thing != Thing::_endOfList) {
-		L0265_T_Thing = f159_getNextThing(thingInList = L0265_T_Thing);
-	}
-	L0269_ps_Generic = (Thing *)f156_getThingData(thingInList);
-	*L0269_ps_Generic = thingToLink;
+	Thing nextThing = f159_getNextThing(thingInList);
+	while (nextThing != Thing::_endOfList)
+		nextThing = f159_getNextThing(thingInList = nextThing);
+
+	thingPtr = (Thing *)f156_getThingData(thingInList);
+	*thingPtr = thingToLink;
 }
 
 WeaponInfo* DungeonMan::f158_getWeaponInfo(Thing thing) {
@@ -1327,11 +1325,8 @@ WeaponInfo* DungeonMan::f158_getWeaponInfo(Thing thing) {
 }
 
 int16 DungeonMan::f142_getProjectileAspect(Thing thing) {
-	ThingType thingType;
-	int16 projAspOrd;
-	WeaponInfo *weaponInfo;
-
-	if ((thingType = thing.getType()) == k15_ExplosionThingType) {
+	ThingType thingType = thing.getType();
+	if (thingType == k15_ExplosionThingType) {
 		if (thing == Thing::_explFireBall)
 			return -_vm->M0_indexToOrdinal(k10_ProjectileAspectExplosionFireBall);
 		if (thing == Thing::_explSlime)
@@ -1343,8 +1338,9 @@ int16 DungeonMan::f142_getProjectileAspect(Thing thing) {
 
 		return -_vm->M0_indexToOrdinal(k11_ProjectileAspectExplosionDefault);
 	} else if (thingType == k5_WeaponThingType) {
-		weaponInfo = f158_getWeaponInfo(thing);
-		if (projAspOrd = weaponInfo->getProjectileAspectOrdinal())
+		WeaponInfo *weaponInfo = f158_getWeaponInfo(thing);
+		int16 projAspOrd = weaponInfo->getProjectileAspectOrdinal();
+		if (projAspOrd)
 			return -projAspOrd;
 	}
 
@@ -1352,25 +1348,20 @@ int16 DungeonMan::f142_getProjectileAspect(Thing thing) {
 }
 
 int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16* mapX, int16* mapY) {
-	int16 newMapX;
-	int16 newMapY;
-	int16 newLevel;
-	int16 offset;
-	Map* map;
-	int16 targetMapIndex;
-
-
-	if (_g309_partyMapIndex == k255_mapIndexEntrance) {
+	if (_g309_partyMapIndex == k255_mapIndexEntrance)
 		return kM1_mapIndexNone;
-	}
-	map = _g277_dungeonMaps + mapIndex;
-	newMapX = map->_offsetMapX + *mapX;
-	newMapY = map->_offsetMapY + *mapY;
-	newLevel = map->_level + levelDelta;
+
+	Map *map = _g277_dungeonMaps + mapIndex;
+	int16 newMapX = map->_offsetMapX + *mapX;
+	int16 newMapY = map->_offsetMapY + *mapY;
+	int16 newLevel = map->_level + levelDelta;
 	map = _g277_dungeonMaps;
-	for (targetMapIndex = 0; targetMapIndex < _g278_dungeonFileHeader._mapCount; targetMapIndex++) {
-		if ((map->_level == newLevel) && (newMapX >= (offset = map->_offsetMapX)) && (newMapX <= (offset + map->_width)) && (newMapY >= (offset = map->_offsetMapY)) && (newMapY <= (offset + map->_height))) {
-			*mapY = newMapY - offset;
+
+	for (int16 targetMapIndex = 0; targetMapIndex < _g278_dungeonFileHeader._mapCount; targetMapIndex++) {
+		if ((map->_level == newLevel)
+		&& (newMapX >= map->_offsetMapX) && (newMapX <= map->_offsetMapX + map->_width)
+		&& (newMapY >= map->_offsetMapY) && (newMapY <= map->_offsetMapY + map->_height)) {
+			*mapY = newMapY - map->_offsetMapY;
 			*mapX = newMapX - map->_offsetMapX;
 			return targetMapIndex;
 		}
@@ -1381,9 +1372,9 @@ int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDe
 
 Thing DungeonMan::f162_getSquareFirstObject(int16 mapX, int16 mapY) {
 	Thing thing = f161_getSquareFirstThing(mapX, mapY);
-	while ((thing != Thing::_endOfList) && (thing.getType() < k4_GroupThingType)) {
+	while ((thing != Thing::_endOfList) && (thing.getType() < k4_GroupThingType))
 		thing = f159_getNextThing(thing);
-	}
+
 	return thing;
 }
 


Commit: 81781f6f00be71c073a6ee359c4b8b86bb059b15
    https://github.com/scummvm/scummvm/commit/81781f6f00be71c073a6ee359c4b8b86bb059b15
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove two GOTOs in f165_getDiscardTHing

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index db7ff6f..ac79fe3 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1379,13 +1379,11 @@ Thing DungeonMan::f162_getSquareFirstObject(int16 mapX, int16 mapY) {
 }
 
 uint16 DungeonMan::f143_getArmourDefense(ArmourInfo* armourInfo, bool useSharpDefense) {
-	uint16 L0244_ui_Defense;
+	uint16 defense = armourInfo->_defense;
+	if (useSharpDefense)
+		defense = _vm->f30_getScaledProduct(defense, 3, getFlag(armourInfo->_attributes, k0x0007_ArmourAttributeSharpDefense) + 4);
 
-	L0244_ui_Defense = armourInfo->_defense;
-	if (useSharpDefense) {
-		L0244_ui_Defense = _vm->f30_getScaledProduct(L0244_ui_Defense, 3, getFlag(armourInfo->_attributes, k0x0007_ArmourAttributeSharpDefense) + 4);
-	}
-	return L0244_ui_Defense;
+	return defense;
 }
 
 Thing DungeonMan::f165_getDiscardTHing(uint16 thingType) {
@@ -1404,25 +1402,27 @@ Thing DungeonMan::f165_getDiscardTHing(uint16 thingType) {
 	static unsigned char G0294_auc_LastDiscardedThingMapIndex[16];
 
 
-	if (thingType == k15_ExplosionThingType) {
+	if (thingType == k15_ExplosionThingType)
 		return Thing::_none;
-	}
+
 	L0284_i_CurrentMapIndex = _vm->_dungeonMan->_g272_currMapIndex;
-	if (((L0279_ui_MapIndex = G0294_auc_LastDiscardedThingMapIndex[thingType]) == _vm->_dungeonMan->_g309_partyMapIndex) && (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount)) {
+	if (((L0279_ui_MapIndex = G0294_auc_LastDiscardedThingMapIndex[thingType]) == _vm->_dungeonMan->_g309_partyMapIndex) && (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount))
 		L0279_ui_MapIndex = 0;
-	}
+
 	L0283_ui_DiscardThingMapIndex = L0279_ui_MapIndex;
 	for (;;) { /*_Infinite loop_*/
 		L0285_ui_MapWidth = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._width;
 		L0286_ui_MapHeight = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._height;
 		L0280_puc_Square = _vm->_dungeonMan->_g279_dungeonMapData[L0279_ui_MapIndex][0];
 		L0281_pT_SquareFirstThing = &_vm->_dungeonMan->_g283_squareFirstThings[_vm->_dungeonMan->_g280_dungeonColumnsCumulativeSquareThingCount[_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[L0279_ui_MapIndex]]];
+		
 		for (L0276_ui_MapX = 0; L0276_ui_MapX <= L0285_ui_MapWidth; L0276_ui_MapX++) {
 			for (L0277_ui_MapY = 0; L0277_ui_MapY <= L0286_ui_MapHeight; L0277_ui_MapY++) {
 				if (getFlag(*L0280_puc_Square++, k0x0010_ThingListPresent)) {
 					L0278_T_Thing = *L0281_pT_SquareFirstThing++;
 					if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && ((L0276_ui_MapX - _vm->_dungeonMan->_g306_partyMapX + 5) <= 10) && ((L0277_ui_MapY - _vm->_dungeonMan->_g307_partyMapY + 5) <= 10)) /* If square is too close to the party */
-						goto T0165029;
+						continue;
+
 					do {
 						if ((L0287_i_ThingType = L0278_T_Thing.getType()) == k3_SensorThingType) {
 							L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing);
@@ -1449,21 +1449,31 @@ Thing DungeonMan::f165_getDiscardTHing(uint16 thingType) {
 								case k6_ArmourThingType:
 									if (((Armour*)L0282_ps_Generic)->getDoNotDiscard())
 										continue;
-									goto T0165026;
+
+									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
+									_vm->_moveSens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0);
+									break;
 								case k5_WeaponThingType:
 									if (((Weapon*)L0282_ps_Generic)->getDoNotDiscard())
 										continue;
-									goto T0165026;
+
+									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
+									_vm->_moveSens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0);
+									break;
 								case k10_JunkThingType:
 									if (((Junk*)L0282_ps_Generic)->getDoNotDiscard())
 										continue;
-									goto T0165026;
+
+									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
+									_vm->_moveSens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0);
+									break;
 								case k8_PotionThingType:
 									if (((Potion*)L0282_ps_Generic)->getDoNotDiscard())
 										continue;
-T0165026:
+
 									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
 									_vm->_moveSens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0);
+									break;
 								}
 								_vm->_dungeonMan->f173_setCurrentMap(L0284_i_CurrentMapIndex);
 								G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex;
@@ -1471,8 +1481,6 @@ T0165026:
 							}
 						}
 					} while ((L0278_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0278_T_Thing)) != Thing::_endOfList);
-T0165029:
-					;
 				}
 			}
 		}
@@ -1481,13 +1489,13 @@ T0165029:
 			return Thing::_none;
 		}
 		do {
-			if (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount) {
+			if (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount)
 				L0279_ui_MapIndex = 0;
-			}
+
 		} while (L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex);
-		if (L0279_ui_MapIndex == L0283_ui_DiscardThingMapIndex) {
+
+		if (L0279_ui_MapIndex == L0283_ui_DiscardThingMapIndex)
 			L0279_ui_MapIndex = _vm->_dungeonMan->_g309_partyMapIndex;
-		}
 	}
 }
 


Commit: 0009c223ea862d28293d5fe692567572a3f4b3b1
    https://github.com/scummvm/scummvm/commit/0009c223ea862d28293d5fe692567572a3f4b3b1
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f165_getDiscardThing

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index ac79fe3..5142281 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1174,7 +1174,7 @@ Thing DungeonMan::f166_getUnusedThing(uint16 thingType) {
 		if (--thingIdx) { /* If there are thing data left to process */
 			thingPtr += thingDataByteCount; /* Proceed to the next thing data */
 		} else {
-			curThing = f165_getDiscardTHing(thingType);
+			curThing = f165_getDiscardThing(thingType);
 			if (curThing == Thing::_none)
 				return Thing::_none;
 
@@ -1386,116 +1386,104 @@ uint16 DungeonMan::f143_getArmourDefense(ArmourInfo* armourInfo, bool useSharpDe
 	return defense;
 }
 
-Thing DungeonMan::f165_getDiscardTHing(uint16 thingType) {
-	uint16 L0276_ui_MapX;
-	uint16 L0277_ui_MapY;
-	Thing L0278_T_Thing;
-	uint16 L0279_ui_MapIndex;
-	byte* L0280_puc_Square;
-	Thing* L0281_pT_SquareFirstThing;
-	Thing* L0282_ps_Generic;
-	uint16 L0283_ui_DiscardThingMapIndex;
-	int L0284_i_CurrentMapIndex;
-	uint16 L0285_ui_MapWidth;
-	uint16 L0286_ui_MapHeight;
-	int L0287_i_ThingType;
-	static unsigned char G0294_auc_LastDiscardedThingMapIndex[16];
-
+Thing DungeonMan::f165_getDiscardThing(uint16 thingType) {
+	// CHECKME: Shouldn't it be saved in the savegames?
+	static unsigned char lastDiscardedThingMapIndex[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
 	if (thingType == k15_ExplosionThingType)
 		return Thing::_none;
 
-	L0284_i_CurrentMapIndex = _vm->_dungeonMan->_g272_currMapIndex;
-	if (((L0279_ui_MapIndex = G0294_auc_LastDiscardedThingMapIndex[thingType]) == _vm->_dungeonMan->_g309_partyMapIndex) && (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount))
-		L0279_ui_MapIndex = 0;
+	int16 currentMapIdx = _vm->_dungeonMan->_g272_currMapIndex;
+	uint16 mapIndex = lastDiscardedThingMapIndex[thingType];
+	if ((mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (++mapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount))
+		mapIndex = 0;
 
-	L0283_ui_DiscardThingMapIndex = L0279_ui_MapIndex;
+	uint16 discardThingMapIndex = mapIndex;
 	for (;;) { /*_Infinite loop_*/
-		L0285_ui_MapWidth = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._width;
-		L0286_ui_MapHeight = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._height;
-		L0280_puc_Square = _vm->_dungeonMan->_g279_dungeonMapData[L0279_ui_MapIndex][0];
-		L0281_pT_SquareFirstThing = &_vm->_dungeonMan->_g283_squareFirstThings[_vm->_dungeonMan->_g280_dungeonColumnsCumulativeSquareThingCount[_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[L0279_ui_MapIndex]]];
+		uint16 mapWidth = _vm->_dungeonMan->_g277_dungeonMaps[mapIndex]._width;
+		uint16 mapHeight = _vm->_dungeonMan->_g277_dungeonMaps[mapIndex]._height;
+		byte *currSquare = _vm->_dungeonMan->_g279_dungeonMapData[mapIndex][0];
+		Thing *squareFirstThing = &_vm->_dungeonMan->_g283_squareFirstThings[_vm->_dungeonMan->_g280_dungeonColumnsCumulativeSquareThingCount[_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[mapIndex]]];
 		
-		for (L0276_ui_MapX = 0; L0276_ui_MapX <= L0285_ui_MapWidth; L0276_ui_MapX++) {
-			for (L0277_ui_MapY = 0; L0277_ui_MapY <= L0286_ui_MapHeight; L0277_ui_MapY++) {
-				if (getFlag(*L0280_puc_Square++, k0x0010_ThingListPresent)) {
-					L0278_T_Thing = *L0281_pT_SquareFirstThing++;
-					if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && ((L0276_ui_MapX - _vm->_dungeonMan->_g306_partyMapX + 5) <= 10) && ((L0277_ui_MapY - _vm->_dungeonMan->_g307_partyMapY + 5) <= 10)) /* If square is too close to the party */
+		for (int16 currMapX = 0; currMapX <= mapWidth; currMapX++) {
+			for (int16 currMapY = 0; currMapY <= mapHeight; currMapY++) {
+				if (getFlag(*currSquare++, k0x0010_ThingListPresent)) {
+					Thing squareThing = *squareFirstThing++;
+					if ((mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && ((currMapX - _vm->_dungeonMan->_g306_partyMapX + 5) <= 10) && ((currMapY - _vm->_dungeonMan->_g307_partyMapY + 5) <= 10)) /* If square is too close to the party */
 						continue;
 
 					do {
-						if ((L0287_i_ThingType = L0278_T_Thing.getType()) == k3_SensorThingType) {
-							L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing);
-							if (((Sensor*)L0282_ps_Generic)->getType()) /* If sensor is not disabled */
+						ThingType squareThingType = squareThing.getType();
+						if (squareThingType == k3_SensorThingType) {
+							Thing *squareThingData = (Thing*)_vm->_dungeonMan->f156_getThingData(squareThing);
+							if (((Sensor*)squareThingData)->getType()) /* If sensor is not disabled */
 								break;
-						} else {
-							if (L0287_i_ThingType == thingType) {
-								L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing);
-								switch (thingType) {
-								case k4_GroupThingType:
-									if (((Group*)L0282_ps_Generic)->getDoNotDiscard())
-										continue;
-								case k14_ProjectileThingType:
-									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
-									if (thingType == k4_GroupThingType) {
-										_vm->_groupMan->f188_dropGroupPossessions(L0276_ui_MapX, L0277_ui_MapY, L0278_T_Thing, kM1_soundModeDoNotPlaySound);
-										_vm->_groupMan->f189_delete(L0276_ui_MapX, L0277_ui_MapY);
-									} else {
-										_vm->_projexpl->f214_projectileDeleteEvent(L0278_T_Thing);
-										f164_unlinkThingFromList(L0278_T_Thing, Thing(0), L0276_ui_MapX, L0277_ui_MapY);
-										_vm->_projexpl->f215_projectileDelete(L0278_T_Thing, 0, L0276_ui_MapX, L0277_ui_MapY);
-									}
-									break;
-								case k6_ArmourThingType:
-									if (((Armour*)L0282_ps_Generic)->getDoNotDiscard())
-										continue;
-
-									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
-									_vm->_moveSens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0);
-									break;
-								case k5_WeaponThingType:
-									if (((Weapon*)L0282_ps_Generic)->getDoNotDiscard())
-										continue;
-
-									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
-									_vm->_moveSens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0);
-									break;
-								case k10_JunkThingType:
-									if (((Junk*)L0282_ps_Generic)->getDoNotDiscard())
-										continue;
-
-									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
-									_vm->_moveSens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0);
-									break;
-								case k8_PotionThingType:
-									if (((Potion*)L0282_ps_Generic)->getDoNotDiscard())
-										continue;
-
-									_vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex);
-									_vm->_moveSens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0);
-									break;
+						} else if (squareThingType == thingType) {
+							Thing *squareThingData = (Thing*)_vm->_dungeonMan->f156_getThingData(squareThing);
+							switch (thingType) {
+							case k4_GroupThingType:
+								if (((Group*)squareThingData)->getDoNotDiscard())
+									continue;
+							case k14_ProjectileThingType:
+								_vm->_dungeonMan->f173_setCurrentMap(mapIndex);
+								if (thingType == k4_GroupThingType) {
+									_vm->_groupMan->f188_dropGroupPossessions(currMapX, currMapY, squareThing, kM1_soundModeDoNotPlaySound);
+									_vm->_groupMan->f189_delete(currMapX, currMapY);
+								} else {
+									_vm->_projexpl->f214_projectileDeleteEvent(squareThing);
+									f164_unlinkThingFromList(squareThing, Thing(0), currMapX, currMapY);
+									_vm->_projexpl->f215_projectileDelete(squareThing, 0, currMapX, currMapY);
 								}
-								_vm->_dungeonMan->f173_setCurrentMap(L0284_i_CurrentMapIndex);
-								G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex;
-								return Thing(L0278_T_Thing.getTypeAndIndex());
+								break;
+							case k6_ArmourThingType:
+								if (((Armour*)squareThingData)->getDoNotDiscard())
+									continue;
+
+								_vm->_dungeonMan->f173_setCurrentMap(mapIndex);
+								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
+								break;
+							case k5_WeaponThingType:
+								if (((Weapon*)squareThingData)->getDoNotDiscard())
+									continue;
+
+								_vm->_dungeonMan->f173_setCurrentMap(mapIndex);
+								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
+								break;
+							case k10_JunkThingType:
+								if (((Junk*)squareThingData)->getDoNotDiscard())
+									continue;
+
+								_vm->_dungeonMan->f173_setCurrentMap(mapIndex);
+								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
+								break;
+							case k8_PotionThingType:
+								if (((Potion*)squareThingData)->getDoNotDiscard())
+									continue;
+
+								_vm->_dungeonMan->f173_setCurrentMap(mapIndex);
+								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
+								break;
 							}
+							_vm->_dungeonMan->f173_setCurrentMap(currentMapIdx);
+							lastDiscardedThingMapIndex[thingType] = mapIndex;
+							return Thing(squareThing.getTypeAndIndex());
 						}
-					} while ((L0278_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0278_T_Thing)) != Thing::_endOfList);
+					} while ((squareThing = _vm->_dungeonMan->f159_getNextThing(squareThing)) != Thing::_endOfList);
 				}
 			}
 		}
-		if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) || (_vm->_dungeonMan->_g278_dungeonFileHeader._mapCount <= 1)) {
-			G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex;
+		if ((mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) || (_vm->_dungeonMan->_g278_dungeonFileHeader._mapCount <= 1)) {
+			lastDiscardedThingMapIndex[thingType] = mapIndex;
 			return Thing::_none;
 		}
-		do {
-			if (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount)
-				L0279_ui_MapIndex = 0;
 
-		} while (L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex);
+		do {
+			if (++mapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount)
+				mapIndex = 0;
+		} while (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex);
 
-		if (L0279_ui_MapIndex == L0283_ui_DiscardThingMapIndex)
-			L0279_ui_MapIndex = _vm->_dungeonMan->_g309_partyMapIndex;
+		if (mapIndex == discardThingMapIndex)
+			mapIndex = _vm->_dungeonMan->_g309_partyMapIndex;
 	}
 }
 
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index bbd1499..e75c6c2 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -699,7 +699,7 @@ public:
 	int16 f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16 *mapX, int16 *mapY); // @ F0154_DUNGEON_GetLocationAfterLevelChange
 	Thing f162_getSquareFirstObject(int16 mapX, int16 mapY); // @ F0162_DUNGEON_GetSquareFirstObject
 	uint16 f143_getArmourDefense(ArmourInfo *armourInfo, bool useSharpDefense); // @ F0143_DUNGEON_GetArmourDefense
-	Thing f165_getDiscardTHing(uint16 thingType); // @ F0165_DUNGEON_GetDiscardedThing
+	Thing f165_getDiscardThing(uint16 thingType); // @ F0165_DUNGEON_GetDiscardedThing
 	uint16 f144_getCreatureAttributes(Thing thing); // @ F0144_DUNGEON_GetCreatureAttributes
 	void f146_setGroupCells(Group *group, uint16 cells, uint16 mapIndex); // @ F0146_DUNGEON_SetGroupCells
 	void f148_setGroupDirections(Group *group, int16 dir, uint16 mapIndex); // @ F0148_DUNGEON_SetGroupDirections


Commit: c57929d3da42fd490911de67c3d4f58f38c08755
    https://github.com/scummvm/scummvm/commit/c57929d3da42fd490911de67c3d4f58f38c08755
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f144_getCreatureAttributes, f146_setGroupCells and f139_isCreatureAllowedOnMap

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 5142281..87bd66f 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1488,43 +1488,31 @@ Thing DungeonMan::f165_getDiscardThing(uint16 thingType) {
 }
 
 uint16 DungeonMan::f144_getCreatureAttributes(Thing thing) {
-	Group* L0245_ps_Group;
-
-	L0245_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing);
-	return g243_CreatureInfo[L0245_ps_Group->_type]._attributes;
+	Group *currGroup = (Group *)_vm->_dungeonMan->f156_getThingData(thing);
+	return g243_CreatureInfo[currGroup->_type]._attributes;
 }
 
 void DungeonMan::f146_setGroupCells(Group* group, uint16 cells, uint16 mapIndex) {
-	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) {
+	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex)
 		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._cells = cells;
-	} else {
+	else
 		group->_cells = cells;
-	}
 }
 
 void DungeonMan::f148_setGroupDirections(Group* group, int16 dir, uint16 mapIndex) {
-	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) {
+	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex)
 		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (Direction)dir;
-	} else {
+	else
 		group->setDir(M21_normalizeModulo4(dir));
-	}
 }
 
 bool DungeonMan::f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) {
-	int16 L0234_i_Counter;
-	int16 L0235_i_CreatureType;
-	byte* L0236_puc_Multiple;
-#define AL0236_puc_Group               L0236_puc_Multiple
-#define AL0236_puc_AllowedCreatureType L0236_puc_Multiple
-	Map* L0237_ps_Map;
-
-	L0235_i_CreatureType = ((Group*)_vm->_dungeonMan->f156_getThingData(thing))->_type;
-	L0237_ps_Map = &_vm->_dungeonMan->_g277_dungeonMaps[mapIndex];
-	AL0236_puc_AllowedCreatureType = _vm->_dungeonMan->_g279_dungeonMapData[mapIndex][L0237_ps_Map->_width] + L0237_ps_Map->_height + 1;
-	for (L0234_i_Counter = L0237_ps_Map->_creatureTypeCount; L0234_i_Counter > 0; L0234_i_Counter--) {
-		if (*AL0236_puc_AllowedCreatureType++ == L0235_i_CreatureType) {
+	int16 creatureType = ((Group*)_vm->_dungeonMan->f156_getThingData(thing))->_type;
+	Map *map = &_vm->_dungeonMan->_g277_dungeonMaps[mapIndex];
+	byte *allowedCreatureType = _vm->_dungeonMan->_g279_dungeonMapData[mapIndex][map->_width] + map->_height + 1;
+	for (int16 L0234_i_Counter = map->_creatureTypeCount; L0234_i_Counter > 0; L0234_i_Counter--) {
+		if (*allowedCreatureType++ == creatureType)
 			return true;
-		}
 	}
 	return false;
 }


Commit: 2b1b784479709a9cdd596200c280617537739bb9
    https://github.com/scummvm/scummvm/commit/2b1b784479709a9cdd596200c280617537739bb9
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove GOTOs in f164_unlinkThingFromList

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 87bd66f..4e27eb5 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1529,15 +1529,12 @@ void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList
 #define AL0275_pui_CumulativeFirstThingCount L0275_pui_Multiple
 
 
-	if (thingToUnlink == Thing::_endOfList) {
+	if (thingToUnlink == Thing::_endOfList)
 		return;
-	}
 
-	{
-		uint16 tmp = thingToUnlink.toUint16();
-		clearFlag(tmp, 0xC000);
-		thingToUnlink = Thing(tmp);
-	}
+	uint16 tmp = thingToUnlink.toUint16();
+	clearFlag(tmp, 0xC000);
+	thingToUnlink = Thing(tmp);
 
 	if (mapX >= 0) {
 		L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink);
@@ -1554,25 +1551,27 @@ void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList
 			while (AL0272_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is unlinked */
 				(*(uint16*)AL0275_pui_CumulativeFirstThingCount++)--; /* Decrement the cumulative first thing count */
 			}
-			goto T0164011;
+			*L0274_ps_Generic = Thing::_endOfList;
+			return;
 		}
 		if (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16()) {
 			*AL0275_pT_Thing = *L0274_ps_Generic;
-			goto T0164011;
+			*L0274_ps_Generic = Thing::_endOfList;
+			return;
 		}
 		thingInList = *AL0275_pT_Thing;
 	}
 	L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList);
 	while (L0273_T_Thing.getTypeAndIndex() != thingToUnlink.toUint16()) {
 		if ((L0273_T_Thing == Thing::_endOfList) || (L0273_T_Thing == Thing::_none)) {
-			goto T0164011;
+			*L0274_ps_Generic = Thing::_endOfList;
+			return;
 		}
 		L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList = L0273_T_Thing);
 	}
 	L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingInList);
 	*L0274_ps_Generic = _vm->_dungeonMan->f159_getNextThing(L0273_T_Thing);
 	L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink);
-T0164011:
 	*L0274_ps_Generic = Thing::_endOfList;
 }
 


Commit: a0543f75027510e44293ff518bc1ecf564066fbc
    https://github.com/scummvm/scummvm/commit/a0543f75027510e44293ff518bc1ecf564066fbc
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove unnecessary memset from setMousePointerFromSpriteData

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 3ecba11..0a9586b 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -992,7 +992,6 @@ bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int
 
 void EventManager::setMousePointerFromSpriteData(byte* mouseSprite) {
 	byte bitmap[16 * 18];
-	memset(bitmap, 0, 16 * 18);
 	for (int16 imgPart = 0; imgPart < 4; ++imgPart) {
 		for (byte *line = mouseSprite + 72 * imgPart, *pixel = bitmap; line < mouseSprite + 72 * (imgPart + 1); line += 4) {
 			uint16 words[2];


Commit: 2994cf707b9a4051b43666c22dea31b92e5a3580
    https://github.com/scummvm/scummvm/commit/2994cf707b9a4051b43666c22dea31b92e5a3580
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix mouse cursor dimensions

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 0a9586b..82c8050 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1002,7 +1002,7 @@ void EventManager::setMousePointerFromSpriteData(byte* mouseSprite) {
 		}
 	}
 
-	CursorMan.replaceCursor(bitmap, 16, 32, 0, 0, 0);
+	CursorMan.replaceCursor(bitmap, 16, 18, 0, 0, 0);
 }
 
 void EventManager::f368_commandSetLeader(ChampionIndex champIndex) {


Commit: 262e74aee85b1fafaab3eff48cbb8574a6b4d7dc
    https://github.com/scummvm/scummvm/commit/262e74aee85b1fafaab3eff48cbb8574a6b4d7dc
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix item display in the dungeon, add f480_releaseBlock

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index b2cf89a..74d11cf 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -721,6 +721,11 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 										Frame(124, 159, 17, 102, 48, 88, 48, 0)	/* Right Horizontal Closed three fourth */
 	);
 
+	for (uint16 i = 0; i < 16; ++i) {
+		_g347_paletteTopAndBottomScreen[i] = 0;
+		_g346_paletteMiddleScreen[i] = 0;
+	}
+
 	for (uint16 i = 0; i < 32; i++)
 		_g345_aui_BlankBuffer[i] = 0;
 }
@@ -737,7 +742,7 @@ DisplayMan::~DisplayMan() {
 	delete[] _g639_derivedBitmapByteCount;
 	if (_g638_derivedBitmaps) {
 		for (uint16 i = 0; i < k730_DerivedBitmapMaximumCount; ++i)
-			delete[] _g638_derivedBitmaps;
+			delete[] _g638_derivedBitmaps[i];
 		delete[] _g638_derivedBitmaps;
 	}
 
@@ -2560,7 +2565,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 					}
 				}
 			}
-			AL0091_puc_Bitmap =f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
+			AL0091_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
 			if (viewWallIndex == k11_ViewWall_D1R_LEFT) {
 				f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]);
 				AL0091_puc_Bitmap = _g74_tmpBitmap;
@@ -2630,7 +2635,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 							  AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport);
 		}
 
-		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { 
+		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
 			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), _g296_bitmapViewport, boxChampionPortraitOnWall,
 				(_g289_championPortraitOrdinal & 0x0007) << 5, (_g289_championPortraitOrdinal >> 3) * 29,
 							  k128_byteWidth, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); /* A portrait is 32x29 pixels */
@@ -2873,61 +2878,51 @@ int16 g225_CenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_Cen
 
 void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16 mapXpos,
 							  int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) {
-
-	DungeonMan &dunMan = *_vm->_dungeonMan;
-
-	// AL_0 shared
-	uint16 &AL_0_creatureIndexRed = *(uint16 *)&thingParam;
-	uint16 &AL_0_creatureGraphicInfoRed = *(uint16 *)&thingParam;
-	uint16 &AL_0_creaturePosX = *(uint16 *)&thingParam;
-	// AL_1 shared
-	int16 &AL_1_viewSquareExplosionIndex = viewSquareIndex;
-	// AL_2 shared
+	int16 AL_0_creatureGraphicInfoRed;
+	int16 AL_0_creatureIndexRed;
+#define AL_1_viewSquareExplosionIndex viewSquareIndex
 	int16 L0126_i_Multiple;
-	int16 &AL_2_viewCell = L0126_i_Multiple;
-	int16 &AL_2_cellPurpleMan = L0126_i_Multiple;
-	int16 &AL_2_explosionSize = L0126_i_Multiple;
-	// AL_4 shared
+#define AL_2_viewCell      L0126_i_Multiple
+#define AL_2_cellPurpleMan          L0126_i_Multiple
+#define AL_2_explosionSize L0126_i_Multiple
 	int16 L0127_i_Multiple;
-	int16 &AL_4_thingType = L0127_i_Multiple;
-	int16 &AL_4_nativeBitmapIndex = L0127_i_Multiple;
-	int16 &AL_4_xPos = L0127_i_Multiple;
-	int16 &AL_4_groupCells = L0127_i_Multiple;
-	int16 &AL_4_normalizdByteWidth = L0127_i_Multiple;
-	int16 &AL_4_yPos = L0127_i_Multiple;
-	int16 &AL_4_projectileAspect = L0127_i_Multiple;
-	int16 &AL_4_explosionType = L0127_i_Multiple;
-	int16 &AL_4_explosionAspectIndex = L0127_i_Multiple;
-	// AL_6 shared
-	byte *L0128_puc_Multiple;
-	byte *&AL_6_bitmapRedBanana = L0128_puc_Multiple;
-
-	ObjectAspect *objectAspect;
+#define AL_4_thingType            L0127_i_Multiple
+#define AL_4_nativeBitmapIndex    L0127_i_Multiple
+#define AL_4_xPos                    L0127_i_Multiple
+#define AL_4_groupCells           L0127_i_Multiple
+#define AL_4_normalizdByteWidth  L0127_i_Multiple
+#define AL_4_yPos                    L0127_i_Multiple
+#define AL_4_projectileAspect     L0127_i_Multiple
+#define AL_4_explosionType        L0127_i_Multiple
+#define AL_4_explosionAspectIndex L0127_i_Multiple
+	byte* L0128_puc_Multiple;
+#define AL_6_bitmapRedBanana L0128_puc_Multiple
+	ObjectAspect* objectAspect;
 	uint32 remainingViewCellOrdinalsToProcess;
 	byte* paletteChanges;
 	byte* bitmapGreenAnt;
 	byte* coordinateSet;
-	int16 derivedBitmapIndex;
-
+	int16 derivedBitmapIndex = - 1;
+	bool L0135_B_DrawAlcoveObjects;
 	int16 byteWidth;
 	int16 heightRedEagle;
 	int16 viewLane; /* The lane (center/left/right) that the specified square is part of */
 	int16 cellYellowBear;
 	int16 paddingPixelCount;
 	int16 heightGreenGoat;
-	bool useAlcoveObjectImage; /* C1_TRUE for objects that have a special graphic when drawn in an alcove, like the Chest */
+	bool useAlcoveObjectImage; /* true for objects that have a special graphic when drawn in an alcove, like the Chest */
 	bool flipHorizontal;
 	bool drawingGrabbableObject;
 	Box boxByteGreen;
 	Thing firstThingToDraw; /* Initialized to thingParam and never changed afterwards. Used as a backup of the specified first object to draw */
-
+	uint16 L0147_ui_Multiple;
+#define AL_10_viewSquareIndexBackup L0147_ui_Multiple
+#define AL_10_explosionScaleIndex   L0147_ui_Multiple
 	int16 cellCounter;
 	uint16 objectShiftIndex;
-
-	uint16 L0150_ui_Multiple;
-	uint16 &AL_8_shiftSetIndex = L0150_ui_Multiple;
-	uint16 &AL_8_projectileScaleIndex = L0150_ui_Multiple;
-
+	uint16 L0150_ui_Multiple = 0;
+#define AL_8_shiftSetIndex        L0150_ui_Multiple
+#define AL_8_projectileScaleIndex L0150_ui_Multiple
 	Thing groupThing;
 	Group* group;
 	ActiveGroup* activeGroup;
@@ -2949,10 +2944,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 	bool useCreatureSpecialD2FrontBitmap;
 	bool useCreatureAttackBitmap;
 	bool useFlippedHorizontallyCreatureFrontImage;
-
-/* Set to C1_TRUE when the last creature that the function should draw is being drawn. This is used to avoid processing the code to draw creatures for the remaining square cells */
-	bool drawCreaturesCompleted;
-
+	bool drawCreaturesCompleted; /* Set to true when the last creature that the function should draw is being drawn. This is used to avoid processing the code to draw creatures for the remaining square cells */
 	int16 doorFrontViewDrawingPass; /* Value 0, 1 or 2 */
 	int16 scale;
 	bool derivedBitmapInCache;
@@ -2961,12 +2953,9 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 	int16 projectilePosX;
 	int16 projectileDirection;
 	int16 projectileAspectType;
-	int16 projectileBitmapIndexData;
+	int16 projectileBitmapIndexDelta;
 	bool doNotScaleWithKineticEnergy;
-
-/* When true, the code section to draw an object is called (with a goto) to draw the projectile, then the code section goes back to projectile processing with another goto */
-	bool drawProjectileAsObject;
-
+	bool drawProjectileAsObject; /* When true, the code section to draw an object is called (with a goto) to draw the projectile, then the code section goes back to projectile processing with another goto */
 	bool sqaureHasProjectile;
 	uint16 currentViewCellToDraw = 0;
 	bool projectileFlipVertical = false;
@@ -2981,33 +2970,26 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 	bool smoke;
 	FieldAspect fieldAspect;
 
-
-	if (thingParam == Thing::_endOfList)
+	if (thingParam == Thing::_endOfList) {
 		return;
-
+	}
 	group = 0;
 	groupThing = Thing::_none;
 	drawCreaturesCompleted = sqaureHasProjectile = squareHasExplosion = false;
 	cellCounter = 0;
 	firstThingToDraw = thingParam;
 	if (getFlag(orderedViewCellOrdinals, k0x0008_CellOrder_DoorFront)) { /* If the function call is to draw objects on a door square viewed from the front */
-/* Two function calls are made in that case to draw objects on both sides of the door frame.
-The door and its frame are drawn between the two calls. This value indicates the drawing pass so that
-creatures are drawn in the right order and so that Fluxcages are not drawn twice */
-		doorFrontViewDrawingPass = (orderedViewCellOrdinals & 0x1) + 1;
-		orderedViewCellOrdinals >>= 4;	/* Remove the first nibble that was used for the door front view pass */
+		doorFrontViewDrawingPass = (orderedViewCellOrdinals & 0x0001) + 1; /* Two function calls are made in that case to draw objects on both sides of the door frame. The door and its frame are drawn between the two calls. This value indicates the drawing pass so that creatures are drawn in the right order and so that Fluxcages are not drawn twice */
+		orderedViewCellOrdinals >>= 4; /* Remove the first nibble that was used for the door front view pass */
 	} else {
-		doorFrontViewDrawingPass = 0;  /* The function call is not to draw objects on a door square viewed from the front */
+		doorFrontViewDrawingPass = 0; /* The function call is not to draw objects on a door square viewed from the front */
 	}
-
-	bool drawAlcoveObjects = !(remainingViewCellOrdinalsToProcess = orderedViewCellOrdinals);
-	uint16 viewSquareIndexBackup = viewSquareIndex;
+	L0135_B_DrawAlcoveObjects = !(remainingViewCellOrdinalsToProcess = orderedViewCellOrdinals);
+	AL_10_viewSquareIndexBackup = viewSquareIndex;
 	viewLane = (viewSquareIndex + 3) % 3;
-
-
 	do {
-/* Draw objects */
-		if (drawAlcoveObjects) {
+		/* Draw objects */
+		if (L0135_B_DrawAlcoveObjects) {
 			AL_2_viewCell = k4_ViewCellAlcove; /* Index of coordinates to draw objects in alcoves */
 			cellYellowBear = returnOppositeDir(directionParam); /* Alcove is on the opposite direction of the viewing direction */
 			objectShiftIndex = 2;
@@ -3016,12 +2998,11 @@ creatures are drawn in the right order and so that Fluxcages are not drawn twice
 			currentViewCellToDraw = AL_2_viewCell;
 			remainingViewCellOrdinalsToProcess >>= 4; /* Proceed to the next cell ordinal */
 			cellCounter++;
-			cellYellowBear = (AL_2_viewCell + directionParam) % 3; /* Convert view cell to absolute cell */
+			cellYellowBear = M21_normalizeModulo4(AL_2_viewCell + directionParam); /* Convert view cell to absolute cell */
 			thingParam = firstThingToDraw;
-			viewSquareIndex = viewSquareIndexBackup; /* Restore value as it may have been modified while drawing a creature */
+			viewSquareIndex = AL_10_viewSquareIndexBackup; /* Restore value as it may have been modified while drawing a creature */
 			objectShiftIndex = 0;
 		}
-
 		objectShiftIndex += (cellYellowBear & 0x0001) << 3;
 		drawProjectileAsObject = false;
 		do {
@@ -3037,12 +3018,10 @@ creatures are drawn in the right order and so that Fluxcages are not drawn twice
 				squareHasExplosion = true;
 				continue;
 			}
-
-			/* Square where objects are visible and object is located on cell being processed */
-			if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) {
-				objectAspect = &(g209_ObjectAspects[g237_ObjectInfo[dunMan.f141_getObjectInfoIndex(thingParam)]._objectAspectIndex]);
+			if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) { /* Square where objects are visible and object is located on cell being processed */
+				objectAspect = &(g209_ObjectAspects[g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thingParam)]._objectAspectIndex]);
 				AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex;
-				if (useAlcoveObjectImage = (drawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane)) {
+				if (useAlcoveObjectImage = (L0135_B_DrawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane)) {
 					AL_4_nativeBitmapIndex++;
 				}
 				coordinateSet = g218_ObjectCoordinateSets[objectAspect->_coordinateSet][viewSquareIndex][AL_2_viewCell];
@@ -3052,20 +3031,16 @@ T0115015_DrawProjectileAsObject:
 				flipHorizontal = getFlag(objectAspect->_graphicInfo, k0x0001_ObjectFlipOnRightMask) &&
 					!useAlcoveObjectImage &&
 					((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight))));
-				/* Flip horizontally if object graphic requires it and is not being drawn in an alcove and the object is
-				either on the right lane or on the right column of the center lane */
+				/* Flip horizontally if object graphic requires it and is not being drawn in an alcove and the object is either on the right lane or on the right column of the center lane */
 				paddingPixelCount = 0;
-
 				if ((viewSquareIndex == k9_ViewSquare_D0C) || ((viewSquareIndex >= k6_ViewSquare_D1C) && (AL_2_viewCell >= k2_ViewCellBackRight))) {
-					/* If object is in the center lane (only D0C or D1C with condition above) and is not a projectile */
-					drawingGrabbableObject = (!viewLane && !drawProjectileAsObject);
+					drawingGrabbableObject = (!viewLane && !drawProjectileAsObject); /* If object is in the center lane (only D0C or D1C with condition above) and is not a projectile */
 					AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
 					AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */
 					byteWidth = objectAspect->_byteWidth;
 					heightRedEagle = objectAspect->_height;
 					if (flipHorizontal) {
-						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * 2 * heightRedEagle * sizeof(byte));
-						f130_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
+						f99_copyBitmapAndFlipHorizontal(AL_6_bitmapRedBanana, _g74_tmpBitmap, byteWidth, heightRedEagle);
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
 				} else {
@@ -3086,21 +3061,20 @@ T0115015_DrawProjectileAsObject:
 					if (flipHorizontal) {
 						derivedBitmapIndex += 2;
 						paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1;
-					} else if (useAlcoveObjectImage) {
-						derivedBitmapIndex += 4;
+					} else {
+						if (useAlcoveObjectImage) {
+							derivedBitmapIndex += 4;
+						}
 					}
-
 					if (f491_isDerivedBitmapInCache(derivedBitmapIndex)) {
 						AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 					} else {
 						bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
-						f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex),
-															 objectAspect->_byteWidth * 2, objectAspect->_height,
-															 byteWidth * 2, heightRedEagle, paletteChanges);
+						f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), objectAspect->_byteWidth << 1, objectAspect->_height, byteWidth << 1, heightRedEagle, paletteChanges);
 						if (flipHorizontal) {
 							f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, M77_getNormalizedByteWidth(byteWidth), heightRedEagle);
 						}
-						warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+						f493_addDerivedBitmap(derivedBitmapIndex);
 					}
 				}
 				AL_4_xPos = coordinateSet[0];
@@ -3109,7 +3083,7 @@ T0115015_DrawProjectileAsObject:
 					AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][g217_ObjectPileShiftSetIndices[objectShiftIndex][0]];
 					boxByteGreen._y2 += g223_ShiftSets[AL_8_shiftSetIndex][g217_ObjectPileShiftSetIndices[objectShiftIndex][1]];
 					objectShiftIndex++; /* The next object drawn will use the next shift values */
-					if (drawAlcoveObjects) {
+					if (L0135_B_DrawAlcoveObjects) {
 						if (objectShiftIndex >= 14) {
 							objectShiftIndex = 2;
 						}
@@ -3122,7 +3096,7 @@ T0115015_DrawProjectileAsObject:
 					boxByteGreen._y2 = 135;
 				}
 				boxByteGreen._x2 = MIN(223, AL_4_xPos + byteWidth);
-				if (boxByteGreen._x1 = MAX(0, AL_4_xPos - byteWidth)) {
+				if (boxByteGreen._x1 = MAX(0, AL_4_xPos - byteWidth + 1)) {
 					if (flipHorizontal) {
 						AL_4_xPos = paddingPixelCount;
 					} else {
@@ -3131,139 +3105,134 @@ T0115015_DrawProjectileAsObject:
 				} else {
 					AL_4_xPos = byteWidth - AL_4_xPos - 1;
 				}
-
 				if (drawingGrabbableObject) {
 					bitmapGreenAnt = AL_6_bitmapRedBanana;
-					Box *AL_6_boxPtrRed = &dunMan._g291_dungeonViewClickableBoxes[AL_2_viewCell];
-					if (AL_6_boxPtrRed->_x1 == 255) { /* If the grabbable object is the first */
-						*AL_6_boxPtrRed = boxByteGreen;
 
-						if ((heightGreenGoat = AL_6_boxPtrRed->_y2 - AL_6_boxPtrRed->_y1) < 14) { /* If the box is too small then enlarge it a little */
+					Box *AL_6_box = &_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[AL_2_viewCell];
+
+					if (AL_6_box->_x1 == 255) { /* If the grabbable object is the first */
+						*AL_6_box = boxByteGreen;
+						if ((heightGreenGoat = AL_6_box->_y2 - AL_6_box->_y1) < 14) { /* If the box is too small then enlarge it a little */
 							heightGreenGoat = heightGreenGoat >> 1;
-							AL_6_boxPtrRed->_y1 += heightGreenGoat - 7;
+							AL_6_box->_y1 += heightGreenGoat - 7;
 							if (heightGreenGoat < 4) {
-								AL_6_boxPtrRed->_y2 -= heightGreenGoat - 3;
+								AL_6_box->_y2 -= heightGreenGoat - 3;
 							}
 						}
 					} else { /* If there are several grabbable objects then enlarge the box so it includes all objects */
-						AL_6_boxPtrRed->_x1 = MIN(AL_6_boxPtrRed->_x1, boxByteGreen._x1);
-						AL_6_boxPtrRed->_x2 = MAX(AL_6_boxPtrRed->_x2, boxByteGreen._x2);
-						AL_6_boxPtrRed->_y1 = MIN(AL_6_boxPtrRed->_y1, boxByteGreen._y1);
-						AL_6_boxPtrRed->_y2 = MAX(AL_6_boxPtrRed->_y2, boxByteGreen._y2);
+						AL_6_box->_x1 = MIN(AL_6_box->_x1, boxByteGreen._x1);
+						AL_6_box->_x2 = MAX(AL_6_box->_x2, boxByteGreen._x2);
+						AL_6_box->_y1 = MIN(AL_6_box->_y1, boxByteGreen._y1);
+						AL_6_box->_y2 = MAX(AL_6_box->_y2, boxByteGreen._y2);
 					}
 					AL_6_bitmapRedBanana = bitmapGreenAnt;
-					dunMan._g292_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */
+					_vm->_dungeonMan->_g292_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */
 				}
-				f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh);
-
+				f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
 				if (drawProjectileAsObject)
 					goto T0115171_BackFromT0115015_DrawProjectileAsObject;
 			}
-		} while ((thingParam = dunMan.f159_getNextThing(thingParam)) != Thing::_endOfList);
+		} while ((thingParam = _vm->_dungeonMan->f159_getNextThing(thingParam)) != Thing::_endOfList);
 		if (AL_2_viewCell == k4_ViewCellAlcove)
 			break; /* End of processing when drawing objects in an alcove */
 		if (viewSquareIndex < k0_ViewSquare_D3C)
 			break; /* End of processing if square is too far away at D4 */
 				   /* Draw creatures */
-
-		/* If (draw cell on the back row or second cell being processed) and (no more cells to draw or next cell to draw is a cell on the front row) */
-		drawingLastBackRowCell = ((AL_2_viewCell <= k1_ViewCellFrontRight) || (cellCounter == 1))
-			&& (!remainingViewCellOrdinalsToProcess || ((remainingViewCellOrdinalsToProcess & 0x0000000F) >= 3));
-
+		drawingLastBackRowCell = ((AL_2_viewCell <= k1_ViewCellFrontRight) || (cellCounter == 1)) && (!remainingViewCellOrdinalsToProcess || ((remainingViewCellOrdinalsToProcess & 0x0000000F) >= 3)); /* If (draw cell on the back row or second cell being processed) and (no more cells to draw or next cell to draw is a cell on the front row) */
 		if ((groupThing == Thing::_none) || drawCreaturesCompleted)
 			goto T0115129_DrawProjectiles; /* Skip code to draw creatures */
-		if (group == nullptr) { /* If all creature data and info has not already been gathered */
-			group = (Group *)dunMan.f156_getThingData(groupThing);
+		if (group == 0) { /* If all creature data and info has not already been gathered */
+			group = (Group*)_vm->_dungeonMan->f156_getThingData(groupThing);
 			activeGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
 			creatureInfo = &g243_CreatureInfo[group->_type];
 			creatureAspectStruct = &g219_CreatureAspects[creatureInfo->_creatureAspectIndex];
 			creatureSize = getFlag(creatureInfo->_attributes, k0x0003_MaskCreatureInfo_size);
 			creatureGraphicInfoGreen = creatureInfo->_graphicInfo;
 		}
-		objectAspect = (ObjectAspect *)creatureAspectStruct;
+		objectAspect = (ObjectAspect*)creatureAspectStruct;
 		if (AL_0_creatureIndexRed = _vm->_groupMan->f176_getCreatureOrdinalInCell(group, cellYellowBear)) { /* If there is a creature on the cell being processed */
 			AL_0_creatureIndexRed--; /* Convert ordinal to index */
 			creatureIndexGreen = AL_0_creatureIndexRed;
-		} else if (creatureSize == k1_MaskCreatureSizeHalf) {
-			AL_0_creatureIndexRed = 0;
-			creatureIndexGreen = -1;
 		} else {
-			goto T0115129_DrawProjectiles; /* No creature to draw at cell, skip to projectiles */
+			if (creatureSize == k1_MaskCreatureSizeHalf) {
+				AL_0_creatureIndexRed = 0;
+				creatureIndexGreen = -1;
+			} else {
+				goto T0115129_DrawProjectiles; /* No creature to draw at cell, skip to projectiles */
+			}
 		}
-
-		creatureDirectionDelta = (directionParam - _vm->_groupMan->M50_getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed)) % 3;
+		creatureDirectionDelta = M21_normalizeModulo4(directionParam - _vm->_groupMan->M50_getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed));
 		twoHalfSquareCreaturesFrontView = false;
 		if ((AL_4_groupCells = activeGroup->_cells) == k255_CreatureTypeSingleCenteredCreature) { /* If there is a single centered creature in the group */
 			if (remainingViewCellOrdinalsToProcess || (doorFrontViewDrawingPass == 1))
-/* Do not draw a single centered creature now, wait until second pass (for a front view door)
- or until all cells have been drawn so the creature is drawn over all the objects on the floor */
-				goto T0115129_DrawProjectiles;
+				goto T0115129_DrawProjectiles; /* Do not draw a single centered creature now, wait until second pass (for a front view door) or until all cells have been drawn so the creature is drawn over all the objects on the floor */
 			drawCreaturesCompleted = true;
 			if ((creatureSize == k1_MaskCreatureSizeHalf) && (creatureDirectionDelta & 0x0001)) { /* Side view of half square creature */
 				AL_2_viewCell = k3_HalfSizedViewCell_CenterColumn;
 			} else {
 				AL_2_viewCell = k4_HalfSizedViewCell_FrontRow;
 			}
-		} else if ((creatureSize == k1_MaskCreatureSizeHalf) && (drawingLastBackRowCell || !remainingViewCellOrdinalsToProcess || (creatureIndexGreen < 0))) {
-			if (drawingLastBackRowCell && (doorFrontViewDrawingPass != 2)) {
-				if ((creatureIndexGreen >= 0) && (creatureDirectionDelta & 0x0001)) {
-					AL_2_viewCell = k2_HalfSizedViewCell_BackRow; /* Side view of a half square creature on the back row. Drawn during pass 1 for a door square */
-				} else {
-					goto T0115129_DrawProjectiles;
-				}
-			} else if ((doorFrontViewDrawingPass != 1) && !remainingViewCellOrdinalsToProcess) {
-				if (creatureDirectionDelta & 0x0001) {
-					if (creatureIndexGreen >= 0) {
-						AL_2_viewCell = k4_HalfSizedViewCell_FrontRow; /* Side view of a half square creature on the front row. Drawn during pass 2 for a door square */
+		} else {
+			if ((creatureSize == k1_MaskCreatureSizeHalf) && (drawingLastBackRowCell || !remainingViewCellOrdinalsToProcess || (creatureIndexGreen < 0))) {
+				if (drawingLastBackRowCell && (doorFrontViewDrawingPass != 2)) {
+					if ((creatureIndexGreen >= 0) && (creatureDirectionDelta & 0x0001)) {
+						AL_2_viewCell = k2_HalfSizedViewCell_BackRow; /* Side view of a half square creature on the back row. Drawn during pass 1 for a door square */
 					} else {
 						goto T0115129_DrawProjectiles;
 					}
 				} else {
-					drawCreaturesCompleted = true;
-					if (creatureIndexGreen < 0) {
-						creatureIndexGreen = 0;
-					}
-					twoHalfSquareCreaturesFrontView = group->getCount();
-					if (((AL_4_groupCells = _vm->_groupMan->M50_getCreatureValue(AL_4_groupCells, AL_0_creatureIndexRed)) == directionParam)
-						|| (AL_4_groupCells == returnPrevVal(directionParam))) {
-						AL_2_viewCell = k0_HalfSizedViewCell_LeftColumn;
+					if ((doorFrontViewDrawingPass != 1) && !remainingViewCellOrdinalsToProcess) {
+						if (creatureDirectionDelta & 0x0001) {
+							if (creatureIndexGreen >= 0) {
+								AL_2_viewCell = k4_HalfSizedViewCell_FrontRow; /* Side view of a half square creature on the front row. Drawn during pass 2 for a door square */
+							} else {
+								goto T0115129_DrawProjectiles;
+							}
+						} else {
+							drawCreaturesCompleted = true;
+							if (creatureIndexGreen < 0) {
+								creatureIndexGreen = 0;
+							}
+							twoHalfSquareCreaturesFrontView = group->getCount();
+							if (((AL_4_groupCells = _vm->_groupMan->M50_getCreatureValue(AL_4_groupCells, AL_0_creatureIndexRed)) == directionParam) || (AL_4_groupCells == returnPrevVal(directionParam))) {
+
+								AL_2_viewCell = k0_HalfSizedViewCell_LeftColumn;
+							} else {
+								AL_2_viewCell = k1_HalfSizedViewCell_RightColumn;
+							}
+						}
 					} else {
-						AL_2_viewCell = k1_HalfSizedViewCell_RightColumn;
+						goto T0115129_DrawProjectiles;
 					}
 				}
 			} else {
-				goto T0115129_DrawProjectiles;
+				if (creatureSize != k0_MaskCreatureSizeQuarter)
+					goto T0115129_DrawProjectiles;
 			}
-
-		} else if (creatureSize != k0_MaskCreatureSizeQuarter)
-			goto T0115129_DrawProjectiles;
-
-
+		}
 		creatureAspectInt = activeGroup->_aspect[creatureIndexGreen];
 		if (viewSquareIndex > k9_ViewSquare_D0C) {
 			viewSquareIndex--;
 		}
 T0115077_DrawSecondHalfSquareCreature:
-		coordinateSet = g224_CreatureCoordinateSets[((CreatureAspect *)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell];
+		coordinateSet = g224_CreatureCoordinateSets[((CreatureAspect*)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell];
 		if (!coordinateSet[1])
 			goto T0115126_CreatureNotVisible;
 		AL_0_creatureGraphicInfoRed = creatureGraphicInfoGreen;
-		AL_4_nativeBitmapIndex = k446_FirstCreatureGraphicIndice + ((CreatureAspect *)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */
-		derivedBitmapIndex = ((CreatureAspect *)objectAspect)->_firstDerivedBitmapIndex;
+		AL_4_nativeBitmapIndex = k446_FirstCreatureGraphicIndice + ((CreatureAspect*)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */
+		derivedBitmapIndex = ((CreatureAspect*)objectAspect)->_firstDerivedBitmapIndex;
 		if (useCreatureSideBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide) && (creatureDirectionDelta & 0x0001)) {
 			useCreatureAttackBitmap = useFlippedHorizontallyCreatureFrontImage = useCreatureBackBitmap = false;
 			AL_4_nativeBitmapIndex++; /* Skip the front image. Side image is right after the front image */
 			derivedBitmapIndex += 2;
-			sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthSide;
-			sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightSide;
+			sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthSide;
+			sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightSide;
 		} else {
 			useCreatureBackBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack) && (creatureDirectionDelta == 0);
-			if (useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, k0x0080_MaskActiveGroupIsAttacking)
-				&& getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack)) {
-
+			if (useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, k0x0080_MaskActiveGroupIsAttacking) && getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack)) {
 				useFlippedHorizontallyCreatureFrontImage = false;
-				sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthAttack;
-				sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightAttack;
+				sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthAttack;
+				sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightAttack;
 				AL_4_nativeBitmapIndex++; /* Skip the front image */
 				derivedBitmapIndex += 2;
 				if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) {
@@ -3275,8 +3244,8 @@ T0115077_DrawSecondHalfSquareCreature:
 					derivedBitmapIndex += 2;
 				}
 			} else {
-				sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthFront;
-				sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightFront;
+				sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthFront;
+				sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightFront;
 				if (useCreatureBackBitmap) {
 					useFlippedHorizontallyCreatureFrontImage = false;
 					if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) {
@@ -3287,8 +3256,7 @@ T0115077_DrawSecondHalfSquareCreature:
 						derivedBitmapIndex += 2;
 					}
 				} else {
-					if (useFlippedHorizontallyCreatureFrontImage = getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)
-						&& getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
+					if (useFlippedHorizontallyCreatureFrontImage = getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack) && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
 						derivedBitmapIndex += 2;
 						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) {
 							derivedBitmapIndex += 2;
@@ -3306,20 +3274,18 @@ T0115077_DrawSecondHalfSquareCreature:
 		if (viewSquareIndex >= k6_ViewSquare_D1C) { /* Creature is on D1 */
 			creaturePaddingPixelCount = 0;
 			AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
-			transparentColor = ((CreatureAspect *)objectAspect)->getTranspColour();
+			transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour();
 			if (useCreatureSideBitmap) {
 				AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 				if (creatureDirectionDelta == 1) {
-					memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * 2 * heightRedEagle * sizeof(byte));
-					f130_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
+					f99_copyBitmapAndFlipHorizontal(AL_6_bitmapRedBanana, _g74_tmpBitmap, byteWidth, heightRedEagle);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
 			} else {
 				if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) {
 					AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 					if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
-						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * 2 * heightRedEagle * sizeof(byte));
-						f130_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle);
+						f99_copyBitmapAndFlipHorizontal(AL_6_bitmapRedBanana, _g74_tmpBitmap, byteWidth, heightRedEagle);
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
 				} else { /* Use first additional derived graphic: front D1 */
@@ -3328,11 +3294,9 @@ T0115077_DrawSecondHalfSquareCreature:
 					} else {
 						bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) {
-							AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
-							memmove(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * 2 * heightRedEagle * sizeof(byte));
-							f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
+							f99_copyBitmapAndFlipHorizontal(bitmapGreenAnt, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), byteWidth, heightRedEagle);
 						}
-						warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+						f493_addDerivedBitmap(derivedBitmapIndex);
 					}
 				}
 			}
@@ -3343,8 +3307,7 @@ T0115077_DrawSecondHalfSquareCreature:
 			if (viewSquareIndex >= k3_ViewSquare_D2C) { /* Creature is on D2 */
 				derivedBitmapIndex++; /* Skip front D3 image in additional graphics */
 				AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front;
-				useCreatureSpecialD2FrontBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0080_CreatureInfoGraphicMaskSpecialD2Front)
-					&& !useCreatureSideBitmap && !useCreatureBackBitmap && !useCreatureAttackBitmap;
+				useCreatureSpecialD2FrontBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0080_CreatureInfoGraphicMaskSpecialD2Front) && !useCreatureSideBitmap && !useCreatureBackBitmap && !useCreatureAttackBitmap;
 				paletteChanges = g222_PalChangesCreature_D2;
 				scale = k20_Scale_D2;
 			} else { /* Creature is on D3 */
@@ -3355,14 +3318,13 @@ T0115077_DrawSecondHalfSquareCreature:
 			}
 			byteWidth = M78_getScaledDimension(sourceByteWidth, scale);
 			heightRedEagle = M78_getScaledDimension(sourceHeight, scale);
-			transparentColor = paletteChanges[((CreatureAspect *)objectAspect)->getTranspColour()] / 10;
+			transparentColor = paletteChanges[((CreatureAspect*)objectAspect)->getTranspColour()] / 10;
 			if (derivedBitmapInCache = f491_isDerivedBitmapInCache(derivedBitmapIndex)) {
 				AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 			} else {
 				bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
-				AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, sourceByteWidth * 2, sourceHeight, byteWidth * 2, heightRedEagle, paletteChanges);
-				warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+				f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), sourceByteWidth << 1, sourceHeight, byteWidth << 1, heightRedEagle, paletteChanges);
+				f493_addDerivedBitmap(derivedBitmapIndex);
 			}
 			if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */
 				(useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) ||
@@ -3371,7 +3333,7 @@ T0115077_DrawSecondHalfSquareCreature:
 				if (!useFlippedHorizontallyCreatureFrontImage || !derivedBitmapInCache) {
 					AL_4_normalizdByteWidth = M77_getNormalizedByteWidth(byteWidth);
 					if (!useFlippedHorizontallyCreatureFrontImage) {
-						memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * 2 * heightRedEagle * sizeof(byte));
+						memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, sizeof(byte) * AL_4_normalizdByteWidth * heightRedEagle);
 						AL_6_bitmapRedBanana = _g74_tmpBitmap;
 					}
 					f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
@@ -3394,17 +3356,17 @@ T0115077_DrawSecondHalfSquareCreature:
 				AL_4_xPos += 100;
 			}
 		}
-		if (!(boxByteGreen._x2 = MIN(MAX(0, AL_4_xPos + byteWidth), 223)))
+		if (!(boxByteGreen._x2 = f26_getBoundedValue(0, AL_4_xPos + byteWidth, 223)))
 			goto T0115126_CreatureNotVisible;
-		if (boxByteGreen._x1 = MIN(MAX(0, AL_4_xPos - byteWidth + 1), 223)) {
+		int16 AL_0_creaturePosX;
+		if (boxByteGreen._x1 = f26_getBoundedValue(0, AL_4_xPos - byteWidth + 1, 223)) {
 			if (boxByteGreen._x1 == 223)
 				goto T0115126_CreatureNotVisible;
 			AL_0_creaturePosX = creaturePaddingPixelCount;
 		} else {
 			AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1);
 		}
-		f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_0_creaturePosX, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, (Color)transparentColor);
-
+		f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_0_creaturePosX, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, (Color)transparentColor, heightRedEagle, 136);
 T0115126_CreatureNotVisible:
 		if (twoHalfSquareCreaturesFrontView) {
 			twoHalfSquareCreaturesFrontView = false;
@@ -3418,47 +3380,41 @@ T0115126_CreatureNotVisible:
 		}
 		/* Draw projectiles */
 T0115129_DrawProjectiles:
-		if (!sqaureHasProjectile
-			|| ((viewSquareIndex = viewSquareIndexBackup) > k9_ViewSquare_D0C)
-/* If there is no projectile to draw or if projectiles are not visible on the specified square or on the cell being drawn */
-|| (!(projectilePosX = g218_ObjectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0])))
-continue;
+		if (!sqaureHasProjectile || ((viewSquareIndex = AL_10_viewSquareIndexBackup) > k9_ViewSquare_D0C) || (!(projectilePosX = g218_ObjectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0]))) /* If there is no projectile to draw or if projectiles are not visible on the specified square or on the cell being drawn */
+			continue;
 		thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */
-
 		do {
 			if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) {
-				projectile = (Projectile *)dunMan.f156_getThingData(thingParam);
-				if ((AL_4_projectileAspect = dunMan.f142_getProjectileAspect(projectile->_slot)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
-					objectAspect = (ObjectAspect *)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-AL_4_projectileAspect)];
-					AL_4_nativeBitmapIndex = ((ProjectileAspect *)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
-					projectileAspectType = getFlag(((ProjectileAspect *)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
-					if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect *)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask))
-						 || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == k9_ViewSquare_D0C)) {
+				projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(thingParam);
+				if ((AL_4_projectileAspect = _vm->_dungeonMan->f142_getProjectileAspect(projectile->_slot)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
+					objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-AL_4_projectileAspect)];
+					AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
+					projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
+					if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask)) || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == k9_ViewSquare_D0C)) {
 						scale = 0; /* Use native bitmap without resizing */
-						byteWidth = ((ProjectileAspect *)objectAspect)->_byteWidth;
-						heightRedEagle = ((ProjectileAspect *)objectAspect)->_height;
+						byteWidth = ((ProjectileAspect*)objectAspect)->_byteWidth;
+						heightRedEagle = ((ProjectileAspect*)objectAspect)->_height;
 					} else {
 						AL_8_projectileScaleIndex = ((viewSquareIndex / 3) << 1) + (AL_2_viewCell >> 1);
 						scale = g215_ProjectileScales[AL_8_projectileScaleIndex];
 						if (!doNotScaleWithKineticEnergy) {
 							scale = (scale * MAX(96, projectile->_kineticEnergy + 1)) >> 8;
 						}
-						byteWidth = M78_getScaledDimension(((ProjectileAspect *)objectAspect)->_byteWidth, scale);
-						heightRedEagle = M78_getScaledDimension(((ProjectileAspect *)objectAspect)->_height, scale);
+						byteWidth = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_byteWidth, scale);
+						heightRedEagle = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale);
 					}
 					if (projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == k0_ProjectileAspectHasBackGraphicRotation)) {
 						projectileFlipVertical = ((mapXpos + mapYpos) & 0x0001);
 					}
 					if (projectileAspectType == k3_ProjectileAspectHasNone) {
-						projectileBitmapIndexData = 0;
+						projectileBitmapIndexDelta = 0;
 						flipVertical = flipHorizontal = false;
 					} else {
-						if (isOrientedWestEast((Direction)(projectileDirection = _vm->_timeline->_g370_events[projectile->_eventIndex]._C._projectile.getDir()))
-							!= isOrientedWestEast(directionParam)) {
+						if (isOrientedWestEast(Direction(projectileDirection = _vm->_timeline->_g370_events[projectile->_eventIndex]._C._projectile.getDir())) != isOrientedWestEast(directionParam)) {
 							if (projectileAspectType == k2_ProjectileAspectHasRotation) {
-								projectileBitmapIndexData = 1;
+								projectileBitmapIndexDelta = 1;
 							} else {
-								projectileBitmapIndexData = 2;
+								projectileBitmapIndexDelta = 2;
 							}
 							if (projectileAspectTypeHasBackGraphicAndRotation) {
 								flipHorizontal = !AL_2_viewCell || (AL_2_viewCell == k3_ViewCellBackLeft);
@@ -3470,20 +3426,16 @@ continue;
 								flipHorizontal = (returnNextVal(directionParam) == projectileDirection);
 							}
 						} else {
-/* If the projectile does not have a back graphic or has one but is not seen from the back or if it has a back graphic and rotation and should be flipped vertically */
-							if ((projectileAspectType >= k2_ProjectileAspectHasRotation)
-								|| ((projectileAspectType == k1_ProjectileAspectBackGraphic)
-									&& (projectileDirection != directionParam)) || (projectileAspectTypeHasBackGraphicAndRotation && projectileFlipVertical)) {
-								projectileBitmapIndexData = 0;
+							if ((projectileAspectType >= k2_ProjectileAspectHasRotation) || ((projectileAspectType == k1_ProjectileAspectBackGraphic) && (projectileDirection != directionParam)) || (projectileAspectTypeHasBackGraphicAndRotation && projectileFlipVertical)) { /* If the projectile does not have a back graphic or has one but is not seen from the back or if it has a back graphic and rotation and should be flipped vertically */
+								projectileBitmapIndexDelta = 0;
 							} else {
-								projectileBitmapIndexData = 1;
+								projectileBitmapIndexDelta = 1;
 							}
 							flipVertical = projectileAspectTypeHasBackGraphicAndRotation && (AL_2_viewCell < k2_ViewCellBackRight);
-							flipHorizontal = getFlag(((ProjectileAspect *)objectAspect)->_graphicInfo, k0x0010_ProjectileSideMask)
-								&& !((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight))));
+							flipHorizontal = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0010_ProjectileSideMask) && !((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight))));
 						}
 					}
-					AL_4_nativeBitmapIndex += projectileBitmapIndexData;
+					AL_4_nativeBitmapIndex += projectileBitmapIndexDelta;
 					paddingPixelCount = 0;
 					if (!scale) {
 						AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
@@ -3491,8 +3443,7 @@ continue;
 						if (flipHorizontal) {
 							paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1;
 						}
-						derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect *)objectAspect)->_firstNativeBitmapRelativeIndex + (projectileBitmapIndexData * 6);
-						if (doNotScaleWithKineticEnergy && f491_isDerivedBitmapInCache(derivedBitmapIndex) + AL_8_projectileScaleIndex) {
+						if (doNotScaleWithKineticEnergy && f491_isDerivedBitmapInCache(derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstDerivedBitmapRelativeIndex + (projectileBitmapIndexDelta * 6) + AL_8_projectileScaleIndex)) {
 							AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 						} else {
 							bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
@@ -3501,17 +3452,16 @@ continue;
 							} else {
 								AL_6_bitmapRedBanana = _g74_tmpBitmap;
 							}
-							f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect *)objectAspect)->_byteWidth * 2, ((ProjectileAspect *)objectAspect)->_height,
-																 byteWidth * 2, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
+							f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
 							if (doNotScaleWithKineticEnergy) {
-								warning(false, "IGNORED CODE F0493_CACHE_AddDerivedBitmap");
+								f493_addDerivedBitmap(derivedBitmapIndex);
 							}
 						}
 					}
 					if (flipHorizontal || flipVertical) {
 						AL_4_normalizdByteWidth = M77_getNormalizedByteWidth(byteWidth);
 						if (AL_6_bitmapRedBanana != _g74_tmpBitmap) {
-							memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * 2 * heightRedEagle * sizeof(byte));
+							memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, sizeof(byte) * AL_4_normalizdByteWidth * heightRedEagle);
 							AL_6_bitmapRedBanana = _g74_tmpBitmap;
 						}
 						if (flipVertical) {
@@ -3531,13 +3481,10 @@ continue;
 							AL_4_xPos = 0;
 						}
 					} else {
-/* BUG0_06 Graphical glitch when drawing projectiles or explosions. If a projectile or explosion bitmap
-is cropped because it is only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and
-the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part of the bitmap is drawn on
-screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
-						AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - projectilePosX - 1));
+						AL_4_xPos = MAX(paddingPixelCount, int16(byteWidth - projectilePosX - 1)); /* BUG0_06 Graphical glitch when drawing projectiles or explosions. If a projectile or explosion bitmap is cropped because it is only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is flipped horizontally (flipHorizontal = true) then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
+
 					}
-					f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh);
+					f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
 				} else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */
 					useAlcoveObjectImage = false;
 					projectileCoordinates[0] = projectilePosX;
@@ -3546,31 +3493,24 @@ screen. To fix this bug, "+ paddingPixelCount" must be added to the second param
 					objectAspect = &g209_ObjectAspects[AL_4_projectileAspect];
 					AL_4_nativeBitmapIndex = objectAspect->_firstNativeBitmapRelativeIndex + k360_FirstObjectGraphicIndice;
 					drawProjectileAsObject = true;
-/* Go to code section to draw an object. Once completed, it jumps back to T0115171_BackFromT0115015_DrawProjectileAsObject below */
-					goto T0115015_DrawProjectileAsObject;
+					goto T0115015_DrawProjectileAsObject; /* Go to code section to draw an object. Once completed, it jumps back to T0115171_BackFromT0115015_DrawProjectileAsObject below */
 				}
 			}
 T0115171_BackFromT0115015_DrawProjectileAsObject:;
-		} while ((thingParam = dunMan.f159_getNextThing(thingParam)) != Thing::_endOfList);
-
+		} while ((thingParam = _vm->_dungeonMan->f159_getNextThing(thingParam)) != Thing::_endOfList);
 	} while (remainingViewCellOrdinalsToProcess);
-
-
 	/* Draw explosions */
 	if (!squareHasExplosion)
-		return;
+		goto T0115214_Return;
 	fluxcageExplosion = 0;
-	AL_1_viewSquareExplosionIndex = viewSquareIndexBackup + 3; /* Convert square index to square index for explosions */
-	uint16 explosionScaleIndex = AL_1_viewSquareExplosionIndex / 3;
+	AL_1_viewSquareExplosionIndex = AL_10_viewSquareIndexBackup + 3; /* Convert square index to square index for explosions */
+	AL_10_explosionScaleIndex = AL_1_viewSquareExplosionIndex / 3;
 	thingParam = firstThingToDraw; /* Restart processing list of things from the beginning. The next loop draws only explosion things among the list */
 	do {
 		if (thingParam.getType() == k15_ExplosionThingType) {
 			AL_2_cellPurpleMan = thingParam.getCell();
-			explosion = (Explosion *)dunMan.f156_getThingData(thingParam);
-			if ((rebirthExplosion = ((unsigned int)(AL_4_explosionType = explosion->getType()) >= k100_ExplosionType_RebirthStep1))
-				&& ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion)
-					|| (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion)
-					|| (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */
+			explosion = (Explosion*)_vm->_dungeonMan->f156_getThingData(thingParam);
+			if ((rebirthExplosion = ((uint16)(AL_4_explosionType = explosion->getType()) >= k100_ExplosionType_RebirthStep1)) && ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion) || (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion) || (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */
 				continue;
 			smoke = false;
 			if ((AL_4_explosionType == k0_ExplosionType_Fireball) || (AL_4_explosionType == k2_ExplosionType_LightningBolt) || (AL_4_explosionType == k101_ExplosionType_RebirthStep2)) {
@@ -3584,15 +3524,13 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 						AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke;
 					} else {
 						if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) {
-							objectAspect = (ObjectAspect *)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-dunMan.f142_getProjectileAspect(Thing::_explLightningBolt))];
-							AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(((ProjectileAspect *)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
+							objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-_vm->_dungeonMan->f142_getProjectileAspect(Thing::_explLightningBolt))];
+							AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
 							explosionCoordinates = g228_RebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
-							byteWidth = M78_getScaledDimension((((ProjectileAspect *)objectAspect)->_byteWidth), explosionCoordinates[2]);
-							heightRedEagle = M78_getScaledDimension((((ProjectileAspect *)objectAspect)->_height), explosionCoordinates[2]);
+							byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_byteWidth), explosionCoordinates[2]);
+							heightRedEagle = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
 							if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) {
-								f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap,
-									((ProjectileAspect *)objectAspect)->_byteWidth * 2, ((ProjectileAspect *)objectAspect)->_height,
-																	 byteWidth * 2, heightRedEagle, g17_PalChangesNoChanges);
+								f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, g17_PalChangesNoChanges);
 								AL_6_bitmapRedBanana = _g74_tmpBitmap;
 							}
 							goto T0115200_DrawExplosion;
@@ -3618,17 +3556,15 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 						AL_4_explosionAspectIndex++; /* Use third graphic in the pattern for large explosion attack */
 					}
 				}
-				warning(false, "IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache");
+				f491_isDerivedBitmapInCache(k0_DerivedBitmapViewport);
 				AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice);
 				if (smoke) {
 					f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, 48, 32, 48, 32, g212_PalChangeSmoke);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
-				f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, nullptr, f492_getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C,
-												   _vm->getRandomNumber(4) + 87, _vm->getRandomNumber(64),
-												   224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
-				warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
-				warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap");
+				f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, 0, f492_getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C, _vm->getRandomNumber(4) + 87, _vm->getRandomNumber(64), k112_byteWidthViewport, Color(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
+				f493_addDerivedBitmap(k0_DerivedBitmapViewport);
+				f480_releaseBlock(k0_DerivedBitmapViewport | 0x8000);
 			} else {
 				if (rebirthExplosion) {
 					explosionCoordinates = g227_RebirthStep2ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
@@ -3644,7 +3580,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 						}
 						explosionCoordinates = g226_ExplosionCoordinates[AL_1_viewSquareExplosionIndex][AL_2_viewCell];
 					}
-					explosionScale = MAX(4, (MAX(48, explosion->getAttack() + 1) * g216_ExplosionBaseScales[explosionScaleIndex]) >> 8) & (int16)0xFFFE;
+					explosionScale = MAX(4, (MAX(48, explosion->getAttack() + 1) * g216_ExplosionBaseScales[AL_10_explosionScaleIndex]) >> 8) & (int)0xFFFE;
 				}
 				AL_6_bitmapRedBanana = f114_getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle);
 T0115200_DrawExplosion:
@@ -3662,24 +3598,18 @@ T0115200_DrawExplosion:
 					continue;
 				boxByteGreen._x2 = AL_4_xPos;
 				AL_4_xPos = explosionCoordinates[0];
-				if (boxByteGreen._x1 = MIN(MAX(0, AL_4_xPos - byteWidth + 1), 223)) {
+				if (boxByteGreen._x1 = f26_getBoundedValue(0, AL_4_xPos - byteWidth + 1, 223)) {
 					AL_4_xPos = paddingPixelCount;
 				} else {
-/* BUG0_07 Graphical glitch when drawing explosions. If an explosion bitmap is cropped because it is only partly visible on the
-left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is not flipped horizontally (flipHorizontal = C0_FALSE) then the
-variable paddingPixelCount is not set before being used here. Its previous value (defined while drawing something else) is used
-and may cause an incorrect bitmap to be drawn */
-					AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - AL_4_xPos - 1));
-
-/* BUG0_06 Graphical glitch when drawing projectiles or explosions. If a projectile or explosion bitmap is cropped because it is
-only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is flipped horizontally (flipHorizontal = C1_TRUE)
-then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
+					AL_4_xPos = MAX(paddingPixelCount, int16(byteWidth - AL_4_xPos - 1)); /* BUG0_07 Graphical glitch when drawing explosions. If an explosion bitmap is cropped because it is only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is not flipped horizontally (flipHorizontal = false) then the variable paddingPixelCount is not set before being used here. Its previous value (defined while drawing something else) is used and may cause an incorrect bitmap to be drawn */
+
+																				   /* BUG0_06 Graphical glitch when drawing projectiles or explosions. If a projectile or explosion bitmap is cropped because it is only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is flipped horizontally (flipHorizontal = true) then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
 				}
 				if (boxByteGreen._x2 <= boxByteGreen._x1)
 					continue;
 				byteWidth = M77_getNormalizedByteWidth(byteWidth);
 				if (flipHorizontal || flipVertical) {
-					memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * 2 * heightRedEagle);
+					memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, sizeof(byte) * byteWidth * heightRedEagle);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
 				if (flipHorizontal) {
@@ -3688,17 +3618,18 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP
 				if (flipVertical) {
 					f131_flipVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
 				}
-				f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport, k10_ColorFlesh);
+				f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
 			}
 		}
-	} while ((thingParam = dunMan.f159_getNextThing(thingParam)) != Thing::_endOfList);
-/* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */
-	if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_g77_doNotDrawFluxcagesDuringEndgame) {
+	} while ((thingParam = _vm->_dungeonMan->f159_getNextThing(thingParam)) != Thing::_endOfList);
+	if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_g77_doNotDrawFluxcagesDuringEndgame) { /* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */
 		AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */
 		fieldAspect = g188_FieldAspects[viewSquareIndex];
 		(fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */
 		f113_drawField(&fieldAspect, g163_FrameWalls[viewSquareIndex]._box);
 	}
+T0115214_Return:
+	;
 }
 
 uint16 DisplayMan::M77_getNormalizedByteWidth(uint16 byteWidth) {
@@ -3732,4 +3663,22 @@ void DisplayMan::f493_addDerivedBitmap(int16 derivedBitmapIndex) {
 	warning(false, "f493_addDerivedBitmap DOES NOTHING");
 }
 
+void DisplayMan::f480_releaseBlock(uint16 index) {
+	delete[] _g638_derivedBitmaps[index];
+	_g638_derivedBitmaps[index] = nullptr;
+}
+
+uint16 DisplayMan::f431_getDarkenedColor(uint16 RGBcolor) {
+	if (getFlag(RGBcolor, D12_MASK_BLUE_COMPONENT)) {
+		RGBcolor--;
+	}
+	if (getFlag(RGBcolor, D11_MASK_GREEN_COMPONENT)) {
+		RGBcolor -= 16;
+	}
+	if (getFlag(RGBcolor, D10_MASK_RED_COMPONENT)) {
+		RGBcolor -= 256;
+	}
+	return RGBcolor;
+}
+
 }
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 4dd1694..7de68ac 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -207,6 +207,7 @@ enum GraphicIndice {
 	k3_entranceRightDoorGraphicIndice = 3, // @ C003_GRAPHIC_ENTRANCE_RIGHT_DOOR
 	k4_entranceGraphicIndice = 4, // @ C004_GRAPHIC_ENTRANCE
 	k5_creditsGraphicIndice = 5, // @ C005_GRAPHIC_CREDITS
+	k6_theEndIndice = 6, // @ C006_GRAPHIC_THE_END
 	k8_StatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION
 	k9_MenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND
 	k10_MenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA
@@ -266,6 +267,7 @@ enum GraphicIndice {
 	k69_FieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R
 	k73_FieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER
 	k120_InscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT
+	k208_wallOrn_43_champMirror = 208, // @ C208_GRAPHIC_WALL_ORNAMENT_43_CHAMPION_MIRROR
 	k241_FloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS
 	k301_DoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
 	k315_firstDoorButton_GraphicIndice = 315, // @ C315_GRAPHIC_FIRST_DOOR_BUTTON
@@ -305,7 +307,7 @@ public:
 	bool isPointInside(Common::Point point) {
 		return (_x1 <= point.x) && (point.x <= _x2) && (_y1 <= point.y) && (point.y <= _y2); // <= because incluseive boundaries
 	}
-	bool isPointInside(int16 x, int16 y) { return isPointInside(Common::Point(x, y));  }
+	bool isPointInside(int16 x, int16 y) { return isPointInside(Common::Point(x, y)); }
 	void setToZero() { _x1 = _x2 = _y1 = _y2 = 0; }
 }; // @ BOX_BYTE, BOX_WORD
 
@@ -504,6 +506,21 @@ public:
 	}
 }; // @ DOOR_FRAMES
 
+#define D00_RGB_BLACK                                0x0000
+#define D01_RGB_DARK_BLUE                            0x0004
+#define D02_RGB_LIGHT_BROWN                          0x0842
+#define D03_RGB_PINK                                 0x086F
+#define D04_RGB_LIGHTER_BROWN                        0x0A62
+#define D05_RGB_DARK_GOLD                            0x0A82
+#define D06_RGB_GOLD                                 0x0CA2
+#define D07_RGB_RED                                  0x0F00
+#define D08_RGB_YELLOW                               0x0FF4
+#define D09_RGB_WHITE                                0x0FFF
+#define D10_MASK_RED_COMPONENT                       0x0F00
+#define D10_MASK_RED_COMPONENT 0x0F00
+#define D11_MASK_GREEN_COMPONENT 0x00F0
+#define D12_MASK_BLUE_COMPONENT 0x000F
+
 class DisplayMan {
 	friend class DM::TextMan;
 
@@ -580,7 +597,9 @@ class DisplayMan {
 	byte *_g696_bitmapWallSet_Wall_D3R2; // @ G0696_puc_Bitmap_WallSet_Wall_D3R2
 	byte *_g698_bitmapWallSet_Wall_D3LCR; // @ G0698_puc_Bitmap_WallSet_Wall_D3LCR
 	byte *_g699_bitmapWallSet_Wall_D2LCR; // @ G0699_puc_Bitmap_WallSet_Wall_D2LCR
+public:
 	byte *_g700_bitmapWallSet_Wall_D1LCR; // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR
+private:
 	byte *_g701_bitmapWallSet_Wall_D0L; // @ G0701_puc_Bitmap_WallSet_Wall_D0L
 	byte *_g702_bitmapWallSet_Wall_D0R; // @ G0702_puc_Bitmap_WallSet_Wall_D0R
 	byte *_g703_bitmapWallSet_DoorFrameTop_D2LCR; // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR
@@ -612,6 +631,7 @@ class DisplayMan {
 	int16 _g694_doorNativeBitmapIndex_Front_D2LCR[2]; // @ G0694_ai_DoorNativeBitmapIndex_Front_D2LCR
 	int16 _g695_doorNativeBitmapIndex_Front_D1LCR[2]; // @ G0695_ai_DoorNativeBitmapIndex_Front_D1LCR
 public:
+
 	uint16 _screenWidth;
 	uint16 _screenHeight;
 	byte *_g348_bitmapScreen; // @ G0348_pl_Bitmap_Screen
@@ -624,6 +644,7 @@ public:
 	int16 _g304_dungeonViewPaletteIndex; // @ G0304_i_DungeonViewPaletteIndex
 	uint16 _g345_aui_BlankBuffer[32]; // @G0345_aui_BlankBuffer
 	uint16 _g347_paletteTopAndBottomScreen[16]; // @ G0347_aui_Palette_TopAndBottomScreen
+	uint16 _g346_paletteMiddleScreen[16]; // @ G0346_aui_Palette_MiddleScreen
 
 	explicit DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
@@ -658,19 +679,19 @@ public:
 	void f20_blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
 	void f21_blitToScreen(byte* bitmap, int16 *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen
 	void f21_blitToScreen(byte* bitmap, Box *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen
-	
 
-	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which 
+
+	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which
 	does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters
 	match the original exatcly, if need arises for heights then we'll have to retrospectively add them in old function calls*/
 	/* Expects inclusive boundaries in box */
 	void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
-					  uint16 destByteWidth, Color transparent = kM1_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit
-/* Expects inclusive boundaries in box */
+						   uint16 destByteWidth, Color transparent = kM1_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit
+	 /* Expects inclusive boundaries in box */
 	void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
-									   int16 firstUnitIndex, int16 destByteWidth, Color transparent,
-									   int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
-	// this function takes pixel widths
+											int16 firstUnitIndex, int16 destByteWidth, Color transparent,
+											int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
+		 // this function takes pixel widths
 	void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
 											  int16 srcPixelWidth, int16 srcHight, int16 destPixelWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
 	void f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height); // @ F0130_VIDEO_FlipHorizontal
@@ -696,8 +717,8 @@ public:
 	int16 f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale); // @ F0459_START_GetScaledBitmapByteCount
 	int16 M78_getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION
 	void f115_cthulhu(Thing thingParam, Direction directionParam,
-				 int16 mapXpos, int16 mapYpos, int16 viewSquareIndex,
-				 uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
+					  int16 mapXpos, int16 mapYpos, int16 viewSquareIndex,
+					  uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
 	uint16 M77_getNormalizedByteWidth(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH
 	uint16 M23_getVerticalOffsetM23(uint16 val); // @ M23_VERTICAL_OFFSET
 	uint16 M22_getHorizontalOffsetM22(uint16 val); // @ M22_HORIZONTAL_OFFSET
@@ -727,9 +748,9 @@ public:
 	bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
 	byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap
 	void f493_addDerivedBitmap(int16 derivedBitmapIndex); // @ F0493_CACHE_AddDerivedBitmap
-
+	void f480_releaseBlock(uint16 index); // @ F0480_CACHE_ReleaseBlock
+	uint16 f431_getDarkenedColor(uint16 RGBcolor);
 	void f436_STARTEND_FadeToPalette(uint16 *P0849_pui_Palette) { warning(false, "STUB: f436_STARTEND_FadeToPalette"); }
-
 };
 
 }


Commit: be4f0665d053da2b4d8ace891be5240902f1063f
    https://github.com/scummvm/scummvm/commit/be4f0665d053da2b4d8ace891be5240902f1063f
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Update TODOs

Changed paths:
    engines/dm/TODOs/todo.txt



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 8ae9df2..b44ec12 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -1,19 +1,12 @@
 Bugs:
 	Display:
-		Broken colour palette
-		Portraits, alcoves etc. look broken from afar
-		Arrow and hand display is messed up
-		Items are displayed in the wrong cells
-
+		Broken colour palette for dungeon and cursor
 		Gui is messed up by drawn spell area line on startup
 		Spellcasting tabs are displayed inproperly, switching between them is possible tho
 
-
 	Logic:
-		When object are put on the right side of the current square, they disappear
-		Object display is a bit mixed up with regards to which cell is it drawn in
-
-		
+		End game method is broken
+		Items thrown on the right side end up on the left side 
 
 
 Possible bugs:


Commit: 774ae8e821f8bb91b297ecde39d0496666c1a6e0
    https://github.com/scummvm/scummvm/commit/774ae8e821f8bb91b297ecde39d0496666c1a6e0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove unnecessary redirection through DMEngine members

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/objectman.cpp
    engines/dm/text.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index f79c60c..cd59e2e 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1083,7 +1083,7 @@ void ChampionMan::f316_deleteScent(uint16 scentIndex) {
 }
 
 void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount) {
-	int16 scentIndex = _vm->_championMan->_g407_party._scentCount;
+	int16 scentIndex = _g407_party._scentCount;
 	if (scentIndex) {
 		bool mergeFl = getFlag(cycleCount, k0x8000_mergeCycles);
 		if (mergeFl)
@@ -1094,7 +1094,7 @@ void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount
 		newScent.setMapY(mapY); /* BUG0_00 Useless code */
 		newScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */
 
-		Scent *curScent = _vm->_championMan->_g407_party._scents; /* BUG0_00 Useless code */
+		Scent *curScent = _g407_party._scents; /* BUG0_00 Useless code */
 		bool cycleCountDefined = false;
 		while (scentIndex--) {
 			if (&*curScent++ == &newScent) {
@@ -1135,7 +1135,7 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer)
 }
 
 int16 ChampionMan::f310_getMovementTicks(Champion *champ) {
-	uint16 maximumLoad = _vm->_championMan->f309_getMaximumLoad(champ);
+	uint16 maximumLoad = f309_getMaximumLoad(champ);
 	uint16 curLoad = champ->_load;
 	uint16 woundTicks;
 	int16 ticks;
@@ -1166,7 +1166,7 @@ int16 ChampionMan::f310_getMovementTicks(Champion *champ) {
 }
 
 bool ChampionMan::f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex, uint16 ammunitionSlotIndex) {
-	Champion *curChampion = &_vm->_championMan->_gK71_champions[champIndex];
+	Champion *curChampion = &_gK71_champions[champIndex];
 	Thing curThing = curChampion->_slots[weaponSlotIndex];
 	if (curThing.getType() != k5_WeaponThingType)
 		return false;
@@ -1188,15 +1188,15 @@ bool ChampionMan::f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint1
 }
 
 void ChampionMan::f293_drawAllChampionStates() {
-	for (int16 i = k0_ChampionFirst; i < _vm->_championMan->_g305_partyChampionCount; i++)
-		_vm->_championMan->f292_drawChampionState((ChampionIndex)i);
+	for (int16 i = k0_ChampionFirst; i < _g305_partyChampionCount; i++)
+		f292_drawChampionState((ChampionIndex)i);
 }
 
 void ChampionMan::f283_viAltarRebirth(uint16 champIndex) {
-	Champion *curChampion = &_vm->_championMan->_gK71_champions[champIndex];
-	if (_vm->_championMan->f285_getIndexInCell(curChampion->_cell) != kM1_ChampionNone) {
+	Champion *curChampion = &_gK71_champions[champIndex];
+	if (f285_getIndexInCell(curChampion->_cell) != kM1_ChampionNone) {
 		uint16 numCell = k0_CellNorthWest;
-		while (_vm->_championMan->f285_getIndexInCell(numCell) != kM1_ChampionNone)
+		while (f285_getIndexInCell(numCell) != kM1_ChampionNone)
 			numCell++;
 
 		curChampion->_cell = (ViewCell)numCell;
@@ -1205,10 +1205,10 @@ void ChampionMan::f283_viAltarRebirth(uint16 champIndex) {
 	uint16 maximumHealth = curChampion->_maxHealth;
 	curChampion->_maxHealth = MAX(25, maximumHealth - (maximumHealth >> 6) - 1);
 	curChampion->_currHealth = curChampion->_maxHealth >> 1;
-	_vm->_menuMan->f393_drawSpellAreaControls(_vm->_championMan->_g514_magicCasterChampionIndex);
+	_vm->_menuMan->f393_drawSpellAreaControls(_g514_magicCasterChampionIndex);
 	curChampion->_dir = _vm->_dungeonMan->_g308_partyDir;
 	setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
-	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+	f292_drawChampionState((ChampionIndex)champIndex);
 }
 
 void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex) {
@@ -1260,7 +1260,7 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex)
 }
 
 bool ChampionMan::f327_isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount) {
-	Champion *curChampion = &_vm->_championMan->_gK71_champions[champIndex];
+	Champion *curChampion = &_gK71_champions[champIndex];
 	if (curChampion->_currMana < requiredManaAmount)
 		return false;
 
@@ -1284,8 +1284,8 @@ void ChampionMan::f326_championShootProjectile(Champion* champ, Thing thing, int
 }
 
 void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() {
-	Champion *championPtr = _vm->_championMan->_gK71_champions;
-	for (uint16 championIndex = k0_ChampionFirst; championIndex < _vm->_championMan->_g305_partyChampionCount; championIndex++, championPtr++) {
+	Champion *championPtr = _gK71_champions;
+	for (uint16 championIndex = k0_ChampionFirst; championIndex < _g305_partyChampionCount; championIndex++, championPtr++) {
 		int16 pendingWounds = _g410_championPendingWounds[championIndex];
 		setFlag(championPtr->_wounds, pendingWounds);
 		_g410_championPendingWounds[championIndex] = 0;
@@ -1300,7 +1300,7 @@ void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() {
 
 		curHealth -= pendingDamage;
 		if (curHealth <= 0) {
-			_vm->_championMan->f319_championKill(championIndex);
+			f319_championKill(championIndex);
 		} else {
 			championPtr->_currHealth = curHealth;
 			setFlag(championPtr->_attributes, k0x0100_ChampionAttributeStatistics);
@@ -1344,7 +1344,7 @@ void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() {
 
 				textPosY = 5;
 			}
-			_vm->_textMan->f53_printToLogicalScreen(textPosX, textPosY, k15_ColorWhite, k8_ColorRed, _vm->_championMan->f288_getStringFromInteger(pendingDamage, false, 3).c_str());
+			_vm->_textMan->f53_printToLogicalScreen(textPosX, textPosY, k15_ColorWhite, k8_ColorRed, f288_getStringFromInteger(pendingDamage, false, 3).c_str());
 
 			int16 eventIndex = championPtr->_hideDamageReceivedIndex;
 			if (eventIndex == -1) {
@@ -1358,22 +1358,22 @@ void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() {
 				M33_setMapAndTime(curEvent->_mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
 				_vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(eventIndex));
 			}
-			_vm->_championMan->f292_drawChampionState((ChampionIndex)championIndex);
+			f292_drawChampionState((ChampionIndex)championIndex);
 			_vm->_eventMan->f77_hideMouse();
 		}
 	}
 }
 
 void ChampionMan::f319_championKill(uint16 champIndex) {
-	Champion *curChampion = &_vm->_championMan->_gK71_champions[champIndex];
+	Champion *curChampion = &_gK71_champions[champIndex];
 	curChampion->_currHealth = 0;
 	setFlag(curChampion->_attributes, k0x1000_ChampionAttributeStatusBox);
 	if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 		if (_vm->_g331_pressingEye) {
 			_vm->_g331_pressingEye = false;
 			_vm->_eventMan->_g597_ignoreMouseMovements = false;
-			if (!_vm->_championMan->_g415_leaderEmptyHanded) {
-				_vm->_objectMan->f34_drawLeaderObjectName(_vm->_championMan->_g414_leaderHandObject);
+			if (!_g415_leaderEmptyHanded) {
+				_vm->_objectMan->f34_drawLeaderObjectName(_g414_leaderHandObject);
 			}
 			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
 			_vm->_eventMan->f77_hideMouse();
@@ -1400,7 +1400,7 @@ void ChampionMan::f319_championKill(uint16 champIndex) {
 	curChampion->_symbols[0] = '\0';
 	curChampion->_dir = _vm->_dungeonMan->_g308_partyDir;
 	curChampion->_maximumDamageReceived = 0;
-	uint16 curChampionIconIndex = _vm->_championMan->M26_championIconIndex(curCell, _vm->_dungeonMan->_g308_partyDir);
+	uint16 curChampionIconIndex = M26_championIconIndex(curCell, _vm->_dungeonMan->_g308_partyDir);
 	if (_vm->M0_indexToOrdinal(curChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
 		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
 		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
@@ -1412,26 +1412,26 @@ void ChampionMan::f319_championKill(uint16 champIndex) {
 
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[curChampionIconIndex << 2], k0_ColorBlack);
-	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+	f292_drawChampionState((ChampionIndex)champIndex);
 
 	int16 aliveChampionIndex;
-	for (aliveChampionIndex = k0_ChampionFirst, curChampion = _vm->_championMan->_gK71_champions; aliveChampionIndex < _vm->_championMan->_g305_partyChampionCount; aliveChampionIndex++, curChampion++) {
+	for (aliveChampionIndex = k0_ChampionFirst, curChampion = _gK71_champions; aliveChampionIndex < _g305_partyChampionCount; aliveChampionIndex++, curChampion++) {
 		if (curChampion->_currHealth)
 			break;
 	}
 
-	if (aliveChampionIndex == _vm->_championMan->_g305_partyChampionCount) { /* BUG0_43 The game does not end if the last living champion in the party is killed while looking at a candidate champion in a portrait. The condition to end the game when the whole party is killed is not true because the code considers the candidate champion as alive (in the loop above) */
-		_vm->_championMan->_g303_partyDead = true;
+	if (aliveChampionIndex == _g305_partyChampionCount) { /* BUG0_43 The game does not end if the last living champion in the party is killed while looking at a candidate champion in a portrait. The condition to end the game when the whole party is killed is not true because the code considers the candidate champion as alive (in the loop above) */
+		_g303_partyDead = true;
 		return;
 	}
 
-	if (champIndex == _vm->_championMan->_g411_leaderIndex)
+	if (champIndex == _g411_leaderIndex)
 		_vm->_eventMan->f368_commandSetLeader((ChampionIndex)aliveChampionIndex);
 
-	if (champIndex == _vm->_championMan->_g514_magicCasterChampionIndex)
+	if (champIndex == _g514_magicCasterChampionIndex)
 		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(aliveChampionIndex);
 	else
-		_vm->_menuMan->f393_drawSpellAreaControls(_vm->_championMan->_g514_magicCasterChampionIndex);
+		_vm->_menuMan->f393_drawSpellAreaControls(_g514_magicCasterChampionIndex);
 }
 
 void ChampionMan::f318_dropAllObjects(uint16 champIndex) {
@@ -1468,7 +1468,7 @@ void ChampionMan::f318_dropAllObjects(uint16 champIndex) {
 		k1_ChampionSlotActionHand
 	};
 
-	uint16 curCell = _vm->_championMan->_gK71_champions[champIndex]._cell;
+	uint16 curCell = _gK71_champions[champIndex]._cell;
 	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
 		Thing curThing = f300_getObjectRemovedFromSlot(champIndex, slotDropOrder[slotIndex]);
 		if (curThing != Thing::_none)
@@ -1485,11 +1485,11 @@ void ChampionMan::f323_unpoison(int16 champIndex) {
 		if ((eventPtr->_type == k75_TMEventTypePoisonChampion) && (eventPtr->_priority == champIndex))
 			_vm->_timeline->f237_deleteEvent(eventIndex);
 	}
-	_vm->_championMan->_gK71_champions[champIndex]._poisonEventCount = 0;
+	_gK71_champions[champIndex]._poisonEventCount = 0;
 }
 
 void ChampionMan::f331_applyTimeEffects() {
-	if (!_vm->_championMan->_g305_partyChampionCount)
+	if (!_g305_partyChampionCount)
 		return;
 
 	Scent checkScent;
@@ -1497,10 +1497,10 @@ void ChampionMan::f331_applyTimeEffects() {
 	checkScent.setMapY(_vm->_dungeonMan->_g307_partyMapY);
 	checkScent.setMapIndex(_vm->_dungeonMan->_g309_partyMapIndex);
 
-	for (byte loopScentIndex = 0; loopScentIndex + 1 < _vm->_championMan->_g407_party._scentCount; loopScentIndex++) {
-		if (&_vm->_championMan->_g407_party._scents[loopScentIndex] != &checkScent) {
-			_vm->_championMan->_g407_party._scentStrengths[loopScentIndex] = MAX(0, _vm->_championMan->_g407_party._scentStrengths[loopScentIndex] - 1);
-			if (!_vm->_championMan->_g407_party._scentStrengths[loopScentIndex] && !loopScentIndex) {
+	for (byte loopScentIndex = 0; loopScentIndex + 1 < _g407_party._scentCount; loopScentIndex++) {
+		if (&_g407_party._scents[loopScentIndex] != &checkScent) {
+			_g407_party._scentStrengths[loopScentIndex] = MAX(0, _g407_party._scentStrengths[loopScentIndex] - 1);
+			if (!_g407_party._scentStrengths[loopScentIndex] && !loopScentIndex) {
 				f316_deleteScent(0);
 				continue;
 			}
@@ -1509,14 +1509,14 @@ void ChampionMan::f331_applyTimeEffects() {
 
 	uint16 gameTime = _vm->_g313_gameTime & 0xFFFF;
 	uint16 timeCriteria = (((gameTime & 0x0080) + ((gameTime & 0x0100) >> 2)) + ((gameTime & 0x0040) << 2)) >> 2;
-	Champion *championPtr = _vm->_championMan->_gK71_champions;
-	for (uint16 championIndex = k0_ChampionFirst; championIndex < _vm->_championMan->_g305_partyChampionCount; championIndex++, championPtr++) {
-		if (championPtr->_currHealth && (_vm->M0_indexToOrdinal(championIndex) != _vm->_championMan->_g299_candidateChampionOrdinal)) {
-			uint16 wizardSkillLevel = _vm->_championMan->f303_getSkillLevel(championIndex, k3_ChampionSkillWizard) + _vm->_championMan->f303_getSkillLevel(championIndex, k2_ChampionSkillPriest);
+	Champion *championPtr = _gK71_champions;
+	for (uint16 championIndex = k0_ChampionFirst; championIndex < _g305_partyChampionCount; championIndex++, championPtr++) {
+		if (championPtr->_currHealth && (_vm->M0_indexToOrdinal(championIndex) != _g299_candidateChampionOrdinal)) {
+			uint16 wizardSkillLevel = f303_getSkillLevel(championIndex, k3_ChampionSkillWizard) + f303_getSkillLevel(championIndex, k2_ChampionSkillPriest);
 			if ((championPtr->_currMana < championPtr->_maxMana)
 				&& (timeCriteria < championPtr->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + wizardSkillLevel)) {
 				int16 manaGain = championPtr->_maxMana / 40;
-				if (_vm->_championMan->_g300_partyIsSleeping)
+				if (_g300_partyIsSleeping)
 					manaGain <<= 1;
 
 				manaGain++;
@@ -1536,7 +1536,7 @@ void ChampionMan::f331_applyTimeEffects() {
 
 			int16 staminaLoss = 0;
 			int16 staminaAmount = f26_getBoundedValue(1, (championPtr->_maxStamina >> 8) - 1, 6);
-			if (_vm->_championMan->_g300_partyIsSleeping)
+			if (_g300_partyIsSleeping)
 				staminaAmount <<= 1;
 
 			int32 compDelay = _vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime;
@@ -1579,7 +1579,7 @@ void ChampionMan::f331_applyTimeEffects() {
 
 			if ((championPtr->_currHealth < championPtr->_maxHealth) && (championPtr->_currStamina >= (championPtr->_maxStamina >> 2)) && (timeCriteria < (championPtr->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] + 12))) {
 				int16 healthGain = (championPtr->_maxHealth >> 7) + 1;
-				if (_vm->_championMan->_g300_partyIsSleeping)
+				if (_g300_partyIsSleeping)
 					healthGain <<= 1;
 
 				if (_vm->_objectMan->f33_getIconIndex(championPtr->_slots[k10_ChampionSlotNeck]) == k121_IconIndiceJunkEkkhardCross)
@@ -1587,7 +1587,7 @@ void ChampionMan::f331_applyTimeEffects() {
 
 				championPtr->_currHealth += MIN(healthGain, (int16)(championPtr->_maxHealth - championPtr->_currHealth));
 			}
-			if (!((int)_vm->_g313_gameTime & (_vm->_championMan->_g300_partyIsSleeping ? 63 : 255))) {
+			if (!((int)_vm->_g313_gameTime & (_g300_partyIsSleeping ? 63 : 255))) {
 				for (uint16 i = k0_ChampionStatLuck; i <= k6_ChampionStatAntifire; i++) {
 					byte *curStatistic = championPtr->_statistics[i];
 					uint16 statisticMaximum = curStatistic[k0_ChampionStatMaximum];
@@ -1597,7 +1597,7 @@ void ChampionMan::f331_applyTimeEffects() {
 						curStatistic[k1_ChampionStatCurrent] -= curStatistic[k1_ChampionStatCurrent] / statisticMaximum;
 				}
 			}
-			if (!_vm->_championMan->_g300_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_g313_gameTime)) {
+			if (!_g300_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_g313_gameTime)) {
 				championPtr->_dir = _vm->_dungeonMan->_g308_partyDir;
 				championPtr->_maximumDamageReceived = 0;
 				setFlag(championPtr->_attributes, k0x0400_ChampionAttributeIcon);
@@ -1780,24 +1780,24 @@ void ChampionMan::f278_resetDataToStartGame() {
 }
 
 void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) {
-	if (!_vm->_championMan->_g415_leaderEmptyHanded)
+	if (!_g415_leaderEmptyHanded)
 		return;
 
-	if (_vm->_championMan->_g305_partyChampionCount == 4)
+	if (_g305_partyChampionCount == 4)
 		return;
 
-	uint16 previousPartyChampionCount = _vm->_championMan->_g305_partyChampionCount;
-	Champion *championPtr = &_vm->_championMan->_gK71_champions[previousPartyChampionCount];
+	uint16 previousPartyChampionCount = _g305_partyChampionCount;
+	Champion *championPtr = &_gK71_champions[previousPartyChampionCount];
 	championPtr->resetToZero();
 	// Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portraits could be missing in the data)
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
-	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, gBoxChampionPortrait, _vm->_championMan->M27_getChampionPortraitX(championPortraitIndex), _vm->_championMan->M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency);
+	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, gBoxChampionPortrait, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency);
 	championPtr->_actionIndex = k255_ChampionActionNone;
 	championPtr->_enableActionEventIndex = -1;
 	championPtr->_hideDamageReceivedIndex = -1;
 	championPtr->_dir = _vm->_dungeonMan->_g308_partyDir;
 	uint16 viewCell = k0_ViewCellFronLeft;
-	while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone)
+	while (f285_getIndexInCell(M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone)
 		viewCell++;
 
 	championPtr->_cell = (ViewCell)M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir);
@@ -1838,16 +1838,16 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 		setFlag(championPtr->_attributes, k0x0010_ChampionAttributeMale);
 
 	decodedStringPtr++;
-	championPtr->_currHealth = championPtr->_maxHealth = _vm->_championMan->f279_getDecodedValue(decodedStringPtr, 4);
+	championPtr->_currHealth = championPtr->_maxHealth = f279_getDecodedValue(decodedStringPtr, 4);
 	decodedStringPtr += 4;
-	championPtr->_currStamina = championPtr->_maxStamina = _vm->_championMan->f279_getDecodedValue(decodedStringPtr, 4);
+	championPtr->_currStamina = championPtr->_maxStamina = f279_getDecodedValue(decodedStringPtr, 4);
 	decodedStringPtr += 4;
-	championPtr->_currMana = championPtr->_maxMana = _vm->_championMan->f279_getDecodedValue(decodedStringPtr, 4);
+	championPtr->_currMana = championPtr->_maxMana = f279_getDecodedValue(decodedStringPtr, 4);
 	decodedStringPtr += 4;
 	decodedStringPtr++;
 	for (int16 statIdx = k0_ChampionStatLuck; statIdx <= k6_ChampionStatAntifire; statIdx++) {
 		championPtr->_statistics[statIdx][k2_ChampionStatMinimum] = 30;
-		championPtr->_statistics[statIdx][k1_ChampionStatCurrent] = championPtr->_statistics[statIdx][k0_ChampionStatMaximum] = _vm->_championMan->f279_getDecodedValue(decodedStringPtr, 2);
+		championPtr->_statistics[statIdx][k1_ChampionStatCurrent] = championPtr->_statistics[statIdx][k0_ChampionStatMaximum] = f279_getDecodedValue(decodedStringPtr, 2);
 		decodedStringPtr += 2;
 	}
 	championPtr->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10;
@@ -1865,13 +1865,13 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 
 		championPtr->_skills[skillIdx]._experience = baseSkillExperience;
 	}
-	_vm->_championMan->_g299_candidateChampionOrdinal = previousPartyChampionCount + 1;
-	if (++_vm->_championMan->_g305_partyChampionCount == 1) {
+	_g299_candidateChampionOrdinal = previousPartyChampionCount + 1;
+	if (++_g305_partyChampionCount == 1) {
 		_vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst);
 		_vm->_menuMan->_g508_refreshActionArea = true;
 	} else {
 		_vm->_menuMan->f388_clearActingChampion();
-		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_vm->_championMan->_g305_partyChampionCount - 1));
+		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1));
 	}
 
 	int16 curMapX = _vm->_dungeonMan->_g306_partyMapX;
@@ -1942,7 +1942,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 				else
 					curSlotIndex = slotIdx++;
 			}
-			_vm->_championMan->f301_addObjectInSlot((ChampionIndex)previousPartyChampionCount, curThing, (ChampionSlot)curSlotIndex);
+			f301_addObjectInSlot((ChampionIndex)previousPartyChampionCount, curThing, (ChampionSlot)curSlotIndex);
 		}
 		curThing = _vm->_dungeonMan->f159_getNextThing(curThing);
 	}
@@ -1952,7 +1952,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 
 void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
 	int16 barGraphHeights[3];
-	Champion *champ = &_vm->_championMan->_gK71_champions[champIndex];
+	Champion *champ = &_gK71_champions[champIndex];
 	int16 barGraphIdx = 0;
 	if (champ->_currHealth > 0) {
 		int32 barGraphHeight = (((int32)champ->_currHealth << 10) * 25) / champ->_maxHealth;
@@ -2162,7 +2162,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 	uint16 championIconIndex = M26_championIconIndex(curChampion->_cell, _vm->_dungeonMan->_g308_partyDir);
 	if (getFlag(championAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(championIconIndex))) {
 		_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[championIconIndex], g46_ChampionColor[champIndex]);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[championIconIndex], _vm->_championMan->M26_championIconIndex(curChampion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[championIconIndex], M26_championIconIndex(curChampion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
 	}
 	if (getFlag(championAttributes, k0x0800_ChampionAttributePanel) && isInventoryChampion) {
 		if (_vm->_g333_pressingMouth)
@@ -2333,8 +2333,8 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 						renamedChampionString[curCharacterIndex] = '\0';
 
 					bool found = false;
-					for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_g305_partyChampionCount - 1; idx++) {
-						if (!strcmp(_vm->_championMan->_gK71_champions[idx]._name, renamedChampionString)) {
+					for (uint16 idx = k0_ChampionFirst; idx < _g305_partyChampionCount - 1; idx++) {
+						if (!strcmp(_gK71_champions[idx]._name, renamedChampionString)) {
 							// If an existing champion already has the specified name for the new champion
 							found = true;
 							break;
@@ -2439,13 +2439,13 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 }
 
 uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, uint16 skillIndex) {
-	if (_vm->_championMan->_g300_partyIsSleeping)
+	if (_g300_partyIsSleeping)
 		return 1;
 
 	bool ignoreTmpExp = getFlag(skillIndex, k0x8000_IgnoreTemporaryExperience);
 	bool ignoreObjModifiers = getFlag(skillIndex, k0x4000_IgnoreObjectModifiers);
 	clearFlag(skillIndex, k0x8000_IgnoreTemporaryExperience | k0x4000_IgnoreObjectModifiers);
-	Champion *champ = &_vm->_championMan->_gK71_champions[champIndex];
+	Champion *champ = &_gK71_champions[champIndex];
 	Skill *skill = &champ->_skills[skillIndex];
 	int32 exp = skill->_experience;
 	if (!ignoreTmpExp)
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 4e27eb5..55cfcdd 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -770,27 +770,27 @@ void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) {
 
 
 Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) {
-	bool isMapYInBounds = (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight);
-	bool isMapXInBounds = (mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth);
+	bool isMapYInBounds = (mapY >= 0) && (mapY < _g274_currMapHeight);
+	bool isMapXInBounds = (mapX >= 0) && (mapX < _g273_currMapWidth);
 
 	if (isMapXInBounds && isMapYInBounds)
-		return Square(_vm->_dungeonMan->_g271_currMapData[mapX][mapY]);
+		return Square(_g271_currMapData[mapX][mapY]);
 
 	if (isMapYInBounds) {
-		SquareType squareType = Square(_vm->_dungeonMan->_g271_currMapData[0][mapY]).getType();
+		SquareType squareType = Square(_g271_currMapData[0][mapY]).getType();
 		if (((mapX == -1) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit))
 			return Square(k0_ElementTypeWall, k0x0004_WallEastRandOrnAllowed);
 
-		squareType = Square(_vm->_dungeonMan->_g271_currMapData[_vm->_dungeonMan->_g273_currMapWidth - 1][mapY]).getType();
-		if (((mapX == _vm->_dungeonMan->_g273_currMapWidth) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit))
+		squareType = Square(_g271_currMapData[_g273_currMapWidth - 1][mapY]).getType();
+		if (((mapX == _g273_currMapWidth) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit))
 			return Square(k0_ElementTypeWall, k0x0001_WallWestRandOrnAllowed);
 	} else if (isMapXInBounds) {
-		SquareType squareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][0]).getType();
+		SquareType squareType = Square(_g271_currMapData[mapX][0]).getType();
 		if (((mapY == -1) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit))
 			return Square(k0_ElementTypeWall, k0x0002_WallSouthRandOrnAllowed);
 
-		squareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][_vm->_dungeonMan->_g274_currMapHeight - 1]).getType();
-		if (((mapY == _vm->_dungeonMan->_g274_currMapHeight) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit))
+		squareType = Square(_g271_currMapData[mapX][_g274_currMapHeight - 1]).getType();
+		if (((mapY == _g274_currMapHeight) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit))
 			return Square(k0_ElementTypeWall, k0x0008_WallNorthRandOrnAllowed);
 	}
 	return Square(k0_ElementTypeWall, 0);
@@ -802,12 +802,12 @@ Square DungeonMan::f152_getRelSquare(Direction dir, int16 stepsForward, int16 st
 }
 
 int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) {
-	unsigned char *curSquare = _vm->_dungeonMan->_g271_currMapData[mapX];
-	if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight) || !getFlag(curSquare[mapY], k0x0010_ThingListPresent))
+	unsigned char *curSquare = _g271_currMapData[mapX];
+	if ((mapX < 0) || (mapX >= _g273_currMapWidth) || (mapY < 0) || (mapY >= _g274_currMapHeight) || !getFlag(curSquare[mapY], k0x0010_ThingListPresent))
 		return -1;
 
 	int16 curMapY = 0;
-	uint16 thingIndex = _vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount[mapX];
+	uint16 thingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
 	while (curMapY++ != mapY) {
 		if (getFlag(*curSquare++, k0x0010_ThingListPresent))
 			thingIndex++;
@@ -964,20 +964,20 @@ T0172010_ClosedFakeWall:
 void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir,
 												 int16 mapX, int16 mapY, bool isFakeWall) {
 
-	int16 randomWallOrnamentCount = _vm->_dungeonMan->_g269_currMap->_randWallOrnCount;
-	aspectArray[k2_RightWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(leftAllowed, randomWallOrnamentCount, mapX, ++mapY * (M21_normalizeModulo4(++dir) + 1), 30);
-	aspectArray[k3_FrontWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(frontAllowed, randomWallOrnamentCount, mapX, mapY * (M21_normalizeModulo4(++dir) + 1), 30);
-	aspectArray[k4_LeftWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(rightAllowed, randomWallOrnamentCount, mapX, mapY-- * (M21_normalizeModulo4(++dir) + 1), 30);
-	if (isFakeWall || (mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight)) { /* If square is a fake wall or is out of map bounds */
+	int16 randomWallOrnamentCount = _g269_currMap->_randWallOrnCount;
+	aspectArray[k2_RightWallOrnOrdAspect] = f170_getRandomOrnOrdinal(leftAllowed, randomWallOrnamentCount, mapX, ++mapY * (M21_normalizeModulo4(++dir) + 1), 30);
+	aspectArray[k3_FrontWallOrnOrdAspect] = f170_getRandomOrnOrdinal(frontAllowed, randomWallOrnamentCount, mapX, mapY * (M21_normalizeModulo4(++dir) + 1), 30);
+	aspectArray[k4_LeftWallOrnOrdAspect] = f170_getRandomOrnOrdinal(rightAllowed, randomWallOrnamentCount, mapX, mapY-- * (M21_normalizeModulo4(++dir) + 1), 30);
+	if (isFakeWall || (mapX < 0) || (mapX >= _g273_currMapWidth) || (mapY < 0) || (mapY >= _g274_currMapHeight)) { /* If square is a fake wall or is out of map bounds */
 		for (int16 sideIndex = k2_RightWallOrnOrdAspect; sideIndex <= k4_LeftWallOrnOrdAspect; sideIndex++) { /* Loop to remove any random ornament that is an alcove */
-			if (_vm->_dungeonMan->f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[sideIndex])))
+			if (f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[sideIndex])))
 				aspectArray[sideIndex] = 0;
 		}
 	}
 }
 
 int16 DungeonMan::f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) {
-	int16 randomOrnamentIndex = f169_getRandomOrnamentIndex((int16)2000 + (mapX << 5) + mapY, (int16)3000 + (_vm->_dungeonMan->_g272_currMapIndex << (int16)6) + _vm->_dungeonMan->_g273_currMapWidth + _vm->_dungeonMan->_g274_currMapHeight, modulo);
+	int16 randomOrnamentIndex = f169_getRandomOrnamentIndex((int16)2000 + (mapX << 5) + mapY, (int16)3000 + (_g272_currMapIndex << (int16)6) + _g273_currMapWidth + _g274_currMapHeight, modulo);
 
 	if (allowed && (randomOrnamentIndex < count))
 		return _vm->M0_indexToOrdinal(randomOrnamentIndex);
@@ -1155,7 +1155,7 @@ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) {
 }
 
 Thing DungeonMan::f166_getUnusedThing(uint16 thingType) {
-	int16 thingCount = _vm->_dungeonMan->_g278_dungeonFileHeader._thingCounts[getFlag(thingType, k0x7FFF_thingType)];
+	int16 thingCount = _g278_dungeonFileHeader._thingCounts[getFlag(thingType, k0x7FFF_thingType)];
 	if (thingType == (k0x8000_championBones | k10_JunkThingType)) {
 		thingType = k10_JunkThingType;
 	} else if (thingType == k10_JunkThingType)
@@ -1163,7 +1163,7 @@ Thing DungeonMan::f166_getUnusedThing(uint16 thingType) {
 
 	int16 thingIdx = thingCount;
 	int16 thingDataByteCount = g235_ThingDataWordCount[thingType] >> 1;
-	Thing *thingPtr = (Thing *)_vm->_dungeonMan->_g284_thingData[thingType];
+	Thing *thingPtr = (Thing *)_g284_thingData[thingType];
 
 	Thing curThing;
 	for (;;) { /*_Infinite loop_*/
@@ -1178,7 +1178,7 @@ Thing DungeonMan::f166_getUnusedThing(uint16 thingType) {
 			if (curThing == Thing::_none)
 				return Thing::_none;
 
-			thingPtr = (Thing *)_vm->_dungeonMan->f156_getThingData(curThing);
+			thingPtr = (Thing *)f156_getThingData(curThing);
 			break;
 		}
 	}
@@ -1393,39 +1393,39 @@ Thing DungeonMan::f165_getDiscardThing(uint16 thingType) {
 	if (thingType == k15_ExplosionThingType)
 		return Thing::_none;
 
-	int16 currentMapIdx = _vm->_dungeonMan->_g272_currMapIndex;
+	int16 currentMapIdx = _g272_currMapIndex;
 	uint16 mapIndex = lastDiscardedThingMapIndex[thingType];
-	if ((mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (++mapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount))
+	if ((mapIndex == _g309_partyMapIndex) && (++mapIndex >= _g278_dungeonFileHeader._mapCount))
 		mapIndex = 0;
 
 	uint16 discardThingMapIndex = mapIndex;
 	for (;;) { /*_Infinite loop_*/
-		uint16 mapWidth = _vm->_dungeonMan->_g277_dungeonMaps[mapIndex]._width;
-		uint16 mapHeight = _vm->_dungeonMan->_g277_dungeonMaps[mapIndex]._height;
-		byte *currSquare = _vm->_dungeonMan->_g279_dungeonMapData[mapIndex][0];
-		Thing *squareFirstThing = &_vm->_dungeonMan->_g283_squareFirstThings[_vm->_dungeonMan->_g280_dungeonColumnsCumulativeSquareThingCount[_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[mapIndex]]];
+		uint16 mapWidth = _g277_dungeonMaps[mapIndex]._width;
+		uint16 mapHeight = _g277_dungeonMaps[mapIndex]._height;
+		byte *currSquare = _g279_dungeonMapData[mapIndex][0];
+		Thing *squareFirstThing = &_g283_squareFirstThings[_g280_dungeonColumnsCumulativeSquareThingCount[_g281_dungeonMapsFirstColumnIndex[mapIndex]]];
 		
 		for (int16 currMapX = 0; currMapX <= mapWidth; currMapX++) {
 			for (int16 currMapY = 0; currMapY <= mapHeight; currMapY++) {
 				if (getFlag(*currSquare++, k0x0010_ThingListPresent)) {
 					Thing squareThing = *squareFirstThing++;
-					if ((mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && ((currMapX - _vm->_dungeonMan->_g306_partyMapX + 5) <= 10) && ((currMapY - _vm->_dungeonMan->_g307_partyMapY + 5) <= 10)) /* If square is too close to the party */
+					if ((mapIndex == _g309_partyMapIndex) && ((currMapX - _g306_partyMapX + 5) <= 10) && ((currMapY - _g307_partyMapY + 5) <= 10)) /* If square is too close to the party */
 						continue;
 
 					do {
 						ThingType squareThingType = squareThing.getType();
 						if (squareThingType == k3_SensorThingType) {
-							Thing *squareThingData = (Thing*)_vm->_dungeonMan->f156_getThingData(squareThing);
+							Thing *squareThingData = (Thing*)f156_getThingData(squareThing);
 							if (((Sensor*)squareThingData)->getType()) /* If sensor is not disabled */
 								break;
 						} else if (squareThingType == thingType) {
-							Thing *squareThingData = (Thing*)_vm->_dungeonMan->f156_getThingData(squareThing);
+							Thing *squareThingData = (Thing*)f156_getThingData(squareThing);
 							switch (thingType) {
 							case k4_GroupThingType:
 								if (((Group*)squareThingData)->getDoNotDiscard())
 									continue;
 							case k14_ProjectileThingType:
-								_vm->_dungeonMan->f173_setCurrentMap(mapIndex);
+								f173_setCurrentMap(mapIndex);
 								if (thingType == k4_GroupThingType) {
 									_vm->_groupMan->f188_dropGroupPossessions(currMapX, currMapY, squareThing, kM1_soundModeDoNotPlaySound);
 									_vm->_groupMan->f189_delete(currMapX, currMapY);
@@ -1439,77 +1439,77 @@ Thing DungeonMan::f165_getDiscardThing(uint16 thingType) {
 								if (((Armour*)squareThingData)->getDoNotDiscard())
 									continue;
 
-								_vm->_dungeonMan->f173_setCurrentMap(mapIndex);
+								f173_setCurrentMap(mapIndex);
 								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
 								break;
 							case k5_WeaponThingType:
 								if (((Weapon*)squareThingData)->getDoNotDiscard())
 									continue;
 
-								_vm->_dungeonMan->f173_setCurrentMap(mapIndex);
+								f173_setCurrentMap(mapIndex);
 								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
 								break;
 							case k10_JunkThingType:
 								if (((Junk*)squareThingData)->getDoNotDiscard())
 									continue;
 
-								_vm->_dungeonMan->f173_setCurrentMap(mapIndex);
+								f173_setCurrentMap(mapIndex);
 								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
 								break;
 							case k8_PotionThingType:
 								if (((Potion*)squareThingData)->getDoNotDiscard())
 									continue;
 
-								_vm->_dungeonMan->f173_setCurrentMap(mapIndex);
+								f173_setCurrentMap(mapIndex);
 								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
 								break;
 							}
-							_vm->_dungeonMan->f173_setCurrentMap(currentMapIdx);
+							f173_setCurrentMap(currentMapIdx);
 							lastDiscardedThingMapIndex[thingType] = mapIndex;
 							return Thing(squareThing.getTypeAndIndex());
 						}
-					} while ((squareThing = _vm->_dungeonMan->f159_getNextThing(squareThing)) != Thing::_endOfList);
+					} while ((squareThing = f159_getNextThing(squareThing)) != Thing::_endOfList);
 				}
 			}
 		}
-		if ((mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) || (_vm->_dungeonMan->_g278_dungeonFileHeader._mapCount <= 1)) {
+		if ((mapIndex == _g309_partyMapIndex) || (_g278_dungeonFileHeader._mapCount <= 1)) {
 			lastDiscardedThingMapIndex[thingType] = mapIndex;
 			return Thing::_none;
 		}
 
 		do {
-			if (++mapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount)
+			if (++mapIndex >= _g278_dungeonFileHeader._mapCount)
 				mapIndex = 0;
-		} while (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex);
+		} while (mapIndex == _g309_partyMapIndex);
 
 		if (mapIndex == discardThingMapIndex)
-			mapIndex = _vm->_dungeonMan->_g309_partyMapIndex;
+			mapIndex = _g309_partyMapIndex;
 	}
 }
 
 uint16 DungeonMan::f144_getCreatureAttributes(Thing thing) {
-	Group *currGroup = (Group *)_vm->_dungeonMan->f156_getThingData(thing);
+	Group *currGroup = (Group *)f156_getThingData(thing);
 	return g243_CreatureInfo[currGroup->_type]._attributes;
 }
 
 void DungeonMan::f146_setGroupCells(Group* group, uint16 cells, uint16 mapIndex) {
-	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex)
+	if (mapIndex == _g309_partyMapIndex)
 		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._cells = cells;
 	else
 		group->_cells = cells;
 }
 
 void DungeonMan::f148_setGroupDirections(Group* group, int16 dir, uint16 mapIndex) {
-	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex)
+	if (mapIndex == _g309_partyMapIndex)
 		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (Direction)dir;
 	else
 		group->setDir(M21_normalizeModulo4(dir));
 }
 
 bool DungeonMan::f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) {
-	int16 creatureType = ((Group*)_vm->_dungeonMan->f156_getThingData(thing))->_type;
-	Map *map = &_vm->_dungeonMan->_g277_dungeonMaps[mapIndex];
-	byte *allowedCreatureType = _vm->_dungeonMan->_g279_dungeonMapData[mapIndex][map->_width] + map->_height + 1;
+	int16 creatureType = ((Group*)f156_getThingData(thing))->_type;
+	Map *map = &_g277_dungeonMaps[mapIndex];
+	byte *allowedCreatureType = _g279_dungeonMapData[mapIndex][map->_width] + map->_height + 1;
 	for (int16 L0234_i_Counter = map->_creatureTypeCount; L0234_i_Counter > 0; L0234_i_Counter--) {
 		if (*allowedCreatureType++ == creatureType)
 			return true;
@@ -1537,17 +1537,17 @@ void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList
 	thingToUnlink = Thing(tmp);
 
 	if (mapX >= 0) {
-		L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink);
-		AL0275_pT_Thing = &_vm->_dungeonMan->_g283_squareFirstThings[L0271_ui_SquareFirstThingIndex = _vm->_dungeonMan->f160_getSquareFirstThingIndex(mapX, mapY)]; /* BUG0_01 Coding error without consequence. The engine does not check that there are things at the specified square coordinates. _vm->_dungeonMan->f160_getSquareFirstThingIndex would return -1 for an empty square. No consequence as the function is never called with the coordinates of an empty square (except in the case of BUG0_59) */
+		L0274_ps_Generic = (Thing*)f156_getThingData(thingToUnlink);
+		AL0275_pT_Thing = &_g283_squareFirstThings[L0271_ui_SquareFirstThingIndex = f160_getSquareFirstThingIndex(mapX, mapY)]; /* BUG0_01 Coding error without consequence. The engine does not check that there are things at the specified square coordinates. f160_getSquareFirstThingIndex would return -1 for an empty square. No consequence as the function is never called with the coordinates of an empty square (except in the case of BUG0_59) */
 		if ((*L0274_ps_Generic == Thing::_endOfList) && (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16())) { /* If the thing to unlink is the last thing on the square */
-			clearFlag(_vm->_dungeonMan->_g271_currMapData[mapX][mapY], k0x0010_ThingListPresent);
-			AL0272_ui_SquareFirstThingIndex = _vm->_dungeonMan->_g278_dungeonFileHeader._squareFirstThingCount - 1;
+			clearFlag(_g271_currMapData[mapX][mapY], k0x0010_ThingListPresent);
+			AL0272_ui_SquareFirstThingIndex = _g278_dungeonFileHeader._squareFirstThingCount - 1;
 			for (uint16 i = 0; i < AL0272_ui_SquareFirstThingIndex - L0271_ui_SquareFirstThingIndex; ++i)
 				AL0275_pT_Thing[i] = AL0275_pT_Thing[i + 1];
 
-			_vm->_dungeonMan->_g283_squareFirstThings[AL0272_ui_SquareFirstThingIndex] = Thing::_none;
-			AL0275_pui_CumulativeFirstThingCount = (Thing*)_vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount + mapX + 1;
-			AL0272_ui_Column = _vm->_dungeonMan->_g282_dungeonColumCount - (_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[_vm->_dungeonMan->_g272_currMapIndex] + mapX) - 1;
+			_g283_squareFirstThings[AL0272_ui_SquareFirstThingIndex] = Thing::_none;
+			AL0275_pui_CumulativeFirstThingCount = (Thing*)_g270_currMapColCumulativeSquareFirstThingCount + mapX + 1;
+			AL0272_ui_Column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1;
 			while (AL0272_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is unlinked */
 				(*(uint16*)AL0275_pui_CumulativeFirstThingCount++)--; /* Decrement the cumulative first thing count */
 			}
@@ -1561,17 +1561,17 @@ void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList
 		}
 		thingInList = *AL0275_pT_Thing;
 	}
-	L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList);
+	L0273_T_Thing = f159_getNextThing(thingInList);
 	while (L0273_T_Thing.getTypeAndIndex() != thingToUnlink.toUint16()) {
 		if ((L0273_T_Thing == Thing::_endOfList) || (L0273_T_Thing == Thing::_none)) {
 			*L0274_ps_Generic = Thing::_endOfList;
 			return;
 		}
-		L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList = L0273_T_Thing);
+		L0273_T_Thing = f159_getNextThing(thingInList = L0273_T_Thing);
 	}
-	L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingInList);
-	*L0274_ps_Generic = _vm->_dungeonMan->f159_getNextThing(L0273_T_Thing);
-	L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink);
+	L0274_ps_Generic = (Thing*)f156_getThingData(thingInList);
+	*L0274_ps_Generic = f159_getNextThing(L0273_T_Thing);
+	L0274_ps_Generic = (Thing*)f156_getThingData(thingToUnlink);
 	*L0274_ps_Generic = Thing::_endOfList;
 }
 
@@ -1580,14 +1580,14 @@ int16 DungeonMan::f155_getStairsExitDirection(int16 mapX, int16 mapY) {
 	bool L0257_B_NorthSouthOrientedStairs;
 
 
-	if (L0257_B_NorthSouthOrientedStairs = !getFlag(_vm->_dungeonMan->f151_getSquare(mapX, mapY).toByte(), k0x0008_StairsNorthSouthOrient)) {
+	if (L0257_B_NorthSouthOrientedStairs = !getFlag(f151_getSquare(mapX, mapY).toByte(), k0x0008_StairsNorthSouthOrient)) {
 		mapX = mapX + _vm->_dirIntoStepCountEast[kDirEast];
 		mapY = mapY + _vm->_dirIntoStepCountNorth[kDirEast];
 	} else {
 		mapX = mapX + _vm->_dirIntoStepCountEast[kDirNorth];
 		mapY = mapY + _vm->_dirIntoStepCountNorth[kDirNorth];
 	}
-	return ((((L0256_i_SquareType = Square(_vm->_dungeonMan->f151_getSquare(mapX, mapY)).getType()) == k0_ElementTypeWall) || (L0256_i_SquareType == k3_ElementTypeStairs)) << 1) + L0257_B_NorthSouthOrientedStairs;
+	return ((((L0256_i_SquareType = Square(f151_getSquare(mapX, mapY)).getType()) == k0_ElementTypeWall) || (L0256_i_SquareType == k3_ElementTypeStairs)) << 1) + L0257_B_NorthSouthOrientedStairs;
 
 }
 
@@ -1634,7 +1634,7 @@ Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {
 	if ((L0295_T_Thing = f166_getUnusedThing(L0294_i_ThingType)) == Thing::_none) {
 		return Thing::_none;
 	}
-	L0296_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0295_T_Thing);
+	L0296_ps_Junk = (Junk*)f156_getThingData(L0295_T_Thing);
 	L0296_ps_Junk->setType(L0293_i_Type); /* Also works for WEAPON in cases other than Boulder */
 	if ((iconIndex == k4_IconIndiceWeaponTorchUnlit) && ((Weapon*)L0296_ps_Junk)->isLit()) { /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */
 		((Weapon*)L0296_ps_Junk)->setChargeCount(15);
@@ -1644,7 +1644,7 @@ Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {
 
 int16 DungeonMan::f169_getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo) {
 	return ((((((val1 * 31417) & 0xFFFF) >> 1) + ((val2 * 11) & 0xFFFF)
-			  + _vm->_dungeonMan->_g278_dungeonFileHeader._ornamentRandomSeed) & 0xFFFF) >> 2) % modulo; /* Pseudorandom number generator */
+			  + _g278_dungeonFileHeader._ornamentRandomSeed) & 0xFFFF) >> 2) % modulo; /* Pseudorandom number generator */
 }
 
 }
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 82c8050..00e11ef 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -426,9 +426,9 @@ void EventManager::f68_setPointerToObject(byte* bitmap) {
 
 void EventManager::f71_mouseDropChampionIcon() {
 	_gK100_preventBuildPointerScreenArea = true;
-	uint16 L0058_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap);
-	_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
-	_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
+	uint16 L0058_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_g599_useChampionIconOrdinalAsMousePointerBitmap);
+	_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+	_g598_mousePointerBitmapUpdated = true;
 	bool L0057_B_UseByteBoxCoordinatesBackup = _vm->_displayMan->_g578_useByteBoxCoordinates;
 	_vm->_displayMan->f21_blitToScreen(_g613_mousePointerOriginalColorsChampionIcon, &g54_BoxChampionIcons[L0058_ui_ChampionIconIndex << 2], 16, k12_ColorDarkestGray, 18);
 	_vm->_displayMan->_g578_useByteBoxCoordinates = L0057_B_UseByteBoxCoordinatesBackup;
@@ -443,7 +443,7 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY)
 	//	return;
 
 	_gK100_preventBuildPointerScreenArea = true;
-	if (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
+	if (_g599_useChampionIconOrdinalAsMousePointerBitmap) {
 		if ((mousePosY > 28) || (mousePosX < 274)) {
 			_gK104_mousePointerType = k4_pointerTypeAutoselect;
 			f71_mouseDropChampionIcon();
@@ -491,8 +491,8 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY)
 	if (_gK104_mousePointerType == k4_pointerTypeAutoselect) {
 		_gK104_mousePointerType = (_g600_useObjectAsMousePointerBitmap) ? k1_pointerTypeObjectIcon : (_g601_useHandAsMousePointerBitmap) ? k3_pointerTypeHand : k0_pointerTypeArrow;
 	}
-	if (_vm->_eventMan->_g598_mousePointerBitmapUpdated || (_gK104_mousePointerType != _gK105_previousMousePointerType)) {
-		_vm->_eventMan->_g598_mousePointerBitmapUpdated = false;
+	if (_g598_mousePointerBitmapUpdated || (_gK104_mousePointerType != _gK105_previousMousePointerType)) {
+		_g598_mousePointerBitmapUpdated = false;
 		switch (_gK104_mousePointerType) {
 		case k0_pointerTypeArrow:
 			setMousePointerFromSpriteData(g42_bitmapArrowPointer);
@@ -657,30 +657,30 @@ void EventManager::f380_processCommandQueue() {
 	static MouseInput* G0484_ps_SecondaryMouseInputBackup;
 
 
-	_vm->_eventMan->_g435_isCommandQueueLocked = true;
+	_g435_isCommandQueueLocked = true;
 	if (_commandQueue.empty()) { /* If the command queue is empty */
-		_vm->_eventMan->_g435_isCommandQueueLocked = false;
-		_vm->_eventMan->f360_processPendingClick();
+		_g435_isCommandQueueLocked = false;
+		f360_processPendingClick();
 		return;
 	}
 
 	Command cmd = _commandQueue.pop();
 	cmdType = cmd._type;
 	if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft) && (_vm->_g310_disabledMovementTicks || (_vm->_g311_projectileDisableMovementTicks && (_vm->_g312_lastProjectileDisabledMovementDirection == (M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + cmdType - k3_CommandMoveForward)))))) { /* If movement is disabled */
-		_vm->_eventMan->_g435_isCommandQueueLocked = false;
-		_vm->_eventMan->f360_processPendingClick();
+		_g435_isCommandQueueLocked = false;
+		f360_processPendingClick();
 		return;
 	}
 	L1161_i_CommandX = cmd._pos.x;
 	L1162_i_CommandY = cmd._pos.y;
-	_vm->_eventMan->_g435_isCommandQueueLocked = false;
-	_vm->_eventMan->f360_processPendingClick();
+	_g435_isCommandQueueLocked = false;
+	f360_processPendingClick();
 	if ((cmdType == k2_CommandTurnRight) || (cmdType == k1_CommandTurnLeft)) {
-		_vm->_eventMan->f365_commandTurnParty(cmdType);
+		f365_commandTurnParty(cmdType);
 		return;
 	}
 	if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft)) {
-		_vm->_eventMan->f366_commandMoveParty(cmdType);
+		f366_commandMoveParty(cmdType);
 		return;
 	}
 	if ((cmdType >= k12_CommandClickInChampion_0_StatusBox) && (cmdType <= k15_CommandClickInChampion_3_StatusBox)) {
@@ -732,11 +732,11 @@ void EventManager::f380_processCommandQueue() {
 		return;
 	}
 	if (cmdType == k80_CommandClickInDungeonView) {
-		_vm->_eventMan->f377_commandProcessType80ClickInDungeonView(L1161_i_CommandX, L1162_i_CommandY);
+		f377_commandProcessType80ClickInDungeonView(L1161_i_CommandX, L1162_i_CommandY);
 		return;
 	}
 	if (cmdType == k81_CommandClickInPanel) {
-		_vm->_eventMan->f378_commandProcess81ClickInPanel(L1161_i_CommandX, L1162_i_CommandY);
+		f378_commandProcess81ClickInPanel(L1161_i_CommandX, L1162_i_CommandY);
 		return;
 	}
 
@@ -754,8 +754,8 @@ void EventManager::f380_processCommandQueue() {
 			f379_drawSleepScreen();
 			_vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
 			_vm->_g318_waitForInputMaxVerticalBlankCount = 0;
-			_vm->_eventMan->_g441_primaryMouseInput = g450_PrimaryMouseInput_PartySleeping;
-			_vm->_eventMan->_g442_secondaryMouseInput = 0;
+			_g441_primaryMouseInput = g450_PrimaryMouseInput_PartySleeping;
+			_g442_secondaryMouseInput = 0;
 			_g443_primaryKeyboardInput = g460_primaryKeyboardInput_partySleeping;
 			_g444_secondaryKeyboardInput = nullptr;
 			f357_discardAllInput();
@@ -780,12 +780,12 @@ void EventManager::f380_processCommandQueue() {
 		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 81, 69, k4_ColorCyan, k0_ColorBlack,
 											 "GAME FROZEN", k136_heightViewport);
 		_vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
-		G0483_ps_PrimaryMouseInputBackup = _vm->_eventMan->_g441_primaryMouseInput;
-		G0484_ps_SecondaryMouseInputBackup = _vm->_eventMan->_g442_secondaryMouseInput;
+		G0483_ps_PrimaryMouseInputBackup = _g441_primaryMouseInput;
+		G0484_ps_SecondaryMouseInputBackup = _g442_secondaryMouseInput;
 		G0481_ps_PrimaryKeyboardInputBackup = _g443_primaryKeyboardInput;
 		G0482_ps_SecondaryKeyboardInputBackup = _g444_secondaryKeyboardInput;
-		_vm->_eventMan->_g441_primaryMouseInput = g451_PrimaryMouseInput_FrozenGame;
-		_vm->_eventMan->_g442_secondaryMouseInput = 0;
+		_g441_primaryMouseInput = g451_PrimaryMouseInput_FrozenGame;
+		_g442_secondaryMouseInput = 0;
 		_g443_primaryKeyboardInput = g461_primaryKeyboardInput_frozenGame;
 		_g444_secondaryKeyboardInput = nullptr;
 		f357_discardAllInput();
@@ -794,8 +794,8 @@ void EventManager::f380_processCommandQueue() {
 	if (cmdType == k148_CommandUnfreezeGame) {
 		_vm->_g301_gameTimeTicking = true;
 		_vm->_menuMan->f457_drawEnabledMenus();
-		_vm->_eventMan->_g441_primaryMouseInput = G0483_ps_PrimaryMouseInputBackup;
-		_vm->_eventMan->_g442_secondaryMouseInput = G0484_ps_SecondaryMouseInputBackup;
+		_g441_primaryMouseInput = G0483_ps_PrimaryMouseInputBackup;
+		_g442_secondaryMouseInput = G0484_ps_SecondaryMouseInputBackup;
 		_g443_primaryKeyboardInput = G0481_ps_PrimaryKeyboardInputBackup;
 		_g444_secondaryKeyboardInput = G0482_ps_SecondaryKeyboardInputBackup;
 		f357_discardAllInput();
@@ -1162,7 +1162,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 		dispMan.D24_fillScreenBox(box, k0_ColorBlack);
 		dispMan.D24_fillScreenBox(g54_BoxChampionIcons[champMan.M26_championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2], k0_ColorBlack);
 		_vm->_menuMan->f457_drawEnabledMenus();
-		_vm->_eventMan->f78_showMouse();
+		f78_showMouse();
 		return;
 	}
 
@@ -1213,7 +1213,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 
 	invMan.f355_toggleInventory(k4_ChampionCloseInventory);
 	_vm->_menuMan->f457_drawEnabledMenus();
-	_vm->_eventMan->f67_setMousePointerToNormal((_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
+	f67_setMousePointerToNormal((_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
 }
 
 void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) {
@@ -1339,11 +1339,11 @@ void EventManager::f367_commandProcessTypes12to27_clickInChampionStatusBox(uint1
 	uint16 L1126_ui_Command;
 
 	if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
-		_vm->_eventMan->f368_commandSetLeader((ChampionIndex)champIndex);
+		f368_commandSetLeader((ChampionIndex)champIndex);
 	} else {
-		L1126_ui_Command = _vm->_eventMan->f358_getCommandTypeFromMouseInput(g455_MouseInput_ChampionNamesHands, Common::Point(posX, posY), k1_LeftMouseButton);
+		L1126_ui_Command = f358_getCommandTypeFromMouseInput(g455_MouseInput_ChampionNamesHands, Common::Point(posX, posY), k1_LeftMouseButton);
 		if ((L1126_ui_Command >= k16_CommandSetLeaderChampion_0) && (L1126_ui_Command <= k19_CommandSetLeaderChampion_3)) {
-			_vm->_eventMan->f368_commandSetLeader((ChampionIndex)(L1126_ui_Command - k16_CommandSetLeaderChampion_0));
+			f368_commandSetLeader((ChampionIndex)(L1126_ui_Command - k16_CommandSetLeaderChampion_0));
 		} else {
 			if ((L1126_ui_Command >= k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand) && (L1126_ui_Command <= k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand)) {
 				_vm->_championMan->f302_processCommands28to65_clickOnSlotBox(L1126_ui_Command - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
@@ -1358,13 +1358,13 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 	static byte G0045_auc_Graphic562_PaletteChanges_MousePointerIconShadow[16] = {0, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 0, 120, 120, 120};
 
 	_gK100_preventBuildPointerScreenArea = true;
-	if (!_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
+	if (!_g599_useChampionIconOrdinalAsMousePointerBitmap) {
 		if (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir)) == kM1_ChampionNone) {
 			_gK100_preventBuildPointerScreenArea = false;
 			return;
 		}
-		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
-		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = true;
+		_g598_mousePointerBitmapUpdated = true;
+		_g599_useChampionIconOrdinalAsMousePointerBitmap = true;
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		byte *L0056_puc_Bitmap = _gK190_mousePointerTempBuffer;
 		memset(L0056_puc_Bitmap, 0, 32 * 18);
@@ -1377,11 +1377,11 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, _g613_mousePointerOriginalColorsChampionIcon, G0622_s_Box_MousePointer_ChampionIcon, L0055_pi_ChampionIconBox->_x1, L0055_pi_ChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
 
 		_vm->_displayMan->D24_fillScreenBox(*L0055_pi_ChampionIconBox, k0_ColorBlack);
-		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(champIconIndex);
+		_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(champIconIndex);
 	} else {
-		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
-		uint16 L0052_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap);
-		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+		_g598_mousePointerBitmapUpdated = true;
+		uint16 L0052_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_g599_useChampionIconOrdinalAsMousePointerBitmap);
+		_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
 		int16 L0054_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(L0052_ui_ChampionIconIndex + _vm->_dungeonMan->_g308_partyDir));
 		if (L0052_ui_ChampionIconIndex == champIconIndex) {
 			setFlag(_vm->_championMan->_gK71_champions[L0054_i_ChampionIndex]._attributes, k0x0400_ChampionAttributeIcon);
@@ -1469,7 +1469,7 @@ void EventManager::f370_commandProcessType100_clickInSpellArea(uint16 posX, uint
 		}
 		return;
 	}
-	L1132_i_Command = _vm->_eventMan->f358_getCommandTypeFromMouseInput(g454_MouseInput_SpellArea, Common::Point(posX, posY), k1_LeftMouseButton);
+	L1132_i_Command = f358_getCommandTypeFromMouseInput(g454_MouseInput_SpellArea, Common::Point(posX, posY), k1_LeftMouseButton);
 	if (L1132_i_Command != k0_CommandNone) {
 		f369_commandProcessTypes101To108_clickInSpellSymbolsArea((CommandType)L1132_i_Command);
 	}
@@ -1515,7 +1515,7 @@ void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX,
 
 
 	if (_vm->_championMan->_g506_actingChampionOrdinal) {
-		L1134_ui_Command = _vm->_eventMan->f358_getCommandTypeFromMouseInput(g452_MouseInput_ActionAreaNames, Common::Point(posX, posY), k1_LeftMouseButton);
+		L1134_ui_Command = f358_getCommandTypeFromMouseInput(g452_MouseInput_ActionAreaNames, Common::Point(posX, posY), k1_LeftMouseButton);
 		if (L1134_ui_Command != k0_CommandNone) {
 			if (L1134_ui_Command == k112_CommandClickInActionAreaPass) {
 				warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
@@ -1537,7 +1537,7 @@ void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX,
 		}
 	} else {
 		if (_vm->_menuMan->_g509_actionAreaContainsIcons) {
-			L1134_ui_Command = _vm->_eventMan->f358_getCommandTypeFromMouseInput(g453_MouseInput_ActionAreaIcons, Common::Point(posX, posY), k1_LeftMouseButton);
+			L1134_ui_Command = f358_getCommandTypeFromMouseInput(g453_MouseInput_ActionAreaIcons, Common::Point(posX, posY), k1_LeftMouseButton);
 			if (L1134_ui_Command != k0_CommandNone) {
 				if ((L1134_ui_Command = L1134_ui_Command - k116_CommandClickInActionAreaChampion_0_Action) < _vm->_championMan->_g305_partyChampionCount) {
 					_vm->_menuMan->f389_processCommands116To119_setActingChampion(L1134_ui_Command);
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 74d11cf..90f89a3 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1434,9 +1434,9 @@ void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame* frame, int1
 	int16 AL0117_i_Square = _vm->_dungeonMan->_g279_dungeonMapData[AL0117_i_MapIndex][mapX][mapY];
 	if ((Square(AL0117_i_Square).getType() == k2_ElementTypePit) && getFlag(AL0117_i_Square, k0x0008_PitOpen)) {
 		if (flipHorizontal) {
-			_vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(nativeBitmapIndex, *frame);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(nativeBitmapIndex, *frame);
 		} else {
-			_vm->_displayMan->f104_drawFloorPitOrStairsBitmap(nativeBitmapIndex, *frame);
+			f104_drawFloorPitOrStairsBitmap(nativeBitmapIndex, *frame);
 		}
 	}
 }
@@ -1693,34 +1693,34 @@ void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
-			_vm->_displayMan->f104_drawFloorPitOrStairsBitmap(_vm->_displayMan->_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L);
+			f104_drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L);
 		} else {
-			_vm->_displayMan->f104_drawFloorPitOrStairsBitmap(_vm->_displayMan->_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L);
+			f104_drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L);
 		}
 		goto T0119018;
 	case k0_ElementTypeWall:
-		_vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k4_ViewSquare_D2L]);
-		_vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT);
-		if (_vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) {
+		f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k4_ViewSquare_D2L]);
+		f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT);
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
 			goto T0119020;
 		}
 		return;
 	case k18_ElementTypeStairsSide:
-		_vm->_displayMan->f104_drawFloorPitOrStairsBitmap(_vm->_displayMan->_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L);
+		f104_drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L);
 	case k16_DoorSideElemType:
 		order = k0x0342_CellOrder_BackRight_FrontLeft_FrontRight;
 		goto T0119019;
 	case k17_DoorFrontElemType:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L);
-		_vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
-		_vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g703_bitmapWallSet_DoorFrameTop_D2LCR, g173_Frame_DoorFrameTop_D2L);
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
+		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, g173_Frame_DoorFrameTop_D2L);
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], _g694_doorNativeBitmapIndex_Front_D2LCR,
 					  M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &g182_doorFrame_D2L);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0119020;
 	case k2_ElementTypePit:
-		_vm->_displayMan->f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice,
+		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice,
 														  g143_FrameFloorPit_D2L);
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
@@ -1730,10 +1730,10 @@ T0119019:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 T0119020:
 		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &g152_FrameFloorPit_D2L, posX, posY, false);
-		_vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, order);
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, order);
 	}
 	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		_vm->_displayMan->f113_drawField(&g188_FieldAspects[k4_ViewSquare_D2L], g163_FrameWalls[k4_ViewSquare_D2L]._box);
+		f113_drawField(&g188_FieldAspects[k4_ViewSquare_D2L], g163_FrameWalls[k4_ViewSquare_D2L]._box);
 	}
 }
 
@@ -1760,34 +1760,34 @@ void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
-			_vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_vm->_displayMan->_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R);
 		} else {
-			_vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_vm->_displayMan->_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R);
 		}
 		goto T0120027;
 	case k0_ElementTypeWall:
-		_vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k5_ViewSquare_D2R]);
-		_vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT);
-		if (_vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) {
+		f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k5_ViewSquare_D2R]);
+		f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT);
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
 			goto T0120029;
 		}
 		return;
 	case k18_ElementTypeStairsSide:
-		_vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_vm->_displayMan->_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R);
+		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R);
 	case k16_DoorSideElemType:
 		order = k0x0431_CellOrder_BackLeft_FrontRight_FrontLeft;
 		goto T0120028;
 	case k17_DoorFrontElemType:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_ViewSquare_D2R);
-		_vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
-		_vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g703_bitmapWallSet_DoorFrameTop_D2LCR, g175_Frame_DoorFrameTop_D2R);
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
+		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, g175_Frame_DoorFrameTop_D2R);
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
 					  _g694_doorNativeBitmapIndex_Front_D2LCR, M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &g184_doorFrame_D2R);
 		order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft;
 		goto T0120029;
 	case k2_ElementTypePit:
-		_vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect]
+		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect]
 																			 ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice, g145_FrameFloorPit_D2R);
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
@@ -1798,10 +1798,10 @@ T0120028:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_viewFloor_D2R);
 		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &g154_FrameFloorPit_D2R, posX, posY, true);
 T0120029:
-		_vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, order);
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, order);
 	}
 	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		_vm->_displayMan->f113_drawField(&g188_FieldAspects[k5_ViewSquare_D2R], g163_FrameWalls[k5_ViewSquare_D2R]._box);
+		f113_drawField(&g188_FieldAspects[k5_ViewSquare_D2R], g163_FrameWalls[k5_ViewSquare_D2R]._box);
 	}
 }
 
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 1d8fc18..2172d87 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -129,9 +129,9 @@ void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThin
 	uint16 L0368_ui_CreatureType = L0367_ps_Group->_type;
 	if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[L0368_ui_CreatureType]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
 		int16 L0369_i_CreatureIndex = L0367_ps_Group->getCount();
-		uint16 L0370_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(L0367_ps_Group, _vm->_dungeonMan->_g272_currMapIndex);
+		uint16 L0370_ui_GroupCells = f145_getGroupCells(L0367_ps_Group, _vm->_dungeonMan->_g272_currMapIndex);
 		do {
-			_vm->_groupMan->f186_dropCreatureFixedPossessions(L0368_ui_CreatureType, mapX, mapY, (L0370_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0370_ui_GroupCells, L0369_i_CreatureIndex), mode);
+			f186_dropCreatureFixedPossessions(L0368_ui_CreatureType, mapX, mapY, (L0370_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : M50_getCreatureValue(L0370_ui_GroupCells, L0369_i_CreatureIndex), mode);
 		} while (L0369_i_CreatureIndex--);
 	}
 	Thing L0365_T_CurrentThing = L0367_ps_Group->_slot;
@@ -393,16 +393,16 @@ int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group *group, uint16 creature
 	if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) /* Lord Chaos cannot be damaged */
 		goto T0190024;
 	if (group->_health[creatureIndex] <= damage) {
-		L0381_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(group, _vm->_dungeonMan->_g272_currMapIndex);
-		L0384_ui_Cell = (L0381_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0381_ui_GroupCells, creatureIndex);
+		L0381_ui_GroupCells = f145_getGroupCells(group, _vm->_dungeonMan->_g272_currMapIndex);
+		L0384_ui_Cell = (L0381_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : M50_getCreatureValue(L0381_ui_GroupCells, creatureIndex);
 		if (!(L0379_ui_CreatureCount = group->getCount())) { /* If there is a single creature in the group */
 			if (notMoving) {
-				f188_dropGroupPossessions(mapX, mapY, _vm->_groupMan->f175_groupGetThing(mapX, mapY), k2_soundModePlayOneTickLater);
+				f188_dropGroupPossessions(mapX, mapY, f175_groupGetThing(mapX, mapY), k2_soundModePlayOneTickLater);
 				f189_delete(mapX, mapY);
 			}
 			AL0375_ui_Outcome = k2_outcomeKilledAllCreaturesInGroup;
 		} else { /* If there are several creatures in the group */
-			L0382_ui_GroupDirections = _vm->_groupMan->f147_getGroupDirections(group, _vm->_dungeonMan->_g272_currMapIndex);
+			L0382_ui_GroupDirections = f147_getGroupDirections(group, _vm->_dungeonMan->_g272_currMapIndex);
 			if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
 				if (notMoving) {
 					f186_dropCreatureFixedPossessions(AL0380_ui_CreatureType, mapX, mapY, L0384_ui_Cell, k2_soundModePlayOneTickLater);
@@ -411,7 +411,7 @@ int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group *group, uint16 creature
 				}
 			}
 			if (L0383_B_CurrentMapIsPartyMap = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) {
-				L0378_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
+				L0378_ps_ActiveGroup = &_g375_activeGroups[group->getActiveGroupIndex()];
 			}
 			if (group->getBehaviour() == k6_behavior_ATTACK) {
 				L0377_ps_Event = _vm->_timeline->_g370_events;
@@ -445,8 +445,8 @@ int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group *group, uint16 creature
 			for (AL0375_ui_NextCreatureIndex = AL0374_ui_CreatureIndex = creatureIndex; AL0374_ui_CreatureIndex < L0379_ui_CreatureCount; AL0374_ui_CreatureIndex++) {
 				AL0375_ui_NextCreatureIndex++;
 				group->_health[AL0374_ui_CreatureIndex] = group->_health[AL0375_ui_NextCreatureIndex];
-				L0382_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0382_ui_GroupDirections, AL0374_ui_CreatureIndex, _vm->_groupMan->M50_getCreatureValue(L0382_ui_GroupDirections, AL0375_ui_NextCreatureIndex));
-				L0381_ui_GroupCells = f178_getGroupValueUpdatedWithCreatureValue(L0381_ui_GroupCells, AL0374_ui_CreatureIndex, _vm->_groupMan->M50_getCreatureValue(L0381_ui_GroupCells, AL0375_ui_NextCreatureIndex));
+				L0382_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0382_ui_GroupDirections, AL0374_ui_CreatureIndex, M50_getCreatureValue(L0382_ui_GroupDirections, AL0375_ui_NextCreatureIndex));
+				L0381_ui_GroupCells = f178_getGroupValueUpdatedWithCreatureValue(L0381_ui_GroupCells, AL0374_ui_CreatureIndex, M50_getCreatureValue(L0381_ui_GroupCells, AL0375_ui_NextCreatureIndex));
 				if (L0383_B_CurrentMapIsPartyMap) {
 					L0378_ps_ActiveGroup->_aspect[AL0374_ui_CreatureIndex] = L0378_ps_ActiveGroup->_aspect[AL0375_ui_NextCreatureIndex];
 				}
@@ -481,7 +481,7 @@ void GroupMan::f189_delete(int16 mapX, int16 mapY) {
 	Group *L0373_ps_Group;
 
 
-	if ((L0372_T_GroupThing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) {
+	if ((L0372_T_GroupThing = f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) {
 		return;
 	}
 	L0373_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0372_T_GroupThing);
@@ -490,7 +490,7 @@ void GroupMan::f189_delete(int16 mapX, int16 mapY) {
 	_vm->_moveSens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
 	L0373_ps_Group->_nextThing = Thing::_none;
 	if (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) {
-		_vm->_groupMan->_g375_activeGroups[L0373_ps_Group->getActiveGroupIndex()]._groupThingIndex = -1;
+		_g375_activeGroups[L0373_ps_Group->getActiveGroupIndex()]._groupThingIndex = -1;
 		_g377_currActiveGroupCount--;
 	}
 	f181_groupDeleteEvents(mapX, mapY);
@@ -609,7 +609,7 @@ void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16
 	if ((_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) && ((AL0446_i_EventType = eventType) != k37_TMEventTypeUpdateBehaviourGroup) && (AL0446_i_EventType != k32_TMEventTypeUpdateAspectGroup) && (AL0446_i_EventType != k38_TMEventTypeUpdateBehaviour_0) && (AL0446_i_EventType != k33_TMEventTypeUpdateAspectCreature_0))
 		goto T0209139_Return;
 	/* If there is no creature at the location specified in the event then the event is ignored */
-	if ((L0449_T_GroupThing = _vm->_groupMan->f175_groupGetThing(eventMapX, eventMapY)) == Thing::_endOfList) {
+	if ((L0449_T_GroupThing = f175_groupGetThing(eventMapX, eventMapY)) == Thing::_endOfList) {
 		goto T0209139_Return;
 	}
 	L0444_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0449_T_GroupThing);
@@ -646,7 +646,7 @@ T0209005_AddEventAndReturn:
 		_g386_fluxCageCount = 0;
 		_g385_fluxCages[0] = 0;
 	}
-	L0445_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[L0444_ps_Group->getActiveGroupIndex()];
+	L0445_ps_ActiveGroup = &_g375_activeGroups[L0444_ps_Group->getActiveGroupIndex()];
 	if ((L0462_i_TicksSinceLastMove = (unsigned char)_vm->_g313_gameTime - L0445_ps_ActiveGroup->_lastMoveTime) < 0) {
 		L0462_i_TicksSinceLastMove += 256;
 	}
@@ -751,7 +751,7 @@ T0209044_SetBehavior6_Attack:
 						L0444_ps_Group->setBehaviour(k6_behavior_ATTACK);
 						AL0446_i_Direction = _g382_currGroupPrimaryDirToParty;
 						for (AL0447_i_CreatureIndex = L0460_ui_CreatureCount; AL0447_i_CreatureIndex >= 0; AL0447_i_CreatureIndex--) {
-							if ((_vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) != AL0446_i_Direction) &&
+							if ((M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) != AL0446_i_Direction) &&
 								((!AL0447_i_CreatureIndex) || (!_vm->getRandomNumber(2)))) {
 								f205_setDirection(L0445_ps_ActiveGroup, AL0446_i_Direction, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
 								M32_setTime(L0465_s_NextEvent._mapTime, _vm->_g313_gameTime + _vm->getRandomNumber(4) + 2); /* Random delay represents the time for the creature to turn */
@@ -976,7 +976,7 @@ T0209096_SetBehavior0_Wander:
 				/* If the creature can see the party and is looking in the party direction or can attack in all direction */
 				if (L0452_i_DistanceToVisibleParty &&
 					(getFlag(L0448_s_CreatureInfo._attributes, k0x0004_MaskCreatureInfo_sideAttack) ||
-					 _vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) == L0454_i_PrimaryDirectionToOrFromParty)) {
+					 M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) == L0454_i_PrimaryDirectionToOrFromParty)) {
 					/* If the creature is in range to attack the party and random test succeeds */
 					if ((L0452_i_DistanceToVisibleParty <= (AL0446_i_Range = L0448_s_CreatureInfo.M56_getAttackRange())) &&
 						(!AL0450_i_DistanceXToParty || !AL0451_i_DistanceYToParty) &&
@@ -985,7 +985,7 @@ T0209096_SetBehavior0_Wander:
 							(!getFlag(AL0446_i_CreatureAttributes = L0448_s_CreatureInfo._attributes, k0x0008_MaskCreatureInfo_preferBackRow) || !_vm->getRandomNumber(4) || !getFlag(AL0446_i_CreatureAttributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) &&
 							(L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter) &&
 							(L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) &&
-							((AL0446_i_Cell = _vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex)) != L0454_i_PrimaryDirectionToOrFromParty) &&
+							((AL0446_i_Cell = M50_getCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex)) != L0454_i_PrimaryDirectionToOrFromParty) &&
 							(AL0446_i_Cell != returnNextVal(L0454_i_PrimaryDirectionToOrFromParty))) { /* If the creature cannot cast spells (range = 1) and is not on a cell where it can attack the party directly and is a quarter square sized creature not in the center of the square then the creature moves to another cell and attack does not occur immediately */
 							if (!L0460_ui_CreatureCount && _vm->getRandomNumber(2)) {
 								L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature;
@@ -995,8 +995,8 @@ T0209096_SetBehavior0_Wander:
 								} else {
 									AL0446_i_Cell++;
 								}
-								if (!_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = M21_normalizeModulo4(AL0446_i_Cell)) ||
-									(_vm->getRandomNumber(2) && !_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((Direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */
+								if (!f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = M21_normalizeModulo4(AL0446_i_Cell)) ||
+									(_vm->getRandomNumber(2) && !f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((Direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */
 									if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* BUG0_70 A projectile impact on a creature may be ignored. The function F0218_PROJECTILE_GetImpactCount to detect projectile impacts when a quarter square sized creature moves inside a group (to another cell on the same square) may fail if there are several creatures in the group because the function expects a single cell index for its last parameter. The function should be called once for each cell where there is a creature */
 										goto T0209139_Return;
 									if (_vm->_projexpl->_g364_creatureDamageOutcome != k1_outcomeKilledSomeCreaturesInGroup) {
@@ -1116,7 +1116,7 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 			return false;
 		}
 	}
-	return (_g388_groupMovementBlockedByGroupThing = _vm->_groupMan->f175_groupGetThing(L0428_i_MapX, L0429_i_MapY)) == Thing::_endOfList;
+	return (_g388_groupMovementBlockedByGroupThing = f175_groupGetThing(L0428_i_MapX, L0429_i_MapY)) == Thing::_endOfList;
 }
 
 int16 GroupMan::f226_getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
@@ -1141,7 +1141,7 @@ int16 GroupMan::f200_groupGetDistanceToVisibleParty(Group *group, int16 creature
 	}
 	if (getFlag(L0424_ps_CreatureInfo->_attributes, k0x0004_MaskCreatureInfo_sideAttack)) /* If creature can see in all directions */
 		goto T0200011;
-	L0423_ui_GroupDirections = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions;
+	L0423_ui_GroupDirections = _g375_activeGroups[group->getActiveGroupIndex()]._directions;
 	if (creatureIndex < 0) { /* Negative index means test if each creature in the group can see the party in their respective direction */
 		L0421_i_CreatureViewDirectionCount = 0;
 		for (creatureIndex = group->getCount(); creatureIndex >= 0; creatureIndex--) {
@@ -1156,7 +1156,7 @@ T0200006:
 			;
 		}
 	} else { /* Positive index means test only if the specified creature in the group can see the party in its direction */
-		L0425_ai_CreatureViewDirections[0] = _vm->_groupMan->M50_getCreatureValue(L0423_ui_GroupDirections, creatureIndex);
+		L0425_ai_CreatureViewDirections[0] = M50_getCreatureValue(L0423_ui_GroupDirections, creatureIndex);
 		L0421_i_CreatureViewDirectionCount = 1;
 	}
 	while (L0421_i_CreatureViewDirectionCount--) {
@@ -1323,7 +1323,7 @@ void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 crea
 	if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) {
 		return;
 	}
-	if (M21_normalizeModulo4(_vm->_groupMan->M50_getCreatureValue(L0435_ui_GroupDirections = activeGroup->_directions, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */
+	if (M21_normalizeModulo4(M50_getCreatureValue(L0435_ui_GroupDirections = activeGroup->_directions, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */
 		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + dir));
 	} else {
 		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir);
@@ -1433,13 +1433,13 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 #define AL0440_i_AttackSoundOrdinal L0440_i_Multiple
 
 	_vm->_projexpl->_g361_lastCreatureAttackTime = _vm->_g313_gameTime;
-	ActiveGroup L0443_s_ActiveGroup = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
+	ActiveGroup L0443_s_ActiveGroup = _g375_activeGroups[group->getActiveGroupIndex()];
 	CreatureInfo *L0441_ps_CreatureInfo = &g243_CreatureInfo[AL0437_ui_CreatureType = group->_type];
 	uint16 L0438_ui_PrimaryDirectionToParty = _g382_currGroupPrimaryDirToParty;
 	if ((AL0439_i_GroupCells = L0443_s_ActiveGroup._cells) == k255_CreatureTypeSingleCenteredCreature) {
 		AL0439_i_TargetCell = _vm->getRandomNumber(2);
 	} else {
-		AL0439_i_TargetCell = ((_vm->_groupMan->M50_getCreatureValue(AL0439_i_GroupCells, creatureIndex) + 5 - L0438_ui_PrimaryDirectionToParty) & 0x0002) >> 1;
+		AL0439_i_TargetCell = ((M50_getCreatureValue(AL0439_i_GroupCells, creatureIndex) + 5 - L0438_ui_PrimaryDirectionToParty) & 0x0002) >> 1;
 	}
 	AL0439_i_TargetCell += L0438_ui_PrimaryDirectionToParty;
 	AL0439_i_TargetCell &= 0x0003;
@@ -1575,7 +1575,7 @@ void GroupMan::f193_stealFromChampion(Group *group, uint16 championIndex) {
 		L0391_i_Percentage -= 20;
 	}
 	if (!_vm->getRandomNumber(8) || (L0396_B_ObjectStolen && _vm->getRandomNumber(2))) {
-		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._delayFleeingFromTarget = _vm->getRandomNumber(64) + 20;
+		_g375_activeGroups[group->getActiveGroupIndex()]._delayFleeingFromTarget = _vm->getRandomNumber(64) + 20;
 		group->setBehaviour(k5_behavior_FLEE);
 	}
 }
@@ -1668,7 +1668,7 @@ void GroupMan::f180_startWanedring(int16 mapX, int16 mapY) {
 	TimelineEvent L0333_s_Event;
 
 
-	L0332_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(mapX, mapY));
+	L0332_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(f175_groupGetThing(mapX, mapY));
 	if (L0332_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
 		L0332_ps_Group->setBehaviour(k0_behavior_WANDER);
 	}
@@ -1688,10 +1688,10 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
 	int16 L0344_i_ActiveGroupIndex;
 
 
-	L0341_ps_ActiveGroup = _vm->_groupMan->_g375_activeGroups;
+	L0341_ps_ActiveGroup = _g375_activeGroups;
 	L0344_i_ActiveGroupIndex = 0;
 	while (L0341_ps_ActiveGroup->_groupThingIndex >= 0) {
-		if (++L0344_i_ActiveGroupIndex >= _vm->_groupMan->_g376_maxActiveGroupCount) {
+		if (++L0344_i_ActiveGroupIndex >= _g376_maxActiveGroupCount) {
 			return;
 		}
 		L0341_ps_ActiveGroup++;
@@ -1721,10 +1721,10 @@ void GroupMan::f184_removeActiveGroup(uint16 activeGroupIndex) {
 	Group *L0348_ps_Group;
 
 
-	if ((activeGroupIndex > _vm->_groupMan->_g376_maxActiveGroupCount) || (_vm->_groupMan->_g375_activeGroups[activeGroupIndex]._groupThingIndex < 0)) {
+	if ((activeGroupIndex > _g376_maxActiveGroupCount) || (_g375_activeGroups[activeGroupIndex]._groupThingIndex < 0)) {
 		return;
 	}
-	L0347_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[activeGroupIndex];
+	L0347_ps_ActiveGroup = &_g375_activeGroups[activeGroupIndex];
 	L0348_ps_Group = &((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex];
 	_g377_currActiveGroupCount--;
 	L0348_ps_Group->_cells = L0347_ps_ActiveGroup->_cells;
@@ -1737,7 +1737,7 @@ void GroupMan::f184_removeActiveGroup(uint16 activeGroupIndex) {
 
 void GroupMan::f194_removeAllActiveGroups() {
 	for (int16 L0397_ui_ActiveGroupIndex = 0; _g377_currActiveGroupCount > 0; L0397_ui_ActiveGroupIndex++) {
-		if (_vm->_groupMan->_g375_activeGroups[L0397_ui_ActiveGroupIndex]._groupThingIndex >= 0) {
+		if (_g375_activeGroups[L0397_ui_ActiveGroupIndex]._groupThingIndex >= 0) {
 			f184_removeActiveGroup(L0397_ui_ActiveGroupIndex);
 		}
 	}
@@ -1780,7 +1780,7 @@ Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplie
 	bool L0355_B_SeveralCreaturesInGroup;
 
 
-	if (((_g377_currActiveGroupCount >= (_vm->_groupMan->_g376_maxActiveGroupCount - 5)) && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) || ((L0349_T_GroupThing = _vm->_dungeonMan->f166_getUnusedThing(k4_GroupThingType)) == Thing::_none)) {
+	if (((_g377_currActiveGroupCount >= (_g376_maxActiveGroupCount - 5)) && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) || ((L0349_T_GroupThing = _vm->_dungeonMan->f166_getUnusedThing(k4_GroupThingType)) == Thing::_none)) {
 		return Thing::_none;
 	}
 	L0353_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0349_T_GroupThing);
@@ -1828,14 +1828,14 @@ int16 GroupMan::f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, i
 	signed char L0325_auc_OrderedCellsToAttack[4];
 
 
-	if ((L0323_T_GroupThing = _vm->_groupMan->f175_groupGetThing(groupX, groupY)) == Thing::_endOfList) {
+	if ((L0323_T_GroupThing = f175_groupGetThing(groupX, groupY)) == Thing::_endOfList) {
 		return 0;
 	}
 	L0324_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0323_T_GroupThing);
 	f229_setOrderedCellsToAttack(L0325_auc_OrderedCellsToAttack, groupX, groupY, partyX, partyY, champCell);
 	L0321_ui_Counter = 0;
 	for (;;) { /*_Infinite loop_*/
-		if (L0322_i_CreatureOrdinal = _vm->_groupMan->f176_getCreatureOrdinalInCell(L0324_ps_Group, L0325_auc_OrderedCellsToAttack[L0321_ui_Counter])) {
+		if (L0322_i_CreatureOrdinal = f176_getCreatureOrdinalInCell(L0324_ps_Group, L0325_auc_OrderedCellsToAttack[L0321_ui_Counter])) {
 			return L0322_i_CreatureOrdinal;
 		}
 		L0321_ui_Counter++;
@@ -1979,7 +1979,7 @@ uint16 GroupMan::f222_isLordChaosOnSquare(int16 mapX, int16 mapY) {
 	Thing L0542_T_Thing;
 	Group* L0543_ps_Group;
 
-	if ((L0542_T_Thing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) {
+	if ((L0542_T_Thing = f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) {
 		return 0;
 	}
 	L0543_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0542_T_Thing);
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index da59e70..019ef5e 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -86,14 +86,14 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 		return;
 	}
 	_vm->_g321_stopWaitingForPlayerInput = true;
-	AL1102_ui_InventoryChampionOrdinal = _vm->_inventoryMan->_g432_inventoryChampionOrdinal;
+	AL1102_ui_InventoryChampionOrdinal = _g432_inventoryChampionOrdinal;
 	if (_vm->M0_indexToOrdinal(championIndex) == AL1102_ui_InventoryChampionOrdinal) {
 		championIndex = k4_ChampionCloseInventory;
 	}
 	_vm->_eventMan->f78_showMouse();
 	if (AL1102_ui_InventoryChampionOrdinal) {
-		_vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
-		_vm->_inventoryMan->f334_closeChest();
+		_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+		f334_closeChest();
 		L1103_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(AL1102_ui_InventoryChampionOrdinal)];
 		if (L1103_ps_Champion->_currHealth && !_vm->_championMan->_g299_candidateChampionOrdinal) {
 			setFlag(L1103_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox);
@@ -115,7 +115,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 		}
 	}
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(championIndex);
+	_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(championIndex);
 	if (!AL1102_ui_InventoryChampionOrdinal) {
 		warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox");
 	}
@@ -694,8 +694,8 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 	static char* G0431_apc_StatisticNames[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"};
 
 
-	_vm->_inventoryMan->f334_closeChest();
-	L1094_ps_Champion = &_vm->_championMan->_gK71_champions[L1093_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal)];
+	f334_closeChest();
+	L1094_ps_Champion = &_vm->_championMan->_gK71_champions[L1093_ui_ChampionIndex = _vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal)];
 	_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
 	L1091_i_Y = 58;
 	for (AL1090_ui_SkillIndex = k0_ChampionSkillFighter; AL1090_ui_SkillIndex <= k3_ChampionSkillWizard; AL1090_ui_SkillIndex++) {
@@ -731,7 +731,7 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 }
 
 void InventoryMan::f350_drawStopPressingMouth() {
-	_vm->_inventoryMan->f347_drawPanel();
+	f347_drawPanel();
 	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
 	warning(false, "Ignored code: G0587_i_HideMousePointerRequestCount");
 	_vm->_eventMan->f77_hideMouse();
@@ -740,8 +740,8 @@ void InventoryMan::f350_drawStopPressingMouth() {
 void InventoryMan::f353_drawStopPressingEye() {
 	Thing L1100_T_LeaderHandObject;
 
-	_vm->_inventoryMan->f332_drawIconToViewport(k202_IconIndiceEyeNotLooking, 12, 13);
-	_vm->_inventoryMan->f347_drawPanel();
+	f332_drawIconToViewport(k202_IconIndiceEyeNotLooking, 12, 13);
+	f347_drawPanel();
 	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
 	if ((L1100_T_LeaderHandObject = _vm->_championMan->_g414_leaderHandObject) != Thing::_none) {
 		_vm->_objectMan->f34_drawLeaderObjectName(L1100_T_LeaderHandObject);
@@ -781,7 +781,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 
 
 	if (_vm->_championMan->_g415_leaderEmptyHanded) {
-		if (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned) {
+		if (_g424_panelContent == k0_PanelContentFoodWaterPoisoned) {
 			return;
 		}
 		_vm->_eventMan->_g597_ignoreMouseMovements = true;
@@ -793,7 +793,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 		} else {
 			_vm->_eventMan->f78_showMouse();
 			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
-			_vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned();
+			f345_drawPanelFoodWaterPoisoned();
 			_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
 		}
 		return;
@@ -807,7 +807,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 	L1079_ui_IconIndex = _vm->_objectMan->f33_getIconIndex(L1078_T_Thing);
 	AL1088_ui_ThingType = L1078_T_Thing.getType();
 	L1089_ui_Weight = _vm->_dungeonMan->f140_getObjectWeight(L1078_T_Thing);
-	L1083_ps_Champion = &_vm->_championMan->_gK71_champions[L1080_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal)];
+	L1083_ps_Champion = &_vm->_championMan->_gK71_champions[L1080_ui_ChampionIndex = _vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal)];
 	L1082_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1078_T_Thing);
 	if ((L1079_ui_IconIndex >= k8_IconIndiceJunkWater) && (L1079_ui_IconIndex <= k9_IconIndiceJunkWaterSkin)) {
 		if (!(L1082_ps_Junk->getChargeCount())) {
@@ -915,7 +915,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 	}
 	_vm->f064_SOUND_RequestPlay_CPSD(k08_soundSWALLOW, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
 	setFlag(L1083_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
-	if (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned) {
+	if (_g424_panelContent == k0_PanelContentFoodWaterPoisoned) {
 		setFlag(L1083_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
 	}
 	_vm->_championMan->f292_drawChampionState((ChampionIndex)L1080_ui_ChampionIndex);
@@ -954,12 +954,12 @@ void InventoryMan::f352_processCommand71_clickOnEye() {
 	_vm->_eventMan->f357_discardAllInput();
 	_vm->_eventMan->f78_showMouse();
 	_vm->f22_delay(8);
-	_vm->_inventoryMan->f332_drawIconToViewport(k203_IconIndiceEyeLooking, 12, 13);
+	f332_drawIconToViewport(k203_IconIndiceEyeLooking, 12, 13);
 	if (_vm->_championMan->_g415_leaderEmptyHanded) {
 		f351_drawChampionSkillsAndStatistics();
 	} else {
 		_vm->_objectMan->f35_clearLeaderObjectName();
-		_vm->_inventoryMan->f342_drawPanelObject(_vm->_championMan->_g414_leaderHandObject, true);
+		f342_drawPanelObject(_vm->_championMan->_g414_leaderHandObject, true);
 	}
 	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index b6db53d..7ac96eb 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -415,12 +415,12 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 		return;
 	}
 	L1213_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex = (ChampionIndex)champIndex];
-	_vm->_menuMan->f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
+	f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
 	_vm->_eventMan->f78_showMouse();
-	_vm->_menuMan->f393_drawSpellAreaControls((ChampionIndex)champIndex);
-	_vm->_displayMan->f21_blitToScreen(_vm->_menuMan->_gK72_bitmapSpellAreaLine, &gK75_BoxSpellAreaLine2, k48_byteWidth, kM1_ColorNoTransparency, 12);
-	_vm->_menuMan->f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols);
-	_vm->_displayMan->f21_blitToScreen(_vm->_menuMan->_gK72_bitmapSpellAreaLine, &gK76_BoxSpellAreaLine3, k48_byteWidth, kM1_ColorNoTransparency, 12);
+	f393_drawSpellAreaControls((ChampionIndex)champIndex);
+	_vm->_displayMan->f21_blitToScreen(_gK72_bitmapSpellAreaLine, &gK75_BoxSpellAreaLine2, k48_byteWidth, kM1_ColorNoTransparency, 12);
+	f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols);
+	_vm->_displayMan->f21_blitToScreen(_gK72_bitmapSpellAreaLine, &gK76_BoxSpellAreaLine3, k48_byteWidth, kM1_ColorNoTransparency, 12);
 	_vm->_eventMan->f77_hideMouse();
 }
 
@@ -436,17 +436,17 @@ void MenuMan::f457_drawEnabledMenus() {
 	} else {
 		AL1462_i_MagicCasterChampionIndex = _vm->_championMan->_g514_magicCasterChampionIndex;
 		_vm->_championMan->_g514_magicCasterChampionIndex = kM1_ChampionNone; /* Force next function to draw the spell area */
-		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(AL1462_i_MagicCasterChampionIndex);
+		f394_setMagicCasterAndDrawSpellArea(AL1462_i_MagicCasterChampionIndex);
 		if (!_vm->_championMan->_g506_actingChampionOrdinal) {
-			_vm->_menuMan->_g509_actionAreaContainsIcons = true;
+			_g509_actionAreaContainsIcons = true;
 		}
-		_vm->_menuMan->f387_drawActionArea();
+		f387_drawActionArea();
 		if (AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 			_vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
 			_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)_vm->M1_ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
 		} else {
 			_vm->_displayMan->f98_drawFloorAndCeiling();
-			_vm->_menuMan->f395_drawMovementArrows();
+			f395_drawMovementArrows();
 		}
 		_vm->_eventMan->f69_setMousePointer();
 	}
@@ -862,7 +862,7 @@ bool MenuMan::f391_didClickTriggerAction(int16 actionListIndex) {
 	Champion* L1199_ps_Champion;
 
 
-	if (!_vm->_championMan->_g506_actingChampionOrdinal || (actionListIndex != -1 && (_vm->_menuMan->_g713_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone)))
+	if (!_vm->_championMan->_g506_actingChampionOrdinal || (actionListIndex != -1 && (_g713_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone)))
 		return false;
 
 	L1199_ps_Champion = &_vm->_championMan->_gK71_champions[L1196_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)];
@@ -871,14 +871,14 @@ bool MenuMan::f391_didClickTriggerAction(int16 actionListIndex) {
 		// L1198_B_ClickTriggeredAction is set to -1 since booleans are stored in int16 in the original
 		L1198_B_ClickTriggeredAction = true;
 	} else {
-		L1197_ui_ActionIndex = _vm->_menuMan->_g713_actionList._actionIndices[actionListIndex];
+		L1197_ui_ActionIndex = _g713_actionList._actionIndices[actionListIndex];
 		L1199_ps_Champion->_actionDefense += g495_actionDefense[L1197_ui_ActionIndex]; /* BUG0_54 The defense modifier of an action is permanent.
 																									 Each action has an associated defense modifier value and a number of ticks while the champion cannot perform another action because the action icon is grayed out. If an action has a non zero defense modifier and a zero value for the number of ticks then the defense modifier is applied but it is never removed. This causes no issue in the original games because there are no actions in this case but it may occur in a version where data is customized. This statement should only be executed if the value for the action in G0491_auc_Graphic560_ActionDisabledTicks is not 0 otherwise the action is not disabled at the end of F0407_MENUS_IsActionPerformed and thus not enabled later in F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction where the defense modifier is also removed */
 		setFlag(L1199_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
 		L1198_B_ClickTriggeredAction = f407_isActionPerformed(L1196_ui_ChampionIndex, L1197_ui_ActionIndex);
 		L1199_ps_Champion->_actionIndex = (ChampionAction)L1197_ui_ActionIndex;
 	}
-	_vm->_menuMan->f388_clearActingChampion();
+	f388_clearActingChampion();
 	return L1198_B_ClickTriggeredAction;
 }
 
@@ -1155,7 +1155,7 @@ T0407014:
 			if ((AL1246_i_ActionHandWeaponClass >= k32_WeaponClassFirstSling) && (AL1246_i_ActionHandWeaponClass <= k47_WeaponClassLastSling)) {
 				if (AL1250_i_ReadyHandWeaponClass != k11_WeaponClassSlingAmmunition) {
 T0407032:
-					_vm->_menuMan->_g513_actionDamage = kM2_damageNoAmmunition;
+					_g513_actionDamage = kM2_damageNoAmmunition;
 					L1255_i_ActionExperienceGain = 0;
 					AL1245_B_ActionPerformed = false;
 					break;
@@ -1441,7 +1441,7 @@ bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int
 			AL1237_ui_CellDelta = 1;
 T0402005: /* Check if there is another champion in front */
 			if (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL1236_ui_ChampionCell + AL1237_ui_CellDelta)) != kM1_ChampionNone) {
-				_vm->_menuMan->_g513_actionDamage = kM1_damageCantReach;
+				_g513_actionDamage = kM1_damageCantReach;
 				goto T0402010;
 			}
 		}
@@ -1452,7 +1452,7 @@ T0402005: /* Check if there is another champion in front */
 		if ((_vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
 			setFlag(AL1237_ui_ActionHitProbability, k0x8000_hitNonMaterialCreatures);
 		}
-		_vm->_menuMan->_g513_actionDamage = _vm->_groupMan->f231_getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing), _vm->M1_ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
+		_g513_actionDamage = _vm->_groupMan->f231_getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing), _vm->M1_ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
 		return true;
 	}
 T0402010:
@@ -1612,11 +1612,11 @@ void MenuMan::f389_processCommands116To119_setActingChampion(uint16 champIndex)
 	L1191_ps_ActionSet = &G0489_as_Graphic560_ActionSets[L1188_ui_ActionSetIndex];
 	_vm->_championMan->_g506_actingChampionOrdinal = _vm->M0_indexToOrdinal(champIndex);
 	f383_setActionList(L1191_ps_ActionSet);
-	_vm->_menuMan->_g509_actionAreaContainsIcons = false;
+	_g509_actionAreaContainsIcons = false;
 	setFlag(L1190_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand);
 	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
-	_vm->_menuMan->f387_drawActionArea();
-	_vm->_menuMan->f387_drawActionArea();
+	f387_drawActionArea();
+	f387_drawActionArea();
 }
 
 void MenuMan::f383_setActionList(ActionSet* actionSet) {
@@ -1628,8 +1628,8 @@ void MenuMan::f383_setActionList(ActionSet* actionSet) {
 	uint16 L1171_ui_ActionIndex;
 	uint16 L1172_ui_MinimumSkillLevel;
 
-	_vm->_menuMan->_g713_actionList._actionIndices[0] = (ChampionAction)actionSet->_actionIndices[0];
-	_vm->_menuMan->_g713_actionList._minimumSkillLevel[0] = 1;
+	_g713_actionList._actionIndices[0] = (ChampionAction)actionSet->_actionIndices[0];
+	_g713_actionList._minimumSkillLevel[0] = 1;
 	L1170_ui_NextAvailableActionListIndex = 1;
 	for (L1169_ui_ActionListIndex = 1; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) {
 		if ((L1171_ui_ActionIndex = actionSet->_actionIndices[L1169_ui_ActionListIndex]) == k255_ChampionActionNone)
@@ -1638,14 +1638,14 @@ void MenuMan::f383_setActionList(ActionSet* actionSet) {
 			continue;
 		clearFlag(L1172_ui_MinimumSkillLevel, k0x0080_actionRequiresCharge);
 		if (_vm->_championMan->f303_getSkillLevel(_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal), g496_ActionSkillIndex[L1171_ui_ActionIndex]) >= L1172_ui_MinimumSkillLevel) {
-			_vm->_menuMan->_g713_actionList._actionIndices[L1170_ui_NextAvailableActionListIndex] = (ChampionAction)L1171_ui_ActionIndex;
-			_vm->_menuMan->_g713_actionList._minimumSkillLevel[L1170_ui_NextAvailableActionListIndex] = L1172_ui_MinimumSkillLevel;
+			_g713_actionList._actionIndices[L1170_ui_NextAvailableActionListIndex] = (ChampionAction)L1171_ui_ActionIndex;
+			_g713_actionList._minimumSkillLevel[L1170_ui_NextAvailableActionListIndex] = L1172_ui_MinimumSkillLevel;
 			L1170_ui_NextAvailableActionListIndex++;
 		}
 	}
 	_g507_actionCount = L1170_ui_NextAvailableActionListIndex;
 	for (L1169_ui_ActionListIndex = L1170_ui_NextAvailableActionListIndex; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) {
-		_vm->_menuMan->_g713_actionList._actionIndices[L1169_ui_ActionListIndex] = k255_ChampionActionNone;
+		_g713_actionList._actionIndices[L1169_ui_ActionListIndex] = k255_ChampionActionNone;
 	}
 }
 
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 192e661..0c00e20 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -138,7 +138,7 @@ IconIndice ObjectMan::f32_getObjectType(Thing thing) {
 byte g29_ChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType
 
 IconIndice ObjectMan::f33_getIconIndex(Thing thing) {
-	int16 L0005_i_IconIndex = _vm->_objectMan->f32_getObjectType(thing);
+	int16 L0005_i_IconIndex = f32_getObjectType(thing);
 	if (L0005_i_IconIndex != kM1_IconIndiceNone) {
 		if (((L0005_i_IconIndex < k32_IconIndiceWeaponDagger) && (L0005_i_IconIndex >= k0_IconIndiceJunkCompassNorth)) ||
 			((L0005_i_IconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (L0005_i_IconIndex <= k163_IconIndicePotionWaterFlask)) ||
@@ -208,7 +208,7 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 	byte* L0020_puc_Bitmap_Destination;
 	int16 L1569_i_Width;
 
-	L0017_ps_SlotBox = &_vm->_objectMan->_g30_slotBoxes[slotBoxIndex];
+	L0017_ps_SlotBox = &_g30_slotBoxes[slotBoxIndex];
 	if ((L0017_ps_SlotBox->_iconIndex = iconIndex) == kM1_IconIndiceNone) {
 		return;
 	}
@@ -237,15 +237,15 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 
 void ObjectMan::f34_drawLeaderObjectName(Thing thing) {
 	char* objectName = nullptr;
-	int16 L0007_i_IconIndex = _vm->_objectMan->f33_getIconIndex(thing);
+	int16 L0007_i_IconIndex = f33_getIconIndex(thing);
 	if (L0007_i_IconIndex == k147_IconIndiceJunkChampionBones) {
 		Junk *junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing);
 		char champBonesName[16];
 		strcpy(champBonesName, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name);
-		strcat(champBonesName, _vm->_objectMan->_g352_objectNames[L0007_i_IconIndex]);
+		strcat(champBonesName, _g352_objectNames[L0007_i_IconIndex]);
 		objectName = champBonesName;
 	} else {
-		objectName = _vm->_objectMan->_g352_objectNames[L0007_i_IconIndex];
+		objectName = _g352_objectNames[L0007_i_IconIndex];
 	}
 	_vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, 233, 37, k4_ColorCyan, k0_ColorBlack, objectName, k14_ObjectNameMaximumLength, k200_heightScreen);
 }
@@ -265,7 +265,7 @@ void ObjectMan::f37_drawIconToScreen(int16 iconIndex, int16 posX, int16 posY) {
 
 	L0014_s_Box._x2 = (L0014_s_Box._x1 = posX) + 15;
 	L0014_s_Box._y2 = (L0014_s_Box._y1 = posY) + 15;
-	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, L0013_puc_Bitmap_Icon);
+	f36_extractIconFromBitmap(iconIndex, L0013_puc_Bitmap_Icon);
 	_vm->_displayMan->f21_blitToScreen(L0013_puc_Bitmap_Icon, &L0014_s_Box, k8_byteWidth, kM1_ColorNoTransparency, 16);
 }
 }
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index d55ebca..51d203d 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -157,7 +157,7 @@ void TextMan::f46_messageAreaPrintString(Color color, const char* string) {
 	L0030_i_StringLength = strlen(string);
 	warning(false, "MISSING CODE: F0561_SCROLLER_IsTextScrolling");
 	if (true) { // there is a test here with F0561_SCROLLER_IsTextScrolling
-		_vm->_textMan->f53_printToLogicalScreen(_g359_messageAreaCursorColumn * 6, (_g358_messageAreaCursorRow * 7 - 6) + 177, color, k0_ColorBlack, string);
+		f53_printToLogicalScreen(_g359_messageAreaCursorColumn * 6, (_g358_messageAreaCursorRow * 7 - 6) + 177, color, k0_ColorBlack, string);
 	} else {
 		f40_printTextToBitmap(_g356_bitmapMessageAreaNewRow, k160_byteWidthScreen, _g359_messageAreaCursorColumn * 6, 5, color, k0_ColorBlack, string, 7);
 		warning(false, "MISSING CODE: F0561_SCROLLER_IsTextScrolling");
@@ -223,6 +223,6 @@ void TextMan::f443_endgamePrintString(int16 x, int16 y, Color textColor, char* t
 		}
 		L1407_pc_Character++;
 	}
-	_vm->_textMan->f53_printToLogicalScreen(x, y, textColor, k12_ColorDarkestGray, L1408_ac_ModifiedString);
+	f53_printToLogicalScreen(x, y, textColor, k12_ColorDarkestGray, L1408_ac_ModifiedString);
 }
 }
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index e2b3f5f..6e5f482 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -114,19 +114,19 @@ void Timeline::f237_deleteEvent(uint16 eventIndex) {
 	uint16 L0587_ui_EventCount;
 
 
-	_vm->_timeline->_g370_events[eventIndex]._type = k0_TMEventTypeNone;
-	if (eventIndex < _vm->_timeline->_g373_firstUnusedEventIndex) {
-		_vm->_timeline->_g373_firstUnusedEventIndex = eventIndex;
+	_g370_events[eventIndex]._type = k0_TMEventTypeNone;
+	if (eventIndex < _g373_firstUnusedEventIndex) {
+		_g373_firstUnusedEventIndex = eventIndex;
 	}
-	_vm->_timeline->_g372_eventCount--;
-	if ((L0587_ui_EventCount = _vm->_timeline->_g372_eventCount) == 0) {
+	_g372_eventCount--;
+	if ((L0587_ui_EventCount = _g372_eventCount) == 0) {
 		return;
 	}
 	L0586_ui_TimelineIndex = f235_getIndex(eventIndex);
 	if (L0586_ui_TimelineIndex == L0587_ui_EventCount) {
 		return;
 	}
-	_vm->_timeline->_g371_timeline[L0586_ui_TimelineIndex] = _vm->_timeline->_g371_timeline[L0587_ui_EventCount];
+	_g371_timeline[L0586_ui_TimelineIndex] = _g371_timeline[L0587_ui_EventCount];
 	f236_fixChronology(L0586_ui_TimelineIndex);
 }
 
@@ -138,16 +138,16 @@ void Timeline::f236_fixChronology(uint16 timelineIndex) {
 	bool L0585_B_ChronologyFixed;
 
 
-	if ((L0583_ui_EventCount = _vm->_timeline->_g372_eventCount) == 1) {
+	if ((L0583_ui_EventCount = _g372_eventCount) == 1) {
 		return;
 	}
 
-	L0584_ps_Event = &_vm->_timeline->_g370_events[L0582_ui_EventIndex = _vm->_timeline->_g371_timeline[timelineIndex]];
+	L0584_ps_Event = &_g370_events[L0582_ui_EventIndex = _g371_timeline[timelineIndex]];
 	L0585_B_ChronologyFixed = false;
 	while (timelineIndex > 0) { /* Check if the event should be moved earlier in the timeline */
 		L0581_ui_TimelineIndex = (timelineIndex - 1) >> 1;
-		if (f234_isEventABeforeB(L0584_ps_Event, &_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex]])) {
-			_vm->_timeline->_g371_timeline[timelineIndex] = _vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex];
+		if (f234_isEventABeforeB(L0584_ps_Event, &_g370_events[_g371_timeline[L0581_ui_TimelineIndex]])) {
+			_g371_timeline[timelineIndex] = _g371_timeline[L0581_ui_TimelineIndex];
 			timelineIndex = L0581_ui_TimelineIndex;
 			L0585_B_ChronologyFixed = true;
 		} else {
@@ -159,18 +159,18 @@ void Timeline::f236_fixChronology(uint16 timelineIndex) {
 	L0583_ui_EventCount = ((L0583_ui_EventCount - 1) - 1) >> 1;
 	while (timelineIndex <= L0583_ui_EventCount) { /* Check if the event should be moved later in the timeline */
 		L0581_ui_TimelineIndex = (timelineIndex << 1) + 1;
-		if (((L0581_ui_TimelineIndex + 1) < _vm->_timeline->_g372_eventCount) && (f234_isEventABeforeB(&_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex + 1]], &_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex]]))) {
+		if (((L0581_ui_TimelineIndex + 1) < _g372_eventCount) && (f234_isEventABeforeB(&_g370_events[_g371_timeline[L0581_ui_TimelineIndex + 1]], &_g370_events[_g371_timeline[L0581_ui_TimelineIndex]]))) {
 			L0581_ui_TimelineIndex++;
 		}
-		if (f234_isEventABeforeB(&_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex]], L0584_ps_Event)) {
-			_vm->_timeline->_g371_timeline[timelineIndex] = _vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex];
+		if (f234_isEventABeforeB(&_g370_events[_g371_timeline[L0581_ui_TimelineIndex]], L0584_ps_Event)) {
+			_g371_timeline[timelineIndex] = _g371_timeline[L0581_ui_TimelineIndex];
 			timelineIndex = L0581_ui_TimelineIndex;
 		} else {
 			break;
 		}
 	}
 T0236011:
-	_vm->_timeline->_g371_timeline[timelineIndex] = L0582_ui_EventIndex;
+	_g371_timeline[timelineIndex] = L0582_ui_EventIndex;
 }
 
 bool Timeline::f234_isEventABeforeB(TimelineEvent* eventA, TimelineEvent* eventB) {
@@ -186,11 +186,11 @@ uint16 Timeline::f235_getIndex(uint16 eventIndex) {
 	uint16* L0580_pui_TimelineEntry;
 
 
-	for (L0579_ui_TimelineIndex = 0, L0580_pui_TimelineEntry = _vm->_timeline->_g371_timeline; L0579_ui_TimelineIndex < _vm->_timeline->_g369_eventMaxCount; L0579_ui_TimelineIndex++) {
+	for (L0579_ui_TimelineIndex = 0, L0580_pui_TimelineEntry = _g371_timeline; L0579_ui_TimelineIndex < _g369_eventMaxCount; L0579_ui_TimelineIndex++) {
 		if (*L0580_pui_TimelineEntry++ == eventIndex)
 			break;
 	}
-	if (L0579_ui_TimelineIndex >= _vm->_timeline->_g369_eventMaxCount) { /* BUG0_00 Useless code. The function is always called with event indices that are in the timeline */
+	if (L0579_ui_TimelineIndex >= _g369_eventMaxCount) { /* BUG0_00 Useless code. The function is always called with event indices that are in the timeline */
 		L0579_ui_TimelineIndex = 0; /* BUG0_01 Coding error without consequence. Wrong return value. If the specified event index is not found in the timeline the function returns 0 which is the same value that is returned if the event index is found in the first timeline entry. No consequence because this code is never executed */
 	}
 	return L0579_ui_TimelineIndex;
@@ -202,11 +202,11 @@ uint16 Timeline::f238_addEventGetEventIndex(TimelineEvent* event) {
 	TimelineEvent* L0591_ps_Event;
 
 
-	if (_vm->_timeline->_g372_eventCount == _vm->_timeline->_g369_eventMaxCount) {
+	if (_g372_eventCount == _g369_eventMaxCount) {
 		_vm->f19_displayErrorAndStop(45);
 	}
 	if ((event->_type >= k5_TMEventTypeCorridor) && (event->_type <= k10_TMEventTypeDoor)) {
-		for (L0588_ui_EventIndex = 0, L0591_ps_Event = _vm->_timeline->_g370_events; L0588_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
+		for (L0588_ui_EventIndex = 0, L0591_ps_Event = _g370_events; L0588_ui_EventIndex < _g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
 			if ((L0591_ps_Event->_type >= k5_TMEventTypeCorridor) && (L0591_ps_Event->_type <= k10_TMEventTypeDoor)) {
 				if ((event->_mapTime == L0591_ps_Event->_mapTime) && (event->getMapXY() == L0591_ps_Event->getMapXY()) && ((L0591_ps_Event->_type != k6_TMEventTypeWall) || (L0591_ps_Event->_C.A._cell == event->_C.A._cell))) {
 					L0591_ps_Event->_C.A._effect = event->_C.A._effect;
@@ -225,7 +225,7 @@ uint16 Timeline::f238_addEventGetEventIndex(TimelineEvent* event) {
 		}
 	} else {
 		if (event->_type == k1_TMEventTypeDoorAnimation) {
-			for (L0588_ui_EventIndex = 0, L0591_ps_Event = _vm->_timeline->_g370_events; L0588_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
+			for (L0588_ui_EventIndex = 0, L0591_ps_Event = _g370_events; L0588_ui_EventIndex < _g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
 				if ((event->_mapTime == L0591_ps_Event->_mapTime) && (event->getMapXY() == L0591_ps_Event->getMapXY())) {
 					if (L0591_ps_Event->_type == k10_TMEventTypeDoor) {
 						if (L0591_ps_Event->_C.A._effect == k2_SensorEffToggle) {
@@ -241,7 +241,7 @@ uint16 Timeline::f238_addEventGetEventIndex(TimelineEvent* event) {
 			}
 		} else {
 			if (event->_type == k2_TMEventTypeDoorDestruction) {
-				for (L0588_ui_EventIndex = 0, L0591_ps_Event = _vm->_timeline->_g370_events; L0588_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
+				for (L0588_ui_EventIndex = 0, L0591_ps_Event = _g370_events; L0588_ui_EventIndex < _g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
 					if ((event->getMapXY() == L0591_ps_Event->getMapXY()) && (M29_map(event->_mapTime) == M29_map(L0591_ps_Event->_mapTime))) {
 						if ((L0591_ps_Event->_type == k1_TMEventTypeDoorAnimation) || (L0591_ps_Event->_type == k10_TMEventTypeDoor)) {
 							f237_deleteEvent(L0588_ui_EventIndex);
@@ -251,14 +251,14 @@ uint16 Timeline::f238_addEventGetEventIndex(TimelineEvent* event) {
 			}
 		}
 	}
-	_vm->_timeline->_g370_events[L0590_ui_NewEventIndex = _vm->_timeline->_g373_firstUnusedEventIndex] = *event; /* Copy the event data (Megamax C can assign structures) */
+	_g370_events[L0590_ui_NewEventIndex = _g373_firstUnusedEventIndex] = *event; /* Copy the event data (Megamax C can assign structures) */
 	do {
-		if (_vm->_timeline->_g373_firstUnusedEventIndex == _vm->_timeline->_g369_eventMaxCount)
+		if (_g373_firstUnusedEventIndex == _g369_eventMaxCount)
 			break;
-		_vm->_timeline->_g373_firstUnusedEventIndex++;
-	} while ((_vm->_timeline->_g370_events[_vm->_timeline->_g373_firstUnusedEventIndex])._type != k0_TMEventTypeNone);
-	_vm->_timeline->_g371_timeline[_vm->_timeline->_g372_eventCount] = L0590_ui_NewEventIndex;
-	f236_fixChronology(_vm->_timeline->_g372_eventCount++);
+		_g373_firstUnusedEventIndex++;
+	} while ((_g370_events[_g373_firstUnusedEventIndex])._type != k0_TMEventTypeNone);
+	_g371_timeline[_g372_eventCount] = L0590_ui_NewEventIndex;
+	f236_fixChronology(_g372_eventCount++);
 	return L0590_ui_NewEventIndex;
 }
 
@@ -380,13 +380,13 @@ T0261053:
 }
 
 bool Timeline::f240_isFirstEventExpiered() {
-	return (_vm->_timeline->_g372_eventCount && (M30_time(_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime));
+	return (_g372_eventCount && (M30_time(_g370_events[_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime));
 }
 
 void Timeline::f239_timelineExtractFirstEvent(TimelineEvent* event) {
 	uint16 L0592_ui_EventIndex;
 
-	*event = _vm->_timeline->_g370_events[L0592_ui_EventIndex = _vm->_timeline->_g371_timeline[0]];
+	*event = _g370_events[L0592_ui_EventIndex = _g371_timeline[0]];
 	f237_deleteEvent(L0592_ui_EventIndex);
 }
 
@@ -424,7 +424,7 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 				}
 			}
 			event->_mapTime++;
-			_vm->_timeline->f238_addEventGetEventIndex(event);
+			f238_addEventGetEventIndex(event);
 			return;
 		}
 		if (((L0599_T_GroupThing = _vm->_groupMan->f175_groupGetThing(L0593_ui_MapX, L0594_ui_MapY)) != Thing::_endOfList) && !getFlag(L0600_ui_CreatureAttributes = _vm->_dungeonMan->f144_getCreatureAttributes(L0599_T_GroupThing), k0x0040_MaskCreatureInfo_nonMaterial)) {
@@ -436,7 +436,7 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 				L0597_puc_Square->setDoorState(L0596_i_DoorState);
 				_vm->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
 				event->_mapTime++;
-				_vm->_timeline->f238_addEventGetEventIndex(event);
+				f238_addEventGetEventIndex(event);
 				return;
 			}
 		}
@@ -457,7 +457,7 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 			return;
 		}
 	}
-	_vm->_timeline->f238_addEventGetEventIndex(event);
+	f238_addEventGetEventIndex(event);
 T0241020_Return:
 	;
 }
@@ -478,11 +478,11 @@ void Timeline::f242_timelineProcessEvent7_squareFakewall(TimelineEvent* event) {
 	if (L0605_i_Effect == k1_SensorEffClear) {
 		if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0603_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0604_ui_MapY == _vm->_dungeonMan->_g307_partyMapY)) {
 			event->_mapTime++;
-			_vm->_timeline->f238_addEventGetEventIndex(event);
+			f238_addEventGetEventIndex(event);
 		} else {
 			if (((L0606_T_Thing = _vm->_groupMan->f175_groupGetThing(L0603_ui_MapX, L0604_ui_MapY)) != Thing::_endOfList) && !getFlag(_vm->_dungeonMan->f144_getCreatureAttributes(L0606_T_Thing), k0x0040_MaskCreatureInfo_nonMaterial)) {
 				event->_mapTime++;
-				_vm->_timeline->f238_addEventGetEventIndex(event);
+				f238_addEventGetEventIndex(event);
 			} else {
 				clearFlag(*L0607_puc_Square, k0x0004_FakeWallOpen);
 			}
@@ -520,7 +520,7 @@ void Timeline::f244_timelineProcessEvent10_squareDoor(TimelineEvent* event) {
 		}
 	}
 	event->_type = k1_TMEventTypeDoorAnimation;
-	_vm->_timeline->f238_addEventGetEventIndex(event);
+	f238_addEventGetEventIndex(event);
 }
 
 void Timeline::f251_timelineProcessEvent9_squarePit(TimelineEvent* event) {
@@ -578,7 +578,7 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 		}
 		if (AL0644_ui_ThingType == k14_ProjectileThingType) {
 			L0646_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(L0645_T_Thing);
-			L0647_ps_Event = &_vm->_timeline->_g370_events[L0646_ps_Projectile->_eventIndex];
+			L0647_ps_Event = &_g370_events[L0646_ps_Projectile->_eventIndex];
 			L0647_ps_Event->_C._projectile.setMapX(_vm->_moveSens->_g397_moveResultMapX);
 			L0647_ps_Event->_C._projectile.setMapY(_vm->_moveSens->_g398_moveResultMapY);
 			L0647_ps_Event->_C._projectile.setDir((Direction)_vm->_moveSens->_g400_moveResultDir);
@@ -586,7 +586,7 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 			M31_setMap(L0647_ps_Event->_mapTime, _vm->_moveSens->_g399_moveResultMapIndex);
 		} else {
 			if (AL0644_ui_ThingType == k15_ExplosionThingType) {
-				for (AL0644_ui_EventIndex = 0, L0647_ps_Event = _vm->_timeline->_g370_events; AL0644_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0647_ps_Event++, AL0644_ui_EventIndex++) {
+				for (AL0644_ui_EventIndex = 0, L0647_ps_Event = _g370_events; AL0644_ui_EventIndex < _g369_eventMaxCount; L0647_ps_Event++, AL0644_ui_EventIndex++) {
 					if ((L0647_ps_Event->_type == k25_TMEventTypeExplosion) && (L0647_ps_Event->_C._slot == L0645_T_Thing.toUint16())) { /* BUG0_23 A Fluxcage explosion remains on a square forever. If you open a pit or teleporter on a square where there is a Fluxcage explosion, the Fluxcage explosion is moved but the associated event is not updated (because Fluxcage explosions do not use k25_TMEventTypeExplosion but rather k24_TMEventTypeRemoveFluxcage) causing the Fluxcage explosion to remain in the dungeon forever on its destination square. When the k24_TMEventTypeRemoveFluxcage expires the explosion thing is not removed, but it is marked as unused. Consequently, any objects placed on the Fluxcage square after it was moved but before it expires become orphans upon expiration. After expiration, any object placed on the fluxcage square is cloned when picked up */
 						L0647_ps_Event->_B._location._mapX = _vm->_moveSens->_g397_moveResultMapX;
 						L0647_ps_Event->_B._location._mapY = _vm->_moveSens->_g398_moveResultMapY;
@@ -854,7 +854,7 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 							L0619_s_Event._B._location._mapX = L0616_ui_MapX;
 							L0619_s_Event._B._location._mapY = L0617_ui_MapY;
 							L0619_s_Event._B._location._mapY = L0617_ui_MapY;
-							_vm->_timeline->f238_addEventGetEventIndex(&L0619_s_Event);
+							f238_addEventGetEventIndex(&L0619_s_Event);
 						}
 					}
 				}
@@ -904,7 +904,7 @@ T0252001:
 			}
 		}
 		event->_mapTime += 5;
-		_vm->_timeline->f238_addEventGetEventIndex(event);
+		f238_addEventGetEventIndex(event);
 	}
 }
 
@@ -1027,7 +1027,7 @@ void Timeline::f257_timelineProcessEvent70_light(TimelineEvent* event) {
 		L0676_s_Event._B._lightPower = L0673_i_WeakerLightPower;
 		M33_setMapAndTime(L0676_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 4);
 		L0676_s_Event._priority = 0;
-		_vm->_timeline->f238_addEventGetEventIndex(&L0676_s_Event);
+		f238_addEventGetEventIndex(&L0676_s_Event);
 	}
 }
 
@@ -1063,7 +1063,7 @@ void Timeline::f255_timelineProcessEvent13_ViAltarRebirth(TimelineEvent* event)
 T0255002:
 		L0670_ui_Step--;
 		event->_C.A._effect = L0670_ui_Step;
-		_vm->_timeline->f238_addEventGetEventIndex(event);
+		f238_addEventGetEventIndex(event);
 		break;
 	case 1:
 		L0667_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0664_i_MapX, L0665_i_MapY);


Commit: 233f93fefebd3150a2da41703b53d8223b9c36c7
    https://github.com/scummvm/scummvm/commit/233f93fefebd3150a2da41703b53d8223b9c36c7
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Swap some warnings to stub methods

Stub methods: f362_commandHighlightBoxEnable, f442_SARTEND_processCommand202_entranceDrawCredits, f437_STARTEND_drawTittle

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 0381f34..9ae9249 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -240,7 +240,7 @@ void DMEngine::f463_initializeGame() {
 	_displayMan->f94_loadFloorSet(k0_FloorSetStone);
 	_displayMan->f95_loadWallSet(k0_WallSetStone);
 	f503_loadSounds();
-	warning(false, "MISSING CODE: F0437_STARTEND_DrawTitle");
+	f437_STARTEND_drawTittle();
 	_textMan->f54_textInitialize();
 	_objectMan->loadObjectNames();
 	_eventMan->initMouse();
@@ -262,7 +262,7 @@ void DMEngine::f463_initializeGame() {
 }
 
 void DMEngine::f448_initMemoryManager() {
-	warning(false, "STUB FUNCTION");
+	warning(false, "STUB METHOD: f448_initMemoryManager");
 	for (uint16 i = 0; i < 16; ++i)
 		_displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i];
 }
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 1c18702..529a768 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -259,6 +259,8 @@ public:
 	void f65_playPendingSound(); // @ F0065_SOUND_PlayPendingSound_CPSD
 	bool f505_soundGetVolume(int16 mapX, int16 mapY, uint8 *leftVolume, uint8 *rightVolume); // @ F0505_SOUND_GetVolume
 	void f438_STARTEND_OpenEntranceDoors() { warning(true, "STUB: f438_STARTEND_OpenEntranceDoors"); } // @ F0438_STARTEND_OpenEntranceDoors
+	void f437_STARTEND_drawTittle() { warning(false, "STUB METHOD: f437_STARTEND_drawTittle"); }// @ F0437_STARTEND_DrawTitle
+	void f442_SARTEND_processCommand202_entranceDrawCredits() { warning(false, "STUB METHOD: f442_SARTEND_processCommand202_entranceDrawCredits"); }// @ F0442_STARTEND_ProcessCommand202_EntranceDrawCredits
 
 private:
 	int16 _g528_saveFormat; // @ G0528_i_Format
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 00e11ef..f4e5061 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -810,7 +810,7 @@ void EventManager::f380_processCommandQueue() {
 		return;
 	}
 	if (cmdType == k202_CommandEntranceDrawCredits) {
-		warning(false, "MISSING CODE: F0442_STARTEND_ProcessCommand202_EntranceDrawCredits()");
+		_vm->f442_SARTEND_processCommand202_entranceDrawCredits();
 		return;
 	}
 	if ((cmdType >= k210_CommandClickOnDialogChoice_1) && (cmdType <= k213_CommandClickOnDialogChoice_4)) {
@@ -827,8 +827,9 @@ void EventManager::f365_commandTurnParty(CommandType cmdType) {
 
 	_vm->_g321_stopWaitingForPlayerInput = true;
 	if (cmdType == k1_CommandTurnLeft) {
-		warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+		f362_commandHighlightBoxEnable(234, 261, 125, 145);
 	} else {
+		f362_commandHighlightBoxEnable(291, 318, 125, 145);
 	}
 	if (Square(L1114_ui_Square = _vm->_dungeonMan->f151_getSquare(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY).toByte()).getType() == k3_ElementTypeStairs) {
 		f364_commandTakeStairs(getFlag(L1114_ui_Square, k0x0004_StairsUp));
@@ -883,7 +884,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	}
 	AL1118_ui_MovementArrowIndex = cmdType - k3_CommandMoveForward;
 	L1120_ps_Box = &g463_BoxMovementArrows[AL1118_ui_MovementArrowIndex];
-	warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+	f362_commandHighlightBoxEnable(L1120_ps_Box->_x1, L1120_ps_Box->_x2, L1120_ps_Box->_y1, L1120_ps_Box->_y2);
 	L1123_B_StairsSquare = (Square(AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(L1121_i_MapX = _vm->_dungeonMan->_g306_partyMapX, L1122_i_MapY = _vm->_dungeonMan->_g307_partyMapY).toByte()).getType() == k3_ElementTypeStairs);
 	if (L1123_B_StairsSquare && (AL1118_ui_MovementArrowIndex == 2)) { /* If moving backward while in stairs */
 		f364_commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp));
@@ -1494,13 +1495,13 @@ void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(Comm
 		if (_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex]._symbols[0] == '\0') {
 			return;
 		}
-		warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+		f362_commandHighlightBoxEnable(234, 303, 63, 73);
 		_vm->_g321_stopWaitingForPlayerInput = _vm->_menuMan->f408_getClickOnSpellCastResult();
 		return;
 	}
 	L1130_ui_SymbolIndex = cmdType - k101_CommandClickInSpellAreaSymbol_1;
 	L1131_ps_Box = &G0464_as_Graphic561_Box_SpellSymbolsAndDelete[L1130_ui_SymbolIndex];
-	warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+	f362_commandHighlightBoxEnable(L1131_ps_Box->_x1, L1131_ps_Box->_x2, L1131_ps_Box->_y1, L1131_ps_Box->_y2);
 	_vm->f22_delay(1);
 	warning(false, "MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
 	if (L1130_ui_SymbolIndex < 6) {
@@ -1518,17 +1519,17 @@ void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX,
 		L1134_ui_Command = f358_getCommandTypeFromMouseInput(g452_MouseInput_ActionAreaNames, Common::Point(posX, posY), k1_LeftMouseButton);
 		if (L1134_ui_Command != k0_CommandNone) {
 			if (L1134_ui_Command == k112_CommandClickInActionAreaPass) {
-				warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+				f362_commandHighlightBoxEnable(285, 319, 77, 83);
 				_vm->_menuMan->f391_didClickTriggerAction(-1);
 			} else {
 				if ((L1134_ui_Command - k112_CommandClickInActionAreaPass) <= _vm->_menuMan->_g507_actionCount) {
 					if (L1134_ui_Command == k113_CommandClickInActionAreaAction_0) {
-						warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+						f362_commandHighlightBoxEnable(234, 318, 86, 96);
 					} else {
 						if (L1134_ui_Command == k114_CommandClickInActionAreaAction_1) {
-							warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+							f362_commandHighlightBoxEnable(234, 318, 98, 108);
 						} else {
-							warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+							f362_commandHighlightBoxEnable(234, 318, 110, 120);
 						}
 					}
 					_vm->_g321_stopWaitingForPlayerInput = _vm->_menuMan->f391_didClickTriggerAction(L1134_ui_Command - k113_CommandClickInActionAreaAction_0);
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 891b0e4..ee49313 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -319,6 +319,7 @@ public:
 	void f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY); // @ F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE
 	void f544_resetPressingEyeOrMouth(); // @ F0544_INPUT_ResetPressingEyeOrMouth
 	void f541_waitForMouseOrKeyActivity(); // @ F0541_INPUT_WaitForMouseOrKeyboardActivity
+	void f362_commandHighlightBoxEnable(int16 x1, int16 x2, int16 y1, int16 y2) { warning(false, "STUB METHOD: f362_commandHighlightBoxEnable"); }// @ F0362_COMMAND_HighlightBoxEnable
 };
 
 }


Commit: d7ff8127152a6a70c854f698142f86300d36243d
    https://github.com/scummvm/scummvm/commit/d7ff8127152a6a70c854f698142f86300d36243d
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f164_unlinkThingFromList

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 55cfcdd..8816ed7 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1518,17 +1518,6 @@ bool DungeonMan::f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) {
 }
 
 void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY) {
-	uint16 L0271_ui_SquareFirstThingIndex;
-	uint16 L0272_ui_Multiple;
-#define AL0272_ui_SquareFirstThingIndex L0272_ui_Multiple
-#define AL0272_ui_Column                L0272_ui_Multiple
-	Thing L0273_T_Thing;
-	Thing* L0274_ps_Generic = nullptr;
-	Thing* L0275_pui_Multiple = nullptr;
-#define AL0275_pT_Thing                      L0275_pui_Multiple
-#define AL0275_pui_CumulativeFirstThingCount L0275_pui_Multiple
-
-
 	if (thingToUnlink == Thing::_endOfList)
 		return;
 
@@ -1536,43 +1525,46 @@ void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList
 	clearFlag(tmp, 0xC000);
 	thingToUnlink = Thing(tmp);
 
+	Thing *thingPtr = nullptr;
 	if (mapX >= 0) {
-		L0274_ps_Generic = (Thing*)f156_getThingData(thingToUnlink);
-		AL0275_pT_Thing = &_g283_squareFirstThings[L0271_ui_SquareFirstThingIndex = f160_getSquareFirstThingIndex(mapX, mapY)]; /* BUG0_01 Coding error without consequence. The engine does not check that there are things at the specified square coordinates. f160_getSquareFirstThingIndex would return -1 for an empty square. No consequence as the function is never called with the coordinates of an empty square (except in the case of BUG0_59) */
-		if ((*L0274_ps_Generic == Thing::_endOfList) && (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16())) { /* If the thing to unlink is the last thing on the square */
+		thingPtr = (Thing*)f156_getThingData(thingToUnlink);
+		uint16 firstThingIndex = f160_getSquareFirstThingIndex(mapX, mapY);
+		Thing *currThing = &_g283_squareFirstThings[firstThingIndex]; /* BUG0_01 Coding error without consequence. The engine does not check that there are things at the specified square coordinates. f160_getSquareFirstThingIndex would return -1 for an empty square. No consequence as the function is never called with the coordinates of an empty square (except in the case of BUG0_59) */
+		if ((*thingPtr == Thing::_endOfList) && (((Thing*)currThing)->getTypeAndIndex() == thingToUnlink.toUint16())) { /* If the thing to unlink is the last thing on the square */
 			clearFlag(_g271_currMapData[mapX][mapY], k0x0010_ThingListPresent);
-			AL0272_ui_SquareFirstThingIndex = _g278_dungeonFileHeader._squareFirstThingCount - 1;
-			for (uint16 i = 0; i < AL0272_ui_SquareFirstThingIndex - L0271_ui_SquareFirstThingIndex; ++i)
-				AL0275_pT_Thing[i] = AL0275_pT_Thing[i + 1];
-
-			_g283_squareFirstThings[AL0272_ui_SquareFirstThingIndex] = Thing::_none;
-			AL0275_pui_CumulativeFirstThingCount = (Thing*)_g270_currMapColCumulativeSquareFirstThingCount + mapX + 1;
-			AL0272_ui_Column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1;
-			while (AL0272_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is unlinked */
-				(*(uint16*)AL0275_pui_CumulativeFirstThingCount++)--; /* Decrement the cumulative first thing count */
+			uint16 squareFirstThingIdx = _g278_dungeonFileHeader._squareFirstThingCount - 1;
+			for (uint16 i = 0; i < squareFirstThingIdx - firstThingIndex; ++i)
+				currThing[i] = currThing[i + 1];
+
+			_g283_squareFirstThings[squareFirstThingIdx] = Thing::_none;
+			uint16 *cumulativeFirstThingCount = _g270_currMapColCumulativeSquareFirstThingCount + mapX + 1;
+			uint16 currColumn = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1;
+			while (currColumn--) { /* For each column starting from and after the column containing the square where the thing is unlinked */
+				(*cumulativeFirstThingCount++)--; /* Decrement the cumulative first thing count */
 			}
-			*L0274_ps_Generic = Thing::_endOfList;
+			*thingPtr = Thing::_endOfList;
 			return;
 		}
-		if (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16()) {
-			*AL0275_pT_Thing = *L0274_ps_Generic;
-			*L0274_ps_Generic = Thing::_endOfList;
+		if (((Thing*)currThing)->getTypeAndIndex() == thingToUnlink.toUint16()) {
+			*currThing = *thingPtr;
+			*thingPtr = Thing::_endOfList;
 			return;
 		}
-		thingInList = *AL0275_pT_Thing;
+		thingInList = *currThing;
 	}
-	L0273_T_Thing = f159_getNextThing(thingInList);
-	while (L0273_T_Thing.getTypeAndIndex() != thingToUnlink.toUint16()) {
-		if ((L0273_T_Thing == Thing::_endOfList) || (L0273_T_Thing == Thing::_none)) {
-			*L0274_ps_Generic = Thing::_endOfList;
+
+	Thing currThing = f159_getNextThing(thingInList);
+	while (currThing.getTypeAndIndex() != thingToUnlink.toUint16()) {
+		if ((currThing == Thing::_endOfList) || (currThing == Thing::_none)) {
+			*thingPtr = Thing::_endOfList;
 			return;
 		}
-		L0273_T_Thing = f159_getNextThing(thingInList = L0273_T_Thing);
+		currThing = f159_getNextThing(thingInList = currThing);
 	}
-	L0274_ps_Generic = (Thing*)f156_getThingData(thingInList);
-	*L0274_ps_Generic = f159_getNextThing(L0273_T_Thing);
-	L0274_ps_Generic = (Thing*)f156_getThingData(thingToUnlink);
-	*L0274_ps_Generic = Thing::_endOfList;
+	thingPtr = (Thing*)f156_getThingData(thingInList);
+	*thingPtr = f159_getNextThing(currThing);
+	thingPtr = (Thing*)f156_getThingData(thingToUnlink);
+	*thingPtr = Thing::_endOfList;
 }
 
 int16 DungeonMan::f155_getStairsExitDirection(int16 mapX, int16 mapY) {


Commit: 3f1fee6dcb9d13dda82683e39cc642419d73d08a
    https://github.com/scummvm/scummvm/commit/3f1fee6dcb9d13dda82683e39cc642419d73d08a
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add _g335_selectedDialogChoice

Changed paths:
    engines/dm/dialog.cpp
    engines/dm/dialog.h
    engines/dm/eventman.cpp



diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index fc610c6..e13cf31 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -33,7 +33,9 @@
 
 namespace DM {
 
-DialogMan::DialogMan(DMEngine* vm) : _vm(vm) {}
+DialogMan::DialogMan(DMEngine* vm) : _vm(vm) {
+	_g335_selectedDialogChoice = 0;
+}
 
 void DialogMan::f427_dialogDraw(char* msg1, char* msg2, char* choice1, char* choice2, char* choice3, char* choice4, bool screenDialog, bool clearScreen, bool fading) {
 	static Box constBox1 = Box(0, 223, 101, 125);
diff --git a/engines/dm/dialog.h b/engines/dm/dialog.h
index 2dd3e5b..a4dd7e3 100644
--- a/engines/dm/dialog.h
+++ b/engines/dm/dialog.h
@@ -33,6 +33,7 @@ namespace DM {
 class DialogMan {
 	DMEngine *_vm;
 public:
+	uint16 _g335_selectedDialogChoice; // @ G0335_ui_SelectedDialogChoice
 	explicit DialogMan(DMEngine *vm);
 	void f427_dialogDraw(char *msg1, char *msg2, char *choice1, char *choice2,
 						 char *choice3, char *choice4, bool screenDialog, bool clearScreen, bool fading); // @ F0427_DIALOG_Draw
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index f4e5061..efa541f 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -38,6 +38,7 @@
 #include "projexpl.h"
 #include "text.h"
 #include "group.h"
+#include "dialog.h"
 
 
 namespace DM {
@@ -814,7 +815,7 @@ void EventManager::f380_processCommandQueue() {
 		return;
 	}
 	if ((cmdType >= k210_CommandClickOnDialogChoice_1) && (cmdType <= k213_CommandClickOnDialogChoice_4)) {
-		warning(false, "MISSING CODE:G0335_ui_SelectedDialogChoice = cmdType - (k210_CommandClickOnDialogChoice_1 - 1);");
+		_vm->_dialog->_g335_selectedDialogChoice = cmdType - (k210_CommandClickOnDialogChoice_1 - 1);
 		return;
 	}
 	if (cmdType == k215_CommandRestartGame) {


Commit: fd775be377bf2fa4914cb621bd2dcf1cbe6ede58
    https://github.com/scummvm/scummvm/commit/fd775be377bf2fa4914cb621bd2dcf1cbe6ede58
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Swap warnings to stub method f363_highlightBoxDisable

Changed paths:
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/menus.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 9ae9249..33bd033 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -395,7 +395,7 @@ void DMEngine::f2_gameloop() {
 				_eventMan->f77_hideMouse();
 			}
 		}
-		// F0363_COMMAND_HighlightBoxDisable();
+		_eventMan->f363_highlightBoxDisable();
 		f65_playPendingSound();
 		_championMan->f320_applyAndDrawPendingDamageAndWounds();
 		if (_championMan->_g303_partyDead)
@@ -440,9 +440,9 @@ void DMEngine::f2_gameloop() {
 			if (_engineShouldQuit)
 				return;
 			_displayMan->updateScreen();
-			// if (!_g321_stopWaitingForPlayerInput) {
-			//		F0363_COMMAND_HighlightBoxDisable();
-			// }
+			if (!_g321_stopWaitingForPlayerInput) {
+				_eventMan->f363_highlightBoxDisable();
+			}
 
 			_system->delayMillis(2);
 			if (++vblankCounter >= _g318_waitForInputMaxVerticalBlankCount * 5)
@@ -537,7 +537,7 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 		f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
 		f22_delay(240);
 	}
-	
+
 	if (_displayMan->_g322_paletteSwitchingEnabled) {
 		uint16 oldPalTopAndBottomScreen[16];
 		for (uint16 i = 0; i < 16; ++i)
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index efa541f..b0d6053 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1504,7 +1504,7 @@ void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(Comm
 	L1131_ps_Box = &G0464_as_Graphic561_Box_SpellSymbolsAndDelete[L1130_ui_SymbolIndex];
 	f362_commandHighlightBoxEnable(L1131_ps_Box->_x1, L1131_ps_Box->_x2, L1131_ps_Box->_y1, L1131_ps_Box->_y2);
 	_vm->f22_delay(1);
-	warning(false, "MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
+	f363_highlightBoxDisable();
 	if (L1130_ui_SymbolIndex < 6) {
 		_vm->_menuMan->f399_addChampionSymbol(L1130_ui_SymbolIndex);
 	} else {
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index ee49313..11958e1 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -258,7 +258,7 @@ class EventManager {
 	void f365_commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty
 	void f366_commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty
 	bool f375_processType80_clickDungeonView_isLeaderHandObjThrown(int16 posX, int16 posY); // @ F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown
-	void setMousePointerFromSpriteData(byte* mouseSprite); 
+	void setMousePointerFromSpriteData(byte* mouseSprite);
 
 public:
 	explicit EventManager(DMEngine *vm);
@@ -320,6 +320,7 @@ public:
 	void f544_resetPressingEyeOrMouth(); // @ F0544_INPUT_ResetPressingEyeOrMouth
 	void f541_waitForMouseOrKeyActivity(); // @ F0541_INPUT_WaitForMouseOrKeyboardActivity
 	void f362_commandHighlightBoxEnable(int16 x1, int16 x2, int16 y1, int16 y2) { warning(false, "STUB METHOD: f362_commandHighlightBoxEnable"); }// @ F0362_COMMAND_HighlightBoxEnable
+	void f363_highlightBoxDisable() { warning(false, "STUB METHOD: f363_highlightBoxDisable"); } // @ F0363_COMMAND_HighlightBoxDisable
 };
 
 }
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 7ac96eb..f3446c3 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -176,7 +176,7 @@ T0386006:
 
 void MenuMan::f456_drawDisabledMenu() {
 	if (!_vm->_championMan->_g300_partyIsSleeping) {
-		warning(false, "MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
+		_vm->_eventMan->f363_highlightBoxDisable();
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 			if (_vm->_inventoryMan->_g424_panelContent == k4_PanelContentChest) {
@@ -459,7 +459,7 @@ int16 MenuMan::f408_getClickOnSpellCastResult() {
 
 	L1260_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
 	_vm->_eventMan->f78_showMouse();
-	warning(false, "MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
+	_vm->_eventMan->f363_highlightBoxDisable();
 	if ((L1259_i_SpellCastResult = f412_getChampionSpellCastResult(_vm->_championMan->_g514_magicCasterChampionIndex)) != k3_spellCastFailureNeedsFlask) {
 		L1260_ps_Champion->_symbols[0] = '\0';
 		f397_drawAvailableSymbols(L1260_ps_Champion->_symbolStep = 0);


Commit: 0f9995851bccea18084cf05b7ef156d78ebdb8d1
    https://github.com/scummvm/scummvm/commit/0f9995851bccea18084cf05b7ef156d78ebdb8d1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add stub method f6_highlightScreenBox

Changed paths:
    engines/dm/eventman.h
    engines/dm/menus.cpp



diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 11958e1..5206485 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -164,7 +164,7 @@ public:
 	Common::Point _pos;
 	CommandType _type;
 
-	Command(Common::Point position, CommandType commandType): _pos(position), _type(commandType) {}
+	Command(Common::Point position, CommandType commandType) : _pos(position), _type(commandType) {}
 }; // @ COMMAND
 
 
@@ -321,6 +321,7 @@ public:
 	void f541_waitForMouseOrKeyActivity(); // @ F0541_INPUT_WaitForMouseOrKeyboardActivity
 	void f362_commandHighlightBoxEnable(int16 x1, int16 x2, int16 y1, int16 y2) { warning(false, "STUB METHOD: f362_commandHighlightBoxEnable"); }// @ F0362_COMMAND_HighlightBoxEnable
 	void f363_highlightBoxDisable() { warning(false, "STUB METHOD: f363_highlightBoxDisable"); } // @ F0363_COMMAND_HighlightBoxDisable
+	void f6_highlightScreenBox(int16 x1, int16 x2, int16 y1, int16 y2) { warning(false, "STUB METHOD: f6_highlightScreenBox"); } // @  F0006_MAIN_HighlightScreenBox
 };
 
 }
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index f3446c3..509623d 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -309,21 +309,21 @@ void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) {
 	int16 champCount = champMan._g305_partyChampionCount;
 	switch (champIndex) {
 	case k0_ChampionFirst:
-		warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		_vm->_eventMan->f6_highlightScreenBox(233, 277, 42, 49);
 		textMan.f53_printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		if (champCount) {
 			if (champCurrHealth[1]) {
-				warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
+				_vm->_eventMan->f6_highlightScreenBox(280, 291, 42, 48);;
 			}
 labelChamp2:
 			if (champCount > 2) {
 				if (champCurrHealth[2]) {
-					warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
+					_vm->_eventMan->f6_highlightScreenBox(294, 305, 42, 48);
 				}
 labelChamp3:
 				if (champCount > 3) {
 					if (champCurrHealth[3]) {
-						warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
+						_vm->_eventMan->f6_highlightScreenBox(308, 319, 42, 48);
 					}
 				}
 			}
@@ -331,32 +331,32 @@ labelChamp3:
 		break;
 	case k1_ChampionSecond:
 		if (champCurrHealth[0]) {
-			warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
+			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
 		}
-		warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		_vm->_eventMan->f6_highlightScreenBox(247, 291, 42, 49);
 		textMan.f53_printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		goto labelChamp2;
 	case k2_ChampionThird:
 		if (champCurrHealth[0]) {
-			warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
+			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
 		}
 		if (champCurrHealth[1]) {
-			warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
+			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
 		}
-		warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		_vm->_eventMan->f6_highlightScreenBox(261, 305, 42, 49);
 		textMan.f53_printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		goto labelChamp3;
 	case k3_ChampionFourth:
 		if (champCurrHealth[0]) {
-			warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
+			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
 		}
 		if (champCurrHealth[1]) {
-			warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
+			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
 		}
 		if (champCurrHealth[2]) {
-			warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
+			_vm->_eventMan->f6_highlightScreenBox(261, 272, 42, 48);
 		}
-		warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox");
+		_vm->_eventMan->f6_highlightScreenBox(275, 319, 42, 49);
 		textMan.f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
 		break;
 	}


Commit: ead63373ca38626ff977c8b09ff2fe3c34b85da2
    https://github.com/scummvm/scummvm/commit/ead63373ca38626ff977c8b09ff2fe3c34b85da2
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add stub methods, clean up warnings and some comments

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/text.cpp
    engines/dm/text.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index b44ec12..5017e48 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -3,9 +3,10 @@ Bugs:
 		Broken colour palette for dungeon and cursor
 		Gui is messed up by drawn spell area line on startup
 		Spellcasting tabs are displayed inproperly, switching between them is possible tho
+		When reordering a champions, the icons in the top right corner ar drawn twice under the cursor
 
 	Logic:
-		End game method is broken
+		F0444_STARTEND_Endgame is broken
 		Items thrown on the right side end up on the left side 
 
 
@@ -23,21 +24,9 @@ Todo:
 	Double check strcat, strstr usages
 	I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions
 
-Finish stuff:
-	F0444_STARTEND_Endgame
-	Make missing code warnings to STUB methods
-	Add quit resuest from scummvm
-	f380_processCommandQueue
-	Missing main loop methods
+Code stuff todo:
+	Complete stub methods
+	Add localization
 	Save file f433_processCommand140_saveGame fails silently
 	
-	F0438_STARTEND_OpenEntranceDoors
-	F0442_STARTEND_ProcessCommand202_EntranceDrawCredits
-	G0335_ui_SelectedDialogChoice
-	Add dialogs
-	Add failcheck to saveing and loading
-	
-
-
-Refactoring
-	Places implementing mini mainloop and where input doesn't really matter should call discardInput instead of processInput
+	
\ No newline at end of file
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 90f89a3..8d23784 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1056,7 +1056,7 @@ void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButt
 
 void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* topAndBottomScreen) {
 	if (middleScreenPalette && topAndBottomScreen)
-		debugC(kDMDebugOftenCalledWarning, "MISSING CODE: F0508_AMIGA_BuildPaletteChangeCopperList");
+		f508_buildPaletteChangeCopperList(middleScreenPalette, topAndBottomScreen);
 
 	f566_viewportBlitToScreen();
 }
@@ -2045,7 +2045,7 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 							  _g296_bitmapViewport, g106_BoxThievesEye_ViewPortVisibleArea, 0, 0,
 							  48, k112_byteWidthViewport, k9_ColorGold, 95, k136_heightViewport); /* BUG0_74 */
 			f493_addDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea);
-			warning(false, "MISSING CODE: F0480_CACHE_ReleaseBlock");
+			f480_releaseBlock(k1_DerivedBitmapThievesEyeVisibleArea | 0x8000);
 		}
 		return;
 	case k17_DoorFrontElemType:
@@ -2692,6 +2692,7 @@ uint32 DisplayMan::getCompressedDataSize(uint16 index) {
 #define kMaskFieldAspectNoMask 255 // @ C255_NO_MASK            
 
 void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) {
+	warning(false, "STUB METHOD: f113_drawField");
 	DisplayMan &dispMan = *_vm->_displayMan;
 
 	byte *bitmapMask;
@@ -2705,11 +2706,6 @@ void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) {
 			dispMan.f130_flipBitmapHorizontal(bitmapMask, fieldAspect->_byteWidth, fieldAspect->_height);
 		}
 	}
-
-	// byte *bitmap = dispMan.f489_getNativeBitmapOrGraphic(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex);
-	warning(false, "MISSING CODE: F0133_VIDEO_BlitBoxFilledWithMaskedBitmap");
-
-	warning(false, "IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache, F0493_CACHE_AddDerivedBitmap, F0480_CACHE_ReleaseBlock");
 }
 
 int16 DisplayMan::f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale) {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 7de68ac..563e129 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -750,7 +750,9 @@ public:
 	void f493_addDerivedBitmap(int16 derivedBitmapIndex); // @ F0493_CACHE_AddDerivedBitmap
 	void f480_releaseBlock(uint16 index); // @ F0480_CACHE_ReleaseBlock
 	uint16 f431_getDarkenedColor(uint16 RGBcolor);
-	void f436_STARTEND_FadeToPalette(uint16 *P0849_pui_Palette) { warning(false, "STUB: f436_STARTEND_FadeToPalette"); }
+	void f436_STARTEND_FadeToPalette(uint16 *P0849_pui_Palette) { warning(false, "STUB METHOD: f436_STARTEND_FadeToPalette"); }
+	void f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom) { warning(false, "STUB METHOD: f508_buildPaletteChangeCopperList"); }// @ F0508_AMIGA_BuildPaletteChangeCopperList
+	void f136_shadeScreenBox(Box* box, Color color) { warning(false, "STUB METHOD: f136_shadeScreenBox"); } // @ F0136_VIDEO_ShadeScreenBox
 };
 
 }
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 019ef5e..48f9716 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -117,14 +117,14 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(championIndex);
 	if (!AL1102_ui_InventoryChampionOrdinal) {
-		warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+		_vm->_displayMan->f136_shadeScreenBox(&g2_BoxMovementArrows, k0_ColorBlack);
 	}
 	L1103_ps_Champion = &_vm->_championMan->_gK71_champions[championIndex];
 	_vm->_displayMan->f466_loadIntoBitmap(k17_InventoryGraphicIndice, _vm->_displayMan->_g296_bitmapViewport);
 	if (_vm->_championMan->_g299_candidateChampionOrdinal) {
 		_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
 	}
-	_vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "HEALTH");
+	_vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "HEALTH"); // TODO: localization
 	_vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
 	_vm->_textMan->f52_printToViewport(5, 132, k13_ColorLightestGray, "MANA");
 	for (AL1102_ui_SlotIndex = k0_ChampionSlotReadyHand; AL1102_ui_SlotIndex < k30_ChampionSlotChest_1; AL1102_ui_SlotIndex++) {
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 24e1a15..3563fb5 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -36,6 +36,7 @@
 #include "menus.h"
 #include "eventman.h"
 #include "projexpl.h"
+#include "dialog.h"
 
 
 namespace DM {
@@ -141,8 +142,8 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		_timeline->f233_initTimeline();
 		_groupMan->f196_initActiveGroups();
 
+		warning(false, "Disabled code in f435_loadgame");
 #if 0
-		// always false?
 		if (L1366_B_FadePalette) {
 			_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
 			D26_WaitForVerticalBlank();
@@ -156,7 +157,7 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		_g526_dungeonId = dmSaveHeader._dungeonId;
 
 		_g524_restartGameAllowed = true;
-		warning(false, "MISSING CDOE: F0427_DIALOG_Draw in f435_loadgame");
+		_dialog->f427_dialogDraw(nullptr, "LOADING GAME . . .", nullptr, nullptr, nullptr, nullptr, true, true, true); // TODO: localization
 	}
 	_championMan->_g303_partyDead = false;
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 509623d..b69780d 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -170,7 +170,7 @@ T0386006:
 	box2._y2 = 110;
 	dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 8, k160_byteWidthScreen, kM1_ColorNoTransparency);
 	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) {
-		warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+		_vm->_displayMan->f136_shadeScreenBox(&box, k0_ColorBlack);
 	}
 }
 
@@ -183,10 +183,10 @@ void MenuMan::f456_drawDisabledMenu() {
 				_vm->_inventoryMan->f334_closeChest();
 			}
 		} else {
-			warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+			_vm->_displayMan->f136_shadeScreenBox(&g2_BoxMovementArrows, k0_ColorBlack);
 		}
-		warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox");
-		warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox");
+		_vm->_displayMan->f136_shadeScreenBox(&g0_BoxSpellArea, k0_ColorBlack);
+		_vm->_displayMan->f136_shadeScreenBox(&g1_BoxActionArea, k0_ColorBlack);
 		_vm->_eventMan->f67_setMousePointerToNormal(k0_pointerArrow);
 	}
 }
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 51d203d..68ea14f 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -139,9 +139,10 @@ void TextMan::f45_messageAreaCreateNewRow() {
 	uint16 L0029_ui_RowIndex;
 
 	if (_g358_messageAreaCursorRow == 3) {
-		warning(false, "MISSING CODE: F0561_SCROLLER_IsTextScrolling");
+		f561_isTextScrolling(&_gK60_s_TextScroller, true);
 		memset(_g356_bitmapMessageAreaNewRow, k0_ColorBlack, 320 * 7);
-		warning(false, "MISSING CODE: F0560_SCROLLER_SetCommand");
+		f560_SCROLLER_setCommand(&_gK60_s_TextScroller, 1);
+
 		for (L0029_ui_RowIndex = 0; L0029_ui_RowIndex < 3; L0029_ui_RowIndex++) {
 			_g360_messageAreaRowExpirationTime[L0029_ui_RowIndex] = _g360_messageAreaRowExpirationTime[L0029_ui_RowIndex + 1];
 		}
@@ -155,13 +156,12 @@ void TextMan::f46_messageAreaPrintString(Color color, const char* string) {
 	int16 L0030_i_StringLength;
 
 	L0030_i_StringLength = strlen(string);
-	warning(false, "MISSING CODE: F0561_SCROLLER_IsTextScrolling");
-	if (true) { // there is a test here with F0561_SCROLLER_IsTextScrolling
+	if (f561_isTextScrolling(&_gK60_s_TextScroller, false)) {
 		f53_printToLogicalScreen(_g359_messageAreaCursorColumn * 6, (_g358_messageAreaCursorRow * 7 - 6) + 177, color, k0_ColorBlack, string);
 	} else {
 		f40_printTextToBitmap(_g356_bitmapMessageAreaNewRow, k160_byteWidthScreen, _g359_messageAreaCursorColumn * 6, 5, color, k0_ColorBlack, string, 7);
-		warning(false, "MISSING CODE: F0561_SCROLLER_IsTextScrolling");
-		warning(false, "MISSING CODE: F0560_SCROLLER_SetCommand");
+		if(f561_isTextScrolling(&_gK60_s_TextScroller, false))
+			f560_SCROLLER_setCommand(&_gK60_s_TextScroller, 1);
 	}
 	_g359_messageAreaCursorColumn += L0030_i_StringLength;
 	_g360_messageAreaRowExpirationTime[_g358_messageAreaCursorRow] = _vm->_g313_gameTime + 200;
@@ -206,7 +206,7 @@ void TextMan::f44_messageAreaClearExpiredRows() {
 		if ((L0027_l_ExpirationTime == -1) || (L0027_l_ExpirationTime > _vm->_g313_gameTime))
 			continue;
 		L0028_s_Box._y2 = (L0028_s_Box._y1 = 172 + (L0026_ui_RowIndex * 7)) + 6;
-		warning(false, "MISSING CODE:F0561_SCROLLER_IsTextScrolling(&K0060_s_TextScroller, true);");
+		f561_isTextScrolling(&_gK60_s_TextScroller, true);
 		_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g348_bitmapScreen, L0028_s_Box, k0_ColorBlack, k160_byteWidthScreen, k200_heightScreen);
 		_g360_messageAreaRowExpirationTime[L0026_ui_RowIndex] = -1;
 	}
diff --git a/engines/dm/text.h b/engines/dm/text.h
index 3a41274..b4eca1a 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -33,6 +33,10 @@
 
 namespace DM {
 
+struct TextScroller {
+	// Placeholder, empty for now
+}; // @ Text_Scroller
+
 class TextMan {
 	DMEngine *_vm;
 	int16 _g359_messageAreaCursorColumn; // @ G0359_i_MessageAreaCursorColumn
@@ -40,14 +44,16 @@ class TextMan {
 	int32 _g360_messageAreaRowExpirationTime[4]; // @ G0360_al_MessageAreaRowExpirationTime
 	byte *_g356_bitmapMessageAreaNewRow; // @ G0356_puc_Bitmap_MessageAreaNewRow
 public:
+	TextScroller _gK60_s_TextScroller;
+
 	explicit TextMan(DMEngine *vm);
 	~TextMan();
 	void f40_printTextToBitmap(byte *destBitmap, uint16 destByteWidth, int16 destX, int16 destY,
-						   Color textColor, Color bgColor, const char *text, uint16 destHeight); // @ F0040_TEXT_Print
+							   Color textColor, Color bgColor, const char *text, uint16 destHeight); // @ F0040_TEXT_Print
 	void f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text); // @ F0053_TEXT_PrintToLogicalScreen
 	void f52_printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport
 	void f41_printWithTrailingSpaces(byte *destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor, Color bgColor,
-								 const char *text, int16 strLenght, int16 destHeight); // @ F0041_TEXT_PrintWithTrailingSpaces
+									 const char *text, int16 strLenght, int16 destHeight); // @ F0041_TEXT_PrintWithTrailingSpaces
 	void f51_messageAreaPrintLineFeed(); // @ F0051_TEXT_MESSAGEAREA_PrintLineFeed
 	void f47_messageAreaPrintMessage(Color color, const char *string); // @ F0047_TEXT_MESSAGEAREA_PrintMessage
 	void f45_messageAreaCreateNewRow(); // @ F0045_TEXT_MESSAGEAREA_CreateNewRow
@@ -56,7 +62,10 @@ public:
 	void f42_messageAreaMoveCursor(int16 column, int16 row); // @ F0042_TEXT_MESSAGEAREA_MoveCursor
 	void f44_messageAreaClearExpiredRows(); // @ F0044_TEXT_MESSAGEAREA_ClearExpiredRows
 	void f443_endgamePrintString(int16 x, int16 y, Color textColor, char *text); // @ F0443_STARTEND_EndgamePrintString
-
+	bool f561_isTextScrolling(TextScroller *scroller, bool waitEndOfScrolling) {
+		warning(false, "STUB METHOD: f561_isTextScrolling"); return true;
+	} // @ F0561_SCROLLER_IsTextScrolling
+	void f560_SCROLLER_setCommand(TextScroller *scroller, int16 command) { warning(false, "STUB METHOD: f560_SCROLLER_setCommand");  } // @ F0560_SCROLLER_SetCommand
 };
 
 }


Commit: d69c2d12fa026a6c5fbea587376cf0ce8fba4fe9
    https://github.com/scummvm/scummvm/commit/d69c2d12fa026a6c5fbea587376cf0ce8fba4fe9
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Change Box's member fields from uint16 to int16

Changed paths:
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 563e129..e5f477d 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -290,12 +290,12 @@ extern uint16 g21_PalDungeonView[6][16]; // @ G0021_aaui_Graphic562_Palette_Dung
 // in all cases, where a function takes a Box, it expects it to contain inclusive boundaries
 class Box {
 public:
-	uint16 _x1;
-	uint16 _x2;
-	uint16 _y1;
-	uint16 _y2;
+	int16 _x1;
+	int16 _x2;
+	int16 _y1;
+	int16 _y2;
 
-	Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2) : _x1(x1), _x2(x2), _y1(y1), _y2(y2) {}
+	Box(int16 x1, int16 x2, int16 y1, int16 y2) : _x1(x1), _x2(x2), _y1(y1), _y2(y2) {}
 	Box() {}
 	template <typename T>
 	explicit Box(T *ptr) {


Commit: 7570844f5e08e3328282bb271292dfca5e61d2a2
    https://github.com/scummvm/scummvm/commit/7570844f5e08e3328282bb271292dfca5e61d2a2
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fill stub method f438_STARTEND_OpenEntranceDoors

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 5017e48..ea98c00 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -4,6 +4,7 @@ Bugs:
 		Gui is messed up by drawn spell area line on startup
 		Spellcasting tabs are displayed inproperly, switching between them is possible tho
 		When reordering a champions, the icons in the top right corner ar drawn twice under the cursor
+		No dugeon is shown during opening the entrance doors
 
 	Logic:
 		F0444_STARTEND_Endgame is broken
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 33bd033..945d739 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -696,4 +696,40 @@ void DMEngine::f439_drawEntrance() {
 	_displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[4], &closedDoorRightBox, k64_byteWidth, kM1_ColorNoTransparency, 161);
 	_displayMan->f436_STARTEND_FadeToPalette(g20_PalEntrance);
 }
+
+void DMEngine::f438_STARTEND_OpenEntranceDoors() {
+	Box rightDoorBox(109, 231, 0 + 33, 160 + 33);
+	byte *rightDoorBitmap = _displayMan->f489_getNativeBitmapOrGraphic(k3_entranceRightDoorGraphicIndice);
+	Box leftDoorBox(0, 100, 0 + 33, 160 + 33);
+	uint16 leftDoorBlitFrom = 0;
+	byte *leftDoorBitmap = _displayMan->f489_getNativeBitmapOrGraphic(k2_entranceLeftDoorGraphicIndice);
+
+	Box screenBox(0, 319, 0, 199);
+	byte *tmpScreen = new byte[320 * 200];
+	memcpy(tmpScreen, _displayMan->_g348_bitmapScreen, 320 * 200);
+	
+	uint16 animStep = 1;
+	do {
+		if ((animStep % 3) == 1) {
+			// Strangerke: CHECKME: Earlier versions of the game were using G0565_puc_Graphic535_Sound02DoorRattle instead of k02_soundDOOR_RATTLE 2
+			f060_SOUND_Play(k02_soundDOOR_RATTLE, 145, 0x40, 0x40);
+		}
+
+		_displayMan->f21_blitToScreen(tmpScreen, &screenBox, 160, kM1_ColorNoTransparency, 200);
+		_displayMan->f132_blitToBitmap(leftDoorBitmap, _displayMan->_g348_bitmapScreen, leftDoorBox, leftDoorBlitFrom, 0, 64, k160_byteWidthScreen, kM1_ColorNoTransparency);
+		_displayMan->f132_blitToBitmap(rightDoorBitmap, _displayMan->_g348_bitmapScreen, rightDoorBox, 0, 0, 64, k160_byteWidthScreen, kM1_ColorNoTransparency);
+		_eventMan->f357_discardAllInput();
+		_displayMan->updateScreen();
+
+		leftDoorBox._x2 -= 4;
+		leftDoorBlitFrom += 4;
+		rightDoorBox._x1 += 4;
+
+		f22_delay(3);
+	} while (++animStep != 32);
+}
+
+
+
+
 } // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 529a768..7f40eae 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -258,7 +258,7 @@ public:
 	void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol); // @ F0060_SOUND_Play
 	void f65_playPendingSound(); // @ F0065_SOUND_PlayPendingSound_CPSD
 	bool f505_soundGetVolume(int16 mapX, int16 mapY, uint8 *leftVolume, uint8 *rightVolume); // @ F0505_SOUND_GetVolume
-	void f438_STARTEND_OpenEntranceDoors() { warning(true, "STUB: f438_STARTEND_OpenEntranceDoors"); } // @ F0438_STARTEND_OpenEntranceDoors
+	void f438_STARTEND_OpenEntranceDoors(); // @ F0438_STARTEND_OpenEntranceDoors
 	void f437_STARTEND_drawTittle() { warning(false, "STUB METHOD: f437_STARTEND_drawTittle"); }// @ F0437_STARTEND_DrawTitle
 	void f442_SARTEND_processCommand202_entranceDrawCredits() { warning(false, "STUB METHOD: f442_SARTEND_processCommand202_entranceDrawCredits"); }// @ F0442_STARTEND_ProcessCommand202_EntranceDrawCredits
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 8d23784..fa2b442 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -826,9 +826,6 @@ void DisplayMan::f460_initializeGraphicData() {
 	_g709_bitmapWallSet_DoorFrameFront = new byte[32 * 123];
 	_g296_bitmapViewport = new byte[224 * 136];
 
-	warning(false, "SKIPPED CODE: G0086_puc_Bitmap_ViewportBlackArea it is useless");
-	warning(false, "SKIPPED CODE: G0087_puc_Bitmap_ViewportFloorArea it is useless");
-
 	if (!_g639_derivedBitmapByteCount)
 		_g639_derivedBitmapByteCount = new uint16[k730_DerivedBitmapMaximumCount];
 	if (!_g638_derivedBitmaps) {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index e5f477d..9e66455 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -677,8 +677,8 @@ public:
 
 	void f20_blitToViewport(byte *bitmap, Box &box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
 	void f20_blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
-	void f21_blitToScreen(byte* bitmap, int16 *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen
-	void f21_blitToScreen(byte* bitmap, Box *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen
+	void f21_blitToScreen(byte *bitmap, int16* box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
+	void f21_blitToScreen(byte* bitmap, Box* box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
 
 
 	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which


Commit: 6428110da8274da755c6f944fa668331d444de06
    https://github.com/scummvm/scummvm/commit/6428110da8274da755c6f944fa668331d444de06
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix dungon not drawn behind entrance doors

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dm.cpp
    engines/dm/dm.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index ea98c00..5017e48 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -4,7 +4,6 @@ Bugs:
 		Gui is messed up by drawn spell area line on startup
 		Spellcasting tabs are displayed inproperly, switching between them is possible tho
 		When reordering a champions, the icons in the top right corner ar drawn twice under the cursor
-		No dugeon is shown during opening the entrance doors
 
 	Logic:
 		F0444_STARTEND_Endgame is broken
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 945d739..ab9ef81 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -185,6 +185,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
 	_g313_gameTime = 0;
 	_g353_stringBuildBuffer[0] = '\0';
 	_g318_waitForInputMaxVerticalBlankCount = 0;
+	_savedScreenForOpenEntranceDoors = nullptr;
 	for (uint16 i = 0; i < 10; ++i)
 		_g562_entranceDoorAnimSteps[i] = nullptr;
 	_g564_interfaceCredits = nullptr;
@@ -214,6 +215,7 @@ DMEngine::~DMEngine() {
 	for (uint16 i = 0; i < k34_D13_soundCount; ++i)
 		delete[] _gK24_soundData[i]._firstSample;
 
+	delete[] _savedScreenForOpenEntranceDoors;
 	// clear debug channels
 	DebugMan.clearAllDebugChannels();
 }
@@ -689,6 +691,10 @@ void DMEngine::f439_drawEntrance() {
 	_displayMan->f128_drawDungeon(kDirSouth, 2, 0);
 	warning(false, "IGNORED CODE: G0324_B_DrawViewportRequested = false;");
 
+	if (!_savedScreenForOpenEntranceDoors)
+		_savedScreenForOpenEntranceDoors = new byte[k200_heightScreen * k160_byteWidthScreen * 2];
+	memcpy(_savedScreenForOpenEntranceDoors, _displayMan->_g348_bitmapScreen, 320 * 200);
+
 	_displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], doorsUpperHalfBox, 0, 30, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
 	_displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], doorsLowerHalfBox, 0, 111, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
 
@@ -698,24 +704,21 @@ void DMEngine::f439_drawEntrance() {
 }
 
 void DMEngine::f438_STARTEND_OpenEntranceDoors() {
-	Box rightDoorBox(109, 231, 0 + 33, 160 + 33);
+	Box rightDoorBox(109, 231, 33, 193);
 	byte *rightDoorBitmap = _displayMan->f489_getNativeBitmapOrGraphic(k3_entranceRightDoorGraphicIndice);
-	Box leftDoorBox(0, 100, 0 + 33, 160 + 33);
+	Box leftDoorBox(0, 100, 33, 193);
 	uint16 leftDoorBlitFrom = 0;
 	byte *leftDoorBitmap = _displayMan->f489_getNativeBitmapOrGraphic(k2_entranceLeftDoorGraphicIndice);
 
 	Box screenBox(0, 319, 0, 199);
-	byte *tmpScreen = new byte[320 * 200];
-	memcpy(tmpScreen, _displayMan->_g348_bitmapScreen, 320 * 200);
-	
-	uint16 animStep = 1;
-	do {
+
+	for (uint16 animStep = 1; animStep < 32; ++animStep) {
 		if ((animStep % 3) == 1) {
 			// Strangerke: CHECKME: Earlier versions of the game were using G0565_puc_Graphic535_Sound02DoorRattle instead of k02_soundDOOR_RATTLE 2
 			f060_SOUND_Play(k02_soundDOOR_RATTLE, 145, 0x40, 0x40);
 		}
 
-		_displayMan->f21_blitToScreen(tmpScreen, &screenBox, 160, kM1_ColorNoTransparency, 200);
+		_displayMan->f21_blitToScreen(_savedScreenForOpenEntranceDoors, &screenBox, 160, kM1_ColorNoTransparency, 200);
 		_displayMan->f132_blitToBitmap(leftDoorBitmap, _displayMan->_g348_bitmapScreen, leftDoorBox, leftDoorBlitFrom, 0, 64, k160_byteWidthScreen, kM1_ColorNoTransparency);
 		_displayMan->f132_blitToBitmap(rightDoorBitmap, _displayMan->_g348_bitmapScreen, rightDoorBox, 0, 0, 64, k160_byteWidthScreen, kM1_ColorNoTransparency);
 		_eventMan->f357_discardAllInput();
@@ -726,7 +729,8 @@ void DMEngine::f438_STARTEND_OpenEntranceDoors() {
 		rightDoorBox._x1 += 4;
 
 		f22_delay(3);
-	} while (++animStep != 32);
+	}
+	delete[] _savedScreenForOpenEntranceDoors;
 }
 
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 7f40eae..d254f3d 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -272,6 +272,7 @@ private:
 	Common::RandomSource *_rnd;
 	SoundData _gK24_soundData[k34_D13_soundCount]; // @ K0024_as_SoundData
 	Common::Queue<PendingSound> _pendingSounds;
+	byte *_savedScreenForOpenEntranceDoors; // ad-hoc HACK
 public:
 	DisplayMan *_displayMan;
 	DungeonMan *_dungeonMan;


Commit: 1f99dab5b51e88c624cdb9a7984221b06eb8ddb1
    https://github.com/scummvm/scummvm/commit/1f99dab5b51e88c624cdb9a7984221b06eb8ddb1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix double delete[] of DMEngine::_savedScreenForOpenEntranceDoor

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index ab9ef81..3eb3231 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -731,6 +731,7 @@ void DMEngine::f438_STARTEND_OpenEntranceDoors() {
 		f22_delay(3);
 	}
 	delete[] _savedScreenForOpenEntranceDoors;
+	_savedScreenForOpenEntranceDoors = nullptr;
 }
 
 


Commit: 256c2c10f8ba77fd217a974919ae4c896b80277f
    https://github.com/scummvm/scummvm/commit/256c2c10f8ba77fd217a974919ae4c896b80277f
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Reorder MenuMan::f392_buildSpellAreaLine, add MenuMan::_gK73_bitmapSpellAreaLines

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dm.cpp
    engines/dm/menus.cpp
    engines/dm/menus.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 5017e48..721507c 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -8,6 +8,7 @@ Bugs:
 	Logic:
 		F0444_STARTEND_Endgame is broken
 		Items thrown on the right side end up on the left side 
+		I'm not sure, but the cooldown between champion actions when fighting monsters seems too muh
 
 
 Possible bugs:
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 3eb3231..2e53490 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -241,7 +241,9 @@ void DMEngine::f463_initializeGame() {
 	_displayMan->loadPalette(g21_PalDungeonView[0]);
 	_displayMan->f94_loadFloorSet(k0_FloorSetStone);
 	_displayMan->f95_loadWallSet(k0_WallSetStone);
-	f503_loadSounds();
+
+	f503_loadSounds(); // @ F0506_AMIGA_AllocateData
+
 	f437_STARTEND_drawTittle();
 	_textMan->f54_textInitialize();
 	_objectMan->loadObjectNames();
@@ -251,7 +253,8 @@ void DMEngine::f463_initializeGame() {
 		if (_engineShouldQuit)
 			return;
 	} while (f435_loadgame(1) != k1_LoadgameSuccess);
-	//F0396_MENUS_LoadSpellAreaLinesBitmap() is not needed, every bitmap has been loaded
+
+	_displayMan->f466_loadIntoBitmap(k11_MenuSpellAreLinesIndice, _menuMan->_gK73_bitmapSpellAreaLines); // @ F0396_MENUS_LoadSpellAreaLinesBitmap
 
 	// There was some memory wizardy for the Amiga platform, I skipped that part
 	_displayMan->f461_allocateFlippedWallBitmaps();
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index b69780d..d3c1185 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -105,6 +105,7 @@ MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
 	_g513_actionDamage = 0;
 	_g713_actionList.resetToZero();
 	_gK72_bitmapSpellAreaLine = new byte[96 * 12];
+	_gK73_bitmapSpellAreaLines = new byte[3 * 96 * 12];
 	_g517_actionTargetGroupThing = Thing(0);
 	_g507_actionCount = 0;
 }
@@ -367,32 +368,28 @@ labelChamp3:
 #define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
 
 void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
-	DisplayMan &dispMan = *_vm->_displayMan;
-
-	Champion &champ = _vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
+	char L1204_ac_SpellSymbolString[2] = {'\0', '\0'};
+	Champion *L1203_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
 	if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) {
-		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine,
-								  gK74_BoxSpellAreaLine, 0, 12, 48, 48, kM1_ColorNoTransparency);
+		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+		_vm->_displayMan->f132_blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 12, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
 		int16 x = 1;
-		byte c = 96 + (6 * champ._symbolStep);
-		char spellSymbolString[2] = {'\0', '\0'};
+		char character = 96 + (6 * L1203_ps_Champion->_symbolStep);
 		for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
-			spellSymbolString[0] = c++;
-			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 14, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
+			L1204_ac_SpellSymbolString[0] = character++;
+			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 14, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
 		}
 	} else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) {
-		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine,
-								  gK74_BoxSpellAreaLine, 0, 24, 48, 48, kM1_ColorNoTransparency);
-		char spellSymbolString[2] = {'\0', '\0'};
+		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+		_vm->_displayMan->f132_blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 24, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
 		int16 x = 8;
 		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
-			if ((spellSymbolString[0] = champ._symbols[symbolIndex]) == '\0')
+			if ((L1204_ac_SpellSymbolString[0] = L1203_ps_Champion->_symbols[symbolIndex]) == '\0')
 				break;
-			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 9, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
+			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 9, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
 		}
 	}
+
 }
 
 void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 6652fdc..40bcfbf 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -79,6 +79,7 @@ public:
 	int16 _g513_actionDamage; // @ G0513_i_ActionDamage
 	ActionList _g713_actionList; // @ G0713_s_ActionList
 	byte *_gK72_bitmapSpellAreaLine; // @ K0072_puc_Bitmap_SpellAreaLine
+	byte *_gK73_bitmapSpellAreaLines; // @ K0073_puc_Bitmap_SpellAreaLines
 	Thing _g517_actionTargetGroupThing; // @ G0517_T_ActionTargetGroupThing
 	uint16 _g507_actionCount; // @ G0507_ui_ActionCount
 


Commit: 644284e077b494286142bebd7c68225401545d22
    https://github.com/scummvm/scummvm/commit/644284e077b494286142bebd7c68225401545d22
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix entrance door placement

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 2e53490..2f52b07 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -707,9 +707,9 @@ void DMEngine::f439_drawEntrance() {
 }
 
 void DMEngine::f438_STARTEND_OpenEntranceDoors() {
-	Box rightDoorBox(109, 231, 33, 193);
+	Box rightDoorBox(109, 231, 30, 193);
 	byte *rightDoorBitmap = _displayMan->f489_getNativeBitmapOrGraphic(k3_entranceRightDoorGraphicIndice);
-	Box leftDoorBox(0, 100, 33, 193);
+	Box leftDoorBox(0, 100, 30, 193);
 	uint16 leftDoorBlitFrom = 0;
 	byte *leftDoorBitmap = _displayMan->f489_getNativeBitmapOrGraphic(k2_entranceLeftDoorGraphicIndice);
 


Commit: f563f8d04fe4ba293b430b789f6529cbd1bce1b6
    https://github.com/scummvm/scummvm/commit/f563f8d04fe4ba293b430b789f6529cbd1bce1b6
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix g0_BoxSpellArea value

Changed paths:
    engines/dm/menus.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index d3c1185..6506999 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -1,1738 +1,1738 @@
-/* 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.
-*
-*/
-
-/*
-* Based on the Reverse Engineering work of Christophe Fontanel,
-* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
-*/
-
-#include "menus.h"
-#include "gfx.h"
-#include "champion.h"
-#include "dungeonman.h"
-#include "objectman.h"
-#include "inventory.h"
-#include "text.h"
-#include "eventman.h"
-#include "timeline.h"
-#include "movesens.h"
-#include "group.h"
-#include "projexpl.h"
-
-
-namespace DM {
-
-unsigned char g496_ActionSkillIndex[44] = { // @ G0496_auc_Graphic560_ActionSkillIndex
-	0,  /* N */
-	7,  /* BLOCK */
-	6,  /* CHOP */
-	0,  /* X */
-	14, /* BLOW HORN */
-	12, /* FLIP */
-	9,  /* PUNCH */
-	9,  /* KICK */
-	7,  /* WAR CRY Atari ST Versions 1.0 1987-12-08 1987-12-11 1.1: 14 */
-	9,  /* STAB */
-	8,  /* CLIMB DOWN */
-	14, /* FREEZE LIFE */
-	9,  /* HIT */
-	4,  /* SWING */
-	5,  /* STAB */
-	5,  /* THRUST */
-	5,  /* JAB */
-	7,  /* PARRY */
-	4,  /* HACK */
-	4,  /* BERZERK */
-	16, /* FIREBALL */
-	17, /* DISPELL */
-	14, /* CONFUSE */
-	17, /* LIGHTNING */
-	17, /* DISRUPT */
-	6,  /* MELEE */
-	8,  /* X */
-	3,  /* INVOKE */
-	4,  /* SLASH */
-	4,  /* CLEAVE */
-	6,  /* BASH */
-	6,  /* STUN */
-	11, /* SHOOT */
-	15, /* SPELLSHIELD */
-	15, /* FIRESHIELD */
-	3,  /* FLUXCAGE */
-	13, /* HEAL */
-	14, /* CALM */
-	17, /* LIGHT */
-	18, /* WINDOW */
-	16, /* SPIT */
-	14, /* BRANDISH */
-	10, /* THROW */
-	3}; /* FUSE */
-
-
-Box  g499_BoxActionArea3ActionMenu = Box(224, 319, 77, 121); // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu
-Box  g500_BoxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
-Box  g501_BoxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
-Box g1_BoxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea 
-byte g498_PalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
-
-Box gK74_BoxSpellAreaLine = Box(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine 
-Box gK75_BoxSpellAreaLine2 = Box(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 
-Box gK76_BoxSpellAreaLine3 = Box(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 
-Box g0_BoxSpellArea = Box(224, 319, 77, 121);
-
-MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
-	_g508_refreshActionArea = false;
-	_g509_actionAreaContainsIcons = false;
-	_g513_actionDamage = 0;
-	_g713_actionList.resetToZero();
-	_gK72_bitmapSpellAreaLine = new byte[96 * 12];
-	_gK73_bitmapSpellAreaLines = new byte[3 * 96 * 12];
-	_g517_actionTargetGroupThing = Thing(0);
-	_g507_actionCount = 0;
-}
-
-MenuMan::~MenuMan() {
-	delete[] _gK72_bitmapSpellAreaLine;
-}
-
-void MenuMan::f395_drawMovementArrows() {
-	DisplayMan &disp = *_vm->_displayMan;
-	byte *arrowsBitmap = disp.f489_getNativeBitmapOrGraphic(k13_MovementArrowsIndice);
-	Box &dest = g2_BoxMovementArrows;
-	uint16 byteWidth = disp.getPixelWidth(k13_MovementArrowsIndice) / 2;
-
-	disp.f132_blitToBitmap(arrowsBitmap, disp._g348_bitmapScreen, dest, 0, 0, byteWidth, k160_byteWidthScreen, kM1_ColorNoTransparency);
-}
-void MenuMan::f388_clearActingChampion() {
-	ChampionMan &cm = *_vm->_championMan;
-	if (cm._g506_actingChampionOrdinal) {
-		cm._g506_actingChampionOrdinal--;
-		cm._gK71_champions[cm._g506_actingChampionOrdinal].setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
-		cm.f292_drawChampionState((ChampionIndex)cm._g506_actingChampionOrdinal);
-		cm._g506_actingChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
-		_g508_refreshActionArea = true;
-	}
-}
-
-void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
-	if (!_g509_actionAreaContainsIcons)
-		return;
-	DisplayMan &dm = *_vm->_displayMan;
-	Champion &champion = _vm->_championMan->_gK71_champions[championIndex];
-
-	Box box;
-	box._x1 = championIndex * 22 + 233;
-	box._x2 = box._x1 + 19;
-	box._y1 = 86;
-	box._y2 = 120;
-	dm._g578_useByteBoxCoordinates = false;
-	if (!champion._currHealth) {
-		dm.D24_fillScreenBox(box, k0_ColorBlack);
-		return;
-	}
-	byte *bitmapIcon = dm._g74_tmpBitmap;
-	Thing thing = champion.getSlot(k1_ChampionSlotActionHand);
-	IconIndice iconIndex;
-	if (thing == Thing::_none) {
-		iconIndex = k201_IconIndiceActionEmptyHand;
-	} else if (g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thing)]._actionSetIndex) {
-		iconIndex = _vm->_objectMan->f33_getIconIndex(thing);
-	} else {
-		dm.f134_fillBitmap(bitmapIcon, k4_ColorCyan, 16, 16);
-		goto T0386006;
-	}
-	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, bitmapIcon);
-	dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, bitmapIcon, 16, 16, 16, 16, g498_PalChangesActionAreaObjectIcon);
-T0386006:
-	dm.D24_fillScreenBox(box, k4_ColorCyan);
-	Box box2;
-	box2._x1 = box._x1 + 2;
-	box2._x2 = box._x2 - 2;
-	box2._y1 = 95;
-	box2._y2 = 110;
-	dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 8, k160_byteWidthScreen, kM1_ColorNoTransparency);
-	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) {
-		_vm->_displayMan->f136_shadeScreenBox(&box, k0_ColorBlack);
-	}
-}
-
-void MenuMan::f456_drawDisabledMenu() {
-	if (!_vm->_championMan->_g300_partyIsSleeping) {
-		_vm->_eventMan->f363_highlightBoxDisable();
-		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
-			if (_vm->_inventoryMan->_g424_panelContent == k4_PanelContentChest) {
-				_vm->_inventoryMan->f334_closeChest();
-			}
-		} else {
-			_vm->_displayMan->f136_shadeScreenBox(&g2_BoxMovementArrows, k0_ColorBlack);
-		}
-		_vm->_displayMan->f136_shadeScreenBox(&g0_BoxSpellArea, k0_ColorBlack);
-		_vm->_displayMan->f136_shadeScreenBox(&g1_BoxActionArea, k0_ColorBlack);
-		_vm->_eventMan->f67_setMousePointerToNormal(k0_pointerArrow);
-	}
-}
-
-void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
-	ChampionMan &champMan = *_vm->_championMan;
-
-	if (!champMan._g305_partyChampionCount)
-		return;
-
-	Champion *champ = nullptr;
-	if (champMan._g300_partyIsSleeping || champMan._g299_candidateChampionOrdinal) {
-		if (champMan._g506_actingChampionOrdinal) {
-			f388_clearActingChampion();
-			return;
-		}
-		if (!champMan._g299_candidateChampionOrdinal)
-			return;
-	} else {
-		champ = champMan._gK71_champions;
-		int16 champIndex = k0_ChampionFirst;
-
-		do {
-			if ((champIndex != champMan._g411_leaderIndex)
-				&& (_vm->M0_indexToOrdinal(champIndex) != champMan._g506_actingChampionOrdinal)
-				&& (champ->_maximumDamageReceived)
-				&& (champ->_dir != champ->_directionMaximumDamageReceived)) {
-
-				champ->_dir = (Direction)champ->_directionMaximumDamageReceived;
-				champ->setAttributeFlag(k0x0400_ChampionAttributeIcon, true);
-				champMan.f292_drawChampionState((ChampionIndex)champIndex);
-			}
-			champ->_maximumDamageReceived = 0;
-			champ++;
-			champIndex++;
-		} while (champIndex < champMan._g305_partyChampionCount);
-	}
-
-	if (_g508_refreshActionArea) {
-		if (!champMan._g506_actingChampionOrdinal) {
-			if (_g513_actionDamage) {
-				f385_drawActionDamage(_g513_actionDamage);
-				_g513_actionDamage = 0;
-			} else {
-				_g509_actionAreaContainsIcons = true;
-				f387_drawActionArea();
-			}
-		} else {
-			_g509_actionAreaContainsIcons = false;
-			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
-			champMan.f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal));
-			f387_drawActionArea();
-		}
-	}
-}
-
-#define k7_ChampionNameMaximumLength 7 // @ C007_CHAMPION_NAME_MAXIMUM_LENGTH
-#define k12_ActionNameMaximumLength 12 // @ C012_ACTION_NAME_MAXIMUM_LENGTH
-
-void MenuMan::f387_drawActionArea() {
-	DisplayMan &dispMan = *_vm->_displayMan;
-	ChampionMan &champMan = *_vm->_championMan;
-	TextMan &textMan = *_vm->_textMan;
-
-	_vm->_eventMan->f77_hideMouse();
-	dispMan._g578_useByteBoxCoordinates = false;
-	dispMan.D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack);
-	if (_g509_actionAreaContainsIcons) {
-		for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._g305_partyChampionCount; ++champIndex)
-			f386_drawActionIcon((ChampionIndex)champIndex);
-	} else if (champMan._g506_actingChampionOrdinal) {
-		Box box = g499_BoxActionArea3ActionMenu;
-		if (_g713_actionList._actionIndices[2] == k255_ChampionActionNone)
-			box = g500_BoxActionArea2ActionMenu;
-		if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone)
-			box = g501_BoxActionArea1ActionMenu;
-		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k10_MenuActionAreaIndice), dispMan._g348_bitmapScreen,
-								  box, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency);
-		textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen,
-											235, 83, k0_ColorBlack, k4_ColorCyan, champMan._gK71_champions[_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name,
-											k7_ChampionNameMaximumLength, k200_heightScreen);
-		for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) {
-			textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
-												f384_getActionName(_g713_actionList._actionIndices[actionListIndex]),
-												k12_ActionNameMaximumLength, k200_heightScreen);
-		}
-	}
-	_vm->_eventMan->f78_showMouse();
-	_g508_refreshActionArea = false;
-}
-
-const char *g490_ChampionActionNames[44] = { // @ G0490_ac_Graphic560_ActionNames
-	"N", "BLOCK", "CHOP", "X", "BLOW HORN", "FLIP", "PUNCH",
-	"KICK", "WAR CRY", "STAB", "CLIMB DOWN", "FREEZE LIFE",
-	"HIT", "SWING", "STAB", "THRUST", "JAB", "PARRY", "HACK",
-	"BERZERK", "FIREBALL", "DISPELL", "CONFUSE", "LIGHTNING",
-	"DISRUPT", "MELEE", "X", "INVOKE", "SLASH", "CLEAVE",
-	"BASH", "STUN", "SHOOT", "SPELLSHIELD", "FIRESHIELD",
-	"FLUXCAGE", "HEAL", "CALM", "LIGHT", "WINDOW", "SPIT",
-	"BRANDISH", "THROW", "FUSE"};
-
-const char* MenuMan::f384_getActionName(ChampionAction actionIndex) {
-	return (actionIndex == k255_ChampionActionNone) ? "" : g490_ChampionActionNames[actionIndex];
-}
-
-
-Box g504_BoxSpellAreaControls = Box(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls 
-
-void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) {
-	ChampionMan &champMan = *_vm->_championMan;
-	DisplayMan &dispMan = *_vm->_displayMan;
-	TextMan &textMan = *_vm->_textMan;
-
-	Champion &champ = champMan._gK71_champions[champIndex];
-	int16 champCurrHealth[4];
-	for (uint16 i = 0; i < 4; ++i)
-		champCurrHealth[i] = champMan._gK71_champions[i]._currHealth;
-	_vm->_eventMan->f77_hideMouse();
-	dispMan.D24_fillScreenBox(g504_BoxSpellAreaControls, k0_ColorBlack);
-	int16 champCount = champMan._g305_partyChampionCount;
-	switch (champIndex) {
-	case k0_ChampionFirst:
-		_vm->_eventMan->f6_highlightScreenBox(233, 277, 42, 49);
-		textMan.f53_printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
-		if (champCount) {
-			if (champCurrHealth[1]) {
-				_vm->_eventMan->f6_highlightScreenBox(280, 291, 42, 48);;
-			}
-labelChamp2:
-			if (champCount > 2) {
-				if (champCurrHealth[2]) {
-					_vm->_eventMan->f6_highlightScreenBox(294, 305, 42, 48);
-				}
-labelChamp3:
-				if (champCount > 3) {
-					if (champCurrHealth[3]) {
-						_vm->_eventMan->f6_highlightScreenBox(308, 319, 42, 48);
-					}
-				}
-			}
-		}
-		break;
-	case k1_ChampionSecond:
-		if (champCurrHealth[0]) {
-			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
-		}
-		_vm->_eventMan->f6_highlightScreenBox(247, 291, 42, 49);
-		textMan.f53_printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
-		goto labelChamp2;
-	case k2_ChampionThird:
-		if (champCurrHealth[0]) {
-			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
-		}
-		if (champCurrHealth[1]) {
-			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
-		}
-		_vm->_eventMan->f6_highlightScreenBox(261, 305, 42, 49);
-		textMan.f53_printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
-		goto labelChamp3;
-	case k3_ChampionFourth:
-		if (champCurrHealth[0]) {
-			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
-		}
-		if (champCurrHealth[1]) {
-			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
-		}
-		if (champCurrHealth[2]) {
-			_vm->_eventMan->f6_highlightScreenBox(261, 272, 42, 48);
-		}
-		_vm->_eventMan->f6_highlightScreenBox(275, 319, 42, 49);
-		textMan.f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
-		break;
-	}
-	_vm->_eventMan->f78_showMouse();
-}
-
-#define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
-#define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
-
-void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
-	char L1204_ac_SpellSymbolString[2] = {'\0', '\0'};
-	Champion *L1203_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
-	if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) {
-		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		_vm->_displayMan->f132_blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 12, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
-		int16 x = 1;
-		char character = 96 + (6 * L1203_ps_Champion->_symbolStep);
-		for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
-			L1204_ac_SpellSymbolString[0] = character++;
-			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 14, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
-		}
-	} else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) {
-		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		_vm->_displayMan->f132_blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 24, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
-		int16 x = 8;
-		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
-			if ((L1204_ac_SpellSymbolString[0] = L1203_ps_Champion->_symbols[symbolIndex]) == '\0')
-				break;
-			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 9, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
-		}
-	}
-
-}
-
-void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
-	Champion* L1213_ps_Champion;
-
-	if ((champIndex == _vm->_championMan->_g514_magicCasterChampionIndex) || ((champIndex != kM1_ChampionNone) && !_vm->_championMan->_gK71_champions[champIndex]._currHealth)) {
-		return;
-	}
-	if (_vm->_championMan->_g514_magicCasterChampionIndex == kM1_ChampionNone) {
-		_vm->_eventMan->f78_showMouse();
-		_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &g0_BoxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33);
-		_vm->_eventMan->f77_hideMouse();
-	}
-	if (champIndex == kM1_ChampionNone) {
-		_vm->_championMan->_g514_magicCasterChampionIndex = kM1_ChampionNone;
-		_vm->_eventMan->f78_showMouse();
-		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		_vm->_displayMan->D24_fillScreenBox(g0_BoxSpellArea, k0_ColorBlack);
-		_vm->_eventMan->f77_hideMouse();
-		return;
-	}
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#include "menus.h"
+#include "gfx.h"
+#include "champion.h"
+#include "dungeonman.h"
+#include "objectman.h"
+#include "inventory.h"
+#include "text.h"
+#include "eventman.h"
+#include "timeline.h"
+#include "movesens.h"
+#include "group.h"
+#include "projexpl.h"
+
+
+namespace DM {
+
+unsigned char g496_ActionSkillIndex[44] = { // @ G0496_auc_Graphic560_ActionSkillIndex
+	0,  /* N */
+	7,  /* BLOCK */
+	6,  /* CHOP */
+	0,  /* X */
+	14, /* BLOW HORN */
+	12, /* FLIP */
+	9,  /* PUNCH */
+	9,  /* KICK */
+	7,  /* WAR CRY Atari ST Versions 1.0 1987-12-08 1987-12-11 1.1: 14 */
+	9,  /* STAB */
+	8,  /* CLIMB DOWN */
+	14, /* FREEZE LIFE */
+	9,  /* HIT */
+	4,  /* SWING */
+	5,  /* STAB */
+	5,  /* THRUST */
+	5,  /* JAB */
+	7,  /* PARRY */
+	4,  /* HACK */
+	4,  /* BERZERK */
+	16, /* FIREBALL */
+	17, /* DISPELL */
+	14, /* CONFUSE */
+	17, /* LIGHTNING */
+	17, /* DISRUPT */
+	6,  /* MELEE */
+	8,  /* X */
+	3,  /* INVOKE */
+	4,  /* SLASH */
+	4,  /* CLEAVE */
+	6,  /* BASH */
+	6,  /* STUN */
+	11, /* SHOOT */
+	15, /* SPELLSHIELD */
+	15, /* FIRESHIELD */
+	3,  /* FLUXCAGE */
+	13, /* HEAL */
+	14, /* CALM */
+	17, /* LIGHT */
+	18, /* WINDOW */
+	16, /* SPIT */
+	14, /* BRANDISH */
+	10, /* THROW */
+	3}; /* FUSE */
+
+
+Box  g499_BoxActionArea3ActionMenu = Box(224, 319, 77, 121); // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu
+Box  g500_BoxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
+Box  g501_BoxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
+Box g1_BoxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea 
+byte g498_PalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
+
+Box gK74_BoxSpellAreaLine = Box(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine 
+Box gK75_BoxSpellAreaLine2 = Box(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 
+Box gK76_BoxSpellAreaLine3 = Box(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 
+Box g0_BoxSpellArea = Box(224, 319, 42, 74);
+
+MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
+	_g508_refreshActionArea = false;
+	_g509_actionAreaContainsIcons = false;
+	_g513_actionDamage = 0;
+	_g713_actionList.resetToZero();
+	_gK72_bitmapSpellAreaLine = new byte[96 * 12];
+	_gK73_bitmapSpellAreaLines = new byte[3 * 96 * 12];
+	_g517_actionTargetGroupThing = Thing(0);
+	_g507_actionCount = 0;
+}
+
+MenuMan::~MenuMan() {
+	delete[] _gK72_bitmapSpellAreaLine;
+}
+
+void MenuMan::f395_drawMovementArrows() {
+	DisplayMan &disp = *_vm->_displayMan;
+	byte *arrowsBitmap = disp.f489_getNativeBitmapOrGraphic(k13_MovementArrowsIndice);
+	Box &dest = g2_BoxMovementArrows;
+	uint16 byteWidth = disp.getPixelWidth(k13_MovementArrowsIndice) / 2;
+
+	disp.f132_blitToBitmap(arrowsBitmap, disp._g348_bitmapScreen, dest, 0, 0, byteWidth, k160_byteWidthScreen, kM1_ColorNoTransparency);
+}
+void MenuMan::f388_clearActingChampion() {
+	ChampionMan &cm = *_vm->_championMan;
+	if (cm._g506_actingChampionOrdinal) {
+		cm._g506_actingChampionOrdinal--;
+		cm._gK71_champions[cm._g506_actingChampionOrdinal].setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
+		cm.f292_drawChampionState((ChampionIndex)cm._g506_actingChampionOrdinal);
+		cm._g506_actingChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+		_g508_refreshActionArea = true;
+	}
+}
+
+void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
+	if (!_g509_actionAreaContainsIcons)
+		return;
+	DisplayMan &dm = *_vm->_displayMan;
+	Champion &champion = _vm->_championMan->_gK71_champions[championIndex];
+
+	Box box;
+	box._x1 = championIndex * 22 + 233;
+	box._x2 = box._x1 + 19;
+	box._y1 = 86;
+	box._y2 = 120;
+	dm._g578_useByteBoxCoordinates = false;
+	if (!champion._currHealth) {
+		dm.D24_fillScreenBox(box, k0_ColorBlack);
+		return;
+	}
+	byte *bitmapIcon = dm._g74_tmpBitmap;
+	Thing thing = champion.getSlot(k1_ChampionSlotActionHand);
+	IconIndice iconIndex;
+	if (thing == Thing::_none) {
+		iconIndex = k201_IconIndiceActionEmptyHand;
+	} else if (g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thing)]._actionSetIndex) {
+		iconIndex = _vm->_objectMan->f33_getIconIndex(thing);
+	} else {
+		dm.f134_fillBitmap(bitmapIcon, k4_ColorCyan, 16, 16);
+		goto T0386006;
+	}
+	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, bitmapIcon);
+	dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, bitmapIcon, 16, 16, 16, 16, g498_PalChangesActionAreaObjectIcon);
+T0386006:
+	dm.D24_fillScreenBox(box, k4_ColorCyan);
+	Box box2;
+	box2._x1 = box._x1 + 2;
+	box2._x2 = box._x2 - 2;
+	box2._y1 = 95;
+	box2._y2 = 110;
+	dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 8, k160_byteWidthScreen, kM1_ColorNoTransparency);
+	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) {
+		_vm->_displayMan->f136_shadeScreenBox(&box, k0_ColorBlack);
+	}
+}
+
+void MenuMan::f456_drawDisabledMenu() {
+	if (!_vm->_championMan->_g300_partyIsSleeping) {
+		_vm->_eventMan->f363_highlightBoxDisable();
+		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+			if (_vm->_inventoryMan->_g424_panelContent == k4_PanelContentChest) {
+				_vm->_inventoryMan->f334_closeChest();
+			}
+		} else {
+			_vm->_displayMan->f136_shadeScreenBox(&g2_BoxMovementArrows, k0_ColorBlack);
+		}
+		_vm->_displayMan->f136_shadeScreenBox(&g0_BoxSpellArea, k0_ColorBlack);
+		_vm->_displayMan->f136_shadeScreenBox(&g1_BoxActionArea, k0_ColorBlack);
+		_vm->_eventMan->f67_setMousePointerToNormal(k0_pointerArrow);
+	}
+}
+
+void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
+	ChampionMan &champMan = *_vm->_championMan;
+
+	if (!champMan._g305_partyChampionCount)
+		return;
+
+	Champion *champ = nullptr;
+	if (champMan._g300_partyIsSleeping || champMan._g299_candidateChampionOrdinal) {
+		if (champMan._g506_actingChampionOrdinal) {
+			f388_clearActingChampion();
+			return;
+		}
+		if (!champMan._g299_candidateChampionOrdinal)
+			return;
+	} else {
+		champ = champMan._gK71_champions;
+		int16 champIndex = k0_ChampionFirst;
+
+		do {
+			if ((champIndex != champMan._g411_leaderIndex)
+				&& (_vm->M0_indexToOrdinal(champIndex) != champMan._g506_actingChampionOrdinal)
+				&& (champ->_maximumDamageReceived)
+				&& (champ->_dir != champ->_directionMaximumDamageReceived)) {
+
+				champ->_dir = (Direction)champ->_directionMaximumDamageReceived;
+				champ->setAttributeFlag(k0x0400_ChampionAttributeIcon, true);
+				champMan.f292_drawChampionState((ChampionIndex)champIndex);
+			}
+			champ->_maximumDamageReceived = 0;
+			champ++;
+			champIndex++;
+		} while (champIndex < champMan._g305_partyChampionCount);
+	}
+
+	if (_g508_refreshActionArea) {
+		if (!champMan._g506_actingChampionOrdinal) {
+			if (_g513_actionDamage) {
+				f385_drawActionDamage(_g513_actionDamage);
+				_g513_actionDamage = 0;
+			} else {
+				_g509_actionAreaContainsIcons = true;
+				f387_drawActionArea();
+			}
+		} else {
+			_g509_actionAreaContainsIcons = false;
+			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
+			champMan.f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal));
+			f387_drawActionArea();
+		}
+	}
+}
+
+#define k7_ChampionNameMaximumLength 7 // @ C007_CHAMPION_NAME_MAXIMUM_LENGTH
+#define k12_ActionNameMaximumLength 12 // @ C012_ACTION_NAME_MAXIMUM_LENGTH
+
+void MenuMan::f387_drawActionArea() {
+	DisplayMan &dispMan = *_vm->_displayMan;
+	ChampionMan &champMan = *_vm->_championMan;
+	TextMan &textMan = *_vm->_textMan;
+
+	_vm->_eventMan->f77_hideMouse();
+	dispMan._g578_useByteBoxCoordinates = false;
+	dispMan.D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack);
+	if (_g509_actionAreaContainsIcons) {
+		for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._g305_partyChampionCount; ++champIndex)
+			f386_drawActionIcon((ChampionIndex)champIndex);
+	} else if (champMan._g506_actingChampionOrdinal) {
+		Box box = g499_BoxActionArea3ActionMenu;
+		if (_g713_actionList._actionIndices[2] == k255_ChampionActionNone)
+			box = g500_BoxActionArea2ActionMenu;
+		if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone)
+			box = g501_BoxActionArea1ActionMenu;
+		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k10_MenuActionAreaIndice), dispMan._g348_bitmapScreen,
+								  box, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency);
+		textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen,
+											235, 83, k0_ColorBlack, k4_ColorCyan, champMan._gK71_champions[_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name,
+											k7_ChampionNameMaximumLength, k200_heightScreen);
+		for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) {
+			textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
+												f384_getActionName(_g713_actionList._actionIndices[actionListIndex]),
+												k12_ActionNameMaximumLength, k200_heightScreen);
+		}
+	}
+	_vm->_eventMan->f78_showMouse();
+	_g508_refreshActionArea = false;
+}
+
+const char *g490_ChampionActionNames[44] = { // @ G0490_ac_Graphic560_ActionNames
+	"N", "BLOCK", "CHOP", "X", "BLOW HORN", "FLIP", "PUNCH",
+	"KICK", "WAR CRY", "STAB", "CLIMB DOWN", "FREEZE LIFE",
+	"HIT", "SWING", "STAB", "THRUST", "JAB", "PARRY", "HACK",
+	"BERZERK", "FIREBALL", "DISPELL", "CONFUSE", "LIGHTNING",
+	"DISRUPT", "MELEE", "X", "INVOKE", "SLASH", "CLEAVE",
+	"BASH", "STUN", "SHOOT", "SPELLSHIELD", "FIRESHIELD",
+	"FLUXCAGE", "HEAL", "CALM", "LIGHT", "WINDOW", "SPIT",
+	"BRANDISH", "THROW", "FUSE"};
+
+const char* MenuMan::f384_getActionName(ChampionAction actionIndex) {
+	return (actionIndex == k255_ChampionActionNone) ? "" : g490_ChampionActionNames[actionIndex];
+}
+
+
+Box g504_BoxSpellAreaControls = Box(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls 
+
+void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) {
+	ChampionMan &champMan = *_vm->_championMan;
+	DisplayMan &dispMan = *_vm->_displayMan;
+	TextMan &textMan = *_vm->_textMan;
+
+	Champion &champ = champMan._gK71_champions[champIndex];
+	int16 champCurrHealth[4];
+	for (uint16 i = 0; i < 4; ++i)
+		champCurrHealth[i] = champMan._gK71_champions[i]._currHealth;
+	_vm->_eventMan->f77_hideMouse();
+	dispMan.D24_fillScreenBox(g504_BoxSpellAreaControls, k0_ColorBlack);
+	int16 champCount = champMan._g305_partyChampionCount;
+	switch (champIndex) {
+	case k0_ChampionFirst:
+		_vm->_eventMan->f6_highlightScreenBox(233, 277, 42, 49);
+		textMan.f53_printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
+		if (champCount) {
+			if (champCurrHealth[1]) {
+				_vm->_eventMan->f6_highlightScreenBox(280, 291, 42, 48);;
+			}
+labelChamp2:
+			if (champCount > 2) {
+				if (champCurrHealth[2]) {
+					_vm->_eventMan->f6_highlightScreenBox(294, 305, 42, 48);
+				}
+labelChamp3:
+				if (champCount > 3) {
+					if (champCurrHealth[3]) {
+						_vm->_eventMan->f6_highlightScreenBox(308, 319, 42, 48);
+					}
+				}
+			}
+		}
+		break;
+	case k1_ChampionSecond:
+		if (champCurrHealth[0]) {
+			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
+		}
+		_vm->_eventMan->f6_highlightScreenBox(247, 291, 42, 49);
+		textMan.f53_printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
+		goto labelChamp2;
+	case k2_ChampionThird:
+		if (champCurrHealth[0]) {
+			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
+		}
+		if (champCurrHealth[1]) {
+			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
+		}
+		_vm->_eventMan->f6_highlightScreenBox(261, 305, 42, 49);
+		textMan.f53_printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
+		goto labelChamp3;
+	case k3_ChampionFourth:
+		if (champCurrHealth[0]) {
+			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
+		}
+		if (champCurrHealth[1]) {
+			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
+		}
+		if (champCurrHealth[2]) {
+			_vm->_eventMan->f6_highlightScreenBox(261, 272, 42, 48);
+		}
+		_vm->_eventMan->f6_highlightScreenBox(275, 319, 42, 49);
+		textMan.f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
+		break;
+	}
+	_vm->_eventMan->f78_showMouse();
+}
+
+#define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
+#define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
+
+void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
+	char L1204_ac_SpellSymbolString[2] = {'\0', '\0'};
+	Champion *L1203_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
+	if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) {
+		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+		_vm->_displayMan->f132_blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 12, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
+		int16 x = 1;
+		char character = 96 + (6 * L1203_ps_Champion->_symbolStep);
+		for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
+			L1204_ac_SpellSymbolString[0] = character++;
+			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 14, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
+		}
+	} else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) {
+		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+		_vm->_displayMan->f132_blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 24, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
+		int16 x = 8;
+		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
+			if ((L1204_ac_SpellSymbolString[0] = L1203_ps_Champion->_symbols[symbolIndex]) == '\0')
+				break;
+			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 9, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
+		}
+	}
+
+}
+
+void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
+	Champion* L1213_ps_Champion;
+
+	if ((champIndex == _vm->_championMan->_g514_magicCasterChampionIndex) || ((champIndex != kM1_ChampionNone) && !_vm->_championMan->_gK71_champions[champIndex]._currHealth)) {
+		return;
+	}
+	if (_vm->_championMan->_g514_magicCasterChampionIndex == kM1_ChampionNone) {
+		_vm->_eventMan->f78_showMouse();
+		_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &g0_BoxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33);
+		_vm->_eventMan->f77_hideMouse();
+	}
+	if (champIndex == kM1_ChampionNone) {
+		_vm->_championMan->_g514_magicCasterChampionIndex = kM1_ChampionNone;
+		_vm->_eventMan->f78_showMouse();
+		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+		_vm->_displayMan->D24_fillScreenBox(g0_BoxSpellArea, k0_ColorBlack);
+		_vm->_eventMan->f77_hideMouse();
+		return;
+	}
 	L1213_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex = (ChampionIndex)champIndex];
-	f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
-	_vm->_eventMan->f78_showMouse();
-	f393_drawSpellAreaControls((ChampionIndex)champIndex);
-	_vm->_displayMan->f21_blitToScreen(_gK72_bitmapSpellAreaLine, &gK75_BoxSpellAreaLine2, k48_byteWidth, kM1_ColorNoTransparency, 12);
-	f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols);
-	_vm->_displayMan->f21_blitToScreen(_gK72_bitmapSpellAreaLine, &gK76_BoxSpellAreaLine3, k48_byteWidth, kM1_ColorNoTransparency, 12);
-	_vm->_eventMan->f77_hideMouse();
-}
-
-void MenuMan::f457_drawEnabledMenus() {
-	int16 L1462_i_Multiple;
-#define AL1462_i_MagicCasterChampionIndex L1462_i_Multiple
-#define AL1462_i_InventoryChampionOrdinal L1462_i_Multiple
-
-
-	if (_vm->_championMan->_g300_partyIsSleeping) {
-		_vm->_eventMan->f379_drawSleepScreen();
-		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
-	} else {
-		AL1462_i_MagicCasterChampionIndex = _vm->_championMan->_g514_magicCasterChampionIndex;
-		_vm->_championMan->_g514_magicCasterChampionIndex = kM1_ChampionNone; /* Force next function to draw the spell area */
-		f394_setMagicCasterAndDrawSpellArea(AL1462_i_MagicCasterChampionIndex);
-		if (!_vm->_championMan->_g506_actingChampionOrdinal) {
-			_g509_actionAreaContainsIcons = true;
-		}
-		f387_drawActionArea();
-		if (AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
-			_vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
-			_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)_vm->M1_ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
-		} else {
-			_vm->_displayMan->f98_drawFloorAndCeiling();
-			f395_drawMovementArrows();
-		}
-		_vm->_eventMan->f69_setMousePointer();
-	}
-}
-
-int16 MenuMan::f408_getClickOnSpellCastResult() {
-	int16 L1259_i_SpellCastResult;
-	Champion* L1260_ps_Champion;
-
-
-	L1260_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
-	_vm->_eventMan->f78_showMouse();
-	_vm->_eventMan->f363_highlightBoxDisable();
-	if ((L1259_i_SpellCastResult = f412_getChampionSpellCastResult(_vm->_championMan->_g514_magicCasterChampionIndex)) != k3_spellCastFailureNeedsFlask) {
-		L1260_ps_Champion->_symbols[0] = '\0';
-		f397_drawAvailableSymbols(L1260_ps_Champion->_symbolStep = 0);
-		f398_drawChampionSymbols(L1260_ps_Champion);
-	} else {
-		L1259_i_SpellCastResult = k0_spellCastFailure;
-	}
-	_vm->_eventMan->f77_hideMouse();
-	return L1259_i_SpellCastResult;
-}
-
-int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
-	uint16 L1267_ui_Multiple;
-#define AL1267_ui_SkillLevel L1267_ui_Multiple
-#define AL1267_ui_LightPower L1267_ui_Multiple
-#define AL1267_ui_SpellPower L1267_ui_Multiple
-#define AL1267_ui_Ticks      L1267_ui_Multiple
-	int16 L1268_i_PowerSymbolOrdinal;
-	uint16 L1269_ui_Multiple;
-#define AL1269_ui_RequiredSkillLevel L1269_ui_Multiple
-#define AL1269_ui_EmptyFlaskWeight   L1269_ui_Multiple
-#define AL1269_ui_Ticks              L1269_ui_Multiple
-	Champion* L1270_ps_Champion;
-	Spell* L1271_ps_Spell;
-	Thing L1272_T_Object;
-	uint16 L1273_ui_Experience;
-	int16 L1274_i_MissingSkillLevelCount;
-	Potion* L1275_ps_Potion;
-	TimelineEvent L1276_s_Event;
-	Junk* L1277_ps_Junk;
-
-
-	if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
-		return k0_spellCastFailure;
-	}
-	L1270_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
-	if (!(L1270_ps_Champion->_currHealth)) {
-		return k0_spellCastFailure;
-	}
-	if ((L1271_ps_Spell = f409_getSpellFromSymbols((unsigned char *)L1270_ps_Champion->_symbols)) == 0) {
-		f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k1_spellCastSuccess, 0);
-		return k0_spellCastFailure;
-	}
-	L1268_i_PowerSymbolOrdinal = L1270_ps_Champion->_symbols[0] - '_'; /* Values 1 to 6 */
-	L1273_ui_Experience = _vm->getRandomNumber(8) + ((AL1269_ui_RequiredSkillLevel = L1271_ps_Spell->_baseRequiredSkillLevel + L1268_i_PowerSymbolOrdinal) << 4) + ((_vm->M1_ordinalToIndex(L1268_i_PowerSymbolOrdinal) * L1271_ps_Spell->_baseRequiredSkillLevel) << 3) + (AL1269_ui_RequiredSkillLevel * AL1269_ui_RequiredSkillLevel);
-	AL1267_ui_SkillLevel = _vm->_championMan->f303_getSkillLevel(champIndex, L1271_ps_Spell->_skillIndex);
-	if (AL1267_ui_SkillLevel < AL1269_ui_RequiredSkillLevel) {
-		L1274_i_MissingSkillLevelCount = AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel;
-		while (L1274_i_MissingSkillLevelCount--) {
-			if (_vm->getRandomNumber(128) > MIN(L1270_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + 15, 115)) {
-				_vm->_championMan->f304_addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience >> (AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel));
-				f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k0_failureNeedsMorePractice, L1271_ps_Spell->_skillIndex);
-				return k0_spellCastFailure;
-			}
-		}
-	}
-	switch (L1271_ps_Spell->M67_spellKind()) {
-	case k1_spellKindPotion:
-		if ((L1275_ps_Potion = f411_getEmptyFlaskInHand(L1270_ps_Champion, &L1272_T_Object)) == NULL) {
-			f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k10_failureNeedsFlaskInHand, 0);
-			return k3_spellCastFailureNeedsFlask;
-		}
-		AL1269_ui_EmptyFlaskWeight = _vm->_dungeonMan->f140_getObjectWeight(L1272_T_Object);
-		L1275_ps_Potion->setType((PotionType)L1271_ps_Spell->M68_spellType());
-		L1275_ps_Potion->setPower(_vm->getRandomNumber(16) + (L1268_i_PowerSymbolOrdinal * 40));
-		L1270_ps_Champion->_load += _vm->_dungeonMan->f140_getObjectWeight(L1272_T_Object) - AL1269_ui_EmptyFlaskWeight;
-		_vm->_championMan->f296_drawChangedObjectIcons();
-		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)) {
-			setFlag(L1270_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad);
-			_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
-		}
-		break;
-	case k2_spellKindProjectile:
-		if (L1270_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) {
-			L1270_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
-			setFlag(L1270_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon);
-			_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
-		}
-		if (L1271_ps_Spell->M68_spellType() == k4_spellType_projectileOpenDoor) {
-			AL1267_ui_SkillLevel <<= 1;
-		}
-		_vm->_championMan->f327_isProjectileSpellCast(champIndex, Thing(L1271_ps_Spell->M68_spellType() + Thing::_firstExplosion.toUint16()), f26_getBoundedValue(21, (L1268_i_PowerSymbolOrdinal + 2) * (4 + (AL1267_ui_SkillLevel << 1)), 255), 0);
-		break;
-	case k3_spellKindOther:
-		L1276_s_Event._priority = 0;
-		AL1267_ui_SpellPower = (L1268_i_PowerSymbolOrdinal + 1) << 2;
-		switch (L1271_ps_Spell->M68_spellType()) {
-		case k0_spellType_otherLight:
-			AL1269_ui_Ticks = 10000 + ((AL1267_ui_SpellPower - 8) << 9);
-			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 1);
-			AL1267_ui_LightPower--;
-			goto T0412019;
-		case k5_spellType_otherMagicTorch:
-			AL1269_ui_Ticks = 2000 + ((AL1267_ui_SpellPower - 3) << 7);
-			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
-			AL1267_ui_LightPower++;
-T0412019:
-			_vm->_championMan->_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[AL1267_ui_LightPower];
-			f404_createEvent70_light(-AL1267_ui_LightPower, AL1269_ui_Ticks);
-			break;
-		case k1_spellType_otherDarkness:
-			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
-			_vm->_championMan->_g407_party._magicalLightAmount -= g39_LightPowerToLightAmount[AL1267_ui_LightPower];
-			f404_createEvent70_light(AL1267_ui_LightPower, 98);
-			break;
-		case k2_spellType_otherThievesEye:
-			L1276_s_Event._type = k73_TMEventTypeThievesEye;
-			_vm->_championMan->_g407_party._event73Count_ThievesEye++;
-			AL1267_ui_SpellPower = (AL1267_ui_SpellPower >> 1);
-			goto T0412032;
-		case k3_spellType_otherInvisibility:
-			L1276_s_Event._type = k71_TMEventTypeInvisibility;
-			_vm->_championMan->_g407_party._event71Count_Invisibility++;
-			goto T0412033;
-		case k4_spellType_otherPartyShield:
-			L1276_s_Event._type = k74_TMEventTypePartyShield;
-			L1276_s_Event._B._defense = AL1267_ui_SpellPower;
-			if (_vm->_championMan->_g407_party._shieldDefense > 50) {
-				L1276_s_Event._B._defense >>= 2;
-			}
-			_vm->_championMan->_g407_party._shieldDefense += L1276_s_Event._B._defense;
-			_vm->_timeline->f260_timelineRefreshAllChampionStatusBoxes();
-			goto T0412032;
-		case k6_spellType_otherFootprints:
-			L1276_s_Event._type = k79_TMEventTypeFootprints;
-			_vm->_championMan->_g407_party._event79Count_Footprints++;
-			_vm->_championMan->_g407_party._firstScentIndex = _vm->_championMan->_g407_party._scentCount;
-			if (L1268_i_PowerSymbolOrdinal < 3) {
-				_vm->_championMan->_g407_party._lastScentIndex = _vm->_championMan->_g407_party._firstScentIndex;
-			} else {
-				_vm->_championMan->_g407_party._lastScentIndex = 0;
-			}
-T0412032:
-			AL1267_ui_Ticks = AL1267_ui_SpellPower * AL1267_ui_SpellPower;
-T0412033:
-			M33_setMapAndTime(L1276_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + AL1267_ui_Ticks);
-			_vm->_timeline->f238_addEventGetEventIndex(&L1276_s_Event);
-			break;
-		case k7_spellType_otherZokathra:
-			if ((L1272_T_Object = _vm->_dungeonMan->f166_getUnusedThing(k10_JunkThingType)) == Thing::_none)
-				break;
-			L1277_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1272_T_Object);
-			L1277_ps_Junk->setType(k51_JunkTypeZokathra);
-			ChampionSlot AL1267_ui_SlotIndex;
-			if (L1270_ps_Champion->_slots[k0_ChampionSlotReadyHand] == Thing::_none) {
-				AL1267_ui_SlotIndex = k0_ChampionSlotReadyHand;
-			} else {
-				if (L1270_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) {
-					AL1267_ui_SlotIndex = k1_ChampionSlotActionHand;
-				} else {
-					AL1267_ui_SlotIndex = kM1_ChampionSlotLeaderHand;
-				}
-			}
-			if ((AL1267_ui_SlotIndex == k0_ChampionSlotReadyHand) || (AL1267_ui_SlotIndex == k1_ChampionSlotActionHand)) {
-				_vm->_championMan->f301_addObjectInSlot((ChampionIndex)champIndex, L1272_T_Object, AL1267_ui_SlotIndex);
-				_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
-			} else {
-				_vm->_moveSens->f267_getMoveResult(L1272_T_Object, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
-			}
-			break;
-		case k8_spellType_otherFireshield:
-			f403_isPartySpellOrFireShieldSuccessful(L1270_ps_Champion, false, (AL1267_ui_SpellPower * AL1267_ui_SpellPower) + 100, false);
-		}
-	}
-	_vm->_championMan->f304_addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience);
-	_vm->_championMan->f330_disableAction(champIndex, L1271_ps_Spell->M69_spellDurration());
-	return k1_spellCastSuccess;
-}
-
-Spell* MenuMan::f409_getSpellFromSymbols(byte* symbols) {
-	static Spell G0487_as_Graphic560_Spells[25] = {
-		/* { Symbols, BaseRequiredSkillLevel, SkillIndex, Attributes } */
-		Spell(0x00666F00, 2, 15, 0x7843),
-		Spell(0x00667073, 1, 18, 0x4863),
-		Spell(0x00686D77, 3, 17, 0xB433),
-		Spell(0x00686C00, 3, 19, 0x6C72),
-		Spell(0x00686D76, 3, 18, 0x8423),
-		Spell(0x00686E76, 4, 17, 0x7822),
-		Spell(0x00686F76, 4, 17, 0x5803),
-		Spell(0x00690000, 1, 16, 0x3C53),
-		Spell(0x00696F00, 3, 16, 0xA802),
-		Spell(0x00697072, 4, 13, 0x3C71),
-		Spell(0x00697075, 4, 15, 0x7083),
-		Spell(0x006A6D00, 1, 18, 0x5032),
-		Spell(0x006A6C00, 1, 19, 0x4062),
-		Spell(0x006A6F77, 1, 15, 0x3013),
-		Spell(0x006B0000, 1, 17, 0x3C42),
-		Spell(0x00667000, 2, 15, 0x64C1),
-		Spell(0x00660000, 2, 13, 0x3CB1),
-		Spell(0x00667074, 4, 13, 0x3C81),
-		Spell(0x00667075, 4, 13, 0x3C91),
-		Spell(0x00670000, 1, 13, 0x80E1),
-		Spell(0x00677000, 1, 13, 0x68A1),
-		Spell(0x00687073, 4, 13, 0x3C61),
-		Spell(0x006B7076, 3,  2, 0xFCD1),
-		Spell(0x006B6C00, 2, 19, 0x7831),
-		Spell(0x006B6E76, 0,  3, 0x3C73)
-	};
-
-	if (*(symbols + 1)) {
-		int16 AL1262_i_BitShiftCount = 24;
-		int32 L1261_l_Symbols = 0;
-		do {
-			L1261_l_Symbols |= (long)*symbols++ << AL1262_i_BitShiftCount;
-		} while (*symbols && ((AL1262_i_BitShiftCount -= 8) >= 0));
-		Spell *L1263_ps_Spell = G0487_as_Graphic560_Spells;
-		int16 AL1262_i_SpellIndex = 25;
-		while (AL1262_i_SpellIndex--) {
-			if (L1263_ps_Spell->_symbols & 0xFF000000) { /* If byte 1 of spell is not 0 then the spell includes the power symbol */
-				if (L1261_l_Symbols == L1263_ps_Spell->_symbols) { /* Compare champion symbols, including power symbol, with spell (never used with actual spells) */
-					return L1263_ps_Spell;
-				}
-			} else {
-				if ((L1261_l_Symbols & 0x00FFFFFF) == L1263_ps_Spell->_symbols) { /* Compare champion symbols, except power symbol, with spell */
-					return L1263_ps_Spell;
-				}
-			}
-			L1263_ps_Spell++;
-		}
-	}
-	return NULL;
-}
-
-void MenuMan::f410_menusPrintSpellFailureMessage(Champion* champ, uint16 failureType, uint16 skillIndex) {
-	char* L1264_pc_Message = nullptr;
-
-	if (skillIndex > k3_ChampionSkillWizard) {
-		skillIndex = (skillIndex - 4) / 4;
-	}
-	_vm->_textMan->f51_messageAreaPrintLineFeed();
-	_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, champ->_name);
-	switch (failureType) {
-	case k0_failureNeedsMorePractice:
-		// TODO: localization
-		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, " NEEDS MORE PRACTICE WITH THIS ");
-		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, g417_baseSkillName[skillIndex]);
-		L1264_pc_Message = " SPELL.";
-		break;
-	case k1_failureMeaninglessSpell:
-		L1264_pc_Message = " MUMBLES A MEANINGLESS SPELL."; // TODO: localization
-		break;
-	case k10_failureNeedsFlaskInHand:
-		L1264_pc_Message = " NEEDS AN EMPTY FLASK IN HAND FOR POTION."; // TODO: localization
-		break;
-	}
-	_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, L1264_pc_Message);
-}
-
-Potion* MenuMan::f411_getEmptyFlaskInHand(Champion* champ, Thing* potionThing) {
-	Thing L1265_T_Thing;
-	int16 L1266_i_SlotIndex;
-
-	for (L1266_i_SlotIndex = k2_ChampionSlotHead; --L1266_i_SlotIndex >= k0_ChampionSlotReadyHand; ) {
-		if (((L1265_T_Thing = champ->_slots[L1266_i_SlotIndex]) != Thing::_none) && (_vm->_objectMan->f33_getIconIndex(L1265_T_Thing) == k195_IconIndicePotionEmptyFlask)) {
-			*potionThing = L1265_T_Thing;
-			return (Potion*)_vm->_dungeonMan->f156_getThingData(L1265_T_Thing);
-		}
-	}
-	return nullptr;
-}
-
-void MenuMan::f404_createEvent70_light(int16 lightPower, int16 ticks) {
-	TimelineEvent L1241_s_Event;
-
-	L1241_s_Event._type = k70_TMEventTypeLight;
-	L1241_s_Event._B._lightPower = lightPower;
-	M33_setMapAndTime(L1241_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + ticks);
-	L1241_s_Event._priority = 0;
-	_vm->_timeline->f238_addEventGetEventIndex(&L1241_s_Event);
-	_vm->_inventoryMan->f337_setDungeonViewPalette();
-}
-
-bool MenuMan::f403_isPartySpellOrFireShieldSuccessful(Champion* champ, bool spellShield, uint16 ticks, bool useMana) {
-	bool L1239_B_IsPartySpellOrFireShieldSuccessful;
-	TimelineEvent L1240_s_Event;
-
-
-	L1239_B_IsPartySpellOrFireShieldSuccessful = true;
-	if (useMana) {
-		if (champ->_currMana == 0) {
-			return false;
-		}
-		if (champ->_currMana < 4) {
-			ticks >>= 1;
-			champ->_currMana = 0;
-			L1239_B_IsPartySpellOrFireShieldSuccessful = false;
-		} else {
-			champ->_currMana -= 4;
-		}
-	}
-	L1240_s_Event._B._defense = ticks >> 5;
-	if (spellShield) {
-		L1240_s_Event._type = k77_TMEventTypeSpellShield;
-		if (_vm->_championMan->_g407_party._spellShieldDefense > 50) {
-			L1240_s_Event._B._defense >>= 2;
-		}
-		_vm->_championMan->_g407_party._spellShieldDefense += L1240_s_Event._B._defense;
-	} else {
-		L1240_s_Event._type = k78_TMEventTypeFireShield;
-		if (_vm->_championMan->_g407_party._fireShieldDefense > 50) {
-			L1240_s_Event._B._defense >>= 2;
-		}
-		_vm->_championMan->_g407_party._fireShieldDefense += L1240_s_Event._B._defense;
-	}
-	L1240_s_Event._priority = 0;
-	M33_setMapAndTime(L1240_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + ticks);
-	_vm->_timeline->f238_addEventGetEventIndex(&L1240_s_Event);
-	_vm->_timeline->f260_timelineRefreshAllChampionStatusBoxes();
-	return L1239_B_IsPartySpellOrFireShieldSuccessful;
-}
-
-void MenuMan::f397_drawAvailableSymbols(uint16 symbolStep) {
-	uint16 L1214_ui_Counter;
-	int16 L1215_i_X;
-	char L1216_c_Character;
-	char L1217_ac_String[2];
-
-	L1217_ac_String[1] = '\0';
-	L1216_c_Character = 96 + 6 * symbolStep;
-	L1215_i_X = 225;
-	for (L1214_ui_Counter = 0; L1214_ui_Counter < 6; L1214_ui_Counter++) {
-		L1217_ac_String[0] = L1216_c_Character++;
-		_vm->_textMan->f53_printToLogicalScreen(L1215_i_X += 14, 58, k4_ColorCyan, k0_ColorBlack, L1217_ac_String);
-	}
-}
-
-void MenuMan::f398_drawChampionSymbols(Champion* champ) {
-	uint16 L1218_ui_SymbolIndex;
-	int16 L1219_i_X;
-	uint16 L1220_ui_SymbolCount;
-	char L1221_ac_String[2];
-
-
-	L1220_ui_SymbolCount = strlen(champ->_symbols);
-	L1219_i_X = 232;
-	L1221_ac_String[1] = '\0';
-	for (L1218_ui_SymbolIndex = 0; L1218_ui_SymbolIndex < 4; L1218_ui_SymbolIndex++) {
-		if (L1218_ui_SymbolIndex >= L1220_ui_SymbolCount) {
-			L1221_ac_String[0] = ' ';
-		} else {
-			L1221_ac_String[0] = champ->_symbols[L1218_ui_SymbolIndex];
-		}
-		_vm->_textMan->f53_printToLogicalScreen(L1219_i_X += 9, 70, k4_ColorCyan, k0_ColorBlack, L1221_ac_String);
-	}
-}
-
-void MenuMan::f399_addChampionSymbol(int16 symbolIndex) {
-	static byte G0485_aauc_Graphic560_SymbolBaseManaCost[4][6] = {
-		{1, 2, 3, 4, 5, 6},   /* Power 1 */
-		{2, 3, 4, 5, 6, 7},   /* Power 2 */
-		{4, 5, 6, 7, 7, 9},   /* Power 3 */
-		{2, 2, 3, 4, 6, 7}}; /* Power 4 */
-	static byte G0486_auc_Graphic560_SymbolManaCostMultiplier[6] = {8, 12, 16, 20, 24, 28};
-
-	uint16 L1222_ui_SymbolStep;
-	uint16 L1223_ui_ManaCost;
-	uint16 L1224_ui_SymbolIndex;
-	Champion* L1225_ps_Champion;
-
-	L1225_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
-	L1222_ui_SymbolStep = L1225_ps_Champion->_symbolStep;
-	L1223_ui_ManaCost = G0485_aauc_Graphic560_SymbolBaseManaCost[L1222_ui_SymbolStep][symbolIndex];
-	if (L1222_ui_SymbolStep) {
-		L1223_ui_ManaCost = (L1223_ui_ManaCost * G0486_auc_Graphic560_SymbolManaCostMultiplier[L1224_ui_SymbolIndex = L1225_ps_Champion->_symbols[0] - 96]) >> 3;
-	}
-	if (L1223_ui_ManaCost <= L1225_ps_Champion->_currMana) {
-		L1225_ps_Champion->_currMana -= L1223_ui_ManaCost;
-		setFlag(L1225_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
-		L1225_ps_Champion->_symbols[L1222_ui_SymbolStep] = 96 + (L1222_ui_SymbolStep * 6) + symbolIndex;
-		L1225_ps_Champion->_symbols[L1222_ui_SymbolStep + 1] = '\0';
-		L1225_ps_Champion->_symbolStep = L1222_ui_SymbolStep = returnNextVal(L1222_ui_SymbolStep);
-		_vm->_eventMan->f78_showMouse();
-		f397_drawAvailableSymbols(L1222_ui_SymbolStep);
-		f398_drawChampionSymbols(L1225_ps_Champion);
-		_vm->_championMan->f292_drawChampionState(_vm->_championMan->_g514_magicCasterChampionIndex);
-		_vm->_eventMan->f77_hideMouse();
-	}
-}
-
-void MenuMan::f400_deleteChampionSymbol() {
-	int16 L1226_ui_SymbolStep;
-	Champion* L1228_ps_Champion;
-
-	L1228_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
-	if (!strlen(L1228_ps_Champion->_symbols)) {
-		return;
-	}
-	L1228_ps_Champion->_symbolStep = L1226_ui_SymbolStep = returnPrevVal(L1228_ps_Champion->_symbolStep);
-	L1228_ps_Champion->_symbols[L1226_ui_SymbolStep] = '\0';
-	_vm->_eventMan->f78_showMouse();
-	f397_drawAvailableSymbols(L1226_ui_SymbolStep);
-	f398_drawChampionSymbols(L1228_ps_Champion);
-	_vm->_eventMan->f77_hideMouse();
-}
-
-bool MenuMan::f391_didClickTriggerAction(int16 actionListIndex) {
-	uint16 L1196_ui_ChampionIndex;
-	uint16 L1197_ui_ActionIndex;
-	bool L1198_B_ClickTriggeredAction;
-	Champion* L1199_ps_Champion;
-
-
-	if (!_vm->_championMan->_g506_actingChampionOrdinal || (actionListIndex != -1 && (_g713_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone)))
-		return false;
-
-	L1199_ps_Champion = &_vm->_championMan->_gK71_champions[L1196_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)];
-	if (actionListIndex == -1) {
-		warning(false, "possible bug in f391_didClickTriggerAction");
-		// L1198_B_ClickTriggeredAction is set to -1 since booleans are stored in int16 in the original
-		L1198_B_ClickTriggeredAction = true;
-	} else {
-		L1197_ui_ActionIndex = _g713_actionList._actionIndices[actionListIndex];
-		L1199_ps_Champion->_actionDefense += g495_actionDefense[L1197_ui_ActionIndex]; /* BUG0_54 The defense modifier of an action is permanent.
-																									 Each action has an associated defense modifier value and a number of ticks while the champion cannot perform another action because the action icon is grayed out. If an action has a non zero defense modifier and a zero value for the number of ticks then the defense modifier is applied but it is never removed. This causes no issue in the original games because there are no actions in this case but it may occur in a version where data is customized. This statement should only be executed if the value for the action in G0491_auc_Graphic560_ActionDisabledTicks is not 0 otherwise the action is not disabled at the end of F0407_MENUS_IsActionPerformed and thus not enabled later in F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction where the defense modifier is also removed */
-		setFlag(L1199_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
-		L1198_B_ClickTriggeredAction = f407_isActionPerformed(L1196_ui_ChampionIndex, L1197_ui_ActionIndex);
-		L1199_ps_Champion->_actionIndex = (ChampionAction)L1197_ui_ActionIndex;
-	}
-	f388_clearActingChampion();
-	return L1198_B_ClickTriggeredAction;
-}
-
-bool MenuMan::f407_isActionPerformed(uint16 champIndex, int16 actionIndex) {
-	static unsigned char G0491_auc_Graphic560_ActionDisabledTicks[44] = {
-		0,  /* N */
-		6,  /* BLOCK */
-		8,  /* CHOP */
-		0,  /* X */
-		6,  /* BLOW HORN */
-		3,  /* FLIP */
-		1,  /* PUNCH */
-		5,  /* KICK */
-		3,  /* WAR CRY */
-		5,  /* STAB */
-		35, /* CLIMB DOWN */
-		20, /* FREEZE LIFE */
-		4,  /* HIT */
-		6,  /* SWING */
-		10, /* STAB */
-		16, /* THRUST */
-		2,  /* JAB */
-		18, /* PARRY */
-		8,  /* HACK */
-		30, /* BERZERK */
-		42, /* FIREBALL */
-		31, /* DISPELL */
-		10, /* CONFUSE */
-		38, /* LIGHTNING */
-		9,  /* DISRUPT */
-		20, /* MELEE */
-		10, /* X */
-		16, /* INVOKE */
-		4,  /* SLASH */
-		12, /* CLEAVE */
-		20, /* BASH */
-		7,  /* STUN */
-		14, /* SHOOT */
-		30, /* SPELLSHIELD */
-		35, /* FIRESHIELD */
-		2,  /* FLUXCAGE */
-		19, /* HEAL */
-		9,  /* CALM */
-		10, /* LIGHT */
-		15, /* WINDOW */
-		22, /* SPIT */
-		10, /* BRANDISH */
-		0,  /* THROW */
-		2}; /* FUSE */
-	static unsigned char G0494_auc_Graphic560_ActionStamina[44] = {
-		0,  /* N */
-		4,  /* BLOCK */
-		10, /* CHOP */
-		0,  /* X */
-		1,  /* BLOW HORN */
-		0,  /* FLIP */
-		1,  /* PUNCH */
-		3,  /* KICK */
-		1,  /* WAR CRY */
-		3,  /* STAB */
-		40, /* CLIMB DOWN */
-		3,  /* FREEZE LIFE */
-		3,  /* HIT */
-		2,  /* SWING */
-		4,  /* STAB */
-		17, /* THRUST */
-		3,  /* JAB */
-		1,  /* PARRY */
-		6,  /* HACK */
-		40, /* BERZERK */
-		5,  /* FIREBALL */
-		2,  /* DISPELL */
-		2,  /* CONFUSE */
-		4,  /* LIGHTNING */
-		5,  /* DISRUPT */
-		25, /* MELEE */
-		1,  /* X */
-		2,  /* INVOKE */
-		2,  /* SLASH */
-		10, /* CLEAVE */
-		9,  /* BASH */
-		2,  /* STUN */
-		3,  /* SHOOT */
-		1,  /* SPELLSHIELD */
-		2,  /* FIRESHIELD */
-		6,  /* FLUXCAGE */
-		1,  /* HEAL */
-		1,  /* CALM */
-		3,  /* LIGHT */
-		2,  /* WINDOW */
-		3,  /* SPIT */
-		2,  /* BRANDISH */
-		0,  /* THROW */
-		2}; /* FUSE */
-	unsigned char G0497_auc_Graphic560_ActionExperienceGain[44] = {
-		0,  /* N */
-		8,  /* BLOCK */
-		10, /* CHOP */
-		0,  /* X */
-		0,  /* BLOW HORN */
-		0,  /* FLIP */
-		8,  /* PUNCH */
-		13, /* KICK */
-		7,  /* WAR CRY */
-		15, /* STAB */
-		15, /* CLIMB DOWN */
-		22, /* FREEZE LIFE */
-		10, /* HIT */
-		6,  /* SWING */
-		12, /* STAB */
-		19, /* THRUST */
-		11, /* JAB */
-		17, /* PARRY */
-		9,  /* HACK */
-		40, /* BERZERK */
-		35, /* FIREBALL */
-		25, /* DISPELL */
-		0,  /* CONFUSE */
-		30, /* LIGHTNING */
-		10, /* DISRUPT */
-		24, /* MELEE */
-		0,  /* X */
-		25, /* INVOKE */
-		9,  /* SLASH */
-		12, /* CLEAVE */
-		11, /* BASH */
-		10, /* STUN */
-		20, /* SHOOT Atari ST Versions 1.0 1987-12-08 1987-12-11: 9 */
-		20, /* SPELLSHIELD */
-		20, /* FIRESHIELD */
-		12, /* FLUXCAGE */
-		0,  /* HEAL */
-		0,  /* CALM */
-		20, /* LIGHT */
-		30, /* WINDOW */
-		25, /* SPIT */
-		0,  /* BRANDISH */
-		5,  /* THROW */
-		1}; /* FUSE */
-	uint16 L1244_ui_Multiple;
-#define AL1244_ui_TargetSquare  L1244_ui_Multiple
-#define AL1244_ui_HealingAmount L1244_ui_Multiple
-#define AL1244_ui_ManaCost      L1244_ui_Multiple
-	int16 L1245_i_Multiple;
-#define AL1245_T_ExplosionThing  L1245_i_Multiple
-#define AL1245_B_ActionPerformed L1245_i_Multiple
-	int16 L1246_i_Multiple;
-#define AL1246_i_RequiredManaAmount    L1246_i_Multiple
-#define AL1246_i_ActionHandWeaponClass L1246_i_Multiple
-#define AL1246_i_StepEnergy            L1246_i_Multiple
-#define AL1246_i_HealingCapability     L1246_i_Multiple
-#define AL1246_i_Ticks                 L1246_i_Multiple
-	Champion* L1247_ps_Champion;
-	Weapon* L1248_ps_Weapon;
-	uint16 L1249_ui_ActionDisabledTicks;
-	int16 L1250_i_Multiple;
-#define AL1250_i_KineticEnergy        L1250_i_Multiple
-#define AL1250_i_ReadyHandWeaponClass L1250_i_Multiple
-#define AL1250_i_MissingHealth        L1250_i_Multiple
-#define AL1250_i_HealingAmount        L1250_i_Multiple
-	int16 L1251_i_MapX;
-	int16 L1252_i_MapY;
-	int16 L1253_i_ActionStamina;
-	int16 L1254_i_ActionSkillIndex;
-	int16 L1255_i_ActionExperienceGain;
-	WeaponInfo* L1256_ps_WeaponInfoActionHand;
-	WeaponInfo* L1257_ps_WeaponInfoReadyHand;
-	TimelineEvent L1258_s_Event;
-
-
-	if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
-		return false;
-	}
-	L1247_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
-	L1248_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L1247_ps_Champion->_slots[k1_ChampionSlotActionHand]);
-	if (!L1247_ps_Champion->_currHealth) {
-		return false;
-	}
-	L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
-	L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
-	L1251_i_MapX += _vm->_dirIntoStepCountEast[L1247_ps_Champion->_dir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[L1247_ps_Champion->_dir];
-	_g517_actionTargetGroupThing = _vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY);
-	L1249_ui_ActionDisabledTicks = G0491_auc_Graphic560_ActionDisabledTicks[actionIndex];
-	L1254_i_ActionSkillIndex = g496_ActionSkillIndex[actionIndex];
-	L1253_i_ActionStamina = G0494_auc_Graphic560_ActionStamina[actionIndex] + _vm->getRandomNumber(2);
-	L1255_i_ActionExperienceGain = G0497_auc_Graphic560_ActionExperienceGain[actionIndex];
-	AL1244_ui_TargetSquare = _vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).toByte();
-	AL1245_B_ActionPerformed = true;
-	if (((L1254_i_ActionSkillIndex >= k16_ChampionSkillFire) && (L1254_i_ActionSkillIndex <= k19_ChampionSkillWater)) || (L1254_i_ActionSkillIndex == k3_ChampionSkillWizard)) {
-		AL1246_i_RequiredManaAmount = 7 - MIN((uint16)6, _vm->_championMan->f303_getSkillLevel(champIndex, L1254_i_ActionSkillIndex));
-	}
-	switch (actionIndex) {
-	case k23_ChampionActionLightning:
-		AL1250_i_KineticEnergy = 180;
-		AL1245_T_ExplosionThing = Thing::_explLightningBolt.toUint16();
-		goto T0407014;
-	case k21_ChampionActionDispel:
-		AL1250_i_KineticEnergy = 150;
-		AL1245_T_ExplosionThing = Thing::_explHarmNonMaterial.toUint16();
-		goto T0407014;
-	case k20_ChampionActionFireball:
-		AL1250_i_KineticEnergy = 150;
-		goto T0407013;
-	case k40_ChampionActionSpit:
-		AL1250_i_KineticEnergy = 250;
-T0407013:
-		AL1245_T_ExplosionThing = Thing::_explFireBall.toUint16();
-T0407014:
-		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
-		if (L1247_ps_Champion->_currMana < AL1246_i_RequiredManaAmount) {
-			AL1250_i_KineticEnergy = MAX(2, L1247_ps_Champion->_currMana * AL1250_i_KineticEnergy / AL1246_i_RequiredManaAmount);
-			AL1246_i_RequiredManaAmount = L1247_ps_Champion->_currMana;
-		}
-		if (!(AL1245_B_ActionPerformed = _vm->_championMan->f327_isProjectileSpellCast(champIndex, Thing(AL1245_T_ExplosionThing), AL1250_i_KineticEnergy, AL1246_i_RequiredManaAmount))) {
-			L1255_i_ActionExperienceGain >>= 1;
-		}
-		f405_decrementCharges(L1247_ps_Champion);
-		break;
-	case k30_ChampionActionBash:
-	case k18_ChampionActionHack:
-	case k19_ChampionActionBerzerk:
-	case k7_ChampionActionKick:
-	case k13_ChampionActionSwing:
-	case k2_ChampionActionChop:
-		if ((Square(AL1244_ui_TargetSquare).getType() == k4_DoorElemType) && (Square(AL1244_ui_TargetSquare).getDoorState() == k4_doorState_CLOSED)) {
-			_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
-			L1249_ui_ActionDisabledTicks = 6;
-			_vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
-			_vm->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater);
-			break;
-		}
-	case k24_ChampionActionDisrupt:
-	case k16_ChampionActionJab:
-	case k17_ChampionActionParry:
-	case k14_ChampionActionStab_C014:
-	case k9_ChampionActionStab_C009:
-	case k31_ChampionActionStun:
-	case k15_ChampionActionThrust:
-	case k25_ChampionActionMelee:
-	case k28_ChampionActionSlash:
-	case k29_ChampionActionCleave:
-	case k6_ChampionActionPunch:
-		if (!(AL1245_B_ActionPerformed = f402_isMeleeActionPerformed(champIndex, L1247_ps_Champion, actionIndex, L1251_i_MapX, L1252_i_MapY, L1254_i_ActionSkillIndex))) {
-			L1255_i_ActionExperienceGain >>= 1;
-			L1249_ui_ActionDisabledTicks >>= 1;
-		}
-		break;
-	case k22_ChampionActionConfuse:
-		f405_decrementCharges(L1247_ps_Champion);
-	case k8_ChampionActionWarCry:
-	case k37_ChampionActionCalm:
-	case k41_ChampionActionBrandish:
-	case k4_ChampionActionBlowHorn:
-		if (actionIndex == k8_ChampionActionWarCry) {
-			_vm->f064_SOUND_RequestPlay_CPSD(k28_soundWAR_CRY, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
-		}
-		if (actionIndex == k4_ChampionActionBlowHorn) {
-			_vm->f064_SOUND_RequestPlay_CPSD(k25_soundBLOW_HORN, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
-		}
-		AL1245_B_ActionPerformed = f401_isGroupFrightenedByAction(champIndex, actionIndex, L1251_i_MapX, L1252_i_MapY);
-		break;
-	case k32_ChampionActionShoot:
-		if (Thing(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]).getType() != k5_WeaponThingType)
-			goto T0407032;
-		L1256_ps_WeaponInfoActionHand = &g238_WeaponInfo[L1248_ps_Weapon->getType()];
-		L1257_ps_WeaponInfoReadyHand = _vm->_dungeonMan->f158_getWeaponInfo(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]);
-		AL1246_i_ActionHandWeaponClass = L1256_ps_WeaponInfoActionHand->_class;
-		AL1250_i_ReadyHandWeaponClass = L1257_ps_WeaponInfoReadyHand->_class;
-		if ((AL1246_i_ActionHandWeaponClass >= k16_WeaponClassFirstBow) && (AL1246_i_ActionHandWeaponClass <= k31_WeaponClassLastBow)) {
-			if (AL1250_i_ReadyHandWeaponClass != k10_WeaponClassBowAmmunition)
-				goto T0407032;
-			AL1246_i_StepEnergy -= k16_WeaponClassFirstBow;
-		} else {
-			if ((AL1246_i_ActionHandWeaponClass >= k32_WeaponClassFirstSling) && (AL1246_i_ActionHandWeaponClass <= k47_WeaponClassLastSling)) {
-				if (AL1250_i_ReadyHandWeaponClass != k11_WeaponClassSlingAmmunition) {
-T0407032:
-					_g513_actionDamage = kM2_damageNoAmmunition;
-					L1255_i_ActionExperienceGain = 0;
-					AL1245_B_ActionPerformed = false;
-					break;
-				}
-				AL1246_i_StepEnergy -= k32_WeaponClassFirstSling;
-			}
-		}
-		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
-		{ // so gotos won't skip init
-			Thing AL1250_T_Object = _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
-			_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
-			_vm->_championMan->f326_championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->f303_getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy);
-		}
-		break;
-	case k5_ChampionActionFlip:
-		// TODO: localization
-		if (_vm->getRandomNumber(2)) {
-			f381_printMessageAfterReplacements("IT COMES UP HEADS.");
-		} else {
-			f381_printMessageAfterReplacements("IT COMES UP TAILS.");
-		}
-		break;
-	case k33_ChampionActionSpellshield:
-	case k34_ChampionActionFireshield:
-		if (!f403_isPartySpellOrFireShieldSuccessful(L1247_ps_Champion, actionIndex == k33_ChampionActionSpellshield, 280, true)) {
-			L1255_i_ActionExperienceGain >>= 2;
-			L1249_ui_ActionDisabledTicks >>= 1;
-		} else {
-			f405_decrementCharges(L1247_ps_Champion);
-		}
-		break;
-	case k27_ChampionActionInvoke:
-		AL1250_i_KineticEnergy = _vm->getRandomNumber(128) + 100;
-		switch (_vm->getRandomNumber(6)) {
-		case 0:
-			AL1245_T_ExplosionThing = Thing::_explPoisonBolt.toUint16();
-			goto T0407014;
-		case 1:
-			AL1245_T_ExplosionThing = Thing::_explPoisonCloud.toUint16();
-			goto T0407014;
-		case 2:
-			AL1245_T_ExplosionThing = Thing::_explHarmNonMaterial.toUint16();
-			goto T0407014;
-		default:
-			goto T0407013;
-		}
-	case k35_ChampionActionFluxcage:
-		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
-		_vm->_groupMan->f224_fluxCageAction(L1251_i_MapX, L1252_i_MapY);
-		break;
-	case k43_ChampionActionFuse:
-		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
-		L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
-		L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
-		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
-		_vm->_groupMan->f225_fuseAction(L1251_i_MapX, L1252_i_MapY);
-		break;
-	case k36_ChampionActionHeal:
-		/* CHANGE2_17_IMPROVEMENT Heal action is much more effective
-		Heal cycles occur as long as the champion has missing health and enough mana. Cycle count = Min(Current Mana / 2, Missing health / Min(10, Heal skill level))
-		Healing amount is Min(Missing health, Min(10, Heal skill level)) * heal cycle count
-		Mana cost is 2 * heal cycle count
-		Experience gain is 2 + 2 * heal cycle count */
-		if (((AL1250_i_MissingHealth = L1247_ps_Champion->_maxHealth - L1247_ps_Champion->_currHealth) > 0) && L1247_ps_Champion->_currMana) {
-			AL1246_i_HealingCapability = MIN((uint16)10, _vm->_championMan->f303_getSkillLevel(champIndex, k13_ChampionSkillHeal));
-			L1255_i_ActionExperienceGain = 2;
-			do {
-				AL1244_ui_HealingAmount = MIN(AL1250_i_MissingHealth, AL1246_i_HealingCapability);
-				L1247_ps_Champion->_currHealth += AL1244_ui_HealingAmount;
-				L1255_i_ActionExperienceGain += 2;
-			} while (((L1247_ps_Champion->_currMana = L1247_ps_Champion->_currMana - 2) > 0) && (AL1250_i_MissingHealth = AL1250_i_MissingHealth - AL1244_ui_HealingAmount));
-			if (L1247_ps_Champion->_currMana < 0) {
-				L1247_ps_Champion->_currMana = 0;
-			}
-			setFlag(L1247_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
-			AL1245_B_ActionPerformed = true;
-		}
-		break;
-	case k39_ChampionActionWindow:
-		AL1246_i_Ticks = _vm->getRandomNumber(_vm->_championMan->f303_getSkillLevel(champIndex, L1254_i_ActionSkillIndex) + 8) + 5;
-		L1258_s_Event._priority = 0;
-		L1258_s_Event._type = k73_TMEventTypeThievesEye;
-		M33_setMapAndTime(L1258_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + AL1246_i_Ticks);
-		_vm->_timeline->f238_addEventGetEventIndex(&L1258_s_Event);
-		_vm->_championMan->_g407_party._event73Count_ThievesEye++;
-		goto T0407076;
-	case k10_ChampionActionClimbDown:
-		L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
-		L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
-		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
-		/* CHANGE6_00_FIX The presence of a group over the pit is checked so that you cannot climb down a pit with the rope if there is a group levitating over it */
-		if ((_vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_ElementTypePit) && (_vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY) == Thing::_endOfList)) {
-			/* BUG0_77 The party moves forward when using the rope in front of a closed pit. The engine does not check whether the pit is open before moving the party over the pit. This is not consistent with the behavior when using the rope in front of a corridor where nothing happens */
-			_vm->_moveSens->_g402_useRopeToClimbDownPit = true;
-			_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1251_i_MapX, L1252_i_MapY);
-			_vm->_moveSens->_g402_useRopeToClimbDownPit = false;
-		} else {
-			L1249_ui_ActionDisabledTicks = 0;
-		}
-		break;
-	case k11_ChampionActionFreezeLife:
-		if (L1248_ps_Weapon->getType() == k42_JunkTypeMagicalBoxBlue) {
-			AL1246_i_Ticks = 30;
-			goto T0407071;
-		}
-		if (L1248_ps_Weapon->getType() == k43_JunkTypeMagicalBoxGreen) {
-			AL1246_i_Ticks = 125;
-T0407071:
-			_vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k1_ChampionSlotActionHand);
-			L1248_ps_Weapon->setNextThing(Thing::_none);
-		} else {
-			AL1246_i_Ticks = 70;
-			f405_decrementCharges(L1247_ps_Champion);
-		}
-		_vm->_championMan->_g407_party._freezeLifeTicks = MIN(200, _vm->_championMan->_g407_party._freezeLifeTicks + AL1246_i_Ticks);
-		break;
-	case k38_ChampionActionLight:
-		_vm->_championMan->_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2];
-		f404_createEvent70_light(-2, 2500);
-T0407076:
-		f405_decrementCharges(L1247_ps_Champion);
-		break;
-	case k42_ChampionActionThrow:
-		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
-		if (AL1245_B_ActionPerformed = _vm->_championMan->f328_isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_g308_partyDir)) || (L1247_ps_Champion->_cell == returnOppositeDir(_vm->_dungeonMan->_g308_partyDir)))) {
-			_vm->_timeline->_g370_events[L1247_ps_Champion->_enableActionEventIndex]._B._slotOrdinal = _vm->M0_indexToOrdinal(k1_ChampionSlotActionHand);
-		}
-	}
-	if (L1249_ui_ActionDisabledTicks) {
-		_vm->_championMan->f330_disableAction(champIndex, L1249_ui_ActionDisabledTicks);
-	}
-	if (L1253_i_ActionStamina) {
-		_vm->_championMan->f325_decrementStamina(champIndex, L1253_i_ActionStamina);
-	}
-	if (L1255_i_ActionExperienceGain) {
-		_vm->_championMan->f304_addSkillExperience(champIndex, L1254_i_ActionSkillIndex, L1255_i_ActionExperienceGain);
-	}
-	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
-	return AL1245_B_ActionPerformed;
-}
-
-void MenuMan::f406_setChampionDirectionToPartyDirection(Champion* champ) {
-	if (champ->_dir != _vm->_dungeonMan->_g308_partyDir) {
-		champ->_dir = _vm->_dungeonMan->_g308_partyDir;
-		setFlag(champ->_attributes, k0x0400_ChampionAttributeIcon);
-	}
-}
-
-void MenuMan::f405_decrementCharges(Champion* champ) {
-	Thing L1242_T_Thing;
-	Junk* L1243_ps_Junk;
-
-	L1243_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1242_T_Thing = champ->_slots[k1_ChampionSlotActionHand]);
-	switch (L1242_T_Thing.getType()) {
-	case k5_WeaponThingType:
-		if (((Weapon*)L1243_ps_Junk)->getChargeCount()) {
-			((Weapon*)L1243_ps_Junk)->setChargeCount(((Weapon*)L1243_ps_Junk)->getChargeCount() - 1);
-		}
-		break;
-	case k6_ArmourThingType:
-		if (((Armour*)L1243_ps_Junk)->getChargeCount()) {
-			((Armour*)L1243_ps_Junk)->setChargeCount(((Armour*)L1243_ps_Junk)->getChargeCount() - 1);
-		}
-		break;
-	case k10_JunkThingType:
-		if (L1243_ps_Junk->getChargeCount()) {
-			L1243_ps_Junk->setChargeCount(L1243_ps_Junk->getChargeCount() - 1);
-		}
-	}
-	_vm->_championMan->f296_drawChangedObjectIcons();
-}
-
-bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int16 actionIndex, int16 targetMapX, int16 targetMapY, int16 skillIndex) {
-	static unsigned char G0492_auc_Graphic560_ActionDamageFactor[44] = {
-		0,  /* N */
-		15, /* BLOCK */
-		48, /* CHOP */
-		0,  /* X */
-		0,  /* BLOW HORN */
-		0,  /* FLIP */
-		32, /* PUNCH */
-		48, /* KICK */
-		0,  /* WAR CRY */
-		48, /* STAB */
-		0,  /* CLIMB DOWN */
-		0,  /* FREEZE LIFE */
-		20, /* HIT */
-		16, /* SWING */
-		60, /* STAB */
-		66, /* THRUST */
-		8,  /* JAB */
-		8,  /* PARRY */
-		25, /* HACK */
-		96, /* BERZERK */
-		0,  /* FIREBALL */
-		0,  /* DISPELL */
-		0,  /* CONFUSE */
-		0,  /* LIGHTNING */
-		55, /* DISRUPT */
-		60, /* MELEE */
-		0,  /* X */
-		0,  /* INVOKE */
-		16, /* SLASH */
-		48, /* CLEAVE */
-		50, /* BASH */
-		16, /* STUN */
-		0,  /* SHOOT */
-		0,  /* SPELLSHIELD */
-		0,  /* FIRESHIELD */
-		0,  /* FLUXCAGE */
-		0,  /* HEAL */
-		0,  /* CALM */
-		0,  /* LIGHT */
-		0,  /* WINDOW */
-		0,  /* SPIT */
-		0,  /* BRANDISH */
-		0,  /* THROW */
-		0}; /* FUSE */
-	static unsigned char G0493_auc_Graphic560_ActionHitProbability[44] = {
-		0,  /* N */
-		22, /* BLOCK */
-		48, /* CHOP */
-		0,  /* X */
-		0,  /* BLOW HORN */
-		0,  /* FLIP */
-		38, /* PUNCH */
-		28, /* KICK */
-		0,  /* WAR CRY */
-		30, /* STAB */
-		0,  /* CLIMB DOWN */
-		0,  /* FREEZE LIFE */
-		20, /* HIT */
-		32, /* SWING */
-		42, /* STAB */
-		57, /* THRUST */
-		70, /* JAB */
-		18, /* PARRY */
-		27, /* HACK */
-		46, /* BERZERK */
-		0,  /* FIREBALL */
-		0,  /* DISPELL */
-		0,  /* CONFUSE */
-		0,  /* LIGHTNING */
-		46, /* DISRUPT */
-		64, /* MELEE */
-		0,  /* X */
-		0,  /* INVOKE */
-		26, /* SLASH */
-		40, /* CLEAVE */
-		32, /* BASH */
-		50, /* STUN */
-		0,  /* SHOOT */
-		0,  /* SPELLSHIELD */
-		0,  /* FIRESHIELD */
-		0,  /* FLUXCAGE */
-		0,  /* HEAL */
-		0,  /* CALM */
-		0,  /* LIGHT */
-		0,  /* WINDOW */
-		0,  /* SPIT */
-		0,  /* BRANDISH */
-		0,  /* THROW */
-		0}; /* FUSE */
-
-	uint16 L1236_ui_Multiple;
-#define AL1236_ui_ChampionCell       L1236_ui_Multiple
-#define AL1236_ui_ActionDamageFactor L1236_ui_Multiple
-	uint16 L1237_ui_Multiple;
-#define AL1237_ui_Direction            L1237_ui_Multiple
-#define AL1237_ui_CellDelta            L1237_ui_Multiple
-#define AL1237_ui_ActionHitProbability L1237_ui_Multiple
-	int16 L1238_i_CreatureOrdinal;
-
-	_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
-	if (_g517_actionTargetGroupThing == Thing::_endOfList)
-		goto T0402010;
-	if (L1238_i_CreatureOrdinal = _vm->_groupMan->f177_getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, AL1236_ui_ChampionCell = champ->_cell)) {
-		switch (M21_normalizeModulo4(AL1236_ui_ChampionCell + 4 - champ->_dir)) {
-		case k2_ViewCellBackRight: /* Champion is on the back right of the square and tries to attack a creature in the front right of its square */
-			AL1237_ui_CellDelta = 3;
-			goto T0402005;
-		case k3_ViewCellBackLeft: /* Champion is on the back left of the square and tries to attack a creature in the front left of its square */
-			AL1237_ui_CellDelta = 1;
-T0402005: /* Check if there is another champion in front */
-			if (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL1236_ui_ChampionCell + AL1237_ui_CellDelta)) != kM1_ChampionNone) {
-				_g513_actionDamage = kM1_damageCantReach;
-				goto T0402010;
-			}
-		}
-		if ((actionIndex == k24_ChampionActionDisrupt) && !getFlag(_vm->_dungeonMan->f144_getCreatureAttributes(_g517_actionTargetGroupThing), k0x0040_MaskCreatureInfo_nonMaterial))
-			goto T0402010;
-		AL1237_ui_ActionHitProbability = G0493_auc_Graphic560_ActionHitProbability[actionIndex];
-		AL1236_ui_ActionDamageFactor = G0492_auc_Graphic560_ActionDamageFactor[actionIndex];
-		if ((_vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
-			setFlag(AL1237_ui_ActionHitProbability, k0x8000_hitNonMaterialCreatures);
-		}
-		_g513_actionDamage = _vm->_groupMan->f231_getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing), _vm->M1_ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
-		return true;
-	}
-T0402010:
-	return false;
-}
-
-bool MenuMan::f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, int16 mapX, int16 mapY) {
-	int16 L1229_i_FrightAmount = 0;
-	uint16 L1230_ui_FearResistance;
-	uint16 L1231_ui_Experience = 0;
-	bool L1232_B_IsGroupFrightenedByAction;
-	Group* L1233_ps_Group;
-	CreatureInfo* L1234_ps_CreatureInfo;
-	ActiveGroup* L1235_ps_ActiveGroup;
-
-
-	L1232_B_IsGroupFrightenedByAction = false;
-	if (_g517_actionTargetGroupThing == Thing::_endOfList)
-		goto T0401016;
-	switch (actionIndex) {
-	case k8_ChampionActionWarCry:
-		L1229_i_FrightAmount = 3;
-		L1231_ui_Experience = 12; /* War Cry gives experience in priest skill k14_ChampionSkillInfluence below. The War Cry action also has an experience gain of 7 defined in G0497_auc_Graphic560_ActionExperienceGain in the same skill (versions 1.1 and below) or in the fighter skill k7_ChampionSkillParry (versions 1.2 and above). In versions 1.2 and above, this is the only action that gives experience in two skills */
-		break;
-	case k37_ChampionActionCalm:
-		L1229_i_FrightAmount = 7;
-		L1231_ui_Experience = 35;
-		break;
-	case k41_ChampionActionBrandish:
-		L1229_i_FrightAmount = 6;
-		L1231_ui_Experience = 30;
-		break;
-	case k4_ChampionActionBlowHorn:
-		L1229_i_FrightAmount = 6;
-		L1231_ui_Experience = 20;
-		break;
-	case k22_ChampionActionConfuse:
-		L1229_i_FrightAmount = 12;
-		L1231_ui_Experience = 45;
-	}
-	L1229_i_FrightAmount += _vm->_championMan->f303_getSkillLevel(champIndex, k14_ChampionSkillInfluence);
-	L1233_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing);
-	L1234_ps_CreatureInfo = &g243_CreatureInfo[L1233_ps_Group->_type];
-	if (((L1230_ui_FearResistance = L1234_ps_CreatureInfo->M57_getFearResistance()) > _vm->getRandomNumber(L1229_i_FrightAmount)) || (L1230_ui_FearResistance == k15_immuneToFear)) {
-		L1231_ui_Experience >>= 1;
-	} else {
-		L1235_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[L1233_ps_Group->getActiveGroupIndex()];
-		if (L1233_ps_Group->getBehaviour() == k6_behavior_ATTACK) {
-			_vm->_groupMan->f182_stopAttacking(L1235_ps_ActiveGroup, mapX, mapY);
-			_vm->_groupMan->f180_startWanedring(mapX, mapY);
-		}
-		L1233_ps_Group->setBehaviour(k5_behavior_FLEE);
-		L1235_ps_ActiveGroup->_delayFleeingFromTarget = ((16 - L1230_ui_FearResistance) << 2) / L1234_ps_CreatureInfo->_movementTicks;
-		L1232_B_IsGroupFrightenedByAction = true;
-	}
-	_vm->_championMan->f304_addSkillExperience(champIndex, k14_ChampionSkillInfluence, L1231_ui_Experience);
-T0401016:
-	return L1232_B_IsGroupFrightenedByAction;
-}
-
-void MenuMan::f381_printMessageAfterReplacements(char* str) {
-	char* L1164_pc_Character;
-	char* L1165_pc_ReplacementString;
-	char L1166_ac_OutputString[128];
-
-
-	L1164_pc_Character = L1166_ac_OutputString;
-	*L1164_pc_Character++ = '\n'; /* New line */
-	do {
-		if (*str == '@') {
-			str++;
-			if (*(L1164_pc_Character - 1) != '\n') { /* New line */
-				*L1164_pc_Character++ = ' ';
-			}
-			switch (*str) {
-			case 'p': /* '@p' in the source string is replaced by the champion name followed by a space */
-				L1165_pc_ReplacementString = _vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)]._name;
-			}
-			*L1164_pc_Character = '\0';
-			strcat(L1166_ac_OutputString, L1165_pc_ReplacementString);
-			L1164_pc_Character += strlen(L1165_pc_ReplacementString);
-			*L1164_pc_Character++ = ' ';
-		} else {
-			*L1164_pc_Character++ = *str;
-		}
-	} while (*str++);
-	*L1164_pc_Character = '\0';
-	if (L1166_ac_OutputString[1]) { /* If the string is not empty (the first character is a new line \n) */
-		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, L1166_ac_OutputString);
-	}
-}
-
-void MenuMan::f389_processCommands116To119_setActingChampion(uint16 champIndex) {
-	static ActionSet G0489_as_Graphic560_ActionSets[44] = {
-		/* { ActionIndices[0], ActionIndices[1], ActionIndices[2], ActionProperties[0], ActionProperties[1], Useless } */
-		ActionSet(255, 255, 255, 0x00, 0x00),
-		ActionSet(27,  43,  35, 0x00, 0x00),
-		ActionSet(6,   7,   8, 0x00, 0x00),
-		ActionSet(0,   0,   0, 0x00, 0x00),
-		ActionSet(0,   0,   0, 0x00, 0x00),
-		ActionSet(13, 255, 255, 0x00, 0x00),
-		ActionSet(13,  20, 255, 0x87, 0x00),
-		ActionSet(13,  23, 255, 0x83, 0x00),
-		ActionSet(28,  41,  22, 0x02, 0x83),
-		ActionSet(16,   2,  23, 0x00, 0x84),
-		ActionSet(2,  25,  20, 0x02, 0x86),
-		ActionSet(17,  41,  34, 0x03, 0x05),
-		ActionSet(42,   9,  28, 0x00, 0x02),
-		ActionSet(13,  17,   2, 0x02, 0x03),
-		ActionSet(16,  17,  15, 0x01, 0x05),
-		ActionSet(28,  17,  25, 0x01, 0x05),
-		ActionSet(2,  25,  15, 0x05, 0x06),
-		ActionSet(9,   2,  29, 0x02, 0x05),
-		ActionSet(16,  29,  24, 0x02, 0x04),
-		ActionSet(13,  15,  19, 0x05, 0x07),
-		ActionSet(13,   2,  25, 0x00, 0x05),
-		ActionSet(2,  29,  19, 0x03, 0x08),
-		ActionSet(13,  30,  31, 0x02, 0x04),
-		ActionSet(13,  31,  25, 0x03, 0x06),
-		ActionSet(42,  30, 255, 0x00, 0x00),
-		ActionSet(0,   0,   0, 0x00, 0x00),
-		ActionSet(42,   9, 255, 0x00, 0x00),
-		ActionSet(32, 255, 255, 0x00, 0x00),
-		ActionSet(37,  33,  36, 0x82, 0x03),
-		ActionSet(37,  33,  34, 0x83, 0x84),
-		ActionSet(17,  38,  21, 0x80, 0x83),
-		ActionSet(13,  21,  34, 0x83, 0x84),
-		ActionSet(36,  37,  41, 0x02, 0x03),
-		ActionSet(13,  23,  39, 0x82, 0x84),
-		ActionSet(13,  17,  40, 0x00, 0x83),
-		ActionSet(17,  36,  38, 0x03, 0x84),
-		ActionSet(4, 255, 255, 0x00, 0x00),
-		ActionSet(5, 255, 255, 0x00, 0x00),
-		ActionSet(11, 255, 255, 0x00, 0x00),
-		ActionSet(10, 255, 255, 0x00, 0x00),
-		ActionSet(42,   9, 255, 0x00, 0x00),
-		ActionSet(1,  12, 255, 0x02, 0x00),
-		ActionSet(42, 255, 255, 0x00, 0x00),
-		ActionSet(6,  11, 255, 0x80, 0x00)};
-	uint16 L1188_ui_ActionSetIndex;
-	Thing L1189_T_Thing;
-	Champion* L1190_ps_Champion;
-	ActionSet* L1191_ps_ActionSet;
-
-
-	L1190_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
-	if (getFlag(L1190_ps_Champion->_attributes, k0x0008_ChampionAttributeDisableAction) || !L1190_ps_Champion->_currHealth) {
-		return;
-	}
-	if ((L1189_T_Thing = L1190_ps_Champion->_slots[k1_ChampionSlotActionHand]) == Thing::_none) {
-		L1188_ui_ActionSetIndex = 2; /* Actions Punck, Kick and War Cry */
-	} else {
-		if ((L1188_ui_ActionSetIndex = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1189_T_Thing)]._actionSetIndex) == 0) {
-			return;
-		}
-	}
-	L1191_ps_ActionSet = &G0489_as_Graphic560_ActionSets[L1188_ui_ActionSetIndex];
-	_vm->_championMan->_g506_actingChampionOrdinal = _vm->M0_indexToOrdinal(champIndex);
-	f383_setActionList(L1191_ps_ActionSet);
-	_g509_actionAreaContainsIcons = false;
-	setFlag(L1190_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand);
-	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
-	f387_drawActionArea();
-	f387_drawActionArea();
-}
-
-void MenuMan::f383_setActionList(ActionSet* actionSet) {
-
-#define k0x0080_actionRequiresCharge 0x0080 // @ MASK0x0080_ACTION_REQUIRES_CHARGE 
-
-	uint16 L1169_ui_ActionListIndex;
-	uint16 L1170_ui_NextAvailableActionListIndex;
-	uint16 L1171_ui_ActionIndex;
-	uint16 L1172_ui_MinimumSkillLevel;
-
-	_g713_actionList._actionIndices[0] = (ChampionAction)actionSet->_actionIndices[0];
-	_g713_actionList._minimumSkillLevel[0] = 1;
-	L1170_ui_NextAvailableActionListIndex = 1;
-	for (L1169_ui_ActionListIndex = 1; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) {
-		if ((L1171_ui_ActionIndex = actionSet->_actionIndices[L1169_ui_ActionListIndex]) == k255_ChampionActionNone)
-			continue;
-		if (getFlag(L1172_ui_MinimumSkillLevel = actionSet->_actionProperties[L1169_ui_ActionListIndex - 1], k0x0080_actionRequiresCharge) && !f382_getActionObjectChargeCount())
-			continue;
-		clearFlag(L1172_ui_MinimumSkillLevel, k0x0080_actionRequiresCharge);
-		if (_vm->_championMan->f303_getSkillLevel(_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal), g496_ActionSkillIndex[L1171_ui_ActionIndex]) >= L1172_ui_MinimumSkillLevel) {
-			_g713_actionList._actionIndices[L1170_ui_NextAvailableActionListIndex] = (ChampionAction)L1171_ui_ActionIndex;
-			_g713_actionList._minimumSkillLevel[L1170_ui_NextAvailableActionListIndex] = L1172_ui_MinimumSkillLevel;
-			L1170_ui_NextAvailableActionListIndex++;
-		}
-	}
-	_g507_actionCount = L1170_ui_NextAvailableActionListIndex;
-	for (L1169_ui_ActionListIndex = L1170_ui_NextAvailableActionListIndex; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) {
-		_g713_actionList._actionIndices[L1169_ui_ActionListIndex] = k255_ChampionActionNone;
-	}
-}
-
-int16 MenuMan::f382_getActionObjectChargeCount() {
-	Thing L1167_T_Thing;
-	Junk* L1168_ps_Junk;
-
-
-	L1168_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1167_T_Thing = _vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand]);
-	switch (L1167_T_Thing.getType()) {
-	case k5_WeaponThingType:
-		return ((Weapon*)L1168_ps_Junk)->getChargeCount();
-	case k6_ArmourThingType:
-		return ((Armour*)L1168_ps_Junk)->getChargeCount();
-	case k10_JunkThingType:
-		return L1168_ps_Junk->getChargeCount();
-	default:
-		return 1;
-	}
-}
-
-void MenuMan::f385_drawActionDamage(int16 damage) {
-	static const Box G0502_s_Graphic560_Box_ActionAreaMediumDamage = Box(242, 305, 81, 117);
-	static const Box G0503_s_Graphic560_Box_ActionAreaSmallDamage = Box(251, 292, 81, 117);
-
-	uint16 L1174_ui_Multiple;
-#define AL1174_ui_DerivedBitmapIndex L1174_ui_Multiple
-#define AL1174_ui_CharacterIndex     L1174_ui_Multiple
-	int16 L1175_i_ByteWidth;
-	int16 L1176_i_Multiple;
-#define AL1176_i_X          L1176_i_Multiple
-#define AL1176_i_PixelWidth L1176_i_Multiple
-	byte* L1177_puc_Bitmap;
-	unsigned char* L1178_puc_Multiple;
-#define AL1178_puc_String L1178_puc_Multiple
-#define AL1178_puc_Bitmap L1178_puc_Multiple
-	char L1179_ac_String[6];
-	const Box* L1180_ps_Box;
-	int16 L1643_i_Width;
-
-	_vm->_eventMan->f78_showMouse();
-	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_vm->_displayMan->D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack);
-	if (damage < 0) {
-		if (damage == kM1_damageCantReach) {
-			AL1176_i_X = 242;
-			AL1178_puc_String = (unsigned char*)"CAN'T REACH"; // TODO: localization
-		} else {
-			AL1176_i_X = 248;
-			AL1178_puc_String = (unsigned char*)"NEED AMMO"; // TODO: localization
-		}
-		_vm->_textMan->f53_printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, (char *)AL1178_puc_String);
-	} else {
-		if (damage > 40) {
-			L1180_ps_Box = &g499_BoxActionArea3ActionMenu;
-			L1177_puc_Bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
-			L1175_i_ByteWidth = k48_byteWidth;
-			L1643_i_Width = 45;
-		} else {
-			if (damage > 15) {
-				AL1174_ui_DerivedBitmapIndex = k2_DerivedBitmapDamageToCreatureMedium;
-				AL1176_i_PixelWidth = 64;
-				L1175_i_ByteWidth = k32_byteWidth;
-				L1180_ps_Box = &G0502_s_Graphic560_Box_ActionAreaMediumDamage;
-			} else {
-				AL1174_ui_DerivedBitmapIndex = k3_DerivedBitmapDamageToCreatureSmall;
-				AL1176_i_PixelWidth = 42;
-				L1175_i_ByteWidth = k24_byteWidth;
-				L1180_ps_Box = &G0503_s_Graphic560_Box_ActionAreaSmallDamage;
-			}
-			L1643_i_Width = 37;
-			if (!_vm->_displayMan->f491_isDerivedBitmapInCache(AL1174_ui_DerivedBitmapIndex)) {
-				AL1178_puc_Bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
-				_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(AL1178_puc_Bitmap, L1177_puc_Bitmap = _vm->_displayMan->f492_getDerivedBitmap(AL1174_ui_DerivedBitmapIndex), 96, 45, AL1176_i_PixelWidth, 37, g17_PalChangesNoChanges);
-				_vm->_displayMan->f493_addDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
-			} else {
-				L1177_puc_Bitmap = _vm->_displayMan->f492_getDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
-			}
-		}
-		_vm->_displayMan->f21_blitToScreen(L1177_puc_Bitmap, (int16 *)L1180_ps_Box, L1175_i_ByteWidth, kM1_ColorNoTransparency, L1643_i_Width);
-		/* Convert damage value to string */
-		AL1174_ui_CharacterIndex = 5;
-		AL1176_i_X = 274;
-		L1179_ac_String[5] = '\0';
-		do {
-			L1179_ac_String[--AL1174_ui_CharacterIndex] = '0' + (damage % 10);
-			AL1176_i_X -= 3;
-		} while (damage /= 10);
-		_vm->_textMan->f53_printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, &L1179_ac_String[AL1174_ui_CharacterIndex]);
-	}
-	_vm->_eventMan->f77_hideMouse();
-}
-}
+	f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
+	_vm->_eventMan->f78_showMouse();
+	f393_drawSpellAreaControls((ChampionIndex)champIndex);
+	_vm->_displayMan->f21_blitToScreen(_gK72_bitmapSpellAreaLine, &gK75_BoxSpellAreaLine2, k48_byteWidth, kM1_ColorNoTransparency, 12);
+	f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols);
+	_vm->_displayMan->f21_blitToScreen(_gK72_bitmapSpellAreaLine, &gK76_BoxSpellAreaLine3, k48_byteWidth, kM1_ColorNoTransparency, 12);
+	_vm->_eventMan->f77_hideMouse();
+}
+
+void MenuMan::f457_drawEnabledMenus() {
+	int16 L1462_i_Multiple;
+#define AL1462_i_MagicCasterChampionIndex L1462_i_Multiple
+#define AL1462_i_InventoryChampionOrdinal L1462_i_Multiple
+
+
+	if (_vm->_championMan->_g300_partyIsSleeping) {
+		_vm->_eventMan->f379_drawSleepScreen();
+		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+	} else {
+		AL1462_i_MagicCasterChampionIndex = _vm->_championMan->_g514_magicCasterChampionIndex;
+		_vm->_championMan->_g514_magicCasterChampionIndex = kM1_ChampionNone; /* Force next function to draw the spell area */
+		f394_setMagicCasterAndDrawSpellArea(AL1462_i_MagicCasterChampionIndex);
+		if (!_vm->_championMan->_g506_actingChampionOrdinal) {
+			_g509_actionAreaContainsIcons = true;
+		}
+		f387_drawActionArea();
+		if (AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+			_vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+			_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)_vm->M1_ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
+		} else {
+			_vm->_displayMan->f98_drawFloorAndCeiling();
+			f395_drawMovementArrows();
+		}
+		_vm->_eventMan->f69_setMousePointer();
+	}
+}
+
+int16 MenuMan::f408_getClickOnSpellCastResult() {
+	int16 L1259_i_SpellCastResult;
+	Champion* L1260_ps_Champion;
+
+
+	L1260_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
+	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->f363_highlightBoxDisable();
+	if ((L1259_i_SpellCastResult = f412_getChampionSpellCastResult(_vm->_championMan->_g514_magicCasterChampionIndex)) != k3_spellCastFailureNeedsFlask) {
+		L1260_ps_Champion->_symbols[0] = '\0';
+		f397_drawAvailableSymbols(L1260_ps_Champion->_symbolStep = 0);
+		f398_drawChampionSymbols(L1260_ps_Champion);
+	} else {
+		L1259_i_SpellCastResult = k0_spellCastFailure;
+	}
+	_vm->_eventMan->f77_hideMouse();
+	return L1259_i_SpellCastResult;
+}
+
+int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
+	uint16 L1267_ui_Multiple;
+#define AL1267_ui_SkillLevel L1267_ui_Multiple
+#define AL1267_ui_LightPower L1267_ui_Multiple
+#define AL1267_ui_SpellPower L1267_ui_Multiple
+#define AL1267_ui_Ticks      L1267_ui_Multiple
+	int16 L1268_i_PowerSymbolOrdinal;
+	uint16 L1269_ui_Multiple;
+#define AL1269_ui_RequiredSkillLevel L1269_ui_Multiple
+#define AL1269_ui_EmptyFlaskWeight   L1269_ui_Multiple
+#define AL1269_ui_Ticks              L1269_ui_Multiple
+	Champion* L1270_ps_Champion;
+	Spell* L1271_ps_Spell;
+	Thing L1272_T_Object;
+	uint16 L1273_ui_Experience;
+	int16 L1274_i_MissingSkillLevelCount;
+	Potion* L1275_ps_Potion;
+	TimelineEvent L1276_s_Event;
+	Junk* L1277_ps_Junk;
+
+
+	if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
+		return k0_spellCastFailure;
+	}
+	L1270_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	if (!(L1270_ps_Champion->_currHealth)) {
+		return k0_spellCastFailure;
+	}
+	if ((L1271_ps_Spell = f409_getSpellFromSymbols((unsigned char *)L1270_ps_Champion->_symbols)) == 0) {
+		f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k1_spellCastSuccess, 0);
+		return k0_spellCastFailure;
+	}
+	L1268_i_PowerSymbolOrdinal = L1270_ps_Champion->_symbols[0] - '_'; /* Values 1 to 6 */
+	L1273_ui_Experience = _vm->getRandomNumber(8) + ((AL1269_ui_RequiredSkillLevel = L1271_ps_Spell->_baseRequiredSkillLevel + L1268_i_PowerSymbolOrdinal) << 4) + ((_vm->M1_ordinalToIndex(L1268_i_PowerSymbolOrdinal) * L1271_ps_Spell->_baseRequiredSkillLevel) << 3) + (AL1269_ui_RequiredSkillLevel * AL1269_ui_RequiredSkillLevel);
+	AL1267_ui_SkillLevel = _vm->_championMan->f303_getSkillLevel(champIndex, L1271_ps_Spell->_skillIndex);
+	if (AL1267_ui_SkillLevel < AL1269_ui_RequiredSkillLevel) {
+		L1274_i_MissingSkillLevelCount = AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel;
+		while (L1274_i_MissingSkillLevelCount--) {
+			if (_vm->getRandomNumber(128) > MIN(L1270_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + 15, 115)) {
+				_vm->_championMan->f304_addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience >> (AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel));
+				f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k0_failureNeedsMorePractice, L1271_ps_Spell->_skillIndex);
+				return k0_spellCastFailure;
+			}
+		}
+	}
+	switch (L1271_ps_Spell->M67_spellKind()) {
+	case k1_spellKindPotion:
+		if ((L1275_ps_Potion = f411_getEmptyFlaskInHand(L1270_ps_Champion, &L1272_T_Object)) == NULL) {
+			f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k10_failureNeedsFlaskInHand, 0);
+			return k3_spellCastFailureNeedsFlask;
+		}
+		AL1269_ui_EmptyFlaskWeight = _vm->_dungeonMan->f140_getObjectWeight(L1272_T_Object);
+		L1275_ps_Potion->setType((PotionType)L1271_ps_Spell->M68_spellType());
+		L1275_ps_Potion->setPower(_vm->getRandomNumber(16) + (L1268_i_PowerSymbolOrdinal * 40));
+		L1270_ps_Champion->_load += _vm->_dungeonMan->f140_getObjectWeight(L1272_T_Object) - AL1269_ui_EmptyFlaskWeight;
+		_vm->_championMan->f296_drawChangedObjectIcons();
+		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)) {
+			setFlag(L1270_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad);
+			_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+		}
+		break;
+	case k2_spellKindProjectile:
+		if (L1270_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) {
+			L1270_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
+			setFlag(L1270_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon);
+			_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+		}
+		if (L1271_ps_Spell->M68_spellType() == k4_spellType_projectileOpenDoor) {
+			AL1267_ui_SkillLevel <<= 1;
+		}
+		_vm->_championMan->f327_isProjectileSpellCast(champIndex, Thing(L1271_ps_Spell->M68_spellType() + Thing::_firstExplosion.toUint16()), f26_getBoundedValue(21, (L1268_i_PowerSymbolOrdinal + 2) * (4 + (AL1267_ui_SkillLevel << 1)), 255), 0);
+		break;
+	case k3_spellKindOther:
+		L1276_s_Event._priority = 0;
+		AL1267_ui_SpellPower = (L1268_i_PowerSymbolOrdinal + 1) << 2;
+		switch (L1271_ps_Spell->M68_spellType()) {
+		case k0_spellType_otherLight:
+			AL1269_ui_Ticks = 10000 + ((AL1267_ui_SpellPower - 8) << 9);
+			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 1);
+			AL1267_ui_LightPower--;
+			goto T0412019;
+		case k5_spellType_otherMagicTorch:
+			AL1269_ui_Ticks = 2000 + ((AL1267_ui_SpellPower - 3) << 7);
+			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
+			AL1267_ui_LightPower++;
+T0412019:
+			_vm->_championMan->_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[AL1267_ui_LightPower];
+			f404_createEvent70_light(-AL1267_ui_LightPower, AL1269_ui_Ticks);
+			break;
+		case k1_spellType_otherDarkness:
+			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
+			_vm->_championMan->_g407_party._magicalLightAmount -= g39_LightPowerToLightAmount[AL1267_ui_LightPower];
+			f404_createEvent70_light(AL1267_ui_LightPower, 98);
+			break;
+		case k2_spellType_otherThievesEye:
+			L1276_s_Event._type = k73_TMEventTypeThievesEye;
+			_vm->_championMan->_g407_party._event73Count_ThievesEye++;
+			AL1267_ui_SpellPower = (AL1267_ui_SpellPower >> 1);
+			goto T0412032;
+		case k3_spellType_otherInvisibility:
+			L1276_s_Event._type = k71_TMEventTypeInvisibility;
+			_vm->_championMan->_g407_party._event71Count_Invisibility++;
+			goto T0412033;
+		case k4_spellType_otherPartyShield:
+			L1276_s_Event._type = k74_TMEventTypePartyShield;
+			L1276_s_Event._B._defense = AL1267_ui_SpellPower;
+			if (_vm->_championMan->_g407_party._shieldDefense > 50) {
+				L1276_s_Event._B._defense >>= 2;
+			}
+			_vm->_championMan->_g407_party._shieldDefense += L1276_s_Event._B._defense;
+			_vm->_timeline->f260_timelineRefreshAllChampionStatusBoxes();
+			goto T0412032;
+		case k6_spellType_otherFootprints:
+			L1276_s_Event._type = k79_TMEventTypeFootprints;
+			_vm->_championMan->_g407_party._event79Count_Footprints++;
+			_vm->_championMan->_g407_party._firstScentIndex = _vm->_championMan->_g407_party._scentCount;
+			if (L1268_i_PowerSymbolOrdinal < 3) {
+				_vm->_championMan->_g407_party._lastScentIndex = _vm->_championMan->_g407_party._firstScentIndex;
+			} else {
+				_vm->_championMan->_g407_party._lastScentIndex = 0;
+			}
+T0412032:
+			AL1267_ui_Ticks = AL1267_ui_SpellPower * AL1267_ui_SpellPower;
+T0412033:
+			M33_setMapAndTime(L1276_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + AL1267_ui_Ticks);
+			_vm->_timeline->f238_addEventGetEventIndex(&L1276_s_Event);
+			break;
+		case k7_spellType_otherZokathra:
+			if ((L1272_T_Object = _vm->_dungeonMan->f166_getUnusedThing(k10_JunkThingType)) == Thing::_none)
+				break;
+			L1277_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1272_T_Object);
+			L1277_ps_Junk->setType(k51_JunkTypeZokathra);
+			ChampionSlot AL1267_ui_SlotIndex;
+			if (L1270_ps_Champion->_slots[k0_ChampionSlotReadyHand] == Thing::_none) {
+				AL1267_ui_SlotIndex = k0_ChampionSlotReadyHand;
+			} else {
+				if (L1270_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) {
+					AL1267_ui_SlotIndex = k1_ChampionSlotActionHand;
+				} else {
+					AL1267_ui_SlotIndex = kM1_ChampionSlotLeaderHand;
+				}
+			}
+			if ((AL1267_ui_SlotIndex == k0_ChampionSlotReadyHand) || (AL1267_ui_SlotIndex == k1_ChampionSlotActionHand)) {
+				_vm->_championMan->f301_addObjectInSlot((ChampionIndex)champIndex, L1272_T_Object, AL1267_ui_SlotIndex);
+				_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+			} else {
+				_vm->_moveSens->f267_getMoveResult(L1272_T_Object, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+			}
+			break;
+		case k8_spellType_otherFireshield:
+			f403_isPartySpellOrFireShieldSuccessful(L1270_ps_Champion, false, (AL1267_ui_SpellPower * AL1267_ui_SpellPower) + 100, false);
+		}
+	}
+	_vm->_championMan->f304_addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience);
+	_vm->_championMan->f330_disableAction(champIndex, L1271_ps_Spell->M69_spellDurration());
+	return k1_spellCastSuccess;
+}
+
+Spell* MenuMan::f409_getSpellFromSymbols(byte* symbols) {
+	static Spell G0487_as_Graphic560_Spells[25] = {
+		/* { Symbols, BaseRequiredSkillLevel, SkillIndex, Attributes } */
+		Spell(0x00666F00, 2, 15, 0x7843),
+		Spell(0x00667073, 1, 18, 0x4863),
+		Spell(0x00686D77, 3, 17, 0xB433),
+		Spell(0x00686C00, 3, 19, 0x6C72),
+		Spell(0x00686D76, 3, 18, 0x8423),
+		Spell(0x00686E76, 4, 17, 0x7822),
+		Spell(0x00686F76, 4, 17, 0x5803),
+		Spell(0x00690000, 1, 16, 0x3C53),
+		Spell(0x00696F00, 3, 16, 0xA802),
+		Spell(0x00697072, 4, 13, 0x3C71),
+		Spell(0x00697075, 4, 15, 0x7083),
+		Spell(0x006A6D00, 1, 18, 0x5032),
+		Spell(0x006A6C00, 1, 19, 0x4062),
+		Spell(0x006A6F77, 1, 15, 0x3013),
+		Spell(0x006B0000, 1, 17, 0x3C42),
+		Spell(0x00667000, 2, 15, 0x64C1),
+		Spell(0x00660000, 2, 13, 0x3CB1),
+		Spell(0x00667074, 4, 13, 0x3C81),
+		Spell(0x00667075, 4, 13, 0x3C91),
+		Spell(0x00670000, 1, 13, 0x80E1),
+		Spell(0x00677000, 1, 13, 0x68A1),
+		Spell(0x00687073, 4, 13, 0x3C61),
+		Spell(0x006B7076, 3,  2, 0xFCD1),
+		Spell(0x006B6C00, 2, 19, 0x7831),
+		Spell(0x006B6E76, 0,  3, 0x3C73)
+	};
+
+	if (*(symbols + 1)) {
+		int16 AL1262_i_BitShiftCount = 24;
+		int32 L1261_l_Symbols = 0;
+		do {
+			L1261_l_Symbols |= (long)*symbols++ << AL1262_i_BitShiftCount;
+		} while (*symbols && ((AL1262_i_BitShiftCount -= 8) >= 0));
+		Spell *L1263_ps_Spell = G0487_as_Graphic560_Spells;
+		int16 AL1262_i_SpellIndex = 25;
+		while (AL1262_i_SpellIndex--) {
+			if (L1263_ps_Spell->_symbols & 0xFF000000) { /* If byte 1 of spell is not 0 then the spell includes the power symbol */
+				if (L1261_l_Symbols == L1263_ps_Spell->_symbols) { /* Compare champion symbols, including power symbol, with spell (never used with actual spells) */
+					return L1263_ps_Spell;
+				}
+			} else {
+				if ((L1261_l_Symbols & 0x00FFFFFF) == L1263_ps_Spell->_symbols) { /* Compare champion symbols, except power symbol, with spell */
+					return L1263_ps_Spell;
+				}
+			}
+			L1263_ps_Spell++;
+		}
+	}
+	return NULL;
+}
+
+void MenuMan::f410_menusPrintSpellFailureMessage(Champion* champ, uint16 failureType, uint16 skillIndex) {
+	char* L1264_pc_Message = nullptr;
+
+	if (skillIndex > k3_ChampionSkillWizard) {
+		skillIndex = (skillIndex - 4) / 4;
+	}
+	_vm->_textMan->f51_messageAreaPrintLineFeed();
+	_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, champ->_name);
+	switch (failureType) {
+	case k0_failureNeedsMorePractice:
+		// TODO: localization
+		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, " NEEDS MORE PRACTICE WITH THIS ");
+		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, g417_baseSkillName[skillIndex]);
+		L1264_pc_Message = " SPELL.";
+		break;
+	case k1_failureMeaninglessSpell:
+		L1264_pc_Message = " MUMBLES A MEANINGLESS SPELL."; // TODO: localization
+		break;
+	case k10_failureNeedsFlaskInHand:
+		L1264_pc_Message = " NEEDS AN EMPTY FLASK IN HAND FOR POTION."; // TODO: localization
+		break;
+	}
+	_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, L1264_pc_Message);
+}
+
+Potion* MenuMan::f411_getEmptyFlaskInHand(Champion* champ, Thing* potionThing) {
+	Thing L1265_T_Thing;
+	int16 L1266_i_SlotIndex;
+
+	for (L1266_i_SlotIndex = k2_ChampionSlotHead; --L1266_i_SlotIndex >= k0_ChampionSlotReadyHand; ) {
+		if (((L1265_T_Thing = champ->_slots[L1266_i_SlotIndex]) != Thing::_none) && (_vm->_objectMan->f33_getIconIndex(L1265_T_Thing) == k195_IconIndicePotionEmptyFlask)) {
+			*potionThing = L1265_T_Thing;
+			return (Potion*)_vm->_dungeonMan->f156_getThingData(L1265_T_Thing);
+		}
+	}
+	return nullptr;
+}
+
+void MenuMan::f404_createEvent70_light(int16 lightPower, int16 ticks) {
+	TimelineEvent L1241_s_Event;
+
+	L1241_s_Event._type = k70_TMEventTypeLight;
+	L1241_s_Event._B._lightPower = lightPower;
+	M33_setMapAndTime(L1241_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + ticks);
+	L1241_s_Event._priority = 0;
+	_vm->_timeline->f238_addEventGetEventIndex(&L1241_s_Event);
+	_vm->_inventoryMan->f337_setDungeonViewPalette();
+}
+
+bool MenuMan::f403_isPartySpellOrFireShieldSuccessful(Champion* champ, bool spellShield, uint16 ticks, bool useMana) {
+	bool L1239_B_IsPartySpellOrFireShieldSuccessful;
+	TimelineEvent L1240_s_Event;
+
+
+	L1239_B_IsPartySpellOrFireShieldSuccessful = true;
+	if (useMana) {
+		if (champ->_currMana == 0) {
+			return false;
+		}
+		if (champ->_currMana < 4) {
+			ticks >>= 1;
+			champ->_currMana = 0;
+			L1239_B_IsPartySpellOrFireShieldSuccessful = false;
+		} else {
+			champ->_currMana -= 4;
+		}
+	}
+	L1240_s_Event._B._defense = ticks >> 5;
+	if (spellShield) {
+		L1240_s_Event._type = k77_TMEventTypeSpellShield;
+		if (_vm->_championMan->_g407_party._spellShieldDefense > 50) {
+			L1240_s_Event._B._defense >>= 2;
+		}
+		_vm->_championMan->_g407_party._spellShieldDefense += L1240_s_Event._B._defense;
+	} else {
+		L1240_s_Event._type = k78_TMEventTypeFireShield;
+		if (_vm->_championMan->_g407_party._fireShieldDefense > 50) {
+			L1240_s_Event._B._defense >>= 2;
+		}
+		_vm->_championMan->_g407_party._fireShieldDefense += L1240_s_Event._B._defense;
+	}
+	L1240_s_Event._priority = 0;
+	M33_setMapAndTime(L1240_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + ticks);
+	_vm->_timeline->f238_addEventGetEventIndex(&L1240_s_Event);
+	_vm->_timeline->f260_timelineRefreshAllChampionStatusBoxes();
+	return L1239_B_IsPartySpellOrFireShieldSuccessful;
+}
+
+void MenuMan::f397_drawAvailableSymbols(uint16 symbolStep) {
+	uint16 L1214_ui_Counter;
+	int16 L1215_i_X;
+	char L1216_c_Character;
+	char L1217_ac_String[2];
+
+	L1217_ac_String[1] = '\0';
+	L1216_c_Character = 96 + 6 * symbolStep;
+	L1215_i_X = 225;
+	for (L1214_ui_Counter = 0; L1214_ui_Counter < 6; L1214_ui_Counter++) {
+		L1217_ac_String[0] = L1216_c_Character++;
+		_vm->_textMan->f53_printToLogicalScreen(L1215_i_X += 14, 58, k4_ColorCyan, k0_ColorBlack, L1217_ac_String);
+	}
+}
+
+void MenuMan::f398_drawChampionSymbols(Champion* champ) {
+	uint16 L1218_ui_SymbolIndex;
+	int16 L1219_i_X;
+	uint16 L1220_ui_SymbolCount;
+	char L1221_ac_String[2];
+
+
+	L1220_ui_SymbolCount = strlen(champ->_symbols);
+	L1219_i_X = 232;
+	L1221_ac_String[1] = '\0';
+	for (L1218_ui_SymbolIndex = 0; L1218_ui_SymbolIndex < 4; L1218_ui_SymbolIndex++) {
+		if (L1218_ui_SymbolIndex >= L1220_ui_SymbolCount) {
+			L1221_ac_String[0] = ' ';
+		} else {
+			L1221_ac_String[0] = champ->_symbols[L1218_ui_SymbolIndex];
+		}
+		_vm->_textMan->f53_printToLogicalScreen(L1219_i_X += 9, 70, k4_ColorCyan, k0_ColorBlack, L1221_ac_String);
+	}
+}
+
+void MenuMan::f399_addChampionSymbol(int16 symbolIndex) {
+	static byte G0485_aauc_Graphic560_SymbolBaseManaCost[4][6] = {
+		{1, 2, 3, 4, 5, 6},   /* Power 1 */
+		{2, 3, 4, 5, 6, 7},   /* Power 2 */
+		{4, 5, 6, 7, 7, 9},   /* Power 3 */
+		{2, 2, 3, 4, 6, 7}}; /* Power 4 */
+	static byte G0486_auc_Graphic560_SymbolManaCostMultiplier[6] = {8, 12, 16, 20, 24, 28};
+
+	uint16 L1222_ui_SymbolStep;
+	uint16 L1223_ui_ManaCost;
+	uint16 L1224_ui_SymbolIndex;
+	Champion* L1225_ps_Champion;
+
+	L1225_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
+	L1222_ui_SymbolStep = L1225_ps_Champion->_symbolStep;
+	L1223_ui_ManaCost = G0485_aauc_Graphic560_SymbolBaseManaCost[L1222_ui_SymbolStep][symbolIndex];
+	if (L1222_ui_SymbolStep) {
+		L1223_ui_ManaCost = (L1223_ui_ManaCost * G0486_auc_Graphic560_SymbolManaCostMultiplier[L1224_ui_SymbolIndex = L1225_ps_Champion->_symbols[0] - 96]) >> 3;
+	}
+	if (L1223_ui_ManaCost <= L1225_ps_Champion->_currMana) {
+		L1225_ps_Champion->_currMana -= L1223_ui_ManaCost;
+		setFlag(L1225_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+		L1225_ps_Champion->_symbols[L1222_ui_SymbolStep] = 96 + (L1222_ui_SymbolStep * 6) + symbolIndex;
+		L1225_ps_Champion->_symbols[L1222_ui_SymbolStep + 1] = '\0';
+		L1225_ps_Champion->_symbolStep = L1222_ui_SymbolStep = returnNextVal(L1222_ui_SymbolStep);
+		_vm->_eventMan->f78_showMouse();
+		f397_drawAvailableSymbols(L1222_ui_SymbolStep);
+		f398_drawChampionSymbols(L1225_ps_Champion);
+		_vm->_championMan->f292_drawChampionState(_vm->_championMan->_g514_magicCasterChampionIndex);
+		_vm->_eventMan->f77_hideMouse();
+	}
+}
+
+void MenuMan::f400_deleteChampionSymbol() {
+	int16 L1226_ui_SymbolStep;
+	Champion* L1228_ps_Champion;
+
+	L1228_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
+	if (!strlen(L1228_ps_Champion->_symbols)) {
+		return;
+	}
+	L1228_ps_Champion->_symbolStep = L1226_ui_SymbolStep = returnPrevVal(L1228_ps_Champion->_symbolStep);
+	L1228_ps_Champion->_symbols[L1226_ui_SymbolStep] = '\0';
+	_vm->_eventMan->f78_showMouse();
+	f397_drawAvailableSymbols(L1226_ui_SymbolStep);
+	f398_drawChampionSymbols(L1228_ps_Champion);
+	_vm->_eventMan->f77_hideMouse();
+}
+
+bool MenuMan::f391_didClickTriggerAction(int16 actionListIndex) {
+	uint16 L1196_ui_ChampionIndex;
+	uint16 L1197_ui_ActionIndex;
+	bool L1198_B_ClickTriggeredAction;
+	Champion* L1199_ps_Champion;
+
+
+	if (!_vm->_championMan->_g506_actingChampionOrdinal || (actionListIndex != -1 && (_g713_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone)))
+		return false;
+
+	L1199_ps_Champion = &_vm->_championMan->_gK71_champions[L1196_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)];
+	if (actionListIndex == -1) {
+		warning(false, "possible bug in f391_didClickTriggerAction");
+		// L1198_B_ClickTriggeredAction is set to -1 since booleans are stored in int16 in the original
+		L1198_B_ClickTriggeredAction = true;
+	} else {
+		L1197_ui_ActionIndex = _g713_actionList._actionIndices[actionListIndex];
+		L1199_ps_Champion->_actionDefense += g495_actionDefense[L1197_ui_ActionIndex]; /* BUG0_54 The defense modifier of an action is permanent.
+																									 Each action has an associated defense modifier value and a number of ticks while the champion cannot perform another action because the action icon is grayed out. If an action has a non zero defense modifier and a zero value for the number of ticks then the defense modifier is applied but it is never removed. This causes no issue in the original games because there are no actions in this case but it may occur in a version where data is customized. This statement should only be executed if the value for the action in G0491_auc_Graphic560_ActionDisabledTicks is not 0 otherwise the action is not disabled at the end of F0407_MENUS_IsActionPerformed and thus not enabled later in F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction where the defense modifier is also removed */
+		setFlag(L1199_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+		L1198_B_ClickTriggeredAction = f407_isActionPerformed(L1196_ui_ChampionIndex, L1197_ui_ActionIndex);
+		L1199_ps_Champion->_actionIndex = (ChampionAction)L1197_ui_ActionIndex;
+	}
+	f388_clearActingChampion();
+	return L1198_B_ClickTriggeredAction;
+}
+
+bool MenuMan::f407_isActionPerformed(uint16 champIndex, int16 actionIndex) {
+	static unsigned char G0491_auc_Graphic560_ActionDisabledTicks[44] = {
+		0,  /* N */
+		6,  /* BLOCK */
+		8,  /* CHOP */
+		0,  /* X */
+		6,  /* BLOW HORN */
+		3,  /* FLIP */
+		1,  /* PUNCH */
+		5,  /* KICK */
+		3,  /* WAR CRY */
+		5,  /* STAB */
+		35, /* CLIMB DOWN */
+		20, /* FREEZE LIFE */
+		4,  /* HIT */
+		6,  /* SWING */
+		10, /* STAB */
+		16, /* THRUST */
+		2,  /* JAB */
+		18, /* PARRY */
+		8,  /* HACK */
+		30, /* BERZERK */
+		42, /* FIREBALL */
+		31, /* DISPELL */
+		10, /* CONFUSE */
+		38, /* LIGHTNING */
+		9,  /* DISRUPT */
+		20, /* MELEE */
+		10, /* X */
+		16, /* INVOKE */
+		4,  /* SLASH */
+		12, /* CLEAVE */
+		20, /* BASH */
+		7,  /* STUN */
+		14, /* SHOOT */
+		30, /* SPELLSHIELD */
+		35, /* FIRESHIELD */
+		2,  /* FLUXCAGE */
+		19, /* HEAL */
+		9,  /* CALM */
+		10, /* LIGHT */
+		15, /* WINDOW */
+		22, /* SPIT */
+		10, /* BRANDISH */
+		0,  /* THROW */
+		2}; /* FUSE */
+	static unsigned char G0494_auc_Graphic560_ActionStamina[44] = {
+		0,  /* N */
+		4,  /* BLOCK */
+		10, /* CHOP */
+		0,  /* X */
+		1,  /* BLOW HORN */
+		0,  /* FLIP */
+		1,  /* PUNCH */
+		3,  /* KICK */
+		1,  /* WAR CRY */
+		3,  /* STAB */
+		40, /* CLIMB DOWN */
+		3,  /* FREEZE LIFE */
+		3,  /* HIT */
+		2,  /* SWING */
+		4,  /* STAB */
+		17, /* THRUST */
+		3,  /* JAB */
+		1,  /* PARRY */
+		6,  /* HACK */
+		40, /* BERZERK */
+		5,  /* FIREBALL */
+		2,  /* DISPELL */
+		2,  /* CONFUSE */
+		4,  /* LIGHTNING */
+		5,  /* DISRUPT */
+		25, /* MELEE */
+		1,  /* X */
+		2,  /* INVOKE */
+		2,  /* SLASH */
+		10, /* CLEAVE */
+		9,  /* BASH */
+		2,  /* STUN */
+		3,  /* SHOOT */
+		1,  /* SPELLSHIELD */
+		2,  /* FIRESHIELD */
+		6,  /* FLUXCAGE */
+		1,  /* HEAL */
+		1,  /* CALM */
+		3,  /* LIGHT */
+		2,  /* WINDOW */
+		3,  /* SPIT */
+		2,  /* BRANDISH */
+		0,  /* THROW */
+		2}; /* FUSE */
+	unsigned char G0497_auc_Graphic560_ActionExperienceGain[44] = {
+		0,  /* N */
+		8,  /* BLOCK */
+		10, /* CHOP */
+		0,  /* X */
+		0,  /* BLOW HORN */
+		0,  /* FLIP */
+		8,  /* PUNCH */
+		13, /* KICK */
+		7,  /* WAR CRY */
+		15, /* STAB */
+		15, /* CLIMB DOWN */
+		22, /* FREEZE LIFE */
+		10, /* HIT */
+		6,  /* SWING */
+		12, /* STAB */
+		19, /* THRUST */
+		11, /* JAB */
+		17, /* PARRY */
+		9,  /* HACK */
+		40, /* BERZERK */
+		35, /* FIREBALL */
+		25, /* DISPELL */
+		0,  /* CONFUSE */
+		30, /* LIGHTNING */
+		10, /* DISRUPT */
+		24, /* MELEE */
+		0,  /* X */
+		25, /* INVOKE */
+		9,  /* SLASH */
+		12, /* CLEAVE */
+		11, /* BASH */
+		10, /* STUN */
+		20, /* SHOOT Atari ST Versions 1.0 1987-12-08 1987-12-11: 9 */
+		20, /* SPELLSHIELD */
+		20, /* FIRESHIELD */
+		12, /* FLUXCAGE */
+		0,  /* HEAL */
+		0,  /* CALM */
+		20, /* LIGHT */
+		30, /* WINDOW */
+		25, /* SPIT */
+		0,  /* BRANDISH */
+		5,  /* THROW */
+		1}; /* FUSE */
+	uint16 L1244_ui_Multiple;
+#define AL1244_ui_TargetSquare  L1244_ui_Multiple
+#define AL1244_ui_HealingAmount L1244_ui_Multiple
+#define AL1244_ui_ManaCost      L1244_ui_Multiple
+	int16 L1245_i_Multiple;
+#define AL1245_T_ExplosionThing  L1245_i_Multiple
+#define AL1245_B_ActionPerformed L1245_i_Multiple
+	int16 L1246_i_Multiple;
+#define AL1246_i_RequiredManaAmount    L1246_i_Multiple
+#define AL1246_i_ActionHandWeaponClass L1246_i_Multiple
+#define AL1246_i_StepEnergy            L1246_i_Multiple
+#define AL1246_i_HealingCapability     L1246_i_Multiple
+#define AL1246_i_Ticks                 L1246_i_Multiple
+	Champion* L1247_ps_Champion;
+	Weapon* L1248_ps_Weapon;
+	uint16 L1249_ui_ActionDisabledTicks;
+	int16 L1250_i_Multiple;
+#define AL1250_i_KineticEnergy        L1250_i_Multiple
+#define AL1250_i_ReadyHandWeaponClass L1250_i_Multiple
+#define AL1250_i_MissingHealth        L1250_i_Multiple
+#define AL1250_i_HealingAmount        L1250_i_Multiple
+	int16 L1251_i_MapX;
+	int16 L1252_i_MapY;
+	int16 L1253_i_ActionStamina;
+	int16 L1254_i_ActionSkillIndex;
+	int16 L1255_i_ActionExperienceGain;
+	WeaponInfo* L1256_ps_WeaponInfoActionHand;
+	WeaponInfo* L1257_ps_WeaponInfoReadyHand;
+	TimelineEvent L1258_s_Event;
+
+
+	if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
+		return false;
+	}
+	L1247_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	L1248_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L1247_ps_Champion->_slots[k1_ChampionSlotActionHand]);
+	if (!L1247_ps_Champion->_currHealth) {
+		return false;
+	}
+	L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
+	L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+	L1251_i_MapX += _vm->_dirIntoStepCountEast[L1247_ps_Champion->_dir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[L1247_ps_Champion->_dir];
+	_g517_actionTargetGroupThing = _vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY);
+	L1249_ui_ActionDisabledTicks = G0491_auc_Graphic560_ActionDisabledTicks[actionIndex];
+	L1254_i_ActionSkillIndex = g496_ActionSkillIndex[actionIndex];
+	L1253_i_ActionStamina = G0494_auc_Graphic560_ActionStamina[actionIndex] + _vm->getRandomNumber(2);
+	L1255_i_ActionExperienceGain = G0497_auc_Graphic560_ActionExperienceGain[actionIndex];
+	AL1244_ui_TargetSquare = _vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).toByte();
+	AL1245_B_ActionPerformed = true;
+	if (((L1254_i_ActionSkillIndex >= k16_ChampionSkillFire) && (L1254_i_ActionSkillIndex <= k19_ChampionSkillWater)) || (L1254_i_ActionSkillIndex == k3_ChampionSkillWizard)) {
+		AL1246_i_RequiredManaAmount = 7 - MIN((uint16)6, _vm->_championMan->f303_getSkillLevel(champIndex, L1254_i_ActionSkillIndex));
+	}
+	switch (actionIndex) {
+	case k23_ChampionActionLightning:
+		AL1250_i_KineticEnergy = 180;
+		AL1245_T_ExplosionThing = Thing::_explLightningBolt.toUint16();
+		goto T0407014;
+	case k21_ChampionActionDispel:
+		AL1250_i_KineticEnergy = 150;
+		AL1245_T_ExplosionThing = Thing::_explHarmNonMaterial.toUint16();
+		goto T0407014;
+	case k20_ChampionActionFireball:
+		AL1250_i_KineticEnergy = 150;
+		goto T0407013;
+	case k40_ChampionActionSpit:
+		AL1250_i_KineticEnergy = 250;
+T0407013:
+		AL1245_T_ExplosionThing = Thing::_explFireBall.toUint16();
+T0407014:
+		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+		if (L1247_ps_Champion->_currMana < AL1246_i_RequiredManaAmount) {
+			AL1250_i_KineticEnergy = MAX(2, L1247_ps_Champion->_currMana * AL1250_i_KineticEnergy / AL1246_i_RequiredManaAmount);
+			AL1246_i_RequiredManaAmount = L1247_ps_Champion->_currMana;
+		}
+		if (!(AL1245_B_ActionPerformed = _vm->_championMan->f327_isProjectileSpellCast(champIndex, Thing(AL1245_T_ExplosionThing), AL1250_i_KineticEnergy, AL1246_i_RequiredManaAmount))) {
+			L1255_i_ActionExperienceGain >>= 1;
+		}
+		f405_decrementCharges(L1247_ps_Champion);
+		break;
+	case k30_ChampionActionBash:
+	case k18_ChampionActionHack:
+	case k19_ChampionActionBerzerk:
+	case k7_ChampionActionKick:
+	case k13_ChampionActionSwing:
+	case k2_ChampionActionChop:
+		if ((Square(AL1244_ui_TargetSquare).getType() == k4_DoorElemType) && (Square(AL1244_ui_TargetSquare).getDoorState() == k4_doorState_CLOSED)) {
+			_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+			L1249_ui_ActionDisabledTicks = 6;
+			_vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
+			_vm->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater);
+			break;
+		}
+	case k24_ChampionActionDisrupt:
+	case k16_ChampionActionJab:
+	case k17_ChampionActionParry:
+	case k14_ChampionActionStab_C014:
+	case k9_ChampionActionStab_C009:
+	case k31_ChampionActionStun:
+	case k15_ChampionActionThrust:
+	case k25_ChampionActionMelee:
+	case k28_ChampionActionSlash:
+	case k29_ChampionActionCleave:
+	case k6_ChampionActionPunch:
+		if (!(AL1245_B_ActionPerformed = f402_isMeleeActionPerformed(champIndex, L1247_ps_Champion, actionIndex, L1251_i_MapX, L1252_i_MapY, L1254_i_ActionSkillIndex))) {
+			L1255_i_ActionExperienceGain >>= 1;
+			L1249_ui_ActionDisabledTicks >>= 1;
+		}
+		break;
+	case k22_ChampionActionConfuse:
+		f405_decrementCharges(L1247_ps_Champion);
+	case k8_ChampionActionWarCry:
+	case k37_ChampionActionCalm:
+	case k41_ChampionActionBrandish:
+	case k4_ChampionActionBlowHorn:
+		if (actionIndex == k8_ChampionActionWarCry) {
+			_vm->f064_SOUND_RequestPlay_CPSD(k28_soundWAR_CRY, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
+		}
+		if (actionIndex == k4_ChampionActionBlowHorn) {
+			_vm->f064_SOUND_RequestPlay_CPSD(k25_soundBLOW_HORN, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
+		}
+		AL1245_B_ActionPerformed = f401_isGroupFrightenedByAction(champIndex, actionIndex, L1251_i_MapX, L1252_i_MapY);
+		break;
+	case k32_ChampionActionShoot:
+		if (Thing(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]).getType() != k5_WeaponThingType)
+			goto T0407032;
+		L1256_ps_WeaponInfoActionHand = &g238_WeaponInfo[L1248_ps_Weapon->getType()];
+		L1257_ps_WeaponInfoReadyHand = _vm->_dungeonMan->f158_getWeaponInfo(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]);
+		AL1246_i_ActionHandWeaponClass = L1256_ps_WeaponInfoActionHand->_class;
+		AL1250_i_ReadyHandWeaponClass = L1257_ps_WeaponInfoReadyHand->_class;
+		if ((AL1246_i_ActionHandWeaponClass >= k16_WeaponClassFirstBow) && (AL1246_i_ActionHandWeaponClass <= k31_WeaponClassLastBow)) {
+			if (AL1250_i_ReadyHandWeaponClass != k10_WeaponClassBowAmmunition)
+				goto T0407032;
+			AL1246_i_StepEnergy -= k16_WeaponClassFirstBow;
+		} else {
+			if ((AL1246_i_ActionHandWeaponClass >= k32_WeaponClassFirstSling) && (AL1246_i_ActionHandWeaponClass <= k47_WeaponClassLastSling)) {
+				if (AL1250_i_ReadyHandWeaponClass != k11_WeaponClassSlingAmmunition) {
+T0407032:
+					_g513_actionDamage = kM2_damageNoAmmunition;
+					L1255_i_ActionExperienceGain = 0;
+					AL1245_B_ActionPerformed = false;
+					break;
+				}
+				AL1246_i_StepEnergy -= k32_WeaponClassFirstSling;
+			}
+		}
+		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+		{ // so gotos won't skip init
+			Thing AL1250_T_Object = _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
+			_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+			_vm->_championMan->f326_championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->f303_getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy);
+		}
+		break;
+	case k5_ChampionActionFlip:
+		// TODO: localization
+		if (_vm->getRandomNumber(2)) {
+			f381_printMessageAfterReplacements("IT COMES UP HEADS.");
+		} else {
+			f381_printMessageAfterReplacements("IT COMES UP TAILS.");
+		}
+		break;
+	case k33_ChampionActionSpellshield:
+	case k34_ChampionActionFireshield:
+		if (!f403_isPartySpellOrFireShieldSuccessful(L1247_ps_Champion, actionIndex == k33_ChampionActionSpellshield, 280, true)) {
+			L1255_i_ActionExperienceGain >>= 2;
+			L1249_ui_ActionDisabledTicks >>= 1;
+		} else {
+			f405_decrementCharges(L1247_ps_Champion);
+		}
+		break;
+	case k27_ChampionActionInvoke:
+		AL1250_i_KineticEnergy = _vm->getRandomNumber(128) + 100;
+		switch (_vm->getRandomNumber(6)) {
+		case 0:
+			AL1245_T_ExplosionThing = Thing::_explPoisonBolt.toUint16();
+			goto T0407014;
+		case 1:
+			AL1245_T_ExplosionThing = Thing::_explPoisonCloud.toUint16();
+			goto T0407014;
+		case 2:
+			AL1245_T_ExplosionThing = Thing::_explHarmNonMaterial.toUint16();
+			goto T0407014;
+		default:
+			goto T0407013;
+		}
+	case k35_ChampionActionFluxcage:
+		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+		_vm->_groupMan->f224_fluxCageAction(L1251_i_MapX, L1252_i_MapY);
+		break;
+	case k43_ChampionActionFuse:
+		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+		L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
+		L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+		_vm->_groupMan->f225_fuseAction(L1251_i_MapX, L1252_i_MapY);
+		break;
+	case k36_ChampionActionHeal:
+		/* CHANGE2_17_IMPROVEMENT Heal action is much more effective
+		Heal cycles occur as long as the champion has missing health and enough mana. Cycle count = Min(Current Mana / 2, Missing health / Min(10, Heal skill level))
+		Healing amount is Min(Missing health, Min(10, Heal skill level)) * heal cycle count
+		Mana cost is 2 * heal cycle count
+		Experience gain is 2 + 2 * heal cycle count */
+		if (((AL1250_i_MissingHealth = L1247_ps_Champion->_maxHealth - L1247_ps_Champion->_currHealth) > 0) && L1247_ps_Champion->_currMana) {
+			AL1246_i_HealingCapability = MIN((uint16)10, _vm->_championMan->f303_getSkillLevel(champIndex, k13_ChampionSkillHeal));
+			L1255_i_ActionExperienceGain = 2;
+			do {
+				AL1244_ui_HealingAmount = MIN(AL1250_i_MissingHealth, AL1246_i_HealingCapability);
+				L1247_ps_Champion->_currHealth += AL1244_ui_HealingAmount;
+				L1255_i_ActionExperienceGain += 2;
+			} while (((L1247_ps_Champion->_currMana = L1247_ps_Champion->_currMana - 2) > 0) && (AL1250_i_MissingHealth = AL1250_i_MissingHealth - AL1244_ui_HealingAmount));
+			if (L1247_ps_Champion->_currMana < 0) {
+				L1247_ps_Champion->_currMana = 0;
+			}
+			setFlag(L1247_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+			AL1245_B_ActionPerformed = true;
+		}
+		break;
+	case k39_ChampionActionWindow:
+		AL1246_i_Ticks = _vm->getRandomNumber(_vm->_championMan->f303_getSkillLevel(champIndex, L1254_i_ActionSkillIndex) + 8) + 5;
+		L1258_s_Event._priority = 0;
+		L1258_s_Event._type = k73_TMEventTypeThievesEye;
+		M33_setMapAndTime(L1258_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + AL1246_i_Ticks);
+		_vm->_timeline->f238_addEventGetEventIndex(&L1258_s_Event);
+		_vm->_championMan->_g407_party._event73Count_ThievesEye++;
+		goto T0407076;
+	case k10_ChampionActionClimbDown:
+		L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
+		L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+		/* CHANGE6_00_FIX The presence of a group over the pit is checked so that you cannot climb down a pit with the rope if there is a group levitating over it */
+		if ((_vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_ElementTypePit) && (_vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY) == Thing::_endOfList)) {
+			/* BUG0_77 The party moves forward when using the rope in front of a closed pit. The engine does not check whether the pit is open before moving the party over the pit. This is not consistent with the behavior when using the rope in front of a corridor where nothing happens */
+			_vm->_moveSens->_g402_useRopeToClimbDownPit = true;
+			_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1251_i_MapX, L1252_i_MapY);
+			_vm->_moveSens->_g402_useRopeToClimbDownPit = false;
+		} else {
+			L1249_ui_ActionDisabledTicks = 0;
+		}
+		break;
+	case k11_ChampionActionFreezeLife:
+		if (L1248_ps_Weapon->getType() == k42_JunkTypeMagicalBoxBlue) {
+			AL1246_i_Ticks = 30;
+			goto T0407071;
+		}
+		if (L1248_ps_Weapon->getType() == k43_JunkTypeMagicalBoxGreen) {
+			AL1246_i_Ticks = 125;
+T0407071:
+			_vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k1_ChampionSlotActionHand);
+			L1248_ps_Weapon->setNextThing(Thing::_none);
+		} else {
+			AL1246_i_Ticks = 70;
+			f405_decrementCharges(L1247_ps_Champion);
+		}
+		_vm->_championMan->_g407_party._freezeLifeTicks = MIN(200, _vm->_championMan->_g407_party._freezeLifeTicks + AL1246_i_Ticks);
+		break;
+	case k38_ChampionActionLight:
+		_vm->_championMan->_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2];
+		f404_createEvent70_light(-2, 2500);
+T0407076:
+		f405_decrementCharges(L1247_ps_Champion);
+		break;
+	case k42_ChampionActionThrow:
+		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+		if (AL1245_B_ActionPerformed = _vm->_championMan->f328_isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_g308_partyDir)) || (L1247_ps_Champion->_cell == returnOppositeDir(_vm->_dungeonMan->_g308_partyDir)))) {
+			_vm->_timeline->_g370_events[L1247_ps_Champion->_enableActionEventIndex]._B._slotOrdinal = _vm->M0_indexToOrdinal(k1_ChampionSlotActionHand);
+		}
+	}
+	if (L1249_ui_ActionDisabledTicks) {
+		_vm->_championMan->f330_disableAction(champIndex, L1249_ui_ActionDisabledTicks);
+	}
+	if (L1253_i_ActionStamina) {
+		_vm->_championMan->f325_decrementStamina(champIndex, L1253_i_ActionStamina);
+	}
+	if (L1255_i_ActionExperienceGain) {
+		_vm->_championMan->f304_addSkillExperience(champIndex, L1254_i_ActionSkillIndex, L1255_i_ActionExperienceGain);
+	}
+	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+	return AL1245_B_ActionPerformed;
+}
+
+void MenuMan::f406_setChampionDirectionToPartyDirection(Champion* champ) {
+	if (champ->_dir != _vm->_dungeonMan->_g308_partyDir) {
+		champ->_dir = _vm->_dungeonMan->_g308_partyDir;
+		setFlag(champ->_attributes, k0x0400_ChampionAttributeIcon);
+	}
+}
+
+void MenuMan::f405_decrementCharges(Champion* champ) {
+	Thing L1242_T_Thing;
+	Junk* L1243_ps_Junk;
+
+	L1243_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1242_T_Thing = champ->_slots[k1_ChampionSlotActionHand]);
+	switch (L1242_T_Thing.getType()) {
+	case k5_WeaponThingType:
+		if (((Weapon*)L1243_ps_Junk)->getChargeCount()) {
+			((Weapon*)L1243_ps_Junk)->setChargeCount(((Weapon*)L1243_ps_Junk)->getChargeCount() - 1);
+		}
+		break;
+	case k6_ArmourThingType:
+		if (((Armour*)L1243_ps_Junk)->getChargeCount()) {
+			((Armour*)L1243_ps_Junk)->setChargeCount(((Armour*)L1243_ps_Junk)->getChargeCount() - 1);
+		}
+		break;
+	case k10_JunkThingType:
+		if (L1243_ps_Junk->getChargeCount()) {
+			L1243_ps_Junk->setChargeCount(L1243_ps_Junk->getChargeCount() - 1);
+		}
+	}
+	_vm->_championMan->f296_drawChangedObjectIcons();
+}
+
+bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int16 actionIndex, int16 targetMapX, int16 targetMapY, int16 skillIndex) {
+	static unsigned char G0492_auc_Graphic560_ActionDamageFactor[44] = {
+		0,  /* N */
+		15, /* BLOCK */
+		48, /* CHOP */
+		0,  /* X */
+		0,  /* BLOW HORN */
+		0,  /* FLIP */
+		32, /* PUNCH */
+		48, /* KICK */
+		0,  /* WAR CRY */
+		48, /* STAB */
+		0,  /* CLIMB DOWN */
+		0,  /* FREEZE LIFE */
+		20, /* HIT */
+		16, /* SWING */
+		60, /* STAB */
+		66, /* THRUST */
+		8,  /* JAB */
+		8,  /* PARRY */
+		25, /* HACK */
+		96, /* BERZERK */
+		0,  /* FIREBALL */
+		0,  /* DISPELL */
+		0,  /* CONFUSE */
+		0,  /* LIGHTNING */
+		55, /* DISRUPT */
+		60, /* MELEE */
+		0,  /* X */
+		0,  /* INVOKE */
+		16, /* SLASH */
+		48, /* CLEAVE */
+		50, /* BASH */
+		16, /* STUN */
+		0,  /* SHOOT */
+		0,  /* SPELLSHIELD */
+		0,  /* FIRESHIELD */
+		0,  /* FLUXCAGE */
+		0,  /* HEAL */
+		0,  /* CALM */
+		0,  /* LIGHT */
+		0,  /* WINDOW */
+		0,  /* SPIT */
+		0,  /* BRANDISH */
+		0,  /* THROW */
+		0}; /* FUSE */
+	static unsigned char G0493_auc_Graphic560_ActionHitProbability[44] = {
+		0,  /* N */
+		22, /* BLOCK */
+		48, /* CHOP */
+		0,  /* X */
+		0,  /* BLOW HORN */
+		0,  /* FLIP */
+		38, /* PUNCH */
+		28, /* KICK */
+		0,  /* WAR CRY */
+		30, /* STAB */
+		0,  /* CLIMB DOWN */
+		0,  /* FREEZE LIFE */
+		20, /* HIT */
+		32, /* SWING */
+		42, /* STAB */
+		57, /* THRUST */
+		70, /* JAB */
+		18, /* PARRY */
+		27, /* HACK */
+		46, /* BERZERK */
+		0,  /* FIREBALL */
+		0,  /* DISPELL */
+		0,  /* CONFUSE */
+		0,  /* LIGHTNING */
+		46, /* DISRUPT */
+		64, /* MELEE */
+		0,  /* X */
+		0,  /* INVOKE */
+		26, /* SLASH */
+		40, /* CLEAVE */
+		32, /* BASH */
+		50, /* STUN */
+		0,  /* SHOOT */
+		0,  /* SPELLSHIELD */
+		0,  /* FIRESHIELD */
+		0,  /* FLUXCAGE */
+		0,  /* HEAL */
+		0,  /* CALM */
+		0,  /* LIGHT */
+		0,  /* WINDOW */
+		0,  /* SPIT */
+		0,  /* BRANDISH */
+		0,  /* THROW */
+		0}; /* FUSE */
+
+	uint16 L1236_ui_Multiple;
+#define AL1236_ui_ChampionCell       L1236_ui_Multiple
+#define AL1236_ui_ActionDamageFactor L1236_ui_Multiple
+	uint16 L1237_ui_Multiple;
+#define AL1237_ui_Direction            L1237_ui_Multiple
+#define AL1237_ui_CellDelta            L1237_ui_Multiple
+#define AL1237_ui_ActionHitProbability L1237_ui_Multiple
+	int16 L1238_i_CreatureOrdinal;
+
+	_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+	if (_g517_actionTargetGroupThing == Thing::_endOfList)
+		goto T0402010;
+	if (L1238_i_CreatureOrdinal = _vm->_groupMan->f177_getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, AL1236_ui_ChampionCell = champ->_cell)) {
+		switch (M21_normalizeModulo4(AL1236_ui_ChampionCell + 4 - champ->_dir)) {
+		case k2_ViewCellBackRight: /* Champion is on the back right of the square and tries to attack a creature in the front right of its square */
+			AL1237_ui_CellDelta = 3;
+			goto T0402005;
+		case k3_ViewCellBackLeft: /* Champion is on the back left of the square and tries to attack a creature in the front left of its square */
+			AL1237_ui_CellDelta = 1;
+T0402005: /* Check if there is another champion in front */
+			if (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL1236_ui_ChampionCell + AL1237_ui_CellDelta)) != kM1_ChampionNone) {
+				_g513_actionDamage = kM1_damageCantReach;
+				goto T0402010;
+			}
+		}
+		if ((actionIndex == k24_ChampionActionDisrupt) && !getFlag(_vm->_dungeonMan->f144_getCreatureAttributes(_g517_actionTargetGroupThing), k0x0040_MaskCreatureInfo_nonMaterial))
+			goto T0402010;
+		AL1237_ui_ActionHitProbability = G0493_auc_Graphic560_ActionHitProbability[actionIndex];
+		AL1236_ui_ActionDamageFactor = G0492_auc_Graphic560_ActionDamageFactor[actionIndex];
+		if ((_vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
+			setFlag(AL1237_ui_ActionHitProbability, k0x8000_hitNonMaterialCreatures);
+		}
+		_g513_actionDamage = _vm->_groupMan->f231_getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing), _vm->M1_ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
+		return true;
+	}
+T0402010:
+	return false;
+}
+
+bool MenuMan::f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, int16 mapX, int16 mapY) {
+	int16 L1229_i_FrightAmount = 0;
+	uint16 L1230_ui_FearResistance;
+	uint16 L1231_ui_Experience = 0;
+	bool L1232_B_IsGroupFrightenedByAction;
+	Group* L1233_ps_Group;
+	CreatureInfo* L1234_ps_CreatureInfo;
+	ActiveGroup* L1235_ps_ActiveGroup;
+
+
+	L1232_B_IsGroupFrightenedByAction = false;
+	if (_g517_actionTargetGroupThing == Thing::_endOfList)
+		goto T0401016;
+	switch (actionIndex) {
+	case k8_ChampionActionWarCry:
+		L1229_i_FrightAmount = 3;
+		L1231_ui_Experience = 12; /* War Cry gives experience in priest skill k14_ChampionSkillInfluence below. The War Cry action also has an experience gain of 7 defined in G0497_auc_Graphic560_ActionExperienceGain in the same skill (versions 1.1 and below) or in the fighter skill k7_ChampionSkillParry (versions 1.2 and above). In versions 1.2 and above, this is the only action that gives experience in two skills */
+		break;
+	case k37_ChampionActionCalm:
+		L1229_i_FrightAmount = 7;
+		L1231_ui_Experience = 35;
+		break;
+	case k41_ChampionActionBrandish:
+		L1229_i_FrightAmount = 6;
+		L1231_ui_Experience = 30;
+		break;
+	case k4_ChampionActionBlowHorn:
+		L1229_i_FrightAmount = 6;
+		L1231_ui_Experience = 20;
+		break;
+	case k22_ChampionActionConfuse:
+		L1229_i_FrightAmount = 12;
+		L1231_ui_Experience = 45;
+	}
+	L1229_i_FrightAmount += _vm->_championMan->f303_getSkillLevel(champIndex, k14_ChampionSkillInfluence);
+	L1233_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing);
+	L1234_ps_CreatureInfo = &g243_CreatureInfo[L1233_ps_Group->_type];
+	if (((L1230_ui_FearResistance = L1234_ps_CreatureInfo->M57_getFearResistance()) > _vm->getRandomNumber(L1229_i_FrightAmount)) || (L1230_ui_FearResistance == k15_immuneToFear)) {
+		L1231_ui_Experience >>= 1;
+	} else {
+		L1235_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[L1233_ps_Group->getActiveGroupIndex()];
+		if (L1233_ps_Group->getBehaviour() == k6_behavior_ATTACK) {
+			_vm->_groupMan->f182_stopAttacking(L1235_ps_ActiveGroup, mapX, mapY);
+			_vm->_groupMan->f180_startWanedring(mapX, mapY);
+		}
+		L1233_ps_Group->setBehaviour(k5_behavior_FLEE);
+		L1235_ps_ActiveGroup->_delayFleeingFromTarget = ((16 - L1230_ui_FearResistance) << 2) / L1234_ps_CreatureInfo->_movementTicks;
+		L1232_B_IsGroupFrightenedByAction = true;
+	}
+	_vm->_championMan->f304_addSkillExperience(champIndex, k14_ChampionSkillInfluence, L1231_ui_Experience);
+T0401016:
+	return L1232_B_IsGroupFrightenedByAction;
+}
+
+void MenuMan::f381_printMessageAfterReplacements(char* str) {
+	char* L1164_pc_Character;
+	char* L1165_pc_ReplacementString;
+	char L1166_ac_OutputString[128];
+
+
+	L1164_pc_Character = L1166_ac_OutputString;
+	*L1164_pc_Character++ = '\n'; /* New line */
+	do {
+		if (*str == '@') {
+			str++;
+			if (*(L1164_pc_Character - 1) != '\n') { /* New line */
+				*L1164_pc_Character++ = ' ';
+			}
+			switch (*str) {
+			case 'p': /* '@p' in the source string is replaced by the champion name followed by a space */
+				L1165_pc_ReplacementString = _vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)]._name;
+			}
+			*L1164_pc_Character = '\0';
+			strcat(L1166_ac_OutputString, L1165_pc_ReplacementString);
+			L1164_pc_Character += strlen(L1165_pc_ReplacementString);
+			*L1164_pc_Character++ = ' ';
+		} else {
+			*L1164_pc_Character++ = *str;
+		}
+	} while (*str++);
+	*L1164_pc_Character = '\0';
+	if (L1166_ac_OutputString[1]) { /* If the string is not empty (the first character is a new line \n) */
+		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, L1166_ac_OutputString);
+	}
+}
+
+void MenuMan::f389_processCommands116To119_setActingChampion(uint16 champIndex) {
+	static ActionSet G0489_as_Graphic560_ActionSets[44] = {
+		/* { ActionIndices[0], ActionIndices[1], ActionIndices[2], ActionProperties[0], ActionProperties[1], Useless } */
+		ActionSet(255, 255, 255, 0x00, 0x00),
+		ActionSet(27,  43,  35, 0x00, 0x00),
+		ActionSet(6,   7,   8, 0x00, 0x00),
+		ActionSet(0,   0,   0, 0x00, 0x00),
+		ActionSet(0,   0,   0, 0x00, 0x00),
+		ActionSet(13, 255, 255, 0x00, 0x00),
+		ActionSet(13,  20, 255, 0x87, 0x00),
+		ActionSet(13,  23, 255, 0x83, 0x00),
+		ActionSet(28,  41,  22, 0x02, 0x83),
+		ActionSet(16,   2,  23, 0x00, 0x84),
+		ActionSet(2,  25,  20, 0x02, 0x86),
+		ActionSet(17,  41,  34, 0x03, 0x05),
+		ActionSet(42,   9,  28, 0x00, 0x02),
+		ActionSet(13,  17,   2, 0x02, 0x03),
+		ActionSet(16,  17,  15, 0x01, 0x05),
+		ActionSet(28,  17,  25, 0x01, 0x05),
+		ActionSet(2,  25,  15, 0x05, 0x06),
+		ActionSet(9,   2,  29, 0x02, 0x05),
+		ActionSet(16,  29,  24, 0x02, 0x04),
+		ActionSet(13,  15,  19, 0x05, 0x07),
+		ActionSet(13,   2,  25, 0x00, 0x05),
+		ActionSet(2,  29,  19, 0x03, 0x08),
+		ActionSet(13,  30,  31, 0x02, 0x04),
+		ActionSet(13,  31,  25, 0x03, 0x06),
+		ActionSet(42,  30, 255, 0x00, 0x00),
+		ActionSet(0,   0,   0, 0x00, 0x00),
+		ActionSet(42,   9, 255, 0x00, 0x00),
+		ActionSet(32, 255, 255, 0x00, 0x00),
+		ActionSet(37,  33,  36, 0x82, 0x03),
+		ActionSet(37,  33,  34, 0x83, 0x84),
+		ActionSet(17,  38,  21, 0x80, 0x83),
+		ActionSet(13,  21,  34, 0x83, 0x84),
+		ActionSet(36,  37,  41, 0x02, 0x03),
+		ActionSet(13,  23,  39, 0x82, 0x84),
+		ActionSet(13,  17,  40, 0x00, 0x83),
+		ActionSet(17,  36,  38, 0x03, 0x84),
+		ActionSet(4, 255, 255, 0x00, 0x00),
+		ActionSet(5, 255, 255, 0x00, 0x00),
+		ActionSet(11, 255, 255, 0x00, 0x00),
+		ActionSet(10, 255, 255, 0x00, 0x00),
+		ActionSet(42,   9, 255, 0x00, 0x00),
+		ActionSet(1,  12, 255, 0x02, 0x00),
+		ActionSet(42, 255, 255, 0x00, 0x00),
+		ActionSet(6,  11, 255, 0x80, 0x00)};
+	uint16 L1188_ui_ActionSetIndex;
+	Thing L1189_T_Thing;
+	Champion* L1190_ps_Champion;
+	ActionSet* L1191_ps_ActionSet;
+
+
+	L1190_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	if (getFlag(L1190_ps_Champion->_attributes, k0x0008_ChampionAttributeDisableAction) || !L1190_ps_Champion->_currHealth) {
+		return;
+	}
+	if ((L1189_T_Thing = L1190_ps_Champion->_slots[k1_ChampionSlotActionHand]) == Thing::_none) {
+		L1188_ui_ActionSetIndex = 2; /* Actions Punck, Kick and War Cry */
+	} else {
+		if ((L1188_ui_ActionSetIndex = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1189_T_Thing)]._actionSetIndex) == 0) {
+			return;
+		}
+	}
+	L1191_ps_ActionSet = &G0489_as_Graphic560_ActionSets[L1188_ui_ActionSetIndex];
+	_vm->_championMan->_g506_actingChampionOrdinal = _vm->M0_indexToOrdinal(champIndex);
+	f383_setActionList(L1191_ps_ActionSet);
+	_g509_actionAreaContainsIcons = false;
+	setFlag(L1190_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand);
+	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+	f387_drawActionArea();
+	f387_drawActionArea();
+}
+
+void MenuMan::f383_setActionList(ActionSet* actionSet) {
+
+#define k0x0080_actionRequiresCharge 0x0080 // @ MASK0x0080_ACTION_REQUIRES_CHARGE 
+
+	uint16 L1169_ui_ActionListIndex;
+	uint16 L1170_ui_NextAvailableActionListIndex;
+	uint16 L1171_ui_ActionIndex;
+	uint16 L1172_ui_MinimumSkillLevel;
+
+	_g713_actionList._actionIndices[0] = (ChampionAction)actionSet->_actionIndices[0];
+	_g713_actionList._minimumSkillLevel[0] = 1;
+	L1170_ui_NextAvailableActionListIndex = 1;
+	for (L1169_ui_ActionListIndex = 1; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) {
+		if ((L1171_ui_ActionIndex = actionSet->_actionIndices[L1169_ui_ActionListIndex]) == k255_ChampionActionNone)
+			continue;
+		if (getFlag(L1172_ui_MinimumSkillLevel = actionSet->_actionProperties[L1169_ui_ActionListIndex - 1], k0x0080_actionRequiresCharge) && !f382_getActionObjectChargeCount())
+			continue;
+		clearFlag(L1172_ui_MinimumSkillLevel, k0x0080_actionRequiresCharge);
+		if (_vm->_championMan->f303_getSkillLevel(_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal), g496_ActionSkillIndex[L1171_ui_ActionIndex]) >= L1172_ui_MinimumSkillLevel) {
+			_g713_actionList._actionIndices[L1170_ui_NextAvailableActionListIndex] = (ChampionAction)L1171_ui_ActionIndex;
+			_g713_actionList._minimumSkillLevel[L1170_ui_NextAvailableActionListIndex] = L1172_ui_MinimumSkillLevel;
+			L1170_ui_NextAvailableActionListIndex++;
+		}
+	}
+	_g507_actionCount = L1170_ui_NextAvailableActionListIndex;
+	for (L1169_ui_ActionListIndex = L1170_ui_NextAvailableActionListIndex; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) {
+		_g713_actionList._actionIndices[L1169_ui_ActionListIndex] = k255_ChampionActionNone;
+	}
+}
+
+int16 MenuMan::f382_getActionObjectChargeCount() {
+	Thing L1167_T_Thing;
+	Junk* L1168_ps_Junk;
+
+
+	L1168_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1167_T_Thing = _vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand]);
+	switch (L1167_T_Thing.getType()) {
+	case k5_WeaponThingType:
+		return ((Weapon*)L1168_ps_Junk)->getChargeCount();
+	case k6_ArmourThingType:
+		return ((Armour*)L1168_ps_Junk)->getChargeCount();
+	case k10_JunkThingType:
+		return L1168_ps_Junk->getChargeCount();
+	default:
+		return 1;
+	}
+}
+
+void MenuMan::f385_drawActionDamage(int16 damage) {
+	static const Box G0502_s_Graphic560_Box_ActionAreaMediumDamage = Box(242, 305, 81, 117);
+	static const Box G0503_s_Graphic560_Box_ActionAreaSmallDamage = Box(251, 292, 81, 117);
+
+	uint16 L1174_ui_Multiple;
+#define AL1174_ui_DerivedBitmapIndex L1174_ui_Multiple
+#define AL1174_ui_CharacterIndex     L1174_ui_Multiple
+	int16 L1175_i_ByteWidth;
+	int16 L1176_i_Multiple;
+#define AL1176_i_X          L1176_i_Multiple
+#define AL1176_i_PixelWidth L1176_i_Multiple
+	byte* L1177_puc_Bitmap;
+	unsigned char* L1178_puc_Multiple;
+#define AL1178_puc_String L1178_puc_Multiple
+#define AL1178_puc_Bitmap L1178_puc_Multiple
+	char L1179_ac_String[6];
+	const Box* L1180_ps_Box;
+	int16 L1643_i_Width;
+
+	_vm->_eventMan->f78_showMouse();
+	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	_vm->_displayMan->D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack);
+	if (damage < 0) {
+		if (damage == kM1_damageCantReach) {
+			AL1176_i_X = 242;
+			AL1178_puc_String = (unsigned char*)"CAN'T REACH"; // TODO: localization
+		} else {
+			AL1176_i_X = 248;
+			AL1178_puc_String = (unsigned char*)"NEED AMMO"; // TODO: localization
+		}
+		_vm->_textMan->f53_printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, (char *)AL1178_puc_String);
+	} else {
+		if (damage > 40) {
+			L1180_ps_Box = &g499_BoxActionArea3ActionMenu;
+			L1177_puc_Bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
+			L1175_i_ByteWidth = k48_byteWidth;
+			L1643_i_Width = 45;
+		} else {
+			if (damage > 15) {
+				AL1174_ui_DerivedBitmapIndex = k2_DerivedBitmapDamageToCreatureMedium;
+				AL1176_i_PixelWidth = 64;
+				L1175_i_ByteWidth = k32_byteWidth;
+				L1180_ps_Box = &G0502_s_Graphic560_Box_ActionAreaMediumDamage;
+			} else {
+				AL1174_ui_DerivedBitmapIndex = k3_DerivedBitmapDamageToCreatureSmall;
+				AL1176_i_PixelWidth = 42;
+				L1175_i_ByteWidth = k24_byteWidth;
+				L1180_ps_Box = &G0503_s_Graphic560_Box_ActionAreaSmallDamage;
+			}
+			L1643_i_Width = 37;
+			if (!_vm->_displayMan->f491_isDerivedBitmapInCache(AL1174_ui_DerivedBitmapIndex)) {
+				AL1178_puc_Bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
+				_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(AL1178_puc_Bitmap, L1177_puc_Bitmap = _vm->_displayMan->f492_getDerivedBitmap(AL1174_ui_DerivedBitmapIndex), 96, 45, AL1176_i_PixelWidth, 37, g17_PalChangesNoChanges);
+				_vm->_displayMan->f493_addDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
+			} else {
+				L1177_puc_Bitmap = _vm->_displayMan->f492_getDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
+			}
+		}
+		_vm->_displayMan->f21_blitToScreen(L1177_puc_Bitmap, (int16 *)L1180_ps_Box, L1175_i_ByteWidth, kM1_ColorNoTransparency, L1643_i_Width);
+		/* Convert damage value to string */
+		AL1174_ui_CharacterIndex = 5;
+		AL1176_i_X = 274;
+		L1179_ac_String[5] = '\0';
+		do {
+			L1179_ac_String[--AL1174_ui_CharacterIndex] = '0' + (damage % 10);
+			AL1176_i_X -= 3;
+		} while (damage /= 10);
+		_vm->_textMan->f53_printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, &L1179_ac_String[AL1174_ui_CharacterIndex]);
+	}
+	_vm->_eventMan->f77_hideMouse();
+}
+}


Commit: 0ab1a2a51ecf2f63a00dc3442b06a9c313cae536
    https://github.com/scummvm/scummvm/commit/0ab1a2a51ecf2f63a00dc3442b06a9c313cae536
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Reorder MenuMan::f393_drawSpellAreaControls

Changed paths:
    engines/dm/menus.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 6506999..3d8f313 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -297,71 +297,69 @@ const char* MenuMan::f384_getActionName(ChampionAction actionIndex) {
 Box g504_BoxSpellAreaControls = Box(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls 
 
 void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) {
-	ChampionMan &champMan = *_vm->_championMan;
-	DisplayMan &dispMan = *_vm->_displayMan;
-	TextMan &textMan = *_vm->_textMan;
-
-	Champion &champ = champMan._gK71_champions[champIndex];
-	int16 champCurrHealth[4];
-	for (uint16 i = 0; i < 4; ++i)
-		champCurrHealth[i] = champMan._gK71_champions[i]._currHealth;
+
+
+	Champion *champ = &_vm->_championMan->_gK71_champions[champIndex];
+	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	int16 champHP0 = _vm->_championMan->_gK71_champions[0]._currHealth;
+	int16 champHP1 = _vm->_championMan->_gK71_champions[1]._currHealth;
+	int16 champHP2 = _vm->_championMan->_gK71_champions[2]._currHealth;
+	int16 champHP3 = _vm->_championMan->_gK71_champions[3]._currHealth;
+	_vm->_eventMan->f78_showMouse();
+	_vm->_displayMan->D24_fillScreenBox(g504_BoxSpellAreaControls, k0_ColorBlack);
+	switch (champIndex) {
+	case 0:
+		_vm->_eventMan->f6_highlightScreenBox(233, 277, 42, 49);
+		_vm->_textMan->f53_printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
+		if (_vm->_championMan->_g305_partyChampionCount > 1) {
+			if (champHP1) {
+				_vm->_eventMan->f6_highlightScreenBox(280, 291, 42, 48);
+			}
+T0393002:
+			if (_vm->_championMan->_g305_partyChampionCount > 2) {
+				if (champHP2) {
+					_vm->_eventMan->f6_highlightScreenBox(294, 305, 42, 48);
+				}
+T0393003:
+				if (_vm->_championMan->_g305_partyChampionCount > 3) {
+					if (champHP3) {
+						_vm->_eventMan->f6_highlightScreenBox(308, 319, 42, 48);
+					}
+				}
+			}
+		}
+		break;
+	case 1:
+		if (champHP0) {
+			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
+		}
+		_vm->_eventMan->f6_highlightScreenBox(247, 291, 42, 49);
+		_vm->_textMan->f53_printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
+		goto T0393002;
+	case 2:
+		if (champHP0) {
+			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
+		}
+		if (champHP1) {
+			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
+		}
+		_vm->_eventMan->f6_highlightScreenBox(261, 305, 42, 49);
+		_vm->_textMan->f53_printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
+		goto T0393003;
+	case 3:
+		if (champHP0) {
+			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
+		}
+		if (champHP1) {
+			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
+		}
+		if (champHP2) {
+			_vm->_eventMan->f6_highlightScreenBox(261, 272, 42, 48);
+		}
+		_vm->_eventMan->f6_highlightScreenBox(275, 319, 42, 49);
+		_vm->_textMan->f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
+	}
 	_vm->_eventMan->f77_hideMouse();
-	dispMan.D24_fillScreenBox(g504_BoxSpellAreaControls, k0_ColorBlack);
-	int16 champCount = champMan._g305_partyChampionCount;
-	switch (champIndex) {
-	case k0_ChampionFirst:
-		_vm->_eventMan->f6_highlightScreenBox(233, 277, 42, 49);
-		textMan.f53_printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
-		if (champCount) {
-			if (champCurrHealth[1]) {
-				_vm->_eventMan->f6_highlightScreenBox(280, 291, 42, 48);;
-			}
-labelChamp2:
-			if (champCount > 2) {
-				if (champCurrHealth[2]) {
-					_vm->_eventMan->f6_highlightScreenBox(294, 305, 42, 48);
-				}
-labelChamp3:
-				if (champCount > 3) {
-					if (champCurrHealth[3]) {
-						_vm->_eventMan->f6_highlightScreenBox(308, 319, 42, 48);
-					}
-				}
-			}
-		}
-		break;
-	case k1_ChampionSecond:
-		if (champCurrHealth[0]) {
-			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
-		}
-		_vm->_eventMan->f6_highlightScreenBox(247, 291, 42, 49);
-		textMan.f53_printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
-		goto labelChamp2;
-	case k2_ChampionThird:
-		if (champCurrHealth[0]) {
-			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
-		}
-		if (champCurrHealth[1]) {
-			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
-		}
-		_vm->_eventMan->f6_highlightScreenBox(261, 305, 42, 49);
-		textMan.f53_printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
-		goto labelChamp3;
-	case k3_ChampionFourth:
-		if (champCurrHealth[0]) {
-			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
-		}
-		if (champCurrHealth[1]) {
-			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
-		}
-		if (champCurrHealth[2]) {
-			_vm->_eventMan->f6_highlightScreenBox(261, 272, 42, 48);
-		}
-		_vm->_eventMan->f6_highlightScreenBox(275, 319, 42, 49);
-		textMan.f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ._name);
-		break;
-	}
-	_vm->_eventMan->f78_showMouse();
 }
 
 #define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
@@ -389,7 +387,6 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
 			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 9, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
 		}
 	}
-
 }
 
 void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {


Commit: 6885cf6e593d1739ae2e864d3f568bb5ccb77222
    https://github.com/scummvm/scummvm/commit/6885cf6e593d1739ae2e864d3f568bb5ccb77222
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix broken spell symbols

Changed paths:
    engines/dm/text.cpp



diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 68ea14f..17531a1 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -72,7 +72,7 @@ void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int1
 		}
 		if (nextY + k6_LetterHeight >= destHeight)
 			break;
-		uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
+		uint16 srcX = (1 + 5) * *begin; // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
 
 		Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1);
 		_vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128 / 2, destByteWidth, kM1_ColorNoTransparency);


Commit: 69c5b01e127c5f2c63469ea04fcb51fc6dd0ee37
    https://github.com/scummvm/scummvm/commit/69c5b01e127c5f2c63469ea04fcb51fc6dd0ee37
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f155_getStairsExitDirection

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 8816ed7..0da7ccd 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1568,19 +1568,22 @@ void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList
 }
 
 int16 DungeonMan::f155_getStairsExitDirection(int16 mapX, int16 mapY) {
-	int16 L0256_i_SquareType;
-	bool L0257_B_NorthSouthOrientedStairs;
+	bool northSouthOrientedStairs = !getFlag(f151_getSquare(mapX, mapY).toByte(), k0x0008_StairsNorthSouthOrient);
 
-
-	if (L0257_B_NorthSouthOrientedStairs = !getFlag(f151_getSquare(mapX, mapY).toByte(), k0x0008_StairsNorthSouthOrient)) {
+	if (northSouthOrientedStairs) {
 		mapX = mapX + _vm->_dirIntoStepCountEast[kDirEast];
 		mapY = mapY + _vm->_dirIntoStepCountNorth[kDirEast];
 	} else {
 		mapX = mapX + _vm->_dirIntoStepCountEast[kDirNorth];
 		mapY = mapY + _vm->_dirIntoStepCountNorth[kDirNorth];
 	}
-	return ((((L0256_i_SquareType = Square(f151_getSquare(mapX, mapY)).getType()) == k0_ElementTypeWall) || (L0256_i_SquareType == k3_ElementTypeStairs)) << 1) + L0257_B_NorthSouthOrientedStairs;
+	int16 squareType = Square(f151_getSquare(mapX, mapY)).getType();
+
+	int16 retval = ((squareType == k0_ElementTypeWall) || (squareType == k3_ElementTypeStairs)) ? 1 : 0;
+	retval <<= 1;
+	retval += (northSouthOrientedStairs ? 1 : 0);
 
+	return retval;
 }
 
 Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {


Commit: b41f86651f827ebfdd492e494b79a9bb5207b09b
    https://github.com/scummvm/scummvm/commit/b41f86651f827ebfdd492e494b79a9bb5207b09b
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f167_getObjForProjectileLaucherOrObjGen

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 0da7ccd..7056ab6 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1587,57 +1587,56 @@ int16 DungeonMan::f155_getStairsExitDirection(int16 mapX, int16 mapY) {
 }
 
 Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {
-	int16 L0293_i_Type;
-	int16 L0294_i_ThingType;
-	Thing L0295_T_Thing;
-	Junk* L0296_ps_Junk;
+	int16 thingType = k5_WeaponThingType;
+	if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit))
+		iconIndex = k4_IconIndiceWeaponTorchUnlit;
 
+	int16 junkType;
 
-	L0294_i_ThingType = k5_WeaponThingType;
-	if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit)) {
-		iconIndex = k4_IconIndiceWeaponTorchUnlit;
-	}
 	switch (iconIndex) {
 	case k54_IconIndiceWeaponRock:
-		L0293_i_Type = k30_WeaponTypeRock;
+		junkType = k30_WeaponTypeRock;
 		break;
 	case k128_IconIndiceJunkBoulder:
-		L0293_i_Type = k25_JunkTypeBoulder;
-		L0294_i_ThingType = k10_JunkThingType;
+		junkType = k25_JunkTypeBoulder;
+		thingType = k10_JunkThingType;
 		break;
 	case k51_IconIndiceWeaponArrow:
-		L0293_i_Type = k27_WeaponTypeArrow;
+		junkType = k27_WeaponTypeArrow;
 		break;
 	case k52_IconIndiceWeaponSlayer:
-		L0293_i_Type = k28_WeaponTypeSlayer;
+		junkType = k28_WeaponTypeSlayer;
 		break;
 	case k55_IconIndiceWeaponPoisonDart:
-		L0293_i_Type = k31_WeaponTypePoisonDart;
+		junkType = k31_WeaponTypePoisonDart;
 		break;
 	case k56_IconIndiceWeaponThrowingStar:
-		L0293_i_Type = k32_WeaponTypeThrowingStar;
+		junkType = k32_WeaponTypeThrowingStar;
 		break;
 	case k32_IconIndiceWeaponDagger:
-		L0293_i_Type = k8_WeaponTypeDagger;
+		junkType = k8_WeaponTypeDagger;
 		break;
 	case k4_IconIndiceWeaponTorchUnlit:
-		L0293_i_Type = k2_WeaponTypeTorch;
+		junkType = k2_WeaponTypeTorch;
 		break;
 	default:
 		return Thing::_none;
 	}
-	if ((L0295_T_Thing = f166_getUnusedThing(L0294_i_ThingType)) == Thing::_none) {
+
+	Thing unusedThing = f166_getUnusedThing(thingType);
+	if (unusedThing == Thing::_none)
 		return Thing::_none;
-	}
-	L0296_ps_Junk = (Junk*)f156_getThingData(L0295_T_Thing);
-	L0296_ps_Junk->setType(L0293_i_Type); /* Also works for WEAPON in cases other than Boulder */
-	if ((iconIndex == k4_IconIndiceWeaponTorchUnlit) && ((Weapon*)L0296_ps_Junk)->isLit()) { /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */
-		((Weapon*)L0296_ps_Junk)->setChargeCount(15);
-	}
-	return L0295_T_Thing;
+
+	Junk *junkPtr = (Junk*)f156_getThingData(unusedThing);
+	junkPtr->setType(junkType); /* Also works for WEAPON in cases other than Boulder */
+	if ((iconIndex == k4_IconIndiceWeaponTorchUnlit) && ((Weapon*)junkPtr)->isLit()) /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */
+		((Weapon*)junkPtr)->setChargeCount(15);
+
+	return unusedThing;
 }
 
 int16 DungeonMan::f169_getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo) {
+	// TODO: Use ScummVM random number generator
 	return ((((((val1 * 31417) & 0xFFFF) >> 1) + ((val2 * 11) & 0xFFFF)
 			  + _g278_dungeonFileHeader._ornamentRandomSeed) & 0xFFFF) >> 2) % modulo; /* Pseudorandom number generator */
 }


Commit: c97b5e170f02ad36d3ae5b6333545e363a025d80
    https://github.com/scummvm/scummvm/commit/c97b5e170f02ad36d3ae5b6333545e363a025d80
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f68_setPointerToObject

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index b0d6053..6d52c37 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -395,12 +395,12 @@ void EventManager::f67_setMousePointerToNormal(int16 mousePointer) {
 }
 
 void EventManager::f68_setPointerToObject(byte* bitmap) {
-	static byte gK27_palChangesMousepointerOjbectIconShadow[16] = {120, 120, 120, 120, 120, 120, 120, 120,
+	static byte palChangesMousepointerOjbectIconShadow[16] = {120, 120, 120, 120, 120, 120, 120, 120,
 		120, 120, 120, 120, 0, 120, 120, 120}; // @ K0027_auc_PaletteChanges_MousePointerObjectIconShadow
-	static byte g44_palChangesMousePointerIcon[16] = {120, 10, 20, 30, 40, 50, 60, 70, 80, 90,
+	static byte palChangesMousePointerIcon[16] = {120, 10, 20, 30, 40, 50, 60, 70, 80, 90,
 		100, 110, 0, 130, 140, 150}; // @ G0044_auc_Graphic562_PaletteChanges_MousePointerIcon
-	static Box g619_BoxMousePointerObjectShadow(2, 17, 2, 17); // @ G0619_s_Box_MousePointer_ObjectShadow 
-	static Box g620_BoxMousePointerObject(0, 15, 0, 15); // @ G0620_s_Box_MousePointer_Object 
+	static Box boxMousePointerObjectShadow(2, 17, 2, 17); // @ G0619_s_Box_MousePointer_ObjectShadow 
+	static Box boxMousePointerObject(0, 15, 0, 15); // @ G0620_s_Box_MousePointer_Object 
 
 	_gK100_preventBuildPointerScreenArea = true;
 	_g600_useObjectAsMousePointerBitmap = true;
@@ -411,15 +411,16 @@ void EventManager::f68_setPointerToObject(byte* bitmap) {
 	memset(L0051_puc_Bitmap, 0, 32 * 18);
 
 	/*
-	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, gK27_palChangesMousepointerOjbectIconShadow);
-	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
-	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, g44_palChangesMousePointerIcon);
-	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
+	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, palChangesMousepointerOjbectIconShadow);
+	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, boxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
+	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, palChangesMousePointerIcon);
+	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, boxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
 	*/
+
 	warning(false, "TODO - Call f129_blitToBitmapShrinkWithPalChange");
 	// dummy code
-	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
-	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
+	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, boxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
+	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, boxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
 
 	_gK100_preventBuildPointerScreenArea = false;
 	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
@@ -427,12 +428,12 @@ void EventManager::f68_setPointerToObject(byte* bitmap) {
 
 void EventManager::f71_mouseDropChampionIcon() {
 	_gK100_preventBuildPointerScreenArea = true;
-	uint16 L0058_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_g599_useChampionIconOrdinalAsMousePointerBitmap);
+	uint16 championIconIndex = _vm->M1_ordinalToIndex(_g599_useChampionIconOrdinalAsMousePointerBitmap);
 	_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
 	_g598_mousePointerBitmapUpdated = true;
-	bool L0057_B_UseByteBoxCoordinatesBackup = _vm->_displayMan->_g578_useByteBoxCoordinates;
-	_vm->_displayMan->f21_blitToScreen(_g613_mousePointerOriginalColorsChampionIcon, &g54_BoxChampionIcons[L0058_ui_ChampionIconIndex << 2], 16, k12_ColorDarkestGray, 18);
-	_vm->_displayMan->_g578_useByteBoxCoordinates = L0057_B_UseByteBoxCoordinatesBackup;
+	bool useByteBoxCoordinatesBackup = _vm->_displayMan->_g578_useByteBoxCoordinates;
+	_vm->_displayMan->f21_blitToScreen(_g613_mousePointerOriginalColorsChampionIcon, &g54_BoxChampionIcons[championIconIndex << 2], 16, k12_ColorDarkestGray, 18);
+	_vm->_displayMan->_g578_useByteBoxCoordinates = useByteBoxCoordinatesBackup;
 	_gK100_preventBuildPointerScreenArea = false;
 }
 


Commit: 1690a717efbf69eda36e5f0d6c1d0342e4c3a640
    https://github.com/scummvm/scummvm/commit/1690a717efbf69eda36e5f0d6c1d0342e4c3a640
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f73_buildpointerScreenArea, enable code in f78_showMouse and f77_hideMouse

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 6d52c37..a54c691 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -438,9 +438,6 @@ void EventManager::f71_mouseDropChampionIcon() {
 }
 
 void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY) {
-	uint16 L1577_i_ChampionIndex;
-	int16 L1578_i_XOverChampionStatusBox;
-
 	// if (_gK100_preventBuildPointerScreenArea)
 	//	return;
 
@@ -449,50 +446,36 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY)
 		if ((mousePosY > 28) || (mousePosX < 274)) {
 			_gK104_mousePointerType = k4_pointerTypeAutoselect;
 			f71_mouseDropChampionIcon();
-		} else {
+		} else
 			_gK104_mousePointerType = k2_pointerTypeChampionIcon;
-		}
-	} else {
-		if (mousePosY >= 169) {
-			_gK104_mousePointerType = k0_pointerTypeArrow;
-		} else {
-			if (mousePosX >= 274) {
+	} else if (mousePosY >= 169)
+		_gK104_mousePointerType = k0_pointerTypeArrow;
+	else if (mousePosX >= 274)
+		_gK104_mousePointerType = k0_pointerTypeArrow;
+	else if (mousePosY <= 28) {
+		uint16 championIdx = mousePosX / 69;
+		uint16 xOverChampionStatusBox = mousePosX % 69;
+		if (championIdx >= _vm->_championMan->_g305_partyChampionCount)
+			_gK104_mousePointerType = k4_pointerTypeAutoselect;
+		else if (xOverChampionStatusBox > 42)
+			_gK104_mousePointerType = k4_pointerTypeAutoselect;
+		else {
+			championIdx++;
+			if (championIdx == _vm->_inventoryMan->_g432_inventoryChampionOrdinal)
 				_gK104_mousePointerType = k0_pointerTypeArrow;
-			} else {
-				if (mousePosY <= 28) {
-					L1577_i_ChampionIndex = mousePosX / 69;
-					L1578_i_XOverChampionStatusBox = mousePosX % 69;
-					if (L1577_i_ChampionIndex >= _vm->_championMan->_g305_partyChampionCount) {
-						_gK104_mousePointerType = k4_pointerTypeAutoselect;
-					} else {
-						if (L1578_i_XOverChampionStatusBox > 42) {
-							_gK104_mousePointerType = k4_pointerTypeAutoselect;
-						} else {
-							L1577_i_ChampionIndex++;
-							if (L1577_i_ChampionIndex == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
-								_gK104_mousePointerType = k0_pointerTypeArrow;
-							} else {
-								if (mousePosY <= 6) {
-									_gK104_mousePointerType = k0_pointerTypeArrow;
-								} else {
-									_gK104_mousePointerType = k4_pointerTypeAutoselect;
-								}
-							}
-						}
-					}
-				} else {
-					if (mousePosX >= 224) {
-						_gK104_mousePointerType = k0_pointerTypeArrow;
-					} else {
-						_gK104_mousePointerType = k4_pointerTypeAutoselect;
-					}
-				}
-			}
+			else if (mousePosY <= 6)
+				_gK104_mousePointerType = k0_pointerTypeArrow;
+			else
+				_gK104_mousePointerType = k4_pointerTypeAutoselect;
 		}
-	}
-	if (_gK104_mousePointerType == k4_pointerTypeAutoselect) {
+	} else if (mousePosX >= 224)
+		_gK104_mousePointerType = k0_pointerTypeArrow;
+	else
+		_gK104_mousePointerType = k4_pointerTypeAutoselect;
+
+	if (_gK104_mousePointerType == k4_pointerTypeAutoselect)
 		_gK104_mousePointerType = (_g600_useObjectAsMousePointerBitmap) ? k1_pointerTypeObjectIcon : (_g601_useHandAsMousePointerBitmap) ? k3_pointerTypeHand : k0_pointerTypeArrow;
-	}
+
 	if (_g598_mousePointerBitmapUpdated || (_gK104_mousePointerType != _gK105_previousMousePointerType)) {
 		_g598_mousePointerBitmapUpdated = false;
 		switch (_gK104_mousePointerType) {
@@ -515,21 +498,20 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY)
 }
 
 void EventManager::f69_setMousePointer() {
-	if (_vm->_championMan->_g415_leaderEmptyHanded) {
+	if (_vm->_championMan->_g415_leaderEmptyHanded)
 		f67_setMousePointerToNormal((_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
-	} else {
+	else
 		f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
-	}
 }
 
 void EventManager::f78_showMouse() {
-	//if(_g587_hideMousePointerRequestCount++ == 0)
-	CursorMan.showMouse(true);
+	if(_g587_hideMousePointerRequestCount++ == 0)
+		CursorMan.showMouse(true);
 }
 
 void EventManager::f77_hideMouse() {
-	// if(_g587_hideMousePointerRequestCount-- == 1)
-	// CursorMan.showMouse(false);
+	if(_g587_hideMousePointerRequestCount-- == 1)
+		CursorMan.showMouse(false);
 }
 
 bool EventManager::isMouseButtonDown(MouseButton button) {
@@ -540,7 +522,6 @@ void EventManager::setMousePos(Common::Point pos) {
 	_vm->_system->warpMouse(pos.x, pos.y);
 }
 
-
 Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Event *grabMouseClick) {
 	Common::Event event;
 	while (_vm->_system->getEventManager()->pollEvent(event)) {
@@ -548,10 +529,12 @@ Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Eve
 		case Common::EVENT_KEYDOWN: {
 			if (event.synthetic)
 				break;
+
 			if (grabKey) {
 				*grabKey = event;
 				return event.type;
 			}
+
 			if (_g443_primaryKeyboardInput) {
 				KeyboardInput *input = _g443_primaryKeyboardInput;
 				while (input->_commandToIssue != k0_CommandNone) {
@@ -637,8 +620,8 @@ void EventManager::f359_processClick(Common::Point mousePos, MouseButton button)
 CommandType EventManager::f358_getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button) {
 	if (!input)
 		return k0_CommandNone;
-	CommandType commandType = k0_CommandNone;
 
+	CommandType commandType = k0_CommandNone;
 	while ((commandType = input->_commandTypeToIssue) != k0_CommandNone) {
 		if (input->_hitbox.isPointInside(mousePos) && input->_button == button)
 			break;


Commit: 1be1728c951e4f81755e870e7a95811a85351fd4
    https://github.com/scummvm/scummvm/commit/1be1728c951e4f81755e870e7a95811a85351fd4
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing code setting _g587_hideMousePointerRequestCount

Changed paths:
    engines/dm/eventman.cpp
    engines/dm/inventory.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index a54c691..8258ef0 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -357,6 +357,7 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 	_g443_primaryKeyboardInput = nullptr;
 	_g444_secondaryKeyboardInput = nullptr;
 	_g597_ignoreMouseMovements = false;
+	warning(false, "_g587_hideMousePointerRequestCount should start with value 1");
 	_g587_hideMousePointerRequestCount = 0;
 	_g558_mouseButtonStatus = 0;
 }
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 48f9716..84c1c59 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -733,7 +733,7 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 void InventoryMan::f350_drawStopPressingMouth() {
 	f347_drawPanel();
 	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
-	warning(false, "Ignored code: G0587_i_HideMousePointerRequestCount");
+	_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
 	_vm->_eventMan->f77_hideMouse();
 }
 


Commit: 50c5b39887288b34fd5c9eb25ade633bf43dff4d
    https://github.com/scummvm/scummvm/commit/50c5b39887288b34fd5c9eb25ade633bf43dff4d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add debugger console

Changed paths:
  A engines/dm/console.cpp
  A engines/dm/console.h
    engines/dm/dm.h
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/module.mk



diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
new file mode 100644
index 0000000..e261850
--- /dev/null
+++ b/engines/dm/console.cpp
@@ -0,0 +1,35 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#include "console.h"
+
+
+namespace DM {
+
+Console::Console(DM::DMEngine* vm) : _vm(vm) {}
+
+}
\ No newline at end of file
diff --git a/engines/dm/console.h b/engines/dm/console.h
new file mode 100644
index 0000000..eab2a32
--- /dev/null
+++ b/engines/dm/console.h
@@ -0,0 +1,42 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#include "gui/debugger.h"
+
+
+
+namespace DM {
+
+class DMEngine;
+
+class Console : public GUI::Debugger {
+	DMEngine *_vm;
+public:
+	explicit Console(DM::DMEngine *vm);
+	virtual ~Console(void) {}
+};
+}
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index d254f3d..ae16e13 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -30,16 +30,16 @@
 
 #include "common/random.h"
 #include "engines/engine.h"
-#include "gui/debugger.h"
 #include "common/savefile.h"
 #include "common/str.h"
 #include "engines/savestate.h"
 
+#include "console.h"
+
 
 
 namespace DM {
 
-class Console;
 class DisplayMan;
 class DungeonMan;
 class EventManager;
@@ -241,6 +241,7 @@ public:
 	explicit DMEngine(OSystem *syst);
 	~DMEngine();
 	virtual bool hasFeature(EngineFeature f) const;
+	GUI::Debugger *getDebugger() { return _console; }
 
 	void f22_delay(uint16 verticalBlank); // @ F0022_MAIN_Delay
 	uint16 f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2); // @ F0030_MAIN_GetScaledProduct
@@ -266,7 +267,6 @@ private:
 	int16 _g528_saveFormat; // @ G0528_i_Format
 	int16 _g527_platform; // @ G0527_i_Platform
 	uint16 _g526_dungeonId; // @ G0526_ui_DungeonID
-	Console *_console;
 	byte *_g562_entranceDoorAnimSteps[10]; // @ G0562_apuc_Bitmap_EntranceDoorAnimationSteps
 	byte *_g564_interfaceCredits; // @ G0564_puc_Graphic5_InterfaceCredits
 	Common::RandomSource *_rnd;
@@ -274,6 +274,7 @@ private:
 	Common::Queue<PendingSound> _pendingSounds;
 	byte *_savedScreenForOpenEntranceDoors; // ad-hoc HACK
 public:
+	Console *_console;
 	DisplayMan *_displayMan;
 	DungeonMan *_dungeonMan;
 	EventManager *_eventMan;
@@ -317,12 +318,6 @@ public:
 	int16 _g318_waitForInputMaxVerticalBlankCount; // @ G0318_i_WaitForInputMaximumVerticalBlankCount
 };
 
-class Console : public GUI::Debugger {
-public:
-	explicit Console(DMEngine *vm) {}
-	virtual ~Console(void) {}
-};
-
 } // End of namespace DM
 
 #endif
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 8258ef0..af875a9 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -531,6 +531,10 @@ Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Eve
 			if (event.synthetic)
 				break;
 
+			if (event.kbd.keycode == Common::KEYCODE_d && event.kbd.hasFlags(Common::KBD_CTRL)) {
+				_vm->_console->attach();
+			}
+
 			if (grabKey) {
 				*grabKey = event;
 				return event.type;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index fa2b442..41fb147 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1211,6 +1211,7 @@ byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale
 
 void DisplayMan::updateScreen() {
 	_vm->_system->copyRectToScreen(_g348_bitmapScreen, _screenWidth, 0, 0, _screenWidth, _screenHeight);
+	_vm->_console->onFrame();
 	_vm->_system->updateScreen();
 }
 
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index bf1cef8..559ebf1 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -30,6 +30,7 @@ MODULE := engines/dm
 
 MODULE_OBJS := \
 	champion.o \
+	console.o \
 	detection.o \
 	dialog.o \
 	dm.o \


Commit: 36395c5b268e80d01ceda2924a69c0e0d293f220
    https://github.com/scummvm/scummvm/commit/36395c5b268e80d01ceda2924a69c0e0d293f220
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add .gitattributes to repository

Changed paths:
  A engines/dm/.gitattributes



diff --git a/engines/dm/.gitattributes b/engines/dm/.gitattributes
new file mode 100644
index 0000000..8620362
--- /dev/null
+++ b/engines/dm/.gitattributes
@@ -0,0 +1,10 @@
+# Set the default behavior, in case people don't have core.autocrlf set.
+* text=auto
+
+# Explicitly declare text files you want to always be normalized and converted
+# to native line endings on checkout.
+*.cpp text
+*.h text
+
+# Declare files that will always have CRLF line endings on checkout.
+*.sln text eol=crlf


Commit: 50f3cfa625e338276e8a4d38836227877ab93e3a
    https://github.com/scummvm/scummvm/commit/50f3cfa625e338276e8a4d38836227877ab93e3a
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add debug command godmode

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/console.cpp
    engines/dm/console.h
    engines/dm/dm.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index cd59e2e..fc24288 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1,2501 +1,2508 @@
-/* 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.
-*
-*/
-
-/*
-* Based on the Reverse Engineering work of Christophe Fontanel,
-* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
-*/
-
-#include "champion.h"
-#include "dungeonman.h"
-#include "eventman.h"
-#include "menus.h"
-#include "inventory.h"
-#include "objectman.h"
-#include "text.h"
-#include "timeline.h"
-#include "projexpl.h"
-#include "group.h"
-#include "movesens.h"
-
-
-namespace DM {
-
-const char *g417_baseSkillName[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"};
-
-Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
-Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
-Box g54_BoxChampionIcons[4] = {
-	Box(281, 299,  0, 13),
-	Box(301, 319,  0, 13),
-	Box(301, 319, 15, 28),
-	Box(281, 299, 15, 28)};
-Color g46_ChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14};
-
-int16 g39_LightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100};
-
-uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
-						   /* 30 for champion inventory, 8 for chest */
-	0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Action Hand      Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0x0002,   /* Head             Head */
-	0x0008,   /* Torso            Torso */
-	0x0010,   /* Legs             Legs */
-	0x0020,   /* Feet             Feet */
-	0x0100,   /* Pouch 2          Pouch */
-	0x0080,   /* Quiver Line2 1   Quiver 2 */
-	0x0080,   /* Quiver Line1 2   Quiver 2 */
-	0x0080,   /* Quiver Line2 2   Quiver 2 */
-	0x0004,   /* Neck             Neck */
-	0x0100,   /* Pouch 1          Pouch */
-	0x0040,   /* Quiver Line1 1   Quiver 1 */
-	0xFFFF,   /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0x0400,   /* Chest 1          Chest */
-	0x0400,   /* Chest 2          Chest */
-	0x0400,   /* Chest 3          Chest */
-	0x0400,   /* Chest 4          Chest */
-	0x0400,   /* Chest 5          Chest */
-	0x0400,   /* Chest 6          Chest */
-	0x0400,   /* Chest 7          Chest */
-	0x0400}; /* Chest 8          Chest */
-
-Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
-
-ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
-	for (uint16 i = 0; i < 4; ++i) {
-		_g409_championPendingDamage[i] = 0;
-		_g410_championPendingWounds[i] = 0;
-		_gK71_champions[i].resetToZero();
-	}
-	_g305_partyChampionCount = 0;
-	_g303_partyDead = false;
-	_g414_leaderHandObject = Thing(0);
-	_g411_leaderIndex = kM1_ChampionNone;
-	_g299_candidateChampionOrdinal = 0;
-	_g300_partyIsSleeping = false;
-	_g506_actingChampionOrdinal = 0;
-	_g413_leaderHandObjectIconIndex = (IconIndice)0;
-	_g415_leaderEmptyHanded = false;
-	_g407_party.resetToZero();
-	_g514_magicCasterChampionIndex = kM1_ChampionNone;
-	_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
-}
-
-bool ChampionMan::f329_isLeaderHandObjectThrown(int16 side) {
-	if (_g411_leaderIndex == kM1_ChampionNone) {
-		return false;
-	}
-	return f328_isObjectThrown(_g411_leaderIndex, kM1_ChampionSlotLeaderHand, side);
-}
-
-bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side) {
-	bool throwingLeaderHandObjectFl = false;
-	Thing curThing;
-	Champion *curChampion = nullptr;
-	Thing actionHandThing;
-
-	if (slotIndex < 0) { /* Throw object in leader hand, which is temporarily placed in action hand */
-		if (_g415_leaderEmptyHanded)
-			return false;
-
-		curThing = f298_getObjectRemovedFromLeaderHand();
-		curChampion = &_gK71_champions[champIndex];
-		actionHandThing = curChampion->getSlot(k1_ChampionSlotActionHand);
-		curChampion->setSlot(k1_ChampionSlotActionHand, curThing);
-		slotIndex = k1_ChampionSlotActionHand;
-		throwingLeaderHandObjectFl = true;
-	}
-
-	int16 kineticEnergy = f312_getStrength(champIndex, slotIndex);
-	if (throwingLeaderHandObjectFl) {
-		// In this case, curChampion and actionHandThing are set.
-		curChampion->setSlot((ChampionSlot)slotIndex, actionHandThing);
-	} else {
-		curThing = f300_getObjectRemovedFromSlot(champIndex, slotIndex);
-		if (curThing == Thing::_none)
-			return false;
-	}
-
-	_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
-	f325_decrementStamina(champIndex, f305_getThrowingStaminaCost(curThing));
-	f330_disableAction(champIndex, 4);
-	int16 experience = 8;
-	int16 weaponKineticEnergy = 1;
-	if (curThing.getType() == k5_WeaponThingType) {
-		experience += 4;
-		WeaponInfo *curWeapon = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
-		if (curWeapon->_class <= k12_WeaponClassPoisinDart) {
-			weaponKineticEnergy = curWeapon->_kineticEnergy;
-			experience += weaponKineticEnergy >> 2;
-		}
-	}
-	f304_addSkillExperience(champIndex, k10_ChampionSkillThrow, experience);
-	kineticEnergy += weaponKineticEnergy;
-	int16 skillLevel = f303_getSkillLevel((ChampionIndex)champIndex, k10_ChampionSkillThrow);
-	kineticEnergy += _vm->getRandomNumber(16) + (kineticEnergy >> 1) + skillLevel;
-	int16 attack = f26_getBoundedValue((uint16)40, (uint16)((skillLevel << 3) + _vm->getRandomNumber(32)), (uint16)200);
-	int16 stepEnergy = MAX(5, 11 - skillLevel);
-	_vm->_projexpl->f212_projectileCreate(curThing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY,
-										  M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + side),
-										  _vm->_dungeonMan->_g308_partyDir, kineticEnergy, attack, stepEnergy);
-	_vm->_g311_projectileDisableMovementTicks = 4;
-	_vm->_g312_lastProjectileDisabledMovementDirection = _vm->_dungeonMan->_g308_partyDir;
-	f292_drawChampionState((ChampionIndex)champIndex);
-	return true;
-}
-
-uint16 ChampionMan::M27_getChampionPortraitX(uint16 index) {
-	return ((index) & 0x7) << 5;
-}
-
-uint16 ChampionMan::M28_getChampionPortraitY(uint16 index) {
-	return ((index) >> 3) * 29;
-}
-
-int16 ChampionMan::f279_getDecodedValue(char *string, uint16 characterCount) {
-	int val = 0;
-	for (uint16 i = 0; i < characterCount; ++i) {
-		val = (val << 4) + (string[i] - 'A');
-	}
-	return val;
-}
-
-void ChampionMan::f289_drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) {
-	Common::String tmp = f288_getStringFromInteger(currVal, true, 3);
-	_vm->_textMan->f52_printToViewport(55, posY, k13_ColorLightestGray, tmp.c_str());
-	_vm->_textMan->f52_printToViewport(73, posY, k13_ColorLightestGray, "/");
-	tmp = f288_getStringFromInteger(maxVal, true, 3);
-	_vm->_textMan->f52_printToViewport(79, posY, k13_ColorLightestGray, tmp.c_str());
-}
-
-uint16 ChampionMan::M70_handSlotIndex(uint16 slotBoxIndex) {
-	return slotBoxIndex & 0x1;
-}
-
-Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) {
-	Common::String valToStr = Common::String::format("%d", val);
-	Common::String result;
-
-	if (padding) {
-		for (int16 i = 0, end = paddingCharCount - valToStr.size(); i < end; ++i)
-			result += ' ';
-	}
-
-	return result += valToStr;
-}
-
-void ChampionMan::f299_applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing) {
-	int16 statIndex = k0_ChampionStatLuck;
-	int16 modifier = 0;
-	ThingType thingType = thing.getType();
-
-	bool cursed = false;
-	if (((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType))
-		&& (slotIndex >= k0_ChampionSlotReadyHand) && (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) {
-		if (thingType == k5_WeaponThingType) {
-			Weapon *weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(thing);
-			cursed = weapon->getCursed();
-		} else {
-			// k6_ArmourThingType
-			Armour *armour = (Armour *)_vm->_dungeonMan->f156_getThingData(thing);
-			cursed = armour->getCursed();
-		}
-
-		if (cursed) {
-			statIndex = k0_ChampionStatLuck;
-			modifier = -3;
-		}
-	}
-
-	if (!cursed) {
-		statIndex = (ChampionStatisticType)thingType; // variable sharing
-
-		if ((iconIndex == k137_IconIndiceJunkRabbitsFoot) && (slotIndex < k30_ChampionSlotChest_1)) {
-			statIndex = k0_ChampionStatLuck;
-			modifier = 10;
-		} else if (slotIndex == k1_ChampionSlotActionHand) {
-			if (iconIndex == k45_IconIndiceWeaponMaceOfOrder) {
-				statIndex = k1_ChampionStatStrength;
-				modifier = 5;
-			} else {
-				statIndex = k8_ChampionStatMana;
-				if ((iconIndex >= k20_IconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= k22_IconIndiceWeaponStaffOfClawsFull)) {
-					modifier = 4;
-				} else {
-					switch (iconIndex) {
-					case k38_IconIndiceWeaponDeltaSideSplitter:
-						modifier = 1;
-						break;
-					case k41_IconIndiceWeaponTheInquisitorDragonFang:
-						modifier = 2;
-						break;
-					case k40_IconIndiceWeaponVorpalBlade:
-						modifier = 4;
-						break;
-					case k58_IconIndiceWeaponStaff:
-						modifier = 2;
-						break;
-					case k59_IconIndiceWeaponWand:
-						modifier = 1;
-						break;
-					case k60_IconIndiceWeaponTeowand:
-						modifier = 6;
-						break;
-					case k61_IconIndiceWeaponYewStaff:
-						modifier = 4;
-						break;
-					case k62_IconIndiceWeaponStaffOfManarStaffOfIrra:
-						modifier = 10;
-						break;
-					case k63_IconIndiceWeaponSnakeStaffCrossOfNeta:
-						modifier = 8;
-						break;
-					case k64_IconIndiceWeaponTheConduitSerpentStaff:
-						modifier = 16;
-						break;
-					case k65_IconIndiceWeaponDragonSpit:
-						modifier = 7;
-						break;
-					case k66_IconIndiceWeaponSceptreOfLyf:
-						modifier = 5;
-						break;
-					default:
-						break;
-					}
-				}
-			}
-		} else if (slotIndex == k4_ChampionSlotLegs) {
-			if (iconIndex == k142_IconIndiceArmourPowertowers) {
-				statIndex = k1_ChampionStatStrength;
-				modifier = 10;
-			}
-		} else if (slotIndex == k2_ChampionSlotHead) {
-			switch (iconIndex) {
-			case k104_IconIndiceArmourCrownOfNerra:
-				statIndex = k3_ChampionStatWisdom;
-				modifier = 10;
-				break;
-			case k140_IconIndiceArmourDexhelm:
-				statIndex = k2_ChampionStatDexterity;
-				modifier = 10;
-				break;
-			default:
-				break;
-			}
-		} else if (slotIndex == k3_ChampionSlotTorso) {
-			switch (iconIndex) {
-			case k141_IconIndiceArmourFlamebain:
-				statIndex = k6_ChampionStatAntifire;
-				modifier = 12;
-				break;
-			case k81_IconIndiceArmourCloakOfNight:
-				statIndex = k2_ChampionStatDexterity;
-				modifier = 8;
-				break;
-			default:
-				break;
-			}
-		} else if (slotIndex == k10_ChampionSlotNeck) {
-			switch (iconIndex) {
-			case k10_IconIndiceJunkJewelSymalUnequipped:
-			case k11_IconIndiceJunkJewelSymalEquipped:
-				statIndex = k5_ChampionStatAntimagic;
-				modifier = 15;
-				break;
-			case k81_IconIndiceArmourCloakOfNight:
-				statIndex = k2_ChampionStatDexterity;
-				modifier = 8;
-				break;
-			case k122_IconIndiceJunkMoonstone:
-				statIndex = k8_ChampionStatMana;
-				modifier = 3;
-				break;
-			default:
-				break;
-			}
-		}
-	}
-
-	if (modifier) {
-		modifier *= modifierFactor;
-		//statIndex is set when modifier is set
-		if (statIndex == k8_ChampionStatMana) {
-			champ->_maxMana += modifier;
-		} else if (statIndex < k6_ChampionStatAntifire + 1) {
-			for (uint16 statValIndex = k0_ChampionStatMaximum; statValIndex <= k2_ChampionStatMinimum; ++statValIndex) {
-				champ->getStatistic((ChampionStatisticType)statIndex, (ChampionStatisticValue)statValIndex) += modifier;
-			}
-		}
-	}
-}
-
-bool ChampionMan::f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) {
-	ObjectMan &objMan = *_vm->_objectMan;
-
-	IconIndice currIconIndex = objMan.f39_getIconIndexInSlotBox(slotBoxIndex);
-	if (((currIconIndex < k32_IconIndiceWeaponDagger) && (currIconIndex >= k0_IconIndiceJunkCompassNorth))
-		|| ((currIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (currIconIndex <= k163_IconIndicePotionWaterFlask))
-		|| (currIconIndex == k195_IconIndicePotionEmptyFlask)) {
-		IconIndice newIconIndex = objMan.f33_getIconIndex(thing);
-		if (newIconIndex != currIconIndex) {
-			if ((slotBoxIndex < k8_SlotBoxInventoryFirstSlot) && !_g420_mousePointerHiddenToDrawChangedObjIconOnScreen) {
-				_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
-				_vm->_eventMan->f77_hideMouse();
-			}
-			objMan.f38_drawIconInSlotBox(slotBoxIndex, newIconIndex);
-			return true;
-		}
-	}
-
-	return false;
-}
-
-void ChampionMan::f296_drawChangedObjectIcons() {
-	InventoryMan &invMan = *_vm->_inventoryMan;
-	ObjectMan &objMan = *_vm->_objectMan;
-	MenuMan &menuMan = *_vm->_menuMan;
-
-	uint16 invChampOrdinal = invMan._g432_inventoryChampionOrdinal;
-	if (_g299_candidateChampionOrdinal && !invChampOrdinal)
-		return;
-
-	_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
-	IconIndice leaderHandObjIconIndex = _g413_leaderHandObjectIconIndex;
-
-	if (((leaderHandObjIconIndex < k32_IconIndiceWeaponDagger) && (leaderHandObjIconIndex >= k0_IconIndiceJunkCompassNorth))	// < instead of <= is correct
-		|| ((leaderHandObjIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= k163_IconIndicePotionWaterFlask))
-		|| (leaderHandObjIconIndex == k195_IconIndicePotionEmptyFlask)) {
-		IconIndice iconIndex = objMan.f33_getIconIndex(_g414_leaderHandObject);
-		if (iconIndex != leaderHandObjIconIndex) {
-			_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
-			_vm->_eventMan->f77_hideMouse();
-			objMan.f36_extractIconFromBitmap(iconIndex, objMan._g412_objectIconForMousePointer);
-			_vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
-			_g413_leaderHandObjectIconIndex = iconIndex;
-			objMan.f34_drawLeaderObjectName(_g414_leaderHandObject);
-		}
-	}
-
-	for (uint16 slotBoxIndex = 0; slotBoxIndex < (_g305_partyChampionCount * 2); ++slotBoxIndex) {
-		int16 champIndex = slotBoxIndex >> 1;
-		if (invChampOrdinal == _vm->M0_indexToOrdinal(champIndex))
-			continue;
-
-		if (f295_hasObjectIconInSlotBoxChanged(slotBoxIndex, _gK71_champions[champIndex].getSlot((ChampionSlot)M70_handSlotIndex(slotBoxIndex)))
-			&& (M70_handSlotIndex(slotBoxIndex) == k1_ChampionSlotActionHand)) {
-
-			menuMan.f386_drawActionIcon((ChampionIndex)champIndex);
-		}
-	}
-
-	if (invChampOrdinal) {
-		Champion *champ = &_gK71_champions[_vm->M1_ordinalToIndex(invChampOrdinal)];
-		Thing *thing = &champ->getSlot(k0_ChampionSlotReadyHand);
-		uint16 drawViewport = 0;
-
-		for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++, thing++) {
-			uint16 objIconChanged = f295_hasObjectIconInSlotBoxChanged(slotIndex + k8_SlotBoxInventoryFirstSlot, *thing) ? 1 : 0;
-			drawViewport |= objIconChanged;
-			if (objIconChanged && (slotIndex == k1_ChampionSlotActionHand)) {
-				menuMan.f386_drawActionIcon((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal));
-			}
-		}
-
-		if (invMan._g424_panelContent = k4_PanelContentChest) {
-			thing = invMan._g425_chestSlots;
-			for (int16 slotIndex = 0; slotIndex < 8; ++slotIndex, thing++) {
-				drawViewport |= (f295_hasObjectIconInSlotBoxChanged(slotIndex + k38_SlotBoxChestFirstSlot, *thing) ? 1 : 0);
-			}
-		}
-
-		if (drawViewport) {
-			champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
-			f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal));
-		}
-	}
-
-	if (_g420_mousePointerHiddenToDrawChangedObjIconOnScreen)
-		_vm->_eventMan->f78_showMouse();
-}
-
-void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex) {
-	InventoryMan &invMan = *_vm->_inventoryMan;
-	DungeonMan &dunMan = *_vm->_dungeonMan;
-	ObjectMan &objMan = *_vm->_objectMan;
-	MenuMan &menuMan = *_vm->_menuMan;
-
-	if (thing == Thing::_none)
-		return;
-
-	Champion *champ = &_gK71_champions[champIndex];
-
-	if (slotIndex >= k30_ChampionSlotChest_1) {
-		invMan._g425_chestSlots[slotIndex - k30_ChampionSlotChest_1] = thing;
-	} else {
-		champ->setSlot(slotIndex, thing);
-	}
-
-	champ->_load += dunMan.f140_getObjectWeight(thing);
-	champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
-	IconIndice iconIndex = objMan.f33_getIconIndex(thing);
-	bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal);
-	f299_applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
-	uint16 *rawObjPtr = dunMan.f156_getThingData(thing);
-
-	if (slotIndex < k2_ChampionSlotHead) {
-		if (slotIndex == k1_ChampionSlotActionHand) {
-			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
-			if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))
-				menuMan.f388_clearActingChampion();
-
-			if ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)) {
-				((Scroll *)rawObjPtr)->setClosed(false);
-				f296_drawChangedObjectIcons();
-			}
-		}
-
-		if (iconIndex = k4_IconIndiceWeaponTorchUnlit) {
-			((Weapon *)rawObjPtr)->setLit(true);
-			_vm->_inventoryMan->f337_setDungeonViewPalette();
-			f296_drawChangedObjectIcons();
-		} else if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand) &&
-			((iconIndex == k144_IconIndiceContainerChestClosed) || ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)))) {
-			champ->setAttributeFlag(k0x0800_ChampionAttributePanel, true);
-		}
-	} else if (slotIndex == k10_ChampionSlotNeck) {
-		if ((iconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (iconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
-			((Junk *)rawObjPtr)->setChargeCount(1);
-			_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2];
-			_vm->_inventoryMan->f337_setDungeonViewPalette();
-			iconIndex = (IconIndice)(iconIndex + 1);
-		} else if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
-			((Junk *)rawObjPtr)->setChargeCount(1);
-			iconIndex = (IconIndice)(iconIndex + 1);
-		}
-	}
-
-	f291_drawSlot(champIndex, slotIndex);
-	if (isInventoryChampion)
-		champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
-}
-
-int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) {
-	int16 scentIndex = _g407_party._scentCount;
-
-	if (scentIndex) {
-		Scent searchedScent;
-		searchedScent.setMapX(mapX);
-		searchedScent.setMapY(mapY);
-		searchedScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex);
-		uint16 searchedScentRedEagle = searchedScent.toUint16();
-		Scent *scent = &_g407_party._scents[scentIndex--];
-		do {
-			if ((*(--scent)).toUint16() == searchedScentRedEagle) {
-				return _vm->M0_indexToOrdinal(scentIndex);
-			}
-		} while (scentIndex--);
-	}
-	return 0;
-}
-
-Thing ChampionMan::f298_getObjectRemovedFromLeaderHand() {
-	_g415_leaderEmptyHanded = true;
-	Thing leaderHandObject = _g414_leaderHandObject;
-
-	if (leaderHandObject != Thing::_none) {
-		_g414_leaderHandObject = Thing::_none;
-		_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
-		_vm->_eventMan->f78_showMouse();
-		_vm->_objectMan->f35_clearLeaderObjectName();
-		_vm->_eventMan->f69_setMousePointer();
-		_vm->_eventMan->f77_hideMouse();
-		if (_g411_leaderIndex != kM1_ChampionNone) {
-			_gK71_champions[_g411_leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(leaderHandObject);
-			setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
-			f292_drawChampionState(_g411_leaderIndex);
-		}
-	}
-	return leaderHandObject;
-}
-
-uint16 ChampionMan::f312_getStrength(int16 champIndex, int16 slotIndex) {
-	Champion *curChampion = &_gK71_champions[champIndex];
-	int16 strength = _vm->getRandomNumber(16) + curChampion->_statistics[k1_ChampionStatStrength][k1_ChampionStatCurrent];
-	Thing curThing = curChampion->_slots[slotIndex];
-	uint16 objectWeight = _vm->_dungeonMan->f140_getObjectWeight(curThing);
-	uint16 oneSixteenthMaximumLoad = f309_getMaximumLoad(curChampion) >> 4;
-
-	if (objectWeight <= oneSixteenthMaximumLoad) {
-		strength += objectWeight - 12;
-	} else {
-		int16 loadThreshold = oneSixteenthMaximumLoad + ((oneSixteenthMaximumLoad - 12) >> 1);
-		if (objectWeight <= loadThreshold) {
-			strength += (objectWeight - oneSixteenthMaximumLoad) >> 1;
-		} else {
-			strength -= (objectWeight - loadThreshold) << 1;
-		}
-	}
-	if (curThing.getType() == k5_WeaponThingType) {
-		WeaponInfo *weaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
-		strength += weaponInfo->_strength;
-		uint16 skillLevel = 0;
-		uint16 weaponClass = weaponInfo->_class;
-		if ((weaponClass == k0_WeaponClassSwingWeapon) || (weaponClass == k2_WeaponClassDaggerAndAxes)) {
-			skillLevel = f303_getSkillLevel(champIndex, k4_ChampionSkillSwing);
-		}
-		if ((weaponClass != k0_WeaponClassSwingWeapon) && (weaponClass < k16_WeaponClassFirstBow)) {
-			skillLevel += f303_getSkillLevel(champIndex, k10_ChampionSkillThrow);
-		}
-		if ((weaponClass >= k16_WeaponClassFirstBow) && (weaponClass < k112_WeaponClassFirstMagicWeapon)) {
-			skillLevel += f303_getSkillLevel(champIndex, k11_ChampionSkillShoot);
-		}
-		strength += skillLevel << 1;
-	}
-	strength = f306_getStaminaAdjustedValue(curChampion, strength);
-	if (getFlag(curChampion->_wounds, (slotIndex == k0_ChampionSlotReadyHand) ? k0x0001_ChampionWoundReadHand : k0x0002_ChampionWoundActionHand)) {
-		strength >>= 1;
-	}
-	return f26_getBoundedValue(0, strength >> 1, 100);
-}
-
-Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) {
-	Champion *curChampion = &_gK71_champions[champIndex];
-	Thing curThing;
-
-	if (slotIndex >= k30_ChampionSlotChest_1) {
-		curThing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
-		_vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1] = Thing::_none;
-	} else {
-		curThing = curChampion->_slots[slotIndex];
-		curChampion->_slots[slotIndex] = Thing::_none;
-	}
-
-	if (curThing == Thing::_none)
-		return Thing::_none;
-
-	bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
-	int16 curIconIndex = _vm->_objectMan->f33_getIconIndex(curThing);
-	// Remove object modifiers
-	f299_applyModifiersToStatistics(curChampion, slotIndex, curIconIndex, -1, curThing);
-
-	Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(curThing);
-	if (slotIndex == k10_ChampionSlotNeck) {
-		if ((curIconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (curIconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
-			((Junk *)curWeapon)->setChargeCount(0);
-			_g407_party._magicalLightAmount -= g39_LightPowerToLightAmount[2];
-			_vm->_inventoryMan->f337_setDungeonViewPalette();
-		} else if ((curIconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (curIconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
-			((Junk *)curWeapon)->setChargeCount(0);
-		}
-	}
-
-	f291_drawSlot(champIndex, slotIndex);
-	if (isInventoryChampion)
-		setFlag(curChampion->_attributes, k0x4000_ChampionAttributeViewport);
-
-	if (slotIndex < k2_ChampionSlotHead) {
-		if (slotIndex == k1_ChampionSlotActionHand) {
-			setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand);
-			if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))
-				_vm->_menuMan->f388_clearActingChampion();
-
-			if ((curIconIndex >= k30_IconIndiceScrollOpen) && (curIconIndex <= k31_IconIndiceScrollClosed)) {
-				((Scroll *)curWeapon)->setClosed(true);
-				f296_drawChangedObjectIcons();
-			}
-		}
-
-		if ((curIconIndex >= k4_IconIndiceWeaponTorchUnlit) && (curIconIndex <= k7_IconIndiceWeaponTorchLit)) {
-			curWeapon->setLit(false);
-			_vm->_inventoryMan->f337_setDungeonViewPalette();
-			f296_drawChangedObjectIcons();
-		}
-
-		if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand)) {
-			switch (curIconIndex) {
-			case k144_IconIndiceContainerChestClosed:
-				_vm->_inventoryMan->f334_closeChest();
-			// No break on purpose
-			case k30_IconIndiceScrollOpen:
-			case k31_IconIndiceScrollClosed:
-				setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel);
-				break;
-			default:
-				break;
-			}
-		}
-	}
-	curChampion->_load -= _vm->_dungeonMan->f140_getObjectWeight(curThing);
-	setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad);
-	return curThing;
-}
-
-void ChampionMan::f325_decrementStamina(int16 championIndex, int16 decrement) {
-	if (championIndex == kM1_ChampionNone)
-		return;
-
-	Champion *curChampion = &_gK71_champions[championIndex];
-	curChampion->_currStamina -= decrement;
-
-	int16 stamina = curChampion->_currStamina;
-	if (stamina <= 0) {
-		curChampion->_currStamina = 0;
-		f321_addPendingDamageAndWounds_getDamage(championIndex, (-stamina) >> 1, k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
-	} else if (stamina > curChampion->_maxStamina) {
-		curChampion->_currStamina = curChampion->_maxStamina;
-	}
-
-	setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics);
-}
-
-int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds, uint16 attackType) {
-	if (attack <= 0)
-		return 0;
-
-	Champion *curChampion = &_gK71_champions[champIndex];
-	if (!curChampion->_currHealth)
-		return 0;
-
-	bool skipScaling = false;
-	if (attackType != k0_attackType_NORMAL) {
-		uint16 defense = 0;
-		uint16 woundCount = 0;
-		for (int16 woundIndex = k0_ChampionSlotReadyHand; woundIndex <= k5_ChampionSlotFeet; woundIndex++) {
-			if (allowedWounds & (1 << woundIndex)) {
-				woundCount++;
-				defense += f313_getWoundDefense(champIndex, woundIndex | ((attackType == k4_attackType_SHARP) ? k0x8000_maskUseSharpDefense : k0x0000_maskDoNotUseSharpDefense));
-			}
-		}
-		if (woundCount)
-			defense /= woundCount;
-
-		switch (attackType) {
-		case k6_attackType_PSYCHIC:
-		{
-			int16 wisdomFactor = 115 - curChampion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent];
-			if (wisdomFactor <= 0) {
-				attack = 0;
-			} else {
-				attack = _vm->f30_getScaledProduct(attack, 6, wisdomFactor);
-			}
-
-			skipScaling = true;
-		}
-		break;
-		case k5_attackType_MAGIC:
-			attack = f307_getStatisticAdjustedAttack(curChampion, k5_ChampionStatAntimagic, attack);
-			attack -= _g407_party._spellShieldDefense;
-			skipScaling = true;
-			break;
-		case k1_attackType_FIRE:
-			attack = f307_getStatisticAdjustedAttack(curChampion, k6_ChampionStatAntifire, attack);
-			attack -= _g407_party._fireShieldDefense;
-			break;
-		case k2_attackType_SELF:
-			defense >>= 1;
-			break;
-		default:
-			break;
-		}
-
-		if (!skipScaling) {
-			if (attack <= 0)
-				return 0;
-
-			attack = _vm->f30_getScaledProduct(attack, 6, 130 - defense);
-		}
-		/* BUG0_44
-			A champion may take much more damage than expected after a Black Flame attack or an impact
-			with a Fireball projectile. If the party has a fire shield defense value higher than the fire
-			attack value then the resulting intermediary attack value is negative and damage should be 0.
-			However, the negative value is still used for further computations and the result may be a very
-			high positive attack value which may kill a champion. This can occur only for k1_attackType_FIRE
-			and if attack is negative before calling F0030_MAIN_GetScaledProduct
-		*/
-
-		if (attack <= 0)
-			return 0;
-
-		int16 adjustedAttack = f307_getStatisticAdjustedAttack(curChampion, k4_ChampionStatVitality, _vm->getRandomNumber(128) + 10);
-		if (attack > adjustedAttack) {
-		/* BUG0_45
-			This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the
-			probability of being wounded. However if it was fixed, the behavior would be the opposite
-			of what it should: the higher the vitality of a champion, the lower the result of
-			F0307_CHAMPION_GetStatisticAdjustedAttack and the more likely the champion could get
-			wounded (because of more iterations in the loop below)
-		*/
-			do {
-				setFlag(*(uint16 *)&_g410_championPendingWounds[champIndex], (1 << _vm->getRandomNumber(8)) & allowedWounds);
-			} while ((attack > (adjustedAttack <<= 1)) && adjustedAttack);
-		}
-
-		if (_g300_partyIsSleeping)
-			f314_wakeUp();
-	}
-	_g409_championPendingDamage[champIndex] += attack;
-	return attack;
-}
-
-int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
-	static const byte woundDefenseFactor[6] = {5, 5, 4, 6, 3, 1}; // @ G0050_auc_Graphic562_WoundDefenseFactor
-
-	Champion *curChampion = &_gK71_champions[champIndex];
-	bool useSharpDefense = getFlag(woundIndex, k0x8000_maskUseSharpDefense);
-	if (useSharpDefense)
-		clearFlag(woundIndex, k0x8000_maskUseSharpDefense);
-
-	uint16 armorShieldDefense = 0;
-	for (int16 slotIndex = k0_ChampionSlotReadyHand; slotIndex <= k1_ChampionSlotActionHand; slotIndex++) {
-		Thing curThing = curChampion->_slots[slotIndex];
-		if (curThing.getType() == k6_ArmourThingType) {
-			ArmourInfo *armorInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(curThing);
-			armorInfo = &g239_ArmourInfo[((Armour *)armorInfo)->getType()];
-			if (getFlag(armorInfo->_attributes, k0x0080_ArmourAttributeIsAShield))
-				armorShieldDefense += ((f312_getStrength(champIndex, slotIndex) + _vm->_dungeonMan->f143_getArmourDefense(armorInfo, useSharpDefense)) * woundDefenseFactor[woundIndex]) >> ((slotIndex == woundIndex) ? 4 : 5);
-		}
-	}
-
-	int16 woundDefense = _vm->getRandomNumber((curChampion->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] >> 3) + 1);
-	if (useSharpDefense)
-		woundDefense >>= 1;
-
-	woundDefense += curChampion->_actionDefense + curChampion->_shieldDefense + _g407_party._shieldDefense + armorShieldDefense;
-	if (woundIndex > k1_ChampionSlotActionHand) {
-		Thing curThing = curChampion->_slots[woundIndex];
-		if (curThing.getType() == k6_ArmourThingType) {
-			ArmourInfo *armourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(curThing);
-			woundDefense += _vm->_dungeonMan->f143_getArmourDefense(&g239_ArmourInfo[((Armour *)armourInfo)->getType()], useSharpDefense);
-		}
-	}
-
-	if (getFlag(curChampion->_wounds, 1 << woundIndex))
-		woundDefense -= 8 + _vm->getRandomNumber(4);
-
-	if (_g300_partyIsSleeping)
-		woundDefense >>= 1;
-
-	return f26_getBoundedValue(0, woundDefense >> 1, 100);
-}
-
-uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion *champ, uint16 statIndex, uint16 attack) {
-	int16 factor = 170 - champ->_statistics[statIndex][k1_ChampionStatCurrent];
-
-	/* BUG0_41
-		The Antifire and Antimagic statistics are completely ignored. The Vitality statistic is ignored
-		against poison and to determine the probability of being wounded. Vitality is still used normally
-		to compute the defense against wounds and the speed of health regeneration. A bug in the Megamax C
-		compiler produces wrong machine code for this statement. It always returns 0 for the current statistic
-		value so that factor = 170 in all cases
-	*/
-	if (factor < 16)
-		return attack >> 3;
-
-	return _vm->f30_getScaledProduct(attack, 7, factor);
-}
-
-void ChampionMan::f314_wakeUp() {
-	_vm->_g321_stopWaitingForPlayerInput = true;
-	_g300_partyIsSleeping = false;
-	_vm->_g318_waitForInputMaxVerticalBlankCount = 10;
-	_vm->f22_delay(10);
-	_vm->_displayMan->f98_drawFloorAndCeiling();
-	_vm->_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface;
-	_vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
-	_vm->_eventMan->_g443_primaryKeyboardInput = g458_primaryKeyboardInput_interface;
-	_vm->_eventMan->_g444_secondaryKeyboardInput = g459_secondaryKeyboardInput_movement;
-	_vm->_eventMan->f357_discardAllInput();
-	_vm->_menuMan->f457_drawEnabledMenus();
-}
-
-int16 ChampionMan::f305_getThrowingStaminaCost(Thing thing) {
-	int16 weight = _vm->_dungeonMan->f140_getObjectWeight(thing) >> 1;
-	int16 staminaCost = f26_getBoundedValue<int16>(1, weight, 10);
-
-	while ((weight -= 10) > 0)
-		staminaCost += weight >> 1;
-
-	return staminaCost;
-}
-
-void ChampionMan::f330_disableAction(uint16 champIndex, uint16 ticks) {
-	Champion *curChampion = &_gK71_champions[champIndex];
-	int32 updatedEnableActionEventTime = _vm->_g313_gameTime + ticks;
-
-	TimelineEvent curEvent;
-	curEvent._type = k11_TMEventTypeEnableChampionAction;
-	curEvent._priority = champIndex;
-	curEvent._B._slotOrdinal = 0;
-
-	int16 eventIndex = curChampion->_enableActionEventIndex;
-	if (eventIndex >= 0) {
-		int32 currentEnableActionEventTime = M30_time(_vm->_timeline->_g370_events[eventIndex]._mapTime);
-		if (updatedEnableActionEventTime >= currentEnableActionEventTime) {
-			updatedEnableActionEventTime += (currentEnableActionEventTime - _vm->_g313_gameTime) >> 1;
-		} else {
-			updatedEnableActionEventTime = currentEnableActionEventTime + (ticks >> 1);
-		}
-		_vm->_timeline->f237_deleteEvent(eventIndex);
-	} else {
-		setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x0008_ChampionAttributeDisableAction);
-		f292_drawChampionState((ChampionIndex)champIndex);
-	}
-	M33_setMapAndTime(curEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, updatedEnableActionEventTime);
-	curChampion->_enableActionEventIndex = _vm->_timeline->f238_addEventGetEventIndex(&curEvent);
-}
-
-void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp) {
-	if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && (_vm->_projexpl->_g361_lastCreatureAttackTime < _vm->_g313_gameTime - 150))
-		exp >>= 1;
-
-	if (exp) {
-		if (_vm->_dungeonMan->_g269_currMap->_difficulty)
-			exp *= _vm->_dungeonMan->_g269_currMap->_difficulty;
-
-		Champion *curChampion = &_gK71_champions[champIndex];
-		uint16 baseSkillIndex;
-		if (skillIndex >= k4_ChampionSkillSwing)
-			baseSkillIndex = (skillIndex - k4_ChampionSkillSwing) >> 2;
-		else
-			baseSkillIndex = skillIndex;
-
-		uint16 skillLevelBefore = f303_getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
-
-		if ((skillIndex >= k4_ChampionSkillSwing) && (_vm->_projexpl->_g361_lastCreatureAttackTime > _vm->_g313_gameTime - 25))
-			exp <<= 1;
-
-		Skill *curSkill = &curChampion->_skills[skillIndex];
-		curSkill->_experience += exp;
-		if (curSkill->_temporaryExperience < 32000)
-			curSkill->_temporaryExperience += f26_getBoundedValue(1, exp >> 3, 100);
-
-		curSkill = &curChampion->_skills[baseSkillIndex];
-		if (skillIndex >= k4_ChampionSkillSwing)
-			curSkill->_experience += exp;
-
-		uint16 skillLevelAfter = f303_getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
-		if (skillLevelAfter > skillLevelBefore) {
-			int16 newBaseSkillLevel = skillLevelAfter;
-			int16 minorStatIncrease = _vm->getRandomNumber(2);
-			int16 majorStatIncrease = 1 + _vm->getRandomNumber(2);
-			uint16 vitalityAmount = _vm->getRandomNumber(2); /* For Priest skill, the amount is 0 or 1 for all skill levels */
-			if (baseSkillIndex != k2_ChampionSkillPriest) {
-				vitalityAmount &= skillLevelAfter; /* For non Priest skills the amount is 0 for even skill levels. The amount is 0 or 1 for odd skill levels */
-			}
-			curChampion->_statistics[k4_ChampionStatVitality][k0_ChampionStatMaximum] += vitalityAmount;
-			uint16 staminaAmount = curChampion->_maxStamina;
-			curChampion->_statistics[k6_ChampionStatAntifire][k0_ChampionStatMaximum] += _vm->getRandomNumber(2) & ~skillLevelAfter; /* The amount is 0 for odd skill levels. The amount is 0 or 1 for even skill levels */
-			bool increaseManaFl = false;
-			switch (baseSkillIndex) {
-			case k0_ChampionSkillFighter:
-				staminaAmount >>= 4;
-				skillLevelAfter *= 3;
-				curChampion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += majorStatIncrease;
-				curChampion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += minorStatIncrease;
-				break;
-			case k1_ChampionSkillNinja:
-				staminaAmount /= 21;
-				skillLevelAfter <<= 1;
-				curChampion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += minorStatIncrease;
-				curChampion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += majorStatIncrease;
-				break;
-			case k3_ChampionSkillWizard:
-				staminaAmount >>= 5;
-				curChampion->_maxMana += skillLevelAfter + (skillLevelAfter >> 1);
-				curChampion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += majorStatIncrease;
-				increaseManaFl = true;
-				break;
-			case k2_ChampionSkillPriest:
-				staminaAmount /= 25;
-				curChampion->_maxMana += skillLevelAfter;
-				skillLevelAfter += (skillLevelAfter + 1) >> 1;
-				curChampion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += minorStatIncrease;
-				increaseManaFl = true;
-				break;
-			default:
-				break;
-			}
-			if (increaseManaFl) {
-				if ((curChampion->_maxMana += MIN(_vm->getRandomNumber(4), (uint16)(newBaseSkillLevel - 1))) > 900)
-					curChampion->_maxMana = 900;
-				curChampion->_statistics[k5_ChampionStatAntimagic][k0_ChampionStatMaximum] += _vm->getRandomNumber(3);
-			}
-
-			if ((curChampion->_maxHealth += skillLevelAfter + _vm->getRandomNumber((skillLevelAfter >> 1) + 1)) > 999)
-				curChampion->_maxHealth = 999;
-
-			if ((curChampion->_maxStamina += staminaAmount + _vm->getRandomNumber((staminaAmount >> 1) + 1)) > 9999)
-				curChampion->_maxStamina = 9999;
-
-			setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
-			f292_drawChampionState((ChampionIndex)champIndex);
-			_vm->_textMan->f51_messageAreaPrintLineFeed();
-			Color curChampionColor = g46_ChampionColor[champIndex];
-			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, curChampion->_name);
-			// TODO: localization
-			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " JUST GAINED A ");
-			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, g417_baseSkillName[baseSkillIndex]);
-			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " LEVEL!");
-		}
-	}
-}
-
-int16 ChampionMan::f324_damageAll_getDamagedChampionCount(uint16 attack, int16 wounds, int16 attackType) {
-	int16 randomMax = (attack >> 3) + 1;
-	uint16 reducedAttack = attack - randomMax;
-	randomMax <<= 1;
-
-	int16 damagedChampionCount = 0;
-	for (int16 championIndex = k0_ChampionFirst; championIndex < _g305_partyChampionCount; championIndex++) {
-		// Actual attack is attack +/- (attack / 8)
-		if (f321_addPendingDamageAndWounds_getDamage(championIndex, MAX(1, reducedAttack + _vm->getRandomNumber(randomMax)), wounds, attackType))
-			damagedChampionCount++;
-	}
-
-	return damagedChampionCount;
-}
-
-int16 ChampionMan::f286_getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) {
-	if (_g305_partyChampionCount && (M38_distance(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)) {
-		signed char orderedCellsToAttack[4];
-		_vm->_groupMan->f229_setOrderedCellsToAttack(orderedCellsToAttack, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, mapX, mapY, cell);
-		for (uint16 i = 0; i < 4; i++) {
-			int16 championIndex = f285_getIndexInCell(orderedCellsToAttack[i]);
-			if (championIndex >= 0)
-				return championIndex;
-		}
-	}
-	return kM1_ChampionNone;
-}
-
-int16 ChampionMan::f311_getDexterity(Champion* champ) {
-	int16 dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent];
-	dexterity -= ((int32)(dexterity >> 1) * (int32)champ->_load) / f309_getMaximumLoad(champ);
-	if (_g300_partyIsSleeping)
-		dexterity >>= 1;
-
-	return f26_getBoundedValue(1 + _vm->getRandomNumber(8), dexterity >> 1, 100 - _vm->getRandomNumber(8));
-}
-
-bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) {
-	if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage))
-		return true;
-
-	unsigned char *curStat = champ->_statistics[k0_ChampionStatLuck];
-	bool isLucky = (_vm->getRandomNumber(curStat[k1_ChampionStatCurrent]) > percentage);
-	curStat[k1_ChampionStatCurrent] = f26_getBoundedValue<char>(curStat[k2_ChampionStatMinimum], curStat[k1_ChampionStatCurrent] + (isLucky ? -2 : 2), curStat[k0_ChampionStatMaximum]);
-	return isLucky;
-}
-
-void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) {
-	if ((champIndex == kM1_ChampionNone) || (_vm->M0_indexToOrdinal(champIndex) == _g299_candidateChampionOrdinal))
-		return;
-
-	Champion *curChampion = &_gK71_champions[champIndex];
-	f321_addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
-	setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
-	if ((_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) && (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
-		setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel);
-	}
-
-	if (--attack) {
-		curChampion->_poisonEventCount++;
-		TimelineEvent newEvent;
-		newEvent._type = k75_TMEventTypePoisonChampion;
-		newEvent._priority = champIndex;
-		M33_setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 36);
-		newEvent._B._attack = attack;
-		_vm->_timeline->f238_addEventGetEventIndex(&newEvent);
-	}
-
-	f292_drawChampionState((ChampionIndex)champIndex);
-}
-
-void ChampionMan::f284_setPartyDirection(int16 dir) {
-	if (dir == _vm->_dungeonMan->_g308_partyDir)
-		return;
-
-	int16 L0834_i_Delta = dir - _vm->_dungeonMan->_g308_partyDir;
-	if (L0834_i_Delta < 0)
-		L0834_i_Delta += 4;
-
-	Champion *curChampion = _gK71_champions;
-	for (int16 i = k0_ChampionFirst; i < _g305_partyChampionCount; i++) {
-		curChampion->_cell = (ViewCell)M21_normalizeModulo4(curChampion->_cell + L0834_i_Delta);
-		curChampion->_dir = (Direction)M21_normalizeModulo4(curChampion->_dir + L0834_i_Delta);
-		curChampion++;
-	}
-
-	_vm->_dungeonMan->_g308_partyDir = (Direction)dir;
-	f296_drawChangedObjectIcons();
-}
-
-void ChampionMan::f316_deleteScent(uint16 scentIndex) {
-	uint16 count = --_g407_party._scentCount - scentIndex;
-
-	if (count) {
-		for (uint16 i = 0; i < count; ++i) {
-			_g407_party._scents[scentIndex + i] = _g407_party._scents[scentIndex + i + 1];
-			_g407_party._scentStrengths[scentIndex + i] = _g407_party._scentStrengths[scentIndex + i + 1];
-		}
-	}
-
-	if (scentIndex < _g407_party._firstScentIndex)
-		_g407_party._firstScentIndex--;
-
-	if (scentIndex < _g407_party._lastScentIndex)
-		_g407_party._lastScentIndex--;
-}
-
-void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount) {
-	int16 scentIndex = _g407_party._scentCount;
-	if (scentIndex) {
-		bool mergeFl = getFlag(cycleCount, k0x8000_mergeCycles);
-		if (mergeFl)
-			clearFlag(cycleCount, k0x8000_mergeCycles);
-
-		Scent newScent; /* BUG0_00 Useless code */
-		newScent.setMapX(mapX); /* BUG0_00 Useless code */
-		newScent.setMapY(mapY); /* BUG0_00 Useless code */
-		newScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */
-
-		Scent *curScent = _g407_party._scents; /* BUG0_00 Useless code */
-		bool cycleCountDefined = false;
-		while (scentIndex--) {
-			if (&*curScent++ == &newScent) {
-				if (!cycleCountDefined) {
-					cycleCountDefined = true;
-					if (mergeFl) {
-						cycleCount = MAX<int32>(_g407_party._scentStrengths[scentIndex], cycleCount);
-					} else {
-						cycleCount = MIN<int32>(80, _g407_party._scentStrengths[scentIndex] + cycleCount);
-					}
-				}
-				_g407_party._scentStrengths[scentIndex] = cycleCount;
-			}
-		}
-	}
-}
-
-void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) {
-	if (thing == Thing::_none)
-		return;
-
-	_g415_leaderEmptyHanded = false;
-	_vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
-	_vm->_eventMan->f78_showMouse();
-	_vm->_objectMan->f34_drawLeaderObjectName(thing);
-
-	if (setMousePointer)
-		_vm->_g325_setMousePointerToObjectInMainLoop = true;
-	else
-		_vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
-
-	_vm->_eventMan->f77_hideMouse();
-	if (_g411_leaderIndex != kM1_ChampionNone) {
-		_gK71_champions[_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing);
-		setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
-		f292_drawChampionState(_g411_leaderIndex);
-	}
-}
-
-int16 ChampionMan::f310_getMovementTicks(Champion *champ) {
-	uint16 maximumLoad = f309_getMaximumLoad(champ);
-	uint16 curLoad = champ->_load;
-	uint16 woundTicks;
-	int16 ticks;
-	/* BUG0_72 - Fixed
-		The party moves very slowly even though no champion 'Load' value is drawn in red.
-		When the Load of a champion has exactly the maximum value he can carry then the Load
-		is drawn in yellow but the speed is the same as when the champion is overloaded
-		(when the Load is drawn in red). The comparison operator should be >= instead of >
-	*/
-	if (maximumLoad >= curLoad) {
-		ticks = 2;
-		if (((int32)curLoad << 3) > ((int32)maximumLoad * 5))
-			ticks++;
-
-		woundTicks = 1;
-	} else {
-		ticks = 4 + (((curLoad - maximumLoad) << 2) / maximumLoad);
-		woundTicks = 2;
-	}
-
-	if (getFlag(champ->_wounds, k0x0020_ChampionWoundFeet))
-		ticks += woundTicks;
-
-	if (_vm->_objectMan->f33_getIconIndex(champ->_slots[k5_ChampionSlotFeet]) == k194_IconIndiceArmourBootOfSpeed)
-		ticks--;
-
-	return ticks;
-}
-
-bool ChampionMan::f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex, uint16 ammunitionSlotIndex) {
-	Champion *curChampion = &_gK71_champions[champIndex];
-	Thing curThing = curChampion->_slots[weaponSlotIndex];
-	if (curThing.getType() != k5_WeaponThingType)
-		return false;
-
-	WeaponInfo *weaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
-	int16 weaponClass = kM1_WeaponClassNone;
-
-	if ((weaponInfo->_class >= k16_WeaponClassFirstBow) && (weaponInfo->_class <= k31_WeaponClassLastBow))
-		weaponClass = k10_WeaponClassBowAmmunition;
-	else if ((weaponInfo->_class >= k32_WeaponClassFirstSling) && (weaponInfo->_class <= k47_WeaponClassLastSling))
-		weaponClass = k11_WeaponClassSlingAmmunition;
-
-	if (weaponClass == kM1_WeaponClassNone)
-		return false;
-
-	curThing = curChampion->_slots[ammunitionSlotIndex];
-	weaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
-	return ((curThing.getType() == k5_WeaponThingType) && (weaponInfo->_class == weaponClass));
-}
-
-void ChampionMan::f293_drawAllChampionStates() {
-	for (int16 i = k0_ChampionFirst; i < _g305_partyChampionCount; i++)
-		f292_drawChampionState((ChampionIndex)i);
-}
-
-void ChampionMan::f283_viAltarRebirth(uint16 champIndex) {
-	Champion *curChampion = &_gK71_champions[champIndex];
-	if (f285_getIndexInCell(curChampion->_cell) != kM1_ChampionNone) {
-		uint16 numCell = k0_CellNorthWest;
-		while (f285_getIndexInCell(numCell) != kM1_ChampionNone)
-			numCell++;
-
-		curChampion->_cell = (ViewCell)numCell;
-	}
-
-	uint16 maximumHealth = curChampion->_maxHealth;
-	curChampion->_maxHealth = MAX(25, maximumHealth - (maximumHealth >> 6) - 1);
-	curChampion->_currHealth = curChampion->_maxHealth >> 1;
-	_vm->_menuMan->f393_drawSpellAreaControls(_g514_magicCasterChampionIndex);
-	curChampion->_dir = _vm->_dungeonMan->_g308_partyDir;
-	setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
-	f292_drawChampionState((ChampionIndex)champIndex);
-}
-
-void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex) {
-	uint16 champIndex;
-	uint16 slotIndex;
-
-	if (slotBoxIndex < k8_SlotBoxInventoryFirstSlot) {
-		if (_g299_candidateChampionOrdinal)
-			return;
-
-		champIndex = slotBoxIndex >> 1;
-		if ((champIndex >= _g305_partyChampionCount) || (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_gK71_champions[champIndex]._currHealth)
-			return;
-
-		slotIndex = M70_handSlotIndex(slotBoxIndex);
-	} else {
-		champIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal);
-		slotIndex = slotBoxIndex - k8_SlotBoxInventoryFirstSlot;
-	}
-
-	Thing leaderHandObject = _g414_leaderHandObject;
-	Thing slotThing;
-	if (slotIndex >= k30_ChampionSlotChest_1) {
-		slotThing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
-	} else {
-		slotThing = _gK71_champions[champIndex]._slots[slotIndex];
-	}
-
-	if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none))
-		return;
-
-	if ((leaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & gSlotMasks[slotIndex])))
-		return;
-
-	_vm->_eventMan->f78_showMouse();
-	if (leaderHandObject != Thing::_none)
-		f298_getObjectRemovedFromLeaderHand();
-
-	if (slotThing != Thing::_none) {
-		f300_getObjectRemovedFromSlot(champIndex, slotIndex);
-		f297_putObjectInLeaderHand(slotThing, false);
-	}
-
-	if (leaderHandObject != Thing::_none)
-		f301_addObjectInSlot((ChampionIndex)champIndex, leaderHandObject, (ChampionSlot)slotIndex);
-
-	f292_drawChampionState((ChampionIndex)champIndex);
-	_vm->_eventMan->f77_hideMouse();
-}
-
-bool ChampionMan::f327_isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount) {
-	Champion *curChampion = &_gK71_champions[champIndex];
-	if (curChampion->_currMana < requiredManaAmount)
-		return false;
-
-	curChampion->_currMana -= requiredManaAmount;
-	setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
-	int16 stepEnergy = 10 - MIN(8, curChampion->_maxMana >> 3);
-	if (kineticEnergy < (stepEnergy << 2)) {
-		kineticEnergy += 3;
-		stepEnergy--;
-	}
-
-	f326_championShootProjectile(curChampion, thing, kineticEnergy, 90, stepEnergy);
-	return true; // fix BUG_01
-}
-
-void ChampionMan::f326_championShootProjectile(Champion* champ, Thing thing, int16 kineticEnergy, int16 attack, int16 stepEnergy) {
-	Direction newDirection = champ->_dir;
-	_vm->_projexpl->f212_projectileCreate(thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, M21_normalizeModulo4((((champ->_cell - newDirection + 1) & 0x0002) >> 1) + newDirection), newDirection, kineticEnergy, attack, stepEnergy);
-	_vm->_g311_projectileDisableMovementTicks = 4;
-	_vm->_g312_lastProjectileDisabledMovementDirection = newDirection;
-}
-
-void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() {
-	Champion *championPtr = _gK71_champions;
-	for (uint16 championIndex = k0_ChampionFirst; championIndex < _g305_partyChampionCount; championIndex++, championPtr++) {
-		int16 pendingWounds = _g410_championPendingWounds[championIndex];
-		setFlag(championPtr->_wounds, pendingWounds);
-		_g410_championPendingWounds[championIndex] = 0;
-		uint16 pendingDamage = _g409_championPendingDamage[championIndex];
-		if (!pendingDamage)
-			continue;
-
-		_g409_championPendingDamage[championIndex] = 0;
-		int16 curHealth = championPtr->_currHealth;
-		if (!curHealth)
-			continue;
-
-		curHealth -= pendingDamage;
-		if (curHealth <= 0) {
-			f319_championKill(championIndex);
-		} else {
-			championPtr->_currHealth = curHealth;
-			setFlag(championPtr->_attributes, k0x0100_ChampionAttributeStatistics);
-			if (pendingWounds) {
-				setFlag(championPtr->_attributes, k0x2000_ChampionAttributeWounds);
-			}
-
-			int16 textPosX = championIndex * k69_ChampionStatusBoxSpacing;
-			int16 textPosY;
-
-			Box blitBox;
-			blitBox._y1 = 0;
-			_vm->_eventMan->f78_showMouse();
-
-			if (_vm->M0_indexToOrdinal(championIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
-				blitBox._y2 = 28;
-				blitBox._x1 = textPosX + 7;
-				blitBox._x2 = blitBox._x1 + 31; /* Box is over the champion portrait in the status box */
-				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k16_damageToChampionBig), &blitBox, k16_byteWidth, k10_ColorFlesh, 29);
-				// Check the number of digits and sets the position accordingly.
-				if (pendingDamage < 10) // 1 digit
-					textPosX += 21;
-				else if (pendingDamage < 100)  // 2 digits
-					textPosX += 18;
-				else // 3 digits
-					textPosX += 15;
-
-				textPosY = 16;
-			} else {
-				blitBox._y2 = 6;
-				blitBox._x1 = textPosX;
-				blitBox._x2 = blitBox._x1 + 47; /* Box is over the champion name in the status box */
-				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k15_damageToChampionSmallIndice), &blitBox, k24_byteWidth, k10_ColorFlesh, 7);
-				// Check the number of digits and sets the position accordingly.
-				if (pendingDamage < 10) // 1 digit
-					textPosX += 19;
-				else if (pendingDamage < 100) // 2 digits
-					textPosX += 16;
-				else //3 digits
-					textPosX += 13;
-
-				textPosY = 5;
-			}
-			_vm->_textMan->f53_printToLogicalScreen(textPosX, textPosY, k15_ColorWhite, k8_ColorRed, f288_getStringFromInteger(pendingDamage, false, 3).c_str());
-
-			int16 eventIndex = championPtr->_hideDamageReceivedIndex;
-			if (eventIndex == -1) {
-				TimelineEvent newEvent;
-				newEvent._type = k12_TMEventTypeHideDamageReceived;
-				M33_setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
-				newEvent._priority = championIndex;
-				championPtr->_hideDamageReceivedIndex = _vm->_timeline->f238_addEventGetEventIndex(&newEvent);
-			} else {
-				TimelineEvent *curEvent = &_vm->_timeline->_g370_events[eventIndex];
-				M33_setMapAndTime(curEvent->_mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
-				_vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(eventIndex));
-			}
-			f292_drawChampionState((ChampionIndex)championIndex);
-			_vm->_eventMan->f77_hideMouse();
-		}
-	}
-}
-
-void ChampionMan::f319_championKill(uint16 champIndex) {
-	Champion *curChampion = &_gK71_champions[champIndex];
-	curChampion->_currHealth = 0;
-	setFlag(curChampion->_attributes, k0x1000_ChampionAttributeStatusBox);
-	if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
-		if (_vm->_g331_pressingEye) {
-			_vm->_g331_pressingEye = false;
-			_vm->_eventMan->_g597_ignoreMouseMovements = false;
-			if (!_g415_leaderEmptyHanded) {
-				_vm->_objectMan->f34_drawLeaderObjectName(_g414_leaderHandObject);
-			}
-			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
-			_vm->_eventMan->f77_hideMouse();
-		} else if (_vm->_g333_pressingMouth) {
-			_vm->_g333_pressingMouth = false;
-			_vm->_eventMan->_g597_ignoreMouseMovements = false;
-			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
-			_vm->_eventMan->f77_hideMouse();
-		}
-		_vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
-	}
-	f318_dropAllObjects(champIndex);
-	Thing unusedThing = _vm->_dungeonMan->f166_getUnusedThing(k0x8000_championBones | k10_JunkThingType);
-	uint16 curCell = 0;
-	if (unusedThing != Thing::_none) {
-		Junk *L0966_ps_Junk = (Junk *)_vm->_dungeonMan->f156_getThingData(unusedThing);
-		L0966_ps_Junk->setType(k5_JunkTypeBones);
-		L0966_ps_Junk->setDoNotDiscard(true);
-		L0966_ps_Junk->setChargeCount(champIndex);
-		curCell = curChampion->_cell;
-		_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(unusedThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
-	}
-	curChampion->_symbolStep = 0;
-	curChampion->_symbols[0] = '\0';
-	curChampion->_dir = _vm->_dungeonMan->_g308_partyDir;
-	curChampion->_maximumDamageReceived = 0;
-	uint16 curChampionIconIndex = M26_championIconIndex(curCell, _vm->_dungeonMan->_g308_partyDir);
-	if (_vm->M0_indexToOrdinal(curChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
-		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
-		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
-		warning(false, "IGNORED CODE:G0592_B_BuildMousePointerScreenAreaRequested = true");
-	}
-
-	if (curChampion->_poisonEventCount)
-		f323_unpoison(champIndex);
-
-	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[curChampionIconIndex << 2], k0_ColorBlack);
-	f292_drawChampionState((ChampionIndex)champIndex);
-
-	int16 aliveChampionIndex;
-	for (aliveChampionIndex = k0_ChampionFirst, curChampion = _gK71_champions; aliveChampionIndex < _g305_partyChampionCount; aliveChampionIndex++, curChampion++) {
-		if (curChampion->_currHealth)
-			break;
-	}
-
-	if (aliveChampionIndex == _g305_partyChampionCount) { /* BUG0_43 The game does not end if the last living champion in the party is killed while looking at a candidate champion in a portrait. The condition to end the game when the whole party is killed is not true because the code considers the candidate champion as alive (in the loop above) */
-		_g303_partyDead = true;
-		return;
-	}
-
-	if (champIndex == _g411_leaderIndex)
-		_vm->_eventMan->f368_commandSetLeader((ChampionIndex)aliveChampionIndex);
-
-	if (champIndex == _g514_magicCasterChampionIndex)
-		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(aliveChampionIndex);
-	else
-		_vm->_menuMan->f393_drawSpellAreaControls(_g514_magicCasterChampionIndex);
-}
-
-void ChampionMan::f318_dropAllObjects(uint16 champIndex) {
-	static const int16 slotDropOrder[30] = {
-		k5_ChampionSlotFeet,
-		k4_ChampionSlotLegs,
-		k9_ChampionSlotQuiverLine_2_2,
-		k8_ChampionSlotQuiverLine_1_2,
-		k7_ChampionSlotQuiverLine_2_1,
-		k12_ChampionSlotQuiverLine_1_1,
-		k6_ChampionSlotPouch_2,
-		k11_ChampionSlotPouch_1,
-		k3_ChampionSlotTorso,
-		k13_ChampionSlotBackpackLine_1_1,
-		k14_ChampionSlotBackpackLine_2_2,
-		k15_ChampionSlotBackpackLine_2_3,
-		k16_ChampionSlotBackpackLine_2_4,
-		k17_ChampionSlotBackpackLine_2_5,
-		k18_ChampionSlotBackpackLine_2_6,
-		k19_ChampionSlotBackpackLine_2_7,
-		k20_ChampionSlotBackpackLine_2_8,
-		k21_ChampionSlotBackpackLine_2_9,
-		k22_ChampionSlotBackpackLine_1_2,
-		k23_ChampionSlotBackpackLine_1_3,
-		k24_ChampionSlotBackpackLine_1_4,
-		k25_ChampionSlotBackpackLine_1_5,
-		k26_ChampionSlotBackpackLine_1_6,
-		k27_ChampionSlotBackpackLine_1_7,
-		k28_ChampionSlotBackpackLine_1_8,
-		k29_ChampionSlotBackpackLine_1_9,
-		k10_ChampionSlotNeck,
-		k2_ChampionSlotHead,
-		k0_ChampionSlotReadyHand,
-		k1_ChampionSlotActionHand
-	};
-
-	uint16 curCell = _gK71_champions[champIndex]._cell;
-	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
-		Thing curThing = f300_getObjectRemovedFromSlot(champIndex, slotDropOrder[slotIndex]);
-		if (curThing != Thing::_none)
-			_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(curThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
-	}
-}
-
-void ChampionMan::f323_unpoison(int16 champIndex) {
-	if (champIndex == kM1_ChampionNone)
-		return;
-
-	TimelineEvent *eventPtr = _vm->_timeline->_g370_events;
-	for (uint16 eventIndex = 0; eventIndex < _vm->_timeline->_g369_eventMaxCount; eventPtr++, eventIndex++) {
-		if ((eventPtr->_type == k75_TMEventTypePoisonChampion) && (eventPtr->_priority == champIndex))
-			_vm->_timeline->f237_deleteEvent(eventIndex);
-	}
-	_gK71_champions[champIndex]._poisonEventCount = 0;
-}
-
-void ChampionMan::f331_applyTimeEffects() {
-	if (!_g305_partyChampionCount)
-		return;
-
-	Scent checkScent;
-	checkScent.setMapX(_vm->_dungeonMan->_g306_partyMapX);
-	checkScent.setMapY(_vm->_dungeonMan->_g307_partyMapY);
-	checkScent.setMapIndex(_vm->_dungeonMan->_g309_partyMapIndex);
-
-	for (byte loopScentIndex = 0; loopScentIndex + 1 < _g407_party._scentCount; loopScentIndex++) {
-		if (&_g407_party._scents[loopScentIndex] != &checkScent) {
-			_g407_party._scentStrengths[loopScentIndex] = MAX(0, _g407_party._scentStrengths[loopScentIndex] - 1);
-			if (!_g407_party._scentStrengths[loopScentIndex] && !loopScentIndex) {
-				f316_deleteScent(0);
-				continue;
-			}
-		}
-	}
-
-	uint16 gameTime = _vm->_g313_gameTime & 0xFFFF;
-	uint16 timeCriteria = (((gameTime & 0x0080) + ((gameTime & 0x0100) >> 2)) + ((gameTime & 0x0040) << 2)) >> 2;
-	Champion *championPtr = _gK71_champions;
-	for (uint16 championIndex = k0_ChampionFirst; championIndex < _g305_partyChampionCount; championIndex++, championPtr++) {
-		if (championPtr->_currHealth && (_vm->M0_indexToOrdinal(championIndex) != _g299_candidateChampionOrdinal)) {
-			uint16 wizardSkillLevel = f303_getSkillLevel(championIndex, k3_ChampionSkillWizard) + f303_getSkillLevel(championIndex, k2_ChampionSkillPriest);
-			if ((championPtr->_currMana < championPtr->_maxMana)
-				&& (timeCriteria < championPtr->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + wizardSkillLevel)) {
-				int16 manaGain = championPtr->_maxMana / 40;
-				if (_g300_partyIsSleeping)
-					manaGain <<= 1;
-
-				manaGain++;
-				f325_decrementStamina(championIndex, manaGain * MAX(7, 16 - wizardSkillLevel));
-				championPtr->_currMana += MIN<int16>(manaGain, championPtr->_maxMana - championPtr->_currMana);
-			} else if (championPtr->_currMana > championPtr->_maxMana)
-				championPtr->_currMana--;
-
-			for (int16 idx = k19_ChampionSkillWater; idx >= k0_ChampionSkillFighter; idx--) {
-				if (championPtr->_skills[idx]._temporaryExperience > 0)
-					championPtr->_skills[idx]._temporaryExperience--;
-			}
-			uint16 staminaGainCycleCount = 4;
-			int16 staminaMagnitude = championPtr->_maxStamina;
-			while (championPtr->_currStamina < (staminaMagnitude >>= 1))
-				staminaGainCycleCount += 2;
-
-			int16 staminaLoss = 0;
-			int16 staminaAmount = f26_getBoundedValue(1, (championPtr->_maxStamina >> 8) - 1, 6);
-			if (_g300_partyIsSleeping)
-				staminaAmount <<= 1;
-
-			int32 compDelay = _vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime;
-			if (compDelay > 80) {
-				staminaAmount++;
-				if (compDelay > 250)
-					staminaAmount++;
-			}
-			do {
-				bool staminaAboveHalf = (staminaGainCycleCount <= 4);
-				if (championPtr->_food < -512) {
-					if (staminaAboveHalf) {
-						staminaLoss += staminaAmount;
-						championPtr->_food -= 2;
-					}
-				} else {
-					if (championPtr->_food >= 0)
-						staminaLoss -= staminaAmount;
-
-					championPtr->_food -= staminaAboveHalf ? 2 : staminaGainCycleCount >> 1;
-				}
-				if (championPtr->_water < -512) {
-					if (staminaAboveHalf) {
-						staminaLoss += staminaAmount;
-						championPtr->_water -= 1;
-					}
-				} else {
-					if (championPtr->_water >= 0)
-						staminaLoss -= staminaAmount;
-
-					championPtr->_water -= staminaAboveHalf ? 1 : staminaGainCycleCount >> 2;
-				}
-			} while (--staminaGainCycleCount && ((championPtr->_currStamina - staminaLoss) < championPtr->_maxStamina));
-			f325_decrementStamina(championIndex, staminaLoss);
-			if (championPtr->_food < -1024)
-				championPtr->_food = -1024;
-
-			if (championPtr->_water < -1024)
-				championPtr->_water = -1024;
-
-			if ((championPtr->_currHealth < championPtr->_maxHealth) && (championPtr->_currStamina >= (championPtr->_maxStamina >> 2)) && (timeCriteria < (championPtr->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] + 12))) {
-				int16 healthGain = (championPtr->_maxHealth >> 7) + 1;
-				if (_g300_partyIsSleeping)
-					healthGain <<= 1;
-
-				if (_vm->_objectMan->f33_getIconIndex(championPtr->_slots[k10_ChampionSlotNeck]) == k121_IconIndiceJunkEkkhardCross)
-					healthGain += (healthGain >> 1) + 1;
-
-				championPtr->_currHealth += MIN(healthGain, (int16)(championPtr->_maxHealth - championPtr->_currHealth));
-			}
-			if (!((int)_vm->_g313_gameTime & (_g300_partyIsSleeping ? 63 : 255))) {
-				for (uint16 i = k0_ChampionStatLuck; i <= k6_ChampionStatAntifire; i++) {
-					byte *curStatistic = championPtr->_statistics[i];
-					uint16 statisticMaximum = curStatistic[k0_ChampionStatMaximum];
-					if (curStatistic[k1_ChampionStatCurrent] < statisticMaximum)
-						curStatistic[k1_ChampionStatCurrent]++;
-					else if (curStatistic[k1_ChampionStatCurrent] > statisticMaximum)
-						curStatistic[k1_ChampionStatCurrent] -= curStatistic[k1_ChampionStatCurrent] / statisticMaximum;
-				}
-			}
-			if (!_g300_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_g313_gameTime)) {
-				championPtr->_dir = _vm->_dungeonMan->_g308_partyDir;
-				championPtr->_maximumDamageReceived = 0;
-				setFlag(championPtr->_attributes, k0x0400_ChampionAttributeIcon);
-			}
-			setFlag(championPtr->_attributes, k0x0100_ChampionAttributeStatistics);
-			if (_vm->M0_indexToOrdinal(championIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
-				if (_vm->_g333_pressingMouth || _vm->_g331_pressingEye || (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
-					setFlag(championPtr->_attributes, k0x0800_ChampionAttributePanel);
-				}
-			}
-		}
-	}
-	f293_drawAllChampionStates();
-}
-
-void ChampionMan::save2_PartyPart(Common::OutSaveFile* file) {
-	for (uint16 i = 0; i < 4; ++i) {
-		Champion *champ = &_gK71_champions[i];
-		file->writeUint16BE(champ->_attributes);
-		file->writeUint16BE(champ->_wounds);
-		for (uint16 y = 0; y < 7; ++y)
-			for (uint16 x = 0; x < 3; ++x)
-				file->writeByte(champ->_statistics[y][x]);
-		for (uint16 j = 0; j < 30; ++j)
-			file->writeUint16BE(champ->_slots[j].toUint16());
-		for (uint16 j = 0; j < 20; ++j) {
-			file->writeSint16BE(champ->_skills[j]._temporaryExperience);
-			file->writeSint32BE(champ->_skills[j]._experience);
-		}
-		for (uint16 j = 0; j < 8; ++j)
-			file->writeByte(champ->_name[j]);
-		for (uint16 j = 0; j < 20; ++j)
-			file->writeByte(champ->_title[j]);
-		file->writeUint16BE(champ->_dir);
-		file->writeUint16BE(champ->_cell);
-		file->writeUint16BE(champ->_actionIndex);
-		file->writeUint16BE(champ->_symbolStep);
-		for (uint16 j = 0; j < 5; ++j)
-			file->writeByte(champ->_symbols[j]);
-		file->writeUint16BE(champ->_directionMaximumDamageReceived);
-		file->writeUint16BE(champ->_maximumDamageReceived);
-		file->writeUint16BE(champ->_poisonEventCount);
-		file->writeSint16BE(champ->_enableActionEventIndex);
-		file->writeSint16BE(champ->_hideDamageReceivedIndex);
-		file->writeSint16BE(champ->_currHealth);
-		file->writeSint16BE(champ->_maxHealth);
-		file->writeSint16BE(champ->_currStamina);
-		file->writeSint16BE(champ->_maxStamina);
-		file->writeSint16BE(champ->_currMana);
-		file->writeSint16BE(champ->_maxMana);
-		file->writeSint16BE(champ->_actionDefense);
-		file->writeSint16BE(champ->_food);
-		file->writeSint16BE(champ->_water);
-		file->writeUint16BE(champ->_load);
-		file->writeSint16BE(champ->_shieldDefense);
-		for (uint16 j = 0; j < 928; ++j)
-			file->writeByte(champ->_portrait[j]);
-	}
-
-	Party &party = _g407_party;
-	file->writeSint16BE(party._magicalLightAmount);
-	file->writeByte(party._event73Count_ThievesEye);
-	file->writeByte(party._event79Count_Footprints);
-	file->writeSint16BE(party._shieldDefense);
-	file->writeSint16BE(party._fireShieldDefense);
-	file->writeSint16BE(party._spellShieldDefense);
-	file->writeByte(party._scentCount);
-	file->writeByte(party._freezeLifeTicks);
-	file->writeByte(party._firstScentIndex);
-	file->writeByte(party._lastScentIndex);
-	for (uint16 i = 0; i < 24; ++i)
-		file->writeUint16BE(party._scents[i].toUint16());
-	for (uint16 i = 0; i < 24; ++i)
-		file->writeByte(party._scentStrengths[i]);
-	file->writeByte(party._event71Count_Invisibility);
-}
-
-void ChampionMan::load2_PartyPart(Common::InSaveFile* file) {
-	for (uint16 i = 0; i < 4; ++i) {
-		Champion *champ = &_gK71_champions[i];
-		champ->_attributes = file->readUint16BE();
-		champ->_wounds = file->readUint16BE();
-		for (uint16 y = 0; y < 7; ++y)
-			for (uint16 x = 0; x < 3; ++x)
-				champ->_statistics[y][x] = file->readByte();
-		for (uint16 j = 0; j < 30; ++j)
-			champ->_slots[j] = Thing(file->readUint16BE());
-		for (uint16 j = 0; j < 20; ++j) {
-			champ->_skills[j]._temporaryExperience = file->readSint16BE();
-			champ->_skills[j]._experience = file->readSint32BE();
-		}
-		for (uint16 j = 0; j < 8; ++j)
-			champ->_name[j] = file->readByte();
-		for (uint16 j = 0; j < 20; ++j)
-			champ->_title[j] = file->readByte();
-		champ->_dir = (Direction)file->readUint16BE();
-		champ->_cell = (ViewCell)file->readUint16BE();
-		champ->_actionIndex = (ChampionAction)file->readUint16BE();
-		champ->_symbolStep = file->readUint16BE();
-		for (uint16 j = 0; j < 5; ++j)
-			champ->_symbols[j] = file->readByte();
-		champ->_directionMaximumDamageReceived = file->readUint16BE();
-		champ->_maximumDamageReceived = file->readUint16BE();
-		champ->_poisonEventCount = file->readUint16BE();
-		champ->_enableActionEventIndex = file->readSint16BE();
-		champ->_hideDamageReceivedIndex = file->readSint16BE();
-		champ->_currHealth = file->readSint16BE();
-		champ->_maxHealth = file->readSint16BE();
-		champ->_currStamina = file->readSint16BE();
-		champ->_maxStamina = file->readSint16BE();
-		champ->_currMana = file->readSint16BE();
-		champ->_maxMana = file->readSint16BE();
-		champ->_actionDefense = file->readSint16BE();
-		champ->_food = file->readSint16BE();
-		champ->_water = file->readSint16BE();
-		champ->_load = file->readUint16BE();
-		champ->_shieldDefense = file->readSint16BE();
-		for (uint16 j = 0; j < 928; ++j)
-			champ->_portrait[j] = file->readByte();
-	}
-
-	Party &party = _g407_party;
-	party._magicalLightAmount = file->readSint16BE();
-	party._event73Count_ThievesEye = file->readByte();
-	party._event79Count_Footprints = file->readByte();
-	party._shieldDefense = file->readSint16BE();
-	party._fireShieldDefense = file->readSint16BE();
-	party._spellShieldDefense = file->readSint16BE();
-	party._scentCount = file->readByte();
-	party._freezeLifeTicks = file->readByte();
-	party._firstScentIndex = file->readByte();
-	party._lastScentIndex = file->readByte();
-	for (uint16 i = 0; i < 24; ++i)
-		party._scents[i] = Scent(file->readUint16BE());
-	for (uint16 i = 0; i < 24; ++i)
-		party._scentStrengths[i] = file->readByte();
-	party._event71Count_Invisibility = file->readByte();
-}
-
-ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
-	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
-		if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
-			return (ChampionIndex)i;
-	}
-
-	return kM1_ChampionNone;
-}
-
-void ChampionMan::f278_resetDataToStartGame() {
-	if (!_vm->_g298_newGame) {
-		Thing L0787_T_Thing;
-		if ((L0787_T_Thing = _g414_leaderHandObject) == Thing::_none) {
-			_g415_leaderEmptyHanded = true;
-			_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
-			_vm->_eventMan->f69_setMousePointer();
-		} else {
-			f297_putObjectInLeaderHand(L0787_T_Thing, true); /* This call will add the weight of the leader hand object to the Load of the leader a first time */
-		}
-		Champion *L0788_ps_Champion = _gK71_champions;
-		int16 L0785_i_ChampionIndex;
-		for (L0785_i_ChampionIndex = k0_ChampionFirst; L0785_i_ChampionIndex < _g305_partyChampionCount; L0785_i_ChampionIndex++, L0788_ps_Champion++) {
-			clearFlag(L0788_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
-			setFlag(L0788_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
-		}
-		f293_drawAllChampionStates();
-		if ((L0785_i_ChampionIndex = _g411_leaderIndex) != kM1_ChampionNone) {
-			_g411_leaderIndex = kM1_ChampionNone;
-			_vm->_eventMan->f368_commandSetLeader((ChampionIndex)L0785_i_ChampionIndex);
-		}
-		if ((L0785_i_ChampionIndex = _g514_magicCasterChampionIndex) != kM1_ChampionNone) {
-			_g514_magicCasterChampionIndex = kM1_ChampionNone;
-			_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(L0785_i_ChampionIndex);
-		}
-		return;
-	}
-
-	_g414_leaderHandObject = Thing::_none;
-	_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
-	_g415_leaderEmptyHanded = true;
-}
-
-void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) {
-	if (!_g415_leaderEmptyHanded)
-		return;
-
-	if (_g305_partyChampionCount == 4)
-		return;
-
-	uint16 previousPartyChampionCount = _g305_partyChampionCount;
-	Champion *championPtr = &_gK71_champions[previousPartyChampionCount];
-	championPtr->resetToZero();
-	// Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portraits could be missing in the data)
-	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
-	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, gBoxChampionPortrait, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency);
-	championPtr->_actionIndex = k255_ChampionActionNone;
-	championPtr->_enableActionEventIndex = -1;
-	championPtr->_hideDamageReceivedIndex = -1;
-	championPtr->_dir = _vm->_dungeonMan->_g308_partyDir;
-	uint16 viewCell = k0_ViewCellFronLeft;
-	while (f285_getIndexInCell(M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone)
-		viewCell++;
-
-	championPtr->_cell = (ViewCell)M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir);
-	championPtr->_attributes = k0x0400_ChampionAttributeIcon;
-	championPtr->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir;
-	championPtr->_food = 1500 + _vm->getRandomNumber(256);
-	championPtr->_water = 1500 + _vm->getRandomNumber(256);
-	for (int16 slotIdx = k0_ChampionSlotReadyHand; slotIdx < k30_ChampionSlotChest_1; slotIdx++)
-		championPtr->_slots[slotIdx] = Thing::_none;
-
-	Thing curThing = _vm->_dungeonMan->f161_getSquareFirstThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
-	while (curThing.getType() != k2_TextstringType)
-		curThing = _vm->_dungeonMan->f159_getNextThing(curThing);
-
-	char L0807_ac_DecodedChampionText[77];
-	char *decodedStringPtr = L0807_ac_DecodedChampionText;
-	_vm->_dungeonMan->f168_decodeText(decodedStringPtr, curThing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
-
-	uint16 charIdx = 0;
-	char tmpChar;
-	while ((tmpChar = *decodedStringPtr++) != '\n')
-		championPtr->_name[charIdx++] = tmpChar;
-
-	championPtr->_name[charIdx] = '\0';
-	charIdx = 0;
-	bool championTitleCopiedFl = false;
-	for (;;) { /*_Infinite loop_*/
-		tmpChar = *decodedStringPtr++;
-		if (tmpChar == '\n') { /* New line */
-			if (championTitleCopiedFl)
-				break;
-			championTitleCopiedFl = true;
-		} else
-			championPtr->_title[charIdx++] = tmpChar;
-	}
-	championPtr->_title[charIdx] = '\0';
-	if (*decodedStringPtr++ == 'M')
-		setFlag(championPtr->_attributes, k0x0010_ChampionAttributeMale);
-
-	decodedStringPtr++;
-	championPtr->_currHealth = championPtr->_maxHealth = f279_getDecodedValue(decodedStringPtr, 4);
-	decodedStringPtr += 4;
-	championPtr->_currStamina = championPtr->_maxStamina = f279_getDecodedValue(decodedStringPtr, 4);
-	decodedStringPtr += 4;
-	championPtr->_currMana = championPtr->_maxMana = f279_getDecodedValue(decodedStringPtr, 4);
-	decodedStringPtr += 4;
-	decodedStringPtr++;
-	for (int16 statIdx = k0_ChampionStatLuck; statIdx <= k6_ChampionStatAntifire; statIdx++) {
-		championPtr->_statistics[statIdx][k2_ChampionStatMinimum] = 30;
-		championPtr->_statistics[statIdx][k1_ChampionStatCurrent] = championPtr->_statistics[statIdx][k0_ChampionStatMaximum] = f279_getDecodedValue(decodedStringPtr, 2);
-		decodedStringPtr += 2;
-	}
-	championPtr->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10;
-	decodedStringPtr++;
-	for (uint16 skillIdx = k4_ChampionSkillSwing; skillIdx <= k19_ChampionSkillWater; skillIdx++) {
-		int skillValue = *decodedStringPtr++ - 'A';
-		if (skillValue > 0)
-			championPtr->_skills[skillIdx]._experience = 125L << skillValue;
-	}
-	for (uint16 skillIdx = k0_ChampionSkillFighter; skillIdx <= k3_ChampionSkillWizard; skillIdx++) {
-		int32 baseSkillExperience = 0;
-		int16 hiddenSkillIndex = (skillIdx + 1) << 2;
-		for (uint16 hiddenIdx = 0; hiddenIdx < 4; hiddenIdx++)
-			baseSkillExperience += championPtr->_skills[hiddenSkillIndex + hiddenIdx]._experience;
-
-		championPtr->_skills[skillIdx]._experience = baseSkillExperience;
-	}
-	_g299_candidateChampionOrdinal = previousPartyChampionCount + 1;
-	if (++_g305_partyChampionCount == 1) {
-		_vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst);
-		_vm->_menuMan->_g508_refreshActionArea = true;
-	} else {
-		_vm->_menuMan->f388_clearActingChampion();
-		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1));
-	}
-
-	int16 curMapX = _vm->_dungeonMan->_g306_partyMapX;
-	int16 curMapY = _vm->_dungeonMan->_g307_partyMapY;
-	uint16 championObjectsCell = returnOppositeDir(_vm->_dungeonMan->_g308_partyDir);
-	curMapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], curMapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
-	curThing = _vm->_dungeonMan->f161_getSquareFirstThing(curMapX, curMapY);
-	int16 slotIdx = k13_ChampionSlotBackpackLine_1_1;
-	while (curThing != Thing::_endOfList) {
-		ThingType thingType = curThing.getType();
-		if ((thingType > k3_SensorThingType) && (curThing.getCell() == championObjectsCell)) {
-			int16 objectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(curThing)]._allowedSlots;
-			uint16 curSlotIndex;
-			switch (thingType) {
-			case k6_ArmourThingType: {
-				bool skipCheck = false;
-				for (curSlotIndex = k2_ChampionSlotHead; curSlotIndex <= k5_ChampionSlotFeet; curSlotIndex++) {
-					if (objectAllowedSlots & gSlotMasks[curSlotIndex]) {
-						skipCheck = true;
-						break;
-					}
-				}
-
-				if (skipCheck)
-					break;
-
-				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
-					curSlotIndex = k10_ChampionSlotNeck;
-				else
-					curSlotIndex = slotIdx++;
-
-				break;
-			}
-			case k5_WeaponThingType:
-				if (championPtr->_slots[k1_ChampionSlotActionHand] == Thing::_none)
-					curSlotIndex = k1_ChampionSlotActionHand;
-				else if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
-					curSlotIndex = k10_ChampionSlotNeck;
-				else
-					curSlotIndex = slotIdx++;
-				break;
-			case k7_ScrollThingType:
-			case k8_PotionThingType:
-				if (championPtr->_slots[k11_ChampionSlotPouch_1] == Thing::_none)
-					curSlotIndex = k11_ChampionSlotPouch_1;
-				else if (championPtr->_slots[k6_ChampionSlotPouch_2] == Thing::_none)
-					curSlotIndex = k6_ChampionSlotPouch_2;
-				else if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
-					curSlotIndex = k10_ChampionSlotNeck;
-				else
-					curSlotIndex = slotIdx++;
-				break;
-			case k9_ContainerThingType:
-			case k10_JunkThingType:
-				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
-					curSlotIndex = k10_ChampionSlotNeck;
-				else
-					curSlotIndex = slotIdx++;
-
-				break;
-			default:
-				break;
-			}
-
-			while (championPtr->_slots[curSlotIndex] != Thing::_none) {
-				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
-					curSlotIndex = k10_ChampionSlotNeck;
-				else
-					curSlotIndex = slotIdx++;
-			}
-			f301_addObjectInSlot((ChampionIndex)previousPartyChampionCount, curThing, (ChampionSlot)curSlotIndex);
-		}
-		curThing = _vm->_dungeonMan->f159_getNextThing(curThing);
-	}
-	_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)previousPartyChampionCount);
-	_vm->_menuMan->f456_drawDisabledMenu();;
-}
-
-void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
-	int16 barGraphHeights[3];
-	Champion *champ = &_gK71_champions[champIndex];
-	int16 barGraphIdx = 0;
-	if (champ->_currHealth > 0) {
-		int32 barGraphHeight = (((int32)champ->_currHealth << 10) * 25) / champ->_maxHealth;
-		barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + ((barGraphHeight & 0x000003FF) ? 1 : 0);
-	} else
-		barGraphHeights[barGraphIdx++] = 0;
-
-	if (champ->_currStamina > 0) {
-		int32 barGraphHeight = (((int32)champ->_currStamina << 10) * 25) / champ->_maxStamina;
-		barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + ((barGraphHeight & 0x000003FF) ? 1 : 0);
-	} else
-		barGraphHeights[barGraphIdx++] = 0;
-
-	if (champ->_currMana > 0) {
-		if (champ->_currMana > champ->_maxMana)
-			barGraphHeights[barGraphIdx] = 25;
-		else {
-			int32 barGraphHeight = (((int32)champ->_currMana << 10) * 25) / champ->_maxMana;
-			barGraphHeights[barGraphIdx] = (barGraphHeight >> 10) + ((barGraphHeight & 0x000003FF) ? 1 : 0);
-		}
-	} else {
-		barGraphHeights[barGraphIdx] = 0;
-	}
-	_vm->_eventMan->f78_showMouse();
-
-	// Strangerke - TO CHECK: if portraits, maybe the old (assembly) code is required for older versions
-	Box box;
-	box._x1 = champIndex * k69_ChampionStatusBoxSpacing + 46;
-	box._x2 = box._x1 + 3;
-	box._y1 = 2;
-	box._y2 = 26;
-	for (int16 barGraphIndex = 0; barGraphIndex < 3; barGraphIndex++) {
-		int16 barGraphHeight = barGraphHeights[barGraphIndex];
-		if (barGraphHeight < 25) {
-			box._y1 = 2;
-			box._y2 = 27 - barGraphHeight;
-			_vm->_displayMan->D24_fillScreenBox(box, k12_ColorDarkestGray);
-		}
-		if (barGraphHeight) {
-			box._y1 = 27 - barGraphHeight;
-			box._y2 = 26;
-			_vm->_displayMan->D24_fillScreenBox(box, g46_ChampionColor[champIndex]);
-		}
-		box._x1 += 7;
-		box._x2 += 7;
-	}
-	_vm->_eventMan->f77_hideMouse();
-}
-
-
-uint16 ChampionMan::f306_getStaminaAdjustedValue(Champion *champ, int16 val) {
-	int16 currStamina = champ->_currStamina;
-	int16 halfMaxStamina = champ->_maxStamina / 2;
-	if (currStamina < halfMaxStamina) {
-		warning(false, "Possible undefined behavior in the original code");
-		val /= 2;
-		return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina;
-	}
-	return val;
-}
-
-uint16 ChampionMan::f309_getMaximumLoad(Champion *champ) {
-	uint16 maximumLoad = champ->getStatistic(k1_ChampionStatStrength, k1_ChampionStatCurrent) * 8 + 100;
-	maximumLoad = f306_getStaminaAdjustedValue(champ, maximumLoad);
-	int16 wounds = champ->getWounds();
-	if (wounds)
-		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(k0x0010_ChampionWoundLegs) ? 2 : 3);
-
-	if (_vm->_objectMan->f33_getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == k119_IconIndiceArmourElvenBoots)
-		maximumLoad += maximumLoad * 16;
-
-	maximumLoad += 9;
-	maximumLoad -= maximumLoad % 10;
-	return maximumLoad;
-}
-
-void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
-	int16 championStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
-	Champion *curChampion = &_gK71_champions[champIndex];
-	uint16 championAttributes = curChampion->_attributes;
-	if (!getFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand))
-		return;
-
-	bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
-	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_vm->_eventMan->f78_showMouse();
-	if (getFlag(championAttributes, k0x1000_ChampionAttributeStatusBox)) {
-		Box box;
-		box._y1 = 0;
-		box._y2 = 28;
-		box._x1 = championStatusBoxX;
-		box._x2 = box._x1 + 66;
-		if (curChampion->_currHealth) {
-			_vm->_displayMan->D24_fillScreenBox(box, k12_ColorDarkestGray);
-			int16 nativeBitmapIndices[3];
-			for (uint16 i = 0; i < 3; ++i)
-				nativeBitmapIndices[i] = 0;
-
-			uint16 borderCount = 0;
-			if (_g407_party._fireShieldDefense > 0)
-				nativeBitmapIndices[borderCount++] = k38_BorderPartyFireshieldIndice;
-
-			if (_g407_party._spellShieldDefense > 0)
-				nativeBitmapIndices[borderCount++] = k39_BorderPartySpellshieldIndice;
-
-			if ((_g407_party._shieldDefense > 0) || curChampion->_shieldDefense)
-				nativeBitmapIndices[borderCount++] = k37_BorderPartyShieldIndice;
-
-			while (borderCount--)
-				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndices[borderCount]), &box, k40_byteWidth, k10_ColorFlesh, 29);
-
-			if (isInventoryChampion) {
-				_vm->_inventoryMan->f354_drawStatusBoxPortrait(champIndex);
-				setFlag(championAttributes, k0x0100_ChampionAttributeStatistics);
-			} else
-				setFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand);
-		} else {
-			_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), &box, k40_byteWidth, kM1_ColorNoTransparency, 29);
-			_vm->_textMan->f53_printToLogicalScreen(championStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, curChampion->_name);
-			_vm->_menuMan->f386_drawActionIcon(champIndex);
-
-			clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
-			_vm->_eventMan->f77_hideMouse();
-			return;
-		}
-	}
-	if (!(curChampion->_currHealth)) {
-		clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
-		_vm->_eventMan->f77_hideMouse();
-		return;
-	}
-
-	if (getFlag(championAttributes, k0x0080_ChampionAttributeNameTitle)) {
-		Color nameColor = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
-		if (isInventoryChampion) {
-			char *championName = curChampion->_name;
-			_vm->_textMan->f52_printToViewport(3, 7, nameColor, championName);
-			int16 championTitleX = 6 * strlen(championName) + 3;
-			char titleFirstCharacter = curChampion->_title[0];
-			if ((titleFirstCharacter != ',') && (titleFirstCharacter != ';') && (titleFirstCharacter != '-'))
-				championTitleX += 6;
-
-			_vm->_textMan->f52_printToViewport(championTitleX, 7, nameColor, curChampion->_title);
-			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
-		} else {
-			Box box;
-			box._y1 = 0;
-			box._y2 = 6;
-			box._x1 = championStatusBoxX;
-			box._x2 = box._x1 + 42;
-			_vm->_displayMan->D24_fillScreenBox(box, k1_ColorDarkGary);
-			_vm->_textMan->f53_printToLogicalScreen(championStatusBoxX + 1, 5, nameColor, k1_ColorDarkGary, curChampion->_name);
-		}
-	}
-	if (getFlag(championAttributes, k0x0100_ChampionAttributeStatistics)) {
-		f287_drawChampionBarGraphs(champIndex);
-		if (isInventoryChampion) {
-			f290_drawHealthStaminaManaValues(curChampion);
-			int16 nativeBitmapIndex;
-			if ((curChampion->_food < 0) || (curChampion->_water < 0) || (curChampion->_poisonEventCount))
-				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
-			else
-				nativeBitmapIndex = k33_SlotBoxNormalIndice;
-
-			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), gBoxMouth, k16_byteWidth, k12_ColorDarkestGray, 18);
-			nativeBitmapIndex = k33_SlotBoxNormalIndice;
-			for (int i = k1_ChampionStatStrength; i <= k6_ChampionStatAntifire; i++) {
-				if ((curChampion->_statistics[i][k1_ChampionStatCurrent] < curChampion->_statistics[i][k0_ChampionStatMaximum])) {
-					nativeBitmapIndex = k34_SlotBoxWoundedIndice;
-					break;
-				}
-			}
-			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), gBoxEye, k16_byteWidth, k12_ColorDarkestGray, 18);
-			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
-		}
-	}
-	if (getFlag(championAttributes, k0x2000_ChampionAttributeWounds)) {
-		for (int i = isInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; i >= k0_ChampionSlotReadyHand; i--)
-			f291_drawSlot(champIndex, i);
-
-		if (isInventoryChampion)
-			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
-	}
-	if (getFlag(championAttributes, k0x0200_ChampionAttributeLoad) && isInventoryChampion) {
-		uint16 maxLoad = f309_getMaximumLoad(curChampion);
-		Color loadColor;
-		if (curChampion->_load > maxLoad)
-			loadColor = k8_ColorRed;
-		else if (((long)curChampion->_load << 3) > ((long)maxLoad * 5))
-			loadColor = k11_ColorYellow;
-		else
-			loadColor = k13_ColorLightestGray;
-
-		_vm->_textMan->f52_printToViewport(104, 132, loadColor, "LOAD ");
-		maxLoad = curChampion->_load / 10;
-		strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, true, 3).c_str());
-		strcat(_vm->_g353_stringBuildBuffer, ".");
-		maxLoad = curChampion->_load - (maxLoad * 10);
-		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, false, 1).c_str());
-		strcat(_vm->_g353_stringBuildBuffer, "/");
-		maxLoad = (f309_getMaximumLoad(curChampion) + 5) / 10;
-		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, true, 3).c_str());
-		strcat(_vm->_g353_stringBuildBuffer, " KG");
-		_vm->_textMan->f52_printToViewport(148, 132, loadColor, _vm->_g353_stringBuildBuffer);
-		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
-	}
-	uint16 championIconIndex = M26_championIconIndex(curChampion->_cell, _vm->_dungeonMan->_g308_partyDir);
-	if (getFlag(championAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(championIconIndex))) {
-		_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[championIconIndex], g46_ChampionColor[champIndex]);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[championIconIndex], M26_championIconIndex(curChampion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
-	}
-	if (getFlag(championAttributes, k0x0800_ChampionAttributePanel) && isInventoryChampion) {
-		if (_vm->_g333_pressingMouth)
-			_vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned();
-		else if (_vm->_g331_pressingEye) {
-			if (_g415_leaderEmptyHanded)
-				_vm->_inventoryMan->f351_drawChampionSkillsAndStatistics();
-		} else
-			_vm->_inventoryMan->f347_drawPanel();
-
-		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
-	}
-	if (getFlag(championAttributes, k0x8000_ChampionAttributeActionHand)) {
-		f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
-		_vm->_menuMan->f386_drawActionIcon(champIndex);
-		if (isInventoryChampion)
-			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
-	}
-	if (getFlag(championAttributes, k0x4000_ChampionAttributeViewport))
-		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
-
-	clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
-	_vm->_eventMan->f77_hideMouse();
-}
-
-uint16 ChampionMan::M26_championIconIndex(int16 val, Direction dir) {
-	return ((val + 4 - dir) & 0x3);
-}
-
-void ChampionMan::f290_drawHealthStaminaManaValues(Champion* champ) {
-	f289_drawHealthOrStaminaOrManaValue(116, champ->_currHealth, champ->_maxHealth);
-	f289_drawHealthOrStaminaOrManaValue(124, champ->_currStamina, champ->_maxStamina);
-	f289_drawHealthOrStaminaOrManaValue(132, champ->_currMana, champ->_maxMana);
-}
-
-void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
-	int16 nativeBitmapIndex = -1;
-	Champion *champ = &_gK71_champions[champIndex];
-	bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex));
-
-	uint16 slotBoxIndex;
-	if (!isInventoryChamp) {
-		// If drawing a slot for a champion other than the champion whose inventory is open
-		if ((slotIndex > k1_ChampionSlotActionHand) || (_g299_candidateChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)))
-			return;
-		slotBoxIndex = (champIndex << 1) + slotIndex;
-	} else
-		slotBoxIndex = k8_SlotBoxInventoryFirstSlot + slotIndex;
-
-	Thing thing;
-	if (slotIndex >= k30_ChampionSlotChest_1)
-		thing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
-	else
-		thing = champ->getSlot((ChampionSlot)slotIndex);
-
-	SlotBox *slotBox = &_vm->_objectMan->_g30_slotBoxes[slotBoxIndex];
-	Box box;
-	box._x1 = slotBox->_x - 1;
-	box._y1 = slotBox->_y - 1;
-	box._x2 = box._x1 + 17;
-	box._y2 = box._y1 + 17;
-
-	if (!isInventoryChamp)
-		_vm->_eventMan->f77_hideMouse();
-
-	int16 iconIndex;
-	if (thing == Thing::_none) {
-		if (slotIndex <= k5_ChampionSlotFeet) {
-			iconIndex = k212_IconIndiceReadyHand + (slotIndex << 1);
-			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) {
-				iconIndex++;
-				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
-			} else
-				nativeBitmapIndex = k33_SlotBoxNormalIndice;
-		} else {
-			if ((slotIndex >= k10_ChampionSlotNeck) && (slotIndex <= k13_ChampionSlotBackpackLine_1_1))
-				iconIndex = k208_IconIndiceNeck + (slotIndex - k10_ChampionSlotNeck);
-			else
-				iconIndex = k204_IconIndiceEmptyBox;
-		}
-	} else {
-		iconIndex = _vm->_objectMan->f33_getIconIndex(thing); // BUG0_35
-		if (isInventoryChamp && (slotIndex == k1_ChampionSlotActionHand) && ((iconIndex == k144_IconIndiceContainerChestClosed) || (iconIndex == k30_IconIndiceScrollOpen))) {
-			iconIndex++;
-		} // BUG2_00
-		if (slotIndex <= k5_ChampionSlotFeet) {
-			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex)))
-				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
-			else
-				nativeBitmapIndex = k33_SlotBoxNormalIndice;
-		}
-	}
-
-	if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->M0_indexToOrdinal(champIndex) == _g506_actingChampionOrdinal))
-		nativeBitmapIndex = k35_SlotBoxActingHandIndice;
-
-	if (nativeBitmapIndex != -1) {
-		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		if (isInventoryChamp)
-			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
-												_vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray);
-		else
-			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
-												_vm->_displayMan->_g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen, k12_ColorDarkestGray);
-	}
-
-	_vm->_objectMan->f38_drawIconInSlotBox(slotBoxIndex, iconIndex);
-
-	if (!isInventoryChamp)
-		_vm->_eventMan->f78_showMouse();
-}
-
-void ChampionMan::f281_renameChampion(Champion* champ) {
-#define k1_RENAME_CHAMPION_NAME 1
-#define k2_RENAME_CHAMPION_TITLE 2
-	static const char underscoreCharacterString[2] = "_";
-	static char renameChampionInputCharacterString[2] = " ";
-	static const char reincarnateSpecialCharacters[6] = {',', '.', ';', ':', ' '};
-
-	Box displayBox;
-	displayBox._y1 = 3;
-	displayBox._y2 = 8;
-	displayBox._x1 = 3;
-	displayBox._x2 = displayBox._x1 + 167;
-
-	_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, displayBox, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
-	_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), g32_BoxPanel, k72_byteWidth, k4_ColorCyan, 73);
-	_vm->_textMan->f52_printToViewport(177, 58, k13_ColorLightestGray, "_______");
-	_vm->_textMan->f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________");
-	_vm->_eventMan->f78_showMouse();
-	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
-	_vm->_eventMan->f67_setMousePointerToNormal(k0_pointerArrow);
-	_vm->_eventMan->f77_hideMouse();
-	uint16 curCharacterIndex = 0;
-	champ->_name[curCharacterIndex] = '\0';
-	champ->_title[0] = '\0';
-	int16 renamedChampionStringMode = k1_RENAME_CHAMPION_NAME;
-	char *renamedChampionString = champ->_name;
-	int16 textPosX = 177;
-	int16 textPosY = 91;
-
-	for (;;) { /*_Infinite loop_*/
-		bool championTitleIsFull = ((renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE) && (curCharacterIndex == 19));
-		if (!championTitleIsFull) {
-			_vm->_eventMan->f78_showMouse();
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k9_ColorGold, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
-			_vm->_eventMan->f77_hideMouse();
-		}
-
-		int16 curCharacter = 256;
-		while (curCharacter == 256) {
-			Common::Event event;
-			Common::EventType eventType = _vm->_eventMan->processInput(&event, &event);
-			_vm->_displayMan->updateScreen();
-			_vm->f22_delay(1);
-
-			if (eventType == Common::EVENT_LBUTTONDOWN) {
-				// If left mouse button status has changed
-				Common::Point mousePos = _vm->_eventMan->getMousePos();
-				if ((renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE || (curCharacterIndex > 0)) && (mousePos.x >= 197) && (mousePos.x <= 215) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'OK' button */
-					int16 characterIndexBackup = curCharacterIndex;
-					char L0821_ac_ChampionNameBackupString[8];
-					renamedChampionString = champ->_name;
-					strcpy(L0821_ac_ChampionNameBackupString, renamedChampionString);
-					curCharacterIndex = strlen(renamedChampionString);
-					// Replace space characters on the right of the champion name by '\0' characters
-					while (renamedChampionString[--curCharacterIndex] == ' ')
-						renamedChampionString[curCharacterIndex] = '\0';
-
-					bool found = false;
-					for (uint16 idx = k0_ChampionFirst; idx < _g305_partyChampionCount - 1; idx++) {
-						if (!strcmp(_gK71_champions[idx]._name, renamedChampionString)) {
-							// If an existing champion already has the specified name for the new champion
-							found = true;
-							break;
-						}
-					}
-					if (!found)
-						return;
-
-					if (renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE)
-						renamedChampionString = champ->_title;
-
-					strcpy(renamedChampionString = champ->_name, L0821_ac_ChampionNameBackupString);
-					curCharacterIndex = characterIndexBackup;
-				} else {
-					if ((mousePos.x >= 107) && (mousePos.x <= 175) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'BACKSPACE' button */
-						curCharacter = '\b';
-						break;
-					}
-#if 0
-					if ((mousePos.x < 107) || (mousePos.x > 215) || (mousePos.y < 116) || (mousePos.y > 144)) {/* Coordinates of table of all other characters */
-						//goto T0281023;
-					}
-					if (!((mousePos.x + 4) % 10) || (!((mousePos.y + 5) % 10) && ((mousePos.x < 207) || (mousePos.y != 135)))) {
-						//goto T0281023;
-					}
-#endif
-					curCharacter = 'A' + (11 * ((mousePos.y - 116) / 10)) + ((mousePos.x - 107) / 10);
-					if ((curCharacter == 86) || (curCharacter == 97)) {
-						// The 'Return' button occupies two cells in the table
-						curCharacter = '\r'; /* Carriage return */
-						break;
-					}
-
-					if (curCharacter >= 87)
-						// Compensate for the first cell occupied by 'Return' button
-						curCharacter--;
-
-					if (curCharacter > 'Z')
-						curCharacter = reincarnateSpecialCharacters[(curCharacter - 'Z') - 1];
-
-					break;
-				}
-			} else if (eventType == Common::EVENT_KEYDOWN)
-				curCharacter = event.kbd.ascii;
-		}
-
-		if ((curCharacter >= 'a') && (curCharacter <= 'z'))
-			curCharacter -= 32; // Convert to uppercase
-
-		if (((curCharacter >= 'A') && (curCharacter <= 'Z')) || (curCharacter == '.') || (curCharacter == ',') || (curCharacter == ';') || (curCharacter == ':') || (curCharacter == ' ')) {
-			if ((curCharacter != ' ') || curCharacterIndex != 0) {
-				if (!championTitleIsFull) {
-					renameChampionInputCharacterString[0] = curCharacter;
-					_vm->_eventMan->f78_showMouse();
-					_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, renameChampionInputCharacterString, k200_heightScreen);
-					_vm->_eventMan->f77_hideMouse();
-					renamedChampionString[curCharacterIndex++] = curCharacter;
-					renamedChampionString[curCharacterIndex] = '\0';
-					textPosX += 6;
-					if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex == 7)) {
-						renamedChampionStringMode = k2_RENAME_CHAMPION_TITLE;
-						renamedChampionString = champ->_title;
-						textPosX = 105;
-						textPosY = 109;
-						curCharacterIndex = 0;
-					}
-				}
-			}
-		} else if (curCharacter == '\r') { // Carriage return
-			if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex > 0)) {
-				_vm->_eventMan->f78_showMouse();
-				_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
-				_vm->_eventMan->f77_hideMouse();
-				renamedChampionStringMode = k2_RENAME_CHAMPION_TITLE;
-				renamedChampionString = champ->_title;
-				textPosX = 105;
-				textPosY = 109;
-				curCharacterIndex = 0;
-			}
-		} else if (curCharacter == '\b') { // Backspace
-			if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex == 0))
-				continue;
-
-			if (!championTitleIsFull) {
-				_vm->_eventMan->f78_showMouse();
-				_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
-				_vm->_eventMan->f77_hideMouse();
-			}
-			if (curCharacterIndex == 0) {
-				renamedChampionString = champ->_name;
-				curCharacterIndex = strlen(renamedChampionString) - 1;
-				renamedChampionStringMode = k1_RENAME_CHAMPION_NAME;
-				textPosX = 177 + (curCharacterIndex * 6);
-				textPosY = 91;
-			} else {
-				curCharacterIndex--;
-				textPosX -= 6;
-			}
-			renamedChampionString[curCharacterIndex] = '\0';
-		}
-	}
-}
-
-uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, uint16 skillIndex) {
-	if (_g300_partyIsSleeping)
-		return 1;
-
-	bool ignoreTmpExp = getFlag(skillIndex, k0x8000_IgnoreTemporaryExperience);
-	bool ignoreObjModifiers = getFlag(skillIndex, k0x4000_IgnoreObjectModifiers);
-	clearFlag(skillIndex, k0x8000_IgnoreTemporaryExperience | k0x4000_IgnoreObjectModifiers);
-	Champion *champ = &_gK71_champions[champIndex];
-	Skill *skill = &champ->_skills[skillIndex];
-	int32 exp = skill->_experience;
-	if (!ignoreTmpExp)
-		exp += skill->_temporaryExperience;
-
-	if (skillIndex > k3_ChampionSkillWizard) {
-		// Hidden skill
-		skill = &champ->_skills[(skillIndex - k4_ChampionSkillSwing) >> 2];
-		exp += skill->_experience; // Add experience in the base skill
-		if (!ignoreTmpExp)
-			exp += skill->_temporaryExperience;
-
-		exp >>= 1; // Halve experience to get average of base skill + hidden skill experience
-	}
-	int16 skillLevel = 1;
-	while (exp >= 500) {
-		exp >>= 1;
-		skillLevel++;
-	}
-	if (!ignoreObjModifiers) {
-		int16 actionHandIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
-		if (actionHandIconIndex == k27_IconIndiceWeaponTheFirestaff)
-			skillLevel++;
-		else if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete)
-			skillLevel += 2;
-
-		int16 neckIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k10_ChampionSlotNeck]);
-		switch (skillIndex) {
-		case k3_ChampionSkillWizard:
-			if (neckIconIndex == k124_IconIndiceJunkPendantFeral)
-				skillLevel += 1;
-			break;
-		case k13_ChampionSkillHeal:
-			// The skill modifiers of these two objects are not cumulative
-			if ((neckIconIndex == k120_IconIndiceJunkGemOfAges) || (actionHandIconIndex == k66_IconIndiceWeaponSceptreOfLyf)) 
-				skillLevel += 1;
-			break;
-		case k14_ChampionSkillInfluence:
-			if (neckIconIndex == k122_IconIndiceJunkMoonstone)
-				skillLevel += 1;
-			break;
-		case k15_ChampionSkillDefend:
-			if (neckIconIndex == k121_IconIndiceJunkEkkhardCross)
-				skillLevel += 1;
-			break;
-		default:
-			break;
-		}
-	}
-	return skillLevel;
-}
-
-}
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#include "champion.h"
+#include "dungeonman.h"
+#include "eventman.h"
+#include "menus.h"
+#include "inventory.h"
+#include "objectman.h"
+#include "text.h"
+#include "timeline.h"
+#include "projexpl.h"
+#include "group.h"
+#include "movesens.h"
+
+
+namespace DM {
+
+const char *g417_baseSkillName[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"};
+
+Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
+Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
+Box g54_BoxChampionIcons[4] = {
+	Box(281, 299,  0, 13),
+	Box(301, 319,  0, 13),
+	Box(301, 319, 15, 28),
+	Box(281, 299, 15, 28)};
+Color g46_ChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14};
+
+int16 g39_LightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100};
+
+uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
+						   /* 30 for champion inventory, 8 for chest */
+	0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Action Hand      Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0x0002,   /* Head             Head */
+	0x0008,   /* Torso            Torso */
+	0x0010,   /* Legs             Legs */
+	0x0020,   /* Feet             Feet */
+	0x0100,   /* Pouch 2          Pouch */
+	0x0080,   /* Quiver Line2 1   Quiver 2 */
+	0x0080,   /* Quiver Line1 2   Quiver 2 */
+	0x0080,   /* Quiver Line2 2   Quiver 2 */
+	0x0004,   /* Neck             Neck */
+	0x0100,   /* Pouch 1          Pouch */
+	0x0040,   /* Quiver Line1 1   Quiver 1 */
+	0xFFFF,   /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0xFFFF,   /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+	0x0400,   /* Chest 1          Chest */
+	0x0400,   /* Chest 2          Chest */
+	0x0400,   /* Chest 3          Chest */
+	0x0400,   /* Chest 4          Chest */
+	0x0400,   /* Chest 5          Chest */
+	0x0400,   /* Chest 6          Chest */
+	0x0400,   /* Chest 7          Chest */
+	0x0400}; /* Chest 8          Chest */
+
+Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
+
+ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
+	for (uint16 i = 0; i < 4; ++i) {
+		_g409_championPendingDamage[i] = 0;
+		_g410_championPendingWounds[i] = 0;
+		_gK71_champions[i].resetToZero();
+	}
+	_g305_partyChampionCount = 0;
+	_g303_partyDead = false;
+	_g414_leaderHandObject = Thing(0);
+	_g411_leaderIndex = kM1_ChampionNone;
+	_g299_candidateChampionOrdinal = 0;
+	_g300_partyIsSleeping = false;
+	_g506_actingChampionOrdinal = 0;
+	_g413_leaderHandObjectIconIndex = (IconIndice)0;
+	_g415_leaderEmptyHanded = false;
+	_g407_party.resetToZero();
+	_g514_magicCasterChampionIndex = kM1_ChampionNone;
+	_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
+}
+
+bool ChampionMan::f329_isLeaderHandObjectThrown(int16 side) {
+	if (_g411_leaderIndex == kM1_ChampionNone) {
+		return false;
+	}
+	return f328_isObjectThrown(_g411_leaderIndex, kM1_ChampionSlotLeaderHand, side);
+}
+
+bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side) {
+	bool throwingLeaderHandObjectFl = false;
+	Thing curThing;
+	Champion *curChampion = nullptr;
+	Thing actionHandThing;
+
+	if (slotIndex < 0) { /* Throw object in leader hand, which is temporarily placed in action hand */
+		if (_g415_leaderEmptyHanded)
+			return false;
+
+		curThing = f298_getObjectRemovedFromLeaderHand();
+		curChampion = &_gK71_champions[champIndex];
+		actionHandThing = curChampion->getSlot(k1_ChampionSlotActionHand);
+		curChampion->setSlot(k1_ChampionSlotActionHand, curThing);
+		slotIndex = k1_ChampionSlotActionHand;
+		throwingLeaderHandObjectFl = true;
+	}
+
+	int16 kineticEnergy = f312_getStrength(champIndex, slotIndex);
+	if (throwingLeaderHandObjectFl) {
+		// In this case, curChampion and actionHandThing are set.
+		curChampion->setSlot((ChampionSlot)slotIndex, actionHandThing);
+	} else {
+		curThing = f300_getObjectRemovedFromSlot(champIndex, slotIndex);
+		if (curThing == Thing::_none)
+			return false;
+	}
+
+	_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+	f325_decrementStamina(champIndex, f305_getThrowingStaminaCost(curThing));
+	f330_disableAction(champIndex, 4);
+	int16 experience = 8;
+	int16 weaponKineticEnergy = 1;
+	if (curThing.getType() == k5_WeaponThingType) {
+		experience += 4;
+		WeaponInfo *curWeapon = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
+		if (curWeapon->_class <= k12_WeaponClassPoisinDart) {
+			weaponKineticEnergy = curWeapon->_kineticEnergy;
+			experience += weaponKineticEnergy >> 2;
+		}
+	}
+	f304_addSkillExperience(champIndex, k10_ChampionSkillThrow, experience);
+	kineticEnergy += weaponKineticEnergy;
+	int16 skillLevel = f303_getSkillLevel((ChampionIndex)champIndex, k10_ChampionSkillThrow);
+	kineticEnergy += _vm->getRandomNumber(16) + (kineticEnergy >> 1) + skillLevel;
+	int16 attack = f26_getBoundedValue((uint16)40, (uint16)((skillLevel << 3) + _vm->getRandomNumber(32)), (uint16)200);
+	int16 stepEnergy = MAX(5, 11 - skillLevel);
+	_vm->_projexpl->f212_projectileCreate(curThing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY,
+										  M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + side),
+										  _vm->_dungeonMan->_g308_partyDir, kineticEnergy, attack, stepEnergy);
+	_vm->_g311_projectileDisableMovementTicks = 4;
+	_vm->_g312_lastProjectileDisabledMovementDirection = _vm->_dungeonMan->_g308_partyDir;
+	f292_drawChampionState((ChampionIndex)champIndex);
+	return true;
+}
+
+uint16 ChampionMan::M27_getChampionPortraitX(uint16 index) {
+	return ((index) & 0x7) << 5;
+}
+
+uint16 ChampionMan::M28_getChampionPortraitY(uint16 index) {
+	return ((index) >> 3) * 29;
+}
+
+int16 ChampionMan::f279_getDecodedValue(char *string, uint16 characterCount) {
+	int val = 0;
+	for (uint16 i = 0; i < characterCount; ++i) {
+		val = (val << 4) + (string[i] - 'A');
+	}
+	return val;
+}
+
+void ChampionMan::f289_drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) {
+	Common::String tmp = f288_getStringFromInteger(currVal, true, 3);
+	_vm->_textMan->f52_printToViewport(55, posY, k13_ColorLightestGray, tmp.c_str());
+	_vm->_textMan->f52_printToViewport(73, posY, k13_ColorLightestGray, "/");
+	tmp = f288_getStringFromInteger(maxVal, true, 3);
+	_vm->_textMan->f52_printToViewport(79, posY, k13_ColorLightestGray, tmp.c_str());
+}
+
+uint16 ChampionMan::M70_handSlotIndex(uint16 slotBoxIndex) {
+	return slotBoxIndex & 0x1;
+}
+
+Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) {
+	Common::String valToStr = Common::String::format("%d", val);
+	Common::String result;
+
+	if (padding) {
+		for (int16 i = 0, end = paddingCharCount - valToStr.size(); i < end; ++i)
+			result += ' ';
+	}
+
+	return result += valToStr;
+}
+
+void ChampionMan::f299_applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing) {
+	int16 statIndex = k0_ChampionStatLuck;
+	int16 modifier = 0;
+	ThingType thingType = thing.getType();
+
+	bool cursed = false;
+	if (((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType))
+		&& (slotIndex >= k0_ChampionSlotReadyHand) && (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) {
+		if (thingType == k5_WeaponThingType) {
+			Weapon *weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(thing);
+			cursed = weapon->getCursed();
+		} else {
+			// k6_ArmourThingType
+			Armour *armour = (Armour *)_vm->_dungeonMan->f156_getThingData(thing);
+			cursed = armour->getCursed();
+		}
+
+		if (cursed) {
+			statIndex = k0_ChampionStatLuck;
+			modifier = -3;
+		}
+	}
+
+	if (!cursed) {
+		statIndex = (ChampionStatisticType)thingType; // variable sharing
+
+		if ((iconIndex == k137_IconIndiceJunkRabbitsFoot) && (slotIndex < k30_ChampionSlotChest_1)) {
+			statIndex = k0_ChampionStatLuck;
+			modifier = 10;
+		} else if (slotIndex == k1_ChampionSlotActionHand) {
+			if (iconIndex == k45_IconIndiceWeaponMaceOfOrder) {
+				statIndex = k1_ChampionStatStrength;
+				modifier = 5;
+			} else {
+				statIndex = k8_ChampionStatMana;
+				if ((iconIndex >= k20_IconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= k22_IconIndiceWeaponStaffOfClawsFull)) {
+					modifier = 4;
+				} else {
+					switch (iconIndex) {
+					case k38_IconIndiceWeaponDeltaSideSplitter:
+						modifier = 1;
+						break;
+					case k41_IconIndiceWeaponTheInquisitorDragonFang:
+						modifier = 2;
+						break;
+					case k40_IconIndiceWeaponVorpalBlade:
+						modifier = 4;
+						break;
+					case k58_IconIndiceWeaponStaff:
+						modifier = 2;
+						break;
+					case k59_IconIndiceWeaponWand:
+						modifier = 1;
+						break;
+					case k60_IconIndiceWeaponTeowand:
+						modifier = 6;
+						break;
+					case k61_IconIndiceWeaponYewStaff:
+						modifier = 4;
+						break;
+					case k62_IconIndiceWeaponStaffOfManarStaffOfIrra:
+						modifier = 10;
+						break;
+					case k63_IconIndiceWeaponSnakeStaffCrossOfNeta:
+						modifier = 8;
+						break;
+					case k64_IconIndiceWeaponTheConduitSerpentStaff:
+						modifier = 16;
+						break;
+					case k65_IconIndiceWeaponDragonSpit:
+						modifier = 7;
+						break;
+					case k66_IconIndiceWeaponSceptreOfLyf:
+						modifier = 5;
+						break;
+					default:
+						break;
+					}
+				}
+			}
+		} else if (slotIndex == k4_ChampionSlotLegs) {
+			if (iconIndex == k142_IconIndiceArmourPowertowers) {
+				statIndex = k1_ChampionStatStrength;
+				modifier = 10;
+			}
+		} else if (slotIndex == k2_ChampionSlotHead) {
+			switch (iconIndex) {
+			case k104_IconIndiceArmourCrownOfNerra:
+				statIndex = k3_ChampionStatWisdom;
+				modifier = 10;
+				break;
+			case k140_IconIndiceArmourDexhelm:
+				statIndex = k2_ChampionStatDexterity;
+				modifier = 10;
+				break;
+			default:
+				break;
+			}
+		} else if (slotIndex == k3_ChampionSlotTorso) {
+			switch (iconIndex) {
+			case k141_IconIndiceArmourFlamebain:
+				statIndex = k6_ChampionStatAntifire;
+				modifier = 12;
+				break;
+			case k81_IconIndiceArmourCloakOfNight:
+				statIndex = k2_ChampionStatDexterity;
+				modifier = 8;
+				break;
+			default:
+				break;
+			}
+		} else if (slotIndex == k10_ChampionSlotNeck) {
+			switch (iconIndex) {
+			case k10_IconIndiceJunkJewelSymalUnequipped:
+			case k11_IconIndiceJunkJewelSymalEquipped:
+				statIndex = k5_ChampionStatAntimagic;
+				modifier = 15;
+				break;
+			case k81_IconIndiceArmourCloakOfNight:
+				statIndex = k2_ChampionStatDexterity;
+				modifier = 8;
+				break;
+			case k122_IconIndiceJunkMoonstone:
+				statIndex = k8_ChampionStatMana;
+				modifier = 3;
+				break;
+			default:
+				break;
+			}
+		}
+	}
+
+	if (modifier) {
+		modifier *= modifierFactor;
+		//statIndex is set when modifier is set
+		if (statIndex == k8_ChampionStatMana) {
+			champ->_maxMana += modifier;
+		} else if (statIndex < k6_ChampionStatAntifire + 1) {
+			for (uint16 statValIndex = k0_ChampionStatMaximum; statValIndex <= k2_ChampionStatMinimum; ++statValIndex) {
+				champ->getStatistic((ChampionStatisticType)statIndex, (ChampionStatisticValue)statValIndex) += modifier;
+			}
+		}
+	}
+}
+
+bool ChampionMan::f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) {
+	ObjectMan &objMan = *_vm->_objectMan;
+
+	IconIndice currIconIndex = objMan.f39_getIconIndexInSlotBox(slotBoxIndex);
+	if (((currIconIndex < k32_IconIndiceWeaponDagger) && (currIconIndex >= k0_IconIndiceJunkCompassNorth))
+		|| ((currIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (currIconIndex <= k163_IconIndicePotionWaterFlask))
+		|| (currIconIndex == k195_IconIndicePotionEmptyFlask)) {
+		IconIndice newIconIndex = objMan.f33_getIconIndex(thing);
+		if (newIconIndex != currIconIndex) {
+			if ((slotBoxIndex < k8_SlotBoxInventoryFirstSlot) && !_g420_mousePointerHiddenToDrawChangedObjIconOnScreen) {
+				_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
+				_vm->_eventMan->f77_hideMouse();
+			}
+			objMan.f38_drawIconInSlotBox(slotBoxIndex, newIconIndex);
+			return true;
+		}
+	}
+
+	return false;
+}
+
+void ChampionMan::f296_drawChangedObjectIcons() {
+	InventoryMan &invMan = *_vm->_inventoryMan;
+	ObjectMan &objMan = *_vm->_objectMan;
+	MenuMan &menuMan = *_vm->_menuMan;
+
+	uint16 invChampOrdinal = invMan._g432_inventoryChampionOrdinal;
+	if (_g299_candidateChampionOrdinal && !invChampOrdinal)
+		return;
+
+	_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
+	IconIndice leaderHandObjIconIndex = _g413_leaderHandObjectIconIndex;
+
+	if (((leaderHandObjIconIndex < k32_IconIndiceWeaponDagger) && (leaderHandObjIconIndex >= k0_IconIndiceJunkCompassNorth))	// < instead of <= is correct
+		|| ((leaderHandObjIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= k163_IconIndicePotionWaterFlask))
+		|| (leaderHandObjIconIndex == k195_IconIndicePotionEmptyFlask)) {
+		IconIndice iconIndex = objMan.f33_getIconIndex(_g414_leaderHandObject);
+		if (iconIndex != leaderHandObjIconIndex) {
+			_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
+			_vm->_eventMan->f77_hideMouse();
+			objMan.f36_extractIconFromBitmap(iconIndex, objMan._g412_objectIconForMousePointer);
+			_vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
+			_g413_leaderHandObjectIconIndex = iconIndex;
+			objMan.f34_drawLeaderObjectName(_g414_leaderHandObject);
+		}
+	}
+
+	for (uint16 slotBoxIndex = 0; slotBoxIndex < (_g305_partyChampionCount * 2); ++slotBoxIndex) {
+		int16 champIndex = slotBoxIndex >> 1;
+		if (invChampOrdinal == _vm->M0_indexToOrdinal(champIndex))
+			continue;
+
+		if (f295_hasObjectIconInSlotBoxChanged(slotBoxIndex, _gK71_champions[champIndex].getSlot((ChampionSlot)M70_handSlotIndex(slotBoxIndex)))
+			&& (M70_handSlotIndex(slotBoxIndex) == k1_ChampionSlotActionHand)) {
+
+			menuMan.f386_drawActionIcon((ChampionIndex)champIndex);
+		}
+	}
+
+	if (invChampOrdinal) {
+		Champion *champ = &_gK71_champions[_vm->M1_ordinalToIndex(invChampOrdinal)];
+		Thing *thing = &champ->getSlot(k0_ChampionSlotReadyHand);
+		uint16 drawViewport = 0;
+
+		for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++, thing++) {
+			uint16 objIconChanged = f295_hasObjectIconInSlotBoxChanged(slotIndex + k8_SlotBoxInventoryFirstSlot, *thing) ? 1 : 0;
+			drawViewport |= objIconChanged;
+			if (objIconChanged && (slotIndex == k1_ChampionSlotActionHand)) {
+				menuMan.f386_drawActionIcon((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal));
+			}
+		}
+
+		if (invMan._g424_panelContent = k4_PanelContentChest) {
+			thing = invMan._g425_chestSlots;
+			for (int16 slotIndex = 0; slotIndex < 8; ++slotIndex, thing++) {
+				drawViewport |= (f295_hasObjectIconInSlotBoxChanged(slotIndex + k38_SlotBoxChestFirstSlot, *thing) ? 1 : 0);
+			}
+		}
+
+		if (drawViewport) {
+			champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
+			f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal));
+		}
+	}
+
+	if (_g420_mousePointerHiddenToDrawChangedObjIconOnScreen)
+		_vm->_eventMan->f78_showMouse();
+}
+
+void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex) {
+	InventoryMan &invMan = *_vm->_inventoryMan;
+	DungeonMan &dunMan = *_vm->_dungeonMan;
+	ObjectMan &objMan = *_vm->_objectMan;
+	MenuMan &menuMan = *_vm->_menuMan;
+
+	if (thing == Thing::_none)
+		return;
+
+	Champion *champ = &_gK71_champions[champIndex];
+
+	if (slotIndex >= k30_ChampionSlotChest_1) {
+		invMan._g425_chestSlots[slotIndex - k30_ChampionSlotChest_1] = thing;
+	} else {
+		champ->setSlot(slotIndex, thing);
+	}
+
+	champ->_load += dunMan.f140_getObjectWeight(thing);
+	champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
+	IconIndice iconIndex = objMan.f33_getIconIndex(thing);
+	bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal);
+	f299_applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
+	uint16 *rawObjPtr = dunMan.f156_getThingData(thing);
+
+	if (slotIndex < k2_ChampionSlotHead) {
+		if (slotIndex == k1_ChampionSlotActionHand) {
+			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
+			if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))
+				menuMan.f388_clearActingChampion();
+
+			if ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)) {
+				((Scroll *)rawObjPtr)->setClosed(false);
+				f296_drawChangedObjectIcons();
+			}
+		}
+
+		if (iconIndex = k4_IconIndiceWeaponTorchUnlit) {
+			((Weapon *)rawObjPtr)->setLit(true);
+			_vm->_inventoryMan->f337_setDungeonViewPalette();
+			f296_drawChangedObjectIcons();
+		} else if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand) &&
+			((iconIndex == k144_IconIndiceContainerChestClosed) || ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)))) {
+			champ->setAttributeFlag(k0x0800_ChampionAttributePanel, true);
+		}
+	} else if (slotIndex == k10_ChampionSlotNeck) {
+		if ((iconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (iconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
+			((Junk *)rawObjPtr)->setChargeCount(1);
+			_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2];
+			_vm->_inventoryMan->f337_setDungeonViewPalette();
+			iconIndex = (IconIndice)(iconIndex + 1);
+		} else if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
+			((Junk *)rawObjPtr)->setChargeCount(1);
+			iconIndex = (IconIndice)(iconIndex + 1);
+		}
+	}
+
+	f291_drawSlot(champIndex, slotIndex);
+	if (isInventoryChampion)
+		champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
+}
+
+int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) {
+	int16 scentIndex = _g407_party._scentCount;
+
+	if (scentIndex) {
+		Scent searchedScent;
+		searchedScent.setMapX(mapX);
+		searchedScent.setMapY(mapY);
+		searchedScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex);
+		uint16 searchedScentRedEagle = searchedScent.toUint16();
+		Scent *scent = &_g407_party._scents[scentIndex--];
+		do {
+			if ((*(--scent)).toUint16() == searchedScentRedEagle) {
+				return _vm->M0_indexToOrdinal(scentIndex);
+			}
+		} while (scentIndex--);
+	}
+	return 0;
+}
+
+Thing ChampionMan::f298_getObjectRemovedFromLeaderHand() {
+	_g415_leaderEmptyHanded = true;
+	Thing leaderHandObject = _g414_leaderHandObject;
+
+	if (leaderHandObject != Thing::_none) {
+		_g414_leaderHandObject = Thing::_none;
+		_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
+		_vm->_eventMan->f78_showMouse();
+		_vm->_objectMan->f35_clearLeaderObjectName();
+		_vm->_eventMan->f69_setMousePointer();
+		_vm->_eventMan->f77_hideMouse();
+		if (_g411_leaderIndex != kM1_ChampionNone) {
+			_gK71_champions[_g411_leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(leaderHandObject);
+			setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
+			f292_drawChampionState(_g411_leaderIndex);
+		}
+	}
+	return leaderHandObject;
+}
+
+uint16 ChampionMan::f312_getStrength(int16 champIndex, int16 slotIndex) {
+	Champion *curChampion = &_gK71_champions[champIndex];
+	int16 strength = _vm->getRandomNumber(16) + curChampion->_statistics[k1_ChampionStatStrength][k1_ChampionStatCurrent];
+	Thing curThing = curChampion->_slots[slotIndex];
+	uint16 objectWeight = _vm->_dungeonMan->f140_getObjectWeight(curThing);
+	uint16 oneSixteenthMaximumLoad = f309_getMaximumLoad(curChampion) >> 4;
+
+	if (objectWeight <= oneSixteenthMaximumLoad) {
+		strength += objectWeight - 12;
+	} else {
+		int16 loadThreshold = oneSixteenthMaximumLoad + ((oneSixteenthMaximumLoad - 12) >> 1);
+		if (objectWeight <= loadThreshold) {
+			strength += (objectWeight - oneSixteenthMaximumLoad) >> 1;
+		} else {
+			strength -= (objectWeight - loadThreshold) << 1;
+		}
+	}
+	if (curThing.getType() == k5_WeaponThingType) {
+		WeaponInfo *weaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
+		strength += weaponInfo->_strength;
+		uint16 skillLevel = 0;
+		uint16 weaponClass = weaponInfo->_class;
+		if ((weaponClass == k0_WeaponClassSwingWeapon) || (weaponClass == k2_WeaponClassDaggerAndAxes)) {
+			skillLevel = f303_getSkillLevel(champIndex, k4_ChampionSkillSwing);
+		}
+		if ((weaponClass != k0_WeaponClassSwingWeapon) && (weaponClass < k16_WeaponClassFirstBow)) {
+			skillLevel += f303_getSkillLevel(champIndex, k10_ChampionSkillThrow);
+		}
+		if ((weaponClass >= k16_WeaponClassFirstBow) && (weaponClass < k112_WeaponClassFirstMagicWeapon)) {
+			skillLevel += f303_getSkillLevel(champIndex, k11_ChampionSkillShoot);
+		}
+		strength += skillLevel << 1;
+	}
+	strength = f306_getStaminaAdjustedValue(curChampion, strength);
+	if (getFlag(curChampion->_wounds, (slotIndex == k0_ChampionSlotReadyHand) ? k0x0001_ChampionWoundReadHand : k0x0002_ChampionWoundActionHand)) {
+		strength >>= 1;
+	}
+	return f26_getBoundedValue(0, strength >> 1, 100);
+}
+
+Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) {
+	Champion *curChampion = &_gK71_champions[champIndex];
+	Thing curThing;
+
+	if (slotIndex >= k30_ChampionSlotChest_1) {
+		curThing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
+		_vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1] = Thing::_none;
+	} else {
+		curThing = curChampion->_slots[slotIndex];
+		curChampion->_slots[slotIndex] = Thing::_none;
+	}
+
+	if (curThing == Thing::_none)
+		return Thing::_none;
+
+	bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+	int16 curIconIndex = _vm->_objectMan->f33_getIconIndex(curThing);
+	// Remove object modifiers
+	f299_applyModifiersToStatistics(curChampion, slotIndex, curIconIndex, -1, curThing);
+
+	Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(curThing);
+	if (slotIndex == k10_ChampionSlotNeck) {
+		if ((curIconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (curIconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
+			((Junk *)curWeapon)->setChargeCount(0);
+			_g407_party._magicalLightAmount -= g39_LightPowerToLightAmount[2];
+			_vm->_inventoryMan->f337_setDungeonViewPalette();
+		} else if ((curIconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (curIconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
+			((Junk *)curWeapon)->setChargeCount(0);
+		}
+	}
+
+	f291_drawSlot(champIndex, slotIndex);
+	if (isInventoryChampion)
+		setFlag(curChampion->_attributes, k0x4000_ChampionAttributeViewport);
+
+	if (slotIndex < k2_ChampionSlotHead) {
+		if (slotIndex == k1_ChampionSlotActionHand) {
+			setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand);
+			if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))
+				_vm->_menuMan->f388_clearActingChampion();
+
+			if ((curIconIndex >= k30_IconIndiceScrollOpen) && (curIconIndex <= k31_IconIndiceScrollClosed)) {
+				((Scroll *)curWeapon)->setClosed(true);
+				f296_drawChangedObjectIcons();
+			}
+		}
+
+		if ((curIconIndex >= k4_IconIndiceWeaponTorchUnlit) && (curIconIndex <= k7_IconIndiceWeaponTorchLit)) {
+			curWeapon->setLit(false);
+			_vm->_inventoryMan->f337_setDungeonViewPalette();
+			f296_drawChangedObjectIcons();
+		}
+
+		if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand)) {
+			switch (curIconIndex) {
+			case k144_IconIndiceContainerChestClosed:
+				_vm->_inventoryMan->f334_closeChest();
+			// No break on purpose
+			case k30_IconIndiceScrollOpen:
+			case k31_IconIndiceScrollClosed:
+				setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel);
+				break;
+			default:
+				break;
+			}
+		}
+	}
+	curChampion->_load -= _vm->_dungeonMan->f140_getObjectWeight(curThing);
+	setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad);
+	return curThing;
+}
+
+void ChampionMan::f325_decrementStamina(int16 championIndex, int16 decrement) {
+	if (championIndex == kM1_ChampionNone)
+		return;
+
+	Champion *curChampion = &_gK71_champions[championIndex];
+	curChampion->_currStamina -= decrement;
+
+	int16 stamina = curChampion->_currStamina;
+	if (stamina <= 0) {
+		curChampion->_currStamina = 0;
+		f321_addPendingDamageAndWounds_getDamage(championIndex, (-stamina) >> 1, k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
+	} else if (stamina > curChampion->_maxStamina) {
+		curChampion->_currStamina = curChampion->_maxStamina;
+	}
+
+	setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics);
+}
+
+int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds, uint16 attackType) {
+	if (attack <= 0)
+		return 0;
+
+	Champion *curChampion = &_gK71_champions[champIndex];
+	if (!curChampion->_currHealth)
+		return 0;
+
+	bool skipScaling = false;
+	if (attackType != k0_attackType_NORMAL) {
+		uint16 defense = 0;
+		uint16 woundCount = 0;
+		for (int16 woundIndex = k0_ChampionSlotReadyHand; woundIndex <= k5_ChampionSlotFeet; woundIndex++) {
+			if (allowedWounds & (1 << woundIndex)) {
+				woundCount++;
+				defense += f313_getWoundDefense(champIndex, woundIndex | ((attackType == k4_attackType_SHARP) ? k0x8000_maskUseSharpDefense : k0x0000_maskDoNotUseSharpDefense));
+			}
+		}
+		if (woundCount)
+			defense /= woundCount;
+
+		switch (attackType) {
+		case k6_attackType_PSYCHIC:
+		{
+			int16 wisdomFactor = 115 - curChampion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent];
+			if (wisdomFactor <= 0) {
+				attack = 0;
+			} else {
+				attack = _vm->f30_getScaledProduct(attack, 6, wisdomFactor);
+			}
+
+			skipScaling = true;
+		}
+		break;
+		case k5_attackType_MAGIC:
+			attack = f307_getStatisticAdjustedAttack(curChampion, k5_ChampionStatAntimagic, attack);
+			attack -= _g407_party._spellShieldDefense;
+			skipScaling = true;
+			break;
+		case k1_attackType_FIRE:
+			attack = f307_getStatisticAdjustedAttack(curChampion, k6_ChampionStatAntifire, attack);
+			attack -= _g407_party._fireShieldDefense;
+			break;
+		case k2_attackType_SELF:
+			defense >>= 1;
+			break;
+		default:
+			break;
+		}
+
+		if (!skipScaling) {
+			if (attack <= 0)
+				return 0;
+
+			attack = _vm->f30_getScaledProduct(attack, 6, 130 - defense);
+		}
+		/* BUG0_44
+			A champion may take much more damage than expected after a Black Flame attack or an impact
+			with a Fireball projectile. If the party has a fire shield defense value higher than the fire
+			attack value then the resulting intermediary attack value is negative and damage should be 0.
+			However, the negative value is still used for further computations and the result may be a very
+			high positive attack value which may kill a champion. This can occur only for k1_attackType_FIRE
+			and if attack is negative before calling F0030_MAIN_GetScaledProduct
+		*/
+
+		if (attack <= 0)
+			return 0;
+
+		int16 adjustedAttack = f307_getStatisticAdjustedAttack(curChampion, k4_ChampionStatVitality, _vm->getRandomNumber(128) + 10);
+		if (attack > adjustedAttack) {
+		/* BUG0_45
+			This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the
+			probability of being wounded. However if it was fixed, the behavior would be the opposite
+			of what it should: the higher the vitality of a champion, the lower the result of
+			F0307_CHAMPION_GetStatisticAdjustedAttack and the more likely the champion could get
+			wounded (because of more iterations in the loop below)
+		*/
+			do {
+				setFlag(*(uint16 *)&_g410_championPendingWounds[champIndex], (1 << _vm->getRandomNumber(8)) & allowedWounds);
+			} while ((attack > (adjustedAttack <<= 1)) && adjustedAttack);
+		}
+
+		if (_g300_partyIsSleeping)
+			f314_wakeUp();
+	}
+	_g409_championPendingDamage[champIndex] += attack;
+	return attack;
+}
+
+int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
+	static const byte woundDefenseFactor[6] = {5, 5, 4, 6, 3, 1}; // @ G0050_auc_Graphic562_WoundDefenseFactor
+
+	Champion *curChampion = &_gK71_champions[champIndex];
+	bool useSharpDefense = getFlag(woundIndex, k0x8000_maskUseSharpDefense);
+	if (useSharpDefense)
+		clearFlag(woundIndex, k0x8000_maskUseSharpDefense);
+
+	uint16 armorShieldDefense = 0;
+	for (int16 slotIndex = k0_ChampionSlotReadyHand; slotIndex <= k1_ChampionSlotActionHand; slotIndex++) {
+		Thing curThing = curChampion->_slots[slotIndex];
+		if (curThing.getType() == k6_ArmourThingType) {
+			ArmourInfo *armorInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(curThing);
+			armorInfo = &g239_ArmourInfo[((Armour *)armorInfo)->getType()];
+			if (getFlag(armorInfo->_attributes, k0x0080_ArmourAttributeIsAShield))
+				armorShieldDefense += ((f312_getStrength(champIndex, slotIndex) + _vm->_dungeonMan->f143_getArmourDefense(armorInfo, useSharpDefense)) * woundDefenseFactor[woundIndex]) >> ((slotIndex == woundIndex) ? 4 : 5);
+		}
+	}
+
+	int16 woundDefense = _vm->getRandomNumber((curChampion->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] >> 3) + 1);
+	if (useSharpDefense)
+		woundDefense >>= 1;
+
+	woundDefense += curChampion->_actionDefense + curChampion->_shieldDefense + _g407_party._shieldDefense + armorShieldDefense;
+	if (woundIndex > k1_ChampionSlotActionHand) {
+		Thing curThing = curChampion->_slots[woundIndex];
+		if (curThing.getType() == k6_ArmourThingType) {
+			ArmourInfo *armourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(curThing);
+			woundDefense += _vm->_dungeonMan->f143_getArmourDefense(&g239_ArmourInfo[((Armour *)armourInfo)->getType()], useSharpDefense);
+		}
+	}
+
+	if (getFlag(curChampion->_wounds, 1 << woundIndex))
+		woundDefense -= 8 + _vm->getRandomNumber(4);
+
+	if (_g300_partyIsSleeping)
+		woundDefense >>= 1;
+
+	return f26_getBoundedValue(0, woundDefense >> 1, 100);
+}
+
+uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion *champ, uint16 statIndex, uint16 attack) {
+	int16 factor = 170 - champ->_statistics[statIndex][k1_ChampionStatCurrent];
+
+	/* BUG0_41
+		The Antifire and Antimagic statistics are completely ignored. The Vitality statistic is ignored
+		against poison and to determine the probability of being wounded. Vitality is still used normally
+		to compute the defense against wounds and the speed of health regeneration. A bug in the Megamax C
+		compiler produces wrong machine code for this statement. It always returns 0 for the current statistic
+		value so that factor = 170 in all cases
+	*/
+	if (factor < 16)
+		return attack >> 3;
+
+	return _vm->f30_getScaledProduct(attack, 7, factor);
+}
+
+void ChampionMan::f314_wakeUp() {
+	_vm->_g321_stopWaitingForPlayerInput = true;
+	_g300_partyIsSleeping = false;
+	_vm->_g318_waitForInputMaxVerticalBlankCount = 10;
+	_vm->f22_delay(10);
+	_vm->_displayMan->f98_drawFloorAndCeiling();
+	_vm->_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface;
+	_vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
+	_vm->_eventMan->_g443_primaryKeyboardInput = g458_primaryKeyboardInput_interface;
+	_vm->_eventMan->_g444_secondaryKeyboardInput = g459_secondaryKeyboardInput_movement;
+	_vm->_eventMan->f357_discardAllInput();
+	_vm->_menuMan->f457_drawEnabledMenus();
+}
+
+int16 ChampionMan::f305_getThrowingStaminaCost(Thing thing) {
+	int16 weight = _vm->_dungeonMan->f140_getObjectWeight(thing) >> 1;
+	int16 staminaCost = f26_getBoundedValue<int16>(1, weight, 10);
+
+	while ((weight -= 10) > 0)
+		staminaCost += weight >> 1;
+
+	return staminaCost;
+}
+
+void ChampionMan::f330_disableAction(uint16 champIndex, uint16 ticks) {
+	Champion *curChampion = &_gK71_champions[champIndex];
+	int32 updatedEnableActionEventTime = _vm->_g313_gameTime + ticks;
+
+	TimelineEvent curEvent;
+	curEvent._type = k11_TMEventTypeEnableChampionAction;
+	curEvent._priority = champIndex;
+	curEvent._B._slotOrdinal = 0;
+
+	int16 eventIndex = curChampion->_enableActionEventIndex;
+	if (eventIndex >= 0) {
+		int32 currentEnableActionEventTime = M30_time(_vm->_timeline->_g370_events[eventIndex]._mapTime);
+		if (updatedEnableActionEventTime >= currentEnableActionEventTime) {
+			updatedEnableActionEventTime += (currentEnableActionEventTime - _vm->_g313_gameTime) >> 1;
+		} else {
+			updatedEnableActionEventTime = currentEnableActionEventTime + (ticks >> 1);
+		}
+		_vm->_timeline->f237_deleteEvent(eventIndex);
+	} else {
+		setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x0008_ChampionAttributeDisableAction);
+		f292_drawChampionState((ChampionIndex)champIndex);
+	}
+	M33_setMapAndTime(curEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, updatedEnableActionEventTime);
+	curChampion->_enableActionEventIndex = _vm->_timeline->f238_addEventGetEventIndex(&curEvent);
+}
+
+void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp) {
+	if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && (_vm->_projexpl->_g361_lastCreatureAttackTime < _vm->_g313_gameTime - 150))
+		exp >>= 1;
+
+	if (exp) {
+		if (_vm->_dungeonMan->_g269_currMap->_difficulty)
+			exp *= _vm->_dungeonMan->_g269_currMap->_difficulty;
+
+		Champion *curChampion = &_gK71_champions[champIndex];
+		uint16 baseSkillIndex;
+		if (skillIndex >= k4_ChampionSkillSwing)
+			baseSkillIndex = (skillIndex - k4_ChampionSkillSwing) >> 2;
+		else
+			baseSkillIndex = skillIndex;
+
+		uint16 skillLevelBefore = f303_getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
+
+		if ((skillIndex >= k4_ChampionSkillSwing) && (_vm->_projexpl->_g361_lastCreatureAttackTime > _vm->_g313_gameTime - 25))
+			exp <<= 1;
+
+		Skill *curSkill = &curChampion->_skills[skillIndex];
+		curSkill->_experience += exp;
+		if (curSkill->_temporaryExperience < 32000)
+			curSkill->_temporaryExperience += f26_getBoundedValue(1, exp >> 3, 100);
+
+		curSkill = &curChampion->_skills[baseSkillIndex];
+		if (skillIndex >= k4_ChampionSkillSwing)
+			curSkill->_experience += exp;
+
+		uint16 skillLevelAfter = f303_getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
+		if (skillLevelAfter > skillLevelBefore) {
+			int16 newBaseSkillLevel = skillLevelAfter;
+			int16 minorStatIncrease = _vm->getRandomNumber(2);
+			int16 majorStatIncrease = 1 + _vm->getRandomNumber(2);
+			uint16 vitalityAmount = _vm->getRandomNumber(2); /* For Priest skill, the amount is 0 or 1 for all skill levels */
+			if (baseSkillIndex != k2_ChampionSkillPriest) {
+				vitalityAmount &= skillLevelAfter; /* For non Priest skills the amount is 0 for even skill levels. The amount is 0 or 1 for odd skill levels */
+			}
+			curChampion->_statistics[k4_ChampionStatVitality][k0_ChampionStatMaximum] += vitalityAmount;
+			uint16 staminaAmount = curChampion->_maxStamina;
+			curChampion->_statistics[k6_ChampionStatAntifire][k0_ChampionStatMaximum] += _vm->getRandomNumber(2) & ~skillLevelAfter; /* The amount is 0 for odd skill levels. The amount is 0 or 1 for even skill levels */
+			bool increaseManaFl = false;
+			switch (baseSkillIndex) {
+			case k0_ChampionSkillFighter:
+				staminaAmount >>= 4;
+				skillLevelAfter *= 3;
+				curChampion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += majorStatIncrease;
+				curChampion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += minorStatIncrease;
+				break;
+			case k1_ChampionSkillNinja:
+				staminaAmount /= 21;
+				skillLevelAfter <<= 1;
+				curChampion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += minorStatIncrease;
+				curChampion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += majorStatIncrease;
+				break;
+			case k3_ChampionSkillWizard:
+				staminaAmount >>= 5;
+				curChampion->_maxMana += skillLevelAfter + (skillLevelAfter >> 1);
+				curChampion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += majorStatIncrease;
+				increaseManaFl = true;
+				break;
+			case k2_ChampionSkillPriest:
+				staminaAmount /= 25;
+				curChampion->_maxMana += skillLevelAfter;
+				skillLevelAfter += (skillLevelAfter + 1) >> 1;
+				curChampion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += minorStatIncrease;
+				increaseManaFl = true;
+				break;
+			default:
+				break;
+			}
+			if (increaseManaFl) {
+				if ((curChampion->_maxMana += MIN(_vm->getRandomNumber(4), (uint16)(newBaseSkillLevel - 1))) > 900)
+					curChampion->_maxMana = 900;
+				curChampion->_statistics[k5_ChampionStatAntimagic][k0_ChampionStatMaximum] += _vm->getRandomNumber(3);
+			}
+
+			if ((curChampion->_maxHealth += skillLevelAfter + _vm->getRandomNumber((skillLevelAfter >> 1) + 1)) > 999)
+				curChampion->_maxHealth = 999;
+
+			if ((curChampion->_maxStamina += staminaAmount + _vm->getRandomNumber((staminaAmount >> 1) + 1)) > 9999)
+				curChampion->_maxStamina = 9999;
+
+			setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+			f292_drawChampionState((ChampionIndex)champIndex);
+			_vm->_textMan->f51_messageAreaPrintLineFeed();
+			Color curChampionColor = g46_ChampionColor[champIndex];
+			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, curChampion->_name);
+			// TODO: localization
+			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " JUST GAINED A ");
+			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, g417_baseSkillName[baseSkillIndex]);
+			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " LEVEL!");
+		}
+	}
+}
+
+int16 ChampionMan::f324_damageAll_getDamagedChampionCount(uint16 attack, int16 wounds, int16 attackType) {
+	int16 randomMax = (attack >> 3) + 1;
+	uint16 reducedAttack = attack - randomMax;
+	randomMax <<= 1;
+
+	int16 damagedChampionCount = 0;
+	for (int16 championIndex = k0_ChampionFirst; championIndex < _g305_partyChampionCount; championIndex++) {
+		// Actual attack is attack +/- (attack / 8)
+		if (f321_addPendingDamageAndWounds_getDamage(championIndex, MAX(1, reducedAttack + _vm->getRandomNumber(randomMax)), wounds, attackType))
+			damagedChampionCount++;
+	}
+
+	return damagedChampionCount;
+}
+
+int16 ChampionMan::f286_getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) {
+	if (_g305_partyChampionCount && (M38_distance(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)) {
+		signed char orderedCellsToAttack[4];
+		_vm->_groupMan->f229_setOrderedCellsToAttack(orderedCellsToAttack, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, mapX, mapY, cell);
+		for (uint16 i = 0; i < 4; i++) {
+			int16 championIndex = f285_getIndexInCell(orderedCellsToAttack[i]);
+			if (championIndex >= 0)
+				return championIndex;
+		}
+	}
+	return kM1_ChampionNone;
+}
+
+int16 ChampionMan::f311_getDexterity(Champion* champ) {
+	int16 dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent];
+	dexterity -= ((int32)(dexterity >> 1) * (int32)champ->_load) / f309_getMaximumLoad(champ);
+	if (_g300_partyIsSleeping)
+		dexterity >>= 1;
+
+	return f26_getBoundedValue(1 + _vm->getRandomNumber(8), dexterity >> 1, 100 - _vm->getRandomNumber(8));
+}
+
+bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) {
+	if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage))
+		return true;
+
+	unsigned char *curStat = champ->_statistics[k0_ChampionStatLuck];
+	bool isLucky = (_vm->getRandomNumber(curStat[k1_ChampionStatCurrent]) > percentage);
+	curStat[k1_ChampionStatCurrent] = f26_getBoundedValue<char>(curStat[k2_ChampionStatMinimum], curStat[k1_ChampionStatCurrent] + (isLucky ? -2 : 2), curStat[k0_ChampionStatMaximum]);
+	return isLucky;
+}
+
+void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) {
+	if ((champIndex == kM1_ChampionNone) || (_vm->M0_indexToOrdinal(champIndex) == _g299_candidateChampionOrdinal))
+		return;
+
+	Champion *curChampion = &_gK71_champions[champIndex];
+	f321_addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
+	setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+	if ((_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) && (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
+		setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel);
+	}
+
+	if (--attack) {
+		curChampion->_poisonEventCount++;
+		TimelineEvent newEvent;
+		newEvent._type = k75_TMEventTypePoisonChampion;
+		newEvent._priority = champIndex;
+		M33_setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 36);
+		newEvent._B._attack = attack;
+		_vm->_timeline->f238_addEventGetEventIndex(&newEvent);
+	}
+
+	f292_drawChampionState((ChampionIndex)champIndex);
+}
+
+void ChampionMan::f284_setPartyDirection(int16 dir) {
+	if (dir == _vm->_dungeonMan->_g308_partyDir)
+		return;
+
+	int16 L0834_i_Delta = dir - _vm->_dungeonMan->_g308_partyDir;
+	if (L0834_i_Delta < 0)
+		L0834_i_Delta += 4;
+
+	Champion *curChampion = _gK71_champions;
+	for (int16 i = k0_ChampionFirst; i < _g305_partyChampionCount; i++) {
+		curChampion->_cell = (ViewCell)M21_normalizeModulo4(curChampion->_cell + L0834_i_Delta);
+		curChampion->_dir = (Direction)M21_normalizeModulo4(curChampion->_dir + L0834_i_Delta);
+		curChampion++;
+	}
+
+	_vm->_dungeonMan->_g308_partyDir = (Direction)dir;
+	f296_drawChangedObjectIcons();
+}
+
+void ChampionMan::f316_deleteScent(uint16 scentIndex) {
+	uint16 count = --_g407_party._scentCount - scentIndex;
+
+	if (count) {
+		for (uint16 i = 0; i < count; ++i) {
+			_g407_party._scents[scentIndex + i] = _g407_party._scents[scentIndex + i + 1];
+			_g407_party._scentStrengths[scentIndex + i] = _g407_party._scentStrengths[scentIndex + i + 1];
+		}
+	}
+
+	if (scentIndex < _g407_party._firstScentIndex)
+		_g407_party._firstScentIndex--;
+
+	if (scentIndex < _g407_party._lastScentIndex)
+		_g407_party._lastScentIndex--;
+}
+
+void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount) {
+	int16 scentIndex = _g407_party._scentCount;
+	if (scentIndex) {
+		bool mergeFl = getFlag(cycleCount, k0x8000_mergeCycles);
+		if (mergeFl)
+			clearFlag(cycleCount, k0x8000_mergeCycles);
+
+		Scent newScent; /* BUG0_00 Useless code */
+		newScent.setMapX(mapX); /* BUG0_00 Useless code */
+		newScent.setMapY(mapY); /* BUG0_00 Useless code */
+		newScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */
+
+		Scent *curScent = _g407_party._scents; /* BUG0_00 Useless code */
+		bool cycleCountDefined = false;
+		while (scentIndex--) {
+			if (&*curScent++ == &newScent) {
+				if (!cycleCountDefined) {
+					cycleCountDefined = true;
+					if (mergeFl) {
+						cycleCount = MAX<int32>(_g407_party._scentStrengths[scentIndex], cycleCount);
+					} else {
+						cycleCount = MIN<int32>(80, _g407_party._scentStrengths[scentIndex] + cycleCount);
+					}
+				}
+				_g407_party._scentStrengths[scentIndex] = cycleCount;
+			}
+		}
+	}
+}
+
+void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) {
+	if (thing == Thing::_none)
+		return;
+
+	_g415_leaderEmptyHanded = false;
+	_vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
+	_vm->_eventMan->f78_showMouse();
+	_vm->_objectMan->f34_drawLeaderObjectName(thing);
+
+	if (setMousePointer)
+		_vm->_g325_setMousePointerToObjectInMainLoop = true;
+	else
+		_vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
+
+	_vm->_eventMan->f77_hideMouse();
+	if (_g411_leaderIndex != kM1_ChampionNone) {
+		_gK71_champions[_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing);
+		setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
+		f292_drawChampionState(_g411_leaderIndex);
+	}
+}
+
+int16 ChampionMan::f310_getMovementTicks(Champion *champ) {
+	uint16 maximumLoad = f309_getMaximumLoad(champ);
+	uint16 curLoad = champ->_load;
+	uint16 woundTicks;
+	int16 ticks;
+	/* BUG0_72 - Fixed
+		The party moves very slowly even though no champion 'Load' value is drawn in red.
+		When the Load of a champion has exactly the maximum value he can carry then the Load
+		is drawn in yellow but the speed is the same as when the champion is overloaded
+		(when the Load is drawn in red). The comparison operator should be >= instead of >
+	*/
+	if (maximumLoad >= curLoad) {
+		ticks = 2;
+		if (((int32)curLoad << 3) > ((int32)maximumLoad * 5))
+			ticks++;
+
+		woundTicks = 1;
+	} else {
+		ticks = 4 + (((curLoad - maximumLoad) << 2) / maximumLoad);
+		woundTicks = 2;
+	}
+
+	if (getFlag(champ->_wounds, k0x0020_ChampionWoundFeet))
+		ticks += woundTicks;
+
+	if (_vm->_objectMan->f33_getIconIndex(champ->_slots[k5_ChampionSlotFeet]) == k194_IconIndiceArmourBootOfSpeed)
+		ticks--;
+
+	return ticks;
+}
+
+bool ChampionMan::f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex, uint16 ammunitionSlotIndex) {
+	Champion *curChampion = &_gK71_champions[champIndex];
+	Thing curThing = curChampion->_slots[weaponSlotIndex];
+	if (curThing.getType() != k5_WeaponThingType)
+		return false;
+
+	WeaponInfo *weaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
+	int16 weaponClass = kM1_WeaponClassNone;
+
+	if ((weaponInfo->_class >= k16_WeaponClassFirstBow) && (weaponInfo->_class <= k31_WeaponClassLastBow))
+		weaponClass = k10_WeaponClassBowAmmunition;
+	else if ((weaponInfo->_class >= k32_WeaponClassFirstSling) && (weaponInfo->_class <= k47_WeaponClassLastSling))
+		weaponClass = k11_WeaponClassSlingAmmunition;
+
+	if (weaponClass == kM1_WeaponClassNone)
+		return false;
+
+	curThing = curChampion->_slots[ammunitionSlotIndex];
+	weaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
+	return ((curThing.getType() == k5_WeaponThingType) && (weaponInfo->_class == weaponClass));
+}
+
+void ChampionMan::f293_drawAllChampionStates() {
+	for (int16 i = k0_ChampionFirst; i < _g305_partyChampionCount; i++)
+		f292_drawChampionState((ChampionIndex)i);
+}
+
+void ChampionMan::f283_viAltarRebirth(uint16 champIndex) {
+	Champion *curChampion = &_gK71_champions[champIndex];
+	if (f285_getIndexInCell(curChampion->_cell) != kM1_ChampionNone) {
+		uint16 numCell = k0_CellNorthWest;
+		while (f285_getIndexInCell(numCell) != kM1_ChampionNone)
+			numCell++;
+
+		curChampion->_cell = (ViewCell)numCell;
+	}
+
+	uint16 maximumHealth = curChampion->_maxHealth;
+	curChampion->_maxHealth = MAX(25, maximumHealth - (maximumHealth >> 6) - 1);
+	curChampion->_currHealth = curChampion->_maxHealth >> 1;
+	_vm->_menuMan->f393_drawSpellAreaControls(_g514_magicCasterChampionIndex);
+	curChampion->_dir = _vm->_dungeonMan->_g308_partyDir;
+	setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
+	f292_drawChampionState((ChampionIndex)champIndex);
+}
+
+void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex) {
+	uint16 champIndex;
+	uint16 slotIndex;
+
+	if (slotBoxIndex < k8_SlotBoxInventoryFirstSlot) {
+		if (_g299_candidateChampionOrdinal)
+			return;
+
+		champIndex = slotBoxIndex >> 1;
+		if ((champIndex >= _g305_partyChampionCount) || (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_gK71_champions[champIndex]._currHealth)
+			return;
+
+		slotIndex = M70_handSlotIndex(slotBoxIndex);
+	} else {
+		champIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+		slotIndex = slotBoxIndex - k8_SlotBoxInventoryFirstSlot;
+	}
+
+	Thing leaderHandObject = _g414_leaderHandObject;
+	Thing slotThing;
+	if (slotIndex >= k30_ChampionSlotChest_1) {
+		slotThing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
+	} else {
+		slotThing = _gK71_champions[champIndex]._slots[slotIndex];
+	}
+
+	if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none))
+		return;
+
+	if ((leaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & gSlotMasks[slotIndex])))
+		return;
+
+	_vm->_eventMan->f78_showMouse();
+	if (leaderHandObject != Thing::_none)
+		f298_getObjectRemovedFromLeaderHand();
+
+	if (slotThing != Thing::_none) {
+		f300_getObjectRemovedFromSlot(champIndex, slotIndex);
+		f297_putObjectInLeaderHand(slotThing, false);
+	}
+
+	if (leaderHandObject != Thing::_none)
+		f301_addObjectInSlot((ChampionIndex)champIndex, leaderHandObject, (ChampionSlot)slotIndex);
+
+	f292_drawChampionState((ChampionIndex)champIndex);
+	_vm->_eventMan->f77_hideMouse();
+}
+
+bool ChampionMan::f327_isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount) {
+	Champion *curChampion = &_gK71_champions[champIndex];
+	if (curChampion->_currMana < requiredManaAmount)
+		return false;
+
+	curChampion->_currMana -= requiredManaAmount;
+	setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+	int16 stepEnergy = 10 - MIN(8, curChampion->_maxMana >> 3);
+	if (kineticEnergy < (stepEnergy << 2)) {
+		kineticEnergy += 3;
+		stepEnergy--;
+	}
+
+	f326_championShootProjectile(curChampion, thing, kineticEnergy, 90, stepEnergy);
+	return true; // fix BUG_01
+}
+
+void ChampionMan::f326_championShootProjectile(Champion* champ, Thing thing, int16 kineticEnergy, int16 attack, int16 stepEnergy) {
+	Direction newDirection = champ->_dir;
+	_vm->_projexpl->f212_projectileCreate(thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, M21_normalizeModulo4((((champ->_cell - newDirection + 1) & 0x0002) >> 1) + newDirection), newDirection, kineticEnergy, attack, stepEnergy);
+	_vm->_g311_projectileDisableMovementTicks = 4;
+	_vm->_g312_lastProjectileDisabledMovementDirection = newDirection;
+}
+
+void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() {
+	Champion *championPtr = _gK71_champions;
+	for (uint16 championIndex = k0_ChampionFirst; championIndex < _g305_partyChampionCount; championIndex++, championPtr++) {
+		int16 pendingWounds = _g410_championPendingWounds[championIndex];
+		setFlag(championPtr->_wounds, pendingWounds);
+		_g410_championPendingWounds[championIndex] = 0;
+		uint16 pendingDamage = _g409_championPendingDamage[championIndex];
+		if (!pendingDamage)
+			continue;
+
+		_g409_championPendingDamage[championIndex] = 0;
+		int16 curHealth = championPtr->_currHealth;
+		if (!curHealth)
+			continue;
+
+		// DEBUG CODE
+		if (_vm->_console->_debugGodmodeHP == false)
+			curHealth -= pendingDamage;
+
+		if (curHealth <= 0) {
+			f319_championKill(championIndex);
+		} else {
+			championPtr->_currHealth = curHealth;
+			setFlag(championPtr->_attributes, k0x0100_ChampionAttributeStatistics);
+			if (pendingWounds) {
+				setFlag(championPtr->_attributes, k0x2000_ChampionAttributeWounds);
+			}
+
+			int16 textPosX = championIndex * k69_ChampionStatusBoxSpacing;
+			int16 textPosY;
+
+			Box blitBox;
+			blitBox._y1 = 0;
+			_vm->_eventMan->f78_showMouse();
+
+			if (_vm->M0_indexToOrdinal(championIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+				blitBox._y2 = 28;
+				blitBox._x1 = textPosX + 7;
+				blitBox._x2 = blitBox._x1 + 31; /* Box is over the champion portrait in the status box */
+				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k16_damageToChampionBig), &blitBox, k16_byteWidth, k10_ColorFlesh, 29);
+				// Check the number of digits and sets the position accordingly.
+				if (pendingDamage < 10) // 1 digit
+					textPosX += 21;
+				else if (pendingDamage < 100)  // 2 digits
+					textPosX += 18;
+				else // 3 digits
+					textPosX += 15;
+
+				textPosY = 16;
+			} else {
+				blitBox._y2 = 6;
+				blitBox._x1 = textPosX;
+				blitBox._x2 = blitBox._x1 + 47; /* Box is over the champion name in the status box */
+				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k15_damageToChampionSmallIndice), &blitBox, k24_byteWidth, k10_ColorFlesh, 7);
+				// Check the number of digits and sets the position accordingly.
+				if (pendingDamage < 10) // 1 digit
+					textPosX += 19;
+				else if (pendingDamage < 100) // 2 digits
+					textPosX += 16;
+				else //3 digits
+					textPosX += 13;
+
+				textPosY = 5;
+			}
+			_vm->_textMan->f53_printToLogicalScreen(textPosX, textPosY, k15_ColorWhite, k8_ColorRed, f288_getStringFromInteger(pendingDamage, false, 3).c_str());
+
+			int16 eventIndex = championPtr->_hideDamageReceivedIndex;
+			if (eventIndex == -1) {
+				TimelineEvent newEvent;
+				newEvent._type = k12_TMEventTypeHideDamageReceived;
+				M33_setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
+				newEvent._priority = championIndex;
+				championPtr->_hideDamageReceivedIndex = _vm->_timeline->f238_addEventGetEventIndex(&newEvent);
+			} else {
+				TimelineEvent *curEvent = &_vm->_timeline->_g370_events[eventIndex];
+				M33_setMapAndTime(curEvent->_mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
+				_vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(eventIndex));
+			}
+			f292_drawChampionState((ChampionIndex)championIndex);
+			_vm->_eventMan->f77_hideMouse();
+		}
+	}
+}
+
+void ChampionMan::f319_championKill(uint16 champIndex) {
+	Champion *curChampion = &_gK71_champions[champIndex];
+	curChampion->_currHealth = 0;
+	setFlag(curChampion->_attributes, k0x1000_ChampionAttributeStatusBox);
+	if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+		if (_vm->_g331_pressingEye) {
+			_vm->_g331_pressingEye = false;
+			_vm->_eventMan->_g597_ignoreMouseMovements = false;
+			if (!_g415_leaderEmptyHanded) {
+				_vm->_objectMan->f34_drawLeaderObjectName(_g414_leaderHandObject);
+			}
+			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
+			_vm->_eventMan->f77_hideMouse();
+		} else if (_vm->_g333_pressingMouth) {
+			_vm->_g333_pressingMouth = false;
+			_vm->_eventMan->_g597_ignoreMouseMovements = false;
+			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
+			_vm->_eventMan->f77_hideMouse();
+		}
+		_vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
+	}
+	f318_dropAllObjects(champIndex);
+	Thing unusedThing = _vm->_dungeonMan->f166_getUnusedThing(k0x8000_championBones | k10_JunkThingType);
+	uint16 curCell = 0;
+	if (unusedThing != Thing::_none) {
+		Junk *L0966_ps_Junk = (Junk *)_vm->_dungeonMan->f156_getThingData(unusedThing);
+		L0966_ps_Junk->setType(k5_JunkTypeBones);
+		L0966_ps_Junk->setDoNotDiscard(true);
+		L0966_ps_Junk->setChargeCount(champIndex);
+		curCell = curChampion->_cell;
+		_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(unusedThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+	}
+	curChampion->_symbolStep = 0;
+	curChampion->_symbols[0] = '\0';
+	curChampion->_dir = _vm->_dungeonMan->_g308_partyDir;
+	curChampion->_maximumDamageReceived = 0;
+	uint16 curChampionIconIndex = M26_championIconIndex(curCell, _vm->_dungeonMan->_g308_partyDir);
+	if (_vm->M0_indexToOrdinal(curChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
+		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
+		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+		warning(false, "IGNORED CODE:G0592_B_BuildMousePointerScreenAreaRequested = true");
+	}
+
+	if (curChampion->_poisonEventCount)
+		f323_unpoison(champIndex);
+
+	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[curChampionIconIndex << 2], k0_ColorBlack);
+	f292_drawChampionState((ChampionIndex)champIndex);
+
+	int16 aliveChampionIndex;
+	for (aliveChampionIndex = k0_ChampionFirst, curChampion = _gK71_champions; aliveChampionIndex < _g305_partyChampionCount; aliveChampionIndex++, curChampion++) {
+		if (curChampion->_currHealth)
+			break;
+	}
+
+	if (aliveChampionIndex == _g305_partyChampionCount) { /* BUG0_43 The game does not end if the last living champion in the party is killed while looking at a candidate champion in a portrait. The condition to end the game when the whole party is killed is not true because the code considers the candidate champion as alive (in the loop above) */
+		_g303_partyDead = true;
+		return;
+	}
+
+	if (champIndex == _g411_leaderIndex)
+		_vm->_eventMan->f368_commandSetLeader((ChampionIndex)aliveChampionIndex);
+
+	if (champIndex == _g514_magicCasterChampionIndex)
+		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(aliveChampionIndex);
+	else
+		_vm->_menuMan->f393_drawSpellAreaControls(_g514_magicCasterChampionIndex);
+}
+
+void ChampionMan::f318_dropAllObjects(uint16 champIndex) {
+	static const int16 slotDropOrder[30] = {
+		k5_ChampionSlotFeet,
+		k4_ChampionSlotLegs,
+		k9_ChampionSlotQuiverLine_2_2,
+		k8_ChampionSlotQuiverLine_1_2,
+		k7_ChampionSlotQuiverLine_2_1,
+		k12_ChampionSlotQuiverLine_1_1,
+		k6_ChampionSlotPouch_2,
+		k11_ChampionSlotPouch_1,
+		k3_ChampionSlotTorso,
+		k13_ChampionSlotBackpackLine_1_1,
+		k14_ChampionSlotBackpackLine_2_2,
+		k15_ChampionSlotBackpackLine_2_3,
+		k16_ChampionSlotBackpackLine_2_4,
+		k17_ChampionSlotBackpackLine_2_5,
+		k18_ChampionSlotBackpackLine_2_6,
+		k19_ChampionSlotBackpackLine_2_7,
+		k20_ChampionSlotBackpackLine_2_8,
+		k21_ChampionSlotBackpackLine_2_9,
+		k22_ChampionSlotBackpackLine_1_2,
+		k23_ChampionSlotBackpackLine_1_3,
+		k24_ChampionSlotBackpackLine_1_4,
+		k25_ChampionSlotBackpackLine_1_5,
+		k26_ChampionSlotBackpackLine_1_6,
+		k27_ChampionSlotBackpackLine_1_7,
+		k28_ChampionSlotBackpackLine_1_8,
+		k29_ChampionSlotBackpackLine_1_9,
+		k10_ChampionSlotNeck,
+		k2_ChampionSlotHead,
+		k0_ChampionSlotReadyHand,
+		k1_ChampionSlotActionHand
+	};
+
+	uint16 curCell = _gK71_champions[champIndex]._cell;
+	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
+		Thing curThing = f300_getObjectRemovedFromSlot(champIndex, slotDropOrder[slotIndex]);
+		if (curThing != Thing::_none)
+			_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(curThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+	}
+}
+
+void ChampionMan::f323_unpoison(int16 champIndex) {
+	if (champIndex == kM1_ChampionNone)
+		return;
+
+	TimelineEvent *eventPtr = _vm->_timeline->_g370_events;
+	for (uint16 eventIndex = 0; eventIndex < _vm->_timeline->_g369_eventMaxCount; eventPtr++, eventIndex++) {
+		if ((eventPtr->_type == k75_TMEventTypePoisonChampion) && (eventPtr->_priority == champIndex))
+			_vm->_timeline->f237_deleteEvent(eventIndex);
+	}
+	_gK71_champions[champIndex]._poisonEventCount = 0;
+}
+
+void ChampionMan::f331_applyTimeEffects() {
+	if (!_g305_partyChampionCount)
+		return;
+
+	Scent checkScent;
+	checkScent.setMapX(_vm->_dungeonMan->_g306_partyMapX);
+	checkScent.setMapY(_vm->_dungeonMan->_g307_partyMapY);
+	checkScent.setMapIndex(_vm->_dungeonMan->_g309_partyMapIndex);
+
+	for (byte loopScentIndex = 0; loopScentIndex + 1 < _g407_party._scentCount; loopScentIndex++) {
+		if (&_g407_party._scents[loopScentIndex] != &checkScent) {
+			_g407_party._scentStrengths[loopScentIndex] = MAX(0, _g407_party._scentStrengths[loopScentIndex] - 1);
+			if (!_g407_party._scentStrengths[loopScentIndex] && !loopScentIndex) {
+				f316_deleteScent(0);
+				continue;
+			}
+		}
+	}
+
+	uint16 gameTime = _vm->_g313_gameTime & 0xFFFF;
+	uint16 timeCriteria = (((gameTime & 0x0080) + ((gameTime & 0x0100) >> 2)) + ((gameTime & 0x0040) << 2)) >> 2;
+	Champion *championPtr = _gK71_champions;
+	for (uint16 championIndex = k0_ChampionFirst; championIndex < _g305_partyChampionCount; championIndex++, championPtr++) {
+		if (championPtr->_currHealth && (_vm->M0_indexToOrdinal(championIndex) != _g299_candidateChampionOrdinal)) {
+			uint16 wizardSkillLevel = f303_getSkillLevel(championIndex, k3_ChampionSkillWizard) + f303_getSkillLevel(championIndex, k2_ChampionSkillPriest);
+			if ((championPtr->_currMana < championPtr->_maxMana)
+				&& (timeCriteria < championPtr->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + wizardSkillLevel)) {
+				int16 manaGain = championPtr->_maxMana / 40;
+				if (_g300_partyIsSleeping)
+					manaGain <<= 1;
+
+				manaGain++;
+				f325_decrementStamina(championIndex, manaGain * MAX(7, 16 - wizardSkillLevel));
+				championPtr->_currMana += MIN<int16>(manaGain, championPtr->_maxMana - championPtr->_currMana);
+			} else if (championPtr->_currMana > championPtr->_maxMana)
+				championPtr->_currMana--;
+
+			for (int16 idx = k19_ChampionSkillWater; idx >= k0_ChampionSkillFighter; idx--) {
+				if (championPtr->_skills[idx]._temporaryExperience > 0)
+					championPtr->_skills[idx]._temporaryExperience--;
+			}
+			uint16 staminaGainCycleCount = 4;
+			int16 staminaMagnitude = championPtr->_maxStamina;
+			while (championPtr->_currStamina < (staminaMagnitude >>= 1))
+				staminaGainCycleCount += 2;
+
+			int16 staminaLoss = 0;
+			int16 staminaAmount = f26_getBoundedValue(1, (championPtr->_maxStamina >> 8) - 1, 6);
+			if (_g300_partyIsSleeping)
+				staminaAmount <<= 1;
+
+			int32 compDelay = _vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime;
+			if (compDelay > 80) {
+				staminaAmount++;
+				if (compDelay > 250)
+					staminaAmount++;
+			}
+			do {
+				bool staminaAboveHalf = (staminaGainCycleCount <= 4);
+				if (championPtr->_food < -512) {
+					if (staminaAboveHalf) {
+						staminaLoss += staminaAmount;
+						championPtr->_food -= 2;
+					}
+				} else {
+					if (championPtr->_food >= 0)
+						staminaLoss -= staminaAmount;
+
+					championPtr->_food -= staminaAboveHalf ? 2 : staminaGainCycleCount >> 1;
+				}
+				if (championPtr->_water < -512) {
+					if (staminaAboveHalf) {
+						staminaLoss += staminaAmount;
+						championPtr->_water -= 1;
+					}
+				} else {
+					if (championPtr->_water >= 0)
+						staminaLoss -= staminaAmount;
+
+					championPtr->_water -= staminaAboveHalf ? 1 : staminaGainCycleCount >> 2;
+				}
+			} while (--staminaGainCycleCount && ((championPtr->_currStamina - staminaLoss) < championPtr->_maxStamina));
+			f325_decrementStamina(championIndex, staminaLoss);
+			if (championPtr->_food < -1024)
+				championPtr->_food = -1024;
+
+			if (championPtr->_water < -1024)
+				championPtr->_water = -1024;
+
+			if ((championPtr->_currHealth < championPtr->_maxHealth) && (championPtr->_currStamina >= (championPtr->_maxStamina >> 2)) && (timeCriteria < (championPtr->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] + 12))) {
+				int16 healthGain = (championPtr->_maxHealth >> 7) + 1;
+				if (_g300_partyIsSleeping)
+					healthGain <<= 1;
+
+				if (_vm->_objectMan->f33_getIconIndex(championPtr->_slots[k10_ChampionSlotNeck]) == k121_IconIndiceJunkEkkhardCross)
+					healthGain += (healthGain >> 1) + 1;
+
+				championPtr->_currHealth += MIN(healthGain, (int16)(championPtr->_maxHealth - championPtr->_currHealth));
+			}
+			if (!((int)_vm->_g313_gameTime & (_g300_partyIsSleeping ? 63 : 255))) {
+				for (uint16 i = k0_ChampionStatLuck; i <= k6_ChampionStatAntifire; i++) {
+					byte *curStatistic = championPtr->_statistics[i];
+					uint16 statisticMaximum = curStatistic[k0_ChampionStatMaximum];
+					if (curStatistic[k1_ChampionStatCurrent] < statisticMaximum)
+						curStatistic[k1_ChampionStatCurrent]++;
+					else if (curStatistic[k1_ChampionStatCurrent] > statisticMaximum)
+						curStatistic[k1_ChampionStatCurrent] -= curStatistic[k1_ChampionStatCurrent] / statisticMaximum;
+				}
+			}
+			if (!_g300_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_g313_gameTime)) {
+				championPtr->_dir = _vm->_dungeonMan->_g308_partyDir;
+				championPtr->_maximumDamageReceived = 0;
+				setFlag(championPtr->_attributes, k0x0400_ChampionAttributeIcon);
+			}
+			setFlag(championPtr->_attributes, k0x0100_ChampionAttributeStatistics);
+			if (_vm->M0_indexToOrdinal(championIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+				if (_vm->_g333_pressingMouth || _vm->_g331_pressingEye || (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
+					setFlag(championPtr->_attributes, k0x0800_ChampionAttributePanel);
+				}
+			}
+		}
+	}
+	f293_drawAllChampionStates();
+}
+
+void ChampionMan::save2_PartyPart(Common::OutSaveFile* file) {
+	for (uint16 i = 0; i < 4; ++i) {
+		Champion *champ = &_gK71_champions[i];
+		file->writeUint16BE(champ->_attributes);
+		file->writeUint16BE(champ->_wounds);
+		for (uint16 y = 0; y < 7; ++y)
+			for (uint16 x = 0; x < 3; ++x)
+				file->writeByte(champ->_statistics[y][x]);
+		for (uint16 j = 0; j < 30; ++j)
+			file->writeUint16BE(champ->_slots[j].toUint16());
+		for (uint16 j = 0; j < 20; ++j) {
+			file->writeSint16BE(champ->_skills[j]._temporaryExperience);
+			file->writeSint32BE(champ->_skills[j]._experience);
+		}
+		for (uint16 j = 0; j < 8; ++j)
+			file->writeByte(champ->_name[j]);
+		for (uint16 j = 0; j < 20; ++j)
+			file->writeByte(champ->_title[j]);
+		file->writeUint16BE(champ->_dir);
+		file->writeUint16BE(champ->_cell);
+		file->writeUint16BE(champ->_actionIndex);
+		file->writeUint16BE(champ->_symbolStep);
+		for (uint16 j = 0; j < 5; ++j)
+			file->writeByte(champ->_symbols[j]);
+		file->writeUint16BE(champ->_directionMaximumDamageReceived);
+		file->writeUint16BE(champ->_maximumDamageReceived);
+		file->writeUint16BE(champ->_poisonEventCount);
+		file->writeSint16BE(champ->_enableActionEventIndex);
+		file->writeSint16BE(champ->_hideDamageReceivedIndex);
+		file->writeSint16BE(champ->_currHealth);
+		file->writeSint16BE(champ->_maxHealth);
+		file->writeSint16BE(champ->_currStamina);
+		file->writeSint16BE(champ->_maxStamina);
+		file->writeSint16BE(champ->_currMana);
+		file->writeSint16BE(champ->_maxMana);
+		file->writeSint16BE(champ->_actionDefense);
+		file->writeSint16BE(champ->_food);
+		file->writeSint16BE(champ->_water);
+		file->writeUint16BE(champ->_load);
+		file->writeSint16BE(champ->_shieldDefense);
+		for (uint16 j = 0; j < 928; ++j)
+			file->writeByte(champ->_portrait[j]);
+	}
+
+	Party &party = _g407_party;
+	file->writeSint16BE(party._magicalLightAmount);
+	file->writeByte(party._event73Count_ThievesEye);
+	file->writeByte(party._event79Count_Footprints);
+	file->writeSint16BE(party._shieldDefense);
+	file->writeSint16BE(party._fireShieldDefense);
+	file->writeSint16BE(party._spellShieldDefense);
+	file->writeByte(party._scentCount);
+	file->writeByte(party._freezeLifeTicks);
+	file->writeByte(party._firstScentIndex);
+	file->writeByte(party._lastScentIndex);
+	for (uint16 i = 0; i < 24; ++i)
+		file->writeUint16BE(party._scents[i].toUint16());
+	for (uint16 i = 0; i < 24; ++i)
+		file->writeByte(party._scentStrengths[i]);
+	file->writeByte(party._event71Count_Invisibility);
+}
+
+void ChampionMan::load2_PartyPart(Common::InSaveFile* file) {
+	for (uint16 i = 0; i < 4; ++i) {
+		Champion *champ = &_gK71_champions[i];
+		champ->_attributes = file->readUint16BE();
+		champ->_wounds = file->readUint16BE();
+		for (uint16 y = 0; y < 7; ++y)
+			for (uint16 x = 0; x < 3; ++x)
+				champ->_statistics[y][x] = file->readByte();
+		for (uint16 j = 0; j < 30; ++j)
+			champ->_slots[j] = Thing(file->readUint16BE());
+		for (uint16 j = 0; j < 20; ++j) {
+			champ->_skills[j]._temporaryExperience = file->readSint16BE();
+			champ->_skills[j]._experience = file->readSint32BE();
+		}
+		for (uint16 j = 0; j < 8; ++j)
+			champ->_name[j] = file->readByte();
+		for (uint16 j = 0; j < 20; ++j)
+			champ->_title[j] = file->readByte();
+		champ->_dir = (Direction)file->readUint16BE();
+		champ->_cell = (ViewCell)file->readUint16BE();
+		champ->_actionIndex = (ChampionAction)file->readUint16BE();
+		champ->_symbolStep = file->readUint16BE();
+		for (uint16 j = 0; j < 5; ++j)
+			champ->_symbols[j] = file->readByte();
+		champ->_directionMaximumDamageReceived = file->readUint16BE();
+		champ->_maximumDamageReceived = file->readUint16BE();
+		champ->_poisonEventCount = file->readUint16BE();
+		champ->_enableActionEventIndex = file->readSint16BE();
+		champ->_hideDamageReceivedIndex = file->readSint16BE();
+		champ->_currHealth = file->readSint16BE();
+		champ->_maxHealth = file->readSint16BE();
+		champ->_currStamina = file->readSint16BE();
+		champ->_maxStamina = file->readSint16BE();
+		champ->_currMana = file->readSint16BE();
+		champ->_maxMana = file->readSint16BE();
+		champ->_actionDefense = file->readSint16BE();
+		champ->_food = file->readSint16BE();
+		champ->_water = file->readSint16BE();
+		champ->_load = file->readUint16BE();
+		champ->_shieldDefense = file->readSint16BE();
+		for (uint16 j = 0; j < 928; ++j)
+			champ->_portrait[j] = file->readByte();
+	}
+
+	Party &party = _g407_party;
+	party._magicalLightAmount = file->readSint16BE();
+	party._event73Count_ThievesEye = file->readByte();
+	party._event79Count_Footprints = file->readByte();
+	party._shieldDefense = file->readSint16BE();
+	party._fireShieldDefense = file->readSint16BE();
+	party._spellShieldDefense = file->readSint16BE();
+	party._scentCount = file->readByte();
+	party._freezeLifeTicks = file->readByte();
+	party._firstScentIndex = file->readByte();
+	party._lastScentIndex = file->readByte();
+	for (uint16 i = 0; i < 24; ++i)
+		party._scents[i] = Scent(file->readUint16BE());
+	for (uint16 i = 0; i < 24; ++i)
+		party._scentStrengths[i] = file->readByte();
+	party._event71Count_Invisibility = file->readByte();
+}
+
+ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
+	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
+		if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
+			return (ChampionIndex)i;
+	}
+
+	return kM1_ChampionNone;
+}
+
+void ChampionMan::f278_resetDataToStartGame() {
+	if (!_vm->_g298_newGame) {
+		Thing L0787_T_Thing;
+		if ((L0787_T_Thing = _g414_leaderHandObject) == Thing::_none) {
+			_g415_leaderEmptyHanded = true;
+			_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
+			_vm->_eventMan->f69_setMousePointer();
+		} else {
+			f297_putObjectInLeaderHand(L0787_T_Thing, true); /* This call will add the weight of the leader hand object to the Load of the leader a first time */
+		}
+		Champion *L0788_ps_Champion = _gK71_champions;
+		int16 L0785_i_ChampionIndex;
+		for (L0785_i_ChampionIndex = k0_ChampionFirst; L0785_i_ChampionIndex < _g305_partyChampionCount; L0785_i_ChampionIndex++, L0788_ps_Champion++) {
+			clearFlag(L0788_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
+			setFlag(L0788_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
+		}
+		f293_drawAllChampionStates();
+		if ((L0785_i_ChampionIndex = _g411_leaderIndex) != kM1_ChampionNone) {
+			_g411_leaderIndex = kM1_ChampionNone;
+			_vm->_eventMan->f368_commandSetLeader((ChampionIndex)L0785_i_ChampionIndex);
+		}
+		if ((L0785_i_ChampionIndex = _g514_magicCasterChampionIndex) != kM1_ChampionNone) {
+			_g514_magicCasterChampionIndex = kM1_ChampionNone;
+			_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(L0785_i_ChampionIndex);
+		}
+		return;
+	}
+
+	_g414_leaderHandObject = Thing::_none;
+	_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
+	_g415_leaderEmptyHanded = true;
+}
+
+void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) {
+	if (!_g415_leaderEmptyHanded)
+		return;
+
+	if (_g305_partyChampionCount == 4)
+		return;
+
+	uint16 previousPartyChampionCount = _g305_partyChampionCount;
+	Champion *championPtr = &_gK71_champions[previousPartyChampionCount];
+	championPtr->resetToZero();
+	// Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portraits could be missing in the data)
+	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
+	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, gBoxChampionPortrait, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency);
+	championPtr->_actionIndex = k255_ChampionActionNone;
+	championPtr->_enableActionEventIndex = -1;
+	championPtr->_hideDamageReceivedIndex = -1;
+	championPtr->_dir = _vm->_dungeonMan->_g308_partyDir;
+	uint16 viewCell = k0_ViewCellFronLeft;
+	while (f285_getIndexInCell(M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone)
+		viewCell++;
+
+	championPtr->_cell = (ViewCell)M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir);
+	championPtr->_attributes = k0x0400_ChampionAttributeIcon;
+	championPtr->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir;
+	championPtr->_food = 1500 + _vm->getRandomNumber(256);
+	championPtr->_water = 1500 + _vm->getRandomNumber(256);
+	for (int16 slotIdx = k0_ChampionSlotReadyHand; slotIdx < k30_ChampionSlotChest_1; slotIdx++)
+		championPtr->_slots[slotIdx] = Thing::_none;
+
+	Thing curThing = _vm->_dungeonMan->f161_getSquareFirstThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+	while (curThing.getType() != k2_TextstringType)
+		curThing = _vm->_dungeonMan->f159_getNextThing(curThing);
+
+	char L0807_ac_DecodedChampionText[77];
+	char *decodedStringPtr = L0807_ac_DecodedChampionText;
+	_vm->_dungeonMan->f168_decodeText(decodedStringPtr, curThing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
+
+	uint16 charIdx = 0;
+	char tmpChar;
+	while ((tmpChar = *decodedStringPtr++) != '\n')
+		championPtr->_name[charIdx++] = tmpChar;
+
+	championPtr->_name[charIdx] = '\0';
+	charIdx = 0;
+	bool championTitleCopiedFl = false;
+	for (;;) { /*_Infinite loop_*/
+		tmpChar = *decodedStringPtr++;
+		if (tmpChar == '\n') { /* New line */
+			if (championTitleCopiedFl)
+				break;
+			championTitleCopiedFl = true;
+		} else
+			championPtr->_title[charIdx++] = tmpChar;
+	}
+	championPtr->_title[charIdx] = '\0';
+	if (*decodedStringPtr++ == 'M')
+		setFlag(championPtr->_attributes, k0x0010_ChampionAttributeMale);
+
+	decodedStringPtr++;
+	championPtr->_currHealth = championPtr->_maxHealth = f279_getDecodedValue(decodedStringPtr, 4);
+	decodedStringPtr += 4;
+	championPtr->_currStamina = championPtr->_maxStamina = f279_getDecodedValue(decodedStringPtr, 4);
+	decodedStringPtr += 4;
+	championPtr->_currMana = championPtr->_maxMana = f279_getDecodedValue(decodedStringPtr, 4);
+	decodedStringPtr += 4;
+	decodedStringPtr++;
+	for (int16 statIdx = k0_ChampionStatLuck; statIdx <= k6_ChampionStatAntifire; statIdx++) {
+		championPtr->_statistics[statIdx][k2_ChampionStatMinimum] = 30;
+		championPtr->_statistics[statIdx][k1_ChampionStatCurrent] = championPtr->_statistics[statIdx][k0_ChampionStatMaximum] = f279_getDecodedValue(decodedStringPtr, 2);
+		decodedStringPtr += 2;
+	}
+	championPtr->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10;
+	decodedStringPtr++;
+	for (uint16 skillIdx = k4_ChampionSkillSwing; skillIdx <= k19_ChampionSkillWater; skillIdx++) {
+		int skillValue = *decodedStringPtr++ - 'A';
+		if (skillValue > 0)
+			championPtr->_skills[skillIdx]._experience = 125L << skillValue;
+	}
+	for (uint16 skillIdx = k0_ChampionSkillFighter; skillIdx <= k3_ChampionSkillWizard; skillIdx++) {
+		int32 baseSkillExperience = 0;
+		int16 hiddenSkillIndex = (skillIdx + 1) << 2;
+		for (uint16 hiddenIdx = 0; hiddenIdx < 4; hiddenIdx++)
+			baseSkillExperience += championPtr->_skills[hiddenSkillIndex + hiddenIdx]._experience;
+
+		championPtr->_skills[skillIdx]._experience = baseSkillExperience;
+	}
+	_g299_candidateChampionOrdinal = previousPartyChampionCount + 1;
+	if (++_g305_partyChampionCount == 1) {
+		_vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst);
+		_vm->_menuMan->_g508_refreshActionArea = true;
+	} else {
+		_vm->_menuMan->f388_clearActingChampion();
+		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1));
+	}
+
+	int16 curMapX = _vm->_dungeonMan->_g306_partyMapX;
+	int16 curMapY = _vm->_dungeonMan->_g307_partyMapY;
+	uint16 championObjectsCell = returnOppositeDir(_vm->_dungeonMan->_g308_partyDir);
+	curMapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], curMapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+	curThing = _vm->_dungeonMan->f161_getSquareFirstThing(curMapX, curMapY);
+	int16 slotIdx = k13_ChampionSlotBackpackLine_1_1;
+	while (curThing != Thing::_endOfList) {
+		ThingType thingType = curThing.getType();
+		if ((thingType > k3_SensorThingType) && (curThing.getCell() == championObjectsCell)) {
+			int16 objectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(curThing)]._allowedSlots;
+			uint16 curSlotIndex;
+			switch (thingType) {
+			case k6_ArmourThingType: {
+				bool skipCheck = false;
+				for (curSlotIndex = k2_ChampionSlotHead; curSlotIndex <= k5_ChampionSlotFeet; curSlotIndex++) {
+					if (objectAllowedSlots & gSlotMasks[curSlotIndex]) {
+						skipCheck = true;
+						break;
+					}
+				}
+
+				if (skipCheck)
+					break;
+
+				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
+					curSlotIndex = k10_ChampionSlotNeck;
+				else
+					curSlotIndex = slotIdx++;
+
+				break;
+			}
+			case k5_WeaponThingType:
+				if (championPtr->_slots[k1_ChampionSlotActionHand] == Thing::_none)
+					curSlotIndex = k1_ChampionSlotActionHand;
+				else if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
+					curSlotIndex = k10_ChampionSlotNeck;
+				else
+					curSlotIndex = slotIdx++;
+				break;
+			case k7_ScrollThingType:
+			case k8_PotionThingType:
+				if (championPtr->_slots[k11_ChampionSlotPouch_1] == Thing::_none)
+					curSlotIndex = k11_ChampionSlotPouch_1;
+				else if (championPtr->_slots[k6_ChampionSlotPouch_2] == Thing::_none)
+					curSlotIndex = k6_ChampionSlotPouch_2;
+				else if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
+					curSlotIndex = k10_ChampionSlotNeck;
+				else
+					curSlotIndex = slotIdx++;
+				break;
+			case k9_ContainerThingType:
+			case k10_JunkThingType:
+				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
+					curSlotIndex = k10_ChampionSlotNeck;
+				else
+					curSlotIndex = slotIdx++;
+
+				break;
+			default:
+				break;
+			}
+
+			while (championPtr->_slots[curSlotIndex] != Thing::_none) {
+				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
+					curSlotIndex = k10_ChampionSlotNeck;
+				else
+					curSlotIndex = slotIdx++;
+			}
+			f301_addObjectInSlot((ChampionIndex)previousPartyChampionCount, curThing, (ChampionSlot)curSlotIndex);
+		}
+		curThing = _vm->_dungeonMan->f159_getNextThing(curThing);
+	}
+	_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)previousPartyChampionCount);
+	_vm->_menuMan->f456_drawDisabledMenu();;
+}
+
+void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
+	int16 barGraphHeights[3];
+	Champion *champ = &_gK71_champions[champIndex];
+	int16 barGraphIdx = 0;
+	if (champ->_currHealth > 0) {
+		int32 barGraphHeight = (((int32)champ->_currHealth << 10) * 25) / champ->_maxHealth;
+		barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + ((barGraphHeight & 0x000003FF) ? 1 : 0);
+	} else
+		barGraphHeights[barGraphIdx++] = 0;
+
+	if (champ->_currStamina > 0) {
+		int32 barGraphHeight = (((int32)champ->_currStamina << 10) * 25) / champ->_maxStamina;
+		barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + ((barGraphHeight & 0x000003FF) ? 1 : 0);
+	} else
+		barGraphHeights[barGraphIdx++] = 0;
+
+	if (champ->_currMana > 0) {
+		if (champ->_currMana > champ->_maxMana)
+			barGraphHeights[barGraphIdx] = 25;
+		else {
+			int32 barGraphHeight = (((int32)champ->_currMana << 10) * 25) / champ->_maxMana;
+			barGraphHeights[barGraphIdx] = (barGraphHeight >> 10) + ((barGraphHeight & 0x000003FF) ? 1 : 0);
+		}
+	} else {
+		barGraphHeights[barGraphIdx] = 0;
+	}
+	_vm->_eventMan->f78_showMouse();
+
+	// Strangerke - TO CHECK: if portraits, maybe the old (assembly) code is required for older versions
+	Box box;
+	box._x1 = champIndex * k69_ChampionStatusBoxSpacing + 46;
+	box._x2 = box._x1 + 3;
+	box._y1 = 2;
+	box._y2 = 26;
+	for (int16 barGraphIndex = 0; barGraphIndex < 3; barGraphIndex++) {
+		int16 barGraphHeight = barGraphHeights[barGraphIndex];
+		if (barGraphHeight < 25) {
+			box._y1 = 2;
+			box._y2 = 27 - barGraphHeight;
+			_vm->_displayMan->D24_fillScreenBox(box, k12_ColorDarkestGray);
+		}
+		if (barGraphHeight) {
+			box._y1 = 27 - barGraphHeight;
+			box._y2 = 26;
+			_vm->_displayMan->D24_fillScreenBox(box, g46_ChampionColor[champIndex]);
+		}
+		box._x1 += 7;
+		box._x2 += 7;
+	}
+	_vm->_eventMan->f77_hideMouse();
+}
+
+
+uint16 ChampionMan::f306_getStaminaAdjustedValue(Champion *champ, int16 val) {
+	int16 currStamina = champ->_currStamina;
+	int16 halfMaxStamina = champ->_maxStamina / 2;
+	if (currStamina < halfMaxStamina) {
+		warning(false, "Possible undefined behavior in the original code");
+		val /= 2;
+		return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina;
+	}
+	return val;
+}
+
+uint16 ChampionMan::f309_getMaximumLoad(Champion *champ) {
+	uint16 maximumLoad = champ->getStatistic(k1_ChampionStatStrength, k1_ChampionStatCurrent) * 8 + 100;
+	maximumLoad = f306_getStaminaAdjustedValue(champ, maximumLoad);
+	int16 wounds = champ->getWounds();
+	if (wounds)
+		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(k0x0010_ChampionWoundLegs) ? 2 : 3);
+
+	if (_vm->_objectMan->f33_getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == k119_IconIndiceArmourElvenBoots)
+		maximumLoad += maximumLoad * 16;
+
+	maximumLoad += 9;
+	maximumLoad -= maximumLoad % 10;
+	return maximumLoad;
+}
+
+void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
+	int16 championStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
+	Champion *curChampion = &_gK71_champions[champIndex];
+	uint16 championAttributes = curChampion->_attributes;
+	if (!getFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand))
+		return;
+
+	bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	_vm->_eventMan->f78_showMouse();
+	if (getFlag(championAttributes, k0x1000_ChampionAttributeStatusBox)) {
+		Box box;
+		box._y1 = 0;
+		box._y2 = 28;
+		box._x1 = championStatusBoxX;
+		box._x2 = box._x1 + 66;
+		if (curChampion->_currHealth) {
+			_vm->_displayMan->D24_fillScreenBox(box, k12_ColorDarkestGray);
+			int16 nativeBitmapIndices[3];
+			for (uint16 i = 0; i < 3; ++i)
+				nativeBitmapIndices[i] = 0;
+
+			uint16 borderCount = 0;
+			if (_g407_party._fireShieldDefense > 0)
+				nativeBitmapIndices[borderCount++] = k38_BorderPartyFireshieldIndice;
+
+			if (_g407_party._spellShieldDefense > 0)
+				nativeBitmapIndices[borderCount++] = k39_BorderPartySpellshieldIndice;
+
+			if ((_g407_party._shieldDefense > 0) || curChampion->_shieldDefense)
+				nativeBitmapIndices[borderCount++] = k37_BorderPartyShieldIndice;
+
+			while (borderCount--)
+				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndices[borderCount]), &box, k40_byteWidth, k10_ColorFlesh, 29);
+
+			if (isInventoryChampion) {
+				_vm->_inventoryMan->f354_drawStatusBoxPortrait(champIndex);
+				setFlag(championAttributes, k0x0100_ChampionAttributeStatistics);
+			} else
+				setFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand);
+		} else {
+			_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), &box, k40_byteWidth, kM1_ColorNoTransparency, 29);
+			_vm->_textMan->f53_printToLogicalScreen(championStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, curChampion->_name);
+			_vm->_menuMan->f386_drawActionIcon(champIndex);
+
+			clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
+			_vm->_eventMan->f77_hideMouse();
+			return;
+		}
+	}
+	if (!(curChampion->_currHealth)) {
+		clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
+		_vm->_eventMan->f77_hideMouse();
+		return;
+	}
+
+	if (getFlag(championAttributes, k0x0080_ChampionAttributeNameTitle)) {
+		Color nameColor = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
+		if (isInventoryChampion) {
+			char *championName = curChampion->_name;
+			_vm->_textMan->f52_printToViewport(3, 7, nameColor, championName);
+			int16 championTitleX = 6 * strlen(championName) + 3;
+			char titleFirstCharacter = curChampion->_title[0];
+			if ((titleFirstCharacter != ',') && (titleFirstCharacter != ';') && (titleFirstCharacter != '-'))
+				championTitleX += 6;
+
+			_vm->_textMan->f52_printToViewport(championTitleX, 7, nameColor, curChampion->_title);
+			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
+		} else {
+			Box box;
+			box._y1 = 0;
+			box._y2 = 6;
+			box._x1 = championStatusBoxX;
+			box._x2 = box._x1 + 42;
+			_vm->_displayMan->D24_fillScreenBox(box, k1_ColorDarkGary);
+			_vm->_textMan->f53_printToLogicalScreen(championStatusBoxX + 1, 5, nameColor, k1_ColorDarkGary, curChampion->_name);
+		}
+	}
+	if (getFlag(championAttributes, k0x0100_ChampionAttributeStatistics)) {
+		f287_drawChampionBarGraphs(champIndex);
+		if (isInventoryChampion) {
+			f290_drawHealthStaminaManaValues(curChampion);
+			int16 nativeBitmapIndex;
+			if ((curChampion->_food < 0) || (curChampion->_water < 0) || (curChampion->_poisonEventCount))
+				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
+			else
+				nativeBitmapIndex = k33_SlotBoxNormalIndice;
+
+			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), gBoxMouth, k16_byteWidth, k12_ColorDarkestGray, 18);
+			nativeBitmapIndex = k33_SlotBoxNormalIndice;
+			for (int i = k1_ChampionStatStrength; i <= k6_ChampionStatAntifire; i++) {
+				if ((curChampion->_statistics[i][k1_ChampionStatCurrent] < curChampion->_statistics[i][k0_ChampionStatMaximum])) {
+					nativeBitmapIndex = k34_SlotBoxWoundedIndice;
+					break;
+				}
+			}
+			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), gBoxEye, k16_byteWidth, k12_ColorDarkestGray, 18);
+			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
+		}
+	}
+	if (getFlag(championAttributes, k0x2000_ChampionAttributeWounds)) {
+		for (int i = isInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; i >= k0_ChampionSlotReadyHand; i--)
+			f291_drawSlot(champIndex, i);
+
+		if (isInventoryChampion)
+			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
+	}
+	if (getFlag(championAttributes, k0x0200_ChampionAttributeLoad) && isInventoryChampion) {
+		uint16 maxLoad = f309_getMaximumLoad(curChampion);
+		Color loadColor;
+		if (curChampion->_load > maxLoad)
+			loadColor = k8_ColorRed;
+		else if (((long)curChampion->_load << 3) > ((long)maxLoad * 5))
+			loadColor = k11_ColorYellow;
+		else
+			loadColor = k13_ColorLightestGray;
+
+		_vm->_textMan->f52_printToViewport(104, 132, loadColor, "LOAD ");
+		maxLoad = curChampion->_load / 10;
+		strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, true, 3).c_str());
+		strcat(_vm->_g353_stringBuildBuffer, ".");
+		maxLoad = curChampion->_load - (maxLoad * 10);
+		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, false, 1).c_str());
+		strcat(_vm->_g353_stringBuildBuffer, "/");
+		maxLoad = (f309_getMaximumLoad(curChampion) + 5) / 10;
+		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, true, 3).c_str());
+		strcat(_vm->_g353_stringBuildBuffer, " KG");
+		_vm->_textMan->f52_printToViewport(148, 132, loadColor, _vm->_g353_stringBuildBuffer);
+		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
+	}
+	uint16 championIconIndex = M26_championIconIndex(curChampion->_cell, _vm->_dungeonMan->_g308_partyDir);
+	if (getFlag(championAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(championIconIndex))) {
+		_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[championIconIndex], g46_ChampionColor[champIndex]);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[championIconIndex], M26_championIconIndex(curChampion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
+	}
+	if (getFlag(championAttributes, k0x0800_ChampionAttributePanel) && isInventoryChampion) {
+		if (_vm->_g333_pressingMouth)
+			_vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned();
+		else if (_vm->_g331_pressingEye) {
+			if (_g415_leaderEmptyHanded)
+				_vm->_inventoryMan->f351_drawChampionSkillsAndStatistics();
+		} else
+			_vm->_inventoryMan->f347_drawPanel();
+
+		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
+	}
+	if (getFlag(championAttributes, k0x8000_ChampionAttributeActionHand)) {
+		f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
+		_vm->_menuMan->f386_drawActionIcon(champIndex);
+		if (isInventoryChampion)
+			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
+	}
+	if (getFlag(championAttributes, k0x4000_ChampionAttributeViewport))
+		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+
+	clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
+	_vm->_eventMan->f77_hideMouse();
+}
+
+uint16 ChampionMan::M26_championIconIndex(int16 val, Direction dir) {
+	return ((val + 4 - dir) & 0x3);
+}
+
+void ChampionMan::f290_drawHealthStaminaManaValues(Champion* champ) {
+	f289_drawHealthOrStaminaOrManaValue(116, champ->_currHealth, champ->_maxHealth);
+	f289_drawHealthOrStaminaOrManaValue(124, champ->_currStamina, champ->_maxStamina);
+	f289_drawHealthOrStaminaOrManaValue(132, champ->_currMana, champ->_maxMana);
+}
+
+void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
+	int16 nativeBitmapIndex = -1;
+	Champion *champ = &_gK71_champions[champIndex];
+	bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex));
+
+	uint16 slotBoxIndex;
+	if (!isInventoryChamp) {
+		// If drawing a slot for a champion other than the champion whose inventory is open
+		if ((slotIndex > k1_ChampionSlotActionHand) || (_g299_candidateChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)))
+			return;
+		slotBoxIndex = (champIndex << 1) + slotIndex;
+	} else
+		slotBoxIndex = k8_SlotBoxInventoryFirstSlot + slotIndex;
+
+	Thing thing;
+	if (slotIndex >= k30_ChampionSlotChest_1)
+		thing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
+	else
+		thing = champ->getSlot((ChampionSlot)slotIndex);
+
+	SlotBox *slotBox = &_vm->_objectMan->_g30_slotBoxes[slotBoxIndex];
+	Box box;
+	box._x1 = slotBox->_x - 1;
+	box._y1 = slotBox->_y - 1;
+	box._x2 = box._x1 + 17;
+	box._y2 = box._y1 + 17;
+
+	if (!isInventoryChamp)
+		_vm->_eventMan->f77_hideMouse();
+
+	int16 iconIndex;
+	if (thing == Thing::_none) {
+		if (slotIndex <= k5_ChampionSlotFeet) {
+			iconIndex = k212_IconIndiceReadyHand + (slotIndex << 1);
+			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) {
+				iconIndex++;
+				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
+			} else
+				nativeBitmapIndex = k33_SlotBoxNormalIndice;
+		} else {
+			if ((slotIndex >= k10_ChampionSlotNeck) && (slotIndex <= k13_ChampionSlotBackpackLine_1_1))
+				iconIndex = k208_IconIndiceNeck + (slotIndex - k10_ChampionSlotNeck);
+			else
+				iconIndex = k204_IconIndiceEmptyBox;
+		}
+	} else {
+		iconIndex = _vm->_objectMan->f33_getIconIndex(thing); // BUG0_35
+		if (isInventoryChamp && (slotIndex == k1_ChampionSlotActionHand) && ((iconIndex == k144_IconIndiceContainerChestClosed) || (iconIndex == k30_IconIndiceScrollOpen))) {
+			iconIndex++;
+		} // BUG2_00
+		if (slotIndex <= k5_ChampionSlotFeet) {
+			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex)))
+				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
+			else
+				nativeBitmapIndex = k33_SlotBoxNormalIndice;
+		}
+	}
+
+	if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->M0_indexToOrdinal(champIndex) == _g506_actingChampionOrdinal))
+		nativeBitmapIndex = k35_SlotBoxActingHandIndice;
+
+	if (nativeBitmapIndex != -1) {
+		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+		if (isInventoryChamp)
+			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
+												_vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray);
+		else
+			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
+												_vm->_displayMan->_g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen, k12_ColorDarkestGray);
+	}
+
+	_vm->_objectMan->f38_drawIconInSlotBox(slotBoxIndex, iconIndex);
+
+	if (!isInventoryChamp)
+		_vm->_eventMan->f78_showMouse();
+}
+
+void ChampionMan::f281_renameChampion(Champion* champ) {
+#define k1_RENAME_CHAMPION_NAME 1
+#define k2_RENAME_CHAMPION_TITLE 2
+	static const char underscoreCharacterString[2] = "_";
+	static char renameChampionInputCharacterString[2] = " ";
+	static const char reincarnateSpecialCharacters[6] = {',', '.', ';', ':', ' '};
+
+	Box displayBox;
+	displayBox._y1 = 3;
+	displayBox._y2 = 8;
+	displayBox._x1 = 3;
+	displayBox._x2 = displayBox._x1 + 167;
+
+	_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, displayBox, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
+	_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), g32_BoxPanel, k72_byteWidth, k4_ColorCyan, 73);
+	_vm->_textMan->f52_printToViewport(177, 58, k13_ColorLightestGray, "_______");
+	_vm->_textMan->f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________");
+	_vm->_eventMan->f78_showMouse();
+	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+	_vm->_eventMan->f67_setMousePointerToNormal(k0_pointerArrow);
+	_vm->_eventMan->f77_hideMouse();
+	uint16 curCharacterIndex = 0;
+	champ->_name[curCharacterIndex] = '\0';
+	champ->_title[0] = '\0';
+	int16 renamedChampionStringMode = k1_RENAME_CHAMPION_NAME;
+	char *renamedChampionString = champ->_name;
+	int16 textPosX = 177;
+	int16 textPosY = 91;
+
+	for (;;) { /*_Infinite loop_*/
+		bool championTitleIsFull = ((renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE) && (curCharacterIndex == 19));
+		if (!championTitleIsFull) {
+			_vm->_eventMan->f78_showMouse();
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k9_ColorGold, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
+			_vm->_eventMan->f77_hideMouse();
+		}
+
+		int16 curCharacter = 256;
+		while (curCharacter == 256) {
+			Common::Event event;
+			Common::EventType eventType = _vm->_eventMan->processInput(&event, &event);
+			_vm->_displayMan->updateScreen();
+			if (_vm->_engineShouldQuit)
+				return;
+			_vm->_displayMan->updateScreen();
+				//_vm->f22_delay(1);
+
+			if (eventType == Common::EVENT_LBUTTONDOWN) {
+				// If left mouse button status has changed
+
+				Common::Point mousePos = _vm->_eventMan->getMousePos();
+				if ((renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE || (curCharacterIndex > 0)) && (mousePos.x >= 197) && (mousePos.x <= 215) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'OK' button */
+					int16 characterIndexBackup = curCharacterIndex;
+					char L0821_ac_ChampionNameBackupString[8];
+					renamedChampionString = champ->_name;
+					strcpy(L0821_ac_ChampionNameBackupString, renamedChampionString);
+					curCharacterIndex = strlen(renamedChampionString);
+					// Replace space characters on the right of the champion name by '\0' characters
+					while (renamedChampionString[--curCharacterIndex] == ' ')
+						renamedChampionString[curCharacterIndex] = '\0';
+
+					bool found = false;
+					for (uint16 idx = k0_ChampionFirst; idx < _g305_partyChampionCount - 1; idx++) {
+						if (!strcmp(_gK71_champions[idx]._name, renamedChampionString)) {
+							// If an existing champion already has the specified name for the new champion
+							found = true;
+							break;
+						}
+					}
+					if (!found)
+						return;
+
+					if (renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE)
+						renamedChampionString = champ->_title;
+
+					strcpy(renamedChampionString = champ->_name, L0821_ac_ChampionNameBackupString);
+					curCharacterIndex = characterIndexBackup;
+				} else {
+					if ((mousePos.x >= 107) && (mousePos.x <= 175) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'BACKSPACE' button */
+						curCharacter = '\b';
+						break;
+					}
+#if 0
+					if ((mousePos.x < 107) || (mousePos.x > 215) || (mousePos.y < 116) || (mousePos.y > 144)) {/* Coordinates of table of all other characters */
+						//goto T0281023;
+					}
+					if (!((mousePos.x + 4) % 10) || (!((mousePos.y + 5) % 10) && ((mousePos.x < 207) || (mousePos.y != 135)))) {
+						//goto T0281023;
+					}
+#endif
+					curCharacter = 'A' + (11 * ((mousePos.y - 116) / 10)) + ((mousePos.x - 107) / 10);
+					if ((curCharacter == 86) || (curCharacter == 97)) {
+						// The 'Return' button occupies two cells in the table
+						curCharacter = '\r'; /* Carriage return */
+						break;
+					}
+
+					if (curCharacter >= 87)
+						// Compensate for the first cell occupied by 'Return' button
+						curCharacter--;
+
+					if (curCharacter > 'Z')
+						curCharacter = reincarnateSpecialCharacters[(curCharacter - 'Z') - 1];
+
+					break;
+				}
+			} else if (eventType == Common::EVENT_KEYDOWN)
+				curCharacter = event.kbd.ascii;
+		}
+
+		if ((curCharacter >= 'a') && (curCharacter <= 'z'))
+			curCharacter -= 32; // Convert to uppercase
+
+		if (((curCharacter >= 'A') && (curCharacter <= 'Z')) || (curCharacter == '.') || (curCharacter == ',') || (curCharacter == ';') || (curCharacter == ':') || (curCharacter == ' ')) {
+			if ((curCharacter != ' ') || curCharacterIndex != 0) {
+				if (!championTitleIsFull) {
+					renameChampionInputCharacterString[0] = curCharacter;
+					_vm->_eventMan->f78_showMouse();
+					_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, renameChampionInputCharacterString, k200_heightScreen);
+					_vm->_eventMan->f77_hideMouse();
+					renamedChampionString[curCharacterIndex++] = curCharacter;
+					renamedChampionString[curCharacterIndex] = '\0';
+					textPosX += 6;
+					if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex == 7)) {
+						renamedChampionStringMode = k2_RENAME_CHAMPION_TITLE;
+						renamedChampionString = champ->_title;
+						textPosX = 105;
+						textPosY = 109;
+						curCharacterIndex = 0;
+					}
+				}
+			}
+		} else if (curCharacter == '\r') { // Carriage return
+			if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex > 0)) {
+				_vm->_eventMan->f78_showMouse();
+				_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
+				_vm->_eventMan->f77_hideMouse();
+				renamedChampionStringMode = k2_RENAME_CHAMPION_TITLE;
+				renamedChampionString = champ->_title;
+				textPosX = 105;
+				textPosY = 109;
+				curCharacterIndex = 0;
+			}
+		} else if (curCharacter == '\b') { // Backspace
+			if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex == 0))
+				continue;
+
+			if (!championTitleIsFull) {
+				_vm->_eventMan->f78_showMouse();
+				_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
+				_vm->_eventMan->f77_hideMouse();
+			}
+			if (curCharacterIndex == 0) {
+				renamedChampionString = champ->_name;
+				curCharacterIndex = strlen(renamedChampionString) - 1;
+				renamedChampionStringMode = k1_RENAME_CHAMPION_NAME;
+				textPosX = 177 + (curCharacterIndex * 6);
+				textPosY = 91;
+			} else {
+				curCharacterIndex--;
+				textPosX -= 6;
+			}
+			renamedChampionString[curCharacterIndex] = '\0';
+		}
+	}
+}
+
+uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, uint16 skillIndex) {
+	if (_g300_partyIsSleeping)
+		return 1;
+
+	bool ignoreTmpExp = getFlag(skillIndex, k0x8000_IgnoreTemporaryExperience);
+	bool ignoreObjModifiers = getFlag(skillIndex, k0x4000_IgnoreObjectModifiers);
+	clearFlag(skillIndex, k0x8000_IgnoreTemporaryExperience | k0x4000_IgnoreObjectModifiers);
+	Champion *champ = &_gK71_champions[champIndex];
+	Skill *skill = &champ->_skills[skillIndex];
+	int32 exp = skill->_experience;
+	if (!ignoreTmpExp)
+		exp += skill->_temporaryExperience;
+
+	if (skillIndex > k3_ChampionSkillWizard) {
+		// Hidden skill
+		skill = &champ->_skills[(skillIndex - k4_ChampionSkillSwing) >> 2];
+		exp += skill->_experience; // Add experience in the base skill
+		if (!ignoreTmpExp)
+			exp += skill->_temporaryExperience;
+
+		exp >>= 1; // Halve experience to get average of base skill + hidden skill experience
+	}
+	int16 skillLevel = 1;
+	while (exp >= 500) {
+		exp >>= 1;
+		skillLevel++;
+	}
+	if (!ignoreObjModifiers) {
+		int16 actionHandIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
+		if (actionHandIconIndex == k27_IconIndiceWeaponTheFirestaff)
+			skillLevel++;
+		else if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete)
+			skillLevel += 2;
+
+		int16 neckIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k10_ChampionSlotNeck]);
+		switch (skillIndex) {
+		case k3_ChampionSkillWizard:
+			if (neckIconIndex == k124_IconIndiceJunkPendantFeral)
+				skillLevel += 1;
+			break;
+		case k13_ChampionSkillHeal:
+			// The skill modifiers of these two objects are not cumulative
+			if ((neckIconIndex == k120_IconIndiceJunkGemOfAges) || (actionHandIconIndex == k66_IconIndiceWeaponSceptreOfLyf))
+				skillLevel += 1;
+			break;
+		case k14_ChampionSkillInfluence:
+			if (neckIconIndex == k122_IconIndiceJunkMoonstone)
+				skillLevel += 1;
+			break;
+		case k15_ChampionSkillDefend:
+			if (neckIconIndex == k121_IconIndiceJunkEkkhardCross)
+				skillLevel += 1;
+			break;
+		default:
+			break;
+		}
+	}
+	return skillLevel;
+}
+
+}
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 04ab769..a94bdcc 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -513,6 +513,7 @@ class ChampionMan {
 	int16 _g410_championPendingWounds[4]; // @ G0410_ai_ChampionPendingWounds
 	int16 _g409_championPendingDamage[4]; // @ G0409_ai_ChampionPendingDamage
 public:
+
 	Champion _gK71_champions[4]; // @ K0071_as_Champions
 	uint16 _g305_partyChampionCount;	// @ G0305_ui_PartyChampionCount
 	bool _g303_partyDead; // @ G0303_B_PartyDead
diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index e261850..a160066 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -30,6 +30,44 @@
 
 namespace DM {
 
-Console::Console(DM::DMEngine* vm) : _vm(vm) {}
+Console::Console(DM::DMEngine* vm) : _vm(vm) {
+	_debugGodmodeMana = false;
+	_debugGodmodeHP = false;
+	_debugGodmodeStamina = false;
 
-}
\ No newline at end of file
+	registerCmd("godmode", WRAP_METHOD(Console, Cmd_godmode));
+}
+
+bool Console::Cmd_godmode(int argc, const char** argv) {
+	if (argc < 3)
+		goto argumentError;
+
+	bool setFlagTo;
+
+	if (strcmp("on", argv[2]) == 0) {
+		setFlagTo = true;
+	} else if (strcmp("off", argv[2]) == 0) {
+		setFlagTo = false;
+	} else
+		goto argumentError;
+
+	if (strcmp("all", argv[1]) == 0) {
+		_debugGodmodeHP = _debugGodmodeMana = _debugGodmodeStamina = setFlagTo;
+	} else if (strcmp("mana", argv[1]) == 0) {
+		_debugGodmodeMana = setFlagTo;
+	} else if (strcmp("hp", argv[1]) == 0) {
+		_debugGodmodeHP = setFlagTo;
+	} else if (strcmp("stamina", argv[1]) == 0) {
+		_debugGodmodeStamina = setFlagTo;
+	} else
+		goto argumentError;
+
+	debugPrintf("God mode set for %s to %s\n", argv[1], argv[2]);
+	return true;
+
+argumentError:
+	debugPrintf("Usage: %s <all/mana/hp/stamina> <on/off>\n", argv[0]);
+	return true;
+}
+
+}
diff --git a/engines/dm/console.h b/engines/dm/console.h
index eab2a32..0bfcfce 100644
--- a/engines/dm/console.h
+++ b/engines/dm/console.h
@@ -36,7 +36,12 @@ class DMEngine;
 class Console : public GUI::Debugger {
 	DMEngine *_vm;
 public:
+	bool _debugGodmodeMana;
+	bool _debugGodmodeHP;
+	bool _debugGodmodeStamina;
+
 	explicit Console(DM::DMEngine *vm);
 	virtual ~Console(void) {}
+	bool Cmd_godmode(int argc, const char **argv);
 };
 }
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 2f52b07..8cd5771 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -367,8 +367,21 @@ void DMEngine::f2_gameloop() {
 	while (true) {
 		if (_engineShouldQuit)
 			return;
+		
+		// DEBUG CODE
+		for (int16 i = 0; i < _championMan->_g305_partyChampionCount; ++i) {
+			Champion &champ = _championMan->_gK71_champions[i];
+			if (_console->_debugGodmodeHP)
+				champ._currHealth = champ._maxHealth;
+			if (_console->_debugGodmodeMana)
+				champ._currMana = champ._maxMana;
+			if (_console->_debugGodmodeStamina)
+				champ._currStamina = champ._maxStamina;
+		}
 
 		for (;;) {
+			
+
 			if (_g327_newPartyMapIndex != kM1_mapIndexNone) {
 				f3_processNewPartyMap(_g327_newPartyMapIndex);
 				_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);


Commit: 1c3c33c76d5390a62fd34d18a31fc3604b298e05
    https://github.com/scummvm/scummvm/commit/1c3c33c76d5390a62fd34d18a31fc3604b298e05
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add noclip debug command

Changed paths:
    engines/dm/console.cpp
    engines/dm/console.h
    engines/dm/eventman.cpp



diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index a160066..d9bd8e2 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -30,34 +30,39 @@
 
 namespace DM {
 
+bool cstrEquals(const char* a, const char *b) { return strcmp(a, b) == 0; }
+
 Console::Console(DM::DMEngine* vm) : _vm(vm) {
 	_debugGodmodeMana = false;
 	_debugGodmodeHP = false;
 	_debugGodmodeStamina = false;
 
+	_debugNoclip = false;
+
 	registerCmd("godmode", WRAP_METHOD(Console, Cmd_godmode));
+	registerCmd("noclip", WRAP_METHOD(Console, Cmd_noclip));
 }
 
 bool Console::Cmd_godmode(int argc, const char** argv) {
-	if (argc < 3)
+	if (argc != 3)
 		goto argumentError;
 
 	bool setFlagTo;
 
-	if (strcmp("on", argv[2]) == 0) {
+	if (cstrEquals("on", argv[2])) {
 		setFlagTo = true;
-	} else if (strcmp("off", argv[2]) == 0) {
+	} else if (cstrEquals("off", argv[2])) {
 		setFlagTo = false;
 	} else
 		goto argumentError;
 
-	if (strcmp("all", argv[1]) == 0) {
+	if (cstrEquals("all", argv[1])) {
 		_debugGodmodeHP = _debugGodmodeMana = _debugGodmodeStamina = setFlagTo;
-	} else if (strcmp("mana", argv[1]) == 0) {
+	} else if (cstrEquals("mana", argv[1])) {
 		_debugGodmodeMana = setFlagTo;
-	} else if (strcmp("hp", argv[1]) == 0) {
+	} else if (cstrEquals("hp", argv[1])) {
 		_debugGodmodeHP = setFlagTo;
-	} else if (strcmp("stamina", argv[1]) == 0) {
+	} else if (cstrEquals("stamina", argv[1])) {
 		_debugGodmodeStamina = setFlagTo;
 	} else
 		goto argumentError;
@@ -70,4 +75,27 @@ argumentError:
 	return true;
 }
 
+bool Console::Cmd_noclip(int argc, const char** argv) {
+	if (argc != 2)
+		goto argumentError;
+
+	if (cstrEquals("on", argv[1])) {
+		_debugNoclip = true;
+		static bool warnedForNoclip = false;
+		if (!warnedForNoclip) {
+			debugPrintf("Noclip can cause unexpected glitches and crashes.\n");
+			warnedForNoclip = true;
+		}
+	} else if (cstrEquals("off", argv[1])) {
+		_debugNoclip = false;
+	} else
+		goto argumentError;
+
+	debugPrintf("Noclip set to %s\n", argv[1]);
+	return true;
+
+argumentError:
+	debugPrintf("Usage: %s <on/off>\n", argv[0]);
+	return true;
+}
 }
diff --git a/engines/dm/console.h b/engines/dm/console.h
index 0bfcfce..96fb677 100644
--- a/engines/dm/console.h
+++ b/engines/dm/console.h
@@ -35,13 +35,20 @@ class DMEngine;
 
 class Console : public GUI::Debugger {
 	DMEngine *_vm;
+
 public:
+	explicit Console(DM::DMEngine *vm);
+	virtual ~Console(void) {}
+
+	// Cmd_godmode
 	bool _debugGodmodeMana;
 	bool _debugGodmodeHP;
 	bool _debugGodmodeStamina;
-
-	explicit Console(DM::DMEngine *vm);
-	virtual ~Console(void) {}
 	bool Cmd_godmode(int argc, const char **argv);
+
+	// Cmd_noclip
+	bool _debugNoclip;
+	bool Cmd_noclip(int argc, const char **argv);
+
 };
 }
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index af875a9..e0ac2c4 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -918,7 +918,8 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 			}
 		}
 	}
-	if (L1117_B_MovementBlocked) {
+	// DEBUG CODE: check for Console flag
+	if (L1117_B_MovementBlocked && !_vm->_console->_debugNoclip) {
 		f357_discardAllInput();
 		_vm->_g321_stopWaitingForPlayerInput = false;
 		return;


Commit: 172477b1153b08ac776bc2ff6d7d82eac87150a0
    https://github.com/scummvm/scummvm/commit/172477b1153b08ac776bc2ff6d7d82eac87150a0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rename engine debug command so they are listed first

Changed paths:
    engines/dm/console.cpp



diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index d9bd8e2..46a654b 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -39,8 +39,8 @@ Console::Console(DM::DMEngine* vm) : _vm(vm) {
 
 	_debugNoclip = false;
 
-	registerCmd("godmode", WRAP_METHOD(Console, Cmd_godmode));
-	registerCmd("noclip", WRAP_METHOD(Console, Cmd_noclip));
+	registerCmd(".godmode", WRAP_METHOD(Console, Cmd_godmode));
+	registerCmd(".noclip", WRAP_METHOD(Console, Cmd_noclip));
 }
 
 bool Console::Cmd_godmode(int argc, const char** argv) {


Commit: c380ccf3f324f1266f894c29c38d9e188488e119
    https://github.com/scummvm/scummvm/commit/c380ccf3f324f1266f894c29c38d9e188488e119
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add SingleUseFlag to console.cpp

Changed paths:
    engines/dm/console.cpp



diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index 46a654b..7bafc3c 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -32,6 +32,17 @@ namespace DM {
 
 bool cstrEquals(const char* a, const char *b) { return strcmp(a, b) == 0; }
 
+class SingleUseFlag {
+	bool _flag;
+public:
+	SingleUseFlag(): _flag(true) {}
+	bool check() {
+		bool currFlagState = _flag;
+		_flag = false;
+		return currFlagState;
+	}
+};
+
 Console::Console(DM::DMEngine* vm) : _vm(vm) {
 	_debugGodmodeMana = false;
 	_debugGodmodeHP = false;
@@ -81,11 +92,9 @@ bool Console::Cmd_noclip(int argc, const char** argv) {
 
 	if (cstrEquals("on", argv[1])) {
 		_debugNoclip = true;
-		static bool warnedForNoclip = false;
-		if (!warnedForNoclip) {
+		static SingleUseFlag warnedForNoclip;
+		if (warnedForNoclip.check())
 			debugPrintf("Noclip can cause unexpected glitches and crashes.\n");
-			warnedForNoclip = true;
-		}
 	} else if (cstrEquals("off", argv[1])) {
 		_debugNoclip = false;
 	} else
@@ -98,4 +107,6 @@ argumentError:
 	debugPrintf("Usage: %s <on/off>\n", argv[0]);
 	return true;
 }
+
+
 }


Commit: 9e3e58a7227a162f461da8ef8a2ab80b95fbb11a
    https://github.com/scummvm/scummvm/commit/9e3e58a7227a162f461da8ef8a2ab80b95fbb11a
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing include guard to console.h

Changed paths:
    engines/dm/console.h



diff --git a/engines/dm/console.h b/engines/dm/console.h
index 96fb677..8ee4857 100644
--- a/engines/dm/console.h
+++ b/engines/dm/console.h
@@ -27,7 +27,8 @@
 
 #include "gui/debugger.h"
 
-
+#ifndef DM_CONSOLE_H
+#define DM_CONSOLE_H
 
 namespace DM {
 
@@ -52,3 +53,5 @@ public:
 
 };
 }
+
+#endif


Commit: 9b772cfb75de39a6800e8016bdccde60ae2246d7
    https://github.com/scummvm/scummvm/commit/9b772cfb75de39a6800e8016bdccde60ae2246d7
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix possibly dangerous cast in eventman.cpp, moveParty

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index e0ac2c4..319156f 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -933,8 +933,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	L1119_ps_Champion = _vm->_championMan->_gK71_champions;
 	for (AL1118_ui_ChampionIndex = k0_ChampionFirst; AL1118_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL1118_ui_ChampionIndex++) {
 		if (L1119_ps_Champion->_currHealth) {
-			warning(false, "possibly dangerous cast to uint16");
-			AL1115_ui_Ticks = MAX(AL1115_ui_Ticks, (uint16)_vm->_championMan->f310_getMovementTicks(L1119_ps_Champion));
+			AL1115_ui_Ticks = MAX((int32)AL1115_ui_Ticks, (int32)_vm->_championMan->f310_getMovementTicks(L1119_ps_Champion));
 		}
 		L1119_ps_Champion++;
 	}


Commit: 0eea48a59b83861f3b488ab7d5beae71c620bccc
    https://github.com/scummvm/scummvm/commit/0eea48a59b83861f3b488ab7d5beae71c620bccc
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing return in processInput with ctrl+d

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 319156f..534b5db 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -533,6 +533,7 @@ Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Eve
 
 			if (event.kbd.keycode == Common::KEYCODE_d && event.kbd.hasFlags(Common::KBD_CTRL)) {
 				_vm->_console->attach();
+				return Common::EVENT_INVALID;
 			}
 
 			if (grabKey) {


Commit: a5c0a324462b9f149eea3ef78589999d193de71e
    https://github.com/scummvm/scummvm/commit/a5c0a324462b9f149eea3ef78589999d193de71e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add debug command .pos

Changed paths:
    engines/dm/console.cpp
    engines/dm/console.h
    engines/dm/dm.cpp
    engines/dm/dm.h



diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index 7bafc3c..afc6b80 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -26,6 +26,10 @@
 */
 
 #include "console.h"
+#include "dm.h"
+#include "champion.h"
+#include "dungeonman.h"
+#include "movesens.h"
 
 
 namespace DM {
@@ -35,7 +39,7 @@ bool cstrEquals(const char* a, const char *b) { return strcmp(a, b) == 0; }
 class SingleUseFlag {
 	bool _flag;
 public:
-	SingleUseFlag(): _flag(true) {}
+	SingleUseFlag() : _flag(true) {}
 	bool check() {
 		bool currFlagState = _flag;
 		_flag = false;
@@ -52,6 +56,7 @@ Console::Console(DM::DMEngine* vm) : _vm(vm) {
 
 	registerCmd(".godmode", WRAP_METHOD(Console, Cmd_godmode));
 	registerCmd(".noclip", WRAP_METHOD(Console, Cmd_noclip));
+	registerCmd(".pos", WRAP_METHOD(Console, Cmd_pos));
 }
 
 bool Console::Cmd_godmode(int argc, const char** argv) {
@@ -94,7 +99,7 @@ bool Console::Cmd_noclip(int argc, const char** argv) {
 		_debugNoclip = true;
 		static SingleUseFlag warnedForNoclip;
 		if (warnedForNoclip.check())
-			debugPrintf("Noclip can cause unexpected glitches and crashes.\n");
+			debugPrintf("Noclip can cause glitches and crashes.\n");
 	} else if (cstrEquals("off", argv[1])) {
 		_debugNoclip = false;
 	} else
@@ -108,5 +113,38 @@ argumentError:
 	return true;
 }
 
+bool Console::Cmd_pos(int argc, const char** argv) {
+	if (argc == 2 && cstrEquals("get", argv[1])) {
+		debugPrintf("Position: (%d, %d)  Direction: %s\n", _vm->_dungeonMan->_g306_partyMapX, 
+					_vm->_dungeonMan->_g307_partyMapY, debugGetDirectionName(_vm->_dungeonMan->_g308_partyDir));
+	} else if (argc == 4 && cstrEquals("set", argv[1])) {
+		int x = atoi(argv[2]);
+		int y = atoi(argv[3]);
+		if (x == 0 || y == 0) {
+			debugPrintf("Error, supply two non-null numbers to '%s set' command\n", argv[0]);
+			return true;
+		}
+
+		Map &currMap = *_vm->_dungeonMan->_g269_currMap;
+		// not >= because dimensions are inslucsive
+		if (x > currMap._width || y > currMap._height) {
+			debugPrintf("Position (%d, %d) is out of bounds, possible values: ([1-%d],[1-%d])\n", x, y,
+						currMap._width, currMap._height);
+			return true;
+		}
+
+		static SingleUseFlag warnForSettingPos;
+		if (warnForSettingPos.check())
+			debugPrintf("Setting position directly can cause glitches and crashes.\n");
+		debugPrintf("Position set to (%d, %d)\n", x, y);
+		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, x, y);
+	} else
+		goto argumentError;
+
+	return true;
 
+argumentError:
+	debugPrintf("Usage: %s get\nUsage: %s set <#> <#>\n", argv[0], argv[0]);
+	return true;
+}
 }
diff --git a/engines/dm/console.h b/engines/dm/console.h
index 8ee4857..a11d334 100644
--- a/engines/dm/console.h
+++ b/engines/dm/console.h
@@ -51,6 +51,9 @@ public:
 	bool _debugNoclip;
 	bool Cmd_noclip(int argc, const char **argv);
 
+	// Cmd_pos
+	bool Cmd_pos(int argc, const char **argv);
+
 };
 }
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 8cd5771..f4ab7f4 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -76,6 +76,13 @@ void warning(bool repeat, const char* s, ...) {
 	}
 }
 
+const char* debugGetDirectionName(Direction dir) {
+	static const char* directionNames[] = {"North", "East", "South", "West"};
+	if (dir < 0 || dir > 3)
+		return "Invalid direction";
+	return directionNames[dir];
+}
+
 void turnDirRight(Direction &dir) {
 	dir = (Direction)((dir + 1) & 3);
 }
@@ -367,7 +374,7 @@ void DMEngine::f2_gameloop() {
 	while (true) {
 		if (_engineShouldQuit)
 			return;
-		
+
 		// DEBUG CODE
 		for (int16 i = 0; i < _championMan->_g305_partyChampionCount; ++i) {
 			Champion &champ = _championMan->_gK71_champions[i];
@@ -380,7 +387,7 @@ void DMEngine::f2_gameloop() {
 		}
 
 		for (;;) {
-			
+
 
 			if (_g327_newPartyMapIndex != kM1_mapIndexNone) {
 				f3_processNewPartyMap(_g327_newPartyMapIndex);
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index ae16e13..08fb3c5 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -63,6 +63,7 @@ enum Direction {
 	kDirSouth = 2,
 	kDirWest = 3
 };
+const char *debugGetDirectionName(Direction dir);
 
 
 


Commit: 56f5af7592283dd63392942a4bd05253be2ed5c4
    https://github.com/scummvm/scummvm/commit/56f5af7592283dd63392942a4bd05253be2ed5c4
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add debug command .map

Changed paths:
    engines/dm/console.cpp
    engines/dm/console.h



diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index afc6b80..24c3f67 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -57,6 +57,7 @@ Console::Console(DM::DMEngine* vm) : _vm(vm) {
 	registerCmd(".godmode", WRAP_METHOD(Console, Cmd_godmode));
 	registerCmd(".noclip", WRAP_METHOD(Console, Cmd_noclip));
 	registerCmd(".pos", WRAP_METHOD(Console, Cmd_pos));
+	registerCmd(".map", WRAP_METHOD(Console, Cmd_map));
 }
 
 bool Console::Cmd_godmode(int argc, const char** argv) {
@@ -97,8 +98,8 @@ bool Console::Cmd_noclip(int argc, const char** argv) {
 
 	if (cstrEquals("on", argv[1])) {
 		_debugNoclip = true;
-		static SingleUseFlag warnedForNoclip;
-		if (warnedForNoclip.check())
+		static SingleUseFlag haventWarned;
+		if (haventWarned.check())
 			debugPrintf("Noclip can cause glitches and crashes.\n");
 	} else if (cstrEquals("off", argv[1])) {
 		_debugNoclip = false;
@@ -115,13 +116,13 @@ argumentError:
 
 bool Console::Cmd_pos(int argc, const char** argv) {
 	if (argc == 2 && cstrEquals("get", argv[1])) {
-		debugPrintf("Position: (%d, %d)  Direction: %s\n", _vm->_dungeonMan->_g306_partyMapX, 
+		debugPrintf("Position: (%d, %d)  Direction: %s\n", _vm->_dungeonMan->_g306_partyMapX,
 					_vm->_dungeonMan->_g307_partyMapY, debugGetDirectionName(_vm->_dungeonMan->_g308_partyDir));
 	} else if (argc == 4 && cstrEquals("set", argv[1])) {
 		int x = atoi(argv[2]);
 		int y = atoi(argv[3]);
-		if (x == 0 || y == 0) {
-			debugPrintf("Error, supply two non-null numbers to '%s set' command\n", argv[0]);
+		if ((x == 0 && !cstrEquals("0", argv[2])) || (y == 0 && !cstrEquals("0", argv[3]))) {
+			debugPrintf("Error, supply two numbers to '%s set' command\n", argv[0]);
 			return true;
 		}
 
@@ -133,8 +134,8 @@ bool Console::Cmd_pos(int argc, const char** argv) {
 			return true;
 		}
 
-		static SingleUseFlag warnForSettingPos;
-		if (warnForSettingPos.check())
+		static SingleUseFlag haventWarned;
+		if (haventWarned.check())
 			debugPrintf("Setting position directly can cause glitches and crashes.\n");
 		debugPrintf("Position set to (%d, %d)\n", x, y);
 		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, x, y);
@@ -147,4 +148,44 @@ argumentError:
 	debugPrintf("Usage: %s get\nUsage: %s set <#> <#>\n", argv[0], argv[0]);
 	return true;
 }
+
+bool Console::Cmd_map(int argc, const char** argv) {
+	if (argc == 2 && cstrEquals("get", argv[1])) {
+		debugPrintf("Map index: %d\n", _vm->_dungeonMan->_g309_partyMapIndex);
+	} else if (argc == 3 && cstrEquals("set", argv[1])) {
+		int index = atoi(argv[2]);
+		if (index == 0 && !cstrEquals("0", argv[2])) {
+			debugPrintf("Error, supply a number to '%s set' command\n", argv[0]);
+			return true;
+		}
+
+		// not >= because dimensions are inslucsive
+		if (index < 0 || index >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount) {
+			debugPrintf("Map index %d is out of bounds, possible values [0, %d]\n", _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount - 1);
+			return true;
+		}
+
+		static SingleUseFlag haventWarned;
+		if (haventWarned.check())
+			debugPrintf("Setting map directly can cause glitches and crashes.\n");
+		debugPrintf("Map set to %d\n", index);
+
+		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0);
+		_vm->_g327_newPartyMapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(
+			_vm->_dungeonMan->_g309_partyMapIndex, index - _vm->_dungeonMan->_g309_partyMapIndex,
+			&_vm->_dungeonMan->_g306_partyMapX, &_vm->_dungeonMan->_g307_partyMapY);
+		if (_vm->_g327_newPartyMapIndex == -1)
+			_vm->_g327_newPartyMapIndex = index;
+		_vm->_dungeonMan->f173_setCurrentMap(_vm->_g327_newPartyMapIndex);
+		_vm->_championMan->f284_setPartyDirection(_vm->_dungeonMan->f155_getStairsExitDirection(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY));
+		_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
+	} else
+		goto argumentError;
+
+	return true;
+
+argumentError:
+	debugPrintf("Usage: %s get\nUsage: %s set <#>\n", argv[0], argv[0]);
+	return true;
+}
 }
diff --git a/engines/dm/console.h b/engines/dm/console.h
index a11d334..9493b35 100644
--- a/engines/dm/console.h
+++ b/engines/dm/console.h
@@ -54,6 +54,8 @@ public:
 	// Cmd_pos
 	bool Cmd_pos(int argc, const char **argv);
 
+	// Cmd_map
+	bool Cmd_map(int argc, const char **argv);
 };
 }
 


Commit: 5955b8d9ca3a6daa05945a7c93517f0ece7b8afe
    https://github.com/scummvm/scummvm/commit/5955b8d9ca3a6daa05945a7c93517f0ece7b8afe
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rename engine debug commands

Changed paths:
    engines/dm/console.cpp



diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index 24c3f67..703bd23 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -54,10 +54,10 @@ Console::Console(DM::DMEngine* vm) : _vm(vm) {
 
 	_debugNoclip = false;
 
-	registerCmd(".godmode", WRAP_METHOD(Console, Cmd_godmode));
-	registerCmd(".noclip", WRAP_METHOD(Console, Cmd_noclip));
-	registerCmd(".pos", WRAP_METHOD(Console, Cmd_pos));
-	registerCmd(".map", WRAP_METHOD(Console, Cmd_map));
+	registerCmd("godmode", WRAP_METHOD(Console, Cmd_godmode));
+	registerCmd("noclip", WRAP_METHOD(Console, Cmd_noclip));
+	registerCmd("pos", WRAP_METHOD(Console, Cmd_pos));
+	registerCmd("map", WRAP_METHOD(Console, Cmd_map));
 }
 
 bool Console::Cmd_godmode(int argc, const char** argv) {


Commit: 6279c566152203fd761cae9b7333f27320730261
    https://github.com/scummvm/scummvm/commit/6279c566152203fd761cae9b7333f27320730261
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add debug command 'items', add option 'list'

Changed paths:
    engines/dm/console.cpp
    engines/dm/console.h
    engines/dm/objectman.h



diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index 703bd23..1145165 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -30,6 +30,7 @@
 #include "champion.h"
 #include "dungeonman.h"
 #include "movesens.h"
+#include "objectman.h"
 
 
 namespace DM {
@@ -58,6 +59,7 @@ Console::Console(DM::DMEngine* vm) : _vm(vm) {
 	registerCmd("noclip", WRAP_METHOD(Console, Cmd_noclip));
 	registerCmd("pos", WRAP_METHOD(Console, Cmd_pos));
 	registerCmd("map", WRAP_METHOD(Console, Cmd_map));
+	registerCmd("items", WRAP_METHOD(Console, Cmd_items));
 }
 
 bool Console::Cmd_godmode(int argc, const char** argv) {
@@ -188,4 +190,24 @@ argumentError:
 	debugPrintf("Usage: %s get\nUsage: %s set <#>\n", argv[0], argv[0]);
 	return true;
 }
+
+bool Console::Cmd_items(int argc, const char** argv) {
+	if (argc == 2 && cstrEquals("list", argv[1])) {
+		debugPrintf("| %s", _vm->_objectMan->_g352_objectNames[0]);
+		for (uint16 i = 1; i < k199_ObjectNameCount; ++i) {
+			const char *name = _vm->_objectMan->_g352_objectNames[i - 1];
+			const char *prevName = _vm->_objectMan->_g352_objectNames[i];
+			if (!cstrEquals(prevName, name))
+				debugPrintf(" | %s", name);
+			if (i % 5 == 0)
+				debugPrintf("\n");
+		}
+		debugPrintf("\n");
+	} else {
+		debugPrintf("Usage: %s list\n", argv[0]);
+		return true;
+	}
+	return true;
+}
+
 }
diff --git a/engines/dm/console.h b/engines/dm/console.h
index 9493b35..461c89f 100644
--- a/engines/dm/console.h
+++ b/engines/dm/console.h
@@ -51,11 +51,9 @@ public:
 	bool _debugNoclip;
 	bool Cmd_noclip(int argc, const char **argv);
 
-	// Cmd_pos
 	bool Cmd_pos(int argc, const char **argv);
-
-	// Cmd_map
 	bool Cmd_map(int argc, const char **argv);
+	bool Cmd_items(int argc, const char **argv);
 };
 }
 
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index 3b55e19..1aa4c54 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -66,7 +66,6 @@ public:
 	IconIndice f39_getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox
 	void f35_clearLeaderObjectName(); // @ F0035_OBJECT_ClearLeaderHandObjectName
 	void f37_drawIconToScreen(int16 iconIndex, int16 posX, int16 posY); // @ F0037_OBJECT_DrawIconToScreen
-
 };
 
 }


Commit: 50453e02bf1dce8535888cc54babf9335af16077
    https://github.com/scummvm/scummvm/commit/50453e02bf1dce8535888cc54babf9335af16077
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add gimme debug command spawning items

Changed paths:
    engines/dm/console.cpp
    engines/dm/console.h
    engines/dm/dm.h



diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index 1145165..baffd02 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -59,7 +59,8 @@ Console::Console(DM::DMEngine* vm) : _vm(vm) {
 	registerCmd("noclip", WRAP_METHOD(Console, Cmd_noclip));
 	registerCmd("pos", WRAP_METHOD(Console, Cmd_pos));
 	registerCmd("map", WRAP_METHOD(Console, Cmd_map));
-	registerCmd("items", WRAP_METHOD(Console, Cmd_items));
+	registerCmd("listItems", WRAP_METHOD(Console, Cmd_listItems));
+	registerCmd("gimme", WRAP_METHOD(Console, Cmd_gimme));
 }
 
 bool Console::Cmd_godmode(int argc, const char** argv) {
@@ -147,7 +148,8 @@ bool Console::Cmd_pos(int argc, const char** argv) {
 	return true;
 
 argumentError:
-	debugPrintf("Usage: %s get\nUsage: %s set <#> <#>\n", argv[0], argv[0]);
+	debugPrintf("Usage: %s get\n", argv[0]);
+	debugPrintf("Usage: %s set <#> <#>\n", argv[0]);
 	return true;
 }
 
@@ -187,26 +189,65 @@ bool Console::Cmd_map(int argc, const char** argv) {
 	return true;
 
 argumentError:
-	debugPrintf("Usage: %s get\nUsage: %s set <#>\n", argv[0], argv[0]);
+	debugPrintf("Usage: %s get\n", argv[0]);
+	debugPrintf("Usage: %s set <#>\n", argv[0]);
 	return true;
 }
 
-bool Console::Cmd_items(int argc, const char** argv) {
-	if (argc == 2 && cstrEquals("list", argv[1])) {
-		debugPrintf("| %s", _vm->_objectMan->_g352_objectNames[0]);
-		for (uint16 i = 1; i < k199_ObjectNameCount; ++i) {
-			const char *name = _vm->_objectMan->_g352_objectNames[i - 1];
-			const char *prevName = _vm->_objectMan->_g352_objectNames[i];
-			if (!cstrEquals(prevName, name))
-				debugPrintf(" | %s", name);
-			if (i % 5 == 0)
-				debugPrintf("\n");
-		}
-		debugPrintf("\n");
-	} else {
-		debugPrintf("Usage: %s list\n", argv[0]);
+bool Console::Cmd_listItems(int argc, const char** argv) {
+	debugPrintf("| %s", _vm->_objectMan->_g352_objectNames[0]);
+	for (uint16 i = 1; i < k199_ObjectNameCount; ++i) {
+		const char *name = _vm->_objectMan->_g352_objectNames[i - 1];
+		const char *prevName = _vm->_objectMan->_g352_objectNames[i];
+		if (!cstrEquals(prevName, name))
+			debugPrintf(" | %s", name);
+		if (i % 5 == 0)
+			debugPrintf("\n");
+	}
+	debugPrintf("\n");
+
+	return true;
+}
+
+bool Console::Cmd_gimme(int argc, const char** argv) {
+	if (argc < 2) {
+		debugPrintf("Usage: gimme <item name>   // item name can have spaces\n");
 		return true;
 	}
+
+	Common::String requestedItemName;
+	for (int16 i = 1; i < argc; ++i)
+		requestedItemName += argv[i];
+
+	for (int16 thingType = 0; thingType < 16; ++thingType) { // 16 number of item types
+		uint16 *thingDataArray = _vm->_dungeonMan->_g284_thingData[thingType];
+		uint16 thingTypeSize = g235_ThingDataWordCount[thingType];
+		uint16 thingCount = _vm->_dungeonMan->_g278_dungeonFileHeader._thingCounts[thingType];
+
+		Thing dummyThing(0);
+		dummyThing.setType(thingType);
+		for (int16 thingIndex = 0; thingIndex < thingCount; ++thingIndex) {
+			dummyThing.setIndex(thingIndex);
+			int16 iconIndex = _vm->_objectMan->f33_getIconIndex(dummyThing);
+			if (iconIndex != -1) {
+				const char *displayName = _vm->_objectMan->_g352_objectNames[iconIndex];
+				if (cstrEquals(displayName, requestedItemName.c_str())) {
+					uint16 *newThingData = new uint16[(thingCount + 1) * thingTypeSize];
+					memcpy(newThingData, thingDataArray, sizeof(uint16) * thingTypeSize * thingCount);
+					delete[] thingDataArray;
+					for (uint16 i = 0; i < thingTypeSize; ++i)
+						newThingData[thingCount * thingTypeSize + i] = newThingData[thingIndex * thingTypeSize + i];
+					_vm->_dungeonMan->_g278_dungeonFileHeader._thingCounts[thingType]++;
+					_vm->_dungeonMan->_g284_thingData[thingType] = newThingData;
+					_vm->_championMan->f301_addObjectInSlot((ChampionIndex)0, dummyThing, (ChampionSlot)29);
+					debugPrintf("Item gimmed to the first champion, last slot\n");
+					return true;
+				}
+			}
+		}
+	}
+
+	debugPrintf("No item found with name '%s'\n", requestedItemName.c_str());
 	return true;
 }
 
diff --git a/engines/dm/console.h b/engines/dm/console.h
index 461c89f..11348ae 100644
--- a/engines/dm/console.h
+++ b/engines/dm/console.h
@@ -53,7 +53,8 @@ public:
 
 	bool Cmd_pos(int argc, const char **argv);
 	bool Cmd_map(int argc, const char **argv);
-	bool Cmd_items(int argc, const char **argv);
+	bool Cmd_listItems(int argc, const char **argv);
+	bool Cmd_gimme(int argc, const char **argv);
 };
 }
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 08fb3c5..25fabc7 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -116,6 +116,11 @@ public:
 	byte getCell() const { return _data >> 14; }
 	ThingType getType() const { return (ThingType)((_data >> 10) & 0xF); }
 	uint16 getIndex() const { return _data & 0x3FF; }
+
+	void setCell(uint16 cell) { _data = (_data & ~(0x3 << 14)) | ((cell & 0x3) << 14); }
+	void setType(uint16 type) { _data = (_data & ~(0xF << 10)) | ((type & 0xF) << 10); }
+	void setIndex(uint16 index) { _data = (_data & ~0x3FF) | (index & 0x3FF); }
+
 	uint16 getTypeAndIndex() { return _data & 0x3FFF; }
 	uint16 toUint16() const { return _data; } // I don't like 'em cast operators
 	bool operator==(const Thing &rhs) const { return _data == rhs._data; }


Commit: bf403cc6e33155140c37329abfbc2d2c28e4f473
    https://github.com/scummvm/scummvm/commit/bf403cc6e33155140c37329abfbc2d2c28e4f473
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Renaming in f380_processCommandQueue and f366_commandMoveParty

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 534b5db..0eae4e5 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -636,17 +636,11 @@ CommandType EventManager::f358_getCommandTypeFromMouseInput(MouseInput *input, C
 	return commandType;
 }
 
-
 void EventManager::f380_processCommandQueue() {
-	int16 AL1159_i_ChampionIndex;
-	CommandType cmdType;
-	int16 L1161_i_CommandX;
-	int16 L1162_i_CommandY;
-	static KeyboardInput* G0481_ps_PrimaryKeyboardInputBackup;
-	static KeyboardInput* G0482_ps_SecondaryKeyboardInputBackup;
-	static MouseInput* G0483_ps_PrimaryMouseInputBackup;
-	static MouseInput* G0484_ps_SecondaryMouseInputBackup;
-
+	static KeyboardInput *primaryKeyboardInputBackup;
+	static KeyboardInput *secondaryKeyboardInputBackup;
+	static MouseInput *primaryMouseInputBackup;
+	static MouseInput *secondaryMouseInputBackup;
 
 	_g435_isCommandQueueLocked = true;
 	if (_commandQueue.empty()) { /* If the command queue is empty */
@@ -656,90 +650,104 @@ void EventManager::f380_processCommandQueue() {
 	}
 
 	Command cmd = _commandQueue.pop();
-	cmdType = cmd._type;
+	CommandType cmdType = cmd._type;
 	if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft) && (_vm->_g310_disabledMovementTicks || (_vm->_g311_projectileDisableMovementTicks && (_vm->_g312_lastProjectileDisabledMovementDirection == (M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + cmdType - k3_CommandMoveForward)))))) { /* If movement is disabled */
 		_g435_isCommandQueueLocked = false;
 		f360_processPendingClick();
 		return;
 	}
-	L1161_i_CommandX = cmd._pos.x;
-	L1162_i_CommandY = cmd._pos.y;
+
+	int16 commandX = cmd._pos.x;
+	int16 commandY = cmd._pos.y;
 	_g435_isCommandQueueLocked = false;
 	f360_processPendingClick();
 	if ((cmdType == k2_CommandTurnRight) || (cmdType == k1_CommandTurnLeft)) {
 		f365_commandTurnParty(cmdType);
 		return;
 	}
+
 	if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft)) {
 		f366_commandMoveParty(cmdType);
 		return;
 	}
+
 	if ((cmdType >= k12_CommandClickInChampion_0_StatusBox) && (cmdType <= k15_CommandClickInChampion_3_StatusBox)) {
-		if (((AL1159_i_ChampionIndex = cmdType - k12_CommandClickInChampion_0_StatusBox) < _vm->_championMan->_g305_partyChampionCount) && !_vm->_championMan->_g299_candidateChampionOrdinal) {
-			f367_commandProcessTypes12to27_clickInChampionStatusBox(AL1159_i_ChampionIndex, L1161_i_CommandX, L1162_i_CommandY);
-		}
+		int16 championIdx = cmdType - k12_CommandClickInChampion_0_StatusBox;
+		if ((championIdx < _vm->_championMan->_g305_partyChampionCount) && !_vm->_championMan->_g299_candidateChampionOrdinal)
+			f367_commandProcessTypes12to27_clickInChampionStatusBox(championIdx, commandX, commandY);
+
 		return;
 	}
+
 	if ((cmdType >= k125_CommandClickOnChamptionIcon_Top_Left) && (cmdType <= k128_CommandClickOnChamptionIcon_Lower_Left)) {
 		f70_mouseProcessCommands125To128_clickOnChampionIcon(cmdType - k125_CommandClickOnChamptionIcon_Top_Left);
+
 		return;
 	}
+
 	if ((cmdType >= k28_CommandClickOnSlotBoxInventoryReadyHand) && (cmdType < (k65_CommandClickOnSlotBoxChest_8 + 1))) {
-		if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) {
+		if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone)
 			_vm->_championMan->f302_processCommands28to65_clickOnSlotBox(cmdType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
-		}
+
 		return;
 	}
+
 	if ((cmdType >= k7_CommandToggleInventoryChampion_0) && (cmdType <= k11_CommandCloseInventory)) {
-		if ((((AL1159_i_ChampionIndex = cmdType - k7_CommandToggleInventoryChampion_0) == k4_ChampionCloseInventory) || (AL1159_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount)) && !_vm->_championMan->_g299_candidateChampionOrdinal) {
-			_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)AL1159_i_ChampionIndex);
-		}
+		int16 championIndex = cmdType - k7_CommandToggleInventoryChampion_0;
+		if (((championIndex == k4_ChampionCloseInventory) || (championIndex < _vm->_championMan->_g305_partyChampionCount)) && !_vm->_championMan->_g299_candidateChampionOrdinal)
+			_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)championIndex);
+
 		return;
 	}
+
 	if (cmdType == k83_CommandToggleInventoryLeader) {
-		if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) {
+		if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone)
 			_vm->_inventoryMan->f355_toggleInventory(_vm->_championMan->_g411_leaderIndex);
-		}
+
 		return;
 	}
+
 	if (cmdType == k100_CommandClickInSpellArea) {
-		if ((!_vm->_championMan->_g299_candidateChampionOrdinal) && (_vm->_championMan->_g514_magicCasterChampionIndex != kM1_ChampionNone)) {
-			f370_commandProcessType100_clickInSpellArea(L1161_i_CommandX, L1162_i_CommandY);
-		}
+		if ((!_vm->_championMan->_g299_candidateChampionOrdinal) && (_vm->_championMan->_g514_magicCasterChampionIndex != kM1_ChampionNone))
+			f370_commandProcessType100_clickInSpellArea(commandX, commandY);
+
 		return;
 	}
+
 	if (cmdType == k111_CommandClickInActionArea) {
-		if (!_vm->_championMan->_g299_candidateChampionOrdinal) {
-			f371_commandProcessType111To115_ClickInActionArea(L1161_i_CommandX, L1162_i_CommandY);
-		}
+		if (!_vm->_championMan->_g299_candidateChampionOrdinal)
+			f371_commandProcessType111To115_ClickInActionArea(commandX, commandY);
+
 		return;
 	}
+
 	if (cmdType == k70_CommandClickOnMouth) {
 		_vm->_inventoryMan->f349_processCommand70_clickOnMouth();
 		return;
 	}
+
 	if (cmdType == k71_CommandClickOnEye) {
 		_vm->_inventoryMan->f352_processCommand71_clickOnEye();
 		return;
 	}
+
 	if (cmdType == k80_CommandClickInDungeonView) {
-		f377_commandProcessType80ClickInDungeonView(L1161_i_CommandX, L1162_i_CommandY);
+		f377_commandProcessType80ClickInDungeonView(commandX, commandY);
 		return;
 	}
 	if (cmdType == k81_CommandClickInPanel) {
-		f378_commandProcess81ClickInPanel(L1161_i_CommandX, L1162_i_CommandY);
+		f378_commandProcess81ClickInPanel(commandX, commandY);
 		return;
 	}
 
-	if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) {
+	if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth)
 		return;
-	}
 
 	if (cmdType == k145_CommandSleep) {
 		if (!_vm->_championMan->_g299_candidateChampionOrdinal) {
-			if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+			if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal)
 				_vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
-			}
+
 			_vm->_menuMan->f456_drawDisabledMenu();
 			_vm->_championMan->_g300_partyIsSleeping = true;
 			f379_drawSleepScreen();
@@ -753,16 +761,19 @@ void EventManager::f380_processCommandQueue() {
 		}
 		return;
 	}
+
 	if (cmdType == k146_CommandWakeUp) {
 		_vm->_championMan->f314_wakeUp();
 		return;
 	}
+
 	if (cmdType == k140_CommandSaveGame) {
-		if ((_vm->_championMan->_g305_partyChampionCount > 0) && !_vm->_championMan->_g299_candidateChampionOrdinal) {
+		if ((_vm->_championMan->_g305_partyChampionCount > 0) && !_vm->_championMan->_g299_candidateChampionOrdinal)
 			_vm->f433_processCommand140_saveGame(1, "Nice save:)");
-		}
+
 		return;
 	}
+
 	if (cmdType == k147_CommandFreezeGame) {
 		_vm->_g301_gameTimeTicking = false;
 		_vm->_menuMan->f456_drawDisabledMenu();
@@ -771,10 +782,10 @@ void EventManager::f380_processCommandQueue() {
 		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 81, 69, k4_ColorCyan, k0_ColorBlack,
 											 "GAME FROZEN", k136_heightViewport);
 		_vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
-		G0483_ps_PrimaryMouseInputBackup = _g441_primaryMouseInput;
-		G0484_ps_SecondaryMouseInputBackup = _g442_secondaryMouseInput;
-		G0481_ps_PrimaryKeyboardInputBackup = _g443_primaryKeyboardInput;
-		G0482_ps_SecondaryKeyboardInputBackup = _g444_secondaryKeyboardInput;
+		primaryMouseInputBackup = _g441_primaryMouseInput;
+		secondaryMouseInputBackup = _g442_secondaryMouseInput;
+		primaryKeyboardInputBackup = _g443_primaryKeyboardInput;
+		secondaryKeyboardInputBackup = _g444_secondaryKeyboardInput;
 		_g441_primaryMouseInput = g451_PrimaryMouseInput_FrozenGame;
 		_g442_secondaryMouseInput = 0;
 		_g443_primaryKeyboardInput = g461_primaryKeyboardInput_frozenGame;
@@ -782,73 +793,82 @@ void EventManager::f380_processCommandQueue() {
 		f357_discardAllInput();
 		return;
 	}
+
 	if (cmdType == k148_CommandUnfreezeGame) {
 		_vm->_g301_gameTimeTicking = true;
 		_vm->_menuMan->f457_drawEnabledMenus();
-		_g441_primaryMouseInput = G0483_ps_PrimaryMouseInputBackup;
-		_g442_secondaryMouseInput = G0484_ps_SecondaryMouseInputBackup;
-		_g443_primaryKeyboardInput = G0481_ps_PrimaryKeyboardInputBackup;
-		_g444_secondaryKeyboardInput = G0482_ps_SecondaryKeyboardInputBackup;
+		_g441_primaryMouseInput = primaryMouseInputBackup;
+		_g442_secondaryMouseInput = secondaryMouseInputBackup;
+		_g443_primaryKeyboardInput = primaryKeyboardInputBackup;
+		_g444_secondaryKeyboardInput = secondaryKeyboardInputBackup;
 		f357_discardAllInput();
 		return;
 	}
+
 	if (cmdType == k200_CommandEntranceEnterDungeon) {
 		_vm->_g298_newGame = k1_modeLoadDungeon;
 		return;
 	}
+
 	if (cmdType == k201_CommandEntranceResume) {
 		_vm->_g298_newGame = k0_modeLoadSavedGame;
 		return;
 	}
+
 	if (cmdType == k202_CommandEntranceDrawCredits) {
 		_vm->f442_SARTEND_processCommand202_entranceDrawCredits();
 		return;
 	}
+
 	if ((cmdType >= k210_CommandClickOnDialogChoice_1) && (cmdType <= k213_CommandClickOnDialogChoice_4)) {
 		_vm->_dialog->_g335_selectedDialogChoice = cmdType - (k210_CommandClickOnDialogChoice_1 - 1);
 		return;
 	}
-	if (cmdType == k215_CommandRestartGame) {
+
+	if (cmdType == k215_CommandRestartGame)
 		_vm->_g523_restartGameRequest = true;
-	}
 }
 
 void EventManager::f365_commandTurnParty(CommandType cmdType) {
-	uint16 L1114_ui_Square;
-
 	_vm->_g321_stopWaitingForPlayerInput = true;
-	if (cmdType == k1_CommandTurnLeft) {
+	if (cmdType == k1_CommandTurnLeft)
 		f362_commandHighlightBoxEnable(234, 261, 125, 145);
-	} else {
+	else
 		f362_commandHighlightBoxEnable(291, 318, 125, 145);
-	}
-	if (Square(L1114_ui_Square = _vm->_dungeonMan->f151_getSquare(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY).toByte()).getType() == k3_ElementTypeStairs) {
-		f364_commandTakeStairs(getFlag(L1114_ui_Square, k0x0004_StairsUp));
+
+	uint16 partySquare = _vm->_dungeonMan->f151_getSquare(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY).toByte();
+	if (Square(partySquare).getType() == k3_ElementTypeStairs) {
+		f364_commandTakeStairs(getFlag(partySquare, k0x0004_StairsUp));
 		return;
 	}
+
 	_vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, false);
 	_vm->_championMan->f284_setPartyDirection(M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + ((cmdType == k2_CommandTurnRight) ? 1 : 3)));
 	_vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, true);
 }
 
 void EventManager::f366_commandMoveParty(CommandType cmdType) {
-	static Box g463_BoxMovementArrows[4] = { // @ G0463_as_Graphic561_Box_MovementArrows
+	static Box boxMovementArrows[4] = { // @ G0463_as_Graphic561_Box_MovementArrows
 		/* { X1, X2, Y1, Y2 } */
 		Box(263, 289, 125, 145),   /* Forward */
 		Box(291, 318, 147, 167),   /* Right */
 		Box(263, 289, 147, 167),   /* Backward */
-		Box(234, 261, 147, 167)}; /* Left */
+		Box(234, 261, 147, 167)    /* Left */
+	};
 
-	static int16 g465_movementArrowToStepForwardCount[4] = { // @ G0465_ai_Graphic561_MovementArrowToStepForwardCount
+	static int16 movementArrowToStepForwardCount[4] = { // @ G0465_ai_Graphic561_MovementArrowToStepForwardCount
 		1,   /* Forward */
 		0,   /* Right */
 		-1,  /* Backward */
-		0}; /* Left */
-	static int16 g466_movementArrowToSepRightCount[4] = { // @ G0466_ai_Graphic561_MovementArrowToStepRightCount
+		0    /* Left */
+	};
+
+	static int16 movementArrowToSepRightCount[4] = { // @ G0466_ai_Graphic561_MovementArrowToStepRightCount
 		0,    /* Forward */
 		1,    /* Right */
 		0,    /* Backward */
-		-1}; /* Left */
+		-1    /* Left */
+	};
 
 	uint16 L1115_ui_Multiple;
 #define AL1115_ui_Square L1115_ui_Multiple
@@ -863,9 +883,6 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	int16 L1121_i_MapX;
 	int16 L1122_i_MapY;
 	bool L1123_B_StairsSquare;
-	int16 L1124_i_FirstDamagedChampionIndex;
-	int16 L1125_i_SecondDamagedChampionIndex;
-
 
 	_vm->_g321_stopWaitingForPlayerInput = true;
 	L1119_ps_Champion = _vm->_championMan->_gK71_champions;
@@ -874,14 +891,14 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 		L1119_ps_Champion++;
 	}
 	AL1118_ui_MovementArrowIndex = cmdType - k3_CommandMoveForward;
-	L1120_ps_Box = &g463_BoxMovementArrows[AL1118_ui_MovementArrowIndex];
+	L1120_ps_Box = &boxMovementArrows[AL1118_ui_MovementArrowIndex];
 	f362_commandHighlightBoxEnable(L1120_ps_Box->_x1, L1120_ps_Box->_x2, L1120_ps_Box->_y1, L1120_ps_Box->_y2);
 	L1123_B_StairsSquare = (Square(AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(L1121_i_MapX = _vm->_dungeonMan->_g306_partyMapX, L1122_i_MapY = _vm->_dungeonMan->_g307_partyMapY).toByte()).getType() == k3_ElementTypeStairs);
 	if (L1123_B_StairsSquare && (AL1118_ui_MovementArrowIndex == 2)) { /* If moving backward while in stairs */
 		f364_commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp));
 		return;
 	}
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(_vm->_dungeonMan->_g308_partyDir, g465_movementArrowToStepForwardCount[AL1118_ui_MovementArrowIndex], g466_movementArrowToSepRightCount[AL1118_ui_MovementArrowIndex], L1121_i_MapX, L1122_i_MapY);
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(_vm->_dungeonMan->_g308_partyDir, movementArrowToStepForwardCount[AL1118_ui_MovementArrowIndex], movementArrowToSepRightCount[AL1118_ui_MovementArrowIndex], L1121_i_MapX, L1122_i_MapY);
 	L1116_i_SquareType = Square(AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(L1121_i_MapX, L1122_i_MapY).toByte()).getType();
 	if (L1116_i_SquareType == k3_ElementTypeStairs) {
 		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0);
@@ -906,18 +923,17 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	if (_vm->_championMan->_g305_partyChampionCount == 0) {
 	} else {
 		if (L1117_B_MovementBlocked) {
-			L1117_B_MovementBlocked = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(L1121_i_MapX, L1122_i_MapY, M21_normalizeModulo4(AL1118_ui_MovementArrowIndex += (_vm->_dungeonMan->_g308_partyDir + 2))), 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
-			if (L1124_i_FirstDamagedChampionIndex != (L1125_i_SecondDamagedChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(L1121_i_MapX, L1122_i_MapY, returnNextVal(AL1118_ui_MovementArrowIndex)))) {
+			AL1118_ui_MovementArrowIndex += (_vm->_dungeonMan->_g308_partyDir + 2);
+			int16 L1124_i_FirstDamagedChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(L1121_i_MapX, L1122_i_MapY, M21_normalizeModulo4(AL1118_ui_MovementArrowIndex));
+			int16 L1125_i_SecondDamagedChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(L1121_i_MapX, L1122_i_MapY, returnNextVal(AL1118_ui_MovementArrowIndex));
+			L1117_B_MovementBlocked = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
+			if (L1124_i_FirstDamagedChampionIndex != L1125_i_SecondDamagedChampionIndex)
 				L1117_B_MovementBlocked |= _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
-			}
-			if (L1117_B_MovementBlocked) {
+
+			if (L1117_B_MovementBlocked)
 				_vm->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, L1121_i_MapX, L1122_i_MapY, k0_soundModePlayImmediately);
-			}
-		} else {
-			if (L1117_B_MovementBlocked = (_vm->_groupMan->f175_groupGetThing(L1121_i_MapX, L1122_i_MapY) != Thing::_endOfList)) {
-				_vm->_groupMan->f209_processEvents29to41(L1121_i_MapX, L1122_i_MapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
-			}
-		}
+		} else if (L1117_B_MovementBlocked = (_vm->_groupMan->f175_groupGetThing(L1121_i_MapX, L1122_i_MapY) != Thing::_endOfList))
+			_vm->_groupMan->f209_processEvents29to41(L1121_i_MapX, L1122_i_MapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
 	}
 	// DEBUG CODE: check for Console flag
 	if (L1117_B_MovementBlocked && !_vm->_console->_debugNoclip) {


Commit: ed9d1e4f3872fe6d0c1cf51019f0f42bab1e2bd5
    https://github.com/scummvm/scummvm/commit/ed9d1e4f3872fe6d0c1cf51019f0f42bab1e2bd5
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f366_commandMoveParty

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 0eae4e5..b7290d6 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -870,91 +870,78 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 		-1    /* Left */
 	};
 
-	uint16 L1115_ui_Multiple;
-#define AL1115_ui_Square L1115_ui_Multiple
-#define AL1115_ui_Ticks  L1115_ui_Multiple
-	int16 L1116_i_SquareType;
-	int16 L1117_B_MovementBlocked;
-	uint16 L1118_ui_Multiple;
-#define AL1118_ui_ChampionIndex      L1118_ui_Multiple
-#define AL1118_ui_MovementArrowIndex L1118_ui_Multiple
-	Champion* L1119_ps_Champion;
-	Box* L1120_ps_Box;
-	int16 L1121_i_MapX;
-	int16 L1122_i_MapY;
-	bool L1123_B_StairsSquare;
-
 	_vm->_g321_stopWaitingForPlayerInput = true;
-	L1119_ps_Champion = _vm->_championMan->_gK71_champions;
-	for (AL1118_ui_ChampionIndex = k0_ChampionFirst; AL1118_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL1118_ui_ChampionIndex++) {
-		_vm->_championMan->f325_decrementStamina(AL1118_ui_ChampionIndex, ((L1119_ps_Champion->_load * 3) / _vm->_championMan->f309_getMaximumLoad(L1119_ps_Champion)) + 1); /* BUG0_50 When a champion is brought back to life at a Vi Altar, his current stamina is lower than what it was before dying. Each time the party moves the current stamina of all champions is decreased, including for dead champions, by an amount that depends on the current load of the champion. For a dead champion the load before he died is used */
-		L1119_ps_Champion++;
-	}
-	AL1118_ui_MovementArrowIndex = cmdType - k3_CommandMoveForward;
-	L1120_ps_Box = &boxMovementArrows[AL1118_ui_MovementArrowIndex];
-	f362_commandHighlightBoxEnable(L1120_ps_Box->_x1, L1120_ps_Box->_x2, L1120_ps_Box->_y1, L1120_ps_Box->_y2);
-	L1123_B_StairsSquare = (Square(AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(L1121_i_MapX = _vm->_dungeonMan->_g306_partyMapX, L1122_i_MapY = _vm->_dungeonMan->_g307_partyMapY).toByte()).getType() == k3_ElementTypeStairs);
-	if (L1123_B_StairsSquare && (AL1118_ui_MovementArrowIndex == 2)) { /* If moving backward while in stairs */
+	Champion *championsPtr = _vm->_championMan->_gK71_champions;
+	for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_g305_partyChampionCount; idx++) {
+		_vm->_championMan->f325_decrementStamina(idx, ((championsPtr->_load * 3) / _vm->_championMan->f309_getMaximumLoad(championsPtr)) + 1); /* BUG0_50 When a champion is brought back to life at a Vi Altar, his current stamina is lower than what it was before dying. Each time the party moves the current stamina of all champions is decreased, including for dead champions, by an amount that depends on the current load of the champion. For a dead champion the load before he died is used */
+		championsPtr++;
+	}
+	uint16 movementArrowIdx = cmdType - k3_CommandMoveForward;
+	Box *highlightBox = &boxMovementArrows[movementArrowIdx];
+	f362_commandHighlightBoxEnable(highlightBox->_x1, highlightBox->_x2, highlightBox->_y1, highlightBox->_y2);
+	int16 partyMapX = _vm->_dungeonMan->_g306_partyMapX;
+	int16 partyMapY = _vm->_dungeonMan->_g307_partyMapY;
+	uint16 AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(partyMapX, partyMapY).toByte();
+	bool isStairsSquare = (Square(AL1115_ui_Square).getType() == k3_ElementTypeStairs);
+	if (isStairsSquare && (movementArrowIdx == 2)) { /* If moving backward while in stairs */
 		f364_commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp));
 		return;
 	}
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(_vm->_dungeonMan->_g308_partyDir, movementArrowToStepForwardCount[AL1118_ui_MovementArrowIndex], movementArrowToSepRightCount[AL1118_ui_MovementArrowIndex], L1121_i_MapX, L1122_i_MapY);
-	L1116_i_SquareType = Square(AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(L1121_i_MapX, L1122_i_MapY).toByte()).getType();
-	if (L1116_i_SquareType == k3_ElementTypeStairs) {
+	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(_vm->_dungeonMan->_g308_partyDir, movementArrowToStepForwardCount[movementArrowIdx], movementArrowToSepRightCount[movementArrowIdx], partyMapX, partyMapY);
+	int16 partySquareType = Square(AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(partyMapX, partyMapY).toByte()).getType();
+	if (partySquareType == k3_ElementTypeStairs) {
 		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0);
-		_vm->_dungeonMan->_g306_partyMapX = L1121_i_MapX;
-		_vm->_dungeonMan->_g307_partyMapY = L1122_i_MapY;
+		_vm->_dungeonMan->_g306_partyMapX = partyMapX;
+		_vm->_dungeonMan->_g307_partyMapY = partyMapY;
 		f364_commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp));
 		return;
 	}
-	L1117_B_MovementBlocked = false;
-	if (L1116_i_SquareType == k0_ElementTypeWall) {
-		L1117_B_MovementBlocked = true;
-	} else {
-		if (L1116_i_SquareType == k4_DoorElemType) {
-			L1117_B_MovementBlocked = Square(AL1115_ui_Square).getDoorState();
-			L1117_B_MovementBlocked = (L1117_B_MovementBlocked != k0_doorState_OPEN) && (L1117_B_MovementBlocked != k1_doorState_FOURTH) && (L1117_B_MovementBlocked != k5_doorState_DESTROYED);
-		} else {
-			if (L1116_i_SquareType == k6_ElementTypeFakeWall) {
-				L1117_B_MovementBlocked = (!getFlag(AL1115_ui_Square, k0x0004_FakeWallOpen) && !getFlag(AL1115_ui_Square, k0x0001_FakeWallImaginary));
-			}
-		}
-	}
-	if (_vm->_championMan->_g305_partyChampionCount == 0) {
-	} else {
-		if (L1117_B_MovementBlocked) {
-			AL1118_ui_MovementArrowIndex += (_vm->_dungeonMan->_g308_partyDir + 2);
-			int16 L1124_i_FirstDamagedChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(L1121_i_MapX, L1122_i_MapY, M21_normalizeModulo4(AL1118_ui_MovementArrowIndex));
-			int16 L1125_i_SecondDamagedChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(L1121_i_MapX, L1122_i_MapY, returnNextVal(AL1118_ui_MovementArrowIndex));
-			L1117_B_MovementBlocked = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
+
+	bool isMovementBlocked = false;
+	if (partySquareType == k0_ElementTypeWall)
+		isMovementBlocked = true;
+	else if (partySquareType == k4_DoorElemType) {
+		byte doorState = Square(AL1115_ui_Square).getDoorState();
+		isMovementBlocked = (doorState != k0_doorState_OPEN) && (doorState != k1_doorState_FOURTH) && (doorState != k5_doorState_DESTROYED);
+	} else if (partySquareType == k6_ElementTypeFakeWall)
+		isMovementBlocked = (!getFlag(AL1115_ui_Square, k0x0004_FakeWallOpen) && !getFlag(AL1115_ui_Square, k0x0001_FakeWallImaginary));
+
+	if (_vm->_championMan->_g305_partyChampionCount) {
+		if (isMovementBlocked) {
+			movementArrowIdx += (_vm->_dungeonMan->_g308_partyDir + 2);
+			int16 L1124_i_FirstDamagedChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(partyMapX, partyMapY, M21_normalizeModulo4(movementArrowIdx));
+			int16 L1125_i_SecondDamagedChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(partyMapX, partyMapY, returnNextVal(movementArrowIdx));
+			int16 damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
 			if (L1124_i_FirstDamagedChampionIndex != L1125_i_SecondDamagedChampionIndex)
-				L1117_B_MovementBlocked |= _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
+				damage |= _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
 
-			if (L1117_B_MovementBlocked)
-				_vm->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, L1121_i_MapX, L1122_i_MapY, k0_soundModePlayImmediately);
-		} else if (L1117_B_MovementBlocked = (_vm->_groupMan->f175_groupGetThing(L1121_i_MapX, L1122_i_MapY) != Thing::_endOfList))
-			_vm->_groupMan->f209_processEvents29to41(L1121_i_MapX, L1122_i_MapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
+			if (damage)
+				_vm->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, partyMapX, partyMapY, k0_soundModePlayImmediately);
+		} else if (isMovementBlocked = (_vm->_groupMan->f175_groupGetThing(partyMapX, partyMapY) != Thing::_endOfList))
+			_vm->_groupMan->f209_processEvents29to41(partyMapX, partyMapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
 	}
+
 	// DEBUG CODE: check for Console flag
-	if (L1117_B_MovementBlocked && !_vm->_console->_debugNoclip) {
+	if (isMovementBlocked && !_vm->_console->_debugNoclip) {
 		f357_discardAllInput();
 		_vm->_g321_stopWaitingForPlayerInput = false;
 		return;
 	}
-	if (L1123_B_StairsSquare) {
-		_vm->_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, L1121_i_MapX, L1122_i_MapY);
-	} else {
-		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1121_i_MapX, L1122_i_MapY);
-	}
-	AL1115_ui_Ticks = 1;
-	L1119_ps_Champion = _vm->_championMan->_gK71_champions;
-	for (AL1118_ui_ChampionIndex = k0_ChampionFirst; AL1118_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL1118_ui_ChampionIndex++) {
-		if (L1119_ps_Champion->_currHealth) {
-			AL1115_ui_Ticks = MAX((int32)AL1115_ui_Ticks, (int32)_vm->_championMan->f310_getMovementTicks(L1119_ps_Champion));
-		}
-		L1119_ps_Champion++;
+
+	if (isStairsSquare)
+		_vm->_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, partyMapX, partyMapY);
+	else
+		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, partyMapX, partyMapY);
+
+	uint16 disabledMovtTicks = 1;
+	championsPtr = _vm->_championMan->_gK71_champions;
+	for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_g305_partyChampionCount; idx++) {
+		if (championsPtr->_currHealth)
+			disabledMovtTicks = MAX((int32)disabledMovtTicks, (int32)_vm->_championMan->f310_getMovementTicks(championsPtr));
+
+		championsPtr++;
 	}
-	_vm->_g310_disabledMovementTicks = AL1115_ui_Ticks;
+	_vm->_g310_disabledMovementTicks = disabledMovtTicks;
 	_vm->_g311_projectileDisableMovementTicks = 0;
 }
 


Commit: 90a57f3625f0ec2a1e3d4870f585409b2e6d842e
    https://github.com/scummvm/scummvm/commit/90a57f3625f0ec2a1e3d4870f585409b2e6d842e
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: REfactor f375_processType80_clickDungeonView_isLeaderHandObjThrown, f372_commandProcessType80ClickInDungeonViewTouchFrontWall and f377_commandProcessType80ClickInDungeonView

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index b7290d6..392f6c6 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -946,43 +946,36 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 }
 
 bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int16 posX, int16 posY) {
-	bool L1149_B_ObjectThrown;
-
-
 #define k0_sideLeft 0 // @ C0_SIDE_LEFT 
 #define k1_sideRight 1 // @ C0_SIDE_LEFT 
 
-	if ((posY < 47) || (posY > 102)) {
+	if ((posY < 47) || (posY > 102))
 		return false;
-	}
+
+	bool objectThrownFl;
 	if (posX <= 111) {
 		if (_vm->_dungeonMan->_g285_squareAheadElement == k17_DoorFrontElemType) {
-			if (posX < 64) {
-				return false;
-			}
-		} else {
-			if (posX < 32) {
+			if (posX < 64)
 				return false;
-			}
-		}
-		// Strangerke: Only poresent in CSB2.1... But it fixes a bug so we keep it
-		L1149_B_ObjectThrown = _vm->_championMan->f329_isLeaderHandObjectThrown(k0_sideLeft);
+		} else if (posX < 32)
+			return false;
+
+		// Strangerke: Only present in CSB2.1... But it fixes a bug so we keep it
+		objectThrownFl = _vm->_championMan->f329_isLeaderHandObjectThrown(k0_sideLeft);
 	} else {
 		if (_vm->_dungeonMan->_g285_squareAheadElement == k17_DoorFrontElemType) {
-			if (posX > 163) {
+			if (posX > 163)
 				return false;
-			}
-		} else {
-			if (posX > 191) {
-				return false;
-			}
-		}
-		L1149_B_ObjectThrown = _vm->_championMan->f329_isLeaderHandObjectThrown(k1_sideRight);
+		} else if (posX > 191)
+			return false;
+
+		objectThrownFl = _vm->_championMan->f329_isLeaderHandObjectThrown(k1_sideRight);
 	}
-	if (L1149_B_ObjectThrown) {
+
+	if (objectThrownFl)
 		_vm->_g321_stopWaitingForPlayerInput = true;
-	}
-	return L1149_B_ObjectThrown;
+
+	return objectThrownFl;
 }
 
 void EventManager::setMousePointerFromSpriteData(byte* mouseSprite) {
@@ -1031,101 +1024,84 @@ void EventManager::f368_commandSetLeader(ChampionIndex champIndex) {
 }
 
 void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() {
-	uint16 L1135_ui_MapX;
-	uint16 L1136_ui_MapY;
-
+	uint16 mapX = _vm->_dungeonMan->_g306_partyMapX + _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir];
+	uint16 mapY = _vm->_dungeonMan->_g307_partyMapY + _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
 
-	L1135_ui_MapX = _vm->_dungeonMan->_g306_partyMapX;
-	L1136_ui_MapY = _vm->_dungeonMan->_g307_partyMapY;
-	L1135_ui_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1136_ui_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
-	if ((L1135_ui_MapX >= 0) && (L1135_ui_MapX < _vm->_dungeonMan->_g273_currMapWidth) && (L1136_ui_MapY >= 0) && (L1136_ui_MapY < _vm->_dungeonMan->_g274_currMapHeight)) {
-		_vm->_g321_stopWaitingForPlayerInput = _vm->_moveSens->f275_sensorIsTriggeredByClickOnWall(L1135_ui_MapX, L1136_ui_MapY, returnOppositeDir(_vm->_dungeonMan->_g308_partyDir));
-	}
+	if ((mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth)
+	 && (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight))
+		_vm->_g321_stopWaitingForPlayerInput = _vm->_moveSens->f275_sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(_vm->_dungeonMan->_g308_partyDir));
 }
 
 void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16 posY) {
-	uint16 L1150_ui_ViewCell;
-	Junk* L1151_ps_Junk;
-	Thing L1152_T_Thing;
-	uint16 L1153_ui_IconIndex;
-	uint16 L1154_ui_Weight;
-	int16 L1155_i_MapX;
-	int16 L1156_i_MapY;
-
 	if (_vm->_dungeonMan->_g285_squareAheadElement == k17_DoorFrontElemType) {
-		if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) {
+		if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone)
 			return;
-		}
-		L1155_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
-		L1156_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
-		L1155_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1156_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+
+		int16 L1155_i_MapX = _vm->_dungeonMan->_g306_partyMapX + _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir];
+		int16 L1156_i_MapY = _vm->_dungeonMan->_g307_partyMapY + _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+
 		if (_vm->_championMan->_g415_leaderEmptyHanded) {
-			L1151_ps_Junk = (Junk*)_vm->_dungeonMan->f157_getSquareFirstThingData(L1155_i_MapX, L1156_i_MapY);
-			if ((((Door*)L1151_ps_Junk)->hasButton()) && _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
+			Junk *junkPtr = (Junk*)_vm->_dungeonMan->f157_getSquareFirstThingData(L1155_i_MapX, L1156_i_MapY);
+			if ((((Door*)junkPtr)->hasButton()) && _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
 				_vm->_g321_stopWaitingForPlayerInput = true;
 				_vm->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 				_vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1);
 				return;
 			}
-		} else {
-			if (f375_processType80_clickDungeonView_isLeaderHandObjThrown(posX, posY)) {
-				return;
-			}
-		}
+		} else if (f375_processType80_clickDungeonView_isLeaderHandObjThrown(posX, posY))
+			return;
 	}
+
 	if (_vm->_championMan->_g415_leaderEmptyHanded) {
-		for (L1150_ui_ViewCell = k0_ViewCellFronLeft; L1150_ui_ViewCell < k5_ViewCellDoorButtonOrWallOrn + 1; L1150_ui_ViewCell++) {
-			if (_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[L1150_ui_ViewCell].isPointInside(posX, posY - 33)) {
-				if (L1150_ui_ViewCell == k5_ViewCellDoorButtonOrWallOrn) {
-					if (!_vm->_dungeonMan->_g286_isFacingAlcove) {
+		for (uint16 currViewCell = k0_ViewCellFronLeft; currViewCell < k5_ViewCellDoorButtonOrWallOrn + 1; currViewCell++) {
+			if (_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[currViewCell].isPointInside(posX, posY - 33)) {
+				if (currViewCell == k5_ViewCellDoorButtonOrWallOrn) {
+					if (!_vm->_dungeonMan->_g286_isFacingAlcove)
 						f372_commandProcessType80ClickInDungeonViewTouchFrontWall();
-					}
-				} else {
-					f373_processType80_clickInDungeonView_grabLeaderHandObject(L1150_ui_ViewCell);
-				}
+				} else
+					f373_processType80_clickInDungeonView_grabLeaderHandObject(currViewCell);
+
 				return;
 			}
 		}
 	} else {
-		L1152_T_Thing = _vm->_championMan->_g414_leaderHandObject;
-		L1151_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1152_T_Thing);
+		Thing thingHandObject = _vm->_championMan->_g414_leaderHandObject;
+		Junk *junkPtr = (Junk*)_vm->_dungeonMan->f156_getThingData(thingHandObject);
 		if (_vm->_dungeonMan->_g285_squareAheadElement == k0_ElementTypeWall) {
-			for (L1150_ui_ViewCell = k0_ViewCellFronLeft; L1150_ui_ViewCell < k1_ViewCellFrontRight + 1; L1150_ui_ViewCell++) {
-				if (g462_BoxObjectPiles[L1150_ui_ViewCell].isPointInside(posX, posY)) {
-					f374_processType80_clickInDungeonViewDropLeaderHandObject(L1150_ui_ViewCell);
+			for (uint16 currViewCell = k0_ViewCellFronLeft; currViewCell < k1_ViewCellFrontRight + 1; currViewCell++) {
+				if (g462_BoxObjectPiles[currViewCell].isPointInside(posX, posY)) {
+					f374_processType80_clickInDungeonViewDropLeaderHandObject(currViewCell);
 					return;
 				}
 			}
 			if (_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
-				if (_vm->_dungeonMan->_g286_isFacingAlcove) {
+				if (_vm->_dungeonMan->_g286_isFacingAlcove)
 					f374_processType80_clickInDungeonViewDropLeaderHandObject(k4_ViewCellAlcove);
-				} else {
+				else {
 					if (_vm->_dungeonMan->_g288_isFacingFountain) {
-						L1153_ui_IconIndex = _vm->_objectMan->f33_getIconIndex(L1152_T_Thing);
-						L1154_ui_Weight = _vm->_dungeonMan->f140_getObjectWeight(L1152_T_Thing);
-						if ((L1153_ui_IconIndex >= k8_IconIndiceJunkWater) && (L1153_ui_IconIndex <= k9_IconIndiceJunkWaterSkin)) {
-							L1151_ps_Junk->setChargeCount(3); /* Full */
-						} else {
-							if (L1153_ui_IconIndex == k195_IconIndicePotionEmptyFlask) {
-								((Potion*)L1151_ps_Junk)->setType(k15_PotionTypeWaterFlask);
-							} else {
-								goto T0377019;
-							}
+						uint16 iconIdx = _vm->_objectMan->f33_getIconIndex(thingHandObject);
+						uint16 weight = _vm->_dungeonMan->f140_getObjectWeight(thingHandObject);
+						if ((iconIdx >= k8_IconIndiceJunkWater) && (iconIdx <= k9_IconIndiceJunkWaterSkin))
+							junkPtr->setChargeCount(3); /* Full */
+						else if (iconIdx == k195_IconIndicePotionEmptyFlask)
+							((Potion*)junkPtr)->setType(k15_PotionTypeWaterFlask);
+						else {
+							f372_commandProcessType80ClickInDungeonViewTouchFrontWall();
+							return;
 						}
 						_vm->_championMan->f296_drawChangedObjectIcons();
-						_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(L1152_T_Thing) - L1154_ui_Weight;
+						_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thingHandObject) - weight;
 					}
-T0377019:
 					f372_commandProcessType80ClickInDungeonViewTouchFrontWall();
 				}
 			}
 		} else {
-			if (f375_processType80_clickDungeonView_isLeaderHandObjThrown(posX, posY)) {
+			if (f375_processType80_clickDungeonView_isLeaderHandObjThrown(posX, posY))
 				return;
-			}
-			for (L1150_ui_ViewCell = k0_ViewCellFronLeft; L1150_ui_ViewCell < k3_ViewCellBackLeft + 1; L1150_ui_ViewCell++) {
-				if (g462_BoxObjectPiles[L1150_ui_ViewCell].isPointInside(posX, posY)) {
-					f374_processType80_clickInDungeonViewDropLeaderHandObject(L1150_ui_ViewCell);
+
+			for (uint16 currViewCell = k0_ViewCellFronLeft; currViewCell < k3_ViewCellBackLeft + 1; currViewCell++) {
+				if (g462_BoxObjectPiles[currViewCell].isPointInside(posX, posY)) {
+					f374_processType80_clickInDungeonViewDropLeaderHandObject(currViewCell);
 					return;
 				}
 			}


Commit: cba80bc69dc94022ab77e6c81ff2098bbdc8748f
    https://github.com/scummvm/scummvm/commit/cba80bc69dc94022ab77e6c81ff2098bbdc8748f
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some refactoring in f373_processType80_clickInDungeonView_grabLeaderHandObject and f374_processType80_clickInDungeonViewDropLeaderHandObject

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 392f6c6..9eb941b 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1173,9 +1173,8 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 		_vm->_projexpl->_g362_lastPartyMovementTime = _vm->_g313_gameTime;
 		f368_commandSetLeader(k0_ChampionFirst);
 		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(k0_ChampionFirst);
-	} else {
+	} else
 		_vm->_menuMan->f393_drawSpellAreaControls(champMan._g514_magicCasterChampionIndex);
-	}
 
 	_vm->_textMan->f51_messageAreaPrintLineFeed();
 	Color champColor = g46_ChampionColor[championIndex];
@@ -1213,67 +1212,59 @@ void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) {
 }
 
 void EventManager::f373_processType80_clickInDungeonView_grabLeaderHandObject(uint16 viewCell) {
-	int16 L1137_i_MapX;
-	int16 L1138_i_MapY;
-	Thing L1139_T_Thing;
-
-
-	if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) {
+	if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone)
 		return;
-	}
-	L1137_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
-	L1138_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+
+	int16 mapX = _vm->_dungeonMan->_g306_partyMapX;
+	int16 mapY = _vm->_dungeonMan->_g307_partyMapY;
 	if (viewCell >= k2_ViewCellBackRight) {
-		L1137_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1138_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
-		if (((L1139_T_Thing = _vm->_groupMan->f175_groupGetThing(L1137_i_MapX, L1138_i_MapY)) != Thing::_endOfList) &&
-			!_vm->_moveSens->f264_isLevitating(L1139_T_Thing) &&
-			_vm->_groupMan->f176_getCreatureOrdinalInCell((Group*)_vm->_dungeonMan->f156_getThingData(L1139_T_Thing), M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir))) {
+		mapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], mapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+		Thing groupThing = _vm->_groupMan->f175_groupGetThing(mapX, mapY);
+		if ((groupThing != Thing::_endOfList) &&
+			!_vm->_moveSens->f264_isLevitating(groupThing) &&
+			_vm->_groupMan->f176_getCreatureOrdinalInCell((Group*)_vm->_dungeonMan->f156_getThingData(groupThing), M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir))) {
 			return; /* It is not possible to grab an object on floor if there is a non levitating creature on its cell */
 		}
 	}
-	L1139_T_Thing = _vm->_dungeonMan->_g292_pileTopObject[viewCell];
-	if (_vm->_objectMan->f33_getIconIndex(L1139_T_Thing) != kM1_IconIndiceNone) {
-		_vm->_moveSens->f267_getMoveResult(L1139_T_Thing, L1137_i_MapX, L1138_i_MapY, kM1_MapXNotOnASquare, 0);
-		_vm->_championMan->f297_putObjectInLeaderHand(L1139_T_Thing, true);
+
+	Thing topPileThing = _vm->_dungeonMan->_g292_pileTopObject[viewCell];
+	if (_vm->_objectMan->f33_getIconIndex(topPileThing) != kM1_IconIndiceNone) {
+		_vm->_moveSens->f267_getMoveResult(topPileThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
+		_vm->_championMan->f297_putObjectInLeaderHand(topPileThing, true);
 	}
+
 	_vm->_g321_stopWaitingForPlayerInput = true;
 }
 
 void EventManager::f374_processType80_clickInDungeonViewDropLeaderHandObject(uint16 viewCell) {
-	int16 L1140_i_MapX;
-	int16 L1141_i_MapY;
-	Thing L1142_T_Thing;
-	Junk* L1143_ps_Junk;
 	int16 L1144_i_IconIndex;
-	uint16 L1145_ui_Cell;
-	bool L1146_B_DroppingIntoAnAlcove;
-	TimelineEvent L1147_s_Event;
-
 
-	if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) {
+	if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone)
 		return;
-	}
-	L1140_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
-	L1141_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
-	if (L1146_B_DroppingIntoAnAlcove = (viewCell == k4_ViewCellAlcove)) {
+
+	int16 mapX = _vm->_dungeonMan->_g306_partyMapX;
+	int16 mapY = _vm->_dungeonMan->_g307_partyMapY;
+	bool droppingIntoAnAlcove = (viewCell == k4_ViewCellAlcove);
+	if (droppingIntoAnAlcove)
 		viewCell = k2_ViewCellBackRight;
-	}
-	if (viewCell > k1_ViewCellFrontRight) {
-		L1140_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1141_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
-	}
-	L1145_ui_Cell = M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + viewCell);
-	L1142_T_Thing = _vm->_championMan->f298_getObjectRemovedFromLeaderHand();
-	_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(L1142_T_Thing, L1145_ui_Cell), kM1_MapXNotOnASquare, 0, L1140_i_MapX, L1141_i_MapY);
-	if (L1146_B_DroppingIntoAnAlcove && _vm->_dungeonMan->_g287_isFacingViAltar && ((L1144_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L1142_T_Thing)) == k147_IconIndiceJunkChampionBones)) {
-		L1143_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1142_T_Thing);
-		M33_setMapAndTime(L1147_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 1);
-		L1147_s_Event._type = k13_TMEventTypeViAltarRebirth;
-		L1147_s_Event._priority = L1143_ps_Junk->getChargeCount();
-		L1147_s_Event._B._location._mapX = L1140_i_MapX;
-		L1147_s_Event._B._location._mapY = L1141_i_MapY;
-		L1147_s_Event._C.A._cell = L1145_ui_Cell;
-		L1147_s_Event._C.A._effect = k2_SensorEffToggle;
-		_vm->_timeline->f238_addEventGetEventIndex(&L1147_s_Event);
+
+	if (viewCell > k1_ViewCellFrontRight)
+		mapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], mapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+
+	uint16 currCell = M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + viewCell);
+	Thing removedThing = _vm->_championMan->f298_getObjectRemovedFromLeaderHand();
+	_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(removedThing, currCell), kM1_MapXNotOnASquare, 0, mapX, mapY);
+	if (droppingIntoAnAlcove && _vm->_dungeonMan->_g287_isFacingViAltar && ((L1144_i_IconIndex = _vm->_objectMan->f33_getIconIndex(removedThing)) == k147_IconIndiceJunkChampionBones)) {
+		Junk *removedJunk = (Junk*)_vm->_dungeonMan->f156_getThingData(removedThing);
+		TimelineEvent newEvent;
+		M33_setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 1);
+		newEvent._type = k13_TMEventTypeViAltarRebirth;
+		newEvent._priority = removedJunk->getChargeCount();
+		newEvent._B._location._mapX = mapX;
+		newEvent._B._location._mapY = mapY;
+		newEvent._C.A._cell = currCell;
+		newEvent._C.A._effect = k2_SensorEffToggle;
+		_vm->_timeline->f238_addEventGetEventIndex(&newEvent);
 	}
 	_vm->_g321_stopWaitingForPlayerInput = true;
 }


Commit: 834595a7f9de4835e93823caa8df5c0e175102c8
    https://github.com/scummvm/scummvm/commit/834595a7f9de4835e93823caa8df5c0e175102c8
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix multiword item names with debug command gimme

Changed paths:
    engines/dm/console.cpp



diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index baffd02..e9a937c 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -165,7 +165,7 @@ bool Console::Cmd_map(int argc, const char** argv) {
 
 		// not >= because dimensions are inslucsive
 		if (index < 0 || index >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount) {
-			debugPrintf("Map index %d is out of bounds, possible values [0, %d]\n", _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount - 1);
+			debugPrintf("Map index %d is out of bounds, possible values [0, %d]\n", index, _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount - 1);
 			return true;
 		}
 
@@ -216,8 +216,11 @@ bool Console::Cmd_gimme(int argc, const char** argv) {
 	}
 
 	Common::String requestedItemName;
-	for (int16 i = 1; i < argc; ++i)
+	for (int16 i = 1; i < argc; ++i) {
 		requestedItemName += argv[i];
+		requestedItemName += " ";
+	}
+	requestedItemName.deleteLastChar();
 
 	for (int16 thingType = 0; thingType < 16; ++thingType) { // 16 number of item types
 		uint16 *thingDataArray = _vm->_dungeonMan->_g284_thingData[thingType];


Commit: 9e333a6216df0363e9fd07876308ab5966de5c42
    https://github.com/scummvm/scummvm/commit/9e333a6216df0363e9fd07876308ab5966de5c42
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add search by substring in listItems debug command

Changed paths:
    engines/dm/console.cpp



diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index e9a937c..b8fae42 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -195,16 +195,39 @@ argumentError:
 }
 
 bool Console::Cmd_listItems(int argc, const char** argv) {
-	debugPrintf("| %s", _vm->_objectMan->_g352_objectNames[0]);
+	Common::String searchedString = "";
+	for (int16 i = 1; i < argc; ++i) {
+		searchedString += argv[i];
+		searchedString += " ";
+	}
+	searchedString.deleteLastChar();
+
+	bool atleastOneFound = false;
+	int16 namesPrintedInLine = 0;
+
+	if(strstr(_vm->_objectMan->_g352_objectNames[0], searchedString.c_str()) != nullptr)
+		debugPrintf("| %s", _vm->_objectMan->_g352_objectNames[0]);
+
 	for (uint16 i = 1; i < k199_ObjectNameCount; ++i) {
 		const char *name = _vm->_objectMan->_g352_objectNames[i - 1];
 		const char *prevName = _vm->_objectMan->_g352_objectNames[i];
-		if (!cstrEquals(prevName, name))
+
+		if (!cstrEquals(name, prevName) && (strstr(name, searchedString.c_str()) != nullptr)) {
 			debugPrintf(" | %s", name);
-		if (i % 5 == 0)
-			debugPrintf("\n");
+			atleastOneFound = true;
+
+			if ((++namesPrintedInLine % 6) == 0) {
+				namesPrintedInLine = 0;
+				debugPrintf("\n");
+			}
+		}
+	}
+
+	if (atleastOneFound) {
+		debugPrintf("\n");
+	} else {
+		debugPrintf("No itemnames found containing '%s'\n", searchedString.c_str());
 	}
-	debugPrintf("\n");
 
 	return true;
 }


Commit: 5c2ee5c7487773a3424ee8220049982896b9509e
    https://github.com/scummvm/scummvm/commit/5c2ee5c7487773a3424ee8220049982896b9509e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix wrong champIcon hidden in f319_championKill

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index fc24288..b819627 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1414,7 +1414,7 @@ void ChampionMan::f319_championKill(uint16 champIndex) {
 		f323_unpoison(champIndex);
 
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[curChampionIconIndex << 2], k0_ColorBlack);
+	_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[curChampionIconIndex], k0_ColorBlack);
 	f292_drawChampionState((ChampionIndex)champIndex);
 
 	int16 aliveChampionIndex;


Commit: 6cba484abb6a83b0dcf9a322ddd981d8feea42a5
    https://github.com/scummvm/scummvm/commit/6cba484abb6a83b0dcf9a322ddd981d8feea42a5
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Make EventManager:f541_waitForMouseOrKeyActivity discard input first

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 9eb941b..3fbc95f 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1521,6 +1521,7 @@ void EventManager::f544_resetPressingEyeOrMouth() {
 }
 
 void EventManager::f541_waitForMouseOrKeyActivity() {
+	f357_discardAllInput();
 	Common::Event event;
 	while (true) {
 		if (_vm->_system->getEventManager()->pollEvent(event)) {


Commit: f5646efa44bf9103f352ea917e537ab6717d11c1
    https://github.com/scummvm/scummvm/commit/f5646efa44bf9103f352ea917e537ab6717d11c1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add TextMan::f43_messageAreaClearAllRows()

Changed paths:
    engines/dm/text.cpp
    engines/dm/text.h



diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 17531a1..6e7ae5e 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -160,7 +160,7 @@ void TextMan::f46_messageAreaPrintString(Color color, const char* string) {
 		f53_printToLogicalScreen(_g359_messageAreaCursorColumn * 6, (_g358_messageAreaCursorRow * 7 - 6) + 177, color, k0_ColorBlack, string);
 	} else {
 		f40_printTextToBitmap(_g356_bitmapMessageAreaNewRow, k160_byteWidthScreen, _g359_messageAreaCursorColumn * 6, 5, color, k0_ColorBlack, string, 7);
-		if(f561_isTextScrolling(&_gK60_s_TextScroller, false))
+		if (f561_isTextScrolling(&_gK60_s_TextScroller, false))
 			f560_SCROLLER_setCommand(&_gK60_s_TextScroller, 1);
 	}
 	_g359_messageAreaCursorColumn += L0030_i_StringLength;
@@ -225,4 +225,19 @@ void TextMan::f443_endgamePrintString(int16 x, int16 y, Color textColor, char* t
 	}
 	f53_printToLogicalScreen(x, y, textColor, k12_ColorDarkestGray, L1408_ac_ModifiedString);
 }
+
+void TextMan::f43_messageAreaClearAllRows() {
+	int16 L0023_i_RowIndex;
+
+	f561_isTextScrolling(&_gK60_s_TextScroller, true);
+
+	Box tmpBox(0, 319, 169, 199);
+	_vm->_displayMan->D24_fillScreenBox(tmpBox, k0_ColorBlack);
+	
+	_g358_messageAreaCursorRow = 3;
+	_g359_messageAreaCursorColumn = 0;
+	for (L0023_i_RowIndex = 0; L0023_i_RowIndex < 4; L0023_i_RowIndex++) {
+		_g360_messageAreaRowExpirationTime[L0023_i_RowIndex] = -1;
+	}
+}
 }
diff --git a/engines/dm/text.h b/engines/dm/text.h
index b4eca1a..51be3b2 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -66,6 +66,7 @@ public:
 		warning(false, "STUB METHOD: f561_isTextScrolling"); return true;
 	} // @ F0561_SCROLLER_IsTextScrolling
 	void f560_SCROLLER_setCommand(TextScroller *scroller, int16 command) { warning(false, "STUB METHOD: f560_SCROLLER_setCommand");  } // @ F0560_SCROLLER_SetCommand
+	void f43_messageAreaClearAllRows(); // @ F0043_TEXT_MESSAGEAREA_ClearAllRows
 };
 
 }


Commit: 13daeb62afac13e877ee398b1aa0e1c9ac294989
    https://github.com/scummvm/scummvm/commit/13daeb62afac13e877ee398b1aa0e1c9ac294989
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Make DMEngine::f22_delay and DMEngine::f444_endGame more responsive

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index f4ab7f4..9fec0c3 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -234,7 +234,11 @@ bool DMEngine::hasFeature(EngineFeature f) const {
 }
 
 void DMEngine::f22_delay(uint16 verticalBlank) {
-	_system->delayMillis(verticalBlank * 20); // Google says most Amiga games had a refreshrate of 50 hz
+	for (uint16 i = 0; i < verticalBlank * 2; ++i) {
+		_eventMan->f357_discardAllInput();
+		_displayMan->updateScreen();
+		_system->delayMillis(10); // Google says most Amiga games had a refreshrate of 50 hz
+	}
 }
 
 uint16 DMEngine::f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2) {
@@ -628,6 +632,7 @@ T0444017:
 			curPalette[i] = darkBluePalette[i];
 		curPalette[15] = D09_RGB_WHITE;
 		_displayMan->f436_STARTEND_FadeToPalette(curPalette);
+		_displayMan->updateScreen();
 		if (waitBeforeDrawingRestart)
 			f22_delay(300);
 


Commit: b46ade6b6c49c3497e2edbc6007280e320119bb5
    https://github.com/scummvm/scummvm/commit/b46ade6b6c49c3497e2edbc6007280e320119bb5
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add DMEngine::f445_STARTEND_fuseSequenceUpdate

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



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 9fec0c3..2d5efdd 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -764,5 +764,16 @@ void DMEngine::f438_STARTEND_OpenEntranceDoors() {
 
 
 
+void DMEngine::f445_STARTEND_fuseSequenceUpdate() {
+	_timeline->f261_processTimeline();
+	_displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
+	f65_playPendingSound();
+	_eventMan->f357_discardAllInput();
+	_displayMan->updateScreen();
+	f22_delay(1);
+	_g313_gameTime++; /* BUG0_71 Some timings are too short on fast computers. 
+					  The ending animation when Lord Chaos is fused plays too quickly because the execution speed is not limited */
+	
+}
 
 } // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 25fabc7..cd38d14 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -268,6 +268,7 @@ public:
 	void f438_STARTEND_OpenEntranceDoors(); // @ F0438_STARTEND_OpenEntranceDoors
 	void f437_STARTEND_drawTittle() { warning(false, "STUB METHOD: f437_STARTEND_drawTittle"); }// @ F0437_STARTEND_DrawTitle
 	void f442_SARTEND_processCommand202_entranceDrawCredits() { warning(false, "STUB METHOD: f442_SARTEND_processCommand202_entranceDrawCredits"); }// @ F0442_STARTEND_ProcessCommand202_EntranceDrawCredits
+	void f445_STARTEND_fuseSequenceUpdate(); // @ F0445_STARTEND_FuseSequenceUpdate
 
 private:
 	int16 _g528_saveFormat; // @ G0528_i_Format


Commit: 37db95c33646a60218f8ed2c897473310a1c582b
    https://github.com/scummvm/scummvm/commit/37db95c33646a60218f8ed2c897473310a1c582b
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add DMEngine::f446_STARTEND_fuseSequnce()

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/group.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 721507c..d20ddb0 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -6,15 +6,14 @@ Bugs:
 		When reordering a champions, the icons in the top right corner ar drawn twice under the cursor
 
 	Logic:
-		F0444_STARTEND_Endgame is broken
 		Items thrown on the right side end up on the left side 
 		I'm not sure, but the cooldown between champion actions when fighting monsters seems too muh
+		Clicking with a scroll in hand on the eye in the inventory makes userinput glitchy
 
 
 Possible bugs:
 	- k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON
 	- possible garbage value return in f140_getObjectWeight
-	- After loading, creatures are in the wrong cells of a square
 
 	
 Todo:
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 2d5efdd..51be9d8 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -762,7 +762,144 @@ void DMEngine::f438_STARTEND_OpenEntranceDoors() {
 	_savedScreenForOpenEntranceDoors = nullptr;
 }
 
+void DMEngine::f446_STARTEND_fuseSequnce() {
+	int16 L1424_i_Multiple;
+#define AL1424_B_RemoveFluxcagesFromLoadChaosSquare L1424_i_Multiple
+#define AL1424_i_Attack                             L1424_i_Multiple
+#define AL1424_i_CreatureTypeSwitchCount            L1424_i_Multiple
+#define AL1424_i_MapX                               L1424_i_Multiple
+#define AL1424_i_TextStringThingCount               L1424_i_Multiple
+	int16 L1425_i_Multiple;
+#define AL1425_i_FluxcageMapX         L1425_i_Multiple
+#define AL1425_i_MapY                 L1425_i_Multiple
+#define AL1425_i_CycleCount           L1425_i_Multiple
+#define AL1425_i_TextStringThingIndex L1425_i_Multiple
+	int16 L1426_i_Multiple;
+#define AL1426_i_FluxcageMapY            L1426_i_Multiple
+#define AL1426_i_FuseSequenceUpdateCount L1426_i_Multiple
+#define AL1426_i_TextStringThingCount    L1426_i_Multiple
+	Thing L1427_T_Thing;
+	Group* L1428_ps_Group;
+	Explosion* L1429_ps_Explosion;
+	Thing L1430_T_NextThing;
+	int16 L1431_i_LordChaosMapX;
+	int16 L1432_i_LordChaosMapY;
+	Thing L1433_T_LordChaosThing;
+	char L1434_c_TextFirstCharacter;
+	Thing L1435_aT_TextStringThings[8];
+	char L1436_ac_String[200];
+
+
+	_g302_gameWon = true;
+	if (_inventoryMan->_g432_inventoryChampionOrdinal) {
+		_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
+	}
+	_eventMan->f363_highlightBoxDisable();
+	_championMan->_g407_party._magicalLightAmount = 200;
+	_inventoryMan->f337_setDungeonViewPalette();
+	_championMan->_g407_party._fireShieldDefense = _championMan->_g407_party._spellShieldDefense = _championMan->_g407_party._shieldDefense = 100;
+	_timeline->f260_timelineRefreshAllChampionStatusBoxes();
+	f445_STARTEND_fuseSequenceUpdate();
+	L1431_i_LordChaosMapX = _dungeonMan->_g306_partyMapX;
+	L1432_i_LordChaosMapY = _dungeonMan->_g307_partyMapY;
+	L1431_i_LordChaosMapX += _dirIntoStepCountEast[_dungeonMan->_g308_partyDir], L1432_i_LordChaosMapY += _dirIntoStepCountNorth[_dungeonMan->_g308_partyDir];
+	L1428_ps_Group = (Group*)_dungeonMan->f156_getThingData(L1433_T_LordChaosThing = _groupMan->f175_groupGetThing(L1431_i_LordChaosMapX, L1432_i_LordChaosMapY));
+	L1428_ps_Group->_health[0] = 10000;
+	_dungeonMan->f146_setGroupCells(L1428_ps_Group, k255_CreatureTypeSingleCenteredCreature, _dungeonMan->_g309_partyMapIndex);
+	_dungeonMan->f148_setGroupDirections(L1428_ps_Group, returnOppositeDir(_dungeonMan->_g308_partyDir), _dungeonMan->_g309_partyMapIndex);
+
+	AL1424_B_RemoveFluxcagesFromLoadChaosSquare = true;
+	AL1425_i_FluxcageMapX = _dungeonMan->_g306_partyMapX;
+	AL1426_i_FluxcageMapY = _dungeonMan->_g307_partyMapY;
+T0446002:
+	L1427_T_Thing = _dungeonMan->f162_getSquareFirstObject(AL1425_i_FluxcageMapX, AL1426_i_FluxcageMapY);
+	while (L1427_T_Thing != Thing::_endOfList) {
+		if (L1427_T_Thing.getType() == k15_ExplosionThingType) {
+			L1429_ps_Explosion = (Explosion*)_dungeonMan->f156_getThingData(L1427_T_Thing);
+			if (L1429_ps_Explosion->getType() == k50_ExplosionType_Fluxcage) {
+				_dungeonMan->f164_unlinkThingFromList(L1427_T_Thing, Thing(0), AL1425_i_FluxcageMapX, AL1426_i_FluxcageMapY);
+				L1429_ps_Explosion->setNextThing(Thing::_none);
+				goto T0446002;
+			}
+		}
+		L1427_T_Thing = _dungeonMan->f159_getNextThing(L1427_T_Thing);
+	}
+	if (AL1424_B_RemoveFluxcagesFromLoadChaosSquare) {
+		AL1424_B_RemoveFluxcagesFromLoadChaosSquare = false;
+		AL1425_i_FluxcageMapX = L1431_i_LordChaosMapX;
+		AL1426_i_FluxcageMapY = L1432_i_LordChaosMapY;
+		goto T0446002;
+	}
+
+	f445_STARTEND_fuseSequenceUpdate();
+	for (AL1424_i_Attack = 55; AL1424_i_Attack <= 255; AL1424_i_Attack += 40) {
+		_projexpl->f213_explosionCreate(Thing::_explFireBall, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
+		f445_STARTEND_fuseSequenceUpdate();
+	}
+	f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized);
+	L1428_ps_Group->_type = k25_CreatureTypeLordOrder;
+	f445_STARTEND_fuseSequenceUpdate();
+	for (AL1424_i_Attack = 55; AL1424_i_Attack <= 255; AL1424_i_Attack += 40) {
+		_projexpl->f213_explosionCreate(Thing::_explHarmNonMaterial, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
+		f445_STARTEND_fuseSequenceUpdate();
+	}
+	for (AL1425_i_CycleCount = 4; --AL1425_i_CycleCount; ) {
+		for (AL1424_i_CreatureTypeSwitchCount = 5; --AL1424_i_CreatureTypeSwitchCount; ) {
+			f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized);
+			L1428_ps_Group->_type = (AL1424_i_CreatureTypeSwitchCount & 0x0001) ? k25_CreatureTypeLordOrder : k23_CreatureTypeLordChaos;
+			for (AL1426_i_FuseSequenceUpdateCount = AL1425_i_CycleCount; AL1426_i_FuseSequenceUpdateCount--; f445_STARTEND_fuseSequenceUpdate());
+		}
+	}
+	_projexpl->f213_explosionCreate(Thing::_explFireBall, 255, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
+	_projexpl->f213_explosionCreate(Thing::_explHarmNonMaterial, 255, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
+	f445_STARTEND_fuseSequenceUpdate();
+	L1428_ps_Group->_type = k26_CreatureTypeGreyLord;
+	f445_STARTEND_fuseSequenceUpdate();
+	_displayMan->_g77_doNotDrawFluxcagesDuringEndgame = true;
+	f445_STARTEND_fuseSequenceUpdate();
+	for (AL1424_i_MapX = 0; AL1424_i_MapX < _dungeonMan->_g273_currMapWidth; AL1424_i_MapX++) {
+		for (AL1425_i_MapY = 0; AL1425_i_MapY < _dungeonMan->_g274_currMapHeight; AL1425_i_MapY++) {
+			if (((L1427_T_Thing = _groupMan->f175_groupGetThing(AL1424_i_MapX, AL1425_i_MapY)) != Thing::_endOfList) && ((AL1424_i_MapX != L1431_i_LordChaosMapX) || (AL1425_i_MapY != L1432_i_LordChaosMapY))) {
+				_groupMan->f189_delete(AL1424_i_MapX, AL1425_i_MapY);
+			}
+		}
+	}
+	f445_STARTEND_fuseSequenceUpdate();
+	/* Count and get list of text things located at 0, 0 in the current map. Their text is then printed as messages in the order specified by their first letter (which is not printed) */
+	L1427_T_Thing = _dungeonMan->f161_getSquareFirstThing(0, 0);
+	AL1424_i_TextStringThingCount = 0;
+	while (L1427_T_Thing != Thing::_endOfList) {
+		if (L1427_T_Thing.getType() == k2_TextstringType) {
+			L1435_aT_TextStringThings[AL1424_i_TextStringThingCount++] = L1427_T_Thing;
+		}
+		L1427_T_Thing = _dungeonMan->f159_getNextThing(L1427_T_Thing);
+	}
+	L1434_c_TextFirstCharacter = 'A';
+	AL1426_i_TextStringThingCount = AL1424_i_TextStringThingCount;
+	while (AL1424_i_TextStringThingCount--) {
+		for (AL1425_i_TextStringThingIndex = 0; AL1425_i_TextStringThingIndex < AL1426_i_TextStringThingCount; AL1425_i_TextStringThingIndex++) {
+			_dungeonMan->f168_decodeText(L1436_ac_String, L1435_aT_TextStringThings[AL1425_i_TextStringThingIndex], (TextType)(k1_TextTypeMessage | k0x8000_DecodeEvenIfInvisible));
+			if (L1436_ac_String[1] == L1434_c_TextFirstCharacter) {
+				_textMan->f43_messageAreaClearAllRows();
+				L1436_ac_String[1] = '\n'; /* New line */
+				_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, &L1436_ac_String[1]);
+				f445_STARTEND_fuseSequenceUpdate();
+				f22_delay(780);
+				L1434_c_TextFirstCharacter++;
+				break;
+			}
+		}
+	}
+
+	for (AL1424_i_Attack = 55; AL1424_i_Attack <= 255; AL1424_i_Attack += 40) {
+		_projexpl->f213_explosionCreate(Thing::_explHarmNonMaterial, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
+		f445_STARTEND_fuseSequenceUpdate();
+	}
 
+	f22_delay(600);
+	_g524_restartGameAllowed = false;
+	f444_endGame(true);
+}
 
 void DMEngine::f445_STARTEND_fuseSequenceUpdate() {
 	_timeline->f261_processTimeline();
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index cd38d14..d7af092 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -268,6 +268,7 @@ public:
 	void f438_STARTEND_OpenEntranceDoors(); // @ F0438_STARTEND_OpenEntranceDoors
 	void f437_STARTEND_drawTittle() { warning(false, "STUB METHOD: f437_STARTEND_drawTittle"); }// @ F0437_STARTEND_DrawTitle
 	void f442_SARTEND_processCommand202_entranceDrawCredits() { warning(false, "STUB METHOD: f442_SARTEND_processCommand202_entranceDrawCredits"); }// @ F0442_STARTEND_ProcessCommand202_EntranceDrawCredits
+	void f446_STARTEND_fuseSequnce(); // @ F0446_STARTEND_FuseSequence
 	void f445_STARTEND_fuseSequenceUpdate(); // @ F0445_STARTEND_FuseSequenceUpdate
 
 private:
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 2172d87..064b30d 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -2055,7 +2055,7 @@ void GroupMan::f225_fuseAction(uint16 mapX, uint16 mapY) {
 				return;
 			}
 		}
-		warning(false, "F0446_STARTEND_FuseSequence()");
+		_vm->f446_STARTEND_fuseSequnce();
 	}
 }
 


Commit: 94ba2fdb2bec8c0a9bf58ded78fd40f6b95aa28c
    https://github.com/scummvm/scummvm/commit/94ba2fdb2bec8c0a9bf58ded78fd40f6b95aa28c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add partial fix of color palette

Changed paths:
    engines/dm/dm.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 51be9d8..59151a9 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -246,10 +246,9 @@ uint16 DMEngine::f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2) {
 }
 
 void DMEngine::f463_initializeGame() {
+	f448_initMemoryManager();
 	_displayMan->f479_loadGraphics();
 	_displayMan->f460_initializeGraphicData();
-	warning(false, "Dummy code in f463_initializeGame, setting palette");
-	_displayMan->loadPalette(g21_PalDungeonView[0]);
 	_displayMan->f94_loadFloorSet(k0_FloorSetStone);
 	_displayMan->f95_loadWallSet(k0_WallSetStone);
 
@@ -279,6 +278,7 @@ void DMEngine::f463_initializeGame() {
 
 void DMEngine::f448_initMemoryManager() {
 	warning(false, "STUB METHOD: f448_initMemoryManager");
+	_displayMan->f508_buildPaletteChangeCopperList(gK57_PalSwoosh, gK57_PalSwoosh);
 	for (uint16 i = 0; i < 16; ++i)
 		_displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i];
 }
@@ -319,7 +319,7 @@ void DMEngine::f462_startGame() {
 		_displayMan->D24_fillScreenBox(boxScreenBottom, k0_ColorBlack);
 	}
 
-	warning(false, "TODO: build copper");
+	_displayMan->f508_buildPaletteChangeCopperList(g21_PalDungeonView[0], _displayMan->_g347_paletteTopAndBottomScreen);
 	_menuMan->f395_drawMovementArrows();
 	_championMan->f278_resetDataToStartGame();
 	_g301_gameTimeTicking = true;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 41fb147..832b336 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -728,6 +728,10 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 
 	for (uint16 i = 0; i < 32; i++)
 		_g345_aui_BlankBuffer[i] = 0;
+
+	// HACK
+	memcpy(_g346_paletteMiddleScreen, g20_PalEntrance, sizeof(uint16) * 16);
+	memcpy(_g347_paletteTopAndBottomScreen, g20_PalEntrance, sizeof(uint16) * 16);
 }
 
 DisplayMan::~DisplayMan() {
@@ -1210,7 +1214,13 @@ byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale
 
 
 void DisplayMan::updateScreen() {
+	// apply copper
+	warning(false, "Top of the screen color is offset as well"); // loop should start from 320 * 30
+	for (uint32 i = 0; i < 320 * 170; ++i)
+		_g348_bitmapScreen[i] += 16;
 	_vm->_system->copyRectToScreen(_g348_bitmapScreen, _screenWidth, 0, 0, _screenWidth, _screenHeight);
+	for (uint32 i = 0; i < 320 * 170; ++i) // loop should start from 320 * 30
+		_g348_bitmapScreen[i] -= 16;
 	_vm->_console->onFrame();
 	_vm->_system->updateScreen();
 }
@@ -1719,7 +1729,7 @@ void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 		goto T0119020;
 	case k2_ElementTypePit:
 		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice,
-														  g143_FrameFloorPit_D2L);
+										g143_FrameFloorPit_D2L);
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
 T0119018:
@@ -1786,7 +1796,7 @@ void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
 		goto T0120029;
 	case k2_ElementTypePit:
 		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect]
-																			 ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice, g145_FrameFloorPit_D2R);
+														   ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice, g145_FrameFloorPit_D2R);
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
 T0120027:
@@ -2157,9 +2167,6 @@ void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 }
 
 void DisplayMan::f128_drawDungeon(Direction dir, int16 posX, int16 posY) {
-	loadPalette(g20_PalEntrance); // dummy code
-
-
 	if (_g297_drawFloorAndCeilingRequested)
 		f98_drawFloorAndCeiling();
 	_g578_useByteBoxCoordinates = true;
@@ -2896,7 +2903,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 	byte* paletteChanges;
 	byte* bitmapGreenAnt;
 	byte* coordinateSet;
-	int16 derivedBitmapIndex = - 1;
+	int16 derivedBitmapIndex = -1;
 	bool L0135_B_DrawAlcoveObjects;
 	int16 byteWidth;
 	int16 heightRedEagle;
@@ -3675,4 +3682,21 @@ uint16 DisplayMan::f431_getDarkenedColor(uint16 RGBcolor) {
 	return RGBcolor;
 }
 
+void DisplayMan::f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom) {
+	// memcpy(_g347_paletteTopAndBottomScreen, topAndBottom, sizeof(uint16) * 16);
+	// memcpy(_g346_paletteMiddleScreen, middleScreen, sizeof(uint16) * 16);
+	byte colorPalette[32 * 3];
+	for (int i = 0; i < 16; ++i) {
+		colorPalette[i * 3] = (topAndBottom[i] >> 8) * (256 / 16);
+		colorPalette[i * 3 + 1] = (topAndBottom[i] >> 4) * (256 / 16);
+		colorPalette[i * 3 + 2] = topAndBottom[i] * (256 / 16);
+	}
+	for (int i = 16; i < 32; ++i) {
+		colorPalette[i * 3] = (middleScreen[i] >> 8) * (256 / 16);
+		colorPalette[i * 3 + 1] = (middleScreen[i] >> 4) * (256 / 16);
+		colorPalette[i * 3 + 2] = middleScreen[i] * (256 / 16);
+	}
+	_vm->_system->getPaletteManager()->setPalette(colorPalette, 0, 32);
+}
+
 }
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 9e66455..564bfb6 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -526,7 +526,6 @@ class DisplayMan {
 
 	DMEngine *_vm;
 
-	/// Related to graphics.dat file
 	uint16 _grapItemCount; // @ G0632_ui_GraphicCount
 	uint32 *_packedItemPos;
 	byte *_packedBitmaps;
@@ -751,7 +750,7 @@ public:
 	void f480_releaseBlock(uint16 index); // @ F0480_CACHE_ReleaseBlock
 	uint16 f431_getDarkenedColor(uint16 RGBcolor);
 	void f436_STARTEND_FadeToPalette(uint16 *P0849_pui_Palette) { warning(false, "STUB METHOD: f436_STARTEND_FadeToPalette"); }
-	void f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom) { warning(false, "STUB METHOD: f508_buildPaletteChangeCopperList"); }// @ F0508_AMIGA_BuildPaletteChangeCopperList
+	void f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom);
 	void f136_shadeScreenBox(Box* box, Color color) { warning(false, "STUB METHOD: f136_shadeScreenBox"); } // @ F0136_VIDEO_ShadeScreenBox
 };
 


Commit: 181995cff9a521fb659aadc802d6cd65233385f2
    https://github.com/scummvm/scummvm/commit/181995cff9a521fb659aadc802d6cd65233385f2
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Deprecate DisplayMan::loadPalette

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 832b336..e42e228 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1063,23 +1063,11 @@ void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* to
 }
 
 void DisplayMan::f566_viewportBlitToScreen() {
-	warning(false, "MISSING FUNCTIONALITY: using correct colorpalette");
 	Box box(0, 223, 33, 33 + 135);
 
 	f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport, k160_byteWidthScreen, kM1_ColorNoTransparency);
 }
 
-void DisplayMan::loadPalette(uint16 *palette) {
-	byte colorPalette[16 * 3];
-	for (int i = 0; i < 16; ++i) {
-		colorPalette[i * 3] = (palette[i] >> 8) * (256 / 16);
-		colorPalette[i * 3 + 1] = (palette[i] >> 4) * (256 / 16);
-		colorPalette[i * 3 + 2] = palette[i] * (256 / 16);
-	}
-	_vm->_system->getPaletteManager()->setPalette(colorPalette, 0, 16);
-}
-
-
 void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) {
 	uint8 *data = _packedBitmaps + _packedItemPos[index];
 	uint16 width = READ_BE_UINT16(data);
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 564bfb6..af8b0d3 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -656,7 +656,6 @@ public:
 	void f479_loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader	
 	void f460_initializeGraphicData(); // @ F0460_START_InitializeGraphicData
 	void f96_loadCurrentMapGraphics(); // @ F0096_DUNGEONVIEW_LoadCurrentMapGraphics_CPSDF
-	void loadPalette(uint16 *palette);
 	void f461_allocateFlippedWallBitmaps(); // @ F0461_START_AllocateFlippedWallBitmaps
 	void f102_drawDoorBitmap(Frame *frame);// @ F0102_DUNGEONVIEW_DrawDoorBitmap
 	void f103_drawDoorFrameBitmapFlippedHorizontally(byte *bitmap, Frame *frame); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally


Commit: 6113b75ca9ca7d288cc0ea8e171ee6c44ca90e1e
    https://github.com/scummvm/scummvm/commit/6113b75ca9ca7d288cc0ea8e171ee6c44ca90e1e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Complete DisplayMan::f436_STARTEND_fadeToPalette

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index e42e228..f5ecade 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -704,7 +704,6 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_g99_bitmapWall_D0R_Native = nullptr;
 
 	_g322_paletteSwitchingEnabled = false;
-	warning(false, "DUMMY CODE: setting _g304_dungeonViewPaletteIndex");
 	_g304_dungeonViewPaletteIndex = 0;
 
 	g186_doorFrame_D1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
@@ -729,9 +728,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	for (uint16 i = 0; i < 32; i++)
 		_g345_aui_BlankBuffer[i] = 0;
 
-	// HACK
-	memcpy(_g346_paletteMiddleScreen, g20_PalEntrance, sizeof(uint16) * 16);
-	memcpy(_g347_paletteTopAndBottomScreen, g20_PalEntrance, sizeof(uint16) * 16);
+	_gK17_paletteFadeFrom = nullptr;
 }
 
 DisplayMan::~DisplayMan() {
@@ -3670,6 +3667,78 @@ uint16 DisplayMan::f431_getDarkenedColor(uint16 RGBcolor) {
 	return RGBcolor;
 }
 
+void DisplayMan::f436_STARTEND_FadeToPalette(uint16* P0849_pui_Palette) {
+	static uint16 K0016_aui_Palette_FadeTemporary[16];
+	uint16 L1374_ui_CurrentRGBColor;
+	int16 L1375_ui_TargetRGBColor;
+	int16 L1376_i_Color;
+	int16 L1377_i_Counter;
+	uint16* L1378_pui_PaletteRegister;
+
+
+	L1378_pui_PaletteRegister = K0016_aui_Palette_FadeTemporary;
+	for (L1376_i_Color = 0; L1376_i_Color < 16; L1376_i_Color++) {
+		L1378_pui_PaletteRegister[L1376_i_Color] = _gK17_paletteFadeFrom[L1376_i_Color];
+	}
+	for (L1377_i_Counter = 0; L1377_i_Counter < 8; L1377_i_Counter++) {
+		for (L1376_i_Color = 0, L1378_pui_PaletteRegister = K0016_aui_Palette_FadeTemporary; L1376_i_Color < 16; L1376_i_Color++, L1378_pui_PaletteRegister++) {
+			L1374_ui_CurrentRGBColor = getFlag(*L1378_pui_PaletteRegister, D12_MASK_BLUE_COMPONENT);
+			L1375_ui_TargetRGBColor = getFlag(P0849_pui_Palette[L1376_i_Color], D12_MASK_BLUE_COMPONENT);
+			if (L1374_ui_CurrentRGBColor > L1375_ui_TargetRGBColor) {
+				if (L1374_ui_CurrentRGBColor > L1375_ui_TargetRGBColor + 1) {
+					*L1378_pui_PaletteRegister -= 2;
+				} else {
+					*L1378_pui_PaletteRegister -= 1;
+				}
+			} else {
+				if (L1374_ui_CurrentRGBColor < L1375_ui_TargetRGBColor) {
+					if (L1374_ui_CurrentRGBColor < L1375_ui_TargetRGBColor - 1) {
+						*L1378_pui_PaletteRegister += 2;
+					} else {
+						*L1378_pui_PaletteRegister += 1;
+					}
+				}
+			}
+			L1374_ui_CurrentRGBColor = getFlag(*L1378_pui_PaletteRegister, D11_MASK_GREEN_COMPONENT) >> 4;
+			L1375_ui_TargetRGBColor = getFlag(P0849_pui_Palette[L1376_i_Color], D11_MASK_GREEN_COMPONENT) >> 4;
+			if (L1374_ui_CurrentRGBColor > L1375_ui_TargetRGBColor) {
+				if (L1374_ui_CurrentRGBColor > L1375_ui_TargetRGBColor + 1) {
+					*L1378_pui_PaletteRegister -= 32;
+				} else {
+					*L1378_pui_PaletteRegister -= 16;
+				}
+			} else {
+				if (L1374_ui_CurrentRGBColor < L1375_ui_TargetRGBColor) {
+					if (L1374_ui_CurrentRGBColor < L1375_ui_TargetRGBColor - 1) {
+						*L1378_pui_PaletteRegister += 32;
+					} else {
+						*L1378_pui_PaletteRegister += 16;
+					}
+				}
+			}
+			L1374_ui_CurrentRGBColor = getFlag(*L1378_pui_PaletteRegister, D10_MASK_RED_COMPONENT) >> 8;
+			L1375_ui_TargetRGBColor = getFlag(P0849_pui_Palette[L1376_i_Color], D10_MASK_RED_COMPONENT) >> 8;
+			if (L1374_ui_CurrentRGBColor > L1375_ui_TargetRGBColor) {
+				if (L1374_ui_CurrentRGBColor > L1375_ui_TargetRGBColor + 1) {
+					*L1378_pui_PaletteRegister -= 512;
+				} else {
+					*L1378_pui_PaletteRegister -= 256;
+				}
+			} else {
+				if (L1374_ui_CurrentRGBColor < L1375_ui_TargetRGBColor) {
+					if (L1374_ui_CurrentRGBColor < L1375_ui_TargetRGBColor - 1) {
+						*L1378_pui_PaletteRegister += 512;
+					} else {
+						*L1378_pui_PaletteRegister += 256;
+					}
+				}
+			}
+		}
+		_vm->f22_delay(1);
+		f508_buildPaletteChangeCopperList(K0016_aui_Palette_FadeTemporary, K0016_aui_Palette_FadeTemporary);
+	}
+}
+
 void DisplayMan::f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom) {
 	// memcpy(_g347_paletteTopAndBottomScreen, topAndBottom, sizeof(uint16) * 16);
 	// memcpy(_g346_paletteMiddleScreen, middleScreen, sizeof(uint16) * 16);
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index af8b0d3..091f40b 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -629,6 +629,8 @@ private:
 	int16 _g693_doorNativeBitmapIndex_Front_D3LCR[2]; // @ G0693_ai_DoorNativeBitmapIndex_Front_D3LCR
 	int16 _g694_doorNativeBitmapIndex_Front_D2LCR[2]; // @ G0694_ai_DoorNativeBitmapIndex_Front_D2LCR
 	int16 _g695_doorNativeBitmapIndex_Front_D1LCR[2]; // @ G0695_ai_DoorNativeBitmapIndex_Front_D1LCR
+
+	uint16 *_gK17_paletteFadeFrom; // @ K0017_pui_Palette_FadeFrom
 public:
 
 	uint16 _screenWidth;
@@ -748,8 +750,8 @@ public:
 	void f493_addDerivedBitmap(int16 derivedBitmapIndex); // @ F0493_CACHE_AddDerivedBitmap
 	void f480_releaseBlock(uint16 index); // @ F0480_CACHE_ReleaseBlock
 	uint16 f431_getDarkenedColor(uint16 RGBcolor);
-	void f436_STARTEND_FadeToPalette(uint16 *P0849_pui_Palette) { warning(false, "STUB METHOD: f436_STARTEND_FadeToPalette"); }
 	void f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom);
+	void f436_STARTEND_FadeToPalette(uint16 *P0849_pui_Palette); // @ F0436_STARTEND_FadeToPalette
 	void f136_shadeScreenBox(Box* box, Color color) { warning(false, "STUB METHOD: f136_shadeScreenBox"); } // @ F0136_VIDEO_ShadeScreenBox
 };
 


Commit: 5fb1b3e808730bfca8856ebd7b60b20081bae1b3
    https://github.com/scummvm/scummvm/commit/5fb1b3e808730bfca8856ebd7b60b20081bae1b3
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing code related to palettes

Changed paths:
    engines/dm/dm.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/loadsave.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 59151a9..b6b71fc 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -279,8 +279,10 @@ void DMEngine::f463_initializeGame() {
 void DMEngine::f448_initMemoryManager() {
 	warning(false, "STUB METHOD: f448_initMemoryManager");
 	_displayMan->f508_buildPaletteChangeCopperList(gK57_PalSwoosh, gK57_PalSwoosh);
-	for (uint16 i = 0; i < 16; ++i)
+	for (uint16 i = 0; i < 16; ++i) {
 		_displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i];
+		_displayMan->_g346_paletteMiddleScreen[i] = g21_PalDungeonView[0][i];
+	}
 }
 
 void DMEngine::f462_startGame() {
@@ -307,6 +309,7 @@ void DMEngine::f462_startGame() {
 	f3_processNewPartyMap(_dungeonMan->_g309_partyMapIndex);
 
 	if (!_g298_newGame) {
+		_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);
 		_displayMan->_g578_useByteBoxCoordinates = false;
 		f22_delay(1);
 		_displayMan->D24_fillScreenBox(boxScreenTop, k0_ColorBlack);
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index f5ecade..06781c8 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1201,10 +1201,10 @@ byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale
 void DisplayMan::updateScreen() {
 	// apply copper
 	warning(false, "Top of the screen color is offset as well"); // loop should start from 320 * 30
-	for (uint32 i = 0; i < 320 * 170; ++i)
+	for (uint32 i = 320 * 30; i < 320 * 170; ++i)
 		_g348_bitmapScreen[i] += 16;
 	_vm->_system->copyRectToScreen(_g348_bitmapScreen, _screenWidth, 0, 0, _screenWidth, _screenHeight);
-	for (uint32 i = 0; i < 320 * 170; ++i) // loop should start from 320 * 30
+	for (uint32 i = 320 * 30; i < 320 * 170; ++i) // loop should start from 320 * 30
 		_g348_bitmapScreen[i] -= 16;
 	_vm->_console->onFrame();
 	_vm->_system->updateScreen();
@@ -3740,8 +3740,7 @@ void DisplayMan::f436_STARTEND_FadeToPalette(uint16* P0849_pui_Palette) {
 }
 
 void DisplayMan::f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom) {
-	// memcpy(_g347_paletteTopAndBottomScreen, topAndBottom, sizeof(uint16) * 16);
-	// memcpy(_g346_paletteMiddleScreen, middleScreen, sizeof(uint16) * 16);
+	_gK17_paletteFadeFrom = topAndBottom;
 	byte colorPalette[32 * 3];
 	for (int i = 0; i < 16; ++i) {
 		colorPalette[i * 3] = (topAndBottom[i] >> 8) * (256 / 16);
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 091f40b..e44709e 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -750,8 +750,8 @@ public:
 	void f493_addDerivedBitmap(int16 derivedBitmapIndex); // @ F0493_CACHE_AddDerivedBitmap
 	void f480_releaseBlock(uint16 index); // @ F0480_CACHE_ReleaseBlock
 	uint16 f431_getDarkenedColor(uint16 RGBcolor);
-	void f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom);
 	void f436_STARTEND_FadeToPalette(uint16 *P0849_pui_Palette); // @ F0436_STARTEND_FadeToPalette
+	void f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom); // @ F0508_AMIGA_BuildPaletteChangeCopperList
 	void f136_shadeScreenBox(Box* box, Color color) { warning(false, "STUB METHOD: f136_shadeScreenBox"); } // @ F0136_VIDEO_ShadeScreenBox
 };
 
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 3563fb5..806e226 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -45,6 +45,7 @@ namespace DM {
 #define C10_DUNGEON_DM 10
 
 LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
+	bool L1366_B_FadePalette = true;
 	Common::String fileName;
 	Common::SaveFileManager *saveFileManager = nullptr;
 	Common::InSaveFile *file = nullptr;
@@ -142,15 +143,12 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		_timeline->f233_initTimeline();
 		_groupMan->f196_initActiveGroups();
 
-		warning(false, "Disabled code in f435_loadgame");
-#if 0
 		if (L1366_B_FadePalette) {
 			_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
-			D26_WaitForVerticalBlank();
-			D18_FillScreenBlack();
+			f22_delay(1);
+			_displayMan->fillScreen(k0_ColorBlack);
 			_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);
 		}
-#endif
 	} else {
 		_g528_saveFormat = dmSaveHeader._saveFormat;
 		_g527_platform = dmSaveHeader._platform;


Commit: 629e0c1a6ddb9132c77c2a5eac0bdb0365b47ee5
    https://github.com/scummvm/scummvm/commit/629e0c1a6ddb9132c77c2a5eac0bdb0365b47ee5
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix building copper

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 06781c8..564e413 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -36,6 +36,7 @@
 #include "group.h"
 #include "timeline.h"
 #include "champion.h"
+#include "eventman.h"
 
 
 namespace DM {
@@ -1200,14 +1201,13 @@ byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale
 
 void DisplayMan::updateScreen() {
 	// apply copper
-	warning(false, "Top of the screen color is offset as well"); // loop should start from 320 * 30
 	for (uint32 i = 320 * 30; i < 320 * 170; ++i)
 		_g348_bitmapScreen[i] += 16;
 	_vm->_system->copyRectToScreen(_g348_bitmapScreen, _screenWidth, 0, 0, _screenWidth, _screenHeight);
-	for (uint32 i = 320 * 30; i < 320 * 170; ++i) // loop should start from 320 * 30
-		_g348_bitmapScreen[i] -= 16;
 	_vm->_console->onFrame();
 	_vm->_system->updateScreen();
+	for (uint32 i = 320 * 30; i < 320 * 170; ++i)
+		_g348_bitmapScreen[i] -= 16;
 }
 
 void DisplayMan::f97_drawViewport(int16 palSwitchingRequestedState) {
@@ -3735,6 +3735,7 @@ void DisplayMan::f436_STARTEND_FadeToPalette(uint16* P0849_pui_Palette) {
 			}
 		}
 		_vm->f22_delay(1);
+		_vm->_eventMan->f357_discardAllInput();
 		f508_buildPaletteChangeCopperList(K0016_aui_Palette_FadeTemporary, K0016_aui_Palette_FadeTemporary);
 	}
 }
@@ -3748,9 +3749,9 @@ void DisplayMan::f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16*
 		colorPalette[i * 3 + 2] = topAndBottom[i] * (256 / 16);
 	}
 	for (int i = 16; i < 32; ++i) {
-		colorPalette[i * 3] = (middleScreen[i] >> 8) * (256 / 16);
-		colorPalette[i * 3 + 1] = (middleScreen[i] >> 4) * (256 / 16);
-		colorPalette[i * 3 + 2] = middleScreen[i] * (256 / 16);
+		colorPalette[i * 3] = (middleScreen[i - 16] >> 8) * (256 / 16);
+		colorPalette[i * 3 + 1] = (middleScreen[i - 16] >> 4) * (256 / 16);
+		colorPalette[i * 3 + 2] = middleScreen[i - 16] * (256 / 16);
 	}
 	_vm->_system->getPaletteManager()->setPalette(colorPalette, 0, 32);
 }


Commit: d36b492b61325b74173c8131a0d9103803365975
    https://github.com/scummvm/scummvm/commit/d36b492b61325b74173c8131a0d9103803365975
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove a useless variable in f374_processType80_clickInDungeonViewDropLeaderHandObject

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 3fbc95f..a2bbc5f 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1237,8 +1237,6 @@ void EventManager::f373_processType80_clickInDungeonView_grabLeaderHandObject(ui
 }
 
 void EventManager::f374_processType80_clickInDungeonViewDropLeaderHandObject(uint16 viewCell) {
-	int16 L1144_i_IconIndex;
-
 	if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone)
 		return;
 
@@ -1254,7 +1252,7 @@ void EventManager::f374_processType80_clickInDungeonViewDropLeaderHandObject(uin
 	uint16 currCell = M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + viewCell);
 	Thing removedThing = _vm->_championMan->f298_getObjectRemovedFromLeaderHand();
 	_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(removedThing, currCell), kM1_MapXNotOnASquare, 0, mapX, mapY);
-	if (droppingIntoAnAlcove && _vm->_dungeonMan->_g287_isFacingViAltar && ((L1144_i_IconIndex = _vm->_objectMan->f33_getIconIndex(removedThing)) == k147_IconIndiceJunkChampionBones)) {
+	if (droppingIntoAnAlcove && _vm->_dungeonMan->_g287_isFacingViAltar && (_vm->_objectMan->f33_getIconIndex(removedThing) == k147_IconIndiceJunkChampionBones)) {
 		Junk *removedJunk = (Junk*)_vm->_dungeonMan->f156_getThingData(removedThing);
 		TimelineEvent newEvent;
 		M33_setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 1);


Commit: 94e0dbc3fe806ee1391fa1d5d4f544e76a271fd2
    https://github.com/scummvm/scummvm/commit/94e0dbc3fe806ee1391fa1d5d4f544e76a271fd2
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f367_commandProcessTypes12to27_clickInChampionStatusBox, f70_mouseProcessCommands125To128_clickOnChampionIcon,

f370_commandProcessType100_clickInSpellArea, f369_commandProcessTypes101To108_clickInSpellSymbolsArea and
f371_commandProcessType111To115_ClickInActionArea

Changed paths:
    engines/dm/eventman.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index a2bbc5f..5d473fc 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1296,26 +1296,21 @@ void EventManager::f364_commandTakeStairs(bool stairsGoDown) {
 }
 
 void EventManager::f367_commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX, int16 posY) {
-	uint16 L1126_ui_Command;
-
 	if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 		f368_commandSetLeader((ChampionIndex)champIndex);
 	} else {
-		L1126_ui_Command = f358_getCommandTypeFromMouseInput(g455_MouseInput_ChampionNamesHands, Common::Point(posX, posY), k1_LeftMouseButton);
-		if ((L1126_ui_Command >= k16_CommandSetLeaderChampion_0) && (L1126_ui_Command <= k19_CommandSetLeaderChampion_3)) {
-			f368_commandSetLeader((ChampionIndex)(L1126_ui_Command - k16_CommandSetLeaderChampion_0));
-		} else {
-			if ((L1126_ui_Command >= k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand) && (L1126_ui_Command <= k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand)) {
-				_vm->_championMan->f302_processCommands28to65_clickOnSlotBox(L1126_ui_Command - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
-			}
-		}
+		uint16 commandType = f358_getCommandTypeFromMouseInput(g455_MouseInput_ChampionNamesHands, Common::Point(posX, posY), k1_LeftMouseButton);
+		if ((commandType >= k16_CommandSetLeaderChampion_0) && (commandType <= k19_CommandSetLeaderChampion_3))
+			f368_commandSetLeader((ChampionIndex)(commandType - k16_CommandSetLeaderChampion_0));
+		else if ((commandType >= k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand) && (commandType <= k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand))
+			_vm->_championMan->f302_processCommands28to65_clickOnSlotBox(commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
 	}
 }
 
 void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex) {
-	static Box G0621_s_Box_MousePointer_ChampionIconShadow = Box(2, 20, 2, 15);
-	static Box G0622_s_Box_MousePointer_ChampionIcon = Box(0, 18, 0, 13);
-	static byte G0045_auc_Graphic562_PaletteChanges_MousePointerIconShadow[16] = {0, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 0, 120, 120, 120};
+	static Box championIconShadowBox = Box(2, 20, 2, 15);
+	static Box championIconBox = Box(0, 18, 0, 13);
+	static byte mousePointerIconShadowBox[16] = {0, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 0, 120, 120, 120};
 
 	_gK100_preventBuildPointerScreenArea = true;
 	if (!_g599_useChampionIconOrdinalAsMousePointerBitmap) {
@@ -1326,38 +1321,35 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 		_g598_mousePointerBitmapUpdated = true;
 		_g599_useChampionIconOrdinalAsMousePointerBitmap = true;
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		byte *L0056_puc_Bitmap = _gK190_mousePointerTempBuffer;
-		memset(L0056_puc_Bitmap, 0, 32 * 18);
-		Box *L0055_pi_ChampionIconBox = &g54_BoxChampionIcons[champIconIndex];
-
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, L0056_puc_Bitmap, G0621_s_Box_MousePointer_ChampionIconShadow, L0055_pi_ChampionIconBox->_x1, L0055_pi_ChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
-
-		_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(L0056_puc_Bitmap, _g613_mousePointerOriginalColorsChampionIcon, 32, 18, 32, 18, G0045_auc_Graphic562_PaletteChanges_MousePointerIconShadow);
-
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, _g613_mousePointerOriginalColorsChampionIcon, G0622_s_Box_MousePointer_ChampionIcon, L0055_pi_ChampionIconBox->_x1, L0055_pi_ChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
-
-		_vm->_displayMan->D24_fillScreenBox(*L0055_pi_ChampionIconBox, k0_ColorBlack);
+		byte *tmpBitmap = _gK190_mousePointerTempBuffer;
+		memset(tmpBitmap, 0, 32 * 18);
+		Box *curChampionIconBox = &g54_BoxChampionIcons[champIconIndex];
+
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, tmpBitmap, championIconShadowBox, curChampionIconBox->_x1, curChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
+		_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(tmpBitmap, _g613_mousePointerOriginalColorsChampionIcon, 32, 18, 32, 18, mousePointerIconShadowBox);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, _g613_mousePointerOriginalColorsChampionIcon, championIconBox, curChampionIconBox->_x1, curChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
+		_vm->_displayMan->D24_fillScreenBox(*curChampionIconBox, k0_ColorBlack);
 		_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(champIconIndex);
 	} else {
 		_g598_mousePointerBitmapUpdated = true;
-		uint16 L0052_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_g599_useChampionIconOrdinalAsMousePointerBitmap);
+		uint16 championIconIndex = _vm->M1_ordinalToIndex(_g599_useChampionIconOrdinalAsMousePointerBitmap);
 		_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
-		int16 L0054_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(L0052_ui_ChampionIconIndex + _vm->_dungeonMan->_g308_partyDir));
-		if (L0052_ui_ChampionIconIndex == champIconIndex) {
-			setFlag(_vm->_championMan->_gK71_champions[L0054_i_ChampionIndex]._attributes, k0x0400_ChampionAttributeIcon);
-			_vm->_championMan->f292_drawChampionState((ChampionIndex)L0054_i_ChampionIndex);
+		int16 championCellIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(championIconIndex + _vm->_dungeonMan->_g308_partyDir));
+		if (championIconIndex == champIconIndex) {
+			setFlag(_vm->_championMan->_gK71_champions[championCellIndex]._attributes, k0x0400_ChampionAttributeIcon);
+			_vm->_championMan->f292_drawChampionState((ChampionIndex)championCellIndex);
 		} else {
-			int16 L0053_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir));
-			if (L0053_i_ChampionIndex >= 0) {
-				_vm->_championMan->_gK71_champions[L0053_i_ChampionIndex]._cell = (ViewCell)M21_normalizeModulo4(L0052_ui_ChampionIconIndex + _vm->_dungeonMan->_g308_partyDir);
-				setFlag(_vm->_championMan->_gK71_champions[L0053_i_ChampionIndex]._attributes, k0x0400_ChampionAttributeIcon);
-				_vm->_championMan->f292_drawChampionState((ChampionIndex)L0053_i_ChampionIndex);
-			} else {
-				_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[L0052_ui_ChampionIconIndex], k0_ColorBlack);
-			}
-			_vm->_championMan->_gK71_champions[L0054_i_ChampionIndex]._cell = (ViewCell)M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir);
-			setFlag(_vm->_championMan->_gK71_champions[L0054_i_ChampionIndex]._attributes, k0x0400_ChampionAttributeIcon);
-			_vm->_championMan->f292_drawChampionState((ChampionIndex)L0054_i_ChampionIndex);
+			int16 championIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir));
+			if (championIndex >= 0) {
+				_vm->_championMan->_gK71_champions[championIndex]._cell = (ViewCell)M21_normalizeModulo4(championIconIndex + _vm->_dungeonMan->_g308_partyDir);
+				setFlag(_vm->_championMan->_gK71_champions[championIndex]._attributes, k0x0400_ChampionAttributeIcon);
+				_vm->_championMan->f292_drawChampionState((ChampionIndex)championIndex);
+			} else
+				_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[championIconIndex], k0_ColorBlack);
+
+			_vm->_championMan->_gK71_champions[championCellIndex]._cell = (ViewCell)M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir);
+			setFlag(_vm->_championMan->_gK71_champions[championCellIndex]._attributes, k0x0400_ChampionAttributeIcon);
+			_vm->_championMan->f292_drawChampionState((ChampionIndex)championCellIndex);
 		}
 	}
 	_gK100_preventBuildPointerScreenArea = false;
@@ -1365,78 +1357,60 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 }
 
 void EventManager::f370_commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY) {
-	int16 L1132_i_Command;
-	int16 L1133_i_ChampionIndex;
-
-
-	L1133_i_ChampionIndex = kM1_ChampionNone;
+	int16 championIndex = kM1_ChampionNone;
 	if (posY <= 48) {
 		switch (_vm->_championMan->_g514_magicCasterChampionIndex) {
 		case 0:
-			if ((posX >= 280) && (posX <= 291)) {
-				L1133_i_ChampionIndex = 1;
-			} else {
-				if ((posX >= 294) && (posX <= 305)) {
-					L1133_i_ChampionIndex = 2;
-				} else {
-					if (posX >= 308) {
-						L1133_i_ChampionIndex = 3;
-					}
-				}
-			}
+			if ((posX >= 280) && (posX <= 291))
+				championIndex = 1;
+			else if ((posX >= 294) && (posX <= 305))
+				championIndex = 2;
+			else if (posX >= 308)
+				championIndex = 3;
+
 			break;
 		case 1:
-			if ((posX >= 233) && (posX <= 244)) {
-				L1133_i_ChampionIndex = 0;
-			} else {
-				if ((posX >= 294) && (posX <= 305)) {
-					L1133_i_ChampionIndex = 2;
-				} else {
-					if (posX >= 308) {
-						L1133_i_ChampionIndex = 3;
-					}
-				}
-			}
+			if ((posX >= 233) && (posX <= 244))
+				championIndex = 0;
+			else if ((posX >= 294) && (posX <= 305))
+				championIndex = 2;
+			else if (posX >= 308)
+				championIndex = 3;
+
 			break;
 		case 2:
-			if ((posX >= 233) && (posX <= 244)) {
-				L1133_i_ChampionIndex = 0;
-			} else {
-				if ((posX >= 247) && (posX <= 258)) {
-					L1133_i_ChampionIndex = 1;
-				} else {
-					if (posX >= 308) {
-						L1133_i_ChampionIndex = 3;
-					}
-				}
-			}
+			if ((posX >= 233) && (posX <= 244))
+				championIndex = 0;
+			else if ((posX >= 247) && (posX <= 258))
+				championIndex = 1;
+			else if (posX >= 308)
+				championIndex = 3;
+
 			break;
 		case 3:
-			if ((posX >= 247) && (posX <= 258)) {
-				L1133_i_ChampionIndex = 1;
-			} else {
-				if ((posX >= 261) && (posX <= 272)) {
-					L1133_i_ChampionIndex = 2;
-				} else {
-					if (posX <= 244) {
-						L1133_i_ChampionIndex = 0;
-					}
-				}
-			}
-		}
-		if ((L1133_i_ChampionIndex != kM1_ChampionNone) && (L1133_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount)) {
-			_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(L1133_i_ChampionIndex);
+			if ((posX >= 247) && (posX <= 258))
+				championIndex = 1;
+			else if ((posX >= 261) && (posX <= 272))
+				championIndex = 2;
+			else if (posX <= 244)
+				championIndex = 0;
+
+			break;
 		}
+
+		if ((championIndex != kM1_ChampionNone) && (championIndex < _vm->_championMan->_g305_partyChampionCount))
+			_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(championIndex);
+
 		return;
 	}
-	L1132_i_Command = f358_getCommandTypeFromMouseInput(g454_MouseInput_SpellArea, Common::Point(posX, posY), k1_LeftMouseButton);
-	if (L1132_i_Command != k0_CommandNone) {
-		f369_commandProcessTypes101To108_clickInSpellSymbolsArea((CommandType)L1132_i_Command);
-	}
+
+	CommandType newCommand = f358_getCommandTypeFromMouseInput(g454_MouseInput_SpellArea, Common::Point(posX, posY), k1_LeftMouseButton);
+	if (newCommand != k0_CommandNone)
+		f369_commandProcessTypes101To108_clickInSpellSymbolsArea(newCommand);
 }
 
 void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType) {
-	static Box G0464_as_Graphic561_Box_SpellSymbolsAndDelete[7] = {
+	static Box spellSymbolsAndDelete[7] = {
 		/* { X1, X2, Y1, Y2 } */
 		Box(235, 247, 51, 61),   /* Symbol 1 */
 		Box(249, 261, 51, 61),   /* Symbol 2 */
@@ -1446,63 +1420,51 @@ void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(Comm
 		Box(305, 317, 51, 61),   /* Symbol 6 */
 		Box(305, 318, 63, 73)}; /* Delete */
 
-	uint16 L1130_ui_SymbolIndex;
-	Box* L1131_ps_Box;
-
-
 	if (cmdType == k108_CommandClickInSpeallAreaCastSpell) {
-		if (_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex]._symbols[0] == '\0') {
+		if (_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex]._symbols[0] == '\0')
 			return;
-		}
+
 		f362_commandHighlightBoxEnable(234, 303, 63, 73);
 		_vm->_g321_stopWaitingForPlayerInput = _vm->_menuMan->f408_getClickOnSpellCastResult();
 		return;
 	}
-	L1130_ui_SymbolIndex = cmdType - k101_CommandClickInSpellAreaSymbol_1;
-	L1131_ps_Box = &G0464_as_Graphic561_Box_SpellSymbolsAndDelete[L1130_ui_SymbolIndex];
-	f362_commandHighlightBoxEnable(L1131_ps_Box->_x1, L1131_ps_Box->_x2, L1131_ps_Box->_y1, L1131_ps_Box->_y2);
+
+	uint16 symbolIndex = cmdType - k101_CommandClickInSpellAreaSymbol_1;
+	Box *highlightBox = &spellSymbolsAndDelete[symbolIndex];
+	f362_commandHighlightBoxEnable(highlightBox->_x1, highlightBox->_x2, highlightBox->_y1, highlightBox->_y2);
 	_vm->f22_delay(1);
 	f363_highlightBoxDisable();
-	if (L1130_ui_SymbolIndex < 6) {
-		_vm->_menuMan->f399_addChampionSymbol(L1130_ui_SymbolIndex);
-	} else {
+
+	if (symbolIndex < 6)
+		_vm->_menuMan->f399_addChampionSymbol(symbolIndex);
+	else
 		_vm->_menuMan->f400_deleteChampionSymbol();
-	}
 }
 
 void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY) {
-	uint16 L1134_ui_Command;
-
-
 	if (_vm->_championMan->_g506_actingChampionOrdinal) {
-		L1134_ui_Command = f358_getCommandTypeFromMouseInput(g452_MouseInput_ActionAreaNames, Common::Point(posX, posY), k1_LeftMouseButton);
-		if (L1134_ui_Command != k0_CommandNone) {
-			if (L1134_ui_Command == k112_CommandClickInActionAreaPass) {
+		uint16 mouseCommand = f358_getCommandTypeFromMouseInput(g452_MouseInput_ActionAreaNames, Common::Point(posX, posY), k1_LeftMouseButton);
+		if (mouseCommand != k0_CommandNone) {
+			if (mouseCommand == k112_CommandClickInActionAreaPass) {
 				f362_commandHighlightBoxEnable(285, 319, 77, 83);
 				_vm->_menuMan->f391_didClickTriggerAction(-1);
-			} else {
-				if ((L1134_ui_Command - k112_CommandClickInActionAreaPass) <= _vm->_menuMan->_g507_actionCount) {
-					if (L1134_ui_Command == k113_CommandClickInActionAreaAction_0) {
-						f362_commandHighlightBoxEnable(234, 318, 86, 96);
-					} else {
-						if (L1134_ui_Command == k114_CommandClickInActionAreaAction_1) {
-							f362_commandHighlightBoxEnable(234, 318, 98, 108);
-						} else {
-							f362_commandHighlightBoxEnable(234, 318, 110, 120);
-						}
-					}
-					_vm->_g321_stopWaitingForPlayerInput = _vm->_menuMan->f391_didClickTriggerAction(L1134_ui_Command - k113_CommandClickInActionAreaAction_0);
-				}
+			} else if ((mouseCommand - k112_CommandClickInActionAreaPass) <= _vm->_menuMan->_g507_actionCount) {
+				if (mouseCommand == k113_CommandClickInActionAreaAction_0)
+					f362_commandHighlightBoxEnable(234, 318, 86, 96);
+				else if (mouseCommand == k114_CommandClickInActionAreaAction_1)
+					f362_commandHighlightBoxEnable(234, 318, 98, 108);
+				else
+					f362_commandHighlightBoxEnable(234, 318, 110, 120);
+
+				_vm->_g321_stopWaitingForPlayerInput = _vm->_menuMan->f391_didClickTriggerAction(mouseCommand - k113_CommandClickInActionAreaAction_0);
 			}
 		}
-	} else {
-		if (_vm->_menuMan->_g509_actionAreaContainsIcons) {
-			L1134_ui_Command = f358_getCommandTypeFromMouseInput(g453_MouseInput_ActionAreaIcons, Common::Point(posX, posY), k1_LeftMouseButton);
-			if (L1134_ui_Command != k0_CommandNone) {
-				if ((L1134_ui_Command = L1134_ui_Command - k116_CommandClickInActionAreaChampion_0_Action) < _vm->_championMan->_g305_partyChampionCount) {
-					_vm->_menuMan->f389_processCommands116To119_setActingChampion(L1134_ui_Command);
-				}
-			}
+	} else if (_vm->_menuMan->_g509_actionAreaContainsIcons) {
+		uint16 mouseCommand = f358_getCommandTypeFromMouseInput(g453_MouseInput_ActionAreaIcons, Common::Point(posX, posY), k1_LeftMouseButton);
+		if (mouseCommand != k0_CommandNone) {
+			mouseCommand -= k116_CommandClickInActionAreaChampion_0_Action;
+			if (mouseCommand < _vm->_championMan->_g305_partyChampionCount)
+				_vm->_menuMan->f389_processCommands116To119_setActingChampion(mouseCommand);
 		}
 	}
 }


Commit: 6ea782eeb57a5164e3bfdf4d9ff72e4bfa385f82
    https://github.com/scummvm/scummvm/commit/6ea782eeb57a5164e3bfdf4d9ff72e4bfa385f82
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Start moving globals to DisplayMan

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 564e413..dd4d349 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -41,10 +41,6 @@
 
 namespace DM {
 
-Box g106_BoxThievesEye_ViewPortVisibleArea(64, 159, 19, 113); // @ G0106_s_Graphic558_Box_ThievesEye_ViewportVisibleArea 
-byte g198_PalChangesDoorButtonAndWallOrn_D3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3
-byte g199_PalChangesDoorButtonAndWallOrn_D2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2
-
 byte g197_doorButtonCoordSet[1] = {0}; // @ G0197_auc_Graphic558_DoorButtonCoordinateSet
 
 uint16 g208_doorButtonCoordSets[1][4][6] = { // @ G0208_aaauc_Graphic558_DoorButtonCoordinateSets
@@ -655,9 +651,9 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 			_g101_currMapWallOrnInfo[j][i] = 0;
 			_g102_currMapFloorOrnInfo[j][i] = 0;
 		}
-		for (int j = 0; j < 17; j++) {
+
+		for (int j = 0; j < 17; j++)
 			_g103_currMapDoorOrnInfo[j][i] = 0;
-		}
 	}
 
 	for (int i = 0; i < 16; i++) {
@@ -707,20 +703,6 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_g322_paletteSwitchingEnabled = false;
 	_g304_dungeonViewPaletteIndex = 0;
 
-	g186_doorFrame_D1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
-		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-										Frame(64, 159, 17, 102, 48, 88, 0, 0),	/* Closed Or Destroyed */
-										Frame(64, 159, 17, 38, 48, 88, 0, 66),	/* Vertical Closed one fourth */
-										Frame(64, 159, 17, 60, 48, 88, 0, 44),	/* Vertical Closed half */
-										Frame(64, 159, 17, 82, 48, 88, 0, 22),	/* Vertical Closed three fourth */
-										Frame(64, 75, 17, 102, 48, 88, 36, 0),	/* Left Horizontal Closed one fourth */
-										Frame(64, 87, 17, 102, 48, 88, 24, 0),	/* Left Horizontal Closed half */
-										Frame(64, 99, 17, 102, 48, 88, 12, 0),	/* Left Horizontal Closed three fourth */
-										Frame(148, 159, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed one fourth */
-										Frame(136, 159, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed half */
-										Frame(124, 159, 17, 102, 48, 88, 48, 0)	/* Right Horizontal Closed three fourth */
-	);
-
 	for (uint16 i = 0; i < 16; ++i) {
 		_g347_paletteTopAndBottomScreen[i] = 0;
 		_g346_paletteMiddleScreen[i] = 0;
@@ -730,6 +712,33 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 		_g345_aui_BlankBuffer[i] = 0;
 
 	_gK17_paletteFadeFrom = nullptr;
+
+	initConstants();
+}
+
+void DisplayMan::initConstants() {
+	const byte palChangesDoorButtonAndWallOrn_D3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3
+	const byte palChangesDoorButtonAndWallOrn_D2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2
+
+	for (int i = 0; i < 16; i++) {
+		g198_PalChangesDoorButtonAndWallOrn_D3[i] = palChangesDoorButtonAndWallOrn_D3[i];
+		g199_PalChangesDoorButtonAndWallOrn_D2[i] = palChangesDoorButtonAndWallOrn_D2[i];
+	}
+
+	g186_doorFrame_D1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
+		Frame(64, 159, 17, 102, 48, 88, 0, 0),	 /* Closed Or Destroyed */
+		Frame(64, 159, 17, 38, 48, 88, 0, 66),	 /* Vertical Closed one fourth */
+		Frame(64, 159, 17, 60, 48, 88, 0, 44),	 /* Vertical Closed half */
+		Frame(64, 159, 17, 82, 48, 88, 0, 22),	 /* Vertical Closed three fourth */
+		Frame(64, 75, 17, 102, 48, 88, 36, 0),	 /* Left Horizontal Closed one fourth */
+		Frame(64, 87, 17, 102, 48, 88, 24, 0),	 /* Left Horizontal Closed half */
+		Frame(64, 99, 17, 102, 48, 88, 12, 0),	 /* Left Horizontal Closed three fourth */
+		Frame(148, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */
+		Frame(136, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */
+		Frame(124, 159, 17, 102, 48, 88, 48, 0)	 /* Right Horizontal Closed three fourth */
+	);
+
+	g106_BoxThievesEye_ViewPortVisibleArea = Box(64, 159, 19, 113); // @ G0106_s_Graphic558_Box_ThievesEye_ViewportVisibleArea 
 }
 
 DisplayMan::~DisplayMan() {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index e44709e..c068b39 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -599,6 +599,10 @@ class DisplayMan {
 public:
 	byte *_g700_bitmapWallSet_Wall_D1LCR; // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR
 private:
+	Box g106_BoxThievesEye_ViewPortVisibleArea; // @ G0106_s_Graphic558_Box_ThievesEye_ViewportVisibleArea 
+	byte g198_PalChangesDoorButtonAndWallOrn_D3[16]; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3
+	byte g199_PalChangesDoorButtonAndWallOrn_D2[16]; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2
+
 	byte *_g701_bitmapWallSet_Wall_D0L; // @ G0701_puc_Bitmap_WallSet_Wall_D0L
 	byte *_g702_bitmapWallSet_Wall_D0R; // @ G0702_puc_Bitmap_WallSet_Wall_D0R
 	byte *_g703_bitmapWallSet_DoorFrameTop_D2LCR; // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR
@@ -753,6 +757,9 @@ public:
 	void f436_STARTEND_FadeToPalette(uint16 *P0849_pui_Palette); // @ F0436_STARTEND_FadeToPalette
 	void f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom); // @ F0508_AMIGA_BuildPaletteChangeCopperList
 	void f136_shadeScreenBox(Box* box, Color color) { warning(false, "STUB METHOD: f136_shadeScreenBox"); } // @ F0136_VIDEO_ShadeScreenBox
+
+private:
+	void initConstants();
 };
 
 }


Commit: c798b1ca02c248a86958d6b43b92f323bd2326e0
    https://github.com/scummvm/scummvm/commit/c798b1ca02c248a86958d6b43b92f323bd2326e0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add offset to debug command pos

Changed paths:
    engines/dm/console.cpp



diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index b8fae42..31a0e13 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -118,9 +118,10 @@ argumentError:
 }
 
 bool Console::Cmd_pos(int argc, const char** argv) {
+	DungeonMan &dm = *_vm->_dungeonMan;
 	if (argc == 2 && cstrEquals("get", argv[1])) {
-		debugPrintf("Position: (%d, %d)  Direction: %s\n", _vm->_dungeonMan->_g306_partyMapX,
-					_vm->_dungeonMan->_g307_partyMapY, debugGetDirectionName(_vm->_dungeonMan->_g308_partyDir));
+		debugPrintf("Position: (%d, %d)  Direction: %s\n", dm._g306_partyMapX + dm._g269_currMap->_offsetMapX,
+					dm._g307_partyMapY + dm._g269_currMap->_offsetMapY, debugGetDirectionName(_vm->_dungeonMan->_g308_partyDir));
 	} else if (argc == 4 && cstrEquals("set", argv[1])) {
 		int x = atoi(argv[2]);
 		int y = atoi(argv[3]);
@@ -131,9 +132,10 @@ bool Console::Cmd_pos(int argc, const char** argv) {
 
 		Map &currMap = *_vm->_dungeonMan->_g269_currMap;
 		// not >= because dimensions are inslucsive
-		if (x > currMap._width || y > currMap._height) {
+		if (x < currMap._offsetMapX || x > currMap._width + currMap._offsetMapX 
+			|| y < currMap._offsetMapY || y > currMap._height + currMap._offsetMapY) {
 			debugPrintf("Position (%d, %d) is out of bounds, possible values: ([1-%d],[1-%d])\n", x, y,
-						currMap._width, currMap._height);
+						currMap._width + currMap._offsetMapX, currMap._height + currMap._offsetMapY);
 			return true;
 		}
 
@@ -141,7 +143,8 @@ bool Console::Cmd_pos(int argc, const char** argv) {
 		if (haventWarned.check())
 			debugPrintf("Setting position directly can cause glitches and crashes.\n");
 		debugPrintf("Position set to (%d, %d)\n", x, y);
-		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, x, y);
+		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY,
+										   x - currMap._offsetMapX, y - currMap._offsetMapY);
 	} else
 		goto argumentError;
 


Commit: 0bd785e7eb72b10d58c4de7e82e44dd59fb0dda3
    https://github.com/scummvm/scummvm/commit/0bd785e7eb72b10d58c4de7e82e44dd59fb0dda3
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix addActiveGroup with groupGenerator

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/group.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index dd4d349..3287045 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -3645,8 +3645,7 @@ bool DisplayMan::f491_isDerivedBitmapInCache(int16 derivedBitmapIndex) {
 		_g638_derivedBitmaps[derivedBitmapIndex] = new byte[_g639_derivedBitmapByteCount[derivedBitmapIndex] * 2];
 		return false;
 	} else {
-		warning(false, "f491_isDerivedBitmapInCache always returns false");
-		return false;
+		return true;
 	}
 }
 
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 064b30d..e5c74fe 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1698,10 +1698,8 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
 	}
 	_g377_currActiveGroupCount++;
 
-	warning(false, "Code differs from the original in GroupMan::f183_addActiveGroup");
-	//L0340_ps_Group = ((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType());
-	L0341_ps_ActiveGroup->_groupThingIndex = thing.getType();
-	L0340_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(f175_groupGetThing(mapX, mapY));
+	L0340_ps_Group = (Group *)(_vm->_dungeonMan->_g284_thingData[k4_GroupThingType] + 
+		g235_ThingDataWordCount[k4_GroupThingType] * (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getIndex()));
 
 	L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells;
 	L0340_ps_Group->getActiveGroupIndex() = L0344_i_ActiveGroupIndex;


Commit: 8e2dac5fb592f8b2379b196b91fe1adba2ee67ff
    https://github.com/scummvm/scummvm/commit/8e2dac5fb592f8b2379b196b91fe1adba2ee67ff
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add DialogMan::f424_dialogGetChoice

Changed paths:
    engines/dm/dialog.cpp
    engines/dm/dialog.h



diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index e13cf31..248003d 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -39,8 +39,8 @@ DialogMan::DialogMan(DMEngine* vm) : _vm(vm) {
 
 void DialogMan::f427_dialogDraw(char* msg1, char* msg2, char* choice1, char* choice2, char* choice3, char* choice4, bool screenDialog, bool clearScreen, bool fading) {
 	static Box constBox1 = Box(0, 223, 101, 125);
-	static Box constBox2 = Box(0, 223,  76, 100);
-	static Box constBox3 = Box(0, 223,  51,  75);
+	static Box constBox2 = Box(0, 223, 76, 100);
+	static Box constBox3 = Box(0, 223, 51, 75);
 	static Box dialog2ChoicesPatch = Box(102, 122, 89, 125);
 	static Box dialog4ChoicesPatch = Box(102, 122, 62, 97);
 
@@ -137,6 +137,7 @@ void DialogMan::f427_dialogDraw(char* msg1, char* msg2, char* choice1, char* cho
 		_vm->_displayMan->f436_STARTEND_FadeToPalette(_vm->_displayMan->_g347_paletteTopAndBottomScreen);
 
 	_vm->_displayMan->_g297_drawFloorAndCeilingRequested = true;
+	_vm->_displayMan->updateScreen();
 }
 
 void DialogMan::f425_printCenteredChoice(byte* bitmap, char* str, int16 posX, int16 posY) {
@@ -160,4 +161,108 @@ bool DialogMan::f426_isMessageOnTwoLines(char* str, char* part1, char* part2) {
 	strcpy(part2, &part1[splitPosition + 1]);
 	return true;
 }
+
+int16 DialogMan::f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex, int16 driveType, int16 automaticChoiceIfFlopyInDrive) {
+	MouseInput* L1298_ps_PrimaryMouseInputBackup;
+	MouseInput* L1299_ps_SecondaryMouseInputBackup;
+	KeyboardInput* L1300_ps_PrimaryKeyboardInputBackup;
+	KeyboardInput* L1301_ps_SecondaryKeyboardInputBackup;
+	Box L1303_s_BoxB;
+	Box L1304_s_BoxA;
+
+	_vm->_eventMan->f77_hideMouse();
+	L1298_ps_PrimaryMouseInputBackup = _vm->_eventMan->_g441_primaryMouseInput;
+	L1299_ps_SecondaryMouseInputBackup = _vm->_eventMan->_g442_secondaryMouseInput;
+	L1300_ps_PrimaryKeyboardInputBackup = _vm->_eventMan->_g443_primaryKeyboardInput;
+	L1301_ps_SecondaryKeyboardInputBackup = _vm->_eventMan->_g444_secondaryKeyboardInput;
+	_vm->_eventMan->_g442_secondaryMouseInput = 0;
+	_vm->_eventMan->_g443_primaryKeyboardInput = nullptr;
+	_vm->_eventMan->_g444_secondaryKeyboardInput = nullptr;
+	_vm->_eventMan->_g441_primaryMouseInput = g480_PrimaryMouseInput_DialogSets[dialogSetIndex][choiceCount - 1];
+	_vm->_eventMan->f357_discardAllInput();
+	_g335_selectedDialogChoice = 99;
+	do {
+		Common::Event key;
+		Common::EventType eventType = _vm->_eventMan->processInput(&key);
+		_vm->_eventMan->f380_processCommandQueue();
+		_vm->_displayMan->updateScreen();
+		_vm->f22_delay(1);
+		if ((_g335_selectedDialogChoice == 99) && (choiceCount == 1) 
+			&& (eventType != Common::EVENT_INVALID) && key.kbd.keycode == Common::KEYCODE_RETURN) {
+			/* If a choice has not been made yet with the mouse and the dialog has only one possible choice and carriage return was pressed on the keyboard */
+			_g335_selectedDialogChoice = k1_DIALOG_CHOICE_1;
+		}
+	} while (_g335_selectedDialogChoice == 99);
+	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	L1304_s_BoxA = _vm->_eventMan->_g441_primaryMouseInput[_g335_selectedDialogChoice - 1]._hitbox;
+	L1304_s_BoxA._x1 -= 3;
+	L1304_s_BoxA._x2 += 3;
+	L1304_s_BoxA._y1 -= 3;
+	L1304_s_BoxA._y2 += 4;
+	_vm->_eventMan->f78_showMouse();
+	_vm->_displayMan->_g297_drawFloorAndCeilingRequested = true;
+	L1303_s_BoxB._x1 = 0;
+	L1303_s_BoxB._y1 = 0;
+	L1303_s_BoxB._y2 = L1304_s_BoxA._y2 - L1304_s_BoxA._y1 + 3;
+	L1303_s_BoxB._x2 = L1304_s_BoxA._x2 - L1304_s_BoxA._x1 + 3;
+	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_g296_bitmapViewport,
+										L1303_s_BoxB, L1304_s_BoxA._x1, L1304_s_BoxA._y1, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 25);
+	_vm->f22_delay(1);
+	L1303_s_BoxB = L1304_s_BoxA;
+	L1303_s_BoxB._y2 = L1303_s_BoxB._y1;
+	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
+	L1303_s_BoxB = L1304_s_BoxA;
+	L1303_s_BoxB._x2 = L1303_s_BoxB._x1;
+	L1303_s_BoxB._y2--;
+	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
+	L1303_s_BoxB = L1304_s_BoxA;
+	L1303_s_BoxB._y2--;
+	L1303_s_BoxB._y1 = L1303_s_BoxB._y2;
+	L1303_s_BoxB._x1 -= 2;
+	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
+	L1303_s_BoxB = L1304_s_BoxA;
+	L1303_s_BoxB._x1 = L1303_s_BoxB._x2;
+	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
+	_vm->f22_delay(5);
+	L1303_s_BoxB = L1304_s_BoxA;
+	L1303_s_BoxB._y1++;
+	L1303_s_BoxB._y2 = L1303_s_BoxB._y1;
+	L1303_s_BoxB._x2 -= 2;
+	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
+	L1303_s_BoxB = L1304_s_BoxA;
+	L1303_s_BoxB._x1++;
+	L1303_s_BoxB._x2 = L1303_s_BoxB._x1;
+	L1303_s_BoxB._y2--;
+	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
+	L1303_s_BoxB = L1304_s_BoxA;
+	L1303_s_BoxB._x2--;
+	L1303_s_BoxB._x1 = L1303_s_BoxB._x2;
+	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
+	L1303_s_BoxB = L1304_s_BoxA;
+	L1303_s_BoxB._y1 = L1303_s_BoxB._y2 = L1303_s_BoxB._y2 - 2;
+	L1303_s_BoxB._x1++;
+	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
+	L1303_s_BoxB = L1304_s_BoxA;
+	L1303_s_BoxB._y1 = L1303_s_BoxB._y2 = L1303_s_BoxB._y2 + 2;
+	L1303_s_BoxB._x1--;
+	L1303_s_BoxB._x2 += 2;
+	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k13_ColorLightestGray);
+	L1303_s_BoxB = L1304_s_BoxA;
+	L1303_s_BoxB._x1 = L1303_s_BoxB._x2 = L1303_s_BoxB._x2 + 3;
+	L1303_s_BoxB._y2 += 2;
+	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k13_ColorLightestGray);
+	_vm->f22_delay(5);
+	L1304_s_BoxA._x2 += 3;
+	L1304_s_BoxA._y2 += 3;
+	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g348_bitmapScreen,
+										L1304_s_BoxA, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 25, k200_heightScreen);
+	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->_g441_primaryMouseInput = L1298_ps_PrimaryMouseInputBackup;
+	_vm->_eventMan->_g442_secondaryMouseInput = L1299_ps_SecondaryMouseInputBackup;
+	_vm->_eventMan->_g443_primaryKeyboardInput = L1300_ps_PrimaryKeyboardInputBackup;
+	_vm->_eventMan->_g444_secondaryKeyboardInput = L1301_ps_SecondaryKeyboardInputBackup;
+	_vm->_eventMan->f357_discardAllInput();
+	_vm->_eventMan->f78_showMouse();
+	return _g335_selectedDialogChoice;
+}
 }
diff --git a/engines/dm/dialog.h b/engines/dm/dialog.h
index a4dd7e3..2aec5e9 100644
--- a/engines/dm/dialog.h
+++ b/engines/dm/dialog.h
@@ -30,6 +30,18 @@
 
 namespace DM {
 
+#define k0_DIALOG_SET_VIEWPORT 0
+#define k1_DIALOG_SET_SCREEN   1
+#define k2_DIALOG_SET_UNKNOWN  2
+#define k1_ONE_CHOICE          1
+#define k2_TWO_CHOICES         2
+#define k4_FOUR_CHOICES        4
+#define k0_DIALOG_CHOICE_NONE  0
+#define k1_DIALOG_CHOICE_1     1
+#define k2_DIALOG_CHOICE_2     2
+#define k3_DIALOG_CHOICE_3     3
+#define k4_DIALOG_CHOICE_4     4
+
 class DialogMan {
 	DMEngine *_vm;
 public:
@@ -39,6 +51,7 @@ public:
 						 char *choice3, char *choice4, bool screenDialog, bool clearScreen, bool fading); // @ F0427_DIALOG_Draw
 	void f425_printCenteredChoice(byte *bitmap, char *str, int16 posX, int16 posY); // @ F0425_DIALOG_PrintCenteredChoice
 	bool f426_isMessageOnTwoLines(char *str, char *part1, char *part2); // @ F0426_DIALOG_IsMessageOnTwoLines
+	int16 f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex, int16 driveType, int16 automaticChoiceIfFlopyInDrive); // @ F0424_DIALOG_GetChoice
 };
 
 }
\ No newline at end of file


Commit: e1ddc2d3ab9ce6920a5dffced67843fe5f0139a5
    https://github.com/scummvm/scummvm/commit/e1ddc2d3ab9ce6920a5dffced67843fe5f0139a5
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove trashing input from DMEngine::f22_delay

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index b6b71fc..d0ca2c8 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -235,7 +235,6 @@ bool DMEngine::hasFeature(EngineFeature f) const {
 
 void DMEngine::f22_delay(uint16 verticalBlank) {
 	for (uint16 i = 0; i < verticalBlank * 2; ++i) {
-		_eventMan->f357_discardAllInput();
 		_displayMan->updateScreen();
 		_system->delayMillis(10); // Google says most Amiga games had a refreshrate of 50 hz
 	}


Commit: 3cb1c6d6efd96f184996400f97e9387e73bd4e67
    https://github.com/scummvm/scummvm/commit/3cb1c6d6efd96f184996400f97e9387e73bd4e67
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Disable releaseBlock code in f115_cthulhu

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 3287045..e1b5137 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -3559,7 +3559,8 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 				}
 				f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, 0, f492_getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C, _vm->getRandomNumber(4) + 87, _vm->getRandomNumber(64), k112_byteWidthViewport, Color(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
 				f493_addDerivedBitmap(k0_DerivedBitmapViewport);
-				f480_releaseBlock(k0_DerivedBitmapViewport | 0x8000);
+				warning(false, "DISABLED CODE: f480_releaseBlock in f115_cthulhu");
+				//f480_releaseBlock(k0_DerivedBitmapViewport | 0x8000);
 			} else {
 				if (rebirthExplosion) {
 					explosionCoordinates = g227_RebirthStep2ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];


Commit: 151b2d64d9c42880673c873a8215bbe20f087101
    https://github.com/scummvm/scummvm/commit/151b2d64d9c42880673c873a8215bbe20f087101
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Adjust choose dialog responsiveness

Changed paths:
    engines/dm/dialog.cpp



diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index 248003d..943f8c5 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -175,7 +175,7 @@ int16 DialogMan::f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex,
 	L1299_ps_SecondaryMouseInputBackup = _vm->_eventMan->_g442_secondaryMouseInput;
 	L1300_ps_PrimaryKeyboardInputBackup = _vm->_eventMan->_g443_primaryKeyboardInput;
 	L1301_ps_SecondaryKeyboardInputBackup = _vm->_eventMan->_g444_secondaryKeyboardInput;
-	_vm->_eventMan->_g442_secondaryMouseInput = 0;
+	_vm->_eventMan->_g442_secondaryMouseInput = nullptr;
 	_vm->_eventMan->_g443_primaryKeyboardInput = nullptr;
 	_vm->_eventMan->_g444_secondaryKeyboardInput = nullptr;
 	_vm->_eventMan->_g441_primaryMouseInput = g480_PrimaryMouseInput_DialogSets[dialogSetIndex][choiceCount - 1];
@@ -185,8 +185,8 @@ int16 DialogMan::f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex,
 		Common::Event key;
 		Common::EventType eventType = _vm->_eventMan->processInput(&key);
 		_vm->_eventMan->f380_processCommandQueue();
-		_vm->_displayMan->updateScreen();
 		_vm->f22_delay(1);
+		_vm->_displayMan->updateScreen();
 		if ((_g335_selectedDialogChoice == 99) && (choiceCount == 1) 
 			&& (eventType != Common::EVENT_INVALID) && key.kbd.keycode == Common::KEYCODE_RETURN) {
 			/* If a choice has not been made yet with the mouse and the dialog has only one possible choice and carriage return was pressed on the keyboard */


Commit: a11ae306e417d4a538270b8a386ceddb539a5aae
    https://github.com/scummvm/scummvm/commit/a11ae306e417d4a538270b8a386ceddb539a5aae
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add dialog choice to savegame

Changed paths:
    engines/dm/loadsave.cpp



diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 806e226..408ad9c 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -164,18 +164,16 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 
 
 void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String desc) {
-	warning(false, "DUMMY CODE in f433_processCommand140_saveGame, saveAndPlayChoice is always 0");
-	int16 saveAndPlayChoice = 0;
 	char *message = nullptr;
 
 	_menuMan->f456_drawDisabledMenu();
 	_eventMan->f78_showMouse();
 
-	// do {
-	//		ask the player what he wants
-	// while 
+	// TODO: localization
+	_dialog->f427_dialogDraw(message, nullptr, "SAVE AND PLAY", "SAVE AND QUIT", "CANCEL", nullptr, false, false, false);
+	int16 saveAndPlayChoice = _dialog->f424_dialogGetChoice(3, k0_DIALOG_SET_VIEWPORT, 0, k0_DIALOG_CHOICE_NONE);
 
-	// F0427_DIALOG_Draw(0, G0551_pc_SAVINGGAME, 0, 0, 0, 0, false, false, false);
+	_dialog->f427_dialogDraw(nullptr, "SAVING GAME . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
 
 	uint16 champHandObjWeight = 0;
 	if (!_championMan->_g415_leaderEmptyHanded) {


Commit: e7d460bdc83a271181124ed03563d2c63204fcb0
    https://github.com/scummvm/scummvm/commit/e7d460bdc83a271181124ed03563d2c63204fcb0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Attempt to fix menus.cpp crlf problem

Changed paths:
    engines/dm/menus.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 3d8f313..7077225 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -297,68 +297,68 @@ const char* MenuMan::f384_getActionName(ChampionAction actionIndex) {
 Box g504_BoxSpellAreaControls = Box(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls 
 
 void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) {
-
-
-	Champion *champ = &_vm->_championMan->_gK71_champions[champIndex];
-	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	int16 champHP0 = _vm->_championMan->_gK71_champions[0]._currHealth;
-	int16 champHP1 = _vm->_championMan->_gK71_champions[1]._currHealth;
-	int16 champHP2 = _vm->_championMan->_gK71_champions[2]._currHealth;
-	int16 champHP3 = _vm->_championMan->_gK71_champions[3]._currHealth;
-	_vm->_eventMan->f78_showMouse();
-	_vm->_displayMan->D24_fillScreenBox(g504_BoxSpellAreaControls, k0_ColorBlack);
-	switch (champIndex) {
-	case 0:
-		_vm->_eventMan->f6_highlightScreenBox(233, 277, 42, 49);
-		_vm->_textMan->f53_printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
-		if (_vm->_championMan->_g305_partyChampionCount > 1) {
-			if (champHP1) {
-				_vm->_eventMan->f6_highlightScreenBox(280, 291, 42, 48);
-			}
-T0393002:
-			if (_vm->_championMan->_g305_partyChampionCount > 2) {
-				if (champHP2) {
-					_vm->_eventMan->f6_highlightScreenBox(294, 305, 42, 48);
-				}
-T0393003:
-				if (_vm->_championMan->_g305_partyChampionCount > 3) {
-					if (champHP3) {
-						_vm->_eventMan->f6_highlightScreenBox(308, 319, 42, 48);
-					}
-				}
-			}
-		}
-		break;
-	case 1:
-		if (champHP0) {
-			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
-		}
-		_vm->_eventMan->f6_highlightScreenBox(247, 291, 42, 49);
-		_vm->_textMan->f53_printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
-		goto T0393002;
-	case 2:
-		if (champHP0) {
-			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
-		}
-		if (champHP1) {
-			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
-		}
-		_vm->_eventMan->f6_highlightScreenBox(261, 305, 42, 49);
-		_vm->_textMan->f53_printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
-		goto T0393003;
-	case 3:
-		if (champHP0) {
-			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
-		}
-		if (champHP1) {
-			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
-		}
-		if (champHP2) {
-			_vm->_eventMan->f6_highlightScreenBox(261, 272, 42, 48);
-		}
-		_vm->_eventMan->f6_highlightScreenBox(275, 319, 42, 49);
-		_vm->_textMan->f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
-	}
+
+
+	Champion *champ = &_vm->_championMan->_gK71_champions[champIndex];
+	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	int16 champHP0 = _vm->_championMan->_gK71_champions[0]._currHealth;
+	int16 champHP1 = _vm->_championMan->_gK71_champions[1]._currHealth;
+	int16 champHP2 = _vm->_championMan->_gK71_champions[2]._currHealth;
+	int16 champHP3 = _vm->_championMan->_gK71_champions[3]._currHealth;
+	_vm->_eventMan->f78_showMouse();
+	_vm->_displayMan->D24_fillScreenBox(g504_BoxSpellAreaControls, k0_ColorBlack);
+	switch (champIndex) {
+	case 0:
+		_vm->_eventMan->f6_highlightScreenBox(233, 277, 42, 49);
+		_vm->_textMan->f53_printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
+		if (_vm->_championMan->_g305_partyChampionCount > 1) {
+			if (champHP1) {
+				_vm->_eventMan->f6_highlightScreenBox(280, 291, 42, 48);
+			}
+T0393002:
+			if (_vm->_championMan->_g305_partyChampionCount > 2) {
+				if (champHP2) {
+					_vm->_eventMan->f6_highlightScreenBox(294, 305, 42, 48);
+				}
+T0393003:
+				if (_vm->_championMan->_g305_partyChampionCount > 3) {
+					if (champHP3) {
+						_vm->_eventMan->f6_highlightScreenBox(308, 319, 42, 48);
+					}
+				}
+			}
+		}
+		break;
+	case 1:
+		if (champHP0) {
+			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
+		}
+		_vm->_eventMan->f6_highlightScreenBox(247, 291, 42, 49);
+		_vm->_textMan->f53_printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
+		goto T0393002;
+	case 2:
+		if (champHP0) {
+			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
+		}
+		if (champHP1) {
+			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
+		}
+		_vm->_eventMan->f6_highlightScreenBox(261, 305, 42, 49);
+		_vm->_textMan->f53_printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
+		goto T0393003;
+	case 3:
+		if (champHP0) {
+			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
+		}
+		if (champHP1) {
+			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
+		}
+		if (champHP2) {
+			_vm->_eventMan->f6_highlightScreenBox(261, 272, 42, 48);
+		}
+		_vm->_eventMan->f6_highlightScreenBox(275, 319, 42, 49);
+		_vm->_textMan->f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
+	}
 	_vm->_eventMan->f77_hideMouse();
 }
 
@@ -408,7 +408,7 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 		_vm->_eventMan->f77_hideMouse();
 		return;
 	}
-	L1213_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex = (ChampionIndex)champIndex];
+	L1213_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex = (ChampionIndex)champIndex];
 	f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
 	_vm->_eventMan->f78_showMouse();
 	f393_drawSpellAreaControls((ChampionIndex)champIndex);


Commit: 78f34ae4e3c811e96a6ec0d3b2e1baac93e62376
    https://github.com/scummvm/scummvm/commit/78f34ae4e3c811e96a6ec0d3b2e1baac93e62376
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Make DMEngine::f22_delay call EventMan::processInput()

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index d0ca2c8..9cb3711 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -55,6 +55,7 @@
 #include "timeline.h"
 #include "projexpl.h"
 #include "dialog.h"
+#include <graphics/cursorman.h>
 
 namespace DM {
 void warning(bool repeat, const char* s, ...) {
@@ -235,6 +236,7 @@ bool DMEngine::hasFeature(EngineFeature f) const {
 
 void DMEngine::f22_delay(uint16 verticalBlank) {
 	for (uint16 i = 0; i < verticalBlank * 2; ++i) {
+		_eventMan->processInput();
 		_displayMan->updateScreen();
 		_system->delayMillis(10); // Google says most Amiga games had a refreshrate of 50 hz
 	}


Commit: 52f76a5d747064f0d61b4508f29edc65f10edf1d
    https://github.com/scummvm/scummvm/commit/52f76a5d747064f0d61b4508f29edc65f10edf1d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove default parameters from blitToBitmap

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/text.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index b819627..4c434b8 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1794,7 +1794,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 	championPtr->resetToZero();
 	// Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portraits could be missing in the data)
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
-	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, gBoxChampionPortrait, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency);
+	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, gBoxChampionPortrait, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency, 87, 29);
 	championPtr->_actionIndex = k255_ChampionActionNone;
 	championPtr->_enableActionEventIndex = -1;
 	championPtr->_hideDamageReceivedIndex = -1;
@@ -2264,12 +2264,15 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
 
 	if (nativeBitmapIndex != -1) {
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		if (isInventoryChamp)
+		if (isInventoryChamp) {
 			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
-												_vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray);
-		else
+												_vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport, 
+												k12_ColorDarkestGray, _vm->_displayMan->getPixelHeight(nativeBitmapIndex), k136_heightViewport);
+		} else {
 			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
-												_vm->_displayMan->_g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen, k12_ColorDarkestGray);
+												_vm->_displayMan->_g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen,
+												k12_ColorDarkestGray, _vm->_displayMan->getPixelHeight(nativeBitmapIndex), k136_heightViewport);
+		}
 	}
 
 	_vm->_objectMan->f38_drawIconInSlotBox(slotBoxIndex, iconIndex);
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 9cb3711..79b10f2 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -673,7 +673,7 @@ T0444017:
 		_displayMan->f436_STARTEND_FadeToPalette(darkBluePalette);
 	}
 	Box box(0, 319, 0, 199);
-	_displayMan->f132_blitToBitmap(_displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice), _displayMan->_g348_bitmapScreen, box, 0, 0, 160, 160, kM1_ColorNoTransparency);
+	_displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice), &box, k160_byteWidthScreen, kM1_ColorNoTransparency, k200_heightScreen);
 
 	_displayMan->f436_STARTEND_FadeToPalette(g19_PalCredits);
 	_eventMan->f541_waitForMouseOrKeyActivity();
@@ -751,8 +751,10 @@ void DMEngine::f438_STARTEND_OpenEntranceDoors() {
 		}
 
 		_displayMan->f21_blitToScreen(_savedScreenForOpenEntranceDoors, &screenBox, 160, kM1_ColorNoTransparency, 200);
-		_displayMan->f132_blitToBitmap(leftDoorBitmap, _displayMan->_g348_bitmapScreen, leftDoorBox, leftDoorBlitFrom, 0, 64, k160_byteWidthScreen, kM1_ColorNoTransparency);
-		_displayMan->f132_blitToBitmap(rightDoorBitmap, _displayMan->_g348_bitmapScreen, rightDoorBox, 0, 0, 64, k160_byteWidthScreen, kM1_ColorNoTransparency);
+		_displayMan->f132_blitToBitmap(leftDoorBitmap, _displayMan->_g348_bitmapScreen, leftDoorBox, leftDoorBlitFrom, 0, 64, k160_byteWidthScreen,
+									   kM1_ColorNoTransparency, 161, k200_heightScreen);
+		_displayMan->f132_blitToBitmap(rightDoorBitmap, _displayMan->_g348_bitmapScreen, rightDoorBox, 0, 0, 64, k160_byteWidthScreen,
+									   kM1_ColorNoTransparency, 161, k200_heightScreen);
 		_eventMan->f357_discardAllInput();
 		_displayMan->updateScreen();
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index e1b5137..1a1de67 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1072,7 +1072,8 @@ void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* to
 void DisplayMan::f566_viewportBlitToScreen() {
 	Box box(0, 223, 33, 33 + 135);
 
-	f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport, k160_byteWidthScreen, kM1_ColorNoTransparency);
+	f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport, k160_byteWidthScreen, kM1_ColorNoTransparency,
+					  k136_heightViewport, k200_heightScreen);
 }
 
 void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) {
@@ -1125,8 +1126,6 @@ void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) {
 
 void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
 								   uint16 destByteWidth, Color transparent, int16 srcHeight, int16 destHight) {
-				// Note: if you want to use srcHeight and destHight parameters, remove the defaults values and 
-				// and complete the function calls at the callsites, otherwise their value can be the default -1
 	uint16 srcWidth = srcByteWidth * 2;
 	uint16 destWidth = destByteWidth * 2;
 	for (uint16 y = 0; y < box._y2 + 1 - box._y1; ++y) // + 1 for inclusive boundaries
@@ -1464,12 +1463,14 @@ void DisplayMan::f21_blitToScreen(byte* bitmap, Box* box, int16 byteWidth, Color
 
 void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
 	if (f._srcByteWidth)
-		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency);
+		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency,
+						  f._srcHeight, k136_heightViewport);
 }
 
 void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) {
 	if (f._srcByteWidth)
-		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh);
+		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh,
+						  f._srcHeight, k136_heightViewport);
 }
 
 
@@ -2327,12 +2328,12 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 	f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap,
 									g163_FrameWalls[k0_ViewSquare_D3C]._srcByteWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight);
 	f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, k10_ColorFlesh, 64, 51);
-	f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, BoxWallD3LCR, 11, 0, 64, 64, kM1_ColorNoTransparency);
+	f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, BoxWallD3LCR, 11, 0, 64, 64, kM1_ColorNoTransparency, 51, 51);
 
 	f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap,
 									g163_FrameWalls[k3_ViewSquare_D2C]._srcByteWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight);
 	f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, k10_ColorFlesh, 72, 71);
-	f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, BoxWallD2LCR, 8, 0, 72, 72, kM1_ColorNoTransparency);
+	f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, BoxWallD2LCR, 8, 0, 72, 72, kM1_ColorNoTransparency, 71, 71);
 
 	f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped,
 									g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight);
@@ -2447,13 +2448,15 @@ void DisplayMan::f93_applyCreatureReplColors(int replacedColor, int replacementC
 
 void DisplayMan::f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
 	if (f._srcByteWidth)
-		f132_blitToBitmap(f489_getNativeBitmapOrGraphic(nativeIndex), _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh);
+		f132_blitToBitmap(f489_getNativeBitmapOrGraphic(nativeIndex), _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh,
+						  f._srcHeight, k136_heightViewport);
 }
 
 void DisplayMan::f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) {
 	if (f._srcByteWidth) {
 		f99_copyBitmapAndFlipHorizontal(f489_getNativeBitmapOrGraphic(nativeIndex), _g74_tmpBitmap, f._srcByteWidth, f._srcHeight);
-		f132_blitToBitmap(_g74_tmpBitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh);
+		f132_blitToBitmap(_g74_tmpBitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh,
+						  f._srcHeight, k136_heightViewport);
 	}
 }
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index c068b39..40b925a 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -690,7 +690,7 @@ public:
 	match the original exatcly, if need arises for heights then we'll have to retrospectively add them in old function calls*/
 	/* Expects inclusive boundaries in box */
 	void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
-						   uint16 destByteWidth, Color transparent = kM1_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit
+						   uint16 destByteWidth, Color transparent, int16 srcHeight, int16 destHight); // @ F0132_VIDEO_Blit
 	 /* Expects inclusive boundaries in box */
 	void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
 											int16 firstUnitIndex, int16 destByteWidth, Color transparent,
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 84c1c59..afe91eb 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -147,7 +147,7 @@ void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) {
 	box._y2 = 28;
 	box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7;
 	box._x2 = box._x1 + 31;
-	dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, dispMan._g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen, kM1_ColorNoTransparency);
+	dispMan.f21_blitToScreen(_vm->_championMan->_gK71_champions[championIndex]._portrait, &box, k16_byteWidth, kM1_ColorNoTransparency, 29);
 }
 
 void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
@@ -180,11 +180,15 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
 	Champion &champ = _vm->_championMan->_gK71_champions[_g432_inventoryChampionOrdinal];
 	f334_closeChest();
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 72, k160_byteWidthScreen, k8_ColorRed);
-	dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k30_FoodLabelIndice), dispMan._g348_bitmapScreen, g35_BoxFood, 0, 0, 24, k160_byteWidthScreen, k12_ColorDarkestGray);
-	dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k31_WaterLabelIndice), dispMan._g348_bitmapScreen, g36_BoxWater, 0, 0, 24, k160_byteWidthScreen, k12_ColorDarkestGray);
+	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice),
+							   g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
+	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k30_FoodLabelIndice),
+							   g35_BoxFood, k24_byteWidth, k12_ColorDarkestGray, 9);
+	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k31_WaterLabelIndice),
+							   g36_BoxWater, k24_byteWidth, k12_ColorDarkestGray, 9);
 	if (champ._poisonEventCount) {
-		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k32_PoisionedLabelIndice), dispMan._g348_bitmapScreen, g37_BoxPoisoned, 0, 0, 48, k160_byteWidthScreen, k12_ColorDarkestGray);
+		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k32_PoisionedLabelIndice),
+								   g37_BoxPoisoned, k48_byteWidth, k12_ColorDarkestGray, 15);
 	}
 	f344_drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown);
 	f344_drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue);
@@ -192,8 +196,8 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
 
 void InventoryMan::f346_drawPanelResurrectReincarnate() {
 	_g424_panelContent = k5_PanelContentResurrectReincarnate;
-	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k40_PanelResurectReincaranteIndice),
-										_vm->_displayMan->_g296_bitmapViewport, g32_BoxPanel, 0, 0, 72, k112_byteWidthViewport, k6_ColorDarkGreen);
+	_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k40_PanelResurectReincaranteIndice),
+										 g32_BoxPanel, k72_byteWidth, k6_ColorDarkGreen, 73);
 }
 
 void InventoryMan::f347_drawPanel() {
@@ -276,7 +280,8 @@ void InventoryMan::f341_drawPanelScroll(Scroll* scroll) {
 		charRed++;
 	}
 	*charRed = '\0';
-	dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k23_PanelOpenScrollIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 72, k112_byteWidthViewport, k8_ColorRed);
+	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k23_PanelOpenScrollIndice),
+							   g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
 	int16 lineCount = 1;
 	charRed++;
 	char *charGreen = charRed; // first char of the second line
@@ -328,8 +333,8 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo
 	if (!isPressingEye) {
 		objMan.f38_drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen);
 	}
-	dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k25_PanelOpenChestIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 72, k160_byteWidthScreen, k8_ColorRed);
-
+	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k25_PanelOpenChestIndice),
+							   g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
 	int16 chestSlotIndex = 0;
 	Thing thing = chest->getSlot();
 	int16 thingCount = 0;
@@ -354,7 +359,7 @@ void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int
 	box._x2 = (box._x1 = xPos) + 15;
 	box._y2 = (box._y1 = yPos) + 15;
 	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, iconBitmap);
-	_vm->_displayMan->f132_blitToBitmap(iconBitmap, _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 8, k112_byteWidthViewport, kM1_ColorNoTransparency);
+	_vm->_displayMan->f20_blitToViewport(iconBitmap, box, k8_byteWidth, kM1_ColorNoTransparency, 16);
 }
 
 void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) {
@@ -428,8 +433,8 @@ Box g33_BoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOr
 
 void InventoryMan::f339_drawPanelArrowOrEye(bool pressingEye) {
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice),
-							  dispMan._g296_bitmapViewport, g33_BoxArrowOrEye, 0, 0, 8, k112_byteWidthViewport, k8_ColorRed);
+	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice),
+							   g33_BoxArrowOrEye, k8_byteWidth, k8_ColorRed, 9);
 }
 
 
@@ -461,10 +466,10 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		f333_openAndDrawChest(thingToDraw, (Container *)rawThingPtr, pressingEye);
 	} else {
 		IconIndice iconIndex = objMan.f33_getIconIndex(thingToDraw);
-		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), dispMan._g296_bitmapViewport,
-								  g32_BoxPanel, 0, 0, 72, k112_byteWidthViewport, k8_ColorRed);
-		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k29_ObjectDescCircleIndice), dispMan._g296_bitmapViewport,
-								  g34_BoxObjectDescCircle, 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray);
+		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice),
+								   g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
+		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k29_ObjectDescCircleIndice),
+								   g34_BoxObjectDescCircle, k16_byteWidth, k12_ColorDarkestGray, 27);
 
 		char *descString = nullptr;
 		char str[40];
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 7077225..5c425c8 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -115,12 +115,10 @@ MenuMan::~MenuMan() {
 }
 
 void MenuMan::f395_drawMovementArrows() {
-	DisplayMan &disp = *_vm->_displayMan;
-	byte *arrowsBitmap = disp.f489_getNativeBitmapOrGraphic(k13_MovementArrowsIndice);
-	Box &dest = g2_BoxMovementArrows;
-	uint16 byteWidth = disp.getPixelWidth(k13_MovementArrowsIndice) / 2;
-
-	disp.f132_blitToBitmap(arrowsBitmap, disp._g348_bitmapScreen, dest, 0, 0, byteWidth, k160_byteWidthScreen, kM1_ColorNoTransparency);
+	_vm->_eventMan->f78_showMouse();
+	_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k13_MovementArrowsIndice),
+									   &g2_BoxMovementArrows, k48_byteWidth, kM1_ColorNoTransparency, 45);
+	_vm->_eventMan->f77_hideMouse();
 }
 void MenuMan::f388_clearActingChampion() {
 	ChampionMan &cm = *_vm->_championMan;
@@ -169,7 +167,7 @@ T0386006:
 	box2._x2 = box._x2 - 2;
 	box2._y1 = 95;
 	box2._y2 = 110;
-	dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 8, k160_byteWidthScreen, kM1_ColorNoTransparency);
+	dm.f21_blitToScreen(bitmapIcon, &box2, k8_byteWidth, kM1_ColorNoTransparency, 16);
 	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) {
 		_vm->_displayMan->f136_shadeScreenBox(&box, k0_ColorBlack);
 	}
@@ -264,8 +262,8 @@ void MenuMan::f387_drawActionArea() {
 			box = g500_BoxActionArea2ActionMenu;
 		if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone)
 			box = g501_BoxActionArea1ActionMenu;
-		dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k10_MenuActionAreaIndice), dispMan._g348_bitmapScreen,
-								  box, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency);
+		dispMan.f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k10_MenuActionAreaIndice),
+								 &box, k48_byteWidth, kM1_ColorNoTransparency, 45);
 		textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen,
 											235, 83, k0_ColorBlack, k4_ColorCyan, champMan._gK71_champions[_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name,
 											k7_ChampionNameMaximumLength, k200_heightScreen);
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 6e7ae5e..8e9b1a1 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -75,7 +75,8 @@ void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int1
 		uint16 srcX = (1 + 5) * *begin; // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
 
 		Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1);
-		_vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128 / 2, destByteWidth, kM1_ColorNoTransparency);
+		_vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128 / 2, destByteWidth, kM1_ColorNoTransparency,
+											k6_LetterHeight, destHeight);
 
 		nextX += k5_LetterWidth + 1;
 	}
@@ -86,7 +87,7 @@ void TextMan::f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textCol
 }
 
 void TextMan::f52_printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) {
-	f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, posX, posY, textColor, bgColor, text, k200_heightScreen);
+	f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, posX, posY, textColor, bgColor, text, k136_heightViewport);
 }
 
 void TextMan::f41_printWithTrailingSpaces(byte* destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor,


Commit: 29f5210b3fd2fdd9500cf81e91fbe15d8af827f7
    https://github.com/scummvm/scummvm/commit/29f5210b3fd2fdd9500cf81e91fbe15d8af827f7
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add sanity check to blitToBimap

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 1a1de67..b5aa123 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1130,9 +1130,12 @@ void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box,
 	uint16 destWidth = destByteWidth * 2;
 	for (uint16 y = 0; y < box._y2 + 1 - box._y1; ++y) // + 1 for inclusive boundaries
 		for (uint16 x = 0; x < box._x2 + 1 - box._x1; ++x) { // + 1 for inclusive boundaries
-			byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x];
-			if (srcPixel != transparent)
-				destBitmap[destWidth * (y + box._y1) + box._x1 + x] = srcPixel;
+			if (srcX + x < srcWidth && y + srcY < srcHeight
+				&& box._x1 + x < destWidth && y + box._y1 < destHight) {
+				byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x];
+				if (srcPixel != transparent)
+					destBitmap[destWidth * (y + box._y1) + box._x1 + x] = srcPixel;
+			}
 		}
 }
 


Commit: fa0009fbb7879f59c3bd9a303abba8e6fb87865c
    https://github.com/scummvm/scummvm/commit/fa0009fbb7879f59c3bd9a303abba8e6fb87865c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add entrance credits

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/menus.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 79b10f2..2912b31 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -768,6 +768,16 @@ void DMEngine::f438_STARTEND_OpenEntranceDoors() {
 	_savedScreenForOpenEntranceDoors = nullptr;
 }
 
+void DMEngine::f442_SARTEND_processCommand202_entranceDrawCredits() {
+	_eventMan->f78_showMouse();
+	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
+	_displayMan->f466_loadIntoBitmap(k5_creditsGraphicIndice, _displayMan->_g348_bitmapScreen);
+	_displayMan->f436_STARTEND_FadeToPalette(g19_PalCredits);
+	f22_delay(50);
+	_eventMan->f541_waitForMouseOrKeyActivity();
+	_g298_newGame = k202_modeEntranceDrawCredits;
+}
+
 void DMEngine::f446_STARTEND_fuseSequnce() {
 	int16 L1424_i_Multiple;
 #define AL1424_B_RemoveFluxcagesFromLoadChaosSquare L1424_i_Multiple
@@ -914,9 +924,9 @@ void DMEngine::f445_STARTEND_fuseSequenceUpdate() {
 	_eventMan->f357_discardAllInput();
 	_displayMan->updateScreen();
 	f22_delay(1);
-	_g313_gameTime++; /* BUG0_71 Some timings are too short on fast computers. 
+	_g313_gameTime++; /* BUG0_71 Some timings are too short on fast computers.
 					  The ending animation when Lord Chaos is fused plays too quickly because the execution speed is not limited */
-	
+
 }
 
 } // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index d7af092..739ef17 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -267,7 +267,7 @@ public:
 	bool f505_soundGetVolume(int16 mapX, int16 mapY, uint8 *leftVolume, uint8 *rightVolume); // @ F0505_SOUND_GetVolume
 	void f438_STARTEND_OpenEntranceDoors(); // @ F0438_STARTEND_OpenEntranceDoors
 	void f437_STARTEND_drawTittle() { warning(false, "STUB METHOD: f437_STARTEND_drawTittle"); }// @ F0437_STARTEND_DrawTitle
-	void f442_SARTEND_processCommand202_entranceDrawCredits() { warning(false, "STUB METHOD: f442_SARTEND_processCommand202_entranceDrawCredits"); }// @ F0442_STARTEND_ProcessCommand202_EntranceDrawCredits
+	void f442_SARTEND_processCommand202_entranceDrawCredits();
 	void f446_STARTEND_fuseSequnce(); // @ F0446_STARTEND_FuseSequence
 	void f445_STARTEND_fuseSequenceUpdate(); // @ F0445_STARTEND_FuseSequenceUpdate
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 5c425c8..3137bad 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -965,7 +965,7 @@ bool MenuMan::f407_isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		2,  /* BRANDISH */
 		0,  /* THROW */
 		2}; /* FUSE */
-	unsigned char G0497_auc_Graphic560_ActionExperienceGain[44] = {
+	static unsigned char G0497_auc_Graphic560_ActionExperienceGain[44] = {
 		0,  /* N */
 		8,  /* BLOCK */
 		10, /* CHOP */


Commit: e49bda9994fb1a7077adee2da0ab8c087dbecf1d
    https://github.com/scummvm/scummvm/commit/e49bda9994fb1a7077adee2da0ab8c087dbecf1d
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Move some globals in DisplayMan, renaming

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index b5aa123..802784a 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -41,39 +41,6 @@
 
 namespace DM {
 
-byte g197_doorButtonCoordSet[1] = {0}; // @ G0197_auc_Graphic558_DoorButtonCoordinateSet
-
-uint16 g208_doorButtonCoordSets[1][4][6] = { // @ G0208_aaauc_Graphic558_DoorButtonCoordinateSets
-	/* X1, X2, Y1, Y2, ByteWidth, Height */
-	{{199, 204, 41, 44, 8, 4},     /* D3R */
-	{136, 141, 41, 44, 8, 4},     /* D3C */
-	{144, 155, 42, 47, 8, 6},     /* D2C */
-	{160, 175, 44, 52, 8, 9}}}; /* D1C */
-
-uint16 g207_doorOrnCoordSets[4][3][6] = { // @ G0207_aaauc_Graphic558_DoorOrnamentCoordinateSets
-	/* { X1, X2, Y1, Y2, ByteWidth, Height } */
-	{{17, 31,  8, 17,  8, 10},     /* D3LCR */
-	{22, 42, 11, 23, 16, 13},     /* D2LCR */
-	{32, 63, 13, 31, 16, 19}},   /* D1LCR */
-	{{0, 47,  0, 40, 24, 41},     /* D3LCR */
-	{0, 63,  0, 60, 32, 61},     /* D2LCR */
-	{0, 95,  0, 87, 48, 88}},   /* D1LCR */
-	{{17, 31, 15, 24,  8, 10},     /* D3LCR */
-	{22, 42, 22, 34, 16, 13},     /* D2LCR */
-	{32, 63, 31, 49, 16, 19}},   /* D1LCR */
-	{{23, 35, 31, 39,  8,  9},     /* D3LCR */
-	{30, 48, 41, 52, 16, 12},     /* D2LCR */
-	{44, 75, 61, 79, 16, 19}}}; /* D1LCR */
-
-
-Frame g164_Frame_DoorFrameLeft_D3L = Frame(0, 31, 28, 70, 16, 43, 0, 0); // @ G0164_s_Graphic558_Frame_DoorFrameLeft_D3L
-Frame g165_Frame_DoorFrameRight_D3R = Frame(192, 223, 28, 70, 16, 43, 0, 0); // @ G0165_s_Graphic558_Frame_DoorFrameRight_D3R
-Frame g166_Frame_DoorFrameLeft_D3C = Frame(64, 95, 27, 70, 16, 44, 0, 0); // @ G0166_s_Graphic558_Frame_DoorFrameLeft_D3C
-Frame g167_Frame_DoorFrameRight_D3C = Frame(128, 159, 27, 70, 16, 44, 0, 0); // @ G0167_s_Graphic558_Frame_DoorFrameRight_D3C
-Frame g168_Frame_DoorFrameLeft_D2C = Frame(48, 95, 22, 86, 24, 65, 0, 0); // @ G0168_s_Graphic558_Frame_DoorFrameLeft_D2C
-Frame g169_Frame_DoorFrameRight_D2C = Frame(128, 175, 22, 86, 24, 65, 0, 0); // @ G0169_s_Graphic558_Frame_DoorFrameRight_D2C
-Frame g170_Frame_DoorFrameLeft_D1C = Frame(43, 74, 14, 107, 16, 94, 0, 0); // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C
-Frame g171_Frame_DoorFrameRight_D1C = Frame(149, 180, 14, 107, 16, 94, 0, 0); // @ G0171_s_Graphic558_Frame_DoorFrameRight_D1C
 Frame g172_Frame_DoorFrame_D0C = Frame(96, 127, 0, 122, 16, 123, 0, 0); // @ G0172_s_Graphic558_Frame_DoorFrame_D0C
 Frame g173_Frame_DoorFrameTop_D2L = Frame(0, 59, 22, 24, 48, 3, 16, 0); // @ G0173_s_Graphic558_Frame_DoorFrameTop_D2L
 Frame g174_Frame_DoorFrameTop_D2C = Frame(64, 159, 22, 24, 48, 3, 0, 0); // @ G0174_s_Graphic558_Frame_DoorFrameTop_D2C
@@ -717,15 +684,17 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 }
 
 void DisplayMan::initConstants() {
-	const byte palChangesDoorButtonAndWallOrn_D3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3
-	const byte palChangesDoorButtonAndWallOrn_D2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2
+	const byte palChangesDoorButtonAndWallOrnD3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3
+	const byte palChangesDoorButtonAndWallOrnD2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2
+	const Frame doorFrameLeftD1C = Frame(43, 74, 14, 107, 16, 94, 0, 0); // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C
+	const Frame doorFrameRightD1C = Frame(149, 180, 14, 107, 16, 94, 0, 0); // @ G0171_s_Graphic558_Frame_DoorFrameRight_D1C
 
 	for (int i = 0; i < 16; i++) {
-		g198_PalChangesDoorButtonAndWallOrn_D3[i] = palChangesDoorButtonAndWallOrn_D3[i];
-		g199_PalChangesDoorButtonAndWallOrn_D2[i] = palChangesDoorButtonAndWallOrn_D2[i];
+		_palChangesDoorButtonAndWallOrnD3[i] = palChangesDoorButtonAndWallOrnD3[i];
+		_palChangesDoorButtonAndWallOrnD2[i] = palChangesDoorButtonAndWallOrnD2[i];
 	}
 
-	g186_doorFrame_D1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
+	_doorFrameD1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
 		Frame(64, 159, 17, 102, 48, 88, 0, 0),	 /* Closed Or Destroyed */
 		Frame(64, 159, 17, 38, 48, 88, 0, 66),	 /* Vertical Closed one fourth */
 		Frame(64, 159, 17, 60, 48, 88, 0, 44),	 /* Vertical Closed half */
@@ -738,7 +707,10 @@ void DisplayMan::initConstants() {
 		Frame(124, 159, 17, 102, 48, 88, 48, 0)	 /* Right Horizontal Closed three fourth */
 	);
 
-	g106_BoxThievesEye_ViewPortVisibleArea = Box(64, 159, 19, 113); // @ G0106_s_Graphic558_Box_ThievesEye_ViewportVisibleArea 
+	_boxThievesEyeViewPortVisibleArea = Box(64, 159, 19, 113); // @ G0106_s_Graphic558_Box_ThievesEye_ViewportVisibleArea 
+
+	_doorFrameLeftD1C = doorFrameLeftD1C;
+	_doorFrameRightD1C = doorFrameRightD1C;
 }
 
 DisplayMan::~DisplayMan() {
@@ -782,7 +754,7 @@ DisplayMan::~DisplayMan() {
 	delete[] _g93_bitmapWall_D0L_Flipped;
 	delete[] _g94_bitmapWall_D0R_Flipped;
 
-	delete g186_doorFrame_D1C;
+	delete _doorFrameD1C;
 }
 
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
@@ -1028,13 +1000,26 @@ void DisplayMan::f103_drawDoorFrameBitmapFlippedHorizontally(byte* bitmap, Frame
 }
 
 void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButtonIndex) {
+	static byte doorButtonCoordSet[1] = {0}; // @ G0197_auc_Graphic558_DoorButtonCoordinateSet
+	static uint16 doorButtonCoordSets[1][4][6] = { // @ G0208_aaauc_Graphic558_DoorButtonCoordinateSets
+		  // X1, X2, Y1, Y2, ByteWidth, Height
+		{ {199, 204, 41, 44, 8, 4},   /* D3R */
+		  {136, 141, 41, 44, 8, 4},   /* D3C */
+		  {144, 155, 42, 47, 8, 6},   /* D2C */
+		  {160, 175, 44, 52, 8, 9}    /* D1C */
+		}
+	};
+
 	if (doorButtonOrdinal) {
 		doorButtonOrdinal--;
+
+		assert(doorButtonOrdinal == 0);
+
 		int16 nativeBitmapIndex = doorButtonOrdinal + k315_firstDoorButton_GraphicIndice;
-		int coordSet = g197_doorButtonCoordSet[doorButtonOrdinal];
-		uint16 *coordSetRedEagle = g208_doorButtonCoordSets[coordSet][viewDoorButtonIndex];
+		int coordSet = doorButtonCoordSet[doorButtonOrdinal];
+		uint16 *coordSetRedEagle = doorButtonCoordSets[coordSet][viewDoorButtonIndex];
 
-		byte* bitmap = nullptr;
+		byte *bitmap = nullptr;
 		if (viewDoorButtonIndex == k3_viewDoorButton_D1C) {
 			bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
 
@@ -1044,14 +1029,14 @@ void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButt
 			_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordSetRedEagle[3];
 		} else {
 			if (!f491_isDerivedBitmapInCache(doorButtonOrdinal = k102_DerivedBitmapFirstDoorButton + (doorButtonOrdinal * 2) + ((!viewDoorButtonIndex) ? 0 : viewDoorButtonIndex - 1))) {
-				uint16 *coordSetBlueGoat = g208_doorButtonCoordSets[coordSet][k3_viewDoorButton_D1C];
+				uint16 *coordSetBlueGoat = doorButtonCoordSets[coordSet][k3_viewDoorButton_D1C];
 				byte *bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
 				f129_blitToBitmapShrinkWithPalChange(bitmapNative, f492_getDerivedBitmap(doorButtonOrdinal),
 													 coordSetBlueGoat[4] << 1, coordSetBlueGoat[5],
 													 // modified code line
 													 coordSetRedEagle[4] << 1,
 													 coordSetRedEagle[5],
-													 (viewDoorButtonIndex == k2_viewDoorButton_D2C) ? g199_PalChangesDoorButtonAndWallOrn_D2 : g198_PalChangesDoorButtonAndWallOrn_D3);
+													 (viewDoorButtonIndex == k2_viewDoorButton_D2C) ? _palChangesDoorButtonAndWallOrnD2 : _palChangesDoorButtonAndWallOrnD3);
 
 				f493_addDerivedBitmap(doorButtonOrdinal);
 			}
@@ -1367,7 +1352,7 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d
 				f131_flipVertical(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
 			}
 		}
-		if ((doorFramesTemp == g186_doorFrame_D1C) && _vm->_championMan->_g407_party._event73Count_ThievesEye) {
+		if ((doorFramesTemp == _doorFrameD1C) && _vm->_championMan->_g407_party._event73Count_ThievesEye) {
 			f109_drawDoorOrnament(_vm->M0_indexToOrdinal(k16_DoorOrnThivesEyeMask), k2_ViewDoorOrnament_D1LCR);
 		}
 		if (doorState == k4_doorState_CLOSED) {
@@ -1390,9 +1375,31 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d
 }
 
 void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIndex) {
-	static byte g200_palChangesDoorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 0, 130}; // @ G0200_auc_Graphic558_PaletteChanges_DoorOrnament_D3
-	static byte g201PalChangesDoorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0201_auc_Graphic558_PaletteChanges_DoorOrnament_D2
-
+	static byte palChangesDoorOrnD3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 0, 130}; // @ G0200_auc_Graphic558_PaletteChanges_DoorOrnament_D3
+	static byte palChangesDoorOrnd2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0201_auc_Graphic558_PaletteChanges_DoorOrnament_D2
+	static uint16 doorOrnCoordSets[4][3][6] = { // @ G0207_aaauc_Graphic558_DoorOrnamentCoordinateSets
+		/* { X1, X2, Y1, Y2, ByteWidth, Height } */
+		{
+			{17, 31,  8, 17,  8, 10},   /* D3LCR */
+			{22, 42, 11, 23, 16, 13},   /* D2LCR */
+			{32, 63, 13, 31, 16, 19}    /* D1LCR */
+		},
+		{
+			{0, 47,  0, 40, 24, 41},    /* D3LCR */
+			{0, 63,  0, 60, 32, 61},    /* D2LCR */
+			{0, 95,  0, 87, 48, 88}     /* D1LCR */
+		},
+		{
+			{17, 31, 15, 24,  8, 10},   /* D3LCR */
+			{22, 42, 22, 34, 16, 13},   /* D2LCR */
+			{32, 63, 31, 49, 16, 19}    /* D1LCR */
+		},
+		{
+			{23, 35, 31, 39,  8,  9},   /* D3LCR */
+			{30, 48, 41, 52, 16, 12},   /* D2LCR */
+			{44, 75, 61, 79, 16, 19}    /* D1LCR */
+		}
+	};
 	int16 AP0120_i_Height = doorOrnOrdinal;
 	int16 AP0121_i_ByteWidth = viewDoorOrnIndex;
 
@@ -1400,7 +1407,7 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn
 		AP0120_i_Height--;
 		int16 L0104_i_NativeBitmapIndex = _g103_currMapDoorOrnInfo[AP0120_i_Height][k0_NativeBitmapIndex];
 		int16 coordSetGreenToad = _g103_currMapDoorOrnInfo[AP0120_i_Height][k1_CoordinateSet];
-		uint16 *coordSetOrangeElk = &g207_doorOrnCoordSets[coordSetGreenToad][AP0121_i_ByteWidth][0];
+		uint16 *coordSetOrangeElk = &doorOrnCoordSets[coordSetGreenToad][AP0121_i_ByteWidth][0];
 		byte *AL0107_puc_Bitmap;
 		if (AP0121_i_ByteWidth == k2_ViewDoorOrnament_D1LCR) {
 			AL0107_puc_Bitmap = f489_getNativeBitmapOrGraphic(L0104_i_NativeBitmapIndex);
@@ -1409,9 +1416,9 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn
 		} else {
 			AP0120_i_Height = k68_DerivedBitmapFirstDoorOrnament_D3 + (AP0120_i_Height * 2) + AP0121_i_ByteWidth;
 			if (!f491_isDerivedBitmapInCache(AP0120_i_Height)) {
-				uint16 *coordSetRedEagle = &g207_doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR][0];
+				uint16 *coordSetRedEagle = &doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR][0];
 				byte *L0108_puc_Bitmap_Native = f489_getNativeBitmapOrGraphic(L0104_i_NativeBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(L0108_puc_Bitmap_Native, f492_getDerivedBitmap(AP0120_i_Height), coordSetRedEagle[4] << 1, coordSetRedEagle[5], coordSetOrangeElk[1] - coordSetOrangeElk[0] + 1, coordSetOrangeElk[5], (AP0121_i_ByteWidth == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2);
+				f129_blitToBitmapShrinkWithPalChange(L0108_puc_Bitmap_Native, f492_getDerivedBitmap(AP0120_i_Height), coordSetRedEagle[4] << 1, coordSetRedEagle[5], coordSetOrangeElk[1] - coordSetOrangeElk[0] + 1, coordSetOrangeElk[5], (AP0121_i_ByteWidth == k0_ViewDoorOrnament_D3LCR) ? palChangesDoorOrnD3 : palChangesDoorOrnd2);
 				f493_addDerivedBitmap(AP0120_i_Height);
 			}
 			AL0107_puc_Bitmap = f492_getDerivedBitmap(AP0120_i_Height);
@@ -1478,19 +1485,20 @@ void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) {
 
 
 void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
-	static DoorFrames g179_doorFrame_D3L = DoorFrames( // @ G0179_s_Graphic558_Frames_Door_D3L
+	static Frame doorFrameLeftD3L = Frame(0, 31, 28, 70, 16, 43, 0, 0); // @ G0164_s_Graphic558_Frame_DoorFrameLeft_D3L
+	static DoorFrames doorFrameD3L = DoorFrames( // @ G0179_s_Graphic558_Frames_Door_D3L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-													  Frame(24, 71, 28, 67, 24, 41, 0, 0),     /* Closed Or Destroyed */
-													  Frame(24, 71, 28, 38, 24, 41, 0, 30),     /* Vertical Closed one fourth */
-													  Frame(24, 71, 28, 48, 24, 41, 0, 20),     /* Vertical Closed half */
-													  Frame(24, 71, 28, 58, 24, 41, 0, 10),   /* Vertical Closed three fourth */
-													  Frame(24, 29, 28, 67, 24, 41, 18, 0),     /* Left Horizontal Closed one fourth */
-													  Frame(24, 35, 28, 67, 24, 41, 12, 0),     /* Left Horizontal Closed half */
-													  Frame(24, 41, 28, 67, 24, 41, 6, 0),   /* Left Horizontal Closed three fourth */
-													  Frame(66, 71, 28, 67, 24, 41, 24, 0),     /* Right Horizontal Closed one fourth */
-													  Frame(60, 71, 28, 67, 24, 41, 24, 0),     /* Right Horizontal Closed half */
-													  Frame(54, 71, 28, 67, 24, 41, 24, 0)
-	); /* Right Horizontal Closed three fourth */
+		Frame(24, 71, 28, 67, 24, 41, 0, 0),   /* Closed Or Destroyed */
+		Frame(24, 71, 28, 38, 24, 41, 0, 30),  /* Vertical Closed one fourth */
+		Frame(24, 71, 28, 48, 24, 41, 0, 20),  /* Vertical Closed half */
+		Frame(24, 71, 28, 58, 24, 41, 0, 10),  /* Vertical Closed three fourth */
+		Frame(24, 29, 28, 67, 24, 41, 18, 0),  /* Left Horizontal Closed one fourth */
+		Frame(24, 35, 28, 67, 24, 41, 12, 0),  /* Left Horizontal Closed half */
+		Frame(24, 41, 28, 67, 24, 41, 6, 0),   /* Left Horizontal Closed three fourth */
+		Frame(66, 71, 28, 67, 24, 41, 24, 0),  /* Right Horizontal Closed one fourth */
+		Frame(60, 71, 28, 67, 24, 41, 24, 0),  /* Right Horizontal Closed half */
+		Frame(54, 71, 28, 67, 24, 41, 24, 0)   /* Right Horizontal Closed three fourth */
+	);
 
 	uint16 squareAspect[5];
 	int16 order;
@@ -1518,9 +1526,9 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 	case k17_ElementTypeDoorFront:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
-		f100_drawWallSetBitmap(_g705_bitmapWallSet_DoorFrameLeft_D3L, g164_Frame_DoorFrameLeft_D3L);
+		f100_drawWallSetBitmap(_g705_bitmapWallSet_DoorFrameLeft_D3L, doorFrameLeftD3L);
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g693_doorNativeBitmapIndex_Front_D3LCR, M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &g179_doorFrame_D3L);
+					  _g693_doorNativeBitmapIndex_Front_D3LCR, M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3L);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0116017_orangeElk;
 	case k2_ElementTypePit:
@@ -1543,24 +1551,24 @@ T0116017_orangeElk:
 }
 
 void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
-	static DoorFrames g181_doorFrame_D3R = DoorFrames( // @ G0181_s_Graphic558_Frames_Door_D3R
+	static Frame doorFrameRightD3R = Frame(192, 223, 28, 70, 16, 43, 0, 0); // @ G0165_s_Graphic558_Frame_DoorFrameRight_D3R
+	static DoorFrames doorFrameD3R = DoorFrames( // @ G0181_s_Graphic558_Frames_Door_D3R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-													  Frame(150, 197, 28, 67, 24, 41, 0, 0),	/* Closed Or Destroyed */
-													  Frame(150, 197, 28, 38, 24, 41, 0, 30),	/* Vertical Closed one fourth */
-													  Frame(150, 197, 28, 48, 24, 41, 0, 20),	/* Vertical Closed half */
-													  Frame(150, 197, 28, 58, 24, 41, 0, 10),	/* Vertical Closed three fourth */
-													  Frame(150, 153, 28, 67, 24, 41, 18, 0),	/* Left Horizontal Closed one fourth */
-													  Frame(150, 161, 28, 67, 24, 41, 12, 0),	/* Left Horizontal Closed half */
-													  Frame(150, 167, 28, 67, 24, 41, 6, 0),	/* Left Horizontal Closed three fourth */
-													  Frame(192, 197, 28, 67, 24, 41, 24, 0),	/* Right Horizontal Closed one fourth */
-													  Frame(186, 197, 28, 67, 24, 41, 24, 0),	/* Right Horizontal Closed half */
-													  Frame(180, 197, 28, 67, 24, 41, 24, 0)		/* Right Horizontal Closed three fourth */
+		Frame(150, 197, 28, 67, 24, 41, 0, 0),	/* Closed Or Destroyed */
+		Frame(150, 197, 28, 38, 24, 41, 0, 30),	/* Vertical Closed one fourth */
+		Frame(150, 197, 28, 48, 24, 41, 0, 20),	/* Vertical Closed half */
+		Frame(150, 197, 28, 58, 24, 41, 0, 10),	/* Vertical Closed three fourth */
+		Frame(150, 153, 28, 67, 24, 41, 18, 0),	/* Left Horizontal Closed one fourth */
+		Frame(150, 161, 28, 67, 24, 41, 12, 0),	/* Left Horizontal Closed half */
+		Frame(150, 167, 28, 67, 24, 41, 6, 0),	/* Left Horizontal Closed three fourth */
+		Frame(192, 197, 28, 67, 24, 41, 24, 0),	/* Right Horizontal Closed one fourth */
+		Frame(186, 197, 28, 67, 24, 41, 24, 0),	/* Right Horizontal Closed half */
+		Frame(180, 197, 28, 67, 24, 41, 24, 0)	/* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
 	uint16 squareAspect[5];
 
-
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
@@ -1586,13 +1594,13 @@ void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
 		memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44);
-		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g165_Frame_DoorFrameRight_D3R);
+		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD3R);
 		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
 			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k0_viewDoorButton_D3R);
 		}
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect],
 					  squareAspect[k2_DoorStateAspect], _g693_doorNativeBitmapIndex_Front_D3LCR,
-					  M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &g181_doorFrame_D3R);
+					  M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3R);
 		goto T0117018;
 	case k2_ElementTypePit:
 		if (!squareAspect[k2_PitInvisibleAspect]) {
@@ -1614,22 +1622,24 @@ T0117018:
 }
 
 void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
-	static DoorFrames g180_doorFrame_D3C = DoorFrames( // @ G0180_s_Graphic558_Frames_Door_D3C
+	static Frame doorFrameLeftD3C = Frame(64, 95, 27, 70, 16, 44, 0, 0); // @ G0166_s_Graphic558_Frame_DoorFrameLeft_D3C
+	static Frame doorFrameRightD3C = Frame(128, 159, 27, 70, 16, 44, 0, 0); // @ G0167_s_Graphic558_Frame_DoorFrameRight_D3C
+	static DoorFrames doorFrameD3C = DoorFrames( // @ G0180_s_Graphic558_Frames_Door_D3C
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-													  Frame(88, 135, 28, 67, 24, 41, 0, 0),		/* Closed Or Destroyed */
-													  Frame(88, 135, 28, 38, 24, 41, 0, 30),		/* Vertical Closed one fourth */
-													  Frame(88, 135, 28, 48, 24, 41, 0, 20),		/* Vertical Closed half */
-													  Frame(88, 135, 28, 58, 24, 41, 0, 10),		/* Vertical Closed three fourth */
-													  Frame(88, 93, 28, 67, 24, 41, 18, 0),		/* Left Horizontal Closed one fourth */
-													  Frame(88, 99, 28, 67, 24, 41, 12, 0),		/* Left Horizontal Closed half */
-													  Frame(88, 105, 28, 67, 24, 41, 6, 0),		/* Left Horizontal Closed three fourth */
-													  Frame(130, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed one fourth */
-													  Frame(124, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed half */
-													  Frame(118, 135, 28, 67, 24, 41, 24, 0)		/* Right Horizontal Closed three fourth */
+		Frame(88, 135, 28, 67, 24, 41, 0, 0),		/* Closed Or Destroyed */
+		Frame(88, 135, 28, 38, 24, 41, 0, 30),		/* Vertical Closed one fourth */
+		Frame(88, 135, 28, 48, 24, 41, 0, 20),		/* Vertical Closed half */
+		Frame(88, 135, 28, 58, 24, 41, 0, 10),		/* Vertical Closed three fourth */
+		Frame(88, 93, 28, 67, 24, 41, 18, 0),		/* Left Horizontal Closed one fourth */
+		Frame(88, 99, 28, 67, 24, 41, 12, 0),		/* Left Horizontal Closed half */
+		Frame(88, 105, 28, 67, 24, 41, 6, 0),		/* Left Horizontal Closed three fourth */
+		Frame(130, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed one fourth */
+		Frame(124, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed half */
+		Frame(118, 135, 28, 67, 24, 41, 24, 0)		/* Right Horizontal Closed three fourth */
 	);
-	int16 order;
-	uint16 squareAspect[5];
 
+	uint16 squareAspect[5];
+	int16 order;
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
@@ -1650,14 +1660,14 @@ void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 	case k17_DoorFrontElemType:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
-		f100_drawWallSetBitmap(_g706_bitmapWallSet_DoorFrameLeft_D3C, g166_Frame_DoorFrameLeft_D3C);
+		f100_drawWallSetBitmap(_g706_bitmapWallSet_DoorFrameLeft_D3C, doorFrameLeftD3C);
 		memmove(_g74_tmpBitmap, _g706_bitmapWallSet_DoorFrameLeft_D3C, 32 * 44);
-		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g167_Frame_DoorFrameRight_D3C);
+		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD3C);
 		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
 			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k1_ViewDoorOrnament_D2LCR);
 		}
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g693_doorNativeBitmapIndex_Front_D3LCR, M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &g180_doorFrame_D3C);
+					  _g693_doorNativeBitmapIndex_Front_D3LCR, M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3C);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0118028;
 	case k2_ElementTypePit:
@@ -1812,24 +1822,25 @@ T0120029:
 }
 
 void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
-	static DoorFrames g183_doorFrame_D2C = DoorFrames( // @ G0183_s_Graphic558_Frames_Door_D2C
+	static Frame doorFrameLeftD2C = Frame(48, 95, 22, 86, 24, 65, 0, 0); // @ G0168_s_Graphic558_Frame_DoorFrameLeft_D2C
+	static Frame doorFrameRightD2C = Frame(128, 175, 22, 86, 24, 65, 0, 0); // @ G0169_s_Graphic558_Frame_DoorFrameRight_D2C
+	static DoorFrames doorFrameD2C = DoorFrames( // @ G0183_s_Graphic558_Frames_Door_D2C
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-													  Frame(80, 143, 24, 82, 32, 61, 0, 0),		/* Closed Or Destroyed */
-													  Frame(80, 143, 24, 39, 32, 61, 0, 45),		/* Vertical Closed one fourth */
-													  Frame(80, 143, 24, 54, 32, 61, 0, 30),		/* Vertical Closed half */
-													  Frame(80, 143, 24, 69, 32, 61, 0, 15),		/* Vertical Closed three fourth */
-													  Frame(80, 87, 24, 82, 32, 61, 24, 0),		/* Left Horizontal Closed one fourth */
-													  Frame(80, 95, 24, 82, 32, 61, 16, 0),		/* Left Horizontal Closed half */
-													  Frame(80, 103, 24, 82, 32, 61, 8, 0),		/* Left Horizontal Closed three fourth */
-													  Frame(136, 143, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed one fourth */
-													  Frame(128, 143, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed half */
-													  Frame(120, 143, 24, 82, 32, 61, 32, 0)		/* Right Horizontal Closed three fourth */
+		Frame(80, 143, 24, 82, 32, 61, 0, 0),    /* Closed Or Destroyed */
+		Frame(80, 143, 24, 39, 32, 61, 0, 45),   /* Vertical Closed one fourth */
+		Frame(80, 143, 24, 54, 32, 61, 0, 30),   /* Vertical Closed half */
+		Frame(80, 143, 24, 69, 32, 61, 0, 15),   /* Vertical Closed three fourth */
+		Frame(80, 87, 24, 82, 32, 61, 24, 0),    /* Left Horizontal Closed one fourth */
+		Frame(80, 95, 24, 82, 32, 61, 16, 0),    /* Left Horizontal Closed half */
+		Frame(80, 103, 24, 82, 32, 61, 8, 0),    /* Left Horizontal Closed three fourth */
+		Frame(136, 143, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed one fourth */
+		Frame(128, 143, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed half */
+		Frame(120, 143, 24, 82, 32, 61, 32, 0)   /* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
 	uint16 squareAspect[5];
 
-
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
@@ -1850,14 +1861,14 @@ void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
 		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, g174_Frame_DoorFrameTop_D2C);
-		f100_drawWallSetBitmap(_g707_bitmapWallSet_DoorFrameLeft_D2C, g168_Frame_DoorFrameLeft_D2C);
+		f100_drawWallSetBitmap(_g707_bitmapWallSet_DoorFrameLeft_D2C, doorFrameLeftD2C);
 		memcpy(_g74_tmpBitmap, _g707_bitmapWallSet_DoorFrameLeft_D2C, 48 * 65);
-		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g169_Frame_DoorFrameRight_D2C);
+		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD2C);
 		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
 			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k2_viewDoorButton_D2C);
 		}
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g694_doorNativeBitmapIndex_Front_D2LCR, M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &g183_doorFrame_D2C);
+					  _g694_doorNativeBitmapIndex_Front_D2LCR, M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2C);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0121016;
 	case k2_ElementTypePit:
@@ -2034,8 +2045,8 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 			f491_isDerivedBitmapInCache(k1_DerivedBitmapThievesEyeVisibleArea);
 			f132_blitToBitmap(_g296_bitmapViewport, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
 							  g107_BoxThievesEyeVisibleArea,
-							  g106_BoxThievesEye_ViewPortVisibleArea._x1,
-							  g106_BoxThievesEye_ViewPortVisibleArea._y1,
+							  _boxThievesEyeViewPortVisibleArea._x1,
+							  _boxThievesEyeViewPortVisibleArea._y1,
 							  k112_byteWidthViewport, 48, kM1_ColorNoTransparency, 136, 95);
 			bitmap = f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice);
 			f132_blitToBitmap(bitmap, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
@@ -2048,7 +2059,7 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 		}
 		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
 			f132_blitToBitmap(f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
-							  _g296_bitmapViewport, g106_BoxThievesEye_ViewPortVisibleArea, 0, 0,
+							  _g296_bitmapViewport, _boxThievesEyeViewPortVisibleArea, 0, 0,
 							  48, k112_byteWidthViewport, k9_ColorGold, 95, k136_heightViewport); /* BUG0_74 */
 			f493_addDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea);
 			f480_releaseBlock(k1_DerivedBitmapThievesEyeVisibleArea | 0x8000);
@@ -2058,13 +2069,13 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
 		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, g177_Frame_DoorFrameTop_D1C);
-		f100_drawWallSetBitmap(_g708_bitmapWallSet_DoorFrameLeft_D1C, g170_Frame_DoorFrameLeft_D1C);
-		f100_drawWallSetBitmap(_g710_bitmapWallSet_DoorFrameRight_D1C, g171_Frame_DoorFrameRight_D1C);
+		f100_drawWallSetBitmap(_g708_bitmapWallSet_DoorFrameLeft_D1C, _doorFrameLeftD1C);
+		f100_drawWallSetBitmap(_g710_bitmapWallSet_DoorFrameRight_D1C, _doorFrameRightD1C);
 		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
 			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C);
 		}
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, g186_doorFrame_D1C);
+					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, _doorFrameD1C);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0124018;
 	case k2_ElementTypePit:
@@ -2138,7 +2149,7 @@ void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
 			memmove(_g74_tmpBitmap, _g709_bitmapWallSet_DoorFrameFront, 32 * 123);
 			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice),
-							  _g74_tmpBitmap, g108_BoxThievesEyeHoleInDoorFrame, g172_Frame_DoorFrame_D0C._box._x1 - g106_BoxThievesEye_ViewPortVisibleArea._x1,
+							  _g74_tmpBitmap, g108_BoxThievesEyeHoleInDoorFrame, g172_Frame_DoorFrame_D0C._box._x1 - _boxThievesEyeViewPortVisibleArea._x1,
 							  0, 48, 16, k9_ColorGold, 95, 123);
 			f100_drawWallSetBitmap(_g74_tmpBitmap, g172_Frame_DoorFrame_D0C);
 		} else {
@@ -2312,7 +2323,7 @@ void DisplayMan::f95_loadWallSet(WallSet set) {
 		f466_loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2);
 
 		f99_copyBitmapAndFlipHorizontal(_g708_bitmapWallSet_DoorFrameLeft_D1C, _g710_bitmapWallSet_DoorFrameRight_D1C,
-										g171_Frame_DoorFrameRight_D1C._srcByteWidth, g171_Frame_DoorFrameRight_D1C._srcHeight);
+										_doorFrameRightD1C._srcByteWidth, _doorFrameRightD1C._srcHeight);
 		f99_copyBitmapAndFlipHorizontal(_g697_bitmapWallSet_Wall_D3L2, _g696_bitmapWallSet_Wall_D3R2,
 										g712_FrameWall_D3R2._srcByteWidth, g712_FrameWall_D3R2._srcHeight);
 	}
@@ -2598,7 +2609,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 			AL0089_i_PixelWidth = (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[1] - (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[0];
 			if (!f491_isDerivedBitmapInCache(AP0116_i_WallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + (AP0116_i_WallOrnamentIndex << 2) + wallOrnDerivedBitmapIndexIncrement[viewWallIndex])) {
 				L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex), AL0091_puc_CoordinateSet[4] << 1, AL0091_puc_CoordinateSet[5], AL0090_puc_CoordinateSet[4] << 1, AL0090_puc_CoordinateSet[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2);
+				f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex), AL0091_puc_CoordinateSet[4] << 1, AL0091_puc_CoordinateSet[5], AL0090_puc_CoordinateSet[4] << 1, AL0090_puc_CoordinateSet[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? _palChangesDoorButtonAndWallOrnD3 : _palChangesDoorButtonAndWallOrnD2);
 				f493_addDerivedBitmap(AP0116_i_WallOrnamentIndex);
 			}
 			AL0091_puc_Bitmap = f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex);
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 40b925a..7dba4f7 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -530,7 +530,7 @@ class DisplayMan {
 	uint32 *_packedItemPos;
 	byte *_packedBitmaps;
 	byte **_bitmaps;
-	DoorFrames *g186_doorFrame_D1C;
+	DoorFrames *_doorFrameD1C;
 	// pointers are not owned by these fields
 	byte *_g75_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile
 
@@ -599,9 +599,9 @@ class DisplayMan {
 public:
 	byte *_g700_bitmapWallSet_Wall_D1LCR; // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR
 private:
-	Box g106_BoxThievesEye_ViewPortVisibleArea; // @ G0106_s_Graphic558_Box_ThievesEye_ViewportVisibleArea 
-	byte g198_PalChangesDoorButtonAndWallOrn_D3[16]; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3
-	byte g199_PalChangesDoorButtonAndWallOrn_D2[16]; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2
+	Box _boxThievesEyeViewPortVisibleArea; // @ G0106_s_Graphic558_Box_ThievesEye_ViewportVisibleArea 
+	byte _palChangesDoorButtonAndWallOrnD3[16]; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3
+	byte _palChangesDoorButtonAndWallOrnD2[16]; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2
 
 	byte *_g701_bitmapWallSet_Wall_D0L; // @ G0701_puc_Bitmap_WallSet_Wall_D0L
 	byte *_g702_bitmapWallSet_Wall_D0R; // @ G0702_puc_Bitmap_WallSet_Wall_D0R
@@ -749,6 +749,9 @@ public:
 	bool _g578_useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates
 	bool _g77_doNotDrawFluxcagesDuringEndgame; // @ G0077_B_DoNotDrawFluxcagesDuringEndgame
 
+	Frame _doorFrameLeftD1C; // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C
+	Frame _doorFrameRightD1C; // @ G0171_s_Graphic558_Frame_DoorFrameRight_D1C
+
 	bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
 	byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap
 	void f493_addDerivedBitmap(int16 derivedBitmapIndex); // @ F0493_CACHE_AddDerivedBitmap


Commit: 5bb786caae9b9f1ca0c181c11d23c8483f20123a
    https://github.com/scummvm/scummvm/commit/5bb786caae9b9f1ca0c181c11d23c8483f20123a
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactoring in DisplayMan

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 802784a..96620f7 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -38,11 +38,8 @@
 #include "champion.h"
 #include "eventman.h"
 
-
 namespace DM {
 
-Frame g172_Frame_DoorFrame_D0C = Frame(96, 127, 0, 122, 16, 123, 0, 0); // @ G0172_s_Graphic558_Frame_DoorFrame_D0C
-Frame g173_Frame_DoorFrameTop_D2L = Frame(0, 59, 22, 24, 48, 3, 16, 0); // @ G0173_s_Graphic558_Frame_DoorFrameTop_D2L
 Frame g174_Frame_DoorFrameTop_D2C = Frame(64, 159, 22, 24, 48, 3, 0, 0); // @ G0174_s_Graphic558_Frame_DoorFrameTop_D2C
 Frame g175_Frame_DoorFrameTop_D2R = Frame(164, 223, 22, 24, 48, 3, 16, 0); // @ G0175_s_Graphic558_Frame_DoorFrameTop_D2R
 Frame g176_Frame_DoorFrameTop_D1L = Frame(0, 31, 14, 17, 64, 4, 16, 0); // @ G0176_s_Graphic558_Frame_DoorFrameTop_D1L
@@ -51,7 +48,6 @@ Frame g178_Frame_DoorFrameTop_D1R = Frame(192, 223, 14, 17, 64, 4, 16, 0); // @
 Frame g110_FrameStairsUpFront_D3L = Frame(0, 79, 25, 70, 40, 46, 0, 0); // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L
 Frame g111_FrameStairsUpFront_D3C = Frame(64, 159, 25, 70, 48, 46, 0, 0); // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C
 Frame g112_FrameStairsUpFront_D3R = Frame(149, 223, 25, 70, 40, 46, 5, 0); // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R
-Frame g113_FrameStairsUpFront_D2L = Frame(0, 63, 22, 83, 32, 62, 0, 0); // @ G0113_s_Graphic558_Frame_StairsUpFront_D2L
 Frame g114_FrameStairsUpFront_D2C = Frame(64, 159, 22, 83, 48, 62, 0, 0); // @ G0114_s_Graphic558_Frame_StairsUpFront_D2C
 Frame g115_FrameStairsUpFront_D2R = Frame(160, 223, 22, 83, 32, 62, 0, 0); // @ G0115_s_Graphic558_Frame_StairsUpFront_D2R
 Frame g116_FrameStairsUpFront_D1L = Frame(0, 31, 9, 108, 16, 100, 0, 0); // @ G0116_s_Graphic558_Frame_StairsUpFront_D1L
@@ -62,7 +58,6 @@ Frame g120_FrameStairsUpFront_D0R = Frame(192, 223, 58, 101, 16, 44, 0, 0); // @
 Frame g121_FrameStairsDownFront_D3L = Frame(0, 79, 28, 68, 40, 41, 0, 0); // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L
 Frame g122_FrameStairsDownFront_D3C = Frame(64, 159, 28, 70, 48, 43, 0, 0); // @ G0122_s_Graphic558_Frame_StairsDownFront_D3C
 Frame g123_FrameStairsDownFront_D3R = Frame(149, 223, 28, 68, 40, 41, 5, 0); // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R
-Frame g124_FrameStairsDownFront_D2L = Frame(0, 63, 24, 85, 32, 62, 0, 0); // @ G0124_s_Graphic558_Frame_StairsDownFront_D2L
 Frame g125_FrameStairsDownFront_D2C = Frame(64, 159, 24, 85, 48, 62, 0, 0); // @ G0125_s_Graphic558_Frame_StairsDownFront_D2C
 Frame g126_FrameStairsDownFront_D2R = Frame(160, 223, 24, 85, 32, 62, 0, 0); // @ G0126_s_Graphic558_Frame_StairsDownFront_D2R
 Frame g127_FrameStairsDownFront_D1L = Frame(0, 31, 18, 108, 16, 91, 0, 0); // @ G0127_s_Graphic558_Frame_StairsDownFront_D1L
@@ -70,7 +65,6 @@ Frame g128_FrameStairsDownFront_D1C = Frame(32, 191, 18, 108, 80, 91, 0, 0); //
 Frame g129_FrameStairsDownFront_D1R = Frame(192, 223, 18, 108, 16, 91, 0, 0); // @ G0129_s_Graphic558_Frame_StairsDownFront_D1R
 Frame g130_FrameStairsDownFront_D0L = Frame(0, 31, 76, 135, 16, 60, 0, 0); // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L
 Frame g131_FrameStairsDownFront_D0R = Frame(192, 223, 76, 135, 16, 60, 0, 0); // @ G0131_s_Graphic558_Frame_StairsDownFront_D0R
-Frame g132_FrameStairsSide_D2L = Frame(60, 75, 57, 61, 8, 5, 0, 0); // @ G0132_s_Graphic558_Frame_StairsSide_D2L
 Frame g133_FrameStairsSide_D2R = Frame(148, 163, 57, 61, 8, 5, 0, 0); // @ G0133_s_Graphic558_Frame_StairsSide_D2R
 Frame g134_FrameStairsUpSide_D1L = Frame(32, 63, 57, 99, 16, 43, 0, 0); // @ G0134_s_Graphic558_Frame_StairsUpSide_D1L
 Frame g135_FrameStairsUpSide_D1R = Frame(160, 191, 57, 99, 16, 43, 0, 0); // @ G0135_s_Graphic558_Frame_StairsUpSide_D1R
@@ -81,7 +75,6 @@ Frame g139_FrameStairsSide_D0R = Frame(208, 223, 73, 85, 8, 13, 0, 0); // @ G013
 Frame g140_FrameFloorPit_D3L = Frame(0, 79, 66, 73, 40, 8, 0, 0); // @ G0140_s_Graphic558_Frame_FloorPit_D3L
 Frame g141_FrameFloorPit_D3C = Frame(64, 159, 66, 73, 48, 8, 0, 0); // @ G0141_s_Graphic558_Frame_FloorPit_D3C
 Frame g142_FrameFloorPit_D3R = Frame(144, 223, 66, 73, 40, 8, 0, 0); // @ G0142_s_Graphic558_Frame_FloorPit_D3R
-Frame g143_FrameFloorPit_D2L = Frame(0, 79, 77, 88, 40, 12, 0, 0); // @ G0143_s_Graphic558_Frame_FloorPit_D2L
 Frame g144_FrameFloorPit_D2C = Frame(64, 159, 77, 88, 48, 12, 0, 0); // @ G0144_s_Graphic558_Frame_FloorPit_D2C
 Frame g145_FrameFloorPit_D2R = Frame(144, 223, 77, 88, 40, 12, 0, 0); // @ G0145_s_Graphic558_Frame_FloorPit_D2R
 Frame g146_FrameFloorPit_D1L = Frame(0, 63, 93, 116, 32, 24, 0, 0); // @ G0146_s_Graphic558_Frame_FloorPit_D1L
@@ -90,7 +83,6 @@ Frame g148_FrameFloorPit_D1R = Frame(160, 223, 93, 116, 32, 24, 0, 0); // @ G014
 Frame g149_FrameFloorPit_D0L = Frame(0, 31, 124, 135, 16, 12, 0, 0); // @ G0149_s_Graphic558_Frame_FloorPit_D0L
 Frame g150_FrameFloorPit_D0C = Frame(16, 207, 124, 135, 96, 12, 0, 0); // @ G0150_s_Graphic558_Frame_FloorPit_D0C
 Frame g151_FrameFloorPit_D0R = Frame(192, 223, 124, 135, 16, 12, 0, 0); // @ G0151_s_Graphic558_Frame_FloorPit_D0R
-Frame g152_FrameFloorPit_D2L = Frame(0, 79, 19, 23, 40, 5, 0, 0); // @ G0152_s_Graphic558_Frame_CeilingPit_D2L
 Frame g153_FrameFloorPit_D2C = Frame(64, 159, 19, 23, 48, 5, 0, 0); // @ G0153_s_Graphic558_Frame_CeilingPit_D2C
 Frame g154_FrameFloorPit_D2R = Frame(144, 223, 19, 23, 40, 5, 0, 0); // @ G0154_s_Graphic558_Frame_CeilingPit_D2R
 Frame g155_FrameFloorPit_D1L = Frame(0, 63, 8, 16, 32, 9, 0, 0); // @ G0155_s_Graphic558_Frame_CeilingPit_D1L
@@ -1688,18 +1680,24 @@ T0118028:
 }
 
 void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
-	static DoorFrames g182_doorFrame_D2L = DoorFrames( // @ G0182_s_Graphic558_Frames_Door_D2L
+	static Frame doorFrameTopD2L = Frame(0, 59, 22, 24, 48, 3, 16, 0); // @ G0173_s_Graphic558_Frame_DoorFrameTop_D2L
+	static Frame frameStairsUpFrontD2L = Frame(0, 63, 22, 83, 32, 62, 0, 0); // @ G0113_s_Graphic558_Frame_StairsUpFront_D2L
+	static Frame frameStairsDownFrontD2L = Frame(0, 63, 24, 85, 32, 62, 0, 0); // @ G0124_s_Graphic558_Frame_StairsDownFront_D2L
+	static Frame frameStairsSideD2L = Frame(60, 75, 57, 61, 8, 5, 0, 0); // @ G0132_s_Graphic558_Frame_StairsSide_D2L
+	static Frame frameFloorPitD2L = Frame(0, 79, 77, 88, 40, 12, 0, 0); // @ G0143_s_Graphic558_Frame_FloorPit_D2L
+	static Frame FrameCeilingPitD2L = Frame(0, 79, 19, 23, 40, 5, 0, 0); // @ G0152_s_Graphic558_Frame_CeilingPit_D2L
+	static DoorFrames doorFrameD2L = DoorFrames( // @ G0182_s_Graphic558_Frames_Door_D2L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-													  Frame(0, 63, 24, 82, 32, 61, 0, 0),	/* Closed Or Destroyed */
-													  Frame(0, 63, 24, 39, 32, 61, 0, 45),	/* Vertical Closed one fourth */
-													  Frame(0, 63, 24, 54, 32, 61, 0, 30),	/* Vertical Closed half */
-													  Frame(0, 63, 24, 69, 32, 61, 0, 15),	/* Vertical Closed three fourth */
-													  Frame(0, 7, 24, 82, 32, 61, 24, 0),	/* Left Horizontal Closed one fourth */
-													  Frame(0, 15, 24, 82, 32, 61, 16, 0),	/* Left Horizontal Closed half */
-													  Frame(0, 23, 24, 82, 32, 61, 8, 0),	/* Left Horizontal Closed three fourth */
-													  Frame(56, 63, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed one fourth */
-													  Frame(48, 63, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed half */
-													  Frame(40, 63, 24, 82, 32, 61, 32, 0)	/* Right Horizontal Closed three fourth */
+		Frame(0, 63, 24, 82, 32, 61, 0, 0),	/* Closed Or Destroyed */
+		Frame(0, 63, 24, 39, 32, 61, 0, 45),   /* Vertical Closed one fourth */
+		Frame(0, 63, 24, 54, 32, 61, 0, 30),   /* Vertical Closed half */
+		Frame(0, 63, 24, 69, 32, 61, 0, 15),   /* Vertical Closed three fourth */
+		Frame(0, 7, 24, 82, 32, 61, 24, 0),    /* Left Horizontal Closed one fourth */
+		Frame(0, 15, 24, 82, 32, 61, 16, 0),   /* Left Horizontal Closed half */
+		Frame(0, 23, 24, 82, 32, 61, 8, 0),    /* Left Horizontal Closed three fourth */
+		Frame(56, 63, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed one fourth */
+		Frame(48, 63, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed half */
+		Frame(40, 63, 24, 82, 32, 61, 32, 0)   /* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
@@ -1709,9 +1707,9 @@ void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
-			f104_drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L);
+			f104_drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, frameStairsUpFrontD2L);
 		} else {
-			f104_drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L);
+			f104_drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, frameStairsDownFrontD2L);
 		}
 		goto T0119018;
 	case k0_ElementTypeWall:
@@ -1723,21 +1721,21 @@ void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 		}
 		return;
 	case k18_ElementTypeStairsSide:
-		f104_drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L);
+		f104_drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, frameStairsSideD2L);
 	case k16_DoorSideElemType:
 		order = k0x0342_CellOrder_BackRight_FrontLeft_FrontRight;
 		goto T0119019;
 	case k17_DoorFrontElemType:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
-		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, g173_Frame_DoorFrameTop_D2L);
+		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, doorFrameTopD2L);
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], _g694_doorNativeBitmapIndex_Front_D2LCR,
-					  M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &g182_doorFrame_D2L);
+					  M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2L);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0119020;
 	case k2_ElementTypePit:
 		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice,
-										g143_FrameFloorPit_D2L);
+										frameFloorPitD2L);
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
 T0119018:
@@ -1745,7 +1743,7 @@ T0119018:
 T0119019:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 T0119020:
-		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &g152_FrameFloorPit_D2L, posX, posY, false);
+		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &FrameCeilingPitD2L, posX, posY, false);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, order);
 	}
 	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
@@ -2139,7 +2137,8 @@ void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
 }
 
 void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
-	static Box g108_BoxThievesEyeHoleInDoorFrame(0, 31, 19, 113); // @ G0108_s_Graphic558_Box_ThievesEye_HoleInDoorFrame 
+	static Frame doorFrameD0C = Frame(96, 127, 0, 122, 16, 123, 0, 0); // @ G0172_s_Graphic558_Frame_DoorFrame_D0C
+	static Box boxThievesEyeHoleInDoorFrame(0, 31, 19, 113); // @ G0108_s_Graphic558_Box_ThievesEye_HoleInDoorFrame 
 
 	uint16 squareAspect[5];
 
@@ -2149,11 +2148,11 @@ void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
 			memmove(_g74_tmpBitmap, _g709_bitmapWallSet_DoorFrameFront, 32 * 123);
 			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice),
-							  _g74_tmpBitmap, g108_BoxThievesEyeHoleInDoorFrame, g172_Frame_DoorFrame_D0C._box._x1 - _boxThievesEyeViewPortVisibleArea._x1,
+							  _g74_tmpBitmap, boxThievesEyeHoleInDoorFrame, doorFrameD0C._box._x1 - _boxThievesEyeViewPortVisibleArea._x1,
 							  0, 48, 16, k9_ColorGold, 95, 123);
-			f100_drawWallSetBitmap(_g74_tmpBitmap, g172_Frame_DoorFrame_D0C);
+			f100_drawWallSetBitmap(_g74_tmpBitmap, doorFrameD0C);
 		} else {
-			f100_drawWallSetBitmap(_g709_bitmapWallSet_DoorFrameFront, g172_Frame_DoorFrame_D0C);
+			f100_drawWallSetBitmap(_g709_bitmapWallSet_DoorFrameFront, doorFrameD0C);
 		}
 		break;
 	case k19_ElementTypeStaisFront:
@@ -2329,7 +2328,6 @@ void DisplayMan::f95_loadWallSet(WallSet set) {
 	}
 }
 
-
 void DisplayMan::f96_loadCurrentMapGraphics() {
 	Box BoxWallD3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR
 	Box BoxWallD2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR


Commit: 07907a8c987824ce786688792b6f1505a69dafc1
    https://github.com/scummvm/scummvm/commit/07907a8c987824ce786688792b6f1505a69dafc1
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Get rid of more global variables

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 96620f7..a5c87a0 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -40,17 +40,11 @@
 
 namespace DM {
 
-Frame g174_Frame_DoorFrameTop_D2C = Frame(64, 159, 22, 24, 48, 3, 0, 0); // @ G0174_s_Graphic558_Frame_DoorFrameTop_D2C
-Frame g175_Frame_DoorFrameTop_D2R = Frame(164, 223, 22, 24, 48, 3, 16, 0); // @ G0175_s_Graphic558_Frame_DoorFrameTop_D2R
-Frame g176_Frame_DoorFrameTop_D1L = Frame(0, 31, 14, 17, 64, 4, 16, 0); // @ G0176_s_Graphic558_Frame_DoorFrameTop_D1L
 Frame g177_Frame_DoorFrameTop_D1C = Frame(48, 175, 14, 17, 64, 4, 0, 0); // @ G0177_s_Graphic558_Frame_DoorFrameTop_D1C
 Frame g178_Frame_DoorFrameTop_D1R = Frame(192, 223, 14, 17, 64, 4, 16, 0); // @ G0178_s_Graphic558_Frame_DoorFrameTop_D1R
 Frame g110_FrameStairsUpFront_D3L = Frame(0, 79, 25, 70, 40, 46, 0, 0); // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L
 Frame g111_FrameStairsUpFront_D3C = Frame(64, 159, 25, 70, 48, 46, 0, 0); // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C
 Frame g112_FrameStairsUpFront_D3R = Frame(149, 223, 25, 70, 40, 46, 5, 0); // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R
-Frame g114_FrameStairsUpFront_D2C = Frame(64, 159, 22, 83, 48, 62, 0, 0); // @ G0114_s_Graphic558_Frame_StairsUpFront_D2C
-Frame g115_FrameStairsUpFront_D2R = Frame(160, 223, 22, 83, 32, 62, 0, 0); // @ G0115_s_Graphic558_Frame_StairsUpFront_D2R
-Frame g116_FrameStairsUpFront_D1L = Frame(0, 31, 9, 108, 16, 100, 0, 0); // @ G0116_s_Graphic558_Frame_StairsUpFront_D1L
 Frame g117_FrameStairsUpFront_D1C = Frame(32, 191, 9, 108, 80, 100, 0, 0); // @ G0117_s_Graphic558_Frame_StairsUpFront_D1C
 Frame g118_FrameStairsUpFront_D1R = Frame(192, 223, 9, 108, 16, 100, 0, 0); // @ G0118_s_Graphic558_Frame_StairsUpFront_D1R
 Frame g119_FrameStairsUpFront_D0L = Frame(0, 31, 58, 101, 16, 44, 0, 0); // @ G0119_s_Graphic558_Frame_StairsUpFront_D0L
@@ -58,34 +52,22 @@ Frame g120_FrameStairsUpFront_D0R = Frame(192, 223, 58, 101, 16, 44, 0, 0); // @
 Frame g121_FrameStairsDownFront_D3L = Frame(0, 79, 28, 68, 40, 41, 0, 0); // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L
 Frame g122_FrameStairsDownFront_D3C = Frame(64, 159, 28, 70, 48, 43, 0, 0); // @ G0122_s_Graphic558_Frame_StairsDownFront_D3C
 Frame g123_FrameStairsDownFront_D3R = Frame(149, 223, 28, 68, 40, 41, 5, 0); // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R
-Frame g125_FrameStairsDownFront_D2C = Frame(64, 159, 24, 85, 48, 62, 0, 0); // @ G0125_s_Graphic558_Frame_StairsDownFront_D2C
-Frame g126_FrameStairsDownFront_D2R = Frame(160, 223, 24, 85, 32, 62, 0, 0); // @ G0126_s_Graphic558_Frame_StairsDownFront_D2R
-Frame g127_FrameStairsDownFront_D1L = Frame(0, 31, 18, 108, 16, 91, 0, 0); // @ G0127_s_Graphic558_Frame_StairsDownFront_D1L
 Frame g128_FrameStairsDownFront_D1C = Frame(32, 191, 18, 108, 80, 91, 0, 0); // @ G0128_s_Graphic558_Frame_StairsDownFront_D1C
 Frame g129_FrameStairsDownFront_D1R = Frame(192, 223, 18, 108, 16, 91, 0, 0); // @ G0129_s_Graphic558_Frame_StairsDownFront_D1R
 Frame g130_FrameStairsDownFront_D0L = Frame(0, 31, 76, 135, 16, 60, 0, 0); // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L
 Frame g131_FrameStairsDownFront_D0R = Frame(192, 223, 76, 135, 16, 60, 0, 0); // @ G0131_s_Graphic558_Frame_StairsDownFront_D0R
-Frame g133_FrameStairsSide_D2R = Frame(148, 163, 57, 61, 8, 5, 0, 0); // @ G0133_s_Graphic558_Frame_StairsSide_D2R
-Frame g134_FrameStairsUpSide_D1L = Frame(32, 63, 57, 99, 16, 43, 0, 0); // @ G0134_s_Graphic558_Frame_StairsUpSide_D1L
 Frame g135_FrameStairsUpSide_D1R = Frame(160, 191, 57, 99, 16, 43, 0, 0); // @ G0135_s_Graphic558_Frame_StairsUpSide_D1R
-Frame g136_FrameStairsDownSide_D1L = Frame(32, 63, 60, 98, 16, 39, 0, 0); // @ G0136_s_Graphic558_Frame_StairsDownSide_D1L
 Frame g137_FrameStairsDownSide_D1R = Frame(160, 191, 60, 98, 16, 39, 0, 0); // @ G0137_s_Graphic558_Frame_StairsDownSide_D1R
 Frame g138_FrameStairsSide_D0L = Frame(0, 15, 73, 85, 8, 13, 0, 0); // @ G0138_s_Graphic558_Frame_StairsSide_D0L
 Frame g139_FrameStairsSide_D0R = Frame(208, 223, 73, 85, 8, 13, 0, 0); // @ G0139_s_Graphic558_Frame_StairsSide_D0R
 Frame g140_FrameFloorPit_D3L = Frame(0, 79, 66, 73, 40, 8, 0, 0); // @ G0140_s_Graphic558_Frame_FloorPit_D3L
 Frame g141_FrameFloorPit_D3C = Frame(64, 159, 66, 73, 48, 8, 0, 0); // @ G0141_s_Graphic558_Frame_FloorPit_D3C
 Frame g142_FrameFloorPit_D3R = Frame(144, 223, 66, 73, 40, 8, 0, 0); // @ G0142_s_Graphic558_Frame_FloorPit_D3R
-Frame g144_FrameFloorPit_D2C = Frame(64, 159, 77, 88, 48, 12, 0, 0); // @ G0144_s_Graphic558_Frame_FloorPit_D2C
-Frame g145_FrameFloorPit_D2R = Frame(144, 223, 77, 88, 40, 12, 0, 0); // @ G0145_s_Graphic558_Frame_FloorPit_D2R
-Frame g146_FrameFloorPit_D1L = Frame(0, 63, 93, 116, 32, 24, 0, 0); // @ G0146_s_Graphic558_Frame_FloorPit_D1L
 Frame g147_FrameFloorPit_D1C = Frame(32, 191, 93, 116, 80, 24, 0, 0); // @ G0147_s_Graphic558_Frame_FloorPit_D1C
 Frame g148_FrameFloorPit_D1R = Frame(160, 223, 93, 116, 32, 24, 0, 0); // @ G0148_s_Graphic558_Frame_FloorPit_D1R
 Frame g149_FrameFloorPit_D0L = Frame(0, 31, 124, 135, 16, 12, 0, 0); // @ G0149_s_Graphic558_Frame_FloorPit_D0L
 Frame g150_FrameFloorPit_D0C = Frame(16, 207, 124, 135, 96, 12, 0, 0); // @ G0150_s_Graphic558_Frame_FloorPit_D0C
 Frame g151_FrameFloorPit_D0R = Frame(192, 223, 124, 135, 16, 12, 0, 0); // @ G0151_s_Graphic558_Frame_FloorPit_D0R
-Frame g153_FrameFloorPit_D2C = Frame(64, 159, 19, 23, 48, 5, 0, 0); // @ G0153_s_Graphic558_Frame_CeilingPit_D2C
-Frame g154_FrameFloorPit_D2R = Frame(144, 223, 19, 23, 40, 5, 0, 0); // @ G0154_s_Graphic558_Frame_CeilingPit_D2R
-Frame g155_FrameFloorPit_D1L = Frame(0, 63, 8, 16, 32, 9, 0, 0); // @ G0155_s_Graphic558_Frame_CeilingPit_D1L
 Frame g156_FrameFloorPit_D1C = Frame(32, 191, 8, 16, 80, 9, 0, 0); // @ G0156_s_Graphic558_Frame_CeilingPit_D1C
 Frame g157_FrameFloorPit_D1R = Frame(160, 223, 8, 16, 32, 9, 0, 0); // @ G0157_s_Graphic558_Frame_CeilingPit_D1R
 Frame g158_FrameFloorPit_D0L = Frame(0, 15, 0, 3, 8, 4, 0, 0); // @ G0158_s_Graphic558_Frame_CeilingPit_D0L
@@ -1752,18 +1734,24 @@ T0119020:
 }
 
 void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
+	static Frame doorFrameTopD2R = Frame(164, 223, 22, 24, 48, 3, 16, 0); // @ G0175_s_Graphic558_Frame_DoorFrameTop_D2R
+	static Frame frameStairsUpFrontD2R = Frame(160, 223, 22, 83, 32, 62, 0, 0); // @ G0115_s_Graphic558_Frame_StairsUpFront_D2R
+	static Frame frameStairsDownFrontD2R = Frame(160, 223, 24, 85, 32, 62, 0, 0); // @ G0126_s_Graphic558_Frame_StairsDownFront_D2R
+	static Frame frameStairsSideD2R = Frame(148, 163, 57, 61, 8, 5, 0, 0); // @ G0133_s_Graphic558_Frame_StairsSide_D2R
+	static Frame frameFloorPitD2R = Frame(144, 223, 77, 88, 40, 12, 0, 0); // @ G0145_s_Graphic558_Frame_FloorPit_D2R
+	static Frame frameCeilingPitD2R = Frame(144, 223, 19, 23, 40, 5, 0, 0); // @ G0154_s_Graphic558_Frame_CeilingPit_D2R
 	static DoorFrames g184_doorFrame_D2R = DoorFrames( // @ G0184_s_Graphic558_Frames_Door_D2R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-													  Frame(160, 223, 24, 82, 32, 61, 0, 0),	/* Closed Or Destroyed */
-													  Frame(160, 223, 24, 39, 32, 61, 0, 45),	/* Vertical Closed one fourth */
-													  Frame(160, 223, 24, 54, 32, 61, 0, 30),	/* Vertical Closed half */
-													  Frame(160, 223, 24, 69, 32, 61, 0, 15),	/* Vertical Closed three fourth */
-													  Frame(160, 167, 24, 82, 32, 61, 24, 0),	/* Left Horizontal Closed one fourth */
-													  Frame(160, 175, 24, 82, 32, 61, 16, 0),	/* Left Horizontal Closed half */
-													  Frame(160, 183, 24, 82, 32, 61, 8, 0),	/* Left Horizontal Closed three fourth */
-													  Frame(216, 223, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed one fourth */
-													  Frame(208, 223, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed half */
-													  Frame(200, 223, 24, 82, 32, 61, 32, 0)		/* Right Horizontal Closed three fourth */
+		Frame(160, 223, 24, 82, 32, 61, 0, 0),	/* Closed Or Destroyed */
+		Frame(160, 223, 24, 39, 32, 61, 0, 45),	/* Vertical Closed one fourth */
+		Frame(160, 223, 24, 54, 32, 61, 0, 30),	/* Vertical Closed half */
+		Frame(160, 223, 24, 69, 32, 61, 0, 15),	/* Vertical Closed three fourth */
+		Frame(160, 167, 24, 82, 32, 61, 24, 0),	/* Left Horizontal Closed one fourth */
+		Frame(160, 175, 24, 82, 32, 61, 16, 0),	/* Left Horizontal Closed half */
+		Frame(160, 183, 24, 82, 32, 61, 8, 0),	/* Left Horizontal Closed three fourth */
+		Frame(216, 223, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed one fourth */
+		Frame(208, 223, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed half */
+		Frame(200, 223, 24, 82, 32, 61, 32, 0)		/* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
@@ -1774,9 +1762,9 @@ void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, frameStairsUpFrontD2R);
 		} else {
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, frameStairsDownFrontD2R);
 		}
 		goto T0120027;
 	case k0_ElementTypeWall:
@@ -1788,21 +1776,21 @@ void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
 		}
 		return;
 	case k18_ElementTypeStairsSide:
-		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R);
+		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, frameStairsSideD2R);
 	case k16_DoorSideElemType:
 		order = k0x0431_CellOrder_BackLeft_FrontRight_FrontLeft;
 		goto T0120028;
 	case k17_DoorFrontElemType:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_ViewSquare_D2R);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
-		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, g175_Frame_DoorFrameTop_D2R);
+		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, doorFrameTopD2R);
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
 					  _g694_doorNativeBitmapIndex_Front_D2LCR, M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &g184_doorFrame_D2R);
 		order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft;
 		goto T0120029;
 	case k2_ElementTypePit:
 		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect]
-														   ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice, g145_FrameFloorPit_D2R);
+														   ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice, frameFloorPitD2R);
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
 T0120027:
@@ -1810,7 +1798,7 @@ T0120027:
 T0120028:
 /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_viewFloor_D2R);
-		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &g154_FrameFloorPit_D2R, posX, posY, true);
+		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &frameCeilingPitD2R, posX, posY, true);
 T0120029:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, order);
 	}
@@ -1822,6 +1810,11 @@ T0120029:
 void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 	static Frame doorFrameLeftD2C = Frame(48, 95, 22, 86, 24, 65, 0, 0); // @ G0168_s_Graphic558_Frame_DoorFrameLeft_D2C
 	static Frame doorFrameRightD2C = Frame(128, 175, 22, 86, 24, 65, 0, 0); // @ G0169_s_Graphic558_Frame_DoorFrameRight_D2C
+	static Frame doorFrameTopD2C = Frame(64, 159, 22, 24, 48, 3, 0, 0); // @ G0174_s_Graphic558_Frame_DoorFrameTop_D2C
+	static Frame frameStairsUpFrontD2C = Frame(64, 159, 22, 83, 48, 62, 0, 0); // @ G0114_s_Graphic558_Frame_StairsUpFront_D2C
+	static Frame frameStairsDownFrontD2C = Frame(64, 159, 24, 85, 48, 62, 0, 0); // @ G0125_s_Graphic558_Frame_StairsDownFront_D2C
+	static Frame frameFloorPitD2C = Frame(64, 159, 77, 88, 48, 12, 0, 0); // @ G0144_s_Graphic558_Frame_FloorPit_D2C
+	static Frame frameCeilingPitD2C = Frame(64, 159, 19, 23, 48, 5, 0, 0); // @ G0153_s_Graphic558_Frame_CeilingPit_D2C
 	static DoorFrames doorFrameD2C = DoorFrames( // @ G0183_s_Graphic558_Frames_Door_D2C
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
 		Frame(80, 143, 24, 82, 32, 61, 0, 0),    /* Closed Or Destroyed */
@@ -1843,9 +1836,9 @@ void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
-			f104_drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, g114_FrameStairsUpFront_D2C);
+			f104_drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, frameStairsUpFrontD2C);
 		} else {
-			f104_drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, g125_FrameStairsDownFront_D2C);
+			f104_drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, frameStairsDownFrontD2C);
 		}
 		goto T0121015;
 	case k0_ElementTypeWall:
@@ -1858,7 +1851,7 @@ void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 	case k17_DoorFrontElemType:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
-		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, g174_Frame_DoorFrameTop_D2C);
+		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, doorFrameTopD2C);
 		f100_drawWallSetBitmap(_g707_bitmapWallSet_DoorFrameLeft_D2C, doorFrameLeftD2C);
 		memcpy(_g74_tmpBitmap, _g707_bitmapWallSet_DoorFrameLeft_D2C, 48 * 65);
 		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD2C);
@@ -1870,14 +1863,14 @@ void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0121016;
 	case k2_ElementTypePit:
-		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k58_FloorPit_invisible_D2C_GraphicIndice : k52_FloorPit_D2C_GraphicIndice, g144_FrameFloorPit_D2C);
+		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k58_FloorPit_invisible_D2C_GraphicIndice : k52_FloorPit_D2C_GraphicIndice, frameFloorPitD2C);
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
 T0121015:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
  /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C);
-		f112_drawCeilingPit(k64_ceilingPitD2C_GraphicIndice, &g153_FrameFloorPit_D2C, posX, posY, false);
+		f112_drawCeilingPit(k64_ceilingPitD2C_GraphicIndice, &frameCeilingPitD2C, posX, posY, false);
 T0121016:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, order);
 	}
@@ -1887,18 +1880,25 @@ T0121016:
 }
 
 void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
-	static DoorFrames g185_doorFrame_D1L = DoorFrames( // @ G0185_s_Graphic558_Frames_Door_D1L
+	static Frame doorFrameTopD1L = Frame(0, 31, 14, 17, 64, 4, 16, 0); // @ G0176_s_Graphic558_Frame_DoorFrameTop_D1L
+	static Frame frameStairsUpFrontD1L = Frame(0, 31, 9, 108, 16, 100, 0, 0); // @ G0116_s_Graphic558_Frame_StairsUpFront_D1L
+	static Frame frameStairsDownFrontD1L = Frame(0, 31, 18, 108, 16, 91, 0, 0); // @ G0127_s_Graphic558_Frame_StairsDownFront_D1L
+	static Frame frameStairsUpSideD1L = Frame(32, 63, 57, 99, 16, 43, 0, 0); // @ G0134_s_Graphic558_Frame_StairsUpSide_D1L
+	static Frame frameStairsDownSideD1L = Frame(32, 63, 60, 98, 16, 39, 0, 0); // @ G0136_s_Graphic558_Frame_StairsDownSide_D1L
+	static Frame frameFloorPitD1L = Frame(0, 63, 93, 116, 32, 24, 0, 0); // @ G0146_s_Graphic558_Frame_FloorPit_D1L
+	static Frame frameCeilingPitD1L = Frame(0, 63, 8, 16, 32, 9, 0, 0); // @ G0155_s_Graphic558_Frame_CeilingPit_D1L
+	static DoorFrames doorFrameD1L = DoorFrames( // @ G0185_s_Graphic558_Frames_Door_D1L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-													  Frame(0, 31, 17, 102, 48, 88, 64, 0),	/* Closed Or Destroyed */
-													  Frame(0, 31, 17, 38, 48, 88, 64, 66),	/* Vertical Closed one fourth */
-													  Frame(0, 31, 17, 60, 48, 88, 64, 44),	/* Vertical Closed half */
-													  Frame(0, 31, 17, 82, 48, 88, 64, 22),	/* Vertical Closed three fourth */
-													  Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed one fourth */
-													  Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed half */
-													  Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed three fourth */
-													  Frame(20, 31, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed one fourth */
-													  Frame(8, 31, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed half */
-													  Frame(0, 31, 17, 102, 48, 88, 52, 0)	/* Right Horizontal Closed three fourth */
+		Frame(0, 31, 17, 102, 48, 88, 64, 0),	/* Closed Or Destroyed */
+		Frame(0, 31, 17, 38, 48, 88, 64, 66),	/* Vertical Closed one fourth */
+		Frame(0, 31, 17, 60, 48, 88, 64, 44),	/* Vertical Closed half */
+		Frame(0, 31, 17, 82, 48, 88, 64, 22),	/* Vertical Closed three fourth */
+		Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed one fourth */
+		Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed half */
+		Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed three fourth */
+		Frame(20, 31, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed one fourth */
+		Frame(8, 31, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed half */
+		Frame(0, 31, 17, 102, 48, 88, 52, 0)	/* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
@@ -1909,9 +1909,9 @@ void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
-			f104_drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g116_FrameStairsUpFront_D1L);
+			f104_drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, frameStairsUpFrontD1L);
 		} else {
-			f104_drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g127_FrameStairsDownFront_D1L);
+			f104_drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, frameStairsDownFrontD1L);
 		}
 		goto T0122019;
 	case k0_ElementTypeWall:
@@ -1920,9 +1920,9 @@ void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
 		return;
 	case k18_ElementTypeStairsSide:
 		if (squareAspect[k2_StairsUpAspect]) {
-			f104_drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g134_FrameStairsUpSide_D1L);
+			f104_drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, frameStairsUpSideD1L);
 		} else {
-			f104_drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g136_FrameStairsDownSide_D1L);
+			f104_drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, frameStairsDownSideD1L);
 		}
 	case k16_DoorSideElemType:
 		order = k0x0032_CellOrder_BackRight_FrontRight;
@@ -1930,13 +1930,13 @@ void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
 	case k17_DoorFrontElemType:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, k0x0028_CellOrder_DoorPass1_BackRight);
-		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, g176_Frame_DoorFrameTop_D1L);
+		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, doorFrameTopD1L);
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &g185_doorFrame_D1L);
+					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1L);
 		order = k0x0039_CellOrder_DoorPass2_FrontRight;
 		goto T0122021;
 	case k2_ElementTypePit:
-		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k59_floorPit_invisible_D1L_GraphicIndice : k53_FloorPit_D1L_GraphicIndice, g146_FrameFloorPit_D1L);
+		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k59_floorPit_invisible_D1L_GraphicIndice : k53_FloorPit_D1L_GraphicIndice, frameFloorPitD1L);
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
 T0122019:
@@ -1944,7 +1944,7 @@ T0122019:
 T0122020:
 		 /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
-		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &g155_FrameFloorPit_D1L, posX, posY, false);
+		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1L, posX, posY, false);
 T0122021:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, order);
 	}


Commit: 469b026bc7821fb592c799d55a101c8af6d5198c
    https://github.com/scummvm/scummvm/commit/469b026bc7821fb592c799d55a101c8af6d5198c
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Get rid of more global variables in gfx

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index a5c87a0..4ab2ea7 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -40,36 +40,24 @@
 
 namespace DM {
 
-Frame g177_Frame_DoorFrameTop_D1C = Frame(48, 175, 14, 17, 64, 4, 0, 0); // @ G0177_s_Graphic558_Frame_DoorFrameTop_D1C
-Frame g178_Frame_DoorFrameTop_D1R = Frame(192, 223, 14, 17, 64, 4, 16, 0); // @ G0178_s_Graphic558_Frame_DoorFrameTop_D1R
 Frame g110_FrameStairsUpFront_D3L = Frame(0, 79, 25, 70, 40, 46, 0, 0); // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L
 Frame g111_FrameStairsUpFront_D3C = Frame(64, 159, 25, 70, 48, 46, 0, 0); // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C
 Frame g112_FrameStairsUpFront_D3R = Frame(149, 223, 25, 70, 40, 46, 5, 0); // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R
-Frame g117_FrameStairsUpFront_D1C = Frame(32, 191, 9, 108, 80, 100, 0, 0); // @ G0117_s_Graphic558_Frame_StairsUpFront_D1C
-Frame g118_FrameStairsUpFront_D1R = Frame(192, 223, 9, 108, 16, 100, 0, 0); // @ G0118_s_Graphic558_Frame_StairsUpFront_D1R
 Frame g119_FrameStairsUpFront_D0L = Frame(0, 31, 58, 101, 16, 44, 0, 0); // @ G0119_s_Graphic558_Frame_StairsUpFront_D0L
 Frame g120_FrameStairsUpFront_D0R = Frame(192, 223, 58, 101, 16, 44, 0, 0); // @ G0120_s_Graphic558_Frame_StairsUpFront_D0R
 Frame g121_FrameStairsDownFront_D3L = Frame(0, 79, 28, 68, 40, 41, 0, 0); // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L
 Frame g122_FrameStairsDownFront_D3C = Frame(64, 159, 28, 70, 48, 43, 0, 0); // @ G0122_s_Graphic558_Frame_StairsDownFront_D3C
 Frame g123_FrameStairsDownFront_D3R = Frame(149, 223, 28, 68, 40, 41, 5, 0); // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R
-Frame g128_FrameStairsDownFront_D1C = Frame(32, 191, 18, 108, 80, 91, 0, 0); // @ G0128_s_Graphic558_Frame_StairsDownFront_D1C
-Frame g129_FrameStairsDownFront_D1R = Frame(192, 223, 18, 108, 16, 91, 0, 0); // @ G0129_s_Graphic558_Frame_StairsDownFront_D1R
 Frame g130_FrameStairsDownFront_D0L = Frame(0, 31, 76, 135, 16, 60, 0, 0); // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L
 Frame g131_FrameStairsDownFront_D0R = Frame(192, 223, 76, 135, 16, 60, 0, 0); // @ G0131_s_Graphic558_Frame_StairsDownFront_D0R
-Frame g135_FrameStairsUpSide_D1R = Frame(160, 191, 57, 99, 16, 43, 0, 0); // @ G0135_s_Graphic558_Frame_StairsUpSide_D1R
-Frame g137_FrameStairsDownSide_D1R = Frame(160, 191, 60, 98, 16, 39, 0, 0); // @ G0137_s_Graphic558_Frame_StairsDownSide_D1R
 Frame g138_FrameStairsSide_D0L = Frame(0, 15, 73, 85, 8, 13, 0, 0); // @ G0138_s_Graphic558_Frame_StairsSide_D0L
 Frame g139_FrameStairsSide_D0R = Frame(208, 223, 73, 85, 8, 13, 0, 0); // @ G0139_s_Graphic558_Frame_StairsSide_D0R
 Frame g140_FrameFloorPit_D3L = Frame(0, 79, 66, 73, 40, 8, 0, 0); // @ G0140_s_Graphic558_Frame_FloorPit_D3L
 Frame g141_FrameFloorPit_D3C = Frame(64, 159, 66, 73, 48, 8, 0, 0); // @ G0141_s_Graphic558_Frame_FloorPit_D3C
 Frame g142_FrameFloorPit_D3R = Frame(144, 223, 66, 73, 40, 8, 0, 0); // @ G0142_s_Graphic558_Frame_FloorPit_D3R
-Frame g147_FrameFloorPit_D1C = Frame(32, 191, 93, 116, 80, 24, 0, 0); // @ G0147_s_Graphic558_Frame_FloorPit_D1C
-Frame g148_FrameFloorPit_D1R = Frame(160, 223, 93, 116, 32, 24, 0, 0); // @ G0148_s_Graphic558_Frame_FloorPit_D1R
 Frame g149_FrameFloorPit_D0L = Frame(0, 31, 124, 135, 16, 12, 0, 0); // @ G0149_s_Graphic558_Frame_FloorPit_D0L
 Frame g150_FrameFloorPit_D0C = Frame(16, 207, 124, 135, 96, 12, 0, 0); // @ G0150_s_Graphic558_Frame_FloorPit_D0C
 Frame g151_FrameFloorPit_D0R = Frame(192, 223, 124, 135, 16, 12, 0, 0); // @ G0151_s_Graphic558_Frame_FloorPit_D0R
-Frame g156_FrameFloorPit_D1C = Frame(32, 191, 8, 16, 80, 9, 0, 0); // @ G0156_s_Graphic558_Frame_CeilingPit_D1C
-Frame g157_FrameFloorPit_D1R = Frame(160, 223, 8, 16, 32, 9, 0, 0); // @ G0157_s_Graphic558_Frame_CeilingPit_D1R
 Frame g158_FrameFloorPit_D0L = Frame(0, 15, 0, 3, 8, 4, 0, 0); // @ G0158_s_Graphic558_Frame_CeilingPit_D0L
 Frame g159_FrameFloorPit_D0C = Frame(16, 207, 0, 3, 96, 4, 0, 0); // @ G0159_s_Graphic558_Frame_CeilingPit_D0C
 Frame g160_FrameFloorPit_D0R = Frame(208, 223, 0, 3, 8, 4, 0, 0); // @ G0160_s_Graphic558_Frame_CeilingPit_D0R
@@ -1954,31 +1942,37 @@ T0122021:
 }
 
 void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {
-	static DoorFrames g187_doorFrame_D1R = DoorFrames( // @ G0187_s_Graphic558_Frames_Door_D1R
+	static Frame doorFrameTopD1R = Frame(192, 223, 14, 17, 64, 4, 16, 0); // @ G0178_s_Graphic558_Frame_DoorFrameTop_D1R
+	static Frame frameStairsUpFrontD1R = Frame(192, 223, 9, 108, 16, 100, 0, 0); // @ G0118_s_Graphic558_Frame_StairsUpFront_D1R
+	static Frame frameStairsDownFrontD1R = Frame(192, 223, 18, 108, 16, 91, 0, 0); // @ G0129_s_Graphic558_Frame_StairsDownFront_D1R
+	static Frame frameStairsUpSideD1R = Frame(160, 191, 57, 99, 16, 43, 0, 0); // @ G0135_s_Graphic558_Frame_StairsUpSide_D1R
+	static Frame frameStairsDownSideD1R = Frame(160, 191, 60, 98, 16, 39, 0, 0); // @ G0137_s_Graphic558_Frame_StairsDownSide_D1R
+	static Frame frameFloorPitD1R = Frame(160, 223, 93, 116, 32, 24, 0, 0); // @ G0148_s_Graphic558_Frame_FloorPit_D1R
+	static Frame frameCeilingPitD1R = Frame(160, 223, 8, 16, 32, 9, 0, 0); // @ G0157_s_Graphic558_Frame_CeilingPit_D1R
+	static DoorFrames doorFrameD1R = DoorFrames( // @ G0187_s_Graphic558_Frames_Door_D1R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-													  Frame(192, 223, 17, 102, 48, 88, 0, 0),     /* Closed Or Destroyed */
-													  Frame(192, 223, 17, 38, 48, 88, 0, 66),     /* Vertical Closed one fourth */
-													  Frame(192, 223, 17, 60, 48, 88, 0, 44),     /* Vertical Closed half */
-													  Frame(192, 223, 17, 82, 48, 88, 0, 22),   /* Vertical Closed three fourth */
-													  Frame(192, 203, 17, 102, 48, 88, 36, 0),     /* Left Horizontal Closed one fourth */
-													  Frame(192, 215, 17, 102, 48, 88, 24, 0),     /* Left Horizontal Closed half */
-													  Frame(192, 223, 17, 102, 48, 88, 12, 0),   /* Left Horizontal Closed three fourth */
-													  Frame(0, 0, 0, 0, 0, 0, 0, 0),     /* Right Horizontal Closed one fourth */
-													  Frame(0, 0, 0, 0, 0, 0, 0, 0),     /* Right Horizontal Closed half */
-													  Frame(0, 0, 0, 0, 0, 0, 0, 0)
-	); /* Right Horizontal Closed three fourth */
+		Frame(192, 223, 17, 102, 48, 88, 0, 0),   /* Closed Or Destroyed */
+		Frame(192, 223, 17, 38, 48, 88, 0, 66),   /* Vertical Closed one fourth */
+		Frame(192, 223, 17, 60, 48, 88, 0, 44),   /* Vertical Closed half */
+		Frame(192, 223, 17, 82, 48, 88, 0, 22),   /* Vertical Closed three fourth */
+		Frame(192, 203, 17, 102, 48, 88, 36, 0),  /* Left Horizontal Closed one fourth */
+		Frame(192, 215, 17, 102, 48, 88, 24, 0),  /* Left Horizontal Closed half */
+		Frame(192, 223, 17, 102, 48, 88, 12, 0),  /* Left Horizontal Closed three fourth */
+		Frame(0, 0, 0, 0, 0, 0, 0, 0),            /* Right Horizontal Closed one fourth */
+		Frame(0, 0, 0, 0, 0, 0, 0, 0),            /* Right Horizontal Closed half */
+		Frame(0, 0, 0, 0, 0, 0, 0, 0)             /* Right Horizontal Closed three fourth */
+	);
 
 	int16 order;
 	uint16 squareAspect[5];
 
-
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g118_FrameStairsUpFront_D1R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, frameStairsUpFrontD1R);
 		} else {
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g129_FrameStairsDownFront_D1R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, frameStairsDownFrontD1R);
 		}
 		goto T0123019;
 	case k0_ElementTypeWall:
@@ -1987,9 +1981,9 @@ void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {
 		return;
 	case k18_ElementTypeStairsSide:
 		if (squareAspect[k2_StairsUpAspect]) {
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g135_FrameStairsUpSide_D1R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, frameStairsUpSideD1R);
 		} else {
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g137_FrameStairsDownSide_D1R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, frameStairsDownSideD1R);
 		}
 	case k16_DoorSideElemType:
 		order = k0x0041_CellOrder_BackLeft_FrontLeft;
@@ -1997,21 +1991,21 @@ void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {
 	case k17_DoorFrontElemType:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, k0x0018_CellOrder_DoorPass1_BackLeft);
-		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, g178_Frame_DoorFrameTop_D1R);
+		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, doorFrameTopD1R);
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &g187_doorFrame_D1R);
+					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1R);
 		order = k0x0049_CellOrder_DoorPass2_FrontLeft;
 		goto T0123021;
 	case k2_ElementTypePit:
 		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect] ? k59_floorPit_invisible_D1L_GraphicIndice
-														   : k53_FloorPit_D1L_GraphicIndice, g148_FrameFloorPit_D1R);
+														   : k53_FloorPit_D1L_GraphicIndice, frameFloorPitD1R);
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
 T0123019:
 		order = k0x0041_CellOrder_BackLeft_FrontLeft;
 T0123020:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &g157_FrameFloorPit_D1R, posX, posY, true);
+		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1R, posX, posY, true);
 T0123021:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, order);
 	}
@@ -2019,20 +2013,26 @@ T0123021:
 		f113_drawField(&g188_FieldAspects[k8_ViewSquare_D1R], g163_FrameWalls[k8_ViewSquare_D1R]._box);
 	}
 }
+
 void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
-	static Box g107_BoxThievesEyeVisibleArea(0, 95, 0, 94); // @ G0107_s_Graphic558_Box_ThievesEye_VisibleArea 
+	static Frame doorFrameTopD1C = Frame(48, 175, 14, 17, 64, 4, 0, 0); // @ G0177_s_Graphic558_Frame_DoorFrameTop_D1C
+	static Frame frameStairsUpFrontD1C = Frame(32, 191, 9, 108, 80, 100, 0, 0); // @ G0117_s_Graphic558_Frame_StairsUpFront_D1C
+	static Frame frameStairsDownFrontD1C = Frame(32, 191, 18, 108, 80, 91, 0, 0); // @ G0128_s_Graphic558_Frame_StairsDownFront_D1C
+	static Frame frameFloorPitD1C = Frame(32, 191, 93, 116, 80, 24, 0, 0); // @ G0147_s_Graphic558_Frame_FloorPit_D1C
+	static Frame frameCeilingPitD1C = Frame(32, 191, 8, 16, 80, 9, 0, 0); // @ G0156_s_Graphic558_Frame_CeilingPit_D1C
+	static Box boxThievesEyeVisibleArea(0, 95, 0, 94); // @ G0107_s_Graphic558_Box_ThievesEye_VisibleArea 
+
 	int16 order;
 	uint16 squareAspect[5];
 	byte* bitmap;
 
-
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (_vm->_dungeonMan->_g285_squareAheadElement = (ElementType)squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
-			f104_drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, g117_FrameStairsUpFront_D1C);
+			f104_drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, frameStairsUpFrontD1C);
 		} else {
-			f104_drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, g128_FrameStairsDownFront_D1C);
+			f104_drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, frameStairsDownFrontD1C);
 		}
 		goto T0124017;
 	case k0_ElementTypeWall:
@@ -2042,13 +2042,13 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
 			f491_isDerivedBitmapInCache(k1_DerivedBitmapThievesEyeVisibleArea);
 			f132_blitToBitmap(_g296_bitmapViewport, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
-							  g107_BoxThievesEyeVisibleArea,
+							  boxThievesEyeVisibleArea,
 							  _boxThievesEyeViewPortVisibleArea._x1,
 							  _boxThievesEyeViewPortVisibleArea._y1,
 							  k112_byteWidthViewport, 48, kM1_ColorNoTransparency, 136, 95);
 			bitmap = f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice);
 			f132_blitToBitmap(bitmap, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
-							  g107_BoxThievesEyeVisibleArea,
+							  boxThievesEyeVisibleArea,
 							  0, 0, 48, 48, k10_ColorFlesh, 95, 95);
 		}
 		f101_drawWallSetBitmapWithoutTransparency(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k6_ViewSquare_D1C]);
@@ -2066,7 +2066,7 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 	case k17_DoorFrontElemType:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
-		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, g177_Frame_DoorFrameTop_D1C);
+		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, doorFrameTopD1C);
 		f100_drawWallSetBitmap(_g708_bitmapWallSet_DoorFrameLeft_D1C, _doorFrameLeftD1C);
 		f100_drawWallSetBitmap(_g710_bitmapWallSet_DoorFrameRight_D1C, _doorFrameRightD1C);
 		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
@@ -2077,14 +2077,14 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0124018;
 	case k2_ElementTypePit:
-		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k60_floorPitInvisibleD1C_GraphicIndice : k54_FloorPit_D1C_GraphicIndice, g147_FrameFloorPit_D1C);
+		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k60_floorPitInvisibleD1C_GraphicIndice : k54_FloorPit_D1C_GraphicIndice, frameFloorPitD1C);
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
 T0124017:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
 /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C);
-		f112_drawCeilingPit(k66_ceilingPitD1C_GraphicIndice, &g156_FrameFloorPit_D1C, posX, posY, false);
+		f112_drawCeilingPit(k66_ceilingPitD1C_GraphicIndice, &frameCeilingPitD1C, posX, posY, false);
 T0124018:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, order);
 	}


Commit: a6d5ad7c998c146b45d29db7a3ddf7bf6c253b74
    https://github.com/scummvm/scummvm/commit/a6d5ad7c998c146b45d29db7a3ddf7bf6c253b74
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: More work on global variables

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 4ab2ea7..0cd85fb 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -40,27 +40,6 @@
 
 namespace DM {
 
-Frame g110_FrameStairsUpFront_D3L = Frame(0, 79, 25, 70, 40, 46, 0, 0); // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L
-Frame g111_FrameStairsUpFront_D3C = Frame(64, 159, 25, 70, 48, 46, 0, 0); // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C
-Frame g112_FrameStairsUpFront_D3R = Frame(149, 223, 25, 70, 40, 46, 5, 0); // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R
-Frame g119_FrameStairsUpFront_D0L = Frame(0, 31, 58, 101, 16, 44, 0, 0); // @ G0119_s_Graphic558_Frame_StairsUpFront_D0L
-Frame g120_FrameStairsUpFront_D0R = Frame(192, 223, 58, 101, 16, 44, 0, 0); // @ G0120_s_Graphic558_Frame_StairsUpFront_D0R
-Frame g121_FrameStairsDownFront_D3L = Frame(0, 79, 28, 68, 40, 41, 0, 0); // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L
-Frame g122_FrameStairsDownFront_D3C = Frame(64, 159, 28, 70, 48, 43, 0, 0); // @ G0122_s_Graphic558_Frame_StairsDownFront_D3C
-Frame g123_FrameStairsDownFront_D3R = Frame(149, 223, 28, 68, 40, 41, 5, 0); // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R
-Frame g130_FrameStairsDownFront_D0L = Frame(0, 31, 76, 135, 16, 60, 0, 0); // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L
-Frame g131_FrameStairsDownFront_D0R = Frame(192, 223, 76, 135, 16, 60, 0, 0); // @ G0131_s_Graphic558_Frame_StairsDownFront_D0R
-Frame g138_FrameStairsSide_D0L = Frame(0, 15, 73, 85, 8, 13, 0, 0); // @ G0138_s_Graphic558_Frame_StairsSide_D0L
-Frame g139_FrameStairsSide_D0R = Frame(208, 223, 73, 85, 8, 13, 0, 0); // @ G0139_s_Graphic558_Frame_StairsSide_D0R
-Frame g140_FrameFloorPit_D3L = Frame(0, 79, 66, 73, 40, 8, 0, 0); // @ G0140_s_Graphic558_Frame_FloorPit_D3L
-Frame g141_FrameFloorPit_D3C = Frame(64, 159, 66, 73, 48, 8, 0, 0); // @ G0141_s_Graphic558_Frame_FloorPit_D3C
-Frame g142_FrameFloorPit_D3R = Frame(144, 223, 66, 73, 40, 8, 0, 0); // @ G0142_s_Graphic558_Frame_FloorPit_D3R
-Frame g149_FrameFloorPit_D0L = Frame(0, 31, 124, 135, 16, 12, 0, 0); // @ G0149_s_Graphic558_Frame_FloorPit_D0L
-Frame g150_FrameFloorPit_D0C = Frame(16, 207, 124, 135, 96, 12, 0, 0); // @ G0150_s_Graphic558_Frame_FloorPit_D0C
-Frame g151_FrameFloorPit_D0R = Frame(192, 223, 124, 135, 16, 12, 0, 0); // @ G0151_s_Graphic558_Frame_FloorPit_D0R
-Frame g158_FrameFloorPit_D0L = Frame(0, 15, 0, 3, 8, 4, 0, 0); // @ G0158_s_Graphic558_Frame_CeilingPit_D0L
-Frame g159_FrameFloorPit_D0C = Frame(16, 207, 0, 3, 96, 4, 0, 0); // @ G0159_s_Graphic558_Frame_CeilingPit_D0C
-Frame g160_FrameFloorPit_D0R = Frame(208, 223, 0, 3, 8, 4, 0, 0); // @ G0160_s_Graphic558_Frame_CeilingPit_D0R
 FieldAspect g188_FieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects
 								  /* { NativeBitmapRelativeIndex, BaseStartUnitIndex, Transparent color, Mask, ByteWidth, Height, X, BitPlaneWordCount } */
 	FieldAspect(0, 63, 0x8A, 0xFF,  0,   0,  0, 64),   /* D3C */
@@ -1448,6 +1427,9 @@ void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) {
 
 void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 	static Frame doorFrameLeftD3L = Frame(0, 31, 28, 70, 16, 43, 0, 0); // @ G0164_s_Graphic558_Frame_DoorFrameLeft_D3L
+	static Frame frameStairsUpFrontD3L = Frame(0, 79, 25, 70, 40, 46, 0, 0); // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L
+	static Frame frameStairsDownFrontD3L = Frame(0, 79, 28, 68, 40, 41, 0, 0); // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L
+	static Frame frameFloorPitD3L = Frame(0, 79, 66, 73, 40, 8, 0, 0); // @ G0140_s_Graphic558_Frame_FloorPit_D3L
 	static DoorFrames doorFrameD3L = DoorFrames( // @ G0179_s_Graphic558_Frames_Door_D3L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
 		Frame(24, 71, 28, 67, 24, 41, 0, 0),   /* Closed Or Destroyed */
@@ -1469,9 +1451,9 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_StairsFrontElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			f104_drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g110_FrameStairsUpFront_D3L);
+			f104_drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, frameStairsUpFrontD3L);
 		else
-			f104_drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g121_FrameStairsDownFront_D3L);
+			f104_drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, frameStairsDownFrontD3L);
 		goto T0116015_redEagle;
 	case k0_WallElemType:
 		f100_drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k1_ViewSquare_D3L]);
@@ -1495,7 +1477,7 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 		goto T0116017_orangeElk;
 	case k2_ElementTypePit:
 		if (!squareAspect[k2_PitInvisibleAspect]) {
-			f104_drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, g140_FrameFloorPit_D3L);
+			f104_drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, frameFloorPitD3L);
 		}
 	case k5_ElementTypeTeleporter:
 	case k1_ElementTypeCorridor:
@@ -1514,6 +1496,9 @@ T0116017_orangeElk:
 
 void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 	static Frame doorFrameRightD3R = Frame(192, 223, 28, 70, 16, 43, 0, 0); // @ G0165_s_Graphic558_Frame_DoorFrameRight_D3R
+	static Frame frameStairsUpFrontD3R = Frame(149, 223, 25, 70, 40, 46, 5, 0); // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R
+	static Frame frameStairsDownFrontD3R = Frame(149, 223, 28, 68, 40, 41, 5, 0); // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R
+	static Frame frameFloorPitD3R = Frame(144, 223, 66, 73, 40, 8, 0, 0); // @ G0142_s_Graphic558_Frame_FloorPit_D3R
 	static DoorFrames doorFrameD3R = DoorFrames( // @ G0181_s_Graphic558_Frames_Door_D3R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
 		Frame(150, 197, 28, 67, 24, 41, 0, 0),	/* Closed Or Destroyed */
@@ -1535,9 +1520,9 @@ void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g112_FrameStairsUpFront_D3R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, frameStairsUpFrontD3R);
 		} else {
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g123_FrameStairsDownFront_D3R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, frameStairsDownFrontD3R);
 		}
 		goto T0117016;
 	case k0_ElementTypeWall:
@@ -1566,7 +1551,7 @@ void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 		goto T0117018;
 	case k2_ElementTypePit:
 		if (!squareAspect[k2_PitInvisibleAspect]) {
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, g142_FrameFloorPit_D3R);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, frameFloorPitD3R);
 		}
 	case k5_ElementTypeTeleporter:
 	case k1_ElementTypeCorridor:
@@ -1586,6 +1571,9 @@ T0117018:
 void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 	static Frame doorFrameLeftD3C = Frame(64, 95, 27, 70, 16, 44, 0, 0); // @ G0166_s_Graphic558_Frame_DoorFrameLeft_D3C
 	static Frame doorFrameRightD3C = Frame(128, 159, 27, 70, 16, 44, 0, 0); // @ G0167_s_Graphic558_Frame_DoorFrameRight_D3C
+	static Frame frameStairsUpFrontD3C = Frame(64, 159, 25, 70, 48, 46, 0, 0); // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C
+	static Frame frameStairsDownFrontD3C = Frame(64, 159, 28, 70, 48, 43, 0, 0); // @ G0122_s_Graphic558_Frame_StairsDownFront_D3C
+	static Frame frameFloorPitD3C = Frame(64, 159, 66, 73, 48, 8, 0, 0); // @ G0141_s_Graphic558_Frame_FloorPit_D3C
 	static DoorFrames doorFrameD3C = DoorFrames( // @ G0180_s_Graphic558_Frames_Door_D3C
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
 		Frame(88, 135, 28, 67, 24, 41, 0, 0),		/* Closed Or Destroyed */
@@ -1607,9 +1595,9 @@ void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElemAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
-			f104_drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, g111_FrameStairsUpFront_D3C);
+			f104_drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, frameStairsUpFrontD3C);
 		} else {
-			f104_drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, g122_FrameStairsDownFront_D3C);
+			f104_drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, frameStairsDownFrontD3C);
 		}
 		goto T0118027;
 	case k0_ElementTypeWall:
@@ -1634,7 +1622,7 @@ void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 		goto T0118028;
 	case k2_ElementTypePit:
 		if (!squareAspect[k2_PitInvisibleAspect]) {
-			f104_drawFloorPitOrStairsBitmap(k50_FloorPit_D3C_GraphicIndice, g141_FrameFloorPit_D3C);
+			f104_drawFloorPitOrStairsBitmap(k50_FloorPit_D3C_GraphicIndice, frameFloorPitD3C);
 		}
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
@@ -2094,12 +2082,16 @@ T0124018:
 }
 
 void DisplayMan::f125_drawSquareD0L(Direction dir, int16 posX, int16 posY) {
+	static Frame frameStairsSideD0L = Frame(0, 15, 73, 85, 8, 13, 0, 0); // @ G0138_s_Graphic558_Frame_StairsSide_D0L
+	static Frame g149_FrameFloorPit_D0L = Frame(0, 31, 124, 135, 16, 12, 0, 0); // @ G0149_s_Graphic558_Frame_FloorPit_D0L
+	static Frame g158_FrameCeilingPit_D0L = Frame(0, 15, 0, 3, 8, 4, 0, 0); // @ G0158_s_Graphic558_Frame_CeilingPit_D0L
+
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[0]) {
 	case k18_StairsSideElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			f104_drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, g138_FrameStairsSide_D0L);
+			f104_drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, frameStairsSideD0L);
 		break;
 	case k0_WallElemType:
 		f100_drawWallSetBitmap(_g701_bitmapWallSet_Wall_D0L, g163_FrameWalls[k10_ViewSquare_D0L]);
@@ -2110,21 +2102,24 @@ void DisplayMan::f125_drawSquareD0L(Direction dir, int16 posX, int16 posY) {
 }
 
 void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
-	uint16 squareAspect[5];
+	static Frame frameStairsSideD0R = Frame(208, 223, 73, 85, 8, 13, 0, 0); // @ G0139_s_Graphic558_Frame_StairsSide_D0R
+	static Frame frameFloorPitD0R = Frame(192, 223, 124, 135, 16, 12, 0, 0); // @ G0151_s_Graphic558_Frame_FloorPit_D0R
+	static Frame frameCeilingPitD0R = Frame(208, 223, 0, 3, 8, 4, 0, 0); // @ G0160_s_Graphic558_Frame_CeilingPit_D0R
 
+	uint16 squareAspect[5];
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElemAspect]) {
 	case k18_ElementTypeStairsSide:
-		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R);
+		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, frameStairsSideD0R);
 		return;
 	case k2_ElementTypePit:
 		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect] ? k61_floorPitInvisibleD0L_GraphicIndice
-														   : k55_FloorPit_D0L_GraphicIndice, g151_FrameFloorPit_D0R);
+														   : k55_FloorPit_D0L_GraphicIndice, frameFloorPitD0R);
 	case k1_CorridorElemType:
 	case k16_DoorSideElemType:
 	case k5_ElementTypeTeleporter:
-		f112_drawCeilingPit(k67_ceilingPitD0L_grahicIndice, &g160_FrameFloorPit_D0R, posX, posY, true);
+		f112_drawCeilingPit(k67_ceilingPitD0L_grahicIndice, &frameCeilingPitD0R, posX, posY, true);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k11_ViewSquare_D0R, k0x0001_CellOrder_BackLeft);
 		break;
 	case k0_ElementTypeWall:
@@ -2138,6 +2133,12 @@ void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
 
 void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 	static Frame doorFrameD0C = Frame(96, 127, 0, 122, 16, 123, 0, 0); // @ G0172_s_Graphic558_Frame_DoorFrame_D0C
+	static Frame frameStairsUpFrontD0L = Frame(0, 31, 58, 101, 16, 44, 0, 0); // @ G0119_s_Graphic558_Frame_StairsUpFront_D0L
+	static Frame frameStairsDownFrontD0L = Frame(0, 31, 76, 135, 16, 60, 0, 0); // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L
+	static Frame frameStairsUpFrontD0R = Frame(192, 223, 58, 101, 16, 44, 0, 0); // @ G0120_s_Graphic558_Frame_StairsUpFront_D0R
+	static Frame frameStairsDownFrontD0R = Frame(192, 223, 76, 135, 16, 60, 0, 0); // @ G0131_s_Graphic558_Frame_StairsDownFront_D0R
+	static Frame frameFloorPitD0C = Frame(16, 207, 124, 135, 96, 12, 0, 0); // @ G0150_s_Graphic558_Frame_FloorPit_D0C
+	static Frame frameCeilingPitD0C = Frame(16, 207, 0, 3, 96, 4, 0, 0); // @ G0159_s_Graphic558_Frame_CeilingPit_D0C
 	static Box boxThievesEyeHoleInDoorFrame(0, 31, 19, 113); // @ G0108_s_Graphic558_Box_ThievesEye_HoleInDoorFrame 
 
 	uint16 squareAspect[5];
@@ -2157,17 +2158,17 @@ void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 		break;
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
-			f104_drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g119_FrameStairsUpFront_D0L);
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g120_FrameStairsUpFront_D0R);
+			f104_drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, frameStairsUpFrontD0L);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, frameStairsUpFrontD0R);
 		} else {
-			f104_drawFloorPitOrStairsBitmap(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g130_FrameStairsDownFront_D0L);
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g131_FrameStairsDownFront_D0R);
+			f104_drawFloorPitOrStairsBitmap(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, frameStairsDownFrontD0L);
+			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, frameStairsDownFrontD0R);
 		}
 		break;
 	case k2_ElementTypePit:
-		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k62_flootPitInvisibleD0C_graphicIndice : k56_FloorPit_D0C_GraphicIndice, g150_FrameFloorPit_D0C);
+		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k62_flootPitInvisibleD0C_graphicIndice : k56_FloorPit_D0C_GraphicIndice, frameFloorPitD0C);
 	}
-	f112_drawCeilingPit(k68_ceilingPitD0C_graphicIndice, &g159_FrameFloorPit_D0C, posX, posY, false);
+	f112_drawCeilingPit(k68_ceilingPitD0C_graphicIndice, &frameCeilingPitD0C, posX, posY, false);
 	f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k9_ViewSquare_D0C, k0x0021_CellOrder_BackLeft_BackRight);
 	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
 		f113_drawField(&g188_FieldAspects[k9_ViewSquare_D0C], g163_FrameWalls[k9_ViewSquare_D0C]._box);


Commit: 013b55533864e2f59a8a54cb6863cd3994fb35c3
    https://github.com/scummvm/scummvm/commit/013b55533864e2f59a8a54cb6863cd3994fb35c3
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing code in f125_drawSquareD0L, rename a constant

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 7056ab6..b745a99 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -838,8 +838,8 @@ void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, Direction dir, int16
 	bool frontRandomWallOrnamentAllowed = false;
 	bool squareIsFakeWall;
 
-	aspectArray[k0_ElemAspect] = Square(AL0307_uc_Square).getType();
-	switch (aspectArray[k0_ElemAspect]) {
+	aspectArray[k0_ElementAspect] = Square(AL0307_uc_Square).getType();
+	switch (aspectArray[k0_ElementAspect]) {
 	case k0_ElementTypeWall:
 		switch (dir) {
 		case kDirNorth:
@@ -895,26 +895,26 @@ T0172010_ClosedFakeWall:
 		break;
 	case k6_ElementTypeFakeWall:
 		if (!getFlag(AL0307_uc_Square, k0x0004_FakeWallOpen)) {
-			aspectArray[k0_ElemAspect] = k0_ElementTypeWall;
+			aspectArray[k0_ElementAspect] = k0_ElementTypeWall;
 			leftRandomWallOrnamentAllowed = rightRandomWallOrnamentAllowed = frontRandomWallOrnamentAllowed = getFlag(AL0307_uc_Square, k0x0008_FakeWallRandOrnOrFootPAllowed);
 			squareIsFakeWall = true;
 			goto T0172010_ClosedFakeWall;
 		}
-		aspectArray[k0_ElemAspect] = k1_CorridorElemType;
+		aspectArray[k0_ElementAspect] = k1_CorridorElemType;
 		AL0307_uc_FootprintsAllowed = getFlag(AL0307_uc_Square, k0x0008_FakeWallRandOrnOrFootPAllowed) ? 8 : 0;
 		// No break on purpose
 	case k1_CorridorElemType:
 	case k2_ElementTypePit:
 	case k5_ElementTypeTeleporter:
-		if (aspectArray[k0_ElemAspect] == k1_CorridorElemType) {
+		if (aspectArray[k0_ElementAspect] == k1_CorridorElemType) {
 			aspectArray[k4_FloorOrnOrdAspect] = f170_getRandomOrnOrdinal(getFlag(AL0307_uc_Square, k0x0008_CorridorRandOrnAllowed), _g269_currMap->_randFloorOrnCount, mapX, mapY, 30);
 			AL0307_uc_FootprintsAllowed = true;
-		} else if (aspectArray[k0_ElemAspect] == k2_ElementTypePit) {
+		} else if (aspectArray[k0_ElementAspect] == k2_ElementTypePit) {
 			if (getFlag(AL0307_uc_Square, k0x0008_PitOpen)) {
 				aspectArray[k2_PitInvisibleAspect] = getFlag(AL0307_uc_Square, k0x0004_PitInvisible);
 				AL0307_uc_FootprintsAllowed &= 0x0001;
 			} else {
-				aspectArray[k0_ElemAspect] = k1_CorridorElemType;
+				aspectArray[k0_ElementAspect] = k1_CorridorElemType;
 				AL0307_uc_FootprintsAllowed = true;
 			}
 		} else { // k5_ElementTypeTeleporter
@@ -935,7 +935,7 @@ T0172010_ClosedFakeWall:
 
 		break;
 	case k3_ElementTypeStairs:
-		aspectArray[k0_ElemAspect] = (bool((getFlag(AL0307_uc_Square, k0x0008_StairsNorthSouthOrient) >> 3)) == isOrientedWestEast(dir)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront;
+		aspectArray[k0_ElementAspect] = (bool((getFlag(AL0307_uc_Square, k0x0008_StairsNorthSouthOrient) >> 3)) == isOrientedWestEast(dir)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront;
 		aspectArray[k2_StairsUpAspect] = getFlag(AL0307_uc_Square, k0x0004_StairsUp);
 		AL0307_uc_FootprintsAllowed = false;
 		while ((curThing != Thing::_endOfList) && (curThing.getType() <= k3_SensorThingType))
@@ -943,9 +943,9 @@ T0172010_ClosedFakeWall:
 		break;
 	case k4_DoorElemType:
 		if (bool((getFlag(AL0307_uc_Square, k0x0008_DoorNorthSouthOrient) >> 3)) == isOrientedWestEast(dir)) {
-			aspectArray[k0_ElemAspect] = k16_DoorSideElemType;
+			aspectArray[k0_ElementAspect] = k16_DoorSideElemType;
 		} else {
-			aspectArray[k0_ElemAspect] = k17_DoorFrontElemType;
+			aspectArray[k0_ElementAspect] = k17_DoorFrontElemType;
 			aspectArray[k2_DoorStateAspect] = Square(AL0307_uc_Square).getDoorState();
 			aspectArray[k3_DoorThingIndexAspect] = f161_getSquareFirstThing(mapX, mapY).getIndex();
 		}
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index e75c6c2..0f13d07 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -161,7 +161,7 @@ enum TextType {
 };
 
 enum SquareAspectIndice {
-	k0_ElemAspect = 0, // @ C0_ELEMENT
+	k0_ElementAspect = 0, // @ C0_ELEMENT
 	k1_FirstGroupOrObjectAspect = 1, // @ C1_FIRST_GROUP_OR_OBJECT 
 	k2_RightWallOrnOrdAspect = 2, // @ C2_RIGHT_WALL_ORNAMENT_ORDINAL 
 	k3_FrontWallOrnOrdAspect = 3, // @ C3_FRONT_WALL_ORNAMENT_ORDINAL 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 0cd85fb..ec0dcd5 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1448,7 +1448,7 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 	int16 order;
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[k0_ElemAspect]) {
+	switch (squareAspect[k0_ElementAspect]) {
 	case k19_StairsFrontElemType:
 		if (squareAspect[k2_StairsUpAspect])
 			f104_drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, frameStairsUpFrontD3L);
@@ -1489,7 +1489,7 @@ T0116016_blueToad:
 T0116017_orangeElk:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order);
 	}
-	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
 		f113_drawField(&g188_FieldAspects[k1_ViewSquare_D3L], g163_FrameWalls[k1_ViewSquare_D3L]._box);
 	}
 }
@@ -1517,7 +1517,7 @@ void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[k0_ElemAspect]) {
+	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, frameStairsUpFrontD3R);
@@ -1563,7 +1563,7 @@ T0117017:
 T0117018:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order);
 	}
-	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
 		f113_drawField(&g188_FieldAspects[k2_ViewSquare_D3R], g163_FrameWalls[k2_ViewSquare_D3R]._box);
 	}
 }
@@ -1592,7 +1592,7 @@ void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 	int16 order;
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[k0_ElemAspect]) {
+	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
 			f104_drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, frameStairsUpFrontD3C);
@@ -1632,7 +1632,7 @@ T0118027:
 T0118028:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, order);
 	}
-	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
 		f113_drawField(&g188_FieldAspects[k0_ViewSquare_D3C], g163_FrameWalls[k0_ViewSquare_D3C]._box);
 	}
 }
@@ -1662,7 +1662,7 @@ void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[k0_ElemAspect]) {
+	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
 			f104_drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, frameStairsUpFrontD2L);
@@ -1704,7 +1704,7 @@ T0119020:
 		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &FrameCeilingPitD2L, posX, posY, false);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, order);
 	}
-	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
 		f113_drawField(&g188_FieldAspects[k4_ViewSquare_D2L], g163_FrameWalls[k4_ViewSquare_D2L]._box);
 	}
 }
@@ -1735,7 +1735,7 @@ void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
 
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[k0_ElemAspect]) {
+	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, frameStairsUpFrontD2R);
@@ -1778,7 +1778,7 @@ T0120028:
 T0120029:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, order);
 	}
-	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
 		f113_drawField(&g188_FieldAspects[k5_ViewSquare_D2R], g163_FrameWalls[k5_ViewSquare_D2R]._box);
 	}
 }
@@ -1809,7 +1809,7 @@ void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[k0_ElemAspect]) {
+	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
 			f104_drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, frameStairsUpFrontD2C);
@@ -1850,7 +1850,7 @@ T0121015:
 T0121016:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, order);
 	}
-	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
 		f113_drawField(&g188_FieldAspects[k3_ViewSquare_D2C], g163_FrameWalls[k3_ViewSquare_D2C]._box);
 	}
 }
@@ -1882,7 +1882,7 @@ void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
 
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[k0_ElemAspect]) {
+	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
 			f104_drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, frameStairsUpFrontD1L);
@@ -1924,7 +1924,7 @@ T0122020:
 T0122021:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, order);
 	}
-	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
 		f113_drawField(&g188_FieldAspects[k7_ViewSquare_D1L], g163_FrameWalls[k7_ViewSquare_D1L]._box);
 	}
 }
@@ -1955,7 +1955,7 @@ void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[k0_ElemAspect]) {
+	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, frameStairsUpFrontD1R);
@@ -1997,7 +1997,7 @@ T0123020:
 T0123021:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, order);
 	}
-	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
 		f113_drawField(&g188_FieldAspects[k8_ViewSquare_D1R], g163_FrameWalls[k8_ViewSquare_D1R]._box);
 	}
 }
@@ -2015,7 +2015,7 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 	byte* bitmap;
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (_vm->_dungeonMan->_g285_squareAheadElement = (ElementType)squareAspect[k0_ElemAspect]) {
+	switch (_vm->_dungeonMan->_g285_squareAheadElement = (ElementType)squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
 			f104_drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, frameStairsUpFrontD1C);
@@ -2076,19 +2076,19 @@ T0124017:
 T0124018:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, order);
 	}
-	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
 		f113_drawField(&g188_FieldAspects[k6_ViewSquare_D1C], g163_FrameWalls[k6_ViewSquare_D1C]._box);
 	}
 }
 
 void DisplayMan::f125_drawSquareD0L(Direction dir, int16 posX, int16 posY) {
 	static Frame frameStairsSideD0L = Frame(0, 15, 73, 85, 8, 13, 0, 0); // @ G0138_s_Graphic558_Frame_StairsSide_D0L
-	static Frame g149_FrameFloorPit_D0L = Frame(0, 31, 124, 135, 16, 12, 0, 0); // @ G0149_s_Graphic558_Frame_FloorPit_D0L
-	static Frame g158_FrameCeilingPit_D0L = Frame(0, 15, 0, 3, 8, 4, 0, 0); // @ G0158_s_Graphic558_Frame_CeilingPit_D0L
+	static Frame frameFloorPitD0L = Frame(0, 31, 124, 135, 16, 12, 0, 0); // @ G0149_s_Graphic558_Frame_FloorPit_D0L
+	static Frame frameCeilingPitD0L = Frame(0, 15, 0, 3, 8, 4, 0, 0); // @ G0158_s_Graphic558_Frame_CeilingPit_D0L
 
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[0]) {
+	switch (squareAspect[k0_ElementAspect]) {
 	case k18_StairsSideElemType:
 		if (squareAspect[k2_StairsUpAspect])
 			f104_drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, frameStairsSideD0L);
@@ -2099,6 +2099,10 @@ void DisplayMan::f125_drawSquareD0L(Direction dir, int16 posX, int16 posY) {
 	default:
 		break;
 	}
+
+	f112_drawCeilingPit(k67_ceilingPitD0L_grahicIndice, &frameCeilingPitD0L, posX, posY, false);
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
+		f113_drawField(&g188_FieldAspects[k10_ViewSquare_D0L], g163_FrameWalls[k10_ViewSquare_D0L]._box);
 }
 
 void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
@@ -2109,7 +2113,7 @@ void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[k0_ElemAspect]) {
+	switch (squareAspect[k0_ElementAspect]) {
 	case k18_ElementTypeStairsSide:
 		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, frameStairsSideD0R);
 		return;
@@ -2126,7 +2130,7 @@ void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
 		f100_drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, g163_FrameWalls[k11_ViewSquare_D0R]);
 		return;
 	}
-	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
 		f113_drawField(&g188_FieldAspects[k11_ViewSquare_D0R], g163_FrameWalls[k11_ViewSquare_D0R]._box);
 	}
 }
@@ -2144,7 +2148,7 @@ void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (squareAspect[k0_ElemAspect]) {
+	switch (squareAspect[k0_ElementAspect]) {
 	case k16_DoorSideElemType:
 		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
 			memmove(_g74_tmpBitmap, _g709_bitmapWallSet_DoorFrameFront, 32 * 123);
@@ -2170,7 +2174,7 @@ void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 	}
 	f112_drawCeilingPit(k68_ceilingPitD0C_graphicIndice, &frameCeilingPitD0C, posX, posY, false);
 	f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k9_ViewSquare_D0C, k0x0021_CellOrder_BackLeft_BackRight);
-	if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
 		f113_drawField(&g188_FieldAspects[k9_ViewSquare_D0C], g163_FrameWalls[k9_ViewSquare_D0C]._box);
 	}
 }


Commit: 89030204bc85adb005b95dd7c8e2a649e75e01de
    https://github.com/scummvm/scummvm/commit/89030204bc85adb005b95dd7c8e2a649e75e01de
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: More work on globals in gfx.cpp

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/inventory.cpp
    engines/dm/menus.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index ec0dcd5..c2de25c 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -40,82 +40,6 @@
 
 namespace DM {
 
-FieldAspect g188_FieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects
-								  /* { NativeBitmapRelativeIndex, BaseStartUnitIndex, Transparent color, Mask, ByteWidth, Height, X, BitPlaneWordCount } */
-	FieldAspect(0, 63, 0x8A, 0xFF,  0,   0,  0, 64),   /* D3C */
-	FieldAspect(0, 63, 0x0A, 0x80, 48,  51, 11, 64),   /* D3L */
-	FieldAspect(0, 63, 0x0A, 0x00, 48,  51,  0, 64),   /* D3R */
-	FieldAspect(0, 60, 0x8A, 0xFF,  0,   0,  0, 64),   /* D2C */
-	FieldAspect(0, 63, 0x0A, 0x81, 40,  71,  5, 64),   /* D2L */
-	FieldAspect(0, 63, 0x0A, 0x01, 40,  71,  0, 64),   /* D2R */
-	FieldAspect(0, 61, 0x8A, 0xFF,  0,   0,  0, 64),   /* D1C */
-	FieldAspect(0, 63, 0x0A, 0x82, 32, 111,  0, 64),   /* D1L */
-	FieldAspect(0, 63, 0x0A, 0x02, 32, 111,  0, 64),   /* D1R */
-	FieldAspect(0, 59, 0x8A, 0xFF,  0,   0,  0, 64),   /* D0C */
-	FieldAspect(0, 63, 0x0A, 0x83, 16, 136,  0, 64),   /* D0L */
-	FieldAspect(0, 63, 0x0A, 0x03, 16, 136,  0, 64)}; /* D0R */
-
-Box g2_BoxMovementArrows = Box(224, 319, 124, 168); // @ G0002_s_Graphic562_Box_MovementArrows
-
-byte g212_PalChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke
-
-ExplosionAspect g211_ExplosionAspects[k4_ExplosionAspectCount] = { // @ G0211_as_Graphic558_ExplosionAspects
-	// ByteWidth, Height 
-	ExplosionAspect(80, 111),   // Fire
-	ExplosionAspect(64,  97),   // Spell
-	ExplosionAspect(80,  91),   // Poison
-	ExplosionAspect(80,  91)    // Death
-};
-
-#define k730_DerivedBitmapMaximumCount 730 // @ C730_DERIVED_BITMAP_MAXIMUM_COUNT
-
-byte g215_ProjectileScales[7] = {
-	13,   /* D4 Back  */
-	16,   /* D4 Front */
-	19,   /* D3 Back  */
-	22,   /* D3 Front */
-	25,   /* D2 Back  */
-	28,   /* D2 Front */
-	32}; /* D1 Back  */
-
-#define k121_FirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT
-#define k75_FirstFloorSet 75 // @ C075_GRAPHIC_FIRST_FLOOR_SET
-#define k77_FirstWallSet 77 // @ C077_GRAPHIC_FIRST_WALL_SET
-#define k90_FirstStairs 90 // @ C090_GRAPHIC_FIRST_STAIRS
-#define k108_FirstDoorSet 108 // @ C108_GRAPHIC_FIRST_DOOR_SET
-#define k120_InscriptionFont 120 // @ C120_GRAPHIC_INSCRIPTION_FONT
-#define k121_FirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT
-#define k247_FirstFloorOrn 247 // @ C247_GRAPHIC_FIRST_FLOOR_ORNAMENT
-#define k303_FirstDoorOrn 303 // @ C303_GRAPHIC_FIRST_DOOR_ORNAMENT
-
-
-enum ViewSquare {
-	kM3_ViewSquare_D4C = -3, // @ CM3_VIEW_SQUARE_D4C
-	kM2_ViewSquare_D4L = -2, // @ CM2_VIEW_SQUARE_D4L
-	kM1_ViewSquare_D4R = -1, // @ CM1_VIEW_SQUARE_D4R
-	k0_ViewSquare_D3C = 0, // @ C00_VIEW_SQUARE_D3C
-	k1_ViewSquare_D3L = 1, // @ C01_VIEW_SQUARE_D3L
-	k2_ViewSquare_D3R = 2, // @ C02_VIEW_SQUARE_D3R
-	k3_ViewSquare_D2C = 3, // @ C03_VIEW_SQUARE_D2C
-	k4_ViewSquare_D2L = 4, // @ C04_VIEW_SQUARE_D2L
-	k5_ViewSquare_D2R = 5, // @ C05_VIEW_SQUARE_D2R
-	k6_ViewSquare_D1C = 6, // @ C06_VIEW_SQUARE_D1C
-	k7_ViewSquare_D1L = 7, // @ C07_VIEW_SQUARE_D1L
-	k8_ViewSquare_D1R = 8, // @ C08_VIEW_SQUARE_D1R
-	k9_ViewSquare_D0C = 9, // @ C09_VIEW_SQUARE_D0C
-	k10_ViewSquare_D0L = 10, // @ C10_VIEW_SQUARE_D0L
-	k11_ViewSquare_D0R = 11, // @ C11_VIEW_SQUARE_D0R
-	k3_ViewSquare_D3C_Explosion = 3, // @ C03_VIEW_SQUARE_D3C_EXPLOSION
-	k4_ViewSquare_D3L_Explosion = 4, // @ C04_VIEW_SQUARE_D3L_EXPLOSION
-	k9_ViewSquare_D1C_Explosion = 9, // @ C09_VIEW_SQUARE_D1C_EXPLOSION
-	k12_ViewSquare_D0C_Explosion = 12 // @ C12_VIEW_SQUARE_D0C_EXPLOSION
-};
-
-
-Frame gK12_CeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling
-Frame gK13_FloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor
-
-Frame g711_FrameWall_D3L2 = Frame(0, 15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2
 Frame g712_FrameWall_D3R2 = Frame(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2
 Frame g163_FrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls
 	/* { X1, X2, Y1, Y2, pixelWidth, Height, X, Y } */
@@ -627,14 +551,59 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 void DisplayMan::initConstants() {
 	const byte palChangesDoorButtonAndWallOrnD3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3
 	const byte palChangesDoorButtonAndWallOrnD2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2
-	const Frame doorFrameLeftD1C = Frame(43, 74, 14, 107, 16, 94, 0, 0); // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C
-	const Frame doorFrameRightD1C = Frame(149, 180, 14, 107, 16, 94, 0, 0); // @ G0171_s_Graphic558_Frame_DoorFrameRight_D1C
+	const FieldAspect fieldAspects188[12] = { // @ G0188_as_Graphic558_FieldAspects
+	/* { NativeBitmapRelativeIndex, BaseStartUnitIndex, Transparent color, Mask, ByteWidth, Height, X, BitPlaneWordCount } */
+		FieldAspect(0, 63, 0x8A, 0xFF,  0,   0,  0, 64),  /* D3C */
+		FieldAspect(0, 63, 0x0A, 0x80, 48,  51, 11, 64),  /* D3L */
+		FieldAspect(0, 63, 0x0A, 0x00, 48,  51,  0, 64),  /* D3R */
+		FieldAspect(0, 60, 0x8A, 0xFF,  0,   0,  0, 64),  /* D2C */
+		FieldAspect(0, 63, 0x0A, 0x81, 40,  71,  5, 64),  /* D2L */
+		FieldAspect(0, 63, 0x0A, 0x01, 40,  71,  0, 64),  /* D2R */
+		FieldAspect(0, 61, 0x8A, 0xFF,  0,   0,  0, 64),  /* D1C */
+		FieldAspect(0, 63, 0x0A, 0x82, 32, 111,  0, 64),  /* D1L */
+		FieldAspect(0, 63, 0x0A, 0x02, 32, 111,  0, 64),  /* D1R */
+		FieldAspect(0, 59, 0x8A, 0xFF,  0,   0,  0, 64),  /* D0C */
+		FieldAspect(0, 63, 0x0A, 0x83, 16, 136,  0, 64),  /* D0L */
+		FieldAspect(0, 63, 0x0A, 0x03, 16, 136,  0, 64)   /* D0R */
+	};
+
+	const ExplosionAspect explosionAspects[k4_ExplosionAspectCount] = { // @ G0211_as_Graphic558_ExplosionAspects
+		// ByteWidth, Height 
+		ExplosionAspect(80, 111),   // Fire
+		ExplosionAspect(64,  97),   // Spell
+		ExplosionAspect(80,  91),   // Poison
+		ExplosionAspect(80,  91)    // Death
+	};
+
+	const byte palChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke
+	const byte projectileScales[7] = {
+		13,   /* D4 Back  */
+		16,   /* D4 Front */
+		19,   /* D3 Back  */
+		22,   /* D3 Front */
+		25,   /* D2 Back  */
+		28,   /* D2 Front */
+		32    /* D1 Back  */
+	};
+
+	_doorFrameLeftD1C = Frame(43, 74, 14, 107, 16, 94, 0, 0); // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C
+	_doorFrameRightD1C = Frame(149, 180, 14, 107, 16, 94, 0, 0); // @ G0171_s_Graphic558_Frame_DoorFrameRight_D1C
 
 	for (int i = 0; i < 16; i++) {
 		_palChangesDoorButtonAndWallOrnD3[i] = palChangesDoorButtonAndWallOrnD3[i];
 		_palChangesDoorButtonAndWallOrnD2[i] = palChangesDoorButtonAndWallOrnD2[i];
+		_palChangeSmoke[i] = palChangeSmoke[i];
 	}
 
+	for (int i = 0; i < 12; i++)
+		_fieldAspects188[i] = fieldAspects188[i];
+
+	for (int i = 0; i < 7; i++)
+		_projectileScales[i] = projectileScales[i];
+
+	for (int i = 0; i < k4_ExplosionAspectCount; i++)
+		g211_ExplosionAspects[i] = explosionAspects[i];
+
 	_doorFrameD1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
 		Frame(64, 159, 17, 102, 48, 88, 0, 0),	 /* Closed Or Destroyed */
 		Frame(64, 159, 17, 38, 48, 88, 0, 66),	 /* Vertical Closed one fourth */
@@ -649,9 +618,7 @@ void DisplayMan::initConstants() {
 	);
 
 	_boxThievesEyeViewPortVisibleArea = Box(64, 159, 19, 113); // @ G0106_s_Graphic558_Box_ThievesEye_ViewportVisibleArea 
-
-	_doorFrameLeftD1C = doorFrameLeftD1C;
-	_doorFrameRightD1C = doorFrameRightD1C;
+	_boxMovementArrows = Box(224, 319, 124, 168); // @ G0002_s_Graphic562_Box_MovementArrows
 }
 
 DisplayMan::~DisplayMan() {
@@ -803,7 +770,7 @@ void DisplayMan::f460_initializeGraphicData() {
 			derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + projectileAspect->_firstDerivedBitmapRelativeIndex;
 
 			for (int16 projectileScaleIndex = 0; projectileScaleIndex < 6; projectileScaleIndex++) {
-				int16 bitmapByteCount = f459_getScaledBitmapByteCount(projectileAspect->_byteWidth, projectileAspect->_height, g215_ProjectileScales[projectileScaleIndex]);
+				int16 bitmapByteCount = f459_getScaledBitmapByteCount(projectileAspect->_byteWidth, projectileAspect->_height, _projectileScales[projectileScaleIndex]);
 				_g639_derivedBitmapByteCount[derivedBitmapIndex] = bitmapByteCount;
 
 				if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k3_ProjectileAspectHasNone) {
@@ -1126,7 +1093,7 @@ byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale
 		byte *nativeBitmap = f489_getNativeBitmapOrGraphic(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice);
 		bitmap = f492_getDerivedBitmap(derBitmapIndex);
 		f129_blitToBitmapShrinkWithPalChange(nativeBitmap, bitmap, explAsp->_byteWidth, explAsp->_height, pixelWidth * 2, height,
-			(explosionAspIndex == k3_ExplosionAspectSmoke) ? g212_PalChangeSmoke : g17_PalChangesNoChanges);
+			(explosionAspIndex == k3_ExplosionAspectSmoke) ? _palChangeSmoke : g17_PalChangesNoChanges);
 		f493_addDerivedBitmap(derBitmapIndex);
 	}
 
@@ -1490,7 +1457,7 @@ T0116017_orangeElk:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&g188_FieldAspects[k1_ViewSquare_D3L], g163_FrameWalls[k1_ViewSquare_D3L]._box);
+		f113_drawField(&_fieldAspects188[k1_ViewSquare_D3L], g163_FrameWalls[k1_ViewSquare_D3L]._box);
 	}
 }
 
@@ -1564,7 +1531,7 @@ T0117018:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&g188_FieldAspects[k2_ViewSquare_D3R], g163_FrameWalls[k2_ViewSquare_D3R]._box);
+		f113_drawField(&_fieldAspects188[k2_ViewSquare_D3R], g163_FrameWalls[k2_ViewSquare_D3R]._box);
 	}
 }
 
@@ -1633,7 +1600,7 @@ T0118028:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&g188_FieldAspects[k0_ViewSquare_D3C], g163_FrameWalls[k0_ViewSquare_D3C]._box);
+		f113_drawField(&_fieldAspects188[k0_ViewSquare_D3C], g163_FrameWalls[k0_ViewSquare_D3C]._box);
 	}
 }
 
@@ -1705,7 +1672,7 @@ T0119020:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&g188_FieldAspects[k4_ViewSquare_D2L], g163_FrameWalls[k4_ViewSquare_D2L]._box);
+		f113_drawField(&_fieldAspects188[k4_ViewSquare_D2L], g163_FrameWalls[k4_ViewSquare_D2L]._box);
 	}
 }
 
@@ -1779,7 +1746,7 @@ T0120029:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&g188_FieldAspects[k5_ViewSquare_D2R], g163_FrameWalls[k5_ViewSquare_D2R]._box);
+		f113_drawField(&_fieldAspects188[k5_ViewSquare_D2R], g163_FrameWalls[k5_ViewSquare_D2R]._box);
 	}
 }
 
@@ -1851,7 +1818,7 @@ T0121016:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&g188_FieldAspects[k3_ViewSquare_D2C], g163_FrameWalls[k3_ViewSquare_D2C]._box);
+		f113_drawField(&_fieldAspects188[k3_ViewSquare_D2C], g163_FrameWalls[k3_ViewSquare_D2C]._box);
 	}
 }
 
@@ -1925,7 +1892,7 @@ T0122021:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&g188_FieldAspects[k7_ViewSquare_D1L], g163_FrameWalls[k7_ViewSquare_D1L]._box);
+		f113_drawField(&_fieldAspects188[k7_ViewSquare_D1L], g163_FrameWalls[k7_ViewSquare_D1L]._box);
 	}
 }
 
@@ -1998,7 +1965,7 @@ T0123021:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&g188_FieldAspects[k8_ViewSquare_D1R], g163_FrameWalls[k8_ViewSquare_D1R]._box);
+		f113_drawField(&_fieldAspects188[k8_ViewSquare_D1R], g163_FrameWalls[k8_ViewSquare_D1R]._box);
 	}
 }
 
@@ -2077,7 +2044,7 @@ T0124018:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&g188_FieldAspects[k6_ViewSquare_D1C], g163_FrameWalls[k6_ViewSquare_D1C]._box);
+		f113_drawField(&_fieldAspects188[k6_ViewSquare_D1C], g163_FrameWalls[k6_ViewSquare_D1C]._box);
 	}
 }
 
@@ -2102,7 +2069,7 @@ void DisplayMan::f125_drawSquareD0L(Direction dir, int16 posX, int16 posY) {
 
 	f112_drawCeilingPit(k67_ceilingPitD0L_grahicIndice, &frameCeilingPitD0L, posX, posY, false);
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
-		f113_drawField(&g188_FieldAspects[k10_ViewSquare_D0L], g163_FrameWalls[k10_ViewSquare_D0L]._box);
+		f113_drawField(&_fieldAspects188[k10_ViewSquare_D0L], g163_FrameWalls[k10_ViewSquare_D0L]._box);
 }
 
 void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
@@ -2131,7 +2098,7 @@ void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
 		return;
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&g188_FieldAspects[k11_ViewSquare_D0R], g163_FrameWalls[k11_ViewSquare_D0R]._box);
+		f113_drawField(&_fieldAspects188[k11_ViewSquare_D0R], g163_FrameWalls[k11_ViewSquare_D0R]._box);
 	}
 }
 
@@ -2175,25 +2142,29 @@ void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 	f112_drawCeilingPit(k68_ceilingPitD0C_graphicIndice, &frameCeilingPitD0C, posX, posY, false);
 	f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k9_ViewSquare_D0C, k0x0021_CellOrder_BackLeft_BackRight);
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&g188_FieldAspects[k9_ViewSquare_D0C], g163_FrameWalls[k9_ViewSquare_D0C]._box);
+		f113_drawField(&_fieldAspects188[k9_ViewSquare_D0C], g163_FrameWalls[k9_ViewSquare_D0C]._box);
 	}
 }
 
 void DisplayMan::f128_drawDungeon(Direction dir, int16 posX, int16 posY) {
+	static Frame ceilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling
+	static Frame floorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor
+	static Frame frameWallD3L2 = Frame(0, 15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2
+
 	if (_g297_drawFloorAndCeilingRequested)
 		f98_drawFloorAndCeiling();
+
 	_g578_useByteBoxCoordinates = true;
 	for (int16 i = 0; i < 6; ++i)
 		_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i].setToZero();
 
-	for (uint16 i = 0; i < 6; ++i) {
+	for (uint16 i = 0; i < 6; ++i)
 		_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i]._x1 = 255;
-	}
 
 	if (_g76_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1) {
-		f100_drawWallSetBitmap(_g85_bitmapCeiling, gK12_CeilingFrame);
+		f100_drawWallSetBitmap(_g85_bitmapCeiling, ceilingFrame);
 		f99_copyBitmapAndFlipHorizontal(_g84_bitmapFloor, _g74_tmpBitmap, k112_byteWidthViewport, 70);
-		f100_drawWallSetBitmap(_g74_tmpBitmap, gK13_FloorFrame);
+		f100_drawWallSetBitmap(_g74_tmpBitmap, floorFrame);
 
 		_g698_bitmapWallSet_Wall_D3LCR = _g90_bitmapWall_D3LCR_Flipped;
 		_g699_bitmapWallSet_Wall_D2LCR = _g91_bitmapWall_D2LCR_Flipped;
@@ -2202,16 +2173,15 @@ void DisplayMan::f128_drawDungeon(Direction dir, int16 posX, int16 posY) {
 		_g702_bitmapWallSet_Wall_D0R = _g94_bitmapWall_D0R_Flipped;
 	} else {
 		f99_copyBitmapAndFlipHorizontal(_g85_bitmapCeiling, _g74_tmpBitmap, k112_byteWidthViewport, 29);
-		f100_drawWallSetBitmap(_g74_tmpBitmap, gK12_CeilingFrame);
-		f100_drawWallSetBitmap(_g84_bitmapFloor, gK13_FloorFrame);
+		f100_drawWallSetBitmap(_g74_tmpBitmap, ceilingFrame);
+		f100_drawWallSetBitmap(_g84_bitmapFloor, floorFrame);
 	}
 
-	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, -2, posX, posY) == k0_ElementTypeWall) {
-		f100_drawWallSetBitmap(_g697_bitmapWallSet_Wall_D3L2, g711_FrameWall_D3L2);
-	}
-	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, 2, posX, posY) == k0_ElementTypeWall) {
+	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, -2, posX, posY) == k0_ElementTypeWall)
+		f100_drawWallSetBitmap(_g697_bitmapWallSet_Wall_D3L2, frameWallD3L2);
+
+	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, 2, posX, posY) == k0_ElementTypeWall)
 		f100_drawWallSetBitmap(_g696_bitmapWallSet_Wall_D3R2, g712_FrameWall_D3R2);
-	}
 
 	int16 tmpPosX = posX;
 	int16 tmpPosY = posY;
@@ -3411,7 +3381,7 @@ T0115129_DrawProjectiles:
 						heightRedEagle = ((ProjectileAspect*)objectAspect)->_height;
 					} else {
 						AL_8_projectileScaleIndex = ((viewSquareIndex / 3) << 1) + (AL_2_viewCell >> 1);
-						scale = g215_ProjectileScales[AL_8_projectileScaleIndex];
+						scale = _projectileScales[AL_8_projectileScaleIndex];
 						if (!doNotScaleWithKineticEnergy) {
 							scale = (scale * MAX(96, projectile->_kineticEnergy + 1)) >> 8;
 						}
@@ -3574,7 +3544,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 				f491_isDerivedBitmapInCache(k0_DerivedBitmapViewport);
 				AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice);
 				if (smoke) {
-					f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, 48, 32, 48, 32, g212_PalChangeSmoke);
+					f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, 48, 32, 48, 32, _palChangeSmoke);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
 				f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, 0, f492_getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C, _vm->getRandomNumber(4) + 87, _vm->getRandomNumber(64), k112_byteWidthViewport, Color(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
@@ -3640,7 +3610,7 @@ T0115200_DrawExplosion:
 	} while ((thingParam = _vm->_dungeonMan->f159_getNextThing(thingParam)) != Thing::_endOfList);
 	if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_g77_doNotDrawFluxcagesDuringEndgame) { /* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */
 		AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */
-		fieldAspect = g188_FieldAspects[viewSquareIndex];
+		fieldAspect = _fieldAspects188[viewSquareIndex];
 		(fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */
 		f113_drawField(&fieldAspect, g163_FrameWalls[viewSquareIndex]._box);
 	}
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 7dba4f7..5e3a113 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -120,9 +120,6 @@ namespace DM {
 #define k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight 0x3421 // @ C3421_CELL_ORDER_BACKLEFT_BACKRIGHT_FRONTLEFT_FRONTRIGHT
 #define k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft 0x4312 // @ C4312_CELL_ORDER_BACKRIGHT_BACKLEFT_FRONTRIGHT_FRONTLEFT
 
-
-
-
 /* Explosion aspects */
 #define k0_ExplosionAspectFire 0 // @ C0_EXPLOSION_ASPECT_FIRE  
 #define k1_ExplosionAspectSpell 1 // @ C1_EXPLOSION_ASPECT_SPELL 
@@ -140,12 +137,45 @@ namespace DM {
 #define k0x0200_CreatureInfoGraphicMaskFlipAttack 0x0200 // @ MASK0x0200_FLIP_ATTACK                      
 #define k0x0400_CreatureInfoGraphicMaskFlipDuringAttack 0x0400 // @ MASK0x0400_FLIP_DURING_ATTACK               
 
+#define k75_FirstFloorSet 75 // @ C075_GRAPHIC_FIRST_FLOOR_SET
+#define k77_FirstWallSet 77 // @ C077_GRAPHIC_FIRST_WALL_SET
+#define k90_FirstStairs 90 // @ C090_GRAPHIC_FIRST_STAIRS
+#define k108_FirstDoorSet 108 // @ C108_GRAPHIC_FIRST_DOOR_SET
+#define k120_InscriptionFont 120 // @ C120_GRAPHIC_INSCRIPTION_FONT
+#define k121_FirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT
+#define k247_FirstFloorOrn 247 // @ C247_GRAPHIC_FIRST_FLOOR_ORNAMENT
+#define k303_FirstDoorOrn 303 // @ C303_GRAPHIC_FIRST_DOOR_ORNAMENT
+#define k730_DerivedBitmapMaximumCount 730 // @ C730_DERIVED_BITMAP_MAXIMUM_COUNT
+
+enum ViewSquare {
+	kM3_ViewSquare_D4C = -3, // @ CM3_VIEW_SQUARE_D4C
+	kM2_ViewSquare_D4L = -2, // @ CM2_VIEW_SQUARE_D4L
+	kM1_ViewSquare_D4R = -1, // @ CM1_VIEW_SQUARE_D4R
+	k0_ViewSquare_D3C = 0, // @ C00_VIEW_SQUARE_D3C
+	k1_ViewSquare_D3L = 1, // @ C01_VIEW_SQUARE_D3L
+	k2_ViewSquare_D3R = 2, // @ C02_VIEW_SQUARE_D3R
+	k3_ViewSquare_D2C = 3, // @ C03_VIEW_SQUARE_D2C
+	k4_ViewSquare_D2L = 4, // @ C04_VIEW_SQUARE_D2L
+	k5_ViewSquare_D2R = 5, // @ C05_VIEW_SQUARE_D2R
+	k6_ViewSquare_D1C = 6, // @ C06_VIEW_SQUARE_D1C
+	k7_ViewSquare_D1L = 7, // @ C07_VIEW_SQUARE_D1L
+	k8_ViewSquare_D1R = 8, // @ C08_VIEW_SQUARE_D1R
+	k9_ViewSquare_D0C = 9, // @ C09_VIEW_SQUARE_D0C
+	k10_ViewSquare_D0L = 10, // @ C10_VIEW_SQUARE_D0L
+	k11_ViewSquare_D0R = 11, // @ C11_VIEW_SQUARE_D0R
+	k3_ViewSquare_D3C_Explosion = 3, // @ C03_VIEW_SQUARE_D3C_EXPLOSION
+	k4_ViewSquare_D3L_Explosion = 4, // @ C04_VIEW_SQUARE_D3L_EXPLOSION
+	k9_ViewSquare_D1C_Explosion = 9, // @ C09_VIEW_SQUARE_D1C_EXPLOSION
+	k12_ViewSquare_D0C_Explosion = 12 // @ C12_VIEW_SQUARE_D0C_EXPLOSION
+};
+
 class ExplosionAspect {
 public:
 	uint16 _byteWidth;
 	uint16 _height;
 
 	ExplosionAspect(uint16 byteWidth, uint16 height) :_byteWidth(byteWidth), _height(height) {}
+	ExplosionAspect() : _byteWidth(0), _height(0) {}
 }; // @ EXPLOSION_ASPECT
 
 extern ExplosionAspect g211_ExplosionAspects[k4_ExplosionAspectCount]; // @ G0211_as_Graphic558_ExplosionAspects
@@ -751,6 +781,11 @@ public:
 
 	Frame _doorFrameLeftD1C; // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C
 	Frame _doorFrameRightD1C; // @ G0171_s_Graphic558_Frame_DoorFrameRight_D1C
+	FieldAspect _fieldAspects188[12];
+	Box _boxMovementArrows;
+	byte _palChangeSmoke[16];
+	byte _projectileScales[7];
+	ExplosionAspect g211_ExplosionAspects[k4_ExplosionAspectCount];
 
 	bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
 	byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index afe91eb..bc28396 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -117,7 +117,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(championIndex);
 	if (!AL1102_ui_InventoryChampionOrdinal) {
-		_vm->_displayMan->f136_shadeScreenBox(&g2_BoxMovementArrows, k0_ColorBlack);
+		_vm->_displayMan->f136_shadeScreenBox(&_vm->_displayMan->_boxMovementArrows, k0_ColorBlack);
 	}
 	L1103_ps_Champion = &_vm->_championMan->_gK71_champions[championIndex];
 	_vm->_displayMan->f466_loadIntoBitmap(k17_InventoryGraphicIndice, _vm->_displayMan->_g296_bitmapViewport);
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 3137bad..d1879db 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -117,7 +117,7 @@ MenuMan::~MenuMan() {
 void MenuMan::f395_drawMovementArrows() {
 	_vm->_eventMan->f78_showMouse();
 	_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k13_MovementArrowsIndice),
-									   &g2_BoxMovementArrows, k48_byteWidth, kM1_ColorNoTransparency, 45);
+									   &_vm->_displayMan->_boxMovementArrows, k48_byteWidth, kM1_ColorNoTransparency, 45);
 	_vm->_eventMan->f77_hideMouse();
 }
 void MenuMan::f388_clearActingChampion() {
@@ -182,7 +182,7 @@ void MenuMan::f456_drawDisabledMenu() {
 				_vm->_inventoryMan->f334_closeChest();
 			}
 		} else {
-			_vm->_displayMan->f136_shadeScreenBox(&g2_BoxMovementArrows, k0_ColorBlack);
+			_vm->_displayMan->f136_shadeScreenBox(&_vm->_displayMan->_boxMovementArrows, k0_ColorBlack);
 		}
 		_vm->_displayMan->f136_shadeScreenBox(&g0_BoxSpellArea, k0_ColorBlack);
 		_vm->_displayMan->f136_shadeScreenBox(&g1_BoxActionArea, k0_ColorBlack);


Commit: 7f11c2551fd3b123b344dec6a652951781d36b90
    https://github.com/scummvm/scummvm/commit/7f11c2551fd3b123b344dec6a652951781d36b90
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Get rid of more globals

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index c2de25c..51e354a 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -40,156 +40,6 @@
 
 namespace DM {
 
-Frame g712_FrameWall_D3R2 = Frame(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2
-Frame g163_FrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls
-	/* { X1, X2, Y1, Y2, pixelWidth, Height, X, Y } */
-	Frame(74, 149, 25,  75,  64,  51,  18, 0),   /* D3C */
-	Frame(0,  83, 25,  75,  64,  51,  32, 0),   /* D3L */
-	Frame(139, 223, 25,  75,  64,  51,   0, 0),   /* D3R */
-	Frame(60, 163, 20,  90,  72,  71,  16, 0),   /* D2C */
-	Frame(0,  74, 20,  90,  72,  71,  61, 0),   /* D2L */
-	Frame(149, 223, 20,  90,  72,  71,   0, 0),   /* D2R */
-	Frame(32, 191,  9, 119, 128, 111,  48, 0),   /* D1C */
-	Frame(0,  63,  9, 119, 128, 111, 192, 0),   /* D1L */
-	Frame(160, 223,  9, 119, 128, 111,   0, 0),   /* D1R */
-	Frame(0, 223,  0, 135,   0,   0,   0, 0),   /* D0C */
-	Frame(0,  31,  0, 135,  16, 136,   0, 0),   /* D0L */
-	Frame(192, 223,  0, 135,  16, 136,   0, 0)
-}; /* D0R */
-
-
-byte g196_DoorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordinateSetIndices
-	0,   /* Door Ornament #00 Square Grid */
-	1,   /* Door Ornament #01 Iron Bars */
-	1,   /* Door Ornament #02 Jewels */
-	1,   /* Door Ornament #03 Wooden Bars */
-	0,   /* Door Ornament #04 Arched Grid */
-	2,   /* Door Ornament #05 Block Lock */
-	3,   /* Door Ornament #06 Corner Lock */
-	1,   /* Door Ornament #07 Black door */
-	2,   /* Door Ornament #08 Red Triangle Lock */
-	2,   /* Door Ornament #09 Triangle Lock */
-	1,   /* Door Ornament #10 Ra Door */
-	1}; /* Door Ornament #11 Iron Door Damages */
-
-byte g195_FloorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnamentCoordinateSetIndices
-	0,   /* Floor Ornament 00 Square Grate */
-	0,   /* Floor Ornament 01 Square Pressure Pad */
-	0,   /* Floor Ornament 02 Moss */
-	0,   /* Floor Ornament 03 Round Grate */
-	2,   /* Floor Ornament 04 Round Pressure Plate */
-	0,   /* Floor Ornament 05 Black Flame Pit */
-	0,   /* Floor Ornament 06 Crack */
-	2,   /* Floor Ornament 07 Tiny Pressure Pad */
-	0}; /* Floor Ornament 08 Puddle */
-
-byte g205_WallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets
-										 /* { X1, X2, Y1, Y2, ByteWidth, Height } */
-	{{80,  83, 41,  45,  8,   5},     /* D3L */
-	{140, 143, 41,  45,  8,   5},     /* D3R */
-	{16,  29, 39,  50,  8,  12},     /* D3L */
-	{107, 120, 39,  50,  8,  12},     /* D3C */
-	{187, 200, 39,  50,  8,  12},     /* D3R */
-	{67,  77, 40,  49,  8,  10},     /* D2L */
-	{146, 156, 40,  49,  8,  10},     /* D2R */
-	{0,  17, 38,  55, 16,  18},     /* D2L */
-	{102, 123, 38,  55, 16,  18},     /* D2C */
-	{206, 223, 38,  55, 16,  18},     /* D2R */
-	{48,  63, 38,  56,  8,  19},     /* D1L */
-	{160, 175, 38,  56,  8,  19},     /* D1R */
-	{96, 127, 36,  63, 16,  28}},   /* D1C */
-	{{74,  82, 41,  60,  8,  20},     /* D3L */
-	{141, 149, 41,  60,  8,  20},     /* D3R */
-	{1,  47, 37,  63, 24,  27},     /* D3L */
-	{88, 134, 37,  63, 24,  27},     /* D3C */
-	{171, 217, 37,  63, 24,  27},     /* D3R */
-	{61,  76, 38,  67,  8,  30},     /* D2L */
-	{147, 162, 38,  67,  8,  30},     /* D2R */
-	{0,  43, 37,  73, 32,  37},     /* D2L */
-	{80, 143, 37,  73, 32,  37},     /* D2C */
-	{180, 223, 37,  73, 32,  37},     /* D2R */
-	{32,  63, 36,  83, 16,  48},     /* D1L */
-	{160, 191, 36,  83, 16,  48},     /* D1R */
-	{64, 159, 36,  91, 48,  56}},   /* D1C */
-	{{80,  83, 66,  70,  8,   5},     /* D3L */
-	{140, 143, 66,  70,  8,   5},     /* D3R */
-	{16,  29, 64,  75,  8,  12},     /* D3L */
-	{106, 119, 64,  75,  8,  12},     /* D3C */
-	{187, 200, 64,  75,  8,  12},     /* D3R */
-	{67,  77, 74,  83,  8,  10},     /* D2L */
-	{146, 156, 74,  83,  8,  10},     /* D2R */
-	{0,  17, 73,  90, 16,  18},     /* D2L */
-	{100, 121, 73,  90, 16,  18},     /* D2C */
-	{206, 223, 73,  90, 16,  18},     /* D2R */
-	{48,  63, 84, 102,  8,  19},     /* D1L */
-	{160, 175, 84, 102,  8,  19},     /* D1R */
-	{96, 127, 92, 119, 16,  28}},   /* D1C */
-	{{80,  83, 49,  53,  8,   5},     /* D3L */
-	{140, 143, 49,  53,  8,   5},     /* D3R */
-	{16,  29, 50,  61,  8,  12},     /* D3L */
-	{106, 119, 50,  61,  8,  12},     /* D3C */
-	{187, 200, 50,  61,  8,  12},     /* D3R */
-	{67,  77, 53,  62,  8,  10},     /* D2L */
-	{146, 156, 53,  62,  8,  10},     /* D2R */
-	{0,  17, 55,  72, 16,  18},     /* D2L */
-	{100, 121, 55,  72, 16,  18},     /* D2C */
-	{206, 223, 55,  72, 16,  18},     /* D2R */
-	{48,  63, 57,  75,  8,  19},     /* D1L */
-	{160, 175, 57,  75,  8,  19},     /* D1R */
-	{96, 127, 64,  91, 16,  28}},   /* D1C */
-	{{75,  90, 40,  44,  8,   5},     /* D3L */
-	{133, 148, 40,  44,  8,   5},     /* D3R */
-	{1,  48, 44,  49, 24,   6},     /* D3L */
-	{88, 135, 44,  49, 24,   6},     /* D3C */
-	{171, 218, 44,  49, 24,   6},     /* D3R */
-	{60,  77, 40,  46, 16,   7},     /* D2L */
-	{146, 163, 40,  46, 16,   7},     /* D2R */
-	{0,  35, 43,  50, 32,   8},     /* D2L */
-	{80, 143, 43,  50, 32,   8},     /* D2C */
-	{184, 223, 43,  50, 32,   8},     /* D2R */
-	{32,  63, 41,  52, 16,  12},     /* D1L */
-	{160, 191, 41,  52, 16,  12},     /* D1R */
-	{64, 159, 41,  52, 48,  12}},   /* D1C */
-	{{78,  85, 36,  51,  8,  16},     /* D3L */
-	{138, 145, 36,  51,  8,  16},     /* D3R */
-	{10,  41, 34,  53, 16,  20},     /* D3L */
-	{98, 129, 34,  53, 16,  20},     /* D3C */
-	{179, 210, 34,  53, 16,  20},     /* D3R */
-	{66,  75, 34,  56,  8,  23},     /* D2L */
-	{148, 157, 34,  56,  8,  23},     /* D2R */
-	{0,  26, 33,  61, 24,  29},     /* D2L */
-	{91, 133, 33,  61, 24,  29},     /* D2C */
-	{194, 223, 33,  61, 24,  29},     /* D2R */
-	{41,  56, 31,  65,  8,  35},     /* D1L */
-	{167, 182, 31,  65,  8,  35},     /* D1R */
-	{80, 143, 29,  71, 32,  43}},   /* D1C */
-	{{75,  82, 25,  75,  8,  51},     /* D3L */
-	{142, 149, 25,  75,  8,  51},     /* D3R */
-	{12,  60, 25,  75, 32,  51},     /* D3L */
-	{88, 136, 25,  75, 32,  51},     /* D3C */
-	{163, 211, 25,  75, 32,  51},     /* D3R */
-	{64,  73, 20,  90,  8,  71},     /* D2L */
-	{150, 159, 20,  90,  8,  71},     /* D2R */
-	{0,  38, 20,  90, 32,  71},     /* D2L */
-	{82, 142, 20,  90, 32,  71},     /* D2C */
-	{184, 223, 20,  90, 32,  71},     /* D2R */
-	{41,  56,  9, 119,  8, 111},     /* D1L */
-	{169, 184,  9, 119,  8, 111},     /* D1R */
-	{64, 159,  9, 119, 48, 111}},   /* D1C */
-	{{74,  85, 25,  75,  8,  51},     /* D3L */
-	{137, 149, 25,  75,  8,  51},     /* D3R */
-	{0,  75, 25,  75, 40,  51},     /* D3L Atari ST: {   0,  83, 25,  75, 48,  51 } */
-	{74, 149, 25,  75, 40,  51},     /* D3C Atari ST: {  74, 149, 25,  75, 48,  51 } */
-	{148, 223, 25,  75, 40,  51},     /* D3R Atari ST: { 139, 223, 25,  75, 48,  51 } */
-	{60,  77, 20,  90, 16,  71},     /* D2L */
-	{146, 163, 20,  90, 16,  71},     /* D2R */
-	{0,  74, 20,  90, 56,  71},     /* D2L */
-	{60, 163, 20,  90, 56,  71},     /* D2C */
-	{149, 223, 20,  90, 56,  71},     /* D2R */
-	{32,  63,  9, 119, 16, 111},     /* D1L */
-	{160, 191,  9, 119, 16, 111},     /* D1R */
-	{32, 191,  9, 119, 80, 111}}}; /* D1C */
-
 byte g194_WallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoordinateSetIndices
 	1,   /* Wall Ornament 00 Unreadable Inscription */
 	1,   /* Wall Ornament 01 Square Alcove */
@@ -586,6 +436,24 @@ void DisplayMan::initConstants() {
 		32    /* D1 Back  */
 	};
 
+	const Frame frameWalls163[12] = { // @ G0163_as_Graphic558_Frame_Walls
+		/* { X1, X2, Y1, Y2, pixelWidth, Height, X, Y } */
+		Frame(74, 149, 25,  75,  64,  51,  18, 0),   /* D3C */
+		Frame(0,  83, 25,  75,  64,  51,  32, 0),   /* D3L */
+		Frame(139, 223, 25,  75,  64,  51,   0, 0),   /* D3R */
+		Frame(60, 163, 20,  90,  72,  71,  16, 0),   /* D2C */
+		Frame(0,  74, 20,  90,  72,  71,  61, 0),   /* D2L */
+		Frame(149, 223, 20,  90,  72,  71,   0, 0),   /* D2R */
+		Frame(32, 191,  9, 119, 128, 111,  48, 0),   /* D1C */
+		Frame(0,  63,  9, 119, 128, 111, 192, 0),   /* D1L */
+		Frame(160, 223,  9, 119, 128, 111,   0, 0),   /* D1R */
+		Frame(0, 223,  0, 135,   0,   0,   0, 0),   /* D0C */
+		Frame(0,  31,  0, 135,  16, 136,   0, 0),   /* D0L */
+		Frame(192, 223,  0, 135,  16, 136,   0, 0)
+	}; /* D0R */
+
+	_frameWallD3R2 = Frame(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2
+
 	_doorFrameLeftD1C = Frame(43, 74, 14, 107, 16, 94, 0, 0); // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C
 	_doorFrameRightD1C = Frame(149, 180, 14, 107, 16, 94, 0, 0); // @ G0171_s_Graphic558_Frame_DoorFrameRight_D1C
 
@@ -595,14 +463,16 @@ void DisplayMan::initConstants() {
 		_palChangeSmoke[i] = palChangeSmoke[i];
 	}
 
-	for (int i = 0; i < 12; i++)
+	for (int i = 0; i < 12; i++) {
 		_fieldAspects188[i] = fieldAspects188[i];
+		g163_FrameWalls[i] = frameWalls163[i];
+	}
 
 	for (int i = 0; i < 7; i++)
 		_projectileScales[i] = projectileScales[i];
 
 	for (int i = 0; i < k4_ExplosionAspectCount; i++)
-		g211_ExplosionAspects[i] = explosionAspects[i];
+		_explosionAspects[i] = explosionAspects[i];
 
 	_doorFrameD1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
 		Frame(64, 159, 17, 102, 48, 88, 0, 0),	 /* Closed Or Destroyed */
@@ -789,7 +659,7 @@ void DisplayMan::f460_initializeGraphicData() {
 	_g75_palChangesProjectile[2] = _g75_palChangesProjectile[3] = g17_PalChangesNoChanges;
 
 	derivedBitmapIndex = k438_DerivedBitmapFirstExplosion;
-	ExplosionAspect *expAsp = g211_ExplosionAspects;
+	ExplosionAspect *expAsp = _explosionAspects;
 	for (uint16 expAspIndex = 0; expAspIndex < k4_ExplosionAspectCount; ++expAspIndex, expAsp++) {
 		for (int16 scale = 4; scale < 32; scale += 2)
 			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(expAsp->_byteWidth, expAsp->_height, scale);
@@ -1078,7 +948,7 @@ void DisplayMan::f131_flipVertical(byte *bitmap, uint16 byteWidth, uint16 height
 }
 
 byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnByteWidth, int16& returnHeight) {
-	ExplosionAspect *explAsp = &g211_ExplosionAspects[explosionAspIndex];
+	ExplosionAspect *explAsp = &_explosionAspects[explosionAspIndex];
 	if (scale > 32)
 		scale = 32;
 	int16 pixelWidth = M78_getScaledDimension(explAsp->_byteWidth, scale);
@@ -2181,7 +2051,7 @@ void DisplayMan::f128_drawDungeon(Direction dir, int16 posX, int16 posY) {
 		f100_drawWallSetBitmap(_g697_bitmapWallSet_Wall_D3L2, frameWallD3L2);
 
 	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, 2, posX, posY) == k0_ElementTypeWall)
-		f100_drawWallSetBitmap(_g696_bitmapWallSet_Wall_D3R2, g712_FrameWall_D3R2);
+		f100_drawWallSetBitmap(_g696_bitmapWallSet_Wall_D3R2, _frameWallD3R2);
 
 	int16 tmpPosX = posX;
 	int16 tmpPosY = posY;
@@ -2299,13 +2169,39 @@ void DisplayMan::f95_loadWallSet(WallSet set) {
 		f99_copyBitmapAndFlipHorizontal(_g708_bitmapWallSet_DoorFrameLeft_D1C, _g710_bitmapWallSet_DoorFrameRight_D1C,
 										_doorFrameRightD1C._srcByteWidth, _doorFrameRightD1C._srcHeight);
 		f99_copyBitmapAndFlipHorizontal(_g697_bitmapWallSet_Wall_D3L2, _g696_bitmapWallSet_Wall_D3R2,
-										g712_FrameWall_D3R2._srcByteWidth, g712_FrameWall_D3R2._srcHeight);
+										_frameWallD3R2._srcByteWidth, _frameWallD3R2._srcHeight);
 	}
 }
 
 void DisplayMan::f96_loadCurrentMapGraphics() {
-	Box BoxWallD3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR
-	Box BoxWallD2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR
+	static Box BoxWallD3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR
+	static Box BoxWallD2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR
+	static byte doorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordinateSetIndices
+		0,   /* Door Ornament #00 Square Grid */
+		1,   /* Door Ornament #01 Iron Bars */
+		1,   /* Door Ornament #02 Jewels */
+		1,   /* Door Ornament #03 Wooden Bars */
+		0,   /* Door Ornament #04 Arched Grid */
+		2,   /* Door Ornament #05 Block Lock */
+		3,   /* Door Ornament #06 Corner Lock */
+		1,   /* Door Ornament #07 Black door */
+		2,   /* Door Ornament #08 Red Triangle Lock */
+		2,   /* Door Ornament #09 Triangle Lock */
+		1,   /* Door Ornament #10 Ra Door */
+		1    /* Door Ornament #11 Iron Door Damages */
+	};
+	static byte floorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnamentCoordinateSetIndices
+		0,   /* Floor Ornament 00 Square Grate */
+		0,   /* Floor Ornament 01 Square Pressure Pad */
+		0,   /* Floor Ornament 02 Moss */
+		0,   /* Floor Ornament 03 Round Grate */
+		2,   /* Floor Ornament 04 Round Pressure Plate */
+		0,   /* Floor Ornament 05 Black Flame Pit */
+		0,   /* Floor Ornament 06 Crack */
+		2,   /* Floor Ornament 07 Tiny Pressure Pad */
+		0    /* Floor Ornament 08 Puddle */
+	};
+
 
 	f94_loadFloorSet(_vm->_dungeonMan->_g269_currMap->_floorSet);
 	f95_loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet);
@@ -2397,14 +2293,14 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 		uint16 ornIndice = _g262_currMapFloorOrnIndices[i];
 		uint16 nativeIndice = k247_FirstFloorOrn + ornIndice * 6;
 		_g102_currMapFloorOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice;
-		_g102_currMapFloorOrnInfo[i][k1_CoordinateSet] = g195_FloorOrnCoordSetIndices[ornIndice];
+		_g102_currMapFloorOrnInfo[i][k1_CoordinateSet] = floorOrnCoordSetIndices[ornIndice];
 	}
 
 	for (uint16 i = 0; i < currMap._doorOrnCount; ++i) {
 		uint16 ornIndice = _g263_currMapDoorOrnIndices[i];
 		uint16 nativeIndice = k303_FirstDoorOrn + ornIndice;
 		_g103_currMapDoorOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice;
-		_g103_currMapDoorOrnInfo[i][k1_CoordinateSet] = g196_DoorOrnCoordIndices[ornIndice];
+		_g103_currMapDoorOrnInfo[i][k1_CoordinateSet] = doorOrnCoordIndices[ornIndice];
 	}
 
 	f93_applyCreatureReplColors(9, 8);
@@ -2479,6 +2375,130 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 		46, 57, 68    /* D1L Right, D1R Left */
 	};
 
+	static byte g205_WallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets
+		/* { X1, X2, Y1, Y2, ByteWidth, Height } */
+		{
+			{80,  83, 41,  45,  8,   5},   /* D3L */
+			{140, 143, 41,  45,  8,   5},  /* D3R */
+			{16,  29, 39,  50,  8,  12},   /* D3L */
+			{107, 120, 39,  50,  8,  12},  /* D3C */
+			{187, 200, 39,  50,  8,  12},  /* D3R */
+			{67,  77, 40,  49,  8,  10},   /* D2L */
+			{146, 156, 40,  49,  8,  10},  /* D2R */
+			{0,  17, 38,  55, 16,  18},    /* D2L */
+			{102, 123, 38,  55, 16,  18},  /* D2C */
+			{206, 223, 38,  55, 16,  18},  /* D2R */
+			{48,  63, 38,  56,  8,  19},   /* D1L */
+			{160, 175, 38,  56,  8,  19},  /* D1R */
+			{96, 127, 36,  63, 16,  28}    /* D1C */
+		},
+		{
+			{74,  82, 41,  60,  8,  20},   /* D3L */
+			{141, 149, 41,  60,  8,  20},  /* D3R */
+			{1,  47, 37,  63, 24,  27},    /* D3L */
+			{88, 134, 37,  63, 24,  27},   /* D3C */
+			{171, 217, 37,  63, 24,  27},  /* D3R */
+			{61,  76, 38,  67,  8,  30},   /* D2L */
+			{147, 162, 38,  67,  8,  30},  /* D2R */
+			{0,  43, 37,  73, 32,  37},    /* D2L */
+			{80, 143, 37,  73, 32,  37},   /* D2C */
+			{180, 223, 37,  73, 32,  37},  /* D2R */
+			{32,  63, 36,  83, 16,  48},   /* D1L */
+			{160, 191, 36,  83, 16,  48},  /* D1R */
+			{64, 159, 36,  91, 48,  56}    /* D1C */
+		},
+		{
+			{80,  83, 66,  70,  8,   5},   /* D3L */
+			{140, 143, 66,  70,  8,   5},  /* D3R */
+			{16,  29, 64,  75,  8,  12},   /* D3L */
+			{106, 119, 64,  75,  8,  12},  /* D3C */
+			{187, 200, 64,  75,  8,  12},  /* D3R */
+			{67,  77, 74,  83,  8,  10},   /* D2L */
+			{146, 156, 74,  83,  8,  10},  /* D2R */
+			{0,  17, 73,  90, 16,  18},    /* D2L */
+			{100, 121, 73,  90, 16,  18},  /* D2C */
+			{206, 223, 73,  90, 16,  18},  /* D2R */
+			{48,  63, 84, 102,  8,  19},   /* D1L */
+			{160, 175, 84, 102,  8,  19},  /* D1R */
+			{96, 127, 92, 119, 16,  28}    /* D1C */
+		},
+		{
+			{80,  83, 49,  53,  8,   5},   /* D3L */
+			{140, 143, 49,  53,  8,   5},  /* D3R */
+			{16,  29, 50,  61,  8,  12},   /* D3L */
+			{106, 119, 50,  61,  8,  12},  /* D3C */
+			{187, 200, 50,  61,  8,  12},  /* D3R */
+			{67,  77, 53,  62,  8,  10},   /* D2L */
+			{146, 156, 53,  62,  8,  10},  /* D2R */
+			{0,  17, 55,  72, 16,  18},    /* D2L */
+			{100, 121, 55,  72, 16,  18},  /* D2C */
+			{206, 223, 55,  72, 16,  18},  /* D2R */
+			{48,  63, 57,  75,  8,  19},   /* D1L */
+			{160, 175, 57,  75,  8,  19},  /* D1R */
+			{96, 127, 64,  91, 16,  28}    /* D1C */
+		},
+		{
+			{75,  90, 40,  44,  8,   5},   /* D3L */
+			{133, 148, 40,  44,  8,   5},  /* D3R */
+			{1,  48, 44,  49, 24,   6},    /* D3L */
+			{88, 135, 44,  49, 24,   6},   /* D3C */
+			{171, 218, 44,  49, 24,   6},  /* D3R */
+			{60,  77, 40,  46, 16,   7},   /* D2L */
+			{146, 163, 40,  46, 16,   7},  /* D2R */
+			{0,  35, 43,  50, 32,   8},    /* D2L */
+			{80, 143, 43,  50, 32,   8},   /* D2C */
+			{184, 223, 43,  50, 32,   8},  /* D2R */
+			{32,  63, 41,  52, 16,  12},   /* D1L */
+			{160, 191, 41,  52, 16,  12},  /* D1R */
+			{64, 159, 41,  52, 48,  12}    /* D1C */
+		},
+		{
+			{78,  85, 36,  51,  8,  16},   /* D3L */
+			{138, 145, 36,  51,  8,  16},  /* D3R */
+			{10,  41, 34,  53, 16,  20},   /* D3L */
+			{98, 129, 34,  53, 16,  20},   /* D3C */
+			{179, 210, 34,  53, 16,  20},  /* D3R */
+			{66,  75, 34,  56,  8,  23},   /* D2L */
+			{148, 157, 34,  56,  8,  23},  /* D2R */
+			{0,  26, 33,  61, 24,  29},    /* D2L */
+			{91, 133, 33,  61, 24,  29},   /* D2C */
+			{194, 223, 33,  61, 24,  29},  /* D2R */
+			{41,  56, 31,  65,  8,  35},   /* D1L */
+			{167, 182, 31,  65,  8,  35},  /* D1R */
+			{80, 143, 29,  71, 32,  43}    /* D1C */
+		},
+		{
+			{75,  82, 25,  75,  8,  51},   /* D3L */
+			{142, 149, 25,  75,  8,  51},  /* D3R */
+			{12,  60, 25,  75, 32,  51},   /* D3L */
+			{88, 136, 25,  75, 32,  51},   /* D3C */
+			{163, 211, 25,  75, 32,  51},  /* D3R */
+			{64,  73, 20,  90,  8,  71},   /* D2L */
+			{150, 159, 20,  90,  8,  71},  /* D2R */
+			{0,  38, 20,  90, 32,  71},    /* D2L */
+			{82, 142, 20,  90, 32,  71},   /* D2C */
+			{184, 223, 20,  90, 32,  71},  /* D2R */
+			{41,  56,  9, 119,  8, 111},   /* D1L */
+			{169, 184,  9, 119,  8, 111},  /* D1R */
+			{64, 159,  9, 119, 48, 111}    /* D1C */
+		},
+		{
+			{74,  85, 25,  75,  8,  51},   /* D3L */
+			{137, 149, 25,  75,  8,  51},  /* D3R */
+			{0,  75, 25,  75, 40,  51},    /* D3L Atari ST: {   0,  83, 25,  75, 48,  51 } */
+			{74, 149, 25,  75, 40,  51},   /* D3C Atari ST: {  74, 149, 25,  75, 48,  51 } */
+			{148, 223, 25,  75, 40,  51},  /* D3R Atari ST: { 139, 223, 25,  75, 48,  51 } */
+			{60,  77, 20,  90, 16,  71},   /* D2L */
+			{146, 163, 20,  90, 16,  71},  /* D2R */
+			{0,  74, 20,  90, 56,  71},    /* D2L */
+			{60, 163, 20,  90, 56,  71},   /* D2C */
+			{149, 223, 20,  90, 56,  71},  /* D2R */
+			{32,  63,  9, 119, 16, 111},   /* D1L */
+			{160, 191,  9, 119, 16, 111},  /* D1R */
+			{32, 191,  9, 119, 80, 111}    /* D1C */
+		}
+	};
+
 	static Box boxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall
 #define AP0116_i_CharacterCount    wallOrnOrd
 #define AP0116_i_WallOrnamentIndex wallOrnOrd
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 5e3a113..9c1e2d9 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -785,7 +785,9 @@ public:
 	Box _boxMovementArrows;
 	byte _palChangeSmoke[16];
 	byte _projectileScales[7];
-	ExplosionAspect g211_ExplosionAspects[k4_ExplosionAspectCount];
+	ExplosionAspect _explosionAspects[k4_ExplosionAspectCount];
+	Frame _frameWallD3R2;
+	Frame g163_FrameWalls[12];
 
 	bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
 	byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap


Commit: f866d4a1caa94b91b8def5d3b7bd9ae3ece6eb89
    https://github.com/scummvm/scummvm/commit/f866d4a1caa94b91b8def5d3b7bd9ae3ece6eb89
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add colour to mouse

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/eventman.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index d20ddb0..4bfd18c 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -1,14 +1,14 @@
 Bugs:
 	Display:
-		Broken colour palette for dungeon and cursor
-		Gui is messed up by drawn spell area line on startup
+		Broken palette for cursor
+		No food and water bar graphs
 		Spellcasting tabs are displayed inproperly, switching between them is possible tho
 		When reordering a champions, the icons in the top right corner ar drawn twice under the cursor
 
 	Logic:
 		Items thrown on the right side end up on the left side 
 		I'm not sure, but the cooldown between champion actions when fighting monsters seems too muh
-		Clicking with a scroll in hand on the eye in the inventory makes userinput glitchy
+		Clicking wit ha scroll in hand on the eye in the inventory makes userinput glitchy
 
 
 Possible bugs:
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 5d473fc..8833f89 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -379,6 +379,14 @@ void EventManager::initMouse() {
 	_gK104_mousePointerType = k0_pointerArrow;
 	_gK105_previousMousePointerType = k1_pointerHand;
 
+	byte mousePalette[16 * 3];
+	for (int i = 0; i < 16; ++i) {
+		mousePalette[i * 3] = (gK150_PalMousePointer[i] >> 8) * (256 / 16);
+		mousePalette[i * 3 + 1] = (gK150_PalMousePointer[i] >> 4) * (256 / 16);
+		mousePalette[i * 3 + 2] = gK150_PalMousePointer[i] * (256 / 16);
+	}
+	CursorMan.pushCursorPalette(mousePalette, 0, 16);
+
 	_mousePos = Common::Point(0, 0);
 	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
 	CursorMan.showMouse(false);
@@ -411,17 +419,18 @@ void EventManager::f68_setPointerToObject(byte* bitmap) {
 	byte *L0051_puc_Bitmap = _g615_mousePointerOriginalColorsObject;
 	memset(L0051_puc_Bitmap, 0, 32 * 18);
 
-	/*
 	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, palChangesMousepointerOjbectIconShadow);
 	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, boxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
 	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, palChangesMousePointerIcon);
 	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, boxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
-	*/
 
+
+	/*
 	warning(false, "TODO - Call f129_blitToBitmapShrinkWithPalChange");
 	// dummy code
 	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, boxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
 	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, boxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
+	*/
 
 	_gK100_preventBuildPointerScreenArea = false;
 	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
@@ -506,12 +515,12 @@ void EventManager::f69_setMousePointer() {
 }
 
 void EventManager::f78_showMouse() {
-	if(_g587_hideMousePointerRequestCount++ == 0)
+	if (_g587_hideMousePointerRequestCount++ == 0)
 		CursorMan.showMouse(true);
 }
 
 void EventManager::f77_hideMouse() {
-	if(_g587_hideMousePointerRequestCount-- == 1)
+	if (_g587_hideMousePointerRequestCount-- == 1)
 		CursorMan.showMouse(false);
 }
 
@@ -980,13 +989,20 @@ bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int
 
 void EventManager::setMousePointerFromSpriteData(byte* mouseSprite) {
 	byte bitmap[16 * 18];
-	for (int16 imgPart = 0; imgPart < 4; ++imgPart) {
-		for (byte *line = mouseSprite + 72 * imgPart, *pixel = bitmap; line < mouseSprite + 72 * (imgPart + 1); line += 4) {
+	memset(bitmap, 0, sizeof(bitmap));
+	for (int16 imgPart = 1; imgPart < 3; ++imgPart) {
+		for (byte *line = mouseSprite + 72 * imgPart, *pixel = bitmap;
+			 line < mouseSprite + 72 * (imgPart + 1);
+			 line += 4) {
+
 			uint16 words[2];
 			words[0] = READ_BE_UINT16(line);
 			words[1] = READ_BE_UINT16(line + 2);
-			for (int16 i = 15; i >= 0; --i)
-				*pixel++ = ((words[0] >> i) & 1) | (((words[1] >> i) & 1) << 1);
+			for (int16 i = 15; i >= 0; --i, ++pixel) {
+				uint16 val = (((words[0] >> i) & 1) | (((words[1] >> i) & 1) << 1)) << (imgPart & 0x2);
+				if (val)
+					*pixel = val + 8;
+			}
 		}
 	}
 
@@ -1028,7 +1044,7 @@ void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() {
 	uint16 mapY = _vm->_dungeonMan->_g307_partyMapY + _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
 
 	if ((mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth)
-	 && (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight))
+		&& (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight))
 		_vm->_g321_stopWaitingForPlayerInput = _vm->_moveSens->f275_sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(_vm->_dungeonMan->_g308_partyDir));
 }
 


Commit: fd1022d722f9c9b5056c3e388479eff24dc54ab0
    https://github.com/scummvm/scummvm/commit/fd1022d722f9c9b5056c3e388479eff24dc54ab0
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: More work on globals

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 51e354a..f1fc815 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -40,189 +40,6 @@
 
 namespace DM {
 
-byte g194_WallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoordinateSetIndices
-	1,   /* Wall Ornament 00 Unreadable Inscription */
-	1,   /* Wall Ornament 01 Square Alcove */
-	1,   /* Wall Ornament 02 Vi Altar */
-	1,   /* Wall Ornament 03 Arched Alcove */
-	0,   /* Wall Ornament 04 Hook */
-	0,   /* Wall Ornament 05 Iron Lock */
-	0,   /* Wall Ornament 06 Wood Ring */
-	0,   /* Wall Ornament 07 Small Switch */
-	0,   /* Wall Ornament 08 Dent 1 */
-	0,   /* Wall Ornament 09 Dent 2 */
-	0,   /* Wall Ornament 10 Iron Ring */
-	2,   /* Wall Ornament 11 Crack */
-	3,   /* Wall Ornament 12 Slime Outlet */
-	0,   /* Wall Ornament 13 Dent 3 */
-	0,   /* Wall Ornament 14 Tiny Switch */
-	0,   /* Wall Ornament 15 Green Switch Out */
-	0,   /* Wall Ornament 16 Blue Switch Out */
-	0,   /* Wall Ornament 17 Coin Slot */
-	0,   /* Wall Ornament 18 Double Iron Lock */
-	0,   /* Wall Ornament 19 Square Lock */
-	0,   /* Wall Ornament 20 Winged Lock */
-	0,   /* Wall Ornament 21 Onyx Lock */
-	0,   /* Wall Ornament 22 Stone Lock */
-	0,   /* Wall Ornament 23 Cross Lock */
-	0,   /* Wall Ornament 24 Topaz Lock */
-	0,   /* Wall Ornament 25 Skeleton Lock */
-	0,   /* Wall Ornament 26 Gold Lock */
-	0,   /* Wall Ornament 27 Tourquoise Lock */
-	0,   /* Wall Ornament 28 Emerald Lock */
-	0,   /* Wall Ornament 29 Ruby Lock */
-	0,   /* Wall Ornament 30 Ra Lock */
-	0,   /* Wall Ornament 31 Master Lock */
-	0,   /* Wall Ornament 32 Gem Hole */
-	2,   /* Wall Ornament 33 Slime */
-	2,   /* Wall Ornament 34 Grate */
-	1,   /* Wall Ornament 35 Fountain */
-	1,   /* Wall Ornament 36 Manacles */
-	1,   /* Wall Ornament 37 Ghoul's Head */
-	1,   /* Wall Ornament 38 Empty Torch Holder */
-	1,   /* Wall Ornament 39 Scratches */
-	4,   /* Wall Ornament 40 Poison Holes */
-	4,   /* Wall Ornament 41 Fireball Holes */
-	4,   /* Wall Ornament 42 Dagger Holes */
-	5,   /* Wall Ornament 43 Champion Mirror */
-	0,   /* Wall Ornament 44 Lever Up */
-	0,   /* Wall Ornament 45 Lever Down */
-	1,   /* Wall Ornament 46 Full Torch Holder */
-	0,   /* Wall Ornament 47 Red Switch Out */
-	0,   /* Wall Ornament 48 Eye Switch */
-	0,   /* Wall Ornament 49 Big Switch Out */
-	2,   /* Wall Ornament 50 Crack Switch Out */
-	0,   /* Wall Ornament 51 Green Switch In */
-	0,   /* Wall Ornament 52 Blue Switch In */
-	0,   /* Wall Ornament 53 Red Switch In */
-	0,   /* Wall Ornament 54 Big Switch In */
-	2,   /* Wall Ornament 55 Crack Switch In. Atari ST Version 1.0 1987-12-08: 0  */
-	6,   /* Wall Ornament 56 Amalgam (Encased Gem) */
-	6,   /* Wall Ornament 57 Amalgam (Free Gem) */
-	6,   /* Wall Ornament 58 Amalgam (Without Gem) */
-	7}; /* Wall Ornament 59 Lord Order (Outside) */
-
-CreatureAspect g219_CreatureAspects[k27_CreatureTypeCount] = { // @ G0219_as_Graphic558_CreatureAspects
-														   /* { FirstNativeBitmapRelativeIndex, FirstDerivedBitmapIndex, pixelWidthFront, HeightFront,
-														   pixelWidthSide, HeightSide, pixelWidthAttack, HeightAttack, CoordinateSet / TransparentColor,
-														   Replacement Color Set Index for color 10 / Replacement Color Set Index for color 9 } */
-	CreatureAspect(0, 0, 56 ,  84, 56 ,  84, 56 ,  84, 0x1D, 0x01),   /* Creature #00 Giant Scorpion / Scorpion */
-	CreatureAspect(4, 0, 32 ,  66,  0 ,   0, 32 ,  69, 0x0B, 0x20),   /* Creature #01 Swamp Slime / Slime Devil */
-	CreatureAspect(6, 0, 24 ,  48, 24 ,  48,  0 ,   0, 0x0B, 0x00),   /* Creature #02 Giggler */
-	CreatureAspect(10, 0, 32 ,  61,  0 ,   0, 32 ,  61, 0x24, 0x31),   /* Creature #03 Wizard Eye / Flying Eye */
-	CreatureAspect(12, 0, 32 ,  64, 56 ,  64, 32 ,  64, 0x14, 0x34),   /* Creature #04 Pain Rat / Hellhound */
-	CreatureAspect(16, 0, 24 ,  49, 40 ,  49,  0 ,   0, 0x18, 0x34),   /* Creature #05 Ruster */
-	CreatureAspect(19, 0, 32 ,  60,  0 ,   0, 32 ,  60, 0x0D, 0x00),   /* Creature #06 Screamer */
-	CreatureAspect(21, 0, 32 ,  43,  0 ,   0, 32 ,  64, 0x04, 0x00),   /* Creature #07 Rockpile / Rock pile */
-	CreatureAspect(23, 0, 32 ,  83,  0 ,   0, 32 ,  93, 0x04, 0x00),   /* Creature #08 Ghost / Rive */
-	CreatureAspect(25, 0, 32 , 101, 32 , 101, 32 , 101, 0x14, 0x00),   /* Creature #09 Stone Golem */
-	CreatureAspect(29, 0, 32 ,  82, 32 ,  82, 32 ,  83, 0x04, 0x00),   /* Creature #10 Mummy */
-	CreatureAspect(33, 0, 32 ,  80,  0 ,   0, 32 ,  99, 0x14, 0x00),   /* Creature #11 Black Flame */
-	CreatureAspect(35, 0, 32 ,  80, 32 ,  80, 32 ,  76, 0x04, 0x00),   /* Creature #12 Skeleton */
-	CreatureAspect(39, 0, 32 ,  96, 56 ,  93, 32 ,  90, 0x1D, 0x20),   /* Creature #13 Couatl */
-	CreatureAspect(43, 0, 32 ,  49, 16 ,  49, 32 ,  56, 0x04, 0x30),   /* Creature #14 Vexirk */
-	CreatureAspect(47, 0, 32 ,  59, 56 ,  43, 32 ,  67, 0x14, 0x78),   /* Creature #15 Magenta Worm / Worm */
-	CreatureAspect(51, 0, 32 ,  83, 32 ,  74, 32 ,  74, 0x04, 0x65),   /* Creature #16 Trolin / Ant Man */
-	CreatureAspect(55, 0, 24 ,  49, 24 ,  53, 24 ,  53, 0x24, 0x00),   /* Creature #17 Giant Wasp / Muncher */
-	CreatureAspect(59, 0, 32 ,  89, 32 ,  89, 32 ,  89, 0x04, 0x00),   /* Creature #18 Animated Armour / Deth Knight */
-	CreatureAspect(63, 0, 32 ,  84, 32 ,  84, 32 ,  84, 0x0D, 0xA9),   /* Creature #19 Materializer / Zytaz */
-	CreatureAspect(67, 0, 56 ,  27,  0 ,   0, 56 ,  80, 0x04, 0x65),   /* Creature #20 Water Elemental */
-	CreatureAspect(69, 0, 56 ,  77, 56 ,  81, 56 ,  77, 0x04, 0xA9),   /* Creature #21 Oitu */
-	CreatureAspect(73, 0, 32 ,  87, 32 ,  89, 32 ,  89, 0x04, 0xCB),   /* Creature #22 Demon */
-	CreatureAspect(77, 0, 32 ,  96, 32 ,  94, 32 ,  96, 0x04, 0x00),   /* Creature #23 Lord Chaos */
-	CreatureAspect(81, 0, 64 ,  94, 72 ,  94, 64 ,  94, 0x04, 0xCB),   /* Creature #24 Red Dragon / Dragon */
-	CreatureAspect(85, 0, 32 ,  93,  0 ,   0,  0 ,   0, 0x04, 0xCB),   /* Creature #25 Lord Order */
-	CreatureAspect(86, 0, 32 ,  93,  0 ,   0,  0 ,   0, 0x04, 0xCB)}; /* Creature #26 Grey Lord */
-
-ObjectAspect g209_ObjectAspects[k85_ObjAspectCount] = { // @ G0209_as_Graphic558_ObjectAspects
-	/* FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo, CoordinateSet */
-	ObjectAspect(0,   0, 24, 27, 0x11, 0),
-	ObjectAspect(2,   6, 24,  8, 0x00, 1),
-	ObjectAspect(3,   8,  8, 18, 0x00, 1),
-	ObjectAspect(4,  10,  8,  8, 0x00, 1),
-	ObjectAspect(5,  12,  8,  4, 0x00, 1),
-	ObjectAspect(6,  14, 16, 11, 0x00, 1),
-	ObjectAspect(7,  16, 24, 13, 0x00, 0),
-	ObjectAspect(8,  18, 32, 16, 0x00, 0),
-	ObjectAspect(9,  20, 40, 24, 0x00, 0),
-	ObjectAspect(10,  22, 16, 20, 0x00, 1),
-	ObjectAspect(11,  24, 40, 20, 0x00, 0),
-	ObjectAspect(12,  26, 32,  4, 0x00, 1),
-	ObjectAspect(13,  28, 40,  8, 0x00, 1),
-	ObjectAspect(14,  30, 32, 17, 0x00, 0),
-	ObjectAspect(15,  32, 40, 17, 0x00, 2),
-	ObjectAspect(16,  34, 16,  9, 0x00, 1),
-	ObjectAspect(17,  36, 24,  5, 0x00, 1),
-	ObjectAspect(18,  38, 16,  9, 0x00, 0),
-	ObjectAspect(19,  40,  8,  4, 0x00, 1),
-	ObjectAspect(20,  42, 32, 21, 0x00, 2),
-	ObjectAspect(21,  44, 32, 25, 0x00, 2),
-	ObjectAspect(22,  46, 32, 14, 0x00, 1),
-	ObjectAspect(23,  48, 32, 26, 0x00, 2),
-	ObjectAspect(24,  50, 32, 16, 0x00, 0),
-	ObjectAspect(25,  52, 32, 16, 0x00, 0),
-	ObjectAspect(26,  54, 16, 16, 0x00, 1),
-	ObjectAspect(27,  56, 16, 15, 0x00, 1),
-	ObjectAspect(28,  58, 16, 13, 0x00, 1),
-	ObjectAspect(29,  60, 16, 10, 0x00, 1),
-	ObjectAspect(30,  62, 40, 24, 0x00, 0),
-	ObjectAspect(31,  64, 40,  9, 0x00, 1),
-	ObjectAspect(32,  66, 16,  3, 0x00, 1),
-	ObjectAspect(33,  68, 32,  5, 0x00, 1),
-	ObjectAspect(34,  70, 40, 16, 0x00, 0),
-	ObjectAspect(35,  72,  8,  7, 0x00, 1),
-	ObjectAspect(36,  74, 32,  7, 0x00, 1),
-	ObjectAspect(37,  76, 24, 14, 0x00, 0),
-	ObjectAspect(38,  78, 16,  8, 0x00, 0),
-	ObjectAspect(39,  80,  8,  3, 0x00, 1),
-	ObjectAspect(40,  82, 40,  9, 0x00, 1),
-	ObjectAspect(41,  84, 24, 14, 0x00, 0),
-	ObjectAspect(42,  86, 40, 20, 0x00, 0),
-	ObjectAspect(43,  88, 40, 15, 0x00, 1),
-	ObjectAspect(44,  90, 32, 10, 0x00, 1),
-	ObjectAspect(45,  92, 32, 19, 0x00, 0),
-	ObjectAspect(46,  94, 40, 25, 0x00, 2),
-	ObjectAspect(47,  96, 24,  7, 0x00, 1),
-	ObjectAspect(48,  98,  8,  7, 0x00, 1),
-	ObjectAspect(49, 100, 16,  5, 0x00, 1),
-	ObjectAspect(50, 102,  8,  9, 0x00, 1),
-	ObjectAspect(51, 104, 32, 11, 0x00, 1),
-	ObjectAspect(52, 106, 32, 14, 0x00, 0),
-	ObjectAspect(53, 108, 24, 20, 0x00, 0),
-	ObjectAspect(54, 110, 16, 14, 0x00, 1),
-	ObjectAspect(55, 112, 32, 23, 0x00, 0),
-	ObjectAspect(56, 114, 24, 16, 0x00, 0),
-	ObjectAspect(57, 116, 32, 25, 0x00, 0),
-	ObjectAspect(58, 118, 24, 25, 0x00, 0),
-	ObjectAspect(59, 120,  8,  8, 0x00, 1),
-	ObjectAspect(60, 122,  8,  7, 0x00, 1),
-	ObjectAspect(61, 124,  8,  8, 0x00, 1),
-	ObjectAspect(62, 126,  8,  8, 0x00, 1),
-	ObjectAspect(63, 128,  8,  5, 0x00, 1),
-	ObjectAspect(64, 130,  8, 13, 0x01, 1),
-	ObjectAspect(65, 134, 16, 13, 0x00, 1),
-	ObjectAspect(66, 136, 16, 14, 0x00, 0),
-	ObjectAspect(67, 138, 16, 10, 0x00, 1),
-	ObjectAspect(68, 140,  8, 18, 0x00, 1),
-	ObjectAspect(69, 142,  8, 17, 0x00, 1),
-	ObjectAspect(70, 144, 32, 18, 0x00, 0),
-	ObjectAspect(71, 146, 16, 23, 0x00, 0),
-	ObjectAspect(72, 148, 16, 24, 0x00, 0),
-	ObjectAspect(73, 150, 16, 15, 0x00, 0),
-	ObjectAspect(74, 152,  8,  7, 0x00, 1),
-	ObjectAspect(75, 154,  8, 15, 0x00, 1),
-	ObjectAspect(76, 156,  8,  9, 0x00, 1),
-	ObjectAspect(77, 158, 16, 14, 0x00, 0),
-	ObjectAspect(78, 160,  8,  8, 0x00, 1),
-	ObjectAspect(79, 162, 16,  9, 0x00, 1),
-	ObjectAspect(80, 164,  8, 13, 0x01, 1),
-	ObjectAspect(81, 168,  8, 18, 0x00, 1),
-	ObjectAspect(82, 170, 24, 28, 0x00, 0),
-	ObjectAspect(83, 172, 40, 13, 0x00, 1),
-	ObjectAspect(84, 174,  8,  4, 0x00, 1),
-	ObjectAspect(85, 176, 32, 17, 0x00, 0)
-};
-
 ProjectileAspect g210_ProjectileAspect[k14_ProjectileAspectCount] = { // @ G0210_as_Graphic558_ProjectileAspects
 	/* ProjectileAspect( FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo ) */
 	ProjectileAspect(0,   0, 32, 11, 0x0011),   /* Arrow */
@@ -438,19 +255,140 @@ void DisplayMan::initConstants() {
 
 	const Frame frameWalls163[12] = { // @ G0163_as_Graphic558_Frame_Walls
 		/* { X1, X2, Y1, Y2, pixelWidth, Height, X, Y } */
-		Frame(74, 149, 25,  75,  64,  51,  18, 0),   /* D3C */
+		Frame(74, 149, 25,  75,  64,  51,  18, 0),  /* D3C */
 		Frame(0,  83, 25,  75,  64,  51,  32, 0),   /* D3L */
-		Frame(139, 223, 25,  75,  64,  51,   0, 0),   /* D3R */
-		Frame(60, 163, 20,  90,  72,  71,  16, 0),   /* D2C */
+		Frame(139, 223, 25,  75,  64,  51,   0, 0), /* D3R */
+		Frame(60, 163, 20,  90,  72,  71,  16, 0),  /* D2C */
 		Frame(0,  74, 20,  90,  72,  71,  61, 0),   /* D2L */
-		Frame(149, 223, 20,  90,  72,  71,   0, 0),   /* D2R */
-		Frame(32, 191,  9, 119, 128, 111,  48, 0),   /* D1C */
+		Frame(149, 223, 20,  90,  72,  71,   0, 0), /* D2R */
+		Frame(32, 191,  9, 119, 128, 111,  48, 0),  /* D1C */
 		Frame(0,  63,  9, 119, 128, 111, 192, 0),   /* D1L */
-		Frame(160, 223,  9, 119, 128, 111,   0, 0),   /* D1R */
+		Frame(160, 223,  9, 119, 128, 111,   0, 0), /* D1R */
 		Frame(0, 223,  0, 135,   0,   0,   0, 0),   /* D0C */
 		Frame(0,  31,  0, 135,  16, 136,   0, 0),   /* D0L */
-		Frame(192, 223,  0, 135,  16, 136,   0, 0)
-	}; /* D0R */
+		Frame(192, 223,  0, 135,  16, 136,   0, 0)  /* D0R */
+	};
+
+	const CreatureAspect creatureAspects219[k27_CreatureTypeCount] = { // @ G0219_as_Graphic558_CreatureAspects
+	/* { FirstNativeBitmapRelativeIndex, FirstDerivedBitmapIndex, pixelWidthFront, HeightFront,
+		 pixelWidthSide, HeightSide, pixelWidthAttack, HeightAttack, CoordinateSet / TransparentColor,
+		 Replacement Color Set Index for color 10 / Replacement Color Set Index for color 9 } */
+		CreatureAspect(0, 0, 56 ,  84, 56 ,  84, 56 ,  84, 0x1D, 0x01),    /* Creature #00 Giant Scorpion / Scorpion */
+		CreatureAspect(4, 0, 32 ,  66,  0 ,   0, 32 ,  69, 0x0B, 0x20),    /* Creature #01 Swamp Slime / Slime Devil */
+		CreatureAspect(6, 0, 24 ,  48, 24 ,  48,  0 ,   0, 0x0B, 0x00),    /* Creature #02 Giggler */
+		CreatureAspect(10, 0, 32 ,  61,  0 ,   0, 32 ,  61, 0x24, 0x31),   /* Creature #03 Wizard Eye / Flying Eye */
+		CreatureAspect(12, 0, 32 ,  64, 56 ,  64, 32 ,  64, 0x14, 0x34),   /* Creature #04 Pain Rat / Hellhound */
+		CreatureAspect(16, 0, 24 ,  49, 40 ,  49,  0 ,   0, 0x18, 0x34),   /* Creature #05 Ruster */
+		CreatureAspect(19, 0, 32 ,  60,  0 ,   0, 32 ,  60, 0x0D, 0x00),   /* Creature #06 Screamer */
+		CreatureAspect(21, 0, 32 ,  43,  0 ,   0, 32 ,  64, 0x04, 0x00),   /* Creature #07 Rockpile / Rock pile */
+		CreatureAspect(23, 0, 32 ,  83,  0 ,   0, 32 ,  93, 0x04, 0x00),   /* Creature #08 Ghost / Rive */
+		CreatureAspect(25, 0, 32 , 101, 32 , 101, 32 , 101, 0x14, 0x00),   /* Creature #09 Stone Golem */
+		CreatureAspect(29, 0, 32 ,  82, 32 ,  82, 32 ,  83, 0x04, 0x00),   /* Creature #10 Mummy */
+		CreatureAspect(33, 0, 32 ,  80,  0 ,   0, 32 ,  99, 0x14, 0x00),   /* Creature #11 Black Flame */
+		CreatureAspect(35, 0, 32 ,  80, 32 ,  80, 32 ,  76, 0x04, 0x00),   /* Creature #12 Skeleton */
+		CreatureAspect(39, 0, 32 ,  96, 56 ,  93, 32 ,  90, 0x1D, 0x20),   /* Creature #13 Couatl */
+		CreatureAspect(43, 0, 32 ,  49, 16 ,  49, 32 ,  56, 0x04, 0x30),   /* Creature #14 Vexirk */
+		CreatureAspect(47, 0, 32 ,  59, 56 ,  43, 32 ,  67, 0x14, 0x78),   /* Creature #15 Magenta Worm / Worm */
+		CreatureAspect(51, 0, 32 ,  83, 32 ,  74, 32 ,  74, 0x04, 0x65),   /* Creature #16 Trolin / Ant Man */
+		CreatureAspect(55, 0, 24 ,  49, 24 ,  53, 24 ,  53, 0x24, 0x00),   /* Creature #17 Giant Wasp / Muncher */
+		CreatureAspect(59, 0, 32 ,  89, 32 ,  89, 32 ,  89, 0x04, 0x00),   /* Creature #18 Animated Armour / Deth Knight */
+		CreatureAspect(63, 0, 32 ,  84, 32 ,  84, 32 ,  84, 0x0D, 0xA9),   /* Creature #19 Materializer / Zytaz */
+		CreatureAspect(67, 0, 56 ,  27,  0 ,   0, 56 ,  80, 0x04, 0x65),   /* Creature #20 Water Elemental */
+		CreatureAspect(69, 0, 56 ,  77, 56 ,  81, 56 ,  77, 0x04, 0xA9),   /* Creature #21 Oitu */
+		CreatureAspect(73, 0, 32 ,  87, 32 ,  89, 32 ,  89, 0x04, 0xCB),   /* Creature #22 Demon */
+		CreatureAspect(77, 0, 32 ,  96, 32 ,  94, 32 ,  96, 0x04, 0x00),   /* Creature #23 Lord Chaos */
+		CreatureAspect(81, 0, 64 ,  94, 72 ,  94, 64 ,  94, 0x04, 0xCB),   /* Creature #24 Red Dragon / Dragon */
+		CreatureAspect(85, 0, 32 ,  93,  0 ,   0,  0 ,   0, 0x04, 0xCB),   /* Creature #25 Lord Order */
+		CreatureAspect(86, 0, 32 ,  93,  0 ,   0,  0 ,   0, 0x04, 0xCB)    /* Creature #26 Grey Lord */
+	};
+	static ObjectAspect objectAspects209[k85_ObjAspectCount] = { // @ G0209_as_Graphic558_ObjectAspects
+		/* FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo, CoordinateSet */
+		ObjectAspect(0,   0, 24, 27, 0x11, 0),
+		ObjectAspect(2,   6, 24,  8, 0x00, 1),
+		ObjectAspect(3,   8,  8, 18, 0x00, 1),
+		ObjectAspect(4,  10,  8,  8, 0x00, 1),
+		ObjectAspect(5,  12,  8,  4, 0x00, 1),
+		ObjectAspect(6,  14, 16, 11, 0x00, 1),
+		ObjectAspect(7,  16, 24, 13, 0x00, 0),
+		ObjectAspect(8,  18, 32, 16, 0x00, 0),
+		ObjectAspect(9,  20, 40, 24, 0x00, 0),
+		ObjectAspect(10,  22, 16, 20, 0x00, 1),
+		ObjectAspect(11,  24, 40, 20, 0x00, 0),
+		ObjectAspect(12,  26, 32,  4, 0x00, 1),
+		ObjectAspect(13,  28, 40,  8, 0x00, 1),
+		ObjectAspect(14,  30, 32, 17, 0x00, 0),
+		ObjectAspect(15,  32, 40, 17, 0x00, 2),
+		ObjectAspect(16,  34, 16,  9, 0x00, 1),
+		ObjectAspect(17,  36, 24,  5, 0x00, 1),
+		ObjectAspect(18,  38, 16,  9, 0x00, 0),
+		ObjectAspect(19,  40,  8,  4, 0x00, 1),
+		ObjectAspect(20,  42, 32, 21, 0x00, 2),
+		ObjectAspect(21,  44, 32, 25, 0x00, 2),
+		ObjectAspect(22,  46, 32, 14, 0x00, 1),
+		ObjectAspect(23,  48, 32, 26, 0x00, 2),
+		ObjectAspect(24,  50, 32, 16, 0x00, 0),
+		ObjectAspect(25,  52, 32, 16, 0x00, 0),
+		ObjectAspect(26,  54, 16, 16, 0x00, 1),
+		ObjectAspect(27,  56, 16, 15, 0x00, 1),
+		ObjectAspect(28,  58, 16, 13, 0x00, 1),
+		ObjectAspect(29,  60, 16, 10, 0x00, 1),
+		ObjectAspect(30,  62, 40, 24, 0x00, 0),
+		ObjectAspect(31,  64, 40,  9, 0x00, 1),
+		ObjectAspect(32,  66, 16,  3, 0x00, 1),
+		ObjectAspect(33,  68, 32,  5, 0x00, 1),
+		ObjectAspect(34,  70, 40, 16, 0x00, 0),
+		ObjectAspect(35,  72,  8,  7, 0x00, 1),
+		ObjectAspect(36,  74, 32,  7, 0x00, 1),
+		ObjectAspect(37,  76, 24, 14, 0x00, 0),
+		ObjectAspect(38,  78, 16,  8, 0x00, 0),
+		ObjectAspect(39,  80,  8,  3, 0x00, 1),
+		ObjectAspect(40,  82, 40,  9, 0x00, 1),
+		ObjectAspect(41,  84, 24, 14, 0x00, 0),
+		ObjectAspect(42,  86, 40, 20, 0x00, 0),
+		ObjectAspect(43,  88, 40, 15, 0x00, 1),
+		ObjectAspect(44,  90, 32, 10, 0x00, 1),
+		ObjectAspect(45,  92, 32, 19, 0x00, 0),
+		ObjectAspect(46,  94, 40, 25, 0x00, 2),
+		ObjectAspect(47,  96, 24,  7, 0x00, 1),
+		ObjectAspect(48,  98,  8,  7, 0x00, 1),
+		ObjectAspect(49, 100, 16,  5, 0x00, 1),
+		ObjectAspect(50, 102,  8,  9, 0x00, 1),
+		ObjectAspect(51, 104, 32, 11, 0x00, 1),
+		ObjectAspect(52, 106, 32, 14, 0x00, 0),
+		ObjectAspect(53, 108, 24, 20, 0x00, 0),
+		ObjectAspect(54, 110, 16, 14, 0x00, 1),
+		ObjectAspect(55, 112, 32, 23, 0x00, 0),
+		ObjectAspect(56, 114, 24, 16, 0x00, 0),
+		ObjectAspect(57, 116, 32, 25, 0x00, 0),
+		ObjectAspect(58, 118, 24, 25, 0x00, 0),
+		ObjectAspect(59, 120,  8,  8, 0x00, 1),
+		ObjectAspect(60, 122,  8,  7, 0x00, 1),
+		ObjectAspect(61, 124,  8,  8, 0x00, 1),
+		ObjectAspect(62, 126,  8,  8, 0x00, 1),
+		ObjectAspect(63, 128,  8,  5, 0x00, 1),
+		ObjectAspect(64, 130,  8, 13, 0x01, 1),
+		ObjectAspect(65, 134, 16, 13, 0x00, 1),
+		ObjectAspect(66, 136, 16, 14, 0x00, 0),
+		ObjectAspect(67, 138, 16, 10, 0x00, 1),
+		ObjectAspect(68, 140,  8, 18, 0x00, 1),
+		ObjectAspect(69, 142,  8, 17, 0x00, 1),
+		ObjectAspect(70, 144, 32, 18, 0x00, 0),
+		ObjectAspect(71, 146, 16, 23, 0x00, 0),
+		ObjectAspect(72, 148, 16, 24, 0x00, 0),
+		ObjectAspect(73, 150, 16, 15, 0x00, 0),
+		ObjectAspect(74, 152,  8,  7, 0x00, 1),
+		ObjectAspect(75, 154,  8, 15, 0x00, 1),
+		ObjectAspect(76, 156,  8,  9, 0x00, 1),
+		ObjectAspect(77, 158, 16, 14, 0x00, 0),
+		ObjectAspect(78, 160,  8,  8, 0x00, 1),
+		ObjectAspect(79, 162, 16,  9, 0x00, 1),
+		ObjectAspect(80, 164,  8, 13, 0x01, 1),
+		ObjectAspect(81, 168,  8, 18, 0x00, 1),
+		ObjectAspect(82, 170, 24, 28, 0x00, 0),
+		ObjectAspect(83, 172, 40, 13, 0x00, 1),
+		ObjectAspect(84, 174,  8,  4, 0x00, 1),
+		ObjectAspect(85, 176, 32, 17, 0x00, 0)
+	};
 
 	_frameWallD3R2 = Frame(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2
 
@@ -465,7 +403,7 @@ void DisplayMan::initConstants() {
 
 	for (int i = 0; i < 12; i++) {
 		_fieldAspects188[i] = fieldAspects188[i];
-		g163_FrameWalls[i] = frameWalls163[i];
+		_frameWalls163[i] = frameWalls163[i];
 	}
 
 	for (int i = 0; i < 7; i++)
@@ -474,6 +412,12 @@ void DisplayMan::initConstants() {
 	for (int i = 0; i < k4_ExplosionAspectCount; i++)
 		_explosionAspects[i] = explosionAspects[i];
 
+	for (int i = 0; i < k27_CreatureTypeCount; i++)
+		_creatureAspects219[i] = creatureAspects219[i];
+
+	for (int i = 0; i < k85_ObjAspectCount; i++)
+		_objectAspects209[i] = objectAspects209[i];
+
 	_doorFrameD1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
 		Frame(64, 159, 17, 102, 48, 88, 0, 0),	 /* Closed Or Destroyed */
 		Frame(64, 159, 17, 38, 48, 88, 0, 66),	 /* Vertical Closed one fourth */
@@ -611,7 +555,7 @@ void DisplayMan::f460_initializeGraphicData() {
 	_g102_currMapFloorOrnInfo[k15_FloorOrnFootprints][k0_NativeBitmapIndex] = k241_FloorOrn_15_D3L_footprints;
 	_g102_currMapFloorOrnInfo[k15_FloorOrnFootprints][k1_CoordinateSet] = 1;
 
-	ObjectAspect *objectAspect = g209_ObjectAspects;
+	ObjectAspect *objectAspect = _objectAspects209;
 	int16 derivedBitmapIndex;
 	for (int16 objectAspectIndex = 0; objectAspectIndex < k85_ObjAspectCount; ++objectAspectIndex, ++objectAspect) {
 		derivedBitmapIndex = k104_DerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex;
@@ -672,7 +616,7 @@ void DisplayMan::f460_initializeGraphicData() {
 	derivedBitmapIndex = k495_DerivedBitmapFirstCreature;
 	CreatureAspect *creatureAsp;
 	for (int16 creatureIndex = 0; creatureIndex < k27_CreatureTypeCount; creatureIndex++) {
-		creatureAsp = &g219_CreatureAspects[creatureIndex];
+		creatureAsp = &_creatureAspects219[creatureIndex];
 
 		int16 creatureGraphicInfo = g243_CreatureInfo[creatureIndex]._graphicInfo;
 		creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex;
@@ -1293,7 +1237,7 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 			f104_drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, frameStairsDownFrontD3L);
 		goto T0116015_redEagle;
 	case k0_WallElemType:
-		f100_drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k1_ViewSquare_D3L]);
+		f100_drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, _frameWalls163[k1_ViewSquare_D3L]);
 		f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT);
 		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
@@ -1327,7 +1271,7 @@ T0116017_orangeElk:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&_fieldAspects188[k1_ViewSquare_D3L], g163_FrameWalls[k1_ViewSquare_D3L]._box);
+		f113_drawField(&_fieldAspects188[k1_ViewSquare_D3L], _frameWalls163[k1_ViewSquare_D3L]._box);
 	}
 }
 
@@ -1363,7 +1307,7 @@ void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 		}
 		goto T0117016;
 	case k0_ElementTypeWall:
-		f100_drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k2_ViewSquare_D3R]);
+		f100_drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, _frameWalls163[k2_ViewSquare_D3R]);
 		f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT);
 		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
@@ -1401,7 +1345,7 @@ T0117018:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&_fieldAspects188[k2_ViewSquare_D3R], g163_FrameWalls[k2_ViewSquare_D3R]._box);
+		f113_drawField(&_fieldAspects188[k2_ViewSquare_D3R], _frameWalls163[k2_ViewSquare_D3R]._box);
 	}
 }
 
@@ -1438,7 +1382,7 @@ void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 		}
 		goto T0118027;
 	case k0_ElementTypeWall:
-		f101_drawWallSetBitmapWithoutTransparency(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k0_ViewSquare_D3C]);
+		f101_drawWallSetBitmapWithoutTransparency(_g698_bitmapWallSet_Wall_D3LCR, _frameWalls163[k0_ViewSquare_D3C]);
 		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
 			goto T0118028;
@@ -1470,7 +1414,7 @@ T0118028:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&_fieldAspects188[k0_ViewSquare_D3C], g163_FrameWalls[k0_ViewSquare_D3C]._box);
+		f113_drawField(&_fieldAspects188[k0_ViewSquare_D3C], _frameWalls163[k0_ViewSquare_D3C]._box);
 	}
 }
 
@@ -1508,7 +1452,7 @@ void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 		}
 		goto T0119018;
 	case k0_ElementTypeWall:
-		f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k4_ViewSquare_D2L]);
+		f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, _frameWalls163[k4_ViewSquare_D2L]);
 		f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT);
 		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
@@ -1542,7 +1486,7 @@ T0119020:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&_fieldAspects188[k4_ViewSquare_D2L], g163_FrameWalls[k4_ViewSquare_D2L]._box);
+		f113_drawField(&_fieldAspects188[k4_ViewSquare_D2L], _frameWalls163[k4_ViewSquare_D2L]._box);
 	}
 }
 
@@ -1581,7 +1525,7 @@ void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
 		}
 		goto T0120027;
 	case k0_ElementTypeWall:
-		f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k5_ViewSquare_D2R]);
+		f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, _frameWalls163[k5_ViewSquare_D2R]);
 		f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT);
 		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
@@ -1616,7 +1560,7 @@ T0120029:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&_fieldAspects188[k5_ViewSquare_D2R], g163_FrameWalls[k5_ViewSquare_D2R]._box);
+		f113_drawField(&_fieldAspects188[k5_ViewSquare_D2R], _frameWalls163[k5_ViewSquare_D2R]._box);
 	}
 }
 
@@ -1655,7 +1599,7 @@ void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 		}
 		goto T0121015;
 	case k0_ElementTypeWall:
-		f101_drawWallSetBitmapWithoutTransparency(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k3_ViewSquare_D2C]);
+		f101_drawWallSetBitmapWithoutTransparency(_g699_bitmapWallSet_Wall_D2LCR, _frameWalls163[k3_ViewSquare_D2C]);
 		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) {
 			order = k0x0000_CellOrder_Alcove;
 			goto T0121016;
@@ -1688,7 +1632,7 @@ T0121016:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&_fieldAspects188[k3_ViewSquare_D2C], g163_FrameWalls[k3_ViewSquare_D2C]._box);
+		f113_drawField(&_fieldAspects188[k3_ViewSquare_D2C], _frameWalls163[k3_ViewSquare_D2C]._box);
 	}
 }
 
@@ -1728,7 +1672,7 @@ void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
 		}
 		goto T0122019;
 	case k0_ElementTypeWall:
-		f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k7_ViewSquare_D1L]);
+		f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, _frameWalls163[k7_ViewSquare_D1L]);
 		f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT);
 		return;
 	case k18_ElementTypeStairsSide:
@@ -1762,7 +1706,7 @@ T0122021:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&_fieldAspects188[k7_ViewSquare_D1L], g163_FrameWalls[k7_ViewSquare_D1L]._box);
+		f113_drawField(&_fieldAspects188[k7_ViewSquare_D1L], _frameWalls163[k7_ViewSquare_D1L]._box);
 	}
 }
 
@@ -1801,7 +1745,7 @@ void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {
 		}
 		goto T0123019;
 	case k0_ElementTypeWall:
-		f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k8_ViewSquare_D1R]);
+		f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, _frameWalls163[k8_ViewSquare_D1R]);
 		f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT);
 		return;
 	case k18_ElementTypeStairsSide:
@@ -1835,7 +1779,7 @@ T0123021:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&_fieldAspects188[k8_ViewSquare_D1R], g163_FrameWalls[k8_ViewSquare_D1R]._box);
+		f113_drawField(&_fieldAspects188[k8_ViewSquare_D1R], _frameWalls163[k8_ViewSquare_D1R]._box);
 	}
 }
 
@@ -1876,7 +1820,7 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 							  boxThievesEyeVisibleArea,
 							  0, 0, 48, 48, k10_ColorFlesh, 95, 95);
 		}
-		f101_drawWallSetBitmapWithoutTransparency(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k6_ViewSquare_D1C]);
+		f101_drawWallSetBitmapWithoutTransparency(_g700_bitmapWallSet_Wall_D1LCR, _frameWalls163[k6_ViewSquare_D1C]);
 		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) {
 			f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, k0x0000_CellOrder_Alcove);
 		}
@@ -1914,7 +1858,7 @@ T0124018:
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, order);
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&_fieldAspects188[k6_ViewSquare_D1C], g163_FrameWalls[k6_ViewSquare_D1C]._box);
+		f113_drawField(&_fieldAspects188[k6_ViewSquare_D1C], _frameWalls163[k6_ViewSquare_D1C]._box);
 	}
 }
 
@@ -1931,7 +1875,7 @@ void DisplayMan::f125_drawSquareD0L(Direction dir, int16 posX, int16 posY) {
 			f104_drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, frameStairsSideD0L);
 		break;
 	case k0_WallElemType:
-		f100_drawWallSetBitmap(_g701_bitmapWallSet_Wall_D0L, g163_FrameWalls[k10_ViewSquare_D0L]);
+		f100_drawWallSetBitmap(_g701_bitmapWallSet_Wall_D0L, _frameWalls163[k10_ViewSquare_D0L]);
 		break;
 	default:
 		break;
@@ -1939,7 +1883,7 @@ void DisplayMan::f125_drawSquareD0L(Direction dir, int16 posX, int16 posY) {
 
 	f112_drawCeilingPit(k67_ceilingPitD0L_grahicIndice, &frameCeilingPitD0L, posX, posY, false);
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
-		f113_drawField(&_fieldAspects188[k10_ViewSquare_D0L], g163_FrameWalls[k10_ViewSquare_D0L]._box);
+		f113_drawField(&_fieldAspects188[k10_ViewSquare_D0L], _frameWalls163[k10_ViewSquare_D0L]._box);
 }
 
 void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
@@ -1964,11 +1908,11 @@ void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k11_ViewSquare_D0R, k0x0001_CellOrder_BackLeft);
 		break;
 	case k0_ElementTypeWall:
-		f100_drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, g163_FrameWalls[k11_ViewSquare_D0R]);
+		f100_drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, _frameWalls163[k11_ViewSquare_D0R]);
 		return;
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&_fieldAspects188[k11_ViewSquare_D0R], g163_FrameWalls[k11_ViewSquare_D0R]._box);
+		f113_drawField(&_fieldAspects188[k11_ViewSquare_D0R], _frameWalls163[k11_ViewSquare_D0R]._box);
 	}
 }
 
@@ -2012,7 +1956,7 @@ void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 	f112_drawCeilingPit(k68_ceilingPitD0C_graphicIndice, &frameCeilingPitD0C, posX, posY, false);
 	f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k9_ViewSquare_D0C, k0x0021_CellOrder_BackLeft_BackRight);
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
-		f113_drawField(&_fieldAspects188[k9_ViewSquare_D0C], g163_FrameWalls[k9_ViewSquare_D0C]._box);
+		f113_drawField(&_fieldAspects188[k9_ViewSquare_D0C], _frameWalls163[k9_ViewSquare_D0C]._box);
 	}
 }
 
@@ -2201,6 +2145,69 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 		2,   /* Floor Ornament 07 Tiny Pressure Pad */
 		0    /* Floor Ornament 08 Puddle */
 	};
+	static byte g194_WallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoordinateSetIndices
+		1,   /* Wall Ornament 00 Unreadable Inscription */
+		1,   /* Wall Ornament 01 Square Alcove */
+		1,   /* Wall Ornament 02 Vi Altar */
+		1,   /* Wall Ornament 03 Arched Alcove */
+		0,   /* Wall Ornament 04 Hook */
+		0,   /* Wall Ornament 05 Iron Lock */
+		0,   /* Wall Ornament 06 Wood Ring */
+		0,   /* Wall Ornament 07 Small Switch */
+		0,   /* Wall Ornament 08 Dent 1 */
+		0,   /* Wall Ornament 09 Dent 2 */
+		0,   /* Wall Ornament 10 Iron Ring */
+		2,   /* Wall Ornament 11 Crack */
+		3,   /* Wall Ornament 12 Slime Outlet */
+		0,   /* Wall Ornament 13 Dent 3 */
+		0,   /* Wall Ornament 14 Tiny Switch */
+		0,   /* Wall Ornament 15 Green Switch Out */
+		0,   /* Wall Ornament 16 Blue Switch Out */
+		0,   /* Wall Ornament 17 Coin Slot */
+		0,   /* Wall Ornament 18 Double Iron Lock */
+		0,   /* Wall Ornament 19 Square Lock */
+		0,   /* Wall Ornament 20 Winged Lock */
+		0,   /* Wall Ornament 21 Onyx Lock */
+		0,   /* Wall Ornament 22 Stone Lock */
+		0,   /* Wall Ornament 23 Cross Lock */
+		0,   /* Wall Ornament 24 Topaz Lock */
+		0,   /* Wall Ornament 25 Skeleton Lock */
+		0,   /* Wall Ornament 26 Gold Lock */
+		0,   /* Wall Ornament 27 Tourquoise Lock */
+		0,   /* Wall Ornament 28 Emerald Lock */
+		0,   /* Wall Ornament 29 Ruby Lock */
+		0,   /* Wall Ornament 30 Ra Lock */
+		0,   /* Wall Ornament 31 Master Lock */
+		0,   /* Wall Ornament 32 Gem Hole */
+		2,   /* Wall Ornament 33 Slime */
+		2,   /* Wall Ornament 34 Grate */
+		1,   /* Wall Ornament 35 Fountain */
+		1,   /* Wall Ornament 36 Manacles */
+		1,   /* Wall Ornament 37 Ghoul's Head */
+		1,   /* Wall Ornament 38 Empty Torch Holder */
+		1,   /* Wall Ornament 39 Scratches */
+		4,   /* Wall Ornament 40 Poison Holes */
+		4,   /* Wall Ornament 41 Fireball Holes */
+		4,   /* Wall Ornament 42 Dagger Holes */
+		5,   /* Wall Ornament 43 Champion Mirror */
+		0,   /* Wall Ornament 44 Lever Up */
+		0,   /* Wall Ornament 45 Lever Down */
+		1,   /* Wall Ornament 46 Full Torch Holder */
+		0,   /* Wall Ornament 47 Red Switch Out */
+		0,   /* Wall Ornament 48 Eye Switch */
+		0,   /* Wall Ornament 49 Big Switch Out */
+		2,   /* Wall Ornament 50 Crack Switch Out */
+		0,   /* Wall Ornament 51 Green Switch In */
+		0,   /* Wall Ornament 52 Blue Switch In */
+		0,   /* Wall Ornament 53 Red Switch In */
+		0,   /* Wall Ornament 54 Big Switch In */
+		2,   /* Wall Ornament 55 Crack Switch In. Atari ST Version 1.0 1987-12-08: 0  */
+		6,   /* Wall Ornament 56 Amalgam (Encased Gem) */
+		6,   /* Wall Ornament 57 Amalgam (Free Gem) */
+		6,   /* Wall Ornament 58 Amalgam (Without Gem) */
+		7    /* Wall Ornament 59 Lord Order (Outside) */
+	};
+
 
 
 	f94_loadFloorSet(_vm->_dungeonMan->_g269_currMap->_floorSet);
@@ -2209,21 +2216,21 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 	_g578_useByteBoxCoordinates = true;
 
 	f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap,
-									g163_FrameWalls[k0_ViewSquare_D3C]._srcByteWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight);
+									_frameWalls163[k0_ViewSquare_D3C]._srcByteWidth, _frameWalls163[k0_ViewSquare_D3C]._srcHeight);
 	f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, k10_ColorFlesh, 64, 51);
 	f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, BoxWallD3LCR, 11, 0, 64, 64, kM1_ColorNoTransparency, 51, 51);
 
 	f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap,
-									g163_FrameWalls[k3_ViewSquare_D2C]._srcByteWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight);
+									_frameWalls163[k3_ViewSquare_D2C]._srcByteWidth, _frameWalls163[k3_ViewSquare_D2C]._srcHeight);
 	f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, k10_ColorFlesh, 72, 71);
 	f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, BoxWallD2LCR, 8, 0, 72, 72, kM1_ColorNoTransparency, 71, 71);
 
 	f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped,
-									g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight);
+									_frameWalls163[k6_ViewSquare_D1C]._srcByteWidth, _frameWalls163[k6_ViewSquare_D1C]._srcHeight);
 	f99_copyBitmapAndFlipHorizontal(_g98_bitmapWall_D0L_Native = _g701_bitmapWallSet_Wall_D0L, _g94_bitmapWall_D0R_Flipped,
-									g163_FrameWalls[k10_ViewSquare_D0L]._srcByteWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight);
+									_frameWalls163[k10_ViewSquare_D0L]._srcByteWidth, _frameWalls163[k10_ViewSquare_D0L]._srcHeight);
 	f99_copyBitmapAndFlipHorizontal(_g99_bitmapWall_D0R_Native = _g702_bitmapWallSet_Wall_D0R, _g93_bitmapWall_D0L_Flipped,
-									g163_FrameWalls[k10_ViewSquare_D0L]._srcByteWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight);
+									_frameWalls163[k10_ViewSquare_D0L]._srcByteWidth, _frameWalls163[k10_ViewSquare_D0L]._srcHeight);
 
 	int16 val = _vm->_dungeonMan->_g269_currMap->_wallSet * k18_StairsGraphicCount + k90_FirstStairs;
 	_g675_stairsNativeBitmapIndex_Up_Front_D3L = val++;
@@ -2307,7 +2314,7 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 	f93_applyCreatureReplColors(10, 12);
 
 	for (uint16 creatureType = 0; creatureType < currMap._creatureTypeCount; ++creatureType) {
-		CreatureAspect &aspect = g219_CreatureAspects[_g264_currMapAllowedCreatureTypes[creatureType]];
+		CreatureAspect &aspect = _creatureAspects219[_g264_currMapAllowedCreatureTypes[creatureType]];
 		uint16 replColorOrdinal = aspect.getReplColour9();
 		if (replColorOrdinal)
 			f93_applyCreatureReplColors(9, _vm->M1_ordinalToIndex(replColorOrdinal));
@@ -2538,7 +2545,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 		if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) {
 			if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
 				if (L0095_B_IsInscription) {
-					f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, boxWallPatchBehindInscription, 94, 28, g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport);
+					f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, boxWallPatchBehindInscription, 94, 28, _frameWalls163[k6_ViewSquare_D1C]._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency, _frameWalls163[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport);
 					AL0090_puc_String = L0099_auc_InscriptionString;
 					L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont);
 					L0097_i_TextLineIndex = 0;
@@ -3024,7 +3031,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 				continue;
 			}
 			if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) { /* Square where objects are visible and object is located on cell being processed */
-				objectAspect = &(g209_ObjectAspects[g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thingParam)]._objectAspectIndex]);
+				objectAspect = &(_objectAspects209[g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thingParam)]._objectAspectIndex]);
 				AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex;
 				if (useAlcoveObjectImage = (L0135_B_DrawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane)) {
 					AL_4_nativeBitmapIndex++;
@@ -3150,7 +3157,7 @@ T0115015_DrawProjectileAsObject:
 			group = (Group*)_vm->_dungeonMan->f156_getThingData(groupThing);
 			activeGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
 			creatureInfo = &g243_CreatureInfo[group->_type];
-			creatureAspectStruct = &g219_CreatureAspects[creatureInfo->_creatureAspectIndex];
+			creatureAspectStruct = &_creatureAspects219[creatureInfo->_creatureAspectIndex];
 			creatureSize = getFlag(creatureInfo->_attributes, k0x0003_MaskCreatureInfo_size);
 			creatureGraphicInfoGreen = creatureInfo->_graphicInfo;
 		}
@@ -3495,7 +3502,7 @@ T0115129_DrawProjectiles:
 					projectileCoordinates[0] = projectilePosX;
 					projectileCoordinates[1] = 47;
 					coordinateSet = projectileCoordinates;
-					objectAspect = &g209_ObjectAspects[AL_4_projectileAspect];
+					objectAspect = &_objectAspects209[AL_4_projectileAspect];
 					AL_4_nativeBitmapIndex = objectAspect->_firstNativeBitmapRelativeIndex + k360_FirstObjectGraphicIndice;
 					drawProjectileAsObject = true;
 					goto T0115015_DrawProjectileAsObject; /* Go to code section to draw an object. Once completed, it jumps back to T0115171_BackFromT0115015_DrawProjectileAsObject below */
@@ -3632,7 +3639,7 @@ T0115200_DrawExplosion:
 		AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */
 		fieldAspect = _fieldAspects188[viewSquareIndex];
 		(fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */
-		f113_drawField(&fieldAspect, g163_FrameWalls[viewSquareIndex]._box);
+		f113_drawField(&fieldAspect, _frameWalls163[viewSquareIndex]._box);
 	}
 T0115214_Return:
 	;
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 9c1e2d9..27abe11 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -434,16 +434,14 @@ private:
 public:
 
 	CreatureAspect(uint16 uint161, uint16 uint162, byte byte0, byte byte1, byte byte2, byte byte3, byte byte4, byte byte5, byte byte6, byte byte7)
-		: _firstNativeBitmapRelativeIndex(uint161),
-		_firstDerivedBitmapIndex(uint162),
-		_byteWidthFront(byte0),
-		_heightFront(byte1),
-		_byteWidthSide(byte2),
-		_heightSide(byte3),
-		_byteWidthAttack(byte4),
-		_heightAttack(byte5),
-		_coordinateSet_TransparentColor(byte6),
-		_replacementColorSetIndices(byte7) {}
+		: _firstNativeBitmapRelativeIndex(uint161), _firstDerivedBitmapIndex(uint162), _byteWidthFront(byte0),
+		_heightFront(byte1), _byteWidthSide(byte2), _heightSide(byte3), _byteWidthAttack(byte4),
+		_heightAttack(byte5), _coordinateSet_TransparentColor(byte6), _replacementColorSetIndices(byte7) {}
+
+	CreatureAspect() :
+		_firstNativeBitmapRelativeIndex(0), _firstDerivedBitmapIndex(0), _byteWidthFront(0),
+		_heightFront(0), _byteWidthSide(0), _heightSide(0), _byteWidthAttack(0),
+		_heightAttack(0), _coordinateSet_TransparentColor(0), _replacementColorSetIndices(0) {}
 
 	byte getCoordSet() { return (_coordinateSet_TransparentColor >> 4) & 0xF; } // @ M71_COORDINATE_SET
 	byte getTranspColour() { return  _coordinateSet_TransparentColor & 0xF; } // @ M72_TRANSPARENT_COLOR
@@ -462,6 +460,8 @@ public:
 	ObjectAspect(byte firstN, byte firstD, byte byteWidth, byte h, byte grap, byte coord) :
 		_firstNativeBitmapRelativeIndex(firstN), _firstDerivedBitmapRelativeIndex(firstD),
 		_byteWidth(byteWidth), _height(h), _graphicInfo(grap), _coordinateSet(coord) {}
+	ObjectAspect() : _firstNativeBitmapRelativeIndex(0), _firstDerivedBitmapRelativeIndex(0),
+		_byteWidth(0), _height(0), _graphicInfo(0), _coordinateSet(0) {}
 }; // @ OBJECT_ASPECT
 
 class ProjectileAspect {
@@ -787,7 +787,9 @@ public:
 	byte _projectileScales[7];
 	ExplosionAspect _explosionAspects[k4_ExplosionAspectCount];
 	Frame _frameWallD3R2;
-	Frame g163_FrameWalls[12];
+	Frame _frameWalls163[12];
+	CreatureAspect _creatureAspects219[k27_CreatureTypeCount];
+	ObjectAspect _objectAspects209[k85_ObjAspectCount]; // @ G0209_as_Graphic558_ObjectAspects
 
 	bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
 	byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap


Commit: 641ef973b01a76bfd1377e19c3fc9beb458166ab
    https://github.com/scummvm/scummvm/commit/641ef973b01a76bfd1377e19c3fc9beb458166ab
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: More work on globals in gfx.cpp

Changed paths:
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 2912b31..cf0202e 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -278,11 +278,13 @@ void DMEngine::f463_initializeGame() {
 }
 
 void DMEngine::f448_initMemoryManager() {
+	static uint16 palSwoosh[16] = {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}; // @ K0057_aui_Palette_Swoosh
+
 	warning(false, "STUB METHOD: f448_initMemoryManager");
-	_displayMan->f508_buildPaletteChangeCopperList(gK57_PalSwoosh, gK57_PalSwoosh);
+	_displayMan->f508_buildPaletteChangeCopperList(palSwoosh, palSwoosh);
 	for (uint16 i = 0; i < 16; ++i) {
-		_displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i];
-		_displayMan->_g346_paletteMiddleScreen[i] = g21_PalDungeonView[0][i];
+		_displayMan->_g347_paletteTopAndBottomScreen[i] = _displayMan->_palDungeonView[0][i];
+		_displayMan->_g346_paletteMiddleScreen[i] = _displayMan->_palDungeonView[0][i];
 	}
 }
 
@@ -323,7 +325,7 @@ void DMEngine::f462_startGame() {
 		_displayMan->D24_fillScreenBox(boxScreenBottom, k0_ColorBlack);
 	}
 
-	_displayMan->f508_buildPaletteChangeCopperList(g21_PalDungeonView[0], _displayMan->_g347_paletteTopAndBottomScreen);
+	_displayMan->f508_buildPaletteChangeCopperList(_displayMan->_palDungeonView[0], _displayMan->_g347_paletteTopAndBottomScreen);
 	_menuMan->f395_drawMovementArrows();
 	_championMan->f278_resetDataToStartGame();
 	_g301_gameTimeTicking = true;
@@ -658,7 +660,7 @@ T0444017:
 			if (_g523_restartGameRequest) {
 				_displayMan->f436_STARTEND_FadeToPalette(darkBluePalette);
 				_displayMan->fillScreen(k0_ColorBlack);
-				_displayMan->f436_STARTEND_FadeToPalette(g21_PalDungeonView[0]);
+				_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_palDungeonView[0]);
 				_g298_newGame = k0_modeLoadSavedGame;
 				if (f435_loadgame(1) != kM1_LoadgameFailure) {
 					f462_startGame();
@@ -675,7 +677,7 @@ T0444017:
 	Box box(0, 319, 0, 199);
 	_displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice), &box, k160_byteWidthScreen, kM1_ColorNoTransparency, k200_heightScreen);
 
-	_displayMan->f436_STARTEND_FadeToPalette(g19_PalCredits);
+	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_palCredits);
 	_eventMan->f541_waitForMouseOrKeyActivity();
 	if (_engineShouldQuit)
 		return;
@@ -696,6 +698,8 @@ void DMEngine::f439_drawEntrance() {
 	static Box doorsLowerHalfBox = Box(0, 231, 81, 160);
 	static Box closedDoorLeftBox = Box(0, 104, 30, 190);
 	static Box closedDoorRightBox = Box(105, 231, 30, 190);
+	/* Atari ST: { 0x000, 0x333, 0x444, 0x420, 0x654, 0x210, 0x040, 0x050, 0x432, 0x700, 0x543, 0x321, 0x222, 0x555, 0x310, 0x777 }, RGB colors are different */
+	static uint16 palEntrance[16] = {0x000, 0x666, 0x888, 0x840, 0xCA8, 0x0C0, 0x080, 0x0A0, 0x864, 0xF00, 0xA86, 0x642, 0x444, 0xAAA, 0x620, 0xFFF}; // @ G0020_aui_Graphic562_Palette_Entrance
 
 	byte *microDungeonCurrentMapData[32];
 
@@ -732,7 +736,7 @@ void DMEngine::f439_drawEntrance() {
 
 	_displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[0], &closedDoorLeftBox, k64_byteWidth, kM1_ColorNoTransparency, 161);
 	_displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[4], &closedDoorRightBox, k64_byteWidth, kM1_ColorNoTransparency, 161);
-	_displayMan->f436_STARTEND_FadeToPalette(g20_PalEntrance);
+	_displayMan->f436_STARTEND_FadeToPalette(palEntrance);
 }
 
 void DMEngine::f438_STARTEND_OpenEntranceDoors() {
@@ -772,7 +776,7 @@ void DMEngine::f442_SARTEND_processCommand202_entranceDrawCredits() {
 	_eventMan->f78_showMouse();
 	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
 	_displayMan->f466_loadIntoBitmap(k5_creditsGraphicIndice, _displayMan->_g348_bitmapScreen);
-	_displayMan->f436_STARTEND_FadeToPalette(g19_PalCredits);
+	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_palCredits);
 	f22_delay(50);
 	_eventMan->f541_waitForMouseOrKeyActivity();
 	_g298_newGame = k202_modeEntranceDrawCredits;
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 8833f89..c2cb3cc 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -369,6 +369,8 @@ EventManager::~EventManager() {
 }
 
 void EventManager::initMouse() {
+	static uint16 gK150_PalMousePointer[16] = {0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x000, 0xAAA, 0x00F, 0xFFF}; // @ K0150_aui_Palette_MousePointer
+
 	if (!_g615_mousePointerOriginalColorsObject)
 		_g615_mousePointerOriginalColorsObject = new byte[32 * 18];
 	if (!_gK190_mousePointerTempBuffer)
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index f1fc815..0617999 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -39,82 +39,14 @@
 #include "eventman.h"
 
 namespace DM {
-
-ProjectileAspect g210_ProjectileAspect[k14_ProjectileAspectCount] = { // @ G0210_as_Graphic558_ProjectileAspects
-	/* ProjectileAspect( FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo ) */
-	ProjectileAspect(0,   0, 32, 11, 0x0011),   /* Arrow */
-	ProjectileAspect(3,  18, 16, 11, 0x0011),   /* Dagger */
-	ProjectileAspect(6,  36, 24, 47, 0x0010),   /* Axe - Executioner */
-	ProjectileAspect(9,  54, 32, 15, 0x0112),   /* Explosion Lightning Bolt */
-	ProjectileAspect(11,  54, 32, 12, 0x0011),   /* Slayer */
-	ProjectileAspect(14,  72, 24, 47, 0x0010),   /* Stone Club */
-	ProjectileAspect(17,  90, 24, 47, 0x0010),   /* Club */
-	ProjectileAspect(20, 108, 16, 11, 0x0011),   /* Poison Dart */
-	ProjectileAspect(23, 126, 48, 18, 0x0011),   /* Storm - Side Splitter - Diamond Edge - Falchion - Ra Blade - Rapier - Biter - Samurai Sword - Sword - Dragon Fang */
-	ProjectileAspect(26, 144,  8, 15, 0x0012),   /* Throwing Star */
-	ProjectileAspect(28, 156, 16, 28, 0x0103),   /* Explosion Fireball */
-	ProjectileAspect(29, 156, 16, 11, 0x0103),   /* Explosion Default */
-	ProjectileAspect(30, 156, 16, 28, 0x0103),   /* Explosion Slime */
-	ProjectileAspect(31, 156, 16, 24, 0x0103) /* Explosion Poison Bolt Poison Cloud */
-};
-
-
-/* Identical to the palette at the end of the swoosh palette animation */
-uint16 gK57_PalSwoosh[16] = {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}; // @ K0057_aui_Palette_Swoosh
-uint16 gK150_PalMousePointer[16] = {0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x000, 0xAAA, 0x00F, 0xFFF}; // @ K0150_aui_Palette_MousePointer
-/* Atari ST: { 0x003, 0x055, 0x773, 0x420, 0x774, 0x000, 0x040, 0x500, 0x642, 0x775, 0x742, 0x760, 0x750, 0x000, 0x310, 0x776 }, RGB colors are different */
-uint16 g19_PalCredits[16] = {0x006, 0x0AA, 0xFF6, 0x840, 0xFF8, 0x000, 0x080, 0xA00, 0xC84, 0xFFA, 0xF84, 0xFC0, 0xFA0, 0x000, 0x620, 0xFFC}; // @ G0019_aui_Graphic562_Palette_Credits
-/* Atari ST: { 0x000, 0x333, 0x444, 0x420, 0x654, 0x210, 0x040, 0x050, 0x432, 0x700, 0x543, 0x321, 0x222, 0x555, 0x310, 0x777 }, RGB colors are different */
-uint16 g20_PalEntrance[16] = {0x000, 0x666, 0x888, 0x840, 0xCA8, 0x0C0, 0x080, 0x0A0, 0x864, 0xF00, 0xA86, 0x642, 0x444, 0xAAA, 0x620, 0xFFF}; // @ G0020_aui_Graphic562_Palette_Entrance
-uint16 g21_PalDungeonView[6][16] = { // @ G0021_aaui_Graphic562_Palette_DungeonView
-	/* Atari ST: { 0x000, 0x333, 0x444, 0x310, 0x066, 0x420, 0x040, 0x060, 0x700, 0x750, 0x643, 0x770, 0x222, 0x555, 0x007, 0x777 }, RGB colors are different */
-	0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x444, 0xAAA, 0x00F, 0xFFF,
-	/* Atari ST: { 0x000, 0x222, 0x333, 0x310, 0x066, 0x410, 0x030, 0x050, 0x600, 0x640, 0x532, 0x760, 0x111, 0x444, 0x006, 0x666 }, RGB colors are different */
-	0x000, 0x444, 0x666, 0x620, 0x0CC, 0x820, 0x060, 0x0A0, 0xC00, 0x000, 0x000, 0xFC0, 0x222, 0x888, 0x00C, 0xCCC,
-	/* Atari ST: { 0x000, 0x111, 0x222, 0x210, 0x066, 0x310, 0x020, 0x040, 0x500, 0x530, 0x421, 0x750, 0x000, 0x333, 0x005, 0x555 }, RGB colors are different */
-	0x000, 0x222, 0x444, 0x420, 0x0CC, 0x620, 0x040, 0x080, 0xA00, 0x000, 0x000, 0xFA0, 0x000, 0x666, 0x00A, 0xAAA,
-	/* Atari ST: { 0x000, 0x000, 0x111, 0x100, 0x066, 0x210, 0x010, 0x030, 0x400, 0x420, 0x310, 0x640, 0x000, 0x222, 0x004, 0x444 }, RGB colors are different */
-	0x000, 0x000, 0x222, 0x200, 0x0CC, 0x420, 0x020, 0x060, 0x800, 0x000, 0x000, 0xC80, 0x000, 0x444, 0x008, 0x888,
-	/* Atari ST: { 0x000, 0x000, 0x000, 0x000, 0x066, 0x100, 0x000, 0x020, 0x300, 0x310, 0x200, 0x530, 0x000, 0x111, 0x003, 0x333 }, RGB colors are different */
-	0x000, 0x000, 0x000, 0x000, 0x0CC, 0x200, 0x000, 0x040, 0x600, 0x000, 0x000, 0xA60, 0x000, 0x222, 0x006, 0x666,
-	/* Atari ST: { 0x000, 0x000, 0x000, 0x000, 0x066, 0x000, 0x000, 0x010, 0x200, 0x200, 0x100, 0x320, 0x000, 0x000, 0x002, 0x222 }, RGB colors are different */
-	0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444
-};
-
-CreatureReplColorSet g220_CreatureReplColorSets[13] = { // @ G0220_as_Graphic558_CreatureReplacementColorSets
-	/* { Color, Color, Color, Color, Color, Color, D2 replacement color index (x10), D3 replacement color index (x10) } */
-	{0x0CA0, 0x0A80, 0x0860, 0x0640, 0x0420, 0x0200,  90,  90},    /* Atari ST: { 0x0650, 0x0540, 0x0430, 0x0320, 0x0210, 0x0100,  90,  90 }, RGB colors are different */
-	{0x0060, 0x0040, 0x0020, 0x0000, 0x0000, 0x0000,   0,   0},    /* Atari ST: { 0x0030, 0x0020, 0x0010, 0x0000, 0x0000, 0x0000,   0,   0 }, */
-	{0x0860, 0x0640, 0x0420, 0x0200, 0x0000, 0x0000, 100, 100},    /* Atari ST: { 0x0430, 0x0320, 0x0210, 0x0100, 0x0000, 0x0000, 100, 100 }, */
-	{0x0640, 0x0420, 0x0200, 0x0000, 0x0000, 0x0000,  90,   0},    /* Atari ST: { 0x0320, 0x0210, 0x0100, 0x0000, 0x0000, 0x0000,  90,   0 }, */
-	{0x000A, 0x0008, 0x0006, 0x0004, 0x0002, 0x0000,  90, 100},    /* Atari ST: { 0x0005, 0x0004, 0x0003, 0x0002, 0x0001, 0x0000,  90, 100 }, */
-	{0x0008, 0x0006, 0x0004, 0x0002, 0x0000, 0x0000, 100,   0},    /* Atari ST: { 0x0004, 0x0003, 0x0002, 0x0001, 0x0000, 0x0000, 100,   0 }, */
-	{0x0808, 0x0606, 0x0404, 0x0202, 0x0000, 0x0000,  90,   0},    /* Atari ST: { 0x0404, 0x0303, 0x0202, 0x0101, 0x0000, 0x0000,  90,   0 }, */
-	{0x0A0A, 0x0808, 0x0606, 0x0404, 0x0202, 0x0000, 100,  90},    /* Atari ST: { 0x0505, 0x0404, 0x0303, 0x0202, 0x0101, 0x0000, 100,  90 }, */
-	{0x0FA0, 0x0C80, 0x0A60, 0x0840, 0x0620, 0x0400, 100,  50},    /* Atari ST: { 0x0750, 0x0640, 0x0530, 0x0420, 0x0310, 0x0200, 100,  50 }, */
-	{0x0F80, 0x0C60, 0x0A40, 0x0820, 0x0600, 0x0200,  50,  70},    /* Atari ST: { 0x0740, 0x0630, 0x0520, 0x0410, 0x0300, 0x0100,  50,  30 }, D3 replacement color index is different */
-	{0x0800, 0x0600, 0x0400, 0x0200, 0x0000, 0x0000, 100, 120},    /* Atari ST: { 0x0400, 0x0300, 0x0200, 0x0100, 0x0000, 0x0000, 100, 100 }, D3 replacement color index is different */
-	{0x0600, 0x0400, 0x0200, 0x0000, 0x0000, 0x0000, 120,   0},    /* Atari ST: { 0x0300, 0x0200, 0x0100, 0x0000, 0x0000, 0x0000, 120,   0 }, */
-	{0x0C86, 0x0A64, 0x0842, 0x0620, 0x0400, 0x0200, 100,  50}};  /* Atari ST: { 0x0643, 0x0532, 0x0421, 0x0310, 0x0200, 0x0100, 100,  50 } }; */
-
 byte g221_PalChangesCreature_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 0, 0, 110, 0, 20, 0, 130}; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3
 byte g222_PalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, 120, 130, 140, 150}; // @ G0222_auc_Graphic558_PaletteChanges_Creature_D2
 
-
-
-
-
 byte g17_PalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges
 
 byte g213_PalChangesFloorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 140, 130}; // @ G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3
 byte g214_PalChangesFloorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2
 
-int16 g193_FountainOrnIndices[k1_FountainOrnCount] = {35}; // @ G0193_ai_Graphic558_FountainOrnamentIndices
-byte g192_AlcoveOrnIndices[k3_AlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrnamentIndices
-	1,   /* Square Alcove */
-	2,   /* Vi Altar */
-	3};  /* Arched Alcove */
-
 
 DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_g348_bitmapScreen = nullptr;
@@ -390,6 +322,41 @@ void DisplayMan::initConstants() {
 		ObjectAspect(85, 176, 32, 17, 0x00, 0)
 	};
 
+	static ProjectileAspect projectileAspect[k14_ProjectileAspectCount] = { // @ G0210_as_Graphic558_ProjectileAspects
+		/* ProjectileAspect( FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo ) */
+		ProjectileAspect(0,   0, 32, 11, 0x0011),   /* Arrow */
+		ProjectileAspect(3,  18, 16, 11, 0x0011),   /* Dagger */
+		ProjectileAspect(6,  36, 24, 47, 0x0010),   /* Axe - Executioner */
+		ProjectileAspect(9,  54, 32, 15, 0x0112),   /* Explosion Lightning Bolt */
+		ProjectileAspect(11,  54, 32, 12, 0x0011),   /* Slayer */
+		ProjectileAspect(14,  72, 24, 47, 0x0010),   /* Stone Club */
+		ProjectileAspect(17,  90, 24, 47, 0x0010),   /* Club */
+		ProjectileAspect(20, 108, 16, 11, 0x0011),   /* Poison Dart */
+		ProjectileAspect(23, 126, 48, 18, 0x0011),   /* Storm - Side Splitter - Diamond Edge - Falchion - Ra Blade - Rapier - Biter - Samurai Sword - Sword - Dragon Fang */
+		ProjectileAspect(26, 144,  8, 15, 0x0012),   /* Throwing Star */
+		ProjectileAspect(28, 156, 16, 28, 0x0103),   /* Explosion Fireball */
+		ProjectileAspect(29, 156, 16, 11, 0x0103),   /* Explosion Default */
+		ProjectileAspect(30, 156, 16, 28, 0x0103),   /* Explosion Slime */
+		ProjectileAspect(31, 156, 16, 24, 0x0103) /* Explosion Poison Bolt Poison Cloud */
+	};
+
+	/* Atari ST: { 0x003, 0x055, 0x773, 0x420, 0x774, 0x000, 0x040, 0x500, 0x642, 0x775, 0x742, 0x760, 0x750, 0x000, 0x310, 0x776 }, RGB colors are different */
+	static uint16 palCredits[16] = {0x006, 0x0AA, 0xFF6, 0x840, 0xFF8, 0x000, 0x080, 0xA00, 0xC84, 0xFFA, 0xF84, 0xFC0, 0xFA0, 0x000, 0x620, 0xFFC}; // @ G0019_aui_Graphic562_Palette_Credits
+	static uint16 palDungeonView[6][16] = { // @ G0021_aaui_Graphic562_Palette_DungeonView
+		/* Atari ST: { 0x000, 0x333, 0x444, 0x310, 0x066, 0x420, 0x040, 0x060, 0x700, 0x750, 0x643, 0x770, 0x222, 0x555, 0x007, 0x777 }, RGB colors are different */
+		0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x444, 0xAAA, 0x00F, 0xFFF,
+		/* Atari ST: { 0x000, 0x222, 0x333, 0x310, 0x066, 0x410, 0x030, 0x050, 0x600, 0x640, 0x532, 0x760, 0x111, 0x444, 0x006, 0x666 }, RGB colors are different */
+		0x000, 0x444, 0x666, 0x620, 0x0CC, 0x820, 0x060, 0x0A0, 0xC00, 0x000, 0x000, 0xFC0, 0x222, 0x888, 0x00C, 0xCCC,
+		/* Atari ST: { 0x000, 0x111, 0x222, 0x210, 0x066, 0x310, 0x020, 0x040, 0x500, 0x530, 0x421, 0x750, 0x000, 0x333, 0x005, 0x555 }, RGB colors are different */
+		0x000, 0x222, 0x444, 0x420, 0x0CC, 0x620, 0x040, 0x080, 0xA00, 0x000, 0x000, 0xFA0, 0x000, 0x666, 0x00A, 0xAAA,
+		/* Atari ST: { 0x000, 0x000, 0x111, 0x100, 0x066, 0x210, 0x010, 0x030, 0x400, 0x420, 0x310, 0x640, 0x000, 0x222, 0x004, 0x444 }, RGB colors are different */
+		0x000, 0x000, 0x222, 0x200, 0x0CC, 0x420, 0x020, 0x060, 0x800, 0x000, 0x000, 0xC80, 0x000, 0x444, 0x008, 0x888,
+		/* Atari ST: { 0x000, 0x000, 0x000, 0x000, 0x066, 0x100, 0x000, 0x020, 0x300, 0x310, 0x200, 0x530, 0x000, 0x111, 0x003, 0x333 }, RGB colors are different */
+		0x000, 0x000, 0x000, 0x000, 0x0CC, 0x200, 0x000, 0x040, 0x600, 0x000, 0x000, 0xA60, 0x000, 0x222, 0x006, 0x666,
+		/* Atari ST: { 0x000, 0x000, 0x000, 0x000, 0x066, 0x000, 0x000, 0x010, 0x200, 0x200, 0x100, 0x320, 0x000, 0x000, 0x002, 0x222 }, RGB colors are different */
+		0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444
+	};
+
 	_frameWallD3R2 = Frame(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2
 
 	_doorFrameLeftD1C = Frame(43, 74, 14, 107, 16, 94, 0, 0); // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C
@@ -399,6 +366,9 @@ void DisplayMan::initConstants() {
 		_palChangesDoorButtonAndWallOrnD3[i] = palChangesDoorButtonAndWallOrnD3[i];
 		_palChangesDoorButtonAndWallOrnD2[i] = palChangesDoorButtonAndWallOrnD2[i];
 		_palChangeSmoke[i] = palChangeSmoke[i];
+		_palCredits[i] = palCredits[i];
+		for (int j = 0; j < 6; j++)
+			_palDungeonView[j][i] = palDungeonView[j][i];
 	}
 
 	for (int i = 0; i < 12; i++) {
@@ -418,6 +388,9 @@ void DisplayMan::initConstants() {
 	for (int i = 0; i < k85_ObjAspectCount; i++)
 		_objectAspects209[i] = objectAspects209[i];
 
+	for (int i = 0; i < k14_ProjectileAspectCount; i++)
+		_projectileAspect[i] = projectileAspect[i];
+
 	_doorFrameD1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
 		Frame(64, 159, 17, 102, 48, 88, 0, 0),	 /* Closed Or Destroyed */
 		Frame(64, 159, 17, 38, 48, 88, 0, 66),	 /* Vertical Closed one fourth */
@@ -577,7 +550,7 @@ void DisplayMan::f460_initializeGraphicData() {
 		}
 	}
 
-	ProjectileAspect *projectileAspect = g210_ProjectileAspect;
+	ProjectileAspect *projectileAspect = _projectileAspect;
 	for (int16 projectileAspectIndex = 0; projectileAspectIndex < k14_ProjectileAspectCount; projectileAspectIndex++, projectileAspect++) {
 
 		if (!getFlag(projectileAspect->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask)) {
@@ -936,13 +909,12 @@ void DisplayMan::f97_drawViewport(int16 palSwitchingRequestedState) {
 		palSwitchingRequestedState = _g322_paletteSwitchingEnabled ? 1 : 0;
 
 	if (_g342_refreshDungeonViewPaleteRequested) {
-		gK10_dungeonViewCurrentPalette = g21_PalDungeonView[_g304_dungeonViewPaletteIndex];
+		gK10_dungeonViewCurrentPalette = _palDungeonView[_g304_dungeonViewPaletteIndex];
 		_g342_refreshDungeonViewPaleteRequested = false;
-		if (palSwitchingRequestedState == k0_viewportNotDungeonView) {
+		if (palSwitchingRequestedState == k0_viewportNotDungeonView)
 			_g322_paletteSwitchingEnabled = true;
-		} else {
+		else
 			_g322_paletteSwitchingEnabled = false;
-		}
 	}
 
 	if (palSwitchingRequestedState != (_g322_paletteSwitchingEnabled ? 1 : 0)) {
@@ -2207,8 +2179,11 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 		6,   /* Wall Ornament 58 Amalgam (Without Gem) */
 		7    /* Wall Ornament 59 Lord Order (Outside) */
 	};
-
-
+	static byte g192_AlcoveOrnIndices[k3_AlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrnamentIndices
+		1,   /* Square Alcove */
+		2,   /* Vi Altar */
+		3};  /* Arched Alcove */
+	static int16 g193_FountainOrnIndices[k1_FountainOrnCount] = {35}; // @ G0193_ai_Graphic558_FountainOrnamentIndices
 
 	f94_loadFloorSet(_vm->_dungeonMan->_g269_currMap->_floorSet);
 	f95_loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet);
@@ -2329,11 +2304,28 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 }
 
 void DisplayMan::f93_applyCreatureReplColors(int replacedColor, int replacementColor) {
+	CreatureReplColorSet creatureReplColorSets[13] = { // @ G0220_as_Graphic558_CreatureReplacementColorSets
+		/* { Color, Color, Color, Color, Color, Color, D2 replacement color index (x10), D3 replacement color index (x10) } */
+		{0x0CA0, 0x0A80, 0x0860, 0x0640, 0x0420, 0x0200,  90,  90},    /* Atari ST: { 0x0650, 0x0540, 0x0430, 0x0320, 0x0210, 0x0100,  90,  90 }, RGB colors are different */
+		{0x0060, 0x0040, 0x0020, 0x0000, 0x0000, 0x0000,   0,   0},    /* Atari ST: { 0x0030, 0x0020, 0x0010, 0x0000, 0x0000, 0x0000,   0,   0 }, */
+		{0x0860, 0x0640, 0x0420, 0x0200, 0x0000, 0x0000, 100, 100},    /* Atari ST: { 0x0430, 0x0320, 0x0210, 0x0100, 0x0000, 0x0000, 100, 100 }, */
+		{0x0640, 0x0420, 0x0200, 0x0000, 0x0000, 0x0000,  90,   0},    /* Atari ST: { 0x0320, 0x0210, 0x0100, 0x0000, 0x0000, 0x0000,  90,   0 }, */
+		{0x000A, 0x0008, 0x0006, 0x0004, 0x0002, 0x0000,  90, 100},    /* Atari ST: { 0x0005, 0x0004, 0x0003, 0x0002, 0x0001, 0x0000,  90, 100 }, */
+		{0x0008, 0x0006, 0x0004, 0x0002, 0x0000, 0x0000, 100,   0},    /* Atari ST: { 0x0004, 0x0003, 0x0002, 0x0001, 0x0000, 0x0000, 100,   0 }, */
+		{0x0808, 0x0606, 0x0404, 0x0202, 0x0000, 0x0000,  90,   0},    /* Atari ST: { 0x0404, 0x0303, 0x0202, 0x0101, 0x0000, 0x0000,  90,   0 }, */
+		{0x0A0A, 0x0808, 0x0606, 0x0404, 0x0202, 0x0000, 100,  90},    /* Atari ST: { 0x0505, 0x0404, 0x0303, 0x0202, 0x0101, 0x0000, 100,  90 }, */
+		{0x0FA0, 0x0C80, 0x0A60, 0x0840, 0x0620, 0x0400, 100,  50},    /* Atari ST: { 0x0750, 0x0640, 0x0530, 0x0420, 0x0310, 0x0200, 100,  50 }, */
+		{0x0F80, 0x0C60, 0x0A40, 0x0820, 0x0600, 0x0200,  50,  70},    /* Atari ST: { 0x0740, 0x0630, 0x0520, 0x0410, 0x0300, 0x0100,  50,  30 }, D3 replacement color index is different */
+		{0x0800, 0x0600, 0x0400, 0x0200, 0x0000, 0x0000, 100, 120},    /* Atari ST: { 0x0400, 0x0300, 0x0200, 0x0100, 0x0000, 0x0000, 100, 100 }, D3 replacement color index is different */
+		{0x0600, 0x0400, 0x0200, 0x0000, 0x0000, 0x0000, 120,   0},    /* Atari ST: { 0x0300, 0x0200, 0x0100, 0x0000, 0x0000, 0x0000, 120,   0 }, */
+		{0x0C86, 0x0A64, 0x0842, 0x0620, 0x0400, 0x0200, 100,  50}     /* Atari ST: { 0x0643, 0x0532, 0x0421, 0x0310, 0x0200, 0x0100, 100,  50 } }; */
+	};
+
 	for (int16 i = 0; i < 6; ++i)
-		g21_PalDungeonView[i][replacedColor] = g220_CreatureReplColorSets[replacementColor]._RGBColor[i];
+		_palDungeonView[i][replacedColor] = creatureReplColorSets[replacementColor]._RGBColor[i];
 
-	g222_PalChangesCreature_D2[replacedColor] = g220_CreatureReplColorSets[replacementColor]._D2ReplacementColor;
-	g221_PalChangesCreature_D3[replacedColor] = g220_CreatureReplColorSets[replacementColor]._D3ReplacementColor;
+	g222_PalChangesCreature_D2[replacedColor] = creatureReplColorSets[replacementColor]._D2ReplacementColor;
+	g221_PalChangesCreature_D3[replacedColor] = creatureReplColorSets[replacementColor]._D3ReplacementColor;
 }
 
 void DisplayMan::f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
@@ -3399,7 +3391,7 @@ T0115129_DrawProjectiles:
 			if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) {
 				projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(thingParam);
 				if ((AL_4_projectileAspect = _vm->_dungeonMan->f142_getProjectileAspect(projectile->_slot)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
-					objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-AL_4_projectileAspect)];
+					objectAspect = (ObjectAspect*)&_projectileAspect[_vm->M1_ordinalToIndex(-AL_4_projectileAspect)];
 					AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
 					projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
 					if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask)) || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == k9_ViewSquare_D0C)) {
@@ -3536,7 +3528,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 						AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke;
 					} else {
 						if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) {
-							objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-_vm->_dungeonMan->f142_getProjectileAspect(Thing::_explLightningBolt))];
+							objectAspect = (ObjectAspect*)&_projectileAspect[_vm->M1_ordinalToIndex(-_vm->_dungeonMan->f142_getProjectileAspect(Thing::_explLightningBolt))];
 							AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
 							explosionCoordinates = g228_RebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
 							byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_byteWidth), explosionCoordinates[2]);
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 27abe11..99a8442 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -310,12 +310,6 @@ enum GraphicIndice {
 };
 
 extern byte g17_PalChangesNoChanges[16];
-extern uint16 gK57_PalSwoosh[16]; // @ K0057_aui_Palette_Swoosh
-extern uint16 gK150_PalMousePointer[16];	// @ K0150_aui_Palette_MousePointer
-extern uint16 g19_PalCredits[16];  // @ G0019_aui_Graphic562_Palette_Credits
-extern uint16 g20_PalEntrance[16]; // @ G0020_aui_Graphic562_Palette_Entrance
-extern uint16 g21_PalDungeonView[6][16]; // @ G0021_aaui_Graphic562_Palette_DungeonView
-
 
 // in all cases, where a function takes a Box, it expects it to contain inclusive boundaries
 class Box {
@@ -416,8 +410,6 @@ public:
 	FieldAspect() {}
 }; // @ FIELD_ASPECT
 
-
-
 class CreatureAspect {
 public:
 	uint16 _firstNativeBitmapRelativeIndex;
@@ -475,6 +467,9 @@ public:
 	ProjectileAspect(byte firstN, byte firstD, byte byteWidth, byte h, uint16 grap) :
 		_firstNativeBitmapRelativeIndex(firstN), _firstDerivedBitmapRelativeIndex(firstD),
 		_byteWidth(byteWidth), _height(h), _graphicInfo(grap) {}
+
+	ProjectileAspect() : _firstNativeBitmapRelativeIndex(0), 
+		_firstDerivedBitmapRelativeIndex(0), _byteWidth(0), _height(0), _graphicInfo(0) {}
 }; // @ PROJECTIL_ASPECT
 
 class CreatureReplColorSet {
@@ -790,6 +785,9 @@ public:
 	Frame _frameWalls163[12];
 	CreatureAspect _creatureAspects219[k27_CreatureTypeCount];
 	ObjectAspect _objectAspects209[k85_ObjAspectCount]; // @ G0209_as_Graphic558_ObjectAspects
+	ProjectileAspect _projectileAspect[k14_ProjectileAspectCount]; // @ G0210_as_Graphic558_ProjectileAspects
+	uint16 _palCredits[16]; // @ G0019_aui_Graphic562_Palette_Credits
+	uint16 _palDungeonView[6][16]; // @ G0021_aaui_Graphic562_Palette_DungeonView
 
 	bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
 	byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap


Commit: 514bad0d09d9abcb1a5ab8ac2016c048d7286fcd
    https://github.com/scummvm/scummvm/commit/514bad0d09d9abcb1a5ab8ac2016c048d7286fcd
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Get rid the last globals of gfx.cpp

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/menus.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 0617999..62282e6 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -39,15 +39,6 @@
 #include "eventman.h"
 
 namespace DM {
-byte g221_PalChangesCreature_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 0, 0, 110, 0, 20, 0, 130}; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3
-byte g222_PalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, 120, 130, 140, 150}; // @ G0222_auc_Graphic558_PaletteChanges_Creature_D2
-
-byte g17_PalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges
-
-byte g213_PalChangesFloorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 140, 130}; // @ G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3
-byte g214_PalChangesFloorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2
-
-
 DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_g348_bitmapScreen = nullptr;
 	_bitmaps = nullptr;
@@ -67,7 +58,6 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_g266_currMapViAltarIndex = 0;
 	_g297_drawFloorAndCeilingRequested = true;
 
-
 	for (int i = 0; i < 4; i++)
 		_g75_palChangesProjectile[i] = nullptr;
 
@@ -357,6 +347,12 @@ void DisplayMan::initConstants() {
 		0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444
 	};
 
+	static byte palChangesCreatureD3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 0, 0, 110, 0, 20, 0, 130}; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3
+	static byte palChangesCreatureD2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, 120, 130, 140, 150}; // @ G0222_auc_Graphic558_PaletteChanges_Creature_D2
+	static byte palChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges
+	static byte palChangesFloorOrnD3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 140, 130}; // @ G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3
+	static byte palChangesFloorOrnD2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2
+
 	_frameWallD3R2 = Frame(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2
 
 	_doorFrameLeftD1C = Frame(43, 74, 14, 107, 16, 94, 0, 0); // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C
@@ -367,6 +363,11 @@ void DisplayMan::initConstants() {
 		_palChangesDoorButtonAndWallOrnD2[i] = palChangesDoorButtonAndWallOrnD2[i];
 		_palChangeSmoke[i] = palChangeSmoke[i];
 		_palCredits[i] = palCredits[i];
+		_palChangesCreatureD3[i] = palChangesCreatureD3[i];
+		_palChangesCreatureD2[i] = palChangesCreatureD2[i];
+		_palChangesNoChanges[16] = palChangesNoChanges[i];
+		_palChangesFloorOrnD3[i] = palChangesFloorOrnD3[i];
+		_palChangesFloorOrnD2[i] = palChangesFloorOrnD2[i];
 		for (int j = 0; j < 6; j++)
 			_palDungeonView[j][i] = palDungeonView[j][i];
 	}
@@ -571,9 +572,9 @@ void DisplayMan::f460_initializeGraphicData() {
 		}
 	}
 
-	_g75_palChangesProjectile[0] = g213_PalChangesFloorOrn_D3;
-	_g75_palChangesProjectile[1] = g214_PalChangesFloorOrn_D2;
-	_g75_palChangesProjectile[2] = _g75_palChangesProjectile[3] = g17_PalChangesNoChanges;
+	_g75_palChangesProjectile[0] = _palChangesFloorOrnD3;
+	_g75_palChangesProjectile[1] = _palChangesFloorOrnD2;
+	_g75_palChangesProjectile[2] = _g75_palChangesProjectile[3] = _palChangesNoChanges;
 
 	derivedBitmapIndex = k438_DerivedBitmapFirstExplosion;
 	ExplosionAspect *expAsp = _explosionAspects;
@@ -880,7 +881,7 @@ byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale
 		byte *nativeBitmap = f489_getNativeBitmapOrGraphic(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice);
 		bitmap = f492_getDerivedBitmap(derBitmapIndex);
 		f129_blitToBitmapShrinkWithPalChange(nativeBitmap, bitmap, explAsp->_byteWidth, explAsp->_height, pixelWidth * 2, height,
-			(explosionAspIndex == k3_ExplosionAspectSmoke) ? _palChangeSmoke : g17_PalChangesNoChanges);
+			(explosionAspIndex == k3_ExplosionAspectSmoke) ? _palChangeSmoke : _palChangesNoChanges);
 		f493_addDerivedBitmap(derBitmapIndex);
 	}
 
@@ -2324,8 +2325,8 @@ void DisplayMan::f93_applyCreatureReplColors(int replacedColor, int replacementC
 	for (int16 i = 0; i < 6; ++i)
 		_palDungeonView[i][replacedColor] = creatureReplColorSets[replacementColor]._RGBColor[i];
 
-	g222_PalChangesCreature_D2[replacedColor] = creatureReplColorSets[replacementColor]._D2ReplacementColor;
-	g221_PalChangesCreature_D3[replacedColor] = creatureReplColorSets[replacementColor]._D3ReplacementColor;
+	_palChangesCreatureD2[replacedColor] = creatureReplColorSets[replacementColor]._D2ReplacementColor;
+	_palChangesCreatureD3[replacedColor] = creatureReplColorSets[replacementColor]._D3ReplacementColor;
 }
 
 void DisplayMan::f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
@@ -3055,12 +3056,12 @@ T0115015_DrawProjectileAsObject:
 						AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front;
 						byteWidth = M78_getScaledDimension(objectAspect->_byteWidth, k20_Scale_D2);
 						heightRedEagle = M78_getScaledDimension(objectAspect->_height, k20_Scale_D2);
-						paletteChanges = g214_PalChangesFloorOrn_D2;
+						paletteChanges = _palChangesFloorOrnD2;
 					} else {
 						AL_8_shiftSetIndex = k2_ShiftSet_D2BackD3Front;
 						byteWidth = M78_getScaledDimension(objectAspect->_byteWidth, k16_Scale_D3);
 						heightRedEagle = M78_getScaledDimension(objectAspect->_height, k16_Scale_D3);
-						paletteChanges = g213_PalChangesFloorOrn_D3;
+						paletteChanges = _palChangesFloorOrnD3;
 					}
 					if (flipHorizontal) {
 						derivedBitmapIndex += 2;
@@ -3312,12 +3313,12 @@ T0115077_DrawSecondHalfSquareCreature:
 				derivedBitmapIndex++; /* Skip front D3 image in additional graphics */
 				AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front;
 				useCreatureSpecialD2FrontBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0080_CreatureInfoGraphicMaskSpecialD2Front) && !useCreatureSideBitmap && !useCreatureBackBitmap && !useCreatureAttackBitmap;
-				paletteChanges = g222_PalChangesCreature_D2;
+				paletteChanges = _palChangesCreatureD2;
 				scale = k20_Scale_D2;
 			} else { /* Creature is on D3 */
 				AL_8_shiftSetIndex = k2_ShiftSet_D2BackD3Front;
 				useCreatureSpecialD2FrontBitmap = false;
-				paletteChanges = g221_PalChangesCreature_D3;
+				paletteChanges = _palChangesCreatureD3;
 				scale = k16_Scale_D3;
 			}
 			byteWidth = M78_getScaledDimension(sourceByteWidth, scale);
@@ -3534,7 +3535,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 							byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_byteWidth), explosionCoordinates[2]);
 							heightRedEagle = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
 							if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) {
-								f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, g17_PalChangesNoChanges);
+								f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, _palChangesNoChanges);
 								AL_6_bitmapRedBanana = _g74_tmpBitmap;
 							}
 							goto T0115200_DrawExplosion;
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 99a8442..2d4ae4e 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -788,6 +788,11 @@ public:
 	ProjectileAspect _projectileAspect[k14_ProjectileAspectCount]; // @ G0210_as_Graphic558_ProjectileAspects
 	uint16 _palCredits[16]; // @ G0019_aui_Graphic562_Palette_Credits
 	uint16 _palDungeonView[6][16]; // @ G0021_aaui_Graphic562_Palette_DungeonView
+	byte _palChangesCreatureD3[16]; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3
+	byte _palChangesCreatureD2[16]; // @ G0222_auc_Graphic558_PaletteChanges_Creature_D2
+	byte _palChangesNoChanges[16]; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges
+	byte _palChangesFloorOrnD3[16]; // @ G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3
+	byte _palChangesFloorOrnD2[16]; // @ G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2
 
 	bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
 	byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index d1879db..5fa9eeb 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -1711,7 +1711,8 @@ void MenuMan::f385_drawActionDamage(int16 damage) {
 			L1643_i_Width = 37;
 			if (!_vm->_displayMan->f491_isDerivedBitmapInCache(AL1174_ui_DerivedBitmapIndex)) {
 				AL1178_puc_Bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
-				_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(AL1178_puc_Bitmap, L1177_puc_Bitmap = _vm->_displayMan->f492_getDerivedBitmap(AL1174_ui_DerivedBitmapIndex), 96, 45, AL1176_i_PixelWidth, 37, g17_PalChangesNoChanges);
+				L1177_puc_Bitmap = _vm->_displayMan->f492_getDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
+				_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(AL1178_puc_Bitmap, L1177_puc_Bitmap, 96, 45, AL1176_i_PixelWidth, 37, _vm->_displayMan->_palChangesNoChanges);
 				_vm->_displayMan->f493_addDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
 			} else {
 				L1177_puc_Bitmap = _vm->_displayMan->f492_getDerivedBitmap(AL1174_ui_DerivedBitmapIndex);


Commit: 3fdd68fe315eddb87cd901a88737d8afb5ad8ba7
    https://github.com/scummvm/scummvm/commit/3fdd68fe315eddb87cd901a88737d8afb5ad8ba7
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Minor adjustment to fuseSequence timing

Changed paths:
    engines/dm/dm.cpp
    engines/dm/gfx.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index cf0202e..66475db 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -927,10 +927,9 @@ void DMEngine::f445_STARTEND_fuseSequenceUpdate() {
 	f65_playPendingSound();
 	_eventMan->f357_discardAllInput();
 	_displayMan->updateScreen();
-	f22_delay(1);
+	f22_delay(2);
 	_g313_gameTime++; /* BUG0_71 Some timings are too short on fast computers.
 					  The ending animation when Lord Chaos is fused plays too quickly because the execution speed is not limited */
-
 }
 
 } // End of namespace DM
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 62282e6..3c4bfac 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -834,8 +834,8 @@ void DisplayMan::f135_fillBoxBitmap(byte* destBitmap, Box &box, Color color, int
 void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box,
 													int16 lastUnitIndex, int16 firstUnitIndex, int16 destByteWidth, Color transparent,
 													int16 xPos, int16 yPos, int16 destHeight, int16 height2) {
-		 // make sure to take care of inclusive boundaries
-	warning(false, "STUB FUNCTION: does nothing at all");
+		 // make sure to take care of inclusive boundaries, color can have 0x8000 flag to not use mask
+
 }
 
 


Commit: c7b353385d08b3c848a59967e769a0eeec837d4e
    https://github.com/scummvm/scummvm/commit/c7b353385d08b3c848a59967e769a0eeec837d4e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix mouse when clicking on eye

Changed paths:
    engines/dm/inventory.cpp



diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index bc28396..698210a 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -739,7 +739,9 @@ void InventoryMan::f350_drawStopPressingMouth() {
 	f347_drawPanel();
 	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
 	_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->f78_showMouse();
 }
 
 void InventoryMan::f353_drawStopPressingEye() {
@@ -751,7 +753,9 @@ void InventoryMan::f353_drawStopPressingEye() {
 	if ((L1100_T_LeaderHandObject = _vm->_championMan->_g414_leaderHandObject) != Thing::_none) {
 		_vm->_objectMan->f34_drawLeaderObjectName(L1100_T_LeaderHandObject);
 	}
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->f78_showMouse();
 }
 
 void InventoryMan::f349_processCommand70_clickOnMouth() {
@@ -957,7 +961,9 @@ void InventoryMan::f352_processCommand71_clickOnEye() {
 		return;
 	}
 	_vm->_eventMan->f357_discardAllInput();
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->f77_hideMouse();
 	_vm->f22_delay(8);
 	f332_drawIconToViewport(k203_IconIndiceEyeLooking, 12, 13);
 	if (_vm->_championMan->_g415_leaderEmptyHanded) {


Commit: 3fffb08a408b042d185fd615e2ea826e53b842fd
    https://github.com/scummvm/scummvm/commit/3fffb08a408b042d185fd615e2ea826e53b842fd
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing localization warnings and query function for language

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/champion.cpp
    engines/dm/detection.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/objectman.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 4bfd18c..1eafa4d 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -1,14 +1,11 @@
 Bugs:
 	Display:
-		Broken palette for cursor
 		No food and water bar graphs
 		Spellcasting tabs are displayed inproperly, switching between them is possible tho
-		When reordering a champions, the icons in the top right corner ar drawn twice under the cursor
+		Cursor icons are drawn twice
 
 	Logic:
 		Items thrown on the right side end up on the left side 
-		I'm not sure, but the cooldown between champion actions when fighting monsters seems too muh
-		Clicking wit ha scroll in hand on the eye in the inventory makes userinput glitchy
 
 
 Possible bugs:
@@ -19,7 +16,6 @@ Possible bugs:
 Todo:
 	Add wiki entry for DM
 	
-	I forgot to add localization warnings
 	Double check enums with hex literals
 	Double check strcat, strstr usages
 	I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 4c434b8..11371df 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -40,7 +40,7 @@
 
 namespace DM {
 
-const char *g417_baseSkillName[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"};
+const char *g417_baseSkillName[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"}; // TODO: localization
 
 Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
 Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
@@ -2149,6 +2149,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		else
 			loadColor = k13_ColorLightestGray;
 
+		// TODO: localization
 		_vm->_textMan->f52_printToViewport(104, 132, loadColor, "LOAD ");
 		maxLoad = curChampion->_load / 10;
 		strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, true, 3).c_str());
diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp
index 7d1c463..a1fd6bc 100644
--- a/engines/dm/detection.cpp
+++ b/engines/dm/detection.cpp
@@ -46,7 +46,7 @@ static const ADGameDescription gameDescriptions[] = {
 			{"Dungeon.dat", 0, "43a213da8eda413541dd12f90ce202f6", 25006},
 		AD_LISTEND
 		},
-	    Common::EN_GRB, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE)
+	    Common::EN_ANY, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE)
 	},
 
 	AD_TABLE_END_MARKER
@@ -86,7 +86,7 @@ public:
 
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
 		if(desc)
-			*engine = new DM::DMEngine(syst);
+			*engine = new DM::DMEngine(syst, desc);
 		return desc != nullptr;
 	}
 	virtual int getMaximumSaveSlot() const { return 99; }
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 66475db..13c8c63 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -56,6 +56,7 @@
 #include "projexpl.h"
 #include "dialog.h"
 #include <graphics/cursorman.h>
+#include <advancedDetector.h>
 
 namespace DM {
 void warning(bool repeat, const char* s, ...) {
@@ -140,7 +141,7 @@ int16 M38_distance(int16 mapx1, int16 mapy1, int16 mapx2, int16 mapy2) {
 	return ABS(mapx1 - mapx2) + ABS(mapy1 - mapy2);
 }
 
-DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
+DMEngine::DMEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst), _console(nullptr), _gameVersion(desc) {
 // Do not load data files
 // Do not initialize graphics here
 // Do not initialize audio devices here
@@ -646,6 +647,7 @@ T0444017:
 			_displayMan->_g578_useByteBoxCoordinates = false;
 			_displayMan->D24_fillScreenBox(restartOuterBox, k12_ColorDarkestGray);
 			_displayMan->D24_fillScreenBox(restartInnerBox, k0_ColorBlack);
+			// TODO: localization
 			_textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RESTART THIS GAME");
 			curPalette[1] = D03_RGB_PINK;
 			curPalette[4] = D09_RGB_WHITE;
@@ -932,4 +934,5 @@ void DMEngine::f445_STARTEND_fuseSequenceUpdate() {
 					  The ending animation when Lord Chaos is fused plays too quickly because the execution speed is not limited */
 }
 
+Common::Language DMEngine::getGameLanguage() { return _gameVersion->language; }
 } // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 739ef17..85910ed 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -37,6 +37,7 @@
 #include "console.h"
 
 
+struct ADGameDescription;
 
 namespace DM {
 
@@ -244,7 +245,7 @@ class DMEngine : public Engine {
 	void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance
 	void f503_loadSounds(); // @ F0503_SOUND_LoadAll
 public:
-	explicit DMEngine(OSystem *syst);
+	explicit DMEngine(OSystem *syst, const ADGameDescription *gameDesc);
 	~DMEngine();
 	virtual bool hasFeature(EngineFeature f) const;
 	GUI::Debugger *getDebugger() { return _console; }
@@ -270,6 +271,7 @@ public:
 	void f442_SARTEND_processCommand202_entranceDrawCredits();
 	void f446_STARTEND_fuseSequnce(); // @ F0446_STARTEND_FuseSequence
 	void f445_STARTEND_fuseSequenceUpdate(); // @ F0445_STARTEND_FuseSequenceUpdate
+	Common::Language getGameLanguage();
 
 private:
 	int16 _g528_saveFormat; // @ G0528_i_Format
@@ -281,6 +283,7 @@ private:
 	SoundData _gK24_soundData[k34_D13_soundCount]; // @ K0024_as_SoundData
 	Common::Queue<PendingSound> _pendingSounds;
 	byte *_savedScreenForOpenEntranceDoors; // ad-hoc HACK
+	const ADGameDescription *_gameVersion;
 public:
 	Console *_console;
 	DisplayMan *_displayMan;
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 698210a..6f4e4e4 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -180,6 +180,7 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
 	Champion &champ = _vm->_championMan->_gK71_champions[_g432_inventoryChampionOrdinal];
 	f334_closeChest();
 	DisplayMan &dispMan = *_vm->_displayMan;
+	// TODO: localization
 	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice),
 							   g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
 	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k30_FoodLabelIndice),
@@ -707,6 +708,7 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 		AL1092_i_SkillLevel = MIN((uint16)16, _vm->_championMan->f303_getSkillLevel(L1093_ui_ChampionIndex, AL1090_ui_SkillIndex | k0x8000_IgnoreTemporaryExperience));
 		if (AL1092_i_SkillLevel == 1)
 			continue;
+		// TODO: localization
 		strcpy(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]);
 		strcat(L1097_ac_String, " ");
 		strcat(L1097_ac_String, g417_baseSkillName[AL1090_ui_SkillIndex]);
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 408ad9c..d6e37b3 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -173,6 +173,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 	_dialog->f427_dialogDraw(message, nullptr, "SAVE AND PLAY", "SAVE AND QUIT", "CANCEL", nullptr, false, false, false);
 	int16 saveAndPlayChoice = _dialog->f424_dialogGetChoice(3, k0_DIALOG_SET_VIEWPORT, 0, k0_DIALOG_CHOICE_NONE);
 
+	// TODO: localization
 	_dialog->f427_dialogDraw(nullptr, "SAVING GAME . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
 
 	uint16 champHandObjWeight = 0;
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 0c00e20..d85ca40 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -241,6 +241,7 @@ void ObjectMan::f34_drawLeaderObjectName(Thing thing) {
 	if (L0007_i_IconIndex == k147_IconIndiceJunkChampionBones) {
 		Junk *junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing);
 		char champBonesName[16];
+		// TODO: localization
 		strcpy(champBonesName, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name);
 		strcat(champBonesName, _g352_objectNames[L0007_i_IconIndex]);
 		objectName = champBonesName;


Commit: e75c07d9a2a8d6e67d35d4699c2603abd81a4ca0
    https://github.com/scummvm/scummvm/commit/e75c07d9a2a8d6e67d35d4699c2603abd81a4ca0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix no food and water bar graphs

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/inventory.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 1eafa4d..6a4429a 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -1,6 +1,5 @@
 Bugs:
 	Display:
-		No food and water bar graphs
 		Spellcasting tabs are displayed inproperly, switching between them is possible tho
 		Cursor icons are drawn twice
 
@@ -21,8 +20,10 @@ Todo:
 	I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions
 
 Code stuff todo:
-	Complete stub methods
+	Complete stub methods(blitShrink, etc.)
+	Add scroller
 	Add localization
-	Save file f433_processCommand140_saveGame fails silently
+	Save file f433_processCommand140_saveGame fails silently, add error checking
+	Clean up f113_drawField
 	
 	
\ No newline at end of file
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 6f4e4e4..c1798e9 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -157,7 +157,7 @@ void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidt
 	box._y1 = y;
 	box._y2 = box._y1 + 6;
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_vm->_displayMan->D24_fillScreenBox(box, color);
+	_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, box, color, k112_byteWidthViewport, k136_heightViewport);
 }
 
 void InventoryMan::f344_drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {


Commit: f7ad6488e36a2895dd77b26c0e94671a0b50abb6
    https://github.com/scummvm/scummvm/commit/f7ad6488e36a2895dd77b26c0e94671a0b50abb6
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add localization

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/objectman.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 6a4429a..5509e69 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -22,7 +22,6 @@ Todo:
 Code stuff todo:
 	Complete stub methods(blitShrink, etc.)
 	Add scroller
-	Add localization
 	Save file f433_processCommand140_saveGame fails silently, add error checking
 	Clean up f113_drawField
 	
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 11371df..35b949b 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -40,7 +40,6 @@
 
 namespace DM {
 
-const char *g417_baseSkillName[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"}; // TODO: localization
 
 Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
 Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
@@ -96,6 +95,26 @@ uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
 
 Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
 
+const char *g417_baseSkillName[4];
+
+void ChampionMan::initConstants() {
+	{
+		static const char *g417_baseSkillName_EN_ANY[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"};
+		static const char *g417_baseSkillName_GR_GRE[4] = {"KAEMPFER", "NINJA", "PRIESTER", "MAGIER"};
+		static const char *g417_baseSkillName_FR_FRA[4] = {"GUERRIER", "NINJA", "PRETRE", "SORCIER"};
+
+		const char **g417_byLanguage;
+		switch (_vm->getGameLanguage()) { // localized
+		default:
+		case Common::EN_ANY: g417_byLanguage = g417_baseSkillName_EN_ANY; break;
+		case Common::GR_GRE: g417_byLanguage = g417_baseSkillName_GR_GRE; break;
+		case Common::FR_FRA: g417_byLanguage = g417_baseSkillName_FR_FRA; break;
+		}
+		for (int i = 0; i < 4; ++i)
+			g417_baseSkillName[i] = g417_byLanguage[i];
+	}
+}
+
 ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
 	for (uint16 i = 0; i < 4; ++i) {
 		_g409_championPendingDamage[i] = 0;
@@ -207,6 +226,7 @@ uint16 ChampionMan::M70_handSlotIndex(uint16 slotBoxIndex) {
 	return slotBoxIndex & 0x1;
 }
 
+
 Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) {
 	Common::String valToStr = Common::String::format("%d", val);
 	Common::String result;
@@ -967,10 +987,22 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex,
 			_vm->_textMan->f51_messageAreaPrintLineFeed();
 			Color curChampionColor = g46_ChampionColor[champIndex];
 			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, curChampion->_name);
-			// TODO: localization
-			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " JUST GAINED A ");
+
+			switch (_vm->getGameLanguage()) { // localized
+			default:
+			case Common::EN_ANY: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " JUST GAINED A "); break;
+			case Common::GR_GRE: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " HAT SOEBEN STUFE"); break;
+			case Common::FR_FRA: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " VIENT DE DEVENIR "); break;
+			}
+
 			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, g417_baseSkillName[baseSkillIndex]);
-			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " LEVEL!");
+
+			switch (_vm->getGameLanguage()) { // localized
+			default:
+			case Common::EN_ANY: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, "!"); break;
+			case Common::GR_GRE: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " LEVEL!"); break;
+			case Common::FR_FRA: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " ERREICHT!"); break;
+			}
 		}
 	}
 }
@@ -2149,17 +2181,30 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		else
 			loadColor = k13_ColorLightestGray;
 
-		// TODO: localization
-		_vm->_textMan->f52_printToViewport(104, 132, loadColor, "LOAD ");
+		switch (_vm->getGameLanguage()) { // localized
+		default:
+		case Common::EN_ANY: _vm->_textMan->f52_printToViewport(104, 132, loadColor, "LOAD "); break;
+		case Common::GR_GRE: _vm->_textMan->f52_printToViewport(104, 132, loadColor, "LAST "); break;
+		case Common::FR_FRA: _vm->_textMan->f52_printToViewport(104, 132, loadColor, "CHARGE "); break;
+		}
+
 		maxLoad = curChampion->_load / 10;
 		strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, true, 3).c_str());
-		strcat(_vm->_g353_stringBuildBuffer, ".");
+
+		switch (_vm->getGameLanguage()) { // localized
+		default:
+		case Common::EN_ANY: strcat(_vm->_g353_stringBuildBuffer, "."); break;
+		case Common::GR_GRE: strcat(_vm->_g353_stringBuildBuffer, ","); break;
+		case Common::FR_FRA: strcat(_vm->_g353_stringBuildBuffer, "KG,"); break;
+		}
+
 		maxLoad = curChampion->_load - (maxLoad * 10);
 		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, false, 1).c_str());
 		strcat(_vm->_g353_stringBuildBuffer, "/");
 		maxLoad = (f309_getMaximumLoad(curChampion) + 5) / 10;
 		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, true, 3).c_str());
-		strcat(_vm->_g353_stringBuildBuffer, " KG");
+		warning(false, "Possibly wrong localization");
+		strcat(_vm->_g353_stringBuildBuffer, " KG"); // this line
 		_vm->_textMan->f52_printToViewport(148, 132, loadColor, _vm->_g353_stringBuildBuffer);
 		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
@@ -2267,7 +2312,7 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		if (isInventoryChamp) {
 			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
-												_vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport, 
+												_vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport,
 												k12_ColorDarkestGray, _vm->_displayMan->getPixelHeight(nativeBitmapIndex), k136_heightViewport);
 		} else {
 			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index a94bdcc..7f726b6 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -453,7 +453,6 @@ public:
 #define k0x8000_maskUseSharpDefense 0x8000 // @ MASK0x8000_USE_SHARP_DEFENSE        
 
 #define k0x8000_mergeCycles 0x8000 // @ MASK0x8000_MERGE_CYCLES
-// TODO: localization
 extern const char *g417_baseSkillName[4]; // @ G0417_apc_BaseSkillNames
 
 #define k0_spellCastFailure 0 // @ C0_SPELL_CAST_FAILURE             
@@ -512,6 +511,9 @@ class ChampionMan {
 	uint16 M70_handSlotIndex(uint16 slotBoxIndex);// @ M70_HAND_SLOT_INDEX
 	int16 _g410_championPendingWounds[4]; // @ G0410_ai_ChampionPendingWounds
 	int16 _g409_championPendingDamage[4]; // @ G0409_ai_ChampionPendingDamage
+
+	void initConstants();
+
 public:
 
 	Champion _gK71_champions[4]; // @ K0071_as_Champions
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 13c8c63..e02f959 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -554,9 +554,35 @@ void DMEngine::f441_processEntrance() {
 }
 
 void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
-	// TODO: localization
-	static Box restartOuterBox = Box(103, 217, 145, 159);
-	static Box restartInnerBox = Box(105, 215, 147, 157);
+
+	static Box G0013_s_Graphic562_Box_Endgame_Restart_Outer_EN_ANY = {103, 217, 145, 159};
+	static Box G0014_s_Graphic562_Box_Endgame_Restart_Inner_EN_ANY = {105, 215, 147, 157};
+
+	static Box G0013_s_Graphic562_Box_Endgame_Restart_Outer_GR_GRE = {82, 238, 145, 159};
+	static Box G0014_s_Graphic562_Box_Endgame_Restart_Inner_GR_GRE = {84, 236, 147, 157};
+
+	static Box G0013_s_Graphic562_Box_Endgame_Restart_Outer_FR_FRA = {100, 220, 145, 159};
+	static Box G0014_s_Graphic562_Box_Endgame_Restart_Inner_FR_FRA = {102, 218, 147, 157};
+
+	Box restartOuterBox;
+	Box restartInnerBox;
+
+	switch (getGameLanguage()) { // localized
+	default:
+	case Common::EN_ANY:
+		restartOuterBox = G0013_s_Graphic562_Box_Endgame_Restart_Outer_EN_ANY;
+		restartInnerBox = G0014_s_Graphic562_Box_Endgame_Restart_Inner_EN_ANY;
+		break;
+	case Common::GR_GRE:
+		restartOuterBox = G0013_s_Graphic562_Box_Endgame_Restart_Outer_GR_GRE;
+		restartInnerBox = G0014_s_Graphic562_Box_Endgame_Restart_Inner_GR_GRE;
+		break;
+	case Common::FR_FRA:
+		restartOuterBox = G0013_s_Graphic562_Box_Endgame_Restart_Outer_FR_FRA;
+		restartInnerBox = G0014_s_Graphic562_Box_Endgame_Restart_Inner_FR_FRA;
+		break;
+	}
+
 	static Box theEndBox = Box(120, 199, 95, 108);
 	static Box championMirrorBox = Box(11, 74, 7, 49);
 	static Box championPortraitBox = Box(27, 58, 13, 41);
@@ -647,8 +673,14 @@ T0444017:
 			_displayMan->_g578_useByteBoxCoordinates = false;
 			_displayMan->D24_fillScreenBox(restartOuterBox, k12_ColorDarkestGray);
 			_displayMan->D24_fillScreenBox(restartInnerBox, k0_ColorBlack);
-			// TODO: localization
-			_textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RESTART THIS GAME");
+
+			switch (getGameLanguage()) { // localized
+			default:
+			case Common::EN_ANY: _textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RESTART THIS GAME"); break;
+			case Common::GR_GRE: _textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "DIESES SPIEL NEU STARTEN"); break;
+			case Common::FR_FRA: _textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RECOMMENCER CE JEU"); break;
+			}
+
 			curPalette[1] = D03_RGB_PINK;
 			curPalette[4] = D09_RGB_WHITE;
 			_eventMan->_g441_primaryMouseInput = g446_PrimaryMouseInput_RestartGame;
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index c2cb3cc..4a51f27 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -789,9 +789,22 @@ void EventManager::f380_processCommandQueue() {
 		_vm->_g301_gameTimeTicking = false;
 		_vm->_menuMan->f456_drawDisabledMenu();
 		_vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 112, 136);
-		// TODO: localization
-		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 81, 69, k4_ColorCyan, k0_ColorBlack,
-											 "GAME FROZEN", k136_heightViewport);
+
+		switch (_vm->getGameLanguage()) { // localized
+		default:
+		case Common::EN_ANY:
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 81, 69, k4_ColorCyan, k0_ColorBlack,
+												 "GAME FROZEN", k136_heightViewport);
+			break;
+		case Common::GR_GRE:
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 66, 69, k4_ColorCyan, k0_ColorBlack,
+												 "SPIEL ANGEHALTEN", k136_heightViewport);
+			break;
+		case Common::FR_FRA:
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 84, 69, k4_ColorCyan, k0_ColorBlack,
+												 "JEU BLOQUE", k136_heightViewport);
+			break;
+		}
 		_vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
 		primaryMouseInputBackup = _g441_primaryMouseInput;
 		secondaryMouseInputBackup = _g442_secondaryMouseInput;
@@ -1197,7 +1210,19 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 	_vm->_textMan->f51_messageAreaPrintLineFeed();
 	Color champColor = g46_ChampionColor[championIndex];
 	_vm->_textMan->f47_messageAreaPrintMessage(champColor, champ->_name);
-	_vm->_textMan->f47_messageAreaPrintMessage(champColor, (commandType == k160_CommandClickInPanelResurrect) ? " RESURRECTED." : " REINCARNATED."); // TODO: localization
+
+	switch (_vm->getGameLanguage()) { // localized
+	default:
+	case Common::EN_ANY:
+		_vm->_textMan->f47_messageAreaPrintMessage(champColor, (commandType == k160_CommandClickInPanelResurrect) ? " RESURRECTED." : " REINCARNATED.");
+		break;
+	case Common::GR_GRE:
+		_vm->_textMan->f47_messageAreaPrintMessage(champColor, (commandType == k160_CommandClickInPanelResurrect) ? " VOM TODE ERWECKT." : " REINKARNIERT.");
+		break;
+	case Common::FR_FRA:
+		_vm->_textMan->f47_messageAreaPrintMessage(champColor, (commandType == k160_CommandClickInPanelResurrect) ? " RESSUSCITE." : " REINCARNE.");
+		break;
+	}
 
 	invMan.f355_toggleInventory(k4_ChampionCloseInventory);
 	_vm->_menuMan->f457_drawEnabledMenus();
@@ -1293,7 +1318,19 @@ bool EventManager::f360_hasPendingClick(Common::Point& point, MouseButton button
 }
 
 void EventManager::f379_drawSleepScreen() {
-	_vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 112, 136); // TODO: localization
+	_vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 112, 136);
+	switch (_vm->getGameLanguage()) { // localized
+	default:
+	case Common::EN_ANY:
+		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 93, 69, k4_ColorCyan, k0_ColorBlack, "WAKE UP", k136_heightViewport);
+		break;
+	case Common::GR_GRE:
+		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 96, 69, k4_ColorCyan, k0_ColorBlack, "WECKEN", k136_heightViewport);
+		break;
+	case Common::FR_FRA:
+		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 72, 69, k4_ColorCyan, k0_ColorBlack, "REVEILLEZ-VOUS", k136_heightViewport);
+		break;
+	}
 }
 
 void EventManager::f357_discardAllInput() {
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index c1798e9..8a25ecd 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -44,23 +44,27 @@ Box g35_BoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food
 Box g36_BoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
 Box g37_BoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
 
-// TODO: localization
-char* G0428_apc_SkillLevelNames[15] = { // @ G0428_apc_SkillLevelNames
-	"NEOPHYTE",
-	"NOVICE",
-	"APPRENTICE",
-	"JOURNEYMAN",
-	"CRAFTSMAN",
-	"ARTISAN",
-	"ADEPT",
-	"EXPERT",
-	"` MASTER",
-	"a MASTER",
-	"b MASTER",
-	"c MASTER",
-	"d MASTER",
-	"e MASTER",
-	"ARCHMASTER"};
+char* G0428_apc_SkillLevelNames[15];
+
+void InventoryMan::initConstants() {
+	{
+		static const char* G0428_apc_SkillLevelNames_EN_ANY[15] = {"NEOPHYTE", "NOVICE", "APPRENTICE", "JOURNEYMAN", "CRAFTSMAN",
+			"ARTISAN", "ADEPT", "EXPERT", "` MASTER", "a MASTER","b MASTER", "c MASTER", "d MASTER", "e MASTER", "ARCHMASTER"};
+		static const char* G0428_apc_SkillLevelNames_GR_GRE[15] = {"ANFAENGER", "NEULING", "LEHRLING", "ARBEITER", "GESELLE", "HANDWERKR", "FACHMANN",
+			"EXPERTE", "` MEISTER", "a MEISTER", "b MEISTER", "c MEISTER", "d MEISTER", "e MEISTER", "ERZMEISTR"};
+		static const char* G0428_apc_SkillLevelNames_FR_FRA[15] = { "NEOPHYTE", "NOVICE", "APPRENTI", "COMPAGNON", "ARTISAN", "PATRON",
+			"ADEPTE", "EXPERT", "MAITRE '", "MAITRE a", "MAITRE b", "MAITRE c", "MAITRE d", "MAITRE e", "SUR-MAITRE"};
+		const char **g428_byLanguage;
+		switch (_vm->getGameLanguage()) { // localized
+		default:
+		case Common::EN_ANY: g428_byLanguage = G0428_apc_SkillLevelNames_EN_ANY; break;
+		case Common::GR_GRE: g428_byLanguage = G0428_apc_SkillLevelNames_GR_GRE; break;
+		case Common::FR_FRA: g428_byLanguage = G0428_apc_SkillLevelNames_FR_FRA; break;
+		}
+		for (int i = 0; i < 15; ++i)
+			g417_baseSkillName[i] = g428_byLanguage[i];
+	}
+}
 
 InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
 	_g432_inventoryChampionOrdinal = 0;
@@ -124,8 +128,23 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	if (_vm->_championMan->_g299_candidateChampionOrdinal) {
 		_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
 	}
-	_vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "HEALTH"); // TODO: localization
-	_vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
+
+	switch (_vm->getGameLanguage()) { // localized
+	default:
+	case Common::EN_ANY:
+		_vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "HEALTH");
+		_vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
+		break;
+	case Common::GR_GRE:
+		_vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "GESUND");
+		_vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "KRAFT");
+		break;
+	case Common::FR_FRA:
+		_vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "SANTE");
+		_vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "VIGUEUR");
+		break;
+	}
+
 	_vm->_textMan->f52_printToViewport(5, 132, k13_ColorLightestGray, "MANA");
 	for (AL1102_ui_SlotIndex = k0_ChampionSlotReadyHand; AL1102_ui_SlotIndex < k30_ChampionSlotChest_1; AL1102_ui_SlotIndex++) {
 		_vm->_championMan->f291_drawSlot(championIndex, AL1102_ui_SlotIndex);
@@ -180,13 +199,24 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
 	Champion &champ = _vm->_championMan->_gK71_champions[_g432_inventoryChampionOrdinal];
 	f334_closeChest();
 	DisplayMan &dispMan = *_vm->_displayMan;
-	// TODO: localization
-	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice),
-							   g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
-	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k30_FoodLabelIndice),
-							   g35_BoxFood, k24_byteWidth, k12_ColorDarkestGray, 9);
-	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k31_WaterLabelIndice),
-							   g36_BoxWater, k24_byteWidth, k12_ColorDarkestGray, 9);
+	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
+
+	switch (_vm->getGameLanguage()) { // localized
+	default:
+	case Common::EN_ANY:
+		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k30_FoodLabelIndice), g35_BoxFood, k24_byteWidth, k12_ColorDarkestGray, 9);
+		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k31_WaterLabelIndice), g36_BoxWater, k24_byteWidth, k12_ColorDarkestGray, 9);
+		break;
+	case Common::GR_GRE:
+		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k30_FoodLabelIndice), g35_BoxFood, k32_byteWidth, k12_ColorDarkestGray, 9);
+		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k31_WaterLabelIndice), g36_BoxWater, k32_byteWidth, k12_ColorDarkestGray, 9);
+		break;
+	case Common::FR_FRA:
+		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k30_FoodLabelIndice), g35_BoxFood, k48_byteWidth, k12_ColorDarkestGray, 9);
+		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k31_WaterLabelIndice), g36_BoxWater, k24_byteWidth, k12_ColorDarkestGray, 9);
+		break;
+	}
+
 	if (champ._poisonEventCount) {
 		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k32_PoisionedLabelIndice),
 								   g37_BoxPoisoned, k48_byteWidth, k12_ColorDarkestGray, 15);
@@ -386,7 +416,14 @@ void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, in
 			if (identicalBitCount-- > 2) {
 				strcat(destString, ", ");
 			} else if (identicalBitCount == 1) {
-				strcat(destString, " AND "); // TODO: localization
+
+				switch (_vm->getGameLanguage()) { // localized
+				default:
+				case Common::EN_ANY: strcat(destString, " AND "); break;
+				case Common::GR_GRE: strcat(destString, " UND "); break;
+				case Common::FR_FRA: strcat(destString, " ET "); break;
+				}
+
 			}
 		}
 	}
@@ -454,7 +491,6 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 	TextMan &textMan = *_vm->_textMan;
 
 	if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) {
-		warning(false, "BUG0_48 The contents of a chest are reorganized when an object with a statistic modifier is placed or removed on a champion");
 		f334_closeChest();
 	}
 
@@ -475,9 +511,20 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		char *descString = nullptr;
 		char str[40];
 		if (iconIndex == k147_IconIndiceJunkChampionBones) {
-			strcpy(str, champMan._gK71_champions[((Junk *)rawThingPtr)->getChargeCount()]._name);  // TODO: localization
-			strcat(str, " "); // TODO: localization
-			strcat(str, objMan._g352_objectNames[iconIndex]);  // TODO: localization
+			switch (_vm->getGameLanguage()) { // localized
+			default:
+			case Common::EN_ANY:
+			case Common::GR_GRE: // german and english versions are the same
+				strcpy(str, champMan._gK71_champions[((Junk *)rawThingPtr)->getChargeCount()]._name);
+				strcat(str, " ");
+				strcat(str, objMan._g352_objectNames[iconIndex]);
+				break;
+			case Common::FR_FRA:
+				strcat(str, objMan._g352_objectNames[iconIndex]);
+				strcat(str, " ");
+				strcpy(str, champMan._gK71_champions[((Junk *)rawThingPtr)->getChargeCount()]._name);
+				break;
+			}
 
 			descString = str;
 		} else if ((thingType == k8_PotionThingType)
@@ -495,7 +542,6 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		textMan.f52_printToViewport(134, 68, k13_ColorLightestGray, descString);
 		f332_drawIconToViewport(iconIndex, 111, 59);
 
-		char *attribString[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"}; // TODO: localization
 
 		_g422_objDescTextYpos = 87;
 
@@ -509,7 +555,13 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit)
 				&& (iconIndex <= k7_IconIndiceWeaponTorchLit)
 				&& (weapon->getChargeCount() == 0)) {
-				f335_drawPanelObjectDescriptionString("(BURNT OUT)"); // TODO: localization
+
+				switch (_vm->getGameLanguage()) { // localized
+				default:
+				case Common::EN_ANY: f335_drawPanelObjectDescriptionString("(BURNT OUT)"); break;
+				case Common::GR_GRE: f335_drawPanelObjectDescriptionString("(AUSGEBRANNT)"); break;
+				case Common::FR_FRA: f335_drawPanelObjectDescriptionString("(CONSUME)"); break;
+				}
 			}
 			break;
 		}
@@ -529,26 +581,39 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			Junk *junk = (Junk *)rawThingPtr;
 			if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
 				potentialAttribMask = 0;
-				switch (junk->getChargeCount()) {
-				case 0:
-					descString = "(EMPTY)"; // TODO: localization
-					break;
-				case 1:
-					descString = "(ALMOST EMPTY)"; // TODO: localization
-					break;
-				case 2:
-					descString = "(ALMOST FULL)"; // TODO: localization
-					break;
-				case 3:
-					descString = "(FULL)"; // TODO: localization
-					break;
+				char *descString_EN_ANY[4] = {"(EMPTY)", "(ALMOST EMPTY)", "(ALMOST FULL)", "(FULL)"};
+				char *descString_GE_GRE[4] = {"(LEER)", "(FAST LEER)", "(FAST VOLL)", "(VOLL)"};
+				char *descString_FR_FRA[4] = {"(VIDE)", "(PRESQUE VIDE)", "(PRESQUE PLEINE)", "(PLEINE)"};
+
+				switch (_vm->getGameLanguage()) { // localized
+				default:
+				case Common::EN_ANY: descString = descString_EN_ANY[junk->getChargeCount()]; break;
+				case Common::GR_GRE: descString = descString_GE_GRE[junk->getChargeCount()]; break;
+				case Common::FR_FRA: descString = descString_FR_FRA[junk->getChargeCount()]; break;
 				}
+
 				f335_drawPanelObjectDescriptionString(descString);
 			} else if ((iconIndex >= k0_IconIndiceJunkCompassNorth) && (iconIndex <= k3_IconIndiceJunkCompassWest)) {
 				potentialAttribMask = 0;
-				strcpy(str, "PARTY FACING "); // TODO: localization
-				static char* directionName[4] = {"NORTH", "EAST", "SOUTH", "WEST"}; // G0430_apc_DirectionNames // TODO: localization
-				strcat(str, directionName[iconIndex]);
+
+				switch (_vm->getGameLanguage()) { // localized
+				default:
+				case Common::EN_ANY: strcpy(str, "PARTY FACING "); break;
+				case Common::GR_GRE: strcpy(str, "GRUPPE BLICKT NACH "); break;
+				case Common::FR_FRA: strcpy(str, "GROUPE FACE "); break;
+				}
+
+
+				static char* directionName_EN_ANY[4] = {"NORTH", "EAST", "SOUTH", "WEST"};
+				static char* directionName_GR_GRE[4] = {"NORDEN", "OSTEN", "SUEDEN", "WESTEN"};
+				static char* directionName_FR_FRA[4] = {"AU NORD", "A L'EST", "AU SUD", "A L'OUEST"};
+				switch (_vm->getGameLanguage()) { // localized
+				default:
+				case Common::EN_ANY: strcat(str, directionName_EN_ANY[iconIndex]); break;
+				case Common::GR_GRE: strcat(str, directionName_FR_FRA[iconIndex]); break;
+				case Common::FR_FRA: strcat(str, directionName_GR_GRE[iconIndex]); break;
+				}
+
 				f335_drawPanelObjectDescriptionString(str);
 			} else {
 				potentialAttribMask = k0x0001_DescriptionMaskConsumable;
@@ -559,21 +624,49 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		} // end of switch 
 
 		if (potentialAttribMask) {
+			char *attribString_EN_ANY[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"};
+			char *attribString_GR_GRE[4] = {"ESSBAR", "VERGIFTET", "DEFEKT", "VERFLUCHT"};
+			char *attribString_FR_FRA[4] = {"COMESTIBLE", "EMPOISONNE", "BRISE", "MAUDIT"};
+			char **attribString = nullptr;
+
+			switch (_vm->getGameLanguage()) { // localized
+			default:
+			case Common::EN_ANY: attribString = attribString_EN_ANY; break;
+			case Common::GR_GRE: attribString = attribString_GR_GRE; break;
+			case Common::FR_FRA: attribString = attribString_FR_FRA; break;
+			}
+
 			f336_buildObjectAttributeString(potentialAttribMask, actualAttribMask, attribString, str, "(", ")");
 			f335_drawPanelObjectDescriptionString(str);
 		}
 
-		strcpy(str, "WEIGHS "); // TODO: localization
+		switch (_vm->getGameLanguage()) { // localized
+		default:
+		case Common::EN_ANY: strcpy(str, "WEIGHS "); break;
+		case Common::GR_GRE: strcpy(str, "WIEGT "); break;
+		case Common::FR_FRA: strcpy(str, "PESE "); break;
+		}
+
 
 		uint16 weight = dunMan.f140_getObjectWeight(thingToDraw);
 		strcat(str, champMan.f288_getStringFromInteger(weight / 10, false, 3).c_str());
 
-		strcat(str, "."); // TODO: localization
+		switch (_vm->getGameLanguage()) { // localized
+		default:
+		case Common::EN_ANY: strcat(str, "."); break;
+		case Common::GR_GRE: strcat(str, ","); break;
+		case Common::FR_FRA: strcat(str, "KG,"); break;
+		}
 
 		weight -= (weight / 10) * 10;
 		strcat(str, champMan.f288_getStringFromInteger(weight, false, 1).c_str());
 
-		strcat(str, " KG."); // TODO: localization
+		switch (_vm->getGameLanguage()) { // localized
+		default:
+		case Common::EN_ANY:
+		case Common::GR_GRE: strcat(str, " KG."); break;
+		case Common::FR_FRA: strcat(str, "."); break;
+		}
 
 		f335_drawPanelObjectDescriptionString(str);
 	}
@@ -696,9 +789,17 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 	int16 L1095_i_StatisticColor;
 	uint16 L1096_ui_StatisticMaximumValue;
 	char L1097_ac_String[20];
-	// TODO: localization
-	static char* G0431_apc_StatisticNames[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"};
 
+	static char* G0431_apc_StatisticNames_EN_ANY[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"};
+	static char* G0431_apc_StatisticNames_GR_GRE[7] = {"L", "STAERKE", "FLINKHEIT", "WEISHEIT", "VITALITAET", "ANTI-MAGIE", "ANTI-FEUER"};
+	static char* G0431_apc_StatisticNames_FR_FRA[7] = {"L", "FORCE", "DEXTERITE", "SAGESSE", "VITALITE", "ANTI-MAGIE", "ANTI-FEU"};
+	char **G0431_apc_StatisticNames;
+	switch (_vm->getGameLanguage()) { // localized
+	default:
+	case Common::EN_ANY: G0431_apc_StatisticNames = G0431_apc_StatisticNames_EN_ANY; break;
+	case Common::GR_GRE: G0431_apc_StatisticNames = G0431_apc_StatisticNames_GR_GRE; break;
+	case Common::FR_FRA: G0431_apc_StatisticNames = G0431_apc_StatisticNames_FR_FRA; break;
+	}
 
 	f334_closeChest();
 	L1094_ps_Champion = &_vm->_championMan->_gK71_champions[L1093_ui_ChampionIndex = _vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal)];
@@ -708,10 +809,21 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 		AL1092_i_SkillLevel = MIN((uint16)16, _vm->_championMan->f303_getSkillLevel(L1093_ui_ChampionIndex, AL1090_ui_SkillIndex | k0x8000_IgnoreTemporaryExperience));
 		if (AL1092_i_SkillLevel == 1)
 			continue;
-		// TODO: localization
-		strcpy(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]);
-		strcat(L1097_ac_String, " ");
-		strcat(L1097_ac_String, g417_baseSkillName[AL1090_ui_SkillIndex]);
+
+		switch (_vm->getGameLanguage()) { // localized
+		default:
+		case Common::EN_ANY:
+		case Common::GR_GRE: // english and german versions are the same
+			strcpy(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]);
+			strcat(L1097_ac_String, " ");
+			strcat(L1097_ac_String, g417_baseSkillName[AL1090_ui_SkillIndex]);
+			break;
+		case Common::FR_FRA:
+			strcat(L1097_ac_String, g417_baseSkillName[AL1090_ui_SkillIndex]);
+			strcat(L1097_ac_String, " ");
+			strcpy(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]);
+			break;
+		}
 		_vm->_textMan->f52_printToViewport(108, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String);
 		L1091_i_Y += 7;
 	}
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 7a35439..0af1661 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -47,10 +47,13 @@ enum PanelContent {
 	k5_PanelContentResurrectReincarnate = 5 // @ C05_PANEL_RESURRECT_REINCARNATE
 };
 
-extern char* G0428_apc_SkillLevelNames[15];
+extern char* G0428_apc_SkillLevelNames[15]; // @ G0428_apc_SkillLevelNames  
 
 class InventoryMan {
 	DMEngine *_vm;
+
+	void initConstants();
+
 public:
 	explicit InventoryMan(DMEngine *vm);
 
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index d6e37b3..7eb29d6 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -155,7 +155,20 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		_g526_dungeonId = dmSaveHeader._dungeonId;
 
 		_g524_restartGameAllowed = true;
-		_dialog->f427_dialogDraw(nullptr, "LOADING GAME . . .", nullptr, nullptr, nullptr, nullptr, true, true, true); // TODO: localization
+
+		switch (getGameLanguage()) { // localized
+		default:
+		case Common::EN_ANY:
+			_dialog->f427_dialogDraw(nullptr, "LOADING GAME . . .", nullptr, nullptr, nullptr, nullptr, true, true, true);
+			break;
+		case Common::GR_GRE:
+			_dialog->f427_dialogDraw(nullptr, "SPIEL WIRD GELADEN . . .", nullptr, nullptr, nullptr, nullptr, true, true, true);
+			break;
+		case Common::FR_FRA:
+			_dialog->f427_dialogDraw(nullptr, "CHARGEMENT DU JEU . . .", nullptr, nullptr, nullptr, nullptr, true, true, true);
+			break;
+		}
+
 	}
 	_championMan->_g303_partyDead = false;
 
@@ -169,12 +182,32 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 	_menuMan->f456_drawDisabledMenu();
 	_eventMan->f78_showMouse();
 
-	// TODO: localization
-	_dialog->f427_dialogDraw(message, nullptr, "SAVE AND PLAY", "SAVE AND QUIT", "CANCEL", nullptr, false, false, false);
+	switch (getGameLanguage()) { // localized
+	default:
+	case Common::EN_ANY:
+		_dialog->f427_dialogDraw(message, nullptr, "SAVE AND PLAY", "SAVE AND QUIT", "CANCEL", nullptr, false, false, false);
+		break;
+	case Common::GR_GRE:
+		_dialog->f427_dialogDraw(message, nullptr, "SICHERN/SPIEL", "SICHERN/ENDEN", "WIDERRUFEN", nullptr, false, false, false);
+		break;
+	case Common::FR_FRA:
+		_dialog->f427_dialogDraw(message, nullptr, "GARDER/JOUER", "GARDER/SORTIR", "ANNULLER", nullptr, false, false, false);
+		break;
+	}
 	int16 saveAndPlayChoice = _dialog->f424_dialogGetChoice(3, k0_DIALOG_SET_VIEWPORT, 0, k0_DIALOG_CHOICE_NONE);
 
-	// TODO: localization
-	_dialog->f427_dialogDraw(nullptr, "SAVING GAME . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
+	switch (getGameLanguage()) { // localized
+	default:
+	case Common::EN_ANY:
+		_dialog->f427_dialogDraw(nullptr, "SAVING GAME . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
+		break;
+	case Common::GR_GRE:
+		_dialog->f427_dialogDraw(nullptr, "SPIEL WIRD GESICHERT . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
+		break;
+	case Common::FR_FRA:
+		_dialog->f427_dialogDraw(nullptr, "UN MOMENT A SAUVEGARDER DU JEU...", nullptr, nullptr, nullptr, nullptr, false, false, false);
+		break;
+	}
 
 	uint16 champHandObjWeight = 0;
 	if (!_championMan->_g415_leaderEmptyHanded) {
@@ -266,7 +299,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 		tmp = ((map._difficulty & 0xF) << 12) | ((map._creatureTypeCount & 0xF) << 4) | (map._doorOrnCount & 0xF);
 		file->writeUint16BE(tmp);
 
-		tmp = ((map._doorSet1 & 0xF) << 12) | ((map._doorSet0 & 0xF) << 8) 
+		tmp = ((map._doorSet1 & 0xF) << 12) | ((map._doorSet0 & 0xF) << 8)
 			| ((map._wallSet & 0xF) << 4) | (map._floorSet & 0xF);
 		file->writeUint16BE(tmp);
 	}
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 5fa9eeb..4ccc5f1 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -683,18 +683,38 @@ void MenuMan::f410_menusPrintSpellFailureMessage(Champion* champ, uint16 failure
 	}
 	_vm->_textMan->f51_messageAreaPrintLineFeed();
 	_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, champ->_name);
+
+	char *messages_EN_ANY[4] = {" NEEDS MORE PRACTICE WITH THIS ", " SPELL.", " MUMBLES A MEANINGLESS SPELL."," NEEDS AN EMPTY FLASK IN HAND FOR POTION."};
+	char *messages_GR_GRE[4] = {" BRAUCHT MEHR UEBUNG MIT DIESEM ", " ZAUBERSPRUCH.",
+		" MURMELT EINEN SINNLOSEN ZAUBERSPRUCH.", " MUSS FUER DEN TRANK EINE LEERE FLASCHE BEREITHALTEN."};
+	char *messages_FR_FRA[5] = {" DOIT PRATIQUER DAVANTAGE SON ", "ENVOUTEMENT.", " MARMONNE UNE CONJURATION IMCOMPREHENSIBLE.",
+		" DOIT AVOIR UN FLACON VIDE EN MAIN POUR LA POTION.", "EXORCISME."};
+	char **messages;
+	switch (_vm->getGameLanguage()) { // localized
+	default:
+	case Common::EN_ANY:
+		messages = messages_EN_ANY; break;
+	case Common::GR_GRE:
+		messages = messages_GR_GRE; break;
+	case Common::FR_FRA:
+		messages = messages_FR_FRA; break;
+	}
+
 	switch (failureType) {
 	case k0_failureNeedsMorePractice:
-		// TODO: localization
-		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, " NEEDS MORE PRACTICE WITH THIS ");
+		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, messages[0]);
 		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, g417_baseSkillName[skillIndex]);
-		L1264_pc_Message = " SPELL.";
+		if (_vm->getGameLanguage() != Common::FR_FRA || skillIndex == k3_ChampionSkillWizard) {
+			L1264_pc_Message = messages[1];
+		} else {
+			L1264_pc_Message = messages[4];
+		}
 		break;
 	case k1_failureMeaninglessSpell:
-		L1264_pc_Message = " MUMBLES A MEANINGLESS SPELL."; // TODO: localization
+		L1264_pc_Message = messages[2];
 		break;
 	case k10_failureNeedsFlaskInHand:
-		L1264_pc_Message = " NEEDS AN EMPTY FLASK IN HAND FOR POTION."; // TODO: localization
+		L1264_pc_Message = messages[3];
 		break;
 	}
 	_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, L1264_pc_Message);
@@ -1162,14 +1182,24 @@ T0407032:
 			_vm->_championMan->f326_championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->f303_getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy);
 		}
 		break;
-	case k5_ChampionActionFlip:
-		// TODO: localization
+	case k5_ChampionActionFlip: {
+		char *messages_EN_ANY[2] = {"IT COMES UP HEADS.", "IT COMES UP TAILS."};
+		char *messages_GR_GRE[2] = {"DIE KOPFSEITE IST OBEN.", "DIE ZAHL IST OBEN."};
+		char *messages_FR_FRA[2] = {"C'EST FACE.", "C'EST PILE."};
+		char **message;
+		switch (_vm->getGameLanguage()) { // localized
+		default:
+		case Common::EN_ANY: message = messages_EN_ANY; break;
+		case Common::GR_GRE: message = messages_GR_GRE; break;
+		case Common::FR_FRA: message = messages_FR_FRA; break;
+		}
 		if (_vm->getRandomNumber(2)) {
-			f381_printMessageAfterReplacements("IT COMES UP HEADS.");
+			f381_printMessageAfterReplacements(message[0]);
 		} else {
-			f381_printMessageAfterReplacements("IT COMES UP TAILS.");
+			f381_printMessageAfterReplacements(message[1]);
 		}
-		break;
+	}
+								break;
 	case k33_ChampionActionSpellshield:
 	case k34_ChampionActionFireshield:
 		if (!f403_isPartySpellOrFireShieldSuccessful(L1247_ps_Champion, actionIndex == k33_ChampionActionSpellshield, 280, true)) {
@@ -1682,12 +1712,27 @@ void MenuMan::f385_drawActionDamage(int16 damage) {
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	_vm->_displayMan->D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack);
 	if (damage < 0) {
+		static char *messages_EN_ANY[2] = {"CAN'T REACH", "NEED AMMO"};
+		static char *messages_GR_GRE[2] = {"ZU WEIT WEG", "MEHR MUNITION"};
+		static char *messages_FR_FRA[2] = {"TROP LOIN", "SANS MUNITION"};
+		static int16  pos_EN_ANY[2] = {242, 248};
+		static int16  pos_GR_GRE[2] = {242, 236};
+		static int16  pos_FR_FRA[2] = {248, 236};
+		char **message;
+		int16 *pos;
+		switch (_vm->getGameLanguage()) { // localized
+		default:
+		case Common::EN_ANY: message = messages_EN_ANY; pos = pos_EN_ANY;  break;
+		case Common::GR_GRE: message = messages_GR_GRE; pos = pos_GR_GRE; break;
+		case Common::FR_FRA: message = messages_FR_FRA; pos = pos_FR_FRA; break;
+		}
+
 		if (damage == kM1_damageCantReach) {
-			AL1176_i_X = 242;
-			AL1178_puc_String = (unsigned char*)"CAN'T REACH"; // TODO: localization
+			AL1176_i_X = pos[0];
+			AL1178_puc_String = (byte*)message[0];
 		} else {
-			AL1176_i_X = 248;
-			AL1178_puc_String = (unsigned char*)"NEED AMMO"; // TODO: localization
+			AL1176_i_X = pos[1];
+			AL1178_puc_String = (byte*)message[1];
 		}
 		_vm->_textMan->f53_printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, (char *)AL1178_puc_String);
 	} else {
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index d85ca40..56ecc3a 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -241,9 +241,20 @@ void ObjectMan::f34_drawLeaderObjectName(Thing thing) {
 	if (L0007_i_IconIndex == k147_IconIndiceJunkChampionBones) {
 		Junk *junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing);
 		char champBonesName[16];
-		// TODO: localization
-		strcpy(champBonesName, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name);
-		strcat(champBonesName, _g352_objectNames[L0007_i_IconIndex]);
+
+		switch (_vm->getGameLanguage()) { // localized
+		default:
+		case Common::EN_ANY:
+		case Common::GR_GRE: // english and german version are the same
+			strcpy(champBonesName, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name);
+			strcat(champBonesName, _g352_objectNames[L0007_i_IconIndex]);
+			break;
+		case Common::FR_FRA:
+			strcat(champBonesName, _g352_objectNames[L0007_i_IconIndex]);
+			strcpy(champBonesName, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name);
+			break;
+		}
+
 		objectName = champBonesName;
 	} else {
 		objectName = _g352_objectNames[L0007_i_IconIndex];


Commit: 57f65753880426a8ac2c632098b50b7f3aa04c43
    https://github.com/scummvm/scummvm/commit/57f65753880426a8ac2c632098b50b7f3aa04c43
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix compilation, some renaming

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index e02f959..14e0c37 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -554,15 +554,14 @@ void DMEngine::f441_processEntrance() {
 }
 
 void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
+	static Box boxEndgameRestartOuterEN(103, 217, 145, 159);
+	static Box boxEndgameRestartInnerEN(105, 215, 147, 157);
 
-	static Box G0013_s_Graphic562_Box_Endgame_Restart_Outer_EN_ANY = {103, 217, 145, 159};
-	static Box G0014_s_Graphic562_Box_Endgame_Restart_Inner_EN_ANY = {105, 215, 147, 157};
+	static Box boxEndgameRestartOuterDE(82, 238, 145, 159);
+	static Box boxEndgameRestartInnerDE(84, 236, 147, 157);
 
-	static Box G0013_s_Graphic562_Box_Endgame_Restart_Outer_GR_GRE = {82, 238, 145, 159};
-	static Box G0014_s_Graphic562_Box_Endgame_Restart_Inner_GR_GRE = {84, 236, 147, 157};
-
-	static Box G0013_s_Graphic562_Box_Endgame_Restart_Outer_FR_FRA = {100, 220, 145, 159};
-	static Box G0014_s_Graphic562_Box_Endgame_Restart_Inner_FR_FRA = {102, 218, 147, 157};
+	static Box boxEndgameRestartOuterFR(100, 220, 145, 159);
+	static Box boxEndgameRestartInnerFR(102, 218, 147, 157);
 
 	Box restartOuterBox;
 	Box restartInnerBox;
@@ -570,22 +569,22 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 	switch (getGameLanguage()) { // localized
 	default:
 	case Common::EN_ANY:
-		restartOuterBox = G0013_s_Graphic562_Box_Endgame_Restart_Outer_EN_ANY;
-		restartInnerBox = G0014_s_Graphic562_Box_Endgame_Restart_Inner_EN_ANY;
+		restartOuterBox = boxEndgameRestartOuterEN;
+		restartInnerBox = boxEndgameRestartInnerEN;
 		break;
 	case Common::GR_GRE:
-		restartOuterBox = G0013_s_Graphic562_Box_Endgame_Restart_Outer_GR_GRE;
-		restartInnerBox = G0014_s_Graphic562_Box_Endgame_Restart_Inner_GR_GRE;
+		restartOuterBox = boxEndgameRestartOuterDE;
+		restartInnerBox = boxEndgameRestartInnerDE;
 		break;
 	case Common::FR_FRA:
-		restartOuterBox = G0013_s_Graphic562_Box_Endgame_Restart_Outer_FR_FRA;
-		restartInnerBox = G0014_s_Graphic562_Box_Endgame_Restart_Inner_FR_FRA;
+		restartOuterBox = boxEndgameRestartOuterFR;
+		restartInnerBox = boxEndgameRestartInnerFR;
 		break;
 	}
 
-	static Box theEndBox = Box(120, 199, 95, 108);
-	static Box championMirrorBox = Box(11, 74, 7, 49);
-	static Box championPortraitBox = Box(27, 58, 13, 41);
+	static Box theEndBox(120, 199, 95, 108);
+	static Box championMirrorBox(11, 74, 7, 49);
+	static Box championPortraitBox(27, 58, 13, 41);
 
 	bool waitBeforeDrawingRestart = true;
 


Commit: 9a174928d27aca7d672cf68a533465a63429bfd3
    https://github.com/scummvm/scummvm/commit/9a174928d27aca7d672cf68a533465a63429bfd3
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some small refactoring in DisplayMan

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 3c4bfac..a8c0c95 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -564,9 +564,8 @@ void DisplayMan::f460_initializeGraphicData() {
 				if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k3_ProjectileAspectHasNone) {
 					_g639_derivedBitmapByteCount[derivedBitmapIndex + 6] = bitmapByteCount;
 
-					if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k2_ProjectileAspectHasRotation) {
+					if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k2_ProjectileAspectHasRotation)
 						_g639_derivedBitmapByteCount[derivedBitmapIndex + 12] = bitmapByteCount;
-					}
 				}
 			}
 		}
@@ -582,9 +581,8 @@ void DisplayMan::f460_initializeGraphicData() {
 		for (int16 scale = 4; scale < 32; scale += 2)
 			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(expAsp->_byteWidth, expAsp->_height, scale);
 
-		if (expAspIndex == k3_ExplosionAspectSmoke) {
+		if (expAspIndex == k3_ExplosionAspectSmoke)
 			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = expAsp->_byteWidth * expAsp->_height;
-		}
 	}
 
 	derivedBitmapIndex = k495_DerivedBitmapFirstCreature;
@@ -595,13 +593,11 @@ void DisplayMan::f460_initializeGraphicData() {
 		int16 creatureGraphicInfo = g243_CreatureInfo[creatureIndex]._graphicInfo;
 		creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex;
 
-		int16 creatureFrontBitmapD3PixelCount;
-		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount
-			= f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
+		int16 creatureFrontBitmapD3PixelCount = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
+		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount;
 
-		int16 creatureFrontBitmapD2PixelCount;
-		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount
-			= f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
+		int16 creatureFrontBitmapD2PixelCount = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
+		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount;
 
 		if (getFlag(creatureGraphicInfo, k0x0008_CreatureInfoGraphicMaskSide)) {
 			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k16_Scale_D3);
@@ -618,8 +614,8 @@ void DisplayMan::f460_initializeGraphicData() {
 			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k20_Scale_D2);
 		}
 
-		int16 additionalFronGraphicCount;
-		if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, k0x0003_CreatureInfoGraphicMaskAdditional)) {
+		int16 additionalFronGraphicCount = getFlag(creatureGraphicInfo, k0x0003_CreatureInfoGraphicMaskAdditional);
+		if (additionalFronGraphicCount) {
 			do {
 				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront;
 				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
@@ -809,7 +805,7 @@ void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box,
 								   uint16 destByteWidth, Color transparent, int16 srcHeight, int16 destHight) {
 	uint16 srcWidth = srcByteWidth * 2;
 	uint16 destWidth = destByteWidth * 2;
-	for (uint16 y = 0; y < box._y2 + 1 - box._y1; ++y) // + 1 for inclusive boundaries
+	for (uint16 y = 0; y < box._y2 + 1 - box._y1; ++y) { // + 1 for inclusive boundaries
 		for (uint16 x = 0; x < box._x2 + 1 - box._x1; ++x) { // + 1 for inclusive boundaries
 			if (srcX + x < srcWidth && y + srcY < srcHeight
 				&& box._x1 + x < destWidth && y + box._y1 < destHight) {
@@ -818,6 +814,7 @@ void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box,
 					destBitmap[destWidth * (y + box._y1) + box._x1 + x] = srcPixel;
 			}
 		}
+	}
 }
 
 void DisplayMan::D24_fillScreenBox(Box &box, Color color) {
@@ -835,7 +832,7 @@ void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte*
 													int16 lastUnitIndex, int16 firstUnitIndex, int16 destByteWidth, Color transparent,
 													int16 xPos, int16 yPos, int16 destHeight, int16 height2) {
 		 // make sure to take care of inclusive boundaries, color can have 0x8000 flag to not use mask
-
+	warning(false, "STUB: f133_blitBoxFilledWithMaskedBitmap");
 }
 
 
@@ -843,12 +840,8 @@ void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte*
 void DisplayMan::f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height) {
 	uint16 width = byteWidth * 2;
 	for (uint16 y = 0; y < height; ++y) {
-		for (uint16 x = 0; x < width / 2; ++x) {
-			byte tmp;
-			tmp = bitmap[y*width + x];
-			bitmap[y*width + x] = bitmap[y*width + width - 1 - x];
-			bitmap[y*width + width - 1 - x] = tmp;
-		}
+		for (uint16 x = 0; x < width / 2; ++x)
+			SWAP<byte>(bitmap[y * width + x], bitmap[y * width + width - 1 - x]);
 	}
 }
 
@@ -873,11 +866,11 @@ byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale
 	int16 height = M78_getScaledDimension(explAsp->_height, scale);
 	byte *bitmap;
 	int16 derBitmapIndex = (explosionAspIndex * 14) + scale / 2 + k438_DerivedBitmapFirstExplosion - 2;
-	if ((scale == 32) && (explosionAspIndex != k3_ExplosionAspectSmoke)) {
+	if ((scale == 32) && (explosionAspIndex != k3_ExplosionAspectSmoke))
 		bitmap = f489_getNativeBitmapOrGraphic(explosionAspIndex + k348_FirstExplosionGraphicIndice);
-	} else if (f491_isDerivedBitmapInCache(derBitmapIndex)) {
+	else if (f491_isDerivedBitmapInCache(derBitmapIndex))
 		bitmap = f492_getDerivedBitmap(derBitmapIndex);
-	} else {
+	else {
 		byte *nativeBitmap = f489_getNativeBitmapOrGraphic(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice);
 		bitmap = f492_getDerivedBitmap(derBitmapIndex);
 		f129_blitToBitmapShrinkWithPalChange(nativeBitmap, bitmap, explAsp->_byteWidth, explAsp->_height, pixelWidth * 2, height,
@@ -890,7 +883,6 @@ byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale
 	return bitmap;
 }
 
-
 void DisplayMan::updateScreen() {
 	// apply copper
 	for (uint32 i = 320 * 30; i < 320 * 170; ++i)
@@ -903,14 +895,14 @@ void DisplayMan::updateScreen() {
 }
 
 void DisplayMan::f97_drawViewport(int16 palSwitchingRequestedState) {
-	static uint16 *gK10_dungeonViewCurrentPalette; // @ K0010_pui_DungeonViewCurrentPalette
+	static uint16 *dungeonViewCurrentPalette; // @ K0010_pui_DungeonViewCurrentPalette
 
 	// ignored code F0510_AMIGA_WaitBottomOfViewPort
 	if (palSwitchingRequestedState == k2_viewportAsBeforeSleepOrFreezeGame)
 		palSwitchingRequestedState = _g322_paletteSwitchingEnabled ? 1 : 0;
 
 	if (_g342_refreshDungeonViewPaleteRequested) {
-		gK10_dungeonViewCurrentPalette = _palDungeonView[_g304_dungeonViewPaletteIndex];
+		dungeonViewCurrentPalette = _palDungeonView[_g304_dungeonViewPaletteIndex];
 		_g342_refreshDungeonViewPaleteRequested = false;
 		if (palSwitchingRequestedState == k0_viewportNotDungeonView)
 			_g322_paletteSwitchingEnabled = true;
@@ -920,15 +912,15 @@ void DisplayMan::f97_drawViewport(int16 palSwitchingRequestedState) {
 
 	if (palSwitchingRequestedState != (_g322_paletteSwitchingEnabled ? 1 : 0)) {
 		if (palSwitchingRequestedState) {
-			f565_viewportSetPalette(gK10_dungeonViewCurrentPalette, _g347_paletteTopAndBottomScreen);
+			f565_viewportSetPalette(dungeonViewCurrentPalette, _g347_paletteTopAndBottomScreen);
 			_g322_paletteSwitchingEnabled = true;
 		} else {
 			f565_viewportSetPalette(_g347_paletteTopAndBottomScreen, _g347_paletteTopAndBottomScreen);
 			_g322_paletteSwitchingEnabled = false;
 		}
-	} else {
+	} else
 		f565_viewportSetPalette(nullptr, nullptr);
-	}
+
 	updateScreen();
 }
 


Commit: 5bd6e3a49b2030a763fa3fb08b4e948e40f37f00
    https://github.com/scummvm/scummvm/commit/5bd6e3a49b2030a763fa3fb08b4e948e40f37f00
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add missing calls in constructors to initConstant methods

Changed paths:
    engines/dm/champion.cpp
    engines/dm/inventory.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 35b949b..4f62203 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -133,6 +133,8 @@ ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
 	_g407_party.resetToZero();
 	_g514_magicCasterChampionIndex = kM1_ChampionNone;
 	_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
+
+	initConstants();
 }
 
 bool ChampionMan::f329_isLeaderHandObjectThrown(int16 side) {
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 8a25ecd..c17191c 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -74,6 +74,8 @@ InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
 	_g426_openChest = Thing::_none;
 	_g421_objDescTextXpos = 0;
 	_g422_objDescTextYpos = 0;
+
+	initConstants();
 }
 
 void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {


Commit: aacbcc07570a800612ae00008276da1bff2a50a6
    https://github.com/scummvm/scummvm/commit/aacbcc07570a800612ae00008276da1bff2a50a6
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Correct language from GR_GRE to DE_DEU

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/objectman.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 4f62203..9171d4f 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -100,14 +100,14 @@ const char *g417_baseSkillName[4];
 void ChampionMan::initConstants() {
 	{
 		static const char *g417_baseSkillName_EN_ANY[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"};
-		static const char *g417_baseSkillName_GR_GRE[4] = {"KAEMPFER", "NINJA", "PRIESTER", "MAGIER"};
+		static const char *g417_baseSkillName_DE_DEU[4] = {"KAEMPFER", "NINJA", "PRIESTER", "MAGIER"};
 		static const char *g417_baseSkillName_FR_FRA[4] = {"GUERRIER", "NINJA", "PRETRE", "SORCIER"};
 
 		const char **g417_byLanguage;
 		switch (_vm->getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY: g417_byLanguage = g417_baseSkillName_EN_ANY; break;
-		case Common::GR_GRE: g417_byLanguage = g417_baseSkillName_GR_GRE; break;
+		case Common::DE_DEU: g417_byLanguage = g417_baseSkillName_DE_DEU; break;
 		case Common::FR_FRA: g417_byLanguage = g417_baseSkillName_FR_FRA; break;
 		}
 		for (int i = 0; i < 4; ++i)
@@ -993,7 +993,7 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex,
 			switch (_vm->getGameLanguage()) { // localized
 			default:
 			case Common::EN_ANY: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " JUST GAINED A "); break;
-			case Common::GR_GRE: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " HAT SOEBEN STUFE"); break;
+			case Common::DE_DEU: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " HAT SOEBEN STUFE"); break;
 			case Common::FR_FRA: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " VIENT DE DEVENIR "); break;
 			}
 
@@ -1002,7 +1002,7 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex,
 			switch (_vm->getGameLanguage()) { // localized
 			default:
 			case Common::EN_ANY: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, "!"); break;
-			case Common::GR_GRE: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " LEVEL!"); break;
+			case Common::DE_DEU: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " LEVEL!"); break;
 			case Common::FR_FRA: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " ERREICHT!"); break;
 			}
 		}
@@ -2186,7 +2186,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		switch (_vm->getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY: _vm->_textMan->f52_printToViewport(104, 132, loadColor, "LOAD "); break;
-		case Common::GR_GRE: _vm->_textMan->f52_printToViewport(104, 132, loadColor, "LAST "); break;
+		case Common::DE_DEU: _vm->_textMan->f52_printToViewport(104, 132, loadColor, "LAST "); break;
 		case Common::FR_FRA: _vm->_textMan->f52_printToViewport(104, 132, loadColor, "CHARGE "); break;
 		}
 
@@ -2196,7 +2196,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		switch (_vm->getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY: strcat(_vm->_g353_stringBuildBuffer, "."); break;
-		case Common::GR_GRE: strcat(_vm->_g353_stringBuildBuffer, ","); break;
+		case Common::DE_DEU: strcat(_vm->_g353_stringBuildBuffer, ","); break;
 		case Common::FR_FRA: strcat(_vm->_g353_stringBuildBuffer, "KG,"); break;
 		}
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 14e0c37..67e1185 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -572,7 +572,7 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 		restartOuterBox = boxEndgameRestartOuterEN;
 		restartInnerBox = boxEndgameRestartInnerEN;
 		break;
-	case Common::GR_GRE:
+	case Common::DE_DEU:
 		restartOuterBox = boxEndgameRestartOuterDE;
 		restartInnerBox = boxEndgameRestartInnerDE;
 		break;
@@ -676,7 +676,7 @@ T0444017:
 			switch (getGameLanguage()) { // localized
 			default:
 			case Common::EN_ANY: _textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RESTART THIS GAME"); break;
-			case Common::GR_GRE: _textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "DIESES SPIEL NEU STARTEN"); break;
+			case Common::DE_DEU: _textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "DIESES SPIEL NEU STARTEN"); break;
 			case Common::FR_FRA: _textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RECOMMENCER CE JEU"); break;
 			}
 
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 4a51f27..e4eaa94 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -796,7 +796,7 @@ void EventManager::f380_processCommandQueue() {
 			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 81, 69, k4_ColorCyan, k0_ColorBlack,
 												 "GAME FROZEN", k136_heightViewport);
 			break;
-		case Common::GR_GRE:
+		case Common::DE_DEU:
 			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 66, 69, k4_ColorCyan, k0_ColorBlack,
 												 "SPIEL ANGEHALTEN", k136_heightViewport);
 			break;
@@ -1216,7 +1216,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 	case Common::EN_ANY:
 		_vm->_textMan->f47_messageAreaPrintMessage(champColor, (commandType == k160_CommandClickInPanelResurrect) ? " RESURRECTED." : " REINCARNATED.");
 		break;
-	case Common::GR_GRE:
+	case Common::DE_DEU:
 		_vm->_textMan->f47_messageAreaPrintMessage(champColor, (commandType == k160_CommandClickInPanelResurrect) ? " VOM TODE ERWECKT." : " REINKARNIERT.");
 		break;
 	case Common::FR_FRA:
@@ -1324,7 +1324,7 @@ void EventManager::f379_drawSleepScreen() {
 	case Common::EN_ANY:
 		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 93, 69, k4_ColorCyan, k0_ColorBlack, "WAKE UP", k136_heightViewport);
 		break;
-	case Common::GR_GRE:
+	case Common::DE_DEU:
 		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 96, 69, k4_ColorCyan, k0_ColorBlack, "WECKEN", k136_heightViewport);
 		break;
 	case Common::FR_FRA:
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index c17191c..f393427 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -50,7 +50,7 @@ void InventoryMan::initConstants() {
 	{
 		static const char* G0428_apc_SkillLevelNames_EN_ANY[15] = {"NEOPHYTE", "NOVICE", "APPRENTICE", "JOURNEYMAN", "CRAFTSMAN",
 			"ARTISAN", "ADEPT", "EXPERT", "` MASTER", "a MASTER","b MASTER", "c MASTER", "d MASTER", "e MASTER", "ARCHMASTER"};
-		static const char* G0428_apc_SkillLevelNames_GR_GRE[15] = {"ANFAENGER", "NEULING", "LEHRLING", "ARBEITER", "GESELLE", "HANDWERKR", "FACHMANN",
+		static const char* G0428_apc_SkillLevelNames_DE_DEU[15] = {"ANFAENGER", "NEULING", "LEHRLING", "ARBEITER", "GESELLE", "HANDWERKR", "FACHMANN",
 			"EXPERTE", "` MEISTER", "a MEISTER", "b MEISTER", "c MEISTER", "d MEISTER", "e MEISTER", "ERZMEISTR"};
 		static const char* G0428_apc_SkillLevelNames_FR_FRA[15] = { "NEOPHYTE", "NOVICE", "APPRENTI", "COMPAGNON", "ARTISAN", "PATRON",
 			"ADEPTE", "EXPERT", "MAITRE '", "MAITRE a", "MAITRE b", "MAITRE c", "MAITRE d", "MAITRE e", "SUR-MAITRE"};
@@ -58,7 +58,7 @@ void InventoryMan::initConstants() {
 		switch (_vm->getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY: g428_byLanguage = G0428_apc_SkillLevelNames_EN_ANY; break;
-		case Common::GR_GRE: g428_byLanguage = G0428_apc_SkillLevelNames_GR_GRE; break;
+		case Common::DE_DEU: g428_byLanguage = G0428_apc_SkillLevelNames_DE_DEU; break;
 		case Common::FR_FRA: g428_byLanguage = G0428_apc_SkillLevelNames_FR_FRA; break;
 		}
 		for (int i = 0; i < 15; ++i)
@@ -137,7 +137,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 		_vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "HEALTH");
 		_vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
 		break;
-	case Common::GR_GRE:
+	case Common::DE_DEU:
 		_vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "GESUND");
 		_vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "KRAFT");
 		break;
@@ -209,7 +209,7 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
 		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k30_FoodLabelIndice), g35_BoxFood, k24_byteWidth, k12_ColorDarkestGray, 9);
 		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k31_WaterLabelIndice), g36_BoxWater, k24_byteWidth, k12_ColorDarkestGray, 9);
 		break;
-	case Common::GR_GRE:
+	case Common::DE_DEU:
 		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k30_FoodLabelIndice), g35_BoxFood, k32_byteWidth, k12_ColorDarkestGray, 9);
 		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k31_WaterLabelIndice), g36_BoxWater, k32_byteWidth, k12_ColorDarkestGray, 9);
 		break;
@@ -422,7 +422,7 @@ void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, in
 				switch (_vm->getGameLanguage()) { // localized
 				default:
 				case Common::EN_ANY: strcat(destString, " AND "); break;
-				case Common::GR_GRE: strcat(destString, " UND "); break;
+				case Common::DE_DEU: strcat(destString, " UND "); break;
 				case Common::FR_FRA: strcat(destString, " ET "); break;
 				}
 
@@ -516,7 +516,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			switch (_vm->getGameLanguage()) { // localized
 			default:
 			case Common::EN_ANY:
-			case Common::GR_GRE: // german and english versions are the same
+			case Common::DE_DEU: // german and english versions are the same
 				strcpy(str, champMan._gK71_champions[((Junk *)rawThingPtr)->getChargeCount()]._name);
 				strcat(str, " ");
 				strcat(str, objMan._g352_objectNames[iconIndex]);
@@ -561,7 +561,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 				switch (_vm->getGameLanguage()) { // localized
 				default:
 				case Common::EN_ANY: f335_drawPanelObjectDescriptionString("(BURNT OUT)"); break;
-				case Common::GR_GRE: f335_drawPanelObjectDescriptionString("(AUSGEBRANNT)"); break;
+				case Common::DE_DEU: f335_drawPanelObjectDescriptionString("(AUSGEBRANNT)"); break;
 				case Common::FR_FRA: f335_drawPanelObjectDescriptionString("(CONSUME)"); break;
 				}
 			}
@@ -584,13 +584,13 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
 				potentialAttribMask = 0;
 				char *descString_EN_ANY[4] = {"(EMPTY)", "(ALMOST EMPTY)", "(ALMOST FULL)", "(FULL)"};
-				char *descString_GE_GRE[4] = {"(LEER)", "(FAST LEER)", "(FAST VOLL)", "(VOLL)"};
+				char *descString_DE_DEU[4] = {"(LEER)", "(FAST LEER)", "(FAST VOLL)", "(VOLL)"};
 				char *descString_FR_FRA[4] = {"(VIDE)", "(PRESQUE VIDE)", "(PRESQUE PLEINE)", "(PLEINE)"};
 
 				switch (_vm->getGameLanguage()) { // localized
 				default:
 				case Common::EN_ANY: descString = descString_EN_ANY[junk->getChargeCount()]; break;
-				case Common::GR_GRE: descString = descString_GE_GRE[junk->getChargeCount()]; break;
+				case Common::DE_DEU: descString = descString_DE_DEU[junk->getChargeCount()]; break;
 				case Common::FR_FRA: descString = descString_FR_FRA[junk->getChargeCount()]; break;
 				}
 
@@ -601,19 +601,19 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 				switch (_vm->getGameLanguage()) { // localized
 				default:
 				case Common::EN_ANY: strcpy(str, "PARTY FACING "); break;
-				case Common::GR_GRE: strcpy(str, "GRUPPE BLICKT NACH "); break;
+				case Common::DE_DEU: strcpy(str, "GRUPPE BLICKT NACH "); break;
 				case Common::FR_FRA: strcpy(str, "GROUPE FACE "); break;
 				}
 
 
 				static char* directionName_EN_ANY[4] = {"NORTH", "EAST", "SOUTH", "WEST"};
-				static char* directionName_GR_GRE[4] = {"NORDEN", "OSTEN", "SUEDEN", "WESTEN"};
+				static char* directionName_DE_DEU[4] = {"NORDEN", "OSTEN", "SUEDEN", "WESTEN"};
 				static char* directionName_FR_FRA[4] = {"AU NORD", "A L'EST", "AU SUD", "A L'OUEST"};
 				switch (_vm->getGameLanguage()) { // localized
 				default:
 				case Common::EN_ANY: strcat(str, directionName_EN_ANY[iconIndex]); break;
-				case Common::GR_GRE: strcat(str, directionName_FR_FRA[iconIndex]); break;
-				case Common::FR_FRA: strcat(str, directionName_GR_GRE[iconIndex]); break;
+				case Common::DE_DEU: strcat(str, directionName_DE_DEU[iconIndex]); break;
+				case Common::FR_FRA: strcat(str, directionName_FR_FRA[iconIndex]); break;
 				}
 
 				f335_drawPanelObjectDescriptionString(str);
@@ -627,14 +627,14 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 
 		if (potentialAttribMask) {
 			char *attribString_EN_ANY[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"};
-			char *attribString_GR_GRE[4] = {"ESSBAR", "VERGIFTET", "DEFEKT", "VERFLUCHT"};
+			char *attribString_DE_DEU[4] = {"ESSBAR", "VERGIFTET", "DEFEKT", "VERFLUCHT"};
 			char *attribString_FR_FRA[4] = {"COMESTIBLE", "EMPOISONNE", "BRISE", "MAUDIT"};
 			char **attribString = nullptr;
 
 			switch (_vm->getGameLanguage()) { // localized
 			default:
 			case Common::EN_ANY: attribString = attribString_EN_ANY; break;
-			case Common::GR_GRE: attribString = attribString_GR_GRE; break;
+			case Common::DE_DEU: attribString = attribString_DE_DEU; break;
 			case Common::FR_FRA: attribString = attribString_FR_FRA; break;
 			}
 
@@ -645,7 +645,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		switch (_vm->getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY: strcpy(str, "WEIGHS "); break;
-		case Common::GR_GRE: strcpy(str, "WIEGT "); break;
+		case Common::DE_DEU: strcpy(str, "WIEGT "); break;
 		case Common::FR_FRA: strcpy(str, "PESE "); break;
 		}
 
@@ -656,7 +656,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		switch (_vm->getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY: strcat(str, "."); break;
-		case Common::GR_GRE: strcat(str, ","); break;
+		case Common::DE_DEU: strcat(str, ","); break;
 		case Common::FR_FRA: strcat(str, "KG,"); break;
 		}
 
@@ -666,7 +666,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		switch (_vm->getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY:
-		case Common::GR_GRE: strcat(str, " KG."); break;
+		case Common::DE_DEU: strcat(str, " KG."); break;
 		case Common::FR_FRA: strcat(str, "."); break;
 		}
 
@@ -793,13 +793,13 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 	char L1097_ac_String[20];
 
 	static char* G0431_apc_StatisticNames_EN_ANY[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"};
-	static char* G0431_apc_StatisticNames_GR_GRE[7] = {"L", "STAERKE", "FLINKHEIT", "WEISHEIT", "VITALITAET", "ANTI-MAGIE", "ANTI-FEUER"};
+	static char* G0431_apc_StatisticNames_DE_DEU[7] = {"L", "STAERKE", "FLINKHEIT", "WEISHEIT", "VITALITAET", "ANTI-MAGIE", "ANTI-FEUER"};
 	static char* G0431_apc_StatisticNames_FR_FRA[7] = {"L", "FORCE", "DEXTERITE", "SAGESSE", "VITALITE", "ANTI-MAGIE", "ANTI-FEU"};
 	char **G0431_apc_StatisticNames;
 	switch (_vm->getGameLanguage()) { // localized
 	default:
 	case Common::EN_ANY: G0431_apc_StatisticNames = G0431_apc_StatisticNames_EN_ANY; break;
-	case Common::GR_GRE: G0431_apc_StatisticNames = G0431_apc_StatisticNames_GR_GRE; break;
+	case Common::DE_DEU: G0431_apc_StatisticNames = G0431_apc_StatisticNames_DE_DEU; break;
 	case Common::FR_FRA: G0431_apc_StatisticNames = G0431_apc_StatisticNames_FR_FRA; break;
 	}
 
@@ -815,7 +815,7 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 		switch (_vm->getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY:
-		case Common::GR_GRE: // english and german versions are the same
+		case Common::DE_DEU: // english and german versions are the same
 			strcpy(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]);
 			strcat(L1097_ac_String, " ");
 			strcat(L1097_ac_String, g417_baseSkillName[AL1090_ui_SkillIndex]);
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 7eb29d6..9eb0e6c 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -161,7 +161,7 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		case Common::EN_ANY:
 			_dialog->f427_dialogDraw(nullptr, "LOADING GAME . . .", nullptr, nullptr, nullptr, nullptr, true, true, true);
 			break;
-		case Common::GR_GRE:
+		case Common::DE_DEU:
 			_dialog->f427_dialogDraw(nullptr, "SPIEL WIRD GELADEN . . .", nullptr, nullptr, nullptr, nullptr, true, true, true);
 			break;
 		case Common::FR_FRA:
@@ -187,7 +187,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 	case Common::EN_ANY:
 		_dialog->f427_dialogDraw(message, nullptr, "SAVE AND PLAY", "SAVE AND QUIT", "CANCEL", nullptr, false, false, false);
 		break;
-	case Common::GR_GRE:
+	case Common::DE_DEU:
 		_dialog->f427_dialogDraw(message, nullptr, "SICHERN/SPIEL", "SICHERN/ENDEN", "WIDERRUFEN", nullptr, false, false, false);
 		break;
 	case Common::FR_FRA:
@@ -201,7 +201,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 	case Common::EN_ANY:
 		_dialog->f427_dialogDraw(nullptr, "SAVING GAME . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
 		break;
-	case Common::GR_GRE:
+	case Common::DE_DEU:
 		_dialog->f427_dialogDraw(nullptr, "SPIEL WIRD GESICHERT . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
 		break;
 	case Common::FR_FRA:
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 4ccc5f1..73a567a 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -685,7 +685,7 @@ void MenuMan::f410_menusPrintSpellFailureMessage(Champion* champ, uint16 failure
 	_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, champ->_name);
 
 	char *messages_EN_ANY[4] = {" NEEDS MORE PRACTICE WITH THIS ", " SPELL.", " MUMBLES A MEANINGLESS SPELL."," NEEDS AN EMPTY FLASK IN HAND FOR POTION."};
-	char *messages_GR_GRE[4] = {" BRAUCHT MEHR UEBUNG MIT DIESEM ", " ZAUBERSPRUCH.",
+	char *messages_DE_DEU[4] = {" BRAUCHT MEHR UEBUNG MIT DIESEM ", " ZAUBERSPRUCH.",
 		" MURMELT EINEN SINNLOSEN ZAUBERSPRUCH.", " MUSS FUER DEN TRANK EINE LEERE FLASCHE BEREITHALTEN."};
 	char *messages_FR_FRA[5] = {" DOIT PRATIQUER DAVANTAGE SON ", "ENVOUTEMENT.", " MARMONNE UNE CONJURATION IMCOMPREHENSIBLE.",
 		" DOIT AVOIR UN FLACON VIDE EN MAIN POUR LA POTION.", "EXORCISME."};
@@ -694,8 +694,8 @@ void MenuMan::f410_menusPrintSpellFailureMessage(Champion* champ, uint16 failure
 	default:
 	case Common::EN_ANY:
 		messages = messages_EN_ANY; break;
-	case Common::GR_GRE:
-		messages = messages_GR_GRE; break;
+	case Common::DE_DEU:
+		messages = messages_DE_DEU; break;
 	case Common::FR_FRA:
 		messages = messages_FR_FRA; break;
 	}
@@ -1184,13 +1184,13 @@ T0407032:
 		break;
 	case k5_ChampionActionFlip: {
 		char *messages_EN_ANY[2] = {"IT COMES UP HEADS.", "IT COMES UP TAILS."};
-		char *messages_GR_GRE[2] = {"DIE KOPFSEITE IST OBEN.", "DIE ZAHL IST OBEN."};
+		char *messages_DE_DEU[2] = {"DIE KOPFSEITE IST OBEN.", "DIE ZAHL IST OBEN."};
 		char *messages_FR_FRA[2] = {"C'EST FACE.", "C'EST PILE."};
 		char **message;
 		switch (_vm->getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY: message = messages_EN_ANY; break;
-		case Common::GR_GRE: message = messages_GR_GRE; break;
+		case Common::DE_DEU: message = messages_DE_DEU; break;
 		case Common::FR_FRA: message = messages_FR_FRA; break;
 		}
 		if (_vm->getRandomNumber(2)) {
@@ -1713,17 +1713,17 @@ void MenuMan::f385_drawActionDamage(int16 damage) {
 	_vm->_displayMan->D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack);
 	if (damage < 0) {
 		static char *messages_EN_ANY[2] = {"CAN'T REACH", "NEED AMMO"};
-		static char *messages_GR_GRE[2] = {"ZU WEIT WEG", "MEHR MUNITION"};
+		static char *messages_DE_DEU[2] = {"ZU WEIT WEG", "MEHR MUNITION"};
 		static char *messages_FR_FRA[2] = {"TROP LOIN", "SANS MUNITION"};
 		static int16  pos_EN_ANY[2] = {242, 248};
-		static int16  pos_GR_GRE[2] = {242, 236};
+		static int16  pos_DE_DEU[2] = {242, 236};
 		static int16  pos_FR_FRA[2] = {248, 236};
 		char **message;
 		int16 *pos;
 		switch (_vm->getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY: message = messages_EN_ANY; pos = pos_EN_ANY;  break;
-		case Common::GR_GRE: message = messages_GR_GRE; pos = pos_GR_GRE; break;
+		case Common::DE_DEU: message = messages_DE_DEU; pos = pos_DE_DEU; break;
 		case Common::FR_FRA: message = messages_FR_FRA; pos = pos_FR_FRA; break;
 		}
 
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 56ecc3a..3104ae2 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -245,7 +245,7 @@ void ObjectMan::f34_drawLeaderObjectName(Thing thing) {
 		switch (_vm->getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY:
-		case Common::GR_GRE: // english and german version are the same
+		case Common::DE_DEU: // english and german version are the same
 			strcpy(champBonesName, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name);
 			strcat(champBonesName, _g352_objectNames[L0007_i_IconIndex]);
 			break;


Commit: b5eb075a66a1f064fe8f8479c63bd99a518b1da4
    https://github.com/scummvm/scummvm/commit/b5eb075a66a1f064fe8f8479c63bd99a518b1da4
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix wrong global initialized in InventoryMan::initConstants()

Changed paths:
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index f393427..bbc451d 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -44,7 +44,7 @@ Box g35_BoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food
 Box g36_BoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
 Box g37_BoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
 
-char* G0428_apc_SkillLevelNames[15];
+const char* G0428_apc_SkillLevelNames[15];
 
 void InventoryMan::initConstants() {
 	{
@@ -62,7 +62,7 @@ void InventoryMan::initConstants() {
 		case Common::FR_FRA: g428_byLanguage = G0428_apc_SkillLevelNames_FR_FRA; break;
 		}
 		for (int i = 0; i < 15; ++i)
-			g417_baseSkillName[i] = g428_byLanguage[i];
+			G0428_apc_SkillLevelNames[i] = g428_byLanguage[i];
 	}
 }
 
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 0af1661..d16f22d 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -47,7 +47,7 @@ enum PanelContent {
 	k5_PanelContentResurrectReincarnate = 5 // @ C05_PANEL_RESURRECT_REINCARNATE
 };
 
-extern char* G0428_apc_SkillLevelNames[15]; // @ G0428_apc_SkillLevelNames  
+extern const char* G0428_apc_SkillLevelNames[15]; // @ G0428_apc_SkillLevelNames  
 
 class InventoryMan {
 	DMEngine *_vm;


Commit: 4f916a08d23e05c445c7dc42807b3d61a1beb3e9
    https://github.com/scummvm/scummvm/commit/4f916a08d23e05c445c7dc42807b3d61a1beb3e9
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add support for uncompressed dungeon.dat

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 5509e69..44cc616 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -6,12 +6,6 @@ Bugs:
 	Logic:
 		Items thrown on the right side end up on the left side 
 
-
-Possible bugs:
-	- k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON
-	- possible garbage value return in f140_getObjectWeight
-
-	
 Todo:
 	Add wiki entry for DM
 	
@@ -20,8 +14,7 @@ Todo:
 	I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions
 
 Code stuff todo:
-	Complete stub methods(blitShrink, etc.)
-	Add scroller
+	Complete stub methods(blitShrink, blitmask, scroller, etc.)
 	Save file f433_processCommand140_saveGame fails silently, add error checking
 	Clean up f113_drawField
 	
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index b745a99..a70077c 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -427,11 +427,11 @@ DungeonMan::~DungeonMan() {
 void DungeonMan::f455_decompressDungeonFile() {
 	Common::File f;
 	f.open("Dungeon.dat");
-	if (f.readUint16BE() == 0x8104) {
+	if (f.readUint16BE() == 0x8104) { // if dungeon is compressed
 		_rawDunFileDataSize = f.readUint32BE();
 		delete[] _rawDunFileData;
 		_rawDunFileData = new byte[_rawDunFileDataSize];
-		f.readUint16BE();
+		f.readUint16BE(); // discard
 		byte common[4];
 		for (uint16 i = 0; i < 4; ++i)
 			common[i] = f.readByte();
@@ -475,8 +475,12 @@ void DungeonMan::f455_decompressDungeonFile() {
 				bitsUsedInWord += 10;
 			}
 		}
-	} else {
-		warning(false, "TODO: if the dungeon is uncompressed, read it here");
+	} else { // read uncompressed Dungeon.dat
+		f.seek(0);
+		_rawDunFileDataSize = f.size();
+		delete[] _rawDunFileData;
+		_rawDunFileData = new byte[_rawDunFileDataSize];
+		f.read(_rawDunFileData, _rawDunFileDataSize);
 	}
 	f.close();
 }


Commit: cc8d3d9dd72e4a7f77ea6f114d917300aa7d1689
    https://github.com/scummvm/scummvm/commit/cc8d3d9dd72e4a7f77ea6f114d917300aa7d1689
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add LZW decompressor

Changed paths:
  A engines/dm/lzw.cpp
  A engines/dm/lzw.h
    engines/dm/module.mk



diff --git a/engines/dm/lzw.cpp b/engines/dm/lzw.cpp
new file mode 100644
index 0000000..c5acc9c
--- /dev/null
+++ b/engines/dm/lzw.cpp
@@ -0,0 +1,189 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#include "lzw.h"
+#include <common/memstream.h>
+
+namespace DM {
+
+LZWdecompressor::LZWdecompressor() {
+	_repetitionEnabled = false;
+	_codeBitCount = 0;
+	_currentMaximumCode = 0;
+	_absoluteMaximumCode = 4096;
+	for (int i = 0; i < 12; ++i)
+		_inputBuffer[i] = 0;
+	_dictNextAvailableCode = 0;
+	_dictFlushed = false;
+
+	byte leastSignificantBitmasks[9] = {0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF};
+	for (uint16 i = 0; i < 9; ++i)
+		_leastSignificantBitmasks[i] = leastSignificantBitmasks[i];
+	_inputBufferBitIndex = 0;
+	_inputBufferBitCount = 0;
+	_charToRepeat = 0;
+
+	_tempBuffer = new byte[5004];
+	_prefixCode = new int16[5003];
+	_appendCharacter = new byte[5226];
+}
+
+LZWdecompressor::~LZWdecompressor() {
+	delete[] _appendCharacter;
+	delete[] _prefixCode;
+	delete[] _tempBuffer;
+}
+
+int16 LZWdecompressor::getNextInputCode(Common::MemoryReadStream &inputStream, int32 *inputByteCount) {
+	byte *inputBuffer = _inputBuffer;
+	if (_dictFlushed || (_inputBufferBitIndex >= _inputBufferBitCount) || (_dictNextAvailableCode > _currentMaximumCode)) {
+		if (_dictNextAvailableCode > _currentMaximumCode) {
+			_codeBitCount++;
+			if (_codeBitCount == 12) {
+				_currentMaximumCode = _absoluteMaximumCode;
+			} else {
+				_currentMaximumCode = (1 << _codeBitCount) - 1;
+			}
+		}
+		if (_dictFlushed) {
+			_currentMaximumCode = (1 << (_codeBitCount = 9)) - 1;
+			_dictFlushed = false;
+		}
+		if (*inputByteCount > _codeBitCount) {
+			_inputBufferBitCount = _codeBitCount;
+		} else {
+			_inputBufferBitCount = *inputByteCount;
+		}
+		if (_inputBufferBitCount > 0) {
+			inputStream.read(_inputBuffer, _inputBufferBitCount);
+			*inputByteCount -= _inputBufferBitCount;
+		} else {
+			return -1;
+		}
+		_inputBufferBitIndex = 0;
+		_inputBufferBitCount = (_inputBufferBitCount << 3) - (_codeBitCount - 1);
+	}
+	int16 bitIndex = _inputBufferBitIndex;
+	int16 requiredInputBitCount = _codeBitCount;
+	inputBuffer += bitIndex >> 3; /* Address of byte in input buffer containing current bit */
+	bitIndex &= 0x0007; /* Bit index of the current bit in the byte */
+	int16 nextInputCode = *inputBuffer++ >> bitIndex; /* Get the first bits of the next input code from the input buffer byte */
+	requiredInputBitCount -= 8 - bitIndex; /* Remaining number of bits to get for a complete input code */
+	bitIndex = 8 - bitIndex;
+	if (requiredInputBitCount >= 8) {
+		nextInputCode |= *inputBuffer++ << bitIndex;
+		bitIndex += 8;
+		requiredInputBitCount -= 8;
+	}
+	nextInputCode |= (*inputBuffer & _leastSignificantBitmasks[requiredInputBitCount]) << bitIndex;
+	_inputBufferBitIndex += _codeBitCount;
+	return nextInputCode;
+}
+
+void LZWdecompressor::F0496_LZW_OutputCharacter(byte character, byte **out) {
+	byte *L1558_pc_Output = *out;
+
+	if (false == _repetitionEnabled) {
+		if (character == 0x90) {
+			_repetitionEnabled = true;
+		} else {
+			*L1558_pc_Output++ = _charToRepeat = character;
+		}
+		*out = L1558_pc_Output;
+		return;
+	} else {
+		if (character) { /* If character following 0x90 is not 0x00 then it is the repeat count */
+			while (--character) {
+				*L1558_pc_Output++ = _charToRepeat;
+			}
+		} else { /* else output a 0x90 character */
+			*L1558_pc_Output++ = 0x90;
+		}
+		_repetitionEnabled = false;
+		*out = L1558_pc_Output;
+		return;
+	}
+}
+
+int32 LZWdecompressor::decompress(Common::MemoryReadStream &inStream, int32 inputByteCount, byte *out) {
+	byte *reversedDecodedStringStart;
+	byte *reversedDecodedStringEnd = reversedDecodedStringStart = _tempBuffer;
+	byte *originalOut = out;
+	_repetitionEnabled = false;
+	_codeBitCount = 9;
+	_dictFlushed = false;
+	_currentMaximumCode = (1 << (_codeBitCount = 9)) - 1;
+	for (int16 code = 255; code >= 0; code--) {
+		_prefixCode[code] = 0;
+		_appendCharacter[code] = code;
+	}
+	_dictNextAvailableCode = 257;
+	int16 oldCode;
+	int16 character = oldCode = getNextInputCode(inStream, &inputByteCount);
+	if (oldCode == -1) {
+		return -1L;
+	}
+	F0496_LZW_OutputCharacter(character, &out);
+	int16 code;
+	while ((code = getNextInputCode(inStream, &inputByteCount)) > -1) {
+		if (code == 256) { /* This code is used to flush the dictionary */
+			for (int i = 0; i < 256; ++i)
+				_prefixCode[i] = 0;
+			_dictFlushed = true;
+			_dictNextAvailableCode = 256;
+			if ((code = getNextInputCode(inStream, &inputByteCount)) == -1) {
+				break;
+			}
+		}
+		/* This code checks for the special STRING+CHARACTER+STRING+CHARACTER+STRING case which generates an undefined code.
+		It handles it by decoding the last code, adding a single character to the end of the decoded string */
+		int16 newCode = code;
+		if (code >= _dictNextAvailableCode) { /* If code is not defined yet */
+			*reversedDecodedStringEnd++ = character;
+			code = oldCode;
+		}
+		/* Use the string table to decode the string corresponding to the code and store the string in the temporary buffer */
+		while (code >= 256) {
+			*reversedDecodedStringEnd++ = _appendCharacter[code];
+			code = _prefixCode[code];
+		}
+		*reversedDecodedStringEnd++ = (character = _appendCharacter[code]);
+		/* Output the decoded string in reverse order */
+		do {
+			F0496_LZW_OutputCharacter(*(--reversedDecodedStringEnd), &out);
+		} while (reversedDecodedStringEnd > reversedDecodedStringStart);
+		/* If possible, add a new code to the string table */
+		if ((code = _dictNextAvailableCode) < _absoluteMaximumCode) {
+			_prefixCode[code] = oldCode;
+			_appendCharacter[code] = character;
+			_dictNextAvailableCode = code + 1;
+		}
+		oldCode = newCode;
+	}
+	return out - originalOut; /* Byte count of decompressed data */
+}
+}
diff --git a/engines/dm/lzw.h b/engines/dm/lzw.h
new file mode 100644
index 0000000..80c18c5
--- /dev/null
+++ b/engines/dm/lzw.h
@@ -0,0 +1,64 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#include <common/file.h>
+
+#include "dm.h"
+
+namespace Common {
+	class MemoryReadStream;
+}
+
+namespace DM {
+class LZWdecompressor {
+	bool _repetitionEnabled;
+	int16 _codeBitCount;
+	int16 _currentMaximumCode;
+	int16 _absoluteMaximumCode;
+	byte _inputBuffer[12];
+	int16 _dictNextAvailableCode;
+	bool _dictFlushed;
+
+	byte _leastSignificantBitmasks[9];
+	int16 _inputBufferBitIndex;
+	int16 _inputBufferBitCount;
+	int16 _charToRepeat;
+
+	byte* _tempBuffer;
+	int16 *_prefixCode;
+	byte *_appendCharacter;
+
+	int16 getNextInputCode(Common::MemoryReadStream &stream, int32 *inputByteCount);
+	void F0496_LZW_OutputCharacter(byte character, byte **out);
+	void operator=(const LZWdecompressor&); // deleted
+public:
+	LZWdecompressor();
+	~LZWdecompressor();
+	int32 decompress(Common::MemoryReadStream &inputStream, int32 inputByteCount, byte *out);
+};
+
+}
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index 559ebf1..d495284 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -41,6 +41,7 @@ MODULE_OBJS := \
 	group.o \
 	inventory.o \
 	loadsave.o \
+	lzw.o \
 	menus.o \
 	movesens.o \
 	objectman.o \


Commit: 170c52a4e0235ec7e5b044e69df52f2862284026
    https://github.com/scummvm/scummvm/commit/170c52a4e0235ec7e5b044e69df52f2862284026
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add unknown Atari game version

Changed paths:
    engines/dm/detection.cpp



diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp
index a1fd6bc..200a81f 100644
--- a/engines/dm/detection.cpp
+++ b/engines/dm/detection.cpp
@@ -48,6 +48,15 @@ static const ADGameDescription gameDescriptions[] = {
 		},
 	    Common::EN_ANY, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE)
 	},
+	{
+		"dm", "Atari ???v English",
+		{
+			{"graphics.dat", 0, "6ffff2a17e2df0effa9a12fb4b1bf6b6", 271911},
+			{"Dungeon.dat", 0, "be9468b460515741babec9a70501e2e9", 33286},
+			AD_LISTEND
+		},
+	Common::EN_ANY, Common::kPlatformAtariST, ADGF_NO_FLAGS, GUIO1(GUIO_NONE)
+	},
 
 	AD_TABLE_END_MARKER
 };


Commit: 7cc41a1929c1609cb952517a60bd222cc62d690d
    https://github.com/scummvm/scummvm/commit/7cc41a1929c1609cb952517a60bd222cc62d690d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add support for LZW compresssed graphics.dat

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index a8c0c95..192d239 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -37,6 +37,7 @@
 #include "timeline.h"
 #include "champion.h"
 #include "eventman.h"
+#include "lzw.h"
 
 namespace DM {
 DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
@@ -44,6 +45,8 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_bitmaps = nullptr;
 	_grapItemCount = 0;
 	_packedItemPos = nullptr;
+	_bitmapCompressedByteCount = nullptr;
+	_bitmapDecompressedByteCount = nullptr;
 	_packedBitmaps = nullptr;
 	_bitmaps = nullptr;
 	_g74_tmpBitmap = nullptr;
@@ -393,16 +396,16 @@ void DisplayMan::initConstants() {
 		_projectileAspect[i] = projectileAspect[i];
 
 	_doorFrameD1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
-		Frame(64, 159, 17, 102, 48, 88, 0, 0),	 /* Closed Or Destroyed */
-		Frame(64, 159, 17, 38, 48, 88, 0, 66),	 /* Vertical Closed one fourth */
-		Frame(64, 159, 17, 60, 48, 88, 0, 44),	 /* Vertical Closed half */
-		Frame(64, 159, 17, 82, 48, 88, 0, 22),	 /* Vertical Closed three fourth */
-		Frame(64, 75, 17, 102, 48, 88, 36, 0),	 /* Left Horizontal Closed one fourth */
-		Frame(64, 87, 17, 102, 48, 88, 24, 0),	 /* Left Horizontal Closed half */
-		Frame(64, 99, 17, 102, 48, 88, 12, 0),	 /* Left Horizontal Closed three fourth */
-		Frame(148, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */
-		Frame(136, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */
-		Frame(124, 159, 17, 102, 48, 88, 48, 0)	 /* Right Horizontal Closed three fourth */
+								   Frame(64, 159, 17, 102, 48, 88, 0, 0),	 /* Closed Or Destroyed */
+								   Frame(64, 159, 17, 38, 48, 88, 0, 66),	 /* Vertical Closed one fourth */
+								   Frame(64, 159, 17, 60, 48, 88, 0, 44),	 /* Vertical Closed half */
+								   Frame(64, 159, 17, 82, 48, 88, 0, 22),	 /* Vertical Closed three fourth */
+								   Frame(64, 75, 17, 102, 48, 88, 36, 0),	 /* Left Horizontal Closed one fourth */
+								   Frame(64, 87, 17, 102, 48, 88, 24, 0),	 /* Left Horizontal Closed half */
+								   Frame(64, 99, 17, 102, 48, 88, 12, 0),	 /* Left Horizontal Closed three fourth */
+								   Frame(148, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */
+								   Frame(136, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */
+								   Frame(124, 159, 17, 102, 48, 88, 48, 0)	 /* Right Horizontal Closed three fourth */
 	);
 
 	_boxThievesEyeViewPortVisibleArea = Box(64, 159, 19, 113); // @ G0106_s_Graphic558_Box_ThievesEye_ViewportVisibleArea 
@@ -417,6 +420,8 @@ DisplayMan::~DisplayMan() {
 		delete[] _bitmaps[0];
 		delete[] _bitmaps;
 	}
+	delete[] _bitmapCompressedByteCount;
+	delete[] _bitmapDecompressedByteCount;
 
 	delete[] _g639_derivedBitmapByteCount;
 	if (_g638_derivedBitmaps) {
@@ -464,26 +469,6 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) {
 	_g74_tmpBitmap = new byte[_screenWidth * _screenHeight];
 }
 
-void DisplayMan::f479_loadGraphics() {
-	Common::File f;
-	f.open("graphics.dat");
-	_grapItemCount = f.readUint16BE();
-	delete[] _packedItemPos;
-	_packedItemPos = new uint32[_grapItemCount + 1];
-	_packedItemPos[0] = 0;
-	for (uint16 i = 1; i < _grapItemCount + 1; ++i)
-		_packedItemPos[i] = f.readUint16BE() + _packedItemPos[i - 1];
-
-	delete[] _packedBitmaps;
-	_packedBitmaps = new uint8[_packedItemPos[_grapItemCount]];
-
-	f.seek(2 + _grapItemCount * 4);
-	for (uint32 i = 0; i < _packedItemPos[_grapItemCount]; ++i)
-		_packedBitmaps[i] = f.readByte();
-
-	f.close();
-	unpackGraphics();
-}
 
 void DisplayMan::f460_initializeGraphicData() {
 	_g85_bitmapCeiling = new byte[224 * 29];
@@ -625,6 +610,49 @@ void DisplayMan::f460_initializeGraphicData() {
 	}
 }
 
+void DisplayMan::f479_loadGraphics() {
+	Common::File f;
+	f.open("graphics.dat");
+	_grapItemCount = f.readUint16BE();
+
+	delete[] _bitmapCompressedByteCount;
+	_bitmapCompressedByteCount = new uint32[_grapItemCount];
+	for (uint16 i = 0; i < _grapItemCount; ++i)
+		_bitmapCompressedByteCount[i] = f.readUint16BE();
+
+	delete[] _bitmapDecompressedByteCount;
+	_bitmapDecompressedByteCount = new uint32[_grapItemCount];
+	for (uint16 i = 0; i < _grapItemCount; ++i)
+		_bitmapDecompressedByteCount[i] = f.readUint16BE();
+
+	delete[] _packedItemPos;
+	_packedItemPos = new uint32[_grapItemCount + 1];
+	_packedItemPos[0] = 0;
+	for (uint16 i = 1; i < _grapItemCount + 1; ++i) {
+		_packedItemPos[i] = _packedItemPos[i - 1] + _bitmapDecompressedByteCount[i - 1];
+	}
+
+	delete[] _packedBitmaps;
+	_packedBitmaps = new uint8[_packedItemPos[_grapItemCount]];
+
+	LZWdecompressor lzw;
+	Common::Array<byte> tmpBuffer;
+	f.seek(2 + _grapItemCount * 4);
+	for (uint32 i = 0; i < _grapItemCount; ++i) {
+		byte *bitmap = _packedBitmaps + _packedItemPos[i];
+		f.read(bitmap, _bitmapCompressedByteCount[i]);
+		if (_bitmapCompressedByteCount[i] != _bitmapDecompressedByteCount[i]) {
+			tmpBuffer.reserve(_bitmapDecompressedByteCount[i]);
+			Common::MemoryReadStream stream(bitmap, _bitmapCompressedByteCount[i]);
+			lzw.decompress(stream, _bitmapCompressedByteCount[i], tmpBuffer.begin());
+			memcpy(bitmap, tmpBuffer.begin(), _bitmapDecompressedByteCount[i]);
+		}
+	}
+
+	f.close();
+	unpackGraphics();
+}
+
 void DisplayMan::unpackGraphics() {
 	uint32 unpackedBitmapsSize = 0;
 	for (uint16 i = 0; i <= 20; ++i)
@@ -655,6 +683,7 @@ void DisplayMan::unpackGraphics() {
 
 void DisplayMan::loadFNT1intoBitmap(uint16 index, byte* destBitmap) {
 	uint8 *data = _packedBitmaps + _packedItemPos[index];
+
 	for (uint16 i = 0; i < 6; i++) {
 		for (uint16 w = 0; w < 128; ++w) {
 			*destBitmap++ = k0_ColorBlack;
@@ -755,10 +784,12 @@ void DisplayMan::f566_viewportBlitToScreen() {
 
 void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) {
 	uint8 *data = _packedBitmaps + _packedItemPos[index];
+
 	uint16 width = READ_BE_UINT16(data);
 	uint16 height = READ_BE_UINT16(data + 2);
 	uint16 nextByteIndex = 4;
-	for (uint16 k = 0; k < width * height;) {
+
+	for (int32 k = 0; k < width * height;) {
 		uint8 nextByte = data[nextByteIndex++];
 		uint8 nibble1 = (nextByte & 0xF0) >> 4;
 		uint8 nibble2 = (nextByte & 0x0F);
@@ -1178,16 +1209,16 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 	static Frame frameFloorPitD3L = Frame(0, 79, 66, 73, 40, 8, 0, 0); // @ G0140_s_Graphic558_Frame_FloorPit_D3L
 	static DoorFrames doorFrameD3L = DoorFrames( // @ G0179_s_Graphic558_Frames_Door_D3L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(24, 71, 28, 67, 24, 41, 0, 0),   /* Closed Or Destroyed */
-		Frame(24, 71, 28, 38, 24, 41, 0, 30),  /* Vertical Closed one fourth */
-		Frame(24, 71, 28, 48, 24, 41, 0, 20),  /* Vertical Closed half */
-		Frame(24, 71, 28, 58, 24, 41, 0, 10),  /* Vertical Closed three fourth */
-		Frame(24, 29, 28, 67, 24, 41, 18, 0),  /* Left Horizontal Closed one fourth */
-		Frame(24, 35, 28, 67, 24, 41, 12, 0),  /* Left Horizontal Closed half */
-		Frame(24, 41, 28, 67, 24, 41, 6, 0),   /* Left Horizontal Closed three fourth */
-		Frame(66, 71, 28, 67, 24, 41, 24, 0),  /* Right Horizontal Closed one fourth */
-		Frame(60, 71, 28, 67, 24, 41, 24, 0),  /* Right Horizontal Closed half */
-		Frame(54, 71, 28, 67, 24, 41, 24, 0)   /* Right Horizontal Closed three fourth */
+												Frame(24, 71, 28, 67, 24, 41, 0, 0),   /* Closed Or Destroyed */
+												Frame(24, 71, 28, 38, 24, 41, 0, 30),  /* Vertical Closed one fourth */
+												Frame(24, 71, 28, 48, 24, 41, 0, 20),  /* Vertical Closed half */
+												Frame(24, 71, 28, 58, 24, 41, 0, 10),  /* Vertical Closed three fourth */
+												Frame(24, 29, 28, 67, 24, 41, 18, 0),  /* Left Horizontal Closed one fourth */
+												Frame(24, 35, 28, 67, 24, 41, 12, 0),  /* Left Horizontal Closed half */
+												Frame(24, 41, 28, 67, 24, 41, 6, 0),   /* Left Horizontal Closed three fourth */
+												Frame(66, 71, 28, 67, 24, 41, 24, 0),  /* Right Horizontal Closed one fourth */
+												Frame(60, 71, 28, 67, 24, 41, 24, 0),  /* Right Horizontal Closed half */
+												Frame(54, 71, 28, 67, 24, 41, 24, 0)   /* Right Horizontal Closed three fourth */
 	);
 
 	uint16 squareAspect[5];
@@ -1247,16 +1278,16 @@ void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 	static Frame frameFloorPitD3R = Frame(144, 223, 66, 73, 40, 8, 0, 0); // @ G0142_s_Graphic558_Frame_FloorPit_D3R
 	static DoorFrames doorFrameD3R = DoorFrames( // @ G0181_s_Graphic558_Frames_Door_D3R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(150, 197, 28, 67, 24, 41, 0, 0),	/* Closed Or Destroyed */
-		Frame(150, 197, 28, 38, 24, 41, 0, 30),	/* Vertical Closed one fourth */
-		Frame(150, 197, 28, 48, 24, 41, 0, 20),	/* Vertical Closed half */
-		Frame(150, 197, 28, 58, 24, 41, 0, 10),	/* Vertical Closed three fourth */
-		Frame(150, 153, 28, 67, 24, 41, 18, 0),	/* Left Horizontal Closed one fourth */
-		Frame(150, 161, 28, 67, 24, 41, 12, 0),	/* Left Horizontal Closed half */
-		Frame(150, 167, 28, 67, 24, 41, 6, 0),	/* Left Horizontal Closed three fourth */
-		Frame(192, 197, 28, 67, 24, 41, 24, 0),	/* Right Horizontal Closed one fourth */
-		Frame(186, 197, 28, 67, 24, 41, 24, 0),	/* Right Horizontal Closed half */
-		Frame(180, 197, 28, 67, 24, 41, 24, 0)	/* Right Horizontal Closed three fourth */
+												Frame(150, 197, 28, 67, 24, 41, 0, 0),	/* Closed Or Destroyed */
+												Frame(150, 197, 28, 38, 24, 41, 0, 30),	/* Vertical Closed one fourth */
+												Frame(150, 197, 28, 48, 24, 41, 0, 20),	/* Vertical Closed half */
+												Frame(150, 197, 28, 58, 24, 41, 0, 10),	/* Vertical Closed three fourth */
+												Frame(150, 153, 28, 67, 24, 41, 18, 0),	/* Left Horizontal Closed one fourth */
+												Frame(150, 161, 28, 67, 24, 41, 12, 0),	/* Left Horizontal Closed half */
+												Frame(150, 167, 28, 67, 24, 41, 6, 0),	/* Left Horizontal Closed three fourth */
+												Frame(192, 197, 28, 67, 24, 41, 24, 0),	/* Right Horizontal Closed one fourth */
+												Frame(186, 197, 28, 67, 24, 41, 24, 0),	/* Right Horizontal Closed half */
+												Frame(180, 197, 28, 67, 24, 41, 24, 0)	/* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
@@ -1322,16 +1353,16 @@ void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 	static Frame frameFloorPitD3C = Frame(64, 159, 66, 73, 48, 8, 0, 0); // @ G0141_s_Graphic558_Frame_FloorPit_D3C
 	static DoorFrames doorFrameD3C = DoorFrames( // @ G0180_s_Graphic558_Frames_Door_D3C
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(88, 135, 28, 67, 24, 41, 0, 0),		/* Closed Or Destroyed */
-		Frame(88, 135, 28, 38, 24, 41, 0, 30),		/* Vertical Closed one fourth */
-		Frame(88, 135, 28, 48, 24, 41, 0, 20),		/* Vertical Closed half */
-		Frame(88, 135, 28, 58, 24, 41, 0, 10),		/* Vertical Closed three fourth */
-		Frame(88, 93, 28, 67, 24, 41, 18, 0),		/* Left Horizontal Closed one fourth */
-		Frame(88, 99, 28, 67, 24, 41, 12, 0),		/* Left Horizontal Closed half */
-		Frame(88, 105, 28, 67, 24, 41, 6, 0),		/* Left Horizontal Closed three fourth */
-		Frame(130, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed one fourth */
-		Frame(124, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed half */
-		Frame(118, 135, 28, 67, 24, 41, 24, 0)		/* Right Horizontal Closed three fourth */
+												Frame(88, 135, 28, 67, 24, 41, 0, 0),		/* Closed Or Destroyed */
+												Frame(88, 135, 28, 38, 24, 41, 0, 30),		/* Vertical Closed one fourth */
+												Frame(88, 135, 28, 48, 24, 41, 0, 20),		/* Vertical Closed half */
+												Frame(88, 135, 28, 58, 24, 41, 0, 10),		/* Vertical Closed three fourth */
+												Frame(88, 93, 28, 67, 24, 41, 18, 0),		/* Left Horizontal Closed one fourth */
+												Frame(88, 99, 28, 67, 24, 41, 12, 0),		/* Left Horizontal Closed half */
+												Frame(88, 105, 28, 67, 24, 41, 6, 0),		/* Left Horizontal Closed three fourth */
+												Frame(130, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed one fourth */
+												Frame(124, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed half */
+												Frame(118, 135, 28, 67, 24, 41, 24, 0)		/* Right Horizontal Closed three fourth */
 	);
 
 	uint16 squareAspect[5];
@@ -1392,16 +1423,16 @@ void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 	static Frame FrameCeilingPitD2L = Frame(0, 79, 19, 23, 40, 5, 0, 0); // @ G0152_s_Graphic558_Frame_CeilingPit_D2L
 	static DoorFrames doorFrameD2L = DoorFrames( // @ G0182_s_Graphic558_Frames_Door_D2L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(0, 63, 24, 82, 32, 61, 0, 0),	/* Closed Or Destroyed */
-		Frame(0, 63, 24, 39, 32, 61, 0, 45),   /* Vertical Closed one fourth */
-		Frame(0, 63, 24, 54, 32, 61, 0, 30),   /* Vertical Closed half */
-		Frame(0, 63, 24, 69, 32, 61, 0, 15),   /* Vertical Closed three fourth */
-		Frame(0, 7, 24, 82, 32, 61, 24, 0),    /* Left Horizontal Closed one fourth */
-		Frame(0, 15, 24, 82, 32, 61, 16, 0),   /* Left Horizontal Closed half */
-		Frame(0, 23, 24, 82, 32, 61, 8, 0),    /* Left Horizontal Closed three fourth */
-		Frame(56, 63, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed one fourth */
-		Frame(48, 63, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed half */
-		Frame(40, 63, 24, 82, 32, 61, 32, 0)   /* Right Horizontal Closed three fourth */
+												Frame(0, 63, 24, 82, 32, 61, 0, 0),	/* Closed Or Destroyed */
+												Frame(0, 63, 24, 39, 32, 61, 0, 45),   /* Vertical Closed one fourth */
+												Frame(0, 63, 24, 54, 32, 61, 0, 30),   /* Vertical Closed half */
+												Frame(0, 63, 24, 69, 32, 61, 0, 15),   /* Vertical Closed three fourth */
+												Frame(0, 7, 24, 82, 32, 61, 24, 0),    /* Left Horizontal Closed one fourth */
+												Frame(0, 15, 24, 82, 32, 61, 16, 0),   /* Left Horizontal Closed half */
+												Frame(0, 23, 24, 82, 32, 61, 8, 0),    /* Left Horizontal Closed three fourth */
+												Frame(56, 63, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed one fourth */
+												Frame(48, 63, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed half */
+												Frame(40, 63, 24, 82, 32, 61, 32, 0)   /* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
@@ -1464,16 +1495,16 @@ void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
 	static Frame frameCeilingPitD2R = Frame(144, 223, 19, 23, 40, 5, 0, 0); // @ G0154_s_Graphic558_Frame_CeilingPit_D2R
 	static DoorFrames g184_doorFrame_D2R = DoorFrames( // @ G0184_s_Graphic558_Frames_Door_D2R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(160, 223, 24, 82, 32, 61, 0, 0),	/* Closed Or Destroyed */
-		Frame(160, 223, 24, 39, 32, 61, 0, 45),	/* Vertical Closed one fourth */
-		Frame(160, 223, 24, 54, 32, 61, 0, 30),	/* Vertical Closed half */
-		Frame(160, 223, 24, 69, 32, 61, 0, 15),	/* Vertical Closed three fourth */
-		Frame(160, 167, 24, 82, 32, 61, 24, 0),	/* Left Horizontal Closed one fourth */
-		Frame(160, 175, 24, 82, 32, 61, 16, 0),	/* Left Horizontal Closed half */
-		Frame(160, 183, 24, 82, 32, 61, 8, 0),	/* Left Horizontal Closed three fourth */
-		Frame(216, 223, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed one fourth */
-		Frame(208, 223, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed half */
-		Frame(200, 223, 24, 82, 32, 61, 32, 0)		/* Right Horizontal Closed three fourth */
+													  Frame(160, 223, 24, 82, 32, 61, 0, 0),	/* Closed Or Destroyed */
+													  Frame(160, 223, 24, 39, 32, 61, 0, 45),	/* Vertical Closed one fourth */
+													  Frame(160, 223, 24, 54, 32, 61, 0, 30),	/* Vertical Closed half */
+													  Frame(160, 223, 24, 69, 32, 61, 0, 15),	/* Vertical Closed three fourth */
+													  Frame(160, 167, 24, 82, 32, 61, 24, 0),	/* Left Horizontal Closed one fourth */
+													  Frame(160, 175, 24, 82, 32, 61, 16, 0),	/* Left Horizontal Closed half */
+													  Frame(160, 183, 24, 82, 32, 61, 8, 0),	/* Left Horizontal Closed three fourth */
+													  Frame(216, 223, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed one fourth */
+													  Frame(208, 223, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed half */
+													  Frame(200, 223, 24, 82, 32, 61, 32, 0)		/* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
@@ -1539,16 +1570,16 @@ void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 	static Frame frameCeilingPitD2C = Frame(64, 159, 19, 23, 48, 5, 0, 0); // @ G0153_s_Graphic558_Frame_CeilingPit_D2C
 	static DoorFrames doorFrameD2C = DoorFrames( // @ G0183_s_Graphic558_Frames_Door_D2C
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(80, 143, 24, 82, 32, 61, 0, 0),    /* Closed Or Destroyed */
-		Frame(80, 143, 24, 39, 32, 61, 0, 45),   /* Vertical Closed one fourth */
-		Frame(80, 143, 24, 54, 32, 61, 0, 30),   /* Vertical Closed half */
-		Frame(80, 143, 24, 69, 32, 61, 0, 15),   /* Vertical Closed three fourth */
-		Frame(80, 87, 24, 82, 32, 61, 24, 0),    /* Left Horizontal Closed one fourth */
-		Frame(80, 95, 24, 82, 32, 61, 16, 0),    /* Left Horizontal Closed half */
-		Frame(80, 103, 24, 82, 32, 61, 8, 0),    /* Left Horizontal Closed three fourth */
-		Frame(136, 143, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed one fourth */
-		Frame(128, 143, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed half */
-		Frame(120, 143, 24, 82, 32, 61, 32, 0)   /* Right Horizontal Closed three fourth */
+												Frame(80, 143, 24, 82, 32, 61, 0, 0),    /* Closed Or Destroyed */
+												Frame(80, 143, 24, 39, 32, 61, 0, 45),   /* Vertical Closed one fourth */
+												Frame(80, 143, 24, 54, 32, 61, 0, 30),   /* Vertical Closed half */
+												Frame(80, 143, 24, 69, 32, 61, 0, 15),   /* Vertical Closed three fourth */
+												Frame(80, 87, 24, 82, 32, 61, 24, 0),    /* Left Horizontal Closed one fourth */
+												Frame(80, 95, 24, 82, 32, 61, 16, 0),    /* Left Horizontal Closed half */
+												Frame(80, 103, 24, 82, 32, 61, 8, 0),    /* Left Horizontal Closed three fourth */
+												Frame(136, 143, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed one fourth */
+												Frame(128, 143, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed half */
+												Frame(120, 143, 24, 82, 32, 61, 32, 0)   /* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
@@ -1611,16 +1642,16 @@ void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
 	static Frame frameCeilingPitD1L = Frame(0, 63, 8, 16, 32, 9, 0, 0); // @ G0155_s_Graphic558_Frame_CeilingPit_D1L
 	static DoorFrames doorFrameD1L = DoorFrames( // @ G0185_s_Graphic558_Frames_Door_D1L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(0, 31, 17, 102, 48, 88, 64, 0),	/* Closed Or Destroyed */
-		Frame(0, 31, 17, 38, 48, 88, 64, 66),	/* Vertical Closed one fourth */
-		Frame(0, 31, 17, 60, 48, 88, 64, 44),	/* Vertical Closed half */
-		Frame(0, 31, 17, 82, 48, 88, 64, 22),	/* Vertical Closed three fourth */
-		Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed one fourth */
-		Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed half */
-		Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed three fourth */
-		Frame(20, 31, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed one fourth */
-		Frame(8, 31, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed half */
-		Frame(0, 31, 17, 102, 48, 88, 52, 0)	/* Right Horizontal Closed three fourth */
+												Frame(0, 31, 17, 102, 48, 88, 64, 0),	/* Closed Or Destroyed */
+												Frame(0, 31, 17, 38, 48, 88, 64, 66),	/* Vertical Closed one fourth */
+												Frame(0, 31, 17, 60, 48, 88, 64, 44),	/* Vertical Closed half */
+												Frame(0, 31, 17, 82, 48, 88, 64, 22),	/* Vertical Closed three fourth */
+												Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed one fourth */
+												Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed half */
+												Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed three fourth */
+												Frame(20, 31, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed one fourth */
+												Frame(8, 31, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed half */
+												Frame(0, 31, 17, 102, 48, 88, 52, 0)	/* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
@@ -1685,16 +1716,16 @@ void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {
 	static Frame frameCeilingPitD1R = Frame(160, 223, 8, 16, 32, 9, 0, 0); // @ G0157_s_Graphic558_Frame_CeilingPit_D1R
 	static DoorFrames doorFrameD1R = DoorFrames( // @ G0187_s_Graphic558_Frames_Door_D1R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-		Frame(192, 223, 17, 102, 48, 88, 0, 0),   /* Closed Or Destroyed */
-		Frame(192, 223, 17, 38, 48, 88, 0, 66),   /* Vertical Closed one fourth */
-		Frame(192, 223, 17, 60, 48, 88, 0, 44),   /* Vertical Closed half */
-		Frame(192, 223, 17, 82, 48, 88, 0, 22),   /* Vertical Closed three fourth */
-		Frame(192, 203, 17, 102, 48, 88, 36, 0),  /* Left Horizontal Closed one fourth */
-		Frame(192, 215, 17, 102, 48, 88, 24, 0),  /* Left Horizontal Closed half */
-		Frame(192, 223, 17, 102, 48, 88, 12, 0),  /* Left Horizontal Closed three fourth */
-		Frame(0, 0, 0, 0, 0, 0, 0, 0),            /* Right Horizontal Closed one fourth */
-		Frame(0, 0, 0, 0, 0, 0, 0, 0),            /* Right Horizontal Closed half */
-		Frame(0, 0, 0, 0, 0, 0, 0, 0)             /* Right Horizontal Closed three fourth */
+												Frame(192, 223, 17, 102, 48, 88, 0, 0),   /* Closed Or Destroyed */
+												Frame(192, 223, 17, 38, 48, 88, 0, 66),   /* Vertical Closed one fourth */
+												Frame(192, 223, 17, 60, 48, 88, 0, 44),   /* Vertical Closed half */
+												Frame(192, 223, 17, 82, 48, 88, 0, 22),   /* Vertical Closed three fourth */
+												Frame(192, 203, 17, 102, 48, 88, 36, 0),  /* Left Horizontal Closed one fourth */
+												Frame(192, 215, 17, 102, 48, 88, 24, 0),  /* Left Horizontal Closed half */
+												Frame(192, 223, 17, 102, 48, 88, 12, 0),  /* Left Horizontal Closed three fourth */
+												Frame(0, 0, 0, 0, 0, 0, 0, 0),            /* Right Horizontal Closed one fourth */
+												Frame(0, 0, 0, 0, 0, 0, 0, 0),            /* Right Horizontal Closed half */
+												Frame(0, 0, 0, 0, 0, 0, 0, 0)             /* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 2d4ae4e..b8b31f0 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -552,6 +552,8 @@ class DisplayMan {
 	DMEngine *_vm;
 
 	uint16 _grapItemCount; // @ G0632_ui_GraphicCount
+	uint32 *_bitmapCompressedByteCount;
+	uint32 *_bitmapDecompressedByteCount;
 	uint32 *_packedItemPos;
 	byte *_packedBitmaps;
 	byte **_bitmaps;


Commit: 0eb61d0a7d1450ca79adfe8ef4bd3874de51ce67
    https://github.com/scummvm/scummvm/commit/0eb61d0a7d1450ca79adfe8ef4bd3874de51ce67
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Pull sound handling into a separate class

Changed paths:
  A engines/dm/sounds.h
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/eventman.cpp
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/projexpl.cpp
    engines/dm/sounds.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 9171d4f..94d2046 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -36,6 +36,7 @@
 #include "projexpl.h"
 #include "group.h"
 #include "movesens.h"
+#include "sounds.h"
 
 
 namespace DM {
@@ -172,7 +173,7 @@ bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16
 			return false;
 	}
 
-	_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 	f325_decrementStamina(champIndex, f305_getThrowingStaminaCost(curThing));
 	f330_disableAction(champIndex, 4);
 	int16 experience = 8;
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 67e1185..19003bb 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -57,6 +57,7 @@
 #include "dialog.h"
 #include <graphics/cursorman.h>
 #include <advancedDetector.h>
+#include "sounds.h"
 
 namespace DM {
 void warning(bool repeat, const char* s, ...) {
@@ -168,6 +169,7 @@ DMEngine::DMEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst),
 	_timeline = nullptr;
 	_projexpl = nullptr;
 	_displayMan = nullptr;
+	_sound = nullptr;
 
 	_engineShouldQuit = false;
 	_g528_saveFormat = 0;
@@ -220,9 +222,9 @@ DMEngine::~DMEngine() {
 	delete _timeline;
 	delete _projexpl;
 	delete _dialog;
+	delete _sound;
 
-	for (uint16 i = 0; i < k34_D13_soundCount; ++i)
-		delete[] _gK24_soundData[i]._firstSample;
+	
 
 	delete[] _savedScreenForOpenEntranceDoors;
 	// clear debug channels
@@ -254,7 +256,7 @@ void DMEngine::f463_initializeGame() {
 	_displayMan->f94_loadFloorSet(k0_FloorSetStone);
 	_displayMan->f95_loadWallSet(k0_WallSetStone);
 
-	f503_loadSounds(); // @ F0506_AMIGA_AllocateData
+	_sound->f503_loadSounds(); // @ F0506_AMIGA_AllocateData
 
 	f437_STARTEND_drawTittle();
 	_textMan->f54_textInitialize();
@@ -359,6 +361,7 @@ Common::Error DMEngine::run() {
 	_timeline = new Timeline(this);
 	_projexpl = new ProjExpl(this);
 	_dialog = new DialogMan(this);
+	_sound = new SoundMan(this);
 	_displayMan->setUpScreens(320, 200);
 
 	f463_initializeGame();
@@ -432,7 +435,7 @@ void DMEngine::f2_gameloop() {
 			}
 		}
 		_eventMan->f363_highlightBoxDisable();
-		f65_playPendingSound();
+		_sound->f65_playPendingSound();
 		_championMan->f320_applyAndDrawPendingDamageAndWounds();
 		if (_championMan->_g303_partyDead)
 			break;
@@ -542,7 +545,7 @@ void DMEngine::f441_processEntrance() {
 	} while (_g298_newGame == k202_CommandEntranceDrawCredits);
 
 	//Strangerke: CHECKME: Earlier versions were using G0566_puc_Graphic534_Sound01Switch
-	f060_SOUND_Play(k01_soundSWITCH, 112, 0x40, 0x40);
+	_sound->f060_SOUND_Play(k01_soundSWITCH, 112, 0x40, 0x40);
 	f22_delay(20);
 	_eventMan->f78_showMouse();
 	if (_g298_newGame)
@@ -595,7 +598,7 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 	_eventMan->_g443_primaryKeyboardInput = nullptr;
 	_eventMan->_g444_secondaryKeyboardInput = nullptr;
 	if (doNotDrawCreditsOnly && !_g302_gameWon) {
-		f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
+		_sound->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
 		f22_delay(240);
 	}
 
@@ -784,7 +787,7 @@ void DMEngine::f438_STARTEND_OpenEntranceDoors() {
 	for (uint16 animStep = 1; animStep < 32; ++animStep) {
 		if ((animStep % 3) == 1) {
 			// Strangerke: CHECKME: Earlier versions of the game were using G0565_puc_Graphic535_Sound02DoorRattle instead of k02_soundDOOR_RATTLE 2
-			f060_SOUND_Play(k02_soundDOOR_RATTLE, 145, 0x40, 0x40);
+			_sound->f060_SOUND_Play(k02_soundDOOR_RATTLE, 145, 0x40, 0x40);
 		}
 
 		_displayMan->f21_blitToScreen(_savedScreenForOpenEntranceDoors, &screenBox, 160, kM1_ColorNoTransparency, 200);
@@ -889,7 +892,7 @@ T0446002:
 		_projexpl->f213_explosionCreate(Thing::_explFireBall, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
 		f445_STARTEND_fuseSequenceUpdate();
 	}
-	f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized);
+	_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized);
 	L1428_ps_Group->_type = k25_CreatureTypeLordOrder;
 	f445_STARTEND_fuseSequenceUpdate();
 	for (AL1424_i_Attack = 55; AL1424_i_Attack <= 255; AL1424_i_Attack += 40) {
@@ -898,7 +901,7 @@ T0446002:
 	}
 	for (AL1425_i_CycleCount = 4; --AL1425_i_CycleCount; ) {
 		for (AL1424_i_CreatureTypeSwitchCount = 5; --AL1424_i_CreatureTypeSwitchCount; ) {
-			f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized);
+			_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized);
 			L1428_ps_Group->_type = (AL1424_i_CreatureTypeSwitchCount & 0x0001) ? k25_CreatureTypeLordOrder : k23_CreatureTypeLordChaos;
 			for (AL1426_i_FuseSequenceUpdateCount = AL1425_i_CycleCount; AL1426_i_FuseSequenceUpdateCount--; f445_STARTEND_fuseSequenceUpdate());
 		}
@@ -957,7 +960,7 @@ T0446002:
 void DMEngine::f445_STARTEND_fuseSequenceUpdate() {
 	_timeline->f261_processTimeline();
 	_displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
-	f65_playPendingSound();
+	_sound->f65_playPendingSound();
 	_eventMan->f357_discardAllInput();
 	_displayMan->updateScreen();
 	f22_delay(2);
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 85910ed..9b39f6e 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -54,6 +54,7 @@ class GroupMan;
 class Timeline;
 class ProjExpl;
 class DialogMan;
+class SoundMan;
 
 
 void warning(bool repeat, const char *s, ...);
@@ -202,36 +203,6 @@ struct SaveGameHeader {
 };
 
 
-#define k34_D13_soundCount 34 // @ D13_SOUND_COUNT
-
-class SoundData {
-public:
-	uint32 _byteCount;
-	byte* _firstSample;
-	uint32 _sampleCount;
-	SoundData(): _byteCount(0), _firstSample(nullptr), _sampleCount(0) {}
-}; // @ SOUND_DATA
-
-class Sound {
-public:
-	int16 _graphicIndex;
-	byte _period;
-	byte _priority;
-	byte _loudDistance;
-	byte _softDistance;
-	Sound(int16 index, byte period, byte priority, byte loudDist, byte softDist) :
-		_graphicIndex(index), _period(period), _priority(priority), _loudDistance(loudDist), _softDistance(softDist) {}
-}; // @ Sound
-
-class PendingSound {
-public:
-	uint8 _leftVolume;
-	uint8 _rightVolume;
-	int16 _soundIndex;
-	PendingSound(uint8 leftVolume, uint8 rightVolume, int16 soundIndex):
-		_leftVolume(leftVolume), _rightVolume(rightVolume), _soundIndex(soundIndex) {}
-};
-
 class DMEngine : public Engine {
 	void f462_startGame(); // @ F0462_START_StartGame_CPSF
 	void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
@@ -243,7 +214,6 @@ class DMEngine : public Engine {
 	void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
 	bool readSaveGameHeader(Common::InSaveFile *file, SaveGameHeader *header);
 	void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance
-	void f503_loadSounds(); // @ F0503_SOUND_LoadAll
 public:
 	explicit DMEngine(OSystem *syst, const ADGameDescription *gameDesc);
 	~DMEngine();
@@ -262,10 +232,6 @@ public:
 	void f441_processEntrance(); // @ F0441_STARTEND_ProcessEntrance
 	void f444_endGame(bool doNotDrawCreditsOnly); // @ F0444_STARTEND_Endgame
 
-	void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode); // @ F0064_SOUND_RequestPlay_CPSD
-	void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol); // @ F0060_SOUND_Play
-	void f65_playPendingSound(); // @ F0065_SOUND_PlayPendingSound_CPSD
-	bool f505_soundGetVolume(int16 mapX, int16 mapY, uint8 *leftVolume, uint8 *rightVolume); // @ F0505_SOUND_GetVolume
 	void f438_STARTEND_OpenEntranceDoors(); // @ F0438_STARTEND_OpenEntranceDoors
 	void f437_STARTEND_drawTittle() { warning(false, "STUB METHOD: f437_STARTEND_drawTittle"); }// @ F0437_STARTEND_DrawTitle
 	void f442_SARTEND_processCommand202_entranceDrawCredits();
@@ -280,8 +246,7 @@ private:
 	byte *_g562_entranceDoorAnimSteps[10]; // @ G0562_apuc_Bitmap_EntranceDoorAnimationSteps
 	byte *_g564_interfaceCredits; // @ G0564_puc_Graphic5_InterfaceCredits
 	Common::RandomSource *_rnd;
-	SoundData _gK24_soundData[k34_D13_soundCount]; // @ K0024_as_SoundData
-	Common::Queue<PendingSound> _pendingSounds;
+	
 	byte *_savedScreenForOpenEntranceDoors; // ad-hoc HACK
 	const ADGameDescription *_gameVersion;
 public:
@@ -299,6 +264,7 @@ public:
 	Timeline *_timeline;
 	ProjExpl *_projexpl;
 	DialogMan *_dialog;
+	SoundMan *_sound;
 
 
 	bool _engineShouldQuit;
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index e4eaa94..0f7c120 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -39,6 +39,7 @@
 #include "text.h"
 #include "group.h"
 #include "dialog.h"
+#include "sounds.h"
 
 
 namespace DM {
@@ -940,7 +941,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 				damage |= _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
 
 			if (damage)
-				_vm->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, partyMapX, partyMapY, k0_soundModePlayImmediately);
+				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, partyMapX, partyMapY, k0_soundModePlayImmediately);
 		} else if (isMovementBlocked = (_vm->_groupMan->f175_groupGetThing(partyMapX, partyMapY) != Thing::_endOfList))
 			_vm->_groupMan->f209_processEvents29to41(partyMapX, partyMapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
 	}
@@ -1075,7 +1076,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 			Junk *junkPtr = (Junk*)_vm->_dungeonMan->f157_getSquareFirstThingData(L1155_i_MapX, L1156_i_MapY);
 			if ((((Door*)junkPtr)->hasButton()) && _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
 				_vm->_g321_stopWaitingForPlayerInput = true;
-				_vm->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 				_vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1);
 				return;
 			}
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index e5c74fe..17cd8d8 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -33,6 +33,7 @@
 #include "timeline.h"
 #include "objectman.h"
 #include "menus.h"
+#include "sounds.h"
 
 
 namespace DM {
@@ -147,7 +148,7 @@ void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThin
 			_vm->_moveSens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
 		} while ((L0365_T_CurrentThing = L0366_T_NextThing) != Thing::_endOfList);
 		if (mode >= k0_soundModePlayImmediately) {
-			_vm->f064_SOUND_RequestPlay_CPSD(L0371_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
+			_vm->_sound->f064_SOUND_RequestPlay_CPSD(L0371_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
 		}
 	}
 }
@@ -258,7 +259,7 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX
 		L0358_T_Thing = M15_thingWithNewCell(L0358_T_Thing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell);
 		_vm->_moveSens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY);
 	}
-	_vm->f064_SOUND_RequestPlay_CPSD(L0362_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
+	_vm->_sound->f064_SOUND_RequestPlay_CPSD(L0362_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
 }
 
 int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
@@ -890,7 +891,7 @@ T0209089_DoubleSquareMove:
 							AL0450_i_DestinationMapX = eventMapX;
 							AL0451_i_DestinationMapY = eventMapY;
 							AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2;
-							_vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY, k1_soundModePlayIfPrioritized);
+							_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY, k1_soundModePlayIfPrioritized);
 							goto T0209061_MoveGroup;
 						}
 					}
@@ -1271,7 +1272,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 				if (getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) && (L0331_ui_CreatureType == k18_CreatureTypeAnimatedArmourDethKnight)) {
 					if (_vm->getRandomNumber(2)) {
 						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-						_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized);
+						_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized);
 					}
 				} else {
 					if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) {
@@ -1293,7 +1294,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
 						L1635_ui_SoundIndex = _vm->_moveSens->f514_getSound(k13_CreatureTypeCouatl);
 						if (L1635_ui_SoundIndex <= k34_D13_soundCount) {
-							_vm->f064_SOUND_RequestPlay_CPSD(L1635_ui_SoundIndex, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized);
+							_vm->_sound->f064_SOUND_RequestPlay_CPSD(L1635_ui_SoundIndex, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized);
 						}
 					}
 				} else {
@@ -1487,7 +1488,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 		AL0440_i_KineticEnergy = (L0441_ps_CreatureInfo->_attack >> 2) + 1;
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
-		_vm->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, mapX, mapY, k0_soundModePlayImmediately);
+		_vm->_sound->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, mapX, mapY, k0_soundModePlayImmediately);
 		_vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (Direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
 	} else {
 		if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) {
@@ -1515,7 +1516,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 		}
 	}
 	if (AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal) {
-		_vm->f064_SOUND_RequestPlay_CPSD(G0244_auc_Graphic559_CreatureAttackSounds[--AL0440_i_AttackSoundOrdinal], mapX, mapY, k1_soundModePlayIfPrioritized);
+		_vm->_sound->f064_SOUND_RequestPlay_CPSD(G0244_auc_Graphic559_CreatureAttackSounds[--AL0440_i_AttackSoundOrdinal], mapX, mapY, k1_soundModePlayIfPrioritized);
 	}
 	return true;
 }
@@ -1638,7 +1639,7 @@ int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) {
 			AL0558_i_Attack -= _vm->getRandomNumber((AL0558_i_Attack >> 1) + 1) - 1;
 		}
 		if (AL0558_i_Damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType)) {
-			_vm->f064_SOUND_RequestPlay_CPSD(k09_soundCHAMPION_0_DAMAGED + champIndex, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater);
+			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k09_soundCHAMPION_0_DAMAGED + champIndex, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater);
 			if ((AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack) && _vm->getRandomNumber(2) && ((AL0559_ui_PoisonAttack = _vm->_championMan->f307_getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack)) >= 0)) {
 				_vm->_championMan->f322_championPoison(champIndex, AL0559_ui_PoisonAttack);
 			}
@@ -1807,7 +1808,7 @@ Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplie
 	if (_vm->_moveSens->f267_getMoveResult(L0349_T_GroupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) { /* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile impact (in which case the thing data was marked as unused) or the party is on the destination square and an event is created to move the creature into the dungeon later (in which case the thing is referenced in the event) */
 		return Thing::_none;
 	}
-	_vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, mapX, mapY, k1_soundModePlayIfPrioritized);
+	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, mapX, mapY, k1_soundModePlayIfPrioritized);
 	return L0349_T_GroupThing;
 }
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index bbc451d..638fba2 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -34,6 +34,7 @@
 #include "objectman.h"
 #include "timeline.h"
 #include "projexpl.h"
+#include "sounds.h"
 
 
 namespace DM {
@@ -1038,7 +1039,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 		_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(L1078_T_Thing) - L1089_ui_Weight;
 		setFlag(_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
 	}
-	_vm->f064_SOUND_RequestPlay_CPSD(k08_soundSWALLOW, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
+	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k08_soundSWALLOW, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
 	setFlag(L1083_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
 	if (_g424_panelContent == k0_PanelContentFoodWaterPoisoned) {
 		setFlag(L1083_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 73a567a..53d5040 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -37,6 +37,7 @@
 #include "movesens.h"
 #include "group.h"
 #include "projexpl.h"
+#include "sounds.h"
 
 
 namespace DM {
@@ -1116,10 +1117,10 @@ T0407014:
 	case k13_ChampionActionSwing:
 	case k2_ChampionActionChop:
 		if ((Square(AL1244_ui_TargetSquare).getType() == k4_DoorElemType) && (Square(AL1244_ui_TargetSquare).getDoorState() == k4_doorState_CLOSED)) {
-			_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 			L1249_ui_ActionDisabledTicks = 6;
 			_vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
-			_vm->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater);
+			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater);
 			break;
 		}
 	case k24_ChampionActionDisrupt:
@@ -1145,10 +1146,10 @@ T0407014:
 	case k41_ChampionActionBrandish:
 	case k4_ChampionActionBlowHorn:
 		if (actionIndex == k8_ChampionActionWarCry) {
-			_vm->f064_SOUND_RequestPlay_CPSD(k28_soundWAR_CRY, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
+			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k28_soundWAR_CRY, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
 		}
 		if (actionIndex == k4_ChampionActionBlowHorn) {
-			_vm->f064_SOUND_RequestPlay_CPSD(k25_soundBLOW_HORN, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
+			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k25_soundBLOW_HORN, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
 		}
 		AL1245_B_ActionPerformed = f401_isGroupFrightenedByAction(champIndex, actionIndex, L1251_i_MapX, L1252_i_MapY);
 		break;
@@ -1178,7 +1179,7 @@ T0407032:
 		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
 		{ // so gotos won't skip init
 			Thing AL1250_T_Object = _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
-			_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 			_vm->_championMan->f326_championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->f303_getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy);
 		}
 		break;
@@ -1451,7 +1452,7 @@ bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int
 #define AL1237_ui_ActionHitProbability L1237_ui_Multiple
 	int16 L1238_i_CreatureOrdinal;
 
-	_vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 	if (_g517_actionTargetGroupThing == Thing::_endOfList)
 		goto T0402010;
 	if (L1238_i_CreatureOrdinal = _vm->_groupMan->f177_getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, AL1236_ui_ChampionCell = champ->_cell)) {
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 1011b42..57bd51f 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -35,6 +35,7 @@
 #include "group.h"
 #include "projexpl.h"
 #include "text.h"
+#include "sounds.h"
 
 
 namespace DM {
@@ -181,7 +182,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 			if (!L0753_B_DoNotTriggerSensor) {
 				L0759_B_AtLeastOneSensorWasTriggered = true;
 				if (L0755_ps_Sensor->getAudibleA()) {
-					_vm->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+					_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 				}
 				if (!_vm->_championMan->_g415_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
 					L0754_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0761_T_LeaderHandObject);
@@ -299,7 +300,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					_vm->_dungeonMan->_g306_partyMapX = destMapX;
 					_vm->_dungeonMan->_g307_partyMapY = destMapY;
 					if (L0712_ps_Teleporter->isAudible()) {
-						_vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
+						_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
 					}
 					L0723_B_DrawDungeonViewWhileFalling = true;
 					if (L0712_ps_Teleporter->getAbsoluteRotation()) {
@@ -310,7 +311,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				} else {
 					if (L0710_i_ThingType == k4_GroupThingType) {
 						if (L0712_ps_Teleporter->isAudible()) {
-							_vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, destMapX, destMapY, k1_soundModePlayIfPrioritized);
+							_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, destMapX, destMapY, k1_soundModePlayIfPrioritized);
 						}
 						L0720_ui_MoveGroupResult = f262_getTeleporterRotatedGroupResult(L0712_ps_Teleporter, thing, L0714_ui_MapIndexSource);
 					} else {
@@ -352,7 +353,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 								}
 							} else {
 								if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF)) {
-									_vm->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
+									_vm->_sound->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
 								}
 							}
 						}
@@ -480,7 +481,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				}
 				L1638_ui_MovementSoundIndex = f514_getSound(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[thing.getIndex()]._type);
 				if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) {
-					_vm->f064_SOUND_RequestPlay_CPSD(L1638_ui_MovementSoundIndex, destMapX, destMapY, k1_soundModePlayIfPrioritized);
+					_vm->_sound->f064_SOUND_RequestPlay_CPSD(L1638_ui_MovementSoundIndex, destMapX, destMapY, k1_soundModePlayIfPrioritized);
 				}
 				if (L0721_B_GroupOnPartyMap && (L0715_ui_MapIndexDestination != _vm->_dungeonMan->_g309_partyMapIndex)) { /* If the group leaves the party map */
 					_vm->_groupMan->f184_removeActiveGroup(AL0708_i_ActiveGroupIndex);
@@ -898,7 +899,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 					goto T0276079;
 			}
 			if (L0769_ps_Sensor->getAudibleA()) {
-				_vm->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized);
+				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized);
 			}
 			f272_sensorTriggerEffect(L0769_ps_Sensor, L0778_i_Effect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
 			goto T0276079;
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 937e144..b65e03a 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -32,6 +32,7 @@
 #include "group.h"
 #include "objectman.h"
 #include "movesens.h"
+#include "sounds.h"
 
 namespace DM {
 
@@ -230,7 +231,7 @@ T0217004:
 				AL0507_ui_SoundIndex = k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM;
 			}
 		}
-		_vm->f064_SOUND_RequestPlay_CPSD(AL0507_ui_SoundIndex, L0499_i_ProjectileMapX, L0500_i_ProjectileMapY, k1_soundModePlayIfPrioritized);
+		_vm->_sound->f064_SOUND_RequestPlay_CPSD(AL0507_ui_SoundIndex, L0499_i_ProjectileMapX, L0500_i_ProjectileMapY, k1_soundModePlayIfPrioritized);
 	}
 T0217044:
 	if (L0509_B_RemovePotion) {
@@ -321,10 +322,10 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 	L0470_ps_Explosion->setType(explThing.toUint16() - Thing::_firstExplosion.toUint16());
 	L0470_ps_Explosion->setAttack(attack);
 	if (explThing.toUint16() < Thing::_explHarmNonMaterial.toUint16()) {
-		_vm->f064_SOUND_RequestPlay_CPSD((attack > 80) ? k05_soundSTRONG_EXPLOSION : k20_soundWEAK_EXPLOSION, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized);
+		_vm->_sound->f064_SOUND_RequestPlay_CPSD((attack > 80) ? k05_soundSTRONG_EXPLOSION : k20_soundWEAK_EXPLOSION, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized);
 	} else {
 		if (explThing != Thing::_explSmoke) {
-			_vm->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized);
+			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized);
 		}
 	}
 	_vm->_dungeonMan->f163_linkThingToList(L0473_T_Thing, Thing(0), AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY);
@@ -564,7 +565,7 @@ void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) {
 		break;
 	case 0xFFE4:
 		L0532_ps_Explosion->setType(L0532_ps_Explosion->getType() + 1);
-		_vm->f064_SOUND_RequestPlay_CPSD(k05_soundSTRONG_EXPLOSION, L0528_ui_MapX, L0529_ui_MapY, k1_soundModePlayIfPrioritized);
+		_vm->_sound->f064_SOUND_RequestPlay_CPSD(k05_soundSTRONG_EXPLOSION, L0528_ui_MapX, L0529_ui_MapY, k1_soundModePlayIfPrioritized);
 		goto T0220026;
 	case 0xFFA8:
 		if (L0532_ps_Explosion->getAttack() > 55) {
diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp
index b44e97b..c90409d 100644
--- a/engines/dm/sounds.cpp
+++ b/engines/dm/sounds.cpp
@@ -33,80 +33,86 @@
 #include <audio/mixer.h>
 #include "timeline.h"
 #include "dungeonman.h"
+#include "sounds.h"
 
 
 namespace DM {
 
+SoundMan::SoundMan(DMEngine* vm) : _vm(vm) {}
 
+SoundMan::~SoundMan() {
+	for (uint16 i = 0; i < k34_D13_soundCount; ++i)
+		delete[] _gK24_soundData[i]._firstSample;
+}
 
 Sound g60_sounds[k34_D13_soundCount] = {
-	Sound(533, 112,  11, 3, 6), /* k00_soundMETALLIC_THUD 0 */
-	Sound(534, 112,  15, 0, 3), /* k01_soundSWITCH 1 */
-	Sound(535, 112,  72, 3, 6), /* k02_soundDOOR_RATTLE 2 */
-	Sound(550, 112,  60, 3, 5), /* k03_soundATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON 3 */
-	Sound(536, 112,  10, 3, 6), /* k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM 4 */
-	Sound(537, 112,  99, 3, 7), /* k05_soundSTRONG_EXPLOSION 5 */
-	Sound(539, 112, 110, 3, 6), /* k06_soundSCREAM 6 */
-	Sound(551, 112,  55, 3, 5), /* k07_soundATTACK_MUMMY_GHOST_RIVE 7 */
-	Sound(540, 112,   2, 3, 6), /* k08_soundSWALLOW 8 */
-	Sound(541, 112,  80, 3, 6), /* k09_soundCHAMPION_0_DAMAGED 9 */
-	Sound(542, 112,  82, 3, 6), /* k10_soundCHAMPION_1_DAMAGED 10 */
-	Sound(543, 112,  84, 3, 6), /* k11_soundCHAMPION_2_DAMAGED 11 */
-	Sound(544, 112,  86, 3, 6), /* k12_soundCHAMPION_3_DAMAGED 12 */
-	Sound(545, 112,  95, 3, 6), /* k13_soundSPELL 13 */
-	Sound(552, 112,  57, 3, 5), /* k14_soundATTACK_SCREAMER_OITU 14 */
-	Sound(553, 112,  52, 3, 5), /* k15_soundATTACK_GIANT_SCORPION_SCORPION 15 */
-	Sound(546, 112,  40, 2, 4), /* k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT 16 */
-	Sound(547, 112,  70, 1, 4), /* k17_soundBUZZ 17 */
-	Sound(549, 138,  75, 3, 6), /* k18_soundPARTY_DAMAGED 18 */
-	Sound(554, 112,  50, 3, 5), /* k19_soundATTACK_MAGENTA_WORM_WORM 19 */
-	Sound(537, 112,  98, 0, 4), /* k20_soundWEAK_EXPLOSION 20 */
-	Sound(555, 112,  96, 2, 4), /* k21_soundATTACK_GIGGLER 21 */
-	Sound(563, 138,  24, 0, 4), /* k22_soundMOVE_ANIMATED_ARMOUR_DETH_KNIGHT 22 Atari ST: not present */
-	Sound(564, 138,  21, 0, 4), /* k23_soundMOVE_COUATL_GIANT_WASP_MUNCHER 23 Atari ST: not present */
-	Sound(565, 138,  23, 0, 4), /* k24_soundMOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON 24 Atari ST: not present */
-	Sound(566, 138, 105, 0, 4), /* k25_soundBLOW_HORN 25 Atari ST: not present */
-	Sound(567, 138,  27, 0, 4), /* k26_soundMOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU 26 Atari ST: not present */
-	Sound(568, 138,  28, 0, 4), /* k27_soundMOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL 27 Atari ST: not present */
-	Sound(569, 138, 106, 0, 4), /* k28_soundWAR_CRY 28 Atari ST: not present */
-	Sound(570, 138,  56, 0, 4), /* k29_soundATTACK_ROCK_ROCKPILE 29 Atari ST: not present */
-	Sound(571, 138,  58, 0, 4), /* k30_soundATTACK_WATER_ELEMENTAL 30 Atari ST: not present */
-	Sound(572, 112,  53, 0, 4), /* k31_soundATTACK_COUATL 31 Atari ST: not present */
-	Sound(573, 138,  29, 0, 4), /* k32_soundMOVE_RED_DRAGON 32 Atari ST: not present */
-	Sound(574, 150,  22, 0, 4)}; /* k33_soundMOVE_SKELETON 33 Atari ST: not present */
-
-void DMEngine::f503_loadSounds() {
+Sound(533, 112,  11, 3, 6), /* k00_soundMETALLIC_THUD 0 */
+Sound(534, 112,  15, 0, 3), /* k01_soundSWITCH 1 */
+Sound(535, 112,  72, 3, 6), /* k02_soundDOOR_RATTLE 2 */
+Sound(550, 112,  60, 3, 5), /* k03_soundATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON 3 */
+Sound(536, 112,  10, 3, 6), /* k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM 4 */
+Sound(537, 112,  99, 3, 7), /* k05_soundSTRONG_EXPLOSION 5 */
+Sound(539, 112, 110, 3, 6), /* k06_soundSCREAM 6 */
+Sound(551, 112,  55, 3, 5), /* k07_soundATTACK_MUMMY_GHOST_RIVE 7 */
+Sound(540, 112,   2, 3, 6), /* k08_soundSWALLOW 8 */
+Sound(541, 112,  80, 3, 6), /* k09_soundCHAMPION_0_DAMAGED 9 */
+Sound(542, 112,  82, 3, 6), /* k10_soundCHAMPION_1_DAMAGED 10 */
+Sound(543, 112,  84, 3, 6), /* k11_soundCHAMPION_2_DAMAGED 11 */
+Sound(544, 112,  86, 3, 6), /* k12_soundCHAMPION_3_DAMAGED 12 */
+Sound(545, 112,  95, 3, 6), /* k13_soundSPELL 13 */
+Sound(552, 112,  57, 3, 5), /* k14_soundATTACK_SCREAMER_OITU 14 */
+Sound(553, 112,  52, 3, 5), /* k15_soundATTACK_GIANT_SCORPION_SCORPION 15 */
+Sound(546, 112,  40, 2, 4), /* k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT 16 */
+Sound(547, 112,  70, 1, 4), /* k17_soundBUZZ 17 */
+Sound(549, 138,  75, 3, 6), /* k18_soundPARTY_DAMAGED 18 */
+Sound(554, 112,  50, 3, 5), /* k19_soundATTACK_MAGENTA_WORM_WORM 19 */
+Sound(537, 112,  98, 0, 4), /* k20_soundWEAK_EXPLOSION 20 */
+Sound(555, 112,  96, 2, 4), /* k21_soundATTACK_GIGGLER 21 */
+Sound(563, 138,  24, 0, 4), /* k22_soundMOVE_ANIMATED_ARMOUR_DETH_KNIGHT 22 Atari ST: not present */
+Sound(564, 138,  21, 0, 4), /* k23_soundMOVE_COUATL_GIANT_WASP_MUNCHER 23 Atari ST: not present */
+Sound(565, 138,  23, 0, 4), /* k24_soundMOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON 24 Atari ST: not present */
+Sound(566, 138, 105, 0, 4), /* k25_soundBLOW_HORN 25 Atari ST: not present */
+Sound(567, 138,  27, 0, 4), /* k26_soundMOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU 26 Atari ST: not present */
+Sound(568, 138,  28, 0, 4), /* k27_soundMOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL 27 Atari ST: not present */
+Sound(569, 138, 106, 0, 4), /* k28_soundWAR_CRY 28 Atari ST: not present */
+Sound(570, 138,  56, 0, 4), /* k29_soundATTACK_ROCK_ROCKPILE 29 Atari ST: not present */
+Sound(571, 138,  58, 0, 4), /* k30_soundATTACK_WATER_ELEMENTAL 30 Atari ST: not present */
+Sound(572, 112,  53, 0, 4), /* k31_soundATTACK_COUATL 31 Atari ST: not present */
+Sound(573, 138,  29, 0, 4), /* k32_soundMOVE_RED_DRAGON 32 Atari ST: not present */
+Sound(574, 150,  22, 0, 4)}; /* k33_soundMOVE_SKELETON 33 Atari ST: not present */
+
+void SoundMan::f503_loadSounds() {
 	for (uint16 soundIndex = 0; soundIndex < k34_D13_soundCount; ++soundIndex) {
 		SoundData *soundData = _gK24_soundData + soundIndex;
 
 		uint16 graphicIndex = g60_sounds[soundIndex]._graphicIndex;
-		soundData->_byteCount = _displayMan->getCompressedDataSize(graphicIndex) - 2; // the header is 2 bytes long
+		soundData->_byteCount = _vm->_displayMan->getCompressedDataSize(graphicIndex) - 2; // the header is 2 bytes long
 		soundData->_firstSample = new byte[soundData->_byteCount];
 
-		Common::MemoryReadStream stream = _displayMan->getCompressedData(graphicIndex);
+		Common::MemoryReadStream stream = _vm->_displayMan->getCompressedData(graphicIndex);
 		soundData->_sampleCount = stream.readUint16BE();
 		stream.read(soundData->_firstSample, soundData->_byteCount);
 	}
 }
 
-void DMEngine::f060_SOUND_Play(uint16 soundIndex, uint16 period, uint8 leftVolume, uint8 rightVolume) {
+void SoundMan::f060_SOUND_Play(uint16 soundIndex, uint16 period, uint8 leftVolume, uint8 rightVolume) {
 	SoundData *sound = &_gK24_soundData[soundIndex];
 	Audio::AudioStream *stream = Audio::makeRawStream(sound->_firstSample, sound->_byteCount, (72800 / period) * 8, 0, DisposeAfterUse::NO);
 
 	signed char balance = ((int16)rightVolume - (int16)leftVolume) / 2;
 
 	Audio::SoundHandle handle;
-	_mixer->playStream(Audio::Mixer::kSFXSoundType, &handle, stream, -1, 127, balance);
+	_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &handle, stream, -1, 127, balance);
 }
 
-void DMEngine::f65_playPendingSound() {
+void SoundMan::f65_playPendingSound() {
 	while (!_pendingSounds.empty()) {
 		PendingSound pendingSound = _pendingSounds.pop();
 		f060_SOUND_Play(pendingSound._soundIndex, g60_sounds[pendingSound._soundIndex]._period, pendingSound._leftVolume, pendingSound._rightVolume);
 	}
 }
 
-bool DMEngine::f505_soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, uint8* rightVolume) {
+bool SoundMan::f505_soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, uint8* rightVolume) {
 	static byte K0030_aauc_DistanceToSoundVolume[25][25] = {
 		{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4,  5,  5,  5,  5,  5,  5,  5, 5, 4, 4, 4, 4, 4},
 		{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 5,  6,  6,  6,  6,  5,  5,  5, 5, 5, 5, 4, 4, 4},
@@ -139,22 +145,22 @@ bool DMEngine::f505_soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, ui
 	int16 L1680_i_LeftVolumeColumnIndex = 0;
 
 
-	switch (_dungeonMan->_g308_partyDir) {
+	switch (_vm->_dungeonMan->_g308_partyDir) {
 	case kDirNorth:
-		L1678_i_RightVolumeColumnIndex = mapX - _dungeonMan->_g306_partyMapX;
-		L1679_i_LineIndex = mapY - _dungeonMan->_g307_partyMapY;
+		L1678_i_RightVolumeColumnIndex = mapX - _vm->_dungeonMan->_g306_partyMapX;
+		L1679_i_LineIndex = mapY - _vm->_dungeonMan->_g307_partyMapY;
 		break;
 	case kDirEast:
-		L1678_i_RightVolumeColumnIndex = mapY - _dungeonMan->_g307_partyMapY;
-		L1679_i_LineIndex = -(mapX - _dungeonMan->_g306_partyMapX);
+		L1678_i_RightVolumeColumnIndex = mapY - _vm->_dungeonMan->_g307_partyMapY;
+		L1679_i_LineIndex = -(mapX - _vm->_dungeonMan->_g306_partyMapX);
 		break;
 	case kDirSouth:
-		L1678_i_RightVolumeColumnIndex = -(mapX - _dungeonMan->_g306_partyMapX);
-		L1679_i_LineIndex = -(mapY - _dungeonMan->_g307_partyMapY);
+		L1678_i_RightVolumeColumnIndex = -(mapX - _vm->_dungeonMan->_g306_partyMapX);
+		L1679_i_LineIndex = -(mapY - _vm->_dungeonMan->_g307_partyMapY);
 		break;
 	case kDirWest:
-		L1678_i_RightVolumeColumnIndex = -(mapY - _dungeonMan->_g307_partyMapY);
-		L1679_i_LineIndex = mapX - _dungeonMan->_g306_partyMapX;
+		L1678_i_RightVolumeColumnIndex = -(mapY - _vm->_dungeonMan->_g307_partyMapY);
+		L1679_i_LineIndex = mapX - _vm->_dungeonMan->_g306_partyMapX;
 		break;
 	}
 	if ((L1678_i_RightVolumeColumnIndex < -12) || (L1678_i_RightVolumeColumnIndex > 12)) { /* Sound is not audible if source is more than 12 squares away from the party */
@@ -171,23 +177,23 @@ bool DMEngine::f505_soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, ui
 	return true;
 }
 
-void DMEngine::f064_SOUND_RequestPlay_CPSD(uint16 soundIndex, int16 mapX, int16 mapY, uint16 mode) {
+void SoundMan::f064_SOUND_RequestPlay_CPSD(uint16 soundIndex, int16 mapX, int16 mapY, uint16 mode) {
 	Sound* sound;
 	uint8 leftVolume, rightVolume;
 
-	if (mode && (_dungeonMan->_g272_currMapIndex != _dungeonMan->_g309_partyMapIndex))
+	if (mode && (_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex))
 		return;
 
 	sound = &g60_sounds[soundIndex];
 	if (mode > k1_soundModePlayIfPrioritized) { /* Add an event in the timeline to play the sound (mode - 1) ticks later */
 		TimelineEvent event;
-		M33_setMapAndTime(event._mapTime, _dungeonMan->_g272_currMapIndex, _g313_gameTime + mode - 1);
+		M33_setMapAndTime(event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + mode - 1);
 		event._type = k20_TMEventTypePlaySound;
 		event._priority = sound->_priority;
 		event._C._soundIndex = soundIndex;
 		event._B._location._mapX = mapX;
 		event._B._location._mapY = mapY;
-		_timeline->f238_addEventGetEventIndex(&event);
+		_vm->_timeline->f238_addEventGetEventIndex(&event);
 		return;
 	}
 
diff --git a/engines/dm/sounds.h b/engines/dm/sounds.h
new file mode 100644
index 0000000..b3add4a
--- /dev/null
+++ b/engines/dm/sounds.h
@@ -0,0 +1,80 @@
+/* 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.
+*
+*/
+
+/*
+* Based on the Reverse Engineering work of Christophe Fontanel,
+* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+*/
+
+#include "dm.h"
+
+namespace DM {
+
+#define k34_D13_soundCount 34 // @ D13_SOUND_COUNT
+
+class SoundData {
+public:
+	uint32 _byteCount;
+	byte* _firstSample;
+	uint32 _sampleCount;
+	SoundData() : _byteCount(0), _firstSample(nullptr), _sampleCount(0) {}
+}; // @ SOUND_DATA
+
+class Sound {
+public:
+	int16 _graphicIndex;
+	byte _period;
+	byte _priority;
+	byte _loudDistance;
+	byte _softDistance;
+	Sound(int16 index, byte period, byte priority, byte loudDist, byte softDist) :
+		_graphicIndex(index), _period(period), _priority(priority), _loudDistance(loudDist), _softDistance(softDist) {}
+}; // @ Sound
+
+class PendingSound {
+public:
+	uint8 _leftVolume;
+	uint8 _rightVolume;
+	int16 _soundIndex;
+	PendingSound(uint8 leftVolume, uint8 rightVolume, int16 soundIndex) :
+		_leftVolume(leftVolume), _rightVolume(rightVolume), _soundIndex(soundIndex) {}
+};
+
+
+class SoundMan {
+	DMEngine *_vm;
+
+public:
+	SoundMan(DMEngine* vm);
+	~SoundMan();
+
+	SoundData _gK24_soundData[k34_D13_soundCount]; // @ K0024_as_SoundData
+	Common::Queue<PendingSound> _pendingSounds;
+
+	void f503_loadSounds(); // @ F0503_SOUND_LoadAll
+	void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode); // @ F0064_SOUND_RequestPlay_CPSD
+	void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol); // @ F0060_SOUND_Play
+	void f65_playPendingSound(); // @ F0065_SOUND_PlayPendingSound_CPSD
+	bool f505_soundGetVolume(int16 mapX, int16 mapY, uint8 *leftVolume, uint8 *rightVolume); // @ F0505_SOUND_GetVolume
+};
+
+}
\ No newline at end of file
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 6e5f482..3d88e43 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -35,6 +35,7 @@
 #include "text.h"
 #include "eventman.h"
 #include "objectman.h"
+#include "sounds.h"
 
 
 namespace DM {
@@ -318,7 +319,7 @@ void Timeline::f261_processTimeline() {
 				f246_timelineProcesEvent65_enableGroupGenerator(L0681_ps_Event);
 				break;
 			case k20_TMEventTypePlaySound:
-				_vm->f064_SOUND_RequestPlay_CPSD(L0682_s_Event._C._soundIndex, L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, k1_soundModePlayIfPrioritized);
+				_vm->_sound->f064_SOUND_RequestPlay_CPSD(L0682_s_Event._C._soundIndex, L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, k1_soundModePlayIfPrioritized);
 				break;
 			case k24_TMEventTypeRemoveFluxcage:
 				if (!_vm->_g302_gameWon) {
@@ -420,7 +421,7 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 				// Original bug fixed - A closing horizontal door wounds champions to the head instead of to the hands. Missing parenthesis in the condition cause all doors to wound the head in addition to the torso
 				// See BUG0_78
 				if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(5, k0x0008_ChampionWoundTorso | (AL0602_ui_VerticalDoor ? k0x0004_ChampionWoundHead : k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand), k2_attackType_SELF)) {
-					_vm->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
+					_vm->_sound->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
 				}
 			}
 			event->_mapTime++;
@@ -434,7 +435,7 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 				}
 				L0596_i_DoorState = (L0596_i_DoorState == k0_doorState_OPEN) ? k0_doorState_OPEN : (L0596_i_DoorState - 1);
 				L0597_puc_Square->setDoorState(L0596_i_DoorState);
-				_vm->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
+				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
 				event->_mapTime++;
 				f238_addEventGetEventIndex(event);
 				return;
@@ -446,7 +447,7 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 	}
 	L0596_i_DoorState += (L0595_i_Effect == k0_SensorEffSet) ? -1 : 1;
 	L0597_puc_Square->setDoorState(L0596_i_DoorState);
-	_vm->f064_SOUND_RequestPlay_CPSD(k02_soundDOOR_RATTLE, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
+	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k02_soundDOOR_RATTLE, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
 
 	if (L0595_i_Effect == k0_SensorEffSet) {
 		if (L0596_i_DoorState == k0_doorState_OPEN) {
@@ -838,7 +839,7 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 					}
 					_vm->_groupMan->f185_groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (Direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY);
 					if (L0614_ps_Sensor->getAudibleA()) {
-						_vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0616_ui_MapX, L0617_ui_MapY, k1_soundModePlayIfPrioritized);
+						_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0616_ui_MapX, L0617_ui_MapY, k1_soundModePlayIfPrioritized);
 					}
 					if (L0614_ps_Sensor->getOnlyOnce()) {
 						L0614_ps_Sensor->setTypeDisabled();
@@ -878,7 +879,7 @@ void Timeline::f252_timelineProcessEvents60to61_moveGroup(TimelineEvent* event)
 T0252001:
 	if (((_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) || (L0656_ui_MapX != _vm->_dungeonMan->_g306_partyMapX) || (L0657_ui_MapY != _vm->_dungeonMan->_g307_partyMapY)) && (_vm->_groupMan->f175_groupGetThing(L0656_ui_MapX, L0657_ui_MapY) == Thing::_endOfList)) { /* BUG0_24 Lord Chaos may teleport into one of the Black Flames and become invisible until the Black Flame is killed. In this case, _vm->_groupMan->f175_groupGetThing returns the Black Flame thing and the Lord Chaos thing is not moved into the dungeon until the Black Flame is killed */
 		if (event->_type == k61_TMEventTypeMoveGroupAudible) {
-			_vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0656_ui_MapX, L0657_ui_MapY, k1_soundModePlayIfPrioritized);
+			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0656_ui_MapX, L0657_ui_MapY, k1_soundModePlayIfPrioritized);
 		}
 		_vm->_moveSens->f267_getMoveResult(Thing(event->_C._slot), kM1_MapXNotOnASquare, 0, L0656_ui_MapX, L0657_ui_MapY);
 	} else {


Commit: 621d83c66b0d9781835c274fe23c2ae2d12bc604
    https://github.com/scummvm/scummvm/commit/621d83c66b0d9781835c274fe23c2ae2d12bc604
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add SoundMan_Atari

Changed paths:
    engines/dm/dm.cpp
    engines/dm/sounds.cpp
    engines/dm/sounds.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 19003bb..e22a41d 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -224,7 +224,7 @@ DMEngine::~DMEngine() {
 	delete _dialog;
 	delete _sound;
 
-	
+
 
 	delete[] _savedScreenForOpenEntranceDoors;
 	// clear debug channels
@@ -361,7 +361,7 @@ Common::Error DMEngine::run() {
 	_timeline = new Timeline(this);
 	_projexpl = new ProjExpl(this);
 	_dialog = new DialogMan(this);
-	_sound = new SoundMan(this);
+	_sound = SoundMan::getSoundMan(this, _gameVersion);
 	_displayMan->setUpScreens(320, 200);
 
 	f463_initializeGame();
diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp
index c90409d..ad9bc09 100644
--- a/engines/dm/sounds.cpp
+++ b/engines/dm/sounds.cpp
@@ -27,6 +27,7 @@
 
 #include "audio/audiostream.h"
 #include "audio/decoders/raw.h"
+#include <advancedDetector.h>
 
 #include "dm.h"
 #include "gfx.h"
@@ -38,6 +39,14 @@
 
 namespace DM {
 
+SoundMan* SoundMan::getSoundMan(DMEngine* vm, const ADGameDescription* gameVersion) {
+	switch (gameVersion->platform) {
+	default: warning(false, "Unknown platform, using default Amiga SoundMan");
+	case Common::kPlatformAmiga: return new SoundMan(vm);
+	case Common::kPlatformAtariST: return new SoundMan_Atari(vm);
+	}
+}
+
 SoundMan::SoundMan(DMEngine* vm) : _vm(vm) {}
 
 SoundMan::~SoundMan() {
@@ -45,6 +54,7 @@ SoundMan::~SoundMan() {
 		delete[] _gK24_soundData[i]._firstSample;
 }
 
+
 Sound g60_sounds[k34_D13_soundCount] = {
 Sound(533, 112,  11, 3, 6), /* k00_soundMETALLIC_THUD 0 */
 Sound(534, 112,  15, 0, 3), /* k01_soundSWITCH 1 */
@@ -207,4 +217,5 @@ void SoundMan::f064_SOUND_RequestPlay_CPSD(uint16 soundIndex, int16 mapX, int16
 	_pendingSounds.push(PendingSound(leftVolume, rightVolume, soundIndex));
 }
 
+
 }
diff --git a/engines/dm/sounds.h b/engines/dm/sounds.h
index b3add4a..6377835 100644
--- a/engines/dm/sounds.h
+++ b/engines/dm/sounds.h
@@ -63,18 +63,31 @@ public:
 class SoundMan {
 	DMEngine *_vm;
 
-public:
+protected:
 	SoundMan(DMEngine* vm);
-	~SoundMan();
+public:
+	virtual ~SoundMan();
+
+	static SoundMan *getSoundMan(DMEngine *vm, const ADGameDescription *gameVersion);
 
 	SoundData _gK24_soundData[k34_D13_soundCount]; // @ K0024_as_SoundData
 	Common::Queue<PendingSound> _pendingSounds;
 
-	void f503_loadSounds(); // @ F0503_SOUND_LoadAll
-	void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode); // @ F0064_SOUND_RequestPlay_CPSD
-	void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol); // @ F0060_SOUND_Play
+	virtual void f503_loadSounds(); // @ F0503_SOUND_LoadAll
+	virtual void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode); // @ F0064_SOUND_RequestPlay_CPSD
+	virtual void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol); // @ F0060_SOUND_Play
 	void f65_playPendingSound(); // @ F0065_SOUND_PlayPendingSound_CPSD
 	bool f505_soundGetVolume(int16 mapX, int16 mapY, uint8 *leftVolume, uint8 *rightVolume); // @ F0505_SOUND_GetVolume
 };
 
+class SoundMan_Atari: public SoundMan {
+	friend class SoundMan;
+
+	SoundMan_Atari(DMEngine* vm): SoundMan(vm) {};
+public:
+	void f503_loadSounds() override {} // @ F0503_SOUND_LoadAll
+	void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode) override {} // @ F0064_SOUND_RequestPlay_CPSD
+	void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol) override {} // @ F0060_SOUND_Play
+};
+
 }
\ No newline at end of file


Commit: 2f424adc308cb85a01e1639488820952b0ef4c02
    https://github.com/scummvm/scummvm/commit/2f424adc308cb85a01e1639488820952b0ef4c02
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix broken wallOrnamentIndices

Changed paths:
    engines/dm/dungeonman.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index a70077c..8cb702a 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -757,15 +757,16 @@ void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) {
 	f173_setCurrentMap(_g309_partyMapIndex = mapIndex);
 
 	byte *metaMapData = _g271_currMapData[_g273_currMapWidth - 1] + _g274_currMapHeight;
-	_vm->_displayMan->_g264_currMapAllowedCreatureTypes = metaMapData;
 
+	_vm->_displayMan->_g264_currMapAllowedCreatureTypes = metaMapData;
 	metaMapData += _g269_currMap->_creatureTypeCount;
-	memcpy(_vm->_displayMan->_g261_currMapWallOrnIndices, metaMapData, _g269_currMap->_wallOrnCount);
 
+	memcpy(_vm->_displayMan->_g261_currMapWallOrnIndices, metaMapData, _g269_currMap->_wallOrnCount);
 	metaMapData += _g269_currMap->_wallOrnCount;
+
 	memcpy(_vm->_displayMan->_g262_currMapFloorOrnIndices, metaMapData, _g269_currMap->_floorOrnCount);
+	metaMapData += _g269_currMap->_floorOrnCount;
 
-	metaMapData += _g269_currMap->_wallOrnCount;
 	memcpy(_vm->_displayMan->_g263_currMapDoorOrnIndices, metaMapData, _g269_currMap->_doorOrnCount);
 
 	_g265_currMapInscriptionWallOrnIndex = _g269_currMap->_wallOrnCount;


Commit: aaa0c7e3cca7e5e49be0314c5d17bc0cc5412b88
    https://github.com/scummvm/scummvm/commit/aaa0c7e3cca7e5e49be0314c5d17bc0cc5412b88
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f108_drawFloorOrnament, get rid of a GOTO

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 192d239..6b1121e 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -975,13 +975,6 @@ void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitm
 }
 
 void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloorIndex) {
-	uint16 floorOrnIndex;
-	int16 nativeBitmapIndex;
-	bool drawFootprints;
-	byte* bitmap;
-	uint16* coordSets;
-
-
 	static byte g191_floorOrnNativeBitmapndexInc[9] = { // @ G0191_auc_Graphic558_FloorOrnamentNativeBitmapIndexIncrements
 		0,   /* D3L */
 		1,   /* D3C */
@@ -991,63 +984,69 @@ void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloor
 		2,   /* D2R */
 		4,   /* D1L */
 		5,   /* D1C */
-		4}; /* D1R */
+		4};  /* D1R */
 
 	static uint16 g206_floorOrnCoordSets[3][9][6] = { // @ G0206_aaauc_Graphic558_FloorOrnamentCoordinateSets
 		/* { X1, X2, Y1, Y2, ByteWidth, Height } */
-		{{32,  79, 66,  71, 24,  6},     /* D3L */
-		{96, 127, 66,  71, 16,  6},     /* D3C */
-		{144, 191, 66,  71, 24,  6},     /* D3R */
-		{0,  63, 77,  87, 32, 11},     /* D2L */
-		{80, 143, 77,  87, 32, 11},     /* D2C */
-		{160, 223, 77,  87, 32, 11},     /* D2R */
-		{0,  31, 92, 116, 16, 25},     /* D1L */
-		{80, 143, 92, 116, 32, 25},     /* D1C */
-		{192, 223, 92, 116, 16, 25}},   /* D1R */
-		{{0,  95, 66,  74, 48,  9},     /* D3L */
-		{64, 159, 66,  74, 48,  9},     /* D3C */
-		{128, 223, 66,  74, 48,  9},     /* D3R */
-		{0,  79, 75,  89, 40, 15},     /* D2L */
-		{56, 167, 75,  89, 56, 15},     /* D2C */
-		{144, 223, 75,  89, 40, 15},     /* D2R */
-		{0,  63, 90, 118, 32, 29},     /* D1L */
-		{32, 191, 90, 118, 80, 29},     /* D1C */
-		{160, 223, 90, 118, 32, 29}},   /* D1R */
-		{{42,  57, 68,  72,  8,  5},     /* D3L */
-		{104, 119, 68,  72,  8,  5},     /* D3C */
-		{166, 181, 68,  72,  8,  5},     /* D3R */
-		{9,  40, 80,  85, 16,  6},     /* D2L */
-		{96, 127, 80,  85, 16,  6},     /* D2C */
-		{183, 214, 80,  85, 16,  6},     /* D2R */
-		{0,  15, 97, 108,  8, 12},     /* D1L */
-		{96, 127, 97, 108, 16, 12},     /* D1C	*/
-		{208, 223, 97, 108,  8, 12}}}; /* D1R */
+		{
+			{32,  79, 66,  71, 24,  6},   /* D3L */
+			{96, 127, 66,  71, 16,  6},   /* D3C */
+			{144, 191, 66,  71, 24,  6},  /* D3R */
+			{0,  63, 77,  87, 32, 11},    /* D2L */
+			{80, 143, 77,  87, 32, 11},   /* D2C */
+			{160, 223, 77,  87, 32, 11},  /* D2R */
+			{0,  31, 92, 116, 16, 25},    /* D1L */
+			{80, 143, 92, 116, 32, 25},   /* D1C */
+			{192, 223, 92, 116, 16, 25}   /* D1R */
+		},
+		{
+			{0,  95, 66,  74, 48,  9},    /* D3L */
+			{64, 159, 66,  74, 48,  9},   /* D3C */
+			{128, 223, 66,  74, 48,  9},  /* D3R */
+			{0,  79, 75,  89, 40, 15},    /* D2L */
+			{56, 167, 75,  89, 56, 15},   /* D2C */
+			{144, 223, 75,  89, 40, 15},  /* D2R */
+			{0,  63, 90, 118, 32, 29},    /* D1L */
+			{32, 191, 90, 118, 80, 29},   /* D1C */
+			{160, 223, 90, 118, 32, 29}   /* D1R */
+		},
+		{
+			{42,  57, 68,  72,  8,  5},   /* D3L */
+			{104, 119, 68,  72,  8,  5},  /* D3C */
+			{166, 181, 68,  72,  8,  5},  /* D3R */
+			{9,  40, 80,  85, 16,  6},    /* D2L */
+			{96, 127, 80,  85, 16,  6},   /* D2C */
+			{183, 214, 80,  85, 16,  6},  /* D2R */
+			{0,  15, 97, 108,  8, 12},    /* D1L */
+			{96, 127, 97, 108, 16, 12},   /* D1C */
+			{208, 223, 97, 108,  8, 12}   /* D1R */
+		}
+	};
 
 	if (floorOrnOrdinal) {
-		if (drawFootprints = getFlag(floorOrnOrdinal, k0x8000_FootprintsAspect)) {
-			if (!clearFlag(floorOrnOrdinal, k0x8000_FootprintsAspect))
-				goto T0108005;
-		}
-		floorOrnOrdinal--;
-		floorOrnIndex = floorOrnOrdinal;
-		nativeBitmapIndex = _g102_currMapFloorOrnInfo[floorOrnIndex][k0_NativeBitmapIndex]
-			+ g191_floorOrnNativeBitmapndexInc[viewFloorIndex];
-		coordSets = g206_floorOrnCoordSets[_g102_currMapFloorOrnInfo[floorOrnIndex][k1_CoordinateSet]][viewFloorIndex];
-		if ((viewFloorIndex == k8_viewFloor_D1R) || (viewFloorIndex == k5_viewFloor_D2R)
-			|| (viewFloorIndex == k2_viewFloor_D3R)
-			|| ((floorOrnIndex == k15_FloorOrnFootprints) && _g76_useFlippedWallAndFootprintsBitmap &&
-			((viewFloorIndex == k7_viewFloor_D1C) || (viewFloorIndex == k4_viewFloor_D2C) || (viewFloorIndex == k1_viewFloor_D3C)))) {
-			f99_copyBitmapAndFlipHorizontal(f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
-											bitmap = _g74_tmpBitmap, coordSets[4], coordSets[5]);
-		} else {
-			bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
-		}
-		f132_blitToBitmap(bitmap, _g296_bitmapViewport,
-						  *(Box *)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport);
-T0108005:
-		if (drawFootprints) {
+		bool drawFootprints = (getFlag(floorOrnOrdinal, k0x8000_FootprintsAspect) ? true : false);
+		byte *bitmap;
+		if (drawFootprints && (clearFlag(floorOrnOrdinal, k0x8000_FootprintsAspect))) {
+			floorOrnOrdinal--;
+			uint16 floorOrnIndex = floorOrnOrdinal;
+			int16 nativeBitmapIndex = _g102_currMapFloorOrnInfo[floorOrnIndex][k0_NativeBitmapIndex]
+				+ g191_floorOrnNativeBitmapndexInc[viewFloorIndex];
+			uint16 *coordSets = g206_floorOrnCoordSets[_g102_currMapFloorOrnInfo[floorOrnIndex][k1_CoordinateSet]][viewFloorIndex];
+			if ((viewFloorIndex == k8_viewFloor_D1R) || (viewFloorIndex == k5_viewFloor_D2R)
+				|| (viewFloorIndex == k2_viewFloor_D3R)
+				|| ((floorOrnIndex == k15_FloorOrnFootprints) && _g76_useFlippedWallAndFootprintsBitmap &&
+				((viewFloorIndex == k7_viewFloor_D1C) || (viewFloorIndex == k4_viewFloor_D2C) || (viewFloorIndex == k1_viewFloor_D3C)))) {
+				bitmap = _g74_tmpBitmap;
+				f99_copyBitmapAndFlipHorizontal(f489_getNativeBitmapOrGraphic(nativeBitmapIndex), bitmap, coordSets[4], coordSets[5]);
+			} else
+				bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+
+			f132_blitToBitmap(bitmap, _g296_bitmapViewport,
+							  *(Box *)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport);
+		}
+
+		if (drawFootprints)
 			f108_drawFloorOrnament(_vm->M0_indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex);
-		}
 	}
 }
 
@@ -1056,7 +1055,6 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d
 	DoorFrames* doorFramesTemp;
 	Door* door;
 
-
 	doorFramesTemp = doorFrames;
 	if (doorState != k0_doorState_OPEN) {
 		door = (Door *)(_vm->_dungeonMan->_g284_thingData[k0_DoorThingType]) + doorThingIndex;


Commit: eb2b298631da9466835d4f18b08b6cfc2e116f5f
    https://github.com/scummvm/scummvm/commit/eb2b298631da9466835d4f18b08b6cfc2e116f5f
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f109_drawDoorOrnament, f111_drawDoor, f112_drawCeilingPit and f116_drawSquareD3L

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 6b1121e..04b0da7 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -538,7 +538,6 @@ void DisplayMan::f460_initializeGraphicData() {
 
 	ProjectileAspect *projectileAspect = _projectileAspect;
 	for (int16 projectileAspectIndex = 0; projectileAspectIndex < k14_ProjectileAspectCount; projectileAspectIndex++, projectileAspect++) {
-
 		if (!getFlag(projectileAspect->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask)) {
 			derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + projectileAspect->_firstDerivedBitmapRelativeIndex;
 
@@ -862,7 +861,7 @@ void DisplayMan::f135_fillBoxBitmap(byte* destBitmap, Box &box, Color color, int
 void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box,
 													int16 lastUnitIndex, int16 firstUnitIndex, int16 destByteWidth, Color transparent,
 													int16 xPos, int16 yPos, int16 destHeight, int16 height2) {
-		 // make sure to take care of inclusive boundaries, color can have 0x8000 flag to not use mask
+	// make sure to take care of inclusive boundaries, color can have 0x8000 flag to not use mask
 	warning(false, "STUB: f133_blitBoxFilledWithMaskedBitmap");
 }
 
@@ -1051,41 +1050,37 @@ void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloor
 }
 
 void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* doorNativeBitmapIndices, int16 byteCount, int16 viewDoorOrnIndex, DoorFrames* doorFrames) {
-	uint16 doorType;
-	DoorFrames* doorFramesTemp;
-	Door* door;
-
-	doorFramesTemp = doorFrames;
-	if (doorState != k0_doorState_OPEN) {
-		door = (Door *)(_vm->_dungeonMan->_g284_thingData[k0_DoorThingType]) + doorThingIndex;
-		memmove(_g74_tmpBitmap, f489_getNativeBitmapOrGraphic(doorNativeBitmapIndices[doorType = door->getType()]), byteCount * 2);
-		f109_drawDoorOrnament(door->getOrnOrdinal(), viewDoorOrnIndex);
-		if (getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[doorType]._attributes, k0x0004_MaskDoorInfo_Animated)) {
-			if (_vm->getRandomNumber(2)) {
-				f130_flipBitmapHorizontal(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
-			}
-			if (_vm->getRandomNumber(2)) {
-				f131_flipVertical(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
-			}
-		}
-		if ((doorFramesTemp == _doorFrameD1C) && _vm->_championMan->_g407_party._event73Count_ThievesEye) {
-			f109_drawDoorOrnament(_vm->M0_indexToOrdinal(k16_DoorOrnThivesEyeMask), k2_ViewDoorOrnament_D1LCR);
-		}
-		if (doorState == k4_doorState_CLOSED) {
-			f102_drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed);
-		} else {
-			if (doorState == k5_doorState_DESTROYED) {
-				f109_drawDoorOrnament(_vm->M0_indexToOrdinal(k15_DoorOrnDestroyedMask), viewDoorOrnIndex);
-				f102_drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed);
-			} else {
-				doorState--;
-				if (door->opensVertically()) {
-					f102_drawDoorBitmap(&doorFramesTemp->_vertical[doorState]);
-				} else {
-					f102_drawDoorBitmap(&doorFramesTemp->_leftHorizontal[doorState]);
-					f102_drawDoorBitmap(&doorFramesTemp->_rightHorizontal[doorState]);
-				}
-			}
+	if (doorState == k0_doorState_OPEN)
+		return;
+
+	DoorFrames *doorFramesTemp = doorFrames;
+	Door *door = (Door *)(_vm->_dungeonMan->_g284_thingData[k0_DoorThingType]) + doorThingIndex;
+	uint16 doorType = door->getType();
+	memmove(_g74_tmpBitmap, f489_getNativeBitmapOrGraphic(doorNativeBitmapIndices[doorType]), byteCount * 2);
+	f109_drawDoorOrnament(door->getOrnOrdinal(), viewDoorOrnIndex);
+	if (getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[doorType]._attributes, k0x0004_MaskDoorInfo_Animated)) {
+		if (_vm->getRandomNumber(2))
+			f130_flipBitmapHorizontal(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
+
+		if (_vm->getRandomNumber(2))
+			f131_flipVertical(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
+	}
+
+	if ((doorFramesTemp == _doorFrameD1C) && _vm->_championMan->_g407_party._event73Count_ThievesEye)
+		f109_drawDoorOrnament(_vm->M0_indexToOrdinal(k16_DoorOrnThivesEyeMask), k2_ViewDoorOrnament_D1LCR);
+
+	if (doorState == k4_doorState_CLOSED)
+		f102_drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed);
+	else if (doorState == k5_doorState_DESTROYED) {
+		f109_drawDoorOrnament(_vm->M0_indexToOrdinal(k15_DoorOrnDestroyedMask), viewDoorOrnIndex);
+		f102_drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed);
+	} else {
+		doorState--;
+		if (door->opensVertically())
+			f102_drawDoorBitmap(&doorFramesTemp->_vertical[doorState]);
+		else {
+			f102_drawDoorBitmap(&doorFramesTemp->_leftHorizontal[doorState]);
+			f102_drawDoorBitmap(&doorFramesTemp->_rightHorizontal[doorState]);
 		}
 	}
 }
@@ -1116,87 +1111,91 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn
 			{44, 75, 61, 79, 16, 19}    /* D1LCR */
 		}
 	};
-	int16 AP0120_i_Height = doorOrnOrdinal;
-	int16 AP0121_i_ByteWidth = viewDoorOrnIndex;
-
-	if (AP0120_i_Height) {
-		AP0120_i_Height--;
-		int16 L0104_i_NativeBitmapIndex = _g103_currMapDoorOrnInfo[AP0120_i_Height][k0_NativeBitmapIndex];
-		int16 coordSetGreenToad = _g103_currMapDoorOrnInfo[AP0120_i_Height][k1_CoordinateSet];
-		uint16 *coordSetOrangeElk = &doorOrnCoordSets[coordSetGreenToad][AP0121_i_ByteWidth][0];
-		byte *AL0107_puc_Bitmap;
-		if (AP0121_i_ByteWidth == k2_ViewDoorOrnament_D1LCR) {
-			AL0107_puc_Bitmap = f489_getNativeBitmapOrGraphic(L0104_i_NativeBitmapIndex);
-			AP0121_i_ByteWidth = k48_byteWidth;
-			AP0120_i_Height = 88;
+
+	int16 height = doorOrnOrdinal;
+
+	if (!height)
+		return;
+
+	int16 byteWidth = viewDoorOrnIndex;
+	height--;
+
+	int16 nativeBitmapIndex = _g103_currMapDoorOrnInfo[height][k0_NativeBitmapIndex];
+	int16 coordSetGreenToad = _g103_currMapDoorOrnInfo[height][k1_CoordinateSet];
+	uint16 *coordSetOrangeElk = &doorOrnCoordSets[coordSetGreenToad][byteWidth][0];
+	byte *blitBitmap;
+	if (byteWidth == k2_ViewDoorOrnament_D1LCR) {
+		blitBitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+		byteWidth = k48_byteWidth;
+		height = 88;
+	} else {
+		height = k68_DerivedBitmapFirstDoorOrnament_D3 + (height * 2) + byteWidth;
+		if (!f491_isDerivedBitmapInCache(height)) {
+			uint16 *coordSetRedEagle = &doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR][0];
+			byte *nativeBitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+			f129_blitToBitmapShrinkWithPalChange(nativeBitmap, f492_getDerivedBitmap(height), coordSetRedEagle[4] << 1, coordSetRedEagle[5], coordSetOrangeElk[1] - coordSetOrangeElk[0] + 1, coordSetOrangeElk[5], (byteWidth == k0_ViewDoorOrnament_D3LCR) ? palChangesDoorOrnD3 : palChangesDoorOrnd2);
+			f493_addDerivedBitmap(height);
+		}
+		blitBitmap = f492_getDerivedBitmap(height);
+		if (byteWidth == k0_ViewDoorOrnament_D3LCR) {
+			byteWidth = k24_byteWidth;
+			height = 41;
 		} else {
-			AP0120_i_Height = k68_DerivedBitmapFirstDoorOrnament_D3 + (AP0120_i_Height * 2) + AP0121_i_ByteWidth;
-			if (!f491_isDerivedBitmapInCache(AP0120_i_Height)) {
-				uint16 *coordSetRedEagle = &doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR][0];
-				byte *L0108_puc_Bitmap_Native = f489_getNativeBitmapOrGraphic(L0104_i_NativeBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(L0108_puc_Bitmap_Native, f492_getDerivedBitmap(AP0120_i_Height), coordSetRedEagle[4] << 1, coordSetRedEagle[5], coordSetOrangeElk[1] - coordSetOrangeElk[0] + 1, coordSetOrangeElk[5], (AP0121_i_ByteWidth == k0_ViewDoorOrnament_D3LCR) ? palChangesDoorOrnD3 : palChangesDoorOrnd2);
-				f493_addDerivedBitmap(AP0120_i_Height);
-			}
-			AL0107_puc_Bitmap = f492_getDerivedBitmap(AP0120_i_Height);
-			if (AP0121_i_ByteWidth == k0_ViewDoorOrnament_D3LCR) {
-				AP0121_i_ByteWidth = k24_byteWidth;
-				AP0120_i_Height = 41;
-			} else {
-				AP0121_i_ByteWidth = k32_byteWidth;
-				AP0120_i_Height = 61;
-			}
+			byteWidth = k32_byteWidth;
+			height = 61;
 		}
-
-		Box box(coordSetOrangeElk[0], coordSetOrangeElk[1], coordSetOrangeElk[2], coordSetOrangeElk[3]);
-		f132_blitToBitmap(AL0107_puc_Bitmap, _g74_tmpBitmap, box, 0, 0, coordSetOrangeElk[4], AP0121_i_ByteWidth, k9_ColorGold, coordSetOrangeElk[5], AP0120_i_Height);
 	}
+
+	Box box(coordSetOrangeElk[0], coordSetOrangeElk[1], coordSetOrangeElk[2], coordSetOrangeElk[3]);
+	f132_blitToBitmap(blitBitmap, _g74_tmpBitmap, box, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height);
 }
 
-void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame* frame, int16 mapX, int16 mapY, bool flipHorizontal) {
-	int16 AL0117_i_MapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g272_currMapIndex, -1, &mapX, &mapY);
+void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int16 mapX, int16 mapY, bool flipHorizontal) {
+	int16 mapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g272_currMapIndex, -1, &mapX, &mapY);
 
-	if (AL0117_i_MapIndex < 0)
+	if (mapIndex < 0)
 		return;
 
-	int16 AL0117_i_Square = _vm->_dungeonMan->_g279_dungeonMapData[AL0117_i_MapIndex][mapX][mapY];
-	if ((Square(AL0117_i_Square).getType() == k2_ElementTypePit) && getFlag(AL0117_i_Square, k0x0008_PitOpen)) {
-		if (flipHorizontal) {
+	int16 mapSquare = _vm->_dungeonMan->_g279_dungeonMapData[mapIndex][mapX][mapY];
+	if ((Square(mapSquare).getType() == k2_ElementTypePit) && getFlag(mapSquare, k0x0008_PitOpen)) {
+		if (flipHorizontal)
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(nativeBitmapIndex, *frame);
-		} else {
+		else
 			f104_drawFloorPitOrStairsBitmap(nativeBitmapIndex, *frame);
-		}
 	}
 }
 
-void DisplayMan::f20_blitToViewport(byte* bitmap, Box& box, int16 byteWidth, Color transparent, int16 height) {
+void DisplayMan::f20_blitToViewport(byte *bitmap, Box& box, int16 byteWidth, Color transparent, int16 height) {
 	f132_blitToBitmap(bitmap, _g296_bitmapViewport, box, 0, 0, byteWidth, k112_byteWidthViewport, transparent, height, k136_heightViewport);
 }
 
-void DisplayMan::f20_blitToViewport(byte* bitmap, int16* box, int16 byteWidth, Color transparent, int16 height) {
+void DisplayMan::f20_blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height) {
 	Box actualBox(box[0], box[1], box[2], box[3]);
 	f20_blitToViewport(bitmap, actualBox, byteWidth, transparent, height);
 }
 
-void DisplayMan::f21_blitToScreen(byte *bitmap, int16* box, int16 byteWidth, Color transparent, int16 height) {
+void DisplayMan::f21_blitToScreen(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height) {
 	Box actualBox(box[0], box[1], box[2], box[3]);
 	f21_blitToScreen(bitmap, &actualBox, byteWidth, transparent, height);
 }
 
-void DisplayMan::f21_blitToScreen(byte* bitmap, Box* box, int16 byteWidth, Color transparent, int16 height) {
+void DisplayMan::f21_blitToScreen(byte *bitmap, Box *box, int16 byteWidth, Color transparent, int16 height) {
 	_g578_useByteBoxCoordinates = false;
 	f132_blitToBitmap(bitmap, _g348_bitmapScreen, *box, 0, 0, byteWidth, k160_byteWidthScreen, transparent, height, k200_heightScreen);
 }
 
 void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
-	if (f._srcByteWidth)
-		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency,
-						  f._srcHeight, k136_heightViewport);
+	if (!f._srcByteWidth)
+		return;
+
+	f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency, f._srcHeight, k136_heightViewport);
 }
 
 void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) {
-	if (f._srcByteWidth)
-		f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh,
-						  f._srcHeight, k136_heightViewport);
+	if (!f._srcByteWidth)
+		return;
+
+	f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, f._srcHeight, k136_heightViewport);
 }
 
 
@@ -1206,17 +1205,17 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 	static Frame frameStairsDownFrontD3L = Frame(0, 79, 28, 68, 40, 41, 0, 0); // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L
 	static Frame frameFloorPitD3L = Frame(0, 79, 66, 73, 40, 8, 0, 0); // @ G0140_s_Graphic558_Frame_FloorPit_D3L
 	static DoorFrames doorFrameD3L = DoorFrames( // @ G0179_s_Graphic558_Frames_Door_D3L
-		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-												Frame(24, 71, 28, 67, 24, 41, 0, 0),   /* Closed Or Destroyed */
-												Frame(24, 71, 28, 38, 24, 41, 0, 30),  /* Vertical Closed one fourth */
-												Frame(24, 71, 28, 48, 24, 41, 0, 20),  /* Vertical Closed half */
-												Frame(24, 71, 28, 58, 24, 41, 0, 10),  /* Vertical Closed three fourth */
-												Frame(24, 29, 28, 67, 24, 41, 18, 0),  /* Left Horizontal Closed one fourth */
-												Frame(24, 35, 28, 67, 24, 41, 12, 0),  /* Left Horizontal Closed half */
-												Frame(24, 41, 28, 67, 24, 41, 6, 0),   /* Left Horizontal Closed three fourth */
-												Frame(66, 71, 28, 67, 24, 41, 24, 0),  /* Right Horizontal Closed one fourth */
-												Frame(60, 71, 28, 67, 24, 41, 24, 0),  /* Right Horizontal Closed half */
-												Frame(54, 71, 28, 67, 24, 41, 24, 0)   /* Right Horizontal Closed three fourth */
+	/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
+		Frame(24, 71, 28, 67, 24, 41, 0, 0),   /* Closed Or Destroyed */
+		Frame(24, 71, 28, 38, 24, 41, 0, 30),  /* Vertical Closed one fourth */
+		Frame(24, 71, 28, 48, 24, 41, 0, 20),  /* Vertical Closed half */
+		Frame(24, 71, 28, 58, 24, 41, 0, 10),  /* Vertical Closed three fourth */
+		Frame(24, 29, 28, 67, 24, 41, 18, 0),  /* Left Horizontal Closed one fourth */
+		Frame(24, 35, 28, 67, 24, 41, 12, 0),  /* Left Horizontal Closed half */
+		Frame(24, 41, 28, 67, 24, 41, 6, 0),   /* Left Horizontal Closed three fourth */
+		Frame(66, 71, 28, 67, 24, 41, 24, 0),  /* Right Horizontal Closed one fourth */
+		Frame(60, 71, 28, 67, 24, 41, 24, 0),  /* Right Horizontal Closed half */
+		Frame(54, 71, 28, 67, 24, 41, 24, 0)   /* Right Horizontal Closed three fourth */
 	);
 
 	uint16 squareAspect[5];
@@ -1251,9 +1250,9 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		goto T0116017_orangeElk;
 	case k2_ElementTypePit:
-		if (!squareAspect[k2_PitInvisibleAspect]) {
+		if (!squareAspect[k2_PitInvisibleAspect])
 			f104_drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, frameFloorPitD3L);
-		}
+	// no break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_ElementTypeCorridor:
 T0116015_redEagle:


Commit: c62e449bbf5db1276c3a1978fa6d764cbada7d00
    https://github.com/scummvm/scummvm/commit/c62e449bbf5db1276c3a1978fa6d764cbada7d00
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f116_drawSquareD3L, remove 4 GOTOs

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 04b0da7..2f46c7c 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1220,7 +1220,7 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 
 	uint16 squareAspect[5];
 	int16 order;
-
+	bool skip = false;
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_StairsFrontElemType:
@@ -1228,19 +1228,24 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 			f104_drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, frameStairsUpFrontD3L);
 		else
 			f104_drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, frameStairsDownFrontD3L);
-		goto T0116015_redEagle;
+		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
+		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
+		break;
 	case k0_WallElemType:
 		f100_drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, _frameWalls163[k1_ViewSquare_D3L]);
 		f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) {
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT))
 			order = k0x0000_CellOrder_Alcove;
-			goto T0116017_orangeElk;
-		}
-		return;
+		else
+			return;
+		break;
 	case k16_ElementTypeDoorSide:
 	case k18_ElementTypeStairsSide:
 		order = k0x0321_CellOrder_BackLeft_BackRight_FrontRight;
-		goto T0116016_blueToad;
+		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
+		break;
 	case k17_ElementTypeDoorFront:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
@@ -1248,24 +1253,27 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
 					  _g693_doorNativeBitmapIndex_Front_D3LCR, M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3L);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
-		goto T0116017_orangeElk;
+		break;
 	case k2_ElementTypePit:
 		if (!squareAspect[k2_PitInvisibleAspect])
 			f104_drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, frameFloorPitD3L);
 	// no break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_ElementTypeCorridor:
-T0116015_redEagle:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
-T0116016_blueToad:
-/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
-T0116017_orangeElk:
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order);
+		break;
+	default:
+		skip = true;
+		break;
 	}
-	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+
+	if (!skip)
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order);
+
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
 		f113_drawField(&_fieldAspects188[k1_ViewSquare_D3L], _frameWalls163[k1_ViewSquare_D3L]._box);
-	}
 }
 
 void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {


Commit: b0381242611de1b64ef7b0049b15a83a259dbb5b
    https://github.com/scummvm/scummvm/commit/b0381242611de1b64ef7b0049b15a83a259dbb5b
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f117_drawSquareD3R, get rid of several GOTOs

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 2f46c7c..e4b840c 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1283,71 +1283,80 @@ void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 	static Frame frameFloorPitD3R = Frame(144, 223, 66, 73, 40, 8, 0, 0); // @ G0142_s_Graphic558_Frame_FloorPit_D3R
 	static DoorFrames doorFrameD3R = DoorFrames( // @ G0181_s_Graphic558_Frames_Door_D3R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-												Frame(150, 197, 28, 67, 24, 41, 0, 0),	/* Closed Or Destroyed */
-												Frame(150, 197, 28, 38, 24, 41, 0, 30),	/* Vertical Closed one fourth */
-												Frame(150, 197, 28, 48, 24, 41, 0, 20),	/* Vertical Closed half */
-												Frame(150, 197, 28, 58, 24, 41, 0, 10),	/* Vertical Closed three fourth */
-												Frame(150, 153, 28, 67, 24, 41, 18, 0),	/* Left Horizontal Closed one fourth */
-												Frame(150, 161, 28, 67, 24, 41, 12, 0),	/* Left Horizontal Closed half */
-												Frame(150, 167, 28, 67, 24, 41, 6, 0),	/* Left Horizontal Closed three fourth */
-												Frame(192, 197, 28, 67, 24, 41, 24, 0),	/* Right Horizontal Closed one fourth */
-												Frame(186, 197, 28, 67, 24, 41, 24, 0),	/* Right Horizontal Closed half */
-												Frame(180, 197, 28, 67, 24, 41, 24, 0)	/* Right Horizontal Closed three fourth */
+		Frame(150, 197, 28, 67, 24, 41, 0, 0),	/* Closed Or Destroyed */
+		Frame(150, 197, 28, 38, 24, 41, 0, 30),	/* Vertical Closed one fourth */
+		Frame(150, 197, 28, 48, 24, 41, 0, 20),	/* Vertical Closed half */
+		Frame(150, 197, 28, 58, 24, 41, 0, 10),	/* Vertical Closed three fourth */
+		Frame(150, 153, 28, 67, 24, 41, 18, 0),	/* Left Horizontal Closed one fourth */
+		Frame(150, 161, 28, 67, 24, 41, 12, 0),	/* Left Horizontal Closed half */
+		Frame(150, 167, 28, 67, 24, 41, 6, 0),	/* Left Horizontal Closed three fourth */
+		Frame(192, 197, 28, 67, 24, 41, 24, 0),	/* Right Horizontal Closed one fourth */
+		Frame(186, 197, 28, 67, 24, 41, 24, 0),	/* Right Horizontal Closed half */
+		Frame(180, 197, 28, 67, 24, 41, 24, 0)	/* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
 	uint16 squareAspect[5];
+	bool skip = false;
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
-		if (squareAspect[k2_StairsUpAspect]) {
+		if (squareAspect[k2_StairsUpAspect])
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, frameStairsUpFrontD3R);
-		} else {
+		else
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, frameStairsDownFrontD3R);
-		}
-		goto T0117016;
+
+		order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft;
+		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
+		break;
 	case k0_ElementTypeWall:
 		f100_drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, _frameWalls163[k2_ViewSquare_D3R]);
 		f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) {
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT))
 			order = k0x0000_CellOrder_Alcove;
-			goto T0117018;
-		}
-		return;
+		else
+			return;
+		break;
 	case k16_ElementTypeDoorSide:
 	case k18_ElementTypeStairsSide:
 		order = k0x0412_CellOrder_BackRight_BackLeft_FrontLeft;
-		goto T0117017;
+		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
+		break;
 	case k17_ElementTypeDoorFront:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
 		memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44);
 		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD3R);
-		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
+		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
 			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k0_viewDoorButton_D3R);
-		}
+
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect],
 					  squareAspect[k2_DoorStateAspect], _g693_doorNativeBitmapIndex_Front_D3LCR,
 					  M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3R);
-		goto T0117018;
+		break;;
 	case k2_ElementTypePit:
-		if (!squareAspect[k2_PitInvisibleAspect]) {
+		if (!squareAspect[k2_PitInvisibleAspect])
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, frameFloorPitD3R);
-		}
+		// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_ElementTypeCorridor:
-T0117016:
 		order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft;
-T0117017:
- /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
-T0117018:
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order);
+		break;
+	default:
+		skip = true;
+		break;
 	}
-	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+
+	if (!skip)
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order);
+
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
 		f113_drawField(&_fieldAspects188[k2_ViewSquare_D3R], _frameWalls163[k2_ViewSquare_D3R]._box);
-	}
 }
 
 void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
@@ -1358,16 +1367,16 @@ void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 	static Frame frameFloorPitD3C = Frame(64, 159, 66, 73, 48, 8, 0, 0); // @ G0141_s_Graphic558_Frame_FloorPit_D3C
 	static DoorFrames doorFrameD3C = DoorFrames( // @ G0180_s_Graphic558_Frames_Door_D3C
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-												Frame(88, 135, 28, 67, 24, 41, 0, 0),		/* Closed Or Destroyed */
-												Frame(88, 135, 28, 38, 24, 41, 0, 30),		/* Vertical Closed one fourth */
-												Frame(88, 135, 28, 48, 24, 41, 0, 20),		/* Vertical Closed half */
-												Frame(88, 135, 28, 58, 24, 41, 0, 10),		/* Vertical Closed three fourth */
-												Frame(88, 93, 28, 67, 24, 41, 18, 0),		/* Left Horizontal Closed one fourth */
-												Frame(88, 99, 28, 67, 24, 41, 12, 0),		/* Left Horizontal Closed half */
-												Frame(88, 105, 28, 67, 24, 41, 6, 0),		/* Left Horizontal Closed three fourth */
-												Frame(130, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed one fourth */
-												Frame(124, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed half */
-												Frame(118, 135, 28, 67, 24, 41, 24, 0)		/* Right Horizontal Closed three fourth */
+		Frame(88, 135, 28, 67, 24, 41, 0, 0),		/* Closed Or Destroyed */
+		Frame(88, 135, 28, 38, 24, 41, 0, 30),		/* Vertical Closed one fourth */
+		Frame(88, 135, 28, 48, 24, 41, 0, 20),		/* Vertical Closed half */
+		Frame(88, 135, 28, 58, 24, 41, 0, 10),		/* Vertical Closed three fourth */
+		Frame(88, 93, 28, 67, 24, 41, 18, 0),		/* Left Horizontal Closed one fourth */
+		Frame(88, 99, 28, 67, 24, 41, 12, 0),		/* Left Horizontal Closed half */
+		Frame(88, 105, 28, 67, 24, 41, 6, 0),		/* Left Horizontal Closed three fourth */
+		Frame(130, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed one fourth */
+		Frame(124, 135, 28, 67, 24, 41, 24, 0),		/* Right Horizontal Closed half */
+		Frame(118, 135, 28, 67, 24, 41, 24, 0)		/* Right Horizontal Closed three fourth */
 	);
 
 	uint16 squareAspect[5];


Commit: 9b1af23a356048f066797342bd0cdbf62a2c818c
    https://github.com/scummvm/scummvm/commit/9b1af23a356048f066797342bd0cdbf62a2c818c
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f118_drawSquareD3C and f119_drawSquareD2L, remove several GOTOs

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index e4b840c..8e48217 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1381,51 +1381,59 @@ void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 
 	uint16 squareAspect[5];
 	int16 order;
+	bool skip = false;
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
-		if (squareAspect[k2_StairsUpAspect]) {
+		if (squareAspect[k2_StairsUpAspect])
 			f104_drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, frameStairsUpFrontD3C);
-		} else {
+		else
 			f104_drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, frameStairsDownFrontD3C);
-		}
-		goto T0118027;
+
+		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		break;
 	case k0_ElementTypeWall:
 		f101_drawWallSetBitmapWithoutTransparency(_g698_bitmapWallSet_Wall_D3LCR, _frameWalls163[k0_ViewSquare_D3C]);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) {
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT))
 			order = k0x0000_CellOrder_Alcove;
-			goto T0118028;
-		}
-		return;
+		else
+			return;
+
+		break;
 	case k17_DoorFrontElemType:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
 		f100_drawWallSetBitmap(_g706_bitmapWallSet_DoorFrameLeft_D3C, doorFrameLeftD3C);
 		memmove(_g74_tmpBitmap, _g706_bitmapWallSet_DoorFrameLeft_D3C, 32 * 44);
 		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD3C);
-		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
+		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
 			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k1_ViewDoorOrnament_D2LCR);
-		}
+
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
 					  _g693_doorNativeBitmapIndex_Front_D3LCR, M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3C);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
-		goto T0118028;
+		break;
 	case k2_ElementTypePit:
-		if (!squareAspect[k2_PitInvisibleAspect]) {
+		if (!squareAspect[k2_PitInvisibleAspect])
 			f104_drawFloorPitOrStairsBitmap(k50_FloorPit_D3C_GraphicIndice, frameFloorPitD3C);
-		}
+	// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
-T0118027:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-T0118028:
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, order);
+		break;
+	default:
+		skip = true;
+		break;
 	}
-	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+
+	if (!skip)
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, order);
+
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
 		f113_drawField(&_fieldAspects188[k0_ViewSquare_D3C], _frameWalls163[k0_ViewSquare_D3C]._box);
-	}
 }
 
 void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
@@ -1437,43 +1445,48 @@ void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 	static Frame FrameCeilingPitD2L = Frame(0, 79, 19, 23, 40, 5, 0, 0); // @ G0152_s_Graphic558_Frame_CeilingPit_D2L
 	static DoorFrames doorFrameD2L = DoorFrames( // @ G0182_s_Graphic558_Frames_Door_D2L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-												Frame(0, 63, 24, 82, 32, 61, 0, 0),	/* Closed Or Destroyed */
-												Frame(0, 63, 24, 39, 32, 61, 0, 45),   /* Vertical Closed one fourth */
-												Frame(0, 63, 24, 54, 32, 61, 0, 30),   /* Vertical Closed half */
-												Frame(0, 63, 24, 69, 32, 61, 0, 15),   /* Vertical Closed three fourth */
-												Frame(0, 7, 24, 82, 32, 61, 24, 0),    /* Left Horizontal Closed one fourth */
-												Frame(0, 15, 24, 82, 32, 61, 16, 0),   /* Left Horizontal Closed half */
-												Frame(0, 23, 24, 82, 32, 61, 8, 0),    /* Left Horizontal Closed three fourth */
-												Frame(56, 63, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed one fourth */
-												Frame(48, 63, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed half */
-												Frame(40, 63, 24, 82, 32, 61, 32, 0)   /* Right Horizontal Closed three fourth */
+		Frame(0, 63, 24, 82, 32, 61, 0, 0),	   /* Closed Or Destroyed */
+		Frame(0, 63, 24, 39, 32, 61, 0, 45),   /* Vertical Closed one fourth */
+		Frame(0, 63, 24, 54, 32, 61, 0, 30),   /* Vertical Closed half */
+		Frame(0, 63, 24, 69, 32, 61, 0, 15),   /* Vertical Closed three fourth */
+		Frame(0, 7, 24, 82, 32, 61, 24, 0),    /* Left Horizontal Closed one fourth */
+		Frame(0, 15, 24, 82, 32, 61, 16, 0),   /* Left Horizontal Closed half */
+		Frame(0, 23, 24, 82, 32, 61, 8, 0),    /* Left Horizontal Closed three fourth */
+		Frame(56, 63, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed one fourth */
+		Frame(48, 63, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed half */
+		Frame(40, 63, 24, 82, 32, 61, 32, 0)   /* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
 	uint16 squareAspect[5];
+	bool skip = false;
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
-		if (squareAspect[k2_StairsUpAspect]) {
+		if (squareAspect[k2_StairsUpAspect])
 			f104_drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, frameStairsUpFrontD2L);
-		} else {
+		else
 			f104_drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, frameStairsDownFrontD2L);
-		}
-		goto T0119018;
+
+		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		break;
 	case k0_ElementTypeWall:
 		f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, _frameWalls163[k4_ViewSquare_D2L]);
 		f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) {
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT))
 			order = k0x0000_CellOrder_Alcove;
-			goto T0119020;
-		}
-		return;
+		else 
+			return;
+		break;
 	case k18_ElementTypeStairsSide:
 		f104_drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, frameStairsSideD2L);
+		// No break on purpose
 	case k16_DoorSideElemType:
 		order = k0x0342_CellOrder_BackRight_FrontLeft_FrontRight;
-		goto T0119019;
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		break;
 	case k17_DoorFrontElemType:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
@@ -1481,23 +1494,29 @@ void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], _g694_doorNativeBitmapIndex_Front_D2LCR,
 					  M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2L);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
-		goto T0119020;
+		break;
 	case k2_ElementTypePit:
 		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice,
 										frameFloorPitD2L);
+		// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
-T0119018:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
-T0119019:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-T0119020:
+		break;
+
+	default:
+		skip = true;
+		break;
+	}
+
+	if (!skip) {
 		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &FrameCeilingPitD2L, posX, posY, false);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, order);
 	}
-	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
 		f113_drawField(&_fieldAspects188[k4_ViewSquare_D2L], _frameWalls163[k4_ViewSquare_D2L]._box);
-	}
 }
 
 void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {


Commit: 3ef8dedebd69d4b24e8b4ef643ac5e7641c37811
    https://github.com/scummvm/scummvm/commit/3ef8dedebd69d4b24e8b4ef643ac5e7641c37811
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f120_drawSquareD2R, f121_drawSquareD2C and f122_drawSquareD1L, remove more GOTOs

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 8e48217..6458a35 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1526,71 +1526,83 @@ void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
 	static Frame frameStairsSideD2R = Frame(148, 163, 57, 61, 8, 5, 0, 0); // @ G0133_s_Graphic558_Frame_StairsSide_D2R
 	static Frame frameFloorPitD2R = Frame(144, 223, 77, 88, 40, 12, 0, 0); // @ G0145_s_Graphic558_Frame_FloorPit_D2R
 	static Frame frameCeilingPitD2R = Frame(144, 223, 19, 23, 40, 5, 0, 0); // @ G0154_s_Graphic558_Frame_CeilingPit_D2R
-	static DoorFrames g184_doorFrame_D2R = DoorFrames( // @ G0184_s_Graphic558_Frames_Door_D2R
+	static DoorFrames doorFrameD2R = DoorFrames( // @ G0184_s_Graphic558_Frames_Door_D2R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-													  Frame(160, 223, 24, 82, 32, 61, 0, 0),	/* Closed Or Destroyed */
-													  Frame(160, 223, 24, 39, 32, 61, 0, 45),	/* Vertical Closed one fourth */
-													  Frame(160, 223, 24, 54, 32, 61, 0, 30),	/* Vertical Closed half */
-													  Frame(160, 223, 24, 69, 32, 61, 0, 15),	/* Vertical Closed three fourth */
-													  Frame(160, 167, 24, 82, 32, 61, 24, 0),	/* Left Horizontal Closed one fourth */
-													  Frame(160, 175, 24, 82, 32, 61, 16, 0),	/* Left Horizontal Closed half */
-													  Frame(160, 183, 24, 82, 32, 61, 8, 0),	/* Left Horizontal Closed three fourth */
-													  Frame(216, 223, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed one fourth */
-													  Frame(208, 223, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed half */
-													  Frame(200, 223, 24, 82, 32, 61, 32, 0)		/* Right Horizontal Closed three fourth */
+		Frame(160, 223, 24, 82, 32, 61, 0, 0),	/* Closed Or Destroyed */
+		Frame(160, 223, 24, 39, 32, 61, 0, 45),	/* Vertical Closed one fourth */
+		Frame(160, 223, 24, 54, 32, 61, 0, 30),	/* Vertical Closed half */
+		Frame(160, 223, 24, 69, 32, 61, 0, 15),	/* Vertical Closed three fourth */
+		Frame(160, 167, 24, 82, 32, 61, 24, 0),	/* Left Horizontal Closed one fourth */
+		Frame(160, 175, 24, 82, 32, 61, 16, 0),	/* Left Horizontal Closed half */
+		Frame(160, 183, 24, 82, 32, 61, 8, 0),	/* Left Horizontal Closed three fourth */
+		Frame(216, 223, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed one fourth */
+		Frame(208, 223, 24, 82, 32, 61, 32, 0),	/* Right Horizontal Closed half */
+		Frame(200, 223, 24, 82, 32, 61, 32, 0)		/* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
 	uint16 squareAspect[5];
-
+	bool skip = false;
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
-		if (squareAspect[k2_StairsUpAspect]) {
+		if (squareAspect[k2_StairsUpAspect])
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, frameStairsUpFrontD2R);
-		} else {
+		else
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, frameStairsDownFrontD2R);
-		}
-		goto T0120027;
+
+		order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft;
+		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_viewFloor_D2R);
+		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &frameCeilingPitD2R, posX, posY, true);
+		break;
 	case k0_ElementTypeWall:
 		f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, _frameWalls163[k5_ViewSquare_D2R]);
 		f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) {
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT))
 			order = k0x0000_CellOrder_Alcove;
-			goto T0120029;
-		}
-		return;
+		else
+			return;
+		break;
 	case k18_ElementTypeStairsSide:
 		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, frameStairsSideD2R);
+		// No break on purpose
 	case k16_DoorSideElemType:
 		order = k0x0431_CellOrder_BackLeft_FrontRight_FrontLeft;
-		goto T0120028;
+		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_viewFloor_D2R);
+		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &frameCeilingPitD2R, posX, posY, true);
+		break;
 	case k17_DoorFrontElemType:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_ViewSquare_D2R);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
 		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, doorFrameTopD2R);
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g694_doorNativeBitmapIndex_Front_D2LCR, M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &g184_doorFrame_D2R);
+					  _g694_doorNativeBitmapIndex_Front_D2LCR, M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2R);
 		order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft;
-		goto T0120029;
+		break;
 	case k2_ElementTypePit:
-		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect]
-														   ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice, frameFloorPitD2R);
+		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(
+			squareAspect[k2_PitInvisibleAspect] ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice, frameFloorPitD2R);
+		// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
-T0120027:
 		order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft;
-T0120028:
-/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_viewFloor_D2R);
 		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &frameCeilingPitD2R, posX, posY, true);
-T0120029:
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, order);
+		break;
+	default:
+		skip = true;
+		break;
 	}
-	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+
+	if (!skip)
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, order);
+
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
 		f113_drawField(&_fieldAspects188[k5_ViewSquare_D2R], _frameWalls163[k5_ViewSquare_D2R]._box);
-	}
 }
 
 void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
@@ -1603,37 +1615,42 @@ void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 	static Frame frameCeilingPitD2C = Frame(64, 159, 19, 23, 48, 5, 0, 0); // @ G0153_s_Graphic558_Frame_CeilingPit_D2C
 	static DoorFrames doorFrameD2C = DoorFrames( // @ G0183_s_Graphic558_Frames_Door_D2C
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-												Frame(80, 143, 24, 82, 32, 61, 0, 0),    /* Closed Or Destroyed */
-												Frame(80, 143, 24, 39, 32, 61, 0, 45),   /* Vertical Closed one fourth */
-												Frame(80, 143, 24, 54, 32, 61, 0, 30),   /* Vertical Closed half */
-												Frame(80, 143, 24, 69, 32, 61, 0, 15),   /* Vertical Closed three fourth */
-												Frame(80, 87, 24, 82, 32, 61, 24, 0),    /* Left Horizontal Closed one fourth */
-												Frame(80, 95, 24, 82, 32, 61, 16, 0),    /* Left Horizontal Closed half */
-												Frame(80, 103, 24, 82, 32, 61, 8, 0),    /* Left Horizontal Closed three fourth */
-												Frame(136, 143, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed one fourth */
-												Frame(128, 143, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed half */
-												Frame(120, 143, 24, 82, 32, 61, 32, 0)   /* Right Horizontal Closed three fourth */
+		Frame(80, 143, 24, 82, 32, 61, 0, 0),    /* Closed Or Destroyed */
+		Frame(80, 143, 24, 39, 32, 61, 0, 45),   /* Vertical Closed one fourth */
+		Frame(80, 143, 24, 54, 32, 61, 0, 30),   /* Vertical Closed half */
+		Frame(80, 143, 24, 69, 32, 61, 0, 15),   /* Vertical Closed three fourth */
+		Frame(80, 87, 24, 82, 32, 61, 24, 0),    /* Left Horizontal Closed one fourth */
+		Frame(80, 95, 24, 82, 32, 61, 16, 0),    /* Left Horizontal Closed half */
+		Frame(80, 103, 24, 82, 32, 61, 8, 0),    /* Left Horizontal Closed three fourth */
+		Frame(136, 143, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed one fourth */
+		Frame(128, 143, 24, 82, 32, 61, 32, 0),  /* Right Horizontal Closed half */
+		Frame(120, 143, 24, 82, 32, 61, 32, 0)   /* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
 	uint16 squareAspect[5];
+	bool skip = false;
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
-		if (squareAspect[k2_StairsUpAspect]) {
+		if (squareAspect[k2_StairsUpAspect])
 			f104_drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, frameStairsUpFrontD2C);
-		} else {
+		else
 			f104_drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, frameStairsDownFrontD2C);
-		}
-		goto T0121015;
+
+		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
+		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C);
+		f112_drawCeilingPit(k64_ceilingPitD2C_GraphicIndice, &frameCeilingPitD2C, posX, posY, false);
+		break;
 	case k0_ElementTypeWall:
 		f101_drawWallSetBitmapWithoutTransparency(_g699_bitmapWallSet_Wall_D2LCR, _frameWalls163[k3_ViewSquare_D2C]);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) {
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT))
 			order = k0x0000_CellOrder_Alcove;
-			goto T0121016;
-		}
-		return;
+		else
+			return;
+		break;
 	case k17_DoorFrontElemType:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
@@ -1641,28 +1658,33 @@ void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 		f100_drawWallSetBitmap(_g707_bitmapWallSet_DoorFrameLeft_D2C, doorFrameLeftD2C);
 		memcpy(_g74_tmpBitmap, _g707_bitmapWallSet_DoorFrameLeft_D2C, 48 * 65);
 		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD2C);
-		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
+		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
 			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k2_viewDoorButton_D2C);
-		}
+
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
 					  _g694_doorNativeBitmapIndex_Front_D2LCR, M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2C);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
-		goto T0121016;
+		break;
 	case k2_ElementTypePit:
 		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k58_FloorPit_invisible_D2C_GraphicIndice : k52_FloorPit_D2C_GraphicIndice, frameFloorPitD2C);
+		// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
-T0121015:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
- /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C);
 		f112_drawCeilingPit(k64_ceilingPitD2C_GraphicIndice, &frameCeilingPitD2C, posX, posY, false);
-T0121016:
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, order);
+		break;
+	default:
+		skip = true;
+		break;
 	}
-	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+
+	if (!skip)
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, order);
+
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
 		f113_drawField(&_fieldAspects188[k3_ViewSquare_D2C], _frameWalls163[k3_ViewSquare_D2C]._box);
-	}
 }
 
 void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
@@ -1675,44 +1697,51 @@ void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
 	static Frame frameCeilingPitD1L = Frame(0, 63, 8, 16, 32, 9, 0, 0); // @ G0155_s_Graphic558_Frame_CeilingPit_D1L
 	static DoorFrames doorFrameD1L = DoorFrames( // @ G0185_s_Graphic558_Frames_Door_D1L
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-												Frame(0, 31, 17, 102, 48, 88, 64, 0),	/* Closed Or Destroyed */
-												Frame(0, 31, 17, 38, 48, 88, 64, 66),	/* Vertical Closed one fourth */
-												Frame(0, 31, 17, 60, 48, 88, 64, 44),	/* Vertical Closed half */
-												Frame(0, 31, 17, 82, 48, 88, 64, 22),	/* Vertical Closed three fourth */
-												Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed one fourth */
-												Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed half */
-												Frame(0, 0, 0, 0, 0, 0, 0, 0),	/* Left Horizontal Closed three fourth */
-												Frame(20, 31, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed one fourth */
-												Frame(8, 31, 17, 102, 48, 88, 48, 0),	/* Right Horizontal Closed half */
-												Frame(0, 31, 17, 102, 48, 88, 52, 0)	/* Right Horizontal Closed three fourth */
+		Frame(0, 31, 17, 102, 48, 88, 64, 0),   /* Closed Or Destroyed */
+		Frame(0, 31, 17, 38, 48, 88, 64, 66),   /* Vertical Closed one fourth */
+		Frame(0, 31, 17, 60, 48, 88, 64, 44),   /* Vertical Closed half */
+		Frame(0, 31, 17, 82, 48, 88, 64, 22),   /* Vertical Closed three fourth */
+		Frame(0, 0, 0, 0, 0, 0, 0, 0),          /* Left Horizontal Closed one fourth */
+		Frame(0, 0, 0, 0, 0, 0, 0, 0),          /* Left Horizontal Closed half */
+		Frame(0, 0, 0, 0, 0, 0, 0, 0),          /* Left Horizontal Closed three fourth */
+		Frame(20, 31, 17, 102, 48, 88, 48, 0),  /* Right Horizontal Closed one fourth */
+		Frame(8, 31, 17, 102, 48, 88, 48, 0),   /* Right Horizontal Closed half */
+		Frame(0, 31, 17, 102, 48, 88, 52, 0)    /* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
 	uint16 squareAspect[5];
-
+	bool skip = false;
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
-		if (squareAspect[k2_StairsUpAspect]) {
+		if (squareAspect[k2_StairsUpAspect])
 			f104_drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, frameStairsUpFrontD1L);
-		} else {
+		else
 			f104_drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, frameStairsDownFrontD1L);
-		}
-		goto T0122019;
+
+		order = k0x0032_CellOrder_BackRight_FrontRight;
+		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
+		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1L, posX, posY, false);
+		break;
 	case k0_ElementTypeWall:
 		f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, _frameWalls163[k7_ViewSquare_D1L]);
 		f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT);
 		return;
 	case k18_ElementTypeStairsSide:
-		if (squareAspect[k2_StairsUpAspect]) {
+		if (squareAspect[k2_StairsUpAspect])
 			f104_drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, frameStairsUpSideD1L);
-		} else {
+		else
 			f104_drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, frameStairsDownSideD1L);
-		}
+		// No break on purpose
 	case k16_DoorSideElemType:
 		order = k0x0032_CellOrder_BackRight_FrontRight;
-		goto T0122020;
+		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
+		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1L, posX, posY, false);
+		break;
 	case k17_DoorFrontElemType:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, k0x0028_CellOrder_DoorPass1_BackRight);
@@ -1720,23 +1749,27 @@ void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
 					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1L);
 		order = k0x0039_CellOrder_DoorPass2_FrontRight;
-		goto T0122021;
+		break;
 	case k2_ElementTypePit:
 		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k59_floorPit_invisible_D1L_GraphicIndice : k53_FloorPit_D1L_GraphicIndice, frameFloorPitD1L);
+		// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
-T0122019:
 		order = k0x0032_CellOrder_BackRight_FrontRight;
-T0122020:
 		 /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
 		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1L, posX, posY, false);
-T0122021:
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, order);
+		break;
+	default:
+		skip = true;
+		break;
 	}
-	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+
+	if (!skip)
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, order);
+
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
 		f113_drawField(&_fieldAspects188[k7_ViewSquare_D1L], _frameWalls163[k7_ViewSquare_D1L]._box);
-	}
 }
 
 void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {


Commit: 72912d4a5f035b42751ecc9b98bbd8aa353828e6
    https://github.com/scummvm/scummvm/commit/72912d4a5f035b42751ecc9b98bbd8aa353828e6
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f123_drawSquareD1R, f124_drawSquareD1C and f125_drawSquareD0L

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 6458a35..0a8e403 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1782,43 +1782,50 @@ void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {
 	static Frame frameCeilingPitD1R = Frame(160, 223, 8, 16, 32, 9, 0, 0); // @ G0157_s_Graphic558_Frame_CeilingPit_D1R
 	static DoorFrames doorFrameD1R = DoorFrames( // @ G0187_s_Graphic558_Frames_Door_D1R
 		/* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */
-												Frame(192, 223, 17, 102, 48, 88, 0, 0),   /* Closed Or Destroyed */
-												Frame(192, 223, 17, 38, 48, 88, 0, 66),   /* Vertical Closed one fourth */
-												Frame(192, 223, 17, 60, 48, 88, 0, 44),   /* Vertical Closed half */
-												Frame(192, 223, 17, 82, 48, 88, 0, 22),   /* Vertical Closed three fourth */
-												Frame(192, 203, 17, 102, 48, 88, 36, 0),  /* Left Horizontal Closed one fourth */
-												Frame(192, 215, 17, 102, 48, 88, 24, 0),  /* Left Horizontal Closed half */
-												Frame(192, 223, 17, 102, 48, 88, 12, 0),  /* Left Horizontal Closed three fourth */
-												Frame(0, 0, 0, 0, 0, 0, 0, 0),            /* Right Horizontal Closed one fourth */
-												Frame(0, 0, 0, 0, 0, 0, 0, 0),            /* Right Horizontal Closed half */
-												Frame(0, 0, 0, 0, 0, 0, 0, 0)             /* Right Horizontal Closed three fourth */
+		Frame(192, 223, 17, 102, 48, 88, 0, 0),   /* Closed Or Destroyed */
+		Frame(192, 223, 17, 38, 48, 88, 0, 66),   /* Vertical Closed one fourth */
+		Frame(192, 223, 17, 60, 48, 88, 0, 44),   /* Vertical Closed half */
+		Frame(192, 223, 17, 82, 48, 88, 0, 22),   /* Vertical Closed three fourth */
+		Frame(192, 203, 17, 102, 48, 88, 36, 0),  /* Left Horizontal Closed one fourth */
+		Frame(192, 215, 17, 102, 48, 88, 24, 0),  /* Left Horizontal Closed half */
+		Frame(192, 223, 17, 102, 48, 88, 12, 0),  /* Left Horizontal Closed three fourth */
+		Frame(0, 0, 0, 0, 0, 0, 0, 0),            /* Right Horizontal Closed one fourth */
+		Frame(0, 0, 0, 0, 0, 0, 0, 0),            /* Right Horizontal Closed half */
+		Frame(0, 0, 0, 0, 0, 0, 0, 0)             /* Right Horizontal Closed three fourth */
 	);
 
 	int16 order;
 	uint16 squareAspect[5];
+	bool skip = false;
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
-		if (squareAspect[k2_StairsUpAspect]) {
+		if (squareAspect[k2_StairsUpAspect])
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, frameStairsUpFrontD1R);
-		} else {
+		else
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, frameStairsDownFrontD1R);
-		}
-		goto T0123019;
+
+		order = k0x0041_CellOrder_BackLeft_FrontLeft;
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1R, posX, posY, true);
+		break;
 	case k0_ElementTypeWall:
 		f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, _frameWalls163[k8_ViewSquare_D1R]);
 		f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT);
 		return;
 	case k18_ElementTypeStairsSide:
-		if (squareAspect[k2_StairsUpAspect]) {
+		if (squareAspect[k2_StairsUpAspect])
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, frameStairsUpSideD1R);
-		} else {
+		else
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, frameStairsDownSideD1R);
-		}
+
+		// No break on purpose
 	case k16_DoorSideElemType:
 		order = k0x0041_CellOrder_BackLeft_FrontLeft;
-		goto T0123020;
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1R, posX, posY, true);
+		break;
 	case k17_DoorFrontElemType:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R);
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, k0x0018_CellOrder_DoorPass1_BackLeft);
@@ -1826,23 +1833,27 @@ void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
 					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1R);
 		order = k0x0049_CellOrder_DoorPass2_FrontLeft;
-		goto T0123021;
+		break;
 	case k2_ElementTypePit:
 		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect] ? k59_floorPit_invisible_D1L_GraphicIndice
 														   : k53_FloorPit_D1L_GraphicIndice, frameFloorPitD1R);
+		// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
-T0123019:
 		order = k0x0041_CellOrder_BackLeft_FrontLeft;
-T0123020:
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1R, posX, posY, true);
-T0123021:
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, order);
+		break;
+	default:
+		skip = true;
+		break;
 	}
-	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+
+	if (!skip)
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, order);
+
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
 		f113_drawField(&_fieldAspects188[k8_ViewSquare_D1R], _frameWalls163[k8_ViewSquare_D1R]._box);
-	}
 }
 
 void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
@@ -1855,17 +1866,21 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 
 	int16 order;
 	uint16 squareAspect[5];
-	byte* bitmap;
+	bool skip = false;
 
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (_vm->_dungeonMan->_g285_squareAheadElement = (ElementType)squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
-		if (squareAspect[k2_StairsUpAspect]) {
+		if (squareAspect[k2_StairsUpAspect])
 			f104_drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, frameStairsUpFrontD1C);
-		} else {
+		else
 			f104_drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, frameStairsDownFrontD1C);
-		}
-		goto T0124017;
+
+		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
+		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C);
+		f112_drawCeilingPit(k66_ceilingPitD1C_GraphicIndice, &frameCeilingPitD1C, posX, posY, false);
+		break;
 	case k0_ElementTypeWall:
 		_vm->_dungeonMan->_g286_isFacingAlcove = false;
 		_vm->_dungeonMan->_g287_isFacingViAltar = false;
@@ -1873,19 +1888,16 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
 			f491_isDerivedBitmapInCache(k1_DerivedBitmapThievesEyeVisibleArea);
 			f132_blitToBitmap(_g296_bitmapViewport, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
-							  boxThievesEyeVisibleArea,
-							  _boxThievesEyeViewPortVisibleArea._x1,
-							  _boxThievesEyeViewPortVisibleArea._y1,
+							  boxThievesEyeVisibleArea, _boxThievesEyeViewPortVisibleArea._x1, _boxThievesEyeViewPortVisibleArea._y1,
 							  k112_byteWidthViewport, 48, kM1_ColorNoTransparency, 136, 95);
-			bitmap = f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice);
+			byte *bitmap = f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice);
 			f132_blitToBitmap(bitmap, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
-							  boxThievesEyeVisibleArea,
-							  0, 0, 48, 48, k10_ColorFlesh, 95, 95);
+							  boxThievesEyeVisibleArea, 0, 0, 48, 48, k10_ColorFlesh, 95, 95);
 		}
 		f101_drawWallSetBitmapWithoutTransparency(_g700_bitmapWallSet_Wall_D1LCR, _frameWalls163[k6_ViewSquare_D1C]);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) {
+		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT))
 			f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, k0x0000_CellOrder_Alcove);
-		}
+
 		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
 			f132_blitToBitmap(f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
 							  _g296_bitmapViewport, _boxThievesEyeViewPortVisibleArea, 0, 0,
@@ -1900,28 +1912,33 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, doorFrameTopD1C);
 		f100_drawWallSetBitmap(_g708_bitmapWallSet_DoorFrameLeft_D1C, _doorFrameLeftD1C);
 		f100_drawWallSetBitmap(_g710_bitmapWallSet_DoorFrameRight_D1C, _doorFrameRightD1C);
-		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) {
+		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
 			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C);
-		}
+
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
 					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, _doorFrameD1C);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
-		goto T0124018;
+		break;
 	case k2_ElementTypePit:
 		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k60_floorPitInvisibleD1C_GraphicIndice : k54_FloorPit_D1C_GraphicIndice, frameFloorPitD1C);
+		// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
-T0124017:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
-/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C);
 		f112_drawCeilingPit(k66_ceilingPitD1C_GraphicIndice, &frameCeilingPitD1C, posX, posY, false);
-T0124018:
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, order);
+		break;
+	default:
+		skip = true;
+		break;
 	}
-	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+
+	if (!skip)
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, order);
+
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
 		f113_drawField(&_fieldAspects188[k6_ViewSquare_D1C], _frameWalls163[k6_ViewSquare_D1C]._box);
-	}
 }
 
 void DisplayMan::f125_drawSquareD0L(Direction dir, int16 posX, int16 posY) {
@@ -1973,9 +1990,8 @@ void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
 		f100_drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, _frameWalls163[k11_ViewSquare_D0R]);
 		return;
 	}
-	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
 		f113_drawField(&_fieldAspects188[k11_ViewSquare_D0R], _frameWalls163[k11_ViewSquare_D0R]._box);
-	}
 }
 
 void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
@@ -1999,9 +2015,8 @@ void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 							  _g74_tmpBitmap, boxThievesEyeHoleInDoorFrame, doorFrameD0C._box._x1 - _boxThievesEyeViewPortVisibleArea._x1,
 							  0, 48, 16, k9_ColorGold, 95, 123);
 			f100_drawWallSetBitmap(_g74_tmpBitmap, doorFrameD0C);
-		} else {
+		} else
 			f100_drawWallSetBitmap(_g709_bitmapWallSet_DoorFrameFront, doorFrameD0C);
-		}
 		break;
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
@@ -2014,12 +2029,12 @@ void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 		break;
 	case k2_ElementTypePit:
 		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k62_flootPitInvisibleD0C_graphicIndice : k56_FloorPit_D0C_GraphicIndice, frameFloorPitD0C);
+		break;
 	}
 	f112_drawCeilingPit(k68_ceilingPitD0C_graphicIndice, &frameCeilingPitD0C, posX, posY, false);
 	f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k9_ViewSquare_D0C, k0x0021_CellOrder_BackLeft_BackRight);
-	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) {
+	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
 		f113_drawField(&_fieldAspects188[k9_ViewSquare_D0C], _frameWalls163[k9_ViewSquare_D0C]._box);
-	}
 }
 
 void DisplayMan::f128_drawDungeon(Direction dir, int16 posX, int16 posY) {
@@ -2145,12 +2160,13 @@ void DisplayMan::f134_fillBitmap(byte *bitmap, Color color, uint16 byteWidth, ui
 }
 
 void DisplayMan::f94_loadFloorSet(FloorSet set) {
-	if (_g230_currentFloorSet != set) {
-		_g230_currentFloorSet = set;
-		int16 index = (set * k2_FloorSetGraphicCount) + k75_FirstFloorSet;
-		f466_loadIntoBitmap(index, _g84_bitmapFloor);
-		f466_loadIntoBitmap(index + 1, _g85_bitmapCeiling);
-	}
+	if (_g230_currentFloorSet == set)
+		return;
+
+	_g230_currentFloorSet = set;
+	int16 index = (set * k2_FloorSetGraphicCount) + k75_FirstFloorSet;
+	f466_loadIntoBitmap(index, _g84_bitmapFloor);
+	f466_loadIntoBitmap(index + 1, _g85_bitmapCeiling);
 }
 
 void DisplayMan::f95_loadWallSet(WallSet set) {
@@ -2346,15 +2362,13 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 		for (int16 ornamentCounter = 0; ornamentCounter < k3_AlcoveOrnCount; ornamentCounter++) {
 			if (greenOrn == g192_AlcoveOrnIndices[ornamentCounter]) {
 				_g267_currMapAlcoveOrnIndices[alcoveCount++] = ornamentIndex;
-				if (greenOrn == 2) { /* Wall ornament #2 is the Vi Altar */
+				if (greenOrn == 2) /* Wall ornament #2 is the Vi Altar */
 					_g266_currMapViAltarIndex = ornamentIndex;
-				}
 			}
 		}
 		for (int16 ornamentCounter = 0; ornamentCounter < k1_FountainOrnCount; ornamentCounter++) {
-			if (greenOrn == g193_FountainOrnIndices[ornamentCounter]) {
+			if (greenOrn == g193_FountainOrnIndices[ornamentCounter])
 				_g268_currMapFountainOrnIndices[fountainCount++] = ornamentIndex;
-			}
 		}
 
 		_g101_currMapWallOrnInfo[ornamentIndex][k1_CoordinateSet] = g194_WallOrnCoordSetIndices[greenOrn];


Commit: e4e30eaafd0d40313bd4d693f535267ea532d1be
    https://github.com/scummvm/scummvm/commit/e4e30eaafd0d40313bd4d693f535267ea532d1be
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor f107_isDrawnWallOrnAnAlcove

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 0a8e403..38a4325 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2603,159 +2603,133 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 	};
 
 	static Box boxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall
-#define AP0116_i_CharacterCount    wallOrnOrd
-#define AP0116_i_WallOrnamentIndex wallOrnOrd
-	int16 L0088_i_Multiple;
-#define AL0088_i_NativeBitmapIndex       L0088_i_Multiple
-#define AL0088_i_UnreadableTextLineCount L0088_i_Multiple
-	int16 L0089_i_Multiple;
-#define AL0089_i_WallOrnamentCoordinateSetIndex L0089_i_Multiple
-#define AL0089_i_FountainOrnamentIndex          L0089_i_Multiple
-#define AL0089_i_PixelWidth                     L0089_i_Multiple
-#define AL0089_i_X                              L0089_i_Multiple
-	byte* L0090_puc_Multiple;
-#define AL0090_puc_String        L0090_puc_Multiple
-#define AL0090_puc_CoordinateSet L0090_puc_Multiple
-	byte* L0091_puc_Multiple;
-#define AL0091_puc_Character     L0091_puc_Multiple
-#define AL0091_puc_Bitmap        L0091_puc_Multiple
-#define AL0091_puc_CoordinateSet L0091_puc_Multiple
-	byte* L0092_puc_Bitmap;
-	int16 L0093_i_CoordinateSetOffset;
-	bool L0094_B_FlipHorizontal;
-	bool L0095_B_IsInscription;
-	bool L0096_B_IsAlcove;
-	int16 L0097_i_TextLineIndex;
-	Frame L0098_s_Frame;
-	unsigned char L0099_auc_InscriptionString[70];
-
-
-	if (wallOrnOrd) {
-		wallOrnOrd--;
-		AL0088_i_NativeBitmapIndex = _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k0_NativeBitmapIndex];
-		AL0090_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex = _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k1_CoordinateSet]][viewWallIndex];
-		L0096_B_IsAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(AP0116_i_WallOrnamentIndex);
-		if (L0095_B_IsInscription = (AP0116_i_WallOrnamentIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex)) {
-			_vm->_dungeonMan->f168_decodeText((char*)L0099_auc_InscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
-		}
-		if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) {
-			if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
-				if (L0095_B_IsInscription) {
-					f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, boxWallPatchBehindInscription, 94, 28, _frameWalls163[k6_ViewSquare_D1C]._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency, _frameWalls163[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport);
-					AL0090_puc_String = L0099_auc_InscriptionString;
-					L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont);
-					L0097_i_TextLineIndex = 0;
-					do {
-						AP0116_i_CharacterCount = 0;
-						AL0091_puc_Character = AL0090_puc_String;
-						while (*AL0091_puc_Character++ < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
-							AP0116_i_CharacterCount++;
-						}
-						L0098_s_Frame._box._x2 = (L0098_s_Frame._box._x1 = 112 - (AP0116_i_CharacterCount << 2)) + 7;
-						L0098_s_Frame._box._y1 = (L0098_s_Frame._box._y2 = inscriptionLineY[L0097_i_TextLineIndex++]) - 7;
-						while (AP0116_i_CharacterCount--) {
-							f132_blitToBitmap(L0092_puc_Bitmap, _g296_bitmapViewport, L0098_s_Frame._box, *AL0090_puc_String++ << 3, 0, k144_byteWidth, k112_byteWidthViewport, k10_ColorFlesh, 8, k136_heightViewport);
-							L0098_s_Frame._box._x1 += 8;
-							L0098_s_Frame._box._x2 += 8;
-						}
-					} while (*AL0090_puc_String++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
-					goto T0107031;
-				}
-				AL0088_i_NativeBitmapIndex++;
-				{
-					Box tmpBox(AL0090_puc_CoordinateSet);
-					_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn] = tmpBox;
-				}
-				_vm->_dungeonMan->_g286_isFacingAlcove = L0096_B_IsAlcove;
-				_vm->_dungeonMan->_g287_isFacingViAltar =
-					(AP0116_i_WallOrnamentIndex == _g266_currMapViAltarIndex);
-				_vm->_dungeonMan->_g288_isFacingFountain = false;
-				for (AL0089_i_FountainOrnamentIndex = 0; AL0089_i_FountainOrnamentIndex < k1_FountainOrnCount; AL0089_i_FountainOrnamentIndex++) {
-					if (_g268_currMapFountainOrnIndices[AL0089_i_FountainOrnamentIndex] == AP0116_i_WallOrnamentIndex) {
-						_vm->_dungeonMan->_g288_isFacingFountain = true;
-						break;
+
+	if (!wallOrnOrd)
+		return false;
+
+	int16 wallOrnamentIndex = wallOrnOrd;
+	wallOrnOrd--;
+	int16 nativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnamentIndex][k0_NativeBitmapIndex];
+	int16 wallOrnamentCoordinateSetIndex = _g101_currMapWallOrnInfo[wallOrnamentIndex][k1_CoordinateSet];
+	byte *coordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][viewWallIndex];
+	bool isAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(wallOrnamentIndex);
+	bool isInscription = (wallOrnamentIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex);
+
+	unsigned char inscriptionString[70];
+	if (isInscription)
+		_vm->_dungeonMan->f168_decodeText((char*)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
+
+	byte *blitBitmap;
+	int16 blitX;
+	if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) {
+		if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
+			if (isInscription) {
+				f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, boxWallPatchBehindInscription, 94, 28, _frameWalls163[k6_ViewSquare_D1C]._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency, _frameWalls163[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport);
+				byte *parseString = inscriptionString;
+				byte *fontBitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont);
+				int16 textLineIndex = 0;
+				do {
+					int16 characterCount = 0;
+					byte *tmpString = parseString;
+					while (*tmpString++ < 128) /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
+						characterCount++;
+
+					Frame newFrame;
+					newFrame._box._x2 = (newFrame._box._x1 = 112 - (characterCount << 2)) + 7;
+					newFrame._box._y1 = (newFrame._box._y2 = inscriptionLineY[textLineIndex++]) - 7;
+					while (characterCount--) {
+						f132_blitToBitmap(fontBitmap, _g296_bitmapViewport, newFrame._box, *parseString++ << 3, 0, k144_byteWidth, k112_byteWidthViewport, k10_ColorFlesh, 8, k136_heightViewport);
+						newFrame._box._x1 += 8;
+						newFrame._box._x2 += 8;
 					}
-				}
-			}
-			AL0091_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
-			if (viewWallIndex == k11_ViewWall_D1R_LEFT) {
-				f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]);
-				AL0091_puc_Bitmap = _g74_tmpBitmap;
+				} while (*parseString++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
+				return isAlcove;
 			}
-			AL0089_i_X = 0;
-		} else {
-			L0093_i_CoordinateSetOffset = 0;
-			if (L0094_B_FlipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT)) {
-				AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k11_ViewWall_D1R_LEFT];
-			} else {
-				if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT)) {
-					AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k10_ViewWall_D1L_RIGHT];
-				} else {
-					AL0088_i_NativeBitmapIndex++;
-					AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k12_ViewWall_D1C_FRONT];
-					if (viewWallIndex == k7_ViewWall_D2L_FRONT) {
-						L0093_i_CoordinateSetOffset = 6;
-					} else {
-						if (viewWallIndex == k9_ViewWall_D2R_FRONT) {
-							L0093_i_CoordinateSetOffset = -6;
-						}
-					}
-				}
-			}
-			AL0089_i_PixelWidth = (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[1] - (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[0];
-			if (!f491_isDerivedBitmapInCache(AP0116_i_WallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + (AP0116_i_WallOrnamentIndex << 2) + wallOrnDerivedBitmapIndexIncrement[viewWallIndex])) {
-				L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex), AL0091_puc_CoordinateSet[4] << 1, AL0091_puc_CoordinateSet[5], AL0090_puc_CoordinateSet[4] << 1, AL0090_puc_CoordinateSet[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? _palChangesDoorButtonAndWallOrnD3 : _palChangesDoorButtonAndWallOrnD2);
-				f493_addDerivedBitmap(AP0116_i_WallOrnamentIndex);
-			}
-			AL0091_puc_Bitmap = f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex);
-			if (L0094_B_FlipHorizontal) {
-				f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]);
-				AL0091_puc_Bitmap = _g74_tmpBitmap;
-				AL0089_i_X = 15 - (AL0089_i_X & 0x000F);
-			} else {
-				if (viewWallIndex == k7_ViewWall_D2L_FRONT) {
-					AL0089_i_X -= AL0090_puc_CoordinateSet[1] - AL0090_puc_CoordinateSet[0];
-				} else {
-					AL0089_i_X = 0;
+			nativeBitmapIndex++;
+			Box tmpBox(coordinateSet);
+			_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn] = tmpBox;
+
+			_vm->_dungeonMan->_g286_isFacingAlcove = isAlcove;
+			_vm->_dungeonMan->_g287_isFacingViAltar =
+				(wallOrnamentIndex == _g266_currMapViAltarIndex);
+			_vm->_dungeonMan->_g288_isFacingFountain = false;
+			for (int i = 0; i < k1_FountainOrnCount; i++) {
+				if (_g268_currMapFountainOrnIndices[i] == wallOrnamentIndex) {
+					_vm->_dungeonMan->_g288_isFacingFountain = true;
+					break;
 				}
 			}
 		}
-		byte byteFrame[6];
-		if (L0095_B_IsInscription) {
-			L0092_puc_Bitmap = AL0090_puc_CoordinateSet;
-			AL0090_puc_String = L0099_auc_InscriptionString;
-			AL0088_i_UnreadableTextLineCount = 0;
-			do {
-				while (*AL0090_puc_String < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
-					AL0090_puc_String++;
-				}
-				AL0088_i_UnreadableTextLineCount++;
-			} while (*AL0090_puc_String++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
-			AL0090_puc_CoordinateSet = L0092_puc_Bitmap;
-			if (AL0088_i_UnreadableTextLineCount < 4) {
-				for (uint16 i = 0; i < 6; ++i)
-					byteFrame[i] = AL0090_puc_CoordinateSet[i];
-				AL0090_puc_CoordinateSet = byteFrame;
-				AL0090_puc_CoordinateSet[3] = unreadableInscriptionBoxY2[wallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + AL0088_i_UnreadableTextLineCount - 1];
-			}
+		blitBitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+		if (viewWallIndex == k11_ViewWall_D1R_LEFT) {
+			f99_copyBitmapAndFlipHorizontal(blitBitmap, _g74_tmpBitmap, coordinateSet[4], coordinateSet[5]);
+			blitBitmap = _g74_tmpBitmap;
 		}
-		{
-			Box tmpBox(AL0090_puc_CoordinateSet);
-			f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport, tmpBox,
-							  AL0089_i_X, 0,
-							  AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport);
+		blitX = 0;
+	} else {
+		byte *wallOrnCoordinateSet;
+		int coordinateSetOffset = 0;
+		bool flipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT);
+		if (flipHorizontal)
+			wallOrnCoordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k11_ViewWall_D1R_LEFT];
+		else if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT))
+			wallOrnCoordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k10_ViewWall_D1L_RIGHT];
+		else {
+			nativeBitmapIndex++;
+			wallOrnCoordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k12_ViewWall_D1C_FRONT];
+			if (viewWallIndex == k7_ViewWall_D2L_FRONT)
+				coordinateSetOffset = 6;
+			else if (viewWallIndex == k9_ViewWall_D2R_FRONT)
+				coordinateSetOffset = -6;
+		}
+		blitX = (coordinateSet + coordinateSetOffset)[1] - (coordinateSet + coordinateSetOffset)[0];
+		if (!f491_isDerivedBitmapInCache(wallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + (wallOrnamentIndex << 2) + wallOrnDerivedBitmapIndexIncrement[viewWallIndex])) {
+			byte *shrinkBitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+			f129_blitToBitmapShrinkWithPalChange(shrinkBitmap, f492_getDerivedBitmap(wallOrnamentIndex), wallOrnCoordinateSet[4] << 1, wallOrnCoordinateSet[5], coordinateSet[4] << 1, coordinateSet[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? _palChangesDoorButtonAndWallOrnD3 : _palChangesDoorButtonAndWallOrnD2);
+			f493_addDerivedBitmap(wallOrnamentIndex);
 		}
+		blitBitmap = f492_getDerivedBitmap(wallOrnamentIndex);
+		if (flipHorizontal) {
+			f99_copyBitmapAndFlipHorizontal(blitBitmap, _g74_tmpBitmap, coordinateSet[4], coordinateSet[5]);
+			blitBitmap = _g74_tmpBitmap;
+			blitX = 15 - (blitX & 0x000F);
+		} else if (viewWallIndex == k7_ViewWall_D2L_FRONT)
+			blitX -= coordinateSet[1] - coordinateSet[0];
+		else
+			blitX = 0;
+	}
 
-		if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
-			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), _g296_bitmapViewport, boxChampionPortraitOnWall,
-				(_g289_championPortraitOrdinal & 0x0007) << 5, (_g289_championPortraitOrdinal >> 3) * 29,
-							  k128_byteWidth, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); /* A portrait is 32x29 pixels */
+	byte byteFrame[6];
+	if (isInscription) {
+		byte *oldCoordSet = coordinateSet;
+		byte *parseString = inscriptionString;
+		int16 unreadableTextLineCount = 0;
+		do {
+			while (*parseString < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
+				parseString++;
+			}
+			unreadableTextLineCount++;
+		} while (*parseString++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
+		coordinateSet = oldCoordSet;
+		if (unreadableTextLineCount < 4) {
+			for (uint16 i = 0; i < 6; ++i)
+				byteFrame[i] = coordinateSet[i];
+			coordinateSet = byteFrame;
+			coordinateSet[3] = unreadableInscriptionBoxY2[wallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
 		}
-T0107031:
-		return L0096_B_IsAlcove;
 	}
-	return false;
+
+	Box tmpBox(coordinateSet);
+	f132_blitToBitmap(blitBitmap, _g296_bitmapViewport, tmpBox, blitX, 0,
+					  coordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, coordinateSet[5], k136_heightViewport);
+
+	if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
+		f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), _g296_bitmapViewport, boxChampionPortraitOnWall,
+			(_g289_championPortraitOrdinal & 0x0007) << 5, (_g289_championPortraitOrdinal >> 3) * 29,
+						  k128_byteWidth, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); /* A portrait is 32x29 pixels */
+	}
+
+	return isAlcove;
 }
 
 


Commit: 09c865fb8f004015a8bc8da8c6119387516a80e0
    https://github.com/scummvm/scummvm/commit/09c865fb8f004015a8bc8da8c6119387516a80e0
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some refactoring, get rid of some more globals

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 38a4325..558c5d9 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -705,9 +705,8 @@ void DisplayMan::f461_allocateFlippedWallBitmaps() {
 
 void DisplayMan::f102_drawDoorBitmap(Frame* frame) {
 	if (frame->_srcByteWidth) {
-		f132_blitToBitmap(_g74_tmpBitmap,
-						  _g296_bitmapViewport,
-						  frame->_box, frame->_srcX, frame->_srcY, frame->_srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, frame->_srcHeight, k136_heightViewport);
+		f132_blitToBitmap(_g74_tmpBitmap, _g296_bitmapViewport, frame->_box, frame->_srcX, frame->_srcY,
+						  frame->_srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, frame->_srcHeight, k136_heightViewport);
 	}
 }
 
@@ -2170,29 +2169,30 @@ void DisplayMan::f94_loadFloorSet(FloorSet set) {
 }
 
 void DisplayMan::f95_loadWallSet(WallSet set) {
-	if ((_g231_currentWallSet != set) || _vm->_g523_restartGameRequest) {
-		_g231_currentWallSet = set;
-
-		int16 graphicIndice = (set * k13_WallSetGraphicCount) + k77_FirstWallSet;
-		f466_loadIntoBitmap(graphicIndice++, _g709_bitmapWallSet_DoorFrameFront);
-		f466_loadIntoBitmap(graphicIndice++, _g708_bitmapWallSet_DoorFrameLeft_D1C);
-		f466_loadIntoBitmap(graphicIndice++, _g707_bitmapWallSet_DoorFrameLeft_D2C);
-		f466_loadIntoBitmap(graphicIndice++, _g706_bitmapWallSet_DoorFrameLeft_D3C);
-		f466_loadIntoBitmap(graphicIndice++, _g705_bitmapWallSet_DoorFrameLeft_D3L);
-		f466_loadIntoBitmap(graphicIndice++, _g704_bitmapWallSet_DoorFrameTop_D1LCR);
-		f466_loadIntoBitmap(graphicIndice++, _g703_bitmapWallSet_DoorFrameTop_D2LCR);
-		f466_loadIntoBitmap(graphicIndice++, _g702_bitmapWallSet_Wall_D0R);
-		f466_loadIntoBitmap(graphicIndice++, _g701_bitmapWallSet_Wall_D0L);
-		f466_loadIntoBitmap(graphicIndice++, _g700_bitmapWallSet_Wall_D1LCR);
-		f466_loadIntoBitmap(graphicIndice++, _g699_bitmapWallSet_Wall_D2LCR);
-		f466_loadIntoBitmap(graphicIndice++, _g698_bitmapWallSet_Wall_D3LCR);
-		f466_loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2);
-
-		f99_copyBitmapAndFlipHorizontal(_g708_bitmapWallSet_DoorFrameLeft_D1C, _g710_bitmapWallSet_DoorFrameRight_D1C,
-										_doorFrameRightD1C._srcByteWidth, _doorFrameRightD1C._srcHeight);
-		f99_copyBitmapAndFlipHorizontal(_g697_bitmapWallSet_Wall_D3L2, _g696_bitmapWallSet_Wall_D3R2,
-										_frameWallD3R2._srcByteWidth, _frameWallD3R2._srcHeight);
-	}
+	if ((_g231_currentWallSet == set) && !_vm->_g523_restartGameRequest)
+		return;
+
+	_g231_currentWallSet = set;
+
+	int16 graphicIndice = (set * k13_WallSetGraphicCount) + k77_FirstWallSet;
+	f466_loadIntoBitmap(graphicIndice++, _g709_bitmapWallSet_DoorFrameFront);
+	f466_loadIntoBitmap(graphicIndice++, _g708_bitmapWallSet_DoorFrameLeft_D1C);
+	f466_loadIntoBitmap(graphicIndice++, _g707_bitmapWallSet_DoorFrameLeft_D2C);
+	f466_loadIntoBitmap(graphicIndice++, _g706_bitmapWallSet_DoorFrameLeft_D3C);
+	f466_loadIntoBitmap(graphicIndice++, _g705_bitmapWallSet_DoorFrameLeft_D3L);
+	f466_loadIntoBitmap(graphicIndice++, _g704_bitmapWallSet_DoorFrameTop_D1LCR);
+	f466_loadIntoBitmap(graphicIndice++, _g703_bitmapWallSet_DoorFrameTop_D2LCR);
+	f466_loadIntoBitmap(graphicIndice++, _g702_bitmapWallSet_Wall_D0R);
+	f466_loadIntoBitmap(graphicIndice++, _g701_bitmapWallSet_Wall_D0L);
+	f466_loadIntoBitmap(graphicIndice++, _g700_bitmapWallSet_Wall_D1LCR);
+	f466_loadIntoBitmap(graphicIndice++, _g699_bitmapWallSet_Wall_D2LCR);
+	f466_loadIntoBitmap(graphicIndice++, _g698_bitmapWallSet_Wall_D3LCR);
+	f466_loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2);
+
+	f99_copyBitmapAndFlipHorizontal(_g708_bitmapWallSet_DoorFrameLeft_D1C, _g710_bitmapWallSet_DoorFrameRight_D1C,
+									_doorFrameRightD1C._srcByteWidth, _doorFrameRightD1C._srcHeight);
+	f99_copyBitmapAndFlipHorizontal(_g697_bitmapWallSet_Wall_D3L2, _g696_bitmapWallSet_Wall_D3R2,
+									_frameWallD3R2._srcByteWidth, _frameWallD3R2._srcHeight);
 }
 
 void DisplayMan::f96_loadCurrentMapGraphics() {
@@ -2434,15 +2434,15 @@ void DisplayMan::f93_applyCreatureReplColors(int replacedColor, int replacementC
 
 void DisplayMan::f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
 	if (f._srcByteWidth)
-		f132_blitToBitmap(f489_getNativeBitmapOrGraphic(nativeIndex), _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh,
-						  f._srcHeight, k136_heightViewport);
+		f132_blitToBitmap(f489_getNativeBitmapOrGraphic(nativeIndex), _g296_bitmapViewport, f._box, f._srcX, f._srcY,
+						f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, f._srcHeight, k136_heightViewport);
 }
 
 void DisplayMan::f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) {
 	if (f._srcByteWidth) {
 		f99_copyBitmapAndFlipHorizontal(f489_getNativeBitmapOrGraphic(nativeIndex), _g74_tmpBitmap, f._srcByteWidth, f._srcHeight);
-		f132_blitToBitmap(_g74_tmpBitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh,
-						  f._srcHeight, k136_heightViewport);
+		f132_blitToBitmap(_g74_tmpBitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth,
+						k112_byteWidthViewport, k10_ColorFlesh, f._srcHeight, k136_heightViewport);
 	}
 }
 
@@ -2739,22 +2739,20 @@ void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *des
 	if (destPixelWidth % 8)
 		destPixelWidth = (destPixelWidth / 8) * 8 + 8;
 
-	const uint32 SCALE_THRESHOLD = 32768;
-	uint32 scaleX = (SCALE_THRESHOLD * srcPixelWidth) / destPixelWidth;
-	uint32 scaleY = (SCALE_THRESHOLD * srcHeight) / destHeight;
+	uint32 scaleX = (kScaleThreshold * srcPixelWidth) / destPixelWidth;
+	uint32 scaleY = (kScaleThreshold * srcHeight) / destHeight;
 
 	warning(false, "MISSING CODE: No palette change takes place in f129_blitToBitmapShrinkWithPalChange");
 
 	// Loop through drawing output lines
 	for (uint32 destY = 0, scaleYCtr = 0; destY < (uint32)destHeight; ++destY, scaleYCtr += scaleY) {
 
-		const byte *srcLine = &srcBitmap[(scaleYCtr / SCALE_THRESHOLD) * srcPixelWidth];
+		const byte *srcLine = &srcBitmap[(scaleYCtr / kScaleThreshold) * srcPixelWidth];
 		byte *destLine = &destBitmap[destY * destPixelWidth];
 
 		// Loop through drawing the pixels of the row
-		for (uint32 destX = 0, xCtr = 0, scaleXCtr = 0; destX < (uint32)destPixelWidth; ++destX, ++xCtr, scaleXCtr += scaleX) {
-			destLine[xCtr] = srcLine[scaleXCtr / SCALE_THRESHOLD];
-		}
+		for (uint32 destX = 0, xCtr = 0, scaleXCtr = 0; destX < (uint32)destPixelWidth; ++destX, ++xCtr, scaleXCtr += scaleX)
+			destLine[xCtr] = srcLine[scaleXCtr / kScaleThreshold];
 	}
 }
 
@@ -2766,31 +2764,21 @@ Common::MemoryReadStream DisplayMan::getCompressedData(uint16 index) {
 	return Common::MemoryReadStream(_packedBitmaps + _packedItemPos[index], getCompressedDataSize(index), DisposeAfterUse::NO);
 }
 
-
 uint32 DisplayMan::getCompressedDataSize(uint16 index) {
 	return _packedItemPos[index + 1] - _packedItemPos[index];
 }
 
-
-/* Field Aspect Mask */
-#define kMaskFieldAspectFlipMask 0x0080 // @ MASK0x0080_FLIP_MASK 
-#define kMaskFieldAspectIndex 0x007F // @ MASK0x007F_MASK_INDEX
-#define kMaskFieldAspectNoMask 255 // @ C255_NO_MASK            
-
 void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) {
 	warning(false, "STUB METHOD: f113_drawField");
-	DisplayMan &dispMan = *_vm->_displayMan;
 
-	byte *bitmapMask;
-	if (fieldAspect->_mask == kMaskFieldAspectNoMask) {
-		bitmapMask = nullptr;
-	} else {
-		bitmapMask = dispMan._g74_tmpBitmap;
+	if (fieldAspect->_mask != kMaskFieldAspectNoMask) {
+		DisplayMan &dispMan = *_vm->_displayMan;
+
+		byte *bitmapMask = dispMan._g74_tmpBitmap;
 		memmove(bitmapMask, dispMan.f489_getNativeBitmapOrGraphic(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)),
 				fieldAspect->_height * fieldAspect->_byteWidth * 2 * sizeof(bitmapMask[0]));
-		if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask)) {
+		if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask))
 			dispMan.f130_flipBitmapHorizontal(bitmapMask, fieldAspect->_byteWidth, fieldAspect->_height);
-		}
 	}
 }
 
@@ -2802,162 +2790,6 @@ int16 DisplayMan::M78_getScaledDimension(int16 dimension, int16 scale) {
 	return (dimension * scale + scale / 2) / 32;
 }
 
-/* This is the full dungeon view */
-Box g105_BoxExplosionPattern_D0C = Box(0, 223, 0, 135); // @ G0105_s_Graphic558_Box_ExplosionPattern_D0C 
-
-byte g216_ExplosionBaseScales[5] = { // @ G0216_auc_Graphic558_ExplosionBaseScales
-	10,/* D4 */   16,/* D3 */   23,/* D2 */   32,/* D1 */   32};/* D0 */
-
-byte g217_ObjectPileShiftSetIndices[16][2] = { // @ G0217_aauc_Graphic558_ObjectPileShiftSetIndices
-	/* { X shift index, Y shift index } */
-	{2, 5},
-	{0, 6},
-	{5, 7},
-	{3, 0},
-	{7, 1},
-	{1, 2},
-	{6, 3},
-	{3, 3},
-	{5, 5},
-	{2, 6},
-	{7, 7},
-	{1, 0},
-	{3, 1},
-	{6, 2},
-	{1, 3},
-	{5, 3}}; /* 16 pairs of X and Y shift values */
-
-byte g218_ObjectCoordinateSets[3][10][5][2] = { // @ G0218_aaaauc_Graphic558_ObjectCoordinateSets
-	/* { {X, Y }, {X, Y }, {X, Y }, {X, Y }, {X, Y } } */
-	{{{0,   0},{0,   0},{125,  72},{95,  72},{112, 64}},     /* D3C */
-	{{0,   0},{0,   0},{62,  72},{25,  72},{24, 64}},     /* D3L */
-	{{0,   0},{0,   0},{200,  72},{162,  72},{194, 64}},     /* D3R */
-	{{92,  78},{132,  78},{136,  86},{88,  86},{112, 74}},     /* D2C */
-	{{10,  78},{53,  78},{41,  86},{0,   0},{3, 74}},     /* D2L */
-	{{171,  78},{218,  78},{0,   0},{183,  86},{219, 74}},     /* D2R */
-	{{83,  96},{141,  96},{148, 111},{76, 111},{112, 94}},     /* D1C */
-	{{0,   0},{26,  96},{5, 111},{0,   0},{0,  0}},     /* D1L */
-	{{197,  96},{0,   0},{0,   0},{220, 111},{0,  0}},     /* D1R */
-	{{66, 131},{158, 131},{0,   0},{0,   0},{0,  0}}},   /* D0C */
-	{{{0,   0},{0,   0},{125,  72},{95,  72},{112, 63}},     /* D3C */
-	{{0,   0},{0,   0},{62,  72},{25,  72},{24, 63}},     /* D3L */
-	{{0,   0},{0,   0},{200,  72},{162,  72},{194, 63}},     /* D3R */
-	{{92,  78},{132,  78},{136,  86},{88,  86},{112, 73}},     /* D2C */
-	{{10,  78},{53,  78},{41,  86},{0,   0},{3, 73}},     /* D2L */
-	{{171,  78},{218,  78},{0,   0},{183,  86},{219, 73}},     /* D2R */
-	{{83,  96},{141,  96},{148, 111},{76, 111},{112, 89}},     /* D1C */
-	{{0,   0},{26,  96},{5, 111},{0,   0},{0,  0}},     /* D1L */
-	{{197,  96},{0,   0},{0,   0},{220, 111},{0,  0}},     /* D1R */
-	{{66, 131},{158, 131},{0,   0},{0,   0},{0,  0}}},   /* D0C */
-	{{{0,   0},{0,   0},{125,  75},{95,  75},{112, 65}},     /* D3C */
-	{{0,   0},{0,   0},{62,  75},{25,  75},{24, 65}},     /* D3L */
-	{{0,   0},{0,   0},{200,  75},{162,  75},{194, 65}},     /* D3R */
-	{{92,  81},{132,  81},{136,  88},{88,  88},{112, 76}},     /* D2C */
-	{{10,  81},{53,  81},{41,  88},{0,   0},{3, 76}},     /* D2L */
-	{{171,  81},{218,  81},{0,  0},{183,  88},{219, 76}},     /* D2R */
-	{{83,  98},{141,  98},{148, 115},{76, 115},{112, 98}},     /* D1C */
-	{{0,   0},{26,  98},{5, 115},{0,   0},{0,  0}},     /* D1L */
-	{{197,  98},{0,   0},{0,   0},{220, 115},{0,  0}},     /* D1R */
-	{{66, 135},{158, 135},{0,   0},{0,   0},{0,  0}}}}; /* D0C */
-
-
-int16 g223_ShiftSets[3][8] = { // @ G0223_aac_Graphic558_ShiftSets
-	{0, 1, 2, 3, 0, -3, -2, -1},   /* D0 Back or D1 Front */
-	{0, 1, 1, 2, 0, -2, -1, -1},   /* D1 Back or D2 Front */
-	{0, 1, 1, 1, 0, -1, -1, -1}}; /* D2 Back or D3 Front */
-
-byte g224_CreatureCoordinateSets[3][11][5][2] = { // @ G0224_aaaauc_Graphic558_CreatureCoordinateSets
-	/* { { X, Y }, { X, Y }, { X, Y }, { X, Y }, { X, Y } } */
-	{{{95,  70},{127,  70},{129,  75},{93,  75},{111,  72}},     /* D3C */
-	{{131,  70},{163,  70},{158,  75},{120,  75},{145,  72}},     /* D3L */
-	{{59,  70},{91,  70},{107,  75},{66,  75},{79,  72}},     /* D3R */
-	{{92,  81},{131,  81},{132,  90},{91,  90},{111,  85}},     /* D2C */
-	{{99,  81},{146,  81},{135,  90},{80,  90},{120,  85}},     /* D2L */
-	{{77,  81},{124,  81},{143,  90},{89,  90},{105,  85}},     /* D2R */
-	{{83, 103},{141, 103},{148, 119},{76, 119},{109, 111}},     /* D1C */
-	{{46, 103},{118, 103},{101, 119},{0,   0},{79, 111}},     /* D1L */
-	{{107, 103},{177, 103},{0,   0},{123, 119},{144, 111}},     /* D1R */
-	{{0,   0},{67, 135},{0,   0},{0,   0},{0,   0}},     /* D0L */
-	{{156, 135},{0,   0},{0,   0},{0,   0},{0,   0}}},   /* D0R */
-	{{{94,  75},{128,  75},{111,  70},{111,  72},{111,  75}},     /* D3C */
-	{{120,  75},{158,  75},{149,  70},{145,  72},{150,  75}},     /* D3L */
-	{{66,  75},{104,  75},{75,  70},{79,  72},{73,  75}},     /* D3R */
-	{{91,  90},{132,  90},{111,  83},{111,  85},{111,  90}},     /* D2C */
-	{{80,  90},{135,  90},{125,  83},{120,  85},{125,  90}},     /* D2L */
-	{{89,  90},{143,  90},{99,  83},{105,  85},{98,  90}},     /* D2R */
-	{{81, 119},{142, 119},{111, 105},{111, 111},{111, 119}},     /* D1C */
-	{{0,   0},{101, 119},{84, 105},{70, 111},{77, 119}},     /* D1L */
-	{{123, 119},{0,   0},{139, 105},{153, 111},{146, 119}},     /* D1R */
-	{{0,   0},{83, 130},{57, 121},{47, 126},{57, 130}},     /* D0L */
-	{{140, 130},{0,   0},{166, 121},{176, 126},{166, 130}}},   /* D0R */
-	{{{95,  59},{127,  59},{129,  61},{93,  61},{111,  60}},     /* D3C */
-	{{131,  59},{163,  59},{158,  61},{120,  61},{145,  60}},     /* D3L */
-	{{59,  59},{91,  59},{107,  61},{66,  61},{79,  60}},     /* D3R */
-	{{92,  65},{131,  65},{132,  67},{91,  67},{111,  66}},     /* D2C */
-	{{99,  65},{146,  65},{135,  67},{80,  67},{120,  66}},     /* D2L */
-	{{77,  65},{124,  65},{143,  67},{89,  67},{105,  66}},     /* D2R */
-	{{83,  79},{141,  79},{148,  85},{76,  85},{111,  81}},     /* D1C */
-	{{46,  79},{118,  79},{101,  85},{0,   0},{79,  81}},     /* D1L */
-	{{107,  79},{177,  79},{0,   0},{123,  85},{144,  81}},     /* D1R */
-	{{0,   0},{67,  96},{0,   0},{0,   0},{0,   0}},     /* D0L */
-	{{156,  96},{0,   0},{0,   0},{0,   0},{0,   0}}}}; /* D0R */
-
-int16 g226_ExplosionCoordinates[15][2][2] = { // @ G0226_aaai_Graphic558_ExplosionCoordinates
-	/* { { Front Left X, Front Left Y }, { Front Right X, Front Right Y } } */
-	{{100, 47},{122, 47}},   /* D4C */
-	{{52, 47},{76, 47}},   /* D4L */
-	{{148, 47},{172, 47}},   /* D4R */
-	{{95, 50},{127, 50}},   /* D3C */
-	{{31, 50},{63, 50}},   /* D3L */
-	{{159, 50},{191, 50}},   /* D3R */
-	{{92, 53},{131, 53}},   /* D2C */
-	{{-3, 53},{46, 53}},   /* D2L */
-	{{177, 53},{226, 53}},   /* D2R */
-	{{83, 57},{141, 57}},   /* D1C */
-	{{-54, 57},{18, 57}},   /* D1L */
-	{{207, 57},{277, 57}},   /* D1R */
-	{{0,  0},{0,  0}},   /* D0C */
-	{{-73, 60},{-33, 60}},   /* D0L */
-	{{256, 60},{296, 60}}}; /* D0R */
-int16 g227_RebirthStep2ExplosionCoordinates[7][3] = { // @ G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates
-	/* { X, Y, Scale } */
-	{113, 57, 12},   /* D3C */
-	{24, 57, 12},   /* D3L */
-	{195, 57, 12},   /* D3R */
-	{111, 63, 16},   /* D2C */
-	{12, 63, 16},   /* D2L */
-	{213, 63, 16},   /* D2R */
-	{112, 76, 24}}; /* D1C */
-int16 g228_RebirthStep1ExplosionCoordinates[7][3] = { // @ G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates
-	/* { X, Y, Scale } */
-	{112, 53, 15},   /* D3C */
-	{24, 53, 15},   /* D3L */
-	{194, 53, 15},   /* D3R */
-	{112, 59, 20},   /* D2C */
-	{15, 59, 20},   /* D2L */
-	{208, 59, 20},   /* D2R */
-	{112, 70, 32}}; /* D1C */
-
-int16 g225_CenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_CenteredExplosionCoordinates
-	/* { X, Y } */
-	{111, 47},   /* D4C */
-	{57, 47},   /* D4L */
-	{167, 47},   /* D4R */
-	{111, 50},   /* D3C */
-	{45, 50},   /* D3L */
-	{179, 50},   /* D3R */
-	{111, 53},   /* D2C */
-	{20, 53},   /* D2L */
-	{205, 53},   /* D2R */
-	{111, 57},   /* D1C */
-	{-30, 57},   /* D1L */
-	{253, 57},   /* D1R */
-	{111, 60},   /* D0C */
-	{-53, 60},   /* D0L */
-	{276, 60}}; /* D0R */
-
-#define k0x0080_BlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK
-
 void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16 mapXpos,
 							  int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) {
 	int16 AL_0_creatureGraphicInfoRed;
@@ -3052,9 +2884,189 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 	bool smoke;
 	FieldAspect fieldAspect;
 
-	if (thingParam == Thing::_endOfList) {
+	/* This is the full dungeon view */
+	Box g105_BoxExplosionPattern_D0C = Box(0, 223, 0, 135); // @ G0105_s_Graphic558_Box_ExplosionPattern_D0C 
+
+	byte g216_ExplosionBaseScales[5] = { // @ G0216_auc_Graphic558_ExplosionBaseScales
+		10,  /* D4 */
+		16,  /* D3 */
+		23,  /* D2 */
+		32,  /* D1 */
+		32   /* D0 */
+	};
+
+	byte g217_ObjectPileShiftSetIndices[16][2] = { // @ G0217_aauc_Graphic558_ObjectPileShiftSetIndices
+	/* { X shift index, Y shift index } */
+		{2, 5},
+		{0, 6},
+		{5, 7},
+		{3, 0},
+		{7, 1},
+		{1, 2},
+		{6, 3},
+		{3, 3},
+		{5, 5},
+		{2, 6},
+		{7, 7},
+		{1, 0},
+		{3, 1},
+		{6, 2},
+		{1, 3},
+		{5, 3}
+	};
+
+	byte g218_ObjectCoordinateSets[3][10][5][2] = { // @ G0218_aaaauc_Graphic558_ObjectCoordinateSets
+	/* { {X, Y }, {X, Y }, {X, Y }, {X, Y }, {X, Y } } */
+		{
+			{{  0,   0}, {  0,   0}, {125,  72}, { 95,  72}, {112, 64}},     /* D3C */
+			{{  0,   0}, {  0,   0}, { 62,  72}, { 25,  72}, { 24, 64}},     /* D3L */
+			{{  0,   0}, {  0,   0}, {200,  72}, {162,  72}, {194, 64}},     /* D3R */
+			{{ 92,  78}, {132,  78}, {136,  86}, { 88,  86}, {112, 74}},     /* D2C */
+			{{ 10,  78}, { 53,  78}, { 41,  86}, {  0,   0}, {  3, 74}},     /* D2L */
+			{{171,  78}, {218,  78}, {  0,   0}, {183,  86}, {219, 74}},     /* D2R */
+			{{ 83,  96}, {141,  96}, {148, 111}, { 76, 111}, {112, 94}},     /* D1C */
+			{{  0,   0}, { 26,  96}, {  5, 111}, {  0,   0}, {  0,  0}},     /* D1L */
+			{{197,  96}, {  0,   0}, {  0,   0}, {220, 111}, {  0,  0}},     /* D1R */
+			{{ 66, 131}, {158, 131}, {  0,   0}, {  0,   0}, {  0,  0}}      /* D0C */
+		},
+		{
+			{{  0,   0}, {  0,   0}, {125,  72}, { 95,  72}, {112, 63}},     /* D3C */
+			{{  0,   0}, {  0,   0}, { 62,  72}, { 25,  72}, { 24, 63}},     /* D3L */
+			{{  0,   0}, {  0,   0}, {200,  72}, {162,  72}, {194, 63}},     /* D3R */
+			{{ 92,  78}, {132,  78}, {136,  86}, { 88,  86}, {112, 73}},     /* D2C */
+			{{ 10,  78}, { 53,  78}, { 41,  86}, {  0,   0}, {  3, 73}},     /* D2L */
+			{{171,  78}, {218,  78}, {  0,   0}, {183,  86}, {219, 73}},     /* D2R */
+			{{ 83,  96}, {141,  96}, {148, 111}, { 76, 111}, {112, 89}},     /* D1C */
+			{{  0,   0}, { 26,  96}, {  5, 111}, {  0,   0}, {  0,  0}},     /* D1L */
+			{{197,  96}, {  0,   0}, {  0,   0}, {220, 111}, {  0,  0}},     /* D1R */
+			{{ 66, 131}, {158, 131}, {  0,   0}, {  0,   0}, {  0,  0}}      /* D0C */
+		},
+		{
+			{{  0,   0}, {  0,   0}, {125,  75}, { 95,  75}, {112, 65}},     /* D3C */
+			{{  0,   0}, {  0,   0}, { 62,  75}, { 25,  75}, { 24, 65}},     /* D3L */
+			{{  0,   0}, {  0,   0}, {200,  75}, {162,  75}, {194, 65}},     /* D3R */
+			{{ 92,  81}, {132,  81}, {136,  88}, { 88,  88}, {112, 76}},     /* D2C */
+			{{ 10,  81}, { 53,  81}, { 41,  88}, {  0,   0}, {  3, 76}},     /* D2L */
+			{{171,  81}, {218,  81}, {  0,   0}, {183,  88}, {219, 76}},     /* D2R */
+			{{ 83,  98}, {141,  98}, {148, 115}, { 76, 115}, {112, 98}},     /* D1C */
+			{{  0,   0}, { 26,  98}, {  5, 115}, {  0,   0}, {  0,  0}},     /* D1L */
+			{{197,  98}, {  0,   0}, {  0,   0}, {220, 115}, {  0,  0}},     /* D1R */
+			{{ 66, 135}, {158, 135}, {  0,   0}, {  0,   0}, {  0,  0}}      /* D0C */
+		}
+	};
+
+	int16 g223_ShiftSets[3][8] = { // @ G0223_aac_Graphic558_ShiftSets
+		{0, 1, 2, 3, 0, -3, -2, -1},   /* D0 Back or D1 Front */
+		{0, 1, 1, 2, 0, -2, -1, -1},   /* D1 Back or D2 Front */
+		{0, 1, 1, 1, 0, -1, -1, -1}    /* D2 Back or D3 Front */
+	};
+
+	byte g224_CreatureCoordinateSets[3][11][5][2] = { // @ G0224_aaaauc_Graphic558_CreatureCoordinateSets
+	/* { { X, Y }, { X, Y }, { X, Y }, { X, Y }, { X, Y } } */
+		{
+			{{ 95,  70}, {127,  70}, {129,  75}, { 93,  75}, {111,  72}},     /* D3C */
+			{{131,  70}, {163,  70}, {158,  75}, {120,  75}, {145,  72}},     /* D3L */
+			{{ 59,  70}, { 91,  70}, {107,  75}, { 66,  75}, { 79,  72}},     /* D3R */
+			{{ 92,  81}, {131,  81}, {132,  90}, { 91,  90}, {111,  85}},     /* D2C */
+			{{ 99,  81}, {146,  81}, {135,  90}, { 80,  90}, {120,  85}},     /* D2L */
+			{{ 77,  81}, {124,  81}, {143,  90}, { 89,  90}, {105,  85}},     /* D2R */
+			{{ 83, 103}, {141, 103}, {148, 119}, { 76, 119}, {109, 111}},     /* D1C */
+			{{ 46, 103}, {118, 103}, {101, 119}, {  0,   0}, { 79, 111}},     /* D1L */
+			{{107, 103}, {177, 103}, {  0,   0}, {123, 119}, {144, 111}},     /* D1R */
+			{{  0,   0}, { 67, 135}, {  0,   0}, {  0,   0}, {  0,   0}},     /* D0L */
+			{{156, 135}, {  0,   0}, {  0,   0}, {  0,   0}, {  0,   0}}      /* D0R */
+		},
+		{
+			{{ 94,  75}, {128,  75}, {111,  70}, {111,  72}, {111,  75}},     /* D3C */
+			{{120,  75}, {158,  75}, {149,  70}, {145,  72}, {150,  75}},     /* D3L */
+			{{ 66,  75}, {104,  75}, { 75,  70}, { 79,  72}, { 73,  75}},     /* D3R */
+			{{ 91,  90}, {132,  90}, {111,  83}, {111,  85}, {111,  90}},     /* D2C */
+			{{ 80,  90}, {135,  90}, {125,  83}, {120,  85}, {125,  90}},     /* D2L */
+			{{ 89,  90}, {143,  90}, { 99,  83}, {105,  85}, { 98,  90}},     /* D2R */
+			{{ 81, 119}, {142, 119}, {111, 105}, {111, 111}, {111, 119}},     /* D1C */
+			{{  0,   0}, {101, 119}, { 84, 105}, { 70, 111}, { 77, 119}},     /* D1L */
+			{{123, 119}, {  0,   0}, {139, 105}, {153, 111}, {146, 119}},     /* D1R */
+			{{  0,   0}, { 83, 130}, { 57, 121}, { 47, 126}, { 57, 130}},     /* D0L */
+			{{140, 130}, {  0,   0}, {166, 121}, {176, 126}, {166, 130}}      /* D0R */
+		},
+		{
+			{{ 95,  59}, {127,  59}, {129,  61}, { 93,  61}, {111,  60}},     /* D3C */
+			{{131,  59}, {163,  59}, {158,  61}, {120,  61}, {145,  60}},     /* D3L */
+			{{ 59,  59}, { 91,  59}, {107,  61}, { 66,  61}, { 79,  60}},     /* D3R */
+			{{ 92,  65}, {131,  65}, {132,  67}, { 91,  67}, {111,  66}},     /* D2C */
+			{{ 99,  65}, {146,  65}, {135,  67}, { 80,  67}, {120,  66}},     /* D2L */
+			{{ 77,  65}, {124,  65}, {143,  67}, { 89,  67}, {105,  66}},     /* D2R */
+			{{ 83,  79}, {141,  79}, {148,  85}, { 76,  85}, {111,  81}},     /* D1C */
+			{{ 46,  79}, {118,  79}, {101,  85}, {  0,   0}, { 79,  81}},     /* D1L */
+			{{107,  79}, {177,  79}, {  0,   0}, {123,  85}, {144,  81}},     /* D1R */
+			{{  0,   0}, { 67,  96}, {  0,   0}, {  0,   0}, {  0,   0}},     /* D0L */
+			{{156,  96}, {  0,   0}, {  0,   0}, {  0,   0}, {  0,   0}}      /* D0R */
+		}
+	};
+
+	int16 g226_ExplosionCoordinates[15][2][2] = { // @ G0226_aaai_Graphic558_ExplosionCoordinates
+	/* { { Front Left X, Front Left Y }, { Front Right X, Front Right Y } } */
+		{{100, 47}, {122, 47}},   /* D4C */
+		{{ 52, 47}, { 76, 47}},   /* D4L */
+		{{148, 47}, {172, 47}},   /* D4R */
+		{{ 95, 50}, {127, 50}},   /* D3C */
+		{{ 31, 50}, { 63, 50}},   /* D3L */
+		{{159, 50}, {191, 50}},   /* D3R */
+		{{ 92, 53}, {131, 53}},   /* D2C */
+		{{ -3, 53}, { 46, 53}},   /* D2L */
+		{{177, 53}, {226, 53}},   /* D2R */
+		{{ 83, 57}, {141, 57}},   /* D1C */
+		{{-54, 57}, { 18, 57}},   /* D1L */
+		{{207, 57}, {277, 57}},   /* D1R */
+		{{  0,  0}, {  0,  0}},   /* D0C */
+		{{-73, 60}, {-33, 60}},   /* D0L */
+		{{256, 60}, {296, 60}}    /* D0R */
+	};
+
+	int16 g227_RebirthStep2ExplosionCoordinates[7][3] = { // @ G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates
+	/* { X, Y, Scale } */
+		{113, 57, 12},   /* D3C */
+		{ 24, 57, 12},   /* D3L */
+		{195, 57, 12},   /* D3R */
+		{111, 63, 16},   /* D2C */
+		{ 12, 63, 16},   /* D2L */
+		{213, 63, 16},   /* D2R */
+		{112, 76, 24}    /* D1C */
+	};
+
+	int16 g228_RebirthStep1ExplosionCoordinates[7][3] = { // @ G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates
+	/* { X, Y, Scale } */
+		{112, 53, 15},   /* D3C */
+		{ 24, 53, 15},   /* D3L */
+		{194, 53, 15},   /* D3R */
+		{112, 59, 20},   /* D2C */
+		{ 15, 59, 20},   /* D2L */
+		{208, 59, 20},   /* D2R */
+		{112, 70, 32} /* D1C */
+	};
+
+	int16 g225_CenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_CenteredExplosionCoordinates
+		/* { X, Y } */
+		{111, 47},   /* D4C */
+		{ 57, 47},   /* D4L */
+		{167, 47},   /* D4R */
+		{111, 50},   /* D3C */
+		{ 45, 50},   /* D3L */
+		{179, 50},   /* D3R */
+		{111, 53},   /* D2C */
+		{ 20, 53},   /* D2L */
+		{205, 53},   /* D2R */
+		{111, 57},   /* D1C */
+		{-30, 57},   /* D1L */
+		{253, 57},   /* D1R */
+		{111, 60},   /* D0C */
+		{-53, 60},   /* D0L */
+		{276, 60}    /* D0R */
+	};
+
+	if (thingParam == Thing::_endOfList)
 		return;
-	}
+
 	group = 0;
 	groupThing = Thing::_none;
 	drawCreaturesCompleted = sqaureHasProjectile = squareHasExplosion = false;
@@ -3732,9 +3744,9 @@ bool DisplayMan::f491_isDerivedBitmapInCache(int16 derivedBitmapIndex) {
 		// * 2, because the original uses 4 bits instead of 8 bits to store a pixel
 		_g638_derivedBitmaps[derivedBitmapIndex] = new byte[_g639_derivedBitmapByteCount[derivedBitmapIndex] * 2];
 		return false;
-	} else {
-		return true;
-	}
+	} 
+
+	return true;
 }
 
 byte* DisplayMan::f492_getDerivedBitmap(int16 derivedBitmapIndex) {
@@ -3751,15 +3763,15 @@ void DisplayMan::f480_releaseBlock(uint16 index) {
 }
 
 uint16 DisplayMan::f431_getDarkenedColor(uint16 RGBcolor) {
-	if (getFlag(RGBcolor, D12_MASK_BLUE_COMPONENT)) {
+	if (getFlag(RGBcolor, D12_MASK_BLUE_COMPONENT))
 		RGBcolor--;
-	}
-	if (getFlag(RGBcolor, D11_MASK_GREEN_COMPONENT)) {
+
+	if (getFlag(RGBcolor, D11_MASK_GREEN_COMPONENT))
 		RGBcolor -= 16;
-	}
-	if (getFlag(RGBcolor, D10_MASK_RED_COMPONENT)) {
+
+	if (getFlag(RGBcolor, D10_MASK_RED_COMPONENT))
 		RGBcolor -= 256;
-	}
+
 	return RGBcolor;
 }
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index b8b31f0..8d01365 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -147,6 +147,11 @@ namespace DM {
 #define k303_FirstDoorOrn 303 // @ C303_GRAPHIC_FIRST_DOOR_ORNAMENT
 #define k730_DerivedBitmapMaximumCount 730 // @ C730_DERIVED_BITMAP_MAXIMUM_COUNT
 
+/* Field Aspect Mask */
+#define kMaskFieldAspectFlipMask 0x0080 // @ MASK0x0080_FLIP_MASK 
+#define kMaskFieldAspectIndex 0x007F // @ MASK0x007F_MASK_INDEX
+#define kMaskFieldAspectNoMask 255 // @ C255_NO_MASK            
+
 enum ViewSquare {
 	kM3_ViewSquare_D4C = -3, // @ CM3_VIEW_SQUARE_D4C
 	kM2_ViewSquare_D4L = -2, // @ CM2_VIEW_SQUARE_D4L
@@ -222,6 +227,9 @@ extern byte g215_ProjectileScales[7]; // @ G0215_auc_Graphic558_ProjectileScales
 #define k12_ProjectileAspectExplosionSlime 12 // @ C12_PROJECTILE_ASPECT_EXPLOSION_SLIME                   
 #define k13_ProjectileAspectExplosionPoisonBoltCloud 13 // @ C13_PROJECTILE_ASPECT_EXPLOSION_POISON_BOLT_POISON_CLOUD
 
+#define k0x0080_BlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK
+#define kScaleThreshold 32768
+
 enum ViewCell {
 	k0_ViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT
 	k1_ViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT


Commit: fbf796779a6eb53559325bd28d7d38ef96392fb1
    https://github.com/scummvm/scummvm/commit/fbf796779a6eb53559325bd28d7d38ef96392fb1
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some refactoring and renaming

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 558c5d9..1d14ae7 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2881,13 +2881,11 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 	int16 explosionScale;
 	bool squareHasExplosion;
 	bool rebirthExplosion;
-	bool smoke;
-	FieldAspect fieldAspect;
 
 	/* This is the full dungeon view */
-	Box g105_BoxExplosionPattern_D0C = Box(0, 223, 0, 135); // @ G0105_s_Graphic558_Box_ExplosionPattern_D0C 
+	static Box boxExplosionPatternD0C = Box(0, 223, 0, 135); // @ G0105_s_Graphic558_Box_ExplosionPattern_D0C 
 
-	byte g216_ExplosionBaseScales[5] = { // @ G0216_auc_Graphic558_ExplosionBaseScales
+	static byte explosionBaseScales[5] = { // @ G0216_auc_Graphic558_ExplosionBaseScales
 		10,  /* D4 */
 		16,  /* D3 */
 		23,  /* D2 */
@@ -2895,7 +2893,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 		32   /* D0 */
 	};
 
-	byte g217_ObjectPileShiftSetIndices[16][2] = { // @ G0217_aauc_Graphic558_ObjectPileShiftSetIndices
+	static byte objectPileShiftSetIndices[16][2] = { // @ G0217_aauc_Graphic558_ObjectPileShiftSetIndices
 	/* { X shift index, Y shift index } */
 		{2, 5},
 		{0, 6},
@@ -2915,7 +2913,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 		{5, 3}
 	};
 
-	byte g218_ObjectCoordinateSets[3][10][5][2] = { // @ G0218_aaaauc_Graphic558_ObjectCoordinateSets
+	static byte objectCoordinateSets[3][10][5][2] = { // @ G0218_aaaauc_Graphic558_ObjectCoordinateSets
 	/* { {X, Y }, {X, Y }, {X, Y }, {X, Y }, {X, Y } } */
 		{
 			{{  0,   0}, {  0,   0}, {125,  72}, { 95,  72}, {112, 64}},     /* D3C */
@@ -2955,13 +2953,13 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 		}
 	};
 
-	int16 g223_ShiftSets[3][8] = { // @ G0223_aac_Graphic558_ShiftSets
+	static int16 shiftSets[3][8] = { // @ G0223_aac_Graphic558_ShiftSets
 		{0, 1, 2, 3, 0, -3, -2, -1},   /* D0 Back or D1 Front */
 		{0, 1, 1, 2, 0, -2, -1, -1},   /* D1 Back or D2 Front */
 		{0, 1, 1, 1, 0, -1, -1, -1}    /* D2 Back or D3 Front */
 	};
 
-	byte g224_CreatureCoordinateSets[3][11][5][2] = { // @ G0224_aaaauc_Graphic558_CreatureCoordinateSets
+	static byte creatureCoordinateSets[3][11][5][2] = { // @ G0224_aaaauc_Graphic558_CreatureCoordinateSets
 	/* { { X, Y }, { X, Y }, { X, Y }, { X, Y }, { X, Y } } */
 		{
 			{{ 95,  70}, {127,  70}, {129,  75}, { 93,  75}, {111,  72}},     /* D3C */
@@ -3004,7 +3002,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 		}
 	};
 
-	int16 g226_ExplosionCoordinates[15][2][2] = { // @ G0226_aaai_Graphic558_ExplosionCoordinates
+	static int16 explosionCoordinatesArray[15][2][2] = { // @ G0226_aaai_Graphic558_ExplosionCoordinates
 	/* { { Front Left X, Front Left Y }, { Front Right X, Front Right Y } } */
 		{{100, 47}, {122, 47}},   /* D4C */
 		{{ 52, 47}, { 76, 47}},   /* D4L */
@@ -3023,7 +3021,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 		{{256, 60}, {296, 60}}    /* D0R */
 	};
 
-	int16 g227_RebirthStep2ExplosionCoordinates[7][3] = { // @ G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates
+	static int16 rebirthStep2ExplosionCoordinates[7][3] = { // @ G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates
 	/* { X, Y, Scale } */
 		{113, 57, 12},   /* D3C */
 		{ 24, 57, 12},   /* D3L */
@@ -3034,7 +3032,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 		{112, 76, 24}    /* D1C */
 	};
 
-	int16 g228_RebirthStep1ExplosionCoordinates[7][3] = { // @ G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates
+	static int16 rebirthStep1ExplosionCoordinates[7][3] = { // @ G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates
 	/* { X, Y, Scale } */
 		{112, 53, 15},   /* D3C */
 		{ 24, 53, 15},   /* D3L */
@@ -3045,7 +3043,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 		{112, 70, 32} /* D1C */
 	};
 
-	int16 g225_CenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_CenteredExplosionCoordinates
+	static int16 centeredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_CenteredExplosionCoordinates
 		/* { X, Y } */
 		{111, 47},   /* D4C */
 		{ 57, 47},   /* D4L */
@@ -3118,7 +3116,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 				if (useAlcoveObjectImage = (L0135_B_DrawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane)) {
 					AL_4_nativeBitmapIndex++;
 				}
-				coordinateSet = g218_ObjectCoordinateSets[objectAspect->_coordinateSet][viewSquareIndex][AL_2_viewCell];
+				coordinateSet = objectCoordinateSets[objectAspect->_coordinateSet][viewSquareIndex][AL_2_viewCell];
 				if (!coordinateSet[1]) /* If object is not visible */
 					continue;
 T0115015_DrawProjectileAsObject:
@@ -3174,8 +3172,8 @@ T0115015_DrawProjectileAsObject:
 				AL_4_xPos = coordinateSet[0];
 				boxByteGreen._y2 = coordinateSet[1];
 				if (!drawProjectileAsObject) { /* If drawing an object that is not a projectile */
-					AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][g217_ObjectPileShiftSetIndices[objectShiftIndex][0]];
-					boxByteGreen._y2 += g223_ShiftSets[AL_8_shiftSetIndex][g217_ObjectPileShiftSetIndices[objectShiftIndex][1]];
+					AL_4_xPos += shiftSets[AL_8_shiftSetIndex][objectPileShiftSetIndices[objectShiftIndex][0]];
+					boxByteGreen._y2 += shiftSets[AL_8_shiftSetIndex][objectPileShiftSetIndices[objectShiftIndex][1]];
 					objectShiftIndex++; /* The next object drawn will use the next shift values */
 					if (L0135_B_DrawAlcoveObjects) {
 						if (objectShiftIndex >= 14) {
@@ -3309,7 +3307,7 @@ T0115015_DrawProjectileAsObject:
 			viewSquareIndex--;
 		}
 T0115077_DrawSecondHalfSquareCreature:
-		coordinateSet = g224_CreatureCoordinateSets[((CreatureAspect*)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell];
+		coordinateSet = creatureCoordinateSets[((CreatureAspect*)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell];
 		if (!coordinateSet[1])
 			goto T0115126_CreatureNotVisible;
 		AL_0_creatureGraphicInfoRed = creatureGraphicInfoGreen;
@@ -3438,11 +3436,11 @@ T0115077_DrawSecondHalfSquareCreature:
 			}
 		}
 		AL_4_yPos = coordinateSet[1];
-		AL_4_yPos += g223_ShiftSets[AL_8_shiftSetIndex][M23_getVerticalOffsetM23(creatureAspectInt)];
+		AL_4_yPos += shiftSets[AL_8_shiftSetIndex][M23_getVerticalOffsetM23(creatureAspectInt)];
 		boxByteGreen._y2 = MIN(AL_4_yPos, (int16)135);
 		boxByteGreen._y1 = MAX(0, AL_4_yPos - (heightRedEagle - 1));
 		AL_4_xPos = coordinateSet[0];
-		AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][M22_getHorizontalOffsetM22(creatureAspectInt)];
+		AL_4_xPos += shiftSets[AL_8_shiftSetIndex][M22_getHorizontalOffsetM22(creatureAspectInt)];
 		if (viewLane == k1_ViewLaneLeft) {
 			AL_4_xPos -= 100;
 		} else {
@@ -3474,7 +3472,7 @@ T0115126_CreatureNotVisible:
 		}
 		/* Draw projectiles */
 T0115129_DrawProjectiles:
-		if (!sqaureHasProjectile || ((viewSquareIndex = AL_10_viewSquareIndexBackup) > k9_ViewSquare_D0C) || (!(projectilePosX = g218_ObjectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0]))) /* If there is no projectile to draw or if projectiles are not visible on the specified square or on the cell being drawn */
+		if (!sqaureHasProjectile || ((viewSquareIndex = AL_10_viewSquareIndexBackup) > k9_ViewSquare_D0C) || (!(projectilePosX = objectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0]))) /* If there is no projectile to draw or if projectiles are not visible on the specified square or on the cell being drawn */
 			continue;
 		thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */
 		do {
@@ -3606,7 +3604,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 			explosion = (Explosion*)_vm->_dungeonMan->f156_getThingData(thingParam);
 			if ((rebirthExplosion = ((uint16)(AL_4_explosionType = explosion->getType()) >= k100_ExplosionType_RebirthStep1)) && ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion) || (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion) || (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */
 				continue;
-			smoke = false;
+			bool smoke = false;
 			if ((AL_4_explosionType == k0_ExplosionType_Fireball) || (AL_4_explosionType == k2_ExplosionType_LightningBolt) || (AL_4_explosionType == k101_ExplosionType_RebirthStep2)) {
 				AL_4_explosionAspectIndex = k0_ExplosionAspectFire;
 			} else {
@@ -3620,7 +3618,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 						if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) {
 							objectAspect = (ObjectAspect*)&_projectileAspect[_vm->M1_ordinalToIndex(-_vm->_dungeonMan->f142_getProjectileAspect(Thing::_explLightningBolt))];
 							AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
-							explosionCoordinates = g228_RebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
+							explosionCoordinates = rebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
 							byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_byteWidth), explosionCoordinates[2]);
 							heightRedEagle = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
 							if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) {
@@ -3656,26 +3654,26 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, 48, 32, 48, 32, _palChangeSmoke);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
-				f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, 0, f492_getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C, _vm->getRandomNumber(4) + 87, _vm->getRandomNumber(64), k112_byteWidthViewport, Color(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
+				f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, 0, f492_getDerivedBitmap(k0_DerivedBitmapViewport), boxExplosionPatternD0C, _vm->getRandomNumber(4) + 87, _vm->getRandomNumber(64), k112_byteWidthViewport, Color(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
 				f493_addDerivedBitmap(k0_DerivedBitmapViewport);
 				warning(false, "DISABLED CODE: f480_releaseBlock in f115_cthulhu");
 				//f480_releaseBlock(k0_DerivedBitmapViewport | 0x8000);
 			} else {
 				if (rebirthExplosion) {
-					explosionCoordinates = g227_RebirthStep2ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
+					explosionCoordinates = rebirthStep2ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
 					explosionScale = explosionCoordinates[2];
 				} else {
 					if (explosion->getCentered()) {
-						explosionCoordinates = g225_CenteredExplosionCoordinates[AL_1_viewSquareExplosionIndex];
+						explosionCoordinates = centeredExplosionCoordinates[AL_1_viewSquareExplosionIndex];
 					} else {
 						if ((AL_2_cellPurpleMan == directionParam) || (AL_2_cellPurpleMan == returnPrevVal(directionParam))) {
 							AL_2_viewCell = k0_ViewCellFronLeft;
 						} else {
 							AL_2_viewCell = k1_ViewCellFrontRight;
 						}
-						explosionCoordinates = g226_ExplosionCoordinates[AL_1_viewSquareExplosionIndex][AL_2_viewCell];
+						explosionCoordinates = explosionCoordinatesArray[AL_1_viewSquareExplosionIndex][AL_2_viewCell];
 					}
-					explosionScale = MAX(4, (MAX(48, explosion->getAttack() + 1) * g216_ExplosionBaseScales[AL_10_explosionScaleIndex]) >> 8) & (int)0xFFFE;
+					explosionScale = MAX(4, (MAX(48, explosion->getAttack() + 1) * explosionBaseScales[AL_10_explosionScaleIndex]) >> 8) & (int)0xFFFE;
 				}
 				AL_6_bitmapRedBanana = f114_getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle);
 T0115200_DrawExplosion:
@@ -3719,7 +3717,7 @@ T0115200_DrawExplosion:
 	} while ((thingParam = _vm->_dungeonMan->f159_getNextThing(thingParam)) != Thing::_endOfList);
 	if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_g77_doNotDrawFluxcagesDuringEndgame) { /* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */
 		AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */
-		fieldAspect = _fieldAspects188[viewSquareIndex];
+		FieldAspect fieldAspect = _fieldAspects188[viewSquareIndex];
 		(fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */
 		f113_drawField(&fieldAspect, _frameWalls163[viewSquareIndex]._box);
 	}
@@ -3777,69 +3775,52 @@ uint16 DisplayMan::f431_getDarkenedColor(uint16 RGBcolor) {
 
 void DisplayMan::f436_STARTEND_FadeToPalette(uint16* P0849_pui_Palette) {
 	static uint16 K0016_aui_Palette_FadeTemporary[16];
-	uint16 L1374_ui_CurrentRGBColor;
-	int16 L1375_ui_TargetRGBColor;
-	int16 L1376_i_Color;
-	int16 L1377_i_Counter;
-	uint16* L1378_pui_PaletteRegister;
-
-
-	L1378_pui_PaletteRegister = K0016_aui_Palette_FadeTemporary;
-	for (L1376_i_Color = 0; L1376_i_Color < 16; L1376_i_Color++) {
-		L1378_pui_PaletteRegister[L1376_i_Color] = _gK17_paletteFadeFrom[L1376_i_Color];
-	}
-	for (L1377_i_Counter = 0; L1377_i_Counter < 8; L1377_i_Counter++) {
-		for (L1376_i_Color = 0, L1378_pui_PaletteRegister = K0016_aui_Palette_FadeTemporary; L1376_i_Color < 16; L1376_i_Color++, L1378_pui_PaletteRegister++) {
-			L1374_ui_CurrentRGBColor = getFlag(*L1378_pui_PaletteRegister, D12_MASK_BLUE_COMPONENT);
-			L1375_ui_TargetRGBColor = getFlag(P0849_pui_Palette[L1376_i_Color], D12_MASK_BLUE_COMPONENT);
-			if (L1374_ui_CurrentRGBColor > L1375_ui_TargetRGBColor) {
-				if (L1374_ui_CurrentRGBColor > L1375_ui_TargetRGBColor + 1) {
-					*L1378_pui_PaletteRegister -= 2;
-				} else {
-					*L1378_pui_PaletteRegister -= 1;
-				}
-			} else {
-				if (L1374_ui_CurrentRGBColor < L1375_ui_TargetRGBColor) {
-					if (L1374_ui_CurrentRGBColor < L1375_ui_TargetRGBColor - 1) {
-						*L1378_pui_PaletteRegister += 2;
-					} else {
-						*L1378_pui_PaletteRegister += 1;
-					}
-				}
+	uint16 *paletteRegister = K0016_aui_Palette_FadeTemporary;
+
+	for (int16 i = 0; i < 16; i++) 
+		paletteRegister[i] = _gK17_paletteFadeFrom[i];
+
+	for (int16 i = 0; i < 8; i++) {
+		paletteRegister = K0016_aui_Palette_FadeTemporary;
+		for (int16 colIdx = 0; colIdx < 16; colIdx++, paletteRegister++) {
+			uint16 currentRGBColor = getFlag(*paletteRegister, D12_MASK_BLUE_COMPONENT);
+			int16 targetRGBColor = getFlag(P0849_pui_Palette[colIdx], D12_MASK_BLUE_COMPONENT);
+			if (currentRGBColor > targetRGBColor) {
+				if (currentRGBColor > targetRGBColor + 1)
+					*paletteRegister -= 2;
+				else
+					*paletteRegister -= 1;
+			} else if (currentRGBColor < targetRGBColor) {
+				if (currentRGBColor < targetRGBColor - 1)
+					*paletteRegister += 2;
+				else
+					*paletteRegister += 1;
 			}
-			L1374_ui_CurrentRGBColor = getFlag(*L1378_pui_PaletteRegister, D11_MASK_GREEN_COMPONENT) >> 4;
-			L1375_ui_TargetRGBColor = getFlag(P0849_pui_Palette[L1376_i_Color], D11_MASK_GREEN_COMPONENT) >> 4;
-			if (L1374_ui_CurrentRGBColor > L1375_ui_TargetRGBColor) {
-				if (L1374_ui_CurrentRGBColor > L1375_ui_TargetRGBColor + 1) {
-					*L1378_pui_PaletteRegister -= 32;
-				} else {
-					*L1378_pui_PaletteRegister -= 16;
-				}
-			} else {
-				if (L1374_ui_CurrentRGBColor < L1375_ui_TargetRGBColor) {
-					if (L1374_ui_CurrentRGBColor < L1375_ui_TargetRGBColor - 1) {
-						*L1378_pui_PaletteRegister += 32;
-					} else {
-						*L1378_pui_PaletteRegister += 16;
-					}
-				}
+			currentRGBColor = getFlag(*paletteRegister, D11_MASK_GREEN_COMPONENT) >> 4;
+			targetRGBColor = getFlag(P0849_pui_Palette[colIdx], D11_MASK_GREEN_COMPONENT) >> 4;
+			if (currentRGBColor > targetRGBColor) {
+				if (currentRGBColor > targetRGBColor + 1)
+					*paletteRegister -= 32;
+				else
+					*paletteRegister -= 16;
+			} else if (currentRGBColor < targetRGBColor) {
+				if (currentRGBColor < targetRGBColor - 1)
+					*paletteRegister += 32;
+				else
+					*paletteRegister += 16;
 			}
-			L1374_ui_CurrentRGBColor = getFlag(*L1378_pui_PaletteRegister, D10_MASK_RED_COMPONENT) >> 8;
-			L1375_ui_TargetRGBColor = getFlag(P0849_pui_Palette[L1376_i_Color], D10_MASK_RED_COMPONENT) >> 8;
-			if (L1374_ui_CurrentRGBColor > L1375_ui_TargetRGBColor) {
-				if (L1374_ui_CurrentRGBColor > L1375_ui_TargetRGBColor + 1) {
-					*L1378_pui_PaletteRegister -= 512;
-				} else {
-					*L1378_pui_PaletteRegister -= 256;
-				}
-			} else {
-				if (L1374_ui_CurrentRGBColor < L1375_ui_TargetRGBColor) {
-					if (L1374_ui_CurrentRGBColor < L1375_ui_TargetRGBColor - 1) {
-						*L1378_pui_PaletteRegister += 512;
-					} else {
-						*L1378_pui_PaletteRegister += 256;
-					}
-				}
+			currentRGBColor = getFlag(*paletteRegister, D10_MASK_RED_COMPONENT) >> 8;
+			targetRGBColor = getFlag(P0849_pui_Palette[colIdx], D10_MASK_RED_COMPONENT) >> 8;
+			if (currentRGBColor > targetRGBColor) {
+				if (currentRGBColor > targetRGBColor + 1)
+					*paletteRegister -= 512;
+				else
+					*paletteRegister -= 256;
+			} else if (currentRGBColor < targetRGBColor) {
+				if (currentRGBColor < targetRGBColor - 1)
+					*paletteRegister += 512;
+				else
+					*paletteRegister += 256;
 			}
 		}
 		_vm->f22_delay(1);


Commit: e2860eb838f55e4b0bf0d09d15224b0d90e86bf2
    https://github.com/scummvm/scummvm/commit/e2860eb838f55e4b0bf0d09d15224b0d90e86bf2
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: WIP renaming and cleanup in f115_cthulhu

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 1d14ae7..ca15619 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2868,19 +2868,9 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 	int16 projectileDirection;
 	int16 projectileAspectType;
 	int16 projectileBitmapIndexDelta;
-	bool doNotScaleWithKineticEnergy;
 	bool drawProjectileAsObject; /* When true, the code section to draw an object is called (with a goto) to draw the projectile, then the code section goes back to projectile processing with another goto */
-	bool sqaureHasProjectile;
 	uint16 currentViewCellToDraw = 0;
 	bool projectileFlipVertical = false;
-	bool projectileAspectTypeHasBackGraphicAndRotation;
-	bool flipVertical;
-	Explosion* explosion;
-	Explosion* fluxcageExplosion;
-	int16* explosionCoordinates;
-	int16 explosionScale;
-	bool squareHasExplosion;
-	bool rebirthExplosion;
 
 	/* This is the full dungeon view */
 	static Box boxExplosionPatternD0C = Box(0, 223, 0, 135); // @ G0105_s_Graphic558_Box_ExplosionPattern_D0C 
@@ -3067,15 +3057,16 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 
 	group = 0;
 	groupThing = Thing::_none;
-	drawCreaturesCompleted = sqaureHasProjectile = squareHasExplosion = false;
+	bool squareHasExplosion = drawCreaturesCompleted = false;
+	bool squareHasProjectile = false;
 	cellCounter = 0;
 	firstThingToDraw = thingParam;
 	if (getFlag(orderedViewCellOrdinals, k0x0008_CellOrder_DoorFront)) { /* If the function call is to draw objects on a door square viewed from the front */
 		doorFrontViewDrawingPass = (orderedViewCellOrdinals & 0x0001) + 1; /* Two function calls are made in that case to draw objects on both sides of the door frame. The door and its frame are drawn between the two calls. This value indicates the drawing pass so that creatures are drawn in the right order and so that Fluxcages are not drawn twice */
 		orderedViewCellOrdinals >>= 4; /* Remove the first nibble that was used for the door front view pass */
-	} else {
+	} else
 		doorFrontViewDrawingPass = 0; /* The function call is not to draw objects on a door square viewed from the front */
-	}
+
 	L0135_B_DrawAlcoveObjects = !(remainingViewCellOrdinalsToProcess = orderedViewCellOrdinals);
 	AL_10_viewSquareIndexBackup = viewSquareIndex;
 	viewLane = (viewSquareIndex + 3) % 3;
@@ -3103,7 +3094,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 				continue;
 			}
 			if (AL_4_thingType == k14_ProjectileThingType) {
-				sqaureHasProjectile = true;
+				squareHasProjectile = true;
 				continue;
 			}
 			if (AL_4_thingType == k15_ExplosionThingType) {
@@ -3113,9 +3104,9 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 			if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) { /* Square where objects are visible and object is located on cell being processed */
 				objectAspect = &(_objectAspects209[g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thingParam)]._objectAspectIndex]);
 				AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex;
-				if (useAlcoveObjectImage = (L0135_B_DrawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane)) {
+				if (useAlcoveObjectImage = (L0135_B_DrawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane))
 					AL_4_nativeBitmapIndex++;
-				}
+
 				coordinateSet = objectCoordinateSets[objectAspect->_coordinateSet][viewSquareIndex][AL_2_viewCell];
 				if (!coordinateSet[1]) /* If object is not visible */
 					continue;
@@ -3153,19 +3144,17 @@ T0115015_DrawProjectileAsObject:
 					if (flipHorizontal) {
 						derivedBitmapIndex += 2;
 						paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1;
-					} else {
-						if (useAlcoveObjectImage) {
+					} else if (useAlcoveObjectImage)
 							derivedBitmapIndex += 4;
-						}
-					}
-					if (f491_isDerivedBitmapInCache(derivedBitmapIndex)) {
+
+					if (f491_isDerivedBitmapInCache(derivedBitmapIndex))
 						AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
-					} else {
+					else {
 						bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 						f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), objectAspect->_byteWidth << 1, objectAspect->_height, byteWidth << 1, heightRedEagle, paletteChanges);
-						if (flipHorizontal) {
+						if (flipHorizontal)
 							f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, M77_getNormalizedByteWidth(byteWidth), heightRedEagle);
-						}
+
 						f493_addDerivedBitmap(derivedBitmapIndex);
 					}
 				}
@@ -3176,27 +3165,24 @@ T0115015_DrawProjectileAsObject:
 					boxByteGreen._y2 += shiftSets[AL_8_shiftSetIndex][objectPileShiftSetIndices[objectShiftIndex][1]];
 					objectShiftIndex++; /* The next object drawn will use the next shift values */
 					if (L0135_B_DrawAlcoveObjects) {
-						if (objectShiftIndex >= 14) {
+						if (objectShiftIndex >= 14)
 							objectShiftIndex = 2;
-						}
-					} else {
+					} else
 						objectShiftIndex &= 0x000F;
-					}
 				}
 				boxByteGreen._y1 = boxByteGreen._y2 - (heightRedEagle - 1);
-				if (boxByteGreen._y2 > 135) {
+				if (boxByteGreen._y2 > 135)
 					boxByteGreen._y2 = 135;
-				}
+
 				boxByteGreen._x2 = MIN(223, AL_4_xPos + byteWidth);
 				if (boxByteGreen._x1 = MAX(0, AL_4_xPos - byteWidth + 1)) {
-					if (flipHorizontal) {
+					if (flipHorizontal)
 						AL_4_xPos = paddingPixelCount;
-					} else {
+					else
 						AL_4_xPos = 0;
-					}
-				} else {
+				} else
 					AL_4_xPos = byteWidth - AL_4_xPos - 1;
-				}
+
 				if (drawingGrabbableObject) {
 					bitmapGreenAnt = AL_6_bitmapRedBanana;
 
@@ -3207,9 +3193,8 @@ T0115015_DrawProjectileAsObject:
 						if ((heightGreenGoat = AL_6_box->_y2 - AL_6_box->_y1) < 14) { /* If the box is too small then enlarge it a little */
 							heightGreenGoat = heightGreenGoat >> 1;
 							AL_6_box->_y1 += heightGreenGoat - 7;
-							if (heightGreenGoat < 4) {
+							if (heightGreenGoat < 4)
 								AL_6_box->_y2 -= heightGreenGoat - 3;
-							}
 						}
 					} else { /* If there are several grabbable objects then enlarge the box so it includes all objects */
 						AL_6_box->_x1 = MIN(AL_6_box->_x1, boxByteGreen._x1);
@@ -3233,6 +3218,7 @@ T0115015_DrawProjectileAsObject:
 		drawingLastBackRowCell = ((AL_2_viewCell <= k1_ViewCellFrontRight) || (cellCounter == 1)) && (!remainingViewCellOrdinalsToProcess || ((remainingViewCellOrdinalsToProcess & 0x0000000F) >= 3)); /* If (draw cell on the back row or second cell being processed) and (no more cells to draw or next cell to draw is a cell on the front row) */
 		if ((groupThing == Thing::_none) || drawCreaturesCompleted)
 			goto T0115129_DrawProjectiles; /* Skip code to draw creatures */
+
 		if (group == 0) { /* If all creature data and info has not already been gathered */
 			group = (Group*)_vm->_dungeonMan->f156_getThingData(groupThing);
 			activeGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
@@ -3249,63 +3235,52 @@ T0115015_DrawProjectileAsObject:
 			if (creatureSize == k1_MaskCreatureSizeHalf) {
 				AL_0_creatureIndexRed = 0;
 				creatureIndexGreen = -1;
-			} else {
+			} else
 				goto T0115129_DrawProjectiles; /* No creature to draw at cell, skip to projectiles */
-			}
 		}
 		creatureDirectionDelta = M21_normalizeModulo4(directionParam - _vm->_groupMan->M50_getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed));
 		twoHalfSquareCreaturesFrontView = false;
 		if ((AL_4_groupCells = activeGroup->_cells) == k255_CreatureTypeSingleCenteredCreature) { /* If there is a single centered creature in the group */
 			if (remainingViewCellOrdinalsToProcess || (doorFrontViewDrawingPass == 1))
 				goto T0115129_DrawProjectiles; /* Do not draw a single centered creature now, wait until second pass (for a front view door) or until all cells have been drawn so the creature is drawn over all the objects on the floor */
+
 			drawCreaturesCompleted = true;
-			if ((creatureSize == k1_MaskCreatureSizeHalf) && (creatureDirectionDelta & 0x0001)) { /* Side view of half square creature */
+			if ((creatureSize == k1_MaskCreatureSizeHalf) && (creatureDirectionDelta & 0x0001)) /* Side view of half square creature */
 				AL_2_viewCell = k3_HalfSizedViewCell_CenterColumn;
-			} else {
+			else
 				AL_2_viewCell = k4_HalfSizedViewCell_FrontRow;
-			}
-		} else {
-			if ((creatureSize == k1_MaskCreatureSizeHalf) && (drawingLastBackRowCell || !remainingViewCellOrdinalsToProcess || (creatureIndexGreen < 0))) {
-				if (drawingLastBackRowCell && (doorFrontViewDrawingPass != 2)) {
-					if ((creatureIndexGreen >= 0) && (creatureDirectionDelta & 0x0001)) {
-						AL_2_viewCell = k2_HalfSizedViewCell_BackRow; /* Side view of a half square creature on the back row. Drawn during pass 1 for a door square */
-					} else {
+		} else if ((creatureSize == k1_MaskCreatureSizeHalf) && (drawingLastBackRowCell || !remainingViewCellOrdinalsToProcess || (creatureIndexGreen < 0))) {
+			if (drawingLastBackRowCell && (doorFrontViewDrawingPass != 2)) {
+				if ((creatureIndexGreen >= 0) && (creatureDirectionDelta & 0x0001))
+					AL_2_viewCell = k2_HalfSizedViewCell_BackRow; /* Side view of a half square creature on the back row. Drawn during pass 1 for a door square */
+				else
+					goto T0115129_DrawProjectiles;
+			} else if ((doorFrontViewDrawingPass != 1) && !remainingViewCellOrdinalsToProcess) {
+				if (creatureDirectionDelta & 0x0001) {
+					if (creatureIndexGreen >= 0)
+						AL_2_viewCell = k4_HalfSizedViewCell_FrontRow; /* Side view of a half square creature on the front row. Drawn during pass 2 for a door square */
+					else
 						goto T0115129_DrawProjectiles;
-					}
 				} else {
-					if ((doorFrontViewDrawingPass != 1) && !remainingViewCellOrdinalsToProcess) {
-						if (creatureDirectionDelta & 0x0001) {
-							if (creatureIndexGreen >= 0) {
-								AL_2_viewCell = k4_HalfSizedViewCell_FrontRow; /* Side view of a half square creature on the front row. Drawn during pass 2 for a door square */
-							} else {
-								goto T0115129_DrawProjectiles;
-							}
-						} else {
-							drawCreaturesCompleted = true;
-							if (creatureIndexGreen < 0) {
-								creatureIndexGreen = 0;
-							}
-							twoHalfSquareCreaturesFrontView = group->getCount();
-							if (((AL_4_groupCells = _vm->_groupMan->M50_getCreatureValue(AL_4_groupCells, AL_0_creatureIndexRed)) == directionParam) || (AL_4_groupCells == returnPrevVal(directionParam))) {
-
-								AL_2_viewCell = k0_HalfSizedViewCell_LeftColumn;
-							} else {
-								AL_2_viewCell = k1_HalfSizedViewCell_RightColumn;
-							}
-						}
-					} else {
-						goto T0115129_DrawProjectiles;
-					}
+					drawCreaturesCompleted = true;
+					if (creatureIndexGreen < 0)
+						creatureIndexGreen = 0;
+
+					twoHalfSquareCreaturesFrontView = group->getCount();
+					if (((AL_4_groupCells = _vm->_groupMan->M50_getCreatureValue(AL_4_groupCells, AL_0_creatureIndexRed)) == directionParam) || (AL_4_groupCells == returnPrevVal(directionParam)))
+						AL_2_viewCell = k0_HalfSizedViewCell_LeftColumn;
+					else
+						AL_2_viewCell = k1_HalfSizedViewCell_RightColumn;
 				}
-			} else {
-				if (creatureSize != k0_MaskCreatureSizeQuarter)
-					goto T0115129_DrawProjectiles;
-			}
-		}
+			} else
+				goto T0115129_DrawProjectiles;
+		} else if (creatureSize != k0_MaskCreatureSizeQuarter)
+			goto T0115129_DrawProjectiles;
+
 		creatureAspectInt = activeGroup->_aspect[creatureIndexGreen];
-		if (viewSquareIndex > k9_ViewSquare_D0C) {
+		if (viewSquareIndex > k9_ViewSquare_D0C)
 			viewSquareIndex--;
-		}
+
 T0115077_DrawSecondHalfSquareCreature:
 		coordinateSet = creatureCoordinateSets[((CreatureAspect*)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell];
 		if (!coordinateSet[1])
@@ -3331,6 +3306,7 @@ T0115077_DrawSecondHalfSquareCreature:
 					AL_4_nativeBitmapIndex++; /* If the creature has a side image, it preceeds the attack image */
 					derivedBitmapIndex += 2;
 				}
+
 				if (getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack)) {
 					AL_4_nativeBitmapIndex++; /* If the creature has a back image, it preceeds the attack image */
 					derivedBitmapIndex += 2;
@@ -3347,19 +3323,16 @@ T0115077_DrawSecondHalfSquareCreature:
 						AL_4_nativeBitmapIndex++; /* If the creature does not have a side image, the back image follows the front image */
 						derivedBitmapIndex += 2;
 					}
-				} else {
-					if (useFlippedHorizontallyCreatureFrontImage = getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack) && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
+				} else if (useFlippedHorizontallyCreatureFrontImage = getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack) && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
+					derivedBitmapIndex += 2;
+					if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide))
+						derivedBitmapIndex += 2;
+
+					if (getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack))
+						derivedBitmapIndex += 2;
+
+					if (getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack))
 						derivedBitmapIndex += 2;
-						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) {
-							derivedBitmapIndex += 2;
-						}
-						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack)) {
-							derivedBitmapIndex += 2;
-						}
-						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack)) {
-							derivedBitmapIndex += 2;
-						}
-					}
 				}
 			}
 		}
@@ -3373,29 +3346,25 @@ T0115077_DrawSecondHalfSquareCreature:
 					f99_copyBitmapAndFlipHorizontal(AL_6_bitmapRedBanana, _g74_tmpBitmap, byteWidth, heightRedEagle);
 					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
-			} else {
-				if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) {
-					AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
-					if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
-						f99_copyBitmapAndFlipHorizontal(AL_6_bitmapRedBanana, _g74_tmpBitmap, byteWidth, heightRedEagle);
-						AL_6_bitmapRedBanana = _g74_tmpBitmap;
-					}
-				} else { /* Use first additional derived graphic: front D1 */
-					if (f491_isDerivedBitmapInCache(derivedBitmapIndex)) { /* If derived graphic is already in memory */
-						AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
-					} else {
-						bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
-						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) {
-							f99_copyBitmapAndFlipHorizontal(bitmapGreenAnt, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), byteWidth, heightRedEagle);
-						}
-						f493_addDerivedBitmap(derivedBitmapIndex);
-					}
+			} else if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) {
+				AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
+				if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
+					f99_copyBitmapAndFlipHorizontal(AL_6_bitmapRedBanana, _g74_tmpBitmap, byteWidth, heightRedEagle);
+					AL_6_bitmapRedBanana = _g74_tmpBitmap;
 				}
+			} else if (f491_isDerivedBitmapInCache(derivedBitmapIndex)) /* If derived graphic is already in memory */
+				AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
+			else {
+				bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
+				if (getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack))
+					f99_copyBitmapAndFlipHorizontal(bitmapGreenAnt, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), byteWidth, heightRedEagle);
+
+				f493_addDerivedBitmap(derivedBitmapIndex);
 			}
 		} else { /* Creature is on D2 or D3 */
-			if (useFlippedHorizontallyCreatureFrontImage) {
+			if (useFlippedHorizontallyCreatureFrontImage)
 				derivedBitmapIndex++; /* Skip front D1 image in additional graphics */
-			}
+
 			if (viewSquareIndex >= k3_ViewSquare_D2C) { /* Creature is on D2 */
 				derivedBitmapIndex++; /* Skip front D3 image in additional graphics */
 				AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front;
@@ -3408,12 +3377,13 @@ T0115077_DrawSecondHalfSquareCreature:
 				paletteChanges = _palChangesCreatureD3;
 				scale = k16_Scale_D3;
 			}
+
 			byteWidth = M78_getScaledDimension(sourceByteWidth, scale);
 			heightRedEagle = M78_getScaledDimension(sourceHeight, scale);
 			transparentColor = paletteChanges[((CreatureAspect*)objectAspect)->getTranspColour()] / 10;
-			if (derivedBitmapInCache = f491_isDerivedBitmapInCache(derivedBitmapIndex)) {
+			if (derivedBitmapInCache = f491_isDerivedBitmapInCache(derivedBitmapIndex))
 				AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
-			} else {
+			else {
 				bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 				f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), sourceByteWidth << 1, sourceHeight, byteWidth << 1, heightRedEagle, paletteChanges);
 				f493_addDerivedBitmap(derivedBitmapIndex);
@@ -3431,9 +3401,8 @@ T0115077_DrawSecondHalfSquareCreature:
 					f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 				}
 				creaturePaddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1;
-			} else {
+			} else
 				creaturePaddingPixelCount = 0;
-			}
 		}
 		AL_4_yPos = coordinateSet[1];
 		AL_4_yPos += shiftSets[AL_8_shiftSetIndex][M23_getVerticalOffsetM23(creatureAspectInt)];
@@ -3441,13 +3410,12 @@ T0115077_DrawSecondHalfSquareCreature:
 		boxByteGreen._y1 = MAX(0, AL_4_yPos - (heightRedEagle - 1));
 		AL_4_xPos = coordinateSet[0];
 		AL_4_xPos += shiftSets[AL_8_shiftSetIndex][M22_getHorizontalOffsetM22(creatureAspectInt)];
-		if (viewLane == k1_ViewLaneLeft) {
+
+		if (viewLane == k1_ViewLaneLeft)
 			AL_4_xPos -= 100;
-		} else {
-			if (viewLane) { /* Lane right */
-				AL_4_xPos += 100;
-			}
-		}
+		else if (viewLane) /* Lane right */
+			AL_4_xPos += 100;
+
 		if (!(boxByteGreen._x2 = f26_getBoundedValue(0, AL_4_xPos + byteWidth, 223)))
 			goto T0115126_CreatureNotVisible;
 		int16 AL_0_creaturePosX;
@@ -3455,25 +3423,26 @@ T0115077_DrawSecondHalfSquareCreature:
 			if (boxByteGreen._x1 == 223)
 				goto T0115126_CreatureNotVisible;
 			AL_0_creaturePosX = creaturePaddingPixelCount;
-		} else {
+		} else
 			AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1);
-		}
+
 		f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_0_creaturePosX, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, (Color)transparentColor, heightRedEagle, 136);
 T0115126_CreatureNotVisible:
 		if (twoHalfSquareCreaturesFrontView) {
 			twoHalfSquareCreaturesFrontView = false;
 			creatureAspectInt = activeGroup->_aspect[!creatureIndexGreen]; /* Aspect of the other creature in the pair */
-			if (AL_2_viewCell == k1_HalfSizedViewCell_RightColumn) {
+			if (AL_2_viewCell == k1_HalfSizedViewCell_RightColumn)
 				AL_2_viewCell = k0_HalfSizedViewCell_LeftColumn;
-			} else {
+			else
 				AL_2_viewCell = k1_HalfSizedViewCell_RightColumn;
-			}
+
 			goto T0115077_DrawSecondHalfSquareCreature;
 		}
 		/* Draw projectiles */
 T0115129_DrawProjectiles:
-		if (!sqaureHasProjectile || ((viewSquareIndex = AL_10_viewSquareIndexBackup) > k9_ViewSquare_D0C) || (!(projectilePosX = objectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0]))) /* If there is no projectile to draw or if projectiles are not visible on the specified square or on the cell being drawn */
+		if (!squareHasProjectile || ((viewSquareIndex = AL_10_viewSquareIndexBackup) > k9_ViewSquare_D0C) || (!(projectilePosX = objectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0]))) /* If there is no projectile to draw or if projectiles are not visible on the specified square or on the cell being drawn */
 			continue;
+
 		thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */
 		do {
 			if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) {
@@ -3482,7 +3451,9 @@ T0115129_DrawProjectiles:
 					objectAspect = (ObjectAspect*)&_projectileAspect[_vm->M1_ordinalToIndex(-AL_4_projectileAspect)];
 					AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
 					projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
-					if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask)) || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == k9_ViewSquare_D0C)) {
+
+					bool doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask);
+					if ((doNotScaleWithKineticEnergy || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == k9_ViewSquare_D0C)) {
 						scale = 0; /* Use native bitmap without resizing */
 						byteWidth = ((ProjectileAspect*)objectAspect)->_byteWidth;
 						heightRedEagle = ((ProjectileAspect*)objectAspect)->_height;
@@ -3495,38 +3466,38 @@ T0115129_DrawProjectiles:
 						byteWidth = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_byteWidth, scale);
 						heightRedEagle = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale);
 					}
-					if (projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == k0_ProjectileAspectHasBackGraphicRotation)) {
+					bool projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == k0_ProjectileAspectHasBackGraphicRotation);
+					if (projectileAspectTypeHasBackGraphicAndRotation)
 						projectileFlipVertical = ((mapXpos + mapYpos) & 0x0001);
-					}
+
+					bool flipVertical;
 					if (projectileAspectType == k3_ProjectileAspectHasNone) {
 						projectileBitmapIndexDelta = 0;
 						flipVertical = flipHorizontal = false;
-					} else {
-						if (isOrientedWestEast(Direction(projectileDirection = _vm->_timeline->_g370_events[projectile->_eventIndex]._C._projectile.getDir())) != isOrientedWestEast(directionParam)) {
-							if (projectileAspectType == k2_ProjectileAspectHasRotation) {
-								projectileBitmapIndexDelta = 1;
-							} else {
-								projectileBitmapIndexDelta = 2;
-							}
-							if (projectileAspectTypeHasBackGraphicAndRotation) {
-								flipHorizontal = !AL_2_viewCell || (AL_2_viewCell == k3_ViewCellBackLeft);
-								if (!(flipVertical = projectileFlipVertical)) {
-									flipHorizontal = !flipHorizontal;
-								}
-							} else {
-								flipVertical = false;
-								flipHorizontal = (returnNextVal(directionParam) == projectileDirection);
-							}
+					} else if (isOrientedWestEast(Direction(projectileDirection = _vm->_timeline->_g370_events[projectile->_eventIndex]._C._projectile.getDir())) != isOrientedWestEast(directionParam)) {
+						if (projectileAspectType == k2_ProjectileAspectHasRotation)
+							projectileBitmapIndexDelta = 1;
+						else
+							projectileBitmapIndexDelta = 2;
+
+						if (projectileAspectTypeHasBackGraphicAndRotation) {
+							flipHorizontal = !AL_2_viewCell || (AL_2_viewCell == k3_ViewCellBackLeft);
+							if (!(flipVertical = projectileFlipVertical))
+								flipHorizontal = !flipHorizontal;
 						} else {
-							if ((projectileAspectType >= k2_ProjectileAspectHasRotation) || ((projectileAspectType == k1_ProjectileAspectBackGraphic) && (projectileDirection != directionParam)) || (projectileAspectTypeHasBackGraphicAndRotation && projectileFlipVertical)) { /* If the projectile does not have a back graphic or has one but is not seen from the back or if it has a back graphic and rotation and should be flipped vertically */
-								projectileBitmapIndexDelta = 0;
-							} else {
-								projectileBitmapIndexDelta = 1;
-							}
-							flipVertical = projectileAspectTypeHasBackGraphicAndRotation && (AL_2_viewCell < k2_ViewCellBackRight);
-							flipHorizontal = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0010_ProjectileSideMask) && !((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight))));
+							flipVertical = false;
+							flipHorizontal = (returnNextVal(directionParam) == projectileDirection);
 						}
+					} else {
+						if ((projectileAspectType >= k2_ProjectileAspectHasRotation) || ((projectileAspectType == k1_ProjectileAspectBackGraphic) && (projectileDirection != directionParam)) || (projectileAspectTypeHasBackGraphicAndRotation && projectileFlipVertical)) /* If the projectile does not have a back graphic or has one but is not seen from the back or if it has a back graphic and rotation and should be flipped vertically */
+							projectileBitmapIndexDelta = 0;
+						else
+							projectileBitmapIndexDelta = 1;
+
+						flipVertical = projectileAspectTypeHasBackGraphicAndRotation && (AL_2_viewCell < k2_ViewCellBackRight);
+						flipHorizontal = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0010_ProjectileSideMask) && !((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight))));
 					}
+
 					AL_4_nativeBitmapIndex += projectileBitmapIndexDelta;
 					paddingPixelCount = 0;
 					if (!scale) {
@@ -3591,18 +3562,23 @@ T0115129_DrawProjectiles:
 T0115171_BackFromT0115015_DrawProjectileAsObject:;
 		} while ((thingParam = _vm->_dungeonMan->f159_getNextThing(thingParam)) != Thing::_endOfList);
 	} while (remainingViewCellOrdinalsToProcess);
+
 	/* Draw explosions */
 	if (!squareHasExplosion)
-		goto T0115214_Return;
-	fluxcageExplosion = 0;
+		return;
+
+	Explosion *fluxcageExplosion = nullptr;
+	int16 *explosionCoordinates;
+
 	AL_1_viewSquareExplosionIndex = AL_10_viewSquareIndexBackup + 3; /* Convert square index to square index for explosions */
 	AL_10_explosionScaleIndex = AL_1_viewSquareExplosionIndex / 3;
 	thingParam = firstThingToDraw; /* Restart processing list of things from the beginning. The next loop draws only explosion things among the list */
 	do {
 		if (thingParam.getType() == k15_ExplosionThingType) {
 			AL_2_cellPurpleMan = thingParam.getCell();
-			explosion = (Explosion*)_vm->_dungeonMan->f156_getThingData(thingParam);
-			if ((rebirthExplosion = ((uint16)(AL_4_explosionType = explosion->getType()) >= k100_ExplosionType_RebirthStep1)) && ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion) || (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion) || (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */
+			Explosion *explosion = (Explosion*)_vm->_dungeonMan->f156_getThingData(thingParam);
+			bool rebirthExplosion = ((uint16)(AL_4_explosionType = explosion->getType()) >= k100_ExplosionType_RebirthStep1);
+			if (rebirthExplosion && ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion) || (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion) || (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */
 				continue;
 			bool smoke = false;
 			if ((AL_4_explosionType == k0_ExplosionType_Fireball) || (AL_4_explosionType == k2_ExplosionType_LightningBolt) || (AL_4_explosionType == k101_ExplosionType_RebirthStep2)) {
@@ -3659,6 +3635,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 				warning(false, "DISABLED CODE: f480_releaseBlock in f115_cthulhu");
 				//f480_releaseBlock(k0_DerivedBitmapViewport | 0x8000);
 			} else {
+				int16 explosionScale;
 				if (rebirthExplosion) {
 					explosionCoordinates = rebirthStep2ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
 					explosionScale = explosionCoordinates[2];
@@ -3677,7 +3654,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 				}
 				AL_6_bitmapRedBanana = f114_getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle);
 T0115200_DrawExplosion:
-				flipVertical = _vm->getRandomNumber(2);
+				bool flipVertical = _vm->getRandomNumber(2);
 				paddingPixelCount = 0;
 				if (flipHorizontal = _vm->getRandomNumber(2)) {
 					paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1; /* Number of unused pixels in the units on the right of the bitmap */
@@ -3715,14 +3692,13 @@ T0115200_DrawExplosion:
 			}
 		}
 	} while ((thingParam = _vm->_dungeonMan->f159_getNextThing(thingParam)) != Thing::_endOfList);
+
 	if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_g77_doNotDrawFluxcagesDuringEndgame) { /* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */
 		AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */
 		FieldAspect fieldAspect = _fieldAspects188[viewSquareIndex];
 		(fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */
 		f113_drawField(&fieldAspect, _frameWalls163[viewSquareIndex]._box);
 	}
-T0115214_Return:
-	;
 }
 
 uint16 DisplayMan::M77_getNormalizedByteWidth(uint16 byteWidth) {


Commit: ab9563b7ff6dc60de47e8ab073766ee29fbf68c4
    https://github.com/scummvm/scummvm/commit/ab9563b7ff6dc60de47e8ab073766ee29fbf68c4
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some more work on f115_cthulhu

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index ca15619..af4583e 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2809,12 +2809,8 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 #define AL_4_projectileAspect     L0127_i_Multiple
 #define AL_4_explosionType        L0127_i_Multiple
 #define AL_4_explosionAspectIndex L0127_i_Multiple
-	byte* L0128_puc_Multiple;
-#define AL_6_bitmapRedBanana L0128_puc_Multiple
 	ObjectAspect* objectAspect;
 	uint32 remainingViewCellOrdinalsToProcess;
-	byte* paletteChanges;
-	byte* bitmapGreenAnt;
 	byte* coordinateSet;
 	int16 derivedBitmapIndex = -1;
 	bool L0135_B_DrawAlcoveObjects;
@@ -2837,10 +2833,6 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 	uint16 L0150_ui_Multiple = 0;
 #define AL_8_shiftSetIndex        L0150_ui_Multiple
 #define AL_8_projectileScaleIndex L0150_ui_Multiple
-	Thing groupThing;
-	Group* group;
-	ActiveGroup* activeGroup;
-	CreatureInfo* creatureInfo;
 	CreatureAspect* creatureAspectStruct;
 	int16 creatureSize;
 	int16 creatureDirectionDelta;
@@ -2848,10 +2840,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 	int16 creatureAspectInt;
 	int16 creatureIndexGreen;
 	int16 transparentColor;
-	int16 sourceByteWidth;
-	int16 sourceHeight;
 	int16 creaturePaddingPixelCount;
-	bool twoHalfSquareCreaturesFrontView;
 	bool drawingLastBackRowCell;
 	bool useCreatureSideBitmap;
 	bool useCreatureBackBitmap;
@@ -2860,10 +2849,6 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 	bool useFlippedHorizontallyCreatureFrontImage;
 	bool drawCreaturesCompleted; /* Set to true when the last creature that the function should draw is being drawn. This is used to avoid processing the code to draw creatures for the remaining square cells */
 	int16 doorFrontViewDrawingPass; /* Value 0, 1 or 2 */
-	int16 scale;
-	bool derivedBitmapInCache;
-	Projectile* projectile;
-	byte projectileCoordinates[2];
 	int16 projectilePosX;
 	int16 projectileDirection;
 	int16 projectileAspectType;
@@ -3055,8 +3040,8 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 	if (thingParam == Thing::_endOfList)
 		return;
 
-	group = 0;
-	groupThing = Thing::_none;
+	Group *group = nullptr;
+	Thing groupThing = Thing::_none;
 	bool squareHasExplosion = drawCreaturesCompleted = false;
 	bool squareHasProjectile = false;
 	cellCounter = 0;
@@ -3070,6 +3055,9 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 	L0135_B_DrawAlcoveObjects = !(remainingViewCellOrdinalsToProcess = orderedViewCellOrdinals);
 	AL_10_viewSquareIndexBackup = viewSquareIndex;
 	viewLane = (viewSquareIndex + 3) % 3;
+	bool twoHalfSquareCreaturesFrontView;
+	byte *bitmapRedBanana;
+	byte *bitmapGreenAnt;
 	do {
 		/* Draw objects */
 		if (L0135_B_DrawAlcoveObjects) {
@@ -3093,14 +3081,17 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 				groupThing = thingParam;
 				continue;
 			}
+
 			if (AL_4_thingType == k14_ProjectileThingType) {
 				squareHasProjectile = true;
 				continue;
 			}
+
 			if (AL_4_thingType == k15_ExplosionThingType) {
 				squareHasExplosion = true;
 				continue;
 			}
+
 			if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) { /* Square where objects are visible and object is located on cell being processed */
 				objectAspect = &(_objectAspects209[g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thingParam)]._objectAspectIndex]);
 				AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex;
@@ -3116,19 +3107,21 @@ T0115015_DrawProjectileAsObject:
 					((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight))));
 				/* Flip horizontally if object graphic requires it and is not being drawn in an alcove and the object is either on the right lane or on the right column of the center lane */
 				paddingPixelCount = 0;
+
 				if ((viewSquareIndex == k9_ViewSquare_D0C) || ((viewSquareIndex >= k6_ViewSquare_D1C) && (AL_2_viewCell >= k2_ViewCellBackRight))) {
 					drawingGrabbableObject = (!viewLane && !drawProjectileAsObject); /* If object is in the center lane (only D0C or D1C with condition above) and is not a projectile */
 					AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
-					AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */
+					bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */
 					byteWidth = objectAspect->_byteWidth;
 					heightRedEagle = objectAspect->_height;
 					if (flipHorizontal) {
-						f99_copyBitmapAndFlipHorizontal(AL_6_bitmapRedBanana, _g74_tmpBitmap, byteWidth, heightRedEagle);
-						AL_6_bitmapRedBanana = _g74_tmpBitmap;
+						f99_copyBitmapAndFlipHorizontal(bitmapRedBanana, _g74_tmpBitmap, byteWidth, heightRedEagle);
+						bitmapRedBanana = _g74_tmpBitmap;
 					}
 				} else {
 					drawingGrabbableObject = false;
 					derivedBitmapIndex = k104_DerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex;
+					byte* paletteChanges;
 					if ((viewSquareIndex >= k6_ViewSquare_D1C) || ((viewSquareIndex >= k3_ViewSquare_D2C) && (AL_2_viewCell >= k2_ViewCellBackRight))) {
 						derivedBitmapIndex++;
 						AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front;
@@ -3148,12 +3141,12 @@ T0115015_DrawProjectileAsObject:
 							derivedBitmapIndex += 4;
 
 					if (f491_isDerivedBitmapInCache(derivedBitmapIndex))
-						AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
+						bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 					else {
 						bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
-						f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), objectAspect->_byteWidth << 1, objectAspect->_height, byteWidth << 1, heightRedEagle, paletteChanges);
+						f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), objectAspect->_byteWidth << 1, objectAspect->_height, byteWidth << 1, heightRedEagle, paletteChanges);
 						if (flipHorizontal)
-							f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, M77_getNormalizedByteWidth(byteWidth), heightRedEagle);
+							f130_flipBitmapHorizontal(bitmapRedBanana, M77_getNormalizedByteWidth(byteWidth), heightRedEagle);
 
 						f493_addDerivedBitmap(derivedBitmapIndex);
 					}
@@ -3184,7 +3177,7 @@ T0115015_DrawProjectileAsObject:
 					AL_4_xPos = byteWidth - AL_4_xPos - 1;
 
 				if (drawingGrabbableObject) {
-					bitmapGreenAnt = AL_6_bitmapRedBanana;
+					bitmapGreenAnt = bitmapRedBanana;
 
 					Box *AL_6_box = &_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[AL_2_viewCell];
 
@@ -3202,10 +3195,10 @@ T0115015_DrawProjectileAsObject:
 						AL_6_box->_y1 = MIN(AL_6_box->_y1, boxByteGreen._y1);
 						AL_6_box->_y2 = MAX(AL_6_box->_y2, boxByteGreen._y2);
 					}
-					AL_6_bitmapRedBanana = bitmapGreenAnt;
+					bitmapRedBanana = bitmapGreenAnt;
 					_vm->_dungeonMan->_g292_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */
 				}
-				f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
+				f132_blitToBitmap(bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
 				if (drawProjectileAsObject)
 					goto T0115171_BackFromT0115015_DrawProjectileAsObject;
 			}
@@ -3219,10 +3212,11 @@ T0115015_DrawProjectileAsObject:
 		if ((groupThing == Thing::_none) || drawCreaturesCompleted)
 			goto T0115129_DrawProjectiles; /* Skip code to draw creatures */
 
-		if (group == 0) { /* If all creature data and info has not already been gathered */
+		ActiveGroup *activeGroup;
+		if (group == nullptr) { /* If all creature data and info has not already been gathered */
 			group = (Group*)_vm->_dungeonMan->f156_getThingData(groupThing);
 			activeGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
-			creatureInfo = &g243_CreatureInfo[group->_type];
+			CreatureInfo *creatureInfo = &g243_CreatureInfo[group->_type];
 			creatureAspectStruct = &_creatureAspects219[creatureInfo->_creatureAspectIndex];
 			creatureSize = getFlag(creatureInfo->_attributes, k0x0003_MaskCreatureInfo_size);
 			creatureGraphicInfoGreen = creatureInfo->_graphicInfo;
@@ -3231,13 +3225,12 @@ T0115015_DrawProjectileAsObject:
 		if (AL_0_creatureIndexRed = _vm->_groupMan->f176_getCreatureOrdinalInCell(group, cellYellowBear)) { /* If there is a creature on the cell being processed */
 			AL_0_creatureIndexRed--; /* Convert ordinal to index */
 			creatureIndexGreen = AL_0_creatureIndexRed;
-		} else {
-			if (creatureSize == k1_MaskCreatureSizeHalf) {
-				AL_0_creatureIndexRed = 0;
-				creatureIndexGreen = -1;
-			} else
-				goto T0115129_DrawProjectiles; /* No creature to draw at cell, skip to projectiles */
-		}
+		} else if (creatureSize == k1_MaskCreatureSizeHalf) {
+			AL_0_creatureIndexRed = 0;
+			creatureIndexGreen = -1;
+		} else
+			goto T0115129_DrawProjectiles; /* No creature to draw at cell, skip to projectiles */
+
 		creatureDirectionDelta = M21_normalizeModulo4(directionParam - _vm->_groupMan->M50_getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed));
 		twoHalfSquareCreaturesFrontView = false;
 		if ((AL_4_groupCells = activeGroup->_cells) == k255_CreatureTypeSingleCenteredCreature) { /* If there is a single centered creature in the group */
@@ -3288,6 +3281,8 @@ T0115077_DrawSecondHalfSquareCreature:
 		AL_0_creatureGraphicInfoRed = creatureGraphicInfoGreen;
 		AL_4_nativeBitmapIndex = k446_FirstCreatureGraphicIndice + ((CreatureAspect*)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */
 		derivedBitmapIndex = ((CreatureAspect*)objectAspect)->_firstDerivedBitmapIndex;
+		int16 sourceByteWidth;
+		int16 sourceHeight;
 		if (useCreatureSideBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide) && (creatureDirectionDelta & 0x0001)) {
 			useCreatureAttackBitmap = useFlippedHorizontallyCreatureFrontImage = useCreatureBackBitmap = false;
 			AL_4_nativeBitmapIndex++; /* Skip the front image. Side image is right after the front image */
@@ -3336,28 +3331,30 @@ T0115077_DrawSecondHalfSquareCreature:
 				}
 			}
 		}
+
+		int16 scale;
 		if (viewSquareIndex >= k6_ViewSquare_D1C) { /* Creature is on D1 */
 			creaturePaddingPixelCount = 0;
 			AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
 			transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour();
 			if (useCreatureSideBitmap) {
-				AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
+				bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 				if (creatureDirectionDelta == 1) {
-					f99_copyBitmapAndFlipHorizontal(AL_6_bitmapRedBanana, _g74_tmpBitmap, byteWidth, heightRedEagle);
-					AL_6_bitmapRedBanana = _g74_tmpBitmap;
+					f99_copyBitmapAndFlipHorizontal(bitmapRedBanana, _g74_tmpBitmap, byteWidth, heightRedEagle);
+					bitmapRedBanana = _g74_tmpBitmap;
 				}
 			} else if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) {
-				AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
+				bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 				if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
-					f99_copyBitmapAndFlipHorizontal(AL_6_bitmapRedBanana, _g74_tmpBitmap, byteWidth, heightRedEagle);
-					AL_6_bitmapRedBanana = _g74_tmpBitmap;
+					f99_copyBitmapAndFlipHorizontal(bitmapRedBanana, _g74_tmpBitmap, byteWidth, heightRedEagle);
+					bitmapRedBanana = _g74_tmpBitmap;
 				}
 			} else if (f491_isDerivedBitmapInCache(derivedBitmapIndex)) /* If derived graphic is already in memory */
-				AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
+				bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 			else {
 				bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 				if (getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack))
-					f99_copyBitmapAndFlipHorizontal(bitmapGreenAnt, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), byteWidth, heightRedEagle);
+					f99_copyBitmapAndFlipHorizontal(bitmapGreenAnt, bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), byteWidth, heightRedEagle);
 
 				f493_addDerivedBitmap(derivedBitmapIndex);
 			}
@@ -3365,6 +3362,7 @@ T0115077_DrawSecondHalfSquareCreature:
 			if (useFlippedHorizontallyCreatureFrontImage)
 				derivedBitmapIndex++; /* Skip front D1 image in additional graphics */
 
+			byte* paletteChanges;
 			if (viewSquareIndex >= k3_ViewSquare_D2C) { /* Creature is on D2 */
 				derivedBitmapIndex++; /* Skip front D3 image in additional graphics */
 				AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front;
@@ -3381,11 +3379,13 @@ T0115077_DrawSecondHalfSquareCreature:
 			byteWidth = M78_getScaledDimension(sourceByteWidth, scale);
 			heightRedEagle = M78_getScaledDimension(sourceHeight, scale);
 			transparentColor = paletteChanges[((CreatureAspect*)objectAspect)->getTranspColour()] / 10;
-			if (derivedBitmapInCache = f491_isDerivedBitmapInCache(derivedBitmapIndex))
-				AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
+
+			bool derivedBitmapInCache = f491_isDerivedBitmapInCache(derivedBitmapIndex);
+			if (derivedBitmapInCache)
+				bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 			else {
 				bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), sourceByteWidth << 1, sourceHeight, byteWidth << 1, heightRedEagle, paletteChanges);
+				f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), sourceByteWidth << 1, sourceHeight, byteWidth << 1, heightRedEagle, paletteChanges);
 				f493_addDerivedBitmap(derivedBitmapIndex);
 			}
 			if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */
@@ -3395,10 +3395,10 @@ T0115077_DrawSecondHalfSquareCreature:
 				if (!useFlippedHorizontallyCreatureFrontImage || !derivedBitmapInCache) {
 					AL_4_normalizdByteWidth = M77_getNormalizedByteWidth(byteWidth);
 					if (!useFlippedHorizontallyCreatureFrontImage) {
-						memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, sizeof(byte) * AL_4_normalizdByteWidth * heightRedEagle);
-						AL_6_bitmapRedBanana = _g74_tmpBitmap;
+						memcpy(_g74_tmpBitmap, bitmapRedBanana, sizeof(byte) * AL_4_normalizdByteWidth * heightRedEagle);
+						bitmapRedBanana = _g74_tmpBitmap;
 					}
-					f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
+					f130_flipBitmapHorizontal(bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 				}
 				creaturePaddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1;
 			} else
@@ -3426,7 +3426,7 @@ T0115077_DrawSecondHalfSquareCreature:
 		} else
 			AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1);
 
-		f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_0_creaturePosX, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, (Color)transparentColor, heightRedEagle, 136);
+		f132_blitToBitmap(bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_0_creaturePosX, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, (Color)transparentColor, heightRedEagle, 136);
 T0115126_CreatureNotVisible:
 		if (twoHalfSquareCreaturesFrontView) {
 			twoHalfSquareCreaturesFrontView = false;
@@ -3446,7 +3446,7 @@ T0115129_DrawProjectiles:
 		thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */
 		do {
 			if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) {
-				projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(thingParam);
+				Projectile *projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(thingParam);
 				if ((AL_4_projectileAspect = _vm->_dungeonMan->f142_getProjectileAspect(projectile->_slot)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
 					objectAspect = (ObjectAspect*)&_projectileAspect[_vm->M1_ordinalToIndex(-AL_4_projectileAspect)];
 					AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
@@ -3501,21 +3501,21 @@ T0115129_DrawProjectiles:
 					AL_4_nativeBitmapIndex += projectileBitmapIndexDelta;
 					paddingPixelCount = 0;
 					if (!scale) {
-						AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
+						bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 					} else {
-						if (flipHorizontal) {
+						if (flipHorizontal)
 							paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1;
-						}
+
 						if (doNotScaleWithKineticEnergy && f491_isDerivedBitmapInCache(derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstDerivedBitmapRelativeIndex + (projectileBitmapIndexDelta * 6) + AL_8_projectileScaleIndex)) {
-							AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
+							bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
 						} else {
 							bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
-							if (doNotScaleWithKineticEnergy) {
-								AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
-							} else {
-								AL_6_bitmapRedBanana = _g74_tmpBitmap;
-							}
-							f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
+							if (doNotScaleWithKineticEnergy)
+								bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
+							else
+								bitmapRedBanana = _g74_tmpBitmap;
+
+							f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
 							if (doNotScaleWithKineticEnergy) {
 								f493_addDerivedBitmap(derivedBitmapIndex);
 							}
@@ -3523,33 +3523,31 @@ T0115129_DrawProjectiles:
 					}
 					if (flipHorizontal || flipVertical) {
 						AL_4_normalizdByteWidth = M77_getNormalizedByteWidth(byteWidth);
-						if (AL_6_bitmapRedBanana != _g74_tmpBitmap) {
-							memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, sizeof(byte) * AL_4_normalizdByteWidth * heightRedEagle);
-							AL_6_bitmapRedBanana = _g74_tmpBitmap;
-						}
-						if (flipVertical) {
-							f131_flipVertical(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
-						}
-						if (flipHorizontal) {
-							f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
+						if (bitmapRedBanana != _g74_tmpBitmap) {
+							memcpy(_g74_tmpBitmap, bitmapRedBanana, sizeof(byte) * AL_4_normalizdByteWidth * heightRedEagle);
+							bitmapRedBanana = _g74_tmpBitmap;
 						}
+						if (flipVertical)
+							f131_flipVertical(bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
+
+						if (flipHorizontal)
+							f130_flipBitmapHorizontal(bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 					}
 					boxByteGreen._y2 = (heightRedEagle >> 1) + 47;
 					boxByteGreen._y1 = 47 - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001);
 					boxByteGreen._x2 = MIN(223, projectilePosX + byteWidth);
 					if (boxByteGreen._x1 = MAX(0, projectilePosX - byteWidth + 1)) {
-						if (flipHorizontal) {
+						if (flipHorizontal)
 							AL_4_xPos = paddingPixelCount;
-						} else {
+						else
 							AL_4_xPos = 0;
-						}
-					} else {
+					} else
 						AL_4_xPos = MAX(paddingPixelCount, int16(byteWidth - projectilePosX - 1)); /* BUG0_06 Graphical glitch when drawing projectiles or explosions. If a projectile or explosion bitmap is cropped because it is only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is flipped horizontally (flipHorizontal = true) then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
 
-					}
-					f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
+					f132_blitToBitmap(bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
 				} else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */
 					useAlcoveObjectImage = false;
+					byte projectileCoordinates[2];
 					projectileCoordinates[0] = projectilePosX;
 					projectileCoordinates[1] = 47;
 					coordinateSet = projectileCoordinates;
@@ -3593,13 +3591,13 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					} else {
 						if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) {
 							objectAspect = (ObjectAspect*)&_projectileAspect[_vm->M1_ordinalToIndex(-_vm->_dungeonMan->f142_getProjectileAspect(Thing::_explLightningBolt))];
-							AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
+							bitmapRedBanana = f489_getNativeBitmapOrGraphic(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
 							explosionCoordinates = rebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
 							byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_byteWidth), explosionCoordinates[2]);
 							heightRedEagle = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
 							if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) {
-								f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, _palChangesNoChanges);
-								AL_6_bitmapRedBanana = _g74_tmpBitmap;
+								f129_blitToBitmapShrinkWithPalChange(bitmapRedBanana, _g74_tmpBitmap, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, _palChangesNoChanges);
+								bitmapRedBanana = _g74_tmpBitmap;
 							}
 							goto T0115200_DrawExplosion;
 						}
@@ -3625,12 +3623,12 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					}
 				}
 				f491_isDerivedBitmapInCache(k0_DerivedBitmapViewport);
-				AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice);
+				bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice);
 				if (smoke) {
-					f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, 48, 32, 48, 32, _palChangeSmoke);
-					AL_6_bitmapRedBanana = _g74_tmpBitmap;
+					f129_blitToBitmapShrinkWithPalChange(bitmapRedBanana, _g74_tmpBitmap, 48, 32, 48, 32, _palChangeSmoke);
+					bitmapRedBanana = _g74_tmpBitmap;
 				}
-				f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, 0, f492_getDerivedBitmap(k0_DerivedBitmapViewport), boxExplosionPatternD0C, _vm->getRandomNumber(4) + 87, _vm->getRandomNumber(64), k112_byteWidthViewport, Color(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
+				f133_blitBoxFilledWithMaskedBitmap(bitmapRedBanana, _g296_bitmapViewport, 0, f492_getDerivedBitmap(k0_DerivedBitmapViewport), boxExplosionPatternD0C, _vm->getRandomNumber(4) + 87, _vm->getRandomNumber(64), k112_byteWidthViewport, Color(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
 				f493_addDerivedBitmap(k0_DerivedBitmapViewport);
 				warning(false, "DISABLED CODE: f480_releaseBlock in f115_cthulhu");
 				//f480_releaseBlock(k0_DerivedBitmapViewport | 0x8000);
@@ -3652,7 +3650,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					}
 					explosionScale = MAX(4, (MAX(48, explosion->getAttack() + 1) * explosionBaseScales[AL_10_explosionScaleIndex]) >> 8) & (int)0xFFFE;
 				}
-				AL_6_bitmapRedBanana = f114_getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle);
+				bitmapRedBanana = f114_getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle);
 T0115200_DrawExplosion:
 				bool flipVertical = _vm->getRandomNumber(2);
 				paddingPixelCount = 0;
@@ -3668,27 +3666,30 @@ T0115200_DrawExplosion:
 					continue;
 				boxByteGreen._x2 = AL_4_xPos;
 				AL_4_xPos = explosionCoordinates[0];
-				if (boxByteGreen._x1 = f26_getBoundedValue(0, AL_4_xPos - byteWidth + 1, 223)) {
+				if (boxByteGreen._x1 = f26_getBoundedValue(0, AL_4_xPos - byteWidth + 1, 223))
 					AL_4_xPos = paddingPixelCount;
-				} else {
+				else {
 					AL_4_xPos = MAX(paddingPixelCount, int16(byteWidth - AL_4_xPos - 1)); /* BUG0_07 Graphical glitch when drawing explosions. If an explosion bitmap is cropped because it is only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is not flipped horizontally (flipHorizontal = false) then the variable paddingPixelCount is not set before being used here. Its previous value (defined while drawing something else) is used and may cause an incorrect bitmap to be drawn */
 
 																				   /* BUG0_06 Graphical glitch when drawing projectiles or explosions. If a projectile or explosion bitmap is cropped because it is only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is flipped horizontally (flipHorizontal = true) then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
 				}
+
 				if (boxByteGreen._x2 <= boxByteGreen._x1)
 					continue;
+
 				byteWidth = M77_getNormalizedByteWidth(byteWidth);
 				if (flipHorizontal || flipVertical) {
-					memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, sizeof(byte) * byteWidth * heightRedEagle);
-					AL_6_bitmapRedBanana = _g74_tmpBitmap;
-				}
-				if (flipHorizontal) {
-					f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
+					memcpy(_g74_tmpBitmap, bitmapRedBanana, sizeof(byte) * byteWidth * heightRedEagle);
+					bitmapRedBanana = _g74_tmpBitmap;
 				}
-				if (flipVertical) {
-					f131_flipVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle);
-				}
-				f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
+
+				if (flipHorizontal)
+					f130_flipBitmapHorizontal(bitmapRedBanana, byteWidth, heightRedEagle);
+
+				if (flipVertical)
+					f131_flipVertical(bitmapRedBanana, byteWidth, heightRedEagle);
+
+				f132_blitToBitmap(bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
 			}
 		}
 	} while ((thingParam = _vm->_dungeonMan->f159_getNextThing(thingParam)) != Thing::_endOfList);


Commit: 921431c7ea6418d12cd8a6e69a13a949f7f79c72
    https://github.com/scummvm/scummvm/commit/921431c7ea6418d12cd8a6e69a13a949f7f79c72
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some renaming in group.cpp, get rid of a global

Changed paths:
    engines/dm/group.cpp



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 17cd8d8..118eea7 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -72,28 +72,29 @@ GroupMan::~GroupMan() {
 void GroupMan::f196_initActiveGroups() {
 	if (_vm->_g298_newGame)
 		_g376_maxActiveGroupCount = 60;
+
 	if (_g375_activeGroups)
 		delete[] _g375_activeGroups;
+
 	_g375_activeGroups = new ActiveGroup[_g376_maxActiveGroupCount];
 	for (uint16 i = 0; i < _g376_maxActiveGroupCount; ++i)
 		_g375_activeGroups[i]._groupThingIndex = -1;
 }
 
 uint16 GroupMan::f145_getGroupCells(Group *group, int16 mapIndex) {
-	byte cells;
-	cells = group->_cells;
+	byte cells = group->_cells;
 	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex)
 		cells = _g375_activeGroups[cells]._cells;
 	return cells;
 }
 
-byte gGroupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_GroupDirections
-
 uint16 GroupMan::f147_getGroupDirections(Group *group, int16 mapIndex) {
+	static byte groupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_GroupDirections
+
 	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex)
 		return _g375_activeGroups[group->getActiveGroupIndex()]._directions;
 
-	return gGroupDirections[group->getDir()];
+	return groupDirections[group->getDir()];
 }
 
 int16 GroupMan::f176_getCreatureOrdinalInCell(Group *group, uint16 cell) {
@@ -102,6 +103,7 @@ int16 GroupMan::f176_getCreatureOrdinalInCell(Group *group, uint16 cell) {
 	if (groupCells == k255_CreatureTypeSingleCenteredCreature)
 		return _vm->M0_indexToOrdinal(0);
 
+	int retval = 0;
 	byte creatureIndex = group->getCount();
 	if (getFlag(g243_CreatureInfo[group->_type]._attributes, k0x0003_MaskCreatureInfo_size) == k1_MaskCreatureSizeHalf) {
 		if ((f147_getGroupDirections(group, currMapIndex) & 1) == (cell & 1))
@@ -109,16 +111,21 @@ int16 GroupMan::f176_getCreatureOrdinalInCell(Group *group, uint16 cell) {
 
 		do {
 			byte creatureCell = M50_getCreatureValue(groupCells, creatureIndex);
-			if (creatureCell == cell || creatureCell == returnNextVal(cell))
-				return _vm->M0_indexToOrdinal(creatureIndex);
+			if (creatureCell == cell || creatureCell == returnNextVal(cell)) {
+				retval = _vm->M0_indexToOrdinal(creatureIndex);
+				break;
+			}
 		} while (creatureIndex--);
 	} else {
 		do {
-			if (M50_getCreatureValue(groupCells, creatureIndex) == cell)
-				return _vm->M0_indexToOrdinal(creatureIndex);
+			if (M50_getCreatureValue(groupCells, creatureIndex) == cell) {
+				retval = _vm->M0_indexToOrdinal(creatureIndex);
+				break;
+			}
 		} while (creatureIndex--);
 	}
-	return 0;
+
+	return retval;
 }
 
 uint16 GroupMan::M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex) {
@@ -126,64 +133,82 @@ uint16 GroupMan::M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex) {
 }
 
 void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode) {
-	Group *L0367_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(groupThing);
-	uint16 L0368_ui_CreatureType = L0367_ps_Group->_type;
-	if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[L0368_ui_CreatureType]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
-		int16 L0369_i_CreatureIndex = L0367_ps_Group->getCount();
-		uint16 L0370_ui_GroupCells = f145_getGroupCells(L0367_ps_Group, _vm->_dungeonMan->_g272_currMapIndex);
+	Group *group = (Group *)_vm->_dungeonMan->f156_getThingData(groupThing);
+	uint16 creatureType = group->_type;
+	if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[creatureType]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
+		int16 creatureIndex = group->getCount();
+		uint16 groupCells = f145_getGroupCells(group, _vm->_dungeonMan->_g272_currMapIndex);
 		do {
-			f186_dropCreatureFixedPossessions(L0368_ui_CreatureType, mapX, mapY, (L0370_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : M50_getCreatureValue(L0370_ui_GroupCells, L0369_i_CreatureIndex), mode);
-		} while (L0369_i_CreatureIndex--);
+			f186_dropCreatureFixedPossessions(creatureType, mapX, mapY,
+				(groupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : M50_getCreatureValue(groupCells, creatureIndex), mode);
+		} while (creatureIndex--);
 	}
-	Thing L0365_T_CurrentThing = L0367_ps_Group->_slot;
-	if ((L0365_T_CurrentThing) != Thing::_endOfList) {
+
+	Thing currentThing = group->_slot;
+	if ((currentThing) != Thing::_endOfList) {
 		bool L0371_B_WeaponDropped = false;
-		Thing L0366_T_NextThing;
+		Thing nextThing;
 		do {
-			L0366_T_NextThing = _vm->_dungeonMan->f159_getNextThing(L0365_T_CurrentThing);
-			L0365_T_CurrentThing = M15_thingWithNewCell(L0365_T_CurrentThing, _vm->getRandomNumber(4));
-			if ((L0365_T_CurrentThing).getType() == k5_WeaponThingType) {
+			nextThing = _vm->_dungeonMan->f159_getNextThing(currentThing);
+			currentThing = M15_thingWithNewCell(currentThing, _vm->getRandomNumber(4));
+			if ((currentThing).getType() == k5_WeaponThingType) {
 				L0371_B_WeaponDropped = true;
 			}
-			_vm->_moveSens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
-		} while ((L0365_T_CurrentThing = L0366_T_NextThing) != Thing::_endOfList);
-		if (mode >= k0_soundModePlayImmediately) {
+			_vm->_moveSens->f267_getMoveResult(currentThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
+		} while ((currentThing = nextThing) != Thing::_endOfList);
+
+		if (mode >= k0_soundModePlayImmediately)
 			_vm->_sound->f064_SOUND_RequestPlay_CPSD(L0371_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
-		}
 	}
 }
 
 void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int16 mapY, uint16 cell, int16 mode) {
-	static uint16 g245FixedPossessionCreature_12Skeleton[3] = { // @ G0245_aui_Graphic559_FixedPossessionsCreature12Skeleton
+	static uint16 fixedPossessionCreature12Skeleton[3] = { // @ G0245_aui_Graphic559_FixedPossessionsCreature12Skeleton
 		k23_ObjectInfoIndexFirstWeapon + k9_WeaponTypeFalchion,
-		k69_ObjectInfoIndexFirstArmour + k30_ArmourTypeWoodenShield, 0};
-	static uint16 g246FixedPossessionCreature_9StoneGolem[2] = { // @ G0246_aui_Graphic559_FixedPossessionsCreature09StoneGolem
-		k23_ObjectInfoIndexFirstWeapon + k24_WeaponTypeStoneClub, 0};
-	static uint16 g247FixedPossessionCreature_16TrolinAntman[2] = { // @ G0247_aui_Graphic559_FixedPossessionsCreature16Trolin_Antman
-		k23_ObjectInfoIndexFirstWeapon + k23_WeaponTypeClub, 0};
-	static uint16 g248FixedPossessionCreature_18AnimatedArmourDethKnight[7] = { // @ G0248_aui_Graphic559_FixedPossessionsCreature18AnimatedArmour_DethKnight
+		k69_ObjectInfoIndexFirstArmour + k30_ArmourTypeWoodenShield,
+		0}
+	;
+	static uint16 fixedPossessionCreature9StoneGolem[2] = { // @ G0246_aui_Graphic559_FixedPossessionsCreature09StoneGolem
+		k23_ObjectInfoIndexFirstWeapon + k24_WeaponTypeStoneClub,
+		0
+	};
+	static uint16 fixedPossessionCreatur16TrolinAntman[2] = { // @ G0247_aui_Graphic559_FixedPossessionsCreature16Trolin_Antman
+		k23_ObjectInfoIndexFirstWeapon + k23_WeaponTypeClub,
+		0
+	};
+	static uint16 fixedPossessionCreature18AnimatedArmourDethKnight[7] = { // @ G0248_aui_Graphic559_FixedPossessionsCreature18AnimatedArmour_DethKnight
 		k69_ObjectInfoIndexFirstArmour + k41_ArmourTypeFootPlate,
 		k69_ObjectInfoIndexFirstArmour + k40_ArmourTypeLegPlate,
 		k69_ObjectInfoIndexFirstArmour + k39_ArmourTypeTorsoPlate,
 		k23_ObjectInfoIndexFirstWeapon + k10_WeaponTypeSword,
 		k69_ObjectInfoIndexFirstArmour + k38_ArmourTypeArmet,
-		k23_ObjectInfoIndexFirstWeapon + k10_WeaponTypeSword, 0};
-	static uint16 g249FixedPossessionCreature_7rockRockPile[5] = { // @ G0249_aui_Graphic559_FixedPossessionsCreature07Rock_RockPile
+		k23_ObjectInfoIndexFirstWeapon + k10_WeaponTypeSword,
+		0
+	};
+	static uint16 fixedPossessionCreature7rockRockPile[5] = { // @ G0249_aui_Graphic559_FixedPossessionsCreature07Rock_RockPile
 		k127_ObjectInfoIndexFirstJunk + k25_JunkTypeBoulder,
 		k127_ObjectInfoIndexFirstJunk + k25_JunkTypeBoulder | k0x8000_randomDrop,
 		k23_ObjectInfoIndexFirstWeapon + k30_WeaponTypeRock | k0x8000_randomDrop,
-		k23_ObjectInfoIndexFirstWeapon + k30_WeaponTypeRock | k0x8000_randomDrop, 0};
-	static uint16 g250FixedPossessionCreature_4PainRatHellHound[3] = { // @ G0250_aui_Graphic559_FixedPossessionsCreature04PainRat_Hellhound
+		k23_ObjectInfoIndexFirstWeapon + k30_WeaponTypeRock | k0x8000_randomDrop,
+		0
+	};
+	static uint16 fixedPossessionCreature4PainRatHellHound[3] = { // @ G0250_aui_Graphic559_FixedPossessionsCreature04PainRat_Hellhound
 		k127_ObjectInfoIndexFirstJunk + k35_JunkTypeDrumstickShank,
-		k127_ObjectInfoIndexFirstJunk + k35_JunkTypeDrumstickShank | k0x8000_randomDrop, 0};
-	static uint16 g251FixedPossessionCreature_6screamer[3] = { // @ G0251_aui_Graphic559_FixedPossessionsCreature06Screamer
+		k127_ObjectInfoIndexFirstJunk + k35_JunkTypeDrumstickShank | k0x8000_randomDrop,
+		0
+	};
+	static uint16 fixedPossessionCreature6screamer[3] = { // @ G0251_aui_Graphic559_FixedPossessionsCreature06Screamer
 		k127_ObjectInfoIndexFirstJunk + k33_JunkTypeScreamerSlice,
-		k127_ObjectInfoIndexFirstJunk + k33_JunkTypeScreamerSlice | k0x8000_randomDrop, 0};
-	static uint16 g252FixedPossessionCreature_15MagnetaWormWorm[4] = { // @ G0252_aui_Graphic559_FixedPossessionsCreature15MagentaWorm_Worm
+		k127_ObjectInfoIndexFirstJunk + k33_JunkTypeScreamerSlice | k0x8000_randomDrop,
+		0
+	};
+	static uint16 fixedPossessionCreature15MagnetaWormWorm[4] = { // @ G0252_aui_Graphic559_FixedPossessionsCreature15MagentaWorm_Worm
 		k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound,
 		k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound | k0x8000_randomDrop,
-		k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound | k0x8000_randomDrop, 0};
-	static uint16 g253FixedPossessionCreature_24RedDragon[11] = { // @ G0253_aui_Graphic559_FixedPossessionsCreature24RedDragon
+		k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound | k0x8000_randomDrop,
+		0
+	};
+	static uint16 fixedPossessionCreature24RedDragon[11] = { // @ G0253_aui_Graphic559_FixedPossessionsCreature24RedDragon
 		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
 		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
 		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak,
@@ -195,71 +220,72 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX
 		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop,
 		k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop, 0};
 
-	uint16 *L0359_pui_FixedPossessions;
-
-	bool L0361_B_Cursed = false;
+	uint16 *fixedPossessions;
+	bool cursedPossessions = false;
 	switch (creatureType) {
-	default:
-		return;
-	case k12_CreatureTypeSkeleton:
-		L0359_pui_FixedPossessions = g245FixedPossessionCreature_12Skeleton;
-		break;
-	case k9_CreatureTypeStoneGolem:
-		L0359_pui_FixedPossessions = g246FixedPossessionCreature_9StoneGolem;
-		break;
-	case k16_CreatureTypeTrolinAntman:
-		L0359_pui_FixedPossessions = g247FixedPossessionCreature_16TrolinAntman;
+	case k4_CreatureTypePainRatHellHound:
+		fixedPossessions = fixedPossessionCreature4PainRatHellHound;
 		break;
-	case k18_CreatureTypeAnimatedArmourDethKnight:
-		L0361_B_Cursed = true;
-		L0359_pui_FixedPossessions = g248FixedPossessionCreature_18AnimatedArmourDethKnight;
+	case k6_CreatureTypeScreamer:
+		fixedPossessions = fixedPossessionCreature6screamer;
 		break;
 	case k7_CreatureTypeRockpile:
-		L0359_pui_FixedPossessions = g249FixedPossessionCreature_7rockRockPile;
+		fixedPossessions = fixedPossessionCreature7rockRockPile;
 		break;
-	case k4_CreatureTypePainRatHellHound:
-		L0359_pui_FixedPossessions = g250FixedPossessionCreature_4PainRatHellHound;
+	case k9_CreatureTypeStoneGolem:
+		fixedPossessions = fixedPossessionCreature9StoneGolem;
 		break;
-	case k6_CreatureTypeScreamer:
-		L0359_pui_FixedPossessions = g251FixedPossessionCreature_6screamer;
+	case k12_CreatureTypeSkeleton:
+		fixedPossessions = fixedPossessionCreature12Skeleton;
+		break;
+	case k16_CreatureTypeTrolinAntman:
+		fixedPossessions = fixedPossessionCreatur16TrolinAntman;
 		break;
 	case k15_CreatureTypeMagnetaWormWorm:
-		L0359_pui_FixedPossessions = g252FixedPossessionCreature_15MagnetaWormWorm;
+		fixedPossessions = fixedPossessionCreature15MagnetaWormWorm;
+		break;
+	case k18_CreatureTypeAnimatedArmourDethKnight:
+		cursedPossessions = true;
+		fixedPossessions = fixedPossessionCreature18AnimatedArmourDethKnight;
 		break;
 	case k24_CreatureTypeRedDragon:
-		L0359_pui_FixedPossessions = g253FixedPossessionCreature_24RedDragon;
+		fixedPossessions = fixedPossessionCreature24RedDragon;
+		break;
+	default:
+		return;
 	}
-	uint16 L0356_ui_FixedPossession;
-	bool L0362_B_WeaponDropped = false;
-	while (L0356_ui_FixedPossession = *L0359_pui_FixedPossessions++) {
-		if (getFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) && _vm->getRandomNumber(2))
+
+	uint16 currFixedPossession;
+	bool weaponDropped = false;
+	while (currFixedPossession = *fixedPossessions++) {
+		if (getFlag(currFixedPossession, k0x8000_randomDrop) && _vm->getRandomNumber(2))
 			continue;
-		int16 L0357_i_ThingType;
-		if (clearFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) >= k127_ObjectInfoIndexFirstJunk) {
-			L0357_i_ThingType = k10_JunkThingType;
-			L0356_ui_FixedPossession -= k127_ObjectInfoIndexFirstJunk;
+
+		int16 currThingType;
+		if (clearFlag(currFixedPossession, k0x8000_randomDrop) >= k127_ObjectInfoIndexFirstJunk) {
+			currThingType = k10_JunkThingType;
+			currFixedPossession -= k127_ObjectInfoIndexFirstJunk;
+		} else if (currFixedPossession >= k69_ObjectInfoIndexFirstArmour) {
+			currThingType = k6_ArmourThingType;
+			currFixedPossession -= k69_ObjectInfoIndexFirstArmour;
 		} else {
-			if (L0356_ui_FixedPossession >= k69_ObjectInfoIndexFirstArmour) {
-				L0357_i_ThingType = k6_ArmourThingType;
-				L0356_ui_FixedPossession -= k69_ObjectInfoIndexFirstArmour;
-			} else {
-				L0362_B_WeaponDropped = true;
-				L0357_i_ThingType = k5_WeaponThingType;
-				L0356_ui_FixedPossession -= k23_ObjectInfoIndexFirstWeapon;
-			}
+			weaponDropped = true;
+			currThingType = k5_WeaponThingType;
+			currFixedPossession -= k23_ObjectInfoIndexFirstWeapon;
 		}
-		Thing L0358_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(L0357_i_ThingType);
-		if ((L0358_T_Thing) == Thing::_none)
+
+		Thing nextUnusedThing = _vm->_dungeonMan->f166_getUnusedThing(currThingType);
+		if ((nextUnusedThing) == Thing::_none)
 			continue;
 
-		Weapon *L0360_ps_Weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(L0358_T_Thing);
+		Weapon *currWeapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(nextUnusedThing);
 /* The same pointer type is used no matter the actual type k5_WeaponThingType, k6_ArmourThingType or k10_JunkThingType */
-		L0360_ps_Weapon->setType(L0356_ui_FixedPossession);
-		L0360_ps_Weapon->setCursed(L0361_B_Cursed);
-		L0358_T_Thing = M15_thingWithNewCell(L0358_T_Thing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell);
-		_vm->_moveSens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY);
+		currWeapon->setType(currFixedPossession);
+		currWeapon->setCursed(cursedPossessions);
+		nextUnusedThing = M15_thingWithNewCell(nextUnusedThing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell);
+		_vm->_moveSens->f267_getMoveResult(nextUnusedThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
 	}
-	_vm->_sound->f064_SOUND_RequestPlay_CPSD(L0362_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
+	_vm->_sound->f064_SOUND_RequestPlay_CPSD(weaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
 }
 
 int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {


Commit: 44a5e36fc1dd2caaa45dd142f9d5355c5dc7a22f
    https://github.com/scummvm/scummvm/commit/44a5e36fc1dd2caaa45dd142f9d5355c5dc7a22f
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Pull K0016_aui_Palette_FadeTemporary into a class vaiable

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index af4583e..94820d9 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -136,6 +136,8 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 		_g345_aui_BlankBuffer[i] = 0;
 
 	_gK17_paletteFadeFrom = nullptr;
+	for (uint16 i = 0; i < 16; ++i)
+		_gK16_paletteFadeTemporary[i] = 0;
 
 	initConstants();
 }
@@ -3751,14 +3753,13 @@ uint16 DisplayMan::f431_getDarkenedColor(uint16 RGBcolor) {
 }
 
 void DisplayMan::f436_STARTEND_FadeToPalette(uint16* P0849_pui_Palette) {
-	static uint16 K0016_aui_Palette_FadeTemporary[16];
-	uint16 *paletteRegister = K0016_aui_Palette_FadeTemporary;
+	uint16 *paletteRegister = _gK16_paletteFadeTemporary;
 
 	for (int16 i = 0; i < 16; i++) 
 		paletteRegister[i] = _gK17_paletteFadeFrom[i];
 
 	for (int16 i = 0; i < 8; i++) {
-		paletteRegister = K0016_aui_Palette_FadeTemporary;
+		paletteRegister = _gK16_paletteFadeTemporary;
 		for (int16 colIdx = 0; colIdx < 16; colIdx++, paletteRegister++) {
 			uint16 currentRGBColor = getFlag(*paletteRegister, D12_MASK_BLUE_COMPONENT);
 			int16 targetRGBColor = getFlag(P0849_pui_Palette[colIdx], D12_MASK_BLUE_COMPONENT);
@@ -3802,7 +3803,7 @@ void DisplayMan::f436_STARTEND_FadeToPalette(uint16* P0849_pui_Palette) {
 		}
 		_vm->f22_delay(1);
 		_vm->_eventMan->f357_discardAllInput();
-		f508_buildPaletteChangeCopperList(K0016_aui_Palette_FadeTemporary, K0016_aui_Palette_FadeTemporary);
+		f508_buildPaletteChangeCopperList(_gK16_paletteFadeTemporary, _gK16_paletteFadeTemporary);
 	}
 }
 
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 8d01365..d089d74 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -670,6 +670,7 @@ private:
 	int16 _g695_doorNativeBitmapIndex_Front_D1LCR[2]; // @ G0695_ai_DoorNativeBitmapIndex_Front_D1LCR
 
 	uint16 *_gK17_paletteFadeFrom; // @ K0017_pui_Palette_FadeFrom
+	uint16 _gK16_paletteFadeTemporary[16]; // @ K0016_aui_Palette_FadeTemporary
 public:
 
 	uint16 _screenWidth;


Commit: 4442b0b302f107013e88120c69d8cf41aaec0ecc
    https://github.com/scummvm/scummvm/commit/4442b0b302f107013e88120c69d8cf41aaec0ecc
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Finish f113_drawField

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/gfx.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 44cc616..1699a8b 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -16,6 +16,5 @@ Todo:
 Code stuff todo:
 	Complete stub methods(blitShrink, blitmask, scroller, etc.)
 	Save file f433_processCommand140_saveGame fails silently, add error checking
-	Clean up f113_drawField
 	
 	
\ No newline at end of file
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 94820d9..0fe319e 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2771,17 +2771,24 @@ uint32 DisplayMan::getCompressedDataSize(uint16 index) {
 }
 
 void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) {
-	warning(false, "STUB METHOD: f113_drawField");
+	byte* bitmapMask = nullptr;
 
 	if (fieldAspect->_mask != kMaskFieldAspectNoMask) {
-		DisplayMan &dispMan = *_vm->_displayMan;
-
-		byte *bitmapMask = dispMan._g74_tmpBitmap;
-		memmove(bitmapMask, dispMan.f489_getNativeBitmapOrGraphic(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)),
-				fieldAspect->_height * fieldAspect->_byteWidth * 2 * sizeof(bitmapMask[0]));
-		if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask))
-			dispMan.f130_flipBitmapHorizontal(bitmapMask, fieldAspect->_byteWidth, fieldAspect->_height);
+		bitmapMask = _g74_tmpBitmap;
+		memmove(bitmapMask, f489_getNativeBitmapOrGraphic(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)),
+				fieldAspect->_height * fieldAspect->_byteWidth * 2);
+		if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask)) {
+			f130_flipBitmapHorizontal(bitmapMask, fieldAspect->_byteWidth, fieldAspect->_height);
+		}
 	}
+
+	f491_isDerivedBitmapInCache(k0_DerivedBitmapViewport);
+	byte *bitmap = f489_getNativeBitmapOrGraphic(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex);
+	f133_blitBoxFilledWithMaskedBitmap(bitmap, _g296_bitmapViewport, bitmapMask, f492_getDerivedBitmap(k0_DerivedBitmapViewport), box,
+									   _vm->getRandomNumber(2) + fieldAspect->_baseStartUnitIndex, _vm->getRandomNumber(32), k112_byteWidthViewport,
+									   (Color)fieldAspect->_transparentColor, fieldAspect->_xPos, 0, 136, fieldAspect->_bitplaneWordCount);
+	f493_addDerivedBitmap(k0_DerivedBitmapViewport);
+	f480_releaseBlock(k0_DerivedBitmapViewport | 0x8000);
 }
 
 int16 DisplayMan::f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale) {


Commit: bcb067698efe6e18be02a23eb48499ed8e0e714f
    https://github.com/scummvm/scummvm/commit/bcb067698efe6e18be02a23eb48499ed8e0e714f
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add support for loading from launcher

Changed paths:
    engines/dm/detection.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/loadsave.cpp



diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp
index 200a81f..7f506ac 100644
--- a/engines/dm/detection.cpp
+++ b/engines/dm/detection.cpp
@@ -32,6 +32,8 @@
 #include "common/fs.h"
 
 #include "engines/advancedDetector.h"
+#include <common/system.h>
+
 namespace DM {
 static const PlainGameDescriptor DMGames[] = {
 	{"dm", "Dungeon Master"},
@@ -46,7 +48,7 @@ static const ADGameDescription gameDescriptions[] = {
 			{"Dungeon.dat", 0, "43a213da8eda413541dd12f90ce202f6", 25006},
 		AD_LISTEND
 		},
-	    Common::EN_ANY, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE)
+		Common::EN_ANY, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE)
 	},
 	{
 		"dm", "Atari ???v English",
@@ -94,13 +96,72 @@ public:
 	virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { return gameDescriptions; }
 
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
-		if(desc)
+		if (desc)
 			*engine = new DM::DMEngine(syst, desc);
 		return desc != nullptr;
 	}
+
+	virtual bool hasFeature(MetaEngineFeature f) const {
+		return
+			(f == kSupportsListSaves) ||
+			(f == kSupportsLoadingDuringStartup) ||
+			(f == kSavesSupportThumbnail) ||
+			(f == kSavesSupportMetaInfo) ||
+			(f == kSavesSupportCreationDate);
+	}
+
 	virtual int getMaximumSaveSlot() const { return 99; }
-	virtual SaveStateList listSaves(const char *target) const { return SaveStateList(); }
-	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { return SaveStateDescriptor(); }
+
+	virtual SaveStateList listSaves(const char *target) const {
+		Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+		SaveGameHeader header;
+		Common::String pattern = target;
+		pattern += ".###";
+
+		Common::StringArray filenames;
+		filenames = saveFileMan->listSavefiles(pattern.c_str());
+
+		SaveStateList saveList;
+
+		for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+			// Obtain the last 3 digits of the filename, since they correspond to the save slot
+			int slotNum = atoi(file->c_str() + file->size() - 3);
+
+			if ((slotNum >= 0) && (slotNum <= 999)) {
+				Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+				if (in) {
+					if (DM::readSaveGameHeader(in, &header))
+						saveList.push_back(SaveStateDescriptor(slotNum, header._descr.getDescription()));
+					delete in;
+				}
+			}
+		}
+
+		// Sort saves based on slot number.
+		Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
+		return saveList;
+	}
+
+	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const {
+		Common::String filename = Common::String::format("%s.%03u", target, slot);
+		Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());
+
+		if (in) {
+			DM::SaveGameHeader header;
+
+			bool successfulRead = DM::readSaveGameHeader(in, &header);
+			delete in;
+
+			if (successfulRead) {
+				SaveStateDescriptor desc(slot, header._descr.getDescription());
+
+				return header._descr;
+			}
+		}
+
+		return SaveStateDescriptor();
+	}
+
 	virtual void removeSaveState(const char *target, int slot) const {}
 };
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index e22a41d..655fb09 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -25,6 +25,7 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
+#include "common/config-manager.h"
 #include "common/scummsys.h"
 #include "common/system.h"
 
@@ -262,11 +263,17 @@ void DMEngine::f463_initializeGame() {
 	_textMan->f54_textInitialize();
 	_objectMan->loadObjectNames();
 	_eventMan->initMouse();
+
+	int16 saveSlot = 1;
 	do {
-		f441_processEntrance();
-		if (_engineShouldQuit)
-			return;
-	} while (f435_loadgame(1) != k1_LoadgameSuccess);
+		if (ConfMan.hasKey("save_slot")) {
+			saveSlot = ConfMan.getInt("save_slot");
+		} else {
+			f441_processEntrance();
+			if (_engineShouldQuit)
+				return;
+		}
+	} while (f435_loadgame(saveSlot) != k1_LoadgameSuccess);
 
 	_displayMan->f466_loadIntoBitmap(k11_MenuSpellAreLinesIndice, _menuMan->_gK73_bitmapSpellAreaLines); // @ F0396_MENUS_LoadSpellAreaLinesBitmap
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 9b39f6e..1187db8 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -212,7 +212,6 @@ class DMEngine : public Engine {
 	void initArrays();
 	Common::String getSavefileName(uint16 slot);
 	void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
-	bool readSaveGameHeader(Common::InSaveFile *file, SaveGameHeader *header);
 	void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance
 public:
 	explicit DMEngine(OSystem *syst, const ADGameDescription *gameDesc);
@@ -295,6 +294,8 @@ public:
 	int16 _g318_waitForInputMaxVerticalBlankCount; // @ G0318_i_WaitForInputMaximumVerticalBlankCount
 };
 
+bool readSaveGameHeader(Common::InSaveFile* in, SaveGameHeader* header);
+
 } // End of namespace DM
 
 #endif
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 9eb0e6c..3b4cd80 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -375,7 +375,7 @@ void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::Strin
 }
 
 
-bool DMEngine::readSaveGameHeader(Common::InSaveFile* in, SaveGameHeader* header) {
+bool readSaveGameHeader(Common::InSaveFile* in, SaveGameHeader* header) {
 	uint32 id = in->readUint32BE();
 
 	// Check if it's a valid ScummVM savegame


Commit: fb14fea01419f43ac56c11d443f98216fc3bd2ae
    https://github.com/scummvm/scummvm/commit/fb14fea01419f43ac56c11d443f98216fc3bd2ae
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Make thumbnail capture the dungeon

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 655fb09..08bfb58 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -59,6 +59,7 @@
 #include <graphics/cursorman.h>
 #include <advancedDetector.h>
 #include "sounds.h"
+#include <graphics/surface.h>
 
 namespace DM {
 void warning(bool repeat, const char* s, ...) {
@@ -202,6 +203,8 @@ DMEngine::DMEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst),
 		_g562_entranceDoorAnimSteps[i] = nullptr;
 	_g564_interfaceCredits = nullptr;
 	debug("DMEngine::DMEngine");
+
+	_saveThumbnail = nullptr;
 }
 
 DMEngine::~DMEngine() {
@@ -225,7 +228,7 @@ DMEngine::~DMEngine() {
 	delete _dialog;
 	delete _sound;
 
-
+	delete _saveThumbnail;
 
 	delete[] _savedScreenForOpenEntranceDoors;
 	// clear debug channels
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 1187db8..d72bc63 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -35,6 +35,7 @@
 #include "engines/savestate.h"
 
 #include "console.h"
+#include <common/memstream.h>
 
 
 struct ADGameDescription;
@@ -265,6 +266,7 @@ public:
 	DialogMan *_dialog;
 	SoundMan *_sound;
 
+	Common::MemoryWriteStreamDynamic *_saveThumbnail;
 
 	bool _engineShouldQuit;
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 638fba2..d19f47c 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -25,6 +25,9 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
+#include <graphics/surface.h>
+#include "graphics/thumbnail.h"
+
 #include "inventory.h"
 #include "dungeonman.h"
 #include "eventman.h"
@@ -53,7 +56,7 @@ void InventoryMan::initConstants() {
 			"ARTISAN", "ADEPT", "EXPERT", "` MASTER", "a MASTER","b MASTER", "c MASTER", "d MASTER", "e MASTER", "ARCHMASTER"};
 		static const char* G0428_apc_SkillLevelNames_DE_DEU[15] = {"ANFAENGER", "NEULING", "LEHRLING", "ARBEITER", "GESELLE", "HANDWERKR", "FACHMANN",
 			"EXPERTE", "` MEISTER", "a MEISTER", "b MEISTER", "c MEISTER", "d MEISTER", "e MEISTER", "ERZMEISTR"};
-		static const char* G0428_apc_SkillLevelNames_FR_FRA[15] = { "NEOPHYTE", "NOVICE", "APPRENTI", "COMPAGNON", "ARTISAN", "PATRON",
+		static const char* G0428_apc_SkillLevelNames_FR_FRA[15] = {"NEOPHYTE", "NOVICE", "APPRENTI", "COMPAGNON", "ARTISAN", "PATRON",
 			"ADEPTE", "EXPERT", "MAITRE '", "MAITRE a", "MAITRE b", "MAITRE c", "MAITRE d", "MAITRE e", "SUR-MAITRE"};
 		const char **g428_byLanguage;
 		switch (_vm->getGameLanguage()) { // localized
@@ -80,6 +83,14 @@ InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
 }
 
 void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
+	if (championIndex == kM1_ChampionNone) {
+		delete _vm->_saveThumbnail;
+		_vm->_saveThumbnail = nullptr;
+	} else if (!_vm->_saveThumbnail) {
+		_vm->_saveThumbnail = new Common::MemoryWriteStreamDynamic();
+		Graphics::saveThumbnail(*_vm->_saveThumbnail);
+	}
+
 	uint16 L1102_ui_Multiple;
 #define AL1102_ui_InventoryChampionOrdinal L1102_ui_Multiple
 #define AL1102_ui_SlotIndex                L1102_ui_Multiple
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 3b4cd80..3bef55f 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -359,7 +359,10 @@ void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::Strin
 	out->writeByte(0);
 
 	// Save the game thumbnail
-	Graphics::saveThumbnail(*out);
+	if (_saveThumbnail) {
+		out->write(_saveThumbnail->getData(), _saveThumbnail->size());
+	} else
+		Graphics::saveThumbnail(*out);
 
 	// Creation date/time
 	TimeDate curTime;


Commit: c01293162cfd47e553fc8aad864abec56a3b463e
    https://github.com/scummvm/scummvm/commit/c01293162cfd47e553fc8aad864abec56a3b463e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Make resume button load up ScummVM's global load dialog

Changed paths:
    engines/dm/dm.cpp
    engines/dm/loadsave.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 08bfb58..dc0655b 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -60,6 +60,8 @@
 #include <advancedDetector.h>
 #include "sounds.h"
 #include <graphics/surface.h>
+#include <common/translation.h>
+#include <gui/saveload.h>
 
 namespace DM {
 void warning(bool repeat, const char* s, ...) {
@@ -178,7 +180,7 @@ DMEngine::DMEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst),
 	_g527_platform = 0;
 	_g526_dungeonId = 0;
 
-	_g298_newGame = false;
+	_g298_newGame = 0;
 	_g523_restartGameRequest = false;
 	_g321_stopWaitingForPlayerInput = true;
 	_g301_gameTimeTicking = false;
@@ -269,13 +271,19 @@ void DMEngine::f463_initializeGame() {
 
 	int16 saveSlot = 1;
 	do {
+		// if loading from the launcher
 		if (ConfMan.hasKey("save_slot")) {
 			saveSlot = ConfMan.getInt("save_slot");
-		} else {
+		} else { // else show the entrance
 			f441_processEntrance();
 			if (_engineShouldQuit)
 				return;
 		}
+		if (_g298_newGame == k0_modeLoadSavedGame) { // if resume was clicked, bring up ScummVM load screen
+			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
+			saveSlot = dialog->runModalWithCurrentTarget();
+			delete dialog;
+		}
 	} while (f435_loadgame(saveSlot) != k1_LoadgameSuccess);
 
 	_displayMan->f466_loadIntoBitmap(k11_MenuSpellAreLinesIndice, _menuMan->_gK73_bitmapSpellAreaLines); // @ F0396_MENUS_LoadSpellAreaLinesBitmap
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 3bef55f..c5082d2 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -45,6 +45,9 @@ namespace DM {
 #define C10_DUNGEON_DM 10
 
 LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
+	if (slot == -1)
+		return kM1_LoadgameFailure;
+
 	bool L1366_B_FadePalette = true;
 	Common::String fileName;
 	Common::SaveFileManager *saveFileManager = nullptr;


Commit: cefc231968412af089b6957173f9162b9852e94e
    https://github.com/scummvm/scummvm/commit/cefc231968412af089b6957173f9162b9852e94e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Make ScummVM's save dialog open up when saving

Changed paths:
    engines/dm/dm.h
    engines/dm/eventman.cpp
    engines/dm/loadsave.cpp



diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index d72bc63..2e3144b 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -213,6 +213,7 @@ class DMEngine : public Engine {
 	void initArrays();
 	Common::String getSavefileName(uint16 slot);
 	void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
+	void writeCompleteSaveFile(int16 slot, Common::String &desc, int16 saveAndPlayChoice);
 	void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance
 public:
 	explicit DMEngine(OSystem *syst, const ADGameDescription *gameDesc);
@@ -227,7 +228,7 @@ public:
 	int16 M0_indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
 	void f19_displayErrorAndStop(int16 errorIndex); // @ F0019_MAIN_DisplayErrorAndStop
 	virtual Common::Error run(); // @ main
-	void f433_processCommand140_saveGame(uint16 slot, const Common::String desc); // @ F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF
+	void f433_processCommand140_saveGame(); // @ F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF
 	LoadgameResponse f435_loadgame(int16 slot); // @ F0435_STARTEND_LoadGame_CPSF
 	void f441_processEntrance(); // @ F0441_STARTEND_ProcessEntrance
 	void f444_endGame(bool doNotDrawCreditsOnly); // @ F0444_STARTEND_Endgame
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 0f7c120..9f0b387 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -781,7 +781,7 @@ void EventManager::f380_processCommandQueue() {
 
 	if (cmdType == k140_CommandSaveGame) {
 		if ((_vm->_championMan->_g305_partyChampionCount > 0) && !_vm->_championMan->_g299_candidateChampionOrdinal)
-			_vm->f433_processCommand140_saveGame(1, "Nice save:)");
+			_vm->f433_processCommand140_saveGame();
 
 		return;
 	}
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index c5082d2..4d24daf 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -37,6 +37,8 @@
 #include "eventman.h"
 #include "projexpl.h"
 #include "dialog.h"
+#include <gui/saveload.h>
+#include <common/translation.h>
 
 
 namespace DM {
@@ -179,54 +181,124 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 }
 
 
-void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String desc) {
-	char *message = nullptr;
-
+void DMEngine::f433_processCommand140_saveGame() {
 	_menuMan->f456_drawDisabledMenu();
 	_eventMan->f78_showMouse();
 
 	switch (getGameLanguage()) { // localized
 	default:
 	case Common::EN_ANY:
-		_dialog->f427_dialogDraw(message, nullptr, "SAVE AND PLAY", "SAVE AND QUIT", "CANCEL", nullptr, false, false, false);
+		_dialog->f427_dialogDraw(nullptr, nullptr, "SAVE AND PLAY", "SAVE AND QUIT", "CANCEL", nullptr, false, false, false);
 		break;
 	case Common::DE_DEU:
-		_dialog->f427_dialogDraw(message, nullptr, "SICHERN/SPIEL", "SICHERN/ENDEN", "WIDERRUFEN", nullptr, false, false, false);
+		_dialog->f427_dialogDraw(nullptr, nullptr, "SICHERN/SPIEL", "SICHERN/ENDEN", "WIDERRUFEN", nullptr, false, false, false);
 		break;
 	case Common::FR_FRA:
-		_dialog->f427_dialogDraw(message, nullptr, "GARDER/JOUER", "GARDER/SORTIR", "ANNULLER", nullptr, false, false, false);
+		_dialog->f427_dialogDraw(nullptr, nullptr, "GARDER/JOUER", "GARDER/SORTIR", "ANNULLER", nullptr, false, false, false);
 		break;
 	}
-	int16 saveAndPlayChoice = _dialog->f424_dialogGetChoice(3, k0_DIALOG_SET_VIEWPORT, 0, k0_DIALOG_CHOICE_NONE);
 
-	switch (getGameLanguage()) { // localized
-	default:
-	case Common::EN_ANY:
-		_dialog->f427_dialogDraw(nullptr, "SAVING GAME . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
-		break;
-	case Common::DE_DEU:
-		_dialog->f427_dialogDraw(nullptr, "SPIEL WIRD GESICHERT . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
-		break;
-	case Common::FR_FRA:
-		_dialog->f427_dialogDraw(nullptr, "UN MOMENT A SAUVEGARDER DU JEU...", nullptr, nullptr, nullptr, nullptr, false, false, false);
-		break;
+	enum SaveAndPlayChoice {
+		kSaveAndPlay = 1,
+		kSaveAndQuit = 2,
+		kCancel = 3
+	};
+
+	SaveAndPlayChoice saveAndPlayChoice = (SaveAndPlayChoice)_dialog->f424_dialogGetChoice(3, k0_DIALOG_SET_VIEWPORT, 0, k0_DIALOG_CHOICE_NONE);
+
+	if (saveAndPlayChoice == kSaveAndQuit || saveAndPlayChoice == kSaveAndPlay) {
+		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
+		int16 saveSlot = dialog->runModalWithCurrentTarget();
+		Common::String saveDescription = dialog->getResultString();
+		if (saveDescription.empty())
+			saveDescription = "Nice save ^^";
+		delete dialog;
+
+		if (saveSlot >= 0) {
+			switch (getGameLanguage()) { // localized
+			default:
+			case Common::EN_ANY:
+				_dialog->f427_dialogDraw(nullptr, "SAVING GAME . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
+				break;
+			case Common::DE_DEU:
+				_dialog->f427_dialogDraw(nullptr, "SPIEL WIRD GESICHERT . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
+				break;
+			case Common::FR_FRA:
+				_dialog->f427_dialogDraw(nullptr, "UN MOMENT A SAUVEGARDER DU JEU...", nullptr, nullptr, nullptr, nullptr, false, false, false);
+				break;
+			}
+
+			uint16 champHandObjWeight = 0;
+			if (!_championMan->_g415_leaderEmptyHanded) {
+				champHandObjWeight = _dungeonMan->f140_getObjectWeight(_championMan->_g414_leaderHandObject);
+				_championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load -= champHandObjWeight;
+			}
+
+			writeCompleteSaveFile(saveSlot, saveDescription, saveAndPlayChoice);
+
+			if (!_championMan->_g415_leaderEmptyHanded) {
+				_championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load += champHandObjWeight;
+			}
+		} else
+			saveAndPlayChoice = kCancel;
 	}
 
-	uint16 champHandObjWeight = 0;
-	if (!_championMan->_g415_leaderEmptyHanded) {
-		champHandObjWeight = _dungeonMan->f140_getObjectWeight(_championMan->_g414_leaderHandObject);
-		_championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load -= champHandObjWeight;
+
+	if (saveAndPlayChoice == kSaveAndQuit) {
+		_eventMan->f77_hideMouse();
+		f444_endGame(false);
 	}
 
+	_g524_restartGameAllowed = true;
+	_menuMan->f457_drawEnabledMenus();
+	_eventMan->f77_hideMouse();
+}
+
+Common::String DMEngine::getSavefileName(uint16 slot) {
+	return Common::String::format("%s.%03u", _targetName.c_str(), slot);
+}
+
+#define SAVEGAME_ID       MKTAG('D', 'M', 'D', 'M')
+#define SAVEGAME_VERSION  1
 
-	Common::String savefileName = getSavefileName(slot);
+void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::String& saveName) {
+	out->writeUint32BE(SAVEGAME_ID);
+
+	// Write version
+	out->writeByte(SAVEGAME_VERSION);
+
+	// Write savegame name
+	out->writeString(saveName);
+	out->writeByte(0);
+
+	// Save the game thumbnail
+	if (_saveThumbnail) {
+		out->write(_saveThumbnail->getData(), _saveThumbnail->size());
+	} else
+		Graphics::saveThumbnail(*out);
+
+	// Creation date/time
+	TimeDate curTime;
+	_system->getTimeAndDate(curTime);
+
+	uint32 saveDate = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
+	uint16 saveTime = ((curTime.tm_hour & 0xFF) << 8) | ((curTime.tm_min) & 0xFF);
+	uint32 playTime = getTotalPlayTime() / 1000;
+
+	out->writeUint32BE(saveDate);
+	out->writeUint16BE(saveTime);
+	out->writeUint32BE(playTime);
+}
+
+void DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescription, int16 saveAndPlayChoice) {
+	Common::String savefileName = getSavefileName(saveSlot);
 	Common::SaveFileManager *saveFileManager = _system->getSavefileManager();
 	Common::OutSaveFile *file = saveFileManager->openForSaving(savefileName);
 
 	if (!file)
 		return; // TODO: silent fail
 
-	writeSaveGameHeader(file, desc);
+	writeSaveGameHeader(file, saveDescription);
 
 	file->writeSint16BE(_g528_saveFormat);
 	file->writeSint16BE(saveAndPlayChoice);
@@ -282,7 +354,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 			file->writeUint16BE(header._thingCounts[i]);
 	}
 
-	 // save _g277_dungeonMaps
+	// save _g277_dungeonMaps
 	for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._mapCount; ++i) {
 		Map &map = _dungeonMan->_g277_dungeonMaps[i];
 		uint16 tmp;
@@ -307,7 +379,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 		file->writeUint16BE(tmp);
 	}
 
-// save _g280_dungeonColumnsCumulativeSquareThingCount
+	// save _g280_dungeonColumnsCumulativeSquareThingCount
 	for (uint16 i = 0; i < _dungeonMan->_g282_dungeonColumCount; ++i)
 		file->writeUint16BE(_dungeonMan->_g280_dungeonColumnsCumulativeSquareThingCount[i]);
 
@@ -331,56 +403,8 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String
 	file->flush();
 	file->finalize();
 	delete file;
-
-	if (!saveAndPlayChoice) {
-		_eventMan->f77_hideMouse();
-		f444_endGame(false);
-	}
-	if (!_championMan->_g415_leaderEmptyHanded) {
-		_championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load += champHandObjWeight;
-	}
-	_g524_restartGameAllowed = true;
-	_menuMan->f457_drawEnabledMenus();
-	_eventMan->f77_hideMouse();
-}
-
-Common::String DMEngine::getSavefileName(uint16 slot) {
-	return Common::String::format("%s.%03u", _targetName.c_str(), slot);
-}
-
-#define SAVEGAME_ID       MKTAG('D', 'M', 'D', 'M')
-#define SAVEGAME_VERSION  1
-
-void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::String& saveName) {
-	out->writeUint32BE(SAVEGAME_ID);
-
-	// Write version
-	out->writeByte(SAVEGAME_VERSION);
-
-	// Write savegame name
-	out->writeString(saveName);
-	out->writeByte(0);
-
-	// Save the game thumbnail
-	if (_saveThumbnail) {
-		out->write(_saveThumbnail->getData(), _saveThumbnail->size());
-	} else
-		Graphics::saveThumbnail(*out);
-
-	// Creation date/time
-	TimeDate curTime;
-	_system->getTimeAndDate(curTime);
-
-	uint32 saveDate = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
-	uint16 saveTime = ((curTime.tm_hour & 0xFF) << 8) | ((curTime.tm_min) & 0xFF);
-	uint32 playTime = getTotalPlayTime() / 1000;
-
-	out->writeUint32BE(saveDate);
-	out->writeUint16BE(saveTime);
-	out->writeUint32BE(playTime);
 }
 
-
 bool readSaveGameHeader(Common::InSaveFile* in, SaveGameHeader* header) {
 	uint32 id = in->readUint32BE();
 


Commit: 5cb1d02972bd13130e6b177dea6e35045ae54055
    https://github.com/scummvm/scummvm/commit/5cb1d02972bd13130e6b177dea6e35045ae54055
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix double load when loading from launcher

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dm.cpp
    engines/dm/loadsave.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 1699a8b..94c5105 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -17,4 +17,5 @@ Code stuff todo:
 	Complete stub methods(blitShrink, blitmask, scroller, etc.)
 	Save file f433_processCommand140_saveGame fails silently, add error checking
 	
-	
\ No newline at end of file
+	Add loading from dungeon
+	Fix incorrect thumbnail	
\ No newline at end of file
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index dc0655b..634ddb5 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -269,7 +269,7 @@ void DMEngine::f463_initializeGame() {
 	_objectMan->loadObjectNames();
 	_eventMan->initMouse();
 
-	int16 saveSlot = 1;
+	int16 saveSlot = -1;
 	do {
 		// if loading from the launcher
 		if (ConfMan.hasKey("save_slot")) {
@@ -278,11 +278,12 @@ void DMEngine::f463_initializeGame() {
 			f441_processEntrance();
 			if (_engineShouldQuit)
 				return;
-		}
-		if (_g298_newGame == k0_modeLoadSavedGame) { // if resume was clicked, bring up ScummVM load screen
-			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
-			saveSlot = dialog->runModalWithCurrentTarget();
-			delete dialog;
+
+			if (_g298_newGame == k0_modeLoadSavedGame) { // if resume was clicked, bring up ScummVM load screen
+				GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
+				saveSlot = dialog->runModalWithCurrentTarget();
+				delete dialog;
+			}
 		}
 	} while (f435_loadgame(saveSlot) != k1_LoadgameSuccess);
 
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 4d24daf..90ac9d9 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -47,7 +47,7 @@ namespace DM {
 #define C10_DUNGEON_DM 10
 
 LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
-	if (slot == -1)
+	if (slot == -1 && _g298_newGame == k0_modeLoadSavedGame)
 		return kM1_LoadgameFailure;
 
 	bool L1366_B_FadePalette = true;


Commit: efac7b5eb0dd90bc45761a666d8b68ddad703d19
    https://github.com/scummvm/scummvm/commit/efac7b5eb0dd90bc45761a666d8b68ddad703d19
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add loading from game

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dialog.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/loadsave.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 94c5105..f303008 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -18,4 +18,6 @@ Code stuff todo:
 	Save file f433_processCommand140_saveGame fails silently, add error checking
 	
 	Add loading from dungeon
-	Fix incorrect thumbnail	
\ No newline at end of file
+	Fix incorrect thumbnail	
+	Add translations to f433_processCommand140_saveGame 'LOAD'
+	
\ No newline at end of file
diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index 943f8c5..900ff76 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -223,7 +223,7 @@ int16 DialogMan::f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex,
 	L1303_s_BoxB = L1304_s_BoxA;
 	L1303_s_BoxB._x1 = L1303_s_BoxB._x2;
 	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
-	_vm->f22_delay(5);
+	_vm->f22_delay(2);
 	L1303_s_BoxB = L1304_s_BoxA;
 	L1303_s_BoxB._y1++;
 	L1303_s_BoxB._y2 = L1303_s_BoxB._y1;
@@ -251,7 +251,7 @@ int16 DialogMan::f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex,
 	L1303_s_BoxB._x1 = L1303_s_BoxB._x2 = L1303_s_BoxB._x2 + 3;
 	L1303_s_BoxB._y2 += 2;
 	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k13_ColorLightestGray);
-	_vm->f22_delay(5);
+	_vm->f22_delay(2);
 	L1304_s_BoxA._x2 += 3;
 	L1304_s_BoxA._y2 += 3;
 	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g348_bitmapScreen,
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 634ddb5..2003ace 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -207,6 +207,8 @@ DMEngine::DMEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst),
 	debug("DMEngine::DMEngine");
 
 	_saveThumbnail = nullptr;
+	_canLoadFromGMM = false;
+	_loadSaveSlotAtRuntime = -1;
 }
 
 DMEngine::~DMEngine() {
@@ -243,6 +245,26 @@ bool DMEngine::hasFeature(EngineFeature f) const {
 		(f == kSupportsLoadingDuringRuntime);
 }
 
+Common::Error DMEngine::loadGameState(int slot) {
+	if (f435_loadgame(slot) != kM1_LoadgameFailure) {
+		_displayMan->fillScreen(k0_ColorBlack);
+		_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_palDungeonView[0]);
+		_g298_newGame = k0_modeLoadSavedGame;
+
+		f462_startGame();
+		_g523_restartGameRequest = false;
+		_eventMan->f77_hideMouse();
+		_eventMan->f357_discardAllInput();
+		return Common::kNoError;
+	}
+
+	return Common::kNoGameDataFoundError;
+}
+
+bool DMEngine::canLoadGameStateCurrently() {
+	return _canLoadFromGMM;
+}
+
 void DMEngine::f22_delay(uint16 verticalBlank) {
 	for (uint16 i = 0; i < verticalBlank * 2; ++i) {
 		_eventMan->processInput();
@@ -386,9 +408,18 @@ Common::Error DMEngine::run() {
 	f463_initializeGame();
 	while (true) {
 		f2_gameloop();
+
 		if (_engineShouldQuit)
 			return Common::kNoError;
-		f444_endGame(_championMan->_g303_partyDead);
+
+		if (_loadSaveSlotAtRuntime == -1)
+			f444_endGame(_championMan->_g303_partyDead);
+		else {
+			loadGameState(_loadSaveSlotAtRuntime);
+			_menuMan->f457_drawEnabledMenus();
+			_displayMan->updateScreen();
+			_loadSaveSlotAtRuntime = -1;
+		}
 	}
 
 	return Common::kNoError;
@@ -403,10 +434,13 @@ void DMEngine::f2_gameloop() {
 		_dungeonMan->_g308_partyDir = kDirWest;
 	}
 
+	_canLoadFromGMM = true;
 	_g318_waitForInputMaxVerticalBlankCount = 10;
 	while (true) {
-		if (_engineShouldQuit)
+		if (_engineShouldQuit) {
+			_canLoadFromGMM = false;
 			return;
+		}
 
 		// DEBUG CODE
 		for (int16 i = 0; i < _championMan->_g305_partyChampionCount; ++i) {
@@ -495,8 +529,10 @@ void DMEngine::f2_gameloop() {
 			}
 
 			_eventMan->f380_processCommandQueue();
-			if (_engineShouldQuit)
+			if (_engineShouldQuit || _loadSaveSlotAtRuntime != -1) {
+				_canLoadFromGMM = false;
 				return;
+			}
 			_displayMan->updateScreen();
 			if (!_g321_stopWaitingForPlayerInput) {
 				_eventMan->f363_highlightBoxDisable();
@@ -508,6 +544,7 @@ void DMEngine::f2_gameloop() {
 
 		} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking);
 	}
+	_canLoadFromGMM = false;
 }
 
 int16 DMEngine::M1_ordinalToIndex(int16 val) {
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 2e3144b..9bf2c15 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -219,6 +219,10 @@ public:
 	explicit DMEngine(OSystem *syst, const ADGameDescription *gameDesc);
 	~DMEngine();
 	virtual bool hasFeature(EngineFeature f) const;
+
+	virtual Common::Error loadGameState(int slot);
+	virtual bool canLoadGameStateCurrently();
+
 	GUI::Debugger *getDebugger() { return _console; }
 
 	void f22_delay(uint16 verticalBlank); // @ F0022_MAIN_Delay
@@ -250,6 +254,7 @@ private:
 	
 	byte *_savedScreenForOpenEntranceDoors; // ad-hoc HACK
 	const ADGameDescription *_gameVersion;
+	bool _canLoadFromGMM;
 public:
 	Console *_console;
 	DisplayMan *_displayMan;
@@ -270,6 +275,7 @@ public:
 	Common::MemoryWriteStreamDynamic *_saveThumbnail;
 
 	bool _engineShouldQuit;
+	int _loadSaveSlotAtRuntime;
 
 	int16 _g298_newGame; // @ G0298_B_NewGame
 	bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 8cb702a..7b8d69d 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -740,8 +740,6 @@ void DungeonMan::f173_setCurrentMap(uint16 mapIndex) {
 		DoorInfo(5, 255)    /* Door type 3 Ra door */
 	};
 
-	if (_g272_currMapIndex == mapIndex)
-		return;
 
 	_g272_currMapIndex = mapIndex;
 	_g271_currMapData = _g279_dungeonMapData[mapIndex];
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 90ac9d9..6a21c42 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -56,19 +56,13 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 	Common::InSaveFile *file = nullptr;
 
 	struct {
-		int16 _saveFormat;
-		int16 _saveAndPlayChoice;
-		int32 _gameId;
-		int16 _platform;
-		uint16 _dungeonId;
+		int16 _saveFormat = 0;
+		int16 _saveAndPlayChoice = 0;
+		int32 _gameId = 0;
+		int16 _platform = 0;
+		uint16 _dungeonId = 0;
 	} dmSaveHeader;
 
-	dmSaveHeader._saveFormat = 0;
-	dmSaveHeader._saveAndPlayChoice = 0;
-	dmSaveHeader._gameId = 0;
-	dmSaveHeader._platform = 0;
-	dmSaveHeader._dungeonId = 0;
-
 	if (!_g298_newGame) {
 		fileName = getSavefileName(slot);
 		saveFileManager = _system->getSavefileManager();
@@ -188,23 +182,35 @@ void DMEngine::f433_processCommand140_saveGame() {
 	switch (getGameLanguage()) { // localized
 	default:
 	case Common::EN_ANY:
-		_dialog->f427_dialogDraw(nullptr, nullptr, "SAVE AND PLAY", "SAVE AND QUIT", "CANCEL", nullptr, false, false, false);
+		_dialog->f427_dialogDraw(nullptr, nullptr, "SAVE AND PLAY", "SAVE AND QUIT", "CANCEL", "LOAD", false, false, false);
 		break;
 	case Common::DE_DEU:
-		_dialog->f427_dialogDraw(nullptr, nullptr, "SICHERN/SPIEL", "SICHERN/ENDEN", "WIDERRUFEN", nullptr, false, false, false);
+		_dialog->f427_dialogDraw(nullptr, nullptr, "SICHERN/SPIEL", "SICHERN/ENDEN", "WIDERRUFEN", "LOAD", false, false, false);
 		break;
 	case Common::FR_FRA:
-		_dialog->f427_dialogDraw(nullptr, nullptr, "GARDER/JOUER", "GARDER/SORTIR", "ANNULLER", nullptr, false, false, false);
+		_dialog->f427_dialogDraw(nullptr, nullptr, "GARDER/JOUER", "GARDER/SORTIR", "ANNULLER", "LOAD", false, false, false);
 		break;
 	}
 
 	enum SaveAndPlayChoice {
 		kSaveAndPlay = 1,
 		kSaveAndQuit = 2,
-		kCancel = 3
+		kCancel = 3,
+		kLoad = 4
 	};
 
-	SaveAndPlayChoice saveAndPlayChoice = (SaveAndPlayChoice)_dialog->f424_dialogGetChoice(3, k0_DIALOG_SET_VIEWPORT, 0, k0_DIALOG_CHOICE_NONE);
+	SaveAndPlayChoice saveAndPlayChoice = (SaveAndPlayChoice)_dialog->f424_dialogGetChoice(4, k0_DIALOG_SET_VIEWPORT, 0, k0_DIALOG_CHOICE_NONE);
+
+	if (saveAndPlayChoice == kLoad) {
+		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
+		int loadSlot = dialog->runModalWithCurrentTarget();
+		if (loadSlot >= 0) {
+			_loadSaveSlotAtRuntime = loadSlot;
+			return;
+		}
+
+		saveAndPlayChoice = kCancel;
+	}
 
 	if (saveAndPlayChoice == kSaveAndQuit || saveAndPlayChoice == kSaveAndPlay) {
 		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);


Commit: b4b76047ff5289dd003f03e05f0d5ed1d0067926
    https://github.com/scummvm/scummvm/commit/b4b76047ff5289dd003f03e05f0d5ed1d0067926
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some GCC warnings

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dialog.h
    engines/dm/dm.h
    engines/dm/eventman.cpp
    engines/dm/group.cpp
    engines/dm/sounds.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 94d2046..9651db6 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -41,16 +41,6 @@
 
 namespace DM {
 
-
-Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
-Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
-Box g54_BoxChampionIcons[4] = {
-	Box(281, 299,  0, 13),
-	Box(301, 319,  0, 13),
-	Box(301, 319, 15, 28),
-	Box(281, 299, 15, 28)};
-Color g46_ChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14};
-
 int16 g39_LightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100};
 
 uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
@@ -99,20 +89,37 @@ Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_Champi
 const char *g417_baseSkillName[4];
 
 void ChampionMan::initConstants() {
-	{
-		static const char *g417_baseSkillName_EN_ANY[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"};
-		static const char *g417_baseSkillName_DE_DEU[4] = {"KAEMPFER", "NINJA", "PRIESTER", "MAGIER"};
-		static const char *g417_baseSkillName_FR_FRA[4] = {"GUERRIER", "NINJA", "PRETRE", "SORCIER"};
+	static const char *g417_baseSkillName_EN_ANY[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"};
+	static const char *g417_baseSkillName_DE_DEU[4] = {"KAEMPFER", "NINJA", "PRIESTER", "MAGIER"};
+	static const char *g417_baseSkillName_FR_FRA[4] = {"GUERRIER", "NINJA", "PRETRE", "SORCIER"};
+	static Box boxChampionIcons[4] = {
+		Box(281, 299,  0, 13),
+		Box(301, 319,  0, 13),
+		Box(301, 319, 15, 28),
+		Box(281, 299, 15, 28)
+	};
 
-		const char **g417_byLanguage;
-		switch (_vm->getGameLanguage()) { // localized
-		default:
-		case Common::EN_ANY: g417_byLanguage = g417_baseSkillName_EN_ANY; break;
-		case Common::DE_DEU: g417_byLanguage = g417_baseSkillName_DE_DEU; break;
-		case Common::FR_FRA: g417_byLanguage = g417_baseSkillName_FR_FRA; break;
-		}
-		for (int i = 0; i < 4; ++i)
-			g417_baseSkillName[i] = g417_byLanguage[i];
+	static Color championColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14};
+
+	const char **g417_byLanguage;
+	switch (_vm->getGameLanguage()) { // localized
+	case Common::EN_ANY: 
+		g417_byLanguage = g417_baseSkillName_EN_ANY;
+		break;
+	case Common::DE_DEU:
+		g417_byLanguage = g417_baseSkillName_DE_DEU;
+		break;
+	case Common::FR_FRA:
+		g417_byLanguage = g417_baseSkillName_FR_FRA;
+		break;
+	default:
+		error("Unexpected language used");
+	}
+
+	for (int i = 0; i < 4; ++i) {
+		g417_baseSkillName[i] = g417_byLanguage[i];
+		_championColor[i] = championColor[i];
+		_boxChampionIcons[i] = boxChampionIcons[i];
 	}
 }
 
@@ -139,9 +146,9 @@ ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
 }
 
 bool ChampionMan::f329_isLeaderHandObjectThrown(int16 side) {
-	if (_g411_leaderIndex == kM1_ChampionNone) {
+	if (_g411_leaderIndex == kM1_ChampionNone)
 		return false;
-	}
+
 	return f328_isObjectThrown(_g411_leaderIndex, kM1_ChampionSlotLeaderHand, side);
 }
 
@@ -459,7 +466,7 @@ void ChampionMan::f296_drawChangedObjectIcons() {
 			}
 		}
 
-		if (invMan._g424_panelContent = k4_PanelContentChest) {
+		if (invMan._g424_panelContent == k4_PanelContentChest) {
 			thing = invMan._g425_chestSlots;
 			for (int16 slotIndex = 0; slotIndex < 8; ++slotIndex, thing++) {
 				drawViewport |= (f295_hasObjectIconInSlotBoxChanged(slotIndex + k38_SlotBoxChestFirstSlot, *thing) ? 1 : 0);
@@ -512,7 +519,7 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 			}
 		}
 
-		if (iconIndex = k4_IconIndiceWeaponTorchUnlit) {
+		if (iconIndex == k4_IconIndiceWeaponTorchUnlit) {
 			((Weapon *)rawObjPtr)->setLit(true);
 			_vm->_inventoryMan->f337_setDungeonViewPalette();
 			f296_drawChangedObjectIcons();
@@ -988,7 +995,7 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex,
 			setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
 			f292_drawChampionState((ChampionIndex)champIndex);
 			_vm->_textMan->f51_messageAreaPrintLineFeed();
-			Color curChampionColor = g46_ChampionColor[champIndex];
+			Color curChampionColor = _championColor[champIndex];
 			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, curChampion->_name);
 
 			switch (_vm->getGameLanguage()) { // localized
@@ -1449,7 +1456,7 @@ void ChampionMan::f319_championKill(uint16 champIndex) {
 		f323_unpoison(champIndex);
 
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[curChampionIconIndex], k0_ColorBlack);
+	_vm->_displayMan->D24_fillScreenBox(_boxChampionIcons[curChampionIconIndex], k0_ColorBlack);
 	f292_drawChampionState((ChampionIndex)champIndex);
 
 	int16 aliveChampionIndex;
@@ -2032,7 +2039,7 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
 		if (barGraphHeight) {
 			box._y1 = 27 - barGraphHeight;
 			box._y2 = 26;
-			_vm->_displayMan->D24_fillScreenBox(box, g46_ChampionColor[champIndex]);
+			_vm->_displayMan->D24_fillScreenBox(box, _championColor[champIndex]);
 		}
 		box._x1 += 7;
 		box._x2 += 7;
@@ -2068,6 +2075,9 @@ uint16 ChampionMan::f309_getMaximumLoad(Champion *champ) {
 }
 
 void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
+	static Box boxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
+	static Box boxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
+
 	int16 championStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
 	Champion *curChampion = &_gK71_champions[champIndex];
 	uint16 championAttributes = curChampion->_attributes;
@@ -2155,7 +2165,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 			else
 				nativeBitmapIndex = k33_SlotBoxNormalIndice;
 
-			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), gBoxMouth, k16_byteWidth, k12_ColorDarkestGray, 18);
+			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), boxMouth, k16_byteWidth, k12_ColorDarkestGray, 18);
 			nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			for (int i = k1_ChampionStatStrength; i <= k6_ChampionStatAntifire; i++) {
 				if ((curChampion->_statistics[i][k1_ChampionStatCurrent] < curChampion->_statistics[i][k0_ChampionStatMaximum])) {
@@ -2163,7 +2173,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 					break;
 				}
 			}
-			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), gBoxEye, k16_byteWidth, k12_ColorDarkestGray, 18);
+			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), boxEye, k16_byteWidth, k12_ColorDarkestGray, 18);
 			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 		}
 	}
@@ -2213,8 +2223,8 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 	}
 	uint16 championIconIndex = M26_championIconIndex(curChampion->_cell, _vm->_dungeonMan->_g308_partyDir);
 	if (getFlag(championAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(championIconIndex))) {
-		_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[championIconIndex], g46_ChampionColor[champIndex]);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[championIconIndex], M26_championIconIndex(curChampion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
+		_vm->_displayMan->D24_fillScreenBox(_boxChampionIcons[championIconIndex], _championColor[champIndex]);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, _boxChampionIcons[championIconIndex], M26_championIconIndex(curChampion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
 	}
 	if (getFlag(championAttributes, k0x0800_ChampionAttributePanel) && isInventoryChampion) {
 		if (_vm->_g333_pressingMouth)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 7f726b6..33e2c62 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -38,9 +38,6 @@ namespace DM {
 #define k0x4000_IgnoreObjectModifiers 0x4000 // @ MASK0x4000_IGNORE_OBJECT_MODIFIERS     
 #define k0x8000_IgnoreTemporaryExperience 0x8000 // @ MASK0x8000_IGNORE_TEMPORARY_EXPERIENCE 
 
-extern Box g54_BoxChampionIcons[4]; // @ G0054_ai_Graphic562_Box_ChampionIcons
-extern Color g46_ChampionColor[4]; // @ G0046_auc_Graphic562_ChampionColor
-
 extern int16 g39_LightPowerToLightAmount[16]; // @ G0039_ai_Graphic562_LightPowerToLightAmount
 
 class Scent {
@@ -590,9 +587,12 @@ public:
 	void f331_applyTimeEffects(); // @ F0331_CHAMPION_ApplyTimeEffects_CPSF
 	void save2_PartyPart(Common::OutSaveFile *file);
 	void load2_PartyPart(Common::InSaveFile* file);
-};
 
 
+	Box _boxChampionIcons[4];
+	Color _championColor[4];
+};
+
 }
 
 #endif
diff --git a/engines/dm/dialog.h b/engines/dm/dialog.h
index 2aec5e9..48a1acc 100644
--- a/engines/dm/dialog.h
+++ b/engines/dm/dialog.h
@@ -54,4 +54,4 @@ public:
 	int16 f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex, int16 driveType, int16 automaticChoiceIfFlopyInDrive); // @ F0424_DIALOG_GetChoice
 };
 
-}
\ No newline at end of file
+}
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 9bf2c15..d30727b 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -141,11 +141,7 @@ bool isOrientedWestEast(Direction dir);	// @ M16_IS_ORIENTED_WEST_EAST
 
 
 #define setFlag(val, mask) ((val) |= (mask))
-
-
 #define getFlag(val, mask) ((val) & (mask))
-
-
 #define clearFlag(val, mask) ((val) &= (~(mask))) // @ M09_CLEAR
 
 uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 9f0b387..f6b9b07 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -43,53 +43,6 @@
 
 
 namespace DM {
-unsigned char g42_bitmapArrowPointer[288] = { // @ G0042_auc_Graphic562_Bitmap_ArrowPointer
-	0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
-	0x78, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00,
-	0x7F, 0x80, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00,
-	0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
-	0x60, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00,
-	0x7E, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00,
-	0x6C, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-	0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0xC0, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00,
-	0x84, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
-	0x80, 0x40, 0x00, 0x00, 0x83, 0xC0, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0xA9, 0x00, 0x00, 0x00,
-	0xC9, 0x00, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00,
-	0xF0, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00,
-	0xFF, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00,
-	0xFE, 0x00, 0x00, 0x00, 0xEF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00,
-	0x07, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-unsigned char g43_bitmapHanPointer[288] = { // @ G0043_auc_Graphic562_Bitmap_HandPointer
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x6A, 0x00, 0x00, 0x00,
-	0x35, 0x40, 0x00, 0x00, 0x1A, 0xA0, 0x00, 0x00, 0x0D, 0x50, 0x00, 0x00, 0x0E, 0xA8, 0x00, 0x00,
-	0x07, 0xF8, 0x00, 0x00, 0xC7, 0xFC, 0x00, 0x00, 0x67, 0xFC, 0x00, 0x00, 0x77, 0xFC, 0x00, 0x00,
-	0x3F, 0xFC, 0x00, 0x00, 0x3F, 0xFC, 0x00, 0x00, 0x1F, 0xFE, 0x00, 0x00, 0x07, 0xFF, 0x00, 0x00,
-	0x01, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x20, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x4A, 0xA0, 0x00, 0x00, 0x25, 0x50, 0x00, 0x00,
-	0x12, 0xA8, 0x00, 0x00, 0x11, 0x54, 0x00, 0x00, 0xC8, 0x04, 0x00, 0x00, 0x28, 0x02, 0x00, 0x00,
-	0x98, 0x02, 0x00, 0x00, 0x88, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00,
-	0x20, 0x01, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
-	0x7F, 0xE0, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x1F, 0xFC, 0x00, 0x00,
-	0xCF, 0xFC, 0x00, 0x00, 0xEF, 0xFE, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00,
-	0x7F, 0xFE, 0x00, 0x00, 0x7F, 0xFE, 0x00, 0x00, 0x3F, 0xFF, 0x00, 0x00, 0x1F, 0xFF, 0x00, 0x00,
-	0x07, 0xFF, 0x00, 0x00, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
-Box g462_BoxObjectPiles[4] = { // @ G0462_as_Graphic561_Box_ObjectPiles
-	/* { X1, X2, Y1, Y2 } */
-	Box(24, 111, 148, 168),   /* Front left */
-	Box(112, 199, 148, 168),   /* Front right */
-	Box(112, 183, 122, 147),   /* Back right */
-	Box(40, 111, 122, 147)}; /* Back left */
-
-
 KeyboardInput g458_primaryKeyboardInput_interface[7] = { // @ G0458_as_Graphic561_PrimaryKeyboardInput_Interface
 														 /* { Command, Code } */
 	KeyboardInput(k7_CommandToggleInventoryChampion_0, Common::KEYCODE_F1, 0), /* F1 (<CSI>1~) Atari ST: Code = 0x3B00 */
@@ -445,12 +398,53 @@ void EventManager::f71_mouseDropChampionIcon() {
 	_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
 	_g598_mousePointerBitmapUpdated = true;
 	bool useByteBoxCoordinatesBackup = _vm->_displayMan->_g578_useByteBoxCoordinates;
-	_vm->_displayMan->f21_blitToScreen(_g613_mousePointerOriginalColorsChampionIcon, &g54_BoxChampionIcons[championIconIndex << 2], 16, k12_ColorDarkestGray, 18);
+	_vm->_displayMan->f21_blitToScreen(_g613_mousePointerOriginalColorsChampionIcon, &_vm->_championMan->_boxChampionIcons[championIconIndex << 2], 16, k12_ColorDarkestGray, 18);
 	_vm->_displayMan->_g578_useByteBoxCoordinates = useByteBoxCoordinatesBackup;
 	_gK100_preventBuildPointerScreenArea = false;
 }
 
 void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY) {
+	static unsigned char bitmapArrowPointer[288] = { // @ G0042_auc_Graphic562_Bitmap_ArrowPointer
+		0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+		0x78, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00,
+		0x7F, 0x80, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00,
+		0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+		0x60, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00,
+		0x7E, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00,
+		0x6C, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0xC0, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00,
+		0x84, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
+		0x80, 0x40, 0x00, 0x00, 0x83, 0xC0, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0xA9, 0x00, 0x00, 0x00,
+		0xC9, 0x00, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00,
+		0xF0, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00,
+		0xFF, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00,
+		0xFE, 0x00, 0x00, 0x00, 0xEF, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00,
+		0x07, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+	};
+	static unsigned char bitmapHanPointer[288] = { // @ G0043_auc_Graphic562_Bitmap_HandPointer
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x6A, 0x00, 0x00, 0x00,
+		0x35, 0x40, 0x00, 0x00, 0x1A, 0xA0, 0x00, 0x00, 0x0D, 0x50, 0x00, 0x00, 0x0E, 0xA8, 0x00, 0x00,
+		0x07, 0xF8, 0x00, 0x00, 0xC7, 0xFC, 0x00, 0x00, 0x67, 0xFC, 0x00, 0x00, 0x77, 0xFC, 0x00, 0x00,
+		0x3F, 0xFC, 0x00, 0x00, 0x3F, 0xFC, 0x00, 0x00, 0x1F, 0xFE, 0x00, 0x00, 0x07, 0xFF, 0x00, 0x00,
+		0x01, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x20, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x4A, 0xA0, 0x00, 0x00, 0x25, 0x50, 0x00, 0x00,
+		0x12, 0xA8, 0x00, 0x00, 0x11, 0x54, 0x00, 0x00, 0xC8, 0x04, 0x00, 0x00, 0x28, 0x02, 0x00, 0x00,
+		0x98, 0x02, 0x00, 0x00, 0x88, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00,
+		0x20, 0x01, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
+		0x7F, 0xE0, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x1F, 0xFC, 0x00, 0x00,
+		0xCF, 0xFC, 0x00, 0x00, 0xEF, 0xFE, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00,
+		0x7F, 0xFE, 0x00, 0x00, 0x7F, 0xFE, 0x00, 0x00, 0x3F, 0xFF, 0x00, 0x00, 0x1F, 0xFF, 0x00, 0x00,
+		0x07, 0xFF, 0x00, 0x00, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+	};
+
 	// if (_gK100_preventBuildPointerScreenArea)
 	//	return;
 
@@ -493,7 +487,7 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY)
 		_g598_mousePointerBitmapUpdated = false;
 		switch (_gK104_mousePointerType) {
 		case k0_pointerTypeArrow:
-			setMousePointerFromSpriteData(g42_bitmapArrowPointer);
+			setMousePointerFromSpriteData(bitmapArrowPointer);
 			break;
 		case k1_pointerTypeObjectIcon:
 			CursorMan.replaceCursor(_g615_mousePointerOriginalColorsObject, 32, 18, 0, 0, 0);
@@ -502,7 +496,7 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY)
 			CursorMan.replaceCursor(_g613_mousePointerOriginalColorsChampionIcon, 32, 18, 0, 0, 0);
 			break;
 		case k3_pointerTypeHand:
-			setMousePointerFromSpriteData(g43_bitmapHanPointer);
+			setMousePointerFromSpriteData(bitmapHanPointer);
 			break;
 		}
 	}
@@ -1065,6 +1059,14 @@ void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() {
 }
 
 void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16 posY) {
+	Box boxObjectPiles[4] = { // @ G0462_as_Graphic561_Box_ObjectPiles
+		/* { X1, X2, Y1, Y2 } */
+		Box(24, 111, 148, 168),   /* Front left */
+		Box(112, 199, 148, 168),  /* Front right */
+		Box(112, 183, 122, 147),  /* Back right */
+		Box(40, 111, 122, 147)    /* Back left */
+	};
+
 	if (_vm->_dungeonMan->_g285_squareAheadElement == k17_DoorFrontElemType) {
 		if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone)
 			return;
@@ -1101,7 +1103,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 		Junk *junkPtr = (Junk*)_vm->_dungeonMan->f156_getThingData(thingHandObject);
 		if (_vm->_dungeonMan->_g285_squareAheadElement == k0_ElementTypeWall) {
 			for (uint16 currViewCell = k0_ViewCellFronLeft; currViewCell < k1_ViewCellFrontRight + 1; currViewCell++) {
-				if (g462_BoxObjectPiles[currViewCell].isPointInside(posX, posY)) {
+				if (boxObjectPiles[currViewCell].isPointInside(posX, posY)) {
 					f374_processType80_clickInDungeonViewDropLeaderHandObject(currViewCell);
 					return;
 				}
@@ -1132,7 +1134,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 				return;
 
 			for (uint16 currViewCell = k0_ViewCellFronLeft; currViewCell < k3_ViewCellBackLeft + 1; currViewCell++) {
-				if (g462_BoxObjectPiles[currViewCell].isPointInside(posX, posY)) {
+				if (boxObjectPiles[currViewCell].isPointInside(posX, posY)) {
 					f374_processType80_clickInDungeonViewDropLeaderHandObject(currViewCell);
 					return;
 				}
@@ -1163,7 +1165,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 		box._x2 = box._x1 + 66;
 		dispMan._g578_useByteBoxCoordinates = false;
 		dispMan.D24_fillScreenBox(box, k0_ColorBlack);
-		dispMan.D24_fillScreenBox(g54_BoxChampionIcons[champMan.M26_championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2], k0_ColorBlack);
+		dispMan.D24_fillScreenBox(_vm->_championMan->_boxChampionIcons[champMan.M26_championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2], k0_ColorBlack);
 		_vm->_menuMan->f457_drawEnabledMenus();
 		f78_showMouse();
 		return;
@@ -1209,7 +1211,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 		_vm->_menuMan->f393_drawSpellAreaControls(champMan._g514_magicCasterChampionIndex);
 
 	_vm->_textMan->f51_messageAreaPrintLineFeed();
-	Color champColor = g46_ChampionColor[championIndex];
+	Color champColor = _vm->_championMan->_championColor[championIndex];
 	_vm->_textMan->f47_messageAreaPrintMessage(champColor, champ->_name);
 
 	switch (_vm->getGameLanguage()) { // localized
@@ -1379,7 +1381,7 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		byte *tmpBitmap = _gK190_mousePointerTempBuffer;
 		memset(tmpBitmap, 0, 32 * 18);
-		Box *curChampionIconBox = &g54_BoxChampionIcons[champIconIndex];
+		Box *curChampionIconBox = &_vm->_championMan->_boxChampionIcons[champIconIndex];
 
 		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, tmpBitmap, championIconShadowBox, curChampionIconBox->_x1, curChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
 		_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(tmpBitmap, _g613_mousePointerOriginalColorsChampionIcon, 32, 18, 32, 18, mousePointerIconShadowBox);
@@ -1401,7 +1403,7 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 				setFlag(_vm->_championMan->_gK71_champions[championIndex]._attributes, k0x0400_ChampionAttributeIcon);
 				_vm->_championMan->f292_drawChampionState((ChampionIndex)championIndex);
 			} else
-				_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[championIconIndex], k0_ColorBlack);
+				_vm->_displayMan->D24_fillScreenBox(_vm->_championMan->_boxChampionIcons[championIconIndex], k0_ColorBlack);
 
 			_vm->_championMan->_gK71_champions[championCellIndex]._cell = (ViewCell)M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir);
 			setFlag(_vm->_championMan->_gK71_champions[championCellIndex]._attributes, k0x0400_ChampionAttributeIcon);
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 118eea7..a66ca05 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -292,7 +292,6 @@ int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 sr
 #define AP0483_i_PrimaryDirection srcMapX
 	int16 L0556_i_Direction;
 
-
 	if (srcMapX == destMapX) {
 		_vm->_projexpl->_g363_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 1; /* Resulting direction may be 1 or 3 (East or West) */
 		if (srcMapY > destMapY) {
diff --git a/engines/dm/sounds.h b/engines/dm/sounds.h
index 6377835..8dfb3af 100644
--- a/engines/dm/sounds.h
+++ b/engines/dm/sounds.h
@@ -90,4 +90,4 @@ public:
 	void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol) override {} // @ F0060_SOUND_Play
 };
 
-}
\ No newline at end of file
+}


Commit: f9d76556c24a3ed68b379277cf60928ef32df7aa
    https://github.com/scummvm/scummvm/commit/f9d76556c24a3ed68b379277cf60928ef32df7aa
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix regression in f107_isDrawnWallOrnAnAlcove

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 0fe319e..e6996d3 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -495,7 +495,7 @@ void DisplayMan::f460_initializeGraphicData() {
 	if (!_g639_derivedBitmapByteCount)
 		_g639_derivedBitmapByteCount = new uint16[k730_DerivedBitmapMaximumCount];
 	if (!_g638_derivedBitmaps) {
-		_g638_derivedBitmaps = new byte*[k730_DerivedBitmapMaximumCount];
+		_g638_derivedBitmaps = new byte *[k730_DerivedBitmapMaximumCount];
 		for (uint16 i = 0; i < k730_DerivedBitmapMaximumCount; ++i)
 			_g638_derivedBitmaps[i] = nullptr;
 	}
@@ -666,7 +666,7 @@ void DisplayMan::unpackGraphics() {
 		delete[] _bitmaps[0];
 		delete[] _bitmaps;
 	}
-	_bitmaps = new byte*[575]; // largest graphic indice (i think)
+	_bitmaps = new byte *[575]; // largest graphic indice (i think)
 	_bitmaps[0] = new byte[unpackedBitmapsSize];
 	f466_loadIntoBitmap(0, _bitmaps[0]);
 	for (uint16 i = 1; i <= 20; ++i) {
@@ -682,7 +682,7 @@ void DisplayMan::unpackGraphics() {
 	loadFNT1intoBitmap(k557_FontGraphicIndice, _bitmaps[k557_FontGraphicIndice]);
 }
 
-void DisplayMan::loadFNT1intoBitmap(uint16 index, byte* destBitmap) {
+void DisplayMan::loadFNT1intoBitmap(uint16 index, byte * destBitmap) {
 	uint8 *data = _packedBitmaps + _packedItemPos[index];
 
 	for (uint16 i = 0; i < 6; i++) {
@@ -712,7 +712,7 @@ void DisplayMan::f102_drawDoorBitmap(Frame* frame) {
 	}
 }
 
-void DisplayMan::f103_drawDoorFrameBitmapFlippedHorizontally(byte* bitmap, Frame* frame) {
+void DisplayMan::f103_drawDoorFrameBitmapFlippedHorizontally(byte *bitmap, Frame *frame) {
 	if (frame->_srcByteWidth) {
 		f130_flipBitmapHorizontal(bitmap, frame->_srcByteWidth, frame->_srcHeight);
 		f132_blitToBitmap(bitmap, _g296_bitmapViewport, frame->_box, frame->_srcX, frame->_srcY,
@@ -854,12 +854,12 @@ void DisplayMan::D24_fillScreenBox(Box &box, Color color) {
 		memset(_g348_bitmapScreen + y * _screenWidth + box._x1, color, sizeof(byte) * width);
 }
 
-void DisplayMan::f135_fillBoxBitmap(byte* destBitmap, Box &box, Color color, int16 byteWidth, int16 height) {
+void DisplayMan::f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 byteWidth, int16 height) {
 	for (int16 y = box._y1; y < box._y2 + 1; ++y) // + 1 for inclusive boundaries
 		memset(destBitmap + y * byteWidth * 2 + box._x1, color, sizeof(byte) * (box._x2 - box._x1 + 1)); // + 1 for inclusive boundaries
 }
 
-void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box,
+void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box& box,
 													int16 lastUnitIndex, int16 firstUnitIndex, int16 destByteWidth, Color transparent,
 													int16 xPos, int16 yPos, int16 destHeight, int16 height2) {
 	// make sure to take care of inclusive boundaries, color can have 0x8000 flag to not use mask
@@ -889,7 +889,7 @@ void DisplayMan::f131_flipVertical(byte *bitmap, uint16 byteWidth, uint16 height
 	delete[] tmp;
 }
 
-byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnByteWidth, int16& returnHeight) {
+byte *DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnByteWidth, int16& returnHeight) {
 	ExplosionAspect *explAsp = &_explosionAspects[explosionAspIndex];
 	if (scale > 32)
 		scale = 32;
@@ -969,7 +969,7 @@ uint16 DisplayMan::getPixelHeight(uint16 index) {
 	return READ_BE_UINT16(data + 2);
 }
 
-void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitmap, uint16 byteWidth, uint16 height) {
+void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height) {
 	memmove(destBitmap, srcBitmap, byteWidth * 2 * height * sizeof(byte));
 	f130_flipBitmapHorizontal(destBitmap, byteWidth, height);
 }
@@ -2449,7 +2449,7 @@ void DisplayMan::f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativ
 }
 
 bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) {
-	static Box boxWallPatchBehindInscription = Box(110, 113, 37, 63); // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription 
+	static Box boxWallPatchBehindInscription = Box(110, 113, 37, 63); // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription
 	static const byte inscriptionLineY[4] = { // @ G0203_auc_Graphic558_InscriptionLineY
 		48,   /* 1 Line  */
 		59,   /* 2 lines */
@@ -2608,133 +2608,131 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 
 	if (!wallOrnOrd)
 		return false;
-
-	int16 wallOrnamentIndex = wallOrnOrd;
 	wallOrnOrd--;
-	int16 nativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnamentIndex][k0_NativeBitmapIndex];
+	int16 wallOrnamentIndex = wallOrnOrd;
+	int16 ornNativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnamentIndex][k0_NativeBitmapIndex];
 	int16 wallOrnamentCoordinateSetIndex = _g101_currMapWallOrnInfo[wallOrnamentIndex][k1_CoordinateSet];
-	byte *coordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][viewWallIndex];
+	byte *ornCoordSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][viewWallIndex];
 	bool isAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(wallOrnamentIndex);
-	bool isInscription = (wallOrnamentIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex);
-
 	unsigned char inscriptionString[70];
+	bool isInscription = (wallOrnamentIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex);
 	if (isInscription)
 		_vm->_dungeonMan->f168_decodeText((char*)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
 
-	byte *blitBitmap;
-	int16 blitX;
+	int16 blitPosX;
+	byte *ornBlitBitmap;
+
 	if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) {
 		if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
 			if (isInscription) {
 				f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, boxWallPatchBehindInscription, 94, 28, _frameWalls163[k6_ViewSquare_D1C]._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency, _frameWalls163[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport);
-				byte *parseString = inscriptionString;
-				byte *fontBitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont);
+				byte *inscrString = inscriptionString;
+				byte *L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont);
 				int16 textLineIndex = 0;
 				do {
 					int16 characterCount = 0;
-					byte *tmpString = parseString;
-					while (*tmpString++ < 128) /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
+					byte *AL0091_puc_Character = inscrString;
+					while (*AL0091_puc_Character++ < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
 						characterCount++;
-
-					Frame newFrame;
-					newFrame._box._x2 = (newFrame._box._x1 = 112 - (characterCount << 2)) + 7;
-					newFrame._box._y1 = (newFrame._box._y2 = inscriptionLineY[textLineIndex++]) - 7;
+					}
+					Frame blitFrame;
+					blitFrame._box._x2 = (blitFrame._box._x1 = 112 - (characterCount << 2)) + 7;
+					blitFrame._box._y1 = (blitFrame._box._y2 = inscriptionLineY[textLineIndex++]) - 7;
 					while (characterCount--) {
-						f132_blitToBitmap(fontBitmap, _g296_bitmapViewport, newFrame._box, *parseString++ << 3, 0, k144_byteWidth, k112_byteWidthViewport, k10_ColorFlesh, 8, k136_heightViewport);
-						newFrame._box._x1 += 8;
-						newFrame._box._x2 += 8;
+						f132_blitToBitmap(L0092_puc_Bitmap, _g296_bitmapViewport, blitFrame._box, *inscrString++ << 3, 0, k144_byteWidth, k112_byteWidthViewport, k10_ColorFlesh, 8, k136_heightViewport);
+						blitFrame._box._x1 += 8;
+						blitFrame._box._x2 += 8;
 					}
-				} while (*parseString++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
+				} while (*inscrString++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
 				return isAlcove;
 			}
-			nativeBitmapIndex++;
-			Box tmpBox(coordinateSet);
-			_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn] = tmpBox;
-
+			ornNativeBitmapIndex++;
+			{
+				Box tmpBox(ornCoordSet);
+				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn] = tmpBox;
+			}
 			_vm->_dungeonMan->_g286_isFacingAlcove = isAlcove;
 			_vm->_dungeonMan->_g287_isFacingViAltar =
 				(wallOrnamentIndex == _g266_currMapViAltarIndex);
 			_vm->_dungeonMan->_g288_isFacingFountain = false;
-			for (int i = 0; i < k1_FountainOrnCount; i++) {
-				if (_g268_currMapFountainOrnIndices[i] == wallOrnamentIndex) {
+			for (int16 idx = 0; idx < k1_FountainOrnCount; idx++) {
+				if (_g268_currMapFountainOrnIndices[idx] == wallOrnamentIndex) {
 					_vm->_dungeonMan->_g288_isFacingFountain = true;
 					break;
 				}
 			}
 		}
-		blitBitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+		ornBlitBitmap = f489_getNativeBitmapOrGraphic(ornNativeBitmapIndex);
 		if (viewWallIndex == k11_ViewWall_D1R_LEFT) {
-			f99_copyBitmapAndFlipHorizontal(blitBitmap, _g74_tmpBitmap, coordinateSet[4], coordinateSet[5]);
-			blitBitmap = _g74_tmpBitmap;
+			f99_copyBitmapAndFlipHorizontal(ornBlitBitmap, _g74_tmpBitmap, ornCoordSet[4], ornCoordSet[5]);
+			ornBlitBitmap = _g74_tmpBitmap;
 		}
-		blitX = 0;
+		blitPosX = 0;
 	} else {
-		byte *wallOrnCoordinateSet;
-		int coordinateSetOffset = 0;
+		int16 coordinateSetOffset = 0;
 		bool flipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT);
 		if (flipHorizontal)
-			wallOrnCoordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k11_ViewWall_D1R_LEFT];
+			ornBlitBitmap = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k11_ViewWall_D1R_LEFT];
 		else if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT))
-			wallOrnCoordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k10_ViewWall_D1L_RIGHT];
+			ornBlitBitmap = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k10_ViewWall_D1L_RIGHT];
 		else {
-			nativeBitmapIndex++;
-			wallOrnCoordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k12_ViewWall_D1C_FRONT];
+			ornNativeBitmapIndex++;
+			ornBlitBitmap = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k12_ViewWall_D1C_FRONT];
 			if (viewWallIndex == k7_ViewWall_D2L_FRONT)
 				coordinateSetOffset = 6;
 			else if (viewWallIndex == k9_ViewWall_D2R_FRONT)
 				coordinateSetOffset = -6;
 		}
-		blitX = (coordinateSet + coordinateSetOffset)[1] - (coordinateSet + coordinateSetOffset)[0];
+		blitPosX = (ornCoordSet + coordinateSetOffset)[1] - (ornCoordSet + coordinateSetOffset)[0];
 		if (!f491_isDerivedBitmapInCache(wallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + (wallOrnamentIndex << 2) + wallOrnDerivedBitmapIndexIncrement[viewWallIndex])) {
-			byte *shrinkBitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
-			f129_blitToBitmapShrinkWithPalChange(shrinkBitmap, f492_getDerivedBitmap(wallOrnamentIndex), wallOrnCoordinateSet[4] << 1, wallOrnCoordinateSet[5], coordinateSet[4] << 1, coordinateSet[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? _palChangesDoorButtonAndWallOrnD3 : _palChangesDoorButtonAndWallOrnD2);
+			byte *blitBitmap = f489_getNativeBitmapOrGraphic(ornNativeBitmapIndex);
+			f129_blitToBitmapShrinkWithPalChange(blitBitmap, f492_getDerivedBitmap(wallOrnamentIndex), ornBlitBitmap[4] << 1, ornBlitBitmap[5], ornCoordSet[4] << 1, ornCoordSet[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? _palChangesDoorButtonAndWallOrnD3 : _palChangesDoorButtonAndWallOrnD2);
 			f493_addDerivedBitmap(wallOrnamentIndex);
 		}
-		blitBitmap = f492_getDerivedBitmap(wallOrnamentIndex);
+		ornBlitBitmap = f492_getDerivedBitmap(wallOrnamentIndex);
 		if (flipHorizontal) {
-			f99_copyBitmapAndFlipHorizontal(blitBitmap, _g74_tmpBitmap, coordinateSet[4], coordinateSet[5]);
-			blitBitmap = _g74_tmpBitmap;
-			blitX = 15 - (blitX & 0x000F);
-		} else if (viewWallIndex == k7_ViewWall_D2L_FRONT)
-			blitX -= coordinateSet[1] - coordinateSet[0];
+			f99_copyBitmapAndFlipHorizontal(ornBlitBitmap, _g74_tmpBitmap, ornCoordSet[4], ornCoordSet[5]);
+			ornBlitBitmap = _g74_tmpBitmap;
+			blitPosX = 15 - (blitPosX & 0x000F);
+		} else if (viewWallIndex == k7_ViewWall_D2L_FRONT) 
+			blitPosX -= ornCoordSet[1] - ornCoordSet[0];
 		else
-			blitX = 0;
+			blitPosX = 0;
 	}
-
 	byte byteFrame[6];
 	if (isInscription) {
-		byte *oldCoordSet = coordinateSet;
-		byte *parseString = inscriptionString;
+		byte *blitBitmap = ornCoordSet;
+		byte *inscrString2 = inscriptionString;
 		int16 unreadableTextLineCount = 0;
 		do {
-			while (*parseString < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
-				parseString++;
+			while (*inscrString2 < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
+				inscrString2++;
 			}
 			unreadableTextLineCount++;
-		} while (*parseString++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
-		coordinateSet = oldCoordSet;
+		} while (*inscrString2++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
+		ornCoordSet = blitBitmap;
 		if (unreadableTextLineCount < 4) {
 			for (uint16 i = 0; i < 6; ++i)
-				byteFrame[i] = coordinateSet[i];
-			coordinateSet = byteFrame;
-			coordinateSet[3] = unreadableInscriptionBoxY2[wallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
+				byteFrame[i] = ornCoordSet[i];
+			ornCoordSet = byteFrame;
+			ornCoordSet[3] = unreadableInscriptionBoxY2[wallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1];
 		}
 	}
 
-	Box tmpBox(coordinateSet);
-	f132_blitToBitmap(blitBitmap, _g296_bitmapViewport, tmpBox, blitX, 0,
-					  coordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, coordinateSet[5], k136_heightViewport);
+	Box tmpBox(ornCoordSet);
+	f132_blitToBitmap(ornBlitBitmap, _g296_bitmapViewport, tmpBox,
+		blitPosX, 0,
+		ornCoordSet[4], k112_byteWidthViewport, k10_ColorFlesh, ornCoordSet[5], k136_heightViewport);
 
 	if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
 		f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), _g296_bitmapViewport, boxChampionPortraitOnWall,
 			(_g289_championPortraitOrdinal & 0x0007) << 5, (_g289_championPortraitOrdinal >> 3) * 29,
-						  k128_byteWidth, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); /* A portrait is 32x29 pixels */
+			k128_byteWidth, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); /* A portrait is 32x29 pixels */
 	}
 
 	return isAlcove;
 }
 
-
 void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
 													  int16 srcPixelWidth, int16 srcHeight,
 													  int16 destPixelWidth, int16 destHeight, byte *palChange) {
@@ -2758,7 +2756,7 @@ void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *des
 	}
 }
 
-byte* DisplayMan::f489_getNativeBitmapOrGraphic(uint16 index) {
+byte *DisplayMan::f489_getNativeBitmapOrGraphic(uint16 index) {
 	return _bitmaps[index];
 }
 
@@ -2771,7 +2769,7 @@ uint32 DisplayMan::getCompressedDataSize(uint16 index) {
 }
 
 void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) {
-	byte* bitmapMask = nullptr;
+	byte *bitmapMask = nullptr;
 
 	if (fieldAspect->_mask != kMaskFieldAspectNoMask) {
 		bitmapMask = _g74_tmpBitmap;
@@ -2820,7 +2818,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 #define AL_4_explosionAspectIndex L0127_i_Multiple
 	ObjectAspect* objectAspect;
 	uint32 remainingViewCellOrdinalsToProcess;
-	byte* coordinateSet;
+	byte *coordinateSet;
 	int16 derivedBitmapIndex = -1;
 	bool L0135_B_DrawAlcoveObjects;
 	int16 byteWidth;


Commit: 6aabe84bf6d117a9e9523eaf664cfb2fd2e04fc1
    https://github.com/scummvm/scummvm/commit/6aabe84bf6d117a9e9523eaf664cfb2fd2e04fc1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Complete f437_STARTEND_drawTittle

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/gfx.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 2003ace..f71627b 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -286,7 +286,9 @@ void DMEngine::f463_initializeGame() {
 
 	_sound->f503_loadSounds(); // @ F0506_AMIGA_AllocateData
 
-	f437_STARTEND_drawTittle();
+	if (!ConfMan.hasKey("save_slot")) // skip drawing title if loading from launcher
+		f437_STARTEND_drawTittle();
+
 	_textMan->f54_textInitialize();
 	_objectMan->loadObjectNames();
 	_eventMan->initMouse();
@@ -324,7 +326,6 @@ void DMEngine::f463_initializeGame() {
 void DMEngine::f448_initMemoryManager() {
 	static uint16 palSwoosh[16] = {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}; // @ K0057_aui_Palette_Swoosh
 
-	warning(false, "STUB METHOD: f448_initMemoryManager");
 	_displayMan->f508_buildPaletteChangeCopperList(palSwoosh, palSwoosh);
 	for (uint16 i = 0; i < 16; ++i) {
 		_displayMan->_g347_paletteTopAndBottomScreen[i] = _displayMan->_palDungeonView[0][i];
@@ -864,6 +865,83 @@ void DMEngine::f438_STARTEND_OpenEntranceDoors() {
 	_savedScreenForOpenEntranceDoors = nullptr;
 }
 
+void DMEngine::f437_STARTEND_drawTittle() {
+	static Box G0003_s_Graphic562_Box_Title_StrikesBack_Destination(0, 319, 118, 174);
+	static Box G0004_s_Graphic562_Box_Title_StrikesBack_Source(0, 319, 0, 56);
+	static Box G0005_s_Graphic562_Box_Title_Presents(0, 319, 90, 105);
+	static Box K0078_s_Box_Title_Dungeon_Chaos(0, 319, 0, 79);
+
+	int16 L1380_i_Counter;
+	uint16 L1381_ui_DestinationHeight;
+	int16 L1382_i_DestinationPixelWidth;
+	byte *L1383_l_Bitmap_TitleSteps;
+	byte* L1384_puc_Bitmap_Title;
+	byte* L1387_apuc_Bitmap_ShrinkedTitle[20]; /* Only the first 18 entries are actually used */
+	byte* L1389_puc_Bitmap_Master_StrikesBack;
+	byte* L1761_puc_Bitmap_Dungeon_Chaos; /* Unreferenced on Atari ST */
+	int16 L1391_aai_Coordinates[20][5]; /* Only the first 18 entries are actually used */
+	uint16 L1392_aui_Palette[16];
+
+
+	_displayMan->_g578_useByteBoxCoordinates = false;
+
+	byte *alloactedMem = L1383_l_Bitmap_TitleSteps = new byte[145600 * 2];
+
+	L1384_puc_Bitmap_Title = L1383_l_Bitmap_TitleSteps;
+	_displayMan->f466_loadIntoBitmap(k1_titleGraphicsIndice, L1383_l_Bitmap_TitleSteps);
+
+	L1383_l_Bitmap_TitleSteps += 320 * 200;
+	for (uint16 i = 0; i < 16; ++i)
+		L1392_aui_Palette[i] = D01_RGB_DARK_BLUE;
+
+	_displayMan->f436_STARTEND_FadeToPalette(L1392_aui_Palette);
+	_displayMan->fillScreen(k0_ColorBlack);
+	_displayMan->f132_blitToBitmap(L1384_puc_Bitmap_Title, _displayMan->_g348_bitmapScreen, G0005_s_Graphic562_Box_Title_Presents, 0, 137, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, k200_heightScreen, k200_heightScreen);
+	L1392_aui_Palette[15] = D09_RGB_WHITE;
+	_displayMan->f436_STARTEND_FadeToPalette(L1392_aui_Palette);
+	_displayMan->f132_blitToBitmap(L1384_puc_Bitmap_Title, L1389_puc_Bitmap_Master_StrikesBack = L1383_l_Bitmap_TitleSteps, G0004_s_Graphic562_Box_Title_StrikesBack_Source, 0, 80, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 57);
+	L1383_l_Bitmap_TitleSteps += 320 * 57;
+	_displayMan->f132_blitToBitmap(L1384_puc_Bitmap_Title, L1761_puc_Bitmap_Dungeon_Chaos = L1383_l_Bitmap_TitleSteps, K0078_s_Box_Title_Dungeon_Chaos, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 80);
+	L1383_l_Bitmap_TitleSteps += 320 * 80;
+	L1384_puc_Bitmap_Title = L1761_puc_Bitmap_Dungeon_Chaos;
+	L1381_ui_DestinationHeight = 12;
+	L1382_i_DestinationPixelWidth = 48;
+	for (L1380_i_Counter = 0; L1380_i_Counter < 18; L1380_i_Counter++) {
+		L1387_apuc_Bitmap_ShrinkedTitle[L1380_i_Counter] = L1383_l_Bitmap_TitleSteps;
+		_displayMan->f129_blitToBitmapShrinkWithPalChange(L1384_puc_Bitmap_Title, L1383_l_Bitmap_TitleSteps, 320, 80, L1382_i_DestinationPixelWidth, L1381_ui_DestinationHeight, _displayMan->_palChangesNoChanges);
+		L1391_aai_Coordinates[L1380_i_Counter][1] = (L1391_aai_Coordinates[L1380_i_Counter][0] = (320 - L1382_i_DestinationPixelWidth) / 2) + L1382_i_DestinationPixelWidth - 1;
+		L1391_aai_Coordinates[L1380_i_Counter][3] = (L1391_aai_Coordinates[L1380_i_Counter][2] = ((int)(160 - L1381_ui_DestinationHeight)) / 2) + L1381_ui_DestinationHeight - 1;
+		L1383_l_Bitmap_TitleSteps += (L1391_aai_Coordinates[L1380_i_Counter][4] = ((L1382_i_DestinationPixelWidth + 15) / 16) * 8) * L1381_ui_DestinationHeight;
+		L1381_ui_DestinationHeight += 4;
+		L1382_i_DestinationPixelWidth += 16;
+	}
+	L1392_aui_Palette[15] = D01_RGB_DARK_BLUE;
+	_displayMan->f436_STARTEND_FadeToPalette(L1392_aui_Palette);
+	_displayMan->fillScreen(k0_ColorBlack);
+	L1392_aui_Palette[3] = D05_RGB_DARK_GOLD;
+	L1392_aui_Palette[4] = D02_RGB_LIGHT_BROWN;
+	L1392_aui_Palette[5] = D06_RGB_GOLD;
+	L1392_aui_Palette[6] = D04_RGB_LIGHTER_BROWN;
+	L1392_aui_Palette[8] = D08_RGB_YELLOW;
+	L1392_aui_Palette[15] = D07_RGB_RED;
+	L1392_aui_Palette[10] = D01_RGB_DARK_BLUE;
+	L1392_aui_Palette[12] = D01_RGB_DARK_BLUE;
+	_displayMan->f436_STARTEND_FadeToPalette(L1392_aui_Palette);
+	f22_delay(1);
+	for (L1380_i_Counter = 0; L1380_i_Counter < 18; L1380_i_Counter++) {
+		f22_delay(2);
+		Box box(L1391_aai_Coordinates[L1380_i_Counter]);
+		_displayMan->f132_blitToBitmap(L1387_apuc_Bitmap_ShrinkedTitle[L1380_i_Counter], _displayMan->_g348_bitmapScreen, box, 0, 0, L1391_aai_Coordinates[L1380_i_Counter][4], k160_byteWidthScreen, kM1_ColorNoTransparency, L1391_aai_Coordinates[L1380_i_Counter][3] - L1391_aai_Coordinates[L1380_i_Counter][2] + 1, k200_heightScreen);
+	}
+	f22_delay(25L);
+	_displayMan->f132_blitToBitmap(L1389_puc_Bitmap_Master_StrikesBack, _displayMan->_g348_bitmapScreen, G0003_s_Graphic562_Box_Title_StrikesBack_Destination, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, k0_ColorBlack, 57, k200_heightScreen);
+	L1392_aui_Palette[10] = D00_RGB_BLACK;
+	L1392_aui_Palette[12] = D07_RGB_RED;
+	_displayMan->f436_STARTEND_FadeToPalette(L1392_aui_Palette);
+	delete[] alloactedMem;
+	f22_delay(75L);
+}
+
 void DMEngine::f442_SARTEND_processCommand202_entranceDrawCredits() {
 	_eventMan->f78_showMouse();
 	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index d30727b..d90943b 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -234,7 +234,7 @@ public:
 	void f444_endGame(bool doNotDrawCreditsOnly); // @ F0444_STARTEND_Endgame
 
 	void f438_STARTEND_OpenEntranceDoors(); // @ F0438_STARTEND_OpenEntranceDoors
-	void f437_STARTEND_drawTittle() { warning(false, "STUB METHOD: f437_STARTEND_drawTittle"); }// @ F0437_STARTEND_DrawTitle
+	void f437_STARTEND_drawTittle(); // @ F0437_STARTEND_DrawTitle
 	void f442_SARTEND_processCommand202_entranceDrawCredits();
 	void f446_STARTEND_fuseSequnce(); // @ F0446_STARTEND_FuseSequence
 	void f445_STARTEND_fuseSequenceUpdate(); // @ F0445_STARTEND_FuseSequenceUpdate
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index d089d74..496abd4 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -241,6 +241,7 @@ enum ViewCell {
 
 enum GraphicIndice {
 	k0_dialogBoxGraphicIndice = 0, // @ C000_GRAPHIC_DIALOG_BOX
+	k1_titleGraphicsIndice = 1, // @ C001_GRAPHIC_TITLE
 	k2_entranceLeftDoorGraphicIndice = 2, // @ C002_GRAPHIC_ENTRANCE_LEFT_DOOR
 	k3_entranceRightDoorGraphicIndice = 3, // @ C003_GRAPHIC_ENTRANCE_RIGHT_DOOR
 	k4_entranceGraphicIndice = 4, // @ C004_GRAPHIC_ENTRANCE
@@ -317,7 +318,6 @@ enum GraphicIndice {
 	k557_FontGraphicIndice = 557 // @ C557_GRAPHIC_FONT 
 };
 
-extern byte g17_PalChangesNoChanges[16];
 
 // in all cases, where a function takes a Box, it expects it to contain inclusive boundaries
 class Box {


Commit: 80f2199151d2a005bbae64e9744477a5e52bfc52
    https://github.com/scummvm/scummvm/commit/80f2199151d2a005bbae64e9744477a5e52bfc52
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Clear check some warnings, complete minor functions

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.cpp
    engines/dm/inventory.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 9651db6..69efb41 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -2216,8 +2216,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		strcat(_vm->_g353_stringBuildBuffer, "/");
 		maxLoad = (f309_getMaximumLoad(curChampion) + 5) / 10;
 		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, true, 3).c_str());
-		warning(false, "Possibly wrong localization");
-		strcat(_vm->_g353_stringBuildBuffer, " KG"); // this line
+		strcat(_vm->_g353_stringBuildBuffer, " KG");
 		_vm->_textMan->f52_printToViewport(148, 132, loadColor, _vm->_g353_stringBuildBuffer);
 		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index f71627b..fa35035 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -427,14 +427,6 @@ Common::Error DMEngine::run() {
 }
 
 void DMEngine::f2_gameloop() {
-	//HACK: Remove this block to get real starting position in the Hall of Champions
-	if (_g298_newGame) {
-		warning(false, "DUMMY CODE: SETTING PARTY POS AND DIRECTION");
-		_dungeonMan->_g306_partyMapX = 9;
-		_dungeonMan->_g307_partyMapY = 9;
-		_dungeonMan->_g308_partyDir = kDirWest;
-	}
-
 	_canLoadFromGMM = true;
 	_g318_waitForInputMaxVerticalBlankCount = 10;
 	while (true) {
@@ -471,8 +463,7 @@ void DMEngine::f2_gameloop() {
 
 		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
 			Box box(0, 223, 0, 135);
-			warning(false, "DUMMY CODE: clearing screen to black");
-			_displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // dummy code
+			_displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // (possibly dummy code)
 			_displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
 			if (_g325_setMousePointerToObjectInMainLoop) {
 				_g325_setMousePointerToObjectInMainLoop = false;
@@ -818,7 +809,6 @@ void DMEngine::f439_drawEntrance() {
 	// note, a global variable is used here in the original
 	_displayMan->f466_loadIntoBitmap(k4_entranceGraphicIndice, _displayMan->_g348_bitmapScreen);
 	_displayMan->f128_drawDungeon(kDirSouth, 2, 0);
-	warning(false, "IGNORED CODE: G0324_B_DrawViewportRequested = false;");
 
 	if (!_savedScreenForOpenEntranceDoors)
 		_savedScreenForOpenEntranceDoors = new byte[k200_heightScreen * k160_byteWidthScreen * 2];
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index f6b9b07..f9ce68b 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -314,6 +314,7 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 	warning(false, "_g587_hideMousePointerRequestCount should start with value 1");
 	_g587_hideMousePointerRequestCount = 0;
 	_g558_mouseButtonStatus = 0;
+	_highlightScreenBox.setToZero();
 }
 
 EventManager::~EventManager() {
@@ -1556,4 +1557,18 @@ void EventManager::f541_waitForMouseOrKeyActivity() {
 		_vm->_displayMan->updateScreen();
 	}
 }
+
+void EventManager::f362_commandHighlightBoxEnable(int16 x1, int16 x2, int16 y1, int16 y2) {
+	_highlightScreenBox = Box(x1, x2, y1, y2);
+	f6_highlightScreenBox(x1, x2, y1, y2);
+	_g341_highlightBoxEnabled = true;
+}
+
+void EventManager::f363_highlightBoxDisable() {
+	if (_g341_highlightBoxEnabled == true) {
+		f6_highlightScreenBox(_highlightScreenBox._x1, _highlightScreenBox._x2, _highlightScreenBox._y1, _highlightScreenBox._y2);
+		_g341_highlightBoxEnabled = false;
+	}
+}
+
 } // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 5206485..7dfd5ac 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -260,6 +260,7 @@ class EventManager {
 	bool f375_processType80_clickDungeonView_isLeaderHandObjThrown(int16 posX, int16 posY); // @ F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown
 	void setMousePointerFromSpriteData(byte* mouseSprite);
 
+	Box _highlightScreenBox; // @ G0336_i_HighlightBoxX1
 public:
 	explicit EventManager(DMEngine *vm);
 	~EventManager();
@@ -319,8 +320,8 @@ public:
 	void f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY); // @ F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE
 	void f544_resetPressingEyeOrMouth(); // @ F0544_INPUT_ResetPressingEyeOrMouth
 	void f541_waitForMouseOrKeyActivity(); // @ F0541_INPUT_WaitForMouseOrKeyboardActivity
-	void f362_commandHighlightBoxEnable(int16 x1, int16 x2, int16 y1, int16 y2) { warning(false, "STUB METHOD: f362_commandHighlightBoxEnable"); }// @ F0362_COMMAND_HighlightBoxEnable
-	void f363_highlightBoxDisable() { warning(false, "STUB METHOD: f363_highlightBoxDisable"); } // @ F0363_COMMAND_HighlightBoxDisable
+	void f362_commandHighlightBoxEnable(int16 x1, int16 x2, int16 y1, int16 y2); // @ F0362_COMMAND_HighlightBoxEnable
+	void f363_highlightBoxDisable(); // @ F0363_COMMAND_HighlightBoxDisable
 	void f6_highlightScreenBox(int16 x1, int16 x2, int16 y1, int16 y2) { warning(false, "STUB METHOD: f6_highlightScreenBox"); } // @  F0006_MAIN_HighlightScreenBox
 };
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index e6996d3..44b1cc1 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2147,7 +2147,8 @@ void DisplayMan::f128_drawDungeon(Direction dir, int16 posX, int16 posY) {
 }
 
 void DisplayMan::f98_drawFloorAndCeiling() {
-	warning(false, "f98_drawFloorAndCeiling doesn't do anything");
+	Box box(0, 223, 0, 36);
+	f135_fillBoxBitmap(_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport);
 	_g297_drawFloorAndCeilingRequested = false;
 }
 
@@ -3735,9 +3736,7 @@ byte* DisplayMan::f492_getDerivedBitmap(int16 derivedBitmapIndex) {
 	return _g638_derivedBitmaps[derivedBitmapIndex];
 }
 
-void DisplayMan::f493_addDerivedBitmap(int16 derivedBitmapIndex) {
-	warning(false, "f493_addDerivedBitmap DOES NOTHING");
-}
+void DisplayMan::f493_addDerivedBitmap(int16 derivedBitmapIndex) {}
 
 void DisplayMan::f480_releaseBlock(uint16 index) {
 	delete[] _g638_derivedBitmaps[index];
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index d19f47c..f715227 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -246,8 +246,7 @@ void InventoryMan::f346_drawPanelResurrectReincarnate() {
 }
 
 void InventoryMan::f347_drawPanel() {
-	warning(false, "possible reintroduction of BUG0_48");
-	f334_closeChest(); // possibility of BUG0_48
+	f334_closeChest();
 
 	ChampionMan &cm = *_vm->_championMan;
 	if (cm._g299_candidateChampionOrdinal) {


Commit: a5b8085c48f11dde20e090b063c3c9558d5f6c66
    https://github.com/scummvm/scummvm/commit/a5b8085c48f11dde20e090b063c3c9558d5f6c66
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix regression (pressure plate), fix compilation

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/objectman.cpp
    engines/dm/projexpl.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 69efb41..6e92915 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1282,7 +1282,7 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex)
 	if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none))
 		return;
 
-	if ((leaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & gSlotMasks[slotIndex])))
+	if ((leaderHandObject != Thing::_none) && (!(_vm->_dungeonMan->g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & gSlotMasks[slotIndex])))
 		return;
 
 	_vm->_eventMan->f78_showMouse();
@@ -1928,7 +1928,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 	while (curThing != Thing::_endOfList) {
 		ThingType thingType = curThing.getType();
 		if ((thingType > k3_SensorThingType) && (curThing.getCell() == championObjectsCell)) {
-			int16 objectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(curThing)]._allowedSlots;
+			int16 objectAllowedSlots = _vm->_dungeonMan->g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(curThing)]._allowedSlots;
 			uint16 curSlotIndex;
 			switch (thingType) {
 			case k6_ArmourThingType: {
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 7b8d69d..b0516ba 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -38,189 +38,6 @@
 
 namespace DM {
 
-ObjectInfo g237_ObjectInfo[180] = { // @ G0237_as_Graphic559_ObjectInfo
-/* { Type, ObjectAspectIndex, ActionSetIndex, AllowedSlots } */
-	ObjectInfo(30,  1,  0, 0x0500),   /* COMPASS        Pouch/Chest */
-	ObjectInfo(144,  0,  0, 0x0200),   /* COMPASS        Hands */
-	ObjectInfo(148, 67,  0, 0x0500),   /* COMPASS        Pouch/Chest */
-	ObjectInfo(149, 67,  0, 0x0500),   /* COMPASS        Pouch/Chest */
-	ObjectInfo(150, 67,  0, 0x0500),   /* TORCH          Pouch/Chest */
-	ObjectInfo(151, 67, 42, 0x0500),   /* TORCH          Pouch/Chest */
-	ObjectInfo(152, 67,  0, 0x0500),   /* TORCH          Pouch/Chest */
-	ObjectInfo(153, 67,  0, 0x0500),   /* TORCH          Pouch/Chest */
-	ObjectInfo(154,  2,  0, 0x0501),   /* WATERSKIN      Mouth/Pouch/Chest */
-	ObjectInfo(155,  2,  0, 0x0501),   /* WATER          Mouth/Pouch/Chest */
-	ObjectInfo(156,  2,  0, 0x0501),   /* JEWEL SYMAL    Mouth/Pouch/Chest */
-	ObjectInfo(157,  2,  0, 0x0501),   /* JEWEL SYMAL    Mouth/Pouch/Chest */
-	ObjectInfo(158,  2,  0, 0x0501),   /* ILLUMULET      Mouth/Pouch/Chest */
-	ObjectInfo(159,  2,  0, 0x0501),   /* ILLUMULET      Mouth/Pouch/Chest */
-	ObjectInfo(160,  2,  0, 0x0501),   /* FLAMITT        Mouth/Pouch/Chest */
-	ObjectInfo(161,  2,  0, 0x0501),   /* FLAMITT        Mouth/Pouch/Chest */
-	ObjectInfo(162,  2,  0, 0x0501),   /* EYE OF TIME    Mouth/Pouch/Chest */
-	ObjectInfo(163,  2,  0, 0x0501),   /* EYE OF TIME    Mouth/Pouch/Chest */
-	ObjectInfo(164, 68,  0, 0x0500),   /* STORMRING      Pouch/Chest */
-	ObjectInfo(165, 68,  0, 0x0500),   /* STORMRING      Pouch/Chest */
-	ObjectInfo(166, 68,  0, 0x0500),   /* STAFF OF CLAWS Pouch/Chest */
-	ObjectInfo(167, 68, 42, 0x0500),   /* STAFF OF CLAWS Pouch/Chest */
-	ObjectInfo(195, 80,  0, 0x0500),   /* STAFF OF CLAWS Pouch/Chest */
-	ObjectInfo(16, 38, 43, 0x0500),   /* BOLT BLADE     Pouch/Chest */
-	ObjectInfo(18, 38,  7, 0x0500),   /* BOLT BLADE     Pouch/Chest */
-	ObjectInfo(4, 35,  5, 0x0400),   /* FURY           Chest */
-	ObjectInfo(14, 37,  6, 0x0400),   /* FURY           Chest */
-	ObjectInfo(20, 11,  8, 0x0040),   /* THE FIRESTAFF  Quiver 1 */
-	ObjectInfo(23, 12,  9, 0x0040),   /* THE FIRESTAFF  Quiver 1 */
-	ObjectInfo(25, 12, 10, 0x0040),   /* THE FIRESTAFF  Quiver 1 */
-	ObjectInfo(27, 39, 11, 0x0040),   /* OPEN SCROLL    Quiver 1 */
-	ObjectInfo(32, 17, 12, 0x05C0),   /* SCROLL         Quiver 1/Quiver 2/Pouch/Chest */
-	ObjectInfo(33, 12, 13, 0x0040),   /* DAGGER         Quiver 1 */
-	ObjectInfo(34, 12, 13, 0x0040),   /* FALCHION       Quiver 1 */
-	ObjectInfo(35, 12, 14, 0x0040),   /* SWORD          Quiver 1 */
-	ObjectInfo(36, 12, 15, 0x0040),   /* RAPIER         Quiver 1 */
-	ObjectInfo(37, 12, 15, 0x0040),   /* SABRE          Quiver 1 */
-	ObjectInfo(38, 12, 16, 0x0040),   /* SAMURAI SWORD  Quiver 1 */
-	ObjectInfo(39, 12, 17, 0x0040),   /* DELTA          Quiver 1 */
-	ObjectInfo(40, 42, 18, 0x0040),   /* DIAMOND EDGE   Quiver 1 */
-	ObjectInfo(41, 12, 19, 0x0040),   /* VORPAL BLADE   Quiver 1 */
-	ObjectInfo(42, 13, 20, 0x0040),   /* THE INQUISITOR Quiver 1 */
-	ObjectInfo(43, 13, 21, 0x0040),   /* AXE            Quiver 1 */
-	ObjectInfo(44, 21, 22, 0x0040),   /* HARDCLEAVE     Quiver 1 */
-	ObjectInfo(45, 21, 22, 0x0040),   /* MACE           Quiver 1 */
-	ObjectInfo(46, 33, 23, 0x0440),   /* MACE OF ORDER  Quiver 1/Chest */
-	ObjectInfo(47, 43, 24, 0x0040),   /* MORNINGSTAR    Quiver 1 */
-	ObjectInfo(48, 44, 24, 0x0040),   /* CLUB           Quiver 1 */
-	ObjectInfo(49, 14, 27, 0x0040),   /* STONE CLUB     Quiver 1 */
-	ObjectInfo(50, 45, 27, 0x0040),   /* BOW            Quiver 1 */
-	ObjectInfo(51, 16, 26, 0x05C0),   /* CROSSBOW       Quiver 1/Quiver 2/Pouch/Chest */
-	ObjectInfo(52, 46, 26, 0x05C0),   /* ARROW          Quiver 1/Quiver 2/Pouch/Chest */
-	ObjectInfo(53, 11, 27, 0x0440),   /* SLAYER         Quiver 1/Chest */
-	ObjectInfo(54, 47, 42, 0x05C0),   /* SLING          Quiver 1/Quiver 2/Pouch/Chest */
-	ObjectInfo(55, 48, 40, 0x05C0),   /* ROCK           Quiver 1/Quiver 2/Pouch/Chest */
-	ObjectInfo(56, 49, 42, 0x05C0),   /* POISON DART    Quiver 1/Quiver 2/Pouch/Chest */
-	ObjectInfo(57, 50,  5, 0x0040),   /* THROWING STAR  Quiver 1 */
-	ObjectInfo(58, 11,  5, 0x0040),   /* STICK          Quiver 1 */
-	ObjectInfo(59, 31, 28, 0x0540),   /* STAFF          Quiver 1/Pouch/Chest */
-	ObjectInfo(60, 31, 29, 0x0540),   /* WAND           Quiver 1/Pouch/Chest */
-	ObjectInfo(61, 11, 30, 0x0040),   /* TEOWAND        Quiver 1 */
-	ObjectInfo(62, 11, 31, 0x0040),   /* YEW STAFF      Quiver 1 */
-	ObjectInfo(63, 11, 32, 0x0040),   /* STAFF OF MANAR Quiver 1 Atari ST Version 1.0 1987-12-08: ObjectAspectIndex = 35 */
-	ObjectInfo(64, 51, 33, 0x0040),   /* SNAKE STAFF    Quiver 1 */
-	ObjectInfo(65, 32,  5, 0x0440),   /* THE CONDUIT    Quiver 1/Chest */
-	ObjectInfo(66, 30, 35, 0x0040),   /* DRAGON SPIT    Quiver 1 */
-	ObjectInfo(135, 65, 36, 0x0440),   /* SCEPTRE OF LYF Quiver 1/Chest */
-	ObjectInfo(143, 45, 27, 0x0040),   /* ROBE           Quiver 1 */
-	ObjectInfo(28, 82,  1, 0x0040),   /* FINE ROBE      Quiver 1 */
-	ObjectInfo(80, 23,  0, 0x040C),   /* KIRTLE         Neck/Torso/Chest */
-	ObjectInfo(81, 23,  0, 0x040C),   /* SILK SHIRT     Neck/Torso/Chest */
-	ObjectInfo(82, 23,  0, 0x0410),   /* ELVEN DOUBLET  Legs/Chest */
-	ObjectInfo(112, 55,  0, 0x0420),   /* LEATHER JERKIN Feet/Chest */
-	ObjectInfo(114,  8,  0, 0x0420),   /* TUNIC          Feet/Chest */
-	ObjectInfo(67, 24,  0, 0x0408),   /* GHI            Torso/Chest */
-	ObjectInfo(83, 24,  0, 0x0410),   /* MAIL AKETON    Legs/Chest */
-	ObjectInfo(68, 24,  0, 0x0408),   /* MITHRAL AKETON Torso/Chest */
-	ObjectInfo(84, 24,  0, 0x0410),   /* TORSO PLATE    Legs/Chest */
-	ObjectInfo(69, 69,  0, 0x0408),   /* PLATE OF LYTE  Torso/Chest */
-	ObjectInfo(70, 24,  0, 0x0408),   /* PLATE OF DARC  Torso/Chest */
-	ObjectInfo(85, 24,  0, 0x0410),   /* CAPE           Legs/Chest */
-	ObjectInfo(86, 69,  0, 0x0410),   /* CLOAK OF NIGHT Legs/Chest */
-	ObjectInfo(71,  7,  0, 0x0408),   /* BARBARIAN HIDE Torso/Chest */
-	ObjectInfo(87,  7,  0, 0x0410),   /* ROBE           Legs/Chest */
-	ObjectInfo(119, 57,  0, 0x0420),   /* FINE ROBE      Feet/Chest */
-	ObjectInfo(72, 23,  0, 0x0408),   /* TABARD         Torso/Chest */
-	ObjectInfo(88, 23,  0, 0x0410),   /* GUNNA          Legs/Chest */
-	ObjectInfo(113, 29,  0, 0x0420),   /* ELVEN HUKE     Feet/Chest */
-	ObjectInfo(89, 69,  0, 0x0410),   /* LEATHER PANTS  Legs/Chest */
-	ObjectInfo(73, 69,  0, 0x0408),   /* BLUE PANTS     Torso/Chest */
-	ObjectInfo(74, 24,  0, 0x0408),   /* GHI TROUSERS   Torso/Chest */
-	ObjectInfo(90, 24,  0, 0x0410),   /* LEG MAIL       Legs/Chest */
-	ObjectInfo(103, 53,  0, 0x0402),   /* MITHRAL MAIL   Head/Chest */
-	ObjectInfo(104, 53,  0, 0x0402),   /* LEG PLATE      Head/Chest */
-	ObjectInfo(96,  9,  0, 0x0402),   /* POLEYN OF LYTE Head/Chest */
-	ObjectInfo(97,  9,  0, 0x0402),   /* POLEYN OF DARC Head/Chest */
-	ObjectInfo(98,  9,  0, 0x0402),   /* BEZERKER HELM  Head/Chest */
-	ObjectInfo(105, 54, 41, 0x0400),   /* HELMET         Chest */
-	ObjectInfo(106, 54, 41, 0x0200),   /* BASINET        Hands */
-	ObjectInfo(108, 10, 41, 0x0200),   /* CASQUE 'N COIF Hands */
-	ObjectInfo(107, 54, 41, 0x0200),   /* ARMET          Hands */
-	ObjectInfo(75, 19,  0, 0x0408),   /* HELM OF LYTE   Torso/Chest */
-	ObjectInfo(91, 19,  0, 0x0410),   /* HELM OF DARC   Legs/Chest */
-	ObjectInfo(76, 19,  0, 0x0408),   /* CALISTA        Torso/Chest */
-	ObjectInfo(92, 19,  0, 0x0410),   /* CROWN OF NERRA Legs/Chest */
-	ObjectInfo(99,  9,  0, 0x0402),   /* BUCKLER        Head/Chest */
-	ObjectInfo(115, 19,  0, 0x0420),   /* HIDE SHIELD    Feet/Chest */
-	ObjectInfo(100, 52,  0, 0x0402),   /* SMALL SHIELD   Head/Chest */
-	ObjectInfo(77, 20,  0, 0x0008),   /* WOODEN SHIELD  Torso */
-	ObjectInfo(93, 22,  0, 0x0010),   /* LARGE SHIELD   Legs */
-	ObjectInfo(116, 56,  0, 0x0420),   /* SHIELD OF LYTE Feet/Chest */
-	ObjectInfo(109, 10, 41, 0x0200),   /* SHIELD OF DARC Hands */
-	ObjectInfo(101, 52,  0, 0x0402),   /* SANDALS        Head/Chest */
-	ObjectInfo(78, 20,  0, 0x0008),   /* SUEDE BOOTS    Torso */
-	ObjectInfo(94, 22,  0, 0x0010),   /* LEATHER BOOTS  Legs */
-	ObjectInfo(117, 56,  0, 0x0420),   /* HOSEN          Feet/Chest */
-	ObjectInfo(110, 10, 41, 0x0200),   /* FOOT PLATE     Hands */
-	ObjectInfo(102, 52,  0, 0x0402),   /* GREAVE OF LYTE Head/Chest */
-	ObjectInfo(79, 20,  0, 0x0008),   /* GREAVE OF DARC Torso */
-	ObjectInfo(95, 22,  0, 0x0010),   /* ELVEN BOOTS    Legs */
-	ObjectInfo(118, 56,  0, 0x0420),   /* GEM OF AGES    Feet/Chest */
-	ObjectInfo(111, 10, 41, 0x0200),   /* EKKHARD CROSS  Hands */
-	ObjectInfo(140, 52,  0, 0x0402),   /* MOONSTONE      Head/Chest */
-	ObjectInfo(141, 19,  0, 0x0408),   /* THE HELLION    Torso/Chest */
-	ObjectInfo(142, 22,  0, 0x0010),   /* PENDANT FERAL  Legs */
-	ObjectInfo(194, 81,  0, 0x0420),   /* COPPER COIN    Feet/Chest */
-	ObjectInfo(196, 84,  0, 0x0408),   /* SILVER COIN    Torso/Chest */
-	ObjectInfo(0, 34,  0, 0x0500),   /* GOLD COIN      Pouch/Chest */
-	ObjectInfo(8,  6,  0, 0x0501),   /* BOULDER        Mouth/Pouch/Chest */
-	ObjectInfo(10, 15,  0, 0x0504),   /* BLUE GEM       Neck/Pouch/Chest */
-	ObjectInfo(12, 15,  0, 0x0504),   /* ORANGE GEM     Neck/Pouch/Chest */
-	ObjectInfo(146, 40,  0, 0x0500),   /* GREEN GEM      Pouch/Chest */
-	ObjectInfo(147, 41,  0, 0x0400),   /* MAGICAL BOX    Chest */
-	ObjectInfo(125,  4, 37, 0x0500),   /* MAGICAL BOX    Pouch/Chest */
-	ObjectInfo(126, 83, 37, 0x0500),   /* MIRROR OF DAWN Pouch/Chest */
-	ObjectInfo(127,  4, 37, 0x0500),   /* HORN OF FEAR   Pouch/Chest */
-	ObjectInfo(176, 18,  0, 0x0500),   /* ROPE           Pouch/Chest */
-	ObjectInfo(177, 18,  0, 0x0500),   /* RABBIT'S FOOT  Pouch/Chest */
-	ObjectInfo(178, 18,  0, 0x0500),   /* CORBAMITE      Pouch/Chest */
-	ObjectInfo(179, 18,  0, 0x0500),   /* CHOKER         Pouch/Chest */
-	ObjectInfo(180, 18,  0, 0x0500),   /* DEXHELM        Pouch/Chest */
-	ObjectInfo(181, 18,  0, 0x0500),   /* FLAMEBAIN      Pouch/Chest */
-	ObjectInfo(182, 18,  0, 0x0500),   /* POWERTOWERS    Pouch/Chest */
-	ObjectInfo(183, 18,  0, 0x0500),   /* SPEEDBOW       Pouch/Chest */
-	ObjectInfo(184, 62,  0, 0x0500),   /* CHEST          Pouch/Chest */
-	ObjectInfo(185, 62,  0, 0x0500),   /* OPEN CHEST     Pouch/Chest */
-	ObjectInfo(186, 62,  0, 0x0500),   /* ASHES          Pouch/Chest */
-	ObjectInfo(187, 62,  0, 0x0500),   /* BONES          Pouch/Chest */
-	ObjectInfo(188, 62,  0, 0x0500),   /* MON POTION     Pouch/Chest */
-	ObjectInfo(189, 62,  0, 0x0500),   /* UM POTION      Pouch/Chest */
-	ObjectInfo(190, 62,  0, 0x0500),   /* DES POTION     Pouch/Chest */
-	ObjectInfo(191, 62,  0, 0x0500),   /* VEN POTION     Pouch/Chest */
-	ObjectInfo(128, 76,  0, 0x0200),   /* SAR POTION     Hands */
-	ObjectInfo(129,  3,  0, 0x0500),   /* ZO POTION      Pouch/Chest */
-	ObjectInfo(130, 60,  0, 0x0500),   /* ROS POTION     Pouch/Chest */
-	ObjectInfo(131, 61,  0, 0x0500),   /* KU POTION      Pouch/Chest */
-	ObjectInfo(168, 27,  0, 0x0501),   /* DANE POTION    Mouth/Pouch/Chest */
-	ObjectInfo(169, 28,  0, 0x0501),   /* NETA POTION    Mouth/Pouch/Chest */
-	ObjectInfo(170, 25,  0, 0x0501),   /* BRO POTION     Mouth/Pouch/Chest */
-	ObjectInfo(171, 26,  0, 0x0501),   /* MA POTION      Mouth/Pouch/Chest */
-	ObjectInfo(172, 71,  0, 0x0401),   /* YA POTION      Mouth/Chest */
-	ObjectInfo(173, 70,  0, 0x0401),   /* EE POTION      Mouth/Chest */
-	ObjectInfo(174,  5,  0, 0x0501),   /* VI POTION      Mouth/Pouch/Chest */
-	ObjectInfo(175, 66,  0, 0x0501),   /* WATER FLASK    Mouth/Pouch/Chest */
-	ObjectInfo(120, 15,  0, 0x0504),   /* KATH BOMB      Neck/Pouch/Chest */
-	ObjectInfo(121, 15,  0, 0x0504),   /* PEW BOMB       Neck/Pouch/Chest */
-	ObjectInfo(122, 58,  0, 0x0504),   /* RA BOMB        Neck/Pouch/Chest */
-	ObjectInfo(123, 59,  0, 0x0504),   /* FUL BOMB       Neck/Pouch/Chest */
-	ObjectInfo(124, 59,  0, 0x0504),   /* APPLE          Neck/Pouch/Chest */
-	ObjectInfo(132, 79, 38, 0x0500),   /* CORN           Pouch/Chest */
-	ObjectInfo(133, 63, 38, 0x0500),   /* BREAD          Pouch/Chest */
-	ObjectInfo(134, 64,  0, 0x0500),   /* CHEESE         Pouch/Chest */
-	ObjectInfo(136, 72, 39, 0x0400),   /* SCREAMER SLICE Chest */
-	ObjectInfo(137, 73,  0, 0x0500),   /* WORM ROUND     Pouch/Chest */
-	ObjectInfo(138, 74,  0, 0x0500),   /* DRUMSTICK      Pouch/Chest */
-	ObjectInfo(139, 75,  0, 0x0504),   /* DRAGON STEAK   Neck/Pouch/Chest */
-	ObjectInfo(192, 77,  0, 0x0500),   /* IRON KEY       Pouch/Chest */
-	ObjectInfo(193, 78,  0, 0x0500),   /* KEY OF B       Pouch/Chest */
-	ObjectInfo(197, 74,  0, 0x0000),   /* SOLID KEY */
-	ObjectInfo(198, 41,  0, 0x0400)}; /* SQUARE KEY     Chest */
-
 ArmourInfo g239_ArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo
 /* { Weight, Defense, Attributes, Unreferenced } */
 	ArmourInfo(3,   5, 0x01),   /* CAPE */
@@ -371,6 +188,194 @@ void DungeonMan::f150_mapCoordsAfterRelMovement(Direction dir, int16 stepsForwar
 	posY += _vm->_dirIntoStepCountNorth[dir] * stepsRight;
 }
 
+void DungeonMan::setupArrays() {
+	ObjectInfo objectInfo[180] = { // @ G0237_as_Graphic559_ObjectInfo
+		/* { Type, ObjectAspectIndex, ActionSetIndex, AllowedSlots } */
+		ObjectInfo(30,  1,  0, 0x0500),   /* COMPASS        Pouch/Chest */
+		ObjectInfo(144,  0,  0, 0x0200),   /* COMPASS        Hands */
+		ObjectInfo(148, 67,  0, 0x0500),   /* COMPASS        Pouch/Chest */
+		ObjectInfo(149, 67,  0, 0x0500),   /* COMPASS        Pouch/Chest */
+		ObjectInfo(150, 67,  0, 0x0500),   /* TORCH          Pouch/Chest */
+		ObjectInfo(151, 67, 42, 0x0500),   /* TORCH          Pouch/Chest */
+		ObjectInfo(152, 67,  0, 0x0500),   /* TORCH          Pouch/Chest */
+		ObjectInfo(153, 67,  0, 0x0500),   /* TORCH          Pouch/Chest */
+		ObjectInfo(154,  2,  0, 0x0501),   /* WATERSKIN      Mouth/Pouch/Chest */
+		ObjectInfo(155,  2,  0, 0x0501),   /* WATER          Mouth/Pouch/Chest */
+		ObjectInfo(156,  2,  0, 0x0501),   /* JEWEL SYMAL    Mouth/Pouch/Chest */
+		ObjectInfo(157,  2,  0, 0x0501),   /* JEWEL SYMAL    Mouth/Pouch/Chest */
+		ObjectInfo(158,  2,  0, 0x0501),   /* ILLUMULET      Mouth/Pouch/Chest */
+		ObjectInfo(159,  2,  0, 0x0501),   /* ILLUMULET      Mouth/Pouch/Chest */
+		ObjectInfo(160,  2,  0, 0x0501),   /* FLAMITT        Mouth/Pouch/Chest */
+		ObjectInfo(161,  2,  0, 0x0501),   /* FLAMITT        Mouth/Pouch/Chest */
+		ObjectInfo(162,  2,  0, 0x0501),   /* EYE OF TIME    Mouth/Pouch/Chest */
+		ObjectInfo(163,  2,  0, 0x0501),   /* EYE OF TIME    Mouth/Pouch/Chest */
+		ObjectInfo(164, 68,  0, 0x0500),   /* STORMRING      Pouch/Chest */
+		ObjectInfo(165, 68,  0, 0x0500),   /* STORMRING      Pouch/Chest */
+		ObjectInfo(166, 68,  0, 0x0500),   /* STAFF OF CLAWS Pouch/Chest */
+		ObjectInfo(167, 68, 42, 0x0500),   /* STAFF OF CLAWS Pouch/Chest */
+		ObjectInfo(195, 80,  0, 0x0500),   /* STAFF OF CLAWS Pouch/Chest */
+		ObjectInfo(16, 38, 43, 0x0500),   /* BOLT BLADE     Pouch/Chest */
+		ObjectInfo(18, 38,  7, 0x0500),   /* BOLT BLADE     Pouch/Chest */
+		ObjectInfo(4, 35,  5, 0x0400),   /* FURY           Chest */
+		ObjectInfo(14, 37,  6, 0x0400),   /* FURY           Chest */
+		ObjectInfo(20, 11,  8, 0x0040),   /* THE FIRESTAFF  Quiver 1 */
+		ObjectInfo(23, 12,  9, 0x0040),   /* THE FIRESTAFF  Quiver 1 */
+		ObjectInfo(25, 12, 10, 0x0040),   /* THE FIRESTAFF  Quiver 1 */
+		ObjectInfo(27, 39, 11, 0x0040),   /* OPEN SCROLL    Quiver 1 */
+		ObjectInfo(32, 17, 12, 0x05C0),   /* SCROLL         Quiver 1/Quiver 2/Pouch/Chest */
+		ObjectInfo(33, 12, 13, 0x0040),   /* DAGGER         Quiver 1 */
+		ObjectInfo(34, 12, 13, 0x0040),   /* FALCHION       Quiver 1 */
+		ObjectInfo(35, 12, 14, 0x0040),   /* SWORD          Quiver 1 */
+		ObjectInfo(36, 12, 15, 0x0040),   /* RAPIER         Quiver 1 */
+		ObjectInfo(37, 12, 15, 0x0040),   /* SABRE          Quiver 1 */
+		ObjectInfo(38, 12, 16, 0x0040),   /* SAMURAI SWORD  Quiver 1 */
+		ObjectInfo(39, 12, 17, 0x0040),   /* DELTA          Quiver 1 */
+		ObjectInfo(40, 42, 18, 0x0040),   /* DIAMOND EDGE   Quiver 1 */
+		ObjectInfo(41, 12, 19, 0x0040),   /* VORPAL BLADE   Quiver 1 */
+		ObjectInfo(42, 13, 20, 0x0040),   /* THE INQUISITOR Quiver 1 */
+		ObjectInfo(43, 13, 21, 0x0040),   /* AXE            Quiver 1 */
+		ObjectInfo(44, 21, 22, 0x0040),   /* HARDCLEAVE     Quiver 1 */
+		ObjectInfo(45, 21, 22, 0x0040),   /* MACE           Quiver 1 */
+		ObjectInfo(46, 33, 23, 0x0440),   /* MACE OF ORDER  Quiver 1/Chest */
+		ObjectInfo(47, 43, 24, 0x0040),   /* MORNINGSTAR    Quiver 1 */
+		ObjectInfo(48, 44, 24, 0x0040),   /* CLUB           Quiver 1 */
+		ObjectInfo(49, 14, 27, 0x0040),   /* STONE CLUB     Quiver 1 */
+		ObjectInfo(50, 45, 27, 0x0040),   /* BOW            Quiver 1 */
+		ObjectInfo(51, 16, 26, 0x05C0),   /* CROSSBOW       Quiver 1/Quiver 2/Pouch/Chest */
+		ObjectInfo(52, 46, 26, 0x05C0),   /* ARROW          Quiver 1/Quiver 2/Pouch/Chest */
+		ObjectInfo(53, 11, 27, 0x0440),   /* SLAYER         Quiver 1/Chest */
+		ObjectInfo(54, 47, 42, 0x05C0),   /* SLING          Quiver 1/Quiver 2/Pouch/Chest */
+		ObjectInfo(55, 48, 40, 0x05C0),   /* ROCK           Quiver 1/Quiver 2/Pouch/Chest */
+		ObjectInfo(56, 49, 42, 0x05C0),   /* POISON DART    Quiver 1/Quiver 2/Pouch/Chest */
+		ObjectInfo(57, 50,  5, 0x0040),   /* THROWING STAR  Quiver 1 */
+		ObjectInfo(58, 11,  5, 0x0040),   /* STICK          Quiver 1 */
+		ObjectInfo(59, 31, 28, 0x0540),   /* STAFF          Quiver 1/Pouch/Chest */
+		ObjectInfo(60, 31, 29, 0x0540),   /* WAND           Quiver 1/Pouch/Chest */
+		ObjectInfo(61, 11, 30, 0x0040),   /* TEOWAND        Quiver 1 */
+		ObjectInfo(62, 11, 31, 0x0040),   /* YEW STAFF      Quiver 1 */
+		ObjectInfo(63, 11, 32, 0x0040),   /* STAFF OF MANAR Quiver 1 Atari ST Version 1.0 1987-12-08: ObjectAspectIndex = 35 */
+		ObjectInfo(64, 51, 33, 0x0040),   /* SNAKE STAFF    Quiver 1 */
+		ObjectInfo(65, 32,  5, 0x0440),   /* THE CONDUIT    Quiver 1/Chest */
+		ObjectInfo(66, 30, 35, 0x0040),   /* DRAGON SPIT    Quiver 1 */
+		ObjectInfo(135, 65, 36, 0x0440),   /* SCEPTRE OF LYF Quiver 1/Chest */
+		ObjectInfo(143, 45, 27, 0x0040),   /* ROBE           Quiver 1 */
+		ObjectInfo(28, 82,  1, 0x0040),   /* FINE ROBE      Quiver 1 */
+		ObjectInfo(80, 23,  0, 0x040C),   /* KIRTLE         Neck/Torso/Chest */
+		ObjectInfo(81, 23,  0, 0x040C),   /* SILK SHIRT     Neck/Torso/Chest */
+		ObjectInfo(82, 23,  0, 0x0410),   /* ELVEN DOUBLET  Legs/Chest */
+		ObjectInfo(112, 55,  0, 0x0420),   /* LEATHER JERKIN Feet/Chest */
+		ObjectInfo(114,  8,  0, 0x0420),   /* TUNIC          Feet/Chest */
+		ObjectInfo(67, 24,  0, 0x0408),   /* GHI            Torso/Chest */
+		ObjectInfo(83, 24,  0, 0x0410),   /* MAIL AKETON    Legs/Chest */
+		ObjectInfo(68, 24,  0, 0x0408),   /* MITHRAL AKETON Torso/Chest */
+		ObjectInfo(84, 24,  0, 0x0410),   /* TORSO PLATE    Legs/Chest */
+		ObjectInfo(69, 69,  0, 0x0408),   /* PLATE OF LYTE  Torso/Chest */
+		ObjectInfo(70, 24,  0, 0x0408),   /* PLATE OF DARC  Torso/Chest */
+		ObjectInfo(85, 24,  0, 0x0410),   /* CAPE           Legs/Chest */
+		ObjectInfo(86, 69,  0, 0x0410),   /* CLOAK OF NIGHT Legs/Chest */
+		ObjectInfo(71,  7,  0, 0x0408),   /* BARBARIAN HIDE Torso/Chest */
+		ObjectInfo(87,  7,  0, 0x0410),   /* ROBE           Legs/Chest */
+		ObjectInfo(119, 57,  0, 0x0420),   /* FINE ROBE      Feet/Chest */
+		ObjectInfo(72, 23,  0, 0x0408),   /* TABARD         Torso/Chest */
+		ObjectInfo(88, 23,  0, 0x0410),   /* GUNNA          Legs/Chest */
+		ObjectInfo(113, 29,  0, 0x0420),   /* ELVEN HUKE     Feet/Chest */
+		ObjectInfo(89, 69,  0, 0x0410),   /* LEATHER PANTS  Legs/Chest */
+		ObjectInfo(73, 69,  0, 0x0408),   /* BLUE PANTS     Torso/Chest */
+		ObjectInfo(74, 24,  0, 0x0408),   /* GHI TROUSERS   Torso/Chest */
+		ObjectInfo(90, 24,  0, 0x0410),   /* LEG MAIL       Legs/Chest */
+		ObjectInfo(103, 53,  0, 0x0402),   /* MITHRAL MAIL   Head/Chest */
+		ObjectInfo(104, 53,  0, 0x0402),   /* LEG PLATE      Head/Chest */
+		ObjectInfo(96,  9,  0, 0x0402),   /* POLEYN OF LYTE Head/Chest */
+		ObjectInfo(97,  9,  0, 0x0402),   /* POLEYN OF DARC Head/Chest */
+		ObjectInfo(98,  9,  0, 0x0402),   /* BEZERKER HELM  Head/Chest */
+		ObjectInfo(105, 54, 41, 0x0400),   /* HELMET         Chest */
+		ObjectInfo(106, 54, 41, 0x0200),   /* BASINET        Hands */
+		ObjectInfo(108, 10, 41, 0x0200),   /* CASQUE 'N COIF Hands */
+		ObjectInfo(107, 54, 41, 0x0200),   /* ARMET          Hands */
+		ObjectInfo(75, 19,  0, 0x0408),   /* HELM OF LYTE   Torso/Chest */
+		ObjectInfo(91, 19,  0, 0x0410),   /* HELM OF DARC   Legs/Chest */
+		ObjectInfo(76, 19,  0, 0x0408),   /* CALISTA        Torso/Chest */
+		ObjectInfo(92, 19,  0, 0x0410),   /* CROWN OF NERRA Legs/Chest */
+		ObjectInfo(99,  9,  0, 0x0402),   /* BUCKLER        Head/Chest */
+		ObjectInfo(115, 19,  0, 0x0420),   /* HIDE SHIELD    Feet/Chest */
+		ObjectInfo(100, 52,  0, 0x0402),   /* SMALL SHIELD   Head/Chest */
+		ObjectInfo(77, 20,  0, 0x0008),   /* WOODEN SHIELD  Torso */
+		ObjectInfo(93, 22,  0, 0x0010),   /* LARGE SHIELD   Legs */
+		ObjectInfo(116, 56,  0, 0x0420),   /* SHIELD OF LYTE Feet/Chest */
+		ObjectInfo(109, 10, 41, 0x0200),   /* SHIELD OF DARC Hands */
+		ObjectInfo(101, 52,  0, 0x0402),   /* SANDALS        Head/Chest */
+		ObjectInfo(78, 20,  0, 0x0008),   /* SUEDE BOOTS    Torso */
+		ObjectInfo(94, 22,  0, 0x0010),   /* LEATHER BOOTS  Legs */
+		ObjectInfo(117, 56,  0, 0x0420),   /* HOSEN          Feet/Chest */
+		ObjectInfo(110, 10, 41, 0x0200),   /* FOOT PLATE     Hands */
+		ObjectInfo(102, 52,  0, 0x0402),   /* GREAVE OF LYTE Head/Chest */
+		ObjectInfo(79, 20,  0, 0x0008),   /* GREAVE OF DARC Torso */
+		ObjectInfo(95, 22,  0, 0x0010),   /* ELVEN BOOTS    Legs */
+		ObjectInfo(118, 56,  0, 0x0420),   /* GEM OF AGES    Feet/Chest */
+		ObjectInfo(111, 10, 41, 0x0200),   /* EKKHARD CROSS  Hands */
+		ObjectInfo(140, 52,  0, 0x0402),   /* MOONSTONE      Head/Chest */
+		ObjectInfo(141, 19,  0, 0x0408),   /* THE HELLION    Torso/Chest */
+		ObjectInfo(142, 22,  0, 0x0010),   /* PENDANT FERAL  Legs */
+		ObjectInfo(194, 81,  0, 0x0420),   /* COPPER COIN    Feet/Chest */
+		ObjectInfo(196, 84,  0, 0x0408),   /* SILVER COIN    Torso/Chest */
+		ObjectInfo(0, 34,  0, 0x0500),   /* GOLD COIN      Pouch/Chest */
+		ObjectInfo(8,  6,  0, 0x0501),   /* BOULDER        Mouth/Pouch/Chest */
+		ObjectInfo(10, 15,  0, 0x0504),   /* BLUE GEM       Neck/Pouch/Chest */
+		ObjectInfo(12, 15,  0, 0x0504),   /* ORANGE GEM     Neck/Pouch/Chest */
+		ObjectInfo(146, 40,  0, 0x0500),   /* GREEN GEM      Pouch/Chest */
+		ObjectInfo(147, 41,  0, 0x0400),   /* MAGICAL BOX    Chest */
+		ObjectInfo(125,  4, 37, 0x0500),   /* MAGICAL BOX    Pouch/Chest */
+		ObjectInfo(126, 83, 37, 0x0500),   /* MIRROR OF DAWN Pouch/Chest */
+		ObjectInfo(127,  4, 37, 0x0500),   /* HORN OF FEAR   Pouch/Chest */
+		ObjectInfo(176, 18,  0, 0x0500),   /* ROPE           Pouch/Chest */
+		ObjectInfo(177, 18,  0, 0x0500),   /* RABBIT'S FOOT  Pouch/Chest */
+		ObjectInfo(178, 18,  0, 0x0500),   /* CORBAMITE      Pouch/Chest */
+		ObjectInfo(179, 18,  0, 0x0500),   /* CHOKER         Pouch/Chest */
+		ObjectInfo(180, 18,  0, 0x0500),   /* DEXHELM        Pouch/Chest */
+		ObjectInfo(181, 18,  0, 0x0500),   /* FLAMEBAIN      Pouch/Chest */
+		ObjectInfo(182, 18,  0, 0x0500),   /* POWERTOWERS    Pouch/Chest */
+		ObjectInfo(183, 18,  0, 0x0500),   /* SPEEDBOW       Pouch/Chest */
+		ObjectInfo(184, 62,  0, 0x0500),   /* CHEST          Pouch/Chest */
+		ObjectInfo(185, 62,  0, 0x0500),   /* OPEN CHEST     Pouch/Chest */
+		ObjectInfo(186, 62,  0, 0x0500),   /* ASHES          Pouch/Chest */
+		ObjectInfo(187, 62,  0, 0x0500),   /* BONES          Pouch/Chest */
+		ObjectInfo(188, 62,  0, 0x0500),   /* MON POTION     Pouch/Chest */
+		ObjectInfo(189, 62,  0, 0x0500),   /* UM POTION      Pouch/Chest */
+		ObjectInfo(190, 62,  0, 0x0500),   /* DES POTION     Pouch/Chest */
+		ObjectInfo(191, 62,  0, 0x0500),   /* VEN POTION     Pouch/Chest */
+		ObjectInfo(128, 76,  0, 0x0200),   /* SAR POTION     Hands */
+		ObjectInfo(129,  3,  0, 0x0500),   /* ZO POTION      Pouch/Chest */
+		ObjectInfo(130, 60,  0, 0x0500),   /* ROS POTION     Pouch/Chest */
+		ObjectInfo(131, 61,  0, 0x0500),   /* KU POTION      Pouch/Chest */
+		ObjectInfo(168, 27,  0, 0x0501),   /* DANE POTION    Mouth/Pouch/Chest */
+		ObjectInfo(169, 28,  0, 0x0501),   /* NETA POTION    Mouth/Pouch/Chest */
+		ObjectInfo(170, 25,  0, 0x0501),   /* BRO POTION     Mouth/Pouch/Chest */
+		ObjectInfo(171, 26,  0, 0x0501),   /* MA POTION      Mouth/Pouch/Chest */
+		ObjectInfo(172, 71,  0, 0x0401),   /* YA POTION      Mouth/Chest */
+		ObjectInfo(173, 70,  0, 0x0401),   /* EE POTION      Mouth/Chest */
+		ObjectInfo(174,  5,  0, 0x0501),   /* VI POTION      Mouth/Pouch/Chest */
+		ObjectInfo(175, 66,  0, 0x0501),   /* WATER FLASK    Mouth/Pouch/Chest */
+		ObjectInfo(120, 15,  0, 0x0504),   /* KATH BOMB      Neck/Pouch/Chest */
+		ObjectInfo(121, 15,  0, 0x0504),   /* PEW BOMB       Neck/Pouch/Chest */
+		ObjectInfo(122, 58,  0, 0x0504),   /* RA BOMB        Neck/Pouch/Chest */
+		ObjectInfo(123, 59,  0, 0x0504),   /* FUL BOMB       Neck/Pouch/Chest */
+		ObjectInfo(124, 59,  0, 0x0504),   /* APPLE          Neck/Pouch/Chest */
+		ObjectInfo(132, 79, 38, 0x0500),   /* CORN           Pouch/Chest */
+		ObjectInfo(133, 63, 38, 0x0500),   /* BREAD          Pouch/Chest */
+		ObjectInfo(134, 64,  0, 0x0500),   /* CHEESE         Pouch/Chest */
+		ObjectInfo(136, 72, 39, 0x0400),   /* SCREAMER SLICE Chest */
+		ObjectInfo(137, 73,  0, 0x0500),   /* WORM ROUND     Pouch/Chest */
+		ObjectInfo(138, 74,  0, 0x0500),   /* DRUMSTICK      Pouch/Chest */
+		ObjectInfo(139, 75,  0, 0x0504),   /* DRAGON STEAK   Neck/Pouch/Chest */
+		ObjectInfo(192, 77,  0, 0x0500),   /* IRON KEY       Pouch/Chest */
+		ObjectInfo(193, 78,  0, 0x0500),   /* KEY OF B       Pouch/Chest */
+		ObjectInfo(197, 74,  0, 0x0000),   /* SOLID KEY */
+		ObjectInfo(198, 41,  0, 0x0400)}; /* SQUARE KEY     Chest */
+
+		for (int i = 0; i < 180; i++)
+			g237_ObjectInfo[i] = objectInfo[i];
+}
+
 DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_rawDunFileDataSize = 0;
 	_rawDunFileData = nullptr;
@@ -408,6 +413,8 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine) {
 		_g292_pileTopObject[i] = Thing(0);
 	for (uint16 i = 0; i < 2; ++i)
 		_g275_currMapDoorInfo[i].resetToZero();
+
+	setupArrays();
 }
 
 DungeonMan::~DungeonMan() {
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 0f13d07..e738723 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -84,6 +84,7 @@ public:
 	uint16 _allowedSlots;
 	ObjectInfo(int16 type, uint16 objectAspectIndex, uint16 actionSetIndex, uint16 allowedSlots)
 		: _type(type), _objectAspectIndex(objectAspectIndex), _actionSetIndex(actionSetIndex), _allowedSlots(allowedSlots) {}
+	ObjectInfo() : _type(0), _objectAspectIndex(0), _actionSetIndex(0), _allowedSlots(0) {}
 	bool getAllowedSlot(ObjectAllowedSlot slot) { return _allowedSlots & slot; }
 	uint16 getAllowedSlots() { return _allowedSlots; }
 	void setAllowedSlot(ObjectAllowedSlot slot, bool val) {
@@ -95,8 +96,6 @@ public:
 	}
 }; // @ OBJECT_INFO
 
-extern ObjectInfo g237_ObjectInfo[180]; // @ G0237_as_Graphic559_ObjectInfo
-
 enum ArmourAttribute {
 	k0x0080_ArmourAttributeIsAShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD
 	k0x0007_ArmourAttributeSharpDefense = 0x0007 // @ MASK0x0007_SHARP_DEFENSE
@@ -747,6 +746,10 @@ public:
 	ElementType _g285_squareAheadElement; // @ G0285_i_SquareAheadElement 
 	Thing _g292_pileTopObject[5]; // @ G0292_aT_PileTopObject
 	DoorInfo _g275_currMapDoorInfo[2]; // @ G0275_as_CurrentMapDoorInfo
+	
+	ObjectInfo g237_ObjectInfo[180]; // @ G0237_as_Graphic559_ObjectInfo
+
+	void setupArrays();
 };
 
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 44b1cc1..c17eabe 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1023,31 +1023,32 @@ void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloor
 		}
 	};
 
-	if (floorOrnOrdinal) {
-		bool drawFootprints = (getFlag(floorOrnOrdinal, k0x8000_FootprintsAspect) ? true : false);
-		byte *bitmap;
-		if (drawFootprints && (clearFlag(floorOrnOrdinal, k0x8000_FootprintsAspect))) {
-			floorOrnOrdinal--;
-			uint16 floorOrnIndex = floorOrnOrdinal;
-			int16 nativeBitmapIndex = _g102_currMapFloorOrnInfo[floorOrnIndex][k0_NativeBitmapIndex]
-				+ g191_floorOrnNativeBitmapndexInc[viewFloorIndex];
-			uint16 *coordSets = g206_floorOrnCoordSets[_g102_currMapFloorOrnInfo[floorOrnIndex][k1_CoordinateSet]][viewFloorIndex];
-			if ((viewFloorIndex == k8_viewFloor_D1R) || (viewFloorIndex == k5_viewFloor_D2R)
-				|| (viewFloorIndex == k2_viewFloor_D3R)
-				|| ((floorOrnIndex == k15_FloorOrnFootprints) && _g76_useFlippedWallAndFootprintsBitmap &&
-				((viewFloorIndex == k7_viewFloor_D1C) || (viewFloorIndex == k4_viewFloor_D2C) || (viewFloorIndex == k1_viewFloor_D3C)))) {
-				bitmap = _g74_tmpBitmap;
-				f99_copyBitmapAndFlipHorizontal(f489_getNativeBitmapOrGraphic(nativeBitmapIndex), bitmap, coordSets[4], coordSets[5]);
-			} else
-				bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+	if (!floorOrnOrdinal)
+		return;
 
-			f132_blitToBitmap(bitmap, _g296_bitmapViewport,
-							  *(Box *)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport);
-		}
+	bool drawFootprints = (getFlag(floorOrnOrdinal, k0x8000_FootprintsAspect) ? true : false);
+	byte *bitmap;
+	if (!drawFootprints || clearFlag(floorOrnOrdinal, k0x8000_FootprintsAspect)) {
+		floorOrnOrdinal--;
+		uint16 floorOrnIndex = floorOrnOrdinal;
+		int16 nativeBitmapIndex = _g102_currMapFloorOrnInfo[floorOrnIndex][k0_NativeBitmapIndex]
+			+ g191_floorOrnNativeBitmapndexInc[viewFloorIndex];
+		uint16 *coordSets = g206_floorOrnCoordSets[_g102_currMapFloorOrnInfo[floorOrnIndex][k1_CoordinateSet]][viewFloorIndex];
+		if ((viewFloorIndex == k8_viewFloor_D1R) || (viewFloorIndex == k5_viewFloor_D2R)
+			|| (viewFloorIndex == k2_viewFloor_D3R)
+			|| ((floorOrnIndex == k15_FloorOrnFootprints) && _g76_useFlippedWallAndFootprintsBitmap &&
+			((viewFloorIndex == k7_viewFloor_D1C) || (viewFloorIndex == k4_viewFloor_D2C) || (viewFloorIndex == k1_viewFloor_D3C)))) {
+			bitmap = _g74_tmpBitmap;
+			f99_copyBitmapAndFlipHorizontal(f489_getNativeBitmapOrGraphic(nativeBitmapIndex), bitmap, coordSets[4], coordSets[5]);
+		} else
+			bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
 
-		if (drawFootprints)
-			f108_drawFloorOrnament(_vm->M0_indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex);
+		f132_blitToBitmap(bitmap, _g296_bitmapViewport,
+						  *(Box *)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport);
 	}
+
+	if (drawFootprints)
+		f108_drawFloorOrnament(_vm->M0_indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex);
 }
 
 void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* doorNativeBitmapIndices, int16 byteCount, int16 viewDoorOrnIndex, DoorFrames* doorFrames) {
@@ -3101,7 +3102,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 			}
 
 			if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) { /* Square where objects are visible and object is located on cell being processed */
-				objectAspect = &(_objectAspects209[g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thingParam)]._objectAspectIndex]);
+				objectAspect = &(_objectAspects209[_vm->_dungeonMan->g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thingParam)]._objectAspectIndex]);
 				AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex;
 				if (useAlcoveObjectImage = (L0135_B_DrawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane))
 					AL_4_nativeBitmapIndex++;
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index f715227..5552da4 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -587,7 +587,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		case k8_PotionThingType: {
 			potentialAttribMask = k0x0001_DescriptionMaskConsumable;
 			Potion *potion = (Potion *)rawThingPtr;
-			actualAttribMask = g237_ObjectInfo[k2_ObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots();
+			actualAttribMask = _vm->_dungeonMan->g237_ObjectInfo[k2_ObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots();
 			break;
 		}
 		case k10_JunkThingType: {
@@ -630,7 +630,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 				f335_drawPanelObjectDescriptionString(str);
 			} else {
 				potentialAttribMask = k0x0001_DescriptionMaskConsumable;
-				actualAttribMask = g237_ObjectInfo[k127_ObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots();
+				actualAttribMask = _vm->_dungeonMan->g237_ObjectInfo[k127_ObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots();
 			}
 			break;
 		}
@@ -937,7 +937,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 	if (_vm->_championMan->_g299_candidateChampionOrdinal) {
 		return;
 	}
-	if (!getFlag(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1078_T_Thing = _vm->_championMan->_g414_leaderHandObject)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) {
+	if (!getFlag(_vm->_dungeonMan->g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1078_T_Thing = _vm->_championMan->_g414_leaderHandObject)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) {
 		return;
 	}
 	L1079_ui_IconIndex = _vm->_objectMan->f33_getIconIndex(L1078_T_Thing);
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 6a21c42..02f1a80 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -56,11 +56,11 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 	Common::InSaveFile *file = nullptr;
 
 	struct {
-		int16 _saveFormat = 0;
-		int16 _saveAndPlayChoice = 0;
-		int32 _gameId = 0;
-		int16 _platform = 0;
-		uint16 _dungeonId = 0;
+		int16 _saveFormat;
+		int16 _saveAndPlayChoice;
+		int32 _gameId;
+		int16 _platform;
+		uint16 _dungeonId;
 	} dmSaveHeader;
 
 	if (!_g298_newGame) {
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 53d5040..afd6eb2 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -153,7 +153,7 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
 	IconIndice iconIndex;
 	if (thing == Thing::_none) {
 		iconIndex = k201_IconIndiceActionEmptyHand;
-	} else if (g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thing)]._actionSetIndex) {
+	} else if (_vm->_dungeonMan->g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thing)]._actionSetIndex) {
 		iconIndex = _vm->_objectMan->f33_getIconIndex(thing);
 	} else {
 		dm.f134_fillBitmap(bitmapIcon, k4_ColorCyan, 16, 16);
@@ -1626,11 +1626,9 @@ void MenuMan::f389_processCommands116To119_setActingChampion(uint16 champIndex)
 		return;
 	}
 	if ((L1189_T_Thing = L1190_ps_Champion->_slots[k1_ChampionSlotActionHand]) == Thing::_none) {
-		L1188_ui_ActionSetIndex = 2; /* Actions Punck, Kick and War Cry */
-	} else {
-		if ((L1188_ui_ActionSetIndex = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1189_T_Thing)]._actionSetIndex) == 0) {
-			return;
-		}
+		L1188_ui_ActionSetIndex = 2; /* Actions Punch, Kick and War Cry */
+	} else if ((L1188_ui_ActionSetIndex = _vm->_dungeonMan->g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1189_T_Thing)]._actionSetIndex) == 0) {
+		return;
 	}
 	L1191_ps_ActionSet = &G0489_as_Graphic560_ActionSets[L1188_ui_ActionSetIndex];
 	_vm->_championMan->_g506_actingChampionOrdinal = _vm->M0_indexToOrdinal(champIndex);
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 3104ae2..3c731d8 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -130,7 +130,7 @@ IconIndice ObjectMan::f32_getObjectType(Thing thing) {
 
 	int16 objectInfoIndex = _vm->_dungeonMan->f141_getObjectInfoIndex(thing);
 	if (objectInfoIndex != -1) {
-		objectInfoIndex = g237_ObjectInfo[objectInfoIndex]._type;
+		objectInfoIndex = _vm->_dungeonMan->g237_ObjectInfo[objectInfoIndex]._type;
 	}
 	return (IconIndice)objectInfoIndex;
 }
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index b65e03a..5e21cbd 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -159,7 +159,7 @@ T0217004:
 			((L0510_i_ProjectileAssociatedThingType == k15_ExplosionThingType) ?
 			 (L0486_T_ProjectileAssociatedThing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) :
 			 ((L0490_ps_Projectile->_attack > _vm->getRandomNumber(128)) &&
-			  getFlag(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0486_T_ProjectileAssociatedThing)].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)
+			  getFlag(_vm->_dungeonMan->g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0486_T_ProjectileAssociatedThing)].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)
 			  && ((L0510_i_ProjectileAssociatedThingType != k10_JunkThingType) ||
 			  ((AL0487_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0486_T_ProjectileAssociatedThing)) < 0) ||
 				  (!((AL0487_i_IconIndex >= k176_IconIndiceJunkIronKey) && (AL0487_i_IconIndex <= k191_IconIndiceJunkMasterKey))))


Commit: 58d1bcc3e7f7aca20b1db3bef019f742ebd6c474
    https://github.com/scummvm/scummvm/commit/58d1bcc3e7f7aca20b1db3bef019f742ebd6c474
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Silent a couple of CppCheck warnings

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dialog.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 6e92915..caf61ef 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -721,7 +721,6 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 	if (!curChampion->_currHealth)
 		return 0;
 
-	bool skipScaling = false;
 	if (attackType != k0_attackType_NORMAL) {
 		uint16 defense = 0;
 		uint16 woundCount = 0;
@@ -734,6 +733,7 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 		if (woundCount)
 			defense /= woundCount;
 
+		bool skipScaling = false;
 		switch (attackType) {
 		case k6_attackType_PSYCHIC:
 		{
diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index 900ff76..53513b7 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -154,7 +154,7 @@ bool DialogMan::f426_isMessageOnTwoLines(char* str, char* part1, char* part2) {
 
 	strcpy(part1, str);
 	uint16 splitPosition = strLength >> 1;
-	while ((part1[splitPosition] != ' ') && (splitPosition < strLength))
+	while ((splitPosition < strLength) && (part1[splitPosition] != ' '))
 		splitPosition++;
 
 	part1[splitPosition] = '\0';


Commit: 705e906698505e8a547ef46c8a2fc65e3f48a49b
    https://github.com/scummvm/scummvm/commit/705e906698505e8a547ef46c8a2fc65e3f48a49b
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some renaming, move some globals to class member

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/objectman.cpp
    engines/dm/projexpl.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index caf61ef..79840fa 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -815,7 +815,7 @@ int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
 		Thing curThing = curChampion->_slots[slotIndex];
 		if (curThing.getType() == k6_ArmourThingType) {
 			ArmourInfo *armorInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(curThing);
-			armorInfo = &g239_ArmourInfo[((Armour *)armorInfo)->getType()];
+			armorInfo = &_vm->_dungeonMan->_armourInfo[((Armour *)armorInfo)->getType()];
 			if (getFlag(armorInfo->_attributes, k0x0080_ArmourAttributeIsAShield))
 				armorShieldDefense += ((f312_getStrength(champIndex, slotIndex) + _vm->_dungeonMan->f143_getArmourDefense(armorInfo, useSharpDefense)) * woundDefenseFactor[woundIndex]) >> ((slotIndex == woundIndex) ? 4 : 5);
 		}
@@ -830,7 +830,7 @@ int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
 		Thing curThing = curChampion->_slots[woundIndex];
 		if (curThing.getType() == k6_ArmourThingType) {
 			ArmourInfo *armourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(curThing);
-			woundDefense += _vm->_dungeonMan->f143_getArmourDefense(&g239_ArmourInfo[((Armour *)armourInfo)->getType()], useSharpDefense);
+			woundDefense += _vm->_dungeonMan->f143_getArmourDefense(&_vm->_dungeonMan->_armourInfo[((Armour *)armourInfo)->getType()], useSharpDefense);
 		}
 	}
 
@@ -1282,7 +1282,7 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex)
 	if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none))
 		return;
 
-	if ((leaderHandObject != Thing::_none) && (!(_vm->_dungeonMan->g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & gSlotMasks[slotIndex])))
+	if ((leaderHandObject != Thing::_none) && (!(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & gSlotMasks[slotIndex])))
 		return;
 
 	_vm->_eventMan->f78_showMouse();
@@ -1928,7 +1928,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 	while (curThing != Thing::_endOfList) {
 		ThingType thingType = curThing.getType();
 		if ((thingType > k3_SensorThingType) && (curThing.getCell() == championObjectsCell)) {
-			int16 objectAllowedSlots = _vm->_dungeonMan->g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(curThing)]._allowedSlots;
+			int16 objectAllowedSlots = _vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(curThing)]._allowedSlots;
 			uint16 curSlotIndex;
 			switch (thingType) {
 			case k6_ArmourThingType: {
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index b0516ba..8a17ce6 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -38,120 +38,10 @@
 
 namespace DM {
 
-ArmourInfo g239_ArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo
-/* { Weight, Defense, Attributes, Unreferenced } */
-	ArmourInfo(3,   5, 0x01),   /* CAPE */
-	ArmourInfo(4,  10, 0x01),   /* CLOAK OF NIGHT */
-	ArmourInfo(3,   4, 0x01),   /* BARBARIAN HIDE */
-	ArmourInfo(6,   5, 0x02),   /* SANDALS */
-	ArmourInfo(16,  25, 0x04),   /* LEATHER BOOTS */
-	ArmourInfo(4,   5, 0x00),   /* ROBE */
-	ArmourInfo(4,   5, 0x00),   /* ROBE */
-	ArmourInfo(3,   7, 0x01),   /* FINE ROBE */
-	ArmourInfo(3,   7, 0x01),   /* FINE ROBE */
-	ArmourInfo(4,   6, 0x01),   /* KIRTLE */
-	ArmourInfo(2,   4, 0x00),   /* SILK SHIRT */
-	ArmourInfo(4,   5, 0x01),   /* TABARD */
-	ArmourInfo(5,   7, 0x01),   /* GUNNA */
-	ArmourInfo(3,  11, 0x02),   /* ELVEN DOUBLET */
-	ArmourInfo(3,  13, 0x02),   /* ELVEN HUKE */
-	ArmourInfo(4,  13, 0x02),   /* ELVEN BOOTS */
-	ArmourInfo(6,  17, 0x03),   /* LEATHER JERKIN */
-	ArmourInfo(8,  20, 0x03),   /* LEATHER PANTS */
-	ArmourInfo(14,  20, 0x03),   /* SUEDE BOOTS */
-	ArmourInfo(6,  12, 0x02),   /* BLUE PANTS */
-	ArmourInfo(5,   9, 0x01),   /* TUNIC */
-	ArmourInfo(5,   8, 0x01),   /* GHI */
-	ArmourInfo(5,   9, 0x01),   /* GHI TROUSERS */
-	ArmourInfo(4,   1, 0x04),   /* CALISTA */
-	ArmourInfo(6,   5, 0x04),   /* CROWN OF NERRA */
-	ArmourInfo(11,  12, 0x05),   /* BEZERKER HELM */
-	ArmourInfo(14,  17, 0x05),   /* HELMET */
-	ArmourInfo(15,  20, 0x05),   /* BASINET */
-	ArmourInfo(11,  22, 0x85),   /* BUCKLER */
-	ArmourInfo(10,  16, 0x82),   /* HIDE SHIELD */
-	ArmourInfo(14,  20, 0x83),   /* WOODEN SHIELD */
-	ArmourInfo(21,  35, 0x84),   /* SMALL SHIELD */
-	ArmourInfo(65,  35, 0x05),   /* MAIL AKETON */
-	ArmourInfo(53,  35, 0x05),   /* LEG MAIL */
-	ArmourInfo(52,  70, 0x07),   /* MITHRAL AKETON */
-	ArmourInfo(41,  55, 0x07),   /* MITHRAL MAIL */
-	ArmourInfo(16,  25, 0x06),   /* CASQUE 'N COIF */
-	ArmourInfo(16,  30, 0x06),   /* HOSEN */
-	ArmourInfo(19,  40, 0x07),   /* ARMET */
-	ArmourInfo(120,  65, 0x04),   /* TORSO PLATE */
-	ArmourInfo(80,  56, 0x04),   /* LEG PLATE */
-	ArmourInfo(28,  37, 0x05),   /* FOOT PLATE */
-	ArmourInfo(34,  56, 0x84),   /* LARGE SHIELD */
-	ArmourInfo(17,  62, 0x05),   /* HELM OF LYTE */
-	ArmourInfo(108, 125, 0x04),   /* PLATE OF LYTE */
-	ArmourInfo(72,  90, 0x04),   /* POLEYN OF LYTE */
-	ArmourInfo(24,  50, 0x05),   /* GREAVE OF LYTE */
-	ArmourInfo(30,  85, 0x84),   /* SHIELD OF LYTE */
-	ArmourInfo(35,  76, 0x04),   /* HELM OF DARC */
-	ArmourInfo(141, 160, 0x04),   /* PLATE OF DARC */
-	ArmourInfo(90, 101, 0x04),   /* POLEYN OF DARC */
-	ArmourInfo(31,  60, 0x05),   /* GREAVE OF DARC */
-	ArmourInfo(40, 100, 0x84),   /* SHIELD OF DARC */
-	ArmourInfo(14,  54, 0x06),   /* DEXHELM */
-	ArmourInfo(57,  60, 0x07),   /* FLAMEBAIN */
-	ArmourInfo(81,  88, 0x04),   /* POWERTOWERS */
-	ArmourInfo(3,  16, 0x02),   /* BOOTS OF SPEED */
-	ArmourInfo(2,   3, 0x03)}; /* HALTER */
-
-WeaponInfo g238_WeaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo
-							   /* { Weight, Class, Strength, KineticEnergy, Attributes } */
-	WeaponInfo(1, 130,   2,   0, 0x2000),   /* EYE OF TIME */
-	WeaponInfo(1, 131,   2,   0, 0x2000),   /* STORMRING */
-	WeaponInfo(11, 0,   8,   2, 0x2000),   /* TORCH */
-	WeaponInfo(12, 112,  10,  80, 0x2028),   /* FLAMITT */
-	WeaponInfo(9, 129,  16,   7, 0x2000),   /* STAFF OF CLAWS */
-	WeaponInfo(30, 113,  49, 110, 0x0942),   /* BOLT BLADE */
-	WeaponInfo(47, 0,  55,  20, 0x0900),   /* FURY */
-	WeaponInfo(24, 255,  25,  10, 0x20FF),   /* THE FIRESTAFF */
-	WeaponInfo(5, 2,  10,  19, 0x0200),   /* DAGGER */
-	WeaponInfo(33, 0,  30,   8, 0x0900),   /* FALCHION */
-	WeaponInfo(32, 0,  34,  10, 0x0900),   /* SWORD */
-	WeaponInfo(26, 0,  38,  10, 0x0900),   /* RAPIER */
-	WeaponInfo(35, 0,  42,  11, 0x0900),   /* SABRE */
-	WeaponInfo(36, 0,  46,  12, 0x0900),   /* SAMURAI SWORD */
-	WeaponInfo(33, 0,  50,  14, 0x0900),   /* DELTA */
-	WeaponInfo(37, 0,  62,  14, 0x0900),   /* DIAMOND EDGE */
-	WeaponInfo(30, 0,  48,  13, 0x0000),   /* VORPAL BLADE */
-	WeaponInfo(39, 0,  58,  15, 0x0900),   /* THE INQUISITOR */
-	WeaponInfo(43, 2,  49,  33, 0x0300),   /* AXE */
-	WeaponInfo(65, 2,  70,  44, 0x0300),   /* HARDCLEAVE */
-	WeaponInfo(31, 0,  32,  10, 0x2000),   /* MACE */
-	WeaponInfo(41, 0,  42,  13, 0x2000),   /* MACE OF ORDER */
-	WeaponInfo(50, 0,  60,  15, 0x2000),   /* MORNINGSTAR */
-	WeaponInfo(36, 0,  19,  10, 0x2700),   /* CLUB */
-	WeaponInfo(110, 0,  44,  22, 0x2600),   /* STONE CLUB */
-	WeaponInfo(10, 20,   1,  50, 0x2032),   /* BOW */
-	WeaponInfo(28, 30,   1, 180, 0x2078),   /* CROSSBOW */
-	WeaponInfo(2, 10,   2,  10, 0x0100),   /* ARROW */
-	WeaponInfo(2, 10,   2,  28, 0x0500),   /* SLAYER */
-	WeaponInfo(19, 39,   5,  20, 0x2032),   /* SLING */
-	WeaponInfo(10, 11,   6,  18, 0x2000),   /* ROCK */
-	WeaponInfo(3, 12,   7,  23, 0x0800),   /* POISON DART */
-	WeaponInfo(1, 1,   3,  19, 0x0A00),   /* THROWING STAR */
-	WeaponInfo(8, 0,   4,   4, 0x2000),   /* STICK */
-	WeaponInfo(26, 129,  12,   4, 0x2000),   /* STAFF */
-	WeaponInfo(1, 130,   0,   0, 0x2000),   /* WAND */
-	WeaponInfo(2, 140,   1,  20, 0x2000),   /* TEOWAND */
-	WeaponInfo(35, 128,  18,   6, 0x2000),   /* YEW STAFF */
-	WeaponInfo(29, 159,   0,   4, 0x2000),   /* STAFF OF MANAR */
-	WeaponInfo(21, 131,   0,   3, 0x2000),   /* SNAKE STAFF */
-	WeaponInfo(33, 136,   0,   7, 0x2000),   /* THE CONDUIT */
-	WeaponInfo(8, 132,   3,   1, 0x2000),   /* DRAGON SPIT */
-	WeaponInfo(18, 131,   9,   4, 0x2000),   /* SCEPTRE OF LYF */
-	WeaponInfo(8, 192,   1,   1, 0x2000),   /* HORN OF FEAR */
-	WeaponInfo(30, 26,   1, 220, 0x207D),   /* SPEEDBOW */
-	WeaponInfo(36, 255, 100,  50, 0x20FF)}; /* THE FIRESTAFF */
-
 CreatureInfo g243_CreatureInfo[k27_CreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo
-												   /* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo,
-												   MovementTicks, AttackTicks, Defense, BaseHealth, Attack, PoisonAttack,
-												   Dexterity, Ranges, Properties, Resistances, AnimationTicks, WoundProbabilities, AttackType } */
+	/* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo,
+		MovementTicks, AttackTicks, Defense, BaseHealth, Attack, PoisonAttack,
+		Dexterity, Ranges, Properties, Resistances, AnimationTicks, WoundProbabilities, AttackType } */
 	{0,  4, 0x0482, 0x623D,   8, 20,  55, 150, 150, 240,  55, 0x1153, 0x299B, 0x0876, 0x0254, 0xFD40, 4},
 	{1,  0, 0x0480, 0xA625,  15, 32,  20, 110,  80,  15,  20, 0x3132, 0x33A9, 0x0E42, 0x0384, 0xFC41, 3},
 	{2,  6, 0x0510, 0x6198,   3,  5,  50,  10,  10,   0, 110, 0x1376, 0x710A, 0x0235, 0x0222, 0xFD20, 0},
@@ -370,10 +260,129 @@ void DungeonMan::setupArrays() {
 		ObjectInfo(192, 77,  0, 0x0500),   /* IRON KEY       Pouch/Chest */
 		ObjectInfo(193, 78,  0, 0x0500),   /* KEY OF B       Pouch/Chest */
 		ObjectInfo(197, 74,  0, 0x0000),   /* SOLID KEY */
-		ObjectInfo(198, 41,  0, 0x0400)}; /* SQUARE KEY     Chest */
+		ObjectInfo(198, 41,  0, 0x0400)    /* SQUARE KEY     Chest */
+	};
+	ArmourInfo armourInfo[58] = { // G0239_as_Graphic559_ArmourInfo
+		/* { Weight, Defense, Attributes, Unreferenced } */
+		ArmourInfo(3,   5, 0x01),   /* CAPE */
+		ArmourInfo(4,  10, 0x01),   /* CLOAK OF NIGHT */
+		ArmourInfo(3,   4, 0x01),   /* BARBARIAN HIDE */
+		ArmourInfo(6,   5, 0x02),   /* SANDALS */
+		ArmourInfo(16,  25, 0x04),   /* LEATHER BOOTS */
+		ArmourInfo(4,   5, 0x00),   /* ROBE */
+		ArmourInfo(4,   5, 0x00),   /* ROBE */
+		ArmourInfo(3,   7, 0x01),   /* FINE ROBE */
+		ArmourInfo(3,   7, 0x01),   /* FINE ROBE */
+		ArmourInfo(4,   6, 0x01),   /* KIRTLE */
+		ArmourInfo(2,   4, 0x00),   /* SILK SHIRT */
+		ArmourInfo(4,   5, 0x01),   /* TABARD */
+		ArmourInfo(5,   7, 0x01),   /* GUNNA */
+		ArmourInfo(3,  11, 0x02),   /* ELVEN DOUBLET */
+		ArmourInfo(3,  13, 0x02),   /* ELVEN HUKE */
+		ArmourInfo(4,  13, 0x02),   /* ELVEN BOOTS */
+		ArmourInfo(6,  17, 0x03),   /* LEATHER JERKIN */
+		ArmourInfo(8,  20, 0x03),   /* LEATHER PANTS */
+		ArmourInfo(14,  20, 0x03),   /* SUEDE BOOTS */
+		ArmourInfo(6,  12, 0x02),   /* BLUE PANTS */
+		ArmourInfo(5,   9, 0x01),   /* TUNIC */
+		ArmourInfo(5,   8, 0x01),   /* GHI */
+		ArmourInfo(5,   9, 0x01),   /* GHI TROUSERS */
+		ArmourInfo(4,   1, 0x04),   /* CALISTA */
+		ArmourInfo(6,   5, 0x04),   /* CROWN OF NERRA */
+		ArmourInfo(11,  12, 0x05),   /* BEZERKER HELM */
+		ArmourInfo(14,  17, 0x05),   /* HELMET */
+		ArmourInfo(15,  20, 0x05),   /* BASINET */
+		ArmourInfo(11,  22, 0x85),   /* BUCKLER */
+		ArmourInfo(10,  16, 0x82),   /* HIDE SHIELD */
+		ArmourInfo(14,  20, 0x83),   /* WOODEN SHIELD */
+		ArmourInfo(21,  35, 0x84),   /* SMALL SHIELD */
+		ArmourInfo(65,  35, 0x05),   /* MAIL AKETON */
+		ArmourInfo(53,  35, 0x05),   /* LEG MAIL */
+		ArmourInfo(52,  70, 0x07),   /* MITHRAL AKETON */
+		ArmourInfo(41,  55, 0x07),   /* MITHRAL MAIL */
+		ArmourInfo(16,  25, 0x06),   /* CASQUE 'N COIF */
+		ArmourInfo(16,  30, 0x06),   /* HOSEN */
+		ArmourInfo(19,  40, 0x07),   /* ARMET */
+		ArmourInfo(120,  65, 0x04),   /* TORSO PLATE */
+		ArmourInfo(80,  56, 0x04),   /* LEG PLATE */
+		ArmourInfo(28,  37, 0x05),   /* FOOT PLATE */
+		ArmourInfo(34,  56, 0x84),   /* LARGE SHIELD */
+		ArmourInfo(17,  62, 0x05),   /* HELM OF LYTE */
+		ArmourInfo(108, 125, 0x04),   /* PLATE OF LYTE */
+		ArmourInfo(72,  90, 0x04),   /* POLEYN OF LYTE */
+		ArmourInfo(24,  50, 0x05),   /* GREAVE OF LYTE */
+		ArmourInfo(30,  85, 0x84),   /* SHIELD OF LYTE */
+		ArmourInfo(35,  76, 0x04),   /* HELM OF DARC */
+		ArmourInfo(141, 160, 0x04),   /* PLATE OF DARC */
+		ArmourInfo(90, 101, 0x04),   /* POLEYN OF DARC */
+		ArmourInfo(31,  60, 0x05),   /* GREAVE OF DARC */
+		ArmourInfo(40, 100, 0x84),   /* SHIELD OF DARC */
+		ArmourInfo(14,  54, 0x06),   /* DEXHELM */
+		ArmourInfo(57,  60, 0x07),   /* FLAMEBAIN */
+		ArmourInfo(81,  88, 0x04),   /* POWERTOWERS */
+		ArmourInfo(3,  16, 0x02),   /* BOOTS OF SPEED */
+		ArmourInfo(2,   3, 0x03)    /* HALTER */
+	};
+
+	WeaponInfo weaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo
+		/* { Weight, Class, Strength, KineticEnergy, Attributes } */
+		WeaponInfo(1, 130,   2,   0, 0x2000),   /* EYE OF TIME */
+		WeaponInfo(1, 131,   2,   0, 0x2000),   /* STORMRING */
+		WeaponInfo(11, 0,   8,   2, 0x2000),   /* TORCH */
+		WeaponInfo(12, 112,  10,  80, 0x2028),   /* FLAMITT */
+		WeaponInfo(9, 129,  16,   7, 0x2000),   /* STAFF OF CLAWS */
+		WeaponInfo(30, 113,  49, 110, 0x0942),   /* BOLT BLADE */
+		WeaponInfo(47, 0,  55,  20, 0x0900),   /* FURY */
+		WeaponInfo(24, 255,  25,  10, 0x20FF),   /* THE FIRESTAFF */
+		WeaponInfo(5, 2,  10,  19, 0x0200),   /* DAGGER */
+		WeaponInfo(33, 0,  30,   8, 0x0900),   /* FALCHION */
+		WeaponInfo(32, 0,  34,  10, 0x0900),   /* SWORD */
+		WeaponInfo(26, 0,  38,  10, 0x0900),   /* RAPIER */
+		WeaponInfo(35, 0,  42,  11, 0x0900),   /* SABRE */
+		WeaponInfo(36, 0,  46,  12, 0x0900),   /* SAMURAI SWORD */
+		WeaponInfo(33, 0,  50,  14, 0x0900),   /* DELTA */
+		WeaponInfo(37, 0,  62,  14, 0x0900),   /* DIAMOND EDGE */
+		WeaponInfo(30, 0,  48,  13, 0x0000),   /* VORPAL BLADE */
+		WeaponInfo(39, 0,  58,  15, 0x0900),   /* THE INQUISITOR */
+		WeaponInfo(43, 2,  49,  33, 0x0300),   /* AXE */
+		WeaponInfo(65, 2,  70,  44, 0x0300),   /* HARDCLEAVE */
+		WeaponInfo(31, 0,  32,  10, 0x2000),   /* MACE */
+		WeaponInfo(41, 0,  42,  13, 0x2000),   /* MACE OF ORDER */
+		WeaponInfo(50, 0,  60,  15, 0x2000),   /* MORNINGSTAR */
+		WeaponInfo(36, 0,  19,  10, 0x2700),   /* CLUB */
+		WeaponInfo(110, 0,  44,  22, 0x2600),   /* STONE CLUB */
+		WeaponInfo(10, 20,   1,  50, 0x2032),   /* BOW */
+		WeaponInfo(28, 30,   1, 180, 0x2078),   /* CROSSBOW */
+		WeaponInfo(2, 10,   2,  10, 0x0100),   /* ARROW */
+		WeaponInfo(2, 10,   2,  28, 0x0500),   /* SLAYER */
+		WeaponInfo(19, 39,   5,  20, 0x2032),   /* SLING */
+		WeaponInfo(10, 11,   6,  18, 0x2000),   /* ROCK */
+		WeaponInfo(3, 12,   7,  23, 0x0800),   /* POISON DART */
+		WeaponInfo(1, 1,   3,  19, 0x0A00),   /* THROWING STAR */
+		WeaponInfo(8, 0,   4,   4, 0x2000),   /* STICK */
+		WeaponInfo(26, 129,  12,   4, 0x2000),   /* STAFF */
+		WeaponInfo(1, 130,   0,   0, 0x2000),   /* WAND */
+		WeaponInfo(2, 140,   1,  20, 0x2000),   /* TEOWAND */
+		WeaponInfo(35, 128,  18,   6, 0x2000),   /* YEW STAFF */
+		WeaponInfo(29, 159,   0,   4, 0x2000),   /* STAFF OF MANAR */
+		WeaponInfo(21, 131,   0,   3, 0x2000),   /* SNAKE STAFF */
+		WeaponInfo(33, 136,   0,   7, 0x2000),   /* THE CONDUIT */
+		WeaponInfo(8, 132,   3,   1, 0x2000),   /* DRAGON SPIT */
+		WeaponInfo(18, 131,   9,   4, 0x2000),   /* SCEPTRE OF LYF */
+		WeaponInfo(8, 192,   1,   1, 0x2000),   /* HORN OF FEAR */
+		WeaponInfo(30, 26,   1, 220, 0x207D),   /* SPEEDBOW */
+		WeaponInfo(36, 255, 100,  50, 0x20FF)   /* THE FIRESTAFF */
+	};
+
+	for (int i = 0; i < 180; i++)
+		_objectInfo[i] = objectInfo[i];
+
+	for (int i = 0; i < 58; i++)
+		_armourInfo[i] = armourInfo[i];
+
+	for (int i = 0; i < 46; i++)
+		_weaponInfo[i] = weaponInfo[i];
 
-		for (int i = 0; i < 180; i++)
-			g237_ObjectInfo[i] = objectInfo[i];
 }
 
 DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine) {
@@ -1234,10 +1243,10 @@ uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 
 	switch (thing.getType()) {
 	case k5_WeaponThingType:
-		weight = g238_WeaponInfo[((Weapon *)junk)->getType()]._weight;
+		weight = _weaponInfo[((Weapon *)junk)->getType()]._weight;
 		break;
 	case k6_ArmourThingType:
-		weight = g239_ArmourInfo[((Armour *)junk)->getType()]._weight;
+		weight = _armourInfo[((Armour *)junk)->getType()]._weight;
 		break;
 	case k10_JunkThingType:
 		weight = junkInfo[junk->getType()];
@@ -1331,7 +1340,7 @@ void DungeonMan::f163_linkThingToList(Thing thingToLink, Thing thingInList, int1
 
 WeaponInfo* DungeonMan::f158_getWeaponInfo(Thing thing) {
 	Weapon* weapon = (Weapon*)f156_getThingData(thing);
-	return &g238_WeaponInfo[weapon->getType()];
+	return &_weaponInfo[weapon->getType()];
 }
 
 int16 DungeonMan::f142_getProjectileAspect(Thing thing) {
@@ -1354,7 +1363,7 @@ int16 DungeonMan::f142_getProjectileAspect(Thing thing) {
 			return -projAspOrd;
 	}
 
-	return g237_ObjectInfo[f141_getObjectInfoIndex(thing)]._objectAspectIndex;
+	return _objectInfo[f141_getObjectInfoIndex(thing)]._objectAspectIndex;
 }
 
 int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16* mapX, int16* mapY) {
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index e738723..269dcdf 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -106,15 +106,15 @@ public:
 	uint16 _weight;
 	uint16 _defense;
 	uint16 _attributes;
+
 	ArmourInfo(uint16 weight, uint16 defense, uint16 attributes)
 		:_weight(weight), _defense(defense), _attributes(attributes) {}
+	ArmourInfo() :_weight(0), _defense(0), _attributes(0) {}
 
 	uint16 getAttribute(ArmourAttribute attribute) { return _attributes & attribute; }
 	void setAttribute(ArmourAttribute attribute) { _attributes |= attribute; }
 }; // @ ARMOUR_INFO
 
-extern ArmourInfo g239_ArmourInfo[58]; // G0239_as_Graphic559_ArmourInfo
-
 #define kM1_WeaponClassNone					-1
 /* Class 0: SWING weapons */
 #define k0_WeaponClassSwingWeapon			0 // @ C000_CLASS_SWING_WEAPON 
@@ -143,13 +143,12 @@ private:
 public:
 	WeaponInfo(uint16 weight, uint16 wClass, uint16 strength, uint16 kineticEnergy, uint16 attributes)
 		: _weight(weight), _class(wClass), _strength(strength), _kineticEnergy(kineticEnergy), _attributes(attributes) {}
+	WeaponInfo() : _weight(0), _class(0), _strength(0), _kineticEnergy(0), _attributes(0) {}
 
 	uint16 getShootAttack() { return _attributes & 0xFF; } // @ M65_SHOOT_ATTACK
 	uint16 getProjectileAspectOrdinal() { return (_attributes >> 8) & 0x1F; } // @ M66_PROJECTILE_ASPECT_ORDINAL
 }; // @ WEAPON_INFO
 
-extern WeaponInfo g238_WeaponInfo[46]; // @ G0238_as_Graphic559_WeaponInfo;
-
 enum TextType {
 	/* Used for text on walls */
 	k0_TextTypeInscription = 0, // @ C0_TEXT_TYPE_INSCRIPTION 
@@ -747,7 +746,9 @@ public:
 	Thing _g292_pileTopObject[5]; // @ G0292_aT_PileTopObject
 	DoorInfo _g275_currMapDoorInfo[2]; // @ G0275_as_CurrentMapDoorInfo
 	
-	ObjectInfo g237_ObjectInfo[180]; // @ G0237_as_Graphic559_ObjectInfo
+	ObjectInfo _objectInfo[180]; // @ G0237_as_Graphic559_ObjectInfo
+	ArmourInfo _armourInfo[58]; // @ G0239_as_Graphic559_ArmourInfo
+	WeaponInfo _weaponInfo[46]; // @ G0238_as_Graphic559_WeaponInfo
 
 	void setupArrays();
 };
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index c17eabe..73621ca 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -3102,7 +3102,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 			}
 
 			if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) { /* Square where objects are visible and object is located on cell being processed */
-				objectAspect = &(_objectAspects209[_vm->_dungeonMan->g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thingParam)]._objectAspectIndex]);
+				objectAspect = &(_objectAspects209[_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thingParam)]._objectAspectIndex]);
 				AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex;
 				if (useAlcoveObjectImage = (L0135_B_DrawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane))
 					AL_4_nativeBitmapIndex++;
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 5552da4..a19a71a 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -587,7 +587,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		case k8_PotionThingType: {
 			potentialAttribMask = k0x0001_DescriptionMaskConsumable;
 			Potion *potion = (Potion *)rawThingPtr;
-			actualAttribMask = _vm->_dungeonMan->g237_ObjectInfo[k2_ObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots();
+			actualAttribMask = _vm->_dungeonMan->_objectInfo[k2_ObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots();
 			break;
 		}
 		case k10_JunkThingType: {
@@ -630,7 +630,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 				f335_drawPanelObjectDescriptionString(str);
 			} else {
 				potentialAttribMask = k0x0001_DescriptionMaskConsumable;
-				actualAttribMask = _vm->_dungeonMan->g237_ObjectInfo[k127_ObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots();
+				actualAttribMask = _vm->_dungeonMan->_objectInfo[k127_ObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots();
 			}
 			break;
 		}
@@ -937,7 +937,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 	if (_vm->_championMan->_g299_candidateChampionOrdinal) {
 		return;
 	}
-	if (!getFlag(_vm->_dungeonMan->g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1078_T_Thing = _vm->_championMan->_g414_leaderHandObject)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) {
+	if (!getFlag(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1078_T_Thing = _vm->_championMan->_g414_leaderHandObject)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) {
 		return;
 	}
 	L1079_ui_IconIndex = _vm->_objectMan->f33_getIconIndex(L1078_T_Thing);
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index afd6eb2..d17286f 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -153,7 +153,7 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
 	IconIndice iconIndex;
 	if (thing == Thing::_none) {
 		iconIndex = k201_IconIndiceActionEmptyHand;
-	} else if (_vm->_dungeonMan->g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thing)]._actionSetIndex) {
+	} else if (_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thing)]._actionSetIndex) {
 		iconIndex = _vm->_objectMan->f33_getIconIndex(thing);
 	} else {
 		dm.f134_fillBitmap(bitmapIcon, k4_ColorCyan, 16, 16);
@@ -1038,7 +1038,7 @@ bool MenuMan::f407_isActionPerformed(uint16 champIndex, int16 actionIndex) {
 	int16 L1245_i_Multiple;
 #define AL1245_T_ExplosionThing  L1245_i_Multiple
 #define AL1245_B_ActionPerformed L1245_i_Multiple
-	int16 L1246_i_Multiple;
+	int16 L1246_i_Multiple = 0;
 #define AL1246_i_RequiredManaAmount    L1246_i_Multiple
 #define AL1246_i_ActionHandWeaponClass L1246_i_Multiple
 #define AL1246_i_StepEnergy            L1246_i_Multiple
@@ -1156,7 +1156,7 @@ T0407014:
 	case k32_ChampionActionShoot:
 		if (Thing(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]).getType() != k5_WeaponThingType)
 			goto T0407032;
-		L1256_ps_WeaponInfoActionHand = &g238_WeaponInfo[L1248_ps_Weapon->getType()];
+		L1256_ps_WeaponInfoActionHand = &_vm->_dungeonMan->_weaponInfo[L1248_ps_Weapon->getType()];
 		L1257_ps_WeaponInfoReadyHand = _vm->_dungeonMan->f158_getWeaponInfo(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]);
 		AL1246_i_ActionHandWeaponClass = L1256_ps_WeaponInfoActionHand->_class;
 		AL1250_i_ReadyHandWeaponClass = L1257_ps_WeaponInfoReadyHand->_class;
@@ -1627,7 +1627,7 @@ void MenuMan::f389_processCommands116To119_setActingChampion(uint16 champIndex)
 	}
 	if ((L1189_T_Thing = L1190_ps_Champion->_slots[k1_ChampionSlotActionHand]) == Thing::_none) {
 		L1188_ui_ActionSetIndex = 2; /* Actions Punch, Kick and War Cry */
-	} else if ((L1188_ui_ActionSetIndex = _vm->_dungeonMan->g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1189_T_Thing)]._actionSetIndex) == 0) {
+	} else if ((L1188_ui_ActionSetIndex = _vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1189_T_Thing)]._actionSetIndex) == 0) {
 		return;
 	}
 	L1191_ps_ActionSet = &G0489_as_Graphic560_ActionSets[L1188_ui_ActionSetIndex];
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 3c731d8..debf948 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -130,7 +130,7 @@ IconIndice ObjectMan::f32_getObjectType(Thing thing) {
 
 	int16 objectInfoIndex = _vm->_dungeonMan->f141_getObjectInfoIndex(thing);
 	if (objectInfoIndex != -1) {
-		objectInfoIndex = _vm->_dungeonMan->g237_ObjectInfo[objectInfoIndex]._type;
+		objectInfoIndex = _vm->_dungeonMan->_objectInfo[objectInfoIndex]._type;
 	}
 	return (IconIndice)objectInfoIndex;
 }
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 5e21cbd..95e3165 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -159,7 +159,7 @@ T0217004:
 			((L0510_i_ProjectileAssociatedThingType == k15_ExplosionThingType) ?
 			 (L0486_T_ProjectileAssociatedThing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) :
 			 ((L0490_ps_Projectile->_attack > _vm->getRandomNumber(128)) &&
-			  getFlag(_vm->_dungeonMan->g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0486_T_ProjectileAssociatedThing)].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)
+			  getFlag(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0486_T_ProjectileAssociatedThing)].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)
 			  && ((L0510_i_ProjectileAssociatedThingType != k10_JunkThingType) ||
 			  ((AL0487_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0486_T_ProjectileAssociatedThing)) < 0) ||
 				  (!((AL0487_i_IconIndex >= k176_IconIndiceJunkIronKey) && (AL0487_i_IconIndex <= k191_IconIndiceJunkMasterKey))))


Commit: 92c9c54481b8eccc9454c982976221baa3697704
    https://github.com/scummvm/scummvm/commit/92c9c54481b8eccc9454c982976221baa3697704
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Start refactoring of eventMan

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/inventory.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 79840fa..2af6889 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -867,8 +867,8 @@ void ChampionMan::f314_wakeUp() {
 	_vm->_displayMan->f98_drawFloorAndCeiling();
 	_vm->_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface;
 	_vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
-	_vm->_eventMan->_g443_primaryKeyboardInput = g458_primaryKeyboardInput_interface;
-	_vm->_eventMan->_g444_secondaryKeyboardInput = g459_secondaryKeyboardInput_movement;
+	_vm->_eventMan->_g443_primaryKeyboardInput = _vm->_eventMan->g458_primaryKeyboardInput_interface;
+	_vm->_eventMan->_g444_secondaryKeyboardInput = _vm->_eventMan->g459_secondaryKeyboardInput_movement;
 	_vm->_eventMan->f357_discardAllInput();
 	_vm->_menuMan->f457_drawEnabledMenus();
 }
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index fa35035..43f9c27 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -351,8 +351,8 @@ void DMEngine::f462_startGame() {
 
 	_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface;
 	_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
-	_eventMan->_g443_primaryKeyboardInput = g458_primaryKeyboardInput_interface;
-	_eventMan->_g444_secondaryKeyboardInput = g459_secondaryKeyboardInput_movement;
+	_eventMan->_g443_primaryKeyboardInput = _eventMan->g458_primaryKeyboardInput_interface;
+	_eventMan->_g444_secondaryKeyboardInput = _eventMan->g459_secondaryKeyboardInput_movement;
 
 	f3_processNewPartyMap(_dungeonMan->_g309_partyMapIndex);
 
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index f9ce68b..c0e3ff2 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -43,48 +43,6 @@
 
 
 namespace DM {
-KeyboardInput g458_primaryKeyboardInput_interface[7] = { // @ G0458_as_Graphic561_PrimaryKeyboardInput_Interface
-														 /* { Command, Code } */
-	KeyboardInput(k7_CommandToggleInventoryChampion_0, Common::KEYCODE_F1, 0), /* F1 (<CSI>1~) Atari ST: Code = 0x3B00 */
-	KeyboardInput(k8_CommandToggleInventoryChampion_1, Common::KEYCODE_F2, 0), /* F2 (<CSI>2~) Atari ST: Code = 0x3C00 */
-	KeyboardInput(k9_CommandToggleInventoryChampion_2, Common::KEYCODE_F3, 0), /* F3 (<CSI>3~) Atari ST: Code = 0x3D00 */
-	KeyboardInput(k10_CommandToggleInventoryChampion_3, Common::KEYCODE_F4, 0), /* F4 (<CSI>4~) Atari ST: Code = 0x3E00 */
-	KeyboardInput(k140_CommandSaveGame, Common::KEYCODE_s, Common::KBD_CTRL), /* CTRL-S       Atari ST: Code = 0x0013 */
-	KeyboardInput(k147_CommandFreezeGame, Common::KEYCODE_ESCAPE, 0), /* Esc (0x1B)   Atari ST: Code = 0x001B */
-	KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)};
-
-
-KeyboardInput g459_secondaryKeyboardInput_movement[19] = { // @ G0459_as_Graphic561_SecondaryKeyboardInput_Movement
-														   /* { Command, Code } */
-	KeyboardInput(k1_CommandTurnLeft, Common::KEYCODE_KP4, 0), /* Numeric pad 4 Atari ST: Code = 0x5200 */
-	KeyboardInput(k3_CommandMoveForward, Common::KEYCODE_KP5, 0), /* Numeric pad 5 Atari ST: Code = 0x4800 */
-	KeyboardInput(k2_CommandTurnRight, Common::KEYCODE_KP6, 0), /* Numeric pad 6 Atari ST: Code = 0x4700 */
-	KeyboardInput(k6_CommandMoveLeft, Common::KEYCODE_KP1, 0), /* Numeric pad 1 Atari ST: Code = 0x4B00 */
-	KeyboardInput(k5_CommandMoveBackward, Common::KEYCODE_KP2, 0), /* Numeric pad 2 Atari ST: Code = 0x5000 */
-	KeyboardInput(k4_CommandMoveRight, Common::KEYCODE_KP3, 0), /* Numeric pad 3 Atari ST: Code = 0x4D00. Remaining entries below not present */
-	KeyboardInput(k3_CommandMoveForward, Common::KEYCODE_w, 0), /* Up Arrow (<CSI>A) */ /*Differs for testing convenience*/
-	KeyboardInput(k3_CommandMoveForward, Common::KEYCODE_w, Common::KBD_SHIFT), /* Shift Up Arrow (<CSI>T) */ /*Differs for testing convenience*/
-	KeyboardInput(k6_CommandMoveLeft, Common::KEYCODE_a, 0), /* Backward Arrow (<CSI>D) */ /*Differs for testing convenience*/
-	KeyboardInput(k6_CommandMoveLeft, Common::KEYCODE_a, Common::KBD_SHIFT), /* Shift Forward Arrow (<CSI> A) */ /*Differs for testing convenience*/
-	KeyboardInput(k4_CommandMoveRight, Common::KEYCODE_d, 0), /* Forward Arrow (<CSI>C) */ /*Differs for testing convenience*/
-	KeyboardInput(k4_CommandMoveRight, Common::KEYCODE_d, Common::KBD_SHIFT), /* Shift Backward Arrow (<CSI> @) */ /*Differs for testing convenience*/
-	KeyboardInput(k5_CommandMoveBackward, Common::KEYCODE_s, 0), /* Down arrow (<CSI>B) */ /*Differs for testing convenience*/
-	KeyboardInput(k5_CommandMoveBackward, Common::KEYCODE_s, Common::KBD_SHIFT), /* Shift Down arrow (<CSI>S) */ /*Differs for testing convenience*/
-	KeyboardInput(k1_CommandTurnLeft, Common::KEYCODE_q, 0), /* Del (0x7F) */ /*Differs for testing convenience*/
-	KeyboardInput(k1_CommandTurnLeft, Common::KEYCODE_q, Common::KBD_SHIFT), /* Shift Del (0x7F) */ /*Differs for testing convenience*/
-	KeyboardInput(k2_CommandTurnRight, Common::KEYCODE_e, 0), /* Help (<CSI>?~) */ /*Differs for testing convenience*/
-	KeyboardInput(k2_CommandTurnRight, Common::KEYCODE_e, Common::KBD_SHIFT), /* Shift Help (<CSI>?~) */ /*Differs for testing convenience*/
-	KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)};
-KeyboardInput g460_primaryKeyboardInput_partySleeping[3] = { // @ G0460_as_Graphic561_PrimaryKeyboardInput_PartySleeping
-															 /* { Command, Code } */
-	KeyboardInput(k146_CommandWakeUp, Common::KEYCODE_RETURN, 0), /* Return */
-	KeyboardInput(k147_CommandFreezeGame, Common::KEYCODE_ESCAPE, 0), /* Esc */
-	KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)};
-KeyboardInput g461_primaryKeyboardInput_frozenGame[2] = { // @ G0461_as_Graphic561_PrimaryKeyboardInput_FrozenGame
-														  /* { Command, Code } */
-	KeyboardInput(k148_CommandUnfreezeGame, Common::KEYCODE_ESCAPE, 0), /* Esc */
-	KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)};
-
 
 MouseInput g445_PrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
 												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
@@ -286,7 +244,65 @@ MouseInput* g480_PrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryM
 	g477_PrimaryMouseInput_ScreenDialog3Choices,
 	g478_PrimaryMouseInput_ScreenDialog4Choices},};
 
+void EventManager::initArrays() {
+	KeyboardInput primaryKeyboardInputInterface[7] = { // @ G0458_as_Graphic561_PrimaryKeyboardInput_Interface
+		/* { Command, Code } */
+		KeyboardInput(k7_CommandToggleInventoryChampion_0, Common::KEYCODE_F1, 0), /* F1 (<CSI>1~) Atari ST: Code = 0x3B00 */
+		KeyboardInput(k8_CommandToggleInventoryChampion_1, Common::KEYCODE_F2, 0), /* F2 (<CSI>2~) Atari ST: Code = 0x3C00 */
+		KeyboardInput(k9_CommandToggleInventoryChampion_2, Common::KEYCODE_F3, 0), /* F3 (<CSI>3~) Atari ST: Code = 0x3D00 */
+		KeyboardInput(k10_CommandToggleInventoryChampion_3, Common::KEYCODE_F4, 0), /* F4 (<CSI>4~) Atari ST: Code = 0x3E00 */
+		KeyboardInput(k140_CommandSaveGame, Common::KEYCODE_s, Common::KBD_CTRL), /* CTRL-S       Atari ST: Code = 0x0013 */
+		KeyboardInput(k147_CommandFreezeGame, Common::KEYCODE_ESCAPE, 0), /* Esc (0x1B)   Atari ST: Code = 0x001B */
+		KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)
+	};
+
+	KeyboardInput secondaryKeyboardInputMovement[19] = { // @ G0459_as_Graphic561_SecondaryKeyboardInput_Movement
+		/* { Command, Code } */
+		KeyboardInput(k1_CommandTurnLeft, Common::KEYCODE_KP4, 0), /* Numeric pad 4 Atari ST: Code = 0x5200 */
+		KeyboardInput(k3_CommandMoveForward, Common::KEYCODE_KP5, 0), /* Numeric pad 5 Atari ST: Code = 0x4800 */
+		KeyboardInput(k2_CommandTurnRight, Common::KEYCODE_KP6, 0), /* Numeric pad 6 Atari ST: Code = 0x4700 */
+		KeyboardInput(k6_CommandMoveLeft, Common::KEYCODE_KP1, 0), /* Numeric pad 1 Atari ST: Code = 0x4B00 */
+		KeyboardInput(k5_CommandMoveBackward, Common::KEYCODE_KP2, 0), /* Numeric pad 2 Atari ST: Code = 0x5000 */
+		KeyboardInput(k4_CommandMoveRight, Common::KEYCODE_KP3, 0), /* Numeric pad 3 Atari ST: Code = 0x4D00. Remaining entries below not present */
+		KeyboardInput(k3_CommandMoveForward, Common::KEYCODE_w, 0), /* Up Arrow (<CSI>A) */ /*Differs for testing convenience*/
+		KeyboardInput(k3_CommandMoveForward, Common::KEYCODE_w, Common::KBD_SHIFT), /* Shift Up Arrow (<CSI>T) */ /*Differs for testing convenience*/
+		KeyboardInput(k6_CommandMoveLeft, Common::KEYCODE_a, 0), /* Backward Arrow (<CSI>D) */ /*Differs for testing convenience*/
+		KeyboardInput(k6_CommandMoveLeft, Common::KEYCODE_a, Common::KBD_SHIFT), /* Shift Forward Arrow (<CSI> A) */ /*Differs for testing convenience*/
+		KeyboardInput(k4_CommandMoveRight, Common::KEYCODE_d, 0), /* Forward Arrow (<CSI>C) */ /*Differs for testing convenience*/
+		KeyboardInput(k4_CommandMoveRight, Common::KEYCODE_d, Common::KBD_SHIFT), /* Shift Backward Arrow (<CSI> @) */ /*Differs for testing convenience*/
+		KeyboardInput(k5_CommandMoveBackward, Common::KEYCODE_s, 0), /* Down arrow (<CSI>B) */ /*Differs for testing convenience*/
+		KeyboardInput(k5_CommandMoveBackward, Common::KEYCODE_s, Common::KBD_SHIFT), /* Shift Down arrow (<CSI>S) */ /*Differs for testing convenience*/
+		KeyboardInput(k1_CommandTurnLeft, Common::KEYCODE_q, 0), /* Del (0x7F) */ /*Differs for testing convenience*/
+		KeyboardInput(k1_CommandTurnLeft, Common::KEYCODE_q, Common::KBD_SHIFT), /* Shift Del (0x7F) */ /*Differs for testing convenience*/
+		KeyboardInput(k2_CommandTurnRight, Common::KEYCODE_e, 0), /* Help (<CSI>?~) */ /*Differs for testing convenience*/
+		KeyboardInput(k2_CommandTurnRight, Common::KEYCODE_e, Common::KBD_SHIFT), /* Shift Help (<CSI>?~) */ /*Differs for testing convenience*/
+		KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)
+	};
+	KeyboardInput primaryKeyboardInputPartySleeping[3] = { // @ G0460_as_Graphic561_PrimaryKeyboardInput_PartySleeping
+		/* { Command, Code } */
+		KeyboardInput(k146_CommandWakeUp, Common::KEYCODE_RETURN, 0), /* Return */
+		KeyboardInput(k147_CommandFreezeGame, Common::KEYCODE_ESCAPE, 0), /* Esc */
+		KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)
+	};
+	KeyboardInput primaryKeyboardInputFrozenGame[2] = { // @ G0461_as_Graphic561_PrimaryKeyboardInput_FrozenGame
+		/* { Command, Code } */
+		KeyboardInput(k148_CommandUnfreezeGame, Common::KEYCODE_ESCAPE, 0), /* Esc */
+		KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)
+	};
+
+	for (int i = 0; i < 7; i++)
+		g458_primaryKeyboardInput_interface[i] = primaryKeyboardInputInterface[i];
+
+	for (int i = 0; i < 19; i++)
+		g459_secondaryKeyboardInput_movement[i] = secondaryKeyboardInputMovement[i];
+
+	for (int i = 0; i < 3 ; i++)
+		g460_primaryKeyboardInput_partySleeping[i] = primaryKeyboardInputPartySleeping[i];
 
+	for (int i = 0; i < 2; i++)
+		g461_primaryKeyboardInput_frozenGame[i] = primaryKeyboardInputFrozenGame[i];
+
+}
 EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 	_mousePos = Common::Point(0, 0);
 	_dummyMapIndex = 0;
@@ -315,6 +331,8 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 	_g587_hideMousePointerRequestCount = 0;
 	_g558_mouseButtonStatus = 0;
 	_highlightScreenBox.setToZero();
+
+	initArrays();
 }
 
 EventManager::~EventManager() {
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 7dfd5ac..9741fd3 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -208,16 +208,9 @@ public:
 	byte _modifiers;
 
 	KeyboardInput(CommandType command, Common::KeyCode keycode, byte modifierFlags) : _commandToIssue(command), _key(keycode), _modifiers(modifierFlags) {}
+	KeyboardInput() : _commandToIssue(k0_CommandNone), _key(Common::KEYCODE_ESCAPE), _modifiers(0) {}
 }; // @ KEYBOARD_INPUT
 
-
-
-extern KeyboardInput g458_primaryKeyboardInput_interface[7];
-extern KeyboardInput g459_secondaryKeyboardInput_movement[19];
-extern KeyboardInput g460_primaryKeyboardInput_partySleeping[3];
-extern KeyboardInput g461_primaryKeyboardInput_frozenGame[2];
-
-
 class DMEngine;
 
 #define k0_pointerArrow 0 // @ C0_POINTER_ARROW 
@@ -323,6 +316,14 @@ public:
 	void f362_commandHighlightBoxEnable(int16 x1, int16 x2, int16 y1, int16 y2); // @ F0362_COMMAND_HighlightBoxEnable
 	void f363_highlightBoxDisable(); // @ F0363_COMMAND_HighlightBoxDisable
 	void f6_highlightScreenBox(int16 x1, int16 x2, int16 y1, int16 y2) { warning(false, "STUB METHOD: f6_highlightScreenBox"); } // @  F0006_MAIN_HighlightScreenBox
+
+
+	KeyboardInput g458_primaryKeyboardInput_interface[7]; // @ G0458_as_Graphic561_PrimaryKeyboardInput_Interface
+	KeyboardInput g459_secondaryKeyboardInput_movement[19]; // @ G0459_as_Graphic561_SecondaryKeyboardInput_Movement
+	KeyboardInput g460_primaryKeyboardInput_partySleeping[3]; // @ G0460_as_Graphic561_PrimaryKeyboardInput_PartySleeping
+	KeyboardInput g461_primaryKeyboardInput_frozenGame[2]; // @ G0461_as_Graphic561_PrimaryKeyboardInput_FrozenGame
+
+	void initArrays();
 };
 
 }
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index a19a71a..dc6b6a1 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -126,7 +126,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 			_vm->_menuMan->f395_drawMovementArrows();
 			_vm->_eventMan->f77_hideMouse();
 			_vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
-			_vm->_eventMan->_g444_secondaryKeyboardInput = g459_secondaryKeyboardInput_movement;
+			_vm->_eventMan->_g444_secondaryKeyboardInput = _vm->_eventMan->g459_secondaryKeyboardInput_movement;
 			_vm->_eventMan->f357_discardAllInput();
 			_vm->_displayMan->f98_drawFloorAndCeiling();
 			return;


Commit: d85970b4e47d05db625eccd04646514d47b8e5fe
    https://github.com/scummvm/scummvm/commit/d85970b4e47d05db625eccd04646514d47b8e5fe
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix releasing flagged bitmaps

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 73621ca..6060d9f 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -3740,6 +3740,7 @@ byte* DisplayMan::f492_getDerivedBitmap(int16 derivedBitmapIndex) {
 void DisplayMan::f493_addDerivedBitmap(int16 derivedBitmapIndex) {}
 
 void DisplayMan::f480_releaseBlock(uint16 index) {
+	index &= ~0x8000;
 	delete[] _g638_derivedBitmaps[index];
 	_g638_derivedBitmaps[index] = nullptr;
 }


Commit: ca267da97c14268f8c650d7dac727182062129d0
    https://github.com/scummvm/scummvm/commit/ca267da97c14268f8c650d7dac727182062129d0
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add file error checking for save game

Changed paths:
    engines/dm/dm.h
    engines/dm/loadsave.cpp



diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index d90943b..edc54c1 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -209,7 +209,7 @@ class DMEngine : public Engine {
 	void initArrays();
 	Common::String getSavefileName(uint16 slot);
 	void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
-	void writeCompleteSaveFile(int16 slot, Common::String &desc, int16 saveAndPlayChoice);
+	bool writeCompleteSaveFile(int16 slot, Common::String &desc, int16 saveAndPlayChoice);
 	void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance
 public:
 	explicit DMEngine(OSystem *syst, const ADGameDescription *gameDesc);
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 02f1a80..a84a0b6 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -240,7 +240,10 @@ void DMEngine::f433_processCommand140_saveGame() {
 				_championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load -= champHandObjWeight;
 			}
 
-			writeCompleteSaveFile(saveSlot, saveDescription, saveAndPlayChoice);
+			if (!writeCompleteSaveFile(saveSlot, saveDescription, saveAndPlayChoice)) {
+				_dialog->f427_dialogDraw(nullptr, "Unable to open file for saving", "OK", nullptr, nullptr, nullptr, false, false, false);
+				_dialog->f424_dialogGetChoice(1, k0_DIALOG_SET_VIEWPORT, 0, k0_DIALOG_CHOICE_NONE);
+			}
 
 			if (!_championMan->_g415_leaderEmptyHanded) {
 				_championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load += champHandObjWeight;
@@ -296,13 +299,14 @@ void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::Strin
 	out->writeUint32BE(playTime);
 }
 
-void DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescription, int16 saveAndPlayChoice) {
+bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescription, int16 saveAndPlayChoice) {
 	Common::String savefileName = getSavefileName(saveSlot);
 	Common::SaveFileManager *saveFileManager = _system->getSavefileManager();
 	Common::OutSaveFile *file = saveFileManager->openForSaving(savefileName);
 
-	if (!file)
-		return; // TODO: silent fail
+	if (!file) {
+		return false;
+	}
 
 	writeSaveGameHeader(file, saveDescription);
 
@@ -409,6 +413,8 @@ void DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 	file->flush();
 	file->finalize();
 	delete file;
+	
+	return true;
 }
 
 bool readSaveGameHeader(Common::InSaveFile* in, SaveGameHeader* header) {


Commit: d97a8905cc18ccf9d036f7708d8e2cf8dfba6067
    https://github.com/scummvm/scummvm/commit/d97a8905cc18ccf9d036f7708d8e2cf8dfba6067
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Remove some warnings

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/group.cpp
    engines/dm/group.h
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 2af6889..6359f42 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1449,7 +1449,6 @@ void ChampionMan::f319_championKill(uint16 champIndex) {
 	if (_vm->M0_indexToOrdinal(curChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
 		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
 		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
-		warning(false, "IGNORED CODE:G0592_B_BuildMousePointerScreenAreaRequested = true");
 	}
 
 	if (curChampion->_poisonEventCount)
@@ -2052,7 +2051,6 @@ uint16 ChampionMan::f306_getStaminaAdjustedValue(Champion *champ, int16 val) {
 	int16 currStamina = champ->_currStamina;
 	int16 halfMaxStamina = champ->_maxStamina / 2;
 	if (currStamina < halfMaxStamina) {
-		warning(false, "Possible undefined behavior in the original code");
 		val /= 2;
 		return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina;
 	}
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 43f9c27..bdbbb1b 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -147,16 +147,6 @@ int16 M38_distance(int16 mapx1, int16 mapy1, int16 mapx2, int16 mapy2) {
 }
 
 DMEngine::DMEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst), _console(nullptr), _gameVersion(desc) {
-// Do not load data files
-// Do not initialize graphics here
-// Do not initialize audio devices here
-// Do these from run
-
-//Specify all default directories
-//const Common::FSNode gameDataDir(ConfMan.get("example"));
-//SearchMan.addSubDirectoryMatching(gameDataDir, "example2");
-	DebugMan.addDebugChannel(kDMDebugExample, "example", "example desc");
-
 	// register random source
 	_rnd = new Common::RandomSource("dm");
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index edc54c1..20b7bf8 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -166,14 +166,6 @@ enum Cell {
 #define k255_mapIndexEntrance 255 // @ C255_MAP_INDEX_ENTRANCE 
 
 
-enum {
-	// engine debug channels
-	kDMDebugExample = 1 << 0,
-	kDMDebugUselessCode = 1 << 1,
-	kDMDebugOftenCalledWarning = 2 << 2
-};
-
-
 
 //TODO: Directly use CLIP
 template<typename T>
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index c0e3ff2..805e5c9 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -399,14 +399,6 @@ void EventManager::f68_setPointerToObject(byte* bitmap) {
 	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, palChangesMousePointerIcon);
 	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, boxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
 
-
-	/*
-	warning(false, "TODO - Call f129_blitToBitmapShrinkWithPalChange");
-	// dummy code
-	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, boxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
-	_vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, boxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
-	*/
-
 	_gK100_preventBuildPointerScreenArea = false;
 	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
 }
@@ -464,9 +456,6 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY)
 		0x07, 0xFF, 0x00, 0x00, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 	};
 
-	// if (_gK100_preventBuildPointerScreenArea)
-	//	return;
-
 	_gK100_preventBuildPointerScreenArea = true;
 	if (_g599_useChampionIconOrdinalAsMousePointerBitmap) {
 		if ((mousePosY > 28) || (mousePosX < 274)) {
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 6060d9f..07b3b61 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2738,14 +2738,16 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
 													  int16 srcPixelWidth, int16 srcHeight,
 													  int16 destPixelWidth, int16 destHeight, byte *palChange) {
+	warning(false, "DUMMY CODE: f129_blitToBitmapShrinkWithPalChange");
+	warning(false, "MISSING CODE: No palette change takes place in f129_blitToBitmapShrinkWithPalChange");
+
+
 	if (destPixelWidth % 8)
 		destPixelWidth = (destPixelWidth / 8) * 8 + 8;
 
 	uint32 scaleX = (kScaleThreshold * srcPixelWidth) / destPixelWidth;
 	uint32 scaleY = (kScaleThreshold * srcHeight) / destHeight;
 
-	warning(false, "MISSING CODE: No palette change takes place in f129_blitToBitmapShrinkWithPalChange");
-
 	// Loop through drawing output lines
 	for (uint32 destY = 0, scaleYCtr = 0; destY < (uint32)destHeight; ++destY, scaleYCtr += scaleY) {
 
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index a66ca05..5bd4539 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -63,6 +63,7 @@ GroupMan::GroupMan(DMEngine *vm) : _vm(vm) {
 	_g376_maxActiveGroupCount = 60;
 	_g375_activeGroups = nullptr;
 	_g377_currActiveGroupCount = 0;
+	_g395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime = 0;
 }
 
 GroupMan::~GroupMan() {
@@ -1342,11 +1343,9 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 
 void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) {
 	uint16 L0435_ui_GroupDirections;
-	static int32 G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime; /* These two variables are used to prevent setting direction of half square sized creatures twice at the same game time */
 	static ActiveGroup *G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup;
 
-	warning(false, "TODO: Move G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime to GroupMan so it's properly initialized");
-	if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) {
+	if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == _g395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) {
 		return;
 	}
 	if (M21_normalizeModulo4(M50_getCreatureValue(L0435_ui_GroupDirections = activeGroup->_directions, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */
@@ -1356,7 +1355,7 @@ void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 crea
 	}
 	if (twoHalfSquareSizedCreatures) {
 		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex ^ 1, dir); /* Set direction of the second half square sized creature */
-		G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime = _vm->_g313_gameTime;
+		_g395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime = _vm->_g313_gameTime;
 		G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup = activeGroup;
 	}
 	activeGroup->_directions = (Direction)L0435_ui_GroupDirections;
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 804b562..8fe1eba 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -171,6 +171,7 @@ class GroupMan {
 	bool _g389_groupMovementBlockedByDoor; // @ G0389_B_GroupMovementBlockedByDoor
 	bool _g390_groupMovementBlockedByParty; // @ G0390_B_GroupMovementBlockedByParty
 	bool _g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter; // @ G0387_B_GroupMovementBlockedByWallStairsPitFakeWallFluxcageTeleporter
+	int32 _g395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime; // @ G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime
 public:
 	uint16 _g376_maxActiveGroupCount; // @ G0376_ui_MaximumActiveGroupCount
 	ActiveGroup *_g375_activeGroups; // @ G0375_ps_ActiveGroups
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index dc6b6a1..3d0415e 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -303,7 +303,6 @@ void InventoryMan::f334_closeChest() {
 }
 
 void InventoryMan::f340_drawPanelScrollTextLine(int16 yPos, char* text) {
-	warning(false, "CHANGE5_03_IMPROVEMENT");
 	for (char* iter = text; *iter != '\0'; ++iter) {
 		if ((*iter >= 'A') && (*iter <= 'Z')) {
 			*iter -= 64;
@@ -330,7 +329,6 @@ void InventoryMan::f341_drawPanelScroll(Scroll* scroll) {
 	charRed++;
 	char *charGreen = charRed; // first char of the second line
 	while (*charGreen) {
-		warning(false, "BUG0_47");
 		/* BUG0_47 Graphical glitch when you open a scroll. If there is a single line of text in a scroll
 		(with no carriage return) then charGreen points to undefined data. This may result in a graphical
 		glitch and also corrupt other memory. This is not an issue in the original dungeons where all
@@ -369,7 +367,6 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo
 	if (_g426_openChest == thingToOpen)
 		return;
 
-	warning(false, "CHANGE8_09_FIX");
 	if (_g426_openChest != Thing::_none)
 		f334_closeChest(); // CHANGE8_09_FIX
 
@@ -383,7 +380,6 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo
 	Thing thing = chest->getSlot();
 	int16 thingCount = 0;
 	while (thing != Thing::_endOfList) {
-		warning(false, "CHANGE8_08_FIX");
 		if (++thingCount > 8)
 			break; // CHANGE8_08_FIX, make sure that no more than the first 8 objects in a chest are drawn
 
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index a84a0b6..7857d49 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -79,19 +79,11 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		_championMan->_g414_leaderHandObject = Thing::_none;
 		_g525_gameId = ((int32)getRandomNumber(65536)) * getRandomNumber(65536);
 	} else {
-		warning(false, "MISSING CODE: missing check for matching _g525_gameId in f435_loadgame");
-		/*if (_vm->_g523_restartGameRequest && (L1372_s_SaveHeader.GameID != _vm->_g525_gameId)) {
-			L1367_pc_Message = G0546_pc_THATSNOTTHESAMEGAME;
-			goto T0435004;
-		}*/
-
-
 		SaveGameHeader header;
 		readSaveGameHeader(file, &header);
 
 		warning(false, "MISSING CODE: missing check for matching format and platform in save in f435_loadgame");
 
-
 		dmSaveHeader._saveFormat = file->readSint16BE();
 		dmSaveHeader._saveAndPlayChoice = file->readSint16BE();
 		dmSaveHeader._gameId = file->readSint32BE();
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index d17286f..c60fb79 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -880,7 +880,6 @@ bool MenuMan::f391_didClickTriggerAction(int16 actionListIndex) {
 
 	L1199_ps_Champion = &_vm->_championMan->_gK71_champions[L1196_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)];
 	if (actionListIndex == -1) {
-		warning(false, "possible bug in f391_didClickTriggerAction");
 		// L1198_B_ClickTriggeredAction is set to -1 since booleans are stored in int16 in the original
 		L1198_B_ClickTriggeredAction = true;
 	} else {


Commit: c469c7282468ed59744c2de2855a12086a0ad451
    https://github.com/scummvm/scummvm/commit/c469c7282468ed59744c2de2855a12086a0ad451
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Move some more globals

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 6359f42..1a7d229 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -41,8 +41,6 @@
 
 namespace DM {
 
-int16 g39_LightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100};
-
 uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
 						   /* 30 for champion inventory, 8 for chest */
 	0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
@@ -100,6 +98,7 @@ void ChampionMan::initConstants() {
 	};
 
 	static Color championColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14};
+	int16 lightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100};
 
 	const char **g417_byLanguage;
 	switch (_vm->getGameLanguage()) { // localized
@@ -121,6 +120,10 @@ void ChampionMan::initConstants() {
 		_championColor[i] = championColor[i];
 		_boxChampionIcons[i] = boxChampionIcons[i];
 	}
+
+	for (int i = 0; i < 16; i++)
+		_lightPowerToLightAmount[i] = lightPowerToLightAmount[i];
+
 }
 
 ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
@@ -530,7 +533,7 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 	} else if (slotIndex == k10_ChampionSlotNeck) {
 		if ((iconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (iconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
 			((Junk *)rawObjPtr)->setChargeCount(1);
-			_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2];
+			_g407_party._magicalLightAmount += _lightPowerToLightAmount[2];
 			_vm->_inventoryMan->f337_setDungeonViewPalette();
 			iconIndex = (IconIndice)(iconIndex + 1);
 		} else if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
@@ -647,7 +650,7 @@ Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotI
 	if (slotIndex == k10_ChampionSlotNeck) {
 		if ((curIconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (curIconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
 			((Junk *)curWeapon)->setChargeCount(0);
-			_g407_party._magicalLightAmount -= g39_LightPowerToLightAmount[2];
+			_g407_party._magicalLightAmount -= _lightPowerToLightAmount[2];
 			_vm->_inventoryMan->f337_setDungeonViewPalette();
 		} else if ((curIconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (curIconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
 			((Junk *)curWeapon)->setChargeCount(0);
@@ -865,10 +868,10 @@ void ChampionMan::f314_wakeUp() {
 	_vm->_g318_waitForInputMaxVerticalBlankCount = 10;
 	_vm->f22_delay(10);
 	_vm->_displayMan->f98_drawFloorAndCeiling();
-	_vm->_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface;
+	_vm->_eventMan->_g441_primaryMouseInput = _vm->_eventMan->_primaryMouseInputInterface;
 	_vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
-	_vm->_eventMan->_g443_primaryKeyboardInput = _vm->_eventMan->g458_primaryKeyboardInput_interface;
-	_vm->_eventMan->_g444_secondaryKeyboardInput = _vm->_eventMan->g459_secondaryKeyboardInput_movement;
+	_vm->_eventMan->_g443_primaryKeyboardInput = _vm->_eventMan->_primaryKeyboardInputInterface;
+	_vm->_eventMan->_g444_secondaryKeyboardInput = _vm->_eventMan->_secondaryKeyboardInputMovement;
 	_vm->_eventMan->f357_discardAllInput();
 	_vm->_menuMan->f457_drawEnabledMenus();
 }
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 33e2c62..af039b7 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -38,8 +38,6 @@ namespace DM {
 #define k0x4000_IgnoreObjectModifiers 0x4000 // @ MASK0x4000_IGNORE_OBJECT_MODIFIERS     
 #define k0x8000_IgnoreTemporaryExperience 0x8000 // @ MASK0x8000_IGNORE_TEMPORARY_EXPERIENCE 
 
-extern int16 g39_LightPowerToLightAmount[16]; // @ G0039_ai_Graphic562_LightPowerToLightAmount
-
 class Scent {
 	uint16 _scent;
 public:
@@ -591,6 +589,7 @@ public:
 
 	Box _boxChampionIcons[4];
 	Color _championColor[4];
+	int16 _lightPowerToLightAmount[16]; // g039_LightPowerToLightAmount
 };
 
 }
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index bdbbb1b..7f3d608 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -339,10 +339,10 @@ void DMEngine::f462_startGame() {
 	_menuMan->_g509_actionAreaContainsIcons = true;
 	_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = M0_indexToOrdinal(kM1_ChampionNone);
 
-	_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface;
+	_eventMan->_g441_primaryMouseInput = _eventMan->_primaryMouseInputInterface;
 	_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
-	_eventMan->_g443_primaryKeyboardInput = _eventMan->g458_primaryKeyboardInput_interface;
-	_eventMan->_g444_secondaryKeyboardInput = _eventMan->g459_secondaryKeyboardInput_movement;
+	_eventMan->_g443_primaryKeyboardInput = _eventMan->_primaryKeyboardInputInterface;
+	_eventMan->_g444_secondaryKeyboardInput = _eventMan->_secondaryKeyboardInputMovement;
 
 	f3_processNewPartyMap(_dungeonMan->_g309_partyMapIndex);
 
@@ -538,7 +538,7 @@ int16 DMEngine::M0_indexToOrdinal(int16 val) {
 }
 
 void DMEngine::f441_processEntrance() {
-	_eventMan->_g441_primaryMouseInput = g445_PrimaryMouseInput_Entrance;
+	_eventMan->_g441_primaryMouseInput = _eventMan->_primaryMouseInputEntrance;
 	_eventMan->_g442_secondaryMouseInput = nullptr;
 	_eventMan->_g443_primaryKeyboardInput = nullptr;
 	_eventMan->_g444_secondaryKeyboardInput = nullptr;
@@ -723,7 +723,7 @@ T0444017:
 
 			curPalette[1] = D03_RGB_PINK;
 			curPalette[4] = D09_RGB_WHITE;
-			_eventMan->_g441_primaryMouseInput = g446_PrimaryMouseInput_RestartGame;
+			_eventMan->_g441_primaryMouseInput = _eventMan->_primaryMouseInputRestartGame;
 			_eventMan->f357_discardAllInput();
 			_eventMan->f77_hideMouse();
 			_displayMan->f436_STARTEND_FadeToPalette(curPalette);
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 805e5c9..79475ad 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -44,39 +44,6 @@
 
 namespace DM {
 
-MouseInput g445_PrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
-												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(k200_CommandEntranceEnterDungeon, 244, 298,  45,  58, k1_LeftMouseButton),
-	// Strangerke - C201_COMMAND_ENTRANCE_RESUME isn't present in the demo
-	MouseInput(k201_CommandEntranceResume,        244, 298,  76,  93, k1_LeftMouseButton),
-	MouseInput(k202_CommandEntranceDrawCredits,  248, 293, 187, 199, k1_LeftMouseButton),
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g446_PrimaryMouseInput_RestartGame[2] = { // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
-													 /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(k215_CommandRestartGame, 103, 217, 145, 159, k1_LeftMouseButton),
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g447_PrimaryMouseInput_Interface[20] = { // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
-													/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(k12_CommandClickInChampion_0_StatusBox,       0,  42,   0,  28, k1_LeftMouseButton),
-	MouseInput(k13_CommandClickInChampion_1_StatusBox,      69, 111,   0,  28, k1_LeftMouseButton),
-	MouseInput(k14_CommandClickInChampion_2_StatusBox,     138, 180,   0,  28, k1_LeftMouseButton),
-	MouseInput(k15_CommandClickInChampion_3_StatusBox,     207, 249,   0,  28, k1_LeftMouseButton),
-	MouseInput(k125_CommandClickOnChamptionIcon_Top_Left,    274, 299,   0,  13, k1_LeftMouseButton),
-	MouseInput(k126_CommandClickOnChamptionIcon_Top_Right,   301, 319,   0,  13, k1_LeftMouseButton),
-	MouseInput(k127_CommandClickOnChamptionIcon_Lower_Right, 301, 319,  15,  28, k1_LeftMouseButton),
-	MouseInput(k128_CommandClickOnChamptionIcon_Lower_Left,  274, 299,  15,  28, k1_LeftMouseButton),
-	MouseInput(k7_CommandToggleInventoryChampion_0,         43,  66,   0,  28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 =  44. swapped with 4 next entries */
-	MouseInput(k8_CommandToggleInventoryChampion_1,        112, 135,   0,  28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 113. swapped with 4 next entries */
-	MouseInput(k9_CommandToggleInventoryChampion_2,        181, 204,   0,  28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 182. swapped with 4 next entries */
-	MouseInput(k10_CommandToggleInventoryChampion_3,        250, 273,   0,  28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 251. swapped with 4 next entries */
-	MouseInput(k7_CommandToggleInventoryChampion_0,          0,  66,   0,  28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */
-	MouseInput(k8_CommandToggleInventoryChampion_1,         69, 135,   0,  28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */
-	MouseInput(k9_CommandToggleInventoryChampion_2,        138, 204,   0,  28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */
-	MouseInput(k10_CommandToggleInventoryChampion_3,        207, 273,   0,  28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */
-	MouseInput(k100_CommandClickInSpellArea,                233, 319,  42,  73, k1_LeftMouseButton),
-	MouseInput(k111_CommandClickInActionArea,               233, 319,  77, 121, k1_LeftMouseButton),
-	MouseInput(k147_CommandFreezeGame,                          0,   1, 198, 199, k1_LeftMouseButton),
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
 MouseInput g448_SecondaryMouseInput_Movement[9] = { // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9]
 													/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(k1_CommandTurnLeft,             234, 261, 125, 145, k1_LeftMouseButton),
@@ -289,19 +256,61 @@ void EventManager::initArrays() {
 		KeyboardInput(k148_CommandUnfreezeGame, Common::KEYCODE_ESCAPE, 0), /* Esc */
 		KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)
 	};
+	MouseInput _primaryMouseInputEntrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
+		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+		MouseInput(k200_CommandEntranceEnterDungeon, 244, 298,  45,  58, k1_LeftMouseButton),
+		// Strangerke - C201_COMMAND_ENTRANCE_RESUME isn't present in the demo
+		MouseInput(k201_CommandEntranceResume,        244, 298,  76,  93, k1_LeftMouseButton),
+		MouseInput(k202_CommandEntranceDrawCredits,  248, 293, 187, 199, k1_LeftMouseButton),
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput _primaryMouseInputRestartGame[2] = { // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
+		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+		MouseInput(k215_CommandRestartGame, 103, 217, 145, 159, k1_LeftMouseButton),
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput _primaryMouseInputInterface[20] = { // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
+		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+		MouseInput(k12_CommandClickInChampion_0_StatusBox,       0,  42,   0,  28, k1_LeftMouseButton),
+		MouseInput(k13_CommandClickInChampion_1_StatusBox,      69, 111,   0,  28, k1_LeftMouseButton),
+		MouseInput(k14_CommandClickInChampion_2_StatusBox,     138, 180,   0,  28, k1_LeftMouseButton),
+		MouseInput(k15_CommandClickInChampion_3_StatusBox,     207, 249,   0,  28, k1_LeftMouseButton),
+		MouseInput(k125_CommandClickOnChamptionIcon_Top_Left,    274, 299,   0,  13, k1_LeftMouseButton),
+		MouseInput(k126_CommandClickOnChamptionIcon_Top_Right,   301, 319,   0,  13, k1_LeftMouseButton),
+		MouseInput(k127_CommandClickOnChamptionIcon_Lower_Right, 301, 319,  15,  28, k1_LeftMouseButton),
+		MouseInput(k128_CommandClickOnChamptionIcon_Lower_Left,  274, 299,  15,  28, k1_LeftMouseButton),
+		MouseInput(k7_CommandToggleInventoryChampion_0,         43,  66,   0,  28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 =  44. swapped with 4 next entries */
+		MouseInput(k8_CommandToggleInventoryChampion_1,        112, 135,   0,  28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 113. swapped with 4 next entries */
+		MouseInput(k9_CommandToggleInventoryChampion_2,        181, 204,   0,  28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 182. swapped with 4 next entries */
+		MouseInput(k10_CommandToggleInventoryChampion_3,        250, 273,   0,  28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 251. swapped with 4 next entries */
+		MouseInput(k7_CommandToggleInventoryChampion_0,          0,  66,   0,  28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */
+		MouseInput(k8_CommandToggleInventoryChampion_1,         69, 135,   0,  28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */
+		MouseInput(k9_CommandToggleInventoryChampion_2,        138, 204,   0,  28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */
+		MouseInput(k10_CommandToggleInventoryChampion_3,        207, 273,   0,  28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */
+		MouseInput(k100_CommandClickInSpellArea,                233, 319,  42,  73, k1_LeftMouseButton),
+		MouseInput(k111_CommandClickInActionArea,               233, 319,  77, 121, k1_LeftMouseButton),
+		MouseInput(k147_CommandFreezeGame,                          0,   1, 198, 199, k1_LeftMouseButton),
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
 
 	for (int i = 0; i < 7; i++)
-		g458_primaryKeyboardInput_interface[i] = primaryKeyboardInputInterface[i];
+		_primaryKeyboardInputInterface[i] = primaryKeyboardInputInterface[i];
 
 	for (int i = 0; i < 19; i++)
-		g459_secondaryKeyboardInput_movement[i] = secondaryKeyboardInputMovement[i];
+		_secondaryKeyboardInputMovement[i] = secondaryKeyboardInputMovement[i];
 
 	for (int i = 0; i < 3 ; i++)
-		g460_primaryKeyboardInput_partySleeping[i] = primaryKeyboardInputPartySleeping[i];
+		_primaryKeyboardInputPartySleeping[i] = primaryKeyboardInputPartySleeping[i];
 
-	for (int i = 0; i < 2; i++)
-		g461_primaryKeyboardInput_frozenGame[i] = primaryKeyboardInputFrozenGame[i];
+	for (int i = 0; i < 2; i++) {
+		_primaryKeyboardInputFrozenGame[i] = primaryKeyboardInputFrozenGame[i];
+		_primaryMouseInputRestartGame[i] = _primaryMouseInputRestartGame[i];
+	}
+	for (int i = 0; i < 4; i++)
+		_primaryMouseInputEntrance[i] = _primaryMouseInputEntrance[i];
 
+	for (int i = 0; i < 20; i++)
+		_primaryMouseInputInterface[i] = _primaryMouseInputInterface[i];
 }
 EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 	_mousePos = Common::Point(0, 0);
@@ -769,7 +778,7 @@ void EventManager::f380_processCommandQueue() {
 			_vm->_g318_waitForInputMaxVerticalBlankCount = 0;
 			_g441_primaryMouseInput = g450_PrimaryMouseInput_PartySleeping;
 			_g442_secondaryMouseInput = 0;
-			_g443_primaryKeyboardInput = g460_primaryKeyboardInput_partySleeping;
+			_g443_primaryKeyboardInput = _primaryKeyboardInputPartySleeping;
 			_g444_secondaryKeyboardInput = nullptr;
 			f357_discardAllInput();
 		}
@@ -815,7 +824,7 @@ void EventManager::f380_processCommandQueue() {
 		secondaryKeyboardInputBackup = _g444_secondaryKeyboardInput;
 		_g441_primaryMouseInput = g451_PrimaryMouseInput_FrozenGame;
 		_g442_secondaryMouseInput = 0;
-		_g443_primaryKeyboardInput = g461_primaryKeyboardInput_frozenGame;
+		_g443_primaryKeyboardInput = _primaryKeyboardInputFrozenGame;
 		_g444_secondaryKeyboardInput = nullptr;
 		f357_discardAllInput();
 		return;
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 9741fd3..824e535 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -176,11 +176,10 @@ public:
 
 	MouseInput(CommandType type, uint16 x1, uint16 x2, uint16 y1, uint16 y2, MouseButton mouseButton)
 		: _commandTypeToIssue(type), _hitbox(x1, x2 + 1, y1, y2 + 1), _button(mouseButton) {}
+	MouseInput()
+		: _commandTypeToIssue(k0_CommandNone), _hitbox(0, 1, 0, 1), _button(k0_NoneMouseButton) {}
 }; // @ MOUSE_INPUT
 
-extern MouseInput g445_PrimaryMouseInput_Entrance[4]; // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
-extern MouseInput g446_PrimaryMouseInput_RestartGame[2]; // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
-extern MouseInput g447_PrimaryMouseInput_Interface[20]; // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
 extern MouseInput g448_SecondaryMouseInput_Movement[9]; // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9]
 extern MouseInput g449_SecondaryMouseInput_ChampionInventory[38]; // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38]
 extern MouseInput g450_PrimaryMouseInput_PartySleeping[3]; // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
@@ -318,10 +317,13 @@ public:
 	void f6_highlightScreenBox(int16 x1, int16 x2, int16 y1, int16 y2) { warning(false, "STUB METHOD: f6_highlightScreenBox"); } // @  F0006_MAIN_HighlightScreenBox
 
 
-	KeyboardInput g458_primaryKeyboardInput_interface[7]; // @ G0458_as_Graphic561_PrimaryKeyboardInput_Interface
-	KeyboardInput g459_secondaryKeyboardInput_movement[19]; // @ G0459_as_Graphic561_SecondaryKeyboardInput_Movement
-	KeyboardInput g460_primaryKeyboardInput_partySleeping[3]; // @ G0460_as_Graphic561_PrimaryKeyboardInput_PartySleeping
-	KeyboardInput g461_primaryKeyboardInput_frozenGame[2]; // @ G0461_as_Graphic561_PrimaryKeyboardInput_FrozenGame
+	KeyboardInput _primaryKeyboardInputInterface[7]; // @ G0458_as_Graphic561_PrimaryKeyboardInput_Interface
+	KeyboardInput _secondaryKeyboardInputMovement[19]; // @ G0459_as_Graphic561_SecondaryKeyboardInput_Movement
+	KeyboardInput _primaryKeyboardInputPartySleeping[3]; // @ G0460_as_Graphic561_PrimaryKeyboardInput_PartySleeping
+	KeyboardInput _primaryKeyboardInputFrozenGame[2]; // @ G0461_as_Graphic561_PrimaryKeyboardInput_FrozenGame
+	MouseInput _primaryMouseInputEntrance[4]; // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
+	MouseInput _primaryMouseInputRestartGame[2]; // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
+	MouseInput _primaryMouseInputInterface[20]; // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
 
 	void initArrays();
 };
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 3d0415e..282501f 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -126,7 +126,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 			_vm->_menuMan->f395_drawMovementArrows();
 			_vm->_eventMan->f77_hideMouse();
 			_vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
-			_vm->_eventMan->_g444_secondaryKeyboardInput = _vm->_eventMan->g459_secondaryKeyboardInput_movement;
+			_vm->_eventMan->_g444_secondaryKeyboardInput = _vm->_eventMan->_secondaryKeyboardInputMovement;
 			_vm->_eventMan->f357_discardAllInput();
 			_vm->_displayMan->f98_drawFloorAndCeiling();
 			return;
@@ -732,7 +732,7 @@ void InventoryMan::f337_setDungeonViewPalette() {
 		AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
 		while (AL1039_ui_Counter--) {
 			if (*AL1040_pi_TorchLightPower) {
-				L1036_i_TotalLightAmount += (g39_LightPowerToLightAmount[*AL1040_pi_TorchLightPower] << L1037_ui_TorchLightAmountMultiplier) >> 6;
+				L1036_i_TotalLightAmount += (_vm->_championMan->_lightPowerToLightAmount[*AL1040_pi_TorchLightPower] << L1037_ui_TorchLightAmountMultiplier) >> 6;
 				L1037_ui_TorchLightAmountMultiplier = MAX(0, L1037_ui_TorchLightAmountMultiplier - 1);
 			}
 			AL1040_pi_TorchLightPower++;
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index c60fb79..abeadd7 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -550,12 +550,12 @@ int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
 			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
 			AL1267_ui_LightPower++;
 T0412019:
-			_vm->_championMan->_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[AL1267_ui_LightPower];
+			_vm->_championMan->_g407_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[AL1267_ui_LightPower];
 			f404_createEvent70_light(-AL1267_ui_LightPower, AL1269_ui_Ticks);
 			break;
 		case k1_spellType_otherDarkness:
 			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
-			_vm->_championMan->_g407_party._magicalLightAmount -= g39_LightPowerToLightAmount[AL1267_ui_LightPower];
+			_vm->_championMan->_g407_party._magicalLightAmount -= _vm->_championMan->_lightPowerToLightAmount[AL1267_ui_LightPower];
 			f404_createEvent70_light(AL1267_ui_LightPower, 98);
 			break;
 		case k2_spellType_otherThievesEye:
@@ -1295,7 +1295,7 @@ T0407071:
 		_vm->_championMan->_g407_party._freezeLifeTicks = MIN(200, _vm->_championMan->_g407_party._freezeLifeTicks + AL1246_i_Ticks);
 		break;
 	case k38_ChampionActionLight:
-		_vm->_championMan->_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2];
+		_vm->_championMan->_g407_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[2];
 		f404_createEvent70_light(-2, 2500);
 T0407076:
 		f405_decrementCharges(L1247_ps_Champion);
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 3d88e43..e23e878 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -1017,7 +1017,7 @@ void Timeline::f257_timelineProcessEvent70_light(TimelineEvent* event) {
 		AL0674_i_LightPower = -AL0674_i_LightPower;
 	}
 	L0673_i_WeakerLightPower = AL0674_i_LightPower - 1;
-	AL0674_i_LightAmount = g39_LightPowerToLightAmount[AL0674_i_LightPower] - g39_LightPowerToLightAmount[L0673_i_WeakerLightPower];
+	AL0674_i_LightAmount = _vm->_championMan->_lightPowerToLightAmount[AL0674_i_LightPower] - _vm->_championMan->_lightPowerToLightAmount[L0673_i_WeakerLightPower];
 	if (L0675_B_NegativeLightPower) {
 		AL0674_i_LightAmount = -AL0674_i_LightAmount;
 		L0673_i_WeakerLightPower = -L0673_i_WeakerLightPower;


Commit: d90f365728ee50596c940791476afe68e376f529
    https://github.com/scummvm/scummvm/commit/d90f365728ee50596c940791476afe68e376f529
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Work on eventman globals, renaming and apply some coding conventions

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dialog.cpp
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/inventory.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 1a7d229..57d7f5e 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -869,7 +869,7 @@ void ChampionMan::f314_wakeUp() {
 	_vm->f22_delay(10);
 	_vm->_displayMan->f98_drawFloorAndCeiling();
 	_vm->_eventMan->_g441_primaryMouseInput = _vm->_eventMan->_primaryMouseInputInterface;
-	_vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
+	_vm->_eventMan->_g442_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputMovement;
 	_vm->_eventMan->_g443_primaryKeyboardInput = _vm->_eventMan->_primaryKeyboardInputInterface;
 	_vm->_eventMan->_g444_secondaryKeyboardInput = _vm->_eventMan->_secondaryKeyboardInputMovement;
 	_vm->_eventMan->f357_discardAllInput();
diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index 53513b7..c069bb4 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -33,11 +33,11 @@
 
 namespace DM {
 
-DialogMan::DialogMan(DMEngine* vm) : _vm(vm) {
+DialogMan::DialogMan(DMEngine *vm) : _vm(vm) {
 	_g335_selectedDialogChoice = 0;
 }
 
-void DialogMan::f427_dialogDraw(char* msg1, char* msg2, char* choice1, char* choice2, char* choice3, char* choice4, bool screenDialog, bool clearScreen, bool fading) {
+void DialogMan::f427_dialogDraw(char *msg1, char *msg2, char *choice1, char *choice2, char *choice3, char *choice4, bool screenDialog, bool clearScreen, bool fading) {
 	static Box constBox1 = Box(0, 223, 101, 125);
 	static Box constBox2 = Box(0, 223, 76, 100);
 	static Box constBox3 = Box(0, 223, 51, 75);
@@ -140,14 +140,14 @@ void DialogMan::f427_dialogDraw(char* msg1, char* msg2, char* choice1, char* cho
 	_vm->_displayMan->updateScreen();
 }
 
-void DialogMan::f425_printCenteredChoice(byte* bitmap, char* str, int16 posX, int16 posY) {
+void DialogMan::f425_printCenteredChoice(byte *bitmap, char *str, int16 posX, int16 posY) {
 	if (str) {
 		posX -= (strlen(str) * 6) >> 1;
 		_vm->_textMan->f40_printTextToBitmap(bitmap, k112_byteWidthViewport, posX, posY, k9_ColorGold, k5_ColorLightBrown, str, k136_heightViewport);
 	}
 }
 
-bool DialogMan::f426_isMessageOnTwoLines(char* str, char* part1, char* part2) {
+bool DialogMan::f426_isMessageOnTwoLines(char *str, char *part1, char *part2) {
 	uint16 strLength = strlen(str);
 	if (strLength <= 30)
 		return false;
@@ -163,10 +163,10 @@ bool DialogMan::f426_isMessageOnTwoLines(char* str, char* part1, char* part2) {
 }
 
 int16 DialogMan::f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex, int16 driveType, int16 automaticChoiceIfFlopyInDrive) {
-	MouseInput* L1298_ps_PrimaryMouseInputBackup;
-	MouseInput* L1299_ps_SecondaryMouseInputBackup;
-	KeyboardInput* L1300_ps_PrimaryKeyboardInputBackup;
-	KeyboardInput* L1301_ps_SecondaryKeyboardInputBackup;
+	MouseInput *L1298_ps_PrimaryMouseInputBackup;
+	MouseInput *L1299_ps_SecondaryMouseInputBackup;
+	KeyboardInput *L1300_ps_PrimaryKeyboardInputBackup;
+	KeyboardInput *L1301_ps_SecondaryKeyboardInputBackup;
 	Box L1303_s_BoxB;
 	Box L1304_s_BoxA;
 
@@ -178,7 +178,7 @@ int16 DialogMan::f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex,
 	_vm->_eventMan->_g442_secondaryMouseInput = nullptr;
 	_vm->_eventMan->_g443_primaryKeyboardInput = nullptr;
 	_vm->_eventMan->_g444_secondaryKeyboardInput = nullptr;
-	_vm->_eventMan->_g441_primaryMouseInput = g480_PrimaryMouseInput_DialogSets[dialogSetIndex][choiceCount - 1];
+	_vm->_eventMan->_g441_primaryMouseInput = _vm->_eventMan->_primaryMouseInputDialogSets[dialogSetIndex][choiceCount - 1];
 	_vm->_eventMan->f357_discardAllInput();
 	_g335_selectedDialogChoice = 99;
 	do {
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 7f3d608..9f84269 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -340,7 +340,7 @@ void DMEngine::f462_startGame() {
 	_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = M0_indexToOrdinal(kM1_ChampionNone);
 
 	_eventMan->_g441_primaryMouseInput = _eventMan->_primaryMouseInputInterface;
-	_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
+	_eventMan->_g442_secondaryMouseInput = _eventMan->_secondaryMouseInputMovement;
 	_eventMan->_g443_primaryKeyboardInput = _eventMan->_primaryKeyboardInputInterface;
 	_eventMan->_g444_secondaryKeyboardInput = _eventMan->_secondaryKeyboardInputMovement;
 
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 79475ad..db4d0f0 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -44,74 +44,6 @@
 
 namespace DM {
 
-MouseInput g448_SecondaryMouseInput_Movement[9] = { // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9]
-													/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(k1_CommandTurnLeft,             234, 261, 125, 145, k1_LeftMouseButton),
-	MouseInput(k3_CommandMoveForward,          263, 289, 125, 145, k1_LeftMouseButton),
-	MouseInput(k2_CommandTurnRight,            291, 318, 125, 145, k1_LeftMouseButton),
-	MouseInput(k6_CommandMoveLeft,             234, 261, 147, 167, k1_LeftMouseButton),
-	MouseInput(k5_CommandMoveBackward,         263, 289, 147, 167, k1_LeftMouseButton),
-	MouseInput(k4_CommandMoveRight,            291, 318, 147, 167, k1_LeftMouseButton),
-	MouseInput(k80_CommandClickInDungeonView,   0, 223,  33, 168, k1_LeftMouseButton),
-	MouseInput(k83_CommandToggleInventoryLeader, 0, 319,  33, 199, k2_RightMouseButton),
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g449_SecondaryMouseInput_ChampionInventory[38] = { // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38]
-															  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(k11_CommandCloseInventory,                                   0, 319,   0, 199, k2_RightMouseButton),
-	MouseInput(k140_CommandSaveGame,                                       174, 182,  36,  44, k1_LeftMouseButton),
-	MouseInput(k145_CommandSleep,                                           188, 204,  36,  44, k1_LeftMouseButton),
-	MouseInput(k11_CommandCloseInventory,                                 210, 218,  36,  44, k1_LeftMouseButton),
-	MouseInput(k28_CommandClickOnSlotBoxInventoryReadyHand ,        6,  21,  86, 101, k1_LeftMouseButton),
-	MouseInput(k29_CommandClickOnSlotBoxInventoryActionHand,       62,  77,  86, 101, k1_LeftMouseButton),
-	MouseInput(k30_CommandClickOnSlotBoxInventoryHead,              34,  49,  59,  74, k1_LeftMouseButton),
-	MouseInput(k31_CommandClickOnSlotBoxInventoryTorso,             34,  49,  79,  94, k1_LeftMouseButton),
-	MouseInput(k32_CommandClickOnSlotBoxInventoryLegs,              34,  49,  99, 114, k1_LeftMouseButton),
-	MouseInput(k33_CommandClickOnSlotBoxInventoryFeet,              34,  49, 119, 134, k1_LeftMouseButton),
-	MouseInput(k34_CommandClickOnSlotBoxInventoryPouch_2,            6,  21, 123, 138, k1_LeftMouseButton),
-	MouseInput(k70_CommandClickOnMouth,                                   56,  71,  46,  61, k1_LeftMouseButton),
-	MouseInput(k71_CommandClickOnEye,                                     12,  27,  46,  61, k1_LeftMouseButton),
-	MouseInput(k35_CommandClickOnSlotBoxInventoryQuiverLine_2_1,    79,  94, 106, 121, k1_LeftMouseButton),
-	MouseInput(k36_CommandClickOnSlotBoxInventoryQuiverLine_1_2,    62,  77, 123, 138, k1_LeftMouseButton),
-	MouseInput(k37_CommandClickOnSlotBoxInventoryQuiverLine_2_2,    79,  94, 123, 138, k1_LeftMouseButton),
-	MouseInput(k38_CommandClickOnSlotBoxInventoryNeck,               6,  21,  66,  81, k1_LeftMouseButton),
-	MouseInput(k39_CommandClickOnSlotBoxInventoryPouch_1,            6,  21, 106, 121, k1_LeftMouseButton),
-	MouseInput(k40_CommandClickOnSlotBoxInventoryQuiverLine_1_1,    62,  77, 106, 121, k1_LeftMouseButton),
-	MouseInput(k41_CommandClickOnSlotBoxInventoryBackpackLine_1_1,  66,  81,  66,  81, k1_LeftMouseButton),
-	MouseInput(k42_CommandClickOnSlotBoxInventoryBackpackLine_2_2,  83,  98,  49,  64, k1_LeftMouseButton),
-	MouseInput(k43_CommandClickOnSlotBoxInventoryBackpackLine_2_3, 100, 115,  49,  64, k1_LeftMouseButton),
-	MouseInput(k44_CommandClickOnSlotBoxInventoryBackpackLine_2_4, 117, 132,  49,  64, k1_LeftMouseButton),
-	MouseInput(k45_CommandClickOnSlotBoxInventoryBackpackLine_2_5, 134, 149,  49,  64, k1_LeftMouseButton),
-	MouseInput(k46_CommandClickOnSlotBoxInventoryBackpackLine_2_6, 151, 166,  49,  64, k1_LeftMouseButton),
-	MouseInput(k47_CommandClickOnSlotBoxInventoryBackpackLine_2_7, 168, 183,  49,  64, k1_LeftMouseButton),
-	MouseInput(k48_CommandClickOnSlotBoxInventoryBackpackLine_2_8, 185, 200,  49,  64, k1_LeftMouseButton),
-	MouseInput(k49_CommandClickOnSlotBoxInventoryBackpackLine_2_9, 202, 217,  49,  64, k1_LeftMouseButton),
-	MouseInput(k50_CommandClickOnSlotBoxInventoryBackpackLine_1_2,  83,  98,  66,  81, k1_LeftMouseButton),
-	MouseInput(k51_CommandClickOnSlotBoxInventoryBackpackLine_1_3, 100, 115,  66,  81, k1_LeftMouseButton),
-	MouseInput(k52_CommandClickOnSlotBoxInventoryBackpackLine_1_4, 117, 132,  66,  81, k1_LeftMouseButton),
-	MouseInput(k53_CommandClickOnSlotBoxInventoryBackpackLine_1_5, 134, 149,  66,  81, k1_LeftMouseButton),
-	MouseInput(k54_CommandClickOnSlotBoxInventoryBackpackLine_1_6, 151, 166,  66,  81, k1_LeftMouseButton),
-	MouseInput(k55_CommandClickOnSlotBoxInventoryBackpackLine_1_7, 168, 183,  66,  81, k1_LeftMouseButton),
-	MouseInput(k56_CommandClickOnSlotBoxInventoryBackpackLine_1_8, 185, 200,  66,  81, k1_LeftMouseButton),
-	MouseInput(k57_CommandClickOnSlotBoxInventoryBackpackLine_1_9, 202, 217,  66,  81, k1_LeftMouseButton),
-	MouseInput(k81_CommandClickInPanel,                                   96, 223,  83, 167, k1_LeftMouseButton),
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g450_PrimaryMouseInput_PartySleeping[3] = { // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
-													   /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(k146_CommandWakeUp, 0, 223, 33, 168, k1_LeftMouseButton),
-	MouseInput(k146_CommandWakeUp, 0, 223, 33, 168, k2_RightMouseButton),
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g451_PrimaryMouseInput_FrozenGame[3] = { // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3]
-													/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(k148_CommandUnfreezeGame, 0, 319, 0, 199, k1_LeftMouseButton),
-	MouseInput(k148_CommandUnfreezeGame, 0, 319, 0, 199, k2_RightMouseButton),
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g452_MouseInput_ActionAreaNames[5] = { // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5]
-												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(k112_CommandClickInActionAreaPass,     285, 318,  77,  83, k1_LeftMouseButton),
-	MouseInput(k113_CommandClickInActionAreaAction_0, 234, 318,  86,  96, k1_LeftMouseButton),
-	MouseInput(k114_CommandClickInActionAreaAction_1, 234, 318,  98, 108, k1_LeftMouseButton),
-	MouseInput(k115_CommandClickInActionAreaAction_2, 234, 318, 110, 120, k1_LeftMouseButton),
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
 MouseInput g453_MouseInput_ActionAreaIcons[5] = { // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5]
 												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 	MouseInput(k116_CommandClickInActionAreaChampion_0_Action, 233, 252, 86, 120, k1_LeftMouseButton),
@@ -201,16 +133,6 @@ MouseInput g478_PrimaryMouseInput_ScreenDialog4Choices[5] = { // @ G0478_as_Grap
 	MouseInput(k213_CommandClickOnDialogChoice_4, 170, 254, 138, 152, k1_LeftMouseButton), /* Lower right button */
 	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
 
-MouseInput* g480_PrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryMouseInput_DialogSets
-	{g471_PrimaryMouseInput_ViewportDialog1Choice,
-	g472_PrimaryMouseInput_ViewportDialog2Choices,
-	g473_PrimaryMouseInput_ViewportDialog3Choices,
-	g474_PrimaryMouseInput_ViewportDialog4Choices},
-	{g475_PrimaryMouseInput_ScreenDialog1Choice,
-	g476_PrimaryMouseInput_ScreenDialog2Choices,
-	g477_PrimaryMouseInput_ScreenDialog3Choices,
-	g478_PrimaryMouseInput_ScreenDialog4Choices},};
-
 void EventManager::initArrays() {
 	KeyboardInput primaryKeyboardInputInterface[7] = { // @ G0458_as_Graphic561_PrimaryKeyboardInput_Interface
 		/* { Command, Code } */
@@ -256,7 +178,7 @@ void EventManager::initArrays() {
 		KeyboardInput(k148_CommandUnfreezeGame, Common::KEYCODE_ESCAPE, 0), /* Esc */
 		KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)
 	};
-	MouseInput _primaryMouseInputEntrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
+	MouseInput primaryMouseInputEntrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
 		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 		MouseInput(k200_CommandEntranceEnterDungeon, 244, 298,  45,  58, k1_LeftMouseButton),
 		// Strangerke - C201_COMMAND_ENTRANCE_RESUME isn't present in the demo
@@ -264,12 +186,12 @@ void EventManager::initArrays() {
 		MouseInput(k202_CommandEntranceDrawCredits,  248, 293, 187, 199, k1_LeftMouseButton),
 		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
 	};
-	MouseInput _primaryMouseInputRestartGame[2] = { // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
+	MouseInput primaryMouseInputRestartGame[2] = { // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
 		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 		MouseInput(k215_CommandRestartGame, 103, 217, 145, 159, k1_LeftMouseButton),
 		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
 	};
-	MouseInput _primaryMouseInputInterface[20] = { // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
+	MouseInput primaryMouseInputInterface[20] = { // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
 		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
 		MouseInput(k12_CommandClickInChampion_0_StatusBox,       0,  42,   0,  28, k1_LeftMouseButton),
 		MouseInput(k13_CommandClickInChampion_1_StatusBox,      69, 111,   0,  28, k1_LeftMouseButton),
@@ -292,25 +214,128 @@ void EventManager::initArrays() {
 		MouseInput(k147_CommandFreezeGame,                          0,   1, 198, 199, k1_LeftMouseButton),
 		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
 	};
+	MouseInput secondaryMouseInputMovement[9] = { // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9]
+		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+		MouseInput(k1_CommandTurnLeft,             234, 261, 125, 145, k1_LeftMouseButton),
+		MouseInput(k3_CommandMoveForward,          263, 289, 125, 145, k1_LeftMouseButton),
+		MouseInput(k2_CommandTurnRight,            291, 318, 125, 145, k1_LeftMouseButton),
+		MouseInput(k6_CommandMoveLeft,             234, 261, 147, 167, k1_LeftMouseButton),
+		MouseInput(k5_CommandMoveBackward,         263, 289, 147, 167, k1_LeftMouseButton),
+		MouseInput(k4_CommandMoveRight,            291, 318, 147, 167, k1_LeftMouseButton),
+		MouseInput(k80_CommandClickInDungeonView,   0, 223,  33, 168, k1_LeftMouseButton),
+		MouseInput(k83_CommandToggleInventoryLeader, 0, 319,  33, 199, k2_RightMouseButton),
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput secondaryMouseInputChampionInventory[38] = { // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38]
+		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+		MouseInput(k11_CommandCloseInventory,                                   0, 319,   0, 199, k2_RightMouseButton),
+		MouseInput(k140_CommandSaveGame,                                       174, 182,  36,  44, k1_LeftMouseButton),
+		MouseInput(k145_CommandSleep,                                           188, 204,  36,  44, k1_LeftMouseButton),
+		MouseInput(k11_CommandCloseInventory,                                 210, 218,  36,  44, k1_LeftMouseButton),
+		MouseInput(k28_CommandClickOnSlotBoxInventoryReadyHand ,        6,  21,  86, 101, k1_LeftMouseButton),
+		MouseInput(k29_CommandClickOnSlotBoxInventoryActionHand,       62,  77,  86, 101, k1_LeftMouseButton),
+		MouseInput(k30_CommandClickOnSlotBoxInventoryHead,              34,  49,  59,  74, k1_LeftMouseButton),
+		MouseInput(k31_CommandClickOnSlotBoxInventoryTorso,             34,  49,  79,  94, k1_LeftMouseButton),
+		MouseInput(k32_CommandClickOnSlotBoxInventoryLegs,              34,  49,  99, 114, k1_LeftMouseButton),
+		MouseInput(k33_CommandClickOnSlotBoxInventoryFeet,              34,  49, 119, 134, k1_LeftMouseButton),
+		MouseInput(k34_CommandClickOnSlotBoxInventoryPouch_2,            6,  21, 123, 138, k1_LeftMouseButton),
+		MouseInput(k70_CommandClickOnMouth,                                   56,  71,  46,  61, k1_LeftMouseButton),
+		MouseInput(k71_CommandClickOnEye,                                     12,  27,  46,  61, k1_LeftMouseButton),
+		MouseInput(k35_CommandClickOnSlotBoxInventoryQuiverLine_2_1,    79,  94, 106, 121, k1_LeftMouseButton),
+		MouseInput(k36_CommandClickOnSlotBoxInventoryQuiverLine_1_2,    62,  77, 123, 138, k1_LeftMouseButton),
+		MouseInput(k37_CommandClickOnSlotBoxInventoryQuiverLine_2_2,    79,  94, 123, 138, k1_LeftMouseButton),
+		MouseInput(k38_CommandClickOnSlotBoxInventoryNeck,               6,  21,  66,  81, k1_LeftMouseButton),
+		MouseInput(k39_CommandClickOnSlotBoxInventoryPouch_1,            6,  21, 106, 121, k1_LeftMouseButton),
+		MouseInput(k40_CommandClickOnSlotBoxInventoryQuiverLine_1_1,    62,  77, 106, 121, k1_LeftMouseButton),
+		MouseInput(k41_CommandClickOnSlotBoxInventoryBackpackLine_1_1,  66,  81,  66,  81, k1_LeftMouseButton),
+		MouseInput(k42_CommandClickOnSlotBoxInventoryBackpackLine_2_2,  83,  98,  49,  64, k1_LeftMouseButton),
+		MouseInput(k43_CommandClickOnSlotBoxInventoryBackpackLine_2_3, 100, 115,  49,  64, k1_LeftMouseButton),
+		MouseInput(k44_CommandClickOnSlotBoxInventoryBackpackLine_2_4, 117, 132,  49,  64, k1_LeftMouseButton),
+		MouseInput(k45_CommandClickOnSlotBoxInventoryBackpackLine_2_5, 134, 149,  49,  64, k1_LeftMouseButton),
+		MouseInput(k46_CommandClickOnSlotBoxInventoryBackpackLine_2_6, 151, 166,  49,  64, k1_LeftMouseButton),
+		MouseInput(k47_CommandClickOnSlotBoxInventoryBackpackLine_2_7, 168, 183,  49,  64, k1_LeftMouseButton),
+		MouseInput(k48_CommandClickOnSlotBoxInventoryBackpackLine_2_8, 185, 200,  49,  64, k1_LeftMouseButton),
+		MouseInput(k49_CommandClickOnSlotBoxInventoryBackpackLine_2_9, 202, 217,  49,  64, k1_LeftMouseButton),
+		MouseInput(k50_CommandClickOnSlotBoxInventoryBackpackLine_1_2,  83,  98,  66,  81, k1_LeftMouseButton),
+		MouseInput(k51_CommandClickOnSlotBoxInventoryBackpackLine_1_3, 100, 115,  66,  81, k1_LeftMouseButton),
+		MouseInput(k52_CommandClickOnSlotBoxInventoryBackpackLine_1_4, 117, 132,  66,  81, k1_LeftMouseButton),
+		MouseInput(k53_CommandClickOnSlotBoxInventoryBackpackLine_1_5, 134, 149,  66,  81, k1_LeftMouseButton),
+		MouseInput(k54_CommandClickOnSlotBoxInventoryBackpackLine_1_6, 151, 166,  66,  81, k1_LeftMouseButton),
+		MouseInput(k55_CommandClickOnSlotBoxInventoryBackpackLine_1_7, 168, 183,  66,  81, k1_LeftMouseButton),
+		MouseInput(k56_CommandClickOnSlotBoxInventoryBackpackLine_1_8, 185, 200,  66,  81, k1_LeftMouseButton),
+		MouseInput(k57_CommandClickOnSlotBoxInventoryBackpackLine_1_9, 202, 217,  66,  81, k1_LeftMouseButton),
+		MouseInput(k81_CommandClickInPanel,                                   96, 223,  83, 167, k1_LeftMouseButton),
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput primaryMouseInputPartySleeping[3] = { // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
+		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+		MouseInput(k146_CommandWakeUp, 0, 223, 33, 168, k1_LeftMouseButton),
+		MouseInput(k146_CommandWakeUp, 0, 223, 33, 168, k2_RightMouseButton),
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput primaryMouseInputFrozenGame[3] = { // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3]
+		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+		MouseInput(k148_CommandUnfreezeGame, 0, 319, 0, 199, k1_LeftMouseButton),
+		MouseInput(k148_CommandUnfreezeGame, 0, 319, 0, 199, k2_RightMouseButton),
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput mouseInputActionAreaNames[5] = { // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5]
+		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+		MouseInput(k112_CommandClickInActionAreaPass,     285, 318,  77,  83, k1_LeftMouseButton),
+		MouseInput(k113_CommandClickInActionAreaAction_0, 234, 318,  86,  96, k1_LeftMouseButton),
+		MouseInput(k114_CommandClickInActionAreaAction_1, 234, 318,  98, 108, k1_LeftMouseButton),
+		MouseInput(k115_CommandClickInActionAreaAction_2, 234, 318, 110, 120, k1_LeftMouseButton),
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput *primaryMouseInputDialogSets[2][4] = { // @ G0480_aaps_PrimaryMouseInput_DialogSets
+		{
+			g471_PrimaryMouseInput_ViewportDialog1Choice,
+			g472_PrimaryMouseInput_ViewportDialog2Choices,
+			g473_PrimaryMouseInput_ViewportDialog3Choices,
+			g474_PrimaryMouseInput_ViewportDialog4Choices
+		},
+		{
+			g475_PrimaryMouseInput_ScreenDialog1Choice,
+			g476_PrimaryMouseInput_ScreenDialog2Choices,
+			g477_PrimaryMouseInput_ScreenDialog3Choices,
+			g478_PrimaryMouseInput_ScreenDialog4Choices
+		}
+	};
+
+	for (int i = 0; i < 2; i++) {
+		_primaryKeyboardInputFrozenGame[i] = primaryKeyboardInputFrozenGame[i];
+		_primaryMouseInputRestartGame[i] = primaryMouseInputRestartGame[i];
+		for (int j = 0; j < 4; j++)
+			_primaryMouseInputDialogSets[i][j] = primaryMouseInputDialogSets[i][j];
+	}
+
+	for (int i = 0; i < 3 ; i++) {
+		_primaryKeyboardInputPartySleeping[i] = primaryKeyboardInputPartySleeping[i];
+		_primaryMouseInputPartySleeping[i] = primaryMouseInputPartySleeping[i];
+		_primaryMouseInputFrozenGame[i] = primaryMouseInputFrozenGame[i];
+	}
+
+	for (int i = 0; i < 4; i++)
+		_primaryMouseInputEntrance[i] = primaryMouseInputEntrance[i];
+
+	for (int i = 0; i < 5; i++)
+		_mouseInputActionAreaNames[i] = mouseInputActionAreaNames[i];
 
 	for (int i = 0; i < 7; i++)
 		_primaryKeyboardInputInterface[i] = primaryKeyboardInputInterface[i];
 
+	for (int i = 0; i < 9; i++)
+		_secondaryMouseInputMovement[i] = secondaryMouseInputMovement[i];
+
 	for (int i = 0; i < 19; i++)
 		_secondaryKeyboardInputMovement[i] = secondaryKeyboardInputMovement[i];
 
-	for (int i = 0; i < 3 ; i++)
-		_primaryKeyboardInputPartySleeping[i] = primaryKeyboardInputPartySleeping[i];
+	for (int i = 0; i < 20; i++)
+		_primaryMouseInputInterface[i] = primaryMouseInputInterface[i];
 
-	for (int i = 0; i < 2; i++) {
-		_primaryKeyboardInputFrozenGame[i] = primaryKeyboardInputFrozenGame[i];
-		_primaryMouseInputRestartGame[i] = _primaryMouseInputRestartGame[i];
-	}
-	for (int i = 0; i < 4; i++)
-		_primaryMouseInputEntrance[i] = _primaryMouseInputEntrance[i];
+	for (int i = 0; i < 38; i++)
+		_secondaryMouseInputChampionInventory[i] = secondaryMouseInputChampionInventory[i];
 
-	for (int i = 0; i < 20; i++)
-		_primaryMouseInputInterface[i] = _primaryMouseInputInterface[i];
 }
 EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 	_mousePos = Common::Point(0, 0);
@@ -776,7 +801,7 @@ void EventManager::f380_processCommandQueue() {
 			f379_drawSleepScreen();
 			_vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
 			_vm->_g318_waitForInputMaxVerticalBlankCount = 0;
-			_g441_primaryMouseInput = g450_PrimaryMouseInput_PartySleeping;
+			_g441_primaryMouseInput = _primaryMouseInputPartySleeping;
 			_g442_secondaryMouseInput = 0;
 			_g443_primaryKeyboardInput = _primaryKeyboardInputPartySleeping;
 			_g444_secondaryKeyboardInput = nullptr;
@@ -822,7 +847,7 @@ void EventManager::f380_processCommandQueue() {
 		secondaryMouseInputBackup = _g442_secondaryMouseInput;
 		primaryKeyboardInputBackup = _g443_primaryKeyboardInput;
 		secondaryKeyboardInputBackup = _g444_secondaryKeyboardInput;
-		_g441_primaryMouseInput = g451_PrimaryMouseInput_FrozenGame;
+		_g441_primaryMouseInput = _primaryMouseInputFrozenGame;
 		_g442_secondaryMouseInput = 0;
 		_g443_primaryKeyboardInput = _primaryKeyboardInputFrozenGame;
 		_g444_secondaryKeyboardInput = nullptr;
@@ -1518,7 +1543,7 @@ void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(Comm
 
 void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY) {
 	if (_vm->_championMan->_g506_actingChampionOrdinal) {
-		uint16 mouseCommand = f358_getCommandTypeFromMouseInput(g452_MouseInput_ActionAreaNames, Common::Point(posX, posY), k1_LeftMouseButton);
+		uint16 mouseCommand = f358_getCommandTypeFromMouseInput(_mouseInputActionAreaNames, Common::Point(posX, posY), k1_LeftMouseButton);
 		if (mouseCommand != k0_CommandNone) {
 			if (mouseCommand == k112_CommandClickInActionAreaPass) {
 				f362_commandHighlightBoxEnable(285, 319, 77, 83);
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 824e535..16ade31 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -180,11 +180,6 @@ public:
 		: _commandTypeToIssue(k0_CommandNone), _hitbox(0, 1, 0, 1), _button(k0_NoneMouseButton) {}
 }; // @ MOUSE_INPUT
 
-extern MouseInput g448_SecondaryMouseInput_Movement[9]; // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9]
-extern MouseInput g449_SecondaryMouseInput_ChampionInventory[38]; // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38]
-extern MouseInput g450_PrimaryMouseInput_PartySleeping[3]; // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
-extern MouseInput g451_PrimaryMouseInput_FrozenGame[3]; // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3]
-extern MouseInput g452_MouseInput_ActionAreaNames[5]; // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5]
 extern MouseInput g453_MouseInput_ActionAreaIcons[5]; // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5]
 extern MouseInput g454_MouseInput_SpellArea[9]; // @ G0454_as_Graphic561_MouseInput_SpellArea[9]
 extern MouseInput g455_MouseInput_ChampionNamesHands[13]; // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
@@ -198,7 +193,6 @@ extern MouseInput g475_PrimaryMouseInput_ScreenDialog1Choice[2]; // @ G0475_as_G
 extern MouseInput g476_PrimaryMouseInput_ScreenDialog2Choices[3]; // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3]
 extern MouseInput g477_PrimaryMouseInput_ScreenDialog3Choices[4]; // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4]
 extern MouseInput g478_PrimaryMouseInput_ScreenDialog4Choices[5]; // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
-extern MouseInput* g480_PrimaryMouseInput_DialogSets[2][4]; // @ G0480_aaps_PrimaryMouseInput_DialogSets
 
 class KeyboardInput {
 public:
@@ -324,6 +318,13 @@ public:
 	MouseInput _primaryMouseInputEntrance[4]; // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
 	MouseInput _primaryMouseInputRestartGame[2]; // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
 	MouseInput _primaryMouseInputInterface[20]; // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
+	MouseInput _secondaryMouseInputMovement[9]; // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9]
+	MouseInput _secondaryMouseInputChampionInventory[38]; // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38]
+	MouseInput _primaryMouseInputPartySleeping[3]; // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
+	MouseInput _primaryMouseInputFrozenGame[3]; // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3]
+	MouseInput _mouseInputActionAreaNames[5]; // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5]
+
+	MouseInput *_primaryMouseInputDialogSets[2][4]; // @ G0480_aaps_PrimaryMouseInput_DialogSets
 
 	void initArrays();
 };
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 282501f..e2cfd96 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -125,7 +125,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 			_vm->_eventMan->_g326_refreshMousePointerInMainLoop = true;
 			_vm->_menuMan->f395_drawMovementArrows();
 			_vm->_eventMan->f77_hideMouse();
-			_vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
+			_vm->_eventMan->_g442_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputMovement;
 			_vm->_eventMan->_g444_secondaryKeyboardInput = _vm->_eventMan->_secondaryKeyboardInputMovement;
 			_vm->_eventMan->f357_discardAllInput();
 			_vm->_displayMan->f98_drawFloorAndCeiling();
@@ -167,7 +167,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	_vm->_championMan->f292_drawChampionState(championIndex);
 	_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
 	_vm->_eventMan->f77_hideMouse();
-	_vm->_eventMan->_g442_secondaryMouseInput = g449_SecondaryMouseInput_ChampionInventory;
+	_vm->_eventMan->_g442_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputChampionInventory;
 	_vm->_eventMan->_g444_secondaryKeyboardInput = nullptr;
 	_vm->_eventMan->f357_discardAllInput();
 }


Commit: 901ba6f132f2c74728711515882d871a4cbc3677
    https://github.com/scummvm/scummvm/commit/901ba6f132f2c74728711515882d871a4cbc3677
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Move more globals to EventMan

Changed paths:
    engines/dm/eventman.cpp
    engines/dm/eventman.h



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index db4d0f0..4410f09 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -44,58 +44,6 @@
 
 namespace DM {
 
-MouseInput g453_MouseInput_ActionAreaIcons[5] = { // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5]
-												  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(k116_CommandClickInActionAreaChampion_0_Action, 233, 252, 86, 120, k1_LeftMouseButton),
-	MouseInput(k117_CommandClickInActionAreaChampion_1_Action, 255, 274, 86, 120, k1_LeftMouseButton),
-	MouseInput(k118_CommandClickInActionAreaChampion_2_Action, 277, 296, 86, 120, k1_LeftMouseButton),
-	MouseInput(k119_CommandClickInActionAreaChampion_3_Action, 299, 318, 86, 120, k1_LeftMouseButton),
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g454_MouseInput_SpellArea[9] = { // @ G0454_as_Graphic561_MouseInput_SpellArea[9]
-											/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(k101_CommandClickInSpellAreaSymbol_1,      235, 247, 51, 61, k1_LeftMouseButton),
-	MouseInput(k102_CommandClickInSpellAreaSymbol_2,      249, 261, 51, 61, k1_LeftMouseButton),
-	MouseInput(k103_CommandClickInSpellAreaSymbol_3,      263, 275, 51, 61, k1_LeftMouseButton),
-	MouseInput(k104_CommandClickInSpellAreaSymbol_4,      277, 289, 51, 61, k1_LeftMouseButton),
-	MouseInput(k105_CommandClickInSpellAreaSymbol_5,      291, 303, 51, 61, k1_LeftMouseButton),
-	MouseInput(k106_CommandClickInSpellAreaSymbol_6,      305, 317, 51, 61, k1_LeftMouseButton),
-	MouseInput(k108_CommandClickInSpeallAreaCastSpell,    234, 303, 63, 73, k1_LeftMouseButton),
-	MouseInput(k107_CommandClickInSpellAreaRecantSymbol, 305, 318, 63, 73, k1_LeftMouseButton),
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g455_MouseInput_ChampionNamesHands[13] = { // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
-													  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(k16_CommandSetLeaderChampion_0,                                    0,  42,  0,  6, k1_LeftMouseButton),
-	MouseInput(k17_CommandSetLeaderChampion_1,                                   69, 111,  0,  6, k1_LeftMouseButton),
-	MouseInput(k18_CommandSetLeaderChampion_2,                                  138, 180,  0,  6, k1_LeftMouseButton),
-	MouseInput(k19_CommandSetLeaderChampion_3,                                  207, 249,  0,  6, k1_LeftMouseButton),
-	MouseInput(k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand,    4,  19, 10, 25, k1_LeftMouseButton),
-	MouseInput(k21_CommandClickOnSlotBoxChampion_0_StatusBoxActionHand,  24,  39, 10, 25, k1_LeftMouseButton),
-	MouseInput(k22_CommandClickOnSlotBoxChampion_1_StatusBoxReadyHand,   73,  88, 10, 25, k1_LeftMouseButton),
-	MouseInput(k23_CommandClickOnSlotBoxChampion_1_StatusBoxActionHand,  93, 108, 10, 25, k1_LeftMouseButton),
-	MouseInput(k24_CommandClickOnSlotBoxChampion_2_StatusBoxReadyHand,  142, 157, 10, 25, k1_LeftMouseButton),
-	MouseInput(k25_CommandClickOnSlotBoxChampion_2_StatusBoxActionHand, 162, 177, 10, 25, k1_LeftMouseButton),
-	MouseInput(k26_CommandClickOnSlotBoxChampion_3_StatusBoxReadyHand,  211, 226, 10, 25, k1_LeftMouseButton),
-	MouseInput(k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand, 231, 246, 10, 25, k1_LeftMouseButton),
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g456_MouseInput_PanelChest[9] = { // @ G0456_as_Graphic561_MouseInput_PanelChest[9]
-											 /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(k58_CommandClickOnSlotBoxChest_1, 117, 132,  92, 107, k1_LeftMouseButton),
-	MouseInput(k59_CommandClickOnSlotBoxChest_2, 106, 121, 109, 124, k1_LeftMouseButton),
-	MouseInput(k60_CommandClickOnSlotBoxChest_3, 111, 126, 126, 141, k1_LeftMouseButton),
-	MouseInput(k61_CommandClickOnSlotBoxChest_4, 128, 143, 131, 146, k1_LeftMouseButton),
-	MouseInput(k62_CommandClickOnSlotBoxChest_5, 145, 160, 134, 149, k1_LeftMouseButton),
-	MouseInput(k63_CommandClickOnSlotBoxChest_6, 162, 177, 136, 151, k1_LeftMouseButton),
-	MouseInput(k64_CommandClickOnSlotBoxChest_7, 179, 194, 137, 152, k1_LeftMouseButton),
-	MouseInput(k65_CommandClickOnSlotBoxChest_8, 196, 211, 138, 153, k1_LeftMouseButton),
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g457_MouseInput_PanelResurrectReincarnateCancel[4] = { // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4]
-																  /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
-	MouseInput(k160_CommandClickInPanelResurrect,   108, 158,  90, 138, k1_LeftMouseButton), /* Atari ST: Box = 104, 158,  86, 142 */
-	MouseInput(k161_CommandClickInPanelReincarnate, 161, 211,  90, 138, k1_LeftMouseButton), /* Atari ST: Box = 163, 217,  86, 142 */
-	MouseInput(k162_CommandClickInPanelCancel,      108, 211, 141, 153, k1_LeftMouseButton), /* Atari ST: Box = 104, 217, 146, 156 */
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-
-
 MouseInput g471_PrimaryMouseInput_ViewportDialog1Choice[2] = { // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
 	MouseInput(k210_CommandClickOnDialogChoice_1, 16, 207, 138, 152, k1_LeftMouseButton), /* Bottom button */
 	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
@@ -287,6 +235,62 @@ void EventManager::initArrays() {
 		MouseInput(k115_CommandClickInActionAreaAction_2, 234, 318, 110, 120, k1_LeftMouseButton),
 		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
 	};
+	MouseInput mouseInputActionAreaIcons[5] = { // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5]
+		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+		MouseInput(k116_CommandClickInActionAreaChampion_0_Action, 233, 252, 86, 120, k1_LeftMouseButton),
+		MouseInput(k117_CommandClickInActionAreaChampion_1_Action, 255, 274, 86, 120, k1_LeftMouseButton),
+		MouseInput(k118_CommandClickInActionAreaChampion_2_Action, 277, 296, 86, 120, k1_LeftMouseButton),
+		MouseInput(k119_CommandClickInActionAreaChampion_3_Action, 299, 318, 86, 120, k1_LeftMouseButton),
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput mouseInputSpellArea[9] = { // @ G0454_as_Graphic561_MouseInput_SpellArea[9]
+		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+		MouseInput(k101_CommandClickInSpellAreaSymbol_1,      235, 247, 51, 61, k1_LeftMouseButton),
+		MouseInput(k102_CommandClickInSpellAreaSymbol_2,      249, 261, 51, 61, k1_LeftMouseButton),
+		MouseInput(k103_CommandClickInSpellAreaSymbol_3,      263, 275, 51, 61, k1_LeftMouseButton),
+		MouseInput(k104_CommandClickInSpellAreaSymbol_4,      277, 289, 51, 61, k1_LeftMouseButton),
+		MouseInput(k105_CommandClickInSpellAreaSymbol_5,      291, 303, 51, 61, k1_LeftMouseButton),
+		MouseInput(k106_CommandClickInSpellAreaSymbol_6,      305, 317, 51, 61, k1_LeftMouseButton),
+		MouseInput(k108_CommandClickInSpeallAreaCastSpell,    234, 303, 63, 73, k1_LeftMouseButton),
+		MouseInput(k107_CommandClickInSpellAreaRecantSymbol, 305, 318, 63, 73, k1_LeftMouseButton),
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput mouseInputChampionNamesHands[13] = { // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
+		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+		MouseInput(k16_CommandSetLeaderChampion_0,                                    0,  42,  0,  6, k1_LeftMouseButton),
+		MouseInput(k17_CommandSetLeaderChampion_1,                                   69, 111,  0,  6, k1_LeftMouseButton),
+		MouseInput(k18_CommandSetLeaderChampion_2,                                  138, 180,  0,  6, k1_LeftMouseButton),
+		MouseInput(k19_CommandSetLeaderChampion_3,                                  207, 249,  0,  6, k1_LeftMouseButton),
+		MouseInput(k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand,    4,  19, 10, 25, k1_LeftMouseButton),
+		MouseInput(k21_CommandClickOnSlotBoxChampion_0_StatusBoxActionHand,  24,  39, 10, 25, k1_LeftMouseButton),
+		MouseInput(k22_CommandClickOnSlotBoxChampion_1_StatusBoxReadyHand,   73,  88, 10, 25, k1_LeftMouseButton),
+		MouseInput(k23_CommandClickOnSlotBoxChampion_1_StatusBoxActionHand,  93, 108, 10, 25, k1_LeftMouseButton),
+		MouseInput(k24_CommandClickOnSlotBoxChampion_2_StatusBoxReadyHand,  142, 157, 10, 25, k1_LeftMouseButton),
+		MouseInput(k25_CommandClickOnSlotBoxChampion_2_StatusBoxActionHand, 162, 177, 10, 25, k1_LeftMouseButton),
+		MouseInput(k26_CommandClickOnSlotBoxChampion_3_StatusBoxReadyHand,  211, 226, 10, 25, k1_LeftMouseButton),
+		MouseInput(k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand, 231, 246, 10, 25, k1_LeftMouseButton),
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput mouseInputPanelChest[9] = { // @ G0456_as_Graphic561_MouseInput_PanelChest[9]
+		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+		MouseInput(k58_CommandClickOnSlotBoxChest_1, 117, 132,  92, 107, k1_LeftMouseButton),
+		MouseInput(k59_CommandClickOnSlotBoxChest_2, 106, 121, 109, 124, k1_LeftMouseButton),
+		MouseInput(k60_CommandClickOnSlotBoxChest_3, 111, 126, 126, 141, k1_LeftMouseButton),
+		MouseInput(k61_CommandClickOnSlotBoxChest_4, 128, 143, 131, 146, k1_LeftMouseButton),
+		MouseInput(k62_CommandClickOnSlotBoxChest_5, 145, 160, 134, 149, k1_LeftMouseButton),
+		MouseInput(k63_CommandClickOnSlotBoxChest_6, 162, 177, 136, 151, k1_LeftMouseButton),
+		MouseInput(k64_CommandClickOnSlotBoxChest_7, 179, 194, 137, 152, k1_LeftMouseButton),
+		MouseInput(k65_CommandClickOnSlotBoxChest_8, 196, 211, 138, 153, k1_LeftMouseButton),
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput mouseInputPanelResurrectReincarnateCancel[4] = { // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4]
+		/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
+		MouseInput(k160_CommandClickInPanelResurrect,   108, 158,  90, 138, k1_LeftMouseButton), /* Atari ST: Box = 104, 158,  86, 142 */
+		MouseInput(k161_CommandClickInPanelReincarnate, 161, 211,  90, 138, k1_LeftMouseButton), /* Atari ST: Box = 163, 217,  86, 142 */
+		MouseInput(k162_CommandClickInPanelCancel,      108, 211, 141, 153, k1_LeftMouseButton), /* Atari ST: Box = 104, 217, 146, 156 */
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+
 	MouseInput *primaryMouseInputDialogSets[2][4] = { // @ G0480_aaps_PrimaryMouseInput_DialogSets
 		{
 			g471_PrimaryMouseInput_ViewportDialog1Choice,
@@ -315,17 +319,27 @@ void EventManager::initArrays() {
 		_primaryMouseInputFrozenGame[i] = primaryMouseInputFrozenGame[i];
 	}
 
-	for (int i = 0; i < 4; i++)
+	for (int i = 0; i < 4; i++) {
 		_primaryMouseInputEntrance[i] = primaryMouseInputEntrance[i];
+		_mouseInputPanelResurrectReincarnateCancel[i] = mouseInputPanelResurrectReincarnateCancel[i];
+	}
 
-	for (int i = 0; i < 5; i++)
+	for (int i = 0; i < 5; i++) {
 		_mouseInputActionAreaNames[i] = mouseInputActionAreaNames[i];
+		_mouseInputActionAreaIcons[i] = mouseInputActionAreaIcons[i];
+	}
 
 	for (int i = 0; i < 7; i++)
 		_primaryKeyboardInputInterface[i] = primaryKeyboardInputInterface[i];
 
-	for (int i = 0; i < 9; i++)
+	for (int i = 0; i < 9; i++) {
 		_secondaryMouseInputMovement[i] = secondaryMouseInputMovement[i];
+		_mouseInputSpellArea[i] = mouseInputSpellArea[i];
+		_mouseInputPanelChest[i] = mouseInputPanelChest[i];
+	}
+
+	for (int i = 0; i < 13; i++)
+		_mouseInputChampionNamesHands[13] = mouseInputChampionNamesHands[i];
 
 	for (int i = 0; i < 19; i++)
 		_secondaryKeyboardInputMovement[i] = secondaryKeyboardInputMovement[i];
@@ -1283,14 +1297,14 @@ void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) {
 	case k4_PanelContentChest:
 		if (champMan._g411_leaderIndex == kM1_ChampionNone) // if no leader
 			return;
-		commandType = f358_getCommandTypeFromMouseInput(g456_MouseInput_PanelChest, Common::Point(x, y), k1_LeftMouseButton);
+		commandType = f358_getCommandTypeFromMouseInput(_mouseInputPanelChest, Common::Point(x, y), k1_LeftMouseButton);
 		if (commandType != k0_CommandNone)
 			_vm->_championMan->f302_processCommands28to65_clickOnSlotBox(commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
 		break;
 	case k5_PanelContentResurrectReincarnate:
 		if (!champMan._g415_leaderEmptyHanded)
 			break;
-		commandType = f358_getCommandTypeFromMouseInput(g457_MouseInput_PanelResurrectReincarnateCancel, Common::Point(x, y), k1_LeftMouseButton);
+		commandType = f358_getCommandTypeFromMouseInput(_mouseInputPanelResurrectReincarnateCancel, Common::Point(x, y), k1_LeftMouseButton);
 		if (commandType != k0_CommandNone)
 			f282_commandProcessCommands160To162ClickInResurrectReincarnatePanel(commandType);
 		break;
@@ -1399,7 +1413,7 @@ void EventManager::f367_commandProcessTypes12to27_clickInChampionStatusBox(uint1
 	if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 		f368_commandSetLeader((ChampionIndex)champIndex);
 	} else {
-		uint16 commandType = f358_getCommandTypeFromMouseInput(g455_MouseInput_ChampionNamesHands, Common::Point(posX, posY), k1_LeftMouseButton);
+		uint16 commandType = f358_getCommandTypeFromMouseInput(_mouseInputChampionNamesHands, Common::Point(posX, posY), k1_LeftMouseButton);
 		if ((commandType >= k16_CommandSetLeaderChampion_0) && (commandType <= k19_CommandSetLeaderChampion_3))
 			f368_commandSetLeader((ChampionIndex)(commandType - k16_CommandSetLeaderChampion_0));
 		else if ((commandType >= k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand) && (commandType <= k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand))
@@ -1504,7 +1518,7 @@ void EventManager::f370_commandProcessType100_clickInSpellArea(uint16 posX, uint
 		return;
 	}
 
-	CommandType newCommand = f358_getCommandTypeFromMouseInput(g454_MouseInput_SpellArea, Common::Point(posX, posY), k1_LeftMouseButton);
+	CommandType newCommand = f358_getCommandTypeFromMouseInput(_mouseInputSpellArea, Common::Point(posX, posY), k1_LeftMouseButton);
 	if (newCommand != k0_CommandNone)
 		f369_commandProcessTypes101To108_clickInSpellSymbolsArea(newCommand);
 }
@@ -1560,7 +1574,7 @@ void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX,
 			}
 		}
 	} else if (_vm->_menuMan->_g509_actionAreaContainsIcons) {
-		uint16 mouseCommand = f358_getCommandTypeFromMouseInput(g453_MouseInput_ActionAreaIcons, Common::Point(posX, posY), k1_LeftMouseButton);
+		uint16 mouseCommand = f358_getCommandTypeFromMouseInput(_mouseInputActionAreaIcons, Common::Point(posX, posY), k1_LeftMouseButton);
 		if (mouseCommand != k0_CommandNone) {
 			mouseCommand -= k116_CommandClickInActionAreaChampion_0_Action;
 			if (mouseCommand < _vm->_championMan->_g305_partyChampionCount)
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 16ade31..9da0cf0 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -180,11 +180,6 @@ public:
 		: _commandTypeToIssue(k0_CommandNone), _hitbox(0, 1, 0, 1), _button(k0_NoneMouseButton) {}
 }; // @ MOUSE_INPUT
 
-extern MouseInput g453_MouseInput_ActionAreaIcons[5]; // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5]
-extern MouseInput g454_MouseInput_SpellArea[9]; // @ G0454_as_Graphic561_MouseInput_SpellArea[9]
-extern MouseInput g455_MouseInput_ChampionNamesHands[13]; // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
-extern MouseInput g456_MouseInput_PanelChest[9]; // @ G0456_as_Graphic561_MouseInput_PanelChest[9]
-extern MouseInput g457_MouseInput_PanelResurrectReincarnateCancel[4]; // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4]
 extern MouseInput g471_PrimaryMouseInput_ViewportDialog1Choice[2]; // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
 extern MouseInput g472_PrimaryMouseInput_ViewportDialog2Choices[3]; // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3]
 extern MouseInput g473_PrimaryMouseInput_ViewportDialog3Choices[4]; // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4]
@@ -323,6 +318,11 @@ public:
 	MouseInput _primaryMouseInputPartySleeping[3]; // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
 	MouseInput _primaryMouseInputFrozenGame[3]; // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3]
 	MouseInput _mouseInputActionAreaNames[5]; // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5]
+	MouseInput _mouseInputActionAreaIcons[5]; // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5]
+	MouseInput _mouseInputSpellArea[9]; // @ G0454_as_Graphic561_MouseInput_SpellArea[9]
+	MouseInput _mouseInputChampionNamesHands[13]; // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
+	MouseInput _mouseInputPanelChest[9]; // @ G0456_as_Graphic561_MouseInput_PanelChest[9]
+	MouseInput _mouseInputPanelResurrectReincarnateCancel[4]; // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4]
 
 	MouseInput *_primaryMouseInputDialogSets[2][4]; // @ G0480_aaps_PrimaryMouseInput_DialogSets
 


Commit: e26a655e6774bf3e58ef4bdb4306b318d47a5609
    https://github.com/scummvm/scummvm/commit/e26a655e6774bf3e58ef4bdb4306b318d47a5609
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Finish moving globals to EventMan

Changed paths:
    engines/dm/eventman.cpp
    engines/dm/eventman.h



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 4410f09..234cac4 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -44,43 +44,6 @@
 
 namespace DM {
 
-MouseInput g471_PrimaryMouseInput_ViewportDialog1Choice[2] = { // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
-	MouseInput(k210_CommandClickOnDialogChoice_1, 16, 207, 138, 152, k1_LeftMouseButton), /* Bottom button */
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g472_PrimaryMouseInput_ViewportDialog2Choices[3] = { // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3]
-	MouseInput(k210_CommandClickOnDialogChoice_1, 16, 207, 101, 115, k1_LeftMouseButton), /* Top button */
-	MouseInput(k211_CommandClickOnDialogChoice_2, 16, 207, 138, 152, k1_LeftMouseButton), /* Bottom button */
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g473_PrimaryMouseInput_ViewportDialog3Choices[4] = { // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4]
-	MouseInput(k210_CommandClickOnDialogChoice_1,  16, 207, 101, 115, k1_LeftMouseButton), /* Top button */
-	MouseInput(k211_CommandClickOnDialogChoice_2,  16, 101, 138, 152, k1_LeftMouseButton), /* Lower left button */
-	MouseInput(k212_CommandClickOnDialogChoice_3, 123, 207, 138, 152, k1_LeftMouseButton), /* Lower right button */
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g474_PrimaryMouseInput_ViewportDialog4Choices[5] = { // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5]
-	MouseInput(k210_CommandClickOnDialogChoice_1,  16, 101, 101, 115, k1_LeftMouseButton), /* Top left button */
-	MouseInput(k211_CommandClickOnDialogChoice_2, 123, 207, 101, 115, k1_LeftMouseButton), /* Top right button */
-	MouseInput(k212_CommandClickOnDialogChoice_3,  16, 101, 138, 152, k1_LeftMouseButton), /* Lower left button */
-	MouseInput(k213_CommandClickOnDialogChoice_4, 123, 207, 138, 152, k1_LeftMouseButton), /* Lower right button */
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g475_PrimaryMouseInput_ScreenDialog1Choice[2] = { // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2]
-	MouseInput(k210_CommandClickOnDialogChoice_1, 63, 254, 138, 152, k1_LeftMouseButton), /* Bottom button */
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g476_PrimaryMouseInput_ScreenDialog2Choices[3] = { // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3]
-	MouseInput(k210_CommandClickOnDialogChoice_1, 63, 254, 101, 115, k1_LeftMouseButton), /* Top button */
-	MouseInput(k211_CommandClickOnDialogChoice_2, 63, 254, 138, 152, k1_LeftMouseButton), /* Bottom button */
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g477_PrimaryMouseInput_ScreenDialog3Choices[4] = { // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4]
-	MouseInput(k210_CommandClickOnDialogChoice_1,  63, 254, 101, 115, k1_LeftMouseButton), /* Top button */
-	MouseInput(k211_CommandClickOnDialogChoice_2,  63, 148, 138, 152, k1_LeftMouseButton), /* Lower left button */
-	MouseInput(k212_CommandClickOnDialogChoice_3, 170, 254, 138, 152, k1_LeftMouseButton), /* Lower right button */
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-MouseInput g478_PrimaryMouseInput_ScreenDialog4Choices[5] = { // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
-	MouseInput(k210_CommandClickOnDialogChoice_1,  63, 148, 101, 115, k1_LeftMouseButton), /* Top left button */
-	MouseInput(k211_CommandClickOnDialogChoice_2, 170, 254, 101, 115, k1_LeftMouseButton), /* Top right button */
-	MouseInput(k212_CommandClickOnDialogChoice_3,  63, 148, 138, 152, k1_LeftMouseButton), /* Lower left button */
-	MouseInput(k213_CommandClickOnDialogChoice_4, 170, 254, 138, 152, k1_LeftMouseButton), /* Lower right button */
-	MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)};
-
 void EventManager::initArrays() {
 	KeyboardInput primaryKeyboardInputInterface[7] = { // @ G0458_as_Graphic561_PrimaryKeyboardInput_Interface
 		/* { Command, Code } */
@@ -290,25 +253,71 @@ void EventManager::initArrays() {
 		MouseInput(k162_CommandClickInPanelCancel,      108, 211, 141, 153, k1_LeftMouseButton), /* Atari ST: Box = 104, 217, 146, 156 */
 		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
 	};
+	MouseInput primaryMouseInputViewportDialog1Choice[2] = { // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
+		MouseInput(k210_CommandClickOnDialogChoice_1, 16, 207, 138, 152, k1_LeftMouseButton), /* Bottom button */
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput primaryMouseInputViewportDialog2Choices[3] = { // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3]
+		MouseInput(k210_CommandClickOnDialogChoice_1, 16, 207, 101, 115, k1_LeftMouseButton), /* Top button */
+		MouseInput(k211_CommandClickOnDialogChoice_2, 16, 207, 138, 152, k1_LeftMouseButton), /* Bottom button */
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput primaryMouseInputViewportDialog3Choices[4] = { // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4]
+		MouseInput(k210_CommandClickOnDialogChoice_1,  16, 207, 101, 115, k1_LeftMouseButton), /* Top button */
+		MouseInput(k211_CommandClickOnDialogChoice_2,  16, 101, 138, 152, k1_LeftMouseButton), /* Lower left button */
+		MouseInput(k212_CommandClickOnDialogChoice_3, 123, 207, 138, 152, k1_LeftMouseButton), /* Lower right button */
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput primaryMouseInputViewportDialog4Choices[5] = { // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5]
+		MouseInput(k210_CommandClickOnDialogChoice_1,  16, 101, 101, 115, k1_LeftMouseButton), /* Top left button */
+		MouseInput(k211_CommandClickOnDialogChoice_2, 123, 207, 101, 115, k1_LeftMouseButton), /* Top right button */
+		MouseInput(k212_CommandClickOnDialogChoice_3,  16, 101, 138, 152, k1_LeftMouseButton), /* Lower left button */
+		MouseInput(k213_CommandClickOnDialogChoice_4, 123, 207, 138, 152, k1_LeftMouseButton), /* Lower right button */
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput primaryMouseInputScreenDialog1Choice[2] = { // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2]
+		MouseInput(k210_CommandClickOnDialogChoice_1, 63, 254, 138, 152, k1_LeftMouseButton), /* Bottom button */
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput primaryMouseInputScreenDialog2Choices[3] = { // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3]
+		MouseInput(k210_CommandClickOnDialogChoice_1, 63, 254, 101, 115, k1_LeftMouseButton), /* Top button */
+		MouseInput(k211_CommandClickOnDialogChoice_2, 63, 254, 138, 152, k1_LeftMouseButton), /* Bottom button */
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput primaryMouseInputScreenDialog3Choices[4] = { // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4]
+		MouseInput(k210_CommandClickOnDialogChoice_1,  63, 254, 101, 115, k1_LeftMouseButton), /* Top button */
+		MouseInput(k211_CommandClickOnDialogChoice_2,  63, 148, 138, 152, k1_LeftMouseButton), /* Lower left button */
+		MouseInput(k212_CommandClickOnDialogChoice_3, 170, 254, 138, 152, k1_LeftMouseButton), /* Lower right button */
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
+	MouseInput primaryMouseInputScreenDialog4Choices[5] = { // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
+		MouseInput(k210_CommandClickOnDialogChoice_1,  63, 148, 101, 115, k1_LeftMouseButton), /* Top left button */
+		MouseInput(k211_CommandClickOnDialogChoice_2, 170, 254, 101, 115, k1_LeftMouseButton), /* Top right button */
+		MouseInput(k212_CommandClickOnDialogChoice_3,  63, 148, 138, 152, k1_LeftMouseButton), /* Lower left button */
+		MouseInput(k213_CommandClickOnDialogChoice_4, 170, 254, 138, 152, k1_LeftMouseButton), /* Lower right button */
+		MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)
+	};
 
 	MouseInput *primaryMouseInputDialogSets[2][4] = { // @ G0480_aaps_PrimaryMouseInput_DialogSets
 		{
-			g471_PrimaryMouseInput_ViewportDialog1Choice,
-			g472_PrimaryMouseInput_ViewportDialog2Choices,
-			g473_PrimaryMouseInput_ViewportDialog3Choices,
-			g474_PrimaryMouseInput_ViewportDialog4Choices
+			_primaryMouseInputViewportDialog1Choice,
+			_primaryMouseInputViewportDialog2Choices,
+			_primaryMouseInputViewportDialog3Choices,
+			_primaryMouseInputViewportDialog4Choices
 		},
 		{
-			g475_PrimaryMouseInput_ScreenDialog1Choice,
-			g476_PrimaryMouseInput_ScreenDialog2Choices,
-			g477_PrimaryMouseInput_ScreenDialog3Choices,
-			g478_PrimaryMouseInput_ScreenDialog4Choices
+			_primaryMouseInputScreenDialog1Choice,
+			_primaryMouseInputScreenDialog2Choices,
+			_primaryMouseInputScreenDialog3Choices,
+			_primaryMouseInputScreenDialog4Choices
 		}
 	};
 
 	for (int i = 0; i < 2; i++) {
 		_primaryKeyboardInputFrozenGame[i] = primaryKeyboardInputFrozenGame[i];
 		_primaryMouseInputRestartGame[i] = primaryMouseInputRestartGame[i];
+		_primaryMouseInputViewportDialog1Choice[i] = primaryMouseInputViewportDialog1Choice[i];
+		_primaryMouseInputScreenDialog1Choice[i] = primaryMouseInputScreenDialog1Choice[i];
 		for (int j = 0; j < 4; j++)
 			_primaryMouseInputDialogSets[i][j] = primaryMouseInputDialogSets[i][j];
 	}
@@ -317,16 +326,22 @@ void EventManager::initArrays() {
 		_primaryKeyboardInputPartySleeping[i] = primaryKeyboardInputPartySleeping[i];
 		_primaryMouseInputPartySleeping[i] = primaryMouseInputPartySleeping[i];
 		_primaryMouseInputFrozenGame[i] = primaryMouseInputFrozenGame[i];
+		_primaryMouseInputViewportDialog2Choices[i] = primaryMouseInputViewportDialog2Choices[i];
+		_primaryMouseInputScreenDialog2Choices[i] = primaryMouseInputScreenDialog2Choices[i];
 	}
 
 	for (int i = 0; i < 4; i++) {
 		_primaryMouseInputEntrance[i] = primaryMouseInputEntrance[i];
 		_mouseInputPanelResurrectReincarnateCancel[i] = mouseInputPanelResurrectReincarnateCancel[i];
+		_primaryMouseInputViewportDialog3Choices[i] = primaryMouseInputViewportDialog3Choices[i];
+		_primaryMouseInputScreenDialog3Choices[i] = primaryMouseInputScreenDialog3Choices[i];
 	}
 
 	for (int i = 0; i < 5; i++) {
 		_mouseInputActionAreaNames[i] = mouseInputActionAreaNames[i];
 		_mouseInputActionAreaIcons[i] = mouseInputActionAreaIcons[i];
+		_primaryMouseInputViewportDialog4Choices[i] = primaryMouseInputViewportDialog4Choices[i];
+		_primaryMouseInputScreenDialog4Choices[i] = primaryMouseInputScreenDialog4Choices[i];
 	}
 
 	for (int i = 0; i < 7; i++)
@@ -349,7 +364,6 @@ void EventManager::initArrays() {
 
 	for (int i = 0; i < 38; i++)
 		_secondaryMouseInputChampionInventory[i] = secondaryMouseInputChampionInventory[i];
-
 }
 EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 	_mousePos = Common::Point(0, 0);
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 9da0cf0..1066f35 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -180,15 +180,6 @@ public:
 		: _commandTypeToIssue(k0_CommandNone), _hitbox(0, 1, 0, 1), _button(k0_NoneMouseButton) {}
 }; // @ MOUSE_INPUT
 
-extern MouseInput g471_PrimaryMouseInput_ViewportDialog1Choice[2]; // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
-extern MouseInput g472_PrimaryMouseInput_ViewportDialog2Choices[3]; // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3]
-extern MouseInput g473_PrimaryMouseInput_ViewportDialog3Choices[4]; // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4]
-extern MouseInput g474_PrimaryMouseInput_ViewportDialog4Choices[5]; // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5]
-extern MouseInput g475_PrimaryMouseInput_ScreenDialog1Choice[2]; // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2]
-extern MouseInput g476_PrimaryMouseInput_ScreenDialog2Choices[3]; // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3]
-extern MouseInput g477_PrimaryMouseInput_ScreenDialog3Choices[4]; // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4]
-extern MouseInput g478_PrimaryMouseInput_ScreenDialog4Choices[5]; // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
-
 class KeyboardInput {
 public:
 	CommandType _commandToIssue;
@@ -323,6 +314,14 @@ public:
 	MouseInput _mouseInputChampionNamesHands[13]; // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
 	MouseInput _mouseInputPanelChest[9]; // @ G0456_as_Graphic561_MouseInput_PanelChest[9]
 	MouseInput _mouseInputPanelResurrectReincarnateCancel[4]; // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4]
+	MouseInput _primaryMouseInputViewportDialog1Choice[2]; // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
+	MouseInput _primaryMouseInputScreenDialog1Choice[2]; // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2]
+	MouseInput _primaryMouseInputViewportDialog2Choices[3]; // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3]
+	MouseInput _primaryMouseInputScreenDialog2Choices[3]; // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3]
+	MouseInput _primaryMouseInputViewportDialog3Choices[4]; // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4]
+	MouseInput _primaryMouseInputScreenDialog3Choices[4]; // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4]
+	MouseInput _primaryMouseInputViewportDialog4Choices[5]; // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5]
+	MouseInput _primaryMouseInputScreenDialog4Choices[5]; // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
 
 	MouseInput *_primaryMouseInputDialogSets[2][4]; // @ G0480_aaps_PrimaryMouseInput_DialogSets
 


Commit: 20165b18656ee6ddb2586983735fa280abfefc54
    https://github.com/scummvm/scummvm/commit/20165b18656ee6ddb2586983735fa280abfefc54
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some GCC warnings

Changed paths:
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp



diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 234cac4..a3677b0 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -926,7 +926,7 @@ void EventManager::f365_commandTurnParty(CommandType cmdType) {
 		f362_commandHighlightBoxEnable(291, 318, 125, 145);
 
 	uint16 partySquare = _vm->_dungeonMan->f151_getSquare(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY).toByte();
-	if (Square(partySquare).getType() == k3_ElementTypeStairs) {
+	if (Square(partySquare).getType() == k3_StairsElemType) {
 		f364_commandTakeStairs(getFlag(partySquare, k0x0004_StairsUp));
 		return;
 	}
@@ -971,7 +971,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	int16 partyMapX = _vm->_dungeonMan->_g306_partyMapX;
 	int16 partyMapY = _vm->_dungeonMan->_g307_partyMapY;
 	uint16 AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(partyMapX, partyMapY).toByte();
-	bool isStairsSquare = (Square(AL1115_ui_Square).getType() == k3_ElementTypeStairs);
+	bool isStairsSquare = (Square(AL1115_ui_Square).getType() == k3_StairsElemType);
 	if (isStairsSquare && (movementArrowIdx == 2)) { /* If moving backward while in stairs */
 		f364_commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp));
 		return;
@@ -1006,8 +1006,11 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 
 			if (damage)
 				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, partyMapX, partyMapY, k0_soundModePlayImmediately);
-		} else if (isMovementBlocked = (_vm->_groupMan->f175_groupGetThing(partyMapX, partyMapY) != Thing::_endOfList))
-			_vm->_groupMan->f209_processEvents29to41(partyMapX, partyMapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
+		} else {
+			isMovementBlocked = (_vm->_groupMan->f175_groupGetThing(partyMapX, partyMapY) != Thing::_endOfList);
+			if (isMovementBlocked)
+				_vm->_groupMan->f209_processEvents29to41(partyMapX, partyMapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
+		}
 	}
 
 	// DEBUG CODE: check for Console flag
@@ -1043,7 +1046,7 @@ bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int
 
 	bool objectThrownFl;
 	if (posX <= 111) {
-		if (_vm->_dungeonMan->_g285_squareAheadElement == k17_DoorFrontElemType) {
+		if (_vm->_dungeonMan->_g285_squareAheadElement == k17_ElementTypeDoorFront) {
 			if (posX < 64)
 				return false;
 		} else if (posX < 32)
@@ -1052,7 +1055,7 @@ bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int
 		// Strangerke: Only present in CSB2.1... But it fixes a bug so we keep it
 		objectThrownFl = _vm->_championMan->f329_isLeaderHandObjectThrown(k0_sideLeft);
 	} else {
-		if (_vm->_dungeonMan->_g285_squareAheadElement == k17_DoorFrontElemType) {
+		if (_vm->_dungeonMan->_g285_squareAheadElement == k17_ElementTypeDoorFront) {
 			if (posX > 163)
 				return false;
 		} else if (posX > 191)
@@ -1137,7 +1140,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 		Box(40, 111, 122, 147)    /* Back left */
 	};
 
-	if (_vm->_dungeonMan->_g285_squareAheadElement == k17_DoorFrontElemType) {
+	if (_vm->_dungeonMan->_g285_squareAheadElement == k17_ElementTypeDoorFront) {
 		if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone)
 			return;
 
@@ -1522,7 +1525,8 @@ void EventManager::f370_commandProcessType100_clickInSpellArea(uint16 posX, uint
 				championIndex = 2;
 			else if (posX <= 244)
 				championIndex = 0;
-
+			break;
+		default:
 			break;
 		}
 
@@ -1620,6 +1624,8 @@ void EventManager::f541_waitForMouseOrKeyActivity() {
 			case Common::EVENT_LBUTTONDOWN:
 			case Common::EVENT_RBUTTONDOWN:
 				return;
+			default:
+				break;
 			}
 		}
 		_vm->f22_delay(1);
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 07b3b61..5f568a8 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -339,17 +339,17 @@ void DisplayMan::initConstants() {
 	static uint16 palCredits[16] = {0x006, 0x0AA, 0xFF6, 0x840, 0xFF8, 0x000, 0x080, 0xA00, 0xC84, 0xFFA, 0xF84, 0xFC0, 0xFA0, 0x000, 0x620, 0xFFC}; // @ G0019_aui_Graphic562_Palette_Credits
 	static uint16 palDungeonView[6][16] = { // @ G0021_aaui_Graphic562_Palette_DungeonView
 		/* Atari ST: { 0x000, 0x333, 0x444, 0x310, 0x066, 0x420, 0x040, 0x060, 0x700, 0x750, 0x643, 0x770, 0x222, 0x555, 0x007, 0x777 }, RGB colors are different */
-		0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x444, 0xAAA, 0x00F, 0xFFF,
+		{ 0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x444, 0xAAA, 0x00F, 0xFFF },
 		/* Atari ST: { 0x000, 0x222, 0x333, 0x310, 0x066, 0x410, 0x030, 0x050, 0x600, 0x640, 0x532, 0x760, 0x111, 0x444, 0x006, 0x666 }, RGB colors are different */
-		0x000, 0x444, 0x666, 0x620, 0x0CC, 0x820, 0x060, 0x0A0, 0xC00, 0x000, 0x000, 0xFC0, 0x222, 0x888, 0x00C, 0xCCC,
+		{ 0x000, 0x444, 0x666, 0x620, 0x0CC, 0x820, 0x060, 0x0A0, 0xC00, 0x000, 0x000, 0xFC0, 0x222, 0x888, 0x00C, 0xCCC },
 		/* Atari ST: { 0x000, 0x111, 0x222, 0x210, 0x066, 0x310, 0x020, 0x040, 0x500, 0x530, 0x421, 0x750, 0x000, 0x333, 0x005, 0x555 }, RGB colors are different */
-		0x000, 0x222, 0x444, 0x420, 0x0CC, 0x620, 0x040, 0x080, 0xA00, 0x000, 0x000, 0xFA0, 0x000, 0x666, 0x00A, 0xAAA,
+		{ 0x000, 0x222, 0x444, 0x420, 0x0CC, 0x620, 0x040, 0x080, 0xA00, 0x000, 0x000, 0xFA0, 0x000, 0x666, 0x00A, 0xAAA },
 		/* Atari ST: { 0x000, 0x000, 0x111, 0x100, 0x066, 0x210, 0x010, 0x030, 0x400, 0x420, 0x310, 0x640, 0x000, 0x222, 0x004, 0x444 }, RGB colors are different */
-		0x000, 0x000, 0x222, 0x200, 0x0CC, 0x420, 0x020, 0x060, 0x800, 0x000, 0x000, 0xC80, 0x000, 0x444, 0x008, 0x888,
+		{ 0x000, 0x000, 0x222, 0x200, 0x0CC, 0x420, 0x020, 0x060, 0x800, 0x000, 0x000, 0xC80, 0x000, 0x444, 0x008, 0x888 },
 		/* Atari ST: { 0x000, 0x000, 0x000, 0x000, 0x066, 0x100, 0x000, 0x020, 0x300, 0x310, 0x200, 0x530, 0x000, 0x111, 0x003, 0x333 }, RGB colors are different */
-		0x000, 0x000, 0x000, 0x000, 0x0CC, 0x200, 0x000, 0x040, 0x600, 0x000, 0x000, 0xA60, 0x000, 0x222, 0x006, 0x666,
+		{ 0x000, 0x000, 0x000, 0x000, 0x0CC, 0x200, 0x000, 0x040, 0x600, 0x000, 0x000, 0xA60, 0x000, 0x222, 0x006, 0x666 },
 		/* Atari ST: { 0x000, 0x000, 0x000, 0x000, 0x066, 0x000, 0x000, 0x010, 0x200, 0x200, 0x100, 0x320, 0x000, 0x000, 0x002, 0x222 }, RGB colors are different */
-		0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444
+		{ 0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444 }
 	};
 
 	static byte palChangesCreatureD3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 0, 0, 110, 0, 20, 0, 130}; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3
@@ -370,7 +370,7 @@ void DisplayMan::initConstants() {
 		_palCredits[i] = palCredits[i];
 		_palChangesCreatureD3[i] = palChangesCreatureD3[i];
 		_palChangesCreatureD2[i] = palChangesCreatureD2[i];
-		_palChangesNoChanges[16] = palChangesNoChanges[i];
+		_palChangesNoChanges[i] = palChangesNoChanges[i];
 		_palChangesFloorOrnD3[i] = palChangesFloorOrnD3[i];
 		_palChangesFloorOrnD2[i] = palChangesFloorOrnD2[i];
 		for (int j = 0; j < 6; j++)
@@ -398,16 +398,16 @@ void DisplayMan::initConstants() {
 		_projectileAspect[i] = projectileAspect[i];
 
 	_doorFrameD1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C
-								   Frame(64, 159, 17, 102, 48, 88, 0, 0),	 /* Closed Or Destroyed */
-								   Frame(64, 159, 17, 38, 48, 88, 0, 66),	 /* Vertical Closed one fourth */
-								   Frame(64, 159, 17, 60, 48, 88, 0, 44),	 /* Vertical Closed half */
-								   Frame(64, 159, 17, 82, 48, 88, 0, 22),	 /* Vertical Closed three fourth */
-								   Frame(64, 75, 17, 102, 48, 88, 36, 0),	 /* Left Horizontal Closed one fourth */
-								   Frame(64, 87, 17, 102, 48, 88, 24, 0),	 /* Left Horizontal Closed half */
-								   Frame(64, 99, 17, 102, 48, 88, 12, 0),	 /* Left Horizontal Closed three fourth */
-								   Frame(148, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */
-								   Frame(136, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */
-								   Frame(124, 159, 17, 102, 48, 88, 48, 0)	 /* Right Horizontal Closed three fourth */
+	   Frame(64, 159, 17, 102, 48, 88, 0, 0),	 /* Closed Or Destroyed */
+	   Frame(64, 159, 17, 38, 48, 88, 0, 66),	 /* Vertical Closed one fourth */
+	   Frame(64, 159, 17, 60, 48, 88, 0, 44),	 /* Vertical Closed half */
+	   Frame(64, 159, 17, 82, 48, 88, 0, 22),	 /* Vertical Closed three fourth */
+	   Frame(64, 75, 17, 102, 48, 88, 36, 0),	 /* Left Horizontal Closed one fourth */
+	   Frame(64, 87, 17, 102, 48, 88, 24, 0),	 /* Left Horizontal Closed half */
+	   Frame(64, 99, 17, 102, 48, 88, 12, 0),	 /* Left Horizontal Closed three fourth */
+	   Frame(148, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */
+	   Frame(136, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */
+	   Frame(124, 159, 17, 102, 48, 88, 48, 0)	 /* Right Horizontal Closed three fourth */
 	);
 
 	_boxThievesEyeViewPortVisibleArea = Box(64, 159, 19, 113); // @ G0106_s_Graphic558_Box_ThievesEye_ViewportVisibleArea 
@@ -1159,7 +1159,7 @@ void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int1
 		return;
 
 	int16 mapSquare = _vm->_dungeonMan->_g279_dungeonMapData[mapIndex][mapX][mapY];
-	if ((Square(mapSquare).getType() == k2_ElementTypePit) && getFlag(mapSquare, k0x0008_PitOpen)) {
+	if ((Square(mapSquare).getType() == k2_PitElemType) && getFlag(mapSquare, k0x0008_PitOpen)) {
 		if (flipHorizontal)
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(nativeBitmapIndex, *frame);
 		else


Commit: 53121afb092587f87faf0281b08e96ff1c59e44e
    https://github.com/scummvm/scummvm/commit/53121afb092587f87faf0281b08e96ff1c59e44e
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some GCC warnings

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dmglobals.cpp
    engines/dm/dungeonman.cpp
    engines/dm/inventory.cpp
    engines/dm/menus.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 57d7f5e..51f89f4 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -41,51 +41,6 @@
 
 namespace DM {
 
-uint16 gSlotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
-						   /* 30 for champion inventory, 8 for chest */
-	0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Action Hand      Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0x0002,   /* Head             Head */
-	0x0008,   /* Torso            Torso */
-	0x0010,   /* Legs             Legs */
-	0x0020,   /* Feet             Feet */
-	0x0100,   /* Pouch 2          Pouch */
-	0x0080,   /* Quiver Line2 1   Quiver 2 */
-	0x0080,   /* Quiver Line1 2   Quiver 2 */
-	0x0080,   /* Quiver Line2 2   Quiver 2 */
-	0x0004,   /* Neck             Neck */
-	0x0100,   /* Pouch 1          Pouch */
-	0x0040,   /* Quiver Line1 1   Quiver 1 */
-	0xFFFF,   /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0xFFFF,   /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
-	0x0400,   /* Chest 1          Chest */
-	0x0400,   /* Chest 2          Chest */
-	0x0400,   /* Chest 3          Chest */
-	0x0400,   /* Chest 4          Chest */
-	0x0400,   /* Chest 5          Chest */
-	0x0400,   /* Chest 6          Chest */
-	0x0400,   /* Chest 7          Chest */
-	0x0400}; /* Chest 8          Chest */
-
-Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
-
-const char *g417_baseSkillName[4];
-
 void ChampionMan::initConstants() {
 	static const char *g417_baseSkillName_EN_ANY[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"};
 	static const char *g417_baseSkillName_DE_DEU[4] = {"KAEMPFER", "NINJA", "PRIESTER", "MAGIER"};
@@ -99,6 +54,49 @@ void ChampionMan::initConstants() {
 
 	static Color championColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14};
 	int16 lightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100};
+	uint16 slotMasks[38] = {  // @ G0038_ai_Graphic562_SlotMasks
+		/* 30 for champion inventory, 8 for chest */
+		0xFFFF,   /* Ready Hand       Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Action Hand      Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0x0002,   /* Head             Head */
+		0x0008,   /* Torso            Torso */
+		0x0010,   /* Legs             Legs */
+		0x0020,   /* Feet             Feet */
+		0x0100,   /* Pouch 2          Pouch */
+		0x0080,   /* Quiver Line2 1   Quiver 2 */
+		0x0080,   /* Quiver Line1 2   Quiver 2 */
+		0x0080,   /* Quiver Line2 2   Quiver 2 */
+		0x0004,   /* Neck             Neck */
+		0x0100,   /* Pouch 1          Pouch */
+		0x0040,   /* Quiver Line1 1   Quiver 1 */
+		0xFFFF,   /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0xFFFF,   /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
+		0x0400,   /* Chest 1          Chest */
+		0x0400,   /* Chest 2          Chest */
+		0x0400,   /* Chest 3          Chest */
+		0x0400,   /* Chest 4          Chest */
+		0x0400,   /* Chest 5          Chest */
+		0x0400,   /* Chest 6          Chest */
+		0x0400,   /* Chest 7          Chest */
+		0x0400    /* Chest 8          Chest */
+	};
+
+	_boxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
 
 	const char **g417_byLanguage;
 	switch (_vm->getGameLanguage()) { // localized
@@ -116,7 +114,7 @@ void ChampionMan::initConstants() {
 	}
 
 	for (int i = 0; i < 4; ++i) {
-		g417_baseSkillName[i] = g417_byLanguage[i];
+		_baseSkillName[i] = g417_byLanguage[i];
 		_championColor[i] = championColor[i];
 		_boxChampionIcons[i] = boxChampionIcons[i];
 	}
@@ -124,6 +122,8 @@ void ChampionMan::initConstants() {
 	for (int i = 0; i < 16; i++)
 		_lightPowerToLightAmount[i] = lightPowerToLightAmount[i];
 
+	for (int i = 0; i < 38; i++)
+		_slotMasks[i] = slotMasks[i];
 }
 
 ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
@@ -1008,7 +1008,7 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex,
 			case Common::FR_FRA: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " VIENT DE DEVENIR "); break;
 			}
 
-			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, g417_baseSkillName[baseSkillIndex]);
+			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, _baseSkillName[baseSkillIndex]);
 
 			switch (_vm->getGameLanguage()) { // localized
 			default:
@@ -1285,7 +1285,7 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex)
 	if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none))
 		return;
 
-	if ((leaderHandObject != Thing::_none) && (!(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & gSlotMasks[slotIndex])))
+	if ((leaderHandObject != Thing::_none) && (!(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & _slotMasks[slotIndex])))
 		return;
 
 	_vm->_eventMan->f78_showMouse();
@@ -1838,7 +1838,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 	championPtr->resetToZero();
 	// Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portraits could be missing in the data)
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
-	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, gBoxChampionPortrait, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency, 87, 29);
+	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, _boxChampionPortrait, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency, 87, 29);
 	championPtr->_actionIndex = k255_ChampionActionNone;
 	championPtr->_enableActionEventIndex = -1;
 	championPtr->_hideDamageReceivedIndex = -1;
@@ -1931,12 +1931,12 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 		ThingType thingType = curThing.getType();
 		if ((thingType > k3_SensorThingType) && (curThing.getCell() == championObjectsCell)) {
 			int16 objectAllowedSlots = _vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(curThing)]._allowedSlots;
-			uint16 curSlotIndex;
+			uint16 curSlotIndex = k0_ChampionSlotReadyHand;
 			switch (thingType) {
 			case k6_ArmourThingType: {
 				bool skipCheck = false;
 				for (curSlotIndex = k2_ChampionSlotHead; curSlotIndex <= k5_ChampionSlotFeet; curSlotIndex++) {
-					if (objectAllowedSlots & gSlotMasks[curSlotIndex]) {
+					if (objectAllowedSlots & _slotMasks[curSlotIndex]) {
 						skipCheck = true;
 						break;
 					}
@@ -1945,7 +1945,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 				if (skipCheck)
 					break;
 
-				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
+				if ((objectAllowedSlots & _slotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
 					curSlotIndex = k10_ChampionSlotNeck;
 				else
 					curSlotIndex = slotIdx++;
@@ -1955,7 +1955,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 			case k5_WeaponThingType:
 				if (championPtr->_slots[k1_ChampionSlotActionHand] == Thing::_none)
 					curSlotIndex = k1_ChampionSlotActionHand;
-				else if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
+				else if ((objectAllowedSlots & _slotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
 					curSlotIndex = k10_ChampionSlotNeck;
 				else
 					curSlotIndex = slotIdx++;
@@ -1966,14 +1966,14 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 					curSlotIndex = k11_ChampionSlotPouch_1;
 				else if (championPtr->_slots[k6_ChampionSlotPouch_2] == Thing::_none)
 					curSlotIndex = k6_ChampionSlotPouch_2;
-				else if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
+				else if ((objectAllowedSlots & _slotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
 					curSlotIndex = k10_ChampionSlotNeck;
 				else
 					curSlotIndex = slotIdx++;
 				break;
 			case k9_ContainerThingType:
 			case k10_JunkThingType:
-				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
+				if ((objectAllowedSlots & _slotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
 					curSlotIndex = k10_ChampionSlotNeck;
 				else
 					curSlotIndex = slotIdx++;
@@ -1984,7 +1984,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 			}
 
 			while (championPtr->_slots[curSlotIndex] != Thing::_none) {
-				if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
+				if ((objectAllowedSlots & _slotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
 					curSlotIndex = k10_ChampionSlotNeck;
 				else
 					curSlotIndex = slotIdx++;
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index af039b7..f7e9f1f 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -448,7 +448,6 @@ public:
 #define k0x8000_maskUseSharpDefense 0x8000 // @ MASK0x8000_USE_SHARP_DEFENSE        
 
 #define k0x8000_mergeCycles 0x8000 // @ MASK0x8000_MERGE_CYCLES
-extern const char *g417_baseSkillName[4]; // @ G0417_apc_BaseSkillNames
 
 #define k0_spellCastFailure 0 // @ C0_SPELL_CAST_FAILURE             
 #define k1_spellCastSuccess 1 // @ C1_SPELL_CAST_SUCCESS             
@@ -590,6 +589,9 @@ public:
 	Box _boxChampionIcons[4];
 	Color _championColor[4];
 	int16 _lightPowerToLightAmount[16]; // g039_LightPowerToLightAmount
+	Box _boxChampionPortrait;
+	uint16 _slotMasks[38];
+	const char *_baseSkillName[4];
 };
 
 }
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 9f84269..ac85b9d 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -72,13 +72,13 @@ void warning(bool repeat, const char* s, ...) {
 	va_end(va);
 
 	if (repeat) {
-		::warning(output.c_str());
+		::warning("%s", output.c_str());
 	} else {
 		static Common::Array<Common::String> stringsPrinted;
 
 		if (Common::find(stringsPrinted.begin(), stringsPrinted.end(), s) == stringsPrinted.end()) {
 			stringsPrinted.push_back(output);
-			::warning(output.c_str());
+			::warning("%s", output.c_str());
 		}
 	}
 }
@@ -683,7 +683,7 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 					char displStr[20];
 					strcpy(displStr, G0428_apc_SkillLevelNames[skillLevel - 2]);
 					strcat(displStr, " ");
-					strcat(displStr, g417_baseSkillName[idx]);
+					strcat(displStr, _championMan->_baseSkillName[idx]);
 					_textMan->f443_endgamePrintString(105, textPosY = textPosY + 8, k13_ColorLightestGray, displStr);
 				}
 				championMirrorBox._y1 += 48;
diff --git a/engines/dm/dmglobals.cpp b/engines/dm/dmglobals.cpp
index 044659a..6457c85 100644
--- a/engines/dm/dmglobals.cpp
+++ b/engines/dm/dmglobals.cpp
@@ -57,8 +57,7 @@ void DMEngine::initArrays() {
 }
 
 void DMEngine::f19_displayErrorAndStop(int16 errorIndex) {
-	debug("Stuff hit the fun: ");
-	debug(Common::String::format("%d", errorIndex).c_str());
+	debug("Stuff hit the fun: %d", errorIndex);
 	Common::Event event;
 	while (_system->getEventManager()->pollEvent(event) || true)
 		;
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 8a17ce6..287c454 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -797,19 +797,19 @@ Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) {
 
 	if (isMapYInBounds) {
 		SquareType squareType = Square(_g271_currMapData[0][mapY]).getType();
-		if (((mapX == -1) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit))
+		if (((mapX == -1) && (squareType == k1_CorridorElemType)) || (squareType == k2_PitElemType))
 			return Square(k0_ElementTypeWall, k0x0004_WallEastRandOrnAllowed);
 
 		squareType = Square(_g271_currMapData[_g273_currMapWidth - 1][mapY]).getType();
-		if (((mapX == _g273_currMapWidth) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit))
+		if (((mapX == _g273_currMapWidth) && (squareType == k1_CorridorElemType)) || (squareType == k2_PitElemType))
 			return Square(k0_ElementTypeWall, k0x0001_WallWestRandOrnAllowed);
 	} else if (isMapXInBounds) {
 		SquareType squareType = Square(_g271_currMapData[mapX][0]).getType();
-		if (((mapY == -1) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit))
+		if (((mapY == -1) && (squareType == k1_CorridorElemType)) || (squareType == k2_PitElemType))
 			return Square(k0_ElementTypeWall, k0x0002_WallSouthRandOrnAllowed);
 
 		squareType = Square(_g271_currMapData[mapX][_g274_currMapHeight - 1]).getType();
-		if (((mapY == _g274_currMapHeight) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit))
+		if (((mapY == _g274_currMapHeight) && (squareType == k1_CorridorElemType)) || (squareType == k2_PitElemType))
 			return Square(k0_ElementTypeWall, k0x0008_WallNorthRandOrnAllowed);
 	}
 	return Square(k0_ElementTypeWall, 0);
@@ -941,7 +941,7 @@ T0172010_ClosedFakeWall:
 			AL0307_uc_FootprintsAllowed = true;
 		}
 
-		while ((curThing != Thing::_endOfList) && ((Direction)curThing.getType() <= k3_SensorThingType)) {
+		while ((curThing != Thing::_endOfList) && (curThing.getType() <= k3_SensorThingType)) {
 			if (curThing.getType() == k3_SensorThingType) {
 				Sensor *curSensor = (Sensor*)f156_getThingData(curThing);
 				aspectArray[k4_FloorOrnOrdAspect] = curSensor->getOrnOrdinal();
@@ -1271,6 +1271,8 @@ uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 	case k7_ScrollThingType:
 		weight = 1;
 		break;
+	default:
+		break;
 	}
 
 	return weight; // this is garbage if none of the branches were taken
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index e2cfd96..3800b95 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -825,10 +825,10 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 		case Common::DE_DEU: // english and german versions are the same
 			strcpy(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]);
 			strcat(L1097_ac_String, " ");
-			strcat(L1097_ac_String, g417_baseSkillName[AL1090_ui_SkillIndex]);
+			strcat(L1097_ac_String, _vm->_championMan->_baseSkillName[AL1090_ui_SkillIndex]);
 			break;
 		case Common::FR_FRA:
-			strcat(L1097_ac_String, g417_baseSkillName[AL1090_ui_SkillIndex]);
+			strcat(L1097_ac_String, _vm->_championMan->_baseSkillName[AL1090_ui_SkillIndex]);
 			strcat(L1097_ac_String, " ");
 			strcpy(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]);
 			break;
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index abeadd7..9aaff30 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -679,9 +679,9 @@ Spell* MenuMan::f409_getSpellFromSymbols(byte* symbols) {
 void MenuMan::f410_menusPrintSpellFailureMessage(Champion* champ, uint16 failureType, uint16 skillIndex) {
 	char* L1264_pc_Message = nullptr;
 
-	if (skillIndex > k3_ChampionSkillWizard) {
+	if (skillIndex > k3_ChampionSkillWizard)
 		skillIndex = (skillIndex - 4) / 4;
-	}
+
 	_vm->_textMan->f51_messageAreaPrintLineFeed();
 	_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, champ->_name);
 
@@ -704,12 +704,12 @@ void MenuMan::f410_menusPrintSpellFailureMessage(Champion* champ, uint16 failure
 	switch (failureType) {
 	case k0_failureNeedsMorePractice:
 		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, messages[0]);
-		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, g417_baseSkillName[skillIndex]);
-		if (_vm->getGameLanguage() != Common::FR_FRA || skillIndex == k3_ChampionSkillWizard) {
+		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, _vm->_championMan->_baseSkillName[skillIndex]);
+		if (_vm->getGameLanguage() != Common::FR_FRA || skillIndex == k3_ChampionSkillWizard)
 			L1264_pc_Message = messages[1];
-		} else {
+		else
 			L1264_pc_Message = messages[4];
-		}
+
 		break;
 	case k1_failureMeaninglessSpell:
 		L1264_pc_Message = messages[2];


Commit: 07438a94e1549ddfd291ba918b23e53bcc24878d
    https://github.com/scummvm/scummvm/commit/07438a94e1549ddfd291ba918b23e53bcc24878d
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Implement missing code in f125_drawSquareD0L

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 5f568a8..c60db12 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1951,13 +1951,20 @@ void DisplayMan::f125_drawSquareD0L(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
+	case k0_WallElemType:
+		f100_drawWallSetBitmap(_g701_bitmapWallSet_Wall_D0L, _frameWalls163[k10_ViewSquare_D0L]);
+		break;
+	case k1_CorridorElemType:
+	case k5_TeleporterElemType:
+	case k16_DoorSideElemType:
+		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k10_ViewSquare_D0L, k0x0002_CellOrder_BackRight);
+		break;
+	case k2_PitElemType:
+		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k61_floorPitInvisibleD0L_GraphicIndice : k55_FloorPit_D0L_GraphicIndice, frameFloorPitD0L);
 	case k18_StairsSideElemType:
 		if (squareAspect[k2_StairsUpAspect])
 			f104_drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, frameStairsSideD0L);
 		break;
-	case k0_WallElemType:
-		f100_drawWallSetBitmap(_g701_bitmapWallSet_Wall_D0L, _frameWalls163[k10_ViewSquare_D0L]);
-		break;
 	default:
 		break;
 	}


Commit: 30eea48e4a0dc763e77ed9435b1e447689afdd2c
    https://github.com/scummvm/scummvm/commit/30eea48e4a0dc763e77ed9435b1e447689afdd2c
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some more GCC warnings

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index c60db12..b3d296e 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2061,7 +2061,8 @@ void DisplayMan::f128_drawDungeon(Direction dir, int16 posX, int16 posY) {
 	for (uint16 i = 0; i < 6; ++i)
 		_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i]._x1 = 255;
 
-	if (_g76_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1) {
+	_g76_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1;
+	if (_g76_useFlippedWallAndFootprintsBitmap) {
 		f100_drawWallSetBitmap(_g85_bitmapCeiling, ceilingFrame);
 		f99_copyBitmapAndFlipHorizontal(_g84_bitmapFloor, _g74_tmpBitmap, k112_byteWidthViewport, 70);
 		f100_drawWallSetBitmap(_g74_tmpBitmap, floorFrame);
@@ -2077,10 +2078,10 @@ void DisplayMan::f128_drawDungeon(Direction dir, int16 posX, int16 posY) {
 		f100_drawWallSetBitmap(_g84_bitmapFloor, floorFrame);
 	}
 
-	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, -2, posX, posY) == k0_ElementTypeWall)
+	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, -2, posX, posY) == k0_WallElemType)
 		f100_drawWallSetBitmap(_g697_bitmapWallSet_Wall_D3L2, frameWallD3L2);
 
-	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, 2, posX, posY) == k0_ElementTypeWall)
+	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, 2, posX, posY) == k0_WallElemType)
 		f100_drawWallSetBitmap(_g696_bitmapWallSet_Wall_D3R2, _frameWallD3R2);
 
 	int16 tmpPosX = posX;
@@ -2421,26 +2422,26 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 void DisplayMan::f93_applyCreatureReplColors(int replacedColor, int replacementColor) {
 	CreatureReplColorSet creatureReplColorSets[13] = { // @ G0220_as_Graphic558_CreatureReplacementColorSets
 		/* { Color, Color, Color, Color, Color, Color, D2 replacement color index (x10), D3 replacement color index (x10) } */
-		{0x0CA0, 0x0A80, 0x0860, 0x0640, 0x0420, 0x0200,  90,  90},    /* Atari ST: { 0x0650, 0x0540, 0x0430, 0x0320, 0x0210, 0x0100,  90,  90 }, RGB colors are different */
-		{0x0060, 0x0040, 0x0020, 0x0000, 0x0000, 0x0000,   0,   0},    /* Atari ST: { 0x0030, 0x0020, 0x0010, 0x0000, 0x0000, 0x0000,   0,   0 }, */
-		{0x0860, 0x0640, 0x0420, 0x0200, 0x0000, 0x0000, 100, 100},    /* Atari ST: { 0x0430, 0x0320, 0x0210, 0x0100, 0x0000, 0x0000, 100, 100 }, */
-		{0x0640, 0x0420, 0x0200, 0x0000, 0x0000, 0x0000,  90,   0},    /* Atari ST: { 0x0320, 0x0210, 0x0100, 0x0000, 0x0000, 0x0000,  90,   0 }, */
-		{0x000A, 0x0008, 0x0006, 0x0004, 0x0002, 0x0000,  90, 100},    /* Atari ST: { 0x0005, 0x0004, 0x0003, 0x0002, 0x0001, 0x0000,  90, 100 }, */
-		{0x0008, 0x0006, 0x0004, 0x0002, 0x0000, 0x0000, 100,   0},    /* Atari ST: { 0x0004, 0x0003, 0x0002, 0x0001, 0x0000, 0x0000, 100,   0 }, */
-		{0x0808, 0x0606, 0x0404, 0x0202, 0x0000, 0x0000,  90,   0},    /* Atari ST: { 0x0404, 0x0303, 0x0202, 0x0101, 0x0000, 0x0000,  90,   0 }, */
-		{0x0A0A, 0x0808, 0x0606, 0x0404, 0x0202, 0x0000, 100,  90},    /* Atari ST: { 0x0505, 0x0404, 0x0303, 0x0202, 0x0101, 0x0000, 100,  90 }, */
-		{0x0FA0, 0x0C80, 0x0A60, 0x0840, 0x0620, 0x0400, 100,  50},    /* Atari ST: { 0x0750, 0x0640, 0x0530, 0x0420, 0x0310, 0x0200, 100,  50 }, */
-		{0x0F80, 0x0C60, 0x0A40, 0x0820, 0x0600, 0x0200,  50,  70},    /* Atari ST: { 0x0740, 0x0630, 0x0520, 0x0410, 0x0300, 0x0100,  50,  30 }, D3 replacement color index is different */
-		{0x0800, 0x0600, 0x0400, 0x0200, 0x0000, 0x0000, 100, 120},    /* Atari ST: { 0x0400, 0x0300, 0x0200, 0x0100, 0x0000, 0x0000, 100, 100 }, D3 replacement color index is different */
-		{0x0600, 0x0400, 0x0200, 0x0000, 0x0000, 0x0000, 120,   0},    /* Atari ST: { 0x0300, 0x0200, 0x0100, 0x0000, 0x0000, 0x0000, 120,   0 }, */
-		{0x0C86, 0x0A64, 0x0842, 0x0620, 0x0400, 0x0200, 100,  50}     /* Atari ST: { 0x0643, 0x0532, 0x0421, 0x0310, 0x0200, 0x0100, 100,  50 } }; */
+		CreatureReplColorSet(0x0CA0, 0x0A80, 0x0860, 0x0640, 0x0420, 0x0200,  90,  90),    /* Atari ST: { 0x0650, 0x0540, 0x0430, 0x0320, 0x0210, 0x0100,  90,  90 }, RGB colors are different */
+		CreatureReplColorSet(0x0060, 0x0040, 0x0020, 0x0000, 0x0000, 0x0000,   0,   0),    /* Atari ST: { 0x0030, 0x0020, 0x0010, 0x0000, 0x0000, 0x0000,   0,   0 }, */
+		CreatureReplColorSet(0x0860, 0x0640, 0x0420, 0x0200, 0x0000, 0x0000, 100, 100),    /* Atari ST: { 0x0430, 0x0320, 0x0210, 0x0100, 0x0000, 0x0000, 100, 100 }, */
+		CreatureReplColorSet(0x0640, 0x0420, 0x0200, 0x0000, 0x0000, 0x0000,  90,   0),    /* Atari ST: { 0x0320, 0x0210, 0x0100, 0x0000, 0x0000, 0x0000,  90,   0 }, */
+		CreatureReplColorSet(0x000A, 0x0008, 0x0006, 0x0004, 0x0002, 0x0000,  90, 100),    /* Atari ST: { 0x0005, 0x0004, 0x0003, 0x0002, 0x0001, 0x0000,  90, 100 }, */
+		CreatureReplColorSet(0x0008, 0x0006, 0x0004, 0x0002, 0x0000, 0x0000, 100,   0),    /* Atari ST: { 0x0004, 0x0003, 0x0002, 0x0001, 0x0000, 0x0000, 100,   0 }, */
+		CreatureReplColorSet(0x0808, 0x0606, 0x0404, 0x0202, 0x0000, 0x0000,  90,   0),    /* Atari ST: { 0x0404, 0x0303, 0x0202, 0x0101, 0x0000, 0x0000,  90,   0 }, */
+		CreatureReplColorSet(0x0A0A, 0x0808, 0x0606, 0x0404, 0x0202, 0x0000, 100,  90),    /* Atari ST: { 0x0505, 0x0404, 0x0303, 0x0202, 0x0101, 0x0000, 100,  90 }, */
+		CreatureReplColorSet(0x0FA0, 0x0C80, 0x0A60, 0x0840, 0x0620, 0x0400, 100,  50),    /* Atari ST: { 0x0750, 0x0640, 0x0530, 0x0420, 0x0310, 0x0200, 100,  50 }, */
+		CreatureReplColorSet(0x0F80, 0x0C60, 0x0A40, 0x0820, 0x0600, 0x0200,  50,  70),    /* Atari ST: { 0x0740, 0x0630, 0x0520, 0x0410, 0x0300, 0x0100,  50,  30 }, D3 replacement color index is different */
+		CreatureReplColorSet(0x0800, 0x0600, 0x0400, 0x0200, 0x0000, 0x0000, 100, 120),    /* Atari ST: { 0x0400, 0x0300, 0x0200, 0x0100, 0x0000, 0x0000, 100, 100 }, D3 replacement color index is different */
+		CreatureReplColorSet(0x0600, 0x0400, 0x0200, 0x0000, 0x0000, 0x0000, 120,   0),    /* Atari ST: { 0x0300, 0x0200, 0x0100, 0x0000, 0x0000, 0x0000, 120,   0 }, */
+		CreatureReplColorSet(0x0C86, 0x0A64, 0x0842, 0x0620, 0x0400, 0x0200, 100,  50)     /* Atari ST: { 0x0643, 0x0532, 0x0421, 0x0310, 0x0200, 0x0100, 100,  50 } }; */
 	};
 
 	for (int16 i = 0; i < 6; ++i)
 		_palDungeonView[i][replacedColor] = creatureReplColorSets[replacementColor]._RGBColor[i];
 
-	_palChangesCreatureD2[replacedColor] = creatureReplColorSets[replacementColor]._D2ReplacementColor;
-	_palChangesCreatureD3[replacedColor] = creatureReplColorSets[replacementColor]._D3ReplacementColor;
+	_palChangesCreatureD2[replacedColor] = creatureReplColorSets[replacementColor]._d2ReplacementColor;
+	_palChangesCreatureD3[replacedColor] = creatureReplColorSets[replacementColor]._d3ReplacementColor;
 }
 
 void DisplayMan::f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
@@ -3113,7 +3114,8 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 			if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) { /* Square where objects are visible and object is located on cell being processed */
 				objectAspect = &(_objectAspects209[_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thingParam)]._objectAspectIndex]);
 				AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex;
-				if (useAlcoveObjectImage = (L0135_B_DrawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane))
+				useAlcoveObjectImage = (L0135_B_DrawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane);
+				if (useAlcoveObjectImage)
 					AL_4_nativeBitmapIndex++;
 
 				coordinateSet = objectCoordinateSets[objectAspect->_coordinateSet][viewSquareIndex][AL_2_viewCell];
@@ -3186,7 +3188,8 @@ T0115015_DrawProjectileAsObject:
 					boxByteGreen._y2 = 135;
 
 				boxByteGreen._x2 = MIN(223, AL_4_xPos + byteWidth);
-				if (boxByteGreen._x1 = MAX(0, AL_4_xPos - byteWidth + 1)) {
+				boxByteGreen._x1 = MAX(0, AL_4_xPos - byteWidth + 1);
+				if (boxByteGreen._x1) {
 					if (flipHorizontal)
 						AL_4_xPos = paddingPixelCount;
 					else
@@ -3240,7 +3243,9 @@ T0115015_DrawProjectileAsObject:
 			creatureGraphicInfoGreen = creatureInfo->_graphicInfo;
 		}
 		objectAspect = (ObjectAspect*)creatureAspectStruct;
-		if (AL_0_creatureIndexRed = _vm->_groupMan->f176_getCreatureOrdinalInCell(group, cellYellowBear)) { /* If there is a creature on the cell being processed */
+		AL_0_creatureIndexRed = _vm->_groupMan->f176_getCreatureOrdinalInCell(group, cellYellowBear);
+
+		if (AL_0_creatureIndexRed) { /* If there is a creature on the cell being processed */
 			AL_0_creatureIndexRed--; /* Convert ordinal to index */
 			creatureIndexGreen = AL_0_creatureIndexRed;
 		} else if (creatureSize == k1_MaskCreatureSizeHalf) {
@@ -3301,7 +3306,8 @@ T0115077_DrawSecondHalfSquareCreature:
 		derivedBitmapIndex = ((CreatureAspect*)objectAspect)->_firstDerivedBitmapIndex;
 		int16 sourceByteWidth;
 		int16 sourceHeight;
-		if (useCreatureSideBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide) && (creatureDirectionDelta & 0x0001)) {
+		useCreatureSideBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide) && (creatureDirectionDelta & 0x0001);
+		if (useCreatureSideBitmap) {
 			useCreatureAttackBitmap = useFlippedHorizontallyCreatureFrontImage = useCreatureBackBitmap = false;
 			AL_4_nativeBitmapIndex++; /* Skip the front image. Side image is right after the front image */
 			derivedBitmapIndex += 2;
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 496abd4..13c0502 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -483,8 +483,19 @@ public:
 class CreatureReplColorSet {
 public:
 	uint16 _RGBColor[6];
-	byte _D2ReplacementColor;
-	byte _D3ReplacementColor;
+	byte _d2ReplacementColor;
+	byte _d3ReplacementColor;
+
+	CreatureReplColorSet(uint16 col1, uint16 col2, uint16 col3, uint16 col4, uint16 col5, uint16 col6, byte d2Rep, byte d3Rep) {
+		_RGBColor[0] = col1;
+		_RGBColor[1] = col2;
+		_RGBColor[2] = col3;
+		_RGBColor[3] = col4;
+		_RGBColor[4] = col5;
+		_RGBColor[5] = col6;
+		_d2ReplacementColor = d2Rep;
+		_d3ReplacementColor = d3Rep;
+	}
 }; // @ CREATURE_REPLACEMENT_COLOR_SET
 
 


Commit: 4613e8ffad84e76d06024448f9215439d5cea5e7
    https://github.com/scummvm/scummvm/commit/4613e8ffad84e76d06024448f9215439d5cea5e7
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some more GCC warnings

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index b3d296e..7760f20 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -3315,7 +3315,8 @@ T0115077_DrawSecondHalfSquareCreature:
 			sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightSide;
 		} else {
 			useCreatureBackBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack) && (creatureDirectionDelta == 0);
-			if (useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, k0x0080_MaskActiveGroupIsAttacking) && getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack)) {
+			useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, k0x0080_MaskActiveGroupIsAttacking) && getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack);
+			if (useCreatureAttackBitmap) {
 				useFlippedHorizontallyCreatureFrontImage = false;
 				sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthAttack;
 				sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightAttack;
@@ -3342,16 +3343,19 @@ T0115077_DrawSecondHalfSquareCreature:
 						AL_4_nativeBitmapIndex++; /* If the creature does not have a side image, the back image follows the front image */
 						derivedBitmapIndex += 2;
 					}
-				} else if (useFlippedHorizontallyCreatureFrontImage = getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack) && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
-					derivedBitmapIndex += 2;
-					if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide))
+				} else {
+					useFlippedHorizontallyCreatureFrontImage = getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack) && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap);
+					if (useFlippedHorizontallyCreatureFrontImage) {
 						derivedBitmapIndex += 2;
+						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide))
+							derivedBitmapIndex += 2;
 
-					if (getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack))
-						derivedBitmapIndex += 2;
+						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack))
+							derivedBitmapIndex += 2;
 
-					if (getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack))
-						derivedBitmapIndex += 2;
+						if (getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack))
+							derivedBitmapIndex += 2;
+					}
 				}
 			}
 		}
@@ -3440,10 +3444,13 @@ T0115077_DrawSecondHalfSquareCreature:
 		else if (viewLane) /* Lane right */
 			AL_4_xPos += 100;
 
-		if (!(boxByteGreen._x2 = f26_getBoundedValue(0, AL_4_xPos + byteWidth, 223)))
+		boxByteGreen._x2 = f26_getBoundedValue(0, AL_4_xPos + byteWidth, 223);
+
+		if (!boxByteGreen._x2)
 			goto T0115126_CreatureNotVisible;
 		int16 AL_0_creaturePosX;
-		if (boxByteGreen._x1 = f26_getBoundedValue(0, AL_4_xPos - byteWidth + 1, 223)) {
+		boxByteGreen._x1 = f26_getBoundedValue(0, AL_4_xPos - byteWidth + 1, 223);
+		if (boxByteGreen._x1) {
 			if (boxByteGreen._x1 == 223)
 				goto T0115126_CreatureNotVisible;
 			AL_0_creaturePosX = creaturePaddingPixelCount;
@@ -3464,7 +3471,15 @@ T0115126_CreatureNotVisible:
 		}
 		/* Draw projectiles */
 T0115129_DrawProjectiles:
-		if (!squareHasProjectile || ((viewSquareIndex = AL_10_viewSquareIndexBackup) > k9_ViewSquare_D0C) || (!(projectilePosX = objectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0]))) /* If there is no projectile to draw or if projectiles are not visible on the specified square or on the cell being drawn */
+		//If there is no projectile to draw or if projectiles are not visible on the specified square or on the cell being drawn
+		if (!squareHasProjectile)
+			continue;
+		viewSquareIndex = AL_10_viewSquareIndexBackup;
+		if (viewSquareIndex > k9_ViewSquare_D0C)
+			continue;
+		AL_2_viewCell = currentViewCellToDraw;
+		projectilePosX = objectCoordinateSets[0][viewSquareIndex][AL_2_viewCell][0];
+		if (!projectilePosX) /* If there is no projectile to draw or if projectiles are not visible on the specified square or on the cell being drawn */
 			continue;
 
 		thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */
@@ -3560,7 +3575,8 @@ T0115129_DrawProjectiles:
 					boxByteGreen._y2 = (heightRedEagle >> 1) + 47;
 					boxByteGreen._y1 = 47 - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001);
 					boxByteGreen._x2 = MIN(223, projectilePosX + byteWidth);
-					if (boxByteGreen._x1 = MAX(0, projectilePosX - byteWidth + 1)) {
+					boxByteGreen._x1 = MAX(0, projectilePosX - byteWidth + 1);
+					if (boxByteGreen._x1) {
 						if (flipHorizontal)
 							AL_4_xPos = paddingPixelCount;
 						else
@@ -3636,15 +3652,15 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 				}
 			}
 			if (AL_1_viewSquareExplosionIndex == k12_ViewSquare_D0C_Explosion) {
-				if (smoke) {
+				if (smoke)
 					AL_4_explosionAspectIndex--; /* Smoke uses the same graphics as Poison Cloud, but with palette changes */
-				}
+
 				AL_4_explosionAspectIndex = AL_4_explosionAspectIndex * 3; /* 3 graphics per explosion pattern */
-				if (AL_2_explosionSize = (explosion->getAttack() >> 5)) {
+				AL_2_explosionSize = (explosion->getAttack() >> 5);
+				if (AL_2_explosionSize) {
 					AL_4_explosionAspectIndex++; /* Use second graphic in the pattern for medium explosion attack */
-					if (AL_2_explosionSize > 3) {
+					if (AL_2_explosionSize > 3)
 						AL_4_explosionAspectIndex++; /* Use third graphic in the pattern for large explosion attack */
-					}
 				}
 				f491_isDerivedBitmapInCache(k0_DerivedBitmapViewport);
 				bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice);
@@ -3665,11 +3681,11 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					if (explosion->getCentered()) {
 						explosionCoordinates = centeredExplosionCoordinates[AL_1_viewSquareExplosionIndex];
 					} else {
-						if ((AL_2_cellPurpleMan == directionParam) || (AL_2_cellPurpleMan == returnPrevVal(directionParam))) {
+						if ((AL_2_cellPurpleMan == directionParam) || (AL_2_cellPurpleMan == returnPrevVal(directionParam)))
 							AL_2_viewCell = k0_ViewCellFronLeft;
-						} else {
+						else
 							AL_2_viewCell = k1_ViewCellFrontRight;
-						}
+
 						explosionCoordinates = explosionCoordinatesArray[AL_1_viewSquareExplosionIndex][AL_2_viewCell];
 					}
 					explosionScale = MAX(4, (MAX(48, explosion->getAttack() + 1) * explosionBaseScales[AL_10_explosionScaleIndex]) >> 8) & (int)0xFFFE;
@@ -3678,19 +3694,23 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 T0115200_DrawExplosion:
 				bool flipVertical = _vm->getRandomNumber(2);
 				paddingPixelCount = 0;
-				if (flipHorizontal = _vm->getRandomNumber(2)) {
+				flipHorizontal = _vm->getRandomNumber(2);
+				if (flipHorizontal)
 					paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1; /* Number of unused pixels in the units on the right of the bitmap */
-				}
+
 				boxByteGreen._y2 = MIN(135, explosionCoordinates[1] + (heightRedEagle >> 1));
 				AL_4_yPos = MAX(0, explosionCoordinates[1] - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001));
 				if (AL_4_yPos >= 136)
 					continue;
 				boxByteGreen._y1 = AL_4_yPos;
-				if ((AL_4_xPos = MIN(223, explosionCoordinates[0] + byteWidth)) < 0)
+				AL_4_xPos = MIN(223, explosionCoordinates[0] + byteWidth);
+				if (AL_4_xPos < 0)
 					continue;
 				boxByteGreen._x2 = AL_4_xPos;
 				AL_4_xPos = explosionCoordinates[0];
-				if (boxByteGreen._x1 = f26_getBoundedValue(0, AL_4_xPos - byteWidth + 1, 223))
+				boxByteGreen._x1 = f26_getBoundedValue(0, AL_4_xPos - byteWidth + 1, 223);
+
+				if (boxByteGreen._x1)
 					AL_4_xPos = paddingPixelCount;
 				else {
 					AL_4_xPos = MAX(paddingPixelCount, int16(byteWidth - AL_4_xPos - 1)); /* BUG0_07 Graphical glitch when drawing explosions. If an explosion bitmap is cropped because it is only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is not flipped horizontally (flipHorizontal = false) then the variable paddingPixelCount is not set before being used here. Its previous value (defined while drawing something else) is used and may cause an incorrect bitmap to be drawn */
@@ -3716,7 +3736,8 @@ T0115200_DrawExplosion:
 				f132_blitToBitmap(bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
 			}
 		}
-	} while ((thingParam = _vm->_dungeonMan->f159_getNextThing(thingParam)) != Thing::_endOfList);
+		thingParam = _vm->_dungeonMan->f159_getNextThing(thingParam);
+	} while (thingParam != Thing::_endOfList);
 
 	if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_g77_doNotDrawFluxcagesDuringEndgame) { /* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */
 		AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */


Commit: 236a27e4cc902ab50fa850535f36993056ba0fbc
    https://github.com/scummvm/scummvm/commit/236a27e4cc902ab50fa850535f36993056ba0fbc
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix more GCC warnings

Changed paths:
    engines/dm/group.cpp



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 5bd4539..22915a9 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -437,9 +437,10 @@ int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group *group, uint16 creature
 					_g392_dropMovingCreatureFixedPossessionsCell[_g391_dropMovingCreatureFixedPossCellCount++] = L0384_ui_Cell;
 				}
 			}
-			if (L0383_B_CurrentMapIsPartyMap = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) {
+			L0383_B_CurrentMapIsPartyMap = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex);
+			if (L0383_B_CurrentMapIsPartyMap)
 				L0378_ps_ActiveGroup = &_g375_activeGroups[group->getActiveGroupIndex()];
-			}
+
 			if (group->getBehaviour() == k6_behavior_ATTACK) {
 				L0377_ps_Event = _vm->_timeline->_g370_events;
 				for (AL0374_ui_EventIndex = 0; AL0374_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; AL0374_ui_EventIndex++) {
@@ -666,7 +667,8 @@ T0209005_AddEventAndReturn:
 		goto T0209139_Return;
 	}
 	/* If the creature is Lord Chaos then ignore the event if the game is won. Initialize data to analyze Fluxcages */
-	if (L0463_B_Archenemy = getFlag(L0448_s_CreatureInfo._attributes, k0x2000_MaskCreatureInfo_archenemy)) {
+	L0463_B_Archenemy = getFlag(L0448_s_CreatureInfo._attributes, k0x2000_MaskCreatureInfo_archenemy);
+	if (L0463_B_Archenemy) {
 		if (_vm->_g302_gameWon) {
 			goto T0209139_Return;
 		}
@@ -674,12 +676,15 @@ T0209005_AddEventAndReturn:
 		_g385_fluxCages[0] = 0;
 	}
 	L0445_ps_ActiveGroup = &_g375_activeGroups[L0444_ps_Group->getActiveGroupIndex()];
-	if ((L0462_i_TicksSinceLastMove = (unsigned char)_vm->_g313_gameTime - L0445_ps_ActiveGroup->_lastMoveTime) < 0) {
+
+	L0462_i_TicksSinceLastMove = (unsigned char)_vm->_g313_gameTime - L0445_ps_ActiveGroup->_lastMoveTime;
+	if (L0462_i_TicksSinceLastMove < 0)
 		L0462_i_TicksSinceLastMove += 256;
-	}
-	if ((L0461_i_MovementTicks = L0448_s_CreatureInfo._movementTicks) == k255_immobile) {
+
+	L0461_i_MovementTicks = L0448_s_CreatureInfo._movementTicks;
+	if (L0461_i_MovementTicks == k255_immobile)
 		L0461_i_MovementTicks = 100;
-	}
+
 	if (_vm->_championMan->_g407_party._freezeLifeTicks && !L0463_B_Archenemy) { /* If life is frozen and the creature is not Lord Chaos (Lord Chaos is immune to Freeze Life) then reschedule the event later (except for reactions which are ignored when life if frozen) */
 		if (eventType < 0)
 			goto T0209139_Return;
@@ -762,12 +767,13 @@ T0209005_AddEventAndReturn:
 		}
 	} else { /* Process Update Behavior events 37 to 41 */
 		L0455_B_CurrentEventTypeIsNotUpdateBehavior = false;
-		if (ticks) {
+		if (ticks)
 			L0464_l_NextAspectUpdateTime = _vm->_g313_gameTime;
-		}
+
 		if (eventType == k37_TMEventTypeUpdateBehaviourGroup) { /* Process event 37, Update Group Behavior */
 			if ((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k2_behavior_USELESS) || (AL0447_i_Behavior == k3_behavior_USELESS)) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */
-				if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+				L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY);
+				if (L0452_i_DistanceToVisibleParty) {
 					if ((L0452_i_DistanceToVisibleParty <= (L0448_s_CreatureInfo.M56_getAttackRange())) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) { /* If the creature is in range for attack and on the same row or column as the party on the map */
 T0209044_SetBehavior6_Attack:
 						if (eventType == kM2_TMEventTypeCreateReactionEvent30HitByProjectile) {
@@ -803,7 +809,8 @@ T0209054_SetBehavior7_Approach:
 					}
 				} else {
 					if (AL0447_i_Behavior == k0_behavior_WANDER) {
-						if (L0454_i_PrimaryDirectionToOrFromParty = f201_getSmelledPartyPrimaryDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY)) {
+						L0454_i_PrimaryDirectionToOrFromParty = f201_getSmelledPartyPrimaryDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY);
+						if (L0454_i_PrimaryDirectionToOrFromParty) {
 							L0454_i_PrimaryDirectionToOrFromParty--;
 							L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = false;
 							goto T0209085_SingleSquareMove;
@@ -823,7 +830,9 @@ T0209058_MoveInRandomDirection:
 									 (L0457_B_MoveToPriorLocation = !_vm->getRandomNumber(4))) /* 1/4 chance of moving back to the square that the creature comes from */
 									&& f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction, false)) {
 T0209061_MoveGroup:
-									if (L0453_B_NewGroupDirectionFound = ((AL0447_i_Ticks = (L0461_i_MovementTicks >> 1) - L0462_i_TicksSinceLastMove) <= 0)) {
+									AL0447_i_Ticks = (L0461_i_MovementTicks >> 1) - L0462_i_TicksSinceLastMove;
+									L0453_B_NewGroupDirectionFound = (AL0447_i_Ticks <= 0);
+									if (L0453_B_NewGroupDirectionFound) {
 										if (_vm->_moveSens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
 											goto T0209139_Return;
 										L0465_s_NextEvent._B._location._mapX = _vm->_moveSens->_g397_moveResultMapX;
@@ -866,16 +875,17 @@ T0209073_SetDirectionGroup:
 						if (eventType < kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) {
 							if (!L0453_B_NewGroupDirectionFound)
 								goto T0209139_Return;
-							if (L0458_B_SetBehavior7_ApproachAfterReaction) {
+							if (L0458_B_SetBehavior7_ApproachAfterReaction)
 								L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
-							}
+
 							f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
 						}
 					}
 				}
 			} else {
 				if (AL0447_i_Behavior == k7_behavior_APPROACH) {
-					if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+					L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY);
+					if (L0452_i_DistanceToVisibleParty) {
 						if ((L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.M56_getAttackRange()) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) /* If the creature is in range for attack and on the same row or column as the party on the map */
 							goto T0209044_SetBehavior6_Attack;
 T0209081_RunTowardParty:
@@ -927,7 +937,8 @@ T0209089_DoubleSquareMove:
 T0209094_FleeFromTarget:
 						L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true;
 						/* If the creature can see the party then update target coordinates */
-						if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+						L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY);
+						if (L0452_i_DistanceToVisibleParty) {
 							AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX);
 							AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY);
 						} else {
@@ -970,16 +981,16 @@ T0209096_SetBehavior0_Wander:
 			if (getFlag(L0445_ps_ActiveGroup->_aspect[AL0447_i_CreatureIndex = eventType - k38_TMEventTypeUpdateBehaviour_0], k0x0080_MaskActiveGroupIsAttacking)) {
 				L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false);
 				L0465_s_NextEvent._mapTime += ((AL0447_i_Ticks = L0448_s_CreatureInfo._attackTicks) + _vm->getRandomNumber(4) - 1);
-				if (AL0447_i_Ticks > 15) {
+				if (AL0447_i_Ticks > 15)
 					L0465_s_NextEvent._mapTime += _vm->getRandomNumber(8) - 2;
-				}
 			} else { /* If the creature is not attacking, then try attacking if possible */
-				if (AL0447_i_CreatureIndex > L0460_ui_CreatureCount) { /* Ignore event if it is for a creature that is not in the group */
+				if (AL0447_i_CreatureIndex > L0460_ui_CreatureCount) /* Ignore event if it is for a creature that is not in the group */
 					goto T0209139_Return;
-				}
+
 				L0454_i_PrimaryDirectionToOrFromParty = _g382_currGroupPrimaryDirToParty;
+				L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, AL0447_i_CreatureIndex, eventMapX, eventMapY);
 				/* If the party is visible, update the target coordinates */
-				if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, AL0447_i_CreatureIndex, eventMapX, eventMapY)) {
+				if (L0452_i_DistanceToVisibleParty) {
 					L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
 					L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
 				}
@@ -1091,7 +1102,6 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 	Teleporter *L0432_ps_Teleporter;
 	Thing L0433_T_Thing;
 
-
 	_g384_groupMovementTestedDirections[dir] = true;
 	_g388_groupMovementBlockedByGroupThing = Thing::_endOfList;
 	_g389_groupMovementBlockedByDoor = false;
@@ -1102,15 +1112,19 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement((Direction)dir, 1, 0, mapX, mapY);
 	L0428_i_MapX = mapX;
 	L0429_i_MapY = mapY;
-	if (_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter =
+	L0430_ui_Square = _vm->_dungeonMan->_g271_currMapData[L0428_i_MapX][L0429_i_MapY];
+	L0431_i_SquareType = Square(L0430_ui_Square).getType();
+	_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter =
 		!(((L0428_i_MapX >= 0) && (L0428_i_MapX < _vm->_dungeonMan->_g273_currMapWidth)) &&
-		((L0429_i_MapY >= 0) && (L0429_i_MapY < _vm->_dungeonMan->_g274_currMapHeight)) &&
-		  ((L0431_i_SquareType = Square(L0430_ui_Square = _vm->_dungeonMan->_g271_currMapData[L0428_i_MapX][L0429_i_MapY]).getType()) != k0_ElementTypeWall) &&
+		 ((L0429_i_MapY >= 0) && (L0429_i_MapY < _vm->_dungeonMan->_g274_currMapHeight)) &&
+		  (L0431_i_SquareType != k0_ElementTypeWall) &&
 		  (L0431_i_SquareType != k3_ElementTypeStairs) &&
-		  ((L0431_i_SquareType != k2_ElementTypePit) || (getFlag(L0430_ui_Square, k0x0001_PitImaginary) && allowMovementOverImaginaryPitsAndFakeWalls) || !getFlag(L0430_ui_Square, k0x0008_PitOpen) || getFlag(creatureInfo->_attributes, k0x0020_MaskCreatureInfo_levitation)) &&
-		  ((L0431_i_SquareType != k6_ElementTypeFakeWall) || getFlag(L0430_ui_Square, k0x0004_FakeWallOpen) || (getFlag(L0430_ui_Square, k0x0001_FakeWallImaginary) && allowMovementOverImaginaryPitsAndFakeWalls)))) {
+		 ((L0431_i_SquareType != k2_ElementTypePit) || (getFlag(L0430_ui_Square, k0x0001_PitImaginary) && allowMovementOverImaginaryPitsAndFakeWalls) || !getFlag(L0430_ui_Square, k0x0008_PitOpen) || getFlag(creatureInfo->_attributes, k0x0020_MaskCreatureInfo_levitation)) &&
+		 ((L0431_i_SquareType != k6_ElementTypeFakeWall) || getFlag(L0430_ui_Square, k0x0004_FakeWallOpen) || (getFlag(L0430_ui_Square, k0x0001_FakeWallImaginary) && allowMovementOverImaginaryPitsAndFakeWalls)));
+
+	if (_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter)
 		return false;
-	}
+
 	if (getFlag(creatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) {
 		L0433_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0428_i_MapX, L0429_i_MapY);
 		while (L0433_T_Thing != Thing::_endOfList) {
@@ -1133,9 +1147,11 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 			return false;
 		}
 	}
-	if (_g390_groupMovementBlockedByParty = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0428_i_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0429_i_MapY == _vm->_dungeonMan->_g307_partyMapY)) {
+
+	_g390_groupMovementBlockedByParty = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0428_i_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0429_i_MapY == _vm->_dungeonMan->_g307_partyMapY);
+	if (_g390_groupMovementBlockedByParty)
 		return false;
-	}
+
 	if (L0431_i_SquareType == k4_DoorElemType) {
 		L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
 		if (((Square(L0430_ui_Square).getDoorState()) > (((Door *)L0432_ps_Teleporter)->opensVertically() ? CreatureInfo::M51_height(creatureInfo->_attributes) : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
@@ -1273,24 +1289,28 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 
 	L0329_ps_Group = &(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]);
 	L0327_ui_CreatureGraphicInfo = g243_CreatureInfo[L0331_ui_CreatureType = L0329_ps_Group->_type]._graphicInfo;
-	if (L0330_B_ProcessGroup = (creatureIndex < 0)) { /* If the creature index is negative then all creatures in the group are processed */
+	L0330_B_ProcessGroup = (creatureIndex < 0);
+	if (L0330_B_ProcessGroup) /* If the creature index is negative then all creatures in the group are processed */
 		creatureIndex = L0329_ps_Group->getCount();
-	}
+
 	do {
 		AL0326_ui_Aspect = activeGroup->_aspect[creatureIndex];
 		AL0326_ui_Aspect &= k0x0080_MaskActiveGroupIsAttacking | k0x0040_MaskActiveGroupFlipBitmap;
-		if (L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 12) & 0x3)) {
+		L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 12) & 0x3);
+		if (L0328_i_Offset) {
 			L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset);
-			if (_vm->getRandomNumber(2)) {
+			if (_vm->getRandomNumber(2))
 				L0328_i_Offset = (-L0328_i_Offset) & 0x0007;
-			}
+
 			AL0326_ui_Aspect |= L0328_i_Offset;
 		}
-		if (L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 14) & 0x3)) {
+
+		L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 14) & 0x3);
+		if (L0328_i_Offset) {
 			L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset);
-			if (_vm->getRandomNumber(2)) {
+			if (_vm->getRandomNumber(2))
 				L0328_i_Offset = (-L0328_i_Offset) & 0x0007;
-			}
+
 			AL0326_ui_Aspect |= (L0328_i_Offset << 3);
 		}
 		if (isAttacking) {
@@ -1300,18 +1320,15 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
 						_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized);
 					}
-				} else {
-					if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) {
-						if (_vm->getRandomNumber(2)) {
-							setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-						} else {
-							clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-						}
-					}
+				} else if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) {
+					if (_vm->getRandomNumber(2))
+						setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+					else
+						clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
 				}
-			} else {
+			} else
 				clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-			}
+
 			setFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking);
 		} else {
 			if (getFlag(L0327_ui_CreatureGraphicInfo, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) {
@@ -1319,20 +1336,16 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 					if (_vm->getRandomNumber(2)) {
 						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
 						L1635_ui_SoundIndex = _vm->_moveSens->f514_getSound(k13_CreatureTypeCouatl);
-						if (L1635_ui_SoundIndex <= k34_D13_soundCount) {
+						if (L1635_ui_SoundIndex <= k34_D13_soundCount)
 							_vm->_sound->f064_SOUND_RequestPlay_CPSD(L1635_ui_SoundIndex, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized);
-						}
-					}
-				} else {
-					if (_vm->getRandomNumber(2)) {
-						setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-					} else {
-						clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
 					}
-				}
-			} else {
+				} else if (_vm->getRandomNumber(2))
+					setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+				else
+					clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+			} else
 				clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-			}
+
 			clearFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking);
 		}
 		activeGroup->_aspect[creatureIndex] = AL0326_ui_Aspect;
@@ -1348,8 +1361,10 @@ void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 crea
 	if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == _g395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) {
 		return;
 	}
-	if (M21_normalizeModulo4(M50_getCreatureValue(L0435_ui_GroupDirections = activeGroup->_directions, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */
-		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + dir));
+	L0435_ui_GroupDirections = activeGroup->_directions;
+	if (M21_normalizeModulo4(M50_getCreatureValue(L0435_ui_GroupDirections, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */
+		dir = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + dir);
+		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir);
 	} else {
 		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir);
 	}
@@ -1412,16 +1427,14 @@ int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo *info, int1
 }
 
 void GroupMan::f206_groupSetDirGroup(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, int16 creatureSize) {
-	bool L0436_B_TwoHalfSquareSizedCreatures;
-
+	bool L0436_B_TwoHalfSquareSizedCreatures = creatureIndex && (creatureSize == k1_MaskCreatureSizeHalf);
 
-	if (L0436_B_TwoHalfSquareSizedCreatures = creatureIndex && (creatureSize == k1_MaskCreatureSizeHalf)) {
+	if (L0436_B_TwoHalfSquareSizedCreatures)
 		creatureIndex--;
-	}
+
 	do {
-		if (!creatureIndex || _vm->getRandomNumber(2)) {
+		if (!creatureIndex || _vm->getRandomNumber(2))
 			f205_setDirection(activeGroup, dir, creatureIndex, L0436_B_TwoHalfSquareSizedCreatures);
-		}
 	} while (creatureIndex--);
 }
 
@@ -1539,9 +1552,10 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 			}
 		}
 	}
-	if (AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal) {
+	AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal;
+	if (AL0440_i_AttackSoundOrdinal)
 		_vm->_sound->f064_SOUND_RequestPlay_CPSD(G0244_auc_Graphic559_CreatureAttackSounds[--AL0440_i_AttackSoundOrdinal], mapX, mapY, k1_soundModePlayIfPrioritized);
-	}
+
 	return true;
 }
 
@@ -1659,13 +1673,18 @@ int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) {
 		AL0558_i_Attack += _vm->getRandomNumber(AL0558_i_Attack);
 		AL0558_i_Attack >>= 2;
 		AL0558_i_Attack += _vm->getRandomNumber(4) + 1;
-		if (_vm->getRandomNumber(2)) {
+		if (_vm->getRandomNumber(2))
 			AL0558_i_Attack -= _vm->getRandomNumber((AL0558_i_Attack >> 1) + 1) - 1;
-		}
-		if (AL0558_i_Damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType)) {
+
+		AL0558_i_Damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType);
+		if (AL0558_i_Damage) {
 			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k09_soundCHAMPION_0_DAMAGED + champIndex, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater);
-			if ((AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack) && _vm->getRandomNumber(2) && ((AL0559_ui_PoisonAttack = _vm->_championMan->f307_getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack)) >= 0)) {
-				_vm->_championMan->f322_championPoison(champIndex, AL0559_ui_PoisonAttack);
+
+			AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack;
+			if (AL0559_ui_PoisonAttack && _vm->getRandomNumber(2)) {
+				AL0559_ui_PoisonAttack = _vm->_championMan->f307_getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack);
+				if (AL0559_ui_PoisonAttack >= 0)
+					_vm->_championMan->f322_championPoison(champIndex, AL0559_ui_PoisonAttack);
 			}
 			return AL0558_i_Damage;
 		}
@@ -1811,11 +1830,12 @@ Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplie
 	L0353_ps_Group->setDoNotDiscard(false);
 	L0353_ps_Group->setDir(dir);
 	L0353_ps_Group->setCount(creatureCount);
-	if (L0355_B_SeveralCreaturesInGroup = creatureCount) {
+	L0355_B_SeveralCreaturesInGroup = creatureCount;
+	if (L0355_B_SeveralCreaturesInGroup)
 		L0351_ui_Cell = _vm->getRandomNumber(4);
-	} else {
+	else
 		L0352_ui_GroupCells = k255_CreatureTypeSingleCenteredCreature;
-	}
+
 	L0354_ps_CreatureInfo = &g243_CreatureInfo[L0353_ps_Group->_type = creatureType];
 	L0350_ui_BaseHealth = L0354_ps_CreatureInfo->_baseHealth;
 	do {
@@ -1850,17 +1870,18 @@ int16 GroupMan::f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, i
 	Group* L0324_ps_Group;
 	signed char L0325_auc_OrderedCellsToAttack[4];
 
-
-	if ((L0323_T_GroupThing = f175_groupGetThing(groupX, groupY)) == Thing::_endOfList) {
+	L0323_T_GroupThing = f175_groupGetThing(groupX, groupY);
+	if (L0323_T_GroupThing == Thing::_endOfList)
 		return 0;
-	}
+
 	L0324_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0323_T_GroupThing);
 	f229_setOrderedCellsToAttack(L0325_auc_OrderedCellsToAttack, groupX, groupY, partyX, partyY, champCell);
 	L0321_ui_Counter = 0;
 	for (;;) { /*_Infinite loop_*/
-		if (L0322_i_CreatureOrdinal = f176_getCreatureOrdinalInCell(L0324_ps_Group, L0325_auc_OrderedCellsToAttack[L0321_ui_Counter])) {
+		L0322_i_CreatureOrdinal = f176_getCreatureOrdinalInCell(L0324_ps_Group, L0325_auc_OrderedCellsToAttack[L0321_ui_Counter]);
+		if (L0322_i_CreatureOrdinal)
 			return L0322_i_CreatureOrdinal;
-		}
+
 		L0321_ui_Counter++;
 	}
 }
@@ -1884,31 +1905,35 @@ int16 GroupMan::f231_getMeleeActionDamage(Champion* champ, int16 champIndex, Gro
 	L0567_i_DoubledMapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty << 1;
 	L0572_ps_CreatureInfo = &g243_CreatureInfo[group->_type];
 	L0571_i_ActionHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
-	if (L0570_B_ActionHitsNonMaterialCreatures = getFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures)) {
+	L0570_B_ActionHitsNonMaterialCreatures = getFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
+	if (L0570_B_ActionHitsNonMaterialCreatures)
 		clearFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
-	}
+
 	if ((!getFlag(L0572_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) || L0570_B_ActionHitsNonMaterialCreatures) &&
 		((_vm->_championMan->f311_getDexterity(champ) > (_vm->getRandomNumber(32) + L0572_ps_CreatureInfo->_dexterity + L0567_i_DoubledMapDifficulty - 16)) ||
 		(!_vm->getRandomNumber(4)) ||
 		 (_vm->_championMan->f308_isLucky(champ, 75 - actionHitProbability)))) {
-		if (!(L0565_i_Damage = _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand))) {
+
+		L0565_i_Damage = _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand);
+		if (!(L0565_i_Damage))
 			goto T0231009;
-		}
+
 		L0565_i_Damage += _vm->getRandomNumber((L0565_i_Damage >> 1) + 1);
 		L0565_i_Damage = ((long)L0565_i_Damage * (long)actionDamageFactor) >> 5;
 		L0568_i_Defense = _vm->getRandomNumber(32) + L0572_ps_CreatureInfo->_defense + L0567_i_DoubledMapDifficulty;
-		if (L0571_i_ActionHandObjectIconIndex == k39_IconIndiceWeaponDiamondEdge) {
+		if (L0571_i_ActionHandObjectIconIndex == k39_IconIndiceWeaponDiamondEdge)
 			L0568_i_Defense -= L0568_i_Defense >> 2;
-		} else {
-			if (L0571_i_ActionHandObjectIconIndex == k43_IconIndiceWeaponHardcleaveExecutioner) {
-				L0568_i_Defense -= L0568_i_Defense >> 3;
-			}
-		}
-		if ((L0566_i_Damage = L0565_i_Damage = _vm->getRandomNumber(32) + L0565_i_Damage - L0568_i_Defense) <= 1) {
+		else if (L0571_i_ActionHandObjectIconIndex == k43_IconIndiceWeaponHardcleaveExecutioner)
+			L0568_i_Defense -= L0568_i_Defense >> 3;
+
+		L0565_i_Damage += _vm->getRandomNumber(32) - L0568_i_Defense;
+		L0566_i_Damage = L0565_i_Damage;
+		if (L0566_i_Damage <= 1) {
 T0231009:
-			if (!(L0565_i_Damage = _vm->getRandomNumber(4))) {
+			L0565_i_Damage = _vm->getRandomNumber(4);
+			if (!L0565_i_Damage)
 				goto T0231015;
-			}
+
 			L0565_i_Damage++;
 			if (((L0566_i_Damage += _vm->getRandomNumber(16)) > 0) || (_vm->getRandomNumber(2))) {
 				L0565_i_Damage += _vm->getRandomNumber(4);
@@ -1952,12 +1977,14 @@ void GroupMan::f224_fluxCageAction(int16 mapX, int16 mapY) {
 	TimelineEvent L0547_s_Event;
 
 
-	if (((AL0546_i_SquareType = _vm->_dungeonMan->f151_getSquare(mapX, mapY).getType()) == k0_ElementTypeWall) || (AL0546_i_SquareType == k3_ElementTypeStairs)) {
+	AL0546_i_SquareType = _vm->_dungeonMan->f151_getSquare(mapX, mapY).getType();
+	if ((AL0546_i_SquareType == k0_ElementTypeWall) || (AL0546_i_SquareType == k3_ElementTypeStairs))
 		return;
-	}
-	if ((L0545_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k15_ExplosionThingType)) == Thing::_none) {
+
+	L0545_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k15_ExplosionThingType);
+	if (L0545_T_Thing == Thing::_none)
 		return;
-	}
+
 	_vm->_dungeonMan->f163_linkThingToList(L0545_T_Thing, Thing(0), mapX, mapY);
 	(((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[L0545_T_Thing.getIndex()]).setType(k50_ExplosionType_Fluxcage);
 	M33_setMapAndTime(L0547_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + 100);
@@ -2002,13 +2029,14 @@ uint16 GroupMan::f222_isLordChaosOnSquare(int16 mapX, int16 mapY) {
 	Thing L0542_T_Thing;
 	Group* L0543_ps_Group;
 
-	if ((L0542_T_Thing = f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) {
+	L0542_T_Thing = f175_groupGetThing(mapX, mapY);
+	if (L0542_T_Thing == Thing::_endOfList)
 		return 0;
-	}
+
 	L0543_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0542_T_Thing);
-	if (L0543_ps_Group->_type == k23_CreatureTypeLordChaos) {
+	if (L0543_ps_Group->_type == k23_CreatureTypeLordChaos)
 		return L0542_T_Thing.toUint16();
-	}
+
 	return 0;
 }
 
@@ -2016,9 +2044,10 @@ bool GroupMan::f221_isFluxcageOnSquare(int16 mapX, int16 mapY) {
 	Thing L0540_T_Thing;
 	int16 L0541_i_SquareType;
 
-	if (((L0541_i_SquareType = _vm->_dungeonMan->f151_getSquare(mapX, mapY).getType()) == k0_ElementTypeWall) || (L0541_i_SquareType == k3_ElementTypeStairs)) {
+	L0541_i_SquareType = _vm->_dungeonMan->f151_getSquare(mapX, mapY).getType();
+	if ((L0541_i_SquareType == k0_ElementTypeWall) || (L0541_i_SquareType == k3_ElementTypeStairs))
 		return false;
-	}
+
 	L0540_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
 	while (L0540_T_Thing != Thing::_endOfList) {
 		if ((L0540_T_Thing.getType() == k15_ExplosionThingType) && (((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[L0540_T_Thing.getIndex()].getType() == k50_ExplosionType_Fluxcage)) {
@@ -2043,7 +2072,8 @@ void GroupMan::f225_fuseAction(uint16 mapX, uint16 mapY) {
 	}
 
 	_vm->_projexpl->f213_explosionCreate(Thing::_explHarmNonMaterial, 255, mapX, mapY, k255_CreatureTypeSingleCenteredCreature); /* BUG0_17 The game crashes after the Fuse action is performed while looking at a wall on a map boundary. An explosion thing is created on the square in front of the party but there is no check to ensure the square coordinates are in the map bounds. This corrupts a memory location and leads to a game crash */
-	if ((L0555_T_LordChaosThing = Thing(f222_isLordChaosOnSquare(mapX, mapY))).toUint16()) {
+	L0555_T_LordChaosThing = Thing(f222_isLordChaosOnSquare(mapX, mapY));
+	if (L0555_T_LordChaosThing.toUint16()) {
 		L0551_ui_FluxcageCount = (L0554_aB_Fluxcages[0] = f221_isFluxcageOnSquare(mapX - 1, mapY)) +
 			(L0554_aB_Fluxcages[1] = f221_isFluxcageOnSquare(mapX + 1, mapY)) +
 			(L0554_aB_Fluxcages[2] = f221_isFluxcageOnSquare(mapX, mapY - 1)) +


Commit: f9323fe9fae6a45c0a4359775ba0383924a75c47
    https://github.com/scummvm/scummvm/commit/f9323fe9fae6a45c0a4359775ba0383924a75c47
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Get rid of some globals in inventory

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 51f89f4..0a33c74 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -2354,7 +2354,7 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 	displayBox._x2 = displayBox._x1 + 167;
 
 	_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, displayBox, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
-	_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), g32_BoxPanel, k72_byteWidth, k4_ColorCyan, 73);
+	_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), _vm->_inventoryMan->g32_BoxPanel, k72_byteWidth, k4_ColorCyan, 73);
 	_vm->_textMan->f52_printToViewport(177, 58, k13_ColorLightestGray, "_______");
 	_vm->_textMan->f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________");
 	_vm->_eventMan->f78_showMouse();
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index ac85b9d..075112b 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -681,7 +681,7 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 						continue;
 
 					char displStr[20];
-					strcpy(displStr, G0428_apc_SkillLevelNames[skillLevel - 2]);
+					strcpy(displStr, _inventoryMan->G0428_apc_SkillLevelNames[skillLevel - 2]);
 					strcat(displStr, " ");
 					strcat(displStr, _championMan->_baseSkillName[idx]);
 					_textMan->f443_endgamePrintString(105, textPosY = textPosY + 8, k13_ColorLightestGray, displStr);
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 3800b95..ed1a014 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -42,32 +42,30 @@
 
 namespace DM {
 
-Box g41_BoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
-Box g32_BoxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel
-Box g35_BoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food
-Box g36_BoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
-Box g37_BoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
-
-const char* G0428_apc_SkillLevelNames[15];
-
 void InventoryMan::initConstants() {
-	{
-		static const char* G0428_apc_SkillLevelNames_EN_ANY[15] = {"NEOPHYTE", "NOVICE", "APPRENTICE", "JOURNEYMAN", "CRAFTSMAN",
-			"ARTISAN", "ADEPT", "EXPERT", "` MASTER", "a MASTER","b MASTER", "c MASTER", "d MASTER", "e MASTER", "ARCHMASTER"};
-		static const char* G0428_apc_SkillLevelNames_DE_DEU[15] = {"ANFAENGER", "NEULING", "LEHRLING", "ARBEITER", "GESELLE", "HANDWERKR", "FACHMANN",
-			"EXPERTE", "` MEISTER", "a MEISTER", "b MEISTER", "c MEISTER", "d MEISTER", "e MEISTER", "ERZMEISTR"};
-		static const char* G0428_apc_SkillLevelNames_FR_FRA[15] = {"NEOPHYTE", "NOVICE", "APPRENTI", "COMPAGNON", "ARTISAN", "PATRON",
-			"ADEPTE", "EXPERT", "MAITRE '", "MAITRE a", "MAITRE b", "MAITRE c", "MAITRE d", "MAITRE e", "SUR-MAITRE"};
-		const char **g428_byLanguage;
-		switch (_vm->getGameLanguage()) { // localized
-		default:
-		case Common::EN_ANY: g428_byLanguage = G0428_apc_SkillLevelNames_EN_ANY; break;
-		case Common::DE_DEU: g428_byLanguage = G0428_apc_SkillLevelNames_DE_DEU; break;
-		case Common::FR_FRA: g428_byLanguage = G0428_apc_SkillLevelNames_FR_FRA; break;
-		}
-		for (int i = 0; i < 15; ++i)
-			G0428_apc_SkillLevelNames[i] = g428_byLanguage[i];
+	static const char* G0428_apc_SkillLevelNames_EN_ANY[15] = {"NEOPHYTE", "NOVICE", "APPRENTICE", "JOURNEYMAN", "CRAFTSMAN",
+		"ARTISAN", "ADEPT", "EXPERT", "` MASTER", "a MASTER","b MASTER", "c MASTER", "d MASTER", "e MASTER", "ARCHMASTER"};
+	static const char* G0428_apc_SkillLevelNames_DE_DEU[15] = {"ANFAENGER", "NEULING", "LEHRLING", "ARBEITER", "GESELLE", "HANDWERKR", "FACHMANN",
+		"EXPERTE", "` MEISTER", "a MEISTER", "b MEISTER", "c MEISTER", "d MEISTER", "e MEISTER", "ERZMEISTR"};
+	static const char* G0428_apc_SkillLevelNames_FR_FRA[15] = {"NEOPHYTE", "NOVICE", "APPRENTI", "COMPAGNON", "ARTISAN", "PATRON",
+		"ADEPTE", "EXPERT", "MAITRE '", "MAITRE a", "MAITRE b", "MAITRE c", "MAITRE d", "MAITRE e", "SUR-MAITRE"};
+	const char **g428_byLanguage;
+	switch (_vm->getGameLanguage()) { // localized
+	default:
+	case Common::EN_ANY:
+		g428_byLanguage = G0428_apc_SkillLevelNames_EN_ANY;
+		break;
+	case Common::DE_DEU:
+		g428_byLanguage = G0428_apc_SkillLevelNames_DE_DEU;
+		break;
+	case Common::FR_FRA:
+		g428_byLanguage = G0428_apc_SkillLevelNames_FR_FRA;
+		break;
 	}
+	for (int i = 0; i < 15; ++i)
+		G0428_apc_SkillLevelNames[i] = g428_byLanguage[i];
+
+	g32_BoxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel
 }
 
 InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
@@ -79,10 +77,15 @@ InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
 	_g421_objDescTextXpos = 0;
 	_g422_objDescTextYpos = 0;
 
+	for (int i = 0; i < 15; i++)
+		G0428_apc_SkillLevelNames[i] = nullptr;
+
 	initConstants();
 }
 
 void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
+	static Box g41_BoxFloppyZzzCross(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
+
 	if (championIndex == kM1_ChampionNone) {
 		delete _vm->_saveThumbnail;
 		_vm->_saveThumbnail = nullptr;
@@ -210,6 +213,10 @@ void InventoryMan::f344_drawPanelFoodOrWaterBar(int16 amount, int16 y, Color col
 }
 
 void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
+	static Box g35_BoxFood(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food
+	static Box g36_BoxWater(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
+	static Box g37_BoxPoisoned(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
+
 	Champion &champ = _vm->_championMan->_gK71_champions[_g432_inventoryChampionOrdinal];
 	f334_closeChest();
 	DisplayMan &dispMan = *_vm->_displayMan;
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index d16f22d..856f7d0 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -37,9 +37,6 @@ namespace DM {
 #define k69_ChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING
 #define k38_SlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT
 
-
-extern Box g32_BoxPanel; // @ G0032_s_Graphic562_Box_Panel
-
 enum PanelContent {
 	k0_PanelContentFoodWaterPoisoned = 0, // @ C00_PANEL_FOOD_WATER_POISONED
 	k2_PanelContentScroll = 2, // @ C02_PANEL_SCROLL
@@ -47,8 +44,6 @@ enum PanelContent {
 	k5_PanelContentResurrectReincarnate = 5 // @ C05_PANEL_RESURRECT_REINCARNATE
 };
 
-extern const char* G0428_apc_SkillLevelNames[15]; // @ G0428_apc_SkillLevelNames  
-
 class InventoryMan {
 	DMEngine *_vm;
 
@@ -63,6 +58,8 @@ public:
 	Thing _g426_openChest; // @ G0426_T_OpenChest
 	int16 _g421_objDescTextXpos; // @ G0421_i_ObjectDescriptionTextX
 	int16 _g422_objDescTextYpos; // @ G0422_i_ObjectDescriptionTextY
+	Box g32_BoxPanel;
+	const char* G0428_apc_SkillLevelNames[15];
 
 	void f355_toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE
 	void f354_drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait


Commit: 2ee50eda35d65a79bc66003edbc28d3bc7600e1f
    https://github.com/scummvm/scummvm/commit/2ee50eda35d65a79bc66003edbc28d3bc7600e1f
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add proper save header

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/loadsave.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index f303008..4bd2d8a 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -14,10 +14,8 @@ Todo:
 	I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions
 
 Code stuff todo:
-	Complete stub methods(blitShrink, blitmask, scroller, etc.)
-	Save file f433_processCommand140_saveGame fails silently, add error checking
-	
-	Add loading from dungeon
+	Complete stub methods(blitShrink, blitmask, scroller)
+	Add proper save header, add error handling to it
 	Fix incorrect thumbnail	
 	Add translations to f433_processCommand140_saveGame 'LOAD'
 	
\ No newline at end of file
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 075112b..236fb76 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -166,8 +166,7 @@ DMEngine::DMEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst),
 	_sound = nullptr;
 
 	_engineShouldQuit = false;
-	_g528_saveFormat = 0;
-	_g527_platform = 0;
+	_g528_saveFormat = k_FORMAT_NONE;
 	_g526_dungeonId = 0;
 
 	_g298_newGame = 0;
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 20b7bf8..98e8cb8 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -36,6 +36,7 @@
 
 #include "console.h"
 #include <common/memstream.h>
+#include <advancedDetector.h>
 
 
 struct ADGameDescription;
@@ -57,6 +58,13 @@ class ProjExpl;
 class DialogMan;
 class SoundMan;
 
+enum SaveFormat {
+	k_FORMAT_NONE = 0,
+	k_FORMAT_DM_ATARI_ST = 1,
+	k_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST = 2,
+	k_FORMAT_DM_APPLE_IIGS = 3,
+	k_FORMAT_DM_AMIGA_36_PC_CSB_AMIGA_PC98_X68000_FM_TOWNS = 5,
+};
 
 void warning(bool repeat, const char *s, ...);
 
@@ -233,8 +241,7 @@ public:
 	Common::Language getGameLanguage();
 
 private:
-	int16 _g528_saveFormat; // @ G0528_i_Format
-	int16 _g527_platform; // @ G0527_i_Platform
+	SaveFormat _g528_saveFormat; // @ G0528_i_Format
 	uint16 _g526_dungeonId; // @ G0526_ui_DungeonID
 	byte *_g562_entranceDoorAnimSteps[10]; // @ G0562_apuc_Bitmap_EntranceDoorAnimationSteps
 	byte *_g564_interfaceCredits; // @ G0564_puc_Graphic5_InterfaceCredits
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 7857d49..09b4d70 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -42,9 +42,6 @@
 
 
 namespace DM {
-#define C2_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST 2
-#define C3_PLATFORM_AMIGA 3
-#define C10_DUNGEON_DM 10
 
 LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 	if (slot == -1 && _g298_newGame == k0_modeLoadSavedGame)
@@ -56,10 +53,9 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 	Common::InSaveFile *file = nullptr;
 
 	struct {
-		int16 _saveFormat;
-		int16 _saveAndPlayChoice;
+		SaveFormat _saveFormat;
+		int32 _saveVersion;
 		int32 _gameId;
-		int16 _platform;
 		uint16 _dungeonId;
 	} dmSaveHeader;
 
@@ -69,9 +65,8 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		file = saveFileManager->openForLoading(fileName);
 	}
 
-	_g528_saveFormat = C2_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST;
-	_g527_platform = C3_PLATFORM_AMIGA;
-	_g526_dungeonId = C10_DUNGEON_DM;
+	dmSaveHeader._saveFormat = k_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST;
+
 	if (_g298_newGame) {
 		//L1366_B_FadePalette = !F0428_DIALOG_RequireGameDiskInDrive_NoDialogDrawn(C0_DO_NOT_FORCE_DIALOG_DM_CSB, true);
 		_g524_restartGameAllowed = false;
@@ -84,10 +79,9 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 
 		warning(false, "MISSING CODE: missing check for matching format and platform in save in f435_loadgame");
 
-		dmSaveHeader._saveFormat = file->readSint16BE();
-		dmSaveHeader._saveAndPlayChoice = file->readSint16BE();
+		dmSaveHeader._saveFormat = (SaveFormat)file->readSint32BE();
+		dmSaveHeader._saveVersion = file->readSint32BE();
 		dmSaveHeader._gameId = file->readSint32BE();
-		dmSaveHeader._platform = file->readSint16BE();
 		dmSaveHeader._dungeonId = file->readUint16BE();
 
 		_g525_gameId = dmSaveHeader._gameId;
@@ -142,7 +136,6 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		}
 	} else {
 		_g528_saveFormat = dmSaveHeader._saveFormat;
-		_g527_platform = dmSaveHeader._platform;
 		_g526_dungeonId = dmSaveHeader._dungeonId;
 
 		_g524_restartGameAllowed = true;
@@ -302,10 +295,9 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 
 	writeSaveGameHeader(file, saveDescription);
 
-	file->writeSint16BE(_g528_saveFormat);
-	file->writeSint16BE(saveAndPlayChoice);
+	file->writeSint32BE(_g528_saveFormat);
+	file->writeSint32BE(1); // save version
 	file->writeSint32BE(_g525_gameId);
-	file->writeSint16BE(_g527_platform);
 	file->writeUint16BE(_g526_dungeonId);
 
 	// write C0_SAVE_PART_GLOBAL_DATA part


Commit: 1a0fe29af818c5771eb3846826dd87697f6f57c5
    https://github.com/scummvm/scummvm/commit/1a0fe29af818c5771eb3846826dd87697f6f57c5
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix drawing title

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 236fb76..bfb6147 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -875,7 +875,8 @@ void DMEngine::f437_STARTEND_drawTittle() {
 
 	_displayMan->f436_STARTEND_FadeToPalette(L1392_aui_Palette);
 	_displayMan->fillScreen(k0_ColorBlack);
-	_displayMan->f132_blitToBitmap(L1384_puc_Bitmap_Title, _displayMan->_g348_bitmapScreen, G0005_s_Graphic562_Box_Title_Presents, 0, 137, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, k200_heightScreen, k200_heightScreen);
+	// uncomment this to draw 'Presents'
+	//_displayMan->f132_blitToBitmap(L1384_puc_Bitmap_Title, _displayMan->_g348_bitmapScreen, G0005_s_Graphic562_Box_Title_Presents, 0, 137, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, k200_heightScreen, k200_heightScreen);
 	L1392_aui_Palette[15] = D09_RGB_WHITE;
 	_displayMan->f436_STARTEND_FadeToPalette(L1392_aui_Palette);
 	_displayMan->f132_blitToBitmap(L1384_puc_Bitmap_Title, L1389_puc_Bitmap_Master_StrikesBack = L1383_l_Bitmap_TitleSteps, G0004_s_Graphic562_Box_Title_StrikesBack_Source, 0, 80, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 57);
@@ -890,7 +891,7 @@ void DMEngine::f437_STARTEND_drawTittle() {
 		_displayMan->f129_blitToBitmapShrinkWithPalChange(L1384_puc_Bitmap_Title, L1383_l_Bitmap_TitleSteps, 320, 80, L1382_i_DestinationPixelWidth, L1381_ui_DestinationHeight, _displayMan->_palChangesNoChanges);
 		L1391_aai_Coordinates[L1380_i_Counter][1] = (L1391_aai_Coordinates[L1380_i_Counter][0] = (320 - L1382_i_DestinationPixelWidth) / 2) + L1382_i_DestinationPixelWidth - 1;
 		L1391_aai_Coordinates[L1380_i_Counter][3] = (L1391_aai_Coordinates[L1380_i_Counter][2] = ((int)(160 - L1381_ui_DestinationHeight)) / 2) + L1381_ui_DestinationHeight - 1;
-		L1383_l_Bitmap_TitleSteps += (L1391_aai_Coordinates[L1380_i_Counter][4] = ((L1382_i_DestinationPixelWidth + 15) / 16) * 8) * L1381_ui_DestinationHeight;
+		L1383_l_Bitmap_TitleSteps += (L1391_aai_Coordinates[L1380_i_Counter][4] = ((L1382_i_DestinationPixelWidth + 15) / 16) * 8) * L1381_ui_DestinationHeight * 2;
 		L1381_ui_DestinationHeight += 4;
 		L1382_i_DestinationPixelWidth += 16;
 	}


Commit: 22a79ac9652a42b0ff08791ebd69b047db170cb5
    https://github.com/scummvm/scummvm/commit/22a79ac9652a42b0ff08791ebd69b047db170cb5
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix drawing of some dungeon items

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 7760f20..5c4bb7e 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2750,15 +2750,13 @@ void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *des
 	warning(false, "MISSING CODE: No palette change takes place in f129_blitToBitmapShrinkWithPalChange");
 
 
-	if (destPixelWidth % 8)
-		destPixelWidth = (destPixelWidth / 8) * 8 + 8;
+	destPixelWidth = (destPixelWidth + 1) & 0xFFFE;
 
 	uint32 scaleX = (kScaleThreshold * srcPixelWidth) / destPixelWidth;
 	uint32 scaleY = (kScaleThreshold * srcHeight) / destHeight;
 
 	// Loop through drawing output lines
 	for (uint32 destY = 0, scaleYCtr = 0; destY < (uint32)destHeight; ++destY, scaleYCtr += scaleY) {
-
 		const byte *srcLine = &srcBitmap[(scaleYCtr / kScaleThreshold) * srcPixelWidth];
 		byte *destLine = &destBitmap[destY * destPixelWidth];
 


Commit: 2199f879bdcd27806e304782423e2b3e838d6bbc
    https://github.com/scummvm/scummvm/commit/2199f879bdcd27806e304782423e2b3e838d6bbc
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix incorrect thumbnails

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/eventman.cpp
    engines/dm/inventory.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 4bd2d8a..4d4fef1 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -16,6 +16,5 @@ Todo:
 Code stuff todo:
 	Complete stub methods(blitShrink, blitmask, scroller)
 	Add proper save header, add error handling to it
-	Fix incorrect thumbnail	
 	Add translations to f433_processCommand140_saveGame 'LOAD'
 	
\ No newline at end of file
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index a3677b0..8ad7971 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -40,6 +40,7 @@
 #include "group.h"
 #include "dialog.h"
 #include "sounds.h"
+#include <mortevielle/saveload.h>
 
 
 namespace DM {
@@ -769,6 +770,14 @@ void EventManager::f380_processCommandQueue() {
 	}
 
 	if ((cmdType >= k7_CommandToggleInventoryChampion_0) && (cmdType <= k11_CommandCloseInventory)) {
+		if (cmdType == k11_CommandCloseInventory) {
+			delete _vm->_saveThumbnail;
+			_vm->_saveThumbnail = nullptr;
+		} else if (!_vm->_saveThumbnail) {
+			_vm->_saveThumbnail = new Common::MemoryWriteStreamDynamic();
+			Graphics::saveThumbnail(*_vm->_saveThumbnail);
+		}
+
 		int16 championIndex = cmdType - k7_CommandToggleInventoryChampion_0;
 		if (((championIndex == k4_ChampionCloseInventory) || (championIndex < _vm->_championMan->_g305_partyChampionCount)) && !_vm->_championMan->_g299_candidateChampionOrdinal)
 			_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)championIndex);
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index ed1a014..5e2ccaa 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -86,13 +86,6 @@ InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
 void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	static Box g41_BoxFloppyZzzCross(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
 
-	if (championIndex == kM1_ChampionNone) {
-		delete _vm->_saveThumbnail;
-		_vm->_saveThumbnail = nullptr;
-	} else if (!_vm->_saveThumbnail) {
-		_vm->_saveThumbnail = new Common::MemoryWriteStreamDynamic();
-		Graphics::saveThumbnail(*_vm->_saveThumbnail);
-	}
 
 	uint16 L1102_ui_Multiple;
 #define AL1102_ui_InventoryChampionOrdinal L1102_ui_Multiple


Commit: 2bdabc3b7afe9ba857bfc2be7ac638a566d09bf4
    https://github.com/scummvm/scummvm/commit/2bdabc3b7afe9ba857bfc2be7ac638a566d09bf4
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Add target and original platform to save files

Changed paths:
    engines/dm/detection.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/loadsave.cpp
    engines/dm/sounds.cpp
    engines/dm/sounds.h



diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp
index 7f506ac..ebdae4e 100644
--- a/engines/dm/detection.cpp
+++ b/engines/dm/detection.cpp
@@ -40,7 +40,7 @@ static const PlainGameDescriptor DMGames[] = {
 	{0, 0}
 };
 
-static const ADGameDescription gameDescriptions[] = {
+static const DMADGameDescription gameDescriptions[] = {
 	{
 		"dm", "Amiga 2.0v English",
 		{
@@ -48,7 +48,11 @@ static const ADGameDescription gameDescriptions[] = {
 			{"Dungeon.dat", 0, "43a213da8eda413541dd12f90ce202f6", 25006},
 		AD_LISTEND
 		},
-		Common::EN_ANY, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE)
+		Common::EN_ANY, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE),
+	    k_saveTarget_DM21, k_saveFormat_dm_amiga__2_x_pc98_x68000_fm_towns_csb_atari_st, k_savePlatform_amiga,
+		{ k_saveTarget_DM21, k_saveTarget_endOfList },
+		{ k_saveFormat_dm_amiga__2_x_pc98_x68000_fm_towns_csb_atari_st, k_saveFormat_endOfList},
+		{ k_savePlatform_accept_any}
 	},
 	{
 		"dm", "Atari ???v English",
@@ -57,22 +61,16 @@ static const ADGameDescription gameDescriptions[] = {
 			{"Dungeon.dat", 0, "be9468b460515741babec9a70501e2e9", 33286},
 			AD_LISTEND
 		},
-	Common::EN_ANY, Common::kPlatformAtariST, ADGF_NO_FLAGS, GUIO1(GUIO_NONE)
+	    Common::EN_ANY, Common::kPlatformAtariST, ADGF_NO_FLAGS, GUIO1(GUIO_NONE),
+	    k_saveTarget_DM21, k_saveFormat_dm_amiga__2_x_pc98_x68000_fm_towns_csb_atari_st, k_savePlatform_atari_st,
+	    { k_saveTarget_DM21, k_saveTarget_endOfList},
+	    { k_saveFormat_dm_amiga__2_x_pc98_x68000_fm_towns_csb_atari_st, k_saveFormat_endOfList},
+	    { k_savePlatform_accept_any }
 	},
 
 	AD_TABLE_END_MARKER
 };
 
-static ADGameDescription fallbackDesc = {
-	"dm",
-	"Unknown version",
-	AD_ENTRY1(0, 0), // This should always be AD_ENTRY1(0, 0) in the fallback descriptor
-	Common::UNK_LANG,
-	Common::kPlatformDOS,
-	ADGF_NO_FLAGS,
-	GUIO1(GUIO_NONE)
-};
-
 
 static const ADExtraGuiOptionsMap optionsList[] = {
 	AD_EXTRA_GUI_OPTIONS_TERMINATOR
@@ -81,7 +79,7 @@ static const ADExtraGuiOptionsMap optionsList[] = {
 
 class DMMetaEngine : public AdvancedMetaEngine {
 public:
-	DMMetaEngine() : AdvancedMetaEngine(DM::gameDescriptions, sizeof(ADGameDescription), DMGames, optionsList) {
+	DMMetaEngine() : AdvancedMetaEngine(DM::gameDescriptions, sizeof(DMADGameDescription), DMGames, optionsList) {
 		_singleId = "dm";
 	}
 
@@ -93,11 +91,9 @@ public:
 		return "Dummy";
 	}
 
-	virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { return gameDescriptions; }
-
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
 		if (desc)
-			*engine = new DM::DMEngine(syst, desc);
+			*engine = new DM::DMEngine(syst, (DMADGameDescription*)desc);
 		return desc != nullptr;
 	}
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index bfb6147..ceb3ae5 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -146,7 +146,7 @@ int16 M38_distance(int16 mapx1, int16 mapy1, int16 mapx2, int16 mapy2) {
 	return ABS(mapx1 - mapx2) + ABS(mapy1 - mapy2);
 }
 
-DMEngine::DMEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst), _console(nullptr), _gameVersion(desc) {
+DMEngine::DMEngine(OSystem *syst, const DMADGameDescription *desc) : Engine(syst), _console(nullptr), _gameVersion(desc) {
 	// register random source
 	_rnd = new Common::RandomSource("dm");
 
@@ -166,7 +166,6 @@ DMEngine::DMEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst),
 	_sound = nullptr;
 
 	_engineShouldQuit = false;
-	_g528_saveFormat = k_FORMAT_NONE;
 	_g526_dungeonId = 0;
 
 	_g298_newGame = 0;
@@ -520,7 +519,7 @@ void DMEngine::f2_gameloop() {
 			}
 
 			_system->delayMillis(2);
-			if (++vblankCounter >= _g318_waitForInputMaxVerticalBlankCount * 5)
+			if (++vblankCounter >= _g318_waitForInputMaxVerticalBlankCount * 4)
 				_g321_stopWaitingForPlayerInput = true;
 
 		} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking);
@@ -1082,5 +1081,5 @@ void DMEngine::f445_STARTEND_fuseSequenceUpdate() {
 					  The ending animation when Lord Chaos is fused plays too quickly because the execution speed is not limited */
 }
 
-Common::Language DMEngine::getGameLanguage() { return _gameVersion->language; }
+Common::Language DMEngine::getGameLanguage() { return _gameVersion->_desc.language; }
 } // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 98e8cb8..e115c8f 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -58,12 +58,47 @@ class ProjExpl;
 class DialogMan;
 class SoundMan;
 
-enum SaveFormat {
-	k_FORMAT_NONE = 0,
-	k_FORMAT_DM_ATARI_ST = 1,
-	k_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST = 2,
-	k_FORMAT_DM_APPLE_IIGS = 3,
-	k_FORMAT_DM_AMIGA_36_PC_CSB_AMIGA_PC98_X68000_FM_TOWNS = 5,
+enum OriginalSaveFormat {
+	k_saveFormat_accept_any = -1,
+	k_saveFormat_endOfList = 0,
+	k_saveFormat_dm_atari_st = 1,
+	k_saveFormat_dm_amiga__2_x_pc98_x68000_fm_towns_csb_atari_st = 2,
+	k_saveFormat_dm_apple_iigs = 3,
+	k_saveFormat_dm_amiga_36_pc_csb_amiga_pc98_x68000_fm_towns = 5,
+	k_saveFormat_total
+};
+
+enum OriginalSavePlatform {
+	k_savePlatform_accept_any = -1,
+	k_savePlatform_endOfList = 0,
+	k_savePlatform_atari_st = 1, // @ C1_PLATFORM_ATARI_ST   
+	k_savePlatform_apple_iigs = 2, // @ C2_PLATFORM_APPLE_IIGS 
+	k_savePlatform_amiga = 3, // @ C3_PLATFORM_AMIGA      
+	k_savePlatform_pc98 = 5, // @ C5_PLATFORM_PC98       
+	k_savePlatform_x68000 = 6, // @ C6_PLATFORM_X68000     
+	k_savePlatform_fm_towns_en = 7, // @ C7_PLATFORM_FM_TOWNS_EN
+	k_savePlatform_fm_towns_jp = 8, // @ C8_PLATFORM_FM_TOWNS_JP
+	k_savePlatform_pc = 9, // @ C9_PLATFORM_PC
+	k_savePlatform_total
+};
+
+enum SaveTarget {
+	k_saveTarget_accept_any = -1,
+	k_saveTarget_endOfList = 0,
+	k_saveTarget_DM21 = 1,
+	k_saveTarget_total
+};
+
+struct DMADGameDescription {
+	ADGameDescription _desc;
+
+	SaveTarget _saveTargetToWrite;
+	OriginalSaveFormat _origSaveFormatToWrite;
+	OriginalSavePlatform _origPlatformToWrite;
+
+	SaveTarget _saveTargetToAccept[k_saveTarget_total + 1];
+	OriginalSaveFormat _saveFormatToAccept[k_saveFormat_total + 1];
+	OriginalSavePlatform _origPlatformToAccept[k_savePlatform_total + 1];
 };
 
 void warning(bool repeat, const char *s, ...);
@@ -212,7 +247,7 @@ class DMEngine : public Engine {
 	bool writeCompleteSaveFile(int16 slot, Common::String &desc, int16 saveAndPlayChoice);
 	void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance
 public:
-	explicit DMEngine(OSystem *syst, const ADGameDescription *gameDesc);
+	explicit DMEngine(OSystem *syst, const DMADGameDescription *gameDesc);
 	~DMEngine();
 	virtual bool hasFeature(EngineFeature f) const;
 
@@ -241,14 +276,13 @@ public:
 	Common::Language getGameLanguage();
 
 private:
-	SaveFormat _g528_saveFormat; // @ G0528_i_Format
 	uint16 _g526_dungeonId; // @ G0526_ui_DungeonID
 	byte *_g562_entranceDoorAnimSteps[10]; // @ G0562_apuc_Bitmap_EntranceDoorAnimationSteps
 	byte *_g564_interfaceCredits; // @ G0564_puc_Graphic5_InterfaceCredits
 	Common::RandomSource *_rnd;
 	
 	byte *_savedScreenForOpenEntranceDoors; // ad-hoc HACK
-	const ADGameDescription *_gameVersion;
+	const DMADGameDescription *_gameVersion;
 	bool _canLoadFromGMM;
 public:
 	Console *_console;
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 09b4d70..4d486cf 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -53,8 +53,11 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 	Common::InSaveFile *file = nullptr;
 
 	struct {
-		SaveFormat _saveFormat;
+		SaveTarget _saveTarget;
 		int32 _saveVersion;
+		OriginalSaveFormat _saveFormat;
+		OriginalSavePlatform _savePlatform;
+
 		int32 _gameId;
 		uint16 _dungeonId;
 	} dmSaveHeader;
@@ -65,8 +68,6 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		file = saveFileManager->openForLoading(fileName);
 	}
 
-	dmSaveHeader._saveFormat = k_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST;
-
 	if (_g298_newGame) {
 		//L1366_B_FadePalette = !F0428_DIALOG_RequireGameDiskInDrive_NoDialogDrawn(C0_DO_NOT_FORCE_DIALOG_DM_CSB, true);
 		_g524_restartGameAllowed = false;
@@ -79,8 +80,11 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 
 		warning(false, "MISSING CODE: missing check for matching format and platform in save in f435_loadgame");
 
-		dmSaveHeader._saveFormat = (SaveFormat)file->readSint32BE();
+
+		dmSaveHeader._saveTarget = (SaveTarget)file->readSint32BE();
 		dmSaveHeader._saveVersion = file->readSint32BE();
+		dmSaveHeader._saveFormat = (OriginalSaveFormat)file->readSint32BE();
+		dmSaveHeader._savePlatform = (OriginalSavePlatform)file->readSint32BE();
 		dmSaveHeader._gameId = file->readSint32BE();
 		dmSaveHeader._dungeonId = file->readUint16BE();
 
@@ -135,7 +139,6 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 			_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);
 		}
 	} else {
-		_g528_saveFormat = dmSaveHeader._saveFormat;
 		_g526_dungeonId = dmSaveHeader._dungeonId;
 
 		_g524_restartGameAllowed = true;
@@ -295,8 +298,10 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 
 	writeSaveGameHeader(file, saveDescription);
 
-	file->writeSint32BE(_g528_saveFormat);
+	file->writeSint32BE(_gameVersion->_saveTargetToWrite);
 	file->writeSint32BE(1); // save version
+	file->writeSint32BE(_gameVersion->_origSaveFormatToWrite);
+	file->writeSint32BE(_gameVersion->_origPlatformToWrite);
 	file->writeSint32BE(_g525_gameId);
 	file->writeUint16BE(_g526_dungeonId);
 
diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp
index ad9bc09..c041715 100644
--- a/engines/dm/sounds.cpp
+++ b/engines/dm/sounds.cpp
@@ -39,8 +39,8 @@
 
 namespace DM {
 
-SoundMan* SoundMan::getSoundMan(DMEngine* vm, const ADGameDescription* gameVersion) {
-	switch (gameVersion->platform) {
+SoundMan* SoundMan::getSoundMan(DMEngine* vm, const DMADGameDescription* gameVersion) {
+	switch (gameVersion->_desc.platform) {
 	default: warning(false, "Unknown platform, using default Amiga SoundMan");
 	case Common::kPlatformAmiga: return new SoundMan(vm);
 	case Common::kPlatformAtariST: return new SoundMan_Atari(vm);
diff --git a/engines/dm/sounds.h b/engines/dm/sounds.h
index 8dfb3af..adbc019 100644
--- a/engines/dm/sounds.h
+++ b/engines/dm/sounds.h
@@ -68,7 +68,7 @@ protected:
 public:
 	virtual ~SoundMan();
 
-	static SoundMan *getSoundMan(DMEngine *vm, const ADGameDescription *gameVersion);
+	static SoundMan *getSoundMan(DMEngine *vm, const DMADGameDescription *gameVersion);
 
 	SoundData _gK24_soundData[k34_D13_soundCount]; // @ K0024_as_SoundData
 	Common::Queue<PendingSound> _pendingSounds;


Commit: fecb869af99927326b6cb6689c0e8e6d499a5977
    https://github.com/scummvm/scummvm/commit/fecb869af99927326b6cb6689c0e8e6d499a5977
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some more GCC warnings, move some globals to MenuMan

Changed paths:
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/menus.h



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 22915a9..c9f7e30 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -256,9 +256,9 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX
 		return;
 	}
 
-	uint16 currFixedPossession;
+	uint16 currFixedPossession = *fixedPossessions++;
 	bool weaponDropped = false;
-	while (currFixedPossession = *fixedPossessions++) {
+	while (currFixedPossession) {
 		if (getFlag(currFixedPossession, k0x8000_randomDrop) && _vm->getRandomNumber(2))
 			continue;
 
@@ -285,6 +285,7 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX
 		currWeapon->setCursed(cursedPossessions);
 		nextUnusedThing = M15_thingWithNewCell(nextUnusedThing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell);
 		_vm->_moveSens->f267_getMoveResult(nextUnusedThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
+		currFixedPossession = *fixedPossessions++;
 	}
 	_vm->_sound->f064_SOUND_RequestPlay_CPSD(weaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
 }
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 5e2ccaa..5463a21 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -440,7 +440,7 @@ void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, in
 	strcat(destString, suffixString);
 }
 
-void InventoryMan::f335_drawPanelObjectDescriptionString(char* descString) {
+void InventoryMan::f335_drawPanelObjectDescriptionString(char *descString) {
 	if (descString[0] == '\f') { // form feed
 		descString++;
 		_g421_objDescTextXpos = 108;
@@ -476,23 +476,22 @@ void InventoryMan::f335_drawPanelObjectDescriptionString(char* descString) {
 	}
 }
 
-Box g33_BoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye 
-
 void InventoryMan::f339_drawPanelArrowOrEye(bool pressingEye) {
+	static Box boxArrowOrEye(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye 
+
 	DisplayMan &dispMan = *_vm->_displayMan;
 	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice),
-							   g33_BoxArrowOrEye, k8_byteWidth, k8_ColorRed, 9);
+							   boxArrowOrEye, k8_byteWidth, k8_ColorRed, 9);
 }
 
-
-Box g34_BoxObjectDescCircle = Box(105, 136, 53, 79); // @ G0034_s_Graphic562_Box_ObjectDescriptionCircle 
-
 #define k0x0001_DescriptionMaskConsumable 0x0001 // @ MASK0x0001_DESCRIPTION_CONSUMABLE
 #define k0x0002_DescriptionMaskPoisoned 0x0002 // @ MASK0x0002_DESCRIPTION_POISONED  
 #define k0x0004_DescriptionMaskBroken 0x0004 // @ MASK0x0004_DESCRIPTION_BROKEN    
 #define k0x0008_DescriptionMaskCursed 0x0008 // @ MASK0x0008_DESCRIPTION_CURSED    
 
 void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
+	static Box boxObjectDescCircle(105, 136, 53, 79); // @ G0034_s_Graphic562_Box_ObjectDescriptionCircle 
+
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 	ObjectMan &objMan = *_vm->_objectMan;
 	DisplayMan &dispMan = *_vm->_displayMan;
@@ -515,7 +514,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice),
 								   g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
 		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k29_ObjectDescCircleIndice),
-								   g34_BoxObjectDescCircle, k16_byteWidth, k12_ColorDarkestGray, 27);
+								   boxObjectDescCircle, k16_byteWidth, k12_ColorDarkestGray, 27);
 
 		char *descString = nullptr;
 		char str[40];
@@ -587,18 +586,24 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			break;
 		}
 		case k10_JunkThingType: {
-			Junk *junk = (Junk *)rawThingPtr;
 			if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
 				potentialAttribMask = 0;
 				char *descString_EN_ANY[4] = {"(EMPTY)", "(ALMOST EMPTY)", "(ALMOST FULL)", "(FULL)"};
 				char *descString_DE_DEU[4] = {"(LEER)", "(FAST LEER)", "(FAST VOLL)", "(VOLL)"};
 				char *descString_FR_FRA[4] = {"(VIDE)", "(PRESQUE VIDE)", "(PRESQUE PLEINE)", "(PLEINE)"};
 
+				Junk *junk = (Junk *)rawThingPtr;
 				switch (_vm->getGameLanguage()) { // localized
 				default:
-				case Common::EN_ANY: descString = descString_EN_ANY[junk->getChargeCount()]; break;
-				case Common::DE_DEU: descString = descString_DE_DEU[junk->getChargeCount()]; break;
-				case Common::FR_FRA: descString = descString_FR_FRA[junk->getChargeCount()]; break;
+				case Common::EN_ANY:
+					descString = descString_EN_ANY[junk->getChargeCount()];
+					break;
+				case Common::DE_DEU:
+					descString = descString_DE_DEU[junk->getChargeCount()];
+					break;
+				case Common::FR_FRA:
+					descString = descString_FR_FRA[junk->getChargeCount()];
+					break;
 				}
 
 				f335_drawPanelObjectDescriptionString(descString);
@@ -607,9 +612,15 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 
 				switch (_vm->getGameLanguage()) { // localized
 				default:
-				case Common::EN_ANY: strcpy(str, "PARTY FACING "); break;
-				case Common::DE_DEU: strcpy(str, "GRUPPE BLICKT NACH "); break;
-				case Common::FR_FRA: strcpy(str, "GROUPE FACE "); break;
+				case Common::EN_ANY:
+					strcpy(str, "PARTY FACING ");
+					break;
+				case Common::DE_DEU:
+					strcpy(str, "GRUPPE BLICKT NACH ");
+					break;
+				case Common::FR_FRA:
+					strcpy(str, "GROUPE FACE ");
+					break;
 				}
 
 
@@ -625,11 +636,14 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 
 				f335_drawPanelObjectDescriptionString(str);
 			} else {
+				Junk *junk = (Junk *)rawThingPtr;
 				potentialAttribMask = k0x0001_DescriptionMaskConsumable;
 				actualAttribMask = _vm->_dungeonMan->_objectInfo[k127_ObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots();
 			}
 			break;
 		}
+		default:
+			break;
 		} // end of switch 
 
 		if (potentialAttribMask) {
@@ -1006,7 +1020,8 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 		case k14_PotionTypeVi:
 			AL1088_ui_HealWoundIterationCount = MAX(1, (((Potion*)L1082_ps_Junk)->getPower() / 42));
 			L1083_ps_Champion->_currHealth += L1083_ps_Champion->_maxHealth / L1086_ui_Counter;
-			if (L1087_i_Wounds = L1083_ps_Champion->_wounds) { /* If the champion is wounded */
+			L1087_i_Wounds = L1083_ps_Champion->_wounds;
+			if (L1087_i_Wounds) { /* If the champion is wounded */
 				L1086_ui_Counter = 10;
 				do {
 					for (AL1085_ui_Counter = 0; AL1085_ui_Counter < AL1088_ui_HealWoundIterationCount; AL1085_ui_Counter++) {
@@ -1019,19 +1034,21 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 			break;
 		case k15_PotionTypeWaterFlask:
 			L1083_ps_Champion->_water = MIN(L1083_ps_Champion->_water + 1600, 2048);
+			break;
+		default:
+			break;
 		}
 		((Potion*)L1082_ps_Junk)->setType(k20_PotionTypeEmptyFlask);
-	} else {
-		if ((L1079_ui_IconIndex >= k168_IconIndiceJunkApple) && (L1079_ui_IconIndex < k176_IconIndiceJunkIronKey)) {
-			L1083_ps_Champion->_food = MIN(L1083_ps_Champion->_food + G0242_ai_Graphic559_FoodAmounts[L1079_ui_IconIndex - k168_IconIndiceJunkApple], 2048);
-		}
+	} else if ((L1079_ui_IconIndex >= k168_IconIndiceJunkApple) && (L1079_ui_IconIndex < k176_IconIndiceJunkIronKey)) {
+		L1083_ps_Champion->_food = MIN(L1083_ps_Champion->_food + G0242_ai_Graphic559_FoodAmounts[L1079_ui_IconIndex - k168_IconIndiceJunkApple], 2048);
 	}
-	if (L1083_ps_Champion->_currStamina > L1083_ps_Champion->_maxStamina) {
+
+	if (L1083_ps_Champion->_currStamina > L1083_ps_Champion->_maxStamina)
 		L1083_ps_Champion->_currStamina = L1083_ps_Champion->_maxStamina;
-	}
-	if (L1083_ps_Champion->_currHealth > L1083_ps_Champion->_maxHealth) {
+
+	if (L1083_ps_Champion->_currHealth > L1083_ps_Champion->_maxHealth)
 		L1083_ps_Champion->_currHealth = L1083_ps_Champion->_maxHealth;
-	}
+
 	if (L1081_B_RemoveObjectFromLeaderHand) {
 		for (L1086_ui_Counter = 5; --L1086_ui_Counter; _vm->f22_delay(8)) { /* Animate mouth icon */
 			_vm->_objectMan->f37_drawIconToScreen(k205_IconIndiceMouthOpen + !(L1086_ui_Counter & 0x0001), 56, 46);
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 9aaff30..30fe420 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -42,63 +42,63 @@
 
 namespace DM {
 
-unsigned char g496_ActionSkillIndex[44] = { // @ G0496_auc_Graphic560_ActionSkillIndex
-	0,  /* N */
-	7,  /* BLOCK */
-	6,  /* CHOP */
-	0,  /* X */
-	14, /* BLOW HORN */
-	12, /* FLIP */
-	9,  /* PUNCH */
-	9,  /* KICK */
-	7,  /* WAR CRY Atari ST Versions 1.0 1987-12-08 1987-12-11 1.1: 14 */
-	9,  /* STAB */
-	8,  /* CLIMB DOWN */
-	14, /* FREEZE LIFE */
-	9,  /* HIT */
-	4,  /* SWING */
-	5,  /* STAB */
-	5,  /* THRUST */
-	5,  /* JAB */
-	7,  /* PARRY */
-	4,  /* HACK */
-	4,  /* BERZERK */
-	16, /* FIREBALL */
-	17, /* DISPELL */
-	14, /* CONFUSE */
-	17, /* LIGHTNING */
-	17, /* DISRUPT */
-	6,  /* MELEE */
-	8,  /* X */
-	3,  /* INVOKE */
-	4,  /* SLASH */
-	4,  /* CLEAVE */
-	6,  /* BASH */
-	6,  /* STUN */
-	11, /* SHOOT */
-	15, /* SPELLSHIELD */
-	15, /* FIRESHIELD */
-	3,  /* FLUXCAGE */
-	13, /* HEAL */
-	14, /* CALM */
-	17, /* LIGHT */
-	18, /* WINDOW */
-	16, /* SPIT */
-	14, /* BRANDISH */
-	10, /* THROW */
-	3}; /* FUSE */
-
-
-Box  g499_BoxActionArea3ActionMenu = Box(224, 319, 77, 121); // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu
-Box  g500_BoxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
-Box  g501_BoxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
-Box g1_BoxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea 
-byte g498_PalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
-
-Box gK74_BoxSpellAreaLine = Box(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine 
-Box gK75_BoxSpellAreaLine2 = Box(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 
-Box gK76_BoxSpellAreaLine3 = Box(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 
-Box g0_BoxSpellArea = Box(224, 319, 42, 74);
+void MenuMan::initConstants() {
+	static unsigned char actionSkillIndex[44] = { // @ G0496_auc_Graphic560_ActionSkillIndex
+		0,  /* N */
+		7,  /* BLOCK */
+		6,  /* CHOP */
+		0,  /* X */
+		14, /* BLOW HORN */
+		12, /* FLIP */
+		9,  /* PUNCH */
+		9,  /* KICK */
+		7,  /* WAR CRY Atari ST Versions 1.0 1987-12-08 1987-12-11 1.1: 14 */
+		9,  /* STAB */
+		8,  /* CLIMB DOWN */
+		14, /* FREEZE LIFE */
+		9,  /* HIT */
+		4,  /* SWING */
+		5,  /* STAB */
+		5,  /* THRUST */
+		5,  /* JAB */
+		7,  /* PARRY */
+		4,  /* HACK */
+		4,  /* BERZERK */
+		16, /* FIREBALL */
+		17, /* DISPELL */
+		14, /* CONFUSE */
+		17, /* LIGHTNING */
+		17, /* DISRUPT */
+		6,  /* MELEE */
+		8,  /* X */
+		3,  /* INVOKE */
+		4,  /* SLASH */
+		4,  /* CLEAVE */
+		6,  /* BASH */
+		6,  /* STUN */
+		11, /* SHOOT */
+		15, /* SPELLSHIELD */
+		15, /* FIRESHIELD */
+		3,  /* FLUXCAGE */
+		13, /* HEAL */
+		14, /* CALM */
+		17, /* LIGHT */
+		18, /* WINDOW */
+		16, /* SPIT */
+		14, /* BRANDISH */
+		10, /* THROW */
+		3 /* FUSE */
+	};
+
+	boxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
+	boxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
+	boxActionArea3ActionMenu = Box(224, 319, 77, 121); // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu
+	boxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea 
+	boxSpellArea = Box(224, 319, 42, 74);
+
+	for (int i = 0; i < 40; i++)
+		g496_ActionSkillIndex[i] = actionSkillIndex[i];
+}
 
 MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
 	_g508_refreshActionArea = false;
@@ -109,6 +109,8 @@ MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
 	_gK73_bitmapSpellAreaLines = new byte[3 * 96 * 12];
 	_g517_actionTargetGroupThing = Thing(0);
 	_g507_actionCount = 0;
+
+	initConstants();
 }
 
 MenuMan::~MenuMan() {
@@ -133,6 +135,8 @@ void MenuMan::f388_clearActingChampion() {
 }
 
 void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
+	static byte palChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
+
 	if (!_g509_actionAreaContainsIcons)
 		return;
 	DisplayMan &dm = *_vm->_displayMan;
@@ -160,7 +164,7 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
 		goto T0386006;
 	}
 	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, bitmapIcon);
-	dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, bitmapIcon, 16, 16, 16, 16, g498_PalChangesActionAreaObjectIcon);
+	dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, bitmapIcon, 16, 16, 16, 16, palChangesActionAreaObjectIcon);
 T0386006:
 	dm.D24_fillScreenBox(box, k4_ColorCyan);
 	Box box2;
@@ -185,8 +189,8 @@ void MenuMan::f456_drawDisabledMenu() {
 		} else {
 			_vm->_displayMan->f136_shadeScreenBox(&_vm->_displayMan->_boxMovementArrows, k0_ColorBlack);
 		}
-		_vm->_displayMan->f136_shadeScreenBox(&g0_BoxSpellArea, k0_ColorBlack);
-		_vm->_displayMan->f136_shadeScreenBox(&g1_BoxActionArea, k0_ColorBlack);
+		_vm->_displayMan->f136_shadeScreenBox(&boxSpellArea, k0_ColorBlack);
+		_vm->_displayMan->f136_shadeScreenBox(&boxActionArea, k0_ColorBlack);
 		_vm->_eventMan->f67_setMousePointerToNormal(k0_pointerArrow);
 	}
 }
@@ -253,16 +257,16 @@ void MenuMan::f387_drawActionArea() {
 
 	_vm->_eventMan->f77_hideMouse();
 	dispMan._g578_useByteBoxCoordinates = false;
-	dispMan.D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack);
+	dispMan.D24_fillScreenBox(boxActionArea, k0_ColorBlack);
 	if (_g509_actionAreaContainsIcons) {
 		for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._g305_partyChampionCount; ++champIndex)
 			f386_drawActionIcon((ChampionIndex)champIndex);
 	} else if (champMan._g506_actingChampionOrdinal) {
-		Box box = g499_BoxActionArea3ActionMenu;
+		Box box = boxActionArea3ActionMenu;
 		if (_g713_actionList._actionIndices[2] == k255_ChampionActionNone)
-			box = g500_BoxActionArea2ActionMenu;
+			box = boxActionArea2ActionMenu;
 		if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone)
-			box = g501_BoxActionArea1ActionMenu;
+			box = boxActionArea1ActionMenu;
 		dispMan.f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k10_MenuActionAreaIndice),
 								 &box, k48_byteWidth, kM1_ColorNoTransparency, 45);
 		textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen,
@@ -365,11 +369,13 @@ T0393003:
 #define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
 
 void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
+	static Box boxSpellAreaLine(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine 
+
 	char L1204_ac_SpellSymbolString[2] = {'\0', '\0'};
 	Champion *L1203_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
 	if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) {
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		_vm->_displayMan->f132_blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 12, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
+		_vm->_displayMan->f132_blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, boxSpellAreaLine, 0, 12, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
 		int16 x = 1;
 		char character = 96 + (6 * L1203_ps_Champion->_symbolStep);
 		for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
@@ -378,7 +384,7 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
 		}
 	} else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) {
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		_vm->_displayMan->f132_blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 24, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
+		_vm->_displayMan->f132_blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, boxSpellAreaLine, 0, 24, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
 		int16 x = 8;
 		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
 			if ((L1204_ac_SpellSymbolString[0] = L1203_ps_Champion->_symbols[symbolIndex]) == '\0')
@@ -389,6 +395,9 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
 }
 
 void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
+	static Box boxSpellAreaLine2(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 
+	static Box boxSpellAreaLine3(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 
+
 	Champion* L1213_ps_Champion;
 
 	if ((champIndex == _vm->_championMan->_g514_magicCasterChampionIndex) || ((champIndex != kM1_ChampionNone) && !_vm->_championMan->_gK71_champions[champIndex]._currHealth)) {
@@ -396,14 +405,14 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	}
 	if (_vm->_championMan->_g514_magicCasterChampionIndex == kM1_ChampionNone) {
 		_vm->_eventMan->f78_showMouse();
-		_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &g0_BoxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33);
+		_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &boxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33);
 		_vm->_eventMan->f77_hideMouse();
 	}
 	if (champIndex == kM1_ChampionNone) {
 		_vm->_championMan->_g514_magicCasterChampionIndex = kM1_ChampionNone;
 		_vm->_eventMan->f78_showMouse();
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		_vm->_displayMan->D24_fillScreenBox(g0_BoxSpellArea, k0_ColorBlack);
+		_vm->_displayMan->D24_fillScreenBox(boxSpellArea, k0_ColorBlack);
 		_vm->_eventMan->f77_hideMouse();
 		return;
 	}
@@ -411,9 +420,9 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
 	_vm->_eventMan->f78_showMouse();
 	f393_drawSpellAreaControls((ChampionIndex)champIndex);
-	_vm->_displayMan->f21_blitToScreen(_gK72_bitmapSpellAreaLine, &gK75_BoxSpellAreaLine2, k48_byteWidth, kM1_ColorNoTransparency, 12);
+	_vm->_displayMan->f21_blitToScreen(_gK72_bitmapSpellAreaLine, &boxSpellAreaLine2, k48_byteWidth, kM1_ColorNoTransparency, 12);
 	f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols);
-	_vm->_displayMan->f21_blitToScreen(_gK72_bitmapSpellAreaLine, &gK76_BoxSpellAreaLine3, k48_byteWidth, kM1_ColorNoTransparency, 12);
+	_vm->_displayMan->f21_blitToScreen(_gK72_bitmapSpellAreaLine, &boxSpellAreaLine3, k48_byteWidth, kM1_ColorNoTransparency, 12);
 	_vm->_eventMan->f77_hideMouse();
 }
 
@@ -1708,7 +1717,7 @@ void MenuMan::f385_drawActionDamage(int16 damage) {
 
 	_vm->_eventMan->f78_showMouse();
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_vm->_displayMan->D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack);
+	_vm->_displayMan->D24_fillScreenBox(boxActionArea, k0_ColorBlack);
 	if (damage < 0) {
 		static char *messages_EN_ANY[2] = {"CAN'T REACH", "NEED AMMO"};
 		static char *messages_DE_DEU[2] = {"ZU WEIT WEG", "MEHR MUNITION"};
@@ -1735,7 +1744,7 @@ void MenuMan::f385_drawActionDamage(int16 damage) {
 		_vm->_textMan->f53_printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, (char *)AL1178_puc_String);
 	} else {
 		if (damage > 40) {
-			L1180_ps_Box = &g499_BoxActionArea3ActionMenu;
+			L1180_ps_Box = &boxActionArea3ActionMenu;
 			L1177_puc_Bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
 			L1175_i_ByteWidth = k48_byteWidth;
 			L1643_i_Width = 45;
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 40bcfbf..34f8355 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -39,9 +39,6 @@ namespace DM {
 
 #define k0x8000_hitNonMaterialCreatures 0x8000 // @ MASK0x8000_HIT_NON_MATERIAL_CREATURES 
 
-extern Box g1_BoxActionArea; // @ G0001_s_Graphic562_Box_ActionArea
-extern Box g0_BoxSpellArea; // @ G0000_s_Graphic562_Box_SpellArea
-
 class ActionList {
 public:
 	byte _minimumSkillLevel[3]; /* Bit 7: requires charge, Bit 6-0: minimum skill level. */
@@ -118,6 +115,15 @@ public:
 	void f383_setActionList(ActionSet *actionSet); // @ F0383_MENUS_SetActionList
 	int16 f382_getActionObjectChargeCount(); // @ F0382_MENUS_GetActionObjectChargeCount
 	void f385_drawActionDamage(int16 damage); // @ F0385_MENUS_DrawActionDamage
+
+	Box boxActionArea3ActionMenu; // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu
+	Box boxActionArea2ActionMenu; // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
+	Box boxActionArea1ActionMenu; // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
+	Box boxActionArea; // @ G0001_s_Graphic562_Box_ActionArea 
+	Box boxSpellArea;
+	unsigned char g496_ActionSkillIndex[44]; // @ G0496_auc_Graphic560_ActionSkillIndex
+
+	void initConstants();
 };
 
 }


Commit: 8ed20d852e8118edf44869cf17c879728f10f255
    https://github.com/scummvm/scummvm/commit/8ed20d852e8118edf44869cf17c879728f10f255
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Change several string constness, hopefully fixing GCC warnings

Changed paths:
    engines/dm/dialog.cpp
    engines/dm/dialog.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/menus.cpp
    engines/dm/menus.h



diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index c069bb4..6772d32 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -37,7 +37,7 @@ DialogMan::DialogMan(DMEngine *vm) : _vm(vm) {
 	_g335_selectedDialogChoice = 0;
 }
 
-void DialogMan::f427_dialogDraw(char *msg1, char *msg2, char *choice1, char *choice2, char *choice3, char *choice4, bool screenDialog, bool clearScreen, bool fading) {
+void DialogMan::f427_dialogDraw(const char *msg1, const char *msg2, const char *choice1, const char *choice2, const char *choice3, const char *choice4, bool screenDialog, bool clearScreen, bool fading) {
 	static Box constBox1 = Box(0, 223, 101, 125);
 	static Box constBox2 = Box(0, 223, 76, 100);
 	static Box constBox3 = Box(0, 223, 51, 75);
@@ -140,14 +140,14 @@ void DialogMan::f427_dialogDraw(char *msg1, char *msg2, char *choice1, char *cho
 	_vm->_displayMan->updateScreen();
 }
 
-void DialogMan::f425_printCenteredChoice(byte *bitmap, char *str, int16 posX, int16 posY) {
+void DialogMan::f425_printCenteredChoice(byte *bitmap, const char *str, int16 posX, int16 posY) {
 	if (str) {
 		posX -= (strlen(str) * 6) >> 1;
 		_vm->_textMan->f40_printTextToBitmap(bitmap, k112_byteWidthViewport, posX, posY, k9_ColorGold, k5_ColorLightBrown, str, k136_heightViewport);
 	}
 }
 
-bool DialogMan::f426_isMessageOnTwoLines(char *str, char *part1, char *part2) {
+bool DialogMan::f426_isMessageOnTwoLines(const char *str, char *part1, char *part2) {
 	uint16 strLength = strlen(str);
 	if (strLength <= 30)
 		return false;
diff --git a/engines/dm/dialog.h b/engines/dm/dialog.h
index 48a1acc..1ac88fe 100644
--- a/engines/dm/dialog.h
+++ b/engines/dm/dialog.h
@@ -47,10 +47,10 @@ class DialogMan {
 public:
 	uint16 _g335_selectedDialogChoice; // @ G0335_ui_SelectedDialogChoice
 	explicit DialogMan(DMEngine *vm);
-	void f427_dialogDraw(char *msg1, char *msg2, char *choice1, char *choice2,
-						 char *choice3, char *choice4, bool screenDialog, bool clearScreen, bool fading); // @ F0427_DIALOG_Draw
-	void f425_printCenteredChoice(byte *bitmap, char *str, int16 posX, int16 posY); // @ F0425_DIALOG_PrintCenteredChoice
-	bool f426_isMessageOnTwoLines(char *str, char *part1, char *part2); // @ F0426_DIALOG_IsMessageOnTwoLines
+	void f427_dialogDraw(const char *msg1, const char *msg2, const char *choice1, const char *choice2,
+						 const char *choice3, const char *choice4, bool screenDialog, bool clearScreen, bool fading); // @ F0427_DIALOG_Draw
+	void f425_printCenteredChoice(byte *bitmap, const char *str, int16 posX, int16 posY); // @ F0425_DIALOG_PrintCenteredChoice
+	bool f426_isMessageOnTwoLines(const char *str, char *part1, char *part2); // @ F0426_DIALOG_IsMessageOnTwoLines
 	int16 f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex, int16 driveType, int16 automaticChoiceIfFlopyInDrive); // @ F0424_DIALOG_GetChoice
 };
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 5463a21..78dc28a 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -402,7 +402,7 @@ void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int
 	_vm->_displayMan->f20_blitToViewport(iconBitmap, box, k8_byteWidth, kM1_ColorNoTransparency, 16);
 }
 
-void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) {
+void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, const char** attribStrings, char* destString, const char* prefixString, const char* suffixString) {
 	uint16 identicalBitCount = 0;
 	int16 attribMask = 1;
 	for (uint16 stringIndex = 0; stringIndex < 16; stringIndex++, attribMask <<= 1) {
@@ -440,7 +440,7 @@ void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, in
 	strcat(destString, suffixString);
 }
 
-void InventoryMan::f335_drawPanelObjectDescriptionString(char *descString) {
+void InventoryMan::f335_drawPanelObjectDescriptionString(const char *descString) {
 	if (descString[0] == '\f') { // form feed
 		descString++;
 		_g421_objDescTextXpos = 108;
@@ -516,7 +516,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k29_ObjectDescCircleIndice),
 								   boxObjectDescCircle, k16_byteWidth, k12_ColorDarkestGray, 27);
 
-		char *descString = nullptr;
+		const char *descString = nullptr;
 		char str[40];
 		if (iconIndex == k147_IconIndiceJunkChampionBones) {
 			switch (_vm->getGameLanguage()) { // localized
@@ -624,9 +624,9 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 				}
 
 
-				static char* directionName_EN_ANY[4] = {"NORTH", "EAST", "SOUTH", "WEST"};
-				static char* directionName_DE_DEU[4] = {"NORDEN", "OSTEN", "SUEDEN", "WESTEN"};
-				static char* directionName_FR_FRA[4] = {"AU NORD", "A L'EST", "AU SUD", "A L'OUEST"};
+				const static char* directionName_EN_ANY[4] = {"NORTH", "EAST", "SOUTH", "WEST"};
+				const static char* directionName_DE_DEU[4] = {"NORDEN", "OSTEN", "SUEDEN", "WESTEN"};
+				const static char* directionName_FR_FRA[4] = {"AU NORD", "A L'EST", "AU SUD", "A L'OUEST"};
 				switch (_vm->getGameLanguage()) { // localized
 				default:
 				case Common::EN_ANY: strcat(str, directionName_EN_ANY[iconIndex]); break;
@@ -647,10 +647,10 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		} // end of switch 
 
 		if (potentialAttribMask) {
-			char *attribString_EN_ANY[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"};
-			char *attribString_DE_DEU[4] = {"ESSBAR", "VERGIFTET", "DEFEKT", "VERFLUCHT"};
-			char *attribString_FR_FRA[4] = {"COMESTIBLE", "EMPOISONNE", "BRISE", "MAUDIT"};
-			char **attribString = nullptr;
+			static const char *attribString_EN_ANY[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"};
+			static const char *attribString_DE_DEU[4] = {"ESSBAR", "VERGIFTET", "DEFEKT", "VERFLUCHT"};
+			static const char *attribString_FR_FRA[4] = {"COMESTIBLE", "EMPOISONNE", "BRISE", "MAUDIT"};
+			static const char **attribString = nullptr;
 
 			switch (_vm->getGameLanguage()) { // localized
 			default:
@@ -813,10 +813,10 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 	uint16 L1096_ui_StatisticMaximumValue;
 	char L1097_ac_String[20];
 
-	static char* G0431_apc_StatisticNames_EN_ANY[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"};
-	static char* G0431_apc_StatisticNames_DE_DEU[7] = {"L", "STAERKE", "FLINKHEIT", "WEISHEIT", "VITALITAET", "ANTI-MAGIE", "ANTI-FEUER"};
-	static char* G0431_apc_StatisticNames_FR_FRA[7] = {"L", "FORCE", "DEXTERITE", "SAGESSE", "VITALITE", "ANTI-MAGIE", "ANTI-FEU"};
-	char **G0431_apc_StatisticNames;
+	static const char* G0431_apc_StatisticNames_EN_ANY[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"};
+	static const char* G0431_apc_StatisticNames_DE_DEU[7] = {"L", "STAERKE", "FLINKHEIT", "WEISHEIT", "VITALITAET", "ANTI-MAGIE", "ANTI-FEUER"};
+	static const char* G0431_apc_StatisticNames_FR_FRA[7] = {"L", "FORCE", "DEXTERITE", "SAGESSE", "VITALITE", "ANTI-MAGIE", "ANTI-FEU"};
+	const char **G0431_apc_StatisticNames;
 	switch (_vm->getGameLanguage()) { // localized
 	default:
 	case Common::EN_ANY: G0431_apc_StatisticNames = G0431_apc_StatisticNames_EN_ANY; break;
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 856f7d0..c15a26c 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -73,9 +73,9 @@ public:
 	void f341_drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll
 	void f333_openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye); // @ F0333_INVENTORY_OpenAndDrawChest
 	void f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos); // @ F0332_INVENTORY_DrawIconToViewport
-	void f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char ** attribStrings,
-									char *destString, char *prefixString, char *suffixString); // @ F0336_INVENTORY_DrawPanel_BuildObjectAttributesString
-	void f335_drawPanelObjectDescriptionString(char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString
+	void f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, const char ** attribStrings,
+									char *destString, const char *prefixString, const char *suffixString); // @ F0336_INVENTORY_DrawPanel_BuildObjectAttributesString
+	void f335_drawPanelObjectDescriptionString(const char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString
 	void f339_drawPanelArrowOrEye(bool pressingEye); // @ F0339_INVENTORY_DrawPanel_ArrowOrEye
 	void f342_drawPanelObject(Thing thingToDraw, bool pressingEye); // @ F0342_INVENTORY_DrawPanel_Object
 	void f337_setDungeonViewPalette(); // @ F0337_INVENTORY_SetDungeonViewPalette
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 30fe420..3134bbb 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -686,7 +686,7 @@ Spell* MenuMan::f409_getSpellFromSymbols(byte* symbols) {
 }
 
 void MenuMan::f410_menusPrintSpellFailureMessage(Champion* champ, uint16 failureType, uint16 skillIndex) {
-	char* L1264_pc_Message = nullptr;
+	const char *L1264_pc_Message = nullptr;
 
 	if (skillIndex > k3_ChampionSkillWizard)
 		skillIndex = (skillIndex - 4) / 4;
@@ -694,12 +694,12 @@ void MenuMan::f410_menusPrintSpellFailureMessage(Champion* champ, uint16 failure
 	_vm->_textMan->f51_messageAreaPrintLineFeed();
 	_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, champ->_name);
 
-	char *messages_EN_ANY[4] = {" NEEDS MORE PRACTICE WITH THIS ", " SPELL.", " MUMBLES A MEANINGLESS SPELL."," NEEDS AN EMPTY FLASK IN HAND FOR POTION."};
-	char *messages_DE_DEU[4] = {" BRAUCHT MEHR UEBUNG MIT DIESEM ", " ZAUBERSPRUCH.",
+	const char *messages_EN_ANY[4] = {" NEEDS MORE PRACTICE WITH THIS ", " SPELL.", " MUMBLES A MEANINGLESS SPELL."," NEEDS AN EMPTY FLASK IN HAND FOR POTION."};
+	const char *messages_DE_DEU[4] = {" BRAUCHT MEHR UEBUNG MIT DIESEM ", " ZAUBERSPRUCH.",
 		" MURMELT EINEN SINNLOSEN ZAUBERSPRUCH.", " MUSS FUER DEN TRANK EINE LEERE FLASCHE BEREITHALTEN."};
-	char *messages_FR_FRA[5] = {" DOIT PRATIQUER DAVANTAGE SON ", "ENVOUTEMENT.", " MARMONNE UNE CONJURATION IMCOMPREHENSIBLE.",
+	const char *messages_FR_FRA[5] = {" DOIT PRATIQUER DAVANTAGE SON ", "ENVOUTEMENT.", " MARMONNE UNE CONJURATION IMCOMPREHENSIBLE.",
 		" DOIT AVOIR UN FLACON VIDE EN MAIN POUR LA POTION.", "EXORCISME."};
-	char **messages;
+	const char **messages;
 	switch (_vm->getGameLanguage()) { // localized
 	default:
 	case Common::EN_ANY:
@@ -1192,10 +1192,10 @@ T0407032:
 		}
 		break;
 	case k5_ChampionActionFlip: {
-		char *messages_EN_ANY[2] = {"IT COMES UP HEADS.", "IT COMES UP TAILS."};
-		char *messages_DE_DEU[2] = {"DIE KOPFSEITE IST OBEN.", "DIE ZAHL IST OBEN."};
-		char *messages_FR_FRA[2] = {"C'EST FACE.", "C'EST PILE."};
-		char **message;
+		const char *messages_EN_ANY[2] = {"IT COMES UP HEADS.", "IT COMES UP TAILS."};
+		const char *messages_DE_DEU[2] = {"DIE KOPFSEITE IST OBEN.", "DIE ZAHL IST OBEN."};
+		const char *messages_FR_FRA[2] = {"C'EST FACE.", "C'EST PILE."};
+		const char **message;
 		switch (_vm->getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY: message = messages_EN_ANY; break;
@@ -1544,7 +1544,7 @@ T0401016:
 	return L1232_B_IsGroupFrightenedByAction;
 }
 
-void MenuMan::f381_printMessageAfterReplacements(char* str) {
+void MenuMan::f381_printMessageAfterReplacements(const char* str) {
 	char* L1164_pc_Character;
 	char* L1165_pc_ReplacementString;
 	char L1166_ac_OutputString[128];
@@ -1719,13 +1719,13 @@ void MenuMan::f385_drawActionDamage(int16 damage) {
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	_vm->_displayMan->D24_fillScreenBox(boxActionArea, k0_ColorBlack);
 	if (damage < 0) {
-		static char *messages_EN_ANY[2] = {"CAN'T REACH", "NEED AMMO"};
-		static char *messages_DE_DEU[2] = {"ZU WEIT WEG", "MEHR MUNITION"};
-		static char *messages_FR_FRA[2] = {"TROP LOIN", "SANS MUNITION"};
+		static const char *messages_EN_ANY[2] = {"CAN'T REACH", "NEED AMMO"};
+		static const char *messages_DE_DEU[2] = {"ZU WEIT WEG", "MEHR MUNITION"};
+		static const char *messages_FR_FRA[2] = {"TROP LOIN", "SANS MUNITION"};
 		static int16  pos_EN_ANY[2] = {242, 248};
 		static int16  pos_DE_DEU[2] = {242, 236};
 		static int16  pos_FR_FRA[2] = {248, 236};
-		char **message;
+		const char **message;
 		int16 *pos;
 		switch (_vm->getGameLanguage()) { // localized
 		default:
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 34f8355..0fe8b44 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -110,7 +110,7 @@ public:
 	bool f402_isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 actionIndex, int16 targetMapX,
 									 int16 targetMapY, int16 skillIndex); // @ F0402_MENUS_IsMeleeActionPerformed
 	bool  f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, int16 mapX, int16 mapY); // @ F0401_MENUS_IsGroupFrightenedByAction
-	void f381_printMessageAfterReplacements(char *str); // @ F0381_MENUS_PrintMessageAfterReplacements
+	void f381_printMessageAfterReplacements(const char *str); // @ F0381_MENUS_PrintMessageAfterReplacements
 	void f389_processCommands116To119_setActingChampion(uint16 champIndex); // @ F0389_MENUS_ProcessCommands116To119_SetActingChampion
 	void f383_setActionList(ActionSet *actionSet); // @ F0383_MENUS_SetActionList
 	int16 f382_getActionObjectChargeCount(); // @ F0382_MENUS_GetActionObjectChargeCount


Commit: 0233b503f1e74b15350f71d7d906e10091ac2688
    https://github.com/scummvm/scummvm/commit/0233b503f1e74b15350f71d7d906e10091ac2688
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Some more work on GCC warnings

Changed paths:
    engines/dm/movesens.cpp
    engines/dm/projexpl.cpp
    engines/dm/sounds.cpp
    engines/dm/sounds.h
    engines/dm/text.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 57bd51f..e961eca 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -587,10 +587,14 @@ bool MovesensMan::f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMa
 		AL0700_i_SecondaryDirection = returnNextVal(AL0699_ui_PrimaryDirection);
 		for (int16 i = 0; i < 4; ++i)
 			L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[i] = 0;
-		if (L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnPrevVal(AL0699_ui_PrimaryDirection)] = L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection]) {
+
+		L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnPrevVal(AL0699_ui_PrimaryDirection)] = L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection];
+		if (L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnPrevVal(AL0699_ui_PrimaryDirection)]) {
 			L0703_B_CheckDestinationSquareProjectileImpacts = true;
 		}
-		if (L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnNextVal(AL0700_i_SecondaryDirection)] = L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection]) {
+
+		L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnNextVal(AL0700_i_SecondaryDirection)] = L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection];
+		if (L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnNextVal(AL0700_i_SecondaryDirection)]) {
 			L0703_B_CheckDestinationSquareProjectileImpacts = true;
 		}
 		if (!L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection]) {
@@ -700,19 +704,25 @@ int16 MovesensMan::f262_getTeleporterRotatedGroupResult(Teleporter* teleporter,
 	L0686_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(thing);
 	L0683_i_Rotation = teleporter->getRotation();
 	L0684_ui_GroupDirections = _vm->_groupMan->f147_getGroupDirections(L0686_ps_Group, mapIndex);
-	if (L0689_B_AbsoluteRotation = teleporter->getAbsoluteRotation()) {
+
+	L0689_B_AbsoluteRotation = teleporter->getAbsoluteRotation();
+	if (L0689_B_AbsoluteRotation) {
 		L0685_ui_UpdatedGroupDirections = L0683_i_Rotation;
 	} else {
 		L0685_ui_UpdatedGroupDirections = M21_normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation);
 	}
-	if ((L0687_ui_UpdatedGroupCells = _vm->_groupMan->f145_getGroupCells(L0686_ps_Group, mapIndex)) != k255_CreatureTypeSingleCenteredCreature) {
+
+	L0687_ui_UpdatedGroupCells = _vm->_groupMan->f145_getGroupCells(L0686_ps_Group, mapIndex);
+	if (L0687_ui_UpdatedGroupCells != k255_CreatureTypeSingleCenteredCreature) {
 		L0690_ui_GroupCells = L0687_ui_UpdatedGroupCells;
 		L0691_i_CreatureSize = getFlag(g243_CreatureInfo[L0686_ps_Group->_type]._attributes, k0x0003_MaskCreatureInfo_size);
 		L0692_i_RelativeRotation = M21_normalizeModulo4(4 + L0685_ui_UpdatedGroupDirections - L0684_ui_GroupDirections);
 		for (L0688_i_CreatureIndex = 0; L0688_i_CreatureIndex <= L0686_ps_Group->getCount(); L0688_i_CreatureIndex++) {
 			L0685_ui_UpdatedGroupDirections = _vm->_groupMan->f178_getGroupValueUpdatedWithCreatureValue(L0685_ui_UpdatedGroupDirections, L0688_i_CreatureIndex, L0689_B_AbsoluteRotation ? L0683_i_Rotation : M21_normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation));
-			if ((L0691_i_CreatureSize == k0_MaskCreatureSizeQuarter) && (L0692_i_RelativeRotation = !L0689_B_AbsoluteRotation)) {
-				L0692_i_RelativeRotation = L0683_i_Rotation;
+			if (L0691_i_CreatureSize == k0_MaskCreatureSizeQuarter) {
+				L0692_i_RelativeRotation = !L0689_B_AbsoluteRotation;
+				if (L0692_i_RelativeRotation) 
+					L0692_i_RelativeRotation = L0683_i_Rotation;
 			}
 			if (L0692_i_RelativeRotation) {
 				L0687_ui_UpdatedGroupCells = _vm->_groupMan->f178_getGroupValueUpdatedWithCreatureValue(L0687_ui_UpdatedGroupCells, L0688_i_CreatureIndex, M21_normalizeModulo4(L0690_ui_GroupCells + L0692_i_RelativeRotation));
@@ -733,7 +743,6 @@ Thing MovesensMan::f263_getTeleporterRotatedProjectileThing(Teleporter* teleport
 	int16 L0693_i_UpdatedDirection;
 	int16 L0694_i_Rotation;
 
-
 	L0693_i_UpdatedDirection = _g400_moveResultDir;
 	L0694_i_Rotation = teleporter->getRotation();
 	if (teleporter->getAbsoluteRotation()) {
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 95e3165..2ca7be1 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -129,6 +129,9 @@ T0217004:
 			L0509_B_RemovePotion = true;
 			L0508_i_PotionPower = ((Potion *)L0491_ps_Group)->getPower();
 			L0492_ps_Potion = (Potion *)L0491_ps_Group;
+			break;
+		default:
+			break;
 		}
 	}
 	L0505_B_CreateExplosionOnImpact = (L0510_i_ProjectileAssociatedThingType == k15_ExplosionThingType) && (L0486_T_ProjectileAssociatedThing != Thing::_explSlime) && (L0486_T_ProjectileAssociatedThing != Thing::_explPoisonBolt);
@@ -190,7 +193,8 @@ T0217004:
 		if (getFlag(L0493_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) && (L0486_T_ProjectileAssociatedThing != Thing::_explHarmNonMaterial)) {
 			return false;
 		}
-		if (L0488_i_Attack = (uint16)((unsigned long)f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing) << 6) / L0493_ps_CreatureInfo->_defense) {
+		L0488_i_Attack = (uint16)((unsigned long)f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing) << 6) / L0493_ps_CreatureInfo->_defense;
+		if (L0488_i_Attack) {
 			if ((AL0487_i_Outcome = _vm->_groupMan->f190_groupGetDamageCreatureOutcome(L0491_ps_Group, L0512_ui_CreatureIndex, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, L0488_i_Attack + _vm->_groupMan->f192_groupGetResistanceAdjustedPoisonAttack(L0511_ui_CreatureType, _g366_projectilePoisonAttack), true)) != k0_outcomeKilledNoCreaturesInGroup) {
 				_vm->_groupMan->f209_processEvents29to41(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, kM2_TMEventTypeCreateReactionEvent30HitByProjectile, 0);
 			}
@@ -466,8 +470,8 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 		L0526_i_SourceMapY = L0524_i_DestinationMapY;
 		L0523_i_DestinationMapX += _vm->_dirIntoStepCountEast[L0517_ui_ProjectileDirection], L0524_i_DestinationMapY += _vm->_dirIntoStepCountNorth[L0517_ui_ProjectileDirection];
 		if ((Square(AL0516_ui_Square = _vm->_dungeonMan->f151_getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY).toByte()).getType() == k0_ElementTypeWall) ||
-			((Square(AL0516_ui_Square).getType() == k6_ElementTypeFakeWall) && !getFlag(AL0516_ui_Square, (k0x0001_FakeWallImaginary | k0x0004_FakeWallOpen))) ||
-			((Square(AL0516_ui_Square).getType() == k3_ElementTypeStairs) && (Square(_vm->_dungeonMan->_g271_currMapData[L0525_i_SourceMapX][L0526_i_SourceMapY]).getType() == k3_ElementTypeStairs))) {
+			((Square(AL0516_ui_Square).getType() == k6_FakeWallElemType) && !getFlag(AL0516_ui_Square, (k0x0001_FakeWallImaginary | k0x0004_FakeWallOpen))) ||
+			((Square(AL0516_ui_Square).getType() == k3_StairsElemType) && (Square(_vm->_dungeonMan->_g271_currMapData[L0525_i_SourceMapX][L0526_i_SourceMapY]).getType() == k3_ElementTypeStairs))) {
 			if (f217_projectileHasImpactOccurred(Square(AL0516_ui_Square).getType(), L0525_i_SourceMapX, L0526_i_SourceMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
 				return;
 			}
diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp
index c041715..fe53f11 100644
--- a/engines/dm/sounds.cpp
+++ b/engines/dm/sounds.cpp
@@ -47,50 +47,56 @@ SoundMan* SoundMan::getSoundMan(DMEngine* vm, const DMADGameDescription* gameVer
 	}
 }
 
-SoundMan::SoundMan(DMEngine* vm) : _vm(vm) {}
+void SoundMan::initConstants() {
+	Sound sounds[k34_D13_soundCount] = {
+		Sound(533, 112,  11, 3, 6), /* k00_soundMETALLIC_THUD 0 */
+		Sound(534, 112,  15, 0, 3), /* k01_soundSWITCH 1 */
+		Sound(535, 112,  72, 3, 6), /* k02_soundDOOR_RATTLE 2 */
+		Sound(550, 112,  60, 3, 5), /* k03_soundATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON 3 */
+		Sound(536, 112,  10, 3, 6), /* k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM 4 */
+		Sound(537, 112,  99, 3, 7), /* k05_soundSTRONG_EXPLOSION 5 */
+		Sound(539, 112, 110, 3, 6), /* k06_soundSCREAM 6 */
+		Sound(551, 112,  55, 3, 5), /* k07_soundATTACK_MUMMY_GHOST_RIVE 7 */
+		Sound(540, 112,   2, 3, 6), /* k08_soundSWALLOW 8 */
+		Sound(541, 112,  80, 3, 6), /* k09_soundCHAMPION_0_DAMAGED 9 */
+		Sound(542, 112,  82, 3, 6), /* k10_soundCHAMPION_1_DAMAGED 10 */
+		Sound(543, 112,  84, 3, 6), /* k11_soundCHAMPION_2_DAMAGED 11 */
+		Sound(544, 112,  86, 3, 6), /* k12_soundCHAMPION_3_DAMAGED 12 */
+		Sound(545, 112,  95, 3, 6), /* k13_soundSPELL 13 */
+		Sound(552, 112,  57, 3, 5), /* k14_soundATTACK_SCREAMER_OITU 14 */
+		Sound(553, 112,  52, 3, 5), /* k15_soundATTACK_GIANT_SCORPION_SCORPION 15 */
+		Sound(546, 112,  40, 2, 4), /* k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT 16 */
+		Sound(547, 112,  70, 1, 4), /* k17_soundBUZZ 17 */
+		Sound(549, 138,  75, 3, 6), /* k18_soundPARTY_DAMAGED 18 */
+		Sound(554, 112,  50, 3, 5), /* k19_soundATTACK_MAGENTA_WORM_WORM 19 */
+		Sound(537, 112,  98, 0, 4), /* k20_soundWEAK_EXPLOSION 20 */
+		Sound(555, 112,  96, 2, 4), /* k21_soundATTACK_GIGGLER 21 */
+		Sound(563, 138,  24, 0, 4), /* k22_soundMOVE_ANIMATED_ARMOUR_DETH_KNIGHT 22 Atari ST: not present */
+		Sound(564, 138,  21, 0, 4), /* k23_soundMOVE_COUATL_GIANT_WASP_MUNCHER 23 Atari ST: not present */
+		Sound(565, 138,  23, 0, 4), /* k24_soundMOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON 24 Atari ST: not present */
+		Sound(566, 138, 105, 0, 4), /* k25_soundBLOW_HORN 25 Atari ST: not present */
+		Sound(567, 138,  27, 0, 4), /* k26_soundMOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU 26 Atari ST: not present */
+		Sound(568, 138,  28, 0, 4), /* k27_soundMOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL 27 Atari ST: not present */
+		Sound(569, 138, 106, 0, 4), /* k28_soundWAR_CRY 28 Atari ST: not present */
+		Sound(570, 138,  56, 0, 4), /* k29_soundATTACK_ROCK_ROCKPILE 29 Atari ST: not present */
+		Sound(571, 138,  58, 0, 4), /* k30_soundATTACK_WATER_ELEMENTAL 30 Atari ST: not present */
+		Sound(572, 112,  53, 0, 4), /* k31_soundATTACK_COUATL 31 Atari ST: not present */
+		Sound(573, 138,  29, 0, 4), /* k32_soundMOVE_RED_DRAGON 32 Atari ST: not present */
+		Sound(574, 150,  22, 0, 4)  /* k33_soundMOVE_SKELETON 33 Atari ST: not present */
+	};
+	for (int i = 0; i < k34_D13_soundCount; i++)
+		g60_sounds[i] = sounds[i];
+}
+
+SoundMan::SoundMan(DMEngine* vm) : _vm(vm) {
+	initConstants();
+}
 
 SoundMan::~SoundMan() {
 	for (uint16 i = 0; i < k34_D13_soundCount; ++i)
 		delete[] _gK24_soundData[i]._firstSample;
 }
 
-
-Sound g60_sounds[k34_D13_soundCount] = {
-Sound(533, 112,  11, 3, 6), /* k00_soundMETALLIC_THUD 0 */
-Sound(534, 112,  15, 0, 3), /* k01_soundSWITCH 1 */
-Sound(535, 112,  72, 3, 6), /* k02_soundDOOR_RATTLE 2 */
-Sound(550, 112,  60, 3, 5), /* k03_soundATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON 3 */
-Sound(536, 112,  10, 3, 6), /* k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM 4 */
-Sound(537, 112,  99, 3, 7), /* k05_soundSTRONG_EXPLOSION 5 */
-Sound(539, 112, 110, 3, 6), /* k06_soundSCREAM 6 */
-Sound(551, 112,  55, 3, 5), /* k07_soundATTACK_MUMMY_GHOST_RIVE 7 */
-Sound(540, 112,   2, 3, 6), /* k08_soundSWALLOW 8 */
-Sound(541, 112,  80, 3, 6), /* k09_soundCHAMPION_0_DAMAGED 9 */
-Sound(542, 112,  82, 3, 6), /* k10_soundCHAMPION_1_DAMAGED 10 */
-Sound(543, 112,  84, 3, 6), /* k11_soundCHAMPION_2_DAMAGED 11 */
-Sound(544, 112,  86, 3, 6), /* k12_soundCHAMPION_3_DAMAGED 12 */
-Sound(545, 112,  95, 3, 6), /* k13_soundSPELL 13 */
-Sound(552, 112,  57, 3, 5), /* k14_soundATTACK_SCREAMER_OITU 14 */
-Sound(553, 112,  52, 3, 5), /* k15_soundATTACK_GIANT_SCORPION_SCORPION 15 */
-Sound(546, 112,  40, 2, 4), /* k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT 16 */
-Sound(547, 112,  70, 1, 4), /* k17_soundBUZZ 17 */
-Sound(549, 138,  75, 3, 6), /* k18_soundPARTY_DAMAGED 18 */
-Sound(554, 112,  50, 3, 5), /* k19_soundATTACK_MAGENTA_WORM_WORM 19 */
-Sound(537, 112,  98, 0, 4), /* k20_soundWEAK_EXPLOSION 20 */
-Sound(555, 112,  96, 2, 4), /* k21_soundATTACK_GIGGLER 21 */
-Sound(563, 138,  24, 0, 4), /* k22_soundMOVE_ANIMATED_ARMOUR_DETH_KNIGHT 22 Atari ST: not present */
-Sound(564, 138,  21, 0, 4), /* k23_soundMOVE_COUATL_GIANT_WASP_MUNCHER 23 Atari ST: not present */
-Sound(565, 138,  23, 0, 4), /* k24_soundMOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON 24 Atari ST: not present */
-Sound(566, 138, 105, 0, 4), /* k25_soundBLOW_HORN 25 Atari ST: not present */
-Sound(567, 138,  27, 0, 4), /* k26_soundMOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU 26 Atari ST: not present */
-Sound(568, 138,  28, 0, 4), /* k27_soundMOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL 27 Atari ST: not present */
-Sound(569, 138, 106, 0, 4), /* k28_soundWAR_CRY 28 Atari ST: not present */
-Sound(570, 138,  56, 0, 4), /* k29_soundATTACK_ROCK_ROCKPILE 29 Atari ST: not present */
-Sound(571, 138,  58, 0, 4), /* k30_soundATTACK_WATER_ELEMENTAL 30 Atari ST: not present */
-Sound(572, 112,  53, 0, 4), /* k31_soundATTACK_COUATL 31 Atari ST: not present */
-Sound(573, 138,  29, 0, 4), /* k32_soundMOVE_RED_DRAGON 32 Atari ST: not present */
-Sound(574, 150,  22, 0, 4)}; /* k33_soundMOVE_SKELETON 33 Atari ST: not present */
-
 void SoundMan::f503_loadSounds() {
 	for (uint16 soundIndex = 0; soundIndex < k34_D13_soundCount; ++soundIndex) {
 		SoundData *soundData = _gK24_soundData + soundIndex;
diff --git a/engines/dm/sounds.h b/engines/dm/sounds.h
index adbc019..3c8c6cd 100644
--- a/engines/dm/sounds.h
+++ b/engines/dm/sounds.h
@@ -48,6 +48,7 @@ public:
 	byte _softDistance;
 	Sound(int16 index, byte period, byte priority, byte loudDist, byte softDist) :
 		_graphicIndex(index), _period(period), _priority(priority), _loudDistance(loudDist), _softDistance(softDist) {}
+	Sound() : _graphicIndex(0), _period(0), _priority(0), _loudDistance(0), _softDistance(0) {}
 }; // @ Sound
 
 class PendingSound {
@@ -78,6 +79,9 @@ public:
 	virtual void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol); // @ F0060_SOUND_Play
 	void f65_playPendingSound(); // @ F0065_SOUND_PlayPendingSound_CPSD
 	bool f505_soundGetVolume(int16 mapX, int16 mapY, uint8 *leftVolume, uint8 *rightVolume); // @ F0505_SOUND_GetVolume
+
+	Sound g60_sounds[k34_D13_soundCount];
+	void initConstants();
 };
 
 class SoundMan_Atari: public SoundMan {
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 8e9b1a1..1fe6a49 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -218,11 +218,13 @@ void TextMan::f443_endgamePrintString(int16 x, int16 y, Color textColor, char* t
 	char L1408_ac_ModifiedString[50];
 
 	L1407_pc_Character = L1408_ac_ModifiedString;
-	while (*L1407_pc_Character = *text++) {
+	*L1407_pc_Character = *text++;
+	while (*L1407_pc_Character) {
 		if ((*L1407_pc_Character >= 'A') && (*L1407_pc_Character <= 'Z')) {
 			*L1407_pc_Character -= 64; /* Use the same font as the one used for scrolls */
 		}
 		L1407_pc_Character++;
+		*L1407_pc_Character = *text++;
 	}
 	f53_printToLogicalScreen(x, y, textColor, k12_ColorDarkestGray, L1408_ac_ModifiedString);
 }
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index e23e878..4ada95f 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -1013,9 +1013,12 @@ void Timeline::f257_timelineProcessEvent70_light(TimelineEvent* event) {
 	if ((AL0674_i_LightPower = event->_B._lightPower) == 0) {
 		return;
 	}
-	if (L0675_B_NegativeLightPower = (AL0674_i_LightPower < 0)) {
+
+	L0675_B_NegativeLightPower = (AL0674_i_LightPower < 0);
+	if (L0675_B_NegativeLightPower) {
 		AL0674_i_LightPower = -AL0674_i_LightPower;
 	}
+
 	L0673_i_WeakerLightPower = AL0674_i_LightPower - 1;
 	AL0674_i_LightAmount = _vm->_championMan->_lightPowerToLightAmount[AL0674_i_LightPower] - _vm->_championMan->_lightPowerToLightAmount[L0673_i_WeakerLightPower];
 	if (L0675_B_NegativeLightPower) {


Commit: 857d4e72ed28c762bb63a47408743885c6c5d934
    https://github.com/scummvm/scummvm/commit/857d4e72ed28c762bb63a47408743885c6c5d934
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Renaming of Champion and ChampionMan functions

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/console.cpp
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/objectman.cpp
    engines/dm/projexpl.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 0a33c74..3ef072f 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -41,6 +41,40 @@
 
 namespace DM {
 
+void Champion::resetToZero() {
+	for (int16 i = 0; i < 30; ++i)
+		_slots[i] = Thing::_none;
+	for (int16 i = 0; i < 20; ++i)
+		_skills[i].resetToZero();
+	_attributes = _wounds = 0;
+	memset(_statistics, 0, 7 * 3);
+	memset(_name, '\0', 8);
+	memset(_title, '\0', 20);
+	_dir = kDirNorth;
+	_cell = k0_ViewCellFronLeft;
+	_actionIndex = k0_ChampionActionN;
+	_symbolStep = 0;
+	memset(_symbols, '\0', 5);
+	_directionMaximumDamageReceived = _maximumDamageReceived = _poisonEventCount = _enableActionEventIndex = 0;
+	_hideDamageReceivedIndex = _currHealth = _maxHealth = _currStamina = _maxStamina = _currMana = _maxMana = 0;
+	_actionDefense = _food = _water = _load = _shieldDefense = 0;
+	memset(_portrait, 0, 464);
+}
+
+void Champion::setWoundsFlag(ChampionWound flag, bool value) {
+	if (value)
+		_wounds |= flag;
+	else
+		_wounds &= ~flag;
+}
+
+void Champion::setAttributeFlag(ChampionAttribute flag, bool value) {
+	if (value)
+		_attributes |= flag;
+	else
+		_attributes &= ~flag;
+}
+
 void ChampionMan::initConstants() {
 	static const char *g417_baseSkillName_EN_ANY[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"};
 	static const char *g417_baseSkillName_DE_DEU[4] = {"KAEMPFER", "NINJA", "PRIESTER", "MAGIER"};
@@ -128,64 +162,64 @@ void ChampionMan::initConstants() {
 
 ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
 	for (uint16 i = 0; i < 4; ++i) {
-		_g409_championPendingDamage[i] = 0;
-		_g410_championPendingWounds[i] = 0;
-		_gK71_champions[i].resetToZero();
-	}
-	_g305_partyChampionCount = 0;
-	_g303_partyDead = false;
-	_g414_leaderHandObject = Thing(0);
-	_g411_leaderIndex = kM1_ChampionNone;
-	_g299_candidateChampionOrdinal = 0;
-	_g300_partyIsSleeping = false;
-	_g506_actingChampionOrdinal = 0;
-	_g413_leaderHandObjectIconIndex = (IconIndice)0;
-	_g415_leaderEmptyHanded = false;
-	_g407_party.resetToZero();
-	_g514_magicCasterChampionIndex = kM1_ChampionNone;
-	_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
+		_championPendingDamage[i] = 0;
+		_championPendingWounds[i] = 0;
+		_champions[i].resetToZero();
+	}
+	_partyChampionCount = 0;
+	_partyDead = false;
+	_leaderHandObject = Thing(0);
+	_leaderIndex = kM1_ChampionNone;
+	_candidateChampionOrdinal = 0;
+	_partyIsSleeping = false;
+	_actingChampionOrdinal = 0;
+	_leaderHandObjectIconIndex = (IconIndice)0;
+	_leaderEmptyHanded = false;
+	_party.resetToZero();
+	_magicCasterChampionIndex = kM1_ChampionNone;
+	_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
 
 	initConstants();
 }
 
-bool ChampionMan::f329_isLeaderHandObjectThrown(int16 side) {
-	if (_g411_leaderIndex == kM1_ChampionNone)
+bool ChampionMan::isLeaderHandObjectThrown(int16 side) {
+	if (_leaderIndex == kM1_ChampionNone)
 		return false;
 
-	return f328_isObjectThrown(_g411_leaderIndex, kM1_ChampionSlotLeaderHand, side);
+	return isObjectThrown(_leaderIndex, kM1_ChampionSlotLeaderHand, side);
 }
 
-bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side) {
+bool ChampionMan::isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side) {
 	bool throwingLeaderHandObjectFl = false;
 	Thing curThing;
 	Champion *curChampion = nullptr;
 	Thing actionHandThing;
 
 	if (slotIndex < 0) { /* Throw object in leader hand, which is temporarily placed in action hand */
-		if (_g415_leaderEmptyHanded)
+		if (_leaderEmptyHanded)
 			return false;
 
-		curThing = f298_getObjectRemovedFromLeaderHand();
-		curChampion = &_gK71_champions[champIndex];
+		curThing = getObjectRemovedFromLeaderHand();
+		curChampion = &_champions[champIndex];
 		actionHandThing = curChampion->getSlot(k1_ChampionSlotActionHand);
 		curChampion->setSlot(k1_ChampionSlotActionHand, curThing);
 		slotIndex = k1_ChampionSlotActionHand;
 		throwingLeaderHandObjectFl = true;
 	}
 
-	int16 kineticEnergy = f312_getStrength(champIndex, slotIndex);
+	int16 kineticEnergy = getStrength(champIndex, slotIndex);
 	if (throwingLeaderHandObjectFl) {
 		// In this case, curChampion and actionHandThing are set.
 		curChampion->setSlot((ChampionSlot)slotIndex, actionHandThing);
 	} else {
-		curThing = f300_getObjectRemovedFromSlot(champIndex, slotIndex);
+		curThing = getObjectRemovedFromSlot(champIndex, slotIndex);
 		if (curThing == Thing::_none)
 			return false;
 	}
 
 	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
-	f325_decrementStamina(champIndex, f305_getThrowingStaminaCost(curThing));
-	f330_disableAction(champIndex, 4);
+	decrementStamina(champIndex, getThrowingStaminaCost(curThing));
+	disableAction(champIndex, 4);
 	int16 experience = 8;
 	int16 weaponKineticEnergy = 1;
 	if (curThing.getType() == k5_WeaponThingType) {
@@ -196,9 +230,9 @@ bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16
 			experience += weaponKineticEnergy >> 2;
 		}
 	}
-	f304_addSkillExperience(champIndex, k10_ChampionSkillThrow, experience);
+	addSkillExperience(champIndex, k10_ChampionSkillThrow, experience);
 	kineticEnergy += weaponKineticEnergy;
-	int16 skillLevel = f303_getSkillLevel((ChampionIndex)champIndex, k10_ChampionSkillThrow);
+	int16 skillLevel = getSkillLevel((ChampionIndex)champIndex, k10_ChampionSkillThrow);
 	kineticEnergy += _vm->getRandomNumber(16) + (kineticEnergy >> 1) + skillLevel;
 	int16 attack = f26_getBoundedValue((uint16)40, (uint16)((skillLevel << 3) + _vm->getRandomNumber(32)), (uint16)200);
 	int16 stepEnergy = MAX(5, 11 - skillLevel);
@@ -207,19 +241,19 @@ bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16
 										  _vm->_dungeonMan->_g308_partyDir, kineticEnergy, attack, stepEnergy);
 	_vm->_g311_projectileDisableMovementTicks = 4;
 	_vm->_g312_lastProjectileDisabledMovementDirection = _vm->_dungeonMan->_g308_partyDir;
-	f292_drawChampionState((ChampionIndex)champIndex);
+	drawChampionState((ChampionIndex)champIndex);
 	return true;
 }
 
-uint16 ChampionMan::M27_getChampionPortraitX(uint16 index) {
+uint16 ChampionMan::getChampionPortraitX(uint16 index) {
 	return ((index) & 0x7) << 5;
 }
 
-uint16 ChampionMan::M28_getChampionPortraitY(uint16 index) {
+uint16 ChampionMan::getChampionPortraitY(uint16 index) {
 	return ((index) >> 3) * 29;
 }
 
-int16 ChampionMan::f279_getDecodedValue(char *string, uint16 characterCount) {
+int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) {
 	int val = 0;
 	for (uint16 i = 0; i < characterCount; ++i) {
 		val = (val << 4) + (string[i] - 'A');
@@ -227,20 +261,20 @@ int16 ChampionMan::f279_getDecodedValue(char *string, uint16 characterCount) {
 	return val;
 }
 
-void ChampionMan::f289_drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) {
-	Common::String tmp = f288_getStringFromInteger(currVal, true, 3);
+void ChampionMan::drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) {
+	Common::String tmp = getStringFromInteger(currVal, true, 3);
 	_vm->_textMan->f52_printToViewport(55, posY, k13_ColorLightestGray, tmp.c_str());
 	_vm->_textMan->f52_printToViewport(73, posY, k13_ColorLightestGray, "/");
-	tmp = f288_getStringFromInteger(maxVal, true, 3);
+	tmp = getStringFromInteger(maxVal, true, 3);
 	_vm->_textMan->f52_printToViewport(79, posY, k13_ColorLightestGray, tmp.c_str());
 }
 
-uint16 ChampionMan::M70_handSlotIndex(uint16 slotBoxIndex) {
+uint16 ChampionMan::getHandSlotIndex(uint16 slotBoxIndex) {
 	return slotBoxIndex & 0x1;
 }
 
 
-Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) {
+Common::String ChampionMan::getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) {
 	Common::String valToStr = Common::String::format("%d", val);
 	Common::String result;
 
@@ -252,7 +286,7 @@ Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding,
 	return result += valToStr;
 }
 
-void ChampionMan::f299_applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing) {
+void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing) {
 	int16 statIndex = k0_ChampionStatLuck;
 	int16 modifier = 0;
 	ThingType thingType = thing.getType();
@@ -397,7 +431,7 @@ void ChampionMan::f299_applyModifiersToStatistics(Champion *champ, int16 slotInd
 	}
 }
 
-bool ChampionMan::f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) {
+bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) {
 	ObjectMan &objMan = *_vm->_objectMan;
 
 	IconIndice currIconIndex = objMan.f39_getIconIndexInSlotBox(slotBoxIndex);
@@ -406,8 +440,8 @@ bool ChampionMan::f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing t
 		|| (currIconIndex == k195_IconIndicePotionEmptyFlask)) {
 		IconIndice newIconIndex = objMan.f33_getIconIndex(thing);
 		if (newIconIndex != currIconIndex) {
-			if ((slotBoxIndex < k8_SlotBoxInventoryFirstSlot) && !_g420_mousePointerHiddenToDrawChangedObjIconOnScreen) {
-				_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
+			if ((slotBoxIndex < k8_SlotBoxInventoryFirstSlot) && !_mousePointerHiddenToDrawChangedObjIconOnScreen) {
+				_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
 				_vm->_eventMan->f77_hideMouse();
 			}
 			objMan.f38_drawIconInSlotBox(slotBoxIndex, newIconIndex);
@@ -418,51 +452,51 @@ bool ChampionMan::f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing t
 	return false;
 }
 
-void ChampionMan::f296_drawChangedObjectIcons() {
+void ChampionMan::drawChangedObjectIcons() {
 	InventoryMan &invMan = *_vm->_inventoryMan;
 	ObjectMan &objMan = *_vm->_objectMan;
 	MenuMan &menuMan = *_vm->_menuMan;
 
 	uint16 invChampOrdinal = invMan._g432_inventoryChampionOrdinal;
-	if (_g299_candidateChampionOrdinal && !invChampOrdinal)
+	if (_candidateChampionOrdinal && !invChampOrdinal)
 		return;
 
-	_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
-	IconIndice leaderHandObjIconIndex = _g413_leaderHandObjectIconIndex;
+	_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
+	IconIndice leaderHandObjIconIndex = _leaderHandObjectIconIndex;
 
 	if (((leaderHandObjIconIndex < k32_IconIndiceWeaponDagger) && (leaderHandObjIconIndex >= k0_IconIndiceJunkCompassNorth))	// < instead of <= is correct
 		|| ((leaderHandObjIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= k163_IconIndicePotionWaterFlask))
 		|| (leaderHandObjIconIndex == k195_IconIndicePotionEmptyFlask)) {
-		IconIndice iconIndex = objMan.f33_getIconIndex(_g414_leaderHandObject);
+		IconIndice iconIndex = objMan.f33_getIconIndex(_leaderHandObject);
 		if (iconIndex != leaderHandObjIconIndex) {
-			_g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
+			_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
 			_vm->_eventMan->f77_hideMouse();
 			objMan.f36_extractIconFromBitmap(iconIndex, objMan._g412_objectIconForMousePointer);
 			_vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
-			_g413_leaderHandObjectIconIndex = iconIndex;
-			objMan.f34_drawLeaderObjectName(_g414_leaderHandObject);
+			_leaderHandObjectIconIndex = iconIndex;
+			objMan.f34_drawLeaderObjectName(_leaderHandObject);
 		}
 	}
 
-	for (uint16 slotBoxIndex = 0; slotBoxIndex < (_g305_partyChampionCount * 2); ++slotBoxIndex) {
+	for (uint16 slotBoxIndex = 0; slotBoxIndex < (_partyChampionCount * 2); ++slotBoxIndex) {
 		int16 champIndex = slotBoxIndex >> 1;
 		if (invChampOrdinal == _vm->M0_indexToOrdinal(champIndex))
 			continue;
 
-		if (f295_hasObjectIconInSlotBoxChanged(slotBoxIndex, _gK71_champions[champIndex].getSlot((ChampionSlot)M70_handSlotIndex(slotBoxIndex)))
-			&& (M70_handSlotIndex(slotBoxIndex) == k1_ChampionSlotActionHand)) {
+		if (hasObjectIconInSlotBoxChanged(slotBoxIndex, _champions[champIndex].getSlot((ChampionSlot)getHandSlotIndex(slotBoxIndex)))
+			&& (getHandSlotIndex(slotBoxIndex) == k1_ChampionSlotActionHand)) {
 
 			menuMan.f386_drawActionIcon((ChampionIndex)champIndex);
 		}
 	}
 
 	if (invChampOrdinal) {
-		Champion *champ = &_gK71_champions[_vm->M1_ordinalToIndex(invChampOrdinal)];
+		Champion *champ = &_champions[_vm->M1_ordinalToIndex(invChampOrdinal)];
 		Thing *thing = &champ->getSlot(k0_ChampionSlotReadyHand);
 		uint16 drawViewport = 0;
 
 		for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++, thing++) {
-			uint16 objIconChanged = f295_hasObjectIconInSlotBoxChanged(slotIndex + k8_SlotBoxInventoryFirstSlot, *thing) ? 1 : 0;
+			uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + k8_SlotBoxInventoryFirstSlot, *thing) ? 1 : 0;
 			drawViewport |= objIconChanged;
 			if (objIconChanged && (slotIndex == k1_ChampionSlotActionHand)) {
 				menuMan.f386_drawActionIcon((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal));
@@ -472,21 +506,21 @@ void ChampionMan::f296_drawChangedObjectIcons() {
 		if (invMan._g424_panelContent == k4_PanelContentChest) {
 			thing = invMan._g425_chestSlots;
 			for (int16 slotIndex = 0; slotIndex < 8; ++slotIndex, thing++) {
-				drawViewport |= (f295_hasObjectIconInSlotBoxChanged(slotIndex + k38_SlotBoxChestFirstSlot, *thing) ? 1 : 0);
+				drawViewport |= (hasObjectIconInSlotBoxChanged(slotIndex + k38_SlotBoxChestFirstSlot, *thing) ? 1 : 0);
 			}
 		}
 
 		if (drawViewport) {
 			champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
-			f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal));
+			drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal));
 		}
 	}
 
-	if (_g420_mousePointerHiddenToDrawChangedObjIconOnScreen)
+	if (_mousePointerHiddenToDrawChangedObjIconOnScreen)
 		_vm->_eventMan->f78_showMouse();
 }
 
-void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex) {
+void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex) {
 	InventoryMan &invMan = *_vm->_inventoryMan;
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 	ObjectMan &objMan = *_vm->_objectMan;
@@ -495,7 +529,7 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 	if (thing == Thing::_none)
 		return;
 
-	Champion *champ = &_gK71_champions[champIndex];
+	Champion *champ = &_champions[champIndex];
 
 	if (slotIndex >= k30_ChampionSlotChest_1) {
 		invMan._g425_chestSlots[slotIndex - k30_ChampionSlotChest_1] = thing;
@@ -507,25 +541,25 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 	champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
 	IconIndice iconIndex = objMan.f33_getIconIndex(thing);
 	bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal);
-	f299_applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
+	applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
 	uint16 *rawObjPtr = dunMan.f156_getThingData(thing);
 
 	if (slotIndex < k2_ChampionSlotHead) {
 		if (slotIndex == k1_ChampionSlotActionHand) {
 			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
-			if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))
+			if (_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))
 				menuMan.f388_clearActingChampion();
 
 			if ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)) {
 				((Scroll *)rawObjPtr)->setClosed(false);
-				f296_drawChangedObjectIcons();
+				drawChangedObjectIcons();
 			}
 		}
 
 		if (iconIndex == k4_IconIndiceWeaponTorchUnlit) {
 			((Weapon *)rawObjPtr)->setLit(true);
 			_vm->_inventoryMan->f337_setDungeonViewPalette();
-			f296_drawChangedObjectIcons();
+			drawChangedObjectIcons();
 		} else if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand) &&
 			((iconIndex == k144_IconIndiceContainerChestClosed) || ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)))) {
 			champ->setAttributeFlag(k0x0800_ChampionAttributePanel, true);
@@ -533,7 +567,7 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 	} else if (slotIndex == k10_ChampionSlotNeck) {
 		if ((iconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (iconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
 			((Junk *)rawObjPtr)->setChargeCount(1);
-			_g407_party._magicalLightAmount += _lightPowerToLightAmount[2];
+			_party._magicalLightAmount += _lightPowerToLightAmount[2];
 			_vm->_inventoryMan->f337_setDungeonViewPalette();
 			iconIndex = (IconIndice)(iconIndex + 1);
 		} else if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
@@ -542,13 +576,13 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch
 		}
 	}
 
-	f291_drawSlot(champIndex, slotIndex);
+	drawSlot(champIndex, slotIndex);
 	if (isInventoryChampion)
 		champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
 }
 
-int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) {
-	int16 scentIndex = _g407_party._scentCount;
+int16 ChampionMan::getScentOrdinal(int16 mapX, int16 mapY) {
+	int16 scentIndex = _party._scentCount;
 
 	if (scentIndex) {
 		Scent searchedScent;
@@ -556,7 +590,7 @@ int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) {
 		searchedScent.setMapY(mapY);
 		searchedScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex);
 		uint16 searchedScentRedEagle = searchedScent.toUint16();
-		Scent *scent = &_g407_party._scents[scentIndex--];
+		Scent *scent = &_party._scents[scentIndex--];
 		do {
 			if ((*(--scent)).toUint16() == searchedScentRedEagle) {
 				return _vm->M0_indexToOrdinal(scentIndex);
@@ -566,32 +600,32 @@ int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) {
 	return 0;
 }
 
-Thing ChampionMan::f298_getObjectRemovedFromLeaderHand() {
-	_g415_leaderEmptyHanded = true;
-	Thing leaderHandObject = _g414_leaderHandObject;
+Thing ChampionMan::getObjectRemovedFromLeaderHand() {
+	_leaderEmptyHanded = true;
+	Thing leaderHandObject = _leaderHandObject;
 
 	if (leaderHandObject != Thing::_none) {
-		_g414_leaderHandObject = Thing::_none;
-		_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
+		_leaderHandObject = Thing::_none;
+		_leaderHandObjectIconIndex = kM1_IconIndiceNone;
 		_vm->_eventMan->f78_showMouse();
 		_vm->_objectMan->f35_clearLeaderObjectName();
 		_vm->_eventMan->f69_setMousePointer();
 		_vm->_eventMan->f77_hideMouse();
-		if (_g411_leaderIndex != kM1_ChampionNone) {
-			_gK71_champions[_g411_leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(leaderHandObject);
-			setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
-			f292_drawChampionState(_g411_leaderIndex);
+		if (_leaderIndex != kM1_ChampionNone) {
+			_champions[_leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(leaderHandObject);
+			setFlag(_champions[_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
+			drawChampionState(_leaderIndex);
 		}
 	}
 	return leaderHandObject;
 }
 
-uint16 ChampionMan::f312_getStrength(int16 champIndex, int16 slotIndex) {
-	Champion *curChampion = &_gK71_champions[champIndex];
+uint16 ChampionMan::getStrength(int16 champIndex, int16 slotIndex) {
+	Champion *curChampion = &_champions[champIndex];
 	int16 strength = _vm->getRandomNumber(16) + curChampion->_statistics[k1_ChampionStatStrength][k1_ChampionStatCurrent];
 	Thing curThing = curChampion->_slots[slotIndex];
 	uint16 objectWeight = _vm->_dungeonMan->f140_getObjectWeight(curThing);
-	uint16 oneSixteenthMaximumLoad = f309_getMaximumLoad(curChampion) >> 4;
+	uint16 oneSixteenthMaximumLoad = getMaximumLoad(curChampion) >> 4;
 
 	if (objectWeight <= oneSixteenthMaximumLoad) {
 		strength += objectWeight - 12;
@@ -609,25 +643,25 @@ uint16 ChampionMan::f312_getStrength(int16 champIndex, int16 slotIndex) {
 		uint16 skillLevel = 0;
 		uint16 weaponClass = weaponInfo->_class;
 		if ((weaponClass == k0_WeaponClassSwingWeapon) || (weaponClass == k2_WeaponClassDaggerAndAxes)) {
-			skillLevel = f303_getSkillLevel(champIndex, k4_ChampionSkillSwing);
+			skillLevel = getSkillLevel(champIndex, k4_ChampionSkillSwing);
 		}
 		if ((weaponClass != k0_WeaponClassSwingWeapon) && (weaponClass < k16_WeaponClassFirstBow)) {
-			skillLevel += f303_getSkillLevel(champIndex, k10_ChampionSkillThrow);
+			skillLevel += getSkillLevel(champIndex, k10_ChampionSkillThrow);
 		}
 		if ((weaponClass >= k16_WeaponClassFirstBow) && (weaponClass < k112_WeaponClassFirstMagicWeapon)) {
-			skillLevel += f303_getSkillLevel(champIndex, k11_ChampionSkillShoot);
+			skillLevel += getSkillLevel(champIndex, k11_ChampionSkillShoot);
 		}
 		strength += skillLevel << 1;
 	}
-	strength = f306_getStaminaAdjustedValue(curChampion, strength);
+	strength = getStaminaAdjustedValue(curChampion, strength);
 	if (getFlag(curChampion->_wounds, (slotIndex == k0_ChampionSlotReadyHand) ? k0x0001_ChampionWoundReadHand : k0x0002_ChampionWoundActionHand)) {
 		strength >>= 1;
 	}
 	return f26_getBoundedValue(0, strength >> 1, 100);
 }
 
-Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) {
-	Champion *curChampion = &_gK71_champions[champIndex];
+Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) {
+	Champion *curChampion = &_champions[champIndex];
 	Thing curThing;
 
 	if (slotIndex >= k30_ChampionSlotChest_1) {
@@ -644,39 +678,39 @@ Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotI
 	bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
 	int16 curIconIndex = _vm->_objectMan->f33_getIconIndex(curThing);
 	// Remove object modifiers
-	f299_applyModifiersToStatistics(curChampion, slotIndex, curIconIndex, -1, curThing);
+	applyModifiersToStatistics(curChampion, slotIndex, curIconIndex, -1, curThing);
 
 	Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(curThing);
 	if (slotIndex == k10_ChampionSlotNeck) {
 		if ((curIconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (curIconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
 			((Junk *)curWeapon)->setChargeCount(0);
-			_g407_party._magicalLightAmount -= _lightPowerToLightAmount[2];
+			_party._magicalLightAmount -= _lightPowerToLightAmount[2];
 			_vm->_inventoryMan->f337_setDungeonViewPalette();
 		} else if ((curIconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (curIconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
 			((Junk *)curWeapon)->setChargeCount(0);
 		}
 	}
 
-	f291_drawSlot(champIndex, slotIndex);
+	drawSlot(champIndex, slotIndex);
 	if (isInventoryChampion)
 		setFlag(curChampion->_attributes, k0x4000_ChampionAttributeViewport);
 
 	if (slotIndex < k2_ChampionSlotHead) {
 		if (slotIndex == k1_ChampionSlotActionHand) {
 			setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand);
-			if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))
+			if (_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))
 				_vm->_menuMan->f388_clearActingChampion();
 
 			if ((curIconIndex >= k30_IconIndiceScrollOpen) && (curIconIndex <= k31_IconIndiceScrollClosed)) {
 				((Scroll *)curWeapon)->setClosed(true);
-				f296_drawChangedObjectIcons();
+				drawChangedObjectIcons();
 			}
 		}
 
 		if ((curIconIndex >= k4_IconIndiceWeaponTorchUnlit) && (curIconIndex <= k7_IconIndiceWeaponTorchLit)) {
 			curWeapon->setLit(false);
 			_vm->_inventoryMan->f337_setDungeonViewPalette();
-			f296_drawChangedObjectIcons();
+			drawChangedObjectIcons();
 		}
 
 		if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand)) {
@@ -698,17 +732,17 @@ Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotI
 	return curThing;
 }
 
-void ChampionMan::f325_decrementStamina(int16 championIndex, int16 decrement) {
+void ChampionMan::decrementStamina(int16 championIndex, int16 decrement) {
 	if (championIndex == kM1_ChampionNone)
 		return;
 
-	Champion *curChampion = &_gK71_champions[championIndex];
+	Champion *curChampion = &_champions[championIndex];
 	curChampion->_currStamina -= decrement;
 
 	int16 stamina = curChampion->_currStamina;
 	if (stamina <= 0) {
 		curChampion->_currStamina = 0;
-		f321_addPendingDamageAndWounds_getDamage(championIndex, (-stamina) >> 1, k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
+		addPendingDamageAndWounds_getDamage(championIndex, (-stamina) >> 1, k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
 	} else if (stamina > curChampion->_maxStamina) {
 		curChampion->_currStamina = curChampion->_maxStamina;
 	}
@@ -716,11 +750,11 @@ void ChampionMan::f325_decrementStamina(int16 championIndex, int16 decrement) {
 	setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics);
 }
 
-int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds, uint16 attackType) {
+int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds, uint16 attackType) {
 	if (attack <= 0)
 		return 0;
 
-	Champion *curChampion = &_gK71_champions[champIndex];
+	Champion *curChampion = &_champions[champIndex];
 	if (!curChampion->_currHealth)
 		return 0;
 
@@ -730,7 +764,7 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 		for (int16 woundIndex = k0_ChampionSlotReadyHand; woundIndex <= k5_ChampionSlotFeet; woundIndex++) {
 			if (allowedWounds & (1 << woundIndex)) {
 				woundCount++;
-				defense += f313_getWoundDefense(champIndex, woundIndex | ((attackType == k4_attackType_SHARP) ? k0x8000_maskUseSharpDefense : k0x0000_maskDoNotUseSharpDefense));
+				defense += getWoundDefense(champIndex, woundIndex | ((attackType == k4_attackType_SHARP) ? k0x8000_maskUseSharpDefense : k0x0000_maskDoNotUseSharpDefense));
 			}
 		}
 		if (woundCount)
@@ -751,13 +785,13 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 		}
 		break;
 		case k5_attackType_MAGIC:
-			attack = f307_getStatisticAdjustedAttack(curChampion, k5_ChampionStatAntimagic, attack);
-			attack -= _g407_party._spellShieldDefense;
+			attack = getStatisticAdjustedAttack(curChampion, k5_ChampionStatAntimagic, attack);
+			attack -= _party._spellShieldDefense;
 			skipScaling = true;
 			break;
 		case k1_attackType_FIRE:
-			attack = f307_getStatisticAdjustedAttack(curChampion, k6_ChampionStatAntifire, attack);
-			attack -= _g407_party._fireShieldDefense;
+			attack = getStatisticAdjustedAttack(curChampion, k6_ChampionStatAntifire, attack);
+			attack -= _party._fireShieldDefense;
 			break;
 		case k2_attackType_SELF:
 			defense >>= 1;
@@ -784,7 +818,7 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 		if (attack <= 0)
 			return 0;
 
-		int16 adjustedAttack = f307_getStatisticAdjustedAttack(curChampion, k4_ChampionStatVitality, _vm->getRandomNumber(128) + 10);
+		int16 adjustedAttack = getStatisticAdjustedAttack(curChampion, k4_ChampionStatVitality, _vm->getRandomNumber(128) + 10);
 		if (attack > adjustedAttack) {
 		/* BUG0_45
 			This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the
@@ -794,21 +828,21 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in
 			wounded (because of more iterations in the loop below)
 		*/
 			do {
-				setFlag(*(uint16 *)&_g410_championPendingWounds[champIndex], (1 << _vm->getRandomNumber(8)) & allowedWounds);
+				setFlag(*(uint16 *)&_championPendingWounds[champIndex], (1 << _vm->getRandomNumber(8)) & allowedWounds);
 			} while ((attack > (adjustedAttack <<= 1)) && adjustedAttack);
 		}
 
-		if (_g300_partyIsSleeping)
-			f314_wakeUp();
+		if (_partyIsSleeping)
+			wakeUp();
 	}
-	_g409_championPendingDamage[champIndex] += attack;
+	_championPendingDamage[champIndex] += attack;
 	return attack;
 }
 
-int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
+int16 ChampionMan::getWoundDefense(int16 champIndex, uint16 woundIndex) {
 	static const byte woundDefenseFactor[6] = {5, 5, 4, 6, 3, 1}; // @ G0050_auc_Graphic562_WoundDefenseFactor
 
-	Champion *curChampion = &_gK71_champions[champIndex];
+	Champion *curChampion = &_champions[champIndex];
 	bool useSharpDefense = getFlag(woundIndex, k0x8000_maskUseSharpDefense);
 	if (useSharpDefense)
 		clearFlag(woundIndex, k0x8000_maskUseSharpDefense);
@@ -820,7 +854,7 @@ int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
 			ArmourInfo *armorInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(curThing);
 			armorInfo = &_vm->_dungeonMan->_armourInfo[((Armour *)armorInfo)->getType()];
 			if (getFlag(armorInfo->_attributes, k0x0080_ArmourAttributeIsAShield))
-				armorShieldDefense += ((f312_getStrength(champIndex, slotIndex) + _vm->_dungeonMan->f143_getArmourDefense(armorInfo, useSharpDefense)) * woundDefenseFactor[woundIndex]) >> ((slotIndex == woundIndex) ? 4 : 5);
+				armorShieldDefense += ((getStrength(champIndex, slotIndex) + _vm->_dungeonMan->f143_getArmourDefense(armorInfo, useSharpDefense)) * woundDefenseFactor[woundIndex]) >> ((slotIndex == woundIndex) ? 4 : 5);
 		}
 	}
 
@@ -828,7 +862,7 @@ int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
 	if (useSharpDefense)
 		woundDefense >>= 1;
 
-	woundDefense += curChampion->_actionDefense + curChampion->_shieldDefense + _g407_party._shieldDefense + armorShieldDefense;
+	woundDefense += curChampion->_actionDefense + curChampion->_shieldDefense + _party._shieldDefense + armorShieldDefense;
 	if (woundIndex > k1_ChampionSlotActionHand) {
 		Thing curThing = curChampion->_slots[woundIndex];
 		if (curThing.getType() == k6_ArmourThingType) {
@@ -840,13 +874,13 @@ int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) {
 	if (getFlag(curChampion->_wounds, 1 << woundIndex))
 		woundDefense -= 8 + _vm->getRandomNumber(4);
 
-	if (_g300_partyIsSleeping)
+	if (_partyIsSleeping)
 		woundDefense >>= 1;
 
 	return f26_getBoundedValue(0, woundDefense >> 1, 100);
 }
 
-uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion *champ, uint16 statIndex, uint16 attack) {
+uint16 ChampionMan::getStatisticAdjustedAttack(Champion *champ, uint16 statIndex, uint16 attack) {
 	int16 factor = 170 - champ->_statistics[statIndex][k1_ChampionStatCurrent];
 
 	/* BUG0_41
@@ -862,9 +896,9 @@ uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion *champ, uint16 stat
 	return _vm->f30_getScaledProduct(attack, 7, factor);
 }
 
-void ChampionMan::f314_wakeUp() {
+void ChampionMan::wakeUp() {
 	_vm->_g321_stopWaitingForPlayerInput = true;
-	_g300_partyIsSleeping = false;
+	_partyIsSleeping = false;
 	_vm->_g318_waitForInputMaxVerticalBlankCount = 10;
 	_vm->f22_delay(10);
 	_vm->_displayMan->f98_drawFloorAndCeiling();
@@ -876,7 +910,7 @@ void ChampionMan::f314_wakeUp() {
 	_vm->_menuMan->f457_drawEnabledMenus();
 }
 
-int16 ChampionMan::f305_getThrowingStaminaCost(Thing thing) {
+int16 ChampionMan::getThrowingStaminaCost(Thing thing) {
 	int16 weight = _vm->_dungeonMan->f140_getObjectWeight(thing) >> 1;
 	int16 staminaCost = f26_getBoundedValue<int16>(1, weight, 10);
 
@@ -886,8 +920,8 @@ int16 ChampionMan::f305_getThrowingStaminaCost(Thing thing) {
 	return staminaCost;
 }
 
-void ChampionMan::f330_disableAction(uint16 champIndex, uint16 ticks) {
-	Champion *curChampion = &_gK71_champions[champIndex];
+void ChampionMan::disableAction(uint16 champIndex, uint16 ticks) {
+	Champion *curChampion = &_champions[champIndex];
 	int32 updatedEnableActionEventTime = _vm->_g313_gameTime + ticks;
 
 	TimelineEvent curEvent;
@@ -906,13 +940,13 @@ void ChampionMan::f330_disableAction(uint16 champIndex, uint16 ticks) {
 		_vm->_timeline->f237_deleteEvent(eventIndex);
 	} else {
 		setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x0008_ChampionAttributeDisableAction);
-		f292_drawChampionState((ChampionIndex)champIndex);
+		drawChampionState((ChampionIndex)champIndex);
 	}
 	M33_setMapAndTime(curEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, updatedEnableActionEventTime);
 	curChampion->_enableActionEventIndex = _vm->_timeline->f238_addEventGetEventIndex(&curEvent);
 }
 
-void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp) {
+void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp) {
 	if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && (_vm->_projexpl->_g361_lastCreatureAttackTime < _vm->_g313_gameTime - 150))
 		exp >>= 1;
 
@@ -920,14 +954,14 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex,
 		if (_vm->_dungeonMan->_g269_currMap->_difficulty)
 			exp *= _vm->_dungeonMan->_g269_currMap->_difficulty;
 
-		Champion *curChampion = &_gK71_champions[champIndex];
+		Champion *curChampion = &_champions[champIndex];
 		uint16 baseSkillIndex;
 		if (skillIndex >= k4_ChampionSkillSwing)
 			baseSkillIndex = (skillIndex - k4_ChampionSkillSwing) >> 2;
 		else
 			baseSkillIndex = skillIndex;
 
-		uint16 skillLevelBefore = f303_getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
+		uint16 skillLevelBefore = getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
 
 		if ((skillIndex >= k4_ChampionSkillSwing) && (_vm->_projexpl->_g361_lastCreatureAttackTime > _vm->_g313_gameTime - 25))
 			exp <<= 1;
@@ -941,7 +975,7 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex,
 		if (skillIndex >= k4_ChampionSkillSwing)
 			curSkill->_experience += exp;
 
-		uint16 skillLevelAfter = f303_getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
+		uint16 skillLevelAfter = getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
 		if (skillLevelAfter > skillLevelBefore) {
 			int16 newBaseSkillLevel = skillLevelAfter;
 			int16 minorStatIncrease = _vm->getRandomNumber(2);
@@ -996,7 +1030,7 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex,
 				curChampion->_maxStamina = 9999;
 
 			setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
-			f292_drawChampionState((ChampionIndex)champIndex);
+			drawChampionState((ChampionIndex)champIndex);
 			_vm->_textMan->f51_messageAreaPrintLineFeed();
 			Color curChampionColor = _championColor[champIndex];
 			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, curChampion->_name);
@@ -1020,27 +1054,27 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex,
 	}
 }
 
-int16 ChampionMan::f324_damageAll_getDamagedChampionCount(uint16 attack, int16 wounds, int16 attackType) {
+int16 ChampionMan::getDamagedChampionCount(uint16 attack, int16 wounds, int16 attackType) {
 	int16 randomMax = (attack >> 3) + 1;
 	uint16 reducedAttack = attack - randomMax;
 	randomMax <<= 1;
 
 	int16 damagedChampionCount = 0;
-	for (int16 championIndex = k0_ChampionFirst; championIndex < _g305_partyChampionCount; championIndex++) {
+	for (int16 championIndex = k0_ChampionFirst; championIndex < _partyChampionCount; championIndex++) {
 		// Actual attack is attack +/- (attack / 8)
-		if (f321_addPendingDamageAndWounds_getDamage(championIndex, MAX(1, reducedAttack + _vm->getRandomNumber(randomMax)), wounds, attackType))
+		if (addPendingDamageAndWounds_getDamage(championIndex, MAX(1, reducedAttack + _vm->getRandomNumber(randomMax)), wounds, attackType))
 			damagedChampionCount++;
 	}
 
 	return damagedChampionCount;
 }
 
-int16 ChampionMan::f286_getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) {
-	if (_g305_partyChampionCount && (M38_distance(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)) {
+int16 ChampionMan::getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) {
+	if (_partyChampionCount && (M38_distance(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)) {
 		signed char orderedCellsToAttack[4];
 		_vm->_groupMan->f229_setOrderedCellsToAttack(orderedCellsToAttack, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, mapX, mapY, cell);
 		for (uint16 i = 0; i < 4; i++) {
-			int16 championIndex = f285_getIndexInCell(orderedCellsToAttack[i]);
+			int16 championIndex = getIndexInCell(orderedCellsToAttack[i]);
 			if (championIndex >= 0)
 				return championIndex;
 		}
@@ -1048,16 +1082,16 @@ int16 ChampionMan::f286_getTargetChampionIndex(int16 mapX, int16 mapY, uint16 ce
 	return kM1_ChampionNone;
 }
 
-int16 ChampionMan::f311_getDexterity(Champion* champ) {
+int16 ChampionMan::getDexterity(Champion* champ) {
 	int16 dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent];
-	dexterity -= ((int32)(dexterity >> 1) * (int32)champ->_load) / f309_getMaximumLoad(champ);
-	if (_g300_partyIsSleeping)
+	dexterity -= ((int32)(dexterity >> 1) * (int32)champ->_load) / getMaximumLoad(champ);
+	if (_partyIsSleeping)
 		dexterity >>= 1;
 
 	return f26_getBoundedValue(1 + _vm->getRandomNumber(8), dexterity >> 1, 100 - _vm->getRandomNumber(8));
 }
 
-bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) {
+bool ChampionMan::isLucky(Champion* champ, uint16 percentage) {
 	if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage))
 		return true;
 
@@ -1067,12 +1101,12 @@ bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) {
 	return isLucky;
 }
 
-void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) {
-	if ((champIndex == kM1_ChampionNone) || (_vm->M0_indexToOrdinal(champIndex) == _g299_candidateChampionOrdinal))
+void ChampionMan::championPoison(int16 champIndex, uint16 attack) {
+	if ((champIndex == kM1_ChampionNone) || (_vm->M0_indexToOrdinal(champIndex) == _candidateChampionOrdinal))
 		return;
 
-	Champion *curChampion = &_gK71_champions[champIndex];
-	f321_addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
+	Champion *curChampion = &_champions[champIndex];
+	addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
 	setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
 	if ((_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) && (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
 		setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel);
@@ -1088,10 +1122,10 @@ void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) {
 		_vm->_timeline->f238_addEventGetEventIndex(&newEvent);
 	}
 
-	f292_drawChampionState((ChampionIndex)champIndex);
+	drawChampionState((ChampionIndex)champIndex);
 }
 
-void ChampionMan::f284_setPartyDirection(int16 dir) {
+void ChampionMan::setPartyDirection(int16 dir) {
 	if (dir == _vm->_dungeonMan->_g308_partyDir)
 		return;
 
@@ -1099,36 +1133,36 @@ void ChampionMan::f284_setPartyDirection(int16 dir) {
 	if (L0834_i_Delta < 0)
 		L0834_i_Delta += 4;
 
-	Champion *curChampion = _gK71_champions;
-	for (int16 i = k0_ChampionFirst; i < _g305_partyChampionCount; i++) {
+	Champion *curChampion = _champions;
+	for (int16 i = k0_ChampionFirst; i < _partyChampionCount; i++) {
 		curChampion->_cell = (ViewCell)M21_normalizeModulo4(curChampion->_cell + L0834_i_Delta);
 		curChampion->_dir = (Direction)M21_normalizeModulo4(curChampion->_dir + L0834_i_Delta);
 		curChampion++;
 	}
 
 	_vm->_dungeonMan->_g308_partyDir = (Direction)dir;
-	f296_drawChangedObjectIcons();
+	drawChangedObjectIcons();
 }
 
-void ChampionMan::f316_deleteScent(uint16 scentIndex) {
-	uint16 count = --_g407_party._scentCount - scentIndex;
+void ChampionMan::deleteScent(uint16 scentIndex) {
+	uint16 count = --_party._scentCount - scentIndex;
 
 	if (count) {
 		for (uint16 i = 0; i < count; ++i) {
-			_g407_party._scents[scentIndex + i] = _g407_party._scents[scentIndex + i + 1];
-			_g407_party._scentStrengths[scentIndex + i] = _g407_party._scentStrengths[scentIndex + i + 1];
+			_party._scents[scentIndex + i] = _party._scents[scentIndex + i + 1];
+			_party._scentStrengths[scentIndex + i] = _party._scentStrengths[scentIndex + i + 1];
 		}
 	}
 
-	if (scentIndex < _g407_party._firstScentIndex)
-		_g407_party._firstScentIndex--;
+	if (scentIndex < _party._firstScentIndex)
+		_party._firstScentIndex--;
 
-	if (scentIndex < _g407_party._lastScentIndex)
-		_g407_party._lastScentIndex--;
+	if (scentIndex < _party._lastScentIndex)
+		_party._lastScentIndex--;
 }
 
-void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount) {
-	int16 scentIndex = _g407_party._scentCount;
+void ChampionMan::addScentStrength(int16 mapX, int16 mapY, int32 cycleCount) {
+	int16 scentIndex = _party._scentCount;
 	if (scentIndex) {
 		bool mergeFl = getFlag(cycleCount, k0x8000_mergeCycles);
 		if (mergeFl)
@@ -1139,30 +1173,30 @@ void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount
 		newScent.setMapY(mapY); /* BUG0_00 Useless code */
 		newScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */
 
-		Scent *curScent = _g407_party._scents; /* BUG0_00 Useless code */
+		Scent *curScent = _party._scents; /* BUG0_00 Useless code */
 		bool cycleCountDefined = false;
 		while (scentIndex--) {
 			if (&*curScent++ == &newScent) {
 				if (!cycleCountDefined) {
 					cycleCountDefined = true;
 					if (mergeFl) {
-						cycleCount = MAX<int32>(_g407_party._scentStrengths[scentIndex], cycleCount);
+						cycleCount = MAX<int32>(_party._scentStrengths[scentIndex], cycleCount);
 					} else {
-						cycleCount = MIN<int32>(80, _g407_party._scentStrengths[scentIndex] + cycleCount);
+						cycleCount = MIN<int32>(80, _party._scentStrengths[scentIndex] + cycleCount);
 					}
 				}
-				_g407_party._scentStrengths[scentIndex] = cycleCount;
+				_party._scentStrengths[scentIndex] = cycleCount;
 			}
 		}
 	}
 }
 
-void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) {
+void ChampionMan::putObjectInLeaderHand(Thing thing, bool setMousePointer) {
 	if (thing == Thing::_none)
 		return;
 
-	_g415_leaderEmptyHanded = false;
-	_vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
+	_leaderEmptyHanded = false;
+	_vm->_objectMan->f36_extractIconFromBitmap(_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
 	_vm->_eventMan->f78_showMouse();
 	_vm->_objectMan->f34_drawLeaderObjectName(thing);
 
@@ -1172,15 +1206,15 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer)
 		_vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
 
 	_vm->_eventMan->f77_hideMouse();
-	if (_g411_leaderIndex != kM1_ChampionNone) {
-		_gK71_champions[_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing);
-		setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
-		f292_drawChampionState(_g411_leaderIndex);
+	if (_leaderIndex != kM1_ChampionNone) {
+		_champions[_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing);
+		setFlag(_champions[_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
+		drawChampionState(_leaderIndex);
 	}
 }
 
-int16 ChampionMan::f310_getMovementTicks(Champion *champ) {
-	uint16 maximumLoad = f309_getMaximumLoad(champ);
+int16 ChampionMan::getMovementTicks(Champion *champ) {
+	uint16 maximumLoad = getMaximumLoad(champ);
 	uint16 curLoad = champ->_load;
 	uint16 woundTicks;
 	int16 ticks;
@@ -1210,8 +1244,8 @@ int16 ChampionMan::f310_getMovementTicks(Champion *champ) {
 	return ticks;
 }
 
-bool ChampionMan::f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex, uint16 ammunitionSlotIndex) {
-	Champion *curChampion = &_gK71_champions[champIndex];
+bool ChampionMan::isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex, uint16 ammunitionSlotIndex) {
+	Champion *curChampion = &_champions[champIndex];
 	Thing curThing = curChampion->_slots[weaponSlotIndex];
 	if (curThing.getType() != k5_WeaponThingType)
 		return false;
@@ -1232,16 +1266,16 @@ bool ChampionMan::f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint1
 	return ((curThing.getType() == k5_WeaponThingType) && (weaponInfo->_class == weaponClass));
 }
 
-void ChampionMan::f293_drawAllChampionStates() {
-	for (int16 i = k0_ChampionFirst; i < _g305_partyChampionCount; i++)
-		f292_drawChampionState((ChampionIndex)i);
+void ChampionMan::drawAllChampionStates() {
+	for (int16 i = k0_ChampionFirst; i < _partyChampionCount; i++)
+		drawChampionState((ChampionIndex)i);
 }
 
-void ChampionMan::f283_viAltarRebirth(uint16 champIndex) {
-	Champion *curChampion = &_gK71_champions[champIndex];
-	if (f285_getIndexInCell(curChampion->_cell) != kM1_ChampionNone) {
+void ChampionMan::viAltarRebirth(uint16 champIndex) {
+	Champion *curChampion = &_champions[champIndex];
+	if (getIndexInCell(curChampion->_cell) != kM1_ChampionNone) {
 		uint16 numCell = k0_CellNorthWest;
-		while (f285_getIndexInCell(numCell) != kM1_ChampionNone)
+		while (getIndexInCell(numCell) != kM1_ChampionNone)
 			numCell++;
 
 		curChampion->_cell = (ViewCell)numCell;
@@ -1250,36 +1284,36 @@ void ChampionMan::f283_viAltarRebirth(uint16 champIndex) {
 	uint16 maximumHealth = curChampion->_maxHealth;
 	curChampion->_maxHealth = MAX(25, maximumHealth - (maximumHealth >> 6) - 1);
 	curChampion->_currHealth = curChampion->_maxHealth >> 1;
-	_vm->_menuMan->f393_drawSpellAreaControls(_g514_magicCasterChampionIndex);
+	_vm->_menuMan->f393_drawSpellAreaControls(_magicCasterChampionIndex);
 	curChampion->_dir = _vm->_dungeonMan->_g308_partyDir;
 	setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
-	f292_drawChampionState((ChampionIndex)champIndex);
+	drawChampionState((ChampionIndex)champIndex);
 }
 
-void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex) {
+void ChampionMan::clickOnSlotBox(uint16 slotBoxIndex) {
 	uint16 champIndex;
 	uint16 slotIndex;
 
 	if (slotBoxIndex < k8_SlotBoxInventoryFirstSlot) {
-		if (_g299_candidateChampionOrdinal)
+		if (_candidateChampionOrdinal)
 			return;
 
 		champIndex = slotBoxIndex >> 1;
-		if ((champIndex >= _g305_partyChampionCount) || (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_gK71_champions[champIndex]._currHealth)
+		if ((champIndex >= _partyChampionCount) || (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_champions[champIndex]._currHealth)
 			return;
 
-		slotIndex = M70_handSlotIndex(slotBoxIndex);
+		slotIndex = getHandSlotIndex(slotBoxIndex);
 	} else {
 		champIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal);
 		slotIndex = slotBoxIndex - k8_SlotBoxInventoryFirstSlot;
 	}
 
-	Thing leaderHandObject = _g414_leaderHandObject;
+	Thing leaderHandObject = _leaderHandObject;
 	Thing slotThing;
 	if (slotIndex >= k30_ChampionSlotChest_1) {
 		slotThing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
 	} else {
-		slotThing = _gK71_champions[champIndex]._slots[slotIndex];
+		slotThing = _champions[champIndex]._slots[slotIndex];
 	}
 
 	if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none))
@@ -1290,22 +1324,22 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex)
 
 	_vm->_eventMan->f78_showMouse();
 	if (leaderHandObject != Thing::_none)
-		f298_getObjectRemovedFromLeaderHand();
+		getObjectRemovedFromLeaderHand();
 
 	if (slotThing != Thing::_none) {
-		f300_getObjectRemovedFromSlot(champIndex, slotIndex);
-		f297_putObjectInLeaderHand(slotThing, false);
+		getObjectRemovedFromSlot(champIndex, slotIndex);
+		putObjectInLeaderHand(slotThing, false);
 	}
 
 	if (leaderHandObject != Thing::_none)
-		f301_addObjectInSlot((ChampionIndex)champIndex, leaderHandObject, (ChampionSlot)slotIndex);
+		addObjectInSlot((ChampionIndex)champIndex, leaderHandObject, (ChampionSlot)slotIndex);
 
-	f292_drawChampionState((ChampionIndex)champIndex);
+	drawChampionState((ChampionIndex)champIndex);
 	_vm->_eventMan->f77_hideMouse();
 }
 
-bool ChampionMan::f327_isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount) {
-	Champion *curChampion = &_gK71_champions[champIndex];
+bool ChampionMan::isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount) {
+	Champion *curChampion = &_champions[champIndex];
 	if (curChampion->_currMana < requiredManaAmount)
 		return false;
 
@@ -1317,28 +1351,28 @@ bool ChampionMan::f327_isProjectileSpellCast(uint16 champIndex, Thing thing, int
 		stepEnergy--;
 	}
 
-	f326_championShootProjectile(curChampion, thing, kineticEnergy, 90, stepEnergy);
+	championShootProjectile(curChampion, thing, kineticEnergy, 90, stepEnergy);
 	return true; // fix BUG_01
 }
 
-void ChampionMan::f326_championShootProjectile(Champion* champ, Thing thing, int16 kineticEnergy, int16 attack, int16 stepEnergy) {
+void ChampionMan::championShootProjectile(Champion* champ, Thing thing, int16 kineticEnergy, int16 attack, int16 stepEnergy) {
 	Direction newDirection = champ->_dir;
 	_vm->_projexpl->f212_projectileCreate(thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, M21_normalizeModulo4((((champ->_cell - newDirection + 1) & 0x0002) >> 1) + newDirection), newDirection, kineticEnergy, attack, stepEnergy);
 	_vm->_g311_projectileDisableMovementTicks = 4;
 	_vm->_g312_lastProjectileDisabledMovementDirection = newDirection;
 }
 
-void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() {
-	Champion *championPtr = _gK71_champions;
-	for (uint16 championIndex = k0_ChampionFirst; championIndex < _g305_partyChampionCount; championIndex++, championPtr++) {
-		int16 pendingWounds = _g410_championPendingWounds[championIndex];
+void ChampionMan::applyAndDrawPendingDamageAndWounds() {
+	Champion *championPtr = _champions;
+	for (uint16 championIndex = k0_ChampionFirst; championIndex < _partyChampionCount; championIndex++, championPtr++) {
+		int16 pendingWounds = _championPendingWounds[championIndex];
 		setFlag(championPtr->_wounds, pendingWounds);
-		_g410_championPendingWounds[championIndex] = 0;
-		uint16 pendingDamage = _g409_championPendingDamage[championIndex];
+		_championPendingWounds[championIndex] = 0;
+		uint16 pendingDamage = _championPendingDamage[championIndex];
 		if (!pendingDamage)
 			continue;
 
-		_g409_championPendingDamage[championIndex] = 0;
+		_championPendingDamage[championIndex] = 0;
 		int16 curHealth = championPtr->_currHealth;
 		if (!curHealth)
 			continue;
@@ -1348,7 +1382,7 @@ void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() {
 			curHealth -= pendingDamage;
 
 		if (curHealth <= 0) {
-			f319_championKill(championIndex);
+			championKill(championIndex);
 		} else {
 			championPtr->_currHealth = curHealth;
 			setFlag(championPtr->_attributes, k0x0100_ChampionAttributeStatistics);
@@ -1392,7 +1426,7 @@ void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() {
 
 				textPosY = 5;
 			}
-			_vm->_textMan->f53_printToLogicalScreen(textPosX, textPosY, k15_ColorWhite, k8_ColorRed, f288_getStringFromInteger(pendingDamage, false, 3).c_str());
+			_vm->_textMan->f53_printToLogicalScreen(textPosX, textPosY, k15_ColorWhite, k8_ColorRed, getStringFromInteger(pendingDamage, false, 3).c_str());
 
 			int16 eventIndex = championPtr->_hideDamageReceivedIndex;
 			if (eventIndex == -1) {
@@ -1406,22 +1440,22 @@ void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() {
 				M33_setMapAndTime(curEvent->_mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
 				_vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(eventIndex));
 			}
-			f292_drawChampionState((ChampionIndex)championIndex);
+			drawChampionState((ChampionIndex)championIndex);
 			_vm->_eventMan->f77_hideMouse();
 		}
 	}
 }
 
-void ChampionMan::f319_championKill(uint16 champIndex) {
-	Champion *curChampion = &_gK71_champions[champIndex];
+void ChampionMan::championKill(uint16 champIndex) {
+	Champion *curChampion = &_champions[champIndex];
 	curChampion->_currHealth = 0;
 	setFlag(curChampion->_attributes, k0x1000_ChampionAttributeStatusBox);
 	if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 		if (_vm->_g331_pressingEye) {
 			_vm->_g331_pressingEye = false;
 			_vm->_eventMan->_g597_ignoreMouseMovements = false;
-			if (!_g415_leaderEmptyHanded) {
-				_vm->_objectMan->f34_drawLeaderObjectName(_g414_leaderHandObject);
+			if (!_leaderEmptyHanded) {
+				_vm->_objectMan->f34_drawLeaderObjectName(_leaderHandObject);
 			}
 			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
 			_vm->_eventMan->f77_hideMouse();
@@ -1433,7 +1467,7 @@ void ChampionMan::f319_championKill(uint16 champIndex) {
 		}
 		_vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
 	}
-	f318_dropAllObjects(champIndex);
+	dropAllObjects(champIndex);
 	Thing unusedThing = _vm->_dungeonMan->f166_getUnusedThing(k0x8000_championBones | k10_JunkThingType);
 	uint16 curCell = 0;
 	if (unusedThing != Thing::_none) {
@@ -1448,40 +1482,40 @@ void ChampionMan::f319_championKill(uint16 champIndex) {
 	curChampion->_symbols[0] = '\0';
 	curChampion->_dir = _vm->_dungeonMan->_g308_partyDir;
 	curChampion->_maximumDamageReceived = 0;
-	uint16 curChampionIconIndex = M26_championIconIndex(curCell, _vm->_dungeonMan->_g308_partyDir);
+	uint16 curChampionIconIndex = getChampionIconIndex(curCell, _vm->_dungeonMan->_g308_partyDir);
 	if (_vm->M0_indexToOrdinal(curChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
 		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
 		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
 	}
 
 	if (curChampion->_poisonEventCount)
-		f323_unpoison(champIndex);
+		unpoison(champIndex);
 
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	_vm->_displayMan->D24_fillScreenBox(_boxChampionIcons[curChampionIconIndex], k0_ColorBlack);
-	f292_drawChampionState((ChampionIndex)champIndex);
+	drawChampionState((ChampionIndex)champIndex);
 
 	int16 aliveChampionIndex;
-	for (aliveChampionIndex = k0_ChampionFirst, curChampion = _gK71_champions; aliveChampionIndex < _g305_partyChampionCount; aliveChampionIndex++, curChampion++) {
+	for (aliveChampionIndex = k0_ChampionFirst, curChampion = _champions; aliveChampionIndex < _partyChampionCount; aliveChampionIndex++, curChampion++) {
 		if (curChampion->_currHealth)
 			break;
 	}
 
-	if (aliveChampionIndex == _g305_partyChampionCount) { /* BUG0_43 The game does not end if the last living champion in the party is killed while looking at a candidate champion in a portrait. The condition to end the game when the whole party is killed is not true because the code considers the candidate champion as alive (in the loop above) */
-		_g303_partyDead = true;
+	if (aliveChampionIndex == _partyChampionCount) { /* BUG0_43 The game does not end if the last living champion in the party is killed while looking at a candidate champion in a portrait. The condition to end the game when the whole party is killed is not true because the code considers the candidate champion as alive (in the loop above) */
+		_partyDead = true;
 		return;
 	}
 
-	if (champIndex == _g411_leaderIndex)
+	if (champIndex == _leaderIndex)
 		_vm->_eventMan->f368_commandSetLeader((ChampionIndex)aliveChampionIndex);
 
-	if (champIndex == _g514_magicCasterChampionIndex)
+	if (champIndex == _magicCasterChampionIndex)
 		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(aliveChampionIndex);
 	else
-		_vm->_menuMan->f393_drawSpellAreaControls(_g514_magicCasterChampionIndex);
+		_vm->_menuMan->f393_drawSpellAreaControls(_magicCasterChampionIndex);
 }
 
-void ChampionMan::f318_dropAllObjects(uint16 champIndex) {
+void ChampionMan::dropAllObjects(uint16 champIndex) {
 	static const int16 slotDropOrder[30] = {
 		k5_ChampionSlotFeet,
 		k4_ChampionSlotLegs,
@@ -1515,15 +1549,15 @@ void ChampionMan::f318_dropAllObjects(uint16 champIndex) {
 		k1_ChampionSlotActionHand
 	};
 
-	uint16 curCell = _gK71_champions[champIndex]._cell;
+	uint16 curCell = _champions[champIndex]._cell;
 	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
-		Thing curThing = f300_getObjectRemovedFromSlot(champIndex, slotDropOrder[slotIndex]);
+		Thing curThing = getObjectRemovedFromSlot(champIndex, slotDropOrder[slotIndex]);
 		if (curThing != Thing::_none)
 			_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(curThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
 	}
 }
 
-void ChampionMan::f323_unpoison(int16 champIndex) {
+void ChampionMan::unpoison(int16 champIndex) {
 	if (champIndex == kM1_ChampionNone)
 		return;
 
@@ -1532,11 +1566,11 @@ void ChampionMan::f323_unpoison(int16 champIndex) {
 		if ((eventPtr->_type == k75_TMEventTypePoisonChampion) && (eventPtr->_priority == champIndex))
 			_vm->_timeline->f237_deleteEvent(eventIndex);
 	}
-	_gK71_champions[champIndex]._poisonEventCount = 0;
+	_champions[champIndex]._poisonEventCount = 0;
 }
 
-void ChampionMan::f331_applyTimeEffects() {
-	if (!_g305_partyChampionCount)
+void ChampionMan::applyTimeEffects() {
+	if (!_partyChampionCount)
 		return;
 
 	Scent checkScent;
@@ -1544,11 +1578,11 @@ void ChampionMan::f331_applyTimeEffects() {
 	checkScent.setMapY(_vm->_dungeonMan->_g307_partyMapY);
 	checkScent.setMapIndex(_vm->_dungeonMan->_g309_partyMapIndex);
 
-	for (byte loopScentIndex = 0; loopScentIndex + 1 < _g407_party._scentCount; loopScentIndex++) {
-		if (&_g407_party._scents[loopScentIndex] != &checkScent) {
-			_g407_party._scentStrengths[loopScentIndex] = MAX(0, _g407_party._scentStrengths[loopScentIndex] - 1);
-			if (!_g407_party._scentStrengths[loopScentIndex] && !loopScentIndex) {
-				f316_deleteScent(0);
+	for (byte loopScentIndex = 0; loopScentIndex + 1 < _party._scentCount; loopScentIndex++) {
+		if (&_party._scents[loopScentIndex] != &checkScent) {
+			_party._scentStrengths[loopScentIndex] = MAX(0, _party._scentStrengths[loopScentIndex] - 1);
+			if (!_party._scentStrengths[loopScentIndex] && !loopScentIndex) {
+				deleteScent(0);
 				continue;
 			}
 		}
@@ -1556,18 +1590,18 @@ void ChampionMan::f331_applyTimeEffects() {
 
 	uint16 gameTime = _vm->_g313_gameTime & 0xFFFF;
 	uint16 timeCriteria = (((gameTime & 0x0080) + ((gameTime & 0x0100) >> 2)) + ((gameTime & 0x0040) << 2)) >> 2;
-	Champion *championPtr = _gK71_champions;
-	for (uint16 championIndex = k0_ChampionFirst; championIndex < _g305_partyChampionCount; championIndex++, championPtr++) {
-		if (championPtr->_currHealth && (_vm->M0_indexToOrdinal(championIndex) != _g299_candidateChampionOrdinal)) {
-			uint16 wizardSkillLevel = f303_getSkillLevel(championIndex, k3_ChampionSkillWizard) + f303_getSkillLevel(championIndex, k2_ChampionSkillPriest);
+	Champion *championPtr = _champions;
+	for (uint16 championIndex = k0_ChampionFirst; championIndex < _partyChampionCount; championIndex++, championPtr++) {
+		if (championPtr->_currHealth && (_vm->M0_indexToOrdinal(championIndex) != _candidateChampionOrdinal)) {
+			uint16 wizardSkillLevel = getSkillLevel(championIndex, k3_ChampionSkillWizard) + getSkillLevel(championIndex, k2_ChampionSkillPriest);
 			if ((championPtr->_currMana < championPtr->_maxMana)
 				&& (timeCriteria < championPtr->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + wizardSkillLevel)) {
 				int16 manaGain = championPtr->_maxMana / 40;
-				if (_g300_partyIsSleeping)
+				if (_partyIsSleeping)
 					manaGain <<= 1;
 
 				manaGain++;
-				f325_decrementStamina(championIndex, manaGain * MAX(7, 16 - wizardSkillLevel));
+				decrementStamina(championIndex, manaGain * MAX(7, 16 - wizardSkillLevel));
 				championPtr->_currMana += MIN<int16>(manaGain, championPtr->_maxMana - championPtr->_currMana);
 			} else if (championPtr->_currMana > championPtr->_maxMana)
 				championPtr->_currMana--;
@@ -1583,7 +1617,7 @@ void ChampionMan::f331_applyTimeEffects() {
 
 			int16 staminaLoss = 0;
 			int16 staminaAmount = f26_getBoundedValue(1, (championPtr->_maxStamina >> 8) - 1, 6);
-			if (_g300_partyIsSleeping)
+			if (_partyIsSleeping)
 				staminaAmount <<= 1;
 
 			int32 compDelay = _vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime;
@@ -1617,7 +1651,7 @@ void ChampionMan::f331_applyTimeEffects() {
 					championPtr->_water -= staminaAboveHalf ? 1 : staminaGainCycleCount >> 2;
 				}
 			} while (--staminaGainCycleCount && ((championPtr->_currStamina - staminaLoss) < championPtr->_maxStamina));
-			f325_decrementStamina(championIndex, staminaLoss);
+			decrementStamina(championIndex, staminaLoss);
 			if (championPtr->_food < -1024)
 				championPtr->_food = -1024;
 
@@ -1626,7 +1660,7 @@ void ChampionMan::f331_applyTimeEffects() {
 
 			if ((championPtr->_currHealth < championPtr->_maxHealth) && (championPtr->_currStamina >= (championPtr->_maxStamina >> 2)) && (timeCriteria < (championPtr->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] + 12))) {
 				int16 healthGain = (championPtr->_maxHealth >> 7) + 1;
-				if (_g300_partyIsSleeping)
+				if (_partyIsSleeping)
 					healthGain <<= 1;
 
 				if (_vm->_objectMan->f33_getIconIndex(championPtr->_slots[k10_ChampionSlotNeck]) == k121_IconIndiceJunkEkkhardCross)
@@ -1634,7 +1668,7 @@ void ChampionMan::f331_applyTimeEffects() {
 
 				championPtr->_currHealth += MIN(healthGain, (int16)(championPtr->_maxHealth - championPtr->_currHealth));
 			}
-			if (!((int)_vm->_g313_gameTime & (_g300_partyIsSleeping ? 63 : 255))) {
+			if (!((int)_vm->_g313_gameTime & (_partyIsSleeping ? 63 : 255))) {
 				for (uint16 i = k0_ChampionStatLuck; i <= k6_ChampionStatAntifire; i++) {
 					byte *curStatistic = championPtr->_statistics[i];
 					uint16 statisticMaximum = curStatistic[k0_ChampionStatMaximum];
@@ -1644,7 +1678,7 @@ void ChampionMan::f331_applyTimeEffects() {
 						curStatistic[k1_ChampionStatCurrent] -= curStatistic[k1_ChampionStatCurrent] / statisticMaximum;
 				}
 			}
-			if (!_g300_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_g313_gameTime)) {
+			if (!_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_g313_gameTime)) {
 				championPtr->_dir = _vm->_dungeonMan->_g308_partyDir;
 				championPtr->_maximumDamageReceived = 0;
 				setFlag(championPtr->_attributes, k0x0400_ChampionAttributeIcon);
@@ -1657,12 +1691,12 @@ void ChampionMan::f331_applyTimeEffects() {
 			}
 		}
 	}
-	f293_drawAllChampionStates();
+	drawAllChampionStates();
 }
 
-void ChampionMan::save2_PartyPart(Common::OutSaveFile* file) {
+void ChampionMan::savePartyPart2(Common::OutSaveFile* file) {
 	for (uint16 i = 0; i < 4; ++i) {
-		Champion *champ = &_gK71_champions[i];
+		Champion *champ = &_champions[i];
 		file->writeUint16BE(champ->_attributes);
 		file->writeUint16BE(champ->_wounds);
 		for (uint16 y = 0; y < 7; ++y)
@@ -1704,7 +1738,7 @@ void ChampionMan::save2_PartyPart(Common::OutSaveFile* file) {
 			file->writeByte(champ->_portrait[j]);
 	}
 
-	Party &party = _g407_party;
+	Party &party = _party;
 	file->writeSint16BE(party._magicalLightAmount);
 	file->writeByte(party._event73Count_ThievesEye);
 	file->writeByte(party._event79Count_Footprints);
@@ -1722,9 +1756,9 @@ void ChampionMan::save2_PartyPart(Common::OutSaveFile* file) {
 	file->writeByte(party._event71Count_Invisibility);
 }
 
-void ChampionMan::load2_PartyPart(Common::InSaveFile* file) {
+void ChampionMan::loadPartyPart2(Common::InSaveFile* file) {
 	for (uint16 i = 0; i < 4; ++i) {
-		Champion *champ = &_gK71_champions[i];
+		Champion *champ = &_champions[i];
 		champ->_attributes = file->readUint16BE();
 		champ->_wounds = file->readUint16BE();
 		for (uint16 y = 0; y < 7; ++y)
@@ -1766,7 +1800,7 @@ void ChampionMan::load2_PartyPart(Common::InSaveFile* file) {
 			champ->_portrait[j] = file->readByte();
 	}
 
-	Party &party = _g407_party;
+	Party &party = _party;
 	party._magicalLightAmount = file->readSint16BE();
 	party._event73Count_ThievesEye = file->readByte();
 	party._event79Count_Footprints = file->readByte();
@@ -1784,67 +1818,67 @@ void ChampionMan::load2_PartyPart(Common::InSaveFile* file) {
 	party._event71Count_Invisibility = file->readByte();
 }
 
-ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
-	for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
-		if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
+ChampionIndex ChampionMan::getIndexInCell(int16 cell) {
+	for (uint16 i = 0; i < _partyChampionCount; ++i) {
+		if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
 			return (ChampionIndex)i;
 	}
 
 	return kM1_ChampionNone;
 }
 
-void ChampionMan::f278_resetDataToStartGame() {
+void ChampionMan::resetDataToStartGame() {
 	if (!_vm->_g298_newGame) {
 		Thing L0787_T_Thing;
-		if ((L0787_T_Thing = _g414_leaderHandObject) == Thing::_none) {
-			_g415_leaderEmptyHanded = true;
-			_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
+		if ((L0787_T_Thing = _leaderHandObject) == Thing::_none) {
+			_leaderEmptyHanded = true;
+			_leaderHandObjectIconIndex = kM1_IconIndiceNone;
 			_vm->_eventMan->f69_setMousePointer();
 		} else {
-			f297_putObjectInLeaderHand(L0787_T_Thing, true); /* This call will add the weight of the leader hand object to the Load of the leader a first time */
+			putObjectInLeaderHand(L0787_T_Thing, true); /* This call will add the weight of the leader hand object to the Load of the leader a first time */
 		}
-		Champion *L0788_ps_Champion = _gK71_champions;
+		Champion *L0788_ps_Champion = _champions;
 		int16 L0785_i_ChampionIndex;
-		for (L0785_i_ChampionIndex = k0_ChampionFirst; L0785_i_ChampionIndex < _g305_partyChampionCount; L0785_i_ChampionIndex++, L0788_ps_Champion++) {
+		for (L0785_i_ChampionIndex = k0_ChampionFirst; L0785_i_ChampionIndex < _partyChampionCount; L0785_i_ChampionIndex++, L0788_ps_Champion++) {
 			clearFlag(L0788_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
 			setFlag(L0788_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
 		}
-		f293_drawAllChampionStates();
-		if ((L0785_i_ChampionIndex = _g411_leaderIndex) != kM1_ChampionNone) {
-			_g411_leaderIndex = kM1_ChampionNone;
+		drawAllChampionStates();
+		if ((L0785_i_ChampionIndex = _leaderIndex) != kM1_ChampionNone) {
+			_leaderIndex = kM1_ChampionNone;
 			_vm->_eventMan->f368_commandSetLeader((ChampionIndex)L0785_i_ChampionIndex);
 		}
-		if ((L0785_i_ChampionIndex = _g514_magicCasterChampionIndex) != kM1_ChampionNone) {
-			_g514_magicCasterChampionIndex = kM1_ChampionNone;
+		if ((L0785_i_ChampionIndex = _magicCasterChampionIndex) != kM1_ChampionNone) {
+			_magicCasterChampionIndex = kM1_ChampionNone;
 			_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(L0785_i_ChampionIndex);
 		}
 		return;
 	}
 
-	_g414_leaderHandObject = Thing::_none;
-	_g413_leaderHandObjectIconIndex = kM1_IconIndiceNone;
-	_g415_leaderEmptyHanded = true;
+	_leaderHandObject = Thing::_none;
+	_leaderHandObjectIconIndex = kM1_IconIndiceNone;
+	_leaderEmptyHanded = true;
 }
 
-void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) {
-	if (!_g415_leaderEmptyHanded)
+void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
+	if (!_leaderEmptyHanded)
 		return;
 
-	if (_g305_partyChampionCount == 4)
+	if (_partyChampionCount == 4)
 		return;
 
-	uint16 previousPartyChampionCount = _g305_partyChampionCount;
-	Champion *championPtr = &_gK71_champions[previousPartyChampionCount];
+	uint16 previousPartyChampionCount = _partyChampionCount;
+	Champion *championPtr = &_champions[previousPartyChampionCount];
 	championPtr->resetToZero();
 	// Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portraits could be missing in the data)
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
-	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, _boxChampionPortrait, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency, 87, 29);
+	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, _boxChampionPortrait, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency, 87, 29);
 	championPtr->_actionIndex = k255_ChampionActionNone;
 	championPtr->_enableActionEventIndex = -1;
 	championPtr->_hideDamageReceivedIndex = -1;
 	championPtr->_dir = _vm->_dungeonMan->_g308_partyDir;
 	uint16 viewCell = k0_ViewCellFronLeft;
-	while (f285_getIndexInCell(M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone)
+	while (getIndexInCell(M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone)
 		viewCell++;
 
 	championPtr->_cell = (ViewCell)M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir);
@@ -1885,16 +1919,16 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 		setFlag(championPtr->_attributes, k0x0010_ChampionAttributeMale);
 
 	decodedStringPtr++;
-	championPtr->_currHealth = championPtr->_maxHealth = f279_getDecodedValue(decodedStringPtr, 4);
+	championPtr->_currHealth = championPtr->_maxHealth = getDecodedValue(decodedStringPtr, 4);
 	decodedStringPtr += 4;
-	championPtr->_currStamina = championPtr->_maxStamina = f279_getDecodedValue(decodedStringPtr, 4);
+	championPtr->_currStamina = championPtr->_maxStamina = getDecodedValue(decodedStringPtr, 4);
 	decodedStringPtr += 4;
-	championPtr->_currMana = championPtr->_maxMana = f279_getDecodedValue(decodedStringPtr, 4);
+	championPtr->_currMana = championPtr->_maxMana = getDecodedValue(decodedStringPtr, 4);
 	decodedStringPtr += 4;
 	decodedStringPtr++;
 	for (int16 statIdx = k0_ChampionStatLuck; statIdx <= k6_ChampionStatAntifire; statIdx++) {
 		championPtr->_statistics[statIdx][k2_ChampionStatMinimum] = 30;
-		championPtr->_statistics[statIdx][k1_ChampionStatCurrent] = championPtr->_statistics[statIdx][k0_ChampionStatMaximum] = f279_getDecodedValue(decodedStringPtr, 2);
+		championPtr->_statistics[statIdx][k1_ChampionStatCurrent] = championPtr->_statistics[statIdx][k0_ChampionStatMaximum] = getDecodedValue(decodedStringPtr, 2);
 		decodedStringPtr += 2;
 	}
 	championPtr->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10;
@@ -1912,13 +1946,13 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 
 		championPtr->_skills[skillIdx]._experience = baseSkillExperience;
 	}
-	_g299_candidateChampionOrdinal = previousPartyChampionCount + 1;
-	if (++_g305_partyChampionCount == 1) {
+	_candidateChampionOrdinal = previousPartyChampionCount + 1;
+	if (++_partyChampionCount == 1) {
 		_vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst);
 		_vm->_menuMan->_g508_refreshActionArea = true;
 	} else {
 		_vm->_menuMan->f388_clearActingChampion();
-		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1));
+		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_partyChampionCount - 1));
 	}
 
 	int16 curMapX = _vm->_dungeonMan->_g306_partyMapX;
@@ -1989,7 +2023,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 				else
 					curSlotIndex = slotIdx++;
 			}
-			f301_addObjectInSlot((ChampionIndex)previousPartyChampionCount, curThing, (ChampionSlot)curSlotIndex);
+			addObjectInSlot((ChampionIndex)previousPartyChampionCount, curThing, (ChampionSlot)curSlotIndex);
 		}
 		curThing = _vm->_dungeonMan->f159_getNextThing(curThing);
 	}
@@ -1997,9 +2031,9 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex)
 	_vm->_menuMan->f456_drawDisabledMenu();;
 }
 
-void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
+void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
 	int16 barGraphHeights[3];
-	Champion *champ = &_gK71_champions[champIndex];
+	Champion *champ = &_champions[champIndex];
 	int16 barGraphIdx = 0;
 	if (champ->_currHealth > 0) {
 		int32 barGraphHeight = (((int32)champ->_currHealth << 10) * 25) / champ->_maxHealth;
@@ -2050,7 +2084,7 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
 }
 
 
-uint16 ChampionMan::f306_getStaminaAdjustedValue(Champion *champ, int16 val) {
+uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) {
 	int16 currStamina = champ->_currStamina;
 	int16 halfMaxStamina = champ->_maxStamina / 2;
 	if (currStamina < halfMaxStamina) {
@@ -2060,9 +2094,9 @@ uint16 ChampionMan::f306_getStaminaAdjustedValue(Champion *champ, int16 val) {
 	return val;
 }
 
-uint16 ChampionMan::f309_getMaximumLoad(Champion *champ) {
+uint16 ChampionMan::getMaximumLoad(Champion *champ) {
 	uint16 maximumLoad = champ->getStatistic(k1_ChampionStatStrength, k1_ChampionStatCurrent) * 8 + 100;
-	maximumLoad = f306_getStaminaAdjustedValue(champ, maximumLoad);
+	maximumLoad = getStaminaAdjustedValue(champ, maximumLoad);
 	int16 wounds = champ->getWounds();
 	if (wounds)
 		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(k0x0010_ChampionWoundLegs) ? 2 : 3);
@@ -2075,12 +2109,12 @@ uint16 ChampionMan::f309_getMaximumLoad(Champion *champ) {
 	return maximumLoad;
 }
 
-void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
+void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	static Box boxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth 
 	static Box boxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye 
 
 	int16 championStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
-	Champion *curChampion = &_gK71_champions[champIndex];
+	Champion *curChampion = &_champions[champIndex];
 	uint16 championAttributes = curChampion->_attributes;
 	if (!getFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand))
 		return;
@@ -2101,13 +2135,13 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 				nativeBitmapIndices[i] = 0;
 
 			uint16 borderCount = 0;
-			if (_g407_party._fireShieldDefense > 0)
+			if (_party._fireShieldDefense > 0)
 				nativeBitmapIndices[borderCount++] = k38_BorderPartyFireshieldIndice;
 
-			if (_g407_party._spellShieldDefense > 0)
+			if (_party._spellShieldDefense > 0)
 				nativeBitmapIndices[borderCount++] = k39_BorderPartySpellshieldIndice;
 
-			if ((_g407_party._shieldDefense > 0) || curChampion->_shieldDefense)
+			if ((_party._shieldDefense > 0) || curChampion->_shieldDefense)
 				nativeBitmapIndices[borderCount++] = k37_BorderPartyShieldIndice;
 
 			while (borderCount--)
@@ -2135,7 +2169,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 	}
 
 	if (getFlag(championAttributes, k0x0080_ChampionAttributeNameTitle)) {
-		Color nameColor = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
+		Color nameColor = (champIndex == _leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
 		if (isInventoryChampion) {
 			char *championName = curChampion->_name;
 			_vm->_textMan->f52_printToViewport(3, 7, nameColor, championName);
@@ -2157,9 +2191,9 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		}
 	}
 	if (getFlag(championAttributes, k0x0100_ChampionAttributeStatistics)) {
-		f287_drawChampionBarGraphs(champIndex);
+		drawChampionBarGraphs(champIndex);
 		if (isInventoryChampion) {
-			f290_drawHealthStaminaManaValues(curChampion);
+			drawHealthStaminaManaValues(curChampion);
 			int16 nativeBitmapIndex;
 			if ((curChampion->_food < 0) || (curChampion->_water < 0) || (curChampion->_poisonEventCount))
 				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
@@ -2180,13 +2214,13 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 	}
 	if (getFlag(championAttributes, k0x2000_ChampionAttributeWounds)) {
 		for (int i = isInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; i >= k0_ChampionSlotReadyHand; i--)
-			f291_drawSlot(champIndex, i);
+			drawSlot(champIndex, i);
 
 		if (isInventoryChampion)
 			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
 	if (getFlag(championAttributes, k0x0200_ChampionAttributeLoad) && isInventoryChampion) {
-		uint16 maxLoad = f309_getMaximumLoad(curChampion);
+		uint16 maxLoad = getMaximumLoad(curChampion);
 		Color loadColor;
 		if (curChampion->_load > maxLoad)
 			loadColor = k8_ColorRed;
@@ -2203,7 +2237,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		}
 
 		maxLoad = curChampion->_load / 10;
-		strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, true, 3).c_str());
+		strcpy(_vm->_g353_stringBuildBuffer, getStringFromInteger(maxLoad, true, 3).c_str());
 
 		switch (_vm->getGameLanguage()) { // localized
 		default:
@@ -2213,24 +2247,24 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		}
 
 		maxLoad = curChampion->_load - (maxLoad * 10);
-		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, false, 1).c_str());
+		strcat(_vm->_g353_stringBuildBuffer, getStringFromInteger(maxLoad, false, 1).c_str());
 		strcat(_vm->_g353_stringBuildBuffer, "/");
-		maxLoad = (f309_getMaximumLoad(curChampion) + 5) / 10;
-		strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, true, 3).c_str());
+		maxLoad = (getMaximumLoad(curChampion) + 5) / 10;
+		strcat(_vm->_g353_stringBuildBuffer, getStringFromInteger(maxLoad, true, 3).c_str());
 		strcat(_vm->_g353_stringBuildBuffer, " KG");
 		_vm->_textMan->f52_printToViewport(148, 132, loadColor, _vm->_g353_stringBuildBuffer);
 		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
-	uint16 championIconIndex = M26_championIconIndex(curChampion->_cell, _vm->_dungeonMan->_g308_partyDir);
+	uint16 championIconIndex = getChampionIconIndex(curChampion->_cell, _vm->_dungeonMan->_g308_partyDir);
 	if (getFlag(championAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(championIconIndex))) {
 		_vm->_displayMan->D24_fillScreenBox(_boxChampionIcons[championIconIndex], _championColor[champIndex]);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, _boxChampionIcons[championIconIndex], M26_championIconIndex(curChampion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, _boxChampionIcons[championIconIndex], getChampionIconIndex(curChampion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
 	}
 	if (getFlag(championAttributes, k0x0800_ChampionAttributePanel) && isInventoryChampion) {
 		if (_vm->_g333_pressingMouth)
 			_vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned();
 		else if (_vm->_g331_pressingEye) {
-			if (_g415_leaderEmptyHanded)
+			if (_leaderEmptyHanded)
 				_vm->_inventoryMan->f351_drawChampionSkillsAndStatistics();
 		} else
 			_vm->_inventoryMan->f347_drawPanel();
@@ -2238,7 +2272,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
 	if (getFlag(championAttributes, k0x8000_ChampionAttributeActionHand)) {
-		f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
+		drawSlot(champIndex, k1_ChampionSlotActionHand);
 		_vm->_menuMan->f386_drawActionIcon(champIndex);
 		if (isInventoryChampion)
 			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
@@ -2250,25 +2284,25 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) {
 	_vm->_eventMan->f77_hideMouse();
 }
 
-uint16 ChampionMan::M26_championIconIndex(int16 val, Direction dir) {
+uint16 ChampionMan::getChampionIconIndex(int16 val, Direction dir) {
 	return ((val + 4 - dir) & 0x3);
 }
 
-void ChampionMan::f290_drawHealthStaminaManaValues(Champion* champ) {
-	f289_drawHealthOrStaminaOrManaValue(116, champ->_currHealth, champ->_maxHealth);
-	f289_drawHealthOrStaminaOrManaValue(124, champ->_currStamina, champ->_maxStamina);
-	f289_drawHealthOrStaminaOrManaValue(132, champ->_currMana, champ->_maxMana);
+void ChampionMan::drawHealthStaminaManaValues(Champion* champ) {
+	drawHealthOrStaminaOrManaValue(116, champ->_currHealth, champ->_maxHealth);
+	drawHealthOrStaminaOrManaValue(124, champ->_currStamina, champ->_maxStamina);
+	drawHealthOrStaminaOrManaValue(132, champ->_currMana, champ->_maxMana);
 }
 
-void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
+void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 	int16 nativeBitmapIndex = -1;
-	Champion *champ = &_gK71_champions[champIndex];
+	Champion *champ = &_champions[champIndex];
 	bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex));
 
 	uint16 slotBoxIndex;
 	if (!isInventoryChamp) {
 		// If drawing a slot for a champion other than the champion whose inventory is open
-		if ((slotIndex > k1_ChampionSlotActionHand) || (_g299_candidateChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)))
+		if ((slotIndex > k1_ChampionSlotActionHand) || (_candidateChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)))
 			return;
 		slotBoxIndex = (champIndex << 1) + slotIndex;
 	} else
@@ -2318,7 +2352,7 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
 		}
 	}
 
-	if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->M0_indexToOrdinal(champIndex) == _g506_actingChampionOrdinal))
+	if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->M0_indexToOrdinal(champIndex) == _actingChampionOrdinal))
 		nativeBitmapIndex = k35_SlotBoxActingHandIndice;
 
 	if (nativeBitmapIndex != -1) {
@@ -2340,7 +2374,7 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) {
 		_vm->_eventMan->f78_showMouse();
 }
 
-void ChampionMan::f281_renameChampion(Champion* champ) {
+void ChampionMan::renameChampion(Champion* champ) {
 #define k1_RENAME_CHAMPION_NAME 1
 #define k2_RENAME_CHAMPION_TITLE 2
 	static const char underscoreCharacterString[2] = "_";
@@ -2402,8 +2436,8 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 						renamedChampionString[curCharacterIndex] = '\0';
 
 					bool found = false;
-					for (uint16 idx = k0_ChampionFirst; idx < _g305_partyChampionCount - 1; idx++) {
-						if (!strcmp(_gK71_champions[idx]._name, renamedChampionString)) {
+					for (uint16 idx = k0_ChampionFirst; idx < _partyChampionCount - 1; idx++) {
+						if (!strcmp(_champions[idx]._name, renamedChampionString)) {
 							// If an existing champion already has the specified name for the new champion
 							found = true;
 							break;
@@ -2507,14 +2541,14 @@ void ChampionMan::f281_renameChampion(Champion* champ) {
 	}
 }
 
-uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, uint16 skillIndex) {
-	if (_g300_partyIsSleeping)
+uint16 ChampionMan::getSkillLevel(int16 champIndex, uint16 skillIndex) {
+	if (_partyIsSleeping)
 		return 1;
 
 	bool ignoreTmpExp = getFlag(skillIndex, k0x8000_IgnoreTemporaryExperience);
 	bool ignoreObjModifiers = getFlag(skillIndex, k0x4000_IgnoreObjectModifiers);
 	clearFlag(skillIndex, k0x8000_IgnoreTemporaryExperience | k0x4000_IgnoreObjectModifiers);
-	Champion *champ = &_gK71_champions[champIndex];
+	Champion *champ = &_champions[champIndex];
 	Skill *skill = &champ->_skills[skillIndex];
 	int32 exp = skill->_experience;
 	if (!ignoreTmpExp)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index f7e9f1f..82117e8 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -400,48 +400,19 @@ public:
 
 	uint16 getAttributes() { return _attributes; }
 	uint16 getAttributes(ChampionAttribute flag) { return _attributes & flag; }
-	void setAttributeFlag(ChampionAttribute flag, bool value) {
-		if (value) {
-			_attributes |= flag;
-		} else {
-			_attributes &= ~flag;
-		}
-	}
+	void setAttributeFlag(ChampionAttribute flag, bool value);
 	void clearAttributes(ChampionAttribute attribute = k0x0000_ChampionAttributNone) { _attributes = attribute; }
 
 	uint16 getWounds() { return _wounds; }
-	void setWoundsFlag(ChampionWound flag, bool value) {
-		if (value) {
-			_wounds |= flag;
-		} else {
-			_wounds &= ~flag;
-		}
-	}
+	void setWoundsFlag(ChampionWound flag, bool value);
 	uint16 getWoundsFlag(ChampionWound wound) { return _wounds & wound; }
 	void clearWounds() { _wounds = k0x0000_ChampionWoundNone; }
-	void resetToZero() { // oh boy > . <
-		for (int16 i = 0; i < 30; ++i)
-			_slots[i] = Thing::_none;
-		for (int16 i = 0; i < 20; ++i)
-			_skills[i].resetToZero();
-		_attributes = _wounds = 0;
-		memset(_statistics, 0, 7 * 3);
-		memset(_name, '\0', 8);
-		memset(_title, '\0', 20);
-		_dir = kDirNorth;
-		_cell = k0_ViewCellFronLeft;
-		_actionIndex = k0_ChampionActionN;
-		_symbolStep = 0;
-		memset(_symbols, '\0', 5);
-		_directionMaximumDamageReceived = _maximumDamageReceived = _poisonEventCount = _enableActionEventIndex = 0;
-		_hideDamageReceivedIndex = _currHealth = _maxHealth = _currStamina = _maxStamina = _currMana = _maxMana = 0;
-		_actionDefense = _food = _water = _load = _shieldDefense = 0;
-		memset(_portrait, 0, 464);
-	}
 	void resetSkillsToZero() {
 		for (int16 i = 0; i < 20; ++i)
 			_skills[i].resetToZero();
 	}
+	void resetToZero();
+
 }; // @ CHAMPION_INCLUDING_PORTRAIT
 
 #define k0x0000_maskDoNotUseSharpDefense 0x0000 // @ MASK0x0000_DO_NOT_USE_SHARP_DEFENSE 
@@ -489,102 +460,101 @@ public:
 	byte _skillIndex;
 	uint16 _attributes; /* Bits 15-10: Duration, Bits 9-4: Type, Bits 3-0: Kind */
 
-	uint16 M67_spellKind() { return _attributes & 0xF; } // @ M67_SPELL_KIND
-	uint16 M68_spellType() { return (_attributes >> 4) & 0x3F; } // @ M68_SPELL_TYPE
-	uint16 M69_spellDurration() { return (_attributes >> 10) & 0x3F; } // @ M69_SPELL_DURATION
+	uint16 getKind() { return _attributes & 0xF; } // @ M67_SPELL_KIND
+	uint16 getType() { return (_attributes >> 4) & 0x3F; } // @ M68_SPELL_TYPE
+	uint16 getDuration() { return (_attributes >> 10) & 0x3F; } // @ M69_SPELL_DURATION
 }; // @ SPELL
 
 class ChampionMan {
 	DMEngine *_vm;
 
-	uint16 M27_getChampionPortraitX(uint16 index); // @ M27_PORTRAIT_X
-	uint16 M28_getChampionPortraitY(uint16 index); // @ M28_PORTRAIT_Y
+	uint16 getChampionPortraitX(uint16 index); // @ M27_PORTRAIT_X
+	uint16 getChampionPortraitY(uint16 index); // @ M28_PORTRAIT_Y
 
-	int16 f279_getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue
-	void f289_drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue
-	uint16 M70_handSlotIndex(uint16 slotBoxIndex);// @ M70_HAND_SLOT_INDEX
-	int16 _g410_championPendingWounds[4]; // @ G0410_ai_ChampionPendingWounds
-	int16 _g409_championPendingDamage[4]; // @ G0409_ai_ChampionPendingDamage
+	int16 getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue
+	void drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue
+	uint16 getHandSlotIndex(uint16 slotBoxIndex);// @ M70_HAND_SLOT_INDEX
+	int16 _championPendingWounds[4]; // @ G0410_ai_ChampionPendingWounds
+	int16 _championPendingDamage[4]; // @ G0409_ai_ChampionPendingDamage
 
 	void initConstants();
 
 public:
 
-	Champion _gK71_champions[4]; // @ K0071_as_Champions
-	uint16 _g305_partyChampionCount;	// @ G0305_ui_PartyChampionCount
-	bool _g303_partyDead; // @ G0303_B_PartyDead
-	Thing _g414_leaderHandObject; // @ G0414_T_LeaderHandObject
-	ChampionIndex _g411_leaderIndex;	// @ G0411_i_LeaderIndex
-	uint16 _g299_candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal
-	bool _g300_partyIsSleeping; // @ G0300_B_PartyIsSleeping
-	uint16 _g506_actingChampionOrdinal; // @ G0506_ui_ActingChampionOrdinal
-	IconIndice _g413_leaderHandObjectIconIndex; // @ G0413_i_LeaderHandObjectIconIndex
-	bool _g415_leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded
-	Party _g407_party; // @ G0407_s_Party
-	ChampionIndex _g514_magicCasterChampionIndex; // @ G0514_i_MagicCasterChampionIndex
-	bool _g420_mousePointerHiddenToDrawChangedObjIconOnScreen; // @ G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen
+	Champion _champions[4]; // @ K0071_as_Champions
+	uint16 _partyChampionCount;	// @ G0305_ui_PartyChampionCount
+	bool _partyDead; // @ G0303_B_PartyDead
+	Thing _leaderHandObject; // @ G0414_T_LeaderHandObject
+	ChampionIndex _leaderIndex;	// @ G0411_i_LeaderIndex
+	uint16 _candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal
+	bool _partyIsSleeping; // @ G0300_B_PartyIsSleeping
+	uint16 _actingChampionOrdinal; // @ G0506_ui_ActingChampionOrdinal
+	IconIndice _leaderHandObjectIconIndex; // @ G0413_i_LeaderHandObjectIconIndex
+	bool _leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded
+	Party _party; // @ G0407_s_Party
+	ChampionIndex _magicCasterChampionIndex; // @ G0514_i_MagicCasterChampionIndex
+	bool _mousePointerHiddenToDrawChangedObjIconOnScreen; // @ G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen
 
 	explicit ChampionMan(DMEngine *vm);
-	ChampionIndex f285_getIndexInCell(int16 cell); // @ F0285_CHAMPION_GetIndexInCell
-	bool f329_isLeaderHandObjectThrown(int16 side); // @ F0329_CHAMPION_IsLeaderHandObjectThrown
-	bool f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side); // @ F0328_CHAMPION_IsObjectThrown
-	void f278_resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
-	void f280_addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty
-	void f287_drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs
-	uint16 f306_getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue
-	uint16 f309_getMaximumLoad(Champion *champ); // @ F0309_CHAMPION_GetMaximumLoad
-	void f292_drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState
-	uint16 M26_championIconIndex(int16 val, Direction dir); // @ M26_CHAMPION_ICON_INDEX
-	void f290_drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues
-	void f291_drawSlot(uint16 champIndex, int16 slotIndex); // @ F0291_CHAMPION_DrawSlot
-	void f281_renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename
-	uint16 f303_getSkillLevel(int16 champIndex, uint16 skillIndex);// @ F0303_CHAMPION_GetSkillLevel
-	Common::String f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger
-	void f299_applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex,
+	ChampionIndex getIndexInCell(int16 cell); // @ F0285_CHAMPION_GetIndexInCell
+	bool isLeaderHandObjectThrown(int16 side); // @ F0329_CHAMPION_IsLeaderHandObjectThrown
+	bool isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side); // @ F0328_CHAMPION_IsObjectThrown
+	void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
+	void addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty
+	void drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs
+	uint16 getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue
+	uint16 getMaximumLoad(Champion *champ); // @ F0309_CHAMPION_GetMaximumLoad
+	void drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState
+	uint16 getChampionIconIndex(int16 val, Direction dir); // @ M26_CHAMPION_ICON_INDEX
+	void drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues
+	void drawSlot(uint16 champIndex, int16 slotIndex); // @ F0291_CHAMPION_DrawSlot
+	void renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename
+	uint16 getSkillLevel(int16 champIndex, uint16 skillIndex);// @ F0303_CHAMPION_GetSkillLevel
+	Common::String getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger
+	void applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex,
 									int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics
-	bool f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged
-	void f296_drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons
-	void f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex); // @ F0301_CHAMPION_AddObjectInSlot
-	int16 f315_getScentOrdinal(int16 mapX, int16 mapY); // @ F0315_CHAMPION_GetScentOrdinal
-	Thing f298_getObjectRemovedFromLeaderHand(); // @ F0298_CHAMPION_GetObjectRemovedFromLeaderHand
-	uint16 f312_getStrength(int16 champIndex, int16 slotIndex); // @ F0312_CHAMPION_GetStrength 
-	Thing f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex); // @ F0300_CHAMPION_GetObjectRemovedFromSlot
-	void f325_decrementStamina(int16 championIndex, int16 decrement); // @ F0325_CHAMPION_DecrementStamina
-	int16 f321_addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds,
+	bool hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged
+	void drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons
+	void addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex); // @ F0301_CHAMPION_AddObjectInSlot
+	int16 getScentOrdinal(int16 mapX, int16 mapY); // @ F0315_CHAMPION_GetScentOrdinal
+	Thing getObjectRemovedFromLeaderHand(); // @ F0298_CHAMPION_GetObjectRemovedFromLeaderHand
+	uint16 getStrength(int16 champIndex, int16 slotIndex); // @ F0312_CHAMPION_GetStrength 
+	Thing getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex); // @ F0300_CHAMPION_GetObjectRemovedFromSlot
+	void decrementStamina(int16 championIndex, int16 decrement); // @ F0325_CHAMPION_DecrementStamina
+	int16 addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds,
 												   uint16 attackType); // @ F0321_CHAMPION_AddPendingDamageAndWounds_GetDamage
-	int16 f313_getWoundDefense(int16 champIndex, uint16 woundIndex); // @ F0313_CHAMPION_GetWoundDefense
-	uint16 f307_getStatisticAdjustedAttack(Champion *champ, uint16 statIndex, uint16 attack); // @ F0307_CHAMPION_GetStatisticAdjustedAttack
-	void f314_wakeUp(); // @ F0314_CHAMPION_WakeUp
-	int16 f305_getThrowingStaminaCost(Thing thing);// @ F0305_CHAMPION_GetThrowingStaminaCost
-	void f330_disableAction(uint16 champIndex, uint16 ticks); // @ F0330_CHAMPION_DisableAction
-	void f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp);// @ F0304_CHAMPION_AddSkillExperience
-	int16 f324_damageAll_getDamagedChampionCount(uint16 attack, int16 wounds,
+	int16 getWoundDefense(int16 champIndex, uint16 woundIndex); // @ F0313_CHAMPION_GetWoundDefense
+	uint16 getStatisticAdjustedAttack(Champion *champ, uint16 statIndex, uint16 attack); // @ F0307_CHAMPION_GetStatisticAdjustedAttack
+	void wakeUp(); // @ F0314_CHAMPION_WakeUp
+	int16 getThrowingStaminaCost(Thing thing);// @ F0305_CHAMPION_GetThrowingStaminaCost
+	void disableAction(uint16 champIndex, uint16 ticks); // @ F0330_CHAMPION_DisableAction
+	void addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp);// @ F0304_CHAMPION_AddSkillExperience
+	int16 getDamagedChampionCount(uint16 attack, int16 wounds,
 												 int16 attackType); // @ F0324_CHAMPION_DamageAll_GetDamagedChampionCount
-	int16 f286_getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell); // @ F0286_CHAMPION_GetTargetChampionIndex
-	int16 f311_getDexterity(Champion *champ); // @ F0311_CHAMPION_GetDexterity
-	bool f308_isLucky(Champion *champ, uint16 percentage); // @ F0308_CHAMPION_IsLucky
-	void f322_championPoison(int16 championIndex, uint16 attack); // @ F0322_CHAMPION_Poison
-	void f284_setPartyDirection(int16 dir); // @ F0284_CHAMPION_SetPartyDirection
-	void f316_deleteScent(uint16 scentIndex); // @ F0316_CHAMPION_DeleteScent
-	void f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount); // @ F0317_CHAMPION_AddScentStrength
-	void f297_putObjectInLeaderHand(Thing thing, bool setMousePointer); // @ F0297_CHAMPION_PutObjectInLeaderHand
-	int16 f310_getMovementTicks(Champion *champ); // @ F0310_CHAMPION_GetMovementTicks
-	bool f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex,
+	int16 getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell); // @ F0286_CHAMPION_GetTargetChampionIndex
+	int16 getDexterity(Champion *champ); // @ F0311_CHAMPION_GetDexterity
+	bool isLucky(Champion *champ, uint16 percentage); // @ F0308_CHAMPION_IsLucky
+	void championPoison(int16 championIndex, uint16 attack); // @ F0322_CHAMPION_Poison
+	void setPartyDirection(int16 dir); // @ F0284_CHAMPION_SetPartyDirection
+	void deleteScent(uint16 scentIndex); // @ F0316_CHAMPION_DeleteScent
+	void addScentStrength(int16 mapX, int16 mapY, int32 cycleCount); // @ F0317_CHAMPION_AddScentStrength
+	void putObjectInLeaderHand(Thing thing, bool setMousePointer); // @ F0297_CHAMPION_PutObjectInLeaderHand
+	int16 getMovementTicks(Champion *champ); // @ F0310_CHAMPION_GetMovementTicks
+	bool isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex,
 											   uint16 ammunitionSlotIndex); // @ F0294_CHAMPION_IsAmmunitionCompatibleWithWeapon
-	void f293_drawAllChampionStates(); // @ F0293_CHAMPION_DrawAllChampionStates
-	void f283_viAltarRebirth(uint16 champIndex); // @ F0283_CHAMPION_ViAltarRebirth
-	void f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex); // @ F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox
-	bool f327_isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount); // @ F0327_CHAMPION_IsProjectileSpellCast
-	void f326_championShootProjectile(Champion *champ, Thing thing, int16 kineticEnergy,
+	void drawAllChampionStates(); // @ F0293_CHAMPION_DrawAllChampionStates
+	void viAltarRebirth(uint16 champIndex); // @ F0283_CHAMPION_ViAltarRebirth
+	void clickOnSlotBox(uint16 slotBoxIndex); // @ F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox
+	bool isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount); // @ F0327_CHAMPION_IsProjectileSpellCast
+	void championShootProjectile(Champion *champ, Thing thing, int16 kineticEnergy,
 									  int16 attack, int16 stepEnergy); // @ F0326_CHAMPION_ShootProjectile
-	void f320_applyAndDrawPendingDamageAndWounds(); // @ F0320_CHAMPION_ApplyAndDrawPendingDamageAndWounds
-	void f319_championKill(uint16 champIndex); // @ F0319_CHAMPION_Kill
-	void f318_dropAllObjects(uint16 champIndex); // @ F0318_CHAMPION_DropAllObjects
-	void f323_unpoison(int16 champIndex); // @ F0323_CHAMPION_Unpoison
-	void f331_applyTimeEffects(); // @ F0331_CHAMPION_ApplyTimeEffects_CPSF
-	void save2_PartyPart(Common::OutSaveFile *file);
-	void load2_PartyPart(Common::InSaveFile* file);
-
+	void applyAndDrawPendingDamageAndWounds(); // @ F0320_CHAMPION_ApplyAndDrawPendingDamageAndWounds
+	void championKill(uint16 champIndex); // @ F0319_CHAMPION_Kill
+	void dropAllObjects(uint16 champIndex); // @ F0318_CHAMPION_DropAllObjects
+	void unpoison(int16 champIndex); // @ F0323_CHAMPION_Unpoison
+	void applyTimeEffects(); // @ F0331_CHAMPION_ApplyTimeEffects_CPSF
+	void savePartyPart2(Common::OutSaveFile *file);
+	void loadPartyPart2(Common::InSaveFile* file);
 
 	Box _boxChampionIcons[4];
 	Color _championColor[4];
diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index 31a0e13..a32bcb7 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -184,7 +184,7 @@ bool Console::Cmd_map(int argc, const char** argv) {
 		if (_vm->_g327_newPartyMapIndex == -1)
 			_vm->_g327_newPartyMapIndex = index;
 		_vm->_dungeonMan->f173_setCurrentMap(_vm->_g327_newPartyMapIndex);
-		_vm->_championMan->f284_setPartyDirection(_vm->_dungeonMan->f155_getStairsExitDirection(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY));
+		_vm->_championMan->setPartyDirection(_vm->_dungeonMan->f155_getStairsExitDirection(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY));
 		_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
 	} else
 		goto argumentError;
@@ -268,7 +268,7 @@ bool Console::Cmd_gimme(int argc, const char** argv) {
 						newThingData[thingCount * thingTypeSize + i] = newThingData[thingIndex * thingTypeSize + i];
 					_vm->_dungeonMan->_g278_dungeonFileHeader._thingCounts[thingType]++;
 					_vm->_dungeonMan->_g284_thingData[thingType] = newThingData;
-					_vm->_championMan->f301_addObjectInSlot((ChampionIndex)0, dummyThing, (ChampionSlot)29);
+					_vm->_championMan->addObjectInSlot((ChampionIndex)0, dummyThing, (ChampionSlot)29);
 					debugPrintf("Item gimmed to the first champion, last slot\n");
 					return true;
 				}
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index ceb3ae5..e4fa210 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -332,8 +332,8 @@ void DMEngine::f462_startGame() {
 	_g334_stopPressingMouth = false;
 	_g340_highlightBoxInversionRequested = false;
 	_eventMan->_g341_highlightBoxEnabled = false;
-	_championMan->_g300_partyIsSleeping = false;
-	_championMan->_g506_actingChampionOrdinal = M0_indexToOrdinal(kM1_ChampionNone);
+	_championMan->_partyIsSleeping = false;
+	_championMan->_actingChampionOrdinal = M0_indexToOrdinal(kM1_ChampionNone);
 	_menuMan->_g509_actionAreaContainsIcons = true;
 	_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = M0_indexToOrdinal(kM1_ChampionNone);
 
@@ -360,7 +360,7 @@ void DMEngine::f462_startGame() {
 
 	_displayMan->f508_buildPaletteChangeCopperList(_displayMan->_palDungeonView[0], _displayMan->_g347_paletteTopAndBottomScreen);
 	_menuMan->f395_drawMovementArrows();
-	_championMan->f278_resetDataToStartGame();
+	_championMan->resetDataToStartGame();
 	_g301_gameTimeTicking = true;
 }
 
@@ -402,7 +402,7 @@ Common::Error DMEngine::run() {
 			return Common::kNoError;
 
 		if (_loadSaveSlotAtRuntime == -1)
-			f444_endGame(_championMan->_g303_partyDead);
+			f444_endGame(_championMan->_partyDead);
 		else {
 			loadGameState(_loadSaveSlotAtRuntime);
 			_menuMan->f457_drawEnabledMenus();
@@ -424,8 +424,8 @@ void DMEngine::f2_gameloop() {
 		}
 
 		// DEBUG CODE
-		for (int16 i = 0; i < _championMan->_g305_partyChampionCount; ++i) {
-			Champion &champ = _championMan->_gK71_champions[i];
+		for (int16 i = 0; i < _championMan->_partyChampionCount; ++i) {
+			Champion &champ = _championMan->_champions[i];
 			if (_console->_debugGodmodeHP)
 				champ._currHealth = champ._maxHealth;
 			if (_console->_debugGodmodeMana)
@@ -449,7 +449,7 @@ void DMEngine::f2_gameloop() {
 				break;
 		}
 
-		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) {
+		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) {
 			Box box(0, 223, 0, 135);
 			_displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // (possibly dummy code)
 			_displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
@@ -469,8 +469,8 @@ void DMEngine::f2_gameloop() {
 		}
 		_eventMan->f363_highlightBoxDisable();
 		_sound->f65_playPendingSound();
-		_championMan->f320_applyAndDrawPendingDamageAndWounds();
-		if (_championMan->_g303_partyDead)
+		_championMan->applyAndDrawPendingDamageAndWounds();
+		if (_championMan->_partyDead)
 			break;
 
 		_g313_gameTime++;
@@ -478,13 +478,13 @@ void DMEngine::f2_gameloop() {
 		if (!(_g313_gameTime & 511))
 			_inventoryMan->f338_decreaseTorchesLightPower();
 
-		if (_championMan->_g407_party._freezeLifeTicks)
-			_championMan->_g407_party._freezeLifeTicks -= 1;
+		if (_championMan->_party._freezeLifeTicks)
+			_championMan->_party._freezeLifeTicks -= 1;
 
 		_menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived();
 
-		if (!(_g313_gameTime & (_championMan->_g300_partyIsSleeping ? 15 : 63)))
-			_championMan->f331_applyTimeEffects();
+		if (!(_g313_gameTime & (_championMan->_partyIsSleeping ? 15 : 63)))
+			_championMan->applyTimeEffects();
 
 		if (_g310_disabledMovementTicks)
 			_g310_disabledMovementTicks--;
@@ -661,9 +661,9 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 		if (_g302_gameWon) {
 			// Strangerke: Related to portraits. Game data could be missing for earlier versions of the game.
 			_displayMan->fillScreen(k12_ColorDarkestGray);
-			for (int16 championIndex = k0_ChampionFirst; championIndex < _championMan->_g305_partyChampionCount; championIndex++) {
+			for (int16 championIndex = k0_ChampionFirst; championIndex < _championMan->_partyChampionCount; championIndex++) {
 				int16 textPosY = championIndex * 48;
-				Champion *curChampion = &_championMan->_gK71_champions[championIndex];
+				Champion *curChampion = &_championMan->_champions[championIndex];
 				_displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k208_wallOrn_43_champMirror), &championMirrorBox, k32_byteWidth, k10_ColorFlesh, 43);
 				_displayMan->f21_blitToScreen(curChampion->_portrait, &championPortraitBox, k16_byteWidth, k1_ColorDarkGary, 29);
 				_textMan->f443_endgamePrintString(87, textPosY += 14, k9_ColorGold, curChampion->_name);
@@ -674,7 +674,7 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 
 				_textMan->f443_endgamePrintString(textPosX, textPosY++, k9_ColorGold, curChampion->_title);
 				for (int16 idx = k0_ChampionSkillFighter; idx <= k3_ChampionSkillWizard; idx++) {
-					uint16 skillLevel = MIN<uint16>(16, _championMan->f303_getSkillLevel(championIndex, idx | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience)));
+					uint16 skillLevel = MIN<uint16>(16, _championMan->getSkillLevel(championIndex, idx | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience)));
 					if (skillLevel == 1)
 						continue;
 
@@ -964,9 +964,9 @@ void DMEngine::f446_STARTEND_fuseSequnce() {
 		_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
 	}
 	_eventMan->f363_highlightBoxDisable();
-	_championMan->_g407_party._magicalLightAmount = 200;
+	_championMan->_party._magicalLightAmount = 200;
 	_inventoryMan->f337_setDungeonViewPalette();
-	_championMan->_g407_party._fireShieldDefense = _championMan->_g407_party._spellShieldDefense = _championMan->_g407_party._shieldDefense = 100;
+	_championMan->_party._fireShieldDefense = _championMan->_party._spellShieldDefense = _championMan->_party._shieldDefense = 100;
 	_timeline->f260_timelineRefreshAllChampionStatusBoxes();
 	f445_STARTEND_fuseSequenceUpdate();
 	L1431_i_LordChaosMapX = _dungeonMan->_g306_partyMapX;
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 287c454..f9d649a 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -949,7 +949,7 @@ T0172010_ClosedFakeWall:
 			curThing = f159_getNextThing(curThing);
 		}
 
-		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapX, mapY)) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_g407_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_g407_party._lastScentIndex))
+		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapX, mapY)) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_party._lastScentIndex))
 			setFlag(aspectArray[k4_FloorOrnOrdAspect], k0x8000_FootprintsAspect);
 
 		break;
@@ -973,7 +973,7 @@ T0172010_ClosedFakeWall:
 		while ((curThing != Thing::_endOfList) && (curThing.getType() <= k3_SensorThingType))
 			curThing = f159_getNextThing(curThing);
 
-		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapX, mapY)) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_g407_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_g407_party._lastScentIndex))
+		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapX, mapY)) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_party._lastScentIndex))
 			setFlag(aspectArray[k4_FloorOrnOrdAspect], k0x8000_FootprintsAspect);
 		break;
 	}
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 8ad7971..c152876 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -533,7 +533,7 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY)
 	else if (mousePosY <= 28) {
 		uint16 championIdx = mousePosX / 69;
 		uint16 xOverChampionStatusBox = mousePosX % 69;
-		if (championIdx >= _vm->_championMan->_g305_partyChampionCount)
+		if (championIdx >= _vm->_championMan->_partyChampionCount)
 			_gK104_mousePointerType = k4_pointerTypeAutoselect;
 		else if (xOverChampionStatusBox > 42)
 			_gK104_mousePointerType = k4_pointerTypeAutoselect;
@@ -576,8 +576,8 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY)
 }
 
 void EventManager::f69_setMousePointer() {
-	if (_vm->_championMan->_g415_leaderEmptyHanded)
-		f67_setMousePointerToNormal((_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
+	if (_vm->_championMan->_leaderEmptyHanded)
+		f67_setMousePointerToNormal((_vm->_championMan->_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
 	else
 		f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
 }
@@ -750,7 +750,7 @@ void EventManager::f380_processCommandQueue() {
 
 	if ((cmdType >= k12_CommandClickInChampion_0_StatusBox) && (cmdType <= k15_CommandClickInChampion_3_StatusBox)) {
 		int16 championIdx = cmdType - k12_CommandClickInChampion_0_StatusBox;
-		if ((championIdx < _vm->_championMan->_g305_partyChampionCount) && !_vm->_championMan->_g299_candidateChampionOrdinal)
+		if ((championIdx < _vm->_championMan->_partyChampionCount) && !_vm->_championMan->_candidateChampionOrdinal)
 			f367_commandProcessTypes12to27_clickInChampionStatusBox(championIdx, commandX, commandY);
 
 		return;
@@ -763,8 +763,8 @@ void EventManager::f380_processCommandQueue() {
 	}
 
 	if ((cmdType >= k28_CommandClickOnSlotBoxInventoryReadyHand) && (cmdType < (k65_CommandClickOnSlotBoxChest_8 + 1))) {
-		if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone)
-			_vm->_championMan->f302_processCommands28to65_clickOnSlotBox(cmdType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
+		if (_vm->_championMan->_leaderIndex != kM1_ChampionNone)
+			_vm->_championMan->clickOnSlotBox(cmdType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
 
 		return;
 	}
@@ -779,28 +779,28 @@ void EventManager::f380_processCommandQueue() {
 		}
 
 		int16 championIndex = cmdType - k7_CommandToggleInventoryChampion_0;
-		if (((championIndex == k4_ChampionCloseInventory) || (championIndex < _vm->_championMan->_g305_partyChampionCount)) && !_vm->_championMan->_g299_candidateChampionOrdinal)
+		if (((championIndex == k4_ChampionCloseInventory) || (championIndex < _vm->_championMan->_partyChampionCount)) && !_vm->_championMan->_candidateChampionOrdinal)
 			_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)championIndex);
 
 		return;
 	}
 
 	if (cmdType == k83_CommandToggleInventoryLeader) {
-		if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone)
-			_vm->_inventoryMan->f355_toggleInventory(_vm->_championMan->_g411_leaderIndex);
+		if (_vm->_championMan->_leaderIndex != kM1_ChampionNone)
+			_vm->_inventoryMan->f355_toggleInventory(_vm->_championMan->_leaderIndex);
 
 		return;
 	}
 
 	if (cmdType == k100_CommandClickInSpellArea) {
-		if ((!_vm->_championMan->_g299_candidateChampionOrdinal) && (_vm->_championMan->_g514_magicCasterChampionIndex != kM1_ChampionNone))
+		if ((!_vm->_championMan->_candidateChampionOrdinal) && (_vm->_championMan->_magicCasterChampionIndex != kM1_ChampionNone))
 			f370_commandProcessType100_clickInSpellArea(commandX, commandY);
 
 		return;
 	}
 
 	if (cmdType == k111_CommandClickInActionArea) {
-		if (!_vm->_championMan->_g299_candidateChampionOrdinal)
+		if (!_vm->_championMan->_candidateChampionOrdinal)
 			f371_commandProcessType111To115_ClickInActionArea(commandX, commandY);
 
 		return;
@@ -829,12 +829,12 @@ void EventManager::f380_processCommandQueue() {
 		return;
 
 	if (cmdType == k145_CommandSleep) {
-		if (!_vm->_championMan->_g299_candidateChampionOrdinal) {
+		if (!_vm->_championMan->_candidateChampionOrdinal) {
 			if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal)
 				_vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
 
 			_vm->_menuMan->f456_drawDisabledMenu();
-			_vm->_championMan->_g300_partyIsSleeping = true;
+			_vm->_championMan->_partyIsSleeping = true;
 			f379_drawSleepScreen();
 			_vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
 			_vm->_g318_waitForInputMaxVerticalBlankCount = 0;
@@ -848,12 +848,12 @@ void EventManager::f380_processCommandQueue() {
 	}
 
 	if (cmdType == k146_CommandWakeUp) {
-		_vm->_championMan->f314_wakeUp();
+		_vm->_championMan->wakeUp();
 		return;
 	}
 
 	if (cmdType == k140_CommandSaveGame) {
-		if ((_vm->_championMan->_g305_partyChampionCount > 0) && !_vm->_championMan->_g299_candidateChampionOrdinal)
+		if ((_vm->_championMan->_partyChampionCount > 0) && !_vm->_championMan->_candidateChampionOrdinal)
 			_vm->f433_processCommand140_saveGame();
 
 		return;
@@ -941,7 +941,7 @@ void EventManager::f365_commandTurnParty(CommandType cmdType) {
 	}
 
 	_vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, false);
-	_vm->_championMan->f284_setPartyDirection(M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + ((cmdType == k2_CommandTurnRight) ? 1 : 3)));
+	_vm->_championMan->setPartyDirection(M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + ((cmdType == k2_CommandTurnRight) ? 1 : 3)));
 	_vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, true);
 }
 
@@ -969,9 +969,9 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	};
 
 	_vm->_g321_stopWaitingForPlayerInput = true;
-	Champion *championsPtr = _vm->_championMan->_gK71_champions;
-	for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_g305_partyChampionCount; idx++) {
-		_vm->_championMan->f325_decrementStamina(idx, ((championsPtr->_load * 3) / _vm->_championMan->f309_getMaximumLoad(championsPtr)) + 1); /* BUG0_50 When a champion is brought back to life at a Vi Altar, his current stamina is lower than what it was before dying. Each time the party moves the current stamina of all champions is decreased, including for dead champions, by an amount that depends on the current load of the champion. For a dead champion the load before he died is used */
+	Champion *championsPtr = _vm->_championMan->_champions;
+	for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_partyChampionCount; idx++) {
+		_vm->_championMan->decrementStamina(idx, ((championsPtr->_load * 3) / _vm->_championMan->getMaximumLoad(championsPtr)) + 1); /* BUG0_50 When a champion is brought back to life at a Vi Altar, his current stamina is lower than what it was before dying. Each time the party moves the current stamina of all champions is decreased, including for dead champions, by an amount that depends on the current load of the champion. For a dead champion the load before he died is used */
 		championsPtr++;
 	}
 	uint16 movementArrowIdx = cmdType - k3_CommandMoveForward;
@@ -1004,14 +1004,14 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	} else if (partySquareType == k6_ElementTypeFakeWall)
 		isMovementBlocked = (!getFlag(AL1115_ui_Square, k0x0004_FakeWallOpen) && !getFlag(AL1115_ui_Square, k0x0001_FakeWallImaginary));
 
-	if (_vm->_championMan->_g305_partyChampionCount) {
+	if (_vm->_championMan->_partyChampionCount) {
 		if (isMovementBlocked) {
 			movementArrowIdx += (_vm->_dungeonMan->_g308_partyDir + 2);
-			int16 L1124_i_FirstDamagedChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(partyMapX, partyMapY, M21_normalizeModulo4(movementArrowIdx));
-			int16 L1125_i_SecondDamagedChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(partyMapX, partyMapY, returnNextVal(movementArrowIdx));
-			int16 damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
+			int16 L1124_i_FirstDamagedChampionIndex = _vm->_championMan->getTargetChampionIndex(partyMapX, partyMapY, M21_normalizeModulo4(movementArrowIdx));
+			int16 L1125_i_SecondDamagedChampionIndex = _vm->_championMan->getTargetChampionIndex(partyMapX, partyMapY, returnNextVal(movementArrowIdx));
+			int16 damage = _vm->_championMan->addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
 			if (L1124_i_FirstDamagedChampionIndex != L1125_i_SecondDamagedChampionIndex)
-				damage |= _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
+				damage |= _vm->_championMan->addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
 
 			if (damage)
 				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, partyMapX, partyMapY, k0_soundModePlayImmediately);
@@ -1035,10 +1035,10 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, partyMapX, partyMapY);
 
 	uint16 disabledMovtTicks = 1;
-	championsPtr = _vm->_championMan->_gK71_champions;
-	for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_g305_partyChampionCount; idx++) {
+	championsPtr = _vm->_championMan->_champions;
+	for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_partyChampionCount; idx++) {
 		if (championsPtr->_currHealth)
-			disabledMovtTicks = MAX((int32)disabledMovtTicks, (int32)_vm->_championMan->f310_getMovementTicks(championsPtr));
+			disabledMovtTicks = MAX((int32)disabledMovtTicks, (int32)_vm->_championMan->getMovementTicks(championsPtr));
 
 		championsPtr++;
 	}
@@ -1062,7 +1062,7 @@ bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int
 			return false;
 
 		// Strangerke: Only present in CSB2.1... But it fixes a bug so we keep it
-		objectThrownFl = _vm->_championMan->f329_isLeaderHandObjectThrown(k0_sideLeft);
+		objectThrownFl = _vm->_championMan->isLeaderHandObjectThrown(k0_sideLeft);
 	} else {
 		if (_vm->_dungeonMan->_g285_squareAheadElement == k17_ElementTypeDoorFront) {
 			if (posX > 163)
@@ -1070,7 +1070,7 @@ bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int
 		} else if (posX > 191)
 			return false;
 
-		objectThrownFl = _vm->_championMan->f329_isLeaderHandObjectThrown(k1_sideRight);
+		objectThrownFl = _vm->_championMan->isLeaderHandObjectThrown(k1_sideRight);
 	}
 
 	if (objectThrownFl)
@@ -1105,29 +1105,29 @@ void EventManager::f368_commandSetLeader(ChampionIndex champIndex) {
 	ChampionMan &cm = *_vm->_championMan;
 	ChampionIndex leaderIndex;
 
-	if ((cm._g411_leaderIndex == champIndex) || ((champIndex != kM1_ChampionNone) && !cm._gK71_champions[champIndex]._currHealth))
+	if ((cm._leaderIndex == champIndex) || ((champIndex != kM1_ChampionNone) && !cm._champions[champIndex]._currHealth))
 		return;
 
-	if (cm._g411_leaderIndex != kM1_ChampionNone) {
-		leaderIndex = cm._g411_leaderIndex;
-		cm._gK71_champions[leaderIndex].setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
-		cm._gK71_champions[leaderIndex].setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
-		cm._gK71_champions[leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(cm._g414_leaderHandObject);
-		cm._g411_leaderIndex = kM1_ChampionNone;
-		cm.f292_drawChampionState(leaderIndex);
+	if (cm._leaderIndex != kM1_ChampionNone) {
+		leaderIndex = cm._leaderIndex;
+		cm._champions[leaderIndex].setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
+		cm._champions[leaderIndex].setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
+		cm._champions[leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(cm._leaderHandObject);
+		cm._leaderIndex = kM1_ChampionNone;
+		cm.drawChampionState(leaderIndex);
 	}
 	if (champIndex == kM1_ChampionNone) {
-		cm._g411_leaderIndex = kM1_ChampionNone;
+		cm._leaderIndex = kM1_ChampionNone;
 		return;
 	}
-	cm._g411_leaderIndex = champIndex;
-	Champion *champion = &cm._gK71_champions[cm._g411_leaderIndex];
+	cm._leaderIndex = champIndex;
+	Champion *champion = &cm._champions[cm._leaderIndex];
 	champion->_dir = _vm->_dungeonMan->_g308_partyDir;
-	cm._gK71_champions[champIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(cm._g414_leaderHandObject);
-	if (_vm->M0_indexToOrdinal(champIndex) != cm._g299_candidateChampionOrdinal) {
+	cm._champions[champIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(cm._leaderHandObject);
+	if (_vm->M0_indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) {
 		champion->setAttributeFlag(k0x0400_ChampionAttributeIcon, true);
 		champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
-		cm.f292_drawChampionState(champIndex);
+		cm.drawChampionState(champIndex);
 	}
 }
 
@@ -1150,13 +1150,13 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 	};
 
 	if (_vm->_dungeonMan->_g285_squareAheadElement == k17_ElementTypeDoorFront) {
-		if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone)
+		if (_vm->_championMan->_leaderIndex == kM1_ChampionNone)
 			return;
 
 		int16 L1155_i_MapX = _vm->_dungeonMan->_g306_partyMapX + _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir];
 		int16 L1156_i_MapY = _vm->_dungeonMan->_g307_partyMapY + _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
 
-		if (_vm->_championMan->_g415_leaderEmptyHanded) {
+		if (_vm->_championMan->_leaderEmptyHanded) {
 			Junk *junkPtr = (Junk*)_vm->_dungeonMan->f157_getSquareFirstThingData(L1155_i_MapX, L1156_i_MapY);
 			if ((((Door*)junkPtr)->hasButton()) && _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
 				_vm->_g321_stopWaitingForPlayerInput = true;
@@ -1168,7 +1168,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 			return;
 	}
 
-	if (_vm->_championMan->_g415_leaderEmptyHanded) {
+	if (_vm->_championMan->_leaderEmptyHanded) {
 		for (uint16 currViewCell = k0_ViewCellFronLeft; currViewCell < k5_ViewCellDoorButtonOrWallOrn + 1; currViewCell++) {
 			if (_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[currViewCell].isPointInside(posX, posY - 33)) {
 				if (currViewCell == k5_ViewCellDoorButtonOrWallOrn) {
@@ -1181,7 +1181,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 			}
 		}
 	} else {
-		Thing thingHandObject = _vm->_championMan->_g414_leaderHandObject;
+		Thing thingHandObject = _vm->_championMan->_leaderHandObject;
 		Junk *junkPtr = (Junk*)_vm->_dungeonMan->f156_getThingData(thingHandObject);
 		if (_vm->_dungeonMan->_g285_squareAheadElement == k0_ElementTypeWall) {
 			for (uint16 currViewCell = k0_ViewCellFronLeft; currViewCell < k1_ViewCellFrontRight + 1; currViewCell++) {
@@ -1205,8 +1205,8 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 							f372_commandProcessType80ClickInDungeonViewTouchFrontWall();
 							return;
 						}
-						_vm->_championMan->f296_drawChangedObjectIcons();
-						_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thingHandObject) - weight;
+						_vm->_championMan->drawChangedObjectIcons();
+						_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thingHandObject) - weight;
 					}
 					f372_commandProcessType80ClickInDungeonViewTouchFrontWall();
 				}
@@ -1231,15 +1231,15 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 	DisplayMan &dispMan = *_vm->_displayMan;
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 
-	uint16 championIndex = champMan._g305_partyChampionCount - 1;
-	Champion *champ = &champMan._gK71_champions[championIndex];
+	uint16 championIndex = champMan._partyChampionCount - 1;
+	Champion *champ = &champMan._champions[championIndex];
 	if (commandType == k162_CommandClickInPanelCancel) {
 		invMan.f355_toggleInventory(k4_ChampionCloseInventory);
-		champMan._g299_candidateChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
-		if (champMan._g305_partyChampionCount == 1) {
+		champMan._candidateChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+		if (champMan._partyChampionCount == 1) {
 			f368_commandSetLeader(kM1_ChampionNone);
 		}
-		champMan._g305_partyChampionCount--;
+		champMan._partyChampionCount--;
 		Box box;
 		box._y1 = 0;
 		box._y2 = 28;
@@ -1247,13 +1247,13 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 		box._x2 = box._x1 + 66;
 		dispMan._g578_useByteBoxCoordinates = false;
 		dispMan.D24_fillScreenBox(box, k0_ColorBlack);
-		dispMan.D24_fillScreenBox(_vm->_championMan->_boxChampionIcons[champMan.M26_championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2], k0_ColorBlack);
+		dispMan.D24_fillScreenBox(_vm->_championMan->_boxChampionIcons[champMan.getChampionIconIndex(champ->_cell, dunMan._g308_partyDir) * 2], k0_ColorBlack);
 		_vm->_menuMan->f457_drawEnabledMenus();
 		f78_showMouse();
 		return;
 	}
 
-	champMan._g299_candidateChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+	champMan._candidateChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
 	int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
 	int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
 
@@ -1273,7 +1273,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 	}
 
 	if (commandType == k161_CommandClickInPanelReincarnate) {
-		champMan.f281_renameChampion(champ);
+		champMan.renameChampion(champ);
 		if (_vm->_engineShouldQuit)
 			return;
 		champ->resetSkillsToZero();
@@ -1285,12 +1285,12 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 		}
 	}
 
-	if (champMan._g305_partyChampionCount == 1) {
+	if (champMan._partyChampionCount == 1) {
 		_vm->_projexpl->_g362_lastPartyMovementTime = _vm->_g313_gameTime;
 		f368_commandSetLeader(k0_ChampionFirst);
 		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(k0_ChampionFirst);
 	} else
-		_vm->_menuMan->f393_drawSpellAreaControls(champMan._g514_magicCasterChampionIndex);
+		_vm->_menuMan->f393_drawSpellAreaControls(champMan._magicCasterChampionIndex);
 
 	_vm->_textMan->f51_messageAreaPrintLineFeed();
 	Color champColor = _vm->_championMan->_championColor[championIndex];
@@ -1311,7 +1311,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 
 	invMan.f355_toggleInventory(k4_ChampionCloseInventory);
 	_vm->_menuMan->f457_drawEnabledMenus();
-	f67_setMousePointerToNormal((_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
+	f67_setMousePointerToNormal((_vm->_championMan->_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
 }
 
 void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) {
@@ -1321,14 +1321,14 @@ void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) {
 	CommandType commandType;
 	switch (invMan._g424_panelContent) {
 	case k4_PanelContentChest:
-		if (champMan._g411_leaderIndex == kM1_ChampionNone) // if no leader
+		if (champMan._leaderIndex == kM1_ChampionNone) // if no leader
 			return;
 		commandType = f358_getCommandTypeFromMouseInput(_mouseInputPanelChest, Common::Point(x, y), k1_LeftMouseButton);
 		if (commandType != k0_CommandNone)
-			_vm->_championMan->f302_processCommands28to65_clickOnSlotBox(commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
+			_vm->_championMan->clickOnSlotBox(commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
 		break;
 	case k5_PanelContentResurrectReincarnate:
-		if (!champMan._g415_leaderEmptyHanded)
+		if (!champMan._leaderEmptyHanded)
 			break;
 		commandType = f358_getCommandTypeFromMouseInput(_mouseInputPanelResurrectReincarnateCancel, Common::Point(x, y), k1_LeftMouseButton);
 		if (commandType != k0_CommandNone)
@@ -1340,7 +1340,7 @@ void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) {
 }
 
 void EventManager::f373_processType80_clickInDungeonView_grabLeaderHandObject(uint16 viewCell) {
-	if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone)
+	if (_vm->_championMan->_leaderIndex == kM1_ChampionNone)
 		return;
 
 	int16 mapX = _vm->_dungeonMan->_g306_partyMapX;
@@ -1358,14 +1358,14 @@ void EventManager::f373_processType80_clickInDungeonView_grabLeaderHandObject(ui
 	Thing topPileThing = _vm->_dungeonMan->_g292_pileTopObject[viewCell];
 	if (_vm->_objectMan->f33_getIconIndex(topPileThing) != kM1_IconIndiceNone) {
 		_vm->_moveSens->f267_getMoveResult(topPileThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
-		_vm->_championMan->f297_putObjectInLeaderHand(topPileThing, true);
+		_vm->_championMan->putObjectInLeaderHand(topPileThing, true);
 	}
 
 	_vm->_g321_stopWaitingForPlayerInput = true;
 }
 
 void EventManager::f374_processType80_clickInDungeonViewDropLeaderHandObject(uint16 viewCell) {
-	if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone)
+	if (_vm->_championMan->_leaderIndex == kM1_ChampionNone)
 		return;
 
 	int16 mapX = _vm->_dungeonMan->_g306_partyMapX;
@@ -1378,7 +1378,7 @@ void EventManager::f374_processType80_clickInDungeonViewDropLeaderHandObject(uin
 		mapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], mapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
 
 	uint16 currCell = M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + viewCell);
-	Thing removedThing = _vm->_championMan->f298_getObjectRemovedFromLeaderHand();
+	Thing removedThing = _vm->_championMan->getObjectRemovedFromLeaderHand();
 	_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(removedThing, currCell), kM1_MapXNotOnASquare, 0, mapX, mapY);
 	if (droppingIntoAnAlcove && _vm->_dungeonMan->_g287_isFacingViAltar && (_vm->_objectMan->f33_getIconIndex(removedThing) == k147_IconIndiceJunkChampionBones)) {
 		Junk *removedJunk = (Junk*)_vm->_dungeonMan->f156_getThingData(removedThing);
@@ -1431,7 +1431,7 @@ void EventManager::f364_commandTakeStairs(bool stairsGoDown) {
 	_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0);
 	_vm->_g327_newPartyMapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g309_partyMapIndex, stairsGoDown ? -1 : 1, &_vm->_dungeonMan->_g306_partyMapX, &_vm->_dungeonMan->_g307_partyMapY);
 	_vm->_dungeonMan->f173_setCurrentMap(_vm->_g327_newPartyMapIndex);
-	_vm->_championMan->f284_setPartyDirection(_vm->_dungeonMan->f155_getStairsExitDirection(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY));
+	_vm->_championMan->setPartyDirection(_vm->_dungeonMan->f155_getStairsExitDirection(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY));
 	_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
 }
 
@@ -1443,7 +1443,7 @@ void EventManager::f367_commandProcessTypes12to27_clickInChampionStatusBox(uint1
 		if ((commandType >= k16_CommandSetLeaderChampion_0) && (commandType <= k19_CommandSetLeaderChampion_3))
 			f368_commandSetLeader((ChampionIndex)(commandType - k16_CommandSetLeaderChampion_0));
 		else if ((commandType >= k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand) && (commandType <= k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand))
-			_vm->_championMan->f302_processCommands28to65_clickOnSlotBox(commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
+			_vm->_championMan->clickOnSlotBox(commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
 	}
 }
 
@@ -1454,7 +1454,7 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 
 	_gK100_preventBuildPointerScreenArea = true;
 	if (!_g599_useChampionIconOrdinalAsMousePointerBitmap) {
-		if (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir)) == kM1_ChampionNone) {
+		if (_vm->_championMan->getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir)) == kM1_ChampionNone) {
 			_gK100_preventBuildPointerScreenArea = false;
 			return;
 		}
@@ -1474,22 +1474,22 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 		_g598_mousePointerBitmapUpdated = true;
 		uint16 championIconIndex = _vm->M1_ordinalToIndex(_g599_useChampionIconOrdinalAsMousePointerBitmap);
 		_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
-		int16 championCellIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(championIconIndex + _vm->_dungeonMan->_g308_partyDir));
+		int16 championCellIndex = _vm->_championMan->getIndexInCell(M21_normalizeModulo4(championIconIndex + _vm->_dungeonMan->_g308_partyDir));
 		if (championIconIndex == champIconIndex) {
-			setFlag(_vm->_championMan->_gK71_champions[championCellIndex]._attributes, k0x0400_ChampionAttributeIcon);
-			_vm->_championMan->f292_drawChampionState((ChampionIndex)championCellIndex);
+			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, k0x0400_ChampionAttributeIcon);
+			_vm->_championMan->drawChampionState((ChampionIndex)championCellIndex);
 		} else {
-			int16 championIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir));
+			int16 championIndex = _vm->_championMan->getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir));
 			if (championIndex >= 0) {
-				_vm->_championMan->_gK71_champions[championIndex]._cell = (ViewCell)M21_normalizeModulo4(championIconIndex + _vm->_dungeonMan->_g308_partyDir);
-				setFlag(_vm->_championMan->_gK71_champions[championIndex]._attributes, k0x0400_ChampionAttributeIcon);
-				_vm->_championMan->f292_drawChampionState((ChampionIndex)championIndex);
+				_vm->_championMan->_champions[championIndex]._cell = (ViewCell)M21_normalizeModulo4(championIconIndex + _vm->_dungeonMan->_g308_partyDir);
+				setFlag(_vm->_championMan->_champions[championIndex]._attributes, k0x0400_ChampionAttributeIcon);
+				_vm->_championMan->drawChampionState((ChampionIndex)championIndex);
 			} else
 				_vm->_displayMan->D24_fillScreenBox(_vm->_championMan->_boxChampionIcons[championIconIndex], k0_ColorBlack);
 
-			_vm->_championMan->_gK71_champions[championCellIndex]._cell = (ViewCell)M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir);
-			setFlag(_vm->_championMan->_gK71_champions[championCellIndex]._attributes, k0x0400_ChampionAttributeIcon);
-			_vm->_championMan->f292_drawChampionState((ChampionIndex)championCellIndex);
+			_vm->_championMan->_champions[championCellIndex]._cell = (ViewCell)M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir);
+			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, k0x0400_ChampionAttributeIcon);
+			_vm->_championMan->drawChampionState((ChampionIndex)championCellIndex);
 		}
 	}
 	_gK100_preventBuildPointerScreenArea = false;
@@ -1499,7 +1499,7 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 void EventManager::f370_commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY) {
 	int16 championIndex = kM1_ChampionNone;
 	if (posY <= 48) {
-		switch (_vm->_championMan->_g514_magicCasterChampionIndex) {
+		switch (_vm->_championMan->_magicCasterChampionIndex) {
 		case 0:
 			if ((posX >= 280) && (posX <= 291))
 				championIndex = 1;
@@ -1539,7 +1539,7 @@ void EventManager::f370_commandProcessType100_clickInSpellArea(uint16 posX, uint
 			break;
 		}
 
-		if ((championIndex != kM1_ChampionNone) && (championIndex < _vm->_championMan->_g305_partyChampionCount))
+		if ((championIndex != kM1_ChampionNone) && (championIndex < _vm->_championMan->_partyChampionCount))
 			_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(championIndex);
 
 		return;
@@ -1562,7 +1562,7 @@ void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(Comm
 		Box(305, 318, 63, 73)}; /* Delete */
 
 	if (cmdType == k108_CommandClickInSpeallAreaCastSpell) {
-		if (_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex]._symbols[0] == '\0')
+		if (_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex]._symbols[0] == '\0')
 			return;
 
 		f362_commandHighlightBoxEnable(234, 303, 63, 73);
@@ -1583,7 +1583,7 @@ void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(Comm
 }
 
 void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY) {
-	if (_vm->_championMan->_g506_actingChampionOrdinal) {
+	if (_vm->_championMan->_actingChampionOrdinal) {
 		uint16 mouseCommand = f358_getCommandTypeFromMouseInput(_mouseInputActionAreaNames, Common::Point(posX, posY), k1_LeftMouseButton);
 		if (mouseCommand != k0_CommandNone) {
 			if (mouseCommand == k112_CommandClickInActionAreaPass) {
@@ -1604,7 +1604,7 @@ void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX,
 		uint16 mouseCommand = f358_getCommandTypeFromMouseInput(_mouseInputActionAreaIcons, Common::Point(posX, posY), k1_LeftMouseButton);
 		if (mouseCommand != k0_CommandNone) {
 			mouseCommand -= k116_CommandClickInActionAreaChampion_0_Action;
-			if (mouseCommand < _vm->_championMan->_g305_partyChampionCount)
+			if (mouseCommand < _vm->_championMan->_partyChampionCount)
 				_vm->_menuMan->f389_processCommands116To119_setActingChampion(mouseCommand);
 		}
 	}
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 5c4bb7e..10baee8 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1068,7 +1068,7 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d
 			f131_flipVertical(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
 	}
 
-	if ((doorFramesTemp == _doorFrameD1C) && _vm->_championMan->_g407_party._event73Count_ThievesEye)
+	if ((doorFramesTemp == _doorFrameD1C) && _vm->_championMan->_party._event73Count_ThievesEye)
 		f109_drawDoorOrnament(_vm->M0_indexToOrdinal(k16_DoorOrnThivesEyeMask), k2_ViewDoorOrnament_D1LCR);
 
 	if (doorState == k4_doorState_CLOSED)
@@ -1887,7 +1887,7 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 		_vm->_dungeonMan->_g286_isFacingAlcove = false;
 		_vm->_dungeonMan->_g287_isFacingViAltar = false;
 		_vm->_dungeonMan->_g288_isFacingFountain = false;
-		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
+		if (_vm->_championMan->_party._event73Count_ThievesEye) {
 			f491_isDerivedBitmapInCache(k1_DerivedBitmapThievesEyeVisibleArea);
 			f132_blitToBitmap(_g296_bitmapViewport, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
 							  boxThievesEyeVisibleArea, _boxThievesEyeViewPortVisibleArea._x1, _boxThievesEyeViewPortVisibleArea._y1,
@@ -1900,7 +1900,7 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT))
 			f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, k0x0000_CellOrder_Alcove);
 
-		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
+		if (_vm->_championMan->_party._event73Count_ThievesEye) {
 			f132_blitToBitmap(f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
 							  _g296_bitmapViewport, _boxThievesEyeViewPortVisibleArea, 0, 0,
 							  48, k112_byteWidthViewport, k9_ColorGold, 95, k136_heightViewport); /* BUG0_74 */
@@ -2018,7 +2018,7 @@ void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k16_DoorSideElemType:
-		if (_vm->_championMan->_g407_party._event73Count_ThievesEye) {
+		if (_vm->_championMan->_party._event73Count_ThievesEye) {
 			memmove(_g74_tmpBitmap, _g709_bitmapWallSet_DoorFrameFront, 32 * 123);
 			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice),
 							  _g74_tmpBitmap, boxThievesEyeHoleInDoorFrame, doorFrameD0C._box._x1 - _boxThievesEyeViewPortVisibleArea._x1,
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index c9f7e30..4b30d2f 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -686,7 +686,7 @@ T0209005_AddEventAndReturn:
 	if (L0461_i_MovementTicks == k255_immobile)
 		L0461_i_MovementTicks = 100;
 
-	if (_vm->_championMan->_g407_party._freezeLifeTicks && !L0463_B_Archenemy) { /* If life is frozen and the creature is not Lord Chaos (Lord Chaos is immune to Freeze Life) then reschedule the event later (except for reactions which are ignored when life if frozen) */
+	if (_vm->_championMan->_party._freezeLifeTicks && !L0463_B_Archenemy) { /* If life is frozen and the creature is not Lord Chaos (Lord Chaos is immune to Freeze Life) then reschedule the event later (except for reactions which are ignored when life if frozen) */
 		if (eventType < 0)
 			goto T0209139_Return;
 		L0465_s_NextEvent._type = eventType;
@@ -1180,7 +1180,7 @@ int16 GroupMan::f200_groupGetDistanceToVisibleParty(Group *group, int16 creature
 
 
 	L0424_ps_CreatureInfo = &g243_CreatureInfo[group->_type];
-	if (_vm->_championMan->_g407_party._event71Count_Invisibility && !getFlag(L0424_ps_CreatureInfo->_attributes, k0x0800_MaskCreatureInfo_seeInvisible)) {
+	if (_vm->_championMan->_party._event71Count_Invisibility && !getFlag(L0424_ps_CreatureInfo->_attributes, k0x0800_MaskCreatureInfo_seeInvisible)) {
 		return 0;
 	}
 	if (getFlag(L0424_ps_CreatureInfo->_attributes, k0x0004_MaskCreatureInfo_sideAttack)) /* If creature can see in all directions */
@@ -1402,8 +1402,8 @@ int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo
 		_vm->_projexpl->_g363_secondaryDirToOrFromParty = _g383_currGroupSecondaryDirToParty;
 		return _vm->M0_indexToOrdinal(_g382_currGroupPrimaryDirToParty);
 	}
-	if ((L0427_i_ScentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapY, mapX)) && ((_vm->_championMan->_g407_party._scentStrengths[_vm->M1_ordinalToIndex(L0427_i_ScentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (L0426_ui_SmellRange << 1)))) { /* If there is a fresh enough party scent on the group square */
-		return _vm->M0_indexToOrdinal(f228_getDirsWhereDestIsVisibleFromSource(mapY, mapX, _vm->_championMan->_g407_party._scents[L0427_i_ScentOrdinal].getMapX(), _vm->_championMan->_g407_party._scents[L0427_i_ScentOrdinal].getMapY()));
+	if ((L0427_i_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapY, mapX)) && ((_vm->_championMan->_party._scentStrengths[_vm->M1_ordinalToIndex(L0427_i_ScentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (L0426_ui_SmellRange << 1)))) { /* If there is a fresh enough party scent on the group square */
+		return _vm->M0_indexToOrdinal(f228_getDirsWhereDestIsVisibleFromSource(mapY, mapX, _vm->_championMan->_party._scents[L0427_i_ScentOrdinal].getMapX(), _vm->_championMan->_party._scents[L0427_i_ScentOrdinal].getMapY()));
 	}
 	return 0;
 }
@@ -1531,14 +1531,14 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 	} else {
 		if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) {
 			AL0439_i_ChampionIndex = _vm->getRandomNumber(4);
-			for (AL0440_i_Counter = 0; (AL0440_i_Counter < 4) && !_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex]._currHealth; AL0440_i_Counter++) {
+			for (AL0440_i_Counter = 0; (AL0440_i_Counter < 4) && !_vm->_championMan->_champions[AL0439_i_ChampionIndex]._currHealth; AL0440_i_Counter++) {
 				AL0439_i_ChampionIndex = returnNextVal(AL0439_i_ChampionIndex);
 			}
 			if (AL0440_i_Counter == 4) {
 				return false;
 			}
 		} else {
-			if ((AL0439_i_ChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(mapX, mapY, AL0439_i_TargetCell)) < 0) {
+			if ((AL0439_i_ChampionIndex = _vm->_championMan->getTargetChampionIndex(mapX, mapY, AL0439_i_TargetCell)) < 0) {
 				return false;
 			}
 		}
@@ -1546,7 +1546,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 			f193_stealFromChampion(group, AL0439_i_ChampionIndex);
 		} else {
 			AL0440_i_Damage = f230_getChampionDamage(group, AL0439_i_ChampionIndex) + 1;
-			Champion *L0442_ps_Champion = &_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex];
+			Champion *L0442_ps_Champion = &_vm->_championMan->_champions[AL0439_i_ChampionIndex];
 			if (AL0440_i_Damage > L0442_ps_Champion->_maximumDamageReceived) {
 				L0442_ps_Champion->_maximumDamageReceived = AL0440_i_Damage;
 				L0442_ps_Champion->_directionMaximumDamageReceived = returnOppositeDir((Direction)L0438_ui_PrimaryDirectionToParty);
@@ -1592,15 +1592,15 @@ void GroupMan::f193_stealFromChampion(Group *group, uint16 championIndex) {
 
 
 	L0396_B_ObjectStolen = false;
-	L0391_i_Percentage = 100 - _vm->_championMan->f311_getDexterity(L0395_ps_Champion = &_vm->_championMan->_gK71_champions[championIndex]);
+	L0391_i_Percentage = 100 - _vm->_championMan->getDexterity(L0395_ps_Champion = &_vm->_championMan->_champions[championIndex]);
 	L0393_ui_Counter = _vm->getRandomNumber(8);
-	while ((L0391_i_Percentage > 0) && !_vm->_championMan->f308_isLucky(L0395_ps_Champion, L0391_i_Percentage)) {
+	while ((L0391_i_Percentage > 0) && !_vm->_championMan->isLucky(L0395_ps_Champion, L0391_i_Percentage)) {
 		if ((L0392_ui_StealFromSlotIndex = G0394_auc_StealFromSlotIndices[L0393_ui_Counter]) == k13_ChampionSlotBackpackLine_1_1) {
 			L0392_ui_StealFromSlotIndex += _vm->getRandomNumber(17); /* Select a random slot in the backpack */
 		}
 		if (((L0394_T_Thing = L0395_ps_Champion->_slots[L0392_ui_StealFromSlotIndex]) != Thing::_none)) {
 			L0396_B_ObjectStolen = true;
-			L0394_T_Thing = _vm->_championMan->f300_getObjectRemovedFromSlot(championIndex, L0392_ui_StealFromSlotIndex);
+			L0394_T_Thing = _vm->_championMan->getObjectRemovedFromSlot(championIndex, L0392_ui_StealFromSlotIndex);
 			if (group->_slot == Thing::_endOfList) {
 				group->_slot = L0394_T_Thing; /* BUG0_12 An object is cloned and appears at two different locations in the dungeon and/or inventory. The game may crash when interacting with this object. If a Giggler with no possessions steals an object that was previously in a chest and was not the last object in the chest then the objects that followed it are cloned. In the chest, the object is part of a linked list of objects that is not reset when the object is removed from the chest and placed in the inventory (but not in the dungeon), nor when it is stolen and added as the first Giggler possession. If the Giggler already has a possession before stealing the object then this does not create a cloned object.
 											 The following statement is missing: L0394_T_Thing->Next = Thing::_endOfList;
@@ -1608,7 +1608,7 @@ void GroupMan::f193_stealFromChampion(Group *group, uint16 championIndex) {
 			} else {
 				_vm->_dungeonMan->f163_linkThingToList(L0394_T_Thing, group->_slot, kM1_MapXNotOnASquare, 0);
 			}
-			_vm->_championMan->f292_drawChampionState((ChampionIndex)championIndex);
+			_vm->_championMan->drawChampionState((ChampionIndex)championIndex);
 		}
 		++L0393_ui_Counter;
 		L0393_ui_Counter &= 0x0007;
@@ -1639,20 +1639,20 @@ int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) {
 	CreatureInfo L0564_s_CreatureInfo;
 
 
-	L0562_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
-	if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
+	L0562_ps_Champion = &_vm->_championMan->_champions[champIndex];
+	if (champIndex >= _vm->_championMan->_partyChampionCount) {
 		return 0;
 	}
 	if (!L0562_ps_Champion->_currHealth) {
 		return 0;
 	}
-	if (_vm->_championMan->_g300_partyIsSleeping) {
-		_vm->_championMan->f314_wakeUp();
+	if (_vm->_championMan->_partyIsSleeping) {
+		_vm->_championMan->wakeUp();
 	}
 	L0563_i_DoubledMapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty << 1;
 	L0564_s_CreatureInfo = g243_CreatureInfo[group->_type];
-	_vm->_championMan->f304_addSkillExperience(champIndex, k7_ChampionSkillParry, L0564_s_CreatureInfo.M58_getExperience());
-	if (_vm->_championMan->_g300_partyIsSleeping || (((_vm->_championMan->f311_getDexterity(L0562_ps_Champion) < (_vm->getRandomNumber(32) + L0564_s_CreatureInfo._dexterity + L0563_i_DoubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !_vm->_championMan->f308_isLucky(L0562_ps_Champion, 60))) {
+	_vm->_championMan->addSkillExperience(champIndex, k7_ChampionSkillParry, L0564_s_CreatureInfo.M58_getExperience());
+	if (_vm->_championMan->_partyIsSleeping || (((_vm->_championMan->getDexterity(L0562_ps_Champion) < (_vm->getRandomNumber(32) + L0564_s_CreatureInfo._dexterity + L0563_i_DoubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !_vm->_championMan->isLucky(L0562_ps_Champion, 60))) {
 		if ((AL0559_ui_WoundTest = _vm->getRandomNumber(65536)) & 0x0070) {
 			AL0559_ui_WoundTest &= 0x000F;
 			L0560_ui_WoundProbabilities = L0564_s_CreatureInfo._woundProbabilities;
@@ -1663,7 +1663,7 @@ int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) {
 		} else {
 			AL0561_ui_AllowedWound = AL0559_ui_WoundTest & 0x0001; /* 0 (Ready hand) or 1 (action hand) */
 		}
-		if ((AL0558_i_Attack = (_vm->getRandomNumber(16) + L0564_s_CreatureInfo._attack + L0563_i_DoubledMapDifficulty) - (_vm->_championMan->f303_getSkillLevel(champIndex, k7_ChampionSkillParry) << 1)) <= 1) {
+		if ((AL0558_i_Attack = (_vm->getRandomNumber(16) + L0564_s_CreatureInfo._attack + L0563_i_DoubledMapDifficulty) - (_vm->_championMan->getSkillLevel(champIndex, k7_ChampionSkillParry) << 1)) <= 1) {
 			if (_vm->getRandomNumber(2)) {
 				goto T0230014;
 			}
@@ -1677,15 +1677,15 @@ int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) {
 		if (_vm->getRandomNumber(2))
 			AL0558_i_Attack -= _vm->getRandomNumber((AL0558_i_Attack >> 1) + 1) - 1;
 
-		AL0558_i_Damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType);
+		AL0558_i_Damage = _vm->_championMan->addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType);
 		if (AL0558_i_Damage) {
 			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k09_soundCHAMPION_0_DAMAGED + champIndex, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater);
 
 			AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack;
 			if (AL0559_ui_PoisonAttack && _vm->getRandomNumber(2)) {
-				AL0559_ui_PoisonAttack = _vm->_championMan->f307_getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack);
+				AL0559_ui_PoisonAttack = _vm->_championMan->getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack);
 				if (AL0559_ui_PoisonAttack >= 0)
-					_vm->_championMan->f322_championPoison(champIndex, AL0559_ui_PoisonAttack);
+					_vm->_championMan->championPoison(champIndex, AL0559_ui_PoisonAttack);
 			}
 			return AL0558_i_Damage;
 		}
@@ -1897,7 +1897,7 @@ int16 GroupMan::f231_getMeleeActionDamage(Champion* champ, int16 champIndex, Gro
 	int16 L0571_i_ActionHandObjectIconIndex;
 	CreatureInfo* L0572_ps_CreatureInfo;
 
-	if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
+	if (champIndex >= _vm->_championMan->_partyChampionCount) {
 		return 0;
 	}
 	if (!champ->_currHealth) {
@@ -1911,11 +1911,11 @@ int16 GroupMan::f231_getMeleeActionDamage(Champion* champ, int16 champIndex, Gro
 		clearFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
 
 	if ((!getFlag(L0572_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) || L0570_B_ActionHitsNonMaterialCreatures) &&
-		((_vm->_championMan->f311_getDexterity(champ) > (_vm->getRandomNumber(32) + L0572_ps_CreatureInfo->_dexterity + L0567_i_DoubledMapDifficulty - 16)) ||
+		((_vm->_championMan->getDexterity(champ) > (_vm->getRandomNumber(32) + L0572_ps_CreatureInfo->_dexterity + L0567_i_DoubledMapDifficulty - 16)) ||
 		(!_vm->getRandomNumber(4)) ||
-		 (_vm->_championMan->f308_isLucky(champ, 75 - actionHitProbability)))) {
+		 (_vm->_championMan->isLucky(champ, 75 - actionHitProbability)))) {
 
-		L0565_i_Damage = _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand);
+		L0565_i_Damage = _vm->_championMan->getStrength(champIndex, k1_ChampionSlotActionHand);
 		if (!(L0565_i_Damage))
 			goto T0231009;
 
@@ -1950,20 +1950,20 @@ T0231009:
 		L0565_i_Damage += _vm->getRandomNumber(4) + 1;
 		if ((L0571_i_ActionHandObjectIconIndex == k40_IconIndiceWeaponVorpalBlade) && !getFlag(L0572_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) && !(L0565_i_Damage >>= 1))
 			goto T0231015;
-		if (_vm->getRandomNumber(64) < _vm->_championMan->f303_getSkillLevel(champIndex, skillIndex)) {
+		if (_vm->getRandomNumber(64) < _vm->_championMan->getSkillLevel(champIndex, skillIndex)) {
 			L0565_i_Damage += L0565_i_Damage + 10;
 		}
 		L0569_i_Outcome = f190_groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapY, L0565_i_Damage, true);
-		_vm->_championMan->f304_addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * L0572_ps_CreatureInfo->M58_getExperience() >> 4) + 3);
-		_vm->_championMan->f325_decrementStamina(champIndex, _vm->getRandomNumber(4) + 4);
+		_vm->_championMan->addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * L0572_ps_CreatureInfo->M58_getExperience() >> 4) + 3);
+		_vm->_championMan->decrementStamina(champIndex, _vm->getRandomNumber(4) + 4);
 		goto T0231016;
 	}
 T0231015:
 	L0565_i_Damage = 0;
 	L0569_i_Outcome = k0_outcomeKilledNoCreaturesInGroup;
-	_vm->_championMan->f325_decrementStamina(champIndex, _vm->getRandomNumber(2) + 2);
+	_vm->_championMan->decrementStamina(champIndex, _vm->getRandomNumber(2) + 2);
 T0231016:
-	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+	_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	if (L0569_i_Outcome != k2_outcomeKilledAllCreaturesInGroup) {
 		f209_processEvents29to41(mapX, mapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
 	}
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 78dc28a..2c10ded 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -93,7 +93,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	Champion* L1103_ps_Champion;
 
 
-	if ((championIndex != k4_ChampionCloseInventory) && !_vm->_championMan->_gK71_champions[championIndex]._currHealth) {
+	if ((championIndex != k4_ChampionCloseInventory) && !_vm->_championMan->_champions[championIndex]._currHealth) {
 		return;
 	}
 	if (_vm->_g333_pressingMouth || _vm->_g331_pressingEye) {
@@ -108,12 +108,12 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	if (AL1102_ui_InventoryChampionOrdinal) {
 		_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
 		f334_closeChest();
-		L1103_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(AL1102_ui_InventoryChampionOrdinal)];
-		if (L1103_ps_Champion->_currHealth && !_vm->_championMan->_g299_candidateChampionOrdinal) {
+		L1103_ps_Champion = &_vm->_championMan->_champions[_vm->M1_ordinalToIndex(AL1102_ui_InventoryChampionOrdinal)];
+		if (L1103_ps_Champion->_currHealth && !_vm->_championMan->_candidateChampionOrdinal) {
 			setFlag(L1103_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox);
-			_vm->_championMan->f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(AL1102_ui_InventoryChampionOrdinal));
+			_vm->_championMan->drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(AL1102_ui_InventoryChampionOrdinal));
 		}
-		if (_vm->_championMan->_g300_partyIsSleeping) {
+		if (_vm->_championMan->_partyIsSleeping) {
 			_vm->_eventMan->f77_hideMouse();
 			return;
 		}
@@ -133,9 +133,9 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	if (!AL1102_ui_InventoryChampionOrdinal) {
 		_vm->_displayMan->f136_shadeScreenBox(&_vm->_displayMan->_boxMovementArrows, k0_ColorBlack);
 	}
-	L1103_ps_Champion = &_vm->_championMan->_gK71_champions[championIndex];
+	L1103_ps_Champion = &_vm->_championMan->_champions[championIndex];
 	_vm->_displayMan->f466_loadIntoBitmap(k17_InventoryGraphicIndice, _vm->_displayMan->_g296_bitmapViewport);
-	if (_vm->_championMan->_g299_candidateChampionOrdinal) {
+	if (_vm->_championMan->_candidateChampionOrdinal) {
 		_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
 	}
 
@@ -157,10 +157,10 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 
 	_vm->_textMan->f52_printToViewport(5, 132, k13_ColorLightestGray, "MANA");
 	for (AL1102_ui_SlotIndex = k0_ChampionSlotReadyHand; AL1102_ui_SlotIndex < k30_ChampionSlotChest_1; AL1102_ui_SlotIndex++) {
-		_vm->_championMan->f291_drawSlot(championIndex, AL1102_ui_SlotIndex);
+		_vm->_championMan->drawSlot(championIndex, AL1102_ui_SlotIndex);
 	}
 	setFlag(L1103_ps_Champion->_attributes, k0x4000_ChampionAttributeViewport | k0x1000_ChampionAttributeStatusBox | k0x0800_ChampionAttributePanel | k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics | k0x0080_ChampionAttributeNameTitle);
-	_vm->_championMan->f292_drawChampionState(championIndex);
+	_vm->_championMan->drawChampionState(championIndex);
 	_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
 	_vm->_eventMan->f77_hideMouse();
 	_vm->_eventMan->_g442_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputChampionInventory;
@@ -176,7 +176,7 @@ void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) {
 	box._y2 = 28;
 	box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7;
 	box._x2 = box._x1 + 31;
-	dispMan.f21_blitToScreen(_vm->_championMan->_gK71_champions[championIndex]._portrait, &box, k16_byteWidth, kM1_ColorNoTransparency, 29);
+	dispMan.f21_blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, &box, k16_byteWidth, kM1_ColorNoTransparency, 29);
 }
 
 void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
@@ -210,7 +210,7 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
 	static Box g36_BoxWater(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
 	static Box g37_BoxPoisoned(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
 
-	Champion &champ = _vm->_championMan->_gK71_champions[_g432_inventoryChampionOrdinal];
+	Champion &champ = _vm->_championMan->_champions[_g432_inventoryChampionOrdinal];
 	f334_closeChest();
 	DisplayMan &dispMan = *_vm->_displayMan;
 	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
@@ -249,12 +249,12 @@ void InventoryMan::f347_drawPanel() {
 	f334_closeChest();
 
 	ChampionMan &cm = *_vm->_championMan;
-	if (cm._g299_candidateChampionOrdinal) {
+	if (cm._candidateChampionOrdinal) {
 		f346_drawPanelResurrectReincarnate();
 		return;
 	}
 
-	Thing thing = cm._gK71_champions[_vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand);
+	Thing thing = cm._champions[_vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand);
 
 	_g424_panelContent = k0_PanelContentFoodWaterPoisoned;
 	switch (thing.getType()) {
@@ -523,21 +523,21 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			default:
 			case Common::EN_ANY:
 			case Common::DE_DEU: // german and english versions are the same
-				strcpy(str, champMan._gK71_champions[((Junk *)rawThingPtr)->getChargeCount()]._name);
+				strcpy(str, champMan._champions[((Junk *)rawThingPtr)->getChargeCount()]._name);
 				strcat(str, " ");
 				strcat(str, objMan._g352_objectNames[iconIndex]);
 				break;
 			case Common::FR_FRA:
 				strcat(str, objMan._g352_objectNames[iconIndex]);
 				strcat(str, " ");
-				strcpy(str, champMan._gK71_champions[((Junk *)rawThingPtr)->getChargeCount()]._name);
+				strcpy(str, champMan._champions[((Junk *)rawThingPtr)->getChargeCount()]._name);
 				break;
 			}
 
 			descString = str;
 		} else if ((thingType == k8_PotionThingType)
 				   && (iconIndex != k163_IconIndicePotionWaterFlask)
-				   && (champMan.f303_getSkillLevel((ChampionIndex)_vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
+				   && (champMan.getSkillLevel((ChampionIndex)_vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
 			str[0] = '_' + ((Potion *)rawThingPtr)->getPower() / 40;
 			str[1] = ' ';
 			str[2] = '\0';
@@ -672,7 +672,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 
 
 		uint16 weight = dunMan.f140_getObjectWeight(thingToDraw);
-		strcat(str, champMan.f288_getStringFromInteger(weight / 10, false, 3).c_str());
+		strcat(str, champMan.getStringFromInteger(weight / 10, false, 3).c_str());
 
 		switch (_vm->getGameLanguage()) { // localized
 		default:
@@ -682,7 +682,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		}
 
 		weight -= (weight / 10) * 10;
-		strcat(str, champMan.f288_getStringFromInteger(weight, false, 1).c_str());
+		strcat(str, champMan.getStringFromInteger(weight, false, 1).c_str());
 
 		switch (_vm->getGameLanguage()) { // localized
 		default:
@@ -704,7 +704,7 @@ void InventoryMan::f337_setDungeonViewPalette() {
 	} else {
 		/* Get torch light power from both hands of each champion in the party */
 		int16 L1038_i_Counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and _vm->_objectMan->f32_getObjectType then returns -1 */
-		Champion *L1043_ps_Champion = _vm->_championMan->_gK71_champions;
+		Champion *L1043_ps_Champion = _vm->_championMan->_champions;
 		int16 L1045_ai_TorchesLightPower[8];
 		int16 *AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
 		while (L1038_i_Counter--) {
@@ -751,7 +751,7 @@ void InventoryMan::f337_setDungeonViewPalette() {
 			}
 			AL1040_pi_TorchLightPower++;
 		}
-		L1036_i_TotalLightAmount += _vm->_championMan->_g407_party._magicalLightAmount;
+		L1036_i_TotalLightAmount += _vm->_championMan->_party._magicalLightAmount;
 		/* Select palette corresponding to the total light amount */
 		const int16 *AL1040_pi_LightAmount = g40_palIndexToLightAmmount;
 		int16 AL1039_ui_PaletteIndex;
@@ -771,11 +771,11 @@ void InventoryMan::f337_setDungeonViewPalette() {
 
 void InventoryMan::f338_decreaseTorchesLightPower() {
 	bool L1048_B_TorchChargeCountChanged = false;
-	int16 L1046_i_ChampionCount = _vm->_championMan->_g305_partyChampionCount;
-	if (_vm->_championMan->_g299_candidateChampionOrdinal) {
+	int16 L1046_i_ChampionCount = _vm->_championMan->_partyChampionCount;
+	if (_vm->_championMan->_candidateChampionOrdinal) {
 		L1046_i_ChampionCount--;
 	}
-	Champion *L1050_ps_Champion = _vm->_championMan->_gK71_champions;
+	Champion *L1050_ps_Champion = _vm->_championMan->_champions;
 	while (L1046_i_ChampionCount--) {
 		int16 L1047_i_SlotIndex = k1_ChampionSlotActionHand + 1;
 		while (L1047_i_SlotIndex--) {
@@ -794,7 +794,7 @@ void InventoryMan::f338_decreaseTorchesLightPower() {
 	}
 	if (L1048_B_TorchChargeCountChanged) {
 		f337_setDungeonViewPalette();
-		_vm->_championMan->f296_drawChangedObjectIcons();
+		_vm->_championMan->drawChangedObjectIcons();
 	}
 }
 
@@ -825,11 +825,11 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 	}
 
 	f334_closeChest();
-	L1094_ps_Champion = &_vm->_championMan->_gK71_champions[L1093_ui_ChampionIndex = _vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal)];
+	L1094_ps_Champion = &_vm->_championMan->_champions[L1093_ui_ChampionIndex = _vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal)];
 	_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
 	L1091_i_Y = 58;
 	for (AL1090_ui_SkillIndex = k0_ChampionSkillFighter; AL1090_ui_SkillIndex <= k3_ChampionSkillWizard; AL1090_ui_SkillIndex++) {
-		AL1092_i_SkillLevel = MIN((uint16)16, _vm->_championMan->f303_getSkillLevel(L1093_ui_ChampionIndex, AL1090_ui_SkillIndex | k0x8000_IgnoreTemporaryExperience));
+		AL1092_i_SkillLevel = MIN((uint16)16, _vm->_championMan->getSkillLevel(L1093_ui_ChampionIndex, AL1090_ui_SkillIndex | k0x8000_IgnoreTemporaryExperience));
 		if (AL1092_i_SkillLevel == 1)
 			continue;
 
@@ -864,9 +864,9 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 				L1095_i_StatisticColor = k13_ColorLightestGray;
 			}
 		}
-		_vm->_textMan->f52_printToViewport(174, L1091_i_Y, (Color)L1095_i_StatisticColor, _vm->_championMan->f288_getStringFromInteger(AL1092_i_StatisticCurrentValue, true, 3).c_str());
+		_vm->_textMan->f52_printToViewport(174, L1091_i_Y, (Color)L1095_i_StatisticColor, _vm->_championMan->getStringFromInteger(AL1092_i_StatisticCurrentValue, true, 3).c_str());
 		strcpy(L1097_ac_String, "/");
-		strcat(L1097_ac_String, _vm->_championMan->f288_getStringFromInteger(L1096_ui_StatisticMaximumValue, true, 3).c_str());
+		strcat(L1097_ac_String, _vm->_championMan->getStringFromInteger(L1096_ui_StatisticMaximumValue, true, 3).c_str());
 		_vm->_textMan->f52_printToViewport(192, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String);
 		L1091_i_Y += 7;
 	}
@@ -887,7 +887,7 @@ void InventoryMan::f353_drawStopPressingEye() {
 	f332_drawIconToViewport(k202_IconIndiceEyeNotLooking, 12, 13);
 	f347_drawPanel();
 	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
-	if ((L1100_T_LeaderHandObject = _vm->_championMan->_g414_leaderHandObject) != Thing::_none) {
+	if ((L1100_T_LeaderHandObject = _vm->_championMan->_leaderHandObject) != Thing::_none) {
 		_vm->_objectMan->f34_drawLeaderObjectName(L1100_T_LeaderHandObject);
 	}
 	_vm->_eventMan->f78_showMouse();
@@ -926,7 +926,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 	uint16 L1089_ui_Weight;
 
 
-	if (_vm->_championMan->_g415_leaderEmptyHanded) {
+	if (_vm->_championMan->_leaderEmptyHanded) {
 		if (_g424_panelContent == k0_PanelContentFoodWaterPoisoned) {
 			return;
 		}
@@ -944,16 +944,16 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 		}
 		return;
 	}
-	if (_vm->_championMan->_g299_candidateChampionOrdinal) {
+	if (_vm->_championMan->_candidateChampionOrdinal) {
 		return;
 	}
-	if (!getFlag(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1078_T_Thing = _vm->_championMan->_g414_leaderHandObject)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) {
+	if (!getFlag(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1078_T_Thing = _vm->_championMan->_leaderHandObject)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) {
 		return;
 	}
 	L1079_ui_IconIndex = _vm->_objectMan->f33_getIconIndex(L1078_T_Thing);
 	AL1088_ui_ThingType = L1078_T_Thing.getType();
 	L1089_ui_Weight = _vm->_dungeonMan->f140_getObjectWeight(L1078_T_Thing);
-	L1083_ps_Champion = &_vm->_championMan->_gK71_champions[L1080_ui_ChampionIndex = _vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal)];
+	L1083_ps_Champion = &_vm->_championMan->_champions[L1080_ui_ChampionIndex = _vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal)];
 	L1082_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1078_T_Thing);
 	if ((L1079_ui_IconIndex >= k8_IconIndiceJunkWater) && (L1079_ui_IconIndex <= k9_IconIndiceJunkWaterSkin)) {
 		if (!(L1082_ps_Junk->getChargeCount())) {
@@ -972,7 +972,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 	}
 	_vm->_eventMan->f78_showMouse();
 	if (L1081_B_RemoveObjectFromLeaderHand) {
-		_vm->_championMan->f298_getObjectRemovedFromLeaderHand();
+		_vm->_championMan->getObjectRemovedFromLeaderHand();
 	}
 	if (AL1088_ui_ThingType == k8_PotionThingType) {
 		AL1085_ui_PotionPower = ((Potion*)L1082_ps_Junk)->getPower();
@@ -992,7 +992,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 			f348_adjustStatisticCurrentValue(L1083_ps_Champion, k4_ChampionStatVitality, AL1085_ui_AdjustedPotionPower);
 			break;
 		case k10_PotionTypeAntivenin:
-			_vm->_championMan->f323_unpoison(L1080_ui_ChampionIndex);
+			_vm->_championMan->unpoison(L1080_ui_ChampionIndex);
 			break;
 		case k11_PotionTypeMon:
 			L1083_ps_Champion->_currStamina += MIN(L1083_ps_Champion->_maxStamina - L1083_ps_Champion->_currStamina, L1083_ps_Champion->_maxStamina / L1086_ui_Counter);
@@ -1058,16 +1058,16 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 			_vm->_displayMan->updateScreen();
 		}
 	} else {
-		_vm->_championMan->f296_drawChangedObjectIcons();
-		_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(L1078_T_Thing) - L1089_ui_Weight;
-		setFlag(_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
+		_vm->_championMan->drawChangedObjectIcons();
+		_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(L1078_T_Thing) - L1089_ui_Weight;
+		setFlag(_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
 	}
 	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k08_soundSWALLOW, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
 	setFlag(L1083_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
 	if (_g424_panelContent == k0_PanelContentFoodWaterPoisoned) {
 		setFlag(L1083_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
 	}
-	_vm->_championMan->f292_drawChampionState((ChampionIndex)L1080_ui_ChampionIndex);
+	_vm->_championMan->drawChampionState((ChampionIndex)L1080_ui_ChampionIndex);
 	_vm->_eventMan->f77_hideMouse();
 }
 
@@ -1106,11 +1106,11 @@ void InventoryMan::f352_processCommand71_clickOnEye() {
 	_vm->_eventMan->f77_hideMouse();
 	_vm->f22_delay(8);
 	f332_drawIconToViewport(k203_IconIndiceEyeLooking, 12, 13);
-	if (_vm->_championMan->_g415_leaderEmptyHanded) {
+	if (_vm->_championMan->_leaderEmptyHanded) {
 		f351_drawChampionSkillsAndStatistics();
 	} else {
 		_vm->_objectMan->f35_clearLeaderObjectName();
-		f342_drawPanelObject(_vm->_championMan->_g414_leaderHandObject, true);
+		f342_drawPanelObject(_vm->_championMan->_leaderHandObject, true);
 	}
 	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
 
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 4d486cf..a3910a9 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -71,8 +71,8 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 	if (_g298_newGame) {
 		//L1366_B_FadePalette = !F0428_DIALOG_RequireGameDiskInDrive_NoDialogDrawn(C0_DO_NOT_FORCE_DIALOG_DM_CSB, true);
 		_g524_restartGameAllowed = false;
-		_championMan->_g305_partyChampionCount = 0;
-		_championMan->_g414_leaderHandObject = Thing::_none;
+		_championMan->_partyChampionCount = 0;
+		_championMan->_leaderHandObject = Thing::_none;
 		_g525_gameId = ((int32)getRandomNumber(65536)) * getRandomNumber(65536);
 	} else {
 		SaveGameHeader header;
@@ -92,13 +92,13 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 
 		_g313_gameTime = file->readSint32BE();
 		// G0349_ul_LastRandomNumber = L1371_s_GlobalData.LastRandomNumber;
-		_championMan->_g305_partyChampionCount = file->readUint16BE();
+		_championMan->_partyChampionCount = file->readUint16BE();
 		_dungeonMan->_g306_partyMapX = file->readSint16BE();
 		_dungeonMan->_g307_partyMapY = file->readSint16BE();
 		_dungeonMan->_g308_partyDir = (Direction)file->readUint16BE();
 		_dungeonMan->_g309_partyMapIndex = file->readByte();
-		_championMan->_g411_leaderIndex = (ChampionIndex)file->readSint16BE();
-		_championMan->_g514_magicCasterChampionIndex = (ChampionIndex)file->readSint16BE();
+		_championMan->_leaderIndex = (ChampionIndex)file->readSint16BE();
+		_championMan->_magicCasterChampionIndex = (ChampionIndex)file->readSint16BE();
 		_timeline->_g372_eventCount = file->readUint16BE();
 		_timeline->_g373_firstUnusedEventIndex = file->readUint16BE();
 		_timeline->_g369_eventMaxCount = file->readUint16BE();
@@ -108,7 +108,7 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		_g310_disabledMovementTicks = file->readSint16BE();
 		_g311_projectileDisableMovementTicks = file->readSint16BE();
 		_g312_lastProjectileDisabledMovementDirection = file->readSint16BE();
-		_championMan->_g414_leaderHandObject = Thing(file->readUint16BE());
+		_championMan->_leaderHandObject = Thing(file->readUint16BE());
 		_groupMan->_g376_maxActiveGroupCount = file->readUint16BE();
 		if (!_g523_restartGameRequest) {
 			_timeline->f233_initTimeline();
@@ -116,7 +116,7 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		}
 
 		_groupMan->load1_ActiveGroupPart(file);
-		_championMan->load2_PartyPart(file);
+		_championMan->loadPartyPart2(file);
 		_timeline->load3_eventsPart(file);
 		_timeline->load4_timelinePart(file);
 
@@ -157,7 +157,7 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		}
 
 	}
-	_championMan->_g303_partyDead = false;
+	_championMan->_partyDead = false;
 
 	return k1_LoadgameSuccess;
 }
@@ -223,9 +223,9 @@ void DMEngine::f433_processCommand140_saveGame() {
 			}
 
 			uint16 champHandObjWeight = 0;
-			if (!_championMan->_g415_leaderEmptyHanded) {
-				champHandObjWeight = _dungeonMan->f140_getObjectWeight(_championMan->_g414_leaderHandObject);
-				_championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load -= champHandObjWeight;
+			if (!_championMan->_leaderEmptyHanded) {
+				champHandObjWeight = _dungeonMan->f140_getObjectWeight(_championMan->_leaderHandObject);
+				_championMan->_champions[_championMan->_leaderIndex]._load -= champHandObjWeight;
 			}
 
 			if (!writeCompleteSaveFile(saveSlot, saveDescription, saveAndPlayChoice)) {
@@ -233,8 +233,8 @@ void DMEngine::f433_processCommand140_saveGame() {
 				_dialog->f424_dialogGetChoice(1, k0_DIALOG_SET_VIEWPORT, 0, k0_DIALOG_CHOICE_NONE);
 			}
 
-			if (!_championMan->_g415_leaderEmptyHanded) {
-				_championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load += champHandObjWeight;
+			if (!_championMan->_leaderEmptyHanded) {
+				_championMan->_champions[_championMan->_leaderIndex]._load += champHandObjWeight;
 			}
 		} else
 			saveAndPlayChoice = kCancel;
@@ -308,13 +308,13 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 	// write C0_SAVE_PART_GLOBAL_DATA part
 	file->writeSint32BE(_g313_gameTime);
 	//L1348_s_GlobalData.LastRandomNumber = G0349_ul_LastRandomNumber;
-	file->writeUint16BE(_championMan->_g305_partyChampionCount);
+	file->writeUint16BE(_championMan->_partyChampionCount);
 	file->writeSint16BE(_dungeonMan->_g306_partyMapX);
 	file->writeSint16BE(_dungeonMan->_g307_partyMapY);
 	file->writeUint16BE(_dungeonMan->_g308_partyDir);
 	file->writeByte(_dungeonMan->_g309_partyMapIndex);
-	file->writeSint16BE(_championMan->_g411_leaderIndex);
-	file->writeSint16BE(_championMan->_g514_magicCasterChampionIndex);
+	file->writeSint16BE(_championMan->_leaderIndex);
+	file->writeSint16BE(_championMan->_magicCasterChampionIndex);
 	file->writeUint16BE(_timeline->_g372_eventCount);
 	file->writeUint16BE(_timeline->_g373_firstUnusedEventIndex);
 	file->writeUint16BE(_timeline->_g369_eventMaxCount);
@@ -324,13 +324,13 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 	file->writeSint16BE(_g310_disabledMovementTicks);
 	file->writeSint16BE(_g311_projectileDisableMovementTicks);
 	file->writeSint16BE(_g312_lastProjectileDisabledMovementDirection);
-	file->writeUint16BE(_championMan->_g414_leaderHandObject.toUint16());
+	file->writeUint16BE(_championMan->_leaderHandObject.toUint16());
 	file->writeUint16BE(_groupMan->_g376_maxActiveGroupCount);
 
 	// write C1_SAVE_PART_ACTIVE_GROUP part
 	_groupMan->save1_ActiveGroupPart(file);
 	// write C2_SAVE_PART_PARTY part
-	_championMan->save2_PartyPart(file);
+	_championMan->savePartyPart2(file);
 	// write C3_SAVE_PART_EVENTS part
 	_timeline->save3_eventsPart(file);
 	// write C4_SAVE_PART_TIMELINE part
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 3134bbb..5a7c9f1 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -125,11 +125,11 @@ void MenuMan::f395_drawMovementArrows() {
 }
 void MenuMan::f388_clearActingChampion() {
 	ChampionMan &cm = *_vm->_championMan;
-	if (cm._g506_actingChampionOrdinal) {
-		cm._g506_actingChampionOrdinal--;
-		cm._gK71_champions[cm._g506_actingChampionOrdinal].setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
-		cm.f292_drawChampionState((ChampionIndex)cm._g506_actingChampionOrdinal);
-		cm._g506_actingChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+	if (cm._actingChampionOrdinal) {
+		cm._actingChampionOrdinal--;
+		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
+		cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal);
+		cm._actingChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
 		_g508_refreshActionArea = true;
 	}
 }
@@ -140,7 +140,7 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
 	if (!_g509_actionAreaContainsIcons)
 		return;
 	DisplayMan &dm = *_vm->_displayMan;
-	Champion &champion = _vm->_championMan->_gK71_champions[championIndex];
+	Champion &champion = _vm->_championMan->_champions[championIndex];
 
 	Box box;
 	box._x1 = championIndex * 22 + 233;
@@ -173,13 +173,13 @@ T0386006:
 	box2._y1 = 95;
 	box2._y2 = 110;
 	dm.f21_blitToScreen(bitmapIcon, &box2, k8_byteWidth, kM1_ColorNoTransparency, 16);
-	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) {
+	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) {
 		_vm->_displayMan->f136_shadeScreenBox(&box, k0_ColorBlack);
 	}
 }
 
 void MenuMan::f456_drawDisabledMenu() {
-	if (!_vm->_championMan->_g300_partyIsSleeping) {
+	if (!_vm->_championMan->_partyIsSleeping) {
 		_vm->_eventMan->f363_highlightBoxDisable();
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
@@ -198,39 +198,39 @@ void MenuMan::f456_drawDisabledMenu() {
 void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
 	ChampionMan &champMan = *_vm->_championMan;
 
-	if (!champMan._g305_partyChampionCount)
+	if (!champMan._partyChampionCount)
 		return;
 
 	Champion *champ = nullptr;
-	if (champMan._g300_partyIsSleeping || champMan._g299_candidateChampionOrdinal) {
-		if (champMan._g506_actingChampionOrdinal) {
+	if (champMan._partyIsSleeping || champMan._candidateChampionOrdinal) {
+		if (champMan._actingChampionOrdinal) {
 			f388_clearActingChampion();
 			return;
 		}
-		if (!champMan._g299_candidateChampionOrdinal)
+		if (!champMan._candidateChampionOrdinal)
 			return;
 	} else {
-		champ = champMan._gK71_champions;
+		champ = champMan._champions;
 		int16 champIndex = k0_ChampionFirst;
 
 		do {
-			if ((champIndex != champMan._g411_leaderIndex)
-				&& (_vm->M0_indexToOrdinal(champIndex) != champMan._g506_actingChampionOrdinal)
+			if ((champIndex != champMan._leaderIndex)
+				&& (_vm->M0_indexToOrdinal(champIndex) != champMan._actingChampionOrdinal)
 				&& (champ->_maximumDamageReceived)
 				&& (champ->_dir != champ->_directionMaximumDamageReceived)) {
 
 				champ->_dir = (Direction)champ->_directionMaximumDamageReceived;
 				champ->setAttributeFlag(k0x0400_ChampionAttributeIcon, true);
-				champMan.f292_drawChampionState((ChampionIndex)champIndex);
+				champMan.drawChampionState((ChampionIndex)champIndex);
 			}
 			champ->_maximumDamageReceived = 0;
 			champ++;
 			champIndex++;
-		} while (champIndex < champMan._g305_partyChampionCount);
+		} while (champIndex < champMan._partyChampionCount);
 	}
 
 	if (_g508_refreshActionArea) {
-		if (!champMan._g506_actingChampionOrdinal) {
+		if (!champMan._actingChampionOrdinal) {
 			if (_g513_actionDamage) {
 				f385_drawActionDamage(_g513_actionDamage);
 				_g513_actionDamage = 0;
@@ -241,7 +241,7 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
 		} else {
 			_g509_actionAreaContainsIcons = false;
 			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
-			champMan.f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal));
+			champMan.drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(champMan._actingChampionOrdinal));
 			f387_drawActionArea();
 		}
 	}
@@ -259,9 +259,9 @@ void MenuMan::f387_drawActionArea() {
 	dispMan._g578_useByteBoxCoordinates = false;
 	dispMan.D24_fillScreenBox(boxActionArea, k0_ColorBlack);
 	if (_g509_actionAreaContainsIcons) {
-		for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._g305_partyChampionCount; ++champIndex)
+		for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._partyChampionCount; ++champIndex)
 			f386_drawActionIcon((ChampionIndex)champIndex);
-	} else if (champMan._g506_actingChampionOrdinal) {
+	} else if (champMan._actingChampionOrdinal) {
 		Box box = boxActionArea3ActionMenu;
 		if (_g713_actionList._actionIndices[2] == k255_ChampionActionNone)
 			box = boxActionArea2ActionMenu;
@@ -270,7 +270,7 @@ void MenuMan::f387_drawActionArea() {
 		dispMan.f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k10_MenuActionAreaIndice),
 								 &box, k48_byteWidth, kM1_ColorNoTransparency, 45);
 		textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen,
-											235, 83, k0_ColorBlack, k4_ColorCyan, champMan._gK71_champions[_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name,
+											235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->M1_ordinalToIndex(champMan._actingChampionOrdinal)]._name,
 											k7_ChampionNameMaximumLength, k200_heightScreen);
 		for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) {
 			textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
@@ -302,29 +302,29 @@ Box g504_BoxSpellAreaControls = Box(233, 319, 42, 49); // @ G0504_s_Graphic560_B
 void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) {
 
 
-	Champion *champ = &_vm->_championMan->_gK71_champions[champIndex];
+	Champion *champ = &_vm->_championMan->_champions[champIndex];
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	int16 champHP0 = _vm->_championMan->_gK71_champions[0]._currHealth;
-	int16 champHP1 = _vm->_championMan->_gK71_champions[1]._currHealth;
-	int16 champHP2 = _vm->_championMan->_gK71_champions[2]._currHealth;
-	int16 champHP3 = _vm->_championMan->_gK71_champions[3]._currHealth;
+	int16 champHP0 = _vm->_championMan->_champions[0]._currHealth;
+	int16 champHP1 = _vm->_championMan->_champions[1]._currHealth;
+	int16 champHP2 = _vm->_championMan->_champions[2]._currHealth;
+	int16 champHP3 = _vm->_championMan->_champions[3]._currHealth;
 	_vm->_eventMan->f78_showMouse();
 	_vm->_displayMan->D24_fillScreenBox(g504_BoxSpellAreaControls, k0_ColorBlack);
 	switch (champIndex) {
 	case 0:
 		_vm->_eventMan->f6_highlightScreenBox(233, 277, 42, 49);
 		_vm->_textMan->f53_printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
-		if (_vm->_championMan->_g305_partyChampionCount > 1) {
+		if (_vm->_championMan->_partyChampionCount > 1) {
 			if (champHP1) {
 				_vm->_eventMan->f6_highlightScreenBox(280, 291, 42, 48);
 			}
 T0393002:
-			if (_vm->_championMan->_g305_partyChampionCount > 2) {
+			if (_vm->_championMan->_partyChampionCount > 2) {
 				if (champHP2) {
 					_vm->_eventMan->f6_highlightScreenBox(294, 305, 42, 48);
 				}
 T0393003:
-				if (_vm->_championMan->_g305_partyChampionCount > 3) {
+				if (_vm->_championMan->_partyChampionCount > 3) {
 					if (champHP3) {
 						_vm->_eventMan->f6_highlightScreenBox(308, 319, 42, 48);
 					}
@@ -372,7 +372,7 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
 	static Box boxSpellAreaLine(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine 
 
 	char L1204_ac_SpellSymbolString[2] = {'\0', '\0'};
-	Champion *L1203_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
+	Champion *L1203_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
 	if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) {
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		_vm->_displayMan->f132_blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, boxSpellAreaLine, 0, 12, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
@@ -400,23 +400,23 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 
 	Champion* L1213_ps_Champion;
 
-	if ((champIndex == _vm->_championMan->_g514_magicCasterChampionIndex) || ((champIndex != kM1_ChampionNone) && !_vm->_championMan->_gK71_champions[champIndex]._currHealth)) {
+	if ((champIndex == _vm->_championMan->_magicCasterChampionIndex) || ((champIndex != kM1_ChampionNone) && !_vm->_championMan->_champions[champIndex]._currHealth)) {
 		return;
 	}
-	if (_vm->_championMan->_g514_magicCasterChampionIndex == kM1_ChampionNone) {
+	if (_vm->_championMan->_magicCasterChampionIndex == kM1_ChampionNone) {
 		_vm->_eventMan->f78_showMouse();
 		_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &boxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33);
 		_vm->_eventMan->f77_hideMouse();
 	}
 	if (champIndex == kM1_ChampionNone) {
-		_vm->_championMan->_g514_magicCasterChampionIndex = kM1_ChampionNone;
+		_vm->_championMan->_magicCasterChampionIndex = kM1_ChampionNone;
 		_vm->_eventMan->f78_showMouse();
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		_vm->_displayMan->D24_fillScreenBox(boxSpellArea, k0_ColorBlack);
 		_vm->_eventMan->f77_hideMouse();
 		return;
 	}
-	L1213_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex = (ChampionIndex)champIndex];
+	L1213_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex = (ChampionIndex)champIndex];
 	f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
 	_vm->_eventMan->f78_showMouse();
 	f393_drawSpellAreaControls((ChampionIndex)champIndex);
@@ -432,14 +432,14 @@ void MenuMan::f457_drawEnabledMenus() {
 #define AL1462_i_InventoryChampionOrdinal L1462_i_Multiple
 
 
-	if (_vm->_championMan->_g300_partyIsSleeping) {
+	if (_vm->_championMan->_partyIsSleeping) {
 		_vm->_eventMan->f379_drawSleepScreen();
 		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
 	} else {
-		AL1462_i_MagicCasterChampionIndex = _vm->_championMan->_g514_magicCasterChampionIndex;
-		_vm->_championMan->_g514_magicCasterChampionIndex = kM1_ChampionNone; /* Force next function to draw the spell area */
+		AL1462_i_MagicCasterChampionIndex = _vm->_championMan->_magicCasterChampionIndex;
+		_vm->_championMan->_magicCasterChampionIndex = kM1_ChampionNone; /* Force next function to draw the spell area */
 		f394_setMagicCasterAndDrawSpellArea(AL1462_i_MagicCasterChampionIndex);
-		if (!_vm->_championMan->_g506_actingChampionOrdinal) {
+		if (!_vm->_championMan->_actingChampionOrdinal) {
 			_g509_actionAreaContainsIcons = true;
 		}
 		f387_drawActionArea();
@@ -459,10 +459,10 @@ int16 MenuMan::f408_getClickOnSpellCastResult() {
 	Champion* L1260_ps_Champion;
 
 
-	L1260_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
+	L1260_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
 	_vm->_eventMan->f78_showMouse();
 	_vm->_eventMan->f363_highlightBoxDisable();
-	if ((L1259_i_SpellCastResult = f412_getChampionSpellCastResult(_vm->_championMan->_g514_magicCasterChampionIndex)) != k3_spellCastFailureNeedsFlask) {
+	if ((L1259_i_SpellCastResult = f412_getChampionSpellCastResult(_vm->_championMan->_magicCasterChampionIndex)) != k3_spellCastFailureNeedsFlask) {
 		L1260_ps_Champion->_symbols[0] = '\0';
 		f397_drawAvailableSymbols(L1260_ps_Champion->_symbolStep = 0);
 		f398_drawChampionSymbols(L1260_ps_Champion);
@@ -494,10 +494,10 @@ int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
 	Junk* L1277_ps_Junk;
 
 
-	if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
+	if (champIndex >= _vm->_championMan->_partyChampionCount) {
 		return k0_spellCastFailure;
 	}
-	L1270_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	L1270_ps_Champion = &_vm->_championMan->_champions[champIndex];
 	if (!(L1270_ps_Champion->_currHealth)) {
 		return k0_spellCastFailure;
 	}
@@ -507,48 +507,48 @@ int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
 	}
 	L1268_i_PowerSymbolOrdinal = L1270_ps_Champion->_symbols[0] - '_'; /* Values 1 to 6 */
 	L1273_ui_Experience = _vm->getRandomNumber(8) + ((AL1269_ui_RequiredSkillLevel = L1271_ps_Spell->_baseRequiredSkillLevel + L1268_i_PowerSymbolOrdinal) << 4) + ((_vm->M1_ordinalToIndex(L1268_i_PowerSymbolOrdinal) * L1271_ps_Spell->_baseRequiredSkillLevel) << 3) + (AL1269_ui_RequiredSkillLevel * AL1269_ui_RequiredSkillLevel);
-	AL1267_ui_SkillLevel = _vm->_championMan->f303_getSkillLevel(champIndex, L1271_ps_Spell->_skillIndex);
+	AL1267_ui_SkillLevel = _vm->_championMan->getSkillLevel(champIndex, L1271_ps_Spell->_skillIndex);
 	if (AL1267_ui_SkillLevel < AL1269_ui_RequiredSkillLevel) {
 		L1274_i_MissingSkillLevelCount = AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel;
 		while (L1274_i_MissingSkillLevelCount--) {
 			if (_vm->getRandomNumber(128) > MIN(L1270_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + 15, 115)) {
-				_vm->_championMan->f304_addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience >> (AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel));
+				_vm->_championMan->addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience >> (AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel));
 				f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k0_failureNeedsMorePractice, L1271_ps_Spell->_skillIndex);
 				return k0_spellCastFailure;
 			}
 		}
 	}
-	switch (L1271_ps_Spell->M67_spellKind()) {
+	switch (L1271_ps_Spell->getKind()) {
 	case k1_spellKindPotion:
 		if ((L1275_ps_Potion = f411_getEmptyFlaskInHand(L1270_ps_Champion, &L1272_T_Object)) == NULL) {
 			f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k10_failureNeedsFlaskInHand, 0);
 			return k3_spellCastFailureNeedsFlask;
 		}
 		AL1269_ui_EmptyFlaskWeight = _vm->_dungeonMan->f140_getObjectWeight(L1272_T_Object);
-		L1275_ps_Potion->setType((PotionType)L1271_ps_Spell->M68_spellType());
+		L1275_ps_Potion->setType((PotionType)L1271_ps_Spell->getType());
 		L1275_ps_Potion->setPower(_vm->getRandomNumber(16) + (L1268_i_PowerSymbolOrdinal * 40));
 		L1270_ps_Champion->_load += _vm->_dungeonMan->f140_getObjectWeight(L1272_T_Object) - AL1269_ui_EmptyFlaskWeight;
-		_vm->_championMan->f296_drawChangedObjectIcons();
+		_vm->_championMan->drawChangedObjectIcons();
 		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)) {
 			setFlag(L1270_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad);
-			_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+			_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 		}
 		break;
 	case k2_spellKindProjectile:
 		if (L1270_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) {
 			L1270_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
 			setFlag(L1270_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon);
-			_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+			_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 		}
-		if (L1271_ps_Spell->M68_spellType() == k4_spellType_projectileOpenDoor) {
+		if (L1271_ps_Spell->getType() == k4_spellType_projectileOpenDoor) {
 			AL1267_ui_SkillLevel <<= 1;
 		}
-		_vm->_championMan->f327_isProjectileSpellCast(champIndex, Thing(L1271_ps_Spell->M68_spellType() + Thing::_firstExplosion.toUint16()), f26_getBoundedValue(21, (L1268_i_PowerSymbolOrdinal + 2) * (4 + (AL1267_ui_SkillLevel << 1)), 255), 0);
+		_vm->_championMan->isProjectileSpellCast(champIndex, Thing(L1271_ps_Spell->getType() + Thing::_firstExplosion.toUint16()), f26_getBoundedValue(21, (L1268_i_PowerSymbolOrdinal + 2) * (4 + (AL1267_ui_SkillLevel << 1)), 255), 0);
 		break;
 	case k3_spellKindOther:
 		L1276_s_Event._priority = 0;
 		AL1267_ui_SpellPower = (L1268_i_PowerSymbolOrdinal + 1) << 2;
-		switch (L1271_ps_Spell->M68_spellType()) {
+		switch (L1271_ps_Spell->getType()) {
 		case k0_spellType_otherLight:
 			AL1269_ui_Ticks = 10000 + ((AL1267_ui_SpellPower - 8) << 9);
 			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 1);
@@ -559,40 +559,40 @@ int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
 			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
 			AL1267_ui_LightPower++;
 T0412019:
-			_vm->_championMan->_g407_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[AL1267_ui_LightPower];
+			_vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[AL1267_ui_LightPower];
 			f404_createEvent70_light(-AL1267_ui_LightPower, AL1269_ui_Ticks);
 			break;
 		case k1_spellType_otherDarkness:
 			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
-			_vm->_championMan->_g407_party._magicalLightAmount -= _vm->_championMan->_lightPowerToLightAmount[AL1267_ui_LightPower];
+			_vm->_championMan->_party._magicalLightAmount -= _vm->_championMan->_lightPowerToLightAmount[AL1267_ui_LightPower];
 			f404_createEvent70_light(AL1267_ui_LightPower, 98);
 			break;
 		case k2_spellType_otherThievesEye:
 			L1276_s_Event._type = k73_TMEventTypeThievesEye;
-			_vm->_championMan->_g407_party._event73Count_ThievesEye++;
+			_vm->_championMan->_party._event73Count_ThievesEye++;
 			AL1267_ui_SpellPower = (AL1267_ui_SpellPower >> 1);
 			goto T0412032;
 		case k3_spellType_otherInvisibility:
 			L1276_s_Event._type = k71_TMEventTypeInvisibility;
-			_vm->_championMan->_g407_party._event71Count_Invisibility++;
+			_vm->_championMan->_party._event71Count_Invisibility++;
 			goto T0412033;
 		case k4_spellType_otherPartyShield:
 			L1276_s_Event._type = k74_TMEventTypePartyShield;
 			L1276_s_Event._B._defense = AL1267_ui_SpellPower;
-			if (_vm->_championMan->_g407_party._shieldDefense > 50) {
+			if (_vm->_championMan->_party._shieldDefense > 50) {
 				L1276_s_Event._B._defense >>= 2;
 			}
-			_vm->_championMan->_g407_party._shieldDefense += L1276_s_Event._B._defense;
+			_vm->_championMan->_party._shieldDefense += L1276_s_Event._B._defense;
 			_vm->_timeline->f260_timelineRefreshAllChampionStatusBoxes();
 			goto T0412032;
 		case k6_spellType_otherFootprints:
 			L1276_s_Event._type = k79_TMEventTypeFootprints;
-			_vm->_championMan->_g407_party._event79Count_Footprints++;
-			_vm->_championMan->_g407_party._firstScentIndex = _vm->_championMan->_g407_party._scentCount;
+			_vm->_championMan->_party._event79Count_Footprints++;
+			_vm->_championMan->_party._firstScentIndex = _vm->_championMan->_party._scentCount;
 			if (L1268_i_PowerSymbolOrdinal < 3) {
-				_vm->_championMan->_g407_party._lastScentIndex = _vm->_championMan->_g407_party._firstScentIndex;
+				_vm->_championMan->_party._lastScentIndex = _vm->_championMan->_party._firstScentIndex;
 			} else {
-				_vm->_championMan->_g407_party._lastScentIndex = 0;
+				_vm->_championMan->_party._lastScentIndex = 0;
 			}
 T0412032:
 			AL1267_ui_Ticks = AL1267_ui_SpellPower * AL1267_ui_SpellPower;
@@ -616,8 +616,8 @@ T0412033:
 				}
 			}
 			if ((AL1267_ui_SlotIndex == k0_ChampionSlotReadyHand) || (AL1267_ui_SlotIndex == k1_ChampionSlotActionHand)) {
-				_vm->_championMan->f301_addObjectInSlot((ChampionIndex)champIndex, L1272_T_Object, AL1267_ui_SlotIndex);
-				_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+				_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, L1272_T_Object, AL1267_ui_SlotIndex);
+				_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 			} else {
 				_vm->_moveSens->f267_getMoveResult(L1272_T_Object, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
 			}
@@ -626,8 +626,8 @@ T0412033:
 			f403_isPartySpellOrFireShieldSuccessful(L1270_ps_Champion, false, (AL1267_ui_SpellPower * AL1267_ui_SpellPower) + 100, false);
 		}
 	}
-	_vm->_championMan->f304_addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience);
-	_vm->_championMan->f330_disableAction(champIndex, L1271_ps_Spell->M69_spellDurration());
+	_vm->_championMan->addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience);
+	_vm->_championMan->disableAction(champIndex, L1271_ps_Spell->getDuration());
 	return k1_spellCastSuccess;
 }
 
@@ -775,16 +775,16 @@ bool MenuMan::f403_isPartySpellOrFireShieldSuccessful(Champion* champ, bool spel
 	L1240_s_Event._B._defense = ticks >> 5;
 	if (spellShield) {
 		L1240_s_Event._type = k77_TMEventTypeSpellShield;
-		if (_vm->_championMan->_g407_party._spellShieldDefense > 50) {
+		if (_vm->_championMan->_party._spellShieldDefense > 50) {
 			L1240_s_Event._B._defense >>= 2;
 		}
-		_vm->_championMan->_g407_party._spellShieldDefense += L1240_s_Event._B._defense;
+		_vm->_championMan->_party._spellShieldDefense += L1240_s_Event._B._defense;
 	} else {
 		L1240_s_Event._type = k78_TMEventTypeFireShield;
-		if (_vm->_championMan->_g407_party._fireShieldDefense > 50) {
+		if (_vm->_championMan->_party._fireShieldDefense > 50) {
 			L1240_s_Event._B._defense >>= 2;
 		}
-		_vm->_championMan->_g407_party._fireShieldDefense += L1240_s_Event._B._defense;
+		_vm->_championMan->_party._fireShieldDefense += L1240_s_Event._B._defense;
 	}
 	L1240_s_Event._priority = 0;
 	M33_setMapAndTime(L1240_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + ticks);
@@ -841,7 +841,7 @@ void MenuMan::f399_addChampionSymbol(int16 symbolIndex) {
 	uint16 L1224_ui_SymbolIndex;
 	Champion* L1225_ps_Champion;
 
-	L1225_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
+	L1225_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
 	L1222_ui_SymbolStep = L1225_ps_Champion->_symbolStep;
 	L1223_ui_ManaCost = G0485_aauc_Graphic560_SymbolBaseManaCost[L1222_ui_SymbolStep][symbolIndex];
 	if (L1222_ui_SymbolStep) {
@@ -856,7 +856,7 @@ void MenuMan::f399_addChampionSymbol(int16 symbolIndex) {
 		_vm->_eventMan->f78_showMouse();
 		f397_drawAvailableSymbols(L1222_ui_SymbolStep);
 		f398_drawChampionSymbols(L1225_ps_Champion);
-		_vm->_championMan->f292_drawChampionState(_vm->_championMan->_g514_magicCasterChampionIndex);
+		_vm->_championMan->drawChampionState(_vm->_championMan->_magicCasterChampionIndex);
 		_vm->_eventMan->f77_hideMouse();
 	}
 }
@@ -865,7 +865,7 @@ void MenuMan::f400_deleteChampionSymbol() {
 	int16 L1226_ui_SymbolStep;
 	Champion* L1228_ps_Champion;
 
-	L1228_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex];
+	L1228_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
 	if (!strlen(L1228_ps_Champion->_symbols)) {
 		return;
 	}
@@ -884,10 +884,10 @@ bool MenuMan::f391_didClickTriggerAction(int16 actionListIndex) {
 	Champion* L1199_ps_Champion;
 
 
-	if (!_vm->_championMan->_g506_actingChampionOrdinal || (actionListIndex != -1 && (_g713_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone)))
+	if (!_vm->_championMan->_actingChampionOrdinal || (actionListIndex != -1 && (_g713_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone)))
 		return false;
 
-	L1199_ps_Champion = &_vm->_championMan->_gK71_champions[L1196_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)];
+	L1199_ps_Champion = &_vm->_championMan->_champions[L1196_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)];
 	if (actionListIndex == -1) {
 		// L1198_B_ClickTriggeredAction is set to -1 since booleans are stored in int16 in the original
 		L1198_B_ClickTriggeredAction = true;
@@ -1070,10 +1070,10 @@ bool MenuMan::f407_isActionPerformed(uint16 champIndex, int16 actionIndex) {
 	TimelineEvent L1258_s_Event;
 
 
-	if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
+	if (champIndex >= _vm->_championMan->_partyChampionCount) {
 		return false;
 	}
-	L1247_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	L1247_ps_Champion = &_vm->_championMan->_champions[champIndex];
 	L1248_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L1247_ps_Champion->_slots[k1_ChampionSlotActionHand]);
 	if (!L1247_ps_Champion->_currHealth) {
 		return false;
@@ -1089,7 +1089,7 @@ bool MenuMan::f407_isActionPerformed(uint16 champIndex, int16 actionIndex) {
 	AL1244_ui_TargetSquare = _vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).toByte();
 	AL1245_B_ActionPerformed = true;
 	if (((L1254_i_ActionSkillIndex >= k16_ChampionSkillFire) && (L1254_i_ActionSkillIndex <= k19_ChampionSkillWater)) || (L1254_i_ActionSkillIndex == k3_ChampionSkillWizard)) {
-		AL1246_i_RequiredManaAmount = 7 - MIN((uint16)6, _vm->_championMan->f303_getSkillLevel(champIndex, L1254_i_ActionSkillIndex));
+		AL1246_i_RequiredManaAmount = 7 - MIN((uint16)6, _vm->_championMan->getSkillLevel(champIndex, L1254_i_ActionSkillIndex));
 	}
 	switch (actionIndex) {
 	case k23_ChampionActionLightning:
@@ -1113,7 +1113,7 @@ T0407014:
 			AL1250_i_KineticEnergy = MAX(2, L1247_ps_Champion->_currMana * AL1250_i_KineticEnergy / AL1246_i_RequiredManaAmount);
 			AL1246_i_RequiredManaAmount = L1247_ps_Champion->_currMana;
 		}
-		if (!(AL1245_B_ActionPerformed = _vm->_championMan->f327_isProjectileSpellCast(champIndex, Thing(AL1245_T_ExplosionThing), AL1250_i_KineticEnergy, AL1246_i_RequiredManaAmount))) {
+		if (!(AL1245_B_ActionPerformed = _vm->_championMan->isProjectileSpellCast(champIndex, Thing(AL1245_T_ExplosionThing), AL1250_i_KineticEnergy, AL1246_i_RequiredManaAmount))) {
 			L1255_i_ActionExperienceGain >>= 1;
 		}
 		f405_decrementCharges(L1247_ps_Champion);
@@ -1127,7 +1127,7 @@ T0407014:
 		if ((Square(AL1244_ui_TargetSquare).getType() == k4_DoorElemType) && (Square(AL1244_ui_TargetSquare).getDoorState() == k4_doorState_CLOSED)) {
 			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 			L1249_ui_ActionDisabledTicks = 6;
-			_vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
+			_vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
 			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater);
 			break;
 		}
@@ -1186,9 +1186,9 @@ T0407032:
 		}
 		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
 		{ // so gotos won't skip init
-			Thing AL1250_T_Object = _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
+			Thing AL1250_T_Object = _vm->_championMan->getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
 			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
-			_vm->_championMan->f326_championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->f303_getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy);
+			_vm->_championMan->championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy);
 		}
 		break;
 	case k5_ChampionActionFlip: {
@@ -1251,7 +1251,7 @@ T0407032:
 		Mana cost is 2 * heal cycle count
 		Experience gain is 2 + 2 * heal cycle count */
 		if (((AL1250_i_MissingHealth = L1247_ps_Champion->_maxHealth - L1247_ps_Champion->_currHealth) > 0) && L1247_ps_Champion->_currMana) {
-			AL1246_i_HealingCapability = MIN((uint16)10, _vm->_championMan->f303_getSkillLevel(champIndex, k13_ChampionSkillHeal));
+			AL1246_i_HealingCapability = MIN((uint16)10, _vm->_championMan->getSkillLevel(champIndex, k13_ChampionSkillHeal));
 			L1255_i_ActionExperienceGain = 2;
 			do {
 				AL1244_ui_HealingAmount = MIN(AL1250_i_MissingHealth, AL1246_i_HealingCapability);
@@ -1266,12 +1266,12 @@ T0407032:
 		}
 		break;
 	case k39_ChampionActionWindow:
-		AL1246_i_Ticks = _vm->getRandomNumber(_vm->_championMan->f303_getSkillLevel(champIndex, L1254_i_ActionSkillIndex) + 8) + 5;
+		AL1246_i_Ticks = _vm->getRandomNumber(_vm->_championMan->getSkillLevel(champIndex, L1254_i_ActionSkillIndex) + 8) + 5;
 		L1258_s_Event._priority = 0;
 		L1258_s_Event._type = k73_TMEventTypeThievesEye;
 		M33_setMapAndTime(L1258_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + AL1246_i_Ticks);
 		_vm->_timeline->f238_addEventGetEventIndex(&L1258_s_Event);
-		_vm->_championMan->_g407_party._event73Count_ThievesEye++;
+		_vm->_championMan->_party._event73Count_ThievesEye++;
 		goto T0407076;
 	case k10_ChampionActionClimbDown:
 		L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
@@ -1295,36 +1295,36 @@ T0407032:
 		if (L1248_ps_Weapon->getType() == k43_JunkTypeMagicalBoxGreen) {
 			AL1246_i_Ticks = 125;
 T0407071:
-			_vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k1_ChampionSlotActionHand);
+			_vm->_championMan->getObjectRemovedFromSlot(champIndex, k1_ChampionSlotActionHand);
 			L1248_ps_Weapon->setNextThing(Thing::_none);
 		} else {
 			AL1246_i_Ticks = 70;
 			f405_decrementCharges(L1247_ps_Champion);
 		}
-		_vm->_championMan->_g407_party._freezeLifeTicks = MIN(200, _vm->_championMan->_g407_party._freezeLifeTicks + AL1246_i_Ticks);
+		_vm->_championMan->_party._freezeLifeTicks = MIN(200, _vm->_championMan->_party._freezeLifeTicks + AL1246_i_Ticks);
 		break;
 	case k38_ChampionActionLight:
-		_vm->_championMan->_g407_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[2];
+		_vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[2];
 		f404_createEvent70_light(-2, 2500);
 T0407076:
 		f405_decrementCharges(L1247_ps_Champion);
 		break;
 	case k42_ChampionActionThrow:
 		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
-		if (AL1245_B_ActionPerformed = _vm->_championMan->f328_isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_g308_partyDir)) || (L1247_ps_Champion->_cell == returnOppositeDir(_vm->_dungeonMan->_g308_partyDir)))) {
+		if (AL1245_B_ActionPerformed = _vm->_championMan->isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_g308_partyDir)) || (L1247_ps_Champion->_cell == returnOppositeDir(_vm->_dungeonMan->_g308_partyDir)))) {
 			_vm->_timeline->_g370_events[L1247_ps_Champion->_enableActionEventIndex]._B._slotOrdinal = _vm->M0_indexToOrdinal(k1_ChampionSlotActionHand);
 		}
 	}
 	if (L1249_ui_ActionDisabledTicks) {
-		_vm->_championMan->f330_disableAction(champIndex, L1249_ui_ActionDisabledTicks);
+		_vm->_championMan->disableAction(champIndex, L1249_ui_ActionDisabledTicks);
 	}
 	if (L1253_i_ActionStamina) {
-		_vm->_championMan->f325_decrementStamina(champIndex, L1253_i_ActionStamina);
+		_vm->_championMan->decrementStamina(champIndex, L1253_i_ActionStamina);
 	}
 	if (L1255_i_ActionExperienceGain) {
-		_vm->_championMan->f304_addSkillExperience(champIndex, L1254_i_ActionSkillIndex, L1255_i_ActionExperienceGain);
+		_vm->_championMan->addSkillExperience(champIndex, L1254_i_ActionSkillIndex, L1255_i_ActionExperienceGain);
 	}
-	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+	_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	return AL1245_B_ActionPerformed;
 }
 
@@ -1356,7 +1356,7 @@ void MenuMan::f405_decrementCharges(Champion* champ) {
 			L1243_ps_Junk->setChargeCount(L1243_ps_Junk->getChargeCount() - 1);
 		}
 	}
-	_vm->_championMan->f296_drawChangedObjectIcons();
+	_vm->_championMan->drawChangedObjectIcons();
 }
 
 bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int16 actionIndex, int16 targetMapX, int16 targetMapY, int16 skillIndex) {
@@ -1471,7 +1471,7 @@ bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int
 		case k3_ViewCellBackLeft: /* Champion is on the back left of the square and tries to attack a creature in the front left of its square */
 			AL1237_ui_CellDelta = 1;
 T0402005: /* Check if there is another champion in front */
-			if (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL1236_ui_ChampionCell + AL1237_ui_CellDelta)) != kM1_ChampionNone) {
+			if (_vm->_championMan->getIndexInCell(M21_normalizeModulo4(AL1236_ui_ChampionCell + AL1237_ui_CellDelta)) != kM1_ChampionNone) {
 				_g513_actionDamage = kM1_damageCantReach;
 				goto T0402010;
 			}
@@ -1524,7 +1524,7 @@ bool MenuMan::f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionInde
 		L1229_i_FrightAmount = 12;
 		L1231_ui_Experience = 45;
 	}
-	L1229_i_FrightAmount += _vm->_championMan->f303_getSkillLevel(champIndex, k14_ChampionSkillInfluence);
+	L1229_i_FrightAmount += _vm->_championMan->getSkillLevel(champIndex, k14_ChampionSkillInfluence);
 	L1233_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing);
 	L1234_ps_CreatureInfo = &g243_CreatureInfo[L1233_ps_Group->_type];
 	if (((L1230_ui_FearResistance = L1234_ps_CreatureInfo->M57_getFearResistance()) > _vm->getRandomNumber(L1229_i_FrightAmount)) || (L1230_ui_FearResistance == k15_immuneToFear)) {
@@ -1539,7 +1539,7 @@ bool MenuMan::f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionInde
 		L1235_ps_ActiveGroup->_delayFleeingFromTarget = ((16 - L1230_ui_FearResistance) << 2) / L1234_ps_CreatureInfo->_movementTicks;
 		L1232_B_IsGroupFrightenedByAction = true;
 	}
-	_vm->_championMan->f304_addSkillExperience(champIndex, k14_ChampionSkillInfluence, L1231_ui_Experience);
+	_vm->_championMan->addSkillExperience(champIndex, k14_ChampionSkillInfluence, L1231_ui_Experience);
 T0401016:
 	return L1232_B_IsGroupFrightenedByAction;
 }
@@ -1560,7 +1560,7 @@ void MenuMan::f381_printMessageAfterReplacements(const char* str) {
 			}
 			switch (*str) {
 			case 'p': /* '@p' in the source string is replaced by the champion name followed by a space */
-				L1165_pc_ReplacementString = _vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)]._name;
+				L1165_pc_ReplacementString = _vm->_championMan->_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._name;
 			}
 			*L1164_pc_Character = '\0';
 			strcat(L1166_ac_OutputString, L1165_pc_ReplacementString);
@@ -1629,7 +1629,7 @@ void MenuMan::f389_processCommands116To119_setActingChampion(uint16 champIndex)
 	ActionSet* L1191_ps_ActionSet;
 
 
-	L1190_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	L1190_ps_Champion = &_vm->_championMan->_champions[champIndex];
 	if (getFlag(L1190_ps_Champion->_attributes, k0x0008_ChampionAttributeDisableAction) || !L1190_ps_Champion->_currHealth) {
 		return;
 	}
@@ -1639,11 +1639,11 @@ void MenuMan::f389_processCommands116To119_setActingChampion(uint16 champIndex)
 		return;
 	}
 	L1191_ps_ActionSet = &G0489_as_Graphic560_ActionSets[L1188_ui_ActionSetIndex];
-	_vm->_championMan->_g506_actingChampionOrdinal = _vm->M0_indexToOrdinal(champIndex);
+	_vm->_championMan->_actingChampionOrdinal = _vm->M0_indexToOrdinal(champIndex);
 	f383_setActionList(L1191_ps_ActionSet);
 	_g509_actionAreaContainsIcons = false;
 	setFlag(L1190_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand);
-	_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+	_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	f387_drawActionArea();
 	f387_drawActionArea();
 }
@@ -1666,7 +1666,7 @@ void MenuMan::f383_setActionList(ActionSet* actionSet) {
 		if (getFlag(L1172_ui_MinimumSkillLevel = actionSet->_actionProperties[L1169_ui_ActionListIndex - 1], k0x0080_actionRequiresCharge) && !f382_getActionObjectChargeCount())
 			continue;
 		clearFlag(L1172_ui_MinimumSkillLevel, k0x0080_actionRequiresCharge);
-		if (_vm->_championMan->f303_getSkillLevel(_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal), g496_ActionSkillIndex[L1171_ui_ActionIndex]) >= L1172_ui_MinimumSkillLevel) {
+		if (_vm->_championMan->getSkillLevel(_vm->M1_ordinalToIndex(_vm->_championMan->_actingChampionOrdinal), g496_ActionSkillIndex[L1171_ui_ActionIndex]) >= L1172_ui_MinimumSkillLevel) {
 			_g713_actionList._actionIndices[L1170_ui_NextAvailableActionListIndex] = (ChampionAction)L1171_ui_ActionIndex;
 			_g713_actionList._minimumSkillLevel[L1170_ui_NextAvailableActionListIndex] = L1172_ui_MinimumSkillLevel;
 			L1170_ui_NextAvailableActionListIndex++;
@@ -1683,7 +1683,7 @@ int16 MenuMan::f382_getActionObjectChargeCount() {
 	Junk* L1168_ps_Junk;
 
 
-	L1168_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1167_T_Thing = _vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand]);
+	L1168_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1167_T_Thing = _vm->_championMan->_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand]);
 	switch (L1167_T_Thing.getType()) {
 	case k5_WeaponThingType:
 		return ((Weapon*)L1168_ps_Junk)->getChargeCount();
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index e961eca..416b48c 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -73,7 +73,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 
 
 	L0759_B_AtLeastOneSensorWasTriggered = false;
-	L0761_T_LeaderHandObject = _vm->_championMan->_g414_leaderHandObject;
+	L0761_T_LeaderHandObject = _vm->_championMan->_leaderHandObject;
 	for (L0752_ui_Cell = k0_CellNorthWest; L0752_ui_Cell < k3_CellSouthWest + 1; L0752_ui_Cell++) {
 		L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell] = 0;
 	}
@@ -94,7 +94,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 			L0755_ps_Sensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0750_T_ThingBeingProcessed);
 			if ((L0757_ui_SensorType = (L0755_ps_Sensor)->getType()) == k0_SensorDisabled)
 				goto T0275058_ProceedToNextThing;
-			if ((_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) && (L0757_ui_SensorType != k127_SensorWallChampionPortrait))
+			if ((_vm->_championMan->_leaderIndex == kM1_ChampionNone) && (L0757_ui_SensorType != k127_SensorWallChampionPortrait))
 				goto T0275058_ProceedToNextThing;
 			if (L0752_ui_Cell != cellParam)
 				goto T0275058_ProceedToNextThing;
@@ -108,7 +108,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 				}
 				break;
 			case k2_SensorWallOrnClickWithAnyObj:
-				L0753_B_DoNotTriggerSensor = (_vm->_championMan->_g415_leaderEmptyHanded != L0755_ps_Sensor->getRevertEffectA());
+				L0753_B_DoNotTriggerSensor = (_vm->_championMan->_leaderEmptyHanded != L0755_ps_Sensor->getRevertEffectA());
 				break;
 			case k17_SensorWallOrnClickWithSpecObjRemovedSensor:
 			case k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors:
@@ -132,26 +132,26 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 			case k12_SensorWallObjGeneratorRotateSensors:
 				if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */
 					goto T0275058_ProceedToNextThing;
-				L0753_B_DoNotTriggerSensor = !_vm->_championMan->_g415_leaderEmptyHanded;
+				L0753_B_DoNotTriggerSensor = !_vm->_championMan->_leaderEmptyHanded;
 				if (!L0753_B_DoNotTriggerSensor) {
 					f270_sensorTriggetLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
 				}
 				break;
 			case k13_SensorWallSingleObjStorageRotateSensors:
-				if (_vm->_championMan->_g415_leaderEmptyHanded) {
+				if (_vm->_championMan->_leaderEmptyHanded) {
 					if ((L0761_T_LeaderHandObject = f273_sensorGetObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData)) == Thing::_none)
 						goto T0275058_ProceedToNextThing;
 					_vm->_dungeonMan->f164_unlinkThingFromList(L0761_T_LeaderHandObject, Thing(0), mapX, mapY);
-					_vm->_championMan->f297_putObjectInLeaderHand(L0761_T_LeaderHandObject, true);
+					_vm->_championMan->putObjectInLeaderHand(L0761_T_LeaderHandObject, true);
 				} else {
 					if ((_vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (f273_sensorGetObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData) != Thing::_none))
 						goto T0275058_ProceedToNextThing;
-					_vm->_championMan->f298_getObjectRemovedFromLeaderHand();
+					_vm->_championMan->getObjectRemovedFromLeaderHand();
 					_vm->_dungeonMan->f163_linkThingToList(M15_thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
 					L0761_T_LeaderHandObject = Thing::_none;
 				}
 				f270_sensorTriggetLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
-				if ((L0756_i_SensorEffect == k3_SensorEffHold) && !_vm->_championMan->_g415_leaderEmptyHanded) {
+				if ((L0756_i_SensorEffect == k3_SensorEffHold) && !_vm->_championMan->_leaderEmptyHanded) {
 					L0753_B_DoNotTriggerSensor = true;
 				} else {
 					L0753_B_DoNotTriggerSensor = false;
@@ -164,13 +164,13 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 				if ((_vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (L0762_T_ThingOnSquare == Thing::_none))
 					goto T0275058_ProceedToNextThing;
 				_vm->_dungeonMan->f164_unlinkThingFromList(L0762_T_ThingOnSquare, Thing(0), mapX, mapY);
-				_vm->_championMan->f298_getObjectRemovedFromLeaderHand();
+				_vm->_championMan->getObjectRemovedFromLeaderHand();
 				_vm->_dungeonMan->f163_linkThingToList(M15_thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
-				_vm->_championMan->f297_putObjectInLeaderHand(L0762_T_ThingOnSquare, true);
+				_vm->_championMan->putObjectInLeaderHand(L0762_T_ThingOnSquare, true);
 				L0753_B_DoNotTriggerSensor = false;
 				break;
 			case k127_SensorWallChampionPortrait:
-				_vm->_championMan->f280_addCandidateChampionToParty(L0758_i_SensorData);
+				_vm->_championMan->addCandidateChampionToParty(L0758_i_SensorData);
 				goto T0275058_ProceedToNextThing;
 			default:
 				goto T0275058_ProceedToNextThing;
@@ -184,16 +184,16 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 				if (L0755_ps_Sensor->getAudibleA()) {
 					_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 				}
-				if (!_vm->_championMan->_g415_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
+				if (!_vm->_championMan->_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
 					L0754_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0761_T_LeaderHandObject);
 					*L0754_ps_Generic = Thing::_none;
-					_vm->_championMan->f298_getObjectRemovedFromLeaderHand();
+					_vm->_championMan->getObjectRemovedFromLeaderHand();
 					L0761_T_LeaderHandObject = Thing::_none;
 				} else {
-					if (_vm->_championMan->_g415_leaderEmptyHanded &&
+					if (_vm->_championMan->_leaderEmptyHanded &&
 						(L0757_ui_SensorType == k12_SensorWallObjGeneratorRotateSensors) &&
 						((L0761_T_LeaderHandObject = _vm->_dungeonMan->f167_getObjForProjectileLaucherOrObjGen(L0758_i_SensorData)) != Thing::_none)) {
-						_vm->_championMan->f297_putObjectInLeaderHand(L0761_T_LeaderHandObject, true);
+						_vm->_championMan->putObjectInLeaderHand(L0761_T_LeaderHandObject, true);
 					}
 				}
 				f272_sensorTriggerEffect(L0755_ps_Sensor, L0756_i_SensorEffect, mapX, mapY, L0752_ui_Cell);
@@ -268,7 +268,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 			_vm->_dungeonMan->_g306_partyMapX = destMapX;
 			_vm->_dungeonMan->_g307_partyMapY = destMapY;
 			L0718_i_RequiredTeleporterScope = k0x0002_TelepScopeObjOrParty;
-			L0723_B_DrawDungeonViewWhileFalling = !_vm->_inventoryMan->_g432_inventoryChampionOrdinal && !_vm->_championMan->_g300_partyIsSleeping;
+			L0723_B_DrawDungeonViewWhileFalling = !_vm->_inventoryMan->_g432_inventoryChampionOrdinal && !_vm->_championMan->_partyIsSleeping;
 			L0716_ui_Direction = _vm->_dungeonMan->_g308_partyDir;
 		} else {
 			if (L0710_i_ThingType == k4_GroupThingType) {
@@ -304,9 +304,9 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					}
 					L0723_B_DrawDungeonViewWhileFalling = true;
 					if (L0712_ps_Teleporter->getAbsoluteRotation()) {
-						_vm->_championMan->f284_setPartyDirection(L0712_ps_Teleporter->getRotation());
+						_vm->_championMan->setPartyDirection(L0712_ps_Teleporter->getRotation());
 					} else {
-						_vm->_championMan->f284_setPartyDirection(M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + L0712_ps_Teleporter->getRotation()));
+						_vm->_championMan->setPartyDirection(M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + L0712_ps_Teleporter->getRotation()));
 					}
 				} else {
 					if (L0710_i_ThingType == k4_GroupThingType) {
@@ -344,15 +344,15 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					if (thing == Thing::_party) {
 						_vm->_dungeonMan->_g306_partyMapX = destMapX;
 						_vm->_dungeonMan->_g307_partyMapY = destMapY;
-						if (_vm->_championMan->_g305_partyChampionCount > 0) {
+						if (_vm->_championMan->_partyChampionCount > 0) {
 							if (_g402_useRopeToClimbDownPit) {
-								for (AL0709_i_ChampionIndex = k0_ChampionFirst, L0711_ps_Champion = _vm->_championMan->_gK71_champions; AL0709_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL0709_i_ChampionIndex++, L0711_ps_Champion++) {
+								for (AL0709_i_ChampionIndex = k0_ChampionFirst, L0711_ps_Champion = _vm->_championMan->_champions; AL0709_i_ChampionIndex < _vm->_championMan->_partyChampionCount; AL0709_i_ChampionIndex++, L0711_ps_Champion++) {
 									if (L0711_ps_Champion->_currHealth) {
-										_vm->_championMan->f325_decrementStamina(AL0709_i_ChampionIndex, ((L0711_ps_Champion->_load * 25) / _vm->_championMan->f309_getMaximumLoad(L0711_ps_Champion)) + 1);
+										_vm->_championMan->decrementStamina(AL0709_i_ChampionIndex, ((L0711_ps_Champion->_load * 25) / _vm->_championMan->getMaximumLoad(L0711_ps_Champion)) + 1);
 									}
 								}
 							} else {
-								if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF)) {
+								if (_vm->_championMan->getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF)) {
 									_vm->_sound->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
 								}
 							}
@@ -412,26 +412,26 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				}
 			}
 		} else {
-			if ((thing == Thing::_party) && _vm->_championMan->_g305_partyChampionCount) {
+			if ((thing == Thing::_party) && _vm->_championMan->_partyChampionCount) {
 				AL0727_ui_Backup = AL0708_i_DestinationSquare;
-				AL0708_i_ScentIndex = _vm->_championMan->_g407_party._scentCount;
+				AL0708_i_ScentIndex = _vm->_championMan->_party._scentCount;
 				while (AL0708_i_ScentIndex >= 24) {
-					_vm->_championMan->f316_deleteScent(0);
+					_vm->_championMan->deleteScent(0);
 					AL0708_i_ScentIndex--;
 				}
 				if (AL0708_i_ScentIndex) {
-					_vm->_championMan->f317_addScentStrength(mapX, mapY, (int)(_vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime));
+					_vm->_championMan->addScentStrength(mapX, mapY, (int)(_vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime));
 				}
 				_vm->_projexpl->_g362_lastPartyMovementTime = _vm->_g313_gameTime;
-				_vm->_championMan->_g407_party._scentCount++;
-				if (_vm->_championMan->_g407_party._event79Count_Footprints) {
-					_vm->_championMan->_g407_party._lastScentIndex = _vm->_championMan->_g407_party._scentCount;
+				_vm->_championMan->_party._scentCount++;
+				if (_vm->_championMan->_party._event79Count_Footprints) {
+					_vm->_championMan->_party._lastScentIndex = _vm->_championMan->_party._scentCount;
 				}
-				_vm->_championMan->_g407_party._scents[AL0708_i_ScentIndex].setMapX(destMapX);
-				_vm->_championMan->_g407_party._scents[AL0708_i_ScentIndex].setMapY(destMapY);
-				_vm->_championMan->_g407_party._scents[AL0708_i_ScentIndex].setMapIndex(L0715_ui_MapIndexDestination);
-				_vm->_championMan->_g407_party._scentStrengths[AL0708_i_ScentIndex] = 0;
-				_vm->_championMan->f317_addScentStrength(destMapX, destMapY, k0x8000_mergeCycles | 24);
+				_vm->_championMan->_party._scents[AL0708_i_ScentIndex].setMapX(destMapX);
+				_vm->_championMan->_party._scents[AL0708_i_ScentIndex].setMapY(destMapY);
+				_vm->_championMan->_party._scents[AL0708_i_ScentIndex].setMapIndex(L0715_ui_MapIndexDestination);
+				_vm->_championMan->_party._scentStrengths[AL0708_i_ScentIndex] = 0;
+				_vm->_championMan->addScentStrength(destMapX, destMapY, k0x8000_mergeCycles | 24);
 				AL0708_i_DestinationSquare = AL0727_ui_Backup;
 			}
 			if (L0715_ui_MapIndexDestination != L0714_ui_MapIndexSource) {
@@ -565,7 +565,7 @@ bool MovesensMan::f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMa
 	if (thing == Thing::_party) {
 		L0702_i_ImpactType = kM2_ChampionElemType;
 		for (AL0699_ui_Cell = k0_CellNorthWest; AL0699_ui_Cell < k3_CellSouthWest + 1; AL0699_ui_Cell++) {
-			if (_vm->_championMan->f285_getIndexInCell((ViewCell)AL0699_ui_Cell) >= 0) {
+			if (_vm->_championMan->getIndexInCell((ViewCell)AL0699_ui_Cell) >= 0) {
 				L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = _vm->M0_indexToOrdinal(AL0699_ui_Cell);
 			}
 		}
@@ -645,7 +645,7 @@ void MovesensMan::f268_addEvent(byte type, byte mapX, byte mapY, byte cell, byte
 }
 
 int16 MovesensMan::f514_getSound(byte creatureType) {
-	if (_vm->_championMan->_g300_partyIsSleeping) {
+	if (_vm->_championMan->_partyIsSleeping) {
 		return 35;
 	}
 
@@ -839,7 +839,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 						goto T0276079;
 					break;
 				case k3_SensorFloorParty:
-					if ((L0767_i_ThingType != kM1_PartyThingType) || (_vm->_championMan->_g305_partyChampionCount == 0))
+					if ((L0767_i_ThingType != kM1_PartyThingType) || (_vm->_championMan->_partyChampionCount == 0))
 						goto T0276079;
 					if (L0779_i_SensorData == 0) {
 						if (partySquare)
@@ -933,7 +933,7 @@ bool MovesensMan::f274_sensorIsObjcetInPartyPossession(int16 objectType) {
 
 
 	L0748_B_LeaderHandObjectProcessed = false;
-	for (L0742_i_ChampionIndex = k0_ChampionFirst, L0745_ps_Champion = _vm->_championMan->_gK71_champions; L0742_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0742_i_ChampionIndex++, L0745_ps_Champion++) {
+	for (L0742_i_ChampionIndex = k0_ChampionFirst, L0745_ps_Champion = _vm->_championMan->_champions; L0742_i_ChampionIndex < _vm->_championMan->_partyChampionCount; L0742_i_ChampionIndex++, L0745_ps_Champion++) {
 		if (L0745_ps_Champion->_currHealth) {
 			L0746_pT_Thing = L0745_ps_Champion->_slots;
 			for (L0743_ui_SlotIndex = k0_ChampionSlotReadyHand; (L0743_ui_SlotIndex < k30_ChampionSlotChest_1) && !L0748_B_LeaderHandObjectProcessed; L0743_ui_SlotIndex++) {
@@ -957,7 +957,7 @@ T0274003:
 	}
 	if (!L0748_B_LeaderHandObjectProcessed) {
 		L0748_B_LeaderHandObjectProcessed = true;
-		L0744_T_Thing = _vm->_championMan->_g414_leaderHandObject;
+		L0744_T_Thing = _vm->_championMan->_leaderHandObject;
 		goto T0274003;
 	}
 	return false;
@@ -1013,15 +1013,15 @@ void MovesensMan::f270_sensorTriggetLocalEffect(int16 localEffect, int16 effX, i
 void MovesensMan::f269_sensorAddSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly) {
 
 	if (leaderOnly) {
-		if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) {
-			_vm->_championMan->f304_addSkillExperience(_vm->_championMan->_g411_leaderIndex, skillIndex, exp);
+		if (_vm->_championMan->_leaderIndex != kM1_ChampionNone) {
+			_vm->_championMan->addSkillExperience(_vm->_championMan->_leaderIndex, skillIndex, exp);
 		}
 	} else {
-		exp /= _vm->_championMan->_g305_partyChampionCount;
-		Champion *L0731_ps_Champion = _vm->_championMan->_gK71_champions;
-		for (int16 L0730_i_ChampionIndex = k0_ChampionFirst; L0730_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0730_i_ChampionIndex++, L0731_ps_Champion++) {
+		exp /= _vm->_championMan->_partyChampionCount;
+		Champion *L0731_ps_Champion = _vm->_championMan->_champions;
+		for (int16 L0730_i_ChampionIndex = k0_ChampionFirst; L0730_i_ChampionIndex < _vm->_championMan->_partyChampionCount; L0730_i_ChampionIndex++, L0731_ps_Champion++) {
 			if (L0731_ps_Champion->_currHealth) {
-				_vm->_championMan->f304_addSkillExperience(L0730_i_ChampionIndex, skillIndex, exp);
+				_vm->_championMan->addSkillExperience(L0730_i_ChampionIndex, skillIndex, exp);
 			}
 		}
 	}
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index debf948..fe5737d 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -246,12 +246,12 @@ void ObjectMan::f34_drawLeaderObjectName(Thing thing) {
 		default:
 		case Common::EN_ANY:
 		case Common::DE_DEU: // english and german version are the same
-			strcpy(champBonesName, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name);
+			strcpy(champBonesName, _vm->_championMan->_champions[junk->getChargeCount()]._name);
 			strcat(champBonesName, _g352_objectNames[L0007_i_IconIndex]);
 			break;
 		case Common::FR_FRA:
 			strcat(champBonesName, _g352_objectNames[L0007_i_IconIndex]);
-			strcpy(champBonesName, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name);
+			strcpy(champBonesName, _vm->_championMan->_champions[junk->getChargeCount()]._name);
 			break;
 		}
 
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 2ca7be1..5fd4b12 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -173,7 +173,7 @@ T0217004:
 		_vm->_groupMan->f232_groupIsDoorDestoryedByAttack(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, L0488_i_Attack + _vm->getRandomNumber(L0488_i_Attack), false, 0);
 		break;
 	case kM2_ChampionElemType:
-		if ((AP0456_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(cell)) < 0) {
+		if ((AP0456_i_ChampionIndex = _vm->_championMan->getIndexInCell(cell)) < 0) {
 			return false;
 		}
 		L0489_i_ChampionAttack = L0488_i_Attack = f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing);
@@ -211,8 +211,8 @@ T0217004:
 			}
 		}
 	}
-	if (L0489_i_ChampionAttack && _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(AP0456_i_ChampionIndex, L0488_i_Attack, k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso, _g367_projectileAttackType) && _g366_projectilePoisonAttack && _vm->getRandomNumber(2)) {
-		_vm->_championMan->f322_championPoison(AP0456_i_ChampionIndex, _g366_projectilePoisonAttack);
+	if (L0489_i_ChampionAttack && _vm->_championMan->addPendingDamageAndWounds_getDamage(AP0456_i_ChampionIndex, L0488_i_Attack, k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso, _g367_projectileAttackType) && _g366_projectilePoisonAttack && _vm->getRandomNumber(2)) {
+		_vm->_championMan->championPoison(AP0456_i_ChampionIndex, _g366_projectilePoisonAttack);
 	}
 	if (L0505_B_CreateExplosionOnImpact || L0509_B_RemovePotion
 		) {
@@ -348,7 +348,7 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 		attack += _vm->getRandomNumber(attack) + 1;
 		if ((explThing == Thing::_explFireBall) || (attack >>= 1)) {
 			if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (AP0443_ui_ProjectileMapX == _vm->_dungeonMan->_g306_partyMapX) && (AP0444_ui_ProjectileMapY == _vm->_dungeonMan->_g307_partyMapY)) {
-				_vm->_championMan->f324_damageAll_getDamagedChampionCount(attack, k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand | k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k1_attackType_FIRE);
+				_vm->_championMan->getDamagedChampionCount(attack, k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand | k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k1_attackType_FIRE);
 			} else {
 				if ((L0473_T_Thing = _vm->_groupMan->f175_groupGetThing(AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY)) != Thing::_endOfList) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
 					Group *L0472_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0473_T_Thing);
@@ -579,7 +579,7 @@ void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) {
 		break;
 	case 0xFF87:
 		if (L0538_B_ExplosionOnPartySquare) {
-			_vm->_championMan->f324_damageAll_getDamagedChampionCount(L0530_i_Attack, k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
+			_vm->_championMan->getDamagedChampionCount(L0530_i_Attack, k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
 		} else {
 			if ((L0535_T_GroupThing != Thing::_endOfList) && (L0530_i_Attack = _vm->_groupMan->f192_groupGetResistanceAdjustedPoisonAttack(AL0537_ui_CreatureType, L0530_i_Attack)) && (_vm->_groupMan->f191_getDamageAllCreaturesOutcome(L0533_ps_Group, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true) != k2_outcomeKilledAllCreaturesInGroup) && (L0530_i_Attack > 2)) {
 				_vm->_groupMan->f209_processEvents29to41(L0528_ui_MapX, L0529_ui_MapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 4ada95f..27f58c9 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -343,37 +343,37 @@ void Timeline::f261_processTimeline() {
 				_vm->_inventoryMan->f337_setDungeonViewPalette();
 				break;
 			case k71_TMEventTypeInvisibility:
-				_vm->_championMan->_g407_party._event71Count_Invisibility--;
+				_vm->_championMan->_party._event71Count_Invisibility--;
 				break;
 			case k72_TMEventTypeChampionShield:
-				_vm->_championMan->_gK71_champions[L0682_s_Event._priority]._shieldDefense -= L0682_s_Event._B._defense;
-				setFlag(_vm->_championMan->_gK71_champions[L0682_s_Event._priority]._attributes, k0x1000_ChampionAttributeStatusBox);
+				_vm->_championMan->_champions[L0682_s_Event._priority]._shieldDefense -= L0682_s_Event._B._defense;
+				setFlag(_vm->_championMan->_champions[L0682_s_Event._priority]._attributes, k0x1000_ChampionAttributeStatusBox);
 T0261048:
-				_vm->_championMan->f292_drawChampionState((ChampionIndex)L0682_s_Event._priority);
+				_vm->_championMan->drawChampionState((ChampionIndex)L0682_s_Event._priority);
 				break;
 			case k73_TMEventTypeThievesEye:
-				_vm->_championMan->_g407_party._event73Count_ThievesEye--;
+				_vm->_championMan->_party._event73Count_ThievesEye--;
 				break;
 			case k74_TMEventTypePartyShield:
-				_vm->_championMan->_g407_party._shieldDefense -= L0682_s_Event._B._defense;
+				_vm->_championMan->_party._shieldDefense -= L0682_s_Event._B._defense;
 T0261053:
 				f260_timelineRefreshAllChampionStatusBoxes();
 				break;
 			case k77_TMEventTypeSpellShield:
-				_vm->_championMan->_g407_party._spellShieldDefense -= L0682_s_Event._B._defense;
+				_vm->_championMan->_party._spellShieldDefense -= L0682_s_Event._B._defense;
 				goto T0261053;
 			case k78_TMEventTypeFireShield:
-				_vm->_championMan->_g407_party._fireShieldDefense -= L0682_s_Event._B._defense;
+				_vm->_championMan->_party._fireShieldDefense -= L0682_s_Event._B._defense;
 				goto T0261053;
 			case k75_TMEventTypePoisonChampion:
-				_vm->_championMan->_gK71_champions[AL0680_ui_ChampionIndex = L0682_s_Event._priority]._poisonEventCount--;
-				_vm->_championMan->f322_championPoison(AL0680_ui_ChampionIndex, L0682_s_Event._B._attack);
+				_vm->_championMan->_champions[AL0680_ui_ChampionIndex = L0682_s_Event._priority]._poisonEventCount--;
+				_vm->_championMan->championPoison(AL0680_ui_ChampionIndex, L0682_s_Event._B._attack);
 				break;
 			case k13_TMEventTypeViAltarRebirth:
 				f255_timelineProcessEvent13_ViAltarRebirth(L0681_ps_Event);
 				break;
 			case k79_TMEventTypeFootprints:
-				_vm->_championMan->_g407_party._event79Count_Footprints--;
+				_vm->_championMan->_party._event79Count_Footprints--;
 			}
 		}
 		_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
@@ -414,13 +414,13 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 		L0598_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0593_ui_MapX, L0594_ui_MapY);
 		AL0602_ui_VerticalDoor = L0598_ps_Door->opensVertically();
 		if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0593_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0594_ui_MapY == _vm->_dungeonMan->_g307_partyMapY) && (L0596_i_DoorState != k0_doorState_OPEN)) {
-			if (_vm->_championMan->_g305_partyChampionCount > 0) {
+			if (_vm->_championMan->_partyChampionCount > 0) {
 				L0597_puc_Square->setDoorState(k0_doorState_OPEN);
 
 				// Strangerke
 				// Original bug fixed - A closing horizontal door wounds champions to the head instead of to the hands. Missing parenthesis in the condition cause all doors to wound the head in addition to the torso
 				// See BUG0_78
-				if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(5, k0x0008_ChampionWoundTorso | (AL0602_ui_VerticalDoor ? k0x0004_ChampionWoundHead : k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand), k2_attackType_SELF)) {
+				if (_vm->_championMan->getDamagedChampionCount(5, k0x0008_ChampionWoundTorso | (AL0602_ui_VerticalDoor ? k0x0004_ChampionWoundHead : k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand), k2_attackType_SELF)) {
 					_vm->_sound->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
 				}
 			}
@@ -555,7 +555,7 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 
 	if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX == _vm->_dungeonMan->_g306_partyMapX) && (mapY == _vm->_dungeonMan->_g307_partyMapY)) {
 		_vm->_moveSens->f267_getMoveResult(Thing::_party, mapX, mapY, mapX, mapY);
-		_vm->_championMan->f296_drawChangedObjectIcons();
+		_vm->_championMan->drawChangedObjectIcons();
 	}
 	if ((L0645_T_Thing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) != Thing::_endOfList) {
 		_vm->_moveSens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
@@ -932,7 +932,7 @@ void Timeline::f253_timelineProcessEvent11Part1_enableChampionAction(uint16 cham
 	int16 L0661_i_QuiverSlotIndex;
 	Champion* L0662_ps_Champion;
 
-	L0662_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	L0662_ps_Champion = &_vm->_championMan->_champions[champIndex];
 	L0662_ps_Champion->_enableActionEventIndex = -1;
 	clearFlag(L0662_ps_Champion->_attributes, k0x0008_ChampionAttributeDisableAction);
 	if (L0662_ps_Champion->_actionIndex != k255_ChampionActionNone) {
@@ -940,18 +940,18 @@ void Timeline::f253_timelineProcessEvent11Part1_enableChampionAction(uint16 cham
 	}
 	if (L0662_ps_Champion->_currHealth) {
 		if ((L0662_ps_Champion->_actionIndex == k32_ChampionActionShoot) && (L0662_ps_Champion->_slots[k0_ChampionSlotReadyHand] == Thing::_none)) {
-			if (_vm->_championMan->f294_isAmmunitionCompatibleWithWeapon(champIndex, k1_ChampionSlotActionHand, L0660_i_SlotIndex = k12_ChampionSlotQuiverLine_1_1)) {
+			if (_vm->_championMan->isAmmunitionCompatibleWithWeapon(champIndex, k1_ChampionSlotActionHand, L0660_i_SlotIndex = k12_ChampionSlotQuiverLine_1_1)) {
 T0253002:
-				_vm->_championMan->f301_addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, L0660_i_SlotIndex), k0_ChampionSlotReadyHand);
+				_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->getObjectRemovedFromSlot(champIndex, L0660_i_SlotIndex), k0_ChampionSlotReadyHand);
 			} else {
 				for (L0661_i_QuiverSlotIndex = 0; L0661_i_QuiverSlotIndex < 3; L0661_i_QuiverSlotIndex++) {
-					if (_vm->_championMan->f294_isAmmunitionCompatibleWithWeapon(champIndex, k1_ChampionSlotActionHand, L0660_i_SlotIndex = L0661_i_QuiverSlotIndex + k7_ChampionSlotQuiverLine_2_1))
+					if (_vm->_championMan->isAmmunitionCompatibleWithWeapon(champIndex, k1_ChampionSlotActionHand, L0660_i_SlotIndex = L0661_i_QuiverSlotIndex + k7_ChampionSlotQuiverLine_2_1))
 						goto T0253002;
 				}
 			}
 		}
 		setFlag(L0662_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand);
-		_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+		_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	}
 	L0662_ps_Champion->_actionIndex = k255_ChampionActionNone;
 }
@@ -960,7 +960,7 @@ void Timeline::f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(uint1
 	uint16 L0677_ui_SlotIndex;
 	Champion* L0678_ps_Champion;
 
-	L0678_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	L0678_ps_Champion = &_vm->_championMan->_champions[champIndex];
 	if (L0678_ps_Champion->_slots[slotIndex] != Thing::_none) {
 		return;
 	}
@@ -975,7 +975,7 @@ void Timeline::f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(uint1
 
 bool Timeline::f258_timelineHasWeaponMovedSlot(int16 champIndex, Champion* champ, uint16 sourceSlotIndex, int16 destSlotIndex) {
 	if (Thing(champ->_slots[sourceSlotIndex]).getType() == k5_WeaponThingType) {
-		_vm->_championMan->f301_addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, sourceSlotIndex),
+		_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->getObjectRemovedFromSlot(champIndex, sourceSlotIndex),
 			(ChampionSlot)destSlotIndex);
 		return true;
 	}
@@ -986,7 +986,7 @@ void Timeline::f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex)
 	Champion* L0663_ps_Champion;
 
 
-	L0663_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+	L0663_ps_Champion = &_vm->_championMan->_champions[champIndex];
 	L0663_ps_Champion->_hideDamageReceivedIndex = -1;
 	if (!L0663_ps_Champion->_currHealth) {
 		return;
@@ -997,7 +997,7 @@ void Timeline::f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex)
 		_vm->_eventMan->f77_hideMouse();
 	} else {
 		setFlag(L0663_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle);
-		_vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+		_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	}
 }
 
@@ -1025,7 +1025,7 @@ void Timeline::f257_timelineProcessEvent70_light(TimelineEvent* event) {
 		AL0674_i_LightAmount = -AL0674_i_LightAmount;
 		L0673_i_WeakerLightPower = -L0673_i_WeakerLightPower;
 	}
-	_vm->_championMan->_g407_party._magicalLightAmount += AL0674_i_LightAmount;
+	_vm->_championMan->_party._magicalLightAmount += AL0674_i_LightAmount;
 	if (L0673_i_WeakerLightPower) {
 		L0676_s_Event._type = k70_TMEventTypeLight;
 		L0676_s_Event._B._lightPower = L0673_i_WeakerLightPower;
@@ -1038,10 +1038,10 @@ void Timeline::f257_timelineProcessEvent70_light(TimelineEvent* event) {
 void Timeline::f260_timelineRefreshAllChampionStatusBoxes() {
 	uint16 L0679_ui_ChampionIndex;
 
-	for (L0679_ui_ChampionIndex = k0_ChampionFirst; L0679_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0679_ui_ChampionIndex++) {
-		setFlag(_vm->_championMan->_gK71_champions[L0679_ui_ChampionIndex]._attributes, k0x1000_ChampionAttributeStatusBox);
+	for (L0679_ui_ChampionIndex = k0_ChampionFirst; L0679_ui_ChampionIndex < _vm->_championMan->_partyChampionCount; L0679_ui_ChampionIndex++) {
+		setFlag(_vm->_championMan->_champions[L0679_ui_ChampionIndex]._attributes, k0x1000_ChampionAttributeStatusBox);
 	}
-	_vm->_championMan->f293_drawAllChampionStates();
+	_vm->_championMan->drawAllChampionStates();
 }
 
 void Timeline::f255_timelineProcessEvent13_ViAltarRebirth(TimelineEvent* event) {
@@ -1088,7 +1088,7 @@ T0255002:
 		}
 		break;
 	case 0:
-		_vm->_championMan->f283_viAltarRebirth(event->_priority);
+		_vm->_championMan->viAltarRebirth(event->_priority);
 	}
 }
 


Commit: 5bd446407690f00dd4282c9840e9c82014bc2f52
    https://github.com/scummvm/scummvm/commit/5bd446407690f00dd4282c9840e9c82014bc2f52
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix some more GCC warnings

Changed paths:
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/projexpl.cpp



diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 2c10ded..e941663 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -553,8 +553,8 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 
 		_g422_objDescTextYpos = 87;
 
-		uint16 potentialAttribMask;
-		uint16 actualAttribMask;
+		uint16 potentialAttribMask = 0;
+		uint16 actualAttribMask = 0;
 		switch (thingType) {
 		case k5_WeaponThingType: {
 			potentialAttribMask = k0x0008_DescriptionMaskCursed | k0x0002_DescriptionMaskPoisoned | k0x0004_DescriptionMaskBroken;
@@ -588,9 +588,9 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		case k10_JunkThingType: {
 			if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
 				potentialAttribMask = 0;
-				char *descString_EN_ANY[4] = {"(EMPTY)", "(ALMOST EMPTY)", "(ALMOST FULL)", "(FULL)"};
-				char *descString_DE_DEU[4] = {"(LEER)", "(FAST LEER)", "(FAST VOLL)", "(VOLL)"};
-				char *descString_FR_FRA[4] = {"(VIDE)", "(PRESQUE VIDE)", "(PRESQUE PLEINE)", "(PLEINE)"};
+				const char *descString_EN_ANY[4] = {"(EMPTY)", "(ALMOST EMPTY)", "(ALMOST FULL)", "(FULL)"};
+				const char *descString_DE_DEU[4] = {"(LEER)", "(FAST LEER)", "(FAST VOLL)", "(VOLL)"};
+				const char *descString_FR_FRA[4] = {"(VIDE)", "(PRESQUE VIDE)", "(PRESQUE PLEINE)", "(PLEINE)"};
 
 				Junk *junk = (Junk *)rawThingPtr;
 				switch (_vm->getGameLanguage()) { // localized
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 5a7c9f1..d387044 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -282,25 +282,23 @@ void MenuMan::f387_drawActionArea() {
 	_g508_refreshActionArea = false;
 }
 
-const char *g490_ChampionActionNames[44] = { // @ G0490_ac_Graphic560_ActionNames
-	"N", "BLOCK", "CHOP", "X", "BLOW HORN", "FLIP", "PUNCH",
-	"KICK", "WAR CRY", "STAB", "CLIMB DOWN", "FREEZE LIFE",
-	"HIT", "SWING", "STAB", "THRUST", "JAB", "PARRY", "HACK",
-	"BERZERK", "FIREBALL", "DISPELL", "CONFUSE", "LIGHTNING",
-	"DISRUPT", "MELEE", "X", "INVOKE", "SLASH", "CLEAVE",
-	"BASH", "STUN", "SHOOT", "SPELLSHIELD", "FIRESHIELD",
-	"FLUXCAGE", "HEAL", "CALM", "LIGHT", "WINDOW", "SPIT",
-	"BRANDISH", "THROW", "FUSE"};
-
 const char* MenuMan::f384_getActionName(ChampionAction actionIndex) {
+	const char *g490_ChampionActionNames[44] = { // @ G0490_ac_Graphic560_ActionNames
+		"N", "BLOCK", "CHOP", "X", "BLOW HORN", "FLIP", "PUNCH",
+		"KICK", "WAR CRY", "STAB", "CLIMB DOWN", "FREEZE LIFE",
+		"HIT", "SWING", "STAB", "THRUST", "JAB", "PARRY", "HACK",
+		"BERZERK", "FIREBALL", "DISPELL", "CONFUSE", "LIGHTNING",
+		"DISRUPT", "MELEE", "X", "INVOKE", "SLASH", "CLEAVE",
+		"BASH", "STUN", "SHOOT", "SPELLSHIELD", "FIRESHIELD",
+		"FLUXCAGE", "HEAL", "CALM", "LIGHT", "WINDOW", "SPIT",
+		"BRANDISH", "THROW", "FUSE"
+	};
+
 	return (actionIndex == k255_ChampionActionNone) ? "" : g490_ChampionActionNames[actionIndex];
 }
 
-
-Box g504_BoxSpellAreaControls = Box(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls 
-
 void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) {
-
+	static Box boxSpellAreaControls(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls 
 
 	Champion *champ = &_vm->_championMan->_champions[champIndex];
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
@@ -309,7 +307,7 @@ void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) {
 	int16 champHP2 = _vm->_championMan->_champions[2]._currHealth;
 	int16 champHP3 = _vm->_championMan->_champions[3]._currHealth;
 	_vm->_eventMan->f78_showMouse();
-	_vm->_displayMan->D24_fillScreenBox(g504_BoxSpellAreaControls, k0_ColorBlack);
+	_vm->_displayMan->D24_fillScreenBox(boxSpellAreaControls, k0_ColorBlack);
 	switch (champIndex) {
 	case 0:
 		_vm->_eventMan->f6_highlightScreenBox(233, 277, 42, 49);
@@ -361,6 +359,9 @@ T0393003:
 		}
 		_vm->_eventMan->f6_highlightScreenBox(275, 319, 42, 49);
 		_vm->_textMan->f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
+		break;
+	default:
+		break;
 	}
 	_vm->_eventMan->f77_hideMouse();
 }
@@ -443,7 +444,8 @@ void MenuMan::f457_drawEnabledMenus() {
 			_g509_actionAreaContainsIcons = true;
 		}
 		f387_drawActionArea();
-		if (AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+		AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_g432_inventoryChampionOrdinal;
+		if (AL1462_i_InventoryChampionOrdinal) {
 			_vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
 			_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)_vm->M1_ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
 		} else {
@@ -501,7 +503,8 @@ int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
 	if (!(L1270_ps_Champion->_currHealth)) {
 		return k0_spellCastFailure;
 	}
-	if ((L1271_ps_Spell = f409_getSpellFromSymbols((unsigned char *)L1270_ps_Champion->_symbols)) == 0) {
+	L1271_ps_Spell = f409_getSpellFromSymbols((unsigned char *)L1270_ps_Champion->_symbols);
+	if (L1271_ps_Spell == 0) {
 		f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k1_spellCastSuccess, 0);
 		return k0_spellCastFailure;
 	}
@@ -1276,9 +1279,10 @@ T0407032:
 	case k10_ChampionActionClimbDown:
 		L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
 		L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
-		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir];
+		L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
 		/* CHANGE6_00_FIX The presence of a group over the pit is checked so that you cannot climb down a pit with the rope if there is a group levitating over it */
-		if ((_vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_ElementTypePit) && (_vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY) == Thing::_endOfList)) {
+		if ((_vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_PitElemType) && (_vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY) == Thing::_endOfList)) {
 			/* BUG0_77 The party moves forward when using the rope in front of a closed pit. The engine does not check whether the pit is open before moving the party over the pit. This is not consistent with the behavior when using the rope in front of a corridor where nothing happens */
 			_vm->_moveSens->_g402_useRopeToClimbDownPit = true;
 			_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1251_i_MapX, L1252_i_MapY);
@@ -1311,7 +1315,8 @@ T0407076:
 		break;
 	case k42_ChampionActionThrow:
 		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
-		if (AL1245_B_ActionPerformed = _vm->_championMan->isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_g308_partyDir)) || (L1247_ps_Champion->_cell == returnOppositeDir(_vm->_dungeonMan->_g308_partyDir)))) {
+		AL1245_B_ActionPerformed = _vm->_championMan->isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_g308_partyDir)) || (L1247_ps_Champion->_cell == (ViewCell)returnOppositeDir(_vm->_dungeonMan->_g308_partyDir)));
+		if (AL1245_B_ActionPerformed) {
 			_vm->_timeline->_g370_events[L1247_ps_Champion->_enableActionEventIndex]._B._slotOrdinal = _vm->M0_indexToOrdinal(k1_ChampionSlotActionHand);
 		}
 	}
@@ -1355,6 +1360,9 @@ void MenuMan::f405_decrementCharges(Champion* champ) {
 		if (L1243_ps_Junk->getChargeCount()) {
 			L1243_ps_Junk->setChargeCount(L1243_ps_Junk->getChargeCount() - 1);
 		}
+		break;
+	default:
+		break;
 	}
 	_vm->_championMan->drawChangedObjectIcons();
 }
@@ -1463,7 +1471,8 @@ bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int
 	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
 	if (_g517_actionTargetGroupThing == Thing::_endOfList)
 		goto T0402010;
-	if (L1238_i_CreatureOrdinal = _vm->_groupMan->f177_getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, AL1236_ui_ChampionCell = champ->_cell)) {
+	L1238_i_CreatureOrdinal = _vm->_groupMan->f177_getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, AL1236_ui_ChampionCell = champ->_cell);
+	if (L1238_i_CreatureOrdinal) {
 		switch (M21_normalizeModulo4(AL1236_ui_ChampionCell + 4 - champ->_dir)) {
 		case k2_ViewCellBackRight: /* Champion is on the back right of the square and tries to attack a creature in the front right of its square */
 			AL1237_ui_CellDelta = 3;
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 416b48c..4c2a9cb 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -363,7 +363,8 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 							_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
 							AL0727_ui_Outcome = _vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group *)_vm->_dungeonMan->f156_getThingData(thing), mapX, mapY, 20, false);
 							_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination);
-							if (L0722_B_FallKilledGroup = (AL0727_ui_Outcome == k2_outcomeKilledAllCreaturesInGroup))
+							L0722_B_FallKilledGroup = (AL0727_ui_Outcome == k2_outcomeKilledAllCreaturesInGroup);
+							if (L0722_B_FallKilledGroup)
 								break;
 							if (AL0727_ui_Outcome == k1_outcomeKilledSomeCreaturesInGroup) {
 								_vm->_groupMan->f187_dropMovingCreatureFixedPossession(thing, destMapX, destMapY);
@@ -782,7 +783,9 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 	if ((!addThing) && (L0767_i_ThingType != kM1_PartyThingType)) {
 		_vm->_dungeonMan->f164_unlinkThingFromList(thing, Thing(0), mapX, mapY);
 	}
-	if (Square(L0777_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType() == k0_ElementTypeWall) {
+
+	L0777_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY];
+	if (Square(L0777_ui_Square).getType() == k0_ElementTypeWall) {
 		L0770_ui_SensorTriggeredCell = thing.getCell();
 	} else {
 		L0770_ui_SensorTriggeredCell = kM1_CellAny; // this will wrap around
@@ -822,7 +825,8 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 	}
 	L0766_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
 	while (L0766_T_Thing != Thing::_endOfList) {
-		if ((L0771_ui_ThingType = (L0766_T_Thing).getType()) == k3_SensorThingType) {
+		L0771_ui_ThingType = (L0766_T_Thing).getType();
+		if (L0771_ui_ThingType == k3_SensorThingType) {
 			L0769_ps_Sensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0766_T_Thing);
 			if ((L0769_ps_Sensor)->getType() == k0_SensorDisabled)
 				goto T0276079;
@@ -857,7 +861,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 						goto T0276079;
 					break;
 				case k5_SensorFloorPartyOnStairs:
-					if ((L0767_i_ThingType != kM1_PartyThingType) || (Square(L0777_ui_Square).getType() != k3_ElementTypeStairs))
+					if ((L0767_i_ThingType != kM1_PartyThingType) || (Square(L0777_ui_Square).getType() != k3_StairsElemType))
 						goto T0276079;
 					break;
 				case k6_SensorFloorGroupGenerator:
@@ -874,7 +878,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 				case k9_SensorFloorVersionChecker:
 					if ((L0767_i_ThingType != kM1_PartyThingType) || !addThing || partySquare)
 						goto T0276079;
-					// Strangerke: 20 is a harcoded version of the game. later version uses 21. Not present in the original dungeons anyway.
+					// Strangerke: 20 is a hardcoded version of the game. later version uses 21. Not present in the original dungeons anyway.
 					L0768_B_TriggerSensor = (L0779_i_SensorData <= 20);
 					break;
 				default:
@@ -901,15 +905,15 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 				}
 			}
 			L0768_B_TriggerSensor ^= L0769_ps_Sensor->getRevertEffectA();
-			if ((L0778_i_Effect = L0769_ps_Sensor->getEffectA()) == k3_SensorEffHold) {
+			L0778_i_Effect = L0769_ps_Sensor->getEffectA();
+			if (L0778_i_Effect == k3_SensorEffHold) {
 				L0778_i_Effect = L0768_B_TriggerSensor ? k0_SensorEffSet : k1_SensorEffClear;
-			} else {
-				if (!L0768_B_TriggerSensor)
-					goto T0276079;
-			}
-			if (L0769_ps_Sensor->getAudibleA()) {
+			} else if (!L0768_B_TriggerSensor)
+				goto T0276079;
+
+			if (L0769_ps_Sensor->getAudibleA())
 				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized);
-			}
+
 			f272_sensorTriggerEffect(L0769_ps_Sensor, L0778_i_Effect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
 			goto T0276079;
 		}
@@ -939,7 +943,8 @@ bool MovesensMan::f274_sensorIsObjcetInPartyPossession(int16 objectType) {
 			for (L0743_ui_SlotIndex = k0_ChampionSlotReadyHand; (L0743_ui_SlotIndex < k30_ChampionSlotChest_1) && !L0748_B_LeaderHandObjectProcessed; L0743_ui_SlotIndex++) {
 				L0744_T_Thing = *L0746_pT_Thing++;
 T0274003:
-				if ((L0747_i_ObjectType = _vm->_objectMan->f32_getObjectType(L0744_T_Thing)) == objectType) {
+				L0747_i_ObjectType = _vm->_objectMan->f32_getObjectType(L0744_T_Thing);
+				if (L0747_i_ObjectType == objectType) {
 					return true;
 				}
 				if (L0747_i_ObjectType == k144_IconIndiceContainerChestClosed) {
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 5fd4b12..7600baf 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -465,13 +465,18 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 			L0520_ps_Projectile->_attack -= AL0516_ui_StepEnergy;
 		}
 	}
-	if (L0522_B_ProjectileMovesToOtherSquare = ((L0517_ui_ProjectileDirection = L0519_ps_Event->_C._projectile.getDir()) == (L0518_ui_Cell = (L0515_T_ProjectileThingNewCell = Thing(L0519_ps_Event->_B._slot)).getCell())) || (returnNextVal(L0517_ui_ProjectileDirection) == L0518_ui_Cell)) {
+	L0517_ui_ProjectileDirection = L0519_ps_Event->_C._projectile.getDir();
+	L0515_T_ProjectileThingNewCell = Thing(L0519_ps_Event->_B._slot);
+	L0518_ui_Cell = L0515_T_ProjectileThingNewCell.getCell();
+	L0522_B_ProjectileMovesToOtherSquare = (L0517_ui_ProjectileDirection == L0518_ui_Cell) || (returnNextVal(L0517_ui_ProjectileDirection) == L0518_ui_Cell);
+	if (L0522_B_ProjectileMovesToOtherSquare) {
 		L0525_i_SourceMapX = L0523_i_DestinationMapX;
 		L0526_i_SourceMapY = L0524_i_DestinationMapY;
 		L0523_i_DestinationMapX += _vm->_dirIntoStepCountEast[L0517_ui_ProjectileDirection], L0524_i_DestinationMapY += _vm->_dirIntoStepCountNorth[L0517_ui_ProjectileDirection];
-		if ((Square(AL0516_ui_Square = _vm->_dungeonMan->f151_getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY).toByte()).getType() == k0_ElementTypeWall) ||
+		AL0516_ui_Square = _vm->_dungeonMan->f151_getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY).toByte();
+		if ((Square(AL0516_ui_Square).getType() == k0_WallElemType) ||
 			((Square(AL0516_ui_Square).getType() == k6_FakeWallElemType) && !getFlag(AL0516_ui_Square, (k0x0001_FakeWallImaginary | k0x0004_FakeWallOpen))) ||
-			((Square(AL0516_ui_Square).getType() == k3_StairsElemType) && (Square(_vm->_dungeonMan->_g271_currMapData[L0525_i_SourceMapX][L0526_i_SourceMapY]).getType() == k3_ElementTypeStairs))) {
+			((Square(AL0516_ui_Square).getType() == k3_StairsElemType) && (Square(_vm->_dungeonMan->_g271_currMapData[L0525_i_SourceMapX][L0526_i_SourceMapY]).getType() == k3_StairsElemType))) {
 			if (f217_projectileHasImpactOccurred(Square(AL0516_ui_Square).getType(), L0525_i_SourceMapX, L0526_i_SourceMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
 				return;
 			}


Commit: 35103036566a1b7a405d518f9e14e39dfdfbcdae
    https://github.com/scummvm/scummvm/commit/35103036566a1b7a405d518f9e14e39dfdfbcdae
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix 2 more warnings

Changed paths:
    engines/dm/menus.cpp
    engines/dm/movesens.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index d387044..69dff00 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -509,7 +509,8 @@ int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
 		return k0_spellCastFailure;
 	}
 	L1268_i_PowerSymbolOrdinal = L1270_ps_Champion->_symbols[0] - '_'; /* Values 1 to 6 */
-	L1273_ui_Experience = _vm->getRandomNumber(8) + ((AL1269_ui_RequiredSkillLevel = L1271_ps_Spell->_baseRequiredSkillLevel + L1268_i_PowerSymbolOrdinal) << 4) + ((_vm->M1_ordinalToIndex(L1268_i_PowerSymbolOrdinal) * L1271_ps_Spell->_baseRequiredSkillLevel) << 3) + (AL1269_ui_RequiredSkillLevel * AL1269_ui_RequiredSkillLevel);
+	AL1269_ui_RequiredSkillLevel = L1271_ps_Spell->_baseRequiredSkillLevel + L1268_i_PowerSymbolOrdinal;
+	L1273_ui_Experience = _vm->getRandomNumber(8) + (AL1269_ui_RequiredSkillLevel << 4) + ((_vm->M1_ordinalToIndex(L1268_i_PowerSymbolOrdinal) * L1271_ps_Spell->_baseRequiredSkillLevel) << 3) + (AL1269_ui_RequiredSkillLevel * AL1269_ui_RequiredSkillLevel);
 	AL1267_ui_SkillLevel = _vm->_championMan->getSkillLevel(champIndex, L1271_ps_Spell->_skillIndex);
 	if (AL1267_ui_SkillLevel < AL1269_ui_RequiredSkillLevel) {
 		L1274_i_MissingSkillLevelCount = AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel;
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 4c2a9cb..adc9b55 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -785,7 +785,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 	}
 
 	L0777_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY];
-	if (Square(L0777_ui_Square).getType() == k0_ElementTypeWall) {
+	if (Square(L0777_ui_Square).getType() == k0_WallElemType) {
 		L0770_ui_SensorTriggeredCell = thing.getCell();
 	} else {
 		L0770_ui_SensorTriggeredCell = kM1_CellAny; // this will wrap around


Commit: 31cb7cd2fc28c20819ba26386368ce861e189e8a
    https://github.com/scummvm/scummvm/commit/31cb7cd2fc28c20819ba26386368ce861e189e8a
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Refactor unreadable if statement

Changed paths:
    engines/dm/movesens.cpp



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index adc9b55..747e8ef 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -583,7 +583,7 @@ bool MovesensMan::f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMa
 			return false;
 		}
 	}
-	if ((destMapX >= 0) && (((((AL0700_i_Distance = srcMapX - destMapX) < 0) ? -AL0700_i_Distance : AL0700_i_Distance) + (((AL0700_i_Distance = srcMapY - destMapY) < 0) ? -AL0700_i_Distance : AL0700_i_Distance)) == 1)) { /* If source and destination squares are adjacent (if party or group is not being teleported) */
+	if ((destMapX >= 0) && ((abs(srcMapX - destMapX) + abs(srcMapY - destMapY)) == 1)) { /* If source and destination squares are adjacent (if party or group is not being teleported) */
 		AL0699_ui_PrimaryDirection = _vm->_groupMan->f228_getDirsWhereDestIsVisibleFromSource(srcMapX, srcMapY, destMapX, destMapY);
 		AL0700_i_SecondaryDirection = returnNextVal(AL0699_ui_PrimaryDirection);
 		for (int16 i = 0; i < 4; ++i)


Commit: 0229a10df0cc35a104ff2f9a7ff5a54674c01aad
    https://github.com/scummvm/scummvm/commit/0229a10df0cc35a104ff2f9a7ff5a54674c01aad
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Make private some function declarations in console

Changed paths:
    engines/dm/console.h



diff --git a/engines/dm/console.h b/engines/dm/console.h
index 11348ae..546711e 100644
--- a/engines/dm/console.h
+++ b/engines/dm/console.h
@@ -35,26 +35,24 @@ namespace DM {
 class DMEngine;
 
 class Console : public GUI::Debugger {
+private:
 	DMEngine *_vm;
 
+	bool Cmd_godmode(int argc, const char **argv);
+	bool Cmd_noclip(int argc, const char **argv);
+	bool Cmd_pos(int argc, const char **argv);
+	bool Cmd_map(int argc, const char **argv);
+	bool Cmd_listItems(int argc, const char **argv);
+	bool Cmd_gimme(int argc, const char **argv);
+
 public:
 	explicit Console(DM::DMEngine *vm);
 	virtual ~Console(void) {}
 
-	// Cmd_godmode
 	bool _debugGodmodeMana;
 	bool _debugGodmodeHP;
 	bool _debugGodmodeStamina;
-	bool Cmd_godmode(int argc, const char **argv);
-
-	// Cmd_noclip
 	bool _debugNoclip;
-	bool Cmd_noclip(int argc, const char **argv);
-
-	bool Cmd_pos(int argc, const char **argv);
-	bool Cmd_map(int argc, const char **argv);
-	bool Cmd_listItems(int argc, const char **argv);
-	bool Cmd_gimme(int argc, const char **argv);
 };
 }
 


Commit: e728cb706eadc8ea31b2df0e3bc6b53c96994a5d
    https://github.com/scummvm/scummvm/commit/e728cb706eadc8ea31b2df0e3bc6b53c96994a5d
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rename functions of DMEngine and DialogMan

Changed paths:
    engines/dm/champion.cpp
    engines/dm/console.cpp
    engines/dm/dialog.cpp
    engines/dm/dialog.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dmglobals.cpp
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/projexpl.cpp
    engines/dm/sounds.cpp
    engines/dm/text.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 3ef072f..b6bcdf2 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -234,13 +234,13 @@ bool ChampionMan::isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side)
 	kineticEnergy += weaponKineticEnergy;
 	int16 skillLevel = getSkillLevel((ChampionIndex)champIndex, k10_ChampionSkillThrow);
 	kineticEnergy += _vm->getRandomNumber(16) + (kineticEnergy >> 1) + skillLevel;
-	int16 attack = f26_getBoundedValue((uint16)40, (uint16)((skillLevel << 3) + _vm->getRandomNumber(32)), (uint16)200);
+	int16 attack = getBoundedValue((uint16)40, (uint16)((skillLevel << 3) + _vm->getRandomNumber(32)), (uint16)200);
 	int16 stepEnergy = MAX(5, 11 - skillLevel);
 	_vm->_projexpl->f212_projectileCreate(curThing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY,
-										  M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + side),
+										  normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + side),
 										  _vm->_dungeonMan->_g308_partyDir, kineticEnergy, attack, stepEnergy);
-	_vm->_g311_projectileDisableMovementTicks = 4;
-	_vm->_g312_lastProjectileDisabledMovementDirection = _vm->_dungeonMan->_g308_partyDir;
+	_vm->_projectileDisableMovementTicks = 4;
+	_vm->_lastProjectileDisabledMovementDirection = _vm->_dungeonMan->_g308_partyDir;
 	drawChampionState((ChampionIndex)champIndex);
 	return true;
 }
@@ -480,7 +480,7 @@ void ChampionMan::drawChangedObjectIcons() {
 
 	for (uint16 slotBoxIndex = 0; slotBoxIndex < (_partyChampionCount * 2); ++slotBoxIndex) {
 		int16 champIndex = slotBoxIndex >> 1;
-		if (invChampOrdinal == _vm->M0_indexToOrdinal(champIndex))
+		if (invChampOrdinal == _vm->indexToOrdinal(champIndex))
 			continue;
 
 		if (hasObjectIconInSlotBoxChanged(slotBoxIndex, _champions[champIndex].getSlot((ChampionSlot)getHandSlotIndex(slotBoxIndex)))
@@ -491,7 +491,7 @@ void ChampionMan::drawChangedObjectIcons() {
 	}
 
 	if (invChampOrdinal) {
-		Champion *champ = &_champions[_vm->M1_ordinalToIndex(invChampOrdinal)];
+		Champion *champ = &_champions[_vm->ordinalToIndex(invChampOrdinal)];
 		Thing *thing = &champ->getSlot(k0_ChampionSlotReadyHand);
 		uint16 drawViewport = 0;
 
@@ -499,7 +499,7 @@ void ChampionMan::drawChangedObjectIcons() {
 			uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + k8_SlotBoxInventoryFirstSlot, *thing) ? 1 : 0;
 			drawViewport |= objIconChanged;
 			if (objIconChanged && (slotIndex == k1_ChampionSlotActionHand)) {
-				menuMan.f386_drawActionIcon((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal));
+				menuMan.f386_drawActionIcon((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
 			}
 		}
 
@@ -512,7 +512,7 @@ void ChampionMan::drawChangedObjectIcons() {
 
 		if (drawViewport) {
 			champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
-			drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal));
+			drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
 		}
 	}
 
@@ -540,14 +540,14 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 	champ->_load += dunMan.f140_getObjectWeight(thing);
 	champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
 	IconIndice iconIndex = objMan.f33_getIconIndex(thing);
-	bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal);
+	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal);
 	applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
 	uint16 *rawObjPtr = dunMan.f156_getThingData(thing);
 
 	if (slotIndex < k2_ChampionSlotHead) {
 		if (slotIndex == k1_ChampionSlotActionHand) {
 			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
-			if (_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))
+			if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
 				menuMan.f388_clearActingChampion();
 
 			if ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)) {
@@ -593,7 +593,7 @@ int16 ChampionMan::getScentOrdinal(int16 mapX, int16 mapY) {
 		Scent *scent = &_party._scents[scentIndex--];
 		do {
 			if ((*(--scent)).toUint16() == searchedScentRedEagle) {
-				return _vm->M0_indexToOrdinal(scentIndex);
+				return _vm->indexToOrdinal(scentIndex);
 			}
 		} while (scentIndex--);
 	}
@@ -657,7 +657,7 @@ uint16 ChampionMan::getStrength(int16 champIndex, int16 slotIndex) {
 	if (getFlag(curChampion->_wounds, (slotIndex == k0_ChampionSlotReadyHand) ? k0x0001_ChampionWoundReadHand : k0x0002_ChampionWoundActionHand)) {
 		strength >>= 1;
 	}
-	return f26_getBoundedValue(0, strength >> 1, 100);
+	return getBoundedValue(0, strength >> 1, 100);
 }
 
 Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) {
@@ -675,7 +675,7 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 	if (curThing == Thing::_none)
 		return Thing::_none;
 
-	bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
 	int16 curIconIndex = _vm->_objectMan->f33_getIconIndex(curThing);
 	// Remove object modifiers
 	applyModifiersToStatistics(curChampion, slotIndex, curIconIndex, -1, curThing);
@@ -698,7 +698,7 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 	if (slotIndex < k2_ChampionSlotHead) {
 		if (slotIndex == k1_ChampionSlotActionHand) {
 			setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand);
-			if (_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))
+			if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
 				_vm->_menuMan->f388_clearActingChampion();
 
 			if ((curIconIndex >= k30_IconIndiceScrollOpen) && (curIconIndex <= k31_IconIndiceScrollClosed)) {
@@ -778,7 +778,7 @@ int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 a
 			if (wisdomFactor <= 0) {
 				attack = 0;
 			} else {
-				attack = _vm->f30_getScaledProduct(attack, 6, wisdomFactor);
+				attack = _vm->getScaledProduct(attack, 6, wisdomFactor);
 			}
 
 			skipScaling = true;
@@ -804,7 +804,7 @@ int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 a
 			if (attack <= 0)
 				return 0;
 
-			attack = _vm->f30_getScaledProduct(attack, 6, 130 - defense);
+			attack = _vm->getScaledProduct(attack, 6, 130 - defense);
 		}
 		/* BUG0_44
 			A champion may take much more damage than expected after a Black Flame attack or an impact
@@ -877,7 +877,7 @@ int16 ChampionMan::getWoundDefense(int16 champIndex, uint16 woundIndex) {
 	if (_partyIsSleeping)
 		woundDefense >>= 1;
 
-	return f26_getBoundedValue(0, woundDefense >> 1, 100);
+	return getBoundedValue(0, woundDefense >> 1, 100);
 }
 
 uint16 ChampionMan::getStatisticAdjustedAttack(Champion *champ, uint16 statIndex, uint16 attack) {
@@ -893,14 +893,14 @@ uint16 ChampionMan::getStatisticAdjustedAttack(Champion *champ, uint16 statIndex
 	if (factor < 16)
 		return attack >> 3;
 
-	return _vm->f30_getScaledProduct(attack, 7, factor);
+	return _vm->getScaledProduct(attack, 7, factor);
 }
 
 void ChampionMan::wakeUp() {
-	_vm->_g321_stopWaitingForPlayerInput = true;
+	_vm->_stopWaitingForPlayerInput = true;
 	_partyIsSleeping = false;
-	_vm->_g318_waitForInputMaxVerticalBlankCount = 10;
-	_vm->f22_delay(10);
+	_vm->_waitForInputMaxVerticalBlankCount = 10;
+	_vm->delay(10);
 	_vm->_displayMan->f98_drawFloorAndCeiling();
 	_vm->_eventMan->_g441_primaryMouseInput = _vm->_eventMan->_primaryMouseInputInterface;
 	_vm->_eventMan->_g442_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputMovement;
@@ -912,7 +912,7 @@ void ChampionMan::wakeUp() {
 
 int16 ChampionMan::getThrowingStaminaCost(Thing thing) {
 	int16 weight = _vm->_dungeonMan->f140_getObjectWeight(thing) >> 1;
-	int16 staminaCost = f26_getBoundedValue<int16>(1, weight, 10);
+	int16 staminaCost = getBoundedValue<int16>(1, weight, 10);
 
 	while ((weight -= 10) > 0)
 		staminaCost += weight >> 1;
@@ -922,7 +922,7 @@ int16 ChampionMan::getThrowingStaminaCost(Thing thing) {
 
 void ChampionMan::disableAction(uint16 champIndex, uint16 ticks) {
 	Champion *curChampion = &_champions[champIndex];
-	int32 updatedEnableActionEventTime = _vm->_g313_gameTime + ticks;
+	int32 updatedEnableActionEventTime = _vm->_gameTime + ticks;
 
 	TimelineEvent curEvent;
 	curEvent._type = k11_TMEventTypeEnableChampionAction;
@@ -931,9 +931,9 @@ void ChampionMan::disableAction(uint16 champIndex, uint16 ticks) {
 
 	int16 eventIndex = curChampion->_enableActionEventIndex;
 	if (eventIndex >= 0) {
-		int32 currentEnableActionEventTime = M30_time(_vm->_timeline->_g370_events[eventIndex]._mapTime);
+		int32 currentEnableActionEventTime = filterTime(_vm->_timeline->_g370_events[eventIndex]._mapTime);
 		if (updatedEnableActionEventTime >= currentEnableActionEventTime) {
-			updatedEnableActionEventTime += (currentEnableActionEventTime - _vm->_g313_gameTime) >> 1;
+			updatedEnableActionEventTime += (currentEnableActionEventTime - _vm->_gameTime) >> 1;
 		} else {
 			updatedEnableActionEventTime = currentEnableActionEventTime + (ticks >> 1);
 		}
@@ -942,12 +942,12 @@ void ChampionMan::disableAction(uint16 champIndex, uint16 ticks) {
 		setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x0008_ChampionAttributeDisableAction);
 		drawChampionState((ChampionIndex)champIndex);
 	}
-	M33_setMapAndTime(curEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, updatedEnableActionEventTime);
+	setMapAndTime(curEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, updatedEnableActionEventTime);
 	curChampion->_enableActionEventIndex = _vm->_timeline->f238_addEventGetEventIndex(&curEvent);
 }
 
 void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp) {
-	if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && (_vm->_projexpl->_g361_lastCreatureAttackTime < _vm->_g313_gameTime - 150))
+	if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && (_vm->_projexpl->_g361_lastCreatureAttackTime < _vm->_gameTime - 150))
 		exp >>= 1;
 
 	if (exp) {
@@ -963,13 +963,13 @@ void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint1
 
 		uint16 skillLevelBefore = getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
 
-		if ((skillIndex >= k4_ChampionSkillSwing) && (_vm->_projexpl->_g361_lastCreatureAttackTime > _vm->_g313_gameTime - 25))
+		if ((skillIndex >= k4_ChampionSkillSwing) && (_vm->_projexpl->_g361_lastCreatureAttackTime > _vm->_gameTime - 25))
 			exp <<= 1;
 
 		Skill *curSkill = &curChampion->_skills[skillIndex];
 		curSkill->_experience += exp;
 		if (curSkill->_temporaryExperience < 32000)
-			curSkill->_temporaryExperience += f26_getBoundedValue(1, exp >> 3, 100);
+			curSkill->_temporaryExperience += getBoundedValue(1, exp >> 3, 100);
 
 		curSkill = &curChampion->_skills[baseSkillIndex];
 		if (skillIndex >= k4_ChampionSkillSwing)
@@ -1070,7 +1070,7 @@ int16 ChampionMan::getDamagedChampionCount(uint16 attack, int16 wounds, int16 at
 }
 
 int16 ChampionMan::getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) {
-	if (_partyChampionCount && (M38_distance(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)) {
+	if (_partyChampionCount && (getDistance(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)) {
 		signed char orderedCellsToAttack[4];
 		_vm->_groupMan->f229_setOrderedCellsToAttack(orderedCellsToAttack, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, mapX, mapY, cell);
 		for (uint16 i = 0; i < 4; i++) {
@@ -1088,7 +1088,7 @@ int16 ChampionMan::getDexterity(Champion* champ) {
 	if (_partyIsSleeping)
 		dexterity >>= 1;
 
-	return f26_getBoundedValue(1 + _vm->getRandomNumber(8), dexterity >> 1, 100 - _vm->getRandomNumber(8));
+	return getBoundedValue(1 + _vm->getRandomNumber(8), dexterity >> 1, 100 - _vm->getRandomNumber(8));
 }
 
 bool ChampionMan::isLucky(Champion* champ, uint16 percentage) {
@@ -1097,18 +1097,18 @@ bool ChampionMan::isLucky(Champion* champ, uint16 percentage) {
 
 	unsigned char *curStat = champ->_statistics[k0_ChampionStatLuck];
 	bool isLucky = (_vm->getRandomNumber(curStat[k1_ChampionStatCurrent]) > percentage);
-	curStat[k1_ChampionStatCurrent] = f26_getBoundedValue<char>(curStat[k2_ChampionStatMinimum], curStat[k1_ChampionStatCurrent] + (isLucky ? -2 : 2), curStat[k0_ChampionStatMaximum]);
+	curStat[k1_ChampionStatCurrent] = getBoundedValue<char>(curStat[k2_ChampionStatMinimum], curStat[k1_ChampionStatCurrent] + (isLucky ? -2 : 2), curStat[k0_ChampionStatMaximum]);
 	return isLucky;
 }
 
 void ChampionMan::championPoison(int16 champIndex, uint16 attack) {
-	if ((champIndex == kM1_ChampionNone) || (_vm->M0_indexToOrdinal(champIndex) == _candidateChampionOrdinal))
+	if ((champIndex == kM1_ChampionNone) || (_vm->indexToOrdinal(champIndex) == _candidateChampionOrdinal))
 		return;
 
 	Champion *curChampion = &_champions[champIndex];
 	addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
 	setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
-	if ((_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) && (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
+	if ((_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) && (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
 		setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel);
 	}
 
@@ -1117,7 +1117,7 @@ void ChampionMan::championPoison(int16 champIndex, uint16 attack) {
 		TimelineEvent newEvent;
 		newEvent._type = k75_TMEventTypePoisonChampion;
 		newEvent._priority = champIndex;
-		M33_setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 36);
+		setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + 36);
 		newEvent._B._attack = attack;
 		_vm->_timeline->f238_addEventGetEventIndex(&newEvent);
 	}
@@ -1135,8 +1135,8 @@ void ChampionMan::setPartyDirection(int16 dir) {
 
 	Champion *curChampion = _champions;
 	for (int16 i = k0_ChampionFirst; i < _partyChampionCount; i++) {
-		curChampion->_cell = (ViewCell)M21_normalizeModulo4(curChampion->_cell + L0834_i_Delta);
-		curChampion->_dir = (Direction)M21_normalizeModulo4(curChampion->_dir + L0834_i_Delta);
+		curChampion->_cell = (ViewCell)normalizeModulo4(curChampion->_cell + L0834_i_Delta);
+		curChampion->_dir = (Direction)normalizeModulo4(curChampion->_dir + L0834_i_Delta);
 		curChampion++;
 	}
 
@@ -1201,7 +1201,7 @@ void ChampionMan::putObjectInLeaderHand(Thing thing, bool setMousePointer) {
 	_vm->_objectMan->f34_drawLeaderObjectName(thing);
 
 	if (setMousePointer)
-		_vm->_g325_setMousePointerToObjectInMainLoop = true;
+		_vm->_setMousePointerToObjectInMainLoop = true;
 	else
 		_vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
 
@@ -1299,12 +1299,12 @@ void ChampionMan::clickOnSlotBox(uint16 slotBoxIndex) {
 			return;
 
 		champIndex = slotBoxIndex >> 1;
-		if ((champIndex >= _partyChampionCount) || (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_champions[champIndex]._currHealth)
+		if ((champIndex >= _partyChampionCount) || (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_champions[champIndex]._currHealth)
 			return;
 
 		slotIndex = getHandSlotIndex(slotBoxIndex);
 	} else {
-		champIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+		champIndex = _vm->ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal);
 		slotIndex = slotBoxIndex - k8_SlotBoxInventoryFirstSlot;
 	}
 
@@ -1357,9 +1357,9 @@ bool ChampionMan::isProjectileSpellCast(uint16 champIndex, Thing thing, int16 ki
 
 void ChampionMan::championShootProjectile(Champion* champ, Thing thing, int16 kineticEnergy, int16 attack, int16 stepEnergy) {
 	Direction newDirection = champ->_dir;
-	_vm->_projexpl->f212_projectileCreate(thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, M21_normalizeModulo4((((champ->_cell - newDirection + 1) & 0x0002) >> 1) + newDirection), newDirection, kineticEnergy, attack, stepEnergy);
-	_vm->_g311_projectileDisableMovementTicks = 4;
-	_vm->_g312_lastProjectileDisabledMovementDirection = newDirection;
+	_vm->_projexpl->f212_projectileCreate(thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, normalizeModulo4((((champ->_cell - newDirection + 1) & 0x0002) >> 1) + newDirection), newDirection, kineticEnergy, attack, stepEnergy);
+	_vm->_projectileDisableMovementTicks = 4;
+	_vm->_lastProjectileDisabledMovementDirection = newDirection;
 }
 
 void ChampionMan::applyAndDrawPendingDamageAndWounds() {
@@ -1397,7 +1397,7 @@ void ChampionMan::applyAndDrawPendingDamageAndWounds() {
 			blitBox._y1 = 0;
 			_vm->_eventMan->f78_showMouse();
 
-			if (_vm->M0_indexToOrdinal(championIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+			if (_vm->indexToOrdinal(championIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 				blitBox._y2 = 28;
 				blitBox._x1 = textPosX + 7;
 				blitBox._x2 = blitBox._x1 + 31; /* Box is over the champion portrait in the status box */
@@ -1432,12 +1432,12 @@ void ChampionMan::applyAndDrawPendingDamageAndWounds() {
 			if (eventIndex == -1) {
 				TimelineEvent newEvent;
 				newEvent._type = k12_TMEventTypeHideDamageReceived;
-				M33_setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
+				setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + 5);
 				newEvent._priority = championIndex;
 				championPtr->_hideDamageReceivedIndex = _vm->_timeline->f238_addEventGetEventIndex(&newEvent);
 			} else {
 				TimelineEvent *curEvent = &_vm->_timeline->_g370_events[eventIndex];
-				M33_setMapAndTime(curEvent->_mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
+				setMapAndTime(curEvent->_mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + 5);
 				_vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(eventIndex));
 			}
 			drawChampionState((ChampionIndex)championIndex);
@@ -1450,17 +1450,17 @@ void ChampionMan::championKill(uint16 champIndex) {
 	Champion *curChampion = &_champions[champIndex];
 	curChampion->_currHealth = 0;
 	setFlag(curChampion->_attributes, k0x1000_ChampionAttributeStatusBox);
-	if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
-		if (_vm->_g331_pressingEye) {
-			_vm->_g331_pressingEye = false;
+	if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+		if (_vm->_pressingEye) {
+			_vm->_pressingEye = false;
 			_vm->_eventMan->_g597_ignoreMouseMovements = false;
 			if (!_leaderEmptyHanded) {
 				_vm->_objectMan->f34_drawLeaderObjectName(_leaderHandObject);
 			}
 			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
 			_vm->_eventMan->f77_hideMouse();
-		} else if (_vm->_g333_pressingMouth) {
-			_vm->_g333_pressingMouth = false;
+		} else if (_vm->_pressingMouth) {
+			_vm->_pressingMouth = false;
 			_vm->_eventMan->_g597_ignoreMouseMovements = false;
 			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
 			_vm->_eventMan->f77_hideMouse();
@@ -1476,16 +1476,16 @@ void ChampionMan::championKill(uint16 champIndex) {
 		L0966_ps_Junk->setDoNotDiscard(true);
 		L0966_ps_Junk->setChargeCount(champIndex);
 		curCell = curChampion->_cell;
-		_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(unusedThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+		_vm->_moveSens->f267_getMoveResult(thingWithNewCell(unusedThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
 	}
 	curChampion->_symbolStep = 0;
 	curChampion->_symbols[0] = '\0';
 	curChampion->_dir = _vm->_dungeonMan->_g308_partyDir;
 	curChampion->_maximumDamageReceived = 0;
 	uint16 curChampionIconIndex = getChampionIconIndex(curCell, _vm->_dungeonMan->_g308_partyDir);
-	if (_vm->M0_indexToOrdinal(curChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
+	if (_vm->indexToOrdinal(curChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
 		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
-		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kM1_ChampionNone);
 	}
 
 	if (curChampion->_poisonEventCount)
@@ -1553,7 +1553,7 @@ void ChampionMan::dropAllObjects(uint16 champIndex) {
 	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
 		Thing curThing = getObjectRemovedFromSlot(champIndex, slotDropOrder[slotIndex]);
 		if (curThing != Thing::_none)
-			_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(curThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+			_vm->_moveSens->f267_getMoveResult(thingWithNewCell(curThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
 	}
 }
 
@@ -1588,11 +1588,11 @@ void ChampionMan::applyTimeEffects() {
 		}
 	}
 
-	uint16 gameTime = _vm->_g313_gameTime & 0xFFFF;
+	uint16 gameTime = _vm->_gameTime & 0xFFFF;
 	uint16 timeCriteria = (((gameTime & 0x0080) + ((gameTime & 0x0100) >> 2)) + ((gameTime & 0x0040) << 2)) >> 2;
 	Champion *championPtr = _champions;
 	for (uint16 championIndex = k0_ChampionFirst; championIndex < _partyChampionCount; championIndex++, championPtr++) {
-		if (championPtr->_currHealth && (_vm->M0_indexToOrdinal(championIndex) != _candidateChampionOrdinal)) {
+		if (championPtr->_currHealth && (_vm->indexToOrdinal(championIndex) != _candidateChampionOrdinal)) {
 			uint16 wizardSkillLevel = getSkillLevel(championIndex, k3_ChampionSkillWizard) + getSkillLevel(championIndex, k2_ChampionSkillPriest);
 			if ((championPtr->_currMana < championPtr->_maxMana)
 				&& (timeCriteria < championPtr->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + wizardSkillLevel)) {
@@ -1616,11 +1616,11 @@ void ChampionMan::applyTimeEffects() {
 				staminaGainCycleCount += 2;
 
 			int16 staminaLoss = 0;
-			int16 staminaAmount = f26_getBoundedValue(1, (championPtr->_maxStamina >> 8) - 1, 6);
+			int16 staminaAmount = getBoundedValue(1, (championPtr->_maxStamina >> 8) - 1, 6);
 			if (_partyIsSleeping)
 				staminaAmount <<= 1;
 
-			int32 compDelay = _vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime;
+			int32 compDelay = _vm->_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime;
 			if (compDelay > 80) {
 				staminaAmount++;
 				if (compDelay > 250)
@@ -1668,7 +1668,7 @@ void ChampionMan::applyTimeEffects() {
 
 				championPtr->_currHealth += MIN(healthGain, (int16)(championPtr->_maxHealth - championPtr->_currHealth));
 			}
-			if (!((int)_vm->_g313_gameTime & (_partyIsSleeping ? 63 : 255))) {
+			if (!((int)_vm->_gameTime & (_partyIsSleeping ? 63 : 255))) {
 				for (uint16 i = k0_ChampionStatLuck; i <= k6_ChampionStatAntifire; i++) {
 					byte *curStatistic = championPtr->_statistics[i];
 					uint16 statisticMaximum = curStatistic[k0_ChampionStatMaximum];
@@ -1678,14 +1678,14 @@ void ChampionMan::applyTimeEffects() {
 						curStatistic[k1_ChampionStatCurrent] -= curStatistic[k1_ChampionStatCurrent] / statisticMaximum;
 				}
 			}
-			if (!_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_g313_gameTime)) {
+			if (!_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_gameTime)) {
 				championPtr->_dir = _vm->_dungeonMan->_g308_partyDir;
 				championPtr->_maximumDamageReceived = 0;
 				setFlag(championPtr->_attributes, k0x0400_ChampionAttributeIcon);
 			}
 			setFlag(championPtr->_attributes, k0x0100_ChampionAttributeStatistics);
-			if (_vm->M0_indexToOrdinal(championIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
-				if (_vm->_g333_pressingMouth || _vm->_g331_pressingEye || (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
+			if (_vm->indexToOrdinal(championIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+				if (_vm->_pressingMouth || _vm->_pressingEye || (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
 					setFlag(championPtr->_attributes, k0x0800_ChampionAttributePanel);
 				}
 			}
@@ -1828,7 +1828,7 @@ ChampionIndex ChampionMan::getIndexInCell(int16 cell) {
 }
 
 void ChampionMan::resetDataToStartGame() {
-	if (!_vm->_g298_newGame) {
+	if (!_vm->_newGameFl) {
 		Thing L0787_T_Thing;
 		if ((L0787_T_Thing = _leaderHandObject) == Thing::_none) {
 			_leaderEmptyHanded = true;
@@ -1878,10 +1878,10 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	championPtr->_hideDamageReceivedIndex = -1;
 	championPtr->_dir = _vm->_dungeonMan->_g308_partyDir;
 	uint16 viewCell = k0_ViewCellFronLeft;
-	while (getIndexInCell(M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone)
+	while (getIndexInCell(normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone)
 		viewCell++;
 
-	championPtr->_cell = (ViewCell)M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir);
+	championPtr->_cell = (ViewCell)normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir);
 	championPtr->_attributes = k0x0400_ChampionAttributeIcon;
 	championPtr->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir;
 	championPtr->_food = 1500 + _vm->getRandomNumber(256);
@@ -2119,7 +2119,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	if (!getFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand))
 		return;
 
-	bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	_vm->_eventMan->f78_showMouse();
 	if (getFlag(championAttributes, k0x1000_ChampionAttributeStatusBox)) {
@@ -2237,33 +2237,33 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		}
 
 		maxLoad = curChampion->_load / 10;
-		strcpy(_vm->_g353_stringBuildBuffer, getStringFromInteger(maxLoad, true, 3).c_str());
+		strcpy(_vm->_stringBuildBuffer, getStringFromInteger(maxLoad, true, 3).c_str());
 
 		switch (_vm->getGameLanguage()) { // localized
 		default:
-		case Common::EN_ANY: strcat(_vm->_g353_stringBuildBuffer, "."); break;
-		case Common::DE_DEU: strcat(_vm->_g353_stringBuildBuffer, ","); break;
-		case Common::FR_FRA: strcat(_vm->_g353_stringBuildBuffer, "KG,"); break;
+		case Common::EN_ANY: strcat(_vm->_stringBuildBuffer, "."); break;
+		case Common::DE_DEU: strcat(_vm->_stringBuildBuffer, ","); break;
+		case Common::FR_FRA: strcat(_vm->_stringBuildBuffer, "KG,"); break;
 		}
 
 		maxLoad = curChampion->_load - (maxLoad * 10);
-		strcat(_vm->_g353_stringBuildBuffer, getStringFromInteger(maxLoad, false, 1).c_str());
-		strcat(_vm->_g353_stringBuildBuffer, "/");
+		strcat(_vm->_stringBuildBuffer, getStringFromInteger(maxLoad, false, 1).c_str());
+		strcat(_vm->_stringBuildBuffer, "/");
 		maxLoad = (getMaximumLoad(curChampion) + 5) / 10;
-		strcat(_vm->_g353_stringBuildBuffer, getStringFromInteger(maxLoad, true, 3).c_str());
-		strcat(_vm->_g353_stringBuildBuffer, " KG");
-		_vm->_textMan->f52_printToViewport(148, 132, loadColor, _vm->_g353_stringBuildBuffer);
+		strcat(_vm->_stringBuildBuffer, getStringFromInteger(maxLoad, true, 3).c_str());
+		strcat(_vm->_stringBuildBuffer, " KG");
+		_vm->_textMan->f52_printToViewport(148, 132, loadColor, _vm->_stringBuildBuffer);
 		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
 	uint16 championIconIndex = getChampionIconIndex(curChampion->_cell, _vm->_dungeonMan->_g308_partyDir);
-	if (getFlag(championAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(championIconIndex))) {
+	if (getFlag(championAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(championIconIndex))) {
 		_vm->_displayMan->D24_fillScreenBox(_boxChampionIcons[championIconIndex], _championColor[champIndex]);
 		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, _boxChampionIcons[championIconIndex], getChampionIconIndex(curChampion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
 	}
 	if (getFlag(championAttributes, k0x0800_ChampionAttributePanel) && isInventoryChampion) {
-		if (_vm->_g333_pressingMouth)
+		if (_vm->_pressingMouth)
 			_vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned();
-		else if (_vm->_g331_pressingEye) {
+		else if (_vm->_pressingEye) {
 			if (_leaderEmptyHanded)
 				_vm->_inventoryMan->f351_drawChampionSkillsAndStatistics();
 		} else
@@ -2297,12 +2297,12 @@ void ChampionMan::drawHealthStaminaManaValues(Champion* champ) {
 void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 	int16 nativeBitmapIndex = -1;
 	Champion *champ = &_champions[champIndex];
-	bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex));
+	bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex));
 
 	uint16 slotBoxIndex;
 	if (!isInventoryChamp) {
 		// If drawing a slot for a champion other than the champion whose inventory is open
-		if ((slotIndex > k1_ChampionSlotActionHand) || (_candidateChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)))
+		if ((slotIndex > k1_ChampionSlotActionHand) || (_candidateChampionOrdinal == _vm->indexToOrdinal(champIndex)))
 			return;
 		slotBoxIndex = (champIndex << 1) + slotIndex;
 	} else
@@ -2352,7 +2352,7 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 		}
 	}
 
-	if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->M0_indexToOrdinal(champIndex) == _actingChampionOrdinal))
+	if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->indexToOrdinal(champIndex) == _actingChampionOrdinal))
 		nativeBitmapIndex = k35_SlotBoxActingHandIndice;
 
 	if (nativeBitmapIndex != -1) {
diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index a32bcb7..9874708 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -178,12 +178,12 @@ bool Console::Cmd_map(int argc, const char** argv) {
 		debugPrintf("Map set to %d\n", index);
 
 		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0);
-		_vm->_g327_newPartyMapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(
+		_vm->_newPartyMapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(
 			_vm->_dungeonMan->_g309_partyMapIndex, index - _vm->_dungeonMan->_g309_partyMapIndex,
 			&_vm->_dungeonMan->_g306_partyMapX, &_vm->_dungeonMan->_g307_partyMapY);
-		if (_vm->_g327_newPartyMapIndex == -1)
-			_vm->_g327_newPartyMapIndex = index;
-		_vm->_dungeonMan->f173_setCurrentMap(_vm->_g327_newPartyMapIndex);
+		if (_vm->_newPartyMapIndex == -1)
+			_vm->_newPartyMapIndex = index;
+		_vm->_dungeonMan->f173_setCurrentMap(_vm->_newPartyMapIndex);
 		_vm->_championMan->setPartyDirection(_vm->_dungeonMan->f155_getStairsExitDirection(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY));
 		_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
 	} else
diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index 6772d32..bf9ea55 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -34,10 +34,10 @@
 namespace DM {
 
 DialogMan::DialogMan(DMEngine *vm) : _vm(vm) {
-	_g335_selectedDialogChoice = 0;
+	_selectedDialogChoice = 0;
 }
 
-void DialogMan::f427_dialogDraw(const char *msg1, const char *msg2, const char *choice1, const char *choice2, const char *choice3, const char *choice4, bool screenDialog, bool clearScreen, bool fading) {
+void DialogMan::dialogDraw(const char *msg1, const char *msg2, const char *choice1, const char *choice2, const char *choice3, const char *choice4, bool screenDialog, bool clearScreen, bool fading) {
 	static Box constBox1 = Box(0, 223, 101, 125);
 	static Box constBox2 = Box(0, 223, 76, 100);
 	static Box constBox3 = Box(0, 223, 51, 75);
@@ -69,21 +69,21 @@ void DialogMan::f427_dialogDraw(const char *msg1, const char *msg2, const char *
 		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, constBox1, 0, 64, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
 		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, constBox2, 0, 39, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
 		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, constBox3, 0, 14, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
-		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 114);
+		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 114);
 	} else if (choiceCount == 2) {
 		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, dialog2ChoicesPatch, 102, 52, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
-		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77);
-		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 112, 114);
+		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77);
+		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 112, 114);
 	} else if (choiceCount == 3) {
-		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77);
-		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 59, 114);
-		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 166, 114);
+		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77);
+		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 59, 114);
+		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 166, 114);
 	} else if (choiceCount == 4) {
 		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, dialog4ChoicesPatch, 102, 99, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
-		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 59, 77);
-		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 166, 77);
-		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 59, 114);
-		f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice4, 166, 114);
+		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 59, 77);
+		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 166, 77);
+		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 59, 114);
+		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice4, 166, 114);
 	}
 
 	int16 textPosX;
@@ -91,7 +91,7 @@ void DialogMan::f427_dialogDraw(const char *msg1, const char *msg2, const char *
 	if (msg1) {
 		char L1312_ac_StringPart1[70];
 		char L1313_ac_StringPart2[70];
-		if (f426_isMessageOnTwoLines(msg1, L1312_ac_StringPart1, L1313_ac_StringPart2)) {
+		if (isMessageOnTwoLines(msg1, L1312_ac_StringPart1, L1313_ac_StringPart2)) {
 			textPosY = 21;
 			textPosX = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1);
 			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
@@ -108,7 +108,7 @@ void DialogMan::f427_dialogDraw(const char *msg1, const char *msg2, const char *
 	if (msg2) {
 		char L1312_ac_StringPart1[70];
 		char L1313_ac_StringPart2[70];
-		if (f426_isMessageOnTwoLines(msg2, L1312_ac_StringPart1, L1313_ac_StringPart2)) {
+		if (isMessageOnTwoLines(msg2, L1312_ac_StringPart1, L1313_ac_StringPart2)) {
 			textPosX = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1);
 			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
 			textPosY += 8;
@@ -130,7 +130,7 @@ void DialogMan::f427_dialogDraw(const char *msg1, const char *msg2, const char *
 		_vm->_eventMan->f77_hideMouse();
 	} else {
 		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
-		_vm->f22_delay(1);
+		_vm->delay(1);
 	}
 
 	if (fading)
@@ -140,14 +140,14 @@ void DialogMan::f427_dialogDraw(const char *msg1, const char *msg2, const char *
 	_vm->_displayMan->updateScreen();
 }
 
-void DialogMan::f425_printCenteredChoice(byte *bitmap, const char *str, int16 posX, int16 posY) {
+void DialogMan::printCenteredChoice(byte *bitmap, const char *str, int16 posX, int16 posY) {
 	if (str) {
 		posX -= (strlen(str) * 6) >> 1;
 		_vm->_textMan->f40_printTextToBitmap(bitmap, k112_byteWidthViewport, posX, posY, k9_ColorGold, k5_ColorLightBrown, str, k136_heightViewport);
 	}
 }
 
-bool DialogMan::f426_isMessageOnTwoLines(const char *str, char *part1, char *part2) {
+bool DialogMan::isMessageOnTwoLines(const char *str, char *part1, char *part2) {
 	uint16 strLength = strlen(str);
 	if (strLength <= 30)
 		return false;
@@ -162,7 +162,7 @@ bool DialogMan::f426_isMessageOnTwoLines(const char *str, char *part1, char *par
 	return true;
 }
 
-int16 DialogMan::f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex, int16 driveType, int16 automaticChoiceIfFlopyInDrive) {
+int16 DialogMan::getChoice(uint16 choiceCount, uint16 dialogSetIndex, int16 driveType, int16 automaticChoiceIfFlopyInDrive) {
 	MouseInput *L1298_ps_PrimaryMouseInputBackup;
 	MouseInput *L1299_ps_SecondaryMouseInputBackup;
 	KeyboardInput *L1300_ps_PrimaryKeyboardInputBackup;
@@ -180,21 +180,21 @@ int16 DialogMan::f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex,
 	_vm->_eventMan->_g444_secondaryKeyboardInput = nullptr;
 	_vm->_eventMan->_g441_primaryMouseInput = _vm->_eventMan->_primaryMouseInputDialogSets[dialogSetIndex][choiceCount - 1];
 	_vm->_eventMan->f357_discardAllInput();
-	_g335_selectedDialogChoice = 99;
+	_selectedDialogChoice = 99;
 	do {
 		Common::Event key;
 		Common::EventType eventType = _vm->_eventMan->processInput(&key);
 		_vm->_eventMan->f380_processCommandQueue();
-		_vm->f22_delay(1);
+		_vm->delay(1);
 		_vm->_displayMan->updateScreen();
-		if ((_g335_selectedDialogChoice == 99) && (choiceCount == 1) 
+		if ((_selectedDialogChoice == 99) && (choiceCount == 1) 
 			&& (eventType != Common::EVENT_INVALID) && key.kbd.keycode == Common::KEYCODE_RETURN) {
 			/* If a choice has not been made yet with the mouse and the dialog has only one possible choice and carriage return was pressed on the keyboard */
-			_g335_selectedDialogChoice = k1_DIALOG_CHOICE_1;
+			_selectedDialogChoice = k1_DIALOG_CHOICE_1;
 		}
-	} while (_g335_selectedDialogChoice == 99);
+	} while (_selectedDialogChoice == 99);
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	L1304_s_BoxA = _vm->_eventMan->_g441_primaryMouseInput[_g335_selectedDialogChoice - 1]._hitbox;
+	L1304_s_BoxA = _vm->_eventMan->_g441_primaryMouseInput[_selectedDialogChoice - 1]._hitbox;
 	L1304_s_BoxA._x1 -= 3;
 	L1304_s_BoxA._x2 += 3;
 	L1304_s_BoxA._y1 -= 3;
@@ -207,7 +207,7 @@ int16 DialogMan::f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex,
 	L1303_s_BoxB._x2 = L1304_s_BoxA._x2 - L1304_s_BoxA._x1 + 3;
 	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_g296_bitmapViewport,
 										L1303_s_BoxB, L1304_s_BoxA._x1, L1304_s_BoxA._y1, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 25);
-	_vm->f22_delay(1);
+	_vm->delay(1);
 	L1303_s_BoxB = L1304_s_BoxA;
 	L1303_s_BoxB._y2 = L1303_s_BoxB._y1;
 	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
@@ -223,7 +223,7 @@ int16 DialogMan::f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex,
 	L1303_s_BoxB = L1304_s_BoxA;
 	L1303_s_BoxB._x1 = L1303_s_BoxB._x2;
 	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
-	_vm->f22_delay(2);
+	_vm->delay(2);
 	L1303_s_BoxB = L1304_s_BoxA;
 	L1303_s_BoxB._y1++;
 	L1303_s_BoxB._y2 = L1303_s_BoxB._y1;
@@ -251,7 +251,7 @@ int16 DialogMan::f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex,
 	L1303_s_BoxB._x1 = L1303_s_BoxB._x2 = L1303_s_BoxB._x2 + 3;
 	L1303_s_BoxB._y2 += 2;
 	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k13_ColorLightestGray);
-	_vm->f22_delay(2);
+	_vm->delay(2);
 	L1304_s_BoxA._x2 += 3;
 	L1304_s_BoxA._y2 += 3;
 	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g348_bitmapScreen,
@@ -263,6 +263,6 @@ int16 DialogMan::f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex,
 	_vm->_eventMan->_g444_secondaryKeyboardInput = L1301_ps_SecondaryKeyboardInputBackup;
 	_vm->_eventMan->f357_discardAllInput();
 	_vm->_eventMan->f78_showMouse();
-	return _g335_selectedDialogChoice;
+	return _selectedDialogChoice;
 }
 }
diff --git a/engines/dm/dialog.h b/engines/dm/dialog.h
index 1ac88fe..647ae8d 100644
--- a/engines/dm/dialog.h
+++ b/engines/dm/dialog.h
@@ -45,13 +45,13 @@ namespace DM {
 class DialogMan {
 	DMEngine *_vm;
 public:
-	uint16 _g335_selectedDialogChoice; // @ G0335_ui_SelectedDialogChoice
+	uint16 _selectedDialogChoice; // @ G0335_ui_SelectedDialogChoice
 	explicit DialogMan(DMEngine *vm);
-	void f427_dialogDraw(const char *msg1, const char *msg2, const char *choice1, const char *choice2,
+	void dialogDraw(const char *msg1, const char *msg2, const char *choice1, const char *choice2,
 						 const char *choice3, const char *choice4, bool screenDialog, bool clearScreen, bool fading); // @ F0427_DIALOG_Draw
-	void f425_printCenteredChoice(byte *bitmap, const char *str, int16 posX, int16 posY); // @ F0425_DIALOG_PrintCenteredChoice
-	bool f426_isMessageOnTwoLines(const char *str, char *part1, char *part2); // @ F0426_DIALOG_IsMessageOnTwoLines
-	int16 f424_dialogGetChoice(uint16 choiceCount, uint16 dialogSetIndex, int16 driveType, int16 automaticChoiceIfFlopyInDrive); // @ F0424_DIALOG_GetChoice
+	void printCenteredChoice(byte *bitmap, const char *str, int16 posX, int16 posY); // @ F0425_DIALOG_PrintCenteredChoice
+	bool isMessageOnTwoLines(const char *str, char *part1, char *part2); // @ F0426_DIALOG_IsMessageOnTwoLines
+	int16 getChoice(uint16 choiceCount, uint16 dialogSetIndex, int16 driveType, int16 automaticChoiceIfFlopyInDrive); // @ F0424_DIALOG_GetChoice
 };
 
 }
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index e4fa210..37f0305 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -118,31 +118,31 @@ uint16 toggleFlag(uint16& val, uint16 mask) {
 	return val ^= mask;
 }
 
-uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height) {
+uint16 bitmapByteCount(uint16 pixelWidth, uint16 height) {
 	return pixelWidth / 2 * height;
 }
 
-uint16 M21_normalizeModulo4(uint16 val) {
+uint16 normalizeModulo4(uint16 val) {
 	return val & 3;
 }
 
-int32 M30_time(int32 mapTime) {
+int32 filterTime(int32 mapTime) {
 	return mapTime & 0x00FFFFFF;
 }
 
-int32 M33_setMapAndTime(int32 &mapTime, uint32 map, uint32 time) {
+int32 setMapAndTime(int32 &mapTime, uint32 map, uint32 time) {
 	return (mapTime) = ((time) | (((long)(map)) << 24));
 }
 
-uint16 M29_map(int32 mapTime) {
+uint16 getMap(int32 mapTime) {
 	return ((uint16)((mapTime) >> 24));
 }
 
-Thing M15_thingWithNewCell(Thing thing, int16 cell) {
+Thing thingWithNewCell(Thing thing, int16 cell) {
 	return Thing(((thing.toUint16()) & 0x3FFF) | ((cell) << 14));
 }
 
-int16 M38_distance(int16 mapx1, int16 mapy1, int16 mapx2, int16 mapy2) {
+int16 getDistance(int16 mapx1, int16 mapy1, int16 mapx2, int16 mapy2) {
 	return ABS(mapx1 - mapx2) + ABS(mapy1 - mapy2);
 }
 
@@ -166,32 +166,32 @@ DMEngine::DMEngine(OSystem *syst, const DMADGameDescription *desc) : Engine(syst
 	_sound = nullptr;
 
 	_engineShouldQuit = false;
-	_g526_dungeonId = 0;
-
-	_g298_newGame = 0;
-	_g523_restartGameRequest = false;
-	_g321_stopWaitingForPlayerInput = true;
-	_g301_gameTimeTicking = false;
-	_g524_restartGameAllowed = false;
-	_g525_gameId = 0;
-	_g331_pressingEye = false;
-	_g332_stopPressingEye = false;
-	_g333_pressingMouth = false;
-	_g334_stopPressingMouth = false;
-	_g340_highlightBoxInversionRequested = false;
-	_g311_projectileDisableMovementTicks = 0;
-	_g312_lastProjectileDisabledMovementDirection = 0;
-	_g302_gameWon = false;
-	_g327_newPartyMapIndex = kM1_mapIndexNone;
-	_g325_setMousePointerToObjectInMainLoop = false;
-	_g310_disabledMovementTicks = 0;
-	_g313_gameTime = 0;
-	_g353_stringBuildBuffer[0] = '\0';
-	_g318_waitForInputMaxVerticalBlankCount = 0;
+	_dungeonId = 0;
+
+	_newGameFl = 0;
+	_restartGameRequest = false;
+	_stopWaitingForPlayerInput = true;
+	_gameTimeTicking = false;
+	_restartGameAllowed = false;
+	_gameId = 0;
+	_pressingEye = false;
+	_stopPressingEye = false;
+	_pressingMouth = false;
+	_stopPressingMouth = false;
+	_highlightBoxInversionRequested = false;
+	_projectileDisableMovementTicks = 0;
+	_lastProjectileDisabledMovementDirection = 0;
+	_gameWon = false;
+	_newPartyMapIndex = kM1_mapIndexNone;
+	_setMousePointerToObjectInMainLoop = false;
+	_disabledMovementTicks = 0;
+	_gameTime = 0;
+	_stringBuildBuffer[0] = '\0';
+	_waitForInputMaxVerticalBlankCount = 0;
 	_savedScreenForOpenEntranceDoors = nullptr;
 	for (uint16 i = 0; i < 10; ++i)
-		_g562_entranceDoorAnimSteps[i] = nullptr;
-	_g564_interfaceCredits = nullptr;
+		_entranceDoorAnimSteps[i] = nullptr;
+	_interfaceCredits = nullptr;
 	debug("DMEngine::DMEngine");
 
 	_saveThumbnail = nullptr;
@@ -234,13 +234,13 @@ bool DMEngine::hasFeature(EngineFeature f) const {
 }
 
 Common::Error DMEngine::loadGameState(int slot) {
-	if (f435_loadgame(slot) != kM1_LoadgameFailure) {
+	if (loadgame(slot) != kM1_LoadgameFailure) {
 		_displayMan->fillScreen(k0_ColorBlack);
 		_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_palDungeonView[0]);
-		_g298_newGame = k0_modeLoadSavedGame;
+		_newGameFl = k0_modeLoadSavedGame;
 
-		f462_startGame();
-		_g523_restartGameRequest = false;
+		startGame();
+		_restartGameRequest = false;
 		_eventMan->f77_hideMouse();
 		_eventMan->f357_discardAllInput();
 		return Common::kNoError;
@@ -253,7 +253,7 @@ bool DMEngine::canLoadGameStateCurrently() {
 	return _canLoadFromGMM;
 }
 
-void DMEngine::f22_delay(uint16 verticalBlank) {
+void DMEngine::delay(uint16 verticalBlank) {
 	for (uint16 i = 0; i < verticalBlank * 2; ++i) {
 		_eventMan->processInput();
 		_displayMan->updateScreen();
@@ -261,12 +261,12 @@ void DMEngine::f22_delay(uint16 verticalBlank) {
 	}
 }
 
-uint16 DMEngine::f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2) {
+uint16 DMEngine::getScaledProduct(uint16 val, uint16 scale, uint16 vale2) {
 	return ((uint32)val * vale2) >> scale;
 }
 
-void DMEngine::f463_initializeGame() {
-	f448_initMemoryManager();
+void DMEngine::initializeGame() {
+	initMemoryManager();
 	_displayMan->f479_loadGraphics();
 	_displayMan->f460_initializeGraphicData();
 	_displayMan->f94_loadFloorSet(k0_FloorSetStone);
@@ -275,7 +275,7 @@ void DMEngine::f463_initializeGame() {
 	_sound->f503_loadSounds(); // @ F0506_AMIGA_AllocateData
 
 	if (!ConfMan.hasKey("save_slot")) // skip drawing title if loading from launcher
-		f437_STARTEND_drawTittle();
+		drawTittle();
 
 	_textMan->f54_textInitialize();
 	_objectMan->loadObjectNames();
@@ -287,31 +287,31 @@ void DMEngine::f463_initializeGame() {
 		if (ConfMan.hasKey("save_slot")) {
 			saveSlot = ConfMan.getInt("save_slot");
 		} else { // else show the entrance
-			f441_processEntrance();
+			processEntrance();
 			if (_engineShouldQuit)
 				return;
 
-			if (_g298_newGame == k0_modeLoadSavedGame) { // if resume was clicked, bring up ScummVM load screen
+			if (_newGameFl == k0_modeLoadSavedGame) { // if resume was clicked, bring up ScummVM load screen
 				GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
 				saveSlot = dialog->runModalWithCurrentTarget();
 				delete dialog;
 			}
 		}
-	} while (f435_loadgame(saveSlot) != k1_LoadgameSuccess);
+	} while (loadgame(saveSlot) != k1_LoadgameSuccess);
 
 	_displayMan->f466_loadIntoBitmap(k11_MenuSpellAreLinesIndice, _menuMan->_gK73_bitmapSpellAreaLines); // @ F0396_MENUS_LoadSpellAreaLinesBitmap
 
 	// There was some memory wizardy for the Amiga platform, I skipped that part
 	_displayMan->f461_allocateFlippedWallBitmaps();
 
-	f462_startGame();
-	if (_g298_newGame)
+	startGame();
+	if (_newGameFl)
 		_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
 	_eventMan->f78_showMouse();
 	_eventMan->f357_discardAllInput();
 }
 
-void DMEngine::f448_initMemoryManager() {
+void DMEngine::initMemoryManager() {
 	static uint16 palSwoosh[16] = {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}; // @ K0057_aui_Palette_Swoosh
 
 	_displayMan->f508_buildPaletteChangeCopperList(palSwoosh, palSwoosh);
@@ -321,33 +321,33 @@ void DMEngine::f448_initMemoryManager() {
 	}
 }
 
-void DMEngine::f462_startGame() {
+void DMEngine::startGame() {
 	static Box boxScreenTop(0, 319, 0, 32); // @ G0061_s_Graphic562_Box_ScreenTop
 	static Box boxScreenRight(224, 319, 33, 169); // @ G0062_s_Graphic562_Box_ScreenRight
 	static Box boxScreenBottom(0, 319, 169, 199); // @ G0063_s_Graphic562_Box_ScreenBottom
 
-	_g331_pressingEye = false;
-	_g332_stopPressingEye = false;
-	_g333_pressingMouth = false;
-	_g334_stopPressingMouth = false;
-	_g340_highlightBoxInversionRequested = false;
+	_pressingEye = false;
+	_stopPressingEye = false;
+	_pressingMouth = false;
+	_stopPressingMouth = false;
+	_highlightBoxInversionRequested = false;
 	_eventMan->_g341_highlightBoxEnabled = false;
 	_championMan->_partyIsSleeping = false;
-	_championMan->_actingChampionOrdinal = M0_indexToOrdinal(kM1_ChampionNone);
+	_championMan->_actingChampionOrdinal = indexToOrdinal(kM1_ChampionNone);
 	_menuMan->_g509_actionAreaContainsIcons = true;
-	_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = M0_indexToOrdinal(kM1_ChampionNone);
+	_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kM1_ChampionNone);
 
 	_eventMan->_g441_primaryMouseInput = _eventMan->_primaryMouseInputInterface;
 	_eventMan->_g442_secondaryMouseInput = _eventMan->_secondaryMouseInputMovement;
 	_eventMan->_g443_primaryKeyboardInput = _eventMan->_primaryKeyboardInputInterface;
 	_eventMan->_g444_secondaryKeyboardInput = _eventMan->_secondaryKeyboardInputMovement;
 
-	f3_processNewPartyMap(_dungeonMan->_g309_partyMapIndex);
+	processNewPartyMap(_dungeonMan->_g309_partyMapIndex);
 
-	if (!_g298_newGame) {
+	if (!_newGameFl) {
 		_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);
 		_displayMan->_g578_useByteBoxCoordinates = false;
-		f22_delay(1);
+		delay(1);
 		_displayMan->D24_fillScreenBox(boxScreenTop, k0_ColorBlack);
 		_displayMan->D24_fillScreenBox(boxScreenRight, k0_ColorBlack);
 		_displayMan->D24_fillScreenBox(boxScreenBottom, k0_ColorBlack);
@@ -361,10 +361,10 @@ void DMEngine::f462_startGame() {
 	_displayMan->f508_buildPaletteChangeCopperList(_displayMan->_palDungeonView[0], _displayMan->_g347_paletteTopAndBottomScreen);
 	_menuMan->f395_drawMovementArrows();
 	_championMan->resetDataToStartGame();
-	_g301_gameTimeTicking = true;
+	_gameTimeTicking = true;
 }
 
-void DMEngine::f3_processNewPartyMap(uint16 mapIndex) {
+void DMEngine::processNewPartyMap(uint16 mapIndex) {
 	_groupMan->f194_removeAllActiveGroups();
 	_dungeonMan->f174_setCurrentMapAndPartyMap(mapIndex);
 	_displayMan->f96_loadCurrentMapGraphics();
@@ -373,7 +373,7 @@ void DMEngine::f3_processNewPartyMap(uint16 mapIndex) {
 }
 
 Common::Error DMEngine::run() {
-	initArrays();
+	initConstants();
 
 	// scummvm/engine specific
 	initGraphics(320, 200, false);
@@ -394,15 +394,15 @@ Common::Error DMEngine::run() {
 	_sound = SoundMan::getSoundMan(this, _gameVersion);
 	_displayMan->setUpScreens(320, 200);
 
-	f463_initializeGame();
+	initializeGame();
 	while (true) {
-		f2_gameloop();
+		gameloop();
 
 		if (_engineShouldQuit)
 			return Common::kNoError;
 
 		if (_loadSaveSlotAtRuntime == -1)
-			f444_endGame(_championMan->_partyDead);
+			endGame(_championMan->_partyDead);
 		else {
 			loadGameState(_loadSaveSlotAtRuntime);
 			_menuMan->f457_drawEnabledMenus();
@@ -414,9 +414,9 @@ Common::Error DMEngine::run() {
 	return Common::kNoError;
 }
 
-void DMEngine::f2_gameloop() {
+void DMEngine::gameloop() {
 	_canLoadFromGMM = true;
-	_g318_waitForInputMaxVerticalBlankCount = 10;
+	_waitForInputMaxVerticalBlankCount = 10;
 	while (true) {
 		if (_engineShouldQuit) {
 			_canLoadFromGMM = false;
@@ -437,15 +437,15 @@ void DMEngine::f2_gameloop() {
 		for (;;) {
 
 
-			if (_g327_newPartyMapIndex != kM1_mapIndexNone) {
-				f3_processNewPartyMap(_g327_newPartyMapIndex);
+			if (_newPartyMapIndex != kM1_mapIndexNone) {
+				processNewPartyMap(_newPartyMapIndex);
 				_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
-				_g327_newPartyMapIndex = kM1_mapIndexNone;
+				_newPartyMapIndex = kM1_mapIndexNone;
 				_eventMan->f357_discardAllInput();
 			}
 			_timeline->f261_processTimeline();
 
-			if (_g327_newPartyMapIndex == kM1_mapIndexNone)
+			if (_newPartyMapIndex == kM1_mapIndexNone)
 				break;
 		}
 
@@ -453,8 +453,8 @@ void DMEngine::f2_gameloop() {
 			Box box(0, 223, 0, 135);
 			_displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // (possibly dummy code)
 			_displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
-			if (_g325_setMousePointerToObjectInMainLoop) {
-				_g325_setMousePointerToObjectInMainLoop = false;
+			if (_setMousePointerToObjectInMainLoop) {
+				_setMousePointerToObjectInMainLoop = false;
 				_eventMan->f78_showMouse();
 				_eventMan->f68_setPointerToObject(_objectMan->_g412_objectIconForMousePointer);
 				_eventMan->f77_hideMouse();
@@ -473,9 +473,9 @@ void DMEngine::f2_gameloop() {
 		if (_championMan->_partyDead)
 			break;
 
-		_g313_gameTime++;
+		_gameTime++;
 
-		if (!(_g313_gameTime & 511))
+		if (!(_gameTime & 511))
 			_inventoryMan->f338_decreaseTorchesLightPower();
 
 		if (_championMan->_party._freezeLifeTicks)
@@ -483,28 +483,28 @@ void DMEngine::f2_gameloop() {
 
 		_menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived();
 
-		if (!(_g313_gameTime & (_championMan->_partyIsSleeping ? 15 : 63)))
+		if (!(_gameTime & (_championMan->_partyIsSleeping ? 15 : 63)))
 			_championMan->applyTimeEffects();
 
-		if (_g310_disabledMovementTicks)
-			_g310_disabledMovementTicks--;
+		if (_disabledMovementTicks)
+			_disabledMovementTicks--;
 
-		if (_g311_projectileDisableMovementTicks)
-			_g311_projectileDisableMovementTicks--;
+		if (_projectileDisableMovementTicks)
+			_projectileDisableMovementTicks--;
 
 		_textMan->f44_messageAreaClearExpiredRows();
-		_g321_stopWaitingForPlayerInput = false;
+		_stopWaitingForPlayerInput = false;
 		uint16 vblankCounter = 0;
 		do {
 			_eventMan->processInput();
 
-			if (_g332_stopPressingEye) {
-				_g331_pressingEye = false;
-				_g332_stopPressingEye = false;
+			if (_stopPressingEye) {
+				_pressingEye = false;
+				_stopPressingEye = false;
 				_inventoryMan->f353_drawStopPressingEye();
-			} else if (_g334_stopPressingMouth) {
-				_g333_pressingMouth = false;
-				_g334_stopPressingMouth = false;
+			} else if (_stopPressingMouth) {
+				_pressingMouth = false;
+				_stopPressingMouth = false;
 				_inventoryMan->f350_drawStopPressingMouth();
 			}
 
@@ -514,42 +514,42 @@ void DMEngine::f2_gameloop() {
 				return;
 			}
 			_displayMan->updateScreen();
-			if (!_g321_stopWaitingForPlayerInput) {
+			if (!_stopWaitingForPlayerInput) {
 				_eventMan->f363_highlightBoxDisable();
 			}
 
 			_system->delayMillis(2);
-			if (++vblankCounter >= _g318_waitForInputMaxVerticalBlankCount * 4)
-				_g321_stopWaitingForPlayerInput = true;
+			if (++vblankCounter >= _waitForInputMaxVerticalBlankCount * 4)
+				_stopWaitingForPlayerInput = true;
 
-		} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking);
+		} while (!_stopWaitingForPlayerInput || !_gameTimeTicking);
 	}
 	_canLoadFromGMM = false;
 }
 
-int16 DMEngine::M1_ordinalToIndex(int16 val) {
+int16 DMEngine::ordinalToIndex(int16 val) {
 	return val - 1;
 }
 
-int16 DMEngine::M0_indexToOrdinal(int16 val) {
+int16 DMEngine::indexToOrdinal(int16 val) {
 	return val + 1;
 }
 
-void DMEngine::f441_processEntrance() {
+void DMEngine::processEntrance() {
 	_eventMan->_g441_primaryMouseInput = _eventMan->_primaryMouseInputEntrance;
 	_eventMan->_g442_secondaryMouseInput = nullptr;
 	_eventMan->_g443_primaryKeyboardInput = nullptr;
 	_eventMan->_g444_secondaryKeyboardInput = nullptr;
-	_g562_entranceDoorAnimSteps[0] = new byte[128 * 161 * 12];
+	_entranceDoorAnimSteps[0] = new byte[128 * 161 * 12];
 	for (uint16 idx = 1; idx < 8; idx++)
-		_g562_entranceDoorAnimSteps[idx] = _g562_entranceDoorAnimSteps[idx - 1] + 128 * 161;
+		_entranceDoorAnimSteps[idx] = _entranceDoorAnimSteps[idx - 1] + 128 * 161;
 
-	_g562_entranceDoorAnimSteps[8] = _g562_entranceDoorAnimSteps[7] + 128 * 161;
-	_g562_entranceDoorAnimSteps[9] = _g562_entranceDoorAnimSteps[8] + 128 * 161 * 2;
+	_entranceDoorAnimSteps[8] = _entranceDoorAnimSteps[7] + 128 * 161;
+	_entranceDoorAnimSteps[9] = _entranceDoorAnimSteps[8] + 128 * 161 * 2;
 
-	_displayMan->f466_loadIntoBitmap(k3_entranceRightDoorGraphicIndice, _g562_entranceDoorAnimSteps[4]);
-	_displayMan->f466_loadIntoBitmap(k2_entranceLeftDoorGraphicIndice, _g562_entranceDoorAnimSteps[0]);
-	_g564_interfaceCredits = _displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice);
+	_displayMan->f466_loadIntoBitmap(k3_entranceRightDoorGraphicIndice, _entranceDoorAnimSteps[4]);
+	_displayMan->f466_loadIntoBitmap(k2_entranceLeftDoorGraphicIndice, _entranceDoorAnimSteps[0]);
+	_interfaceCredits = _displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice);
 	_displayMan->_g578_useByteBoxCoordinates = false;
 	Box displayBox;
 	displayBox._x1 = 0;
@@ -557,42 +557,42 @@ void DMEngine::f441_processEntrance() {
 	displayBox._y1 = 0;
 	displayBox._y2 = 160;
 	for (uint16 idx = 1; idx < 4; idx++) {
-		_displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[0], _g562_entranceDoorAnimSteps[idx], displayBox, idx << 2, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161);
+		_displayMan->f132_blitToBitmap(_entranceDoorAnimSteps[0], _entranceDoorAnimSteps[idx], displayBox, idx << 2, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161);
 		displayBox._x2 -= 4;
 	}
 	displayBox._x2 = 127;
 	for (uint16 idx = 5; idx < 8; idx++) {
 		displayBox._x1 += 4;
-		_displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[4], _g562_entranceDoorAnimSteps[idx], displayBox, 0, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161);
+		_displayMan->f132_blitToBitmap(_entranceDoorAnimSteps[4], _entranceDoorAnimSteps[idx], displayBox, 0, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161);
 	}
 
 	do {
-		f439_drawEntrance();
+		drawEntrance();
 		_eventMan->f78_showMouse();
 		_eventMan->f357_discardAllInput();
-		_g298_newGame = k99_modeWaitingOnEntrance;
+		_newGameFl = k99_modeWaitingOnEntrance;
 		do {
 			_eventMan->processInput();
 			if (_engineShouldQuit)
 				return;
 			_eventMan->f380_processCommandQueue();
 			_displayMan->updateScreen();
-		} while (_g298_newGame == k99_modeWaitingOnEntrance);
-	} while (_g298_newGame == k202_CommandEntranceDrawCredits);
+		} while (_newGameFl == k99_modeWaitingOnEntrance);
+	} while (_newGameFl == k202_CommandEntranceDrawCredits);
 
 	//Strangerke: CHECKME: Earlier versions were using G0566_puc_Graphic534_Sound01Switch
 	_sound->f060_SOUND_Play(k01_soundSWITCH, 112, 0x40, 0x40);
-	f22_delay(20);
+	delay(20);
 	_eventMan->f78_showMouse();
-	if (_g298_newGame)
-		f438_STARTEND_OpenEntranceDoors();
+	if (_newGameFl)
+		openEntranceDoors();
 
-	delete[] _g562_entranceDoorAnimSteps[0];
+	delete[] _entranceDoorAnimSteps[0];
 	for (uint16 i = 0; i < 10; ++i)
-		_g562_entranceDoorAnimSteps[i] = nullptr;
+		_entranceDoorAnimSteps[i] = nullptr;
 }
 
-void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
+void DMEngine::endGame(bool doNotDrawCreditsOnly) {
 	static Box boxEndgameRestartOuterEN(103, 217, 145, 159);
 	static Box boxEndgameRestartInnerEN(105, 215, 147, 157);
 
@@ -633,9 +633,9 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 	_eventMan->_g442_secondaryMouseInput = nullptr;
 	_eventMan->_g443_primaryKeyboardInput = nullptr;
 	_eventMan->_g444_secondaryKeyboardInput = nullptr;
-	if (doNotDrawCreditsOnly && !_g302_gameWon) {
+	if (doNotDrawCreditsOnly && !_gameWon) {
 		_sound->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
-		f22_delay(240);
+		delay(240);
 	}
 
 	if (_displayMan->_g322_paletteSwitchingEnabled) {
@@ -643,14 +643,14 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 		for (uint16 i = 0; i < 16; ++i)
 			oldPalTopAndBottomScreen[i] = _displayMan->_g347_paletteTopAndBottomScreen[i];
 		for (int i = 0; i <= 7; i++) {
-			f22_delay(1);
+			delay(1);
 			for (int colIdx = 0; colIdx < 16; colIdx++) {
 				_displayMan->_g346_paletteMiddleScreen[colIdx] = _displayMan->f431_getDarkenedColor(_displayMan->_g346_paletteMiddleScreen[colIdx]);
 				_displayMan->_g347_paletteTopAndBottomScreen[colIdx] = _displayMan->f431_getDarkenedColor(_displayMan->_g347_paletteTopAndBottomScreen[colIdx]);
 			}
 		}
 		_displayMan->_g322_paletteSwitchingEnabled = false;
-		f22_delay(1);
+		delay(1);
 		for (uint16 i = 0; i < 16; ++i)
 			_displayMan->_g347_paletteTopAndBottomScreen[i] = oldPalTopAndBottomScreen[i];
 	} else
@@ -658,7 +658,7 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) {
 
 	uint16 darkBluePalette[16];
 	if (doNotDrawCreditsOnly) {
-		if (_g302_gameWon) {
+		if (_gameWon) {
 			// Strangerke: Related to portraits. Game data could be missing for earlier versions of the game.
 			_displayMan->fillScreen(k12_ColorDarkestGray);
 			for (int16 championIndex = k0_ChampionFirst; championIndex < _championMan->_partyChampionCount; championIndex++) {
@@ -705,9 +705,9 @@ T0444017:
 		_displayMan->f436_STARTEND_FadeToPalette(curPalette);
 		_displayMan->updateScreen();
 		if (waitBeforeDrawingRestart)
-			f22_delay(300);
+			delay(300);
 
-		if (_g524_restartGameAllowed) {
+		if (_restartGameAllowed) {
 			_displayMan->_g578_useByteBoxCoordinates = false;
 			_displayMan->D24_fillScreenBox(restartOuterBox, k12_ColorDarkestGray);
 			_displayMan->D24_fillScreenBox(restartInnerBox, k0_ColorBlack);
@@ -725,18 +725,18 @@ T0444017:
 			_eventMan->f357_discardAllInput();
 			_eventMan->f77_hideMouse();
 			_displayMan->f436_STARTEND_FadeToPalette(curPalette);
-			for (int16 verticalBlankCount = 900; --verticalBlankCount && !_g523_restartGameRequest; f22_delay(1))
+			for (int16 verticalBlankCount = 900; --verticalBlankCount && !_restartGameRequest; delay(1))
 				_eventMan->f380_processCommandQueue();
 
 			_eventMan->f78_showMouse();
-			if (_g523_restartGameRequest) {
+			if (_restartGameRequest) {
 				_displayMan->f436_STARTEND_FadeToPalette(darkBluePalette);
 				_displayMan->fillScreen(k0_ColorBlack);
 				_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_palDungeonView[0]);
-				_g298_newGame = k0_modeLoadSavedGame;
-				if (f435_loadgame(1) != kM1_LoadgameFailure) {
-					f462_startGame();
-					_g523_restartGameRequest = false;
+				_newGameFl = k0_modeLoadSavedGame;
+				if (loadgame(1) != kM1_LoadgameFailure) {
+					startGame();
+					_restartGameRequest = false;
 					_eventMan->f77_hideMouse();
 					_eventMan->f357_discardAllInput();
 					return;
@@ -754,7 +754,7 @@ T0444017:
 	if (_engineShouldQuit)
 		return;
 
-	if (_g524_restartGameAllowed && doNotDrawCreditsOnly) {
+	if (_restartGameAllowed && doNotDrawCreditsOnly) {
 		waitBeforeDrawingRestart = false;
 		_displayMan->f436_STARTEND_FadeToPalette(darkBluePalette);
 		goto T0444017;
@@ -765,7 +765,7 @@ T0444017:
 }
 
 
-void DMEngine::f439_drawEntrance() {
+void DMEngine::drawEntrance() {
 	static Box doorsUpperHalfBox = Box(0, 231, 0, 80);
 	static Box doorsLowerHalfBox = Box(0, 231, 81, 160);
 	static Box closedDoorLeftBox = Box(0, 104, 30, 190);
@@ -802,15 +802,15 @@ void DMEngine::f439_drawEntrance() {
 		_savedScreenForOpenEntranceDoors = new byte[k200_heightScreen * k160_byteWidthScreen * 2];
 	memcpy(_savedScreenForOpenEntranceDoors, _displayMan->_g348_bitmapScreen, 320 * 200);
 
-	_displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], doorsUpperHalfBox, 0, 30, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
-	_displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], doorsLowerHalfBox, 0, 111, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
+	_displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _entranceDoorAnimSteps[8], doorsUpperHalfBox, 0, 30, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
+	_displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _entranceDoorAnimSteps[8], doorsLowerHalfBox, 0, 111, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
 
-	_displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[0], &closedDoorLeftBox, k64_byteWidth, kM1_ColorNoTransparency, 161);
-	_displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[4], &closedDoorRightBox, k64_byteWidth, kM1_ColorNoTransparency, 161);
+	_displayMan->f21_blitToScreen(_entranceDoorAnimSteps[0], &closedDoorLeftBox, k64_byteWidth, kM1_ColorNoTransparency, 161);
+	_displayMan->f21_blitToScreen(_entranceDoorAnimSteps[4], &closedDoorRightBox, k64_byteWidth, kM1_ColorNoTransparency, 161);
 	_displayMan->f436_STARTEND_FadeToPalette(palEntrance);
 }
 
-void DMEngine::f438_STARTEND_OpenEntranceDoors() {
+void DMEngine::openEntranceDoors() {
 	Box rightDoorBox(109, 231, 30, 193);
 	byte *rightDoorBitmap = _displayMan->f489_getNativeBitmapOrGraphic(k3_entranceRightDoorGraphicIndice);
 	Box leftDoorBox(0, 100, 30, 193);
@@ -837,13 +837,13 @@ void DMEngine::f438_STARTEND_OpenEntranceDoors() {
 		leftDoorBlitFrom += 4;
 		rightDoorBox._x1 += 4;
 
-		f22_delay(3);
+		delay(3);
 	}
 	delete[] _savedScreenForOpenEntranceDoors;
 	_savedScreenForOpenEntranceDoors = nullptr;
 }
 
-void DMEngine::f437_STARTEND_drawTittle() {
+void DMEngine::drawTittle() {
 	static Box G0003_s_Graphic562_Box_Title_StrikesBack_Destination(0, 319, 118, 174);
 	static Box G0004_s_Graphic562_Box_Title_StrikesBack_Source(0, 319, 0, 56);
 	static Box G0005_s_Graphic562_Box_Title_Presents(0, 319, 90, 105);
@@ -906,32 +906,32 @@ void DMEngine::f437_STARTEND_drawTittle() {
 	L1392_aui_Palette[10] = D01_RGB_DARK_BLUE;
 	L1392_aui_Palette[12] = D01_RGB_DARK_BLUE;
 	_displayMan->f436_STARTEND_FadeToPalette(L1392_aui_Palette);
-	f22_delay(1);
+	delay(1);
 	for (L1380_i_Counter = 0; L1380_i_Counter < 18; L1380_i_Counter++) {
-		f22_delay(2);
+		delay(2);
 		Box box(L1391_aai_Coordinates[L1380_i_Counter]);
 		_displayMan->f132_blitToBitmap(L1387_apuc_Bitmap_ShrinkedTitle[L1380_i_Counter], _displayMan->_g348_bitmapScreen, box, 0, 0, L1391_aai_Coordinates[L1380_i_Counter][4], k160_byteWidthScreen, kM1_ColorNoTransparency, L1391_aai_Coordinates[L1380_i_Counter][3] - L1391_aai_Coordinates[L1380_i_Counter][2] + 1, k200_heightScreen);
 	}
-	f22_delay(25L);
+	delay(25L);
 	_displayMan->f132_blitToBitmap(L1389_puc_Bitmap_Master_StrikesBack, _displayMan->_g348_bitmapScreen, G0003_s_Graphic562_Box_Title_StrikesBack_Destination, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, k0_ColorBlack, 57, k200_heightScreen);
 	L1392_aui_Palette[10] = D00_RGB_BLACK;
 	L1392_aui_Palette[12] = D07_RGB_RED;
 	_displayMan->f436_STARTEND_FadeToPalette(L1392_aui_Palette);
 	delete[] alloactedMem;
-	f22_delay(75L);
+	delay(75L);
 }
 
-void DMEngine::f442_SARTEND_processCommand202_entranceDrawCredits() {
+void DMEngine::entranceDrawCredits() {
 	_eventMan->f78_showMouse();
 	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
 	_displayMan->f466_loadIntoBitmap(k5_creditsGraphicIndice, _displayMan->_g348_bitmapScreen);
 	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_palCredits);
-	f22_delay(50);
+	delay(50);
 	_eventMan->f541_waitForMouseOrKeyActivity();
-	_g298_newGame = k202_modeEntranceDrawCredits;
+	_newGameFl = k202_modeEntranceDrawCredits;
 }
 
-void DMEngine::f446_STARTEND_fuseSequnce() {
+void DMEngine::fuseSequnce() {
 	int16 L1424_i_Multiple;
 #define AL1424_B_RemoveFluxcagesFromLoadChaosSquare L1424_i_Multiple
 #define AL1424_i_Attack                             L1424_i_Multiple
@@ -959,7 +959,7 @@ void DMEngine::f446_STARTEND_fuseSequnce() {
 	char L1436_ac_String[200];
 
 
-	_g302_gameWon = true;
+	_gameWon = true;
 	if (_inventoryMan->_g432_inventoryChampionOrdinal) {
 		_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
 	}
@@ -968,7 +968,7 @@ void DMEngine::f446_STARTEND_fuseSequnce() {
 	_inventoryMan->f337_setDungeonViewPalette();
 	_championMan->_party._fireShieldDefense = _championMan->_party._spellShieldDefense = _championMan->_party._shieldDefense = 100;
 	_timeline->f260_timelineRefreshAllChampionStatusBoxes();
-	f445_STARTEND_fuseSequenceUpdate();
+	fuseSequenceUpdate();
 	L1431_i_LordChaosMapX = _dungeonMan->_g306_partyMapX;
 	L1432_i_LordChaosMapY = _dungeonMan->_g307_partyMapY;
 	L1431_i_LordChaosMapX += _dirIntoStepCountEast[_dungeonMan->_g308_partyDir], L1432_i_LordChaosMapY += _dirIntoStepCountNorth[_dungeonMan->_g308_partyDir];
@@ -1000,32 +1000,32 @@ T0446002:
 		goto T0446002;
 	}
 
-	f445_STARTEND_fuseSequenceUpdate();
+	fuseSequenceUpdate();
 	for (AL1424_i_Attack = 55; AL1424_i_Attack <= 255; AL1424_i_Attack += 40) {
 		_projexpl->f213_explosionCreate(Thing::_explFireBall, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
-		f445_STARTEND_fuseSequenceUpdate();
+		fuseSequenceUpdate();
 	}
 	_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized);
 	L1428_ps_Group->_type = k25_CreatureTypeLordOrder;
-	f445_STARTEND_fuseSequenceUpdate();
+	fuseSequenceUpdate();
 	for (AL1424_i_Attack = 55; AL1424_i_Attack <= 255; AL1424_i_Attack += 40) {
 		_projexpl->f213_explosionCreate(Thing::_explHarmNonMaterial, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
-		f445_STARTEND_fuseSequenceUpdate();
+		fuseSequenceUpdate();
 	}
 	for (AL1425_i_CycleCount = 4; --AL1425_i_CycleCount; ) {
 		for (AL1424_i_CreatureTypeSwitchCount = 5; --AL1424_i_CreatureTypeSwitchCount; ) {
 			_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized);
 			L1428_ps_Group->_type = (AL1424_i_CreatureTypeSwitchCount & 0x0001) ? k25_CreatureTypeLordOrder : k23_CreatureTypeLordChaos;
-			for (AL1426_i_FuseSequenceUpdateCount = AL1425_i_CycleCount; AL1426_i_FuseSequenceUpdateCount--; f445_STARTEND_fuseSequenceUpdate());
+			for (AL1426_i_FuseSequenceUpdateCount = AL1425_i_CycleCount; AL1426_i_FuseSequenceUpdateCount--; fuseSequenceUpdate());
 		}
 	}
 	_projexpl->f213_explosionCreate(Thing::_explFireBall, 255, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
 	_projexpl->f213_explosionCreate(Thing::_explHarmNonMaterial, 255, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
-	f445_STARTEND_fuseSequenceUpdate();
+	fuseSequenceUpdate();
 	L1428_ps_Group->_type = k26_CreatureTypeGreyLord;
-	f445_STARTEND_fuseSequenceUpdate();
+	fuseSequenceUpdate();
 	_displayMan->_g77_doNotDrawFluxcagesDuringEndgame = true;
-	f445_STARTEND_fuseSequenceUpdate();
+	fuseSequenceUpdate();
 	for (AL1424_i_MapX = 0; AL1424_i_MapX < _dungeonMan->_g273_currMapWidth; AL1424_i_MapX++) {
 		for (AL1425_i_MapY = 0; AL1425_i_MapY < _dungeonMan->_g274_currMapHeight; AL1425_i_MapY++) {
 			if (((L1427_T_Thing = _groupMan->f175_groupGetThing(AL1424_i_MapX, AL1425_i_MapY)) != Thing::_endOfList) && ((AL1424_i_MapX != L1431_i_LordChaosMapX) || (AL1425_i_MapY != L1432_i_LordChaosMapY))) {
@@ -1033,7 +1033,7 @@ T0446002:
 			}
 		}
 	}
-	f445_STARTEND_fuseSequenceUpdate();
+	fuseSequenceUpdate();
 	/* Count and get list of text things located at 0, 0 in the current map. Their text is then printed as messages in the order specified by their first letter (which is not printed) */
 	L1427_T_Thing = _dungeonMan->f161_getSquareFirstThing(0, 0);
 	AL1424_i_TextStringThingCount = 0;
@@ -1052,8 +1052,8 @@ T0446002:
 				_textMan->f43_messageAreaClearAllRows();
 				L1436_ac_String[1] = '\n'; /* New line */
 				_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, &L1436_ac_String[1]);
-				f445_STARTEND_fuseSequenceUpdate();
-				f22_delay(780);
+				fuseSequenceUpdate();
+				delay(780);
 				L1434_c_TextFirstCharacter++;
 				break;
 			}
@@ -1062,22 +1062,22 @@ T0446002:
 
 	for (AL1424_i_Attack = 55; AL1424_i_Attack <= 255; AL1424_i_Attack += 40) {
 		_projexpl->f213_explosionCreate(Thing::_explHarmNonMaterial, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
-		f445_STARTEND_fuseSequenceUpdate();
+		fuseSequenceUpdate();
 	}
 
-	f22_delay(600);
-	_g524_restartGameAllowed = false;
-	f444_endGame(true);
+	delay(600);
+	_restartGameAllowed = false;
+	endGame(true);
 }
 
-void DMEngine::f445_STARTEND_fuseSequenceUpdate() {
+void DMEngine::fuseSequenceUpdate() {
 	_timeline->f261_processTimeline();
 	_displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
 	_sound->f65_playPendingSound();
 	_eventMan->f357_discardAllInput();
 	_displayMan->updateScreen();
-	f22_delay(2);
-	_g313_gameTime++; /* BUG0_71 Some timings are too short on fast computers.
+	delay(2);
+	_gameTime++; /* BUG0_71 Some timings are too short on fast computers.
 					  The ending animation when Lord Chaos is fused plays too quickly because the execution speed is not limited */
 }
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index e115c8f..cc8b93a 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -109,9 +109,8 @@ enum Direction {
 	kDirSouth = 2,
 	kDirWest = 3
 };
-const char *debugGetDirectionName(Direction dir);
-
 
+const char *debugGetDirectionName(Direction dir);
 
 enum ThingType {
 	kM1_PartyThingType = -1,  // @ CM1_THING_TYPE_PARTY
@@ -173,8 +172,6 @@ public:
 	bool operator!=(const Thing &rhs) const { return _data != rhs._data; }
 }; // @ THING
 
-
-
 void turnDirRight(Direction &dir);
 void turnDirLeft(Direction &dir);
 Direction returnOppositeDir(Direction dir);	// @ M18_OPPOSITE
@@ -182,20 +179,18 @@ uint16 returnPrevVal(uint16 val); // @ M19_PREVIOUS
 uint16 returnNextVal(uint16 val); // @ M17_NEXT
 bool isOrientedWestEast(Direction dir);	// @ M16_IS_ORIENTED_WEST_EAST
 
-
 #define setFlag(val, mask) ((val) |= (mask))
 #define getFlag(val, mask) ((val) & (mask))
 #define clearFlag(val, mask) ((val) &= (~(mask))) // @ M09_CLEAR
 
 uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE
-uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height);  // @ M75_BITMAP_BYTE_COUNT
-uint16 M21_normalizeModulo4(uint16 val); // @ M21_NORMALIZE
-int32 M30_time(int32 map_time); // @ M30_TIME
-int32 M33_setMapAndTime(int32 &map_time, uint32 map, uint32 time); // @ M33_SET_MAP_AND_TIME
-uint16 M29_map(int32 map_time); // @ M29_MAP
-Thing M15_thingWithNewCell(Thing thing, int16 cell); // @ M15_THING_WITH_NEW_CELL
-int16 M38_distance(int16 mapx1, int16 mapy1, int16 mapx2, int16 mapy2);// @ M38_DISTANCE
-
+uint16 bitmapByteCount(uint16 pixelWidth, uint16 height);  // @ M75_BITMAP_BYTE_COUNT
+uint16 normalizeModulo4(uint16 val); // @ M21_NORMALIZE
+int32 filterTime(int32 map_time); // @ M30_TIME
+int32 setMapAndTime(int32 &map_time, uint32 map, uint32 time); // @ M33_SET_MAP_AND_TIME
+uint16 getMap(int32 map_time); // @ M29_MAP
+Thing thingWithNewCell(Thing thing, int16 cell); // @ M15_THING_WITH_NEW_CELL
+int16 getDistance(int16 mapx1, int16 mapy1, int16 mapx2, int16 mapy2);// @ M38_DISTANCE
 
 enum Cell {
 	kM1_CellAny = -1, // @ CM1_CELL_ANY      
@@ -208,11 +203,9 @@ enum Cell {
 #define kM1_mapIndexNone -1 // @ CM1_MAP_INDEX_NONE       
 #define k255_mapIndexEntrance 255 // @ C255_MAP_INDEX_ENTRANCE 
 
-
-
 //TODO: Directly use CLIP
 template<typename T>
-inline T f26_getBoundedValue(T min, T val, T max) {
+inline T getBoundedValue(T min, T val, T max) {
 	return CLIP<T>(min, val, max);
 } // @ F0026_MAIN_GetBoundedValue
 
@@ -228,24 +221,22 @@ enum LoadgameResponse {
 	k1_LoadgameSuccess = 1// @ C01_LOAD_GAME_SUCCESS
 };
 
-
 struct SaveGameHeader {
 	byte _version;
 	SaveStateDescriptor _descr;
 };
 
-
 class DMEngine : public Engine {
-	void f462_startGame(); // @ F0462_START_StartGame_CPSF
-	void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
-	void f463_initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
-	void f448_initMemoryManager(); // @ F0448_STARTUP1_InitializeMemoryManager_CPSADEF
-	void f2_gameloop(); // @ F0002_MAIN_GameLoop_CPSDF
-	void initArrays();
+	void startGame(); // @ F0462_START_StartGame_CPSF
+	void processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
+	void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
+	void initMemoryManager(); // @ F0448_STARTUP1_InitializeMemoryManager_CPSADEF
+	void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF
+	void initConstants();
 	Common::String getSavefileName(uint16 slot);
 	void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
 	bool writeCompleteSaveFile(int16 slot, Common::String &desc, int16 saveAndPlayChoice);
-	void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance
+	void drawEntrance(); // @ F0439_STARTEND_DrawEntrance
 public:
 	explicit DMEngine(OSystem *syst, const DMADGameDescription *gameDesc);
 	~DMEngine();
@@ -256,29 +247,29 @@ public:
 
 	GUI::Debugger *getDebugger() { return _console; }
 
-	void f22_delay(uint16 verticalBlank); // @ F0022_MAIN_Delay
-	uint16 f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2); // @ F0030_MAIN_GetScaledProduct
+	void delay(uint16 verticalBlank); // @ F0022_MAIN_Delay
+	uint16 getScaledProduct(uint16 val, uint16 scale, uint16 vale2); // @ F0030_MAIN_GetScaledProduct
 	uint16 getRandomNumber(uint32 max) { return _rnd->getRandomNumber(max - 1); }
-	int16 M1_ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
-	int16 M0_indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
-	void f19_displayErrorAndStop(int16 errorIndex); // @ F0019_MAIN_DisplayErrorAndStop
+	int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
+	int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
+	void displayErrorAndStop(int16 errorIndex); // @ F0019_MAIN_DisplayErrorAndStop
 	virtual Common::Error run(); // @ main
-	void f433_processCommand140_saveGame(); // @ F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF
-	LoadgameResponse f435_loadgame(int16 slot); // @ F0435_STARTEND_LoadGame_CPSF
-	void f441_processEntrance(); // @ F0441_STARTEND_ProcessEntrance
-	void f444_endGame(bool doNotDrawCreditsOnly); // @ F0444_STARTEND_Endgame
-
-	void f438_STARTEND_OpenEntranceDoors(); // @ F0438_STARTEND_OpenEntranceDoors
-	void f437_STARTEND_drawTittle(); // @ F0437_STARTEND_DrawTitle
-	void f442_SARTEND_processCommand202_entranceDrawCredits();
-	void f446_STARTEND_fuseSequnce(); // @ F0446_STARTEND_FuseSequence
-	void f445_STARTEND_fuseSequenceUpdate(); // @ F0445_STARTEND_FuseSequenceUpdate
+	void saveGame(); // @ F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF
+	LoadgameResponse loadgame(int16 slot); // @ F0435_STARTEND_LoadGame_CPSF
+	void processEntrance(); // @ F0441_STARTEND_ProcessEntrance
+	void endGame(bool doNotDrawCreditsOnly); // @ F0444_STARTEND_Endgame
+
+	void openEntranceDoors(); // @ F0438_STARTEND_OpenEntranceDoors
+	void drawTittle(); // @ F0437_STARTEND_DrawTitle
+	void entranceDrawCredits();
+	void fuseSequnce(); // @ F0446_STARTEND_FuseSequence
+	void fuseSequenceUpdate(); // @ F0445_STARTEND_FuseSequenceUpdate
 	Common::Language getGameLanguage();
 
 private:
-	uint16 _g526_dungeonId; // @ G0526_ui_DungeonID
-	byte *_g562_entranceDoorAnimSteps[10]; // @ G0562_apuc_Bitmap_EntranceDoorAnimationSteps
-	byte *_g564_interfaceCredits; // @ G0564_puc_Graphic5_InterfaceCredits
+	uint16 _dungeonId; // @ G0526_ui_DungeonID
+	byte *_entranceDoorAnimSteps[10]; // @ G0562_apuc_Bitmap_EntranceDoorAnimationSteps
+	byte *_interfaceCredits; // @ G0564_puc_Graphic5_InterfaceCredits
 	Common::RandomSource *_rnd;
 	
 	byte *_savedScreenForOpenEntranceDoors; // ad-hoc HACK
@@ -306,30 +297,30 @@ public:
 	bool _engineShouldQuit;
 	int _loadSaveSlotAtRuntime;
 
-	int16 _g298_newGame; // @ G0298_B_NewGame
-	bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested
-
-	bool _g321_stopWaitingForPlayerInput; // @ G0321_B_StopWaitingForPlayerInput
-	bool _g301_gameTimeTicking; // @ G0301_B_GameTimeTicking
-	bool _g524_restartGameAllowed; // @ G0524_B_RestartGameAllowed
-	int32 _g525_gameId; // @ G0525_l_GameID, probably useless here
-	bool _g331_pressingEye; // @ G0331_B_PressingEye
-	bool _g332_stopPressingEye; // @ G0332_B_StopPressingEye
-	bool _g333_pressingMouth; // @ G0333_B_PressingMouth
-	bool _g334_stopPressingMouth; // @ G0334_B_StopPressingMouth
-	bool _g340_highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested
-	int16 _g311_projectileDisableMovementTicks; // @ G0311_i_ProjectileDisabledMovementTicks
-	int16 _g312_lastProjectileDisabledMovementDirection; // @ G0312_i_LastProjectileDisabledMovementDirection
-	bool _g302_gameWon; // @ G0302_B_GameWon
-	int16 _g327_newPartyMapIndex; // @ G0327_i_NewPartyMapIndex
-	bool _g325_setMousePointerToObjectInMainLoop; // @ G0325_B_SetMousePointerToObjectInMainLoop
-	int16 _g310_disabledMovementTicks; // @ G0310_i_DisabledMovementTicks
+	int16 _newGameFl; // @ G0298_B_NewGame
+	bool _restartGameRequest; // @ G0523_B_RestartGameRequested
+
+	bool _stopWaitingForPlayerInput; // @ G0321_B_StopWaitingForPlayerInput
+	bool _gameTimeTicking; // @ G0301_B_GameTimeTicking
+	bool _restartGameAllowed; // @ G0524_B_RestartGameAllowed
+	int32 _gameId; // @ G0525_l_GameID, probably useless here
+	bool _pressingEye; // @ G0331_B_PressingEye
+	bool _stopPressingEye; // @ G0332_B_StopPressingEye
+	bool _pressingMouth; // @ G0333_B_PressingMouth
+	bool _stopPressingMouth; // @ G0334_B_StopPressingMouth
+	bool _highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested
+	int16 _projectileDisableMovementTicks; // @ G0311_i_ProjectileDisabledMovementTicks
+	int16 _lastProjectileDisabledMovementDirection; // @ G0312_i_LastProjectileDisabledMovementDirection
+	bool _gameWon; // @ G0302_B_GameWon
+	int16 _newPartyMapIndex; // @ G0327_i_NewPartyMapIndex
+	bool _setMousePointerToObjectInMainLoop; // @ G0325_B_SetMousePointerToObjectInMainLoop
+	int16 _disabledMovementTicks; // @ G0310_i_DisabledMovementTicks
 
 	int8 _dirIntoStepCountEast[4]; // @ G0233_ai_Graphic559_DirectionToStepEastCount
 	int8 _dirIntoStepCountNorth[4]; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
-	int32 _g313_gameTime; // @ G0313_ul_GameTime
-	char _g353_stringBuildBuffer[128]; // @ G0353_ac_StringBuildBuffer
-	int16 _g318_waitForInputMaxVerticalBlankCount; // @ G0318_i_WaitForInputMaximumVerticalBlankCount
+	int32 _gameTime; // @ G0313_ul_GameTime
+	char _stringBuildBuffer[128]; // @ G0353_ac_StringBuildBuffer
+	int16 _waitForInputMaxVerticalBlankCount; // @ G0318_i_WaitForInputMaximumVerticalBlankCount
 };
 
 bool readSaveGameHeader(Common::InSaveFile* in, SaveGameHeader* header);
diff --git a/engines/dm/dmglobals.cpp b/engines/dm/dmglobals.cpp
index 6457c85..b55c405 100644
--- a/engines/dm/dmglobals.cpp
+++ b/engines/dm/dmglobals.cpp
@@ -42,7 +42,7 @@
 
 namespace DM {
 
-void DMEngine::initArrays() {
+void DMEngine::initConstants() {
 	// G0233_ai_Graphic559_DirectionToStepEastCount
 	_dirIntoStepCountEast[0] = 0;  // North
 	_dirIntoStepCountEast[1] = 1;  // East
@@ -56,7 +56,7 @@ void DMEngine::initArrays() {
 	_dirIntoStepCountNorth[3] = 0;  // South
 }
 
-void DMEngine::f19_displayErrorAndStop(int16 errorIndex) {
+void DMEngine::displayErrorAndStop(int16 errorIndex) {
 	debug("Stuff hit the fun: %d", errorIndex);
 	Common::Event event;
 	while (_system->getEventManager()->pollEvent(event) || true)
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index f9d649a..ef4aa6a 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -557,7 +557,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 		50    /* Explosion */
 	};
 
-	if (_vm->_g298_newGame)
+	if (_vm->_newGameFl)
 		f455_decompressDungeonFile();
 
 	Common::ReadStream *dunDataStream = nullptr;
@@ -582,7 +582,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 		_g278_dungeonFileHeader._thingCounts[i] = dunDataStream->readUint16BE();
 
 	// init party position and mapindex
-	if (_vm->_g298_newGame) {
+	if (_vm->_newGameFl) {
 		uint16 startLoc = _g278_dungeonFileHeader._partyStartLocation;
 		_g308_partyDir = (Direction)((startLoc >> 10) & 3);
 		_g306_partyMapX = startLoc & 0x1F;
@@ -591,7 +591,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 	}
 
 	// load map data
-	if (!_vm->_g523_restartGameRequest) {
+	if (!_vm->_restartGameRequest) {
 		delete[] _g277_dungeonMaps;
 		_g277_dungeonMaps = new Map[_g278_dungeonFileHeader._mapCount];
 	}
@@ -626,7 +626,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 	}
 
 	// load column stuff thingy
-	if (!_vm->_g523_restartGameRequest) {
+	if (!_vm->_restartGameRequest) {
 		delete[] _g281_dungeonMapsFirstColumnIndex;
 		_g281_dungeonMapsFirstColumnIndex = new uint16[_g278_dungeonFileHeader._mapCount];
 	}
@@ -638,10 +638,10 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 	_g282_dungeonColumCount = columCount;
 
 	uint32 actualSquareFirstThingCount = _g278_dungeonFileHeader._squareFirstThingCount;
-	if (_vm->_g298_newGame)
+	if (_vm->_newGameFl)
 		_g278_dungeonFileHeader._squareFirstThingCount += 300;
 
-	if (!_vm->_g523_restartGameRequest) {
+	if (!_vm->_restartGameRequest) {
 		delete[] _g280_dungeonColumnsCumulativeSquareThingCount;
 		_g280_dungeonColumnsCumulativeSquareThingCount = new uint16[columCount];
 	}
@@ -649,7 +649,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 		_g280_dungeonColumnsCumulativeSquareThingCount[i] = dunDataStream->readUint16BE();
 
 	// load square first things
-	if (!_vm->_g523_restartGameRequest) {
+	if (!_vm->_restartGameRequest) {
 		delete[] _g283_squareFirstThings;
 		_g283_squareFirstThings = new Thing[_g278_dungeonFileHeader._squareFirstThingCount];
 	}
@@ -657,13 +657,13 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 	for (uint16 i = 0; i < actualSquareFirstThingCount; ++i)
 		_g283_squareFirstThings[i].set(dunDataStream->readUint16BE());
 
-	if (_vm->_g298_newGame) {
+	if (_vm->_newGameFl) {
 		for (uint16 i = 0; i < 300; ++i)
 			_g283_squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none;
 	}
 
 	// load text data
-	if (!_vm->_g523_restartGameRequest) {
+	if (!_vm->_restartGameRequest) {
 		delete[] _g260_dungeonTextData;
 		_g260_dungeonTextData = new uint16[_g278_dungeonFileHeader._textDataWordCount];
 	}
@@ -671,13 +671,13 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 	for (uint16 i = 0; i < _g278_dungeonFileHeader._textDataWordCount; ++i)
 		_g260_dungeonTextData[i] = dunDataStream->readUint16BE();
 
-	if (_vm->_g298_newGame)
+	if (_vm->_newGameFl)
 		_vm->_timeline->_g369_eventMaxCount = 100;
 
 	// load things
 	for (uint16 thingType = k0_DoorThingType; thingType < k16_ThingTypeTotal; ++thingType) {
 		uint16 thingCount = _g278_dungeonFileHeader._thingCounts[thingType];
-		if (_vm->_g298_newGame)
+		if (_vm->_newGameFl)
 			_g278_dungeonFileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + additionalThingCounts[thingType]);
 
 		uint16 thingStoreWordCount = g235_ThingDataWordCount[thingType];
@@ -685,7 +685,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 		if (thingStoreWordCount == 0)
 			continue;
 
-		if (!_vm->_g523_restartGameRequest) {
+		if (!_vm->_restartGameRequest) {
 			delete[] _g284_thingData[thingType];
 			_g284_thingData[thingType] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount];
 		}
@@ -708,7 +708,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 			}
 		}
 
-		if (_vm->_g298_newGame) {
+		if (_vm->_newGameFl) {
 			if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType)
 				_vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType];
 
@@ -718,7 +718,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 	}
 
 	// load map data
-	if (!_vm->_g523_restartGameRequest) {
+	if (!_vm->_restartGameRequest) {
 		delete[] _g276_dungeonRawMapData;
 		_g276_dungeonRawMapData = new byte[_g278_dungeonFileHeader._rawMapDataSize];
 	}
@@ -726,7 +726,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 	for (uint32 i = 0; i < _g278_dungeonFileHeader._rawMapDataSize; ++i)
 		_g276_dungeonRawMapData[i] = dunDataStream->readByte();
 
-	if (!_vm->_g523_restartGameRequest) {
+	if (!_vm->_restartGameRequest) {
 		uint8 mapCount = _g278_dungeonFileHeader._mapCount;
 		delete[] _g279_dungeonMapData;
 		_g279_dungeonMapData = new byte**[_g282_dungeonColumCount + mapCount];
@@ -890,7 +890,7 @@ T0172010_ClosedFakeWall:
 		f171_setSquareAspectOrnOrdinals(aspectArray, leftRandomWallOrnamentAllowed, frontRandomWallOrnamentAllowed, rightRandomWallOrnamentAllowed, dir, mapX, mapY, squareIsFakeWall);
 		while ((curThing != Thing::_endOfList) && (curThing.getType() <= k3_SensorThingType)) {
 			ThingType curThingType = curThing.getType();
-			int16 AL0310_i_SideIndex = M21_normalizeModulo4(curThing.getCell() - dir);
+			int16 AL0310_i_SideIndex = normalizeModulo4(curThing.getCell() - dir);
 			if (AL0310_i_SideIndex) { /* Invisible on the back wall if 0 */
 				Sensor *curSensor = (Sensor*)f156_getThingData(curThing);
 				if (curThingType == k2_TextstringType) {
@@ -901,7 +901,7 @@ T0172010_ClosedFakeWall:
 				} else {
 					aspectArray[AL0310_i_SideIndex + 1] = curSensor->getOrnOrdinal();
 					if (curSensor->getType() == k127_SensorWallChampionPortrait) {
-						_vm->_displayMan->_g289_championPortraitOrdinal = _vm->M0_indexToOrdinal(curSensor->getData());
+						_vm->_displayMan->_g289_championPortraitOrdinal = _vm->indexToOrdinal(curSensor->getData());
 					}
 				}
 			}
@@ -984,12 +984,12 @@ void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftA
 												 int16 mapX, int16 mapY, bool isFakeWall) {
 
 	int16 randomWallOrnamentCount = _g269_currMap->_randWallOrnCount;
-	aspectArray[k2_RightWallOrnOrdAspect] = f170_getRandomOrnOrdinal(leftAllowed, randomWallOrnamentCount, mapX, ++mapY * (M21_normalizeModulo4(++dir) + 1), 30);
-	aspectArray[k3_FrontWallOrnOrdAspect] = f170_getRandomOrnOrdinal(frontAllowed, randomWallOrnamentCount, mapX, mapY * (M21_normalizeModulo4(++dir) + 1), 30);
-	aspectArray[k4_LeftWallOrnOrdAspect] = f170_getRandomOrnOrdinal(rightAllowed, randomWallOrnamentCount, mapX, mapY-- * (M21_normalizeModulo4(++dir) + 1), 30);
+	aspectArray[k2_RightWallOrnOrdAspect] = f170_getRandomOrnOrdinal(leftAllowed, randomWallOrnamentCount, mapX, ++mapY * (normalizeModulo4(++dir) + 1), 30);
+	aspectArray[k3_FrontWallOrnOrdAspect] = f170_getRandomOrnOrdinal(frontAllowed, randomWallOrnamentCount, mapX, mapY * (normalizeModulo4(++dir) + 1), 30);
+	aspectArray[k4_LeftWallOrnOrdAspect] = f170_getRandomOrnOrdinal(rightAllowed, randomWallOrnamentCount, mapX, mapY-- * (normalizeModulo4(++dir) + 1), 30);
 	if (isFakeWall || (mapX < 0) || (mapX >= _g273_currMapWidth) || (mapY < 0) || (mapY >= _g274_currMapHeight)) { /* If square is a fake wall or is out of map bounds */
 		for (int16 sideIndex = k2_RightWallOrnOrdAspect; sideIndex <= k4_LeftWallOrnOrdAspect; sideIndex++) { /* Loop to remove any random ornament that is an alcove */
-			if (f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[sideIndex])))
+			if (f149_isWallOrnAnAlcove(_vm->ordinalToIndex(aspectArray[sideIndex])))
 				aspectArray[sideIndex] = 0;
 		}
 	}
@@ -999,7 +999,7 @@ int16 DungeonMan::f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX
 	int16 randomOrnamentIndex = f169_getRandomOrnamentIndex((int16)2000 + (mapX << 5) + mapY, (int16)3000 + (_g272_currMapIndex << (int16)6) + _g273_currMapWidth + _g274_currMapHeight, modulo);
 
 	if (allowed && (randomOrnamentIndex < count))
-		return _vm->M0_indexToOrdinal(randomOrnamentIndex);
+		return _vm->indexToOrdinal(randomOrnamentIndex);
 
 	return 0;
 }
@@ -1349,15 +1349,15 @@ int16 DungeonMan::f142_getProjectileAspect(Thing thing) {
 	ThingType thingType = thing.getType();
 	if (thingType == k15_ExplosionThingType) {
 		if (thing == Thing::_explFireBall)
-			return -_vm->M0_indexToOrdinal(k10_ProjectileAspectExplosionFireBall);
+			return -_vm->indexToOrdinal(k10_ProjectileAspectExplosionFireBall);
 		if (thing == Thing::_explSlime)
-			return -_vm->M0_indexToOrdinal(k12_ProjectileAspectExplosionSlime);
+			return -_vm->indexToOrdinal(k12_ProjectileAspectExplosionSlime);
 		if (thing == Thing::_explLightningBolt)
-			return -_vm->M0_indexToOrdinal(k3_ProjectileAspectExplosionLightningBolt);
+			return -_vm->indexToOrdinal(k3_ProjectileAspectExplosionLightningBolt);
 		if ((thing == Thing::_explPoisonBolt) || (thing == Thing::_explPoisonCloud))
-			return -_vm->M0_indexToOrdinal(k13_ProjectileAspectExplosionPoisonBoltCloud);
+			return -_vm->indexToOrdinal(k13_ProjectileAspectExplosionPoisonBoltCloud);
 
-		return -_vm->M0_indexToOrdinal(k11_ProjectileAspectExplosionDefault);
+		return -_vm->indexToOrdinal(k11_ProjectileAspectExplosionDefault);
 	} else if (thingType == k5_WeaponThingType) {
 		WeaponInfo *weaponInfo = f158_getWeaponInfo(thing);
 		int16 projAspOrd = weaponInfo->getProjectileAspectOrdinal();
@@ -1402,7 +1402,7 @@ Thing DungeonMan::f162_getSquareFirstObject(int16 mapX, int16 mapY) {
 uint16 DungeonMan::f143_getArmourDefense(ArmourInfo* armourInfo, bool useSharpDefense) {
 	uint16 defense = armourInfo->_defense;
 	if (useSharpDefense)
-		defense = _vm->f30_getScaledProduct(defense, 3, getFlag(armourInfo->_attributes, k0x0007_ArmourAttributeSharpDefense) + 4);
+		defense = _vm->getScaledProduct(defense, 3, getFlag(armourInfo->_attributes, k0x0007_ArmourAttributeSharpDefense) + 4);
 
 	return defense;
 }
@@ -1524,7 +1524,7 @@ void DungeonMan::f148_setGroupDirections(Group* group, int16 dir, uint16 mapInde
 	if (mapIndex == _g309_partyMapIndex)
 		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (Direction)dir;
 	else
-		group->setDir(M21_normalizeModulo4(dir));
+		group->setDir(normalizeModulo4(dir));
 }
 
 bool DungeonMan::f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) {
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index c152876..dbf8c1b 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -468,8 +468,8 @@ void EventManager::f68_setPointerToObject(byte* bitmap) {
 
 void EventManager::f71_mouseDropChampionIcon() {
 	_gK100_preventBuildPointerScreenArea = true;
-	uint16 championIconIndex = _vm->M1_ordinalToIndex(_g599_useChampionIconOrdinalAsMousePointerBitmap);
-	_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+	uint16 championIconIndex = _vm->ordinalToIndex(_g599_useChampionIconOrdinalAsMousePointerBitmap);
+	_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kM1_ChampionNone);
 	_g598_mousePointerBitmapUpdated = true;
 	bool useByteBoxCoordinatesBackup = _vm->_displayMan->_g578_useByteBoxCoordinates;
 	_vm->_displayMan->f21_blitToScreen(_g613_mousePointerOriginalColorsChampionIcon, &_vm->_championMan->_boxChampionIcons[championIconIndex << 2], 16, k12_ColorDarkestGray, 18);
@@ -728,7 +728,7 @@ void EventManager::f380_processCommandQueue() {
 
 	Command cmd = _commandQueue.pop();
 	CommandType cmdType = cmd._type;
-	if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft) && (_vm->_g310_disabledMovementTicks || (_vm->_g311_projectileDisableMovementTicks && (_vm->_g312_lastProjectileDisabledMovementDirection == (M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + cmdType - k3_CommandMoveForward)))))) { /* If movement is disabled */
+	if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft) && (_vm->_disabledMovementTicks || (_vm->_projectileDisableMovementTicks && (_vm->_lastProjectileDisabledMovementDirection == (normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + cmdType - k3_CommandMoveForward)))))) { /* If movement is disabled */
 		_g435_isCommandQueueLocked = false;
 		f360_processPendingClick();
 		return;
@@ -825,7 +825,7 @@ void EventManager::f380_processCommandQueue() {
 		return;
 	}
 
-	if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth)
+	if (_vm->_pressingEye || _vm->_pressingMouth)
 		return;
 
 	if (cmdType == k145_CommandSleep) {
@@ -837,7 +837,7 @@ void EventManager::f380_processCommandQueue() {
 			_vm->_championMan->_partyIsSleeping = true;
 			f379_drawSleepScreen();
 			_vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
-			_vm->_g318_waitForInputMaxVerticalBlankCount = 0;
+			_vm->_waitForInputMaxVerticalBlankCount = 0;
 			_g441_primaryMouseInput = _primaryMouseInputPartySleeping;
 			_g442_secondaryMouseInput = 0;
 			_g443_primaryKeyboardInput = _primaryKeyboardInputPartySleeping;
@@ -854,13 +854,13 @@ void EventManager::f380_processCommandQueue() {
 
 	if (cmdType == k140_CommandSaveGame) {
 		if ((_vm->_championMan->_partyChampionCount > 0) && !_vm->_championMan->_candidateChampionOrdinal)
-			_vm->f433_processCommand140_saveGame();
+			_vm->saveGame();
 
 		return;
 	}
 
 	if (cmdType == k147_CommandFreezeGame) {
-		_vm->_g301_gameTimeTicking = false;
+		_vm->_gameTimeTicking = false;
 		_vm->_menuMan->f456_drawDisabledMenu();
 		_vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 112, 136);
 
@@ -893,7 +893,7 @@ void EventManager::f380_processCommandQueue() {
 	}
 
 	if (cmdType == k148_CommandUnfreezeGame) {
-		_vm->_g301_gameTimeTicking = true;
+		_vm->_gameTimeTicking = true;
 		_vm->_menuMan->f457_drawEnabledMenus();
 		_g441_primaryMouseInput = primaryMouseInputBackup;
 		_g442_secondaryMouseInput = secondaryMouseInputBackup;
@@ -904,31 +904,31 @@ void EventManager::f380_processCommandQueue() {
 	}
 
 	if (cmdType == k200_CommandEntranceEnterDungeon) {
-		_vm->_g298_newGame = k1_modeLoadDungeon;
+		_vm->_newGameFl = k1_modeLoadDungeon;
 		return;
 	}
 
 	if (cmdType == k201_CommandEntranceResume) {
-		_vm->_g298_newGame = k0_modeLoadSavedGame;
+		_vm->_newGameFl = k0_modeLoadSavedGame;
 		return;
 	}
 
 	if (cmdType == k202_CommandEntranceDrawCredits) {
-		_vm->f442_SARTEND_processCommand202_entranceDrawCredits();
+		_vm->entranceDrawCredits();
 		return;
 	}
 
 	if ((cmdType >= k210_CommandClickOnDialogChoice_1) && (cmdType <= k213_CommandClickOnDialogChoice_4)) {
-		_vm->_dialog->_g335_selectedDialogChoice = cmdType - (k210_CommandClickOnDialogChoice_1 - 1);
+		_vm->_dialog->_selectedDialogChoice = cmdType - (k210_CommandClickOnDialogChoice_1 - 1);
 		return;
 	}
 
 	if (cmdType == k215_CommandRestartGame)
-		_vm->_g523_restartGameRequest = true;
+		_vm->_restartGameRequest = true;
 }
 
 void EventManager::f365_commandTurnParty(CommandType cmdType) {
-	_vm->_g321_stopWaitingForPlayerInput = true;
+	_vm->_stopWaitingForPlayerInput = true;
 	if (cmdType == k1_CommandTurnLeft)
 		f362_commandHighlightBoxEnable(234, 261, 125, 145);
 	else
@@ -941,7 +941,7 @@ void EventManager::f365_commandTurnParty(CommandType cmdType) {
 	}
 
 	_vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, false);
-	_vm->_championMan->setPartyDirection(M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + ((cmdType == k2_CommandTurnRight) ? 1 : 3)));
+	_vm->_championMan->setPartyDirection(normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + ((cmdType == k2_CommandTurnRight) ? 1 : 3)));
 	_vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, true);
 }
 
@@ -968,7 +968,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 		-1    /* Left */
 	};
 
-	_vm->_g321_stopWaitingForPlayerInput = true;
+	_vm->_stopWaitingForPlayerInput = true;
 	Champion *championsPtr = _vm->_championMan->_champions;
 	for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_partyChampionCount; idx++) {
 		_vm->_championMan->decrementStamina(idx, ((championsPtr->_load * 3) / _vm->_championMan->getMaximumLoad(championsPtr)) + 1); /* BUG0_50 When a champion is brought back to life at a Vi Altar, his current stamina is lower than what it was before dying. Each time the party moves the current stamina of all champions is decreased, including for dead champions, by an amount that depends on the current load of the champion. For a dead champion the load before he died is used */
@@ -1007,7 +1007,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	if (_vm->_championMan->_partyChampionCount) {
 		if (isMovementBlocked) {
 			movementArrowIdx += (_vm->_dungeonMan->_g308_partyDir + 2);
-			int16 L1124_i_FirstDamagedChampionIndex = _vm->_championMan->getTargetChampionIndex(partyMapX, partyMapY, M21_normalizeModulo4(movementArrowIdx));
+			int16 L1124_i_FirstDamagedChampionIndex = _vm->_championMan->getTargetChampionIndex(partyMapX, partyMapY, normalizeModulo4(movementArrowIdx));
 			int16 L1125_i_SecondDamagedChampionIndex = _vm->_championMan->getTargetChampionIndex(partyMapX, partyMapY, returnNextVal(movementArrowIdx));
 			int16 damage = _vm->_championMan->addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
 			if (L1124_i_FirstDamagedChampionIndex != L1125_i_SecondDamagedChampionIndex)
@@ -1025,7 +1025,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	// DEBUG CODE: check for Console flag
 	if (isMovementBlocked && !_vm->_console->_debugNoclip) {
 		f357_discardAllInput();
-		_vm->_g321_stopWaitingForPlayerInput = false;
+		_vm->_stopWaitingForPlayerInput = false;
 		return;
 	}
 
@@ -1042,8 +1042,8 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 
 		championsPtr++;
 	}
-	_vm->_g310_disabledMovementTicks = disabledMovtTicks;
-	_vm->_g311_projectileDisableMovementTicks = 0;
+	_vm->_disabledMovementTicks = disabledMovtTicks;
+	_vm->_projectileDisableMovementTicks = 0;
 }
 
 bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int16 posX, int16 posY) {
@@ -1074,7 +1074,7 @@ bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int
 	}
 
 	if (objectThrownFl)
-		_vm->_g321_stopWaitingForPlayerInput = true;
+		_vm->_stopWaitingForPlayerInput = true;
 
 	return objectThrownFl;
 }
@@ -1124,7 +1124,7 @@ void EventManager::f368_commandSetLeader(ChampionIndex champIndex) {
 	Champion *champion = &cm._champions[cm._leaderIndex];
 	champion->_dir = _vm->_dungeonMan->_g308_partyDir;
 	cm._champions[champIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(cm._leaderHandObject);
-	if (_vm->M0_indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) {
+	if (_vm->indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) {
 		champion->setAttributeFlag(k0x0400_ChampionAttributeIcon, true);
 		champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
 		cm.drawChampionState(champIndex);
@@ -1137,7 +1137,7 @@ void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() {
 
 	if ((mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth)
 		&& (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight))
-		_vm->_g321_stopWaitingForPlayerInput = _vm->_moveSens->f275_sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(_vm->_dungeonMan->_g308_partyDir));
+		_vm->_stopWaitingForPlayerInput = _vm->_moveSens->f275_sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(_vm->_dungeonMan->_g308_partyDir));
 }
 
 void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16 posY) {
@@ -1159,9 +1159,9 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 		if (_vm->_championMan->_leaderEmptyHanded) {
 			Junk *junkPtr = (Junk*)_vm->_dungeonMan->f157_getSquareFirstThingData(L1155_i_MapX, L1156_i_MapY);
 			if ((((Door*)junkPtr)->hasButton()) && _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
-				_vm->_g321_stopWaitingForPlayerInput = true;
+				_vm->_stopWaitingForPlayerInput = true;
 				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
-				_vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1);
+				_vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_gameTime + 1);
 				return;
 			}
 		} else if (f375_processType80_clickDungeonView_isLeaderHandObjThrown(posX, posY))
@@ -1235,7 +1235,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 	Champion *champ = &champMan._champions[championIndex];
 	if (commandType == k162_CommandClickInPanelCancel) {
 		invMan.f355_toggleInventory(k4_ChampionCloseInventory);
-		champMan._candidateChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+		champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 		if (champMan._partyChampionCount == 1) {
 			f368_commandSetLeader(kM1_ChampionNone);
 		}
@@ -1253,7 +1253,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 		return;
 	}
 
-	champMan._candidateChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+	champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 	int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
 	int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
 
@@ -1286,7 +1286,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 	}
 
 	if (champMan._partyChampionCount == 1) {
-		_vm->_projexpl->_g362_lastPartyMovementTime = _vm->_g313_gameTime;
+		_vm->_projexpl->_g362_lastPartyMovementTime = _vm->_gameTime;
 		f368_commandSetLeader(k0_ChampionFirst);
 		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(k0_ChampionFirst);
 	} else
@@ -1350,7 +1350,7 @@ void EventManager::f373_processType80_clickInDungeonView_grabLeaderHandObject(ui
 		Thing groupThing = _vm->_groupMan->f175_groupGetThing(mapX, mapY);
 		if ((groupThing != Thing::_endOfList) &&
 			!_vm->_moveSens->f264_isLevitating(groupThing) &&
-			_vm->_groupMan->f176_getCreatureOrdinalInCell((Group*)_vm->_dungeonMan->f156_getThingData(groupThing), M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir))) {
+			_vm->_groupMan->f176_getCreatureOrdinalInCell((Group*)_vm->_dungeonMan->f156_getThingData(groupThing), normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir))) {
 			return; /* It is not possible to grab an object on floor if there is a non levitating creature on its cell */
 		}
 	}
@@ -1361,7 +1361,7 @@ void EventManager::f373_processType80_clickInDungeonView_grabLeaderHandObject(ui
 		_vm->_championMan->putObjectInLeaderHand(topPileThing, true);
 	}
 
-	_vm->_g321_stopWaitingForPlayerInput = true;
+	_vm->_stopWaitingForPlayerInput = true;
 }
 
 void EventManager::f374_processType80_clickInDungeonViewDropLeaderHandObject(uint16 viewCell) {
@@ -1377,13 +1377,13 @@ void EventManager::f374_processType80_clickInDungeonViewDropLeaderHandObject(uin
 	if (viewCell > k1_ViewCellFrontRight)
 		mapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], mapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
 
-	uint16 currCell = M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + viewCell);
+	uint16 currCell = normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + viewCell);
 	Thing removedThing = _vm->_championMan->getObjectRemovedFromLeaderHand();
-	_vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(removedThing, currCell), kM1_MapXNotOnASquare, 0, mapX, mapY);
+	_vm->_moveSens->f267_getMoveResult(thingWithNewCell(removedThing, currCell), kM1_MapXNotOnASquare, 0, mapX, mapY);
 	if (droppingIntoAnAlcove && _vm->_dungeonMan->_g287_isFacingViAltar && (_vm->_objectMan->f33_getIconIndex(removedThing) == k147_IconIndiceJunkChampionBones)) {
 		Junk *removedJunk = (Junk*)_vm->_dungeonMan->f156_getThingData(removedThing);
 		TimelineEvent newEvent;
-		M33_setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 1);
+		setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + 1);
 		newEvent._type = k13_TMEventTypeViAltarRebirth;
 		newEvent._priority = removedJunk->getChargeCount();
 		newEvent._B._location._mapX = mapX;
@@ -1392,7 +1392,7 @@ void EventManager::f374_processType80_clickInDungeonViewDropLeaderHandObject(uin
 		newEvent._C.A._effect = k2_SensorEffToggle;
 		_vm->_timeline->f238_addEventGetEventIndex(&newEvent);
 	}
-	_vm->_g321_stopWaitingForPlayerInput = true;
+	_vm->_stopWaitingForPlayerInput = true;
 }
 
 bool EventManager::f360_hasPendingClick(Common::Point& point, MouseButton button) {
@@ -1429,14 +1429,14 @@ void EventManager::f357_discardAllInput() {
 
 void EventManager::f364_commandTakeStairs(bool stairsGoDown) {
 	_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0);
-	_vm->_g327_newPartyMapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g309_partyMapIndex, stairsGoDown ? -1 : 1, &_vm->_dungeonMan->_g306_partyMapX, &_vm->_dungeonMan->_g307_partyMapY);
-	_vm->_dungeonMan->f173_setCurrentMap(_vm->_g327_newPartyMapIndex);
+	_vm->_newPartyMapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g309_partyMapIndex, stairsGoDown ? -1 : 1, &_vm->_dungeonMan->_g306_partyMapX, &_vm->_dungeonMan->_g307_partyMapY);
+	_vm->_dungeonMan->f173_setCurrentMap(_vm->_newPartyMapIndex);
 	_vm->_championMan->setPartyDirection(_vm->_dungeonMan->f155_getStairsExitDirection(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY));
 	_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
 }
 
 void EventManager::f367_commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX, int16 posY) {
-	if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+	if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 		f368_commandSetLeader((ChampionIndex)champIndex);
 	} else {
 		uint16 commandType = f358_getCommandTypeFromMouseInput(_mouseInputChampionNamesHands, Common::Point(posX, posY), k1_LeftMouseButton);
@@ -1454,7 +1454,7 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 
 	_gK100_preventBuildPointerScreenArea = true;
 	if (!_g599_useChampionIconOrdinalAsMousePointerBitmap) {
-		if (_vm->_championMan->getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir)) == kM1_ChampionNone) {
+		if (_vm->_championMan->getIndexInCell(normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir)) == kM1_ChampionNone) {
 			_gK100_preventBuildPointerScreenArea = false;
 			return;
 		}
@@ -1469,25 +1469,25 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 		_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(tmpBitmap, _g613_mousePointerOriginalColorsChampionIcon, 32, 18, 32, 18, mousePointerIconShadowBox);
 		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, _g613_mousePointerOriginalColorsChampionIcon, championIconBox, curChampionIconBox->_x1, curChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
 		_vm->_displayMan->D24_fillScreenBox(*curChampionIconBox, k0_ColorBlack);
-		_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(champIconIndex);
+		_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(champIconIndex);
 	} else {
 		_g598_mousePointerBitmapUpdated = true;
-		uint16 championIconIndex = _vm->M1_ordinalToIndex(_g599_useChampionIconOrdinalAsMousePointerBitmap);
-		_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
-		int16 championCellIndex = _vm->_championMan->getIndexInCell(M21_normalizeModulo4(championIconIndex + _vm->_dungeonMan->_g308_partyDir));
+		uint16 championIconIndex = _vm->ordinalToIndex(_g599_useChampionIconOrdinalAsMousePointerBitmap);
+		_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kM1_ChampionNone);
+		int16 championCellIndex = _vm->_championMan->getIndexInCell(normalizeModulo4(championIconIndex + _vm->_dungeonMan->_g308_partyDir));
 		if (championIconIndex == champIconIndex) {
 			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, k0x0400_ChampionAttributeIcon);
 			_vm->_championMan->drawChampionState((ChampionIndex)championCellIndex);
 		} else {
-			int16 championIndex = _vm->_championMan->getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir));
+			int16 championIndex = _vm->_championMan->getIndexInCell(normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir));
 			if (championIndex >= 0) {
-				_vm->_championMan->_champions[championIndex]._cell = (ViewCell)M21_normalizeModulo4(championIconIndex + _vm->_dungeonMan->_g308_partyDir);
+				_vm->_championMan->_champions[championIndex]._cell = (ViewCell)normalizeModulo4(championIconIndex + _vm->_dungeonMan->_g308_partyDir);
 				setFlag(_vm->_championMan->_champions[championIndex]._attributes, k0x0400_ChampionAttributeIcon);
 				_vm->_championMan->drawChampionState((ChampionIndex)championIndex);
 			} else
 				_vm->_displayMan->D24_fillScreenBox(_vm->_championMan->_boxChampionIcons[championIconIndex], k0_ColorBlack);
 
-			_vm->_championMan->_champions[championCellIndex]._cell = (ViewCell)M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir);
+			_vm->_championMan->_champions[championCellIndex]._cell = (ViewCell)normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir);
 			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, k0x0400_ChampionAttributeIcon);
 			_vm->_championMan->drawChampionState((ChampionIndex)championCellIndex);
 		}
@@ -1566,14 +1566,14 @@ void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(Comm
 			return;
 
 		f362_commandHighlightBoxEnable(234, 303, 63, 73);
-		_vm->_g321_stopWaitingForPlayerInput = _vm->_menuMan->f408_getClickOnSpellCastResult();
+		_vm->_stopWaitingForPlayerInput = _vm->_menuMan->f408_getClickOnSpellCastResult();
 		return;
 	}
 
 	uint16 symbolIndex = cmdType - k101_CommandClickInSpellAreaSymbol_1;
 	Box *highlightBox = &spellSymbolsAndDelete[symbolIndex];
 	f362_commandHighlightBoxEnable(highlightBox->_x1, highlightBox->_x2, highlightBox->_y1, highlightBox->_y2);
-	_vm->f22_delay(1);
+	_vm->delay(1);
 	f363_highlightBoxDisable();
 
 	if (symbolIndex < 6)
@@ -1597,7 +1597,7 @@ void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX,
 				else
 					f362_commandHighlightBoxEnable(234, 318, 110, 120);
 
-				_vm->_g321_stopWaitingForPlayerInput = _vm->_menuMan->f391_didClickTriggerAction(mouseCommand - k113_CommandClickInActionAreaAction_0);
+				_vm->_stopWaitingForPlayerInput = _vm->_menuMan->f391_didClickTriggerAction(mouseCommand - k113_CommandClickInActionAreaAction_0);
 			}
 		}
 	} else if (_vm->_menuMan->_g509_actionAreaContainsIcons) {
@@ -1611,13 +1611,13 @@ void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX,
 }
 
 void EventManager::f544_resetPressingEyeOrMouth() {
-	if (_vm->_g331_pressingEye) {
+	if (_vm->_pressingEye) {
 		_g597_ignoreMouseMovements = false;
-		_vm->_g332_stopPressingEye = true;
+		_vm->_stopPressingEye = true;
 	}
-	if (_vm->_g333_pressingMouth) {
+	if (_vm->_pressingMouth) {
 		_g597_ignoreMouseMovements = false;
-		_vm->_g334_stopPressingMouth = true;
+		_vm->_stopPressingMouth = true;
 	}
 }
 
@@ -1637,7 +1637,7 @@ void EventManager::f541_waitForMouseOrKeyActivity() {
 				break;
 			}
 		}
-		_vm->f22_delay(1);
+		_vm->delay(1);
 		_vm->_displayMan->updateScreen();
 	}
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 10baee8..f56d78d 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -1048,7 +1048,7 @@ void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloor
 	}
 
 	if (drawFootprints)
-		f108_drawFloorOrnament(_vm->M0_indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex);
+		f108_drawFloorOrnament(_vm->indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex);
 }
 
 void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* doorNativeBitmapIndices, int16 byteCount, int16 viewDoorOrnIndex, DoorFrames* doorFrames) {
@@ -1069,12 +1069,12 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d
 	}
 
 	if ((doorFramesTemp == _doorFrameD1C) && _vm->_championMan->_party._event73Count_ThievesEye)
-		f109_drawDoorOrnament(_vm->M0_indexToOrdinal(k16_DoorOrnThivesEyeMask), k2_ViewDoorOrnament_D1LCR);
+		f109_drawDoorOrnament(_vm->indexToOrdinal(k16_DoorOrnThivesEyeMask), k2_ViewDoorOrnament_D1LCR);
 
 	if (doorState == k4_doorState_CLOSED)
 		f102_drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed);
 	else if (doorState == k5_doorState_DESTROYED) {
-		f109_drawDoorOrnament(_vm->M0_indexToOrdinal(k15_DoorOrnDestroyedMask), viewDoorOrnIndex);
+		f109_drawDoorOrnament(_vm->indexToOrdinal(k15_DoorOrnDestroyedMask), viewDoorOrnIndex);
 		f102_drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed);
 	} else {
 		doorState--;
@@ -1253,7 +1253,7 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
 		f100_drawWallSetBitmap(_g705_bitmapWallSet_DoorFrameLeft_D3L, doorFrameLeftD3L);
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g693_doorNativeBitmapIndex_Front_D3LCR, M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3L);
+					  _g693_doorNativeBitmapIndex_Front_D3LCR, bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3L);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		break;
 	case k2_ElementTypePit:
@@ -1333,11 +1333,11 @@ void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 		memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44);
 		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD3R);
 		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
-			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k0_viewDoorButton_D3R);
+			f110_drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k0_viewDoorButton_D3R);
 
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect],
 					  squareAspect[k2_DoorStateAspect], _g693_doorNativeBitmapIndex_Front_D3LCR,
-					  M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3R);
+					  bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3R);
 		break;;
 	case k2_ElementTypePit:
 		if (!squareAspect[k2_PitInvisibleAspect])
@@ -1411,10 +1411,10 @@ void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 		memmove(_g74_tmpBitmap, _g706_bitmapWallSet_DoorFrameLeft_D3C, 32 * 44);
 		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD3C);
 		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
-			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k1_ViewDoorOrnament_D2LCR);
+			f110_drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k1_ViewDoorOrnament_D2LCR);
 
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g693_doorNativeBitmapIndex_Front_D3LCR, M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3C);
+					  _g693_doorNativeBitmapIndex_Front_D3LCR, bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3C);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		break;
 	case k2_ElementTypePit:
@@ -1494,7 +1494,7 @@ void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
 		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, doorFrameTopD2L);
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], _g694_doorNativeBitmapIndex_Front_D2LCR,
-					  M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2L);
+					  bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2L);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		break;
 	case k2_ElementTypePit:
@@ -1581,7 +1581,7 @@ void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
 		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, doorFrameTopD2R);
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g694_doorNativeBitmapIndex_Front_D2LCR, M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2R);
+					  _g694_doorNativeBitmapIndex_Front_D2LCR, bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2R);
 		order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft;
 		break;
 	case k2_ElementTypePit:
@@ -1661,10 +1661,10 @@ void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 		memcpy(_g74_tmpBitmap, _g707_bitmapWallSet_DoorFrameLeft_D2C, 48 * 65);
 		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD2C);
 		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
-			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k2_viewDoorButton_D2C);
+			f110_drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k2_viewDoorButton_D2C);
 
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g694_doorNativeBitmapIndex_Front_D2LCR, M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2C);
+					  _g694_doorNativeBitmapIndex_Front_D2LCR, bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2C);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		break;
 	case k2_ElementTypePit:
@@ -1749,7 +1749,7 @@ void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, k0x0028_CellOrder_DoorPass1_BackRight);
 		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, doorFrameTopD1L);
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1L);
+					  _g695_doorNativeBitmapIndex_Front_D1LCR, bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1L);
 		order = k0x0039_CellOrder_DoorPass2_FrontRight;
 		break;
 	case k2_ElementTypePit:
@@ -1833,7 +1833,7 @@ void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, k0x0018_CellOrder_DoorPass1_BackLeft);
 		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, doorFrameTopD1R);
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1R);
+					  _g695_doorNativeBitmapIndex_Front_D1LCR, bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1R);
 		order = k0x0049_CellOrder_DoorPass2_FrontLeft;
 		break;
 	case k2_ElementTypePit:
@@ -1915,10 +1915,10 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 		f100_drawWallSetBitmap(_g708_bitmapWallSet_DoorFrameLeft_D1C, _doorFrameLeftD1C);
 		f100_drawWallSetBitmap(_g710_bitmapWallSet_DoorFrameRight_D1C, _doorFrameRightD1C);
 		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
-			f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C);
+			f110_drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C);
 
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, _doorFrameD1C);
+					  _g695_doorNativeBitmapIndex_Front_D1LCR, bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, _doorFrameD1C);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		break;
 	case k2_ElementTypePit:
@@ -2181,7 +2181,7 @@ void DisplayMan::f94_loadFloorSet(FloorSet set) {
 }
 
 void DisplayMan::f95_loadWallSet(WallSet set) {
-	if ((_g231_currentWallSet == set) && !_vm->_g523_restartGameRequest)
+	if ((_g231_currentWallSet == set) && !_vm->_restartGameRequest)
 		return;
 
 	_g231_currentWallSet = set;
@@ -2408,11 +2408,11 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 		CreatureAspect &aspect = _creatureAspects219[_g264_currMapAllowedCreatureTypes[creatureType]];
 		uint16 replColorOrdinal = aspect.getReplColour9();
 		if (replColorOrdinal)
-			f93_applyCreatureReplColors(9, _vm->M1_ordinalToIndex(replColorOrdinal));
+			f93_applyCreatureReplColors(9, _vm->ordinalToIndex(replColorOrdinal));
 
 		replColorOrdinal = aspect.getReplColour10();
 		if (replColorOrdinal)
-			f93_applyCreatureReplColors(10, _vm->M1_ordinalToIndex(replColorOrdinal));
+			f93_applyCreatureReplColors(10, _vm->ordinalToIndex(replColorOrdinal));
 	}
 
 	_g297_drawFloorAndCeilingRequested = true;
@@ -3082,11 +3082,11 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 			cellYellowBear = returnOppositeDir(directionParam); /* Alcove is on the opposite direction of the viewing direction */
 			objectShiftIndex = 2;
 		} else {
-			AL_2_viewCell = _vm->M1_ordinalToIndex((int16)remainingViewCellOrdinalsToProcess & 0x000F); /* View cell is the index of coordinates to draw object */
+			AL_2_viewCell = _vm->ordinalToIndex((int16)remainingViewCellOrdinalsToProcess & 0x000F); /* View cell is the index of coordinates to draw object */
 			currentViewCellToDraw = AL_2_viewCell;
 			remainingViewCellOrdinalsToProcess >>= 4; /* Proceed to the next cell ordinal */
 			cellCounter++;
-			cellYellowBear = M21_normalizeModulo4(AL_2_viewCell + directionParam); /* Convert view cell to absolute cell */
+			cellYellowBear = normalizeModulo4(AL_2_viewCell + directionParam); /* Convert view cell to absolute cell */
 			thingParam = firstThingToDraw;
 			viewSquareIndex = AL_10_viewSquareIndexBackup; /* Restore value as it may have been modified while drawing a creature */
 			objectShiftIndex = 0;
@@ -3252,7 +3252,7 @@ T0115015_DrawProjectileAsObject:
 		} else
 			goto T0115129_DrawProjectiles; /* No creature to draw at cell, skip to projectiles */
 
-		creatureDirectionDelta = M21_normalizeModulo4(directionParam - _vm->_groupMan->M50_getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed));
+		creatureDirectionDelta = normalizeModulo4(directionParam - _vm->_groupMan->M50_getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed));
 		twoHalfSquareCreaturesFrontView = false;
 		if ((AL_4_groupCells = activeGroup->_cells) == k255_CreatureTypeSingleCenteredCreature) { /* If there is a single centered creature in the group */
 			if (remainingViewCellOrdinalsToProcess || (doorFrontViewDrawingPass == 1))
@@ -3442,12 +3442,12 @@ T0115077_DrawSecondHalfSquareCreature:
 		else if (viewLane) /* Lane right */
 			AL_4_xPos += 100;
 
-		boxByteGreen._x2 = f26_getBoundedValue(0, AL_4_xPos + byteWidth, 223);
+		boxByteGreen._x2 = getBoundedValue(0, AL_4_xPos + byteWidth, 223);
 
 		if (!boxByteGreen._x2)
 			goto T0115126_CreatureNotVisible;
 		int16 AL_0_creaturePosX;
-		boxByteGreen._x1 = f26_getBoundedValue(0, AL_4_xPos - byteWidth + 1, 223);
+		boxByteGreen._x1 = getBoundedValue(0, AL_4_xPos - byteWidth + 1, 223);
 		if (boxByteGreen._x1) {
 			if (boxByteGreen._x1 == 223)
 				goto T0115126_CreatureNotVisible;
@@ -3485,7 +3485,7 @@ T0115129_DrawProjectiles:
 			if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) {
 				Projectile *projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(thingParam);
 				if ((AL_4_projectileAspect = _vm->_dungeonMan->f142_getProjectileAspect(projectile->_slot)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
-					objectAspect = (ObjectAspect*)&_projectileAspect[_vm->M1_ordinalToIndex(-AL_4_projectileAspect)];
+					objectAspect = (ObjectAspect*)&_projectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)];
 					AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
 					projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
 
@@ -3628,7 +3628,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 						AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke;
 					} else {
 						if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) {
-							objectAspect = (ObjectAspect*)&_projectileAspect[_vm->M1_ordinalToIndex(-_vm->_dungeonMan->f142_getProjectileAspect(Thing::_explLightningBolt))];
+							objectAspect = (ObjectAspect*)&_projectileAspect[_vm->ordinalToIndex(-_vm->_dungeonMan->f142_getProjectileAspect(Thing::_explLightningBolt))];
 							bitmapRedBanana = f489_getNativeBitmapOrGraphic(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
 							explosionCoordinates = rebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
 							byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_byteWidth), explosionCoordinates[2]);
@@ -3706,7 +3706,7 @@ T0115200_DrawExplosion:
 					continue;
 				boxByteGreen._x2 = AL_4_xPos;
 				AL_4_xPos = explosionCoordinates[0];
-				boxByteGreen._x1 = f26_getBoundedValue(0, AL_4_xPos - byteWidth + 1, 223);
+				boxByteGreen._x1 = getBoundedValue(0, AL_4_xPos - byteWidth + 1, 223);
 
 				if (boxByteGreen._x1)
 					AL_4_xPos = paddingPixelCount;
@@ -3841,7 +3841,7 @@ void DisplayMan::f436_STARTEND_FadeToPalette(uint16* P0849_pui_Palette) {
 					*paletteRegister += 256;
 			}
 		}
-		_vm->f22_delay(1);
+		_vm->delay(1);
 		_vm->_eventMan->f357_discardAllInput();
 		f508_buildPaletteChangeCopperList(_gK16_paletteFadeTemporary, _gK16_paletteFadeTemporary);
 	}
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 4b30d2f..14b2a44 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -71,7 +71,7 @@ GroupMan::~GroupMan() {
 }
 
 void GroupMan::f196_initActiveGroups() {
-	if (_vm->_g298_newGame)
+	if (_vm->_newGameFl)
 		_g376_maxActiveGroupCount = 60;
 
 	if (_g375_activeGroups)
@@ -102,7 +102,7 @@ int16 GroupMan::f176_getCreatureOrdinalInCell(Group *group, uint16 cell) {
 	uint16 currMapIndex = _vm->_dungeonMan->_g272_currMapIndex;
 	byte groupCells = f145_getGroupCells(group, currMapIndex);
 	if (groupCells == k255_CreatureTypeSingleCenteredCreature)
-		return _vm->M0_indexToOrdinal(0);
+		return _vm->indexToOrdinal(0);
 
 	int retval = 0;
 	byte creatureIndex = group->getCount();
@@ -113,14 +113,14 @@ int16 GroupMan::f176_getCreatureOrdinalInCell(Group *group, uint16 cell) {
 		do {
 			byte creatureCell = M50_getCreatureValue(groupCells, creatureIndex);
 			if (creatureCell == cell || creatureCell == returnNextVal(cell)) {
-				retval = _vm->M0_indexToOrdinal(creatureIndex);
+				retval = _vm->indexToOrdinal(creatureIndex);
 				break;
 			}
 		} while (creatureIndex--);
 	} else {
 		do {
 			if (M50_getCreatureValue(groupCells, creatureIndex) == cell) {
-				retval = _vm->M0_indexToOrdinal(creatureIndex);
+				retval = _vm->indexToOrdinal(creatureIndex);
 				break;
 			}
 		} while (creatureIndex--);
@@ -151,7 +151,7 @@ void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThin
 		Thing nextThing;
 		do {
 			nextThing = _vm->_dungeonMan->f159_getNextThing(currentThing);
-			currentThing = M15_thingWithNewCell(currentThing, _vm->getRandomNumber(4));
+			currentThing = thingWithNewCell(currentThing, _vm->getRandomNumber(4));
 			if ((currentThing).getType() == k5_WeaponThingType) {
 				L0371_B_WeaponDropped = true;
 			}
@@ -283,7 +283,7 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX
 /* The same pointer type is used no matter the actual type k5_WeaponThingType, k6_ArmourThingType or k10_JunkThingType */
 		currWeapon->setType(currFixedPossession);
 		currWeapon->setCursed(cursedPossessions);
-		nextUnusedThing = M15_thingWithNewCell(nextUnusedThing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell);
+		nextUnusedThing = thingWithNewCell(nextUnusedThing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell);
 		_vm->_moveSens->f267_getMoveResult(nextUnusedThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
 		currFixedPossession = *fixedPossessions++;
 	}
@@ -369,7 +369,7 @@ bool GroupMan::f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16
 		if (Square(*L0574_puc_Square).getDoorState() == k4_doorState_CLOSED) {
 			if (ticks) {
 				TimelineEvent L0575_s_Event;
-				M33_setMapAndTime(L0575_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ticks);
+				setMapAndTime(L0575_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_gameTime + ticks);
 				L0575_s_Event._type = k2_TMEventTypeDoorDestruction;
 				L0575_s_Event._priority = 0;
 				L0575_s_Event._B._location._mapX = mapX;
@@ -445,7 +445,7 @@ int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group *group, uint16 creature
 			if (group->getBehaviour() == k6_behavior_ATTACK) {
 				L0377_ps_Event = _vm->_timeline->_g370_events;
 				for (AL0374_ui_EventIndex = 0; AL0374_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; AL0374_ui_EventIndex++) {
-					if ((M29_map(L0377_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) &&
+					if ((getMap(L0377_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) &&
 						(L0377_ps_Event->_B._location._mapX == mapX) &&
 						(L0377_ps_Event->_B._location._mapY == mapY) &&
 						((AL0375_ui_EventType = L0377_ps_Event->_type) > k32_TMEventTypeUpdateAspectGroup) &&
@@ -533,7 +533,7 @@ void GroupMan::f181_groupDeleteEvents(int16 mapX, int16 mapY) {
 
 	L0336_ps_Event = _vm->_timeline->_g370_events;
 	for (L0334_i_EventIndex = 0; L0334_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0334_i_EventIndex++) {
-		if ((M29_map(L0336_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) &&
+		if ((getMap(L0336_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) &&
 			((L0335_ui_EventType = L0336_ps_Event->_type) > k29_TMEventTypeGroupReactionDangerOnSquare - 1) && (L0335_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1) &&
 			(L0336_ps_Event->_B._location._mapX == mapX) && (L0336_ps_Event->_B._location._mapY == mapY)) {
 			_vm->_timeline->f237_deleteEvent(L0334_i_EventIndex);
@@ -644,7 +644,7 @@ void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16
 	L0444_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0449_T_GroupThing);
 	L0448_s_CreatureInfo = g243_CreatureInfo[L0444_ps_Group->_type];
 	/* Update the event */
-	M33_setMapAndTime(L0465_s_NextEvent._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime);
+	setMapAndTime(L0465_s_NextEvent._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_gameTime);
 	L0465_s_NextEvent._priority = 255 - L0448_s_CreatureInfo._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
 	L0465_s_NextEvent._B._location._mapX = eventMapX;
 	L0465_s_NextEvent._B._location._mapY = eventMapY;
@@ -670,7 +670,7 @@ T0209005_AddEventAndReturn:
 	/* If the creature is Lord Chaos then ignore the event if the game is won. Initialize data to analyze Fluxcages */
 	L0463_B_Archenemy = getFlag(L0448_s_CreatureInfo._attributes, k0x2000_MaskCreatureInfo_archenemy);
 	if (L0463_B_Archenemy) {
-		if (_vm->_g302_gameWon) {
+		if (_vm->_gameWon) {
 			goto T0209139_Return;
 		}
 		_g386_fluxCageCount = 0;
@@ -678,7 +678,7 @@ T0209005_AddEventAndReturn:
 	}
 	L0445_ps_ActiveGroup = &_g375_activeGroups[L0444_ps_Group->getActiveGroupIndex()];
 
-	L0462_i_TicksSinceLastMove = (unsigned char)_vm->_g313_gameTime - L0445_ps_ActiveGroup->_lastMoveTime;
+	L0462_i_TicksSinceLastMove = (unsigned char)_vm->_gameTime - L0445_ps_ActiveGroup->_lastMoveTime;
 	if (L0462_i_TicksSinceLastMove < 0)
 		L0462_i_TicksSinceLastMove += 256;
 
@@ -749,7 +749,7 @@ T0209005_AddEventAndReturn:
 		L0465_s_NextEvent._type = eventType + 5;
 		if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
 			if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) {
-				if (M38_distance(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, eventMapX, eventMapY) <= 1)
+				if (getDistance(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, eventMapX, eventMapY) <= 1)
 					goto T0209044_SetBehavior6_Attack;
 				if (((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k3_behavior_USELESS)) && (AL0447_i_Behavior != k7_behavior_APPROACH)) /* BUG0_00 Useless code. Behavior cannot be 3 because this value is never used. Moreover, the second condition in the && is redundant (if the value is 0 or 3, it cannot be 7). The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */
 					goto T0209054_SetBehavior7_Approach;
@@ -763,13 +763,13 @@ T0209005_AddEventAndReturn:
 			goto T0209136;
 		}
 		if ((AL0450_i_DistanceXToParty > 3) || (AL0451_i_DistanceYToParty > 3)) {
-			L0464_l_NextAspectUpdateTime = _vm->_g313_gameTime + ((L0448_s_CreatureInfo._animationTicks >> 4) & 0xF);
+			L0464_l_NextAspectUpdateTime = _vm->_gameTime + ((L0448_s_CreatureInfo._animationTicks >> 4) & 0xF);
 			goto T0209136;
 		}
 	} else { /* Process Update Behavior events 37 to 41 */
 		L0455_B_CurrentEventTypeIsNotUpdateBehavior = false;
 		if (ticks)
-			L0464_l_NextAspectUpdateTime = _vm->_g313_gameTime;
+			L0464_l_NextAspectUpdateTime = _vm->_gameTime;
 
 		if (eventType == k37_TMEventTypeUpdateBehaviourGroup) { /* Process event 37, Update Group Behavior */
 			if ((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k2_behavior_USELESS) || (AL0447_i_Behavior == k3_behavior_USELESS)) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */
@@ -788,9 +788,9 @@ T0209044_SetBehavior6_Attack:
 							if ((M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) != AL0446_i_Direction) &&
 								((!AL0447_i_CreatureIndex) || (!_vm->getRandomNumber(2)))) {
 								f205_setDirection(L0445_ps_ActiveGroup, AL0446_i_Direction, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
-								M32_setTime(L0465_s_NextEvent._mapTime, _vm->_g313_gameTime + _vm->getRandomNumber(4) + 2); /* Random delay represents the time for the creature to turn */
+								M32_setTime(L0465_s_NextEvent._mapTime, _vm->_gameTime + _vm->getRandomNumber(4) + 2); /* Random delay represents the time for the creature to turn */
 							} else {
-								M32_setTime(L0465_s_NextEvent._mapTime, _vm->_g313_gameTime + 1);
+								M32_setTime(L0465_s_NextEvent._mapTime, _vm->_gameTime + 1);
 							}
 							if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) {
 								L0465_s_NextEvent._mapTime += MIN((uint16)((L0448_s_CreatureInfo._attackTicks >> 1) + _vm->getRandomNumber(4)), ticks);
@@ -840,7 +840,7 @@ T0209061_MoveGroup:
 										L0465_s_NextEvent._B._location._mapY = _vm->_moveSens->_g398_moveResultMapY;;
 										L0445_ps_ActiveGroup->_priorMapX = eventMapX;
 										L0445_ps_ActiveGroup->_priorMapY = eventMapY;
-										L0445_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime;
+										L0445_ps_ActiveGroup->_lastMoveTime = _vm->_gameTime;
 									} else {
 										L0461_i_MovementTicks = AL0447_i_Ticks;
 										L0462_i_TicksSinceLastMove = -1;
@@ -952,7 +952,7 @@ T0209096_SetBehavior0_Wander:
 							if (_vm->getRandomNumber(2)) {
 								/* If the creature cannot move and the party is adjacent then stop fleeing */
 								if (!f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false)) {
-									if (M38_distance(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)
+									if (getDistance(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)
 										goto T0209096_SetBehavior0_Wander;
 								}
 								/* Set creature target to the home square where the creature was located when the party entered the map */
@@ -1002,14 +1002,14 @@ T0209096_SetBehavior0_Wander:
 						if (AL0446_i_GroupCellsCriteria & 0x0038) { /* 7/8 chances of changing cell to the center of the square */
 							L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature;
 						} else { /* 1/8 chance of changing cell to the next or previous cell on the square */
-							AL0446_i_GroupCellsCriteria = M21_normalizeModulo4(M21_normalizeModulo4(L0445_ps_ActiveGroup->_cells) + ((AL0446_i_GroupCellsCriteria & 0x0001) ? 1 : -1));
+							AL0446_i_GroupCellsCriteria = normalizeModulo4(normalizeModulo4(L0445_ps_ActiveGroup->_cells) + ((AL0446_i_GroupCellsCriteria & 0x0001) ? 1 : -1));
 						}
 					}
 					/* If 1/8 chance and the creature is not adjacent to the party and is a quarter square sized creature then process projectile impacts and update the creature cell if still alive. When the creature is not in front of the party, it has 7/8 chances of dodging a projectile by moving to another cell or staying in the center of the square */
 					if (!(AL0446_i_GroupCellsCriteria & 0x0038) && (L0452_i_DistanceToVisibleParty != 1) && (L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter)) {
 						if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* This call to F0218_PROJECTILE_GetImpactCount works fine because there is a single creature in the group so L0445_ps_ActiveGroup->Cells contains only one cell index */
 							goto T0209139_Return;
-						L0445_ps_ActiveGroup->_cells = M21_normalizeModulo4(AL0446_i_GroupCellsCriteria);
+						L0445_ps_ActiveGroup->_cells = normalizeModulo4(AL0446_i_GroupCellsCriteria);
 					}
 				}
 				/* If the creature can see the party and is looking in the party direction or can attack in all direction */
@@ -1034,7 +1034,7 @@ T0209096_SetBehavior0_Wander:
 								} else {
 									AL0446_i_Cell++;
 								}
-								if (!f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = M21_normalizeModulo4(AL0446_i_Cell)) ||
+								if (!f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = normalizeModulo4(AL0446_i_Cell)) ||
 									(_vm->getRandomNumber(2) && !f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((Direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */
 									if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* BUG0_70 A projectile impact on a creature may be ignored. The function F0218_PROJECTILE_GetImpactCount to detect projectile impacts when a quarter square sized creature moves inside a group (to another cell on the same square) may fail if there are several creatures in the group because the function expects a single cell index for its last parameter. The function should be called once for each cell where there is a creature */
 										goto T0209139_Return;
@@ -1063,7 +1063,7 @@ T0209096_SetBehavior0_Wander:
 						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
 						f205_setDirection(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
 						L0465_s_NextEvent._mapTime += 2;
-						L0464_l_NextAspectUpdateTime = M30_time(L0465_s_NextEvent._mapTime);
+						L0464_l_NextAspectUpdateTime = filterTime(L0465_s_NextEvent._mapTime);
 					} else { /* If the party is not visible, move to the target (last known party location) */
 						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
 						if (L0460_ui_CreatureCount) {
@@ -1189,7 +1189,7 @@ int16 GroupMan::f200_groupGetDistanceToVisibleParty(Group *group, int16 creature
 	if (creatureIndex < 0) { /* Negative index means test if each creature in the group can see the party in their respective direction */
 		L0421_i_CreatureViewDirectionCount = 0;
 		for (creatureIndex = group->getCount(); creatureIndex >= 0; creatureIndex--) {
-			L0420_i_CreatureDirection = M21_normalizeModulo4(L0423_ui_GroupDirections >> (creatureIndex << 1));
+			L0420_i_CreatureDirection = normalizeModulo4(L0423_ui_GroupDirections >> (creatureIndex << 1));
 			AL0422_i_Counter = L0421_i_CreatureViewDirectionCount;
 			while (AL0422_i_Counter--) {
 				if (L0425_ai_CreatureViewDirections[AL0422_i_Counter] == L0420_i_CreatureDirection) /* If the creature looks in the same direction as another one in the group */
@@ -1237,7 +1237,7 @@ int16 GroupMan::f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 src
 	int16 L0419_i_ValueC;
 
 
-	if (M38_distance(srcMapX, srcMapY, destMapX, destMapY) <= 1) {
+	if (getDistance(srcMapX, srcMapY, destMapX, destMapY) <= 1) {
 		return 1;
 	}
 	L0415_B_DistanceXSmallerThanDistanceY = (AL0412_i_DistanceX = ((AL0412_i_DistanceX = destMapX - srcMapX) < 0) ? -AL0412_i_DistanceX : AL0412_i_DistanceX) < (AL0413_i_DistanceY = ((AL0413_i_DistanceY = destMapY - srcMapY) < 0) ? -AL0413_i_DistanceY : AL0413_i_DistanceY);
@@ -1262,7 +1262,7 @@ int16 GroupMan::f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 src
 				return 0;
 			}
 		}
-	} while (M38_distance(AL0412_i_PathMapX, AL0413_i_PathMapY, srcMapX, srcMapY) > 1);
+	} while (getDistance(AL0412_i_PathMapX, AL0413_i_PathMapY, srcMapX, srcMapY) > 1);
 	return f226_getDistanceBetweenSquares(srcMapX, srcMapY, destMapX, destMapY);
 }
 
@@ -1352,18 +1352,18 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 		activeGroup->_aspect[creatureIndex] = AL0326_ui_Aspect;
 	} while (L0330_B_ProcessGroup && (creatureIndex--));
 	AL0326_ui_AnimationTicks = g243_CreatureInfo[L0329_ps_Group->_type]._animationTicks;
-	return _vm->_g313_gameTime + (isAttacking ? ((AL0326_ui_AnimationTicks >> 8) & 0xF) : ((AL0326_ui_AnimationTicks >> 4) & 0xF)) + _vm->getRandomNumber(2);
+	return _vm->_gameTime + (isAttacking ? ((AL0326_ui_AnimationTicks >> 8) & 0xF) : ((AL0326_ui_AnimationTicks >> 4) & 0xF)) + _vm->getRandomNumber(2);
 }
 
 void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) {
 	uint16 L0435_ui_GroupDirections;
 	static ActiveGroup *G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup;
 
-	if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == _g395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) {
+	if (twoHalfSquareSizedCreatures && (_vm->_gameTime == _g395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) {
 		return;
 	}
 	L0435_ui_GroupDirections = activeGroup->_directions;
-	if (M21_normalizeModulo4(M50_getCreatureValue(L0435_ui_GroupDirections, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */
+	if (normalizeModulo4(M50_getCreatureValue(L0435_ui_GroupDirections, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */
 		dir = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + dir);
 		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir);
 	} else {
@@ -1371,7 +1371,7 @@ void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 crea
 	}
 	if (twoHalfSquareSizedCreatures) {
 		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex ^ 1, dir); /* Set direction of the second half square sized creature */
-		_g395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime = _vm->_g313_gameTime;
+		_g395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime = _vm->_gameTime;
 		G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup = activeGroup;
 	}
 	activeGroup->_directions = (Direction)L0435_ui_GroupDirections;
@@ -1379,12 +1379,12 @@ void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 crea
 
 void GroupMan::f208_groupAddEvent(TimelineEvent *event, uint32 time) {
 	warning(false, "potentially dangerous cast to uint32 below");
-	if (time < (uint32)M30_time(event->_mapTime)) {
+	if (time < (uint32)filterTime(event->_mapTime)) {
 		event->_type -= 5;
-		event->_C._ticks = M30_time(event->_mapTime) - time;
+		event->_C._ticks = filterTime(event->_mapTime) - time;
 		M32_setTime(event->_mapTime, time);
 	} else {
-		event->_C._ticks = time - M30_time(event->_mapTime);
+		event->_C._ticks = time - filterTime(event->_mapTime);
 	}
 	_vm->_timeline->f238_addEventGetEventIndex(event);
 }
@@ -1400,10 +1400,10 @@ int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo
 	}
 	if ((((L0426_ui_SmellRange + 1) >> 1) >= _g381_currGroupDistanceToParty) && f199_getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f198_isSmellPartyBlocked)) {
 		_vm->_projexpl->_g363_secondaryDirToOrFromParty = _g383_currGroupSecondaryDirToParty;
-		return _vm->M0_indexToOrdinal(_g382_currGroupPrimaryDirToParty);
+		return _vm->indexToOrdinal(_g382_currGroupPrimaryDirToParty);
 	}
-	if ((L0427_i_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapY, mapX)) && ((_vm->_championMan->_party._scentStrengths[_vm->M1_ordinalToIndex(L0427_i_ScentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (L0426_ui_SmellRange << 1)))) { /* If there is a fresh enough party scent on the group square */
-		return _vm->M0_indexToOrdinal(f228_getDirsWhereDestIsVisibleFromSource(mapY, mapX, _vm->_championMan->_party._scents[L0427_i_ScentOrdinal].getMapX(), _vm->_championMan->_party._scents[L0427_i_ScentOrdinal].getMapY()));
+	if ((L0427_i_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapY, mapX)) && ((_vm->_championMan->_party._scentStrengths[_vm->ordinalToIndex(L0427_i_ScentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (L0426_ui_SmellRange << 1)))) { /* If there is a fresh enough party scent on the group square */
+		return _vm->indexToOrdinal(f228_getDirsWhereDestIsVisibleFromSource(mapY, mapX, _vm->_championMan->_party._scents[L0427_i_ScentOrdinal].getMapX(), _vm->_championMan->_party._scents[L0427_i_ScentOrdinal].getMapY()));
 	}
 	return 0;
 }
@@ -1421,7 +1421,7 @@ int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo *info, int1
 
 	for (L0434_i_Direction = kDirNorth; L0434_i_Direction <= kDirWest; L0434_i_Direction++) {
 		if ((!_g384_groupMovementTestedDirections[L0434_i_Direction]) && f202_isMovementPossible(info, mapX, mapY, L0434_i_Direction, allowMovementOverImaginaryPitsAndFakeWalls)) {
-			return _vm->M0_indexToOrdinal(L0434_i_Direction);
+			return _vm->indexToOrdinal(L0434_i_Direction);
 		}
 	}
 	return 0;
@@ -1471,7 +1471,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 #define AL0440_i_Damage             L0440_i_Multiple
 #define AL0440_i_AttackSoundOrdinal L0440_i_Multiple
 
-	_vm->_projexpl->_g361_lastCreatureAttackTime = _vm->_g313_gameTime;
+	_vm->_projexpl->_g361_lastCreatureAttackTime = _vm->_gameTime;
 	ActiveGroup L0443_s_ActiveGroup = _g375_activeGroups[group->getActiveGroupIndex()];
 	CreatureInfo *L0441_ps_CreatureInfo = &g243_CreatureInfo[AL0437_ui_CreatureType = group->_type];
 	uint16 L0438_ui_PrimaryDirectionToParty = _g382_currGroupPrimaryDirToParty;
@@ -1527,7 +1527,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
 		_vm->_sound->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, mapX, mapY, k0_soundModePlayImmediately);
-		_vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (Direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
+		_vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (Direction)_g382_currGroupPrimaryDirToParty, getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
 	} else {
 		if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) {
 			AL0439_i_ChampionIndex = _vm->getRandomNumber(4);
@@ -1717,7 +1717,7 @@ void GroupMan::f180_startWanedring(int16 mapX, int16 mapY) {
 	if (L0332_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
 		L0332_ps_Group->setBehaviour(k0_behavior_WANDER);
 	}
-	M33_setMapAndTime(L0333_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, (_vm->_g313_gameTime + 1));
+	setMapAndTime(L0333_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, (_vm->_gameTime + 1));
 	L0333_s_Event._type = k37_TMEventTypeUpdateBehaviourGroup;
 	L0333_s_Event._priority = 255 - g243_CreatureInfo[L0332_ps_Group->_type]._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
 	L0333_s_Event._C._ticks = 0;
@@ -1750,7 +1750,7 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
 	L0340_ps_Group->getActiveGroupIndex() = L0344_i_ActiveGroupIndex;
 	L0341_ps_ActiveGroup->_priorMapX = L0341_ps_ActiveGroup->_homeMapX = mapX;
 	L0341_ps_ActiveGroup->_priorMapY = L0341_ps_ActiveGroup->_homeMapY = mapY;
-	L0341_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime - 127;
+	L0341_ps_ActiveGroup->_lastMoveTime = _vm->_gameTime - 127;
 	L0339_ui_CreatureIndex = L0340_ps_Group->getCount();
 	do {
 		L0341_ps_ActiveGroup->_directions = (Direction)f178_getGroupValueUpdatedWithCreatureValue(L0341_ps_ActiveGroup->_directions, L0339_ui_CreatureIndex, L0340_ps_Group->getDir());
@@ -1771,7 +1771,7 @@ void GroupMan::f184_removeActiveGroup(uint16 activeGroupIndex) {
 	L0348_ps_Group = &((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex];
 	_g377_currActiveGroupCount--;
 	L0348_ps_Group->_cells = L0347_ps_ActiveGroup->_cells;
-	L0348_ps_Group->setDir(M21_normalizeModulo4(L0347_ps_ActiveGroup->_directions));
+	L0348_ps_Group->setDir(normalizeModulo4(L0347_ps_ActiveGroup->_directions));
 	if (L0348_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
 		L0348_ps_Group->setBehaviour(k0_behavior_WANDER);
 	}
@@ -1988,7 +1988,7 @@ void GroupMan::f224_fluxCageAction(int16 mapX, int16 mapY) {
 
 	_vm->_dungeonMan->f163_linkThingToList(L0545_T_Thing, Thing(0), mapX, mapY);
 	(((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[L0545_T_Thing.getIndex()]).setType(k50_ExplosionType_Fluxcage);
-	M33_setMapAndTime(L0547_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + 100);
+	setMapAndTime(L0547_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_gameTime + 100);
 	L0547_s_Event._type = k24_TMEventTypeRemoveFluxcage;
 	L0547_s_Event._priority = 0;
 	L0547_s_Event._C._slot = L0545_T_Thing.toUint16();
@@ -2109,7 +2109,7 @@ void GroupMan::f225_fuseAction(uint16 mapX, uint16 mapY) {
 				return;
 			}
 		}
-		_vm->f446_STARTEND_fuseSequnce();
+		_vm->fuseSequnce();
 	}
 }
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index e941663..222be92 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -96,22 +96,22 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	if ((championIndex != k4_ChampionCloseInventory) && !_vm->_championMan->_champions[championIndex]._currHealth) {
 		return;
 	}
-	if (_vm->_g333_pressingMouth || _vm->_g331_pressingEye) {
+	if (_vm->_pressingMouth || _vm->_pressingEye) {
 		return;
 	}
-	_vm->_g321_stopWaitingForPlayerInput = true;
+	_vm->_stopWaitingForPlayerInput = true;
 	AL1102_ui_InventoryChampionOrdinal = _g432_inventoryChampionOrdinal;
-	if (_vm->M0_indexToOrdinal(championIndex) == AL1102_ui_InventoryChampionOrdinal) {
+	if (_vm->indexToOrdinal(championIndex) == AL1102_ui_InventoryChampionOrdinal) {
 		championIndex = k4_ChampionCloseInventory;
 	}
 	_vm->_eventMan->f78_showMouse();
 	if (AL1102_ui_InventoryChampionOrdinal) {
-		_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+		_g432_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 		f334_closeChest();
-		L1103_ps_Champion = &_vm->_championMan->_champions[_vm->M1_ordinalToIndex(AL1102_ui_InventoryChampionOrdinal)];
+		L1103_ps_Champion = &_vm->_championMan->_champions[_vm->ordinalToIndex(AL1102_ui_InventoryChampionOrdinal)];
 		if (L1103_ps_Champion->_currHealth && !_vm->_championMan->_candidateChampionOrdinal) {
 			setFlag(L1103_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox);
-			_vm->_championMan->drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(AL1102_ui_InventoryChampionOrdinal));
+			_vm->_championMan->drawChampionState((ChampionIndex)_vm->ordinalToIndex(AL1102_ui_InventoryChampionOrdinal));
 		}
 		if (_vm->_championMan->_partyIsSleeping) {
 			_vm->_eventMan->f77_hideMouse();
@@ -129,7 +129,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 		}
 	}
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(championIndex);
+	_g432_inventoryChampionOrdinal = _vm->indexToOrdinal(championIndex);
 	if (!AL1102_ui_InventoryChampionOrdinal) {
 		_vm->_displayMan->f136_shadeScreenBox(&_vm->_displayMan->_boxMovementArrows, k0_ColorBlack);
 	}
@@ -254,7 +254,7 @@ void InventoryMan::f347_drawPanel() {
 		return;
 	}
 
-	Thing thing = cm._champions[_vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand);
+	Thing thing = cm._champions[_vm->ordinalToIndex(_g432_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand);
 
 	_g424_panelContent = k0_PanelContentFoodWaterPoisoned;
 	switch (thing.getType()) {
@@ -498,7 +498,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 	ChampionMan &champMan = *_vm->_championMan;
 	TextMan &textMan = *_vm->_textMan;
 
-	if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) {
+	if (_vm->_pressingEye || _vm->_pressingMouth) {
 		f334_closeChest();
 	}
 
@@ -537,7 +537,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			descString = str;
 		} else if ((thingType == k8_PotionThingType)
 				   && (iconIndex != k163_IconIndicePotionWaterFlask)
-				   && (champMan.getSkillLevel((ChampionIndex)_vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
+				   && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_g432_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
 			str[0] = '_' + ((Potion *)rawThingPtr)->getPower() / 40;
 			str[1] = ' ';
 			str[2] = '\0';
@@ -825,7 +825,7 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 	}
 
 	f334_closeChest();
-	L1094_ps_Champion = &_vm->_championMan->_champions[L1093_ui_ChampionIndex = _vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal)];
+	L1094_ps_Champion = &_vm->_championMan->_champions[L1093_ui_ChampionIndex = _vm->ordinalToIndex(_g432_inventoryChampionOrdinal)];
 	_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
 	L1091_i_Y = 58;
 	for (AL1090_ui_SkillIndex = k0_ChampionSkillFighter; AL1090_ui_SkillIndex <= k3_ChampionSkillWizard; AL1090_ui_SkillIndex++) {
@@ -931,11 +931,11 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 			return;
 		}
 		_vm->_eventMan->_g597_ignoreMouseMovements = true;
-		_vm->_g333_pressingMouth = true;
+		_vm->_pressingMouth = true;
 		if (!_vm->_eventMan->isMouseButtonDown(k1_LeftMouseButton)) {
 			_vm->_eventMan->_g597_ignoreMouseMovements = false;
-			_vm->_g333_pressingMouth = false;
-			_vm->_g334_stopPressingMouth = false;
+			_vm->_pressingMouth = false;
+			_vm->_stopPressingMouth = false;
 		} else {
 			_vm->_eventMan->f78_showMouse();
 			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
@@ -953,7 +953,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 	L1079_ui_IconIndex = _vm->_objectMan->f33_getIconIndex(L1078_T_Thing);
 	AL1088_ui_ThingType = L1078_T_Thing.getType();
 	L1089_ui_Weight = _vm->_dungeonMan->f140_getObjectWeight(L1078_T_Thing);
-	L1083_ps_Champion = &_vm->_championMan->_champions[L1080_ui_ChampionIndex = _vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal)];
+	L1083_ps_Champion = &_vm->_championMan->_champions[L1080_ui_ChampionIndex = _vm->ordinalToIndex(_g432_inventoryChampionOrdinal)];
 	L1082_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1078_T_Thing);
 	if ((L1079_ui_IconIndex >= k8_IconIndiceJunkWater) && (L1079_ui_IconIndex <= k9_IconIndiceJunkWaterSkin)) {
 		if (!(L1082_ps_Junk->getChargeCount())) {
@@ -1004,7 +1004,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 			}
 			L1083_ps_Champion->_shieldDefense += AL1085_ui_AdjustedPotionPower;
 			L1084_s_Event._type = k72_TMEventTypeChampionShield;
-			M33_setMapAndTime(L1084_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + (AL1085_ui_AdjustedPotionPower * AL1085_ui_AdjustedPotionPower));
+			setMapAndTime(L1084_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + (AL1085_ui_AdjustedPotionPower * AL1085_ui_AdjustedPotionPower));
 			L1084_s_Event._priority = L1080_ui_ChampionIndex;
 			L1084_s_Event._B._defense = AL1085_ui_AdjustedPotionPower;
 			_vm->_timeline->f238_addEventGetEventIndex(&L1084_s_Event);
@@ -1050,7 +1050,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 		L1083_ps_Champion->_currHealth = L1083_ps_Champion->_maxHealth;
 
 	if (L1081_B_RemoveObjectFromLeaderHand) {
-		for (L1086_ui_Counter = 5; --L1086_ui_Counter; _vm->f22_delay(8)) { /* Animate mouth icon */
+		for (L1086_ui_Counter = 5; --L1086_ui_Counter; _vm->delay(8)) { /* Animate mouth icon */
 			_vm->_objectMan->f37_drawIconToScreen(k205_IconIndiceMouthOpen + !(L1086_ui_Counter & 0x0001), 56, 46);
 			_vm->_eventMan->f357_discardAllInput();
 			if (_vm->_engineShouldQuit)
@@ -1093,18 +1093,18 @@ void InventoryMan::f348_adjustStatisticCurrentValue(Champion* champ, uint16 stat
 
 void InventoryMan::f352_processCommand71_clickOnEye() {
 	_vm->_eventMan->_g597_ignoreMouseMovements = true;
-	_vm->_g331_pressingEye = true;
+	_vm->_pressingEye = true;
 	if (!_vm->_eventMan->isMouseButtonDown(k1_LeftMouseButton)) {
 		_vm->_eventMan->_g597_ignoreMouseMovements = false;
-		_vm->_g331_pressingEye = false;
-		_vm->_g332_stopPressingEye = false;
+		_vm->_pressingEye = false;
+		_vm->_stopPressingEye = false;
 		return;
 	}
 	_vm->_eventMan->f357_discardAllInput();
 	_vm->_eventMan->f77_hideMouse();
 	_vm->_eventMan->f77_hideMouse();
 	_vm->_eventMan->f77_hideMouse();
-	_vm->f22_delay(8);
+	_vm->delay(8);
 	f332_drawIconToViewport(k203_IconIndiceEyeLooking, 12, 13);
 	if (_vm->_championMan->_leaderEmptyHanded) {
 		f351_drawChampionSkillsAndStatistics();
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index a3910a9..ceaf79e 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -43,8 +43,8 @@
 
 namespace DM {
 
-LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
-	if (slot == -1 && _g298_newGame == k0_modeLoadSavedGame)
+LoadgameResponse DMEngine::loadgame(int16 slot) {
+	if (slot == -1 && _newGameFl == k0_modeLoadSavedGame)
 		return kM1_LoadgameFailure;
 
 	bool L1366_B_FadePalette = true;
@@ -62,18 +62,18 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		uint16 _dungeonId;
 	} dmSaveHeader;
 
-	if (!_g298_newGame) {
+	if (!_newGameFl) {
 		fileName = getSavefileName(slot);
 		saveFileManager = _system->getSavefileManager();
 		file = saveFileManager->openForLoading(fileName);
 	}
 
-	if (_g298_newGame) {
+	if (_newGameFl) {
 		//L1366_B_FadePalette = !F0428_DIALOG_RequireGameDiskInDrive_NoDialogDrawn(C0_DO_NOT_FORCE_DIALOG_DM_CSB, true);
-		_g524_restartGameAllowed = false;
+		_restartGameAllowed = false;
 		_championMan->_partyChampionCount = 0;
 		_championMan->_leaderHandObject = Thing::_none;
-		_g525_gameId = ((int32)getRandomNumber(65536)) * getRandomNumber(65536);
+		_gameId = ((int32)getRandomNumber(65536)) * getRandomNumber(65536);
 	} else {
 		SaveGameHeader header;
 		readSaveGameHeader(file, &header);
@@ -88,9 +88,9 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		dmSaveHeader._gameId = file->readSint32BE();
 		dmSaveHeader._dungeonId = file->readUint16BE();
 
-		_g525_gameId = dmSaveHeader._gameId;
+		_gameId = dmSaveHeader._gameId;
 
-		_g313_gameTime = file->readSint32BE();
+		_gameTime = file->readSint32BE();
 		// G0349_ul_LastRandomNumber = L1371_s_GlobalData.LastRandomNumber;
 		_championMan->_partyChampionCount = file->readUint16BE();
 		_dungeonMan->_g306_partyMapX = file->readSint16BE();
@@ -105,12 +105,12 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 		_groupMan->_g377_currActiveGroupCount = file->readUint16BE();
 		_projexpl->_g361_lastCreatureAttackTime = file->readSint32BE();
 		_projexpl->_g362_lastPartyMovementTime = file->readSint32BE();
-		_g310_disabledMovementTicks = file->readSint16BE();
-		_g311_projectileDisableMovementTicks = file->readSint16BE();
-		_g312_lastProjectileDisabledMovementDirection = file->readSint16BE();
+		_disabledMovementTicks = file->readSint16BE();
+		_projectileDisableMovementTicks = file->readSint16BE();
+		_lastProjectileDisabledMovementDirection = file->readSint16BE();
 		_championMan->_leaderHandObject = Thing(file->readUint16BE());
 		_groupMan->_g376_maxActiveGroupCount = file->readUint16BE();
-		if (!_g523_restartGameRequest) {
+		if (!_restartGameRequest) {
 			_timeline->f233_initTimeline();
 			_groupMan->f196_initActiveGroups();
 		}
@@ -128,31 +128,31 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 	_dungeonMan->f434_loadDungeonFile(file);
 	delete file;
 
-	if (_g298_newGame) {
+	if (_newGameFl) {
 		_timeline->f233_initTimeline();
 		_groupMan->f196_initActiveGroups();
 
 		if (L1366_B_FadePalette) {
 			_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
-			f22_delay(1);
+			delay(1);
 			_displayMan->fillScreen(k0_ColorBlack);
 			_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);
 		}
 	} else {
-		_g526_dungeonId = dmSaveHeader._dungeonId;
+		_dungeonId = dmSaveHeader._dungeonId;
 
-		_g524_restartGameAllowed = true;
+		_restartGameAllowed = true;
 
 		switch (getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY:
-			_dialog->f427_dialogDraw(nullptr, "LOADING GAME . . .", nullptr, nullptr, nullptr, nullptr, true, true, true);
+			_dialog->dialogDraw(nullptr, "LOADING GAME . . .", nullptr, nullptr, nullptr, nullptr, true, true, true);
 			break;
 		case Common::DE_DEU:
-			_dialog->f427_dialogDraw(nullptr, "SPIEL WIRD GELADEN . . .", nullptr, nullptr, nullptr, nullptr, true, true, true);
+			_dialog->dialogDraw(nullptr, "SPIEL WIRD GELADEN . . .", nullptr, nullptr, nullptr, nullptr, true, true, true);
 			break;
 		case Common::FR_FRA:
-			_dialog->f427_dialogDraw(nullptr, "CHARGEMENT DU JEU . . .", nullptr, nullptr, nullptr, nullptr, true, true, true);
+			_dialog->dialogDraw(nullptr, "CHARGEMENT DU JEU . . .", nullptr, nullptr, nullptr, nullptr, true, true, true);
 			break;
 		}
 
@@ -163,20 +163,20 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) {
 }
 
 
-void DMEngine::f433_processCommand140_saveGame() {
+void DMEngine::saveGame() {
 	_menuMan->f456_drawDisabledMenu();
 	_eventMan->f78_showMouse();
 
 	switch (getGameLanguage()) { // localized
 	default:
 	case Common::EN_ANY:
-		_dialog->f427_dialogDraw(nullptr, nullptr, "SAVE AND PLAY", "SAVE AND QUIT", "CANCEL", "LOAD", false, false, false);
+		_dialog->dialogDraw(nullptr, nullptr, "SAVE AND PLAY", "SAVE AND QUIT", "CANCEL", "LOAD", false, false, false);
 		break;
 	case Common::DE_DEU:
-		_dialog->f427_dialogDraw(nullptr, nullptr, "SICHERN/SPIEL", "SICHERN/ENDEN", "WIDERRUFEN", "LOAD", false, false, false);
+		_dialog->dialogDraw(nullptr, nullptr, "SICHERN/SPIEL", "SICHERN/ENDEN", "WIDERRUFEN", "LOAD", false, false, false);
 		break;
 	case Common::FR_FRA:
-		_dialog->f427_dialogDraw(nullptr, nullptr, "GARDER/JOUER", "GARDER/SORTIR", "ANNULLER", "LOAD", false, false, false);
+		_dialog->dialogDraw(nullptr, nullptr, "GARDER/JOUER", "GARDER/SORTIR", "ANNULLER", "LOAD", false, false, false);
 		break;
 	}
 
@@ -187,7 +187,7 @@ void DMEngine::f433_processCommand140_saveGame() {
 		kLoad = 4
 	};
 
-	SaveAndPlayChoice saveAndPlayChoice = (SaveAndPlayChoice)_dialog->f424_dialogGetChoice(4, k0_DIALOG_SET_VIEWPORT, 0, k0_DIALOG_CHOICE_NONE);
+	SaveAndPlayChoice saveAndPlayChoice = (SaveAndPlayChoice)_dialog->getChoice(4, k0_DIALOG_SET_VIEWPORT, 0, k0_DIALOG_CHOICE_NONE);
 
 	if (saveAndPlayChoice == kLoad) {
 		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
@@ -212,13 +212,13 @@ void DMEngine::f433_processCommand140_saveGame() {
 			switch (getGameLanguage()) { // localized
 			default:
 			case Common::EN_ANY:
-				_dialog->f427_dialogDraw(nullptr, "SAVING GAME . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
+				_dialog->dialogDraw(nullptr, "SAVING GAME . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
 				break;
 			case Common::DE_DEU:
-				_dialog->f427_dialogDraw(nullptr, "SPIEL WIRD GESICHERT . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
+				_dialog->dialogDraw(nullptr, "SPIEL WIRD GESICHERT . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
 				break;
 			case Common::FR_FRA:
-				_dialog->f427_dialogDraw(nullptr, "UN MOMENT A SAUVEGARDER DU JEU...", nullptr, nullptr, nullptr, nullptr, false, false, false);
+				_dialog->dialogDraw(nullptr, "UN MOMENT A SAUVEGARDER DU JEU...", nullptr, nullptr, nullptr, nullptr, false, false, false);
 				break;
 			}
 
@@ -229,8 +229,8 @@ void DMEngine::f433_processCommand140_saveGame() {
 			}
 
 			if (!writeCompleteSaveFile(saveSlot, saveDescription, saveAndPlayChoice)) {
-				_dialog->f427_dialogDraw(nullptr, "Unable to open file for saving", "OK", nullptr, nullptr, nullptr, false, false, false);
-				_dialog->f424_dialogGetChoice(1, k0_DIALOG_SET_VIEWPORT, 0, k0_DIALOG_CHOICE_NONE);
+				_dialog->dialogDraw(nullptr, "Unable to open file for saving", "OK", nullptr, nullptr, nullptr, false, false, false);
+				_dialog->getChoice(1, k0_DIALOG_SET_VIEWPORT, 0, k0_DIALOG_CHOICE_NONE);
 			}
 
 			if (!_championMan->_leaderEmptyHanded) {
@@ -243,10 +243,10 @@ void DMEngine::f433_processCommand140_saveGame() {
 
 	if (saveAndPlayChoice == kSaveAndQuit) {
 		_eventMan->f77_hideMouse();
-		f444_endGame(false);
+		endGame(false);
 	}
 
-	_g524_restartGameAllowed = true;
+	_restartGameAllowed = true;
 	_menuMan->f457_drawEnabledMenus();
 	_eventMan->f77_hideMouse();
 }
@@ -302,11 +302,11 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 	file->writeSint32BE(1); // save version
 	file->writeSint32BE(_gameVersion->_origSaveFormatToWrite);
 	file->writeSint32BE(_gameVersion->_origPlatformToWrite);
-	file->writeSint32BE(_g525_gameId);
-	file->writeUint16BE(_g526_dungeonId);
+	file->writeSint32BE(_gameId);
+	file->writeUint16BE(_dungeonId);
 
 	// write C0_SAVE_PART_GLOBAL_DATA part
-	file->writeSint32BE(_g313_gameTime);
+	file->writeSint32BE(_gameTime);
 	//L1348_s_GlobalData.LastRandomNumber = G0349_ul_LastRandomNumber;
 	file->writeUint16BE(_championMan->_partyChampionCount);
 	file->writeSint16BE(_dungeonMan->_g306_partyMapX);
@@ -321,9 +321,9 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 	file->writeUint16BE(_groupMan->_g377_currActiveGroupCount);
 	file->writeSint32BE(_projexpl->_g361_lastCreatureAttackTime);
 	file->writeSint32BE(_projexpl->_g362_lastPartyMovementTime);
-	file->writeSint16BE(_g310_disabledMovementTicks);
-	file->writeSint16BE(_g311_projectileDisableMovementTicks);
-	file->writeSint16BE(_g312_lastProjectileDisabledMovementDirection);
+	file->writeSint16BE(_disabledMovementTicks);
+	file->writeSint16BE(_projectileDisableMovementTicks);
+	file->writeSint16BE(_lastProjectileDisabledMovementDirection);
 	file->writeUint16BE(_championMan->_leaderHandObject.toUint16());
 	file->writeUint16BE(_groupMan->_g376_maxActiveGroupCount);
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 69dff00..e49c4ce 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -129,7 +129,7 @@ void MenuMan::f388_clearActingChampion() {
 		cm._actingChampionOrdinal--;
 		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
 		cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal);
-		cm._actingChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+		cm._actingChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 		_g508_refreshActionArea = true;
 	}
 }
@@ -215,7 +215,7 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
 
 		do {
 			if ((champIndex != champMan._leaderIndex)
-				&& (_vm->M0_indexToOrdinal(champIndex) != champMan._actingChampionOrdinal)
+				&& (_vm->indexToOrdinal(champIndex) != champMan._actingChampionOrdinal)
 				&& (champ->_maximumDamageReceived)
 				&& (champ->_dir != champ->_directionMaximumDamageReceived)) {
 
@@ -241,7 +241,7 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
 		} else {
 			_g509_actionAreaContainsIcons = false;
 			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
-			champMan.drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(champMan._actingChampionOrdinal));
+			champMan.drawChampionState((ChampionIndex)_vm->ordinalToIndex(champMan._actingChampionOrdinal));
 			f387_drawActionArea();
 		}
 	}
@@ -270,7 +270,7 @@ void MenuMan::f387_drawActionArea() {
 		dispMan.f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k10_MenuActionAreaIndice),
 								 &box, k48_byteWidth, kM1_ColorNoTransparency, 45);
 		textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen,
-											235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->M1_ordinalToIndex(champMan._actingChampionOrdinal)]._name,
+											235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._actingChampionOrdinal)]._name,
 											k7_ChampionNameMaximumLength, k200_heightScreen);
 		for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) {
 			textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
@@ -446,8 +446,8 @@ void MenuMan::f457_drawEnabledMenus() {
 		f387_drawActionArea();
 		AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_g432_inventoryChampionOrdinal;
 		if (AL1462_i_InventoryChampionOrdinal) {
-			_vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
-			_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)_vm->M1_ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
+			_vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
+			_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)_vm->ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
 		} else {
 			_vm->_displayMan->f98_drawFloorAndCeiling();
 			f395_drawMovementArrows();
@@ -510,7 +510,7 @@ int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
 	}
 	L1268_i_PowerSymbolOrdinal = L1270_ps_Champion->_symbols[0] - '_'; /* Values 1 to 6 */
 	AL1269_ui_RequiredSkillLevel = L1271_ps_Spell->_baseRequiredSkillLevel + L1268_i_PowerSymbolOrdinal;
-	L1273_ui_Experience = _vm->getRandomNumber(8) + (AL1269_ui_RequiredSkillLevel << 4) + ((_vm->M1_ordinalToIndex(L1268_i_PowerSymbolOrdinal) * L1271_ps_Spell->_baseRequiredSkillLevel) << 3) + (AL1269_ui_RequiredSkillLevel * AL1269_ui_RequiredSkillLevel);
+	L1273_ui_Experience = _vm->getRandomNumber(8) + (AL1269_ui_RequiredSkillLevel << 4) + ((_vm->ordinalToIndex(L1268_i_PowerSymbolOrdinal) * L1271_ps_Spell->_baseRequiredSkillLevel) << 3) + (AL1269_ui_RequiredSkillLevel * AL1269_ui_RequiredSkillLevel);
 	AL1267_ui_SkillLevel = _vm->_championMan->getSkillLevel(champIndex, L1271_ps_Spell->_skillIndex);
 	if (AL1267_ui_SkillLevel < AL1269_ui_RequiredSkillLevel) {
 		L1274_i_MissingSkillLevelCount = AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel;
@@ -533,7 +533,7 @@ int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
 		L1275_ps_Potion->setPower(_vm->getRandomNumber(16) + (L1268_i_PowerSymbolOrdinal * 40));
 		L1270_ps_Champion->_load += _vm->_dungeonMan->f140_getObjectWeight(L1272_T_Object) - AL1269_ui_EmptyFlaskWeight;
 		_vm->_championMan->drawChangedObjectIcons();
-		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)) {
+		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex)) {
 			setFlag(L1270_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad);
 			_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 		}
@@ -547,7 +547,7 @@ int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
 		if (L1271_ps_Spell->getType() == k4_spellType_projectileOpenDoor) {
 			AL1267_ui_SkillLevel <<= 1;
 		}
-		_vm->_championMan->isProjectileSpellCast(champIndex, Thing(L1271_ps_Spell->getType() + Thing::_firstExplosion.toUint16()), f26_getBoundedValue(21, (L1268_i_PowerSymbolOrdinal + 2) * (4 + (AL1267_ui_SkillLevel << 1)), 255), 0);
+		_vm->_championMan->isProjectileSpellCast(champIndex, Thing(L1271_ps_Spell->getType() + Thing::_firstExplosion.toUint16()), getBoundedValue(21, (L1268_i_PowerSymbolOrdinal + 2) * (4 + (AL1267_ui_SkillLevel << 1)), 255), 0);
 		break;
 	case k3_spellKindOther:
 		L1276_s_Event._priority = 0;
@@ -601,7 +601,7 @@ T0412019:
 T0412032:
 			AL1267_ui_Ticks = AL1267_ui_SpellPower * AL1267_ui_SpellPower;
 T0412033:
-			M33_setMapAndTime(L1276_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + AL1267_ui_Ticks);
+			setMapAndTime(L1276_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + AL1267_ui_Ticks);
 			_vm->_timeline->f238_addEventGetEventIndex(&L1276_s_Event);
 			break;
 		case k7_spellType_otherZokathra:
@@ -752,7 +752,7 @@ void MenuMan::f404_createEvent70_light(int16 lightPower, int16 ticks) {
 
 	L1241_s_Event._type = k70_TMEventTypeLight;
 	L1241_s_Event._B._lightPower = lightPower;
-	M33_setMapAndTime(L1241_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + ticks);
+	setMapAndTime(L1241_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + ticks);
 	L1241_s_Event._priority = 0;
 	_vm->_timeline->f238_addEventGetEventIndex(&L1241_s_Event);
 	_vm->_inventoryMan->f337_setDungeonViewPalette();
@@ -791,7 +791,7 @@ bool MenuMan::f403_isPartySpellOrFireShieldSuccessful(Champion* champ, bool spel
 		_vm->_championMan->_party._fireShieldDefense += L1240_s_Event._B._defense;
 	}
 	L1240_s_Event._priority = 0;
-	M33_setMapAndTime(L1240_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + ticks);
+	setMapAndTime(L1240_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + ticks);
 	_vm->_timeline->f238_addEventGetEventIndex(&L1240_s_Event);
 	_vm->_timeline->f260_timelineRefreshAllChampionStatusBoxes();
 	return L1239_B_IsPartySpellOrFireShieldSuccessful;
@@ -891,7 +891,7 @@ bool MenuMan::f391_didClickTriggerAction(int16 actionListIndex) {
 	if (!_vm->_championMan->_actingChampionOrdinal || (actionListIndex != -1 && (_g713_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone)))
 		return false;
 
-	L1199_ps_Champion = &_vm->_championMan->_champions[L1196_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)];
+	L1199_ps_Champion = &_vm->_championMan->_champions[L1196_ui_ChampionIndex = _vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)];
 	if (actionListIndex == -1) {
 		// L1198_B_ClickTriggeredAction is set to -1 since booleans are stored in int16 in the original
 		L1198_B_ClickTriggeredAction = true;
@@ -1273,7 +1273,7 @@ T0407032:
 		AL1246_i_Ticks = _vm->getRandomNumber(_vm->_championMan->getSkillLevel(champIndex, L1254_i_ActionSkillIndex) + 8) + 5;
 		L1258_s_Event._priority = 0;
 		L1258_s_Event._type = k73_TMEventTypeThievesEye;
-		M33_setMapAndTime(L1258_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + AL1246_i_Ticks);
+		setMapAndTime(L1258_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + AL1246_i_Ticks);
 		_vm->_timeline->f238_addEventGetEventIndex(&L1258_s_Event);
 		_vm->_championMan->_party._event73Count_ThievesEye++;
 		goto T0407076;
@@ -1318,7 +1318,7 @@ T0407076:
 		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
 		AL1245_B_ActionPerformed = _vm->_championMan->isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_g308_partyDir)) || (L1247_ps_Champion->_cell == (ViewCell)returnOppositeDir(_vm->_dungeonMan->_g308_partyDir)));
 		if (AL1245_B_ActionPerformed) {
-			_vm->_timeline->_g370_events[L1247_ps_Champion->_enableActionEventIndex]._B._slotOrdinal = _vm->M0_indexToOrdinal(k1_ChampionSlotActionHand);
+			_vm->_timeline->_g370_events[L1247_ps_Champion->_enableActionEventIndex]._B._slotOrdinal = _vm->indexToOrdinal(k1_ChampionSlotActionHand);
 		}
 	}
 	if (L1249_ui_ActionDisabledTicks) {
@@ -1474,14 +1474,14 @@ bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int
 		goto T0402010;
 	L1238_i_CreatureOrdinal = _vm->_groupMan->f177_getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, AL1236_ui_ChampionCell = champ->_cell);
 	if (L1238_i_CreatureOrdinal) {
-		switch (M21_normalizeModulo4(AL1236_ui_ChampionCell + 4 - champ->_dir)) {
+		switch (normalizeModulo4(AL1236_ui_ChampionCell + 4 - champ->_dir)) {
 		case k2_ViewCellBackRight: /* Champion is on the back right of the square and tries to attack a creature in the front right of its square */
 			AL1237_ui_CellDelta = 3;
 			goto T0402005;
 		case k3_ViewCellBackLeft: /* Champion is on the back left of the square and tries to attack a creature in the front left of its square */
 			AL1237_ui_CellDelta = 1;
 T0402005: /* Check if there is another champion in front */
-			if (_vm->_championMan->getIndexInCell(M21_normalizeModulo4(AL1236_ui_ChampionCell + AL1237_ui_CellDelta)) != kM1_ChampionNone) {
+			if (_vm->_championMan->getIndexInCell(normalizeModulo4(AL1236_ui_ChampionCell + AL1237_ui_CellDelta)) != kM1_ChampionNone) {
 				_g513_actionDamage = kM1_damageCantReach;
 				goto T0402010;
 			}
@@ -1493,7 +1493,7 @@ T0402005: /* Check if there is another champion in front */
 		if ((_vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
 			setFlag(AL1237_ui_ActionHitProbability, k0x8000_hitNonMaterialCreatures);
 		}
-		_g513_actionDamage = _vm->_groupMan->f231_getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing), _vm->M1_ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
+		_g513_actionDamage = _vm->_groupMan->f231_getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing), _vm->ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
 		return true;
 	}
 T0402010:
@@ -1570,7 +1570,7 @@ void MenuMan::f381_printMessageAfterReplacements(const char* str) {
 			}
 			switch (*str) {
 			case 'p': /* '@p' in the source string is replaced by the champion name followed by a space */
-				L1165_pc_ReplacementString = _vm->_championMan->_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._name;
+				L1165_pc_ReplacementString = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._name;
 			}
 			*L1164_pc_Character = '\0';
 			strcat(L1166_ac_OutputString, L1165_pc_ReplacementString);
@@ -1649,7 +1649,7 @@ void MenuMan::f389_processCommands116To119_setActingChampion(uint16 champIndex)
 		return;
 	}
 	L1191_ps_ActionSet = &G0489_as_Graphic560_ActionSets[L1188_ui_ActionSetIndex];
-	_vm->_championMan->_actingChampionOrdinal = _vm->M0_indexToOrdinal(champIndex);
+	_vm->_championMan->_actingChampionOrdinal = _vm->indexToOrdinal(champIndex);
 	f383_setActionList(L1191_ps_ActionSet);
 	_g509_actionAreaContainsIcons = false;
 	setFlag(L1190_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand);
@@ -1676,7 +1676,7 @@ void MenuMan::f383_setActionList(ActionSet* actionSet) {
 		if (getFlag(L1172_ui_MinimumSkillLevel = actionSet->_actionProperties[L1169_ui_ActionListIndex - 1], k0x0080_actionRequiresCharge) && !f382_getActionObjectChargeCount())
 			continue;
 		clearFlag(L1172_ui_MinimumSkillLevel, k0x0080_actionRequiresCharge);
-		if (_vm->_championMan->getSkillLevel(_vm->M1_ordinalToIndex(_vm->_championMan->_actingChampionOrdinal), g496_ActionSkillIndex[L1171_ui_ActionIndex]) >= L1172_ui_MinimumSkillLevel) {
+		if (_vm->_championMan->getSkillLevel(_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal), g496_ActionSkillIndex[L1171_ui_ActionIndex]) >= L1172_ui_MinimumSkillLevel) {
 			_g713_actionList._actionIndices[L1170_ui_NextAvailableActionListIndex] = (ChampionAction)L1171_ui_ActionIndex;
 			_g713_actionList._minimumSkillLevel[L1170_ui_NextAvailableActionListIndex] = L1172_ui_MinimumSkillLevel;
 			L1170_ui_NextAvailableActionListIndex++;
@@ -1693,7 +1693,7 @@ int16 MenuMan::f382_getActionObjectChargeCount() {
 	Junk* L1168_ps_Junk;
 
 
-	L1168_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1167_T_Thing = _vm->_championMan->_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand]);
+	L1168_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1167_T_Thing = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand]);
 	switch (L1167_T_Thing.getType()) {
 	case k5_WeaponThingType:
 		return ((Weapon*)L1168_ps_Junk)->getChargeCount();
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 747e8ef..b24a997 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -147,7 +147,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 					if ((_vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (f273_sensorGetObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData) != Thing::_none))
 						goto T0275058_ProceedToNextThing;
 					_vm->_championMan->getObjectRemovedFromLeaderHand();
-					_vm->_dungeonMan->f163_linkThingToList(M15_thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
+					_vm->_dungeonMan->f163_linkThingToList(thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
 					L0761_T_LeaderHandObject = Thing::_none;
 				}
 				f270_sensorTriggetLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
@@ -165,7 +165,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 					goto T0275058_ProceedToNextThing;
 				_vm->_dungeonMan->f164_unlinkThingFromList(L0762_T_ThingOnSquare, Thing(0), mapX, mapY);
 				_vm->_championMan->getObjectRemovedFromLeaderHand();
-				_vm->_dungeonMan->f163_linkThingToList(M15_thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
+				_vm->_dungeonMan->f163_linkThingToList(thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
 				_vm->_championMan->putObjectInLeaderHand(L0762_T_ThingOnSquare, true);
 				L0753_B_DoNotTriggerSensor = false;
 				break;
@@ -306,7 +306,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					if (L0712_ps_Teleporter->getAbsoluteRotation()) {
 						_vm->_championMan->setPartyDirection(L0712_ps_Teleporter->getRotation());
 					} else {
-						_vm->_championMan->setPartyDirection(M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + L0712_ps_Teleporter->getRotation()));
+						_vm->_championMan->setPartyDirection(normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + L0712_ps_Teleporter->getRotation()));
 					}
 				} else {
 					if (L0710_i_ThingType == k4_GroupThingType) {
@@ -319,7 +319,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 							thing = f263_getTeleporterRotatedProjectileThing(L0712_ps_Teleporter, thing);
 						} else {
 							if (!(L0712_ps_Teleporter->getAbsoluteRotation()) && (mapX != -2)) {
-								thing = M15_thingWithNewCell(thing, M21_normalizeModulo4(thing.getCell() + L0712_ps_Teleporter->getRotation()));
+								thing = thingWithNewCell(thing, normalizeModulo4(thing.getCell() + L0712_ps_Teleporter->getRotation()));
 							}
 						}
 					}
@@ -381,8 +381,8 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 						destMapX += _vm->_dirIntoStepCountEast[L0716_ui_Direction], destMapY += _vm->_dirIntoStepCountNorth[L0716_ui_Direction];
 						L0716_ui_Direction = returnOppositeDir((Direction)L0716_ui_Direction);
 						AL0727_ui_ThingCell = thing.getCell();
-						AL0727_ui_ThingCell = M21_normalizeModulo4((((AL0727_ui_ThingCell - L0716_ui_Direction + 1) & 0x0002) >> 1) + L0716_ui_Direction);
-						thing = M15_thingWithNewCell(thing, AL0727_ui_ThingCell);
+						AL0727_ui_ThingCell = normalizeModulo4((((AL0727_ui_ThingCell - L0716_ui_Direction + 1) & 0x0002) >> 1) + L0716_ui_Direction);
+						thing = thingWithNewCell(thing, AL0727_ui_ThingCell);
 					} else
 						break;
 				}
@@ -421,9 +421,9 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					AL0708_i_ScentIndex--;
 				}
 				if (AL0708_i_ScentIndex) {
-					_vm->_championMan->addScentStrength(mapX, mapY, (int)(_vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime));
+					_vm->_championMan->addScentStrength(mapX, mapY, (int)(_vm->_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime));
 				}
-				_vm->_projexpl->_g362_lastPartyMovementTime = _vm->_g313_gameTime;
+				_vm->_projexpl->_g362_lastPartyMovementTime = _vm->_gameTime;
 				_vm->_championMan->_party._scentCount++;
 				if (_vm->_championMan->_party._event79Count_Footprints) {
 					_vm->_championMan->_party._lastScentIndex = _vm->_championMan->_party._scentCount;
@@ -462,7 +462,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, L0725_B_PartySquare, true);
 			} else {
 				_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
-				_vm->_g327_newPartyMapIndex = L0715_ui_MapIndexDestination;
+				_vm->_newPartyMapIndex = L0715_ui_MapIndexDestination;
 			}
 		} else {
 			if (L0710_i_ThingType == k4_GroupThingType) {
@@ -567,7 +567,7 @@ bool MovesensMan::f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMa
 		L0702_i_ImpactType = kM2_ChampionElemType;
 		for (AL0699_ui_Cell = k0_CellNorthWest; AL0699_ui_Cell < k3_CellSouthWest + 1; AL0699_ui_Cell++) {
 			if (_vm->_championMan->getIndexInCell((ViewCell)AL0699_ui_Cell) >= 0) {
-				L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = _vm->M0_indexToOrdinal(AL0699_ui_Cell);
+				L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = _vm->indexToOrdinal(AL0699_ui_Cell);
 			}
 		}
 	} else {
@@ -576,7 +576,7 @@ bool MovesensMan::f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMa
 		for (AL0699_ui_Cell = k0_CellNorthWest, AL0700_B_CreatureAlive = false; AL0699_ui_Cell < k3_CellSouthWest + 1; AL0699_ui_Cell++) {
 			AL0700_B_CreatureAlive |= L0701_ps_Group->_health[AL0699_ui_Cell];
 			if (_vm->_groupMan->f176_getCreatureOrdinalInCell(L0701_ps_Group, AL0699_ui_Cell)) {
-				L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = _vm->M0_indexToOrdinal(AL0699_ui_Cell);
+				L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = _vm->indexToOrdinal(AL0699_ui_Cell);
 			}
 		}
 		if (!AL0700_B_CreatureAlive) {
@@ -612,7 +612,7 @@ T0266017_CheckProjectileImpacts:
 	while (L0697_T_Thing != Thing::_endOfList) {
 		if (((L0697_T_Thing).getType() == k14_ProjectileThingType) &&
 			(_vm->_timeline->_g370_events[(((Projectile *)_vm->_dungeonMan->_g284_thingData[k14_ProjectileThingType])[(L0697_T_Thing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts) && (AL0699_ui_ChampionOrCreatureOrdinal = L0707_auc_ChampionOrCreatureOrdinalInCell[(L0697_T_Thing).getCell()]) &&
-			_vm->_projexpl->f217_projectileHasImpactOccurred(L0702_i_ImpactType, srcMapX, srcMapY, _vm->M1_ordinalToIndex(AL0699_ui_ChampionOrCreatureOrdinal), L0697_T_Thing)) {
+			_vm->_projexpl->f217_projectileHasImpactOccurred(L0702_i_ImpactType, srcMapX, srcMapY, _vm->ordinalToIndex(AL0699_ui_ChampionOrCreatureOrdinal), L0697_T_Thing)) {
 			_vm->_projexpl->f214_projectileDeleteEvent(L0697_T_Thing);
 			if (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup) {
 				return true;
@@ -635,7 +635,7 @@ T0266017_CheckProjectileImpacts:
 void MovesensMan::f268_addEvent(byte type, byte mapX, byte mapY, byte cell, byte effect, int32 time) {
 	TimelineEvent L0729_s_Event;
 
-	M33_setMapAndTime(L0729_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, time);
+	setMapAndTime(L0729_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, time);
 	L0729_s_Event._type = type;
 	L0729_s_Event._priority = 0;
 	L0729_s_Event._B._location._mapX = mapX;
@@ -710,23 +710,23 @@ int16 MovesensMan::f262_getTeleporterRotatedGroupResult(Teleporter* teleporter,
 	if (L0689_B_AbsoluteRotation) {
 		L0685_ui_UpdatedGroupDirections = L0683_i_Rotation;
 	} else {
-		L0685_ui_UpdatedGroupDirections = M21_normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation);
+		L0685_ui_UpdatedGroupDirections = normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation);
 	}
 
 	L0687_ui_UpdatedGroupCells = _vm->_groupMan->f145_getGroupCells(L0686_ps_Group, mapIndex);
 	if (L0687_ui_UpdatedGroupCells != k255_CreatureTypeSingleCenteredCreature) {
 		L0690_ui_GroupCells = L0687_ui_UpdatedGroupCells;
 		L0691_i_CreatureSize = getFlag(g243_CreatureInfo[L0686_ps_Group->_type]._attributes, k0x0003_MaskCreatureInfo_size);
-		L0692_i_RelativeRotation = M21_normalizeModulo4(4 + L0685_ui_UpdatedGroupDirections - L0684_ui_GroupDirections);
+		L0692_i_RelativeRotation = normalizeModulo4(4 + L0685_ui_UpdatedGroupDirections - L0684_ui_GroupDirections);
 		for (L0688_i_CreatureIndex = 0; L0688_i_CreatureIndex <= L0686_ps_Group->getCount(); L0688_i_CreatureIndex++) {
-			L0685_ui_UpdatedGroupDirections = _vm->_groupMan->f178_getGroupValueUpdatedWithCreatureValue(L0685_ui_UpdatedGroupDirections, L0688_i_CreatureIndex, L0689_B_AbsoluteRotation ? L0683_i_Rotation : M21_normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation));
+			L0685_ui_UpdatedGroupDirections = _vm->_groupMan->f178_getGroupValueUpdatedWithCreatureValue(L0685_ui_UpdatedGroupDirections, L0688_i_CreatureIndex, L0689_B_AbsoluteRotation ? L0683_i_Rotation : normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation));
 			if (L0691_i_CreatureSize == k0_MaskCreatureSizeQuarter) {
 				L0692_i_RelativeRotation = !L0689_B_AbsoluteRotation;
 				if (L0692_i_RelativeRotation) 
 					L0692_i_RelativeRotation = L0683_i_Rotation;
 			}
 			if (L0692_i_RelativeRotation) {
-				L0687_ui_UpdatedGroupCells = _vm->_groupMan->f178_getGroupValueUpdatedWithCreatureValue(L0687_ui_UpdatedGroupCells, L0688_i_CreatureIndex, M21_normalizeModulo4(L0690_ui_GroupCells + L0692_i_RelativeRotation));
+				L0687_ui_UpdatedGroupCells = _vm->_groupMan->f178_getGroupValueUpdatedWithCreatureValue(L0687_ui_UpdatedGroupCells, L0688_i_CreatureIndex, normalizeModulo4(L0690_ui_GroupCells + L0692_i_RelativeRotation));
 			}
 			L0684_ui_GroupDirections >>= 2;
 			L0690_ui_GroupCells >>= 2;
@@ -749,8 +749,8 @@ Thing MovesensMan::f263_getTeleporterRotatedProjectileThing(Teleporter* teleport
 	if (teleporter->getAbsoluteRotation()) {
 		L0693_i_UpdatedDirection = L0694_i_Rotation;
 	} else {
-		L0693_i_UpdatedDirection = M21_normalizeModulo4(L0693_i_UpdatedDirection + L0694_i_Rotation);
-		projectileThing = M15_thingWithNewCell(projectileThing, M21_normalizeModulo4((projectileThing).getCell() + L0694_i_Rotation));
+		L0693_i_UpdatedDirection = normalizeModulo4(L0693_i_UpdatedDirection + L0694_i_Rotation);
+		projectileThing = thingWithNewCell(projectileThing, normalizeModulo4((projectileThing).getCell() + L0694_i_Rotation));
 	}
 	_g400_moveResultDir = L0693_i_UpdatedDirection;
 	return projectileThing;
@@ -798,8 +798,8 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 				L0773_B_SquareContainsGroup = true;
 			} else {
 				if ((L0771_ui_ThingType == k2_TextstringType) && (L0767_i_ThingType == kM1_PartyThingType) && addThing && !partySquare) {
-					_vm->_dungeonMan->f168_decodeText(_vm->_g353_stringBuildBuffer, L0766_T_Thing, k1_TextTypeMessage);
-					_vm->_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, _vm->_g353_stringBuildBuffer);
+					_vm->_dungeonMan->f168_decodeText(_vm->_stringBuildBuffer, L0766_T_Thing, k1_TextTypeMessage);
+					_vm->_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, _vm->_stringBuildBuffer);
 				} else {
 					if ((L0771_ui_ThingType > k4_GroupThingType) && (L0771_ui_ThingType < k14_ProjectileThingType)) {
 						L0772_B_SquareContainsObject = true;
@@ -852,7 +852,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 						if (!addThing) {
 							L0768_B_TriggerSensor = false;
 						} else {
-							L0768_B_TriggerSensor = (L0779_i_SensorData == _vm->M0_indexToOrdinal(_vm->_dungeonMan->_g308_partyDir));
+							L0768_B_TriggerSensor = (L0779_i_SensorData == _vm->indexToOrdinal(_vm->_dungeonMan->_g308_partyDir));
 						}
 					}
 					break;
@@ -988,7 +988,7 @@ void MovesensMan::f272_sensorTriggerEffect(Sensor* sensor, int16 effect, int16 m
 	if (sensor->getOnlyOnce()) {
 		sensor->setTypeDisabled();
 	}
-	L0738_l_Time = _vm->_g313_gameTime + sensor->getValue();
+	L0738_l_Time = _vm->_gameTime + sensor->getValue();
 	if (sensor->getLocalEffect()) {
 		f270_sensorTriggetLocalEffect(sensor->M49_localEffect(), mapX, mapY, cell);
 	} else {
@@ -1074,7 +1074,7 @@ void MovesensMan::f271_processRotationEffect() {
 void MovesensMan::f265_createEvent60to61_moveGroup(Thing groupThing, int16 mapX, int16 mapY, int16 mapIndex, bool audible) {
 	TimelineEvent L0696_s_Event;
 
-	M33_setMapAndTime(L0696_s_Event._mapTime, mapIndex, _vm->_g313_gameTime + 5);
+	setMapAndTime(L0696_s_Event._mapTime, mapIndex, _vm->_gameTime + 5);
 	L0696_s_Event._type = audible ? k61_TMEventTypeMoveGroupAudible : k60_TMEventTypeMoveGroupSilent;
 	L0696_s_Event._priority = 0;
 	L0696_s_Event._B._location._mapX = mapX;
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 7600baf..7eee98a 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -55,13 +55,13 @@ void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16
 	if ((L0466_T_ProjectileThing = _vm->_dungeonMan->f166_getUnusedThing(k14_ProjectileThingType)) == Thing::_none) { /* BUG0_16 If the game cannot create a projectile thing because it has run out of such things (60 maximum) then the object being thrown/shot/launched is orphaned. If the game has run out of projectile things it will try to remove a projectile from elsewhere in the dungeon, except in an area of 11x11 squares centered around the party (to make sure the player cannot actually see the thing disappear on screen) */
 		return;
 	}
-	L0466_T_ProjectileThing = M15_thingWithNewCell(L0466_T_ProjectileThing, cell);
+	L0466_T_ProjectileThing = thingWithNewCell(L0466_T_ProjectileThing, cell);
 	L0467_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(L0466_T_ProjectileThing);
 	L0467_ps_Projectile->_slot = thing;
 	L0467_ps_Projectile->_kineticEnergy = MIN((int16)kineticEnergy, (int16)255);
 	L0467_ps_Projectile->_attack = attack;
 	_vm->_dungeonMan->f163_linkThingToList(L0466_T_ProjectileThing, Thing(0), mapX, mapY); /* Projectiles are added on the square and not 'moved' onto the square. In the case of a projectile launcher sensor, this means that the new projectile traverses the square in front of the launcher without any trouble: there is no impact if it is a wall, the projectile direction is not changed if it is a teleporter. Impacts with creatures and champions are still processed */
-	M33_setMapAndTime(L0468_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + 1);
+	setMapAndTime(L0468_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_gameTime + 1);
 	if (_g365_createLanucherProjectile) {
 		L0468_s_Event._type = k49_TMEventTypeMoveProjectile; /* Launcher projectiles can impact immediately */
 	} else {
@@ -152,7 +152,7 @@ T0217004:
 		L0494_ps_Door = (Door *)_vm->_dungeonMan->f157_getSquareFirstThingData(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY);
 		if ((AL0487_i_DoorState != k5_doorState_DESTROYED) && (L0486_T_ProjectileAssociatedThing == Thing::_explOpenDoor)) {
 			if (L0494_ps_Door->hasButton()) {
-				_vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1);
+				_vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, 0, k2_SensorEffToggle, _vm->_gameTime + 1);
 			}
 			break;
 		}
@@ -321,7 +321,7 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 		L0470_ps_Explosion->setCentered(true);
 	} else {
 		L0470_ps_Explosion->setCentered(false);
-		L0473_T_Thing = M15_thingWithNewCell(L0473_T_Thing, cell);
+		L0473_T_Thing = thingWithNewCell(L0473_T_Thing, cell);
 	}
 	L0470_ps_Explosion->setType(explThing.toUint16() - Thing::_firstExplosion.toUint16());
 	L0470_ps_Explosion->setAttack(attack);
@@ -334,7 +334,7 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 	}
 	_vm->_dungeonMan->f163_linkThingToList(L0473_T_Thing, Thing(0), AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY);
 	TimelineEvent L0476_s_Event;
-	M33_setMapAndTime(L0476_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ((explThing == Thing::_explRebirthStep1) ? 5 : 1));
+	setMapAndTime(L0476_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_gameTime + ((explThing == Thing::_explRebirthStep1) ? 5 : 1));
 	L0476_s_Event._type = k25_TMEventTypeExplosion;
 	L0476_s_Event._priority = 0;
 	L0476_s_Event._C._slot = L0473_T_Thing.toUint16();
@@ -487,13 +487,13 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 	} else {
 		L0518_ui_Cell++;
 	}
-	L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, L0518_ui_Cell &= 0x0003);
+	L0515_T_ProjectileThingNewCell = thingWithNewCell(L0515_T_ProjectileThingNewCell, L0518_ui_Cell &= 0x0003);
 	if (L0522_B_ProjectileMovesToOtherSquare) {
 		_vm->_moveSens->f267_getMoveResult(L0515_T_ProjectileThingNewCell, L0525_i_SourceMapX, L0526_i_SourceMapY, L0523_i_DestinationMapX, L0524_i_DestinationMapY);
 		L0519_ps_Event->_C._projectile.setMapX(_vm->_moveSens->_g397_moveResultMapX);
 		L0519_ps_Event->_C._projectile.setMapY(_vm->_moveSens->_g398_moveResultMapY);
 		L0519_ps_Event->_C._projectile.setDir((Direction)_vm->_moveSens->_g400_moveResultDir);
-		L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_moveSens->_g401_moveResultCell);
+		L0515_T_ProjectileThingNewCell = thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_moveSens->_g401_moveResultCell);
 		M31_setMap(L0519_ps_Event->_mapTime, _vm->_moveSens->_g399_moveResultMapIndex);
 	} else {
 		if ((Square(_vm->_dungeonMan->f151_getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY)).getType() == k4_DoorElemType) && f217_projectileHasImpactOccurred(k4_DoorElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp
index fe53f11..e0bef37 100644
--- a/engines/dm/sounds.cpp
+++ b/engines/dm/sounds.cpp
@@ -203,7 +203,7 @@ void SoundMan::f064_SOUND_RequestPlay_CPSD(uint16 soundIndex, int16 mapX, int16
 	sound = &g60_sounds[soundIndex];
 	if (mode > k1_soundModePlayIfPrioritized) { /* Add an event in the timeline to play the sound (mode - 1) ticks later */
 		TimelineEvent event;
-		M33_setMapAndTime(event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + mode - 1);
+		setMapAndTime(event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_gameTime + mode - 1);
 		event._type = k20_TMEventTypePlaySound;
 		event._priority = sound->_priority;
 		event._C._soundIndex = soundIndex;
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 1fe6a49..bae4661 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -165,7 +165,7 @@ void TextMan::f46_messageAreaPrintString(Color color, const char* string) {
 			f560_SCROLLER_setCommand(&_gK60_s_TextScroller, 1);
 	}
 	_g359_messageAreaCursorColumn += L0030_i_StringLength;
-	_g360_messageAreaRowExpirationTime[_g358_messageAreaCursorRow] = _vm->_g313_gameTime + 200;
+	_g360_messageAreaRowExpirationTime[_g358_messageAreaCursorRow] = _vm->_gameTime + 200;
 
 }
 
@@ -204,7 +204,7 @@ void TextMan::f44_messageAreaClearExpiredRows() {
 	L0028_s_Box._x2 = 319;
 	for (L0026_ui_RowIndex = 0; L0026_ui_RowIndex < 4; L0026_ui_RowIndex++) {
 		L0027_l_ExpirationTime = _g360_messageAreaRowExpirationTime[L0026_ui_RowIndex];
-		if ((L0027_l_ExpirationTime == -1) || (L0027_l_ExpirationTime > _vm->_g313_gameTime))
+		if ((L0027_l_ExpirationTime == -1) || (L0027_l_ExpirationTime > _vm->_gameTime))
 			continue;
 		L0028_s_Box._y2 = (L0028_s_Box._y1 = 172 + (L0026_ui_RowIndex * 7)) + 6;
 		f561_isTextScrolling(&_gK60_s_TextScroller, true);
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 27f58c9..27ea5e4 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -102,7 +102,7 @@ Timeline::~Timeline() {
 void Timeline::f233_initTimeline() {
 	_g370_events = new TimelineEvent[_g369_eventMaxCount];
 	_g371_timeline = new uint16[_g369_eventMaxCount];
-	if (_vm->_g298_newGame) {
+	if (_vm->_newGameFl) {
 		for (int16 i = 0; i < _g369_eventMaxCount; ++i)
 			_g370_events[i]._type = k0_TMEventTypeNone;
 		_g372_eventCount = 0;
@@ -177,8 +177,8 @@ T0236011:
 bool Timeline::f234_isEventABeforeB(TimelineEvent* eventA, TimelineEvent* eventB) {
 	bool L0578_B_Simultaneous;
 
-	return (M30_time(eventA->_mapTime) < M30_time(eventB->_mapTime)) ||
-		((L0578_B_Simultaneous = (M30_time(eventA->_mapTime) == M30_time(eventB->_mapTime))) && (eventA->getTypePriority() > eventB->getTypePriority())) ||
+	return (filterTime(eventA->_mapTime) < filterTime(eventB->_mapTime)) ||
+		((L0578_B_Simultaneous = (filterTime(eventA->_mapTime) == filterTime(eventB->_mapTime))) && (eventA->getTypePriority() > eventB->getTypePriority())) ||
 		(L0578_B_Simultaneous && (eventA->getTypePriority() == eventB->getTypePriority()) && (eventA <= eventB));
 }
 
@@ -204,7 +204,7 @@ uint16 Timeline::f238_addEventGetEventIndex(TimelineEvent* event) {
 
 
 	if (_g372_eventCount == _g369_eventMaxCount) {
-		_vm->f19_displayErrorAndStop(45);
+		_vm->displayErrorAndStop(45);
 	}
 	if ((event->_type >= k5_TMEventTypeCorridor) && (event->_type <= k10_TMEventTypeDoor)) {
 		for (L0588_ui_EventIndex = 0, L0591_ps_Event = _g370_events; L0588_ui_EventIndex < _g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
@@ -243,7 +243,7 @@ uint16 Timeline::f238_addEventGetEventIndex(TimelineEvent* event) {
 		} else {
 			if (event->_type == k2_TMEventTypeDoorDestruction) {
 				for (L0588_ui_EventIndex = 0, L0591_ps_Event = _g370_events; L0588_ui_EventIndex < _g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
-					if ((event->getMapXY() == L0591_ps_Event->getMapXY()) && (M29_map(event->_mapTime) == M29_map(L0591_ps_Event->_mapTime))) {
+					if ((event->getMapXY() == L0591_ps_Event->getMapXY()) && (getMap(event->_mapTime) == getMap(L0591_ps_Event->_mapTime))) {
 						if ((L0591_ps_Event->_type == k1_TMEventTypeDoorAnimation) || (L0591_ps_Event->_type == k10_TMEventTypeDoor)) {
 							f237_deleteEvent(L0588_ui_EventIndex);
 						}
@@ -274,7 +274,7 @@ void Timeline::f261_processTimeline() {
 	while (f240_isFirstEventExpiered()) {
 		L0681_ps_Event = &L0682_s_Event;
 		f239_timelineExtractFirstEvent(L0681_ps_Event);
-		_vm->_dungeonMan->f173_setCurrentMap(M29_map(L0682_s_Event._mapTime));
+		_vm->_dungeonMan->f173_setCurrentMap(getMap(L0682_s_Event._mapTime));
 		AL0680_ui_EventType = L0682_s_Event._type;
 		if ((AL0680_ui_EventType > (k29_TMEventTypeGroupReactionDangerOnSquare - 1)) && (AL0680_ui_EventType < (k41_TMEventTypeUpdateBehaviour_3 + 1))) {
 			_vm->_groupMan->f209_processEvents29to41(L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, AL0680_ui_EventType, L0682_s_Event._C._ticks);
@@ -322,7 +322,7 @@ void Timeline::f261_processTimeline() {
 				_vm->_sound->f064_SOUND_RequestPlay_CPSD(L0682_s_Event._C._soundIndex, L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, k1_soundModePlayIfPrioritized);
 				break;
 			case k24_TMEventTypeRemoveFluxcage:
-				if (!_vm->_g302_gameWon) {
+				if (!_vm->_gameWon) {
 					_vm->_dungeonMan->f164_unlinkThingFromList(Thing(L0682_s_Event._C._slot), Thing(0), L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY);
 					L0681_ps_Event = (TimelineEvent*)_vm->_dungeonMan->f156_getThingData(Thing(L0682_s_Event._C._slot));
 					((Explosion*)L0681_ps_Event)->setNextThing(Thing::_none);
@@ -331,7 +331,7 @@ void Timeline::f261_processTimeline() {
 			case k11_TMEventTypeEnableChampionAction:
 				f253_timelineProcessEvent11Part1_enableChampionAction(L0682_s_Event._priority);
 				if (L0682_s_Event._B._slotOrdinal) {
-					f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(L0682_s_Event._priority, _vm->M1_ordinalToIndex(L0682_s_Event._B._slotOrdinal));
+					f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(L0682_s_Event._priority, _vm->ordinalToIndex(L0682_s_Event._B._slotOrdinal));
 				}
 				goto T0261048;
 			case k12_TMEventTypeHideDamageReceived:
@@ -381,7 +381,7 @@ T0261053:
 }
 
 bool Timeline::f240_isFirstEventExpiered() {
-	return (_g372_eventCount && (M30_time(_g370_events[_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime));
+	return (_g372_eventCount && (filterTime(_g370_events[_g371_timeline[0]]._mapTime) <= _vm->_gameTime));
 }
 
 void Timeline::f239_timelineExtractFirstEvent(TimelineEvent* event) {
@@ -583,7 +583,7 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 			L0647_ps_Event->_C._projectile.setMapX(_vm->_moveSens->_g397_moveResultMapX);
 			L0647_ps_Event->_C._projectile.setMapY(_vm->_moveSens->_g398_moveResultMapY);
 			L0647_ps_Event->_C._projectile.setDir((Direction)_vm->_moveSens->_g400_moveResultDir);
-			L0647_ps_Event->_B._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_moveSens->_g401_moveResultCell).toUint16();
+			L0647_ps_Event->_B._slot = thingWithNewCell(L0645_T_Thing, _vm->_moveSens->_g401_moveResultCell).toUint16();
 			M31_setMap(L0647_ps_Event->_mapTime, _vm->_moveSens->_g399_moveResultMapIndex);
 		} else {
 			if (AL0644_ui_ThingType == k15_ExplosionThingType) {
@@ -591,7 +591,7 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 					if ((L0647_ps_Event->_type == k25_TMEventTypeExplosion) && (L0647_ps_Event->_C._slot == L0645_T_Thing.toUint16())) { /* BUG0_23 A Fluxcage explosion remains on a square forever. If you open a pit or teleporter on a square where there is a Fluxcage explosion, the Fluxcage explosion is moved but the associated event is not updated (because Fluxcage explosions do not use k25_TMEventTypeExplosion but rather k24_TMEventTypeRemoveFluxcage) causing the Fluxcage explosion to remain in the dungeon forever on its destination square. When the k24_TMEventTypeRemoveFluxcage expires the explosion thing is not removed, but it is marked as unused. Consequently, any objects placed on the Fluxcage square after it was moved but before it expires become orphans upon expiration. After expiration, any object placed on the fluxcage square is cloned when picked up */
 						L0647_ps_Event->_B._location._mapX = _vm->_moveSens->_g397_moveResultMapX;
 						L0647_ps_Event->_B._location._mapY = _vm->_moveSens->_g398_moveResultMapY;
-						L0647_ps_Event->_C._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_moveSens->_g401_moveResultCell).toUint16();
+						L0647_ps_Event->_C._slot = thingWithNewCell(L0645_T_Thing, _vm->_moveSens->_g401_moveResultCell).toUint16();
 						M31_setMap(L0647_ps_Event->_mapTime, _vm->_moveSens->_g399_moveResultMapIndex);
 					}
 				}
@@ -701,10 +701,10 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
 							}
 						} else {
 							if (L0640_ui_SensorType == k18_SensorWallEndGame) {
-								_vm->f22_delay(60 * L0638_ps_Sensor->getValue());
-								_vm->_g524_restartGameAllowed = false;
-								_vm->_g302_gameWon = true;
-								_vm->f444_endGame(true);
+								_vm->delay(60 * L0638_ps_Sensor->getValue());
+								_vm->_restartGameAllowed = false;
+								_vm->_gameWon = true;
+								_vm->endGame(true);
 							}
 						}
 					}
@@ -781,7 +781,7 @@ void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* eve
 		}
 	}
 	if (L0632_B_LaunchSingleProjectile) {
-		L0628_ui_ProjectileCell = M21_normalizeModulo4(L0628_ui_ProjectileCell + _vm->getRandomNumber(2));
+		L0628_ui_ProjectileCell = normalizeModulo4(L0628_ui_ProjectileCell + _vm->getRandomNumber(2));
 	}
 	L0626_i_MapX += _vm->_dirIntoStepCountEast[L0624_ui_Cell], L0627_i_MapY += _vm->_dirIntoStepCountNorth[L0624_ui_Cell]; /* BUG0_20 The game crashes if the launcher sensor is on a map boundary and shoots in a direction outside the map */
 	_vm->_projexpl->_g365_createLanucherProjectile = true;
@@ -821,8 +821,8 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 				L0615_ps_TextString->setVisible((event->_C.A._effect == k0_SensorEffSet));
 			}
 			if (!L0611_B_TextCurrentlyVisible && L0615_ps_TextString->isVisible() && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0616_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0617_ui_MapY == _vm->_dungeonMan->_g307_partyMapY)) {
-				_vm->_dungeonMan->f168_decodeText(_vm->_g353_stringBuildBuffer, L0613_T_Thing, k1_TextTypeMessage);
-				_vm->_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, _vm->_g353_stringBuildBuffer);
+				_vm->_dungeonMan->f168_decodeText(_vm->_stringBuildBuffer, L0613_T_Thing, k1_TextTypeMessage);
+				_vm->_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, _vm->_stringBuildBuffer);
 			}
 		} else {
 			if (L0610_i_ThingType == k3_SensorThingType) {
@@ -850,7 +850,7 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 								AL0618_ui_Ticks = (AL0618_ui_Ticks - 126) << 6;
 							}
 							L0619_s_Event._type = k65_TMEventTypeEnableGroupGenerator;
-							M33_setMapAndTime(L0619_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + AL0618_ui_Ticks);
+							setMapAndTime(L0619_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_gameTime + AL0618_ui_Ticks);
 							L0619_s_Event._priority = 0;
 							L0619_s_Event._B._location._mapX = L0616_ui_MapX;
 							L0619_s_Event._B._location._mapY = L0617_ui_MapY;
@@ -991,7 +991,7 @@ void Timeline::f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex)
 	if (!L0663_ps_Champion->_currHealth) {
 		return;
 	}
-	if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+	if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 		_vm->_eventMan->f78_showMouse();
 		_vm->_inventoryMan->f354_drawStatusBoxPortrait((ChampionIndex)champIndex);
 		_vm->_eventMan->f77_hideMouse();
@@ -1029,7 +1029,7 @@ void Timeline::f257_timelineProcessEvent70_light(TimelineEvent* event) {
 	if (L0673_i_WeakerLightPower) {
 		L0676_s_Event._type = k70_TMEventTypeLight;
 		L0676_s_Event._B._lightPower = L0673_i_WeakerLightPower;
-		M33_setMapAndTime(L0676_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 4);
+		setMapAndTime(L0676_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + 4);
 		L0676_s_Event._priority = 0;
 		f238_addEventGetEventIndex(&L0676_s_Event);
 	}


Commit: 544ce3578b9c190169d85cfa9ab2c0138684b525
    https://github.com/scummvm/scummvm/commit/544ce3578b9c190169d85cfa9ab2c0138684b525
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: rename members of dungeonman

Changed paths:
    engines/dm/dungeonman.h
    engines/dm/group.cpp
    engines/dm/menus.cpp
    engines/dm/projexpl.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 269dcdf..ce90dc1 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -173,8 +173,6 @@ enum SquareAspectIndice {
 	k0x8000_FootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS             
 };
 
-
-
 #define k15_immuneToFire 15 // @ C15_IMMUNE_TO_FIRE   
 #define k15_immuneToPoison 15 // @ C15_IMMUNE_TO_POISON 
 
@@ -198,15 +196,15 @@ public:
 	uint16 _woundProbabilities; /* Contains 4 probabilities to wound a champion's Head (Bits 15-12), Legs (Bits 11-8), Torso (Bits 7-4) and Feet (Bits 3-0) */
 	byte _attackType;
 
-	uint16 M57_getFearResistance() { return (_properties >> 4) & 0xF; }
-	uint16 M58_getExperience() { return (_properties >> 8) & 0xF; }
-	uint16 M59_getWariness() { return (_properties >> 12) & 0xF; }
-	uint16 M60_getFireResistance() { return (_resistances >> 4) & 0xF; }
-	uint16 M61_poisonResistance() { return (_resistances >> 8) & 0xF; }
-	static uint16 M51_height(uint16 attrib) { return (attrib >> 7) & 0x3; }
-	uint16 M54_getSightRange() { return (_ranges) & 0xF; }
-	uint16 M55_getSmellRange() { return  (_ranges >> 8) & 0xF; }
-	uint16 M56_getAttackRange() { return (_ranges >> 12) & 0xF; }
+	uint16 getFearResistance() { return (_properties >> 4) & 0xF; }
+	uint16 getExperience() { return (_properties >> 8) & 0xF; }
+	uint16 getWariness() { return (_properties >> 12) & 0xF; }
+	uint16 getFireResistance() { return (_resistances >> 4) & 0xF; }
+	uint16 getPoisonResistance() { return (_resistances >> 8) & 0xF; }
+	static uint16 getHeight(uint16 attrib) { return (attrib >> 7) & 0x3; }
+	uint16 getSightRange() { return (_ranges) & 0xF; }
+	uint16 getSmellRange() { return  (_ranges >> 8) & 0xF; }
+	uint16 getAttackRange() { return (_ranges >> 12) & 0xF; }
 }; // @ CREATURE_INFO
 
 
@@ -231,7 +229,6 @@ enum TeleporterScope {
 	k0x0002_TelepScopeObjOrParty = 2 // @ MASK0x0002_SCOPE_OBJECTS_OR_PARTY
 };
 
-
 class Teleporter {
 	Thing _nextThing;
 	uint16 _attributes;
@@ -248,8 +245,6 @@ public:
 	uint16 getTargetMapIndex() { return _destMapIndex >> 8; }
 }; // @ TELEPORTER
 
-
-
 class TextString {
 	Thing _nextThing;
 	uint16 _textDataRef;
@@ -320,8 +315,6 @@ public:
 	void setData(uint16 dat) { _datAndType = dat; } // @ M41_SET_DATA
 	void setTypeDisabled() { _datAndType &= 0xFF80; } // @ M44_SET_TYPE_DISABLED
 
-
-
 	bool getOnlyOnce() { return (_attributes >> 2) & 1; }
 	uint16 getEffectA() { return (_attributes >> 3) & 0x3; }
 	bool getRevertEffectA() { return (_attributes >> 5) & 0x1; }
@@ -333,7 +326,7 @@ public:
 	uint16 getTargetMapY() { return (_action >> 11); }
 	uint16 getTargetMapX() { return (_action >> 6) & 0x1F; }
 	Direction getTargetCell() { return (Direction)((_action >> 4) & 3); }
-	uint16 M45_healthMultiplier() { return ((_action >> 4) & 0xF); } // @ M45_HEALTH_MULTIPLIER
+	uint16 getHealthMultiplier() { return ((_action >> 4) & 0xF); } // @ M45_HEALTH_MULTIPLIER
 	uint16 M46_ticks() { return ((_action >> 4) >> 4) & 0xFFF; } // @ M46_TICKS
 	uint16 M47_kineticEnergy() { return ((_action >> 4) & 0xFF); }// @ M47_KINETIC_ENERGY
 	uint16 M48_stepEnergy() { return ((_action >> 4) >> 8) & 0xFF; }// @ M48_STEP_ENERGY
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 14b2a44..18af098 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -466,7 +466,7 @@ int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group *group, uint16 creature
 					}
 					L0377_ps_Event++;
 				}
-				if (L0383_B_CurrentMapIsPartyMap && ((AL0380_ui_FearResistance = L0376_ps_CreatureInfo->M57_getFearResistance()) != k15_immuneToFear) && ((AL0380_ui_FearResistance += L0379_ui_CreatureCount - 1) < (_vm->getRandomNumber(16)))) { /* Test if the death of a creature frigthens the remaining creatures in the group */
+				if (L0383_B_CurrentMapIsPartyMap && ((AL0380_ui_FearResistance = L0376_ps_CreatureInfo->getFearResistance()) != k15_immuneToFear) && ((AL0380_ui_FearResistance += L0379_ui_CreatureCount - 1) < (_vm->getRandomNumber(16)))) { /* Test if the death of a creature frigthens the remaining creatures in the group */
 					L0378_ps_ActiveGroup->_delayFleeingFromTarget = _vm->getRandomNumber(100 - (AL0380_ui_FearResistance << 2)) + 20;
 					group->setBehaviour(k5_behavior_FLEE);
 				}
@@ -583,7 +583,7 @@ int16 GroupMan::f192_groupGetResistanceAdjustedPoisonAttack(uint16 creatreType,
 	int16 L0390_i_PoisonResistance;
 
 
-	if (!poisonAttack || ((L0390_i_PoisonResistance = g243_CreatureInfo[creatreType].M61_poisonResistance()) == k15_immuneToPoison)) {
+	if (!poisonAttack || ((L0390_i_PoisonResistance = g243_CreatureInfo[creatreType].getPoisonResistance()) == k15_immuneToPoison)) {
 		return 0;
 	}
 	return ((poisonAttack + _vm->getRandomNumber(4)) << 3) / ++L0390_i_PoisonResistance;
@@ -775,7 +775,7 @@ T0209005_AddEventAndReturn:
 			if ((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k2_behavior_USELESS) || (AL0447_i_Behavior == k3_behavior_USELESS)) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */
 				L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY);
 				if (L0452_i_DistanceToVisibleParty) {
-					if ((L0452_i_DistanceToVisibleParty <= (L0448_s_CreatureInfo.M56_getAttackRange())) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) { /* If the creature is in range for attack and on the same row or column as the party on the map */
+					if ((L0452_i_DistanceToVisibleParty <= (L0448_s_CreatureInfo.getAttackRange())) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) { /* If the creature is in range for attack and on the same row or column as the party on the map */
 T0209044_SetBehavior6_Attack:
 						if (eventType == kM2_TMEventTypeCreateReactionEvent30HitByProjectile) {
 							f181_groupDeleteEvents(eventMapX, eventMapY);
@@ -865,7 +865,7 @@ T0209061_MoveGroup:
 							_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0454_i_PrimaryDirectionToOrFromParty = _vm->getRandomNumber(4));
 							goto T0209089_DoubleSquareMove; /* BUG0_69 Memory corruption when you close a door on Lord Chaos. The local variable (L0454_i_PrimaryDirectionToOrFromParty) containing the direction where Lord Chaos tries to move may be used as an array index without being initialized and cause memory corruption */
 						}
-						if (L0453_B_NewGroupDirectionFound || ((!_vm->getRandomNumber(4) || (L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.M55_getSmellRange())) && (eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare))) {
+						if (L0453_B_NewGroupDirectionFound || ((!_vm->getRandomNumber(4) || (L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.getSmellRange())) && (eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare))) {
 T0209073_SetDirectionGroup:
 							if (!L0453_B_NewGroupDirectionFound && (L0462_i_TicksSinceLastMove >= 0)) { /* If direction is not found yet then look around in a random direction */
 								AL0446_i_Direction = _vm->getRandomNumber(4);
@@ -887,7 +887,7 @@ T0209073_SetDirectionGroup:
 				if (AL0447_i_Behavior == k7_behavior_APPROACH) {
 					L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY);
 					if (L0452_i_DistanceToVisibleParty) {
-						if ((L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.M56_getAttackRange()) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) /* If the creature is in range for attack and on the same row or column as the party on the map */
+						if ((L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.getAttackRange()) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) /* If the creature is in range for attack and on the same row or column as the party on the map */
 							goto T0209044_SetBehavior6_Attack;
 T0209081_RunTowardParty:
 						L0461_i_MovementTicks++;
@@ -1017,7 +1017,7 @@ T0209096_SetBehavior0_Wander:
 					(getFlag(L0448_s_CreatureInfo._attributes, k0x0004_MaskCreatureInfo_sideAttack) ||
 					 M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) == L0454_i_PrimaryDirectionToOrFromParty)) {
 					/* If the creature is in range to attack the party and random test succeeds */
-					if ((L0452_i_DistanceToVisibleParty <= (AL0446_i_Range = L0448_s_CreatureInfo.M56_getAttackRange())) &&
+					if ((L0452_i_DistanceToVisibleParty <= (AL0446_i_Range = L0448_s_CreatureInfo.getAttackRange())) &&
 						(!AL0450_i_DistanceXToParty || !AL0451_i_DistanceYToParty) &&
 						(AL0446_i_Range <= (_vm->getRandomNumber(16) + 1))) {
 						if ((AL0446_i_Range == 1) &&
@@ -1141,7 +1141,7 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 			L0433_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0433_T_Thing);
 		}
 	}
-	if ((L0431_i_SquareType == k5_ElementTypeTeleporter) && getFlag(L0430_ui_Square, k0x0008_TeleporterOpen) && (creatureInfo->M59_getWariness() >= 10)) {
+	if ((L0431_i_SquareType == k5_ElementTypeTeleporter) && getFlag(L0430_ui_Square, k0x0008_TeleporterOpen) && (creatureInfo->getWariness() >= 10)) {
 		L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
 		if (getFlag(L0432_ps_Teleporter->getScope(), k0x0001_TelepScopeCreatures) && !_vm->_dungeonMan->f139_isCreatureAllowedOnMap(_g380_currGroupThing, L0432_ps_Teleporter->getTargetMapIndex())) {
 			_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
@@ -1155,7 +1155,7 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 
 	if (L0431_i_SquareType == k4_DoorElemType) {
 		L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
-		if (((Square(L0430_ui_Square).getDoorState()) > (((Door *)L0432_ps_Teleporter)->opensVertically() ? CreatureInfo::M51_height(creatureInfo->_attributes) : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
+		if (((Square(L0430_ui_Square).getDoorState()) > (((Door *)L0432_ps_Teleporter)->opensVertically() ? CreatureInfo::getHeight(creatureInfo->_attributes) : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
 			_g389_groupMovementBlockedByDoor = true;
 			return false;
 		}
@@ -1206,7 +1206,7 @@ T0200006:
 	while (L0421_i_CreatureViewDirectionCount--) {
 		if (f227_isDestVisibleFromSource(L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount], mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY)) {
 T0200011:
-			AL0422_i_SightRange = L0424_ps_CreatureInfo->M54_getSightRange();
+			AL0422_i_SightRange = L0424_ps_CreatureInfo->getSightRange();
 			if (!getFlag(L0424_ps_CreatureInfo->_attributes, k0x1000_MaskCreatureInfo_nightVision)) {
 				AL0422_i_SightRange -= _vm->_displayMan->_g304_dungeonViewPaletteIndex >> 1;
 			}
@@ -1395,7 +1395,7 @@ int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo
 	int16 L0427_i_ScentOrdinal;
 
 
-	if (!(L0426_ui_SmellRange = creatureInfo->M55_getSmellRange())) {
+	if (!(L0426_ui_SmellRange = creatureInfo->getSmellRange())) {
 		return 0;
 	}
 	if ((((L0426_ui_SmellRange + 1) >> 1) >= _g381_currGroupDistanceToParty) && f199_getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f198_isSmellPartyBlocked)) {
@@ -1482,7 +1482,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 	}
 	AL0439_i_TargetCell += L0438_ui_PrimaryDirectionToParty;
 	AL0439_i_TargetCell &= 0x0003;
-	if ((L0441_ps_CreatureInfo->M56_getAttackRange() > 1) && ((_g381_currGroupDistanceToParty > 1) || _vm->getRandomNumber(2))) {
+	if ((L0441_ps_CreatureInfo->getAttackRange() > 1) && ((_g381_currGroupDistanceToParty > 1) || _vm->getRandomNumber(2))) {
 		switch (AL0437_ui_CreatureType) {
 		case k14_CreatureTypeVexirk:
 		case k23_CreatureTypeLordChaos:
@@ -1651,7 +1651,7 @@ int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) {
 	}
 	L0563_i_DoubledMapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty << 1;
 	L0564_s_CreatureInfo = g243_CreatureInfo[group->_type];
-	_vm->_championMan->addSkillExperience(champIndex, k7_ChampionSkillParry, L0564_s_CreatureInfo.M58_getExperience());
+	_vm->_championMan->addSkillExperience(champIndex, k7_ChampionSkillParry, L0564_s_CreatureInfo.getExperience());
 	if (_vm->_championMan->_partyIsSleeping || (((_vm->_championMan->getDexterity(L0562_ps_Champion) < (_vm->getRandomNumber(32) + L0564_s_CreatureInfo._dexterity + L0563_i_DoubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !_vm->_championMan->isLucky(L0562_ps_Champion, 60))) {
 		if ((AL0559_ui_WoundTest = _vm->getRandomNumber(65536)) & 0x0070) {
 			AL0559_ui_WoundTest &= 0x000F;
@@ -1954,7 +1954,7 @@ T0231009:
 			L0565_i_Damage += L0565_i_Damage + 10;
 		}
 		L0569_i_Outcome = f190_groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapY, L0565_i_Damage, true);
-		_vm->_championMan->addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * L0572_ps_CreatureInfo->M58_getExperience() >> 4) + 3);
+		_vm->_championMan->addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * L0572_ps_CreatureInfo->getExperience() >> 4) + 3);
 		_vm->_championMan->decrementStamina(champIndex, _vm->getRandomNumber(4) + 4);
 		goto T0231016;
 	}
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index e49c4ce..d2cddf6 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -1537,7 +1537,7 @@ bool MenuMan::f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionInde
 	L1229_i_FrightAmount += _vm->_championMan->getSkillLevel(champIndex, k14_ChampionSkillInfluence);
 	L1233_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing);
 	L1234_ps_CreatureInfo = &g243_CreatureInfo[L1233_ps_Group->_type];
-	if (((L1230_ui_FearResistance = L1234_ps_CreatureInfo->M57_getFearResistance()) > _vm->getRandomNumber(L1229_i_FrightAmount)) || (L1230_ui_FearResistance == k15_immuneToFear)) {
+	if (((L1230_ui_FearResistance = L1234_ps_CreatureInfo->getFearResistance()) > _vm->getRandomNumber(L1229_i_FrightAmount)) || (L1230_ui_FearResistance == k15_immuneToFear)) {
 		L1231_ui_Experience >>= 1;
 	} else {
 		L1235_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[L1233_ps_Group->getActiveGroupIndex()];
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 7eee98a..bc0c1a9 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -353,7 +353,7 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 				if ((L0473_T_Thing = _vm->_groupMan->f175_groupGetThing(AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY)) != Thing::_endOfList) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
 					Group *L0472_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0473_T_Thing);
 					CreatureInfo *L0471_ps_CreatureInfo = &g243_CreatureInfo[L0472_ps_Group->_type];
-					int16 L0469_i_CreatureFireResistance = L0471_ps_CreatureInfo->M60_getFireResistance();
+					int16 L0469_i_CreatureFireResistance = L0471_ps_CreatureInfo->getFireResistance();
 					if (L0469_i_CreatureFireResistance != k15_immuneToFire) {
 						if (getFlag(L0471_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
 							attack >>= 2;
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 27ea5e4..45ca771 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -429,7 +429,7 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 			return;
 		}
 		if (((L0599_T_GroupThing = _vm->_groupMan->f175_groupGetThing(L0593_ui_MapX, L0594_ui_MapY)) != Thing::_endOfList) && !getFlag(L0600_ui_CreatureAttributes = _vm->_dungeonMan->f144_getCreatureAttributes(L0599_T_GroupThing), k0x0040_MaskCreatureInfo_nonMaterial)) {
-			if (L0596_i_DoorState >= (AL0602_ui_Height ? CreatureInfo::M51_height(L0600_ui_CreatureAttributes) : 1)) { /* Creature height or 1 */
+			if (L0596_i_DoorState >= (AL0602_ui_Height ? CreatureInfo::getHeight(L0600_ui_CreatureAttributes) : 1)) { /* Creature height or 1 */
 				if (_vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group*)_vm->_dungeonMan->f156_getThingData(L0599_T_GroupThing), L0593_ui_MapX, L0594_ui_MapY, 5, true) != k2_outcomeKilledAllCreaturesInGroup) {
 					_vm->_groupMan->f209_processEvents29to41(L0593_ui_MapX, L0594_ui_MapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
 				}
@@ -834,7 +834,8 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 					} else {
 						L0612_i_CreatureCount--;
 					}
-					if ((AL0618_ui_HealthMultiplier = L0614_ps_Sensor->M45_healthMultiplier()) == 0) {
+					AL0618_ui_HealthMultiplier = L0614_ps_Sensor->getHealthMultiplier();
+					if (AL0618_ui_HealthMultiplier == 0) {
 						AL0618_ui_HealthMultiplier = _vm->_dungeonMan->_g269_currMap->_difficulty;
 					}
 					_vm->_groupMan->f185_groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (Direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY);
@@ -844,7 +845,8 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 					if (L0614_ps_Sensor->getOnlyOnce()) {
 						L0614_ps_Sensor->setTypeDisabled();
 					} else {
-						if ((AL0618_ui_Ticks = L0614_ps_Sensor->M46_ticks()) != 0) {
+						AL0618_ui_Ticks = L0614_ps_Sensor->M46_ticks();
+						if (AL0618_ui_Ticks != 0) {
 							L0614_ps_Sensor->setTypeDisabled();
 							if (AL0618_ui_Ticks > 127) {
 								AL0618_ui_Ticks = (AL0618_ui_Ticks - 126) << 6;
@@ -871,7 +873,6 @@ void Timeline::f252_timelineProcessEvents60to61_moveGroup(TimelineEvent* event)
 	Group* L0658_ps_Group;
 	bool L0659_B_RandomDirectionMoveRetried;
 
-
 	L0659_B_RandomDirectionMoveRetried = false;
 	L0656_ui_MapX = event->_B._location._mapX;
 	L0657_ui_MapY = event->_B._location._mapY;


Commit: 64b1c4fdf11001acc442fea7367b11f45336b25f
    https://github.com/scummvm/scummvm/commit/64b1c4fdf11001acc442fea7367b11f45336b25f
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rename DungeonMan class members

Changed paths:
    engines/dm/champion.cpp
    engines/dm/console.cpp
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/objectman.cpp
    engines/dm/projexpl.cpp
    engines/dm/sounds.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index b6bcdf2..f9adcc7 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -217,14 +217,14 @@ bool ChampionMan::isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side)
 			return false;
 	}
 
-	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 	decrementStamina(champIndex, getThrowingStaminaCost(curThing));
 	disableAction(champIndex, 4);
 	int16 experience = 8;
 	int16 weaponKineticEnergy = 1;
 	if (curThing.getType() == k5_WeaponThingType) {
 		experience += 4;
-		WeaponInfo *curWeapon = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
+		WeaponInfo *curWeapon = _vm->_dungeonMan->getWeaponInfo(curThing);
 		if (curWeapon->_class <= k12_WeaponClassPoisinDart) {
 			weaponKineticEnergy = curWeapon->_kineticEnergy;
 			experience += weaponKineticEnergy >> 2;
@@ -236,11 +236,11 @@ bool ChampionMan::isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side)
 	kineticEnergy += _vm->getRandomNumber(16) + (kineticEnergy >> 1) + skillLevel;
 	int16 attack = getBoundedValue((uint16)40, (uint16)((skillLevel << 3) + _vm->getRandomNumber(32)), (uint16)200);
 	int16 stepEnergy = MAX(5, 11 - skillLevel);
-	_vm->_projexpl->f212_projectileCreate(curThing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY,
-										  normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + side),
-										  _vm->_dungeonMan->_g308_partyDir, kineticEnergy, attack, stepEnergy);
+	_vm->_projexpl->f212_projectileCreate(curThing, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY,
+										  normalizeModulo4(_vm->_dungeonMan->_partyDir + side),
+										  _vm->_dungeonMan->_partyDir, kineticEnergy, attack, stepEnergy);
 	_vm->_projectileDisableMovementTicks = 4;
-	_vm->_lastProjectileDisabledMovementDirection = _vm->_dungeonMan->_g308_partyDir;
+	_vm->_lastProjectileDisabledMovementDirection = _vm->_dungeonMan->_partyDir;
 	drawChampionState((ChampionIndex)champIndex);
 	return true;
 }
@@ -295,11 +295,11 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 	if (((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType))
 		&& (slotIndex >= k0_ChampionSlotReadyHand) && (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) {
 		if (thingType == k5_WeaponThingType) {
-			Weapon *weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(thing);
+			Weapon *weapon = (Weapon *)_vm->_dungeonMan->getThingData(thing);
 			cursed = weapon->getCursed();
 		} else {
 			// k6_ArmourThingType
-			Armour *armour = (Armour *)_vm->_dungeonMan->f156_getThingData(thing);
+			Armour *armour = (Armour *)_vm->_dungeonMan->getThingData(thing);
 			cursed = armour->getCursed();
 		}
 
@@ -537,12 +537,12 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 		champ->setSlot(slotIndex, thing);
 	}
 
-	champ->_load += dunMan.f140_getObjectWeight(thing);
+	champ->_load += dunMan.getObjectWeight(thing);
 	champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
 	IconIndice iconIndex = objMan.f33_getIconIndex(thing);
 	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal);
 	applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
-	uint16 *rawObjPtr = dunMan.f156_getThingData(thing);
+	uint16 *rawObjPtr = dunMan.getThingData(thing);
 
 	if (slotIndex < k2_ChampionSlotHead) {
 		if (slotIndex == k1_ChampionSlotActionHand) {
@@ -588,7 +588,7 @@ int16 ChampionMan::getScentOrdinal(int16 mapX, int16 mapY) {
 		Scent searchedScent;
 		searchedScent.setMapX(mapX);
 		searchedScent.setMapY(mapY);
-		searchedScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex);
+		searchedScent.setMapIndex(_vm->_dungeonMan->_currMapIndex);
 		uint16 searchedScentRedEagle = searchedScent.toUint16();
 		Scent *scent = &_party._scents[scentIndex--];
 		do {
@@ -612,7 +612,7 @@ Thing ChampionMan::getObjectRemovedFromLeaderHand() {
 		_vm->_eventMan->f69_setMousePointer();
 		_vm->_eventMan->f77_hideMouse();
 		if (_leaderIndex != kM1_ChampionNone) {
-			_champions[_leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(leaderHandObject);
+			_champions[_leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(leaderHandObject);
 			setFlag(_champions[_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
 			drawChampionState(_leaderIndex);
 		}
@@ -624,7 +624,7 @@ uint16 ChampionMan::getStrength(int16 champIndex, int16 slotIndex) {
 	Champion *curChampion = &_champions[champIndex];
 	int16 strength = _vm->getRandomNumber(16) + curChampion->_statistics[k1_ChampionStatStrength][k1_ChampionStatCurrent];
 	Thing curThing = curChampion->_slots[slotIndex];
-	uint16 objectWeight = _vm->_dungeonMan->f140_getObjectWeight(curThing);
+	uint16 objectWeight = _vm->_dungeonMan->getObjectWeight(curThing);
 	uint16 oneSixteenthMaximumLoad = getMaximumLoad(curChampion) >> 4;
 
 	if (objectWeight <= oneSixteenthMaximumLoad) {
@@ -638,7 +638,7 @@ uint16 ChampionMan::getStrength(int16 champIndex, int16 slotIndex) {
 		}
 	}
 	if (curThing.getType() == k5_WeaponThingType) {
-		WeaponInfo *weaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
+		WeaponInfo *weaponInfo = _vm->_dungeonMan->getWeaponInfo(curThing);
 		strength += weaponInfo->_strength;
 		uint16 skillLevel = 0;
 		uint16 weaponClass = weaponInfo->_class;
@@ -680,7 +680,7 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 	// Remove object modifiers
 	applyModifiersToStatistics(curChampion, slotIndex, curIconIndex, -1, curThing);
 
-	Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(curThing);
+	Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->getThingData(curThing);
 	if (slotIndex == k10_ChampionSlotNeck) {
 		if ((curIconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (curIconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
 			((Junk *)curWeapon)->setChargeCount(0);
@@ -727,7 +727,7 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 			}
 		}
 	}
-	curChampion->_load -= _vm->_dungeonMan->f140_getObjectWeight(curThing);
+	curChampion->_load -= _vm->_dungeonMan->getObjectWeight(curThing);
 	setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad);
 	return curThing;
 }
@@ -851,10 +851,10 @@ int16 ChampionMan::getWoundDefense(int16 champIndex, uint16 woundIndex) {
 	for (int16 slotIndex = k0_ChampionSlotReadyHand; slotIndex <= k1_ChampionSlotActionHand; slotIndex++) {
 		Thing curThing = curChampion->_slots[slotIndex];
 		if (curThing.getType() == k6_ArmourThingType) {
-			ArmourInfo *armorInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(curThing);
+			ArmourInfo *armorInfo = (ArmourInfo *)_vm->_dungeonMan->getThingData(curThing);
 			armorInfo = &_vm->_dungeonMan->_armourInfo[((Armour *)armorInfo)->getType()];
 			if (getFlag(armorInfo->_attributes, k0x0080_ArmourAttributeIsAShield))
-				armorShieldDefense += ((getStrength(champIndex, slotIndex) + _vm->_dungeonMan->f143_getArmourDefense(armorInfo, useSharpDefense)) * woundDefenseFactor[woundIndex]) >> ((slotIndex == woundIndex) ? 4 : 5);
+				armorShieldDefense += ((getStrength(champIndex, slotIndex) + _vm->_dungeonMan->getArmourDefense(armorInfo, useSharpDefense)) * woundDefenseFactor[woundIndex]) >> ((slotIndex == woundIndex) ? 4 : 5);
 		}
 	}
 
@@ -866,8 +866,8 @@ int16 ChampionMan::getWoundDefense(int16 champIndex, uint16 woundIndex) {
 	if (woundIndex > k1_ChampionSlotActionHand) {
 		Thing curThing = curChampion->_slots[woundIndex];
 		if (curThing.getType() == k6_ArmourThingType) {
-			ArmourInfo *armourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(curThing);
-			woundDefense += _vm->_dungeonMan->f143_getArmourDefense(&_vm->_dungeonMan->_armourInfo[((Armour *)armourInfo)->getType()], useSharpDefense);
+			ArmourInfo *armourInfo = (ArmourInfo *)_vm->_dungeonMan->getThingData(curThing);
+			woundDefense += _vm->_dungeonMan->getArmourDefense(&_vm->_dungeonMan->_armourInfo[((Armour *)armourInfo)->getType()], useSharpDefense);
 		}
 	}
 
@@ -911,7 +911,7 @@ void ChampionMan::wakeUp() {
 }
 
 int16 ChampionMan::getThrowingStaminaCost(Thing thing) {
-	int16 weight = _vm->_dungeonMan->f140_getObjectWeight(thing) >> 1;
+	int16 weight = _vm->_dungeonMan->getObjectWeight(thing) >> 1;
 	int16 staminaCost = getBoundedValue<int16>(1, weight, 10);
 
 	while ((weight -= 10) > 0)
@@ -942,7 +942,7 @@ void ChampionMan::disableAction(uint16 champIndex, uint16 ticks) {
 		setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x0008_ChampionAttributeDisableAction);
 		drawChampionState((ChampionIndex)champIndex);
 	}
-	setMapAndTime(curEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, updatedEnableActionEventTime);
+	setMapAndTime(curEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, updatedEnableActionEventTime);
 	curChampion->_enableActionEventIndex = _vm->_timeline->f238_addEventGetEventIndex(&curEvent);
 }
 
@@ -951,8 +951,8 @@ void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint1
 		exp >>= 1;
 
 	if (exp) {
-		if (_vm->_dungeonMan->_g269_currMap->_difficulty)
-			exp *= _vm->_dungeonMan->_g269_currMap->_difficulty;
+		if (_vm->_dungeonMan->_currMap->_difficulty)
+			exp *= _vm->_dungeonMan->_currMap->_difficulty;
 
 		Champion *curChampion = &_champions[champIndex];
 		uint16 baseSkillIndex;
@@ -1070,9 +1070,9 @@ int16 ChampionMan::getDamagedChampionCount(uint16 attack, int16 wounds, int16 at
 }
 
 int16 ChampionMan::getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) {
-	if (_partyChampionCount && (getDistance(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)) {
+	if (_partyChampionCount && (getDistance(mapX, mapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY) <= 1)) {
 		signed char orderedCellsToAttack[4];
-		_vm->_groupMan->f229_setOrderedCellsToAttack(orderedCellsToAttack, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, mapX, mapY, cell);
+		_vm->_groupMan->f229_setOrderedCellsToAttack(orderedCellsToAttack, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, mapX, mapY, cell);
 		for (uint16 i = 0; i < 4; i++) {
 			int16 championIndex = getIndexInCell(orderedCellsToAttack[i]);
 			if (championIndex >= 0)
@@ -1117,7 +1117,7 @@ void ChampionMan::championPoison(int16 champIndex, uint16 attack) {
 		TimelineEvent newEvent;
 		newEvent._type = k75_TMEventTypePoisonChampion;
 		newEvent._priority = champIndex;
-		setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + 36);
+		setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + 36);
 		newEvent._B._attack = attack;
 		_vm->_timeline->f238_addEventGetEventIndex(&newEvent);
 	}
@@ -1126,10 +1126,10 @@ void ChampionMan::championPoison(int16 champIndex, uint16 attack) {
 }
 
 void ChampionMan::setPartyDirection(int16 dir) {
-	if (dir == _vm->_dungeonMan->_g308_partyDir)
+	if (dir == _vm->_dungeonMan->_partyDir)
 		return;
 
-	int16 L0834_i_Delta = dir - _vm->_dungeonMan->_g308_partyDir;
+	int16 L0834_i_Delta = dir - _vm->_dungeonMan->_partyDir;
 	if (L0834_i_Delta < 0)
 		L0834_i_Delta += 4;
 
@@ -1140,7 +1140,7 @@ void ChampionMan::setPartyDirection(int16 dir) {
 		curChampion++;
 	}
 
-	_vm->_dungeonMan->_g308_partyDir = (Direction)dir;
+	_vm->_dungeonMan->_partyDir = (Direction)dir;
 	drawChangedObjectIcons();
 }
 
@@ -1171,7 +1171,7 @@ void ChampionMan::addScentStrength(int16 mapX, int16 mapY, int32 cycleCount) {
 		Scent newScent; /* BUG0_00 Useless code */
 		newScent.setMapX(mapX); /* BUG0_00 Useless code */
 		newScent.setMapY(mapY); /* BUG0_00 Useless code */
-		newScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */
+		newScent.setMapIndex(_vm->_dungeonMan->_currMapIndex); /* BUG0_00 Useless code */
 
 		Scent *curScent = _party._scents; /* BUG0_00 Useless code */
 		bool cycleCountDefined = false;
@@ -1207,7 +1207,7 @@ void ChampionMan::putObjectInLeaderHand(Thing thing, bool setMousePointer) {
 
 	_vm->_eventMan->f77_hideMouse();
 	if (_leaderIndex != kM1_ChampionNone) {
-		_champions[_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing);
+		_champions[_leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(thing);
 		setFlag(_champions[_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
 		drawChampionState(_leaderIndex);
 	}
@@ -1250,7 +1250,7 @@ bool ChampionMan::isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 wea
 	if (curThing.getType() != k5_WeaponThingType)
 		return false;
 
-	WeaponInfo *weaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
+	WeaponInfo *weaponInfo = _vm->_dungeonMan->getWeaponInfo(curThing);
 	int16 weaponClass = kM1_WeaponClassNone;
 
 	if ((weaponInfo->_class >= k16_WeaponClassFirstBow) && (weaponInfo->_class <= k31_WeaponClassLastBow))
@@ -1262,7 +1262,7 @@ bool ChampionMan::isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 wea
 		return false;
 
 	curThing = curChampion->_slots[ammunitionSlotIndex];
-	weaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(curThing);
+	weaponInfo = _vm->_dungeonMan->getWeaponInfo(curThing);
 	return ((curThing.getType() == k5_WeaponThingType) && (weaponInfo->_class == weaponClass));
 }
 
@@ -1285,7 +1285,7 @@ void ChampionMan::viAltarRebirth(uint16 champIndex) {
 	curChampion->_maxHealth = MAX(25, maximumHealth - (maximumHealth >> 6) - 1);
 	curChampion->_currHealth = curChampion->_maxHealth >> 1;
 	_vm->_menuMan->f393_drawSpellAreaControls(_magicCasterChampionIndex);
-	curChampion->_dir = _vm->_dungeonMan->_g308_partyDir;
+	curChampion->_dir = _vm->_dungeonMan->_partyDir;
 	setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
 	drawChampionState((ChampionIndex)champIndex);
 }
@@ -1319,7 +1319,7 @@ void ChampionMan::clickOnSlotBox(uint16 slotBoxIndex) {
 	if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none))
 		return;
 
-	if ((leaderHandObject != Thing::_none) && (!(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & _slotMasks[slotIndex])))
+	if ((leaderHandObject != Thing::_none) && (!(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(leaderHandObject)]._allowedSlots & _slotMasks[slotIndex])))
 		return;
 
 	_vm->_eventMan->f78_showMouse();
@@ -1357,7 +1357,7 @@ bool ChampionMan::isProjectileSpellCast(uint16 champIndex, Thing thing, int16 ki
 
 void ChampionMan::championShootProjectile(Champion* champ, Thing thing, int16 kineticEnergy, int16 attack, int16 stepEnergy) {
 	Direction newDirection = champ->_dir;
-	_vm->_projexpl->f212_projectileCreate(thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, normalizeModulo4((((champ->_cell - newDirection + 1) & 0x0002) >> 1) + newDirection), newDirection, kineticEnergy, attack, stepEnergy);
+	_vm->_projexpl->f212_projectileCreate(thing, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, normalizeModulo4((((champ->_cell - newDirection + 1) & 0x0002) >> 1) + newDirection), newDirection, kineticEnergy, attack, stepEnergy);
 	_vm->_projectileDisableMovementTicks = 4;
 	_vm->_lastProjectileDisabledMovementDirection = newDirection;
 }
@@ -1432,12 +1432,12 @@ void ChampionMan::applyAndDrawPendingDamageAndWounds() {
 			if (eventIndex == -1) {
 				TimelineEvent newEvent;
 				newEvent._type = k12_TMEventTypeHideDamageReceived;
-				setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + 5);
+				setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + 5);
 				newEvent._priority = championIndex;
 				championPtr->_hideDamageReceivedIndex = _vm->_timeline->f238_addEventGetEventIndex(&newEvent);
 			} else {
 				TimelineEvent *curEvent = &_vm->_timeline->_g370_events[eventIndex];
-				setMapAndTime(curEvent->_mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + 5);
+				setMapAndTime(curEvent->_mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + 5);
 				_vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(eventIndex));
 			}
 			drawChampionState((ChampionIndex)championIndex);
@@ -1468,21 +1468,21 @@ void ChampionMan::championKill(uint16 champIndex) {
 		_vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
 	}
 	dropAllObjects(champIndex);
-	Thing unusedThing = _vm->_dungeonMan->f166_getUnusedThing(k0x8000_championBones | k10_JunkThingType);
+	Thing unusedThing = _vm->_dungeonMan->getUnusedThing(k0x8000_championBones | k10_JunkThingType);
 	uint16 curCell = 0;
 	if (unusedThing != Thing::_none) {
-		Junk *L0966_ps_Junk = (Junk *)_vm->_dungeonMan->f156_getThingData(unusedThing);
+		Junk *L0966_ps_Junk = (Junk *)_vm->_dungeonMan->getThingData(unusedThing);
 		L0966_ps_Junk->setType(k5_JunkTypeBones);
 		L0966_ps_Junk->setDoNotDiscard(true);
 		L0966_ps_Junk->setChargeCount(champIndex);
 		curCell = curChampion->_cell;
-		_vm->_moveSens->f267_getMoveResult(thingWithNewCell(unusedThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+		_vm->_moveSens->f267_getMoveResult(thingWithNewCell(unusedThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
 	}
 	curChampion->_symbolStep = 0;
 	curChampion->_symbols[0] = '\0';
-	curChampion->_dir = _vm->_dungeonMan->_g308_partyDir;
+	curChampion->_dir = _vm->_dungeonMan->_partyDir;
 	curChampion->_maximumDamageReceived = 0;
-	uint16 curChampionIconIndex = getChampionIconIndex(curCell, _vm->_dungeonMan->_g308_partyDir);
+	uint16 curChampionIconIndex = getChampionIconIndex(curCell, _vm->_dungeonMan->_partyDir);
 	if (_vm->indexToOrdinal(curChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
 		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
 		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kM1_ChampionNone);
@@ -1553,7 +1553,7 @@ void ChampionMan::dropAllObjects(uint16 champIndex) {
 	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
 		Thing curThing = getObjectRemovedFromSlot(champIndex, slotDropOrder[slotIndex]);
 		if (curThing != Thing::_none)
-			_vm->_moveSens->f267_getMoveResult(thingWithNewCell(curThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+			_vm->_moveSens->f267_getMoveResult(thingWithNewCell(curThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
 	}
 }
 
@@ -1574,9 +1574,9 @@ void ChampionMan::applyTimeEffects() {
 		return;
 
 	Scent checkScent;
-	checkScent.setMapX(_vm->_dungeonMan->_g306_partyMapX);
-	checkScent.setMapY(_vm->_dungeonMan->_g307_partyMapY);
-	checkScent.setMapIndex(_vm->_dungeonMan->_g309_partyMapIndex);
+	checkScent.setMapX(_vm->_dungeonMan->_partyMapX);
+	checkScent.setMapY(_vm->_dungeonMan->_partyMapY);
+	checkScent.setMapIndex(_vm->_dungeonMan->_partyMapIndex);
 
 	for (byte loopScentIndex = 0; loopScentIndex + 1 < _party._scentCount; loopScentIndex++) {
 		if (&_party._scents[loopScentIndex] != &checkScent) {
@@ -1678,8 +1678,8 @@ void ChampionMan::applyTimeEffects() {
 						curStatistic[k1_ChampionStatCurrent] -= curStatistic[k1_ChampionStatCurrent] / statisticMaximum;
 				}
 			}
-			if (!_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_gameTime)) {
-				championPtr->_dir = _vm->_dungeonMan->_g308_partyDir;
+			if (!_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_gameTime)) {
+				championPtr->_dir = _vm->_dungeonMan->_partyDir;
 				championPtr->_maximumDamageReceived = 0;
 				setFlag(championPtr->_attributes, k0x0400_ChampionAttributeIcon);
 			}
@@ -1876,26 +1876,26 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	championPtr->_actionIndex = k255_ChampionActionNone;
 	championPtr->_enableActionEventIndex = -1;
 	championPtr->_hideDamageReceivedIndex = -1;
-	championPtr->_dir = _vm->_dungeonMan->_g308_partyDir;
+	championPtr->_dir = _vm->_dungeonMan->_partyDir;
 	uint16 viewCell = k0_ViewCellFronLeft;
-	while (getIndexInCell(normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone)
+	while (getIndexInCell(normalizeModulo4(viewCell + _vm->_dungeonMan->_partyDir)) != kM1_ChampionNone)
 		viewCell++;
 
-	championPtr->_cell = (ViewCell)normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir);
+	championPtr->_cell = (ViewCell)normalizeModulo4(viewCell + _vm->_dungeonMan->_partyDir);
 	championPtr->_attributes = k0x0400_ChampionAttributeIcon;
-	championPtr->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir;
+	championPtr->_directionMaximumDamageReceived = _vm->_dungeonMan->_partyDir;
 	championPtr->_food = 1500 + _vm->getRandomNumber(256);
 	championPtr->_water = 1500 + _vm->getRandomNumber(256);
 	for (int16 slotIdx = k0_ChampionSlotReadyHand; slotIdx < k30_ChampionSlotChest_1; slotIdx++)
 		championPtr->_slots[slotIdx] = Thing::_none;
 
-	Thing curThing = _vm->_dungeonMan->f161_getSquareFirstThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+	Thing curThing = _vm->_dungeonMan->getSquareFirstThing(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
 	while (curThing.getType() != k2_TextstringType)
-		curThing = _vm->_dungeonMan->f159_getNextThing(curThing);
+		curThing = _vm->_dungeonMan->getNextThing(curThing);
 
 	char L0807_ac_DecodedChampionText[77];
 	char *decodedStringPtr = L0807_ac_DecodedChampionText;
-	_vm->_dungeonMan->f168_decodeText(decodedStringPtr, curThing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
+	_vm->_dungeonMan->decodeText(decodedStringPtr, curThing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
 
 	uint16 charIdx = 0;
 	char tmpChar;
@@ -1955,16 +1955,16 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_partyChampionCount - 1));
 	}
 
-	int16 curMapX = _vm->_dungeonMan->_g306_partyMapX;
-	int16 curMapY = _vm->_dungeonMan->_g307_partyMapY;
-	uint16 championObjectsCell = returnOppositeDir(_vm->_dungeonMan->_g308_partyDir);
-	curMapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], curMapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
-	curThing = _vm->_dungeonMan->f161_getSquareFirstThing(curMapX, curMapY);
+	int16 curMapX = _vm->_dungeonMan->_partyMapX;
+	int16 curMapY = _vm->_dungeonMan->_partyMapY;
+	uint16 championObjectsCell = returnOppositeDir(_vm->_dungeonMan->_partyDir);
+	curMapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir], curMapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
+	curThing = _vm->_dungeonMan->getSquareFirstThing(curMapX, curMapY);
 	int16 slotIdx = k13_ChampionSlotBackpackLine_1_1;
 	while (curThing != Thing::_endOfList) {
 		ThingType thingType = curThing.getType();
 		if ((thingType > k3_SensorThingType) && (curThing.getCell() == championObjectsCell)) {
-			int16 objectAllowedSlots = _vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(curThing)]._allowedSlots;
+			int16 objectAllowedSlots = _vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(curThing)]._allowedSlots;
 			uint16 curSlotIndex = k0_ChampionSlotReadyHand;
 			switch (thingType) {
 			case k6_ArmourThingType: {
@@ -2025,7 +2025,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 			}
 			addObjectInSlot((ChampionIndex)previousPartyChampionCount, curThing, (ChampionSlot)curSlotIndex);
 		}
-		curThing = _vm->_dungeonMan->f159_getNextThing(curThing);
+		curThing = _vm->_dungeonMan->getNextThing(curThing);
 	}
 	_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)previousPartyChampionCount);
 	_vm->_menuMan->f456_drawDisabledMenu();;
@@ -2255,10 +2255,10 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		_vm->_textMan->f52_printToViewport(148, 132, loadColor, _vm->_stringBuildBuffer);
 		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
-	uint16 championIconIndex = getChampionIconIndex(curChampion->_cell, _vm->_dungeonMan->_g308_partyDir);
+	uint16 championIconIndex = getChampionIconIndex(curChampion->_cell, _vm->_dungeonMan->_partyDir);
 	if (getFlag(championAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(championIconIndex))) {
 		_vm->_displayMan->D24_fillScreenBox(_boxChampionIcons[championIconIndex], _championColor[champIndex]);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, _boxChampionIcons[championIconIndex], getChampionIconIndex(curChampion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, _boxChampionIcons[championIconIndex], getChampionIconIndex(curChampion->_dir, _vm->_dungeonMan->_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
 	}
 	if (getFlag(championAttributes, k0x0800_ChampionAttributePanel) && isInventoryChampion) {
 		if (_vm->_pressingMouth)
diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index 9874708..b931733 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -120,8 +120,8 @@ argumentError:
 bool Console::Cmd_pos(int argc, const char** argv) {
 	DungeonMan &dm = *_vm->_dungeonMan;
 	if (argc == 2 && cstrEquals("get", argv[1])) {
-		debugPrintf("Position: (%d, %d)  Direction: %s\n", dm._g306_partyMapX + dm._g269_currMap->_offsetMapX,
-					dm._g307_partyMapY + dm._g269_currMap->_offsetMapY, debugGetDirectionName(_vm->_dungeonMan->_g308_partyDir));
+		debugPrintf("Position: (%d, %d)  Direction: %s\n", dm._partyMapX + dm._currMap->_offsetMapX,
+					dm._partyMapY + dm._currMap->_offsetMapY, debugGetDirectionName(_vm->_dungeonMan->_partyDir));
 	} else if (argc == 4 && cstrEquals("set", argv[1])) {
 		int x = atoi(argv[2]);
 		int y = atoi(argv[3]);
@@ -130,7 +130,7 @@ bool Console::Cmd_pos(int argc, const char** argv) {
 			return true;
 		}
 
-		Map &currMap = *_vm->_dungeonMan->_g269_currMap;
+		Map &currMap = *_vm->_dungeonMan->_currMap;
 		// not >= because dimensions are inslucsive
 		if (x < currMap._offsetMapX || x > currMap._width + currMap._offsetMapX 
 			|| y < currMap._offsetMapY || y > currMap._height + currMap._offsetMapY) {
@@ -143,7 +143,7 @@ bool Console::Cmd_pos(int argc, const char** argv) {
 		if (haventWarned.check())
 			debugPrintf("Setting position directly can cause glitches and crashes.\n");
 		debugPrintf("Position set to (%d, %d)\n", x, y);
-		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY,
+		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY,
 										   x - currMap._offsetMapX, y - currMap._offsetMapY);
 	} else
 		goto argumentError;
@@ -158,7 +158,7 @@ argumentError:
 
 bool Console::Cmd_map(int argc, const char** argv) {
 	if (argc == 2 && cstrEquals("get", argv[1])) {
-		debugPrintf("Map index: %d\n", _vm->_dungeonMan->_g309_partyMapIndex);
+		debugPrintf("Map index: %d\n", _vm->_dungeonMan->_partyMapIndex);
 	} else if (argc == 3 && cstrEquals("set", argv[1])) {
 		int index = atoi(argv[2]);
 		if (index == 0 && !cstrEquals("0", argv[2])) {
@@ -167,8 +167,8 @@ bool Console::Cmd_map(int argc, const char** argv) {
 		}
 
 		// not >= because dimensions are inslucsive
-		if (index < 0 || index >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount) {
-			debugPrintf("Map index %d is out of bounds, possible values [0, %d]\n", index, _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount - 1);
+		if (index < 0 || index >= _vm->_dungeonMan->_dungeonFileHeader._mapCount) {
+			debugPrintf("Map index %d is out of bounds, possible values [0, %d]\n", index, _vm->_dungeonMan->_dungeonFileHeader._mapCount - 1);
 			return true;
 		}
 
@@ -177,15 +177,15 @@ bool Console::Cmd_map(int argc, const char** argv) {
 			debugPrintf("Setting map directly can cause glitches and crashes.\n");
 		debugPrintf("Map set to %d\n", index);
 
-		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0);
-		_vm->_newPartyMapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(
-			_vm->_dungeonMan->_g309_partyMapIndex, index - _vm->_dungeonMan->_g309_partyMapIndex,
-			&_vm->_dungeonMan->_g306_partyMapX, &_vm->_dungeonMan->_g307_partyMapY);
+		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kM1_MapXNotOnASquare, 0);
+		_vm->_newPartyMapIndex = _vm->_dungeonMan->getLocationAfterLevelChange(
+			_vm->_dungeonMan->_partyMapIndex, index - _vm->_dungeonMan->_partyMapIndex,
+			&_vm->_dungeonMan->_partyMapX, &_vm->_dungeonMan->_partyMapY);
 		if (_vm->_newPartyMapIndex == -1)
 			_vm->_newPartyMapIndex = index;
-		_vm->_dungeonMan->f173_setCurrentMap(_vm->_newPartyMapIndex);
-		_vm->_championMan->setPartyDirection(_vm->_dungeonMan->f155_getStairsExitDirection(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY));
-		_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
+		_vm->_dungeonMan->setCurrentMap(_vm->_newPartyMapIndex);
+		_vm->_championMan->setPartyDirection(_vm->_dungeonMan->getStairsExitDirection(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY));
+		_vm->_dungeonMan->setCurrentMap(_vm->_dungeonMan->_partyMapIndex);
 	} else
 		goto argumentError;
 
@@ -249,9 +249,9 @@ bool Console::Cmd_gimme(int argc, const char** argv) {
 	requestedItemName.deleteLastChar();
 
 	for (int16 thingType = 0; thingType < 16; ++thingType) { // 16 number of item types
-		uint16 *thingDataArray = _vm->_dungeonMan->_g284_thingData[thingType];
+		uint16 *thingDataArray = _vm->_dungeonMan->_thingData[thingType];
 		uint16 thingTypeSize = g235_ThingDataWordCount[thingType];
-		uint16 thingCount = _vm->_dungeonMan->_g278_dungeonFileHeader._thingCounts[thingType];
+		uint16 thingCount = _vm->_dungeonMan->_dungeonFileHeader._thingCounts[thingType];
 
 		Thing dummyThing(0);
 		dummyThing.setType(thingType);
@@ -266,8 +266,8 @@ bool Console::Cmd_gimme(int argc, const char** argv) {
 					delete[] thingDataArray;
 					for (uint16 i = 0; i < thingTypeSize; ++i)
 						newThingData[thingCount * thingTypeSize + i] = newThingData[thingIndex * thingTypeSize + i];
-					_vm->_dungeonMan->_g278_dungeonFileHeader._thingCounts[thingType]++;
-					_vm->_dungeonMan->_g284_thingData[thingType] = newThingData;
+					_vm->_dungeonMan->_dungeonFileHeader._thingCounts[thingType]++;
+					_vm->_dungeonMan->_thingData[thingType] = newThingData;
 					_vm->_championMan->addObjectInSlot((ChampionIndex)0, dummyThing, (ChampionSlot)29);
 					debugPrintf("Item gimmed to the first champion, last slot\n");
 					return true;
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 37f0305..0c225a7 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -306,7 +306,7 @@ void DMEngine::initializeGame() {
 
 	startGame();
 	if (_newGameFl)
-		_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
+		_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
 	_eventMan->f78_showMouse();
 	_eventMan->f357_discardAllInput();
 }
@@ -342,7 +342,7 @@ void DMEngine::startGame() {
 	_eventMan->_g443_primaryKeyboardInput = _eventMan->_primaryKeyboardInputInterface;
 	_eventMan->_g444_secondaryKeyboardInput = _eventMan->_secondaryKeyboardInputMovement;
 
-	processNewPartyMap(_dungeonMan->_g309_partyMapIndex);
+	processNewPartyMap(_dungeonMan->_partyMapIndex);
 
 	if (!_newGameFl) {
 		_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);
@@ -366,7 +366,7 @@ void DMEngine::startGame() {
 
 void DMEngine::processNewPartyMap(uint16 mapIndex) {
 	_groupMan->f194_removeAllActiveGroups();
-	_dungeonMan->f174_setCurrentMapAndPartyMap(mapIndex);
+	_dungeonMan->setCurrentMapAndPartyMap(mapIndex);
 	_displayMan->f96_loadCurrentMapGraphics();
 	_groupMan->f195_addAllActiveGroups();
 	_inventoryMan->f337_setDungeonViewPalette();
@@ -439,7 +439,7 @@ void DMEngine::gameloop() {
 
 			if (_newPartyMapIndex != kM1_mapIndexNone) {
 				processNewPartyMap(_newPartyMapIndex);
-				_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
+				_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
 				_newPartyMapIndex = kM1_mapIndexNone;
 				_eventMan->f357_discardAllInput();
 			}
@@ -452,7 +452,7 @@ void DMEngine::gameloop() {
 		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) {
 			Box box(0, 223, 0, 135);
 			_displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // (possibly dummy code)
-			_displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
+			_displayMan->f128_drawDungeon(_dungeonMan->_partyDir, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
 			if (_setMousePointerToObjectInMainLoop) {
 				_setMousePointerToObjectInMainLoop = false;
 				_eventMan->f78_showMouse();
@@ -634,7 +634,7 @@ void DMEngine::endGame(bool doNotDrawCreditsOnly) {
 	_eventMan->_g443_primaryKeyboardInput = nullptr;
 	_eventMan->_g444_secondaryKeyboardInput = nullptr;
 	if (doNotDrawCreditsOnly && !_gameWon) {
-		_sound->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
+		_sound->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY, k0_soundModePlayImmediately);
 		delay(240);
 	}
 
@@ -775,14 +775,14 @@ void DMEngine::drawEntrance() {
 
 	byte *microDungeonCurrentMapData[32];
 
-	_dungeonMan->_g309_partyMapIndex = k255_mapIndexEntrance;
+	_dungeonMan->_partyMapIndex = k255_mapIndexEntrance;
 	_displayMan->_g297_drawFloorAndCeilingRequested = true;
-	_dungeonMan->_g273_currMapWidth = 5;
-	_dungeonMan->_g274_currMapHeight = 5;
-	_dungeonMan->_g271_currMapData = microDungeonCurrentMapData;
+	_dungeonMan->_currMapWidth = 5;
+	_dungeonMan->_currMapHeight = 5;
+	_dungeonMan->_currMapData = microDungeonCurrentMapData;
 
 	Map map; // uninitialized, won't be used
-	_dungeonMan->_g269_currMap = ↦
+	_dungeonMan->_currMap = ↦
 	Square microDungeonSquares[25];
 	for (uint16 i = 0; i < 25; ++i)
 		microDungeonSquares[i] = Square(k0_ElementTypeWall, 0);
@@ -969,29 +969,29 @@ void DMEngine::fuseSequnce() {
 	_championMan->_party._fireShieldDefense = _championMan->_party._spellShieldDefense = _championMan->_party._shieldDefense = 100;
 	_timeline->f260_timelineRefreshAllChampionStatusBoxes();
 	fuseSequenceUpdate();
-	L1431_i_LordChaosMapX = _dungeonMan->_g306_partyMapX;
-	L1432_i_LordChaosMapY = _dungeonMan->_g307_partyMapY;
-	L1431_i_LordChaosMapX += _dirIntoStepCountEast[_dungeonMan->_g308_partyDir], L1432_i_LordChaosMapY += _dirIntoStepCountNorth[_dungeonMan->_g308_partyDir];
-	L1428_ps_Group = (Group*)_dungeonMan->f156_getThingData(L1433_T_LordChaosThing = _groupMan->f175_groupGetThing(L1431_i_LordChaosMapX, L1432_i_LordChaosMapY));
+	L1431_i_LordChaosMapX = _dungeonMan->_partyMapX;
+	L1432_i_LordChaosMapY = _dungeonMan->_partyMapY;
+	L1431_i_LordChaosMapX += _dirIntoStepCountEast[_dungeonMan->_partyDir], L1432_i_LordChaosMapY += _dirIntoStepCountNorth[_dungeonMan->_partyDir];
+	L1428_ps_Group = (Group*)_dungeonMan->getThingData(L1433_T_LordChaosThing = _groupMan->f175_groupGetThing(L1431_i_LordChaosMapX, L1432_i_LordChaosMapY));
 	L1428_ps_Group->_health[0] = 10000;
-	_dungeonMan->f146_setGroupCells(L1428_ps_Group, k255_CreatureTypeSingleCenteredCreature, _dungeonMan->_g309_partyMapIndex);
-	_dungeonMan->f148_setGroupDirections(L1428_ps_Group, returnOppositeDir(_dungeonMan->_g308_partyDir), _dungeonMan->_g309_partyMapIndex);
+	_dungeonMan->setGroupCells(L1428_ps_Group, k255_CreatureTypeSingleCenteredCreature, _dungeonMan->_partyMapIndex);
+	_dungeonMan->setGroupDirections(L1428_ps_Group, returnOppositeDir(_dungeonMan->_partyDir), _dungeonMan->_partyMapIndex);
 
 	AL1424_B_RemoveFluxcagesFromLoadChaosSquare = true;
-	AL1425_i_FluxcageMapX = _dungeonMan->_g306_partyMapX;
-	AL1426_i_FluxcageMapY = _dungeonMan->_g307_partyMapY;
+	AL1425_i_FluxcageMapX = _dungeonMan->_partyMapX;
+	AL1426_i_FluxcageMapY = _dungeonMan->_partyMapY;
 T0446002:
-	L1427_T_Thing = _dungeonMan->f162_getSquareFirstObject(AL1425_i_FluxcageMapX, AL1426_i_FluxcageMapY);
+	L1427_T_Thing = _dungeonMan->getSquareFirstObject(AL1425_i_FluxcageMapX, AL1426_i_FluxcageMapY);
 	while (L1427_T_Thing != Thing::_endOfList) {
 		if (L1427_T_Thing.getType() == k15_ExplosionThingType) {
-			L1429_ps_Explosion = (Explosion*)_dungeonMan->f156_getThingData(L1427_T_Thing);
+			L1429_ps_Explosion = (Explosion*)_dungeonMan->getThingData(L1427_T_Thing);
 			if (L1429_ps_Explosion->getType() == k50_ExplosionType_Fluxcage) {
-				_dungeonMan->f164_unlinkThingFromList(L1427_T_Thing, Thing(0), AL1425_i_FluxcageMapX, AL1426_i_FluxcageMapY);
+				_dungeonMan->unlinkThingFromList(L1427_T_Thing, Thing(0), AL1425_i_FluxcageMapX, AL1426_i_FluxcageMapY);
 				L1429_ps_Explosion->setNextThing(Thing::_none);
 				goto T0446002;
 			}
 		}
-		L1427_T_Thing = _dungeonMan->f159_getNextThing(L1427_T_Thing);
+		L1427_T_Thing = _dungeonMan->getNextThing(L1427_T_Thing);
 	}
 	if (AL1424_B_RemoveFluxcagesFromLoadChaosSquare) {
 		AL1424_B_RemoveFluxcagesFromLoadChaosSquare = false;
@@ -1026,8 +1026,8 @@ T0446002:
 	fuseSequenceUpdate();
 	_displayMan->_g77_doNotDrawFluxcagesDuringEndgame = true;
 	fuseSequenceUpdate();
-	for (AL1424_i_MapX = 0; AL1424_i_MapX < _dungeonMan->_g273_currMapWidth; AL1424_i_MapX++) {
-		for (AL1425_i_MapY = 0; AL1425_i_MapY < _dungeonMan->_g274_currMapHeight; AL1425_i_MapY++) {
+	for (AL1424_i_MapX = 0; AL1424_i_MapX < _dungeonMan->_currMapWidth; AL1424_i_MapX++) {
+		for (AL1425_i_MapY = 0; AL1425_i_MapY < _dungeonMan->_currMapHeight; AL1425_i_MapY++) {
 			if (((L1427_T_Thing = _groupMan->f175_groupGetThing(AL1424_i_MapX, AL1425_i_MapY)) != Thing::_endOfList) && ((AL1424_i_MapX != L1431_i_LordChaosMapX) || (AL1425_i_MapY != L1432_i_LordChaosMapY))) {
 				_groupMan->f189_delete(AL1424_i_MapX, AL1425_i_MapY);
 			}
@@ -1035,19 +1035,19 @@ T0446002:
 	}
 	fuseSequenceUpdate();
 	/* Count and get list of text things located at 0, 0 in the current map. Their text is then printed as messages in the order specified by their first letter (which is not printed) */
-	L1427_T_Thing = _dungeonMan->f161_getSquareFirstThing(0, 0);
+	L1427_T_Thing = _dungeonMan->getSquareFirstThing(0, 0);
 	AL1424_i_TextStringThingCount = 0;
 	while (L1427_T_Thing != Thing::_endOfList) {
 		if (L1427_T_Thing.getType() == k2_TextstringType) {
 			L1435_aT_TextStringThings[AL1424_i_TextStringThingCount++] = L1427_T_Thing;
 		}
-		L1427_T_Thing = _dungeonMan->f159_getNextThing(L1427_T_Thing);
+		L1427_T_Thing = _dungeonMan->getNextThing(L1427_T_Thing);
 	}
 	L1434_c_TextFirstCharacter = 'A';
 	AL1426_i_TextStringThingCount = AL1424_i_TextStringThingCount;
 	while (AL1424_i_TextStringThingCount--) {
 		for (AL1425_i_TextStringThingIndex = 0; AL1425_i_TextStringThingIndex < AL1426_i_TextStringThingCount; AL1425_i_TextStringThingIndex++) {
-			_dungeonMan->f168_decodeText(L1436_ac_String, L1435_aT_TextStringThings[AL1425_i_TextStringThingIndex], (TextType)(k1_TextTypeMessage | k0x8000_DecodeEvenIfInvisible));
+			_dungeonMan->decodeText(L1436_ac_String, L1435_aT_TextStringThings[AL1425_i_TextStringThingIndex], (TextType)(k1_TextTypeMessage | k0x8000_DecodeEvenIfInvisible));
 			if (L1436_ac_String[1] == L1434_c_TextFirstCharacter) {
 				_textMan->f43_messageAreaClearAllRows();
 				L1436_ac_String[1] = '\n'; /* New line */
@@ -1072,7 +1072,7 @@ T0446002:
 
 void DMEngine::fuseSequenceUpdate() {
 	_timeline->f261_processTimeline();
-	_displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY);
+	_displayMan->f128_drawDungeon(_dungeonMan->_partyDir, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
 	_sound->f65_playPendingSound();
 	_eventMan->f357_discardAllInput();
 	_displayMan->updateScreen();
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index ef4aa6a..5e06e57 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -70,7 +70,7 @@ CreatureInfo g243_CreatureInfo[k27_CreatureTypeCount] = { // @ G0243_as_Graphic5
 	{25,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5},
 	{26,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}};
 
-void DungeonMan::f150_mapCoordsAfterRelMovement(Direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
+void DungeonMan::mapCoordsAfterRelMovement(Direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
 	posX += _vm->_dirIntoStepCountEast[dir] * stepsForward;
 	posY += _vm->_dirIntoStepCountNorth[dir] * stepsForward;
 	turnDirRight(dir);
@@ -388,59 +388,59 @@ void DungeonMan::setupArrays() {
 DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_rawDunFileDataSize = 0;
 	_rawDunFileData = nullptr;
-	_g282_dungeonColumCount = 0;
-	_g281_dungeonMapsFirstColumnIndex = nullptr;
+	_dungeonColumCount = 0;
+	_dungeonMapsFirstColumnIndex = nullptr;
 
-	_g282_dungeonColumCount = 0;
-	_g280_dungeonColumnsCumulativeSquareThingCount = nullptr;
-	_g283_squareFirstThings = nullptr;
-	_g260_dungeonTextData = nullptr;
+	_dungeonColumCount = 0;
+	_dungeonColumnsCumulativeSquareThingCount = nullptr;
+	_squareFirstThings = nullptr;
+	_dungeonTextData = nullptr;
 	for (uint16 i = 0; i < 16; ++i)
-		_g284_thingData[i] = nullptr;
-
-	_g279_dungeonMapData = nullptr;
-	_g308_partyDir = (Direction)0;
-	_g306_partyMapX = 0;
-	_g307_partyMapY = 0;
-	_g309_partyMapIndex = 0;
-	_g272_currMapIndex = kM1_mapIndexNone;
-	_g271_currMapData = nullptr;
-	_g269_currMap = nullptr;
-	_g273_currMapWidth = 0;
-	_g274_currMapHeight = 0;
-	_g270_currMapColCumulativeSquareFirstThingCount = nullptr;
-	_g277_dungeonMaps = nullptr;
-	_g276_dungeonRawMapData = nullptr;
-	_g265_currMapInscriptionWallOrnIndex = 0;
+		_thingData[i] = nullptr;
+
+	_dungeonMapData = nullptr;
+	_partyDir = (Direction)0;
+	_partyMapX = 0;
+	_partyMapY = 0;
+	_partyMapIndex = 0;
+	_currMapIndex = kM1_mapIndexNone;
+	_currMapData = nullptr;
+	_currMap = nullptr;
+	_currMapWidth = 0;
+	_currMapHeight = 0;
+	_currMapColCumulativeSquareFirstThingCount = nullptr;
+	_dungeonMaps = nullptr;
+	_dungeonRawMapData = nullptr;
+	_currMapInscriptionWallOrnIndex = 0;
 	for (uint16 i = 0; i < 6; ++i)
-		_g291_dungeonViewClickableBoxes[i].setToZero();
-	_g286_isFacingAlcove = false;
-	_g287_isFacingViAltar = false;
-	_g288_isFacingFountain = false;
-	_g285_squareAheadElement = (ElementType)0;
+		_dungeonViewClickableBoxes[i].setToZero();
+	_isFacingAlcove = false;
+	_isFacingViAltar = false;
+	_isFacingFountain = false;
+	_squareAheadElement = (ElementType)0;
 	for (uint16 i = 0; i < 5; ++i)
-		_g292_pileTopObject[i] = Thing(0);
+		_pileTopObject[i] = Thing(0);
 	for (uint16 i = 0; i < 2; ++i)
-		_g275_currMapDoorInfo[i].resetToZero();
+		_currMapDoorInfo[i].resetToZero();
 
 	setupArrays();
 }
 
 DungeonMan::~DungeonMan() {
 	delete[] _rawDunFileData;
-	delete[] _g277_dungeonMaps;
-	delete[] _g281_dungeonMapsFirstColumnIndex;
-	delete[] _g280_dungeonColumnsCumulativeSquareThingCount;
-	delete[] _g283_squareFirstThings;
-	delete[] _g260_dungeonTextData;
-	delete[] _g279_dungeonMapData;
+	delete[] _dungeonMaps;
+	delete[] _dungeonMapsFirstColumnIndex;
+	delete[] _dungeonColumnsCumulativeSquareThingCount;
+	delete[] _squareFirstThings;
+	delete[] _dungeonTextData;
+	delete[] _dungeonMapData;
 	for (uint16 i = 0; i < 16; ++i)
-		delete[] _g284_thingData[i];
+		delete[] _thingData[i];
 
-	delete[] _g276_dungeonRawMapData;
+	delete[] _dungeonRawMapData;
 }
 
-void DungeonMan::f455_decompressDungeonFile() {
+void DungeonMan::decompressDungeonFile() {
 	Common::File f;
 	f.open("Dungeon.dat");
 	if (f.readUint16BE() == 0x8104) { // if dungeon is compressed
@@ -537,7 +537,7 @@ const Thing Thing::_explRebirthStep1(0xFFE4); // @ C0xFFE4_THING_EXPLOSION_REBIR
 const Thing Thing::_explRebirthStep2(0xFFE5); // @ C0xFFE5_THING_EXPLOSION_REBIRTH_STEP2    
 const Thing Thing::_party(0xFFFF); // @ C0xFFFF_THING_PARTY          
 
-void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
+void DungeonMan::loadDungeonFile(Common::InSaveFile *file) {
 	static const byte additionalThingCounts[16] = { // @ G0236_auc_Graphic559_AdditionalThingCounts{
 		0,    /* Door */
 		0,    /* Teleporter */
@@ -558,7 +558,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 	};
 
 	if (_vm->_newGameFl)
-		f455_decompressDungeonFile();
+		decompressDungeonFile();
 
 	Common::ReadStream *dunDataStream = nullptr;
 	if (file) {
@@ -571,114 +571,114 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 	}
 
 	// initialize _g278_dungeonFileHeader
-	_g278_dungeonFileHeader._ornamentRandomSeed = dunDataStream->readUint16BE();
-	_g278_dungeonFileHeader._rawMapDataSize = dunDataStream->readUint16BE();
-	_g278_dungeonFileHeader._mapCount = dunDataStream->readByte();
+	_dungeonFileHeader._ornamentRandomSeed = dunDataStream->readUint16BE();
+	_dungeonFileHeader._rawMapDataSize = dunDataStream->readUint16BE();
+	_dungeonFileHeader._mapCount = dunDataStream->readByte();
 	dunDataStream->readByte(); // discard 1 byte
-	_g278_dungeonFileHeader._textDataWordCount = dunDataStream->readUint16BE();
-	_g278_dungeonFileHeader._partyStartLocation = dunDataStream->readUint16BE();
-	_g278_dungeonFileHeader._squareFirstThingCount = dunDataStream->readUint16BE();
+	_dungeonFileHeader._textDataWordCount = dunDataStream->readUint16BE();
+	_dungeonFileHeader._partyStartLocation = dunDataStream->readUint16BE();
+	_dungeonFileHeader._squareFirstThingCount = dunDataStream->readUint16BE();
 	for (uint16 i = 0; i < k16_ThingTypeTotal; ++i)
-		_g278_dungeonFileHeader._thingCounts[i] = dunDataStream->readUint16BE();
+		_dungeonFileHeader._thingCounts[i] = dunDataStream->readUint16BE();
 
 	// init party position and mapindex
 	if (_vm->_newGameFl) {
-		uint16 startLoc = _g278_dungeonFileHeader._partyStartLocation;
-		_g308_partyDir = (Direction)((startLoc >> 10) & 3);
-		_g306_partyMapX = startLoc & 0x1F;
-		_g307_partyMapY = (startLoc >> 5) & 0x1F;
-		_g309_partyMapIndex = 0;
+		uint16 startLoc = _dungeonFileHeader._partyStartLocation;
+		_partyDir = (Direction)((startLoc >> 10) & 3);
+		_partyMapX = startLoc & 0x1F;
+		_partyMapY = (startLoc >> 5) & 0x1F;
+		_partyMapIndex = 0;
 	}
 
 	// load map data
 	if (!_vm->_restartGameRequest) {
-		delete[] _g277_dungeonMaps;
-		_g277_dungeonMaps = new Map[_g278_dungeonFileHeader._mapCount];
+		delete[] _dungeonMaps;
+		_dungeonMaps = new Map[_dungeonFileHeader._mapCount];
 	}
 
-	for (uint16 i = 0; i < _g278_dungeonFileHeader._mapCount; ++i) {
-		_g277_dungeonMaps[i]._rawDunDataOffset = dunDataStream->readUint16BE();
+	for (uint16 i = 0; i < _dungeonFileHeader._mapCount; ++i) {
+		_dungeonMaps[i]._rawDunDataOffset = dunDataStream->readUint16BE();
 		dunDataStream->readUint32BE(); // discard 4 bytes
-		_g277_dungeonMaps[i]._offsetMapX = dunDataStream->readByte();
-		_g277_dungeonMaps[i]._offsetMapY = dunDataStream->readByte();
+		_dungeonMaps[i]._offsetMapX = dunDataStream->readByte();
+		_dungeonMaps[i]._offsetMapY = dunDataStream->readByte();
 		
 		uint16 tmp = dunDataStream->readUint16BE();
-		_g277_dungeonMaps[i]._height = tmp >> 11;
-		_g277_dungeonMaps[i]._width = (tmp >> 6) & 0x1F;
-		_g277_dungeonMaps[i]._level = tmp & 0x3F; // Only used in DMII
+		_dungeonMaps[i]._height = tmp >> 11;
+		_dungeonMaps[i]._width = (tmp >> 6) & 0x1F;
+		_dungeonMaps[i]._level = tmp & 0x3F; // Only used in DMII
 
 		tmp = dunDataStream->readUint16BE();
-		_g277_dungeonMaps[i]._randFloorOrnCount = tmp >> 12;
-		_g277_dungeonMaps[i]._floorOrnCount = (tmp >> 8) & 0xF;
-		_g277_dungeonMaps[i]._randWallOrnCount = (tmp >> 4) & 0xF;
-		_g277_dungeonMaps[i]._wallOrnCount = tmp & 0xF;
+		_dungeonMaps[i]._randFloorOrnCount = tmp >> 12;
+		_dungeonMaps[i]._floorOrnCount = (tmp >> 8) & 0xF;
+		_dungeonMaps[i]._randWallOrnCount = (tmp >> 4) & 0xF;
+		_dungeonMaps[i]._wallOrnCount = tmp & 0xF;
 
 		tmp = dunDataStream->readUint16BE();
-		_g277_dungeonMaps[i]._difficulty = tmp >> 12;
-		_g277_dungeonMaps[i]._creatureTypeCount = (tmp >> 4) & 0xF;
-		_g277_dungeonMaps[i]._doorOrnCount = tmp & 0xF;
+		_dungeonMaps[i]._difficulty = tmp >> 12;
+		_dungeonMaps[i]._creatureTypeCount = (tmp >> 4) & 0xF;
+		_dungeonMaps[i]._doorOrnCount = tmp & 0xF;
 
 		tmp = dunDataStream->readUint16BE();
-		_g277_dungeonMaps[i]._doorSet1 = (tmp >> 12) & 0xF;
-		_g277_dungeonMaps[i]._doorSet0 = (tmp >> 8) & 0xF;
-		_g277_dungeonMaps[i]._wallSet = (WallSet)((tmp >> 4) & 0xF);
-		_g277_dungeonMaps[i]._floorSet = (FloorSet)(tmp & 0xF);
+		_dungeonMaps[i]._doorSet1 = (tmp >> 12) & 0xF;
+		_dungeonMaps[i]._doorSet0 = (tmp >> 8) & 0xF;
+		_dungeonMaps[i]._wallSet = (WallSet)((tmp >> 4) & 0xF);
+		_dungeonMaps[i]._floorSet = (FloorSet)(tmp & 0xF);
 	}
 
 	// load column stuff thingy
 	if (!_vm->_restartGameRequest) {
-		delete[] _g281_dungeonMapsFirstColumnIndex;
-		_g281_dungeonMapsFirstColumnIndex = new uint16[_g278_dungeonFileHeader._mapCount];
+		delete[] _dungeonMapsFirstColumnIndex;
+		_dungeonMapsFirstColumnIndex = new uint16[_dungeonFileHeader._mapCount];
 	}
 	uint16 columCount = 0;
-	for (uint16 i = 0; i < _g278_dungeonFileHeader._mapCount; ++i) {
-		_g281_dungeonMapsFirstColumnIndex[i] = columCount;
-		columCount += _g277_dungeonMaps[i]._width + 1;
+	for (uint16 i = 0; i < _dungeonFileHeader._mapCount; ++i) {
+		_dungeonMapsFirstColumnIndex[i] = columCount;
+		columCount += _dungeonMaps[i]._width + 1;
 	}
-	_g282_dungeonColumCount = columCount;
+	_dungeonColumCount = columCount;
 
-	uint32 actualSquareFirstThingCount = _g278_dungeonFileHeader._squareFirstThingCount;
+	uint32 actualSquareFirstThingCount = _dungeonFileHeader._squareFirstThingCount;
 	if (_vm->_newGameFl)
-		_g278_dungeonFileHeader._squareFirstThingCount += 300;
+		_dungeonFileHeader._squareFirstThingCount += 300;
 
 	if (!_vm->_restartGameRequest) {
-		delete[] _g280_dungeonColumnsCumulativeSquareThingCount;
-		_g280_dungeonColumnsCumulativeSquareThingCount = new uint16[columCount];
+		delete[] _dungeonColumnsCumulativeSquareThingCount;
+		_dungeonColumnsCumulativeSquareThingCount = new uint16[columCount];
 	}
 	for (uint16 i = 0; i < columCount; ++i)
-		_g280_dungeonColumnsCumulativeSquareThingCount[i] = dunDataStream->readUint16BE();
+		_dungeonColumnsCumulativeSquareThingCount[i] = dunDataStream->readUint16BE();
 
 	// load square first things
 	if (!_vm->_restartGameRequest) {
-		delete[] _g283_squareFirstThings;
-		_g283_squareFirstThings = new Thing[_g278_dungeonFileHeader._squareFirstThingCount];
+		delete[] _squareFirstThings;
+		_squareFirstThings = new Thing[_dungeonFileHeader._squareFirstThingCount];
 	}
 
 	for (uint16 i = 0; i < actualSquareFirstThingCount; ++i)
-		_g283_squareFirstThings[i].set(dunDataStream->readUint16BE());
+		_squareFirstThings[i].set(dunDataStream->readUint16BE());
 
 	if (_vm->_newGameFl) {
 		for (uint16 i = 0; i < 300; ++i)
-			_g283_squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none;
+			_squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none;
 	}
 
 	// load text data
 	if (!_vm->_restartGameRequest) {
-		delete[] _g260_dungeonTextData;
-		_g260_dungeonTextData = new uint16[_g278_dungeonFileHeader._textDataWordCount];
+		delete[] _dungeonTextData;
+		_dungeonTextData = new uint16[_dungeonFileHeader._textDataWordCount];
 	}
 
-	for (uint16 i = 0; i < _g278_dungeonFileHeader._textDataWordCount; ++i)
-		_g260_dungeonTextData[i] = dunDataStream->readUint16BE();
+	for (uint16 i = 0; i < _dungeonFileHeader._textDataWordCount; ++i)
+		_dungeonTextData[i] = dunDataStream->readUint16BE();
 
 	if (_vm->_newGameFl)
 		_vm->_timeline->_g369_eventMaxCount = 100;
 
 	// load things
 	for (uint16 thingType = k0_DoorThingType; thingType < k16_ThingTypeTotal; ++thingType) {
-		uint16 thingCount = _g278_dungeonFileHeader._thingCounts[thingType];
+		uint16 thingCount = _dungeonFileHeader._thingCounts[thingType];
 		if (_vm->_newGameFl)
-			_g278_dungeonFileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + additionalThingCounts[thingType]);
+			_dungeonFileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + additionalThingCounts[thingType]);
 
 		uint16 thingStoreWordCount = g235_ThingDataWordCount[thingType];
 
@@ -686,13 +686,13 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 			continue;
 
 		if (!_vm->_restartGameRequest) {
-			delete[] _g284_thingData[thingType];
-			_g284_thingData[thingType] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount];
+			delete[] _thingData[thingType];
+			_thingData[thingType] = new uint16[_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount];
 		}
 
 		if ((thingType == k4_GroupThingType || thingType == k14_ProjectileThingType) && !file) { // !file because save files have diff. structure than dungeon.dat 
 			for (uint16 i = 0; i < thingCount; ++i) {
-				uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount;
+				uint16 *nextSlot = _thingData[thingType] + i *thingStoreWordCount;
 				for (uint16 j = 0; j < thingStoreWordCount; ++j) {
 					if (j == 2 || j == 3)
 						nextSlot[j] = dunDataStream->readByte();
@@ -702,7 +702,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 			}
 		} else {
 			for (uint16 i = 0; i < thingCount; ++i) {
-				uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount;
+				uint16 *nextSlot = _thingData[thingType] + i *thingStoreWordCount;
 				for (uint16 j = 0; j < thingStoreWordCount; ++j)
 					nextSlot[j] = dunDataStream->readUint16BE();
 			}
@@ -710,33 +710,33 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 
 		if (_vm->_newGameFl) {
 			if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType)
-				_vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType];
+				_vm->_timeline->_g369_eventMaxCount += _dungeonFileHeader._thingCounts[thingType];
 
 			for (uint16 i = 0; i < additionalThingCounts[thingType]; ++i)
-				(_g284_thingData[thingType] + (thingCount + i) * thingStoreWordCount)[0] = Thing::_none.toUint16();
+				(_thingData[thingType] + (thingCount + i) * thingStoreWordCount)[0] = Thing::_none.toUint16();
 		}
 	}
 
 	// load map data
 	if (!_vm->_restartGameRequest) {
-		delete[] _g276_dungeonRawMapData;
-		_g276_dungeonRawMapData = new byte[_g278_dungeonFileHeader._rawMapDataSize];
+		delete[] _dungeonRawMapData;
+		_dungeonRawMapData = new byte[_dungeonFileHeader._rawMapDataSize];
 	}
 
-	for (uint32 i = 0; i < _g278_dungeonFileHeader._rawMapDataSize; ++i)
-		_g276_dungeonRawMapData[i] = dunDataStream->readByte();
+	for (uint32 i = 0; i < _dungeonFileHeader._rawMapDataSize; ++i)
+		_dungeonRawMapData[i] = dunDataStream->readByte();
 
 	if (!_vm->_restartGameRequest) {
-		uint8 mapCount = _g278_dungeonFileHeader._mapCount;
-		delete[] _g279_dungeonMapData;
-		_g279_dungeonMapData = new byte**[_g282_dungeonColumCount + mapCount];
-		byte **colFirstSquares = (byte**)_g279_dungeonMapData + mapCount;
+		uint8 mapCount = _dungeonFileHeader._mapCount;
+		delete[] _dungeonMapData;
+		_dungeonMapData = new byte**[_dungeonColumCount + mapCount];
+		byte **colFirstSquares = (byte**)_dungeonMapData + mapCount;
 		for (uint8 i = 0; i < mapCount; ++i) {
-			_g279_dungeonMapData[i] = colFirstSquares;
-			byte *square = _g276_dungeonRawMapData + _g277_dungeonMaps[i]._rawDunDataOffset;
+			_dungeonMapData[i] = colFirstSquares;
+			byte *square = _dungeonRawMapData + _dungeonMaps[i]._rawDunDataOffset;
 			*colFirstSquares++ = square;
-			for (uint16 w = 1; w <= _g277_dungeonMaps[i]._width; ++w) {
-				square += _g277_dungeonMaps[i]._height + 1;
+			for (uint16 w = 1; w <= _dungeonMaps[i]._width; ++w) {
+				square += _dungeonMaps[i]._height + 1;
 				*colFirstSquares++ = square;
 			}
 		}
@@ -747,7 +747,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) {
 	} // the deletion of the function parameter 'file' happens elsewhere
 }
 
-void DungeonMan::f173_setCurrentMap(uint16 mapIndex) {
+void DungeonMan::setCurrentMap(uint16 mapIndex) {
 	static const DoorInfo doorInfo[4] = { // @ G0254_as_Graphic559_DoorInfo
 		/* { Attributes, Defense } */
 		DoorInfo(3, 110),   /* Door type 0 Portcullis */
@@ -757,76 +757,76 @@ void DungeonMan::f173_setCurrentMap(uint16 mapIndex) {
 	};
 
 
-	_g272_currMapIndex = mapIndex;
-	_g271_currMapData = _g279_dungeonMapData[mapIndex];
-	_g269_currMap = _g277_dungeonMaps + mapIndex;
-	_g273_currMapWidth = _g277_dungeonMaps[mapIndex]._width + 1;
-	_g274_currMapHeight = _g277_dungeonMaps[mapIndex]._height + 1;
-	_g275_currMapDoorInfo[0] = doorInfo[_g269_currMap->_doorSet0];
-	_g275_currMapDoorInfo[1] = doorInfo[_g269_currMap->_doorSet1];
-	_g270_currMapColCumulativeSquareFirstThingCount = &_g280_dungeonColumnsCumulativeSquareThingCount[_g281_dungeonMapsFirstColumnIndex[mapIndex]];
+	_currMapIndex = mapIndex;
+	_currMapData = _dungeonMapData[mapIndex];
+	_currMap = _dungeonMaps + mapIndex;
+	_currMapWidth = _dungeonMaps[mapIndex]._width + 1;
+	_currMapHeight = _dungeonMaps[mapIndex]._height + 1;
+	_currMapDoorInfo[0] = doorInfo[_currMap->_doorSet0];
+	_currMapDoorInfo[1] = doorInfo[_currMap->_doorSet1];
+	_currMapColCumulativeSquareFirstThingCount = &_dungeonColumnsCumulativeSquareThingCount[_dungeonMapsFirstColumnIndex[mapIndex]];
 }
 
-void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) {
-	f173_setCurrentMap(_g309_partyMapIndex = mapIndex);
+void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) {
+	setCurrentMap(_partyMapIndex = mapIndex);
 
-	byte *metaMapData = _g271_currMapData[_g273_currMapWidth - 1] + _g274_currMapHeight;
+	byte *metaMapData = _currMapData[_currMapWidth - 1] + _currMapHeight;
 
 	_vm->_displayMan->_g264_currMapAllowedCreatureTypes = metaMapData;
-	metaMapData += _g269_currMap->_creatureTypeCount;
+	metaMapData += _currMap->_creatureTypeCount;
 
-	memcpy(_vm->_displayMan->_g261_currMapWallOrnIndices, metaMapData, _g269_currMap->_wallOrnCount);
-	metaMapData += _g269_currMap->_wallOrnCount;
+	memcpy(_vm->_displayMan->_g261_currMapWallOrnIndices, metaMapData, _currMap->_wallOrnCount);
+	metaMapData += _currMap->_wallOrnCount;
 
-	memcpy(_vm->_displayMan->_g262_currMapFloorOrnIndices, metaMapData, _g269_currMap->_floorOrnCount);
-	metaMapData += _g269_currMap->_floorOrnCount;
+	memcpy(_vm->_displayMan->_g262_currMapFloorOrnIndices, metaMapData, _currMap->_floorOrnCount);
+	metaMapData += _currMap->_floorOrnCount;
 
-	memcpy(_vm->_displayMan->_g263_currMapDoorOrnIndices, metaMapData, _g269_currMap->_doorOrnCount);
+	memcpy(_vm->_displayMan->_g263_currMapDoorOrnIndices, metaMapData, _currMap->_doorOrnCount);
 
-	_g265_currMapInscriptionWallOrnIndex = _g269_currMap->_wallOrnCount;
-	_vm->_displayMan->_g261_currMapWallOrnIndices[_g265_currMapInscriptionWallOrnIndex] = k0_WallOrnInscription;
+	_currMapInscriptionWallOrnIndex = _currMap->_wallOrnCount;
+	_vm->_displayMan->_g261_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = k0_WallOrnInscription;
 }
 
 
-Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) {
-	bool isMapYInBounds = (mapY >= 0) && (mapY < _g274_currMapHeight);
-	bool isMapXInBounds = (mapX >= 0) && (mapX < _g273_currMapWidth);
+Square DungeonMan::getSquare(int16 mapX, int16 mapY) {
+	bool isMapYInBounds = (mapY >= 0) && (mapY < _currMapHeight);
+	bool isMapXInBounds = (mapX >= 0) && (mapX < _currMapWidth);
 
 	if (isMapXInBounds && isMapYInBounds)
-		return Square(_g271_currMapData[mapX][mapY]);
+		return Square(_currMapData[mapX][mapY]);
 
 	if (isMapYInBounds) {
-		SquareType squareType = Square(_g271_currMapData[0][mapY]).getType();
+		SquareType squareType = Square(_currMapData[0][mapY]).getType();
 		if (((mapX == -1) && (squareType == k1_CorridorElemType)) || (squareType == k2_PitElemType))
 			return Square(k0_ElementTypeWall, k0x0004_WallEastRandOrnAllowed);
 
-		squareType = Square(_g271_currMapData[_g273_currMapWidth - 1][mapY]).getType();
-		if (((mapX == _g273_currMapWidth) && (squareType == k1_CorridorElemType)) || (squareType == k2_PitElemType))
+		squareType = Square(_currMapData[_currMapWidth - 1][mapY]).getType();
+		if (((mapX == _currMapWidth) && (squareType == k1_CorridorElemType)) || (squareType == k2_PitElemType))
 			return Square(k0_ElementTypeWall, k0x0001_WallWestRandOrnAllowed);
 	} else if (isMapXInBounds) {
-		SquareType squareType = Square(_g271_currMapData[mapX][0]).getType();
+		SquareType squareType = Square(_currMapData[mapX][0]).getType();
 		if (((mapY == -1) && (squareType == k1_CorridorElemType)) || (squareType == k2_PitElemType))
 			return Square(k0_ElementTypeWall, k0x0002_WallSouthRandOrnAllowed);
 
-		squareType = Square(_g271_currMapData[mapX][_g274_currMapHeight - 1]).getType();
-		if (((mapY == _g274_currMapHeight) && (squareType == k1_CorridorElemType)) || (squareType == k2_PitElemType))
+		squareType = Square(_currMapData[mapX][_currMapHeight - 1]).getType();
+		if (((mapY == _currMapHeight) && (squareType == k1_CorridorElemType)) || (squareType == k2_PitElemType))
 			return Square(k0_ElementTypeWall, k0x0008_WallNorthRandOrnAllowed);
 	}
 	return Square(k0_ElementTypeWall, 0);
 }
 
-Square DungeonMan::f152_getRelSquare(Direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
-	f150_mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY);
-	return f151_getSquare(posX, posY);
+Square DungeonMan::getRelSquare(Direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
+	mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY);
+	return getSquare(posX, posY);
 }
 
-int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) {
-	unsigned char *curSquare = _g271_currMapData[mapX];
-	if ((mapX < 0) || (mapX >= _g273_currMapWidth) || (mapY < 0) || (mapY >= _g274_currMapHeight) || !getFlag(curSquare[mapY], k0x0010_ThingListPresent))
+int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) {
+	unsigned char *curSquare = _currMapData[mapX];
+	if ((mapX < 0) || (mapX >= _currMapWidth) || (mapY < 0) || (mapY >= _currMapHeight) || !getFlag(curSquare[mapY], k0x0010_ThingListPresent))
 		return -1;
 
 	int16 curMapY = 0;
-	uint16 thingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
+	uint16 thingIndex = _currMapColCumulativeSquareFirstThingCount[mapX];
 	while (curMapY++ != mapY) {
 		if (getFlag(*curSquare++, k0x0010_ThingListPresent))
 			thingIndex++;
@@ -834,14 +834,14 @@ int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) {
 	return thingIndex;
 }
 
-Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) {
-	int16 index = f160_getSquareFirstThingIndex(mapX, mapY);
+Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) {
+	int16 index = getSquareFirstThingIndex(mapX, mapY);
 	if (index == -1)
 		return Thing::_endOfList;
-	return _g283_squareFirstThings[index];
+	return _squareFirstThings[index];
 }
 
-void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX, int16 mapY) {	
+void DungeonMan::setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX, int16 mapY) {	
 	unsigned char L0307_uc_Multiple;
 #define AL0307_uc_Square            L0307_uc_Multiple
 #define AL0307_uc_FootprintsAllowed L0307_uc_Multiple
@@ -850,8 +850,8 @@ void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, Direction dir, int16
 	for (uint16 i = 0; i < 5; ++i)
 		aspectArray[i] = 0;
 
-	Thing curThing = f161_getSquareFirstThing(mapX, mapY);
-	AL0307_uc_Square = f151_getSquare(mapX, mapY).toByte();
+	Thing curThing = getSquareFirstThing(mapX, mapY);
+	AL0307_uc_Square = getSquare(mapX, mapY).toByte();
 	bool leftRandomWallOrnamentAllowed = false;
 	bool rightRandomWallOrnamentAllowed = false;
 	bool frontRandomWallOrnamentAllowed = false;
@@ -887,27 +887,27 @@ void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, Direction dir, int16
 		_vm->_displayMan->_g289_championPortraitOrdinal = 0; 
 		squareIsFakeWall = false;
 T0172010_ClosedFakeWall:
-		f171_setSquareAspectOrnOrdinals(aspectArray, leftRandomWallOrnamentAllowed, frontRandomWallOrnamentAllowed, rightRandomWallOrnamentAllowed, dir, mapX, mapY, squareIsFakeWall);
+		setSquareAspectOrnOrdinals(aspectArray, leftRandomWallOrnamentAllowed, frontRandomWallOrnamentAllowed, rightRandomWallOrnamentAllowed, dir, mapX, mapY, squareIsFakeWall);
 		while ((curThing != Thing::_endOfList) && (curThing.getType() <= k3_SensorThingType)) {
 			ThingType curThingType = curThing.getType();
 			int16 AL0310_i_SideIndex = normalizeModulo4(curThing.getCell() - dir);
 			if (AL0310_i_SideIndex) { /* Invisible on the back wall if 0 */
-				Sensor *curSensor = (Sensor*)f156_getThingData(curThing);
+				Sensor *curSensor = (Sensor*)getThingData(curThing);
 				if (curThingType == k2_TextstringType) {
 					if (((TextString*)curSensor)->isVisible()) {
-						aspectArray[AL0310_i_SideIndex + 1] = _g265_currMapInscriptionWallOrnIndex + 1;
+						aspectArray[AL0310_i_SideIndex + 1] = _currMapInscriptionWallOrnIndex + 1;
 						_vm->_displayMan->_g290_inscriptionThing = curThing; /* BUG0_76 The same text is drawn on multiple sides of a wall square. The engine stores only a single text to draw on a wall in a global variable. Even if different texts are placed on different sides of the wall, the same text is drawn on each affected side */
 					}
 				} else {
-					aspectArray[AL0310_i_SideIndex + 1] = curSensor->getOrnOrdinal();
+					aspectArray[AL0310_i_SideIndex + 1] = curSensor->getAttrOrnOrdinal();
 					if (curSensor->getType() == k127_SensorWallChampionPortrait) {
 						_vm->_displayMan->_g289_championPortraitOrdinal = _vm->indexToOrdinal(curSensor->getData());
 					}
 				}
 			}
-			curThing = f159_getNextThing(curThing);
+			curThing = getNextThing(curThing);
 		}
-		if (squareIsFakeWall && (_g306_partyMapX != mapX) && (_g307_partyMapY != mapY)) {
+		if (squareIsFakeWall && (_partyMapX != mapX) && (_partyMapY != mapY)) {
 			aspectArray[k1_FirstGroupOrObjectAspect] = Thing::_endOfList.toUint16();
 			return;
 		}
@@ -926,7 +926,7 @@ T0172010_ClosedFakeWall:
 	case k2_ElementTypePit:
 	case k5_ElementTypeTeleporter:
 		if (aspectArray[k0_ElementAspect] == k1_CorridorElemType) {
-			aspectArray[k4_FloorOrnOrdAspect] = f170_getRandomOrnOrdinal(getFlag(AL0307_uc_Square, k0x0008_CorridorRandOrnAllowed), _g269_currMap->_randFloorOrnCount, mapX, mapY, 30);
+			aspectArray[k4_FloorOrnOrdAspect] = getRandomOrnOrdinal(getFlag(AL0307_uc_Square, k0x0008_CorridorRandOrnAllowed), _currMap->_randFloorOrnCount, mapX, mapY, 30);
 			AL0307_uc_FootprintsAllowed = true;
 		} else if (aspectArray[k0_ElementAspect] == k2_ElementTypePit) {
 			if (getFlag(AL0307_uc_Square, k0x0008_PitOpen)) {
@@ -943,10 +943,10 @@ T0172010_ClosedFakeWall:
 
 		while ((curThing != Thing::_endOfList) && (curThing.getType() <= k3_SensorThingType)) {
 			if (curThing.getType() == k3_SensorThingType) {
-				Sensor *curSensor = (Sensor*)f156_getThingData(curThing);
-				aspectArray[k4_FloorOrnOrdAspect] = curSensor->getOrnOrdinal();
+				Sensor *curSensor = (Sensor*)getThingData(curThing);
+				aspectArray[k4_FloorOrnOrdAspect] = curSensor->getAttrOrnOrdinal();
 			}
-			curThing = f159_getNextThing(curThing);
+			curThing = getNextThing(curThing);
 		}
 
 		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapX, mapY)) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_party._lastScentIndex))
@@ -958,7 +958,7 @@ T0172010_ClosedFakeWall:
 		aspectArray[k2_StairsUpAspect] = getFlag(AL0307_uc_Square, k0x0004_StairsUp);
 		AL0307_uc_FootprintsAllowed = false;
 		while ((curThing != Thing::_endOfList) && (curThing.getType() <= k3_SensorThingType))
-			curThing = f159_getNextThing(curThing);
+			curThing = getNextThing(curThing);
 		break;
 	case k4_DoorElemType:
 		if (bool((getFlag(AL0307_uc_Square, k0x0008_DoorNorthSouthOrient) >> 3)) == isOrientedWestEast(dir)) {
@@ -966,12 +966,12 @@ T0172010_ClosedFakeWall:
 		} else {
 			aspectArray[k0_ElementAspect] = k17_DoorFrontElemType;
 			aspectArray[k2_DoorStateAspect] = Square(AL0307_uc_Square).getDoorState();
-			aspectArray[k3_DoorThingIndexAspect] = f161_getSquareFirstThing(mapX, mapY).getIndex();
+			aspectArray[k3_DoorThingIndexAspect] = getSquareFirstThing(mapX, mapY).getIndex();
 		}
 		AL0307_uc_FootprintsAllowed = true;
 
 		while ((curThing != Thing::_endOfList) && (curThing.getType() <= k3_SensorThingType))
-			curThing = f159_getNextThing(curThing);
+			curThing = getNextThing(curThing);
 
 		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapX, mapY)) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_party._lastScentIndex))
 			setFlag(aspectArray[k4_FloorOrnOrdAspect], k0x8000_FootprintsAspect);
@@ -980,23 +980,23 @@ T0172010_ClosedFakeWall:
 	aspectArray[k1_FirstGroupOrObjectAspect] = curThing.toUint16();
 }
 
-void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir,
+void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir,
 												 int16 mapX, int16 mapY, bool isFakeWall) {
 
-	int16 randomWallOrnamentCount = _g269_currMap->_randWallOrnCount;
-	aspectArray[k2_RightWallOrnOrdAspect] = f170_getRandomOrnOrdinal(leftAllowed, randomWallOrnamentCount, mapX, ++mapY * (normalizeModulo4(++dir) + 1), 30);
-	aspectArray[k3_FrontWallOrnOrdAspect] = f170_getRandomOrnOrdinal(frontAllowed, randomWallOrnamentCount, mapX, mapY * (normalizeModulo4(++dir) + 1), 30);
-	aspectArray[k4_LeftWallOrnOrdAspect] = f170_getRandomOrnOrdinal(rightAllowed, randomWallOrnamentCount, mapX, mapY-- * (normalizeModulo4(++dir) + 1), 30);
-	if (isFakeWall || (mapX < 0) || (mapX >= _g273_currMapWidth) || (mapY < 0) || (mapY >= _g274_currMapHeight)) { /* If square is a fake wall or is out of map bounds */
+	int16 randomWallOrnamentCount = _currMap->_randWallOrnCount;
+	aspectArray[k2_RightWallOrnOrdAspect] = getRandomOrnOrdinal(leftAllowed, randomWallOrnamentCount, mapX, ++mapY * (normalizeModulo4(++dir) + 1), 30);
+	aspectArray[k3_FrontWallOrnOrdAspect] = getRandomOrnOrdinal(frontAllowed, randomWallOrnamentCount, mapX, mapY * (normalizeModulo4(++dir) + 1), 30);
+	aspectArray[k4_LeftWallOrnOrdAspect] = getRandomOrnOrdinal(rightAllowed, randomWallOrnamentCount, mapX, mapY-- * (normalizeModulo4(++dir) + 1), 30);
+	if (isFakeWall || (mapX < 0) || (mapX >= _currMapWidth) || (mapY < 0) || (mapY >= _currMapHeight)) { /* If square is a fake wall or is out of map bounds */
 		for (int16 sideIndex = k2_RightWallOrnOrdAspect; sideIndex <= k4_LeftWallOrnOrdAspect; sideIndex++) { /* Loop to remove any random ornament that is an alcove */
-			if (f149_isWallOrnAnAlcove(_vm->ordinalToIndex(aspectArray[sideIndex])))
+			if (isWallOrnAnAlcove(_vm->ordinalToIndex(aspectArray[sideIndex])))
 				aspectArray[sideIndex] = 0;
 		}
 	}
 }
 
-int16 DungeonMan::f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) {
-	int16 randomOrnamentIndex = f169_getRandomOrnamentIndex((int16)2000 + (mapX << 5) + mapY, (int16)3000 + (_g272_currMapIndex << (int16)6) + _g273_currMapWidth + _g274_currMapHeight, modulo);
+int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) {
+	int16 randomOrnamentIndex = getRandomOrnamentIndex((int16)2000 + (mapX << 5) + mapY, (int16)3000 + (_currMapIndex << (int16)6) + _currMapWidth + _currMapHeight, modulo);
 
 	if (allowed && (randomOrnamentIndex < count))
 		return _vm->indexToOrdinal(randomOrnamentIndex);
@@ -1005,7 +1005,7 @@ int16 DungeonMan::f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX
 }
 
 
-bool DungeonMan::f149_isWallOrnAnAlcove(int16 wallOrnIndex) {
+bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) {
 	if (wallOrnIndex >= 0) {
 		for (uint16 i = 0; i < k3_AlcoveOrnCount; ++i) {
 			if (_vm->_displayMan->_g267_currMapAlcoveOrnIndices[i] == wallOrnIndex)
@@ -1016,19 +1016,19 @@ bool DungeonMan::f149_isWallOrnAnAlcove(int16 wallOrnIndex) {
 	return false;
 }
 
-uint16 *DungeonMan::f156_getThingData(Thing thing) {
-	return _g284_thingData[thing.getType()] + thing.getIndex() * g235_ThingDataWordCount[thing.getType()];
+uint16 *DungeonMan::getThingData(Thing thing) {
+	return _thingData[thing.getType()] + thing.getIndex() * g235_ThingDataWordCount[thing.getType()];
 }
 
-uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) {
-	return f156_getThingData(f161_getSquareFirstThing(mapX, mapY));
+uint16* DungeonMan::getSquareFirstThingData(int16 mapX, int16 mapY) {
+	return getThingData(getSquareFirstThing(mapX, mapY));
 }
 
-Thing DungeonMan::f159_getNextThing(Thing thing) {
-	return Thing(f156_getThingData(thing)[0]);
+Thing DungeonMan::getNextThing(Thing thing) {
+	return Thing(getThingData(thing)[0]);
 }
 
-void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) {
+void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 	static char messageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings
 		{'x',   0,   0,   0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '?',  0,  0,  0, 0, 0, 0, 0 }, */
 		{'y',   0,   0,   0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '!',  0,  0,  0, 0, 0, 0, 0 }, */
@@ -1110,7 +1110,7 @@ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) {
 		{0,   0,  0,  0, 0, 0, 0, 0}
 	};
 
-	TextString textString(_g284_thingData[k2_TextstringType] + thing.getIndex() * g235_ThingDataWordCount[k2_TextstringType]);
+	TextString textString(_thingData[k2_TextstringType] + thing.getIndex() * g235_ThingDataWordCount[k2_TextstringType]);
 	if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) {
 		type = (TextType)(type & ~k0x8000_DecodeEvenIfInvisible);
 		char sepChar;
@@ -1124,7 +1124,7 @@ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) {
 		}
 		uint16 codeCounter = 0;
 		int16 escChar = 0;
-		uint16 *codeWord = _g260_dungeonTextData + textString.getWordOffset();
+		uint16 *codeWord = _dungeonTextData + textString.getWordOffset();
 		uint16 code = 0, codes = 0;
 		char *escReplString = nullptr;
 		for (;;) { /*infinite loop*/
@@ -1173,8 +1173,8 @@ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) {
 	*destString = ((type == k0_TextTypeInscription) ? 0x81 : '\0');
 }
 
-Thing DungeonMan::f166_getUnusedThing(uint16 thingType) {
-	int16 thingCount = _g278_dungeonFileHeader._thingCounts[getFlag(thingType, k0x7FFF_thingType)];
+Thing DungeonMan::getUnusedThing(uint16 thingType) {
+	int16 thingCount = _dungeonFileHeader._thingCounts[getFlag(thingType, k0x7FFF_thingType)];
 	if (thingType == (k0x8000_championBones | k10_JunkThingType)) {
 		thingType = k10_JunkThingType;
 	} else if (thingType == k10_JunkThingType)
@@ -1182,7 +1182,7 @@ Thing DungeonMan::f166_getUnusedThing(uint16 thingType) {
 
 	int16 thingIdx = thingCount;
 	int16 thingDataByteCount = g235_ThingDataWordCount[thingType] >> 1;
-	Thing *thingPtr = (Thing *)_g284_thingData[thingType];
+	Thing *thingPtr = (Thing *)_thingData[thingType];
 
 	Thing curThing;
 	for (;;) { /*_Infinite loop_*/
@@ -1193,11 +1193,11 @@ Thing DungeonMan::f166_getUnusedThing(uint16 thingType) {
 		if (--thingIdx) { /* If there are thing data left to process */
 			thingPtr += thingDataByteCount; /* Proceed to the next thing data */
 		} else {
-			curThing = f165_getDiscardThing(thingType);
+			curThing = getDiscardThing(thingType);
 			if (curThing == Thing::_none)
 				return Thing::_none;
 
-			thingPtr = (Thing *)f156_getThingData(curThing);
+			thingPtr = (Thing *)getThingData(curThing);
 			break;
 		}
 	}
@@ -1207,7 +1207,7 @@ Thing DungeonMan::f166_getUnusedThing(uint16 thingType) {
 	return curThing;
 }
 
-uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
+uint16 DungeonMan::getObjectWeight(Thing thing) {
 	static const uint16 junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo
 		// COMPASS - WATERSKIN - JEWEL SYMAL - ILLUMULET - ASHES
 		1, 3, 2, 2, 4,
@@ -1239,7 +1239,7 @@ uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 	// Initialization is not present in original
 	// Set to 0 by default as it's the default value used for Thing::_none
 	uint16 weight = 0;
-	Junk *junk = (Junk *)f156_getThingData(thing);
+	Junk *junk = (Junk *)getThingData(thing);
 
 	switch (thing.getType()) {
 	case k5_WeaponThingType:
@@ -1258,8 +1258,8 @@ uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 		weight = 50;
 		thing = ((Container*)junk)->getSlot();
 		while (thing != Thing::_endOfList) {
-			weight += f140_getObjectWeight(thing);
-			thing = f159_getNextThing(thing);
+			weight += getObjectWeight(thing);
+			thing = getNextThing(thing);
 		}
 		break;
 	case k8_PotionThingType:
@@ -1278,8 +1278,8 @@ uint16 DungeonMan::f140_getObjectWeight(Thing thing) {
 	return weight; // this is garbage if none of the branches were taken
 }
 
-int16 DungeonMan::f141_getObjectInfoIndex(Thing thing) {
-	uint16 *rawType = f156_getThingData(thing);
+int16 DungeonMan::getObjectInfoIndex(Thing thing) {
+	uint16 *rawType = getThingData(thing);
 	switch (thing.getType()) {
 	case k7_ScrollThingType:
 		return k0_ObjectInfoIndexFirstScroll;
@@ -1298,54 +1298,54 @@ int16 DungeonMan::f141_getObjectInfoIndex(Thing thing) {
 	}
 }
 
-void DungeonMan::f163_linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) {
+void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) {
 	if (thingToLink == Thing::_endOfList)
 		return;
 
-	Thing *thingPtr = (Thing *)f156_getThingData(thingToLink);
+	Thing *thingPtr = (Thing *)getThingData(thingToLink);
 	*thingPtr = Thing::_endOfList;
 	/* If mapX >= 0 then the thing is linked to the list of things on the specified square else it is linked at the end of the specified thing list */
 	if (mapX >= 0) {
-		byte *currSquare = &_g271_currMapData[mapX][mapY];
+		byte *currSquare = &_currMapData[mapX][mapY];
 		if (getFlag(*currSquare, k0x0010_ThingListPresent)) {
-			thingInList = f161_getSquareFirstThing(mapX, mapY);
+			thingInList = getSquareFirstThing(mapX, mapY);
 		} else {
 			setFlag(*currSquare, k0x0010_ThingListPresent);
-			uint16 * tmp = _g270_currMapColCumulativeSquareFirstThingCount + mapX + 1;
-			uint16 currColumn = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1;
+			uint16 * tmp = _currMapColCumulativeSquareFirstThingCount + mapX + 1;
+			uint16 currColumn = _dungeonColumCount - (_dungeonMapsFirstColumnIndex[_currMapIndex] + mapX) - 1;
 			while (currColumn--) { /* For each column starting from and after the column containing the square where the thing is added */
 				(*tmp++)++; /* Increment the cumulative first thing count */
 			}
 			uint16 currMapY = 0;
 			currSquare -= mapY;
-			uint16 currSquareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX];
+			uint16 currSquareFirstThingIndex = _currMapColCumulativeSquareFirstThingCount[mapX];
 			while (currMapY++ != mapY) {
 				if (getFlag(*currSquare++, k0x0010_ThingListPresent))
 					currSquareFirstThingIndex++;
 			}
-			Thing *currThing = &_g283_squareFirstThings[currSquareFirstThingIndex];
+			Thing *currThing = &_squareFirstThings[currSquareFirstThingIndex];
 			// the second '- 1' is for the loop initialization, > 0 is because we are copying from one behind
-			for (int16 i = _g278_dungeonFileHeader._squareFirstThingCount - currSquareFirstThingIndex - 1 - 1; i > 0; --i)
+			for (int16 i = _dungeonFileHeader._squareFirstThingCount - currSquareFirstThingIndex - 1 - 1; i > 0; --i)
 				currThing[i] = currThing[i - 1];
 
 			*currThing = thingToLink;
 			return;
 		}
 	}
-	Thing nextThing = f159_getNextThing(thingInList);
+	Thing nextThing = getNextThing(thingInList);
 	while (nextThing != Thing::_endOfList)
-		nextThing = f159_getNextThing(thingInList = nextThing);
+		nextThing = getNextThing(thingInList = nextThing);
 
-	thingPtr = (Thing *)f156_getThingData(thingInList);
+	thingPtr = (Thing *)getThingData(thingInList);
 	*thingPtr = thingToLink;
 }
 
-WeaponInfo* DungeonMan::f158_getWeaponInfo(Thing thing) {
-	Weapon* weapon = (Weapon*)f156_getThingData(thing);
+WeaponInfo* DungeonMan::getWeaponInfo(Thing thing) {
+	Weapon* weapon = (Weapon*)getThingData(thing);
 	return &_weaponInfo[weapon->getType()];
 }
 
-int16 DungeonMan::f142_getProjectileAspect(Thing thing) {
+int16 DungeonMan::getProjectileAspect(Thing thing) {
 	ThingType thingType = thing.getType();
 	if (thingType == k15_ExplosionThingType) {
 		if (thing == Thing::_explFireBall)
@@ -1359,26 +1359,26 @@ int16 DungeonMan::f142_getProjectileAspect(Thing thing) {
 
 		return -_vm->indexToOrdinal(k11_ProjectileAspectExplosionDefault);
 	} else if (thingType == k5_WeaponThingType) {
-		WeaponInfo *weaponInfo = f158_getWeaponInfo(thing);
+		WeaponInfo *weaponInfo = getWeaponInfo(thing);
 		int16 projAspOrd = weaponInfo->getProjectileAspectOrdinal();
 		if (projAspOrd)
 			return -projAspOrd;
 	}
 
-	return _objectInfo[f141_getObjectInfoIndex(thing)]._objectAspectIndex;
+	return _objectInfo[getObjectInfoIndex(thing)]._objectAspectIndex;
 }
 
-int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16* mapX, int16* mapY) {
-	if (_g309_partyMapIndex == k255_mapIndexEntrance)
+int16 DungeonMan::getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16* mapX, int16* mapY) {
+	if (_partyMapIndex == k255_mapIndexEntrance)
 		return kM1_mapIndexNone;
 
-	Map *map = _g277_dungeonMaps + mapIndex;
+	Map *map = _dungeonMaps + mapIndex;
 	int16 newMapX = map->_offsetMapX + *mapX;
 	int16 newMapY = map->_offsetMapY + *mapY;
 	int16 newLevel = map->_level + levelDelta;
-	map = _g277_dungeonMaps;
+	map = _dungeonMaps;
 
-	for (int16 targetMapIndex = 0; targetMapIndex < _g278_dungeonFileHeader._mapCount; targetMapIndex++) {
+	for (int16 targetMapIndex = 0; targetMapIndex < _dungeonFileHeader._mapCount; targetMapIndex++) {
 		if ((map->_level == newLevel)
 		&& (newMapX >= map->_offsetMapX) && (newMapX <= map->_offsetMapX + map->_width)
 		&& (newMapY >= map->_offsetMapY) && (newMapY <= map->_offsetMapY + map->_height)) {
@@ -1391,15 +1391,15 @@ int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDe
 	return kM1_mapIndexNone;
 }
 
-Thing DungeonMan::f162_getSquareFirstObject(int16 mapX, int16 mapY) {
-	Thing thing = f161_getSquareFirstThing(mapX, mapY);
+Thing DungeonMan::getSquareFirstObject(int16 mapX, int16 mapY) {
+	Thing thing = getSquareFirstThing(mapX, mapY);
 	while ((thing != Thing::_endOfList) && (thing.getType() < k4_GroupThingType))
-		thing = f159_getNextThing(thing);
+		thing = getNextThing(thing);
 
 	return thing;
 }
 
-uint16 DungeonMan::f143_getArmourDefense(ArmourInfo* armourInfo, bool useSharpDefense) {
+uint16 DungeonMan::getArmourDefense(ArmourInfo* armourInfo, bool useSharpDefense) {
 	uint16 defense = armourInfo->_defense;
 	if (useSharpDefense)
 		defense = _vm->getScaledProduct(defense, 3, getFlag(armourInfo->_attributes, k0x0007_ArmourAttributeSharpDefense) + 4);
@@ -1407,52 +1407,52 @@ uint16 DungeonMan::f143_getArmourDefense(ArmourInfo* armourInfo, bool useSharpDe
 	return defense;
 }
 
-Thing DungeonMan::f165_getDiscardThing(uint16 thingType) {
+Thing DungeonMan::getDiscardThing(uint16 thingType) {
 	// CHECKME: Shouldn't it be saved in the savegames?
 	static unsigned char lastDiscardedThingMapIndex[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
 	if (thingType == k15_ExplosionThingType)
 		return Thing::_none;
 
-	int16 currentMapIdx = _g272_currMapIndex;
+	int16 currentMapIdx = _currMapIndex;
 	uint16 mapIndex = lastDiscardedThingMapIndex[thingType];
-	if ((mapIndex == _g309_partyMapIndex) && (++mapIndex >= _g278_dungeonFileHeader._mapCount))
+	if ((mapIndex == _partyMapIndex) && (++mapIndex >= _dungeonFileHeader._mapCount))
 		mapIndex = 0;
 
 	uint16 discardThingMapIndex = mapIndex;
 	for (;;) { /*_Infinite loop_*/
-		uint16 mapWidth = _g277_dungeonMaps[mapIndex]._width;
-		uint16 mapHeight = _g277_dungeonMaps[mapIndex]._height;
-		byte *currSquare = _g279_dungeonMapData[mapIndex][0];
-		Thing *squareFirstThing = &_g283_squareFirstThings[_g280_dungeonColumnsCumulativeSquareThingCount[_g281_dungeonMapsFirstColumnIndex[mapIndex]]];
+		uint16 mapWidth = _dungeonMaps[mapIndex]._width;
+		uint16 mapHeight = _dungeonMaps[mapIndex]._height;
+		byte *currSquare = _dungeonMapData[mapIndex][0];
+		Thing *squareFirstThing = &_squareFirstThings[_dungeonColumnsCumulativeSquareThingCount[_dungeonMapsFirstColumnIndex[mapIndex]]];
 		
 		for (int16 currMapX = 0; currMapX <= mapWidth; currMapX++) {
 			for (int16 currMapY = 0; currMapY <= mapHeight; currMapY++) {
 				if (getFlag(*currSquare++, k0x0010_ThingListPresent)) {
 					Thing squareThing = *squareFirstThing++;
-					if ((mapIndex == _g309_partyMapIndex) && ((currMapX - _g306_partyMapX + 5) <= 10) && ((currMapY - _g307_partyMapY + 5) <= 10)) /* If square is too close to the party */
+					if ((mapIndex == _partyMapIndex) && ((currMapX - _partyMapX + 5) <= 10) && ((currMapY - _partyMapY + 5) <= 10)) /* If square is too close to the party */
 						continue;
 
 					do {
 						ThingType squareThingType = squareThing.getType();
 						if (squareThingType == k3_SensorThingType) {
-							Thing *squareThingData = (Thing*)f156_getThingData(squareThing);
+							Thing *squareThingData = (Thing*)getThingData(squareThing);
 							if (((Sensor*)squareThingData)->getType()) /* If sensor is not disabled */
 								break;
 						} else if (squareThingType == thingType) {
-							Thing *squareThingData = (Thing*)f156_getThingData(squareThing);
+							Thing *squareThingData = (Thing*)getThingData(squareThing);
 							switch (thingType) {
 							case k4_GroupThingType:
 								if (((Group*)squareThingData)->getDoNotDiscard())
 									continue;
 							case k14_ProjectileThingType:
-								f173_setCurrentMap(mapIndex);
+								setCurrentMap(mapIndex);
 								if (thingType == k4_GroupThingType) {
 									_vm->_groupMan->f188_dropGroupPossessions(currMapX, currMapY, squareThing, kM1_soundModeDoNotPlaySound);
 									_vm->_groupMan->f189_delete(currMapX, currMapY);
 								} else {
 									_vm->_projexpl->f214_projectileDeleteEvent(squareThing);
-									f164_unlinkThingFromList(squareThing, Thing(0), currMapX, currMapY);
+									unlinkThingFromList(squareThing, Thing(0), currMapX, currMapY);
 									_vm->_projexpl->f215_projectileDelete(squareThing, 0, currMapX, currMapY);
 								}
 								break;
@@ -1460,77 +1460,77 @@ Thing DungeonMan::f165_getDiscardThing(uint16 thingType) {
 								if (((Armour*)squareThingData)->getDoNotDiscard())
 									continue;
 
-								f173_setCurrentMap(mapIndex);
+								setCurrentMap(mapIndex);
 								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
 								break;
 							case k5_WeaponThingType:
 								if (((Weapon*)squareThingData)->getDoNotDiscard())
 									continue;
 
-								f173_setCurrentMap(mapIndex);
+								setCurrentMap(mapIndex);
 								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
 								break;
 							case k10_JunkThingType:
 								if (((Junk*)squareThingData)->getDoNotDiscard())
 									continue;
 
-								f173_setCurrentMap(mapIndex);
+								setCurrentMap(mapIndex);
 								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
 								break;
 							case k8_PotionThingType:
 								if (((Potion*)squareThingData)->getDoNotDiscard())
 									continue;
 
-								f173_setCurrentMap(mapIndex);
+								setCurrentMap(mapIndex);
 								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
 								break;
 							}
-							f173_setCurrentMap(currentMapIdx);
+							setCurrentMap(currentMapIdx);
 							lastDiscardedThingMapIndex[thingType] = mapIndex;
 							return Thing(squareThing.getTypeAndIndex());
 						}
-					} while ((squareThing = f159_getNextThing(squareThing)) != Thing::_endOfList);
+					} while ((squareThing = getNextThing(squareThing)) != Thing::_endOfList);
 				}
 			}
 		}
-		if ((mapIndex == _g309_partyMapIndex) || (_g278_dungeonFileHeader._mapCount <= 1)) {
+		if ((mapIndex == _partyMapIndex) || (_dungeonFileHeader._mapCount <= 1)) {
 			lastDiscardedThingMapIndex[thingType] = mapIndex;
 			return Thing::_none;
 		}
 
 		do {
-			if (++mapIndex >= _g278_dungeonFileHeader._mapCount)
+			if (++mapIndex >= _dungeonFileHeader._mapCount)
 				mapIndex = 0;
-		} while (mapIndex == _g309_partyMapIndex);
+		} while (mapIndex == _partyMapIndex);
 
 		if (mapIndex == discardThingMapIndex)
-			mapIndex = _g309_partyMapIndex;
+			mapIndex = _partyMapIndex;
 	}
 }
 
-uint16 DungeonMan::f144_getCreatureAttributes(Thing thing) {
-	Group *currGroup = (Group *)f156_getThingData(thing);
+uint16 DungeonMan::getCreatureAttributes(Thing thing) {
+	Group *currGroup = (Group *)getThingData(thing);
 	return g243_CreatureInfo[currGroup->_type]._attributes;
 }
 
-void DungeonMan::f146_setGroupCells(Group* group, uint16 cells, uint16 mapIndex) {
-	if (mapIndex == _g309_partyMapIndex)
+void DungeonMan::setGroupCells(Group* group, uint16 cells, uint16 mapIndex) {
+	if (mapIndex == _partyMapIndex)
 		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._cells = cells;
 	else
 		group->_cells = cells;
 }
 
-void DungeonMan::f148_setGroupDirections(Group* group, int16 dir, uint16 mapIndex) {
-	if (mapIndex == _g309_partyMapIndex)
+void DungeonMan::setGroupDirections(Group* group, int16 dir, uint16 mapIndex) {
+	if (mapIndex == _partyMapIndex)
 		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (Direction)dir;
 	else
 		group->setDir(normalizeModulo4(dir));
 }
 
-bool DungeonMan::f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) {
-	int16 creatureType = ((Group*)f156_getThingData(thing))->_type;
-	Map *map = &_g277_dungeonMaps[mapIndex];
-	byte *allowedCreatureType = _g279_dungeonMapData[mapIndex][map->_width] + map->_height + 1;
+bool DungeonMan::isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) {
+	int16 creatureType = ((Group*)getThingData(thing))->_type;
+	Map *map = &_dungeonMaps[mapIndex];
+	byte *allowedCreatureType = _dungeonMapData[mapIndex][map->_width] + map->_height + 1;
 	for (int16 L0234_i_Counter = map->_creatureTypeCount; L0234_i_Counter > 0; L0234_i_Counter--) {
 		if (*allowedCreatureType++ == creatureType)
 			return true;
@@ -1538,7 +1538,7 @@ bool DungeonMan::f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) {
 	return false;
 }
 
-void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY) {
+void DungeonMan::unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY) {
 	if (thingToUnlink == Thing::_endOfList)
 		return;
 
@@ -1548,18 +1548,18 @@ void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList
 
 	Thing *thingPtr = nullptr;
 	if (mapX >= 0) {
-		thingPtr = (Thing*)f156_getThingData(thingToUnlink);
-		uint16 firstThingIndex = f160_getSquareFirstThingIndex(mapX, mapY);
-		Thing *currThing = &_g283_squareFirstThings[firstThingIndex]; /* BUG0_01 Coding error without consequence. The engine does not check that there are things at the specified square coordinates. f160_getSquareFirstThingIndex would return -1 for an empty square. No consequence as the function is never called with the coordinates of an empty square (except in the case of BUG0_59) */
+		thingPtr = (Thing*)getThingData(thingToUnlink);
+		uint16 firstThingIndex = getSquareFirstThingIndex(mapX, mapY);
+		Thing *currThing = &_squareFirstThings[firstThingIndex]; /* BUG0_01 Coding error without consequence. The engine does not check that there are things at the specified square coordinates. f160_getSquareFirstThingIndex would return -1 for an empty square. No consequence as the function is never called with the coordinates of an empty square (except in the case of BUG0_59) */
 		if ((*thingPtr == Thing::_endOfList) && (((Thing*)currThing)->getTypeAndIndex() == thingToUnlink.toUint16())) { /* If the thing to unlink is the last thing on the square */
-			clearFlag(_g271_currMapData[mapX][mapY], k0x0010_ThingListPresent);
-			uint16 squareFirstThingIdx = _g278_dungeonFileHeader._squareFirstThingCount - 1;
+			clearFlag(_currMapData[mapX][mapY], k0x0010_ThingListPresent);
+			uint16 squareFirstThingIdx = _dungeonFileHeader._squareFirstThingCount - 1;
 			for (uint16 i = 0; i < squareFirstThingIdx - firstThingIndex; ++i)
 				currThing[i] = currThing[i + 1];
 
-			_g283_squareFirstThings[squareFirstThingIdx] = Thing::_none;
-			uint16 *cumulativeFirstThingCount = _g270_currMapColCumulativeSquareFirstThingCount + mapX + 1;
-			uint16 currColumn = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1;
+			_squareFirstThings[squareFirstThingIdx] = Thing::_none;
+			uint16 *cumulativeFirstThingCount = _currMapColCumulativeSquareFirstThingCount + mapX + 1;
+			uint16 currColumn = _dungeonColumCount - (_dungeonMapsFirstColumnIndex[_currMapIndex] + mapX) - 1;
 			while (currColumn--) { /* For each column starting from and after the column containing the square where the thing is unlinked */
 				(*cumulativeFirstThingCount++)--; /* Decrement the cumulative first thing count */
 			}
@@ -1574,22 +1574,22 @@ void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList
 		thingInList = *currThing;
 	}
 
-	Thing currThing = f159_getNextThing(thingInList);
+	Thing currThing = getNextThing(thingInList);
 	while (currThing.getTypeAndIndex() != thingToUnlink.toUint16()) {
 		if ((currThing == Thing::_endOfList) || (currThing == Thing::_none)) {
 			*thingPtr = Thing::_endOfList;
 			return;
 		}
-		currThing = f159_getNextThing(thingInList = currThing);
+		currThing = getNextThing(thingInList = currThing);
 	}
-	thingPtr = (Thing*)f156_getThingData(thingInList);
-	*thingPtr = f159_getNextThing(currThing);
-	thingPtr = (Thing*)f156_getThingData(thingToUnlink);
+	thingPtr = (Thing*)getThingData(thingInList);
+	*thingPtr = getNextThing(currThing);
+	thingPtr = (Thing*)getThingData(thingToUnlink);
 	*thingPtr = Thing::_endOfList;
 }
 
-int16 DungeonMan::f155_getStairsExitDirection(int16 mapX, int16 mapY) {
-	bool northSouthOrientedStairs = !getFlag(f151_getSquare(mapX, mapY).toByte(), k0x0008_StairsNorthSouthOrient);
+int16 DungeonMan::getStairsExitDirection(int16 mapX, int16 mapY) {
+	bool northSouthOrientedStairs = !getFlag(getSquare(mapX, mapY).toByte(), k0x0008_StairsNorthSouthOrient);
 
 	if (northSouthOrientedStairs) {
 		mapX = mapX + _vm->_dirIntoStepCountEast[kDirEast];
@@ -1598,7 +1598,7 @@ int16 DungeonMan::f155_getStairsExitDirection(int16 mapX, int16 mapY) {
 		mapX = mapX + _vm->_dirIntoStepCountEast[kDirNorth];
 		mapY = mapY + _vm->_dirIntoStepCountNorth[kDirNorth];
 	}
-	int16 squareType = Square(f151_getSquare(mapX, mapY)).getType();
+	int16 squareType = Square(getSquare(mapX, mapY)).getType();
 
 	int16 retval = ((squareType == k0_ElementTypeWall) || (squareType == k3_ElementTypeStairs)) ? 1 : 0;
 	retval <<= 1;
@@ -1607,7 +1607,7 @@ int16 DungeonMan::f155_getStairsExitDirection(int16 mapX, int16 mapY) {
 	return retval;
 }
 
-Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {
+Thing DungeonMan::getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {
 	int16 thingType = k5_WeaponThingType;
 	if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit))
 		iconIndex = k4_IconIndiceWeaponTorchUnlit;
@@ -1644,11 +1644,11 @@ Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {
 		return Thing::_none;
 	}
 
-	Thing unusedThing = f166_getUnusedThing(thingType);
+	Thing unusedThing = getUnusedThing(thingType);
 	if (unusedThing == Thing::_none)
 		return Thing::_none;
 
-	Junk *junkPtr = (Junk*)f156_getThingData(unusedThing);
+	Junk *junkPtr = (Junk*)getThingData(unusedThing);
 	junkPtr->setType(junkType); /* Also works for WEAPON in cases other than Boulder */
 	if ((iconIndex == k4_IconIndiceWeaponTorchUnlit) && ((Weapon*)junkPtr)->isLit()) /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */
 		((Weapon*)junkPtr)->setChargeCount(15);
@@ -1656,10 +1656,10 @@ Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {
 	return unusedThing;
 }
 
-int16 DungeonMan::f169_getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo) {
+int16 DungeonMan::getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo) {
 	// TODO: Use ScummVM random number generator
 	return ((((((val1 * 31417) & 0xFFFF) >> 1) + ((val2 * 11) & 0xFFFF)
-			  + _g278_dungeonFileHeader._ornamentRandomSeed) & 0xFFFF) >> 2) % modulo; /* Pseudorandom number generator */
+			  + _dungeonFileHeader._ornamentRandomSeed) & 0xFFFF) >> 2) % modulo; /* Pseudorandom number generator */
 }
 
 }
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index ce90dc1..1f52614 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -315,22 +315,22 @@ public:
 	void setData(uint16 dat) { _datAndType = dat; } // @ M41_SET_DATA
 	void setTypeDisabled() { _datAndType &= 0xFF80; } // @ M44_SET_TYPE_DISABLED
 
-	bool getOnlyOnce() { return (_attributes >> 2) & 1; }
-	uint16 getEffectA() { return (_attributes >> 3) & 0x3; }
-	bool getRevertEffectA() { return (_attributes >> 5) & 0x1; }
-	bool getAudibleA() { return (_attributes >> 6) & 0x1; }
-	uint16 getValue() { return (_attributes >> 7) & 0xF; }
-	bool getLocalEffect() { return (_attributes >> 11) & 1; }
-	uint16 getOrnOrdinal() { return _attributes >> 12; }
-
-	uint16 getTargetMapY() { return (_action >> 11); }
-	uint16 getTargetMapX() { return (_action >> 6) & 0x1F; }
-	Direction getTargetCell() { return (Direction)((_action >> 4) & 3); }
-	uint16 getHealthMultiplier() { return ((_action >> 4) & 0xF); } // @ M45_HEALTH_MULTIPLIER
-	uint16 M46_ticks() { return ((_action >> 4) >> 4) & 0xFFF; } // @ M46_TICKS
-	uint16 M47_kineticEnergy() { return ((_action >> 4) & 0xFF); }// @ M47_KINETIC_ENERGY
-	uint16 M48_stepEnergy() { return ((_action >> 4) >> 8) & 0xFF; }// @ M48_STEP_ENERGY
-	uint16 M49_localEffect() { return (_action >> 4); } // @ M49_LOCAL_EFFECT
+	bool getAttrOnlyOnce() { return (_attributes >> 2) & 1; }
+	uint16 getAttrEffectA() { return (_attributes >> 3) & 0x3; }
+	bool getAttrRevertEffectA() { return (_attributes >> 5) & 0x1; }
+	bool getAttrAudibleA() { return (_attributes >> 6) & 0x1; }
+	uint16 getAttrValue() { return (_attributes >> 7) & 0xF; }
+	bool getAttrLocalEffect() { return (_attributes >> 11) & 1; }
+	uint16 getAttrOrnOrdinal() { return _attributes >> 12; }
+
+	uint16 getActionTargetMapY() { return (_action >> 11); }
+	uint16 getActionTargetMapX() { return (_action >> 6) & 0x1F; }
+	Direction getActionTargetCell() { return (Direction)((_action >> 4) & 3); }
+	uint16 getActionHealthMultiplier() { return ((_action >> 4) & 0xF); } // @ M45_HEALTH_MULTIPLIER
+	uint16 getActionTicks() { return ((_action >> 4) >> 4) & 0xFFF; } // @ M46_TICKS
+	uint16 getActionKineticEnergy() { return ((_action >> 4) & 0xFF); }// @ M47_KINETIC_ENERGY
+	uint16 getActionStepEnergy() { return ((_action >> 4) >> 8) & 0xFF; }// @ M48_STEP_ENERGY
+	uint16 getActionLocalEffect() { return (_action >> 4); } // @ M49_LOCAL_EFFECT
 
 	void setDatAndTypeWithOr(uint16 val) { _datAndType |= val;  }
 
@@ -339,7 +339,6 @@ public:
 
 #define k0x8000_randomDrop 0x8000 // @ MASK0x8000_RANDOM_DROP 
 
-
 enum WeaponType {
 	k2_WeaponTypeTorch = 2, // @ C02_WEAPON_TORCH
 	k8_WeaponTypeDagger = 8, // @ C08_WEAPON_DAGGER
@@ -646,98 +645,92 @@ class DungeonMan {
 	DungeonMan(const DungeonMan &other); // no implementation on purpose
 	void operator=(const DungeonMan &rhs); // no implementation on purpose
 
-	Square f152_getRelSquare(Direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare
+	Square getRelSquare(Direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare
 
-	void f455_decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon
+	void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon
 
-	int16 f160_getSquareFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex
+	int16 getSquareFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex
 
-	int16 f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal
-	void f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir,
+	int16 getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal
+	void setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir,
 										 int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals
 
-
 public:
 	explicit DungeonMan(DMEngine *dmEngine);
 	~DungeonMan();
 
-	Square f151_getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare
-	void f173_setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
-	Thing f161_getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing
-	Thing f159_getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing)
-	uint16 *f156_getThingData(Thing thing); // @ F0156_DUNGEON_GetThingData
-	uint16 *f157_getSquareFirstThingData(int16 mapX, int16 mapY); // @ F0157_DUNGEON_GetSquareFirstThingData
+	Square getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare
+	void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
+	Thing getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing
+	Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing)
+	uint16 *getThingData(Thing thing); // @ F0156_DUNGEON_GetThingData
+	uint16 *getSquareFirstThingData(int16 mapX, int16 mapY); // @ F0157_DUNGEON_GetSquareFirstThingData
 
 	// TODO: this does stuff other than load the file!
-	void f434_loadDungeonFile(Common::InSaveFile *file);	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
-	void f174_setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap
+	void loadDungeonFile(Common::InSaveFile *file);	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
+	void setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap
 
-	bool f149_isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove
-	void f150_mapCoordsAfterRelMovement(Direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement
-	SquareType f153_getRelSquareType(Direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
-		return Square(f152_getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType();
+	bool isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove
+	void mapCoordsAfterRelMovement(Direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement
+	SquareType getRelSquareType(Direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
+		return Square(getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType();
 	} // @ F0153_DUNGEON_GetRelativeSquareType
-	void f172_setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect
-	void f168_decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText
-	Thing f166_getUnusedThing(uint16 thingType); // @ F0166_DUNGEON_GetUnusedThing
-
-
-	uint16 f140_getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight
-	int16 f141_getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex
-	void f163_linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY); // @ F0163_DUNGEON_LinkThingToList
-	WeaponInfo *f158_getWeaponInfo(Thing thing); // @ F0158_DUNGEON_GetWeaponInfo
-	int16 f142_getProjectileAspect(Thing thing); // @ F0142_DUNGEON_GetProjectileAspect
-	int16 f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16 *mapX, int16 *mapY); // @ F0154_DUNGEON_GetLocationAfterLevelChange
-	Thing f162_getSquareFirstObject(int16 mapX, int16 mapY); // @ F0162_DUNGEON_GetSquareFirstObject
-	uint16 f143_getArmourDefense(ArmourInfo *armourInfo, bool useSharpDefense); // @ F0143_DUNGEON_GetArmourDefense
-	Thing f165_getDiscardThing(uint16 thingType); // @ F0165_DUNGEON_GetDiscardedThing
-	uint16 f144_getCreatureAttributes(Thing thing); // @ F0144_DUNGEON_GetCreatureAttributes
-	void f146_setGroupCells(Group *group, uint16 cells, uint16 mapIndex); // @ F0146_DUNGEON_SetGroupCells
-	void f148_setGroupDirections(Group *group, int16 dir, uint16 mapIndex); // @ F0148_DUNGEON_SetGroupDirections
-	bool f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex); // @ F0139_DUNGEON_IsCreatureAllowedOnMap
-	void f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY); // @ F0164_DUNGEON_UnlinkThingFromList
-	int16 f155_getStairsExitDirection(int16 mapX, int16 mapY); // @ F0155_DUNGEON_GetStairsExitDirection
-	Thing f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex); // @ F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator
-	int16 f169_getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo); // @ F0169_DUNGEON_GetRandomOrnamentIndex
-
+	void setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect
+	void decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText
+	Thing getUnusedThing(uint16 thingType); // @ F0166_DUNGEON_GetUnusedThing
+
+	uint16 getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight
+	int16 getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex
+	void linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY); // @ F0163_DUNGEON_LinkThingToList
+	WeaponInfo *getWeaponInfo(Thing thing); // @ F0158_DUNGEON_GetWeaponInfo
+	int16 getProjectileAspect(Thing thing); // @ F0142_DUNGEON_GetProjectileAspect
+	int16 getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16 *mapX, int16 *mapY); // @ F0154_DUNGEON_GetLocationAfterLevelChange
+	Thing getSquareFirstObject(int16 mapX, int16 mapY); // @ F0162_DUNGEON_GetSquareFirstObject
+	uint16 getArmourDefense(ArmourInfo *armourInfo, bool useSharpDefense); // @ F0143_DUNGEON_GetArmourDefense
+	Thing getDiscardThing(uint16 thingType); // @ F0165_DUNGEON_GetDiscardedThing
+	uint16 getCreatureAttributes(Thing thing); // @ F0144_DUNGEON_GetCreatureAttributes
+	void setGroupCells(Group *group, uint16 cells, uint16 mapIndex); // @ F0146_DUNGEON_SetGroupCells
+	void setGroupDirections(Group *group, int16 dir, uint16 mapIndex); // @ F0148_DUNGEON_SetGroupDirections
+	bool isCreatureAllowedOnMap(Thing thing, uint16 mapIndex); // @ F0139_DUNGEON_IsCreatureAllowedOnMap
+	void unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY); // @ F0164_DUNGEON_UnlinkThingFromList
+	int16 getStairsExitDirection(int16 mapX, int16 mapY); // @ F0155_DUNGEON_GetStairsExitDirection
+	Thing getObjForProjectileLaucherOrObjGen(uint16 iconIndex); // @ F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator
+	int16 getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo); // @ F0169_DUNGEON_GetRandomOrnamentIndex
 
 	uint32 _rawDunFileDataSize;	 // @ probably NONE
 	byte *_rawDunFileData; // @ ???
-	DungeonFileHeader _g278_dungeonFileHeader; // @ G0278_ps_DungeonHeader
-
-
-	uint16 *_g281_dungeonMapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex
-	uint16 _g282_dungeonColumCount; // @ G0282_ui_DungeonColumnCount
-	uint16 *_g280_dungeonColumnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
-	Thing *_g283_squareFirstThings; // @ G0283_pT_SquareFirstThings
-	uint16 *_g260_dungeonTextData; // @ G0260_pui_DungeonTextData
-	uint16 *_g284_thingData[16]; // @ G0284_apuc_ThingData
-	byte ***_g279_dungeonMapData; // @ G0279_pppuc_DungeonMapData
-
-
-	Direction _g308_partyDir; // @ G0308_i_PartyDirection
-	int16 _g306_partyMapX; // @ G0306_i_PartyMapX
-	int16 _g307_partyMapY; // @ G0307_i_PartyMapY
-	uint8 _g309_partyMapIndex; // @ G0309_i_PartyMapIndex
-	int16 _g272_currMapIndex; // @ G0272_i_CurrentMapIndex
-	byte **_g271_currMapData; // @ G0271_ppuc_CurrentMapData
-	Map *_g269_currMap; // @ G0269_ps_CurrentMap
-	uint16 _g273_currMapWidth; // @ G0273_i_CurrentMapWidth
-	uint16 _g274_currMapHeight; // @ G0274_i_CurrentMapHeight
-	uint16 *_g270_currMapColCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount
-
-
-	Map *_g277_dungeonMaps; // @ G0277_ps_DungeonMaps
-	byte *_g276_dungeonRawMapData; // @ G0276_puc_DungeonRawMapData
-
-	int16 _g265_currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex
-	Box _g291_dungeonViewClickableBoxes[6]; // G0291_aauc_DungeonViewClickableBoxes
-	bool _g286_isFacingAlcove; // @ G0286_B_FacingAlcove
-	bool _g287_isFacingViAltar; // @ G0287_B_FacingViAltar
-	bool _g288_isFacingFountain; // @ G0288_B_FacingFountain
-	ElementType _g285_squareAheadElement; // @ G0285_i_SquareAheadElement 
-	Thing _g292_pileTopObject[5]; // @ G0292_aT_PileTopObject
-	DoorInfo _g275_currMapDoorInfo[2]; // @ G0275_as_CurrentMapDoorInfo
+	DungeonFileHeader _dungeonFileHeader; // @ G0278_ps_DungeonHeader
+
+	uint16 *_dungeonMapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex
+	uint16 _dungeonColumCount; // @ G0282_ui_DungeonColumnCount
+	uint16 *_dungeonColumnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
+	Thing *_squareFirstThings; // @ G0283_pT_SquareFirstThings
+	uint16 *_dungeonTextData; // @ G0260_pui_DungeonTextData
+	uint16 *_thingData[16]; // @ G0284_apuc_ThingData
+	byte ***_dungeonMapData; // @ G0279_pppuc_DungeonMapData
+
+	Direction _partyDir; // @ G0308_i_PartyDirection
+	int16 _partyMapX; // @ G0306_i_PartyMapX
+	int16 _partyMapY; // @ G0307_i_PartyMapY
+	uint8 _partyMapIndex; // @ G0309_i_PartyMapIndex
+	int16 _currMapIndex; // @ G0272_i_CurrentMapIndex
+	byte **_currMapData; // @ G0271_ppuc_CurrentMapData
+	Map *_currMap; // @ G0269_ps_CurrentMap
+	uint16 _currMapWidth; // @ G0273_i_CurrentMapWidth
+	uint16 _currMapHeight; // @ G0274_i_CurrentMapHeight
+	uint16 *_currMapColCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount
+
+	Map *_dungeonMaps; // @ G0277_ps_DungeonMaps
+	byte *_dungeonRawMapData; // @ G0276_puc_DungeonRawMapData
+
+	int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex
+	Box _dungeonViewClickableBoxes[6]; // G0291_aauc_DungeonViewClickableBoxes
+	bool _isFacingAlcove; // @ G0286_B_FacingAlcove
+	bool _isFacingViAltar; // @ G0287_B_FacingViAltar
+	bool _isFacingFountain; // @ G0288_B_FacingFountain
+	ElementType _squareAheadElement; // @ G0285_i_SquareAheadElement 
+	Thing _pileTopObject[5]; // @ G0292_aT_PileTopObject
+	DoorInfo _currMapDoorInfo[2]; // @ G0275_as_CurrentMapDoorInfo
 	
 	ObjectInfo _objectInfo[180]; // @ G0237_as_Graphic559_ObjectInfo
 	ArmourInfo _armourInfo[58]; // @ G0239_as_Graphic559_ArmourInfo
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index dbf8c1b..b5dfccc 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -728,7 +728,7 @@ void EventManager::f380_processCommandQueue() {
 
 	Command cmd = _commandQueue.pop();
 	CommandType cmdType = cmd._type;
-	if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft) && (_vm->_disabledMovementTicks || (_vm->_projectileDisableMovementTicks && (_vm->_lastProjectileDisabledMovementDirection == (normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + cmdType - k3_CommandMoveForward)))))) { /* If movement is disabled */
+	if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft) && (_vm->_disabledMovementTicks || (_vm->_projectileDisableMovementTicks && (_vm->_lastProjectileDisabledMovementDirection == (normalizeModulo4(_vm->_dungeonMan->_partyDir + cmdType - k3_CommandMoveForward)))))) { /* If movement is disabled */
 		_g435_isCommandQueueLocked = false;
 		f360_processPendingClick();
 		return;
@@ -934,15 +934,15 @@ void EventManager::f365_commandTurnParty(CommandType cmdType) {
 	else
 		f362_commandHighlightBoxEnable(291, 318, 125, 145);
 
-	uint16 partySquare = _vm->_dungeonMan->f151_getSquare(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY).toByte();
+	uint16 partySquare = _vm->_dungeonMan->getSquare(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY).toByte();
 	if (Square(partySquare).getType() == k3_StairsElemType) {
 		f364_commandTakeStairs(getFlag(partySquare, k0x0004_StairsUp));
 		return;
 	}
 
-	_vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, false);
-	_vm->_championMan->setPartyDirection(normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + ((cmdType == k2_CommandTurnRight) ? 1 : 3)));
-	_vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, true);
+	_vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, Thing::_party, true, false);
+	_vm->_championMan->setPartyDirection(normalizeModulo4(_vm->_dungeonMan->_partyDir + ((cmdType == k2_CommandTurnRight) ? 1 : 3)));
+	_vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, Thing::_party, true, true);
 }
 
 void EventManager::f366_commandMoveParty(CommandType cmdType) {
@@ -977,20 +977,20 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	uint16 movementArrowIdx = cmdType - k3_CommandMoveForward;
 	Box *highlightBox = &boxMovementArrows[movementArrowIdx];
 	f362_commandHighlightBoxEnable(highlightBox->_x1, highlightBox->_x2, highlightBox->_y1, highlightBox->_y2);
-	int16 partyMapX = _vm->_dungeonMan->_g306_partyMapX;
-	int16 partyMapY = _vm->_dungeonMan->_g307_partyMapY;
-	uint16 AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(partyMapX, partyMapY).toByte();
+	int16 partyMapX = _vm->_dungeonMan->_partyMapX;
+	int16 partyMapY = _vm->_dungeonMan->_partyMapY;
+	uint16 AL1115_ui_Square = _vm->_dungeonMan->getSquare(partyMapX, partyMapY).toByte();
 	bool isStairsSquare = (Square(AL1115_ui_Square).getType() == k3_StairsElemType);
 	if (isStairsSquare && (movementArrowIdx == 2)) { /* If moving backward while in stairs */
 		f364_commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp));
 		return;
 	}
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(_vm->_dungeonMan->_g308_partyDir, movementArrowToStepForwardCount[movementArrowIdx], movementArrowToSepRightCount[movementArrowIdx], partyMapX, partyMapY);
-	int16 partySquareType = Square(AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(partyMapX, partyMapY).toByte()).getType();
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(_vm->_dungeonMan->_partyDir, movementArrowToStepForwardCount[movementArrowIdx], movementArrowToSepRightCount[movementArrowIdx], partyMapX, partyMapY);
+	int16 partySquareType = Square(AL1115_ui_Square = _vm->_dungeonMan->getSquare(partyMapX, partyMapY).toByte()).getType();
 	if (partySquareType == k3_ElementTypeStairs) {
-		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0);
-		_vm->_dungeonMan->_g306_partyMapX = partyMapX;
-		_vm->_dungeonMan->_g307_partyMapY = partyMapY;
+		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kM1_MapXNotOnASquare, 0);
+		_vm->_dungeonMan->_partyMapX = partyMapX;
+		_vm->_dungeonMan->_partyMapY = partyMapY;
 		f364_commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp));
 		return;
 	}
@@ -1006,7 +1006,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 
 	if (_vm->_championMan->_partyChampionCount) {
 		if (isMovementBlocked) {
-			movementArrowIdx += (_vm->_dungeonMan->_g308_partyDir + 2);
+			movementArrowIdx += (_vm->_dungeonMan->_partyDir + 2);
 			int16 L1124_i_FirstDamagedChampionIndex = _vm->_championMan->getTargetChampionIndex(partyMapX, partyMapY, normalizeModulo4(movementArrowIdx));
 			int16 L1125_i_SecondDamagedChampionIndex = _vm->_championMan->getTargetChampionIndex(partyMapX, partyMapY, returnNextVal(movementArrowIdx));
 			int16 damage = _vm->_championMan->addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
@@ -1032,7 +1032,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	if (isStairsSquare)
 		_vm->_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, partyMapX, partyMapY);
 	else
-		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, partyMapX, partyMapY);
+		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, partyMapX, partyMapY);
 
 	uint16 disabledMovtTicks = 1;
 	championsPtr = _vm->_championMan->_champions;
@@ -1055,7 +1055,7 @@ bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int
 
 	bool objectThrownFl;
 	if (posX <= 111) {
-		if (_vm->_dungeonMan->_g285_squareAheadElement == k17_ElementTypeDoorFront) {
+		if (_vm->_dungeonMan->_squareAheadElement == k17_ElementTypeDoorFront) {
 			if (posX < 64)
 				return false;
 		} else if (posX < 32)
@@ -1064,7 +1064,7 @@ bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int
 		// Strangerke: Only present in CSB2.1... But it fixes a bug so we keep it
 		objectThrownFl = _vm->_championMan->isLeaderHandObjectThrown(k0_sideLeft);
 	} else {
-		if (_vm->_dungeonMan->_g285_squareAheadElement == k17_ElementTypeDoorFront) {
+		if (_vm->_dungeonMan->_squareAheadElement == k17_ElementTypeDoorFront) {
 			if (posX > 163)
 				return false;
 		} else if (posX > 191)
@@ -1112,7 +1112,7 @@ void EventManager::f368_commandSetLeader(ChampionIndex champIndex) {
 		leaderIndex = cm._leaderIndex;
 		cm._champions[leaderIndex].setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
 		cm._champions[leaderIndex].setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
-		cm._champions[leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(cm._leaderHandObject);
+		cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject);
 		cm._leaderIndex = kM1_ChampionNone;
 		cm.drawChampionState(leaderIndex);
 	}
@@ -1122,8 +1122,8 @@ void EventManager::f368_commandSetLeader(ChampionIndex champIndex) {
 	}
 	cm._leaderIndex = champIndex;
 	Champion *champion = &cm._champions[cm._leaderIndex];
-	champion->_dir = _vm->_dungeonMan->_g308_partyDir;
-	cm._champions[champIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(cm._leaderHandObject);
+	champion->_dir = _vm->_dungeonMan->_partyDir;
+	cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject);
 	if (_vm->indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) {
 		champion->setAttributeFlag(k0x0400_ChampionAttributeIcon, true);
 		champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
@@ -1132,12 +1132,12 @@ void EventManager::f368_commandSetLeader(ChampionIndex champIndex) {
 }
 
 void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() {
-	uint16 mapX = _vm->_dungeonMan->_g306_partyMapX + _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir];
-	uint16 mapY = _vm->_dungeonMan->_g307_partyMapY + _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+	uint16 mapX = _vm->_dungeonMan->_partyMapX + _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir];
+	uint16 mapY = _vm->_dungeonMan->_partyMapY + _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
 
-	if ((mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth)
-		&& (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight))
-		_vm->_stopWaitingForPlayerInput = _vm->_moveSens->f275_sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(_vm->_dungeonMan->_g308_partyDir));
+	if ((mapX >= 0) && (mapX < _vm->_dungeonMan->_currMapWidth)
+		&& (mapY >= 0) && (mapY < _vm->_dungeonMan->_currMapHeight))
+		_vm->_stopWaitingForPlayerInput = _vm->_moveSens->f275_sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(_vm->_dungeonMan->_partyDir));
 }
 
 void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16 posY) {
@@ -1149,18 +1149,18 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 		Box(40, 111, 122, 147)    /* Back left */
 	};
 
-	if (_vm->_dungeonMan->_g285_squareAheadElement == k17_ElementTypeDoorFront) {
+	if (_vm->_dungeonMan->_squareAheadElement == k17_ElementTypeDoorFront) {
 		if (_vm->_championMan->_leaderIndex == kM1_ChampionNone)
 			return;
 
-		int16 L1155_i_MapX = _vm->_dungeonMan->_g306_partyMapX + _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir];
-		int16 L1156_i_MapY = _vm->_dungeonMan->_g307_partyMapY + _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+		int16 L1155_i_MapX = _vm->_dungeonMan->_partyMapX + _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir];
+		int16 L1156_i_MapY = _vm->_dungeonMan->_partyMapY + _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
 
 		if (_vm->_championMan->_leaderEmptyHanded) {
-			Junk *junkPtr = (Junk*)_vm->_dungeonMan->f157_getSquareFirstThingData(L1155_i_MapX, L1156_i_MapY);
-			if ((((Door*)junkPtr)->hasButton()) && _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
+			Junk *junkPtr = (Junk*)_vm->_dungeonMan->getSquareFirstThingData(L1155_i_MapX, L1156_i_MapY);
+			if ((((Door*)junkPtr)->hasButton()) && _vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
 				_vm->_stopWaitingForPlayerInput = true;
-				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 				_vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_gameTime + 1);
 				return;
 			}
@@ -1170,9 +1170,9 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 
 	if (_vm->_championMan->_leaderEmptyHanded) {
 		for (uint16 currViewCell = k0_ViewCellFronLeft; currViewCell < k5_ViewCellDoorButtonOrWallOrn + 1; currViewCell++) {
-			if (_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[currViewCell].isPointInside(posX, posY - 33)) {
+			if (_vm->_dungeonMan->_dungeonViewClickableBoxes[currViewCell].isPointInside(posX, posY - 33)) {
 				if (currViewCell == k5_ViewCellDoorButtonOrWallOrn) {
-					if (!_vm->_dungeonMan->_g286_isFacingAlcove)
+					if (!_vm->_dungeonMan->_isFacingAlcove)
 						f372_commandProcessType80ClickInDungeonViewTouchFrontWall();
 				} else
 					f373_processType80_clickInDungeonView_grabLeaderHandObject(currViewCell);
@@ -1182,21 +1182,21 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 		}
 	} else {
 		Thing thingHandObject = _vm->_championMan->_leaderHandObject;
-		Junk *junkPtr = (Junk*)_vm->_dungeonMan->f156_getThingData(thingHandObject);
-		if (_vm->_dungeonMan->_g285_squareAheadElement == k0_ElementTypeWall) {
+		Junk *junkPtr = (Junk*)_vm->_dungeonMan->getThingData(thingHandObject);
+		if (_vm->_dungeonMan->_squareAheadElement == k0_ElementTypeWall) {
 			for (uint16 currViewCell = k0_ViewCellFronLeft; currViewCell < k1_ViewCellFrontRight + 1; currViewCell++) {
 				if (boxObjectPiles[currViewCell].isPointInside(posX, posY)) {
 					f374_processType80_clickInDungeonViewDropLeaderHandObject(currViewCell);
 					return;
 				}
 			}
-			if (_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
-				if (_vm->_dungeonMan->_g286_isFacingAlcove)
+			if (_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
+				if (_vm->_dungeonMan->_isFacingAlcove)
 					f374_processType80_clickInDungeonViewDropLeaderHandObject(k4_ViewCellAlcove);
 				else {
-					if (_vm->_dungeonMan->_g288_isFacingFountain) {
+					if (_vm->_dungeonMan->_isFacingFountain) {
 						uint16 iconIdx = _vm->_objectMan->f33_getIconIndex(thingHandObject);
-						uint16 weight = _vm->_dungeonMan->f140_getObjectWeight(thingHandObject);
+						uint16 weight = _vm->_dungeonMan->getObjectWeight(thingHandObject);
 						if ((iconIdx >= k8_IconIndiceJunkWater) && (iconIdx <= k9_IconIndiceJunkWaterSkin))
 							junkPtr->setChargeCount(3); /* Full */
 						else if (iconIdx == k195_IconIndicePotionEmptyFlask)
@@ -1206,7 +1206,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 							return;
 						}
 						_vm->_championMan->drawChangedObjectIcons();
-						_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thingHandObject) - weight;
+						_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(thingHandObject) - weight;
 					}
 					f372_commandProcessType80ClickInDungeonViewTouchFrontWall();
 				}
@@ -1247,29 +1247,29 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 		box._x2 = box._x1 + 66;
 		dispMan._g578_useByteBoxCoordinates = false;
 		dispMan.D24_fillScreenBox(box, k0_ColorBlack);
-		dispMan.D24_fillScreenBox(_vm->_championMan->_boxChampionIcons[champMan.getChampionIconIndex(champ->_cell, dunMan._g308_partyDir) * 2], k0_ColorBlack);
+		dispMan.D24_fillScreenBox(_vm->_championMan->_boxChampionIcons[champMan.getChampionIconIndex(champ->_cell, dunMan._partyDir) * 2], k0_ColorBlack);
 		_vm->_menuMan->f457_drawEnabledMenus();
 		f78_showMouse();
 		return;
 	}
 
 	champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
-	int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
-	int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
+	int16 mapX = dunMan._partyMapX + _vm->_dirIntoStepCountEast[dunMan._partyDir];
+	int16 mapY = dunMan._partyMapY + _vm->_dirIntoStepCountNorth[dunMan._partyDir];
 
 	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
 		Thing thing = champ->getSlot((ChampionSlot)slotIndex);
 		if (thing != Thing::_none) {
-			_vm->_dungeonMan->f164_unlinkThingFromList(thing, Thing(0), mapX, mapY);
+			_vm->_dungeonMan->unlinkThingFromList(thing, Thing(0), mapX, mapY);
 		}
 	}
-	Thing thing = dunMan.f161_getSquareFirstThing(mapX, mapY);
+	Thing thing = dunMan.getSquareFirstThing(mapX, mapY);
 	for (;;) { // infinite
 		if (thing.getType() == k3_SensorThingType) {
-			((Sensor*)dunMan.f156_getThingData(thing))->setTypeDisabled();
+			((Sensor*)dunMan.getThingData(thing))->setTypeDisabled();
 			break;
 		}
-		thing = dunMan.f159_getNextThing(thing);
+		thing = dunMan.getNextThing(thing);
 	}
 
 	if (commandType == k161_CommandClickInPanelReincarnate) {
@@ -1343,19 +1343,19 @@ void EventManager::f373_processType80_clickInDungeonView_grabLeaderHandObject(ui
 	if (_vm->_championMan->_leaderIndex == kM1_ChampionNone)
 		return;
 
-	int16 mapX = _vm->_dungeonMan->_g306_partyMapX;
-	int16 mapY = _vm->_dungeonMan->_g307_partyMapY;
+	int16 mapX = _vm->_dungeonMan->_partyMapX;
+	int16 mapY = _vm->_dungeonMan->_partyMapY;
 	if (viewCell >= k2_ViewCellBackRight) {
-		mapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], mapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+		mapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir], mapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
 		Thing groupThing = _vm->_groupMan->f175_groupGetThing(mapX, mapY);
 		if ((groupThing != Thing::_endOfList) &&
 			!_vm->_moveSens->f264_isLevitating(groupThing) &&
-			_vm->_groupMan->f176_getCreatureOrdinalInCell((Group*)_vm->_dungeonMan->f156_getThingData(groupThing), normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir))) {
+			_vm->_groupMan->f176_getCreatureOrdinalInCell((Group*)_vm->_dungeonMan->getThingData(groupThing), normalizeModulo4(viewCell + _vm->_dungeonMan->_partyDir))) {
 			return; /* It is not possible to grab an object on floor if there is a non levitating creature on its cell */
 		}
 	}
 
-	Thing topPileThing = _vm->_dungeonMan->_g292_pileTopObject[viewCell];
+	Thing topPileThing = _vm->_dungeonMan->_pileTopObject[viewCell];
 	if (_vm->_objectMan->f33_getIconIndex(topPileThing) != kM1_IconIndiceNone) {
 		_vm->_moveSens->f267_getMoveResult(topPileThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
 		_vm->_championMan->putObjectInLeaderHand(topPileThing, true);
@@ -1368,22 +1368,22 @@ void EventManager::f374_processType80_clickInDungeonViewDropLeaderHandObject(uin
 	if (_vm->_championMan->_leaderIndex == kM1_ChampionNone)
 		return;
 
-	int16 mapX = _vm->_dungeonMan->_g306_partyMapX;
-	int16 mapY = _vm->_dungeonMan->_g307_partyMapY;
+	int16 mapX = _vm->_dungeonMan->_partyMapX;
+	int16 mapY = _vm->_dungeonMan->_partyMapY;
 	bool droppingIntoAnAlcove = (viewCell == k4_ViewCellAlcove);
 	if (droppingIntoAnAlcove)
 		viewCell = k2_ViewCellBackRight;
 
 	if (viewCell > k1_ViewCellFrontRight)
-		mapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], mapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+		mapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir], mapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
 
-	uint16 currCell = normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + viewCell);
+	uint16 currCell = normalizeModulo4(_vm->_dungeonMan->_partyDir + viewCell);
 	Thing removedThing = _vm->_championMan->getObjectRemovedFromLeaderHand();
 	_vm->_moveSens->f267_getMoveResult(thingWithNewCell(removedThing, currCell), kM1_MapXNotOnASquare, 0, mapX, mapY);
-	if (droppingIntoAnAlcove && _vm->_dungeonMan->_g287_isFacingViAltar && (_vm->_objectMan->f33_getIconIndex(removedThing) == k147_IconIndiceJunkChampionBones)) {
-		Junk *removedJunk = (Junk*)_vm->_dungeonMan->f156_getThingData(removedThing);
+	if (droppingIntoAnAlcove && _vm->_dungeonMan->_isFacingViAltar && (_vm->_objectMan->f33_getIconIndex(removedThing) == k147_IconIndiceJunkChampionBones)) {
+		Junk *removedJunk = (Junk*)_vm->_dungeonMan->getThingData(removedThing);
 		TimelineEvent newEvent;
-		setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + 1);
+		setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + 1);
 		newEvent._type = k13_TMEventTypeViAltarRebirth;
 		newEvent._priority = removedJunk->getChargeCount();
 		newEvent._B._location._mapX = mapX;
@@ -1428,11 +1428,11 @@ void EventManager::f357_discardAllInput() {
 }
 
 void EventManager::f364_commandTakeStairs(bool stairsGoDown) {
-	_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0);
-	_vm->_newPartyMapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g309_partyMapIndex, stairsGoDown ? -1 : 1, &_vm->_dungeonMan->_g306_partyMapX, &_vm->_dungeonMan->_g307_partyMapY);
-	_vm->_dungeonMan->f173_setCurrentMap(_vm->_newPartyMapIndex);
-	_vm->_championMan->setPartyDirection(_vm->_dungeonMan->f155_getStairsExitDirection(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY));
-	_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
+	_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kM1_MapXNotOnASquare, 0);
+	_vm->_newPartyMapIndex = _vm->_dungeonMan->getLocationAfterLevelChange(_vm->_dungeonMan->_partyMapIndex, stairsGoDown ? -1 : 1, &_vm->_dungeonMan->_partyMapX, &_vm->_dungeonMan->_partyMapY);
+	_vm->_dungeonMan->setCurrentMap(_vm->_newPartyMapIndex);
+	_vm->_championMan->setPartyDirection(_vm->_dungeonMan->getStairsExitDirection(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY));
+	_vm->_dungeonMan->setCurrentMap(_vm->_dungeonMan->_partyMapIndex);
 }
 
 void EventManager::f367_commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX, int16 posY) {
@@ -1454,7 +1454,7 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 
 	_gK100_preventBuildPointerScreenArea = true;
 	if (!_g599_useChampionIconOrdinalAsMousePointerBitmap) {
-		if (_vm->_championMan->getIndexInCell(normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir)) == kM1_ChampionNone) {
+		if (_vm->_championMan->getIndexInCell(normalizeModulo4(champIconIndex + _vm->_dungeonMan->_partyDir)) == kM1_ChampionNone) {
 			_gK100_preventBuildPointerScreenArea = false;
 			return;
 		}
@@ -1474,20 +1474,20 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 		_g598_mousePointerBitmapUpdated = true;
 		uint16 championIconIndex = _vm->ordinalToIndex(_g599_useChampionIconOrdinalAsMousePointerBitmap);
 		_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kM1_ChampionNone);
-		int16 championCellIndex = _vm->_championMan->getIndexInCell(normalizeModulo4(championIconIndex + _vm->_dungeonMan->_g308_partyDir));
+		int16 championCellIndex = _vm->_championMan->getIndexInCell(normalizeModulo4(championIconIndex + _vm->_dungeonMan->_partyDir));
 		if (championIconIndex == champIconIndex) {
 			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, k0x0400_ChampionAttributeIcon);
 			_vm->_championMan->drawChampionState((ChampionIndex)championCellIndex);
 		} else {
-			int16 championIndex = _vm->_championMan->getIndexInCell(normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir));
+			int16 championIndex = _vm->_championMan->getIndexInCell(normalizeModulo4(champIconIndex + _vm->_dungeonMan->_partyDir));
 			if (championIndex >= 0) {
-				_vm->_championMan->_champions[championIndex]._cell = (ViewCell)normalizeModulo4(championIconIndex + _vm->_dungeonMan->_g308_partyDir);
+				_vm->_championMan->_champions[championIndex]._cell = (ViewCell)normalizeModulo4(championIconIndex + _vm->_dungeonMan->_partyDir);
 				setFlag(_vm->_championMan->_champions[championIndex]._attributes, k0x0400_ChampionAttributeIcon);
 				_vm->_championMan->drawChampionState((ChampionIndex)championIndex);
 			} else
 				_vm->_displayMan->D24_fillScreenBox(_vm->_championMan->_boxChampionIcons[championIconIndex], k0_ColorBlack);
 
-			_vm->_championMan->_champions[championCellIndex]._cell = (ViewCell)normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir);
+			_vm->_championMan->_champions[championCellIndex]._cell = (ViewCell)normalizeModulo4(champIconIndex + _vm->_dungeonMan->_partyDir);
 			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, k0x0400_ChampionAttributeIcon);
 			_vm->_championMan->drawChampionState((ChampionIndex)championCellIndex);
 		}
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index f56d78d..30f5a0c 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -744,10 +744,10 @@ void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButt
 		if (viewDoorButtonIndex == k3_viewDoorButton_D1C) {
 			bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
 
-			_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordSetRedEagle[0];
-			_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordSetRedEagle[1];
-			_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordSetRedEagle[2];
-			_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordSetRedEagle[3];
+			_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordSetRedEagle[0];
+			_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordSetRedEagle[1];
+			_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordSetRedEagle[2];
+			_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordSetRedEagle[3];
 		} else {
 			if (!f491_isDerivedBitmapInCache(doorButtonOrdinal = k102_DerivedBitmapFirstDoorButton + (doorButtonOrdinal * 2) + ((!viewDoorButtonIndex) ? 0 : viewDoorButtonIndex - 1))) {
 				uint16 *coordSetBlueGoat = doorButtonCoordSets[coordSet][k3_viewDoorButton_D1C];
@@ -1056,11 +1056,11 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d
 		return;
 
 	DoorFrames *doorFramesTemp = doorFrames;
-	Door *door = (Door *)(_vm->_dungeonMan->_g284_thingData[k0_DoorThingType]) + doorThingIndex;
+	Door *door = (Door *)(_vm->_dungeonMan->_thingData[k0_DoorThingType]) + doorThingIndex;
 	uint16 doorType = door->getType();
 	memmove(_g74_tmpBitmap, f489_getNativeBitmapOrGraphic(doorNativeBitmapIndices[doorType]), byteCount * 2);
 	f109_drawDoorOrnament(door->getOrnOrdinal(), viewDoorOrnIndex);
-	if (getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[doorType]._attributes, k0x0004_MaskDoorInfo_Animated)) {
+	if (getFlag(_vm->_dungeonMan->_currMapDoorInfo[doorType]._attributes, k0x0004_MaskDoorInfo_Animated)) {
 		if (_vm->getRandomNumber(2))
 			f130_flipBitmapHorizontal(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
 
@@ -1153,12 +1153,12 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn
 }
 
 void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int16 mapX, int16 mapY, bool flipHorizontal) {
-	int16 mapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g272_currMapIndex, -1, &mapX, &mapY);
+	int16 mapIndex = _vm->_dungeonMan->getLocationAfterLevelChange(_vm->_dungeonMan->_currMapIndex, -1, &mapX, &mapY);
 
 	if (mapIndex < 0)
 		return;
 
-	int16 mapSquare = _vm->_dungeonMan->_g279_dungeonMapData[mapIndex][mapX][mapY];
+	int16 mapSquare = _vm->_dungeonMan->_dungeonMapData[mapIndex][mapX][mapY];
 	if ((Square(mapSquare).getType() == k2_PitElemType) && getFlag(mapSquare, k0x0008_PitOpen)) {
 		if (flipHorizontal)
 			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(nativeBitmapIndex, *frame);
@@ -1223,7 +1223,7 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	int16 order;
 	bool skip = false;
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_StairsFrontElemType:
 		if (squareAspect[k2_StairsUpAspect])
@@ -1301,7 +1301,7 @@ void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	bool skip = false;
 
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
@@ -1332,7 +1332,7 @@ void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
 		memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44);
 		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD3R);
-		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
+		if (((Door *)_vm->_dungeonMan->_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
 			f110_drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k0_viewDoorButton_D3R);
 
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect],
@@ -1385,7 +1385,7 @@ void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 	int16 order;
 	bool skip = false;
 
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
@@ -1410,7 +1410,7 @@ void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 		f100_drawWallSetBitmap(_g706_bitmapWallSet_DoorFrameLeft_D3C, doorFrameLeftD3C);
 		memmove(_g74_tmpBitmap, _g706_bitmapWallSet_DoorFrameLeft_D3C, 32 * 44);
 		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD3C);
-		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
+		if (((Door *)_vm->_dungeonMan->_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
 			f110_drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k1_ViewDoorOrnament_D2LCR);
 
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
@@ -1463,7 +1463,7 @@ void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	bool skip = false;
 
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
@@ -1546,7 +1546,7 @@ void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	bool skip = false;
 
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
@@ -1633,7 +1633,7 @@ void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	bool skip = false;
 
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
@@ -1660,7 +1660,7 @@ void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 		f100_drawWallSetBitmap(_g707_bitmapWallSet_DoorFrameLeft_D2C, doorFrameLeftD2C);
 		memcpy(_g74_tmpBitmap, _g707_bitmapWallSet_DoorFrameLeft_D2C, 48 * 65);
 		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD2C);
-		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
+		if (((Door *)_vm->_dungeonMan->_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
 			f110_drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k2_viewDoorButton_D2C);
 
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
@@ -1715,7 +1715,7 @@ void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	bool skip = false;
 
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
@@ -1800,7 +1800,7 @@ void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	bool skip = false;
 
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
@@ -1870,8 +1870,8 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 	uint16 squareAspect[5];
 	bool skip = false;
 
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
-	switch (_vm->_dungeonMan->_g285_squareAheadElement = (ElementType)squareAspect[k0_ElementAspect]) {
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
+	switch (_vm->_dungeonMan->_squareAheadElement = (ElementType)squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
 			f104_drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, frameStairsUpFrontD1C);
@@ -1884,9 +1884,9 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 		f112_drawCeilingPit(k66_ceilingPitD1C_GraphicIndice, &frameCeilingPitD1C, posX, posY, false);
 		break;
 	case k0_ElementTypeWall:
-		_vm->_dungeonMan->_g286_isFacingAlcove = false;
-		_vm->_dungeonMan->_g287_isFacingViAltar = false;
-		_vm->_dungeonMan->_g288_isFacingFountain = false;
+		_vm->_dungeonMan->_isFacingAlcove = false;
+		_vm->_dungeonMan->_isFacingViAltar = false;
+		_vm->_dungeonMan->_isFacingFountain = false;
 		if (_vm->_championMan->_party._event73Count_ThievesEye) {
 			f491_isDerivedBitmapInCache(k1_DerivedBitmapThievesEyeVisibleArea);
 			f132_blitToBitmap(_g296_bitmapViewport, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
@@ -1914,7 +1914,7 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, doorFrameTopD1C);
 		f100_drawWallSetBitmap(_g708_bitmapWallSet_DoorFrameLeft_D1C, _doorFrameLeftD1C);
 		f100_drawWallSetBitmap(_g710_bitmapWallSet_DoorFrameRight_D1C, _doorFrameRightD1C);
-		if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
+		if (((Door *)_vm->_dungeonMan->_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
 			f110_drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C);
 
 		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
@@ -1949,7 +1949,7 @@ void DisplayMan::f125_drawSquareD0L(Direction dir, int16 posX, int16 posY) {
 	static Frame frameCeilingPitD0L = Frame(0, 15, 0, 3, 8, 4, 0, 0); // @ G0158_s_Graphic558_Frame_CeilingPit_D0L
 
 	uint16 squareAspect[5];
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k0_WallElemType:
 		f100_drawWallSetBitmap(_g701_bitmapWallSet_Wall_D0L, _frameWalls163[k10_ViewSquare_D0L]);
@@ -1981,7 +1981,7 @@ void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
 
 	uint16 squareAspect[5];
 
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k18_ElementTypeStairsSide:
 		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, frameStairsSideD0R);
@@ -2015,7 +2015,7 @@ void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 
 	uint16 squareAspect[5];
 
-	_vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY);
+	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k16_DoorSideElemType:
 		if (_vm->_championMan->_party._event73Count_ThievesEye) {
@@ -2056,10 +2056,10 @@ void DisplayMan::f128_drawDungeon(Direction dir, int16 posX, int16 posY) {
 
 	_g578_useByteBoxCoordinates = true;
 	for (int16 i = 0; i < 6; ++i)
-		_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i].setToZero();
+		_vm->_dungeonMan->_dungeonViewClickableBoxes[i].setToZero();
 
 	for (uint16 i = 0; i < 6; ++i)
-		_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i]._x1 = 255;
+		_vm->_dungeonMan->_dungeonViewClickableBoxes[i]._x1 = 255;
 
 	_g76_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1;
 	if (_g76_useFlippedWallAndFootprintsBitmap) {
@@ -2078,67 +2078,67 @@ void DisplayMan::f128_drawDungeon(Direction dir, int16 posX, int16 posY) {
 		f100_drawWallSetBitmap(_g84_bitmapFloor, floorFrame);
 	}
 
-	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, -2, posX, posY) == k0_WallElemType)
+	if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == k0_WallElemType)
 		f100_drawWallSetBitmap(_g697_bitmapWallSet_Wall_D3L2, frameWallD3L2);
 
-	if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, 2, posX, posY) == k0_WallElemType)
+	if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == k0_WallElemType)
 		f100_drawWallSetBitmap(_g696_bitmapWallSet_Wall_D3R2, _frameWallD3R2);
 
 	int16 tmpPosX = posX;
 	int16 tmpPosY = posY;
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 4, -1, tmpPosX, tmpPosY);
-	f115_cthulhu(_vm->_dungeonMan->f162_getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM2_ViewSquare_D4L, k0x0001_CellOrder_BackLeft);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 4, -1, tmpPosX, tmpPosY);
+	f115_cthulhu(_vm->_dungeonMan->getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM2_ViewSquare_D4L, k0x0001_CellOrder_BackLeft);
 	tmpPosX = posX;
 	tmpPosY = posY;
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 4, 1, tmpPosX, tmpPosY);
-	f115_cthulhu(_vm->_dungeonMan->f162_getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM1_ViewSquare_D4R, k0x0001_CellOrder_BackLeft);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 4, 1, tmpPosX, tmpPosY);
+	f115_cthulhu(_vm->_dungeonMan->getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM1_ViewSquare_D4R, k0x0001_CellOrder_BackLeft);
 	tmpPosX = posX;
 	tmpPosY = posY;
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 4, 0, tmpPosX, tmpPosY);
-	f115_cthulhu(_vm->_dungeonMan->f162_getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM3_ViewSquare_D4C, k0x0001_CellOrder_BackLeft);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 4, 0, tmpPosX, tmpPosY);
+	f115_cthulhu(_vm->_dungeonMan->getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM3_ViewSquare_D4C, k0x0001_CellOrder_BackLeft);
 	tmpPosX = posX;
 	tmpPosY = posY;
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY);
 	f116_drawSquareD3L(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 3, 1, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, 1, tmpPosX, tmpPosY);
 	f117_drawSquareD3R(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 3, 0, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, 0, tmpPosX, tmpPosY);
 	f118_drawSquareD3C(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 2, -1, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, -1, tmpPosX, tmpPosY);
 	f119_drawSquareD2L(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 2, 1, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, 1, tmpPosX, tmpPosY);
 	f120_drawSquareD2R(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 2, 0, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, 0, tmpPosX, tmpPosY);
 	f121_drawSquareD2C(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 1, -1, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, -1, tmpPosX, tmpPosY);
 	f122_drawSquareD1L(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 1, 1, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, 1, tmpPosX, tmpPosY);
 	f123_drawSquareD1R(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 1, 0, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, 0, tmpPosX, tmpPosY);
 	f124_drawSquareD1C(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 0, -1, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 0, -1, tmpPosX, tmpPosY);
 	f125_drawSquareD0L(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 0, 1, tmpPosX, tmpPosY);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 0, 1, tmpPosX, tmpPosY);
 	f126_drawSquareD0R(dir, tmpPosX, tmpPosY);
 	f127_drawSquareD0C(dir, posX, posY);
 
@@ -2150,8 +2150,8 @@ void DisplayMan::f128_drawDungeon(Direction dir, int16 posX, int16 posY) {
 		_g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native;
 	}
 
-	f97_drawViewport((_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance) ? 1 : 0);
-	if (_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance)
+	f97_drawViewport((_vm->_dungeonMan->_partyMapIndex != k255_mapIndexEntrance) ? 1 : 0);
+	if (_vm->_dungeonMan->_partyMapIndex != k255_mapIndexEntrance)
 		f98_drawFloorAndCeiling();
 }
 
@@ -2303,8 +2303,8 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 		3};  /* Arched Alcove */
 	static int16 g193_FountainOrnIndices[k1_FountainOrnCount] = {35}; // @ G0193_ai_Graphic558_FountainOrnamentIndices
 
-	f94_loadFloorSet(_vm->_dungeonMan->_g269_currMap->_floorSet);
-	f95_loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet);
+	f94_loadFloorSet(_vm->_dungeonMan->_currMap->_floorSet);
+	f95_loadWallSet(_vm->_dungeonMan->_currMap->_wallSet);
 
 	_g578_useByteBoxCoordinates = true;
 
@@ -2325,7 +2325,7 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 	f99_copyBitmapAndFlipHorizontal(_g99_bitmapWall_D0R_Native = _g702_bitmapWallSet_Wall_D0R, _g93_bitmapWall_D0L_Flipped,
 									_frameWalls163[k10_ViewSquare_D0L]._srcByteWidth, _frameWalls163[k10_ViewSquare_D0L]._srcHeight);
 
-	int16 val = _vm->_dungeonMan->_g269_currMap->_wallSet * k18_StairsGraphicCount + k90_FirstStairs;
+	int16 val = _vm->_dungeonMan->_currMap->_wallSet * k18_StairsGraphicCount + k90_FirstStairs;
 	_g675_stairsNativeBitmapIndex_Up_Front_D3L = val++;
 	_g676_stairsNativeBitmapIndex_Up_Front_D3C = val++;
 	_g677_stairsNativeBitmapIndex_Up_Front_D2L = val++;
@@ -2352,8 +2352,8 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 		_g268_currMapFountainOrnIndices[i] = -1;
 
 	uint16 doorSets[2];
-	doorSets[0] = _vm->_dungeonMan->_g269_currMap->_doorSet0;
-	doorSets[1] = _vm->_dungeonMan->_g269_currMap->_doorSet1;
+	doorSets[0] = _vm->_dungeonMan->_currMap->_doorSet0;
+	doorSets[1] = _vm->_dungeonMan->_currMap->_doorSet1;
 	for (uint16 doorSet = 0; doorSet <= 1; doorSet++) {
 		int16 counter = k108_FirstDoorSet + (doorSets[doorSet] * k3_DoorSetGraphicsCount);
 		_g693_doorNativeBitmapIndex_Front_D3LCR[doorSet] = counter++;
@@ -2363,7 +2363,7 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 
 	uint16 alcoveCount = 0;
 	uint16 fountainCount = 0;
-	Map &currMap = *_vm->_dungeonMan->_g269_currMap;
+	Map &currMap = *_vm->_dungeonMan->_currMap;
 
 	_g266_currMapViAltarIndex = -1;
 
@@ -2623,11 +2623,11 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 	int16 ornNativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnamentIndex][k0_NativeBitmapIndex];
 	int16 wallOrnamentCoordinateSetIndex = _g101_currMapWallOrnInfo[wallOrnamentIndex][k1_CoordinateSet];
 	byte *ornCoordSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][viewWallIndex];
-	bool isAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(wallOrnamentIndex);
+	bool isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnamentIndex);
 	unsigned char inscriptionString[70];
-	bool isInscription = (wallOrnamentIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex);
+	bool isInscription = (wallOrnamentIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex);
 	if (isInscription)
-		_vm->_dungeonMan->f168_decodeText((char*)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
+		_vm->_dungeonMan->decodeText((char*)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
 
 	int16 blitPosX;
 	byte *ornBlitBitmap;
@@ -2659,15 +2659,15 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 			ornNativeBitmapIndex++;
 			{
 				Box tmpBox(ornCoordSet);
-				_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn] = tmpBox;
+				_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn] = tmpBox;
 			}
-			_vm->_dungeonMan->_g286_isFacingAlcove = isAlcove;
-			_vm->_dungeonMan->_g287_isFacingViAltar =
+			_vm->_dungeonMan->_isFacingAlcove = isAlcove;
+			_vm->_dungeonMan->_isFacingViAltar =
 				(wallOrnamentIndex == _g266_currMapViAltarIndex);
-			_vm->_dungeonMan->_g288_isFacingFountain = false;
+			_vm->_dungeonMan->_isFacingFountain = false;
 			for (int16 idx = 0; idx < k1_FountainOrnCount; idx++) {
 				if (_g268_currMapFountainOrnIndices[idx] == wallOrnamentIndex) {
-					_vm->_dungeonMan->_g288_isFacingFountain = true;
+					_vm->_dungeonMan->_isFacingFountain = true;
 					break;
 				}
 			}
@@ -3110,7 +3110,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
 			}
 
 			if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) { /* Square where objects are visible and object is located on cell being processed */
-				objectAspect = &(_objectAspects209[_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thingParam)]._objectAspectIndex]);
+				objectAspect = &(_objectAspects209[_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(thingParam)]._objectAspectIndex]);
 				AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex;
 				useAlcoveObjectImage = (L0135_B_DrawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane);
 				if (useAlcoveObjectImage)
@@ -3198,7 +3198,7 @@ T0115015_DrawProjectileAsObject:
 				if (drawingGrabbableObject) {
 					bitmapGreenAnt = bitmapRedBanana;
 
-					Box *AL_6_box = &_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[AL_2_viewCell];
+					Box *AL_6_box = &_vm->_dungeonMan->_dungeonViewClickableBoxes[AL_2_viewCell];
 
 					if (AL_6_box->_x1 == 255) { /* If the grabbable object is the first */
 						*AL_6_box = boxByteGreen;
@@ -3215,13 +3215,13 @@ T0115015_DrawProjectileAsObject:
 						AL_6_box->_y2 = MAX(AL_6_box->_y2, boxByteGreen._y2);
 					}
 					bitmapRedBanana = bitmapGreenAnt;
-					_vm->_dungeonMan->_g292_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */
+					_vm->_dungeonMan->_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */
 				}
 				f132_blitToBitmap(bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
 				if (drawProjectileAsObject)
 					goto T0115171_BackFromT0115015_DrawProjectileAsObject;
 			}
-		} while ((thingParam = _vm->_dungeonMan->f159_getNextThing(thingParam)) != Thing::_endOfList);
+		} while ((thingParam = _vm->_dungeonMan->getNextThing(thingParam)) != Thing::_endOfList);
 		if (AL_2_viewCell == k4_ViewCellAlcove)
 			break; /* End of processing when drawing objects in an alcove */
 		if (viewSquareIndex < k0_ViewSquare_D3C)
@@ -3233,7 +3233,7 @@ T0115015_DrawProjectileAsObject:
 
 		ActiveGroup *activeGroup;
 		if (group == nullptr) { /* If all creature data and info has not already been gathered */
-			group = (Group*)_vm->_dungeonMan->f156_getThingData(groupThing);
+			group = (Group*)_vm->_dungeonMan->getThingData(groupThing);
 			activeGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
 			CreatureInfo *creatureInfo = &g243_CreatureInfo[group->_type];
 			creatureAspectStruct = &_creatureAspects219[creatureInfo->_creatureAspectIndex];
@@ -3483,8 +3483,8 @@ T0115129_DrawProjectiles:
 		thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */
 		do {
 			if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) {
-				Projectile *projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(thingParam);
-				if ((AL_4_projectileAspect = _vm->_dungeonMan->f142_getProjectileAspect(projectile->_slot)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
+				Projectile *projectile = (Projectile*)_vm->_dungeonMan->getThingData(thingParam);
+				if ((AL_4_projectileAspect = _vm->_dungeonMan->getProjectileAspect(projectile->_slot)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
 					objectAspect = (ObjectAspect*)&_projectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)];
 					AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
 					projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
@@ -3596,7 +3596,7 @@ T0115129_DrawProjectiles:
 				}
 			}
 T0115171_BackFromT0115015_DrawProjectileAsObject:;
-		} while ((thingParam = _vm->_dungeonMan->f159_getNextThing(thingParam)) != Thing::_endOfList);
+		} while ((thingParam = _vm->_dungeonMan->getNextThing(thingParam)) != Thing::_endOfList);
 	} while (remainingViewCellOrdinalsToProcess);
 
 	/* Draw explosions */
@@ -3612,7 +3612,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 	do {
 		if (thingParam.getType() == k15_ExplosionThingType) {
 			AL_2_cellPurpleMan = thingParam.getCell();
-			Explosion *explosion = (Explosion*)_vm->_dungeonMan->f156_getThingData(thingParam);
+			Explosion *explosion = (Explosion*)_vm->_dungeonMan->getThingData(thingParam);
 			bool rebirthExplosion = ((uint16)(AL_4_explosionType = explosion->getType()) >= k100_ExplosionType_RebirthStep1);
 			if (rebirthExplosion && ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion) || (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion) || (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */
 				continue;
@@ -3628,7 +3628,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 						AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke;
 					} else {
 						if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) {
-							objectAspect = (ObjectAspect*)&_projectileAspect[_vm->ordinalToIndex(-_vm->_dungeonMan->f142_getProjectileAspect(Thing::_explLightningBolt))];
+							objectAspect = (ObjectAspect*)&_projectileAspect[_vm->ordinalToIndex(-_vm->_dungeonMan->getProjectileAspect(Thing::_explLightningBolt))];
 							bitmapRedBanana = f489_getNativeBitmapOrGraphic(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
 							explosionCoordinates = rebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
 							byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_byteWidth), explosionCoordinates[2]);
@@ -3734,7 +3734,7 @@ T0115200_DrawExplosion:
 				f132_blitToBitmap(bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
 			}
 		}
-		thingParam = _vm->_dungeonMan->f159_getNextThing(thingParam);
+		thingParam = _vm->_dungeonMan->getNextThing(thingParam);
 	} while (thingParam != Thing::_endOfList);
 
 	if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_g77_doNotDrawFluxcagesDuringEndgame) { /* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 18af098..5c60ff4 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -84,7 +84,7 @@ void GroupMan::f196_initActiveGroups() {
 
 uint16 GroupMan::f145_getGroupCells(Group *group, int16 mapIndex) {
 	byte cells = group->_cells;
-	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex)
+	if (mapIndex == _vm->_dungeonMan->_partyMapIndex)
 		cells = _g375_activeGroups[cells]._cells;
 	return cells;
 }
@@ -92,14 +92,14 @@ uint16 GroupMan::f145_getGroupCells(Group *group, int16 mapIndex) {
 uint16 GroupMan::f147_getGroupDirections(Group *group, int16 mapIndex) {
 	static byte groupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_GroupDirections
 
-	if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex)
+	if (mapIndex == _vm->_dungeonMan->_partyMapIndex)
 		return _g375_activeGroups[group->getActiveGroupIndex()]._directions;
 
 	return groupDirections[group->getDir()];
 }
 
 int16 GroupMan::f176_getCreatureOrdinalInCell(Group *group, uint16 cell) {
-	uint16 currMapIndex = _vm->_dungeonMan->_g272_currMapIndex;
+	uint16 currMapIndex = _vm->_dungeonMan->_currMapIndex;
 	byte groupCells = f145_getGroupCells(group, currMapIndex);
 	if (groupCells == k255_CreatureTypeSingleCenteredCreature)
 		return _vm->indexToOrdinal(0);
@@ -134,11 +134,11 @@ uint16 GroupMan::M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex) {
 }
 
 void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode) {
-	Group *group = (Group *)_vm->_dungeonMan->f156_getThingData(groupThing);
+	Group *group = (Group *)_vm->_dungeonMan->getThingData(groupThing);
 	uint16 creatureType = group->_type;
 	if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[creatureType]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
 		int16 creatureIndex = group->getCount();
-		uint16 groupCells = f145_getGroupCells(group, _vm->_dungeonMan->_g272_currMapIndex);
+		uint16 groupCells = f145_getGroupCells(group, _vm->_dungeonMan->_currMapIndex);
 		do {
 			f186_dropCreatureFixedPossessions(creatureType, mapX, mapY,
 				(groupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : M50_getCreatureValue(groupCells, creatureIndex), mode);
@@ -150,7 +150,7 @@ void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThin
 		bool L0371_B_WeaponDropped = false;
 		Thing nextThing;
 		do {
-			nextThing = _vm->_dungeonMan->f159_getNextThing(currentThing);
+			nextThing = _vm->_dungeonMan->getNextThing(currentThing);
 			currentThing = thingWithNewCell(currentThing, _vm->getRandomNumber(4));
 			if ((currentThing).getType() == k5_WeaponThingType) {
 				L0371_B_WeaponDropped = true;
@@ -275,11 +275,11 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX
 			currFixedPossession -= k23_ObjectInfoIndexFirstWeapon;
 		}
 
-		Thing nextUnusedThing = _vm->_dungeonMan->f166_getUnusedThing(currThingType);
+		Thing nextUnusedThing = _vm->_dungeonMan->getUnusedThing(currThingType);
 		if ((nextUnusedThing) == Thing::_none)
 			continue;
 
-		Weapon *currWeapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(nextUnusedThing);
+		Weapon *currWeapon = (Weapon *)_vm->_dungeonMan->getThingData(nextUnusedThing);
 /* The same pointer type is used no matter the actual type k5_WeaponThingType, k6_ArmourThingType or k10_JunkThingType */
 		currWeapon->setType(currFixedPossession);
 		currWeapon->setCursed(cursedPossessions);
@@ -360,16 +360,16 @@ bool GroupMan::f227_isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 src
 }
 
 bool GroupMan::f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack, bool magicAttack, int16 ticks) {
-	Door *L0573_ps_Door = (Door *)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY);
+	Door *L0573_ps_Door = (Door *)_vm->_dungeonMan->getSquareFirstThingData(mapX, mapY);
 	if ((magicAttack && !L0573_ps_Door->isMagicDestructible()) || (!magicAttack && !L0573_ps_Door->isMeleeDestructible())) {
 		return false;
 	}
-	if (attack >= _vm->_dungeonMan->_g275_currMapDoorInfo[L0573_ps_Door->getType()]._defense) {
-		byte *L0574_puc_Square = &_vm->_dungeonMan->_g271_currMapData[mapX][mapY];
+	if (attack >= _vm->_dungeonMan->_currMapDoorInfo[L0573_ps_Door->getType()]._defense) {
+		byte *L0574_puc_Square = &_vm->_dungeonMan->_currMapData[mapX][mapY];
 		if (Square(*L0574_puc_Square).getDoorState() == k4_doorState_CLOSED) {
 			if (ticks) {
 				TimelineEvent L0575_s_Event;
-				setMapAndTime(L0575_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_gameTime + ticks);
+				setMapAndTime(L0575_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + ticks);
 				L0575_s_Event._type = k2_TMEventTypeDoorDestruction;
 				L0575_s_Event._priority = 0;
 				L0575_s_Event._B._location._mapX = mapX;
@@ -387,9 +387,9 @@ bool GroupMan::f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16
 Thing GroupMan::f175_groupGetThing(int16 mapX, int16 mapY) {
 	Thing L0317_T_Thing;
 
-	L0317_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
+	L0317_T_Thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
 	while ((L0317_T_Thing != Thing::_endOfList) && ((L0317_T_Thing).getType() != k4_GroupThingType)) {
-		L0317_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0317_T_Thing);
+		L0317_T_Thing = _vm->_dungeonMan->getNextThing(L0317_T_Thing);
 	}
 	return L0317_T_Thing;
 }
@@ -421,7 +421,7 @@ int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group *group, uint16 creature
 	if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) /* Lord Chaos cannot be damaged */
 		goto T0190024;
 	if (group->_health[creatureIndex] <= damage) {
-		L0381_ui_GroupCells = f145_getGroupCells(group, _vm->_dungeonMan->_g272_currMapIndex);
+		L0381_ui_GroupCells = f145_getGroupCells(group, _vm->_dungeonMan->_currMapIndex);
 		L0384_ui_Cell = (L0381_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : M50_getCreatureValue(L0381_ui_GroupCells, creatureIndex);
 		if (!(L0379_ui_CreatureCount = group->getCount())) { /* If there is a single creature in the group */
 			if (notMoving) {
@@ -430,7 +430,7 @@ int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group *group, uint16 creature
 			}
 			AL0375_ui_Outcome = k2_outcomeKilledAllCreaturesInGroup;
 		} else { /* If there are several creatures in the group */
-			L0382_ui_GroupDirections = f147_getGroupDirections(group, _vm->_dungeonMan->_g272_currMapIndex);
+			L0382_ui_GroupDirections = f147_getGroupDirections(group, _vm->_dungeonMan->_currMapIndex);
 			if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
 				if (notMoving) {
 					f186_dropCreatureFixedPossessions(AL0380_ui_CreatureType, mapX, mapY, L0384_ui_Cell, k2_soundModePlayOneTickLater);
@@ -438,14 +438,14 @@ int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group *group, uint16 creature
 					_g392_dropMovingCreatureFixedPossessionsCell[_g391_dropMovingCreatureFixedPossCellCount++] = L0384_ui_Cell;
 				}
 			}
-			L0383_B_CurrentMapIsPartyMap = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex);
+			L0383_B_CurrentMapIsPartyMap = (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex);
 			if (L0383_B_CurrentMapIsPartyMap)
 				L0378_ps_ActiveGroup = &_g375_activeGroups[group->getActiveGroupIndex()];
 
 			if (group->getBehaviour() == k6_behavior_ATTACK) {
 				L0377_ps_Event = _vm->_timeline->_g370_events;
 				for (AL0374_ui_EventIndex = 0; AL0374_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; AL0374_ui_EventIndex++) {
-					if ((getMap(L0377_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) &&
+					if ((getMap(L0377_ps_Event->_mapTime) == _vm->_dungeonMan->_currMapIndex) &&
 						(L0377_ps_Event->_B._location._mapX == mapX) &&
 						(L0377_ps_Event->_B._location._mapY == mapY) &&
 						((AL0375_ui_EventType = L0377_ps_Event->_type) > k32_TMEventTypeUpdateAspectGroup) &&
@@ -481,8 +481,8 @@ int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group *group, uint16 creature
 				}
 			}
 			L0381_ui_GroupCells &= 0x003F;
-			_vm->_dungeonMan->f146_setGroupCells(group, L0381_ui_GroupCells, _vm->_dungeonMan->_g272_currMapIndex);
-			_vm->_dungeonMan->f148_setGroupDirections(group, L0382_ui_GroupDirections, _vm->_dungeonMan->_g272_currMapIndex);
+			_vm->_dungeonMan->setGroupCells(group, L0381_ui_GroupCells, _vm->_dungeonMan->_currMapIndex);
+			_vm->_dungeonMan->setGroupDirections(group, L0382_ui_GroupDirections, _vm->_dungeonMan->_currMapIndex);
 			group->setCount(group->getCount() - 1);
 			AL0375_ui_Outcome = k1_outcomeKilledSomeCreaturesInGroup;
 		}
@@ -513,12 +513,12 @@ void GroupMan::f189_delete(int16 mapX, int16 mapY) {
 	if ((L0372_T_GroupThing = f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) {
 		return;
 	}
-	L0373_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0372_T_GroupThing);
+	L0373_ps_Group = (Group *)_vm->_dungeonMan->getThingData(L0372_T_GroupThing);
 	for (uint16 i = 0; i < 4; ++i)
 		L0373_ps_Group->_health[i] = 0;
 	_vm->_moveSens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
 	L0373_ps_Group->_nextThing = Thing::_none;
-	if (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) {
+	if (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) {
 		_g375_activeGroups[L0373_ps_Group->getActiveGroupIndex()]._groupThingIndex = -1;
 		_g377_currActiveGroupCount--;
 	}
@@ -533,7 +533,7 @@ void GroupMan::f181_groupDeleteEvents(int16 mapX, int16 mapY) {
 
 	L0336_ps_Event = _vm->_timeline->_g370_events;
 	for (L0334_i_EventIndex = 0; L0334_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0334_i_EventIndex++) {
-		if ((getMap(L0336_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) &&
+		if ((getMap(L0336_ps_Event->_mapTime) == _vm->_dungeonMan->_currMapIndex) &&
 			((L0335_ui_EventType = L0336_ps_Event->_type) > k29_TMEventTypeGroupReactionDangerOnSquare - 1) && (L0335_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1) &&
 			(L0336_ps_Event->_B._location._mapX == mapX) && (L0336_ps_Event->_B._location._mapY == mapY)) {
 			_vm->_timeline->f237_deleteEvent(L0334_i_EventIndex);
@@ -635,21 +635,21 @@ void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16
 
 
 	/* If the party is not on the map specified in the event and the event type is not one of 32, 33, 37, 38 then the event is ignored */
-	if ((_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) && ((AL0446_i_EventType = eventType) != k37_TMEventTypeUpdateBehaviourGroup) && (AL0446_i_EventType != k32_TMEventTypeUpdateAspectGroup) && (AL0446_i_EventType != k38_TMEventTypeUpdateBehaviour_0) && (AL0446_i_EventType != k33_TMEventTypeUpdateAspectCreature_0))
+	if ((_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex) && ((AL0446_i_EventType = eventType) != k37_TMEventTypeUpdateBehaviourGroup) && (AL0446_i_EventType != k32_TMEventTypeUpdateAspectGroup) && (AL0446_i_EventType != k38_TMEventTypeUpdateBehaviour_0) && (AL0446_i_EventType != k33_TMEventTypeUpdateAspectCreature_0))
 		goto T0209139_Return;
 	/* If there is no creature at the location specified in the event then the event is ignored */
 	if ((L0449_T_GroupThing = f175_groupGetThing(eventMapX, eventMapY)) == Thing::_endOfList) {
 		goto T0209139_Return;
 	}
-	L0444_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0449_T_GroupThing);
+	L0444_ps_Group = (Group *)_vm->_dungeonMan->getThingData(L0449_T_GroupThing);
 	L0448_s_CreatureInfo = g243_CreatureInfo[L0444_ps_Group->_type];
 	/* Update the event */
-	setMapAndTime(L0465_s_NextEvent._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_gameTime);
+	setMapAndTime(L0465_s_NextEvent._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime);
 	L0465_s_NextEvent._priority = 255 - L0448_s_CreatureInfo._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
 	L0465_s_NextEvent._B._location._mapX = eventMapX;
 	L0465_s_NextEvent._B._location._mapY = eventMapY;
 	/* If the creature is not on the party map then try and move the creature in a random direction and place a new event 37 in the timeline for the next creature movement */
-	if (_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) {
+	if (_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex) {
 		if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->getRandomNumber(4), false)) { /* BUG0_67 A group that is not on the party map may wrongly move or not move into a teleporter. Normally, a creature type with Wariness >= 10 (Vexirk, Materializer / Zytaz, Demon, Lord Chaos, Red Dragon / Dragon) would only move into a teleporter if the creature type is allowed on the destination map. However, the variable G0380_T_CurrentGroupThing identifying the group is not set before being used by F0139_DUNGEON_IsCreatureAllowedOnMap called by f202_isMovementPossible so the check to see if the creature type is allowed may operate on another creature type and thus return an incorrect result, causing the creature to teleport while it should not, or not to teleport while it should */
 			AL0450_i_DestinationMapX = eventMapX;
 			AL0451_i_DestinationMapY = eventMapY;
@@ -660,7 +660,7 @@ void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16
 			L0465_s_NextEvent._B._location._mapY = _vm->_moveSens->_g398_moveResultMapY;
 		}
 		L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup;
-		AL0446_i_Ticks = MAX(ABS(_vm->_dungeonMan->_g272_currMapIndex - _vm->_dungeonMan->_g309_partyMapIndex) << 4, L0448_s_CreatureInfo._movementTicks << 1);
+		AL0446_i_Ticks = MAX(ABS(_vm->_dungeonMan->_currMapIndex - _vm->_dungeonMan->_partyMapIndex) << 4, L0448_s_CreatureInfo._movementTicks << 1);
 		/* BUG0_68 A group moves or acts with a wrong timing. Event is added below but L0465_s_NextEvent.C.Ticks has not been initialized. No consequence while the group is not on the party map. When the party enters the group map the first group event may have a wrong timing */
 T0209005_AddEventAndReturn:
 		L0465_s_NextEvent._mapTime += AL0446_i_Ticks;
@@ -707,14 +707,14 @@ T0209005_AddEventAndReturn:
 	AL0447_i_Behavior = L0444_ps_Group->getBehaviour();
 	L0460_ui_CreatureCount = L0444_ps_Group->getCount();
 	L0459_i_CreatureSize = getFlag(L0448_s_CreatureInfo._attributes, k0x0003_MaskCreatureInfo_size);
-	AL0450_i_DistanceXToParty = ((AL0446_i_Distance = eventMapX - _vm->_dungeonMan->_g306_partyMapX) < 0) ? -AL0446_i_Distance : AL0446_i_Distance;
-	AL0451_i_DistanceYToParty = ((AL0446_i_Distance = eventMapY - _vm->_dungeonMan->_g307_partyMapY) < 0) ? -AL0446_i_Distance : AL0446_i_Distance;
+	AL0450_i_DistanceXToParty = ((AL0446_i_Distance = eventMapX - _vm->_dungeonMan->_partyMapX) < 0) ? -AL0446_i_Distance : AL0446_i_Distance;
+	AL0451_i_DistanceYToParty = ((AL0446_i_Distance = eventMapY - _vm->_dungeonMan->_partyMapY) < 0) ? -AL0446_i_Distance : AL0446_i_Distance;
 	_g378_currentGroupMapX = eventMapX;
 	_g379_currentGroupMapY = eventMapY;
 	_g380_currGroupThing = L0449_T_GroupThing;
 	_g384_groupMovementTestedDirections[0] = 0;
-	_g381_currGroupDistanceToParty = f226_getDistanceBetweenSquares(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
-	_g382_currGroupPrimaryDirToParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+	_g381_currGroupDistanceToParty = f226_getDistanceBetweenSquares(eventMapX, eventMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
+	_g382_currGroupPrimaryDirToParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
 	_g383_currGroupSecondaryDirToParty = _vm->_projexpl->_g363_secondaryDirToOrFromParty;
 	L0464_l_NextAspectUpdateTime = 0;
 	L0455_B_CurrentEventTypeIsNotUpdateBehavior = true;
@@ -725,8 +725,8 @@ T0209005_AddEventAndReturn:
 				f181_groupDeleteEvents(eventMapX, eventMapY);
 				goto T0209044_SetBehavior6_Attack;
 			}
-			L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
-			L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+			L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
+			L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
 			goto T0209139_Return;
 		case kM2_TMEventTypeCreateReactionEvent30HitByProjectile: /* This event is used for the reaction of a group after a projectile impacted with one creature in the group (some creatures may have been killed) */
 			if ((AL0447_i_Behavior == k6_behavior_ATTACK) || (AL0447_i_Behavior == k5_behavior_FLEE)) /* If the creature is attacking the party or fleeing from the target then there is no reaction */
@@ -749,13 +749,13 @@ T0209005_AddEventAndReturn:
 		L0465_s_NextEvent._type = eventType + 5;
 		if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
 			if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) {
-				if (getDistance(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, eventMapX, eventMapY) <= 1)
+				if (getDistance(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, eventMapX, eventMapY) <= 1)
 					goto T0209044_SetBehavior6_Attack;
 				if (((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k3_behavior_USELESS)) && (AL0447_i_Behavior != k7_behavior_APPROACH)) /* BUG0_00 Useless code. Behavior cannot be 3 because this value is never used. Moreover, the second condition in the && is redundant (if the value is 0 or 3, it cannot be 7). The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */
 					goto T0209054_SetBehavior7_Approach;
 			}
-			L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
-			L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+			L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
+			L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
 		}
 		if (AL0447_i_Behavior == k6_behavior_ATTACK) {
 			AL0446_i_CreatureAspectIndex = eventType - k33_TMEventTypeUpdateAspectCreature_0; /* Value -1 for event 32, meaning aspect will be updated for all creatures in the group */
@@ -780,8 +780,8 @@ T0209044_SetBehavior6_Attack:
 						if (eventType == kM2_TMEventTypeCreateReactionEvent30HitByProjectile) {
 							f181_groupDeleteEvents(eventMapX, eventMapY);
 						}
-						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
-						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
+						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
 						L0444_ps_Group->setBehaviour(k6_behavior_ATTACK);
 						AL0446_i_Direction = _g382_currGroupPrimaryDirToParty;
 						for (AL0447_i_CreatureIndex = L0460_ui_CreatureCount; AL0447_i_CreatureIndex >= 0; AL0447_i_CreatureIndex--) {
@@ -803,8 +803,8 @@ T0209044_SetBehavior6_Attack:
 					if (AL0447_i_Behavior != k2_behavior_USELESS) { /* BUG0_00 Useless code. Behavior cannot be 2 because this value is never used */
 T0209054_SetBehavior7_Approach:
 						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
-						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
-						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
+						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
 						L0465_s_NextEvent._mapTime += 1;
 						goto T0209134_SetEvent37;
 					}
@@ -853,8 +853,8 @@ T0209061_MoveGroup:
 										 !f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false) ||
 										 _vm->getRandomNumber(2)))
 										goto T0209044_SetBehavior6_Attack;
-									L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
-									L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+									L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
+									L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
 								}
 							} while ((AL0446_i_Direction = returnNextVal(AL0446_i_Direction)) != AL0447_i_ReferenceDirection);
 						}
@@ -892,8 +892,8 @@ T0209073_SetDirectionGroup:
 T0209081_RunTowardParty:
 						L0461_i_MovementTicks++;
 						L0461_i_MovementTicks = L0461_i_MovementTicks >> 1; /* Running speed is half the movement ticks */
-						AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX);
-						AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY);
+						AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX);
+						AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY);
 					} else {
 T0209082_WalkTowardTarget:
 						AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_targetMapX;
@@ -940,8 +940,8 @@ T0209094_FleeFromTarget:
 						/* If the creature can see the party then update target coordinates */
 						L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY);
 						if (L0452_i_DistanceToVisibleParty) {
-							AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX);
-							AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY);
+							AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX);
+							AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY);
 						} else {
 							if (!(--(L0445_ps_ActiveGroup->_delayFleeingFromTarget))) { /* If the creature is not afraid anymore then stop fleeing from target */
 T0209096_SetBehavior0_Wander:
@@ -952,7 +952,7 @@ T0209096_SetBehavior0_Wander:
 							if (_vm->getRandomNumber(2)) {
 								/* If the creature cannot move and the party is adjacent then stop fleeing */
 								if (!f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false)) {
-									if (getDistance(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)
+									if (getDistance(eventMapX, eventMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY) <= 1)
 										goto T0209096_SetBehavior0_Wander;
 								}
 								/* Set creature target to the home square where the creature was located when the party entered the map */
@@ -992,8 +992,8 @@ T0209096_SetBehavior0_Wander:
 				L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, AL0447_i_CreatureIndex, eventMapX, eventMapY);
 				/* If the party is visible, update the target coordinates */
 				if (L0452_i_DistanceToVisibleParty) {
-					L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
-					L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+					L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
+					L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
 				}
 				/* If there is a single creature in the group that is not full square sized and 1/4 chance */
 				if (!L0460_ui_CreatureCount && (L0459_i_CreatureSize != k2_MaskCreatureSizeFull) && !((AL0446_i_GroupCellsCriteria = _vm->getRandomNumber(65536)) & 0x00C0)) {
@@ -1059,8 +1059,8 @@ T0209096_SetBehavior0_Wander:
 				} else {
 					/* If the party is visible, update target coordinates */
 					if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
-						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX;
-						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY;
+						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
+						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
 						f205_setDirection(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
 						L0465_s_NextEvent._mapTime += 2;
 						L0464_l_NextAspectUpdateTime = filterTime(L0465_s_NextEvent._mapTime);
@@ -1110,14 +1110,14 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 	if (creatureInfo->_movementTicks == k255_immobile) {
 		return false;
 	}
-	_vm->_dungeonMan->f150_mapCoordsAfterRelMovement((Direction)dir, 1, 0, mapX, mapY);
+	_vm->_dungeonMan->mapCoordsAfterRelMovement((Direction)dir, 1, 0, mapX, mapY);
 	L0428_i_MapX = mapX;
 	L0429_i_MapY = mapY;
-	L0430_ui_Square = _vm->_dungeonMan->_g271_currMapData[L0428_i_MapX][L0429_i_MapY];
+	L0430_ui_Square = _vm->_dungeonMan->_currMapData[L0428_i_MapX][L0429_i_MapY];
 	L0431_i_SquareType = Square(L0430_ui_Square).getType();
 	_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter =
-		!(((L0428_i_MapX >= 0) && (L0428_i_MapX < _vm->_dungeonMan->_g273_currMapWidth)) &&
-		 ((L0429_i_MapY >= 0) && (L0429_i_MapY < _vm->_dungeonMan->_g274_currMapHeight)) &&
+		!(((L0428_i_MapX >= 0) && (L0428_i_MapX < _vm->_dungeonMan->_currMapWidth)) &&
+		 ((L0429_i_MapY >= 0) && (L0429_i_MapY < _vm->_dungeonMan->_currMapHeight)) &&
 		  (L0431_i_SquareType != k0_ElementTypeWall) &&
 		  (L0431_i_SquareType != k3_ElementTypeStairs) &&
 		 ((L0431_i_SquareType != k2_ElementTypePit) || (getFlag(L0430_ui_Square, k0x0001_PitImaginary) && allowMovementOverImaginaryPitsAndFakeWalls) || !getFlag(L0430_ui_Square, k0x0008_PitOpen) || getFlag(creatureInfo->_attributes, k0x0020_MaskCreatureInfo_levitation)) &&
@@ -1127,10 +1127,10 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 		return false;
 
 	if (getFlag(creatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) {
-		L0433_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0428_i_MapX, L0429_i_MapY);
+		L0433_T_Thing = _vm->_dungeonMan->getSquareFirstThing(L0428_i_MapX, L0429_i_MapY);
 		while (L0433_T_Thing != Thing::_endOfList) {
 			if ((L0433_T_Thing).getType() == k15_ExplosionThingType) {
-				L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f156_getThingData(L0433_T_Thing);
+				L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(L0433_T_Thing);
 				if (((Explosion *)L0432_ps_Teleporter)->setType(k50_ExplosionType_Fluxcage)) {
 					_g385_fluxCages[dir] = true;
 					_g386_fluxCageCount++;
@@ -1138,23 +1138,23 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 					return false;
 				}
 			}
-			L0433_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0433_T_Thing);
+			L0433_T_Thing = _vm->_dungeonMan->getNextThing(L0433_T_Thing);
 		}
 	}
 	if ((L0431_i_SquareType == k5_ElementTypeTeleporter) && getFlag(L0430_ui_Square, k0x0008_TeleporterOpen) && (creatureInfo->getWariness() >= 10)) {
-		L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
-		if (getFlag(L0432_ps_Teleporter->getScope(), k0x0001_TelepScopeCreatures) && !_vm->_dungeonMan->f139_isCreatureAllowedOnMap(_g380_currGroupThing, L0432_ps_Teleporter->getTargetMapIndex())) {
+		L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
+		if (getFlag(L0432_ps_Teleporter->getScope(), k0x0001_TelepScopeCreatures) && !_vm->_dungeonMan->isCreatureAllowedOnMap(_g380_currGroupThing, L0432_ps_Teleporter->getTargetMapIndex())) {
 			_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
 			return false;
 		}
 	}
 
-	_g390_groupMovementBlockedByParty = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0428_i_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0429_i_MapY == _vm->_dungeonMan->_g307_partyMapY);
+	_g390_groupMovementBlockedByParty = (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0428_i_MapX == _vm->_dungeonMan->_partyMapX) && (L0429_i_MapY == _vm->_dungeonMan->_partyMapY);
 	if (_g390_groupMovementBlockedByParty)
 		return false;
 
 	if (L0431_i_SquareType == k4_DoorElemType) {
-		L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
+		L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
 		if (((Square(L0430_ui_Square).getDoorState()) > (((Door *)L0432_ps_Teleporter)->opensVertically() ? CreatureInfo::getHeight(creatureInfo->_attributes) : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
 			_g389_groupMovementBlockedByDoor = true;
 			return false;
@@ -1204,7 +1204,7 @@ T0200006:
 		L0421_i_CreatureViewDirectionCount = 1;
 	}
 	while (L0421_i_CreatureViewDirectionCount--) {
-		if (f227_isDestVisibleFromSource(L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount], mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY)) {
+		if (f227_isDestVisibleFromSource(L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount], mapX, mapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY)) {
 T0200011:
 			AL0422_i_SightRange = L0424_ps_CreatureInfo->getSightRange();
 			if (!getFlag(L0424_ps_CreatureInfo->_attributes, k0x1000_MaskCreatureInfo_nightVision)) {
@@ -1213,7 +1213,7 @@ T0200011:
 			if (_g381_currGroupDistanceToParty > MAX((int16)1, AL0422_i_SightRange)) {
 				return 0;
 			}
-			return f199_getDistanceBetweenUnblockedSquares(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f197_isViewPartyBlocked);
+			return f199_getDistanceBetweenUnblockedSquares(mapX, mapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, &GroupMan::f197_isViewPartyBlocked);
 		}
 	}
 	return 0;
@@ -1267,12 +1267,12 @@ int16 GroupMan::f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 src
 }
 
 bool GroupMan::f197_isViewPartyBlocked(uint16 mapX, uint16 mapY) {
-	uint16 L0404_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY];
+	uint16 L0404_ui_Square = _vm->_dungeonMan->_currMapData[mapX][mapY];
 	int16 L0405_i_SquareType = Square(L0404_ui_Square).getType();
 	if (L0405_i_SquareType == k4_DoorElemType) {
-		Door *L0407_ps_Door = (Door *)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY);
+		Door *L0407_ps_Door = (Door *)_vm->_dungeonMan->getSquareFirstThingData(mapX, mapY);
 		int16 L0406_i_DoorState = Square(L0404_ui_Square).getDoorState();
-		return ((L0406_i_DoorState == k3_doorState_FOURTH) || (L0406_i_DoorState == k4_doorState_CLOSED)) && !getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[L0407_ps_Door->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough);
+		return ((L0406_i_DoorState == k3_doorState_FOURTH) || (L0406_i_DoorState == k4_doorState_CLOSED)) && !getFlag(_vm->_dungeonMan->_currMapDoorInfo[L0407_ps_Door->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough);
 	}
 	return (L0405_i_SquareType == k0_ElementTypeWall) || ((L0405_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0404_ui_Square, k0x0004_FakeWallOpen));
 }
@@ -1288,7 +1288,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 	uint16 L0331_ui_CreatureType;
 	uint16 L1635_ui_SoundIndex;
 
-	L0329_ps_Group = &(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]);
+	L0329_ps_Group = &(((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]);
 	L0327_ui_CreatureGraphicInfo = g243_CreatureInfo[L0331_ui_CreatureType = L0329_ps_Group->_type]._graphicInfo;
 	L0330_B_ProcessGroup = (creatureIndex < 0);
 	if (L0330_B_ProcessGroup) /* If the creature index is negative then all creatures in the group are processed */
@@ -1398,7 +1398,7 @@ int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo
 	if (!(L0426_ui_SmellRange = creatureInfo->getSmellRange())) {
 		return 0;
 	}
-	if ((((L0426_ui_SmellRange + 1) >> 1) >= _g381_currGroupDistanceToParty) && f199_getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f198_isSmellPartyBlocked)) {
+	if ((((L0426_ui_SmellRange + 1) >> 1) >= _g381_currGroupDistanceToParty) && f199_getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, &GroupMan::f198_isSmellPartyBlocked)) {
 		_vm->_projexpl->_g363_secondaryDirToOrFromParty = _g383_currGroupSecondaryDirToParty;
 		return _vm->indexToOrdinal(_g382_currGroupPrimaryDirToParty);
 	}
@@ -1412,7 +1412,7 @@ bool GroupMan::f198_isSmellPartyBlocked(uint16 mapX, uint16 mapY) {
 	uint16 L0408_ui_Square;
 	int16 L0409_i_SquareType;
 
-	return ((L0409_i_SquareType = Square(L0408_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k0_ElementTypeWall) || ((L0409_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0408_ui_Square, k0x0004_FakeWallOpen));
+	return ((L0409_i_SquareType = Square(L0408_ui_Square = _vm->_dungeonMan->_currMapData[mapX][mapY]).getType()) == k0_ElementTypeWall) || ((L0409_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0408_ui_Square, k0x0004_FakeWallOpen));
 }
 
 int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo *info, int16 mapX, int16 mapY, bool allowMovementOverImaginaryPitsAndFakeWalls) {
@@ -1606,7 +1606,7 @@ void GroupMan::f193_stealFromChampion(Group *group, uint16 championIndex) {
 											 The following statement is missing: L0394_T_Thing->Next = Thing::_endOfList;
 											 This creates cloned things if L0394_T_Thing->Next is not Thing::_endOfList which is the case when the object comes from a chest in which it was not the last object */
 			} else {
-				_vm->_dungeonMan->f163_linkThingToList(L0394_T_Thing, group->_slot, kM1_MapXNotOnASquare, 0);
+				_vm->_dungeonMan->linkThingToList(L0394_T_Thing, group->_slot, kM1_MapXNotOnASquare, 0);
 			}
 			_vm->_championMan->drawChampionState((ChampionIndex)championIndex);
 		}
@@ -1649,7 +1649,7 @@ int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) {
 	if (_vm->_championMan->_partyIsSleeping) {
 		_vm->_championMan->wakeUp();
 	}
-	L0563_i_DoubledMapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty << 1;
+	L0563_i_DoubledMapDifficulty = _vm->_dungeonMan->_currMap->_difficulty << 1;
 	L0564_s_CreatureInfo = g243_CreatureInfo[group->_type];
 	_vm->_championMan->addSkillExperience(champIndex, k7_ChampionSkillParry, L0564_s_CreatureInfo.getExperience());
 	if (_vm->_championMan->_partyIsSleeping || (((_vm->_championMan->getDexterity(L0562_ps_Champion) < (_vm->getRandomNumber(32) + L0564_s_CreatureInfo._dexterity + L0563_i_DoubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !_vm->_championMan->isLucky(L0562_ps_Champion, 60))) {
@@ -1679,7 +1679,7 @@ int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) {
 
 		AL0558_i_Damage = _vm->_championMan->addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType);
 		if (AL0558_i_Damage) {
-			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k09_soundCHAMPION_0_DAMAGED + champIndex, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater);
+			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k09_soundCHAMPION_0_DAMAGED + champIndex, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k2_soundModePlayOneTickLater);
 
 			AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack;
 			if (AL0559_ui_PoisonAttack && _vm->getRandomNumber(2)) {
@@ -1700,7 +1700,7 @@ void GroupMan::f187_dropMovingCreatureFixedPossession(Thing thing, int16 mapX, i
 
 
 	if (_g391_dropMovingCreatureFixedPossCellCount) {
-		L0363_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(thing);
+		L0363_ps_Group = (Group *)_vm->_dungeonMan->getThingData(thing);
 		L0364_i_CreatureType = L0363_ps_Group->_type;
 		while (_g391_dropMovingCreatureFixedPossCellCount) {
 			f186_dropCreatureFixedPossessions(L0364_i_CreatureType, mapX, mapY, _g392_dropMovingCreatureFixedPossessionsCell[--_g391_dropMovingCreatureFixedPossCellCount], k2_soundModePlayOneTickLater);
@@ -1713,11 +1713,11 @@ void GroupMan::f180_startWanedring(int16 mapX, int16 mapY) {
 	TimelineEvent L0333_s_Event;
 
 
-	L0332_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(f175_groupGetThing(mapX, mapY));
+	L0332_ps_Group = (Group *)_vm->_dungeonMan->getThingData(f175_groupGetThing(mapX, mapY));
 	if (L0332_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
 		L0332_ps_Group->setBehaviour(k0_behavior_WANDER);
 	}
-	setMapAndTime(L0333_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, (_vm->_gameTime + 1));
+	setMapAndTime(L0333_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, (_vm->_gameTime + 1));
 	L0333_s_Event._type = k37_TMEventTypeUpdateBehaviourGroup;
 	L0333_s_Event._priority = 255 - g243_CreatureInfo[L0332_ps_Group->_type]._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
 	L0333_s_Event._C._ticks = 0;
@@ -1743,7 +1743,7 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
 	}
 	_g377_currActiveGroupCount++;
 
-	L0340_ps_Group = (Group *)(_vm->_dungeonMan->_g284_thingData[k4_GroupThingType] + 
+	L0340_ps_Group = (Group *)(_vm->_dungeonMan->_thingData[k4_GroupThingType] + 
 		g235_ThingDataWordCount[k4_GroupThingType] * (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getIndex()));
 
 	L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells;
@@ -1768,7 +1768,7 @@ void GroupMan::f184_removeActiveGroup(uint16 activeGroupIndex) {
 		return;
 	}
 	L0347_ps_ActiveGroup = &_g375_activeGroups[activeGroupIndex];
-	L0348_ps_Group = &((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex];
+	L0348_ps_Group = &((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex];
 	_g377_currActiveGroupCount--;
 	L0348_ps_Group->_cells = L0347_ps_ActiveGroup->_cells;
 	L0348_ps_Group->setDir(normalizeModulo4(L0347_ps_ActiveGroup->_directions));
@@ -1794,10 +1794,10 @@ void GroupMan::f195_addAllActiveGroups() {
 	Thing *L0402_pT_SquareFirstThing;
 
 
-	L0401_puc_Square = _vm->_dungeonMan->_g271_currMapData[0];
-	L0402_pT_SquareFirstThing = &_vm->_dungeonMan->_g283_squareFirstThings[_vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount[0]];
-	for (L0398_ui_MapX = 0; L0398_ui_MapX < _vm->_dungeonMan->_g273_currMapWidth; L0398_ui_MapX++) {
-		for (L0399_ui_MapY = 0; L0399_ui_MapY < _vm->_dungeonMan->_g274_currMapHeight; L0399_ui_MapY++) {
+	L0401_puc_Square = _vm->_dungeonMan->_currMapData[0];
+	L0402_pT_SquareFirstThing = &_vm->_dungeonMan->_squareFirstThings[_vm->_dungeonMan->_currMapColCumulativeSquareFirstThingCount[0]];
+	for (L0398_ui_MapX = 0; L0398_ui_MapX < _vm->_dungeonMan->_currMapWidth; L0398_ui_MapX++) {
+		for (L0399_ui_MapY = 0; L0399_ui_MapY < _vm->_dungeonMan->_currMapHeight; L0399_ui_MapY++) {
 			if (getFlag(*L0401_puc_Square++, k0x0010_ThingListPresent)) {
 				L0400_T_Thing = *L0402_pT_SquareFirstThing++;
 				do {
@@ -1807,7 +1807,7 @@ void GroupMan::f195_addAllActiveGroups() {
 						f180_startWanedring(L0398_ui_MapX, L0399_ui_MapY);
 						break;
 					}
-				} while ((L0400_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0400_T_Thing)) != Thing::_endOfList);
+				} while ((L0400_T_Thing = _vm->_dungeonMan->getNextThing(L0400_T_Thing)) != Thing::_endOfList);
 			}
 		}
 	}
@@ -1823,10 +1823,10 @@ Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplie
 	bool L0355_B_SeveralCreaturesInGroup;
 
 
-	if (((_g377_currActiveGroupCount >= (_g376_maxActiveGroupCount - 5)) && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) || ((L0349_T_GroupThing = _vm->_dungeonMan->f166_getUnusedThing(k4_GroupThingType)) == Thing::_none)) {
+	if (((_g377_currActiveGroupCount >= (_g376_maxActiveGroupCount - 5)) && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex)) || ((L0349_T_GroupThing = _vm->_dungeonMan->getUnusedThing(k4_GroupThingType)) == Thing::_none)) {
 		return Thing::_none;
 	}
-	L0353_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0349_T_GroupThing);
+	L0353_ps_Group = (Group*)_vm->_dungeonMan->getThingData(L0349_T_GroupThing);
 	L0353_ps_Group->_slot = Thing::_endOfList;
 	L0353_ps_Group->setDoNotDiscard(false);
 	L0353_ps_Group->setDir(dir);
@@ -1860,7 +1860,7 @@ Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplie
 bool GroupMan::f223_isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY) {
 	int16 L0544_i_SquareType;
 
-	return (((L0544_i_SquareType = Square(_vm->_dungeonMan->f151_getSquare(mapX, mapY)).getType()) == k1_CorridorElemType)
+	return (((L0544_i_SquareType = Square(_vm->_dungeonMan->getSquare(mapX, mapY)).getType()) == k1_CorridorElemType)
 			|| (L0544_i_SquareType == k5_ElementTypeTeleporter) || (L0544_i_SquareType == k2_ElementTypePit) || (L0544_i_SquareType == k4_DoorElemType));
 }
 
@@ -1875,7 +1875,7 @@ int16 GroupMan::f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, i
 	if (L0323_T_GroupThing == Thing::_endOfList)
 		return 0;
 
-	L0324_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0323_T_GroupThing);
+	L0324_ps_Group = (Group*)_vm->_dungeonMan->getThingData(L0323_T_GroupThing);
 	f229_setOrderedCellsToAttack(L0325_auc_OrderedCellsToAttack, groupX, groupY, partyX, partyY, champCell);
 	L0321_ui_Counter = 0;
 	for (;;) { /*_Infinite loop_*/
@@ -1903,7 +1903,7 @@ int16 GroupMan::f231_getMeleeActionDamage(Champion* champ, int16 champIndex, Gro
 	if (!champ->_currHealth) {
 		return 0;
 	}
-	L0567_i_DoubledMapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty << 1;
+	L0567_i_DoubledMapDifficulty = _vm->_dungeonMan->_currMap->_difficulty << 1;
 	L0572_ps_CreatureInfo = &g243_CreatureInfo[group->_type];
 	L0571_i_ActionHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
 	L0570_B_ActionHitsNonMaterialCreatures = getFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
@@ -1978,17 +1978,17 @@ void GroupMan::f224_fluxCageAction(int16 mapX, int16 mapY) {
 	TimelineEvent L0547_s_Event;
 
 
-	AL0546_i_SquareType = _vm->_dungeonMan->f151_getSquare(mapX, mapY).getType();
+	AL0546_i_SquareType = _vm->_dungeonMan->getSquare(mapX, mapY).getType();
 	if ((AL0546_i_SquareType == k0_ElementTypeWall) || (AL0546_i_SquareType == k3_ElementTypeStairs))
 		return;
 
-	L0545_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k15_ExplosionThingType);
+	L0545_T_Thing = _vm->_dungeonMan->getUnusedThing(k15_ExplosionThingType);
 	if (L0545_T_Thing == Thing::_none)
 		return;
 
-	_vm->_dungeonMan->f163_linkThingToList(L0545_T_Thing, Thing(0), mapX, mapY);
-	(((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[L0545_T_Thing.getIndex()]).setType(k50_ExplosionType_Fluxcage);
-	setMapAndTime(L0547_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_gameTime + 100);
+	_vm->_dungeonMan->linkThingToList(L0545_T_Thing, Thing(0), mapX, mapY);
+	(((Explosion*)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[L0545_T_Thing.getIndex()]).setType(k50_ExplosionType_Fluxcage);
+	setMapAndTime(L0547_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + 100);
 	L0547_s_Event._type = k24_TMEventTypeRemoveFluxcage;
 	L0547_s_Event._priority = 0;
 	L0547_s_Event._C._slot = L0545_T_Thing.toUint16();
@@ -2034,7 +2034,7 @@ uint16 GroupMan::f222_isLordChaosOnSquare(int16 mapX, int16 mapY) {
 	if (L0542_T_Thing == Thing::_endOfList)
 		return 0;
 
-	L0543_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0542_T_Thing);
+	L0543_ps_Group = (Group*)_vm->_dungeonMan->getThingData(L0542_T_Thing);
 	if (L0543_ps_Group->_type == k23_CreatureTypeLordChaos)
 		return L0542_T_Thing.toUint16();
 
@@ -2045,16 +2045,16 @@ bool GroupMan::f221_isFluxcageOnSquare(int16 mapX, int16 mapY) {
 	Thing L0540_T_Thing;
 	int16 L0541_i_SquareType;
 
-	L0541_i_SquareType = _vm->_dungeonMan->f151_getSquare(mapX, mapY).getType();
+	L0541_i_SquareType = _vm->_dungeonMan->getSquare(mapX, mapY).getType();
 	if ((L0541_i_SquareType == k0_ElementTypeWall) || (L0541_i_SquareType == k3_ElementTypeStairs))
 		return false;
 
-	L0540_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
+	L0540_T_Thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
 	while (L0540_T_Thing != Thing::_endOfList) {
-		if ((L0540_T_Thing.getType() == k15_ExplosionThingType) && (((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[L0540_T_Thing.getIndex()].getType() == k50_ExplosionType_Fluxcage)) {
+		if ((L0540_T_Thing.getType() == k15_ExplosionThingType) && (((Explosion*)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[L0540_T_Thing.getIndex()].getType() == k50_ExplosionType_Fluxcage)) {
 			return true;
 		}
-		L0540_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0540_T_Thing);
+		L0540_T_Thing = _vm->_dungeonMan->getNextThing(L0540_T_Thing);
 	}
 	return false;
 }
@@ -2068,7 +2068,7 @@ void GroupMan::f225_fuseAction(uint16 mapX, uint16 mapY) {
 	bool L0554_aB_Fluxcages[4];
 	Thing L0555_T_LordChaosThing;
 
-	if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight)) {
+	if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_currMapHeight)) {
 		return;
 	}
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 222be92..fd132d7 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -281,7 +281,7 @@ void InventoryMan::f334_closeChest() {
 	bool processFirstChestSlot = true;
 	if (_g426_openChest == Thing::_none)
 		return;
-	Container *container = (Container*)dunMan.f156_getThingData(_g426_openChest);
+	Container *container = (Container*)dunMan.getThingData(_g426_openChest);
 	_g426_openChest = Thing::_none;
 	container->getSlot() = Thing::_endOfList;
 	Thing prevThing;
@@ -292,10 +292,10 @@ void InventoryMan::f334_closeChest() {
 
 			if (processFirstChestSlot) {
 				processFirstChestSlot = false;
-				*dunMan.f156_getThingData(thing) = Thing::_endOfList.toUint16();
+				*dunMan.getThingData(thing) = Thing::_endOfList.toUint16();
 				container->getSlot() = prevThing = thing;
 			} else {
-				dunMan.f163_linkThingToList(thing, prevThing, kM1_MapXNotOnASquare, 0);
+				dunMan.linkThingToList(thing, prevThing, kM1_MapXNotOnASquare, 0);
 				prevThing = thing;
 			}
 		}
@@ -317,7 +317,7 @@ void InventoryMan::f341_drawPanelScroll(Scroll* scroll) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 
 	char stringFirstLine[300];
-	_vm->_dungeonMan->f168_decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
+	_vm->_dungeonMan->decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
 	char *charRed = stringFirstLine;
 	while (*charRed && (*charRed != '\n')) {
 		charRed++;
@@ -385,7 +385,7 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo
 
 		objMan.f38_drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, objMan.f33_getIconIndex(thing));
 		_g425_chestSlots[chestSlotIndex++] = thing;
-		thing = _vm->_dungeonMan->f159_getNextThing(thing);
+		thing = _vm->_dungeonMan->getNextThing(thing);
 	}
 	while (chestSlotIndex < 8) {
 		objMan.f38_drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, kM1_IconIndiceNone);
@@ -502,7 +502,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		f334_closeChest();
 	}
 
-	uint16 *rawThingPtr = dunMan.f156_getThingData(thingToDraw);
+	uint16 *rawThingPtr = dunMan.getThingData(thingToDraw);
 	f335_drawPanelObjectDescriptionString("\f"); // form feed
 	ThingType thingType = thingToDraw.getType();
 	if (thingType == k7_ScrollThingType) {
@@ -671,7 +671,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		}
 
 
-		uint16 weight = dunMan.f140_getObjectWeight(thingToDraw);
+		uint16 weight = dunMan.getObjectWeight(thingToDraw);
 		strcat(str, champMan.getStringFromInteger(weight / 10, false, 3).c_str());
 
 		switch (_vm->getGameLanguage()) { // localized
@@ -699,7 +699,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 void InventoryMan::f337_setDungeonViewPalette() {
 	static const int16 g40_palIndexToLightAmmount[6] = {99, 75, 50, 25, 1, 0}; // @ G0040_ai_Graphic562_PaletteIndexToLightAmount
 
-	if (_vm->_dungeonMan->_g269_currMap->_difficulty == 0) {
+	if (_vm->_dungeonMan->_currMap->_difficulty == 0) {
 		_vm->_displayMan->_g304_dungeonViewPaletteIndex = 0; /* Brightest color palette index */
 	} else {
 		/* Get torch light power from both hands of each champion in the party */
@@ -713,7 +713,7 @@ void InventoryMan::f337_setDungeonViewPalette() {
 				uint16 AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16();
 				if ((_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing)) >= k4_IconIndiceWeaponTorchUnlit) &&
 					(_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing)) <= k7_IconIndiceWeaponTorchLit)) {
-					Weapon *L1042_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(Thing(AL1044_T_Thing));
+					Weapon *L1042_ps_Weapon = (Weapon*)_vm->_dungeonMan->getThingData(Thing(AL1044_T_Thing));
 					*AL1040_pi_TorchLightPower = L1042_ps_Weapon->getChargeCount();
 				} else {
 					*AL1040_pi_TorchLightPower = 0;
@@ -781,7 +781,7 @@ void InventoryMan::f338_decreaseTorchesLightPower() {
 		while (L1047_i_SlotIndex--) {
 			int16 L1049_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L1050_ps_Champion->_slots[L1047_i_SlotIndex]);
 			if ((L1049_i_IconIndex >= k4_IconIndiceWeaponTorchUnlit) && (L1049_i_IconIndex <= k7_IconIndiceWeaponTorchLit)) {
-				Weapon *L1051_ps_Weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(L1050_ps_Champion->_slots[L1047_i_SlotIndex]);
+				Weapon *L1051_ps_Weapon = (Weapon *)_vm->_dungeonMan->getThingData(L1050_ps_Champion->_slots[L1047_i_SlotIndex]);
 				if (L1051_ps_Weapon->getChargeCount()) {
 					if (L1051_ps_Weapon->setChargeCount(L1051_ps_Weapon->getChargeCount() - 1) == 0) {
 						L1051_ps_Weapon->setDoNotDiscard(false);
@@ -947,14 +947,14 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 	if (_vm->_championMan->_candidateChampionOrdinal) {
 		return;
 	}
-	if (!getFlag(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1078_T_Thing = _vm->_championMan->_leaderHandObject)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) {
+	if (!getFlag(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(L1078_T_Thing = _vm->_championMan->_leaderHandObject)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) {
 		return;
 	}
 	L1079_ui_IconIndex = _vm->_objectMan->f33_getIconIndex(L1078_T_Thing);
 	AL1088_ui_ThingType = L1078_T_Thing.getType();
-	L1089_ui_Weight = _vm->_dungeonMan->f140_getObjectWeight(L1078_T_Thing);
+	L1089_ui_Weight = _vm->_dungeonMan->getObjectWeight(L1078_T_Thing);
 	L1083_ps_Champion = &_vm->_championMan->_champions[L1080_ui_ChampionIndex = _vm->ordinalToIndex(_g432_inventoryChampionOrdinal)];
-	L1082_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1078_T_Thing);
+	L1082_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L1078_T_Thing);
 	if ((L1079_ui_IconIndex >= k8_IconIndiceJunkWater) && (L1079_ui_IconIndex <= k9_IconIndiceJunkWaterSkin)) {
 		if (!(L1082_ps_Junk->getChargeCount())) {
 			return;
@@ -1004,7 +1004,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 			}
 			L1083_ps_Champion->_shieldDefense += AL1085_ui_AdjustedPotionPower;
 			L1084_s_Event._type = k72_TMEventTypeChampionShield;
-			setMapAndTime(L1084_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + (AL1085_ui_AdjustedPotionPower * AL1085_ui_AdjustedPotionPower));
+			setMapAndTime(L1084_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + (AL1085_ui_AdjustedPotionPower * AL1085_ui_AdjustedPotionPower));
 			L1084_s_Event._priority = L1080_ui_ChampionIndex;
 			L1084_s_Event._B._defense = AL1085_ui_AdjustedPotionPower;
 			_vm->_timeline->f238_addEventGetEventIndex(&L1084_s_Event);
@@ -1059,10 +1059,10 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 		}
 	} else {
 		_vm->_championMan->drawChangedObjectIcons();
-		_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(L1078_T_Thing) - L1089_ui_Weight;
+		_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(L1078_T_Thing) - L1089_ui_Weight;
 		setFlag(_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
 	}
-	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k08_soundSWALLOW, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
+	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k08_soundSWALLOW, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
 	setFlag(L1083_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
 	if (_g424_panelContent == k0_PanelContentFoodWaterPoisoned) {
 		setFlag(L1083_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index ceaf79e..a6efc10 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -93,10 +93,10 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
 		_gameTime = file->readSint32BE();
 		// G0349_ul_LastRandomNumber = L1371_s_GlobalData.LastRandomNumber;
 		_championMan->_partyChampionCount = file->readUint16BE();
-		_dungeonMan->_g306_partyMapX = file->readSint16BE();
-		_dungeonMan->_g307_partyMapY = file->readSint16BE();
-		_dungeonMan->_g308_partyDir = (Direction)file->readUint16BE();
-		_dungeonMan->_g309_partyMapIndex = file->readByte();
+		_dungeonMan->_partyMapX = file->readSint16BE();
+		_dungeonMan->_partyMapY = file->readSint16BE();
+		_dungeonMan->_partyDir = (Direction)file->readUint16BE();
+		_dungeonMan->_partyMapIndex = file->readByte();
 		_championMan->_leaderIndex = (ChampionIndex)file->readSint16BE();
 		_championMan->_magicCasterChampionIndex = (ChampionIndex)file->readSint16BE();
 		_timeline->_g372_eventCount = file->readUint16BE();
@@ -125,7 +125,7 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
 		assert(sentinel == 0x6f85e3d3);
 	}
 
-	_dungeonMan->f434_loadDungeonFile(file);
+	_dungeonMan->loadDungeonFile(file);
 	delete file;
 
 	if (_newGameFl) {
@@ -224,7 +224,7 @@ void DMEngine::saveGame() {
 
 			uint16 champHandObjWeight = 0;
 			if (!_championMan->_leaderEmptyHanded) {
-				champHandObjWeight = _dungeonMan->f140_getObjectWeight(_championMan->_leaderHandObject);
+				champHandObjWeight = _dungeonMan->getObjectWeight(_championMan->_leaderHandObject);
 				_championMan->_champions[_championMan->_leaderIndex]._load -= champHandObjWeight;
 			}
 
@@ -309,10 +309,10 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 	file->writeSint32BE(_gameTime);
 	//L1348_s_GlobalData.LastRandomNumber = G0349_ul_LastRandomNumber;
 	file->writeUint16BE(_championMan->_partyChampionCount);
-	file->writeSint16BE(_dungeonMan->_g306_partyMapX);
-	file->writeSint16BE(_dungeonMan->_g307_partyMapY);
-	file->writeUint16BE(_dungeonMan->_g308_partyDir);
-	file->writeByte(_dungeonMan->_g309_partyMapIndex);
+	file->writeSint16BE(_dungeonMan->_partyMapX);
+	file->writeSint16BE(_dungeonMan->_partyMapY);
+	file->writeUint16BE(_dungeonMan->_partyDir);
+	file->writeByte(_dungeonMan->_partyMapIndex);
 	file->writeSint16BE(_championMan->_leaderIndex);
 	file->writeSint16BE(_championMan->_magicCasterChampionIndex);
 	file->writeUint16BE(_timeline->_g372_eventCount);
@@ -341,7 +341,7 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 
 	// save _g278_dungeonFileHeader
 	{
-		DungeonFileHeader &header = _dungeonMan->_g278_dungeonFileHeader;
+		DungeonFileHeader &header = _dungeonMan->_dungeonFileHeader;
 		file->writeUint16BE(header._ornamentRandomSeed);
 		file->writeUint16BE(header._rawMapDataSize);
 		file->writeByte(header._mapCount);
@@ -354,8 +354,8 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 	}
 
 	// save _g277_dungeonMaps
-	for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._mapCount; ++i) {
-		Map &map = _dungeonMan->_g277_dungeonMaps[i];
+	for (uint16 i = 0; i < _dungeonMan->_dungeonFileHeader._mapCount; ++i) {
+		Map &map = _dungeonMan->_dungeonMaps[i];
 		uint16 tmp;
 
 		file->writeUint16BE(map._rawDunDataOffset);
@@ -379,25 +379,25 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 	}
 
 	// save _g280_dungeonColumnsCumulativeSquareThingCount
-	for (uint16 i = 0; i < _dungeonMan->_g282_dungeonColumCount; ++i)
-		file->writeUint16BE(_dungeonMan->_g280_dungeonColumnsCumulativeSquareThingCount[i]);
+	for (uint16 i = 0; i < _dungeonMan->_dungeonColumCount; ++i)
+		file->writeUint16BE(_dungeonMan->_dungeonColumnsCumulativeSquareThingCount[i]);
 
 	// save _g283_squareFirstThings
-	for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._squareFirstThingCount; ++i)
-		file->writeUint16BE(_dungeonMan->_g283_squareFirstThings[i].toUint16());
+	for (uint16 i = 0; i < _dungeonMan->_dungeonFileHeader._squareFirstThingCount; ++i)
+		file->writeUint16BE(_dungeonMan->_squareFirstThings[i].toUint16());
 
 	// save _g260_dungeonTextData
-	for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._textDataWordCount; ++i)
-		file->writeUint16BE(_dungeonMan->_g260_dungeonTextData[i]);
+	for (uint16 i = 0; i < _dungeonMan->_dungeonFileHeader._textDataWordCount; ++i)
+		file->writeUint16BE(_dungeonMan->_dungeonTextData[i]);
 
 	// save _g284_thingData
 	for (uint16 thingIndex = 0; thingIndex < 16; ++thingIndex)
-		for (uint16 i = 0; i < g235_ThingDataWordCount[thingIndex] * _dungeonMan->_g278_dungeonFileHeader._thingCounts[thingIndex]; ++i)
-			file->writeUint16BE(_dungeonMan->_g284_thingData[thingIndex][i]);
+		for (uint16 i = 0; i < g235_ThingDataWordCount[thingIndex] * _dungeonMan->_dungeonFileHeader._thingCounts[thingIndex]; ++i)
+			file->writeUint16BE(_dungeonMan->_thingData[thingIndex][i]);
 
 	// save _g276_dungeonRawMapData
-	for (uint32 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._rawMapDataSize; ++i)
-		file->writeByte(_dungeonMan->_g276_dungeonRawMapData[i]);
+	for (uint32 i = 0; i < _dungeonMan->_dungeonFileHeader._rawMapDataSize; ++i)
+		file->writeByte(_dungeonMan->_dungeonRawMapData[i]);
 
 	file->flush();
 	file->finalize();
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index d2cddf6..cf32fd7 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -157,7 +157,7 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
 	IconIndice iconIndex;
 	if (thing == Thing::_none) {
 		iconIndex = k201_IconIndiceActionEmptyHand;
-	} else if (_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thing)]._actionSetIndex) {
+	} else if (_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
 		iconIndex = _vm->_objectMan->f33_getIconIndex(thing);
 	} else {
 		dm.f134_fillBitmap(bitmapIcon, k4_ColorCyan, 16, 16);
@@ -528,10 +528,10 @@ int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
 			f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k10_failureNeedsFlaskInHand, 0);
 			return k3_spellCastFailureNeedsFlask;
 		}
-		AL1269_ui_EmptyFlaskWeight = _vm->_dungeonMan->f140_getObjectWeight(L1272_T_Object);
+		AL1269_ui_EmptyFlaskWeight = _vm->_dungeonMan->getObjectWeight(L1272_T_Object);
 		L1275_ps_Potion->setType((PotionType)L1271_ps_Spell->getType());
 		L1275_ps_Potion->setPower(_vm->getRandomNumber(16) + (L1268_i_PowerSymbolOrdinal * 40));
-		L1270_ps_Champion->_load += _vm->_dungeonMan->f140_getObjectWeight(L1272_T_Object) - AL1269_ui_EmptyFlaskWeight;
+		L1270_ps_Champion->_load += _vm->_dungeonMan->getObjectWeight(L1272_T_Object) - AL1269_ui_EmptyFlaskWeight;
 		_vm->_championMan->drawChangedObjectIcons();
 		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex)) {
 			setFlag(L1270_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad);
@@ -539,8 +539,8 @@ int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
 		}
 		break;
 	case k2_spellKindProjectile:
-		if (L1270_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) {
-			L1270_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
+		if (L1270_ps_Champion->_dir != _vm->_dungeonMan->_partyDir) {
+			L1270_ps_Champion->_dir = _vm->_dungeonMan->_partyDir;
 			setFlag(L1270_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon);
 			_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 		}
@@ -601,13 +601,13 @@ T0412019:
 T0412032:
 			AL1267_ui_Ticks = AL1267_ui_SpellPower * AL1267_ui_SpellPower;
 T0412033:
-			setMapAndTime(L1276_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + AL1267_ui_Ticks);
+			setMapAndTime(L1276_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + AL1267_ui_Ticks);
 			_vm->_timeline->f238_addEventGetEventIndex(&L1276_s_Event);
 			break;
 		case k7_spellType_otherZokathra:
-			if ((L1272_T_Object = _vm->_dungeonMan->f166_getUnusedThing(k10_JunkThingType)) == Thing::_none)
+			if ((L1272_T_Object = _vm->_dungeonMan->getUnusedThing(k10_JunkThingType)) == Thing::_none)
 				break;
-			L1277_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1272_T_Object);
+			L1277_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L1272_T_Object);
 			L1277_ps_Junk->setType(k51_JunkTypeZokathra);
 			ChampionSlot AL1267_ui_SlotIndex;
 			if (L1270_ps_Champion->_slots[k0_ChampionSlotReadyHand] == Thing::_none) {
@@ -623,7 +623,7 @@ T0412033:
 				_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, L1272_T_Object, AL1267_ui_SlotIndex);
 				_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 			} else {
-				_vm->_moveSens->f267_getMoveResult(L1272_T_Object, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+				_vm->_moveSens->f267_getMoveResult(L1272_T_Object, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
 			}
 			break;
 		case k8_spellType_otherFireshield:
@@ -741,7 +741,7 @@ Potion* MenuMan::f411_getEmptyFlaskInHand(Champion* champ, Thing* potionThing) {
 	for (L1266_i_SlotIndex = k2_ChampionSlotHead; --L1266_i_SlotIndex >= k0_ChampionSlotReadyHand; ) {
 		if (((L1265_T_Thing = champ->_slots[L1266_i_SlotIndex]) != Thing::_none) && (_vm->_objectMan->f33_getIconIndex(L1265_T_Thing) == k195_IconIndicePotionEmptyFlask)) {
 			*potionThing = L1265_T_Thing;
-			return (Potion*)_vm->_dungeonMan->f156_getThingData(L1265_T_Thing);
+			return (Potion*)_vm->_dungeonMan->getThingData(L1265_T_Thing);
 		}
 	}
 	return nullptr;
@@ -752,7 +752,7 @@ void MenuMan::f404_createEvent70_light(int16 lightPower, int16 ticks) {
 
 	L1241_s_Event._type = k70_TMEventTypeLight;
 	L1241_s_Event._B._lightPower = lightPower;
-	setMapAndTime(L1241_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + ticks);
+	setMapAndTime(L1241_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + ticks);
 	L1241_s_Event._priority = 0;
 	_vm->_timeline->f238_addEventGetEventIndex(&L1241_s_Event);
 	_vm->_inventoryMan->f337_setDungeonViewPalette();
@@ -791,7 +791,7 @@ bool MenuMan::f403_isPartySpellOrFireShieldSuccessful(Champion* champ, bool spel
 		_vm->_championMan->_party._fireShieldDefense += L1240_s_Event._B._defense;
 	}
 	L1240_s_Event._priority = 0;
-	setMapAndTime(L1240_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + ticks);
+	setMapAndTime(L1240_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + ticks);
 	_vm->_timeline->f238_addEventGetEventIndex(&L1240_s_Event);
 	_vm->_timeline->f260_timelineRefreshAllChampionStatusBoxes();
 	return L1239_B_IsPartySpellOrFireShieldSuccessful;
@@ -1078,19 +1078,19 @@ bool MenuMan::f407_isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		return false;
 	}
 	L1247_ps_Champion = &_vm->_championMan->_champions[champIndex];
-	L1248_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L1247_ps_Champion->_slots[k1_ChampionSlotActionHand]);
+	L1248_ps_Weapon = (Weapon*)_vm->_dungeonMan->getThingData(L1247_ps_Champion->_slots[k1_ChampionSlotActionHand]);
 	if (!L1247_ps_Champion->_currHealth) {
 		return false;
 	}
-	L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
-	L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+	L1251_i_MapX = _vm->_dungeonMan->_partyMapX;
+	L1252_i_MapY = _vm->_dungeonMan->_partyMapY;
 	L1251_i_MapX += _vm->_dirIntoStepCountEast[L1247_ps_Champion->_dir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[L1247_ps_Champion->_dir];
 	_g517_actionTargetGroupThing = _vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY);
 	L1249_ui_ActionDisabledTicks = G0491_auc_Graphic560_ActionDisabledTicks[actionIndex];
 	L1254_i_ActionSkillIndex = g496_ActionSkillIndex[actionIndex];
 	L1253_i_ActionStamina = G0494_auc_Graphic560_ActionStamina[actionIndex] + _vm->getRandomNumber(2);
 	L1255_i_ActionExperienceGain = G0497_auc_Graphic560_ActionExperienceGain[actionIndex];
-	AL1244_ui_TargetSquare = _vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).toByte();
+	AL1244_ui_TargetSquare = _vm->_dungeonMan->getSquare(L1251_i_MapX, L1252_i_MapY).toByte();
 	AL1245_B_ActionPerformed = true;
 	if (((L1254_i_ActionSkillIndex >= k16_ChampionSkillFire) && (L1254_i_ActionSkillIndex <= k19_ChampionSkillWater)) || (L1254_i_ActionSkillIndex == k3_ChampionSkillWizard)) {
 		AL1246_i_RequiredManaAmount = 7 - MIN((uint16)6, _vm->_championMan->getSkillLevel(champIndex, L1254_i_ActionSkillIndex));
@@ -1129,10 +1129,10 @@ T0407014:
 	case k13_ChampionActionSwing:
 	case k2_ChampionActionChop:
 		if ((Square(AL1244_ui_TargetSquare).getType() == k4_DoorElemType) && (Square(AL1244_ui_TargetSquare).getDoorState() == k4_doorState_CLOSED)) {
-			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 			L1249_ui_ActionDisabledTicks = 6;
 			_vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
-			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater);
+			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k2_soundModePlayOneTickLater);
 			break;
 		}
 	case k24_ChampionActionDisrupt:
@@ -1169,7 +1169,7 @@ T0407014:
 		if (Thing(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]).getType() != k5_WeaponThingType)
 			goto T0407032;
 		L1256_ps_WeaponInfoActionHand = &_vm->_dungeonMan->_weaponInfo[L1248_ps_Weapon->getType()];
-		L1257_ps_WeaponInfoReadyHand = _vm->_dungeonMan->f158_getWeaponInfo(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]);
+		L1257_ps_WeaponInfoReadyHand = _vm->_dungeonMan->getWeaponInfo(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]);
 		AL1246_i_ActionHandWeaponClass = L1256_ps_WeaponInfoActionHand->_class;
 		AL1250_i_ReadyHandWeaponClass = L1257_ps_WeaponInfoReadyHand->_class;
 		if ((AL1246_i_ActionHandWeaponClass >= k16_WeaponClassFirstBow) && (AL1246_i_ActionHandWeaponClass <= k31_WeaponClassLastBow)) {
@@ -1191,7 +1191,7 @@ T0407032:
 		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
 		{ // so gotos won't skip init
 			Thing AL1250_T_Object = _vm->_championMan->getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
-			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 			_vm->_championMan->championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy);
 		}
 		break;
@@ -1243,9 +1243,9 @@ T0407032:
 		break;
 	case k43_ChampionActionFuse:
 		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
-		L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
-		L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
-		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+		L1251_i_MapX = _vm->_dungeonMan->_partyMapX;
+		L1252_i_MapY = _vm->_dungeonMan->_partyMapY;
+		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
 		_vm->_groupMan->f225_fuseAction(L1251_i_MapX, L1252_i_MapY);
 		break;
 	case k36_ChampionActionHeal:
@@ -1273,20 +1273,20 @@ T0407032:
 		AL1246_i_Ticks = _vm->getRandomNumber(_vm->_championMan->getSkillLevel(champIndex, L1254_i_ActionSkillIndex) + 8) + 5;
 		L1258_s_Event._priority = 0;
 		L1258_s_Event._type = k73_TMEventTypeThievesEye;
-		setMapAndTime(L1258_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + AL1246_i_Ticks);
+		setMapAndTime(L1258_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + AL1246_i_Ticks);
 		_vm->_timeline->f238_addEventGetEventIndex(&L1258_s_Event);
 		_vm->_championMan->_party._event73Count_ThievesEye++;
 		goto T0407076;
 	case k10_ChampionActionClimbDown:
-		L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
-		L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
-		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir];
-		L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+		L1251_i_MapX = _vm->_dungeonMan->_partyMapX;
+		L1252_i_MapY = _vm->_dungeonMan->_partyMapY;
+		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir];
+		L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
 		/* CHANGE6_00_FIX The presence of a group over the pit is checked so that you cannot climb down a pit with the rope if there is a group levitating over it */
-		if ((_vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_PitElemType) && (_vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY) == Thing::_endOfList)) {
+		if ((_vm->_dungeonMan->getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_PitElemType) && (_vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY) == Thing::_endOfList)) {
 			/* BUG0_77 The party moves forward when using the rope in front of a closed pit. The engine does not check whether the pit is open before moving the party over the pit. This is not consistent with the behavior when using the rope in front of a corridor where nothing happens */
 			_vm->_moveSens->_g402_useRopeToClimbDownPit = true;
-			_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1251_i_MapX, L1252_i_MapY);
+			_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, L1251_i_MapX, L1252_i_MapY);
 			_vm->_moveSens->_g402_useRopeToClimbDownPit = false;
 		} else {
 			L1249_ui_ActionDisabledTicks = 0;
@@ -1316,7 +1316,7 @@ T0407076:
 		break;
 	case k42_ChampionActionThrow:
 		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
-		AL1245_B_ActionPerformed = _vm->_championMan->isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_g308_partyDir)) || (L1247_ps_Champion->_cell == (ViewCell)returnOppositeDir(_vm->_dungeonMan->_g308_partyDir)));
+		AL1245_B_ActionPerformed = _vm->_championMan->isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_partyDir)) || (L1247_ps_Champion->_cell == (ViewCell)returnOppositeDir(_vm->_dungeonMan->_partyDir)));
 		if (AL1245_B_ActionPerformed) {
 			_vm->_timeline->_g370_events[L1247_ps_Champion->_enableActionEventIndex]._B._slotOrdinal = _vm->indexToOrdinal(k1_ChampionSlotActionHand);
 		}
@@ -1335,8 +1335,8 @@ T0407076:
 }
 
 void MenuMan::f406_setChampionDirectionToPartyDirection(Champion* champ) {
-	if (champ->_dir != _vm->_dungeonMan->_g308_partyDir) {
-		champ->_dir = _vm->_dungeonMan->_g308_partyDir;
+	if (champ->_dir != _vm->_dungeonMan->_partyDir) {
+		champ->_dir = _vm->_dungeonMan->_partyDir;
 		setFlag(champ->_attributes, k0x0400_ChampionAttributeIcon);
 	}
 }
@@ -1345,7 +1345,7 @@ void MenuMan::f405_decrementCharges(Champion* champ) {
 	Thing L1242_T_Thing;
 	Junk* L1243_ps_Junk;
 
-	L1243_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1242_T_Thing = champ->_slots[k1_ChampionSlotActionHand]);
+	L1243_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L1242_T_Thing = champ->_slots[k1_ChampionSlotActionHand]);
 	switch (L1242_T_Thing.getType()) {
 	case k5_WeaponThingType:
 		if (((Weapon*)L1243_ps_Junk)->getChargeCount()) {
@@ -1469,10 +1469,10 @@ bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int
 #define AL1237_ui_ActionHitProbability L1237_ui_Multiple
 	int16 L1238_i_CreatureOrdinal;
 
-	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 	if (_g517_actionTargetGroupThing == Thing::_endOfList)
 		goto T0402010;
-	L1238_i_CreatureOrdinal = _vm->_groupMan->f177_getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, AL1236_ui_ChampionCell = champ->_cell);
+	L1238_i_CreatureOrdinal = _vm->_groupMan->f177_getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, AL1236_ui_ChampionCell = champ->_cell);
 	if (L1238_i_CreatureOrdinal) {
 		switch (normalizeModulo4(AL1236_ui_ChampionCell + 4 - champ->_dir)) {
 		case k2_ViewCellBackRight: /* Champion is on the back right of the square and tries to attack a creature in the front right of its square */
@@ -1486,14 +1486,14 @@ T0402005: /* Check if there is another champion in front */
 				goto T0402010;
 			}
 		}
-		if ((actionIndex == k24_ChampionActionDisrupt) && !getFlag(_vm->_dungeonMan->f144_getCreatureAttributes(_g517_actionTargetGroupThing), k0x0040_MaskCreatureInfo_nonMaterial))
+		if ((actionIndex == k24_ChampionActionDisrupt) && !getFlag(_vm->_dungeonMan->getCreatureAttributes(_g517_actionTargetGroupThing), k0x0040_MaskCreatureInfo_nonMaterial))
 			goto T0402010;
 		AL1237_ui_ActionHitProbability = G0493_auc_Graphic560_ActionHitProbability[actionIndex];
 		AL1236_ui_ActionDamageFactor = G0492_auc_Graphic560_ActionDamageFactor[actionIndex];
 		if ((_vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
 			setFlag(AL1237_ui_ActionHitProbability, k0x8000_hitNonMaterialCreatures);
 		}
-		_g513_actionDamage = _vm->_groupMan->f231_getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing), _vm->ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
+		_g513_actionDamage = _vm->_groupMan->f231_getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->getThingData(_g517_actionTargetGroupThing), _vm->ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
 		return true;
 	}
 T0402010:
@@ -1535,7 +1535,7 @@ bool MenuMan::f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionInde
 		L1231_ui_Experience = 45;
 	}
 	L1229_i_FrightAmount += _vm->_championMan->getSkillLevel(champIndex, k14_ChampionSkillInfluence);
-	L1233_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing);
+	L1233_ps_Group = (Group*)_vm->_dungeonMan->getThingData(_g517_actionTargetGroupThing);
 	L1234_ps_CreatureInfo = &g243_CreatureInfo[L1233_ps_Group->_type];
 	if (((L1230_ui_FearResistance = L1234_ps_CreatureInfo->getFearResistance()) > _vm->getRandomNumber(L1229_i_FrightAmount)) || (L1230_ui_FearResistance == k15_immuneToFear)) {
 		L1231_ui_Experience >>= 1;
@@ -1645,7 +1645,7 @@ void MenuMan::f389_processCommands116To119_setActingChampion(uint16 champIndex)
 	}
 	if ((L1189_T_Thing = L1190_ps_Champion->_slots[k1_ChampionSlotActionHand]) == Thing::_none) {
 		L1188_ui_ActionSetIndex = 2; /* Actions Punch, Kick and War Cry */
-	} else if ((L1188_ui_ActionSetIndex = _vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1189_T_Thing)]._actionSetIndex) == 0) {
+	} else if ((L1188_ui_ActionSetIndex = _vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(L1189_T_Thing)]._actionSetIndex) == 0) {
 		return;
 	}
 	L1191_ps_ActionSet = &G0489_as_Graphic560_ActionSets[L1188_ui_ActionSetIndex];
@@ -1693,7 +1693,7 @@ int16 MenuMan::f382_getActionObjectChargeCount() {
 	Junk* L1168_ps_Junk;
 
 
-	L1168_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1167_T_Thing = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand]);
+	L1168_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L1167_T_Thing = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand]);
 	switch (L1167_T_Thing.getType()) {
 	case k5_WeaponThingType:
 		return ((Weapon*)L1168_ps_Junk)->getChargeCount();
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index b24a997..ac66f23 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -77,7 +77,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 	for (L0752_ui_Cell = k0_CellNorthWest; L0752_ui_Cell < k3_CellSouthWest + 1; L0752_ui_Cell++) {
 		L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell] = 0;
 	}
-	L0764_T_SquareFirstThing = L0750_T_ThingBeingProcessed = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
+	L0764_T_SquareFirstThing = L0750_T_ThingBeingProcessed = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
 	while (L0750_T_ThingBeingProcessed != Thing::_endOfList) {
 		if ((L0751_ui_ThingType = (L0750_T_ThingBeingProcessed).getType()) == k3_SensorThingType) {
 			L0760_ai_SensorCountToProcessPerCell[(L0750_T_ThingBeingProcessed).getCell()]++;
@@ -85,13 +85,13 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 			if (L0751_ui_ThingType >= k4_GroupThingType)
 				break;
 		}
-		L0750_T_ThingBeingProcessed = _vm->_dungeonMan->f159_getNextThing(L0750_T_ThingBeingProcessed);
+		L0750_T_ThingBeingProcessed = _vm->_dungeonMan->getNextThing(L0750_T_ThingBeingProcessed);
 	}
 	L0763_T_LastProcessedThing = L0750_T_ThingBeingProcessed = L0764_T_SquareFirstThing;
 	while (L0750_T_ThingBeingProcessed != Thing::_endOfList) {
 		if ((L0751_ui_ThingType = (L0750_T_ThingBeingProcessed).getType()) == k3_SensorThingType) {
 			L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell = (L0750_T_ThingBeingProcessed).getCell()]--;
-			L0755_ps_Sensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0750_T_ThingBeingProcessed);
+			L0755_ps_Sensor = (Sensor *)_vm->_dungeonMan->getThingData(L0750_T_ThingBeingProcessed);
 			if ((L0757_ui_SensorType = (L0755_ps_Sensor)->getType()) == k0_SensorDisabled)
 				goto T0275058_ProceedToNextThing;
 			if ((_vm->_championMan->_leaderIndex == kM1_ChampionNone) && (L0757_ui_SensorType != k127_SensorWallChampionPortrait))
@@ -99,16 +99,16 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 			if (L0752_ui_Cell != cellParam)
 				goto T0275058_ProceedToNextThing;
 			L0758_i_SensorData = L0755_ps_Sensor->getData();
-			L0756_i_SensorEffect = L0755_ps_Sensor->getEffectA();
+			L0756_i_SensorEffect = L0755_ps_Sensor->getAttrEffectA();
 			switch (L0757_ui_SensorType) {
 			case k1_SensorWallOrnClick:
 				L0753_B_DoNotTriggerSensor = false;
-				if (L0755_ps_Sensor->getEffectA() == k3_SensorEffHold) {
+				if (L0755_ps_Sensor->getAttrEffectA() == k3_SensorEffHold) {
 					goto T0275058_ProceedToNextThing;
 				}
 				break;
 			case k2_SensorWallOrnClickWithAnyObj:
-				L0753_B_DoNotTriggerSensor = (_vm->_championMan->_leaderEmptyHanded != L0755_ps_Sensor->getRevertEffectA());
+				L0753_B_DoNotTriggerSensor = (_vm->_championMan->_leaderEmptyHanded != L0755_ps_Sensor->getAttrRevertEffectA());
 				break;
 			case k17_SensorWallOrnClickWithSpecObjRemovedSensor:
 			case k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors:
@@ -116,11 +116,11 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 					goto T0275058_ProceedToNextThing;
 			case k3_SensorWallOrnClickWithSpecObj:
 			case k4_SensorWallOrnClickWithSpecObjRemoved:
-				L0753_B_DoNotTriggerSensor = ((L0758_i_SensorData == _vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject)) == L0755_ps_Sensor->getRevertEffectA());
+				L0753_B_DoNotTriggerSensor = ((L0758_i_SensorData == _vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject)) == L0755_ps_Sensor->getAttrRevertEffectA());
 				if (!L0753_B_DoNotTriggerSensor && (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) {
 					if (L0763_T_LastProcessedThing == L0750_T_ThingBeingProcessed) /* If the sensor is the only one of its type on the cell */
 						break;
-					L0765_ps_Sensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0763_T_LastProcessedThing);
+					L0765_ps_Sensor = (Sensor *)_vm->_dungeonMan->getThingData(L0763_T_LastProcessedThing);
 					L0765_ps_Sensor->setNextThing(L0755_ps_Sensor->getNextThing());
 					L0755_ps_Sensor->setNextThing(Thing::_none);
 					L0750_T_ThingBeingProcessed = L0763_T_LastProcessedThing;
@@ -141,13 +141,13 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 				if (_vm->_championMan->_leaderEmptyHanded) {
 					if ((L0761_T_LeaderHandObject = f273_sensorGetObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData)) == Thing::_none)
 						goto T0275058_ProceedToNextThing;
-					_vm->_dungeonMan->f164_unlinkThingFromList(L0761_T_LeaderHandObject, Thing(0), mapX, mapY);
+					_vm->_dungeonMan->unlinkThingFromList(L0761_T_LeaderHandObject, Thing(0), mapX, mapY);
 					_vm->_championMan->putObjectInLeaderHand(L0761_T_LeaderHandObject, true);
 				} else {
 					if ((_vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (f273_sensorGetObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData) != Thing::_none))
 						goto T0275058_ProceedToNextThing;
 					_vm->_championMan->getObjectRemovedFromLeaderHand();
-					_vm->_dungeonMan->f163_linkThingToList(thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
+					_vm->_dungeonMan->linkThingToList(thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
 					L0761_T_LeaderHandObject = Thing::_none;
 				}
 				f270_sensorTriggetLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
@@ -160,12 +160,12 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 			case k16_SensorWallObjExchanger:
 				if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */
 					goto T0275058_ProceedToNextThing;
-				L0762_T_ThingOnSquare = _vm->_dungeonMan->f162_getSquareFirstObject(mapX, mapY);
+				L0762_T_ThingOnSquare = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
 				if ((_vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (L0762_T_ThingOnSquare == Thing::_none))
 					goto T0275058_ProceedToNextThing;
-				_vm->_dungeonMan->f164_unlinkThingFromList(L0762_T_ThingOnSquare, Thing(0), mapX, mapY);
+				_vm->_dungeonMan->unlinkThingFromList(L0762_T_ThingOnSquare, Thing(0), mapX, mapY);
 				_vm->_championMan->getObjectRemovedFromLeaderHand();
-				_vm->_dungeonMan->f163_linkThingToList(thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
+				_vm->_dungeonMan->linkThingToList(thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
 				_vm->_championMan->putObjectInLeaderHand(L0762_T_ThingOnSquare, true);
 				L0753_B_DoNotTriggerSensor = false;
 				break;
@@ -181,18 +181,18 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 			}
 			if (!L0753_B_DoNotTriggerSensor) {
 				L0759_B_AtLeastOneSensorWasTriggered = true;
-				if (L0755_ps_Sensor->getAudibleA()) {
-					_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized);
+				if (L0755_ps_Sensor->getAttrAudibleA()) {
+					_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 				}
 				if (!_vm->_championMan->_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
-					L0754_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0761_T_LeaderHandObject);
+					L0754_ps_Generic = (Thing *)_vm->_dungeonMan->getThingData(L0761_T_LeaderHandObject);
 					*L0754_ps_Generic = Thing::_none;
 					_vm->_championMan->getObjectRemovedFromLeaderHand();
 					L0761_T_LeaderHandObject = Thing::_none;
 				} else {
 					if (_vm->_championMan->_leaderEmptyHanded &&
 						(L0757_ui_SensorType == k12_SensorWallObjGeneratorRotateSensors) &&
-						((L0761_T_LeaderHandObject = _vm->_dungeonMan->f167_getObjForProjectileLaucherOrObjGen(L0758_i_SensorData)) != Thing::_none)) {
+						((L0761_T_LeaderHandObject = _vm->_dungeonMan->getObjForProjectileLaucherOrObjGen(L0758_i_SensorData)) != Thing::_none)) {
 						_vm->_championMan->putObjectInLeaderHand(L0761_T_LeaderHandObject, true);
 					}
 				}
@@ -204,7 +204,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 			break;
 T0275058_ProceedToNextThing:
 		L0763_T_LastProcessedThing = L0750_T_ThingBeingProcessed;
-		L0750_T_ThingBeingProcessed = _vm->_dungeonMan->f159_getNextThing(L0750_T_ThingBeingProcessed);
+		L0750_T_ThingBeingProcessed = _vm->_dungeonMan->getNextThing(L0750_T_ThingBeingProcessed);
 	}
 	f271_processRotationEffect();
 	return L0759_B_AtLeastOneSensorWasTriggered;
@@ -245,7 +245,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 		L0713_B_ThingLevitates = f264_isLevitating(thing);
 	}
 	/* If moving the party or a creature on the party map from a dungeon square then check for a projectile impact */
-	if ((mapX >= 0) && ((thing == Thing::_party) || ((L0710_i_ThingType == k4_GroupThingType) && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)))) {
+	if ((mapX >= 0) && ((thing == Thing::_party) || ((L0710_i_ThingType == k4_GroupThingType) && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex)))) {
 		if (f266_moveIsKilledByProjectileImpact(mapX, mapY, destMapX, destMapY, thing)) {
 			return true; /* The specified group thing cannot be moved because it was killed by a projectile impact */
 		}
@@ -258,18 +258,18 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 	bool L0726_B_Audible = false;
 
 	if (destMapX >= 0) {
-		L0714_ui_MapIndexSource = L0715_ui_MapIndexDestination = _vm->_dungeonMan->_g272_currMapIndex;
-		L0721_B_GroupOnPartyMap = (L0714_ui_MapIndexSource == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX >= 0);
+		L0714_ui_MapIndexSource = L0715_ui_MapIndexDestination = _vm->_dungeonMan->_currMapIndex;
+		L0721_B_GroupOnPartyMap = (L0714_ui_MapIndexSource == _vm->_dungeonMan->_partyMapIndex) && (mapX >= 0);
 		uint16 L0716_ui_Direction = 0;
 		bool L0722_B_FallKilledGroup = false;
 		bool L0723_B_DrawDungeonViewWhileFalling = false;
 		bool L0724_B_DestinationIsTeleporterTarget = false;
 		if (thing == Thing::_party) {
-			_vm->_dungeonMan->_g306_partyMapX = destMapX;
-			_vm->_dungeonMan->_g307_partyMapY = destMapY;
+			_vm->_dungeonMan->_partyMapX = destMapX;
+			_vm->_dungeonMan->_partyMapY = destMapY;
 			L0718_i_RequiredTeleporterScope = k0x0002_TelepScopeObjOrParty;
 			L0723_B_DrawDungeonViewWhileFalling = !_vm->_inventoryMan->_g432_inventoryChampionOrdinal && !_vm->_championMan->_partyIsSleeping;
-			L0716_ui_Direction = _vm->_dungeonMan->_g308_partyDir;
+			L0716_ui_Direction = _vm->_dungeonMan->_partyDir;
 		} else {
 			if (L0710_i_ThingType == k4_GroupThingType) {
 				L0718_i_RequiredTeleporterScope = k0x0001_TelepScopeCreatures;
@@ -278,15 +278,15 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 			}
 		}
 		if (L0710_i_ThingType == k14_ProjectileThingType) {
-			L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f156_getThingData(thing);
+			L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(thing);
 			_g400_moveResultDir = (_vm->_timeline->_g370_events[((Projectile *)L0712_ps_Teleporter)->_eventIndex])._C._projectile.getDir();
 		}
 		for (L0728_i_ChainedMoveCount = 1000; --L0728_i_ChainedMoveCount; ) { /* No more than 1000 chained moves at once (in a chain of teleporters and pits for example) */
-			AL0708_i_DestinationSquare = _vm->_dungeonMan->_g271_currMapData[destMapX][destMapY];
+			AL0708_i_DestinationSquare = _vm->_dungeonMan->_currMapData[destMapX][destMapY];
 			if ((AL0709_i_DestinationSquareType = Square(AL0708_i_DestinationSquare).getType()) == k5_ElementTypeTeleporter) {
 				if (!getFlag(AL0708_i_DestinationSquare, k0x0008_TeleporterOpen))
 					break;
-				L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f157_getSquareFirstThingData(destMapX, destMapY);
+				L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getSquareFirstThingData(destMapX, destMapY);
 				if ((L0712_ps_Teleporter->getScope() == k0x0001_TelepScopeCreatures) && (L0710_i_ThingType != k4_GroupThingType))
 					break;
 				if ((L0718_i_RequiredTeleporterScope != (k0x0001_TelepScopeCreatures | k0x0002_TelepScopeObjOrParty)) && !getFlag(L0712_ps_Teleporter->getScope(), L0718_i_RequiredTeleporterScope))
@@ -295,18 +295,18 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				destMapX = L0712_ps_Teleporter->getTargetMapX();
 				destMapY = L0712_ps_Teleporter->getTargetMapY();
 				L0726_B_Audible = L0712_ps_Teleporter->isAudible();
-				_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination = L0712_ps_Teleporter->getTargetMapIndex());
+				_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination = L0712_ps_Teleporter->getTargetMapIndex());
 				if (thing == Thing::_party) {
-					_vm->_dungeonMan->_g306_partyMapX = destMapX;
-					_vm->_dungeonMan->_g307_partyMapY = destMapY;
+					_vm->_dungeonMan->_partyMapX = destMapX;
+					_vm->_dungeonMan->_partyMapY = destMapY;
 					if (L0712_ps_Teleporter->isAudible()) {
-						_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
+						_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
 					}
 					L0723_B_DrawDungeonViewWhileFalling = true;
 					if (L0712_ps_Teleporter->getAbsoluteRotation()) {
 						_vm->_championMan->setPartyDirection(L0712_ps_Teleporter->getRotation());
 					} else {
-						_vm->_championMan->setPartyDirection(normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + L0712_ps_Teleporter->getRotation()));
+						_vm->_championMan->setPartyDirection(normalizeModulo4(_vm->_dungeonMan->_partyDir + L0712_ps_Teleporter->getRotation()));
 					}
 				} else {
 					if (L0710_i_ThingType == k4_GroupThingType) {
@@ -331,19 +331,19 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					if (L0723_B_DrawDungeonViewWhileFalling && !_g402_useRopeToClimbDownPit) {
 						L0723_B_DrawDungeonViewWhileFalling = true;
 						if (L0719_i_TraversedPitCount) {
-							_vm->_dungeonMan->f174_setCurrentMapAndPartyMap(L0715_ui_MapIndexDestination);
+							_vm->_dungeonMan->setCurrentMapAndPartyMap(L0715_ui_MapIndexDestination);
 							_vm->_displayMan->f96_loadCurrentMapGraphics();
 						}
 						L0719_i_TraversedPitCount++;
-						_vm->_displayMan->f128_drawDungeon(_vm->_dungeonMan->_g308_partyDir, destMapX, destMapY); /* BUG0_28 When falling through multiple pits the dungeon view is updated to show each traversed map but the graphics used for creatures, wall and floor ornaments may not be correct. The dungeon view is drawn for each map by using the graphics loaded for the source map. Therefore the graphics for creatures, wall and floor ornaments may not look like what they should */
+						_vm->_displayMan->f128_drawDungeon(_vm->_dungeonMan->_partyDir, destMapX, destMapY); /* BUG0_28 When falling through multiple pits the dungeon view is updated to show each traversed map but the graphics used for creatures, wall and floor ornaments may not be correct. The dungeon view is drawn for each map by using the graphics loaded for the source map. Therefore the graphics for creatures, wall and floor ornaments may not look like what they should */
 																												  /* BUG0_71 Some timings are too short on fast computers. When the party falls in a series of pits, the dungeon view is refreshed too quickly because the execution speed is not limited */
 																												  /* BUG0_01 While drawing creatures the engine will read invalid ACTIVE_GROUP data in _vm->_groupMan->_g375_activeGroups because the data is for the creatures on the source map and not the map being drawn. The only consequence is that creatures may be drawn with incorrect bitmaps and/or directions */
 					}
-					L0715_ui_MapIndexDestination = _vm->_dungeonMan->f154_getLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &destMapX, &destMapY);
-					_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination);
+					L0715_ui_MapIndexDestination = _vm->_dungeonMan->getLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &destMapX, &destMapY);
+					_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
 					if (thing == Thing::_party) {
-						_vm->_dungeonMan->_g306_partyMapX = destMapX;
-						_vm->_dungeonMan->_g307_partyMapY = destMapY;
+						_vm->_dungeonMan->_partyMapX = destMapX;
+						_vm->_dungeonMan->_partyMapY = destMapY;
 						if (_vm->_championMan->_partyChampionCount > 0) {
 							if (_g402_useRopeToClimbDownPit) {
 								for (AL0709_i_ChampionIndex = k0_ChampionFirst, L0711_ps_Champion = _vm->_championMan->_champions; AL0709_i_ChampionIndex < _vm->_championMan->_partyChampionCount; AL0709_i_ChampionIndex++, L0711_ps_Champion++) {
@@ -353,16 +353,16 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 								}
 							} else {
 								if (_vm->_championMan->getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF)) {
-									_vm->_sound->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately);
+									_vm->_sound->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
 								}
 							}
 						}
 						_g402_useRopeToClimbDownPit = false;
 					} else {
 						if (L0710_i_ThingType == k4_GroupThingType) {
-							_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
-							AL0727_ui_Outcome = _vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group *)_vm->_dungeonMan->f156_getThingData(thing), mapX, mapY, 20, false);
-							_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination);
+							_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
+							AL0727_ui_Outcome = _vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group *)_vm->_dungeonMan->getThingData(thing), mapX, mapY, 20, false);
+							_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
 							L0722_B_FallKilledGroup = (AL0727_ui_Outcome == k2_outcomeKilledAllCreaturesInGroup);
 							if (L0722_B_FallKilledGroup)
 								break;
@@ -374,10 +374,10 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				} else {
 					if ((AL0709_i_DestinationSquareType == k3_ElementTypeStairs) && (thing != Thing::_party) && (L0710_i_ThingType != k14_ProjectileThingType)) {
 						if (!getFlag(AL0708_i_DestinationSquare, k0x0004_StairsUp)) {
-							L0715_ui_MapIndexDestination = _vm->_dungeonMan->f154_getLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &destMapX, &destMapY);
-							_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination);
+							L0715_ui_MapIndexDestination = _vm->_dungeonMan->getLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &destMapX, &destMapY);
+							_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
 						}
-						L0716_ui_Direction = _vm->_dungeonMan->f155_getStairsExitDirection(destMapX, destMapY);
+						L0716_ui_Direction = _vm->_dungeonMan->getStairsExitDirection(destMapX, destMapY);
 						destMapX += _vm->_dirIntoStepCountEast[L0716_ui_Direction], destMapY += _vm->_dirIntoStepCountNorth[L0716_ui_Direction];
 						L0716_ui_Direction = returnOppositeDir((Direction)L0716_ui_Direction);
 						AL0727_ui_ThingCell = thing.getCell();
@@ -388,10 +388,10 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				}
 			}
 		}
-		if ((L0710_i_ThingType == k4_GroupThingType) && (L0722_B_FallKilledGroup || !_vm->_dungeonMan->f139_isCreatureAllowedOnMap(thing, L0715_ui_MapIndexDestination))) {
+		if ((L0710_i_ThingType == k4_GroupThingType) && (L0722_B_FallKilledGroup || !_vm->_dungeonMan->isCreatureAllowedOnMap(thing, L0715_ui_MapIndexDestination))) {
 			_vm->_groupMan->f187_dropMovingCreatureFixedPossession(thing, destMapX, destMapY);
 			_vm->_groupMan->f188_dropGroupPossessions(destMapX, destMapY, thing, k2_soundModePlayOneTickLater);
-			_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
+			_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
 			if (mapX >= 0) {
 				_vm->_groupMan->f189_delete(mapX, mapY);
 			}
@@ -404,7 +404,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 		L0725_B_PartySquare = (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) && (destMapX == mapX) && (destMapY == mapY);
 		if (L0725_B_PartySquare) {
 			if (thing == Thing::_party) {
-				if (_vm->_dungeonMan->_g308_partyDir == L0716_ui_Direction) {
+				if (_vm->_dungeonMan->_partyDir == L0716_ui_Direction) {
 					return false;
 				}
 			} else {
@@ -436,7 +436,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				AL0708_i_DestinationSquare = AL0727_ui_Backup;
 			}
 			if (L0715_ui_MapIndexDestination != L0714_ui_MapIndexSource) {
-				_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
+				_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
 			}
 		}
 	}
@@ -445,32 +445,32 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 			f276_sensorProcessThingAdditionOrRemoval(mapX, mapY, Thing::_party, L0725_B_PartySquare, false);
 		} else {
 			if (L0713_B_ThingLevitates) {
-				_vm->_dungeonMan->f164_unlinkThingFromList(thing, Thing(0), mapX, mapY);
+				_vm->_dungeonMan->unlinkThingFromList(thing, Thing(0), mapX, mapY);
 			} else {
-				f276_sensorProcessThingAdditionOrRemoval(mapX, mapY, thing, (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX == _vm->_dungeonMan->_g306_partyMapX) && (mapY == _vm->_dungeonMan->_g307_partyMapY), false);
+				f276_sensorProcessThingAdditionOrRemoval(mapX, mapY, thing, (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY), false);
 			}
 		}
 	}
 	if (destMapX >= 0) {
 		if (thing == Thing::_party) {
-			_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination);
-			if ((thing = _vm->_groupMan->f175_groupGetThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY)) != Thing::_endOfList) { /* Delete group if party moves onto its square */
-				_vm->_groupMan->f188_dropGroupPossessions(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, thing, k1_soundModePlayIfPrioritized);
-				_vm->_groupMan->f189_delete(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+			_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
+			if ((thing = _vm->_groupMan->f175_groupGetThing(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY)) != Thing::_endOfList) { /* Delete group if party moves onto its square */
+				_vm->_groupMan->f188_dropGroupPossessions(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, thing, k1_soundModePlayIfPrioritized);
+				_vm->_groupMan->f189_delete(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
 			}
 			if (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) {
-				f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, L0725_B_PartySquare, true);
+				f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, Thing::_party, L0725_B_PartySquare, true);
 			} else {
-				_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
+				_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
 				_vm->_newPartyMapIndex = L0715_ui_MapIndexDestination;
 			}
 		} else {
 			if (L0710_i_ThingType == k4_GroupThingType) {
-				_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination);
-				L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f156_getThingData(thing);
+				_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
+				L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(thing);
 				AL0708_i_ActiveGroupIndex = ((Group *)L0712_ps_Teleporter)->getActiveGroupIndex();
-				if (((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_g309_partyMapIndex) && (destMapX == _vm->_dungeonMan->_g306_partyMapX) && (destMapY == _vm->_dungeonMan->_g307_partyMapY)) || (_vm->_groupMan->f175_groupGetThing(destMapX, destMapY) != Thing::_endOfList)) { /* If a group tries to move to the party square or over another group then create an event to move the group later */
-					_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
+				if (((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_partyMapIndex) && (destMapX == _vm->_dungeonMan->_partyMapX) && (destMapY == _vm->_dungeonMan->_partyMapY)) || (_vm->_groupMan->f175_groupGetThing(destMapX, destMapY) != Thing::_endOfList)) { /* If a group tries to move to the party square or over another group then create an event to move the group later */
+					_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
 					if (mapX >= 0) {
 						_vm->_groupMan->f181_groupDeleteEvents(mapX, mapY);
 					}
@@ -480,28 +480,28 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					f265_createEvent60to61_moveGroup(thing, destMapX, destMapY, L0715_ui_MapIndexDestination, L0726_B_Audible);
 					return true; /* The specified group thing cannot be moved because the party or another group is on the destination square */
 				}
-				L1638_ui_MovementSoundIndex = f514_getSound(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[thing.getIndex()]._type);
+				L1638_ui_MovementSoundIndex = f514_getSound(((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[thing.getIndex()]._type);
 				if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) {
 					_vm->_sound->f064_SOUND_RequestPlay_CPSD(L1638_ui_MovementSoundIndex, destMapX, destMapY, k1_soundModePlayIfPrioritized);
 				}
-				if (L0721_B_GroupOnPartyMap && (L0715_ui_MapIndexDestination != _vm->_dungeonMan->_g309_partyMapIndex)) { /* If the group leaves the party map */
+				if (L0721_B_GroupOnPartyMap && (L0715_ui_MapIndexDestination != _vm->_dungeonMan->_partyMapIndex)) { /* If the group leaves the party map */
 					_vm->_groupMan->f184_removeActiveGroup(AL0708_i_ActiveGroupIndex);
 					L0720_ui_MoveGroupResult = true;
 				} else {
-					if ((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_g309_partyMapIndex) && (!L0721_B_GroupOnPartyMap)) { /* If the group arrives on the party map */
+					if ((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_partyMapIndex) && (!L0721_B_GroupOnPartyMap)) { /* If the group arrives on the party map */
 						_vm->_groupMan->f183_addActiveGroup(thing, destMapX, destMapY);
 						L0720_ui_MoveGroupResult = true;
 					}
 				}
 				if (L0713_B_ThingLevitates) {
-					_vm->_dungeonMan->f163_linkThingToList(thing, Thing(0), destMapX, destMapY);
+					_vm->_dungeonMan->linkThingToList(thing, Thing(0), destMapX, destMapY);
 				} else {
 					f276_sensorProcessThingAdditionOrRemoval(destMapX, destMapY, thing, false, true);
 				}
 				if (L0720_ui_MoveGroupResult || (mapX < 0)) { /* If group moved from one map to another or if it was just placed on a square */
 					_vm->_groupMan->f180_startWanedring(destMapX, destMapY);
 				}
-				_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
+				_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
 				if (mapX >= 0) {
 					if (L0720_ui_MoveGroupResult > 1) { /* If the group behavior was C6_BEHAVIOR_ATTACK before being teleported from and to the party map */
 						_vm->_groupMan->f182_stopAttacking(&_vm->_groupMan->_g375_activeGroups[L0720_ui_MoveGroupResult - 2], mapX, mapY);
@@ -513,13 +513,13 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				}
 				return L0720_ui_MoveGroupResult;
 			}
-			_vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination);
+			_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
 			if (L0710_i_ThingType == k14_ProjectileThingType) { /* BUG0_29 An explosion can trigger a floor sensor. Explosions do not trigger floor sensors on the square where they are created. However, if an explosion is moved by a teleporter (or by falling into a pit, see BUG0_26) after it was created, it can trigger floor sensors on the destination square. This is because explosions are not considered as levitating in the code, while projectiles are. The condition here should be (L0713_B_ThingLevitates) so that explosions would not start sensor processing on their destination square as they should be Levitating. This would work if F0264_MOVE_IsLevitating returned true for explosions (see BUG0_26) */
-				_vm->_dungeonMan->f163_linkThingToList(thing, Thing(0), destMapX, destMapY);
+				_vm->_dungeonMan->linkThingToList(thing, Thing(0), destMapX, destMapY);
 			} else {
-				f276_sensorProcessThingAdditionOrRemoval(destMapX, destMapY, thing, (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (destMapX == _vm->_dungeonMan->_g306_partyMapX) && (destMapY == _vm->_dungeonMan->_g307_partyMapY), true);
+				f276_sensorProcessThingAdditionOrRemoval(destMapX, destMapY, thing, (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (destMapX == _vm->_dungeonMan->_partyMapX) && (destMapY == _vm->_dungeonMan->_partyMapY), true);
 			}
-			_vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource);
+			_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
 		}
 	}
 	return false;
@@ -530,7 +530,7 @@ bool MovesensMan::f264_isLevitating(Thing thing) {
 
 
 	if ((L0695_i_ThingType = thing.getType()) == k4_GroupThingType) {
-		return getFlag(_vm->_dungeonMan->f144_getCreatureAttributes(thing), k0x0020_MaskCreatureInfo_levitation);
+		return getFlag(_vm->_dungeonMan->getCreatureAttributes(thing), k0x0020_MaskCreatureInfo_levitation);
 	}
 	if (L0695_i_ThingType == k14_ProjectileThingType) { /* BUG0_26 An explosion may fall in a pit. If a pit is opened while there is an explosion above then the explosion falls into the pit in F0267_MOVE_GetMoveResult_CPSCE. Explosions are not considered as levitating so they are moved when the pit is opened. This function should return true for explosions */
 		return true;
@@ -572,7 +572,7 @@ bool MovesensMan::f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMa
 		}
 	} else {
 		L0702_i_ImpactType = kM1_CreatureElemType;
-		L0701_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(thing);
+		L0701_ps_Group = (Group *)_vm->_dungeonMan->getThingData(thing);
 		for (AL0699_ui_Cell = k0_CellNorthWest, AL0700_B_CreatureAlive = false; AL0699_ui_Cell < k3_CellSouthWest + 1; AL0699_ui_Cell++) {
 			AL0700_B_CreatureAlive |= L0701_ps_Group->_health[AL0699_ui_Cell];
 			if (_vm->_groupMan->f176_getCreatureOrdinalInCell(L0701_ps_Group, AL0699_ui_Cell)) {
@@ -608,10 +608,10 @@ bool MovesensMan::f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMa
 	L0704_ui_ProjectileMapX = srcMapX; /* Check impacts with projectiles on the source square */
 	L0705_ui_ProjectileMapY = srcMapY;
 T0266017_CheckProjectileImpacts:
-	L0697_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0704_ui_ProjectileMapX, L0705_ui_ProjectileMapY);
+	L0697_T_Thing = _vm->_dungeonMan->getSquareFirstThing(L0704_ui_ProjectileMapX, L0705_ui_ProjectileMapY);
 	while (L0697_T_Thing != Thing::_endOfList) {
 		if (((L0697_T_Thing).getType() == k14_ProjectileThingType) &&
-			(_vm->_timeline->_g370_events[(((Projectile *)_vm->_dungeonMan->_g284_thingData[k14_ProjectileThingType])[(L0697_T_Thing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts) && (AL0699_ui_ChampionOrCreatureOrdinal = L0707_auc_ChampionOrCreatureOrdinalInCell[(L0697_T_Thing).getCell()]) &&
+			(_vm->_timeline->_g370_events[(((Projectile *)_vm->_dungeonMan->_thingData[k14_ProjectileThingType])[(L0697_T_Thing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts) && (AL0699_ui_ChampionOrCreatureOrdinal = L0707_auc_ChampionOrCreatureOrdinalInCell[(L0697_T_Thing).getCell()]) &&
 			_vm->_projexpl->f217_projectileHasImpactOccurred(L0702_i_ImpactType, srcMapX, srcMapY, _vm->ordinalToIndex(AL0699_ui_ChampionOrCreatureOrdinal), L0697_T_Thing)) {
 			_vm->_projexpl->f214_projectileDeleteEvent(L0697_T_Thing);
 			if (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup) {
@@ -619,7 +619,7 @@ T0266017_CheckProjectileImpacts:
 			}
 			goto T0266017_CheckProjectileImpacts;
 		}
-		L0697_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0697_T_Thing);
+		L0697_T_Thing = _vm->_dungeonMan->getNextThing(L0697_T_Thing);
 	}
 	if (L0703_B_CheckDestinationSquareProjectileImpacts) {
 		srcMapX |= ((L0704_ui_ProjectileMapX = destMapX) + 1) << 8; /* Check impacts with projectiles on the destination square */
@@ -635,7 +635,7 @@ T0266017_CheckProjectileImpacts:
 void MovesensMan::f268_addEvent(byte type, byte mapX, byte mapY, byte cell, byte effect, int32 time) {
 	TimelineEvent L0729_s_Event;
 
-	setMapAndTime(L0729_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, time);
+	setMapAndTime(L0729_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, time);
 	L0729_s_Event._type = type;
 	L0729_s_Event._priority = 0;
 	L0729_s_Event._B._location._mapX = mapX;
@@ -702,7 +702,7 @@ int16 MovesensMan::f262_getTeleporterRotatedGroupResult(Teleporter* teleporter,
 	int16 L0691_i_CreatureSize;
 	int16 L0692_i_RelativeRotation;
 
-	L0686_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(thing);
+	L0686_ps_Group = (Group *)_vm->_dungeonMan->getThingData(thing);
 	L0683_i_Rotation = teleporter->getRotation();
 	L0684_ui_GroupDirections = _vm->_groupMan->f147_getGroupDirections(L0686_ps_Group, mapIndex);
 
@@ -732,9 +732,9 @@ int16 MovesensMan::f262_getTeleporterRotatedGroupResult(Teleporter* teleporter,
 			L0690_ui_GroupCells >>= 2;
 		}
 	}
-	_vm->_dungeonMan->f148_setGroupDirections(L0686_ps_Group, L0685_ui_UpdatedGroupDirections, mapIndex);
-	_vm->_dungeonMan->f146_setGroupCells(L0686_ps_Group, L0687_ui_UpdatedGroupCells, mapIndex);
-	if ((mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0686_ps_Group->setBehaviour(k6_behavior_ATTACK))) {
+	_vm->_dungeonMan->setGroupDirections(L0686_ps_Group, L0685_ui_UpdatedGroupDirections, mapIndex);
+	_vm->_dungeonMan->setGroupCells(L0686_ps_Group, L0687_ui_UpdatedGroupCells, mapIndex);
+	if ((mapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0686_ps_Group->setBehaviour(k6_behavior_ATTACK))) {
 		return L0686_ps_Group->getActiveGroupIndex() + 2;
 	}
 	return 1;
@@ -781,24 +781,24 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 		L0774_i_ObjectType = kM1_IconIndiceNone;
 	}
 	if ((!addThing) && (L0767_i_ThingType != kM1_PartyThingType)) {
-		_vm->_dungeonMan->f164_unlinkThingFromList(thing, Thing(0), mapX, mapY);
+		_vm->_dungeonMan->unlinkThingFromList(thing, Thing(0), mapX, mapY);
 	}
 
-	L0777_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY];
+	L0777_ui_Square = _vm->_dungeonMan->_currMapData[mapX][mapY];
 	if (Square(L0777_ui_Square).getType() == k0_WallElemType) {
 		L0770_ui_SensorTriggeredCell = thing.getCell();
 	} else {
 		L0770_ui_SensorTriggeredCell = kM1_CellAny; // this will wrap around
 	}
 	L0772_B_SquareContainsObject = L0773_B_SquareContainsGroup = L0775_B_SquareContainsThingOfSameType = L0776_B_SquareContainsThingOfDifferentType = false;
-	L0766_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
+	L0766_T_Thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
 	if (L0770_ui_SensorTriggeredCell == kM1_CellAny) {
 		while (L0766_T_Thing != Thing::_endOfList) {
 			if ((L0771_ui_ThingType = (L0766_T_Thing).getType()) == k4_GroupThingType) {
 				L0773_B_SquareContainsGroup = true;
 			} else {
 				if ((L0771_ui_ThingType == k2_TextstringType) && (L0767_i_ThingType == kM1_PartyThingType) && addThing && !partySquare) {
-					_vm->_dungeonMan->f168_decodeText(_vm->_stringBuildBuffer, L0766_T_Thing, k1_TextTypeMessage);
+					_vm->_dungeonMan->decodeText(_vm->_stringBuildBuffer, L0766_T_Thing, k1_TextTypeMessage);
 					_vm->_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, _vm->_stringBuildBuffer);
 				} else {
 					if ((L0771_ui_ThingType > k4_GroupThingType) && (L0771_ui_ThingType < k14_ProjectileThingType)) {
@@ -808,7 +808,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 					}
 				}
 			}
-			L0766_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0766_T_Thing);
+			L0766_T_Thing = _vm->_dungeonMan->getNextThing(L0766_T_Thing);
 		}
 	} else {
 		while (L0766_T_Thing != Thing::_endOfList) {
@@ -817,17 +817,17 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 				L0775_B_SquareContainsThingOfSameType |= (_vm->_objectMan->f32_getObjectType(L0766_T_Thing) == L0774_i_ObjectType);
 				L0776_B_SquareContainsThingOfDifferentType |= (_vm->_objectMan->f32_getObjectType(L0766_T_Thing) != L0774_i_ObjectType);
 			}
-			L0766_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0766_T_Thing);
+			L0766_T_Thing = _vm->_dungeonMan->getNextThing(L0766_T_Thing);
 		}
 	}
 	if (addThing && (L0767_i_ThingType != kM1_PartyThingType)) {
-		_vm->_dungeonMan->f163_linkThingToList(thing, Thing(0), mapX, mapY);
+		_vm->_dungeonMan->linkThingToList(thing, Thing(0), mapX, mapY);
 	}
-	L0766_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
+	L0766_T_Thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
 	while (L0766_T_Thing != Thing::_endOfList) {
 		L0771_ui_ThingType = (L0766_T_Thing).getType();
 		if (L0771_ui_ThingType == k3_SensorThingType) {
-			L0769_ps_Sensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0766_T_Thing);
+			L0769_ps_Sensor = (Sensor *)_vm->_dungeonMan->getThingData(L0766_T_Thing);
 			if ((L0769_ps_Sensor)->getType() == k0_SensorDisabled)
 				goto T0276079;
 			L0779_i_SensorData = L0769_ps_Sensor->getData();
@@ -852,7 +852,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 						if (!addThing) {
 							L0768_B_TriggerSensor = false;
 						} else {
-							L0768_B_TriggerSensor = (L0779_i_SensorData == _vm->indexToOrdinal(_vm->_dungeonMan->_g308_partyDir));
+							L0768_B_TriggerSensor = (L0779_i_SensorData == _vm->indexToOrdinal(_vm->_dungeonMan->_partyDir));
 						}
 					}
 					break;
@@ -904,14 +904,14 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 					goto T0276079;
 				}
 			}
-			L0768_B_TriggerSensor ^= L0769_ps_Sensor->getRevertEffectA();
-			L0778_i_Effect = L0769_ps_Sensor->getEffectA();
+			L0768_B_TriggerSensor ^= L0769_ps_Sensor->getAttrRevertEffectA();
+			L0778_i_Effect = L0769_ps_Sensor->getAttrEffectA();
 			if (L0778_i_Effect == k3_SensorEffHold) {
 				L0778_i_Effect = L0768_B_TriggerSensor ? k0_SensorEffSet : k1_SensorEffClear;
 			} else if (!L0768_B_TriggerSensor)
 				goto T0276079;
 
-			if (L0769_ps_Sensor->getAudibleA())
+			if (L0769_ps_Sensor->getAttrAudibleA())
 				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized);
 
 			f272_sensorTriggerEffect(L0769_ps_Sensor, L0778_i_Effect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
@@ -920,7 +920,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 		if (L0771_ui_ThingType >= k4_GroupThingType)
 			break;
 T0276079:
-		L0766_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0766_T_Thing);
+		L0766_T_Thing = _vm->_dungeonMan->getNextThing(L0766_T_Thing);
 	}
 	f271_processRotationEffect();
 }
@@ -948,13 +948,13 @@ T0274003:
 					return true;
 				}
 				if (L0747_i_ObjectType == k144_IconIndiceContainerChestClosed) {
-					L0749_ps_Container = (Container *)_vm->_dungeonMan->f156_getThingData(L0744_T_Thing);
+					L0749_ps_Container = (Container *)_vm->_dungeonMan->getThingData(L0744_T_Thing);
 					L0744_T_Thing = L0749_ps_Container->getSlot();
 					while (L0744_T_Thing != Thing::_endOfList) {
 						if (_vm->_objectMan->f32_getObjectType(L0744_T_Thing) == objectType) {
 							return true;
 						}
-						L0744_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0744_T_Thing);
+						L0744_T_Thing = _vm->_dungeonMan->getNextThing(L0744_T_Thing);
 					}
 				}
 			}
@@ -985,18 +985,18 @@ void MovesensMan::f272_sensorTriggerEffect(Sensor* sensor, int16 effect, int16 m
 	uint16 L0740_ui_TargetCell;
 
 
-	if (sensor->getOnlyOnce()) {
+	if (sensor->getAttrOnlyOnce()) {
 		sensor->setTypeDisabled();
 	}
-	L0738_l_Time = _vm->_gameTime + sensor->getValue();
-	if (sensor->getLocalEffect()) {
-		f270_sensorTriggetLocalEffect(sensor->M49_localEffect(), mapX, mapY, cell);
+	L0738_l_Time = _vm->_gameTime + sensor->getAttrValue();
+	if (sensor->getAttrLocalEffect()) {
+		f270_sensorTriggetLocalEffect(sensor->getActionLocalEffect(), mapX, mapY, cell);
 	} else {
-		L0736_i_TargetMapX = sensor->getTargetMapX();
-		L0737_i_TargetMapY = sensor->getTargetMapY();
-		L0739_ui_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[L0736_i_TargetMapX][L0737_i_TargetMapY]).getType();
+		L0736_i_TargetMapX = sensor->getActionTargetMapX();
+		L0737_i_TargetMapY = sensor->getActionTargetMapY();
+		L0739_ui_SquareType = Square(_vm->_dungeonMan->_currMapData[L0736_i_TargetMapX][L0737_i_TargetMapY]).getType();
 		if (L0739_ui_SquareType == k0_ElementTypeWall) {
-			L0740_ui_TargetCell = sensor->getTargetCell();
+			L0740_ui_TargetCell = sensor->getActionTargetCell();
 		} else {
 			L0740_ui_TargetCell = k0_CellNorthWest;
 		}
@@ -1045,25 +1045,25 @@ void MovesensMan::f271_processRotationEffect() {
 	switch (_g403_sensorRotationEffect) {
 	case k1_SensorEffClear:
 	case k2_SensorEffToggle:
-		L0732_T_FirstSensorThing = _vm->_dungeonMan->f161_getSquareFirstThing(_g404_sensorRotationEffMapX, _g405_sensorRotationEffMapY);
+		L0732_T_FirstSensorThing = _vm->_dungeonMan->getSquareFirstThing(_g404_sensorRotationEffMapX, _g405_sensorRotationEffMapY);
 		while (((L0732_T_FirstSensorThing).getType() != k3_SensorThingType) || ((_g406_sensorRotationEffCell != kM1_CellAny) && ((L0732_T_FirstSensorThing).getCell() != _g406_sensorRotationEffCell))) {
-			L0732_T_FirstSensorThing = _vm->_dungeonMan->f159_getNextThing(L0732_T_FirstSensorThing);
+			L0732_T_FirstSensorThing = _vm->_dungeonMan->getNextThing(L0732_T_FirstSensorThing);
 		}
-		L0734_ps_FirstSensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0732_T_FirstSensorThing);
+		L0734_ps_FirstSensor = (Sensor *)_vm->_dungeonMan->getThingData(L0732_T_FirstSensorThing);
 		L0733_T_LastSensorThing = L0734_ps_FirstSensor->getNextThing();
 		while ((L0733_T_LastSensorThing != Thing::_endOfList) && (((L0733_T_LastSensorThing).getType() != k3_SensorThingType) || ((_g406_sensorRotationEffCell != kM1_CellAny) && ((L0733_T_LastSensorThing).getCell() != _g406_sensorRotationEffCell)))) {
-			L0733_T_LastSensorThing = _vm->_dungeonMan->f159_getNextThing(L0733_T_LastSensorThing);
+			L0733_T_LastSensorThing = _vm->_dungeonMan->getNextThing(L0733_T_LastSensorThing);
 		}
 		if (L0733_T_LastSensorThing == Thing::_endOfList)
 			break;
-		_vm->_dungeonMan->f164_unlinkThingFromList(L0732_T_FirstSensorThing, Thing(0), _g404_sensorRotationEffMapX, _g405_sensorRotationEffMapY);
-		L0735_ps_LastSensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0733_T_LastSensorThing);
-		L0733_T_LastSensorThing = _vm->_dungeonMan->f159_getNextThing(L0733_T_LastSensorThing);
+		_vm->_dungeonMan->unlinkThingFromList(L0732_T_FirstSensorThing, Thing(0), _g404_sensorRotationEffMapX, _g405_sensorRotationEffMapY);
+		L0735_ps_LastSensor = (Sensor *)_vm->_dungeonMan->getThingData(L0733_T_LastSensorThing);
+		L0733_T_LastSensorThing = _vm->_dungeonMan->getNextThing(L0733_T_LastSensorThing);
 		while (((L0733_T_LastSensorThing != Thing::_endOfList) && ((L0733_T_LastSensorThing).getType() == k3_SensorThingType))) {
 			if ((_g406_sensorRotationEffCell == kM1_CellAny) || ((L0733_T_LastSensorThing).getCell() == _g406_sensorRotationEffCell)) {
-				L0735_ps_LastSensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0733_T_LastSensorThing);
+				L0735_ps_LastSensor = (Sensor *)_vm->_dungeonMan->getThingData(L0733_T_LastSensorThing);
 			}
-			L0733_T_LastSensorThing = _vm->_dungeonMan->f159_getNextThing(L0733_T_LastSensorThing);
+			L0733_T_LastSensorThing = _vm->_dungeonMan->getNextThing(L0733_T_LastSensorThing);
 		}
 		L0734_ps_FirstSensor->setNextThing(L0735_ps_LastSensor->getNextThing());
 		L0735_ps_LastSensor->setNextThing(L0732_T_FirstSensorThing);
@@ -1087,14 +1087,14 @@ Thing MovesensMan::f273_sensorGetObjectOfTypeInCell(int16 mapX, int16 mapY, int1
 	Thing L0741_T_Thing;
 
 
-	L0741_T_Thing = _vm->_dungeonMan->f162_getSquareFirstObject(mapX, mapY);
+	L0741_T_Thing = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
 	while (L0741_T_Thing != Thing::_endOfList) {
 		if (_vm->_objectMan->f32_getObjectType(L0741_T_Thing) == objectType) {
 			if ((cell == kM1_CellAny) || ((L0741_T_Thing.getCell()) == cell)) {
 				return L0741_T_Thing;
 			}
 		}
-		L0741_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0741_T_Thing);
+		L0741_T_Thing = _vm->_dungeonMan->getNextThing(L0741_T_Thing);
 	}
 	return Thing::_none;
 }
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index fe5737d..00023c3 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -128,7 +128,7 @@ IconIndice ObjectMan::f32_getObjectType(Thing thing) {
 	if (thing == Thing::_none)
 		return kM1_IconIndiceNone;
 
-	int16 objectInfoIndex = _vm->_dungeonMan->f141_getObjectInfoIndex(thing);
+	int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing);
 	if (objectInfoIndex != -1) {
 		objectInfoIndex = _vm->_dungeonMan->_objectInfo[objectInfoIndex]._type;
 	}
@@ -143,10 +143,10 @@ IconIndice ObjectMan::f33_getIconIndex(Thing thing) {
 		if (((L0005_i_IconIndex < k32_IconIndiceWeaponDagger) && (L0005_i_IconIndex >= k0_IconIndiceJunkCompassNorth)) ||
 			((L0005_i_IconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (L0005_i_IconIndex <= k163_IconIndicePotionWaterFlask)) ||
 			(L0005_i_IconIndex == k195_IconIndicePotionEmptyFlask)) {
-			Junk *L0006_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing);
+			Junk *L0006_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(thing);
 			switch (L0005_i_IconIndex) {
 			case k0_IconIndiceJunkCompassNorth:
-				L0005_i_IconIndex += _vm->_dungeonMan->_g308_partyDir;
+				L0005_i_IconIndex += _vm->_dungeonMan->_partyDir;
 				break;
 			case k4_IconIndiceWeaponTorchUnlit:
 				if (((Weapon*)L0006_ps_Junk)->isLit()) {
@@ -239,7 +239,7 @@ void ObjectMan::f34_drawLeaderObjectName(Thing thing) {
 	char* objectName = nullptr;
 	int16 L0007_i_IconIndex = f33_getIconIndex(thing);
 	if (L0007_i_IconIndex == k147_IconIndiceJunkChampionBones) {
-		Junk *junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing);
+		Junk *junk = (Junk*)_vm->_dungeonMan->getThingData(thing);
 		char champBonesName[16];
 
 		switch (_vm->getGameLanguage()) { // localized
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index bc0c1a9..4fdda2e 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -52,16 +52,16 @@ void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16
 	TimelineEvent L0468_s_Event;
 
 
-	if ((L0466_T_ProjectileThing = _vm->_dungeonMan->f166_getUnusedThing(k14_ProjectileThingType)) == Thing::_none) { /* BUG0_16 If the game cannot create a projectile thing because it has run out of such things (60 maximum) then the object being thrown/shot/launched is orphaned. If the game has run out of projectile things it will try to remove a projectile from elsewhere in the dungeon, except in an area of 11x11 squares centered around the party (to make sure the player cannot actually see the thing disappear on screen) */
+	if ((L0466_T_ProjectileThing = _vm->_dungeonMan->getUnusedThing(k14_ProjectileThingType)) == Thing::_none) { /* BUG0_16 If the game cannot create a projectile thing because it has run out of such things (60 maximum) then the object being thrown/shot/launched is orphaned. If the game has run out of projectile things it will try to remove a projectile from elsewhere in the dungeon, except in an area of 11x11 squares centered around the party (to make sure the player cannot actually see the thing disappear on screen) */
 		return;
 	}
 	L0466_T_ProjectileThing = thingWithNewCell(L0466_T_ProjectileThing, cell);
-	L0467_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(L0466_T_ProjectileThing);
+	L0467_ps_Projectile = (Projectile *)_vm->_dungeonMan->getThingData(L0466_T_ProjectileThing);
 	L0467_ps_Projectile->_slot = thing;
 	L0467_ps_Projectile->_kineticEnergy = MIN((int16)kineticEnergy, (int16)255);
 	L0467_ps_Projectile->_attack = attack;
-	_vm->_dungeonMan->f163_linkThingToList(L0466_T_ProjectileThing, Thing(0), mapX, mapY); /* Projectiles are added on the square and not 'moved' onto the square. In the case of a projectile launcher sensor, this means that the new projectile traverses the square in front of the launcher without any trouble: there is no impact if it is a wall, the projectile direction is not changed if it is a teleporter. Impacts with creatures and champions are still processed */
-	setMapAndTime(L0468_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_gameTime + 1);
+	_vm->_dungeonMan->linkThingToList(L0466_T_ProjectileThing, Thing(0), mapX, mapY); /* Projectiles are added on the square and not 'moved' onto the square. In the case of a projectile launcher sensor, this means that the new projectile traverses the square in front of the launcher without any trouble: there is no impact if it is a wall, the projectile direction is not changed if it is a teleporter. Impacts with creatures and champions are still processed */
+	setMapAndTime(L0468_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + 1);
 	if (_g365_createLanucherProjectile) {
 		L0468_s_Event._type = k49_TMEventTypeMoveProjectile; /* Launcher projectiles can impact immediately */
 	} else {
@@ -112,13 +112,13 @@ bool ProjExpl::f217_projectileHasImpactOccurred(int16 impactType, int16 mapXComb
 	uint16 L0511_ui_CreatureType;
 	uint16 L0512_ui_CreatureIndex;
 
-	L0490_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(Thing(projectileThing));
+	L0490_ps_Projectile = (Projectile *)_vm->_dungeonMan->getThingData(Thing(projectileThing));
 	L0501_i_MapXCombo = mapXCombo;
 	L0502_i_MapYCombo = mapYCombo;
 	L0509_B_RemovePotion = false;
 	_g364_creatureDamageOutcome = k0_outcomeKilledNoCreaturesInGroup;
 	if ((L0510_i_ProjectileAssociatedThingType = (L0486_T_ProjectileAssociatedThing = L0490_ps_Projectile->_slot).getType()) == k8_PotionThingType) {
-		L0491_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0486_T_ProjectileAssociatedThing);
+		L0491_ps_Group = (Group *)_vm->_dungeonMan->getThingData(L0486_T_ProjectileAssociatedThing);
 		switch (((Potion *)L0491_ps_Group)->getType()) {
 		case k3_PotionTypeVen:
 			L0498_T_ExplosionThing = Thing::_explPoisonCloud;
@@ -148,8 +148,8 @@ T0217004:
 	}
 	switch (impactType) {
 	case k4_DoorElemType:
-		AL0487_i_DoorState = Square(L0503_uc_Square = _vm->_dungeonMan->_g271_currMapData[AP0454_i_ProjectileTargetMapX][AP0455_i_ProjectileTargetMapY]).getDoorState();
-		L0494_ps_Door = (Door *)_vm->_dungeonMan->f157_getSquareFirstThingData(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY);
+		AL0487_i_DoorState = Square(L0503_uc_Square = _vm->_dungeonMan->_currMapData[AP0454_i_ProjectileTargetMapX][AP0455_i_ProjectileTargetMapY]).getDoorState();
+		L0494_ps_Door = (Door *)_vm->_dungeonMan->getSquareFirstThingData(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY);
 		if ((AL0487_i_DoorState != k5_doorState_DESTROYED) && (L0486_T_ProjectileAssociatedThing == Thing::_explOpenDoor)) {
 			if (L0494_ps_Door->hasButton()) {
 				_vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, 0, k2_SensorEffToggle, _vm->_gameTime + 1);
@@ -158,11 +158,11 @@ T0217004:
 		}
 		if ((AL0487_i_DoorState == k5_doorState_DESTROYED) ||
 			(AL0487_i_DoorState <= k1_doorState_FOURTH) ||
-			(getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[L0494_ps_Door->getType()]._attributes, k0x0002_MaskDoorInfo_ProjectilesCanPassThrough) &&
+			(getFlag(_vm->_dungeonMan->_currMapDoorInfo[L0494_ps_Door->getType()]._attributes, k0x0002_MaskDoorInfo_ProjectilesCanPassThrough) &&
 			((L0510_i_ProjectileAssociatedThingType == k15_ExplosionThingType) ?
 			 (L0486_T_ProjectileAssociatedThing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) :
 			 ((L0490_ps_Projectile->_attack > _vm->getRandomNumber(128)) &&
-			  getFlag(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0486_T_ProjectileAssociatedThing)].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)
+			  getFlag(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(L0486_T_ProjectileAssociatedThing)].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)
 			  && ((L0510_i_ProjectileAssociatedThingType != k10_JunkThingType) ||
 			  ((AL0487_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0486_T_ProjectileAssociatedThing)) < 0) ||
 				  (!((AL0487_i_IconIndex >= k176_IconIndiceJunkIronKey) && (AL0487_i_IconIndex <= k191_IconIndiceJunkMasterKey))))
@@ -179,7 +179,7 @@ T0217004:
 		L0489_i_ChampionAttack = L0488_i_Attack = f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing);
 		break;
 	case kM1_CreatureElemType:
-		L0491_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY));
+		L0491_ps_Group = (Group *)_vm->_dungeonMan->getThingData(_vm->_groupMan->f175_groupGetThing(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY));
 		if (!(L0512_ui_CreatureIndex = _vm->_groupMan->f176_getCreatureOrdinalInCell(L0491_ps_Group, cell))) {
 			return false;
 		}
@@ -203,7 +203,7 @@ T0217004:
 				(AL0487_i_Outcome == k0_outcomeKilledNoCreaturesInGroup) &&
 				(L0510_i_ProjectileAssociatedThingType == k5_WeaponThingType) &&
 				getFlag(L0493_ps_CreatureInfo->_attributes, k0x0400_MaskCreatureInfo_keepThrownSharpWeapon)) {
-				L0495_ps_Weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(L0486_T_ProjectileAssociatedThing);
+				L0495_ps_Weapon = (Weapon *)_vm->_dungeonMan->getThingData(L0486_T_ProjectileAssociatedThing);
 				AL0487_i_WeaponType = L0495_ps_Weapon->getType();
 				if ((AL0487_i_WeaponType == k8_WeaponTypeDagger) || (AL0487_i_WeaponType == k27_WeaponTypeArrow) || (AL0487_i_WeaponType == k28_WeaponTypeSlayer) || (AL0487_i_WeaponType == k31_WeaponTypePoisonDart) || (AL0487_i_WeaponType == k32_WeaponTypeThrowingStar)) {
 					L0497_pT_GroupSlot = &L0491_ps_Group->_slot;
@@ -242,7 +242,7 @@ T0217044:
 		L0492_ps_Potion->_nextThing = Thing::_none;
 		L0490_ps_Projectile->_slot = L0498_T_ExplosionThing;
 	}
-	_vm->_dungeonMan->f164_unlinkThingFromList(projectileThing, Thing(0), L0499_i_ProjectileMapX, L0500_i_ProjectileMapY);
+	_vm->_dungeonMan->unlinkThingFromList(projectileThing, Thing(0), L0499_i_ProjectileMapX, L0500_i_ProjectileMapY);
 	f215_projectileDelete(projectileThing, L0497_pT_GroupSlot, L0499_i_ProjectileMapX, L0500_i_ProjectileMapY);
 	return true;
 }
@@ -261,13 +261,13 @@ uint16 ProjExpl::f216_projectileGetImpactAttack(Projectile* projectile, Thing th
 	L0484_ui_KineticEnergy = projectile->_kineticEnergy;
 	if ((AL0483_ui_ThingType = thing.getType()) != k15_ExplosionThingType) {
 		if (AL0483_ui_ThingType == k5_WeaponThingType) {
-			L0485_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(thing);
+			L0485_ps_WeaponInfo = _vm->_dungeonMan->getWeaponInfo(thing);
 			AL0483_ui_Attack = L0485_ps_WeaponInfo->_kineticEnergy;
 			_g367_projectileAttackType = k3_attackType_BLUNT;
 		} else {
 			AL0483_ui_Attack = _vm->getRandomNumber(4);
 		}
-		AL0483_ui_Attack += _vm->_dungeonMan->f140_getObjectWeight(thing) >> 1;
+		AL0483_ui_Attack += _vm->_dungeonMan->getObjectWeight(thing) >> 1;
 	} else {
 		if (thing == Thing::_explSlime) {
 			AL0483_ui_Attack = _vm->getRandomNumber(16);
@@ -299,12 +299,12 @@ uint16 ProjExpl::f216_projectileGetImpactAttack(Projectile* projectile, Thing th
 void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXCombo, uint16 mapYCombo, uint16 cell) {
 #define AP0443_ui_ProjectileMapX mapXCombo
 #define AP0444_ui_ProjectileMapY mapYCombo
-	Thing L0473_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k15_ExplosionThingType);
+	Thing L0473_T_Thing = _vm->_dungeonMan->getUnusedThing(k15_ExplosionThingType);
 	if (L0473_T_Thing == Thing::_none) {
 		return;
 	}
 
-	Explosion *L0470_ps_Explosion = &((Explosion *)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[(L0473_T_Thing).getIndex()];
+	Explosion *L0470_ps_Explosion = &((Explosion *)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[(L0473_T_Thing).getIndex()];
 	int16 L0474_i_ProjectileTargetMapX;
 	int16 L0475_i_ProjectileTargetMapY;
 	if (mapXCombo <= 255) {
@@ -332,9 +332,9 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized);
 		}
 	}
-	_vm->_dungeonMan->f163_linkThingToList(L0473_T_Thing, Thing(0), AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY);
+	_vm->_dungeonMan->linkThingToList(L0473_T_Thing, Thing(0), AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY);
 	TimelineEvent L0476_s_Event;
-	setMapAndTime(L0476_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_gameTime + ((explThing == Thing::_explRebirthStep1) ? 5 : 1));
+	setMapAndTime(L0476_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + ((explThing == Thing::_explRebirthStep1) ? 5 : 1));
 	L0476_s_Event._type = k25_TMEventTypeExplosion;
 	L0476_s_Event._priority = 0;
 	L0476_s_Event._C._slot = L0473_T_Thing.toUint16();
@@ -347,11 +347,11 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 		attack = (attack >> 1) + 1;
 		attack += _vm->getRandomNumber(attack) + 1;
 		if ((explThing == Thing::_explFireBall) || (attack >>= 1)) {
-			if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (AP0443_ui_ProjectileMapX == _vm->_dungeonMan->_g306_partyMapX) && (AP0444_ui_ProjectileMapY == _vm->_dungeonMan->_g307_partyMapY)) {
+			if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (AP0443_ui_ProjectileMapX == _vm->_dungeonMan->_partyMapX) && (AP0444_ui_ProjectileMapY == _vm->_dungeonMan->_partyMapY)) {
 				_vm->_championMan->getDamagedChampionCount(attack, k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand | k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k1_attackType_FIRE);
 			} else {
 				if ((L0473_T_Thing = _vm->_groupMan->f175_groupGetThing(AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY)) != Thing::_endOfList) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
-					Group *L0472_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0473_T_Thing);
+					Group *L0472_ps_Group = (Group *)_vm->_dungeonMan->getThingData(L0473_T_Thing);
 					CreatureInfo *L0471_ps_CreatureInfo = &g243_CreatureInfo[L0472_ps_Group->_type];
 					int16 L0469_i_CreatureFireResistance = L0471_ps_CreatureInfo->getFireResistance();
 					if (L0469_i_CreatureFireResistance != k15_immuneToFire) {
@@ -376,7 +376,7 @@ int16 ProjExpl::f218_projectileGetImpactCount(int16 impactType, int16 mapX, int1
 	L0514_i_ImpactCount = 0;
 	_g364_creatureDamageOutcome = k0_outcomeKilledNoCreaturesInGroup;
 T0218001:
-	L0513_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
+	L0513_T_Thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
 	while (L0513_T_Thing != Thing::_endOfList) {
 		if (((L0513_T_Thing).getType() == k14_ProjectileThingType) &&
 			((L0513_T_Thing).getCell() == cell) &&
@@ -387,7 +387,7 @@ T0218001:
 				break;
 			goto T0218001;
 		}
-		L0513_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0513_T_Thing);
+		L0513_T_Thing = _vm->_dungeonMan->getNextThing(L0513_T_Thing);
 	}
 	return L0514_i_ImpactCount;
 }
@@ -396,22 +396,22 @@ void ProjExpl::f214_projectileDeleteEvent(Thing thing) {
 	Projectile* L0477_ps_Projectile;
 
 
-	L0477_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(thing);
+	L0477_ps_Projectile = (Projectile *)_vm->_dungeonMan->getThingData(thing);
 	_vm->_timeline->f237_deleteEvent(L0477_ps_Projectile->_eventIndex);
 }
 
 void ProjExpl::f215_projectileDelete(Thing projectileThing, Thing* groupSlot, int16 mapX, int16 mapY) {
-	Projectile *L0480_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(projectileThing);
+	Projectile *L0480_ps_Projectile = (Projectile *)_vm->_dungeonMan->getThingData(projectileThing);
 	Thing L0479_T_Thing = L0480_ps_Projectile->_slot;
 	if (L0479_T_Thing.getType() != k15_ExplosionThingType) {
 		if (groupSlot != NULL) {
 			Thing L0478_T_PreviousThing = *groupSlot;
 			if (L0478_T_PreviousThing == Thing::_endOfList) {
-				Thing *L0481_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0479_T_Thing);
+				Thing *L0481_ps_Generic = (Thing *)_vm->_dungeonMan->getThingData(L0479_T_Thing);
 				*L0481_ps_Generic = Thing::_endOfList;
 				*groupSlot = L0479_T_Thing;
 			} else {
-				_vm->_dungeonMan->f163_linkThingToList(L0479_T_Thing, L0478_T_PreviousThing, kM1_MapXNotOnASquare, 0);
+				_vm->_dungeonMan->linkThingToList(L0479_T_Thing, L0478_T_PreviousThing, kM1_MapXNotOnASquare, 0);
 			}
 		} else {
 			_vm->_moveSens->f267_getMoveResult(Thing((L0479_T_Thing).getTypeAndIndex() | getFlag(projectileThing.toUint16(), 0xC)), -2, 0, mapX, mapY);
@@ -440,21 +440,21 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 
 	L0527_s_Event = *event;
 	L0519_ps_Event = &L0527_s_Event;
-	L0520_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(L0521_T_ProjectileThing = L0515_T_ProjectileThingNewCell = Thing(L0519_ps_Event->_B._slot));
+	L0520_ps_Projectile = (Projectile*)_vm->_dungeonMan->getThingData(L0521_T_ProjectileThing = L0515_T_ProjectileThingNewCell = Thing(L0519_ps_Event->_B._slot));
 	L0523_i_DestinationMapX = L0519_ps_Event->_C._projectile.getMapX();
 	L0524_i_DestinationMapY = L0519_ps_Event->_C._projectile.getMapY();
 	if (L0519_ps_Event->_type == k48_TMEventTypeMoveProjectileIgnoreImpacts) {
 		L0519_ps_Event->_type = k49_TMEventTypeMoveProjectile;
 	} else {
 		L0518_ui_Cell = (L0515_T_ProjectileThingNewCell).getCell();
-		if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0523_i_DestinationMapX == _vm->_dungeonMan->_g306_partyMapX) && (L0524_i_DestinationMapY == _vm->_dungeonMan->_g307_partyMapY) && f217_projectileHasImpactOccurred(kM2_ChampionElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
+		if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0523_i_DestinationMapX == _vm->_dungeonMan->_partyMapX) && (L0524_i_DestinationMapY == _vm->_dungeonMan->_partyMapY) && f217_projectileHasImpactOccurred(kM2_ChampionElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
 			return;
 		}
 		if ((_vm->_groupMan->f175_groupGetThing(L0523_i_DestinationMapX, L0524_i_DestinationMapY) != Thing::_endOfList) && f217_projectileHasImpactOccurred(kM1_CreatureElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
 			return;
 		}
 		if (L0520_ps_Projectile->_kineticEnergy <= (AL0516_ui_StepEnergy = L0519_ps_Event->_C._projectile.getStepEnergy())) {
-			_vm->_dungeonMan->f164_unlinkThingFromList(L0515_T_ProjectileThingNewCell = L0521_T_ProjectileThing, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+			_vm->_dungeonMan->unlinkThingFromList(L0515_T_ProjectileThingNewCell = L0521_T_ProjectileThing, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
 			f215_projectileDelete(L0515_T_ProjectileThingNewCell, NULL, L0523_i_DestinationMapX, L0524_i_DestinationMapY);
 			return;
 		}
@@ -473,10 +473,10 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 		L0525_i_SourceMapX = L0523_i_DestinationMapX;
 		L0526_i_SourceMapY = L0524_i_DestinationMapY;
 		L0523_i_DestinationMapX += _vm->_dirIntoStepCountEast[L0517_ui_ProjectileDirection], L0524_i_DestinationMapY += _vm->_dirIntoStepCountNorth[L0517_ui_ProjectileDirection];
-		AL0516_ui_Square = _vm->_dungeonMan->f151_getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY).toByte();
+		AL0516_ui_Square = _vm->_dungeonMan->getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY).toByte();
 		if ((Square(AL0516_ui_Square).getType() == k0_WallElemType) ||
 			((Square(AL0516_ui_Square).getType() == k6_FakeWallElemType) && !getFlag(AL0516_ui_Square, (k0x0001_FakeWallImaginary | k0x0004_FakeWallOpen))) ||
-			((Square(AL0516_ui_Square).getType() == k3_StairsElemType) && (Square(_vm->_dungeonMan->_g271_currMapData[L0525_i_SourceMapX][L0526_i_SourceMapY]).getType() == k3_StairsElemType))) {
+			((Square(AL0516_ui_Square).getType() == k3_StairsElemType) && (Square(_vm->_dungeonMan->_currMapData[L0525_i_SourceMapX][L0526_i_SourceMapY]).getType() == k3_StairsElemType))) {
 			if (f217_projectileHasImpactOccurred(Square(AL0516_ui_Square).getType(), L0525_i_SourceMapX, L0526_i_SourceMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
 				return;
 			}
@@ -496,13 +496,13 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 		L0515_T_ProjectileThingNewCell = thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_moveSens->_g401_moveResultCell);
 		M31_setMap(L0519_ps_Event->_mapTime, _vm->_moveSens->_g399_moveResultMapIndex);
 	} else {
-		if ((Square(_vm->_dungeonMan->f151_getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY)).getType() == k4_DoorElemType) && f217_projectileHasImpactOccurred(k4_DoorElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
+		if ((Square(_vm->_dungeonMan->getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY)).getType() == k4_DoorElemType) && f217_projectileHasImpactOccurred(k4_DoorElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
 			return;
 		}
-		_vm->_dungeonMan->f164_unlinkThingFromList(L0515_T_ProjectileThingNewCell, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
-		_vm->_dungeonMan->f163_linkThingToList(L0515_T_ProjectileThingNewCell, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+		_vm->_dungeonMan->unlinkThingFromList(L0515_T_ProjectileThingNewCell, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+		_vm->_dungeonMan->linkThingToList(L0515_T_ProjectileThingNewCell, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
 	}
-	L0519_ps_Event->_mapTime += (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) ? 1 : 3;
+	L0519_ps_Event->_mapTime += (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) ? 1 : 3;
 	//Strangerke: CHECKME: Maybe we should keep that piece of code too as it sounds like it's fixing a weird behavior of projectiles on different maps
 #ifdef COMPILE42_CSB20EN_CSB21EN /* CHANGE7_20_IMPROVEMENT Projectiles now move at the same speed on all maps instead of moving slower on maps other than the party map */
 	L0519_ps_Event->Map_Time++;
@@ -531,11 +531,11 @@ void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) {
 
 	L0528_ui_MapX = event->_B._location._mapX;
 	L0529_ui_MapY = event->_B._location._mapY;
-	L0532_ps_Explosion = &((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[Thing((event->_C._slot)).getIndex()];
-	AL0531_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[L0528_ui_MapX][L0529_ui_MapY]).getType();
-	L0538_B_ExplosionOnPartySquare = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0528_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0529_ui_MapY == _vm->_dungeonMan->_g307_partyMapY);
+	L0532_ps_Explosion = &((Explosion*)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[Thing((event->_C._slot)).getIndex()];
+	AL0531_i_SquareType = Square(_vm->_dungeonMan->_currMapData[L0528_ui_MapX][L0529_ui_MapY]).getType();
+	L0538_B_ExplosionOnPartySquare = (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0528_ui_MapX == _vm->_dungeonMan->_partyMapX) && (L0529_ui_MapY == _vm->_dungeonMan->_partyMapY);
 	if ((L0535_T_GroupThing = _vm->_groupMan->f175_groupGetThing(L0528_ui_MapX, L0529_ui_MapY)) != Thing::_endOfList) {
-		L0533_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0535_T_GroupThing);
+		L0533_ps_Group = (Group*)_vm->_dungeonMan->getThingData(L0535_T_GroupThing);
 		L0534_ps_CreatureInfo = &g243_CreatureInfo[AL0537_ui_CreatureType = L0533_ps_Group->_type];
 	}
 	if ((L0536_T_ExplosionThing = Thing(Thing::_firstExplosion.toUint16() + L0532_ps_Explosion->getType())) == Thing::_explPoisonCloud) {
@@ -557,7 +557,7 @@ void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) {
 		break;
 	case 0xFF83:
 		if ((L0535_T_GroupThing != Thing::_endOfList) && getFlag(L0534_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
-			if ((AL0537_ui_CreatureType == k19_CreatureTypeMaterializerZytaz) && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
+			if ((AL0537_ui_CreatureType == k19_CreatureTypeMaterializerZytaz) && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex)) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
 				L0530_i_Attack -= (AL0537_ui_NonMaterialAdditionalAttack = L0530_i_Attack >> 3);
 				AL0537_ui_NonMaterialAdditionalAttack <<= 1;
 				AL0537_ui_NonMaterialAdditionalAttack++;
@@ -599,7 +599,7 @@ T0220026:
 			return;
 		}
 	}
-	_vm->_dungeonMan->f164_unlinkThingFromList(Thing(event->_C._slot), Thing(0), L0528_ui_MapX, L0529_ui_MapY);
+	_vm->_dungeonMan->unlinkThingFromList(Thing(event->_C._slot), Thing(0), L0528_ui_MapX, L0529_ui_MapY);
 	L0532_ps_Explosion->setNextThing(Thing::_none);
 }
 }
diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp
index e0bef37..bb1bd1f 100644
--- a/engines/dm/sounds.cpp
+++ b/engines/dm/sounds.cpp
@@ -161,22 +161,22 @@ bool SoundMan::f505_soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, ui
 	int16 L1680_i_LeftVolumeColumnIndex = 0;
 
 
-	switch (_vm->_dungeonMan->_g308_partyDir) {
+	switch (_vm->_dungeonMan->_partyDir) {
 	case kDirNorth:
-		L1678_i_RightVolumeColumnIndex = mapX - _vm->_dungeonMan->_g306_partyMapX;
-		L1679_i_LineIndex = mapY - _vm->_dungeonMan->_g307_partyMapY;
+		L1678_i_RightVolumeColumnIndex = mapX - _vm->_dungeonMan->_partyMapX;
+		L1679_i_LineIndex = mapY - _vm->_dungeonMan->_partyMapY;
 		break;
 	case kDirEast:
-		L1678_i_RightVolumeColumnIndex = mapY - _vm->_dungeonMan->_g307_partyMapY;
-		L1679_i_LineIndex = -(mapX - _vm->_dungeonMan->_g306_partyMapX);
+		L1678_i_RightVolumeColumnIndex = mapY - _vm->_dungeonMan->_partyMapY;
+		L1679_i_LineIndex = -(mapX - _vm->_dungeonMan->_partyMapX);
 		break;
 	case kDirSouth:
-		L1678_i_RightVolumeColumnIndex = -(mapX - _vm->_dungeonMan->_g306_partyMapX);
-		L1679_i_LineIndex = -(mapY - _vm->_dungeonMan->_g307_partyMapY);
+		L1678_i_RightVolumeColumnIndex = -(mapX - _vm->_dungeonMan->_partyMapX);
+		L1679_i_LineIndex = -(mapY - _vm->_dungeonMan->_partyMapY);
 		break;
 	case kDirWest:
-		L1678_i_RightVolumeColumnIndex = -(mapY - _vm->_dungeonMan->_g307_partyMapY);
-		L1679_i_LineIndex = mapX - _vm->_dungeonMan->_g306_partyMapX;
+		L1678_i_RightVolumeColumnIndex = -(mapY - _vm->_dungeonMan->_partyMapY);
+		L1679_i_LineIndex = mapX - _vm->_dungeonMan->_partyMapX;
 		break;
 	}
 	if ((L1678_i_RightVolumeColumnIndex < -12) || (L1678_i_RightVolumeColumnIndex > 12)) { /* Sound is not audible if source is more than 12 squares away from the party */
@@ -197,13 +197,13 @@ void SoundMan::f064_SOUND_RequestPlay_CPSD(uint16 soundIndex, int16 mapX, int16
 	Sound* sound;
 	uint8 leftVolume, rightVolume;
 
-	if (mode && (_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex))
+	if (mode && (_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex))
 		return;
 
 	sound = &g60_sounds[soundIndex];
 	if (mode > k1_soundModePlayIfPrioritized) { /* Add an event in the timeline to play the sound (mode - 1) ticks later */
 		TimelineEvent event;
-		setMapAndTime(event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_gameTime + mode - 1);
+		setMapAndTime(event._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + mode - 1);
 		event._type = k20_TMEventTypePlaySound;
 		event._priority = sound->_priority;
 		event._C._soundIndex = soundIndex;
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 45ca771..3f414c8 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -274,7 +274,7 @@ void Timeline::f261_processTimeline() {
 	while (f240_isFirstEventExpiered()) {
 		L0681_ps_Event = &L0682_s_Event;
 		f239_timelineExtractFirstEvent(L0681_ps_Event);
-		_vm->_dungeonMan->f173_setCurrentMap(getMap(L0682_s_Event._mapTime));
+		_vm->_dungeonMan->setCurrentMap(getMap(L0682_s_Event._mapTime));
 		AL0680_ui_EventType = L0682_s_Event._type;
 		if ((AL0680_ui_EventType > (k29_TMEventTypeGroupReactionDangerOnSquare - 1)) && (AL0680_ui_EventType < (k41_TMEventTypeUpdateBehaviour_3 + 1))) {
 			_vm->_groupMan->f209_processEvents29to41(L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, AL0680_ui_EventType, L0682_s_Event._C._ticks);
@@ -323,8 +323,8 @@ void Timeline::f261_processTimeline() {
 				break;
 			case k24_TMEventTypeRemoveFluxcage:
 				if (!_vm->_gameWon) {
-					_vm->_dungeonMan->f164_unlinkThingFromList(Thing(L0682_s_Event._C._slot), Thing(0), L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY);
-					L0681_ps_Event = (TimelineEvent*)_vm->_dungeonMan->f156_getThingData(Thing(L0682_s_Event._C._slot));
+					_vm->_dungeonMan->unlinkThingFromList(Thing(L0682_s_Event._C._slot), Thing(0), L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY);
+					L0681_ps_Event = (TimelineEvent*)_vm->_dungeonMan->getThingData(Thing(L0682_s_Event._C._slot));
 					((Explosion*)L0681_ps_Event)->setNextThing(Thing::_none);
 				}
 				break;
@@ -338,7 +338,7 @@ void Timeline::f261_processTimeline() {
 				f254_timelineProcessEvent12_hideDamageReceived(L0682_s_Event._priority);
 				break;
 			case k70_TMEventTypeLight:
-				_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
+				_vm->_dungeonMan->setCurrentMap(_vm->_dungeonMan->_partyMapIndex);
 				f257_timelineProcessEvent70_light(L0681_ps_Event);
 				_vm->_inventoryMan->f337_setDungeonViewPalette();
 				break;
@@ -376,7 +376,7 @@ T0261053:
 				_vm->_championMan->_party._event79Count_Footprints--;
 			}
 		}
-		_vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex);
+		_vm->_dungeonMan->setCurrentMap(_vm->_dungeonMan->_partyMapIndex);
 	}
 }
 
@@ -404,16 +404,16 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 #define AL0602_ui_VerticalDoor L0602_ui_Multiple
 #define AL0602_ui_Height       L0602_ui_Multiple
 
-	L0597_puc_Square = (Square*)&_vm->_dungeonMan->_g271_currMapData[L0593_ui_MapX = event->_B._location._mapX][L0594_ui_MapY = event->_B._location._mapY];
+	L0597_puc_Square = (Square*)&_vm->_dungeonMan->_currMapData[L0593_ui_MapX = event->_B._location._mapX][L0594_ui_MapY = event->_B._location._mapY];
 	if ((L0596_i_DoorState = Square(*L0597_puc_Square).getDoorState()) == k5_doorState_DESTROYED) {
 		return;
 	}
 	event->_mapTime++;
 	L0595_i_Effect = event->_C.A._effect;
 	if (L0595_i_Effect == k1_SensorEffClear) {
-		L0598_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0593_ui_MapX, L0594_ui_MapY);
+		L0598_ps_Door = (Door*)_vm->_dungeonMan->getSquareFirstThingData(L0593_ui_MapX, L0594_ui_MapY);
 		AL0602_ui_VerticalDoor = L0598_ps_Door->opensVertically();
-		if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0593_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0594_ui_MapY == _vm->_dungeonMan->_g307_partyMapY) && (L0596_i_DoorState != k0_doorState_OPEN)) {
+		if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0593_ui_MapX == _vm->_dungeonMan->_partyMapX) && (L0594_ui_MapY == _vm->_dungeonMan->_partyMapY) && (L0596_i_DoorState != k0_doorState_OPEN)) {
 			if (_vm->_championMan->_partyChampionCount > 0) {
 				L0597_puc_Square->setDoorState(k0_doorState_OPEN);
 
@@ -428,9 +428,9 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 			f238_addEventGetEventIndex(event);
 			return;
 		}
-		if (((L0599_T_GroupThing = _vm->_groupMan->f175_groupGetThing(L0593_ui_MapX, L0594_ui_MapY)) != Thing::_endOfList) && !getFlag(L0600_ui_CreatureAttributes = _vm->_dungeonMan->f144_getCreatureAttributes(L0599_T_GroupThing), k0x0040_MaskCreatureInfo_nonMaterial)) {
+		if (((L0599_T_GroupThing = _vm->_groupMan->f175_groupGetThing(L0593_ui_MapX, L0594_ui_MapY)) != Thing::_endOfList) && !getFlag(L0600_ui_CreatureAttributes = _vm->_dungeonMan->getCreatureAttributes(L0599_T_GroupThing), k0x0040_MaskCreatureInfo_nonMaterial)) {
 			if (L0596_i_DoorState >= (AL0602_ui_Height ? CreatureInfo::getHeight(L0600_ui_CreatureAttributes) : 1)) { /* Creature height or 1 */
-				if (_vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group*)_vm->_dungeonMan->f156_getThingData(L0599_T_GroupThing), L0593_ui_MapX, L0594_ui_MapY, 5, true) != k2_outcomeKilledAllCreaturesInGroup) {
+				if (_vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group*)_vm->_dungeonMan->getThingData(L0599_T_GroupThing), L0593_ui_MapX, L0594_ui_MapY, 5, true) != k2_outcomeKilledAllCreaturesInGroup) {
 					_vm->_groupMan->f209_processEvents29to41(L0593_ui_MapX, L0594_ui_MapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
 				}
 				L0596_i_DoorState = (L0596_i_DoorState == k0_doorState_OPEN) ? k0_doorState_OPEN : (L0596_i_DoorState - 1);
@@ -471,17 +471,17 @@ void Timeline::f242_timelineProcessEvent7_squareFakewall(TimelineEvent* event) {
 	byte* L0607_puc_Square;
 
 
-	L0607_puc_Square = &_vm->_dungeonMan->_g271_currMapData[L0603_ui_MapX = event->_B._location._mapX][L0604_ui_MapY = event->_B._location._mapY];
+	L0607_puc_Square = &_vm->_dungeonMan->_currMapData[L0603_ui_MapX = event->_B._location._mapX][L0604_ui_MapY = event->_B._location._mapY];
 	L0605_i_Effect = event->_C.A._effect;
 	if (L0605_i_Effect == k2_SensorEffToggle) {
 		L0605_i_Effect = getFlag(*L0607_puc_Square, k0x0004_FakeWallOpen) ? k1_SensorEffClear : k0_SensorEffSet;
 	}
 	if (L0605_i_Effect == k1_SensorEffClear) {
-		if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0603_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0604_ui_MapY == _vm->_dungeonMan->_g307_partyMapY)) {
+		if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0603_ui_MapX == _vm->_dungeonMan->_partyMapX) && (L0604_ui_MapY == _vm->_dungeonMan->_partyMapY)) {
 			event->_mapTime++;
 			f238_addEventGetEventIndex(event);
 		} else {
-			if (((L0606_T_Thing = _vm->_groupMan->f175_groupGetThing(L0603_ui_MapX, L0604_ui_MapY)) != Thing::_endOfList) && !getFlag(_vm->_dungeonMan->f144_getCreatureAttributes(L0606_T_Thing), k0x0040_MaskCreatureInfo_nonMaterial)) {
+			if (((L0606_T_Thing = _vm->_groupMan->f175_groupGetThing(L0603_ui_MapX, L0604_ui_MapY)) != Thing::_endOfList) && !getFlag(_vm->_dungeonMan->getCreatureAttributes(L0606_T_Thing), k0x0040_MaskCreatureInfo_nonMaterial)) {
 				event->_mapTime++;
 				f238_addEventGetEventIndex(event);
 			} else {
@@ -496,7 +496,7 @@ void Timeline::f242_timelineProcessEvent7_squareFakewall(TimelineEvent* event) {
 void Timeline::f243_timelineProcessEvent2_doorDestruction(TimelineEvent* event) {
 	Square* L0608_puc_Square;
 
-	L0608_puc_Square = (Square*)&_vm->_dungeonMan->_g271_currMapData[event->_B._location._mapX][event->_B._location._mapY];
+	L0608_puc_Square = (Square*)&_vm->_dungeonMan->_currMapData[event->_B._location._mapX][event->_B._location._mapY];
 	L0608_puc_Square->setDoorState(k5_doorState_DESTROYED);
 }
 
@@ -504,7 +504,7 @@ void Timeline::f244_timelineProcessEvent10_squareDoor(TimelineEvent* event) {
 	int16 L0609_i_DoorState;
 
 
-	if ((L0609_i_DoorState = Square(_vm->_dungeonMan->_g271_currMapData[event->_B._location._mapX][event->_B._location._mapY]).getDoorState()) == k5_doorState_DESTROYED) {
+	if ((L0609_i_DoorState = Square(_vm->_dungeonMan->_currMapData[event->_B._location._mapX][event->_B._location._mapY]).getDoorState()) == k5_doorState_DESTROYED) {
 		return;
 	}
 	if (event->_C.A._effect == k2_SensorEffToggle) {
@@ -530,7 +530,7 @@ void Timeline::f251_timelineProcessEvent9_squarePit(TimelineEvent* event) {
 	byte* L0655_puc_Square;
 
 
-	L0655_puc_Square = &_vm->_dungeonMan->_g271_currMapData[L0653_ui_MapX = event->_B._location._mapX][L0654_ui_MapY = event->_B._location._mapY];
+	L0655_puc_Square = &_vm->_dungeonMan->_currMapData[L0653_ui_MapX = event->_B._location._mapX][L0654_ui_MapY = event->_B._location._mapY];
 	if (event->_C.A._effect == k2_SensorEffToggle) {
 		event->_C.A._effect = getFlag(*L0655_puc_Square, k0x0008_PitOpen) ? k1_SensorEffClear : k0_SensorEffSet;
 	}
@@ -553,32 +553,32 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 	int16 L0649_i_ThingsToMoveCount;
 
 
-	if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX == _vm->_dungeonMan->_g306_partyMapX) && (mapY == _vm->_dungeonMan->_g307_partyMapY)) {
+	if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY)) {
 		_vm->_moveSens->f267_getMoveResult(Thing::_party, mapX, mapY, mapX, mapY);
 		_vm->_championMan->drawChangedObjectIcons();
 	}
 	if ((L0645_T_Thing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) != Thing::_endOfList) {
 		_vm->_moveSens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
 	}
-	L0645_T_Thing = _vm->_dungeonMan->f162_getSquareFirstObject(mapX, mapY);
+	L0645_T_Thing = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
 	L0648_T_NextThing = L0645_T_Thing;
 	L0649_i_ThingsToMoveCount = 0;
 	while (L0645_T_Thing != Thing::_endOfList) {
 		if (L0645_T_Thing.getType() > k4_GroupThingType) {
 			L0649_i_ThingsToMoveCount++;
 		}
-		L0645_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0645_T_Thing);
+		L0645_T_Thing = _vm->_dungeonMan->getNextThing(L0645_T_Thing);
 	}
 	L0645_T_Thing = L0648_T_NextThing;
 	while ((L0645_T_Thing != Thing::_endOfList) && L0649_i_ThingsToMoveCount) {
 		L0649_i_ThingsToMoveCount--;
-		L0648_T_NextThing = _vm->_dungeonMan->f159_getNextThing(L0645_T_Thing);
+		L0648_T_NextThing = _vm->_dungeonMan->getNextThing(L0645_T_Thing);
 		AL0644_ui_ThingType = L0645_T_Thing.getType();
 		if (AL0644_ui_ThingType > k4_GroupThingType) {
 			_vm->_moveSens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
 		}
 		if (AL0644_ui_ThingType == k14_ProjectileThingType) {
-			L0646_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(L0645_T_Thing);
+			L0646_ps_Projectile = (Projectile*)_vm->_dungeonMan->getThingData(L0645_T_Thing);
 			L0647_ps_Event = &_g370_events[L0646_ps_Projectile->_eventIndex];
 			L0647_ps_Event->_C._projectile.setMapX(_vm->_moveSens->_g397_moveResultMapX);
 			L0647_ps_Event->_C._projectile.setMapY(_vm->_moveSens->_g398_moveResultMapY);
@@ -607,7 +607,7 @@ void Timeline::f250_timelineProcessEvent8_squareTeleporter(TimelineEvent* event)
 	byte* L0652_puc_Square;
 
 
-	L0652_puc_Square = &_vm->_dungeonMan->_g271_currMapData[L0650_ui_MapX = event->_B._location._mapX][L0651_ui_MapY = event->_B._location._mapY];
+	L0652_puc_Square = &_vm->_dungeonMan->_currMapData[L0650_ui_MapX = event->_B._location._mapX][L0651_ui_MapY = event->_B._location._mapY];
 	if (event->_C.A._effect == k2_SensorEffToggle) {
 		event->_C.A._effect = getFlag(*L0652_puc_Square, k0x0008_TeleporterOpen) ? k1_SensorEffClear : k0_SensorEffSet;
 	}
@@ -634,11 +634,11 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
 	uint16 L0643_ui_Cell;
 
 
-	L0634_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0641_i_MapX = event->_B._location._mapX, L0642_i_MapY = event->_B._location._mapY);
+	L0634_T_Thing = _vm->_dungeonMan->getSquareFirstThing(L0641_i_MapX = event->_B._location._mapX, L0642_i_MapY = event->_B._location._mapY);
 	L0643_ui_Cell = event->_C.A._cell;
 	while (L0634_T_Thing != Thing::_endOfList) {
 		if (((L0635_i_ThingType = L0634_T_Thing.getType()) == k2_TextstringType) && (L0634_T_Thing.getCell() == event->_C.A._cell)) {
-			L0639_ps_TextString = (TextString*)_vm->_dungeonMan->f156_getThingData(L0634_T_Thing);
+			L0639_ps_TextString = (TextString*)_vm->_dungeonMan->getThingData(L0634_T_Thing);
 			if (event->_C.A._effect == k2_SensorEffToggle) {
 				L0639_ps_TextString->setVisible(!L0639_ps_TextString->isVisible());
 			} else {
@@ -646,7 +646,7 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
 			}
 		} else {
 			if (L0635_i_ThingType == k3_SensorThingType) {
-				L0638_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0634_T_Thing);
+				L0638_ps_Sensor = (Sensor*)_vm->_dungeonMan->getThingData(L0634_T_Thing);
 				L0640_ui_SensorType = L0638_ps_Sensor->getType();
 				L0637_ui_SensorData = L0638_ps_Sensor->getData();
 				if (L0640_ui_SensorType == k6_SensorWallCountdown) {
@@ -659,12 +659,12 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
 							L0637_ui_SensorData--;
 						}
 						L0638_ps_Sensor->setData(L0637_ui_SensorData);
-						if (L0638_ps_Sensor->getEffectA() == k3_SensorEffHold) {
-							AL0636_B_TriggerSetEffect = ((L0637_ui_SensorData == 0) != L0638_ps_Sensor->getRevertEffectA());
+						if (L0638_ps_Sensor->getAttrEffectA() == k3_SensorEffHold) {
+							AL0636_B_TriggerSetEffect = ((L0637_ui_SensorData == 0) != L0638_ps_Sensor->getAttrRevertEffectA());
 							_vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
 						} else {
 							if (L0637_ui_SensorData == 0) {
-								_vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
+								_vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getAttrEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
 							}
 						}
 					}
@@ -685,23 +685,23 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
 							}
 						}
 						L0638_ps_Sensor->setData(L0637_ui_SensorData);
-						AL0636_B_TriggerSetEffect = (Sensor::getDataMask1(L0637_ui_SensorData) == Sensor::getDataMask2(L0637_ui_SensorData)) != L0638_ps_Sensor->getRevertEffectA();
-						if (L0638_ps_Sensor->getEffectA() == k3_SensorEffHold) {
+						AL0636_B_TriggerSetEffect = (Sensor::getDataMask1(L0637_ui_SensorData) == Sensor::getDataMask2(L0637_ui_SensorData)) != L0638_ps_Sensor->getAttrRevertEffectA();
+						if (L0638_ps_Sensor->getAttrEffectA() == k3_SensorEffHold) {
 							_vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
 						} else {
 							if (AL0636_B_TriggerSetEffect) {
-								_vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
+								_vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getAttrEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
 							}
 						}
 					} else {
 						if ((((L0640_ui_SensorType >= k7_SensorWallSingleProjLauncherNewObj) && (L0640_ui_SensorType <= k10_SensorWallDoubleProjLauncherExplosion)) || (L0640_ui_SensorType == k14_SensorWallSingleProjLauncherSquareObj) || (L0640_ui_SensorType == k15_SensorWallDoubleProjLauncherSquareObj)) && (L0634_T_Thing.getCell() == event->_C.A._cell)) {
 							f247_triggerProjectileLauncher(L0638_ps_Sensor, event);
-							if (L0638_ps_Sensor->getOnlyOnce()) {
+							if (L0638_ps_Sensor->getAttrOnlyOnce()) {
 								L0638_ps_Sensor->setTypeDisabled();
 							}
 						} else {
 							if (L0640_ui_SensorType == k18_SensorWallEndGame) {
-								_vm->delay(60 * L0638_ps_Sensor->getValue());
+								_vm->delay(60 * L0638_ps_Sensor->getAttrValue());
 								_vm->_restartGameAllowed = false;
 								_vm->_gameWon = true;
 								_vm->endGame(true);
@@ -711,7 +711,7 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
 				}
 			}
 		}
-		L0634_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0634_T_Thing);
+		L0634_T_Thing = _vm->_dungeonMan->getNextThing(L0634_T_Thing);
 	}
 	_vm->_moveSens->f271_processRotationEffect();
 }
@@ -737,8 +737,8 @@ void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* eve
 	L0628_ui_ProjectileCell = returnOppositeDir((Direction)L0624_ui_Cell);
 	L0625_i_SensorType = sensor->getType();
 	L0629_i_SensorData = sensor->getData();
-	L0630_i_KineticEnergy = sensor->M47_kineticEnergy();
-	L0631_i_StepEnergy = sensor->M48_stepEnergy();
+	L0630_i_KineticEnergy = sensor->getActionKineticEnergy();
+	L0631_i_StepEnergy = sensor->getActionStepEnergy();
 	L0632_B_LaunchSingleProjectile = (L0625_i_SensorType == k7_SensorWallSingleProjLauncherNewObj) ||
 		(L0625_i_SensorType == k8_SensorWallSingleProjLauncherExplosion) ||
 		(L0625_i_SensorType == k14_SensorWallSingleProjLauncherSquareObj);
@@ -746,36 +746,36 @@ void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* eve
 		L0622_T_FirstProjectileAssociatedThing = L0623_T_SecondProjectileAssociatedThing = Thing(L0629_i_SensorData + Thing::_firstExplosion.toUint16());
 	} else {
 		if ((L0625_i_SensorType == k14_SensorWallSingleProjLauncherSquareObj) || (L0625_i_SensorType == k15_SensorWallDoubleProjLauncherSquareObj)) {
-			L0622_T_FirstProjectileAssociatedThing = _vm->_dungeonMan->f161_getSquareFirstThing(L0626_i_MapX, L0627_i_MapY);
+			L0622_T_FirstProjectileAssociatedThing = _vm->_dungeonMan->getSquareFirstThing(L0626_i_MapX, L0627_i_MapY);
 			while (L0622_T_FirstProjectileAssociatedThing != Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList. If there are no more objects on the square then this loop may return an undefined value, this can crash the game. In the original DM and CSB dungeons, the number of times that these sensors are triggered is always controlled to be equal to the number of available objects (with a countdown sensor or a number of once only sensors) */
 				L0633_ui_ThingCell = L0622_T_FirstProjectileAssociatedThing.getCell();
 				if ((L0622_T_FirstProjectileAssociatedThing.getType() > k3_SensorThingType) && ((L0633_ui_ThingCell == L0624_ui_Cell) || (L0633_ui_ThingCell == returnNextVal(L0624_ui_Cell))))
 					break;
-				L0622_T_FirstProjectileAssociatedThing = _vm->_dungeonMan->f159_getNextThing(L0622_T_FirstProjectileAssociatedThing);
+				L0622_T_FirstProjectileAssociatedThing = _vm->_dungeonMan->getNextThing(L0622_T_FirstProjectileAssociatedThing);
 			}
 			if (L0622_T_FirstProjectileAssociatedThing == Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList */
 				return;
 			}
-			_vm->_dungeonMan->f164_unlinkThingFromList(L0622_T_FirstProjectileAssociatedThing, Thing(0), L0626_i_MapX, L0627_i_MapY); /* The object is removed without triggering any sensor effects */
+			_vm->_dungeonMan->unlinkThingFromList(L0622_T_FirstProjectileAssociatedThing, Thing(0), L0626_i_MapX, L0627_i_MapY); /* The object is removed without triggering any sensor effects */
 			if (!L0632_B_LaunchSingleProjectile) {
-				L0623_T_SecondProjectileAssociatedThing = _vm->_dungeonMan->f161_getSquareFirstThing(L0626_i_MapX, L0627_i_MapY);
+				L0623_T_SecondProjectileAssociatedThing = _vm->_dungeonMan->getSquareFirstThing(L0626_i_MapX, L0627_i_MapY);
 				while (L0623_T_SecondProjectileAssociatedThing != Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList. If there are no more objects on the square then this loop may return an undefined value, this can crash the game */
 					L0633_ui_ThingCell = L0623_T_SecondProjectileAssociatedThing.getCell();
 					if ((L0623_T_SecondProjectileAssociatedThing.getType() > k3_SensorThingType) && ((L0633_ui_ThingCell == L0624_ui_Cell) || (L0633_ui_ThingCell == returnNextVal(L0624_ui_Cell))))
 						break;
-					L0623_T_SecondProjectileAssociatedThing = _vm->_dungeonMan->f159_getNextThing(L0623_T_SecondProjectileAssociatedThing);
+					L0623_T_SecondProjectileAssociatedThing = _vm->_dungeonMan->getNextThing(L0623_T_SecondProjectileAssociatedThing);
 				}
 				if (L0623_T_SecondProjectileAssociatedThing == Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList */
 					L0632_B_LaunchSingleProjectile = true;
 				} else {
-					_vm->_dungeonMan->f164_unlinkThingFromList(L0623_T_SecondProjectileAssociatedThing, Thing(0), L0626_i_MapX, L0627_i_MapY); /* The object is removed without triggering any sensor effects */
+					_vm->_dungeonMan->unlinkThingFromList(L0623_T_SecondProjectileAssociatedThing, Thing(0), L0626_i_MapX, L0627_i_MapY); /* The object is removed without triggering any sensor effects */
 				}
 			}
 		} else {
-			if ((L0622_T_FirstProjectileAssociatedThing = _vm->_dungeonMan->f167_getObjForProjectileLaucherOrObjGen(L0629_i_SensorData)) == Thing::_none) {
+			if ((L0622_T_FirstProjectileAssociatedThing = _vm->_dungeonMan->getObjForProjectileLaucherOrObjGen(L0629_i_SensorData)) == Thing::_none) {
 				return;
 			}
-			if (!L0632_B_LaunchSingleProjectile && ((L0623_T_SecondProjectileAssociatedThing = _vm->_dungeonMan->f167_getObjForProjectileLaucherOrObjGen(L0629_i_SensorData)) == Thing::_none)) {
+			if (!L0632_B_LaunchSingleProjectile && ((L0623_T_SecondProjectileAssociatedThing = _vm->_dungeonMan->getObjForProjectileLaucherOrObjGen(L0629_i_SensorData)) == Thing::_none)) {
 				L0632_B_LaunchSingleProjectile = true;
 			}
 		}
@@ -810,49 +810,49 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 	TimelineEvent L0619_s_Event;
 
 
-	L0613_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0616_ui_MapX = event->_B._location._mapX, L0617_ui_MapY = event->_B._location._mapY);
+	L0613_T_Thing = _vm->_dungeonMan->getSquareFirstThing(L0616_ui_MapX = event->_B._location._mapX, L0617_ui_MapY = event->_B._location._mapY);
 	while (L0613_T_Thing != Thing::_endOfList) {
 		if ((L0610_i_ThingType = L0613_T_Thing.getType()) == k2_TextstringType) {
-			L0615_ps_TextString = (TextString*)_vm->_dungeonMan->f156_getThingData(L0613_T_Thing);
+			L0615_ps_TextString = (TextString*)_vm->_dungeonMan->getThingData(L0613_T_Thing);
 			L0611_B_TextCurrentlyVisible = L0615_ps_TextString->isVisible();
 			if (event->_C.A._effect == k2_SensorEffToggle) {
 				L0615_ps_TextString->setVisible(!L0611_B_TextCurrentlyVisible);
 			} else {
 				L0615_ps_TextString->setVisible((event->_C.A._effect == k0_SensorEffSet));
 			}
-			if (!L0611_B_TextCurrentlyVisible && L0615_ps_TextString->isVisible() && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0616_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0617_ui_MapY == _vm->_dungeonMan->_g307_partyMapY)) {
-				_vm->_dungeonMan->f168_decodeText(_vm->_stringBuildBuffer, L0613_T_Thing, k1_TextTypeMessage);
+			if (!L0611_B_TextCurrentlyVisible && L0615_ps_TextString->isVisible() && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0616_ui_MapX == _vm->_dungeonMan->_partyMapX) && (L0617_ui_MapY == _vm->_dungeonMan->_partyMapY)) {
+				_vm->_dungeonMan->decodeText(_vm->_stringBuildBuffer, L0613_T_Thing, k1_TextTypeMessage);
 				_vm->_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, _vm->_stringBuildBuffer);
 			}
 		} else {
 			if (L0610_i_ThingType == k3_SensorThingType) {
-				L0614_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0613_T_Thing);
+				L0614_ps_Sensor = (Sensor*)_vm->_dungeonMan->getThingData(L0613_T_Thing);
 				if (L0614_ps_Sensor->getType() == k6_SensorFloorGroupGenerator) {
-					L0612_i_CreatureCount = L0614_ps_Sensor->getValue();
+					L0612_i_CreatureCount = L0614_ps_Sensor->getAttrValue();
 					if (getFlag(L0612_i_CreatureCount, k0x0008_randomizeGeneratedCreatureCount)) {
 						L0612_i_CreatureCount = _vm->getRandomNumber(getFlag(L0612_i_CreatureCount, k0x0007_generatedCreatureCount));
 					} else {
 						L0612_i_CreatureCount--;
 					}
-					AL0618_ui_HealthMultiplier = L0614_ps_Sensor->getHealthMultiplier();
+					AL0618_ui_HealthMultiplier = L0614_ps_Sensor->getActionHealthMultiplier();
 					if (AL0618_ui_HealthMultiplier == 0) {
-						AL0618_ui_HealthMultiplier = _vm->_dungeonMan->_g269_currMap->_difficulty;
+						AL0618_ui_HealthMultiplier = _vm->_dungeonMan->_currMap->_difficulty;
 					}
 					_vm->_groupMan->f185_groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (Direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY);
-					if (L0614_ps_Sensor->getAudibleA()) {
+					if (L0614_ps_Sensor->getAttrAudibleA()) {
 						_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0616_ui_MapX, L0617_ui_MapY, k1_soundModePlayIfPrioritized);
 					}
-					if (L0614_ps_Sensor->getOnlyOnce()) {
+					if (L0614_ps_Sensor->getAttrOnlyOnce()) {
 						L0614_ps_Sensor->setTypeDisabled();
 					} else {
-						AL0618_ui_Ticks = L0614_ps_Sensor->M46_ticks();
+						AL0618_ui_Ticks = L0614_ps_Sensor->getActionTicks();
 						if (AL0618_ui_Ticks != 0) {
 							L0614_ps_Sensor->setTypeDisabled();
 							if (AL0618_ui_Ticks > 127) {
 								AL0618_ui_Ticks = (AL0618_ui_Ticks - 126) << 6;
 							}
 							L0619_s_Event._type = k65_TMEventTypeEnableGroupGenerator;
-							setMapAndTime(L0619_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_gameTime + AL0618_ui_Ticks);
+							setMapAndTime(L0619_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + AL0618_ui_Ticks);
 							L0619_s_Event._priority = 0;
 							L0619_s_Event._B._location._mapX = L0616_ui_MapX;
 							L0619_s_Event._B._location._mapY = L0617_ui_MapY;
@@ -863,7 +863,7 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 				}
 			}
 		}
-		L0613_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0613_T_Thing);
+		L0613_T_Thing = _vm->_dungeonMan->getNextThing(L0613_T_Thing);
 	}
 }
 
@@ -878,7 +878,7 @@ void Timeline::f252_timelineProcessEvents60to61_moveGroup(TimelineEvent* event)
 	L0657_ui_MapY = event->_B._location._mapY;
 	L0657_ui_MapY = event->_B._location._mapY;
 T0252001:
-	if (((_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) || (L0656_ui_MapX != _vm->_dungeonMan->_g306_partyMapX) || (L0657_ui_MapY != _vm->_dungeonMan->_g307_partyMapY)) && (_vm->_groupMan->f175_groupGetThing(L0656_ui_MapX, L0657_ui_MapY) == Thing::_endOfList)) { /* BUG0_24 Lord Chaos may teleport into one of the Black Flames and become invisible until the Black Flame is killed. In this case, _vm->_groupMan->f175_groupGetThing returns the Black Flame thing and the Lord Chaos thing is not moved into the dungeon until the Black Flame is killed */
+	if (((_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex) || (L0656_ui_MapX != _vm->_dungeonMan->_partyMapX) || (L0657_ui_MapY != _vm->_dungeonMan->_partyMapY)) && (_vm->_groupMan->f175_groupGetThing(L0656_ui_MapX, L0657_ui_MapY) == Thing::_endOfList)) { /* BUG0_24 Lord Chaos may teleport into one of the Black Flames and become invisible until the Black Flame is killed. In this case, _vm->_groupMan->f175_groupGetThing returns the Black Flame thing and the Lord Chaos thing is not moved into the dungeon until the Black Flame is killed */
 		if (event->_type == k61_TMEventTypeMoveGroupAudible) {
 			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0656_ui_MapX, L0657_ui_MapY, k1_soundModePlayIfPrioritized);
 		}
@@ -886,7 +886,7 @@ T0252001:
 	} else {
 		if (!L0659_B_RandomDirectionMoveRetried) {
 			L0659_B_RandomDirectionMoveRetried = true;
-			L0658_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(Thing(event->_C._slot));
+			L0658_ps_Group = (Group*)_vm->_dungeonMan->getThingData(Thing(event->_C._slot));
 			if ((L0658_ps_Group->_type == k23_CreatureTypeLordChaos) && !_vm->getRandomNumber(4)) {
 				switch (_vm->getRandomNumber(4)) {
 				case 0:
@@ -914,17 +914,17 @@ void Timeline::f246_timelineProcesEvent65_enableGroupGenerator(TimelineEvent* ev
 	Thing L0620_T_Thing;
 	Sensor* L0621_ps_Sensor;
 
-	L0620_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(event->_B._location._mapX, event->_B._location._mapY);
-	L0620_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(event->_B._location._mapX, event->_B._location._mapY);
+	L0620_T_Thing = _vm->_dungeonMan->getSquareFirstThing(event->_B._location._mapX, event->_B._location._mapY);
+	L0620_T_Thing = _vm->_dungeonMan->getSquareFirstThing(event->_B._location._mapX, event->_B._location._mapY);
 	while (L0620_T_Thing != Thing::_none) {
 		if ((L0620_T_Thing.getType()) == k3_SensorThingType) {
-			L0621_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0620_T_Thing);
+			L0621_ps_Sensor = (Sensor*)_vm->_dungeonMan->getThingData(L0620_T_Thing);
 			if (L0621_ps_Sensor->getType() == k0_SensorDisabled) {
 				L0621_ps_Sensor->setDatAndTypeWithOr(k6_SensorFloorGroupGenerator);
 				return;
 			}
 		}
-		L0620_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0620_T_Thing);
+		L0620_T_Thing = _vm->_dungeonMan->getNextThing(L0620_T_Thing);
 	}
 }
 
@@ -1030,7 +1030,7 @@ void Timeline::f257_timelineProcessEvent70_light(TimelineEvent* event) {
 	if (L0673_i_WeakerLightPower) {
 		L0676_s_Event._type = k70_TMEventTypeLight;
 		L0676_s_Event._B._lightPower = L0673_i_WeakerLightPower;
-		setMapAndTime(L0676_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_gameTime + 4);
+		setMapAndTime(L0676_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + 4);
 		L0676_s_Event._priority = 0;
 		f238_addEventGetEventIndex(&L0676_s_Event);
 	}
@@ -1071,21 +1071,21 @@ T0255002:
 		f238_addEventGetEventIndex(event);
 		break;
 	case 1:
-		L0667_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0664_i_MapX, L0665_i_MapY);
+		L0667_T_Thing = _vm->_dungeonMan->getSquareFirstThing(L0664_i_MapX, L0665_i_MapY);
 		while (L0667_T_Thing != Thing::_endOfList) {
 			if ((L0667_T_Thing.getCell() == L0666_ui_Cell) && (L0667_T_Thing.getType() == k10_JunkThingType)) {
 				L0669_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0667_T_Thing);
 				if (L0669_i_IconIndex == k147_IconIndiceJunkChampionBones) {
-					L0668_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0667_T_Thing);
+					L0668_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L0667_T_Thing);
 					if (L0668_ps_Junk->getChargeCount() == L0671_ui_ChampionIndex) {
-						_vm->_dungeonMan->f164_unlinkThingFromList(L0667_T_Thing, Thing(0), L0664_i_MapX, L0665_i_MapY); /* BUG0_25 When a champion dies, no bones object is created so it is not possible to bring the champion back to life at an altar of Vi. Each time a champion is brought back to life, the bones object is removed from the dungeon but it is not marked as unused and thus becomes an orphan. After a large number of champion deaths, all JUNK things are exhausted and the game cannot create any more. This also affects the creation of JUNK things dropped by some creatures when they die (Screamer, Rockpile, Magenta Worm, Pain Rat, Red Dragon) */
+						_vm->_dungeonMan->unlinkThingFromList(L0667_T_Thing, Thing(0), L0664_i_MapX, L0665_i_MapY); /* BUG0_25 When a champion dies, no bones object is created so it is not possible to bring the champion back to life at an altar of Vi. Each time a champion is brought back to life, the bones object is removed from the dungeon but it is not marked as unused and thus becomes an orphan. After a large number of champion deaths, all JUNK things are exhausted and the game cannot create any more. This also affects the creation of JUNK things dropped by some creatures when they die (Screamer, Rockpile, Magenta Worm, Pain Rat, Red Dragon) */
 						L0668_ps_Junk->setNextThing(Thing::_none);
 						event->_mapTime += 1;
 						goto T0255002;
 					}
 				}
 			}
-			L0667_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0667_T_Thing);
+			L0667_T_Thing = _vm->_dungeonMan->getNextThing(L0667_T_Thing);
 		}
 		break;
 	case 0:


Commit: 36e6eac2f3d4b62774fd685ade0ec3707166be04
    https://github.com/scummvm/scummvm/commit/36e6eac2f3d4b62774fd685ade0ec3707166be04
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Fix GCC errors in detection.cpp

Changed paths:
    engines/dm/detection.cpp
    engines/dm/dm.h



diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp
index ebdae4e..548bab8 100644
--- a/engines/dm/detection.cpp
+++ b/engines/dm/detection.cpp
@@ -42,33 +42,38 @@ static const PlainGameDescriptor DMGames[] = {
 
 static const DMADGameDescription gameDescriptions[] = {
 	{
-		"dm", "Amiga 2.0v English",
-		{
-			{"graphics.dat", 0, "c2205f6225bde728417de29394f97d55", 411960},
-			{"Dungeon.dat", 0, "43a213da8eda413541dd12f90ce202f6", 25006},
-		AD_LISTEND
+		{"dm", "Amiga 2.0v English",
+			{
+				{"graphics.dat", 0, "c2205f6225bde728417de29394f97d55", 411960},
+				{"Dungeon.dat", 0, "43a213da8eda413541dd12f90ce202f6", 25006},
+				AD_LISTEND
+			},
+			Common::EN_ANY, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE)
 		},
-		Common::EN_ANY, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE),
 	    k_saveTarget_DM21, k_saveFormat_dm_amiga__2_x_pc98_x68000_fm_towns_csb_atari_st, k_savePlatform_amiga,
 		{ k_saveTarget_DM21, k_saveTarget_endOfList },
 		{ k_saveFormat_dm_amiga__2_x_pc98_x68000_fm_towns_csb_atari_st, k_saveFormat_endOfList},
 		{ k_savePlatform_accept_any}
 	},
 	{
-		"dm", "Atari ???v English",
-		{
-			{"graphics.dat", 0, "6ffff2a17e2df0effa9a12fb4b1bf6b6", 271911},
-			{"Dungeon.dat", 0, "be9468b460515741babec9a70501e2e9", 33286},
-			AD_LISTEND
-		},
-	    Common::EN_ANY, Common::kPlatformAtariST, ADGF_NO_FLAGS, GUIO1(GUIO_NONE),
+		{"dm", "Atari ???v English",
+			{
+				{"graphics.dat", 0, "6ffff2a17e2df0effa9a12fb4b1bf6b6", 271911},
+				{"Dungeon.dat", 0, "be9468b460515741babec9a70501e2e9", 33286},
+				AD_LISTEND
+			},
+	    	Common::EN_ANY, Common::kPlatformAtariST, ADGF_NO_FLAGS, GUIO1(GUIO_NONE),
+	    },
 	    k_saveTarget_DM21, k_saveFormat_dm_amiga__2_x_pc98_x68000_fm_towns_csb_atari_st, k_savePlatform_atari_st,
 	    { k_saveTarget_DM21, k_saveTarget_endOfList},
 	    { k_saveFormat_dm_amiga__2_x_pc98_x68000_fm_towns_csb_atari_st, k_saveFormat_endOfList},
 	    { k_savePlatform_accept_any }
 	},
 
-	AD_TABLE_END_MARKER
+	{	
+		AD_TABLE_END_MARKER, k_saveTarget_none, k_saveFormat_none, k_savePlatform_none,
+		{k_saveTarget_none}, {k_saveFormat_none}, {k_savePlatform_none}
+	}
 };
 
 
@@ -93,7 +98,7 @@ public:
 
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
 		if (desc)
-			*engine = new DM::DMEngine(syst, (DMADGameDescription*)desc);
+			*engine = new DM::DMEngine(syst, (const DMADGameDescription*)desc);
 		return desc != nullptr;
 	}
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index cc8b93a..921197f 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -61,6 +61,7 @@ class SoundMan;
 enum OriginalSaveFormat {
 	k_saveFormat_accept_any = -1,
 	k_saveFormat_endOfList = 0,
+	k_saveFormat_none = 0,
 	k_saveFormat_dm_atari_st = 1,
 	k_saveFormat_dm_amiga__2_x_pc98_x68000_fm_towns_csb_atari_st = 2,
 	k_saveFormat_dm_apple_iigs = 3,
@@ -71,6 +72,7 @@ enum OriginalSaveFormat {
 enum OriginalSavePlatform {
 	k_savePlatform_accept_any = -1,
 	k_savePlatform_endOfList = 0,
+	k_savePlatform_none = 0,
 	k_savePlatform_atari_st = 1, // @ C1_PLATFORM_ATARI_ST   
 	k_savePlatform_apple_iigs = 2, // @ C2_PLATFORM_APPLE_IIGS 
 	k_savePlatform_amiga = 3, // @ C3_PLATFORM_AMIGA      
@@ -85,6 +87,7 @@ enum OriginalSavePlatform {
 enum SaveTarget {
 	k_saveTarget_accept_any = -1,
 	k_saveTarget_endOfList = 0,
+	k_saveTarget_none = 0,
 	k_saveTarget_DM21 = 1,
 	k_saveTarget_total
 };


Commit: 0d5f9a762eec1b6ce13e21b2f94aaac7596ff479
    https://github.com/scummvm/scummvm/commit/0d5f9a762eec1b6ce13e21b2f94aaac7596ff479
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rename class members in EventManager

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dialog.cpp
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index f9adcc7..9edd146 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -442,7 +442,7 @@ bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing)
 		if (newIconIndex != currIconIndex) {
 			if ((slotBoxIndex < k8_SlotBoxInventoryFirstSlot) && !_mousePointerHiddenToDrawChangedObjIconOnScreen) {
 				_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
-				_vm->_eventMan->f77_hideMouse();
+				_vm->_eventMan->hideMouse();
 			}
 			objMan.f38_drawIconInSlotBox(slotBoxIndex, newIconIndex);
 			return true;
@@ -470,9 +470,9 @@ void ChampionMan::drawChangedObjectIcons() {
 		IconIndice iconIndex = objMan.f33_getIconIndex(_leaderHandObject);
 		if (iconIndex != leaderHandObjIconIndex) {
 			_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
-			_vm->_eventMan->f77_hideMouse();
+			_vm->_eventMan->hideMouse();
 			objMan.f36_extractIconFromBitmap(iconIndex, objMan._g412_objectIconForMousePointer);
-			_vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
+			_vm->_eventMan->setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
 			_leaderHandObjectIconIndex = iconIndex;
 			objMan.f34_drawLeaderObjectName(_leaderHandObject);
 		}
@@ -517,7 +517,7 @@ void ChampionMan::drawChangedObjectIcons() {
 	}
 
 	if (_mousePointerHiddenToDrawChangedObjIconOnScreen)
-		_vm->_eventMan->f78_showMouse();
+		_vm->_eventMan->showMouse();
 }
 
 void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex) {
@@ -607,10 +607,10 @@ Thing ChampionMan::getObjectRemovedFromLeaderHand() {
 	if (leaderHandObject != Thing::_none) {
 		_leaderHandObject = Thing::_none;
 		_leaderHandObjectIconIndex = kM1_IconIndiceNone;
-		_vm->_eventMan->f78_showMouse();
+		_vm->_eventMan->showMouse();
 		_vm->_objectMan->f35_clearLeaderObjectName();
-		_vm->_eventMan->f69_setMousePointer();
-		_vm->_eventMan->f77_hideMouse();
+		_vm->_eventMan->setMousePointer();
+		_vm->_eventMan->hideMouse();
 		if (_leaderIndex != kM1_ChampionNone) {
 			_champions[_leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(leaderHandObject);
 			setFlag(_champions[_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
@@ -902,11 +902,11 @@ void ChampionMan::wakeUp() {
 	_vm->_waitForInputMaxVerticalBlankCount = 10;
 	_vm->delay(10);
 	_vm->_displayMan->f98_drawFloorAndCeiling();
-	_vm->_eventMan->_g441_primaryMouseInput = _vm->_eventMan->_primaryMouseInputInterface;
-	_vm->_eventMan->_g442_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputMovement;
-	_vm->_eventMan->_g443_primaryKeyboardInput = _vm->_eventMan->_primaryKeyboardInputInterface;
-	_vm->_eventMan->_g444_secondaryKeyboardInput = _vm->_eventMan->_secondaryKeyboardInputMovement;
-	_vm->_eventMan->f357_discardAllInput();
+	_vm->_eventMan->_primaryMouseInput = _vm->_eventMan->_primaryMouseInputInterface;
+	_vm->_eventMan->_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputMovement;
+	_vm->_eventMan->_primaryKeyboardInput = _vm->_eventMan->_primaryKeyboardInputInterface;
+	_vm->_eventMan->_secondaryKeyboardInput = _vm->_eventMan->_secondaryKeyboardInputMovement;
+	_vm->_eventMan->discardAllInput();
 	_vm->_menuMan->f457_drawEnabledMenus();
 }
 
@@ -1197,15 +1197,15 @@ void ChampionMan::putObjectInLeaderHand(Thing thing, bool setMousePointer) {
 
 	_leaderEmptyHanded = false;
 	_vm->_objectMan->f36_extractIconFromBitmap(_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->showMouse();
 	_vm->_objectMan->f34_drawLeaderObjectName(thing);
 
 	if (setMousePointer)
 		_vm->_setMousePointerToObjectInMainLoop = true;
 	else
-		_vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
+		_vm->_eventMan->setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
 
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->hideMouse();
 	if (_leaderIndex != kM1_ChampionNone) {
 		_champions[_leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(thing);
 		setFlag(_champions[_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
@@ -1322,7 +1322,7 @@ void ChampionMan::clickOnSlotBox(uint16 slotBoxIndex) {
 	if ((leaderHandObject != Thing::_none) && (!(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(leaderHandObject)]._allowedSlots & _slotMasks[slotIndex])))
 		return;
 
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->showMouse();
 	if (leaderHandObject != Thing::_none)
 		getObjectRemovedFromLeaderHand();
 
@@ -1335,7 +1335,7 @@ void ChampionMan::clickOnSlotBox(uint16 slotBoxIndex) {
 		addObjectInSlot((ChampionIndex)champIndex, leaderHandObject, (ChampionSlot)slotIndex);
 
 	drawChampionState((ChampionIndex)champIndex);
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->hideMouse();
 }
 
 bool ChampionMan::isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount) {
@@ -1395,7 +1395,7 @@ void ChampionMan::applyAndDrawPendingDamageAndWounds() {
 
 			Box blitBox;
 			blitBox._y1 = 0;
-			_vm->_eventMan->f78_showMouse();
+			_vm->_eventMan->showMouse();
 
 			if (_vm->indexToOrdinal(championIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 				blitBox._y2 = 28;
@@ -1441,7 +1441,7 @@ void ChampionMan::applyAndDrawPendingDamageAndWounds() {
 				_vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(eventIndex));
 			}
 			drawChampionState((ChampionIndex)championIndex);
-			_vm->_eventMan->f77_hideMouse();
+			_vm->_eventMan->hideMouse();
 		}
 	}
 }
@@ -1453,17 +1453,17 @@ void ChampionMan::championKill(uint16 champIndex) {
 	if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 		if (_vm->_pressingEye) {
 			_vm->_pressingEye = false;
-			_vm->_eventMan->_g597_ignoreMouseMovements = false;
+			_vm->_eventMan->_ignoreMouseMovements = false;
 			if (!_leaderEmptyHanded) {
 				_vm->_objectMan->f34_drawLeaderObjectName(_leaderHandObject);
 			}
-			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
-			_vm->_eventMan->f77_hideMouse();
+			_vm->_eventMan->_hideMousePointerRequestCount = 1;
+			_vm->_eventMan->hideMouse();
 		} else if (_vm->_pressingMouth) {
 			_vm->_pressingMouth = false;
-			_vm->_eventMan->_g597_ignoreMouseMovements = false;
-			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
-			_vm->_eventMan->f77_hideMouse();
+			_vm->_eventMan->_ignoreMouseMovements = false;
+			_vm->_eventMan->_hideMousePointerRequestCount = 1;
+			_vm->_eventMan->hideMouse();
 		}
 		_vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
 	}
@@ -1483,9 +1483,9 @@ void ChampionMan::championKill(uint16 champIndex) {
 	curChampion->_dir = _vm->_dungeonMan->_partyDir;
 	curChampion->_maximumDamageReceived = 0;
 	uint16 curChampionIconIndex = getChampionIconIndex(curCell, _vm->_dungeonMan->_partyDir);
-	if (_vm->indexToOrdinal(curChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
-		_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
-		_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kM1_ChampionNone);
+	if (_vm->indexToOrdinal(curChampionIconIndex) == _vm->_eventMan->_useChampionIconOrdinalAsMousePointerBitmap) {
+		_vm->_eventMan->_mousePointerBitmapUpdated = true;
+		_vm->_eventMan->_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kM1_ChampionNone);
 	}
 
 	if (curChampion->_poisonEventCount)
@@ -1507,7 +1507,7 @@ void ChampionMan::championKill(uint16 champIndex) {
 	}
 
 	if (champIndex == _leaderIndex)
-		_vm->_eventMan->f368_commandSetLeader((ChampionIndex)aliveChampionIndex);
+		_vm->_eventMan->commandSetLeader((ChampionIndex)aliveChampionIndex);
 
 	if (champIndex == _magicCasterChampionIndex)
 		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(aliveChampionIndex);
@@ -1833,7 +1833,7 @@ void ChampionMan::resetDataToStartGame() {
 		if ((L0787_T_Thing = _leaderHandObject) == Thing::_none) {
 			_leaderEmptyHanded = true;
 			_leaderHandObjectIconIndex = kM1_IconIndiceNone;
-			_vm->_eventMan->f69_setMousePointer();
+			_vm->_eventMan->setMousePointer();
 		} else {
 			putObjectInLeaderHand(L0787_T_Thing, true); /* This call will add the weight of the leader hand object to the Load of the leader a first time */
 		}
@@ -1846,7 +1846,7 @@ void ChampionMan::resetDataToStartGame() {
 		drawAllChampionStates();
 		if ((L0785_i_ChampionIndex = _leaderIndex) != kM1_ChampionNone) {
 			_leaderIndex = kM1_ChampionNone;
-			_vm->_eventMan->f368_commandSetLeader((ChampionIndex)L0785_i_ChampionIndex);
+			_vm->_eventMan->commandSetLeader((ChampionIndex)L0785_i_ChampionIndex);
 		}
 		if ((L0785_i_ChampionIndex = _magicCasterChampionIndex) != kM1_ChampionNone) {
 			_magicCasterChampionIndex = kM1_ChampionNone;
@@ -1948,7 +1948,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	}
 	_candidateChampionOrdinal = previousPartyChampionCount + 1;
 	if (++_partyChampionCount == 1) {
-		_vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst);
+		_vm->_eventMan->commandSetLeader(k0_ChampionFirst);
 		_vm->_menuMan->_g508_refreshActionArea = true;
 	} else {
 		_vm->_menuMan->f388_clearActingChampion();
@@ -2057,7 +2057,7 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
 	} else {
 		barGraphHeights[barGraphIdx] = 0;
 	}
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->showMouse();
 
 	// Strangerke - TO CHECK: if portraits, maybe the old (assembly) code is required for older versions
 	Box box;
@@ -2080,7 +2080,7 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
 		box._x1 += 7;
 		box._x2 += 7;
 	}
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->hideMouse();
 }
 
 
@@ -2121,7 +2121,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 
 	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->showMouse();
 	if (getFlag(championAttributes, k0x1000_ChampionAttributeStatusBox)) {
 		Box box;
 		box._y1 = 0;
@@ -2158,13 +2158,13 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			_vm->_menuMan->f386_drawActionIcon(champIndex);
 
 			clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
-			_vm->_eventMan->f77_hideMouse();
+			_vm->_eventMan->hideMouse();
 			return;
 		}
 	}
 	if (!(curChampion->_currHealth)) {
 		clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
-		_vm->_eventMan->f77_hideMouse();
+		_vm->_eventMan->hideMouse();
 		return;
 	}
 
@@ -2256,7 +2256,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
 	uint16 championIconIndex = getChampionIconIndex(curChampion->_cell, _vm->_dungeonMan->_partyDir);
-	if (getFlag(championAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(championIconIndex))) {
+	if (getFlag(championAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(championIconIndex))) {
 		_vm->_displayMan->D24_fillScreenBox(_boxChampionIcons[championIconIndex], _championColor[champIndex]);
 		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, _boxChampionIcons[championIconIndex], getChampionIconIndex(curChampion->_dir, _vm->_dungeonMan->_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
 	}
@@ -2281,7 +2281,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
 
 	clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->hideMouse();
 }
 
 uint16 ChampionMan::getChampionIconIndex(int16 val, Direction dir) {
@@ -2322,7 +2322,7 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 	box._y2 = box._y1 + 17;
 
 	if (!isInventoryChamp)
-		_vm->_eventMan->f77_hideMouse();
+		_vm->_eventMan->hideMouse();
 
 	int16 iconIndex;
 	if (thing == Thing::_none) {
@@ -2371,7 +2371,7 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 	_vm->_objectMan->f38_drawIconInSlotBox(slotBoxIndex, iconIndex);
 
 	if (!isInventoryChamp)
-		_vm->_eventMan->f78_showMouse();
+		_vm->_eventMan->showMouse();
 }
 
 void ChampionMan::renameChampion(Champion* champ) {
@@ -2391,10 +2391,10 @@ void ChampionMan::renameChampion(Champion* champ) {
 	_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), _vm->_inventoryMan->g32_BoxPanel, k72_byteWidth, k4_ColorCyan, 73);
 	_vm->_textMan->f52_printToViewport(177, 58, k13_ColorLightestGray, "_______");
 	_vm->_textMan->f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________");
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->showMouse();
 	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
-	_vm->_eventMan->f67_setMousePointerToNormal(k0_pointerArrow);
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->setMousePointerToNormal(k0_pointerArrow);
+	_vm->_eventMan->hideMouse();
 	uint16 curCharacterIndex = 0;
 	champ->_name[curCharacterIndex] = '\0';
 	champ->_title[0] = '\0';
@@ -2406,9 +2406,9 @@ void ChampionMan::renameChampion(Champion* champ) {
 	for (;;) { /*_Infinite loop_*/
 		bool championTitleIsFull = ((renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE) && (curCharacterIndex == 19));
 		if (!championTitleIsFull) {
-			_vm->_eventMan->f78_showMouse();
+			_vm->_eventMan->showMouse();
 			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k9_ColorGold, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
-			_vm->_eventMan->f77_hideMouse();
+			_vm->_eventMan->hideMouse();
 		}
 
 		int16 curCharacter = 256;
@@ -2491,9 +2491,9 @@ void ChampionMan::renameChampion(Champion* champ) {
 			if ((curCharacter != ' ') || curCharacterIndex != 0) {
 				if (!championTitleIsFull) {
 					renameChampionInputCharacterString[0] = curCharacter;
-					_vm->_eventMan->f78_showMouse();
+					_vm->_eventMan->showMouse();
 					_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, renameChampionInputCharacterString, k200_heightScreen);
-					_vm->_eventMan->f77_hideMouse();
+					_vm->_eventMan->hideMouse();
 					renamedChampionString[curCharacterIndex++] = curCharacter;
 					renamedChampionString[curCharacterIndex] = '\0';
 					textPosX += 6;
@@ -2508,9 +2508,9 @@ void ChampionMan::renameChampion(Champion* champ) {
 			}
 		} else if (curCharacter == '\r') { // Carriage return
 			if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex > 0)) {
-				_vm->_eventMan->f78_showMouse();
+				_vm->_eventMan->showMouse();
 				_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
-				_vm->_eventMan->f77_hideMouse();
+				_vm->_eventMan->hideMouse();
 				renamedChampionStringMode = k2_RENAME_CHAMPION_TITLE;
 				renamedChampionString = champ->_title;
 				textPosX = 105;
@@ -2522,9 +2522,9 @@ void ChampionMan::renameChampion(Champion* champ) {
 				continue;
 
 			if (!championTitleIsFull) {
-				_vm->_eventMan->f78_showMouse();
+				_vm->_eventMan->showMouse();
 				_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
-				_vm->_eventMan->f77_hideMouse();
+				_vm->_eventMan->hideMouse();
 			}
 			if (curCharacterIndex == 0) {
 				renamedChampionString = champ->_name;
diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index bf9ea55..ae58b75 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -125,9 +125,9 @@ void DialogMan::dialogDraw(const char *msg1, const char *msg2, const char *choic
 		displayBox._y2 = 168;
 		displayBox._x1 = 47;
 		displayBox._x2 = 270;
-		_vm->_eventMan->f78_showMouse();
+		_vm->_eventMan->showMouse();
 		_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->_g296_bitmapViewport, &displayBox, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport);
-		_vm->_eventMan->f77_hideMouse();
+		_vm->_eventMan->hideMouse();
 	} else {
 		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
 		_vm->delay(1);
@@ -170,21 +170,21 @@ int16 DialogMan::getChoice(uint16 choiceCount, uint16 dialogSetIndex, int16 driv
 	Box L1303_s_BoxB;
 	Box L1304_s_BoxA;
 
-	_vm->_eventMan->f77_hideMouse();
-	L1298_ps_PrimaryMouseInputBackup = _vm->_eventMan->_g441_primaryMouseInput;
-	L1299_ps_SecondaryMouseInputBackup = _vm->_eventMan->_g442_secondaryMouseInput;
-	L1300_ps_PrimaryKeyboardInputBackup = _vm->_eventMan->_g443_primaryKeyboardInput;
-	L1301_ps_SecondaryKeyboardInputBackup = _vm->_eventMan->_g444_secondaryKeyboardInput;
-	_vm->_eventMan->_g442_secondaryMouseInput = nullptr;
-	_vm->_eventMan->_g443_primaryKeyboardInput = nullptr;
-	_vm->_eventMan->_g444_secondaryKeyboardInput = nullptr;
-	_vm->_eventMan->_g441_primaryMouseInput = _vm->_eventMan->_primaryMouseInputDialogSets[dialogSetIndex][choiceCount - 1];
-	_vm->_eventMan->f357_discardAllInput();
+	_vm->_eventMan->hideMouse();
+	L1298_ps_PrimaryMouseInputBackup = _vm->_eventMan->_primaryMouseInput;
+	L1299_ps_SecondaryMouseInputBackup = _vm->_eventMan->_secondaryMouseInput;
+	L1300_ps_PrimaryKeyboardInputBackup = _vm->_eventMan->_primaryKeyboardInput;
+	L1301_ps_SecondaryKeyboardInputBackup = _vm->_eventMan->_secondaryKeyboardInput;
+	_vm->_eventMan->_secondaryMouseInput = nullptr;
+	_vm->_eventMan->_primaryKeyboardInput = nullptr;
+	_vm->_eventMan->_secondaryKeyboardInput = nullptr;
+	_vm->_eventMan->_primaryMouseInput = _vm->_eventMan->_primaryMouseInputDialogSets[dialogSetIndex][choiceCount - 1];
+	_vm->_eventMan->discardAllInput();
 	_selectedDialogChoice = 99;
 	do {
 		Common::Event key;
 		Common::EventType eventType = _vm->_eventMan->processInput(&key);
-		_vm->_eventMan->f380_processCommandQueue();
+		_vm->_eventMan->processCommandQueue();
 		_vm->delay(1);
 		_vm->_displayMan->updateScreen();
 		if ((_selectedDialogChoice == 99) && (choiceCount == 1) 
@@ -194,12 +194,12 @@ int16 DialogMan::getChoice(uint16 choiceCount, uint16 dialogSetIndex, int16 driv
 		}
 	} while (_selectedDialogChoice == 99);
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	L1304_s_BoxA = _vm->_eventMan->_g441_primaryMouseInput[_selectedDialogChoice - 1]._hitbox;
+	L1304_s_BoxA = _vm->_eventMan->_primaryMouseInput[_selectedDialogChoice - 1]._hitbox;
 	L1304_s_BoxA._x1 -= 3;
 	L1304_s_BoxA._x2 += 3;
 	L1304_s_BoxA._y1 -= 3;
 	L1304_s_BoxA._y2 += 4;
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->showMouse();
 	_vm->_displayMan->_g297_drawFloorAndCeilingRequested = true;
 	L1303_s_BoxB._x1 = 0;
 	L1303_s_BoxB._y1 = 0;
@@ -256,13 +256,13 @@ int16 DialogMan::getChoice(uint16 choiceCount, uint16 dialogSetIndex, int16 driv
 	L1304_s_BoxA._y2 += 3;
 	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g348_bitmapScreen,
 										L1304_s_BoxA, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 25, k200_heightScreen);
-	_vm->_eventMan->f77_hideMouse();
-	_vm->_eventMan->_g441_primaryMouseInput = L1298_ps_PrimaryMouseInputBackup;
-	_vm->_eventMan->_g442_secondaryMouseInput = L1299_ps_SecondaryMouseInputBackup;
-	_vm->_eventMan->_g443_primaryKeyboardInput = L1300_ps_PrimaryKeyboardInputBackup;
-	_vm->_eventMan->_g444_secondaryKeyboardInput = L1301_ps_SecondaryKeyboardInputBackup;
-	_vm->_eventMan->f357_discardAllInput();
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->hideMouse();
+	_vm->_eventMan->_primaryMouseInput = L1298_ps_PrimaryMouseInputBackup;
+	_vm->_eventMan->_secondaryMouseInput = L1299_ps_SecondaryMouseInputBackup;
+	_vm->_eventMan->_primaryKeyboardInput = L1300_ps_PrimaryKeyboardInputBackup;
+	_vm->_eventMan->_secondaryKeyboardInput = L1301_ps_SecondaryKeyboardInputBackup;
+	_vm->_eventMan->discardAllInput();
+	_vm->_eventMan->showMouse();
 	return _selectedDialogChoice;
 }
 }
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 0c225a7..a51132c 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -241,8 +241,8 @@ Common::Error DMEngine::loadGameState(int slot) {
 
 		startGame();
 		_restartGameRequest = false;
-		_eventMan->f77_hideMouse();
-		_eventMan->f357_discardAllInput();
+		_eventMan->hideMouse();
+		_eventMan->discardAllInput();
 		return Common::kNoError;
 	}
 
@@ -307,8 +307,8 @@ void DMEngine::initializeGame() {
 	startGame();
 	if (_newGameFl)
 		_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
-	_eventMan->f78_showMouse();
-	_eventMan->f357_discardAllInput();
+	_eventMan->showMouse();
+	_eventMan->discardAllInput();
 }
 
 void DMEngine::initMemoryManager() {
@@ -331,16 +331,16 @@ void DMEngine::startGame() {
 	_pressingMouth = false;
 	_stopPressingMouth = false;
 	_highlightBoxInversionRequested = false;
-	_eventMan->_g341_highlightBoxEnabled = false;
+	_eventMan->_highlightBoxEnabled = false;
 	_championMan->_partyIsSleeping = false;
 	_championMan->_actingChampionOrdinal = indexToOrdinal(kM1_ChampionNone);
 	_menuMan->_g509_actionAreaContainsIcons = true;
-	_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kM1_ChampionNone);
+	_eventMan->_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kM1_ChampionNone);
 
-	_eventMan->_g441_primaryMouseInput = _eventMan->_primaryMouseInputInterface;
-	_eventMan->_g442_secondaryMouseInput = _eventMan->_secondaryMouseInputMovement;
-	_eventMan->_g443_primaryKeyboardInput = _eventMan->_primaryKeyboardInputInterface;
-	_eventMan->_g444_secondaryKeyboardInput = _eventMan->_secondaryKeyboardInputMovement;
+	_eventMan->_primaryMouseInput = _eventMan->_primaryMouseInputInterface;
+	_eventMan->_secondaryMouseInput = _eventMan->_secondaryMouseInputMovement;
+	_eventMan->_primaryKeyboardInput = _eventMan->_primaryKeyboardInputInterface;
+	_eventMan->_secondaryKeyboardInput = _eventMan->_secondaryKeyboardInputMovement;
 
 	processNewPartyMap(_dungeonMan->_partyMapIndex);
 
@@ -441,7 +441,7 @@ void DMEngine::gameloop() {
 				processNewPartyMap(_newPartyMapIndex);
 				_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
 				_newPartyMapIndex = kM1_mapIndexNone;
-				_eventMan->f357_discardAllInput();
+				_eventMan->discardAllInput();
 			}
 			_timeline->f261_processTimeline();
 
@@ -455,19 +455,19 @@ void DMEngine::gameloop() {
 			_displayMan->f128_drawDungeon(_dungeonMan->_partyDir, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
 			if (_setMousePointerToObjectInMainLoop) {
 				_setMousePointerToObjectInMainLoop = false;
-				_eventMan->f78_showMouse();
-				_eventMan->f68_setPointerToObject(_objectMan->_g412_objectIconForMousePointer);
-				_eventMan->f77_hideMouse();
+				_eventMan->showMouse();
+				_eventMan->setPointerToObject(_objectMan->_g412_objectIconForMousePointer);
+				_eventMan->hideMouse();
 
 			}
-			if (_eventMan->_g326_refreshMousePointerInMainLoop) {
-				_eventMan->_g326_refreshMousePointerInMainLoop = false;
-				_eventMan->_g598_mousePointerBitmapUpdated = true;
-				_eventMan->f78_showMouse();
-				_eventMan->f77_hideMouse();
+			if (_eventMan->_refreshMousePointerInMainLoop) {
+				_eventMan->_refreshMousePointerInMainLoop = false;
+				_eventMan->_mousePointerBitmapUpdated = true;
+				_eventMan->showMouse();
+				_eventMan->hideMouse();
 			}
 		}
-		_eventMan->f363_highlightBoxDisable();
+		_eventMan->highlightBoxDisable();
 		_sound->f65_playPendingSound();
 		_championMan->applyAndDrawPendingDamageAndWounds();
 		if (_championMan->_partyDead)
@@ -508,14 +508,14 @@ void DMEngine::gameloop() {
 				_inventoryMan->f350_drawStopPressingMouth();
 			}
 
-			_eventMan->f380_processCommandQueue();
+			_eventMan->processCommandQueue();
 			if (_engineShouldQuit || _loadSaveSlotAtRuntime != -1) {
 				_canLoadFromGMM = false;
 				return;
 			}
 			_displayMan->updateScreen();
 			if (!_stopWaitingForPlayerInput) {
-				_eventMan->f363_highlightBoxDisable();
+				_eventMan->highlightBoxDisable();
 			}
 
 			_system->delayMillis(2);
@@ -536,10 +536,10 @@ int16 DMEngine::indexToOrdinal(int16 val) {
 }
 
 void DMEngine::processEntrance() {
-	_eventMan->_g441_primaryMouseInput = _eventMan->_primaryMouseInputEntrance;
-	_eventMan->_g442_secondaryMouseInput = nullptr;
-	_eventMan->_g443_primaryKeyboardInput = nullptr;
-	_eventMan->_g444_secondaryKeyboardInput = nullptr;
+	_eventMan->_primaryMouseInput = _eventMan->_primaryMouseInputEntrance;
+	_eventMan->_secondaryMouseInput = nullptr;
+	_eventMan->_primaryKeyboardInput = nullptr;
+	_eventMan->_secondaryKeyboardInput = nullptr;
 	_entranceDoorAnimSteps[0] = new byte[128 * 161 * 12];
 	for (uint16 idx = 1; idx < 8; idx++)
 		_entranceDoorAnimSteps[idx] = _entranceDoorAnimSteps[idx - 1] + 128 * 161;
@@ -568,14 +568,14 @@ void DMEngine::processEntrance() {
 
 	do {
 		drawEntrance();
-		_eventMan->f78_showMouse();
-		_eventMan->f357_discardAllInput();
+		_eventMan->showMouse();
+		_eventMan->discardAllInput();
 		_newGameFl = k99_modeWaitingOnEntrance;
 		do {
 			_eventMan->processInput();
 			if (_engineShouldQuit)
 				return;
-			_eventMan->f380_processCommandQueue();
+			_eventMan->processCommandQueue();
 			_displayMan->updateScreen();
 		} while (_newGameFl == k99_modeWaitingOnEntrance);
 	} while (_newGameFl == k202_CommandEntranceDrawCredits);
@@ -583,7 +583,7 @@ void DMEngine::processEntrance() {
 	//Strangerke: CHECKME: Earlier versions were using G0566_puc_Graphic534_Sound01Switch
 	_sound->f060_SOUND_Play(k01_soundSWITCH, 112, 0x40, 0x40);
 	delay(20);
-	_eventMan->f78_showMouse();
+	_eventMan->showMouse();
 	if (_newGameFl)
 		openEntranceDoors();
 
@@ -627,12 +627,12 @@ void DMEngine::endGame(bool doNotDrawCreditsOnly) {
 
 	bool waitBeforeDrawingRestart = true;
 
-	_eventMan->f67_setMousePointerToNormal(k0_pointerArrow);
-	_eventMan->f78_showMouse();
-	_eventMan->_g441_primaryMouseInput = nullptr;
-	_eventMan->_g442_secondaryMouseInput = nullptr;
-	_eventMan->_g443_primaryKeyboardInput = nullptr;
-	_eventMan->_g444_secondaryKeyboardInput = nullptr;
+	_eventMan->setMousePointerToNormal(k0_pointerArrow);
+	_eventMan->showMouse();
+	_eventMan->_primaryMouseInput = nullptr;
+	_eventMan->_secondaryMouseInput = nullptr;
+	_eventMan->_primaryKeyboardInput = nullptr;
+	_eventMan->_secondaryKeyboardInput = nullptr;
 	if (doNotDrawCreditsOnly && !_gameWon) {
 		_sound->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY, k0_soundModePlayImmediately);
 		delay(240);
@@ -721,14 +721,14 @@ T0444017:
 
 			curPalette[1] = D03_RGB_PINK;
 			curPalette[4] = D09_RGB_WHITE;
-			_eventMan->_g441_primaryMouseInput = _eventMan->_primaryMouseInputRestartGame;
-			_eventMan->f357_discardAllInput();
-			_eventMan->f77_hideMouse();
+			_eventMan->_primaryMouseInput = _eventMan->_primaryMouseInputRestartGame;
+			_eventMan->discardAllInput();
+			_eventMan->hideMouse();
 			_displayMan->f436_STARTEND_FadeToPalette(curPalette);
 			for (int16 verticalBlankCount = 900; --verticalBlankCount && !_restartGameRequest; delay(1))
-				_eventMan->f380_processCommandQueue();
+				_eventMan->processCommandQueue();
 
-			_eventMan->f78_showMouse();
+			_eventMan->showMouse();
 			if (_restartGameRequest) {
 				_displayMan->f436_STARTEND_FadeToPalette(darkBluePalette);
 				_displayMan->fillScreen(k0_ColorBlack);
@@ -737,8 +737,8 @@ T0444017:
 				if (loadgame(1) != kM1_LoadgameFailure) {
 					startGame();
 					_restartGameRequest = false;
-					_eventMan->f77_hideMouse();
-					_eventMan->f357_discardAllInput();
+					_eventMan->hideMouse();
+					_eventMan->discardAllInput();
 					return;
 				}
 			}
@@ -750,7 +750,7 @@ T0444017:
 	_displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice), &box, k160_byteWidthScreen, kM1_ColorNoTransparency, k200_heightScreen);
 
 	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_palCredits);
-	_eventMan->f541_waitForMouseOrKeyActivity();
+	_eventMan->waitForMouseOrKeyActivity();
 	if (_engineShouldQuit)
 		return;
 
@@ -830,7 +830,7 @@ void DMEngine::openEntranceDoors() {
 									   kM1_ColorNoTransparency, 161, k200_heightScreen);
 		_displayMan->f132_blitToBitmap(rightDoorBitmap, _displayMan->_g348_bitmapScreen, rightDoorBox, 0, 0, 64, k160_byteWidthScreen,
 									   kM1_ColorNoTransparency, 161, k200_heightScreen);
-		_eventMan->f357_discardAllInput();
+		_eventMan->discardAllInput();
 		_displayMan->updateScreen();
 
 		leftDoorBox._x2 -= 4;
@@ -922,12 +922,12 @@ void DMEngine::drawTittle() {
 }
 
 void DMEngine::entranceDrawCredits() {
-	_eventMan->f78_showMouse();
+	_eventMan->showMouse();
 	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
 	_displayMan->f466_loadIntoBitmap(k5_creditsGraphicIndice, _displayMan->_g348_bitmapScreen);
 	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_palCredits);
 	delay(50);
-	_eventMan->f541_waitForMouseOrKeyActivity();
+	_eventMan->waitForMouseOrKeyActivity();
 	_newGameFl = k202_modeEntranceDrawCredits;
 }
 
@@ -963,7 +963,7 @@ void DMEngine::fuseSequnce() {
 	if (_inventoryMan->_g432_inventoryChampionOrdinal) {
 		_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
 	}
-	_eventMan->f363_highlightBoxDisable();
+	_eventMan->highlightBoxDisable();
 	_championMan->_party._magicalLightAmount = 200;
 	_inventoryMan->f337_setDungeonViewPalette();
 	_championMan->_party._fireShieldDefense = _championMan->_party._spellShieldDefense = _championMan->_party._shieldDefense = 100;
@@ -1074,7 +1074,7 @@ void DMEngine::fuseSequenceUpdate() {
 	_timeline->f261_processTimeline();
 	_displayMan->f128_drawDungeon(_dungeonMan->_partyDir, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
 	_sound->f65_playPendingSound();
-	_eventMan->f357_discardAllInput();
+	_eventMan->discardAllInput();
 	_displayMan->updateScreen();
 	delay(2);
 	_gameTime++; /* BUG0_71 Some timings are too short on fast computers.
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index b5dfccc..77a9b5b 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -369,53 +369,53 @@ void EventManager::initArrays() {
 EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 	_mousePos = Common::Point(0, 0);
 	_dummyMapIndex = 0;
-	_g436_pendingClickPresent = false;
-	_g437_pendingClickPos = Common::Point(0, 0);
-	_g615_mousePointerOriginalColorsObject = nullptr;
-	_g613_mousePointerOriginalColorsChampionIcon = nullptr;
-	_gK190_mousePointerTempBuffer = nullptr;
-	_g435_isCommandQueueLocked = true;
-	_gK104_mousePointerType = 0;
-	_gK105_previousMousePointerType = 0;
-	_g441_primaryMouseInput = nullptr;
-	_g442_secondaryMouseInput = nullptr;
-	_g598_mousePointerBitmapUpdated = true;
-	_g326_refreshMousePointerInMainLoop = false;
-	_g341_highlightBoxEnabled = false;
-	_g599_useChampionIconOrdinalAsMousePointerBitmap = 0;
-	_g439_pendingClickButton = k0_NoneMouseButton;
-	_g600_useObjectAsMousePointerBitmap = false;
-	_g601_useHandAsMousePointerBitmap = false;
-	_gK100_preventBuildPointerScreenArea = false;
-	_g443_primaryKeyboardInput = nullptr;
-	_g444_secondaryKeyboardInput = nullptr;
-	_g597_ignoreMouseMovements = false;
+	_pendingClickPresent = false;
+	_pendingClickPos = Common::Point(0, 0);
+	_mousePointerOriginalColorsObject = nullptr;
+	_mousePointerOriginalColorsChampionIcon = nullptr;
+	_mousePointerTempBuffer = nullptr;
+	_isCommandQueueLocked = true;
+	_mousePointerType = 0;
+	_previousMousePointerType = 0;
+	_primaryMouseInput = nullptr;
+	_secondaryMouseInput = nullptr;
+	_mousePointerBitmapUpdated = true;
+	_refreshMousePointerInMainLoop = false;
+	_highlightBoxEnabled = false;
+	_useChampionIconOrdinalAsMousePointerBitmap = 0;
+	_pendingClickButton = k0_NoneMouseButton;
+	_useObjectAsMousePointerBitmap = false;
+	_useHandAsMousePointerBitmap = false;
+	_preventBuildPointerScreenArea = false;
+	_primaryKeyboardInput = nullptr;
+	_secondaryKeyboardInput = nullptr;
+	_ignoreMouseMovements = false;
 	warning(false, "_g587_hideMousePointerRequestCount should start with value 1");
-	_g587_hideMousePointerRequestCount = 0;
-	_g558_mouseButtonStatus = 0;
+	_hideMousePointerRequestCount = 0;
+	_mouseButtonStatus = 0;
 	_highlightScreenBox.setToZero();
 
 	initArrays();
 }
 
 EventManager::~EventManager() {
-	delete[] _g615_mousePointerOriginalColorsObject;
-	delete[] _gK190_mousePointerTempBuffer;
-	delete[] _g613_mousePointerOriginalColorsChampionIcon;
+	delete[] _mousePointerOriginalColorsObject;
+	delete[] _mousePointerTempBuffer;
+	delete[] _mousePointerOriginalColorsChampionIcon;
 }
 
 void EventManager::initMouse() {
 	static uint16 gK150_PalMousePointer[16] = {0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x000, 0xAAA, 0x00F, 0xFFF}; // @ K0150_aui_Palette_MousePointer
 
-	if (!_g615_mousePointerOriginalColorsObject)
-		_g615_mousePointerOriginalColorsObject = new byte[32 * 18];
-	if (!_gK190_mousePointerTempBuffer)
-		_gK190_mousePointerTempBuffer = new byte[32 * 18];
-	if (!_g613_mousePointerOriginalColorsChampionIcon)
-		_g613_mousePointerOriginalColorsChampionIcon = new byte[32 * 18];
+	if (!_mousePointerOriginalColorsObject)
+		_mousePointerOriginalColorsObject = new byte[32 * 18];
+	if (!_mousePointerTempBuffer)
+		_mousePointerTempBuffer = new byte[32 * 18];
+	if (!_mousePointerOriginalColorsChampionIcon)
+		_mousePointerOriginalColorsChampionIcon = new byte[32 * 18];
 
-	_gK104_mousePointerType = k0_pointerArrow;
-	_gK105_previousMousePointerType = k1_pointerHand;
+	_mousePointerType = k0_pointerArrow;
+	_previousMousePointerType = k1_pointerHand;
 
 	byte mousePalette[16 * 3];
 	for (int i = 0; i < 16; ++i) {
@@ -426,22 +426,22 @@ void EventManager::initMouse() {
 	CursorMan.pushCursorPalette(mousePalette, 0, 16);
 
 	_mousePos = Common::Point(0, 0);
-	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
+	buildpointerScreenArea(_mousePos.x, _mousePos.y);
 	CursorMan.showMouse(false);
 
 	setMousePos(Common::Point(320 / 2, 200 / 2));
 }
 
-void EventManager::f67_setMousePointerToNormal(int16 mousePointer) {
-	_gK100_preventBuildPointerScreenArea = true;
-	_g600_useObjectAsMousePointerBitmap = false;
-	_g601_useHandAsMousePointerBitmap = (mousePointer == k1_pointerHand);
-	_g598_mousePointerBitmapUpdated = true;
-	_gK100_preventBuildPointerScreenArea = false;
-	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
+void EventManager::setMousePointerToNormal(int16 mousePointer) {
+	_preventBuildPointerScreenArea = true;
+	_useObjectAsMousePointerBitmap = false;
+	_useHandAsMousePointerBitmap = (mousePointer == k1_pointerHand);
+	_mousePointerBitmapUpdated = true;
+	_preventBuildPointerScreenArea = false;
+	buildpointerScreenArea(_mousePos.x, _mousePos.y);
 }
 
-void EventManager::f68_setPointerToObject(byte* bitmap) {
+void EventManager::setPointerToObject(byte* bitmap) {
 	static byte palChangesMousepointerOjbectIconShadow[16] = {120, 120, 120, 120, 120, 120, 120, 120,
 		120, 120, 120, 120, 0, 120, 120, 120}; // @ K0027_auc_PaletteChanges_MousePointerObjectIconShadow
 	static byte palChangesMousePointerIcon[16] = {120, 10, 20, 30, 40, 50, 60, 70, 80, 90,
@@ -449,35 +449,35 @@ void EventManager::f68_setPointerToObject(byte* bitmap) {
 	static Box boxMousePointerObjectShadow(2, 17, 2, 17); // @ G0619_s_Box_MousePointer_ObjectShadow 
 	static Box boxMousePointerObject(0, 15, 0, 15); // @ G0620_s_Box_MousePointer_Object 
 
-	_gK100_preventBuildPointerScreenArea = true;
-	_g600_useObjectAsMousePointerBitmap = true;
-	_g601_useHandAsMousePointerBitmap = false;
-	_g598_mousePointerBitmapUpdated = true;
+	_preventBuildPointerScreenArea = true;
+	_useObjectAsMousePointerBitmap = true;
+	_useHandAsMousePointerBitmap = false;
+	_mousePointerBitmapUpdated = true;
 	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
-	byte *L0051_puc_Bitmap = _g615_mousePointerOriginalColorsObject;
+	byte *L0051_puc_Bitmap = _mousePointerOriginalColorsObject;
 	memset(L0051_puc_Bitmap, 0, 32 * 18);
 
-	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, palChangesMousepointerOjbectIconShadow);
-	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, boxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
-	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, palChangesMousePointerIcon);
-	_vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, boxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
+	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _mousePointerTempBuffer, 16, 16, 16, 16, palChangesMousepointerOjbectIconShadow);
+	_vm->_displayMan->f132_blitToBitmap(_mousePointerTempBuffer, L0051_puc_Bitmap, boxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
+	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _mousePointerTempBuffer, 16, 16, 16, 16, palChangesMousePointerIcon);
+	_vm->_displayMan->f132_blitToBitmap(_mousePointerTempBuffer, L0051_puc_Bitmap, boxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
 
-	_gK100_preventBuildPointerScreenArea = false;
-	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
+	_preventBuildPointerScreenArea = false;
+	buildpointerScreenArea(_mousePos.x, _mousePos.y);
 }
 
-void EventManager::f71_mouseDropChampionIcon() {
-	_gK100_preventBuildPointerScreenArea = true;
-	uint16 championIconIndex = _vm->ordinalToIndex(_g599_useChampionIconOrdinalAsMousePointerBitmap);
-	_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kM1_ChampionNone);
-	_g598_mousePointerBitmapUpdated = true;
+void EventManager::mouseDropChampionIcon() {
+	_preventBuildPointerScreenArea = true;
+	uint16 championIconIndex = _vm->ordinalToIndex(_useChampionIconOrdinalAsMousePointerBitmap);
+	_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kM1_ChampionNone);
+	_mousePointerBitmapUpdated = true;
 	bool useByteBoxCoordinatesBackup = _vm->_displayMan->_g578_useByteBoxCoordinates;
-	_vm->_displayMan->f21_blitToScreen(_g613_mousePointerOriginalColorsChampionIcon, &_vm->_championMan->_boxChampionIcons[championIconIndex << 2], 16, k12_ColorDarkestGray, 18);
+	_vm->_displayMan->f21_blitToScreen(_mousePointerOriginalColorsChampionIcon, &_vm->_championMan->_boxChampionIcons[championIconIndex << 2], 16, k12_ColorDarkestGray, 18);
 	_vm->_displayMan->_g578_useByteBoxCoordinates = useByteBoxCoordinatesBackup;
-	_gK100_preventBuildPointerScreenArea = false;
+	_preventBuildPointerScreenArea = false;
 }
 
-void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY) {
+void EventManager::buildpointerScreenArea(int16 mousePosX, int16 mousePosY) {
 	static unsigned char bitmapArrowPointer[288] = { // @ G0042_auc_Graphic562_Bitmap_ArrowPointer
 		0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
 		0x78, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00,
@@ -519,81 +519,81 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY)
 		0x07, 0xFF, 0x00, 0x00, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 	};
 
-	_gK100_preventBuildPointerScreenArea = true;
-	if (_g599_useChampionIconOrdinalAsMousePointerBitmap) {
+	_preventBuildPointerScreenArea = true;
+	if (_useChampionIconOrdinalAsMousePointerBitmap) {
 		if ((mousePosY > 28) || (mousePosX < 274)) {
-			_gK104_mousePointerType = k4_pointerTypeAutoselect;
-			f71_mouseDropChampionIcon();
+			_mousePointerType = k4_pointerTypeAutoselect;
+			mouseDropChampionIcon();
 		} else
-			_gK104_mousePointerType = k2_pointerTypeChampionIcon;
+			_mousePointerType = k2_pointerTypeChampionIcon;
 	} else if (mousePosY >= 169)
-		_gK104_mousePointerType = k0_pointerTypeArrow;
+		_mousePointerType = k0_pointerTypeArrow;
 	else if (mousePosX >= 274)
-		_gK104_mousePointerType = k0_pointerTypeArrow;
+		_mousePointerType = k0_pointerTypeArrow;
 	else if (mousePosY <= 28) {
 		uint16 championIdx = mousePosX / 69;
 		uint16 xOverChampionStatusBox = mousePosX % 69;
 		if (championIdx >= _vm->_championMan->_partyChampionCount)
-			_gK104_mousePointerType = k4_pointerTypeAutoselect;
+			_mousePointerType = k4_pointerTypeAutoselect;
 		else if (xOverChampionStatusBox > 42)
-			_gK104_mousePointerType = k4_pointerTypeAutoselect;
+			_mousePointerType = k4_pointerTypeAutoselect;
 		else {
 			championIdx++;
 			if (championIdx == _vm->_inventoryMan->_g432_inventoryChampionOrdinal)
-				_gK104_mousePointerType = k0_pointerTypeArrow;
+				_mousePointerType = k0_pointerTypeArrow;
 			else if (mousePosY <= 6)
-				_gK104_mousePointerType = k0_pointerTypeArrow;
+				_mousePointerType = k0_pointerTypeArrow;
 			else
-				_gK104_mousePointerType = k4_pointerTypeAutoselect;
+				_mousePointerType = k4_pointerTypeAutoselect;
 		}
 	} else if (mousePosX >= 224)
-		_gK104_mousePointerType = k0_pointerTypeArrow;
+		_mousePointerType = k0_pointerTypeArrow;
 	else
-		_gK104_mousePointerType = k4_pointerTypeAutoselect;
+		_mousePointerType = k4_pointerTypeAutoselect;
 
-	if (_gK104_mousePointerType == k4_pointerTypeAutoselect)
-		_gK104_mousePointerType = (_g600_useObjectAsMousePointerBitmap) ? k1_pointerTypeObjectIcon : (_g601_useHandAsMousePointerBitmap) ? k3_pointerTypeHand : k0_pointerTypeArrow;
+	if (_mousePointerType == k4_pointerTypeAutoselect)
+		_mousePointerType = (_useObjectAsMousePointerBitmap) ? k1_pointerTypeObjectIcon : (_useHandAsMousePointerBitmap) ? k3_pointerTypeHand : k0_pointerTypeArrow;
 
-	if (_g598_mousePointerBitmapUpdated || (_gK104_mousePointerType != _gK105_previousMousePointerType)) {
-		_g598_mousePointerBitmapUpdated = false;
-		switch (_gK104_mousePointerType) {
+	if (_mousePointerBitmapUpdated || (_mousePointerType != _previousMousePointerType)) {
+		_mousePointerBitmapUpdated = false;
+		switch (_mousePointerType) {
 		case k0_pointerTypeArrow:
 			setMousePointerFromSpriteData(bitmapArrowPointer);
 			break;
 		case k1_pointerTypeObjectIcon:
-			CursorMan.replaceCursor(_g615_mousePointerOriginalColorsObject, 32, 18, 0, 0, 0);
+			CursorMan.replaceCursor(_mousePointerOriginalColorsObject, 32, 18, 0, 0, 0);
 			break;
 		case k2_pointerTypeChampionIcon:
-			CursorMan.replaceCursor(_g613_mousePointerOriginalColorsChampionIcon, 32, 18, 0, 0, 0);
+			CursorMan.replaceCursor(_mousePointerOriginalColorsChampionIcon, 32, 18, 0, 0, 0);
 			break;
 		case k3_pointerTypeHand:
 			setMousePointerFromSpriteData(bitmapHanPointer);
 			break;
 		}
 	}
-	_gK105_previousMousePointerType = _gK104_mousePointerType;
-	_gK100_preventBuildPointerScreenArea = false;
+	_previousMousePointerType = _mousePointerType;
+	_preventBuildPointerScreenArea = false;
 }
 
-void EventManager::f69_setMousePointer() {
+void EventManager::setMousePointer() {
 	if (_vm->_championMan->_leaderEmptyHanded)
-		f67_setMousePointerToNormal((_vm->_championMan->_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
+		setMousePointerToNormal((_vm->_championMan->_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
 	else
-		f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
+		setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
 }
 
-void EventManager::f78_showMouse() {
-	if (_g587_hideMousePointerRequestCount++ == 0)
+void EventManager::showMouse() {
+	if (_hideMousePointerRequestCount++ == 0)
 		CursorMan.showMouse(true);
 }
 
-void EventManager::f77_hideMouse() {
-	if (_g587_hideMousePointerRequestCount-- == 1)
+void EventManager::hideMouse() {
+	if (_hideMousePointerRequestCount-- == 1)
 		CursorMan.showMouse(false);
 }
 
 bool EventManager::isMouseButtonDown(MouseButton button) {
-	return (button != k0_NoneMouseButton) ? (_g558_mouseButtonStatus & button) : (_g558_mouseButtonStatus == 0);
+	return (button != k0_NoneMouseButton) ? (_mouseButtonStatus & button) : (_mouseButtonStatus == 0);
 }
 
 void EventManager::setMousePos(Common::Point pos) {
@@ -618,11 +618,11 @@ Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Eve
 				return event.type;
 			}
 
-			if (_g443_primaryKeyboardInput) {
-				KeyboardInput *input = _g443_primaryKeyboardInput;
+			if (_primaryKeyboardInput) {
+				KeyboardInput *input = _primaryKeyboardInput;
 				while (input->_commandToIssue != k0_CommandNone) {
 					if ((input->_key == event.kbd.keycode) && (input->_modifiers == (event.kbd.flags & input->_modifiers))) {
-						f360_processPendingClick(); // possible fix to BUG0_73
+						processPendingClick(); // possible fix to BUG0_73
 						_commandQueue.push(Command(Common::Point(-1, -1), input->_commandToIssue));
 						break;
 					}
@@ -630,11 +630,11 @@ Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Eve
 				}
 			}
 
-			if (_g444_secondaryKeyboardInput) {
-				KeyboardInput *input = _g444_secondaryKeyboardInput;
+			if (_secondaryKeyboardInput) {
+				KeyboardInput *input = _secondaryKeyboardInput;
 				while (input->_commandToIssue != k0_CommandNone) {
 					if ((input->_key == event.kbd.keycode) && (input->_modifiers == (event.kbd.flags & input->_modifiers))) {
-						f360_processPendingClick(); // possible fix to BUG0_73
+						processPendingClick(); // possible fix to BUG0_73
 						_commandQueue.push(Command(Common::Point(-1, -1), input->_commandToIssue));
 						break;
 					}
@@ -644,27 +644,27 @@ Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Eve
 			break;
 		}
 		case Common::EVENT_MOUSEMOVE:
-			if (!_g597_ignoreMouseMovements)
+			if (!_ignoreMouseMovements)
 				_mousePos = event.mouse;
 			break;
 		case Common::EVENT_LBUTTONDOWN:
 		case Common::EVENT_RBUTTONDOWN: {
 			MouseButton button = (event.type == Common::EVENT_LBUTTONDOWN) ? k1_LeftMouseButton : k2_RightMouseButton;
-			_g558_mouseButtonStatus |= button;
+			_mouseButtonStatus |= button;
 			if (grabMouseClick) {
 				*grabMouseClick = event;
 				return event.type;
 			}
-			_g436_pendingClickPresent = true;
-			_g437_pendingClickPos = _mousePos;
-			_g439_pendingClickButton = button;
+			_pendingClickPresent = true;
+			_pendingClickPos = _mousePos;
+			_pendingClickButton = button;
 			break;
 		}
 		case Common::EVENT_LBUTTONUP:
 		case Common::EVENT_RBUTTONUP: {
 			MouseButton button = (event.type == Common::EVENT_LBUTTONDOWN) ? k1_LeftMouseButton : k2_RightMouseButton;
-			_g558_mouseButtonStatus &= ~button;
-			f544_resetPressingEyeOrMouth();
+			_mouseButtonStatus &= ~button;
+			resetPressingEyeOrMouth();
 			break;
 		}
 		case Common::EVENT_QUIT:
@@ -674,33 +674,33 @@ Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Eve
 			break;
 		}
 	}
-	if (_g597_ignoreMouseMovements)
+	if (_ignoreMouseMovements)
 		setMousePos(_mousePos);
 	return Common::EVENT_INVALID;
 }
 
 
-void EventManager::f360_processPendingClick() {
-	if (_g436_pendingClickPresent) {
-		_g436_pendingClickPresent = false;
-		f359_processClick(_g437_pendingClickPos, _g439_pendingClickButton);
+void EventManager::processPendingClick() {
+	if (_pendingClickPresent) {
+		_pendingClickPresent = false;
+		processClick(_pendingClickPos, _pendingClickButton);
 	}
 }
 
-void EventManager::f359_processClick(Common::Point mousePos, MouseButton button) {
+void EventManager::processClick(Common::Point mousePos, MouseButton button) {
 	CommandType commandType;
 
-	commandType = f358_getCommandTypeFromMouseInput(_g441_primaryMouseInput, mousePos, button);
+	commandType = getCommandTypeFromMouseInput(_primaryMouseInput, mousePos, button);
 	if (commandType == k0_CommandNone)
-		commandType = f358_getCommandTypeFromMouseInput(_g442_secondaryMouseInput, mousePos, button);
+		commandType = getCommandTypeFromMouseInput(_secondaryMouseInput, mousePos, button);
 
 	if (commandType != k0_CommandNone)
 		_commandQueue.push(Command(mousePos, commandType));
 
-	_g435_isCommandQueueLocked = false;
+	_isCommandQueueLocked = false;
 }
 
-CommandType EventManager::f358_getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button) {
+CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button) {
 	if (!input)
 		return k0_CommandNone;
 
@@ -713,51 +713,51 @@ CommandType EventManager::f358_getCommandTypeFromMouseInput(MouseInput *input, C
 	return commandType;
 }
 
-void EventManager::f380_processCommandQueue() {
+void EventManager::processCommandQueue() {
 	static KeyboardInput *primaryKeyboardInputBackup;
 	static KeyboardInput *secondaryKeyboardInputBackup;
 	static MouseInput *primaryMouseInputBackup;
 	static MouseInput *secondaryMouseInputBackup;
 
-	_g435_isCommandQueueLocked = true;
+	_isCommandQueueLocked = true;
 	if (_commandQueue.empty()) { /* If the command queue is empty */
-		_g435_isCommandQueueLocked = false;
-		f360_processPendingClick();
+		_isCommandQueueLocked = false;
+		processPendingClick();
 		return;
 	}
 
 	Command cmd = _commandQueue.pop();
 	CommandType cmdType = cmd._type;
 	if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft) && (_vm->_disabledMovementTicks || (_vm->_projectileDisableMovementTicks && (_vm->_lastProjectileDisabledMovementDirection == (normalizeModulo4(_vm->_dungeonMan->_partyDir + cmdType - k3_CommandMoveForward)))))) { /* If movement is disabled */
-		_g435_isCommandQueueLocked = false;
-		f360_processPendingClick();
+		_isCommandQueueLocked = false;
+		processPendingClick();
 		return;
 	}
 
 	int16 commandX = cmd._pos.x;
 	int16 commandY = cmd._pos.y;
-	_g435_isCommandQueueLocked = false;
-	f360_processPendingClick();
+	_isCommandQueueLocked = false;
+	processPendingClick();
 	if ((cmdType == k2_CommandTurnRight) || (cmdType == k1_CommandTurnLeft)) {
-		f365_commandTurnParty(cmdType);
+		commandTurnParty(cmdType);
 		return;
 	}
 
 	if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft)) {
-		f366_commandMoveParty(cmdType);
+		commandMoveParty(cmdType);
 		return;
 	}
 
 	if ((cmdType >= k12_CommandClickInChampion_0_StatusBox) && (cmdType <= k15_CommandClickInChampion_3_StatusBox)) {
 		int16 championIdx = cmdType - k12_CommandClickInChampion_0_StatusBox;
 		if ((championIdx < _vm->_championMan->_partyChampionCount) && !_vm->_championMan->_candidateChampionOrdinal)
-			f367_commandProcessTypes12to27_clickInChampionStatusBox(championIdx, commandX, commandY);
+			commandProcessTypes12to27_clickInChampionStatusBox(championIdx, commandX, commandY);
 
 		return;
 	}
 
 	if ((cmdType >= k125_CommandClickOnChamptionIcon_Top_Left) && (cmdType <= k128_CommandClickOnChamptionIcon_Lower_Left)) {
-		f70_mouseProcessCommands125To128_clickOnChampionIcon(cmdType - k125_CommandClickOnChamptionIcon_Top_Left);
+		mouseProcessCommands125To128_clickOnChampionIcon(cmdType - k125_CommandClickOnChamptionIcon_Top_Left);
 
 		return;
 	}
@@ -794,14 +794,14 @@ void EventManager::f380_processCommandQueue() {
 
 	if (cmdType == k100_CommandClickInSpellArea) {
 		if ((!_vm->_championMan->_candidateChampionOrdinal) && (_vm->_championMan->_magicCasterChampionIndex != kM1_ChampionNone))
-			f370_commandProcessType100_clickInSpellArea(commandX, commandY);
+			commandProcessType100_clickInSpellArea(commandX, commandY);
 
 		return;
 	}
 
 	if (cmdType == k111_CommandClickInActionArea) {
 		if (!_vm->_championMan->_candidateChampionOrdinal)
-			f371_commandProcessType111To115_ClickInActionArea(commandX, commandY);
+			commandProcessType111To115_ClickInActionArea(commandX, commandY);
 
 		return;
 	}
@@ -817,11 +817,11 @@ void EventManager::f380_processCommandQueue() {
 	}
 
 	if (cmdType == k80_CommandClickInDungeonView) {
-		f377_commandProcessType80ClickInDungeonView(commandX, commandY);
+		commandProcessType80ClickInDungeonView(commandX, commandY);
 		return;
 	}
 	if (cmdType == k81_CommandClickInPanel) {
-		f378_commandProcess81ClickInPanel(commandX, commandY);
+		commandProcess81ClickInPanel(commandX, commandY);
 		return;
 	}
 
@@ -835,14 +835,14 @@ void EventManager::f380_processCommandQueue() {
 
 			_vm->_menuMan->f456_drawDisabledMenu();
 			_vm->_championMan->_partyIsSleeping = true;
-			f379_drawSleepScreen();
+			drawSleepScreen();
 			_vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
 			_vm->_waitForInputMaxVerticalBlankCount = 0;
-			_g441_primaryMouseInput = _primaryMouseInputPartySleeping;
-			_g442_secondaryMouseInput = 0;
-			_g443_primaryKeyboardInput = _primaryKeyboardInputPartySleeping;
-			_g444_secondaryKeyboardInput = nullptr;
-			f357_discardAllInput();
+			_primaryMouseInput = _primaryMouseInputPartySleeping;
+			_secondaryMouseInput = 0;
+			_primaryKeyboardInput = _primaryKeyboardInputPartySleeping;
+			_secondaryKeyboardInput = nullptr;
+			discardAllInput();
 		}
 		return;
 	}
@@ -880,26 +880,26 @@ void EventManager::f380_processCommandQueue() {
 			break;
 		}
 		_vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
-		primaryMouseInputBackup = _g441_primaryMouseInput;
-		secondaryMouseInputBackup = _g442_secondaryMouseInput;
-		primaryKeyboardInputBackup = _g443_primaryKeyboardInput;
-		secondaryKeyboardInputBackup = _g444_secondaryKeyboardInput;
-		_g441_primaryMouseInput = _primaryMouseInputFrozenGame;
-		_g442_secondaryMouseInput = 0;
-		_g443_primaryKeyboardInput = _primaryKeyboardInputFrozenGame;
-		_g444_secondaryKeyboardInput = nullptr;
-		f357_discardAllInput();
+		primaryMouseInputBackup = _primaryMouseInput;
+		secondaryMouseInputBackup = _secondaryMouseInput;
+		primaryKeyboardInputBackup = _primaryKeyboardInput;
+		secondaryKeyboardInputBackup = _secondaryKeyboardInput;
+		_primaryMouseInput = _primaryMouseInputFrozenGame;
+		_secondaryMouseInput = 0;
+		_primaryKeyboardInput = _primaryKeyboardInputFrozenGame;
+		_secondaryKeyboardInput = nullptr;
+		discardAllInput();
 		return;
 	}
 
 	if (cmdType == k148_CommandUnfreezeGame) {
 		_vm->_gameTimeTicking = true;
 		_vm->_menuMan->f457_drawEnabledMenus();
-		_g441_primaryMouseInput = primaryMouseInputBackup;
-		_g442_secondaryMouseInput = secondaryMouseInputBackup;
-		_g443_primaryKeyboardInput = primaryKeyboardInputBackup;
-		_g444_secondaryKeyboardInput = secondaryKeyboardInputBackup;
-		f357_discardAllInput();
+		_primaryMouseInput = primaryMouseInputBackup;
+		_secondaryMouseInput = secondaryMouseInputBackup;
+		_primaryKeyboardInput = primaryKeyboardInputBackup;
+		_secondaryKeyboardInput = secondaryKeyboardInputBackup;
+		discardAllInput();
 		return;
 	}
 
@@ -927,16 +927,16 @@ void EventManager::f380_processCommandQueue() {
 		_vm->_restartGameRequest = true;
 }
 
-void EventManager::f365_commandTurnParty(CommandType cmdType) {
+void EventManager::commandTurnParty(CommandType cmdType) {
 	_vm->_stopWaitingForPlayerInput = true;
 	if (cmdType == k1_CommandTurnLeft)
-		f362_commandHighlightBoxEnable(234, 261, 125, 145);
+		commandHighlightBoxEnable(234, 261, 125, 145);
 	else
-		f362_commandHighlightBoxEnable(291, 318, 125, 145);
+		commandHighlightBoxEnable(291, 318, 125, 145);
 
 	uint16 partySquare = _vm->_dungeonMan->getSquare(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY).toByte();
 	if (Square(partySquare).getType() == k3_StairsElemType) {
-		f364_commandTakeStairs(getFlag(partySquare, k0x0004_StairsUp));
+		commandTakeStairs(getFlag(partySquare, k0x0004_StairsUp));
 		return;
 	}
 
@@ -945,7 +945,7 @@ void EventManager::f365_commandTurnParty(CommandType cmdType) {
 	_vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, Thing::_party, true, true);
 }
 
-void EventManager::f366_commandMoveParty(CommandType cmdType) {
+void EventManager::commandMoveParty(CommandType cmdType) {
 	static Box boxMovementArrows[4] = { // @ G0463_as_Graphic561_Box_MovementArrows
 		/* { X1, X2, Y1, Y2 } */
 		Box(263, 289, 125, 145),   /* Forward */
@@ -976,13 +976,13 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	}
 	uint16 movementArrowIdx = cmdType - k3_CommandMoveForward;
 	Box *highlightBox = &boxMovementArrows[movementArrowIdx];
-	f362_commandHighlightBoxEnable(highlightBox->_x1, highlightBox->_x2, highlightBox->_y1, highlightBox->_y2);
+	commandHighlightBoxEnable(highlightBox->_x1, highlightBox->_x2, highlightBox->_y1, highlightBox->_y2);
 	int16 partyMapX = _vm->_dungeonMan->_partyMapX;
 	int16 partyMapY = _vm->_dungeonMan->_partyMapY;
 	uint16 AL1115_ui_Square = _vm->_dungeonMan->getSquare(partyMapX, partyMapY).toByte();
 	bool isStairsSquare = (Square(AL1115_ui_Square).getType() == k3_StairsElemType);
 	if (isStairsSquare && (movementArrowIdx == 2)) { /* If moving backward while in stairs */
-		f364_commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp));
+		commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp));
 		return;
 	}
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(_vm->_dungeonMan->_partyDir, movementArrowToStepForwardCount[movementArrowIdx], movementArrowToSepRightCount[movementArrowIdx], partyMapX, partyMapY);
@@ -991,7 +991,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kM1_MapXNotOnASquare, 0);
 		_vm->_dungeonMan->_partyMapX = partyMapX;
 		_vm->_dungeonMan->_partyMapY = partyMapY;
-		f364_commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp));
+		commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp));
 		return;
 	}
 
@@ -1024,7 +1024,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 
 	// DEBUG CODE: check for Console flag
 	if (isMovementBlocked && !_vm->_console->_debugNoclip) {
-		f357_discardAllInput();
+		discardAllInput();
 		_vm->_stopWaitingForPlayerInput = false;
 		return;
 	}
@@ -1046,7 +1046,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
 	_vm->_projectileDisableMovementTicks = 0;
 }
 
-bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int16 posX, int16 posY) {
+bool EventManager::isLeaderHandObjThrown(int16 posX, int16 posY) {
 #define k0_sideLeft 0 // @ C0_SIDE_LEFT 
 #define k1_sideRight 1 // @ C0_SIDE_LEFT 
 
@@ -1101,7 +1101,7 @@ void EventManager::setMousePointerFromSpriteData(byte* mouseSprite) {
 	CursorMan.replaceCursor(bitmap, 16, 18, 0, 0, 0);
 }
 
-void EventManager::f368_commandSetLeader(ChampionIndex champIndex) {
+void EventManager::commandSetLeader(ChampionIndex champIndex) {
 	ChampionMan &cm = *_vm->_championMan;
 	ChampionIndex leaderIndex;
 
@@ -1131,7 +1131,7 @@ void EventManager::f368_commandSetLeader(ChampionIndex champIndex) {
 	}
 }
 
-void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() {
+void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() {
 	uint16 mapX = _vm->_dungeonMan->_partyMapX + _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir];
 	uint16 mapY = _vm->_dungeonMan->_partyMapY + _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
 
@@ -1140,7 +1140,7 @@ void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() {
 		_vm->_stopWaitingForPlayerInput = _vm->_moveSens->f275_sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(_vm->_dungeonMan->_partyDir));
 }
 
-void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16 posY) {
+void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY) {
 	Box boxObjectPiles[4] = { // @ G0462_as_Graphic561_Box_ObjectPiles
 		/* { X1, X2, Y1, Y2 } */
 		Box(24, 111, 148, 168),   /* Front left */
@@ -1164,7 +1164,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 				_vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_gameTime + 1);
 				return;
 			}
-		} else if (f375_processType80_clickDungeonView_isLeaderHandObjThrown(posX, posY))
+		} else if (isLeaderHandObjThrown(posX, posY))
 			return;
 	}
 
@@ -1173,9 +1173,9 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 			if (_vm->_dungeonMan->_dungeonViewClickableBoxes[currViewCell].isPointInside(posX, posY - 33)) {
 				if (currViewCell == k5_ViewCellDoorButtonOrWallOrn) {
 					if (!_vm->_dungeonMan->_isFacingAlcove)
-						f372_commandProcessType80ClickInDungeonViewTouchFrontWall();
+						commandProcessType80ClickInDungeonViewTouchFrontWall();
 				} else
-					f373_processType80_clickInDungeonView_grabLeaderHandObject(currViewCell);
+					processType80_clickInDungeonView_grabLeaderHandObject(currViewCell);
 
 				return;
 			}
@@ -1186,13 +1186,13 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 		if (_vm->_dungeonMan->_squareAheadElement == k0_ElementTypeWall) {
 			for (uint16 currViewCell = k0_ViewCellFronLeft; currViewCell < k1_ViewCellFrontRight + 1; currViewCell++) {
 				if (boxObjectPiles[currViewCell].isPointInside(posX, posY)) {
-					f374_processType80_clickInDungeonViewDropLeaderHandObject(currViewCell);
+					processType80_clickInDungeonViewDropLeaderHandObject(currViewCell);
 					return;
 				}
 			}
 			if (_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
 				if (_vm->_dungeonMan->_isFacingAlcove)
-					f374_processType80_clickInDungeonViewDropLeaderHandObject(k4_ViewCellAlcove);
+					processType80_clickInDungeonViewDropLeaderHandObject(k4_ViewCellAlcove);
 				else {
 					if (_vm->_dungeonMan->_isFacingFountain) {
 						uint16 iconIdx = _vm->_objectMan->f33_getIconIndex(thingHandObject);
@@ -1202,22 +1202,22 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 						else if (iconIdx == k195_IconIndicePotionEmptyFlask)
 							((Potion*)junkPtr)->setType(k15_PotionTypeWaterFlask);
 						else {
-							f372_commandProcessType80ClickInDungeonViewTouchFrontWall();
+							commandProcessType80ClickInDungeonViewTouchFrontWall();
 							return;
 						}
 						_vm->_championMan->drawChangedObjectIcons();
 						_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(thingHandObject) - weight;
 					}
-					f372_commandProcessType80ClickInDungeonViewTouchFrontWall();
+					commandProcessType80ClickInDungeonViewTouchFrontWall();
 				}
 			}
 		} else {
-			if (f375_processType80_clickDungeonView_isLeaderHandObjThrown(posX, posY))
+			if (isLeaderHandObjThrown(posX, posY))
 				return;
 
 			for (uint16 currViewCell = k0_ViewCellFronLeft; currViewCell < k3_ViewCellBackLeft + 1; currViewCell++) {
 				if (boxObjectPiles[currViewCell].isPointInside(posX, posY)) {
-					f374_processType80_clickInDungeonViewDropLeaderHandObject(currViewCell);
+					processType80_clickInDungeonViewDropLeaderHandObject(currViewCell);
 					return;
 				}
 			}
@@ -1225,7 +1225,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16
 	}
 }
 
-void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType) {
+void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType) {
 	ChampionMan &champMan = *_vm->_championMan;
 	InventoryMan &invMan = *_vm->_inventoryMan;
 	DisplayMan &dispMan = *_vm->_displayMan;
@@ -1237,7 +1237,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 		invMan.f355_toggleInventory(k4_ChampionCloseInventory);
 		champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 		if (champMan._partyChampionCount == 1) {
-			f368_commandSetLeader(kM1_ChampionNone);
+			commandSetLeader(kM1_ChampionNone);
 		}
 		champMan._partyChampionCount--;
 		Box box;
@@ -1249,7 +1249,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 		dispMan.D24_fillScreenBox(box, k0_ColorBlack);
 		dispMan.D24_fillScreenBox(_vm->_championMan->_boxChampionIcons[champMan.getChampionIconIndex(champ->_cell, dunMan._partyDir) * 2], k0_ColorBlack);
 		_vm->_menuMan->f457_drawEnabledMenus();
-		f78_showMouse();
+		showMouse();
 		return;
 	}
 
@@ -1287,7 +1287,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 
 	if (champMan._partyChampionCount == 1) {
 		_vm->_projexpl->_g362_lastPartyMovementTime = _vm->_gameTime;
-		f368_commandSetLeader(k0_ChampionFirst);
+		commandSetLeader(k0_ChampionFirst);
 		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(k0_ChampionFirst);
 	} else
 		_vm->_menuMan->f393_drawSpellAreaControls(champMan._magicCasterChampionIndex);
@@ -1311,10 +1311,10 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat
 
 	invMan.f355_toggleInventory(k4_ChampionCloseInventory);
 	_vm->_menuMan->f457_drawEnabledMenus();
-	f67_setMousePointerToNormal((_vm->_championMan->_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
+	setMousePointerToNormal((_vm->_championMan->_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
 }
 
-void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) {
+void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) {
 	ChampionMan &champMan = *_vm->_championMan;
 	InventoryMan &invMan = *_vm->_inventoryMan;
 
@@ -1323,23 +1323,23 @@ void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) {
 	case k4_PanelContentChest:
 		if (champMan._leaderIndex == kM1_ChampionNone) // if no leader
 			return;
-		commandType = f358_getCommandTypeFromMouseInput(_mouseInputPanelChest, Common::Point(x, y), k1_LeftMouseButton);
+		commandType = getCommandTypeFromMouseInput(_mouseInputPanelChest, Common::Point(x, y), k1_LeftMouseButton);
 		if (commandType != k0_CommandNone)
 			_vm->_championMan->clickOnSlotBox(commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
 		break;
 	case k5_PanelContentResurrectReincarnate:
 		if (!champMan._leaderEmptyHanded)
 			break;
-		commandType = f358_getCommandTypeFromMouseInput(_mouseInputPanelResurrectReincarnateCancel, Common::Point(x, y), k1_LeftMouseButton);
+		commandType = getCommandTypeFromMouseInput(_mouseInputPanelResurrectReincarnateCancel, Common::Point(x, y), k1_LeftMouseButton);
 		if (commandType != k0_CommandNone)
-			f282_commandProcessCommands160To162ClickInResurrectReincarnatePanel(commandType);
+			commandProcessCommands160To162ClickInResurrectReincarnatePanel(commandType);
 		break;
 	default:
 		break;
 	}
 }
 
-void EventManager::f373_processType80_clickInDungeonView_grabLeaderHandObject(uint16 viewCell) {
+void EventManager::processType80_clickInDungeonView_grabLeaderHandObject(uint16 viewCell) {
 	if (_vm->_championMan->_leaderIndex == kM1_ChampionNone)
 		return;
 
@@ -1364,7 +1364,7 @@ void EventManager::f373_processType80_clickInDungeonView_grabLeaderHandObject(ui
 	_vm->_stopWaitingForPlayerInput = true;
 }
 
-void EventManager::f374_processType80_clickInDungeonViewDropLeaderHandObject(uint16 viewCell) {
+void EventManager::processType80_clickInDungeonViewDropLeaderHandObject(uint16 viewCell) {
 	if (_vm->_championMan->_leaderIndex == kM1_ChampionNone)
 		return;
 
@@ -1395,14 +1395,14 @@ void EventManager::f374_processType80_clickInDungeonViewDropLeaderHandObject(uin
 	_vm->_stopWaitingForPlayerInput = true;
 }
 
-bool EventManager::f360_hasPendingClick(Common::Point& point, MouseButton button) {
-	if (_g439_pendingClickButton && button == _g439_pendingClickButton)
-		point = _g437_pendingClickPos;
+bool EventManager::hasPendingClick(Common::Point& point, MouseButton button) {
+	if (_pendingClickButton && button == _pendingClickButton)
+		point = _pendingClickPos;
 
-	return _g436_pendingClickPresent;
+	return _pendingClickPresent;
 }
 
-void EventManager::f379_drawSleepScreen() {
+void EventManager::drawSleepScreen() {
 	_vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 112, 136);
 	switch (_vm->getGameLanguage()) { // localized
 	default:
@@ -1418,7 +1418,7 @@ void EventManager::f379_drawSleepScreen() {
 	}
 }
 
-void EventManager::f357_discardAllInput() {
+void EventManager::discardAllInput() {
 	Common::Event event;
 	while (_vm->_system->getEventManager()->pollEvent(event) && !_vm->_engineShouldQuit) {
 		if (event.type == Common::EVENT_QUIT)
@@ -1427,7 +1427,7 @@ void EventManager::f357_discardAllInput() {
 	_commandQueue.clear();
 }
 
-void EventManager::f364_commandTakeStairs(bool stairsGoDown) {
+void EventManager::commandTakeStairs(bool stairsGoDown) {
 	_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kM1_MapXNotOnASquare, 0);
 	_vm->_newPartyMapIndex = _vm->_dungeonMan->getLocationAfterLevelChange(_vm->_dungeonMan->_partyMapIndex, stairsGoDown ? -1 : 1, &_vm->_dungeonMan->_partyMapX, &_vm->_dungeonMan->_partyMapY);
 	_vm->_dungeonMan->setCurrentMap(_vm->_newPartyMapIndex);
@@ -1435,45 +1435,45 @@ void EventManager::f364_commandTakeStairs(bool stairsGoDown) {
 	_vm->_dungeonMan->setCurrentMap(_vm->_dungeonMan->_partyMapIndex);
 }
 
-void EventManager::f367_commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX, int16 posY) {
+void EventManager::commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX, int16 posY) {
 	if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
-		f368_commandSetLeader((ChampionIndex)champIndex);
+		commandSetLeader((ChampionIndex)champIndex);
 	} else {
-		uint16 commandType = f358_getCommandTypeFromMouseInput(_mouseInputChampionNamesHands, Common::Point(posX, posY), k1_LeftMouseButton);
+		uint16 commandType = getCommandTypeFromMouseInput(_mouseInputChampionNamesHands, Common::Point(posX, posY), k1_LeftMouseButton);
 		if ((commandType >= k16_CommandSetLeaderChampion_0) && (commandType <= k19_CommandSetLeaderChampion_3))
-			f368_commandSetLeader((ChampionIndex)(commandType - k16_CommandSetLeaderChampion_0));
+			commandSetLeader((ChampionIndex)(commandType - k16_CommandSetLeaderChampion_0));
 		else if ((commandType >= k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand) && (commandType <= k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand))
 			_vm->_championMan->clickOnSlotBox(commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
 	}
 }
 
-void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex) {
+void EventManager::mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex) {
 	static Box championIconShadowBox = Box(2, 20, 2, 15);
 	static Box championIconBox = Box(0, 18, 0, 13);
 	static byte mousePointerIconShadowBox[16] = {0, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 0, 120, 120, 120};
 
-	_gK100_preventBuildPointerScreenArea = true;
-	if (!_g599_useChampionIconOrdinalAsMousePointerBitmap) {
+	_preventBuildPointerScreenArea = true;
+	if (!_useChampionIconOrdinalAsMousePointerBitmap) {
 		if (_vm->_championMan->getIndexInCell(normalizeModulo4(champIconIndex + _vm->_dungeonMan->_partyDir)) == kM1_ChampionNone) {
-			_gK100_preventBuildPointerScreenArea = false;
+			_preventBuildPointerScreenArea = false;
 			return;
 		}
-		_g598_mousePointerBitmapUpdated = true;
-		_g599_useChampionIconOrdinalAsMousePointerBitmap = true;
+		_mousePointerBitmapUpdated = true;
+		_useChampionIconOrdinalAsMousePointerBitmap = true;
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		byte *tmpBitmap = _gK190_mousePointerTempBuffer;
+		byte *tmpBitmap = _mousePointerTempBuffer;
 		memset(tmpBitmap, 0, 32 * 18);
 		Box *curChampionIconBox = &_vm->_championMan->_boxChampionIcons[champIconIndex];
 
 		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, tmpBitmap, championIconShadowBox, curChampionIconBox->_x1, curChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
-		_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(tmpBitmap, _g613_mousePointerOriginalColorsChampionIcon, 32, 18, 32, 18, mousePointerIconShadowBox);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, _g613_mousePointerOriginalColorsChampionIcon, championIconBox, curChampionIconBox->_x1, curChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
+		_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(tmpBitmap, _mousePointerOriginalColorsChampionIcon, 32, 18, 32, 18, mousePointerIconShadowBox);
+		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, _mousePointerOriginalColorsChampionIcon, championIconBox, curChampionIconBox->_x1, curChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
 		_vm->_displayMan->D24_fillScreenBox(*curChampionIconBox, k0_ColorBlack);
-		_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(champIconIndex);
+		_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(champIconIndex);
 	} else {
-		_g598_mousePointerBitmapUpdated = true;
-		uint16 championIconIndex = _vm->ordinalToIndex(_g599_useChampionIconOrdinalAsMousePointerBitmap);
-		_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kM1_ChampionNone);
+		_mousePointerBitmapUpdated = true;
+		uint16 championIconIndex = _vm->ordinalToIndex(_useChampionIconOrdinalAsMousePointerBitmap);
+		_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kM1_ChampionNone);
 		int16 championCellIndex = _vm->_championMan->getIndexInCell(normalizeModulo4(championIconIndex + _vm->_dungeonMan->_partyDir));
 		if (championIconIndex == champIconIndex) {
 			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, k0x0400_ChampionAttributeIcon);
@@ -1492,11 +1492,11 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
 			_vm->_championMan->drawChampionState((ChampionIndex)championCellIndex);
 		}
 	}
-	_gK100_preventBuildPointerScreenArea = false;
-	f73_buildpointerScreenArea(_mousePos.x, _mousePos.y);
+	_preventBuildPointerScreenArea = false;
+	buildpointerScreenArea(_mousePos.x, _mousePos.y);
 }
 
-void EventManager::f370_commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY) {
+void EventManager::commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY) {
 	int16 championIndex = kM1_ChampionNone;
 	if (posY <= 48) {
 		switch (_vm->_championMan->_magicCasterChampionIndex) {
@@ -1545,12 +1545,12 @@ void EventManager::f370_commandProcessType100_clickInSpellArea(uint16 posX, uint
 		return;
 	}
 
-	CommandType newCommand = f358_getCommandTypeFromMouseInput(_mouseInputSpellArea, Common::Point(posX, posY), k1_LeftMouseButton);
+	CommandType newCommand = getCommandTypeFromMouseInput(_mouseInputSpellArea, Common::Point(posX, posY), k1_LeftMouseButton);
 	if (newCommand != k0_CommandNone)
-		f369_commandProcessTypes101To108_clickInSpellSymbolsArea(newCommand);
+		commandProcessTypes101To108_clickInSpellSymbolsArea(newCommand);
 }
 
-void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType) {
+void EventManager::commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType) {
 	static Box spellSymbolsAndDelete[7] = {
 		/* { X1, X2, Y1, Y2 } */
 		Box(235, 247, 51, 61),   /* Symbol 1 */
@@ -1565,16 +1565,16 @@ void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(Comm
 		if (_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex]._symbols[0] == '\0')
 			return;
 
-		f362_commandHighlightBoxEnable(234, 303, 63, 73);
+		commandHighlightBoxEnable(234, 303, 63, 73);
 		_vm->_stopWaitingForPlayerInput = _vm->_menuMan->f408_getClickOnSpellCastResult();
 		return;
 	}
 
 	uint16 symbolIndex = cmdType - k101_CommandClickInSpellAreaSymbol_1;
 	Box *highlightBox = &spellSymbolsAndDelete[symbolIndex];
-	f362_commandHighlightBoxEnable(highlightBox->_x1, highlightBox->_x2, highlightBox->_y1, highlightBox->_y2);
+	commandHighlightBoxEnable(highlightBox->_x1, highlightBox->_x2, highlightBox->_y1, highlightBox->_y2);
 	_vm->delay(1);
-	f363_highlightBoxDisable();
+	highlightBoxDisable();
 
 	if (symbolIndex < 6)
 		_vm->_menuMan->f399_addChampionSymbol(symbolIndex);
@@ -1582,26 +1582,26 @@ void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(Comm
 		_vm->_menuMan->f400_deleteChampionSymbol();
 }
 
-void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY) {
+void EventManager::commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY) {
 	if (_vm->_championMan->_actingChampionOrdinal) {
-		uint16 mouseCommand = f358_getCommandTypeFromMouseInput(_mouseInputActionAreaNames, Common::Point(posX, posY), k1_LeftMouseButton);
+		uint16 mouseCommand = getCommandTypeFromMouseInput(_mouseInputActionAreaNames, Common::Point(posX, posY), k1_LeftMouseButton);
 		if (mouseCommand != k0_CommandNone) {
 			if (mouseCommand == k112_CommandClickInActionAreaPass) {
-				f362_commandHighlightBoxEnable(285, 319, 77, 83);
+				commandHighlightBoxEnable(285, 319, 77, 83);
 				_vm->_menuMan->f391_didClickTriggerAction(-1);
 			} else if ((mouseCommand - k112_CommandClickInActionAreaPass) <= _vm->_menuMan->_g507_actionCount) {
 				if (mouseCommand == k113_CommandClickInActionAreaAction_0)
-					f362_commandHighlightBoxEnable(234, 318, 86, 96);
+					commandHighlightBoxEnable(234, 318, 86, 96);
 				else if (mouseCommand == k114_CommandClickInActionAreaAction_1)
-					f362_commandHighlightBoxEnable(234, 318, 98, 108);
+					commandHighlightBoxEnable(234, 318, 98, 108);
 				else
-					f362_commandHighlightBoxEnable(234, 318, 110, 120);
+					commandHighlightBoxEnable(234, 318, 110, 120);
 
 				_vm->_stopWaitingForPlayerInput = _vm->_menuMan->f391_didClickTriggerAction(mouseCommand - k113_CommandClickInActionAreaAction_0);
 			}
 		}
 	} else if (_vm->_menuMan->_g509_actionAreaContainsIcons) {
-		uint16 mouseCommand = f358_getCommandTypeFromMouseInput(_mouseInputActionAreaIcons, Common::Point(posX, posY), k1_LeftMouseButton);
+		uint16 mouseCommand = getCommandTypeFromMouseInput(_mouseInputActionAreaIcons, Common::Point(posX, posY), k1_LeftMouseButton);
 		if (mouseCommand != k0_CommandNone) {
 			mouseCommand -= k116_CommandClickInActionAreaChampion_0_Action;
 			if (mouseCommand < _vm->_championMan->_partyChampionCount)
@@ -1610,19 +1610,19 @@ void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX,
 	}
 }
 
-void EventManager::f544_resetPressingEyeOrMouth() {
+void EventManager::resetPressingEyeOrMouth() {
 	if (_vm->_pressingEye) {
-		_g597_ignoreMouseMovements = false;
+		_ignoreMouseMovements = false;
 		_vm->_stopPressingEye = true;
 	}
 	if (_vm->_pressingMouth) {
-		_g597_ignoreMouseMovements = false;
+		_ignoreMouseMovements = false;
 		_vm->_stopPressingMouth = true;
 	}
 }
 
-void EventManager::f541_waitForMouseOrKeyActivity() {
-	f357_discardAllInput();
+void EventManager::waitForMouseOrKeyActivity() {
+	discardAllInput();
 	Common::Event event;
 	while (true) {
 		if (_vm->_system->getEventManager()->pollEvent(event)) {
@@ -1642,16 +1642,16 @@ void EventManager::f541_waitForMouseOrKeyActivity() {
 	}
 }
 
-void EventManager::f362_commandHighlightBoxEnable(int16 x1, int16 x2, int16 y1, int16 y2) {
+void EventManager::commandHighlightBoxEnable(int16 x1, int16 x2, int16 y1, int16 y2) {
 	_highlightScreenBox = Box(x1, x2, y1, y2);
-	f6_highlightScreenBox(x1, x2, y1, y2);
-	_g341_highlightBoxEnabled = true;
+	highlightScreenBox(x1, x2, y1, y2);
+	_highlightBoxEnabled = true;
 }
 
-void EventManager::f363_highlightBoxDisable() {
-	if (_g341_highlightBoxEnabled == true) {
-		f6_highlightScreenBox(_highlightScreenBox._x1, _highlightScreenBox._x2, _highlightScreenBox._y1, _highlightScreenBox._y2);
-		_g341_highlightBoxEnabled = false;
+void EventManager::highlightBoxDisable() {
+	if (_highlightBoxEnabled == true) {
+		highlightScreenBox(_highlightScreenBox._x1, _highlightScreenBox._x2, _highlightScreenBox._y1, _highlightScreenBox._y2);
+		_highlightBoxEnabled = false;
 	}
 }
 
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 1066f35..5686e50 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -36,11 +36,8 @@
 #include "gfx.h"
 #include "champion.h"
 
-
 namespace DM {
 
-
-
 enum MouseButton {
 	k0_NoneMouseButton = 0, // present only because of typesafety
 	k1_LeftMouseButton = 1,
@@ -201,35 +198,32 @@ class DMEngine;
 #define k3_pointerTypeHand 3 // @ C3_POINTER_TYPE_HAND          
 #define k4_pointerTypeAutoselect 4 // @ C4_POINTER_TYPE_AUTOSELECT    
 
-
-
-
 class EventManager {
 	DMEngine *_vm;
 
 	Common::Point _mousePos;
 	uint16 _dummyMapIndex;
 
-	bool _g436_pendingClickPresent; // G0436_B_PendingClickPresent
-	Common::Point _g437_pendingClickPos; // @ G0437_i_PendingClickX, G0438_i_PendingClickY
-	MouseButton _g439_pendingClickButton; // @ G0439_i_PendingClickButtonsStatus
-	bool _g600_useObjectAsMousePointerBitmap; // @ G0600_B_UseObjectAsMousePointerBitmap
-	bool _g601_useHandAsMousePointerBitmap; // @ G0601_B_UseHandAsMousePointerBitmap
-	bool _gK100_preventBuildPointerScreenArea; // @ K0100_B_PreventBuildPointerScreenArea
-	byte *_g615_mousePointerOriginalColorsObject; // @ G0615_puc_Bitmap_MousePointerOriginalColorsObject
-	byte *_g613_mousePointerOriginalColorsChampionIcon; // @ G0613_puc_Bitmap_MousePointerOriginalColorsChampionIcon
-	byte *_gK190_mousePointerTempBuffer; // @ K0190_puc_Bitmap_MousePointerTemporaryBuffer
-	int16 _gK104_mousePointerType; // @ K0104_i_MousePointerType
-	int16 _gK105_previousMousePointerType; // @ K0105_i_PreviousMousePointerType
-	uint16 _g558_mouseButtonStatus;// @ G0588_i_MouseButtonsStatus
+	bool _pendingClickPresent; // G0436_B_PendingClickPresent
+	Common::Point _pendingClickPos; // @ G0437_i_PendingClickX, G0438_i_PendingClickY
+	MouseButton _pendingClickButton; // @ G0439_i_PendingClickButtonsStatus
+	bool _useObjectAsMousePointerBitmap; // @ G0600_B_UseObjectAsMousePointerBitmap
+	bool _useHandAsMousePointerBitmap; // @ G0601_B_UseHandAsMousePointerBitmap
+	bool _preventBuildPointerScreenArea; // @ K0100_B_PreventBuildPointerScreenArea
+	byte *_mousePointerOriginalColorsObject; // @ G0615_puc_Bitmap_MousePointerOriginalColorsObject
+	byte *_mousePointerOriginalColorsChampionIcon; // @ G0613_puc_Bitmap_MousePointerOriginalColorsChampionIcon
+	byte *_mousePointerTempBuffer; // @ K0190_puc_Bitmap_MousePointerTemporaryBuffer
+	int16 _mousePointerType; // @ K0104_i_MousePointerType
+	int16 _previousMousePointerType; // @ K0105_i_PreviousMousePointerType
+	uint16 _mouseButtonStatus;// @ G0588_i_MouseButtonsStatus
 
 // this doesn't seem to be used anywhere at all
-	bool _g435_isCommandQueueLocked; // @ G0435_B_CommandQueueLocked
+	bool _isCommandQueueLocked; // @ G0435_B_CommandQueueLocked
 	Common::Queue<Command> _commandQueue;
 
-	void f365_commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty
-	void f366_commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty
-	bool f375_processType80_clickDungeonView_isLeaderHandObjThrown(int16 posX, int16 posY); // @ F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown
+	void commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty
+	void commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty
+	bool isLeaderHandObjThrown(int16 posX, int16 posY); // @ F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown
 	void setMousePointerFromSpriteData(byte* mouseSprite);
 
 	Box _highlightScreenBox; // @ G0336_i_HighlightBoxX1
@@ -237,25 +231,25 @@ public:
 	explicit EventManager(DMEngine *vm);
 	~EventManager();
 
-	MouseInput* _g441_primaryMouseInput;// @ G0441_ps_PrimaryMouseInput
-	MouseInput* _g442_secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput
-	bool _g598_mousePointerBitmapUpdated; // @ G0598_B_MousePointerBitmapUpdated
-	bool _g326_refreshMousePointerInMainLoop; // @ G0326_B_RefreshMousePointerInMainLoop
-	bool _g341_highlightBoxEnabled; // @ G0341_B_HighlightBoxEnabled
-	uint16 _g599_useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap
-	KeyboardInput *_g443_primaryKeyboardInput; // @ G0443_ps_PrimaryKeyboardInput
-	KeyboardInput *_g444_secondaryKeyboardInput; // @ G0444_ps_SecondaryKeyboardInput
-	bool _g597_ignoreMouseMovements;// @ G0597_B_IgnoreMouseMovements
-	int16 _g587_hideMousePointerRequestCount; // @ G0587_i_HideMousePointerRequestCount
+	MouseInput* _primaryMouseInput;// @ G0441_ps_PrimaryMouseInput
+	MouseInput* _secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput
+	bool _mousePointerBitmapUpdated; // @ G0598_B_MousePointerBitmapUpdated
+	bool _refreshMousePointerInMainLoop; // @ G0326_B_RefreshMousePointerInMainLoop
+	bool _highlightBoxEnabled; // @ G0341_B_HighlightBoxEnabled
+	uint16 _useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap
+	KeyboardInput *_primaryKeyboardInput; // @ G0443_ps_PrimaryKeyboardInput
+	KeyboardInput *_secondaryKeyboardInput; // @ G0444_ps_SecondaryKeyboardInput
+	bool _ignoreMouseMovements;// @ G0597_B_IgnoreMouseMovements
+	int16 _hideMousePointerRequestCount; // @ G0587_i_HideMousePointerRequestCount
 
 	void initMouse();
-	void f67_setMousePointerToNormal(int16 mousePointer); // @ F0067_MOUSE_SetPointerToNormal
-	void f68_setPointerToObject(byte *bitmap); // @ F0068_MOUSE_SetPointerToObject
-	void f71_mouseDropChampionIcon(); // @ F0071_MOUSE_DropChampionIcon
-	void f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY); // @ F0073_MOUSE_BuildPointerScreenArea
-	void f69_setMousePointer(); // @ F0069_MOUSE_SetPointer
-	void f78_showMouse(); // @ F0077_MOUSE_HidePointer_CPSE
-	void f77_hideMouse(); // @ F0078_MOUSE_ShowPointer
+	void setMousePointerToNormal(int16 mousePointer); // @ F0067_MOUSE_SetPointerToNormal
+	void setPointerToObject(byte *bitmap); // @ F0068_MOUSE_SetPointerToObject
+	void mouseDropChampionIcon(); // @ F0071_MOUSE_DropChampionIcon
+	void buildpointerScreenArea(int16 mousePosX, int16 mousePosY); // @ F0073_MOUSE_BuildPointerScreenArea
+	void setMousePointer(); // @ F0069_MOUSE_SetPointer
+	void showMouse(); // @ F0077_MOUSE_HidePointer_CPSE
+	void hideMouse(); // @ F0078_MOUSE_ShowPointer
 	bool isMouseButtonDown(MouseButton button);
 
 	void setMousePos(Common::Point pos);
@@ -267,35 +261,34 @@ public:
 	* If there are no more events, it returns with Common::EVENT_INVALID.
 	*/
 	Common::EventType processInput(Common::Event *grabKey = nullptr, Common::Event *grabMouseClick = nullptr);
-	void f360_processPendingClick(); // @ F0360_COMMAND_ProcessPendingClick
-	void f359_processClick(Common::Point mousePos, MouseButton button); // @ F0359_COMMAND_ProcessClick_CPSC
-	CommandType f358_getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC
-	void f380_processCommandQueue(); // @ F0380_COMMAND_ProcessQueue_CPSC
-
-	void f368_commandSetLeader(ChampionIndex index); // @ F0368_COMMAND_SetLeader
-	void f372_commandProcessType80ClickInDungeonViewTouchFrontWall(); // @ F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall
-	void f377_commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView
-	void f282_commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType); // @ F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel
-	void f378_commandProcess81ClickInPanel(int16 x, int16 y); // @ F0378_COMMAND_ProcessType81_ClickInPanel
-	void f373_processType80_clickInDungeonView_grabLeaderHandObject(uint16 viewCell); // @ F0373_COMMAND_ProcessType80_ClickInDungeonView_GrabLeaderHandObject
-	void f374_processType80_clickInDungeonViewDropLeaderHandObject(uint16 viewCell); // @ F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject
-
-	bool f360_hasPendingClick(Common::Point &point, MouseButton button); // @ F0360_COMMAND_ProcessPendingClick
-	void f379_drawSleepScreen(); // @ F0379_COMMAND_DrawSleepScreen
-	void f357_discardAllInput(); // @ F0357_COMMAND_DiscardAllInput
-	void f364_commandTakeStairs(bool stairsGoDown);// @ F0364_COMMAND_TakeStairs
-	void f367_commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX,
+	void processPendingClick(); // @ F0360_COMMAND_ProcessPendingClick
+	void processClick(Common::Point mousePos, MouseButton button); // @ F0359_COMMAND_ProcessClick_CPSC
+	CommandType getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC
+	void processCommandQueue(); // @ F0380_COMMAND_ProcessQueue_CPSC
+
+	void commandSetLeader(ChampionIndex index); // @ F0368_COMMAND_SetLeader
+	void commandProcessType80ClickInDungeonViewTouchFrontWall(); // @ F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall
+	void commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView
+	void commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType); // @ F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel
+	void commandProcess81ClickInPanel(int16 x, int16 y); // @ F0378_COMMAND_ProcessType81_ClickInPanel
+	void processType80_clickInDungeonView_grabLeaderHandObject(uint16 viewCell); // @ F0373_COMMAND_ProcessType80_ClickInDungeonView_GrabLeaderHandObject
+	void processType80_clickInDungeonViewDropLeaderHandObject(uint16 viewCell); // @ F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject
+
+	bool hasPendingClick(Common::Point &point, MouseButton button); // @ F0360_COMMAND_ProcessPendingClick
+	void drawSleepScreen(); // @ F0379_COMMAND_DrawSleepScreen
+	void discardAllInput(); // @ F0357_COMMAND_DiscardAllInput
+	void commandTakeStairs(bool stairsGoDown);// @ F0364_COMMAND_TakeStairs
+	void commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX,
 																 int16 posY); // @ F0367_COMMAND_ProcessTypes12To27_ClickInChampionStatusBox
-	void f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex); // @ F0070_MOUSE_ProcessCommands125To128_ClickOnChampionIcon
-	void f370_commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY); // @ F0370_COMMAND_ProcessType100_ClickInSpellArea
-	void f369_commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType); // @ F0369_COMMAND_ProcessTypes101To108_ClickInSpellSymbolsArea_CPSE
-	void f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY); // @ F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE
-	void f544_resetPressingEyeOrMouth(); // @ F0544_INPUT_ResetPressingEyeOrMouth
-	void f541_waitForMouseOrKeyActivity(); // @ F0541_INPUT_WaitForMouseOrKeyboardActivity
-	void f362_commandHighlightBoxEnable(int16 x1, int16 x2, int16 y1, int16 y2); // @ F0362_COMMAND_HighlightBoxEnable
-	void f363_highlightBoxDisable(); // @ F0363_COMMAND_HighlightBoxDisable
-	void f6_highlightScreenBox(int16 x1, int16 x2, int16 y1, int16 y2) { warning(false, "STUB METHOD: f6_highlightScreenBox"); } // @  F0006_MAIN_HighlightScreenBox
-
+	void mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex); // @ F0070_MOUSE_ProcessCommands125To128_ClickOnChampionIcon
+	void commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY); // @ F0370_COMMAND_ProcessType100_ClickInSpellArea
+	void commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType); // @ F0369_COMMAND_ProcessTypes101To108_ClickInSpellSymbolsArea_CPSE
+	void commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY); // @ F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE
+	void resetPressingEyeOrMouth(); // @ F0544_INPUT_ResetPressingEyeOrMouth
+	void waitForMouseOrKeyActivity(); // @ F0541_INPUT_WaitForMouseOrKeyboardActivity
+	void commandHighlightBoxEnable(int16 x1, int16 x2, int16 y1, int16 y2); // @ F0362_COMMAND_HighlightBoxEnable
+	void highlightBoxDisable(); // @ F0363_COMMAND_HighlightBoxDisable
+	void highlightScreenBox(int16 x1, int16 x2, int16 y1, int16 y2) { warning(false, "STUB METHOD: highlightScreenBox"); } // @  F0006_MAIN_HighlightScreenBox
 
 	KeyboardInput _primaryKeyboardInputInterface[7]; // @ G0458_as_Graphic561_PrimaryKeyboardInput_Interface
 	KeyboardInput _secondaryKeyboardInputMovement[19]; // @ G0459_as_Graphic561_SecondaryKeyboardInput_Movement
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 30f5a0c..ceeb285 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -3842,7 +3842,7 @@ void DisplayMan::f436_STARTEND_FadeToPalette(uint16* P0849_pui_Palette) {
 			}
 		}
 		_vm->delay(1);
-		_vm->_eventMan->f357_discardAllInput();
+		_vm->_eventMan->discardAllInput();
 		f508_buildPaletteChangeCopperList(_gK16_paletteFadeTemporary, _gK16_paletteFadeTemporary);
 	}
 }
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index fd132d7..c4c48a0 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -104,7 +104,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	if (_vm->indexToOrdinal(championIndex) == AL1102_ui_InventoryChampionOrdinal) {
 		championIndex = k4_ChampionCloseInventory;
 	}
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->showMouse();
 	if (AL1102_ui_InventoryChampionOrdinal) {
 		_g432_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 		f334_closeChest();
@@ -114,16 +114,16 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 			_vm->_championMan->drawChampionState((ChampionIndex)_vm->ordinalToIndex(AL1102_ui_InventoryChampionOrdinal));
 		}
 		if (_vm->_championMan->_partyIsSleeping) {
-			_vm->_eventMan->f77_hideMouse();
+			_vm->_eventMan->hideMouse();
 			return;
 		}
 		if (championIndex == k4_ChampionCloseInventory) {
-			_vm->_eventMan->_g326_refreshMousePointerInMainLoop = true;
+			_vm->_eventMan->_refreshMousePointerInMainLoop = true;
 			_vm->_menuMan->f395_drawMovementArrows();
-			_vm->_eventMan->f77_hideMouse();
-			_vm->_eventMan->_g442_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputMovement;
-			_vm->_eventMan->_g444_secondaryKeyboardInput = _vm->_eventMan->_secondaryKeyboardInputMovement;
-			_vm->_eventMan->f357_discardAllInput();
+			_vm->_eventMan->hideMouse();
+			_vm->_eventMan->_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputMovement;
+			_vm->_eventMan->_secondaryKeyboardInput = _vm->_eventMan->_secondaryKeyboardInputMovement;
+			_vm->_eventMan->discardAllInput();
 			_vm->_displayMan->f98_drawFloorAndCeiling();
 			return;
 		}
@@ -161,11 +161,11 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	}
 	setFlag(L1103_ps_Champion->_attributes, k0x4000_ChampionAttributeViewport | k0x1000_ChampionAttributeStatusBox | k0x0800_ChampionAttributePanel | k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics | k0x0080_ChampionAttributeNameTitle);
 	_vm->_championMan->drawChampionState(championIndex);
-	_vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
-	_vm->_eventMan->f77_hideMouse();
-	_vm->_eventMan->_g442_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputChampionInventory;
-	_vm->_eventMan->_g444_secondaryKeyboardInput = nullptr;
-	_vm->_eventMan->f357_discardAllInput();
+	_vm->_eventMan->_mousePointerBitmapUpdated = true;
+	_vm->_eventMan->hideMouse();
+	_vm->_eventMan->_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputChampionInventory;
+	_vm->_eventMan->_secondaryKeyboardInput = nullptr;
+	_vm->_eventMan->discardAllInput();
 }
 
 void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) {
@@ -875,10 +875,10 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 void InventoryMan::f350_drawStopPressingMouth() {
 	f347_drawPanel();
 	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
-	_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
-	_vm->_eventMan->f78_showMouse();
-	_vm->_eventMan->f78_showMouse();
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->_hideMousePointerRequestCount = 1;
+	_vm->_eventMan->showMouse();
+	_vm->_eventMan->showMouse();
+	_vm->_eventMan->showMouse();
 }
 
 void InventoryMan::f353_drawStopPressingEye() {
@@ -890,9 +890,9 @@ void InventoryMan::f353_drawStopPressingEye() {
 	if ((L1100_T_LeaderHandObject = _vm->_championMan->_leaderHandObject) != Thing::_none) {
 		_vm->_objectMan->f34_drawLeaderObjectName(L1100_T_LeaderHandObject);
 	}
-	_vm->_eventMan->f78_showMouse();
-	_vm->_eventMan->f78_showMouse();
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->showMouse();
+	_vm->_eventMan->showMouse();
+	_vm->_eventMan->showMouse();
 }
 
 void InventoryMan::f349_processCommand70_clickOnMouth() {
@@ -930,15 +930,15 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 		if (_g424_panelContent == k0_PanelContentFoodWaterPoisoned) {
 			return;
 		}
-		_vm->_eventMan->_g597_ignoreMouseMovements = true;
+		_vm->_eventMan->_ignoreMouseMovements = true;
 		_vm->_pressingMouth = true;
 		if (!_vm->_eventMan->isMouseButtonDown(k1_LeftMouseButton)) {
-			_vm->_eventMan->_g597_ignoreMouseMovements = false;
+			_vm->_eventMan->_ignoreMouseMovements = false;
 			_vm->_pressingMouth = false;
 			_vm->_stopPressingMouth = false;
 		} else {
-			_vm->_eventMan->f78_showMouse();
-			_vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
+			_vm->_eventMan->showMouse();
+			_vm->_eventMan->_hideMousePointerRequestCount = 1;
 			f345_drawPanelFoodWaterPoisoned();
 			_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
 		}
@@ -970,7 +970,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 			L1081_B_RemoveObjectFromLeaderHand = true;
 		}
 	}
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->showMouse();
 	if (L1081_B_RemoveObjectFromLeaderHand) {
 		_vm->_championMan->getObjectRemovedFromLeaderHand();
 	}
@@ -1052,7 +1052,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 	if (L1081_B_RemoveObjectFromLeaderHand) {
 		for (L1086_ui_Counter = 5; --L1086_ui_Counter; _vm->delay(8)) { /* Animate mouth icon */
 			_vm->_objectMan->f37_drawIconToScreen(k205_IconIndiceMouthOpen + !(L1086_ui_Counter & 0x0001), 56, 46);
-			_vm->_eventMan->f357_discardAllInput();
+			_vm->_eventMan->discardAllInput();
 			if (_vm->_engineShouldQuit)
 				return;
 			_vm->_displayMan->updateScreen();
@@ -1068,7 +1068,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 		setFlag(L1083_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
 	}
 	_vm->_championMan->drawChampionState((ChampionIndex)L1080_ui_ChampionIndex);
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->hideMouse();
 }
 
 void InventoryMan::f348_adjustStatisticCurrentValue(Champion* champ, uint16 statIndex, int16 valueDelta) {
@@ -1092,18 +1092,18 @@ void InventoryMan::f348_adjustStatisticCurrentValue(Champion* champ, uint16 stat
 }
 
 void InventoryMan::f352_processCommand71_clickOnEye() {
-	_vm->_eventMan->_g597_ignoreMouseMovements = true;
+	_vm->_eventMan->_ignoreMouseMovements = true;
 	_vm->_pressingEye = true;
 	if (!_vm->_eventMan->isMouseButtonDown(k1_LeftMouseButton)) {
-		_vm->_eventMan->_g597_ignoreMouseMovements = false;
+		_vm->_eventMan->_ignoreMouseMovements = false;
 		_vm->_pressingEye = false;
 		_vm->_stopPressingEye = false;
 		return;
 	}
-	_vm->_eventMan->f357_discardAllInput();
-	_vm->_eventMan->f77_hideMouse();
-	_vm->_eventMan->f77_hideMouse();
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->discardAllInput();
+	_vm->_eventMan->hideMouse();
+	_vm->_eventMan->hideMouse();
+	_vm->_eventMan->hideMouse();
 	_vm->delay(8);
 	f332_drawIconToViewport(k203_IconIndiceEyeLooking, 12, 13);
 	if (_vm->_championMan->_leaderEmptyHanded) {
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index a6efc10..52ba139 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -165,7 +165,7 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
 
 void DMEngine::saveGame() {
 	_menuMan->f456_drawDisabledMenu();
-	_eventMan->f78_showMouse();
+	_eventMan->showMouse();
 
 	switch (getGameLanguage()) { // localized
 	default:
@@ -242,13 +242,13 @@ void DMEngine::saveGame() {
 
 
 	if (saveAndPlayChoice == kSaveAndQuit) {
-		_eventMan->f77_hideMouse();
+		_eventMan->hideMouse();
 		endGame(false);
 	}
 
 	_restartGameAllowed = true;
 	_menuMan->f457_drawEnabledMenus();
-	_eventMan->f77_hideMouse();
+	_eventMan->hideMouse();
 }
 
 Common::String DMEngine::getSavefileName(uint16 slot) {
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index cf32fd7..ae271fc 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -118,10 +118,10 @@ MenuMan::~MenuMan() {
 }
 
 void MenuMan::f395_drawMovementArrows() {
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->showMouse();
 	_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k13_MovementArrowsIndice),
 									   &_vm->_displayMan->_boxMovementArrows, k48_byteWidth, kM1_ColorNoTransparency, 45);
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->hideMouse();
 }
 void MenuMan::f388_clearActingChampion() {
 	ChampionMan &cm = *_vm->_championMan;
@@ -180,7 +180,7 @@ T0386006:
 
 void MenuMan::f456_drawDisabledMenu() {
 	if (!_vm->_championMan->_partyIsSleeping) {
-		_vm->_eventMan->f363_highlightBoxDisable();
+		_vm->_eventMan->highlightBoxDisable();
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 			if (_vm->_inventoryMan->_g424_panelContent == k4_PanelContentChest) {
@@ -191,7 +191,7 @@ void MenuMan::f456_drawDisabledMenu() {
 		}
 		_vm->_displayMan->f136_shadeScreenBox(&boxSpellArea, k0_ColorBlack);
 		_vm->_displayMan->f136_shadeScreenBox(&boxActionArea, k0_ColorBlack);
-		_vm->_eventMan->f67_setMousePointerToNormal(k0_pointerArrow);
+		_vm->_eventMan->setMousePointerToNormal(k0_pointerArrow);
 	}
 }
 
@@ -255,7 +255,7 @@ void MenuMan::f387_drawActionArea() {
 	ChampionMan &champMan = *_vm->_championMan;
 	TextMan &textMan = *_vm->_textMan;
 
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->hideMouse();
 	dispMan._g578_useByteBoxCoordinates = false;
 	dispMan.D24_fillScreenBox(boxActionArea, k0_ColorBlack);
 	if (_g509_actionAreaContainsIcons) {
@@ -278,7 +278,7 @@ void MenuMan::f387_drawActionArea() {
 												k12_ActionNameMaximumLength, k200_heightScreen);
 		}
 	}
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->showMouse();
 	_g508_refreshActionArea = false;
 }
 
@@ -306,25 +306,25 @@ void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) {
 	int16 champHP1 = _vm->_championMan->_champions[1]._currHealth;
 	int16 champHP2 = _vm->_championMan->_champions[2]._currHealth;
 	int16 champHP3 = _vm->_championMan->_champions[3]._currHealth;
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->showMouse();
 	_vm->_displayMan->D24_fillScreenBox(boxSpellAreaControls, k0_ColorBlack);
 	switch (champIndex) {
 	case 0:
-		_vm->_eventMan->f6_highlightScreenBox(233, 277, 42, 49);
+		_vm->_eventMan->highlightScreenBox(233, 277, 42, 49);
 		_vm->_textMan->f53_printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
 		if (_vm->_championMan->_partyChampionCount > 1) {
 			if (champHP1) {
-				_vm->_eventMan->f6_highlightScreenBox(280, 291, 42, 48);
+				_vm->_eventMan->highlightScreenBox(280, 291, 42, 48);
 			}
 T0393002:
 			if (_vm->_championMan->_partyChampionCount > 2) {
 				if (champHP2) {
-					_vm->_eventMan->f6_highlightScreenBox(294, 305, 42, 48);
+					_vm->_eventMan->highlightScreenBox(294, 305, 42, 48);
 				}
 T0393003:
 				if (_vm->_championMan->_partyChampionCount > 3) {
 					if (champHP3) {
-						_vm->_eventMan->f6_highlightScreenBox(308, 319, 42, 48);
+						_vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
 					}
 				}
 			}
@@ -332,38 +332,38 @@ T0393003:
 		break;
 	case 1:
 		if (champHP0) {
-			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
+			_vm->_eventMan->highlightScreenBox(233, 244, 42, 48);
 		}
-		_vm->_eventMan->f6_highlightScreenBox(247, 291, 42, 49);
+		_vm->_eventMan->highlightScreenBox(247, 291, 42, 49);
 		_vm->_textMan->f53_printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
 		goto T0393002;
 	case 2:
 		if (champHP0) {
-			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
+			_vm->_eventMan->highlightScreenBox(233, 244, 42, 48);
 		}
 		if (champHP1) {
-			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
+			_vm->_eventMan->highlightScreenBox(247, 258, 42, 48);
 		}
-		_vm->_eventMan->f6_highlightScreenBox(261, 305, 42, 49);
+		_vm->_eventMan->highlightScreenBox(261, 305, 42, 49);
 		_vm->_textMan->f53_printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
 		goto T0393003;
 	case 3:
 		if (champHP0) {
-			_vm->_eventMan->f6_highlightScreenBox(233, 244, 42, 48);
+			_vm->_eventMan->highlightScreenBox(233, 244, 42, 48);
 		}
 		if (champHP1) {
-			_vm->_eventMan->f6_highlightScreenBox(247, 258, 42, 48);
+			_vm->_eventMan->highlightScreenBox(247, 258, 42, 48);
 		}
 		if (champHP2) {
-			_vm->_eventMan->f6_highlightScreenBox(261, 272, 42, 48);
+			_vm->_eventMan->highlightScreenBox(261, 272, 42, 48);
 		}
-		_vm->_eventMan->f6_highlightScreenBox(275, 319, 42, 49);
+		_vm->_eventMan->highlightScreenBox(275, 319, 42, 49);
 		_vm->_textMan->f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
 		break;
 	default:
 		break;
 	}
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->hideMouse();
 }
 
 #define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
@@ -405,26 +405,26 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 		return;
 	}
 	if (_vm->_championMan->_magicCasterChampionIndex == kM1_ChampionNone) {
-		_vm->_eventMan->f78_showMouse();
+		_vm->_eventMan->showMouse();
 		_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &boxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33);
-		_vm->_eventMan->f77_hideMouse();
+		_vm->_eventMan->hideMouse();
 	}
 	if (champIndex == kM1_ChampionNone) {
 		_vm->_championMan->_magicCasterChampionIndex = kM1_ChampionNone;
-		_vm->_eventMan->f78_showMouse();
+		_vm->_eventMan->showMouse();
 		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 		_vm->_displayMan->D24_fillScreenBox(boxSpellArea, k0_ColorBlack);
-		_vm->_eventMan->f77_hideMouse();
+		_vm->_eventMan->hideMouse();
 		return;
 	}
 	L1213_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex = (ChampionIndex)champIndex];
 	f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->showMouse();
 	f393_drawSpellAreaControls((ChampionIndex)champIndex);
 	_vm->_displayMan->f21_blitToScreen(_gK72_bitmapSpellAreaLine, &boxSpellAreaLine2, k48_byteWidth, kM1_ColorNoTransparency, 12);
 	f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols);
 	_vm->_displayMan->f21_blitToScreen(_gK72_bitmapSpellAreaLine, &boxSpellAreaLine3, k48_byteWidth, kM1_ColorNoTransparency, 12);
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->hideMouse();
 }
 
 void MenuMan::f457_drawEnabledMenus() {
@@ -434,7 +434,7 @@ void MenuMan::f457_drawEnabledMenus() {
 
 
 	if (_vm->_championMan->_partyIsSleeping) {
-		_vm->_eventMan->f379_drawSleepScreen();
+		_vm->_eventMan->drawSleepScreen();
 		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
 	} else {
 		AL1462_i_MagicCasterChampionIndex = _vm->_championMan->_magicCasterChampionIndex;
@@ -452,7 +452,7 @@ void MenuMan::f457_drawEnabledMenus() {
 			_vm->_displayMan->f98_drawFloorAndCeiling();
 			f395_drawMovementArrows();
 		}
-		_vm->_eventMan->f69_setMousePointer();
+		_vm->_eventMan->setMousePointer();
 	}
 }
 
@@ -462,8 +462,8 @@ int16 MenuMan::f408_getClickOnSpellCastResult() {
 
 
 	L1260_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
-	_vm->_eventMan->f78_showMouse();
-	_vm->_eventMan->f363_highlightBoxDisable();
+	_vm->_eventMan->showMouse();
+	_vm->_eventMan->highlightBoxDisable();
 	if ((L1259_i_SpellCastResult = f412_getChampionSpellCastResult(_vm->_championMan->_magicCasterChampionIndex)) != k3_spellCastFailureNeedsFlask) {
 		L1260_ps_Champion->_symbols[0] = '\0';
 		f397_drawAvailableSymbols(L1260_ps_Champion->_symbolStep = 0);
@@ -471,7 +471,7 @@ int16 MenuMan::f408_getClickOnSpellCastResult() {
 	} else {
 		L1259_i_SpellCastResult = k0_spellCastFailure;
 	}
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->hideMouse();
 	return L1259_i_SpellCastResult;
 }
 
@@ -857,11 +857,11 @@ void MenuMan::f399_addChampionSymbol(int16 symbolIndex) {
 		L1225_ps_Champion->_symbols[L1222_ui_SymbolStep] = 96 + (L1222_ui_SymbolStep * 6) + symbolIndex;
 		L1225_ps_Champion->_symbols[L1222_ui_SymbolStep + 1] = '\0';
 		L1225_ps_Champion->_symbolStep = L1222_ui_SymbolStep = returnNextVal(L1222_ui_SymbolStep);
-		_vm->_eventMan->f78_showMouse();
+		_vm->_eventMan->showMouse();
 		f397_drawAvailableSymbols(L1222_ui_SymbolStep);
 		f398_drawChampionSymbols(L1225_ps_Champion);
 		_vm->_championMan->drawChampionState(_vm->_championMan->_magicCasterChampionIndex);
-		_vm->_eventMan->f77_hideMouse();
+		_vm->_eventMan->hideMouse();
 	}
 }
 
@@ -875,10 +875,10 @@ void MenuMan::f400_deleteChampionSymbol() {
 	}
 	L1228_ps_Champion->_symbolStep = L1226_ui_SymbolStep = returnPrevVal(L1228_ps_Champion->_symbolStep);
 	L1228_ps_Champion->_symbols[L1226_ui_SymbolStep] = '\0';
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->showMouse();
 	f397_drawAvailableSymbols(L1226_ui_SymbolStep);
 	f398_drawChampionSymbols(L1228_ps_Champion);
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->hideMouse();
 }
 
 bool MenuMan::f391_didClickTriggerAction(int16 actionListIndex) {
@@ -1725,7 +1725,7 @@ void MenuMan::f385_drawActionDamage(int16 damage) {
 	const Box* L1180_ps_Box;
 	int16 L1643_i_Width;
 
-	_vm->_eventMan->f78_showMouse();
+	_vm->_eventMan->showMouse();
 	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
 	_vm->_displayMan->D24_fillScreenBox(boxActionArea, k0_ColorBlack);
 	if (damage < 0) {
@@ -1791,6 +1791,6 @@ void MenuMan::f385_drawActionDamage(int16 damage) {
 		} while (damage /= 10);
 		_vm->_textMan->f53_printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, &L1179_ac_String[AL1174_ui_CharacterIndex]);
 	}
-	_vm->_eventMan->f77_hideMouse();
+	_vm->_eventMan->hideMouse();
 }
 }
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 3f414c8..b1a60da 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -993,9 +993,9 @@ void Timeline::f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex)
 		return;
 	}
 	if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
-		_vm->_eventMan->f78_showMouse();
+		_vm->_eventMan->showMouse();
 		_vm->_inventoryMan->f354_drawStatusBoxPortrait((ChampionIndex)champIndex);
-		_vm->_eventMan->f77_hideMouse();
+		_vm->_eventMan->hideMouse();
 	} else {
 		setFlag(L0663_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle);
 		_vm->_championMan->drawChampionState((ChampionIndex)champIndex);


Commit: 6a02a571cd5e8df4f70f64eace4fbce03f70faf8
    https://github.com/scummvm/scummvm/commit/6a02a571cd5e8df4f70f64eace4fbce03f70faf8
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rename variables and functions of DisplayMan

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dialog.cpp
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/objectman.cpp
    engines/dm/text.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 9edd146..91a1f99 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -901,7 +901,7 @@ void ChampionMan::wakeUp() {
 	_partyIsSleeping = false;
 	_vm->_waitForInputMaxVerticalBlankCount = 10;
 	_vm->delay(10);
-	_vm->_displayMan->f98_drawFloorAndCeiling();
+	_vm->_displayMan->drawFloorAndCeiling();
 	_vm->_eventMan->_primaryMouseInput = _vm->_eventMan->_primaryMouseInputInterface;
 	_vm->_eventMan->_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputMovement;
 	_vm->_eventMan->_primaryKeyboardInput = _vm->_eventMan->_primaryKeyboardInputInterface;
@@ -1401,7 +1401,7 @@ void ChampionMan::applyAndDrawPendingDamageAndWounds() {
 				blitBox._y2 = 28;
 				blitBox._x1 = textPosX + 7;
 				blitBox._x2 = blitBox._x1 + 31; /* Box is over the champion portrait in the status box */
-				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k16_damageToChampionBig), &blitBox, k16_byteWidth, k10_ColorFlesh, 29);
+				_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k16_damageToChampionBig), &blitBox, k16_byteWidth, k10_ColorFlesh, 29);
 				// Check the number of digits and sets the position accordingly.
 				if (pendingDamage < 10) // 1 digit
 					textPosX += 21;
@@ -1415,7 +1415,7 @@ void ChampionMan::applyAndDrawPendingDamageAndWounds() {
 				blitBox._y2 = 6;
 				blitBox._x1 = textPosX;
 				blitBox._x2 = blitBox._x1 + 47; /* Box is over the champion name in the status box */
-				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k15_damageToChampionSmallIndice), &blitBox, k24_byteWidth, k10_ColorFlesh, 7);
+				_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k15_damageToChampionSmallIndice), &blitBox, k24_byteWidth, k10_ColorFlesh, 7);
 				// Check the number of digits and sets the position accordingly.
 				if (pendingDamage < 10) // 1 digit
 					textPosX += 19;
@@ -1491,8 +1491,8 @@ void ChampionMan::championKill(uint16 champIndex) {
 	if (curChampion->_poisonEventCount)
 		unpoison(champIndex);
 
-	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_vm->_displayMan->D24_fillScreenBox(_boxChampionIcons[curChampionIconIndex], k0_ColorBlack);
+	_vm->_displayMan->_useByteBoxCoordinates = false;
+	_vm->_displayMan->fillScreenBox(_boxChampionIcons[curChampionIconIndex], k0_ColorBlack);
 	drawChampionState((ChampionIndex)champIndex);
 
 	int16 aliveChampionIndex;
@@ -1871,8 +1871,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	Champion *championPtr = &_champions[previousPartyChampionCount];
 	championPtr->resetToZero();
 	// Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portraits could be missing in the data)
-	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
-	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, _boxChampionPortrait, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency, 87, 29);
+	_vm->_displayMan->_useByteBoxCoordinates = true;
+	_vm->_displayMan->blitToBitmap(_vm->_displayMan->getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, _boxChampionPortrait, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency, 87, 29);
 	championPtr->_actionIndex = k255_ChampionActionNone;
 	championPtr->_enableActionEventIndex = -1;
 	championPtr->_hideDamageReceivedIndex = -1;
@@ -2070,12 +2070,12 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
 		if (barGraphHeight < 25) {
 			box._y1 = 2;
 			box._y2 = 27 - barGraphHeight;
-			_vm->_displayMan->D24_fillScreenBox(box, k12_ColorDarkestGray);
+			_vm->_displayMan->fillScreenBox(box, k12_ColorDarkestGray);
 		}
 		if (barGraphHeight) {
 			box._y1 = 27 - barGraphHeight;
 			box._y2 = 26;
-			_vm->_displayMan->D24_fillScreenBox(box, _championColor[champIndex]);
+			_vm->_displayMan->fillScreenBox(box, _championColor[champIndex]);
 		}
 		box._x1 += 7;
 		box._x2 += 7;
@@ -2120,7 +2120,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		return;
 
 	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
-	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	_vm->_displayMan->_useByteBoxCoordinates = false;
 	_vm->_eventMan->showMouse();
 	if (getFlag(championAttributes, k0x1000_ChampionAttributeStatusBox)) {
 		Box box;
@@ -2129,7 +2129,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		box._x1 = championStatusBoxX;
 		box._x2 = box._x1 + 66;
 		if (curChampion->_currHealth) {
-			_vm->_displayMan->D24_fillScreenBox(box, k12_ColorDarkestGray);
+			_vm->_displayMan->fillScreenBox(box, k12_ColorDarkestGray);
 			int16 nativeBitmapIndices[3];
 			for (uint16 i = 0; i < 3; ++i)
 				nativeBitmapIndices[i] = 0;
@@ -2145,7 +2145,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 				nativeBitmapIndices[borderCount++] = k37_BorderPartyShieldIndice;
 
 			while (borderCount--)
-				_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndices[borderCount]), &box, k40_byteWidth, k10_ColorFlesh, 29);
+				_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(nativeBitmapIndices[borderCount]), &box, k40_byteWidth, k10_ColorFlesh, 29);
 
 			if (isInventoryChampion) {
 				_vm->_inventoryMan->f354_drawStatusBoxPortrait(champIndex);
@@ -2153,7 +2153,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			} else
 				setFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand);
 		} else {
-			_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), &box, k40_byteWidth, kM1_ColorNoTransparency, 29);
+			_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), &box, k40_byteWidth, kM1_ColorNoTransparency, 29);
 			_vm->_textMan->f53_printToLogicalScreen(championStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, curChampion->_name);
 			_vm->_menuMan->f386_drawActionIcon(champIndex);
 
@@ -2186,7 +2186,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			box._y2 = 6;
 			box._x1 = championStatusBoxX;
 			box._x2 = box._x1 + 42;
-			_vm->_displayMan->D24_fillScreenBox(box, k1_ColorDarkGary);
+			_vm->_displayMan->fillScreenBox(box, k1_ColorDarkGary);
 			_vm->_textMan->f53_printToLogicalScreen(championStatusBoxX + 1, 5, nameColor, k1_ColorDarkGary, curChampion->_name);
 		}
 	}
@@ -2200,7 +2200,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			else
 				nativeBitmapIndex = k33_SlotBoxNormalIndice;
 
-			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), boxMouth, k16_byteWidth, k12_ColorDarkestGray, 18);
+			_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(nativeBitmapIndex), boxMouth, k16_byteWidth, k12_ColorDarkestGray, 18);
 			nativeBitmapIndex = k33_SlotBoxNormalIndice;
 			for (int i = k1_ChampionStatStrength; i <= k6_ChampionStatAntifire; i++) {
 				if ((curChampion->_statistics[i][k1_ChampionStatCurrent] < curChampion->_statistics[i][k0_ChampionStatMaximum])) {
@@ -2208,7 +2208,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 					break;
 				}
 			}
-			_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), boxEye, k16_byteWidth, k12_ColorDarkestGray, 18);
+			_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(nativeBitmapIndex), boxEye, k16_byteWidth, k12_ColorDarkestGray, 18);
 			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 		}
 	}
@@ -2257,8 +2257,8 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	}
 	uint16 championIconIndex = getChampionIconIndex(curChampion->_cell, _vm->_dungeonMan->_partyDir);
 	if (getFlag(championAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(championIconIndex))) {
-		_vm->_displayMan->D24_fillScreenBox(_boxChampionIcons[championIconIndex], _championColor[champIndex]);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, _boxChampionIcons[championIconIndex], getChampionIconIndex(curChampion->_dir, _vm->_dungeonMan->_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
+		_vm->_displayMan->fillScreenBox(_boxChampionIcons[championIconIndex], _championColor[champIndex]);
+		_vm->_displayMan->blitToBitmap(_vm->_displayMan->getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_bitmapScreen, _boxChampionIcons[championIconIndex], getChampionIconIndex(curChampion->_dir, _vm->_dungeonMan->_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
 	}
 	if (getFlag(championAttributes, k0x0800_ChampionAttributePanel) && isInventoryChampion) {
 		if (_vm->_pressingMouth)
@@ -2278,7 +2278,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
 	if (getFlag(championAttributes, k0x4000_ChampionAttributeViewport))
-		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+		_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 
 	clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
 	_vm->_eventMan->hideMouse();
@@ -2356,14 +2356,14 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 		nativeBitmapIndex = k35_SlotBoxActingHandIndice;
 
 	if (nativeBitmapIndex != -1) {
-		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+		_vm->_displayMan->_useByteBoxCoordinates = false;
 		if (isInventoryChamp) {
-			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
-												_vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport,
+			_vm->_displayMan->blitToBitmap(_vm->_displayMan->getNativeBitmapOrGraphic(nativeBitmapIndex),
+												_vm->_displayMan->_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport,
 												k12_ColorDarkestGray, _vm->_displayMan->getPixelHeight(nativeBitmapIndex), k136_heightViewport);
 		} else {
-			_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex),
-												_vm->_displayMan->_g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen,
+			_vm->_displayMan->blitToBitmap(_vm->_displayMan->getNativeBitmapOrGraphic(nativeBitmapIndex),
+												_vm->_displayMan->_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen,
 												k12_ColorDarkestGray, _vm->_displayMan->getPixelHeight(nativeBitmapIndex), k136_heightViewport);
 		}
 	}
@@ -2387,12 +2387,12 @@ void ChampionMan::renameChampion(Champion* champ) {
 	displayBox._x1 = 3;
 	displayBox._x2 = displayBox._x1 + 167;
 
-	_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, displayBox, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
-	_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), _vm->_inventoryMan->g32_BoxPanel, k72_byteWidth, k4_ColorCyan, 73);
+	_vm->_displayMan->fillBoxBitmap(_vm->_displayMan->_bitmapViewport, displayBox, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
+	_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), _vm->_inventoryMan->g32_BoxPanel, k72_byteWidth, k4_ColorCyan, 73);
 	_vm->_textMan->f52_printToViewport(177, 58, k13_ColorLightestGray, "_______");
 	_vm->_textMan->f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________");
 	_vm->_eventMan->showMouse();
-	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+	_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 	_vm->_eventMan->setMousePointerToNormal(k0_pointerArrow);
 	_vm->_eventMan->hideMouse();
 	uint16 curCharacterIndex = 0;
@@ -2407,7 +2407,7 @@ void ChampionMan::renameChampion(Champion* champ) {
 		bool championTitleIsFull = ((renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE) && (curCharacterIndex == 19));
 		if (!championTitleIsFull) {
 			_vm->_eventMan->showMouse();
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k9_ColorGold, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k9_ColorGold, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
 			_vm->_eventMan->hideMouse();
 		}
 
@@ -2492,7 +2492,7 @@ void ChampionMan::renameChampion(Champion* champ) {
 				if (!championTitleIsFull) {
 					renameChampionInputCharacterString[0] = curCharacter;
 					_vm->_eventMan->showMouse();
-					_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, renameChampionInputCharacterString, k200_heightScreen);
+					_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, renameChampionInputCharacterString, k200_heightScreen);
 					_vm->_eventMan->hideMouse();
 					renamedChampionString[curCharacterIndex++] = curCharacter;
 					renamedChampionString[curCharacterIndex] = '\0';
@@ -2509,7 +2509,7 @@ void ChampionMan::renameChampion(Champion* champ) {
 		} else if (curCharacter == '\r') { // Carriage return
 			if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex > 0)) {
 				_vm->_eventMan->showMouse();
-				_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
+				_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
 				_vm->_eventMan->hideMouse();
 				renamedChampionStringMode = k2_RENAME_CHAMPION_TITLE;
 				renamedChampionString = champ->_title;
@@ -2523,7 +2523,7 @@ void ChampionMan::renameChampion(Champion* champ) {
 
 			if (!championTitleIsFull) {
 				_vm->_eventMan->showMouse();
-				_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
+				_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
 				_vm->_eventMan->hideMouse();
 			}
 			if (curCharacterIndex == 0) {
diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index ae58b75..c842556 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -44,10 +44,10 @@ void DialogMan::dialogDraw(const char *msg1, const char *msg2, const char *choic
 	static Box dialog2ChoicesPatch = Box(102, 122, 89, 125);
 	static Box dialog4ChoicesPatch = Box(102, 122, 62, 97);
 
-	_vm->_displayMan->f466_loadIntoBitmap(k0_dialogBoxGraphicIndice, _vm->_displayMan->_g296_bitmapViewport);
+	_vm->_displayMan->loadIntoBitmap(k0_dialogBoxGraphicIndice, _vm->_displayMan->_bitmapViewport);
 	//Strangerke: the version should be replaced by a ScummVM/RogueVM (?) string
 	// TODO: replace with ScummVM version string
-	_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 192, 7, k2_ColorLightGray, k1_ColorDarkGary, "V2.2", k136_heightViewport);
+	_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 192, 7, k2_ColorLightGray, k1_ColorDarkGary, "V2.2", k136_heightViewport);
 	int16 choiceCount = 1;
 	if (choice2)
 		choiceCount++;
@@ -59,31 +59,31 @@ void DialogMan::dialogDraw(const char *msg1, const char *msg2, const char *choic
 		choiceCount++;
 
 	if (fading)
-		_vm->_displayMan->f436_STARTEND_FadeToPalette(_vm->_displayMan->_g345_aui_BlankBuffer);
+		_vm->_displayMan->startEndFadeToPalette(_vm->_displayMan->_blankBuffer);
 
 	if (clearScreen)
 		_vm->_displayMan->fillScreen(k0_ColorBlack);
 
-	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	_vm->_displayMan->_useByteBoxCoordinates = false;
 	if (choiceCount == 1) {
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, constBox1, 0, 64, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, constBox2, 0, 39, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, constBox3, 0, 14, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
-		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 114);
+		_vm->_displayMan->blitToBitmap(_vm->_displayMan->_bitmapViewport, _vm->_displayMan->_bitmapViewport, constBox1, 0, 64, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
+		_vm->_displayMan->blitToBitmap(_vm->_displayMan->_bitmapViewport, _vm->_displayMan->_bitmapViewport, constBox2, 0, 39, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
+		_vm->_displayMan->blitToBitmap(_vm->_displayMan->_bitmapViewport, _vm->_displayMan->_bitmapViewport, constBox3, 0, 14, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
+		printCenteredChoice(_vm->_displayMan->_bitmapViewport, choice1, 112, 114);
 	} else if (choiceCount == 2) {
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, dialog2ChoicesPatch, 102, 52, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
-		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77);
-		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 112, 114);
+		_vm->_displayMan->blitToBitmap(_vm->_displayMan->_bitmapViewport, _vm->_displayMan->_bitmapViewport, dialog2ChoicesPatch, 102, 52, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
+		printCenteredChoice(_vm->_displayMan->_bitmapViewport, choice1, 112, 77);
+		printCenteredChoice(_vm->_displayMan->_bitmapViewport, choice2, 112, 114);
 	} else if (choiceCount == 3) {
-		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77);
-		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 59, 114);
-		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 166, 114);
+		printCenteredChoice(_vm->_displayMan->_bitmapViewport, choice1, 112, 77);
+		printCenteredChoice(_vm->_displayMan->_bitmapViewport, choice2, 59, 114);
+		printCenteredChoice(_vm->_displayMan->_bitmapViewport, choice3, 166, 114);
 	} else if (choiceCount == 4) {
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, dialog4ChoicesPatch, 102, 99, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
-		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 59, 77);
-		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 166, 77);
-		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 59, 114);
-		printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice4, 166, 114);
+		_vm->_displayMan->blitToBitmap(_vm->_displayMan->_bitmapViewport, _vm->_displayMan->_bitmapViewport, dialog4ChoicesPatch, 102, 99, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport);
+		printCenteredChoice(_vm->_displayMan->_bitmapViewport, choice1, 59, 77);
+		printCenteredChoice(_vm->_displayMan->_bitmapViewport, choice2, 166, 77);
+		printCenteredChoice(_vm->_displayMan->_bitmapViewport, choice3, 59, 114);
+		printCenteredChoice(_vm->_displayMan->_bitmapViewport, choice4, 166, 114);
 	}
 
 	int16 textPosX;
@@ -94,14 +94,14 @@ void DialogMan::dialogDraw(const char *msg1, const char *msg2, const char *choic
 		if (isMessageOnTwoLines(msg1, L1312_ac_StringPart1, L1313_ac_StringPart2)) {
 			textPosY = 21;
 			textPosX = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
 			textPosY += 8;
 			textPosX = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport);
 			textPosY += 8;
 		} else {
 			textPosX = 113 - ((strlen(msg1) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, msg1, k136_heightViewport);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, msg1, k136_heightViewport);
 			textPosY += 8;
 		}
 	}
@@ -110,13 +110,13 @@ void DialogMan::dialogDraw(const char *msg1, const char *msg2, const char *choic
 		char L1313_ac_StringPart2[70];
 		if (isMessageOnTwoLines(msg2, L1312_ac_StringPart1, L1313_ac_StringPart2)) {
 			textPosX = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
 			textPosY += 8;
 			textPosX = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport);
 		} else {
 			textPosX = 113 - ((strlen(msg2) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, msg2, k136_heightViewport);
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, msg2, k136_heightViewport);
 		}
 	}
 	if (screenDialog) {
@@ -126,17 +126,17 @@ void DialogMan::dialogDraw(const char *msg1, const char *msg2, const char *choic
 		displayBox._x1 = 47;
 		displayBox._x2 = 270;
 		_vm->_eventMan->showMouse();
-		_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->_g296_bitmapViewport, &displayBox, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport);
+		_vm->_displayMan->blitToScreen(_vm->_displayMan->_bitmapViewport, &displayBox, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport);
 		_vm->_eventMan->hideMouse();
 	} else {
-		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+		_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 		_vm->delay(1);
 	}
 
 	if (fading)
-		_vm->_displayMan->f436_STARTEND_FadeToPalette(_vm->_displayMan->_g347_paletteTopAndBottomScreen);
+		_vm->_displayMan->startEndFadeToPalette(_vm->_displayMan->_paletteTopAndBottomScreen);
 
-	_vm->_displayMan->_g297_drawFloorAndCeilingRequested = true;
+	_vm->_displayMan->_drawFloorAndCeilingRequested = true;
 	_vm->_displayMan->updateScreen();
 }
 
@@ -193,68 +193,68 @@ int16 DialogMan::getChoice(uint16 choiceCount, uint16 dialogSetIndex, int16 driv
 			_selectedDialogChoice = k1_DIALOG_CHOICE_1;
 		}
 	} while (_selectedDialogChoice == 99);
-	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	_vm->_displayMan->_useByteBoxCoordinates = false;
 	L1304_s_BoxA = _vm->_eventMan->_primaryMouseInput[_selectedDialogChoice - 1]._hitbox;
 	L1304_s_BoxA._x1 -= 3;
 	L1304_s_BoxA._x2 += 3;
 	L1304_s_BoxA._y1 -= 3;
 	L1304_s_BoxA._y2 += 4;
 	_vm->_eventMan->showMouse();
-	_vm->_displayMan->_g297_drawFloorAndCeilingRequested = true;
+	_vm->_displayMan->_drawFloorAndCeilingRequested = true;
 	L1303_s_BoxB._x1 = 0;
 	L1303_s_BoxB._y1 = 0;
 	L1303_s_BoxB._y2 = L1304_s_BoxA._y2 - L1304_s_BoxA._y1 + 3;
 	L1303_s_BoxB._x2 = L1304_s_BoxA._x2 - L1304_s_BoxA._x1 + 3;
-	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_g296_bitmapViewport,
+	_vm->_displayMan->blitToBitmap(_vm->_displayMan->_bitmapScreen, _vm->_displayMan->_bitmapViewport,
 										L1303_s_BoxB, L1304_s_BoxA._x1, L1304_s_BoxA._y1, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 25);
 	_vm->delay(1);
 	L1303_s_BoxB = L1304_s_BoxA;
 	L1303_s_BoxB._y2 = L1303_s_BoxB._y1;
-	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
+	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
 	L1303_s_BoxB = L1304_s_BoxA;
 	L1303_s_BoxB._x2 = L1303_s_BoxB._x1;
 	L1303_s_BoxB._y2--;
-	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
+	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
 	L1303_s_BoxB = L1304_s_BoxA;
 	L1303_s_BoxB._y2--;
 	L1303_s_BoxB._y1 = L1303_s_BoxB._y2;
 	L1303_s_BoxB._x1 -= 2;
-	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
+	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
 	L1303_s_BoxB = L1304_s_BoxA;
 	L1303_s_BoxB._x1 = L1303_s_BoxB._x2;
-	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
+	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
 	_vm->delay(2);
 	L1303_s_BoxB = L1304_s_BoxA;
 	L1303_s_BoxB._y1++;
 	L1303_s_BoxB._y2 = L1303_s_BoxB._y1;
 	L1303_s_BoxB._x2 -= 2;
-	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
+	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
 	L1303_s_BoxB = L1304_s_BoxA;
 	L1303_s_BoxB._x1++;
 	L1303_s_BoxB._x2 = L1303_s_BoxB._x1;
 	L1303_s_BoxB._y2--;
-	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
+	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
 	L1303_s_BoxB = L1304_s_BoxA;
 	L1303_s_BoxB._x2--;
 	L1303_s_BoxB._x1 = L1303_s_BoxB._x2;
-	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
+	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
 	L1303_s_BoxB = L1304_s_BoxA;
 	L1303_s_BoxB._y1 = L1303_s_BoxB._y2 = L1303_s_BoxB._y2 - 2;
 	L1303_s_BoxB._x1++;
-	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
+	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
 	L1303_s_BoxB = L1304_s_BoxA;
 	L1303_s_BoxB._y1 = L1303_s_BoxB._y2 = L1303_s_BoxB._y2 + 2;
 	L1303_s_BoxB._x1--;
 	L1303_s_BoxB._x2 += 2;
-	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k13_ColorLightestGray);
+	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k13_ColorLightestGray);
 	L1303_s_BoxB = L1304_s_BoxA;
 	L1303_s_BoxB._x1 = L1303_s_BoxB._x2 = L1303_s_BoxB._x2 + 3;
 	L1303_s_BoxB._y2 += 2;
-	_vm->_displayMan->D24_fillScreenBox(L1303_s_BoxB, k13_ColorLightestGray);
+	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k13_ColorLightestGray);
 	_vm->delay(2);
 	L1304_s_BoxA._x2 += 3;
 	L1304_s_BoxA._y2 += 3;
-	_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g348_bitmapScreen,
+	_vm->_displayMan->blitToBitmap(_vm->_displayMan->_bitmapViewport, _vm->_displayMan->_bitmapScreen,
 										L1304_s_BoxA, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 25, k200_heightScreen);
 	_vm->_eventMan->hideMouse();
 	_vm->_eventMan->_primaryMouseInput = L1298_ps_PrimaryMouseInputBackup;
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index a51132c..9eefbff 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -236,7 +236,7 @@ bool DMEngine::hasFeature(EngineFeature f) const {
 Common::Error DMEngine::loadGameState(int slot) {
 	if (loadgame(slot) != kM1_LoadgameFailure) {
 		_displayMan->fillScreen(k0_ColorBlack);
-		_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_palDungeonView[0]);
+		_displayMan->startEndFadeToPalette(_displayMan->_palDungeonView[0]);
 		_newGameFl = k0_modeLoadSavedGame;
 
 		startGame();
@@ -267,10 +267,10 @@ uint16 DMEngine::getScaledProduct(uint16 val, uint16 scale, uint16 vale2) {
 
 void DMEngine::initializeGame() {
 	initMemoryManager();
-	_displayMan->f479_loadGraphics();
-	_displayMan->f460_initializeGraphicData();
-	_displayMan->f94_loadFloorSet(k0_FloorSetStone);
-	_displayMan->f95_loadWallSet(k0_WallSetStone);
+	_displayMan->loadGraphics();
+	_displayMan->initializeGraphicData();
+	_displayMan->loadFloorSet(k0_FloorSetStone);
+	_displayMan->loadWallSet(k0_WallSetStone);
 
 	_sound->f503_loadSounds(); // @ F0506_AMIGA_AllocateData
 
@@ -299,10 +299,10 @@ void DMEngine::initializeGame() {
 		}
 	} while (loadgame(saveSlot) != k1_LoadgameSuccess);
 
-	_displayMan->f466_loadIntoBitmap(k11_MenuSpellAreLinesIndice, _menuMan->_gK73_bitmapSpellAreaLines); // @ F0396_MENUS_LoadSpellAreaLinesBitmap
+	_displayMan->loadIntoBitmap(k11_MenuSpellAreLinesIndice, _menuMan->_gK73_bitmapSpellAreaLines); // @ F0396_MENUS_LoadSpellAreaLinesBitmap
 
 	// There was some memory wizardy for the Amiga platform, I skipped that part
-	_displayMan->f461_allocateFlippedWallBitmaps();
+	_displayMan->allocateFlippedWallBitmaps();
 
 	startGame();
 	if (_newGameFl)
@@ -314,10 +314,10 @@ void DMEngine::initializeGame() {
 void DMEngine::initMemoryManager() {
 	static uint16 palSwoosh[16] = {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}; // @ K0057_aui_Palette_Swoosh
 
-	_displayMan->f508_buildPaletteChangeCopperList(palSwoosh, palSwoosh);
+	_displayMan->buildPaletteChangeCopperList(palSwoosh, palSwoosh);
 	for (uint16 i = 0; i < 16; ++i) {
-		_displayMan->_g347_paletteTopAndBottomScreen[i] = _displayMan->_palDungeonView[0][i];
-		_displayMan->_g346_paletteMiddleScreen[i] = _displayMan->_palDungeonView[0][i];
+		_displayMan->_paletteTopAndBottomScreen[i] = _displayMan->_palDungeonView[0][i];
+		_displayMan->_paletteMiddleScreen[i] = _displayMan->_palDungeonView[0][i];
 	}
 }
 
@@ -345,20 +345,20 @@ void DMEngine::startGame() {
 	processNewPartyMap(_dungeonMan->_partyMapIndex);
 
 	if (!_newGameFl) {
-		_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);
-		_displayMan->_g578_useByteBoxCoordinates = false;
+		_displayMan->startEndFadeToPalette(_displayMan->_paletteTopAndBottomScreen);
+		_displayMan->_useByteBoxCoordinates = false;
 		delay(1);
-		_displayMan->D24_fillScreenBox(boxScreenTop, k0_ColorBlack);
-		_displayMan->D24_fillScreenBox(boxScreenRight, k0_ColorBlack);
-		_displayMan->D24_fillScreenBox(boxScreenBottom, k0_ColorBlack);
+		_displayMan->fillScreenBox(boxScreenTop, k0_ColorBlack);
+		_displayMan->fillScreenBox(boxScreenRight, k0_ColorBlack);
+		_displayMan->fillScreenBox(boxScreenBottom, k0_ColorBlack);
 	} else {
-		_displayMan->_g578_useByteBoxCoordinates = false;
-		_displayMan->D24_fillScreenBox(boxScreenTop, k0_ColorBlack);
-		_displayMan->D24_fillScreenBox(boxScreenRight, k0_ColorBlack);
-		_displayMan->D24_fillScreenBox(boxScreenBottom, k0_ColorBlack);
+		_displayMan->_useByteBoxCoordinates = false;
+		_displayMan->fillScreenBox(boxScreenTop, k0_ColorBlack);
+		_displayMan->fillScreenBox(boxScreenRight, k0_ColorBlack);
+		_displayMan->fillScreenBox(boxScreenBottom, k0_ColorBlack);
 	}
 
-	_displayMan->f508_buildPaletteChangeCopperList(_displayMan->_palDungeonView[0], _displayMan->_g347_paletteTopAndBottomScreen);
+	_displayMan->buildPaletteChangeCopperList(_displayMan->_palDungeonView[0], _displayMan->_paletteTopAndBottomScreen);
 	_menuMan->f395_drawMovementArrows();
 	_championMan->resetDataToStartGame();
 	_gameTimeTicking = true;
@@ -367,7 +367,7 @@ void DMEngine::startGame() {
 void DMEngine::processNewPartyMap(uint16 mapIndex) {
 	_groupMan->f194_removeAllActiveGroups();
 	_dungeonMan->setCurrentMapAndPartyMap(mapIndex);
-	_displayMan->f96_loadCurrentMapGraphics();
+	_displayMan->loadCurrentMapGraphics();
 	_groupMan->f195_addAllActiveGroups();
 	_inventoryMan->f337_setDungeonViewPalette();
 }
@@ -451,8 +451,8 @@ void DMEngine::gameloop() {
 
 		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) {
 			Box box(0, 223, 0, 135);
-			_displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // (possibly dummy code)
-			_displayMan->f128_drawDungeon(_dungeonMan->_partyDir, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
+			_displayMan->fillBoxBitmap(_displayMan->_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // (possibly dummy code)
+			_displayMan->drawDungeon(_dungeonMan->_partyDir, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
 			if (_setMousePointerToObjectInMainLoop) {
 				_setMousePointerToObjectInMainLoop = false;
 				_eventMan->showMouse();
@@ -547,23 +547,23 @@ void DMEngine::processEntrance() {
 	_entranceDoorAnimSteps[8] = _entranceDoorAnimSteps[7] + 128 * 161;
 	_entranceDoorAnimSteps[9] = _entranceDoorAnimSteps[8] + 128 * 161 * 2;
 
-	_displayMan->f466_loadIntoBitmap(k3_entranceRightDoorGraphicIndice, _entranceDoorAnimSteps[4]);
-	_displayMan->f466_loadIntoBitmap(k2_entranceLeftDoorGraphicIndice, _entranceDoorAnimSteps[0]);
-	_interfaceCredits = _displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice);
-	_displayMan->_g578_useByteBoxCoordinates = false;
+	_displayMan->loadIntoBitmap(k3_entranceRightDoorGraphicIndice, _entranceDoorAnimSteps[4]);
+	_displayMan->loadIntoBitmap(k2_entranceLeftDoorGraphicIndice, _entranceDoorAnimSteps[0]);
+	_interfaceCredits = _displayMan->getNativeBitmapOrGraphic(k5_creditsGraphicIndice);
+	_displayMan->_useByteBoxCoordinates = false;
 	Box displayBox;
 	displayBox._x1 = 0;
 	displayBox._x2 = 100;
 	displayBox._y1 = 0;
 	displayBox._y2 = 160;
 	for (uint16 idx = 1; idx < 4; idx++) {
-		_displayMan->f132_blitToBitmap(_entranceDoorAnimSteps[0], _entranceDoorAnimSteps[idx], displayBox, idx << 2, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161);
+		_displayMan->blitToBitmap(_entranceDoorAnimSteps[0], _entranceDoorAnimSteps[idx], displayBox, idx << 2, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161);
 		displayBox._x2 -= 4;
 	}
 	displayBox._x2 = 127;
 	for (uint16 idx = 5; idx < 8; idx++) {
 		displayBox._x1 += 4;
-		_displayMan->f132_blitToBitmap(_entranceDoorAnimSteps[4], _entranceDoorAnimSteps[idx], displayBox, 0, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161);
+		_displayMan->blitToBitmap(_entranceDoorAnimSteps[4], _entranceDoorAnimSteps[idx], displayBox, 0, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161);
 	}
 
 	do {
@@ -638,23 +638,23 @@ void DMEngine::endGame(bool doNotDrawCreditsOnly) {
 		delay(240);
 	}
 
-	if (_displayMan->_g322_paletteSwitchingEnabled) {
+	if (_displayMan->_paletteSwitchingEnabled) {
 		uint16 oldPalTopAndBottomScreen[16];
 		for (uint16 i = 0; i < 16; ++i)
-			oldPalTopAndBottomScreen[i] = _displayMan->_g347_paletteTopAndBottomScreen[i];
+			oldPalTopAndBottomScreen[i] = _displayMan->_paletteTopAndBottomScreen[i];
 		for (int i = 0; i <= 7; i++) {
 			delay(1);
 			for (int colIdx = 0; colIdx < 16; colIdx++) {
-				_displayMan->_g346_paletteMiddleScreen[colIdx] = _displayMan->f431_getDarkenedColor(_displayMan->_g346_paletteMiddleScreen[colIdx]);
-				_displayMan->_g347_paletteTopAndBottomScreen[colIdx] = _displayMan->f431_getDarkenedColor(_displayMan->_g347_paletteTopAndBottomScreen[colIdx]);
+				_displayMan->_paletteMiddleScreen[colIdx] = _displayMan->getDarkenedColor(_displayMan->_paletteMiddleScreen[colIdx]);
+				_displayMan->_paletteTopAndBottomScreen[colIdx] = _displayMan->getDarkenedColor(_displayMan->_paletteTopAndBottomScreen[colIdx]);
 			}
 		}
-		_displayMan->_g322_paletteSwitchingEnabled = false;
+		_displayMan->_paletteSwitchingEnabled = false;
 		delay(1);
 		for (uint16 i = 0; i < 16; ++i)
-			_displayMan->_g347_paletteTopAndBottomScreen[i] = oldPalTopAndBottomScreen[i];
+			_displayMan->_paletteTopAndBottomScreen[i] = oldPalTopAndBottomScreen[i];
 	} else
-		_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
+		_displayMan->startEndFadeToPalette(_displayMan->_blankBuffer);
 
 	uint16 darkBluePalette[16];
 	if (doNotDrawCreditsOnly) {
@@ -664,8 +664,8 @@ void DMEngine::endGame(bool doNotDrawCreditsOnly) {
 			for (int16 championIndex = k0_ChampionFirst; championIndex < _championMan->_partyChampionCount; championIndex++) {
 				int16 textPosY = championIndex * 48;
 				Champion *curChampion = &_championMan->_champions[championIndex];
-				_displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k208_wallOrn_43_champMirror), &championMirrorBox, k32_byteWidth, k10_ColorFlesh, 43);
-				_displayMan->f21_blitToScreen(curChampion->_portrait, &championPortraitBox, k16_byteWidth, k1_ColorDarkGary, 29);
+				_displayMan->blitToScreen(_displayMan->getNativeBitmapOrGraphic(k208_wallOrn_43_champMirror), &championMirrorBox, k32_byteWidth, k10_ColorFlesh, 43);
+				_displayMan->blitToScreen(curChampion->_portrait, &championPortraitBox, k16_byteWidth, k1_ColorDarkGary, 29);
 				_textMan->f443_endgamePrintString(87, textPosY += 14, k9_ColorGold, curChampion->_name);
 				int textPosX = (6 * strlen(curChampion->_name)) + 87;
 				char championTitleFirstCharacter = curChampion->_title[0];
@@ -689,28 +689,28 @@ void DMEngine::endGame(bool doNotDrawCreditsOnly) {
 				championPortraitBox._y1 += 48;
 				championPortraitBox._y1 += 48;
 			}
-			_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);
+			_displayMan->startEndFadeToPalette(_displayMan->_paletteTopAndBottomScreen);
 			_engineShouldQuit = true;
 			return;
 		}
 T0444017:
 		_displayMan->fillScreen(k0_ColorBlack);
-		_displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k6_theEndIndice), &theEndBox, k40_byteWidth, kM1_ColorNoTransparency, 14);
+		_displayMan->blitToScreen(_displayMan->getNativeBitmapOrGraphic(k6_theEndIndice), &theEndBox, k40_byteWidth, kM1_ColorNoTransparency, 14);
 		for (uint16 i = 0; i < 16; ++i)
 			darkBluePalette[i] = D01_RGB_DARK_BLUE;
 		uint16 curPalette[16];
 		for (uint16 i = 0; i < 15; ++i)
 			curPalette[i] = darkBluePalette[i];
 		curPalette[15] = D09_RGB_WHITE;
-		_displayMan->f436_STARTEND_FadeToPalette(curPalette);
+		_displayMan->startEndFadeToPalette(curPalette);
 		_displayMan->updateScreen();
 		if (waitBeforeDrawingRestart)
 			delay(300);
 
 		if (_restartGameAllowed) {
-			_displayMan->_g578_useByteBoxCoordinates = false;
-			_displayMan->D24_fillScreenBox(restartOuterBox, k12_ColorDarkestGray);
-			_displayMan->D24_fillScreenBox(restartInnerBox, k0_ColorBlack);
+			_displayMan->_useByteBoxCoordinates = false;
+			_displayMan->fillScreenBox(restartOuterBox, k12_ColorDarkestGray);
+			_displayMan->fillScreenBox(restartInnerBox, k0_ColorBlack);
 
 			switch (getGameLanguage()) { // localized
 			default:
@@ -724,15 +724,15 @@ T0444017:
 			_eventMan->_primaryMouseInput = _eventMan->_primaryMouseInputRestartGame;
 			_eventMan->discardAllInput();
 			_eventMan->hideMouse();
-			_displayMan->f436_STARTEND_FadeToPalette(curPalette);
+			_displayMan->startEndFadeToPalette(curPalette);
 			for (int16 verticalBlankCount = 900; --verticalBlankCount && !_restartGameRequest; delay(1))
 				_eventMan->processCommandQueue();
 
 			_eventMan->showMouse();
 			if (_restartGameRequest) {
-				_displayMan->f436_STARTEND_FadeToPalette(darkBluePalette);
+				_displayMan->startEndFadeToPalette(darkBluePalette);
 				_displayMan->fillScreen(k0_ColorBlack);
-				_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_palDungeonView[0]);
+				_displayMan->startEndFadeToPalette(_displayMan->_palDungeonView[0]);
 				_newGameFl = k0_modeLoadSavedGame;
 				if (loadgame(1) != kM1_LoadgameFailure) {
 					startGame();
@@ -744,19 +744,19 @@ T0444017:
 			}
 		}
 
-		_displayMan->f436_STARTEND_FadeToPalette(darkBluePalette);
+		_displayMan->startEndFadeToPalette(darkBluePalette);
 	}
 	Box box(0, 319, 0, 199);
-	_displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice), &box, k160_byteWidthScreen, kM1_ColorNoTransparency, k200_heightScreen);
+	_displayMan->blitToScreen(_displayMan->getNativeBitmapOrGraphic(k5_creditsGraphicIndice), &box, k160_byteWidthScreen, kM1_ColorNoTransparency, k200_heightScreen);
 
-	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_palCredits);
+	_displayMan->startEndFadeToPalette(_displayMan->_palCredits);
 	_eventMan->waitForMouseOrKeyActivity();
 	if (_engineShouldQuit)
 		return;
 
 	if (_restartGameAllowed && doNotDrawCreditsOnly) {
 		waitBeforeDrawingRestart = false;
-		_displayMan->f436_STARTEND_FadeToPalette(darkBluePalette);
+		_displayMan->startEndFadeToPalette(darkBluePalette);
 		goto T0444017;
 	}
 
@@ -776,7 +776,7 @@ void DMEngine::drawEntrance() {
 	byte *microDungeonCurrentMapData[32];
 
 	_dungeonMan->_partyMapIndex = k255_mapIndexEntrance;
-	_displayMan->_g297_drawFloorAndCeilingRequested = true;
+	_displayMan->_drawFloorAndCeilingRequested = true;
 	_dungeonMan->_currMapWidth = 5;
 	_dungeonMan->_currMapHeight = 5;
 	_dungeonMan->_currMapData = microDungeonCurrentMapData;
@@ -792,30 +792,30 @@ void DMEngine::drawEntrance() {
 		microDungeonSquares[idx + 10] = Square(k1_CorridorElemType, 0);
 	}
 	microDungeonSquares[7] = Square(k1_CorridorElemType, 0);
-	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
+	_displayMan->startEndFadeToPalette(_displayMan->_blankBuffer);
 
 	// note, a global variable is used here in the original
-	_displayMan->f466_loadIntoBitmap(k4_entranceGraphicIndice, _displayMan->_g348_bitmapScreen);
-	_displayMan->f128_drawDungeon(kDirSouth, 2, 0);
+	_displayMan->loadIntoBitmap(k4_entranceGraphicIndice, _displayMan->_bitmapScreen);
+	_displayMan->drawDungeon(kDirSouth, 2, 0);
 
 	if (!_savedScreenForOpenEntranceDoors)
 		_savedScreenForOpenEntranceDoors = new byte[k200_heightScreen * k160_byteWidthScreen * 2];
-	memcpy(_savedScreenForOpenEntranceDoors, _displayMan->_g348_bitmapScreen, 320 * 200);
+	memcpy(_savedScreenForOpenEntranceDoors, _displayMan->_bitmapScreen, 320 * 200);
 
-	_displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _entranceDoorAnimSteps[8], doorsUpperHalfBox, 0, 30, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
-	_displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _entranceDoorAnimSteps[8], doorsLowerHalfBox, 0, 111, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
+	_displayMan->_useByteBoxCoordinates = false, _displayMan->blitToBitmap(_displayMan->_bitmapScreen, _entranceDoorAnimSteps[8], doorsUpperHalfBox, 0, 30, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
+	_displayMan->_useByteBoxCoordinates = false, _displayMan->blitToBitmap(_displayMan->_bitmapScreen, _entranceDoorAnimSteps[8], doorsLowerHalfBox, 0, 111, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161);
 
-	_displayMan->f21_blitToScreen(_entranceDoorAnimSteps[0], &closedDoorLeftBox, k64_byteWidth, kM1_ColorNoTransparency, 161);
-	_displayMan->f21_blitToScreen(_entranceDoorAnimSteps[4], &closedDoorRightBox, k64_byteWidth, kM1_ColorNoTransparency, 161);
-	_displayMan->f436_STARTEND_FadeToPalette(palEntrance);
+	_displayMan->blitToScreen(_entranceDoorAnimSteps[0], &closedDoorLeftBox, k64_byteWidth, kM1_ColorNoTransparency, 161);
+	_displayMan->blitToScreen(_entranceDoorAnimSteps[4], &closedDoorRightBox, k64_byteWidth, kM1_ColorNoTransparency, 161);
+	_displayMan->startEndFadeToPalette(palEntrance);
 }
 
 void DMEngine::openEntranceDoors() {
 	Box rightDoorBox(109, 231, 30, 193);
-	byte *rightDoorBitmap = _displayMan->f489_getNativeBitmapOrGraphic(k3_entranceRightDoorGraphicIndice);
+	byte *rightDoorBitmap = _displayMan->getNativeBitmapOrGraphic(k3_entranceRightDoorGraphicIndice);
 	Box leftDoorBox(0, 100, 30, 193);
 	uint16 leftDoorBlitFrom = 0;
-	byte *leftDoorBitmap = _displayMan->f489_getNativeBitmapOrGraphic(k2_entranceLeftDoorGraphicIndice);
+	byte *leftDoorBitmap = _displayMan->getNativeBitmapOrGraphic(k2_entranceLeftDoorGraphicIndice);
 
 	Box screenBox(0, 319, 0, 199);
 
@@ -825,10 +825,10 @@ void DMEngine::openEntranceDoors() {
 			_sound->f060_SOUND_Play(k02_soundDOOR_RATTLE, 145, 0x40, 0x40);
 		}
 
-		_displayMan->f21_blitToScreen(_savedScreenForOpenEntranceDoors, &screenBox, 160, kM1_ColorNoTransparency, 200);
-		_displayMan->f132_blitToBitmap(leftDoorBitmap, _displayMan->_g348_bitmapScreen, leftDoorBox, leftDoorBlitFrom, 0, 64, k160_byteWidthScreen,
+		_displayMan->blitToScreen(_savedScreenForOpenEntranceDoors, &screenBox, 160, kM1_ColorNoTransparency, 200);
+		_displayMan->blitToBitmap(leftDoorBitmap, _displayMan->_bitmapScreen, leftDoorBox, leftDoorBlitFrom, 0, 64, k160_byteWidthScreen,
 									   kM1_ColorNoTransparency, 161, k200_heightScreen);
-		_displayMan->f132_blitToBitmap(rightDoorBitmap, _displayMan->_g348_bitmapScreen, rightDoorBox, 0, 0, 64, k160_byteWidthScreen,
+		_displayMan->blitToBitmap(rightDoorBitmap, _displayMan->_bitmapScreen, rightDoorBox, 0, 0, 64, k160_byteWidthScreen,
 									   kM1_ColorNoTransparency, 161, k200_heightScreen);
 		_eventMan->discardAllInput();
 		_displayMan->updateScreen();
@@ -861,33 +861,33 @@ void DMEngine::drawTittle() {
 	uint16 L1392_aui_Palette[16];
 
 
-	_displayMan->_g578_useByteBoxCoordinates = false;
+	_displayMan->_useByteBoxCoordinates = false;
 
 	byte *alloactedMem = L1383_l_Bitmap_TitleSteps = new byte[145600 * 2];
 
 	L1384_puc_Bitmap_Title = L1383_l_Bitmap_TitleSteps;
-	_displayMan->f466_loadIntoBitmap(k1_titleGraphicsIndice, L1383_l_Bitmap_TitleSteps);
+	_displayMan->loadIntoBitmap(k1_titleGraphicsIndice, L1383_l_Bitmap_TitleSteps);
 
 	L1383_l_Bitmap_TitleSteps += 320 * 200;
 	for (uint16 i = 0; i < 16; ++i)
 		L1392_aui_Palette[i] = D01_RGB_DARK_BLUE;
 
-	_displayMan->f436_STARTEND_FadeToPalette(L1392_aui_Palette);
+	_displayMan->startEndFadeToPalette(L1392_aui_Palette);
 	_displayMan->fillScreen(k0_ColorBlack);
 	// uncomment this to draw 'Presents'
 	//_displayMan->f132_blitToBitmap(L1384_puc_Bitmap_Title, _displayMan->_g348_bitmapScreen, G0005_s_Graphic562_Box_Title_Presents, 0, 137, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, k200_heightScreen, k200_heightScreen);
 	L1392_aui_Palette[15] = D09_RGB_WHITE;
-	_displayMan->f436_STARTEND_FadeToPalette(L1392_aui_Palette);
-	_displayMan->f132_blitToBitmap(L1384_puc_Bitmap_Title, L1389_puc_Bitmap_Master_StrikesBack = L1383_l_Bitmap_TitleSteps, G0004_s_Graphic562_Box_Title_StrikesBack_Source, 0, 80, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 57);
+	_displayMan->startEndFadeToPalette(L1392_aui_Palette);
+	_displayMan->blitToBitmap(L1384_puc_Bitmap_Title, L1389_puc_Bitmap_Master_StrikesBack = L1383_l_Bitmap_TitleSteps, G0004_s_Graphic562_Box_Title_StrikesBack_Source, 0, 80, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 57);
 	L1383_l_Bitmap_TitleSteps += 320 * 57;
-	_displayMan->f132_blitToBitmap(L1384_puc_Bitmap_Title, L1761_puc_Bitmap_Dungeon_Chaos = L1383_l_Bitmap_TitleSteps, K0078_s_Box_Title_Dungeon_Chaos, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 80);
+	_displayMan->blitToBitmap(L1384_puc_Bitmap_Title, L1761_puc_Bitmap_Dungeon_Chaos = L1383_l_Bitmap_TitleSteps, K0078_s_Box_Title_Dungeon_Chaos, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 80);
 	L1383_l_Bitmap_TitleSteps += 320 * 80;
 	L1384_puc_Bitmap_Title = L1761_puc_Bitmap_Dungeon_Chaos;
 	L1381_ui_DestinationHeight = 12;
 	L1382_i_DestinationPixelWidth = 48;
 	for (L1380_i_Counter = 0; L1380_i_Counter < 18; L1380_i_Counter++) {
 		L1387_apuc_Bitmap_ShrinkedTitle[L1380_i_Counter] = L1383_l_Bitmap_TitleSteps;
-		_displayMan->f129_blitToBitmapShrinkWithPalChange(L1384_puc_Bitmap_Title, L1383_l_Bitmap_TitleSteps, 320, 80, L1382_i_DestinationPixelWidth, L1381_ui_DestinationHeight, _displayMan->_palChangesNoChanges);
+		_displayMan->blitToBitmapShrinkWithPalChange(L1384_puc_Bitmap_Title, L1383_l_Bitmap_TitleSteps, 320, 80, L1382_i_DestinationPixelWidth, L1381_ui_DestinationHeight, _displayMan->_palChangesNoChanges);
 		L1391_aai_Coordinates[L1380_i_Counter][1] = (L1391_aai_Coordinates[L1380_i_Counter][0] = (320 - L1382_i_DestinationPixelWidth) / 2) + L1382_i_DestinationPixelWidth - 1;
 		L1391_aai_Coordinates[L1380_i_Counter][3] = (L1391_aai_Coordinates[L1380_i_Counter][2] = ((int)(160 - L1381_ui_DestinationHeight)) / 2) + L1381_ui_DestinationHeight - 1;
 		L1383_l_Bitmap_TitleSteps += (L1391_aai_Coordinates[L1380_i_Counter][4] = ((L1382_i_DestinationPixelWidth + 15) / 16) * 8) * L1381_ui_DestinationHeight * 2;
@@ -895,7 +895,7 @@ void DMEngine::drawTittle() {
 		L1382_i_DestinationPixelWidth += 16;
 	}
 	L1392_aui_Palette[15] = D01_RGB_DARK_BLUE;
-	_displayMan->f436_STARTEND_FadeToPalette(L1392_aui_Palette);
+	_displayMan->startEndFadeToPalette(L1392_aui_Palette);
 	_displayMan->fillScreen(k0_ColorBlack);
 	L1392_aui_Palette[3] = D05_RGB_DARK_GOLD;
 	L1392_aui_Palette[4] = D02_RGB_LIGHT_BROWN;
@@ -905,27 +905,27 @@ void DMEngine::drawTittle() {
 	L1392_aui_Palette[15] = D07_RGB_RED;
 	L1392_aui_Palette[10] = D01_RGB_DARK_BLUE;
 	L1392_aui_Palette[12] = D01_RGB_DARK_BLUE;
-	_displayMan->f436_STARTEND_FadeToPalette(L1392_aui_Palette);
+	_displayMan->startEndFadeToPalette(L1392_aui_Palette);
 	delay(1);
 	for (L1380_i_Counter = 0; L1380_i_Counter < 18; L1380_i_Counter++) {
 		delay(2);
 		Box box(L1391_aai_Coordinates[L1380_i_Counter]);
-		_displayMan->f132_blitToBitmap(L1387_apuc_Bitmap_ShrinkedTitle[L1380_i_Counter], _displayMan->_g348_bitmapScreen, box, 0, 0, L1391_aai_Coordinates[L1380_i_Counter][4], k160_byteWidthScreen, kM1_ColorNoTransparency, L1391_aai_Coordinates[L1380_i_Counter][3] - L1391_aai_Coordinates[L1380_i_Counter][2] + 1, k200_heightScreen);
+		_displayMan->blitToBitmap(L1387_apuc_Bitmap_ShrinkedTitle[L1380_i_Counter], _displayMan->_bitmapScreen, box, 0, 0, L1391_aai_Coordinates[L1380_i_Counter][4], k160_byteWidthScreen, kM1_ColorNoTransparency, L1391_aai_Coordinates[L1380_i_Counter][3] - L1391_aai_Coordinates[L1380_i_Counter][2] + 1, k200_heightScreen);
 	}
 	delay(25L);
-	_displayMan->f132_blitToBitmap(L1389_puc_Bitmap_Master_StrikesBack, _displayMan->_g348_bitmapScreen, G0003_s_Graphic562_Box_Title_StrikesBack_Destination, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, k0_ColorBlack, 57, k200_heightScreen);
+	_displayMan->blitToBitmap(L1389_puc_Bitmap_Master_StrikesBack, _displayMan->_bitmapScreen, G0003_s_Graphic562_Box_Title_StrikesBack_Destination, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, k0_ColorBlack, 57, k200_heightScreen);
 	L1392_aui_Palette[10] = D00_RGB_BLACK;
 	L1392_aui_Palette[12] = D07_RGB_RED;
-	_displayMan->f436_STARTEND_FadeToPalette(L1392_aui_Palette);
+	_displayMan->startEndFadeToPalette(L1392_aui_Palette);
 	delete[] alloactedMem;
 	delay(75L);
 }
 
 void DMEngine::entranceDrawCredits() {
 	_eventMan->showMouse();
-	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
-	_displayMan->f466_loadIntoBitmap(k5_creditsGraphicIndice, _displayMan->_g348_bitmapScreen);
-	_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_palCredits);
+	_displayMan->startEndFadeToPalette(_displayMan->_blankBuffer);
+	_displayMan->loadIntoBitmap(k5_creditsGraphicIndice, _displayMan->_bitmapScreen);
+	_displayMan->startEndFadeToPalette(_displayMan->_palCredits);
 	delay(50);
 	_eventMan->waitForMouseOrKeyActivity();
 	_newGameFl = k202_modeEntranceDrawCredits;
@@ -1024,7 +1024,7 @@ T0446002:
 	fuseSequenceUpdate();
 	L1428_ps_Group->_type = k26_CreatureTypeGreyLord;
 	fuseSequenceUpdate();
-	_displayMan->_g77_doNotDrawFluxcagesDuringEndgame = true;
+	_displayMan->_doNotDrawFluxcagesDuringEndgame = true;
 	fuseSequenceUpdate();
 	for (AL1424_i_MapX = 0; AL1424_i_MapX < _dungeonMan->_currMapWidth; AL1424_i_MapX++) {
 		for (AL1425_i_MapY = 0; AL1425_i_MapY < _dungeonMan->_currMapHeight; AL1425_i_MapY++) {
@@ -1072,7 +1072,7 @@ T0446002:
 
 void DMEngine::fuseSequenceUpdate() {
 	_timeline->f261_processTimeline();
-	_displayMan->f128_drawDungeon(_dungeonMan->_partyDir, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
+	_displayMan->drawDungeon(_dungeonMan->_partyDir, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
 	_sound->f65_playPendingSound();
 	_eventMan->discardAllInput();
 	_displayMan->updateScreen();
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 5e06e57..00e66fe 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -772,19 +772,19 @@ void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) {
 
 	byte *metaMapData = _currMapData[_currMapWidth - 1] + _currMapHeight;
 
-	_vm->_displayMan->_g264_currMapAllowedCreatureTypes = metaMapData;
+	_vm->_displayMan->_currMapAllowedCreatureTypes = metaMapData;
 	metaMapData += _currMap->_creatureTypeCount;
 
-	memcpy(_vm->_displayMan->_g261_currMapWallOrnIndices, metaMapData, _currMap->_wallOrnCount);
+	memcpy(_vm->_displayMan->_currMapWallOrnIndices, metaMapData, _currMap->_wallOrnCount);
 	metaMapData += _currMap->_wallOrnCount;
 
-	memcpy(_vm->_displayMan->_g262_currMapFloorOrnIndices, metaMapData, _currMap->_floorOrnCount);
+	memcpy(_vm->_displayMan->_currMapFloorOrnIndices, metaMapData, _currMap->_floorOrnCount);
 	metaMapData += _currMap->_floorOrnCount;
 
-	memcpy(_vm->_displayMan->_g263_currMapDoorOrnIndices, metaMapData, _currMap->_doorOrnCount);
+	memcpy(_vm->_displayMan->_currMapDoorOrnIndices, metaMapData, _currMap->_doorOrnCount);
 
 	_currMapInscriptionWallOrnIndex = _currMap->_wallOrnCount;
-	_vm->_displayMan->_g261_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = k0_WallOrnInscription;
+	_vm->_displayMan->_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = k0_WallOrnInscription;
 }
 
 
@@ -884,7 +884,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX,
 		default:
 			assert(false);
 		}
-		_vm->_displayMan->_g289_championPortraitOrdinal = 0; 
+		_vm->_displayMan->_championPortraitOrdinal = 0; 
 		squareIsFakeWall = false;
 T0172010_ClosedFakeWall:
 		setSquareAspectOrnOrdinals(aspectArray, leftRandomWallOrnamentAllowed, frontRandomWallOrnamentAllowed, rightRandomWallOrnamentAllowed, dir, mapX, mapY, squareIsFakeWall);
@@ -896,12 +896,12 @@ T0172010_ClosedFakeWall:
 				if (curThingType == k2_TextstringType) {
 					if (((TextString*)curSensor)->isVisible()) {
 						aspectArray[AL0310_i_SideIndex + 1] = _currMapInscriptionWallOrnIndex + 1;
-						_vm->_displayMan->_g290_inscriptionThing = curThing; /* BUG0_76 The same text is drawn on multiple sides of a wall square. The engine stores only a single text to draw on a wall in a global variable. Even if different texts are placed on different sides of the wall, the same text is drawn on each affected side */
+						_vm->_displayMan->_inscriptionThing = curThing; /* BUG0_76 The same text is drawn on multiple sides of a wall square. The engine stores only a single text to draw on a wall in a global variable. Even if different texts are placed on different sides of the wall, the same text is drawn on each affected side */
 					}
 				} else {
 					aspectArray[AL0310_i_SideIndex + 1] = curSensor->getAttrOrnOrdinal();
 					if (curSensor->getType() == k127_SensorWallChampionPortrait) {
-						_vm->_displayMan->_g289_championPortraitOrdinal = _vm->indexToOrdinal(curSensor->getData());
+						_vm->_displayMan->_championPortraitOrdinal = _vm->indexToOrdinal(curSensor->getData());
 					}
 				}
 			}
@@ -1008,7 +1008,7 @@ int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int
 bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) {
 	if (wallOrnIndex >= 0) {
 		for (uint16 i = 0; i < k3_AlcoveOrnCount; ++i) {
-			if (_vm->_displayMan->_g267_currMapAlcoveOrnIndices[i] == wallOrnIndex)
+			if (_vm->_displayMan->_currMapAlcoveOrnIndices[i] == wallOrnIndex)
 				return true;
 		}
 	}
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 77a9b5b..d5d1e31 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -453,14 +453,14 @@ void EventManager::setPointerToObject(byte* bitmap) {
 	_useObjectAsMousePointerBitmap = true;
 	_useHandAsMousePointerBitmap = false;
 	_mousePointerBitmapUpdated = true;
-	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
+	_vm->_displayMan->_useByteBoxCoordinates = true;
 	byte *L0051_puc_Bitmap = _mousePointerOriginalColorsObject;
 	memset(L0051_puc_Bitmap, 0, 32 * 18);
 
-	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _mousePointerTempBuffer, 16, 16, 16, 16, palChangesMousepointerOjbectIconShadow);
-	_vm->_displayMan->f132_blitToBitmap(_mousePointerTempBuffer, L0051_puc_Bitmap, boxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
-	_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _mousePointerTempBuffer, 16, 16, 16, 16, palChangesMousePointerIcon);
-	_vm->_displayMan->f132_blitToBitmap(_mousePointerTempBuffer, L0051_puc_Bitmap, boxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
+	_vm->_displayMan->blitToBitmapShrinkWithPalChange(bitmap, _mousePointerTempBuffer, 16, 16, 16, 16, palChangesMousepointerOjbectIconShadow);
+	_vm->_displayMan->blitToBitmap(_mousePointerTempBuffer, L0051_puc_Bitmap, boxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18);
+	_vm->_displayMan->blitToBitmapShrinkWithPalChange(bitmap, _mousePointerTempBuffer, 16, 16, 16, 16, palChangesMousePointerIcon);
+	_vm->_displayMan->blitToBitmap(_mousePointerTempBuffer, L0051_puc_Bitmap, boxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18);
 
 	_preventBuildPointerScreenArea = false;
 	buildpointerScreenArea(_mousePos.x, _mousePos.y);
@@ -471,9 +471,9 @@ void EventManager::mouseDropChampionIcon() {
 	uint16 championIconIndex = _vm->ordinalToIndex(_useChampionIconOrdinalAsMousePointerBitmap);
 	_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kM1_ChampionNone);
 	_mousePointerBitmapUpdated = true;
-	bool useByteBoxCoordinatesBackup = _vm->_displayMan->_g578_useByteBoxCoordinates;
-	_vm->_displayMan->f21_blitToScreen(_mousePointerOriginalColorsChampionIcon, &_vm->_championMan->_boxChampionIcons[championIconIndex << 2], 16, k12_ColorDarkestGray, 18);
-	_vm->_displayMan->_g578_useByteBoxCoordinates = useByteBoxCoordinatesBackup;
+	bool useByteBoxCoordinatesBackup = _vm->_displayMan->_useByteBoxCoordinates;
+	_vm->_displayMan->blitToScreen(_mousePointerOriginalColorsChampionIcon, &_vm->_championMan->_boxChampionIcons[championIconIndex << 2], 16, k12_ColorDarkestGray, 18);
+	_vm->_displayMan->_useByteBoxCoordinates = useByteBoxCoordinatesBackup;
 	_preventBuildPointerScreenArea = false;
 }
 
@@ -836,7 +836,7 @@ void EventManager::processCommandQueue() {
 			_vm->_menuMan->f456_drawDisabledMenu();
 			_vm->_championMan->_partyIsSleeping = true;
 			drawSleepScreen();
-			_vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
+			_vm->_displayMan->drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
 			_vm->_waitForInputMaxVerticalBlankCount = 0;
 			_primaryMouseInput = _primaryMouseInputPartySleeping;
 			_secondaryMouseInput = 0;
@@ -862,24 +862,24 @@ void EventManager::processCommandQueue() {
 	if (cmdType == k147_CommandFreezeGame) {
 		_vm->_gameTimeTicking = false;
 		_vm->_menuMan->f456_drawDisabledMenu();
-		_vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 112, 136);
+		_vm->_displayMan->fillBitmap(_vm->_displayMan->_bitmapViewport, k0_ColorBlack, 112, 136);
 
 		switch (_vm->getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY:
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 81, 69, k4_ColorCyan, k0_ColorBlack,
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 81, 69, k4_ColorCyan, k0_ColorBlack,
 												 "GAME FROZEN", k136_heightViewport);
 			break;
 		case Common::DE_DEU:
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 66, 69, k4_ColorCyan, k0_ColorBlack,
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 66, 69, k4_ColorCyan, k0_ColorBlack,
 												 "SPIEL ANGEHALTEN", k136_heightViewport);
 			break;
 		case Common::FR_FRA:
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 84, 69, k4_ColorCyan, k0_ColorBlack,
+			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 84, 69, k4_ColorCyan, k0_ColorBlack,
 												 "JEU BLOQUE", k136_heightViewport);
 			break;
 		}
-		_vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
+		_vm->_displayMan->drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
 		primaryMouseInputBackup = _primaryMouseInput;
 		secondaryMouseInputBackup = _secondaryMouseInput;
 		primaryKeyboardInputBackup = _primaryKeyboardInput;
@@ -1245,9 +1245,9 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 		box._y2 = 28;
 		box._x1 = championIndex * k69_ChampionStatusBoxSpacing;
 		box._x2 = box._x1 + 66;
-		dispMan._g578_useByteBoxCoordinates = false;
-		dispMan.D24_fillScreenBox(box, k0_ColorBlack);
-		dispMan.D24_fillScreenBox(_vm->_championMan->_boxChampionIcons[champMan.getChampionIconIndex(champ->_cell, dunMan._partyDir) * 2], k0_ColorBlack);
+		dispMan._useByteBoxCoordinates = false;
+		dispMan.fillScreenBox(box, k0_ColorBlack);
+		dispMan.fillScreenBox(_vm->_championMan->_boxChampionIcons[champMan.getChampionIconIndex(champ->_cell, dunMan._partyDir) * 2], k0_ColorBlack);
 		_vm->_menuMan->f457_drawEnabledMenus();
 		showMouse();
 		return;
@@ -1403,17 +1403,17 @@ bool EventManager::hasPendingClick(Common::Point& point, MouseButton button) {
 }
 
 void EventManager::drawSleepScreen() {
-	_vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 112, 136);
+	_vm->_displayMan->fillBitmap(_vm->_displayMan->_bitmapViewport, k0_ColorBlack, 112, 136);
 	switch (_vm->getGameLanguage()) { // localized
 	default:
 	case Common::EN_ANY:
-		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 93, 69, k4_ColorCyan, k0_ColorBlack, "WAKE UP", k136_heightViewport);
+		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 93, 69, k4_ColorCyan, k0_ColorBlack, "WAKE UP", k136_heightViewport);
 		break;
 	case Common::DE_DEU:
-		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 96, 69, k4_ColorCyan, k0_ColorBlack, "WECKEN", k136_heightViewport);
+		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 96, 69, k4_ColorCyan, k0_ColorBlack, "WECKEN", k136_heightViewport);
 		break;
 	case Common::FR_FRA:
-		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 72, 69, k4_ColorCyan, k0_ColorBlack, "REVEILLEZ-VOUS", k136_heightViewport);
+		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 72, 69, k4_ColorCyan, k0_ColorBlack, "REVEILLEZ-VOUS", k136_heightViewport);
 		break;
 	}
 }
@@ -1460,15 +1460,15 @@ void EventManager::mouseProcessCommands125To128_clickOnChampionIcon(uint16 champ
 		}
 		_mousePointerBitmapUpdated = true;
 		_useChampionIconOrdinalAsMousePointerBitmap = true;
-		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+		_vm->_displayMan->_useByteBoxCoordinates = false;
 		byte *tmpBitmap = _mousePointerTempBuffer;
 		memset(tmpBitmap, 0, 32 * 18);
 		Box *curChampionIconBox = &_vm->_championMan->_boxChampionIcons[champIconIndex];
 
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, tmpBitmap, championIconShadowBox, curChampionIconBox->_x1, curChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
-		_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(tmpBitmap, _mousePointerOriginalColorsChampionIcon, 32, 18, 32, 18, mousePointerIconShadowBox);
-		_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, _mousePointerOriginalColorsChampionIcon, championIconBox, curChampionIconBox->_x1, curChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
-		_vm->_displayMan->D24_fillScreenBox(*curChampionIconBox, k0_ColorBlack);
+		_vm->_displayMan->blitToBitmap(_vm->_displayMan->_bitmapScreen, tmpBitmap, championIconShadowBox, curChampionIconBox->_x1, curChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
+		_vm->_displayMan->blitToBitmapShrinkWithPalChange(tmpBitmap, _mousePointerOriginalColorsChampionIcon, 32, 18, 32, 18, mousePointerIconShadowBox);
+		_vm->_displayMan->blitToBitmap(_vm->_displayMan->_bitmapScreen, _mousePointerOriginalColorsChampionIcon, championIconBox, curChampionIconBox->_x1, curChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18);
+		_vm->_displayMan->fillScreenBox(*curChampionIconBox, k0_ColorBlack);
 		_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(champIconIndex);
 	} else {
 		_mousePointerBitmapUpdated = true;
@@ -1485,7 +1485,7 @@ void EventManager::mouseProcessCommands125To128_clickOnChampionIcon(uint16 champ
 				setFlag(_vm->_championMan->_champions[championIndex]._attributes, k0x0400_ChampionAttributeIcon);
 				_vm->_championMan->drawChampionState((ChampionIndex)championIndex);
 			} else
-				_vm->_displayMan->D24_fillScreenBox(_vm->_championMan->_boxChampionIcons[championIconIndex], k0_ColorBlack);
+				_vm->_displayMan->fillScreenBox(_vm->_championMan->_boxChampionIcons[championIconIndex], k0_ColorBlack);
 
 			_vm->_championMan->_champions[championCellIndex]._cell = (ViewCell)normalizeModulo4(champIconIndex + _vm->_dungeonMan->_partyDir);
 			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, k0x0400_ChampionAttributeIcon);
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index ceeb285..89cba9d 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -41,7 +41,7 @@
 
 namespace DM {
 DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
-	_g348_bitmapScreen = nullptr;
+	_bitmapScreen = nullptr;
 	_bitmaps = nullptr;
 	_grapItemCount = 0;
 	_packedItemPos = nullptr;
@@ -49,95 +49,95 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	_bitmapDecompressedByteCount = nullptr;
 	_packedBitmaps = nullptr;
 	_bitmaps = nullptr;
-	_g74_tmpBitmap = nullptr;
-	_g84_bitmapFloor = nullptr;
-	_g85_bitmapCeiling = nullptr;
-	_g264_currMapAllowedCreatureTypes = nullptr;
-	_g639_derivedBitmapByteCount = nullptr;
-	_g638_derivedBitmaps = nullptr;
+	_tmpBitmap = nullptr;
+	_bitmapFloor = nullptr;
+	_bitmapCeiling = nullptr;
+	_currMapAllowedCreatureTypes = nullptr;
+	_derivedBitmapByteCount = nullptr;
+	_derivedBitmaps = nullptr;
 
 	_screenWidth = _screenHeight = 0;
-	_g289_championPortraitOrdinal = 0;
-	_g266_currMapViAltarIndex = 0;
-	_g297_drawFloorAndCeilingRequested = true;
+	_championPortraitOrdinal = 0;
+	_currMapViAltarIndex = 0;
+	_drawFloorAndCeilingRequested = true;
 
 	for (int i = 0; i < 4; i++)
-		_g75_palChangesProjectile[i] = nullptr;
+		_palChangesProjectile[i] = nullptr;
 
 	for (int i = 0; i < k3_AlcoveOrnCount; i++)
-		_g267_currMapAlcoveOrnIndices[i] = 0;
+		_currMapAlcoveOrnIndices[i] = 0;
 
 	for (int i = 0; i < k1_FountainOrnCount; i++)
-		_g268_currMapFountainOrnIndices[i] = 0;
+		_currMapFountainOrnIndices[i] = 0;
 
 	for (int i = 0; i < 2; i++) {
 		for (int j = 0; j < 16; j++) {
-			_g101_currMapWallOrnInfo[j][i] = 0;
-			_g102_currMapFloorOrnInfo[j][i] = 0;
+			_currMapWallOrnInfo[j][i] = 0;
+			_currMapFloorOrnInfo[j][i] = 0;
 		}
 
 		for (int j = 0; j < 17; j++)
-			_g103_currMapDoorOrnInfo[j][i] = 0;
+			_currMapDoorOrnInfo[j][i] = 0;
 	}
 
 	for (int i = 0; i < 16; i++) {
-		_g261_currMapWallOrnIndices[i] = 0;
-		_g262_currMapFloorOrnIndices[i] = 0;
+		_currMapWallOrnIndices[i] = 0;
+		_currMapFloorOrnIndices[i] = 0;
 	}
 
 	for (int i = 0; i < 18; i++)
-		_g263_currMapDoorOrnIndices[i] = 0;
-
-	_g290_inscriptionThing = Thing::_none;
-	_g578_useByteBoxCoordinates = false;
-
-	_g85_bitmapCeiling = nullptr;
-	_g84_bitmapFloor = nullptr;
-	_g697_bitmapWallSet_Wall_D3L2 = nullptr;
-	_g696_bitmapWallSet_Wall_D3R2 = nullptr;
-	_g698_bitmapWallSet_Wall_D3LCR = nullptr;
-	_g699_bitmapWallSet_Wall_D2LCR = nullptr;
-	_g700_bitmapWallSet_Wall_D1LCR = nullptr;
-	_g701_bitmapWallSet_Wall_D0L = nullptr;
-	_g702_bitmapWallSet_Wall_D0R = nullptr;
-	_g703_bitmapWallSet_DoorFrameTop_D2LCR = nullptr;
-	_g704_bitmapWallSet_DoorFrameTop_D1LCR = nullptr;
-	_g705_bitmapWallSet_DoorFrameLeft_D3L = nullptr;
-	_g706_bitmapWallSet_DoorFrameLeft_D3C = nullptr;
-	_g707_bitmapWallSet_DoorFrameLeft_D2C = nullptr;
-	_g708_bitmapWallSet_DoorFrameLeft_D1C = nullptr;
-	_g710_bitmapWallSet_DoorFrameRight_D1C = nullptr;
-	_g709_bitmapWallSet_DoorFrameFront = nullptr;
-	_g296_bitmapViewport = nullptr;
-
-	_g231_currentWallSet = -1;
-	_g230_currentFloorSet = -1;
-
-	_g90_bitmapWall_D3LCR_Flipped = nullptr;
-	_g91_bitmapWall_D2LCR_Flipped = nullptr;
-	_g92_bitmapWall_D1LCR_Flipped = nullptr;
-	_g93_bitmapWall_D0L_Flipped = nullptr;
-	_g94_bitmapWall_D0R_Flipped = nullptr;
-	_g95_bitmapWall_D3LCR_Native = nullptr;
-	_g96_bitmapWall_D2LCR_Native = nullptr;
-	_g97_bitmapWall_D1LCR_Native = nullptr;
-	_g98_bitmapWall_D0L_Native = nullptr;
-	_g99_bitmapWall_D0R_Native = nullptr;
-
-	_g322_paletteSwitchingEnabled = false;
-	_g304_dungeonViewPaletteIndex = 0;
+		_currMapDoorOrnIndices[i] = 0;
+
+	_inscriptionThing = Thing::_none;
+	_useByteBoxCoordinates = false;
+
+	_bitmapCeiling = nullptr;
+	_bitmapFloor = nullptr;
+	_bitmapWallSetD3L2 = nullptr;
+	_bitmapWallSetD3R2 = nullptr;
+	_bitmapWallSetD3LCR = nullptr;
+	_bitmapWallSetD2LCR = nullptr;
+	_bitmapWallSetD1LCR = nullptr;
+	bitmapWallSetWallD0L = nullptr;
+	_bitmapWallSetWallD0R = nullptr;
+	_bitmapWallSetDoorFrameTopD2LCR = nullptr;
+	_bitmapWallSetDoorFrameTopD1LCR = nullptr;
+	_bitmapWallSetDoorFrameLeftD3L = nullptr;
+	_bitmapWallSetDoorFrameLeftD3C = nullptr;
+	_bitmapWallSetDoorFrameLeftD2C = nullptr;
+	_bitmapWallSetDoorFrameLeftD1C = nullptr;
+	_bitmapWallSetDoorFrameRightD1C = nullptr;
+	_bitmapWallSetDoorFrameFront = nullptr;
+	_bitmapViewport = nullptr;
+
+	_currentWallSet = -1;
+	_currentFloorSet = -1;
+
+	_bitmapWallD3LCRFlipped = nullptr;
+	_bitmapWallD2LCRFlipped = nullptr;
+	_bitmapWallD1LCRFlipped = nullptr;
+	_bitmapWallD0LFlipped = nullptr;
+	_bitmapWallD0RFlipped = nullptr;
+	_bitmapWallD3LCRNative = nullptr;
+	_bitmapWallD2LCRNative = nullptr;
+	_bitmapWallD1LCRNative = nullptr;
+	_bitmapWallD0LNative = nullptr;
+	_bitmapWallD0RNative = nullptr;
+
+	_paletteSwitchingEnabled = false;
+	_dungeonViewPaletteIndex = 0;
 
 	for (uint16 i = 0; i < 16; ++i) {
-		_g347_paletteTopAndBottomScreen[i] = 0;
-		_g346_paletteMiddleScreen[i] = 0;
+		_paletteTopAndBottomScreen[i] = 0;
+		_paletteMiddleScreen[i] = 0;
 	}
 
 	for (uint16 i = 0; i < 32; i++)
-		_g345_aui_BlankBuffer[i] = 0;
+		_blankBuffer[i] = 0;
 
-	_gK17_paletteFadeFrom = nullptr;
+	_paletteFadeFrom = nullptr;
 	for (uint16 i = 0; i < 16; ++i)
-		_gK16_paletteFadeTemporary[i] = 0;
+		_paletteFadeTemporary[i] = 0;
 
 	initConstants();
 }
@@ -417,7 +417,7 @@ void DisplayMan::initConstants() {
 DisplayMan::~DisplayMan() {
 	delete[] _packedItemPos;
 	delete[] _packedBitmaps;
-	delete[] _g348_bitmapScreen;
+	delete[] _bitmapScreen;
 	if (_bitmaps) {
 		delete[] _bitmaps[0];
 		delete[] _bitmaps;
@@ -425,37 +425,37 @@ DisplayMan::~DisplayMan() {
 	delete[] _bitmapCompressedByteCount;
 	delete[] _bitmapDecompressedByteCount;
 
-	delete[] _g639_derivedBitmapByteCount;
-	if (_g638_derivedBitmaps) {
+	delete[] _derivedBitmapByteCount;
+	if (_derivedBitmaps) {
 		for (uint16 i = 0; i < k730_DerivedBitmapMaximumCount; ++i)
-			delete[] _g638_derivedBitmaps[i];
-		delete[] _g638_derivedBitmaps;
+			delete[] _derivedBitmaps[i];
+		delete[] _derivedBitmaps;
 	}
 
-	delete[] _g85_bitmapCeiling;
-	delete[] _g84_bitmapFloor;
-	delete[] _g697_bitmapWallSet_Wall_D3L2;
-	delete[] _g696_bitmapWallSet_Wall_D3R2;
-	delete[] _g698_bitmapWallSet_Wall_D3LCR;
-	delete[] _g699_bitmapWallSet_Wall_D2LCR;
-	delete[] _g700_bitmapWallSet_Wall_D1LCR;
-	delete[] _g701_bitmapWallSet_Wall_D0L;
-	delete[] _g702_bitmapWallSet_Wall_D0R;
-	delete[] _g703_bitmapWallSet_DoorFrameTop_D2LCR;
-	delete[] _g704_bitmapWallSet_DoorFrameTop_D1LCR;
-	delete[] _g705_bitmapWallSet_DoorFrameLeft_D3L;
-	delete[] _g706_bitmapWallSet_DoorFrameLeft_D3C;
-	delete[] _g707_bitmapWallSet_DoorFrameLeft_D2C;
-	delete[] _g708_bitmapWallSet_DoorFrameLeft_D1C;
-	delete[] _g710_bitmapWallSet_DoorFrameRight_D1C;
-	delete[] _g709_bitmapWallSet_DoorFrameFront;
-	delete[] _g296_bitmapViewport;
-
-	delete[] _g90_bitmapWall_D3LCR_Flipped;
-	delete[] _g91_bitmapWall_D2LCR_Flipped;
-	delete[] _g92_bitmapWall_D1LCR_Flipped;
-	delete[] _g93_bitmapWall_D0L_Flipped;
-	delete[] _g94_bitmapWall_D0R_Flipped;
+	delete[] _bitmapCeiling;
+	delete[] _bitmapFloor;
+	delete[] _bitmapWallSetD3L2;
+	delete[] _bitmapWallSetD3R2;
+	delete[] _bitmapWallSetD3LCR;
+	delete[] _bitmapWallSetD2LCR;
+	delete[] _bitmapWallSetD1LCR;
+	delete[] bitmapWallSetWallD0L;
+	delete[] _bitmapWallSetWallD0R;
+	delete[] _bitmapWallSetDoorFrameTopD2LCR;
+	delete[] _bitmapWallSetDoorFrameTopD1LCR;
+	delete[] _bitmapWallSetDoorFrameLeftD3L;
+	delete[] _bitmapWallSetDoorFrameLeftD3C;
+	delete[] _bitmapWallSetDoorFrameLeftD2C;
+	delete[] _bitmapWallSetDoorFrameLeftD1C;
+	delete[] _bitmapWallSetDoorFrameRightD1C;
+	delete[] _bitmapWallSetDoorFrameFront;
+	delete[] _bitmapViewport;
+
+	delete[] _bitmapWallD3LCRFlipped;
+	delete[] _bitmapWallD2LCRFlipped;
+	delete[] _bitmapWallD1LCRFlipped;
+	delete[] _bitmapWallD0LFlipped;
+	delete[] _bitmapWallD0RFlipped;
 
 	delete _doorFrameD1C;
 }
@@ -463,78 +463,78 @@ DisplayMan::~DisplayMan() {
 void DisplayMan::setUpScreens(uint16 width, uint16 height) {
 	_screenWidth = width;
 	_screenHeight = height;
-	delete[] _g74_tmpBitmap;
-	delete[] _g348_bitmapScreen;
-	_g348_bitmapScreen = new byte[_screenWidth * _screenHeight];
+	delete[] _tmpBitmap;
+	delete[] _bitmapScreen;
+	_bitmapScreen = new byte[_screenWidth * _screenHeight];
 	fillScreen(k0_ColorBlack);
 
-	_g74_tmpBitmap = new byte[_screenWidth * _screenHeight];
-}
-
-
-void DisplayMan::f460_initializeGraphicData() {
-	_g85_bitmapCeiling = new byte[224 * 29];
-	_g84_bitmapFloor = new byte[224 * 70];
-	_g697_bitmapWallSet_Wall_D3L2 = new byte[16 * 49];
-	_g696_bitmapWallSet_Wall_D3R2 = new byte[16 * 49];
-	_g698_bitmapWallSet_Wall_D3LCR = new byte[128 * 51];
-	_g699_bitmapWallSet_Wall_D2LCR = new byte[144 * 71];
-	_g700_bitmapWallSet_Wall_D1LCR = new byte[256 * 111];
-	_g701_bitmapWallSet_Wall_D0L = new byte[32 * 136];
-	_g702_bitmapWallSet_Wall_D0R = new byte[32 * 136];
-	_g703_bitmapWallSet_DoorFrameTop_D2LCR = new byte[96 * 3];
-	_g704_bitmapWallSet_DoorFrameTop_D1LCR = new byte[128 * 4];
-	_g705_bitmapWallSet_DoorFrameLeft_D3L = new byte[32 * 44];
-	_g706_bitmapWallSet_DoorFrameLeft_D3C = new byte[32 * 44];
-	_g707_bitmapWallSet_DoorFrameLeft_D2C = new byte[48 * 65];
-	_g708_bitmapWallSet_DoorFrameLeft_D1C = new byte[32 * 94];
-	_g710_bitmapWallSet_DoorFrameRight_D1C = new byte[32 * 94];
-	_g709_bitmapWallSet_DoorFrameFront = new byte[32 * 123];
-	_g296_bitmapViewport = new byte[224 * 136];
-
-	if (!_g639_derivedBitmapByteCount)
-		_g639_derivedBitmapByteCount = new uint16[k730_DerivedBitmapMaximumCount];
-	if (!_g638_derivedBitmaps) {
-		_g638_derivedBitmaps = new byte *[k730_DerivedBitmapMaximumCount];
+	_tmpBitmap = new byte[_screenWidth * _screenHeight];
+}
+
+
+void DisplayMan::initializeGraphicData() {
+	_bitmapCeiling = new byte[224 * 29];
+	_bitmapFloor = new byte[224 * 70];
+	_bitmapWallSetD3L2 = new byte[16 * 49];
+	_bitmapWallSetD3R2 = new byte[16 * 49];
+	_bitmapWallSetD3LCR = new byte[128 * 51];
+	_bitmapWallSetD2LCR = new byte[144 * 71];
+	_bitmapWallSetD1LCR = new byte[256 * 111];
+	bitmapWallSetWallD0L = new byte[32 * 136];
+	_bitmapWallSetWallD0R = new byte[32 * 136];
+	_bitmapWallSetDoorFrameTopD2LCR = new byte[96 * 3];
+	_bitmapWallSetDoorFrameTopD1LCR = new byte[128 * 4];
+	_bitmapWallSetDoorFrameLeftD3L = new byte[32 * 44];
+	_bitmapWallSetDoorFrameLeftD3C = new byte[32 * 44];
+	_bitmapWallSetDoorFrameLeftD2C = new byte[48 * 65];
+	_bitmapWallSetDoorFrameLeftD1C = new byte[32 * 94];
+	_bitmapWallSetDoorFrameRightD1C = new byte[32 * 94];
+	_bitmapWallSetDoorFrameFront = new byte[32 * 123];
+	_bitmapViewport = new byte[224 * 136];
+
+	if (!_derivedBitmapByteCount)
+		_derivedBitmapByteCount = new uint16[k730_DerivedBitmapMaximumCount];
+	if (!_derivedBitmaps) {
+		_derivedBitmaps = new byte *[k730_DerivedBitmapMaximumCount];
 		for (uint16 i = 0; i < k730_DerivedBitmapMaximumCount; ++i)
-			_g638_derivedBitmaps[i] = nullptr;
+			_derivedBitmaps[i] = nullptr;
 	}
 
-	_g639_derivedBitmapByteCount[k0_DerivedBitmapViewport] = 112 * 136;
-	_g639_derivedBitmapByteCount[k1_DerivedBitmapThievesEyeVisibleArea] = 48 * 95;
-	_g639_derivedBitmapByteCount[k2_DerivedBitmapDamageToCreatureMedium] = 32 * 37;
-	_g639_derivedBitmapByteCount[k3_DerivedBitmapDamageToCreatureSmall] = 24 * 37;
+	_derivedBitmapByteCount[k0_DerivedBitmapViewport] = 112 * 136;
+	_derivedBitmapByteCount[k1_DerivedBitmapThievesEyeVisibleArea] = 48 * 95;
+	_derivedBitmapByteCount[k2_DerivedBitmapDamageToCreatureMedium] = 32 * 37;
+	_derivedBitmapByteCount[k3_DerivedBitmapDamageToCreatureSmall] = 24 * 37;
 
 	for (int16 doorOrnamentIndex = k15_DoorOrnDestroyedMask; doorOrnamentIndex <= k16_DoorOrnThivesEyeMask; doorOrnamentIndex++) {
-		_g103_currMapDoorOrnInfo[doorOrnamentIndex][k0_NativeBitmapIndex] = doorOrnamentIndex + (k301_DoorMaskDestroyedIndice - k15_DoorOrnDestroyedMask);
-		_g103_currMapDoorOrnInfo[doorOrnamentIndex][k1_CoordinateSet] = 1;
+		_currMapDoorOrnInfo[doorOrnamentIndex][k0_NativeBitmapIndex] = doorOrnamentIndex + (k301_DoorMaskDestroyedIndice - k15_DoorOrnDestroyedMask);
+		_currMapDoorOrnInfo[doorOrnamentIndex][k1_CoordinateSet] = 1;
 
-		_g639_derivedBitmapByteCount[doorOrnamentIndex * 2 + k68_DerivedBitmapFirstDoorOrnament_D3] = 24 * 41;
-		_g639_derivedBitmapByteCount[doorOrnamentIndex * 2 + k69_DerivedBitmapFirstDoorOrnament_D2] = 32 * 61;
+		_derivedBitmapByteCount[doorOrnamentIndex * 2 + k68_DerivedBitmapFirstDoorOrnament_D3] = 24 * 41;
+		_derivedBitmapByteCount[doorOrnamentIndex * 2 + k69_DerivedBitmapFirstDoorOrnament_D2] = 32 * 61;
 	}
 
-	_g102_currMapFloorOrnInfo[k15_FloorOrnFootprints][k0_NativeBitmapIndex] = k241_FloorOrn_15_D3L_footprints;
-	_g102_currMapFloorOrnInfo[k15_FloorOrnFootprints][k1_CoordinateSet] = 1;
+	_currMapFloorOrnInfo[k15_FloorOrnFootprints][k0_NativeBitmapIndex] = k241_FloorOrn_15_D3L_footprints;
+	_currMapFloorOrnInfo[k15_FloorOrnFootprints][k1_CoordinateSet] = 1;
 
 	ObjectAspect *objectAspect = _objectAspects209;
 	int16 derivedBitmapIndex;
 	for (int16 objectAspectIndex = 0; objectAspectIndex < k85_ObjAspectCount; ++objectAspectIndex, ++objectAspect) {
 		derivedBitmapIndex = k104_DerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex;
 
-		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(objectAspect->_byteWidth, objectAspect->_height, k16_Scale_D3);
-		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(objectAspect->_byteWidth, objectAspect->_height, k20_Scale_D2);
+		_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapByteCount(objectAspect->_byteWidth, objectAspect->_height, k16_Scale_D3);
+		_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapByteCount(objectAspect->_byteWidth, objectAspect->_height, k20_Scale_D2);
 
 		if (getFlag(objectAspect->_graphicInfo, k0x0001_ObjectFlipOnRightMask)) {
-			_g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2];
+			_derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2];
 			derivedBitmapIndex++;
-			_g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2];
+			_derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2];
 			derivedBitmapIndex++;
 		}
 
 		if (getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask)) {
-			_g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2];
+			_derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2];
 			derivedBitmapIndex++;
-			_g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2];
+			_derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2];
 		}
 	}
 
@@ -544,31 +544,31 @@ void DisplayMan::f460_initializeGraphicData() {
 			derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + projectileAspect->_firstDerivedBitmapRelativeIndex;
 
 			for (int16 projectileScaleIndex = 0; projectileScaleIndex < 6; projectileScaleIndex++) {
-				int16 bitmapByteCount = f459_getScaledBitmapByteCount(projectileAspect->_byteWidth, projectileAspect->_height, _projectileScales[projectileScaleIndex]);
-				_g639_derivedBitmapByteCount[derivedBitmapIndex] = bitmapByteCount;
+				int16 bitmapByteCount = getScaledBitmapByteCount(projectileAspect->_byteWidth, projectileAspect->_height, _projectileScales[projectileScaleIndex]);
+				_derivedBitmapByteCount[derivedBitmapIndex] = bitmapByteCount;
 
 				if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k3_ProjectileAspectHasNone) {
-					_g639_derivedBitmapByteCount[derivedBitmapIndex + 6] = bitmapByteCount;
+					_derivedBitmapByteCount[derivedBitmapIndex + 6] = bitmapByteCount;
 
 					if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k2_ProjectileAspectHasRotation)
-						_g639_derivedBitmapByteCount[derivedBitmapIndex + 12] = bitmapByteCount;
+						_derivedBitmapByteCount[derivedBitmapIndex + 12] = bitmapByteCount;
 				}
 			}
 		}
 	}
 
-	_g75_palChangesProjectile[0] = _palChangesFloorOrnD3;
-	_g75_palChangesProjectile[1] = _palChangesFloorOrnD2;
-	_g75_palChangesProjectile[2] = _g75_palChangesProjectile[3] = _palChangesNoChanges;
+	_palChangesProjectile[0] = _palChangesFloorOrnD3;
+	_palChangesProjectile[1] = _palChangesFloorOrnD2;
+	_palChangesProjectile[2] = _palChangesProjectile[3] = _palChangesNoChanges;
 
 	derivedBitmapIndex = k438_DerivedBitmapFirstExplosion;
 	ExplosionAspect *expAsp = _explosionAspects;
 	for (uint16 expAspIndex = 0; expAspIndex < k4_ExplosionAspectCount; ++expAspIndex, expAsp++) {
 		for (int16 scale = 4; scale < 32; scale += 2)
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(expAsp->_byteWidth, expAsp->_height, scale);
+			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapByteCount(expAsp->_byteWidth, expAsp->_height, scale);
 
 		if (expAspIndex == k3_ExplosionAspectSmoke)
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = expAsp->_byteWidth * expAsp->_height;
+			_derivedBitmapByteCount[derivedBitmapIndex++] = expAsp->_byteWidth * expAsp->_height;
 	}
 
 	derivedBitmapIndex = k495_DerivedBitmapFirstCreature;
@@ -579,39 +579,39 @@ void DisplayMan::f460_initializeGraphicData() {
 		int16 creatureGraphicInfo = g243_CreatureInfo[creatureIndex]._graphicInfo;
 		creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex;
 
-		int16 creatureFrontBitmapD3PixelCount = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
-		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount;
+		int16 creatureFrontBitmapD3PixelCount = getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
+		_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount;
 
-		int16 creatureFrontBitmapD2PixelCount = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
-		_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount;
+		int16 creatureFrontBitmapD2PixelCount = getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
+		_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount;
 
 		if (getFlag(creatureGraphicInfo, k0x0008_CreatureInfoGraphicMaskSide)) {
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k16_Scale_D3);
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k20_Scale_D2);
+			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapByteCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k16_Scale_D3);
+			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapByteCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k20_Scale_D2);
 		}
 
 		if (getFlag(creatureGraphicInfo, k0x0010_CreatureInfoGraphicMaskBack)) {
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount;
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount;
+			_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount;
+			_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount;
 		}
 
 		if (getFlag(creatureGraphicInfo, k0x0020_CreatureInfoGraphicMaskAttack)) {
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k16_Scale_D3);
-			_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k20_Scale_D2);
+			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapByteCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k16_Scale_D3);
+			_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapByteCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k20_Scale_D2);
 		}
 
 		int16 additionalFronGraphicCount = getFlag(creatureGraphicInfo, k0x0003_CreatureInfoGraphicMaskAdditional);
 		if (additionalFronGraphicCount) {
 			do {
-				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront;
-				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
-				_g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
+				_derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront;
+				_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
+				_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2);
 			} while (--additionalFronGraphicCount);
 		}
 	}
 }
 
-void DisplayMan::f479_loadGraphics() {
+void DisplayMan::loadGraphics() {
 	Common::File f;
 	f.open("graphics.dat");
 	_grapItemCount = f.readUint16BE();
@@ -668,15 +668,15 @@ void DisplayMan::unpackGraphics() {
 	}
 	_bitmaps = new byte *[575]; // largest graphic indice (i think)
 	_bitmaps[0] = new byte[unpackedBitmapsSize];
-	f466_loadIntoBitmap(0, _bitmaps[0]);
+	loadIntoBitmap(0, _bitmaps[0]);
 	for (uint16 i = 1; i <= 20; ++i) {
 		_bitmaps[i] = _bitmaps[i - 1] + getPixelWidth(i - 1) * getPixelHeight(i - 1);
-		f466_loadIntoBitmap(i, _bitmaps[i]);
+		loadIntoBitmap(i, _bitmaps[i]);
 	}
 	_bitmaps[22] = _bitmaps[20] + getPixelWidth(20) * getPixelHeight(20);
 	for (uint16 i = 23; i <= 532; ++i) {
 		_bitmaps[i] = _bitmaps[i - 1] + getPixelWidth(i - 1) * getPixelHeight(i - 1);
-		f466_loadIntoBitmap(i, _bitmaps[i]);
+		loadIntoBitmap(i, _bitmaps[i]);
 	}
 	_bitmaps[k557_FontGraphicIndice] = _bitmaps[532] + getPixelWidth(532) * getPixelHeight(532);
 	loadFNT1intoBitmap(k557_FontGraphicIndice, _bitmaps[k557_FontGraphicIndice]);
@@ -697,30 +697,30 @@ void DisplayMan::loadFNT1intoBitmap(uint16 index, byte * destBitmap) {
 	}
 }
 
-void DisplayMan::f461_allocateFlippedWallBitmaps() {
-	_g90_bitmapWall_D3LCR_Flipped = new byte[128 * 51];
-	_g91_bitmapWall_D2LCR_Flipped = new byte[144 * 71];
-	_g92_bitmapWall_D1LCR_Flipped = new byte[256 * 111];
-	_g93_bitmapWall_D0L_Flipped = new byte[32 * 136];
-	_g94_bitmapWall_D0R_Flipped = new byte[32 * 136];
+void DisplayMan::allocateFlippedWallBitmaps() {
+	_bitmapWallD3LCRFlipped = new byte[128 * 51];
+	_bitmapWallD2LCRFlipped = new byte[144 * 71];
+	_bitmapWallD1LCRFlipped = new byte[256 * 111];
+	_bitmapWallD0LFlipped = new byte[32 * 136];
+	_bitmapWallD0RFlipped = new byte[32 * 136];
 }
 
-void DisplayMan::f102_drawDoorBitmap(Frame* frame) {
+void DisplayMan::drawDoorBitmap(Frame* frame) {
 	if (frame->_srcByteWidth) {
-		f132_blitToBitmap(_g74_tmpBitmap, _g296_bitmapViewport, frame->_box, frame->_srcX, frame->_srcY,
+		blitToBitmap(_tmpBitmap, _bitmapViewport, frame->_box, frame->_srcX, frame->_srcY,
 						  frame->_srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, frame->_srcHeight, k136_heightViewport);
 	}
 }
 
-void DisplayMan::f103_drawDoorFrameBitmapFlippedHorizontally(byte *bitmap, Frame *frame) {
+void DisplayMan::drawDoorFrameBitmapFlippedHorizontally(byte *bitmap, Frame *frame) {
 	if (frame->_srcByteWidth) {
-		f130_flipBitmapHorizontal(bitmap, frame->_srcByteWidth, frame->_srcHeight);
-		f132_blitToBitmap(bitmap, _g296_bitmapViewport, frame->_box, frame->_srcX, frame->_srcY,
+		flipBitmapHorizontal(bitmap, frame->_srcByteWidth, frame->_srcHeight);
+		blitToBitmap(bitmap, _bitmapViewport, frame->_box, frame->_srcX, frame->_srcY,
 						  frame->_srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, frame->_srcHeight, k136_heightViewport);
 	}
 }
 
-void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButtonIndex) {
+void DisplayMan::drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButtonIndex) {
 	static byte doorButtonCoordSet[1] = {0}; // @ G0197_auc_Graphic558_DoorButtonCoordinateSet
 	static uint16 doorButtonCoordSets[1][4][6] = { // @ G0208_aaauc_Graphic558_DoorButtonCoordinateSets
 		  // X1, X2, Y1, Y2, ByteWidth, Height
@@ -742,47 +742,47 @@ void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButt
 
 		byte *bitmap = nullptr;
 		if (viewDoorButtonIndex == k3_viewDoorButton_D1C) {
-			bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+			bitmap = getNativeBitmapOrGraphic(nativeBitmapIndex);
 
 			_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordSetRedEagle[0];
 			_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordSetRedEagle[1];
 			_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordSetRedEagle[2];
 			_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordSetRedEagle[3];
 		} else {
-			if (!f491_isDerivedBitmapInCache(doorButtonOrdinal = k102_DerivedBitmapFirstDoorButton + (doorButtonOrdinal * 2) + ((!viewDoorButtonIndex) ? 0 : viewDoorButtonIndex - 1))) {
+			if (!isDerivedBitmapInCache(doorButtonOrdinal = k102_DerivedBitmapFirstDoorButton + (doorButtonOrdinal * 2) + ((!viewDoorButtonIndex) ? 0 : viewDoorButtonIndex - 1))) {
 				uint16 *coordSetBlueGoat = doorButtonCoordSets[coordSet][k3_viewDoorButton_D1C];
-				byte *bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(bitmapNative, f492_getDerivedBitmap(doorButtonOrdinal),
+				byte *bitmapNative = getNativeBitmapOrGraphic(nativeBitmapIndex);
+				blitToBitmapShrinkWithPalChange(bitmapNative, getDerivedBitmap(doorButtonOrdinal),
 													 coordSetBlueGoat[4] << 1, coordSetBlueGoat[5],
 													 // modified code line
 													 coordSetRedEagle[4] << 1,
 													 coordSetRedEagle[5],
 													 (viewDoorButtonIndex == k2_viewDoorButton_D2C) ? _palChangesDoorButtonAndWallOrnD2 : _palChangesDoorButtonAndWallOrnD3);
 
-				f493_addDerivedBitmap(doorButtonOrdinal);
+				addDerivedBitmap(doorButtonOrdinal);
 			}
-			bitmap = f492_getDerivedBitmap(doorButtonOrdinal);
+			bitmap = getDerivedBitmap(doorButtonOrdinal);
 		}
-		f132_blitToBitmap(bitmap, _g296_bitmapViewport, *(Box *)coordSetRedEagle, 0, 0,
+		blitToBitmap(bitmap, _bitmapViewport, *(Box *)coordSetRedEagle, 0, 0,
 						  coordSetRedEagle[4], k112_byteWidthViewport, k10_ColorFlesh, coordSetRedEagle[5], k136_heightViewport);
 	}
 }
 
-void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* topAndBottomScreen) {
+void DisplayMan::viewportSetPalette(uint16* middleScreenPalette, uint16* topAndBottomScreen) {
 	if (middleScreenPalette && topAndBottomScreen)
-		f508_buildPaletteChangeCopperList(middleScreenPalette, topAndBottomScreen);
+		buildPaletteChangeCopperList(middleScreenPalette, topAndBottomScreen);
 
-	f566_viewportBlitToScreen();
+	viewportBlitToScreen();
 }
 
-void DisplayMan::f566_viewportBlitToScreen() {
+void DisplayMan::viewportBlitToScreen() {
 	Box box(0, 223, 33, 33 + 135);
 
-	f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport, k160_byteWidthScreen, kM1_ColorNoTransparency,
+	blitToBitmap(_bitmapViewport, _bitmapScreen, box, 0, 0, k112_byteWidthViewport, k160_byteWidthScreen, kM1_ColorNoTransparency,
 					  k136_heightViewport, k200_heightScreen);
 }
 
-void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) {
+void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
 	uint8 *data = _packedBitmaps + _packedItemPos[index];
 
 	uint16 width = READ_BE_UINT16(data);
@@ -832,7 +832,7 @@ void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) {
 	}
 }
 
-void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
+void DisplayMan::blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
 								   uint16 destByteWidth, Color transparent, int16 srcHeight, int16 destHight) {
 	uint16 srcWidth = srcByteWidth * 2;
 	uint16 destWidth = destByteWidth * 2;
@@ -848,18 +848,18 @@ void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box,
 	}
 }
 
-void DisplayMan::D24_fillScreenBox(Box &box, Color color) {
+void DisplayMan::fillScreenBox(Box &box, Color color) {
 	uint16 width = box._x2 + 1 - box._x1; // + 1 for inclusive boundaries
 	for (int16 y = box._y1; y < box._y2 + 1; ++y) // + 1 for inclusive boundaries
-		memset(_g348_bitmapScreen + y * _screenWidth + box._x1, color, sizeof(byte) * width);
+		memset(_bitmapScreen + y * _screenWidth + box._x1, color, sizeof(byte) * width);
 }
 
-void DisplayMan::f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 byteWidth, int16 height) {
+void DisplayMan::fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 byteWidth, int16 height) {
 	for (int16 y = box._y1; y < box._y2 + 1; ++y) // + 1 for inclusive boundaries
 		memset(destBitmap + y * byteWidth * 2 + box._x1, color, sizeof(byte) * (box._x2 - box._x1 + 1)); // + 1 for inclusive boundaries
 }
 
-void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box& box,
+void DisplayMan::blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box& box,
 													int16 lastUnitIndex, int16 firstUnitIndex, int16 destByteWidth, Color transparent,
 													int16 xPos, int16 yPos, int16 destHeight, int16 height2) {
 	// make sure to take care of inclusive boundaries, color can have 0x8000 flag to not use mask
@@ -868,7 +868,7 @@ void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte
 
 
 
-void DisplayMan::f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height) {
+void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height) {
 	uint16 width = byteWidth * 2;
 	for (uint16 y = 0; y < height; ++y) {
 		for (uint16 x = 0; x < width / 2; ++x)
@@ -876,7 +876,7 @@ void DisplayMan::f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint1
 	}
 }
 
-void DisplayMan::f131_flipVertical(byte *bitmap, uint16 byteWidth, uint16 height) {
+void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 byteWidth, uint16 height) {
 	uint16 width = byteWidth * 2;
 	byte *tmp = new byte[width];
 
@@ -889,24 +889,24 @@ void DisplayMan::f131_flipVertical(byte *bitmap, uint16 byteWidth, uint16 height
 	delete[] tmp;
 }
 
-byte *DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnByteWidth, int16& returnHeight) {
+byte *DisplayMan::getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnByteWidth, int16& returnHeight) {
 	ExplosionAspect *explAsp = &_explosionAspects[explosionAspIndex];
 	if (scale > 32)
 		scale = 32;
-	int16 pixelWidth = M78_getScaledDimension(explAsp->_byteWidth, scale);
-	int16 height = M78_getScaledDimension(explAsp->_height, scale);
+	int16 pixelWidth = getScaledDimension(explAsp->_byteWidth, scale);
+	int16 height = getScaledDimension(explAsp->_height, scale);
 	byte *bitmap;
 	int16 derBitmapIndex = (explosionAspIndex * 14) + scale / 2 + k438_DerivedBitmapFirstExplosion - 2;
 	if ((scale == 32) && (explosionAspIndex != k3_ExplosionAspectSmoke))
-		bitmap = f489_getNativeBitmapOrGraphic(explosionAspIndex + k348_FirstExplosionGraphicIndice);
-	else if (f491_isDerivedBitmapInCache(derBitmapIndex))
-		bitmap = f492_getDerivedBitmap(derBitmapIndex);
+		bitmap = getNativeBitmapOrGraphic(explosionAspIndex + k348_FirstExplosionGraphicIndice);
+	else if (isDerivedBitmapInCache(derBitmapIndex))
+		bitmap = getDerivedBitmap(derBitmapIndex);
 	else {
-		byte *nativeBitmap = f489_getNativeBitmapOrGraphic(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice);
-		bitmap = f492_getDerivedBitmap(derBitmapIndex);
-		f129_blitToBitmapShrinkWithPalChange(nativeBitmap, bitmap, explAsp->_byteWidth, explAsp->_height, pixelWidth * 2, height,
+		byte *nativeBitmap = getNativeBitmapOrGraphic(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice);
+		bitmap = getDerivedBitmap(derBitmapIndex);
+		blitToBitmapShrinkWithPalChange(nativeBitmap, bitmap, explAsp->_byteWidth, explAsp->_height, pixelWidth * 2, height,
 			(explosionAspIndex == k3_ExplosionAspectSmoke) ? _palChangeSmoke : _palChangesNoChanges);
-		f493_addDerivedBitmap(derBitmapIndex);
+		addDerivedBitmap(derBitmapIndex);
 	}
 
 	returnByteWidth = pixelWidth;
@@ -917,46 +917,46 @@ byte *DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale
 void DisplayMan::updateScreen() {
 	// apply copper
 	for (uint32 i = 320 * 30; i < 320 * 170; ++i)
-		_g348_bitmapScreen[i] += 16;
-	_vm->_system->copyRectToScreen(_g348_bitmapScreen, _screenWidth, 0, 0, _screenWidth, _screenHeight);
+		_bitmapScreen[i] += 16;
+	_vm->_system->copyRectToScreen(_bitmapScreen, _screenWidth, 0, 0, _screenWidth, _screenHeight);
 	_vm->_console->onFrame();
 	_vm->_system->updateScreen();
 	for (uint32 i = 320 * 30; i < 320 * 170; ++i)
-		_g348_bitmapScreen[i] -= 16;
+		_bitmapScreen[i] -= 16;
 }
 
-void DisplayMan::f97_drawViewport(int16 palSwitchingRequestedState) {
+void DisplayMan::drawViewport(int16 palSwitchingRequestedState) {
 	static uint16 *dungeonViewCurrentPalette; // @ K0010_pui_DungeonViewCurrentPalette
 
 	// ignored code F0510_AMIGA_WaitBottomOfViewPort
 	if (palSwitchingRequestedState == k2_viewportAsBeforeSleepOrFreezeGame)
-		palSwitchingRequestedState = _g322_paletteSwitchingEnabled ? 1 : 0;
+		palSwitchingRequestedState = _paletteSwitchingEnabled ? 1 : 0;
 
-	if (_g342_refreshDungeonViewPaleteRequested) {
-		dungeonViewCurrentPalette = _palDungeonView[_g304_dungeonViewPaletteIndex];
-		_g342_refreshDungeonViewPaleteRequested = false;
+	if (_refreshDungeonViewPaleteRequested) {
+		dungeonViewCurrentPalette = _palDungeonView[_dungeonViewPaletteIndex];
+		_refreshDungeonViewPaleteRequested = false;
 		if (palSwitchingRequestedState == k0_viewportNotDungeonView)
-			_g322_paletteSwitchingEnabled = true;
+			_paletteSwitchingEnabled = true;
 		else
-			_g322_paletteSwitchingEnabled = false;
+			_paletteSwitchingEnabled = false;
 	}
 
-	if (palSwitchingRequestedState != (_g322_paletteSwitchingEnabled ? 1 : 0)) {
+	if (palSwitchingRequestedState != (_paletteSwitchingEnabled ? 1 : 0)) {
 		if (palSwitchingRequestedState) {
-			f565_viewportSetPalette(dungeonViewCurrentPalette, _g347_paletteTopAndBottomScreen);
-			_g322_paletteSwitchingEnabled = true;
+			viewportSetPalette(dungeonViewCurrentPalette, _paletteTopAndBottomScreen);
+			_paletteSwitchingEnabled = true;
 		} else {
-			f565_viewportSetPalette(_g347_paletteTopAndBottomScreen, _g347_paletteTopAndBottomScreen);
-			_g322_paletteSwitchingEnabled = false;
+			viewportSetPalette(_paletteTopAndBottomScreen, _paletteTopAndBottomScreen);
+			_paletteSwitchingEnabled = false;
 		}
 	} else
-		f565_viewportSetPalette(nullptr, nullptr);
+		viewportSetPalette(nullptr, nullptr);
 
 	updateScreen();
 }
 
 byte *DisplayMan::getCurrentVgaBuffer() {
-	return _g348_bitmapScreen;
+	return _bitmapScreen;
 }
 
 uint16 DisplayMan::getPixelWidth(uint16 index) {
@@ -969,12 +969,12 @@ uint16 DisplayMan::getPixelHeight(uint16 index) {
 	return READ_BE_UINT16(data + 2);
 }
 
-void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height) {
+void DisplayMan::copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height) {
 	memmove(destBitmap, srcBitmap, byteWidth * 2 * height * sizeof(byte));
-	f130_flipBitmapHorizontal(destBitmap, byteWidth, height);
+	flipBitmapHorizontal(destBitmap, byteWidth, height);
 }
 
-void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloorIndex) {
+void DisplayMan::drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloorIndex) {
 	static byte g191_floorOrnNativeBitmapndexInc[9] = { // @ G0191_auc_Graphic558_FloorOrnamentNativeBitmapIndexIncrements
 		0,   /* D3L */
 		1,   /* D3C */
@@ -1031,63 +1031,63 @@ void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloor
 	if (!drawFootprints || clearFlag(floorOrnOrdinal, k0x8000_FootprintsAspect)) {
 		floorOrnOrdinal--;
 		uint16 floorOrnIndex = floorOrnOrdinal;
-		int16 nativeBitmapIndex = _g102_currMapFloorOrnInfo[floorOrnIndex][k0_NativeBitmapIndex]
+		int16 nativeBitmapIndex = _currMapFloorOrnInfo[floorOrnIndex][k0_NativeBitmapIndex]
 			+ g191_floorOrnNativeBitmapndexInc[viewFloorIndex];
-		uint16 *coordSets = g206_floorOrnCoordSets[_g102_currMapFloorOrnInfo[floorOrnIndex][k1_CoordinateSet]][viewFloorIndex];
+		uint16 *coordSets = g206_floorOrnCoordSets[_currMapFloorOrnInfo[floorOrnIndex][k1_CoordinateSet]][viewFloorIndex];
 		if ((viewFloorIndex == k8_viewFloor_D1R) || (viewFloorIndex == k5_viewFloor_D2R)
 			|| (viewFloorIndex == k2_viewFloor_D3R)
-			|| ((floorOrnIndex == k15_FloorOrnFootprints) && _g76_useFlippedWallAndFootprintsBitmap &&
+			|| ((floorOrnIndex == k15_FloorOrnFootprints) && _useFlippedWallAndFootprintsBitmap &&
 			((viewFloorIndex == k7_viewFloor_D1C) || (viewFloorIndex == k4_viewFloor_D2C) || (viewFloorIndex == k1_viewFloor_D3C)))) {
-			bitmap = _g74_tmpBitmap;
-			f99_copyBitmapAndFlipHorizontal(f489_getNativeBitmapOrGraphic(nativeBitmapIndex), bitmap, coordSets[4], coordSets[5]);
+			bitmap = _tmpBitmap;
+			copyBitmapAndFlipHorizontal(getNativeBitmapOrGraphic(nativeBitmapIndex), bitmap, coordSets[4], coordSets[5]);
 		} else
-			bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+			bitmap = getNativeBitmapOrGraphic(nativeBitmapIndex);
 
-		f132_blitToBitmap(bitmap, _g296_bitmapViewport,
+		blitToBitmap(bitmap, _bitmapViewport,
 						  *(Box *)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport);
 	}
 
 	if (drawFootprints)
-		f108_drawFloorOrnament(_vm->indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex);
+		drawFloorOrnament(_vm->indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex);
 }
 
-void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* doorNativeBitmapIndices, int16 byteCount, int16 viewDoorOrnIndex, DoorFrames* doorFrames) {
+void DisplayMan::drawDoor(uint16 doorThingIndex, uint16 doorState, int16* doorNativeBitmapIndices, int16 byteCount, int16 viewDoorOrnIndex, DoorFrames* doorFrames) {
 	if (doorState == k0_doorState_OPEN)
 		return;
 
 	DoorFrames *doorFramesTemp = doorFrames;
 	Door *door = (Door *)(_vm->_dungeonMan->_thingData[k0_DoorThingType]) + doorThingIndex;
 	uint16 doorType = door->getType();
-	memmove(_g74_tmpBitmap, f489_getNativeBitmapOrGraphic(doorNativeBitmapIndices[doorType]), byteCount * 2);
-	f109_drawDoorOrnament(door->getOrnOrdinal(), viewDoorOrnIndex);
+	memmove(_tmpBitmap, getNativeBitmapOrGraphic(doorNativeBitmapIndices[doorType]), byteCount * 2);
+	drawDoorOrnament(door->getOrnOrdinal(), viewDoorOrnIndex);
 	if (getFlag(_vm->_dungeonMan->_currMapDoorInfo[doorType]._attributes, k0x0004_MaskDoorInfo_Animated)) {
 		if (_vm->getRandomNumber(2))
-			f130_flipBitmapHorizontal(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
+			flipBitmapHorizontal(_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
 
 		if (_vm->getRandomNumber(2))
-			f131_flipVertical(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
+			flipBitmapVertical(_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight);
 	}
 
 	if ((doorFramesTemp == _doorFrameD1C) && _vm->_championMan->_party._event73Count_ThievesEye)
-		f109_drawDoorOrnament(_vm->indexToOrdinal(k16_DoorOrnThivesEyeMask), k2_ViewDoorOrnament_D1LCR);
+		drawDoorOrnament(_vm->indexToOrdinal(k16_DoorOrnThivesEyeMask), k2_ViewDoorOrnament_D1LCR);
 
 	if (doorState == k4_doorState_CLOSED)
-		f102_drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed);
+		drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed);
 	else if (doorState == k5_doorState_DESTROYED) {
-		f109_drawDoorOrnament(_vm->indexToOrdinal(k15_DoorOrnDestroyedMask), viewDoorOrnIndex);
-		f102_drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed);
+		drawDoorOrnament(_vm->indexToOrdinal(k15_DoorOrnDestroyedMask), viewDoorOrnIndex);
+		drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed);
 	} else {
 		doorState--;
 		if (door->opensVertically())
-			f102_drawDoorBitmap(&doorFramesTemp->_vertical[doorState]);
+			drawDoorBitmap(&doorFramesTemp->_vertical[doorState]);
 		else {
-			f102_drawDoorBitmap(&doorFramesTemp->_leftHorizontal[doorState]);
-			f102_drawDoorBitmap(&doorFramesTemp->_rightHorizontal[doorState]);
+			drawDoorBitmap(&doorFramesTemp->_leftHorizontal[doorState]);
+			drawDoorBitmap(&doorFramesTemp->_rightHorizontal[doorState]);
 		}
 	}
 }
 
-void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIndex) {
+void DisplayMan::drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIndex) {
 	static byte palChangesDoorOrnD3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 0, 130}; // @ G0200_auc_Graphic558_PaletteChanges_DoorOrnament_D3
 	static byte palChangesDoorOrnd2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0201_auc_Graphic558_PaletteChanges_DoorOrnament_D2
 	static uint16 doorOrnCoordSets[4][3][6] = { // @ G0207_aaauc_Graphic558_DoorOrnamentCoordinateSets
@@ -1122,23 +1122,23 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn
 	int16 byteWidth = viewDoorOrnIndex;
 	height--;
 
-	int16 nativeBitmapIndex = _g103_currMapDoorOrnInfo[height][k0_NativeBitmapIndex];
-	int16 coordSetGreenToad = _g103_currMapDoorOrnInfo[height][k1_CoordinateSet];
+	int16 nativeBitmapIndex = _currMapDoorOrnInfo[height][k0_NativeBitmapIndex];
+	int16 coordSetGreenToad = _currMapDoorOrnInfo[height][k1_CoordinateSet];
 	uint16 *coordSetOrangeElk = &doorOrnCoordSets[coordSetGreenToad][byteWidth][0];
 	byte *blitBitmap;
 	if (byteWidth == k2_ViewDoorOrnament_D1LCR) {
-		blitBitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
+		blitBitmap = getNativeBitmapOrGraphic(nativeBitmapIndex);
 		byteWidth = k48_byteWidth;
 		height = 88;
 	} else {
 		height = k68_DerivedBitmapFirstDoorOrnament_D3 + (height * 2) + byteWidth;
-		if (!f491_isDerivedBitmapInCache(height)) {
+		if (!isDerivedBitmapInCache(height)) {
 			uint16 *coordSetRedEagle = &doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR][0];
-			byte *nativeBitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex);
-			f129_blitToBitmapShrinkWithPalChange(nativeBitmap, f492_getDerivedBitmap(height), coordSetRedEagle[4] << 1, coordSetRedEagle[5], coordSetOrangeElk[1] - coordSetOrangeElk[0] + 1, coordSetOrangeElk[5], (byteWidth == k0_ViewDoorOrnament_D3LCR) ? palChangesDoorOrnD3 : palChangesDoorOrnd2);
-			f493_addDerivedBitmap(height);
+			byte *nativeBitmap = getNativeBitmapOrGraphic(nativeBitmapIndex);
+			blitToBitmapShrinkWithPalChange(nativeBitmap, getDerivedBitmap(height), coordSetRedEagle[4] << 1, coordSetRedEagle[5], coordSetOrangeElk[1] - coordSetOrangeElk[0] + 1, coordSetOrangeElk[5], (byteWidth == k0_ViewDoorOrnament_D3LCR) ? palChangesDoorOrnD3 : palChangesDoorOrnd2);
+			addDerivedBitmap(height);
 		}
-		blitBitmap = f492_getDerivedBitmap(height);
+		blitBitmap = getDerivedBitmap(height);
 		if (byteWidth == k0_ViewDoorOrnament_D3LCR) {
 			byteWidth = k24_byteWidth;
 			height = 41;
@@ -1149,10 +1149,10 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn
 	}
 
 	Box box(coordSetOrangeElk[0], coordSetOrangeElk[1], coordSetOrangeElk[2], coordSetOrangeElk[3]);
-	f132_blitToBitmap(blitBitmap, _g74_tmpBitmap, box, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height);
+	blitToBitmap(blitBitmap, _tmpBitmap, box, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height);
 }
 
-void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int16 mapX, int16 mapY, bool flipHorizontal) {
+void DisplayMan::drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int16 mapX, int16 mapY, bool flipHorizontal) {
 	int16 mapIndex = _vm->_dungeonMan->getLocationAfterLevelChange(_vm->_dungeonMan->_currMapIndex, -1, &mapX, &mapY);
 
 	if (mapIndex < 0)
@@ -1161,47 +1161,47 @@ void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int1
 	int16 mapSquare = _vm->_dungeonMan->_dungeonMapData[mapIndex][mapX][mapY];
 	if ((Square(mapSquare).getType() == k2_PitElemType) && getFlag(mapSquare, k0x0008_PitOpen)) {
 		if (flipHorizontal)
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(nativeBitmapIndex, *frame);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(nativeBitmapIndex, *frame);
 		else
-			f104_drawFloorPitOrStairsBitmap(nativeBitmapIndex, *frame);
+			drawFloorPitOrStairsBitmap(nativeBitmapIndex, *frame);
 	}
 }
 
-void DisplayMan::f20_blitToViewport(byte *bitmap, Box& box, int16 byteWidth, Color transparent, int16 height) {
-	f132_blitToBitmap(bitmap, _g296_bitmapViewport, box, 0, 0, byteWidth, k112_byteWidthViewport, transparent, height, k136_heightViewport);
+void DisplayMan::blitToViewport(byte *bitmap, Box& box, int16 byteWidth, Color transparent, int16 height) {
+	blitToBitmap(bitmap, _bitmapViewport, box, 0, 0, byteWidth, k112_byteWidthViewport, transparent, height, k136_heightViewport);
 }
 
-void DisplayMan::f20_blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height) {
+void DisplayMan::blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height) {
 	Box actualBox(box[0], box[1], box[2], box[3]);
-	f20_blitToViewport(bitmap, actualBox, byteWidth, transparent, height);
+	blitToViewport(bitmap, actualBox, byteWidth, transparent, height);
 }
 
-void DisplayMan::f21_blitToScreen(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height) {
+void DisplayMan::blitToScreen(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height) {
 	Box actualBox(box[0], box[1], box[2], box[3]);
-	f21_blitToScreen(bitmap, &actualBox, byteWidth, transparent, height);
+	blitToScreen(bitmap, &actualBox, byteWidth, transparent, height);
 }
 
-void DisplayMan::f21_blitToScreen(byte *bitmap, Box *box, int16 byteWidth, Color transparent, int16 height) {
-	_g578_useByteBoxCoordinates = false;
-	f132_blitToBitmap(bitmap, _g348_bitmapScreen, *box, 0, 0, byteWidth, k160_byteWidthScreen, transparent, height, k200_heightScreen);
+void DisplayMan::blitToScreen(byte *bitmap, Box *box, int16 byteWidth, Color transparent, int16 height) {
+	_useByteBoxCoordinates = false;
+	blitToBitmap(bitmap, _bitmapScreen, *box, 0, 0, byteWidth, k160_byteWidthScreen, transparent, height, k200_heightScreen);
 }
 
-void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
+void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) {
 	if (!f._srcByteWidth)
 		return;
 
-	f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency, f._srcHeight, k136_heightViewport);
+	blitToBitmap(bitmap, _bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency, f._srcHeight, k136_heightViewport);
 }
 
-void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) {
+void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) {
 	if (!f._srcByteWidth)
 		return;
 
-	f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, f._srcHeight, k136_heightViewport);
+	blitToBitmap(bitmap, _bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, f._srcHeight, k136_heightViewport);
 }
 
 
-void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
+void DisplayMan::drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 	static Frame doorFrameLeftD3L = Frame(0, 31, 28, 70, 16, 43, 0, 0); // @ G0164_s_Graphic558_Frame_DoorFrameLeft_D3L
 	static Frame frameStairsUpFrontD3L = Frame(0, 79, 25, 70, 40, 46, 0, 0); // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L
 	static Frame frameStairsDownFrontD3L = Frame(0, 79, 28, 68, 40, 41, 0, 0); // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L
@@ -1227,17 +1227,17 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_StairsFrontElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			f104_drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, frameStairsUpFrontD3L);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexUpFrontD3L, frameStairsUpFrontD3L);
 		else
-			f104_drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, frameStairsDownFrontD3L);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexDownFrontD3L, frameStairsDownFrontD3L);
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
 		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
 		break;
 	case k0_WallElemType:
-		f100_drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, _frameWalls163[k1_ViewSquare_D3L]);
-		f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT))
+		drawWallSetBitmap(_bitmapWallSetD3LCR, _frameWalls163[k1_ViewSquare_D3L]);
+		isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT))
 			order = k0x0000_CellOrder_Alcove;
 		else
 			return;
@@ -1246,25 +1246,25 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 	case k18_ElementTypeStairsSide:
 		order = k0x0321_CellOrder_BackLeft_BackRight_FrontRight;
 		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
 		break;
 	case k17_ElementTypeDoorFront:
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
-		f100_drawWallSetBitmap(_g705_bitmapWallSet_DoorFrameLeft_D3L, doorFrameLeftD3L);
-		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g693_doorNativeBitmapIndex_Front_D3LCR, bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3L);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
+		drawWallSetBitmap(_bitmapWallSetDoorFrameLeftD3L, doorFrameLeftD3L);
+		drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
+					  _doorNativeBitmapIndexFrontD3LCR, bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3L);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		break;
 	case k2_ElementTypePit:
 		if (!squareAspect[k2_PitInvisibleAspect])
-			f104_drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, frameFloorPitD3L);
+			drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, frameFloorPitD3L);
 	// no break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_ElementTypeCorridor:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
 		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L);
 		break;
 	default:
 		skip = true;
@@ -1272,13 +1272,13 @@ void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) {
 	}
 
 	if (!skip)
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order);
 
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
-		f113_drawField(&_fieldAspects188[k1_ViewSquare_D3L], _frameWalls163[k1_ViewSquare_D3L]._box);
+		drawField(&_fieldAspects188[k1_ViewSquare_D3L], _frameWalls163[k1_ViewSquare_D3L]._box);
 }
 
-void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
+void DisplayMan::drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 	static Frame doorFrameRightD3R = Frame(192, 223, 28, 70, 16, 43, 0, 0); // @ G0165_s_Graphic558_Frame_DoorFrameRight_D3R
 	static Frame frameStairsUpFrontD3R = Frame(149, 223, 25, 70, 40, 46, 5, 0); // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R
 	static Frame frameStairsDownFrontD3R = Frame(149, 223, 28, 68, 40, 41, 5, 0); // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R
@@ -1305,18 +1305,18 @@ void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, frameStairsUpFrontD3R);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_stairsNativeBitmapIndexUpFrontD3L, frameStairsUpFrontD3R);
 		else
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, frameStairsDownFrontD3R);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_stairsNativeBitmapIndexDownFrontD3L, frameStairsDownFrontD3R);
 
 		order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft;
 		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
 		break;
 	case k0_ElementTypeWall:
-		f100_drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, _frameWalls163[k2_ViewSquare_D3R]);
-		f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT))
+		drawWallSetBitmap(_bitmapWallSetD3LCR, _frameWalls163[k2_ViewSquare_D3R]);
+		isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT))
 			order = k0x0000_CellOrder_Alcove;
 		else
 			return;
@@ -1325,29 +1325,29 @@ void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 	case k18_ElementTypeStairsSide:
 		order = k0x0412_CellOrder_BackRight_BackLeft_FrontLeft;
 		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
 		break;
 	case k17_ElementTypeDoorFront:
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
-		memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44);
-		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD3R);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
+		memmove(_tmpBitmap, _bitmapWallSetDoorFrameLeftD3L, 32 * 44);
+		drawDoorFrameBitmapFlippedHorizontally(_tmpBitmap, &doorFrameRightD3R);
 		if (((Door *)_vm->_dungeonMan->_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
-			f110_drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k0_viewDoorButton_D3R);
+			drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k0_viewDoorButton_D3R);
 
-		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect],
-					  squareAspect[k2_DoorStateAspect], _g693_doorNativeBitmapIndex_Front_D3LCR,
+		drawDoor(squareAspect[k3_DoorThingIndexAspect],
+					  squareAspect[k2_DoorStateAspect], _doorNativeBitmapIndexFrontD3LCR,
 					  bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3R);
 		break;;
 	case k2_ElementTypePit:
 		if (!squareAspect[k2_PitInvisibleAspect])
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, frameFloorPitD3R);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, frameFloorPitD3R);
 		// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_ElementTypeCorridor:
 		order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft;
 		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R);
 		break;
 	default:
 		skip = true;
@@ -1355,13 +1355,13 @@ void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) {
 	}
 
 	if (!skip)
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order);
 
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
-		f113_drawField(&_fieldAspects188[k2_ViewSquare_D3R], _frameWalls163[k2_ViewSquare_D3R]._box);
+		drawField(&_fieldAspects188[k2_ViewSquare_D3R], _frameWalls163[k2_ViewSquare_D3R]._box);
 }
 
-void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
+void DisplayMan::drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 	static Frame doorFrameLeftD3C = Frame(64, 95, 27, 70, 16, 44, 0, 0); // @ G0166_s_Graphic558_Frame_DoorFrameLeft_D3C
 	static Frame doorFrameRightD3C = Frame(128, 159, 27, 70, 16, 44, 0, 0); // @ G0167_s_Graphic558_Frame_DoorFrameRight_D3C
 	static Frame frameStairsUpFrontD3C = Frame(64, 159, 25, 70, 48, 46, 0, 0); // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C
@@ -1389,42 +1389,42 @@ void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
-			f104_drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, frameStairsUpFrontD3C);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexUpFrontD3C, frameStairsUpFrontD3C);
 		else
-			f104_drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, frameStairsDownFrontD3C);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexDownFrontD3C, frameStairsDownFrontD3C);
 
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		break;
 	case k0_ElementTypeWall:
-		f101_drawWallSetBitmapWithoutTransparency(_g698_bitmapWallSet_Wall_D3LCR, _frameWalls163[k0_ViewSquare_D3C]);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT))
+		drawWallSetBitmapWithoutTransparency(_bitmapWallSetD3LCR, _frameWalls163[k0_ViewSquare_D3C]);
+		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT))
 			order = k0x0000_CellOrder_Alcove;
 		else
 			return;
 
 		break;
 	case k17_DoorFrontElemType:
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C);
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
-		f100_drawWallSetBitmap(_g706_bitmapWallSet_DoorFrameLeft_D3C, doorFrameLeftD3C);
-		memmove(_g74_tmpBitmap, _g706_bitmapWallSet_DoorFrameLeft_D3C, 32 * 44);
-		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD3C);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
+		drawWallSetBitmap(_bitmapWallSetDoorFrameLeftD3C, doorFrameLeftD3C);
+		memmove(_tmpBitmap, _bitmapWallSetDoorFrameLeftD3C, 32 * 44);
+		drawDoorFrameBitmapFlippedHorizontally(_tmpBitmap, &doorFrameRightD3C);
 		if (((Door *)_vm->_dungeonMan->_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
-			f110_drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k1_ViewDoorOrnament_D2LCR);
+			drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k1_ViewDoorOrnament_D2LCR);
 
-		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g693_doorNativeBitmapIndex_Front_D3LCR, bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3C);
+		drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
+					  _doorNativeBitmapIndexFrontD3LCR, bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3C);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		break;
 	case k2_ElementTypePit:
 		if (!squareAspect[k2_PitInvisibleAspect])
-			f104_drawFloorPitOrStairsBitmap(k50_FloorPit_D3C_GraphicIndice, frameFloorPitD3C);
+			drawFloorPitOrStairsBitmap(k50_FloorPit_D3C_GraphicIndice, frameFloorPitD3C);
 	// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		break;
 	default:
 		skip = true;
@@ -1432,13 +1432,13 @@ void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) {
 	}
 
 	if (!skip)
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, order);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, order);
 
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
-		f113_drawField(&_fieldAspects188[k0_ViewSquare_D3C], _frameWalls163[k0_ViewSquare_D3C]._box);
+		drawField(&_fieldAspects188[k0_ViewSquare_D3C], _frameWalls163[k0_ViewSquare_D3C]._box);
 }
 
-void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
+void DisplayMan::drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 	static Frame doorFrameTopD2L = Frame(0, 59, 22, 24, 48, 3, 16, 0); // @ G0173_s_Graphic558_Frame_DoorFrameTop_D2L
 	static Frame frameStairsUpFrontD2L = Frame(0, 63, 22, 83, 32, 62, 0, 0); // @ G0113_s_Graphic558_Frame_StairsUpFront_D2L
 	static Frame frameStairsDownFrontD2L = Frame(0, 63, 24, 85, 32, 62, 0, 0); // @ G0124_s_Graphic558_Frame_StairsDownFront_D2L
@@ -1467,44 +1467,44 @@ void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
-			f104_drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, frameStairsUpFrontD2L);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexUpFrontD2L, frameStairsUpFrontD2L);
 		else
-			f104_drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, frameStairsDownFrontD2L);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexDownFrontD2L, frameStairsDownFrontD2L);
 
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		break;
 	case k0_ElementTypeWall:
-		f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, _frameWalls163[k4_ViewSquare_D2L]);
-		f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT))
+		drawWallSetBitmap(_bitmapWallSetD2LCR, _frameWalls163[k4_ViewSquare_D2L]);
+		isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT))
 			order = k0x0000_CellOrder_Alcove;
 		else 
 			return;
 		break;
 	case k18_ElementTypeStairsSide:
-		f104_drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, frameStairsSideD2L);
+		drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexSideD2L, frameStairsSideD2L);
 		// No break on purpose
 	case k16_DoorSideElemType:
 		order = k0x0342_CellOrder_BackRight_FrontLeft_FrontRight;
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		break;
 	case k17_DoorFrontElemType:
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L);
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
-		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, doorFrameTopD2L);
-		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], _g694_doorNativeBitmapIndex_Front_D2LCR,
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
+		drawWallSetBitmap(_bitmapWallSetDoorFrameTopD2LCR, doorFrameTopD2L);
+		drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], _doorNativeBitmapIndexFrontD2LCR,
 					  bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2L);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		break;
 	case k2_ElementTypePit:
-		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice,
+		drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice,
 										frameFloorPitD2L);
 		// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
 		break;
 
 	default:
@@ -1513,15 +1513,15 @@ void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
 	}
 
 	if (!skip) {
-		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &FrameCeilingPitD2L, posX, posY, false);
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, order);
+		drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &FrameCeilingPitD2L, posX, posY, false);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, order);
 	}
 
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
-		f113_drawField(&_fieldAspects188[k4_ViewSquare_D2L], _frameWalls163[k4_ViewSquare_D2L]._box);
+		drawField(&_fieldAspects188[k4_ViewSquare_D2L], _frameWalls163[k4_ViewSquare_D2L]._box);
 }
 
-void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
+void DisplayMan::drawSquareD2R(Direction dir, int16 posX, int16 posY) {
 	static Frame doorFrameTopD2R = Frame(164, 223, 22, 24, 48, 3, 16, 0); // @ G0175_s_Graphic558_Frame_DoorFrameTop_D2R
 	static Frame frameStairsUpFrontD2R = Frame(160, 223, 22, 83, 32, 62, 0, 0); // @ G0115_s_Graphic558_Frame_StairsUpFront_D2R
 	static Frame frameStairsDownFrontD2R = Frame(160, 223, 24, 85, 32, 62, 0, 0); // @ G0126_s_Graphic558_Frame_StairsDownFront_D2R
@@ -1550,50 +1550,50 @@ void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, frameStairsUpFrontD2R);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_stairsNativeBitmapIndexUpFrontD2L, frameStairsUpFrontD2R);
 		else
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, frameStairsDownFrontD2R);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_stairsNativeBitmapIndexDownFrontD2L, frameStairsDownFrontD2R);
 
 		order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft;
 		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_viewFloor_D2R);
-		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &frameCeilingPitD2R, posX, posY, true);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_viewFloor_D2R);
+		drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &frameCeilingPitD2R, posX, posY, true);
 		break;
 	case k0_ElementTypeWall:
-		f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, _frameWalls163[k5_ViewSquare_D2R]);
-		f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT))
+		drawWallSetBitmap(_bitmapWallSetD2LCR, _frameWalls163[k5_ViewSquare_D2R]);
+		isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT);
+		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT))
 			order = k0x0000_CellOrder_Alcove;
 		else
 			return;
 		break;
 	case k18_ElementTypeStairsSide:
-		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, frameStairsSideD2R);
+		drawFloorPitOrStairsBitmapFlippedHorizontally(_stairsNativeBitmapIndexSideD2L, frameStairsSideD2R);
 		// No break on purpose
 	case k16_DoorSideElemType:
 		order = k0x0431_CellOrder_BackLeft_FrontRight_FrontLeft;
 		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_viewFloor_D2R);
-		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &frameCeilingPitD2R, posX, posY, true);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_viewFloor_D2R);
+		drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &frameCeilingPitD2R, posX, posY, true);
 		break;
 	case k17_DoorFrontElemType:
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_ViewSquare_D2R);
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
-		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, doorFrameTopD2R);
-		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g694_doorNativeBitmapIndex_Front_D2LCR, bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2R);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_ViewSquare_D2R);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft);
+		drawWallSetBitmap(_bitmapWallSetDoorFrameTopD2LCR, doorFrameTopD2R);
+		drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
+					  _doorNativeBitmapIndexFrontD2LCR, bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2R);
 		order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft;
 		break;
 	case k2_ElementTypePit:
-		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(
+		drawFloorPitOrStairsBitmapFlippedHorizontally(
 			squareAspect[k2_PitInvisibleAspect] ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice, frameFloorPitD2R);
 		// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
 		order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft;
 		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_viewFloor_D2R);
-		f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &frameCeilingPitD2R, posX, posY, true);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_viewFloor_D2R);
+		drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &frameCeilingPitD2R, posX, posY, true);
 		break;
 	default:
 		skip = true;
@@ -1601,13 +1601,13 @@ void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
 	}
 
 	if (!skip)
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, order);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, order);
 
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
-		f113_drawField(&_fieldAspects188[k5_ViewSquare_D2R], _frameWalls163[k5_ViewSquare_D2R]._box);
+		drawField(&_fieldAspects188[k5_ViewSquare_D2R], _frameWalls163[k5_ViewSquare_D2R]._box);
 }
 
-void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
+void DisplayMan::drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 	static Frame doorFrameLeftD2C = Frame(48, 95, 22, 86, 24, 65, 0, 0); // @ G0168_s_Graphic558_Frame_DoorFrameLeft_D2C
 	static Frame doorFrameRightD2C = Frame(128, 175, 22, 86, 24, 65, 0, 0); // @ G0169_s_Graphic558_Frame_DoorFrameRight_D2C
 	static Frame doorFrameTopD2C = Frame(64, 159, 22, 24, 48, 3, 0, 0); // @ G0174_s_Graphic558_Frame_DoorFrameTop_D2C
@@ -1637,45 +1637,45 @@ void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
-			f104_drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, frameStairsUpFrontD2C);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexUpFrontD2C, frameStairsUpFrontD2C);
 		else
-			f104_drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, frameStairsDownFrontD2C);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexDownFrontD2C, frameStairsDownFrontD2C);
 
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
 		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C);
-		f112_drawCeilingPit(k64_ceilingPitD2C_GraphicIndice, &frameCeilingPitD2C, posX, posY, false);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C);
+		drawCeilingPit(k64_ceilingPitD2C_GraphicIndice, &frameCeilingPitD2C, posX, posY, false);
 		break;
 	case k0_ElementTypeWall:
-		f101_drawWallSetBitmapWithoutTransparency(_g699_bitmapWallSet_Wall_D2LCR, _frameWalls163[k3_ViewSquare_D2C]);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT))
+		drawWallSetBitmapWithoutTransparency(_bitmapWallSetD2LCR, _frameWalls163[k3_ViewSquare_D2C]);
+		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT))
 			order = k0x0000_CellOrder_Alcove;
 		else
 			return;
 		break;
 	case k17_DoorFrontElemType:
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C);
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
-		f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, doorFrameTopD2C);
-		f100_drawWallSetBitmap(_g707_bitmapWallSet_DoorFrameLeft_D2C, doorFrameLeftD2C);
-		memcpy(_g74_tmpBitmap, _g707_bitmapWallSet_DoorFrameLeft_D2C, 48 * 65);
-		f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &doorFrameRightD2C);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
+		drawWallSetBitmap(_bitmapWallSetDoorFrameTopD2LCR, doorFrameTopD2C);
+		drawWallSetBitmap(_bitmapWallSetDoorFrameLeftD2C, doorFrameLeftD2C);
+		memcpy(_tmpBitmap, _bitmapWallSetDoorFrameLeftD2C, 48 * 65);
+		drawDoorFrameBitmapFlippedHorizontally(_tmpBitmap, &doorFrameRightD2C);
 		if (((Door *)_vm->_dungeonMan->_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
-			f110_drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k2_viewDoorButton_D2C);
+			drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k2_viewDoorButton_D2C);
 
-		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g694_doorNativeBitmapIndex_Front_D2LCR, bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2C);
+		drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
+					  _doorNativeBitmapIndexFrontD2LCR, bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2C);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		break;
 	case k2_ElementTypePit:
-		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k58_FloorPit_invisible_D2C_GraphicIndice : k52_FloorPit_D2C_GraphicIndice, frameFloorPitD2C);
+		drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k58_FloorPit_invisible_D2C_GraphicIndice : k52_FloorPit_D2C_GraphicIndice, frameFloorPitD2C);
 		// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
 		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C);
-		f112_drawCeilingPit(k64_ceilingPitD2C_GraphicIndice, &frameCeilingPitD2C, posX, posY, false);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C);
+		drawCeilingPit(k64_ceilingPitD2C_GraphicIndice, &frameCeilingPitD2C, posX, posY, false);
 		break;
 	default:
 		skip = true;
@@ -1683,13 +1683,13 @@ void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) {
 	}
 
 	if (!skip)
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, order);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, order);
 
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
-		f113_drawField(&_fieldAspects188[k3_ViewSquare_D2C], _frameWalls163[k3_ViewSquare_D2C]._box);
+		drawField(&_fieldAspects188[k3_ViewSquare_D2C], _frameWalls163[k3_ViewSquare_D2C]._box);
 }
 
-void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
+void DisplayMan::drawSquareD1L(Direction dir, int16 posX, int16 posY) {
 	static Frame doorFrameTopD1L = Frame(0, 31, 14, 17, 64, 4, 16, 0); // @ G0176_s_Graphic558_Frame_DoorFrameTop_D1L
 	static Frame frameStairsUpFrontD1L = Frame(0, 31, 9, 108, 16, 100, 0, 0); // @ G0116_s_Graphic558_Frame_StairsUpFront_D1L
 	static Frame frameStairsDownFrontD1L = Frame(0, 31, 18, 108, 16, 91, 0, 0); // @ G0127_s_Graphic558_Frame_StairsDownFront_D1L
@@ -1719,48 +1719,48 @@ void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
-			f104_drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, frameStairsUpFrontD1L);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexUpFrontD1L, frameStairsUpFrontD1L);
 		else
-			f104_drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, frameStairsDownFrontD1L);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexDownFrontD1L, frameStairsDownFrontD1L);
 
 		order = k0x0032_CellOrder_BackRight_FrontRight;
 		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
-		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1L, posX, posY, false);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
+		drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1L, posX, posY, false);
 		break;
 	case k0_ElementTypeWall:
-		f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, _frameWalls163[k7_ViewSquare_D1L]);
-		f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT);
+		drawWallSetBitmap(_bitmapWallSetD1LCR, _frameWalls163[k7_ViewSquare_D1L]);
+		isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT);
 		return;
 	case k18_ElementTypeStairsSide:
 		if (squareAspect[k2_StairsUpAspect])
-			f104_drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, frameStairsUpSideD1L);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexUpSideD1L, frameStairsUpSideD1L);
 		else
-			f104_drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, frameStairsDownSideD1L);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexDownSideD1L, frameStairsDownSideD1L);
 		// No break on purpose
 	case k16_DoorSideElemType:
 		order = k0x0032_CellOrder_BackRight_FrontRight;
 		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
-		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1L, posX, posY, false);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
+		drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1L, posX, posY, false);
 		break;
 	case k17_DoorFrontElemType:
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, k0x0028_CellOrder_DoorPass1_BackRight);
-		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, doorFrameTopD1L);
-		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g695_doorNativeBitmapIndex_Front_D1LCR, bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1L);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, k0x0028_CellOrder_DoorPass1_BackRight);
+		drawWallSetBitmap(_bitmapWallSetDoorFrameTopD1LCR, doorFrameTopD1L);
+		drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
+					  _doorNativeBitmapIndexFrontD1LCR, bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1L);
 		order = k0x0039_CellOrder_DoorPass2_FrontRight;
 		break;
 	case k2_ElementTypePit:
-		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k59_floorPit_invisible_D1L_GraphicIndice : k53_FloorPit_D1L_GraphicIndice, frameFloorPitD1L);
+		drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k59_floorPit_invisible_D1L_GraphicIndice : k53_FloorPit_D1L_GraphicIndice, frameFloorPitD1L);
 		// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
 		order = k0x0032_CellOrder_BackRight_FrontRight;
 		 /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
-		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1L, posX, posY, false);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L);
+		drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1L, posX, posY, false);
 		break;
 	default:
 		skip = true;
@@ -1768,13 +1768,13 @@ void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) {
 	}
 
 	if (!skip)
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, order);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, order);
 
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
-		f113_drawField(&_fieldAspects188[k7_ViewSquare_D1L], _frameWalls163[k7_ViewSquare_D1L]._box);
+		drawField(&_fieldAspects188[k7_ViewSquare_D1L], _frameWalls163[k7_ViewSquare_D1L]._box);
 }
 
-void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {
+void DisplayMan::drawSquareD1R(Direction dir, int16 posX, int16 posY) {
 	static Frame doorFrameTopD1R = Frame(192, 223, 14, 17, 64, 4, 16, 0); // @ G0178_s_Graphic558_Frame_DoorFrameTop_D1R
 	static Frame frameStairsUpFrontD1R = Frame(192, 223, 9, 108, 16, 100, 0, 0); // @ G0118_s_Graphic558_Frame_StairsUpFront_D1R
 	static Frame frameStairsDownFrontD1R = Frame(192, 223, 18, 108, 16, 91, 0, 0); // @ G0129_s_Graphic558_Frame_StairsDownFront_D1R
@@ -1804,47 +1804,47 @@ void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, frameStairsUpFrontD1R);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_stairsNativeBitmapIndexUpFrontD1L, frameStairsUpFrontD1R);
 		else
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, frameStairsDownFrontD1R);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_stairsNativeBitmapIndexDownFrontD1L, frameStairsDownFrontD1R);
 
 		order = k0x0041_CellOrder_BackLeft_FrontLeft;
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1R, posX, posY, true);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1R, posX, posY, true);
 		break;
 	case k0_ElementTypeWall:
-		f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, _frameWalls163[k8_ViewSquare_D1R]);
-		f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT);
+		drawWallSetBitmap(_bitmapWallSetD1LCR, _frameWalls163[k8_ViewSquare_D1R]);
+		isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT);
 		return;
 	case k18_ElementTypeStairsSide:
 		if (squareAspect[k2_StairsUpAspect])
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, frameStairsUpSideD1R);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_stairsNativeBitmapIndexUpSideD1L, frameStairsUpSideD1R);
 		else
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, frameStairsDownSideD1R);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_stairsNativeBitmapIndexDownSideD1L, frameStairsDownSideD1R);
 
 		// No break on purpose
 	case k16_DoorSideElemType:
 		order = k0x0041_CellOrder_BackLeft_FrontLeft;
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1R, posX, posY, true);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1R, posX, posY, true);
 		break;
 	case k17_DoorFrontElemType:
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R);
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, k0x0018_CellOrder_DoorPass1_BackLeft);
-		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, doorFrameTopD1R);
-		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g695_doorNativeBitmapIndex_Front_D1LCR, bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1R);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, k0x0018_CellOrder_DoorPass1_BackLeft);
+		drawWallSetBitmap(_bitmapWallSetDoorFrameTopD1LCR, doorFrameTopD1R);
+		drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
+					  _doorNativeBitmapIndexFrontD1LCR, bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1R);
 		order = k0x0049_CellOrder_DoorPass2_FrontLeft;
 		break;
 	case k2_ElementTypePit:
-		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect] ? k59_floorPit_invisible_D1L_GraphicIndice
+		drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect] ? k59_floorPit_invisible_D1L_GraphicIndice
 														   : k53_FloorPit_D1L_GraphicIndice, frameFloorPitD1R);
 		// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
 		order = k0x0041_CellOrder_BackLeft_FrontLeft;
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1R, posX, posY, true);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
+		drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &frameCeilingPitD1R, posX, posY, true);
 		break;
 	default:
 		skip = true;
@@ -1852,13 +1852,13 @@ void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) {
 	}
 
 	if (!skip)
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, order);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, order);
 
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
-		f113_drawField(&_fieldAspects188[k8_ViewSquare_D1R], _frameWalls163[k8_ViewSquare_D1R]._box);
+		drawField(&_fieldAspects188[k8_ViewSquare_D1R], _frameWalls163[k8_ViewSquare_D1R]._box);
 }
 
-void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
+void DisplayMan::drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 	static Frame doorFrameTopD1C = Frame(48, 175, 14, 17, 64, 4, 0, 0); // @ G0177_s_Graphic558_Frame_DoorFrameTop_D1C
 	static Frame frameStairsUpFrontD1C = Frame(32, 191, 9, 108, 80, 100, 0, 0); // @ G0117_s_Graphic558_Frame_StairsUpFront_D1C
 	static Frame frameStairsDownFrontD1C = Frame(32, 191, 18, 108, 80, 91, 0, 0); // @ G0128_s_Graphic558_Frame_StairsDownFront_D1C
@@ -1874,62 +1874,62 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 	switch (_vm->_dungeonMan->_squareAheadElement = (ElementType)squareAspect[k0_ElementAspect]) {
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect])
-			f104_drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, frameStairsUpFrontD1C);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexUpFrontD1C, frameStairsUpFrontD1C);
 		else
-			f104_drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, frameStairsDownFrontD1C);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexDownFrontD1C, frameStairsDownFrontD1C);
 
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
 		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C);
-		f112_drawCeilingPit(k66_ceilingPitD1C_GraphicIndice, &frameCeilingPitD1C, posX, posY, false);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C);
+		drawCeilingPit(k66_ceilingPitD1C_GraphicIndice, &frameCeilingPitD1C, posX, posY, false);
 		break;
 	case k0_ElementTypeWall:
 		_vm->_dungeonMan->_isFacingAlcove = false;
 		_vm->_dungeonMan->_isFacingViAltar = false;
 		_vm->_dungeonMan->_isFacingFountain = false;
 		if (_vm->_championMan->_party._event73Count_ThievesEye) {
-			f491_isDerivedBitmapInCache(k1_DerivedBitmapThievesEyeVisibleArea);
-			f132_blitToBitmap(_g296_bitmapViewport, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
+			isDerivedBitmapInCache(k1_DerivedBitmapThievesEyeVisibleArea);
+			blitToBitmap(_bitmapViewport, getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
 							  boxThievesEyeVisibleArea, _boxThievesEyeViewPortVisibleArea._x1, _boxThievesEyeViewPortVisibleArea._y1,
 							  k112_byteWidthViewport, 48, kM1_ColorNoTransparency, 136, 95);
-			byte *bitmap = f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice);
-			f132_blitToBitmap(bitmap, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
+			byte *bitmap = getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice);
+			blitToBitmap(bitmap, getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
 							  boxThievesEyeVisibleArea, 0, 0, 48, 48, k10_ColorFlesh, 95, 95);
 		}
-		f101_drawWallSetBitmapWithoutTransparency(_g700_bitmapWallSet_Wall_D1LCR, _frameWalls163[k6_ViewSquare_D1C]);
-		if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT))
-			f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, k0x0000_CellOrder_Alcove);
+		drawWallSetBitmapWithoutTransparency(_bitmapWallSetD1LCR, _frameWalls163[k6_ViewSquare_D1C]);
+		if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT))
+			drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, k0x0000_CellOrder_Alcove);
 
 		if (_vm->_championMan->_party._event73Count_ThievesEye) {
-			f132_blitToBitmap(f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
-							  _g296_bitmapViewport, _boxThievesEyeViewPortVisibleArea, 0, 0,
+			blitToBitmap(getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea),
+							  _bitmapViewport, _boxThievesEyeViewPortVisibleArea, 0, 0,
 							  48, k112_byteWidthViewport, k9_ColorGold, 95, k136_heightViewport); /* BUG0_74 */
-			f493_addDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea);
-			f480_releaseBlock(k1_DerivedBitmapThievesEyeVisibleArea | 0x8000);
+			addDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea);
+			releaseBlock(k1_DerivedBitmapThievesEyeVisibleArea | 0x8000);
 		}
 		return;
 	case k17_DoorFrontElemType:
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C);
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
-		f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, doorFrameTopD1C);
-		f100_drawWallSetBitmap(_g708_bitmapWallSet_DoorFrameLeft_D1C, _doorFrameLeftD1C);
-		f100_drawWallSetBitmap(_g710_bitmapWallSet_DoorFrameRight_D1C, _doorFrameRightD1C);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight);
+		drawWallSetBitmap(_bitmapWallSetDoorFrameTopD1LCR, doorFrameTopD1C);
+		drawWallSetBitmap(_bitmapWallSetDoorFrameLeftD1C, _doorFrameLeftD1C);
+		drawWallSetBitmap(_bitmapWallSetDoorFrameRightD1C, _doorFrameRightD1C);
 		if (((Door *)_vm->_dungeonMan->_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton())
-			f110_drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C);
+			drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C);
 
-		f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
-					  _g695_doorNativeBitmapIndex_Front_D1LCR, bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, _doorFrameD1C);
+		drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect],
+					  _doorNativeBitmapIndexFrontD1LCR, bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, _doorFrameD1C);
 		order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight;
 		break;
 	case k2_ElementTypePit:
-		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k60_floorPitInvisibleD1C_GraphicIndice : k54_FloorPit_D1C_GraphicIndice, frameFloorPitD1C);
+		drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k60_floorPitInvisibleD1C_GraphicIndice : k54_FloorPit_D1C_GraphicIndice, frameFloorPitD1C);
 		// No break on purpose
 	case k5_ElementTypeTeleporter:
 	case k1_CorridorElemType:
 		order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight;
 		/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */
-		f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C);
-		f112_drawCeilingPit(k66_ceilingPitD1C_GraphicIndice, &frameCeilingPitD1C, posX, posY, false);
+		drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C);
+		drawCeilingPit(k66_ceilingPitD1C_GraphicIndice, &frameCeilingPitD1C, posX, posY, false);
 		break;
 	default:
 		skip = true;
@@ -1937,13 +1937,13 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) {
 	}
 
 	if (!skip)
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, order);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, order);
 
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
-		f113_drawField(&_fieldAspects188[k6_ViewSquare_D1C], _frameWalls163[k6_ViewSquare_D1C]._box);
+		drawField(&_fieldAspects188[k6_ViewSquare_D1C], _frameWalls163[k6_ViewSquare_D1C]._box);
 }
 
-void DisplayMan::f125_drawSquareD0L(Direction dir, int16 posX, int16 posY) {
+void DisplayMan::drawSquareD0L(Direction dir, int16 posX, int16 posY) {
 	static Frame frameStairsSideD0L = Frame(0, 15, 73, 85, 8, 13, 0, 0); // @ G0138_s_Graphic558_Frame_StairsSide_D0L
 	static Frame frameFloorPitD0L = Frame(0, 31, 124, 135, 16, 12, 0, 0); // @ G0149_s_Graphic558_Frame_FloorPit_D0L
 	static Frame frameCeilingPitD0L = Frame(0, 15, 0, 3, 8, 4, 0, 0); // @ G0158_s_Graphic558_Frame_CeilingPit_D0L
@@ -1952,29 +1952,29 @@ void DisplayMan::f125_drawSquareD0L(Direction dir, int16 posX, int16 posY) {
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k0_WallElemType:
-		f100_drawWallSetBitmap(_g701_bitmapWallSet_Wall_D0L, _frameWalls163[k10_ViewSquare_D0L]);
+		drawWallSetBitmap(bitmapWallSetWallD0L, _frameWalls163[k10_ViewSquare_D0L]);
 		break;
 	case k1_CorridorElemType:
 	case k5_TeleporterElemType:
 	case k16_DoorSideElemType:
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k10_ViewSquare_D0L, k0x0002_CellOrder_BackRight);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k10_ViewSquare_D0L, k0x0002_CellOrder_BackRight);
 		break;
 	case k2_PitElemType:
-		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k61_floorPitInvisibleD0L_GraphicIndice : k55_FloorPit_D0L_GraphicIndice, frameFloorPitD0L);
+		drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k61_floorPitInvisibleD0L_GraphicIndice : k55_FloorPit_D0L_GraphicIndice, frameFloorPitD0L);
 	case k18_StairsSideElemType:
 		if (squareAspect[k2_StairsUpAspect])
-			f104_drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, frameStairsSideD0L);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexSideD0L, frameStairsSideD0L);
 		break;
 	default:
 		break;
 	}
 
-	f112_drawCeilingPit(k67_ceilingPitD0L_grahicIndice, &frameCeilingPitD0L, posX, posY, false);
+	drawCeilingPit(k67_ceilingPitD0L_grahicIndice, &frameCeilingPitD0L, posX, posY, false);
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
-		f113_drawField(&_fieldAspects188[k10_ViewSquare_D0L], _frameWalls163[k10_ViewSquare_D0L]._box);
+		drawField(&_fieldAspects188[k10_ViewSquare_D0L], _frameWalls163[k10_ViewSquare_D0L]._box);
 }
 
-void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
+void DisplayMan::drawSquareD0R(Direction dir, int16 posX, int16 posY) {
 	static Frame frameStairsSideD0R = Frame(208, 223, 73, 85, 8, 13, 0, 0); // @ G0139_s_Graphic558_Frame_StairsSide_D0R
 	static Frame frameFloorPitD0R = Frame(192, 223, 124, 135, 16, 12, 0, 0); // @ G0151_s_Graphic558_Frame_FloorPit_D0R
 	static Frame frameCeilingPitD0R = Frame(208, 223, 0, 3, 8, 4, 0, 0); // @ G0160_s_Graphic558_Frame_CeilingPit_D0R
@@ -1984,26 +1984,26 @@ void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) {
 	_vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY);
 	switch (squareAspect[k0_ElementAspect]) {
 	case k18_ElementTypeStairsSide:
-		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, frameStairsSideD0R);
+		drawFloorPitOrStairsBitmapFlippedHorizontally(_stairsNativeBitmapIndexSideD0L, frameStairsSideD0R);
 		return;
 	case k2_ElementTypePit:
-		f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect] ? k61_floorPitInvisibleD0L_GraphicIndice
+		drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect] ? k61_floorPitInvisibleD0L_GraphicIndice
 														   : k55_FloorPit_D0L_GraphicIndice, frameFloorPitD0R);
 	case k1_CorridorElemType:
 	case k16_DoorSideElemType:
 	case k5_ElementTypeTeleporter:
-		f112_drawCeilingPit(k67_ceilingPitD0L_grahicIndice, &frameCeilingPitD0R, posX, posY, true);
-		f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k11_ViewSquare_D0R, k0x0001_CellOrder_BackLeft);
+		drawCeilingPit(k67_ceilingPitD0L_grahicIndice, &frameCeilingPitD0R, posX, posY, true);
+		drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k11_ViewSquare_D0R, k0x0001_CellOrder_BackLeft);
 		break;
 	case k0_ElementTypeWall:
-		f100_drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, _frameWalls163[k11_ViewSquare_D0R]);
+		drawWallSetBitmap(_bitmapWallSetWallD0R, _frameWalls163[k11_ViewSquare_D0R]);
 		return;
 	}
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
-		f113_drawField(&_fieldAspects188[k11_ViewSquare_D0R], _frameWalls163[k11_ViewSquare_D0R]._box);
+		drawField(&_fieldAspects188[k11_ViewSquare_D0R], _frameWalls163[k11_ViewSquare_D0R]._box);
 }
 
-void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
+void DisplayMan::drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 	static Frame doorFrameD0C = Frame(96, 127, 0, 122, 16, 123, 0, 0); // @ G0172_s_Graphic558_Frame_DoorFrame_D0C
 	static Frame frameStairsUpFrontD0L = Frame(0, 31, 58, 101, 16, 44, 0, 0); // @ G0119_s_Graphic558_Frame_StairsUpFront_D0L
 	static Frame frameStairsDownFrontD0L = Frame(0, 31, 76, 135, 16, 60, 0, 0); // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L
@@ -2019,195 +2019,195 @@ void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
 	switch (squareAspect[k0_ElementAspect]) {
 	case k16_DoorSideElemType:
 		if (_vm->_championMan->_party._event73Count_ThievesEye) {
-			memmove(_g74_tmpBitmap, _g709_bitmapWallSet_DoorFrameFront, 32 * 123);
-			f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice),
-							  _g74_tmpBitmap, boxThievesEyeHoleInDoorFrame, doorFrameD0C._box._x1 - _boxThievesEyeViewPortVisibleArea._x1,
+			memmove(_tmpBitmap, _bitmapWallSetDoorFrameFront, 32 * 123);
+			blitToBitmap(getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice),
+							  _tmpBitmap, boxThievesEyeHoleInDoorFrame, doorFrameD0C._box._x1 - _boxThievesEyeViewPortVisibleArea._x1,
 							  0, 48, 16, k9_ColorGold, 95, 123);
-			f100_drawWallSetBitmap(_g74_tmpBitmap, doorFrameD0C);
+			drawWallSetBitmap(_tmpBitmap, doorFrameD0C);
 		} else
-			f100_drawWallSetBitmap(_g709_bitmapWallSet_DoorFrameFront, doorFrameD0C);
+			drawWallSetBitmap(_bitmapWallSetDoorFrameFront, doorFrameD0C);
 		break;
 	case k19_ElementTypeStaisFront:
 		if (squareAspect[k2_StairsUpAspect]) {
-			f104_drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, frameStairsUpFrontD0L);
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, frameStairsUpFrontD0R);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexUpFrontD0CLeft, frameStairsUpFrontD0L);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_stairsNativeBitmapIndexUpFrontD0CLeft, frameStairsUpFrontD0R);
 		} else {
-			f104_drawFloorPitOrStairsBitmap(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, frameStairsDownFrontD0L);
-			f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, frameStairsDownFrontD0R);
+			drawFloorPitOrStairsBitmap(_stairsNativeBitmapIndexDownFrontD0CLeft, frameStairsDownFrontD0L);
+			drawFloorPitOrStairsBitmapFlippedHorizontally(_stairsNativeBitmapIndexDownFrontD0CLeft, frameStairsDownFrontD0R);
 		}
 		break;
 	case k2_ElementTypePit:
-		f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k62_flootPitInvisibleD0C_graphicIndice : k56_FloorPit_D0C_GraphicIndice, frameFloorPitD0C);
+		drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k62_flootPitInvisibleD0C_graphicIndice : k56_FloorPit_D0C_GraphicIndice, frameFloorPitD0C);
 		break;
 	}
-	f112_drawCeilingPit(k68_ceilingPitD0C_graphicIndice, &frameCeilingPitD0C, posX, posY, false);
-	f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k9_ViewSquare_D0C, k0x0021_CellOrder_BackLeft_BackRight);
+	drawCeilingPit(k68_ceilingPitD0C_graphicIndice, &frameCeilingPitD0C, posX, posY, false);
+	drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k9_ViewSquare_D0C, k0x0021_CellOrder_BackLeft_BackRight);
 	if ((squareAspect[k0_ElementAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect])
-		f113_drawField(&_fieldAspects188[k9_ViewSquare_D0C], _frameWalls163[k9_ViewSquare_D0C]._box);
+		drawField(&_fieldAspects188[k9_ViewSquare_D0C], _frameWalls163[k9_ViewSquare_D0C]._box);
 }
 
-void DisplayMan::f128_drawDungeon(Direction dir, int16 posX, int16 posY) {
+void DisplayMan::drawDungeon(Direction dir, int16 posX, int16 posY) {
 	static Frame ceilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling
 	static Frame floorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor
 	static Frame frameWallD3L2 = Frame(0, 15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2
 
-	if (_g297_drawFloorAndCeilingRequested)
-		f98_drawFloorAndCeiling();
+	if (_drawFloorAndCeilingRequested)
+		drawFloorAndCeiling();
 
-	_g578_useByteBoxCoordinates = true;
+	_useByteBoxCoordinates = true;
 	for (int16 i = 0; i < 6; ++i)
 		_vm->_dungeonMan->_dungeonViewClickableBoxes[i].setToZero();
 
 	for (uint16 i = 0; i < 6; ++i)
 		_vm->_dungeonMan->_dungeonViewClickableBoxes[i]._x1 = 255;
 
-	_g76_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1;
-	if (_g76_useFlippedWallAndFootprintsBitmap) {
-		f100_drawWallSetBitmap(_g85_bitmapCeiling, ceilingFrame);
-		f99_copyBitmapAndFlipHorizontal(_g84_bitmapFloor, _g74_tmpBitmap, k112_byteWidthViewport, 70);
-		f100_drawWallSetBitmap(_g74_tmpBitmap, floorFrame);
-
-		_g698_bitmapWallSet_Wall_D3LCR = _g90_bitmapWall_D3LCR_Flipped;
-		_g699_bitmapWallSet_Wall_D2LCR = _g91_bitmapWall_D2LCR_Flipped;
-		_g700_bitmapWallSet_Wall_D1LCR = _g92_bitmapWall_D1LCR_Flipped;
-		_g701_bitmapWallSet_Wall_D0L = _g93_bitmapWall_D0L_Flipped;
-		_g702_bitmapWallSet_Wall_D0R = _g94_bitmapWall_D0R_Flipped;
+	_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1;
+	if (_useFlippedWallAndFootprintsBitmap) {
+		drawWallSetBitmap(_bitmapCeiling, ceilingFrame);
+		copyBitmapAndFlipHorizontal(_bitmapFloor, _tmpBitmap, k112_byteWidthViewport, 70);
+		drawWallSetBitmap(_tmpBitmap, floorFrame);
+
+		_bitmapWallSetD3LCR = _bitmapWallD3LCRFlipped;
+		_bitmapWallSetD2LCR = _bitmapWallD2LCRFlipped;
+		_bitmapWallSetD1LCR = _bitmapWallD1LCRFlipped;
+		bitmapWallSetWallD0L = _bitmapWallD0LFlipped;
+		_bitmapWallSetWallD0R = _bitmapWallD0RFlipped;
 	} else {
-		f99_copyBitmapAndFlipHorizontal(_g85_bitmapCeiling, _g74_tmpBitmap, k112_byteWidthViewport, 29);
-		f100_drawWallSetBitmap(_g74_tmpBitmap, ceilingFrame);
-		f100_drawWallSetBitmap(_g84_bitmapFloor, floorFrame);
+		copyBitmapAndFlipHorizontal(_bitmapCeiling, _tmpBitmap, k112_byteWidthViewport, 29);
+		drawWallSetBitmap(_tmpBitmap, ceilingFrame);
+		drawWallSetBitmap(_bitmapFloor, floorFrame);
 	}
 
 	if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == k0_WallElemType)
-		f100_drawWallSetBitmap(_g697_bitmapWallSet_Wall_D3L2, frameWallD3L2);
+		drawWallSetBitmap(_bitmapWallSetD3L2, frameWallD3L2);
 
 	if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == k0_WallElemType)
-		f100_drawWallSetBitmap(_g696_bitmapWallSet_Wall_D3R2, _frameWallD3R2);
+		drawWallSetBitmap(_bitmapWallSetD3R2, _frameWallD3R2);
 
 	int16 tmpPosX = posX;
 	int16 tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 4, -1, tmpPosX, tmpPosY);
-	f115_cthulhu(_vm->_dungeonMan->getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM2_ViewSquare_D4L, k0x0001_CellOrder_BackLeft);
+	drawObjectsCreaturesProjectilesExplosions(_vm->_dungeonMan->getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM2_ViewSquare_D4L, k0x0001_CellOrder_BackLeft);
 	tmpPosX = posX;
 	tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 4, 1, tmpPosX, tmpPosY);
-	f115_cthulhu(_vm->_dungeonMan->getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM1_ViewSquare_D4R, k0x0001_CellOrder_BackLeft);
+	drawObjectsCreaturesProjectilesExplosions(_vm->_dungeonMan->getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM1_ViewSquare_D4R, k0x0001_CellOrder_BackLeft);
 	tmpPosX = posX;
 	tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 4, 0, tmpPosX, tmpPosY);
-	f115_cthulhu(_vm->_dungeonMan->getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM3_ViewSquare_D4C, k0x0001_CellOrder_BackLeft);
+	drawObjectsCreaturesProjectilesExplosions(_vm->_dungeonMan->getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM3_ViewSquare_D4C, k0x0001_CellOrder_BackLeft);
 	tmpPosX = posX;
 	tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY);
-	f116_drawSquareD3L(dir, tmpPosX, tmpPosY);
+	drawSquareD3L(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, 1, tmpPosX, tmpPosY);
-	f117_drawSquareD3R(dir, tmpPosX, tmpPosY);
+	drawSquareD3R(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, 0, tmpPosX, tmpPosY);
-	f118_drawSquareD3C(dir, tmpPosX, tmpPosY);
+	drawSquareD3C(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, -1, tmpPosX, tmpPosY);
-	f119_drawSquareD2L(dir, tmpPosX, tmpPosY);
+	drawSquareD2L(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, 1, tmpPosX, tmpPosY);
-	f120_drawSquareD2R(dir, tmpPosX, tmpPosY);
+	drawSquareD2R(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, 0, tmpPosX, tmpPosY);
-	f121_drawSquareD2C(dir, tmpPosX, tmpPosY);
+	drawSquareD2C(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, -1, tmpPosX, tmpPosY);
-	f122_drawSquareD1L(dir, tmpPosX, tmpPosY);
+	drawSquareD1L(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, 1, tmpPosX, tmpPosY);
-	f123_drawSquareD1R(dir, tmpPosX, tmpPosY);
+	drawSquareD1R(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, 0, tmpPosX, tmpPosY);
-	f124_drawSquareD1C(dir, tmpPosX, tmpPosY);
+	drawSquareD1C(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 0, -1, tmpPosX, tmpPosY);
-	f125_drawSquareD0L(dir, tmpPosX, tmpPosY);
+	drawSquareD0L(dir, tmpPosX, tmpPosY);
 	tmpPosX = posX;
 	tmpPosY = posY;
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 0, 1, tmpPosX, tmpPosY);
-	f126_drawSquareD0R(dir, tmpPosX, tmpPosY);
-	f127_drawSquareD0C(dir, posX, posY);
-
-	if (_g76_useFlippedWallAndFootprintsBitmap) {
-		_g698_bitmapWallSet_Wall_D3LCR = _g95_bitmapWall_D3LCR_Native;
-		_g699_bitmapWallSet_Wall_D2LCR = _g96_bitmapWall_D2LCR_Native;
-		_g700_bitmapWallSet_Wall_D1LCR = _g97_bitmapWall_D1LCR_Native;
-		_g701_bitmapWallSet_Wall_D0L = _g98_bitmapWall_D0L_Native;
-		_g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native;
+	drawSquareD0R(dir, tmpPosX, tmpPosY);
+	drawSquareD0C(dir, posX, posY);
+
+	if (_useFlippedWallAndFootprintsBitmap) {
+		_bitmapWallSetD3LCR = _bitmapWallD3LCRNative;
+		_bitmapWallSetD2LCR = _bitmapWallD2LCRNative;
+		_bitmapWallSetD1LCR = _bitmapWallD1LCRNative;
+		bitmapWallSetWallD0L = _bitmapWallD0LNative;
+		_bitmapWallSetWallD0R = _bitmapWallD0RNative;
 	}
 
-	f97_drawViewport((_vm->_dungeonMan->_partyMapIndex != k255_mapIndexEntrance) ? 1 : 0);
+	drawViewport((_vm->_dungeonMan->_partyMapIndex != k255_mapIndexEntrance) ? 1 : 0);
 	if (_vm->_dungeonMan->_partyMapIndex != k255_mapIndexEntrance)
-		f98_drawFloorAndCeiling();
+		drawFloorAndCeiling();
 }
 
-void DisplayMan::f98_drawFloorAndCeiling() {
+void DisplayMan::drawFloorAndCeiling() {
 	Box box(0, 223, 0, 36);
-	f135_fillBoxBitmap(_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport);
-	_g297_drawFloorAndCeilingRequested = false;
+	fillBoxBitmap(_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport);
+	_drawFloorAndCeilingRequested = false;
 }
 
 void DisplayMan::fillScreen(Color color) {
 	memset(getCurrentVgaBuffer(), color, sizeof(byte) * _screenWidth * _screenHeight);
 }
 
-void DisplayMan::f134_fillBitmap(byte *bitmap, Color color, uint16 byteWidth, uint16 height) {
+void DisplayMan::fillBitmap(byte *bitmap, Color color, uint16 byteWidth, uint16 height) {
 	uint16 width = byteWidth * 2;
 	memset(bitmap, color, sizeof(byte) * width * height);
 }
 
-void DisplayMan::f94_loadFloorSet(FloorSet set) {
-	if (_g230_currentFloorSet == set)
+void DisplayMan::loadFloorSet(FloorSet set) {
+	if (_currentFloorSet == set)
 		return;
 
-	_g230_currentFloorSet = set;
+	_currentFloorSet = set;
 	int16 index = (set * k2_FloorSetGraphicCount) + k75_FirstFloorSet;
-	f466_loadIntoBitmap(index, _g84_bitmapFloor);
-	f466_loadIntoBitmap(index + 1, _g85_bitmapCeiling);
+	loadIntoBitmap(index, _bitmapFloor);
+	loadIntoBitmap(index + 1, _bitmapCeiling);
 }
 
-void DisplayMan::f95_loadWallSet(WallSet set) {
-	if ((_g231_currentWallSet == set) && !_vm->_restartGameRequest)
+void DisplayMan::loadWallSet(WallSet set) {
+	if ((_currentWallSet == set) && !_vm->_restartGameRequest)
 		return;
 
-	_g231_currentWallSet = set;
+	_currentWallSet = set;
 
 	int16 graphicIndice = (set * k13_WallSetGraphicCount) + k77_FirstWallSet;
-	f466_loadIntoBitmap(graphicIndice++, _g709_bitmapWallSet_DoorFrameFront);
-	f466_loadIntoBitmap(graphicIndice++, _g708_bitmapWallSet_DoorFrameLeft_D1C);
-	f466_loadIntoBitmap(graphicIndice++, _g707_bitmapWallSet_DoorFrameLeft_D2C);
-	f466_loadIntoBitmap(graphicIndice++, _g706_bitmapWallSet_DoorFrameLeft_D3C);
-	f466_loadIntoBitmap(graphicIndice++, _g705_bitmapWallSet_DoorFrameLeft_D3L);
-	f466_loadIntoBitmap(graphicIndice++, _g704_bitmapWallSet_DoorFrameTop_D1LCR);
-	f466_loadIntoBitmap(graphicIndice++, _g703_bitmapWallSet_DoorFrameTop_D2LCR);
-	f466_loadIntoBitmap(graphicIndice++, _g702_bitmapWallSet_Wall_D0R);
-	f466_loadIntoBitmap(graphicIndice++, _g701_bitmapWallSet_Wall_D0L);
-	f466_loadIntoBitmap(graphicIndice++, _g700_bitmapWallSet_Wall_D1LCR);
-	f466_loadIntoBitmap(graphicIndice++, _g699_bitmapWallSet_Wall_D2LCR);
-	f466_loadIntoBitmap(graphicIndice++, _g698_bitmapWallSet_Wall_D3LCR);
-	f466_loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2);
-
-	f99_copyBitmapAndFlipHorizontal(_g708_bitmapWallSet_DoorFrameLeft_D1C, _g710_bitmapWallSet_DoorFrameRight_D1C,
+	loadIntoBitmap(graphicIndice++, _bitmapWallSetDoorFrameFront);
+	loadIntoBitmap(graphicIndice++, _bitmapWallSetDoorFrameLeftD1C);
+	loadIntoBitmap(graphicIndice++, _bitmapWallSetDoorFrameLeftD2C);
+	loadIntoBitmap(graphicIndice++, _bitmapWallSetDoorFrameLeftD3C);
+	loadIntoBitmap(graphicIndice++, _bitmapWallSetDoorFrameLeftD3L);
+	loadIntoBitmap(graphicIndice++, _bitmapWallSetDoorFrameTopD1LCR);
+	loadIntoBitmap(graphicIndice++, _bitmapWallSetDoorFrameTopD2LCR);
+	loadIntoBitmap(graphicIndice++, _bitmapWallSetWallD0R);
+	loadIntoBitmap(graphicIndice++, bitmapWallSetWallD0L);
+	loadIntoBitmap(graphicIndice++, _bitmapWallSetD1LCR);
+	loadIntoBitmap(graphicIndice++, _bitmapWallSetD2LCR);
+	loadIntoBitmap(graphicIndice++, _bitmapWallSetD3LCR);
+	loadIntoBitmap(graphicIndice++, _bitmapWallSetD3L2);
+
+	copyBitmapAndFlipHorizontal(_bitmapWallSetDoorFrameLeftD1C, _bitmapWallSetDoorFrameRightD1C,
 									_doorFrameRightD1C._srcByteWidth, _doorFrameRightD1C._srcHeight);
-	f99_copyBitmapAndFlipHorizontal(_g697_bitmapWallSet_Wall_D3L2, _g696_bitmapWallSet_Wall_D3R2,
+	copyBitmapAndFlipHorizontal(_bitmapWallSetD3L2, _bitmapWallSetD3R2,
 									_frameWallD3R2._srcByteWidth, _frameWallD3R2._srcHeight);
 }
 
-void DisplayMan::f96_loadCurrentMapGraphics() {
+void DisplayMan::loadCurrentMapGraphics() {
 	static Box BoxWallD3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR
 	static Box BoxWallD2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR
 	static byte doorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordinateSetIndices
@@ -2303,123 +2303,123 @@ void DisplayMan::f96_loadCurrentMapGraphics() {
 		3};  /* Arched Alcove */
 	static int16 g193_FountainOrnIndices[k1_FountainOrnCount] = {35}; // @ G0193_ai_Graphic558_FountainOrnamentIndices
 
-	f94_loadFloorSet(_vm->_dungeonMan->_currMap->_floorSet);
-	f95_loadWallSet(_vm->_dungeonMan->_currMap->_wallSet);
+	loadFloorSet(_vm->_dungeonMan->_currMap->_floorSet);
+	loadWallSet(_vm->_dungeonMan->_currMap->_wallSet);
 
-	_g578_useByteBoxCoordinates = true;
+	_useByteBoxCoordinates = true;
 
-	f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap,
+	copyBitmapAndFlipHorizontal(_bitmapWallD3LCRNative = _bitmapWallSetD3LCR, _tmpBitmap,
 									_frameWalls163[k0_ViewSquare_D3C]._srcByteWidth, _frameWalls163[k0_ViewSquare_D3C]._srcHeight);
-	f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, k10_ColorFlesh, 64, 51);
-	f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, BoxWallD3LCR, 11, 0, 64, 64, kM1_ColorNoTransparency, 51, 51);
+	fillBitmap(_bitmapWallD3LCRFlipped, k10_ColorFlesh, 64, 51);
+	blitToBitmap(_tmpBitmap, _bitmapWallD3LCRFlipped, BoxWallD3LCR, 11, 0, 64, 64, kM1_ColorNoTransparency, 51, 51);
 
-	f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap,
+	copyBitmapAndFlipHorizontal(_bitmapWallD2LCRNative = _bitmapWallSetD2LCR, _tmpBitmap,
 									_frameWalls163[k3_ViewSquare_D2C]._srcByteWidth, _frameWalls163[k3_ViewSquare_D2C]._srcHeight);
-	f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, k10_ColorFlesh, 72, 71);
-	f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, BoxWallD2LCR, 8, 0, 72, 72, kM1_ColorNoTransparency, 71, 71);
+	fillBitmap(_bitmapWallD2LCRFlipped, k10_ColorFlesh, 72, 71);
+	blitToBitmap(_tmpBitmap, _bitmapWallD2LCRFlipped, BoxWallD2LCR, 8, 0, 72, 72, kM1_ColorNoTransparency, 71, 71);
 
-	f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped,
+	copyBitmapAndFlipHorizontal(_bitmapWallD1LCRNative = _bitmapWallSetD1LCR, _bitmapWallD1LCRFlipped,
 									_frameWalls163[k6_ViewSquare_D1C]._srcByteWidth, _frameWalls163[k6_ViewSquare_D1C]._srcHeight);
-	f99_copyBitmapAndFlipHorizontal(_g98_bitmapWall_D0L_Native = _g701_bitmapWallSet_Wall_D0L, _g94_bitmapWall_D0R_Flipped,
+	copyBitmapAndFlipHorizontal(_bitmapWallD0LNative = bitmapWallSetWallD0L, _bitmapWallD0RFlipped,
 									_frameWalls163[k10_ViewSquare_D0L]._srcByteWidth, _frameWalls163[k10_ViewSquare_D0L]._srcHeight);
-	f99_copyBitmapAndFlipHorizontal(_g99_bitmapWall_D0R_Native = _g702_bitmapWallSet_Wall_D0R, _g93_bitmapWall_D0L_Flipped,
+	copyBitmapAndFlipHorizontal(_bitmapWallD0RNative = _bitmapWallSetWallD0R, _bitmapWallD0LFlipped,
 									_frameWalls163[k10_ViewSquare_D0L]._srcByteWidth, _frameWalls163[k10_ViewSquare_D0L]._srcHeight);
 
 	int16 val = _vm->_dungeonMan->_currMap->_wallSet * k18_StairsGraphicCount + k90_FirstStairs;
-	_g675_stairsNativeBitmapIndex_Up_Front_D3L = val++;
-	_g676_stairsNativeBitmapIndex_Up_Front_D3C = val++;
-	_g677_stairsNativeBitmapIndex_Up_Front_D2L = val++;
-	_g678_stairsNativeBitmapIndex_Up_Front_D2C = val++;
-	_g679_stairsNativeBitmapIndex_Up_Front_D1L = val++;
-	_g680_stairsNativeBitmapIndex_Up_Front_D1C = val++;
-	_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left = val++;
-	_g682_stairsNativeBitmapIndex_Down_Front_D3L = val++;
-	_g683_stairsNativeBitmapIndex_Down_Front_D3C = val++;
-	_g684_stairsNativeBitmapIndex_Down_Front_D2L = val++;
-	_g685_stairsNativeBitmapIndex_Down_Front_D2C = val++;
-	_g686_stairsNativeBitmapIndex_Down_Front_D1L = val++;
-	_g687_stairsNativeBitmapIndex_Down_Front_D1C = val++;
-	_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left = val++;
-	_g689_stairsNativeBitmapIndex_Side_D2L = val++;
-	_g690_stairsNativeBitmapIndex_Up_Side_D1L = val++;
-	_g691_stairsNativeBitmapIndex_Down_Side_D1L = val++;
-	_g692_stairsNativeBitmapIndex_Side_D0L = val++;
+	_stairsNativeBitmapIndexUpFrontD3L = val++;
+	_stairsNativeBitmapIndexUpFrontD3C = val++;
+	_stairsNativeBitmapIndexUpFrontD2L = val++;
+	_stairsNativeBitmapIndexUpFrontD2C = val++;
+	_stairsNativeBitmapIndexUpFrontD1L = val++;
+	_stairsNativeBitmapIndexUpFrontD1C = val++;
+	_stairsNativeBitmapIndexUpFrontD0CLeft = val++;
+	_stairsNativeBitmapIndexDownFrontD3L = val++;
+	_stairsNativeBitmapIndexDownFrontD3C = val++;
+	_stairsNativeBitmapIndexDownFrontD2L = val++;
+	_stairsNativeBitmapIndexDownFrontD2C = val++;
+	_stairsNativeBitmapIndexDownFrontD1L = val++;
+	_stairsNativeBitmapIndexDownFrontD1C = val++;
+	_stairsNativeBitmapIndexDownFrontD0CLeft = val++;
+	_stairsNativeBitmapIndexSideD2L = val++;
+	_stairsNativeBitmapIndexUpSideD1L = val++;
+	_stairsNativeBitmapIndexDownSideD1L = val++;
+	_stairsNativeBitmapIndexSideD0L = val++;
 
 	for (int16 i = 0; i < k3_AlcoveOrnCount; ++i)
-		_g267_currMapAlcoveOrnIndices[i] = -1;
+		_currMapAlcoveOrnIndices[i] = -1;
 
 	for (int16 i = 0; i < k1_FountainOrnCount; ++i)
-		_g268_currMapFountainOrnIndices[i] = -1;
+		_currMapFountainOrnIndices[i] = -1;
 
 	uint16 doorSets[2];
 	doorSets[0] = _vm->_dungeonMan->_currMap->_doorSet0;
 	doorSets[1] = _vm->_dungeonMan->_currMap->_doorSet1;
 	for (uint16 doorSet = 0; doorSet <= 1; doorSet++) {
 		int16 counter = k108_FirstDoorSet + (doorSets[doorSet] * k3_DoorSetGraphicsCount);
-		_g693_doorNativeBitmapIndex_Front_D3LCR[doorSet] = counter++;
-		_g694_doorNativeBitmapIndex_Front_D2LCR[doorSet] = counter++;
-		_g695_doorNativeBitmapIndex_Front_D1LCR[doorSet] = counter++;
+		_doorNativeBitmapIndexFrontD3LCR[doorSet] = counter++;
+		_doorNativeBitmapIndexFrontD2LCR[doorSet] = counter++;
+		_doorNativeBitmapIndexFrontD1LCR[doorSet] = counter++;
 	}
 
 	uint16 alcoveCount = 0;
 	uint16 fountainCount = 0;
 	Map &currMap = *_vm->_dungeonMan->_currMap;
 
-	_g266_currMapViAltarIndex = -1;
+	_currMapViAltarIndex = -1;
 
 	for (int16 ornamentIndex = 0; ornamentIndex <= currMap._wallOrnCount; ornamentIndex++) {
-		int16 greenOrn = _g261_currMapWallOrnIndices[ornamentIndex];
+		int16 greenOrn = _currMapWallOrnIndices[ornamentIndex];
 		int16 counter = k121_FirstWallOrn + greenOrn * 2; /* Each wall ornament has 2 graphics */
-		_g101_currMapWallOrnInfo[ornamentIndex][k0_NativeBitmapIndex] = counter;
+		_currMapWallOrnInfo[ornamentIndex][k0_NativeBitmapIndex] = counter;
 		for (int16 ornamentCounter = 0; ornamentCounter < k3_AlcoveOrnCount; ornamentCounter++) {
 			if (greenOrn == g192_AlcoveOrnIndices[ornamentCounter]) {
-				_g267_currMapAlcoveOrnIndices[alcoveCount++] = ornamentIndex;
+				_currMapAlcoveOrnIndices[alcoveCount++] = ornamentIndex;
 				if (greenOrn == 2) /* Wall ornament #2 is the Vi Altar */
-					_g266_currMapViAltarIndex = ornamentIndex;
+					_currMapViAltarIndex = ornamentIndex;
 			}
 		}
 		for (int16 ornamentCounter = 0; ornamentCounter < k1_FountainOrnCount; ornamentCounter++) {
 			if (greenOrn == g193_FountainOrnIndices[ornamentCounter])
-				_g268_currMapFountainOrnIndices[fountainCount++] = ornamentIndex;
+				_currMapFountainOrnIndices[fountainCount++] = ornamentIndex;
 		}
 
-		_g101_currMapWallOrnInfo[ornamentIndex][k1_CoordinateSet] = g194_WallOrnCoordSetIndices[greenOrn];
+		_currMapWallOrnInfo[ornamentIndex][k1_CoordinateSet] = g194_WallOrnCoordSetIndices[greenOrn];
 	}
 
 
 	for (uint16 i = 0; i < currMap._floorOrnCount; ++i) {
-		uint16 ornIndice = _g262_currMapFloorOrnIndices[i];
+		uint16 ornIndice = _currMapFloorOrnIndices[i];
 		uint16 nativeIndice = k247_FirstFloorOrn + ornIndice * 6;
-		_g102_currMapFloorOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice;
-		_g102_currMapFloorOrnInfo[i][k1_CoordinateSet] = floorOrnCoordSetIndices[ornIndice];
+		_currMapFloorOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice;
+		_currMapFloorOrnInfo[i][k1_CoordinateSet] = floorOrnCoordSetIndices[ornIndice];
 	}
 
 	for (uint16 i = 0; i < currMap._doorOrnCount; ++i) {
-		uint16 ornIndice = _g263_currMapDoorOrnIndices[i];
+		uint16 ornIndice = _currMapDoorOrnIndices[i];
 		uint16 nativeIndice = k303_FirstDoorOrn + ornIndice;
-		_g103_currMapDoorOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice;
-		_g103_currMapDoorOrnInfo[i][k1_CoordinateSet] = doorOrnCoordIndices[ornIndice];
+		_currMapDoorOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice;
+		_currMapDoorOrnInfo[i][k1_CoordinateSet] = doorOrnCoordIndices[ornIndice];
 	}
 
-	f93_applyCreatureReplColors(9, 8);
-	f93_applyCreatureReplColors(10, 12);
+	applyCreatureReplColors(9, 8);
+	applyCreatureReplColors(10, 12);
 
 	for (uint16 creatureType = 0; creatureType < currMap._creatureTypeCount; ++creatureType) {
-		CreatureAspect &aspect = _creatureAspects219[_g264_currMapAllowedCreatureTypes[creatureType]];
+		CreatureAspect &aspect = _creatureAspects219[_currMapAllowedCreatureTypes[creatureType]];
 		uint16 replColorOrdinal = aspect.getReplColour9();
 		if (replColorOrdinal)
-			f93_applyCreatureReplColors(9, _vm->ordinalToIndex(replColorOrdinal));
+			applyCreatureReplColors(9, _vm->ordinalToIndex(replColorOrdinal));
 
 		replColorOrdinal = aspect.getReplColour10();
 		if (replColorOrdinal)
-			f93_applyCreatureReplColors(10, _vm->ordinalToIndex(replColorOrdinal));
+			applyCreatureReplColors(10, _vm->ordinalToIndex(replColorOrdinal));
 	}
 
-	_g297_drawFloorAndCeilingRequested = true;
-	_g342_refreshDungeonViewPaleteRequested = true;
+	_drawFloorAndCeilingRequested = true;
+	_refreshDungeonViewPaleteRequested = true;
 }
 
-void DisplayMan::f93_applyCreatureReplColors(int replacedColor, int replacementColor) {
+void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor) {
 	CreatureReplColorSet creatureReplColorSets[13] = { // @ G0220_as_Graphic558_CreatureReplacementColorSets
 		/* { Color, Color, Color, Color, Color, Color, D2 replacement color index (x10), D3 replacement color index (x10) } */
 		CreatureReplColorSet(0x0CA0, 0x0A80, 0x0860, 0x0640, 0x0420, 0x0200,  90,  90),    /* Atari ST: { 0x0650, 0x0540, 0x0430, 0x0320, 0x0210, 0x0100,  90,  90 }, RGB colors are different */
@@ -2444,21 +2444,21 @@ void DisplayMan::f93_applyCreatureReplColors(int replacedColor, int replacementC
 	_palChangesCreatureD3[replacedColor] = creatureReplColorSets[replacementColor]._d3ReplacementColor;
 }
 
-void DisplayMan::f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
+void DisplayMan::drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) {
 	if (f._srcByteWidth)
-		f132_blitToBitmap(f489_getNativeBitmapOrGraphic(nativeIndex), _g296_bitmapViewport, f._box, f._srcX, f._srcY,
+		blitToBitmap(getNativeBitmapOrGraphic(nativeIndex), _bitmapViewport, f._box, f._srcX, f._srcY,
 						f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, f._srcHeight, k136_heightViewport);
 }
 
-void DisplayMan::f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) {
+void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) {
 	if (f._srcByteWidth) {
-		f99_copyBitmapAndFlipHorizontal(f489_getNativeBitmapOrGraphic(nativeIndex), _g74_tmpBitmap, f._srcByteWidth, f._srcHeight);
-		f132_blitToBitmap(_g74_tmpBitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth,
+		copyBitmapAndFlipHorizontal(getNativeBitmapOrGraphic(nativeIndex), _tmpBitmap, f._srcByteWidth, f._srcHeight);
+		blitToBitmap(_tmpBitmap, _bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth,
 						k112_byteWidthViewport, k10_ColorFlesh, f._srcHeight, k136_heightViewport);
 	}
 }
 
-bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) {
+bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) {
 	static Box boxWallPatchBehindInscription = Box(110, 113, 37, 63); // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription
 	static const byte inscriptionLineY[4] = { // @ G0203_auc_Graphic558_InscriptionLineY
 		48,   /* 1 Line  */
@@ -2620,14 +2620,14 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 		return false;
 	wallOrnOrd--;
 	int16 wallOrnamentIndex = wallOrnOrd;
-	int16 ornNativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnamentIndex][k0_NativeBitmapIndex];
-	int16 wallOrnamentCoordinateSetIndex = _g101_currMapWallOrnInfo[wallOrnamentIndex][k1_CoordinateSet];
+	int16 ornNativeBitmapIndex = _currMapWallOrnInfo[wallOrnamentIndex][k0_NativeBitmapIndex];
+	int16 wallOrnamentCoordinateSetIndex = _currMapWallOrnInfo[wallOrnamentIndex][k1_CoordinateSet];
 	byte *ornCoordSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][viewWallIndex];
 	bool isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnamentIndex);
 	unsigned char inscriptionString[70];
 	bool isInscription = (wallOrnamentIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex);
 	if (isInscription)
-		_vm->_dungeonMan->decodeText((char*)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription);
+		_vm->_dungeonMan->decodeText((char*)inscriptionString, _inscriptionThing, k0_TextTypeInscription);
 
 	int16 blitPosX;
 	byte *ornBlitBitmap;
@@ -2635,9 +2635,9 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 	if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) {
 		if (viewWallIndex == k12_ViewWall_D1C_FRONT) {
 			if (isInscription) {
-				f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, boxWallPatchBehindInscription, 94, 28, _frameWalls163[k6_ViewSquare_D1C]._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency, _frameWalls163[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport);
+				blitToBitmap(_bitmapWallSetD1LCR, _bitmapViewport, boxWallPatchBehindInscription, 94, 28, _frameWalls163[k6_ViewSquare_D1C]._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency, _frameWalls163[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport);
 				byte *inscrString = inscriptionString;
-				byte *L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont);
+				byte *L0092_puc_Bitmap = getNativeBitmapOrGraphic(k120_InscriptionFont);
 				int16 textLineIndex = 0;
 				do {
 					int16 characterCount = 0;
@@ -2649,7 +2649,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 					blitFrame._box._x2 = (blitFrame._box._x1 = 112 - (characterCount << 2)) + 7;
 					blitFrame._box._y1 = (blitFrame._box._y2 = inscriptionLineY[textLineIndex++]) - 7;
 					while (characterCount--) {
-						f132_blitToBitmap(L0092_puc_Bitmap, _g296_bitmapViewport, blitFrame._box, *inscrString++ << 3, 0, k144_byteWidth, k112_byteWidthViewport, k10_ColorFlesh, 8, k136_heightViewport);
+						blitToBitmap(L0092_puc_Bitmap, _bitmapViewport, blitFrame._box, *inscrString++ << 3, 0, k144_byteWidth, k112_byteWidthViewport, k10_ColorFlesh, 8, k136_heightViewport);
 						blitFrame._box._x1 += 8;
 						blitFrame._box._x2 += 8;
 					}
@@ -2663,19 +2663,19 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 			}
 			_vm->_dungeonMan->_isFacingAlcove = isAlcove;
 			_vm->_dungeonMan->_isFacingViAltar =
-				(wallOrnamentIndex == _g266_currMapViAltarIndex);
+				(wallOrnamentIndex == _currMapViAltarIndex);
 			_vm->_dungeonMan->_isFacingFountain = false;
 			for (int16 idx = 0; idx < k1_FountainOrnCount; idx++) {
-				if (_g268_currMapFountainOrnIndices[idx] == wallOrnamentIndex) {
+				if (_currMapFountainOrnIndices[idx] == wallOrnamentIndex) {
 					_vm->_dungeonMan->_isFacingFountain = true;
 					break;
 				}
 			}
 		}
-		ornBlitBitmap = f489_getNativeBitmapOrGraphic(ornNativeBitmapIndex);
+		ornBlitBitmap = getNativeBitmapOrGraphic(ornNativeBitmapIndex);
 		if (viewWallIndex == k11_ViewWall_D1R_LEFT) {
-			f99_copyBitmapAndFlipHorizontal(ornBlitBitmap, _g74_tmpBitmap, ornCoordSet[4], ornCoordSet[5]);
-			ornBlitBitmap = _g74_tmpBitmap;
+			copyBitmapAndFlipHorizontal(ornBlitBitmap, _tmpBitmap, ornCoordSet[4], ornCoordSet[5]);
+			ornBlitBitmap = _tmpBitmap;
 		}
 		blitPosX = 0;
 	} else {
@@ -2694,15 +2694,15 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 				coordinateSetOffset = -6;
 		}
 		blitPosX = (ornCoordSet + coordinateSetOffset)[1] - (ornCoordSet + coordinateSetOffset)[0];
-		if (!f491_isDerivedBitmapInCache(wallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + (wallOrnamentIndex << 2) + wallOrnDerivedBitmapIndexIncrement[viewWallIndex])) {
-			byte *blitBitmap = f489_getNativeBitmapOrGraphic(ornNativeBitmapIndex);
-			f129_blitToBitmapShrinkWithPalChange(blitBitmap, f492_getDerivedBitmap(wallOrnamentIndex), ornBlitBitmap[4] << 1, ornBlitBitmap[5], ornCoordSet[4] << 1, ornCoordSet[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? _palChangesDoorButtonAndWallOrnD3 : _palChangesDoorButtonAndWallOrnD2);
-			f493_addDerivedBitmap(wallOrnamentIndex);
+		if (!isDerivedBitmapInCache(wallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + (wallOrnamentIndex << 2) + wallOrnDerivedBitmapIndexIncrement[viewWallIndex])) {
+			byte *blitBitmap = getNativeBitmapOrGraphic(ornNativeBitmapIndex);
+			blitToBitmapShrinkWithPalChange(blitBitmap, getDerivedBitmap(wallOrnamentIndex), ornBlitBitmap[4] << 1, ornBlitBitmap[5], ornCoordSet[4] << 1, ornCoordSet[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? _palChangesDoorButtonAndWallOrnD3 : _palChangesDoorButtonAndWallOrnD2);
+			addDerivedBitmap(wallOrnamentIndex);
 		}
-		ornBlitBitmap = f492_getDerivedBitmap(wallOrnamentIndex);
+		ornBlitBitmap = getDerivedBitmap(wallOrnamentIndex);
 		if (flipHorizontal) {
-			f99_copyBitmapAndFlipHorizontal(ornBlitBitmap, _g74_tmpBitmap, ornCoordSet[4], ornCoordSet[5]);
-			ornBlitBitmap = _g74_tmpBitmap;
+			copyBitmapAndFlipHorizontal(ornBlitBitmap, _tmpBitmap, ornCoordSet[4], ornCoordSet[5]);
+			ornBlitBitmap = _tmpBitmap;
 			blitPosX = 15 - (blitPosX & 0x000F);
 		} else if (viewWallIndex == k7_ViewWall_D2L_FRONT) 
 			blitPosX -= ornCoordSet[1] - ornCoordSet[0];
@@ -2730,20 +2730,20 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall
 	}
 
 	Box tmpBox(ornCoordSet);
-	f132_blitToBitmap(ornBlitBitmap, _g296_bitmapViewport, tmpBox,
+	blitToBitmap(ornBlitBitmap, _bitmapViewport, tmpBox,
 		blitPosX, 0,
 		ornCoordSet[4], k112_byteWidthViewport, k10_ColorFlesh, ornCoordSet[5], k136_heightViewport);
 
-	if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) {
-		f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), _g296_bitmapViewport, boxChampionPortraitOnWall,
-			(_g289_championPortraitOrdinal & 0x0007) << 5, (_g289_championPortraitOrdinal >> 3) * 29,
+	if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _championPortraitOrdinal--) {
+		blitToBitmap(getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), _bitmapViewport, boxChampionPortraitOnWall,
+			(_championPortraitOrdinal & 0x0007) << 5, (_championPortraitOrdinal >> 3) * 29,
 			k128_byteWidth, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); /* A portrait is 32x29 pixels */
 	}
 
 	return isAlcove;
 }
 
-void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
+void DisplayMan::blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
 													  int16 srcPixelWidth, int16 srcHeight,
 													  int16 destPixelWidth, int16 destHeight, byte *palChange) {
 	warning(false, "DUMMY CODE: f129_blitToBitmapShrinkWithPalChange");
@@ -2766,7 +2766,7 @@ void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *des
 	}
 }
 
-byte *DisplayMan::f489_getNativeBitmapOrGraphic(uint16 index) {
+byte *DisplayMan::getNativeBitmapOrGraphic(uint16 index) {
 	return _bitmaps[index];
 }
 
@@ -2778,36 +2778,36 @@ uint32 DisplayMan::getCompressedDataSize(uint16 index) {
 	return _packedItemPos[index + 1] - _packedItemPos[index];
 }
 
-void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) {
+void DisplayMan::drawField(FieldAspect* fieldAspect, Box& box) {
 	byte *bitmapMask = nullptr;
 
 	if (fieldAspect->_mask != kMaskFieldAspectNoMask) {
-		bitmapMask = _g74_tmpBitmap;
-		memmove(bitmapMask, f489_getNativeBitmapOrGraphic(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)),
+		bitmapMask = _tmpBitmap;
+		memmove(bitmapMask, getNativeBitmapOrGraphic(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)),
 				fieldAspect->_height * fieldAspect->_byteWidth * 2);
 		if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask)) {
-			f130_flipBitmapHorizontal(bitmapMask, fieldAspect->_byteWidth, fieldAspect->_height);
+			flipBitmapHorizontal(bitmapMask, fieldAspect->_byteWidth, fieldAspect->_height);
 		}
 	}
 
-	f491_isDerivedBitmapInCache(k0_DerivedBitmapViewport);
-	byte *bitmap = f489_getNativeBitmapOrGraphic(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex);
-	f133_blitBoxFilledWithMaskedBitmap(bitmap, _g296_bitmapViewport, bitmapMask, f492_getDerivedBitmap(k0_DerivedBitmapViewport), box,
+	isDerivedBitmapInCache(k0_DerivedBitmapViewport);
+	byte *bitmap = getNativeBitmapOrGraphic(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex);
+	blitBoxFilledWithMaskedBitmap(bitmap, _bitmapViewport, bitmapMask, getDerivedBitmap(k0_DerivedBitmapViewport), box,
 									   _vm->getRandomNumber(2) + fieldAspect->_baseStartUnitIndex, _vm->getRandomNumber(32), k112_byteWidthViewport,
 									   (Color)fieldAspect->_transparentColor, fieldAspect->_xPos, 0, 136, fieldAspect->_bitplaneWordCount);
-	f493_addDerivedBitmap(k0_DerivedBitmapViewport);
-	f480_releaseBlock(k0_DerivedBitmapViewport | 0x8000);
+	addDerivedBitmap(k0_DerivedBitmapViewport);
+	releaseBlock(k0_DerivedBitmapViewport | 0x8000);
 }
 
-int16 DisplayMan::f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale) {
-	return M77_getNormalizedByteWidth(M78_getScaledDimension(byteWidth, scale)) * M78_getScaledDimension(height, scale);
+int16 DisplayMan::getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale) {
+	return getNormalizedByteWidth(getScaledDimension(byteWidth, scale)) * getScaledDimension(height, scale);
 }
 
-int16 DisplayMan::M78_getScaledDimension(int16 dimension, int16 scale) {
+int16 DisplayMan::getScaledDimension(int16 dimension, int16 scale) {
 	return (dimension * scale + scale / 2) / 32;
 }
 
-void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16 mapXpos,
+void DisplayMan::drawObjectsCreaturesProjectilesExplosions(Thing thingParam, Direction directionParam, int16 mapXpos,
 							  int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) {
 	int16 AL_0_creatureGraphicInfoRed;
 	int16 AL_0_creatureIndexRed;
@@ -3129,12 +3129,12 @@ T0115015_DrawProjectileAsObject:
 				if ((viewSquareIndex == k9_ViewSquare_D0C) || ((viewSquareIndex >= k6_ViewSquare_D1C) && (AL_2_viewCell >= k2_ViewCellBackRight))) {
 					drawingGrabbableObject = (!viewLane && !drawProjectileAsObject); /* If object is in the center lane (only D0C or D1C with condition above) and is not a projectile */
 					AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
-					bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */
+					bitmapRedBanana = getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */
 					byteWidth = objectAspect->_byteWidth;
 					heightRedEagle = objectAspect->_height;
 					if (flipHorizontal) {
-						f99_copyBitmapAndFlipHorizontal(bitmapRedBanana, _g74_tmpBitmap, byteWidth, heightRedEagle);
-						bitmapRedBanana = _g74_tmpBitmap;
+						copyBitmapAndFlipHorizontal(bitmapRedBanana, _tmpBitmap, byteWidth, heightRedEagle);
+						bitmapRedBanana = _tmpBitmap;
 					}
 				} else {
 					drawingGrabbableObject = false;
@@ -3143,13 +3143,13 @@ T0115015_DrawProjectileAsObject:
 					if ((viewSquareIndex >= k6_ViewSquare_D1C) || ((viewSquareIndex >= k3_ViewSquare_D2C) && (AL_2_viewCell >= k2_ViewCellBackRight))) {
 						derivedBitmapIndex++;
 						AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front;
-						byteWidth = M78_getScaledDimension(objectAspect->_byteWidth, k20_Scale_D2);
-						heightRedEagle = M78_getScaledDimension(objectAspect->_height, k20_Scale_D2);
+						byteWidth = getScaledDimension(objectAspect->_byteWidth, k20_Scale_D2);
+						heightRedEagle = getScaledDimension(objectAspect->_height, k20_Scale_D2);
 						paletteChanges = _palChangesFloorOrnD2;
 					} else {
 						AL_8_shiftSetIndex = k2_ShiftSet_D2BackD3Front;
-						byteWidth = M78_getScaledDimension(objectAspect->_byteWidth, k16_Scale_D3);
-						heightRedEagle = M78_getScaledDimension(objectAspect->_height, k16_Scale_D3);
+						byteWidth = getScaledDimension(objectAspect->_byteWidth, k16_Scale_D3);
+						heightRedEagle = getScaledDimension(objectAspect->_height, k16_Scale_D3);
 						paletteChanges = _palChangesFloorOrnD3;
 					}
 					if (flipHorizontal) {
@@ -3158,15 +3158,15 @@ T0115015_DrawProjectileAsObject:
 					} else if (useAlcoveObjectImage)
 							derivedBitmapIndex += 4;
 
-					if (f491_isDerivedBitmapInCache(derivedBitmapIndex))
-						bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
+					if (isDerivedBitmapInCache(derivedBitmapIndex))
+						bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
 					else {
-						bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
-						f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), objectAspect->_byteWidth << 1, objectAspect->_height, byteWidth << 1, heightRedEagle, paletteChanges);
+						bitmapGreenAnt = getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
+						blitToBitmapShrinkWithPalChange(bitmapGreenAnt, bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex), objectAspect->_byteWidth << 1, objectAspect->_height, byteWidth << 1, heightRedEagle, paletteChanges);
 						if (flipHorizontal)
-							f130_flipBitmapHorizontal(bitmapRedBanana, M77_getNormalizedByteWidth(byteWidth), heightRedEagle);
+							flipBitmapHorizontal(bitmapRedBanana, getNormalizedByteWidth(byteWidth), heightRedEagle);
 
-						f493_addDerivedBitmap(derivedBitmapIndex);
+						addDerivedBitmap(derivedBitmapIndex);
 					}
 				}
 				AL_4_xPos = coordinateSet[0];
@@ -3217,7 +3217,7 @@ T0115015_DrawProjectileAsObject:
 					bitmapRedBanana = bitmapGreenAnt;
 					_vm->_dungeonMan->_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */
 				}
-				f132_blitToBitmap(bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
+				blitToBitmap(bitmapRedBanana, _bitmapViewport, boxByteGreen, AL_4_xPos, 0, getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
 				if (drawProjectileAsObject)
 					goto T0115171_BackFromT0115015_DrawProjectileAsObject;
 			}
@@ -3364,25 +3364,25 @@ T0115077_DrawSecondHalfSquareCreature:
 			AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
 			transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour();
 			if (useCreatureSideBitmap) {
-				bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
+				bitmapRedBanana = getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 				if (creatureDirectionDelta == 1) {
-					f99_copyBitmapAndFlipHorizontal(bitmapRedBanana, _g74_tmpBitmap, byteWidth, heightRedEagle);
-					bitmapRedBanana = _g74_tmpBitmap;
+					copyBitmapAndFlipHorizontal(bitmapRedBanana, _tmpBitmap, byteWidth, heightRedEagle);
+					bitmapRedBanana = _tmpBitmap;
 				}
 			} else if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) {
-				bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
+				bitmapRedBanana = getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 				if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) {
-					f99_copyBitmapAndFlipHorizontal(bitmapRedBanana, _g74_tmpBitmap, byteWidth, heightRedEagle);
-					bitmapRedBanana = _g74_tmpBitmap;
+					copyBitmapAndFlipHorizontal(bitmapRedBanana, _tmpBitmap, byteWidth, heightRedEagle);
+					bitmapRedBanana = _tmpBitmap;
 				}
-			} else if (f491_isDerivedBitmapInCache(derivedBitmapIndex)) /* If derived graphic is already in memory */
-				bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
+			} else if (isDerivedBitmapInCache(derivedBitmapIndex)) /* If derived graphic is already in memory */
+				bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
 			else {
-				bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
+				bitmapGreenAnt = getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 				if (getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack))
-					f99_copyBitmapAndFlipHorizontal(bitmapGreenAnt, bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), byteWidth, heightRedEagle);
+					copyBitmapAndFlipHorizontal(bitmapGreenAnt, bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex), byteWidth, heightRedEagle);
 
-				f493_addDerivedBitmap(derivedBitmapIndex);
+				addDerivedBitmap(derivedBitmapIndex);
 			}
 		} else { /* Creature is on D2 or D3 */
 			if (useFlippedHorizontallyCreatureFrontImage)
@@ -3402,40 +3402,40 @@ T0115077_DrawSecondHalfSquareCreature:
 				scale = k16_Scale_D3;
 			}
 
-			byteWidth = M78_getScaledDimension(sourceByteWidth, scale);
-			heightRedEagle = M78_getScaledDimension(sourceHeight, scale);
+			byteWidth = getScaledDimension(sourceByteWidth, scale);
+			heightRedEagle = getScaledDimension(sourceHeight, scale);
 			transparentColor = paletteChanges[((CreatureAspect*)objectAspect)->getTranspColour()] / 10;
 
-			bool derivedBitmapInCache = f491_isDerivedBitmapInCache(derivedBitmapIndex);
+			bool derivedBitmapInCache = isDerivedBitmapInCache(derivedBitmapIndex);
 			if (derivedBitmapInCache)
-				bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
+				bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
 			else {
-				bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
-				f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), sourceByteWidth << 1, sourceHeight, byteWidth << 1, heightRedEagle, paletteChanges);
-				f493_addDerivedBitmap(derivedBitmapIndex);
+				bitmapGreenAnt = getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
+				blitToBitmapShrinkWithPalChange(bitmapGreenAnt, bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex), sourceByteWidth << 1, sourceHeight, byteWidth << 1, heightRedEagle, paletteChanges);
+				addDerivedBitmap(derivedBitmapIndex);
 			}
 			if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */
 				(useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) ||
 				(useCreatureSpecialD2FrontBitmap && getFlag(AL_0_creatureGraphicInfoRed, k0x0100_CreatureInfoGraphicMaskSpecialD2FrontIsFlipped)) ||
 				(useFlippedHorizontallyCreatureFrontImage && getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack))) { /* If the graphic should be flipped */
 				if (!useFlippedHorizontallyCreatureFrontImage || !derivedBitmapInCache) {
-					AL_4_normalizdByteWidth = M77_getNormalizedByteWidth(byteWidth);
+					AL_4_normalizdByteWidth = getNormalizedByteWidth(byteWidth);
 					if (!useFlippedHorizontallyCreatureFrontImage) {
-						memcpy(_g74_tmpBitmap, bitmapRedBanana, sizeof(byte) * AL_4_normalizdByteWidth * heightRedEagle);
-						bitmapRedBanana = _g74_tmpBitmap;
+						memcpy(_tmpBitmap, bitmapRedBanana, sizeof(byte) * AL_4_normalizdByteWidth * heightRedEagle);
+						bitmapRedBanana = _tmpBitmap;
 					}
-					f130_flipBitmapHorizontal(bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
+					flipBitmapHorizontal(bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 				}
 				creaturePaddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1;
 			} else
 				creaturePaddingPixelCount = 0;
 		}
 		AL_4_yPos = coordinateSet[1];
-		AL_4_yPos += shiftSets[AL_8_shiftSetIndex][M23_getVerticalOffsetM23(creatureAspectInt)];
+		AL_4_yPos += shiftSets[AL_8_shiftSetIndex][getVerticalOffsetM23(creatureAspectInt)];
 		boxByteGreen._y2 = MIN(AL_4_yPos, (int16)135);
 		boxByteGreen._y1 = MAX(0, AL_4_yPos - (heightRedEagle - 1));
 		AL_4_xPos = coordinateSet[0];
-		AL_4_xPos += shiftSets[AL_8_shiftSetIndex][M22_getHorizontalOffsetM22(creatureAspectInt)];
+		AL_4_xPos += shiftSets[AL_8_shiftSetIndex][getHorizontalOffsetM22(creatureAspectInt)];
 
 		if (viewLane == k1_ViewLaneLeft)
 			AL_4_xPos -= 100;
@@ -3455,7 +3455,7 @@ T0115077_DrawSecondHalfSquareCreature:
 		} else
 			AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1);
 
-		f132_blitToBitmap(bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_0_creaturePosX, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, (Color)transparentColor, heightRedEagle, 136);
+		blitToBitmap(bitmapRedBanana, _bitmapViewport, boxByteGreen, AL_0_creaturePosX, 0, getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, (Color)transparentColor, heightRedEagle, 136);
 T0115126_CreatureNotVisible:
 		if (twoHalfSquareCreaturesFrontView) {
 			twoHalfSquareCreaturesFrontView = false;
@@ -3500,8 +3500,8 @@ T0115129_DrawProjectiles:
 						if (!doNotScaleWithKineticEnergy) {
 							scale = (scale * MAX(96, projectile->_kineticEnergy + 1)) >> 8;
 						}
-						byteWidth = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_byteWidth, scale);
-						heightRedEagle = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale);
+						byteWidth = getScaledDimension(((ProjectileAspect*)objectAspect)->_byteWidth, scale);
+						heightRedEagle = getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale);
 					}
 					bool projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == k0_ProjectileAspectHasBackGraphicRotation);
 					if (projectileAspectTypeHasBackGraphicAndRotation)
@@ -3538,37 +3538,37 @@ T0115129_DrawProjectiles:
 					AL_4_nativeBitmapIndex += projectileBitmapIndexDelta;
 					paddingPixelCount = 0;
 					if (!scale) {
-						bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
+						bitmapRedBanana = getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 					} else {
 						if (flipHorizontal)
 							paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1;
 
-						if (doNotScaleWithKineticEnergy && f491_isDerivedBitmapInCache(derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstDerivedBitmapRelativeIndex + (projectileBitmapIndexDelta * 6) + AL_8_projectileScaleIndex)) {
-							bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
+						if (doNotScaleWithKineticEnergy && isDerivedBitmapInCache(derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstDerivedBitmapRelativeIndex + (projectileBitmapIndexDelta * 6) + AL_8_projectileScaleIndex)) {
+							bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
 						} else {
-							bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
+							bitmapGreenAnt = getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 							if (doNotScaleWithKineticEnergy)
-								bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex);
+								bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
 							else
-								bitmapRedBanana = _g74_tmpBitmap;
+								bitmapRedBanana = _tmpBitmap;
 
-							f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
+							blitToBitmapShrinkWithPalChange(bitmapGreenAnt, bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, _palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
 							if (doNotScaleWithKineticEnergy) {
-								f493_addDerivedBitmap(derivedBitmapIndex);
+								addDerivedBitmap(derivedBitmapIndex);
 							}
 						}
 					}
 					if (flipHorizontal || flipVertical) {
-						AL_4_normalizdByteWidth = M77_getNormalizedByteWidth(byteWidth);
-						if (bitmapRedBanana != _g74_tmpBitmap) {
-							memcpy(_g74_tmpBitmap, bitmapRedBanana, sizeof(byte) * AL_4_normalizdByteWidth * heightRedEagle);
-							bitmapRedBanana = _g74_tmpBitmap;
+						AL_4_normalizdByteWidth = getNormalizedByteWidth(byteWidth);
+						if (bitmapRedBanana != _tmpBitmap) {
+							memcpy(_tmpBitmap, bitmapRedBanana, sizeof(byte) * AL_4_normalizdByteWidth * heightRedEagle);
+							bitmapRedBanana = _tmpBitmap;
 						}
 						if (flipVertical)
-							f131_flipVertical(bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
+							flipBitmapVertical(bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 
 						if (flipHorizontal)
-							f130_flipBitmapHorizontal(bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
+							flipBitmapHorizontal(bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle);
 					}
 					boxByteGreen._y2 = (heightRedEagle >> 1) + 47;
 					boxByteGreen._y1 = 47 - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001);
@@ -3582,7 +3582,7 @@ T0115129_DrawProjectiles:
 					} else
 						AL_4_xPos = MAX(paddingPixelCount, int16(byteWidth - projectilePosX - 1)); /* BUG0_06 Graphical glitch when drawing projectiles or explosions. If a projectile or explosion bitmap is cropped because it is only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is flipped horizontally (flipHorizontal = true) then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */
 
-					f132_blitToBitmap(bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
+					blitToBitmap(bitmapRedBanana, _bitmapViewport, boxByteGreen, AL_4_xPos, 0, getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
 				} else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */
 					useAlcoveObjectImage = false;
 					byte projectileCoordinates[2];
@@ -3629,13 +3629,13 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					} else {
 						if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) {
 							objectAspect = (ObjectAspect*)&_projectileAspect[_vm->ordinalToIndex(-_vm->_dungeonMan->getProjectileAspect(Thing::_explLightningBolt))];
-							bitmapRedBanana = f489_getNativeBitmapOrGraphic(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
+							bitmapRedBanana = getNativeBitmapOrGraphic(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
 							explosionCoordinates = rebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
-							byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_byteWidth), explosionCoordinates[2]);
-							heightRedEagle = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
+							byteWidth = getScaledDimension((((ProjectileAspect*)objectAspect)->_byteWidth), explosionCoordinates[2]);
+							heightRedEagle = getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
 							if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) {
-								f129_blitToBitmapShrinkWithPalChange(bitmapRedBanana, _g74_tmpBitmap, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, _palChangesNoChanges);
-								bitmapRedBanana = _g74_tmpBitmap;
+								blitToBitmapShrinkWithPalChange(bitmapRedBanana, _tmpBitmap, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, _palChangesNoChanges);
+								bitmapRedBanana = _tmpBitmap;
 							}
 							goto T0115200_DrawExplosion;
 						}
@@ -3660,14 +3660,14 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					if (AL_2_explosionSize > 3)
 						AL_4_explosionAspectIndex++; /* Use third graphic in the pattern for large explosion attack */
 				}
-				f491_isDerivedBitmapInCache(k0_DerivedBitmapViewport);
-				bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice);
+				isDerivedBitmapInCache(k0_DerivedBitmapViewport);
+				bitmapRedBanana = getNativeBitmapOrGraphic(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice);
 				if (smoke) {
-					f129_blitToBitmapShrinkWithPalChange(bitmapRedBanana, _g74_tmpBitmap, 48, 32, 48, 32, _palChangeSmoke);
-					bitmapRedBanana = _g74_tmpBitmap;
+					blitToBitmapShrinkWithPalChange(bitmapRedBanana, _tmpBitmap, 48, 32, 48, 32, _palChangeSmoke);
+					bitmapRedBanana = _tmpBitmap;
 				}
-				f133_blitBoxFilledWithMaskedBitmap(bitmapRedBanana, _g296_bitmapViewport, 0, f492_getDerivedBitmap(k0_DerivedBitmapViewport), boxExplosionPatternD0C, _vm->getRandomNumber(4) + 87, _vm->getRandomNumber(64), k112_byteWidthViewport, Color(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
-				f493_addDerivedBitmap(k0_DerivedBitmapViewport);
+				blitBoxFilledWithMaskedBitmap(bitmapRedBanana, _bitmapViewport, 0, getDerivedBitmap(k0_DerivedBitmapViewport), boxExplosionPatternD0C, _vm->getRandomNumber(4) + 87, _vm->getRandomNumber(64), k112_byteWidthViewport, Color(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
+				addDerivedBitmap(k0_DerivedBitmapViewport);
 				warning(false, "DISABLED CODE: f480_releaseBlock in f115_cthulhu");
 				//f480_releaseBlock(k0_DerivedBitmapViewport | 0x8000);
 			} else {
@@ -3688,7 +3688,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 					}
 					explosionScale = MAX(4, (MAX(48, explosion->getAttack() + 1) * explosionBaseScales[AL_10_explosionScaleIndex]) >> 8) & (int)0xFFFE;
 				}
-				bitmapRedBanana = f114_getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle);
+				bitmapRedBanana = getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle);
 T0115200_DrawExplosion:
 				bool flipVertical = _vm->getRandomNumber(2);
 				paddingPixelCount = 0;
@@ -3719,67 +3719,67 @@ T0115200_DrawExplosion:
 				if (boxByteGreen._x2 <= boxByteGreen._x1)
 					continue;
 
-				byteWidth = M77_getNormalizedByteWidth(byteWidth);
+				byteWidth = getNormalizedByteWidth(byteWidth);
 				if (flipHorizontal || flipVertical) {
-					memcpy(_g74_tmpBitmap, bitmapRedBanana, sizeof(byte) * byteWidth * heightRedEagle);
-					bitmapRedBanana = _g74_tmpBitmap;
+					memcpy(_tmpBitmap, bitmapRedBanana, sizeof(byte) * byteWidth * heightRedEagle);
+					bitmapRedBanana = _tmpBitmap;
 				}
 
 				if (flipHorizontal)
-					f130_flipBitmapHorizontal(bitmapRedBanana, byteWidth, heightRedEagle);
+					flipBitmapHorizontal(bitmapRedBanana, byteWidth, heightRedEagle);
 
 				if (flipVertical)
-					f131_flipVertical(bitmapRedBanana, byteWidth, heightRedEagle);
+					flipBitmapVertical(bitmapRedBanana, byteWidth, heightRedEagle);
 
-				f132_blitToBitmap(bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
+				blitToBitmap(bitmapRedBanana, _bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
 			}
 		}
 		thingParam = _vm->_dungeonMan->getNextThing(thingParam);
 	} while (thingParam != Thing::_endOfList);
 
-	if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_g77_doNotDrawFluxcagesDuringEndgame) { /* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */
+	if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_doNotDrawFluxcagesDuringEndgame) { /* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */
 		AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */
 		FieldAspect fieldAspect = _fieldAspects188[viewSquareIndex];
 		(fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */
-		f113_drawField(&fieldAspect, _frameWalls163[viewSquareIndex]._box);
+		drawField(&fieldAspect, _frameWalls163[viewSquareIndex]._box);
 	}
 }
 
-uint16 DisplayMan::M77_getNormalizedByteWidth(uint16 byteWidth) {
+uint16 DisplayMan::getNormalizedByteWidth(uint16 byteWidth) {
 	return (byteWidth + 7) & 0xFFF8;
 }
 
-uint16 DisplayMan::M23_getVerticalOffsetM23(uint16 val) {
+uint16 DisplayMan::getVerticalOffsetM23(uint16 val) {
 	return (val >> 3) & 0x7;
 }
 
-uint16 DisplayMan::M22_getHorizontalOffsetM22(uint16 val) {
+uint16 DisplayMan::getHorizontalOffsetM22(uint16 val) {
 	return (val & 0x7);
 }
 
-bool DisplayMan::f491_isDerivedBitmapInCache(int16 derivedBitmapIndex) {
-	if (_g638_derivedBitmaps[derivedBitmapIndex] == nullptr) {
+bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) {
+	if (_derivedBitmaps[derivedBitmapIndex] == nullptr) {
 		// * 2, because the original uses 4 bits instead of 8 bits to store a pixel
-		_g638_derivedBitmaps[derivedBitmapIndex] = new byte[_g639_derivedBitmapByteCount[derivedBitmapIndex] * 2];
+		_derivedBitmaps[derivedBitmapIndex] = new byte[_derivedBitmapByteCount[derivedBitmapIndex] * 2];
 		return false;
 	} 
 
 	return true;
 }
 
-byte* DisplayMan::f492_getDerivedBitmap(int16 derivedBitmapIndex) {
-	return _g638_derivedBitmaps[derivedBitmapIndex];
+byte* DisplayMan::getDerivedBitmap(int16 derivedBitmapIndex) {
+	return _derivedBitmaps[derivedBitmapIndex];
 }
 
-void DisplayMan::f493_addDerivedBitmap(int16 derivedBitmapIndex) {}
+void DisplayMan::addDerivedBitmap(int16 derivedBitmapIndex) {}
 
-void DisplayMan::f480_releaseBlock(uint16 index) {
+void DisplayMan::releaseBlock(uint16 index) {
 	index &= ~0x8000;
-	delete[] _g638_derivedBitmaps[index];
-	_g638_derivedBitmaps[index] = nullptr;
+	delete[] _derivedBitmaps[index];
+	_derivedBitmaps[index] = nullptr;
 }
 
-uint16 DisplayMan::f431_getDarkenedColor(uint16 RGBcolor) {
+uint16 DisplayMan::getDarkenedColor(uint16 RGBcolor) {
 	if (getFlag(RGBcolor, D12_MASK_BLUE_COMPONENT))
 		RGBcolor--;
 
@@ -3792,14 +3792,14 @@ uint16 DisplayMan::f431_getDarkenedColor(uint16 RGBcolor) {
 	return RGBcolor;
 }
 
-void DisplayMan::f436_STARTEND_FadeToPalette(uint16* P0849_pui_Palette) {
-	uint16 *paletteRegister = _gK16_paletteFadeTemporary;
+void DisplayMan::startEndFadeToPalette(uint16* P0849_pui_Palette) {
+	uint16 *paletteRegister = _paletteFadeTemporary;
 
 	for (int16 i = 0; i < 16; i++) 
-		paletteRegister[i] = _gK17_paletteFadeFrom[i];
+		paletteRegister[i] = _paletteFadeFrom[i];
 
 	for (int16 i = 0; i < 8; i++) {
-		paletteRegister = _gK16_paletteFadeTemporary;
+		paletteRegister = _paletteFadeTemporary;
 		for (int16 colIdx = 0; colIdx < 16; colIdx++, paletteRegister++) {
 			uint16 currentRGBColor = getFlag(*paletteRegister, D12_MASK_BLUE_COMPONENT);
 			int16 targetRGBColor = getFlag(P0849_pui_Palette[colIdx], D12_MASK_BLUE_COMPONENT);
@@ -3843,12 +3843,12 @@ void DisplayMan::f436_STARTEND_FadeToPalette(uint16* P0849_pui_Palette) {
 		}
 		_vm->delay(1);
 		_vm->_eventMan->discardAllInput();
-		f508_buildPaletteChangeCopperList(_gK16_paletteFadeTemporary, _gK16_paletteFadeTemporary);
+		buildPaletteChangeCopperList(_paletteFadeTemporary, _paletteFadeTemporary);
 	}
 }
 
-void DisplayMan::f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom) {
-	_gK17_paletteFadeFrom = topAndBottom;
+void DisplayMan::buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom) {
+	_paletteFadeFrom = topAndBottom;
 	byte colorPalette[32 * 3];
 	for (int i = 0; i < 16; ++i) {
 		colorPalette[i * 3] = (topAndBottom[i] >> 8) * (256 / 16);
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 13c0502..508d4d8 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -578,7 +578,7 @@ class DisplayMan {
 	byte **_bitmaps;
 	DoorFrames *_doorFrameD1C;
 	// pointers are not owned by these fields
-	byte *_g75_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile
+	byte *_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile
 
 	DisplayMan(const DisplayMan &other); // no implementation on purpose
 	void operator=(const DisplayMan &rhs); // no implementation on purpose
@@ -588,213 +588,211 @@ class DisplayMan {
 	void unpackGraphics();
 	void loadFNT1intoBitmap(uint16 index, byte *destBitmap);
 
-	void f565_viewportSetPalette(uint16 * middleScreenPalette, uint16 * topAndBottomScreen); // @ F0565_VIEWPORT_SetPalette
-	void f566_viewportBlitToScreen(); // @ F0566_VIEWPORT_BlitToScreen
-
-	void f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally
-	void f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap
-	void f100_drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap
-	void f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency
-	void f116_drawSquareD3L(Direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L
-	void f117_drawSquareD3R(Direction dir, int16 posX, int16 posY); // @ F0117_DUNGEONVIEW_DrawSquareD3R
-	void f118_drawSquareD3C(Direction dir, int16 posX, int16 posY); // @ F0118_DUNGEONVIEW_DrawSquareD3C_CPSF
-	void f119_drawSquareD2L(Direction dir, int16 posX, int16 posY); // @ F0119_DUNGEONVIEW_DrawSquareD2L
-	void f120_drawSquareD2R(Direction dir, int16 posX, int16 posY); // @ F0120_DUNGEONVIEW_DrawSquareD2R_CPSF
-	void f121_drawSquareD2C(Direction dir, int16 posX, int16 posY); // @ F0121_DUNGEONVIEW_DrawSquareD2C
-	void f122_drawSquareD1L(Direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1L
-	void f123_drawSquareD1R(Direction dir, int16 posX, int16 posY); // @ F0123_DUNGEONVIEW_DrawSquareD1R
-	void f124_drawSquareD1C(Direction dir, int16 posX, int16 posY); // @ F0124_DUNGEONVIEW_DrawSquareD1C
-	void f125_drawSquareD0L(Direction dir, int16 posX, int16 posY); // @ F0125_DUNGEONVIEW_DrawSquareD0L
-	void f126_drawSquareD0R(Direction dir, int16 posX, int16 posY); // @ F0126_DUNGEONVIEW_DrawSquareD0R
-	void f127_drawSquareD0C(Direction dir, int16 posX, int16 posY); // @ F0127_DUNGEONVIEW_DrawSquareD0C
-
-
-	void f93_applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors
-
-	bool f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF
-
-	uint16 *_g639_derivedBitmapByteCount; // @ G0639_pui_DerivedBitmapByteCount
-	byte **_g638_derivedBitmaps; // @ G0638_pui_DerivedBitmapBlockIndices
-
-	int16 _g675_stairsNativeBitmapIndex_Up_Front_D3L; // @ G0675_i_StairsNativeBitmapIndex_Up_Front_D3L
-	int16 _g676_stairsNativeBitmapIndex_Up_Front_D3C; // @ G0676_i_StairsNativeBitmapIndex_Up_Front_D3C
-	int16 _g677_stairsNativeBitmapIndex_Up_Front_D2L; // @ G0677_i_StairsNativeBitmapIndex_Up_Front_D2L
-	int16 _g678_stairsNativeBitmapIndex_Up_Front_D2C; // @ G0678_i_StairsNativeBitmapIndex_Up_Front_D2C
-	int16 _g679_stairsNativeBitmapIndex_Up_Front_D1L; // @ G0679_i_StairsNativeBitmapIndex_Up_Front_D1L
-	int16 _g680_stairsNativeBitmapIndex_Up_Front_D1C; // @ G0680_i_StairsNativeBitmapIndex_Up_Front_D1C
-	int16 _g681_stairsNativeBitmapIndex_Up_Front_D0C_Left; // @ G0681_i_StairsNativeBitmapIndex_Up_Front_D0C_Left
-	int16 _g682_stairsNativeBitmapIndex_Down_Front_D3L; // @ G0682_i_StairsNativeBitmapIndex_Down_Front_D3L
-	int16 _g683_stairsNativeBitmapIndex_Down_Front_D3C; // @ G0683_i_StairsNativeBitmapIndex_Down_Front_D3C
-	int16 _g684_stairsNativeBitmapIndex_Down_Front_D2L; // @ G0684_i_StairsNativeBitmapIndex_Down_Front_D2L
-	int16 _g685_stairsNativeBitmapIndex_Down_Front_D2C; // @ G0685_i_StairsNativeBitmapIndex_Down_Front_D2C
-	int16 _g686_stairsNativeBitmapIndex_Down_Front_D1L; // @ G0686_i_StairsNativeBitmapIndex_Down_Front_D1L
-	int16 _g687_stairsNativeBitmapIndex_Down_Front_D1C; // @ G0687_i_StairsNativeBitmapIndex_Down_Front_D1C
-	int16 _g688_stairsNativeBitmapIndex_Down_Front_D0C_Left; // @ G0688_i_StairsNativeBitmapIndex_Down_Front_D0C_Left
-	int16 _g689_stairsNativeBitmapIndex_Side_D2L; // @ G0689_i_StairsNativeBitmapIndex_Side_D2L
-	int16 _g690_stairsNativeBitmapIndex_Up_Side_D1L; // @ G0690_i_StairsNativeBitmapIndex_Up_Side_D1L
-	int16 _g691_stairsNativeBitmapIndex_Down_Side_D1L; // @ G0691_i_StairsNativeBitmapIndex_Down_Side_D1L
-	int16 _g692_stairsNativeBitmapIndex_Side_D0L; // @ G0692_i_StairsNativeBitmapIndex_Side_D0L
-
-
-	byte *_g84_bitmapFloor; // @ G0084_puc_Bitmap_Floor
-	byte *_g85_bitmapCeiling; // @ G0085_puc_Bitmap_Ceiling
-	byte *_g697_bitmapWallSet_Wall_D3L2; // @ G0697_puc_Bitmap_WallSet_Wall_D3L2
-	byte *_g696_bitmapWallSet_Wall_D3R2; // @ G0696_puc_Bitmap_WallSet_Wall_D3R2
-	byte *_g698_bitmapWallSet_Wall_D3LCR; // @ G0698_puc_Bitmap_WallSet_Wall_D3LCR
-	byte *_g699_bitmapWallSet_Wall_D2LCR; // @ G0699_puc_Bitmap_WallSet_Wall_D2LCR
+	void viewportSetPalette(uint16 *middleScreenPalette, uint16 *topAndBottomScreen); // @ F0565_VIEWPORT_SetPalette
+	void viewportBlitToScreen(); // @ F0566_VIEWPORT_BlitToScreen
+
+	void drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally
+	void drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap
+	void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap
+	void drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency
+	void drawSquareD3L(Direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L
+	void drawSquareD3R(Direction dir, int16 posX, int16 posY); // @ F0117_DUNGEONVIEW_DrawSquareD3R
+	void drawSquareD3C(Direction dir, int16 posX, int16 posY); // @ F0118_DUNGEONVIEW_DrawSquareD3C_CPSF
+	void drawSquareD2L(Direction dir, int16 posX, int16 posY); // @ F0119_DUNGEONVIEW_DrawSquareD2L
+	void drawSquareD2R(Direction dir, int16 posX, int16 posY); // @ F0120_DUNGEONVIEW_DrawSquareD2R_CPSF
+	void drawSquareD2C(Direction dir, int16 posX, int16 posY); // @ F0121_DUNGEONVIEW_DrawSquareD2C
+	void drawSquareD1L(Direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1L
+	void drawSquareD1R(Direction dir, int16 posX, int16 posY); // @ F0123_DUNGEONVIEW_DrawSquareD1R
+	void drawSquareD1C(Direction dir, int16 posX, int16 posY); // @ F0124_DUNGEONVIEW_DrawSquareD1C
+	void drawSquareD0L(Direction dir, int16 posX, int16 posY); // @ F0125_DUNGEONVIEW_DrawSquareD0L
+	void drawSquareD0R(Direction dir, int16 posX, int16 posY); // @ F0126_DUNGEONVIEW_DrawSquareD0R
+	void drawSquareD0C(Direction dir, int16 posX, int16 posY); // @ F0127_DUNGEONVIEW_DrawSquareD0C
+
+	void applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors
+
+	bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF
+
+	uint16 *_derivedBitmapByteCount; // @ G0639_pui_DerivedBitmapByteCount
+	byte **_derivedBitmaps; // @ G0638_pui_DerivedBitmapBlockIndices
+
+	int16 _stairsNativeBitmapIndexUpFrontD3L; // @ G0675_i_StairsNativeBitmapIndex_Up_Front_D3L
+	int16 _stairsNativeBitmapIndexUpFrontD3C; // @ G0676_i_StairsNativeBitmapIndex_Up_Front_D3C
+	int16 _stairsNativeBitmapIndexUpFrontD2L; // @ G0677_i_StairsNativeBitmapIndex_Up_Front_D2L
+	int16 _stairsNativeBitmapIndexUpFrontD2C; // @ G0678_i_StairsNativeBitmapIndex_Up_Front_D2C
+	int16 _stairsNativeBitmapIndexUpFrontD1L; // @ G0679_i_StairsNativeBitmapIndex_Up_Front_D1L
+	int16 _stairsNativeBitmapIndexUpFrontD1C; // @ G0680_i_StairsNativeBitmapIndex_Up_Front_D1C
+	int16 _stairsNativeBitmapIndexUpFrontD0CLeft; // @ G0681_i_StairsNativeBitmapIndex_Up_Front_D0C_Left
+	int16 _stairsNativeBitmapIndexDownFrontD3L; // @ G0682_i_StairsNativeBitmapIndex_Down_Front_D3L
+	int16 _stairsNativeBitmapIndexDownFrontD3C; // @ G0683_i_StairsNativeBitmapIndex_Down_Front_D3C
+	int16 _stairsNativeBitmapIndexDownFrontD2L; // @ G0684_i_StairsNativeBitmapIndex_Down_Front_D2L
+	int16 _stairsNativeBitmapIndexDownFrontD2C; // @ G0685_i_StairsNativeBitmapIndex_Down_Front_D2C
+	int16 _stairsNativeBitmapIndexDownFrontD1L; // @ G0686_i_StairsNativeBitmapIndex_Down_Front_D1L
+	int16 _stairsNativeBitmapIndexDownFrontD1C; // @ G0687_i_StairsNativeBitmapIndex_Down_Front_D1C
+	int16 _stairsNativeBitmapIndexDownFrontD0CLeft; // @ G0688_i_StairsNativeBitmapIndex_Down_Front_D0C_Left
+	int16 _stairsNativeBitmapIndexSideD2L; // @ G0689_i_StairsNativeBitmapIndex_Side_D2L
+	int16 _stairsNativeBitmapIndexUpSideD1L; // @ G0690_i_StairsNativeBitmapIndex_Up_Side_D1L
+	int16 _stairsNativeBitmapIndexDownSideD1L; // @ G0691_i_StairsNativeBitmapIndex_Down_Side_D1L
+	int16 _stairsNativeBitmapIndexSideD0L; // @ G0692_i_StairsNativeBitmapIndex_Side_D0L
+
+	byte *_bitmapFloor; // @ G0084_puc_Bitmap_Floor
+	byte *_bitmapCeiling; // @ G0085_puc_Bitmap_Ceiling
+	byte *_bitmapWallSetD3L2; // @ G0697_puc_Bitmap_WallSet_Wall_D3L2
+	byte *_bitmapWallSetD3R2; // @ G0696_puc_Bitmap_WallSet_Wall_D3R2
+	byte *_bitmapWallSetD3LCR; // @ G0698_puc_Bitmap_WallSet_Wall_D3LCR
+	byte *_bitmapWallSetD2LCR; // @ G0699_puc_Bitmap_WallSet_Wall_D2LCR
 public:
-	byte *_g700_bitmapWallSet_Wall_D1LCR; // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR
+	byte *_bitmapWallSetD1LCR; // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR
 private:
 	Box _boxThievesEyeViewPortVisibleArea; // @ G0106_s_Graphic558_Box_ThievesEye_ViewportVisibleArea 
 	byte _palChangesDoorButtonAndWallOrnD3[16]; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3
 	byte _palChangesDoorButtonAndWallOrnD2[16]; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2
 
-	byte *_g701_bitmapWallSet_Wall_D0L; // @ G0701_puc_Bitmap_WallSet_Wall_D0L
-	byte *_g702_bitmapWallSet_Wall_D0R; // @ G0702_puc_Bitmap_WallSet_Wall_D0R
-	byte *_g703_bitmapWallSet_DoorFrameTop_D2LCR; // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR
-	byte *_g704_bitmapWallSet_DoorFrameTop_D1LCR; // @ G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR
-	byte *_g705_bitmapWallSet_DoorFrameLeft_D3L; // @ G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L
-	byte *_g706_bitmapWallSet_DoorFrameLeft_D3C; // @ G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C
-	byte *_g707_bitmapWallSet_DoorFrameLeft_D2C; // @ G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C
-	byte *_g708_bitmapWallSet_DoorFrameLeft_D1C; // @ G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C
-	byte *_g710_bitmapWallSet_DoorFrameRight_D1C; // @ G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C
-	byte *_g709_bitmapWallSet_DoorFrameFront; // @ G0709_puc_Bitmap_WallSet_DoorFrameFront
-
-	byte *_g90_bitmapWall_D3LCR_Flipped; // @ G0090_puc_Bitmap_WallD3LCR_Flipped;
-	byte *_g91_bitmapWall_D2LCR_Flipped; // @ G0091_puc_Bitmap_WallD2LCR_Flipped;
-	byte *_g92_bitmapWall_D1LCR_Flipped; // @ G0092_puc_Bitmap_WallD1LCR_Flipped;
-	byte *_g93_bitmapWall_D0L_Flipped; // @ G0093_puc_Bitmap_WallD0L_Flipped;
-	byte *_g94_bitmapWall_D0R_Flipped; // @ G0094_puc_Bitmap_WallD0R_Flipped;
-	byte *_g95_bitmapWall_D3LCR_Native; // @ G0095_puc_Bitmap_WallD3LCR_Native;
-	byte *_g96_bitmapWall_D2LCR_Native; // @ G0096_puc_Bitmap_WallD2LCR_Native;
-	byte *_g97_bitmapWall_D1LCR_Native; // @ G0097_puc_Bitmap_WallD1LCR_Native;
-	byte *_g98_bitmapWall_D0L_Native; // @ G0098_puc_Bitmap_WallD0L_Native;
-	byte *_g99_bitmapWall_D0R_Native; // @ G0099_puc_Bitmap_WallD0R_Native;
-
-	int16 _g231_currentWallSet; // @ G0231_i_CurrentWallSet
-	int16 _g230_currentFloorSet;// @ G0230_i_CurrentFloorSet
-
-	bool _g76_useFlippedWallAndFootprintsBitmap; // @ G0076_B_UseFlippedWallAndFootprintsBitmaps
-
-	int16 _g693_doorNativeBitmapIndex_Front_D3LCR[2]; // @ G0693_ai_DoorNativeBitmapIndex_Front_D3LCR
-	int16 _g694_doorNativeBitmapIndex_Front_D2LCR[2]; // @ G0694_ai_DoorNativeBitmapIndex_Front_D2LCR
-	int16 _g695_doorNativeBitmapIndex_Front_D1LCR[2]; // @ G0695_ai_DoorNativeBitmapIndex_Front_D1LCR
-
-	uint16 *_gK17_paletteFadeFrom; // @ K0017_pui_Palette_FadeFrom
-	uint16 _gK16_paletteFadeTemporary[16]; // @ K0016_aui_Palette_FadeTemporary
+	byte *bitmapWallSetWallD0L; // @ G0701_puc_Bitmap_WallSet_Wall_D0L
+	byte *_bitmapWallSetWallD0R; // @ G0702_puc_Bitmap_WallSet_Wall_D0R
+	byte *_bitmapWallSetDoorFrameTopD2LCR; // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR
+	byte *_bitmapWallSetDoorFrameTopD1LCR; // @ G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR
+	byte *_bitmapWallSetDoorFrameLeftD3L; // @ G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L
+	byte *_bitmapWallSetDoorFrameLeftD3C; // @ G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C
+	byte *_bitmapWallSetDoorFrameLeftD2C; // @ G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C
+	byte *_bitmapWallSetDoorFrameLeftD1C; // @ G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C
+	byte *_bitmapWallSetDoorFrameRightD1C; // @ G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C
+	byte *_bitmapWallSetDoorFrameFront; // @ G0709_puc_Bitmap_WallSet_DoorFrameFront
+
+	byte *_bitmapWallD3LCRFlipped; // @ G0090_puc_Bitmap_WallD3LCR_Flipped;
+	byte *_bitmapWallD2LCRFlipped; // @ G0091_puc_Bitmap_WallD2LCR_Flipped;
+	byte *_bitmapWallD1LCRFlipped; // @ G0092_puc_Bitmap_WallD1LCR_Flipped;
+	byte *_bitmapWallD0LFlipped; // @ G0093_puc_Bitmap_WallD0L_Flipped;
+	byte *_bitmapWallD0RFlipped; // @ G0094_puc_Bitmap_WallD0R_Flipped;
+	byte *_bitmapWallD3LCRNative; // @ G0095_puc_Bitmap_WallD3LCR_Native;
+	byte *_bitmapWallD2LCRNative; // @ G0096_puc_Bitmap_WallD2LCR_Native;
+	byte *_bitmapWallD1LCRNative; // @ G0097_puc_Bitmap_WallD1LCR_Native;
+	byte *_bitmapWallD0LNative; // @ G0098_puc_Bitmap_WallD0L_Native;
+	byte *_bitmapWallD0RNative; // @ G0099_puc_Bitmap_WallD0R_Native;
+
+	int16 _currentWallSet; // @ G0231_i_CurrentWallSet
+	int16 _currentFloorSet;// @ G0230_i_CurrentFloorSet
+
+	bool _useFlippedWallAndFootprintsBitmap; // @ G0076_B_UseFlippedWallAndFootprintsBitmaps
+
+	int16 _doorNativeBitmapIndexFrontD3LCR[2]; // @ G0693_ai_DoorNativeBitmapIndex_Front_D3LCR
+	int16 _doorNativeBitmapIndexFrontD2LCR[2]; // @ G0694_ai_DoorNativeBitmapIndex_Front_D2LCR
+	int16 _doorNativeBitmapIndexFrontD1LCR[2]; // @ G0695_ai_DoorNativeBitmapIndex_Front_D1LCR
+
+	uint16 *_paletteFadeFrom; // @ K0017_pui_Palette_FadeFrom
+	uint16 _paletteFadeTemporary[16]; // @ K0016_aui_Palette_FadeTemporary
 public:
 
 	uint16 _screenWidth;
 	uint16 _screenHeight;
-	byte *_g348_bitmapScreen; // @ G0348_pl_Bitmap_Screen
-	byte* _g296_bitmapViewport; // @ G0296_puc_Bitmap_Viewport
+	byte *_bitmapScreen; // @ G0348_pl_Bitmap_Screen
+	byte *_bitmapViewport; // @ G0296_puc_Bitmap_Viewport
 
 	// some methods use this for a stratchpad, don't make assumptions about content between function calls
-	byte *_g74_tmpBitmap; // @ G0074_puc_Bitmap_Temporary
-	bool _g322_paletteSwitchingEnabled; // @ G0322_B_PaletteSwitchingEnabled
-	bool _g342_refreshDungeonViewPaleteRequested; // @ G0342_B_RefreshDungeonViewPaletteRequested
-	int16 _g304_dungeonViewPaletteIndex; // @ G0304_i_DungeonViewPaletteIndex
-	uint16 _g345_aui_BlankBuffer[32]; // @G0345_aui_BlankBuffer
-	uint16 _g347_paletteTopAndBottomScreen[16]; // @ G0347_aui_Palette_TopAndBottomScreen
-	uint16 _g346_paletteMiddleScreen[16]; // @ G0346_aui_Palette_MiddleScreen
+	byte *_tmpBitmap; // @ G0074_puc_Bitmap_Temporary
+	bool _paletteSwitchingEnabled; // @ G0322_B_PaletteSwitchingEnabled
+	bool _refreshDungeonViewPaleteRequested; // @ G0342_B_RefreshDungeonViewPaletteRequested
+	int16 _dungeonViewPaletteIndex; // @ G0304_i_DungeonViewPaletteIndex
+	uint16 _blankBuffer[32]; // @G0345_aui_BlankBuffer
+	uint16 _paletteTopAndBottomScreen[16]; // @ G0347_aui_Palette_TopAndBottomScreen
+	uint16 _paletteMiddleScreen[16]; // @ G0346_aui_Palette_MiddleScreen
 
 	explicit DisplayMan(DMEngine *dmEngine);
 	~DisplayMan();
 
-	void f95_loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet
-	void f94_loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet
+	void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet
+	void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet
 
-	void f466_loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap
+	void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap
 	void setUpScreens(uint16 width, uint16 height);
-	void f479_loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader	
-	void f460_initializeGraphicData(); // @ F0460_START_InitializeGraphicData
-	void f96_loadCurrentMapGraphics(); // @ F0096_DUNGEONVIEW_LoadCurrentMapGraphics_CPSDF
-	void f461_allocateFlippedWallBitmaps(); // @ F0461_START_AllocateFlippedWallBitmaps
-	void f102_drawDoorBitmap(Frame *frame);// @ F0102_DUNGEONVIEW_DrawDoorBitmap
-	void f103_drawDoorFrameBitmapFlippedHorizontally(byte *bitmap, Frame *frame); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally
-	void f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButtonIndex); // @ F0110_DUNGEONVIEW_DrawDoorButton
+	void loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader	
+	void initializeGraphicData(); // @ F0460_START_InitializeGraphicData
+	void loadCurrentMapGraphics(); // @ F0096_DUNGEONVIEW_LoadCurrentMapGraphics_CPSDF
+	void allocateFlippedWallBitmaps(); // @ F0461_START_AllocateFlippedWallBitmaps
+	void drawDoorBitmap(Frame *frame);// @ F0102_DUNGEONVIEW_DrawDoorBitmap
+	void drawDoorFrameBitmapFlippedHorizontally(byte *bitmap, Frame *frame); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally
+	void drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButtonIndex); // @ F0110_DUNGEONVIEW_DrawDoorButton
 
 	/// Gives the width of an IMG0 type item
 	uint16 getPixelWidth(uint16 index);
 	/// Gives the height of an IMG1 type item
 	uint16 getPixelHeight(uint16 index);
 
-	void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); // @ F0099_DUNGEONVIEW_CopyBitmapAndFlipHorizontal
-	void f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloorIndex); // @ F0108_DUNGEONVIEW_DrawFloorOrnament
-	void f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16 *doorNativeBitmapIndices, int16 byteCount,
+	void copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); // @ F0099_DUNGEONVIEW_CopyBitmapAndFlipHorizontal
+	void drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloorIndex); // @ F0108_DUNGEONVIEW_DrawFloorOrnament
+	void drawDoor(uint16 doorThingIndex, uint16 doorState, int16 *doorNativeBitmapIndices, int16 byteCount,
 					   int16 viewDoorOrnIndex, DoorFrames *doorFrames); // @ F0111_DUNGEONVIEW_DrawDoor
-	void f109_drawDoorOrnament(int16 doorOrnOdinal, int16 viewDoorOrnIndex); // @ F0109_DUNGEONVIEW_DrawDoorOrnament
-	void f112_drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int16 mapX, int16 mapY, bool flipHorizontal); // @ F0112_DUNGEONVIEW_DrawCeilingPit
+	void drawDoorOrnament(int16 doorOrnOdinal, int16 viewDoorOrnIndex); // @ F0109_DUNGEONVIEW_DrawDoorOrnament
+	void drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int16 mapX, int16 mapY, bool flipHorizontal); // @ F0112_DUNGEONVIEW_DrawCeilingPit
 
-	void f20_blitToViewport(byte *bitmap, Box &box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
-	void f20_blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
-	void f21_blitToScreen(byte *bitmap, int16* box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
-	void f21_blitToScreen(byte* bitmap, Box* box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
+	void blitToViewport(byte *bitmap, Box &box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
+	void blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
+	void blitToScreen(byte *bitmap, int16* box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
+	void blitToScreen(byte* bitmap, Box* box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
 
 
 	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which
 	does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters
-	match the original exatcly, if need arises for heights then we'll have to retrospectively add them in old function calls*/
+	match the original exactly, if need arises for heights then we'll have to retrospectively add them in old function calls*/
 	/* Expects inclusive boundaries in box */
-	void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
+	void blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
 						   uint16 destByteWidth, Color transparent, int16 srcHeight, int16 destHight); // @ F0132_VIDEO_Blit
 	 /* Expects inclusive boundaries in box */
-	void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
+	void blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
 											int16 firstUnitIndex, int16 destByteWidth, Color transparent,
 											int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap
 		 // this function takes pixel widths
-	void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
+	void blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
 											  int16 srcPixelWidth, int16 srcHight, int16 destPixelWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges
-	void f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height); // @ F0130_VIDEO_FlipHorizontal
-	void f131_flipVertical(byte *bitmap, uint16 byteWidth, uint16 height);
-	byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnByteWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap
+	void flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height); // @ F0130_VIDEO_FlipHorizontal
+	void flipBitmapVertical(byte *bitmap, uint16 byteWidth, uint16 height);
+	byte *getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnByteWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap
 
-	void f134_fillBitmap(byte *bitmap, Color color, uint16 byteWidth, uint16 height); // @ F0134_VIDEO_FillBitmap
+	void fillBitmap(byte *bitmap, Color color, uint16 byteWidth, uint16 height); // @ F0134_VIDEO_FillBitmap
 	void fillScreen(Color color);
 	/* Expects inclusive boundaries in box */
-	void D24_fillScreenBox(Box &box, Color color); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox
+	void fillScreenBox(Box &box, Color color); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox
 /* Expects inclusive boundaries in box */
-	void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 byteWidth, int16 height); // @ F0135_VIDEO_FillBox
-	void f128_drawDungeon(Direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
-	void f98_drawFloorAndCeiling(); // @ F0098_DUNGEONVIEW_DrawFloorAndCeiling
+	void fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 byteWidth, int16 height); // @ F0135_VIDEO_FillBox
+	void drawDungeon(Direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
+	void drawFloorAndCeiling(); // @ F0098_DUNGEONVIEW_DrawFloorAndCeiling
 	void updateScreen();
-	void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport
+	void drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport
 
-	byte* f489_getNativeBitmapOrGraphic(uint16 index); // @ F0489_MEMORY_GetNativeBitmapOrGraphic
+	byte *getNativeBitmapOrGraphic(uint16 index); // @ F0489_MEMORY_GetNativeBitmapOrGraphic
 	Common::MemoryReadStream getCompressedData(uint16 index);
 	uint32 getCompressedDataSize(uint16 index);
-	void f113_drawField(FieldAspect *fieldAspect, Box &box); // @ F0113_DUNGEONVIEW_DrawField
+	void drawField(FieldAspect *fieldAspect, Box &box); // @ F0113_DUNGEONVIEW_DrawField
 
-	int16 f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale); // @ F0459_START_GetScaledBitmapByteCount
-	int16 M78_getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION
-	void f115_cthulhu(Thing thingParam, Direction directionParam,
+	int16 getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale); // @ F0459_START_GetScaledBitmapByteCount
+	int16 getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION
+	void drawObjectsCreaturesProjectilesExplosions(Thing thingParam, Direction directionParam,
 					  int16 mapXpos, int16 mapYpos, int16 viewSquareIndex,
 					  uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF
-	uint16 M77_getNormalizedByteWidth(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH
-	uint16 M23_getVerticalOffsetM23(uint16 val); // @ M23_VERTICAL_OFFSET
-	uint16 M22_getHorizontalOffsetM22(uint16 val); // @ M22_HORIZONTAL_OFFSET
+	uint16 getNormalizedByteWidth(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH
+	uint16 getVerticalOffsetM23(uint16 val); // @ M23_VERTICAL_OFFSET
+	uint16 getHorizontalOffsetM22(uint16 val); // @ M22_HORIZONTAL_OFFSET
 
-	int16 _g289_championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
-	int16 _g267_currMapAlcoveOrnIndices[k3_AlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
-	int16 _g268_currMapFountainOrnIndices[k1_FountainOrnCount]; // @ G0268_ai_CurrentMapFountainOrnamentIndices
-	int16 _g101_currMapWallOrnInfo[16][2]; // @ G0101_aai_CurrentMapWallOrnamentsInfo
-	int16 _g102_currMapFloorOrnInfo[16][2]; // @ G0102_aai_CurrentMapFloorOrnamentsInfo
-	int16 _g103_currMapDoorOrnInfo[17][2]; // @ G0103_aai_CurrentMapDoorOrnamentsInfo
-	byte *_g264_currMapAllowedCreatureTypes; // @ G0264_puc_CurrentMapAllowedCreatureTypes
-	byte _g261_currMapWallOrnIndices[16]; // @ G0261_auc_CurrentMapWallOrnamentIndices
-	byte _g262_currMapFloorOrnIndices[16]; // @ G0262_auc_CurrentMapFloorOrnamentIndices
-	byte _g263_currMapDoorOrnIndices[18]; // @ G0263_auc_CurrentMapDoorOrnamentIndices
+	int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
+	int16 _currMapAlcoveOrnIndices[k3_AlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
+	int16 _currMapFountainOrnIndices[k1_FountainOrnCount]; // @ G0268_ai_CurrentMapFountainOrnamentIndices
+	int16 _currMapWallOrnInfo[16][2]; // @ G0101_aai_CurrentMapWallOrnamentsInfo
+	int16 _currMapFloorOrnInfo[16][2]; // @ G0102_aai_CurrentMapFloorOrnamentsInfo
+	int16 _currMapDoorOrnInfo[17][2]; // @ G0103_aai_CurrentMapDoorOrnamentsInfo
+	byte *_currMapAllowedCreatureTypes; // @ G0264_puc_CurrentMapAllowedCreatureTypes
+	byte _currMapWallOrnIndices[16]; // @ G0261_auc_CurrentMapWallOrnamentIndices
+	byte _currMapFloorOrnIndices[16]; // @ G0262_auc_CurrentMapFloorOrnamentIndices
+	byte _currMapDoorOrnIndices[18]; // @ G0263_auc_CurrentMapDoorOrnamentIndices
 
-	int16 _g266_currMapViAltarIndex; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex
+	int16 _currMapViAltarIndex; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex
 
-	Thing _g290_inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing
+	Thing _inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing
 
-	bool _g297_drawFloorAndCeilingRequested; // @ G0297_B_DrawFloorAndCeilingRequested
+	bool _drawFloorAndCeilingRequested; // @ G0297_B_DrawFloorAndCeilingRequested
 
 	// This tells blitting functions whether to assume a BYTE_BOX or a WORD_BOX has been passed to them,
 	// I only use WORD_BOX, so this will probably deem useless
-	bool _g578_useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates
-	bool _g77_doNotDrawFluxcagesDuringEndgame; // @ G0077_B_DoNotDrawFluxcagesDuringEndgame
+	bool _useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates
+	bool _doNotDrawFluxcagesDuringEndgame; // @ G0077_B_DoNotDrawFluxcagesDuringEndgame
 
 	Frame _doorFrameLeftD1C; // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C
 	Frame _doorFrameRightD1C; // @ G0171_s_Graphic558_Frame_DoorFrameRight_D1C
@@ -816,14 +814,14 @@ public:
 	byte _palChangesFloorOrnD3[16]; // @ G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3
 	byte _palChangesFloorOrnD2[16]; // @ G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2
 
-	bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
-	byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap
-	void f493_addDerivedBitmap(int16 derivedBitmapIndex); // @ F0493_CACHE_AddDerivedBitmap
-	void f480_releaseBlock(uint16 index); // @ F0480_CACHE_ReleaseBlock
-	uint16 f431_getDarkenedColor(uint16 RGBcolor);
-	void f436_STARTEND_FadeToPalette(uint16 *P0849_pui_Palette); // @ F0436_STARTEND_FadeToPalette
-	void f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom); // @ F0508_AMIGA_BuildPaletteChangeCopperList
-	void f136_shadeScreenBox(Box* box, Color color) { warning(false, "STUB METHOD: f136_shadeScreenBox"); } // @ F0136_VIDEO_ShadeScreenBox
+	bool isDerivedBitmapInCache(int16 derivedBitmapIndex); // @  F0491_CACHE_IsDerivedBitmapInCache
+	byte *getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap
+	void addDerivedBitmap(int16 derivedBitmapIndex); // @ F0493_CACHE_AddDerivedBitmap
+	void releaseBlock(uint16 index); // @ F0480_CACHE_ReleaseBlock
+	uint16 getDarkenedColor(uint16 RGBcolor);
+	void startEndFadeToPalette(uint16 *P0849_pui_Palette); // @ F0436_STARTEND_FadeToPalette
+	void buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom); // @ F0508_AMIGA_BuildPaletteChangeCopperList
+	void shadeScreenBox(Box* box, Color color) { warning(false, "STUB METHOD: shadeScreenBox"); } // @ F0136_VIDEO_ShadeScreenBox
 
 private:
 	void initConstants();
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 5c60ff4..2b2675c 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1208,7 +1208,7 @@ T0200006:
 T0200011:
 			AL0422_i_SightRange = L0424_ps_CreatureInfo->getSightRange();
 			if (!getFlag(L0424_ps_CreatureInfo->_attributes, k0x1000_MaskCreatureInfo_nightVision)) {
-				AL0422_i_SightRange -= _vm->_displayMan->_g304_dungeonViewPaletteIndex >> 1;
+				AL0422_i_SightRange -= _vm->_displayMan->_dungeonViewPaletteIndex >> 1;
 			}
 			if (_g381_currGroupDistanceToParty > MAX((int16)1, AL0422_i_SightRange)) {
 				return 0;
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index c4c48a0..8e12d9c 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -124,19 +124,19 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 			_vm->_eventMan->_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputMovement;
 			_vm->_eventMan->_secondaryKeyboardInput = _vm->_eventMan->_secondaryKeyboardInputMovement;
 			_vm->_eventMan->discardAllInput();
-			_vm->_displayMan->f98_drawFloorAndCeiling();
+			_vm->_displayMan->drawFloorAndCeiling();
 			return;
 		}
 	}
-	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	_vm->_displayMan->_useByteBoxCoordinates = false;
 	_g432_inventoryChampionOrdinal = _vm->indexToOrdinal(championIndex);
 	if (!AL1102_ui_InventoryChampionOrdinal) {
-		_vm->_displayMan->f136_shadeScreenBox(&_vm->_displayMan->_boxMovementArrows, k0_ColorBlack);
+		_vm->_displayMan->shadeScreenBox(&_vm->_displayMan->_boxMovementArrows, k0_ColorBlack);
 	}
 	L1103_ps_Champion = &_vm->_championMan->_champions[championIndex];
-	_vm->_displayMan->f466_loadIntoBitmap(k17_InventoryGraphicIndice, _vm->_displayMan->_g296_bitmapViewport);
+	_vm->_displayMan->loadIntoBitmap(k17_InventoryGraphicIndice, _vm->_displayMan->_bitmapViewport);
 	if (_vm->_championMan->_candidateChampionOrdinal) {
-		_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
+		_vm->_displayMan->fillBoxBitmap(_vm->_displayMan->_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
 	}
 
 	switch (_vm->getGameLanguage()) { // localized
@@ -170,13 +170,13 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 
 void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) {
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan._g578_useByteBoxCoordinates = false;
+	dispMan._useByteBoxCoordinates = false;
 	Box box;
 	box._y1 = 0;
 	box._y2 = 28;
 	box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7;
 	box._x2 = box._x1 + 31;
-	dispMan.f21_blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, &box, k16_byteWidth, kM1_ColorNoTransparency, 29);
+	dispMan.blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, &box, k16_byteWidth, kM1_ColorNoTransparency, 29);
 }
 
 void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
@@ -185,8 +185,8 @@ void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidt
 	box._x2 = box._x1 + pixelWidth;
 	box._y1 = y;
 	box._y2 = box._y1 + 6;
-	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, box, color, k112_byteWidthViewport, k136_heightViewport);
+	_vm->_displayMan->_useByteBoxCoordinates = false;
+	_vm->_displayMan->fillBoxBitmap(_vm->_displayMan->_bitmapViewport, box, color, k112_byteWidthViewport, k136_heightViewport);
 }
 
 void InventoryMan::f344_drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
@@ -213,26 +213,26 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
 	Champion &champ = _vm->_championMan->_champions[_g432_inventoryChampionOrdinal];
 	f334_closeChest();
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
+	dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k20_PanelEmptyIndice), g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
 
 	switch (_vm->getGameLanguage()) { // localized
 	default:
 	case Common::EN_ANY:
-		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k30_FoodLabelIndice), g35_BoxFood, k24_byteWidth, k12_ColorDarkestGray, 9);
-		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k31_WaterLabelIndice), g36_BoxWater, k24_byteWidth, k12_ColorDarkestGray, 9);
+		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k30_FoodLabelIndice), g35_BoxFood, k24_byteWidth, k12_ColorDarkestGray, 9);
+		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k31_WaterLabelIndice), g36_BoxWater, k24_byteWidth, k12_ColorDarkestGray, 9);
 		break;
 	case Common::DE_DEU:
-		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k30_FoodLabelIndice), g35_BoxFood, k32_byteWidth, k12_ColorDarkestGray, 9);
-		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k31_WaterLabelIndice), g36_BoxWater, k32_byteWidth, k12_ColorDarkestGray, 9);
+		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k30_FoodLabelIndice), g35_BoxFood, k32_byteWidth, k12_ColorDarkestGray, 9);
+		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k31_WaterLabelIndice), g36_BoxWater, k32_byteWidth, k12_ColorDarkestGray, 9);
 		break;
 	case Common::FR_FRA:
-		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k30_FoodLabelIndice), g35_BoxFood, k48_byteWidth, k12_ColorDarkestGray, 9);
-		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k31_WaterLabelIndice), g36_BoxWater, k24_byteWidth, k12_ColorDarkestGray, 9);
+		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k30_FoodLabelIndice), g35_BoxFood, k48_byteWidth, k12_ColorDarkestGray, 9);
+		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k31_WaterLabelIndice), g36_BoxWater, k24_byteWidth, k12_ColorDarkestGray, 9);
 		break;
 	}
 
 	if (champ._poisonEventCount) {
-		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k32_PoisionedLabelIndice),
+		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k32_PoisionedLabelIndice),
 								   g37_BoxPoisoned, k48_byteWidth, k12_ColorDarkestGray, 15);
 	}
 	f344_drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown);
@@ -241,7 +241,7 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
 
 void InventoryMan::f346_drawPanelResurrectReincarnate() {
 	_g424_panelContent = k5_PanelContentResurrectReincarnate;
-	_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k40_PanelResurectReincaranteIndice),
+	_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k40_PanelResurectReincaranteIndice),
 										 g32_BoxPanel, k72_byteWidth, k6_ColorDarkGreen, 73);
 }
 
@@ -323,7 +323,7 @@ void InventoryMan::f341_drawPanelScroll(Scroll* scroll) {
 		charRed++;
 	}
 	*charRed = '\0';
-	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k23_PanelOpenScrollIndice),
+	dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k23_PanelOpenScrollIndice),
 							   g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
 	int16 lineCount = 1;
 	charRed++;
@@ -374,7 +374,7 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo
 	if (!isPressingEye) {
 		objMan.f38_drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen);
 	}
-	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k25_PanelOpenChestIndice),
+	dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k25_PanelOpenChestIndice),
 							   g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
 	int16 chestSlotIndex = 0;
 	Thing thing = chest->getSlot();
@@ -399,7 +399,7 @@ void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int
 	box._x2 = (box._x1 = xPos) + 15;
 	box._y2 = (box._y1 = yPos) + 15;
 	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, iconBitmap);
-	_vm->_displayMan->f20_blitToViewport(iconBitmap, box, k8_byteWidth, kM1_ColorNoTransparency, 16);
+	_vm->_displayMan->blitToViewport(iconBitmap, box, k8_byteWidth, kM1_ColorNoTransparency, 16);
 }
 
 void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, const char** attribStrings, char* destString, const char* prefixString, const char* suffixString) {
@@ -480,7 +480,7 @@ void InventoryMan::f339_drawPanelArrowOrEye(bool pressingEye) {
 	static Box boxArrowOrEye(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye 
 
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice),
+	dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice),
 							   boxArrowOrEye, k8_byteWidth, k8_ColorRed, 9);
 }
 
@@ -511,9 +511,9 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		f333_openAndDrawChest(thingToDraw, (Container *)rawThingPtr, pressingEye);
 	} else {
 		IconIndice iconIndex = objMan.f33_getIconIndex(thingToDraw);
-		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice),
+		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k20_PanelEmptyIndice),
 								   g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
-		dispMan.f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k29_ObjectDescCircleIndice),
+		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k29_ObjectDescCircleIndice),
 								   boxObjectDescCircle, k16_byteWidth, k12_ColorDarkestGray, 27);
 
 		const char *descString = nullptr;
@@ -700,7 +700,7 @@ void InventoryMan::f337_setDungeonViewPalette() {
 	static const int16 g40_palIndexToLightAmmount[6] = {99, 75, 50, 25, 1, 0}; // @ G0040_ai_Graphic562_PaletteIndexToLightAmount
 
 	if (_vm->_dungeonMan->_currMap->_difficulty == 0) {
-		_vm->_displayMan->_g304_dungeonViewPaletteIndex = 0; /* Brightest color palette index */
+		_vm->_displayMan->_dungeonViewPaletteIndex = 0; /* Brightest color palette index */
 	} else {
 		/* Get torch light power from both hands of each champion in the party */
 		int16 L1038_i_Counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and _vm->_objectMan->f32_getObjectType then returns -1 */
@@ -763,10 +763,10 @@ void InventoryMan::f337_setDungeonViewPalette() {
 		} else {
 			AL1039_ui_PaletteIndex = 5; /* Darkest color palette index */
 		}
-		_vm->_displayMan->_g304_dungeonViewPaletteIndex = AL1039_ui_PaletteIndex;
+		_vm->_displayMan->_dungeonViewPaletteIndex = AL1039_ui_PaletteIndex;
 	}
 
-	_vm->_displayMan->_g342_refreshDungeonViewPaleteRequested = true;
+	_vm->_displayMan->_refreshDungeonViewPaleteRequested = true;
 }
 
 void InventoryMan::f338_decreaseTorchesLightPower() {
@@ -826,7 +826,7 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 
 	f334_closeChest();
 	L1094_ps_Champion = &_vm->_championMan->_champions[L1093_ui_ChampionIndex = _vm->ordinalToIndex(_g432_inventoryChampionOrdinal)];
-	_vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
+	_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k20_PanelEmptyIndice), g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
 	L1091_i_Y = 58;
 	for (AL1090_ui_SkillIndex = k0_ChampionSkillFighter; AL1090_ui_SkillIndex <= k3_ChampionSkillWizard; AL1090_ui_SkillIndex++) {
 		AL1092_i_SkillLevel = MIN((uint16)16, _vm->_championMan->getSkillLevel(L1093_ui_ChampionIndex, AL1090_ui_SkillIndex | k0x8000_IgnoreTemporaryExperience));
@@ -874,7 +874,7 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 
 void InventoryMan::f350_drawStopPressingMouth() {
 	f347_drawPanel();
-	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+	_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 	_vm->_eventMan->_hideMousePointerRequestCount = 1;
 	_vm->_eventMan->showMouse();
 	_vm->_eventMan->showMouse();
@@ -886,7 +886,7 @@ void InventoryMan::f353_drawStopPressingEye() {
 
 	f332_drawIconToViewport(k202_IconIndiceEyeNotLooking, 12, 13);
 	f347_drawPanel();
-	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+	_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 	if ((L1100_T_LeaderHandObject = _vm->_championMan->_leaderHandObject) != Thing::_none) {
 		_vm->_objectMan->f34_drawLeaderObjectName(L1100_T_LeaderHandObject);
 	}
@@ -940,7 +940,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 			_vm->_eventMan->showMouse();
 			_vm->_eventMan->_hideMousePointerRequestCount = 1;
 			f345_drawPanelFoodWaterPoisoned();
-			_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+			_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 		}
 		return;
 	}
@@ -1112,7 +1112,7 @@ void InventoryMan::f352_processCommand71_clickOnEye() {
 		_vm->_objectMan->f35_clearLeaderObjectName();
 		f342_drawPanelObject(_vm->_championMan->_leaderHandObject, true);
 	}
-	_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+	_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 
 }
 }
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 52ba139..17a9b4f 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -133,10 +133,10 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
 		_groupMan->f196_initActiveGroups();
 
 		if (L1366_B_FadePalette) {
-			_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer);
+			_displayMan->startEndFadeToPalette(_displayMan->_blankBuffer);
 			delay(1);
 			_displayMan->fillScreen(k0_ColorBlack);
-			_displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);
+			_displayMan->startEndFadeToPalette(_displayMan->_paletteTopAndBottomScreen);
 		}
 	} else {
 		_dungeonId = dmSaveHeader._dungeonId;
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index ae271fc..c42616f 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -119,7 +119,7 @@ MenuMan::~MenuMan() {
 
 void MenuMan::f395_drawMovementArrows() {
 	_vm->_eventMan->showMouse();
-	_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k13_MovementArrowsIndice),
+	_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k13_MovementArrowsIndice),
 									   &_vm->_displayMan->_boxMovementArrows, k48_byteWidth, kM1_ColorNoTransparency, 45);
 	_vm->_eventMan->hideMouse();
 }
@@ -147,12 +147,12 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
 	box._x2 = box._x1 + 19;
 	box._y1 = 86;
 	box._y2 = 120;
-	dm._g578_useByteBoxCoordinates = false;
+	dm._useByteBoxCoordinates = false;
 	if (!champion._currHealth) {
-		dm.D24_fillScreenBox(box, k0_ColorBlack);
+		dm.fillScreenBox(box, k0_ColorBlack);
 		return;
 	}
-	byte *bitmapIcon = dm._g74_tmpBitmap;
+	byte *bitmapIcon = dm._tmpBitmap;
 	Thing thing = champion.getSlot(k1_ChampionSlotActionHand);
 	IconIndice iconIndex;
 	if (thing == Thing::_none) {
@@ -160,37 +160,37 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
 	} else if (_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
 		iconIndex = _vm->_objectMan->f33_getIconIndex(thing);
 	} else {
-		dm.f134_fillBitmap(bitmapIcon, k4_ColorCyan, 16, 16);
+		dm.fillBitmap(bitmapIcon, k4_ColorCyan, 16, 16);
 		goto T0386006;
 	}
 	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, bitmapIcon);
-	dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, bitmapIcon, 16, 16, 16, 16, palChangesActionAreaObjectIcon);
+	dm.blitToBitmapShrinkWithPalChange(bitmapIcon, bitmapIcon, 16, 16, 16, 16, palChangesActionAreaObjectIcon);
 T0386006:
-	dm.D24_fillScreenBox(box, k4_ColorCyan);
+	dm.fillScreenBox(box, k4_ColorCyan);
 	Box box2;
 	box2._x1 = box._x1 + 2;
 	box2._x2 = box._x2 - 2;
 	box2._y1 = 95;
 	box2._y2 = 110;
-	dm.f21_blitToScreen(bitmapIcon, &box2, k8_byteWidth, kM1_ColorNoTransparency, 16);
+	dm.blitToScreen(bitmapIcon, &box2, k8_byteWidth, kM1_ColorNoTransparency, 16);
 	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) {
-		_vm->_displayMan->f136_shadeScreenBox(&box, k0_ColorBlack);
+		_vm->_displayMan->shadeScreenBox(&box, k0_ColorBlack);
 	}
 }
 
 void MenuMan::f456_drawDisabledMenu() {
 	if (!_vm->_championMan->_partyIsSleeping) {
 		_vm->_eventMan->highlightBoxDisable();
-		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+		_vm->_displayMan->_useByteBoxCoordinates = false;
 		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
 			if (_vm->_inventoryMan->_g424_panelContent == k4_PanelContentChest) {
 				_vm->_inventoryMan->f334_closeChest();
 			}
 		} else {
-			_vm->_displayMan->f136_shadeScreenBox(&_vm->_displayMan->_boxMovementArrows, k0_ColorBlack);
+			_vm->_displayMan->shadeScreenBox(&_vm->_displayMan->_boxMovementArrows, k0_ColorBlack);
 		}
-		_vm->_displayMan->f136_shadeScreenBox(&boxSpellArea, k0_ColorBlack);
-		_vm->_displayMan->f136_shadeScreenBox(&boxActionArea, k0_ColorBlack);
+		_vm->_displayMan->shadeScreenBox(&boxSpellArea, k0_ColorBlack);
+		_vm->_displayMan->shadeScreenBox(&boxActionArea, k0_ColorBlack);
 		_vm->_eventMan->setMousePointerToNormal(k0_pointerArrow);
 	}
 }
@@ -256,8 +256,8 @@ void MenuMan::f387_drawActionArea() {
 	TextMan &textMan = *_vm->_textMan;
 
 	_vm->_eventMan->hideMouse();
-	dispMan._g578_useByteBoxCoordinates = false;
-	dispMan.D24_fillScreenBox(boxActionArea, k0_ColorBlack);
+	dispMan._useByteBoxCoordinates = false;
+	dispMan.fillScreenBox(boxActionArea, k0_ColorBlack);
 	if (_g509_actionAreaContainsIcons) {
 		for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._partyChampionCount; ++champIndex)
 			f386_drawActionIcon((ChampionIndex)champIndex);
@@ -267,13 +267,13 @@ void MenuMan::f387_drawActionArea() {
 			box = boxActionArea2ActionMenu;
 		if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone)
 			box = boxActionArea1ActionMenu;
-		dispMan.f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k10_MenuActionAreaIndice),
+		dispMan.blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k10_MenuActionAreaIndice),
 								 &box, k48_byteWidth, kM1_ColorNoTransparency, 45);
-		textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen,
+		textMan.f41_printWithTrailingSpaces(dispMan._bitmapScreen, k160_byteWidthScreen,
 											235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._actingChampionOrdinal)]._name,
 											k7_ChampionNameMaximumLength, k200_heightScreen);
 		for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) {
-			textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
+			textMan.f41_printWithTrailingSpaces(dispMan._bitmapScreen, k160_byteWidthScreen, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
 												f384_getActionName(_g713_actionList._actionIndices[actionListIndex]),
 												k12_ActionNameMaximumLength, k200_heightScreen);
 		}
@@ -301,13 +301,13 @@ void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) {
 	static Box boxSpellAreaControls(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls 
 
 	Champion *champ = &_vm->_championMan->_champions[champIndex];
-	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	_vm->_displayMan->_useByteBoxCoordinates = false;
 	int16 champHP0 = _vm->_championMan->_champions[0]._currHealth;
 	int16 champHP1 = _vm->_championMan->_champions[1]._currHealth;
 	int16 champHP2 = _vm->_championMan->_champions[2]._currHealth;
 	int16 champHP3 = _vm->_championMan->_champions[3]._currHealth;
 	_vm->_eventMan->showMouse();
-	_vm->_displayMan->D24_fillScreenBox(boxSpellAreaControls, k0_ColorBlack);
+	_vm->_displayMan->fillScreenBox(boxSpellAreaControls, k0_ColorBlack);
 	switch (champIndex) {
 	case 0:
 		_vm->_eventMan->highlightScreenBox(233, 277, 42, 49);
@@ -375,8 +375,8 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
 	char L1204_ac_SpellSymbolString[2] = {'\0', '\0'};
 	Champion *L1203_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
 	if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) {
-		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		_vm->_displayMan->f132_blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, boxSpellAreaLine, 0, 12, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
+		_vm->_displayMan->_useByteBoxCoordinates = false;
+		_vm->_displayMan->blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, boxSpellAreaLine, 0, 12, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
 		int16 x = 1;
 		char character = 96 + (6 * L1203_ps_Champion->_symbolStep);
 		for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
@@ -384,8 +384,8 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
 			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 14, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
 		}
 	} else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) {
-		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		_vm->_displayMan->f132_blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, boxSpellAreaLine, 0, 24, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
+		_vm->_displayMan->_useByteBoxCoordinates = false;
+		_vm->_displayMan->blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, boxSpellAreaLine, 0, 24, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
 		int16 x = 8;
 		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
 			if ((L1204_ac_SpellSymbolString[0] = L1203_ps_Champion->_symbols[symbolIndex]) == '\0')
@@ -406,14 +406,14 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	}
 	if (_vm->_championMan->_magicCasterChampionIndex == kM1_ChampionNone) {
 		_vm->_eventMan->showMouse();
-		_vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &boxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33);
+		_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &boxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33);
 		_vm->_eventMan->hideMouse();
 	}
 	if (champIndex == kM1_ChampionNone) {
 		_vm->_championMan->_magicCasterChampionIndex = kM1_ChampionNone;
 		_vm->_eventMan->showMouse();
-		_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-		_vm->_displayMan->D24_fillScreenBox(boxSpellArea, k0_ColorBlack);
+		_vm->_displayMan->_useByteBoxCoordinates = false;
+		_vm->_displayMan->fillScreenBox(boxSpellArea, k0_ColorBlack);
 		_vm->_eventMan->hideMouse();
 		return;
 	}
@@ -421,9 +421,9 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
 	_vm->_eventMan->showMouse();
 	f393_drawSpellAreaControls((ChampionIndex)champIndex);
-	_vm->_displayMan->f21_blitToScreen(_gK72_bitmapSpellAreaLine, &boxSpellAreaLine2, k48_byteWidth, kM1_ColorNoTransparency, 12);
+	_vm->_displayMan->blitToScreen(_gK72_bitmapSpellAreaLine, &boxSpellAreaLine2, k48_byteWidth, kM1_ColorNoTransparency, 12);
 	f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols);
-	_vm->_displayMan->f21_blitToScreen(_gK72_bitmapSpellAreaLine, &boxSpellAreaLine3, k48_byteWidth, kM1_ColorNoTransparency, 12);
+	_vm->_displayMan->blitToScreen(_gK72_bitmapSpellAreaLine, &boxSpellAreaLine3, k48_byteWidth, kM1_ColorNoTransparency, 12);
 	_vm->_eventMan->hideMouse();
 }
 
@@ -435,7 +435,7 @@ void MenuMan::f457_drawEnabledMenus() {
 
 	if (_vm->_championMan->_partyIsSleeping) {
 		_vm->_eventMan->drawSleepScreen();
-		_vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView);
+		_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 	} else {
 		AL1462_i_MagicCasterChampionIndex = _vm->_championMan->_magicCasterChampionIndex;
 		_vm->_championMan->_magicCasterChampionIndex = kM1_ChampionNone; /* Force next function to draw the spell area */
@@ -449,7 +449,7 @@ void MenuMan::f457_drawEnabledMenus() {
 			_vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 			_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)_vm->ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
 		} else {
-			_vm->_displayMan->f98_drawFloorAndCeiling();
+			_vm->_displayMan->drawFloorAndCeiling();
 			f395_drawMovementArrows();
 		}
 		_vm->_eventMan->setMousePointer();
@@ -1726,8 +1726,8 @@ void MenuMan::f385_drawActionDamage(int16 damage) {
 	int16 L1643_i_Width;
 
 	_vm->_eventMan->showMouse();
-	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
-	_vm->_displayMan->D24_fillScreenBox(boxActionArea, k0_ColorBlack);
+	_vm->_displayMan->_useByteBoxCoordinates = false;
+	_vm->_displayMan->fillScreenBox(boxActionArea, k0_ColorBlack);
 	if (damage < 0) {
 		static const char *messages_EN_ANY[2] = {"CAN'T REACH", "NEED AMMO"};
 		static const char *messages_DE_DEU[2] = {"ZU WEIT WEG", "MEHR MUNITION"};
@@ -1755,7 +1755,7 @@ void MenuMan::f385_drawActionDamage(int16 damage) {
 	} else {
 		if (damage > 40) {
 			L1180_ps_Box = &boxActionArea3ActionMenu;
-			L1177_puc_Bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
+			L1177_puc_Bitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
 			L1175_i_ByteWidth = k48_byteWidth;
 			L1643_i_Width = 45;
 		} else {
@@ -1771,16 +1771,16 @@ void MenuMan::f385_drawActionDamage(int16 damage) {
 				L1180_ps_Box = &G0503_s_Graphic560_Box_ActionAreaSmallDamage;
 			}
 			L1643_i_Width = 37;
-			if (!_vm->_displayMan->f491_isDerivedBitmapInCache(AL1174_ui_DerivedBitmapIndex)) {
-				AL1178_puc_Bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
-				L1177_puc_Bitmap = _vm->_displayMan->f492_getDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
-				_vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(AL1178_puc_Bitmap, L1177_puc_Bitmap, 96, 45, AL1176_i_PixelWidth, 37, _vm->_displayMan->_palChangesNoChanges);
-				_vm->_displayMan->f493_addDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
+			if (!_vm->_displayMan->isDerivedBitmapInCache(AL1174_ui_DerivedBitmapIndex)) {
+				AL1178_puc_Bitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
+				L1177_puc_Bitmap = _vm->_displayMan->getDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
+				_vm->_displayMan->blitToBitmapShrinkWithPalChange(AL1178_puc_Bitmap, L1177_puc_Bitmap, 96, 45, AL1176_i_PixelWidth, 37, _vm->_displayMan->_palChangesNoChanges);
+				_vm->_displayMan->addDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
 			} else {
-				L1177_puc_Bitmap = _vm->_displayMan->f492_getDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
+				L1177_puc_Bitmap = _vm->_displayMan->getDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
 			}
 		}
-		_vm->_displayMan->f21_blitToScreen(L1177_puc_Bitmap, (int16 *)L1180_ps_Box, L1175_i_ByteWidth, kM1_ColorNoTransparency, L1643_i_Width);
+		_vm->_displayMan->blitToScreen(L1177_puc_Bitmap, (int16 *)L1180_ps_Box, L1175_i_ByteWidth, kM1_ColorNoTransparency, L1643_i_Width);
 		/* Convert damage value to string */
 		AL1174_ui_CharacterIndex = 5;
 		AL1176_i_X = 274;
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index ac66f23..25b8e34 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -332,10 +332,10 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 						L0723_B_DrawDungeonViewWhileFalling = true;
 						if (L0719_i_TraversedPitCount) {
 							_vm->_dungeonMan->setCurrentMapAndPartyMap(L0715_ui_MapIndexDestination);
-							_vm->_displayMan->f96_loadCurrentMapGraphics();
+							_vm->_displayMan->loadCurrentMapGraphics();
 						}
 						L0719_i_TraversedPitCount++;
-						_vm->_displayMan->f128_drawDungeon(_vm->_dungeonMan->_partyDir, destMapX, destMapY); /* BUG0_28 When falling through multiple pits the dungeon view is updated to show each traversed map but the graphics used for creatures, wall and floor ornaments may not be correct. The dungeon view is drawn for each map by using the graphics loaded for the source map. Therefore the graphics for creatures, wall and floor ornaments may not look like what they should */
+						_vm->_displayMan->drawDungeon(_vm->_dungeonMan->_partyDir, destMapX, destMapY); /* BUG0_28 When falling through multiple pits the dungeon view is updated to show each traversed map but the graphics used for creatures, wall and floor ornaments may not be correct. The dungeon view is drawn for each map by using the graphics loaded for the source map. Therefore the graphics for creatures, wall and floor ornaments may not look like what they should */
 																												  /* BUG0_71 Some timings are too short on fast computers. When the party falls in a series of pits, the dungeon view is refreshed too quickly because the execution speed is not limited */
 																												  /* BUG0_01 While drawing creatures the engine will read invalid ACTIVE_GROUP data in _vm->_groupMan->_g375_activeGroups because the data is for the creatures on the source map and not the map being drawn. The only consequence is that creatures may be drawn with incorrect bitmaps and/or directions */
 					}
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 00023c3..56b99fe 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -189,14 +189,14 @@ void ObjectMan::f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 		if (g26_IconGraphicFirstIndex[L0011_ui_Counter] > iconIndex)
 			break;
 	}
-	L0012_pl_Bitmap_Icon = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k42_ObjectIcons_000_TO_031 + --L0011_ui_Counter);
+	L0012_pl_Bitmap_Icon = _vm->_displayMan->getNativeBitmapOrGraphic(k42_ObjectIcons_000_TO_031 + --L0011_ui_Counter);
 	iconIndex -= g26_IconGraphicFirstIndex[L0011_ui_Counter];
-	_vm->_displayMan->_g578_useByteBoxCoordinates = true;
+	_vm->_displayMan->_useByteBoxCoordinates = true;
 	L1568_s_Box._y1 = 0;
 	L1568_s_Box._x1 = 0;
 	L1568_s_Box._y2 = 15;
 	L1568_s_Box._x2 = 15;
-	_vm->_displayMan->f132_blitToBitmap(L0012_pl_Bitmap_Icon, destBitmap, L1568_s_Box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, kM1_ColorNoTransparency, gK77_IconGraphicHeight[L0011_ui_Counter], 16);
+	_vm->_displayMan->blitToBitmap(L0012_pl_Bitmap_Icon, destBitmap, L1568_s_Box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, kM1_ColorNoTransparency, gK77_IconGraphicHeight[L0011_ui_Counter], 16);
 }
 
 void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
@@ -219,18 +219,18 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 			break;
 	}
 	L0015_ui_IconGraphicIndex--;
-	L0018_puc_Bitmap_Icons = _vm->_displayMan->f489_getNativeBitmapOrGraphic(L0015_ui_IconGraphicIndex + k42_ObjectIcons_000_TO_031);
+	L0018_puc_Bitmap_Icons = _vm->_displayMan->getNativeBitmapOrGraphic(L0015_ui_IconGraphicIndex + k42_ObjectIcons_000_TO_031);
 	iconIndex -= g26_IconGraphicFirstIndex[L0015_ui_IconGraphicIndex];
 	if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) {
-		L0020_puc_Bitmap_Destination = _vm->_displayMan->_g296_bitmapViewport;
+		L0020_puc_Bitmap_Destination = _vm->_displayMan->_bitmapViewport;
 		L0016_i_ByteWidth = k112_byteWidthViewport;
 		L1569_i_Width = 136;
 	} else {
-		L0020_puc_Bitmap_Destination = (unsigned char*)_vm->_displayMan->_g348_bitmapScreen;
+		L0020_puc_Bitmap_Destination = (unsigned char*)_vm->_displayMan->_bitmapScreen;
 		L0016_i_ByteWidth = k160_byteWidthScreen;
 		L1569_i_Width = 200;
 	}
-	_vm->_displayMan->_g578_useByteBoxCoordinates = false, _vm->_displayMan->f132_blitToBitmap(L0018_puc_Bitmap_Icons, L0020_puc_Bitmap_Destination, L0019_s_Box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, k128_byteWidth, L0016_i_ByteWidth, kM1_ColorNoTransparency, gK77_IconGraphicHeight[L0015_ui_IconGraphicIndex], L1569_i_Width);
+	_vm->_displayMan->_useByteBoxCoordinates = false, _vm->_displayMan->blitToBitmap(L0018_puc_Bitmap_Icons, L0020_puc_Bitmap_Destination, L0019_s_Box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, k128_byteWidth, L0016_i_ByteWidth, kM1_ColorNoTransparency, gK77_IconGraphicHeight[L0015_ui_IconGraphicIndex], L1569_i_Width);
 }
 
 #define k14_ObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH
@@ -259,7 +259,7 @@ void ObjectMan::f34_drawLeaderObjectName(Thing thing) {
 	} else {
 		objectName = _g352_objectNames[L0007_i_IconIndex];
 	}
-	_vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, 233, 37, k4_ColorCyan, k0_ColorBlack, objectName, k14_ObjectNameMaximumLength, k200_heightScreen);
+	_vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, 233, 37, k4_ColorCyan, k0_ColorBlack, objectName, k14_ObjectNameMaximumLength, k200_heightScreen);
 }
 
 IconIndice ObjectMan::f39_getIconIndexInSlotBox(uint16 slotBoxIndex) {
@@ -268,7 +268,7 @@ IconIndice ObjectMan::f39_getIconIndexInSlotBox(uint16 slotBoxIndex) {
 
 void ObjectMan::f35_clearLeaderObjectName() {
 	static Box g28_BoxLeaderHandObjectName(233, 319, 33, 38); // @ G0028_s_Graphic562_Box_LeaderHandObjectName 
-	_vm->_displayMan->D24_fillScreenBox(g28_BoxLeaderHandObjectName, k0_ColorBlack);
+	_vm->_displayMan->fillScreenBox(g28_BoxLeaderHandObjectName, k0_ColorBlack);
 }
 
 void ObjectMan::f37_drawIconToScreen(int16 iconIndex, int16 posX, int16 posY) {
@@ -278,6 +278,6 @@ void ObjectMan::f37_drawIconToScreen(int16 iconIndex, int16 posX, int16 posY) {
 	L0014_s_Box._x2 = (L0014_s_Box._x1 = posX) + 15;
 	L0014_s_Box._y2 = (L0014_s_Box._y1 = posY) + 15;
 	f36_extractIconFromBitmap(iconIndex, L0013_puc_Bitmap_Icon);
-	_vm->_displayMan->f21_blitToScreen(L0013_puc_Bitmap_Icon, &L0014_s_Box, k8_byteWidth, kM1_ColorNoTransparency, 16);
+	_vm->_displayMan->blitToScreen(L0013_puc_Bitmap_Icon, &L0014_s_Box, k8_byteWidth, kM1_ColorNoTransparency, 16);
 }
 }
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index bae4661..68feba8 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -57,9 +57,9 @@ void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int1
 	uint16 textLength = strlen(text);
 	uint16 nextX = destX;
 	uint16 nextY = destY;
-	byte *srcBitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k557_FontGraphicIndice);
+	byte *srcBitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k557_FontGraphicIndice);
 
-	byte *tmp = _vm->_displayMan->_g74_tmpBitmap;
+	byte *tmp = _vm->_displayMan->_tmpBitmap;
 	for (uint16 i = 0; i < (k5_LetterWidth + 1) * k6_LetterHeight * 128; ++i) {
 		tmp[i] = srcBitmap[i] ? textColor : bgColor;
 	}
@@ -75,7 +75,7 @@ void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int1
 		uint16 srcX = (1 + 5) * *begin; // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
 
 		Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1);
-		_vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128 / 2, destByteWidth, kM1_ColorNoTransparency,
+		_vm->_displayMan->blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128 / 2, destByteWidth, kM1_ColorNoTransparency,
 											k6_LetterHeight, destHeight);
 
 		nextX += k5_LetterWidth + 1;
@@ -83,11 +83,11 @@ void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int1
 }
 
 void TextMan::f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text) {
-	f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth / 2, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight);
+	f40_printTextToBitmap(_vm->_displayMan->_bitmapScreen, _vm->_displayMan->_screenWidth / 2, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight);
 }
 
 void TextMan::f52_printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) {
-	f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, posX, posY, textColor, bgColor, text, k136_heightViewport);
+	f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, posX, posY, textColor, bgColor, text, k136_heightViewport);
 }
 
 void TextMan::f41_printWithTrailingSpaces(byte* destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor,
@@ -199,7 +199,7 @@ void TextMan::f44_messageAreaClearExpiredRows() {
 	int32 L0027_l_ExpirationTime;
 	Box L0028_s_Box;
 
-	_vm->_displayMan->_g578_useByteBoxCoordinates = false;
+	_vm->_displayMan->_useByteBoxCoordinates = false;
 	L0028_s_Box._x1 = 0;
 	L0028_s_Box._x2 = 319;
 	for (L0026_ui_RowIndex = 0; L0026_ui_RowIndex < 4; L0026_ui_RowIndex++) {
@@ -208,7 +208,7 @@ void TextMan::f44_messageAreaClearExpiredRows() {
 			continue;
 		L0028_s_Box._y2 = (L0028_s_Box._y1 = 172 + (L0026_ui_RowIndex * 7)) + 6;
 		f561_isTextScrolling(&_gK60_s_TextScroller, true);
-		_vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g348_bitmapScreen, L0028_s_Box, k0_ColorBlack, k160_byteWidthScreen, k200_heightScreen);
+		_vm->_displayMan->fillBoxBitmap(_vm->_displayMan->_bitmapScreen, L0028_s_Box, k0_ColorBlack, k160_byteWidthScreen, k200_heightScreen);
 		_g360_messageAreaRowExpirationTime[L0026_ui_RowIndex] = -1;
 	}
 }
@@ -235,7 +235,7 @@ void TextMan::f43_messageAreaClearAllRows() {
 	f561_isTextScrolling(&_gK60_s_TextScroller, true);
 
 	Box tmpBox(0, 319, 169, 199);
-	_vm->_displayMan->D24_fillScreenBox(tmpBox, k0_ColorBlack);
+	_vm->_displayMan->fillScreenBox(tmpBox, k0_ColorBlack);
 	
 	_g358_messageAreaCursorRow = 3;
 	_g359_messageAreaCursorColumn = 0;


Commit: 5c81e4f4fd2ea79255e9bc635eb8ef2a93aef60c
    https://github.com/scummvm/scummvm/commit/5c81e4f4fd2ea79255e9bc635eb8ef2a93aef60c
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rename functions and class members of GroupMan

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/group.cpp
    engines/dm/group.h
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/projexpl.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 91a1f99..f21d4c5 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1072,7 +1072,7 @@ int16 ChampionMan::getDamagedChampionCount(uint16 attack, int16 wounds, int16 at
 int16 ChampionMan::getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) {
 	if (_partyChampionCount && (getDistance(mapX, mapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY) <= 1)) {
 		signed char orderedCellsToAttack[4];
-		_vm->_groupMan->f229_setOrderedCellsToAttack(orderedCellsToAttack, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, mapX, mapY, cell);
+		_vm->_groupMan->setOrderedCellsToAttack(orderedCellsToAttack, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, mapX, mapY, cell);
 		for (uint16 i = 0; i < 4; i++) {
 			int16 championIndex = getIndexInCell(orderedCellsToAttack[i]);
 			if (championIndex >= 0)
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 9eefbff..7f439a2 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -365,10 +365,10 @@ void DMEngine::startGame() {
 }
 
 void DMEngine::processNewPartyMap(uint16 mapIndex) {
-	_groupMan->f194_removeAllActiveGroups();
+	_groupMan->removeAllActiveGroups();
 	_dungeonMan->setCurrentMapAndPartyMap(mapIndex);
 	_displayMan->loadCurrentMapGraphics();
-	_groupMan->f195_addAllActiveGroups();
+	_groupMan->addAllActiveGroups();
 	_inventoryMan->f337_setDungeonViewPalette();
 }
 
@@ -972,7 +972,7 @@ void DMEngine::fuseSequnce() {
 	L1431_i_LordChaosMapX = _dungeonMan->_partyMapX;
 	L1432_i_LordChaosMapY = _dungeonMan->_partyMapY;
 	L1431_i_LordChaosMapX += _dirIntoStepCountEast[_dungeonMan->_partyDir], L1432_i_LordChaosMapY += _dirIntoStepCountNorth[_dungeonMan->_partyDir];
-	L1428_ps_Group = (Group*)_dungeonMan->getThingData(L1433_T_LordChaosThing = _groupMan->f175_groupGetThing(L1431_i_LordChaosMapX, L1432_i_LordChaosMapY));
+	L1428_ps_Group = (Group*)_dungeonMan->getThingData(L1433_T_LordChaosThing = _groupMan->groupGetThing(L1431_i_LordChaosMapX, L1432_i_LordChaosMapY));
 	L1428_ps_Group->_health[0] = 10000;
 	_dungeonMan->setGroupCells(L1428_ps_Group, k255_CreatureTypeSingleCenteredCreature, _dungeonMan->_partyMapIndex);
 	_dungeonMan->setGroupDirections(L1428_ps_Group, returnOppositeDir(_dungeonMan->_partyDir), _dungeonMan->_partyMapIndex);
@@ -1028,8 +1028,8 @@ T0446002:
 	fuseSequenceUpdate();
 	for (AL1424_i_MapX = 0; AL1424_i_MapX < _dungeonMan->_currMapWidth; AL1424_i_MapX++) {
 		for (AL1425_i_MapY = 0; AL1425_i_MapY < _dungeonMan->_currMapHeight; AL1425_i_MapY++) {
-			if (((L1427_T_Thing = _groupMan->f175_groupGetThing(AL1424_i_MapX, AL1425_i_MapY)) != Thing::_endOfList) && ((AL1424_i_MapX != L1431_i_LordChaosMapX) || (AL1425_i_MapY != L1432_i_LordChaosMapY))) {
-				_groupMan->f189_delete(AL1424_i_MapX, AL1425_i_MapY);
+			if (((L1427_T_Thing = _groupMan->groupGetThing(AL1424_i_MapX, AL1425_i_MapY)) != Thing::_endOfList) && ((AL1424_i_MapX != L1431_i_LordChaosMapX) || (AL1425_i_MapY != L1432_i_LordChaosMapY))) {
+				_groupMan->groupDelete(AL1424_i_MapX, AL1425_i_MapY);
 			}
 		}
 	}
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 00e66fe..5f356b9 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1448,8 +1448,8 @@ Thing DungeonMan::getDiscardThing(uint16 thingType) {
 							case k14_ProjectileThingType:
 								setCurrentMap(mapIndex);
 								if (thingType == k4_GroupThingType) {
-									_vm->_groupMan->f188_dropGroupPossessions(currMapX, currMapY, squareThing, kM1_soundModeDoNotPlaySound);
-									_vm->_groupMan->f189_delete(currMapX, currMapY);
+									_vm->_groupMan->dropGroupPossessions(currMapX, currMapY, squareThing, kM1_soundModeDoNotPlaySound);
+									_vm->_groupMan->groupDelete(currMapX, currMapY);
 								} else {
 									_vm->_projexpl->f214_projectileDeleteEvent(squareThing);
 									unlinkThingFromList(squareThing, Thing(0), currMapX, currMapY);
@@ -1515,14 +1515,14 @@ uint16 DungeonMan::getCreatureAttributes(Thing thing) {
 
 void DungeonMan::setGroupCells(Group* group, uint16 cells, uint16 mapIndex) {
 	if (mapIndex == _partyMapIndex)
-		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._cells = cells;
+		_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()]._cells = cells;
 	else
 		group->_cells = cells;
 }
 
 void DungeonMan::setGroupDirections(Group* group, int16 dir, uint16 mapIndex) {
 	if (mapIndex == _partyMapIndex)
-		_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (Direction)dir;
+		_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()]._directions = (Direction)dir;
 	else
 		group->setDir(normalizeModulo4(dir));
 }
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index d5d1e31..b627549 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1016,9 +1016,9 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 			if (damage)
 				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, partyMapX, partyMapY, k0_soundModePlayImmediately);
 		} else {
-			isMovementBlocked = (_vm->_groupMan->f175_groupGetThing(partyMapX, partyMapY) != Thing::_endOfList);
+			isMovementBlocked = (_vm->_groupMan->groupGetThing(partyMapX, partyMapY) != Thing::_endOfList);
 			if (isMovementBlocked)
-				_vm->_groupMan->f209_processEvents29to41(partyMapX, partyMapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
+				_vm->_groupMan->processEvents29to41(partyMapX, partyMapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
 		}
 	}
 
@@ -1347,10 +1347,10 @@ void EventManager::processType80_clickInDungeonView_grabLeaderHandObject(uint16
 	int16 mapY = _vm->_dungeonMan->_partyMapY;
 	if (viewCell >= k2_ViewCellBackRight) {
 		mapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir], mapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
-		Thing groupThing = _vm->_groupMan->f175_groupGetThing(mapX, mapY);
+		Thing groupThing = _vm->_groupMan->groupGetThing(mapX, mapY);
 		if ((groupThing != Thing::_endOfList) &&
 			!_vm->_moveSens->f264_isLevitating(groupThing) &&
-			_vm->_groupMan->f176_getCreatureOrdinalInCell((Group*)_vm->_dungeonMan->getThingData(groupThing), normalizeModulo4(viewCell + _vm->_dungeonMan->_partyDir))) {
+			_vm->_groupMan->getCreatureOrdinalInCell((Group*)_vm->_dungeonMan->getThingData(groupThing), normalizeModulo4(viewCell + _vm->_dungeonMan->_partyDir))) {
 			return; /* It is not possible to grab an object on floor if there is a non levitating creature on its cell */
 		}
 	}
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 89cba9d..7947ea9 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -3234,14 +3234,14 @@ T0115015_DrawProjectileAsObject:
 		ActiveGroup *activeGroup;
 		if (group == nullptr) { /* If all creature data and info has not already been gathered */
 			group = (Group*)_vm->_dungeonMan->getThingData(groupThing);
-			activeGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()];
+			activeGroup = &_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()];
 			CreatureInfo *creatureInfo = &g243_CreatureInfo[group->_type];
 			creatureAspectStruct = &_creatureAspects219[creatureInfo->_creatureAspectIndex];
 			creatureSize = getFlag(creatureInfo->_attributes, k0x0003_MaskCreatureInfo_size);
 			creatureGraphicInfoGreen = creatureInfo->_graphicInfo;
 		}
 		objectAspect = (ObjectAspect*)creatureAspectStruct;
-		AL_0_creatureIndexRed = _vm->_groupMan->f176_getCreatureOrdinalInCell(group, cellYellowBear);
+		AL_0_creatureIndexRed = _vm->_groupMan->getCreatureOrdinalInCell(group, cellYellowBear);
 
 		if (AL_0_creatureIndexRed) { /* If there is a creature on the cell being processed */
 			AL_0_creatureIndexRed--; /* Convert ordinal to index */
@@ -3252,7 +3252,7 @@ T0115015_DrawProjectileAsObject:
 		} else
 			goto T0115129_DrawProjectiles; /* No creature to draw at cell, skip to projectiles */
 
-		creatureDirectionDelta = normalizeModulo4(directionParam - _vm->_groupMan->M50_getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed));
+		creatureDirectionDelta = normalizeModulo4(directionParam - _vm->_groupMan->getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed));
 		twoHalfSquareCreaturesFrontView = false;
 		if ((AL_4_groupCells = activeGroup->_cells) == k255_CreatureTypeSingleCenteredCreature) { /* If there is a single centered creature in the group */
 			if (remainingViewCellOrdinalsToProcess || (doorFrontViewDrawingPass == 1))
@@ -3281,7 +3281,7 @@ T0115015_DrawProjectileAsObject:
 						creatureIndexGreen = 0;
 
 					twoHalfSquareCreaturesFrontView = group->getCount();
-					if (((AL_4_groupCells = _vm->_groupMan->M50_getCreatureValue(AL_4_groupCells, AL_0_creatureIndexRed)) == directionParam) || (AL_4_groupCells == returnPrevVal(directionParam)))
+					if (((AL_4_groupCells = _vm->_groupMan->getCreatureValue(AL_4_groupCells, AL_0_creatureIndexRed)) == directionParam) || (AL_4_groupCells == returnPrevVal(directionParam)))
 						AL_2_viewCell = k0_HalfSizedViewCell_LeftColumn;
 					else
 						AL_2_viewCell = k1_HalfSizedViewCell_RightColumn;
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 2b2675c..99ce133 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -43,75 +43,75 @@ int32 M32_setTime(int32 &map_time, int32 time) {
 
 GroupMan::GroupMan(DMEngine *vm) : _vm(vm) {
 	for (uint16 i = 0; i < 4; ++i)
-		_g392_dropMovingCreatureFixedPossessionsCell[i] = 0;
-	_g391_dropMovingCreatureFixedPossCellCount = 0;
-	_g386_fluxCageCount = 0;
+		_dropMovingCreatureFixedPossessionsCell[i] = 0;
+	_dropMovingCreatureFixedPossCellCount = 0;
+	_fluxCageCount = 0;
 	for (uint16 i = 0; i < 4; ++i)
-		_g385_fluxCages[i] = 0;
-	_g378_currentGroupMapX = 0;
-	_g379_currentGroupMapY = 0;
-	_g380_currGroupThing = Thing(0);
+		_fluxCages[i] = 0;
+	_currentGroupMapX = 0;
+	_currentGroupMapY = 0;
+	_currGroupThing = Thing(0);
 	for (uint16 i = 0; i < 4; ++i)
-		_g384_groupMovementTestedDirections[i] = 0;
-	_g381_currGroupDistanceToParty = 0;
-	_g382_currGroupPrimaryDirToParty = 0;
-	_g383_currGroupSecondaryDirToParty = 0;
-	_g388_groupMovementBlockedByGroupThing = Thing(0);
-	_g389_groupMovementBlockedByDoor = false;
-	_g390_groupMovementBlockedByParty = false;
-	_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = false;
-	_g376_maxActiveGroupCount = 60;
-	_g375_activeGroups = nullptr;
-	_g377_currActiveGroupCount = 0;
-	_g395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime = 0;
+		_groupMovementTestedDirections[i] = 0;
+	_currGroupDistanceToParty = 0;
+	_currGroupPrimaryDirToParty = 0;
+	_currGroupSecondaryDirToParty = 0;
+	_groupMovementBlockedByGroupThing = Thing(0);
+	_groupMovementBlockedByDoor = false;
+	_groupMovementBlockedByParty = false;
+	_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = false;
+	_maxActiveGroupCount = 60;
+	_activeGroups = nullptr;
+	_currActiveGroupCount = 0;
+	twoHalfSquareSizedCreaturesGroupLastDirectionSetTime = 0;
 }
 
 GroupMan::~GroupMan() {
-	delete[] _g375_activeGroups;
+	delete[] _activeGroups;
 }
 
-void GroupMan::f196_initActiveGroups() {
+void GroupMan::initActiveGroups() {
 	if (_vm->_newGameFl)
-		_g376_maxActiveGroupCount = 60;
+		_maxActiveGroupCount = 60;
 
-	if (_g375_activeGroups)
-		delete[] _g375_activeGroups;
+	if (_activeGroups)
+		delete[] _activeGroups;
 
-	_g375_activeGroups = new ActiveGroup[_g376_maxActiveGroupCount];
-	for (uint16 i = 0; i < _g376_maxActiveGroupCount; ++i)
-		_g375_activeGroups[i]._groupThingIndex = -1;
+	_activeGroups = new ActiveGroup[_maxActiveGroupCount];
+	for (uint16 i = 0; i < _maxActiveGroupCount; ++i)
+		_activeGroups[i]._groupThingIndex = -1;
 }
 
-uint16 GroupMan::f145_getGroupCells(Group *group, int16 mapIndex) {
+uint16 GroupMan::getGroupCells(Group *group, int16 mapIndex) {
 	byte cells = group->_cells;
 	if (mapIndex == _vm->_dungeonMan->_partyMapIndex)
-		cells = _g375_activeGroups[cells]._cells;
+		cells = _activeGroups[cells]._cells;
 	return cells;
 }
 
-uint16 GroupMan::f147_getGroupDirections(Group *group, int16 mapIndex) {
+uint16 GroupMan::getGroupDirections(Group *group, int16 mapIndex) {
 	static byte groupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_GroupDirections
 
 	if (mapIndex == _vm->_dungeonMan->_partyMapIndex)
-		return _g375_activeGroups[group->getActiveGroupIndex()]._directions;
+		return _activeGroups[group->getActiveGroupIndex()]._directions;
 
 	return groupDirections[group->getDir()];
 }
 
-int16 GroupMan::f176_getCreatureOrdinalInCell(Group *group, uint16 cell) {
+int16 GroupMan::getCreatureOrdinalInCell(Group *group, uint16 cell) {
 	uint16 currMapIndex = _vm->_dungeonMan->_currMapIndex;
-	byte groupCells = f145_getGroupCells(group, currMapIndex);
+	byte groupCells = getGroupCells(group, currMapIndex);
 	if (groupCells == k255_CreatureTypeSingleCenteredCreature)
 		return _vm->indexToOrdinal(0);
 
 	int retval = 0;
 	byte creatureIndex = group->getCount();
 	if (getFlag(g243_CreatureInfo[group->_type]._attributes, k0x0003_MaskCreatureInfo_size) == k1_MaskCreatureSizeHalf) {
-		if ((f147_getGroupDirections(group, currMapIndex) & 1) == (cell & 1))
+		if ((getGroupDirections(group, currMapIndex) & 1) == (cell & 1))
 			cell = returnPrevVal(cell);
 
 		do {
-			byte creatureCell = M50_getCreatureValue(groupCells, creatureIndex);
+			byte creatureCell = getCreatureValue(groupCells, creatureIndex);
 			if (creatureCell == cell || creatureCell == returnNextVal(cell)) {
 				retval = _vm->indexToOrdinal(creatureIndex);
 				break;
@@ -119,7 +119,7 @@ int16 GroupMan::f176_getCreatureOrdinalInCell(Group *group, uint16 cell) {
 		} while (creatureIndex--);
 	} else {
 		do {
-			if (M50_getCreatureValue(groupCells, creatureIndex) == cell) {
+			if (getCreatureValue(groupCells, creatureIndex) == cell) {
 				retval = _vm->indexToOrdinal(creatureIndex);
 				break;
 			}
@@ -129,19 +129,19 @@ int16 GroupMan::f176_getCreatureOrdinalInCell(Group *group, uint16 cell) {
 	return retval;
 }
 
-uint16 GroupMan::M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex) {
+uint16 GroupMan::getCreatureValue(uint16 groupVal, uint16 creatureIndex) {
 	return (groupVal >> (creatureIndex << 1)) & 0x3;
 }
 
-void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode) {
+void GroupMan::dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode) {
 	Group *group = (Group *)_vm->_dungeonMan->getThingData(groupThing);
 	uint16 creatureType = group->_type;
 	if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[creatureType]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
 		int16 creatureIndex = group->getCount();
-		uint16 groupCells = f145_getGroupCells(group, _vm->_dungeonMan->_currMapIndex);
+		uint16 groupCells = getGroupCells(group, _vm->_dungeonMan->_currMapIndex);
 		do {
-			f186_dropCreatureFixedPossessions(creatureType, mapX, mapY,
-				(groupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : M50_getCreatureValue(groupCells, creatureIndex), mode);
+			dropCreatureFixedPossessions(creatureType, mapX, mapY,
+				(groupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : getCreatureValue(groupCells, creatureIndex), mode);
 		} while (creatureIndex--);
 	}
 
@@ -163,7 +163,7 @@ void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThin
 	}
 }
 
-void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int16 mapY, uint16 cell, int16 mode) {
+void GroupMan::dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int16 mapY, uint16 cell, int16 mode) {
 	static uint16 fixedPossessionCreature12Skeleton[3] = { // @ G0245_aui_Graphic559_FixedPossessionsCreature12Skeleton
 		k23_ObjectInfoIndexFirstWeapon + k9_WeaponTypeFalchion,
 		k69_ObjectInfoIndexFirstArmour + k30_ArmourTypeWoodenShield,
@@ -290,7 +290,7 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX
 	_vm->_sound->f064_SOUND_RequestPlay_CPSD(weaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
 }
 
-int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
+int16 GroupMan::getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
 #define AP0483_i_PrimaryDirection srcMapX
 	int16 L0556_i_Direction;
 
@@ -310,9 +310,9 @@ int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 sr
 	}
 	L0556_i_Direction = kDirNorth;
 	for (;;) {
-		if (f227_isDestVisibleFromSource(L0556_i_Direction, srcMapX, srcMapY, destMapX, destMapY)) {
-			if (!f227_isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
-				if ((L0556_i_Direction != kDirNorth) || !f227_isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnPrevVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
+		if (isDestVisibleFromSource(L0556_i_Direction, srcMapX, srcMapY, destMapX, destMapY)) {
+			if (!isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
+				if ((L0556_i_Direction != kDirNorth) || !isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnPrevVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
 					_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + L0556_i_Direction);
 					return L0556_i_Direction;
 				}
@@ -328,7 +328,7 @@ int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 sr
 	}
 }
 
-bool GroupMan::f227_isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
+bool GroupMan::isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
 	int L1637_i_Temp;
 
 	switch (dir) { /* If direction is not 'West' then swap variables so that the same test as for west can be applied */
@@ -359,7 +359,7 @@ bool GroupMan::f227_isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 src
 	return ((srcMapX -= (destMapX - 1)) > 0) && ((((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY) <= srcMapX);
 }
 
-bool GroupMan::f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack, bool magicAttack, int16 ticks) {
+bool GroupMan::groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack, bool magicAttack, int16 ticks) {
 	Door *L0573_ps_Door = (Door *)_vm->_dungeonMan->getSquareFirstThingData(mapX, mapY);
 	if ((magicAttack && !L0573_ps_Door->isMagicDestructible()) || (!magicAttack && !L0573_ps_Door->isMeleeDestructible())) {
 		return false;
@@ -384,7 +384,7 @@ bool GroupMan::f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16
 	return false;
 }
 
-Thing GroupMan::f175_groupGetThing(int16 mapX, int16 mapY) {
+Thing GroupMan::groupGetThing(int16 mapX, int16 mapY) {
 	Thing L0317_T_Thing;
 
 	L0317_T_Thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
@@ -394,7 +394,7 @@ Thing GroupMan::f175_groupGetThing(int16 mapX, int16 mapY) {
 	return L0317_T_Thing;
 }
 
-int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex, int16 mapX, int16 mapY, int16 damage, bool notMoving) {
+int16 GroupMan::groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex, int16 mapX, int16 mapY, int16 damage, bool notMoving) {
 	uint16 L0374_ui_Multiple;
 #define AL0374_ui_EventIndex    L0374_ui_Multiple
 #define AL0374_ui_CreatureIndex L0374_ui_Multiple
@@ -421,26 +421,26 @@ int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group *group, uint16 creature
 	if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) /* Lord Chaos cannot be damaged */
 		goto T0190024;
 	if (group->_health[creatureIndex] <= damage) {
-		L0381_ui_GroupCells = f145_getGroupCells(group, _vm->_dungeonMan->_currMapIndex);
-		L0384_ui_Cell = (L0381_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : M50_getCreatureValue(L0381_ui_GroupCells, creatureIndex);
+		L0381_ui_GroupCells = getGroupCells(group, _vm->_dungeonMan->_currMapIndex);
+		L0384_ui_Cell = (L0381_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : getCreatureValue(L0381_ui_GroupCells, creatureIndex);
 		if (!(L0379_ui_CreatureCount = group->getCount())) { /* If there is a single creature in the group */
 			if (notMoving) {
-				f188_dropGroupPossessions(mapX, mapY, f175_groupGetThing(mapX, mapY), k2_soundModePlayOneTickLater);
-				f189_delete(mapX, mapY);
+				dropGroupPossessions(mapX, mapY, groupGetThing(mapX, mapY), k2_soundModePlayOneTickLater);
+				groupDelete(mapX, mapY);
 			}
 			AL0375_ui_Outcome = k2_outcomeKilledAllCreaturesInGroup;
 		} else { /* If there are several creatures in the group */
-			L0382_ui_GroupDirections = f147_getGroupDirections(group, _vm->_dungeonMan->_currMapIndex);
+			L0382_ui_GroupDirections = getGroupDirections(group, _vm->_dungeonMan->_currMapIndex);
 			if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
 				if (notMoving) {
-					f186_dropCreatureFixedPossessions(AL0380_ui_CreatureType, mapX, mapY, L0384_ui_Cell, k2_soundModePlayOneTickLater);
+					dropCreatureFixedPossessions(AL0380_ui_CreatureType, mapX, mapY, L0384_ui_Cell, k2_soundModePlayOneTickLater);
 				} else {
-					_g392_dropMovingCreatureFixedPossessionsCell[_g391_dropMovingCreatureFixedPossCellCount++] = L0384_ui_Cell;
+					_dropMovingCreatureFixedPossessionsCell[_dropMovingCreatureFixedPossCellCount++] = L0384_ui_Cell;
 				}
 			}
 			L0383_B_CurrentMapIsPartyMap = (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex);
 			if (L0383_B_CurrentMapIsPartyMap)
-				L0378_ps_ActiveGroup = &_g375_activeGroups[group->getActiveGroupIndex()];
+				L0378_ps_ActiveGroup = &_activeGroups[group->getActiveGroupIndex()];
 
 			if (group->getBehaviour() == k6_behavior_ATTACK) {
 				L0377_ps_Event = _vm->_timeline->_g370_events;
@@ -474,8 +474,8 @@ int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group *group, uint16 creature
 			for (AL0375_ui_NextCreatureIndex = AL0374_ui_CreatureIndex = creatureIndex; AL0374_ui_CreatureIndex < L0379_ui_CreatureCount; AL0374_ui_CreatureIndex++) {
 				AL0375_ui_NextCreatureIndex++;
 				group->_health[AL0374_ui_CreatureIndex] = group->_health[AL0375_ui_NextCreatureIndex];
-				L0382_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0382_ui_GroupDirections, AL0374_ui_CreatureIndex, M50_getCreatureValue(L0382_ui_GroupDirections, AL0375_ui_NextCreatureIndex));
-				L0381_ui_GroupCells = f178_getGroupValueUpdatedWithCreatureValue(L0381_ui_GroupCells, AL0374_ui_CreatureIndex, M50_getCreatureValue(L0381_ui_GroupCells, AL0375_ui_NextCreatureIndex));
+				L0382_ui_GroupDirections = getGroupValueUpdatedWithCreatureValue(L0382_ui_GroupDirections, AL0374_ui_CreatureIndex, getCreatureValue(L0382_ui_GroupDirections, AL0375_ui_NextCreatureIndex));
+				L0381_ui_GroupCells = getGroupValueUpdatedWithCreatureValue(L0381_ui_GroupCells, AL0374_ui_CreatureIndex, getCreatureValue(L0381_ui_GroupCells, AL0375_ui_NextCreatureIndex));
 				if (L0383_B_CurrentMapIsPartyMap) {
 					L0378_ps_ActiveGroup->_aspect[AL0374_ui_CreatureIndex] = L0378_ps_ActiveGroup->_aspect[AL0375_ui_NextCreatureIndex];
 				}
@@ -505,12 +505,12 @@ T0190024:
 	return k0_outcomeKilledNoCreaturesInGroup;
 }
 
-void GroupMan::f189_delete(int16 mapX, int16 mapY) {
+void GroupMan::groupDelete(int16 mapX, int16 mapY) {
 	Thing L0372_T_GroupThing;
 	Group *L0373_ps_Group;
 
 
-	if ((L0372_T_GroupThing = f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) {
+	if ((L0372_T_GroupThing = groupGetThing(mapX, mapY)) == Thing::_endOfList) {
 		return;
 	}
 	L0373_ps_Group = (Group *)_vm->_dungeonMan->getThingData(L0372_T_GroupThing);
@@ -519,13 +519,13 @@ void GroupMan::f189_delete(int16 mapX, int16 mapY) {
 	_vm->_moveSens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
 	L0373_ps_Group->_nextThing = Thing::_none;
 	if (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) {
-		_g375_activeGroups[L0373_ps_Group->getActiveGroupIndex()]._groupThingIndex = -1;
-		_g377_currActiveGroupCount--;
+		_activeGroups[L0373_ps_Group->getActiveGroupIndex()]._groupThingIndex = -1;
+		_currActiveGroupCount--;
 	}
-	f181_groupDeleteEvents(mapX, mapY);
+	groupDeleteEvents(mapX, mapY);
 }
 
-void GroupMan::f181_groupDeleteEvents(int16 mapX, int16 mapY) {
+void GroupMan::groupDeleteEvents(int16 mapX, int16 mapY) {
 	int16 L0334_i_EventIndex;
 	uint16 L0335_ui_EventType;
 	TimelineEvent *L0336_ps_Event;
@@ -542,13 +542,13 @@ void GroupMan::f181_groupDeleteEvents(int16 mapX, int16 mapY) {
 	}
 }
 
-uint16 GroupMan::f178_getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatreVal) {
+uint16 GroupMan::getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatreVal) {
 	creatreVal &= 0x0003;
 	creatreVal <<= (creatureIndex <<= 1);
 	return creatreVal | (groupVal & ~(3 << creatreVal));
 }
 
-int16 GroupMan::f191_getDamageAllCreaturesOutcome(Group *group, int16 mapX, int16 mapY, int16 attack, bool notMoving) {
+int16 GroupMan::getDamageAllCreaturesOutcome(Group *group, int16 mapX, int16 mapY, int16 attack, bool notMoving) {
 	uint16 L0385_ui_RandomAttack;
 	int16 L0386_i_CreatureIndex;
 	int16 L0387_i_Outcome;
@@ -558,13 +558,13 @@ int16 GroupMan::f191_getDamageAllCreaturesOutcome(Group *group, int16 mapX, int1
 
 	L0388_B_KilledSomeCreatures = false;
 	L0389_B_KilledAllCreatures = true;
-	_g391_dropMovingCreatureFixedPossCellCount = 0;
+	_dropMovingCreatureFixedPossCellCount = 0;
 	if (attack > 0) {
 		L0386_i_CreatureIndex = group->getCount();
 		attack -= (L0385_ui_RandomAttack = (attack >> 3) + 1);
 		L0385_ui_RandomAttack <<= 1;
 		do {
-			L0389_B_KilledAllCreatures = (L0387_i_Outcome = f190_groupGetDamageCreatureOutcome(group, L0386_i_CreatureIndex, mapX, mapY, attack + _vm->getRandomNumber(L0385_ui_RandomAttack), notMoving)) && L0389_B_KilledAllCreatures;
+			L0389_B_KilledAllCreatures = (L0387_i_Outcome = groupGetDamageCreatureOutcome(group, L0386_i_CreatureIndex, mapX, mapY, attack + _vm->getRandomNumber(L0385_ui_RandomAttack), notMoving)) && L0389_B_KilledAllCreatures;
 			L0388_B_KilledSomeCreatures = L0388_B_KilledSomeCreatures || L0387_i_Outcome;
 		} while (L0386_i_CreatureIndex--);
 		if (L0389_B_KilledAllCreatures) {
@@ -579,7 +579,7 @@ int16 GroupMan::f191_getDamageAllCreaturesOutcome(Group *group, int16 mapX, int1
 	}
 }
 
-int16 GroupMan::f192_groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack) {
+int16 GroupMan::groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack) {
 	int16 L0390_i_PoisonResistance;
 
 
@@ -589,7 +589,7 @@ int16 GroupMan::f192_groupGetResistanceAdjustedPoisonAttack(uint16 creatreType,
 	return ((poisonAttack + _vm->getRandomNumber(4)) << 3) / ++L0390_i_PoisonResistance;
 }
 
-void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks) {
+void GroupMan::processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks) {
 	Group *L0444_ps_Group;
 	ActiveGroup *L0445_ps_ActiveGroup;
 	int16 L0446_i_Multiple;
@@ -638,7 +638,7 @@ void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16
 	if ((_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex) && ((AL0446_i_EventType = eventType) != k37_TMEventTypeUpdateBehaviourGroup) && (AL0446_i_EventType != k32_TMEventTypeUpdateAspectGroup) && (AL0446_i_EventType != k38_TMEventTypeUpdateBehaviour_0) && (AL0446_i_EventType != k33_TMEventTypeUpdateAspectCreature_0))
 		goto T0209139_Return;
 	/* If there is no creature at the location specified in the event then the event is ignored */
-	if ((L0449_T_GroupThing = f175_groupGetThing(eventMapX, eventMapY)) == Thing::_endOfList) {
+	if ((L0449_T_GroupThing = groupGetThing(eventMapX, eventMapY)) == Thing::_endOfList) {
 		goto T0209139_Return;
 	}
 	L0444_ps_Group = (Group *)_vm->_dungeonMan->getThingData(L0449_T_GroupThing);
@@ -650,7 +650,7 @@ void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16
 	L0465_s_NextEvent._B._location._mapY = eventMapY;
 	/* If the creature is not on the party map then try and move the creature in a random direction and place a new event 37 in the timeline for the next creature movement */
 	if (_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex) {
-		if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->getRandomNumber(4), false)) { /* BUG0_67 A group that is not on the party map may wrongly move or not move into a teleporter. Normally, a creature type with Wariness >= 10 (Vexirk, Materializer / Zytaz, Demon, Lord Chaos, Red Dragon / Dragon) would only move into a teleporter if the creature type is allowed on the destination map. However, the variable G0380_T_CurrentGroupThing identifying the group is not set before being used by F0139_DUNGEON_IsCreatureAllowedOnMap called by f202_isMovementPossible so the check to see if the creature type is allowed may operate on another creature type and thus return an incorrect result, causing the creature to teleport while it should not, or not to teleport while it should */
+		if (isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->getRandomNumber(4), false)) { /* BUG0_67 A group that is not on the party map may wrongly move or not move into a teleporter. Normally, a creature type with Wariness >= 10 (Vexirk, Materializer / Zytaz, Demon, Lord Chaos, Red Dragon / Dragon) would only move into a teleporter if the creature type is allowed on the destination map. However, the variable G0380_T_CurrentGroupThing identifying the group is not set before being used by F0139_DUNGEON_IsCreatureAllowedOnMap called by f202_isMovementPossible so the check to see if the creature type is allowed may operate on another creature type and thus return an incorrect result, causing the creature to teleport while it should not, or not to teleport while it should */
 			AL0450_i_DestinationMapX = eventMapX;
 			AL0451_i_DestinationMapY = eventMapY;
 			AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
@@ -673,10 +673,10 @@ T0209005_AddEventAndReturn:
 		if (_vm->_gameWon) {
 			goto T0209139_Return;
 		}
-		_g386_fluxCageCount = 0;
-		_g385_fluxCages[0] = 0;
+		_fluxCageCount = 0;
+		_fluxCages[0] = 0;
 	}
-	L0445_ps_ActiveGroup = &_g375_activeGroups[L0444_ps_Group->getActiveGroupIndex()];
+	L0445_ps_ActiveGroup = &_activeGroups[L0444_ps_Group->getActiveGroupIndex()];
 
 	L0462_i_TicksSinceLastMove = (unsigned char)_vm->_gameTime - L0445_ps_ActiveGroup->_lastMoveTime;
 	if (L0462_i_TicksSinceLastMove < 0)
@@ -709,20 +709,20 @@ T0209005_AddEventAndReturn:
 	L0459_i_CreatureSize = getFlag(L0448_s_CreatureInfo._attributes, k0x0003_MaskCreatureInfo_size);
 	AL0450_i_DistanceXToParty = ((AL0446_i_Distance = eventMapX - _vm->_dungeonMan->_partyMapX) < 0) ? -AL0446_i_Distance : AL0446_i_Distance;
 	AL0451_i_DistanceYToParty = ((AL0446_i_Distance = eventMapY - _vm->_dungeonMan->_partyMapY) < 0) ? -AL0446_i_Distance : AL0446_i_Distance;
-	_g378_currentGroupMapX = eventMapX;
-	_g379_currentGroupMapY = eventMapY;
-	_g380_currGroupThing = L0449_T_GroupThing;
-	_g384_groupMovementTestedDirections[0] = 0;
-	_g381_currGroupDistanceToParty = f226_getDistanceBetweenSquares(eventMapX, eventMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
-	_g382_currGroupPrimaryDirToParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
-	_g383_currGroupSecondaryDirToParty = _vm->_projexpl->_g363_secondaryDirToOrFromParty;
+	_currentGroupMapX = eventMapX;
+	_currentGroupMapY = eventMapY;
+	_currGroupThing = L0449_T_GroupThing;
+	_groupMovementTestedDirections[0] = 0;
+	_currGroupDistanceToParty = getDistanceBetweenSquares(eventMapX, eventMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
+	_currGroupPrimaryDirToParty = getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
+	_currGroupSecondaryDirToParty = _vm->_projexpl->_g363_secondaryDirToOrFromParty;
 	L0464_l_NextAspectUpdateTime = 0;
 	L0455_B_CurrentEventTypeIsNotUpdateBehavior = true;
 	if (eventType <= k31_TMEventTypeGroupReactionPartyIsAdjecent) { /* Process Reaction events 29 to 31 */
 		switch (eventType = eventType - k32_TMEventTypeUpdateAspectGroup) {
 		case kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent: /* This event is used when the party bumps into a group or attacks a group physically (not with a spell). It causes the creature behavior to change to attack if it is not already attacking the party or fleeing from target */
 			if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) {
-				f181_groupDeleteEvents(eventMapX, eventMapY);
+				groupDeleteEvents(eventMapX, eventMapY);
 				goto T0209044_SetBehavior6_Attack;
 			}
 			L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
@@ -732,7 +732,7 @@ T0209005_AddEventAndReturn:
 			if ((AL0447_i_Behavior == k6_behavior_ATTACK) || (AL0447_i_Behavior == k5_behavior_FLEE)) /* If the creature is attacking the party or fleeing from the target then there is no reaction */
 				goto T0209139_Return;
 			if ((AL0446_i_Behavior2Or3 = ((AL0447_i_Behavior == k3_behavior_USELESS) || (AL0447_i_Behavior == k2_behavior_USELESS))) || (_vm->getRandomNumber(4))) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances */
-				if (!f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { /* If the group cannot see the party then look in a random direction to try and search for the party */
+				if (!groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { /* If the group cannot see the party then look in a random direction to try and search for the party */
 					L0458_B_SetBehavior7_ApproachAfterReaction = L0453_B_NewGroupDirectionFound = false;
 					goto T0209073_SetDirectionGroup;
 				}
@@ -747,7 +747,7 @@ T0209005_AddEventAndReturn:
 	}
 	if (eventType < k37_TMEventTypeUpdateBehaviourGroup) { /* Process Update Aspect events 32 to 36 */
 		L0465_s_NextEvent._type = eventType + 5;
-		if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+		if (groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
 			if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) {
 				if (getDistance(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, eventMapX, eventMapY) <= 1)
 					goto T0209044_SetBehavior6_Attack;
@@ -759,7 +759,7 @@ T0209005_AddEventAndReturn:
 		}
 		if (AL0447_i_Behavior == k6_behavior_ATTACK) {
 			AL0446_i_CreatureAspectIndex = eventType - k33_TMEventTypeUpdateAspectCreature_0; /* Value -1 for event 32, meaning aspect will be updated for all creatures in the group */
-			L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0446_i_CreatureAspectIndex, getFlag(L0445_ps_ActiveGroup->_aspect[AL0446_i_CreatureAspectIndex], k0x0080_MaskActiveGroupIsAttacking));
+			L0464_l_NextAspectUpdateTime = getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0446_i_CreatureAspectIndex, getFlag(L0445_ps_ActiveGroup->_aspect[AL0446_i_CreatureAspectIndex], k0x0080_MaskActiveGroupIsAttacking));
 			goto T0209136;
 		}
 		if ((AL0450_i_DistanceXToParty > 3) || (AL0451_i_DistanceYToParty > 3)) {
@@ -773,21 +773,21 @@ T0209005_AddEventAndReturn:
 
 		if (eventType == k37_TMEventTypeUpdateBehaviourGroup) { /* Process event 37, Update Group Behavior */
 			if ((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k2_behavior_USELESS) || (AL0447_i_Behavior == k3_behavior_USELESS)) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */
-				L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY);
+				L0452_i_DistanceToVisibleParty = groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY);
 				if (L0452_i_DistanceToVisibleParty) {
 					if ((L0452_i_DistanceToVisibleParty <= (L0448_s_CreatureInfo.getAttackRange())) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) { /* If the creature is in range for attack and on the same row or column as the party on the map */
 T0209044_SetBehavior6_Attack:
 						if (eventType == kM2_TMEventTypeCreateReactionEvent30HitByProjectile) {
-							f181_groupDeleteEvents(eventMapX, eventMapY);
+							groupDeleteEvents(eventMapX, eventMapY);
 						}
 						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
 						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
 						L0444_ps_Group->setBehaviour(k6_behavior_ATTACK);
-						AL0446_i_Direction = _g382_currGroupPrimaryDirToParty;
+						AL0446_i_Direction = _currGroupPrimaryDirToParty;
 						for (AL0447_i_CreatureIndex = L0460_ui_CreatureCount; AL0447_i_CreatureIndex >= 0; AL0447_i_CreatureIndex--) {
-							if ((M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) != AL0446_i_Direction) &&
+							if ((getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) != AL0446_i_Direction) &&
 								((!AL0447_i_CreatureIndex) || (!_vm->getRandomNumber(2)))) {
-								f205_setDirection(L0445_ps_ActiveGroup, AL0446_i_Direction, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
+								setGroupDirection(L0445_ps_ActiveGroup, AL0446_i_Direction, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
 								M32_setTime(L0465_s_NextEvent._mapTime, _vm->_gameTime + _vm->getRandomNumber(4) + 2); /* Random delay represents the time for the creature to turn */
 							} else {
 								M32_setTime(L0465_s_NextEvent._mapTime, _vm->_gameTime + 1);
@@ -796,7 +796,7 @@ T0209044_SetBehavior6_Attack:
 								L0465_s_NextEvent._mapTime += MIN((uint16)((L0448_s_CreatureInfo._attackTicks >> 1) + _vm->getRandomNumber(4)), ticks);
 							}
 							L0465_s_NextEvent._type = k38_TMEventTypeUpdateBehaviour_0 + AL0447_i_CreatureIndex;
-							f208_groupAddEvent(&L0465_s_NextEvent, f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false));
+							addGroupEvent(&L0465_s_NextEvent, getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false));
 						}
 						goto T0209139_Return;
 					}
@@ -810,7 +810,7 @@ T0209054_SetBehavior7_Approach:
 					}
 				} else {
 					if (AL0447_i_Behavior == k0_behavior_WANDER) {
-						L0454_i_PrimaryDirectionToOrFromParty = f201_getSmelledPartyPrimaryDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY);
+						L0454_i_PrimaryDirectionToOrFromParty = getSmelledPartyPrimaryDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY);
 						if (L0454_i_PrimaryDirectionToOrFromParty) {
 							L0454_i_PrimaryDirectionToOrFromParty--;
 							L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = false;
@@ -829,7 +829,7 @@ T0209058_MoveInRandomDirection:
 								if (((L0445_ps_ActiveGroup->_priorMapX != AL0450_i_DestinationMapX) ||
 									(L0445_ps_ActiveGroup->_priorMapY != AL0451_i_DestinationMapY) ||
 									 (L0457_B_MoveToPriorLocation = !_vm->getRandomNumber(4))) /* 1/4 chance of moving back to the square that the creature comes from */
-									&& f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction, false)) {
+									&& isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction, false)) {
 T0209061_MoveGroup:
 									AL0447_i_Ticks = (L0461_i_MovementTicks >> 1) - L0462_i_TicksSinceLastMove;
 									L0453_B_NewGroupDirectionFound = (AL0447_i_Ticks <= 0);
@@ -847,10 +847,10 @@ T0209061_MoveGroup:
 									}
 									break;
 								}
-								if (_g390_groupMovementBlockedByParty) {
+								if (_groupMovementBlockedByParty) {
 									if ((eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) &&
 										((L0444_ps_Group->getBehaviour() != k5_behavior_FLEE) ||
-										 !f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false) ||
+										 !getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false) ||
 										 _vm->getRandomNumber(2)))
 										goto T0209044_SetBehavior6_Attack;
 									L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
@@ -870,7 +870,7 @@ T0209073_SetDirectionGroup:
 							if (!L0453_B_NewGroupDirectionFound && (L0462_i_TicksSinceLastMove >= 0)) { /* If direction is not found yet then look around in a random direction */
 								AL0446_i_Direction = _vm->getRandomNumber(4);
 							}
-							f206_groupSetDirGroup(L0445_ps_ActiveGroup, AL0446_i_Direction, L0460_ui_CreatureCount, L0459_i_CreatureSize);
+							setDirGroup(L0445_ps_ActiveGroup, AL0446_i_Direction, L0460_ui_CreatureCount, L0459_i_CreatureSize);
 						}
 						/* If event is kM3_TMEventTypeCreateReactionEvent29DangerOnSquare or kM2_TMEventTypeCreateReactionEvent30HitByProjectile */
 						if (eventType < kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) {
@@ -879,13 +879,13 @@ T0209073_SetDirectionGroup:
 							if (L0458_B_SetBehavior7_ApproachAfterReaction)
 								L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
 
-							f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+							stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
 						}
 					}
 				}
 			} else {
 				if (AL0447_i_Behavior == k7_behavior_APPROACH) {
-					L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY);
+					L0452_i_DistanceToVisibleParty = groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY);
 					if (L0452_i_DistanceToVisibleParty) {
 						if ((L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.getAttackRange()) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) /* If the creature is in range for attack and on the same row or column as the party on the map */
 							goto T0209044_SetBehavior6_Attack;
@@ -907,12 +907,12 @@ T0209082_WalkTowardTarget:
 					}
 					L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true;
 T0209084_SingleSquareMoveTowardParty:
-					L0454_i_PrimaryDirectionToOrFromParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY);
+					L0454_i_PrimaryDirectionToOrFromParty = getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY);
 T0209085_SingleSquareMove:
-					if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls) ||
-						f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls && _vm->getRandomNumber(2)) ||
-						f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)AL0446_i_Direction), false) ||
-						(!_vm->getRandomNumber(4) && f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)L0454_i_PrimaryDirectionToOrFromParty), false))) {
+					if (isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls) ||
+						isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls && _vm->getRandomNumber(2)) ||
+						isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)AL0446_i_Direction), false) ||
+						(!_vm->getRandomNumber(4) && isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)L0454_i_PrimaryDirectionToOrFromParty), false))) {
 						AL0450_i_DestinationMapX = eventMapX;
 						AL0451_i_DestinationMapY = eventMapY;
 						AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
@@ -920,11 +920,11 @@ T0209085_SingleSquareMove:
 					}
 					if (L0463_B_Archenemy) {
 T0209089_DoubleSquareMove:
-						f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false); /* BUG0_00 Useless code. Returned value is ignored. When Lord Chaos teleports two squares away the ability to move to the first square is ignored which means Lord Chaos can teleport through walls or any other obstacle */
-						if (f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty) ||
-							f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty) ||
-							(_g386_fluxCageCount && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)AL0446_i_Direction))) ||
-							((_g386_fluxCageCount >= 2) && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)L0454_i_PrimaryDirectionToOrFromParty)))) {
+						getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false); /* BUG0_00 Useless code. Returned value is ignored. When Lord Chaos teleports two squares away the ability to move to the first square is ignored which means Lord Chaos can teleport through walls or any other obstacle */
+						if (isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty) ||
+							isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty) ||
+							(_fluxCageCount && isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)AL0446_i_Direction))) ||
+							((_fluxCageCount >= 2) && isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)L0454_i_PrimaryDirectionToOrFromParty)))) {
 							AL0450_i_DestinationMapX = eventMapX;
 							AL0451_i_DestinationMapY = eventMapY;
 							AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2;
@@ -932,13 +932,13 @@ T0209089_DoubleSquareMove:
 							goto T0209061_MoveGroup;
 						}
 					}
-					f206_groupSetDirGroup(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, L0460_ui_CreatureCount, L0459_i_CreatureSize);
+					setDirGroup(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, L0460_ui_CreatureCount, L0459_i_CreatureSize);
 				} else {
 					if (AL0447_i_Behavior == k5_behavior_FLEE) {
 T0209094_FleeFromTarget:
 						L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true;
 						/* If the creature can see the party then update target coordinates */
-						L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY);
+						L0452_i_DistanceToVisibleParty = groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY);
 						if (L0452_i_DistanceToVisibleParty) {
 							AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX);
 							AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY);
@@ -951,7 +951,7 @@ T0209096_SetBehavior0_Wander:
 							}
 							if (_vm->getRandomNumber(2)) {
 								/* If the creature cannot move and the party is adjacent then stop fleeing */
-								if (!f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false)) {
+								if (!getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false)) {
 									if (getDistance(eventMapX, eventMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY) <= 1)
 										goto T0209096_SetBehavior0_Wander;
 								}
@@ -964,7 +964,7 @@ T0209096_SetBehavior0_Wander:
 							AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY;
 						}
 						/* Try and flee from the party (opposite direction) */
-						L0454_i_PrimaryDirectionToOrFromParty = returnOppositeDir((Direction)f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY));
+						L0454_i_PrimaryDirectionToOrFromParty = returnOppositeDir((Direction)getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY));
 						_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnOppositeDir((Direction)_vm->_projexpl->_g363_secondaryDirToOrFromParty);
 						L0461_i_MovementTicks -= (L0461_i_MovementTicks >> 2);
 						goto T0209085_SingleSquareMove;
@@ -974,13 +974,13 @@ T0209096_SetBehavior0_Wander:
 		} else { /* Process events 38 to 41, Update Creature Behavior */
 			if (AL0447_i_Behavior == k5_behavior_FLEE) {
 				if (L0460_ui_CreatureCount) {
-					f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+					stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
 				}
 				goto T0209094_FleeFromTarget;
 			}
 			/* If the creature is attacking, then compute the next aspect update time and the next attack time */
 			if (getFlag(L0445_ps_ActiveGroup->_aspect[AL0447_i_CreatureIndex = eventType - k38_TMEventTypeUpdateBehaviour_0], k0x0080_MaskActiveGroupIsAttacking)) {
-				L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false);
+				L0464_l_NextAspectUpdateTime = getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false);
 				L0465_s_NextEvent._mapTime += ((AL0447_i_Ticks = L0448_s_CreatureInfo._attackTicks) + _vm->getRandomNumber(4) - 1);
 				if (AL0447_i_Ticks > 15)
 					L0465_s_NextEvent._mapTime += _vm->getRandomNumber(8) - 2;
@@ -988,8 +988,8 @@ T0209096_SetBehavior0_Wander:
 				if (AL0447_i_CreatureIndex > L0460_ui_CreatureCount) /* Ignore event if it is for a creature that is not in the group */
 					goto T0209139_Return;
 
-				L0454_i_PrimaryDirectionToOrFromParty = _g382_currGroupPrimaryDirToParty;
-				L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, AL0447_i_CreatureIndex, eventMapX, eventMapY);
+				L0454_i_PrimaryDirectionToOrFromParty = _currGroupPrimaryDirToParty;
+				L0452_i_DistanceToVisibleParty = groupGetDistanceToVisibleParty(L0444_ps_Group, AL0447_i_CreatureIndex, eventMapX, eventMapY);
 				/* If the party is visible, update the target coordinates */
 				if (L0452_i_DistanceToVisibleParty) {
 					L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
@@ -1015,7 +1015,7 @@ T0209096_SetBehavior0_Wander:
 				/* If the creature can see the party and is looking in the party direction or can attack in all direction */
 				if (L0452_i_DistanceToVisibleParty &&
 					(getFlag(L0448_s_CreatureInfo._attributes, k0x0004_MaskCreatureInfo_sideAttack) ||
-					 M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) == L0454_i_PrimaryDirectionToOrFromParty)) {
+					 getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) == L0454_i_PrimaryDirectionToOrFromParty)) {
 					/* If the creature is in range to attack the party and random test succeeds */
 					if ((L0452_i_DistanceToVisibleParty <= (AL0446_i_Range = L0448_s_CreatureInfo.getAttackRange())) &&
 						(!AL0450_i_DistanceXToParty || !AL0451_i_DistanceYToParty) &&
@@ -1024,7 +1024,7 @@ T0209096_SetBehavior0_Wander:
 							(!getFlag(AL0446_i_CreatureAttributes = L0448_s_CreatureInfo._attributes, k0x0008_MaskCreatureInfo_preferBackRow) || !_vm->getRandomNumber(4) || !getFlag(AL0446_i_CreatureAttributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) &&
 							(L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter) &&
 							(L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) &&
-							((AL0446_i_Cell = M50_getCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex)) != L0454_i_PrimaryDirectionToOrFromParty) &&
+							((AL0446_i_Cell = getCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex)) != L0454_i_PrimaryDirectionToOrFromParty) &&
 							(AL0446_i_Cell != returnNextVal(L0454_i_PrimaryDirectionToOrFromParty))) { /* If the creature cannot cast spells (range = 1) and is not on a cell where it can attack the party directly and is a quarter square sized creature not in the center of the square then the creature moves to another cell and attack does not occur immediately */
 							if (!L0460_ui_CreatureCount && _vm->getRandomNumber(2)) {
 								L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature;
@@ -1034,12 +1034,12 @@ T0209096_SetBehavior0_Wander:
 								} else {
 									AL0446_i_Cell++;
 								}
-								if (!f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = normalizeModulo4(AL0446_i_Cell)) ||
-									(_vm->getRandomNumber(2) && !f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((Direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */
+								if (!getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = normalizeModulo4(AL0446_i_Cell)) ||
+									(_vm->getRandomNumber(2) && !getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((Direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */
 									if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* BUG0_70 A projectile impact on a creature may be ignored. The function F0218_PROJECTILE_GetImpactCount to detect projectile impacts when a quarter square sized creature moves inside a group (to another cell on the same square) may fail if there are several creatures in the group because the function expects a single cell index for its last parameter. The function should be called once for each cell where there is a creature */
 										goto T0209139_Return;
 									if (_vm->_projexpl->_g364_creatureDamageOutcome != k1_outcomeKilledSomeCreaturesInGroup) {
-										L0445_ps_ActiveGroup->_cells = f178_getGroupValueUpdatedWithCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex, AL0446_i_Cell);
+										L0445_ps_ActiveGroup->_cells = getGroupValueUpdatedWithCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex, AL0446_i_Cell);
 									}
 								}
 							}
@@ -1047,27 +1047,27 @@ T0209096_SetBehavior0_Wander:
 							L0465_s_NextEvent._type = eventType;
 							goto T0209135;
 						}
-						L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, f207_isCreatureAttacking(L0444_ps_Group, eventMapX, eventMapY, AL0447_i_CreatureIndex));
+						L0464_l_NextAspectUpdateTime = getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, isCreatureAttacking(L0444_ps_Group, eventMapX, eventMapY, AL0447_i_CreatureIndex));
 						L0465_s_NextEvent._mapTime += (L0448_s_CreatureInfo._animationTicks & 0xF) + _vm->getRandomNumber(2);
 					} else {
 						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
 						if (L0460_ui_CreatureCount) {
-							f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+							stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
 						}
 						goto T0209081_RunTowardParty;
 					}
 				} else {
 					/* If the party is visible, update target coordinates */
-					if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+					if (groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
 						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
 						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
-						f205_setDirection(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
+						setGroupDirection(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
 						L0465_s_NextEvent._mapTime += 2;
 						L0464_l_NextAspectUpdateTime = filterTime(L0465_s_NextEvent._mapTime);
 					} else { /* If the party is not visible, move to the target (last known party location) */
 						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
 						if (L0460_ui_CreatureCount) {
-							f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+							stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
 						}
 						goto T0209082_WalkTowardTarget;
 					}
@@ -1082,7 +1082,7 @@ T0209134_SetEvent37:
 	}
 T0209135:
 	if (!L0464_l_NextAspectUpdateTime) {
-		L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, kM1_wholeCreatureGroup, false);
+		L0464_l_NextAspectUpdateTime = getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, kM1_wholeCreatureGroup, false);
 	}
 T0209136:
 	if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) {
@@ -1090,12 +1090,12 @@ T0209136:
 	} else {
 		L0464_l_NextAspectUpdateTime += ticks;
 	}
-	f208_groupAddEvent(&L0465_s_NextEvent, L0464_l_NextAspectUpdateTime);
+	addGroupEvent(&L0465_s_NextEvent, L0464_l_NextAspectUpdateTime);
 T0209139_Return:
 	;
 }
 
-bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, int16 mapY, uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls) {
+bool GroupMan::isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, int16 mapY, uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls) {
 	int16 L0428_i_MapX;
 	int16 L0429_i_MapY;
 	uint16 L0430_ui_Square = 0;
@@ -1103,10 +1103,10 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 	Teleporter *L0432_ps_Teleporter;
 	Thing L0433_T_Thing;
 
-	_g384_groupMovementTestedDirections[dir] = true;
-	_g388_groupMovementBlockedByGroupThing = Thing::_endOfList;
-	_g389_groupMovementBlockedByDoor = false;
-	_g390_groupMovementBlockedByParty = false;
+	_groupMovementTestedDirections[dir] = true;
+	_groupMovementBlockedByGroupThing = Thing::_endOfList;
+	_groupMovementBlockedByDoor = false;
+	_groupMovementBlockedByParty = false;
 	if (creatureInfo->_movementTicks == k255_immobile) {
 		return false;
 	}
@@ -1115,7 +1115,7 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 	L0429_i_MapY = mapY;
 	L0430_ui_Square = _vm->_dungeonMan->_currMapData[L0428_i_MapX][L0429_i_MapY];
 	L0431_i_SquareType = Square(L0430_ui_Square).getType();
-	_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter =
+	_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter =
 		!(((L0428_i_MapX >= 0) && (L0428_i_MapX < _vm->_dungeonMan->_currMapWidth)) &&
 		 ((L0429_i_MapY >= 0) && (L0429_i_MapY < _vm->_dungeonMan->_currMapHeight)) &&
 		  (L0431_i_SquareType != k0_ElementTypeWall) &&
@@ -1123,7 +1123,7 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 		 ((L0431_i_SquareType != k2_ElementTypePit) || (getFlag(L0430_ui_Square, k0x0001_PitImaginary) && allowMovementOverImaginaryPitsAndFakeWalls) || !getFlag(L0430_ui_Square, k0x0008_PitOpen) || getFlag(creatureInfo->_attributes, k0x0020_MaskCreatureInfo_levitation)) &&
 		 ((L0431_i_SquareType != k6_ElementTypeFakeWall) || getFlag(L0430_ui_Square, k0x0004_FakeWallOpen) || (getFlag(L0430_ui_Square, k0x0001_FakeWallImaginary) && allowMovementOverImaginaryPitsAndFakeWalls)));
 
-	if (_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter)
+	if (_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter)
 		return false;
 
 	if (getFlag(creatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) {
@@ -1132,9 +1132,9 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 			if ((L0433_T_Thing).getType() == k15_ExplosionThingType) {
 				L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(L0433_T_Thing);
 				if (((Explosion *)L0432_ps_Teleporter)->setType(k50_ExplosionType_Fluxcage)) {
-					_g385_fluxCages[dir] = true;
-					_g386_fluxCageCount++;
-					_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
+					_fluxCages[dir] = true;
+					_fluxCageCount++;
+					_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
 					return false;
 				}
 			}
@@ -1143,32 +1143,32 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i
 	}
 	if ((L0431_i_SquareType == k5_ElementTypeTeleporter) && getFlag(L0430_ui_Square, k0x0008_TeleporterOpen) && (creatureInfo->getWariness() >= 10)) {
 		L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
-		if (getFlag(L0432_ps_Teleporter->getScope(), k0x0001_TelepScopeCreatures) && !_vm->_dungeonMan->isCreatureAllowedOnMap(_g380_currGroupThing, L0432_ps_Teleporter->getTargetMapIndex())) {
-			_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
+		if (getFlag(L0432_ps_Teleporter->getScope(), k0x0001_TelepScopeCreatures) && !_vm->_dungeonMan->isCreatureAllowedOnMap(_currGroupThing, L0432_ps_Teleporter->getTargetMapIndex())) {
+			_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
 			return false;
 		}
 	}
 
-	_g390_groupMovementBlockedByParty = (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0428_i_MapX == _vm->_dungeonMan->_partyMapX) && (L0429_i_MapY == _vm->_dungeonMan->_partyMapY);
-	if (_g390_groupMovementBlockedByParty)
+	_groupMovementBlockedByParty = (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0428_i_MapX == _vm->_dungeonMan->_partyMapX) && (L0429_i_MapY == _vm->_dungeonMan->_partyMapY);
+	if (_groupMovementBlockedByParty)
 		return false;
 
 	if (L0431_i_SquareType == k4_DoorElemType) {
 		L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
 		if (((Square(L0430_ui_Square).getDoorState()) > (((Door *)L0432_ps_Teleporter)->opensVertically() ? CreatureInfo::getHeight(creatureInfo->_attributes) : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
-			_g389_groupMovementBlockedByDoor = true;
+			_groupMovementBlockedByDoor = true;
 			return false;
 		}
 	}
-	return (_g388_groupMovementBlockedByGroupThing = f175_groupGetThing(L0428_i_MapX, L0429_i_MapY)) == Thing::_endOfList;
+	return (_groupMovementBlockedByGroupThing = groupGetThing(L0428_i_MapX, L0429_i_MapY)) == Thing::_endOfList;
 }
 
-int16 GroupMan::f226_getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
+int16 GroupMan::getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
 	return ((((srcMapX -= destMapX) < 0) ? -srcMapX : srcMapX) +
 		(((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY));
 }
 
-int16 GroupMan::f200_groupGetDistanceToVisibleParty(Group *group, int16 creatureIndex, int16 mapX, int16 mapY) {
+int16 GroupMan::groupGetDistanceToVisibleParty(Group *group, int16 creatureIndex, int16 mapX, int16 mapY) {
 	int16 L0420_i_CreatureDirection;
 	int16 L0421_i_CreatureViewDirectionCount; /* Count of directions to test in L0425_ai_CreatureViewDirections */
 	int16 L0422_i_Multiple;
@@ -1185,7 +1185,7 @@ int16 GroupMan::f200_groupGetDistanceToVisibleParty(Group *group, int16 creature
 	}
 	if (getFlag(L0424_ps_CreatureInfo->_attributes, k0x0004_MaskCreatureInfo_sideAttack)) /* If creature can see in all directions */
 		goto T0200011;
-	L0423_ui_GroupDirections = _g375_activeGroups[group->getActiveGroupIndex()]._directions;
+	L0423_ui_GroupDirections = _activeGroups[group->getActiveGroupIndex()]._directions;
 	if (creatureIndex < 0) { /* Negative index means test if each creature in the group can see the party in their respective direction */
 		L0421_i_CreatureViewDirectionCount = 0;
 		for (creatureIndex = group->getCount(); creatureIndex >= 0; creatureIndex--) {
@@ -1200,26 +1200,26 @@ T0200006:
 			;
 		}
 	} else { /* Positive index means test only if the specified creature in the group can see the party in its direction */
-		L0425_ai_CreatureViewDirections[0] = M50_getCreatureValue(L0423_ui_GroupDirections, creatureIndex);
+		L0425_ai_CreatureViewDirections[0] = getCreatureValue(L0423_ui_GroupDirections, creatureIndex);
 		L0421_i_CreatureViewDirectionCount = 1;
 	}
 	while (L0421_i_CreatureViewDirectionCount--) {
-		if (f227_isDestVisibleFromSource(L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount], mapX, mapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY)) {
+		if (isDestVisibleFromSource(L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount], mapX, mapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY)) {
 T0200011:
 			AL0422_i_SightRange = L0424_ps_CreatureInfo->getSightRange();
 			if (!getFlag(L0424_ps_CreatureInfo->_attributes, k0x1000_MaskCreatureInfo_nightVision)) {
 				AL0422_i_SightRange -= _vm->_displayMan->_dungeonViewPaletteIndex >> 1;
 			}
-			if (_g381_currGroupDistanceToParty > MAX((int16)1, AL0422_i_SightRange)) {
+			if (_currGroupDistanceToParty > MAX((int16)1, AL0422_i_SightRange)) {
 				return 0;
 			}
-			return f199_getDistanceBetweenUnblockedSquares(mapX, mapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, &GroupMan::f197_isViewPartyBlocked);
+			return getDistanceBetweenUnblockedSquares(mapX, mapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, &GroupMan::isViewPartyBlocked);
 		}
 	}
 	return 0;
 }
 
-int16 GroupMan::f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 srcMapY,
+int16 GroupMan::getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 srcMapY,
 														int16 destMapX, int16 destMapY, bool (GroupMan::*isBlocked)(uint16, uint16)) {
 	int16 L0410_i_XAxisStep;
 	int16 L0411_i_YAxisStep;
@@ -1263,10 +1263,10 @@ int16 GroupMan::f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 src
 			}
 		}
 	} while (getDistance(AL0412_i_PathMapX, AL0413_i_PathMapY, srcMapX, srcMapY) > 1);
-	return f226_getDistanceBetweenSquares(srcMapX, srcMapY, destMapX, destMapY);
+	return getDistanceBetweenSquares(srcMapX, srcMapY, destMapX, destMapY);
 }
 
-bool GroupMan::f197_isViewPartyBlocked(uint16 mapX, uint16 mapY) {
+bool GroupMan::isViewPartyBlocked(uint16 mapX, uint16 mapY) {
 	uint16 L0404_ui_Square = _vm->_dungeonMan->_currMapData[mapX][mapY];
 	int16 L0405_i_SquareType = Square(L0404_ui_Square).getType();
 	if (L0405_i_SquareType == k4_DoorElemType) {
@@ -1277,7 +1277,7 @@ bool GroupMan::f197_isViewPartyBlocked(uint16 mapX, uint16 mapY) {
 	return (L0405_i_SquareType == k0_ElementTypeWall) || ((L0405_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0404_ui_Square, k0x0004_FakeWallOpen));
 }
 
-int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 creatureIndex, bool isAttacking) {
+int32 GroupMan::getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 creatureIndex, bool isAttacking) {
 	uint16 L0326_ui_Multiple;
 #define AL0326_ui_Aspect         L0326_ui_Multiple
 #define AL0326_ui_AnimationTicks L0326_ui_Multiple
@@ -1319,7 +1319,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 				if (getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) && (L0331_ui_CreatureType == k18_CreatureTypeAnimatedArmourDethKnight)) {
 					if (_vm->getRandomNumber(2)) {
 						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-						_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized);
+						_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _currentGroupMapX, _currentGroupMapY, k1_soundModePlayIfPrioritized);
 					}
 				} else if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) {
 					if (_vm->getRandomNumber(2))
@@ -1338,7 +1338,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
 						L1635_ui_SoundIndex = _vm->_moveSens->f514_getSound(k13_CreatureTypeCouatl);
 						if (L1635_ui_SoundIndex <= k34_D13_soundCount)
-							_vm->_sound->f064_SOUND_RequestPlay_CPSD(L1635_ui_SoundIndex, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized);
+							_vm->_sound->f064_SOUND_RequestPlay_CPSD(L1635_ui_SoundIndex, _currentGroupMapX, _currentGroupMapY, k1_soundModePlayIfPrioritized);
 					}
 				} else if (_vm->getRandomNumber(2))
 					setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
@@ -1355,29 +1355,29 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16
 	return _vm->_gameTime + (isAttacking ? ((AL0326_ui_AnimationTicks >> 8) & 0xF) : ((AL0326_ui_AnimationTicks >> 4) & 0xF)) + _vm->getRandomNumber(2);
 }
 
-void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) {
+void GroupMan::setGroupDirection(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) {
 	uint16 L0435_ui_GroupDirections;
 	static ActiveGroup *G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup;
 
-	if (twoHalfSquareSizedCreatures && (_vm->_gameTime == _g395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) {
+	if (twoHalfSquareSizedCreatures && (_vm->_gameTime == twoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) {
 		return;
 	}
 	L0435_ui_GroupDirections = activeGroup->_directions;
-	if (normalizeModulo4(M50_getCreatureValue(L0435_ui_GroupDirections, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */
+	if (normalizeModulo4(getCreatureValue(L0435_ui_GroupDirections, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */
 		dir = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + dir);
-		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir);
+		L0435_ui_GroupDirections = getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir);
 	} else {
-		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir);
+		L0435_ui_GroupDirections = getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir);
 	}
 	if (twoHalfSquareSizedCreatures) {
-		L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex ^ 1, dir); /* Set direction of the second half square sized creature */
-		_g395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime = _vm->_gameTime;
+		L0435_ui_GroupDirections = getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex ^ 1, dir); /* Set direction of the second half square sized creature */
+		twoHalfSquareSizedCreaturesGroupLastDirectionSetTime = _vm->_gameTime;
 		G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup = activeGroup;
 	}
 	activeGroup->_directions = (Direction)L0435_ui_GroupDirections;
 }
 
-void GroupMan::f208_groupAddEvent(TimelineEvent *event, uint32 time) {
+void GroupMan::addGroupEvent(TimelineEvent *event, uint32 time) {
 	warning(false, "potentially dangerous cast to uint32 below");
 	if (time < (uint32)filterTime(event->_mapTime)) {
 		event->_type -= 5;
@@ -1389,7 +1389,7 @@ void GroupMan::f208_groupAddEvent(TimelineEvent *event, uint32 time) {
 	_vm->_timeline->f238_addEventGetEventIndex(event);
 }
 
-int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo, int16 mapY, int16 mapX) {
+int16 GroupMan::getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo, int16 mapY, int16 mapX) {
 
 	uint16 L0426_ui_SmellRange;
 	int16 L0427_i_ScentOrdinal;
@@ -1398,36 +1398,36 @@ int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo
 	if (!(L0426_ui_SmellRange = creatureInfo->getSmellRange())) {
 		return 0;
 	}
-	if ((((L0426_ui_SmellRange + 1) >> 1) >= _g381_currGroupDistanceToParty) && f199_getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, &GroupMan::f198_isSmellPartyBlocked)) {
-		_vm->_projexpl->_g363_secondaryDirToOrFromParty = _g383_currGroupSecondaryDirToParty;
-		return _vm->indexToOrdinal(_g382_currGroupPrimaryDirToParty);
+	if ((((L0426_ui_SmellRange + 1) >> 1) >= _currGroupDistanceToParty) && getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, &GroupMan::isSmellPartyBlocked)) {
+		_vm->_projexpl->_g363_secondaryDirToOrFromParty = _currGroupSecondaryDirToParty;
+		return _vm->indexToOrdinal(_currGroupPrimaryDirToParty);
 	}
 	if ((L0427_i_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapY, mapX)) && ((_vm->_championMan->_party._scentStrengths[_vm->ordinalToIndex(L0427_i_ScentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (L0426_ui_SmellRange << 1)))) { /* If there is a fresh enough party scent on the group square */
-		return _vm->indexToOrdinal(f228_getDirsWhereDestIsVisibleFromSource(mapY, mapX, _vm->_championMan->_party._scents[L0427_i_ScentOrdinal].getMapX(), _vm->_championMan->_party._scents[L0427_i_ScentOrdinal].getMapY()));
+		return _vm->indexToOrdinal(getDirsWhereDestIsVisibleFromSource(mapY, mapX, _vm->_championMan->_party._scents[L0427_i_ScentOrdinal].getMapX(), _vm->_championMan->_party._scents[L0427_i_ScentOrdinal].getMapY()));
 	}
 	return 0;
 }
 
-bool GroupMan::f198_isSmellPartyBlocked(uint16 mapX, uint16 mapY) {
+bool GroupMan::isSmellPartyBlocked(uint16 mapX, uint16 mapY) {
 	uint16 L0408_ui_Square;
 	int16 L0409_i_SquareType;
 
 	return ((L0409_i_SquareType = Square(L0408_ui_Square = _vm->_dungeonMan->_currMapData[mapX][mapY]).getType()) == k0_ElementTypeWall) || ((L0409_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0408_ui_Square, k0x0004_FakeWallOpen));
 }
 
-int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo *info, int16 mapX, int16 mapY, bool allowMovementOverImaginaryPitsAndFakeWalls) {
+int16 GroupMan::getFirstPossibleMovementDirOrdinal(CreatureInfo *info, int16 mapX, int16 mapY, bool allowMovementOverImaginaryPitsAndFakeWalls) {
 	int16 L0434_i_Direction;
 
 
 	for (L0434_i_Direction = kDirNorth; L0434_i_Direction <= kDirWest; L0434_i_Direction++) {
-		if ((!_g384_groupMovementTestedDirections[L0434_i_Direction]) && f202_isMovementPossible(info, mapX, mapY, L0434_i_Direction, allowMovementOverImaginaryPitsAndFakeWalls)) {
+		if ((!_groupMovementTestedDirections[L0434_i_Direction]) && isMovementPossible(info, mapX, mapY, L0434_i_Direction, allowMovementOverImaginaryPitsAndFakeWalls)) {
 			return _vm->indexToOrdinal(L0434_i_Direction);
 		}
 	}
 	return 0;
 }
 
-void GroupMan::f206_groupSetDirGroup(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, int16 creatureSize) {
+void GroupMan::setDirGroup(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, int16 creatureSize) {
 	bool L0436_B_TwoHalfSquareSizedCreatures = creatureIndex && (creatureSize == k1_MaskCreatureSizeHalf);
 
 	if (L0436_B_TwoHalfSquareSizedCreatures)
@@ -1435,27 +1435,27 @@ void GroupMan::f206_groupSetDirGroup(ActiveGroup *activeGroup, int16 dir, int16
 
 	do {
 		if (!creatureIndex || _vm->getRandomNumber(2))
-			f205_setDirection(activeGroup, dir, creatureIndex, L0436_B_TwoHalfSquareSizedCreatures);
+			setGroupDirection(activeGroup, dir, creatureIndex, L0436_B_TwoHalfSquareSizedCreatures);
 	} while (creatureIndex--);
 }
 
-void GroupMan::f182_stopAttacking(ActiveGroup *group, int16 mapX, int16 mapY) {
+void GroupMan::stopAttacking(ActiveGroup *group, int16 mapX, int16 mapY) {
 	int16 L0337_i_CreatureIndex;
 
 	for (L0337_i_CreatureIndex = 0; L0337_i_CreatureIndex < 4; clearFlag(group->_aspect[L0337_i_CreatureIndex++], k0x0080_MaskActiveGroupIsAttacking));
-	f181_groupDeleteEvents(mapX, mapY);
+	groupDeleteEvents(mapX, mapY);
 
 }
 
-bool GroupMan::f204_isArchenemyDoubleMovementPossible(CreatureInfo *info, int16 mapX, int16 mapY, uint16 dir) {
-	if (_g385_fluxCages[dir]) {
+bool GroupMan::isArchenemyDoubleMovementPossible(CreatureInfo *info, int16 mapX, int16 mapY, uint16 dir) {
+	if (_fluxCages[dir]) {
 		return false;
 	}
 	mapX += _vm->_dirIntoStepCountEast[dir], mapY += _vm->_dirIntoStepCountNorth[dir];
-	return f202_isMovementPossible(info, mapX, mapY, dir, false);
+	return isMovementPossible(info, mapX, mapY, dir, false);
 }
 
-bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 creatureIndex) {
+bool GroupMan::isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 creatureIndex) {
 	static const uint8 G0244_auc_Graphic559_CreatureAttackSounds[11] = { 3, 7, 14, 15, 19, 21, 29, 30, 31, 4, 16 }; /* Atari ST: { 3, 7, 14, 15, 19, 21, 4, 16 } */
 
 	uint16 L0437_ui_Multiple;
@@ -1472,17 +1472,17 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 #define AL0440_i_AttackSoundOrdinal L0440_i_Multiple
 
 	_vm->_projexpl->_g361_lastCreatureAttackTime = _vm->_gameTime;
-	ActiveGroup L0443_s_ActiveGroup = _g375_activeGroups[group->getActiveGroupIndex()];
+	ActiveGroup L0443_s_ActiveGroup = _activeGroups[group->getActiveGroupIndex()];
 	CreatureInfo *L0441_ps_CreatureInfo = &g243_CreatureInfo[AL0437_ui_CreatureType = group->_type];
-	uint16 L0438_ui_PrimaryDirectionToParty = _g382_currGroupPrimaryDirToParty;
+	uint16 L0438_ui_PrimaryDirectionToParty = _currGroupPrimaryDirToParty;
 	if ((AL0439_i_GroupCells = L0443_s_ActiveGroup._cells) == k255_CreatureTypeSingleCenteredCreature) {
 		AL0439_i_TargetCell = _vm->getRandomNumber(2);
 	} else {
-		AL0439_i_TargetCell = ((M50_getCreatureValue(AL0439_i_GroupCells, creatureIndex) + 5 - L0438_ui_PrimaryDirectionToParty) & 0x0002) >> 1;
+		AL0439_i_TargetCell = ((getCreatureValue(AL0439_i_GroupCells, creatureIndex) + 5 - L0438_ui_PrimaryDirectionToParty) & 0x0002) >> 1;
 	}
 	AL0439_i_TargetCell += L0438_ui_PrimaryDirectionToParty;
 	AL0439_i_TargetCell &= 0x0003;
-	if ((L0441_ps_CreatureInfo->getAttackRange() > 1) && ((_g381_currGroupDistanceToParty > 1) || _vm->getRandomNumber(2))) {
+	if ((L0441_ps_CreatureInfo->getAttackRange() > 1) && ((_currGroupDistanceToParty > 1) || _vm->getRandomNumber(2))) {
 		switch (AL0437_ui_CreatureType) {
 		case k14_CreatureTypeVexirk:
 		case k23_CreatureTypeLordChaos:
@@ -1527,7 +1527,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
 		_vm->_sound->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, mapX, mapY, k0_soundModePlayImmediately);
-		_vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (Direction)_g382_currGroupPrimaryDirToParty, getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
+		_vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (Direction)_currGroupPrimaryDirToParty, getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
 	} else {
 		if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) {
 			AL0439_i_ChampionIndex = _vm->getRandomNumber(4);
@@ -1543,9 +1543,9 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 			}
 		}
 		if (AL0437_ui_CreatureType == k2_CreatureTypeGiggler) {
-			f193_stealFromChampion(group, AL0439_i_ChampionIndex);
+			stealFromChampion(group, AL0439_i_ChampionIndex);
 		} else {
-			AL0440_i_Damage = f230_getChampionDamage(group, AL0439_i_ChampionIndex) + 1;
+			AL0440_i_Damage = getChampionDamage(group, AL0439_i_ChampionIndex) + 1;
 			Champion *L0442_ps_Champion = &_vm->_championMan->_champions[AL0439_i_ChampionIndex];
 			if (AL0440_i_Damage > L0442_ps_Champion->_maximumDamageReceived) {
 				L0442_ps_Champion->_maximumDamageReceived = AL0440_i_Damage;
@@ -1560,7 +1560,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui
 	return true;
 }
 
-void GroupMan::f229_setOrderedCellsToAttack(signed char *orderedCellsToAttack, int16 targetMapX, int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource) {
+void GroupMan::setOrderedCellsToAttack(signed char *orderedCellsToAttack, int16 targetMapX, int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource) {
 	static signed char g23_orderedCellsToAttack[8][4] = { // @ G0023_aac_Graphic562_OrderedCellsToAttack
 		{0, 1, 3, 2},   /* Attack South from position Northwest or Southwest */
 		{1, 0, 2, 3},   /* Attack South from position Northeast or Southeast */
@@ -1573,7 +1573,7 @@ void GroupMan::f229_setOrderedCellsToAttack(signed char *orderedCellsToAttack, i
 	uint16 L0557_ui_OrderedCellsToAttackIndex;
 
 
-	if (!((L0557_ui_OrderedCellsToAttackIndex = f228_getDirsWhereDestIsVisibleFromSource(targetMapX, targetMapY, attackerMapX, attackerMapY) << 1) & 0x0002)) {
+	if (!((L0557_ui_OrderedCellsToAttackIndex = getDirsWhereDestIsVisibleFromSource(targetMapX, targetMapY, attackerMapX, attackerMapY) << 1) & 0x0002)) {
 		cellSource++;
 	}
 	L0557_ui_OrderedCellsToAttackIndex += (cellSource >> 1) & 0x0001;
@@ -1581,7 +1581,7 @@ void GroupMan::f229_setOrderedCellsToAttack(signed char *orderedCellsToAttack, i
 		orderedCellsToAttack[i] = g23_orderedCellsToAttack[L0557_ui_OrderedCellsToAttackIndex][i];
 }
 
-void GroupMan::f193_stealFromChampion(Group *group, uint16 championIndex) {
+void GroupMan::stealFromChampion(Group *group, uint16 championIndex) {
 	int16 L0391_i_Percentage;
 	uint16 L0392_ui_StealFromSlotIndex;
 	uint16 L0393_ui_Counter;
@@ -1615,12 +1615,12 @@ void GroupMan::f193_stealFromChampion(Group *group, uint16 championIndex) {
 		L0391_i_Percentage -= 20;
 	}
 	if (!_vm->getRandomNumber(8) || (L0396_B_ObjectStolen && _vm->getRandomNumber(2))) {
-		_g375_activeGroups[group->getActiveGroupIndex()]._delayFleeingFromTarget = _vm->getRandomNumber(64) + 20;
+		_activeGroups[group->getActiveGroupIndex()]._delayFleeingFromTarget = _vm->getRandomNumber(64) + 20;
 		group->setBehaviour(k5_behavior_FLEE);
 	}
 }
 
-int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) {
+int16 GroupMan::getChampionDamage(Group *group, uint16 champIndex) {
 	unsigned char g24_woundProbabilityIndexToWoundMask[4] = {32, 16, 8, 4}; // @ G0024_auc_Graphic562_WoundProbabilityIndexToWoundMask
 
 	Champion *L0562_ps_Champion;
@@ -1694,26 +1694,26 @@ T0230014:
 	return 0;
 }
 
-void GroupMan::f187_dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY) {
+void GroupMan::dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY) {
 	Group *L0363_ps_Group;
 	int16 L0364_i_CreatureType;
 
 
-	if (_g391_dropMovingCreatureFixedPossCellCount) {
+	if (_dropMovingCreatureFixedPossCellCount) {
 		L0363_ps_Group = (Group *)_vm->_dungeonMan->getThingData(thing);
 		L0364_i_CreatureType = L0363_ps_Group->_type;
-		while (_g391_dropMovingCreatureFixedPossCellCount) {
-			f186_dropCreatureFixedPossessions(L0364_i_CreatureType, mapX, mapY, _g392_dropMovingCreatureFixedPossessionsCell[--_g391_dropMovingCreatureFixedPossCellCount], k2_soundModePlayOneTickLater);
+		while (_dropMovingCreatureFixedPossCellCount) {
+			dropCreatureFixedPossessions(L0364_i_CreatureType, mapX, mapY, _dropMovingCreatureFixedPossessionsCell[--_dropMovingCreatureFixedPossCellCount], k2_soundModePlayOneTickLater);
 		}
 	}
 }
 
-void GroupMan::f180_startWanedring(int16 mapX, int16 mapY) {
+void GroupMan::startWanedring(int16 mapX, int16 mapY) {
 	Group *L0332_ps_Group;
 	TimelineEvent L0333_s_Event;
 
 
-	L0332_ps_Group = (Group *)_vm->_dungeonMan->getThingData(f175_groupGetThing(mapX, mapY));
+	L0332_ps_Group = (Group *)_vm->_dungeonMan->getThingData(groupGetThing(mapX, mapY));
 	if (L0332_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
 		L0332_ps_Group->setBehaviour(k0_behavior_WANDER);
 	}
@@ -1726,22 +1726,22 @@ void GroupMan::f180_startWanedring(int16 mapX, int16 mapY) {
 	_vm->_timeline->f238_addEventGetEventIndex(&L0333_s_Event);
 }
 
-void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
+void GroupMan::addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
 	uint16 L0339_ui_CreatureIndex;
 	Group *L0340_ps_Group;
 	ActiveGroup *L0341_ps_ActiveGroup;
 	int16 L0344_i_ActiveGroupIndex;
 
 
-	L0341_ps_ActiveGroup = _g375_activeGroups;
+	L0341_ps_ActiveGroup = _activeGroups;
 	L0344_i_ActiveGroupIndex = 0;
 	while (L0341_ps_ActiveGroup->_groupThingIndex >= 0) {
-		if (++L0344_i_ActiveGroupIndex >= _g376_maxActiveGroupCount) {
+		if (++L0344_i_ActiveGroupIndex >= _maxActiveGroupCount) {
 			return;
 		}
 		L0341_ps_ActiveGroup++;
 	}
-	_g377_currActiveGroupCount++;
+	_currActiveGroupCount++;
 
 	L0340_ps_Group = (Group *)(_vm->_dungeonMan->_thingData[k4_GroupThingType] + 
 		g235_ThingDataWordCount[k4_GroupThingType] * (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getIndex()));
@@ -1753,23 +1753,23 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
 	L0341_ps_ActiveGroup->_lastMoveTime = _vm->_gameTime - 127;
 	L0339_ui_CreatureIndex = L0340_ps_Group->getCount();
 	do {
-		L0341_ps_ActiveGroup->_directions = (Direction)f178_getGroupValueUpdatedWithCreatureValue(L0341_ps_ActiveGroup->_directions, L0339_ui_CreatureIndex, L0340_ps_Group->getDir());
+		L0341_ps_ActiveGroup->_directions = (Direction)getGroupValueUpdatedWithCreatureValue(L0341_ps_ActiveGroup->_directions, L0339_ui_CreatureIndex, L0340_ps_Group->getDir());
 		L0341_ps_ActiveGroup->_aspect[L0339_ui_CreatureIndex] = 0;
 	} while (L0339_ui_CreatureIndex--);
-	f179_getCreatureAspectUpdateTime(L0341_ps_ActiveGroup, kM1_wholeCreatureGroup, false);
+	getCreatureAspectUpdateTime(L0341_ps_ActiveGroup, kM1_wholeCreatureGroup, false);
 }
 
-void GroupMan::f184_removeActiveGroup(uint16 activeGroupIndex) {
+void GroupMan::removeActiveGroup(uint16 activeGroupIndex) {
 	ActiveGroup *L0347_ps_ActiveGroup;
 	Group *L0348_ps_Group;
 
 
-	if ((activeGroupIndex > _g376_maxActiveGroupCount) || (_g375_activeGroups[activeGroupIndex]._groupThingIndex < 0)) {
+	if ((activeGroupIndex > _maxActiveGroupCount) || (_activeGroups[activeGroupIndex]._groupThingIndex < 0)) {
 		return;
 	}
-	L0347_ps_ActiveGroup = &_g375_activeGroups[activeGroupIndex];
+	L0347_ps_ActiveGroup = &_activeGroups[activeGroupIndex];
 	L0348_ps_Group = &((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex];
-	_g377_currActiveGroupCount--;
+	_currActiveGroupCount--;
 	L0348_ps_Group->_cells = L0347_ps_ActiveGroup->_cells;
 	L0348_ps_Group->setDir(normalizeModulo4(L0347_ps_ActiveGroup->_directions));
 	if (L0348_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
@@ -1778,15 +1778,15 @@ void GroupMan::f184_removeActiveGroup(uint16 activeGroupIndex) {
 	L0347_ps_ActiveGroup->_groupThingIndex = -1;
 }
 
-void GroupMan::f194_removeAllActiveGroups() {
-	for (int16 L0397_ui_ActiveGroupIndex = 0; _g377_currActiveGroupCount > 0; L0397_ui_ActiveGroupIndex++) {
-		if (_g375_activeGroups[L0397_ui_ActiveGroupIndex]._groupThingIndex >= 0) {
-			f184_removeActiveGroup(L0397_ui_ActiveGroupIndex);
+void GroupMan::removeAllActiveGroups() {
+	for (int16 L0397_ui_ActiveGroupIndex = 0; _currActiveGroupCount > 0; L0397_ui_ActiveGroupIndex++) {
+		if (_activeGroups[L0397_ui_ActiveGroupIndex]._groupThingIndex >= 0) {
+			removeActiveGroup(L0397_ui_ActiveGroupIndex);
 		}
 	}
 }
 
-void GroupMan::f195_addAllActiveGroups() {
+void GroupMan::addAllActiveGroups() {
 	uint16 L0398_ui_MapX;
 	uint16 L0399_ui_MapY;
 	Thing L0400_T_Thing;
@@ -1802,9 +1802,9 @@ void GroupMan::f195_addAllActiveGroups() {
 				L0400_T_Thing = *L0402_pT_SquareFirstThing++;
 				do {
 					if (L0400_T_Thing.getType() == k4_GroupThingType) {
-						f181_groupDeleteEvents(L0398_ui_MapX, L0399_ui_MapY);
-						f183_addActiveGroup(L0400_T_Thing, L0398_ui_MapX, L0399_ui_MapY);
-						f180_startWanedring(L0398_ui_MapX, L0399_ui_MapY);
+						groupDeleteEvents(L0398_ui_MapX, L0399_ui_MapY);
+						addActiveGroup(L0400_T_Thing, L0398_ui_MapX, L0399_ui_MapY);
+						startWanedring(L0398_ui_MapX, L0399_ui_MapY);
 						break;
 					}
 				} while ((L0400_T_Thing = _vm->_dungeonMan->getNextThing(L0400_T_Thing)) != Thing::_endOfList);
@@ -1813,7 +1813,7 @@ void GroupMan::f195_addAllActiveGroups() {
 	}
 }
 
-Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, Direction dir, int16 mapX, int16 mapY) {
+Thing GroupMan::groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, Direction dir, int16 mapX, int16 mapY) {
 	Thing L0349_T_GroupThing;
 	uint16 L0350_ui_BaseHealth;
 	uint16 L0351_ui_Cell = 0;
@@ -1823,7 +1823,7 @@ Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplie
 	bool L0355_B_SeveralCreaturesInGroup;
 
 
-	if (((_g377_currActiveGroupCount >= (_g376_maxActiveGroupCount - 5)) && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex)) || ((L0349_T_GroupThing = _vm->_dungeonMan->getUnusedThing(k4_GroupThingType)) == Thing::_none)) {
+	if (((_currActiveGroupCount >= (_maxActiveGroupCount - 5)) && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex)) || ((L0349_T_GroupThing = _vm->_dungeonMan->getUnusedThing(k4_GroupThingType)) == Thing::_none)) {
 		return Thing::_none;
 	}
 	L0353_ps_Group = (Group*)_vm->_dungeonMan->getThingData(L0349_T_GroupThing);
@@ -1842,7 +1842,7 @@ Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplie
 	do {
 		L0353_ps_Group->_health[creatureCount] = (L0350_ui_BaseHealth * healthMultiplier) + _vm->getRandomNumber((L0350_ui_BaseHealth >> 2) + 1);
 		if (L0355_B_SeveralCreaturesInGroup) {
-			L0352_ui_GroupCells = f178_getGroupValueUpdatedWithCreatureValue(L0352_ui_GroupCells, creatureCount, L0351_ui_Cell++);
+			L0352_ui_GroupCells = getGroupValueUpdatedWithCreatureValue(L0352_ui_GroupCells, creatureCount, L0351_ui_Cell++);
 			if (getFlag(L0354_ps_CreatureInfo->_attributes, k0x0003_MaskCreatureInfo_size) == k1_MaskCreatureSizeHalf) {
 				L0351_ui_Cell++;
 			}
@@ -1857,29 +1857,29 @@ Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplie
 	return L0349_T_GroupThing;
 }
 
-bool GroupMan::f223_isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY) {
+bool GroupMan::isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY) {
 	int16 L0544_i_SquareType;
 
 	return (((L0544_i_SquareType = Square(_vm->_dungeonMan->getSquare(mapX, mapY)).getType()) == k1_CorridorElemType)
 			|| (L0544_i_SquareType == k5_ElementTypeTeleporter) || (L0544_i_SquareType == k2_ElementTypePit) || (L0544_i_SquareType == k4_DoorElemType));
 }
 
-int16 GroupMan::f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 partyY, uint16 champCell) {
+int16 GroupMan::getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 partyY, uint16 champCell) {
 	uint16 L0321_ui_Counter;
 	int16 L0322_i_CreatureOrdinal;
 	Thing L0323_T_GroupThing;
 	Group* L0324_ps_Group;
 	signed char L0325_auc_OrderedCellsToAttack[4];
 
-	L0323_T_GroupThing = f175_groupGetThing(groupX, groupY);
+	L0323_T_GroupThing = groupGetThing(groupX, groupY);
 	if (L0323_T_GroupThing == Thing::_endOfList)
 		return 0;
 
 	L0324_ps_Group = (Group*)_vm->_dungeonMan->getThingData(L0323_T_GroupThing);
-	f229_setOrderedCellsToAttack(L0325_auc_OrderedCellsToAttack, groupX, groupY, partyX, partyY, champCell);
+	setOrderedCellsToAttack(L0325_auc_OrderedCellsToAttack, groupX, groupY, partyX, partyY, champCell);
 	L0321_ui_Counter = 0;
 	for (;;) { /*_Infinite loop_*/
-		L0322_i_CreatureOrdinal = f176_getCreatureOrdinalInCell(L0324_ps_Group, L0325_auc_OrderedCellsToAttack[L0321_ui_Counter]);
+		L0322_i_CreatureOrdinal = getCreatureOrdinalInCell(L0324_ps_Group, L0325_auc_OrderedCellsToAttack[L0321_ui_Counter]);
 		if (L0322_i_CreatureOrdinal)
 			return L0322_i_CreatureOrdinal;
 
@@ -1887,7 +1887,7 @@ int16 GroupMan::f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, i
 	}
 }
 
-int16 GroupMan::f231_getMeleeActionDamage(Champion* champ, int16 champIndex, Group* group, int16 creatureIndex, int16 mapX, int16 mapY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex) {
+int16 GroupMan::getMeleeActionDamage(Champion* champ, int16 champIndex, Group* group, int16 creatureIndex, int16 mapX, int16 mapY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex) {
 	int16 L0565_i_Damage = 0;
 	int16 L0566_i_Damage = 0;
 	int16 L0567_i_DoubledMapDifficulty;
@@ -1953,7 +1953,7 @@ T0231009:
 		if (_vm->getRandomNumber(64) < _vm->_championMan->getSkillLevel(champIndex, skillIndex)) {
 			L0565_i_Damage += L0565_i_Damage + 10;
 		}
-		L0569_i_Outcome = f190_groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapY, L0565_i_Damage, true);
+		L0569_i_Outcome = groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapY, L0565_i_Damage, true);
 		_vm->_championMan->addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * L0572_ps_CreatureInfo->getExperience() >> 4) + 3);
 		_vm->_championMan->decrementStamina(champIndex, _vm->getRandomNumber(4) + 4);
 		goto T0231016;
@@ -1965,12 +1965,12 @@ T0231015:
 T0231016:
 	_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	if (L0569_i_Outcome != k2_outcomeKilledAllCreaturesInGroup) {
-		f209_processEvents29to41(mapX, mapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
+		processEvents29to41(mapX, mapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
 	}
 	return L0565_i_Damage;
 }
 
-void GroupMan::f224_fluxCageAction(int16 mapX, int16 mapY) {
+void GroupMan::fluxCageAction(int16 mapX, int16 mapY) {
 	Thing L0545_T_Thing;
 	int16 L0546_i_Multiple;
 #define AL0546_i_SquareType    L0546_i_Multiple
@@ -1996,41 +1996,41 @@ void GroupMan::f224_fluxCageAction(int16 mapX, int16 mapY) {
 	L0547_s_Event._B._location._mapY = mapY;
 	L0547_s_Event._B._location._mapY = mapY;
 	_vm->_timeline->f238_addEventGetEventIndex(&L0547_s_Event);
-	if (f222_isLordChaosOnSquare(mapX, mapY - 1)) {
+	if (isLordChaosOnSquare(mapX, mapY - 1)) {
 		mapY--;
-		AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX + 1, mapY);
+		AL0546_i_FluxcageCount = isFluxcageOnSquare(mapX + 1, mapY);
 		goto T0224005;
 	}
-	if (f222_isLordChaosOnSquare(mapX - 1, mapY)) {
+	if (isLordChaosOnSquare(mapX - 1, mapY)) {
 		mapX--;
-		AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX, mapY + 1);
+		AL0546_i_FluxcageCount = isFluxcageOnSquare(mapX, mapY + 1);
 T0224005:
-		AL0546_i_FluxcageCount += f221_isFluxcageOnSquare(mapX, mapY - 1) + f221_isFluxcageOnSquare(mapX - 1, mapY);
+		AL0546_i_FluxcageCount += isFluxcageOnSquare(mapX, mapY - 1) + isFluxcageOnSquare(mapX - 1, mapY);
 	} else {
-		if (f222_isLordChaosOnSquare(mapX + 1, mapY)) {
+		if (isLordChaosOnSquare(mapX + 1, mapY)) {
 			mapX++;
-			AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX, mapY - 1);
+			AL0546_i_FluxcageCount = isFluxcageOnSquare(mapX, mapY - 1);
 			goto T0224008;
 		}
-		if (f222_isLordChaosOnSquare(mapX, mapY + 1)) {
+		if (isLordChaosOnSquare(mapX, mapY + 1)) {
 			mapY++;
-			AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX - 1, mapY);
+			AL0546_i_FluxcageCount = isFluxcageOnSquare(mapX - 1, mapY);
 T0224008:
-			AL0546_i_FluxcageCount += f221_isFluxcageOnSquare(mapX, mapY + 1) + f221_isFluxcageOnSquare(mapX + 1, mapY);
+			AL0546_i_FluxcageCount += isFluxcageOnSquare(mapX, mapY + 1) + isFluxcageOnSquare(mapX + 1, mapY);
 		} else {
 			AL0546_i_FluxcageCount = 0;
 		}
 	}
 	if (AL0546_i_FluxcageCount == 2) {
-		f209_processEvents29to41(mapX, mapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
+		processEvents29to41(mapX, mapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
 	}
 }
 
-uint16 GroupMan::f222_isLordChaosOnSquare(int16 mapX, int16 mapY) {
+uint16 GroupMan::isLordChaosOnSquare(int16 mapX, int16 mapY) {
 	Thing L0542_T_Thing;
 	Group* L0543_ps_Group;
 
-	L0542_T_Thing = f175_groupGetThing(mapX, mapY);
+	L0542_T_Thing = groupGetThing(mapX, mapY);
 	if (L0542_T_Thing == Thing::_endOfList)
 		return 0;
 
@@ -2041,7 +2041,7 @@ uint16 GroupMan::f222_isLordChaosOnSquare(int16 mapX, int16 mapY) {
 	return 0;
 }
 
-bool GroupMan::f221_isFluxcageOnSquare(int16 mapX, int16 mapY) {
+bool GroupMan::isFluxcageOnSquare(int16 mapX, int16 mapY) {
 	Thing L0540_T_Thing;
 	int16 L0541_i_SquareType;
 
@@ -2059,7 +2059,7 @@ bool GroupMan::f221_isFluxcageOnSquare(int16 mapX, int16 mapY) {
 	return false;
 }
 
-void GroupMan::f225_fuseAction(uint16 mapX, uint16 mapY) {
+void GroupMan::fuseAction(uint16 mapX, uint16 mapY) {
 	int16 L0548_i_MapX;
 	int16 L0549_i_MapY;
 	uint16 L0551_ui_FluxcageCount;
@@ -2073,12 +2073,12 @@ void GroupMan::f225_fuseAction(uint16 mapX, uint16 mapY) {
 	}
 
 	_vm->_projexpl->f213_explosionCreate(Thing::_explHarmNonMaterial, 255, mapX, mapY, k255_CreatureTypeSingleCenteredCreature); /* BUG0_17 The game crashes after the Fuse action is performed while looking at a wall on a map boundary. An explosion thing is created on the square in front of the party but there is no check to ensure the square coordinates are in the map bounds. This corrupts a memory location and leads to a game crash */
-	L0555_T_LordChaosThing = Thing(f222_isLordChaosOnSquare(mapX, mapY));
+	L0555_T_LordChaosThing = Thing(isLordChaosOnSquare(mapX, mapY));
 	if (L0555_T_LordChaosThing.toUint16()) {
-		L0551_ui_FluxcageCount = (L0554_aB_Fluxcages[0] = f221_isFluxcageOnSquare(mapX - 1, mapY)) +
-			(L0554_aB_Fluxcages[1] = f221_isFluxcageOnSquare(mapX + 1, mapY)) +
-			(L0554_aB_Fluxcages[2] = f221_isFluxcageOnSquare(mapX, mapY - 1)) +
-			(L0554_aB_Fluxcages[3] = f221_isFluxcageOnSquare(mapX, mapY + 1));
+		L0551_ui_FluxcageCount = (L0554_aB_Fluxcages[0] = isFluxcageOnSquare(mapX - 1, mapY)) +
+			(L0554_aB_Fluxcages[1] = isFluxcageOnSquare(mapX + 1, mapY)) +
+			(L0554_aB_Fluxcages[2] = isFluxcageOnSquare(mapX, mapY - 1)) +
+			(L0554_aB_Fluxcages[3] = isFluxcageOnSquare(mapX, mapY + 1));
 		while (L0551_ui_FluxcageCount++ < 4) {
 			L0548_i_MapX = mapX;
 			L0549_i_MapY = mapY;
@@ -2102,9 +2102,9 @@ void GroupMan::f225_fuseAction(uint16 mapX, uint16 mapY) {
 					break;
 				}
 			}
-			if (f223_isSquareACorridorTeleporterPitOrDoor(L0548_i_MapX, L0549_i_MapY)) {
+			if (isSquareACorridorTeleporterPitOrDoor(L0548_i_MapX, L0549_i_MapY)) {
 				if (!_vm->_moveSens->f267_getMoveResult(L0555_T_LordChaosThing, mapX, mapY, L0548_i_MapX, L0549_i_MapY)) {
-					f180_startWanedring(L0548_i_MapX, L0549_i_MapY);
+					startWanedring(L0548_i_MapX, L0549_i_MapY);
 				}
 				return;
 			}
@@ -2113,9 +2113,9 @@ void GroupMan::f225_fuseAction(uint16 mapX, uint16 mapY) {
 	}
 }
 
-void GroupMan::save1_ActiveGroupPart(Common::OutSaveFile* file) {
-	for (uint16 i = 0; i < _g376_maxActiveGroupCount; ++i) {
-		ActiveGroup *group = &_g375_activeGroups[i];
+void GroupMan::saveActiveGroupPart(Common::OutSaveFile* file) {
+	for (uint16 i = 0; i < _maxActiveGroupCount; ++i) {
+		ActiveGroup *group = &_activeGroups[i];
 		file->writeUint16BE(group->_groupThingIndex);
 		file->writeUint16BE(group->_directions);
 		file->writeByte(group->_cells);
@@ -2132,9 +2132,9 @@ void GroupMan::save1_ActiveGroupPart(Common::OutSaveFile* file) {
 	}
 }
 
-void GroupMan::load1_ActiveGroupPart(Common::InSaveFile* file) {
-	for (uint16 i = 0; i < _g376_maxActiveGroupCount; ++i) {
-		ActiveGroup *group = &_g375_activeGroups[i];
+void GroupMan::loadActiveGroupPart(Common::InSaveFile* file) {
+	for (uint16 i = 0; i < _maxActiveGroupCount; ++i) {
+		ActiveGroup *group = &_activeGroups[i];
 		group->_groupThingIndex = file->readUint16BE();
 		group->_directions = (Direction)file->readUint16BE();
 		group->_cells = file->readByte();
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 8fe1eba..6627826 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -25,7 +25,6 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-
 #ifndef DM_GROUP_H
 #define DM_GROUP_H
 
@@ -155,101 +154,99 @@ int32 M32_setTime(int32 &map_time, int32 time); // @ M32_SET_TIME
 
 class GroupMan {
 	DMEngine *_vm;
-	byte _g392_dropMovingCreatureFixedPossessionsCell[4]; // @ G0392_auc_DropMovingCreatureFixedPossessionsCells
-	uint16 _g391_dropMovingCreatureFixedPossCellCount; // @ G0391_ui_DropMovingCreatureFixedPossessionsCellCount
-	uint16 _g386_fluxCageCount; // @ G0386_ui_FluxCageCount
-	int16 _g385_fluxCages[4]; // @ G0385_ac_FluxCages
-	int16 _g378_currentGroupMapX; // @ G0378_i_CurrentGroupMapX
-	int16 _g379_currentGroupMapY; // @ G0379_i_CurrentGroupMapY
-	Thing _g380_currGroupThing; // @ G0380_T_CurrentGroupThing
-	int16 _g384_groupMovementTestedDirections[4]; // @ G0384_auc_GroupMovementTestedDirections
-	uint16 _g381_currGroupDistanceToParty; // @ G0381_ui_CurrentGroupDistanceToParty
-	int16 _g382_currGroupPrimaryDirToParty; // @ G0382_i_CurrentGroupPrimaryDirectionToParty
-	int16 _g383_currGroupSecondaryDirToParty; // @ G0383_i_CurrentGroupSecondaryDirectionToParty
-
-	Thing _g388_groupMovementBlockedByGroupThing; // @ G0388_T_GroupMovementBlockedByGroupThing
-	bool _g389_groupMovementBlockedByDoor; // @ G0389_B_GroupMovementBlockedByDoor
-	bool _g390_groupMovementBlockedByParty; // @ G0390_B_GroupMovementBlockedByParty
-	bool _g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter; // @ G0387_B_GroupMovementBlockedByWallStairsPitFakeWallFluxcageTeleporter
-	int32 _g395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime; // @ G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime
+	byte _dropMovingCreatureFixedPossessionsCell[4]; // @ G0392_auc_DropMovingCreatureFixedPossessionsCells
+	uint16 _dropMovingCreatureFixedPossCellCount; // @ G0391_ui_DropMovingCreatureFixedPossessionsCellCount
+	uint16 _fluxCageCount; // @ G0386_ui_FluxCageCount
+	int16 _fluxCages[4]; // @ G0385_ac_FluxCages
+	int16 _currentGroupMapX; // @ G0378_i_CurrentGroupMapX
+	int16 _currentGroupMapY; // @ G0379_i_CurrentGroupMapY
+	Thing _currGroupThing; // @ G0380_T_CurrentGroupThing
+	int16 _groupMovementTestedDirections[4]; // @ G0384_auc_GroupMovementTestedDirections
+	uint16 _currGroupDistanceToParty; // @ G0381_ui_CurrentGroupDistanceToParty
+	int16 _currGroupPrimaryDirToParty; // @ G0382_i_CurrentGroupPrimaryDirectionToParty
+	int16 _currGroupSecondaryDirToParty; // @ G0383_i_CurrentGroupSecondaryDirectionToParty
+
+	Thing _groupMovementBlockedByGroupThing; // @ G0388_T_GroupMovementBlockedByGroupThing
+	bool _groupMovementBlockedByDoor; // @ G0389_B_GroupMovementBlockedByDoor
+	bool _groupMovementBlockedByParty; // @ G0390_B_GroupMovementBlockedByParty
+	bool _groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter; // @ G0387_B_GroupMovementBlockedByWallStairsPitFakeWallFluxcageTeleporter
+	int32 twoHalfSquareSizedCreaturesGroupLastDirectionSetTime; // @ G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime
 public:
-	uint16 _g376_maxActiveGroupCount; // @ G0376_ui_MaximumActiveGroupCount
-	ActiveGroup *_g375_activeGroups; // @ G0375_ps_ActiveGroups
-	uint16 _g377_currActiveGroupCount; // @ G0377_ui_CurrentActiveGroupCount
+	uint16 _maxActiveGroupCount; // @ G0376_ui_MaximumActiveGroupCount
+	ActiveGroup *_activeGroups; // @ G0375_ps_ActiveGroups
+	uint16 _currActiveGroupCount; // @ G0377_ui_CurrentActiveGroupCount
 	explicit GroupMan(DMEngine *vm);
 	~GroupMan();
 
-	void f196_initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups
-	uint16 f145_getGroupCells(Group *group, int16 mapIndex); // @ F0145_DUNGEON_GetGroupCells
-	uint16 f147_getGroupDirections(Group *group, int16 mapIndex); // @ F0147_DUNGEON_GetGroupDirections
-	int16 f176_getCreatureOrdinalInCell(Group *group, uint16 cell); // @ F0176_GROUP_GetCreatureOrdinalInCell
-	uint16 M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex); // @ M50_CREATURE_VALUE
-	void f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode); // @ F0188_GROUP_DropGroupPossessions
-	void f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int16 mapY, uint16 cell,
+	void initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups
+	uint16 getGroupCells(Group *group, int16 mapIndex); // @ F0145_DUNGEON_GetGroupCells
+	uint16 getGroupDirections(Group *group, int16 mapIndex); // @ F0147_DUNGEON_GetGroupDirections
+	int16 getCreatureOrdinalInCell(Group *group, uint16 cell); // @ F0176_GROUP_GetCreatureOrdinalInCell
+	uint16 getCreatureValue(uint16 groupVal, uint16 creatureIndex); // @ M50_CREATURE_VALUE
+	void dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode); // @ F0188_GROUP_DropGroupPossessions
+	void dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int16 mapY, uint16 cell,
 										   int16 mode); // @ F0186_GROUP_DropCreatureFixedPossessions
-	int16 f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY,
+	int16 getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY,
 												   int16 destMapX, int16 destMapY); // @ F0228_GROUP_GetDirectionsWhereDestinationIsVisibleFromSource
-	bool f227_isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 srcMapY, int16 destMapX,
+	bool isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 srcMapY, int16 destMapX,
 									  int16 destMapY); // @ F0227_GROUP_IsDestinationVisibleFromSource
-	bool f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack,
+	bool groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack,
 										   bool magicAttack, int16 ticks); // @ F0232_GROUP_IsDoorDestroyedByAttack
-	Thing f175_groupGetThing(int16 mapX, int16 mapY); // @ F0175_GROUP_GetThing
-	int16 f190_groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex,
+	Thing groupGetThing(int16 mapX, int16 mapY); // @ F0175_GROUP_GetThing
+	int16 groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex,
 											 int16 mapX, int16 mapY, int16 damage, bool notMoving); // @ F0190_GROUP_GetDamageCreatureOutcome
-	void f189_delete(int16 mapX, int16 mapY); // @ F0189_GROUP_Delete
-	void f181_groupDeleteEvents(int16 mapX, int16 mapY); // @ F0181_GROUP_DeleteEvents
-	uint16 f178_getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatreVal); // @ F0178_GROUP_GetGroupValueUpdatedWithCreatureValue
-	int16 f191_getDamageAllCreaturesOutcome(Group *group, int16 mapX, int16 mapY, int16 attack, bool notMoving); // @ F0191_GROUP_GetDamageAllCreaturesOutcome
-	int16 f192_groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack); // @ F0192_GROUP_GetResistanceAdjustedPoisonAttack
-	void f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks); // @ F0209_GROUP_ProcessEvents29to41
-	bool f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, int16 mapY,
+	void groupDelete(int16 mapX, int16 mapY); // @ F0189_GROUP_Delete
+	void groupDeleteEvents(int16 mapX, int16 mapY); // @ F0181_GROUP_DeleteEvents
+	uint16 getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatreVal); // @ F0178_GROUP_GetGroupValueUpdatedWithCreatureValue
+	int16 getDamageAllCreaturesOutcome(Group *group, int16 mapX, int16 mapY, int16 attack, bool notMoving); // @ F0191_GROUP_GetDamageAllCreaturesOutcome
+	int16 groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack); // @ F0192_GROUP_GetResistanceAdjustedPoisonAttack
+	void processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks); // @ F0209_GROUP_ProcessEvents29to41
+	bool isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, int16 mapY,
 								 uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls); // @ F0202_GROUP_IsMovementPossible
-	int16 f226_getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 destMapX,
+	int16 getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 destMapX,
 										 int16 destMapY); // @ F0226_GROUP_GetDistanceBetweenSquares
 
-	int16 f200_groupGetDistanceToVisibleParty(Group *group, int16 creatureIndex, int16 mapX, int16 mapY); // @ F0200_GROUP_GetDistanceToVisibleParty
-	int16 f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 srcMapY,
+	int16 groupGetDistanceToVisibleParty(Group *group, int16 creatureIndex, int16 mapX, int16 mapY); // @ F0200_GROUP_GetDistanceToVisibleParty
+	int16 getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 srcMapY,
 												  int16 destMapX, int16 destMapY, bool (GroupMan::*isBlocked)(uint16, uint16)); // @ F0199_GROUP_GetDistanceBetweenUnblockedSquares
-	bool f197_isViewPartyBlocked(uint16 mapX, uint16 mapY); // @ F0197_GROUP_IsViewPartyBlocked
-	int32 f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 creatureIndex,
+	bool isViewPartyBlocked(uint16 mapX, uint16 mapY); // @ F0197_GROUP_IsViewPartyBlocked
+	int32 getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 creatureIndex,
 										   bool isAttacking); // @ F0179_GROUP_GetCreatureAspectUpdateTime
-	void f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures); // @ F0205_GROUP_SetDirection
-	void f208_groupAddEvent(TimelineEvent *event, uint32 time); // @ F0208_GROUP_AddEvent
-	int16 f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo, int16 mapY, int16 mapX); // @ F0201_GROUP_GetSmelledPartyPrimaryDirectionOrdinal
-	bool f198_isSmellPartyBlocked(uint16 mapX, uint16 mapY); // @ F0198_GROUP_IsSmellPartyBlocked
-	int16 f203_getFirstPossibleMovementDirOrdinal(CreatureInfo *info, int16 mapX, int16 mapY,
+	void setGroupDirection(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures); // @ F0205_GROUP_SetDirection
+	void addGroupEvent(TimelineEvent *event, uint32 time); // @ F0208_GROUP_AddEvent
+	int16 getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo, int16 mapY, int16 mapX); // @ F0201_GROUP_GetSmelledPartyPrimaryDirectionOrdinal
+	bool isSmellPartyBlocked(uint16 mapX, uint16 mapY); // @ F0198_GROUP_IsSmellPartyBlocked
+	int16 getFirstPossibleMovementDirOrdinal(CreatureInfo *info, int16 mapX, int16 mapY,
 												  bool allowMovementOverImaginaryPitsAndFakeWalls); // @ F0203_GROUP_GetFirstPossibleMovementDirectionOrdinal
-	void f206_groupSetDirGroup(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex,
+	void setDirGroup(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex,
 							   int16 creatureSize); // @ F0206_GROUP_SetDirectionGroup
-	void f182_stopAttacking(ActiveGroup *group, int16 mapX, int16 mapY);// @ F0182_GROUP_StopAttacking
-	bool f204_isArchenemyDoubleMovementPossible(CreatureInfo *info, int16 mapX, int16 mapY, uint16 dir); // @ F0204_GROUP_IsArchenemyDoubleMovementPossible
-	bool f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 creatureIndex); // @ F0207_GROUP_IsCreatureAttacking
-	void f229_setOrderedCellsToAttack(signed char * orderedCellsToAttack, int16 targetMapX,
+	void stopAttacking(ActiveGroup *group, int16 mapX, int16 mapY);// @ F0182_GROUP_StopAttacking
+	bool isArchenemyDoubleMovementPossible(CreatureInfo *info, int16 mapX, int16 mapY, uint16 dir); // @ F0204_GROUP_IsArchenemyDoubleMovementPossible
+	bool isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 creatureIndex); // @ F0207_GROUP_IsCreatureAttacking
+	void setOrderedCellsToAttack(signed char * orderedCellsToAttack, int16 targetMapX,
 	                                  int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource); // @ F0229_GROUP_SetOrderedCellsToAttack
-	void f193_stealFromChampion(Group *group, uint16 championIndex); // @ F0193_GROUP_StealFromChampion
-	int16 f230_getChampionDamage(Group *group, uint16 champIndex); // @ F0230_GROUP_GetChampionDamage
-	void f187_dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY); // @ F0187_GROUP_DropMovingCreatureFixedPossessions
-	void f180_startWanedring(int16 mapX, int16 mapY); // @ F0180_GROUP_StartWandering
-	void f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY); // @ F0183_GROUP_AddActiveGroup
-	void f184_removeActiveGroup(uint16 activeGroupIndex); // @ F0184_GROUP_RemoveActiveGroup
-	void f194_removeAllActiveGroups(); // @ F0194_GROUP_RemoveAllActiveGroups
-	void f195_addAllActiveGroups(); // @ F0195_GROUP_AddAllActiveGroups
-	Thing f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, Direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated
-	bool f223_isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY); // @ F0223_GROUP_IsSquareACorridorTeleporterPitOrDoor
-	int16 f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 paryY,
+	void stealFromChampion(Group *group, uint16 championIndex); // @ F0193_GROUP_StealFromChampion
+	int16 getChampionDamage(Group *group, uint16 champIndex); // @ F0230_GROUP_GetChampionDamage
+	void dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY); // @ F0187_GROUP_DropMovingCreatureFixedPossessions
+	void startWanedring(int16 mapX, int16 mapY); // @ F0180_GROUP_StartWandering
+	void addActiveGroup(Thing thing, int16 mapX, int16 mapY); // @ F0183_GROUP_AddActiveGroup
+	void removeActiveGroup(uint16 activeGroupIndex); // @ F0184_GROUP_RemoveActiveGroup
+	void removeAllActiveGroups(); // @ F0194_GROUP_RemoveAllActiveGroups
+	void addAllActiveGroups(); // @ F0195_GROUP_AddAllActiveGroups
+	Thing groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, Direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated
+	bool isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY); // @ F0223_GROUP_IsSquareACorridorTeleporterPitOrDoor
+	int16 getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 paryY,
 											 uint16 champCell); // @ F0177_GROUP_GetMeleeTargetCreatureOrdinal
-	int16 f231_getMeleeActionDamage(Champion *champ, int16 champIndex, Group *group, int16 creatureIndex,
+	int16 getMeleeActionDamage(Champion *champ, int16 champIndex, Group *group, int16 creatureIndex,
 									int16 mapX, int16 mapY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex); // @ F0231_GROUP_GetMeleeActionDamage
-	void f224_fluxCageAction(int16 mapX, int16 mapY); // @ F0224_GROUP_FluxCageAction
-	uint16 f222_isLordChaosOnSquare(int16 mapX, int16 mapY); // @ F0222_GROUP_IsLordChaosOnSquare
-	bool f221_isFluxcageOnSquare(int16 mapX, int16 mapY); // @ F0221_GROUP_IsFluxcageOnSquare
-	void f225_fuseAction(uint16 mapX, uint16 mapY); // @ F0225_GROUP_FuseAction
-	void save1_ActiveGroupPart(Common::OutSaveFile *file);
-	void load1_ActiveGroupPart(Common::InSaveFile* file);
+	void fluxCageAction(int16 mapX, int16 mapY); // @ F0224_GROUP_FluxCageAction
+	uint16 isLordChaosOnSquare(int16 mapX, int16 mapY); // @ F0222_GROUP_IsLordChaosOnSquare
+	bool isFluxcageOnSquare(int16 mapX, int16 mapY); // @ F0221_GROUP_IsFluxcageOnSquare
+	void fuseAction(uint16 mapX, uint16 mapY); // @ F0225_GROUP_FuseAction
+	void saveActiveGroupPart(Common::OutSaveFile *file);
+	void loadActiveGroupPart(Common::InSaveFile* file);
 };
 
-
-
 }
 
 #endif
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 17a9b4f..4442c6c 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -102,20 +102,20 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
 		_timeline->_g372_eventCount = file->readUint16BE();
 		_timeline->_g373_firstUnusedEventIndex = file->readUint16BE();
 		_timeline->_g369_eventMaxCount = file->readUint16BE();
-		_groupMan->_g377_currActiveGroupCount = file->readUint16BE();
+		_groupMan->_currActiveGroupCount = file->readUint16BE();
 		_projexpl->_g361_lastCreatureAttackTime = file->readSint32BE();
 		_projexpl->_g362_lastPartyMovementTime = file->readSint32BE();
 		_disabledMovementTicks = file->readSint16BE();
 		_projectileDisableMovementTicks = file->readSint16BE();
 		_lastProjectileDisabledMovementDirection = file->readSint16BE();
 		_championMan->_leaderHandObject = Thing(file->readUint16BE());
-		_groupMan->_g376_maxActiveGroupCount = file->readUint16BE();
+		_groupMan->_maxActiveGroupCount = file->readUint16BE();
 		if (!_restartGameRequest) {
 			_timeline->f233_initTimeline();
-			_groupMan->f196_initActiveGroups();
+			_groupMan->initActiveGroups();
 		}
 
-		_groupMan->load1_ActiveGroupPart(file);
+		_groupMan->loadActiveGroupPart(file);
 		_championMan->loadPartyPart2(file);
 		_timeline->load3_eventsPart(file);
 		_timeline->load4_timelinePart(file);
@@ -130,7 +130,7 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
 
 	if (_newGameFl) {
 		_timeline->f233_initTimeline();
-		_groupMan->f196_initActiveGroups();
+		_groupMan->initActiveGroups();
 
 		if (L1366_B_FadePalette) {
 			_displayMan->startEndFadeToPalette(_displayMan->_blankBuffer);
@@ -318,17 +318,17 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 	file->writeUint16BE(_timeline->_g372_eventCount);
 	file->writeUint16BE(_timeline->_g373_firstUnusedEventIndex);
 	file->writeUint16BE(_timeline->_g369_eventMaxCount);
-	file->writeUint16BE(_groupMan->_g377_currActiveGroupCount);
+	file->writeUint16BE(_groupMan->_currActiveGroupCount);
 	file->writeSint32BE(_projexpl->_g361_lastCreatureAttackTime);
 	file->writeSint32BE(_projexpl->_g362_lastPartyMovementTime);
 	file->writeSint16BE(_disabledMovementTicks);
 	file->writeSint16BE(_projectileDisableMovementTicks);
 	file->writeSint16BE(_lastProjectileDisabledMovementDirection);
 	file->writeUint16BE(_championMan->_leaderHandObject.toUint16());
-	file->writeUint16BE(_groupMan->_g376_maxActiveGroupCount);
+	file->writeUint16BE(_groupMan->_maxActiveGroupCount);
 
 	// write C1_SAVE_PART_ACTIVE_GROUP part
-	_groupMan->save1_ActiveGroupPart(file);
+	_groupMan->saveActiveGroupPart(file);
 	// write C2_SAVE_PART_PARTY part
 	_championMan->savePartyPart2(file);
 	// write C3_SAVE_PART_EVENTS part
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index c42616f..adc151e 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -1085,7 +1085,7 @@ bool MenuMan::f407_isActionPerformed(uint16 champIndex, int16 actionIndex) {
 	L1251_i_MapX = _vm->_dungeonMan->_partyMapX;
 	L1252_i_MapY = _vm->_dungeonMan->_partyMapY;
 	L1251_i_MapX += _vm->_dirIntoStepCountEast[L1247_ps_Champion->_dir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[L1247_ps_Champion->_dir];
-	_g517_actionTargetGroupThing = _vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY);
+	_g517_actionTargetGroupThing = _vm->_groupMan->groupGetThing(L1251_i_MapX, L1252_i_MapY);
 	L1249_ui_ActionDisabledTicks = G0491_auc_Graphic560_ActionDisabledTicks[actionIndex];
 	L1254_i_ActionSkillIndex = g496_ActionSkillIndex[actionIndex];
 	L1253_i_ActionStamina = G0494_auc_Graphic560_ActionStamina[actionIndex] + _vm->getRandomNumber(2);
@@ -1131,7 +1131,7 @@ T0407014:
 		if ((Square(AL1244_ui_TargetSquare).getType() == k4_DoorElemType) && (Square(AL1244_ui_TargetSquare).getDoorState() == k4_doorState_CLOSED)) {
 			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 			L1249_ui_ActionDisabledTicks = 6;
-			_vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
+			_vm->_groupMan->groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
 			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k2_soundModePlayOneTickLater);
 			break;
 		}
@@ -1239,14 +1239,14 @@ T0407032:
 		}
 	case k35_ChampionActionFluxcage:
 		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
-		_vm->_groupMan->f224_fluxCageAction(L1251_i_MapX, L1252_i_MapY);
+		_vm->_groupMan->fluxCageAction(L1251_i_MapX, L1252_i_MapY);
 		break;
 	case k43_ChampionActionFuse:
 		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
 		L1251_i_MapX = _vm->_dungeonMan->_partyMapX;
 		L1252_i_MapY = _vm->_dungeonMan->_partyMapY;
 		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
-		_vm->_groupMan->f225_fuseAction(L1251_i_MapX, L1252_i_MapY);
+		_vm->_groupMan->fuseAction(L1251_i_MapX, L1252_i_MapY);
 		break;
 	case k36_ChampionActionHeal:
 		/* CHANGE2_17_IMPROVEMENT Heal action is much more effective
@@ -1283,7 +1283,7 @@ T0407032:
 		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir];
 		L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
 		/* CHANGE6_00_FIX The presence of a group over the pit is checked so that you cannot climb down a pit with the rope if there is a group levitating over it */
-		if ((_vm->_dungeonMan->getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_PitElemType) && (_vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY) == Thing::_endOfList)) {
+		if ((_vm->_dungeonMan->getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_PitElemType) && (_vm->_groupMan->groupGetThing(L1251_i_MapX, L1252_i_MapY) == Thing::_endOfList)) {
 			/* BUG0_77 The party moves forward when using the rope in front of a closed pit. The engine does not check whether the pit is open before moving the party over the pit. This is not consistent with the behavior when using the rope in front of a corridor where nothing happens */
 			_vm->_moveSens->_g402_useRopeToClimbDownPit = true;
 			_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, L1251_i_MapX, L1252_i_MapY);
@@ -1472,7 +1472,7 @@ bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int
 	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 	if (_g517_actionTargetGroupThing == Thing::_endOfList)
 		goto T0402010;
-	L1238_i_CreatureOrdinal = _vm->_groupMan->f177_getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, AL1236_ui_ChampionCell = champ->_cell);
+	L1238_i_CreatureOrdinal = _vm->_groupMan->getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, AL1236_ui_ChampionCell = champ->_cell);
 	if (L1238_i_CreatureOrdinal) {
 		switch (normalizeModulo4(AL1236_ui_ChampionCell + 4 - champ->_dir)) {
 		case k2_ViewCellBackRight: /* Champion is on the back right of the square and tries to attack a creature in the front right of its square */
@@ -1493,7 +1493,7 @@ T0402005: /* Check if there is another champion in front */
 		if ((_vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
 			setFlag(AL1237_ui_ActionHitProbability, k0x8000_hitNonMaterialCreatures);
 		}
-		_g513_actionDamage = _vm->_groupMan->f231_getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->getThingData(_g517_actionTargetGroupThing), _vm->ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
+		_g513_actionDamage = _vm->_groupMan->getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->getThingData(_g517_actionTargetGroupThing), _vm->ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
 		return true;
 	}
 T0402010:
@@ -1540,10 +1540,10 @@ bool MenuMan::f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionInde
 	if (((L1230_ui_FearResistance = L1234_ps_CreatureInfo->getFearResistance()) > _vm->getRandomNumber(L1229_i_FrightAmount)) || (L1230_ui_FearResistance == k15_immuneToFear)) {
 		L1231_ui_Experience >>= 1;
 	} else {
-		L1235_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[L1233_ps_Group->getActiveGroupIndex()];
+		L1235_ps_ActiveGroup = &_vm->_groupMan->_activeGroups[L1233_ps_Group->getActiveGroupIndex()];
 		if (L1233_ps_Group->getBehaviour() == k6_behavior_ATTACK) {
-			_vm->_groupMan->f182_stopAttacking(L1235_ps_ActiveGroup, mapX, mapY);
-			_vm->_groupMan->f180_startWanedring(mapX, mapY);
+			_vm->_groupMan->stopAttacking(L1235_ps_ActiveGroup, mapX, mapY);
+			_vm->_groupMan->startWanedring(mapX, mapY);
 		}
 		L1233_ps_Group->setBehaviour(k5_behavior_FLEE);
 		L1235_ps_ActiveGroup->_delayFleeingFromTarget = ((16 - L1230_ui_FearResistance) << 2) / L1234_ps_CreatureInfo->_movementTicks;
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 25b8e34..98da742 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -361,13 +361,13 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					} else {
 						if (L0710_i_ThingType == k4_GroupThingType) {
 							_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
-							AL0727_ui_Outcome = _vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group *)_vm->_dungeonMan->getThingData(thing), mapX, mapY, 20, false);
+							AL0727_ui_Outcome = _vm->_groupMan->getDamageAllCreaturesOutcome((Group *)_vm->_dungeonMan->getThingData(thing), mapX, mapY, 20, false);
 							_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
 							L0722_B_FallKilledGroup = (AL0727_ui_Outcome == k2_outcomeKilledAllCreaturesInGroup);
 							if (L0722_B_FallKilledGroup)
 								break;
 							if (AL0727_ui_Outcome == k1_outcomeKilledSomeCreaturesInGroup) {
-								_vm->_groupMan->f187_dropMovingCreatureFixedPossession(thing, destMapX, destMapY);
+								_vm->_groupMan->dropMovingCreatureFixedPossession(thing, destMapX, destMapY);
 							}
 						}
 					}
@@ -389,11 +389,11 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 			}
 		}
 		if ((L0710_i_ThingType == k4_GroupThingType) && (L0722_B_FallKilledGroup || !_vm->_dungeonMan->isCreatureAllowedOnMap(thing, L0715_ui_MapIndexDestination))) {
-			_vm->_groupMan->f187_dropMovingCreatureFixedPossession(thing, destMapX, destMapY);
-			_vm->_groupMan->f188_dropGroupPossessions(destMapX, destMapY, thing, k2_soundModePlayOneTickLater);
+			_vm->_groupMan->dropMovingCreatureFixedPossession(thing, destMapX, destMapY);
+			_vm->_groupMan->dropGroupPossessions(destMapX, destMapY, thing, k2_soundModePlayOneTickLater);
 			_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
 			if (mapX >= 0) {
-				_vm->_groupMan->f189_delete(mapX, mapY);
+				_vm->_groupMan->groupDelete(mapX, mapY);
 			}
 			return true; /* The specified group thing cannot be moved because it was killed by a fall or because it is not allowed on the destination map */
 		}
@@ -454,9 +454,9 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 	if (destMapX >= 0) {
 		if (thing == Thing::_party) {
 			_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
-			if ((thing = _vm->_groupMan->f175_groupGetThing(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY)) != Thing::_endOfList) { /* Delete group if party moves onto its square */
-				_vm->_groupMan->f188_dropGroupPossessions(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, thing, k1_soundModePlayIfPrioritized);
-				_vm->_groupMan->f189_delete(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
+			if ((thing = _vm->_groupMan->groupGetThing(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY)) != Thing::_endOfList) { /* Delete group if party moves onto its square */
+				_vm->_groupMan->dropGroupPossessions(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, thing, k1_soundModePlayIfPrioritized);
+				_vm->_groupMan->groupDelete(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
 			}
 			if (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) {
 				f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, Thing::_party, L0725_B_PartySquare, true);
@@ -469,13 +469,13 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
 				L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(thing);
 				AL0708_i_ActiveGroupIndex = ((Group *)L0712_ps_Teleporter)->getActiveGroupIndex();
-				if (((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_partyMapIndex) && (destMapX == _vm->_dungeonMan->_partyMapX) && (destMapY == _vm->_dungeonMan->_partyMapY)) || (_vm->_groupMan->f175_groupGetThing(destMapX, destMapY) != Thing::_endOfList)) { /* If a group tries to move to the party square or over another group then create an event to move the group later */
+				if (((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_partyMapIndex) && (destMapX == _vm->_dungeonMan->_partyMapX) && (destMapY == _vm->_dungeonMan->_partyMapY)) || (_vm->_groupMan->groupGetThing(destMapX, destMapY) != Thing::_endOfList)) { /* If a group tries to move to the party square or over another group then create an event to move the group later */
 					_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
 					if (mapX >= 0) {
-						_vm->_groupMan->f181_groupDeleteEvents(mapX, mapY);
+						_vm->_groupMan->groupDeleteEvents(mapX, mapY);
 					}
 					if (L0721_B_GroupOnPartyMap) {
-						_vm->_groupMan->f184_removeActiveGroup(AL0708_i_ActiveGroupIndex);
+						_vm->_groupMan->removeActiveGroup(AL0708_i_ActiveGroupIndex);
 					}
 					f265_createEvent60to61_moveGroup(thing, destMapX, destMapY, L0715_ui_MapIndexDestination, L0726_B_Audible);
 					return true; /* The specified group thing cannot be moved because the party or another group is on the destination square */
@@ -485,11 +485,11 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					_vm->_sound->f064_SOUND_RequestPlay_CPSD(L1638_ui_MovementSoundIndex, destMapX, destMapY, k1_soundModePlayIfPrioritized);
 				}
 				if (L0721_B_GroupOnPartyMap && (L0715_ui_MapIndexDestination != _vm->_dungeonMan->_partyMapIndex)) { /* If the group leaves the party map */
-					_vm->_groupMan->f184_removeActiveGroup(AL0708_i_ActiveGroupIndex);
+					_vm->_groupMan->removeActiveGroup(AL0708_i_ActiveGroupIndex);
 					L0720_ui_MoveGroupResult = true;
 				} else {
 					if ((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_partyMapIndex) && (!L0721_B_GroupOnPartyMap)) { /* If the group arrives on the party map */
-						_vm->_groupMan->f183_addActiveGroup(thing, destMapX, destMapY);
+						_vm->_groupMan->addActiveGroup(thing, destMapX, destMapY);
 						L0720_ui_MoveGroupResult = true;
 					}
 				}
@@ -499,15 +499,15 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					f276_sensorProcessThingAdditionOrRemoval(destMapX, destMapY, thing, false, true);
 				}
 				if (L0720_ui_MoveGroupResult || (mapX < 0)) { /* If group moved from one map to another or if it was just placed on a square */
-					_vm->_groupMan->f180_startWanedring(destMapX, destMapY);
+					_vm->_groupMan->startWanedring(destMapX, destMapY);
 				}
 				_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
 				if (mapX >= 0) {
 					if (L0720_ui_MoveGroupResult > 1) { /* If the group behavior was C6_BEHAVIOR_ATTACK before being teleported from and to the party map */
-						_vm->_groupMan->f182_stopAttacking(&_vm->_groupMan->_g375_activeGroups[L0720_ui_MoveGroupResult - 2], mapX, mapY);
+						_vm->_groupMan->stopAttacking(&_vm->_groupMan->_activeGroups[L0720_ui_MoveGroupResult - 2], mapX, mapY);
 					} else {
 						if (L0720_ui_MoveGroupResult) { /* If the group was teleported or leaved the party map or entered the party map */
-							_vm->_groupMan->f181_groupDeleteEvents(mapX, mapY);
+							_vm->_groupMan->groupDeleteEvents(mapX, mapY);
 						}
 					}
 				}
@@ -575,7 +575,7 @@ bool MovesensMan::f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMa
 		L0701_ps_Group = (Group *)_vm->_dungeonMan->getThingData(thing);
 		for (AL0699_ui_Cell = k0_CellNorthWest, AL0700_B_CreatureAlive = false; AL0699_ui_Cell < k3_CellSouthWest + 1; AL0699_ui_Cell++) {
 			AL0700_B_CreatureAlive |= L0701_ps_Group->_health[AL0699_ui_Cell];
-			if (_vm->_groupMan->f176_getCreatureOrdinalInCell(L0701_ps_Group, AL0699_ui_Cell)) {
+			if (_vm->_groupMan->getCreatureOrdinalInCell(L0701_ps_Group, AL0699_ui_Cell)) {
 				L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = _vm->indexToOrdinal(AL0699_ui_Cell);
 			}
 		}
@@ -584,7 +584,7 @@ bool MovesensMan::f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMa
 		}
 	}
 	if ((destMapX >= 0) && ((abs(srcMapX - destMapX) + abs(srcMapY - destMapY)) == 1)) { /* If source and destination squares are adjacent (if party or group is not being teleported) */
-		AL0699_ui_PrimaryDirection = _vm->_groupMan->f228_getDirsWhereDestIsVisibleFromSource(srcMapX, srcMapY, destMapX, destMapY);
+		AL0699_ui_PrimaryDirection = _vm->_groupMan->getDirsWhereDestIsVisibleFromSource(srcMapX, srcMapY, destMapX, destMapY);
 		AL0700_i_SecondaryDirection = returnNextVal(AL0699_ui_PrimaryDirection);
 		for (int16 i = 0; i < 4; ++i)
 			L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[i] = 0;
@@ -704,7 +704,7 @@ int16 MovesensMan::f262_getTeleporterRotatedGroupResult(Teleporter* teleporter,
 
 	L0686_ps_Group = (Group *)_vm->_dungeonMan->getThingData(thing);
 	L0683_i_Rotation = teleporter->getRotation();
-	L0684_ui_GroupDirections = _vm->_groupMan->f147_getGroupDirections(L0686_ps_Group, mapIndex);
+	L0684_ui_GroupDirections = _vm->_groupMan->getGroupDirections(L0686_ps_Group, mapIndex);
 
 	L0689_B_AbsoluteRotation = teleporter->getAbsoluteRotation();
 	if (L0689_B_AbsoluteRotation) {
@@ -713,20 +713,20 @@ int16 MovesensMan::f262_getTeleporterRotatedGroupResult(Teleporter* teleporter,
 		L0685_ui_UpdatedGroupDirections = normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation);
 	}
 
-	L0687_ui_UpdatedGroupCells = _vm->_groupMan->f145_getGroupCells(L0686_ps_Group, mapIndex);
+	L0687_ui_UpdatedGroupCells = _vm->_groupMan->getGroupCells(L0686_ps_Group, mapIndex);
 	if (L0687_ui_UpdatedGroupCells != k255_CreatureTypeSingleCenteredCreature) {
 		L0690_ui_GroupCells = L0687_ui_UpdatedGroupCells;
 		L0691_i_CreatureSize = getFlag(g243_CreatureInfo[L0686_ps_Group->_type]._attributes, k0x0003_MaskCreatureInfo_size);
 		L0692_i_RelativeRotation = normalizeModulo4(4 + L0685_ui_UpdatedGroupDirections - L0684_ui_GroupDirections);
 		for (L0688_i_CreatureIndex = 0; L0688_i_CreatureIndex <= L0686_ps_Group->getCount(); L0688_i_CreatureIndex++) {
-			L0685_ui_UpdatedGroupDirections = _vm->_groupMan->f178_getGroupValueUpdatedWithCreatureValue(L0685_ui_UpdatedGroupDirections, L0688_i_CreatureIndex, L0689_B_AbsoluteRotation ? L0683_i_Rotation : normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation));
+			L0685_ui_UpdatedGroupDirections = _vm->_groupMan->getGroupValueUpdatedWithCreatureValue(L0685_ui_UpdatedGroupDirections, L0688_i_CreatureIndex, L0689_B_AbsoluteRotation ? L0683_i_Rotation : normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation));
 			if (L0691_i_CreatureSize == k0_MaskCreatureSizeQuarter) {
 				L0692_i_RelativeRotation = !L0689_B_AbsoluteRotation;
 				if (L0692_i_RelativeRotation) 
 					L0692_i_RelativeRotation = L0683_i_Rotation;
 			}
 			if (L0692_i_RelativeRotation) {
-				L0687_ui_UpdatedGroupCells = _vm->_groupMan->f178_getGroupValueUpdatedWithCreatureValue(L0687_ui_UpdatedGroupCells, L0688_i_CreatureIndex, normalizeModulo4(L0690_ui_GroupCells + L0692_i_RelativeRotation));
+				L0687_ui_UpdatedGroupCells = _vm->_groupMan->getGroupValueUpdatedWithCreatureValue(L0687_ui_UpdatedGroupCells, L0688_i_CreatureIndex, normalizeModulo4(L0690_ui_GroupCells + L0692_i_RelativeRotation));
 			}
 			L0684_ui_GroupDirections >>= 2;
 			L0690_ui_GroupCells >>= 2;
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 4fdda2e..8ef4013 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -170,7 +170,7 @@ T0217004:
 			return false;
 		}
 		L0488_i_Attack = f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing) + 1;
-		_vm->_groupMan->f232_groupIsDoorDestoryedByAttack(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, L0488_i_Attack + _vm->getRandomNumber(L0488_i_Attack), false, 0);
+		_vm->_groupMan->groupIsDoorDestoryedByAttack(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, L0488_i_Attack + _vm->getRandomNumber(L0488_i_Attack), false, 0);
 		break;
 	case kM2_ChampionElemType:
 		if ((AP0456_i_ChampionIndex = _vm->_championMan->getIndexInCell(cell)) < 0) {
@@ -179,8 +179,8 @@ T0217004:
 		L0489_i_ChampionAttack = L0488_i_Attack = f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing);
 		break;
 	case kM1_CreatureElemType:
-		L0491_ps_Group = (Group *)_vm->_dungeonMan->getThingData(_vm->_groupMan->f175_groupGetThing(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY));
-		if (!(L0512_ui_CreatureIndex = _vm->_groupMan->f176_getCreatureOrdinalInCell(L0491_ps_Group, cell))) {
+		L0491_ps_Group = (Group *)_vm->_dungeonMan->getThingData(_vm->_groupMan->groupGetThing(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY));
+		if (!(L0512_ui_CreatureIndex = _vm->_groupMan->getCreatureOrdinalInCell(L0491_ps_Group, cell))) {
 			return false;
 		}
 		L0512_ui_CreatureIndex--;
@@ -195,8 +195,8 @@ T0217004:
 		}
 		L0488_i_Attack = (uint16)((unsigned long)f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing) << 6) / L0493_ps_CreatureInfo->_defense;
 		if (L0488_i_Attack) {
-			if ((AL0487_i_Outcome = _vm->_groupMan->f190_groupGetDamageCreatureOutcome(L0491_ps_Group, L0512_ui_CreatureIndex, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, L0488_i_Attack + _vm->_groupMan->f192_groupGetResistanceAdjustedPoisonAttack(L0511_ui_CreatureType, _g366_projectilePoisonAttack), true)) != k0_outcomeKilledNoCreaturesInGroup) {
-				_vm->_groupMan->f209_processEvents29to41(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, kM2_TMEventTypeCreateReactionEvent30HitByProjectile, 0);
+			if ((AL0487_i_Outcome = _vm->_groupMan->groupGetDamageCreatureOutcome(L0491_ps_Group, L0512_ui_CreatureIndex, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, L0488_i_Attack + _vm->_groupMan->groupGetResistanceAdjustedPoisonAttack(L0511_ui_CreatureType, _g366_projectilePoisonAttack), true)) != k0_outcomeKilledNoCreaturesInGroup) {
+				_vm->_groupMan->processEvents29to41(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, kM2_TMEventTypeCreateReactionEvent30HitByProjectile, 0);
 			}
 			_g364_creatureDamageOutcome = AL0487_i_Outcome;
 			if (!L0505_B_CreateExplosionOnImpact &&
@@ -350,7 +350,7 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 			if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (AP0443_ui_ProjectileMapX == _vm->_dungeonMan->_partyMapX) && (AP0444_ui_ProjectileMapY == _vm->_dungeonMan->_partyMapY)) {
 				_vm->_championMan->getDamagedChampionCount(attack, k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand | k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k1_attackType_FIRE);
 			} else {
-				if ((L0473_T_Thing = _vm->_groupMan->f175_groupGetThing(AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY)) != Thing::_endOfList) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
+				if ((L0473_T_Thing = _vm->_groupMan->groupGetThing(AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY)) != Thing::_endOfList) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
 					Group *L0472_ps_Group = (Group *)_vm->_dungeonMan->getThingData(L0473_T_Thing);
 					CreatureInfo *L0471_ps_CreatureInfo = &g243_CreatureInfo[L0472_ps_Group->_type];
 					int16 L0469_i_CreatureFireResistance = L0471_ps_CreatureInfo->getFireResistance();
@@ -359,7 +359,7 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 							attack >>= 2;
 						}
 						if ((attack -= _vm->getRandomNumber((L0469_i_CreatureFireResistance << 1) + 1)) > 0) {
-							_g364_creatureDamageOutcome = _vm->_groupMan->f191_getDamageAllCreaturesOutcome(L0472_ps_Group, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, attack, true);
+							_g364_creatureDamageOutcome = _vm->_groupMan->getDamageAllCreaturesOutcome(L0472_ps_Group, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, attack, true);
 						}
 					}
 				}
@@ -450,7 +450,7 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 		if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0523_i_DestinationMapX == _vm->_dungeonMan->_partyMapX) && (L0524_i_DestinationMapY == _vm->_dungeonMan->_partyMapY) && f217_projectileHasImpactOccurred(kM2_ChampionElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
 			return;
 		}
-		if ((_vm->_groupMan->f175_groupGetThing(L0523_i_DestinationMapX, L0524_i_DestinationMapY) != Thing::_endOfList) && f217_projectileHasImpactOccurred(kM1_CreatureElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
+		if ((_vm->_groupMan->groupGetThing(L0523_i_DestinationMapX, L0524_i_DestinationMapY) != Thing::_endOfList) && f217_projectileHasImpactOccurred(kM1_CreatureElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
 			return;
 		}
 		if (L0520_ps_Projectile->_kineticEnergy <= (AL0516_ui_StepEnergy = L0519_ps_Event->_C._projectile.getStepEnergy())) {
@@ -534,7 +534,7 @@ void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) {
 	L0532_ps_Explosion = &((Explosion*)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[Thing((event->_C._slot)).getIndex()];
 	AL0531_i_SquareType = Square(_vm->_dungeonMan->_currMapData[L0528_ui_MapX][L0529_ui_MapY]).getType();
 	L0538_B_ExplosionOnPartySquare = (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0528_ui_MapX == _vm->_dungeonMan->_partyMapX) && (L0529_ui_MapY == _vm->_dungeonMan->_partyMapY);
-	if ((L0535_T_GroupThing = _vm->_groupMan->f175_groupGetThing(L0528_ui_MapX, L0529_ui_MapY)) != Thing::_endOfList) {
+	if ((L0535_T_GroupThing = _vm->_groupMan->groupGetThing(L0528_ui_MapX, L0529_ui_MapY)) != Thing::_endOfList) {
 		L0533_ps_Group = (Group*)_vm->_dungeonMan->getThingData(L0535_T_GroupThing);
 		L0534_ps_CreatureInfo = &g243_CreatureInfo[AL0537_ui_CreatureType = L0533_ps_Group->_type];
 	}
@@ -552,7 +552,7 @@ void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) {
 			break;
 	case 0xFF80:
 		if (AL0531_i_SquareType == k4_DoorElemType) {
-			_vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true, 0);
+			_vm->_groupMan->groupIsDoorDestoryedByAttack(L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true, 0);
 		}
 		break;
 	case 0xFF83:
@@ -563,12 +563,12 @@ void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) {
 				AL0537_ui_NonMaterialAdditionalAttack++;
 				AL0531_i_CreatureCount = L0533_ps_Group->getCount();
 				do {
-					if (getFlag(_vm->_groupMan->_g375_activeGroups[L0533_ps_Group->getActiveGroupIndex()]._aspect[AL0531_i_CreatureCount], k0x0080_MaskActiveGroupIsAttacking)) { /* Materializer / Zytaz can only be damaged while they are attacking */
-						_vm->_groupMan->f190_groupGetDamageCreatureOutcome(L0533_ps_Group, AL0531_i_CreatureCount, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack + _vm->getRandomNumber(AL0537_ui_NonMaterialAdditionalAttack) + _vm->getRandomNumber(4), true);
+					if (getFlag(_vm->_groupMan->_activeGroups[L0533_ps_Group->getActiveGroupIndex()]._aspect[AL0531_i_CreatureCount], k0x0080_MaskActiveGroupIsAttacking)) { /* Materializer / Zytaz can only be damaged while they are attacking */
+						_vm->_groupMan->groupGetDamageCreatureOutcome(L0533_ps_Group, AL0531_i_CreatureCount, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack + _vm->getRandomNumber(AL0537_ui_NonMaterialAdditionalAttack) + _vm->getRandomNumber(4), true);
 					}
 				} while (--AL0531_i_CreatureCount >= 0);
 			} else {
-				_vm->_groupMan->f191_getDamageAllCreaturesOutcome(L0533_ps_Group, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true);
+				_vm->_groupMan->getDamageAllCreaturesOutcome(L0533_ps_Group, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true);
 			}
 		}
 		break;
@@ -586,8 +586,8 @@ void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) {
 		if (L0538_B_ExplosionOnPartySquare) {
 			_vm->_championMan->getDamagedChampionCount(L0530_i_Attack, k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
 		} else {
-			if ((L0535_T_GroupThing != Thing::_endOfList) && (L0530_i_Attack = _vm->_groupMan->f192_groupGetResistanceAdjustedPoisonAttack(AL0537_ui_CreatureType, L0530_i_Attack)) && (_vm->_groupMan->f191_getDamageAllCreaturesOutcome(L0533_ps_Group, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true) != k2_outcomeKilledAllCreaturesInGroup) && (L0530_i_Attack > 2)) {
-				_vm->_groupMan->f209_processEvents29to41(L0528_ui_MapX, L0529_ui_MapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
+			if ((L0535_T_GroupThing != Thing::_endOfList) && (L0530_i_Attack = _vm->_groupMan->groupGetResistanceAdjustedPoisonAttack(AL0537_ui_CreatureType, L0530_i_Attack)) && (_vm->_groupMan->getDamageAllCreaturesOutcome(L0533_ps_Group, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true) != k2_outcomeKilledAllCreaturesInGroup) && (L0530_i_Attack > 2)) {
+				_vm->_groupMan->processEvents29to41(L0528_ui_MapX, L0529_ui_MapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
 			}
 		}
 		if (L0532_ps_Explosion->getAttack() >= 6) {
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index b1a60da..1e19c22 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -277,7 +277,7 @@ void Timeline::f261_processTimeline() {
 		_vm->_dungeonMan->setCurrentMap(getMap(L0682_s_Event._mapTime));
 		AL0680_ui_EventType = L0682_s_Event._type;
 		if ((AL0680_ui_EventType > (k29_TMEventTypeGroupReactionDangerOnSquare - 1)) && (AL0680_ui_EventType < (k41_TMEventTypeUpdateBehaviour_3 + 1))) {
-			_vm->_groupMan->f209_processEvents29to41(L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, AL0680_ui_EventType, L0682_s_Event._C._ticks);
+			_vm->_groupMan->processEvents29to41(L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, AL0680_ui_EventType, L0682_s_Event._C._ticks);
 		} else {
 			switch (AL0680_ui_EventType) {
 			case k48_TMEventTypeMoveProjectileIgnoreImpacts:
@@ -428,10 +428,10 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 			f238_addEventGetEventIndex(event);
 			return;
 		}
-		if (((L0599_T_GroupThing = _vm->_groupMan->f175_groupGetThing(L0593_ui_MapX, L0594_ui_MapY)) != Thing::_endOfList) && !getFlag(L0600_ui_CreatureAttributes = _vm->_dungeonMan->getCreatureAttributes(L0599_T_GroupThing), k0x0040_MaskCreatureInfo_nonMaterial)) {
+		if (((L0599_T_GroupThing = _vm->_groupMan->groupGetThing(L0593_ui_MapX, L0594_ui_MapY)) != Thing::_endOfList) && !getFlag(L0600_ui_CreatureAttributes = _vm->_dungeonMan->getCreatureAttributes(L0599_T_GroupThing), k0x0040_MaskCreatureInfo_nonMaterial)) {
 			if (L0596_i_DoorState >= (AL0602_ui_Height ? CreatureInfo::getHeight(L0600_ui_CreatureAttributes) : 1)) { /* Creature height or 1 */
-				if (_vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group*)_vm->_dungeonMan->getThingData(L0599_T_GroupThing), L0593_ui_MapX, L0594_ui_MapY, 5, true) != k2_outcomeKilledAllCreaturesInGroup) {
-					_vm->_groupMan->f209_processEvents29to41(L0593_ui_MapX, L0594_ui_MapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
+				if (_vm->_groupMan->getDamageAllCreaturesOutcome((Group*)_vm->_dungeonMan->getThingData(L0599_T_GroupThing), L0593_ui_MapX, L0594_ui_MapY, 5, true) != k2_outcomeKilledAllCreaturesInGroup) {
+					_vm->_groupMan->processEvents29to41(L0593_ui_MapX, L0594_ui_MapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
 				}
 				L0596_i_DoorState = (L0596_i_DoorState == k0_doorState_OPEN) ? k0_doorState_OPEN : (L0596_i_DoorState - 1);
 				L0597_puc_Square->setDoorState(L0596_i_DoorState);
@@ -481,7 +481,7 @@ void Timeline::f242_timelineProcessEvent7_squareFakewall(TimelineEvent* event) {
 			event->_mapTime++;
 			f238_addEventGetEventIndex(event);
 		} else {
-			if (((L0606_T_Thing = _vm->_groupMan->f175_groupGetThing(L0603_ui_MapX, L0604_ui_MapY)) != Thing::_endOfList) && !getFlag(_vm->_dungeonMan->getCreatureAttributes(L0606_T_Thing), k0x0040_MaskCreatureInfo_nonMaterial)) {
+			if (((L0606_T_Thing = _vm->_groupMan->groupGetThing(L0603_ui_MapX, L0604_ui_MapY)) != Thing::_endOfList) && !getFlag(_vm->_dungeonMan->getCreatureAttributes(L0606_T_Thing), k0x0040_MaskCreatureInfo_nonMaterial)) {
 				event->_mapTime++;
 				f238_addEventGetEventIndex(event);
 			} else {
@@ -557,7 +557,7 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 		_vm->_moveSens->f267_getMoveResult(Thing::_party, mapX, mapY, mapX, mapY);
 		_vm->_championMan->drawChangedObjectIcons();
 	}
-	if ((L0645_T_Thing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) != Thing::_endOfList) {
+	if ((L0645_T_Thing = _vm->_groupMan->groupGetThing(mapX, mapY)) != Thing::_endOfList) {
 		_vm->_moveSens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
 	}
 	L0645_T_Thing = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
@@ -838,7 +838,7 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 					if (AL0618_ui_HealthMultiplier == 0) {
 						AL0618_ui_HealthMultiplier = _vm->_dungeonMan->_currMap->_difficulty;
 					}
-					_vm->_groupMan->f185_groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (Direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY);
+					_vm->_groupMan->groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (Direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY);
 					if (L0614_ps_Sensor->getAttrAudibleA()) {
 						_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0616_ui_MapX, L0617_ui_MapY, k1_soundModePlayIfPrioritized);
 					}
@@ -878,7 +878,7 @@ void Timeline::f252_timelineProcessEvents60to61_moveGroup(TimelineEvent* event)
 	L0657_ui_MapY = event->_B._location._mapY;
 	L0657_ui_MapY = event->_B._location._mapY;
 T0252001:
-	if (((_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex) || (L0656_ui_MapX != _vm->_dungeonMan->_partyMapX) || (L0657_ui_MapY != _vm->_dungeonMan->_partyMapY)) && (_vm->_groupMan->f175_groupGetThing(L0656_ui_MapX, L0657_ui_MapY) == Thing::_endOfList)) { /* BUG0_24 Lord Chaos may teleport into one of the Black Flames and become invisible until the Black Flame is killed. In this case, _vm->_groupMan->f175_groupGetThing returns the Black Flame thing and the Lord Chaos thing is not moved into the dungeon until the Black Flame is killed */
+	if (((_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex) || (L0656_ui_MapX != _vm->_dungeonMan->_partyMapX) || (L0657_ui_MapY != _vm->_dungeonMan->_partyMapY)) && (_vm->_groupMan->groupGetThing(L0656_ui_MapX, L0657_ui_MapY) == Thing::_endOfList)) { /* BUG0_24 Lord Chaos may teleport into one of the Black Flames and become invisible until the Black Flame is killed. In this case, _vm->_groupMan->f175_groupGetThing returns the Black Flame thing and the Lord Chaos thing is not moved into the dungeon until the Black Flame is killed */
 		if (event->_type == k61_TMEventTypeMoveGroupAudible) {
 			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0656_ui_MapX, L0657_ui_MapY, k1_soundModePlayIfPrioritized);
 		}
@@ -901,7 +901,7 @@ T0252001:
 				case 3:
 					L0657_ui_MapY++;
 				}
-				if (_vm->_groupMan->f223_isSquareACorridorTeleporterPitOrDoor(L0656_ui_MapX, L0657_ui_MapY))
+				if (_vm->_groupMan->isSquareACorridorTeleporterPitOrDoor(L0656_ui_MapX, L0657_ui_MapY))
 					goto T0252001;
 			}
 		}


Commit: 5b05f3cff40aea2434e38d574959c07927434c88
    https://github.com/scummvm/scummvm/commit/5b05f3cff40aea2434e38d574959c07927434c88
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rename members of InventoryMan

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index f21d4c5..e841633 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -457,7 +457,7 @@ void ChampionMan::drawChangedObjectIcons() {
 	ObjectMan &objMan = *_vm->_objectMan;
 	MenuMan &menuMan = *_vm->_menuMan;
 
-	uint16 invChampOrdinal = invMan._g432_inventoryChampionOrdinal;
+	uint16 invChampOrdinal = invMan._inventoryChampionOrdinal;
 	if (_candidateChampionOrdinal && !invChampOrdinal)
 		return;
 
@@ -503,8 +503,8 @@ void ChampionMan::drawChangedObjectIcons() {
 			}
 		}
 
-		if (invMan._g424_panelContent == k4_PanelContentChest) {
-			thing = invMan._g425_chestSlots;
+		if (invMan._panelContent == k4_PanelContentChest) {
+			thing = invMan._chestSlots;
 			for (int16 slotIndex = 0; slotIndex < 8; ++slotIndex, thing++) {
 				drawViewport |= (hasObjectIconInSlotBoxChanged(slotIndex + k38_SlotBoxChestFirstSlot, *thing) ? 1 : 0);
 			}
@@ -532,7 +532,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 	Champion *champ = &_champions[champIndex];
 
 	if (slotIndex >= k30_ChampionSlotChest_1) {
-		invMan._g425_chestSlots[slotIndex - k30_ChampionSlotChest_1] = thing;
+		invMan._chestSlots[slotIndex - k30_ChampionSlotChest_1] = thing;
 	} else {
 		champ->setSlot(slotIndex, thing);
 	}
@@ -540,7 +540,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 	champ->_load += dunMan.getObjectWeight(thing);
 	champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
 	IconIndice iconIndex = objMan.f33_getIconIndex(thing);
-	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal);
+	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
 	applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
 	uint16 *rawObjPtr = dunMan.getThingData(thing);
 
@@ -558,7 +558,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 
 		if (iconIndex == k4_IconIndiceWeaponTorchUnlit) {
 			((Weapon *)rawObjPtr)->setLit(true);
-			_vm->_inventoryMan->f337_setDungeonViewPalette();
+			_vm->_inventoryMan->setDungeonViewPalette();
 			drawChangedObjectIcons();
 		} else if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand) &&
 			((iconIndex == k144_IconIndiceContainerChestClosed) || ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)))) {
@@ -568,7 +568,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 		if ((iconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (iconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
 			((Junk *)rawObjPtr)->setChargeCount(1);
 			_party._magicalLightAmount += _lightPowerToLightAmount[2];
-			_vm->_inventoryMan->f337_setDungeonViewPalette();
+			_vm->_inventoryMan->setDungeonViewPalette();
 			iconIndex = (IconIndice)(iconIndex + 1);
 		} else if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
 			((Junk *)rawObjPtr)->setChargeCount(1);
@@ -665,8 +665,8 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 	Thing curThing;
 
 	if (slotIndex >= k30_ChampionSlotChest_1) {
-		curThing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
-		_vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1] = Thing::_none;
+		curThing = _vm->_inventoryMan->_chestSlots[slotIndex - k30_ChampionSlotChest_1];
+		_vm->_inventoryMan->_chestSlots[slotIndex - k30_ChampionSlotChest_1] = Thing::_none;
 	} else {
 		curThing = curChampion->_slots[slotIndex];
 		curChampion->_slots[slotIndex] = Thing::_none;
@@ -675,7 +675,7 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 	if (curThing == Thing::_none)
 		return Thing::_none;
 
-	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal);
 	int16 curIconIndex = _vm->_objectMan->f33_getIconIndex(curThing);
 	// Remove object modifiers
 	applyModifiersToStatistics(curChampion, slotIndex, curIconIndex, -1, curThing);
@@ -685,7 +685,7 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 		if ((curIconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (curIconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
 			((Junk *)curWeapon)->setChargeCount(0);
 			_party._magicalLightAmount -= _lightPowerToLightAmount[2];
-			_vm->_inventoryMan->f337_setDungeonViewPalette();
+			_vm->_inventoryMan->setDungeonViewPalette();
 		} else if ((curIconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (curIconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
 			((Junk *)curWeapon)->setChargeCount(0);
 		}
@@ -709,14 +709,14 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 
 		if ((curIconIndex >= k4_IconIndiceWeaponTorchUnlit) && (curIconIndex <= k7_IconIndiceWeaponTorchLit)) {
 			curWeapon->setLit(false);
-			_vm->_inventoryMan->f337_setDungeonViewPalette();
+			_vm->_inventoryMan->setDungeonViewPalette();
 			drawChangedObjectIcons();
 		}
 
 		if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand)) {
 			switch (curIconIndex) {
 			case k144_IconIndiceContainerChestClosed:
-				_vm->_inventoryMan->f334_closeChest();
+				_vm->_inventoryMan->closeChest();
 			// No break on purpose
 			case k30_IconIndiceScrollOpen:
 			case k31_IconIndiceScrollClosed:
@@ -1108,7 +1108,7 @@ void ChampionMan::championPoison(int16 champIndex, uint16 attack) {
 	Champion *curChampion = &_champions[champIndex];
 	addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
 	setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
-	if ((_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) && (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
+	if ((_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) && (_vm->_inventoryMan->_panelContent == k0_PanelContentFoodWaterPoisoned)) {
 		setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel);
 	}
 
@@ -1299,19 +1299,19 @@ void ChampionMan::clickOnSlotBox(uint16 slotBoxIndex) {
 			return;
 
 		champIndex = slotBoxIndex >> 1;
-		if ((champIndex >= _partyChampionCount) || (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_champions[champIndex]._currHealth)
+		if ((champIndex >= _partyChampionCount) || (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) || !_champions[champIndex]._currHealth)
 			return;
 
 		slotIndex = getHandSlotIndex(slotBoxIndex);
 	} else {
-		champIndex = _vm->ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+		champIndex = _vm->ordinalToIndex(_vm->_inventoryMan->_inventoryChampionOrdinal);
 		slotIndex = slotBoxIndex - k8_SlotBoxInventoryFirstSlot;
 	}
 
 	Thing leaderHandObject = _leaderHandObject;
 	Thing slotThing;
 	if (slotIndex >= k30_ChampionSlotChest_1) {
-		slotThing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
+		slotThing = _vm->_inventoryMan->_chestSlots[slotIndex - k30_ChampionSlotChest_1];
 	} else {
 		slotThing = _champions[champIndex]._slots[slotIndex];
 	}
@@ -1397,7 +1397,7 @@ void ChampionMan::applyAndDrawPendingDamageAndWounds() {
 			blitBox._y1 = 0;
 			_vm->_eventMan->showMouse();
 
-			if (_vm->indexToOrdinal(championIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+			if (_vm->indexToOrdinal(championIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) {
 				blitBox._y2 = 28;
 				blitBox._x1 = textPosX + 7;
 				blitBox._x2 = blitBox._x1 + 31; /* Box is over the champion portrait in the status box */
@@ -1450,7 +1450,7 @@ void ChampionMan::championKill(uint16 champIndex) {
 	Champion *curChampion = &_champions[champIndex];
 	curChampion->_currHealth = 0;
 	setFlag(curChampion->_attributes, k0x1000_ChampionAttributeStatusBox);
-	if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+	if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) {
 		if (_vm->_pressingEye) {
 			_vm->_pressingEye = false;
 			_vm->_eventMan->_ignoreMouseMovements = false;
@@ -1465,7 +1465,7 @@ void ChampionMan::championKill(uint16 champIndex) {
 			_vm->_eventMan->_hideMousePointerRequestCount = 1;
 			_vm->_eventMan->hideMouse();
 		}
-		_vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
+		_vm->_inventoryMan->toggleInventory(k4_ChampionCloseInventory);
 	}
 	dropAllObjects(champIndex);
 	Thing unusedThing = _vm->_dungeonMan->getUnusedThing(k0x8000_championBones | k10_JunkThingType);
@@ -1684,8 +1684,8 @@ void ChampionMan::applyTimeEffects() {
 				setFlag(championPtr->_attributes, k0x0400_ChampionAttributeIcon);
 			}
 			setFlag(championPtr->_attributes, k0x0100_ChampionAttributeStatistics);
-			if (_vm->indexToOrdinal(championIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
-				if (_vm->_pressingMouth || _vm->_pressingEye || (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
+			if (_vm->indexToOrdinal(championIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) {
+				if (_vm->_pressingMouth || _vm->_pressingEye || (_vm->_inventoryMan->_panelContent == k0_PanelContentFoodWaterPoisoned)) {
 					setFlag(championPtr->_attributes, k0x0800_ChampionAttributePanel);
 				}
 			}
@@ -2027,7 +2027,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 		}
 		curThing = _vm->_dungeonMan->getNextThing(curThing);
 	}
-	_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)previousPartyChampionCount);
+	_vm->_inventoryMan->toggleInventory((ChampionIndex)previousPartyChampionCount);
 	_vm->_menuMan->f456_drawDisabledMenu();;
 }
 
@@ -2119,7 +2119,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	if (!getFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand))
 		return;
 
-	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal);
+	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal);
 	_vm->_displayMan->_useByteBoxCoordinates = false;
 	_vm->_eventMan->showMouse();
 	if (getFlag(championAttributes, k0x1000_ChampionAttributeStatusBox)) {
@@ -2148,7 +2148,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 				_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(nativeBitmapIndices[borderCount]), &box, k40_byteWidth, k10_ColorFlesh, 29);
 
 			if (isInventoryChampion) {
-				_vm->_inventoryMan->f354_drawStatusBoxPortrait(champIndex);
+				_vm->_inventoryMan->drawStatusBoxPortrait(champIndex);
 				setFlag(championAttributes, k0x0100_ChampionAttributeStatistics);
 			} else
 				setFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand);
@@ -2262,12 +2262,12 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	}
 	if (getFlag(championAttributes, k0x0800_ChampionAttributePanel) && isInventoryChampion) {
 		if (_vm->_pressingMouth)
-			_vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned();
+			_vm->_inventoryMan->drawPanelFoodWaterPoisoned();
 		else if (_vm->_pressingEye) {
 			if (_leaderEmptyHanded)
-				_vm->_inventoryMan->f351_drawChampionSkillsAndStatistics();
+				_vm->_inventoryMan->drawChampionSkillsAndStatistics();
 		} else
-			_vm->_inventoryMan->f347_drawPanel();
+			_vm->_inventoryMan->drawPanel();
 
 		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
@@ -2297,7 +2297,7 @@ void ChampionMan::drawHealthStaminaManaValues(Champion* champ) {
 void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 	int16 nativeBitmapIndex = -1;
 	Champion *champ = &_champions[champIndex];
-	bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex));
+	bool isInventoryChamp = (_vm->_inventoryMan->_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex));
 
 	uint16 slotBoxIndex;
 	if (!isInventoryChamp) {
@@ -2310,7 +2310,7 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 
 	Thing thing;
 	if (slotIndex >= k30_ChampionSlotChest_1)
-		thing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1];
+		thing = _vm->_inventoryMan->_chestSlots[slotIndex - k30_ChampionSlotChest_1];
 	else
 		thing = champ->getSlot((ChampionSlot)slotIndex);
 
@@ -2388,7 +2388,7 @@ void ChampionMan::renameChampion(Champion* champ) {
 	displayBox._x2 = displayBox._x1 + 167;
 
 	_vm->_displayMan->fillBoxBitmap(_vm->_displayMan->_bitmapViewport, displayBox, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
-	_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), _vm->_inventoryMan->g32_BoxPanel, k72_byteWidth, k4_ColorCyan, 73);
+	_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), _vm->_inventoryMan->_boxPanel, k72_byteWidth, k4_ColorCyan, 73);
 	_vm->_textMan->f52_printToViewport(177, 58, k13_ColorLightestGray, "_______");
 	_vm->_textMan->f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________");
 	_vm->_eventMan->showMouse();
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 7f439a2..ed27dca 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -369,7 +369,7 @@ void DMEngine::processNewPartyMap(uint16 mapIndex) {
 	_dungeonMan->setCurrentMapAndPartyMap(mapIndex);
 	_displayMan->loadCurrentMapGraphics();
 	_groupMan->addAllActiveGroups();
-	_inventoryMan->f337_setDungeonViewPalette();
+	_inventoryMan->setDungeonViewPalette();
 }
 
 Common::Error DMEngine::run() {
@@ -449,7 +449,7 @@ void DMEngine::gameloop() {
 				break;
 		}
 
-		if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) {
+		if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) {
 			Box box(0, 223, 0, 135);
 			_displayMan->fillBoxBitmap(_displayMan->_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // (possibly dummy code)
 			_displayMan->drawDungeon(_dungeonMan->_partyDir, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
@@ -476,7 +476,7 @@ void DMEngine::gameloop() {
 		_gameTime++;
 
 		if (!(_gameTime & 511))
-			_inventoryMan->f338_decreaseTorchesLightPower();
+			_inventoryMan->decreaseTorchesLightPower();
 
 		if (_championMan->_party._freezeLifeTicks)
 			_championMan->_party._freezeLifeTicks -= 1;
@@ -501,11 +501,11 @@ void DMEngine::gameloop() {
 			if (_stopPressingEye) {
 				_pressingEye = false;
 				_stopPressingEye = false;
-				_inventoryMan->f353_drawStopPressingEye();
+				_inventoryMan->drawStopPressingEye();
 			} else if (_stopPressingMouth) {
 				_pressingMouth = false;
 				_stopPressingMouth = false;
-				_inventoryMan->f350_drawStopPressingMouth();
+				_inventoryMan->drawStopPressingMouth();
 			}
 
 			_eventMan->processCommandQueue();
@@ -679,7 +679,7 @@ void DMEngine::endGame(bool doNotDrawCreditsOnly) {
 						continue;
 
 					char displStr[20];
-					strcpy(displStr, _inventoryMan->G0428_apc_SkillLevelNames[skillLevel - 2]);
+					strcpy(displStr, _inventoryMan->_skillLevelNames[skillLevel - 2]);
 					strcat(displStr, " ");
 					strcat(displStr, _championMan->_baseSkillName[idx]);
 					_textMan->f443_endgamePrintString(105, textPosY = textPosY + 8, k13_ColorLightestGray, displStr);
@@ -960,12 +960,12 @@ void DMEngine::fuseSequnce() {
 
 
 	_gameWon = true;
-	if (_inventoryMan->_g432_inventoryChampionOrdinal) {
-		_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
+	if (_inventoryMan->_inventoryChampionOrdinal) {
+		_inventoryMan->toggleInventory(k4_ChampionCloseInventory);
 	}
 	_eventMan->highlightBoxDisable();
 	_championMan->_party._magicalLightAmount = 200;
-	_inventoryMan->f337_setDungeonViewPalette();
+	_inventoryMan->setDungeonViewPalette();
 	_championMan->_party._fireShieldDefense = _championMan->_party._spellShieldDefense = _championMan->_party._shieldDefense = 100;
 	_timeline->f260_timelineRefreshAllChampionStatusBoxes();
 	fuseSequenceUpdate();
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index b627549..8e9142e 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -539,7 +539,7 @@ void EventManager::buildpointerScreenArea(int16 mousePosX, int16 mousePosY) {
 			_mousePointerType = k4_pointerTypeAutoselect;
 		else {
 			championIdx++;
-			if (championIdx == _vm->_inventoryMan->_g432_inventoryChampionOrdinal)
+			if (championIdx == _vm->_inventoryMan->_inventoryChampionOrdinal)
 				_mousePointerType = k0_pointerTypeArrow;
 			else if (mousePosY <= 6)
 				_mousePointerType = k0_pointerTypeArrow;
@@ -780,14 +780,14 @@ void EventManager::processCommandQueue() {
 
 		int16 championIndex = cmdType - k7_CommandToggleInventoryChampion_0;
 		if (((championIndex == k4_ChampionCloseInventory) || (championIndex < _vm->_championMan->_partyChampionCount)) && !_vm->_championMan->_candidateChampionOrdinal)
-			_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)championIndex);
+			_vm->_inventoryMan->toggleInventory((ChampionIndex)championIndex);
 
 		return;
 	}
 
 	if (cmdType == k83_CommandToggleInventoryLeader) {
 		if (_vm->_championMan->_leaderIndex != kM1_ChampionNone)
-			_vm->_inventoryMan->f355_toggleInventory(_vm->_championMan->_leaderIndex);
+			_vm->_inventoryMan->toggleInventory(_vm->_championMan->_leaderIndex);
 
 		return;
 	}
@@ -807,12 +807,12 @@ void EventManager::processCommandQueue() {
 	}
 
 	if (cmdType == k70_CommandClickOnMouth) {
-		_vm->_inventoryMan->f349_processCommand70_clickOnMouth();
+		_vm->_inventoryMan->clickOnMouth();
 		return;
 	}
 
 	if (cmdType == k71_CommandClickOnEye) {
-		_vm->_inventoryMan->f352_processCommand71_clickOnEye();
+		_vm->_inventoryMan->clickOnEye();
 		return;
 	}
 
@@ -830,8 +830,8 @@ void EventManager::processCommandQueue() {
 
 	if (cmdType == k145_CommandSleep) {
 		if (!_vm->_championMan->_candidateChampionOrdinal) {
-			if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal)
-				_vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
+			if (_vm->_inventoryMan->_inventoryChampionOrdinal)
+				_vm->_inventoryMan->toggleInventory(k4_ChampionCloseInventory);
 
 			_vm->_menuMan->f456_drawDisabledMenu();
 			_vm->_championMan->_partyIsSleeping = true;
@@ -1234,7 +1234,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	uint16 championIndex = champMan._partyChampionCount - 1;
 	Champion *champ = &champMan._champions[championIndex];
 	if (commandType == k162_CommandClickInPanelCancel) {
-		invMan.f355_toggleInventory(k4_ChampionCloseInventory);
+		invMan.toggleInventory(k4_ChampionCloseInventory);
 		champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 		if (champMan._partyChampionCount == 1) {
 			commandSetLeader(kM1_ChampionNone);
@@ -1309,7 +1309,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 		break;
 	}
 
-	invMan.f355_toggleInventory(k4_ChampionCloseInventory);
+	invMan.toggleInventory(k4_ChampionCloseInventory);
 	_vm->_menuMan->f457_drawEnabledMenus();
 	setMousePointerToNormal((_vm->_championMan->_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
 }
@@ -1319,7 +1319,7 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) {
 	InventoryMan &invMan = *_vm->_inventoryMan;
 
 	CommandType commandType;
-	switch (invMan._g424_panelContent) {
+	switch (invMan._panelContent) {
 	case k4_PanelContentChest:
 		if (champMan._leaderIndex == kM1_ChampionNone) // if no leader
 			return;
@@ -1436,7 +1436,7 @@ void EventManager::commandTakeStairs(bool stairsGoDown) {
 }
 
 void EventManager::commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX, int16 posY) {
-	if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+	if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) {
 		commandSetLeader((ChampionIndex)champIndex);
 	} else {
 		uint16 commandType = getCommandTypeFromMouseInput(_mouseInputChampionNamesHands, Common::Point(posX, posY), k1_LeftMouseButton);
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 8e12d9c..36d09bb 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -63,27 +63,27 @@ void InventoryMan::initConstants() {
 		break;
 	}
 	for (int i = 0; i < 15; ++i)
-		G0428_apc_SkillLevelNames[i] = g428_byLanguage[i];
+		_skillLevelNames[i] = g428_byLanguage[i];
 
-	g32_BoxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel
+	_boxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel
 }
 
 InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
-	_g432_inventoryChampionOrdinal = 0;
-	_g424_panelContent = k0_PanelContentFoodWaterPoisoned;
+	_inventoryChampionOrdinal = 0;
+	_panelContent = k0_PanelContentFoodWaterPoisoned;
 	for (uint16 i = 0; i < 8; ++i)
-		_g425_chestSlots[i] = Thing(0);
-	_g426_openChest = Thing::_none;
-	_g421_objDescTextXpos = 0;
-	_g422_objDescTextYpos = 0;
+		_chestSlots[i] = Thing(0);
+	_openChest = Thing::_none;
+	_objDescTextXpos = 0;
+	_objDescTextYpos = 0;
 
 	for (int i = 0; i < 15; i++)
-		G0428_apc_SkillLevelNames[i] = nullptr;
+		_skillLevelNames[i] = nullptr;
 
 	initConstants();
 }
 
-void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
+void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	static Box g41_BoxFloppyZzzCross(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
 
 
@@ -100,14 +100,14 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 		return;
 	}
 	_vm->_stopWaitingForPlayerInput = true;
-	AL1102_ui_InventoryChampionOrdinal = _g432_inventoryChampionOrdinal;
+	AL1102_ui_InventoryChampionOrdinal = _inventoryChampionOrdinal;
 	if (_vm->indexToOrdinal(championIndex) == AL1102_ui_InventoryChampionOrdinal) {
 		championIndex = k4_ChampionCloseInventory;
 	}
 	_vm->_eventMan->showMouse();
 	if (AL1102_ui_InventoryChampionOrdinal) {
-		_g432_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
-		f334_closeChest();
+		_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
+		closeChest();
 		L1103_ps_Champion = &_vm->_championMan->_champions[_vm->ordinalToIndex(AL1102_ui_InventoryChampionOrdinal)];
 		if (L1103_ps_Champion->_currHealth && !_vm->_championMan->_candidateChampionOrdinal) {
 			setFlag(L1103_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox);
@@ -129,7 +129,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 		}
 	}
 	_vm->_displayMan->_useByteBoxCoordinates = false;
-	_g432_inventoryChampionOrdinal = _vm->indexToOrdinal(championIndex);
+	_inventoryChampionOrdinal = _vm->indexToOrdinal(championIndex);
 	if (!AL1102_ui_InventoryChampionOrdinal) {
 		_vm->_displayMan->shadeScreenBox(&_vm->_displayMan->_boxMovementArrows, k0_ColorBlack);
 	}
@@ -168,7 +168,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
 	_vm->_eventMan->discardAllInput();
 }
 
-void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) {
+void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 	dispMan._useByteBoxCoordinates = false;
 	Box box;
@@ -179,7 +179,7 @@ void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) {
 	dispMan.blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, &box, k16_byteWidth, kM1_ColorNoTransparency, 29);
 }
 
-void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
+void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
 	Box box;
 	box._x1 = x;
 	box._x2 = box._x1 + pixelWidth;
@@ -189,7 +189,7 @@ void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidt
 	_vm->_displayMan->fillBoxBitmap(_vm->_displayMan->_bitmapViewport, box, color, k112_byteWidthViewport, k136_heightViewport);
 }
 
-void InventoryMan::f344_drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
+void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
 	if (amount < -512) {
 		color = k8_ColorRed;
 	} else if (amount < 0) {
@@ -201,19 +201,19 @@ void InventoryMan::f344_drawPanelFoodOrWaterBar(int16 amount, int16 y, Color col
 		pixelWidth = 3071;
 	}
 	pixelWidth /= 32;
-	f343_drawPanelHorizontalBar(115, y + 2, pixelWidth, k0_ColorBlack);
-	f343_drawPanelHorizontalBar(113, y, pixelWidth, color);
+	drawPanelHorizontalBar(115, y + 2, pixelWidth, k0_ColorBlack);
+	drawPanelHorizontalBar(113, y, pixelWidth, color);
 }
 
-void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
+void InventoryMan::drawPanelFoodWaterPoisoned() {
 	static Box g35_BoxFood(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food
 	static Box g36_BoxWater(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
 	static Box g37_BoxPoisoned(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
 
-	Champion &champ = _vm->_championMan->_champions[_g432_inventoryChampionOrdinal];
-	f334_closeChest();
+	Champion &champ = _vm->_championMan->_champions[_inventoryChampionOrdinal];
+	closeChest();
 	DisplayMan &dispMan = *_vm->_displayMan;
-	dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k20_PanelEmptyIndice), g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
+	dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k20_PanelEmptyIndice), _boxPanel, k72_byteWidth, k8_ColorRed, 73);
 
 	switch (_vm->getGameLanguage()) { // localized
 	default:
@@ -235,60 +235,60 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
 		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k32_PoisionedLabelIndice),
 								   g37_BoxPoisoned, k48_byteWidth, k12_ColorDarkestGray, 15);
 	}
-	f344_drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown);
-	f344_drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue);
+	drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown);
+	drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue);
 }
 
-void InventoryMan::f346_drawPanelResurrectReincarnate() {
-	_g424_panelContent = k5_PanelContentResurrectReincarnate;
+void InventoryMan::drawPanelResurrectReincarnate() {
+	_panelContent = k5_PanelContentResurrectReincarnate;
 	_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k40_PanelResurectReincaranteIndice),
-										 g32_BoxPanel, k72_byteWidth, k6_ColorDarkGreen, 73);
+										 _boxPanel, k72_byteWidth, k6_ColorDarkGreen, 73);
 }
 
-void InventoryMan::f347_drawPanel() {
-	f334_closeChest();
+void InventoryMan::drawPanel() {
+	closeChest();
 
 	ChampionMan &cm = *_vm->_championMan;
 	if (cm._candidateChampionOrdinal) {
-		f346_drawPanelResurrectReincarnate();
+		drawPanelResurrectReincarnate();
 		return;
 	}
 
-	Thing thing = cm._champions[_vm->ordinalToIndex(_g432_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand);
+	Thing thing = cm._champions[_vm->ordinalToIndex(_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand);
 
-	_g424_panelContent = k0_PanelContentFoodWaterPoisoned;
+	_panelContent = k0_PanelContentFoodWaterPoisoned;
 	switch (thing.getType()) {
 	case k9_ContainerThingType:
-		_g424_panelContent = k4_PanelContentChest;
+		_panelContent = k4_PanelContentChest;
 		break;
 	case k7_ScrollThingType:
-		_g424_panelContent = k2_PanelContentScroll;
+		_panelContent = k2_PanelContentScroll;
 		break;
 	default:
 		thing = Thing::_none;
 		break;
 	}
 	if (thing == Thing::_none) {
-		f345_drawPanelFoodWaterPoisoned();
+		drawPanelFoodWaterPoisoned();
 	} else {
-		f342_drawPanelObject(thing, false);
+		drawPanelObject(thing, false);
 	}
 }
 
-void InventoryMan::f334_closeChest() {
+void InventoryMan::closeChest() {
 	DungeonMan &dunMan = *_vm->_dungeonMan;
 
 	bool processFirstChestSlot = true;
-	if (_g426_openChest == Thing::_none)
+	if (_openChest == Thing::_none)
 		return;
-	Container *container = (Container*)dunMan.getThingData(_g426_openChest);
-	_g426_openChest = Thing::_none;
+	Container *container = (Container*)dunMan.getThingData(_openChest);
+	_openChest = Thing::_none;
 	container->getSlot() = Thing::_endOfList;
 	Thing prevThing;
 	for (int16 chestSlotIndex = 0; chestSlotIndex < 8; ++chestSlotIndex) {
-		Thing thing = _g425_chestSlots[chestSlotIndex];
+		Thing thing = _chestSlots[chestSlotIndex];
 		if (thing != Thing::_none) {
-			_g425_chestSlots[chestSlotIndex] = Thing::_none; // CHANGE8_09_FIX
+			_chestSlots[chestSlotIndex] = Thing::_none; // CHANGE8_09_FIX
 
 			if (processFirstChestSlot) {
 				processFirstChestSlot = false;
@@ -302,7 +302,7 @@ void InventoryMan::f334_closeChest() {
 	}
 }
 
-void InventoryMan::f340_drawPanelScrollTextLine(int16 yPos, char* text) {
+void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) {
 	for (char* iter = text; *iter != '\0'; ++iter) {
 		if ((*iter >= 'A') && (*iter <= 'Z')) {
 			*iter -= 64;
@@ -313,7 +313,7 @@ void InventoryMan::f340_drawPanelScrollTextLine(int16 yPos, char* text) {
 	_vm->_textMan->f52_printToViewport(162 - (6 * strlen(text) / 2), yPos, k0_ColorBlack, text, k15_ColorWhite);
 }
 
-void InventoryMan::f341_drawPanelScroll(Scroll* scroll) {
+void InventoryMan::drawPanelScroll(Scroll* scroll) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 
 	char stringFirstLine[300];
@@ -324,7 +324,7 @@ void InventoryMan::f341_drawPanelScroll(Scroll* scroll) {
 	}
 	*charRed = '\0';
 	dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k23_PanelOpenScrollIndice),
-							   g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
+							   _boxPanel, k72_byteWidth, k8_ColorRed, 73);
 	int16 lineCount = 1;
 	charRed++;
 	char *charGreen = charRed; // first char of the second line
@@ -344,7 +344,7 @@ void InventoryMan::f341_drawPanelScroll(Scroll* scroll) {
 		lineCount--;
 	}
 	int16 yPos = 92 - (7 * lineCount) / 2; // center the text vertically
-	f340_drawPanelScrollTextLine(yPos, stringFirstLine);
+	drawPanelScrollTextLine(yPos, stringFirstLine);
 	charGreen = charRed;
 	while (*charGreen) {
 		yPos += 7;
@@ -355,27 +355,27 @@ void InventoryMan::f341_drawPanelScroll(Scroll* scroll) {
 			charRed[1] = '\0';
 		}
 		*charRed++ = '\0';
-		f340_drawPanelScrollTextLine(yPos, charGreen);
+		drawPanelScrollTextLine(yPos, charGreen);
 		charGreen = charRed;
 	}
 }
 
-void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bool isPressingEye) {
+void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool isPressingEye) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 	ObjectMan &objMan = *_vm->_objectMan;
 
-	if (_g426_openChest == thingToOpen)
+	if (_openChest == thingToOpen)
 		return;
 
-	if (_g426_openChest != Thing::_none)
-		f334_closeChest(); // CHANGE8_09_FIX
+	if (_openChest != Thing::_none)
+		closeChest(); // CHANGE8_09_FIX
 
-	_g426_openChest = thingToOpen;
+	_openChest = thingToOpen;
 	if (!isPressingEye) {
 		objMan.f38_drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen);
 	}
 	dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k25_PanelOpenChestIndice),
-							   g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
+							   _boxPanel, k72_byteWidth, k8_ColorRed, 73);
 	int16 chestSlotIndex = 0;
 	Thing thing = chest->getSlot();
 	int16 thingCount = 0;
@@ -384,16 +384,16 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo
 			break; // CHANGE8_08_FIX, make sure that no more than the first 8 objects in a chest are drawn
 
 		objMan.f38_drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, objMan.f33_getIconIndex(thing));
-		_g425_chestSlots[chestSlotIndex++] = thing;
+		_chestSlots[chestSlotIndex++] = thing;
 		thing = _vm->_dungeonMan->getNextThing(thing);
 	}
 	while (chestSlotIndex < 8) {
 		objMan.f38_drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, kM1_IconIndiceNone);
-		_g425_chestSlots[chestSlotIndex++] = Thing::_none;
+		_chestSlots[chestSlotIndex++] = Thing::_none;
 	}
 }
 
-void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos) {
+void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos) {
 	static byte iconBitmap[16 * 16];
 	Box box;
 	box._x2 = (box._x1 = xPos) + 15;
@@ -402,7 +402,7 @@ void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int
 	_vm->_displayMan->blitToViewport(iconBitmap, box, k8_byteWidth, kM1_ColorNoTransparency, 16);
 }
 
-void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, const char** attribStrings, char* destString, const char* prefixString, const char* suffixString) {
+void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, const char** attribStrings, char* destString, const char* prefixString, const char* suffixString) {
 	uint16 identicalBitCount = 0;
 	int16 attribMask = 1;
 	for (uint16 stringIndex = 0; stringIndex < 16; stringIndex++, attribMask <<= 1) {
@@ -440,11 +440,11 @@ void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, in
 	strcat(destString, suffixString);
 }
 
-void InventoryMan::f335_drawPanelObjectDescriptionString(const char *descString) {
+void InventoryMan::drawPanelObjectDescriptionString(const char *descString) {
 	if (descString[0] == '\f') { // form feed
 		descString++;
-		_g421_objDescTextXpos = 108;
-		_g422_objDescTextYpos = 59;
+		_objDescTextXpos = 108;
+		_objDescTextYpos = 59;
 	}
 
 	if (descString[0]) {
@@ -464,8 +464,8 @@ void InventoryMan::f335_drawPanelObjectDescriptionString(const char *descString)
 				severalLines = true;
 			}
 
-			_vm->_textMan->f52_printToViewport(_g421_objDescTextXpos, _g422_objDescTextYpos, k13_ColorLightestGray, stringLine);
-			_g422_objDescTextYpos += 7;
+			_vm->_textMan->f52_printToViewport(_objDescTextXpos, _objDescTextYpos, k13_ColorLightestGray, stringLine);
+			_objDescTextYpos += 7;
 			if (severalLines) {
 				severalLines = false;
 				stringLine = ++string;
@@ -476,7 +476,7 @@ void InventoryMan::f335_drawPanelObjectDescriptionString(const char *descString)
 	}
 }
 
-void InventoryMan::f339_drawPanelArrowOrEye(bool pressingEye) {
+void InventoryMan::drawPanelArrowOrEye(bool pressingEye) {
 	static Box boxArrowOrEye(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye 
 
 	DisplayMan &dispMan = *_vm->_displayMan;
@@ -489,7 +489,7 @@ void InventoryMan::f339_drawPanelArrowOrEye(bool pressingEye) {
 #define k0x0004_DescriptionMaskBroken 0x0004 // @ MASK0x0004_DESCRIPTION_BROKEN    
 #define k0x0008_DescriptionMaskCursed 0x0008 // @ MASK0x0008_DESCRIPTION_CURSED    
 
-void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
+void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 	static Box boxObjectDescCircle(105, 136, 53, 79); // @ G0034_s_Graphic562_Box_ObjectDescriptionCircle 
 
 	DungeonMan &dunMan = *_vm->_dungeonMan;
@@ -499,20 +499,20 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 	TextMan &textMan = *_vm->_textMan;
 
 	if (_vm->_pressingEye || _vm->_pressingMouth) {
-		f334_closeChest();
+		closeChest();
 	}
 
 	uint16 *rawThingPtr = dunMan.getThingData(thingToDraw);
-	f335_drawPanelObjectDescriptionString("\f"); // form feed
+	drawPanelObjectDescriptionString("\f"); // form feed
 	ThingType thingType = thingToDraw.getType();
 	if (thingType == k7_ScrollThingType) {
-		f341_drawPanelScroll((Scroll*)rawThingPtr);
+		drawPanelScroll((Scroll*)rawThingPtr);
 	} else if (thingType == k9_ContainerThingType) {
-		f333_openAndDrawChest(thingToDraw, (Container *)rawThingPtr, pressingEye);
+		openAndDrawChest(thingToDraw, (Container *)rawThingPtr, pressingEye);
 	} else {
 		IconIndice iconIndex = objMan.f33_getIconIndex(thingToDraw);
 		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k20_PanelEmptyIndice),
-								   g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
+								   _boxPanel, k72_byteWidth, k8_ColorRed, 73);
 		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k29_ObjectDescCircleIndice),
 								   boxObjectDescCircle, k16_byteWidth, k12_ColorDarkestGray, 27);
 
@@ -537,7 +537,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			descString = str;
 		} else if ((thingType == k8_PotionThingType)
 				   && (iconIndex != k163_IconIndicePotionWaterFlask)
-				   && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_g432_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
+				   && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
 			str[0] = '_' + ((Potion *)rawThingPtr)->getPower() / 40;
 			str[1] = ' ';
 			str[2] = '\0';
@@ -548,10 +548,10 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		}
 
 		textMan.f52_printToViewport(134, 68, k13_ColorLightestGray, descString);
-		f332_drawIconToViewport(iconIndex, 111, 59);
+		drawIconToViewport(iconIndex, 111, 59);
 
 
-		_g422_objDescTextYpos = 87;
+		_objDescTextYpos = 87;
 
 		uint16 potentialAttribMask = 0;
 		uint16 actualAttribMask = 0;
@@ -566,9 +566,9 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 
 				switch (_vm->getGameLanguage()) { // localized
 				default:
-				case Common::EN_ANY: f335_drawPanelObjectDescriptionString("(BURNT OUT)"); break;
-				case Common::DE_DEU: f335_drawPanelObjectDescriptionString("(AUSGEBRANNT)"); break;
-				case Common::FR_FRA: f335_drawPanelObjectDescriptionString("(CONSUME)"); break;
+				case Common::EN_ANY: drawPanelObjectDescriptionString("(BURNT OUT)"); break;
+				case Common::DE_DEU: drawPanelObjectDescriptionString("(AUSGEBRANNT)"); break;
+				case Common::FR_FRA: drawPanelObjectDescriptionString("(CONSUME)"); break;
 				}
 			}
 			break;
@@ -606,7 +606,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 					break;
 				}
 
-				f335_drawPanelObjectDescriptionString(descString);
+				drawPanelObjectDescriptionString(descString);
 			} else if ((iconIndex >= k0_IconIndiceJunkCompassNorth) && (iconIndex <= k3_IconIndiceJunkCompassWest)) {
 				potentialAttribMask = 0;
 
@@ -634,7 +634,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 				case Common::FR_FRA: strcat(str, directionName_FR_FRA[iconIndex]); break;
 				}
 
-				f335_drawPanelObjectDescriptionString(str);
+				drawPanelObjectDescriptionString(str);
 			} else {
 				Junk *junk = (Junk *)rawThingPtr;
 				potentialAttribMask = k0x0001_DescriptionMaskConsumable;
@@ -659,8 +659,8 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			case Common::FR_FRA: attribString = attribString_FR_FRA; break;
 			}
 
-			f336_buildObjectAttributeString(potentialAttribMask, actualAttribMask, attribString, str, "(", ")");
-			f335_drawPanelObjectDescriptionString(str);
+			buildObjectAttributeString(potentialAttribMask, actualAttribMask, attribString, str, "(", ")");
+			drawPanelObjectDescriptionString(str);
 		}
 
 		switch (_vm->getGameLanguage()) { // localized
@@ -691,12 +691,12 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		case Common::FR_FRA: strcat(str, "."); break;
 		}
 
-		f335_drawPanelObjectDescriptionString(str);
+		drawPanelObjectDescriptionString(str);
 	}
-	f339_drawPanelArrowOrEye(pressingEye);
+	drawPanelArrowOrEye(pressingEye);
 }
 
-void InventoryMan::f337_setDungeonViewPalette() {
+void InventoryMan::setDungeonViewPalette() {
 	static const int16 g40_palIndexToLightAmmount[6] = {99, 75, 50, 25, 1, 0}; // @ G0040_ai_Graphic562_PaletteIndexToLightAmount
 
 	if (_vm->_dungeonMan->_currMap->_difficulty == 0) {
@@ -769,7 +769,7 @@ void InventoryMan::f337_setDungeonViewPalette() {
 	_vm->_displayMan->_refreshDungeonViewPaleteRequested = true;
 }
 
-void InventoryMan::f338_decreaseTorchesLightPower() {
+void InventoryMan::decreaseTorchesLightPower() {
 	bool L1048_B_TorchChargeCountChanged = false;
 	int16 L1046_i_ChampionCount = _vm->_championMan->_partyChampionCount;
 	if (_vm->_championMan->_candidateChampionOrdinal) {
@@ -793,12 +793,12 @@ void InventoryMan::f338_decreaseTorchesLightPower() {
 		L1050_ps_Champion++;
 	}
 	if (L1048_B_TorchChargeCountChanged) {
-		f337_setDungeonViewPalette();
+		setDungeonViewPalette();
 		_vm->_championMan->drawChangedObjectIcons();
 	}
 }
 
-void InventoryMan::f351_drawChampionSkillsAndStatistics() {
+void InventoryMan::drawChampionSkillsAndStatistics() {
 
 	uint16 L1090_ui_Multiple;
 #define AL1090_ui_SkillIndex     L1090_ui_Multiple
@@ -824,9 +824,9 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 	case Common::FR_FRA: G0431_apc_StatisticNames = G0431_apc_StatisticNames_FR_FRA; break;
 	}
 
-	f334_closeChest();
-	L1094_ps_Champion = &_vm->_championMan->_champions[L1093_ui_ChampionIndex = _vm->ordinalToIndex(_g432_inventoryChampionOrdinal)];
-	_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k20_PanelEmptyIndice), g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73);
+	closeChest();
+	L1094_ps_Champion = &_vm->_championMan->_champions[L1093_ui_ChampionIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal)];
+	_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k20_PanelEmptyIndice), _boxPanel, k72_byteWidth, k8_ColorRed, 73);
 	L1091_i_Y = 58;
 	for (AL1090_ui_SkillIndex = k0_ChampionSkillFighter; AL1090_ui_SkillIndex <= k3_ChampionSkillWizard; AL1090_ui_SkillIndex++) {
 		AL1092_i_SkillLevel = MIN((uint16)16, _vm->_championMan->getSkillLevel(L1093_ui_ChampionIndex, AL1090_ui_SkillIndex | k0x8000_IgnoreTemporaryExperience));
@@ -837,14 +837,14 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 		default:
 		case Common::EN_ANY:
 		case Common::DE_DEU: // english and german versions are the same
-			strcpy(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]);
+			strcpy(L1097_ac_String, _skillLevelNames[AL1092_i_SkillLevel - 2]);
 			strcat(L1097_ac_String, " ");
 			strcat(L1097_ac_String, _vm->_championMan->_baseSkillName[AL1090_ui_SkillIndex]);
 			break;
 		case Common::FR_FRA:
 			strcat(L1097_ac_String, _vm->_championMan->_baseSkillName[AL1090_ui_SkillIndex]);
 			strcat(L1097_ac_String, " ");
-			strcpy(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]);
+			strcpy(L1097_ac_String, _skillLevelNames[AL1092_i_SkillLevel - 2]);
 			break;
 		}
 		_vm->_textMan->f52_printToViewport(108, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String);
@@ -872,8 +872,8 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() {
 	}
 }
 
-void InventoryMan::f350_drawStopPressingMouth() {
-	f347_drawPanel();
+void InventoryMan::drawStopPressingMouth() {
+	drawPanel();
 	_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 	_vm->_eventMan->_hideMousePointerRequestCount = 1;
 	_vm->_eventMan->showMouse();
@@ -881,11 +881,11 @@ void InventoryMan::f350_drawStopPressingMouth() {
 	_vm->_eventMan->showMouse();
 }
 
-void InventoryMan::f353_drawStopPressingEye() {
+void InventoryMan::drawStopPressingEye() {
 	Thing L1100_T_LeaderHandObject;
 
-	f332_drawIconToViewport(k202_IconIndiceEyeNotLooking, 12, 13);
-	f347_drawPanel();
+	drawIconToViewport(k202_IconIndiceEyeNotLooking, 12, 13);
+	drawPanel();
 	_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 	if ((L1100_T_LeaderHandObject = _vm->_championMan->_leaderHandObject) != Thing::_none) {
 		_vm->_objectMan->f34_drawLeaderObjectName(L1100_T_LeaderHandObject);
@@ -895,7 +895,7 @@ void InventoryMan::f353_drawStopPressingEye() {
 	_vm->_eventMan->showMouse();
 }
 
-void InventoryMan::f349_processCommand70_clickOnMouth() {
+void InventoryMan::clickOnMouth() {
 	static int16 G0242_ai_Graphic559_FoodAmounts[8] = {
 		500,    /* Apple */
 		600,    /* Corn */
@@ -927,7 +927,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 
 
 	if (_vm->_championMan->_leaderEmptyHanded) {
-		if (_g424_panelContent == k0_PanelContentFoodWaterPoisoned) {
+		if (_panelContent == k0_PanelContentFoodWaterPoisoned) {
 			return;
 		}
 		_vm->_eventMan->_ignoreMouseMovements = true;
@@ -939,7 +939,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 		} else {
 			_vm->_eventMan->showMouse();
 			_vm->_eventMan->_hideMousePointerRequestCount = 1;
-			f345_drawPanelFoodWaterPoisoned();
+			drawPanelFoodWaterPoisoned();
 			_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 		}
 		return;
@@ -953,7 +953,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 	L1079_ui_IconIndex = _vm->_objectMan->f33_getIconIndex(L1078_T_Thing);
 	AL1088_ui_ThingType = L1078_T_Thing.getType();
 	L1089_ui_Weight = _vm->_dungeonMan->getObjectWeight(L1078_T_Thing);
-	L1083_ps_Champion = &_vm->_championMan->_champions[L1080_ui_ChampionIndex = _vm->ordinalToIndex(_g432_inventoryChampionOrdinal)];
+	L1083_ps_Champion = &_vm->_championMan->_champions[L1080_ui_ChampionIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal)];
 	L1082_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L1078_T_Thing);
 	if ((L1079_ui_IconIndex >= k8_IconIndiceJunkWater) && (L1079_ui_IconIndex <= k9_IconIndiceJunkWaterSkin)) {
 		if (!(L1082_ps_Junk->getChargeCount())) {
@@ -980,16 +980,16 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 		AL1085_ui_AdjustedPotionPower = (AL1085_ui_PotionPower / 25) + 8; /* Value between 8 and 18 */
 		switch (((Potion*)L1082_ps_Junk)->getType()) {
 		case k6_PotionTypeRos:
-			f348_adjustStatisticCurrentValue(L1083_ps_Champion, k2_ChampionStatDexterity, AL1085_ui_AdjustedPotionPower);
+			adjustStatisticCurrentValue(L1083_ps_Champion, k2_ChampionStatDexterity, AL1085_ui_AdjustedPotionPower);
 			break;
 		case k7_PotionTypeKu:
-			f348_adjustStatisticCurrentValue(L1083_ps_Champion, k1_ChampionStatStrength, (((Potion*)L1082_ps_Junk)->getPower() / 35) + 5); /* Value between 5 and 12 */
+			adjustStatisticCurrentValue(L1083_ps_Champion, k1_ChampionStatStrength, (((Potion*)L1082_ps_Junk)->getPower() / 35) + 5); /* Value between 5 and 12 */
 			break;
 		case k8_PotionTypeDane:
-			f348_adjustStatisticCurrentValue(L1083_ps_Champion, k3_ChampionStatWisdom, AL1085_ui_AdjustedPotionPower);
+			adjustStatisticCurrentValue(L1083_ps_Champion, k3_ChampionStatWisdom, AL1085_ui_AdjustedPotionPower);
 			break;
 		case k9_PotionTypeNeta:
-			f348_adjustStatisticCurrentValue(L1083_ps_Champion, k4_ChampionStatVitality, AL1085_ui_AdjustedPotionPower);
+			adjustStatisticCurrentValue(L1083_ps_Champion, k4_ChampionStatVitality, AL1085_ui_AdjustedPotionPower);
 			break;
 		case k10_PotionTypeAntivenin:
 			_vm->_championMan->unpoison(L1080_ui_ChampionIndex);
@@ -1064,14 +1064,14 @@ void InventoryMan::f349_processCommand70_clickOnMouth() {
 	}
 	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k08_soundSWALLOW, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
 	setFlag(L1083_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
-	if (_g424_panelContent == k0_PanelContentFoodWaterPoisoned) {
+	if (_panelContent == k0_PanelContentFoodWaterPoisoned) {
 		setFlag(L1083_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
 	}
 	_vm->_championMan->drawChampionState((ChampionIndex)L1080_ui_ChampionIndex);
 	_vm->_eventMan->hideMouse();
 }
 
-void InventoryMan::f348_adjustStatisticCurrentValue(Champion* champ, uint16 statIndex, int16 valueDelta) {
+void InventoryMan::adjustStatisticCurrentValue(Champion* champ, uint16 statIndex, int16 valueDelta) {
 	int16 L1077_i_Multiple;
 #define AL1077_i_CurrentValue L1077_i_Multiple
 #define AL1077_i_Delta        L1077_i_Multiple
@@ -1091,7 +1091,7 @@ void InventoryMan::f348_adjustStatisticCurrentValue(Champion* champ, uint16 stat
 	champ->_statistics[statIndex][k1_ChampionStatCurrent] += AL1077_i_Delta;
 }
 
-void InventoryMan::f352_processCommand71_clickOnEye() {
+void InventoryMan::clickOnEye() {
 	_vm->_eventMan->_ignoreMouseMovements = true;
 	_vm->_pressingEye = true;
 	if (!_vm->_eventMan->isMouseButtonDown(k1_LeftMouseButton)) {
@@ -1105,12 +1105,12 @@ void InventoryMan::f352_processCommand71_clickOnEye() {
 	_vm->_eventMan->hideMouse();
 	_vm->_eventMan->hideMouse();
 	_vm->delay(8);
-	f332_drawIconToViewport(k203_IconIndiceEyeLooking, 12, 13);
+	drawIconToViewport(k203_IconIndiceEyeLooking, 12, 13);
 	if (_vm->_championMan->_leaderEmptyHanded) {
-		f351_drawChampionSkillsAndStatistics();
+		drawChampionSkillsAndStatistics();
 	} else {
 		_vm->_objectMan->f35_clearLeaderObjectName();
-		f342_drawPanelObject(_vm->_championMan->_leaderHandObject, true);
+		drawPanelObject(_vm->_championMan->_leaderHandObject, true);
 	}
 	_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index c15a26c..6ad520c 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -52,41 +52,40 @@ class InventoryMan {
 public:
 	explicit InventoryMan(DMEngine *vm);
 
-	int16 _g432_inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal
-	PanelContent _g424_panelContent; // @ G0424_i_PanelContent 
-	Thing _g425_chestSlots[8]; // @ G0425_aT_ChestSlots
-	Thing _g426_openChest; // @ G0426_T_OpenChest
-	int16 _g421_objDescTextXpos; // @ G0421_i_ObjectDescriptionTextX
-	int16 _g422_objDescTextYpos; // @ G0422_i_ObjectDescriptionTextY
-	Box g32_BoxPanel;
-	const char* G0428_apc_SkillLevelNames[15];
+	int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal
+	PanelContent _panelContent; // @ G0424_i_PanelContent 
+	Thing _chestSlots[8]; // @ G0425_aT_ChestSlots
+	Thing _openChest; // @ G0426_T_OpenChest
+	int16 _objDescTextXpos; // @ G0421_i_ObjectDescriptionTextX
+	int16 _objDescTextYpos; // @ G0422_i_ObjectDescriptionTextY
+	Box _boxPanel;
+	const char *_skillLevelNames[15];
 
-	void f355_toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE
-	void f354_drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait
-	void f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar
-	void f344_drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color); // @ F0344_INVENTORY_DrawPanel_FoodOrWaterBar 
-	void f345_drawPanelFoodWaterPoisoned(); // @ F0345_INVENTORY_DrawPanel_FoodWaterPoisoned
-	void f346_drawPanelResurrectReincarnate(); // @ F0346_INVENTORY_DrawPanel_ResurrectReincarnate
-	void f347_drawPanel(); // @ F0347_INVENTORY_DrawPanel
-	void f334_closeChest(); // @ F0334_INVENTORY_CloseChest
-	void f340_drawPanelScrollTextLine(int16 yPos, char *text); // @ F0340_INVENTORY_DrawPanel_ScrollTextLine
-	void f341_drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll
-	void f333_openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye); // @ F0333_INVENTORY_OpenAndDrawChest
-	void f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos); // @ F0332_INVENTORY_DrawIconToViewport
-	void f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, const char ** attribStrings,
+	void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE
+	void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait
+	void drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar
+	void drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color); // @ F0344_INVENTORY_DrawPanel_FoodOrWaterBar 
+	void drawPanelFoodWaterPoisoned(); // @ F0345_INVENTORY_DrawPanel_FoodWaterPoisoned
+	void drawPanelResurrectReincarnate(); // @ F0346_INVENTORY_DrawPanel_ResurrectReincarnate
+	void drawPanel(); // @ F0347_INVENTORY_DrawPanel
+	void closeChest(); // @ F0334_INVENTORY_CloseChest
+	void drawPanelScrollTextLine(int16 yPos, char *text); // @ F0340_INVENTORY_DrawPanel_ScrollTextLine
+	void drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll
+	void openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye); // @ F0333_INVENTORY_OpenAndDrawChest
+	void drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos); // @ F0332_INVENTORY_DrawIconToViewport
+	void buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, const char ** attribStrings,
 									char *destString, const char *prefixString, const char *suffixString); // @ F0336_INVENTORY_DrawPanel_BuildObjectAttributesString
-	void f335_drawPanelObjectDescriptionString(const char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString
-	void f339_drawPanelArrowOrEye(bool pressingEye); // @ F0339_INVENTORY_DrawPanel_ArrowOrEye
-	void f342_drawPanelObject(Thing thingToDraw, bool pressingEye); // @ F0342_INVENTORY_DrawPanel_Object
-	void f337_setDungeonViewPalette(); // @ F0337_INVENTORY_SetDungeonViewPalette
-	void f338_decreaseTorchesLightPower(); // @ F0338_INVENTORY_DecreaseTorchesLightPower_CPSE
-	void f351_drawChampionSkillsAndStatistics(); // @ F0351_INVENTORY_DrawChampionSkillsAndStatistics
-	void f350_drawStopPressingMouth(); // @ F0350_INVENTORY_DrawStopPressingMouth
-	void f353_drawStopPressingEye();// @ F0353_INVENTORY_DrawStopPressingEye
-	void f349_processCommand70_clickOnMouth(); // @ F0349_INVENTORY_ProcessCommand70_ClickOnMouth
-	void f348_adjustStatisticCurrentValue(Champion *champ, uint16 statIndex, int16 valueDelta); // @ F0348_INVENTORY_AdjustStatisticCurrentValue
-	void f352_processCommand71_clickOnEye(); // @ F0352_INVENTORY_ProcessCommand71_ClickOnEye
-
+	void drawPanelObjectDescriptionString(const char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString
+	void drawPanelArrowOrEye(bool pressingEye); // @ F0339_INVENTORY_DrawPanel_ArrowOrEye
+	void drawPanelObject(Thing thingToDraw, bool pressingEye); // @ F0342_INVENTORY_DrawPanel_Object
+	void setDungeonViewPalette(); // @ F0337_INVENTORY_SetDungeonViewPalette
+	void decreaseTorchesLightPower(); // @ F0338_INVENTORY_DecreaseTorchesLightPower_CPSE
+	void drawChampionSkillsAndStatistics(); // @ F0351_INVENTORY_DrawChampionSkillsAndStatistics
+	void drawStopPressingMouth(); // @ F0350_INVENTORY_DrawStopPressingMouth
+	void drawStopPressingEye();// @ F0353_INVENTORY_DrawStopPressingEye
+	void clickOnMouth(); // @ F0349_INVENTORY_ProcessCommand70_ClickOnMouth
+	void adjustStatisticCurrentValue(Champion *champ, uint16 statIndex, int16 valueDelta); // @ F0348_INVENTORY_AdjustStatisticCurrentValue
+	void clickOnEye(); // @ F0352_INVENTORY_ProcessCommand71_ClickOnEye
 };
 
 }
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index adc151e..e52b01e 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -182,9 +182,9 @@ void MenuMan::f456_drawDisabledMenu() {
 	if (!_vm->_championMan->_partyIsSleeping) {
 		_vm->_eventMan->highlightBoxDisable();
 		_vm->_displayMan->_useByteBoxCoordinates = false;
-		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
-			if (_vm->_inventoryMan->_g424_panelContent == k4_PanelContentChest) {
-				_vm->_inventoryMan->f334_closeChest();
+		if (_vm->_inventoryMan->_inventoryChampionOrdinal) {
+			if (_vm->_inventoryMan->_panelContent == k4_PanelContentChest) {
+				_vm->_inventoryMan->closeChest();
 			}
 		} else {
 			_vm->_displayMan->shadeScreenBox(&_vm->_displayMan->_boxMovementArrows, k0_ColorBlack);
@@ -444,10 +444,10 @@ void MenuMan::f457_drawEnabledMenus() {
 			_g509_actionAreaContainsIcons = true;
 		}
 		f387_drawActionArea();
-		AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_g432_inventoryChampionOrdinal;
+		AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_inventoryChampionOrdinal;
 		if (AL1462_i_InventoryChampionOrdinal) {
-			_vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
-			_vm->_inventoryMan->f355_toggleInventory((ChampionIndex)_vm->ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
+			_vm->_inventoryMan->_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
+			_vm->_inventoryMan->toggleInventory((ChampionIndex)_vm->ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
 		} else {
 			_vm->_displayMan->drawFloorAndCeiling();
 			f395_drawMovementArrows();
@@ -533,7 +533,7 @@ int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
 		L1275_ps_Potion->setPower(_vm->getRandomNumber(16) + (L1268_i_PowerSymbolOrdinal * 40));
 		L1270_ps_Champion->_load += _vm->_dungeonMan->getObjectWeight(L1272_T_Object) - AL1269_ui_EmptyFlaskWeight;
 		_vm->_championMan->drawChangedObjectIcons();
-		if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex)) {
+		if (_vm->_inventoryMan->_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex)) {
 			setFlag(L1270_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad);
 			_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 		}
@@ -755,7 +755,7 @@ void MenuMan::f404_createEvent70_light(int16 lightPower, int16 ticks) {
 	setMapAndTime(L1241_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + ticks);
 	L1241_s_Event._priority = 0;
 	_vm->_timeline->f238_addEventGetEventIndex(&L1241_s_Event);
-	_vm->_inventoryMan->f337_setDungeonViewPalette();
+	_vm->_inventoryMan->setDungeonViewPalette();
 }
 
 bool MenuMan::f403_isPartySpellOrFireShieldSuccessful(Champion* champ, bool spellShield, uint16 ticks, bool useMana) {
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 98da742..37dd738 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -268,7 +268,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 			_vm->_dungeonMan->_partyMapX = destMapX;
 			_vm->_dungeonMan->_partyMapY = destMapY;
 			L0718_i_RequiredTeleporterScope = k0x0002_TelepScopeObjOrParty;
-			L0723_B_DrawDungeonViewWhileFalling = !_vm->_inventoryMan->_g432_inventoryChampionOrdinal && !_vm->_championMan->_partyIsSleeping;
+			L0723_B_DrawDungeonViewWhileFalling = !_vm->_inventoryMan->_inventoryChampionOrdinal && !_vm->_championMan->_partyIsSleeping;
 			L0716_ui_Direction = _vm->_dungeonMan->_partyDir;
 		} else {
 			if (L0710_i_ThingType == k4_GroupThingType) {
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 1e19c22..db3e215 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -340,7 +340,7 @@ void Timeline::f261_processTimeline() {
 			case k70_TMEventTypeLight:
 				_vm->_dungeonMan->setCurrentMap(_vm->_dungeonMan->_partyMapIndex);
 				f257_timelineProcessEvent70_light(L0681_ps_Event);
-				_vm->_inventoryMan->f337_setDungeonViewPalette();
+				_vm->_inventoryMan->setDungeonViewPalette();
 				break;
 			case k71_TMEventTypeInvisibility:
 				_vm->_championMan->_party._event71Count_Invisibility--;
@@ -992,9 +992,9 @@ void Timeline::f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex)
 	if (!L0663_ps_Champion->_currHealth) {
 		return;
 	}
-	if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+	if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) {
 		_vm->_eventMan->showMouse();
-		_vm->_inventoryMan->f354_drawStatusBoxPortrait((ChampionIndex)champIndex);
+		_vm->_inventoryMan->drawStatusBoxPortrait((ChampionIndex)champIndex);
 		_vm->_eventMan->hideMouse();
 	} else {
 		setFlag(L0663_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle);


Commit: d2fbd98f3d28d14b58f215bd1559ef7433df08e3
    https://github.com/scummvm/scummvm/commit/d2fbd98f3d28d14b58f215bd1559ef7433df08e3
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Renaming in MenuMan definition

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/lzw.cpp
    engines/dm/lzw.h
    engines/dm/menus.cpp
    engines/dm/menus.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index e841633..b7f2460 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -486,7 +486,7 @@ void ChampionMan::drawChangedObjectIcons() {
 		if (hasObjectIconInSlotBoxChanged(slotBoxIndex, _champions[champIndex].getSlot((ChampionSlot)getHandSlotIndex(slotBoxIndex)))
 			&& (getHandSlotIndex(slotBoxIndex) == k1_ChampionSlotActionHand)) {
 
-			menuMan.f386_drawActionIcon((ChampionIndex)champIndex);
+			menuMan.drawActionIcon((ChampionIndex)champIndex);
 		}
 	}
 
@@ -499,7 +499,7 @@ void ChampionMan::drawChangedObjectIcons() {
 			uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + k8_SlotBoxInventoryFirstSlot, *thing) ? 1 : 0;
 			drawViewport |= objIconChanged;
 			if (objIconChanged && (slotIndex == k1_ChampionSlotActionHand)) {
-				menuMan.f386_drawActionIcon((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
+				menuMan.drawActionIcon((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
 			}
 		}
 
@@ -548,7 +548,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 		if (slotIndex == k1_ChampionSlotActionHand) {
 			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
 			if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
-				menuMan.f388_clearActingChampion();
+				menuMan.clearActingChampion();
 
 			if ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)) {
 				((Scroll *)rawObjPtr)->setClosed(false);
@@ -699,7 +699,7 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 		if (slotIndex == k1_ChampionSlotActionHand) {
 			setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand);
 			if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
-				_vm->_menuMan->f388_clearActingChampion();
+				_vm->_menuMan->clearActingChampion();
 
 			if ((curIconIndex >= k30_IconIndiceScrollOpen) && (curIconIndex <= k31_IconIndiceScrollClosed)) {
 				((Scroll *)curWeapon)->setClosed(true);
@@ -907,7 +907,7 @@ void ChampionMan::wakeUp() {
 	_vm->_eventMan->_primaryKeyboardInput = _vm->_eventMan->_primaryKeyboardInputInterface;
 	_vm->_eventMan->_secondaryKeyboardInput = _vm->_eventMan->_secondaryKeyboardInputMovement;
 	_vm->_eventMan->discardAllInput();
-	_vm->_menuMan->f457_drawEnabledMenus();
+	_vm->_menuMan->drawEnabledMenus();
 }
 
 int16 ChampionMan::getThrowingStaminaCost(Thing thing) {
@@ -1284,7 +1284,7 @@ void ChampionMan::viAltarRebirth(uint16 champIndex) {
 	uint16 maximumHealth = curChampion->_maxHealth;
 	curChampion->_maxHealth = MAX(25, maximumHealth - (maximumHealth >> 6) - 1);
 	curChampion->_currHealth = curChampion->_maxHealth >> 1;
-	_vm->_menuMan->f393_drawSpellAreaControls(_magicCasterChampionIndex);
+	_vm->_menuMan->drawSpellAreaControls(_magicCasterChampionIndex);
 	curChampion->_dir = _vm->_dungeonMan->_partyDir;
 	setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
 	drawChampionState((ChampionIndex)champIndex);
@@ -1510,9 +1510,9 @@ void ChampionMan::championKill(uint16 champIndex) {
 		_vm->_eventMan->commandSetLeader((ChampionIndex)aliveChampionIndex);
 
 	if (champIndex == _magicCasterChampionIndex)
-		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(aliveChampionIndex);
+		_vm->_menuMan->setMagicCasterAndDrawSpellArea(aliveChampionIndex);
 	else
-		_vm->_menuMan->f393_drawSpellAreaControls(_magicCasterChampionIndex);
+		_vm->_menuMan->drawSpellAreaControls(_magicCasterChampionIndex);
 }
 
 void ChampionMan::dropAllObjects(uint16 champIndex) {
@@ -1850,7 +1850,7 @@ void ChampionMan::resetDataToStartGame() {
 		}
 		if ((L0785_i_ChampionIndex = _magicCasterChampionIndex) != kM1_ChampionNone) {
 			_magicCasterChampionIndex = kM1_ChampionNone;
-			_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(L0785_i_ChampionIndex);
+			_vm->_menuMan->setMagicCasterAndDrawSpellArea(L0785_i_ChampionIndex);
 		}
 		return;
 	}
@@ -1949,10 +1949,10 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	_candidateChampionOrdinal = previousPartyChampionCount + 1;
 	if (++_partyChampionCount == 1) {
 		_vm->_eventMan->commandSetLeader(k0_ChampionFirst);
-		_vm->_menuMan->_g508_refreshActionArea = true;
+		_vm->_menuMan->_refreshActionArea = true;
 	} else {
-		_vm->_menuMan->f388_clearActingChampion();
-		_vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_partyChampionCount - 1));
+		_vm->_menuMan->clearActingChampion();
+		_vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1));
 	}
 
 	int16 curMapX = _vm->_dungeonMan->_partyMapX;
@@ -2028,7 +2028,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 		curThing = _vm->_dungeonMan->getNextThing(curThing);
 	}
 	_vm->_inventoryMan->toggleInventory((ChampionIndex)previousPartyChampionCount);
-	_vm->_menuMan->f456_drawDisabledMenu();;
+	_vm->_menuMan->drawDisabledMenu();;
 }
 
 void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) {
@@ -2155,7 +2155,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		} else {
 			_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), &box, k40_byteWidth, kM1_ColorNoTransparency, 29);
 			_vm->_textMan->f53_printToLogicalScreen(championStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, curChampion->_name);
-			_vm->_menuMan->f386_drawActionIcon(champIndex);
+			_vm->_menuMan->drawActionIcon(champIndex);
 
 			clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
 			_vm->_eventMan->hideMouse();
@@ -2273,7 +2273,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	}
 	if (getFlag(championAttributes, k0x8000_ChampionAttributeActionHand)) {
 		drawSlot(champIndex, k1_ChampionSlotActionHand);
-		_vm->_menuMan->f386_drawActionIcon(champIndex);
+		_vm->_menuMan->drawActionIcon(champIndex);
 		if (isInventoryChampion)
 			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index ed27dca..1b218e1 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -299,7 +299,7 @@ void DMEngine::initializeGame() {
 		}
 	} while (loadgame(saveSlot) != k1_LoadgameSuccess);
 
-	_displayMan->loadIntoBitmap(k11_MenuSpellAreLinesIndice, _menuMan->_gK73_bitmapSpellAreaLines); // @ F0396_MENUS_LoadSpellAreaLinesBitmap
+	_displayMan->loadIntoBitmap(k11_MenuSpellAreLinesIndice, _menuMan->_bitmapSpellAreaLines); // @ F0396_MENUS_LoadSpellAreaLinesBitmap
 
 	// There was some memory wizardy for the Amiga platform, I skipped that part
 	_displayMan->allocateFlippedWallBitmaps();
@@ -334,7 +334,7 @@ void DMEngine::startGame() {
 	_eventMan->_highlightBoxEnabled = false;
 	_championMan->_partyIsSleeping = false;
 	_championMan->_actingChampionOrdinal = indexToOrdinal(kM1_ChampionNone);
-	_menuMan->_g509_actionAreaContainsIcons = true;
+	_menuMan->_actionAreaContainsIcons = true;
 	_eventMan->_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kM1_ChampionNone);
 
 	_eventMan->_primaryMouseInput = _eventMan->_primaryMouseInputInterface;
@@ -359,7 +359,7 @@ void DMEngine::startGame() {
 	}
 
 	_displayMan->buildPaletteChangeCopperList(_displayMan->_palDungeonView[0], _displayMan->_paletteTopAndBottomScreen);
-	_menuMan->f395_drawMovementArrows();
+	_menuMan->drawMovementArrows();
 	_championMan->resetDataToStartGame();
 	_gameTimeTicking = true;
 }
@@ -405,7 +405,7 @@ Common::Error DMEngine::run() {
 			endGame(_championMan->_partyDead);
 		else {
 			loadGameState(_loadSaveSlotAtRuntime);
-			_menuMan->f457_drawEnabledMenus();
+			_menuMan->drawEnabledMenus();
 			_displayMan->updateScreen();
 			_loadSaveSlotAtRuntime = -1;
 		}
@@ -481,7 +481,7 @@ void DMEngine::gameloop() {
 		if (_championMan->_party._freezeLifeTicks)
 			_championMan->_party._freezeLifeTicks -= 1;
 
-		_menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived();
+		_menuMan->refreshActionAreaAndSetChampDirMaxDamageReceived();
 
 		if (!(_gameTime & (_championMan->_partyIsSleeping ? 15 : 63)))
 			_championMan->applyTimeEffects();
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 8e9142e..5007b8c 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -833,7 +833,7 @@ void EventManager::processCommandQueue() {
 			if (_vm->_inventoryMan->_inventoryChampionOrdinal)
 				_vm->_inventoryMan->toggleInventory(k4_ChampionCloseInventory);
 
-			_vm->_menuMan->f456_drawDisabledMenu();
+			_vm->_menuMan->drawDisabledMenu();
 			_vm->_championMan->_partyIsSleeping = true;
 			drawSleepScreen();
 			_vm->_displayMan->drawViewport(k2_viewportAsBeforeSleepOrFreezeGame);
@@ -861,7 +861,7 @@ void EventManager::processCommandQueue() {
 
 	if (cmdType == k147_CommandFreezeGame) {
 		_vm->_gameTimeTicking = false;
-		_vm->_menuMan->f456_drawDisabledMenu();
+		_vm->_menuMan->drawDisabledMenu();
 		_vm->_displayMan->fillBitmap(_vm->_displayMan->_bitmapViewport, k0_ColorBlack, 112, 136);
 
 		switch (_vm->getGameLanguage()) { // localized
@@ -894,7 +894,7 @@ void EventManager::processCommandQueue() {
 
 	if (cmdType == k148_CommandUnfreezeGame) {
 		_vm->_gameTimeTicking = true;
-		_vm->_menuMan->f457_drawEnabledMenus();
+		_vm->_menuMan->drawEnabledMenus();
 		_primaryMouseInput = primaryMouseInputBackup;
 		_secondaryMouseInput = secondaryMouseInputBackup;
 		_primaryKeyboardInput = primaryKeyboardInputBackup;
@@ -1248,7 +1248,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 		dispMan._useByteBoxCoordinates = false;
 		dispMan.fillScreenBox(box, k0_ColorBlack);
 		dispMan.fillScreenBox(_vm->_championMan->_boxChampionIcons[champMan.getChampionIconIndex(champ->_cell, dunMan._partyDir) * 2], k0_ColorBlack);
-		_vm->_menuMan->f457_drawEnabledMenus();
+		_vm->_menuMan->drawEnabledMenus();
 		showMouse();
 		return;
 	}
@@ -1288,9 +1288,9 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	if (champMan._partyChampionCount == 1) {
 		_vm->_projexpl->_g362_lastPartyMovementTime = _vm->_gameTime;
 		commandSetLeader(k0_ChampionFirst);
-		_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(k0_ChampionFirst);
+		_vm->_menuMan->setMagicCasterAndDrawSpellArea(k0_ChampionFirst);
 	} else
-		_vm->_menuMan->f393_drawSpellAreaControls(champMan._magicCasterChampionIndex);
+		_vm->_menuMan->drawSpellAreaControls(champMan._magicCasterChampionIndex);
 
 	_vm->_textMan->f51_messageAreaPrintLineFeed();
 	Color champColor = _vm->_championMan->_championColor[championIndex];
@@ -1310,7 +1310,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	}
 
 	invMan.toggleInventory(k4_ChampionCloseInventory);
-	_vm->_menuMan->f457_drawEnabledMenus();
+	_vm->_menuMan->drawEnabledMenus();
 	setMousePointerToNormal((_vm->_championMan->_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
 }
 
@@ -1540,7 +1540,7 @@ void EventManager::commandProcessType100_clickInSpellArea(uint16 posX, uint16 po
 		}
 
 		if ((championIndex != kM1_ChampionNone) && (championIndex < _vm->_championMan->_partyChampionCount))
-			_vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(championIndex);
+			_vm->_menuMan->setMagicCasterAndDrawSpellArea(championIndex);
 
 		return;
 	}
@@ -1566,7 +1566,7 @@ void EventManager::commandProcessTypes101To108_clickInSpellSymbolsArea(CommandTy
 			return;
 
 		commandHighlightBoxEnable(234, 303, 63, 73);
-		_vm->_stopWaitingForPlayerInput = _vm->_menuMan->f408_getClickOnSpellCastResult();
+		_vm->_stopWaitingForPlayerInput = _vm->_menuMan->getClickOnSpellCastResult();
 		return;
 	}
 
@@ -1577,9 +1577,9 @@ void EventManager::commandProcessTypes101To108_clickInSpellSymbolsArea(CommandTy
 	highlightBoxDisable();
 
 	if (symbolIndex < 6)
-		_vm->_menuMan->f399_addChampionSymbol(symbolIndex);
+		_vm->_menuMan->addChampionSymbol(symbolIndex);
 	else
-		_vm->_menuMan->f400_deleteChampionSymbol();
+		_vm->_menuMan->deleteChampionSymbol();
 }
 
 void EventManager::commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY) {
@@ -1588,8 +1588,8 @@ void EventManager::commandProcessType111To115_ClickInActionArea(int16 posX, int1
 		if (mouseCommand != k0_CommandNone) {
 			if (mouseCommand == k112_CommandClickInActionAreaPass) {
 				commandHighlightBoxEnable(285, 319, 77, 83);
-				_vm->_menuMan->f391_didClickTriggerAction(-1);
-			} else if ((mouseCommand - k112_CommandClickInActionAreaPass) <= _vm->_menuMan->_g507_actionCount) {
+				_vm->_menuMan->didClickTriggerAction(-1);
+			} else if ((mouseCommand - k112_CommandClickInActionAreaPass) <= _vm->_menuMan->_actionCount) {
 				if (mouseCommand == k113_CommandClickInActionAreaAction_0)
 					commandHighlightBoxEnable(234, 318, 86, 96);
 				else if (mouseCommand == k114_CommandClickInActionAreaAction_1)
@@ -1597,15 +1597,15 @@ void EventManager::commandProcessType111To115_ClickInActionArea(int16 posX, int1
 				else
 					commandHighlightBoxEnable(234, 318, 110, 120);
 
-				_vm->_stopWaitingForPlayerInput = _vm->_menuMan->f391_didClickTriggerAction(mouseCommand - k113_CommandClickInActionAreaAction_0);
+				_vm->_stopWaitingForPlayerInput = _vm->_menuMan->didClickTriggerAction(mouseCommand - k113_CommandClickInActionAreaAction_0);
 			}
 		}
-	} else if (_vm->_menuMan->_g509_actionAreaContainsIcons) {
+	} else if (_vm->_menuMan->_actionAreaContainsIcons) {
 		uint16 mouseCommand = getCommandTypeFromMouseInput(_mouseInputActionAreaIcons, Common::Point(posX, posY), k1_LeftMouseButton);
 		if (mouseCommand != k0_CommandNone) {
 			mouseCommand -= k116_CommandClickInActionAreaChampion_0_Action;
 			if (mouseCommand < _vm->_championMan->_partyChampionCount)
-				_vm->_menuMan->f389_processCommands116To119_setActingChampion(mouseCommand);
+				_vm->_menuMan->processCommands116To119_setActingChampion(mouseCommand);
 		}
 	}
 }
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 36d09bb..0cbc095 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -119,7 +119,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 		}
 		if (championIndex == k4_ChampionCloseInventory) {
 			_vm->_eventMan->_refreshMousePointerInMainLoop = true;
-			_vm->_menuMan->f395_drawMovementArrows();
+			_vm->_menuMan->drawMovementArrows();
 			_vm->_eventMan->hideMouse();
 			_vm->_eventMan->_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputMovement;
 			_vm->_eventMan->_secondaryKeyboardInput = _vm->_eventMan->_secondaryKeyboardInputMovement;
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 4442c6c..d30eb62 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -164,7 +164,7 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
 
 
 void DMEngine::saveGame() {
-	_menuMan->f456_drawDisabledMenu();
+	_menuMan->drawDisabledMenu();
 	_eventMan->showMouse();
 
 	switch (getGameLanguage()) { // localized
@@ -247,7 +247,7 @@ void DMEngine::saveGame() {
 	}
 
 	_restartGameAllowed = true;
-	_menuMan->f457_drawEnabledMenus();
+	_menuMan->drawEnabledMenus();
 	_eventMan->hideMouse();
 }
 
diff --git a/engines/dm/lzw.cpp b/engines/dm/lzw.cpp
index c5acc9c..63b60c5 100644
--- a/engines/dm/lzw.cpp
+++ b/engines/dm/lzw.cpp
@@ -104,7 +104,7 @@ int16 LZWdecompressor::getNextInputCode(Common::MemoryReadStream &inputStream, i
 	return nextInputCode;
 }
 
-void LZWdecompressor::F0496_LZW_OutputCharacter(byte character, byte **out) {
+void LZWdecompressor::outputCharacter(byte character, byte **out) {
 	byte *L1558_pc_Output = *out;
 
 	if (false == _repetitionEnabled) {
@@ -147,7 +147,7 @@ int32 LZWdecompressor::decompress(Common::MemoryReadStream &inStream, int32 inpu
 	if (oldCode == -1) {
 		return -1L;
 	}
-	F0496_LZW_OutputCharacter(character, &out);
+	outputCharacter(character, &out);
 	int16 code;
 	while ((code = getNextInputCode(inStream, &inputByteCount)) > -1) {
 		if (code == 256) { /* This code is used to flush the dictionary */
@@ -174,7 +174,7 @@ int32 LZWdecompressor::decompress(Common::MemoryReadStream &inStream, int32 inpu
 		*reversedDecodedStringEnd++ = (character = _appendCharacter[code]);
 		/* Output the decoded string in reverse order */
 		do {
-			F0496_LZW_OutputCharacter(*(--reversedDecodedStringEnd), &out);
+			outputCharacter(*(--reversedDecodedStringEnd), &out);
 		} while (reversedDecodedStringEnd > reversedDecodedStringStart);
 		/* If possible, add a new code to the string table */
 		if ((code = _dictNextAvailableCode) < _absoluteMaximumCode) {
diff --git a/engines/dm/lzw.h b/engines/dm/lzw.h
index 80c18c5..a83f1ad 100644
--- a/engines/dm/lzw.h
+++ b/engines/dm/lzw.h
@@ -53,7 +53,7 @@ class LZWdecompressor {
 	byte *_appendCharacter;
 
 	int16 getNextInputCode(Common::MemoryReadStream &stream, int32 *inputByteCount);
-	void F0496_LZW_OutputCharacter(byte character, byte **out);
+	void outputCharacter(byte character, byte **out);
 	void operator=(const LZWdecompressor&); // deleted
 public:
 	LZWdecompressor();
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index e52b01e..ce372f0 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -90,54 +90,54 @@ void MenuMan::initConstants() {
 		3 /* FUSE */
 	};
 
-	boxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
-	boxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
-	boxActionArea3ActionMenu = Box(224, 319, 77, 121); // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu
-	boxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea 
-	boxSpellArea = Box(224, 319, 42, 74);
+	_boxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
+	_boxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
+	_boxActionArea3ActionMenu = Box(224, 319, 77, 121); // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu
+	_boxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea 
+	_boxSpellArea = Box(224, 319, 42, 74);
 
 	for (int i = 0; i < 40; i++)
-		g496_ActionSkillIndex[i] = actionSkillIndex[i];
+		_actionSkillIndex[i] = actionSkillIndex[i];
 }
 
 MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
-	_g508_refreshActionArea = false;
-	_g509_actionAreaContainsIcons = false;
-	_g513_actionDamage = 0;
-	_g713_actionList.resetToZero();
-	_gK72_bitmapSpellAreaLine = new byte[96 * 12];
-	_gK73_bitmapSpellAreaLines = new byte[3 * 96 * 12];
-	_g517_actionTargetGroupThing = Thing(0);
-	_g507_actionCount = 0;
+	_refreshActionArea = false;
+	_actionAreaContainsIcons = false;
+	_actionDamage = 0;
+	_actionList.resetToZero();
+	_bitmapSpellAreaLine = new byte[96 * 12];
+	_bitmapSpellAreaLines = new byte[3 * 96 * 12];
+	_actionTargetGroupThing = Thing(0);
+	_actionCount = 0;
 
 	initConstants();
 }
 
 MenuMan::~MenuMan() {
-	delete[] _gK72_bitmapSpellAreaLine;
+	delete[] _bitmapSpellAreaLine;
 }
 
-void MenuMan::f395_drawMovementArrows() {
+void MenuMan::drawMovementArrows() {
 	_vm->_eventMan->showMouse();
 	_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k13_MovementArrowsIndice),
 									   &_vm->_displayMan->_boxMovementArrows, k48_byteWidth, kM1_ColorNoTransparency, 45);
 	_vm->_eventMan->hideMouse();
 }
-void MenuMan::f388_clearActingChampion() {
+void MenuMan::clearActingChampion() {
 	ChampionMan &cm = *_vm->_championMan;
 	if (cm._actingChampionOrdinal) {
 		cm._actingChampionOrdinal--;
 		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
 		cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal);
 		cm._actingChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
-		_g508_refreshActionArea = true;
+		_refreshActionArea = true;
 	}
 }
 
-void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) {
+void MenuMan::drawActionIcon(ChampionIndex championIndex) {
 	static byte palChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon
 
-	if (!_g509_actionAreaContainsIcons)
+	if (!_actionAreaContainsIcons)
 		return;
 	DisplayMan &dm = *_vm->_displayMan;
 	Champion &champion = _vm->_championMan->_champions[championIndex];
@@ -178,7 +178,7 @@ T0386006:
 	}
 }
 
-void MenuMan::f456_drawDisabledMenu() {
+void MenuMan::drawDisabledMenu() {
 	if (!_vm->_championMan->_partyIsSleeping) {
 		_vm->_eventMan->highlightBoxDisable();
 		_vm->_displayMan->_useByteBoxCoordinates = false;
@@ -189,13 +189,13 @@ void MenuMan::f456_drawDisabledMenu() {
 		} else {
 			_vm->_displayMan->shadeScreenBox(&_vm->_displayMan->_boxMovementArrows, k0_ColorBlack);
 		}
-		_vm->_displayMan->shadeScreenBox(&boxSpellArea, k0_ColorBlack);
-		_vm->_displayMan->shadeScreenBox(&boxActionArea, k0_ColorBlack);
+		_vm->_displayMan->shadeScreenBox(&_boxSpellArea, k0_ColorBlack);
+		_vm->_displayMan->shadeScreenBox(&_boxActionArea, k0_ColorBlack);
 		_vm->_eventMan->setMousePointerToNormal(k0_pointerArrow);
 	}
 }
 
-void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
+void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
 	ChampionMan &champMan = *_vm->_championMan;
 
 	if (!champMan._partyChampionCount)
@@ -204,7 +204,7 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
 	Champion *champ = nullptr;
 	if (champMan._partyIsSleeping || champMan._candidateChampionOrdinal) {
 		if (champMan._actingChampionOrdinal) {
-			f388_clearActingChampion();
+			clearActingChampion();
 			return;
 		}
 		if (!champMan._candidateChampionOrdinal)
@@ -229,20 +229,20 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
 		} while (champIndex < champMan._partyChampionCount);
 	}
 
-	if (_g508_refreshActionArea) {
+	if (_refreshActionArea) {
 		if (!champMan._actingChampionOrdinal) {
-			if (_g513_actionDamage) {
-				f385_drawActionDamage(_g513_actionDamage);
-				_g513_actionDamage = 0;
+			if (_actionDamage) {
+				drawActionDamage(_actionDamage);
+				_actionDamage = 0;
 			} else {
-				_g509_actionAreaContainsIcons = true;
-				f387_drawActionArea();
+				_actionAreaContainsIcons = true;
+				drawActionArea();
 			}
 		} else {
-			_g509_actionAreaContainsIcons = false;
+			_actionAreaContainsIcons = false;
 			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
 			champMan.drawChampionState((ChampionIndex)_vm->ordinalToIndex(champMan._actingChampionOrdinal));
-			f387_drawActionArea();
+			drawActionArea();
 		}
 	}
 }
@@ -250,23 +250,23 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() {
 #define k7_ChampionNameMaximumLength 7 // @ C007_CHAMPION_NAME_MAXIMUM_LENGTH
 #define k12_ActionNameMaximumLength 12 // @ C012_ACTION_NAME_MAXIMUM_LENGTH
 
-void MenuMan::f387_drawActionArea() {
+void MenuMan::drawActionArea() {
 	DisplayMan &dispMan = *_vm->_displayMan;
 	ChampionMan &champMan = *_vm->_championMan;
 	TextMan &textMan = *_vm->_textMan;
 
 	_vm->_eventMan->hideMouse();
 	dispMan._useByteBoxCoordinates = false;
-	dispMan.fillScreenBox(boxActionArea, k0_ColorBlack);
-	if (_g509_actionAreaContainsIcons) {
+	dispMan.fillScreenBox(_boxActionArea, k0_ColorBlack);
+	if (_actionAreaContainsIcons) {
 		for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._partyChampionCount; ++champIndex)
-			f386_drawActionIcon((ChampionIndex)champIndex);
+			drawActionIcon((ChampionIndex)champIndex);
 	} else if (champMan._actingChampionOrdinal) {
-		Box box = boxActionArea3ActionMenu;
-		if (_g713_actionList._actionIndices[2] == k255_ChampionActionNone)
-			box = boxActionArea2ActionMenu;
-		if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone)
-			box = boxActionArea1ActionMenu;
+		Box box = _boxActionArea3ActionMenu;
+		if (_actionList._actionIndices[2] == k255_ChampionActionNone)
+			box = _boxActionArea2ActionMenu;
+		if (_actionList._actionIndices[1] == k255_ChampionActionNone)
+			box = _boxActionArea1ActionMenu;
 		dispMan.blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k10_MenuActionAreaIndice),
 								 &box, k48_byteWidth, kM1_ColorNoTransparency, 45);
 		textMan.f41_printWithTrailingSpaces(dispMan._bitmapScreen, k160_byteWidthScreen,
@@ -274,15 +274,15 @@ void MenuMan::f387_drawActionArea() {
 											k7_ChampionNameMaximumLength, k200_heightScreen);
 		for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) {
 			textMan.f41_printWithTrailingSpaces(dispMan._bitmapScreen, k160_byteWidthScreen, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
-												f384_getActionName(_g713_actionList._actionIndices[actionListIndex]),
+												getActionName(_actionList._actionIndices[actionListIndex]),
 												k12_ActionNameMaximumLength, k200_heightScreen);
 		}
 	}
 	_vm->_eventMan->showMouse();
-	_g508_refreshActionArea = false;
+	_refreshActionArea = false;
 }
 
-const char* MenuMan::f384_getActionName(ChampionAction actionIndex) {
+const char* MenuMan::getActionName(ChampionAction actionIndex) {
 	const char *g490_ChampionActionNames[44] = { // @ G0490_ac_Graphic560_ActionNames
 		"N", "BLOCK", "CHOP", "X", "BLOW HORN", "FLIP", "PUNCH",
 		"KICK", "WAR CRY", "STAB", "CLIMB DOWN", "FREEZE LIFE",
@@ -297,7 +297,7 @@ const char* MenuMan::f384_getActionName(ChampionAction actionIndex) {
 	return (actionIndex == k255_ChampionActionNone) ? "" : g490_ChampionActionNames[actionIndex];
 }
 
-void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) {
+void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
 	static Box boxSpellAreaControls(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls 
 
 	Champion *champ = &_vm->_championMan->_champions[champIndex];
@@ -369,33 +369,33 @@ T0393003:
 #define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
 #define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
 
-void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) {
+void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
 	static Box boxSpellAreaLine(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine 
 
 	char L1204_ac_SpellSymbolString[2] = {'\0', '\0'};
 	Champion *L1203_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
 	if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) {
 		_vm->_displayMan->_useByteBoxCoordinates = false;
-		_vm->_displayMan->blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, boxSpellAreaLine, 0, 12, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
+		_vm->_displayMan->blitToBitmap(_bitmapSpellAreaLines, _bitmapSpellAreaLine, boxSpellAreaLine, 0, 12, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
 		int16 x = 1;
 		char character = 96 + (6 * L1203_ps_Champion->_symbolStep);
 		for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
 			L1204_ac_SpellSymbolString[0] = character++;
-			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 14, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
+			_vm->_textMan->f40_printTextToBitmap(_bitmapSpellAreaLine, 48, x += 14, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
 		}
 	} else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) {
 		_vm->_displayMan->_useByteBoxCoordinates = false;
-		_vm->_displayMan->blitToBitmap(_gK73_bitmapSpellAreaLines, _gK72_bitmapSpellAreaLine, boxSpellAreaLine, 0, 24, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
+		_vm->_displayMan->blitToBitmap(_bitmapSpellAreaLines, _bitmapSpellAreaLine, boxSpellAreaLine, 0, 24, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
 		int16 x = 8;
 		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
 			if ((L1204_ac_SpellSymbolString[0] = L1203_ps_Champion->_symbols[symbolIndex]) == '\0')
 				break;
-			_vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 9, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
+			_vm->_textMan->f40_printTextToBitmap(_bitmapSpellAreaLine, 48, x += 9, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
 		}
 	}
 }
 
-void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
+void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	static Box boxSpellAreaLine2(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 
 	static Box boxSpellAreaLine3(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 
 
@@ -406,28 +406,28 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	}
 	if (_vm->_championMan->_magicCasterChampionIndex == kM1_ChampionNone) {
 		_vm->_eventMan->showMouse();
-		_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &boxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33);
+		_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &_boxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33);
 		_vm->_eventMan->hideMouse();
 	}
 	if (champIndex == kM1_ChampionNone) {
 		_vm->_championMan->_magicCasterChampionIndex = kM1_ChampionNone;
 		_vm->_eventMan->showMouse();
 		_vm->_displayMan->_useByteBoxCoordinates = false;
-		_vm->_displayMan->fillScreenBox(boxSpellArea, k0_ColorBlack);
+		_vm->_displayMan->fillScreenBox(_boxSpellArea, k0_ColorBlack);
 		_vm->_eventMan->hideMouse();
 		return;
 	}
 	L1213_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex = (ChampionIndex)champIndex];
-	f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
+	buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
 	_vm->_eventMan->showMouse();
-	f393_drawSpellAreaControls((ChampionIndex)champIndex);
-	_vm->_displayMan->blitToScreen(_gK72_bitmapSpellAreaLine, &boxSpellAreaLine2, k48_byteWidth, kM1_ColorNoTransparency, 12);
-	f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols);
-	_vm->_displayMan->blitToScreen(_gK72_bitmapSpellAreaLine, &boxSpellAreaLine3, k48_byteWidth, kM1_ColorNoTransparency, 12);
+	drawSpellAreaControls((ChampionIndex)champIndex);
+	_vm->_displayMan->blitToScreen(_bitmapSpellAreaLine, &boxSpellAreaLine2, k48_byteWidth, kM1_ColorNoTransparency, 12);
+	buildSpellAreaLine(k3_SpellAreaChampionSymbols);
+	_vm->_displayMan->blitToScreen(_bitmapSpellAreaLine, &boxSpellAreaLine3, k48_byteWidth, kM1_ColorNoTransparency, 12);
 	_vm->_eventMan->hideMouse();
 }
 
-void MenuMan::f457_drawEnabledMenus() {
+void MenuMan::drawEnabledMenus() {
 	int16 L1462_i_Multiple;
 #define AL1462_i_MagicCasterChampionIndex L1462_i_Multiple
 #define AL1462_i_InventoryChampionOrdinal L1462_i_Multiple
@@ -439,24 +439,24 @@ void MenuMan::f457_drawEnabledMenus() {
 	} else {
 		AL1462_i_MagicCasterChampionIndex = _vm->_championMan->_magicCasterChampionIndex;
 		_vm->_championMan->_magicCasterChampionIndex = kM1_ChampionNone; /* Force next function to draw the spell area */
-		f394_setMagicCasterAndDrawSpellArea(AL1462_i_MagicCasterChampionIndex);
+		setMagicCasterAndDrawSpellArea(AL1462_i_MagicCasterChampionIndex);
 		if (!_vm->_championMan->_actingChampionOrdinal) {
-			_g509_actionAreaContainsIcons = true;
+			_actionAreaContainsIcons = true;
 		}
-		f387_drawActionArea();
+		drawActionArea();
 		AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_inventoryChampionOrdinal;
 		if (AL1462_i_InventoryChampionOrdinal) {
 			_vm->_inventoryMan->_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 			_vm->_inventoryMan->toggleInventory((ChampionIndex)_vm->ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
 		} else {
 			_vm->_displayMan->drawFloorAndCeiling();
-			f395_drawMovementArrows();
+			drawMovementArrows();
 		}
 		_vm->_eventMan->setMousePointer();
 	}
 }
 
-int16 MenuMan::f408_getClickOnSpellCastResult() {
+int16 MenuMan::getClickOnSpellCastResult() {
 	int16 L1259_i_SpellCastResult;
 	Champion* L1260_ps_Champion;
 
@@ -464,10 +464,10 @@ int16 MenuMan::f408_getClickOnSpellCastResult() {
 	L1260_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
 	_vm->_eventMan->showMouse();
 	_vm->_eventMan->highlightBoxDisable();
-	if ((L1259_i_SpellCastResult = f412_getChampionSpellCastResult(_vm->_championMan->_magicCasterChampionIndex)) != k3_spellCastFailureNeedsFlask) {
+	if ((L1259_i_SpellCastResult = getChampionSpellCastResult(_vm->_championMan->_magicCasterChampionIndex)) != k3_spellCastFailureNeedsFlask) {
 		L1260_ps_Champion->_symbols[0] = '\0';
-		f397_drawAvailableSymbols(L1260_ps_Champion->_symbolStep = 0);
-		f398_drawChampionSymbols(L1260_ps_Champion);
+		drawAvailableSymbols(L1260_ps_Champion->_symbolStep = 0);
+		drawChampionSymbols(L1260_ps_Champion);
 	} else {
 		L1259_i_SpellCastResult = k0_spellCastFailure;
 	}
@@ -475,7 +475,7 @@ int16 MenuMan::f408_getClickOnSpellCastResult() {
 	return L1259_i_SpellCastResult;
 }
 
-int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
+int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 	uint16 L1267_ui_Multiple;
 #define AL1267_ui_SkillLevel L1267_ui_Multiple
 #define AL1267_ui_LightPower L1267_ui_Multiple
@@ -503,9 +503,9 @@ int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
 	if (!(L1270_ps_Champion->_currHealth)) {
 		return k0_spellCastFailure;
 	}
-	L1271_ps_Spell = f409_getSpellFromSymbols((unsigned char *)L1270_ps_Champion->_symbols);
+	L1271_ps_Spell = getSpellFromSymbols((unsigned char *)L1270_ps_Champion->_symbols);
 	if (L1271_ps_Spell == 0) {
-		f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k1_spellCastSuccess, 0);
+		menusPrintSpellFailureMessage(L1270_ps_Champion, k1_spellCastSuccess, 0);
 		return k0_spellCastFailure;
 	}
 	L1268_i_PowerSymbolOrdinal = L1270_ps_Champion->_symbols[0] - '_'; /* Values 1 to 6 */
@@ -517,15 +517,15 @@ int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
 		while (L1274_i_MissingSkillLevelCount--) {
 			if (_vm->getRandomNumber(128) > MIN(L1270_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + 15, 115)) {
 				_vm->_championMan->addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience >> (AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel));
-				f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k0_failureNeedsMorePractice, L1271_ps_Spell->_skillIndex);
+				menusPrintSpellFailureMessage(L1270_ps_Champion, k0_failureNeedsMorePractice, L1271_ps_Spell->_skillIndex);
 				return k0_spellCastFailure;
 			}
 		}
 	}
 	switch (L1271_ps_Spell->getKind()) {
 	case k1_spellKindPotion:
-		if ((L1275_ps_Potion = f411_getEmptyFlaskInHand(L1270_ps_Champion, &L1272_T_Object)) == NULL) {
-			f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k10_failureNeedsFlaskInHand, 0);
+		if ((L1275_ps_Potion = getEmptyFlaskInHand(L1270_ps_Champion, &L1272_T_Object)) == NULL) {
+			menusPrintSpellFailureMessage(L1270_ps_Champion, k10_failureNeedsFlaskInHand, 0);
 			return k3_spellCastFailureNeedsFlask;
 		}
 		AL1269_ui_EmptyFlaskWeight = _vm->_dungeonMan->getObjectWeight(L1272_T_Object);
@@ -564,12 +564,12 @@ int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) {
 			AL1267_ui_LightPower++;
 T0412019:
 			_vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[AL1267_ui_LightPower];
-			f404_createEvent70_light(-AL1267_ui_LightPower, AL1269_ui_Ticks);
+			createEvent70_light(-AL1267_ui_LightPower, AL1269_ui_Ticks);
 			break;
 		case k1_spellType_otherDarkness:
 			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
 			_vm->_championMan->_party._magicalLightAmount -= _vm->_championMan->_lightPowerToLightAmount[AL1267_ui_LightPower];
-			f404_createEvent70_light(AL1267_ui_LightPower, 98);
+			createEvent70_light(AL1267_ui_LightPower, 98);
 			break;
 		case k2_spellType_otherThievesEye:
 			L1276_s_Event._type = k73_TMEventTypeThievesEye;
@@ -627,7 +627,7 @@ T0412033:
 			}
 			break;
 		case k8_spellType_otherFireshield:
-			f403_isPartySpellOrFireShieldSuccessful(L1270_ps_Champion, false, (AL1267_ui_SpellPower * AL1267_ui_SpellPower) + 100, false);
+			isPartySpellOrFireShieldSuccessful(L1270_ps_Champion, false, (AL1267_ui_SpellPower * AL1267_ui_SpellPower) + 100, false);
 		}
 	}
 	_vm->_championMan->addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience);
@@ -635,7 +635,7 @@ T0412033:
 	return k1_spellCastSuccess;
 }
 
-Spell* MenuMan::f409_getSpellFromSymbols(byte* symbols) {
+Spell* MenuMan::getSpellFromSymbols(byte* symbols) {
 	static Spell G0487_as_Graphic560_Spells[25] = {
 		/* { Symbols, BaseRequiredSkillLevel, SkillIndex, Attributes } */
 		Spell(0x00666F00, 2, 15, 0x7843),
@@ -689,7 +689,7 @@ Spell* MenuMan::f409_getSpellFromSymbols(byte* symbols) {
 	return NULL;
 }
 
-void MenuMan::f410_menusPrintSpellFailureMessage(Champion* champ, uint16 failureType, uint16 skillIndex) {
+void MenuMan::menusPrintSpellFailureMessage(Champion* champ, uint16 failureType, uint16 skillIndex) {
 	const char *L1264_pc_Message = nullptr;
 
 	if (skillIndex > k3_ChampionSkillWizard)
@@ -734,7 +734,7 @@ void MenuMan::f410_menusPrintSpellFailureMessage(Champion* champ, uint16 failure
 	_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, L1264_pc_Message);
 }
 
-Potion* MenuMan::f411_getEmptyFlaskInHand(Champion* champ, Thing* potionThing) {
+Potion* MenuMan::getEmptyFlaskInHand(Champion* champ, Thing* potionThing) {
 	Thing L1265_T_Thing;
 	int16 L1266_i_SlotIndex;
 
@@ -747,7 +747,7 @@ Potion* MenuMan::f411_getEmptyFlaskInHand(Champion* champ, Thing* potionThing) {
 	return nullptr;
 }
 
-void MenuMan::f404_createEvent70_light(int16 lightPower, int16 ticks) {
+void MenuMan::createEvent70_light(int16 lightPower, int16 ticks) {
 	TimelineEvent L1241_s_Event;
 
 	L1241_s_Event._type = k70_TMEventTypeLight;
@@ -758,7 +758,7 @@ void MenuMan::f404_createEvent70_light(int16 lightPower, int16 ticks) {
 	_vm->_inventoryMan->setDungeonViewPalette();
 }
 
-bool MenuMan::f403_isPartySpellOrFireShieldSuccessful(Champion* champ, bool spellShield, uint16 ticks, bool useMana) {
+bool MenuMan::isPartySpellOrFireShieldSuccessful(Champion* champ, bool spellShield, uint16 ticks, bool useMana) {
 	bool L1239_B_IsPartySpellOrFireShieldSuccessful;
 	TimelineEvent L1240_s_Event;
 
@@ -797,7 +797,7 @@ bool MenuMan::f403_isPartySpellOrFireShieldSuccessful(Champion* champ, bool spel
 	return L1239_B_IsPartySpellOrFireShieldSuccessful;
 }
 
-void MenuMan::f397_drawAvailableSymbols(uint16 symbolStep) {
+void MenuMan::drawAvailableSymbols(uint16 symbolStep) {
 	uint16 L1214_ui_Counter;
 	int16 L1215_i_X;
 	char L1216_c_Character;
@@ -812,7 +812,7 @@ void MenuMan::f397_drawAvailableSymbols(uint16 symbolStep) {
 	}
 }
 
-void MenuMan::f398_drawChampionSymbols(Champion* champ) {
+void MenuMan::drawChampionSymbols(Champion* champ) {
 	uint16 L1218_ui_SymbolIndex;
 	int16 L1219_i_X;
 	uint16 L1220_ui_SymbolCount;
@@ -832,7 +832,7 @@ void MenuMan::f398_drawChampionSymbols(Champion* champ) {
 	}
 }
 
-void MenuMan::f399_addChampionSymbol(int16 symbolIndex) {
+void MenuMan::addChampionSymbol(int16 symbolIndex) {
 	static byte G0485_aauc_Graphic560_SymbolBaseManaCost[4][6] = {
 		{1, 2, 3, 4, 5, 6},   /* Power 1 */
 		{2, 3, 4, 5, 6, 7},   /* Power 2 */
@@ -858,14 +858,14 @@ void MenuMan::f399_addChampionSymbol(int16 symbolIndex) {
 		L1225_ps_Champion->_symbols[L1222_ui_SymbolStep + 1] = '\0';
 		L1225_ps_Champion->_symbolStep = L1222_ui_SymbolStep = returnNextVal(L1222_ui_SymbolStep);
 		_vm->_eventMan->showMouse();
-		f397_drawAvailableSymbols(L1222_ui_SymbolStep);
-		f398_drawChampionSymbols(L1225_ps_Champion);
+		drawAvailableSymbols(L1222_ui_SymbolStep);
+		drawChampionSymbols(L1225_ps_Champion);
 		_vm->_championMan->drawChampionState(_vm->_championMan->_magicCasterChampionIndex);
 		_vm->_eventMan->hideMouse();
 	}
 }
 
-void MenuMan::f400_deleteChampionSymbol() {
+void MenuMan::deleteChampionSymbol() {
 	int16 L1226_ui_SymbolStep;
 	Champion* L1228_ps_Champion;
 
@@ -876,19 +876,19 @@ void MenuMan::f400_deleteChampionSymbol() {
 	L1228_ps_Champion->_symbolStep = L1226_ui_SymbolStep = returnPrevVal(L1228_ps_Champion->_symbolStep);
 	L1228_ps_Champion->_symbols[L1226_ui_SymbolStep] = '\0';
 	_vm->_eventMan->showMouse();
-	f397_drawAvailableSymbols(L1226_ui_SymbolStep);
-	f398_drawChampionSymbols(L1228_ps_Champion);
+	drawAvailableSymbols(L1226_ui_SymbolStep);
+	drawChampionSymbols(L1228_ps_Champion);
 	_vm->_eventMan->hideMouse();
 }
 
-bool MenuMan::f391_didClickTriggerAction(int16 actionListIndex) {
+bool MenuMan::didClickTriggerAction(int16 actionListIndex) {
 	uint16 L1196_ui_ChampionIndex;
 	uint16 L1197_ui_ActionIndex;
 	bool L1198_B_ClickTriggeredAction;
 	Champion* L1199_ps_Champion;
 
 
-	if (!_vm->_championMan->_actingChampionOrdinal || (actionListIndex != -1 && (_g713_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone)))
+	if (!_vm->_championMan->_actingChampionOrdinal || (actionListIndex != -1 && (_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone)))
 		return false;
 
 	L1199_ps_Champion = &_vm->_championMan->_champions[L1196_ui_ChampionIndex = _vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)];
@@ -896,18 +896,18 @@ bool MenuMan::f391_didClickTriggerAction(int16 actionListIndex) {
 		// L1198_B_ClickTriggeredAction is set to -1 since booleans are stored in int16 in the original
 		L1198_B_ClickTriggeredAction = true;
 	} else {
-		L1197_ui_ActionIndex = _g713_actionList._actionIndices[actionListIndex];
+		L1197_ui_ActionIndex = _actionList._actionIndices[actionListIndex];
 		L1199_ps_Champion->_actionDefense += g495_actionDefense[L1197_ui_ActionIndex]; /* BUG0_54 The defense modifier of an action is permanent.
 																									 Each action has an associated defense modifier value and a number of ticks while the champion cannot perform another action because the action icon is grayed out. If an action has a non zero defense modifier and a zero value for the number of ticks then the defense modifier is applied but it is never removed. This causes no issue in the original games because there are no actions in this case but it may occur in a version where data is customized. This statement should only be executed if the value for the action in G0491_auc_Graphic560_ActionDisabledTicks is not 0 otherwise the action is not disabled at the end of F0407_MENUS_IsActionPerformed and thus not enabled later in F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction where the defense modifier is also removed */
 		setFlag(L1199_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
-		L1198_B_ClickTriggeredAction = f407_isActionPerformed(L1196_ui_ChampionIndex, L1197_ui_ActionIndex);
+		L1198_B_ClickTriggeredAction = isActionPerformed(L1196_ui_ChampionIndex, L1197_ui_ActionIndex);
 		L1199_ps_Champion->_actionIndex = (ChampionAction)L1197_ui_ActionIndex;
 	}
-	f388_clearActingChampion();
+	clearActingChampion();
 	return L1198_B_ClickTriggeredAction;
 }
 
-bool MenuMan::f407_isActionPerformed(uint16 champIndex, int16 actionIndex) {
+bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 	static unsigned char G0491_auc_Graphic560_ActionDisabledTicks[44] = {
 		0,  /* N */
 		6,  /* BLOCK */
@@ -1085,9 +1085,9 @@ bool MenuMan::f407_isActionPerformed(uint16 champIndex, int16 actionIndex) {
 	L1251_i_MapX = _vm->_dungeonMan->_partyMapX;
 	L1252_i_MapY = _vm->_dungeonMan->_partyMapY;
 	L1251_i_MapX += _vm->_dirIntoStepCountEast[L1247_ps_Champion->_dir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[L1247_ps_Champion->_dir];
-	_g517_actionTargetGroupThing = _vm->_groupMan->groupGetThing(L1251_i_MapX, L1252_i_MapY);
+	_actionTargetGroupThing = _vm->_groupMan->groupGetThing(L1251_i_MapX, L1252_i_MapY);
 	L1249_ui_ActionDisabledTicks = G0491_auc_Graphic560_ActionDisabledTicks[actionIndex];
-	L1254_i_ActionSkillIndex = g496_ActionSkillIndex[actionIndex];
+	L1254_i_ActionSkillIndex = _actionSkillIndex[actionIndex];
 	L1253_i_ActionStamina = G0494_auc_Graphic560_ActionStamina[actionIndex] + _vm->getRandomNumber(2);
 	L1255_i_ActionExperienceGain = G0497_auc_Graphic560_ActionExperienceGain[actionIndex];
 	AL1244_ui_TargetSquare = _vm->_dungeonMan->getSquare(L1251_i_MapX, L1252_i_MapY).toByte();
@@ -1112,7 +1112,7 @@ bool MenuMan::f407_isActionPerformed(uint16 champIndex, int16 actionIndex) {
 T0407013:
 		AL1245_T_ExplosionThing = Thing::_explFireBall.toUint16();
 T0407014:
-		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+		setChampionDirectionToPartyDirection(L1247_ps_Champion);
 		if (L1247_ps_Champion->_currMana < AL1246_i_RequiredManaAmount) {
 			AL1250_i_KineticEnergy = MAX(2, L1247_ps_Champion->_currMana * AL1250_i_KineticEnergy / AL1246_i_RequiredManaAmount);
 			AL1246_i_RequiredManaAmount = L1247_ps_Champion->_currMana;
@@ -1120,7 +1120,7 @@ T0407014:
 		if (!(AL1245_B_ActionPerformed = _vm->_championMan->isProjectileSpellCast(champIndex, Thing(AL1245_T_ExplosionThing), AL1250_i_KineticEnergy, AL1246_i_RequiredManaAmount))) {
 			L1255_i_ActionExperienceGain >>= 1;
 		}
-		f405_decrementCharges(L1247_ps_Champion);
+		decrementCharges(L1247_ps_Champion);
 		break;
 	case k30_ChampionActionBash:
 	case k18_ChampionActionHack:
@@ -1146,13 +1146,13 @@ T0407014:
 	case k28_ChampionActionSlash:
 	case k29_ChampionActionCleave:
 	case k6_ChampionActionPunch:
-		if (!(AL1245_B_ActionPerformed = f402_isMeleeActionPerformed(champIndex, L1247_ps_Champion, actionIndex, L1251_i_MapX, L1252_i_MapY, L1254_i_ActionSkillIndex))) {
+		if (!(AL1245_B_ActionPerformed = isMeleeActionPerformed(champIndex, L1247_ps_Champion, actionIndex, L1251_i_MapX, L1252_i_MapY, L1254_i_ActionSkillIndex))) {
 			L1255_i_ActionExperienceGain >>= 1;
 			L1249_ui_ActionDisabledTicks >>= 1;
 		}
 		break;
 	case k22_ChampionActionConfuse:
-		f405_decrementCharges(L1247_ps_Champion);
+		decrementCharges(L1247_ps_Champion);
 	case k8_ChampionActionWarCry:
 	case k37_ChampionActionCalm:
 	case k41_ChampionActionBrandish:
@@ -1163,7 +1163,7 @@ T0407014:
 		if (actionIndex == k4_ChampionActionBlowHorn) {
 			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k25_soundBLOW_HORN, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
 		}
-		AL1245_B_ActionPerformed = f401_isGroupFrightenedByAction(champIndex, actionIndex, L1251_i_MapX, L1252_i_MapY);
+		AL1245_B_ActionPerformed = isGroupFrightenedByAction(champIndex, actionIndex, L1251_i_MapX, L1252_i_MapY);
 		break;
 	case k32_ChampionActionShoot:
 		if (Thing(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]).getType() != k5_WeaponThingType)
@@ -1180,7 +1180,7 @@ T0407014:
 			if ((AL1246_i_ActionHandWeaponClass >= k32_WeaponClassFirstSling) && (AL1246_i_ActionHandWeaponClass <= k47_WeaponClassLastSling)) {
 				if (AL1250_i_ReadyHandWeaponClass != k11_WeaponClassSlingAmmunition) {
 T0407032:
-					_g513_actionDamage = kM2_damageNoAmmunition;
+					_actionDamage = kM2_damageNoAmmunition;
 					L1255_i_ActionExperienceGain = 0;
 					AL1245_B_ActionPerformed = false;
 					break;
@@ -1188,7 +1188,7 @@ T0407032:
 				AL1246_i_StepEnergy -= k32_WeaponClassFirstSling;
 			}
 		}
-		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+		setChampionDirectionToPartyDirection(L1247_ps_Champion);
 		{ // so gotos won't skip init
 			Thing AL1250_T_Object = _vm->_championMan->getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
 			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
@@ -1207,19 +1207,19 @@ T0407032:
 		case Common::FR_FRA: message = messages_FR_FRA; break;
 		}
 		if (_vm->getRandomNumber(2)) {
-			f381_printMessageAfterReplacements(message[0]);
+			printMessageAfterReplacements(message[0]);
 		} else {
-			f381_printMessageAfterReplacements(message[1]);
+			printMessageAfterReplacements(message[1]);
 		}
 	}
 								break;
 	case k33_ChampionActionSpellshield:
 	case k34_ChampionActionFireshield:
-		if (!f403_isPartySpellOrFireShieldSuccessful(L1247_ps_Champion, actionIndex == k33_ChampionActionSpellshield, 280, true)) {
+		if (!isPartySpellOrFireShieldSuccessful(L1247_ps_Champion, actionIndex == k33_ChampionActionSpellshield, 280, true)) {
 			L1255_i_ActionExperienceGain >>= 2;
 			L1249_ui_ActionDisabledTicks >>= 1;
 		} else {
-			f405_decrementCharges(L1247_ps_Champion);
+			decrementCharges(L1247_ps_Champion);
 		}
 		break;
 	case k27_ChampionActionInvoke:
@@ -1238,11 +1238,11 @@ T0407032:
 			goto T0407013;
 		}
 	case k35_ChampionActionFluxcage:
-		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+		setChampionDirectionToPartyDirection(L1247_ps_Champion);
 		_vm->_groupMan->fluxCageAction(L1251_i_MapX, L1252_i_MapY);
 		break;
 	case k43_ChampionActionFuse:
-		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+		setChampionDirectionToPartyDirection(L1247_ps_Champion);
 		L1251_i_MapX = _vm->_dungeonMan->_partyMapX;
 		L1252_i_MapY = _vm->_dungeonMan->_partyMapY;
 		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
@@ -1304,18 +1304,18 @@ T0407071:
 			L1248_ps_Weapon->setNextThing(Thing::_none);
 		} else {
 			AL1246_i_Ticks = 70;
-			f405_decrementCharges(L1247_ps_Champion);
+			decrementCharges(L1247_ps_Champion);
 		}
 		_vm->_championMan->_party._freezeLifeTicks = MIN(200, _vm->_championMan->_party._freezeLifeTicks + AL1246_i_Ticks);
 		break;
 	case k38_ChampionActionLight:
 		_vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[2];
-		f404_createEvent70_light(-2, 2500);
+		createEvent70_light(-2, 2500);
 T0407076:
-		f405_decrementCharges(L1247_ps_Champion);
+		decrementCharges(L1247_ps_Champion);
 		break;
 	case k42_ChampionActionThrow:
-		f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+		setChampionDirectionToPartyDirection(L1247_ps_Champion);
 		AL1245_B_ActionPerformed = _vm->_championMan->isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_partyDir)) || (L1247_ps_Champion->_cell == (ViewCell)returnOppositeDir(_vm->_dungeonMan->_partyDir)));
 		if (AL1245_B_ActionPerformed) {
 			_vm->_timeline->_g370_events[L1247_ps_Champion->_enableActionEventIndex]._B._slotOrdinal = _vm->indexToOrdinal(k1_ChampionSlotActionHand);
@@ -1334,14 +1334,14 @@ T0407076:
 	return AL1245_B_ActionPerformed;
 }
 
-void MenuMan::f406_setChampionDirectionToPartyDirection(Champion* champ) {
+void MenuMan::setChampionDirectionToPartyDirection(Champion* champ) {
 	if (champ->_dir != _vm->_dungeonMan->_partyDir) {
 		champ->_dir = _vm->_dungeonMan->_partyDir;
 		setFlag(champ->_attributes, k0x0400_ChampionAttributeIcon);
 	}
 }
 
-void MenuMan::f405_decrementCharges(Champion* champ) {
+void MenuMan::decrementCharges(Champion* champ) {
 	Thing L1242_T_Thing;
 	Junk* L1243_ps_Junk;
 
@@ -1368,7 +1368,7 @@ void MenuMan::f405_decrementCharges(Champion* champ) {
 	_vm->_championMan->drawChangedObjectIcons();
 }
 
-bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int16 actionIndex, int16 targetMapX, int16 targetMapY, int16 skillIndex) {
+bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion* champ, int16 actionIndex, int16 targetMapX, int16 targetMapY, int16 skillIndex) {
 	static unsigned char G0492_auc_Graphic560_ActionDamageFactor[44] = {
 		0,  /* N */
 		15, /* BLOCK */
@@ -1470,7 +1470,7 @@ bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int
 	int16 L1238_i_CreatureOrdinal;
 
 	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
-	if (_g517_actionTargetGroupThing == Thing::_endOfList)
+	if (_actionTargetGroupThing == Thing::_endOfList)
 		goto T0402010;
 	L1238_i_CreatureOrdinal = _vm->_groupMan->getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, AL1236_ui_ChampionCell = champ->_cell);
 	if (L1238_i_CreatureOrdinal) {
@@ -1482,25 +1482,25 @@ bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int
 			AL1237_ui_CellDelta = 1;
 T0402005: /* Check if there is another champion in front */
 			if (_vm->_championMan->getIndexInCell(normalizeModulo4(AL1236_ui_ChampionCell + AL1237_ui_CellDelta)) != kM1_ChampionNone) {
-				_g513_actionDamage = kM1_damageCantReach;
+				_actionDamage = kM1_damageCantReach;
 				goto T0402010;
 			}
 		}
-		if ((actionIndex == k24_ChampionActionDisrupt) && !getFlag(_vm->_dungeonMan->getCreatureAttributes(_g517_actionTargetGroupThing), k0x0040_MaskCreatureInfo_nonMaterial))
+		if ((actionIndex == k24_ChampionActionDisrupt) && !getFlag(_vm->_dungeonMan->getCreatureAttributes(_actionTargetGroupThing), k0x0040_MaskCreatureInfo_nonMaterial))
 			goto T0402010;
 		AL1237_ui_ActionHitProbability = G0493_auc_Graphic560_ActionHitProbability[actionIndex];
 		AL1236_ui_ActionDamageFactor = G0492_auc_Graphic560_ActionDamageFactor[actionIndex];
 		if ((_vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
 			setFlag(AL1237_ui_ActionHitProbability, k0x8000_hitNonMaterialCreatures);
 		}
-		_g513_actionDamage = _vm->_groupMan->getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->getThingData(_g517_actionTargetGroupThing), _vm->ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
+		_actionDamage = _vm->_groupMan->getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->getThingData(_actionTargetGroupThing), _vm->ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
 		return true;
 	}
 T0402010:
 	return false;
 }
 
-bool MenuMan::f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, int16 mapX, int16 mapY) {
+bool MenuMan::isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, int16 mapX, int16 mapY) {
 	int16 L1229_i_FrightAmount = 0;
 	uint16 L1230_ui_FearResistance;
 	uint16 L1231_ui_Experience = 0;
@@ -1511,7 +1511,7 @@ bool MenuMan::f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionInde
 
 
 	L1232_B_IsGroupFrightenedByAction = false;
-	if (_g517_actionTargetGroupThing == Thing::_endOfList)
+	if (_actionTargetGroupThing == Thing::_endOfList)
 		goto T0401016;
 	switch (actionIndex) {
 	case k8_ChampionActionWarCry:
@@ -1535,7 +1535,7 @@ bool MenuMan::f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionInde
 		L1231_ui_Experience = 45;
 	}
 	L1229_i_FrightAmount += _vm->_championMan->getSkillLevel(champIndex, k14_ChampionSkillInfluence);
-	L1233_ps_Group = (Group*)_vm->_dungeonMan->getThingData(_g517_actionTargetGroupThing);
+	L1233_ps_Group = (Group*)_vm->_dungeonMan->getThingData(_actionTargetGroupThing);
 	L1234_ps_CreatureInfo = &g243_CreatureInfo[L1233_ps_Group->_type];
 	if (((L1230_ui_FearResistance = L1234_ps_CreatureInfo->getFearResistance()) > _vm->getRandomNumber(L1229_i_FrightAmount)) || (L1230_ui_FearResistance == k15_immuneToFear)) {
 		L1231_ui_Experience >>= 1;
@@ -1554,7 +1554,7 @@ T0401016:
 	return L1232_B_IsGroupFrightenedByAction;
 }
 
-void MenuMan::f381_printMessageAfterReplacements(const char* str) {
+void MenuMan::printMessageAfterReplacements(const char* str) {
 	char* L1164_pc_Character;
 	char* L1165_pc_ReplacementString;
 	char L1166_ac_OutputString[128];
@@ -1586,7 +1586,7 @@ void MenuMan::f381_printMessageAfterReplacements(const char* str) {
 	}
 }
 
-void MenuMan::f389_processCommands116To119_setActingChampion(uint16 champIndex) {
+void MenuMan::processCommands116To119_setActingChampion(uint16 champIndex) {
 	static ActionSet G0489_as_Graphic560_ActionSets[44] = {
 		/* { ActionIndices[0], ActionIndices[1], ActionIndices[2], ActionProperties[0], ActionProperties[1], Useless } */
 		ActionSet(255, 255, 255, 0x00, 0x00),
@@ -1650,15 +1650,15 @@ void MenuMan::f389_processCommands116To119_setActingChampion(uint16 champIndex)
 	}
 	L1191_ps_ActionSet = &G0489_as_Graphic560_ActionSets[L1188_ui_ActionSetIndex];
 	_vm->_championMan->_actingChampionOrdinal = _vm->indexToOrdinal(champIndex);
-	f383_setActionList(L1191_ps_ActionSet);
-	_g509_actionAreaContainsIcons = false;
+	setActionList(L1191_ps_ActionSet);
+	_actionAreaContainsIcons = false;
 	setFlag(L1190_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand);
 	_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
-	f387_drawActionArea();
-	f387_drawActionArea();
+	drawActionArea();
+	drawActionArea();
 }
 
-void MenuMan::f383_setActionList(ActionSet* actionSet) {
+void MenuMan::setActionList(ActionSet* actionSet) {
 
 #define k0x0080_actionRequiresCharge 0x0080 // @ MASK0x0080_ACTION_REQUIRES_CHARGE 
 
@@ -1667,28 +1667,28 @@ void MenuMan::f383_setActionList(ActionSet* actionSet) {
 	uint16 L1171_ui_ActionIndex;
 	uint16 L1172_ui_MinimumSkillLevel;
 
-	_g713_actionList._actionIndices[0] = (ChampionAction)actionSet->_actionIndices[0];
-	_g713_actionList._minimumSkillLevel[0] = 1;
+	_actionList._actionIndices[0] = (ChampionAction)actionSet->_actionIndices[0];
+	_actionList._minimumSkillLevel[0] = 1;
 	L1170_ui_NextAvailableActionListIndex = 1;
 	for (L1169_ui_ActionListIndex = 1; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) {
 		if ((L1171_ui_ActionIndex = actionSet->_actionIndices[L1169_ui_ActionListIndex]) == k255_ChampionActionNone)
 			continue;
-		if (getFlag(L1172_ui_MinimumSkillLevel = actionSet->_actionProperties[L1169_ui_ActionListIndex - 1], k0x0080_actionRequiresCharge) && !f382_getActionObjectChargeCount())
+		if (getFlag(L1172_ui_MinimumSkillLevel = actionSet->_actionProperties[L1169_ui_ActionListIndex - 1], k0x0080_actionRequiresCharge) && !getActionObjectChargeCount())
 			continue;
 		clearFlag(L1172_ui_MinimumSkillLevel, k0x0080_actionRequiresCharge);
-		if (_vm->_championMan->getSkillLevel(_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal), g496_ActionSkillIndex[L1171_ui_ActionIndex]) >= L1172_ui_MinimumSkillLevel) {
-			_g713_actionList._actionIndices[L1170_ui_NextAvailableActionListIndex] = (ChampionAction)L1171_ui_ActionIndex;
-			_g713_actionList._minimumSkillLevel[L1170_ui_NextAvailableActionListIndex] = L1172_ui_MinimumSkillLevel;
+		if (_vm->_championMan->getSkillLevel(_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal), _actionSkillIndex[L1171_ui_ActionIndex]) >= L1172_ui_MinimumSkillLevel) {
+			_actionList._actionIndices[L1170_ui_NextAvailableActionListIndex] = (ChampionAction)L1171_ui_ActionIndex;
+			_actionList._minimumSkillLevel[L1170_ui_NextAvailableActionListIndex] = L1172_ui_MinimumSkillLevel;
 			L1170_ui_NextAvailableActionListIndex++;
 		}
 	}
-	_g507_actionCount = L1170_ui_NextAvailableActionListIndex;
+	_actionCount = L1170_ui_NextAvailableActionListIndex;
 	for (L1169_ui_ActionListIndex = L1170_ui_NextAvailableActionListIndex; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) {
-		_g713_actionList._actionIndices[L1169_ui_ActionListIndex] = k255_ChampionActionNone;
+		_actionList._actionIndices[L1169_ui_ActionListIndex] = k255_ChampionActionNone;
 	}
 }
 
-int16 MenuMan::f382_getActionObjectChargeCount() {
+int16 MenuMan::getActionObjectChargeCount() {
 	Thing L1167_T_Thing;
 	Junk* L1168_ps_Junk;
 
@@ -1706,7 +1706,7 @@ int16 MenuMan::f382_getActionObjectChargeCount() {
 	}
 }
 
-void MenuMan::f385_drawActionDamage(int16 damage) {
+void MenuMan::drawActionDamage(int16 damage) {
 	static const Box G0502_s_Graphic560_Box_ActionAreaMediumDamage = Box(242, 305, 81, 117);
 	static const Box G0503_s_Graphic560_Box_ActionAreaSmallDamage = Box(251, 292, 81, 117);
 
@@ -1727,7 +1727,7 @@ void MenuMan::f385_drawActionDamage(int16 damage) {
 
 	_vm->_eventMan->showMouse();
 	_vm->_displayMan->_useByteBoxCoordinates = false;
-	_vm->_displayMan->fillScreenBox(boxActionArea, k0_ColorBlack);
+	_vm->_displayMan->fillScreenBox(_boxActionArea, k0_ColorBlack);
 	if (damage < 0) {
 		static const char *messages_EN_ANY[2] = {"CAN'T REACH", "NEED AMMO"};
 		static const char *messages_DE_DEU[2] = {"ZU WEIT WEG", "MEHR MUNITION"};
@@ -1754,7 +1754,7 @@ void MenuMan::f385_drawActionDamage(int16 damage) {
 		_vm->_textMan->f53_printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, (char *)AL1178_puc_String);
 	} else {
 		if (damage > 40) {
-			L1180_ps_Box = &boxActionArea3ActionMenu;
+			L1180_ps_Box = &_boxActionArea3ActionMenu;
 			L1177_puc_Bitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
 			L1175_i_ByteWidth = k48_byteWidth;
 			L1643_i_Width = 45;
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 0fe8b44..77455fb 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -22,7 +22,7 @@
 
 /*
 * Based on the Reverse Engineering work of Christophe Fontanel,
-* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
+-* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
 #ifndef DM_MENUS_H
@@ -71,61 +71,61 @@ public:
 	explicit MenuMan(DMEngine *vm);
 	~MenuMan();
 
-	bool _g508_refreshActionArea; // @ G0508_B_RefreshActionArea
-	bool _g509_actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons
-	int16 _g513_actionDamage; // @ G0513_i_ActionDamage
-	ActionList _g713_actionList; // @ G0713_s_ActionList
-	byte *_gK72_bitmapSpellAreaLine; // @ K0072_puc_Bitmap_SpellAreaLine
-	byte *_gK73_bitmapSpellAreaLines; // @ K0073_puc_Bitmap_SpellAreaLines
-	Thing _g517_actionTargetGroupThing; // @ G0517_T_ActionTargetGroupThing
-	uint16 _g507_actionCount; // @ G0507_ui_ActionCount
-
-	void f388_clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
-	void f386_drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon
-
-	void f395_drawMovementArrows(); // @ F0395_MENUS_DrawMovementArrows
-	void f456_drawDisabledMenu(); // @ F0456_START_DrawDisabledMenus
-	void f390_refreshActionAreaAndSetChampDirMaxDamageReceived(); // @ F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived
-	void f387_drawActionArea(); // @ F0387_MENUS_DrawActionArea
-	const char* f384_getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName
-	void f393_drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls
-	void f392_buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine
-	void f394_setMagicCasterAndDrawSpellArea(int16 champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea
-	void f457_drawEnabledMenus(); // @ F0457_START_DrawEnabledMenus_CPSF
-	int16 f408_getClickOnSpellCastResult(); // @ F0408_MENUS_GetClickOnSpellCastResult
-	int16 f412_getChampionSpellCastResult(uint16 champIndex); // @ F0412_MENUS_GetChampionSpellCastResult
-	Spell *f409_getSpellFromSymbols(byte *symbols); // @ F0409_MENUS_GetSpellFromSymbols
-	void f410_menusPrintSpellFailureMessage(Champion *champ, uint16 failureType, uint16 skillIndex); // @ F0410_MENUS_PrintSpellFailureMessage
-	Potion *f411_getEmptyFlaskInHand(Champion *champ, Thing *potionThing); // @ F0411_MENUS_GetEmptyFlaskInHand
-	void f404_createEvent70_light(int16 lightPower, int16 ticks); // @ F0404_MENUS_CreateEvent70_Light
-	bool f403_isPartySpellOrFireShieldSuccessful(Champion *champ, bool spellShield, uint16 ticks, bool useMana); // @ F0403_MENUS_IsPartySpellOrFireShieldSuccessful
-	void f397_drawAvailableSymbols(uint16 symbolStep); // @ F0397_MENUS_DrawAvailableSymbols
-	void f398_drawChampionSymbols(Champion *champ); // @ F0398_MENUS_DrawChampionSymbols
-	void f399_addChampionSymbol(int16 symbolIndex); // @ F0399_MENUS_AddChampionSymbol
-	void f400_deleteChampionSymbol(); // @ F0400_MENUS_DeleteChampionSymbol
-	bool f391_didClickTriggerAction(int16 actionListIndex); // @ F0391_MENUS_DidClickTriggerAction
-	bool f407_isActionPerformed(uint16 champIndex, int16 actionIndex); // @ F0407_MENUS_IsActionPerformed
-	void f406_setChampionDirectionToPartyDirection(Champion *champ); // @ F0406_MENUS_SetChampionDirectionToPartyDirection
-	void f405_decrementCharges(Champion *champ); // @ F0405_MENUS_DecrementCharges
-	bool f402_isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 actionIndex, int16 targetMapX,
+	bool _refreshActionArea; // @ G0508_B_RefreshActionArea
+	bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons
+	int16 _actionDamage; // @ G0513_i_ActionDamage
+	ActionList _actionList; // @ G0713_s_ActionList
+	byte *_bitmapSpellAreaLine; // @ K0072_puc_Bitmap_SpellAreaLine
+	byte *_bitmapSpellAreaLines; // @ K0073_puc_Bitmap_SpellAreaLines
+	Thing _actionTargetGroupThing; // @ G0517_T_ActionTargetGroupThing
+	uint16 _actionCount; // @ G0507_ui_ActionCount
+
+	void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
+	void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon
+
+	void drawMovementArrows(); // @ F0395_MENUS_DrawMovementArrows
+	void drawDisabledMenu(); // @ F0456_START_DrawDisabledMenus
+	void refreshActionAreaAndSetChampDirMaxDamageReceived(); // @ F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived
+	void drawActionArea(); // @ F0387_MENUS_DrawActionArea
+	const char *getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName
+	void drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls
+	void buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine
+	void setMagicCasterAndDrawSpellArea(int16 champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea
+	void drawEnabledMenus(); // @ F0457_START_DrawEnabledMenus_CPSF
+	int16 getClickOnSpellCastResult(); // @ F0408_MENUS_GetClickOnSpellCastResult
+	int16 getChampionSpellCastResult(uint16 champIndex); // @ F0412_MENUS_GetChampionSpellCastResult
+	Spell *getSpellFromSymbols(byte *symbols); // @ F0409_MENUS_GetSpellFromSymbols
+	void menusPrintSpellFailureMessage(Champion *champ, uint16 failureType, uint16 skillIndex); // @ F0410_MENUS_PrintSpellFailureMessage
+	Potion *getEmptyFlaskInHand(Champion *champ, Thing *potionThing); // @ F0411_MENUS_GetEmptyFlaskInHand
+	void createEvent70_light(int16 lightPower, int16 ticks); // @ F0404_MENUS_CreateEvent70_Light
+	bool isPartySpellOrFireShieldSuccessful(Champion *champ, bool spellShield, uint16 ticks, bool useMana); // @ F0403_MENUS_IsPartySpellOrFireShieldSuccessful
+	void drawAvailableSymbols(uint16 symbolStep); // @ F0397_MENUS_DrawAvailableSymbols
+	void drawChampionSymbols(Champion *champ); // @ F0398_MENUS_DrawChampionSymbols
+	void addChampionSymbol(int16 symbolIndex); // @ F0399_MENUS_AddChampionSymbol
+	void deleteChampionSymbol(); // @ F0400_MENUS_DeleteChampionSymbol
+	bool didClickTriggerAction(int16 actionListIndex); // @ F0391_MENUS_DidClickTriggerAction
+	bool isActionPerformed(uint16 champIndex, int16 actionIndex); // @ F0407_MENUS_IsActionPerformed
+	void setChampionDirectionToPartyDirection(Champion *champ); // @ F0406_MENUS_SetChampionDirectionToPartyDirection
+	void decrementCharges(Champion *champ); // @ F0405_MENUS_DecrementCharges
+	bool isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 actionIndex, int16 targetMapX,
 									 int16 targetMapY, int16 skillIndex); // @ F0402_MENUS_IsMeleeActionPerformed
-	bool  f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, int16 mapX, int16 mapY); // @ F0401_MENUS_IsGroupFrightenedByAction
-	void f381_printMessageAfterReplacements(const char *str); // @ F0381_MENUS_PrintMessageAfterReplacements
-	void f389_processCommands116To119_setActingChampion(uint16 champIndex); // @ F0389_MENUS_ProcessCommands116To119_SetActingChampion
-	void f383_setActionList(ActionSet *actionSet); // @ F0383_MENUS_SetActionList
-	int16 f382_getActionObjectChargeCount(); // @ F0382_MENUS_GetActionObjectChargeCount
-	void f385_drawActionDamage(int16 damage); // @ F0385_MENUS_DrawActionDamage
-
-	Box boxActionArea3ActionMenu; // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu
-	Box boxActionArea2ActionMenu; // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
-	Box boxActionArea1ActionMenu; // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
-	Box boxActionArea; // @ G0001_s_Graphic562_Box_ActionArea 
-	Box boxSpellArea;
-	unsigned char g496_ActionSkillIndex[44]; // @ G0496_auc_Graphic560_ActionSkillIndex
+	bool isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, int16 mapX, int16 mapY); // @ F0401_MENUS_IsGroupFrightenedByAction
+	void printMessageAfterReplacements(const char *str); // @ F0381_MENUS_PrintMessageAfterReplacements
+	void processCommands116To119_setActingChampion(uint16 champIndex); // @ F0389_MENUS_ProcessCommands116To119_SetActingChampion
+	void setActionList(ActionSet *actionSet); // @ F0383_MENUS_SetActionList
+	int16 getActionObjectChargeCount(); // @ F0382_MENUS_GetActionObjectChargeCount
+	void drawActionDamage(int16 damage); // @ F0385_MENUS_DrawActionDamage
+
+	Box _boxActionArea3ActionMenu; // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu
+	Box _boxActionArea2ActionMenu; // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
+	Box _boxActionArea1ActionMenu; // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
+	Box _boxActionArea; // @ G0001_s_Graphic562_Box_ActionArea 
+	Box _boxSpellArea;
+	unsigned char _actionSkillIndex[44]; // @ G0496_auc_Graphic560_ActionSkillIndex
 
 	void initConstants();
 };
 
 }
 
-#endif // !DM_MENUS_H
+#endif // DM_MENUS_H


Commit: 938b38a66a87e11bdb6719a22023c0dcede1b5bb
    https://github.com/scummvm/scummvm/commit/938b38a66a87e11bdb6719a22023c0dcede1b5bb
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rename class members of MovesensMan

Changed paths:
    engines/dm/champion.cpp
    engines/dm/console.cpp
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/group.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/movesens.h
    engines/dm/projexpl.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index b7f2460..9e30bdf 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1476,7 +1476,7 @@ void ChampionMan::championKill(uint16 champIndex) {
 		L0966_ps_Junk->setDoNotDiscard(true);
 		L0966_ps_Junk->setChargeCount(champIndex);
 		curCell = curChampion->_cell;
-		_vm->_moveSens->f267_getMoveResult(thingWithNewCell(unusedThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
+		_vm->_moveSens->getMoveResult(thingWithNewCell(unusedThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
 	}
 	curChampion->_symbolStep = 0;
 	curChampion->_symbols[0] = '\0';
@@ -1553,7 +1553,7 @@ void ChampionMan::dropAllObjects(uint16 champIndex) {
 	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
 		Thing curThing = getObjectRemovedFromSlot(champIndex, slotDropOrder[slotIndex]);
 		if (curThing != Thing::_none)
-			_vm->_moveSens->f267_getMoveResult(thingWithNewCell(curThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
+			_vm->_moveSens->getMoveResult(thingWithNewCell(curThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
 	}
 }
 
diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index b931733..77da72a 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -143,7 +143,7 @@ bool Console::Cmd_pos(int argc, const char** argv) {
 		if (haventWarned.check())
 			debugPrintf("Setting position directly can cause glitches and crashes.\n");
 		debugPrintf("Position set to (%d, %d)\n", x, y);
-		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY,
+		_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY,
 										   x - currMap._offsetMapX, y - currMap._offsetMapY);
 	} else
 		goto argumentError;
@@ -177,7 +177,7 @@ bool Console::Cmd_map(int argc, const char** argv) {
 			debugPrintf("Setting map directly can cause glitches and crashes.\n");
 		debugPrintf("Map set to %d\n", index);
 
-		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kM1_MapXNotOnASquare, 0);
+		_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kM1_MapXNotOnASquare, 0);
 		_vm->_newPartyMapIndex = _vm->_dungeonMan->getLocationAfterLevelChange(
 			_vm->_dungeonMan->_partyMapIndex, index - _vm->_dungeonMan->_partyMapIndex,
 			&_vm->_dungeonMan->_partyMapX, &_vm->_dungeonMan->_partyMapY);
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 1b218e1..c82246d 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -306,7 +306,7 @@ void DMEngine::initializeGame() {
 
 	startGame();
 	if (_newGameFl)
-		_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
+		_moveSens->getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
 	_eventMan->showMouse();
 	_eventMan->discardAllInput();
 }
@@ -439,7 +439,7 @@ void DMEngine::gameloop() {
 
 			if (_newPartyMapIndex != kM1_mapIndexNone) {
 				processNewPartyMap(_newPartyMapIndex);
-				_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
+				_moveSens->getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
 				_newPartyMapIndex = kM1_mapIndexNone;
 				_eventMan->discardAllInput();
 			}
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 5f356b9..82b1e8d 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1461,28 +1461,28 @@ Thing DungeonMan::getDiscardThing(uint16 thingType) {
 									continue;
 
 								setCurrentMap(mapIndex);
-								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
+								_vm->_moveSens->getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
 								break;
 							case k5_WeaponThingType:
 								if (((Weapon*)squareThingData)->getDoNotDiscard())
 									continue;
 
 								setCurrentMap(mapIndex);
-								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
+								_vm->_moveSens->getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
 								break;
 							case k10_JunkThingType:
 								if (((Junk*)squareThingData)->getDoNotDiscard())
 									continue;
 
 								setCurrentMap(mapIndex);
-								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
+								_vm->_moveSens->getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
 								break;
 							case k8_PotionThingType:
 								if (((Potion*)squareThingData)->getDoNotDiscard())
 									continue;
 
 								setCurrentMap(mapIndex);
-								_vm->_moveSens->f267_getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
+								_vm->_moveSens->getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
 								break;
 							}
 							setCurrentMap(currentMapIdx);
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 5007b8c..c84fd01 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -940,9 +940,9 @@ void EventManager::commandTurnParty(CommandType cmdType) {
 		return;
 	}
 
-	_vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, Thing::_party, true, false);
+	_vm->_moveSens->processThingAdditionOrRemoval(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, Thing::_party, true, false);
 	_vm->_championMan->setPartyDirection(normalizeModulo4(_vm->_dungeonMan->_partyDir + ((cmdType == k2_CommandTurnRight) ? 1 : 3)));
-	_vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, Thing::_party, true, true);
+	_vm->_moveSens->processThingAdditionOrRemoval(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, Thing::_party, true, true);
 }
 
 void EventManager::commandMoveParty(CommandType cmdType) {
@@ -988,7 +988,7 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 	_vm->_dungeonMan->mapCoordsAfterRelMovement(_vm->_dungeonMan->_partyDir, movementArrowToStepForwardCount[movementArrowIdx], movementArrowToSepRightCount[movementArrowIdx], partyMapX, partyMapY);
 	int16 partySquareType = Square(AL1115_ui_Square = _vm->_dungeonMan->getSquare(partyMapX, partyMapY).toByte()).getType();
 	if (partySquareType == k3_ElementTypeStairs) {
-		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kM1_MapXNotOnASquare, 0);
+		_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kM1_MapXNotOnASquare, 0);
 		_vm->_dungeonMan->_partyMapX = partyMapX;
 		_vm->_dungeonMan->_partyMapY = partyMapY;
 		commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp));
@@ -1030,9 +1030,9 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 	}
 
 	if (isStairsSquare)
-		_vm->_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, partyMapX, partyMapY);
+		_vm->_moveSens->getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, partyMapX, partyMapY);
 	else
-		_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, partyMapX, partyMapY);
+		_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, partyMapX, partyMapY);
 
 	uint16 disabledMovtTicks = 1;
 	championsPtr = _vm->_championMan->_champions;
@@ -1137,7 +1137,7 @@ void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() {
 
 	if ((mapX >= 0) && (mapX < _vm->_dungeonMan->_currMapWidth)
 		&& (mapY >= 0) && (mapY < _vm->_dungeonMan->_currMapHeight))
-		_vm->_stopWaitingForPlayerInput = _vm->_moveSens->f275_sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(_vm->_dungeonMan->_partyDir));
+		_vm->_stopWaitingForPlayerInput = _vm->_moveSens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(_vm->_dungeonMan->_partyDir));
 }
 
 void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY) {
@@ -1161,7 +1161,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 			if ((((Door*)junkPtr)->hasButton()) && _vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
 				_vm->_stopWaitingForPlayerInput = true;
 				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
-				_vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_gameTime + 1);
+				_vm->_moveSens->addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_gameTime + 1);
 				return;
 			}
 		} else if (isLeaderHandObjThrown(posX, posY))
@@ -1349,7 +1349,7 @@ void EventManager::processType80_clickInDungeonView_grabLeaderHandObject(uint16
 		mapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir], mapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
 		Thing groupThing = _vm->_groupMan->groupGetThing(mapX, mapY);
 		if ((groupThing != Thing::_endOfList) &&
-			!_vm->_moveSens->f264_isLevitating(groupThing) &&
+			!_vm->_moveSens->isLevitating(groupThing) &&
 			_vm->_groupMan->getCreatureOrdinalInCell((Group*)_vm->_dungeonMan->getThingData(groupThing), normalizeModulo4(viewCell + _vm->_dungeonMan->_partyDir))) {
 			return; /* It is not possible to grab an object on floor if there is a non levitating creature on its cell */
 		}
@@ -1357,7 +1357,7 @@ void EventManager::processType80_clickInDungeonView_grabLeaderHandObject(uint16
 
 	Thing topPileThing = _vm->_dungeonMan->_pileTopObject[viewCell];
 	if (_vm->_objectMan->f33_getIconIndex(topPileThing) != kM1_IconIndiceNone) {
-		_vm->_moveSens->f267_getMoveResult(topPileThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
+		_vm->_moveSens->getMoveResult(topPileThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
 		_vm->_championMan->putObjectInLeaderHand(topPileThing, true);
 	}
 
@@ -1379,7 +1379,7 @@ void EventManager::processType80_clickInDungeonViewDropLeaderHandObject(uint16 v
 
 	uint16 currCell = normalizeModulo4(_vm->_dungeonMan->_partyDir + viewCell);
 	Thing removedThing = _vm->_championMan->getObjectRemovedFromLeaderHand();
-	_vm->_moveSens->f267_getMoveResult(thingWithNewCell(removedThing, currCell), kM1_MapXNotOnASquare, 0, mapX, mapY);
+	_vm->_moveSens->getMoveResult(thingWithNewCell(removedThing, currCell), kM1_MapXNotOnASquare, 0, mapX, mapY);
 	if (droppingIntoAnAlcove && _vm->_dungeonMan->_isFacingViAltar && (_vm->_objectMan->f33_getIconIndex(removedThing) == k147_IconIndiceJunkChampionBones)) {
 		Junk *removedJunk = (Junk*)_vm->_dungeonMan->getThingData(removedThing);
 		TimelineEvent newEvent;
@@ -1428,7 +1428,7 @@ void EventManager::discardAllInput() {
 }
 
 void EventManager::commandTakeStairs(bool stairsGoDown) {
-	_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kM1_MapXNotOnASquare, 0);
+	_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kM1_MapXNotOnASquare, 0);
 	_vm->_newPartyMapIndex = _vm->_dungeonMan->getLocationAfterLevelChange(_vm->_dungeonMan->_partyMapIndex, stairsGoDown ? -1 : 1, &_vm->_dungeonMan->_partyMapX, &_vm->_dungeonMan->_partyMapY);
 	_vm->_dungeonMan->setCurrentMap(_vm->_newPartyMapIndex);
 	_vm->_championMan->setPartyDirection(_vm->_dungeonMan->getStairsExitDirection(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY));
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 99ce133..9155418 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -155,7 +155,7 @@ void GroupMan::dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, in
 			if ((currentThing).getType() == k5_WeaponThingType) {
 				L0371_B_WeaponDropped = true;
 			}
-			_vm->_moveSens->f267_getMoveResult(currentThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
+			_vm->_moveSens->getMoveResult(currentThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
 		} while ((currentThing = nextThing) != Thing::_endOfList);
 
 		if (mode >= k0_soundModePlayImmediately)
@@ -284,7 +284,7 @@ void GroupMan::dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int
 		currWeapon->setType(currFixedPossession);
 		currWeapon->setCursed(cursedPossessions);
 		nextUnusedThing = thingWithNewCell(nextUnusedThing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell);
-		_vm->_moveSens->f267_getMoveResult(nextUnusedThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
+		_vm->_moveSens->getMoveResult(nextUnusedThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
 		currFixedPossession = *fixedPossessions++;
 	}
 	_vm->_sound->f064_SOUND_RequestPlay_CPSD(weaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
@@ -516,7 +516,7 @@ void GroupMan::groupDelete(int16 mapX, int16 mapY) {
 	L0373_ps_Group = (Group *)_vm->_dungeonMan->getThingData(L0372_T_GroupThing);
 	for (uint16 i = 0; i < 4; ++i)
 		L0373_ps_Group->_health[i] = 0;
-	_vm->_moveSens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
+	_vm->_moveSens->getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
 	L0373_ps_Group->_nextThing = Thing::_none;
 	if (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) {
 		_activeGroups[L0373_ps_Group->getActiveGroupIndex()]._groupThingIndex = -1;
@@ -654,10 +654,10 @@ void GroupMan::processEvents29to41(int16 eventMapX, int16 eventMapY, int16 event
 			AL0450_i_DestinationMapX = eventMapX;
 			AL0451_i_DestinationMapY = eventMapY;
 			AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
-			if (_vm->_moveSens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
+			if (_vm->_moveSens->getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
 				goto T0209139_Return;
-			L0465_s_NextEvent._B._location._mapX = _vm->_moveSens->_g397_moveResultMapX;
-			L0465_s_NextEvent._B._location._mapY = _vm->_moveSens->_g398_moveResultMapY;
+			L0465_s_NextEvent._B._location._mapX = _vm->_moveSens->_moveResultMapX;
+			L0465_s_NextEvent._B._location._mapY = _vm->_moveSens->_moveResultMapY;
 		}
 		L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup;
 		AL0446_i_Ticks = MAX(ABS(_vm->_dungeonMan->_currMapIndex - _vm->_dungeonMan->_partyMapIndex) << 4, L0448_s_CreatureInfo._movementTicks << 1);
@@ -834,10 +834,10 @@ T0209061_MoveGroup:
 									AL0447_i_Ticks = (L0461_i_MovementTicks >> 1) - L0462_i_TicksSinceLastMove;
 									L0453_B_NewGroupDirectionFound = (AL0447_i_Ticks <= 0);
 									if (L0453_B_NewGroupDirectionFound) {
-										if (_vm->_moveSens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
+										if (_vm->_moveSens->getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
 											goto T0209139_Return;
-										L0465_s_NextEvent._B._location._mapX = _vm->_moveSens->_g397_moveResultMapX;
-										L0465_s_NextEvent._B._location._mapY = _vm->_moveSens->_g398_moveResultMapY;;
+										L0465_s_NextEvent._B._location._mapX = _vm->_moveSens->_moveResultMapX;
+										L0465_s_NextEvent._B._location._mapY = _vm->_moveSens->_moveResultMapY;;
 										L0445_ps_ActiveGroup->_priorMapX = eventMapX;
 										L0445_ps_ActiveGroup->_priorMapY = eventMapY;
 										L0445_ps_ActiveGroup->_lastMoveTime = _vm->_gameTime;
@@ -1336,7 +1336,7 @@ int32 GroupMan::getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 crea
 				if (L0331_ui_CreatureType == k13_CreatureTypeCouatl) {
 					if (_vm->getRandomNumber(2)) {
 						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-						L1635_ui_SoundIndex = _vm->_moveSens->f514_getSound(k13_CreatureTypeCouatl);
+						L1635_ui_SoundIndex = _vm->_moveSens->getSound(k13_CreatureTypeCouatl);
 						if (L1635_ui_SoundIndex <= k34_D13_soundCount)
 							_vm->_sound->f064_SOUND_RequestPlay_CPSD(L1635_ui_SoundIndex, _currentGroupMapX, _currentGroupMapY, k1_soundModePlayIfPrioritized);
 					}
@@ -1850,7 +1850,7 @@ Thing GroupMan::groupGetGenerated(int16 creatureType, int16 healthMultiplier, ui
 		}
 	} while (creatureCount--);
 	L0353_ps_Group->_cells = L0352_ui_GroupCells;
-	if (_vm->_moveSens->f267_getMoveResult(L0349_T_GroupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) { /* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile impact (in which case the thing data was marked as unused) or the party is on the destination square and an event is created to move the creature into the dungeon later (in which case the thing is referenced in the event) */
+	if (_vm->_moveSens->getMoveResult(L0349_T_GroupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) { /* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile impact (in which case the thing data was marked as unused) or the party is on the destination square and an event is created to move the creature into the dungeon later (in which case the thing is referenced in the event) */
 		return Thing::_none;
 	}
 	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, mapX, mapY, k1_soundModePlayIfPrioritized);
@@ -2103,7 +2103,7 @@ void GroupMan::fuseAction(uint16 mapX, uint16 mapY) {
 				}
 			}
 			if (isSquareACorridorTeleporterPitOrDoor(L0548_i_MapX, L0549_i_MapY)) {
-				if (!_vm->_moveSens->f267_getMoveResult(L0555_T_LordChaosThing, mapX, mapY, L0548_i_MapX, L0549_i_MapY)) {
+				if (!_vm->_moveSens->getMoveResult(L0555_T_LordChaosThing, mapX, mapY, L0548_i_MapX, L0549_i_MapY)) {
 					startWanedring(L0548_i_MapX, L0549_i_MapY);
 				}
 				return;
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index ce372f0..8750d30 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -623,7 +623,7 @@ T0412033:
 				_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, L1272_T_Object, AL1267_ui_SlotIndex);
 				_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 			} else {
-				_vm->_moveSens->f267_getMoveResult(L1272_T_Object, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
+				_vm->_moveSens->getMoveResult(L1272_T_Object, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
 			}
 			break;
 		case k8_spellType_otherFireshield:
@@ -1285,9 +1285,9 @@ T0407032:
 		/* CHANGE6_00_FIX The presence of a group over the pit is checked so that you cannot climb down a pit with the rope if there is a group levitating over it */
 		if ((_vm->_dungeonMan->getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_PitElemType) && (_vm->_groupMan->groupGetThing(L1251_i_MapX, L1252_i_MapY) == Thing::_endOfList)) {
 			/* BUG0_77 The party moves forward when using the rope in front of a closed pit. The engine does not check whether the pit is open before moving the party over the pit. This is not consistent with the behavior when using the rope in front of a corridor where nothing happens */
-			_vm->_moveSens->_g402_useRopeToClimbDownPit = true;
-			_vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, L1251_i_MapX, L1252_i_MapY);
-			_vm->_moveSens->_g402_useRopeToClimbDownPit = false;
+			_vm->_moveSens->_useRopeToClimbDownPit = true;
+			_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, L1251_i_MapX, L1252_i_MapY);
+			_vm->_moveSens->_useRopeToClimbDownPit = false;
 		} else {
 			L1249_ui_ActionDisabledTicks = 0;
 		}
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 37dd738..fce6df3 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -41,19 +41,19 @@
 namespace DM {
 
 MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {
-	_g397_moveResultMapX = 0;
-	_g398_moveResultMapY = 0;
-	_g399_moveResultMapIndex = 0;
-	_g400_moveResultDir = 0;
-	_g401_moveResultCell = 0;
-	_g402_useRopeToClimbDownPit = false;
-	_g403_sensorRotationEffect = 0;
-	_g404_sensorRotationEffMapX = 0;
-	_g405_sensorRotationEffMapY = 0;
-	_g406_sensorRotationEffCell = 0;
+	_moveResultMapX = 0;
+	_moveResultMapY = 0;
+	_moveResultMapIndex = 0;
+	_moveResultDir = 0;
+	_moveResultCell = 0;
+	_useRopeToClimbDownPit = false;
+	_sensorRotationEffect = 0;
+	_sensorRotationEffMapX = 0;
+	_sensorRotationEffMapY = 0;
+	_sensorRotationEffCell = 0;
 }
 
-bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam) {
+bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam) {
 	Thing L0750_T_ThingBeingProcessed;
 	uint16 L0751_ui_ThingType;
 	uint16 L0752_ui_Cell;
@@ -126,7 +126,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 					L0750_T_ThingBeingProcessed = L0763_T_LastProcessedThing;
 				}
 				if (!L0753_B_DoNotTriggerSensor && (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors)) {
-					f270_sensorTriggetLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
+					triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
 				}
 				break;
 			case k12_SensorWallObjGeneratorRotateSensors:
@@ -134,23 +134,23 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 					goto T0275058_ProceedToNextThing;
 				L0753_B_DoNotTriggerSensor = !_vm->_championMan->_leaderEmptyHanded;
 				if (!L0753_B_DoNotTriggerSensor) {
-					f270_sensorTriggetLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
+					triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
 				}
 				break;
 			case k13_SensorWallSingleObjStorageRotateSensors:
 				if (_vm->_championMan->_leaderEmptyHanded) {
-					if ((L0761_T_LeaderHandObject = f273_sensorGetObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData)) == Thing::_none)
+					if ((L0761_T_LeaderHandObject = getObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData)) == Thing::_none)
 						goto T0275058_ProceedToNextThing;
 					_vm->_dungeonMan->unlinkThingFromList(L0761_T_LeaderHandObject, Thing(0), mapX, mapY);
 					_vm->_championMan->putObjectInLeaderHand(L0761_T_LeaderHandObject, true);
 				} else {
-					if ((_vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (f273_sensorGetObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData) != Thing::_none))
+					if ((_vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (getObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData) != Thing::_none))
 						goto T0275058_ProceedToNextThing;
 					_vm->_championMan->getObjectRemovedFromLeaderHand();
 					_vm->_dungeonMan->linkThingToList(thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
 					L0761_T_LeaderHandObject = Thing::_none;
 				}
-				f270_sensorTriggetLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
+				triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
 				if ((L0756_i_SensorEffect == k3_SensorEffHold) && !_vm->_championMan->_leaderEmptyHanded) {
 					L0753_B_DoNotTriggerSensor = true;
 				} else {
@@ -196,7 +196,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui
 						_vm->_championMan->putObjectInLeaderHand(L0761_T_LeaderHandObject, true);
 					}
 				}
-				f272_sensorTriggerEffect(L0755_ps_Sensor, L0756_i_SensorEffect, mapX, mapY, L0752_ui_Cell);
+				triggerEffect(L0755_ps_Sensor, L0756_i_SensorEffect, mapX, mapY, L0752_ui_Cell);
 			}
 			goto T0275058_ProceedToNextThing;
 		}
@@ -206,11 +206,11 @@ T0275058_ProceedToNextThing:
 		L0763_T_LastProcessedThing = L0750_T_ThingBeingProcessed;
 		L0750_T_ThingBeingProcessed = _vm->_dungeonMan->getNextThing(L0750_T_ThingBeingProcessed);
 	}
-	f271_processRotationEffect();
+	processRotationEffect();
 	return L0759_B_AtLeastOneSensorWasTriggered;
 }
 
-bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destMapX, int16 destMapY) {
+bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destMapX, int16 destMapY) {
 	int16 L0708_i_Multiple = 0;
 #define AL0708_i_DestinationSquare L0708_i_Multiple
 #define AL0708_i_ScentIndex        L0708_i_Multiple
@@ -242,11 +242,11 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 	if (thing != Thing::_party) {
 		L0710_i_ThingType = thing.getType();
 		L0717_ui_ThingCell = thing.getCell();
-		L0713_B_ThingLevitates = f264_isLevitating(thing);
+		L0713_B_ThingLevitates = isLevitating(thing);
 	}
 	/* If moving the party or a creature on the party map from a dungeon square then check for a projectile impact */
 	if ((mapX >= 0) && ((thing == Thing::_party) || ((L0710_i_ThingType == k4_GroupThingType) && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex)))) {
-		if (f266_moveIsKilledByProjectileImpact(mapX, mapY, destMapX, destMapY, thing)) {
+		if (moveIsKilledByProjectileImpact(mapX, mapY, destMapX, destMapY, thing)) {
 			return true; /* The specified group thing cannot be moved because it was killed by a projectile impact */
 		}
 	}
@@ -279,7 +279,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 		}
 		if (L0710_i_ThingType == k14_ProjectileThingType) {
 			L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(thing);
-			_g400_moveResultDir = (_vm->_timeline->_g370_events[((Projectile *)L0712_ps_Teleporter)->_eventIndex])._C._projectile.getDir();
+			_moveResultDir = (_vm->_timeline->_g370_events[((Projectile *)L0712_ps_Teleporter)->_eventIndex])._C._projectile.getDir();
 		}
 		for (L0728_i_ChainedMoveCount = 1000; --L0728_i_ChainedMoveCount; ) { /* No more than 1000 chained moves at once (in a chain of teleporters and pits for example) */
 			AL0708_i_DestinationSquare = _vm->_dungeonMan->_currMapData[destMapX][destMapY];
@@ -313,10 +313,10 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 						if (L0712_ps_Teleporter->isAudible()) {
 							_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, destMapX, destMapY, k1_soundModePlayIfPrioritized);
 						}
-						L0720_ui_MoveGroupResult = f262_getTeleporterRotatedGroupResult(L0712_ps_Teleporter, thing, L0714_ui_MapIndexSource);
+						L0720_ui_MoveGroupResult = getTeleporterRotatedGroupResult(L0712_ps_Teleporter, thing, L0714_ui_MapIndexSource);
 					} else {
 						if (L0710_i_ThingType == k14_ProjectileThingType) {
-							thing = f263_getTeleporterRotatedProjectileThing(L0712_ps_Teleporter, thing);
+							thing = getTeleporterRotatedProjectileThing(L0712_ps_Teleporter, thing);
 						} else {
 							if (!(L0712_ps_Teleporter->getAbsoluteRotation()) && (mapX != -2)) {
 								thing = thingWithNewCell(thing, normalizeModulo4(thing.getCell() + L0712_ps_Teleporter->getRotation()));
@@ -328,7 +328,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					break;
 			} else {
 				if ((AL0709_i_DestinationSquareType == k2_ElementTypePit) && !L0713_B_ThingLevitates && getFlag(AL0708_i_DestinationSquare, k0x0008_PitOpen) && !getFlag(AL0708_i_DestinationSquare, k0x0001_PitImaginary)) {
-					if (L0723_B_DrawDungeonViewWhileFalling && !_g402_useRopeToClimbDownPit) {
+					if (L0723_B_DrawDungeonViewWhileFalling && !_useRopeToClimbDownPit) {
 						L0723_B_DrawDungeonViewWhileFalling = true;
 						if (L0719_i_TraversedPitCount) {
 							_vm->_dungeonMan->setCurrentMapAndPartyMap(L0715_ui_MapIndexDestination);
@@ -345,7 +345,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 						_vm->_dungeonMan->_partyMapX = destMapX;
 						_vm->_dungeonMan->_partyMapY = destMapY;
 						if (_vm->_championMan->_partyChampionCount > 0) {
-							if (_g402_useRopeToClimbDownPit) {
+							if (_useRopeToClimbDownPit) {
 								for (AL0709_i_ChampionIndex = k0_ChampionFirst, L0711_ps_Champion = _vm->_championMan->_champions; AL0709_i_ChampionIndex < _vm->_championMan->_partyChampionCount; AL0709_i_ChampionIndex++, L0711_ps_Champion++) {
 									if (L0711_ps_Champion->_currHealth) {
 										_vm->_championMan->decrementStamina(AL0709_i_ChampionIndex, ((L0711_ps_Champion->_load * 25) / _vm->_championMan->getMaximumLoad(L0711_ps_Champion)) + 1);
@@ -357,7 +357,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 								}
 							}
 						}
-						_g402_useRopeToClimbDownPit = false;
+						_useRopeToClimbDownPit = false;
 					} else {
 						if (L0710_i_ThingType == k4_GroupThingType) {
 							_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
@@ -397,10 +397,10 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 			}
 			return true; /* The specified group thing cannot be moved because it was killed by a fall or because it is not allowed on the destination map */
 		}
-		_g397_moveResultMapX = destMapX;
-		_g398_moveResultMapY = destMapY;
-		_g399_moveResultMapIndex = L0715_ui_MapIndexDestination;
-		_g401_moveResultCell = thing.getCell();
+		_moveResultMapX = destMapX;
+		_moveResultMapY = destMapY;
+		_moveResultMapIndex = L0715_ui_MapIndexDestination;
+		_moveResultCell = thing.getCell();
 		L0725_B_PartySquare = (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) && (destMapX == mapX) && (destMapY == mapY);
 		if (L0725_B_PartySquare) {
 			if (thing == Thing::_party) {
@@ -408,7 +408,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					return false;
 				}
 			} else {
-				if ((_g401_moveResultCell == L0717_ui_ThingCell) && (L0710_i_ThingType != k14_ProjectileThingType)) {
+				if ((_moveResultCell == L0717_ui_ThingCell) && (L0710_i_ThingType != k14_ProjectileThingType)) {
 					return false;
 				}
 			}
@@ -442,12 +442,12 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 	}
 	if (mapX >= 0) {
 		if (thing == Thing::_party) {
-			f276_sensorProcessThingAdditionOrRemoval(mapX, mapY, Thing::_party, L0725_B_PartySquare, false);
+			processThingAdditionOrRemoval(mapX, mapY, Thing::_party, L0725_B_PartySquare, false);
 		} else {
 			if (L0713_B_ThingLevitates) {
 				_vm->_dungeonMan->unlinkThingFromList(thing, Thing(0), mapX, mapY);
 			} else {
-				f276_sensorProcessThingAdditionOrRemoval(mapX, mapY, thing, (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY), false);
+				processThingAdditionOrRemoval(mapX, mapY, thing, (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY), false);
 			}
 		}
 	}
@@ -459,7 +459,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				_vm->_groupMan->groupDelete(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
 			}
 			if (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) {
-				f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, Thing::_party, L0725_B_PartySquare, true);
+				processThingAdditionOrRemoval(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, Thing::_party, L0725_B_PartySquare, true);
 			} else {
 				_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
 				_vm->_newPartyMapIndex = L0715_ui_MapIndexDestination;
@@ -477,10 +477,10 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 					if (L0721_B_GroupOnPartyMap) {
 						_vm->_groupMan->removeActiveGroup(AL0708_i_ActiveGroupIndex);
 					}
-					f265_createEvent60to61_moveGroup(thing, destMapX, destMapY, L0715_ui_MapIndexDestination, L0726_B_Audible);
+					createEventMoveGroup(thing, destMapX, destMapY, L0715_ui_MapIndexDestination, L0726_B_Audible);
 					return true; /* The specified group thing cannot be moved because the party or another group is on the destination square */
 				}
-				L1638_ui_MovementSoundIndex = f514_getSound(((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[thing.getIndex()]._type);
+				L1638_ui_MovementSoundIndex = getSound(((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[thing.getIndex()]._type);
 				if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) {
 					_vm->_sound->f064_SOUND_RequestPlay_CPSD(L1638_ui_MovementSoundIndex, destMapX, destMapY, k1_soundModePlayIfPrioritized);
 				}
@@ -496,7 +496,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 				if (L0713_B_ThingLevitates) {
 					_vm->_dungeonMan->linkThingToList(thing, Thing(0), destMapX, destMapY);
 				} else {
-					f276_sensorProcessThingAdditionOrRemoval(destMapX, destMapY, thing, false, true);
+					processThingAdditionOrRemoval(destMapX, destMapY, thing, false, true);
 				}
 				if (L0720_ui_MoveGroupResult || (mapX < 0)) { /* If group moved from one map to another or if it was just placed on a square */
 					_vm->_groupMan->startWanedring(destMapX, destMapY);
@@ -517,7 +517,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 			if (L0710_i_ThingType == k14_ProjectileThingType) { /* BUG0_29 An explosion can trigger a floor sensor. Explosions do not trigger floor sensors on the square where they are created. However, if an explosion is moved by a teleporter (or by falling into a pit, see BUG0_26) after it was created, it can trigger floor sensors on the destination square. This is because explosions are not considered as levitating in the code, while projectiles are. The condition here should be (L0713_B_ThingLevitates) so that explosions would not start sensor processing on their destination square as they should be Levitating. This would work if F0264_MOVE_IsLevitating returned true for explosions (see BUG0_26) */
 				_vm->_dungeonMan->linkThingToList(thing, Thing(0), destMapX, destMapY);
 			} else {
-				f276_sensorProcessThingAdditionOrRemoval(destMapX, destMapY, thing, (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (destMapX == _vm->_dungeonMan->_partyMapX) && (destMapY == _vm->_dungeonMan->_partyMapY), true);
+				processThingAdditionOrRemoval(destMapX, destMapY, thing, (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (destMapX == _vm->_dungeonMan->_partyMapX) && (destMapY == _vm->_dungeonMan->_partyMapY), true);
 			}
 			_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
 		}
@@ -525,7 +525,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16
 	return false;
 }
 
-bool MovesensMan::f264_isLevitating(Thing thing) {
+bool MovesensMan::isLevitating(Thing thing) {
 	int16 L0695_i_ThingType;
 
 
@@ -538,7 +538,7 @@ bool MovesensMan::f264_isLevitating(Thing thing) {
 	return false;
 }
 
-bool MovesensMan::f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY, Thing thing) {
+bool MovesensMan::moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY, Thing thing) {
 	Thing L0697_T_Thing;
 	uint16 L0699_ui_Multiple;
 #define AL0699_ui_Cell                      L0699_ui_Multiple
@@ -632,7 +632,7 @@ T0266017_CheckProjectileImpacts:
 	return false;
 }
 
-void MovesensMan::f268_addEvent(byte type, byte mapX, byte mapY, byte cell, byte effect, int32 time) {
+void MovesensMan::addEvent(byte type, byte mapX, byte mapY, byte cell, byte effect, int32 time) {
 	TimelineEvent L0729_s_Event;
 
 	setMapAndTime(L0729_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, time);
@@ -645,7 +645,7 @@ void MovesensMan::f268_addEvent(byte type, byte mapX, byte mapY, byte cell, byte
 	_vm->_timeline->f238_addEventGetEventIndex(&L0729_s_Event);
 }
 
-int16 MovesensMan::f514_getSound(byte creatureType) {
+int16 MovesensMan::getSound(byte creatureType) {
 	if (_vm->_championMan->_partyIsSleeping) {
 		return 35;
 	}
@@ -690,7 +690,7 @@ int16 MovesensMan::f514_getSound(byte creatureType) {
 	return -1000; // if this is returned, it's an error, this should break it good
 }
 
-int16 MovesensMan::f262_getTeleporterRotatedGroupResult(Teleporter* teleporter, Thing thing, uint16 mapIndex) {
+int16 MovesensMan::getTeleporterRotatedGroupResult(Teleporter* teleporter, Thing thing, uint16 mapIndex) {
 	int16 L0683_i_Rotation;
 	uint16 L0684_ui_GroupDirections;
 	uint16 L0685_ui_UpdatedGroupDirections;
@@ -740,11 +740,11 @@ int16 MovesensMan::f262_getTeleporterRotatedGroupResult(Teleporter* teleporter,
 	return 1;
 }
 
-Thing MovesensMan::f263_getTeleporterRotatedProjectileThing(Teleporter* teleporter, Thing projectileThing) {
+Thing MovesensMan::getTeleporterRotatedProjectileThing(Teleporter* teleporter, Thing projectileThing) {
 	int16 L0693_i_UpdatedDirection;
 	int16 L0694_i_Rotation;
 
-	L0693_i_UpdatedDirection = _g400_moveResultDir;
+	L0693_i_UpdatedDirection = _moveResultDir;
 	L0694_i_Rotation = teleporter->getRotation();
 	if (teleporter->getAbsoluteRotation()) {
 		L0693_i_UpdatedDirection = L0694_i_Rotation;
@@ -752,11 +752,11 @@ Thing MovesensMan::f263_getTeleporterRotatedProjectileThing(Teleporter* teleport
 		L0693_i_UpdatedDirection = normalizeModulo4(L0693_i_UpdatedDirection + L0694_i_Rotation);
 		projectileThing = thingWithNewCell(projectileThing, normalizeModulo4((projectileThing).getCell() + L0694_i_Rotation));
 	}
-	_g400_moveResultDir = L0693_i_UpdatedDirection;
+	_moveResultDir = L0693_i_UpdatedDirection;
 	return projectileThing;
 }
 
-void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing thing, bool partySquare, bool addThing) {
+void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing thing, bool partySquare, bool addThing) {
 	Thing L0766_T_Thing;
 	int16 L0767_i_ThingType;
 	bool L0768_B_TriggerSensor;
@@ -873,7 +873,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 				case k8_SensorFloorPartyPossession:
 					if (L0767_i_ThingType != kM1_PartyThingType)
 						goto T0276079;
-					L0768_B_TriggerSensor = f274_sensorIsObjcetInPartyPossession(L0779_i_SensorData);
+					L0768_B_TriggerSensor = isObjcetInPartyPossession(L0779_i_SensorData);
 					break;
 				case k9_SensorFloorVersionChecker:
 					if ((L0767_i_ThingType != kM1_PartyThingType) || !addThing || partySquare)
@@ -914,7 +914,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 			if (L0769_ps_Sensor->getAttrAudibleA())
 				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized);
 
-			f272_sensorTriggerEffect(L0769_ps_Sensor, L0778_i_Effect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
+			triggerEffect(L0769_ps_Sensor, L0778_i_Effect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
 			goto T0276079;
 		}
 		if (L0771_ui_ThingType >= k4_GroupThingType)
@@ -922,10 +922,10 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m
 T0276079:
 		L0766_T_Thing = _vm->_dungeonMan->getNextThing(L0766_T_Thing);
 	}
-	f271_processRotationEffect();
+	processRotationEffect();
 }
 
-bool MovesensMan::f274_sensorIsObjcetInPartyPossession(int16 objectType) {
+bool MovesensMan::isObjcetInPartyPossession(int16 objectType) {
 	int16 L0742_i_ChampionIndex;
 	uint16 L0743_ui_SlotIndex = 0;
 	Thing L0744_T_Thing = Thing::_none;
@@ -968,7 +968,7 @@ T0274003:
 	return false;
 }
 
-void MovesensMan::f272_sensorTriggerEffect(Sensor* sensor, int16 effect, int16 mapX, int16 mapY, uint16 cell) {
+void MovesensMan::triggerEffect(Sensor* sensor, int16 effect, int16 mapX, int16 mapY, uint16 cell) {
 	byte g59_squareTypeToEventType[7] = { // @ G0059_auc_Graphic562_SquareTypeToEventType
 		k6_TMEventTypeWall,
 		k5_TMEventTypeCorridor,
@@ -990,7 +990,7 @@ void MovesensMan::f272_sensorTriggerEffect(Sensor* sensor, int16 effect, int16 m
 	}
 	L0738_l_Time = _vm->_gameTime + sensor->getAttrValue();
 	if (sensor->getAttrLocalEffect()) {
-		f270_sensorTriggetLocalEffect(sensor->getActionLocalEffect(), mapX, mapY, cell);
+		triggerLocalEffect(sensor->getActionLocalEffect(), mapX, mapY, cell);
 	} else {
 		L0736_i_TargetMapX = sensor->getActionTargetMapX();
 		L0737_i_TargetMapY = sensor->getActionTargetMapY();
@@ -1000,22 +1000,22 @@ void MovesensMan::f272_sensorTriggerEffect(Sensor* sensor, int16 effect, int16 m
 		} else {
 			L0740_ui_TargetCell = k0_CellNorthWest;
 		}
-		f268_addEvent(g59_squareTypeToEventType[L0739_ui_SquareType], L0736_i_TargetMapX, L0737_i_TargetMapY, L0740_ui_TargetCell, effect, L0738_l_Time);
+		addEvent(g59_squareTypeToEventType[L0739_ui_SquareType], L0736_i_TargetMapX, L0737_i_TargetMapY, L0740_ui_TargetCell, effect, L0738_l_Time);
 	}
 }
 
-void MovesensMan::f270_sensorTriggetLocalEffect(int16 localEffect, int16 effX, int16 effY, int16 effCell) {
+void MovesensMan::triggerLocalEffect(int16 localEffect, int16 effX, int16 effY, int16 effCell) {
 	if (localEffect == k10_SensorEffAddExp) {
-		f269_sensorAddSkillExperience(k8_ChampionSkillSteal, 300, localEffect != kM1_CellAny);
+		addSkillExperience(k8_ChampionSkillSteal, 300, localEffect != kM1_CellAny);
 		return;
 	}
-	_g403_sensorRotationEffect = localEffect;
-	_g404_sensorRotationEffMapX = effX;
-	_g405_sensorRotationEffMapY = effY;
-	_g406_sensorRotationEffCell = effCell;
+	_sensorRotationEffect = localEffect;
+	_sensorRotationEffMapX = effX;
+	_sensorRotationEffMapY = effY;
+	_sensorRotationEffCell = effCell;
 }
 
-void MovesensMan::f269_sensorAddSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly) {
+void MovesensMan::addSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly) {
 
 	if (leaderOnly) {
 		if (_vm->_championMan->_leaderIndex != kM1_ChampionNone) {
@@ -1032,35 +1032,35 @@ void MovesensMan::f269_sensorAddSkillExperience(int16 skillIndex, uint16 exp, bo
 	}
 }
 
-void MovesensMan::f271_processRotationEffect() {
+void MovesensMan::processRotationEffect() {
 	Thing L0732_T_FirstSensorThing;
 	Thing L0733_T_LastSensorThing;
 	Sensor* L0734_ps_FirstSensor;
 	Sensor* L0735_ps_LastSensor;
 
 
-	if (_g403_sensorRotationEffect == kM1_SensorEffNone) {
+	if (_sensorRotationEffect == kM1_SensorEffNone) {
 		return;
 	}
-	switch (_g403_sensorRotationEffect) {
+	switch (_sensorRotationEffect) {
 	case k1_SensorEffClear:
 	case k2_SensorEffToggle:
-		L0732_T_FirstSensorThing = _vm->_dungeonMan->getSquareFirstThing(_g404_sensorRotationEffMapX, _g405_sensorRotationEffMapY);
-		while (((L0732_T_FirstSensorThing).getType() != k3_SensorThingType) || ((_g406_sensorRotationEffCell != kM1_CellAny) && ((L0732_T_FirstSensorThing).getCell() != _g406_sensorRotationEffCell))) {
+		L0732_T_FirstSensorThing = _vm->_dungeonMan->getSquareFirstThing(_sensorRotationEffMapX, _sensorRotationEffMapY);
+		while (((L0732_T_FirstSensorThing).getType() != k3_SensorThingType) || ((_sensorRotationEffCell != kM1_CellAny) && ((L0732_T_FirstSensorThing).getCell() != _sensorRotationEffCell))) {
 			L0732_T_FirstSensorThing = _vm->_dungeonMan->getNextThing(L0732_T_FirstSensorThing);
 		}
 		L0734_ps_FirstSensor = (Sensor *)_vm->_dungeonMan->getThingData(L0732_T_FirstSensorThing);
 		L0733_T_LastSensorThing = L0734_ps_FirstSensor->getNextThing();
-		while ((L0733_T_LastSensorThing != Thing::_endOfList) && (((L0733_T_LastSensorThing).getType() != k3_SensorThingType) || ((_g406_sensorRotationEffCell != kM1_CellAny) && ((L0733_T_LastSensorThing).getCell() != _g406_sensorRotationEffCell)))) {
+		while ((L0733_T_LastSensorThing != Thing::_endOfList) && (((L0733_T_LastSensorThing).getType() != k3_SensorThingType) || ((_sensorRotationEffCell != kM1_CellAny) && ((L0733_T_LastSensorThing).getCell() != _sensorRotationEffCell)))) {
 			L0733_T_LastSensorThing = _vm->_dungeonMan->getNextThing(L0733_T_LastSensorThing);
 		}
 		if (L0733_T_LastSensorThing == Thing::_endOfList)
 			break;
-		_vm->_dungeonMan->unlinkThingFromList(L0732_T_FirstSensorThing, Thing(0), _g404_sensorRotationEffMapX, _g405_sensorRotationEffMapY);
+		_vm->_dungeonMan->unlinkThingFromList(L0732_T_FirstSensorThing, Thing(0), _sensorRotationEffMapX, _sensorRotationEffMapY);
 		L0735_ps_LastSensor = (Sensor *)_vm->_dungeonMan->getThingData(L0733_T_LastSensorThing);
 		L0733_T_LastSensorThing = _vm->_dungeonMan->getNextThing(L0733_T_LastSensorThing);
 		while (((L0733_T_LastSensorThing != Thing::_endOfList) && ((L0733_T_LastSensorThing).getType() == k3_SensorThingType))) {
-			if ((_g406_sensorRotationEffCell == kM1_CellAny) || ((L0733_T_LastSensorThing).getCell() == _g406_sensorRotationEffCell)) {
+			if ((_sensorRotationEffCell == kM1_CellAny) || ((L0733_T_LastSensorThing).getCell() == _sensorRotationEffCell)) {
 				L0735_ps_LastSensor = (Sensor *)_vm->_dungeonMan->getThingData(L0733_T_LastSensorThing);
 			}
 			L0733_T_LastSensorThing = _vm->_dungeonMan->getNextThing(L0733_T_LastSensorThing);
@@ -1068,10 +1068,10 @@ void MovesensMan::f271_processRotationEffect() {
 		L0734_ps_FirstSensor->setNextThing(L0735_ps_LastSensor->getNextThing());
 		L0735_ps_LastSensor->setNextThing(L0732_T_FirstSensorThing);
 	}
-	_g403_sensorRotationEffect = kM1_SensorEffNone;
+	_sensorRotationEffect = kM1_SensorEffNone;
 }
 
-void MovesensMan::f265_createEvent60to61_moveGroup(Thing groupThing, int16 mapX, int16 mapY, int16 mapIndex, bool audible) {
+void MovesensMan::createEventMoveGroup(Thing groupThing, int16 mapX, int16 mapY, int16 mapIndex, bool audible) {
 	TimelineEvent L0696_s_Event;
 
 	setMapAndTime(L0696_s_Event._mapTime, mapIndex, _vm->_gameTime + 5);
@@ -1083,7 +1083,7 @@ void MovesensMan::f265_createEvent60to61_moveGroup(Thing groupThing, int16 mapX,
 	_vm->_timeline->f238_addEventGetEventIndex(&L0696_s_Event);
 }
 
-Thing MovesensMan::f273_sensorGetObjectOfTypeInCell(int16 mapX, int16 mapY, int16 cell, int16 objectType) {
+Thing MovesensMan::getObjectOfTypeInCell(int16 mapX, int16 mapY, int16 cell, int16 objectType) {
 	Thing L0741_T_Thing;
 
 
diff --git a/engines/dm/movesens.h b/engines/dm/movesens.h
index 79a1fa9..c9381fa 100644
--- a/engines/dm/movesens.h
+++ b/engines/dm/movesens.h
@@ -38,37 +38,35 @@ namespace DM {
 	class MovesensMan {
 	DMEngine *_vm;
 public:
-	int16 _g397_moveResultMapX; // @ G0397_i_MoveResultMapX
-	int16 _g398_moveResultMapY; // @ G0398_i_MoveResultMapY
-	uint16 _g399_moveResultMapIndex; // @ G0399_ui_MoveResultMapIndex
-	int16 _g400_moveResultDir; // @ G0400_i_MoveResultDirection
-	uint16 _g401_moveResultCell; // @ G0401_ui_MoveResultCell
-	bool _g402_useRopeToClimbDownPit; // @ G0402_B_UseRopeToClimbDownPit
-	int16 _g403_sensorRotationEffect; // @ G0403_i_SensorRotationEffect
-	int16 _g404_sensorRotationEffMapX; // @ G0404_i_SensorRotationEffectMapX
-	int16 _g405_sensorRotationEffMapY; // @ G0405_i_SensorRotationEffectMapY
-	int16 _g406_sensorRotationEffCell; // @ G0406_i_SensorRotationEffectCell
 	explicit MovesensMan(DMEngine *vm);
-	bool f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam); // @ F0275_SENSOR_IsTriggeredByClickOnWall
-	bool f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destMapX, int16 destMapY); // @ F0267_MOVE_GetMoveResult_CPSCE
-	bool f264_isLevitating(Thing thing); // @ F0264_MOVE_IsLevitating
-	bool f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY, Thing thing); // @ F0266_MOVE_IsKilledByProjectileImpact
-	void f268_addEvent(byte type, byte mapX, byte mapY, byte cell, byte effect, int32 time); // @ F0268_SENSOR_AddEvent
-	int16 f514_getSound(byte creatureType); // @ F0514_MOVE_GetSound
-	int16 f262_getTeleporterRotatedGroupResult(Teleporter *teleporter, Thing thing, uint16 mapIndex);// @ F0262_MOVE_GetTeleporterRotatedGroupResult
-	Thing f263_getTeleporterRotatedProjectileThing(Teleporter *teleporter, Thing projectileThing); // @ F0263_MOVE_GetTeleporterRotatedProjectileThing
-	void f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing thing, bool partySquare, bool addThing);// @ F0276_SENSOR_ProcessThingAdditionOrRemoval
-	bool f274_sensorIsObjcetInPartyPossession(int16 objectType); // @ F0274_SENSOR_IsObjectInPartyPossession
-	void f272_sensorTriggerEffect(Sensor *sensor, int16 effect, int16 mapX, int16 mapY, uint16 cell); // @ F0272_SENSOR_TriggerEffect
-	void f270_sensorTriggetLocalEffect(int16 localEffect, int16 effX, int16 effY, int16 effCell); // @ F0270_SENSOR_TriggerLocalEffect
-	void f269_sensorAddSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly); // @ F0269_SENSOR_AddSkillExperience
-	void f271_processRotationEffect();// @ F0271_SENSOR_ProcessRotationEffect
-	void f265_createEvent60to61_moveGroup(Thing groupThing, int16 mapX, int16 mapY, int16 mapIndex, bool audible); // @ F0265_MOVE_CreateEvent60To61_MoveGroup
-	Thing f273_sensorGetObjectOfTypeInCell(int16 mapX, int16 mapY, int16 cell, int16 objectType); // @ F0273_SENSOR_GetObjectOfTypeInCell
-
-
 
+	int16 _moveResultMapX; // @ G0397_i_MoveResultMapX
+	int16 _moveResultMapY; // @ G0398_i_MoveResultMapY
+	uint16 _moveResultMapIndex; // @ G0399_ui_MoveResultMapIndex
+	int16 _moveResultDir; // @ G0400_i_MoveResultDirection
+	uint16 _moveResultCell; // @ G0401_ui_MoveResultCell
+	bool _useRopeToClimbDownPit; // @ G0402_B_UseRopeToClimbDownPit
+	int16 _sensorRotationEffect; // @ G0403_i_SensorRotationEffect
+	int16 _sensorRotationEffMapX; // @ G0404_i_SensorRotationEffectMapX
+	int16 _sensorRotationEffMapY; // @ G0405_i_SensorRotationEffectMapY
+	int16 _sensorRotationEffCell; // @ G0406_i_SensorRotationEffectCell
 
+	bool sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam); // @ F0275_SENSOR_IsTriggeredByClickOnWall
+	bool getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destMapX, int16 destMapY); // @ F0267_MOVE_GetMoveResult_CPSCE
+	bool isLevitating(Thing thing); // @ F0264_MOVE_IsLevitating
+	bool moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY, Thing thing); // @ F0266_MOVE_IsKilledByProjectileImpact
+	void addEvent(byte type, byte mapX, byte mapY, byte cell, byte effect, int32 time); // @ F0268_SENSOR_AddEvent
+	int16 getSound(byte creatureType); // @ F0514_MOVE_GetSound
+	int16 getTeleporterRotatedGroupResult(Teleporter *teleporter, Thing thing, uint16 mapIndex);// @ F0262_MOVE_GetTeleporterRotatedGroupResult
+	Thing getTeleporterRotatedProjectileThing(Teleporter *teleporter, Thing projectileThing); // @ F0263_MOVE_GetTeleporterRotatedProjectileThing
+	void processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing thing, bool partySquare, bool addThing);// @ F0276_SENSOR_ProcessThingAdditionOrRemoval
+	bool isObjcetInPartyPossession(int16 objectType); // @ F0274_SENSOR_IsObjectInPartyPossession
+	void triggerEffect(Sensor *sensor, int16 effect, int16 mapX, int16 mapY, uint16 cell); // @ F0272_SENSOR_TriggerEffect
+	void triggerLocalEffect(int16 localEffect, int16 effX, int16 effY, int16 effCell); // @ F0270_SENSOR_TriggerLocalEffect
+	void addSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly); // @ F0269_SENSOR_AddSkillExperience
+	void processRotationEffect();// @ F0271_SENSOR_ProcessRotationEffect
+	void createEventMoveGroup(Thing groupThing, int16 mapX, int16 mapY, int16 mapIndex, bool audible); // @ F0265_MOVE_CreateEvent60To61_MoveGroup
+	Thing getObjectOfTypeInCell(int16 mapX, int16 mapY, int16 cell, int16 objectType); // @ F0273_SENSOR_GetObjectOfTypeInCell
 };
 
 }
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 8ef4013..591f17f 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -152,7 +152,7 @@ T0217004:
 		L0494_ps_Door = (Door *)_vm->_dungeonMan->getSquareFirstThingData(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY);
 		if ((AL0487_i_DoorState != k5_doorState_DESTROYED) && (L0486_T_ProjectileAssociatedThing == Thing::_explOpenDoor)) {
 			if (L0494_ps_Door->hasButton()) {
-				_vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, 0, k2_SensorEffToggle, _vm->_gameTime + 1);
+				_vm->_moveSens->addEvent(k10_TMEventTypeDoor, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, 0, k2_SensorEffToggle, _vm->_gameTime + 1);
 			}
 			break;
 		}
@@ -414,7 +414,7 @@ void ProjExpl::f215_projectileDelete(Thing projectileThing, Thing* groupSlot, in
 				_vm->_dungeonMan->linkThingToList(L0479_T_Thing, L0478_T_PreviousThing, kM1_MapXNotOnASquare, 0);
 			}
 		} else {
-			_vm->_moveSens->f267_getMoveResult(Thing((L0479_T_Thing).getTypeAndIndex() | getFlag(projectileThing.toUint16(), 0xC)), -2, 0, mapX, mapY);
+			_vm->_moveSens->getMoveResult(Thing((L0479_T_Thing).getTypeAndIndex() | getFlag(projectileThing.toUint16(), 0xC)), -2, 0, mapX, mapY);
 		}
 	}
 	L0480_ps_Projectile->_nextThing = Thing::_none;
@@ -489,12 +489,12 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 	}
 	L0515_T_ProjectileThingNewCell = thingWithNewCell(L0515_T_ProjectileThingNewCell, L0518_ui_Cell &= 0x0003);
 	if (L0522_B_ProjectileMovesToOtherSquare) {
-		_vm->_moveSens->f267_getMoveResult(L0515_T_ProjectileThingNewCell, L0525_i_SourceMapX, L0526_i_SourceMapY, L0523_i_DestinationMapX, L0524_i_DestinationMapY);
-		L0519_ps_Event->_C._projectile.setMapX(_vm->_moveSens->_g397_moveResultMapX);
-		L0519_ps_Event->_C._projectile.setMapY(_vm->_moveSens->_g398_moveResultMapY);
-		L0519_ps_Event->_C._projectile.setDir((Direction)_vm->_moveSens->_g400_moveResultDir);
-		L0515_T_ProjectileThingNewCell = thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_moveSens->_g401_moveResultCell);
-		M31_setMap(L0519_ps_Event->_mapTime, _vm->_moveSens->_g399_moveResultMapIndex);
+		_vm->_moveSens->getMoveResult(L0515_T_ProjectileThingNewCell, L0525_i_SourceMapX, L0526_i_SourceMapY, L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+		L0519_ps_Event->_C._projectile.setMapX(_vm->_moveSens->_moveResultMapX);
+		L0519_ps_Event->_C._projectile.setMapY(_vm->_moveSens->_moveResultMapY);
+		L0519_ps_Event->_C._projectile.setDir((Direction)_vm->_moveSens->_moveResultDir);
+		L0515_T_ProjectileThingNewCell = thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_moveSens->_moveResultCell);
+		M31_setMap(L0519_ps_Event->_mapTime, _vm->_moveSens->_moveResultMapIndex);
 	} else {
 		if ((Square(_vm->_dungeonMan->getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY)).getType() == k4_DoorElemType) && f217_projectileHasImpactOccurred(k4_DoorElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
 			return;
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index db3e215..002b7a6 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -554,11 +554,11 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 
 
 	if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY)) {
-		_vm->_moveSens->f267_getMoveResult(Thing::_party, mapX, mapY, mapX, mapY);
+		_vm->_moveSens->getMoveResult(Thing::_party, mapX, mapY, mapX, mapY);
 		_vm->_championMan->drawChangedObjectIcons();
 	}
 	if ((L0645_T_Thing = _vm->_groupMan->groupGetThing(mapX, mapY)) != Thing::_endOfList) {
-		_vm->_moveSens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
+		_vm->_moveSens->getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
 	}
 	L0645_T_Thing = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
 	L0648_T_NextThing = L0645_T_Thing;
@@ -575,24 +575,24 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 		L0648_T_NextThing = _vm->_dungeonMan->getNextThing(L0645_T_Thing);
 		AL0644_ui_ThingType = L0645_T_Thing.getType();
 		if (AL0644_ui_ThingType > k4_GroupThingType) {
-			_vm->_moveSens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
+			_vm->_moveSens->getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
 		}
 		if (AL0644_ui_ThingType == k14_ProjectileThingType) {
 			L0646_ps_Projectile = (Projectile*)_vm->_dungeonMan->getThingData(L0645_T_Thing);
 			L0647_ps_Event = &_g370_events[L0646_ps_Projectile->_eventIndex];
-			L0647_ps_Event->_C._projectile.setMapX(_vm->_moveSens->_g397_moveResultMapX);
-			L0647_ps_Event->_C._projectile.setMapY(_vm->_moveSens->_g398_moveResultMapY);
-			L0647_ps_Event->_C._projectile.setDir((Direction)_vm->_moveSens->_g400_moveResultDir);
-			L0647_ps_Event->_B._slot = thingWithNewCell(L0645_T_Thing, _vm->_moveSens->_g401_moveResultCell).toUint16();
-			M31_setMap(L0647_ps_Event->_mapTime, _vm->_moveSens->_g399_moveResultMapIndex);
+			L0647_ps_Event->_C._projectile.setMapX(_vm->_moveSens->_moveResultMapX);
+			L0647_ps_Event->_C._projectile.setMapY(_vm->_moveSens->_moveResultMapY);
+			L0647_ps_Event->_C._projectile.setDir((Direction)_vm->_moveSens->_moveResultDir);
+			L0647_ps_Event->_B._slot = thingWithNewCell(L0645_T_Thing, _vm->_moveSens->_moveResultCell).toUint16();
+			M31_setMap(L0647_ps_Event->_mapTime, _vm->_moveSens->_moveResultMapIndex);
 		} else {
 			if (AL0644_ui_ThingType == k15_ExplosionThingType) {
 				for (AL0644_ui_EventIndex = 0, L0647_ps_Event = _g370_events; AL0644_ui_EventIndex < _g369_eventMaxCount; L0647_ps_Event++, AL0644_ui_EventIndex++) {
 					if ((L0647_ps_Event->_type == k25_TMEventTypeExplosion) && (L0647_ps_Event->_C._slot == L0645_T_Thing.toUint16())) { /* BUG0_23 A Fluxcage explosion remains on a square forever. If you open a pit or teleporter on a square where there is a Fluxcage explosion, the Fluxcage explosion is moved but the associated event is not updated (because Fluxcage explosions do not use k25_TMEventTypeExplosion but rather k24_TMEventTypeRemoveFluxcage) causing the Fluxcage explosion to remain in the dungeon forever on its destination square. When the k24_TMEventTypeRemoveFluxcage expires the explosion thing is not removed, but it is marked as unused. Consequently, any objects placed on the Fluxcage square after it was moved but before it expires become orphans upon expiration. After expiration, any object placed on the fluxcage square is cloned when picked up */
-						L0647_ps_Event->_B._location._mapX = _vm->_moveSens->_g397_moveResultMapX;
-						L0647_ps_Event->_B._location._mapY = _vm->_moveSens->_g398_moveResultMapY;
-						L0647_ps_Event->_C._slot = thingWithNewCell(L0645_T_Thing, _vm->_moveSens->_g401_moveResultCell).toUint16();
-						M31_setMap(L0647_ps_Event->_mapTime, _vm->_moveSens->_g399_moveResultMapIndex);
+						L0647_ps_Event->_B._location._mapX = _vm->_moveSens->_moveResultMapX;
+						L0647_ps_Event->_B._location._mapY = _vm->_moveSens->_moveResultMapY;
+						L0647_ps_Event->_C._slot = thingWithNewCell(L0645_T_Thing, _vm->_moveSens->_moveResultCell).toUint16();
+						M31_setMap(L0647_ps_Event->_mapTime, _vm->_moveSens->_moveResultMapIndex);
 					}
 				}
 			}
@@ -661,10 +661,10 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
 						L0638_ps_Sensor->setData(L0637_ui_SensorData);
 						if (L0638_ps_Sensor->getAttrEffectA() == k3_SensorEffHold) {
 							AL0636_B_TriggerSetEffect = ((L0637_ui_SensorData == 0) != L0638_ps_Sensor->getAttrRevertEffectA());
-							_vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
+							_vm->_moveSens->triggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
 						} else {
 							if (L0637_ui_SensorData == 0) {
-								_vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getAttrEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
+								_vm->_moveSens->triggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getAttrEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
 							}
 						}
 					}
@@ -687,10 +687,10 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
 						L0638_ps_Sensor->setData(L0637_ui_SensorData);
 						AL0636_B_TriggerSetEffect = (Sensor::getDataMask1(L0637_ui_SensorData) == Sensor::getDataMask2(L0637_ui_SensorData)) != L0638_ps_Sensor->getAttrRevertEffectA();
 						if (L0638_ps_Sensor->getAttrEffectA() == k3_SensorEffHold) {
-							_vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
+							_vm->_moveSens->triggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
 						} else {
 							if (AL0636_B_TriggerSetEffect) {
-								_vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getAttrEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
+								_vm->_moveSens->triggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getAttrEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
 							}
 						}
 					} else {
@@ -713,7 +713,7 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
 		}
 		L0634_T_Thing = _vm->_dungeonMan->getNextThing(L0634_T_Thing);
 	}
-	_vm->_moveSens->f271_processRotationEffect();
+	_vm->_moveSens->processRotationEffect();
 }
 
 void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* event) {
@@ -882,7 +882,7 @@ T0252001:
 		if (event->_type == k61_TMEventTypeMoveGroupAudible) {
 			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0656_ui_MapX, L0657_ui_MapY, k1_soundModePlayIfPrioritized);
 		}
-		_vm->_moveSens->f267_getMoveResult(Thing(event->_C._slot), kM1_MapXNotOnASquare, 0, L0656_ui_MapX, L0657_ui_MapY);
+		_vm->_moveSens->getMoveResult(Thing(event->_C._slot), kM1_MapXNotOnASquare, 0, L0656_ui_MapX, L0657_ui_MapY);
 	} else {
 		if (!L0659_B_RandomDirectionMoveRetried) {
 			L0659_B_RandomDirectionMoveRetried = true;


Commit: 52170d39aef8f0a844831cdb6bd8572210a9bb29
    https://github.com/scummvm/scummvm/commit/52170d39aef8f0a844831cdb6bd8572210a9bb29
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rename ObjectMan and ProjExpl members

Changed paths:
    engines/dm/champion.cpp
    engines/dm/console.cpp
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/objectman.cpp
    engines/dm/objectman.h
    engines/dm/projexpl.cpp
    engines/dm/projexpl.h
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 9e30bdf..6d9c579 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -236,7 +236,7 @@ bool ChampionMan::isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side)
 	kineticEnergy += _vm->getRandomNumber(16) + (kineticEnergy >> 1) + skillLevel;
 	int16 attack = getBoundedValue((uint16)40, (uint16)((skillLevel << 3) + _vm->getRandomNumber(32)), (uint16)200);
 	int16 stepEnergy = MAX(5, 11 - skillLevel);
-	_vm->_projexpl->f212_projectileCreate(curThing, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY,
+	_vm->_projexpl->createProjectile(curThing, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY,
 										  normalizeModulo4(_vm->_dungeonMan->_partyDir + side),
 										  _vm->_dungeonMan->_partyDir, kineticEnergy, attack, stepEnergy);
 	_vm->_projectileDisableMovementTicks = 4;
@@ -434,17 +434,17 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) {
 	ObjectMan &objMan = *_vm->_objectMan;
 
-	IconIndice currIconIndex = objMan.f39_getIconIndexInSlotBox(slotBoxIndex);
+	IconIndice currIconIndex = objMan.getIconIndexInSlotBox(slotBoxIndex);
 	if (((currIconIndex < k32_IconIndiceWeaponDagger) && (currIconIndex >= k0_IconIndiceJunkCompassNorth))
 		|| ((currIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (currIconIndex <= k163_IconIndicePotionWaterFlask))
 		|| (currIconIndex == k195_IconIndicePotionEmptyFlask)) {
-		IconIndice newIconIndex = objMan.f33_getIconIndex(thing);
+		IconIndice newIconIndex = objMan.getIconIndex(thing);
 		if (newIconIndex != currIconIndex) {
 			if ((slotBoxIndex < k8_SlotBoxInventoryFirstSlot) && !_mousePointerHiddenToDrawChangedObjIconOnScreen) {
 				_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
 				_vm->_eventMan->hideMouse();
 			}
-			objMan.f38_drawIconInSlotBox(slotBoxIndex, newIconIndex);
+			objMan.drawIconInSlotBox(slotBoxIndex, newIconIndex);
 			return true;
 		}
 	}
@@ -467,14 +467,14 @@ void ChampionMan::drawChangedObjectIcons() {
 	if (((leaderHandObjIconIndex < k32_IconIndiceWeaponDagger) && (leaderHandObjIconIndex >= k0_IconIndiceJunkCompassNorth))	// < instead of <= is correct
 		|| ((leaderHandObjIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= k163_IconIndicePotionWaterFlask))
 		|| (leaderHandObjIconIndex == k195_IconIndicePotionEmptyFlask)) {
-		IconIndice iconIndex = objMan.f33_getIconIndex(_leaderHandObject);
+		IconIndice iconIndex = objMan.getIconIndex(_leaderHandObject);
 		if (iconIndex != leaderHandObjIconIndex) {
 			_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
 			_vm->_eventMan->hideMouse();
-			objMan.f36_extractIconFromBitmap(iconIndex, objMan._g412_objectIconForMousePointer);
-			_vm->_eventMan->setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
+			objMan.extractIconFromBitmap(iconIndex, objMan._objectIconForMousePointer);
+			_vm->_eventMan->setPointerToObject(_vm->_objectMan->_objectIconForMousePointer);
 			_leaderHandObjectIconIndex = iconIndex;
-			objMan.f34_drawLeaderObjectName(_leaderHandObject);
+			objMan.drawLeaderObjectName(_leaderHandObject);
 		}
 	}
 
@@ -539,7 +539,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 
 	champ->_load += dunMan.getObjectWeight(thing);
 	champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
-	IconIndice iconIndex = objMan.f33_getIconIndex(thing);
+	IconIndice iconIndex = objMan.getIconIndex(thing);
 	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
 	applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
 	uint16 *rawObjPtr = dunMan.getThingData(thing);
@@ -608,7 +608,7 @@ Thing ChampionMan::getObjectRemovedFromLeaderHand() {
 		_leaderHandObject = Thing::_none;
 		_leaderHandObjectIconIndex = kM1_IconIndiceNone;
 		_vm->_eventMan->showMouse();
-		_vm->_objectMan->f35_clearLeaderObjectName();
+		_vm->_objectMan->clearLeaderObjectName();
 		_vm->_eventMan->setMousePointer();
 		_vm->_eventMan->hideMouse();
 		if (_leaderIndex != kM1_ChampionNone) {
@@ -676,7 +676,7 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 		return Thing::_none;
 
 	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal);
-	int16 curIconIndex = _vm->_objectMan->f33_getIconIndex(curThing);
+	int16 curIconIndex = _vm->_objectMan->getIconIndex(curThing);
 	// Remove object modifiers
 	applyModifiersToStatistics(curChampion, slotIndex, curIconIndex, -1, curThing);
 
@@ -947,7 +947,7 @@ void ChampionMan::disableAction(uint16 champIndex, uint16 ticks) {
 }
 
 void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp) {
-	if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && (_vm->_projexpl->_g361_lastCreatureAttackTime < _vm->_gameTime - 150))
+	if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && (_vm->_projexpl->_lastCreatureAttackTime < _vm->_gameTime - 150))
 		exp >>= 1;
 
 	if (exp) {
@@ -963,7 +963,7 @@ void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint1
 
 		uint16 skillLevelBefore = getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
 
-		if ((skillIndex >= k4_ChampionSkillSwing) && (_vm->_projexpl->_g361_lastCreatureAttackTime > _vm->_gameTime - 25))
+		if ((skillIndex >= k4_ChampionSkillSwing) && (_vm->_projexpl->_lastCreatureAttackTime > _vm->_gameTime - 25))
 			exp <<= 1;
 
 		Skill *curSkill = &curChampion->_skills[skillIndex];
@@ -1196,14 +1196,14 @@ void ChampionMan::putObjectInLeaderHand(Thing thing, bool setMousePointer) {
 		return;
 
 	_leaderEmptyHanded = false;
-	_vm->_objectMan->f36_extractIconFromBitmap(_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
+	_vm->_objectMan->extractIconFromBitmap(_leaderHandObjectIconIndex = _vm->_objectMan->getIconIndex(_leaderHandObject = thing), _vm->_objectMan->_objectIconForMousePointer);
 	_vm->_eventMan->showMouse();
-	_vm->_objectMan->f34_drawLeaderObjectName(thing);
+	_vm->_objectMan->drawLeaderObjectName(thing);
 
 	if (setMousePointer)
 		_vm->_setMousePointerToObjectInMainLoop = true;
 	else
-		_vm->_eventMan->setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
+		_vm->_eventMan->setPointerToObject(_vm->_objectMan->_objectIconForMousePointer);
 
 	_vm->_eventMan->hideMouse();
 	if (_leaderIndex != kM1_ChampionNone) {
@@ -1238,7 +1238,7 @@ int16 ChampionMan::getMovementTicks(Champion *champ) {
 	if (getFlag(champ->_wounds, k0x0020_ChampionWoundFeet))
 		ticks += woundTicks;
 
-	if (_vm->_objectMan->f33_getIconIndex(champ->_slots[k5_ChampionSlotFeet]) == k194_IconIndiceArmourBootOfSpeed)
+	if (_vm->_objectMan->getIconIndex(champ->_slots[k5_ChampionSlotFeet]) == k194_IconIndiceArmourBootOfSpeed)
 		ticks--;
 
 	return ticks;
@@ -1357,7 +1357,7 @@ bool ChampionMan::isProjectileSpellCast(uint16 champIndex, Thing thing, int16 ki
 
 void ChampionMan::championShootProjectile(Champion* champ, Thing thing, int16 kineticEnergy, int16 attack, int16 stepEnergy) {
 	Direction newDirection = champ->_dir;
-	_vm->_projexpl->f212_projectileCreate(thing, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, normalizeModulo4((((champ->_cell - newDirection + 1) & 0x0002) >> 1) + newDirection), newDirection, kineticEnergy, attack, stepEnergy);
+	_vm->_projexpl->createProjectile(thing, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, normalizeModulo4((((champ->_cell - newDirection + 1) & 0x0002) >> 1) + newDirection), newDirection, kineticEnergy, attack, stepEnergy);
 	_vm->_projectileDisableMovementTicks = 4;
 	_vm->_lastProjectileDisabledMovementDirection = newDirection;
 }
@@ -1455,7 +1455,7 @@ void ChampionMan::championKill(uint16 champIndex) {
 			_vm->_pressingEye = false;
 			_vm->_eventMan->_ignoreMouseMovements = false;
 			if (!_leaderEmptyHanded) {
-				_vm->_objectMan->f34_drawLeaderObjectName(_leaderHandObject);
+				_vm->_objectMan->drawLeaderObjectName(_leaderHandObject);
 			}
 			_vm->_eventMan->_hideMousePointerRequestCount = 1;
 			_vm->_eventMan->hideMouse();
@@ -1620,7 +1620,7 @@ void ChampionMan::applyTimeEffects() {
 			if (_partyIsSleeping)
 				staminaAmount <<= 1;
 
-			int32 compDelay = _vm->_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime;
+			int32 compDelay = _vm->_gameTime - _vm->_projexpl->_lastPartyMovementTime;
 			if (compDelay > 80) {
 				staminaAmount++;
 				if (compDelay > 250)
@@ -1663,7 +1663,7 @@ void ChampionMan::applyTimeEffects() {
 				if (_partyIsSleeping)
 					healthGain <<= 1;
 
-				if (_vm->_objectMan->f33_getIconIndex(championPtr->_slots[k10_ChampionSlotNeck]) == k121_IconIndiceJunkEkkhardCross)
+				if (_vm->_objectMan->getIconIndex(championPtr->_slots[k10_ChampionSlotNeck]) == k121_IconIndiceJunkEkkhardCross)
 					healthGain += (healthGain >> 1) + 1;
 
 				championPtr->_currHealth += MIN(healthGain, (int16)(championPtr->_maxHealth - championPtr->_currHealth));
@@ -1678,7 +1678,7 @@ void ChampionMan::applyTimeEffects() {
 						curStatistic[k1_ChampionStatCurrent] -= curStatistic[k1_ChampionStatCurrent] / statisticMaximum;
 				}
 			}
-			if (!_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_gameTime)) {
+			if (!_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_partyDir) && (_vm->_projexpl->_lastCreatureAttackTime + 60 < _vm->_gameTime)) {
 				championPtr->_dir = _vm->_dungeonMan->_partyDir;
 				championPtr->_maximumDamageReceived = 0;
 				setFlag(championPtr->_attributes, k0x0400_ChampionAttributeIcon);
@@ -2101,7 +2101,7 @@ uint16 ChampionMan::getMaximumLoad(Champion *champ) {
 	if (wounds)
 		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(k0x0010_ChampionWoundLegs) ? 2 : 3);
 
-	if (_vm->_objectMan->f33_getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == k119_IconIndiceArmourElvenBoots)
+	if (_vm->_objectMan->getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == k119_IconIndiceArmourElvenBoots)
 		maximumLoad += maximumLoad * 16;
 
 	maximumLoad += 9;
@@ -2314,7 +2314,7 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 	else
 		thing = champ->getSlot((ChampionSlot)slotIndex);
 
-	SlotBox *slotBox = &_vm->_objectMan->_g30_slotBoxes[slotBoxIndex];
+	SlotBox *slotBox = &_vm->_objectMan->_slotBoxes[slotBoxIndex];
 	Box box;
 	box._x1 = slotBox->_x - 1;
 	box._y1 = slotBox->_y - 1;
@@ -2340,7 +2340,7 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 				iconIndex = k204_IconIndiceEmptyBox;
 		}
 	} else {
-		iconIndex = _vm->_objectMan->f33_getIconIndex(thing); // BUG0_35
+		iconIndex = _vm->_objectMan->getIconIndex(thing); // BUG0_35
 		if (isInventoryChamp && (slotIndex == k1_ChampionSlotActionHand) && ((iconIndex == k144_IconIndiceContainerChestClosed) || (iconIndex == k30_IconIndiceScrollOpen))) {
 			iconIndex++;
 		} // BUG2_00
@@ -2368,7 +2368,7 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 		}
 	}
 
-	_vm->_objectMan->f38_drawIconInSlotBox(slotBoxIndex, iconIndex);
+	_vm->_objectMan->drawIconInSlotBox(slotBoxIndex, iconIndex);
 
 	if (!isInventoryChamp)
 		_vm->_eventMan->showMouse();
@@ -2569,13 +2569,13 @@ uint16 ChampionMan::getSkillLevel(int16 champIndex, uint16 skillIndex) {
 		skillLevel++;
 	}
 	if (!ignoreObjModifiers) {
-		int16 actionHandIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
+		int16 actionHandIconIndex = _vm->_objectMan->getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
 		if (actionHandIconIndex == k27_IconIndiceWeaponTheFirestaff)
 			skillLevel++;
 		else if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete)
 			skillLevel += 2;
 
-		int16 neckIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k10_ChampionSlotNeck]);
+		int16 neckIconIndex = _vm->_objectMan->getIconIndex(champ->_slots[k10_ChampionSlotNeck]);
 		switch (skillIndex) {
 		case k3_ChampionSkillWizard:
 			if (neckIconIndex == k124_IconIndiceJunkPendantFeral)
diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index 77da72a..c5ebd14 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -208,12 +208,12 @@ bool Console::Cmd_listItems(int argc, const char** argv) {
 	bool atleastOneFound = false;
 	int16 namesPrintedInLine = 0;
 
-	if(strstr(_vm->_objectMan->_g352_objectNames[0], searchedString.c_str()) != nullptr)
-		debugPrintf("| %s", _vm->_objectMan->_g352_objectNames[0]);
+	if(strstr(_vm->_objectMan->_objectNames[0], searchedString.c_str()) != nullptr)
+		debugPrintf("| %s", _vm->_objectMan->_objectNames[0]);
 
 	for (uint16 i = 1; i < k199_ObjectNameCount; ++i) {
-		const char *name = _vm->_objectMan->_g352_objectNames[i - 1];
-		const char *prevName = _vm->_objectMan->_g352_objectNames[i];
+		const char *name = _vm->_objectMan->_objectNames[i - 1];
+		const char *prevName = _vm->_objectMan->_objectNames[i];
 
 		if (!cstrEquals(name, prevName) && (strstr(name, searchedString.c_str()) != nullptr)) {
 			debugPrintf(" | %s", name);
@@ -257,9 +257,9 @@ bool Console::Cmd_gimme(int argc, const char** argv) {
 		dummyThing.setType(thingType);
 		for (int16 thingIndex = 0; thingIndex < thingCount; ++thingIndex) {
 			dummyThing.setIndex(thingIndex);
-			int16 iconIndex = _vm->_objectMan->f33_getIconIndex(dummyThing);
+			int16 iconIndex = _vm->_objectMan->getIconIndex(dummyThing);
 			if (iconIndex != -1) {
-				const char *displayName = _vm->_objectMan->_g352_objectNames[iconIndex];
+				const char *displayName = _vm->_objectMan->_objectNames[iconIndex];
 				if (cstrEquals(displayName, requestedItemName.c_str())) {
 					uint16 *newThingData = new uint16[(thingCount + 1) * thingTypeSize];
 					memcpy(newThingData, thingDataArray, sizeof(uint16) * thingTypeSize * thingCount);
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index c82246d..eb592ed 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -456,7 +456,7 @@ void DMEngine::gameloop() {
 			if (_setMousePointerToObjectInMainLoop) {
 				_setMousePointerToObjectInMainLoop = false;
 				_eventMan->showMouse();
-				_eventMan->setPointerToObject(_objectMan->_g412_objectIconForMousePointer);
+				_eventMan->setPointerToObject(_objectMan->_objectIconForMousePointer);
 				_eventMan->hideMouse();
 
 			}
@@ -1002,14 +1002,14 @@ T0446002:
 
 	fuseSequenceUpdate();
 	for (AL1424_i_Attack = 55; AL1424_i_Attack <= 255; AL1424_i_Attack += 40) {
-		_projexpl->f213_explosionCreate(Thing::_explFireBall, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
+		_projexpl->createExplosion(Thing::_explFireBall, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
 		fuseSequenceUpdate();
 	}
 	_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized);
 	L1428_ps_Group->_type = k25_CreatureTypeLordOrder;
 	fuseSequenceUpdate();
 	for (AL1424_i_Attack = 55; AL1424_i_Attack <= 255; AL1424_i_Attack += 40) {
-		_projexpl->f213_explosionCreate(Thing::_explHarmNonMaterial, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
+		_projexpl->createExplosion(Thing::_explHarmNonMaterial, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
 		fuseSequenceUpdate();
 	}
 	for (AL1425_i_CycleCount = 4; --AL1425_i_CycleCount; ) {
@@ -1019,8 +1019,8 @@ T0446002:
 			for (AL1426_i_FuseSequenceUpdateCount = AL1425_i_CycleCount; AL1426_i_FuseSequenceUpdateCount--; fuseSequenceUpdate());
 		}
 	}
-	_projexpl->f213_explosionCreate(Thing::_explFireBall, 255, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
-	_projexpl->f213_explosionCreate(Thing::_explHarmNonMaterial, 255, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
+	_projexpl->createExplosion(Thing::_explFireBall, 255, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
+	_projexpl->createExplosion(Thing::_explHarmNonMaterial, 255, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
 	fuseSequenceUpdate();
 	L1428_ps_Group->_type = k26_CreatureTypeGreyLord;
 	fuseSequenceUpdate();
@@ -1061,7 +1061,7 @@ T0446002:
 	}
 
 	for (AL1424_i_Attack = 55; AL1424_i_Attack <= 255; AL1424_i_Attack += 40) {
-		_projexpl->f213_explosionCreate(Thing::_explHarmNonMaterial, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
+		_projexpl->createExplosion(Thing::_explHarmNonMaterial, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
 		fuseSequenceUpdate();
 	}
 
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 82b1e8d..dbfbfc3 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1451,9 +1451,9 @@ Thing DungeonMan::getDiscardThing(uint16 thingType) {
 									_vm->_groupMan->dropGroupPossessions(currMapX, currMapY, squareThing, kM1_soundModeDoNotPlaySound);
 									_vm->_groupMan->groupDelete(currMapX, currMapY);
 								} else {
-									_vm->_projexpl->f214_projectileDeleteEvent(squareThing);
+									_vm->_projexpl->projectileDeleteEvent(squareThing);
 									unlinkThingFromList(squareThing, Thing(0), currMapX, currMapY);
-									_vm->_projexpl->f215_projectileDelete(squareThing, 0, currMapX, currMapY);
+									_vm->_projexpl->projectileDelete(squareThing, 0, currMapX, currMapY);
 								}
 								break;
 							case k6_ArmourThingType:
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index c84fd01..a823486 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -579,7 +579,7 @@ void EventManager::setMousePointer() {
 	if (_vm->_championMan->_leaderEmptyHanded)
 		setMousePointerToNormal((_vm->_championMan->_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
 	else
-		setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
+		setPointerToObject(_vm->_objectMan->_objectIconForMousePointer);
 }
 
 void EventManager::showMouse() {
@@ -1195,7 +1195,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 					processType80_clickInDungeonViewDropLeaderHandObject(k4_ViewCellAlcove);
 				else {
 					if (_vm->_dungeonMan->_isFacingFountain) {
-						uint16 iconIdx = _vm->_objectMan->f33_getIconIndex(thingHandObject);
+						uint16 iconIdx = _vm->_objectMan->getIconIndex(thingHandObject);
 						uint16 weight = _vm->_dungeonMan->getObjectWeight(thingHandObject);
 						if ((iconIdx >= k8_IconIndiceJunkWater) && (iconIdx <= k9_IconIndiceJunkWaterSkin))
 							junkPtr->setChargeCount(3); /* Full */
@@ -1286,7 +1286,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	}
 
 	if (champMan._partyChampionCount == 1) {
-		_vm->_projexpl->_g362_lastPartyMovementTime = _vm->_gameTime;
+		_vm->_projexpl->_lastPartyMovementTime = _vm->_gameTime;
 		commandSetLeader(k0_ChampionFirst);
 		_vm->_menuMan->setMagicCasterAndDrawSpellArea(k0_ChampionFirst);
 	} else
@@ -1356,7 +1356,7 @@ void EventManager::processType80_clickInDungeonView_grabLeaderHandObject(uint16
 	}
 
 	Thing topPileThing = _vm->_dungeonMan->_pileTopObject[viewCell];
-	if (_vm->_objectMan->f33_getIconIndex(topPileThing) != kM1_IconIndiceNone) {
+	if (_vm->_objectMan->getIconIndex(topPileThing) != kM1_IconIndiceNone) {
 		_vm->_moveSens->getMoveResult(topPileThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
 		_vm->_championMan->putObjectInLeaderHand(topPileThing, true);
 	}
@@ -1380,7 +1380,7 @@ void EventManager::processType80_clickInDungeonViewDropLeaderHandObject(uint16 v
 	uint16 currCell = normalizeModulo4(_vm->_dungeonMan->_partyDir + viewCell);
 	Thing removedThing = _vm->_championMan->getObjectRemovedFromLeaderHand();
 	_vm->_moveSens->getMoveResult(thingWithNewCell(removedThing, currCell), kM1_MapXNotOnASquare, 0, mapX, mapY);
-	if (droppingIntoAnAlcove && _vm->_dungeonMan->_isFacingViAltar && (_vm->_objectMan->f33_getIconIndex(removedThing) == k147_IconIndiceJunkChampionBones)) {
+	if (droppingIntoAnAlcove && _vm->_dungeonMan->_isFacingViAltar && (_vm->_objectMan->getIconIndex(removedThing) == k147_IconIndiceJunkChampionBones)) {
 		Junk *removedJunk = (Junk*)_vm->_dungeonMan->getThingData(removedThing);
 		TimelineEvent newEvent;
 		setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + 1);
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 9155418..ebc946b 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -295,14 +295,14 @@ int16 GroupMan::getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY
 	int16 L0556_i_Direction;
 
 	if (srcMapX == destMapX) {
-		_vm->_projexpl->_g363_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 1; /* Resulting direction may be 1 or 3 (East or West) */
+		_vm->_projexpl->_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 1; /* Resulting direction may be 1 or 3 (East or West) */
 		if (srcMapY > destMapY) {
 			return kDirNorth;
 		}
 		return kDirSouth;
 	}
 	if (srcMapY == destMapY) {
-		_vm->_projexpl->_g363_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 0; /* Resulting direction may be 0 or 2 (North or South) */
+		_vm->_projexpl->_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 0; /* Resulting direction may be 0 or 2 (North or South) */
 		if (srcMapX > destMapX) {
 			return kDirWest;
 		}
@@ -311,15 +311,15 @@ int16 GroupMan::getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY
 	L0556_i_Direction = kDirNorth;
 	for (;;) {
 		if (isDestVisibleFromSource(L0556_i_Direction, srcMapX, srcMapY, destMapX, destMapY)) {
-			if (!isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
-				if ((L0556_i_Direction != kDirNorth) || !isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnPrevVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
-					_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + L0556_i_Direction);
+			if (!isDestVisibleFromSource(_vm->_projexpl->_secondaryDirToOrFromParty = returnNextVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
+				if ((L0556_i_Direction != kDirNorth) || !isDestVisibleFromSource(_vm->_projexpl->_secondaryDirToOrFromParty = returnPrevVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
+					_vm->_projexpl->_secondaryDirToOrFromParty = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + L0556_i_Direction);
 					return L0556_i_Direction;
 				}
 			}
 			if (_vm->getRandomNumber(2)) {
-				AP0483_i_PrimaryDirection = _vm->_projexpl->_g363_secondaryDirToOrFromParty;
-				_vm->_projexpl->_g363_secondaryDirToOrFromParty = L0556_i_Direction;
+				AP0483_i_PrimaryDirection = _vm->_projexpl->_secondaryDirToOrFromParty;
+				_vm->_projexpl->_secondaryDirToOrFromParty = L0556_i_Direction;
 				return AP0483_i_PrimaryDirection;
 			}
 			return L0556_i_Direction;
@@ -495,7 +495,7 @@ int16 GroupMan::groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex
 				AL0374_ui_Attack = 255;
 			}
 		}
-		_vm->_projexpl->f213_explosionCreate(Thing::_explSmoke, AL0374_ui_Attack, mapX, mapY, L0384_ui_Cell); /* BUG0_66 Smoke is placed on the source map instead of the destination map when a creature dies by falling through a pit. The game has a special case to correctly drop the creature possessions on the destination map but there is no such special case for the smoke. Note that the death must be caused by the damage of the fall (there is no smoke if the creature is removed because its type is not allowed on the destination map). However this bug has no visible consequence because of BUG0_26: the smoke explosion falls in the pit right after being placed in the dungeon and before being drawn on screen so it is only visible on the destination square */
+		_vm->_projexpl->createExplosion(Thing::_explSmoke, AL0374_ui_Attack, mapX, mapY, L0384_ui_Cell); /* BUG0_66 Smoke is placed on the source map instead of the destination map when a creature dies by falling through a pit. The game has a special case to correctly drop the creature possessions on the destination map but there is no such special case for the smoke. Note that the death must be caused by the damage of the fall (there is no smoke if the creature is removed because its type is not allowed on the destination map). However this bug has no visible consequence because of BUG0_26: the smoke explosion falls in the pit right after being placed in the dungeon and before being drawn on screen so it is only visible on the destination square */
 		return AL0375_ui_Outcome;
 	}
 	if (damage > 0) {
@@ -715,7 +715,7 @@ T0209005_AddEventAndReturn:
 	_groupMovementTestedDirections[0] = 0;
 	_currGroupDistanceToParty = getDistanceBetweenSquares(eventMapX, eventMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
 	_currGroupPrimaryDirToParty = getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
-	_currGroupSecondaryDirToParty = _vm->_projexpl->_g363_secondaryDirToOrFromParty;
+	_currGroupSecondaryDirToParty = _vm->_projexpl->_secondaryDirToOrFromParty;
 	L0464_l_NextAspectUpdateTime = 0;
 	L0455_B_CurrentEventTypeIsNotUpdateBehavior = true;
 	if (eventType <= k31_TMEventTypeGroupReactionPartyIsAdjecent) { /* Process Reaction events 29 to 31 */
@@ -862,7 +862,7 @@ T0209061_MoveGroup:
 							(L0462_i_TicksSinceLastMove != -1) &&
 							L0463_B_Archenemy &&
 							((eventType == kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) || !_vm->getRandomNumber(4))) { /* BUG0_15 The game hangs when you close a door on Lord Chaos. A condition is missing in the code to manage creatures and this may create an infinite loop between two parts in the code */
-							_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0454_i_PrimaryDirectionToOrFromParty = _vm->getRandomNumber(4));
+							_vm->_projexpl->_secondaryDirToOrFromParty = returnNextVal(L0454_i_PrimaryDirectionToOrFromParty = _vm->getRandomNumber(4));
 							goto T0209089_DoubleSquareMove; /* BUG0_69 Memory corruption when you close a door on Lord Chaos. The local variable (L0454_i_PrimaryDirectionToOrFromParty) containing the direction where Lord Chaos tries to move may be used as an array index without being initialized and cause memory corruption */
 						}
 						if (L0453_B_NewGroupDirectionFound || ((!_vm->getRandomNumber(4) || (L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.getSmellRange())) && (eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare))) {
@@ -910,7 +910,7 @@ T0209084_SingleSquareMoveTowardParty:
 					L0454_i_PrimaryDirectionToOrFromParty = getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY);
 T0209085_SingleSquareMove:
 					if (isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls) ||
-						isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls && _vm->getRandomNumber(2)) ||
+						isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_secondaryDirToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls && _vm->getRandomNumber(2)) ||
 						isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)AL0446_i_Direction), false) ||
 						(!_vm->getRandomNumber(4) && isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)L0454_i_PrimaryDirectionToOrFromParty), false))) {
 						AL0450_i_DestinationMapX = eventMapX;
@@ -922,7 +922,7 @@ T0209085_SingleSquareMove:
 T0209089_DoubleSquareMove:
 						getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false); /* BUG0_00 Useless code. Returned value is ignored. When Lord Chaos teleports two squares away the ability to move to the first square is ignored which means Lord Chaos can teleport through walls or any other obstacle */
 						if (isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty) ||
-							isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty) ||
+							isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_secondaryDirToOrFromParty) ||
 							(_fluxCageCount && isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)AL0446_i_Direction))) ||
 							((_fluxCageCount >= 2) && isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)L0454_i_PrimaryDirectionToOrFromParty)))) {
 							AL0450_i_DestinationMapX = eventMapX;
@@ -965,7 +965,7 @@ T0209096_SetBehavior0_Wander:
 						}
 						/* Try and flee from the party (opposite direction) */
 						L0454_i_PrimaryDirectionToOrFromParty = returnOppositeDir((Direction)getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY));
-						_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnOppositeDir((Direction)_vm->_projexpl->_g363_secondaryDirToOrFromParty);
+						_vm->_projexpl->_secondaryDirToOrFromParty = returnOppositeDir((Direction)_vm->_projexpl->_secondaryDirToOrFromParty);
 						L0461_i_MovementTicks -= (L0461_i_MovementTicks >> 2);
 						goto T0209085_SingleSquareMove;
 					}
@@ -1007,7 +1007,7 @@ T0209096_SetBehavior0_Wander:
 					}
 					/* If 1/8 chance and the creature is not adjacent to the party and is a quarter square sized creature then process projectile impacts and update the creature cell if still alive. When the creature is not in front of the party, it has 7/8 chances of dodging a projectile by moving to another cell or staying in the center of the square */
 					if (!(AL0446_i_GroupCellsCriteria & 0x0038) && (L0452_i_DistanceToVisibleParty != 1) && (L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter)) {
-						if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* This call to F0218_PROJECTILE_GetImpactCount works fine because there is a single creature in the group so L0445_ps_ActiveGroup->Cells contains only one cell index */
+						if (_vm->_projexpl->projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* This call to F0218_PROJECTILE_GetImpactCount works fine because there is a single creature in the group so L0445_ps_ActiveGroup->Cells contains only one cell index */
 							goto T0209139_Return;
 						L0445_ps_ActiveGroup->_cells = normalizeModulo4(AL0446_i_GroupCellsCriteria);
 					}
@@ -1036,9 +1036,9 @@ T0209096_SetBehavior0_Wander:
 								}
 								if (!getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = normalizeModulo4(AL0446_i_Cell)) ||
 									(_vm->getRandomNumber(2) && !getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((Direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */
-									if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* BUG0_70 A projectile impact on a creature may be ignored. The function F0218_PROJECTILE_GetImpactCount to detect projectile impacts when a quarter square sized creature moves inside a group (to another cell on the same square) may fail if there are several creatures in the group because the function expects a single cell index for its last parameter. The function should be called once for each cell where there is a creature */
+									if (_vm->_projexpl->projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* BUG0_70 A projectile impact on a creature may be ignored. The function F0218_PROJECTILE_GetImpactCount to detect projectile impacts when a quarter square sized creature moves inside a group (to another cell on the same square) may fail if there are several creatures in the group because the function expects a single cell index for its last parameter. The function should be called once for each cell where there is a creature */
 										goto T0209139_Return;
-									if (_vm->_projexpl->_g364_creatureDamageOutcome != k1_outcomeKilledSomeCreaturesInGroup) {
+									if (_vm->_projexpl->_creatureDamageOutcome != k1_outcomeKilledSomeCreaturesInGroup) {
 										L0445_ps_ActiveGroup->_cells = getGroupValueUpdatedWithCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex, AL0446_i_Cell);
 									}
 								}
@@ -1399,7 +1399,7 @@ int16 GroupMan::getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo, int
 		return 0;
 	}
 	if ((((L0426_ui_SmellRange + 1) >> 1) >= _currGroupDistanceToParty) && getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, &GroupMan::isSmellPartyBlocked)) {
-		_vm->_projexpl->_g363_secondaryDirToOrFromParty = _currGroupSecondaryDirToParty;
+		_vm->_projexpl->_secondaryDirToOrFromParty = _currGroupSecondaryDirToParty;
 		return _vm->indexToOrdinal(_currGroupPrimaryDirToParty);
 	}
 	if ((L0427_i_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapY, mapX)) && ((_vm->_championMan->_party._scentStrengths[_vm->ordinalToIndex(L0427_i_ScentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (L0426_ui_SmellRange << 1)))) { /* If there is a fresh enough party scent on the group square */
@@ -1471,7 +1471,7 @@ bool GroupMan::isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16
 #define AL0440_i_Damage             L0440_i_Multiple
 #define AL0440_i_AttackSoundOrdinal L0440_i_Multiple
 
-	_vm->_projexpl->_g361_lastCreatureAttackTime = _vm->_gameTime;
+	_vm->_projexpl->_lastCreatureAttackTime = _vm->_gameTime;
 	ActiveGroup L0443_s_ActiveGroup = _activeGroups[group->getActiveGroupIndex()];
 	CreatureInfo *L0441_ps_CreatureInfo = &g243_CreatureInfo[AL0437_ui_CreatureType = group->_type];
 	uint16 L0438_ui_PrimaryDirectionToParty = _currGroupPrimaryDirToParty;
@@ -1527,7 +1527,7 @@ bool GroupMan::isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
 		_vm->_sound->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, mapX, mapY, k0_soundModePlayImmediately);
-		_vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (Direction)_currGroupPrimaryDirToParty, getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
+		_vm->_projexpl->createProjectile(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (Direction)_currGroupPrimaryDirToParty, getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
 	} else {
 		if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) {
 			AL0439_i_ChampionIndex = _vm->getRandomNumber(4);
@@ -1905,7 +1905,7 @@ int16 GroupMan::getMeleeActionDamage(Champion* champ, int16 champIndex, Group* g
 	}
 	L0567_i_DoubledMapDifficulty = _vm->_dungeonMan->_currMap->_difficulty << 1;
 	L0572_ps_CreatureInfo = &g243_CreatureInfo[group->_type];
-	L0571_i_ActionHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
+	L0571_i_ActionHandObjectIconIndex = _vm->_objectMan->getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
 	L0570_B_ActionHitsNonMaterialCreatures = getFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
 	if (L0570_B_ActionHitsNonMaterialCreatures)
 		clearFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
@@ -2072,7 +2072,7 @@ void GroupMan::fuseAction(uint16 mapX, uint16 mapY) {
 		return;
 	}
 
-	_vm->_projexpl->f213_explosionCreate(Thing::_explHarmNonMaterial, 255, mapX, mapY, k255_CreatureTypeSingleCenteredCreature); /* BUG0_17 The game crashes after the Fuse action is performed while looking at a wall on a map boundary. An explosion thing is created on the square in front of the party but there is no check to ensure the square coordinates are in the map bounds. This corrupts a memory location and leads to a game crash */
+	_vm->_projexpl->createExplosion(Thing::_explHarmNonMaterial, 255, mapX, mapY, k255_CreatureTypeSingleCenteredCreature); /* BUG0_17 The game crashes after the Fuse action is performed while looking at a wall on a map boundary. An explosion thing is created on the square in front of the party but there is no check to ensure the square coordinates are in the map bounds. This corrupts a memory location and leads to a game crash */
 	L0555_T_LordChaosThing = Thing(isLordChaosOnSquare(mapX, mapY));
 	if (L0555_T_LordChaosThing.toUint16()) {
 		L0551_ui_FluxcageCount = (L0554_aB_Fluxcages[0] = isFluxcageOnSquare(mapX - 1, mapY)) +
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 0cbc095..c7f95c6 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -372,7 +372,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 
 	_openChest = thingToOpen;
 	if (!isPressingEye) {
-		objMan.f38_drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen);
+		objMan.drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen);
 	}
 	dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k25_PanelOpenChestIndice),
 							   _boxPanel, k72_byteWidth, k8_ColorRed, 73);
@@ -383,12 +383,12 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 		if (++thingCount > 8)
 			break; // CHANGE8_08_FIX, make sure that no more than the first 8 objects in a chest are drawn
 
-		objMan.f38_drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, objMan.f33_getIconIndex(thing));
+		objMan.drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, objMan.getIconIndex(thing));
 		_chestSlots[chestSlotIndex++] = thing;
 		thing = _vm->_dungeonMan->getNextThing(thing);
 	}
 	while (chestSlotIndex < 8) {
-		objMan.f38_drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, kM1_IconIndiceNone);
+		objMan.drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, kM1_IconIndiceNone);
 		_chestSlots[chestSlotIndex++] = Thing::_none;
 	}
 }
@@ -398,7 +398,7 @@ void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yP
 	Box box;
 	box._x2 = (box._x1 = xPos) + 15;
 	box._y2 = (box._y1 = yPos) + 15;
-	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, iconBitmap);
+	_vm->_objectMan->extractIconFromBitmap(iconIndex, iconBitmap);
 	_vm->_displayMan->blitToViewport(iconBitmap, box, k8_byteWidth, kM1_ColorNoTransparency, 16);
 }
 
@@ -510,7 +510,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 	} else if (thingType == k9_ContainerThingType) {
 		openAndDrawChest(thingToDraw, (Container *)rawThingPtr, pressingEye);
 	} else {
-		IconIndice iconIndex = objMan.f33_getIconIndex(thingToDraw);
+		IconIndice iconIndex = objMan.getIconIndex(thingToDraw);
 		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k20_PanelEmptyIndice),
 								   _boxPanel, k72_byteWidth, k8_ColorRed, 73);
 		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k29_ObjectDescCircleIndice),
@@ -525,10 +525,10 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			case Common::DE_DEU: // german and english versions are the same
 				strcpy(str, champMan._champions[((Junk *)rawThingPtr)->getChargeCount()]._name);
 				strcat(str, " ");
-				strcat(str, objMan._g352_objectNames[iconIndex]);
+				strcat(str, objMan._objectNames[iconIndex]);
 				break;
 			case Common::FR_FRA:
-				strcat(str, objMan._g352_objectNames[iconIndex]);
+				strcat(str, objMan._objectNames[iconIndex]);
 				strcat(str, " ");
 				strcpy(str, champMan._champions[((Junk *)rawThingPtr)->getChargeCount()]._name);
 				break;
@@ -541,10 +541,10 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			str[0] = '_' + ((Potion *)rawThingPtr)->getPower() / 40;
 			str[1] = ' ';
 			str[2] = '\0';
-			strcat(str, objMan._g352_objectNames[iconIndex]);
+			strcat(str, objMan._objectNames[iconIndex]);
 			descString = str;
 		} else {
-			descString = objMan._g352_objectNames[iconIndex];
+			descString = objMan._objectNames[iconIndex];
 		}
 
 		textMan.f52_printToViewport(134, 68, k13_ColorLightestGray, descString);
@@ -711,8 +711,8 @@ void InventoryMan::setDungeonViewPalette() {
 			uint16 AL1039_ui_SlotIndex = k1_ChampionSlotActionHand + 1;
 			while (AL1039_ui_SlotIndex--) {
 				uint16 AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16();
-				if ((_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing)) >= k4_IconIndiceWeaponTorchUnlit) &&
-					(_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing)) <= k7_IconIndiceWeaponTorchLit)) {
+				if ((_vm->_objectMan->getObjectType(Thing(AL1044_T_Thing)) >= k4_IconIndiceWeaponTorchUnlit) &&
+					(_vm->_objectMan->getObjectType(Thing(AL1044_T_Thing)) <= k7_IconIndiceWeaponTorchLit)) {
 					Weapon *L1042_ps_Weapon = (Weapon*)_vm->_dungeonMan->getThingData(Thing(AL1044_T_Thing));
 					*AL1040_pi_TorchLightPower = L1042_ps_Weapon->getChargeCount();
 				} else {
@@ -779,7 +779,7 @@ void InventoryMan::decreaseTorchesLightPower() {
 	while (L1046_i_ChampionCount--) {
 		int16 L1047_i_SlotIndex = k1_ChampionSlotActionHand + 1;
 		while (L1047_i_SlotIndex--) {
-			int16 L1049_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L1050_ps_Champion->_slots[L1047_i_SlotIndex]);
+			int16 L1049_i_IconIndex = _vm->_objectMan->getIconIndex(L1050_ps_Champion->_slots[L1047_i_SlotIndex]);
 			if ((L1049_i_IconIndex >= k4_IconIndiceWeaponTorchUnlit) && (L1049_i_IconIndex <= k7_IconIndiceWeaponTorchLit)) {
 				Weapon *L1051_ps_Weapon = (Weapon *)_vm->_dungeonMan->getThingData(L1050_ps_Champion->_slots[L1047_i_SlotIndex]);
 				if (L1051_ps_Weapon->getChargeCount()) {
@@ -888,7 +888,7 @@ void InventoryMan::drawStopPressingEye() {
 	drawPanel();
 	_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 	if ((L1100_T_LeaderHandObject = _vm->_championMan->_leaderHandObject) != Thing::_none) {
-		_vm->_objectMan->f34_drawLeaderObjectName(L1100_T_LeaderHandObject);
+		_vm->_objectMan->drawLeaderObjectName(L1100_T_LeaderHandObject);
 	}
 	_vm->_eventMan->showMouse();
 	_vm->_eventMan->showMouse();
@@ -950,7 +950,7 @@ void InventoryMan::clickOnMouth() {
 	if (!getFlag(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(L1078_T_Thing = _vm->_championMan->_leaderHandObject)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) {
 		return;
 	}
-	L1079_ui_IconIndex = _vm->_objectMan->f33_getIconIndex(L1078_T_Thing);
+	L1079_ui_IconIndex = _vm->_objectMan->getIconIndex(L1078_T_Thing);
 	AL1088_ui_ThingType = L1078_T_Thing.getType();
 	L1089_ui_Weight = _vm->_dungeonMan->getObjectWeight(L1078_T_Thing);
 	L1083_ps_Champion = &_vm->_championMan->_champions[L1080_ui_ChampionIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal)];
@@ -1051,7 +1051,7 @@ void InventoryMan::clickOnMouth() {
 
 	if (L1081_B_RemoveObjectFromLeaderHand) {
 		for (L1086_ui_Counter = 5; --L1086_ui_Counter; _vm->delay(8)) { /* Animate mouth icon */
-			_vm->_objectMan->f37_drawIconToScreen(k205_IconIndiceMouthOpen + !(L1086_ui_Counter & 0x0001), 56, 46);
+			_vm->_objectMan->drawIconToScreen(k205_IconIndiceMouthOpen + !(L1086_ui_Counter & 0x0001), 56, 46);
 			_vm->_eventMan->discardAllInput();
 			if (_vm->_engineShouldQuit)
 				return;
@@ -1109,7 +1109,7 @@ void InventoryMan::clickOnEye() {
 	if (_vm->_championMan->_leaderEmptyHanded) {
 		drawChampionSkillsAndStatistics();
 	} else {
-		_vm->_objectMan->f35_clearLeaderObjectName();
+		_vm->_objectMan->clearLeaderObjectName();
 		drawPanelObject(_vm->_championMan->_leaderHandObject, true);
 	}
 	_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index d30eb62..1108fd8 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -103,8 +103,8 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
 		_timeline->_g373_firstUnusedEventIndex = file->readUint16BE();
 		_timeline->_g369_eventMaxCount = file->readUint16BE();
 		_groupMan->_currActiveGroupCount = file->readUint16BE();
-		_projexpl->_g361_lastCreatureAttackTime = file->readSint32BE();
-		_projexpl->_g362_lastPartyMovementTime = file->readSint32BE();
+		_projexpl->_lastCreatureAttackTime = file->readSint32BE();
+		_projexpl->_lastPartyMovementTime = file->readSint32BE();
 		_disabledMovementTicks = file->readSint16BE();
 		_projectileDisableMovementTicks = file->readSint16BE();
 		_lastProjectileDisabledMovementDirection = file->readSint16BE();
@@ -319,8 +319,8 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 	file->writeUint16BE(_timeline->_g373_firstUnusedEventIndex);
 	file->writeUint16BE(_timeline->_g369_eventMaxCount);
 	file->writeUint16BE(_groupMan->_currActiveGroupCount);
-	file->writeSint32BE(_projexpl->_g361_lastCreatureAttackTime);
-	file->writeSint32BE(_projexpl->_g362_lastPartyMovementTime);
+	file->writeSint32BE(_projexpl->_lastCreatureAttackTime);
+	file->writeSint32BE(_projexpl->_lastPartyMovementTime);
 	file->writeSint16BE(_disabledMovementTicks);
 	file->writeSint16BE(_projectileDisableMovementTicks);
 	file->writeSint16BE(_lastProjectileDisabledMovementDirection);
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 8750d30..79955b8 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -158,12 +158,12 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) {
 	if (thing == Thing::_none) {
 		iconIndex = k201_IconIndiceActionEmptyHand;
 	} else if (_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
-		iconIndex = _vm->_objectMan->f33_getIconIndex(thing);
+		iconIndex = _vm->_objectMan->getIconIndex(thing);
 	} else {
 		dm.fillBitmap(bitmapIcon, k4_ColorCyan, 16, 16);
 		goto T0386006;
 	}
-	_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, bitmapIcon);
+	_vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon);
 	dm.blitToBitmapShrinkWithPalChange(bitmapIcon, bitmapIcon, 16, 16, 16, 16, palChangesActionAreaObjectIcon);
 T0386006:
 	dm.fillScreenBox(box, k4_ColorCyan);
@@ -739,7 +739,7 @@ Potion* MenuMan::getEmptyFlaskInHand(Champion* champ, Thing* potionThing) {
 	int16 L1266_i_SlotIndex;
 
 	for (L1266_i_SlotIndex = k2_ChampionSlotHead; --L1266_i_SlotIndex >= k0_ChampionSlotReadyHand; ) {
-		if (((L1265_T_Thing = champ->_slots[L1266_i_SlotIndex]) != Thing::_none) && (_vm->_objectMan->f33_getIconIndex(L1265_T_Thing) == k195_IconIndicePotionEmptyFlask)) {
+		if (((L1265_T_Thing = champ->_slots[L1266_i_SlotIndex]) != Thing::_none) && (_vm->_objectMan->getIconIndex(L1265_T_Thing) == k195_IconIndicePotionEmptyFlask)) {
 			*potionThing = L1265_T_Thing;
 			return (Potion*)_vm->_dungeonMan->getThingData(L1265_T_Thing);
 		}
@@ -1490,7 +1490,7 @@ T0402005: /* Check if there is another champion in front */
 			goto T0402010;
 		AL1237_ui_ActionHitProbability = G0493_auc_Graphic560_ActionHitProbability[actionIndex];
 		AL1236_ui_ActionDamageFactor = G0492_auc_Graphic560_ActionDamageFactor[actionIndex];
-		if ((_vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
+		if ((_vm->_objectMan->getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
 			setFlag(AL1237_ui_ActionHitProbability, k0x8000_hitNonMaterialCreatures);
 		}
 		_actionDamage = _vm->_groupMan->getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->getThingData(_actionTargetGroupThing), _vm->ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index fce6df3..694d135 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -116,7 +116,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 					goto T0275058_ProceedToNextThing;
 			case k3_SensorWallOrnClickWithSpecObj:
 			case k4_SensorWallOrnClickWithSpecObjRemoved:
-				L0753_B_DoNotTriggerSensor = ((L0758_i_SensorData == _vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject)) == L0755_ps_Sensor->getAttrRevertEffectA());
+				L0753_B_DoNotTriggerSensor = ((L0758_i_SensorData == _vm->_objectMan->getObjectType(L0761_T_LeaderHandObject)) == L0755_ps_Sensor->getAttrRevertEffectA());
 				if (!L0753_B_DoNotTriggerSensor && (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) {
 					if (L0763_T_LastProcessedThing == L0750_T_ThingBeingProcessed) /* If the sensor is the only one of its type on the cell */
 						break;
@@ -144,7 +144,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 					_vm->_dungeonMan->unlinkThingFromList(L0761_T_LeaderHandObject, Thing(0), mapX, mapY);
 					_vm->_championMan->putObjectInLeaderHand(L0761_T_LeaderHandObject, true);
 				} else {
-					if ((_vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (getObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData) != Thing::_none))
+					if ((_vm->_objectMan->getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (getObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData) != Thing::_none))
 						goto T0275058_ProceedToNextThing;
 					_vm->_championMan->getObjectRemovedFromLeaderHand();
 					_vm->_dungeonMan->linkThingToList(thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
@@ -161,7 +161,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 				if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */
 					goto T0275058_ProceedToNextThing;
 				L0762_T_ThingOnSquare = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
-				if ((_vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (L0762_T_ThingOnSquare == Thing::_none))
+				if ((_vm->_objectMan->getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (L0762_T_ThingOnSquare == Thing::_none))
 					goto T0275058_ProceedToNextThing;
 				_vm->_dungeonMan->unlinkThingFromList(L0762_T_ThingOnSquare, Thing(0), mapX, mapY);
 				_vm->_championMan->getObjectRemovedFromLeaderHand();
@@ -421,9 +421,9 @@ bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destM
 					AL0708_i_ScentIndex--;
 				}
 				if (AL0708_i_ScentIndex) {
-					_vm->_championMan->addScentStrength(mapX, mapY, (int)(_vm->_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime));
+					_vm->_championMan->addScentStrength(mapX, mapY, (int)(_vm->_gameTime - _vm->_projexpl->_lastPartyMovementTime));
 				}
-				_vm->_projexpl->_g362_lastPartyMovementTime = _vm->_gameTime;
+				_vm->_projexpl->_lastPartyMovementTime = _vm->_gameTime;
 				_vm->_championMan->_party._scentCount++;
 				if (_vm->_championMan->_party._event79Count_Footprints) {
 					_vm->_championMan->_party._lastScentIndex = _vm->_championMan->_party._scentCount;
@@ -612,9 +612,9 @@ T0266017_CheckProjectileImpacts:
 	while (L0697_T_Thing != Thing::_endOfList) {
 		if (((L0697_T_Thing).getType() == k14_ProjectileThingType) &&
 			(_vm->_timeline->_g370_events[(((Projectile *)_vm->_dungeonMan->_thingData[k14_ProjectileThingType])[(L0697_T_Thing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts) && (AL0699_ui_ChampionOrCreatureOrdinal = L0707_auc_ChampionOrCreatureOrdinalInCell[(L0697_T_Thing).getCell()]) &&
-			_vm->_projexpl->f217_projectileHasImpactOccurred(L0702_i_ImpactType, srcMapX, srcMapY, _vm->ordinalToIndex(AL0699_ui_ChampionOrCreatureOrdinal), L0697_T_Thing)) {
-			_vm->_projexpl->f214_projectileDeleteEvent(L0697_T_Thing);
-			if (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup) {
+			_vm->_projexpl->hasProjectileImpactOccurred(L0702_i_ImpactType, srcMapX, srcMapY, _vm->ordinalToIndex(AL0699_ui_ChampionOrCreatureOrdinal), L0697_T_Thing)) {
+			_vm->_projexpl->projectileDeleteEvent(L0697_T_Thing);
+			if (_vm->_projexpl->_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup) {
 				return true;
 			}
 			goto T0266017_CheckProjectileImpacts;
@@ -775,7 +775,7 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 
 	if (thing != Thing::_party) {
 		L0767_i_ThingType = thing.getType();
-		L0774_i_ObjectType = _vm->_objectMan->f32_getObjectType(thing);
+		L0774_i_ObjectType = _vm->_objectMan->getObjectType(thing);
 	} else {
 		L0767_i_ThingType = kM1_PartyThingType;
 		L0774_i_ObjectType = kM1_IconIndiceNone;
@@ -803,8 +803,8 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 				} else {
 					if ((L0771_ui_ThingType > k4_GroupThingType) && (L0771_ui_ThingType < k14_ProjectileThingType)) {
 						L0772_B_SquareContainsObject = true;
-						L0775_B_SquareContainsThingOfSameType |= (_vm->_objectMan->f32_getObjectType(L0766_T_Thing) == L0774_i_ObjectType);
-						L0776_B_SquareContainsThingOfDifferentType |= (_vm->_objectMan->f32_getObjectType(L0766_T_Thing) != L0774_i_ObjectType);
+						L0775_B_SquareContainsThingOfSameType |= (_vm->_objectMan->getObjectType(L0766_T_Thing) == L0774_i_ObjectType);
+						L0776_B_SquareContainsThingOfDifferentType |= (_vm->_objectMan->getObjectType(L0766_T_Thing) != L0774_i_ObjectType);
 					}
 				}
 			}
@@ -814,8 +814,8 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 		while (L0766_T_Thing != Thing::_endOfList) {
 			if ((L0770_ui_SensorTriggeredCell == (L0766_T_Thing).getCell()) && ((L0766_T_Thing).getType() > k4_GroupThingType)) {
 				L0772_B_SquareContainsObject = true;
-				L0775_B_SquareContainsThingOfSameType |= (_vm->_objectMan->f32_getObjectType(L0766_T_Thing) == L0774_i_ObjectType);
-				L0776_B_SquareContainsThingOfDifferentType |= (_vm->_objectMan->f32_getObjectType(L0766_T_Thing) != L0774_i_ObjectType);
+				L0775_B_SquareContainsThingOfSameType |= (_vm->_objectMan->getObjectType(L0766_T_Thing) == L0774_i_ObjectType);
+				L0776_B_SquareContainsThingOfDifferentType |= (_vm->_objectMan->getObjectType(L0766_T_Thing) != L0774_i_ObjectType);
 			}
 			L0766_T_Thing = _vm->_dungeonMan->getNextThing(L0766_T_Thing);
 		}
@@ -857,7 +857,7 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 					}
 					break;
 				case k4_SensorFloorObj:
-					if ((L0779_i_SensorData != _vm->_objectMan->f32_getObjectType(thing)) || L0775_B_SquareContainsThingOfSameType)
+					if ((L0779_i_SensorData != _vm->_objectMan->getObjectType(thing)) || L0775_B_SquareContainsThingOfSameType)
 						goto T0276079;
 					break;
 				case k5_SensorFloorPartyOnStairs:
@@ -893,11 +893,11 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 						goto T0276079;
 					break;
 				case k2_SensorWallOrnClickWithAnyObj:
-					if (L0775_B_SquareContainsThingOfSameType || (L0769_ps_Sensor->getData() != _vm->_objectMan->f32_getObjectType(thing)))
+					if (L0775_B_SquareContainsThingOfSameType || (L0769_ps_Sensor->getData() != _vm->_objectMan->getObjectType(thing)))
 						goto T0276079;
 					break;
 				case k3_SensorWallOrnClickWithSpecObj:
-					if (L0776_B_SquareContainsThingOfDifferentType || (L0769_ps_Sensor->getData() == _vm->_objectMan->f32_getObjectType(thing)))
+					if (L0776_B_SquareContainsThingOfDifferentType || (L0769_ps_Sensor->getData() == _vm->_objectMan->getObjectType(thing)))
 						goto T0276079;
 					break;
 				default:
@@ -943,7 +943,7 @@ bool MovesensMan::isObjcetInPartyPossession(int16 objectType) {
 			for (L0743_ui_SlotIndex = k0_ChampionSlotReadyHand; (L0743_ui_SlotIndex < k30_ChampionSlotChest_1) && !L0748_B_LeaderHandObjectProcessed; L0743_ui_SlotIndex++) {
 				L0744_T_Thing = *L0746_pT_Thing++;
 T0274003:
-				L0747_i_ObjectType = _vm->_objectMan->f32_getObjectType(L0744_T_Thing);
+				L0747_i_ObjectType = _vm->_objectMan->getObjectType(L0744_T_Thing);
 				if (L0747_i_ObjectType == objectType) {
 					return true;
 				}
@@ -951,7 +951,7 @@ T0274003:
 					L0749_ps_Container = (Container *)_vm->_dungeonMan->getThingData(L0744_T_Thing);
 					L0744_T_Thing = L0749_ps_Container->getSlot();
 					while (L0744_T_Thing != Thing::_endOfList) {
-						if (_vm->_objectMan->f32_getObjectType(L0744_T_Thing) == objectType) {
+						if (_vm->_objectMan->getObjectType(L0744_T_Thing) == objectType) {
 							return true;
 						}
 						L0744_T_Thing = _vm->_dungeonMan->getNextThing(L0744_T_Thing);
@@ -1089,7 +1089,7 @@ Thing MovesensMan::getObjectOfTypeInCell(int16 mapX, int16 mapY, int16 cell, int
 
 	L0741_T_Thing = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
 	while (L0741_T_Thing != Thing::_endOfList) {
-		if (_vm->_objectMan->f32_getObjectType(L0741_T_Thing) == objectType) {
+		if (_vm->_objectMan->getObjectType(L0741_T_Thing) == objectType) {
 			if ((cell == kM1_CellAny) || ((L0741_T_Thing.getCell()) == cell)) {
 				return L0741_T_Thing;
 			}
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 56b99fe..8bf1285 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -44,62 +44,62 @@ int16 g26_IconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIc
 
 ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {
 	/* 8 for champion hands in status boxes, 30 for champion inventory, 8 for chest */
-	_g30_slotBoxes[0] = SlotBox(4, 10, 0);    /* Champion Status Box 0 Ready Hand */
-	_g30_slotBoxes[1] = SlotBox(24, 10, 0);   /* Champion Status Box 0 Action Hand */
-	_g30_slotBoxes[2] = SlotBox(73, 10, 0);   /* Champion Status Box 1 Ready Hand */
-	_g30_slotBoxes[3] = SlotBox(93, 10, 0);   /* Champion Status Box 1 Action Hand */
-	_g30_slotBoxes[4] = SlotBox(142, 10, 0);  /* Champion Status Box 2 Ready Hand */
-	_g30_slotBoxes[5] = SlotBox(162, 10, 0);  /* Champion Status Box 2 Action Hand */
-	_g30_slotBoxes[6] = SlotBox(211, 10, 0);  /* Champion Status Box 3 Ready Hand */
-	_g30_slotBoxes[7] = SlotBox(231, 10, 0);  /* Champion Status Box 3 Action Hand */
-	_g30_slotBoxes[8] = SlotBox(6, 53, 0);    /* Ready Hand */
-	_g30_slotBoxes[9] = SlotBox(62, 53, 0);   /* Action Hand */
-	_g30_slotBoxes[10] = SlotBox(34, 26, 0);  /* Head */
-	_g30_slotBoxes[11] = SlotBox(34, 46, 0);  /* Torso */
-	_g30_slotBoxes[12] = SlotBox(34, 66, 0);  /* Legs */
-	_g30_slotBoxes[13] = SlotBox(34, 86, 0);  /* Feet */
-	_g30_slotBoxes[14] = SlotBox(6, 90, 0);   /* Pouch 2 */
-	_g30_slotBoxes[15] = SlotBox(79, 73, 0);  /* Quiver Line2 1 */
-	_g30_slotBoxes[16] = SlotBox(62, 90, 0);  /* Quiver Line1 2 */
-	_g30_slotBoxes[17] = SlotBox(79, 90, 0);  /* Quiver Line2 2 */
-	_g30_slotBoxes[18] = SlotBox(6, 33, 0);   /* Neck */
-	_g30_slotBoxes[19] = SlotBox(6, 73, 0);   /* Pouch 1 */
-	_g30_slotBoxes[20] = SlotBox(62, 73, 0);  /* Quiver Line1 1 */
-	_g30_slotBoxes[21] = SlotBox(66, 33, 0);  /* Backpack Line1 1 */
-	_g30_slotBoxes[22] = SlotBox(83, 16, 0);  /* Backpack Line2 2 */
-	_g30_slotBoxes[23] = SlotBox(100, 16, 0); /* Backpack Line2 3 */
-	_g30_slotBoxes[24] = SlotBox(117, 16, 0); /* Backpack Line2 4 */
-	_g30_slotBoxes[25] = SlotBox(134, 16, 0); /* Backpack Line2 5 */
-	_g30_slotBoxes[26] = SlotBox(151, 16, 0); /* Backpack Line2 6 */
-	_g30_slotBoxes[27] = SlotBox(168, 16, 0); /* Backpack Line2 7 */
-	_g30_slotBoxes[28] = SlotBox(185, 16, 0); /* Backpack Line2 8 */
-	_g30_slotBoxes[29] = SlotBox(202, 16, 0); /* Backpack Line2 9 */
-	_g30_slotBoxes[30] = SlotBox(83, 33, 0);  /* Backpack Line1 2 */
-	_g30_slotBoxes[31] = SlotBox(100, 33, 0); /* Backpack Line1 3 */
-	_g30_slotBoxes[32] = SlotBox(117, 33, 0); /* Backpack Line1 4 */
-	_g30_slotBoxes[33] = SlotBox(134, 33, 0); /* Backpack Line1 5 */
-	_g30_slotBoxes[34] = SlotBox(151, 33, 0); /* Backpack Line1 6 */
-	_g30_slotBoxes[35] = SlotBox(168, 33, 0); /* Backpack Line1 7 */
-	_g30_slotBoxes[36] = SlotBox(185, 33, 0); /* Backpack Line1 8 */
-	_g30_slotBoxes[37] = SlotBox(202, 33, 0); /* Backpack Line1 9 */
-	_g30_slotBoxes[38] = SlotBox(117, 59, 0); /* Chest 1 */
-	_g30_slotBoxes[39] = SlotBox(106, 76, 0); /* Chest 2 */
-	_g30_slotBoxes[40] = SlotBox(111, 93, 0); /* Chest 3 */
-	_g30_slotBoxes[41] = SlotBox(128, 98, 0); /* Chest 4 */
-	_g30_slotBoxes[42] = SlotBox(145, 101, 0); /* Chest 5 */
-	_g30_slotBoxes[43] = SlotBox(162, 103, 0); /* Chest 6 */
-	_g30_slotBoxes[44] = SlotBox(179, 104, 0); /* Chest 7 */
-	_g30_slotBoxes[45] = SlotBox(196, 105, 0); /* Chest 8 */
+	_slotBoxes[0] = SlotBox(4, 10, 0);    /* Champion Status Box 0 Ready Hand */
+	_slotBoxes[1] = SlotBox(24, 10, 0);   /* Champion Status Box 0 Action Hand */
+	_slotBoxes[2] = SlotBox(73, 10, 0);   /* Champion Status Box 1 Ready Hand */
+	_slotBoxes[3] = SlotBox(93, 10, 0);   /* Champion Status Box 1 Action Hand */
+	_slotBoxes[4] = SlotBox(142, 10, 0);  /* Champion Status Box 2 Ready Hand */
+	_slotBoxes[5] = SlotBox(162, 10, 0);  /* Champion Status Box 2 Action Hand */
+	_slotBoxes[6] = SlotBox(211, 10, 0);  /* Champion Status Box 3 Ready Hand */
+	_slotBoxes[7] = SlotBox(231, 10, 0);  /* Champion Status Box 3 Action Hand */
+	_slotBoxes[8] = SlotBox(6, 53, 0);    /* Ready Hand */
+	_slotBoxes[9] = SlotBox(62, 53, 0);   /* Action Hand */
+	_slotBoxes[10] = SlotBox(34, 26, 0);  /* Head */
+	_slotBoxes[11] = SlotBox(34, 46, 0);  /* Torso */
+	_slotBoxes[12] = SlotBox(34, 66, 0);  /* Legs */
+	_slotBoxes[13] = SlotBox(34, 86, 0);  /* Feet */
+	_slotBoxes[14] = SlotBox(6, 90, 0);   /* Pouch 2 */
+	_slotBoxes[15] = SlotBox(79, 73, 0);  /* Quiver Line2 1 */
+	_slotBoxes[16] = SlotBox(62, 90, 0);  /* Quiver Line1 2 */
+	_slotBoxes[17] = SlotBox(79, 90, 0);  /* Quiver Line2 2 */
+	_slotBoxes[18] = SlotBox(6, 33, 0);   /* Neck */
+	_slotBoxes[19] = SlotBox(6, 73, 0);   /* Pouch 1 */
+	_slotBoxes[20] = SlotBox(62, 73, 0);  /* Quiver Line1 1 */
+	_slotBoxes[21] = SlotBox(66, 33, 0);  /* Backpack Line1 1 */
+	_slotBoxes[22] = SlotBox(83, 16, 0);  /* Backpack Line2 2 */
+	_slotBoxes[23] = SlotBox(100, 16, 0); /* Backpack Line2 3 */
+	_slotBoxes[24] = SlotBox(117, 16, 0); /* Backpack Line2 4 */
+	_slotBoxes[25] = SlotBox(134, 16, 0); /* Backpack Line2 5 */
+	_slotBoxes[26] = SlotBox(151, 16, 0); /* Backpack Line2 6 */
+	_slotBoxes[27] = SlotBox(168, 16, 0); /* Backpack Line2 7 */
+	_slotBoxes[28] = SlotBox(185, 16, 0); /* Backpack Line2 8 */
+	_slotBoxes[29] = SlotBox(202, 16, 0); /* Backpack Line2 9 */
+	_slotBoxes[30] = SlotBox(83, 33, 0);  /* Backpack Line1 2 */
+	_slotBoxes[31] = SlotBox(100, 33, 0); /* Backpack Line1 3 */
+	_slotBoxes[32] = SlotBox(117, 33, 0); /* Backpack Line1 4 */
+	_slotBoxes[33] = SlotBox(134, 33, 0); /* Backpack Line1 5 */
+	_slotBoxes[34] = SlotBox(151, 33, 0); /* Backpack Line1 6 */
+	_slotBoxes[35] = SlotBox(168, 33, 0); /* Backpack Line1 7 */
+	_slotBoxes[36] = SlotBox(185, 33, 0); /* Backpack Line1 8 */
+	_slotBoxes[37] = SlotBox(202, 33, 0); /* Backpack Line1 9 */
+	_slotBoxes[38] = SlotBox(117, 59, 0); /* Chest 1 */
+	_slotBoxes[39] = SlotBox(106, 76, 0); /* Chest 2 */
+	_slotBoxes[40] = SlotBox(111, 93, 0); /* Chest 3 */
+	_slotBoxes[41] = SlotBox(128, 98, 0); /* Chest 4 */
+	_slotBoxes[42] = SlotBox(145, 101, 0); /* Chest 5 */
+	_slotBoxes[43] = SlotBox(162, 103, 0); /* Chest 6 */
+	_slotBoxes[44] = SlotBox(179, 104, 0); /* Chest 7 */
+	_slotBoxes[45] = SlotBox(196, 105, 0); /* Chest 8 */
 
 	for (uint16 i = 0; i < k199_ObjectNameCount; ++i)
-		_g352_objectNames[i] = nullptr;
+		_objectNames[i] = nullptr;
 
-	_g412_objectIconForMousePointer = nullptr;
+	_objectIconForMousePointer = nullptr;
 }
 
 ObjectMan::~ObjectMan() {
-	delete[] _g412_objectIconForMousePointer;
-	delete[] _g352_objectNames[0];
+	delete[] _objectIconForMousePointer;
+	delete[] _objectNames[0];
 }
 
 #define k556_ObjectNamesGraphicIndice 556 // @ C556_GRAPHIC_OBJECT_NAMES
@@ -107,13 +107,13 @@ ObjectMan::~ObjectMan() {
 void ObjectMan::loadObjectNames() {
 	DisplayMan &dispMan = *_vm->_displayMan;
 
-	_g412_objectIconForMousePointer = new byte[16 * 16];
+	_objectIconForMousePointer = new byte[16 * 16];
 
 	char *objectNames = new char[dispMan.getCompressedDataSize(k556_ObjectNamesGraphicIndice) + k199_ObjectNameCount];
 	Common::MemoryReadStream stream = dispMan.getCompressedData(k556_ObjectNamesGraphicIndice);
 
 	for (uint16 objNameIndex = 0; objNameIndex < k199_ObjectNameCount; ++objNameIndex) {
-		_g352_objectNames[objNameIndex] = objectNames;
+		_objectNames[objNameIndex] = objectNames;
 
 		byte tmpByte;
 		for (tmpByte = stream.readByte(); !(tmpByte & 0x80); tmpByte = stream.readByte()) // last char of object name has 7th bit on
@@ -124,7 +124,7 @@ void ObjectMan::loadObjectNames() {
 	}
 }
 
-IconIndice ObjectMan::f32_getObjectType(Thing thing) {
+IconIndice ObjectMan::getObjectType(Thing thing) {
 	if (thing == Thing::_none)
 		return kM1_IconIndiceNone;
 
@@ -137,8 +137,8 @@ IconIndice ObjectMan::f32_getObjectType(Thing thing) {
 
 byte g29_ChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType
 
-IconIndice ObjectMan::f33_getIconIndex(Thing thing) {
-	int16 L0005_i_IconIndex = f32_getObjectType(thing);
+IconIndice ObjectMan::getIconIndex(Thing thing) {
+	int16 L0005_i_IconIndex = getObjectType(thing);
 	if (L0005_i_IconIndex != kM1_IconIndiceNone) {
 		if (((L0005_i_IconIndex < k32_IconIndiceWeaponDagger) && (L0005_i_IconIndex >= k0_IconIndiceJunkCompassNorth)) ||
 			((L0005_i_IconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (L0005_i_IconIndex <= k163_IconIndicePotionWaterFlask)) ||
@@ -180,7 +180,7 @@ IconIndice ObjectMan::f33_getIconIndex(Thing thing) {
 	return (IconIndice)L0005_i_IconIndex;
 }
 
-void ObjectMan::f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
+void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 	uint16 L0011_ui_Counter;
 	byte* L0012_pl_Bitmap_Icon;
 	Box L1568_s_Box;
@@ -199,7 +199,7 @@ void ObjectMan::f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 	_vm->_displayMan->blitToBitmap(L0012_pl_Bitmap_Icon, destBitmap, L1568_s_Box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, kM1_ColorNoTransparency, gK77_IconGraphicHeight[L0011_ui_Counter], 16);
 }
 
-void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
+void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 	uint16 L0015_ui_IconGraphicIndex;
 	int16 L0016_i_ByteWidth;
 	SlotBox* L0017_ps_SlotBox;
@@ -208,7 +208,7 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 	byte* L0020_puc_Bitmap_Destination;
 	int16 L1569_i_Width;
 
-	L0017_ps_SlotBox = &_g30_slotBoxes[slotBoxIndex];
+	L0017_ps_SlotBox = &_slotBoxes[slotBoxIndex];
 	if ((L0017_ps_SlotBox->_iconIndex = iconIndex) == kM1_IconIndiceNone) {
 		return;
 	}
@@ -235,9 +235,9 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 
 #define k14_ObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH
 
-void ObjectMan::f34_drawLeaderObjectName(Thing thing) {
+void ObjectMan::drawLeaderObjectName(Thing thing) {
 	char* objectName = nullptr;
-	int16 L0007_i_IconIndex = f33_getIconIndex(thing);
+	int16 L0007_i_IconIndex = getIconIndex(thing);
 	if (L0007_i_IconIndex == k147_IconIndiceJunkChampionBones) {
 		Junk *junk = (Junk*)_vm->_dungeonMan->getThingData(thing);
 		char champBonesName[16];
@@ -247,37 +247,37 @@ void ObjectMan::f34_drawLeaderObjectName(Thing thing) {
 		case Common::EN_ANY:
 		case Common::DE_DEU: // english and german version are the same
 			strcpy(champBonesName, _vm->_championMan->_champions[junk->getChargeCount()]._name);
-			strcat(champBonesName, _g352_objectNames[L0007_i_IconIndex]);
+			strcat(champBonesName, _objectNames[L0007_i_IconIndex]);
 			break;
 		case Common::FR_FRA:
-			strcat(champBonesName, _g352_objectNames[L0007_i_IconIndex]);
+			strcat(champBonesName, _objectNames[L0007_i_IconIndex]);
 			strcpy(champBonesName, _vm->_championMan->_champions[junk->getChargeCount()]._name);
 			break;
 		}
 
 		objectName = champBonesName;
 	} else {
-		objectName = _g352_objectNames[L0007_i_IconIndex];
+		objectName = _objectNames[L0007_i_IconIndex];
 	}
 	_vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, 233, 37, k4_ColorCyan, k0_ColorBlack, objectName, k14_ObjectNameMaximumLength, k200_heightScreen);
 }
 
-IconIndice ObjectMan::f39_getIconIndexInSlotBox(uint16 slotBoxIndex) {
-	return (IconIndice)_g30_slotBoxes[slotBoxIndex]._iconIndex;
+IconIndice ObjectMan::getIconIndexInSlotBox(uint16 slotBoxIndex) {
+	return (IconIndice)_slotBoxes[slotBoxIndex]._iconIndex;
 }
 
-void ObjectMan::f35_clearLeaderObjectName() {
+void ObjectMan::clearLeaderObjectName() {
 	static Box g28_BoxLeaderHandObjectName(233, 319, 33, 38); // @ G0028_s_Graphic562_Box_LeaderHandObjectName 
 	_vm->_displayMan->fillScreenBox(g28_BoxLeaderHandObjectName, k0_ColorBlack);
 }
 
-void ObjectMan::f37_drawIconToScreen(int16 iconIndex, int16 posX, int16 posY) {
+void ObjectMan::drawIconToScreen(int16 iconIndex, int16 posX, int16 posY) {
 	static byte L0013_puc_Bitmap_Icon[16 * 16];
 	Box L0014_s_Box;
 
 	L0014_s_Box._x2 = (L0014_s_Box._x1 = posX) + 15;
 	L0014_s_Box._y2 = (L0014_s_Box._y1 = posY) + 15;
-	f36_extractIconFromBitmap(iconIndex, L0013_puc_Bitmap_Icon);
+	extractIconFromBitmap(iconIndex, L0013_puc_Bitmap_Icon);
 	_vm->_displayMan->blitToScreen(L0013_puc_Bitmap_Icon, &L0014_s_Box, k8_byteWidth, kM1_ColorNoTransparency, 16);
 }
 }
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index 1aa4c54..4478bab 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -54,18 +54,18 @@ public:
 	~ObjectMan();
 	void loadObjectNames();	// @ F0031_OBJECT_LoadNames
 
-	SlotBox _g30_slotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes;
-	char *_g352_objectNames[k199_ObjectNameCount]; // @ G0352_apc_ObjectNames
-	byte *_g412_objectIconForMousePointer; // @ G0412_puc_Bitmap_ObjectIconForMousePointer
+	SlotBox _slotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes;
+	char *_objectNames[k199_ObjectNameCount]; // @ G0352_apc_ObjectNames
+	byte *_objectIconForMousePointer; // @ G0412_puc_Bitmap_ObjectIconForMousePointer
 
-	IconIndice f32_getObjectType(Thing thing); // @ F0032_OBJECT_GetType
-	IconIndice f33_getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
-	void f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // @ F0036_OBJECT_ExtractIconFromBitmap
-	void f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox
-	void f34_drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName
-	IconIndice f39_getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox
-	void f35_clearLeaderObjectName(); // @ F0035_OBJECT_ClearLeaderHandObjectName
-	void f37_drawIconToScreen(int16 iconIndex, int16 posX, int16 posY); // @ F0037_OBJECT_DrawIconToScreen
+	IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType
+	IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
+	void extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // @ F0036_OBJECT_ExtractIconFromBitmap
+	void drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox
+	void drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName
+	IconIndice getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox
+	void clearLeaderObjectName(); // @ F0035_OBJECT_ClearLeaderHandObjectName
+	void drawIconToScreen(int16 iconIndex, int16 posX, int16 posY); // @ F0037_OBJECT_DrawIconToScreen
 };
 
 }
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 591f17f..aab6e7c 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -37,16 +37,16 @@
 namespace DM {
 
 ProjExpl::ProjExpl(DMEngine* vm) : _vm(vm) {
-	_g364_creatureDamageOutcome = 0;
-	_g363_secondaryDirToOrFromParty = 0;
-	_g361_lastCreatureAttackTime = -200;
-	_g365_createLanucherProjectile = false;
-	_g366_projectilePoisonAttack = 0;
-	_g367_projectileAttackType = 0;
-	_g362_lastPartyMovementTime = 0;
+	_creatureDamageOutcome = 0;
+	_secondaryDirToOrFromParty = 0;
+	_lastCreatureAttackTime = -200;
+	_createLauncherProjectile = false;
+	_projectilePoisonAttack = 0;
+	_projectileAttackType = 0;
+	_lastPartyMovementTime = 0;
 }
 
-void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, Direction dir, byte kineticEnergy, byte attack, byte stepEnergy) {
+void ProjExpl::createProjectile(Thing thing, int16 mapX, int16 mapY, uint16 cell, Direction dir, byte kineticEnergy, byte attack, byte stepEnergy) {
 	Thing L0466_T_ProjectileThing;
 	Projectile* L0467_ps_Projectile;
 	TimelineEvent L0468_s_Event;
@@ -62,7 +62,7 @@ void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16
 	L0467_ps_Projectile->_attack = attack;
 	_vm->_dungeonMan->linkThingToList(L0466_T_ProjectileThing, Thing(0), mapX, mapY); /* Projectiles are added on the square and not 'moved' onto the square. In the case of a projectile launcher sensor, this means that the new projectile traverses the square in front of the launcher without any trouble: there is no impact if it is a wall, the projectile direction is not changed if it is a teleporter. Impacts with creatures and champions are still processed */
 	setMapAndTime(L0468_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + 1);
-	if (_g365_createLanucherProjectile) {
+	if (_createLauncherProjectile) {
 		L0468_s_Event._type = k49_TMEventTypeMoveProjectile; /* Launcher projectiles can impact immediately */
 	} else {
 		L0468_s_Event._type = k48_TMEventTypeMoveProjectileIgnoreImpacts; /* Projectiles created by champions or creatures ignore impacts on their first movement */
@@ -76,7 +76,7 @@ void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16
 	L0467_ps_Projectile->_eventIndex = _vm->_timeline->f238_addEventGetEventIndex(&L0468_s_Event);
 }
 
-bool ProjExpl::f217_projectileHasImpactOccurred(int16 impactType, int16 mapXCombo, int16 mapYCombo, int16 cell, Thing projectileThing) {
+bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, int16 mapYCombo, int16 cell, Thing projectileThing) {
 #define AP0454_i_ProjectileTargetMapX mapXCombo
 #define AP0455_i_ProjectileTargetMapY mapYCombo
 #define AP0456_i_ChampionIndex cell
@@ -116,7 +116,7 @@ bool ProjExpl::f217_projectileHasImpactOccurred(int16 impactType, int16 mapXComb
 	L0501_i_MapXCombo = mapXCombo;
 	L0502_i_MapYCombo = mapYCombo;
 	L0509_B_RemovePotion = false;
-	_g364_creatureDamageOutcome = k0_outcomeKilledNoCreaturesInGroup;
+	_creatureDamageOutcome = k0_outcomeKilledNoCreaturesInGroup;
 	if ((L0510_i_ProjectileAssociatedThingType = (L0486_T_ProjectileAssociatedThing = L0490_ps_Projectile->_slot).getType()) == k8_PotionThingType) {
 		L0491_ps_Group = (Group *)_vm->_dungeonMan->getThingData(L0486_T_ProjectileAssociatedThing);
 		switch (((Potion *)L0491_ps_Group)->getType()) {
@@ -164,19 +164,19 @@ T0217004:
 			 ((L0490_ps_Projectile->_attack > _vm->getRandomNumber(128)) &&
 			  getFlag(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(L0486_T_ProjectileAssociatedThing)].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)
 			  && ((L0510_i_ProjectileAssociatedThingType != k10_JunkThingType) ||
-			  ((AL0487_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0486_T_ProjectileAssociatedThing)) < 0) ||
+			  ((AL0487_i_IconIndex = _vm->_objectMan->getIconIndex(L0486_T_ProjectileAssociatedThing)) < 0) ||
 				  (!((AL0487_i_IconIndex >= k176_IconIndiceJunkIronKey) && (AL0487_i_IconIndex <= k191_IconIndiceJunkMasterKey))))
 			  )))) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
 			return false;
 		}
-		L0488_i_Attack = f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing) + 1;
+		L0488_i_Attack = getProjectileImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing) + 1;
 		_vm->_groupMan->groupIsDoorDestoryedByAttack(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, L0488_i_Attack + _vm->getRandomNumber(L0488_i_Attack), false, 0);
 		break;
 	case kM2_ChampionElemType:
 		if ((AP0456_i_ChampionIndex = _vm->_championMan->getIndexInCell(cell)) < 0) {
 			return false;
 		}
-		L0489_i_ChampionAttack = L0488_i_Attack = f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing);
+		L0489_i_ChampionAttack = L0488_i_Attack = getProjectileImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing);
 		break;
 	case kM1_CreatureElemType:
 		L0491_ps_Group = (Group *)_vm->_dungeonMan->getThingData(_vm->_groupMan->groupGetThing(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY));
@@ -187,18 +187,18 @@ T0217004:
 		L0493_ps_CreatureInfo = &g243_CreatureInfo[L0511_ui_CreatureType = L0491_ps_Group->_type];
 		if ((L0486_T_ProjectileAssociatedThing == Thing::_explFireBall) && (L0511_ui_CreatureType == k11_CreatureTypeBlackFlame)) {
 			L0496_pui_CreatureHealth = &L0491_ps_Group->_health[L0512_ui_CreatureIndex];
-			*L0496_pui_CreatureHealth = MIN(1000, *L0496_pui_CreatureHealth + f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing));
+			*L0496_pui_CreatureHealth = MIN(1000, *L0496_pui_CreatureHealth + getProjectileImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing));
 			goto T0217044;
 		}
 		if (getFlag(L0493_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) && (L0486_T_ProjectileAssociatedThing != Thing::_explHarmNonMaterial)) {
 			return false;
 		}
-		L0488_i_Attack = (uint16)((unsigned long)f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing) << 6) / L0493_ps_CreatureInfo->_defense;
+		L0488_i_Attack = (uint16)((unsigned long)getProjectileImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing) << 6) / L0493_ps_CreatureInfo->_defense;
 		if (L0488_i_Attack) {
-			if ((AL0487_i_Outcome = _vm->_groupMan->groupGetDamageCreatureOutcome(L0491_ps_Group, L0512_ui_CreatureIndex, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, L0488_i_Attack + _vm->_groupMan->groupGetResistanceAdjustedPoisonAttack(L0511_ui_CreatureType, _g366_projectilePoisonAttack), true)) != k0_outcomeKilledNoCreaturesInGroup) {
+			if ((AL0487_i_Outcome = _vm->_groupMan->groupGetDamageCreatureOutcome(L0491_ps_Group, L0512_ui_CreatureIndex, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, L0488_i_Attack + _vm->_groupMan->groupGetResistanceAdjustedPoisonAttack(L0511_ui_CreatureType, _projectilePoisonAttack), true)) != k0_outcomeKilledNoCreaturesInGroup) {
 				_vm->_groupMan->processEvents29to41(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, kM2_TMEventTypeCreateReactionEvent30HitByProjectile, 0);
 			}
-			_g364_creatureDamageOutcome = AL0487_i_Outcome;
+			_creatureDamageOutcome = AL0487_i_Outcome;
 			if (!L0505_B_CreateExplosionOnImpact &&
 				(AL0487_i_Outcome == k0_outcomeKilledNoCreaturesInGroup) &&
 				(L0510_i_ProjectileAssociatedThingType == k5_WeaponThingType) &&
@@ -211,8 +211,8 @@ T0217004:
 			}
 		}
 	}
-	if (L0489_i_ChampionAttack && _vm->_championMan->addPendingDamageAndWounds_getDamage(AP0456_i_ChampionIndex, L0488_i_Attack, k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso, _g367_projectileAttackType) && _g366_projectilePoisonAttack && _vm->getRandomNumber(2)) {
-		_vm->_championMan->championPoison(AP0456_i_ChampionIndex, _g366_projectilePoisonAttack);
+	if (L0489_i_ChampionAttack && _vm->_championMan->addPendingDamageAndWounds_getDamage(AP0456_i_ChampionIndex, L0488_i_Attack, k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso, _projectileAttackType) && _projectilePoisonAttack && _vm->getRandomNumber(2)) {
+		_vm->_championMan->championPoison(AP0456_i_ChampionIndex, _projectilePoisonAttack);
 	}
 	if (L0505_B_CreateExplosionOnImpact || L0509_B_RemovePotion
 		) {
@@ -224,7 +224,7 @@ T0217004:
 		}
 		if ((L0486_T_ProjectileAssociatedThing == Thing::_explLightningBolt) && !(AL0507_ui_ExplosionAttack >>= 1))
 			goto T0217044;
-		f213_explosionCreate(L0486_T_ProjectileAssociatedThing, AL0507_ui_ExplosionAttack, L0501_i_MapXCombo, L0502_i_MapYCombo, (L0486_T_ProjectileAssociatedThing == Thing::_explPoisonCloud) ? k255_CreatureTypeSingleCenteredCreature : cell);
+		createExplosion(L0486_T_ProjectileAssociatedThing, AL0507_ui_ExplosionAttack, L0501_i_MapXCombo, L0502_i_MapYCombo, (L0486_T_ProjectileAssociatedThing == Thing::_explPoisonCloud) ? k255_CreatureTypeSingleCenteredCreature : cell);
 	} else {
 		if ((L0486_T_ProjectileAssociatedThing).getType() == k5_WeaponThingType) {
 			AL0507_ui_SoundIndex = k00_soundMETALLIC_THUD;
@@ -243,11 +243,11 @@ T0217044:
 		L0490_ps_Projectile->_slot = L0498_T_ExplosionThing;
 	}
 	_vm->_dungeonMan->unlinkThingFromList(projectileThing, Thing(0), L0499_i_ProjectileMapX, L0500_i_ProjectileMapY);
-	f215_projectileDelete(projectileThing, L0497_pT_GroupSlot, L0499_i_ProjectileMapX, L0500_i_ProjectileMapY);
+	projectileDelete(projectileThing, L0497_pT_GroupSlot, L0499_i_ProjectileMapX, L0500_i_ProjectileMapY);
 	return true;
 }
 
-uint16 ProjExpl::f216_projectileGetImpactAttack(Projectile* projectile, Thing thing) {
+uint16 ProjExpl::getProjectileImpactAttack(Projectile* projectile, Thing thing) {
 	WeaponInfo* L0485_ps_WeaponInfo;
 	uint16 L0483_ui_Multiple;
 #define AL0483_ui_ThingType L0483_ui_Multiple
@@ -255,15 +255,15 @@ uint16 ProjExpl::f216_projectileGetImpactAttack(Projectile* projectile, Thing th
 	uint16 L0484_ui_KineticEnergy;
 
 
-	_g366_projectilePoisonAttack = 0;
-	_g367_projectileAttackType = k3_attackType_BLUNT;
+	_projectilePoisonAttack = 0;
+	_projectileAttackType = k3_attackType_BLUNT;
 
 	L0484_ui_KineticEnergy = projectile->_kineticEnergy;
 	if ((AL0483_ui_ThingType = thing.getType()) != k15_ExplosionThingType) {
 		if (AL0483_ui_ThingType == k5_WeaponThingType) {
 			L0485_ps_WeaponInfo = _vm->_dungeonMan->getWeaponInfo(thing);
 			AL0483_ui_Attack = L0485_ps_WeaponInfo->_kineticEnergy;
-			_g367_projectileAttackType = k3_attackType_BLUNT;
+			_projectileAttackType = k3_attackType_BLUNT;
 		} else {
 			AL0483_ui_Attack = _vm->getRandomNumber(4);
 		}
@@ -271,21 +271,21 @@ uint16 ProjExpl::f216_projectileGetImpactAttack(Projectile* projectile, Thing th
 	} else {
 		if (thing == Thing::_explSlime) {
 			AL0483_ui_Attack = _vm->getRandomNumber(16);
-			_g366_projectilePoisonAttack = AL0483_ui_Attack + 10;
+			_projectilePoisonAttack = AL0483_ui_Attack + 10;
 			AL0483_ui_Attack += _vm->getRandomNumber(32);
 		} else {
 			if (thing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) {
-				_g367_projectileAttackType = k5_attackType_MAGIC;
+				_projectileAttackType = k5_attackType_MAGIC;
 				if (thing == Thing::_explPoisonBolt) {
-					_g366_projectilePoisonAttack = L0484_ui_KineticEnergy;
+					_projectilePoisonAttack = L0484_ui_KineticEnergy;
 					return 1;
 				}
 				return 0;
 			}
-			_g367_projectileAttackType = k1_attackType_FIRE;
+			_projectileAttackType = k1_attackType_FIRE;
 			AL0483_ui_Attack = _vm->getRandomNumber(16) + _vm->getRandomNumber(16) + 10;
 			if (thing == Thing::_explLightningBolt) {
-				_g367_projectileAttackType = k7_attackType_LIGHTNING;
+				_projectileAttackType = k7_attackType_LIGHTNING;
 				AL0483_ui_Attack *= 5;
 			}
 		}
@@ -296,7 +296,7 @@ uint16 ProjExpl::f216_projectileGetImpactAttack(Projectile* projectile, Thing th
 	return AL0483_ui_Attack;
 }
 
-void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXCombo, uint16 mapYCombo, uint16 cell) {
+void ProjExpl::createExplosion(Thing explThing, uint16 attack, uint16 mapXCombo, uint16 mapYCombo, uint16 cell) {
 #define AP0443_ui_ProjectileMapX mapXCombo
 #define AP0444_ui_ProjectileMapY mapYCombo
 	Thing L0473_T_Thing = _vm->_dungeonMan->getUnusedThing(k15_ExplosionThingType);
@@ -359,7 +359,7 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 							attack >>= 2;
 						}
 						if ((attack -= _vm->getRandomNumber((L0469_i_CreatureFireResistance << 1) + 1)) > 0) {
-							_g364_creatureDamageOutcome = _vm->_groupMan->getDamageAllCreaturesOutcome(L0472_ps_Group, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, attack, true);
+							_creatureDamageOutcome = _vm->_groupMan->getDamageAllCreaturesOutcome(L0472_ps_Group, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, attack, true);
 						}
 					}
 				}
@@ -368,22 +368,22 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC
 	}
 }
 
-int16 ProjExpl::f218_projectileGetImpactCount(int16 impactType, int16 mapX, int16 mapY, int16 cell) {
+int16 ProjExpl::projectileGetImpactCount(int16 impactType, int16 mapX, int16 mapY, int16 cell) {
 	Thing L0513_T_Thing;
 	int16 L0514_i_ImpactCount;
 
 
 	L0514_i_ImpactCount = 0;
-	_g364_creatureDamageOutcome = k0_outcomeKilledNoCreaturesInGroup;
+	_creatureDamageOutcome = k0_outcomeKilledNoCreaturesInGroup;
 T0218001:
 	L0513_T_Thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
 	while (L0513_T_Thing != Thing::_endOfList) {
 		if (((L0513_T_Thing).getType() == k14_ProjectileThingType) &&
 			((L0513_T_Thing).getCell() == cell) &&
-			f217_projectileHasImpactOccurred(impactType, mapX, mapY, cell, L0513_T_Thing)) {
-			f214_projectileDeleteEvent(L0513_T_Thing);
+			hasProjectileImpactOccurred(impactType, mapX, mapY, cell, L0513_T_Thing)) {
+			projectileDeleteEvent(L0513_T_Thing);
 			L0514_i_ImpactCount++;
-			if ((impactType == kM1_CreatureElemType) && (_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup))
+			if ((impactType == kM1_CreatureElemType) && (_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup))
 				break;
 			goto T0218001;
 		}
@@ -392,7 +392,7 @@ T0218001:
 	return L0514_i_ImpactCount;
 }
 
-void ProjExpl::f214_projectileDeleteEvent(Thing thing) {
+void ProjExpl::projectileDeleteEvent(Thing thing) {
 	Projectile* L0477_ps_Projectile;
 
 
@@ -400,7 +400,7 @@ void ProjExpl::f214_projectileDeleteEvent(Thing thing) {
 	_vm->_timeline->f237_deleteEvent(L0477_ps_Projectile->_eventIndex);
 }
 
-void ProjExpl::f215_projectileDelete(Thing projectileThing, Thing* groupSlot, int16 mapX, int16 mapY) {
+void ProjExpl::projectileDelete(Thing projectileThing, Thing* groupSlot, int16 mapX, int16 mapY) {
 	Projectile *L0480_ps_Projectile = (Projectile *)_vm->_dungeonMan->getThingData(projectileThing);
 	Thing L0479_T_Thing = L0480_ps_Projectile->_slot;
 	if (L0479_T_Thing.getType() != k15_ExplosionThingType) {
@@ -420,7 +420,7 @@ void ProjExpl::f215_projectileDelete(Thing projectileThing, Thing* groupSlot, in
 	L0480_ps_Projectile->_nextThing = Thing::_none;
 }
 
-void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
+void ProjExpl::processEvents48To49(TimelineEvent* event) {
 	TimelineEvent* L0519_ps_Event;
 	Projectile* L0520_ps_Projectile;
 	Thing L0515_T_ProjectileThingNewCell;
@@ -447,15 +447,15 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 		L0519_ps_Event->_type = k49_TMEventTypeMoveProjectile;
 	} else {
 		L0518_ui_Cell = (L0515_T_ProjectileThingNewCell).getCell();
-		if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0523_i_DestinationMapX == _vm->_dungeonMan->_partyMapX) && (L0524_i_DestinationMapY == _vm->_dungeonMan->_partyMapY) && f217_projectileHasImpactOccurred(kM2_ChampionElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
+		if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0523_i_DestinationMapX == _vm->_dungeonMan->_partyMapX) && (L0524_i_DestinationMapY == _vm->_dungeonMan->_partyMapY) && hasProjectileImpactOccurred(kM2_ChampionElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
 			return;
 		}
-		if ((_vm->_groupMan->groupGetThing(L0523_i_DestinationMapX, L0524_i_DestinationMapY) != Thing::_endOfList) && f217_projectileHasImpactOccurred(kM1_CreatureElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
+		if ((_vm->_groupMan->groupGetThing(L0523_i_DestinationMapX, L0524_i_DestinationMapY) != Thing::_endOfList) && hasProjectileImpactOccurred(kM1_CreatureElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
 			return;
 		}
 		if (L0520_ps_Projectile->_kineticEnergy <= (AL0516_ui_StepEnergy = L0519_ps_Event->_C._projectile.getStepEnergy())) {
 			_vm->_dungeonMan->unlinkThingFromList(L0515_T_ProjectileThingNewCell = L0521_T_ProjectileThing, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
-			f215_projectileDelete(L0515_T_ProjectileThingNewCell, NULL, L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+			projectileDelete(L0515_T_ProjectileThingNewCell, NULL, L0523_i_DestinationMapX, L0524_i_DestinationMapY);
 			return;
 		}
 		L0520_ps_Projectile->_kineticEnergy -= AL0516_ui_StepEnergy;
@@ -477,7 +477,7 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 		if ((Square(AL0516_ui_Square).getType() == k0_WallElemType) ||
 			((Square(AL0516_ui_Square).getType() == k6_FakeWallElemType) && !getFlag(AL0516_ui_Square, (k0x0001_FakeWallImaginary | k0x0004_FakeWallOpen))) ||
 			((Square(AL0516_ui_Square).getType() == k3_StairsElemType) && (Square(_vm->_dungeonMan->_currMapData[L0525_i_SourceMapX][L0526_i_SourceMapY]).getType() == k3_StairsElemType))) {
-			if (f217_projectileHasImpactOccurred(Square(AL0516_ui_Square).getType(), L0525_i_SourceMapX, L0526_i_SourceMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
+			if (hasProjectileImpactOccurred(Square(AL0516_ui_Square).getType(), L0525_i_SourceMapX, L0526_i_SourceMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
 				return;
 			}
 		}
@@ -496,7 +496,7 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 		L0515_T_ProjectileThingNewCell = thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_moveSens->_moveResultCell);
 		M31_setMap(L0519_ps_Event->_mapTime, _vm->_moveSens->_moveResultMapIndex);
 	} else {
-		if ((Square(_vm->_dungeonMan->getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY)).getType() == k4_DoorElemType) && f217_projectileHasImpactOccurred(k4_DoorElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
+		if ((Square(_vm->_dungeonMan->getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY)).getType() == k4_DoorElemType) && hasProjectileImpactOccurred(k4_DoorElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
 			return;
 		}
 		_vm->_dungeonMan->unlinkThingFromList(L0515_T_ProjectileThingNewCell, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
@@ -511,7 +511,7 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
 	L0520_ps_Projectile->_eventIndex = _vm->_timeline->f238_addEventGetEventIndex(L0519_ps_Event);
 }
 
-void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) {
+void ProjExpl::processEvent25(TimelineEvent* event) {
 	Explosion* L0532_ps_Explosion;
 	Group* L0533_ps_Group = nullptr;
 	CreatureInfo* L0534_ps_CreatureInfo = nullptr;
diff --git a/engines/dm/projexpl.h b/engines/dm/projexpl.h
index 0d6f3b6..1621e31 100644
--- a/engines/dm/projexpl.h
+++ b/engines/dm/projexpl.h
@@ -80,26 +80,28 @@ class Projectile;
 class ProjExpl {
 	DMEngine *_vm;
 public:
-	int16 _g364_creatureDamageOutcome; // @ G0364_i_CreatureDamageOutcome
-	int16 _g363_secondaryDirToOrFromParty; // @ G0363_i_SecondaryDirectionToOrFromParty
-	int32 _g361_lastCreatureAttackTime; // @ G0361_l_LastCreatureAttackTime
-	bool _g365_createLanucherProjectile; // @ G0365_B_CreateLauncherProjectile
-	int16 _g366_projectilePoisonAttack; // @ G0366_i_ProjectilePoisonAttack
-	int16 _g367_projectileAttackType; // @ G0367_i_ProjectileAttackType
-	int32 _g362_lastPartyMovementTime; // @ G0362_l_LastPartyMovementTime
+	int16 _creatureDamageOutcome; // @ G0364_i_CreatureDamageOutcome
+	int16 _secondaryDirToOrFromParty; // @ G0363_i_SecondaryDirectionToOrFromParty
+	int32 _lastCreatureAttackTime; // @ G0361_l_LastCreatureAttackTime
+	bool _createLauncherProjectile; // @ G0365_B_CreateLauncherProjectile
+	int16 _projectilePoisonAttack; // @ G0366_i_ProjectilePoisonAttack
+	int16 _projectileAttackType; // @ G0367_i_ProjectileAttackType
+	int32 _lastPartyMovementTime; // @ G0362_l_LastPartyMovementTime
+
 	explicit ProjExpl(DMEngine *vm);
-	void f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, Direction dir,
+
+	void createProjectile(Thing thing, int16 mapX, int16 mapY, uint16 cell, Direction dir,
 							   byte kineticEnergy, byte attack, byte stepEnergy); // @ F0212_PROJECTILE_Create
-	bool f217_projectileHasImpactOccurred(int16 impactType, int16 mapXCombo, int16 mapYCombo,
+	bool hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, int16 mapYCombo,
 										  int16 cell, Thing projectileThing); // @ F0217_PROJECTILE_HasImpactOccured
-	uint16 f216_projectileGetImpactAttack(Projectile *projectile, Thing thing); // @ F0216_PROJECTILE_GetImpactAttack
-	void f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXCombo,
+	uint16 getProjectileImpactAttack(Projectile *projectile, Thing thing); // @ F0216_PROJECTILE_GetImpactAttack
+	void createExplosion(Thing explThing, uint16 attack, uint16 mapXCombo,
 							  uint16 mapYCombo, uint16 cell); // @ F0213_EXPLOSION_Create
-	int16 f218_projectileGetImpactCount(int16 impactType, int16 mapX, int16 mapY, int16 cell); // @ F0218_PROJECTILE_GetImpactCount
-	void f214_projectileDeleteEvent(Thing thing); // @ F0214_PROJECTILE_DeleteEvent
-	void f215_projectileDelete(Thing projectileThing, Thing *groupSlot, int16 mapX, int16 mapY); // @ F0215_PROJECTILE_Delete
-	void f219_processEvents48To49_projectile(TimelineEvent *event); // @ F0219_PROJECTILE_ProcessEvents48To49_Projectile
-	void f220_explosionProcessEvent25_explosion(TimelineEvent *event); // @ F0220_EXPLOSION_ProcessEvent25_Explosion
+	int16 projectileGetImpactCount(int16 impactType, int16 mapX, int16 mapY, int16 cell); // @ F0218_PROJECTILE_GetImpactCount
+	void projectileDeleteEvent(Thing thing); // @ F0214_PROJECTILE_DeleteEvent
+	void projectileDelete(Thing projectileThing, Thing *groupSlot, int16 mapX, int16 mapY); // @ F0215_PROJECTILE_Delete
+	void processEvents48To49(TimelineEvent *event); // @ F0219_PROJECTILE_ProcessEvents48To49_Projectile
+	void processEvent25(TimelineEvent *event); // @ F0220_EXPLOSION_ProcessEvent25_Explosion
 };
 
 }
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 002b7a6..2fd2eb9 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -282,13 +282,13 @@ void Timeline::f261_processTimeline() {
 			switch (AL0680_ui_EventType) {
 			case k48_TMEventTypeMoveProjectileIgnoreImpacts:
 			case k49_TMEventTypeMoveProjectile:
-				_vm->_projexpl->f219_processEvents48To49_projectile(L0681_ps_Event);
+				_vm->_projexpl->processEvents48To49(L0681_ps_Event);
 				break;
 			case k1_TMEventTypeDoorAnimation:
 				f241_timelineProcessEvent1_doorAnimation(L0681_ps_Event);
 				break;
 			case k25_TMEventTypeExplosion:
-				_vm->_projexpl->f220_explosionProcessEvent25_explosion(L0681_ps_Event);
+				_vm->_projexpl->processEvent25(L0681_ps_Event);
 				break;
 			case k7_TMEventTypeFakeWall:
 				f242_timelineProcessEvent7_squareFakewall(L0681_ps_Event);
@@ -784,12 +784,12 @@ void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* eve
 		L0628_ui_ProjectileCell = normalizeModulo4(L0628_ui_ProjectileCell + _vm->getRandomNumber(2));
 	}
 	L0626_i_MapX += _vm->_dirIntoStepCountEast[L0624_ui_Cell], L0627_i_MapY += _vm->_dirIntoStepCountNorth[L0624_ui_Cell]; /* BUG0_20 The game crashes if the launcher sensor is on a map boundary and shoots in a direction outside the map */
-	_vm->_projexpl->_g365_createLanucherProjectile = true;
-	_vm->_projexpl->f212_projectileCreate(L0622_T_FirstProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, L0628_ui_ProjectileCell, (Direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy);
+	_vm->_projexpl->_createLauncherProjectile = true;
+	_vm->_projexpl->createProjectile(L0622_T_FirstProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, L0628_ui_ProjectileCell, (Direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy);
 	if (!L0632_B_LaunchSingleProjectile) {
-		_vm->_projexpl->f212_projectileCreate(L0623_T_SecondProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, returnNextVal(L0628_ui_ProjectileCell), (Direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy);
+		_vm->_projexpl->createProjectile(L0623_T_SecondProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, returnNextVal(L0628_ui_ProjectileCell), (Direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy);
 	}
-	_vm->_projexpl->_g365_createLanucherProjectile = false;
+	_vm->_projexpl->_createLauncherProjectile = false;
 }
 
 void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
@@ -1063,7 +1063,7 @@ void Timeline::f255_timelineProcessEvent13_ViAltarRebirth(TimelineEvent* event)
 	L0671_ui_ChampionIndex = event->_priority;
 	switch (L0670_ui_Step = event->_C.A._effect) { /* Rebirth is a 3 steps process (Step 2 -> Step 1 -> Step 0). Step is stored in the Effect value of the event */
 	case 2:
-		_vm->_projexpl->f213_explosionCreate(Thing::_explRebirthStep1, 0, L0664_i_MapX, L0665_i_MapY, L0666_ui_Cell);
+		_vm->_projexpl->createExplosion(Thing::_explRebirthStep1, 0, L0664_i_MapX, L0665_i_MapY, L0666_ui_Cell);
 		event->_mapTime += 5;
 T0255002:
 		L0670_ui_Step--;
@@ -1074,7 +1074,7 @@ T0255002:
 		L0667_T_Thing = _vm->_dungeonMan->getSquareFirstThing(L0664_i_MapX, L0665_i_MapY);
 		while (L0667_T_Thing != Thing::_endOfList) {
 			if ((L0667_T_Thing.getCell() == L0666_ui_Cell) && (L0667_T_Thing.getType() == k10_JunkThingType)) {
-				L0669_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0667_T_Thing);
+				L0669_i_IconIndex = _vm->_objectMan->getIconIndex(L0667_T_Thing);
 				if (L0669_i_IconIndex == k147_IconIndiceJunkChampionBones) {
 					L0668_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L0667_T_Thing);
 					if (L0668_ps_Junk->getChargeCount() == L0671_ui_ChampionIndex) {


Commit: 42fea91d5de21501632b660adbec8fdbae461cf3
    https://github.com/scummvm/scummvm/commit/42fea91d5de21501632b660adbec8fdbae461cf3
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Finish the renaming of class members

Changed paths:
    engines/dm/champion.cpp
    engines/dm/dialog.cpp
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/objectman.cpp
    engines/dm/projexpl.cpp
    engines/dm/sounds.cpp
    engines/dm/sounds.h
    engines/dm/text.cpp
    engines/dm/text.h
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 6d9c579..cebd00f 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -217,7 +217,7 @@ bool ChampionMan::isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side)
 			return false;
 	}
 
-	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
+	_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 	decrementStamina(champIndex, getThrowingStaminaCost(curThing));
 	disableAction(champIndex, 4);
 	int16 experience = 8;
@@ -263,10 +263,10 @@ int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) {
 
 void ChampionMan::drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) {
 	Common::String tmp = getStringFromInteger(currVal, true, 3);
-	_vm->_textMan->f52_printToViewport(55, posY, k13_ColorLightestGray, tmp.c_str());
-	_vm->_textMan->f52_printToViewport(73, posY, k13_ColorLightestGray, "/");
+	_vm->_textMan->printToViewport(55, posY, k13_ColorLightestGray, tmp.c_str());
+	_vm->_textMan->printToViewport(73, posY, k13_ColorLightestGray, "/");
 	tmp = getStringFromInteger(maxVal, true, 3);
-	_vm->_textMan->f52_printToViewport(79, posY, k13_ColorLightestGray, tmp.c_str());
+	_vm->_textMan->printToViewport(79, posY, k13_ColorLightestGray, tmp.c_str());
 }
 
 uint16 ChampionMan::getHandSlotIndex(uint16 slotBoxIndex) {
@@ -931,19 +931,19 @@ void ChampionMan::disableAction(uint16 champIndex, uint16 ticks) {
 
 	int16 eventIndex = curChampion->_enableActionEventIndex;
 	if (eventIndex >= 0) {
-		int32 currentEnableActionEventTime = filterTime(_vm->_timeline->_g370_events[eventIndex]._mapTime);
+		int32 currentEnableActionEventTime = filterTime(_vm->_timeline->_events[eventIndex]._mapTime);
 		if (updatedEnableActionEventTime >= currentEnableActionEventTime) {
 			updatedEnableActionEventTime += (currentEnableActionEventTime - _vm->_gameTime) >> 1;
 		} else {
 			updatedEnableActionEventTime = currentEnableActionEventTime + (ticks >> 1);
 		}
-		_vm->_timeline->f237_deleteEvent(eventIndex);
+		_vm->_timeline->deleteEvent(eventIndex);
 	} else {
 		setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x0008_ChampionAttributeDisableAction);
 		drawChampionState((ChampionIndex)champIndex);
 	}
 	setMapAndTime(curEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, updatedEnableActionEventTime);
-	curChampion->_enableActionEventIndex = _vm->_timeline->f238_addEventGetEventIndex(&curEvent);
+	curChampion->_enableActionEventIndex = _vm->_timeline->addEventGetEventIndex(&curEvent);
 }
 
 void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp) {
@@ -1031,24 +1031,24 @@ void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint1
 
 			setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
 			drawChampionState((ChampionIndex)champIndex);
-			_vm->_textMan->f51_messageAreaPrintLineFeed();
+			_vm->_textMan->printLineFeed();
 			Color curChampionColor = _championColor[champIndex];
-			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, curChampion->_name);
+			_vm->_textMan->printMessage(curChampionColor, curChampion->_name);
 
 			switch (_vm->getGameLanguage()) { // localized
 			default:
-			case Common::EN_ANY: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " JUST GAINED A "); break;
-			case Common::DE_DEU: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " HAT SOEBEN STUFE"); break;
-			case Common::FR_FRA: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " VIENT DE DEVENIR "); break;
+			case Common::EN_ANY: _vm->_textMan->printMessage(curChampionColor, " JUST GAINED A "); break;
+			case Common::DE_DEU: _vm->_textMan->printMessage(curChampionColor, " HAT SOEBEN STUFE"); break;
+			case Common::FR_FRA: _vm->_textMan->printMessage(curChampionColor, " VIENT DE DEVENIR "); break;
 			}
 
-			_vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, _baseSkillName[baseSkillIndex]);
+			_vm->_textMan->printMessage(curChampionColor, _baseSkillName[baseSkillIndex]);
 
 			switch (_vm->getGameLanguage()) { // localized
 			default:
-			case Common::EN_ANY: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, "!"); break;
-			case Common::DE_DEU: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " LEVEL!"); break;
-			case Common::FR_FRA: _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " ERREICHT!"); break;
+			case Common::EN_ANY: _vm->_textMan->printMessage(curChampionColor, "!"); break;
+			case Common::DE_DEU: _vm->_textMan->printMessage(curChampionColor, " LEVEL!"); break;
+			case Common::FR_FRA: _vm->_textMan->printMessage(curChampionColor, " ERREICHT!"); break;
 			}
 		}
 	}
@@ -1119,7 +1119,7 @@ void ChampionMan::championPoison(int16 champIndex, uint16 attack) {
 		newEvent._priority = champIndex;
 		setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + 36);
 		newEvent._B._attack = attack;
-		_vm->_timeline->f238_addEventGetEventIndex(&newEvent);
+		_vm->_timeline->addEventGetEventIndex(&newEvent);
 	}
 
 	drawChampionState((ChampionIndex)champIndex);
@@ -1426,7 +1426,7 @@ void ChampionMan::applyAndDrawPendingDamageAndWounds() {
 
 				textPosY = 5;
 			}
-			_vm->_textMan->f53_printToLogicalScreen(textPosX, textPosY, k15_ColorWhite, k8_ColorRed, getStringFromInteger(pendingDamage, false, 3).c_str());
+			_vm->_textMan->printToLogicalScreen(textPosX, textPosY, k15_ColorWhite, k8_ColorRed, getStringFromInteger(pendingDamage, false, 3).c_str());
 
 			int16 eventIndex = championPtr->_hideDamageReceivedIndex;
 			if (eventIndex == -1) {
@@ -1434,11 +1434,11 @@ void ChampionMan::applyAndDrawPendingDamageAndWounds() {
 				newEvent._type = k12_TMEventTypeHideDamageReceived;
 				setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + 5);
 				newEvent._priority = championIndex;
-				championPtr->_hideDamageReceivedIndex = _vm->_timeline->f238_addEventGetEventIndex(&newEvent);
+				championPtr->_hideDamageReceivedIndex = _vm->_timeline->addEventGetEventIndex(&newEvent);
 			} else {
-				TimelineEvent *curEvent = &_vm->_timeline->_g370_events[eventIndex];
+				TimelineEvent *curEvent = &_vm->_timeline->_events[eventIndex];
 				setMapAndTime(curEvent->_mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + 5);
-				_vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(eventIndex));
+				_vm->_timeline->fixChronology(_vm->_timeline->getIndex(eventIndex));
 			}
 			drawChampionState((ChampionIndex)championIndex);
 			_vm->_eventMan->hideMouse();
@@ -1561,10 +1561,10 @@ void ChampionMan::unpoison(int16 champIndex) {
 	if (champIndex == kM1_ChampionNone)
 		return;
 
-	TimelineEvent *eventPtr = _vm->_timeline->_g370_events;
-	for (uint16 eventIndex = 0; eventIndex < _vm->_timeline->_g369_eventMaxCount; eventPtr++, eventIndex++) {
+	TimelineEvent *eventPtr = _vm->_timeline->_events;
+	for (uint16 eventIndex = 0; eventIndex < _vm->_timeline->_eventMaxCount; eventPtr++, eventIndex++) {
 		if ((eventPtr->_type == k75_TMEventTypePoisonChampion) && (eventPtr->_priority == champIndex))
-			_vm->_timeline->f237_deleteEvent(eventIndex);
+			_vm->_timeline->deleteEvent(eventIndex);
 	}
 	_champions[champIndex]._poisonEventCount = 0;
 }
@@ -2154,7 +2154,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 				setFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand);
 		} else {
 			_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), &box, k40_byteWidth, kM1_ColorNoTransparency, 29);
-			_vm->_textMan->f53_printToLogicalScreen(championStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, curChampion->_name);
+			_vm->_textMan->printToLogicalScreen(championStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, curChampion->_name);
 			_vm->_menuMan->drawActionIcon(champIndex);
 
 			clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
@@ -2172,13 +2172,13 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		Color nameColor = (champIndex == _leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
 		if (isInventoryChampion) {
 			char *championName = curChampion->_name;
-			_vm->_textMan->f52_printToViewport(3, 7, nameColor, championName);
+			_vm->_textMan->printToViewport(3, 7, nameColor, championName);
 			int16 championTitleX = 6 * strlen(championName) + 3;
 			char titleFirstCharacter = curChampion->_title[0];
 			if ((titleFirstCharacter != ',') && (titleFirstCharacter != ';') && (titleFirstCharacter != '-'))
 				championTitleX += 6;
 
-			_vm->_textMan->f52_printToViewport(championTitleX, 7, nameColor, curChampion->_title);
+			_vm->_textMan->printToViewport(championTitleX, 7, nameColor, curChampion->_title);
 			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 		} else {
 			Box box;
@@ -2187,7 +2187,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			box._x1 = championStatusBoxX;
 			box._x2 = box._x1 + 42;
 			_vm->_displayMan->fillScreenBox(box, k1_ColorDarkGary);
-			_vm->_textMan->f53_printToLogicalScreen(championStatusBoxX + 1, 5, nameColor, k1_ColorDarkGary, curChampion->_name);
+			_vm->_textMan->printToLogicalScreen(championStatusBoxX + 1, 5, nameColor, k1_ColorDarkGary, curChampion->_name);
 		}
 	}
 	if (getFlag(championAttributes, k0x0100_ChampionAttributeStatistics)) {
@@ -2231,9 +2231,9 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 
 		switch (_vm->getGameLanguage()) { // localized
 		default:
-		case Common::EN_ANY: _vm->_textMan->f52_printToViewport(104, 132, loadColor, "LOAD "); break;
-		case Common::DE_DEU: _vm->_textMan->f52_printToViewport(104, 132, loadColor, "LAST "); break;
-		case Common::FR_FRA: _vm->_textMan->f52_printToViewport(104, 132, loadColor, "CHARGE "); break;
+		case Common::EN_ANY: _vm->_textMan->printToViewport(104, 132, loadColor, "LOAD "); break;
+		case Common::DE_DEU: _vm->_textMan->printToViewport(104, 132, loadColor, "LAST "); break;
+		case Common::FR_FRA: _vm->_textMan->printToViewport(104, 132, loadColor, "CHARGE "); break;
 		}
 
 		maxLoad = curChampion->_load / 10;
@@ -2252,7 +2252,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		maxLoad = (getMaximumLoad(curChampion) + 5) / 10;
 		strcat(_vm->_stringBuildBuffer, getStringFromInteger(maxLoad, true, 3).c_str());
 		strcat(_vm->_stringBuildBuffer, " KG");
-		_vm->_textMan->f52_printToViewport(148, 132, loadColor, _vm->_stringBuildBuffer);
+		_vm->_textMan->printToViewport(148, 132, loadColor, _vm->_stringBuildBuffer);
 		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
 	}
 	uint16 championIconIndex = getChampionIconIndex(curChampion->_cell, _vm->_dungeonMan->_partyDir);
@@ -2389,8 +2389,8 @@ void ChampionMan::renameChampion(Champion* champ) {
 
 	_vm->_displayMan->fillBoxBitmap(_vm->_displayMan->_bitmapViewport, displayBox, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
 	_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), _vm->_inventoryMan->_boxPanel, k72_byteWidth, k4_ColorCyan, 73);
-	_vm->_textMan->f52_printToViewport(177, 58, k13_ColorLightestGray, "_______");
-	_vm->_textMan->f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________");
+	_vm->_textMan->printToViewport(177, 58, k13_ColorLightestGray, "_______");
+	_vm->_textMan->printToViewport(105, 76, k13_ColorLightestGray, "___________________");
 	_vm->_eventMan->showMouse();
 	_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 	_vm->_eventMan->setMousePointerToNormal(k0_pointerArrow);
@@ -2407,7 +2407,7 @@ void ChampionMan::renameChampion(Champion* champ) {
 		bool championTitleIsFull = ((renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE) && (curCharacterIndex == 19));
 		if (!championTitleIsFull) {
 			_vm->_eventMan->showMouse();
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k9_ColorGold, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
+			_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k9_ColorGold, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
 			_vm->_eventMan->hideMouse();
 		}
 
@@ -2492,7 +2492,7 @@ void ChampionMan::renameChampion(Champion* champ) {
 				if (!championTitleIsFull) {
 					renameChampionInputCharacterString[0] = curCharacter;
 					_vm->_eventMan->showMouse();
-					_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, renameChampionInputCharacterString, k200_heightScreen);
+					_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, renameChampionInputCharacterString, k200_heightScreen);
 					_vm->_eventMan->hideMouse();
 					renamedChampionString[curCharacterIndex++] = curCharacter;
 					renamedChampionString[curCharacterIndex] = '\0';
@@ -2509,7 +2509,7 @@ void ChampionMan::renameChampion(Champion* champ) {
 		} else if (curCharacter == '\r') { // Carriage return
 			if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex > 0)) {
 				_vm->_eventMan->showMouse();
-				_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
+				_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
 				_vm->_eventMan->hideMouse();
 				renamedChampionStringMode = k2_RENAME_CHAMPION_TITLE;
 				renamedChampionString = champ->_title;
@@ -2523,7 +2523,7 @@ void ChampionMan::renameChampion(Champion* champ) {
 
 			if (!championTitleIsFull) {
 				_vm->_eventMan->showMouse();
-				_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
+				_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen);
 				_vm->_eventMan->hideMouse();
 			}
 			if (curCharacterIndex == 0) {
diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index c842556..25ff25d 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -47,7 +47,7 @@ void DialogMan::dialogDraw(const char *msg1, const char *msg2, const char *choic
 	_vm->_displayMan->loadIntoBitmap(k0_dialogBoxGraphicIndice, _vm->_displayMan->_bitmapViewport);
 	//Strangerke: the version should be replaced by a ScummVM/RogueVM (?) string
 	// TODO: replace with ScummVM version string
-	_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 192, 7, k2_ColorLightGray, k1_ColorDarkGary, "V2.2", k136_heightViewport);
+	_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 192, 7, k2_ColorLightGray, k1_ColorDarkGary, "V2.2", k136_heightViewport);
 	int16 choiceCount = 1;
 	if (choice2)
 		choiceCount++;
@@ -94,14 +94,14 @@ void DialogMan::dialogDraw(const char *msg1, const char *msg2, const char *choic
 		if (isMessageOnTwoLines(msg1, L1312_ac_StringPart1, L1313_ac_StringPart2)) {
 			textPosY = 21;
 			textPosX = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
+			_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
 			textPosY += 8;
 			textPosX = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport);
+			_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport);
 			textPosY += 8;
 		} else {
 			textPosX = 113 - ((strlen(msg1) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, msg1, k136_heightViewport);
+			_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, msg1, k136_heightViewport);
 			textPosY += 8;
 		}
 	}
@@ -110,13 +110,13 @@ void DialogMan::dialogDraw(const char *msg1, const char *msg2, const char *choic
 		char L1313_ac_StringPart2[70];
 		if (isMessageOnTwoLines(msg2, L1312_ac_StringPart1, L1313_ac_StringPart2)) {
 			textPosX = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
+			_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport);
 			textPosY += 8;
 			textPosX = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport);
+			_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport);
 		} else {
 			textPosX = 113 - ((strlen(msg2) * 6) >> 1);
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, msg2, k136_heightViewport);
+			_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, msg2, k136_heightViewport);
 		}
 	}
 	if (screenDialog) {
@@ -143,7 +143,7 @@ void DialogMan::dialogDraw(const char *msg1, const char *msg2, const char *choic
 void DialogMan::printCenteredChoice(byte *bitmap, const char *str, int16 posX, int16 posY) {
 	if (str) {
 		posX -= (strlen(str) * 6) >> 1;
-		_vm->_textMan->f40_printTextToBitmap(bitmap, k112_byteWidthViewport, posX, posY, k9_ColorGold, k5_ColorLightBrown, str, k136_heightViewport);
+		_vm->_textMan->printTextToBitmap(bitmap, k112_byteWidthViewport, posX, posY, k9_ColorGold, k5_ColorLightBrown, str, k136_heightViewport);
 	}
 }
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index eb592ed..6124d8f 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -272,12 +272,12 @@ void DMEngine::initializeGame() {
 	_displayMan->loadFloorSet(k0_FloorSetStone);
 	_displayMan->loadWallSet(k0_WallSetStone);
 
-	_sound->f503_loadSounds(); // @ F0506_AMIGA_AllocateData
+	_sound->loadSounds(); // @ F0506_AMIGA_AllocateData
 
 	if (!ConfMan.hasKey("save_slot")) // skip drawing title if loading from launcher
 		drawTittle();
 
-	_textMan->f54_textInitialize();
+	_textMan->initialize();
 	_objectMan->loadObjectNames();
 	_eventMan->initMouse();
 
@@ -443,7 +443,7 @@ void DMEngine::gameloop() {
 				_newPartyMapIndex = kM1_mapIndexNone;
 				_eventMan->discardAllInput();
 			}
-			_timeline->f261_processTimeline();
+			_timeline->processTimeline();
 
 			if (_newPartyMapIndex == kM1_mapIndexNone)
 				break;
@@ -468,7 +468,7 @@ void DMEngine::gameloop() {
 			}
 		}
 		_eventMan->highlightBoxDisable();
-		_sound->f65_playPendingSound();
+		_sound->playPendingSound();
 		_championMan->applyAndDrawPendingDamageAndWounds();
 		if (_championMan->_partyDead)
 			break;
@@ -492,7 +492,7 @@ void DMEngine::gameloop() {
 		if (_projectileDisableMovementTicks)
 			_projectileDisableMovementTicks--;
 
-		_textMan->f44_messageAreaClearExpiredRows();
+		_textMan->clearExpiredRows();
 		_stopWaitingForPlayerInput = false;
 		uint16 vblankCounter = 0;
 		do {
@@ -581,7 +581,7 @@ void DMEngine::processEntrance() {
 	} while (_newGameFl == k202_CommandEntranceDrawCredits);
 
 	//Strangerke: CHECKME: Earlier versions were using G0566_puc_Graphic534_Sound01Switch
-	_sound->f060_SOUND_Play(k01_soundSWITCH, 112, 0x40, 0x40);
+	_sound->play(k01_soundSWITCH, 112, 0x40, 0x40);
 	delay(20);
 	_eventMan->showMouse();
 	if (_newGameFl)
@@ -634,7 +634,7 @@ void DMEngine::endGame(bool doNotDrawCreditsOnly) {
 	_eventMan->_primaryKeyboardInput = nullptr;
 	_eventMan->_secondaryKeyboardInput = nullptr;
 	if (doNotDrawCreditsOnly && !_gameWon) {
-		_sound->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY, k0_soundModePlayImmediately);
+		_sound->requestPlay(k06_soundSCREAM, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY, k0_soundModePlayImmediately);
 		delay(240);
 	}
 
@@ -666,13 +666,13 @@ void DMEngine::endGame(bool doNotDrawCreditsOnly) {
 				Champion *curChampion = &_championMan->_champions[championIndex];
 				_displayMan->blitToScreen(_displayMan->getNativeBitmapOrGraphic(k208_wallOrn_43_champMirror), &championMirrorBox, k32_byteWidth, k10_ColorFlesh, 43);
 				_displayMan->blitToScreen(curChampion->_portrait, &championPortraitBox, k16_byteWidth, k1_ColorDarkGary, 29);
-				_textMan->f443_endgamePrintString(87, textPosY += 14, k9_ColorGold, curChampion->_name);
+				_textMan->printEndGameString(87, textPosY += 14, k9_ColorGold, curChampion->_name);
 				int textPosX = (6 * strlen(curChampion->_name)) + 87;
 				char championTitleFirstCharacter = curChampion->_title[0];
 				if ((championTitleFirstCharacter != ',') && (championTitleFirstCharacter != ';') && (championTitleFirstCharacter != '-'))
 					textPosX += 6;
 
-				_textMan->f443_endgamePrintString(textPosX, textPosY++, k9_ColorGold, curChampion->_title);
+				_textMan->printEndGameString(textPosX, textPosY++, k9_ColorGold, curChampion->_title);
 				for (int16 idx = k0_ChampionSkillFighter; idx <= k3_ChampionSkillWizard; idx++) {
 					uint16 skillLevel = MIN<uint16>(16, _championMan->getSkillLevel(championIndex, idx | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience)));
 					if (skillLevel == 1)
@@ -682,7 +682,7 @@ void DMEngine::endGame(bool doNotDrawCreditsOnly) {
 					strcpy(displStr, _inventoryMan->_skillLevelNames[skillLevel - 2]);
 					strcat(displStr, " ");
 					strcat(displStr, _championMan->_baseSkillName[idx]);
-					_textMan->f443_endgamePrintString(105, textPosY = textPosY + 8, k13_ColorLightestGray, displStr);
+					_textMan->printEndGameString(105, textPosY = textPosY + 8, k13_ColorLightestGray, displStr);
 				}
 				championMirrorBox._y1 += 48;
 				championMirrorBox._y2 += 48;
@@ -714,9 +714,9 @@ T0444017:
 
 			switch (getGameLanguage()) { // localized
 			default:
-			case Common::EN_ANY: _textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RESTART THIS GAME"); break;
-			case Common::DE_DEU: _textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "DIESES SPIEL NEU STARTEN"); break;
-			case Common::FR_FRA: _textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RECOMMENCER CE JEU"); break;
+			case Common::EN_ANY: _textMan->printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RESTART THIS GAME"); break;
+			case Common::DE_DEU: _textMan->printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "DIESES SPIEL NEU STARTEN"); break;
+			case Common::FR_FRA: _textMan->printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RECOMMENCER CE JEU"); break;
 			}
 
 			curPalette[1] = D03_RGB_PINK;
@@ -822,7 +822,7 @@ void DMEngine::openEntranceDoors() {
 	for (uint16 animStep = 1; animStep < 32; ++animStep) {
 		if ((animStep % 3) == 1) {
 			// Strangerke: CHECKME: Earlier versions of the game were using G0565_puc_Graphic535_Sound02DoorRattle instead of k02_soundDOOR_RATTLE 2
-			_sound->f060_SOUND_Play(k02_soundDOOR_RATTLE, 145, 0x40, 0x40);
+			_sound->play(k02_soundDOOR_RATTLE, 145, 0x40, 0x40);
 		}
 
 		_displayMan->blitToScreen(_savedScreenForOpenEntranceDoors, &screenBox, 160, kM1_ColorNoTransparency, 200);
@@ -967,7 +967,7 @@ void DMEngine::fuseSequnce() {
 	_championMan->_party._magicalLightAmount = 200;
 	_inventoryMan->setDungeonViewPalette();
 	_championMan->_party._fireShieldDefense = _championMan->_party._spellShieldDefense = _championMan->_party._shieldDefense = 100;
-	_timeline->f260_timelineRefreshAllChampionStatusBoxes();
+	_timeline->refreshAllChampionStatusBoxes();
 	fuseSequenceUpdate();
 	L1431_i_LordChaosMapX = _dungeonMan->_partyMapX;
 	L1432_i_LordChaosMapY = _dungeonMan->_partyMapY;
@@ -1005,7 +1005,7 @@ T0446002:
 		_projexpl->createExplosion(Thing::_explFireBall, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
 		fuseSequenceUpdate();
 	}
-	_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized);
+	_sound->requestPlay(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized);
 	L1428_ps_Group->_type = k25_CreatureTypeLordOrder;
 	fuseSequenceUpdate();
 	for (AL1424_i_Attack = 55; AL1424_i_Attack <= 255; AL1424_i_Attack += 40) {
@@ -1014,7 +1014,7 @@ T0446002:
 	}
 	for (AL1425_i_CycleCount = 4; --AL1425_i_CycleCount; ) {
 		for (AL1424_i_CreatureTypeSwitchCount = 5; --AL1424_i_CreatureTypeSwitchCount; ) {
-			_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized);
+			_sound->requestPlay(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized);
 			L1428_ps_Group->_type = (AL1424_i_CreatureTypeSwitchCount & 0x0001) ? k25_CreatureTypeLordOrder : k23_CreatureTypeLordChaos;
 			for (AL1426_i_FuseSequenceUpdateCount = AL1425_i_CycleCount; AL1426_i_FuseSequenceUpdateCount--; fuseSequenceUpdate());
 		}
@@ -1049,9 +1049,9 @@ T0446002:
 		for (AL1425_i_TextStringThingIndex = 0; AL1425_i_TextStringThingIndex < AL1426_i_TextStringThingCount; AL1425_i_TextStringThingIndex++) {
 			_dungeonMan->decodeText(L1436_ac_String, L1435_aT_TextStringThings[AL1425_i_TextStringThingIndex], (TextType)(k1_TextTypeMessage | k0x8000_DecodeEvenIfInvisible));
 			if (L1436_ac_String[1] == L1434_c_TextFirstCharacter) {
-				_textMan->f43_messageAreaClearAllRows();
+				_textMan->clearAllRows();
 				L1436_ac_String[1] = '\n'; /* New line */
-				_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, &L1436_ac_String[1]);
+				_textMan->printMessage(k15_ColorWhite, &L1436_ac_String[1]);
 				fuseSequenceUpdate();
 				delay(780);
 				L1434_c_TextFirstCharacter++;
@@ -1071,9 +1071,9 @@ T0446002:
 }
 
 void DMEngine::fuseSequenceUpdate() {
-	_timeline->f261_processTimeline();
+	_timeline->processTimeline();
 	_displayMan->drawDungeon(_dungeonMan->_partyDir, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY);
-	_sound->f65_playPendingSound();
+	_sound->playPendingSound();
 	_eventMan->discardAllInput();
 	_displayMan->updateScreen();
 	delay(2);
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index dbfbfc3..3fb452a 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -672,7 +672,7 @@ void DungeonMan::loadDungeonFile(Common::InSaveFile *file) {
 		_dungeonTextData[i] = dunDataStream->readUint16BE();
 
 	if (_vm->_newGameFl)
-		_vm->_timeline->_g369_eventMaxCount = 100;
+		_vm->_timeline->_eventMaxCount = 100;
 
 	// load things
 	for (uint16 thingType = k0_DoorThingType; thingType < k16_ThingTypeTotal; ++thingType) {
@@ -710,7 +710,7 @@ void DungeonMan::loadDungeonFile(Common::InSaveFile *file) {
 
 		if (_vm->_newGameFl) {
 			if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType)
-				_vm->_timeline->_g369_eventMaxCount += _dungeonFileHeader._thingCounts[thingType];
+				_vm->_timeline->_eventMaxCount += _dungeonFileHeader._thingCounts[thingType];
 
 			for (uint16 i = 0; i < additionalThingCounts[thingType]; ++i)
 				(_thingData[thingType] + (thingCount + i) * thingStoreWordCount)[0] = Thing::_none.toUint16();
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index a823486..39f74e5 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -867,15 +867,15 @@ void EventManager::processCommandQueue() {
 		switch (_vm->getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY:
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 81, 69, k4_ColorCyan, k0_ColorBlack,
+			_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 81, 69, k4_ColorCyan, k0_ColorBlack,
 												 "GAME FROZEN", k136_heightViewport);
 			break;
 		case Common::DE_DEU:
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 66, 69, k4_ColorCyan, k0_ColorBlack,
+			_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 66, 69, k4_ColorCyan, k0_ColorBlack,
 												 "SPIEL ANGEHALTEN", k136_heightViewport);
 			break;
 		case Common::FR_FRA:
-			_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 84, 69, k4_ColorCyan, k0_ColorBlack,
+			_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 84, 69, k4_ColorCyan, k0_ColorBlack,
 												 "JEU BLOQUE", k136_heightViewport);
 			break;
 		}
@@ -1014,7 +1014,7 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 				damage |= _vm->_championMan->addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
 
 			if (damage)
-				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, partyMapX, partyMapY, k0_soundModePlayImmediately);
+				_vm->_sound->requestPlay(k18_soundPARTY_DAMAGED, partyMapX, partyMapY, k0_soundModePlayImmediately);
 		} else {
 			isMovementBlocked = (_vm->_groupMan->groupGetThing(partyMapX, partyMapY) != Thing::_endOfList);
 			if (isMovementBlocked)
@@ -1160,7 +1160,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 			Junk *junkPtr = (Junk*)_vm->_dungeonMan->getSquareFirstThingData(L1155_i_MapX, L1156_i_MapY);
 			if ((((Door*)junkPtr)->hasButton()) && _vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) {
 				_vm->_stopWaitingForPlayerInput = true;
-				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
+				_vm->_sound->requestPlay(k01_soundSWITCH, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 				_vm->_moveSens->addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_gameTime + 1);
 				return;
 			}
@@ -1292,20 +1292,20 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	} else
 		_vm->_menuMan->drawSpellAreaControls(champMan._magicCasterChampionIndex);
 
-	_vm->_textMan->f51_messageAreaPrintLineFeed();
+	_vm->_textMan->printLineFeed();
 	Color champColor = _vm->_championMan->_championColor[championIndex];
-	_vm->_textMan->f47_messageAreaPrintMessage(champColor, champ->_name);
+	_vm->_textMan->printMessage(champColor, champ->_name);
 
 	switch (_vm->getGameLanguage()) { // localized
 	default:
 	case Common::EN_ANY:
-		_vm->_textMan->f47_messageAreaPrintMessage(champColor, (commandType == k160_CommandClickInPanelResurrect) ? " RESURRECTED." : " REINCARNATED.");
+		_vm->_textMan->printMessage(champColor, (commandType == k160_CommandClickInPanelResurrect) ? " RESURRECTED." : " REINCARNATED.");
 		break;
 	case Common::DE_DEU:
-		_vm->_textMan->f47_messageAreaPrintMessage(champColor, (commandType == k160_CommandClickInPanelResurrect) ? " VOM TODE ERWECKT." : " REINKARNIERT.");
+		_vm->_textMan->printMessage(champColor, (commandType == k160_CommandClickInPanelResurrect) ? " VOM TODE ERWECKT." : " REINKARNIERT.");
 		break;
 	case Common::FR_FRA:
-		_vm->_textMan->f47_messageAreaPrintMessage(champColor, (commandType == k160_CommandClickInPanelResurrect) ? " RESSUSCITE." : " REINCARNE.");
+		_vm->_textMan->printMessage(champColor, (commandType == k160_CommandClickInPanelResurrect) ? " RESSUSCITE." : " REINCARNE.");
 		break;
 	}
 
@@ -1390,7 +1390,7 @@ void EventManager::processType80_clickInDungeonViewDropLeaderHandObject(uint16 v
 		newEvent._B._location._mapY = mapY;
 		newEvent._C.A._cell = currCell;
 		newEvent._C.A._effect = k2_SensorEffToggle;
-		_vm->_timeline->f238_addEventGetEventIndex(&newEvent);
+		_vm->_timeline->addEventGetEventIndex(&newEvent);
 	}
 	_vm->_stopWaitingForPlayerInput = true;
 }
@@ -1407,13 +1407,13 @@ void EventManager::drawSleepScreen() {
 	switch (_vm->getGameLanguage()) { // localized
 	default:
 	case Common::EN_ANY:
-		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 93, 69, k4_ColorCyan, k0_ColorBlack, "WAKE UP", k136_heightViewport);
+		_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 93, 69, k4_ColorCyan, k0_ColorBlack, "WAKE UP", k136_heightViewport);
 		break;
 	case Common::DE_DEU:
-		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 96, 69, k4_ColorCyan, k0_ColorBlack, "WECKEN", k136_heightViewport);
+		_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 96, 69, k4_ColorCyan, k0_ColorBlack, "WECKEN", k136_heightViewport);
 		break;
 	case Common::FR_FRA:
-		_vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 72, 69, k4_ColorCyan, k0_ColorBlack, "REVEILLEZ-VOUS", k136_heightViewport);
+		_vm->_textMan->printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, 72, 69, k4_ColorCyan, k0_ColorBlack, "REVEILLEZ-VOUS", k136_heightViewport);
 		break;
 	}
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 7947ea9..506a2e0 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -3511,7 +3511,7 @@ T0115129_DrawProjectiles:
 					if (projectileAspectType == k3_ProjectileAspectHasNone) {
 						projectileBitmapIndexDelta = 0;
 						flipVertical = flipHorizontal = false;
-					} else if (isOrientedWestEast(Direction(projectileDirection = _vm->_timeline->_g370_events[projectile->_eventIndex]._C._projectile.getDir())) != isOrientedWestEast(directionParam)) {
+					} else if (isOrientedWestEast(Direction(projectileDirection = _vm->_timeline->_events[projectile->_eventIndex]._C._projectile.getDir())) != isOrientedWestEast(directionParam)) {
 						if (projectileAspectType == k2_ProjectileAspectHasRotation)
 							projectileBitmapIndexDelta = 1;
 						else
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index ebc946b..f0a28a1 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -159,7 +159,7 @@ void GroupMan::dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, in
 		} while ((currentThing = nextThing) != Thing::_endOfList);
 
 		if (mode >= k0_soundModePlayImmediately)
-			_vm->_sound->f064_SOUND_RequestPlay_CPSD(L0371_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
+			_vm->_sound->requestPlay(L0371_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
 	}
 }
 
@@ -287,7 +287,7 @@ void GroupMan::dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int
 		_vm->_moveSens->getMoveResult(nextUnusedThing, kM1_MapXNotOnASquare, 0, mapX, mapY);
 		currFixedPossession = *fixedPossessions++;
 	}
-	_vm->_sound->f064_SOUND_RequestPlay_CPSD(weaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
+	_vm->_sound->requestPlay(weaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode);
 }
 
 int16 GroupMan::getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
@@ -374,7 +374,7 @@ bool GroupMan::groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 atta
 				L0575_s_Event._priority = 0;
 				L0575_s_Event._B._location._mapX = mapX;
 				L0575_s_Event._B._location._mapY = mapY;
-				_vm->_timeline->f238_addEventGetEventIndex(&L0575_s_Event);
+				_vm->_timeline->addEventGetEventIndex(&L0575_s_Event);
 			} else {
 				((Square *)L0574_puc_Square)->setDoorState(k5_doorState_DESTROYED);
 			}
@@ -443,8 +443,8 @@ int16 GroupMan::groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex
 				L0378_ps_ActiveGroup = &_activeGroups[group->getActiveGroupIndex()];
 
 			if (group->getBehaviour() == k6_behavior_ATTACK) {
-				L0377_ps_Event = _vm->_timeline->_g370_events;
-				for (AL0374_ui_EventIndex = 0; AL0374_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; AL0374_ui_EventIndex++) {
+				L0377_ps_Event = _vm->_timeline->_events;
+				for (AL0374_ui_EventIndex = 0; AL0374_ui_EventIndex < _vm->_timeline->_eventMaxCount; AL0374_ui_EventIndex++) {
 					if ((getMap(L0377_ps_Event->_mapTime) == _vm->_dungeonMan->_currMapIndex) &&
 						(L0377_ps_Event->_B._location._mapX == mapX) &&
 						(L0377_ps_Event->_B._location._mapY == mapY) &&
@@ -456,11 +456,11 @@ int16 GroupMan::groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex
 							AL0375_ui_EventType -= k38_TMEventTypeUpdateBehaviour_0; /* Get creature index for events 38 to 41 */
 						}
 						if (AL0375_ui_NextCreatureIndex == creatureIndex) {
-							_vm->_timeline->f237_deleteEvent(AL0374_ui_EventIndex);
+							_vm->_timeline->deleteEvent(AL0374_ui_EventIndex);
 						} else {
 							if (AL0375_ui_NextCreatureIndex > creatureIndex) {
 								L0377_ps_Event->_type -= 1;
-								_vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(AL0374_ui_EventIndex));
+								_vm->_timeline->fixChronology(_vm->_timeline->getIndex(AL0374_ui_EventIndex));
 							}
 						}
 					}
@@ -531,12 +531,12 @@ void GroupMan::groupDeleteEvents(int16 mapX, int16 mapY) {
 	TimelineEvent *L0336_ps_Event;
 
 
-	L0336_ps_Event = _vm->_timeline->_g370_events;
-	for (L0334_i_EventIndex = 0; L0334_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0334_i_EventIndex++) {
+	L0336_ps_Event = _vm->_timeline->_events;
+	for (L0334_i_EventIndex = 0; L0334_i_EventIndex < _vm->_timeline->_eventMaxCount; L0334_i_EventIndex++) {
 		if ((getMap(L0336_ps_Event->_mapTime) == _vm->_dungeonMan->_currMapIndex) &&
 			((L0335_ui_EventType = L0336_ps_Event->_type) > k29_TMEventTypeGroupReactionDangerOnSquare - 1) && (L0335_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1) &&
 			(L0336_ps_Event->_B._location._mapX == mapX) && (L0336_ps_Event->_B._location._mapY == mapY)) {
-			_vm->_timeline->f237_deleteEvent(L0334_i_EventIndex);
+			_vm->_timeline->deleteEvent(L0334_i_EventIndex);
 		}
 		L0336_ps_Event++;
 	}
@@ -664,7 +664,7 @@ void GroupMan::processEvents29to41(int16 eventMapX, int16 eventMapY, int16 event
 		/* BUG0_68 A group moves or acts with a wrong timing. Event is added below but L0465_s_NextEvent.C.Ticks has not been initialized. No consequence while the group is not on the party map. When the party enters the group map the first group event may have a wrong timing */
 T0209005_AddEventAndReturn:
 		L0465_s_NextEvent._mapTime += AL0446_i_Ticks;
-		_vm->_timeline->f238_addEventGetEventIndex(&L0465_s_NextEvent);
+		_vm->_timeline->addEventGetEventIndex(&L0465_s_NextEvent);
 		goto T0209139_Return;
 	}
 	/* If the creature is Lord Chaos then ignore the event if the game is won. Initialize data to analyze Fluxcages */
@@ -928,7 +928,7 @@ T0209089_DoubleSquareMove:
 							AL0450_i_DestinationMapX = eventMapX;
 							AL0451_i_DestinationMapY = eventMapY;
 							AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2;
-							_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY, k1_soundModePlayIfPrioritized);
+							_vm->_sound->requestPlay(k17_soundBUZZ, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY, k1_soundModePlayIfPrioritized);
 							goto T0209061_MoveGroup;
 						}
 					}
@@ -1319,7 +1319,7 @@ int32 GroupMan::getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 crea
 				if (getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) && (L0331_ui_CreatureType == k18_CreatureTypeAnimatedArmourDethKnight)) {
 					if (_vm->getRandomNumber(2)) {
 						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-						_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _currentGroupMapX, _currentGroupMapY, k1_soundModePlayIfPrioritized);
+						_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _currentGroupMapX, _currentGroupMapY, k1_soundModePlayIfPrioritized);
 					}
 				} else if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) {
 					if (_vm->getRandomNumber(2))
@@ -1338,7 +1338,7 @@ int32 GroupMan::getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 crea
 						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
 						L1635_ui_SoundIndex = _vm->_moveSens->getSound(k13_CreatureTypeCouatl);
 						if (L1635_ui_SoundIndex <= k34_D13_soundCount)
-							_vm->_sound->f064_SOUND_RequestPlay_CPSD(L1635_ui_SoundIndex, _currentGroupMapX, _currentGroupMapY, k1_soundModePlayIfPrioritized);
+							_vm->_sound->requestPlay(L1635_ui_SoundIndex, _currentGroupMapX, _currentGroupMapY, k1_soundModePlayIfPrioritized);
 					}
 				} else if (_vm->getRandomNumber(2))
 					setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
@@ -1386,7 +1386,7 @@ void GroupMan::addGroupEvent(TimelineEvent *event, uint32 time) {
 	} else {
 		event->_C._ticks = time - filterTime(event->_mapTime);
 	}
-	_vm->_timeline->f238_addEventGetEventIndex(event);
+	_vm->_timeline->addEventGetEventIndex(event);
 }
 
 int16 GroupMan::getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo, int16 mapY, int16 mapX) {
@@ -1526,7 +1526,7 @@ bool GroupMan::isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16
 		AL0440_i_KineticEnergy = (L0441_ps_CreatureInfo->_attack >> 2) + 1;
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
 		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
-		_vm->_sound->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, mapX, mapY, k0_soundModePlayImmediately);
+		_vm->_sound->requestPlay(k13_soundSPELL, mapX, mapY, k0_soundModePlayImmediately);
 		_vm->_projexpl->createProjectile(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (Direction)_currGroupPrimaryDirToParty, getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
 	} else {
 		if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) {
@@ -1555,7 +1555,7 @@ bool GroupMan::isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16
 	}
 	AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal;
 	if (AL0440_i_AttackSoundOrdinal)
-		_vm->_sound->f064_SOUND_RequestPlay_CPSD(G0244_auc_Graphic559_CreatureAttackSounds[--AL0440_i_AttackSoundOrdinal], mapX, mapY, k1_soundModePlayIfPrioritized);
+		_vm->_sound->requestPlay(G0244_auc_Graphic559_CreatureAttackSounds[--AL0440_i_AttackSoundOrdinal], mapX, mapY, k1_soundModePlayIfPrioritized);
 
 	return true;
 }
@@ -1679,7 +1679,7 @@ int16 GroupMan::getChampionDamage(Group *group, uint16 champIndex) {
 
 		AL0558_i_Damage = _vm->_championMan->addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType);
 		if (AL0558_i_Damage) {
-			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k09_soundCHAMPION_0_DAMAGED + champIndex, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k2_soundModePlayOneTickLater);
+			_vm->_sound->requestPlay(k09_soundCHAMPION_0_DAMAGED + champIndex, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k2_soundModePlayOneTickLater);
 
 			AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack;
 			if (AL0559_ui_PoisonAttack && _vm->getRandomNumber(2)) {
@@ -1723,7 +1723,7 @@ void GroupMan::startWanedring(int16 mapX, int16 mapY) {
 	L0333_s_Event._C._ticks = 0;
 	L0333_s_Event._B._location._mapX = mapX;
 	L0333_s_Event._B._location._mapY = mapY;
-	_vm->_timeline->f238_addEventGetEventIndex(&L0333_s_Event);
+	_vm->_timeline->addEventGetEventIndex(&L0333_s_Event);
 }
 
 void GroupMan::addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
@@ -1853,7 +1853,7 @@ Thing GroupMan::groupGetGenerated(int16 creatureType, int16 healthMultiplier, ui
 	if (_vm->_moveSens->getMoveResult(L0349_T_GroupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) { /* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile impact (in which case the thing data was marked as unused) or the party is on the destination square and an event is created to move the creature into the dungeon later (in which case the thing is referenced in the event) */
 		return Thing::_none;
 	}
-	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, mapX, mapY, k1_soundModePlayIfPrioritized);
+	_vm->_sound->requestPlay(k17_soundBUZZ, mapX, mapY, k1_soundModePlayIfPrioritized);
 	return L0349_T_GroupThing;
 }
 
@@ -1995,7 +1995,7 @@ void GroupMan::fluxCageAction(int16 mapX, int16 mapY) {
 	L0547_s_Event._B._location._mapX = mapX;
 	L0547_s_Event._B._location._mapY = mapY;
 	L0547_s_Event._B._location._mapY = mapY;
-	_vm->_timeline->f238_addEventGetEventIndex(&L0547_s_Event);
+	_vm->_timeline->addEventGetEventIndex(&L0547_s_Event);
 	if (isLordChaosOnSquare(mapX, mapY - 1)) {
 		mapY--;
 		AL0546_i_FluxcageCount = isFluxcageOnSquare(mapX + 1, mapY);
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index c7f95c6..be1e976 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -142,20 +142,20 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	switch (_vm->getGameLanguage()) { // localized
 	default:
 	case Common::EN_ANY:
-		_vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "HEALTH");
-		_vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
+		_vm->_textMan->printToViewport(5, 116, k13_ColorLightestGray, "HEALTH");
+		_vm->_textMan->printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
 		break;
 	case Common::DE_DEU:
-		_vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "GESUND");
-		_vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "KRAFT");
+		_vm->_textMan->printToViewport(5, 116, k13_ColorLightestGray, "GESUND");
+		_vm->_textMan->printToViewport(5, 124, k13_ColorLightestGray, "KRAFT");
 		break;
 	case Common::FR_FRA:
-		_vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "SANTE");
-		_vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "VIGUEUR");
+		_vm->_textMan->printToViewport(5, 116, k13_ColorLightestGray, "SANTE");
+		_vm->_textMan->printToViewport(5, 124, k13_ColorLightestGray, "VIGUEUR");
 		break;
 	}
 
-	_vm->_textMan->f52_printToViewport(5, 132, k13_ColorLightestGray, "MANA");
+	_vm->_textMan->printToViewport(5, 132, k13_ColorLightestGray, "MANA");
 	for (AL1102_ui_SlotIndex = k0_ChampionSlotReadyHand; AL1102_ui_SlotIndex < k30_ChampionSlotChest_1; AL1102_ui_SlotIndex++) {
 		_vm->_championMan->drawSlot(championIndex, AL1102_ui_SlotIndex);
 	}
@@ -310,7 +310,7 @@ void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) {
 			*iter -= 96;
 		}
 	}
-	_vm->_textMan->f52_printToViewport(162 - (6 * strlen(text) / 2), yPos, k0_ColorBlack, text, k15_ColorWhite);
+	_vm->_textMan->printToViewport(162 - (6 * strlen(text) / 2), yPos, k0_ColorBlack, text, k15_ColorWhite);
 }
 
 void InventoryMan::drawPanelScroll(Scroll* scroll) {
@@ -464,7 +464,7 @@ void InventoryMan::drawPanelObjectDescriptionString(const char *descString) {
 				severalLines = true;
 			}
 
-			_vm->_textMan->f52_printToViewport(_objDescTextXpos, _objDescTextYpos, k13_ColorLightestGray, stringLine);
+			_vm->_textMan->printToViewport(_objDescTextXpos, _objDescTextYpos, k13_ColorLightestGray, stringLine);
 			_objDescTextYpos += 7;
 			if (severalLines) {
 				severalLines = false;
@@ -547,7 +547,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			descString = objMan._objectNames[iconIndex];
 		}
 
-		textMan.f52_printToViewport(134, 68, k13_ColorLightestGray, descString);
+		textMan.printToViewport(134, 68, k13_ColorLightestGray, descString);
 		drawIconToViewport(iconIndex, 111, 59);
 
 
@@ -847,12 +847,12 @@ void InventoryMan::drawChampionSkillsAndStatistics() {
 			strcpy(L1097_ac_String, _skillLevelNames[AL1092_i_SkillLevel - 2]);
 			break;
 		}
-		_vm->_textMan->f52_printToViewport(108, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String);
+		_vm->_textMan->printToViewport(108, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String);
 		L1091_i_Y += 7;
 	}
 	L1091_i_Y = 86;
 	for (AL1090_ui_StatisticIndex = k1_ChampionStatStrength; AL1090_ui_StatisticIndex <= k6_ChampionStatAntifire; AL1090_ui_StatisticIndex++) {
-		_vm->_textMan->f52_printToViewport(108, L1091_i_Y, k13_ColorLightestGray, G0431_apc_StatisticNames[AL1090_ui_StatisticIndex]);
+		_vm->_textMan->printToViewport(108, L1091_i_Y, k13_ColorLightestGray, G0431_apc_StatisticNames[AL1090_ui_StatisticIndex]);
 		AL1092_i_StatisticCurrentValue = L1094_ps_Champion->_statistics[AL1090_ui_StatisticIndex][k1_ChampionStatCurrent];
 		L1096_ui_StatisticMaximumValue = L1094_ps_Champion->_statistics[AL1090_ui_StatisticIndex][k0_ChampionStatMaximum];
 		if (AL1092_i_StatisticCurrentValue < L1096_ui_StatisticMaximumValue) {
@@ -864,10 +864,10 @@ void InventoryMan::drawChampionSkillsAndStatistics() {
 				L1095_i_StatisticColor = k13_ColorLightestGray;
 			}
 		}
-		_vm->_textMan->f52_printToViewport(174, L1091_i_Y, (Color)L1095_i_StatisticColor, _vm->_championMan->getStringFromInteger(AL1092_i_StatisticCurrentValue, true, 3).c_str());
+		_vm->_textMan->printToViewport(174, L1091_i_Y, (Color)L1095_i_StatisticColor, _vm->_championMan->getStringFromInteger(AL1092_i_StatisticCurrentValue, true, 3).c_str());
 		strcpy(L1097_ac_String, "/");
 		strcat(L1097_ac_String, _vm->_championMan->getStringFromInteger(L1096_ui_StatisticMaximumValue, true, 3).c_str());
-		_vm->_textMan->f52_printToViewport(192, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String);
+		_vm->_textMan->printToViewport(192, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String);
 		L1091_i_Y += 7;
 	}
 }
@@ -1007,7 +1007,7 @@ void InventoryMan::clickOnMouth() {
 			setMapAndTime(L1084_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + (AL1085_ui_AdjustedPotionPower * AL1085_ui_AdjustedPotionPower));
 			L1084_s_Event._priority = L1080_ui_ChampionIndex;
 			L1084_s_Event._B._defense = AL1085_ui_AdjustedPotionPower;
-			_vm->_timeline->f238_addEventGetEventIndex(&L1084_s_Event);
+			_vm->_timeline->addEventGetEventIndex(&L1084_s_Event);
 			setFlag(L1083_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox);
 			break;
 		case k13_PotionTypeEe:
@@ -1062,7 +1062,7 @@ void InventoryMan::clickOnMouth() {
 		_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(L1078_T_Thing) - L1089_ui_Weight;
 		setFlag(_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
 	}
-	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k08_soundSWALLOW, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
+	_vm->_sound->requestPlay(k08_soundSWALLOW, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
 	setFlag(L1083_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
 	if (_panelContent == k0_PanelContentFoodWaterPoisoned) {
 		setFlag(L1083_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 1108fd8..5091c00 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -99,9 +99,9 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
 		_dungeonMan->_partyMapIndex = file->readByte();
 		_championMan->_leaderIndex = (ChampionIndex)file->readSint16BE();
 		_championMan->_magicCasterChampionIndex = (ChampionIndex)file->readSint16BE();
-		_timeline->_g372_eventCount = file->readUint16BE();
-		_timeline->_g373_firstUnusedEventIndex = file->readUint16BE();
-		_timeline->_g369_eventMaxCount = file->readUint16BE();
+		_timeline->_eventCount = file->readUint16BE();
+		_timeline->_firstUnusedEventIndex = file->readUint16BE();
+		_timeline->_eventMaxCount = file->readUint16BE();
 		_groupMan->_currActiveGroupCount = file->readUint16BE();
 		_projexpl->_lastCreatureAttackTime = file->readSint32BE();
 		_projexpl->_lastPartyMovementTime = file->readSint32BE();
@@ -111,14 +111,14 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
 		_championMan->_leaderHandObject = Thing(file->readUint16BE());
 		_groupMan->_maxActiveGroupCount = file->readUint16BE();
 		if (!_restartGameRequest) {
-			_timeline->f233_initTimeline();
+			_timeline->initTimeline();
 			_groupMan->initActiveGroups();
 		}
 
 		_groupMan->loadActiveGroupPart(file);
 		_championMan->loadPartyPart2(file);
-		_timeline->load3_eventsPart(file);
-		_timeline->load4_timelinePart(file);
+		_timeline->loadEventsPart(file);
+		_timeline->loadTimelinePart(file);
 
 		// read sentinel
 		uint32 sentinel = file->readUint32BE();
@@ -129,7 +129,7 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
 	delete file;
 
 	if (_newGameFl) {
-		_timeline->f233_initTimeline();
+		_timeline->initTimeline();
 		_groupMan->initActiveGroups();
 
 		if (L1366_B_FadePalette) {
@@ -315,9 +315,9 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 	file->writeByte(_dungeonMan->_partyMapIndex);
 	file->writeSint16BE(_championMan->_leaderIndex);
 	file->writeSint16BE(_championMan->_magicCasterChampionIndex);
-	file->writeUint16BE(_timeline->_g372_eventCount);
-	file->writeUint16BE(_timeline->_g373_firstUnusedEventIndex);
-	file->writeUint16BE(_timeline->_g369_eventMaxCount);
+	file->writeUint16BE(_timeline->_eventCount);
+	file->writeUint16BE(_timeline->_firstUnusedEventIndex);
+	file->writeUint16BE(_timeline->_eventMaxCount);
 	file->writeUint16BE(_groupMan->_currActiveGroupCount);
 	file->writeSint32BE(_projexpl->_lastCreatureAttackTime);
 	file->writeSint32BE(_projexpl->_lastPartyMovementTime);
@@ -332,9 +332,9 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 	// write C2_SAVE_PART_PARTY part
 	_championMan->savePartyPart2(file);
 	// write C3_SAVE_PART_EVENTS part
-	_timeline->save3_eventsPart(file);
+	_timeline->saveEventsPart(file);
 	// write C4_SAVE_PART_TIMELINE part
-	_timeline->save4_timelinePart(file);
+	_timeline->saveTimelinePart(file);
 
 	// write sentinel
 	file->writeUint32BE(0x6f85e3d3);
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 79955b8..a8217dd 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -269,11 +269,11 @@ void MenuMan::drawActionArea() {
 			box = _boxActionArea1ActionMenu;
 		dispMan.blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k10_MenuActionAreaIndice),
 								 &box, k48_byteWidth, kM1_ColorNoTransparency, 45);
-		textMan.f41_printWithTrailingSpaces(dispMan._bitmapScreen, k160_byteWidthScreen,
+		textMan.printWithTrailingSpaces(dispMan._bitmapScreen, k160_byteWidthScreen,
 											235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._actingChampionOrdinal)]._name,
 											k7_ChampionNameMaximumLength, k200_heightScreen);
 		for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) {
-			textMan.f41_printWithTrailingSpaces(dispMan._bitmapScreen, k160_byteWidthScreen, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
+			textMan.printWithTrailingSpaces(dispMan._bitmapScreen, k160_byteWidthScreen, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack,
 												getActionName(_actionList._actionIndices[actionListIndex]),
 												k12_ActionNameMaximumLength, k200_heightScreen);
 		}
@@ -311,7 +311,7 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
 	switch (champIndex) {
 	case 0:
 		_vm->_eventMan->highlightScreenBox(233, 277, 42, 49);
-		_vm->_textMan->f53_printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
+		_vm->_textMan->printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
 		if (_vm->_championMan->_partyChampionCount > 1) {
 			if (champHP1) {
 				_vm->_eventMan->highlightScreenBox(280, 291, 42, 48);
@@ -335,7 +335,7 @@ T0393003:
 			_vm->_eventMan->highlightScreenBox(233, 244, 42, 48);
 		}
 		_vm->_eventMan->highlightScreenBox(247, 291, 42, 49);
-		_vm->_textMan->f53_printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
+		_vm->_textMan->printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
 		goto T0393002;
 	case 2:
 		if (champHP0) {
@@ -345,7 +345,7 @@ T0393003:
 			_vm->_eventMan->highlightScreenBox(247, 258, 42, 48);
 		}
 		_vm->_eventMan->highlightScreenBox(261, 305, 42, 49);
-		_vm->_textMan->f53_printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
+		_vm->_textMan->printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
 		goto T0393003;
 	case 3:
 		if (champHP0) {
@@ -358,7 +358,7 @@ T0393003:
 			_vm->_eventMan->highlightScreenBox(261, 272, 42, 48);
 		}
 		_vm->_eventMan->highlightScreenBox(275, 319, 42, 49);
-		_vm->_textMan->f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
+		_vm->_textMan->printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
 		break;
 	default:
 		break;
@@ -381,7 +381,7 @@ void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
 		char character = 96 + (6 * L1203_ps_Champion->_symbolStep);
 		for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
 			L1204_ac_SpellSymbolString[0] = character++;
-			_vm->_textMan->f40_printTextToBitmap(_bitmapSpellAreaLine, 48, x += 14, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
+			_vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 48, x += 14, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
 		}
 	} else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) {
 		_vm->_displayMan->_useByteBoxCoordinates = false;
@@ -390,7 +390,7 @@ void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
 		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
 			if ((L1204_ac_SpellSymbolString[0] = L1203_ps_Champion->_symbols[symbolIndex]) == '\0')
 				break;
-			_vm->_textMan->f40_printTextToBitmap(_bitmapSpellAreaLine, 48, x += 9, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
+			_vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 48, x += 9, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
 		}
 	}
 }
@@ -587,7 +587,7 @@ T0412019:
 				L1276_s_Event._B._defense >>= 2;
 			}
 			_vm->_championMan->_party._shieldDefense += L1276_s_Event._B._defense;
-			_vm->_timeline->f260_timelineRefreshAllChampionStatusBoxes();
+			_vm->_timeline->refreshAllChampionStatusBoxes();
 			goto T0412032;
 		case k6_spellType_otherFootprints:
 			L1276_s_Event._type = k79_TMEventTypeFootprints;
@@ -602,7 +602,7 @@ T0412032:
 			AL1267_ui_Ticks = AL1267_ui_SpellPower * AL1267_ui_SpellPower;
 T0412033:
 			setMapAndTime(L1276_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + AL1267_ui_Ticks);
-			_vm->_timeline->f238_addEventGetEventIndex(&L1276_s_Event);
+			_vm->_timeline->addEventGetEventIndex(&L1276_s_Event);
 			break;
 		case k7_spellType_otherZokathra:
 			if ((L1272_T_Object = _vm->_dungeonMan->getUnusedThing(k10_JunkThingType)) == Thing::_none)
@@ -695,8 +695,8 @@ void MenuMan::menusPrintSpellFailureMessage(Champion* champ, uint16 failureType,
 	if (skillIndex > k3_ChampionSkillWizard)
 		skillIndex = (skillIndex - 4) / 4;
 
-	_vm->_textMan->f51_messageAreaPrintLineFeed();
-	_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, champ->_name);
+	_vm->_textMan->printLineFeed();
+	_vm->_textMan->printMessage(k4_ColorCyan, champ->_name);
 
 	const char *messages_EN_ANY[4] = {" NEEDS MORE PRACTICE WITH THIS ", " SPELL.", " MUMBLES A MEANINGLESS SPELL."," NEEDS AN EMPTY FLASK IN HAND FOR POTION."};
 	const char *messages_DE_DEU[4] = {" BRAUCHT MEHR UEBUNG MIT DIESEM ", " ZAUBERSPRUCH.",
@@ -716,8 +716,8 @@ void MenuMan::menusPrintSpellFailureMessage(Champion* champ, uint16 failureType,
 
 	switch (failureType) {
 	case k0_failureNeedsMorePractice:
-		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, messages[0]);
-		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, _vm->_championMan->_baseSkillName[skillIndex]);
+		_vm->_textMan->printMessage(k4_ColorCyan, messages[0]);
+		_vm->_textMan->printMessage(k4_ColorCyan, _vm->_championMan->_baseSkillName[skillIndex]);
 		if (_vm->getGameLanguage() != Common::FR_FRA || skillIndex == k3_ChampionSkillWizard)
 			L1264_pc_Message = messages[1];
 		else
@@ -731,7 +731,7 @@ void MenuMan::menusPrintSpellFailureMessage(Champion* champ, uint16 failureType,
 		L1264_pc_Message = messages[3];
 		break;
 	}
-	_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, L1264_pc_Message);
+	_vm->_textMan->printMessage(k4_ColorCyan, L1264_pc_Message);
 }
 
 Potion* MenuMan::getEmptyFlaskInHand(Champion* champ, Thing* potionThing) {
@@ -754,7 +754,7 @@ void MenuMan::createEvent70_light(int16 lightPower, int16 ticks) {
 	L1241_s_Event._B._lightPower = lightPower;
 	setMapAndTime(L1241_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + ticks);
 	L1241_s_Event._priority = 0;
-	_vm->_timeline->f238_addEventGetEventIndex(&L1241_s_Event);
+	_vm->_timeline->addEventGetEventIndex(&L1241_s_Event);
 	_vm->_inventoryMan->setDungeonViewPalette();
 }
 
@@ -792,8 +792,8 @@ bool MenuMan::isPartySpellOrFireShieldSuccessful(Champion* champ, bool spellShie
 	}
 	L1240_s_Event._priority = 0;
 	setMapAndTime(L1240_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + ticks);
-	_vm->_timeline->f238_addEventGetEventIndex(&L1240_s_Event);
-	_vm->_timeline->f260_timelineRefreshAllChampionStatusBoxes();
+	_vm->_timeline->addEventGetEventIndex(&L1240_s_Event);
+	_vm->_timeline->refreshAllChampionStatusBoxes();
 	return L1239_B_IsPartySpellOrFireShieldSuccessful;
 }
 
@@ -808,7 +808,7 @@ void MenuMan::drawAvailableSymbols(uint16 symbolStep) {
 	L1215_i_X = 225;
 	for (L1214_ui_Counter = 0; L1214_ui_Counter < 6; L1214_ui_Counter++) {
 		L1217_ac_String[0] = L1216_c_Character++;
-		_vm->_textMan->f53_printToLogicalScreen(L1215_i_X += 14, 58, k4_ColorCyan, k0_ColorBlack, L1217_ac_String);
+		_vm->_textMan->printToLogicalScreen(L1215_i_X += 14, 58, k4_ColorCyan, k0_ColorBlack, L1217_ac_String);
 	}
 }
 
@@ -828,7 +828,7 @@ void MenuMan::drawChampionSymbols(Champion* champ) {
 		} else {
 			L1221_ac_String[0] = champ->_symbols[L1218_ui_SymbolIndex];
 		}
-		_vm->_textMan->f53_printToLogicalScreen(L1219_i_X += 9, 70, k4_ColorCyan, k0_ColorBlack, L1221_ac_String);
+		_vm->_textMan->printToLogicalScreen(L1219_i_X += 9, 70, k4_ColorCyan, k0_ColorBlack, L1221_ac_String);
 	}
 }
 
@@ -897,7 +897,7 @@ bool MenuMan::didClickTriggerAction(int16 actionListIndex) {
 		L1198_B_ClickTriggeredAction = true;
 	} else {
 		L1197_ui_ActionIndex = _actionList._actionIndices[actionListIndex];
-		L1199_ps_Champion->_actionDefense += g495_actionDefense[L1197_ui_ActionIndex]; /* BUG0_54 The defense modifier of an action is permanent.
+		L1199_ps_Champion->_actionDefense += _actionDefense[L1197_ui_ActionIndex]; /* BUG0_54 The defense modifier of an action is permanent.
 																									 Each action has an associated defense modifier value and a number of ticks while the champion cannot perform another action because the action icon is grayed out. If an action has a non zero defense modifier and a zero value for the number of ticks then the defense modifier is applied but it is never removed. This causes no issue in the original games because there are no actions in this case but it may occur in a version where data is customized. This statement should only be executed if the value for the action in G0491_auc_Graphic560_ActionDisabledTicks is not 0 otherwise the action is not disabled at the end of F0407_MENUS_IsActionPerformed and thus not enabled later in F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction where the defense modifier is also removed */
 		setFlag(L1199_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
 		L1198_B_ClickTriggeredAction = isActionPerformed(L1196_ui_ChampionIndex, L1197_ui_ActionIndex);
@@ -1129,10 +1129,10 @@ T0407014:
 	case k13_ChampionActionSwing:
 	case k2_ChampionActionChop:
 		if ((Square(AL1244_ui_TargetSquare).getType() == k4_DoorElemType) && (Square(AL1244_ui_TargetSquare).getDoorState() == k4_doorState_CLOSED)) {
-			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
+			_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 			L1249_ui_ActionDisabledTicks = 6;
 			_vm->_groupMan->groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
-			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k2_soundModePlayOneTickLater);
+			_vm->_sound->requestPlay(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k2_soundModePlayOneTickLater);
 			break;
 		}
 	case k24_ChampionActionDisrupt:
@@ -1158,10 +1158,10 @@ T0407014:
 	case k41_ChampionActionBrandish:
 	case k4_ChampionActionBlowHorn:
 		if (actionIndex == k8_ChampionActionWarCry) {
-			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k28_soundWAR_CRY, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
+			_vm->_sound->requestPlay(k28_soundWAR_CRY, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
 		}
 		if (actionIndex == k4_ChampionActionBlowHorn) {
-			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k25_soundBLOW_HORN, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
+			_vm->_sound->requestPlay(k25_soundBLOW_HORN, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
 		}
 		AL1245_B_ActionPerformed = isGroupFrightenedByAction(champIndex, actionIndex, L1251_i_MapX, L1252_i_MapY);
 		break;
@@ -1191,7 +1191,7 @@ T0407032:
 		setChampionDirectionToPartyDirection(L1247_ps_Champion);
 		{ // so gotos won't skip init
 			Thing AL1250_T_Object = _vm->_championMan->getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
-			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
+			_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 			_vm->_championMan->championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy);
 		}
 		break;
@@ -1274,7 +1274,7 @@ T0407032:
 		L1258_s_Event._priority = 0;
 		L1258_s_Event._type = k73_TMEventTypeThievesEye;
 		setMapAndTime(L1258_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + AL1246_i_Ticks);
-		_vm->_timeline->f238_addEventGetEventIndex(&L1258_s_Event);
+		_vm->_timeline->addEventGetEventIndex(&L1258_s_Event);
 		_vm->_championMan->_party._event73Count_ThievesEye++;
 		goto T0407076;
 	case k10_ChampionActionClimbDown:
@@ -1318,7 +1318,7 @@ T0407076:
 		setChampionDirectionToPartyDirection(L1247_ps_Champion);
 		AL1245_B_ActionPerformed = _vm->_championMan->isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_partyDir)) || (L1247_ps_Champion->_cell == (ViewCell)returnOppositeDir(_vm->_dungeonMan->_partyDir)));
 		if (AL1245_B_ActionPerformed) {
-			_vm->_timeline->_g370_events[L1247_ps_Champion->_enableActionEventIndex]._B._slotOrdinal = _vm->indexToOrdinal(k1_ChampionSlotActionHand);
+			_vm->_timeline->_events[L1247_ps_Champion->_enableActionEventIndex]._B._slotOrdinal = _vm->indexToOrdinal(k1_ChampionSlotActionHand);
 		}
 	}
 	if (L1249_ui_ActionDisabledTicks) {
@@ -1469,7 +1469,7 @@ bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion* champ, int16 ac
 #define AL1237_ui_ActionHitProbability L1237_ui_Multiple
 	int16 L1238_i_CreatureOrdinal;
 
-	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
+	_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 	if (_actionTargetGroupThing == Thing::_endOfList)
 		goto T0402010;
 	L1238_i_CreatureOrdinal = _vm->_groupMan->getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, AL1236_ui_ChampionCell = champ->_cell);
@@ -1582,7 +1582,7 @@ void MenuMan::printMessageAfterReplacements(const char* str) {
 	} while (*str++);
 	*L1164_pc_Character = '\0';
 	if (L1166_ac_OutputString[1]) { /* If the string is not empty (the first character is a new line \n) */
-		_vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, L1166_ac_OutputString);
+		_vm->_textMan->printMessage(k4_ColorCyan, L1166_ac_OutputString);
 	}
 }
 
@@ -1751,7 +1751,7 @@ void MenuMan::drawActionDamage(int16 damage) {
 			AL1176_i_X = pos[1];
 			AL1178_puc_String = (byte*)message[1];
 		}
-		_vm->_textMan->f53_printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, (char *)AL1178_puc_String);
+		_vm->_textMan->printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, (char *)AL1178_puc_String);
 	} else {
 		if (damage > 40) {
 			L1180_ps_Box = &_boxActionArea3ActionMenu;
@@ -1789,7 +1789,7 @@ void MenuMan::drawActionDamage(int16 damage) {
 			L1179_ac_String[--AL1174_ui_CharacterIndex] = '0' + (damage % 10);
 			AL1176_i_X -= 3;
 		} while (damage /= 10);
-		_vm->_textMan->f53_printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, &L1179_ac_String[AL1174_ui_CharacterIndex]);
+		_vm->_textMan->printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, &L1179_ac_String[AL1174_ui_CharacterIndex]);
 	}
 	_vm->_eventMan->hideMouse();
 }
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 694d135..58a4f64 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -182,7 +182,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 			if (!L0753_B_DoNotTriggerSensor) {
 				L0759_B_AtLeastOneSensorWasTriggered = true;
 				if (L0755_ps_Sensor->getAttrAudibleA()) {
-					_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
+					_vm->_sound->requestPlay(k01_soundSWITCH, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 				}
 				if (!_vm->_championMan->_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
 					L0754_ps_Generic = (Thing *)_vm->_dungeonMan->getThingData(L0761_T_LeaderHandObject);
@@ -279,7 +279,7 @@ bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destM
 		}
 		if (L0710_i_ThingType == k14_ProjectileThingType) {
 			L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(thing);
-			_moveResultDir = (_vm->_timeline->_g370_events[((Projectile *)L0712_ps_Teleporter)->_eventIndex])._C._projectile.getDir();
+			_moveResultDir = (_vm->_timeline->_events[((Projectile *)L0712_ps_Teleporter)->_eventIndex])._C._projectile.getDir();
 		}
 		for (L0728_i_ChainedMoveCount = 1000; --L0728_i_ChainedMoveCount; ) { /* No more than 1000 chained moves at once (in a chain of teleporters and pits for example) */
 			AL0708_i_DestinationSquare = _vm->_dungeonMan->_currMapData[destMapX][destMapY];
@@ -300,7 +300,7 @@ bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destM
 					_vm->_dungeonMan->_partyMapX = destMapX;
 					_vm->_dungeonMan->_partyMapY = destMapY;
 					if (L0712_ps_Teleporter->isAudible()) {
-						_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
+						_vm->_sound->requestPlay(k17_soundBUZZ, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
 					}
 					L0723_B_DrawDungeonViewWhileFalling = true;
 					if (L0712_ps_Teleporter->getAbsoluteRotation()) {
@@ -311,7 +311,7 @@ bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destM
 				} else {
 					if (L0710_i_ThingType == k4_GroupThingType) {
 						if (L0712_ps_Teleporter->isAudible()) {
-							_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, destMapX, destMapY, k1_soundModePlayIfPrioritized);
+							_vm->_sound->requestPlay(k17_soundBUZZ, destMapX, destMapY, k1_soundModePlayIfPrioritized);
 						}
 						L0720_ui_MoveGroupResult = getTeleporterRotatedGroupResult(L0712_ps_Teleporter, thing, L0714_ui_MapIndexSource);
 					} else {
@@ -353,7 +353,7 @@ bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destM
 								}
 							} else {
 								if (_vm->_championMan->getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF)) {
-									_vm->_sound->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
+									_vm->_sound->requestPlay(k06_soundSCREAM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
 								}
 							}
 						}
@@ -482,7 +482,7 @@ bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destM
 				}
 				L1638_ui_MovementSoundIndex = getSound(((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[thing.getIndex()]._type);
 				if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) {
-					_vm->_sound->f064_SOUND_RequestPlay_CPSD(L1638_ui_MovementSoundIndex, destMapX, destMapY, k1_soundModePlayIfPrioritized);
+					_vm->_sound->requestPlay(L1638_ui_MovementSoundIndex, destMapX, destMapY, k1_soundModePlayIfPrioritized);
 				}
 				if (L0721_B_GroupOnPartyMap && (L0715_ui_MapIndexDestination != _vm->_dungeonMan->_partyMapIndex)) { /* If the group leaves the party map */
 					_vm->_groupMan->removeActiveGroup(AL0708_i_ActiveGroupIndex);
@@ -611,7 +611,7 @@ T0266017_CheckProjectileImpacts:
 	L0697_T_Thing = _vm->_dungeonMan->getSquareFirstThing(L0704_ui_ProjectileMapX, L0705_ui_ProjectileMapY);
 	while (L0697_T_Thing != Thing::_endOfList) {
 		if (((L0697_T_Thing).getType() == k14_ProjectileThingType) &&
-			(_vm->_timeline->_g370_events[(((Projectile *)_vm->_dungeonMan->_thingData[k14_ProjectileThingType])[(L0697_T_Thing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts) && (AL0699_ui_ChampionOrCreatureOrdinal = L0707_auc_ChampionOrCreatureOrdinalInCell[(L0697_T_Thing).getCell()]) &&
+			(_vm->_timeline->_events[(((Projectile *)_vm->_dungeonMan->_thingData[k14_ProjectileThingType])[(L0697_T_Thing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts) && (AL0699_ui_ChampionOrCreatureOrdinal = L0707_auc_ChampionOrCreatureOrdinalInCell[(L0697_T_Thing).getCell()]) &&
 			_vm->_projexpl->hasProjectileImpactOccurred(L0702_i_ImpactType, srcMapX, srcMapY, _vm->ordinalToIndex(AL0699_ui_ChampionOrCreatureOrdinal), L0697_T_Thing)) {
 			_vm->_projexpl->projectileDeleteEvent(L0697_T_Thing);
 			if (_vm->_projexpl->_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup) {
@@ -642,7 +642,7 @@ void MovesensMan::addEvent(byte type, byte mapX, byte mapY, byte cell, byte effe
 	L0729_s_Event._B._location._mapY = mapY;
 	L0729_s_Event._C.A._cell = cell;
 	L0729_s_Event._C.A._effect = effect;
-	_vm->_timeline->f238_addEventGetEventIndex(&L0729_s_Event);
+	_vm->_timeline->addEventGetEventIndex(&L0729_s_Event);
 }
 
 int16 MovesensMan::getSound(byte creatureType) {
@@ -799,7 +799,7 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 			} else {
 				if ((L0771_ui_ThingType == k2_TextstringType) && (L0767_i_ThingType == kM1_PartyThingType) && addThing && !partySquare) {
 					_vm->_dungeonMan->decodeText(_vm->_stringBuildBuffer, L0766_T_Thing, k1_TextTypeMessage);
-					_vm->_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, _vm->_stringBuildBuffer);
+					_vm->_textMan->printMessage(k15_ColorWhite, _vm->_stringBuildBuffer);
 				} else {
 					if ((L0771_ui_ThingType > k4_GroupThingType) && (L0771_ui_ThingType < k14_ProjectileThingType)) {
 						L0772_B_SquareContainsObject = true;
@@ -912,7 +912,7 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 				goto T0276079;
 
 			if (L0769_ps_Sensor->getAttrAudibleA())
-				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized);
+				_vm->_sound->requestPlay(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized);
 
 			triggerEffect(L0769_ps_Sensor, L0778_i_Effect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
 			goto T0276079;
@@ -1080,7 +1080,7 @@ void MovesensMan::createEventMoveGroup(Thing groupThing, int16 mapX, int16 mapY,
 	L0696_s_Event._B._location._mapX = mapX;
 	L0696_s_Event._B._location._mapY = mapY;
 	L0696_s_Event._C._slot = groupThing.toUint16();
-	_vm->_timeline->f238_addEventGetEventIndex(&L0696_s_Event);
+	_vm->_timeline->addEventGetEventIndex(&L0696_s_Event);
 }
 
 Thing MovesensMan::getObjectOfTypeInCell(int16 mapX, int16 mapY, int16 cell, int16 objectType) {
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 8bf1285..75865fb 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -259,7 +259,7 @@ void ObjectMan::drawLeaderObjectName(Thing thing) {
 	} else {
 		objectName = _objectNames[L0007_i_IconIndex];
 	}
-	_vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, 233, 37, k4_ColorCyan, k0_ColorBlack, objectName, k14_ObjectNameMaximumLength, k200_heightScreen);
+	_vm->_textMan->printWithTrailingSpaces(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, 233, 37, k4_ColorCyan, k0_ColorBlack, objectName, k14_ObjectNameMaximumLength, k200_heightScreen);
 }
 
 IconIndice ObjectMan::getIconIndexInSlotBox(uint16 slotBoxIndex) {
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index aab6e7c..bcaca84 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -73,7 +73,7 @@ void ProjExpl::createProjectile(Thing thing, int16 mapX, int16 mapY, uint16 cell
 	L0468_s_Event._C._projectile.setMapY(mapY);
 	L0468_s_Event._C._projectile.setStepEnergy(stepEnergy);
 	L0468_s_Event._C._projectile.setDir(dir);
-	L0467_ps_Projectile->_eventIndex = _vm->_timeline->f238_addEventGetEventIndex(&L0468_s_Event);
+	L0467_ps_Projectile->_eventIndex = _vm->_timeline->addEventGetEventIndex(&L0468_s_Event);
 }
 
 bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, int16 mapYCombo, int16 cell, Thing projectileThing) {
@@ -235,7 +235,7 @@ T0217004:
 				AL0507_ui_SoundIndex = k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM;
 			}
 		}
-		_vm->_sound->f064_SOUND_RequestPlay_CPSD(AL0507_ui_SoundIndex, L0499_i_ProjectileMapX, L0500_i_ProjectileMapY, k1_soundModePlayIfPrioritized);
+		_vm->_sound->requestPlay(AL0507_ui_SoundIndex, L0499_i_ProjectileMapX, L0500_i_ProjectileMapY, k1_soundModePlayIfPrioritized);
 	}
 T0217044:
 	if (L0509_B_RemovePotion) {
@@ -326,10 +326,10 @@ void ProjExpl::createExplosion(Thing explThing, uint16 attack, uint16 mapXCombo,
 	L0470_ps_Explosion->setType(explThing.toUint16() - Thing::_firstExplosion.toUint16());
 	L0470_ps_Explosion->setAttack(attack);
 	if (explThing.toUint16() < Thing::_explHarmNonMaterial.toUint16()) {
-		_vm->_sound->f064_SOUND_RequestPlay_CPSD((attack > 80) ? k05_soundSTRONG_EXPLOSION : k20_soundWEAK_EXPLOSION, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized);
+		_vm->_sound->requestPlay((attack > 80) ? k05_soundSTRONG_EXPLOSION : k20_soundWEAK_EXPLOSION, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized);
 	} else {
 		if (explThing != Thing::_explSmoke) {
-			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized);
+			_vm->_sound->requestPlay(k13_soundSPELL, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized);
 		}
 	}
 	_vm->_dungeonMan->linkThingToList(L0473_T_Thing, Thing(0), AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY);
@@ -340,7 +340,7 @@ void ProjExpl::createExplosion(Thing explThing, uint16 attack, uint16 mapXCombo,
 	L0476_s_Event._C._slot = L0473_T_Thing.toUint16();
 	L0476_s_Event._B._location._mapX = AP0443_ui_ProjectileMapX;
 	L0476_s_Event._B._location._mapY = AP0444_ui_ProjectileMapY;
-	_vm->_timeline->f238_addEventGetEventIndex(&L0476_s_Event);
+	_vm->_timeline->addEventGetEventIndex(&L0476_s_Event);
 	if ((explThing == Thing::_explLightningBolt) || (explThing == Thing::_explFireBall)) {
 		AP0443_ui_ProjectileMapX = L0474_i_ProjectileTargetMapX;
 		AP0444_ui_ProjectileMapY = L0475_i_ProjectileTargetMapY;
@@ -397,7 +397,7 @@ void ProjExpl::projectileDeleteEvent(Thing thing) {
 
 
 	L0477_ps_Projectile = (Projectile *)_vm->_dungeonMan->getThingData(thing);
-	_vm->_timeline->f237_deleteEvent(L0477_ps_Projectile->_eventIndex);
+	_vm->_timeline->deleteEvent(L0477_ps_Projectile->_eventIndex);
 }
 
 void ProjExpl::projectileDelete(Thing projectileThing, Thing* groupSlot, int16 mapX, int16 mapY) {
@@ -508,7 +508,7 @@ void ProjExpl::processEvents48To49(TimelineEvent* event) {
 	L0519_ps_Event->Map_Time++;
 #endif
 	L0519_ps_Event->_B._slot = L0515_T_ProjectileThingNewCell.toUint16();
-	L0520_ps_Projectile->_eventIndex = _vm->_timeline->f238_addEventGetEventIndex(L0519_ps_Event);
+	L0520_ps_Projectile->_eventIndex = _vm->_timeline->addEventGetEventIndex(L0519_ps_Event);
 }
 
 void ProjExpl::processEvent25(TimelineEvent* event) {
@@ -574,7 +574,7 @@ void ProjExpl::processEvent25(TimelineEvent* event) {
 		break;
 	case 0xFFE4:
 		L0532_ps_Explosion->setType(L0532_ps_Explosion->getType() + 1);
-		_vm->_sound->f064_SOUND_RequestPlay_CPSD(k05_soundSTRONG_EXPLOSION, L0528_ui_MapX, L0529_ui_MapY, k1_soundModePlayIfPrioritized);
+		_vm->_sound->requestPlay(k05_soundSTRONG_EXPLOSION, L0528_ui_MapX, L0529_ui_MapY, k1_soundModePlayIfPrioritized);
 		goto T0220026;
 	case 0xFFA8:
 		if (L0532_ps_Explosion->getAttack() > 55) {
@@ -595,7 +595,7 @@ void ProjExpl::processEvent25(TimelineEvent* event) {
 T0220026:
 			L0539_s_Event = *event;
 			L0539_s_Event._mapTime++;
-			_vm->_timeline->f238_addEventGetEventIndex(&L0539_s_Event);
+			_vm->_timeline->addEventGetEventIndex(&L0539_s_Event);
 			return;
 		}
 	}
diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp
index bb1bd1f..886e5fd 100644
--- a/engines/dm/sounds.cpp
+++ b/engines/dm/sounds.cpp
@@ -85,7 +85,7 @@ void SoundMan::initConstants() {
 		Sound(574, 150,  22, 0, 4)  /* k33_soundMOVE_SKELETON 33 Atari ST: not present */
 	};
 	for (int i = 0; i < k34_D13_soundCount; i++)
-		g60_sounds[i] = sounds[i];
+		_sounds[i] = sounds[i];
 }
 
 SoundMan::SoundMan(DMEngine* vm) : _vm(vm) {
@@ -94,14 +94,14 @@ SoundMan::SoundMan(DMEngine* vm) : _vm(vm) {
 
 SoundMan::~SoundMan() {
 	for (uint16 i = 0; i < k34_D13_soundCount; ++i)
-		delete[] _gK24_soundData[i]._firstSample;
+		delete[] _soundData[i]._firstSample;
 }
 
-void SoundMan::f503_loadSounds() {
+void SoundMan::loadSounds() {
 	for (uint16 soundIndex = 0; soundIndex < k34_D13_soundCount; ++soundIndex) {
-		SoundData *soundData = _gK24_soundData + soundIndex;
+		SoundData *soundData = _soundData + soundIndex;
 
-		uint16 graphicIndex = g60_sounds[soundIndex]._graphicIndex;
+		uint16 graphicIndex = _sounds[soundIndex]._graphicIndex;
 		soundData->_byteCount = _vm->_displayMan->getCompressedDataSize(graphicIndex) - 2; // the header is 2 bytes long
 		soundData->_firstSample = new byte[soundData->_byteCount];
 
@@ -111,8 +111,8 @@ void SoundMan::f503_loadSounds() {
 	}
 }
 
-void SoundMan::f060_SOUND_Play(uint16 soundIndex, uint16 period, uint8 leftVolume, uint8 rightVolume) {
-	SoundData *sound = &_gK24_soundData[soundIndex];
+void SoundMan::play(uint16 soundIndex, uint16 period, uint8 leftVolume, uint8 rightVolume) {
+	SoundData *sound = &_soundData[soundIndex];
 	Audio::AudioStream *stream = Audio::makeRawStream(sound->_firstSample, sound->_byteCount, (72800 / period) * 8, 0, DisposeAfterUse::NO);
 
 	signed char balance = ((int16)rightVolume - (int16)leftVolume) / 2;
@@ -121,14 +121,14 @@ void SoundMan::f060_SOUND_Play(uint16 soundIndex, uint16 period, uint8 leftVolum
 	_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &handle, stream, -1, 127, balance);
 }
 
-void SoundMan::f65_playPendingSound() {
+void SoundMan::playPendingSound() {
 	while (!_pendingSounds.empty()) {
 		PendingSound pendingSound = _pendingSounds.pop();
-		f060_SOUND_Play(pendingSound._soundIndex, g60_sounds[pendingSound._soundIndex]._period, pendingSound._leftVolume, pendingSound._rightVolume);
+		play(pendingSound._soundIndex, _sounds[pendingSound._soundIndex]._period, pendingSound._leftVolume, pendingSound._rightVolume);
 	}
 }
 
-bool SoundMan::f505_soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, uint8* rightVolume) {
+bool SoundMan::soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, uint8* rightVolume) {
 	static byte K0030_aauc_DistanceToSoundVolume[25][25] = {
 		{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4,  5,  5,  5,  5,  5,  5,  5, 5, 4, 4, 4, 4, 4},
 		{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 5,  6,  6,  6,  6,  5,  5,  5, 5, 5, 5, 4, 4, 4},
@@ -193,14 +193,14 @@ bool SoundMan::f505_soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, ui
 	return true;
 }
 
-void SoundMan::f064_SOUND_RequestPlay_CPSD(uint16 soundIndex, int16 mapX, int16 mapY, uint16 mode) {
+void SoundMan::requestPlay(uint16 soundIndex, int16 mapX, int16 mapY, uint16 mode) {
 	Sound* sound;
 	uint8 leftVolume, rightVolume;
 
 	if (mode && (_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex))
 		return;
 
-	sound = &g60_sounds[soundIndex];
+	sound = &_sounds[soundIndex];
 	if (mode > k1_soundModePlayIfPrioritized) { /* Add an event in the timeline to play the sound (mode - 1) ticks later */
 		TimelineEvent event;
 		setMapAndTime(event._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + mode - 1);
@@ -209,15 +209,15 @@ void SoundMan::f064_SOUND_RequestPlay_CPSD(uint16 soundIndex, int16 mapX, int16
 		event._C._soundIndex = soundIndex;
 		event._B._location._mapX = mapX;
 		event._B._location._mapY = mapY;
-		_vm->_timeline->f238_addEventGetEventIndex(&event);
+		_vm->_timeline->addEventGetEventIndex(&event);
 		return;
 	}
 
-	if (!f505_soundGetVolume(mapX, mapY, &leftVolume, &rightVolume)) {
+	if (!soundGetVolume(mapX, mapY, &leftVolume, &rightVolume)) {
 		return;
 	}
 	if (!mode) { /* Play the sound immediately */
-		f060_SOUND_Play(soundIndex, sound->_period, leftVolume, rightVolume);
+		play(soundIndex, sound->_period, leftVolume, rightVolume);
 		return;
 	}
 	_pendingSounds.push(PendingSound(leftVolume, rightVolume, soundIndex));
diff --git a/engines/dm/sounds.h b/engines/dm/sounds.h
index 3c8c6cd..e449274 100644
--- a/engines/dm/sounds.h
+++ b/engines/dm/sounds.h
@@ -60,7 +60,6 @@ public:
 		_leftVolume(leftVolume), _rightVolume(rightVolume), _soundIndex(soundIndex) {}
 };
 
-
 class SoundMan {
 	DMEngine *_vm;
 
@@ -71,16 +70,16 @@ public:
 
 	static SoundMan *getSoundMan(DMEngine *vm, const DMADGameDescription *gameVersion);
 
-	SoundData _gK24_soundData[k34_D13_soundCount]; // @ K0024_as_SoundData
+	SoundData _soundData[k34_D13_soundCount]; // @ K0024_as_SoundData
 	Common::Queue<PendingSound> _pendingSounds;
 
-	virtual void f503_loadSounds(); // @ F0503_SOUND_LoadAll
-	virtual void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode); // @ F0064_SOUND_RequestPlay_CPSD
-	virtual void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol); // @ F0060_SOUND_Play
-	void f65_playPendingSound(); // @ F0065_SOUND_PlayPendingSound_CPSD
-	bool f505_soundGetVolume(int16 mapX, int16 mapY, uint8 *leftVolume, uint8 *rightVolume); // @ F0505_SOUND_GetVolume
+	virtual void loadSounds(); // @ F0503_SOUND_LoadAll
+	virtual void requestPlay(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode); // @ F0064_SOUND_RequestPlay_CPSD
+	virtual void play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol); // @ F0060_SOUND_Play
+	void playPendingSound(); // @ F0065_SOUND_PlayPendingSound_CPSD
+	bool soundGetVolume(int16 mapX, int16 mapY, uint8 *leftVolume, uint8 *rightVolume); // @ F0505_SOUND_GetVolume
 
-	Sound g60_sounds[k34_D13_soundCount];
+	Sound _sounds[k34_D13_soundCount];
 	void initConstants();
 };
 
@@ -89,9 +88,9 @@ class SoundMan_Atari: public SoundMan {
 
 	SoundMan_Atari(DMEngine* vm): SoundMan(vm) {};
 public:
-	void f503_loadSounds() override {} // @ F0503_SOUND_LoadAll
-	void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode) override {} // @ F0064_SOUND_RequestPlay_CPSD
-	void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol) override {} // @ F0060_SOUND_Play
+	void loadSounds() override {} // @ F0503_SOUND_LoadAll
+	void requestPlay(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode) override {} // @ F0064_SOUND_RequestPlay_CPSD
+	void play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol) override {} // @ F0060_SOUND_Play
 };
 
 }
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 68feba8..6dd906c 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -31,21 +31,21 @@
 namespace DM {
 
 TextMan::TextMan(DMEngine* vm) : _vm(vm) {
-	_g359_messageAreaCursorColumn = 0;
-	_g358_messageAreaCursorRow = 0;
+	_messageAreaCursorColumn = 0;
+	_messageAreaCursorRow = 0;
 	for (uint16 i = 0; i < 4; ++i)
-		_g360_messageAreaRowExpirationTime[i] = 0;
-	_g356_bitmapMessageAreaNewRow = new byte[320 * 7];
+		_messageAreaRowExpirationTime[i] = 0;
+	_bitmapMessageAreaNewRow = new byte[320 * 7];
 }
 
 TextMan::~TextMan() {
-	delete[] _g356_bitmapMessageAreaNewRow;
+	delete[] _bitmapMessageAreaNewRow;
 }
 
 #define k5_LetterWidth 5
 #define k6_LetterHeight 6
 
-void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int16 destX, int16 destY,
+void TextMan::printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int16 destX, int16 destY,
 									Color textColor, Color bgColor, const char* text, uint16 destHeight) {
 	if ((destX -= 1) < 0) // fixes missalignment, to be checked
 		destX = 0;
@@ -82,27 +82,27 @@ void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int1
 	}
 }
 
-void TextMan::f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text) {
-	f40_printTextToBitmap(_vm->_displayMan->_bitmapScreen, _vm->_displayMan->_screenWidth / 2, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight);
+void TextMan::printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text) {
+	printTextToBitmap(_vm->_displayMan->_bitmapScreen, _vm->_displayMan->_screenWidth / 2, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight);
 }
 
-void TextMan::f52_printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) {
-	f40_printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, posX, posY, textColor, bgColor, text, k136_heightViewport);
+void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) {
+	printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, posX, posY, textColor, bgColor, text, k136_heightViewport);
 }
 
-void TextMan::f41_printWithTrailingSpaces(byte* destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor,
+void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor,
 										  Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight) {
 	Common::String str = text;
 	for (int16 i = str.size(); i < requiredTextLength; ++i)
 		str += ' ';
-	f40_printTextToBitmap(destBitmap, destByteWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight);
+	printTextToBitmap(destBitmap, destByteWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight);
 }
 
-void TextMan::f51_messageAreaPrintLineFeed() {
-	f47_messageAreaPrintMessage(k0_ColorBlack, "\n");
+void TextMan::printLineFeed() {
+	printMessage(k0_ColorBlack, "\n");
 }
 
-void TextMan::f47_messageAreaPrintMessage(Color color, const char* string) {
+void TextMan::printMessage(Color color, const char* string) {
 	uint16 L0031_ui_CharacterIndex;
 	char L0033_ac_String[54];
 
@@ -110,15 +110,15 @@ void TextMan::f47_messageAreaPrintMessage(Color color, const char* string) {
 	while (*string) {
 		if (*string == '\n') { /* New line */
 			string++;
-			if ((_g359_messageAreaCursorColumn != 0) || (_g358_messageAreaCursorRow != 0)) {
-				_g359_messageAreaCursorColumn = 0;
-				f45_messageAreaCreateNewRow();
+			if ((_messageAreaCursorColumn != 0) || (_messageAreaCursorRow != 0)) {
+				_messageAreaCursorColumn = 0;
+				createNewRow();
 			}
 		} else {
 			if (*string == ' ') {
 				string++;
-				if (_g359_messageAreaCursorColumn != 53) {
-					f46_messageAreaPrintString(color, " "); // TODO: I'm not sure this is like the original
+				if (_messageAreaCursorColumn != 53) {
+					printString(color, " "); // TODO: I'm not sure this is like the original
 				}
 			} else {
 				L0031_ui_CharacterIndex = 0;
@@ -126,56 +126,56 @@ void TextMan::f47_messageAreaPrintMessage(Color color, const char* string) {
 					L0033_ac_String[L0031_ui_CharacterIndex++] = *string++;
 				} while (*string && (*string != ' ') && (*string != '\n')); /* End of string, space or New line */
 				L0033_ac_String[L0031_ui_CharacterIndex] = '\0';
-				if (_g359_messageAreaCursorColumn + L0031_ui_CharacterIndex > 53) {
-					_g359_messageAreaCursorColumn = 2;
-					f45_messageAreaCreateNewRow();
+				if (_messageAreaCursorColumn + L0031_ui_CharacterIndex > 53) {
+					_messageAreaCursorColumn = 2;
+					createNewRow();
 				}
-				f46_messageAreaPrintString(color, L0033_ac_String);
+				printString(color, L0033_ac_String);
 			}
 		}
 	}
 }
 
-void TextMan::f45_messageAreaCreateNewRow() {
+void TextMan::createNewRow() {
 	uint16 L0029_ui_RowIndex;
 
-	if (_g358_messageAreaCursorRow == 3) {
-		f561_isTextScrolling(&_gK60_s_TextScroller, true);
-		memset(_g356_bitmapMessageAreaNewRow, k0_ColorBlack, 320 * 7);
-		f560_SCROLLER_setCommand(&_gK60_s_TextScroller, 1);
+	if (_messageAreaCursorRow == 3) {
+		isTextScrolling(&_textScroller, true);
+		memset(_bitmapMessageAreaNewRow, k0_ColorBlack, 320 * 7);
+		setScrollerCommand(&_textScroller, 1);
 
 		for (L0029_ui_RowIndex = 0; L0029_ui_RowIndex < 3; L0029_ui_RowIndex++) {
-			_g360_messageAreaRowExpirationTime[L0029_ui_RowIndex] = _g360_messageAreaRowExpirationTime[L0029_ui_RowIndex + 1];
+			_messageAreaRowExpirationTime[L0029_ui_RowIndex] = _messageAreaRowExpirationTime[L0029_ui_RowIndex + 1];
 		}
-		_g360_messageAreaRowExpirationTime[3] = -1;
+		_messageAreaRowExpirationTime[3] = -1;
 	} else {
-		_g358_messageAreaCursorRow++;
+		_messageAreaCursorRow++;
 	}
 }
 
-void TextMan::f46_messageAreaPrintString(Color color, const char* string) {
+void TextMan::printString(Color color, const char* string) {
 	int16 L0030_i_StringLength;
 
 	L0030_i_StringLength = strlen(string);
-	if (f561_isTextScrolling(&_gK60_s_TextScroller, false)) {
-		f53_printToLogicalScreen(_g359_messageAreaCursorColumn * 6, (_g358_messageAreaCursorRow * 7 - 6) + 177, color, k0_ColorBlack, string);
+	if (isTextScrolling(&_textScroller, false)) {
+		printToLogicalScreen(_messageAreaCursorColumn * 6, (_messageAreaCursorRow * 7 - 6) + 177, color, k0_ColorBlack, string);
 	} else {
-		f40_printTextToBitmap(_g356_bitmapMessageAreaNewRow, k160_byteWidthScreen, _g359_messageAreaCursorColumn * 6, 5, color, k0_ColorBlack, string, 7);
-		if (f561_isTextScrolling(&_gK60_s_TextScroller, false))
-			f560_SCROLLER_setCommand(&_gK60_s_TextScroller, 1);
+		printTextToBitmap(_bitmapMessageAreaNewRow, k160_byteWidthScreen, _messageAreaCursorColumn * 6, 5, color, k0_ColorBlack, string, 7);
+		if (isTextScrolling(&_textScroller, false))
+			setScrollerCommand(&_textScroller, 1);
 	}
-	_g359_messageAreaCursorColumn += L0030_i_StringLength;
-	_g360_messageAreaRowExpirationTime[_g358_messageAreaCursorRow] = _vm->_gameTime + 200;
+	_messageAreaCursorColumn += L0030_i_StringLength;
+	_messageAreaRowExpirationTime[_messageAreaCursorRow] = _vm->_gameTime + 200;
 
 }
 
-void TextMan::f54_textInitialize() {
-	f42_messageAreaMoveCursor(0, 3);
+void TextMan::initialize() {
+	moveCursor(0, 3);
 	for (uint16 i = 0; i < 4; ++i)
-		_g360_messageAreaRowExpirationTime[i] = -1;
+		_messageAreaRowExpirationTime[i] = -1;
 }
 
-void TextMan::f42_messageAreaMoveCursor(int16 column, int16 row) {
+void TextMan::moveCursor(int16 column, int16 row) {
 	if (column < 0) {
 		column = 0;
 	} else {
@@ -183,7 +183,7 @@ void TextMan::f42_messageAreaMoveCursor(int16 column, int16 row) {
 			column = 52;
 		}
 	}
-	_g359_messageAreaCursorColumn = column;
+	_messageAreaCursorColumn = column;
 	if (row < 0) {
 		row = 0;
 	} else {
@@ -191,10 +191,10 @@ void TextMan::f42_messageAreaMoveCursor(int16 column, int16 row) {
 			row = 3;
 		}
 	}
-	_g358_messageAreaCursorRow = row;
+	_messageAreaCursorRow = row;
 }
 
-void TextMan::f44_messageAreaClearExpiredRows() {
+void TextMan::clearExpiredRows() {
 	uint16 L0026_ui_RowIndex;
 	int32 L0027_l_ExpirationTime;
 	Box L0028_s_Box;
@@ -203,17 +203,17 @@ void TextMan::f44_messageAreaClearExpiredRows() {
 	L0028_s_Box._x1 = 0;
 	L0028_s_Box._x2 = 319;
 	for (L0026_ui_RowIndex = 0; L0026_ui_RowIndex < 4; L0026_ui_RowIndex++) {
-		L0027_l_ExpirationTime = _g360_messageAreaRowExpirationTime[L0026_ui_RowIndex];
+		L0027_l_ExpirationTime = _messageAreaRowExpirationTime[L0026_ui_RowIndex];
 		if ((L0027_l_ExpirationTime == -1) || (L0027_l_ExpirationTime > _vm->_gameTime))
 			continue;
 		L0028_s_Box._y2 = (L0028_s_Box._y1 = 172 + (L0026_ui_RowIndex * 7)) + 6;
-		f561_isTextScrolling(&_gK60_s_TextScroller, true);
+		isTextScrolling(&_textScroller, true);
 		_vm->_displayMan->fillBoxBitmap(_vm->_displayMan->_bitmapScreen, L0028_s_Box, k0_ColorBlack, k160_byteWidthScreen, k200_heightScreen);
-		_g360_messageAreaRowExpirationTime[L0026_ui_RowIndex] = -1;
+		_messageAreaRowExpirationTime[L0026_ui_RowIndex] = -1;
 	}
 }
 
-void TextMan::f443_endgamePrintString(int16 x, int16 y, Color textColor, char* text) {
+void TextMan::printEndGameString(int16 x, int16 y, Color textColor, char* text) {
 	char* L1407_pc_Character;
 	char L1408_ac_ModifiedString[50];
 
@@ -226,21 +226,21 @@ void TextMan::f443_endgamePrintString(int16 x, int16 y, Color textColor, char* t
 		L1407_pc_Character++;
 		*L1407_pc_Character = *text++;
 	}
-	f53_printToLogicalScreen(x, y, textColor, k12_ColorDarkestGray, L1408_ac_ModifiedString);
+	printToLogicalScreen(x, y, textColor, k12_ColorDarkestGray, L1408_ac_ModifiedString);
 }
 
-void TextMan::f43_messageAreaClearAllRows() {
+void TextMan::clearAllRows() {
 	int16 L0023_i_RowIndex;
 
-	f561_isTextScrolling(&_gK60_s_TextScroller, true);
+	isTextScrolling(&_textScroller, true);
 
 	Box tmpBox(0, 319, 169, 199);
 	_vm->_displayMan->fillScreenBox(tmpBox, k0_ColorBlack);
 	
-	_g358_messageAreaCursorRow = 3;
-	_g359_messageAreaCursorColumn = 0;
+	_messageAreaCursorRow = 3;
+	_messageAreaCursorColumn = 0;
 	for (L0023_i_RowIndex = 0; L0023_i_RowIndex < 4; L0023_i_RowIndex++) {
-		_g360_messageAreaRowExpirationTime[L0023_i_RowIndex] = -1;
+		_messageAreaRowExpirationTime[L0023_i_RowIndex] = -1;
 	}
 }
 }
diff --git a/engines/dm/text.h b/engines/dm/text.h
index 51be3b2..55392a1 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -39,34 +39,35 @@ struct TextScroller {
 
 class TextMan {
 	DMEngine *_vm;
-	int16 _g359_messageAreaCursorColumn; // @ G0359_i_MessageAreaCursorColumn
-	int16 _g358_messageAreaCursorRow; // @ G0358_i_MessageAreaCursorRow
-	int32 _g360_messageAreaRowExpirationTime[4]; // @ G0360_al_MessageAreaRowExpirationTime
-	byte *_g356_bitmapMessageAreaNewRow; // @ G0356_puc_Bitmap_MessageAreaNewRow
+	int16 _messageAreaCursorColumn; // @ G0359_i_MessageAreaCursorColumn
+	int16 _messageAreaCursorRow; // @ G0358_i_MessageAreaCursorRow
+	int32 _messageAreaRowExpirationTime[4]; // @ G0360_al_MessageAreaRowExpirationTime
+	byte *_bitmapMessageAreaNewRow; // @ G0356_puc_Bitmap_MessageAreaNewRow
 public:
-	TextScroller _gK60_s_TextScroller;
+	TextScroller _textScroller;
 
 	explicit TextMan(DMEngine *vm);
 	~TextMan();
-	void f40_printTextToBitmap(byte *destBitmap, uint16 destByteWidth, int16 destX, int16 destY,
+
+	void printTextToBitmap(byte *destBitmap, uint16 destByteWidth, int16 destX, int16 destY,
 							   Color textColor, Color bgColor, const char *text, uint16 destHeight); // @ F0040_TEXT_Print
-	void f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text); // @ F0053_TEXT_PrintToLogicalScreen
-	void f52_printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport
-	void f41_printWithTrailingSpaces(byte *destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor, Color bgColor,
+	void printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text); // @ F0053_TEXT_PrintToLogicalScreen
+	void printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport
+	void printWithTrailingSpaces(byte *destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor, Color bgColor,
 									 const char *text, int16 strLenght, int16 destHeight); // @ F0041_TEXT_PrintWithTrailingSpaces
-	void f51_messageAreaPrintLineFeed(); // @ F0051_TEXT_MESSAGEAREA_PrintLineFeed
-	void f47_messageAreaPrintMessage(Color color, const char *string); // @ F0047_TEXT_MESSAGEAREA_PrintMessage
-	void f45_messageAreaCreateNewRow(); // @ F0045_TEXT_MESSAGEAREA_CreateNewRow
-	void f46_messageAreaPrintString(Color color, const char* string);// @ F0046_TEXT_MESSAGEAREA_PrintString
-	void f54_textInitialize(); // @ F0054_TEXT_Initialize
-	void f42_messageAreaMoveCursor(int16 column, int16 row); // @ F0042_TEXT_MESSAGEAREA_MoveCursor
-	void f44_messageAreaClearExpiredRows(); // @ F0044_TEXT_MESSAGEAREA_ClearExpiredRows
-	void f443_endgamePrintString(int16 x, int16 y, Color textColor, char *text); // @ F0443_STARTEND_EndgamePrintString
-	bool f561_isTextScrolling(TextScroller *scroller, bool waitEndOfScrolling) {
-		warning(false, "STUB METHOD: f561_isTextScrolling"); return true;
+	void printLineFeed(); // @ F0051_TEXT_MESSAGEAREA_PrintLineFeed
+	void printMessage(Color color, const char *string); // @ F0047_TEXT_MESSAGEAREA_PrintMessage
+	void createNewRow(); // @ F0045_TEXT_MESSAGEAREA_CreateNewRow
+	void printString(Color color, const char* string);// @ F0046_TEXT_MESSAGEAREA_PrintString
+	void initialize(); // @ F0054_TEXT_Initialize
+	void moveCursor(int16 column, int16 row); // @ F0042_TEXT_MESSAGEAREA_MoveCursor
+	void clearExpiredRows(); // @ F0044_TEXT_MESSAGEAREA_ClearExpiredRows
+	void printEndGameString(int16 x, int16 y, Color textColor, char *text); // @ F0443_STARTEND_EndgamePrintString
+	bool isTextScrolling(TextScroller *scroller, bool waitEndOfScrolling) {
+		warning(false, "STUB METHOD: isTextScrolling"); return true;
 	} // @ F0561_SCROLLER_IsTextScrolling
-	void f560_SCROLLER_setCommand(TextScroller *scroller, int16 command) { warning(false, "STUB METHOD: f560_SCROLLER_setCommand");  } // @ F0560_SCROLLER_SetCommand
-	void f43_messageAreaClearAllRows(); // @ F0043_TEXT_MESSAGEAREA_ClearAllRows
+	void setScrollerCommand(TextScroller *scroller, int16 command) { warning(false, "STUB METHOD: f560_SCROLLER_setCommand");  } // @ F0560_SCROLLER_SetCommand
+	void clearAllRows(); // @ F0043_TEXT_MESSAGEAREA_ClearAllRows
 };
 
 }
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 2fd2eb9..1089855 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -40,7 +40,7 @@
 
 namespace DM {
 
-signed char g495_actionDefense[44] = { // @ G0495_ac_Graphic560_ActionDefense
+signed char _actionDefense[44] = { // @ G0495_ac_Graphic560_ActionDefense
 	0,   /* N */
 	36,  /* BLOCK */
 	0,   /* CHOP */
@@ -87,51 +87,51 @@ signed char g495_actionDefense[44] = { // @ G0495_ac_Graphic560_ActionDefense
 	8};  /* FUSE */
 
 Timeline::Timeline(DMEngine* vm) : _vm(vm) {
-	_g369_eventMaxCount = 0;
-	_g370_events = nullptr;
-	_g372_eventCount = 0;
-	_g371_timeline = nullptr;
-	_g373_firstUnusedEventIndex = 0;
+	_eventMaxCount = 0;
+	_events = nullptr;
+	_eventCount = 0;
+	_timeline = nullptr;
+	_firstUnusedEventIndex = 0;
 }
 
 Timeline::~Timeline() {
-	delete[] _g370_events;
-	delete[] _g371_timeline;
+	delete[] _events;
+	delete[] _timeline;
 }
 
-void Timeline::f233_initTimeline() {
-	_g370_events = new TimelineEvent[_g369_eventMaxCount];
-	_g371_timeline = new uint16[_g369_eventMaxCount];
+void Timeline::initTimeline() {
+	_events = new TimelineEvent[_eventMaxCount];
+	_timeline = new uint16[_eventMaxCount];
 	if (_vm->_newGameFl) {
-		for (int16 i = 0; i < _g369_eventMaxCount; ++i)
-			_g370_events[i]._type = k0_TMEventTypeNone;
-		_g372_eventCount = 0;
-		_g373_firstUnusedEventIndex = 0;
+		for (int16 i = 0; i < _eventMaxCount; ++i)
+			_events[i]._type = k0_TMEventTypeNone;
+		_eventCount = 0;
+		_firstUnusedEventIndex = 0;
 	}
 }
 
-void Timeline::f237_deleteEvent(uint16 eventIndex) {
+void Timeline::deleteEvent(uint16 eventIndex) {
 	uint16 L0586_ui_TimelineIndex;
 	uint16 L0587_ui_EventCount;
 
 
-	_g370_events[eventIndex]._type = k0_TMEventTypeNone;
-	if (eventIndex < _g373_firstUnusedEventIndex) {
-		_g373_firstUnusedEventIndex = eventIndex;
+	_events[eventIndex]._type = k0_TMEventTypeNone;
+	if (eventIndex < _firstUnusedEventIndex) {
+		_firstUnusedEventIndex = eventIndex;
 	}
-	_g372_eventCount--;
-	if ((L0587_ui_EventCount = _g372_eventCount) == 0) {
+	_eventCount--;
+	if ((L0587_ui_EventCount = _eventCount) == 0) {
 		return;
 	}
-	L0586_ui_TimelineIndex = f235_getIndex(eventIndex);
+	L0586_ui_TimelineIndex = getIndex(eventIndex);
 	if (L0586_ui_TimelineIndex == L0587_ui_EventCount) {
 		return;
 	}
-	_g371_timeline[L0586_ui_TimelineIndex] = _g371_timeline[L0587_ui_EventCount];
-	f236_fixChronology(L0586_ui_TimelineIndex);
+	_timeline[L0586_ui_TimelineIndex] = _timeline[L0587_ui_EventCount];
+	fixChronology(L0586_ui_TimelineIndex);
 }
 
-void Timeline::f236_fixChronology(uint16 timelineIndex) {
+void Timeline::fixChronology(uint16 timelineIndex) {
 	uint16 L0581_ui_TimelineIndex;
 	uint16 L0582_ui_EventIndex;
 	uint16 L0583_ui_EventCount;
@@ -139,16 +139,16 @@ void Timeline::f236_fixChronology(uint16 timelineIndex) {
 	bool L0585_B_ChronologyFixed;
 
 
-	if ((L0583_ui_EventCount = _g372_eventCount) == 1) {
+	if ((L0583_ui_EventCount = _eventCount) == 1) {
 		return;
 	}
 
-	L0584_ps_Event = &_g370_events[L0582_ui_EventIndex = _g371_timeline[timelineIndex]];
+	L0584_ps_Event = &_events[L0582_ui_EventIndex = _timeline[timelineIndex]];
 	L0585_B_ChronologyFixed = false;
 	while (timelineIndex > 0) { /* Check if the event should be moved earlier in the timeline */
 		L0581_ui_TimelineIndex = (timelineIndex - 1) >> 1;
-		if (f234_isEventABeforeB(L0584_ps_Event, &_g370_events[_g371_timeline[L0581_ui_TimelineIndex]])) {
-			_g371_timeline[timelineIndex] = _g371_timeline[L0581_ui_TimelineIndex];
+		if (isEventABeforeB(L0584_ps_Event, &_events[_timeline[L0581_ui_TimelineIndex]])) {
+			_timeline[timelineIndex] = _timeline[L0581_ui_TimelineIndex];
 			timelineIndex = L0581_ui_TimelineIndex;
 			L0585_B_ChronologyFixed = true;
 		} else {
@@ -160,21 +160,21 @@ void Timeline::f236_fixChronology(uint16 timelineIndex) {
 	L0583_ui_EventCount = ((L0583_ui_EventCount - 1) - 1) >> 1;
 	while (timelineIndex <= L0583_ui_EventCount) { /* Check if the event should be moved later in the timeline */
 		L0581_ui_TimelineIndex = (timelineIndex << 1) + 1;
-		if (((L0581_ui_TimelineIndex + 1) < _g372_eventCount) && (f234_isEventABeforeB(&_g370_events[_g371_timeline[L0581_ui_TimelineIndex + 1]], &_g370_events[_g371_timeline[L0581_ui_TimelineIndex]]))) {
+		if (((L0581_ui_TimelineIndex + 1) < _eventCount) && (isEventABeforeB(&_events[_timeline[L0581_ui_TimelineIndex + 1]], &_events[_timeline[L0581_ui_TimelineIndex]]))) {
 			L0581_ui_TimelineIndex++;
 		}
-		if (f234_isEventABeforeB(&_g370_events[_g371_timeline[L0581_ui_TimelineIndex]], L0584_ps_Event)) {
-			_g371_timeline[timelineIndex] = _g371_timeline[L0581_ui_TimelineIndex];
+		if (isEventABeforeB(&_events[_timeline[L0581_ui_TimelineIndex]], L0584_ps_Event)) {
+			_timeline[timelineIndex] = _timeline[L0581_ui_TimelineIndex];
 			timelineIndex = L0581_ui_TimelineIndex;
 		} else {
 			break;
 		}
 	}
 T0236011:
-	_g371_timeline[timelineIndex] = L0582_ui_EventIndex;
+	_timeline[timelineIndex] = L0582_ui_EventIndex;
 }
 
-bool Timeline::f234_isEventABeforeB(TimelineEvent* eventA, TimelineEvent* eventB) {
+bool Timeline::isEventABeforeB(TimelineEvent* eventA, TimelineEvent* eventB) {
 	bool L0578_B_Simultaneous;
 
 	return (filterTime(eventA->_mapTime) < filterTime(eventB->_mapTime)) ||
@@ -182,32 +182,32 @@ bool Timeline::f234_isEventABeforeB(TimelineEvent* eventA, TimelineEvent* eventB
 		(L0578_B_Simultaneous && (eventA->getTypePriority() == eventB->getTypePriority()) && (eventA <= eventB));
 }
 
-uint16 Timeline::f235_getIndex(uint16 eventIndex) {
+uint16 Timeline::getIndex(uint16 eventIndex) {
 	uint16 L0579_ui_TimelineIndex;
 	uint16* L0580_pui_TimelineEntry;
 
 
-	for (L0579_ui_TimelineIndex = 0, L0580_pui_TimelineEntry = _g371_timeline; L0579_ui_TimelineIndex < _g369_eventMaxCount; L0579_ui_TimelineIndex++) {
+	for (L0579_ui_TimelineIndex = 0, L0580_pui_TimelineEntry = _timeline; L0579_ui_TimelineIndex < _eventMaxCount; L0579_ui_TimelineIndex++) {
 		if (*L0580_pui_TimelineEntry++ == eventIndex)
 			break;
 	}
-	if (L0579_ui_TimelineIndex >= _g369_eventMaxCount) { /* BUG0_00 Useless code. The function is always called with event indices that are in the timeline */
+	if (L0579_ui_TimelineIndex >= _eventMaxCount) { /* BUG0_00 Useless code. The function is always called with event indices that are in the timeline */
 		L0579_ui_TimelineIndex = 0; /* BUG0_01 Coding error without consequence. Wrong return value. If the specified event index is not found in the timeline the function returns 0 which is the same value that is returned if the event index is found in the first timeline entry. No consequence because this code is never executed */
 	}
 	return L0579_ui_TimelineIndex;
 }
 
-uint16 Timeline::f238_addEventGetEventIndex(TimelineEvent* event) {
+uint16 Timeline::addEventGetEventIndex(TimelineEvent* event) {
 	uint16 L0588_ui_EventIndex;
 	uint16 L0590_ui_NewEventIndex;
 	TimelineEvent* L0591_ps_Event;
 
 
-	if (_g372_eventCount == _g369_eventMaxCount) {
+	if (_eventCount == _eventMaxCount) {
 		_vm->displayErrorAndStop(45);
 	}
 	if ((event->_type >= k5_TMEventTypeCorridor) && (event->_type <= k10_TMEventTypeDoor)) {
-		for (L0588_ui_EventIndex = 0, L0591_ps_Event = _g370_events; L0588_ui_EventIndex < _g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
+		for (L0588_ui_EventIndex = 0, L0591_ps_Event = _events; L0588_ui_EventIndex < _eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
 			if ((L0591_ps_Event->_type >= k5_TMEventTypeCorridor) && (L0591_ps_Event->_type <= k10_TMEventTypeDoor)) {
 				if ((event->_mapTime == L0591_ps_Event->_mapTime) && (event->getMapXY() == L0591_ps_Event->getMapXY()) && ((L0591_ps_Event->_type != k6_TMEventTypeWall) || (L0591_ps_Event->_C.A._cell == event->_C.A._cell))) {
 					L0591_ps_Event->_C.A._effect = event->_C.A._effect;
@@ -219,14 +219,14 @@ uint16 Timeline::f238_addEventGetEventIndex(TimelineEvent* event) {
 					if (event->_C.A._effect == k2_SensorEffToggle) {
 						event->_C.A._effect = 1 - L0591_ps_Event->_C.A._effect;
 					}
-					f237_deleteEvent(L0588_ui_EventIndex);
+					deleteEvent(L0588_ui_EventIndex);
 					break;
 				}
 			}
 		}
 	} else {
 		if (event->_type == k1_TMEventTypeDoorAnimation) {
-			for (L0588_ui_EventIndex = 0, L0591_ps_Event = _g370_events; L0588_ui_EventIndex < _g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
+			for (L0588_ui_EventIndex = 0, L0591_ps_Event = _events; L0588_ui_EventIndex < _eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
 				if ((event->_mapTime == L0591_ps_Event->_mapTime) && (event->getMapXY() == L0591_ps_Event->getMapXY())) {
 					if (L0591_ps_Event->_type == k10_TMEventTypeDoor) {
 						if (L0591_ps_Event->_C.A._effect == k2_SensorEffToggle) {
@@ -242,28 +242,28 @@ uint16 Timeline::f238_addEventGetEventIndex(TimelineEvent* event) {
 			}
 		} else {
 			if (event->_type == k2_TMEventTypeDoorDestruction) {
-				for (L0588_ui_EventIndex = 0, L0591_ps_Event = _g370_events; L0588_ui_EventIndex < _g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
+				for (L0588_ui_EventIndex = 0, L0591_ps_Event = _events; L0588_ui_EventIndex < _eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
 					if ((event->getMapXY() == L0591_ps_Event->getMapXY()) && (getMap(event->_mapTime) == getMap(L0591_ps_Event->_mapTime))) {
 						if ((L0591_ps_Event->_type == k1_TMEventTypeDoorAnimation) || (L0591_ps_Event->_type == k10_TMEventTypeDoor)) {
-							f237_deleteEvent(L0588_ui_EventIndex);
+							deleteEvent(L0588_ui_EventIndex);
 						}
 					}
 				}
 			}
 		}
 	}
-	_g370_events[L0590_ui_NewEventIndex = _g373_firstUnusedEventIndex] = *event; /* Copy the event data (Megamax C can assign structures) */
+	_events[L0590_ui_NewEventIndex = _firstUnusedEventIndex] = *event; /* Copy the event data (Megamax C can assign structures) */
 	do {
-		if (_g373_firstUnusedEventIndex == _g369_eventMaxCount)
+		if (_firstUnusedEventIndex == _eventMaxCount)
 			break;
-		_g373_firstUnusedEventIndex++;
-	} while ((_g370_events[_g373_firstUnusedEventIndex])._type != k0_TMEventTypeNone);
-	_g371_timeline[_g372_eventCount] = L0590_ui_NewEventIndex;
-	f236_fixChronology(_g372_eventCount++);
+		_firstUnusedEventIndex++;
+	} while ((_events[_firstUnusedEventIndex])._type != k0_TMEventTypeNone);
+	_timeline[_eventCount] = L0590_ui_NewEventIndex;
+	fixChronology(_eventCount++);
 	return L0590_ui_NewEventIndex;
 }
 
-void Timeline::f261_processTimeline() {
+void Timeline::processTimeline() {
 	uint16 L0680_ui_Multiple;
 #define AL0680_ui_EventType     L0680_ui_Multiple
 #define AL0680_ui_ChampionIndex L0680_ui_Multiple
@@ -271,9 +271,9 @@ void Timeline::f261_processTimeline() {
 	TimelineEvent L0682_s_Event;
 
 
-	while (f240_isFirstEventExpiered()) {
+	while (isFirstEventExpiered()) {
 		L0681_ps_Event = &L0682_s_Event;
-		f239_timelineExtractFirstEvent(L0681_ps_Event);
+		extractFirstEvent(L0681_ps_Event);
 		_vm->_dungeonMan->setCurrentMap(getMap(L0682_s_Event._mapTime));
 		AL0680_ui_EventType = L0682_s_Event._type;
 		if ((AL0680_ui_EventType > (k29_TMEventTypeGroupReactionDangerOnSquare - 1)) && (AL0680_ui_EventType < (k41_TMEventTypeUpdateBehaviour_3 + 1))) {
@@ -285,41 +285,41 @@ void Timeline::f261_processTimeline() {
 				_vm->_projexpl->processEvents48To49(L0681_ps_Event);
 				break;
 			case k1_TMEventTypeDoorAnimation:
-				f241_timelineProcessEvent1_doorAnimation(L0681_ps_Event);
+				processEventDoorAnimation(L0681_ps_Event);
 				break;
 			case k25_TMEventTypeExplosion:
 				_vm->_projexpl->processEvent25(L0681_ps_Event);
 				break;
 			case k7_TMEventTypeFakeWall:
-				f242_timelineProcessEvent7_squareFakewall(L0681_ps_Event);
+				processEventSquareFakewall(L0681_ps_Event);
 				break;
 			case k2_TMEventTypeDoorDestruction:
-				f243_timelineProcessEvent2_doorDestruction(L0681_ps_Event);
+				processEventDoorDestruction(L0681_ps_Event);
 				break;
 			case k10_TMEventTypeDoor:
-				f244_timelineProcessEvent10_squareDoor(L0681_ps_Event);
+				processEventSquareDoor(L0681_ps_Event);
 				break;
 			case k9_TMEventTypePit:
-				f251_timelineProcessEvent9_squarePit(L0681_ps_Event);
+				processEventSquarePit(L0681_ps_Event);
 				break;
 			case k8_TMEventTypeTeleporter:
-				f250_timelineProcessEvent8_squareTeleporter(L0681_ps_Event);
+				processEventSquareTeleporter(L0681_ps_Event);
 				break;
 			case k6_TMEventTypeWall:
-				f248_timelineProcessEvent6_squareWall(L0681_ps_Event);
+				processEventSquareWall(L0681_ps_Event);
 				break;
 			case k5_TMEventTypeCorridor:
-				f245_timlineProcessEvent5_squareCorridor(L0681_ps_Event);
+				processEventSquareCorridor(L0681_ps_Event);
 				break;
 			case k60_TMEventTypeMoveGroupSilent:
 			case k61_TMEventTypeMoveGroupAudible:
-				f252_timelineProcessEvents60to61_moveGroup(L0681_ps_Event);
+				processEventsMoveGroup(L0681_ps_Event);
 				break;
 			case k65_TMEventTypeEnableGroupGenerator:
-				f246_timelineProcesEvent65_enableGroupGenerator(L0681_ps_Event);
+				procesEventEnableGroupGenerator(L0681_ps_Event);
 				break;
 			case k20_TMEventTypePlaySound:
-				_vm->_sound->f064_SOUND_RequestPlay_CPSD(L0682_s_Event._C._soundIndex, L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, k1_soundModePlayIfPrioritized);
+				_vm->_sound->requestPlay(L0682_s_Event._C._soundIndex, L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, k1_soundModePlayIfPrioritized);
 				break;
 			case k24_TMEventTypeRemoveFluxcage:
 				if (!_vm->_gameWon) {
@@ -329,17 +329,17 @@ void Timeline::f261_processTimeline() {
 				}
 				break;
 			case k11_TMEventTypeEnableChampionAction:
-				f253_timelineProcessEvent11Part1_enableChampionAction(L0682_s_Event._priority);
+				processEventEnableChampionAction(L0682_s_Event._priority);
 				if (L0682_s_Event._B._slotOrdinal) {
-					f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(L0682_s_Event._priority, _vm->ordinalToIndex(L0682_s_Event._B._slotOrdinal));
+					processEventMoveWeaponFromQuiverToSlot(L0682_s_Event._priority, _vm->ordinalToIndex(L0682_s_Event._B._slotOrdinal));
 				}
 				goto T0261048;
 			case k12_TMEventTypeHideDamageReceived:
-				f254_timelineProcessEvent12_hideDamageReceived(L0682_s_Event._priority);
+				processEventHideDamageReceived(L0682_s_Event._priority);
 				break;
 			case k70_TMEventTypeLight:
 				_vm->_dungeonMan->setCurrentMap(_vm->_dungeonMan->_partyMapIndex);
-				f257_timelineProcessEvent70_light(L0681_ps_Event);
+				processEventLight(L0681_ps_Event);
 				_vm->_inventoryMan->setDungeonViewPalette();
 				break;
 			case k71_TMEventTypeInvisibility:
@@ -357,7 +357,7 @@ T0261048:
 			case k74_TMEventTypePartyShield:
 				_vm->_championMan->_party._shieldDefense -= L0682_s_Event._B._defense;
 T0261053:
-				f260_timelineRefreshAllChampionStatusBoxes();
+				refreshAllChampionStatusBoxes();
 				break;
 			case k77_TMEventTypeSpellShield:
 				_vm->_championMan->_party._spellShieldDefense -= L0682_s_Event._B._defense;
@@ -370,7 +370,7 @@ T0261053:
 				_vm->_championMan->championPoison(AL0680_ui_ChampionIndex, L0682_s_Event._B._attack);
 				break;
 			case k13_TMEventTypeViAltarRebirth:
-				f255_timelineProcessEvent13_ViAltarRebirth(L0681_ps_Event);
+				processEventViAltarRebirth(L0681_ps_Event);
 				break;
 			case k79_TMEventTypeFootprints:
 				_vm->_championMan->_party._event79Count_Footprints--;
@@ -380,18 +380,18 @@ T0261053:
 	}
 }
 
-bool Timeline::f240_isFirstEventExpiered() {
-	return (_g372_eventCount && (filterTime(_g370_events[_g371_timeline[0]]._mapTime) <= _vm->_gameTime));
+bool Timeline::isFirstEventExpiered() {
+	return (_eventCount && (filterTime(_events[_timeline[0]]._mapTime) <= _vm->_gameTime));
 }
 
-void Timeline::f239_timelineExtractFirstEvent(TimelineEvent* event) {
+void Timeline::extractFirstEvent(TimelineEvent* event) {
 	uint16 L0592_ui_EventIndex;
 
-	*event = _g370_events[L0592_ui_EventIndex = _g371_timeline[0]];
-	f237_deleteEvent(L0592_ui_EventIndex);
+	*event = _events[L0592_ui_EventIndex = _timeline[0]];
+	deleteEvent(L0592_ui_EventIndex);
 }
 
-void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
+void Timeline::processEventDoorAnimation(TimelineEvent* event) {
 	uint16 L0593_ui_MapX;
 	uint16 L0594_ui_MapY;
 	int16 L0595_i_Effect;
@@ -421,11 +421,11 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 				// Original bug fixed - A closing horizontal door wounds champions to the head instead of to the hands. Missing parenthesis in the condition cause all doors to wound the head in addition to the torso
 				// See BUG0_78
 				if (_vm->_championMan->getDamagedChampionCount(5, k0x0008_ChampionWoundTorso | (AL0602_ui_VerticalDoor ? k0x0004_ChampionWoundHead : k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand), k2_attackType_SELF)) {
-					_vm->_sound->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
+					_vm->_sound->requestPlay(k18_soundPARTY_DAMAGED, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
 				}
 			}
 			event->_mapTime++;
-			f238_addEventGetEventIndex(event);
+			addEventGetEventIndex(event);
 			return;
 		}
 		if (((L0599_T_GroupThing = _vm->_groupMan->groupGetThing(L0593_ui_MapX, L0594_ui_MapY)) != Thing::_endOfList) && !getFlag(L0600_ui_CreatureAttributes = _vm->_dungeonMan->getCreatureAttributes(L0599_T_GroupThing), k0x0040_MaskCreatureInfo_nonMaterial)) {
@@ -435,9 +435,9 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 				}
 				L0596_i_DoorState = (L0596_i_DoorState == k0_doorState_OPEN) ? k0_doorState_OPEN : (L0596_i_DoorState - 1);
 				L0597_puc_Square->setDoorState(L0596_i_DoorState);
-				_vm->_sound->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
+				_vm->_sound->requestPlay(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
 				event->_mapTime++;
-				f238_addEventGetEventIndex(event);
+				addEventGetEventIndex(event);
 				return;
 			}
 		}
@@ -447,7 +447,7 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 	}
 	L0596_i_DoorState += (L0595_i_Effect == k0_SensorEffSet) ? -1 : 1;
 	L0597_puc_Square->setDoorState(L0596_i_DoorState);
-	_vm->_sound->f064_SOUND_RequestPlay_CPSD(k02_soundDOOR_RATTLE, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
+	_vm->_sound->requestPlay(k02_soundDOOR_RATTLE, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
 
 	if (L0595_i_Effect == k0_SensorEffSet) {
 		if (L0596_i_DoorState == k0_doorState_OPEN) {
@@ -458,12 +458,12 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) {
 			return;
 		}
 	}
-	f238_addEventGetEventIndex(event);
+	addEventGetEventIndex(event);
 T0241020_Return:
 	;
 }
 
-void Timeline::f242_timelineProcessEvent7_squareFakewall(TimelineEvent* event) {
+void Timeline::processEventSquareFakewall(TimelineEvent* event) {
 	uint16 L0603_ui_MapX;
 	uint16 L0604_ui_MapY;
 	int16 L0605_i_Effect;
@@ -479,11 +479,11 @@ void Timeline::f242_timelineProcessEvent7_squareFakewall(TimelineEvent* event) {
 	if (L0605_i_Effect == k1_SensorEffClear) {
 		if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0603_ui_MapX == _vm->_dungeonMan->_partyMapX) && (L0604_ui_MapY == _vm->_dungeonMan->_partyMapY)) {
 			event->_mapTime++;
-			f238_addEventGetEventIndex(event);
+			addEventGetEventIndex(event);
 		} else {
 			if (((L0606_T_Thing = _vm->_groupMan->groupGetThing(L0603_ui_MapX, L0604_ui_MapY)) != Thing::_endOfList) && !getFlag(_vm->_dungeonMan->getCreatureAttributes(L0606_T_Thing), k0x0040_MaskCreatureInfo_nonMaterial)) {
 				event->_mapTime++;
-				f238_addEventGetEventIndex(event);
+				addEventGetEventIndex(event);
 			} else {
 				clearFlag(*L0607_puc_Square, k0x0004_FakeWallOpen);
 			}
@@ -493,14 +493,14 @@ void Timeline::f242_timelineProcessEvent7_squareFakewall(TimelineEvent* event) {
 	}
 }
 
-void Timeline::f243_timelineProcessEvent2_doorDestruction(TimelineEvent* event) {
+void Timeline::processEventDoorDestruction(TimelineEvent* event) {
 	Square* L0608_puc_Square;
 
 	L0608_puc_Square = (Square*)&_vm->_dungeonMan->_currMapData[event->_B._location._mapX][event->_B._location._mapY];
 	L0608_puc_Square->setDoorState(k5_doorState_DESTROYED);
 }
 
-void Timeline::f244_timelineProcessEvent10_squareDoor(TimelineEvent* event) {
+void Timeline::processEventSquareDoor(TimelineEvent* event) {
 	int16 L0609_i_DoorState;
 
 
@@ -521,10 +521,10 @@ void Timeline::f244_timelineProcessEvent10_squareDoor(TimelineEvent* event) {
 		}
 	}
 	event->_type = k1_TMEventTypeDoorAnimation;
-	f238_addEventGetEventIndex(event);
+	addEventGetEventIndex(event);
 }
 
-void Timeline::f251_timelineProcessEvent9_squarePit(TimelineEvent* event) {
+void Timeline::processEventSquarePit(TimelineEvent* event) {
 	uint16 L0653_ui_MapX;
 	uint16 L0654_ui_MapY;
 	byte* L0655_puc_Square;
@@ -536,13 +536,13 @@ void Timeline::f251_timelineProcessEvent9_squarePit(TimelineEvent* event) {
 	}
 	if (event->_C.A._effect == k0_SensorEffSet) {
 		setFlag(*L0655_puc_Square, k0x0008_PitOpen);
-		f249_moveTeleporterOrPitSquareThings(L0653_ui_MapX, L0654_ui_MapY);
+		moveTeleporterOrPitSquareThings(L0653_ui_MapX, L0654_ui_MapY);
 	} else {
 		clearFlag(*L0655_puc_Square, k0x0008_PitOpen);
 	}
 }
 
-void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
+void Timeline::moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 	uint16 L0644_ui_Multiple;
 #define AL0644_ui_ThingType  L0644_ui_Multiple
 #define AL0644_ui_EventIndex L0644_ui_Multiple
@@ -579,7 +579,7 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 		}
 		if (AL0644_ui_ThingType == k14_ProjectileThingType) {
 			L0646_ps_Projectile = (Projectile*)_vm->_dungeonMan->getThingData(L0645_T_Thing);
-			L0647_ps_Event = &_g370_events[L0646_ps_Projectile->_eventIndex];
+			L0647_ps_Event = &_events[L0646_ps_Projectile->_eventIndex];
 			L0647_ps_Event->_C._projectile.setMapX(_vm->_moveSens->_moveResultMapX);
 			L0647_ps_Event->_C._projectile.setMapY(_vm->_moveSens->_moveResultMapY);
 			L0647_ps_Event->_C._projectile.setDir((Direction)_vm->_moveSens->_moveResultDir);
@@ -587,7 +587,7 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 			M31_setMap(L0647_ps_Event->_mapTime, _vm->_moveSens->_moveResultMapIndex);
 		} else {
 			if (AL0644_ui_ThingType == k15_ExplosionThingType) {
-				for (AL0644_ui_EventIndex = 0, L0647_ps_Event = _g370_events; AL0644_ui_EventIndex < _g369_eventMaxCount; L0647_ps_Event++, AL0644_ui_EventIndex++) {
+				for (AL0644_ui_EventIndex = 0, L0647_ps_Event = _events; AL0644_ui_EventIndex < _eventMaxCount; L0647_ps_Event++, AL0644_ui_EventIndex++) {
 					if ((L0647_ps_Event->_type == k25_TMEventTypeExplosion) && (L0647_ps_Event->_C._slot == L0645_T_Thing.toUint16())) { /* BUG0_23 A Fluxcage explosion remains on a square forever. If you open a pit or teleporter on a square where there is a Fluxcage explosion, the Fluxcage explosion is moved but the associated event is not updated (because Fluxcage explosions do not use k25_TMEventTypeExplosion but rather k24_TMEventTypeRemoveFluxcage) causing the Fluxcage explosion to remain in the dungeon forever on its destination square. When the k24_TMEventTypeRemoveFluxcage expires the explosion thing is not removed, but it is marked as unused. Consequently, any objects placed on the Fluxcage square after it was moved but before it expires become orphans upon expiration. After expiration, any object placed on the fluxcage square is cloned when picked up */
 						L0647_ps_Event->_B._location._mapX = _vm->_moveSens->_moveResultMapX;
 						L0647_ps_Event->_B._location._mapY = _vm->_moveSens->_moveResultMapY;
@@ -601,7 +601,7 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 	}
 }
 
-void Timeline::f250_timelineProcessEvent8_squareTeleporter(TimelineEvent* event) {
+void Timeline::processEventSquareTeleporter(TimelineEvent* event) {
 	uint16 L0650_ui_MapX;
 	uint16 L0651_ui_MapY;
 	byte* L0652_puc_Square;
@@ -613,13 +613,13 @@ void Timeline::f250_timelineProcessEvent8_squareTeleporter(TimelineEvent* event)
 	}
 	if (event->_C.A._effect == k0_SensorEffSet) {
 		setFlag(*L0652_puc_Square, k0x0008_TeleporterOpen);
-		f249_moveTeleporterOrPitSquareThings(L0650_ui_MapX, L0651_ui_MapY);
+		moveTeleporterOrPitSquareThings(L0650_ui_MapX, L0651_ui_MapY);
 	} else {
 		clearFlag(*L0652_puc_Square, k0x0008_TeleporterOpen);
 	}
 }
 
-void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
+void Timeline::processEventSquareWall(TimelineEvent* event) {
 	Thing L0634_T_Thing;
 	int16 L0635_i_ThingType;
 	int16 L0636_i_Multiple;
@@ -695,7 +695,7 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
 						}
 					} else {
 						if ((((L0640_ui_SensorType >= k7_SensorWallSingleProjLauncherNewObj) && (L0640_ui_SensorType <= k10_SensorWallDoubleProjLauncherExplosion)) || (L0640_ui_SensorType == k14_SensorWallSingleProjLauncherSquareObj) || (L0640_ui_SensorType == k15_SensorWallDoubleProjLauncherSquareObj)) && (L0634_T_Thing.getCell() == event->_C.A._cell)) {
-							f247_triggerProjectileLauncher(L0638_ps_Sensor, event);
+							triggerProjectileLauncher(L0638_ps_Sensor, event);
 							if (L0638_ps_Sensor->getAttrOnlyOnce()) {
 								L0638_ps_Sensor->setTypeDisabled();
 							}
@@ -716,7 +716,7 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) {
 	_vm->_moveSens->processRotationEffect();
 }
 
-void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* event) {
+void Timeline::triggerProjectileLauncher(Sensor* sensor, TimelineEvent* event) {
 	Thing L0622_T_FirstProjectileAssociatedThing;
 	Thing L0623_T_SecondProjectileAssociatedThing;
 	uint16 L0624_ui_Cell;
@@ -792,7 +792,7 @@ void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* eve
 	_vm->_projexpl->_createLauncherProjectile = false;
 }
 
-void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
+void Timeline::processEventSquareCorridor(TimelineEvent* event) {
 #define k0x0008_randomizeGeneratedCreatureCount 0x0008 // @ MASK0x0008_RANDOMIZE_GENERATED_CREATURE_COUNT
 #define k0x0007_generatedCreatureCount 0x0007	// @ MASK0x0007_GENERATED_CREATURE_COUNT
 
@@ -822,7 +822,7 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 			}
 			if (!L0611_B_TextCurrentlyVisible && L0615_ps_TextString->isVisible() && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0616_ui_MapX == _vm->_dungeonMan->_partyMapX) && (L0617_ui_MapY == _vm->_dungeonMan->_partyMapY)) {
 				_vm->_dungeonMan->decodeText(_vm->_stringBuildBuffer, L0613_T_Thing, k1_TextTypeMessage);
-				_vm->_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, _vm->_stringBuildBuffer);
+				_vm->_textMan->printMessage(k15_ColorWhite, _vm->_stringBuildBuffer);
 			}
 		} else {
 			if (L0610_i_ThingType == k3_SensorThingType) {
@@ -840,7 +840,7 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 					}
 					_vm->_groupMan->groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (Direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY);
 					if (L0614_ps_Sensor->getAttrAudibleA()) {
-						_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0616_ui_MapX, L0617_ui_MapY, k1_soundModePlayIfPrioritized);
+						_vm->_sound->requestPlay(k17_soundBUZZ, L0616_ui_MapX, L0617_ui_MapY, k1_soundModePlayIfPrioritized);
 					}
 					if (L0614_ps_Sensor->getAttrOnlyOnce()) {
 						L0614_ps_Sensor->setTypeDisabled();
@@ -857,7 +857,7 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 							L0619_s_Event._B._location._mapX = L0616_ui_MapX;
 							L0619_s_Event._B._location._mapY = L0617_ui_MapY;
 							L0619_s_Event._B._location._mapY = L0617_ui_MapY;
-							f238_addEventGetEventIndex(&L0619_s_Event);
+							addEventGetEventIndex(&L0619_s_Event);
 						}
 					}
 				}
@@ -867,7 +867,7 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) {
 	}
 }
 
-void Timeline::f252_timelineProcessEvents60to61_moveGroup(TimelineEvent* event) {
+void Timeline::processEventsMoveGroup(TimelineEvent* event) {
 	uint16 L0656_ui_MapX;
 	uint16 L0657_ui_MapY;
 	Group* L0658_ps_Group;
@@ -880,7 +880,7 @@ void Timeline::f252_timelineProcessEvents60to61_moveGroup(TimelineEvent* event)
 T0252001:
 	if (((_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex) || (L0656_ui_MapX != _vm->_dungeonMan->_partyMapX) || (L0657_ui_MapY != _vm->_dungeonMan->_partyMapY)) && (_vm->_groupMan->groupGetThing(L0656_ui_MapX, L0657_ui_MapY) == Thing::_endOfList)) { /* BUG0_24 Lord Chaos may teleport into one of the Black Flames and become invisible until the Black Flame is killed. In this case, _vm->_groupMan->f175_groupGetThing returns the Black Flame thing and the Lord Chaos thing is not moved into the dungeon until the Black Flame is killed */
 		if (event->_type == k61_TMEventTypeMoveGroupAudible) {
-			_vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0656_ui_MapX, L0657_ui_MapY, k1_soundModePlayIfPrioritized);
+			_vm->_sound->requestPlay(k17_soundBUZZ, L0656_ui_MapX, L0657_ui_MapY, k1_soundModePlayIfPrioritized);
 		}
 		_vm->_moveSens->getMoveResult(Thing(event->_C._slot), kM1_MapXNotOnASquare, 0, L0656_ui_MapX, L0657_ui_MapY);
 	} else {
@@ -906,11 +906,11 @@ T0252001:
 			}
 		}
 		event->_mapTime += 5;
-		f238_addEventGetEventIndex(event);
+		addEventGetEventIndex(event);
 	}
 }
 
-void Timeline::f246_timelineProcesEvent65_enableGroupGenerator(TimelineEvent* event) {
+void Timeline::procesEventEnableGroupGenerator(TimelineEvent* event) {
 	Thing L0620_T_Thing;
 	Sensor* L0621_ps_Sensor;
 
@@ -928,7 +928,7 @@ void Timeline::f246_timelineProcesEvent65_enableGroupGenerator(TimelineEvent* ev
 	}
 }
 
-void Timeline::f253_timelineProcessEvent11Part1_enableChampionAction(uint16 champIndex) {
+void Timeline::processEventEnableChampionAction(uint16 champIndex) {
 	int16 L0660_i_SlotIndex;
 	int16 L0661_i_QuiverSlotIndex;
 	Champion* L0662_ps_Champion;
@@ -937,7 +937,7 @@ void Timeline::f253_timelineProcessEvent11Part1_enableChampionAction(uint16 cham
 	L0662_ps_Champion->_enableActionEventIndex = -1;
 	clearFlag(L0662_ps_Champion->_attributes, k0x0008_ChampionAttributeDisableAction);
 	if (L0662_ps_Champion->_actionIndex != k255_ChampionActionNone) {
-		L0662_ps_Champion->_actionDefense -= g495_actionDefense[L0662_ps_Champion->_actionDefense];
+		L0662_ps_Champion->_actionDefense -= _actionDefense[L0662_ps_Champion->_actionDefense];
 	}
 	if (L0662_ps_Champion->_currHealth) {
 		if ((L0662_ps_Champion->_actionIndex == k32_ChampionActionShoot) && (L0662_ps_Champion->_slots[k0_ChampionSlotReadyHand] == Thing::_none)) {
@@ -957,7 +957,7 @@ T0253002:
 	L0662_ps_Champion->_actionIndex = k255_ChampionActionNone;
 }
 
-void Timeline::f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(uint16 champIndex, uint16 slotIndex) {
+void Timeline::processEventMoveWeaponFromQuiverToSlot(uint16 champIndex, uint16 slotIndex) {
 	uint16 L0677_ui_SlotIndex;
 	Champion* L0678_ps_Champion;
 
@@ -965,16 +965,16 @@ void Timeline::f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(uint1
 	if (L0678_ps_Champion->_slots[slotIndex] != Thing::_none) {
 		return;
 	}
-	if (f258_timelineHasWeaponMovedSlot(champIndex, L0678_ps_Champion, k12_ChampionSlotQuiverLine_1_1, slotIndex)) {
+	if (hasWeaponMovedSlot(champIndex, L0678_ps_Champion, k12_ChampionSlotQuiverLine_1_1, slotIndex)) {
 		return;
 	}
 	for (L0677_ui_SlotIndex = k7_ChampionSlotQuiverLine_2_1; L0677_ui_SlotIndex <= k9_ChampionSlotQuiverLine_2_2; L0677_ui_SlotIndex++) {
-		if (f258_timelineHasWeaponMovedSlot(champIndex, L0678_ps_Champion, L0677_ui_SlotIndex, slotIndex))
+		if (hasWeaponMovedSlot(champIndex, L0678_ps_Champion, L0677_ui_SlotIndex, slotIndex))
 			break;
 	}
 }
 
-bool Timeline::f258_timelineHasWeaponMovedSlot(int16 champIndex, Champion* champ, uint16 sourceSlotIndex, int16 destSlotIndex) {
+bool Timeline::hasWeaponMovedSlot(int16 champIndex, Champion* champ, uint16 sourceSlotIndex, int16 destSlotIndex) {
 	if (Thing(champ->_slots[sourceSlotIndex]).getType() == k5_WeaponThingType) {
 		_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->getObjectRemovedFromSlot(champIndex, sourceSlotIndex),
 			(ChampionSlot)destSlotIndex);
@@ -983,7 +983,7 @@ bool Timeline::f258_timelineHasWeaponMovedSlot(int16 champIndex, Champion* champ
 	return false;
 }
 
-void Timeline::f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex) {
+void Timeline::processEventHideDamageReceived(uint16 champIndex) {
 	Champion* L0663_ps_Champion;
 
 
@@ -1002,7 +1002,7 @@ void Timeline::f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex)
 	}
 }
 
-void Timeline::f257_timelineProcessEvent70_light(TimelineEvent* event) {
+void Timeline::processEventLight(TimelineEvent* event) {
 	int16 L0673_i_WeakerLightPower;
 	int16 L0674_i_Multiple;
 #define AL0674_i_LightPower  L0674_i_Multiple
@@ -1032,11 +1032,11 @@ void Timeline::f257_timelineProcessEvent70_light(TimelineEvent* event) {
 		L0676_s_Event._B._lightPower = L0673_i_WeakerLightPower;
 		setMapAndTime(L0676_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + 4);
 		L0676_s_Event._priority = 0;
-		f238_addEventGetEventIndex(&L0676_s_Event);
+		addEventGetEventIndex(&L0676_s_Event);
 	}
 }
 
-void Timeline::f260_timelineRefreshAllChampionStatusBoxes() {
+void Timeline::refreshAllChampionStatusBoxes() {
 	uint16 L0679_ui_ChampionIndex;
 
 	for (L0679_ui_ChampionIndex = k0_ChampionFirst; L0679_ui_ChampionIndex < _vm->_championMan->_partyChampionCount; L0679_ui_ChampionIndex++) {
@@ -1045,7 +1045,7 @@ void Timeline::f260_timelineRefreshAllChampionStatusBoxes() {
 	_vm->_championMan->drawAllChampionStates();
 }
 
-void Timeline::f255_timelineProcessEvent13_ViAltarRebirth(TimelineEvent* event) {
+void Timeline::processEventViAltarRebirth(TimelineEvent* event) {
 	int16 L0664_i_MapX;
 	int16 L0665_i_MapY;
 	uint16 L0666_ui_Cell;
@@ -1068,7 +1068,7 @@ void Timeline::f255_timelineProcessEvent13_ViAltarRebirth(TimelineEvent* event)
 T0255002:
 		L0670_ui_Step--;
 		event->_C.A._effect = L0670_ui_Step;
-		f238_addEventGetEventIndex(event);
+		addEventGetEventIndex(event);
 		break;
 	case 1:
 		L0667_T_Thing = _vm->_dungeonMan->getSquareFirstThing(L0664_i_MapX, L0665_i_MapY);
@@ -1093,9 +1093,9 @@ T0255002:
 	}
 }
 
-void Timeline::save3_eventsPart(Common::OutSaveFile* file) {
-	for (uint16 i = 0; i < _g369_eventMaxCount; ++i) {
-		TimelineEvent *event = &_g370_events[i];
+void Timeline::saveEventsPart(Common::OutSaveFile* file) {
+	for (uint16 i = 0; i < _eventMaxCount; ++i) {
+		TimelineEvent *event = &_events[i];
 		file->writeSint32BE(event->_mapTime);
 		file->writeByte(event->_type);
 		file->writeByte(event->_priority);
@@ -1106,14 +1106,14 @@ void Timeline::save3_eventsPart(Common::OutSaveFile* file) {
 	}
 }
 
-void Timeline::save4_timelinePart(Common::OutSaveFile* file) {
-	for (uint16 i = 0; i < _g369_eventMaxCount; ++i)
-		file->writeUint16BE(_g371_timeline[i]);
+void Timeline::saveTimelinePart(Common::OutSaveFile* file) {
+	for (uint16 i = 0; i < _eventMaxCount; ++i)
+		file->writeUint16BE(_timeline[i]);
 }
 
-void Timeline::load3_eventsPart(Common::InSaveFile* file) {
-	for (uint16 i = 0; i < _g369_eventMaxCount; ++i) {
-		TimelineEvent *event = &_g370_events[i];
+void Timeline::loadEventsPart(Common::InSaveFile* file) {
+	for (uint16 i = 0; i < _eventMaxCount; ++i) {
+		TimelineEvent *event = &_events[i];
 		event->_mapTime = file->readSint32BE();
 		event->_type = file->readByte();
 		event->_priority = file->readByte();
@@ -1124,9 +1124,9 @@ void Timeline::load3_eventsPart(Common::InSaveFile* file) {
 	}
 }
 
-void Timeline::load4_timelinePart(Common::InSaveFile* file) {
-	for (uint16 i = 0; i < _g369_eventMaxCount; ++i)
-		_g371_timeline[i] = file->readUint16BE();
+void Timeline::loadTimelinePart(Common::InSaveFile* file) {
+	for (uint16 i = 0; i < _eventMaxCount; ++i)
+		_timeline[i] = file->readUint16BE();
 }
 
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index ffc6cc7..d3c63fd 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -95,7 +95,7 @@ k82_TMEventTypeMagicMap_C82 = 82, // @ C82_EVENT_MAGIC_MAP
 k83_TMEventTypeMagicMap_C83 = 83  // @ C83_EVENT_MAGIC_MAP    
 };
 
-extern signed char g495_actionDefense[44]; // @ G0495_ac_Graphic560_ActionDefense
+extern signed char _actionDefense[44]; // @ G0495_ac_Graphic560_ActionDefense
 
 class TimelineEvent {
 public:
@@ -149,51 +149,50 @@ public:
 class Timeline {
 	DMEngine *_vm;
 public:
-	uint16 _g369_eventMaxCount; // @ G0369_ui_EventMaximumCount
-	TimelineEvent *_g370_events; // @ G0370_ps_Events
-	uint16 _g372_eventCount; // @ G0372_ui_EventCount 
-	uint16 *_g371_timeline; // @ G0371_pui_Timeline
-	uint16 _g373_firstUnusedEventIndex; // @ G0373_ui_FirstUnusedEventIndex
+	uint16 _eventMaxCount; // @ G0369_ui_EventMaximumCount
+	TimelineEvent *_events; // @ G0370_ps_Events
+	uint16 _eventCount; // @ G0372_ui_EventCount 
+	uint16 *_timeline; // @ G0371_pui_Timeline
+	uint16 _firstUnusedEventIndex; // @ G0373_ui_FirstUnusedEventIndex
 
 	explicit Timeline(DMEngine *vm);
 	~Timeline();
-	void f233_initTimeline(); // @ F0233_TIMELINE_Initialize
-	void f237_deleteEvent(uint16 eventIndex);// @ F0237_TIMELINE_DeleteEvent
-	void f236_fixChronology(uint16 timelineIndex); // @ F0236_TIMELINE_FixChronology
-	bool f234_isEventABeforeB(TimelineEvent *eventA, TimelineEvent *eventB); // @ F0234_TIMELINE_IsEventABeforeEventB
-	uint16 f235_getIndex(uint16 eventIndex); // @ F0235_TIMELINE_GetIndex
-	uint16 f238_addEventGetEventIndex(TimelineEvent *event); // @ F0238_TIMELINE_AddEvent_GetEventIndex_CPSE
-	void f261_processTimeline(); // @ F0261_TIMELINE_Process_CPSEF
-	bool f240_isFirstEventExpiered(); // @ F0240_TIMELINE_IsFirstEventExpired_CPSE
-	void f239_timelineExtractFirstEvent(TimelineEvent *event); // @ F0239_TIMELINE_ExtractFirstEvent
-	void f241_timelineProcessEvent1_doorAnimation(TimelineEvent *event); // @ F0241_TIMELINE_ProcessEvent1_DoorAnimation
-	void f242_timelineProcessEvent7_squareFakewall(TimelineEvent *event); // @ F0242_TIMELINE_ProcessEvent7_Square_FakeWall
-	void f243_timelineProcessEvent2_doorDestruction(TimelineEvent *event); // @ F0243_TIMELINE_ProcessEvent2_DoorDestruction
-	void f244_timelineProcessEvent10_squareDoor(TimelineEvent *event); // @ F0244_TIMELINE_ProcessEvent10_Square_Door
-	void f251_timelineProcessEvent9_squarePit(TimelineEvent *event); // @ F0251_TIMELINE_ProcessEvent9_Square_Pit
-	void f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY); // @ F0249_TIMELINE_MoveTeleporterOrPitSquareThings
-	void f250_timelineProcessEvent8_squareTeleporter(TimelineEvent *event); // @ F0250_TIMELINE_ProcessEvent8_Square_Teleporter
-	void f248_timelineProcessEvent6_squareWall(TimelineEvent *event); // @ F0248_TIMELINE_ProcessEvent6_Square_Wall
-	void f247_triggerProjectileLauncher(Sensor *sensor, TimelineEvent *event); // @ F0247_TIMELINE_TriggerProjectileLauncher
-	void f245_timlineProcessEvent5_squareCorridor(TimelineEvent *event); // @ F0245_TIMELINE_ProcessEvent5_Square_Corridor
-	void f252_timelineProcessEvents60to61_moveGroup(TimelineEvent *event); // @ F0252_TIMELINE_ProcessEvents60to61_MoveGroup
-	void f246_timelineProcesEvent65_enableGroupGenerator(TimelineEvent *event); // @ F0246_TIMELINE_ProcessEvent65_EnableGroupGenerator
-	void f253_timelineProcessEvent11Part1_enableChampionAction(uint16 champIndex); // @ F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction
-	void f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(uint16 champIndex,
+	void initTimeline(); // @ F0233_TIMELINE_Initialize
+	void deleteEvent(uint16 eventIndex);// @ F0237_TIMELINE_DeleteEvent
+	void fixChronology(uint16 timelineIndex); // @ F0236_TIMELINE_FixChronology
+	bool isEventABeforeB(TimelineEvent *eventA, TimelineEvent *eventB); // @ F0234_TIMELINE_IsEventABeforeEventB
+	uint16 getIndex(uint16 eventIndex); // @ F0235_TIMELINE_GetIndex
+	uint16 addEventGetEventIndex(TimelineEvent *event); // @ F0238_TIMELINE_AddEvent_GetEventIndex_CPSE
+	void processTimeline(); // @ F0261_TIMELINE_Process_CPSEF
+	bool isFirstEventExpiered(); // @ F0240_TIMELINE_IsFirstEventExpired_CPSE
+	void extractFirstEvent(TimelineEvent *event); // @ F0239_TIMELINE_ExtractFirstEvent
+	void processEventDoorAnimation(TimelineEvent *event); // @ F0241_TIMELINE_ProcessEvent1_DoorAnimation
+	void processEventSquareFakewall(TimelineEvent *event); // @ F0242_TIMELINE_ProcessEvent7_Square_FakeWall
+	void processEventDoorDestruction(TimelineEvent *event); // @ F0243_TIMELINE_ProcessEvent2_DoorDestruction
+	void processEventSquareDoor(TimelineEvent *event); // @ F0244_TIMELINE_ProcessEvent10_Square_Door
+	void processEventSquarePit(TimelineEvent *event); // @ F0251_TIMELINE_ProcessEvent9_Square_Pit
+	void moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY); // @ F0249_TIMELINE_MoveTeleporterOrPitSquareThings
+	void processEventSquareTeleporter(TimelineEvent *event); // @ F0250_TIMELINE_ProcessEvent8_Square_Teleporter
+	void processEventSquareWall(TimelineEvent *event); // @ F0248_TIMELINE_ProcessEvent6_Square_Wall
+	void triggerProjectileLauncher(Sensor *sensor, TimelineEvent *event); // @ F0247_TIMELINE_TriggerProjectileLauncher
+	void processEventSquareCorridor(TimelineEvent *event); // @ F0245_TIMELINE_ProcessEvent5_Square_Corridor
+	void processEventsMoveGroup(TimelineEvent *event); // @ F0252_TIMELINE_ProcessEvents60to61_MoveGroup
+	void procesEventEnableGroupGenerator(TimelineEvent *event); // @ F0246_TIMELINE_ProcessEvent65_EnableGroupGenerator
+	void processEventEnableChampionAction(uint16 champIndex); // @ F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction
+	void processEventMoveWeaponFromQuiverToSlot(uint16 champIndex,
 																	 uint16 slotIndex);// @ F0259_TIMELINE_ProcessEvent11Part2_MoveWeaponFromQuiverToSlot
-	bool f258_timelineHasWeaponMovedSlot(int16 champIndex, Champion *champ,
+	bool hasWeaponMovedSlot(int16 champIndex, Champion *champ,
 										 uint16 sourceSlotIndex, int16 destSlotIndex); // @ F0258_TIMELINE_HasWeaponMovedToSlot
-	void f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex); // @ F0254_TIMELINE_ProcessEvent12_HideDamageReceived
-	void f257_timelineProcessEvent70_light(TimelineEvent *event); // @ F0257_TIMELINE_ProcessEvent70_Light
-	void f260_timelineRefreshAllChampionStatusBoxes(); // @ F0260_TIMELINE_RefreshAllChampionStatusBoxes
-	void f255_timelineProcessEvent13_ViAltarRebirth(TimelineEvent *event); // @ F0255_TIMELINE_ProcessEvent13_ViAltarRebirth
-	void save3_eventsPart(Common::OutSaveFile *file);
-	void save4_timelinePart(Common::OutSaveFile *file);
-	void load3_eventsPart(Common::InSaveFile* file);
-	void load4_timelinePart(Common::InSaveFile* file);
+	void processEventHideDamageReceived(uint16 champIndex); // @ F0254_TIMELINE_ProcessEvent12_HideDamageReceived
+	void processEventLight(TimelineEvent *event); // @ F0257_TIMELINE_ProcessEvent70_Light
+	void refreshAllChampionStatusBoxes(); // @ F0260_TIMELINE_RefreshAllChampionStatusBoxes
+	void processEventViAltarRebirth(TimelineEvent *event); // @ F0255_TIMELINE_ProcessEvent13_ViAltarRebirth
+	void saveEventsPart(Common::OutSaveFile *file);
+	void saveTimelinePart(Common::OutSaveFile *file);
+	void loadEventsPart(Common::InSaveFile* file);
+	void loadTimelinePart(Common::InSaveFile* file);
 };
 
-
 }
 
 #endif


Commit: 8f6f350aa5ac89ab0aa4a4203ce2bf7e608a783f
    https://github.com/scummvm/scummvm/commit/8f6f350aa5ac89ab0aa4a4203ce2bf7e608a783f
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Renaming in ChampionMan

Changed paths:
    engines/dm/champion.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index cebd00f..00b7e80 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -132,23 +132,23 @@ void ChampionMan::initConstants() {
 
 	_boxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait 
 
-	const char **g417_byLanguage;
+	const char **baseSkillName;
 	switch (_vm->getGameLanguage()) { // localized
 	case Common::EN_ANY: 
-		g417_byLanguage = g417_baseSkillName_EN_ANY;
+		baseSkillName = g417_baseSkillName_EN_ANY;
 		break;
 	case Common::DE_DEU:
-		g417_byLanguage = g417_baseSkillName_DE_DEU;
+		baseSkillName = g417_baseSkillName_DE_DEU;
 		break;
 	case Common::FR_FRA:
-		g417_byLanguage = g417_baseSkillName_FR_FRA;
+		baseSkillName = g417_baseSkillName_FR_FRA;
 		break;
 	default:
 		error("Unexpected language used");
 	}
 
 	for (int i = 0; i < 4; ++i) {
-		_baseSkillName[i] = g417_byLanguage[i];
+		_baseSkillName[i] = baseSkillName[i];
 		_championColor[i] = championColor[i];
 		_boxChampionIcons[i] = boxChampionIcons[i];
 	}


Commit: 6a5182ac199496506ccd63034c5e36ec0bc76237
    https://github.com/scummvm/scummvm/commit/6a5182ac199496506ccd63034c5e36ec0bc76237
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Renaming in DialogMan::getChoice()

Changed paths:
    engines/dm/dialog.cpp



diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index 25ff25d..c6b317c 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -163,18 +163,11 @@ bool DialogMan::isMessageOnTwoLines(const char *str, char *part1, char *part2) {
 }
 
 int16 DialogMan::getChoice(uint16 choiceCount, uint16 dialogSetIndex, int16 driveType, int16 automaticChoiceIfFlopyInDrive) {
-	MouseInput *L1298_ps_PrimaryMouseInputBackup;
-	MouseInput *L1299_ps_SecondaryMouseInputBackup;
-	KeyboardInput *L1300_ps_PrimaryKeyboardInputBackup;
-	KeyboardInput *L1301_ps_SecondaryKeyboardInputBackup;
-	Box L1303_s_BoxB;
-	Box L1304_s_BoxA;
-
 	_vm->_eventMan->hideMouse();
-	L1298_ps_PrimaryMouseInputBackup = _vm->_eventMan->_primaryMouseInput;
-	L1299_ps_SecondaryMouseInputBackup = _vm->_eventMan->_secondaryMouseInput;
-	L1300_ps_PrimaryKeyboardInputBackup = _vm->_eventMan->_primaryKeyboardInput;
-	L1301_ps_SecondaryKeyboardInputBackup = _vm->_eventMan->_secondaryKeyboardInput;
+	MouseInput *primaryMouseInputBackup = _vm->_eventMan->_primaryMouseInput;
+	MouseInput *secondaryMouseInputBackup = _vm->_eventMan->_secondaryMouseInput;
+	KeyboardInput *primaryKeyboardInputBackup = _vm->_eventMan->_primaryKeyboardInput;
+	KeyboardInput *secondaryKeyboardInputBackup = _vm->_eventMan->_secondaryKeyboardInput;
 	_vm->_eventMan->_secondaryMouseInput = nullptr;
 	_vm->_eventMan->_primaryKeyboardInput = nullptr;
 	_vm->_eventMan->_secondaryKeyboardInput = nullptr;
@@ -194,73 +187,70 @@ int16 DialogMan::getChoice(uint16 choiceCount, uint16 dialogSetIndex, int16 driv
 		}
 	} while (_selectedDialogChoice == 99);
 	_vm->_displayMan->_useByteBoxCoordinates = false;
-	L1304_s_BoxA = _vm->_eventMan->_primaryMouseInput[_selectedDialogChoice - 1]._hitbox;
-	L1304_s_BoxA._x1 -= 3;
-	L1304_s_BoxA._x2 += 3;
-	L1304_s_BoxA._y1 -= 3;
-	L1304_s_BoxA._y2 += 4;
+	Box boxA = _vm->_eventMan->_primaryMouseInput[_selectedDialogChoice - 1]._hitbox;
+	boxA._x1 -= 3;
+	boxA._x2 += 3;
+	boxA._y1 -= 3;
+	boxA._y2 += 4;
 	_vm->_eventMan->showMouse();
 	_vm->_displayMan->_drawFloorAndCeilingRequested = true;
-	L1303_s_BoxB._x1 = 0;
-	L1303_s_BoxB._y1 = 0;
-	L1303_s_BoxB._y2 = L1304_s_BoxA._y2 - L1304_s_BoxA._y1 + 3;
-	L1303_s_BoxB._x2 = L1304_s_BoxA._x2 - L1304_s_BoxA._x1 + 3;
+	Box boxB(0, 0, boxA._x2 - boxA._x1 + 3, boxA._y2 - boxA._y1 + 3);
 	_vm->_displayMan->blitToBitmap(_vm->_displayMan->_bitmapScreen, _vm->_displayMan->_bitmapViewport,
-										L1303_s_BoxB, L1304_s_BoxA._x1, L1304_s_BoxA._y1, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 25);
+										boxB, boxA._x1, boxA._y1, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 25);
 	_vm->delay(1);
-	L1303_s_BoxB = L1304_s_BoxA;
-	L1303_s_BoxB._y2 = L1303_s_BoxB._y1;
-	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
-	L1303_s_BoxB = L1304_s_BoxA;
-	L1303_s_BoxB._x2 = L1303_s_BoxB._x1;
-	L1303_s_BoxB._y2--;
-	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
-	L1303_s_BoxB = L1304_s_BoxA;
-	L1303_s_BoxB._y2--;
-	L1303_s_BoxB._y1 = L1303_s_BoxB._y2;
-	L1303_s_BoxB._x1 -= 2;
-	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
-	L1303_s_BoxB = L1304_s_BoxA;
-	L1303_s_BoxB._x1 = L1303_s_BoxB._x2;
-	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
+	boxB = boxA;
+	boxB._y2 = boxB._y1;
+	_vm->_displayMan->fillScreenBox(boxB, k5_ColorLightBrown);
+	boxB = boxA;
+	boxB._x2 = boxB._x1;
+	boxB._y2--;
+	_vm->_displayMan->fillScreenBox(boxB, k5_ColorLightBrown);
+	boxB = boxA;
+	boxB._y2--;
+	boxB._y1 = boxB._y2;
+	boxB._x1 -= 2;
+	_vm->_displayMan->fillScreenBox(boxB, k0_ColorBlack);
+	boxB = boxA;
+	boxB._x1 = boxB._x2;
+	_vm->_displayMan->fillScreenBox(boxB, k0_ColorBlack);
 	_vm->delay(2);
-	L1303_s_BoxB = L1304_s_BoxA;
-	L1303_s_BoxB._y1++;
-	L1303_s_BoxB._y2 = L1303_s_BoxB._y1;
-	L1303_s_BoxB._x2 -= 2;
-	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
-	L1303_s_BoxB = L1304_s_BoxA;
-	L1303_s_BoxB._x1++;
-	L1303_s_BoxB._x2 = L1303_s_BoxB._x1;
-	L1303_s_BoxB._y2--;
-	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k5_ColorLightBrown);
-	L1303_s_BoxB = L1304_s_BoxA;
-	L1303_s_BoxB._x2--;
-	L1303_s_BoxB._x1 = L1303_s_BoxB._x2;
-	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
-	L1303_s_BoxB = L1304_s_BoxA;
-	L1303_s_BoxB._y1 = L1303_s_BoxB._y2 = L1303_s_BoxB._y2 - 2;
-	L1303_s_BoxB._x1++;
-	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k0_ColorBlack);
-	L1303_s_BoxB = L1304_s_BoxA;
-	L1303_s_BoxB._y1 = L1303_s_BoxB._y2 = L1303_s_BoxB._y2 + 2;
-	L1303_s_BoxB._x1--;
-	L1303_s_BoxB._x2 += 2;
-	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k13_ColorLightestGray);
-	L1303_s_BoxB = L1304_s_BoxA;
-	L1303_s_BoxB._x1 = L1303_s_BoxB._x2 = L1303_s_BoxB._x2 + 3;
-	L1303_s_BoxB._y2 += 2;
-	_vm->_displayMan->fillScreenBox(L1303_s_BoxB, k13_ColorLightestGray);
+	boxB = boxA;
+	boxB._y1++;
+	boxB._y2 = boxB._y1;
+	boxB._x2 -= 2;
+	_vm->_displayMan->fillScreenBox(boxB, k5_ColorLightBrown);
+	boxB = boxA;
+	boxB._x1++;
+	boxB._x2 = boxB._x1;
+	boxB._y2--;
+	_vm->_displayMan->fillScreenBox(boxB, k5_ColorLightBrown);
+	boxB = boxA;
+	boxB._x2--;
+	boxB._x1 = boxB._x2;
+	_vm->_displayMan->fillScreenBox(boxB, k0_ColorBlack);
+	boxB = boxA;
+	boxB._y1 = boxB._y2 = boxB._y2 - 2;
+	boxB._x1++;
+	_vm->_displayMan->fillScreenBox(boxB, k0_ColorBlack);
+	boxB = boxA;
+	boxB._y1 = boxB._y2 = boxB._y2 + 2;
+	boxB._x1--;
+	boxB._x2 += 2;
+	_vm->_displayMan->fillScreenBox(boxB, k13_ColorLightestGray);
+	boxB = boxA;
+	boxB._x1 = boxB._x2 = boxB._x2 + 3;
+	boxB._y2 += 2;
+	_vm->_displayMan->fillScreenBox(boxB, k13_ColorLightestGray);
 	_vm->delay(2);
-	L1304_s_BoxA._x2 += 3;
-	L1304_s_BoxA._y2 += 3;
+	boxA._x2 += 3;
+	boxA._y2 += 3;
 	_vm->_displayMan->blitToBitmap(_vm->_displayMan->_bitmapViewport, _vm->_displayMan->_bitmapScreen,
-										L1304_s_BoxA, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 25, k200_heightScreen);
+										boxA, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 25, k200_heightScreen);
 	_vm->_eventMan->hideMouse();
-	_vm->_eventMan->_primaryMouseInput = L1298_ps_PrimaryMouseInputBackup;
-	_vm->_eventMan->_secondaryMouseInput = L1299_ps_SecondaryMouseInputBackup;
-	_vm->_eventMan->_primaryKeyboardInput = L1300_ps_PrimaryKeyboardInputBackup;
-	_vm->_eventMan->_secondaryKeyboardInput = L1301_ps_SecondaryKeyboardInputBackup;
+	_vm->_eventMan->_primaryMouseInput = primaryMouseInputBackup;
+	_vm->_eventMan->_secondaryMouseInput = secondaryMouseInputBackup;
+	_vm->_eventMan->_primaryKeyboardInput = primaryKeyboardInputBackup;
+	_vm->_eventMan->_secondaryKeyboardInput = secondaryKeyboardInputBackup;
 	_vm->_eventMan->discardAllInput();
 	_vm->_eventMan->showMouse();
 	return _selectedDialogChoice;


Commit: b9986f4f273c0ee6b941ae09dc337013917af1db
    https://github.com/scummvm/scummvm/commit/b9986f4f273c0ee6b941ae09dc337013917af1db
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-26T23:02:22+02:00

Commit Message:
DM: Rework processEntrance() and drawTittle()

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 6124d8f..b3d3e8a 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -551,11 +551,7 @@ void DMEngine::processEntrance() {
 	_displayMan->loadIntoBitmap(k2_entranceLeftDoorGraphicIndice, _entranceDoorAnimSteps[0]);
 	_interfaceCredits = _displayMan->getNativeBitmapOrGraphic(k5_creditsGraphicIndice);
 	_displayMan->_useByteBoxCoordinates = false;
-	Box displayBox;
-	displayBox._x1 = 0;
-	displayBox._x2 = 100;
-	displayBox._y1 = 0;
-	displayBox._y2 = 160;
+	Box displayBox(0, 100, 0, 160);
 	for (uint16 idx = 1; idx < 4; idx++) {
 		_displayMan->blitToBitmap(_entranceDoorAnimSteps[0], _entranceDoorAnimSteps[idx], displayBox, idx << 2, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161);
 		displayBox._x2 -= 4;
@@ -714,9 +710,15 @@ T0444017:
 
 			switch (getGameLanguage()) { // localized
 			default:
-			case Common::EN_ANY: _textMan->printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RESTART THIS GAME"); break;
-			case Common::DE_DEU: _textMan->printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "DIESES SPIEL NEU STARTEN"); break;
-			case Common::FR_FRA: _textMan->printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RECOMMENCER CE JEU"); break;
+			case Common::EN_ANY:
+				_textMan->printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RESTART THIS GAME");
+				break;
+			case Common::DE_DEU:
+				_textMan->printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "DIESES SPIEL NEU STARTEN");
+				break;
+			case Common::FR_FRA:
+				_textMan->printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RECOMMENCER CE JEU");
+				break;
 			}
 
 			curPalette[1] = D03_RGB_PINK;
@@ -844,81 +846,76 @@ void DMEngine::openEntranceDoors() {
 }
 
 void DMEngine::drawTittle() {
-	static Box G0003_s_Graphic562_Box_Title_StrikesBack_Destination(0, 319, 118, 174);
-	static Box G0004_s_Graphic562_Box_Title_StrikesBack_Source(0, 319, 0, 56);
-	static Box G0005_s_Graphic562_Box_Title_Presents(0, 319, 90, 105);
-	static Box K0078_s_Box_Title_Dungeon_Chaos(0, 319, 0, 79);
-
-	int16 L1380_i_Counter;
-	uint16 L1381_ui_DestinationHeight;
-	int16 L1382_i_DestinationPixelWidth;
-	byte *L1383_l_Bitmap_TitleSteps;
-	byte* L1384_puc_Bitmap_Title;
-	byte* L1387_apuc_Bitmap_ShrinkedTitle[20]; /* Only the first 18 entries are actually used */
-	byte* L1389_puc_Bitmap_Master_StrikesBack;
-	byte* L1761_puc_Bitmap_Dungeon_Chaos; /* Unreferenced on Atari ST */
-	int16 L1391_aai_Coordinates[20][5]; /* Only the first 18 entries are actually used */
-	uint16 L1392_aui_Palette[16];
-
+	static Box boxTitleStrikesBackDestination(0, 319, 118, 174);
+	static Box boxTitleStrikesBackSource(0, 319, 0, 56);
+	static Box boxTitlePresents(0, 319, 90, 105);
+	static Box boxTitleDungeonChaos(0, 319, 0, 79);
 
 	_displayMan->_useByteBoxCoordinates = false;
 
-	byte *alloactedMem = L1383_l_Bitmap_TitleSteps = new byte[145600 * 2];
-
-	L1384_puc_Bitmap_Title = L1383_l_Bitmap_TitleSteps;
-	_displayMan->loadIntoBitmap(k1_titleGraphicsIndice, L1383_l_Bitmap_TitleSteps);
+	byte *allocatedMem = new byte[145600 * 2];
+	byte *titleSteps = allocatedMem;
+	byte *bitmapTitle = titleSteps;
+	_displayMan->loadIntoBitmap(k1_titleGraphicsIndice, titleSteps);
 
-	L1383_l_Bitmap_TitleSteps += 320 * 200;
+	titleSteps += 320 * 200;
+	uint16 blitPalette[16];
 	for (uint16 i = 0; i < 16; ++i)
-		L1392_aui_Palette[i] = D01_RGB_DARK_BLUE;
+		blitPalette[i] = D01_RGB_DARK_BLUE;
 
-	_displayMan->startEndFadeToPalette(L1392_aui_Palette);
+	_displayMan->startEndFadeToPalette(blitPalette);
 	_displayMan->fillScreen(k0_ColorBlack);
 	// uncomment this to draw 'Presents'
 	//_displayMan->f132_blitToBitmap(L1384_puc_Bitmap_Title, _displayMan->_g348_bitmapScreen, G0005_s_Graphic562_Box_Title_Presents, 0, 137, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, k200_heightScreen, k200_heightScreen);
-	L1392_aui_Palette[15] = D09_RGB_WHITE;
-	_displayMan->startEndFadeToPalette(L1392_aui_Palette);
-	_displayMan->blitToBitmap(L1384_puc_Bitmap_Title, L1389_puc_Bitmap_Master_StrikesBack = L1383_l_Bitmap_TitleSteps, G0004_s_Graphic562_Box_Title_StrikesBack_Source, 0, 80, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 57);
-	L1383_l_Bitmap_TitleSteps += 320 * 57;
-	_displayMan->blitToBitmap(L1384_puc_Bitmap_Title, L1761_puc_Bitmap_Dungeon_Chaos = L1383_l_Bitmap_TitleSteps, K0078_s_Box_Title_Dungeon_Chaos, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 80);
-	L1383_l_Bitmap_TitleSteps += 320 * 80;
-	L1384_puc_Bitmap_Title = L1761_puc_Bitmap_Dungeon_Chaos;
-	L1381_ui_DestinationHeight = 12;
-	L1382_i_DestinationPixelWidth = 48;
-	for (L1380_i_Counter = 0; L1380_i_Counter < 18; L1380_i_Counter++) {
-		L1387_apuc_Bitmap_ShrinkedTitle[L1380_i_Counter] = L1383_l_Bitmap_TitleSteps;
-		_displayMan->blitToBitmapShrinkWithPalChange(L1384_puc_Bitmap_Title, L1383_l_Bitmap_TitleSteps, 320, 80, L1382_i_DestinationPixelWidth, L1381_ui_DestinationHeight, _displayMan->_palChangesNoChanges);
-		L1391_aai_Coordinates[L1380_i_Counter][1] = (L1391_aai_Coordinates[L1380_i_Counter][0] = (320 - L1382_i_DestinationPixelWidth) / 2) + L1382_i_DestinationPixelWidth - 1;
-		L1391_aai_Coordinates[L1380_i_Counter][3] = (L1391_aai_Coordinates[L1380_i_Counter][2] = ((int)(160 - L1381_ui_DestinationHeight)) / 2) + L1381_ui_DestinationHeight - 1;
-		L1383_l_Bitmap_TitleSteps += (L1391_aai_Coordinates[L1380_i_Counter][4] = ((L1382_i_DestinationPixelWidth + 15) / 16) * 8) * L1381_ui_DestinationHeight * 2;
-		L1381_ui_DestinationHeight += 4;
-		L1382_i_DestinationPixelWidth += 16;
+	blitPalette[15] = D09_RGB_WHITE;
+	_displayMan->startEndFadeToPalette(blitPalette);
+	byte *masterStrikesBack = titleSteps;
+	_displayMan->blitToBitmap(bitmapTitle, masterStrikesBack, boxTitleStrikesBackSource, 0, 80, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 57);
+	titleSteps += 320 * 57;
+	byte *bitmapDungeonChaos = titleSteps; /* Unreferenced on Atari ST */
+	_displayMan->blitToBitmap(bitmapTitle, bitmapDungeonChaos, boxTitleDungeonChaos, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, kM1_ColorNoTransparency, 200, 80);
+	titleSteps += 320 * 80;
+	bitmapTitle = bitmapDungeonChaos;
+	uint16 destinationHeight = 12;
+	int16 destinationPixelWidth = 48;
+	byte *shrinkedTitle[20]; /* Only the first 18 entries are actually used */
+	int16 blitCoordinates[20][5]; /* Only the first 18 entries are actually used */
+	for (int16 i = 0; i < 18; i++) {
+		shrinkedTitle[i] = titleSteps;
+		_displayMan->blitToBitmapShrinkWithPalChange(bitmapTitle, titleSteps, 320, 80, destinationPixelWidth, destinationHeight, _displayMan->_palChangesNoChanges);
+		blitCoordinates[i][0] = (320 - destinationPixelWidth) / 2;
+		blitCoordinates[i][1] = blitCoordinates[i][0] + destinationPixelWidth - 1;
+		blitCoordinates[i][2] = (160 - destinationHeight) / 2;
+		blitCoordinates[i][3] = blitCoordinates[i][2] + destinationHeight - 1;
+		titleSteps += (blitCoordinates[i][4] = ((destinationPixelWidth + 15) / 16) * 8) * destinationHeight * 2;
+		destinationHeight += 4;
+		destinationPixelWidth += 16;
 	}
-	L1392_aui_Palette[15] = D01_RGB_DARK_BLUE;
-	_displayMan->startEndFadeToPalette(L1392_aui_Palette);
+	blitPalette[15] = D01_RGB_DARK_BLUE;
+	_displayMan->startEndFadeToPalette(blitPalette);
 	_displayMan->fillScreen(k0_ColorBlack);
-	L1392_aui_Palette[3] = D05_RGB_DARK_GOLD;
-	L1392_aui_Palette[4] = D02_RGB_LIGHT_BROWN;
-	L1392_aui_Palette[5] = D06_RGB_GOLD;
-	L1392_aui_Palette[6] = D04_RGB_LIGHTER_BROWN;
-	L1392_aui_Palette[8] = D08_RGB_YELLOW;
-	L1392_aui_Palette[15] = D07_RGB_RED;
-	L1392_aui_Palette[10] = D01_RGB_DARK_BLUE;
-	L1392_aui_Palette[12] = D01_RGB_DARK_BLUE;
-	_displayMan->startEndFadeToPalette(L1392_aui_Palette);
+	blitPalette[3] = D05_RGB_DARK_GOLD;
+	blitPalette[4] = D02_RGB_LIGHT_BROWN;
+	blitPalette[5] = D06_RGB_GOLD;
+	blitPalette[6] = D04_RGB_LIGHTER_BROWN;
+	blitPalette[8] = D08_RGB_YELLOW;
+	blitPalette[15] = D07_RGB_RED;
+	blitPalette[10] = D01_RGB_DARK_BLUE;
+	blitPalette[12] = D01_RGB_DARK_BLUE;
+	_displayMan->startEndFadeToPalette(blitPalette);
 	delay(1);
-	for (L1380_i_Counter = 0; L1380_i_Counter < 18; L1380_i_Counter++) {
+	for (int16 i = 0; i < 18; i++) {
 		delay(2);
-		Box box(L1391_aai_Coordinates[L1380_i_Counter]);
-		_displayMan->blitToBitmap(L1387_apuc_Bitmap_ShrinkedTitle[L1380_i_Counter], _displayMan->_bitmapScreen, box, 0, 0, L1391_aai_Coordinates[L1380_i_Counter][4], k160_byteWidthScreen, kM1_ColorNoTransparency, L1391_aai_Coordinates[L1380_i_Counter][3] - L1391_aai_Coordinates[L1380_i_Counter][2] + 1, k200_heightScreen);
+		Box box(blitCoordinates[i]);
+		_displayMan->blitToBitmap(shrinkedTitle[i], _displayMan->_bitmapScreen, box, 0, 0, blitCoordinates[i][4], k160_byteWidthScreen, kM1_ColorNoTransparency, blitCoordinates[i][3] - blitCoordinates[i][2] + 1, k200_heightScreen);
 	}
-	delay(25L);
-	_displayMan->blitToBitmap(L1389_puc_Bitmap_Master_StrikesBack, _displayMan->_bitmapScreen, G0003_s_Graphic562_Box_Title_StrikesBack_Destination, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, k0_ColorBlack, 57, k200_heightScreen);
-	L1392_aui_Palette[10] = D00_RGB_BLACK;
-	L1392_aui_Palette[12] = D07_RGB_RED;
-	_displayMan->startEndFadeToPalette(L1392_aui_Palette);
-	delete[] alloactedMem;
-	delay(75L);
+	delay(25);
+	_displayMan->blitToBitmap(masterStrikesBack, _displayMan->_bitmapScreen, boxTitleStrikesBackDestination, 0, 0, k160_byteWidthScreen, k160_byteWidthScreen, k0_ColorBlack, 57, k200_heightScreen);
+	blitPalette[10] = D00_RGB_BLACK;
+	blitPalette[12] = D07_RGB_RED;
+	_displayMan->startEndFadeToPalette(blitPalette);
+	delete[] allocatedMem;
+	delay(75);
 }
 
 void DMEngine::entranceDrawCredits() {


Commit: bf5875d2fe5ae1a12212e3956012171c7bb8b33c
    https://github.com/scummvm/scummvm/commit/bf5875d2fe5ae1a12212e3956012171c7bb8b33c
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-27T10:54:29+02:00

Commit Message:
DM: Janitorial - Fix the style of some pointers

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 00b7e80..95f5bfa 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1082,7 +1082,7 @@ int16 ChampionMan::getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) {
 	return kM1_ChampionNone;
 }
 
-int16 ChampionMan::getDexterity(Champion* champ) {
+int16 ChampionMan::getDexterity(Champion *champ) {
 	int16 dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent];
 	dexterity -= ((int32)(dexterity >> 1) * (int32)champ->_load) / getMaximumLoad(champ);
 	if (_partyIsSleeping)
@@ -1091,7 +1091,7 @@ int16 ChampionMan::getDexterity(Champion* champ) {
 	return getBoundedValue(1 + _vm->getRandomNumber(8), dexterity >> 1, 100 - _vm->getRandomNumber(8));
 }
 
-bool ChampionMan::isLucky(Champion* champ, uint16 percentage) {
+bool ChampionMan::isLucky(Champion *champ, uint16 percentage) {
 	if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage))
 		return true;
 
@@ -1355,7 +1355,7 @@ bool ChampionMan::isProjectileSpellCast(uint16 champIndex, Thing thing, int16 ki
 	return true; // fix BUG_01
 }
 
-void ChampionMan::championShootProjectile(Champion* champ, Thing thing, int16 kineticEnergy, int16 attack, int16 stepEnergy) {
+void ChampionMan::championShootProjectile(Champion *champ, Thing thing, int16 kineticEnergy, int16 attack, int16 stepEnergy) {
 	Direction newDirection = champ->_dir;
 	_vm->_projexpl->createProjectile(thing, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, normalizeModulo4((((champ->_cell - newDirection + 1) & 0x0002) >> 1) + newDirection), newDirection, kineticEnergy, attack, stepEnergy);
 	_vm->_projectileDisableMovementTicks = 4;
@@ -1694,7 +1694,7 @@ void ChampionMan::applyTimeEffects() {
 	drawAllChampionStates();
 }
 
-void ChampionMan::savePartyPart2(Common::OutSaveFile* file) {
+void ChampionMan::savePartyPart2(Common::OutSaveFile *file) {
 	for (uint16 i = 0; i < 4; ++i) {
 		Champion *champ = &_champions[i];
 		file->writeUint16BE(champ->_attributes);
@@ -1756,7 +1756,7 @@ void ChampionMan::savePartyPart2(Common::OutSaveFile* file) {
 	file->writeByte(party._event71Count_Invisibility);
 }
 
-void ChampionMan::loadPartyPart2(Common::InSaveFile* file) {
+void ChampionMan::loadPartyPart2(Common::InSaveFile *file) {
 	for (uint16 i = 0; i < 4; ++i) {
 		Champion *champ = &_champions[i];
 		champ->_attributes = file->readUint16BE();
@@ -2288,7 +2288,7 @@ uint16 ChampionMan::getChampionIconIndex(int16 val, Direction dir) {
 	return ((val + 4 - dir) & 0x3);
 }
 
-void ChampionMan::drawHealthStaminaManaValues(Champion* champ) {
+void ChampionMan::drawHealthStaminaManaValues(Champion *champ) {
 	drawHealthOrStaminaOrManaValue(116, champ->_currHealth, champ->_maxHealth);
 	drawHealthOrStaminaOrManaValue(124, champ->_currStamina, champ->_maxStamina);
 	drawHealthOrStaminaOrManaValue(132, champ->_currMana, champ->_maxMana);
@@ -2374,7 +2374,7 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 		_vm->_eventMan->showMouse();
 }
 
-void ChampionMan::renameChampion(Champion* champ) {
+void ChampionMan::renameChampion(Champion *champ) {
 #define k1_RENAME_CHAMPION_NAME 1
 #define k2_RENAME_CHAMPION_TITLE 2
 	static const char underscoreCharacterString[2] = "_";
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 82117e8..88fbfcf 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -508,7 +508,7 @@ public:
 	uint16 getChampionIconIndex(int16 val, Direction dir); // @ M26_CHAMPION_ICON_INDEX
 	void drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues
 	void drawSlot(uint16 champIndex, int16 slotIndex); // @ F0291_CHAMPION_DrawSlot
-	void renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename
+	void renameChampion(Champion *champ); // @ F0281_CHAMPION_Rename
 	uint16 getSkillLevel(int16 champIndex, uint16 skillIndex);// @ F0303_CHAMPION_GetSkillLevel
 	Common::String getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger
 	void applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex,
@@ -554,7 +554,7 @@ public:
 	void unpoison(int16 champIndex); // @ F0323_CHAMPION_Unpoison
 	void applyTimeEffects(); // @ F0331_CHAMPION_ApplyTimeEffects_CPSF
 	void savePartyPart2(Common::OutSaveFile *file);
-	void loadPartyPart2(Common::InSaveFile* file);
+	void loadPartyPart2(Common::InSaveFile *file);
 
 	Box _boxChampionIcons[4];
 	Color _championColor[4];
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index b3d3e8a..92d0914 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -64,7 +64,7 @@
 #include <gui/saveload.h>
 
 namespace DM {
-void warning(bool repeat, const char* s, ...) {
+void warning(bool repeat, const char *s, ...) {
 	va_list va;
 
 	va_start(va, s);
@@ -83,8 +83,8 @@ void warning(bool repeat, const char* s, ...) {
 	}
 }
 
-const char* debugGetDirectionName(Direction dir) {
-	static const char* directionNames[] = {"North", "East", "South", "West"};
+const char *debugGetDirectionName(Direction dir) {
+	static const char *directionNames[] = {"North", "East", "South", "West"};
 	if (dir < 0 || dir > 3)
 		return "Invalid direction";
 	return directionNames[dir];
@@ -945,8 +945,8 @@ void DMEngine::fuseSequnce() {
 #define AL1426_i_FuseSequenceUpdateCount L1426_i_Multiple
 #define AL1426_i_TextStringThingCount    L1426_i_Multiple
 	Thing L1427_T_Thing;
-	Group* L1428_ps_Group;
-	Explosion* L1429_ps_Explosion;
+	Group *L1428_ps_Group;
+	Explosion *L1429_ps_Explosion;
 	Thing L1430_T_NextThing;
 	int16 L1431_i_LordChaosMapX;
 	int16 L1432_i_LordChaosMapY;


Commit: 5ca69756651f438fe09e64a706575084440881a7
    https://github.com/scummvm/scummvm/commit/5ca69756651f438fe09e64a706575084440881a7
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-27T11:07:49+02:00

Commit Message:
DM: Remove custom warning function

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/group.cpp
    engines/dm/loadsave.cpp
    engines/dm/sounds.cpp
    engines/dm/text.h



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 92d0914..753b6cb 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -64,25 +64,6 @@
 #include <gui/saveload.h>
 
 namespace DM {
-void warning(bool repeat, const char *s, ...) {
-	va_list va;
-
-	va_start(va, s);
-	Common::String output = Common::String::vformat(s, va);
-	va_end(va);
-
-	if (repeat) {
-		::warning("%s", output.c_str());
-	} else {
-		static Common::Array<Common::String> stringsPrinted;
-
-		if (Common::find(stringsPrinted.begin(), stringsPrinted.end(), s) == stringsPrinted.end()) {
-			stringsPrinted.push_back(output);
-			::warning("%s", output.c_str());
-		}
-	}
-}
-
 const char *debugGetDirectionName(Direction dir) {
 	static const char *directionNames[] = {"North", "East", "South", "West"};
 	if (dir < 0 || dir > 3)
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 921197f..f83f477 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -104,8 +104,6 @@ struct DMADGameDescription {
 	OriginalSavePlatform _origPlatformToAccept[k_savePlatform_total + 1];
 };
 
-void warning(bool repeat, const char *s, ...);
-
 enum Direction {
 	kDirNorth = 0,
 	kDirEast = 1,
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 39f74e5..c267b73 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -390,7 +390,7 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) {
 	_primaryKeyboardInput = nullptr;
 	_secondaryKeyboardInput = nullptr;
 	_ignoreMouseMovements = false;
-	warning(false, "_g587_hideMousePointerRequestCount should start with value 1");
+	warning("_g587_hideMousePointerRequestCount should start with value 1");
 	_hideMousePointerRequestCount = 0;
 	_mouseButtonStatus = 0;
 	_highlightScreenBox.setToZero();
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 5686e50..92d055c 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -288,7 +288,7 @@ public:
 	void waitForMouseOrKeyActivity(); // @ F0541_INPUT_WaitForMouseOrKeyboardActivity
 	void commandHighlightBoxEnable(int16 x1, int16 x2, int16 y1, int16 y2); // @ F0362_COMMAND_HighlightBoxEnable
 	void highlightBoxDisable(); // @ F0363_COMMAND_HighlightBoxDisable
-	void highlightScreenBox(int16 x1, int16 x2, int16 y1, int16 y2) { warning(false, "STUB METHOD: highlightScreenBox"); } // @  F0006_MAIN_HighlightScreenBox
+	void highlightScreenBox(int16 x1, int16 x2, int16 y1, int16 y2) { warning("STUB METHOD: highlightScreenBox"); } // @  F0006_MAIN_HighlightScreenBox
 
 	KeyboardInput _primaryKeyboardInputInterface[7]; // @ G0458_as_Graphic561_PrimaryKeyboardInput_Interface
 	KeyboardInput _secondaryKeyboardInputMovement[19]; // @ G0459_as_Graphic561_SecondaryKeyboardInput_Movement
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 506a2e0..d402305 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -863,7 +863,7 @@ void DisplayMan::blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask
 													int16 lastUnitIndex, int16 firstUnitIndex, int16 destByteWidth, Color transparent,
 													int16 xPos, int16 yPos, int16 destHeight, int16 height2) {
 	// make sure to take care of inclusive boundaries, color can have 0x8000 flag to not use mask
-	warning(false, "STUB: f133_blitBoxFilledWithMaskedBitmap");
+	warning("STUB: f133_blitBoxFilledWithMaskedBitmap");
 }
 
 
@@ -2746,8 +2746,8 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 void DisplayMan::blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap,
 													  int16 srcPixelWidth, int16 srcHeight,
 													  int16 destPixelWidth, int16 destHeight, byte *palChange) {
-	warning(false, "DUMMY CODE: f129_blitToBitmapShrinkWithPalChange");
-	warning(false, "MISSING CODE: No palette change takes place in f129_blitToBitmapShrinkWithPalChange");
+	warning("DUMMY CODE: f129_blitToBitmapShrinkWithPalChange");
+	warning("MISSING CODE: No palette change takes place in f129_blitToBitmapShrinkWithPalChange");
 
 
 	destPixelWidth = (destPixelWidth + 1) & 0xFFFE;
@@ -3668,7 +3668,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 				}
 				blitBoxFilledWithMaskedBitmap(bitmapRedBanana, _bitmapViewport, 0, getDerivedBitmap(k0_DerivedBitmapViewport), boxExplosionPatternD0C, _vm->getRandomNumber(4) + 87, _vm->getRandomNumber(64), k112_byteWidthViewport, Color(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93);
 				addDerivedBitmap(k0_DerivedBitmapViewport);
-				warning(false, "DISABLED CODE: f480_releaseBlock in f115_cthulhu");
+				warning("DISABLED CODE: f480_releaseBlock in drawObjectsCreaturesProjectilesExplosions");
 				//f480_releaseBlock(k0_DerivedBitmapViewport | 0x8000);
 			} else {
 				int16 explosionScale;
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 508d4d8..44e75ab 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -821,7 +821,7 @@ public:
 	uint16 getDarkenedColor(uint16 RGBcolor);
 	void startEndFadeToPalette(uint16 *P0849_pui_Palette); // @ F0436_STARTEND_FadeToPalette
 	void buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom); // @ F0508_AMIGA_BuildPaletteChangeCopperList
-	void shadeScreenBox(Box* box, Color color) { warning(false, "STUB METHOD: shadeScreenBox"); } // @ F0136_VIDEO_ShadeScreenBox
+	void shadeScreenBox(Box* box, Color color) { warning("STUB METHOD: shadeScreenBox"); } // @ F0136_VIDEO_ShadeScreenBox
 
 private:
 	void initConstants();
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index f0a28a1..41aefbb 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1378,7 +1378,7 @@ void GroupMan::setGroupDirection(ActiveGroup *activeGroup, int16 dir, int16 crea
 }
 
 void GroupMan::addGroupEvent(TimelineEvent *event, uint32 time) {
-	warning(false, "potentially dangerous cast to uint32 below");
+	warning("potentially dangerous cast to uint32 below");
 	if (time < (uint32)filterTime(event->_mapTime)) {
 		event->_type -= 5;
 		event->_C._ticks = filterTime(event->_mapTime) - time;
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 5091c00..302d7ef 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -78,8 +78,7 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
 		SaveGameHeader header;
 		readSaveGameHeader(file, &header);
 
-		warning(false, "MISSING CODE: missing check for matching format and platform in save in f435_loadgame");
-
+		warning("MISSING CODE: missing check for matching format and platform in save in f435_loadgame");
 
 		dmSaveHeader._saveTarget = (SaveTarget)file->readSint32BE();
 		dmSaveHeader._saveVersion = file->readSint32BE();
diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp
index 886e5fd..421c299 100644
--- a/engines/dm/sounds.cpp
+++ b/engines/dm/sounds.cpp
@@ -41,9 +41,13 @@ namespace DM {
 
 SoundMan* SoundMan::getSoundMan(DMEngine* vm, const DMADGameDescription* gameVersion) {
 	switch (gameVersion->_desc.platform) {
-	default: warning(false, "Unknown platform, using default Amiga SoundMan");
-	case Common::kPlatformAmiga: return new SoundMan(vm);
-	case Common::kPlatformAtariST: return new SoundMan_Atari(vm);
+	default:
+		warning("Unknown platform, using default Amiga SoundMan");
+		// No break on purpose
+	case Common::kPlatformAmiga:
+		return new SoundMan(vm);
+	case Common::kPlatformAtariST:
+		return new SoundMan_Atari(vm);
 	}
 }
 
diff --git a/engines/dm/text.h b/engines/dm/text.h
index 55392a1..b6049d7 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -64,9 +64,9 @@ public:
 	void clearExpiredRows(); // @ F0044_TEXT_MESSAGEAREA_ClearExpiredRows
 	void printEndGameString(int16 x, int16 y, Color textColor, char *text); // @ F0443_STARTEND_EndgamePrintString
 	bool isTextScrolling(TextScroller *scroller, bool waitEndOfScrolling) {
-		warning(false, "STUB METHOD: isTextScrolling"); return true;
+		warning("STUB METHOD: isTextScrolling"); return true;
 	} // @ F0561_SCROLLER_IsTextScrolling
-	void setScrollerCommand(TextScroller *scroller, int16 command) { warning(false, "STUB METHOD: f560_SCROLLER_setCommand");  } // @ F0560_SCROLLER_SetCommand
+	void setScrollerCommand(TextScroller *scroller, int16 command) { warning("STUB METHOD: f560_SCROLLER_setCommand");  } // @ F0560_SCROLLER_SetCommand
 	void clearAllRows(); // @ F0043_TEXT_MESSAGEAREA_ClearAllRows
 };
 


Commit: 1e2fa9630f16c7908182fe0acb34fcf815c4bded
    https://github.com/scummvm/scummvm/commit/1e2fa9630f16c7908182fe0acb34fcf815c4bded
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-27T14:20:06+02:00

Commit Message:
DM: Rework fuseSequence

Changed paths:
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/group.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 753b6cb..14c5ffa 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -909,34 +909,7 @@ void DMEngine::entranceDrawCredits() {
 	_newGameFl = k202_modeEntranceDrawCredits;
 }
 
-void DMEngine::fuseSequnce() {
-	int16 L1424_i_Multiple;
-#define AL1424_B_RemoveFluxcagesFromLoadChaosSquare L1424_i_Multiple
-#define AL1424_i_Attack                             L1424_i_Multiple
-#define AL1424_i_CreatureTypeSwitchCount            L1424_i_Multiple
-#define AL1424_i_MapX                               L1424_i_Multiple
-#define AL1424_i_TextStringThingCount               L1424_i_Multiple
-	int16 L1425_i_Multiple;
-#define AL1425_i_FluxcageMapX         L1425_i_Multiple
-#define AL1425_i_MapY                 L1425_i_Multiple
-#define AL1425_i_CycleCount           L1425_i_Multiple
-#define AL1425_i_TextStringThingIndex L1425_i_Multiple
-	int16 L1426_i_Multiple;
-#define AL1426_i_FluxcageMapY            L1426_i_Multiple
-#define AL1426_i_FuseSequenceUpdateCount L1426_i_Multiple
-#define AL1426_i_TextStringThingCount    L1426_i_Multiple
-	Thing L1427_T_Thing;
-	Group *L1428_ps_Group;
-	Explosion *L1429_ps_Explosion;
-	Thing L1430_T_NextThing;
-	int16 L1431_i_LordChaosMapX;
-	int16 L1432_i_LordChaosMapY;
-	Thing L1433_T_LordChaosThing;
-	char L1434_c_TextFirstCharacter;
-	Thing L1435_aT_TextStringThings[8];
-	char L1436_ac_String[200];
-
-
+void DMEngine::fuseSequence() {
 	_gameWon = true;
 	if (_inventoryMan->_inventoryChampionOrdinal) {
 		_inventoryMan->toggleInventory(k4_ChampionCloseInventory);
@@ -947,99 +920,104 @@ void DMEngine::fuseSequnce() {
 	_championMan->_party._fireShieldDefense = _championMan->_party._spellShieldDefense = _championMan->_party._shieldDefense = 100;
 	_timeline->refreshAllChampionStatusBoxes();
 	fuseSequenceUpdate();
-	L1431_i_LordChaosMapX = _dungeonMan->_partyMapX;
-	L1432_i_LordChaosMapY = _dungeonMan->_partyMapY;
-	L1431_i_LordChaosMapX += _dirIntoStepCountEast[_dungeonMan->_partyDir], L1432_i_LordChaosMapY += _dirIntoStepCountNorth[_dungeonMan->_partyDir];
-	L1428_ps_Group = (Group*)_dungeonMan->getThingData(L1433_T_LordChaosThing = _groupMan->groupGetThing(L1431_i_LordChaosMapX, L1432_i_LordChaosMapY));
-	L1428_ps_Group->_health[0] = 10000;
-	_dungeonMan->setGroupCells(L1428_ps_Group, k255_CreatureTypeSingleCenteredCreature, _dungeonMan->_partyMapIndex);
-	_dungeonMan->setGroupDirections(L1428_ps_Group, returnOppositeDir(_dungeonMan->_partyDir), _dungeonMan->_partyMapIndex);
-
-	AL1424_B_RemoveFluxcagesFromLoadChaosSquare = true;
-	AL1425_i_FluxcageMapX = _dungeonMan->_partyMapX;
-	AL1426_i_FluxcageMapY = _dungeonMan->_partyMapY;
+	int16 lordChaosMapX = _dungeonMan->_partyMapX;
+	int16 lordChaosMapY = _dungeonMan->_partyMapY;
+	lordChaosMapX += _dirIntoStepCountEast[_dungeonMan->_partyDir], lordChaosMapY += _dirIntoStepCountNorth[_dungeonMan->_partyDir];
+	Thing lordChaosThing = _groupMan->groupGetThing(lordChaosMapX, lordChaosMapY);
+	Group *lordGroup = (Group*)_dungeonMan->getThingData(lordChaosThing);
+	lordGroup->_health[0] = 10000;
+	_dungeonMan->setGroupCells(lordGroup, k255_CreatureTypeSingleCenteredCreature, _dungeonMan->_partyMapIndex);
+	_dungeonMan->setGroupDirections(lordGroup, returnOppositeDir(_dungeonMan->_partyDir), _dungeonMan->_partyMapIndex);
+
+	bool removeFluxcagesFromLordChaosSquare = true;
+	int16 fluxCageMapX = _dungeonMan->_partyMapX;
+	int16 fluxcageMapY = _dungeonMan->_partyMapY;
 T0446002:
-	L1427_T_Thing = _dungeonMan->getSquareFirstObject(AL1425_i_FluxcageMapX, AL1426_i_FluxcageMapY);
-	while (L1427_T_Thing != Thing::_endOfList) {
-		if (L1427_T_Thing.getType() == k15_ExplosionThingType) {
-			L1429_ps_Explosion = (Explosion*)_dungeonMan->getThingData(L1427_T_Thing);
-			if (L1429_ps_Explosion->getType() == k50_ExplosionType_Fluxcage) {
-				_dungeonMan->unlinkThingFromList(L1427_T_Thing, Thing(0), AL1425_i_FluxcageMapX, AL1426_i_FluxcageMapY);
-				L1429_ps_Explosion->setNextThing(Thing::_none);
+	Thing curThing = _dungeonMan->getSquareFirstObject(fluxCageMapX, fluxcageMapY);
+	while (curThing != Thing::_endOfList) {
+		if (curThing.getType() == k15_ExplosionThingType) {
+			Explosion *curExplosion = (Explosion*)_dungeonMan->getThingData(curThing);
+			if (curExplosion->getType() == k50_ExplosionType_Fluxcage) {
+				_dungeonMan->unlinkThingFromList(curThing, Thing(0), fluxCageMapX, fluxcageMapY);
+				curExplosion->setNextThing(Thing::_none);
 				goto T0446002;
 			}
 		}
-		L1427_T_Thing = _dungeonMan->getNextThing(L1427_T_Thing);
+		curThing = _dungeonMan->getNextThing(curThing);
 	}
-	if (AL1424_B_RemoveFluxcagesFromLoadChaosSquare) {
-		AL1424_B_RemoveFluxcagesFromLoadChaosSquare = false;
-		AL1425_i_FluxcageMapX = L1431_i_LordChaosMapX;
-		AL1426_i_FluxcageMapY = L1432_i_LordChaosMapY;
+	if (removeFluxcagesFromLordChaosSquare) {
+		removeFluxcagesFromLordChaosSquare = false;
+		fluxCageMapX = lordChaosMapX;
+		fluxcageMapY = lordChaosMapY;
 		goto T0446002;
 	}
 
 	fuseSequenceUpdate();
-	for (AL1424_i_Attack = 55; AL1424_i_Attack <= 255; AL1424_i_Attack += 40) {
-		_projexpl->createExplosion(Thing::_explFireBall, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
+	for (int16 attackId = 55; attackId <= 255; attackId += 40) {
+		_projexpl->createExplosion(Thing::_explFireBall, attackId, lordChaosMapX, lordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
 		fuseSequenceUpdate();
 	}
-	_sound->requestPlay(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized);
-	L1428_ps_Group->_type = k25_CreatureTypeLordOrder;
+	_sound->requestPlay(k17_soundBUZZ, lordChaosMapX, lordChaosMapY, k1_soundModePlayIfPrioritized);
+	lordGroup->_type = k25_CreatureTypeLordOrder;
 	fuseSequenceUpdate();
-	for (AL1424_i_Attack = 55; AL1424_i_Attack <= 255; AL1424_i_Attack += 40) {
-		_projexpl->createExplosion(Thing::_explHarmNonMaterial, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
+	for (int16 attackId = 55; attackId <= 255; attackId += 40) {
+		_projexpl->createExplosion(Thing::_explHarmNonMaterial, attackId, lordChaosMapX, lordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
 		fuseSequenceUpdate();
 	}
-	for (AL1425_i_CycleCount = 4; --AL1425_i_CycleCount; ) {
-		for (AL1424_i_CreatureTypeSwitchCount = 5; --AL1424_i_CreatureTypeSwitchCount; ) {
-			_sound->requestPlay(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized);
-			L1428_ps_Group->_type = (AL1424_i_CreatureTypeSwitchCount & 0x0001) ? k25_CreatureTypeLordOrder : k23_CreatureTypeLordChaos;
-			for (AL1426_i_FuseSequenceUpdateCount = AL1425_i_CycleCount; AL1426_i_FuseSequenceUpdateCount--; fuseSequenceUpdate());
+	for (int16 cycleCount = 4; --cycleCount; ) {
+		for (int16 switchCount = 5; --switchCount; ) {
+			_sound->requestPlay(k17_soundBUZZ, lordChaosMapX, lordChaosMapY, k1_soundModePlayIfPrioritized);
+			lordGroup->_type = (switchCount & 0x0001) ? k25_CreatureTypeLordOrder : k23_CreatureTypeLordChaos;
+			for (int16 fuseSequenceUpdateCount = cycleCount; fuseSequenceUpdateCount--; )
+				fuseSequenceUpdate();
 		}
 	}
-	_projexpl->createExplosion(Thing::_explFireBall, 255, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
-	_projexpl->createExplosion(Thing::_explHarmNonMaterial, 255, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
+	_projexpl->createExplosion(Thing::_explFireBall, 255, lordChaosMapX, lordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
+	_projexpl->createExplosion(Thing::_explHarmNonMaterial, 255, lordChaosMapX, lordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
 	fuseSequenceUpdate();
-	L1428_ps_Group->_type = k26_CreatureTypeGreyLord;
+	lordGroup->_type = k26_CreatureTypeGreyLord;
 	fuseSequenceUpdate();
 	_displayMan->_doNotDrawFluxcagesDuringEndgame = true;
 	fuseSequenceUpdate();
-	for (AL1424_i_MapX = 0; AL1424_i_MapX < _dungeonMan->_currMapWidth; AL1424_i_MapX++) {
-		for (AL1425_i_MapY = 0; AL1425_i_MapY < _dungeonMan->_currMapHeight; AL1425_i_MapY++) {
-			if (((L1427_T_Thing = _groupMan->groupGetThing(AL1424_i_MapX, AL1425_i_MapY)) != Thing::_endOfList) && ((AL1424_i_MapX != L1431_i_LordChaosMapX) || (AL1425_i_MapY != L1432_i_LordChaosMapY))) {
-				_groupMan->groupDelete(AL1424_i_MapX, AL1425_i_MapY);
+	for (int16 curMapX = 0; curMapX < _dungeonMan->_currMapWidth; curMapX++) {
+		for (int curMapY = 0; curMapY < _dungeonMan->_currMapHeight; curMapY++) {
+			curThing = _groupMan->groupGetThing(curMapX, curMapY);
+			if ((curThing != Thing::_endOfList) && ((curMapX != lordChaosMapX) || (curMapY != lordChaosMapY))) {
+				_groupMan->groupDelete(curMapX, curMapY);
 			}
 		}
 	}
 	fuseSequenceUpdate();
 	/* Count and get list of text things located at 0, 0 in the current map. Their text is then printed as messages in the order specified by their first letter (which is not printed) */
-	L1427_T_Thing = _dungeonMan->getSquareFirstThing(0, 0);
-	AL1424_i_TextStringThingCount = 0;
-	while (L1427_T_Thing != Thing::_endOfList) {
-		if (L1427_T_Thing.getType() == k2_TextstringType) {
-			L1435_aT_TextStringThings[AL1424_i_TextStringThingCount++] = L1427_T_Thing;
+	curThing = _dungeonMan->getSquareFirstThing(0, 0);
+	int16 textStringThingCount = 0;
+	Thing textStringThings[8];
+	while (curThing != Thing::_endOfList) {
+		if (curThing.getType() == k2_TextstringType) {
+			textStringThings[textStringThingCount++] = curThing;
 		}
-		L1427_T_Thing = _dungeonMan->getNextThing(L1427_T_Thing);
+		curThing = _dungeonMan->getNextThing(curThing);
 	}
-	L1434_c_TextFirstCharacter = 'A';
-	AL1426_i_TextStringThingCount = AL1424_i_TextStringThingCount;
-	while (AL1424_i_TextStringThingCount--) {
-		for (AL1425_i_TextStringThingIndex = 0; AL1425_i_TextStringThingIndex < AL1426_i_TextStringThingCount; AL1425_i_TextStringThingIndex++) {
-			_dungeonMan->decodeText(L1436_ac_String, L1435_aT_TextStringThings[AL1425_i_TextStringThingIndex], (TextType)(k1_TextTypeMessage | k0x8000_DecodeEvenIfInvisible));
-			if (L1436_ac_String[1] == L1434_c_TextFirstCharacter) {
+	char textFirstChar = 'A';
+	int16 maxCount = textStringThingCount;
+	while (textStringThingCount--) {
+		for (int16 idx = 0; idx < maxCount; idx++) {
+			char decodedString[200];
+			_dungeonMan->decodeText(decodedString, textStringThings[idx], (TextType)(k1_TextTypeMessage | k0x8000_DecodeEvenIfInvisible));
+			if (decodedString[1] == textFirstChar) {
 				_textMan->clearAllRows();
-				L1436_ac_String[1] = '\n'; /* New line */
-				_textMan->printMessage(k15_ColorWhite, &L1436_ac_String[1]);
+				decodedString[1] = '\n'; /* New line */
+				_textMan->printMessage(k15_ColorWhite, &decodedString[1]);
 				fuseSequenceUpdate();
 				delay(780);
-				L1434_c_TextFirstCharacter++;
+				textFirstChar++;
 				break;
 			}
 		}
 	}
 
-	for (AL1424_i_Attack = 55; AL1424_i_Attack <= 255; AL1424_i_Attack += 40) {
-		_projexpl->createExplosion(Thing::_explHarmNonMaterial, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
+	for (int16 attackId = 55; attackId <= 255; attackId += 40) {
+		_projexpl->createExplosion(Thing::_explHarmNonMaterial, attackId, lordChaosMapX, lordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
 		fuseSequenceUpdate();
 	}
 
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index f83f477..a99eeb5 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -263,7 +263,7 @@ public:
 	void openEntranceDoors(); // @ F0438_STARTEND_OpenEntranceDoors
 	void drawTittle(); // @ F0437_STARTEND_DrawTitle
 	void entranceDrawCredits();
-	void fuseSequnce(); // @ F0446_STARTEND_FuseSequence
+	void fuseSequence(); // @ F0446_STARTEND_FuseSequence
 	void fuseSequenceUpdate(); // @ F0445_STARTEND_FuseSequenceUpdate
 	Common::Language getGameLanguage();
 
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 41aefbb..677fd70 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -2109,7 +2109,7 @@ void GroupMan::fuseAction(uint16 mapX, uint16 mapY) {
 				return;
 			}
 		}
-		_vm->fuseSequnce();
+		_vm->fuseSequence();
 	}
 }
 


Commit: d76ef497f7b9f20b7fa1de829f82e96e9e490eaf
    https://github.com/scummvm/scummvm/commit/d76ef497f7b9f20b7fa1de829f82e96e9e490eaf
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-27T14:24:11+02:00

Commit Message:
DM: Rewrite 3 for loops

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 14c5ffa..67ba6a0 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -911,9 +911,9 @@ void DMEngine::entranceDrawCredits() {
 
 void DMEngine::fuseSequence() {
 	_gameWon = true;
-	if (_inventoryMan->_inventoryChampionOrdinal) {
+	if (_inventoryMan->_inventoryChampionOrdinal)
 		_inventoryMan->toggleInventory(k4_ChampionCloseInventory);
-	}
+
 	_eventMan->highlightBoxDisable();
 	_championMan->_party._magicalLightAmount = 200;
 	_inventoryMan->setDungeonViewPalette();
@@ -964,11 +964,11 @@ T0446002:
 		_projexpl->createExplosion(Thing::_explHarmNonMaterial, attackId, lordChaosMapX, lordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
 		fuseSequenceUpdate();
 	}
-	for (int16 cycleCount = 4; --cycleCount; ) {
-		for (int16 switchCount = 5; --switchCount; ) {
+	for (int16 cycleCount = 3; cycleCount > 0; cycleCount--) {
+		for (int16 switchCount = 4; switchCount > 0; switchCount--) {
 			_sound->requestPlay(k17_soundBUZZ, lordChaosMapX, lordChaosMapY, k1_soundModePlayIfPrioritized);
 			lordGroup->_type = (switchCount & 0x0001) ? k25_CreatureTypeLordOrder : k23_CreatureTypeLordChaos;
-			for (int16 fuseSequenceUpdateCount = cycleCount; fuseSequenceUpdateCount--; )
+			for (int16 fuseSequenceUpdateCount = cycleCount - 1; fuseSequenceUpdateCount >= 0; fuseSequenceUpdateCount--)
 				fuseSequenceUpdate();
 		}
 	}
@@ -993,9 +993,9 @@ T0446002:
 	int16 textStringThingCount = 0;
 	Thing textStringThings[8];
 	while (curThing != Thing::_endOfList) {
-		if (curThing.getType() == k2_TextstringType) {
+		if (curThing.getType() == k2_TextstringType)
 			textStringThings[textStringThingCount++] = curThing;
-		}
+
 		curThing = _dungeonMan->getNextThing(curThing);
 	}
 	char textFirstChar = 'A';


Commit: b4fecce3fc7d9e64d6dd563674ad96248c27110b
    https://github.com/scummvm/scummvm/commit/b4fecce3fc7d9e64d6dd563674ad96248c27110b
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-27T17:41:53+02:00

Commit Message:
DM: Remove a couple of GOTOs in fuseSequence()

Changed paths:
    engines/dm/dm.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 67ba6a0..d772018 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -932,26 +932,27 @@ void DMEngine::fuseSequence() {
 	bool removeFluxcagesFromLordChaosSquare = true;
 	int16 fluxCageMapX = _dungeonMan->_partyMapX;
 	int16 fluxcageMapY = _dungeonMan->_partyMapY;
-T0446002:
-	Thing curThing = _dungeonMan->getSquareFirstObject(fluxCageMapX, fluxcageMapY);
-	while (curThing != Thing::_endOfList) {
-		if (curThing.getType() == k15_ExplosionThingType) {
-			Explosion *curExplosion = (Explosion*)_dungeonMan->getThingData(curThing);
-			if (curExplosion->getType() == k50_ExplosionType_Fluxcage) {
-				_dungeonMan->unlinkThingFromList(curThing, Thing(0), fluxCageMapX, fluxcageMapY);
-				curExplosion->setNextThing(Thing::_none);
-				goto T0446002;
+
+	for(;;) {
+		Thing curThing = _dungeonMan->getSquareFirstObject(fluxCageMapX, fluxcageMapY);
+		while (curThing != Thing::_endOfList) {
+			if (curThing.getType() == k15_ExplosionThingType) {
+				Explosion *curExplosion = (Explosion*)_dungeonMan->getThingData(curThing);
+				if (curExplosion->getType() == k50_ExplosionType_Fluxcage) {
+					_dungeonMan->unlinkThingFromList(curThing, Thing(0), fluxCageMapX, fluxcageMapY);
+					curExplosion->setNextThing(Thing::_none);
+					continue;
+				}
 			}
+			curThing = _dungeonMan->getNextThing(curThing);
 		}
-		curThing = _dungeonMan->getNextThing(curThing);
-	}
-	if (removeFluxcagesFromLordChaosSquare) {
-		removeFluxcagesFromLordChaosSquare = false;
-		fluxCageMapX = lordChaosMapX;
-		fluxcageMapY = lordChaosMapY;
-		goto T0446002;
+		if (removeFluxcagesFromLordChaosSquare) {
+			removeFluxcagesFromLordChaosSquare = false;
+			fluxCageMapX = lordChaosMapX;
+			fluxcageMapY = lordChaosMapY;
+		} else
+			break;
 	}
-
 	fuseSequenceUpdate();
 	for (int16 attackId = 55; attackId <= 255; attackId += 40) {
 		_projexpl->createExplosion(Thing::_explFireBall, attackId, lordChaosMapX, lordChaosMapY, k255_CreatureTypeSingleCenteredCreature);
@@ -981,7 +982,7 @@ T0446002:
 	fuseSequenceUpdate();
 	for (int16 curMapX = 0; curMapX < _dungeonMan->_currMapWidth; curMapX++) {
 		for (int curMapY = 0; curMapY < _dungeonMan->_currMapHeight; curMapY++) {
-			curThing = _groupMan->groupGetThing(curMapX, curMapY);
+			Thing curThing = _groupMan->groupGetThing(curMapX, curMapY);
 			if ((curThing != Thing::_endOfList) && ((curMapX != lordChaosMapX) || (curMapY != lordChaosMapY))) {
 				_groupMan->groupDelete(curMapX, curMapY);
 			}
@@ -989,7 +990,7 @@ T0446002:
 	}
 	fuseSequenceUpdate();
 	/* Count and get list of text things located at 0, 0 in the current map. Their text is then printed as messages in the order specified by their first letter (which is not printed) */
-	curThing = _dungeonMan->getSquareFirstThing(0, 0);
+	Thing curThing = _dungeonMan->getSquareFirstThing(0, 0);
 	int16 textStringThingCount = 0;
 	Thing textStringThings[8];
 	while (curThing != Thing::_endOfList) {


Commit: 361722d459b1afff6b12ba722420e86703b06dea
    https://github.com/scummvm/scummvm/commit/361722d459b1afff6b12ba722420e86703b06dea
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-27T23:10:13+02:00

Commit Message:
DM: More renaming in DungeonMan, move some arrays

Changed paths:
    engines/dm/champion.cpp
    engines/dm/console.cpp
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dmglobals.cpp
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/gfx.cpp
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/objectman.cpp
    engines/dm/projexpl.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 95f5bfa..271af52 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -852,7 +852,7 @@ int16 ChampionMan::getWoundDefense(int16 champIndex, uint16 woundIndex) {
 		Thing curThing = curChampion->_slots[slotIndex];
 		if (curThing.getType() == k6_ArmourThingType) {
 			ArmourInfo *armorInfo = (ArmourInfo *)_vm->_dungeonMan->getThingData(curThing);
-			armorInfo = &_vm->_dungeonMan->_armourInfo[((Armour *)armorInfo)->getType()];
+			armorInfo = &_vm->_dungeonMan->_armourInfos[((Armour *)armorInfo)->getType()];
 			if (getFlag(armorInfo->_attributes, k0x0080_ArmourAttributeIsAShield))
 				armorShieldDefense += ((getStrength(champIndex, slotIndex) + _vm->_dungeonMan->getArmourDefense(armorInfo, useSharpDefense)) * woundDefenseFactor[woundIndex]) >> ((slotIndex == woundIndex) ? 4 : 5);
 		}
@@ -867,7 +867,7 @@ int16 ChampionMan::getWoundDefense(int16 champIndex, uint16 woundIndex) {
 		Thing curThing = curChampion->_slots[woundIndex];
 		if (curThing.getType() == k6_ArmourThingType) {
 			ArmourInfo *armourInfo = (ArmourInfo *)_vm->_dungeonMan->getThingData(curThing);
-			woundDefense += _vm->_dungeonMan->getArmourDefense(&_vm->_dungeonMan->_armourInfo[((Armour *)armourInfo)->getType()], useSharpDefense);
+			woundDefense += _vm->_dungeonMan->getArmourDefense(&_vm->_dungeonMan->_armourInfos[((Armour *)armourInfo)->getType()], useSharpDefense);
 		}
 	}
 
@@ -1319,7 +1319,7 @@ void ChampionMan::clickOnSlotBox(uint16 slotBoxIndex) {
 	if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none))
 		return;
 
-	if ((leaderHandObject != Thing::_none) && (!(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(leaderHandObject)]._allowedSlots & _slotMasks[slotIndex])))
+	if ((leaderHandObject != Thing::_none) && (!(_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(leaderHandObject)]._allowedSlots & _slotMasks[slotIndex])))
 		return;
 
 	_vm->_eventMan->showMouse();
@@ -1964,7 +1964,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	while (curThing != Thing::_endOfList) {
 		ThingType thingType = curThing.getType();
 		if ((thingType > k3_SensorThingType) && (curThing.getCell() == championObjectsCell)) {
-			int16 objectAllowedSlots = _vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(curThing)]._allowedSlots;
+			int16 objectAllowedSlots = _vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(curThing)]._allowedSlots;
 			uint16 curSlotIndex = k0_ChampionSlotReadyHand;
 			switch (thingType) {
 			case k6_ArmourThingType: {
diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index c5ebd14..a815700 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -250,7 +250,7 @@ bool Console::Cmd_gimme(int argc, const char** argv) {
 
 	for (int16 thingType = 0; thingType < 16; ++thingType) { // 16 number of item types
 		uint16 *thingDataArray = _vm->_dungeonMan->_thingData[thingType];
-		uint16 thingTypeSize = g235_ThingDataWordCount[thingType];
+		uint16 thingTypeSize = _vm->_dungeonMan->_thingDataWordCount[thingType];
 		uint16 thingCount = _vm->_dungeonMan->_dungeonFileHeader._thingCounts[thingType];
 
 		Thing dummyThing(0);
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index d772018..0bb227a 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -1038,5 +1038,8 @@ void DMEngine::fuseSequenceUpdate() {
 					  The ending animation when Lord Chaos is fused plays too quickly because the execution speed is not limited */
 }
 
-Common::Language DMEngine::getGameLanguage() { return _gameVersion->_desc.language; }
+Common::Language DMEngine::getGameLanguage() {
+	return _gameVersion->_desc.language;
+}
+
 } // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index a99eeb5..083dfad 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -253,7 +253,6 @@ public:
 	uint16 getRandomNumber(uint32 max) { return _rnd->getRandomNumber(max - 1); }
 	int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
 	int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
-	void displayErrorAndStop(int16 errorIndex); // @ F0019_MAIN_DisplayErrorAndStop
 	virtual Common::Error run(); // @ main
 	void saveGame(); // @ F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF
 	LoadgameResponse loadgame(int16 slot); // @ F0435_STARTEND_LoadGame_CPSF
diff --git a/engines/dm/dmglobals.cpp b/engines/dm/dmglobals.cpp
index b55c405..02e819d 100644
--- a/engines/dm/dmglobals.cpp
+++ b/engines/dm/dmglobals.cpp
@@ -39,7 +39,6 @@
 #include "movesens.h"
 #include "string.h"
 
-
 namespace DM {
 
 void DMEngine::initConstants() {
@@ -56,10 +55,4 @@ void DMEngine::initConstants() {
 	_dirIntoStepCountNorth[3] = 0;  // South
 }
 
-void DMEngine::displayErrorAndStop(int16 errorIndex) {
-	debug("Stuff hit the fun: %d", errorIndex);
-	Common::Event event;
-	while (_system->getEventManager()->pollEvent(event) || true)
-		;
-}
 } // End of namespace DM
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 3fb452a..eff761a 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -35,41 +35,8 @@
 #include "movesens.h"
 #include "projexpl.h"
 
-
 namespace DM {
 
-CreatureInfo g243_CreatureInfo[k27_CreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo
-	/* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo,
-		MovementTicks, AttackTicks, Defense, BaseHealth, Attack, PoisonAttack,
-		Dexterity, Ranges, Properties, Resistances, AnimationTicks, WoundProbabilities, AttackType } */
-	{0,  4, 0x0482, 0x623D,   8, 20,  55, 150, 150, 240,  55, 0x1153, 0x299B, 0x0876, 0x0254, 0xFD40, 4},
-	{1,  0, 0x0480, 0xA625,  15, 32,  20, 110,  80,  15,  20, 0x3132, 0x33A9, 0x0E42, 0x0384, 0xFC41, 3},
-	{2,  6, 0x0510, 0x6198,   3,  5,  50,  10,  10,   0, 110, 0x1376, 0x710A, 0x0235, 0x0222, 0xFD20, 0},
-	{3,  0, 0x04B4, 0xB225,  10, 21,  30,  40,  58,   0,  80, 0x320A, 0x96AA, 0x0B3C, 0x0113, 0xF910, 5},
-	{4,  1, 0x0701, 0xA3B8,   9,  8,  45, 101,  90,   0,  65, 0x1554, 0x58FF, 0x0A34, 0x0143, 0xFE93, 4},
-	{5,  0, 0x0581, 0x539D,  20, 18, 100,  60,  30,   0,  30, 0x1232, 0x4338, 0x0583, 0x0265, 0xFFD6, 3},
-	{6,  3, 0x070C, 0x0020, 120, 10,   5, 165,   5,   0,   5, 0x1111, 0x10F1, 0x0764, 0x02F2, 0xFC84, 6},
-	{7,  7, 0x0300, 0x0220, 185, 15, 170,  50,  40,   5,  10, 0x1463, 0x25C4, 0x06E3, 0x01F4, 0xFD93, 4}, /* Atari ST: AttackSoundOrdinal = 0 */
-	{8,  2, 0x1864, 0x5225,  11, 16,  15,  30,  55,   0,  80, 0x1423, 0x4664, 0x0FC8, 0x0116, 0xFB30, 6},
-	{9, 10, 0x0282, 0x71B8,  21, 14, 240, 120, 219,   0,  35, 0x1023, 0x3BFF, 0x0FF7, 0x04F3, 0xF920, 3}, /* Atari ST: AttackSoundOrdinal = 7 */
-	{10,  2, 0x1480, 0x11B8,  17, 12,  25,  33,  20,   0,  40, 0x1224, 0x5497, 0x0F15, 0x0483, 0xFB20, 3},
-	{11,  0, 0x18C6, 0x0225, 255,  8,  45,  80, 105,   0,  60, 0x1314, 0x55A5, 0x0FF9, 0x0114, 0xFD95, 1},
-	{12, 11, 0x1280, 0x6038,   7,  7,  22,  20,  22,   0,  80, 0x1013, 0x6596, 0x0F63, 0x0132, 0xFA30, 4}, /* Atari ST: AttackSoundOrdinal = 8 */
-	{13,  9, 0x14A2, 0xB23D,   5, 10,  42,  39,  90, 100,  88, 0x1343, 0x5734, 0x0638, 0x0112, 0xFA30, 4}, /* Atari ST: AttackSoundOrdinal = 0 */
-	{14,  0, 0x05B8, 0x1638,  10, 20,  47,  44,  75,   0,  90, 0x4335, 0xD952, 0x035B, 0x0664, 0xFD60, 5},
-	{15,  5, 0x0381, 0x523D,  18, 19,  72,  70,  45,  35,  35, 0x1AA1, 0x15AB, 0x0B93, 0x0253, 0xFFC5, 4},
-	{16, 10, 0x0680, 0xA038,  13,  8,  28,  20,  25,   0,  41, 0x1343, 0x2148, 0x0321, 0x0332, 0xFC30, 3}, /* Atari ST: AttackSoundOrdinal = 7 */
-	{17,  0, 0x04A0, 0xF23D,   1, 16, 180,   8,  28,  20, 150, 0x1432, 0x19FD, 0x0004, 0x0112, 0xF710, 4},
-	{18, 11, 0x0280, 0xA3BD,  14,  6, 140,  60, 105,   0,  70, 0x1005, 0x7AFF, 0x0FFA, 0x0143, 0xFA30, 4}, /* Atari ST: AttackSoundOrdinal = 8 */
-	{19,  0, 0x0060, 0xE23D,   5, 18,  15,  33,  61,   0,  65, 0x3258, 0xAC77, 0x0F56, 0x0117, 0xFC40, 5},
-	{20,  8, 0x10DE, 0x0225,  25, 25,  75, 144,  66,   0,  50, 0x1381, 0x7679, 0x0EA7, 0x0345, 0xFD93, 3}, /* Atari ST: AttackSoundOrdinal = 0 */
-	{21,  3, 0x0082, 0xA3BD,   7, 15,  33,  77, 130,   0,  60, 0x1592, 0x696A, 0x0859, 0x0224, 0xFC30, 4},
-	{22,  0, 0x1480, 0x53BD,  10, 14,  68, 100, 100,   0,  75, 0x4344, 0xBDF9, 0x0A5D, 0x0124, 0xF920, 3},
-	{23,  0, 0x38AA, 0x0038,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5},
-	{24,  1, 0x068A, 0x97BD,  13, 28, 110, 255, 255,   0,  70, 0x3645, 0xBF7C, 0x06CD, 0x0445, 0xFC30, 4}, /* Atari ST Version 1.0 1987-12-08 1987-12-11: Ranges = 0x2645 */
-	{25,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5},
-	{26,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}};
-
 void DungeonMan::mapCoordsAfterRelMovement(Direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
 	posX += _vm->_dirIntoStepCountEast[dir] * stepsForward;
 	posY += _vm->_dirIntoStepCountNorth[dir] * stepsForward;
@@ -78,7 +45,7 @@ void DungeonMan::mapCoordsAfterRelMovement(Direction dir, int16 stepsForward, in
 	posY += _vm->_dirIntoStepCountNorth[dir] * stepsRight;
 }
 
-void DungeonMan::setupArrays() {
+void DungeonMan::setupConstants() {
 	ObjectInfo objectInfo[180] = { // @ G0237_as_Graphic559_ObjectInfo
 		/* { Type, ObjectAspectIndex, ActionSetIndex, AllowedSlots } */
 		ObjectInfo(30,  1,  0, 0x0500),   /* COMPASS        Pouch/Chest */
@@ -374,14 +341,72 @@ void DungeonMan::setupArrays() {
 		WeaponInfo(36, 255, 100,  50, 0x20FF)   /* THE FIRESTAFF */
 	};
 
+	CreatureInfo creatureInfo[k27_CreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo
+	/* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo,
+		MovementTicks, AttackTicks, Defense, BaseHealth, Attack, PoisonAttack,
+		Dexterity, Ranges, Properties, Resistances, AnimationTicks, WoundProbabilities, AttackType } */
+		{0,  4, 0x0482, 0x623D,   8, 20,  55, 150, 150, 240,  55, 0x1153, 0x299B, 0x0876, 0x0254, 0xFD40, 4},
+		{1,  0, 0x0480, 0xA625,  15, 32,  20, 110,  80,  15,  20, 0x3132, 0x33A9, 0x0E42, 0x0384, 0xFC41, 3},
+		{2,  6, 0x0510, 0x6198,   3,  5,  50,  10,  10,   0, 110, 0x1376, 0x710A, 0x0235, 0x0222, 0xFD20, 0},
+		{3,  0, 0x04B4, 0xB225,  10, 21,  30,  40,  58,   0,  80, 0x320A, 0x96AA, 0x0B3C, 0x0113, 0xF910, 5},
+		{4,  1, 0x0701, 0xA3B8,   9,  8,  45, 101,  90,   0,  65, 0x1554, 0x58FF, 0x0A34, 0x0143, 0xFE93, 4},
+		{5,  0, 0x0581, 0x539D,  20, 18, 100,  60,  30,   0,  30, 0x1232, 0x4338, 0x0583, 0x0265, 0xFFD6, 3},
+		{6,  3, 0x070C, 0x0020, 120, 10,   5, 165,   5,   0,   5, 0x1111, 0x10F1, 0x0764, 0x02F2, 0xFC84, 6},
+		{7,  7, 0x0300, 0x0220, 185, 15, 170,  50,  40,   5,  10, 0x1463, 0x25C4, 0x06E3, 0x01F4, 0xFD93, 4}, /* Atari ST: AttackSoundOrdinal = 0 */
+		{8,  2, 0x1864, 0x5225,  11, 16,  15,  30,  55,   0,  80, 0x1423, 0x4664, 0x0FC8, 0x0116, 0xFB30, 6},
+		{9, 10, 0x0282, 0x71B8,  21, 14, 240, 120, 219,   0,  35, 0x1023, 0x3BFF, 0x0FF7, 0x04F3, 0xF920, 3}, /* Atari ST: AttackSoundOrdinal = 7 */
+		{10,  2, 0x1480, 0x11B8,  17, 12,  25,  33,  20,   0,  40, 0x1224, 0x5497, 0x0F15, 0x0483, 0xFB20, 3},
+		{11,  0, 0x18C6, 0x0225, 255,  8,  45,  80, 105,   0,  60, 0x1314, 0x55A5, 0x0FF9, 0x0114, 0xFD95, 1},
+		{12, 11, 0x1280, 0x6038,   7,  7,  22,  20,  22,   0,  80, 0x1013, 0x6596, 0x0F63, 0x0132, 0xFA30, 4}, /* Atari ST: AttackSoundOrdinal = 8 */
+		{13,  9, 0x14A2, 0xB23D,   5, 10,  42,  39,  90, 100,  88, 0x1343, 0x5734, 0x0638, 0x0112, 0xFA30, 4}, /* Atari ST: AttackSoundOrdinal = 0 */
+		{14,  0, 0x05B8, 0x1638,  10, 20,  47,  44,  75,   0,  90, 0x4335, 0xD952, 0x035B, 0x0664, 0xFD60, 5},
+		{15,  5, 0x0381, 0x523D,  18, 19,  72,  70,  45,  35,  35, 0x1AA1, 0x15AB, 0x0B93, 0x0253, 0xFFC5, 4},
+		{16, 10, 0x0680, 0xA038,  13,  8,  28,  20,  25,   0,  41, 0x1343, 0x2148, 0x0321, 0x0332, 0xFC30, 3}, /* Atari ST: AttackSoundOrdinal = 7 */
+		{17,  0, 0x04A0, 0xF23D,   1, 16, 180,   8,  28,  20, 150, 0x1432, 0x19FD, 0x0004, 0x0112, 0xF710, 4},
+		{18, 11, 0x0280, 0xA3BD,  14,  6, 140,  60, 105,   0,  70, 0x1005, 0x7AFF, 0x0FFA, 0x0143, 0xFA30, 4}, /* Atari ST: AttackSoundOrdinal = 8 */
+		{19,  0, 0x0060, 0xE23D,   5, 18,  15,  33,  61,   0,  65, 0x3258, 0xAC77, 0x0F56, 0x0117, 0xFC40, 5},
+		{20,  8, 0x10DE, 0x0225,  25, 25,  75, 144,  66,   0,  50, 0x1381, 0x7679, 0x0EA7, 0x0345, 0xFD93, 3}, /* Atari ST: AttackSoundOrdinal = 0 */
+		{21,  3, 0x0082, 0xA3BD,   7, 15,  33,  77, 130,   0,  60, 0x1592, 0x696A, 0x0859, 0x0224, 0xFC30, 4},
+		{22,  0, 0x1480, 0x53BD,  10, 14,  68, 100, 100,   0,  75, 0x4344, 0xBDF9, 0x0A5D, 0x0124, 0xF920, 3},
+		{23,  0, 0x38AA, 0x0038,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5},
+		{24,  1, 0x068A, 0x97BD,  13, 28, 110, 255, 255,   0,  70, 0x3645, 0xBF7C, 0x06CD, 0x0445, 0xFC30, 4}, /* Atari ST Version 1.0 1987-12-08 1987-12-11: Ranges = 0x2645 */
+		{25,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5},
+		{26,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}
+	};
+	// this is the number of uint16s the data has to be stored, not the length of the data in dungeon.dat!
+	byte thingDataWordCount[16] = { // @ G0235_auc_Graphic559_ThingDataByteCount
+		2,   /* Door */
+		3,   /* Teleporter */
+		2,   /* Text String */
+		4,   /* Sensor */
+		9,   /* Group */
+		2,   /* Weapon */
+		2,   /* Armour */
+		2,   /* Scroll */
+		2,   /* Potion */
+		4,   /* Container */
+		2,   /* Junk */
+		0,   /* Unused */
+		0,   /* Unused */
+		0,   /* Unused */
+		5,   /* Projectile */
+		2    /* Explosion */
+	};
+
 	for (int i = 0; i < 180; i++)
-		_objectInfo[i] = objectInfo[i];
+		_objectInfos[i] = objectInfo[i];
 
 	for (int i = 0; i < 58; i++)
-		_armourInfo[i] = armourInfo[i];
+		_armourInfos[i] = armourInfo[i];
 
 	for (int i = 0; i < 46; i++)
-		_weaponInfo[i] = weaponInfo[i];
+		_weaponInfos[i] = weaponInfo[i];
+
+	for (int i = 0; i < k27_CreatureTypeCount; i++)
+		_creatureInfos[i] = creatureInfo[i];
+
+	for (int i = 0; i < 16; i++)
+		_thingDataWordCount[i] = thingDataWordCount[i];
 
 }
 
@@ -423,7 +448,7 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine) {
 	for (uint16 i = 0; i < 2; ++i)
 		_currMapDoorInfo[i].resetToZero();
 
-	setupArrays();
+	setupConstants();
 }
 
 DungeonMan::~DungeonMan() {
@@ -501,26 +526,6 @@ void DungeonMan::decompressDungeonFile() {
 	f.close();
 }
 
-// this is the number of uint16s the data has to be stored, not the length of the data in dungeon.dat!
-byte g235_ThingDataWordCount[16] = { // @ G0235_auc_Graphic559_ThingDataByteCount
-	2,   /* Door */
-	3,   /* Teleporter */
-	2,   /* Text String */
-	4,   /* Sensor */
-	9,   /* Group */
-	2,   /* Weapon */
-	2,   /* Armour */
-	2,   /* Scroll */
-	2,   /* Potion */
-	4,   /* Container */
-	2,   /* Junk */
-	0,   /* Unused */
-	0,   /* Unused */
-	0,   /* Unused */
-	5,   /* Projectile */
-	2    /* Explosion */
-};
-
 const Thing Thing::_none(0); // @ C0xFFFF_THING_NONE
 const Thing Thing::_endOfList(0xFFFE); // @ C0xFFFE_THING_ENDOFLIST
 const Thing Thing::_firstExplosion(0xFF80); // @ C0xFF80_THING_FIRST_EXPLOSION            
@@ -680,7 +685,7 @@ void DungeonMan::loadDungeonFile(Common::InSaveFile *file) {
 		if (_vm->_newGameFl)
 			_dungeonFileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + additionalThingCounts[thingType]);
 
-		uint16 thingStoreWordCount = g235_ThingDataWordCount[thingType];
+		uint16 thingStoreWordCount = _thingDataWordCount[thingType];
 
 		if (thingStoreWordCount == 0)
 			continue;
@@ -1017,7 +1022,7 @@ bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) {
 }
 
 uint16 *DungeonMan::getThingData(Thing thing) {
-	return _thingData[thing.getType()] + thing.getIndex() * g235_ThingDataWordCount[thing.getType()];
+	return _thingData[thing.getType()] + thing.getIndex() * _thingDataWordCount[thing.getType()];
 }
 
 uint16* DungeonMan::getSquareFirstThingData(int16 mapX, int16 mapY) {
@@ -1110,7 +1115,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) {
 		{0,   0,  0,  0, 0, 0, 0, 0}
 	};
 
-	TextString textString(_thingData[k2_TextstringType] + thing.getIndex() * g235_ThingDataWordCount[k2_TextstringType]);
+	TextString textString(_thingData[k2_TextstringType] + thing.getIndex() * _thingDataWordCount[k2_TextstringType]);
 	if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) {
 		type = (TextType)(type & ~k0x8000_DecodeEvenIfInvisible);
 		char sepChar;
@@ -1181,7 +1186,7 @@ Thing DungeonMan::getUnusedThing(uint16 thingType) {
 		thingCount -= 3; /* Always keep 3 unused JUNK things for the bones of dead champions */
 
 	int16 thingIdx = thingCount;
-	int16 thingDataByteCount = g235_ThingDataWordCount[thingType] >> 1;
+	int16 thingDataByteCount = _thingDataWordCount[thingType] >> 1;
 	Thing *thingPtr = (Thing *)_thingData[thingType];
 
 	Thing curThing;
@@ -1243,10 +1248,10 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 
 	switch (thing.getType()) {
 	case k5_WeaponThingType:
-		weight = _weaponInfo[((Weapon *)junk)->getType()]._weight;
+		weight = _weaponInfos[((Weapon *)junk)->getType()]._weight;
 		break;
 	case k6_ArmourThingType:
-		weight = _armourInfo[((Armour *)junk)->getType()]._weight;
+		weight = _armourInfos[((Armour *)junk)->getType()]._weight;
 		break;
 	case k10_JunkThingType:
 		weight = junkInfo[junk->getType()];
@@ -1342,7 +1347,7 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map
 
 WeaponInfo* DungeonMan::getWeaponInfo(Thing thing) {
 	Weapon* weapon = (Weapon*)getThingData(thing);
-	return &_weaponInfo[weapon->getType()];
+	return &_weaponInfos[weapon->getType()];
 }
 
 int16 DungeonMan::getProjectileAspect(Thing thing) {
@@ -1365,7 +1370,7 @@ int16 DungeonMan::getProjectileAspect(Thing thing) {
 			return -projAspOrd;
 	}
 
-	return _objectInfo[getObjectInfoIndex(thing)]._objectAspectIndex;
+	return _objectInfos[getObjectInfoIndex(thing)]._objectAspectIndex;
 }
 
 int16 DungeonMan::getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16* mapX, int16* mapY) {
@@ -1510,7 +1515,7 @@ Thing DungeonMan::getDiscardThing(uint16 thingType) {
 
 uint16 DungeonMan::getCreatureAttributes(Thing thing) {
 	Group *currGroup = (Group *)getThingData(thing);
-	return g243_CreatureInfo[currGroup->_type]._attributes;
+	return _creatureInfos[currGroup->_type]._attributes;
 }
 
 void DungeonMan::setGroupCells(Group* group, uint16 cells, uint16 mapIndex) {
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 1f52614..ac85b28 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -31,7 +31,6 @@
 #include "dm.h"
 #include "gfx.h"
 
-
 namespace DM {
 
 /* Object info */
@@ -207,9 +206,6 @@ public:
 	uint16 getAttackRange() { return (_ranges >> 12) & 0xF; }
 }; // @ CREATURE_INFO
 
-
-extern CreatureInfo g243_CreatureInfo[k27_CreatureTypeCount]; // @ G0243_as_Graphic559_CreatureInfo
-
 class Door {
 	Thing _nextThing;
 	uint16 _attributes;
@@ -637,8 +633,6 @@ public:
 
 class Group;
 
-extern byte g235_ThingDataWordCount[16];
-
 class DungeonMan {
 	DMEngine *_vm;
 
@@ -732,11 +726,13 @@ public:
 	Thing _pileTopObject[5]; // @ G0292_aT_PileTopObject
 	DoorInfo _currMapDoorInfo[2]; // @ G0275_as_CurrentMapDoorInfo
 	
-	ObjectInfo _objectInfo[180]; // @ G0237_as_Graphic559_ObjectInfo
-	ArmourInfo _armourInfo[58]; // @ G0239_as_Graphic559_ArmourInfo
-	WeaponInfo _weaponInfo[46]; // @ G0238_as_Graphic559_WeaponInfo
+	ObjectInfo _objectInfos[180]; // @ G0237_as_Graphic559_ObjectInfo
+	ArmourInfo _armourInfos[58]; // @ G0239_as_Graphic559_ArmourInfo
+	WeaponInfo _weaponInfos[46]; // @ G0238_as_Graphic559_WeaponInfo
+	CreatureInfo _creatureInfos[k27_CreatureTypeCount]; // @ G0243_as_Graphic559_CreatureInfo
+	byte _thingDataWordCount[16]; // @ G0235_auc_Graphic559_ThingDataByteCount
 
-	void setupArrays();
+	void setupConstants();
 };
 
 }
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index d402305..296ee96 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -576,7 +576,7 @@ void DisplayMan::initializeGraphicData() {
 	for (int16 creatureIndex = 0; creatureIndex < k27_CreatureTypeCount; creatureIndex++) {
 		creatureAsp = &_creatureAspects219[creatureIndex];
 
-		int16 creatureGraphicInfo = g243_CreatureInfo[creatureIndex]._graphicInfo;
+		int16 creatureGraphicInfo = _vm->_dungeonMan->_creatureInfos[creatureIndex]._graphicInfo;
 		creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex;
 
 		int16 creatureFrontBitmapD3PixelCount = getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3);
@@ -3110,7 +3110,7 @@ void DisplayMan::drawObjectsCreaturesProjectilesExplosions(Thing thingParam, Dir
 			}
 
 			if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) { /* Square where objects are visible and object is located on cell being processed */
-				objectAspect = &(_objectAspects209[_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(thingParam)]._objectAspectIndex]);
+				objectAspect = &(_objectAspects209[_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(thingParam)]._objectAspectIndex]);
 				AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex;
 				useAlcoveObjectImage = (L0135_B_DrawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane);
 				if (useAlcoveObjectImage)
@@ -3235,7 +3235,7 @@ T0115015_DrawProjectileAsObject:
 		if (group == nullptr) { /* If all creature data and info has not already been gathered */
 			group = (Group*)_vm->_dungeonMan->getThingData(groupThing);
 			activeGroup = &_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()];
-			CreatureInfo *creatureInfo = &g243_CreatureInfo[group->_type];
+			CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type];
 			creatureAspectStruct = &_creatureAspects219[creatureInfo->_creatureAspectIndex];
 			creatureSize = getFlag(creatureInfo->_attributes, k0x0003_MaskCreatureInfo_size);
 			creatureGraphicInfoGreen = creatureInfo->_graphicInfo;
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 677fd70..519a62e 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -106,7 +106,7 @@ int16 GroupMan::getCreatureOrdinalInCell(Group *group, uint16 cell) {
 
 	int retval = 0;
 	byte creatureIndex = group->getCount();
-	if (getFlag(g243_CreatureInfo[group->_type]._attributes, k0x0003_MaskCreatureInfo_size) == k1_MaskCreatureSizeHalf) {
+	if (getFlag(_vm->_dungeonMan->_creatureInfos[group->_type]._attributes, k0x0003_MaskCreatureInfo_size) == k1_MaskCreatureSizeHalf) {
 		if ((getGroupDirections(group, currMapIndex) & 1) == (cell & 1))
 			cell = returnPrevVal(cell);
 
@@ -136,7 +136,7 @@ uint16 GroupMan::getCreatureValue(uint16 groupVal, uint16 creatureIndex) {
 void GroupMan::dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode) {
 	Group *group = (Group *)_vm->_dungeonMan->getThingData(groupThing);
 	uint16 creatureType = group->_type;
-	if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[creatureType]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
+	if ((mode >= k0_soundModePlayImmediately) && getFlag(_vm->_dungeonMan->_creatureInfos[creatureType]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
 		int16 creatureIndex = group->getCount();
 		uint16 groupCells = getGroupCells(group, _vm->_dungeonMan->_currMapIndex);
 		do {
@@ -417,7 +417,7 @@ int16 GroupMan::groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex
 	uint16 L0384_ui_Cell;
 
 
-	L0376_ps_CreatureInfo = &g243_CreatureInfo[AL0380_ui_CreatureType = group->_type];
+	L0376_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[AL0380_ui_CreatureType = group->_type];
 	if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) /* Lord Chaos cannot be damaged */
 		goto T0190024;
 	if (group->_health[creatureIndex] <= damage) {
@@ -582,8 +582,7 @@ int16 GroupMan::getDamageAllCreaturesOutcome(Group *group, int16 mapX, int16 map
 int16 GroupMan::groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack) {
 	int16 L0390_i_PoisonResistance;
 
-
-	if (!poisonAttack || ((L0390_i_PoisonResistance = g243_CreatureInfo[creatreType].getPoisonResistance()) == k15_immuneToPoison)) {
+	if (!poisonAttack || ((L0390_i_PoisonResistance = _vm->_dungeonMan->_creatureInfos[creatreType].getPoisonResistance()) == k15_immuneToPoison)) {
 		return 0;
 	}
 	return ((poisonAttack + _vm->getRandomNumber(4)) << 3) / ++L0390_i_PoisonResistance;
@@ -642,7 +641,7 @@ void GroupMan::processEvents29to41(int16 eventMapX, int16 eventMapY, int16 event
 		goto T0209139_Return;
 	}
 	L0444_ps_Group = (Group *)_vm->_dungeonMan->getThingData(L0449_T_GroupThing);
-	L0448_s_CreatureInfo = g243_CreatureInfo[L0444_ps_Group->_type];
+	L0448_s_CreatureInfo = _vm->_dungeonMan->_creatureInfos[L0444_ps_Group->_type];
 	/* Update the event */
 	setMapAndTime(L0465_s_NextEvent._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime);
 	L0465_s_NextEvent._priority = 255 - L0448_s_CreatureInfo._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
@@ -1179,7 +1178,7 @@ int16 GroupMan::groupGetDistanceToVisibleParty(Group *group, int16 creatureIndex
 	int16 L0425_ai_CreatureViewDirections[4]; /* List of directions to test */
 
 
-	L0424_ps_CreatureInfo = &g243_CreatureInfo[group->_type];
+	L0424_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type];
 	if (_vm->_championMan->_party._event71Count_Invisibility && !getFlag(L0424_ps_CreatureInfo->_attributes, k0x0800_MaskCreatureInfo_seeInvisible)) {
 		return 0;
 	}
@@ -1289,7 +1288,7 @@ int32 GroupMan::getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 crea
 	uint16 L1635_ui_SoundIndex;
 
 	L0329_ps_Group = &(((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]);
-	L0327_ui_CreatureGraphicInfo = g243_CreatureInfo[L0331_ui_CreatureType = L0329_ps_Group->_type]._graphicInfo;
+	L0327_ui_CreatureGraphicInfo = _vm->_dungeonMan->_creatureInfos[L0331_ui_CreatureType = L0329_ps_Group->_type]._graphicInfo;
 	L0330_B_ProcessGroup = (creatureIndex < 0);
 	if (L0330_B_ProcessGroup) /* If the creature index is negative then all creatures in the group are processed */
 		creatureIndex = L0329_ps_Group->getCount();
@@ -1351,7 +1350,7 @@ int32 GroupMan::getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 crea
 		}
 		activeGroup->_aspect[creatureIndex] = AL0326_ui_Aspect;
 	} while (L0330_B_ProcessGroup && (creatureIndex--));
-	AL0326_ui_AnimationTicks = g243_CreatureInfo[L0329_ps_Group->_type]._animationTicks;
+	AL0326_ui_AnimationTicks = _vm->_dungeonMan->_creatureInfos[L0329_ps_Group->_type]._animationTicks;
 	return _vm->_gameTime + (isAttacking ? ((AL0326_ui_AnimationTicks >> 8) & 0xF) : ((AL0326_ui_AnimationTicks >> 4) & 0xF)) + _vm->getRandomNumber(2);
 }
 
@@ -1473,7 +1472,7 @@ bool GroupMan::isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16
 
 	_vm->_projexpl->_lastCreatureAttackTime = _vm->_gameTime;
 	ActiveGroup L0443_s_ActiveGroup = _activeGroups[group->getActiveGroupIndex()];
-	CreatureInfo *L0441_ps_CreatureInfo = &g243_CreatureInfo[AL0437_ui_CreatureType = group->_type];
+	CreatureInfo *L0441_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[AL0437_ui_CreatureType = group->_type];
 	uint16 L0438_ui_PrimaryDirectionToParty = _currGroupPrimaryDirToParty;
 	if ((AL0439_i_GroupCells = L0443_s_ActiveGroup._cells) == k255_CreatureTypeSingleCenteredCreature) {
 		AL0439_i_TargetCell = _vm->getRandomNumber(2);
@@ -1650,7 +1649,7 @@ int16 GroupMan::getChampionDamage(Group *group, uint16 champIndex) {
 		_vm->_championMan->wakeUp();
 	}
 	L0563_i_DoubledMapDifficulty = _vm->_dungeonMan->_currMap->_difficulty << 1;
-	L0564_s_CreatureInfo = g243_CreatureInfo[group->_type];
+	L0564_s_CreatureInfo = _vm->_dungeonMan->_creatureInfos[group->_type];
 	_vm->_championMan->addSkillExperience(champIndex, k7_ChampionSkillParry, L0564_s_CreatureInfo.getExperience());
 	if (_vm->_championMan->_partyIsSleeping || (((_vm->_championMan->getDexterity(L0562_ps_Champion) < (_vm->getRandomNumber(32) + L0564_s_CreatureInfo._dexterity + L0563_i_DoubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !_vm->_championMan->isLucky(L0562_ps_Champion, 60))) {
 		if ((AL0559_ui_WoundTest = _vm->getRandomNumber(65536)) & 0x0070) {
@@ -1719,7 +1718,7 @@ void GroupMan::startWanedring(int16 mapX, int16 mapY) {
 	}
 	setMapAndTime(L0333_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, (_vm->_gameTime + 1));
 	L0333_s_Event._type = k37_TMEventTypeUpdateBehaviourGroup;
-	L0333_s_Event._priority = 255 - g243_CreatureInfo[L0332_ps_Group->_type]._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
+	L0333_s_Event._priority = 255 - _vm->_dungeonMan->_creatureInfos[L0332_ps_Group->_type]._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
 	L0333_s_Event._C._ticks = 0;
 	L0333_s_Event._B._location._mapX = mapX;
 	L0333_s_Event._B._location._mapY = mapY;
@@ -1744,7 +1743,7 @@ void GroupMan::addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
 	_currActiveGroupCount++;
 
 	L0340_ps_Group = (Group *)(_vm->_dungeonMan->_thingData[k4_GroupThingType] + 
-		g235_ThingDataWordCount[k4_GroupThingType] * (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getIndex()));
+		_vm->_dungeonMan->_thingDataWordCount[k4_GroupThingType] * (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getIndex()));
 
 	L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells;
 	L0340_ps_Group->getActiveGroupIndex() = L0344_i_ActiveGroupIndex;
@@ -1837,7 +1836,7 @@ Thing GroupMan::groupGetGenerated(int16 creatureType, int16 healthMultiplier, ui
 	else
 		L0352_ui_GroupCells = k255_CreatureTypeSingleCenteredCreature;
 
-	L0354_ps_CreatureInfo = &g243_CreatureInfo[L0353_ps_Group->_type = creatureType];
+	L0354_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[L0353_ps_Group->_type = creatureType];
 	L0350_ui_BaseHealth = L0354_ps_CreatureInfo->_baseHealth;
 	do {
 		L0353_ps_Group->_health[creatureCount] = (L0350_ui_BaseHealth * healthMultiplier) + _vm->getRandomNumber((L0350_ui_BaseHealth >> 2) + 1);
@@ -1904,7 +1903,7 @@ int16 GroupMan::getMeleeActionDamage(Champion* champ, int16 champIndex, Group* g
 		return 0;
 	}
 	L0567_i_DoubledMapDifficulty = _vm->_dungeonMan->_currMap->_difficulty << 1;
-	L0572_ps_CreatureInfo = &g243_CreatureInfo[group->_type];
+	L0572_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type];
 	L0571_i_ActionHandObjectIconIndex = _vm->_objectMan->getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
 	L0570_B_ActionHitsNonMaterialCreatures = getFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
 	if (L0570_B_ActionHitsNonMaterialCreatures)
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index be1e976..ab8cf8b 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -582,7 +582,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		case k8_PotionThingType: {
 			potentialAttribMask = k0x0001_DescriptionMaskConsumable;
 			Potion *potion = (Potion *)rawThingPtr;
-			actualAttribMask = _vm->_dungeonMan->_objectInfo[k2_ObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots();
+			actualAttribMask = _vm->_dungeonMan->_objectInfos[k2_ObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots();
 			break;
 		}
 		case k10_JunkThingType: {
@@ -638,7 +638,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			} else {
 				Junk *junk = (Junk *)rawThingPtr;
 				potentialAttribMask = k0x0001_DescriptionMaskConsumable;
-				actualAttribMask = _vm->_dungeonMan->_objectInfo[k127_ObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots();
+				actualAttribMask = _vm->_dungeonMan->_objectInfos[k127_ObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots();
 			}
 			break;
 		}
@@ -947,13 +947,16 @@ void InventoryMan::clickOnMouth() {
 	if (_vm->_championMan->_candidateChampionOrdinal) {
 		return;
 	}
-	if (!getFlag(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(L1078_T_Thing = _vm->_championMan->_leaderHandObject)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) {
+
+	L1078_T_Thing = _vm->_championMan->_leaderHandObject;
+	if (!getFlag(_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(L1078_T_Thing)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) {
 		return;
 	}
 	L1079_ui_IconIndex = _vm->_objectMan->getIconIndex(L1078_T_Thing);
 	AL1088_ui_ThingType = L1078_T_Thing.getType();
 	L1089_ui_Weight = _vm->_dungeonMan->getObjectWeight(L1078_T_Thing);
-	L1083_ps_Champion = &_vm->_championMan->_champions[L1080_ui_ChampionIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal)];
+	L1080_ui_ChampionIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal);
+	L1083_ps_Champion = &_vm->_championMan->_champions[L1080_ui_ChampionIndex];
 	L1082_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L1078_T_Thing);
 	if ((L1079_ui_IconIndex >= k8_IconIndiceJunkWater) && (L1079_ui_IconIndex <= k9_IconIndiceJunkWaterSkin)) {
 		if (!(L1082_ps_Junk->getChargeCount())) {
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 302d7ef..0fde805 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -391,7 +391,7 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 
 	// save _g284_thingData
 	for (uint16 thingIndex = 0; thingIndex < 16; ++thingIndex)
-		for (uint16 i = 0; i < g235_ThingDataWordCount[thingIndex] * _dungeonMan->_dungeonFileHeader._thingCounts[thingIndex]; ++i)
+		for (uint16 i = 0; i < _dungeonMan->_thingDataWordCount[thingIndex] * _dungeonMan->_dungeonFileHeader._thingCounts[thingIndex]; ++i)
 			file->writeUint16BE(_dungeonMan->_thingData[thingIndex][i]);
 
 	// save _g276_dungeonRawMapData
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index a8217dd..fe6cc29 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -157,7 +157,7 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) {
 	IconIndice iconIndex;
 	if (thing == Thing::_none) {
 		iconIndex = k201_IconIndiceActionEmptyHand;
-	} else if (_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
+	} else if (_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
 		iconIndex = _vm->_objectMan->getIconIndex(thing);
 	} else {
 		dm.fillBitmap(bitmapIcon, k4_ColorCyan, 16, 16);
@@ -1168,7 +1168,7 @@ T0407014:
 	case k32_ChampionActionShoot:
 		if (Thing(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]).getType() != k5_WeaponThingType)
 			goto T0407032;
-		L1256_ps_WeaponInfoActionHand = &_vm->_dungeonMan->_weaponInfo[L1248_ps_Weapon->getType()];
+		L1256_ps_WeaponInfoActionHand = &_vm->_dungeonMan->_weaponInfos[L1248_ps_Weapon->getType()];
 		L1257_ps_WeaponInfoReadyHand = _vm->_dungeonMan->getWeaponInfo(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]);
 		AL1246_i_ActionHandWeaponClass = L1256_ps_WeaponInfoActionHand->_class;
 		AL1250_i_ReadyHandWeaponClass = L1257_ps_WeaponInfoReadyHand->_class;
@@ -1536,7 +1536,7 @@ bool MenuMan::isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, in
 	}
 	L1229_i_FrightAmount += _vm->_championMan->getSkillLevel(champIndex, k14_ChampionSkillInfluence);
 	L1233_ps_Group = (Group*)_vm->_dungeonMan->getThingData(_actionTargetGroupThing);
-	L1234_ps_CreatureInfo = &g243_CreatureInfo[L1233_ps_Group->_type];
+	L1234_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[L1233_ps_Group->_type];
 	if (((L1230_ui_FearResistance = L1234_ps_CreatureInfo->getFearResistance()) > _vm->getRandomNumber(L1229_i_FrightAmount)) || (L1230_ui_FearResistance == k15_immuneToFear)) {
 		L1231_ui_Experience >>= 1;
 	} else {
@@ -1645,7 +1645,7 @@ void MenuMan::processCommands116To119_setActingChampion(uint16 champIndex) {
 	}
 	if ((L1189_T_Thing = L1190_ps_Champion->_slots[k1_ChampionSlotActionHand]) == Thing::_none) {
 		L1188_ui_ActionSetIndex = 2; /* Actions Punch, Kick and War Cry */
-	} else if ((L1188_ui_ActionSetIndex = _vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(L1189_T_Thing)]._actionSetIndex) == 0) {
+	} else if ((L1188_ui_ActionSetIndex = _vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(L1189_T_Thing)]._actionSetIndex) == 0) {
 		return;
 	}
 	L1191_ps_ActionSet = &G0489_as_Graphic560_ActionSets[L1188_ui_ActionSetIndex];
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 58a4f64..5d7d7e1 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -716,7 +716,7 @@ int16 MovesensMan::getTeleporterRotatedGroupResult(Teleporter* teleporter, Thing
 	L0687_ui_UpdatedGroupCells = _vm->_groupMan->getGroupCells(L0686_ps_Group, mapIndex);
 	if (L0687_ui_UpdatedGroupCells != k255_CreatureTypeSingleCenteredCreature) {
 		L0690_ui_GroupCells = L0687_ui_UpdatedGroupCells;
-		L0691_i_CreatureSize = getFlag(g243_CreatureInfo[L0686_ps_Group->_type]._attributes, k0x0003_MaskCreatureInfo_size);
+		L0691_i_CreatureSize = getFlag(_vm->_dungeonMan->_creatureInfos[L0686_ps_Group->_type]._attributes, k0x0003_MaskCreatureInfo_size);
 		L0692_i_RelativeRotation = normalizeModulo4(4 + L0685_ui_UpdatedGroupDirections - L0684_ui_GroupDirections);
 		for (L0688_i_CreatureIndex = 0; L0688_i_CreatureIndex <= L0686_ps_Group->getCount(); L0688_i_CreatureIndex++) {
 			L0685_ui_UpdatedGroupDirections = _vm->_groupMan->getGroupValueUpdatedWithCreatureValue(L0685_ui_UpdatedGroupDirections, L0688_i_CreatureIndex, L0689_B_AbsoluteRotation ? L0683_i_Rotation : normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation));
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 75865fb..c191fa5 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -130,7 +130,7 @@ IconIndice ObjectMan::getObjectType(Thing thing) {
 
 	int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing);
 	if (objectInfoIndex != -1) {
-		objectInfoIndex = _vm->_dungeonMan->_objectInfo[objectInfoIndex]._type;
+		objectInfoIndex = _vm->_dungeonMan->_objectInfos[objectInfoIndex]._type;
 	}
 	return (IconIndice)objectInfoIndex;
 }
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index bcaca84..99fda67 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -162,7 +162,7 @@ T0217004:
 			((L0510_i_ProjectileAssociatedThingType == k15_ExplosionThingType) ?
 			 (L0486_T_ProjectileAssociatedThing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) :
 			 ((L0490_ps_Projectile->_attack > _vm->getRandomNumber(128)) &&
-			  getFlag(_vm->_dungeonMan->_objectInfo[_vm->_dungeonMan->getObjectInfoIndex(L0486_T_ProjectileAssociatedThing)].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)
+			  getFlag(_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(L0486_T_ProjectileAssociatedThing)].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)
 			  && ((L0510_i_ProjectileAssociatedThingType != k10_JunkThingType) ||
 			  ((AL0487_i_IconIndex = _vm->_objectMan->getIconIndex(L0486_T_ProjectileAssociatedThing)) < 0) ||
 				  (!((AL0487_i_IconIndex >= k176_IconIndiceJunkIronKey) && (AL0487_i_IconIndex <= k191_IconIndiceJunkMasterKey))))
@@ -184,7 +184,7 @@ T0217004:
 			return false;
 		}
 		L0512_ui_CreatureIndex--;
-		L0493_ps_CreatureInfo = &g243_CreatureInfo[L0511_ui_CreatureType = L0491_ps_Group->_type];
+		L0493_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[L0511_ui_CreatureType = L0491_ps_Group->_type];
 		if ((L0486_T_ProjectileAssociatedThing == Thing::_explFireBall) && (L0511_ui_CreatureType == k11_CreatureTypeBlackFlame)) {
 			L0496_pui_CreatureHealth = &L0491_ps_Group->_health[L0512_ui_CreatureIndex];
 			*L0496_pui_CreatureHealth = MIN(1000, *L0496_pui_CreatureHealth + getProjectileImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing));
@@ -352,7 +352,7 @@ void ProjExpl::createExplosion(Thing explThing, uint16 attack, uint16 mapXCombo,
 			} else {
 				if ((L0473_T_Thing = _vm->_groupMan->groupGetThing(AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY)) != Thing::_endOfList) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
 					Group *L0472_ps_Group = (Group *)_vm->_dungeonMan->getThingData(L0473_T_Thing);
-					CreatureInfo *L0471_ps_CreatureInfo = &g243_CreatureInfo[L0472_ps_Group->_type];
+					CreatureInfo *L0471_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[L0472_ps_Group->_type];
 					int16 L0469_i_CreatureFireResistance = L0471_ps_CreatureInfo->getFireResistance();
 					if (L0469_i_CreatureFireResistance != k15_immuneToFire) {
 						if (getFlag(L0471_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
@@ -536,7 +536,7 @@ void ProjExpl::processEvent25(TimelineEvent* event) {
 	L0538_B_ExplosionOnPartySquare = (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0528_ui_MapX == _vm->_dungeonMan->_partyMapX) && (L0529_ui_MapY == _vm->_dungeonMan->_partyMapY);
 	if ((L0535_T_GroupThing = _vm->_groupMan->groupGetThing(L0528_ui_MapX, L0529_ui_MapY)) != Thing::_endOfList) {
 		L0533_ps_Group = (Group*)_vm->_dungeonMan->getThingData(L0535_T_GroupThing);
-		L0534_ps_CreatureInfo = &g243_CreatureInfo[AL0537_ui_CreatureType = L0533_ps_Group->_type];
+		L0534_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[AL0537_ui_CreatureType = L0533_ps_Group->_type];
 	}
 	if ((L0536_T_ExplosionThing = Thing(Thing::_firstExplosion.toUint16() + L0532_ps_Explosion->getType())) == Thing::_explPoisonCloud) {
 		L0530_i_Attack = MAX(1, MIN(L0532_ps_Explosion->getAttack() >> 5, 4) + _vm->getRandomNumber(2)); /* Value between 1 and 5 */
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 1089855..98987dc 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -203,9 +203,9 @@ uint16 Timeline::addEventGetEventIndex(TimelineEvent* event) {
 	TimelineEvent* L0591_ps_Event;
 
 
-	if (_eventCount == _eventMaxCount) {
-		_vm->displayErrorAndStop(45);
-	}
+	if (_eventCount == _eventMaxCount)
+		error("Too many events");
+
 	if ((event->_type >= k5_TMEventTypeCorridor) && (event->_type <= k10_TMEventTypeDoor)) {
 		for (L0588_ui_EventIndex = 0, L0591_ps_Event = _events; L0588_ui_EventIndex < _eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
 			if ((L0591_ps_Event->_type >= k5_TMEventTypeCorridor) && (L0591_ps_Event->_type <= k10_TMEventTypeDoor)) {


Commit: 8c9eed7bac935bf901c5fde5f9ed0f2e4e11daa4
    https://github.com/scummvm/scummvm/commit/8c9eed7bac935bf901c5fde5f9ed0f2e4e11daa4
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-28T00:33:32+02:00

Commit Message:
DM: Some renaming

Changed paths:
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/group.cpp



diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index eff761a..f41ccf2 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -954,7 +954,8 @@ T0172010_ClosedFakeWall:
 			curThing = getNextThing(curThing);
 		}
 
-		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapX, mapY)) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_party._lastScentIndex))
+		AL0307_uc_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapX, mapY);
+		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_party._lastScentIndex))
 			setFlag(aspectArray[k4_FloorOrnOrdAspect], k0x8000_FootprintsAspect);
 
 		break;
@@ -978,7 +979,8 @@ T0172010_ClosedFakeWall:
 		while ((curThing != Thing::_endOfList) && (curThing.getType() <= k3_SensorThingType))
 			curThing = getNextThing(curThing);
 
-		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapX, mapY)) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_party._lastScentIndex))
+		AL0307_uc_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapX, mapY);
+		if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_party._lastScentIndex))
 			setFlag(aspectArray[k4_FloorOrnOrdAspect], k0x8000_FootprintsAspect);
 		break;
 	}
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index c267b73..01f6567 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1559,7 +1559,8 @@ void EventManager::commandProcessTypes101To108_clickInSpellSymbolsArea(CommandTy
 		Box(277, 289, 51, 61),   /* Symbol 4 */
 		Box(291, 303, 51, 61),   /* Symbol 5 */
 		Box(305, 317, 51, 61),   /* Symbol 6 */
-		Box(305, 318, 63, 73)}; /* Delete */
+		Box(305, 318, 63, 73)    /* Delete */
+	};
 
 	if (cmdType == k108_CommandClickInSpeallAreaCastSpell) {
 		if (_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex]._symbols[0] == '\0')
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 296ee96..264fa29 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -749,7 +749,8 @@ void DisplayMan::drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButtonInd
 			_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordSetRedEagle[2];
 			_vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordSetRedEagle[3];
 		} else {
-			if (!isDerivedBitmapInCache(doorButtonOrdinal = k102_DerivedBitmapFirstDoorButton + (doorButtonOrdinal * 2) + ((!viewDoorButtonIndex) ? 0 : viewDoorButtonIndex - 1))) {
+			doorButtonOrdinal = k102_DerivedBitmapFirstDoorButton + (doorButtonOrdinal * 2) + ((!viewDoorButtonIndex) ? 0 : viewDoorButtonIndex - 1);
+			if (!isDerivedBitmapInCache(doorButtonOrdinal)) {
 				uint16 *coordSetBlueGoat = doorButtonCoordSets[coordSet][k3_viewDoorButton_D1C];
 				byte *bitmapNative = getNativeBitmapOrGraphic(nativeBitmapIndex);
 				blitToBitmapShrinkWithPalChange(bitmapNative, getDerivedBitmap(doorButtonOrdinal),
@@ -776,7 +777,7 @@ void DisplayMan::viewportSetPalette(uint16* middleScreenPalette, uint16* topAndB
 }
 
 void DisplayMan::viewportBlitToScreen() {
-	Box box(0, 223, 33, 33 + 135);
+	Box box(0, 223, 33, 168);
 
 	blitToBitmap(_bitmapViewport, _bitmapScreen, box, 0, 0, k112_byteWidthViewport, k160_byteWidthScreen, kM1_ColorNoTransparency,
 					  k136_heightViewport, k200_heightScreen);
@@ -863,11 +864,9 @@ void DisplayMan::blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask
 													int16 lastUnitIndex, int16 firstUnitIndex, int16 destByteWidth, Color transparent,
 													int16 xPos, int16 yPos, int16 destHeight, int16 height2) {
 	// make sure to take care of inclusive boundaries, color can have 0x8000 flag to not use mask
-	warning("STUB: f133_blitBoxFilledWithMaskedBitmap");
+	warning("STUB: blitBoxFilledWithMaskedBitmap");
 }
 
-
-
 void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height) {
 	uint16 width = byteWidth * 2;
 	for (uint16 y = 0; y < height; ++y) {
@@ -2208,8 +2207,8 @@ void DisplayMan::loadWallSet(WallSet set) {
 }
 
 void DisplayMan::loadCurrentMapGraphics() {
-	static Box BoxWallD3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR
-	static Box BoxWallD2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR
+	static Box boxWallD3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR
+	static Box boxWallD2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR
 	static byte doorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordinateSetIndices
 		0,   /* Door Ornament #00 Square Grid */
 		1,   /* Door Ornament #01 Iron Bars */
@@ -2311,12 +2310,12 @@ void DisplayMan::loadCurrentMapGraphics() {
 	copyBitmapAndFlipHorizontal(_bitmapWallD3LCRNative = _bitmapWallSetD3LCR, _tmpBitmap,
 									_frameWalls163[k0_ViewSquare_D3C]._srcByteWidth, _frameWalls163[k0_ViewSquare_D3C]._srcHeight);
 	fillBitmap(_bitmapWallD3LCRFlipped, k10_ColorFlesh, 64, 51);
-	blitToBitmap(_tmpBitmap, _bitmapWallD3LCRFlipped, BoxWallD3LCR, 11, 0, 64, 64, kM1_ColorNoTransparency, 51, 51);
+	blitToBitmap(_tmpBitmap, _bitmapWallD3LCRFlipped, boxWallD3LCR, 11, 0, 64, 64, kM1_ColorNoTransparency, 51, 51);
 
 	copyBitmapAndFlipHorizontal(_bitmapWallD2LCRNative = _bitmapWallSetD2LCR, _tmpBitmap,
 									_frameWalls163[k3_ViewSquare_D2C]._srcByteWidth, _frameWalls163[k3_ViewSquare_D2C]._srcHeight);
 	fillBitmap(_bitmapWallD2LCRFlipped, k10_ColorFlesh, 72, 71);
-	blitToBitmap(_tmpBitmap, _bitmapWallD2LCRFlipped, BoxWallD2LCR, 8, 0, 72, 72, kM1_ColorNoTransparency, 71, 71);
+	blitToBitmap(_tmpBitmap, _bitmapWallD2LCRFlipped, boxWallD2LCR, 8, 0, 72, 72, kM1_ColorNoTransparency, 71, 71);
 
 	copyBitmapAndFlipHorizontal(_bitmapWallD1LCRNative = _bitmapWallSetD1LCR, _bitmapWallD1LCRFlipped,
 									_frameWalls163[k6_ViewSquare_D1C]._srcByteWidth, _frameWalls163[k6_ViewSquare_D1C]._srcHeight);
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 519a62e..6c11946 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -291,9 +291,6 @@ void GroupMan::dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int
 }
 
 int16 GroupMan::getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
-#define AP0483_i_PrimaryDirection srcMapX
-	int16 L0556_i_Direction;
-
 	if (srcMapX == destMapX) {
 		_vm->_projexpl->_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 1; /* Resulting direction may be 1 or 3 (East or West) */
 		if (srcMapY > destMapY) {
@@ -308,75 +305,65 @@ int16 GroupMan::getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY
 		}
 		return kDirEast;
 	}
-	L0556_i_Direction = kDirNorth;
+
+	int16 curDirection = kDirNorth;
 	for (;;) {
-		if (isDestVisibleFromSource(L0556_i_Direction, srcMapX, srcMapY, destMapX, destMapY)) {
-			if (!isDestVisibleFromSource(_vm->_projexpl->_secondaryDirToOrFromParty = returnNextVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
-				if ((L0556_i_Direction != kDirNorth) || !isDestVisibleFromSource(_vm->_projexpl->_secondaryDirToOrFromParty = returnPrevVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) {
-					_vm->_projexpl->_secondaryDirToOrFromParty = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + L0556_i_Direction);
-					return L0556_i_Direction;
+		if (isDestVisibleFromSource(curDirection, srcMapX, srcMapY, destMapX, destMapY)) {
+			_vm->_projexpl->_secondaryDirToOrFromParty = returnNextVal(curDirection);
+			if (!isDestVisibleFromSource(_vm->_projexpl->_secondaryDirToOrFromParty, srcMapX, srcMapY, destMapX, destMapY)) {
+				_vm->_projexpl->_secondaryDirToOrFromParty = returnPrevVal(curDirection);
+				if ((curDirection != kDirNorth) || !isDestVisibleFromSource(_vm->_projexpl->_secondaryDirToOrFromParty, srcMapX, srcMapY, destMapX, destMapY)) {
+					_vm->_projexpl->_secondaryDirToOrFromParty = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + curDirection);
+					return curDirection;
 				}
 			}
 			if (_vm->getRandomNumber(2)) {
-				AP0483_i_PrimaryDirection = _vm->_projexpl->_secondaryDirToOrFromParty;
-				_vm->_projexpl->_secondaryDirToOrFromParty = L0556_i_Direction;
-				return AP0483_i_PrimaryDirection;
+				int16 primaryDirection = _vm->_projexpl->_secondaryDirToOrFromParty;
+				_vm->_projexpl->_secondaryDirToOrFromParty = curDirection;
+				return primaryDirection;
 			}
-			return L0556_i_Direction;
+			return curDirection;
 		}
-		L0556_i_Direction++;
+		curDirection++;
 	}
 }
 
 bool GroupMan::isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
-	int L1637_i_Temp;
-
 	switch (dir) { /* If direction is not 'West' then swap variables so that the same test as for west can be applied */
 	case kDirSouth:
-		L1637_i_Temp = srcMapX;
-		srcMapX = destMapY;
-		destMapY = L1637_i_Temp;
-		L1637_i_Temp = destMapX;
-		destMapX = srcMapY;
-		srcMapY = L1637_i_Temp;
+		SWAP(srcMapX, destMapY);
+		SWAP(destMapX, srcMapY);
 		break;
 	case kDirEast:
-		L1637_i_Temp = srcMapX;
-		srcMapX = destMapX;
-		destMapX = L1637_i_Temp;
-		L1637_i_Temp = destMapY;
-		destMapY = srcMapY;
-		srcMapY = L1637_i_Temp;
+		SWAP(srcMapX, destMapX);
+		SWAP(destMapY, srcMapY);
 		break;
 	case kDirNorth:
-		L1637_i_Temp = srcMapX;
-		srcMapX = srcMapY;
-		srcMapY = L1637_i_Temp;
-		L1637_i_Temp = destMapX;
-		destMapX = destMapY;
-		destMapY = L1637_i_Temp;
+		SWAP(srcMapX, srcMapY);
+		SWAP(destMapX, destMapY);
+		break;
 	}
 	return ((srcMapX -= (destMapX - 1)) > 0) && ((((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY) <= srcMapX);
 }
 
 bool GroupMan::groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack, bool magicAttack, int16 ticks) {
-	Door *L0573_ps_Door = (Door *)_vm->_dungeonMan->getSquareFirstThingData(mapX, mapY);
-	if ((magicAttack && !L0573_ps_Door->isMagicDestructible()) || (!magicAttack && !L0573_ps_Door->isMeleeDestructible())) {
+	Door *curDoor = (Door *)_vm->_dungeonMan->getSquareFirstThingData(mapX, mapY);
+	if ((magicAttack && !curDoor->isMagicDestructible()) || (!magicAttack && !curDoor->isMeleeDestructible())) {
 		return false;
 	}
-	if (attack >= _vm->_dungeonMan->_currMapDoorInfo[L0573_ps_Door->getType()]._defense) {
-		byte *L0574_puc_Square = &_vm->_dungeonMan->_currMapData[mapX][mapY];
-		if (Square(*L0574_puc_Square).getDoorState() == k4_doorState_CLOSED) {
+	if (attack >= _vm->_dungeonMan->_currMapDoorInfo[curDoor->getType()]._defense) {
+		byte *curSquare = &_vm->_dungeonMan->_currMapData[mapX][mapY];
+		if (Square(*curSquare).getDoorState() == k4_doorState_CLOSED) {
 			if (ticks) {
-				TimelineEvent L0575_s_Event;
-				setMapAndTime(L0575_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + ticks);
-				L0575_s_Event._type = k2_TMEventTypeDoorDestruction;
-				L0575_s_Event._priority = 0;
-				L0575_s_Event._B._location._mapX = mapX;
-				L0575_s_Event._B._location._mapY = mapY;
-				_vm->_timeline->addEventGetEventIndex(&L0575_s_Event);
+				TimelineEvent newEvent;
+				setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + ticks);
+				newEvent._type = k2_TMEventTypeDoorDestruction;
+				newEvent._priority = 0;
+				newEvent._B._location._mapX = mapX;
+				newEvent._B._location._mapY = mapY;
+				_vm->_timeline->addEventGetEventIndex(&newEvent);
 			} else {
-				((Square *)L0574_puc_Square)->setDoorState(k5_doorState_DESTROYED);
+				((Square *)curSquare)->setDoorState(k5_doorState_DESTROYED);
 			}
 			return true;
 		}
@@ -385,13 +372,11 @@ bool GroupMan::groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 atta
 }
 
 Thing GroupMan::groupGetThing(int16 mapX, int16 mapY) {
-	Thing L0317_T_Thing;
-
-	L0317_T_Thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
-	while ((L0317_T_Thing != Thing::_endOfList) && ((L0317_T_Thing).getType() != k4_GroupThingType)) {
-		L0317_T_Thing = _vm->_dungeonMan->getNextThing(L0317_T_Thing);
+	Thing curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+	while ((curThing != Thing::_endOfList) && ((curThing).getType() != k4_GroupThingType)) {
+		curThing = _vm->_dungeonMan->getNextThing(curThing);
 	}
-	return L0317_T_Thing;
+	return curThing;
 }
 
 int16 GroupMan::groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex, int16 mapX, int16 mapY, int16 damage, bool notMoving) {


Commit: ed248ca1e05ad016e6c737c05782cf90c34a1082
    https://github.com/scummvm/scummvm/commit/ed248ca1e05ad016e6c737c05782cf90c34a1082
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-28T10:34:41+02:00

Commit Message:
DM: Renaming in GroupMan

Changed paths:
    engines/dm/group.cpp



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 6c11946..f061920 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -293,16 +293,16 @@ void GroupMan::dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int
 int16 GroupMan::getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
 	if (srcMapX == destMapX) {
 		_vm->_projexpl->_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 1; /* Resulting direction may be 1 or 3 (East or West) */
-		if (srcMapY > destMapY) {
+		if (srcMapY > destMapY)
 			return kDirNorth;
-		}
+
 		return kDirSouth;
 	}
 	if (srcMapY == destMapY) {
 		_vm->_projexpl->_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 0; /* Resulting direction may be 0 or 2 (North or South) */
-		if (srcMapX > destMapX) {
+		if (srcMapX > destMapX)
 			return kDirWest;
-		}
+
 		return kDirEast;
 	}
 
@@ -348,9 +348,9 @@ bool GroupMan::isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 srcMapY,
 
 bool GroupMan::groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack, bool magicAttack, int16 ticks) {
 	Door *curDoor = (Door *)_vm->_dungeonMan->getSquareFirstThingData(mapX, mapY);
-	if ((magicAttack && !curDoor->isMagicDestructible()) || (!magicAttack && !curDoor->isMeleeDestructible())) {
+	if ((magicAttack && !curDoor->isMagicDestructible()) || (!magicAttack && !curDoor->isMeleeDestructible()))
 		return false;
-	}
+
 	if (attack >= _vm->_dungeonMan->_currMapDoorInfo[curDoor->getType()]._defense) {
 		byte *curSquare = &_vm->_dungeonMan->_currMapData[mapX][mapY];
 		if (Square(*curSquare).getDoorState() == k4_doorState_CLOSED) {
@@ -373,138 +373,124 @@ bool GroupMan::groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 atta
 
 Thing GroupMan::groupGetThing(int16 mapX, int16 mapY) {
 	Thing curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
-	while ((curThing != Thing::_endOfList) && ((curThing).getType() != k4_GroupThingType)) {
+	while ((curThing != Thing::_endOfList) && (curThing.getType() != k4_GroupThingType))
 		curThing = _vm->_dungeonMan->getNextThing(curThing);
-	}
+
 	return curThing;
 }
 
 int16 GroupMan::groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex, int16 mapX, int16 mapY, int16 damage, bool notMoving) {
-	uint16 L0374_ui_Multiple;
-#define AL0374_ui_EventIndex    L0374_ui_Multiple
-#define AL0374_ui_CreatureIndex L0374_ui_Multiple
-#define AL0374_ui_CreatureSize  L0374_ui_Multiple
-#define AL0374_ui_Attack        L0374_ui_Multiple
-	uint16 L0375_ui_Multiple;
-#define AL0375_ui_Outcome           L0375_ui_Multiple
-#define AL0375_ui_EventType         L0375_ui_Multiple
-#define AL0375_ui_NextCreatureIndex L0375_ui_Multiple
-	CreatureInfo *L0376_ps_CreatureInfo;
-	TimelineEvent *L0377_ps_Event;
-	ActiveGroup *L0378_ps_ActiveGroup = nullptr;
-	uint16 L0379_ui_CreatureCount;
-	uint16 L0380_ui_Multiple = 0;
-#define AL0380_ui_CreatureType   L0380_ui_Multiple
-#define AL0380_ui_FearResistance L0380_ui_Multiple
-	uint16 L0381_ui_GroupCells;
-	uint16 L0382_ui_GroupDirections;
-	bool L0383_B_CurrentMapIsPartyMap;
-	uint16 L0384_ui_Cell;
-
-
-	L0376_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[AL0380_ui_CreatureType = group->_type];
-	if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) /* Lord Chaos cannot be damaged */
-		goto T0190024;
+	uint16 creatureType = group->_type;
+	CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[creatureType];
+	if (getFlag(creatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) /* Lord Chaos cannot be damaged */
+		return k0_outcomeKilledNoCreaturesInGroup;
+
 	if (group->_health[creatureIndex] <= damage) {
-		L0381_ui_GroupCells = getGroupCells(group, _vm->_dungeonMan->_currMapIndex);
-		L0384_ui_Cell = (L0381_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : getCreatureValue(L0381_ui_GroupCells, creatureIndex);
-		if (!(L0379_ui_CreatureCount = group->getCount())) { /* If there is a single creature in the group */
+		uint16 groupCells = getGroupCells(group, _vm->_dungeonMan->_currMapIndex);
+		uint16 cell = (groupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : getCreatureValue(groupCells, creatureIndex);
+		uint16 creatureCount = group->getCount();
+		uint16 retVal;
+
+		if (!creatureCount) { /* If there is a single creature in the group */
 			if (notMoving) {
 				dropGroupPossessions(mapX, mapY, groupGetThing(mapX, mapY), k2_soundModePlayOneTickLater);
 				groupDelete(mapX, mapY);
 			}
-			AL0375_ui_Outcome = k2_outcomeKilledAllCreaturesInGroup;
+			retVal = k2_outcomeKilledAllCreaturesInGroup;
 		} else { /* If there are several creatures in the group */
-			L0382_ui_GroupDirections = getGroupDirections(group, _vm->_dungeonMan->_currMapIndex);
-			if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
-				if (notMoving) {
-					dropCreatureFixedPossessions(AL0380_ui_CreatureType, mapX, mapY, L0384_ui_Cell, k2_soundModePlayOneTickLater);
-				} else {
-					_dropMovingCreatureFixedPossessionsCell[_dropMovingCreatureFixedPossCellCount++] = L0384_ui_Cell;
-				}
+			uint16 groupDirections = getGroupDirections(group, _vm->_dungeonMan->_currMapIndex);
+			if (getFlag(creatureInfo->_attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) {
+				if (notMoving)
+					dropCreatureFixedPossessions(creatureType, mapX, mapY, cell, k2_soundModePlayOneTickLater);
+				else
+					_dropMovingCreatureFixedPossessionsCell[_dropMovingCreatureFixedPossCellCount++] = cell;
 			}
-			L0383_B_CurrentMapIsPartyMap = (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex);
-			if (L0383_B_CurrentMapIsPartyMap)
-				L0378_ps_ActiveGroup = &_activeGroups[group->getActiveGroupIndex()];
+			bool currentMapIsPartyMap = (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex);
+			ActiveGroup *activeGroup = nullptr;
+			if (currentMapIsPartyMap)
+				activeGroup = &_activeGroups[group->getActiveGroupIndex()];
 
 			if (group->getBehaviour() == k6_behavior_ATTACK) {
-				L0377_ps_Event = _vm->_timeline->_events;
-				for (AL0374_ui_EventIndex = 0; AL0374_ui_EventIndex < _vm->_timeline->_eventMaxCount; AL0374_ui_EventIndex++) {
-					if ((getMap(L0377_ps_Event->_mapTime) == _vm->_dungeonMan->_currMapIndex) &&
-						(L0377_ps_Event->_B._location._mapX == mapX) &&
-						(L0377_ps_Event->_B._location._mapY == mapY) &&
-						((AL0375_ui_EventType = L0377_ps_Event->_type) > k32_TMEventTypeUpdateAspectGroup) &&
-						(AL0375_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1)) {
-						if (AL0375_ui_EventType < k37_TMEventTypeUpdateBehaviourGroup) {
-							AL0375_ui_EventType -= k33_TMEventTypeUpdateAspectCreature_0; /* Get creature index for events 33 to 36 */
-						} else {
-							AL0375_ui_EventType -= k38_TMEventTypeUpdateBehaviour_0; /* Get creature index for events 38 to 41 */
-						}
-						if (AL0375_ui_NextCreatureIndex == creatureIndex) {
-							_vm->_timeline->deleteEvent(AL0374_ui_EventIndex);
-						} else {
-							if (AL0375_ui_NextCreatureIndex > creatureIndex) {
-								L0377_ps_Event->_type -= 1;
-								_vm->_timeline->fixChronology(_vm->_timeline->getIndex(AL0374_ui_EventIndex));
-							}
+				TimelineEvent *curEvent = _vm->_timeline->_events;
+				for (uint16 eventIndex = 0; eventIndex < _vm->_timeline->_eventMaxCount; eventIndex++) {
+					uint16 curEventType = curEvent->_type;
+					if ((getMap(curEvent->_mapTime) == _vm->_dungeonMan->_currMapIndex) &&
+						(curEvent->_B._location._mapX == mapX) &&
+						(curEvent->_B._location._mapY == mapY) &&
+						(curEventType > k32_TMEventTypeUpdateAspectGroup) &&
+						(curEventType < k41_TMEventTypeUpdateBehaviour_3 + 1)) {
+						uint16 nextCreatureIndex;
+						if (curEventType < k37_TMEventTypeUpdateBehaviourGroup)
+							nextCreatureIndex = curEventType - k33_TMEventTypeUpdateAspectCreature_0; /* Get creature index for events 33 to 36 */
+						else
+							nextCreatureIndex = curEventType - k38_TMEventTypeUpdateBehaviour_0; /* Get creature index for events 38 to 41 */
+
+						if (nextCreatureIndex == creatureIndex)
+							_vm->_timeline->deleteEvent(eventIndex);
+						else if (nextCreatureIndex > creatureIndex) {
+							curEvent->_type -= 1;
+							_vm->_timeline->fixChronology(_vm->_timeline->getIndex(eventIndex));
 						}
 					}
-					L0377_ps_Event++;
+					curEvent++;
 				}
-				if (L0383_B_CurrentMapIsPartyMap && ((AL0380_ui_FearResistance = L0376_ps_CreatureInfo->getFearResistance()) != k15_immuneToFear) && ((AL0380_ui_FearResistance += L0379_ui_CreatureCount - 1) < (_vm->getRandomNumber(16)))) { /* Test if the death of a creature frigthens the remaining creatures in the group */
-					L0378_ps_ActiveGroup->_delayFleeingFromTarget = _vm->getRandomNumber(100 - (AL0380_ui_FearResistance << 2)) + 20;
-					group->setBehaviour(k5_behavior_FLEE);
+
+				uint16 fearResistance = creatureInfo->getFearResistance();
+				if (currentMapIsPartyMap && (fearResistance) != k15_immuneToFear) {
+					fearResistance += creatureCount - 1;
+					if (fearResistance < _vm->getRandomNumber(16)) { /* Test if the death of a creature frightens the remaining creatures in the group */
+						activeGroup->_delayFleeingFromTarget = _vm->getRandomNumber(100 - (fearResistance << 2)) + 20;
+						group->setBehaviour(k5_behavior_FLEE);
+					}
 				}
 			}
-			for (AL0375_ui_NextCreatureIndex = AL0374_ui_CreatureIndex = creatureIndex; AL0374_ui_CreatureIndex < L0379_ui_CreatureCount; AL0374_ui_CreatureIndex++) {
-				AL0375_ui_NextCreatureIndex++;
-				group->_health[AL0374_ui_CreatureIndex] = group->_health[AL0375_ui_NextCreatureIndex];
-				L0382_ui_GroupDirections = getGroupValueUpdatedWithCreatureValue(L0382_ui_GroupDirections, AL0374_ui_CreatureIndex, getCreatureValue(L0382_ui_GroupDirections, AL0375_ui_NextCreatureIndex));
-				L0381_ui_GroupCells = getGroupValueUpdatedWithCreatureValue(L0381_ui_GroupCells, AL0374_ui_CreatureIndex, getCreatureValue(L0381_ui_GroupCells, AL0375_ui_NextCreatureIndex));
-				if (L0383_B_CurrentMapIsPartyMap) {
-					L0378_ps_ActiveGroup->_aspect[AL0374_ui_CreatureIndex] = L0378_ps_ActiveGroup->_aspect[AL0375_ui_NextCreatureIndex];
-				}
+			uint16 nextCreatureIndex = creatureIndex;
+			for (uint16 curCreatureIndex = creatureIndex; curCreatureIndex < creatureCount; curCreatureIndex++) {
+				nextCreatureIndex++;
+				group->_health[curCreatureIndex] = group->_health[nextCreatureIndex];
+				groupDirections = getGroupValueUpdatedWithCreatureValue(groupDirections, curCreatureIndex, getCreatureValue(groupDirections, nextCreatureIndex));
+				groupCells = getGroupValueUpdatedWithCreatureValue(groupCells, curCreatureIndex, getCreatureValue(groupCells, nextCreatureIndex));
+				if (currentMapIsPartyMap)
+					activeGroup->_aspect[curCreatureIndex] = activeGroup->_aspect[nextCreatureIndex];
 			}
-			L0381_ui_GroupCells &= 0x003F;
-			_vm->_dungeonMan->setGroupCells(group, L0381_ui_GroupCells, _vm->_dungeonMan->_currMapIndex);
-			_vm->_dungeonMan->setGroupDirections(group, L0382_ui_GroupDirections, _vm->_dungeonMan->_currMapIndex);
+			groupCells &= 0x003F;
+			_vm->_dungeonMan->setGroupCells(group, groupCells, _vm->_dungeonMan->_currMapIndex);
+			_vm->_dungeonMan->setGroupDirections(group, groupDirections, _vm->_dungeonMan->_currMapIndex);
 			group->setCount(group->getCount() - 1);
-			AL0375_ui_Outcome = k1_outcomeKilledSomeCreaturesInGroup;
+			retVal = k1_outcomeKilledSomeCreaturesInGroup;
 		}
-		if ((AL0374_ui_CreatureSize = getFlag(L0376_ps_CreatureInfo->_attributes, k0x0003_MaskCreatureInfo_size)) == k0_MaskCreatureSizeQuarter) {
-			AL0374_ui_Attack = 110;
-		} else {
-			if (AL0374_ui_CreatureSize == k1_MaskCreatureSizeHalf) {
-				AL0374_ui_Attack = 190;
-			} else {
-				AL0374_ui_Attack = 255;
-			}
-		}
-		_vm->_projexpl->createExplosion(Thing::_explSmoke, AL0374_ui_Attack, mapX, mapY, L0384_ui_Cell); /* BUG0_66 Smoke is placed on the source map instead of the destination map when a creature dies by falling through a pit. The game has a special case to correctly drop the creature possessions on the destination map but there is no such special case for the smoke. Note that the death must be caused by the damage of the fall (there is no smoke if the creature is removed because its type is not allowed on the destination map). However this bug has no visible consequence because of BUG0_26: the smoke explosion falls in the pit right after being placed in the dungeon and before being drawn on screen so it is only visible on the destination square */
-		return AL0375_ui_Outcome;
+
+		uint16 creatureSize = getFlag(creatureInfo->_attributes, k0x0003_MaskCreatureInfo_size);
+		uint16 attack;
+		if (creatureSize == k0_MaskCreatureSizeQuarter)
+			attack = 110;
+		else if (creatureSize == k1_MaskCreatureSizeHalf)
+			attack = 190;
+		else
+			attack = 255;
+
+		_vm->_projexpl->createExplosion(Thing::_explSmoke, attack, mapX, mapY, cell); /* BUG0_66 Smoke is placed on the source map instead of the destination map when a creature dies by falling through a pit. The game has a special case to correctly drop the creature possessions on the destination map but there is no such special case for the smoke. Note that the death must be caused by the damage of the fall (there is no smoke if the creature is removed because its type is not allowed on the destination map). However this bug has no visible consequence because of BUG0_26: the smoke explosion falls in the pit right after being placed in the dungeon and before being drawn on screen so it is only visible on the destination square */
+		return retVal;
 	}
-	if (damage > 0) {
+
+	if (damage > 0)
 		group->_health[creatureIndex] -= damage;
-	}
-T0190024:
+
 	return k0_outcomeKilledNoCreaturesInGroup;
 }
 
 void GroupMan::groupDelete(int16 mapX, int16 mapY) {
-	Thing L0372_T_GroupThing;
-	Group *L0373_ps_Group;
-
-
-	if ((L0372_T_GroupThing = groupGetThing(mapX, mapY)) == Thing::_endOfList) {
+	Thing groupThing = groupGetThing(mapX, mapY);
+	if (groupThing == Thing::_endOfList)
 		return;
-	}
-	L0373_ps_Group = (Group *)_vm->_dungeonMan->getThingData(L0372_T_GroupThing);
+
+	Group *group = (Group *)_vm->_dungeonMan->getThingData(groupThing);
 	for (uint16 i = 0; i < 4; ++i)
-		L0373_ps_Group->_health[i] = 0;
-	_vm->_moveSens->getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
-	L0373_ps_Group->_nextThing = Thing::_none;
+		group->_health[i] = 0;
+	_vm->_moveSens->getMoveResult(groupThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
+	group->_nextThing = Thing::_none;
 	if (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) {
-		_activeGroups[L0373_ps_Group->getActiveGroupIndex()]._groupThingIndex = -1;
+		_activeGroups[group->getActiveGroupIndex()]._groupThingIndex = -1;
 		_currActiveGroupCount--;
 	}
 	groupDeleteEvents(mapX, mapY);


Commit: c54204910d18945f8d0f8637a2c1ee307046deb5
    https://github.com/scummvm/scummvm/commit/c54204910d18945f8d0f8637a2c1ee307046deb5
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-28T22:26:44+02:00

Commit Message:
DM: WIP rework of processEvents29to41, some more renaming

Changed paths:
    engines/dm/group.cpp
    engines/dm/group.h



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index f061920..eada054 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -497,76 +497,62 @@ void GroupMan::groupDelete(int16 mapX, int16 mapY) {
 }
 
 void GroupMan::groupDeleteEvents(int16 mapX, int16 mapY) {
-	int16 L0334_i_EventIndex;
-	uint16 L0335_ui_EventType;
-	TimelineEvent *L0336_ps_Event;
-
-
-	L0336_ps_Event = _vm->_timeline->_events;
-	for (L0334_i_EventIndex = 0; L0334_i_EventIndex < _vm->_timeline->_eventMaxCount; L0334_i_EventIndex++) {
-		if ((getMap(L0336_ps_Event->_mapTime) == _vm->_dungeonMan->_currMapIndex) &&
-			((L0335_ui_EventType = L0336_ps_Event->_type) > k29_TMEventTypeGroupReactionDangerOnSquare - 1) && (L0335_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1) &&
-			(L0336_ps_Event->_B._location._mapX == mapX) && (L0336_ps_Event->_B._location._mapY == mapY)) {
-			_vm->_timeline->deleteEvent(L0334_i_EventIndex);
+	TimelineEvent *curEvent = _vm->_timeline->_events;
+	for (int16 eventIndex = 0; eventIndex < _vm->_timeline->_eventMaxCount; eventIndex++) {
+		uint16 curEventType = curEvent->_type;
+		if ((getMap(curEvent->_mapTime) == _vm->_dungeonMan->_currMapIndex) &&
+			(curEventType > k29_TMEventTypeGroupReactionDangerOnSquare - 1) && (curEventType < k41_TMEventTypeUpdateBehaviour_3 + 1) &&
+			(curEvent->_B._location._mapX == mapX) && (curEvent->_B._location._mapY == mapY)) {
+			_vm->_timeline->deleteEvent(eventIndex);
 		}
-		L0336_ps_Event++;
+		curEvent++;
 	}
 }
 
-uint16 GroupMan::getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatreVal) {
-	creatreVal &= 0x0003;
-	creatreVal <<= (creatureIndex <<= 1);
-	return creatreVal | (groupVal & ~(3 << creatreVal));
+uint16 GroupMan::getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatureVal) {
+	creatureVal &= 0x0003;
+	creatureIndex <<= 1;
+	creatureVal <<= creatureIndex;
+	return creatureVal | (groupVal & ~(3 << creatureVal));
 }
 
 int16 GroupMan::getDamageAllCreaturesOutcome(Group *group, int16 mapX, int16 mapY, int16 attack, bool notMoving) {
-	uint16 L0385_ui_RandomAttack;
-	int16 L0386_i_CreatureIndex;
-	int16 L0387_i_Outcome;
-	bool L0388_B_KilledSomeCreatures;
-	bool L0389_B_KilledAllCreatures;
-
-
-	L0388_B_KilledSomeCreatures = false;
-	L0389_B_KilledAllCreatures = true;
+	bool killedSomeCreatures = false;
+	bool killedAllCreatures = true;
 	_dropMovingCreatureFixedPossCellCount = 0;
 	if (attack > 0) {
-		L0386_i_CreatureIndex = group->getCount();
-		attack -= (L0385_ui_RandomAttack = (attack >> 3) + 1);
-		L0385_ui_RandomAttack <<= 1;
+		int16 creatureIndex = group->getCount();
+		uint16 randomAttackSeed = (attack >> 3) + 1;
+		attack -= randomAttackSeed;
+		randomAttackSeed <<= 1;
 		do {
-			L0389_B_KilledAllCreatures = (L0387_i_Outcome = groupGetDamageCreatureOutcome(group, L0386_i_CreatureIndex, mapX, mapY, attack + _vm->getRandomNumber(L0385_ui_RandomAttack), notMoving)) && L0389_B_KilledAllCreatures;
-			L0388_B_KilledSomeCreatures = L0388_B_KilledSomeCreatures || L0387_i_Outcome;
-		} while (L0386_i_CreatureIndex--);
-		if (L0389_B_KilledAllCreatures) {
+			int16 outcomeVal = groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapY, attack + _vm->getRandomNumber(randomAttackSeed), notMoving);
+			killedAllCreatures = outcomeVal && killedAllCreatures;
+			killedSomeCreatures = killedSomeCreatures || outcomeVal;
+		} while (creatureIndex--);
+		if (killedAllCreatures)
 			return k2_outcomeKilledAllCreaturesInGroup;
-		}
-		if (L0388_B_KilledSomeCreatures) {
+
+		if (killedSomeCreatures)
 			return k1_outcomeKilledSomeCreaturesInGroup;
-		}
-		return k0_outcomeKilledNoCreaturesInGroup;
-	} else {
-		return k0_outcomeKilledNoCreaturesInGroup;
 	}
+	
+	return k0_outcomeKilledNoCreaturesInGroup;
 }
 
 int16 GroupMan::groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack) {
-	int16 L0390_i_PoisonResistance;
+	int16 poisonResistance = _vm->_dungeonMan->_creatureInfos[creatreType].getPoisonResistance();
 
-	if (!poisonAttack || ((L0390_i_PoisonResistance = _vm->_dungeonMan->_creatureInfos[creatreType].getPoisonResistance()) == k15_immuneToPoison)) {
+	if (!poisonAttack || (poisonResistance == k15_immuneToPoison))
 		return 0;
-	}
-	return ((poisonAttack + _vm->getRandomNumber(4)) << 3) / ++L0390_i_PoisonResistance;
+
+	return ((poisonAttack + _vm->getRandomNumber(4)) << 3) / (poisonResistance + 1);
 }
 
 void GroupMan::processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks) {
-	Group *L0444_ps_Group;
-	ActiveGroup *L0445_ps_ActiveGroup;
 	int16 L0446_i_Multiple;
-#define AL0446_i_EventType           L0446_i_Multiple
 #define AL0446_i_Direction           L0446_i_Multiple
 #define AL0446_i_Ticks               L0446_i_Multiple
-#define AL0446_i_Distance            L0446_i_Multiple
 #define AL0446_i_Behavior2Or3        L0446_i_Multiple
 #define AL0446_i_CreatureAspectIndex L0446_i_Multiple
 #define AL0446_i_Range               L0446_i_Multiple
@@ -578,8 +564,6 @@ void GroupMan::processEvents29to41(int16 eventMapX, int16 eventMapY, int16 event
 #define AL0447_i_CreatureIndex      L0447_i_Multiple
 #define AL0447_i_ReferenceDirection L0447_i_Multiple
 #define AL0447_i_Ticks              L0447_i_Multiple
-	CreatureInfo L0448_s_CreatureInfo;
-	Thing L0449_T_GroupThing;
 	int16 L0450_i_Multiple;
 #define AL0450_i_DestinationMapX  L0450_i_Multiple
 #define AL0450_i_DistanceXToParty L0450_i_Multiple
@@ -588,79 +572,71 @@ void GroupMan::processEvents29to41(int16 eventMapX, int16 eventMapY, int16 event
 #define AL0451_i_DestinationMapY  L0451_i_Multiple
 #define AL0451_i_DistanceYToParty L0451_i_Multiple
 #define AL0451_i_TargetMapY       L0451_i_Multiple
-	int16 L0452_i_DistanceToVisibleParty = 0;
-	bool L0453_B_NewGroupDirectionFound;
-	int16 L0454_i_PrimaryDirectionToOrFromParty;
-	bool L0455_B_CurrentEventTypeIsNotUpdateBehavior;
-	bool L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls;
-	bool L0457_B_MoveToPriorLocation;
-	bool L0458_B_SetBehavior7_ApproachAfterReaction = false;
-	int16 L0459_i_CreatureSize;
-	uint16 L0460_ui_CreatureCount;
-	int16 L0461_i_MovementTicks;
-	int16 L0462_i_TicksSinceLastMove;
-	bool L0463_B_Archenemy;
-	int32 L0464_l_NextAspectUpdateTime;
-	TimelineEvent L0465_s_NextEvent;
-
 
 	/* If the party is not on the map specified in the event and the event type is not one of 32, 33, 37, 38 then the event is ignored */
-	if ((_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex) && ((AL0446_i_EventType = eventType) != k37_TMEventTypeUpdateBehaviourGroup) && (AL0446_i_EventType != k32_TMEventTypeUpdateAspectGroup) && (AL0446_i_EventType != k38_TMEventTypeUpdateBehaviour_0) && (AL0446_i_EventType != k33_TMEventTypeUpdateAspectCreature_0))
-		goto T0209139_Return;
+	if ((_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex)
+	 && (eventType != k37_TMEventTypeUpdateBehaviourGroup) && (eventType != k32_TMEventTypeUpdateAspectGroup)
+	 && (eventType != k38_TMEventTypeUpdateBehaviour_0) && (eventType != k33_TMEventTypeUpdateAspectCreature_0))
+		return;
+
+	Thing groupThing = groupGetThing(eventMapX, eventMapY);
 	/* If there is no creature at the location specified in the event then the event is ignored */
-	if ((L0449_T_GroupThing = groupGetThing(eventMapX, eventMapY)) == Thing::_endOfList) {
-		goto T0209139_Return;
-	}
-	L0444_ps_Group = (Group *)_vm->_dungeonMan->getThingData(L0449_T_GroupThing);
-	L0448_s_CreatureInfo = _vm->_dungeonMan->_creatureInfos[L0444_ps_Group->_type];
+	if (groupThing == Thing::_endOfList)
+		return;
+
+	Group *curGroup = (Group *)_vm->_dungeonMan->getThingData(groupThing);
+	CreatureInfo creatureInfo = _vm->_dungeonMan->_creatureInfos[curGroup->_type];
 	/* Update the event */
-	setMapAndTime(L0465_s_NextEvent._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime);
-	L0465_s_NextEvent._priority = 255 - L0448_s_CreatureInfo._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
-	L0465_s_NextEvent._B._location._mapX = eventMapX;
-	L0465_s_NextEvent._B._location._mapY = eventMapY;
+	TimelineEvent nextEvent;
+	setMapAndTime(nextEvent._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime);
+	nextEvent._priority = 255 - creatureInfo._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
+	nextEvent._B._location._mapX = eventMapX;
+	nextEvent._B._location._mapY = eventMapY;
 	/* If the creature is not on the party map then try and move the creature in a random direction and place a new event 37 in the timeline for the next creature movement */
 	if (_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex) {
-		if (isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->getRandomNumber(4), false)) { /* BUG0_67 A group that is not on the party map may wrongly move or not move into a teleporter. Normally, a creature type with Wariness >= 10 (Vexirk, Materializer / Zytaz, Demon, Lord Chaos, Red Dragon / Dragon) would only move into a teleporter if the creature type is allowed on the destination map. However, the variable G0380_T_CurrentGroupThing identifying the group is not set before being used by F0139_DUNGEON_IsCreatureAllowedOnMap called by f202_isMovementPossible so the check to see if the creature type is allowed may operate on another creature type and thus return an incorrect result, causing the creature to teleport while it should not, or not to teleport while it should */
+		if (isMovementPossible(&creatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->getRandomNumber(4), false)) { /* BUG0_67 A group that is not on the party map may wrongly move or not move into a teleporter. Normally, a creature type with Wariness >= 10 (Vexirk, Materializer / Zytaz, Demon, Lord Chaos, Red Dragon / Dragon) would only move into a teleporter if the creature type is allowed on the destination map. However, the variable G0380_T_CurrentGroupThing identifying the group is not set before being used by F0139_DUNGEON_IsCreatureAllowedOnMap called by f202_isMovementPossible so the check to see if the creature type is allowed may operate on another creature type and thus return an incorrect result, causing the creature to teleport while it should not, or not to teleport while it should */
 			AL0450_i_DestinationMapX = eventMapX;
 			AL0451_i_DestinationMapY = eventMapY;
-			AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
-			if (_vm->_moveSens->getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
-				goto T0209139_Return;
-			L0465_s_NextEvent._B._location._mapX = _vm->_moveSens->_moveResultMapX;
-			L0465_s_NextEvent._B._location._mapY = _vm->_moveSens->_moveResultMapY;
+			AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction];
+			AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
+			if (_vm->_moveSens->getMoveResult(groupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
+				return;
+			nextEvent._B._location._mapX = _vm->_moveSens->_moveResultMapX;
+			nextEvent._B._location._mapY = _vm->_moveSens->_moveResultMapY;
 		}
-		L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup;
-		AL0446_i_Ticks = MAX(ABS(_vm->_dungeonMan->_currMapIndex - _vm->_dungeonMan->_partyMapIndex) << 4, L0448_s_CreatureInfo._movementTicks << 1);
+		nextEvent._type = k37_TMEventTypeUpdateBehaviourGroup;
+		AL0446_i_Ticks = MAX(ABS(_vm->_dungeonMan->_currMapIndex - _vm->_dungeonMan->_partyMapIndex) << 4, creatureInfo._movementTicks << 1);
 		/* BUG0_68 A group moves or acts with a wrong timing. Event is added below but L0465_s_NextEvent.C.Ticks has not been initialized. No consequence while the group is not on the party map. When the party enters the group map the first group event may have a wrong timing */
 T0209005_AddEventAndReturn:
-		L0465_s_NextEvent._mapTime += AL0446_i_Ticks;
-		_vm->_timeline->addEventGetEventIndex(&L0465_s_NextEvent);
-		goto T0209139_Return;
+		nextEvent._mapTime += AL0446_i_Ticks;
+		_vm->_timeline->addEventGetEventIndex(&nextEvent);
+		return;
 	}
 	/* If the creature is Lord Chaos then ignore the event if the game is won. Initialize data to analyze Fluxcages */
-	L0463_B_Archenemy = getFlag(L0448_s_CreatureInfo._attributes, k0x2000_MaskCreatureInfo_archenemy);
-	if (L0463_B_Archenemy) {
-		if (_vm->_gameWon) {
-			goto T0209139_Return;
-		}
+	bool isArchEnemy = getFlag(creatureInfo._attributes, k0x2000_MaskCreatureInfo_archenemy);
+	if (isArchEnemy) {
+		if (_vm->_gameWon)
+			return;
+
 		_fluxCageCount = 0;
 		_fluxCages[0] = 0;
 	}
-	L0445_ps_ActiveGroup = &_activeGroups[L0444_ps_Group->getActiveGroupIndex()];
+	ActiveGroup *activeGroup = &_activeGroups[curGroup->getActiveGroupIndex()];
 
-	L0462_i_TicksSinceLastMove = (unsigned char)_vm->_gameTime - L0445_ps_ActiveGroup->_lastMoveTime;
-	if (L0462_i_TicksSinceLastMove < 0)
-		L0462_i_TicksSinceLastMove += 256;
+	// CHECKME: Terrible mix of types
+	int16 ticksSinceLastMove = (unsigned char)_vm->_gameTime - activeGroup->_lastMoveTime;
+	if (ticksSinceLastMove < 0)
+		ticksSinceLastMove += 256;
 
-	L0461_i_MovementTicks = L0448_s_CreatureInfo._movementTicks;
-	if (L0461_i_MovementTicks == k255_immobile)
-		L0461_i_MovementTicks = 100;
+	int16 movementTicks = creatureInfo._movementTicks;
+	if (movementTicks == k255_immobile)
+		movementTicks = 100;
 
-	if (_vm->_championMan->_party._freezeLifeTicks && !L0463_B_Archenemy) { /* If life is frozen and the creature is not Lord Chaos (Lord Chaos is immune to Freeze Life) then reschedule the event later (except for reactions which are ignored when life if frozen) */
+	if (_vm->_championMan->_party._freezeLifeTicks && !isArchEnemy) { /* If life is frozen and the creature is not Lord Chaos (Lord Chaos is immune to Freeze Life) then reschedule the event later (except for reactions which are ignored when life if frozen) */
 		if (eventType < 0)
-			goto T0209139_Return;
-		L0465_s_NextEvent._type = eventType;
-		L0465_s_NextEvent._C._ticks = ticks;
+			return;
+		nextEvent._type = eventType;
+		nextEvent._C._ticks = ticks;
 		AL0446_i_Ticks = 4; /* Retry in 4 ticks */
 		goto T0209005_AddEventAndReturn;
 	}
@@ -668,26 +644,31 @@ T0209005_AddEventAndReturn:
 	For event kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, the reaction time is 1 tick
 	For event kM2_TMEventTypeCreateReactionEvent30HitByProjectile and kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, the reaction time may be 1 tick or slower: slow moving creatures react more slowly. The more recent is the last creature move, the slower the reaction */
 	if (eventType < 0) {
-		L0465_s_NextEvent._type = eventType + k32_TMEventTypeUpdateAspectGroup;
-		if ((eventType == kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) || ((AL0446_i_Ticks = ((L0461_i_MovementTicks + 2) >> 2) - L0462_i_TicksSinceLastMove) < 1)) { /* AL0446_i_Ticks is the reaction time */
+		nextEvent._type = eventType + k32_TMEventTypeUpdateAspectGroup;
+		if ((eventType == kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) || ((AL0446_i_Ticks = ((movementTicks + 2) >> 2) - ticksSinceLastMove) < 1)) { /* AL0446_i_Ticks is the reaction time */
 			AL0446_i_Ticks = 1; /* Retry in 1 tick */
 		}
 		goto T0209005_AddEventAndReturn; /* BUG0_68 A group moves or acts with a wrong timing. Event is added but L0465_s_NextEvent.C.Ticks has not been initialized */
 	}
-	AL0447_i_Behavior = L0444_ps_Group->getBehaviour();
-	L0460_ui_CreatureCount = L0444_ps_Group->getCount();
-	L0459_i_CreatureSize = getFlag(L0448_s_CreatureInfo._attributes, k0x0003_MaskCreatureInfo_size);
-	AL0450_i_DistanceXToParty = ((AL0446_i_Distance = eventMapX - _vm->_dungeonMan->_partyMapX) < 0) ? -AL0446_i_Distance : AL0446_i_Distance;
-	AL0451_i_DistanceYToParty = ((AL0446_i_Distance = eventMapY - _vm->_dungeonMan->_partyMapY) < 0) ? -AL0446_i_Distance : AL0446_i_Distance;
+	AL0447_i_Behavior = curGroup->getBehaviour();
+	uint16 creatureCount = curGroup->getCount();
+	int16 creatureSize = getFlag(creatureInfo._attributes, k0x0003_MaskCreatureInfo_size);
+	AL0450_i_DistanceXToParty = ABS(eventMapX - _vm->_dungeonMan->_partyMapX);
+	AL0451_i_DistanceYToParty = ABS(eventMapY - _vm->_dungeonMan->_partyMapY);
 	_currentGroupMapX = eventMapX;
 	_currentGroupMapY = eventMapY;
-	_currGroupThing = L0449_T_GroupThing;
+	_currGroupThing = groupThing;
 	_groupMovementTestedDirections[0] = 0;
 	_currGroupDistanceToParty = getDistanceBetweenSquares(eventMapX, eventMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
 	_currGroupPrimaryDirToParty = getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
 	_currGroupSecondaryDirToParty = _vm->_projexpl->_secondaryDirToOrFromParty;
-	L0464_l_NextAspectUpdateTime = 0;
-	L0455_B_CurrentEventTypeIsNotUpdateBehavior = true;
+	int32 nextAspectUpdateTime = 0;
+	bool notUpdateBehaviorFl = true;
+	bool newGroupDirectionFound;
+	bool approachAfterReaction = false;
+	bool moveToPriorLocation = false;
+	int16 distanceToVisibleParty = 0;
+
 	if (eventType <= k31_TMEventTypeGroupReactionPartyIsAdjecent) { /* Process Reaction events 29 to 31 */
 		switch (eventType = eventType - k32_TMEventTypeUpdateAspectGroup) {
 		case kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent: /* This event is used when the party bumps into a group or attacks a group physically (not with a spell). It causes the creature behavior to change to attack if it is not already attacking the party or fleeing from target */
@@ -695,206 +676,207 @@ T0209005_AddEventAndReturn:
 				groupDeleteEvents(eventMapX, eventMapY);
 				goto T0209044_SetBehavior6_Attack;
 			}
-			L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
-			L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
-			goto T0209139_Return;
+			activeGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
+			activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
+			return;
 		case kM2_TMEventTypeCreateReactionEvent30HitByProjectile: /* This event is used for the reaction of a group after a projectile impacted with one creature in the group (some creatures may have been killed) */
 			if ((AL0447_i_Behavior == k6_behavior_ATTACK) || (AL0447_i_Behavior == k5_behavior_FLEE)) /* If the creature is attacking the party or fleeing from the target then there is no reaction */
-				goto T0209139_Return;
+				return;
 			if ((AL0446_i_Behavior2Or3 = ((AL0447_i_Behavior == k3_behavior_USELESS) || (AL0447_i_Behavior == k2_behavior_USELESS))) || (_vm->getRandomNumber(4))) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances */
-				if (!groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { /* If the group cannot see the party then look in a random direction to try and search for the party */
-					L0458_B_SetBehavior7_ApproachAfterReaction = L0453_B_NewGroupDirectionFound = false;
+				if (!groupGetDistanceToVisibleParty(curGroup, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { /* If the group cannot see the party then look in a random direction to try and search for the party */
+					approachAfterReaction = newGroupDirectionFound = false;
 					goto T0209073_SetDirectionGroup;
 				}
 				if (AL0446_i_Behavior2Or3 || (_vm->getRandomNumber(4))) /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances then no reaction */
-					goto T0209139_Return;
+					return;
 			} /* No 'break': proceed to instruction after the next 'case' below. Reaction is to move in a random direction to try and avoid other projectiles */
 		case kM3_TMEventTypeCreateReactionEvent29DangerOnSquare: /* This event is used when some creatures in the group were killed by a Poison Cloud or by a closing door or if Lord Chaos is surrounded by 3 Fluxcages. It causes the creature to move in a random direction to avoid the danger */
-			L0458_B_SetBehavior7_ApproachAfterReaction = (AL0447_i_Behavior == k6_behavior_ATTACK); /* If the creature behavior is 'Attack' and it has to move to avoid danger then it will change its behavior to 'Approach' after the movement */
-			L0453_B_NewGroupDirectionFound = false;
+			approachAfterReaction = (AL0447_i_Behavior == k6_behavior_ATTACK); /* If the creature behavior is 'Attack' and it has to move to avoid danger then it will change its behavior to 'Approach' after the movement */
+			newGroupDirectionFound = false;
 			goto T0209058_MoveInRandomDirection;
 		}
 	}
 	if (eventType < k37_TMEventTypeUpdateBehaviourGroup) { /* Process Update Aspect events 32 to 36 */
-		L0465_s_NextEvent._type = eventType + 5;
-		if (groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+		nextEvent._type = eventType + 5;
+		if (groupGetDistanceToVisibleParty(curGroup, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
 			if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) {
 				if (getDistance(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, eventMapX, eventMapY) <= 1)
 					goto T0209044_SetBehavior6_Attack;
 				if (((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k3_behavior_USELESS)) && (AL0447_i_Behavior != k7_behavior_APPROACH)) /* BUG0_00 Useless code. Behavior cannot be 3 because this value is never used. Moreover, the second condition in the && is redundant (if the value is 0 or 3, it cannot be 7). The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */
 					goto T0209054_SetBehavior7_Approach;
 			}
-			L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
-			L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
+			activeGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
+			activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
 		}
 		if (AL0447_i_Behavior == k6_behavior_ATTACK) {
 			AL0446_i_CreatureAspectIndex = eventType - k33_TMEventTypeUpdateAspectCreature_0; /* Value -1 for event 32, meaning aspect will be updated for all creatures in the group */
-			L0464_l_NextAspectUpdateTime = getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0446_i_CreatureAspectIndex, getFlag(L0445_ps_ActiveGroup->_aspect[AL0446_i_CreatureAspectIndex], k0x0080_MaskActiveGroupIsAttacking));
+			nextAspectUpdateTime = getCreatureAspectUpdateTime(activeGroup, AL0446_i_CreatureAspectIndex, getFlag(activeGroup->_aspect[AL0446_i_CreatureAspectIndex], k0x0080_MaskActiveGroupIsAttacking));
 			goto T0209136;
 		}
 		if ((AL0450_i_DistanceXToParty > 3) || (AL0451_i_DistanceYToParty > 3)) {
-			L0464_l_NextAspectUpdateTime = _vm->_gameTime + ((L0448_s_CreatureInfo._animationTicks >> 4) & 0xF);
+			nextAspectUpdateTime = _vm->_gameTime + ((creatureInfo._animationTicks >> 4) & 0xF);
 			goto T0209136;
 		}
 	} else { /* Process Update Behavior events 37 to 41 */
-		L0455_B_CurrentEventTypeIsNotUpdateBehavior = false;
+		int16 primaryDirectionToOrFromParty;
+		notUpdateBehaviorFl = false;
 		if (ticks)
-			L0464_l_NextAspectUpdateTime = _vm->_gameTime;
+			nextAspectUpdateTime = _vm->_gameTime;
 
 		if (eventType == k37_TMEventTypeUpdateBehaviourGroup) { /* Process event 37, Update Group Behavior */
+			bool allowMovementOverFakePitsAndFakeWalls;
 			if ((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k2_behavior_USELESS) || (AL0447_i_Behavior == k3_behavior_USELESS)) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */
-				L0452_i_DistanceToVisibleParty = groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY);
-				if (L0452_i_DistanceToVisibleParty) {
-					if ((L0452_i_DistanceToVisibleParty <= (L0448_s_CreatureInfo.getAttackRange())) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) { /* If the creature is in range for attack and on the same row or column as the party on the map */
+				distanceToVisibleParty = groupGetDistanceToVisibleParty(curGroup, kM1_wholeCreatureGroup, eventMapX, eventMapY);
+				if (distanceToVisibleParty) {
+					if ((distanceToVisibleParty <= (creatureInfo.getAttackRange())) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) { /* If the creature is in range for attack and on the same row or column as the party on the map */
 T0209044_SetBehavior6_Attack:
 						if (eventType == kM2_TMEventTypeCreateReactionEvent30HitByProjectile) {
 							groupDeleteEvents(eventMapX, eventMapY);
 						}
-						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
-						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
-						L0444_ps_Group->setBehaviour(k6_behavior_ATTACK);
+						activeGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
+						activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
+						curGroup->setBehaviour(k6_behavior_ATTACK);
 						AL0446_i_Direction = _currGroupPrimaryDirToParty;
-						for (AL0447_i_CreatureIndex = L0460_ui_CreatureCount; AL0447_i_CreatureIndex >= 0; AL0447_i_CreatureIndex--) {
-							if ((getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) != AL0446_i_Direction) &&
+						for (AL0447_i_CreatureIndex = creatureCount; AL0447_i_CreatureIndex >= 0; AL0447_i_CreatureIndex--) {
+							if ((getCreatureValue(activeGroup->_directions, AL0447_i_CreatureIndex) != AL0446_i_Direction) &&
 								((!AL0447_i_CreatureIndex) || (!_vm->getRandomNumber(2)))) {
-								setGroupDirection(L0445_ps_ActiveGroup, AL0446_i_Direction, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
-								M32_setTime(L0465_s_NextEvent._mapTime, _vm->_gameTime + _vm->getRandomNumber(4) + 2); /* Random delay represents the time for the creature to turn */
+								setGroupDirection(activeGroup, AL0446_i_Direction, AL0447_i_CreatureIndex, creatureCount && (creatureSize == k1_MaskCreatureSizeHalf));
+								M32_setTime(nextEvent._mapTime, _vm->_gameTime + _vm->getRandomNumber(4) + 2); /* Random delay represents the time for the creature to turn */
 							} else {
-								M32_setTime(L0465_s_NextEvent._mapTime, _vm->_gameTime + 1);
+								M32_setTime(nextEvent._mapTime, _vm->_gameTime + 1);
 							}
-							if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) {
-								L0465_s_NextEvent._mapTime += MIN((uint16)((L0448_s_CreatureInfo._attackTicks >> 1) + _vm->getRandomNumber(4)), ticks);
+							if (notUpdateBehaviorFl) {
+								nextEvent._mapTime += MIN((uint16)((creatureInfo._attackTicks >> 1) + _vm->getRandomNumber(4)), ticks);
 							}
-							L0465_s_NextEvent._type = k38_TMEventTypeUpdateBehaviour_0 + AL0447_i_CreatureIndex;
-							addGroupEvent(&L0465_s_NextEvent, getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false));
+							nextEvent._type = k38_TMEventTypeUpdateBehaviour_0 + AL0447_i_CreatureIndex;
+							addGroupEvent(&nextEvent, getCreatureAspectUpdateTime(activeGroup, AL0447_i_CreatureIndex, false));
 						}
-						goto T0209139_Return;
+						return;
 					}
 					if (AL0447_i_Behavior != k2_behavior_USELESS) { /* BUG0_00 Useless code. Behavior cannot be 2 because this value is never used */
 T0209054_SetBehavior7_Approach:
-						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
-						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
-						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
-						L0465_s_NextEvent._mapTime += 1;
+						curGroup->setBehaviour(k7_behavior_APPROACH);
+						activeGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
+						activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
+						nextEvent._mapTime += 1;
 						goto T0209134_SetEvent37;
 					}
 				} else {
 					if (AL0447_i_Behavior == k0_behavior_WANDER) {
-						L0454_i_PrimaryDirectionToOrFromParty = getSmelledPartyPrimaryDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY);
-						if (L0454_i_PrimaryDirectionToOrFromParty) {
-							L0454_i_PrimaryDirectionToOrFromParty--;
-							L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = false;
+						primaryDirectionToOrFromParty = getSmelledPartyPrimaryDirOrdinal(&creatureInfo, eventMapX, eventMapY);
+						if (primaryDirectionToOrFromParty) {
+							primaryDirectionToOrFromParty--;
+							allowMovementOverFakePitsAndFakeWalls = false;
 							goto T0209085_SingleSquareMove;
 						}
-						L0453_B_NewGroupDirectionFound = false;
+						newGroupDirectionFound = false;
 						if (_vm->getRandomNumber(2)) {
 T0209058_MoveInRandomDirection:
 							AL0446_i_Direction = _vm->getRandomNumber(4);
 							AL0447_i_ReferenceDirection = AL0446_i_Direction;
-							L0457_B_MoveToPriorLocation = false;
 							do {
 								AL0450_i_DestinationMapX = eventMapX;
 								AL0451_i_DestinationMapY = eventMapY;
 								AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
-								if (((L0445_ps_ActiveGroup->_priorMapX != AL0450_i_DestinationMapX) ||
-									(L0445_ps_ActiveGroup->_priorMapY != AL0451_i_DestinationMapY) ||
-									 (L0457_B_MoveToPriorLocation = !_vm->getRandomNumber(4))) /* 1/4 chance of moving back to the square that the creature comes from */
-									&& isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction, false)) {
+								if (((activeGroup->_priorMapX != AL0450_i_DestinationMapX) ||
+									(activeGroup->_priorMapY != AL0451_i_DestinationMapY) ||
+									 (moveToPriorLocation = !_vm->getRandomNumber(4))) /* 1/4 chance of moving back to the square that the creature comes from */
+									&& isMovementPossible(&creatureInfo, eventMapX, eventMapY, AL0446_i_Direction, false)) {
 T0209061_MoveGroup:
-									AL0447_i_Ticks = (L0461_i_MovementTicks >> 1) - L0462_i_TicksSinceLastMove;
-									L0453_B_NewGroupDirectionFound = (AL0447_i_Ticks <= 0);
-									if (L0453_B_NewGroupDirectionFound) {
-										if (_vm->_moveSens->getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
-											goto T0209139_Return;
-										L0465_s_NextEvent._B._location._mapX = _vm->_moveSens->_moveResultMapX;
-										L0465_s_NextEvent._B._location._mapY = _vm->_moveSens->_moveResultMapY;;
-										L0445_ps_ActiveGroup->_priorMapX = eventMapX;
-										L0445_ps_ActiveGroup->_priorMapY = eventMapY;
-										L0445_ps_ActiveGroup->_lastMoveTime = _vm->_gameTime;
+									AL0447_i_Ticks = (movementTicks >> 1) - ticksSinceLastMove;
+									newGroupDirectionFound = (AL0447_i_Ticks <= 0);
+									if (newGroupDirectionFound) {
+										if (_vm->_moveSens->getMoveResult(groupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY))
+											return;
+										nextEvent._B._location._mapX = _vm->_moveSens->_moveResultMapX;
+										nextEvent._B._location._mapY = _vm->_moveSens->_moveResultMapY;;
+										activeGroup->_priorMapX = eventMapX;
+										activeGroup->_priorMapY = eventMapY;
+										activeGroup->_lastMoveTime = _vm->_gameTime;
 									} else {
-										L0461_i_MovementTicks = AL0447_i_Ticks;
-										L0462_i_TicksSinceLastMove = -1;
+										movementTicks = AL0447_i_Ticks;
+										ticksSinceLastMove = -1;
 									}
 									break;
 								}
 								if (_groupMovementBlockedByParty) {
 									if ((eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) &&
-										((L0444_ps_Group->getBehaviour() != k5_behavior_FLEE) ||
-										 !getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false) ||
+										((curGroup->getBehaviour() != k5_behavior_FLEE) ||
+										 !getFirstPossibleMovementDirOrdinal(&creatureInfo, eventMapX, eventMapY, false) ||
 										 _vm->getRandomNumber(2)))
 										goto T0209044_SetBehavior6_Attack;
-									L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
-									L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
+									activeGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
+									activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
 								}
 							} while ((AL0446_i_Direction = returnNextVal(AL0446_i_Direction)) != AL0447_i_ReferenceDirection);
 						}
-						if (!L0453_B_NewGroupDirectionFound &&
-							(L0462_i_TicksSinceLastMove != -1) &&
-							L0463_B_Archenemy &&
+						if (!newGroupDirectionFound &&
+							(ticksSinceLastMove != -1) &&
+							isArchEnemy &&
 							((eventType == kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) || !_vm->getRandomNumber(4))) { /* BUG0_15 The game hangs when you close a door on Lord Chaos. A condition is missing in the code to manage creatures and this may create an infinite loop between two parts in the code */
-							_vm->_projexpl->_secondaryDirToOrFromParty = returnNextVal(L0454_i_PrimaryDirectionToOrFromParty = _vm->getRandomNumber(4));
+							_vm->_projexpl->_secondaryDirToOrFromParty = returnNextVal(primaryDirectionToOrFromParty = _vm->getRandomNumber(4));
 							goto T0209089_DoubleSquareMove; /* BUG0_69 Memory corruption when you close a door on Lord Chaos. The local variable (L0454_i_PrimaryDirectionToOrFromParty) containing the direction where Lord Chaos tries to move may be used as an array index without being initialized and cause memory corruption */
 						}
-						if (L0453_B_NewGroupDirectionFound || ((!_vm->getRandomNumber(4) || (L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.getSmellRange())) && (eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare))) {
+						if (newGroupDirectionFound || ((!_vm->getRandomNumber(4) || (distanceToVisibleParty <= creatureInfo.getSmellRange())) && (eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare))) {
 T0209073_SetDirectionGroup:
-							if (!L0453_B_NewGroupDirectionFound && (L0462_i_TicksSinceLastMove >= 0)) { /* If direction is not found yet then look around in a random direction */
+							if (!newGroupDirectionFound && (ticksSinceLastMove >= 0)) { /* If direction is not found yet then look around in a random direction */
 								AL0446_i_Direction = _vm->getRandomNumber(4);
 							}
-							setDirGroup(L0445_ps_ActiveGroup, AL0446_i_Direction, L0460_ui_CreatureCount, L0459_i_CreatureSize);
+							setDirGroup(activeGroup, AL0446_i_Direction, creatureCount, creatureSize);
 						}
 						/* If event is kM3_TMEventTypeCreateReactionEvent29DangerOnSquare or kM2_TMEventTypeCreateReactionEvent30HitByProjectile */
 						if (eventType < kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) {
-							if (!L0453_B_NewGroupDirectionFound)
-								goto T0209139_Return;
-							if (L0458_B_SetBehavior7_ApproachAfterReaction)
-								L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
+							if (!newGroupDirectionFound)
+								return;
+							if (approachAfterReaction)
+								curGroup->setBehaviour(k7_behavior_APPROACH);
 
-							stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+							stopAttacking(activeGroup, eventMapX, eventMapY);
 						}
 					}
 				}
 			} else {
 				if (AL0447_i_Behavior == k7_behavior_APPROACH) {
-					L0452_i_DistanceToVisibleParty = groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY);
-					if (L0452_i_DistanceToVisibleParty) {
-						if ((L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.getAttackRange()) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) /* If the creature is in range for attack and on the same row or column as the party on the map */
+					distanceToVisibleParty = groupGetDistanceToVisibleParty(curGroup, kM1_wholeCreatureGroup, eventMapX, eventMapY);
+					if (distanceToVisibleParty) {
+						if ((distanceToVisibleParty <= creatureInfo.getAttackRange()) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) /* If the creature is in range for attack and on the same row or column as the party on the map */
 							goto T0209044_SetBehavior6_Attack;
 T0209081_RunTowardParty:
-						L0461_i_MovementTicks++;
-						L0461_i_MovementTicks = L0461_i_MovementTicks >> 1; /* Running speed is half the movement ticks */
-						AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX);
-						AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY);
+						movementTicks++;
+						movementTicks = movementTicks >> 1; /* Running speed is half the movement ticks */
+						AL0450_i_TargetMapX = (activeGroup->_targetMapX = _vm->_dungeonMan->_partyMapX);
+						AL0451_i_TargetMapY = (activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY);
 					} else {
 T0209082_WalkTowardTarget:
-						AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_targetMapX;
-						AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY;
+						AL0450_i_TargetMapX = activeGroup->_targetMapX;
+						AL0451_i_TargetMapY = activeGroup->_targetMapY;
 						/* If the creature reached its target but the party is not there anymore */
 						if ((eventMapX == AL0450_i_TargetMapX) && (eventMapY == AL0451_i_TargetMapY)) {
-							L0453_B_NewGroupDirectionFound = false;
-							L0444_ps_Group->setBehaviour(k0_behavior_WANDER);
+							newGroupDirectionFound = false;
+							curGroup->setBehaviour(k0_behavior_WANDER);
 							goto T0209073_SetDirectionGroup;
 						}
 					}
-					L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true;
+					allowMovementOverFakePitsAndFakeWalls = true;
 T0209084_SingleSquareMoveTowardParty:
-					L0454_i_PrimaryDirectionToOrFromParty = getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY);
+					primaryDirectionToOrFromParty = getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY);
 T0209085_SingleSquareMove:
-					if (isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls) ||
-						isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_secondaryDirToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls && _vm->getRandomNumber(2)) ||
-						isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)AL0446_i_Direction), false) ||
-						(!_vm->getRandomNumber(4) && isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)L0454_i_PrimaryDirectionToOrFromParty), false))) {
+					if (isMovementPossible(&creatureInfo, eventMapX, eventMapY, AL0446_i_Direction = primaryDirectionToOrFromParty, allowMovementOverFakePitsAndFakeWalls) ||
+						isMovementPossible(&creatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_secondaryDirToOrFromParty, allowMovementOverFakePitsAndFakeWalls && _vm->getRandomNumber(2)) ||
+						isMovementPossible(&creatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)AL0446_i_Direction), false) ||
+						(!_vm->getRandomNumber(4) && isMovementPossible(&creatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)primaryDirectionToOrFromParty), false))) {
 						AL0450_i_DestinationMapX = eventMapX;
 						AL0451_i_DestinationMapY = eventMapY;
 						AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction];
 						goto T0209061_MoveGroup;
 					}
-					if (L0463_B_Archenemy) {
+					if (isArchEnemy) {
 T0209089_DoubleSquareMove:
-						getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false); /* BUG0_00 Useless code. Returned value is ignored. When Lord Chaos teleports two squares away the ability to move to the first square is ignored which means Lord Chaos can teleport through walls or any other obstacle */
-						if (isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty) ||
-							isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_secondaryDirToOrFromParty) ||
-							(_fluxCageCount && isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)AL0446_i_Direction))) ||
-							((_fluxCageCount >= 2) && isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)L0454_i_PrimaryDirectionToOrFromParty)))) {
+						getFirstPossibleMovementDirOrdinal(&creatureInfo, eventMapX, eventMapY, false); /* BUG0_00 Useless code. Returned value is ignored. When Lord Chaos teleports two squares away the ability to move to the first square is ignored which means Lord Chaos can teleport through walls or any other obstacle */
+						if (isArchenemyDoubleMovementPossible(&creatureInfo, eventMapX, eventMapY, AL0446_i_Direction = primaryDirectionToOrFromParty) ||
+							isArchenemyDoubleMovementPossible(&creatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_secondaryDirToOrFromParty) ||
+							(_fluxCageCount && isArchenemyDoubleMovementPossible(&creatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)AL0446_i_Direction))) ||
+							((_fluxCageCount >= 2) && isArchenemyDoubleMovementPossible(&creatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)primaryDirectionToOrFromParty)))) {
 							AL0450_i_DestinationMapX = eventMapX;
 							AL0451_i_DestinationMapY = eventMapY;
 							AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2;
@@ -902,167 +884,165 @@ T0209089_DoubleSquareMove:
 							goto T0209061_MoveGroup;
 						}
 					}
-					setDirGroup(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, L0460_ui_CreatureCount, L0459_i_CreatureSize);
+					setDirGroup(activeGroup, primaryDirectionToOrFromParty, creatureCount, creatureSize);
 				} else {
 					if (AL0447_i_Behavior == k5_behavior_FLEE) {
 T0209094_FleeFromTarget:
-						L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true;
+						allowMovementOverFakePitsAndFakeWalls = true;
 						/* If the creature can see the party then update target coordinates */
-						L0452_i_DistanceToVisibleParty = groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY);
-						if (L0452_i_DistanceToVisibleParty) {
-							AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX);
-							AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY);
+						distanceToVisibleParty = groupGetDistanceToVisibleParty(curGroup, kM1_wholeCreatureGroup, eventMapX, eventMapY);
+						if (distanceToVisibleParty) {
+							AL0450_i_TargetMapX = (activeGroup->_targetMapX = _vm->_dungeonMan->_partyMapX);
+							AL0451_i_TargetMapY = (activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY);
 						} else {
-							if (!(--(L0445_ps_ActiveGroup->_delayFleeingFromTarget))) { /* If the creature is not afraid anymore then stop fleeing from target */
+							if (!(--(activeGroup->_delayFleeingFromTarget))) { /* If the creature is not afraid anymore then stop fleeing from target */
 T0209096_SetBehavior0_Wander:
-								L0453_B_NewGroupDirectionFound = false;
-								L0444_ps_Group->setBehaviour(k0_behavior_WANDER);
+								newGroupDirectionFound = false;
+								curGroup->setBehaviour(k0_behavior_WANDER);
 								goto T0209073_SetDirectionGroup;
 							}
 							if (_vm->getRandomNumber(2)) {
 								/* If the creature cannot move and the party is adjacent then stop fleeing */
-								if (!getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false)) {
+								if (!getFirstPossibleMovementDirOrdinal(&creatureInfo, eventMapX, eventMapY, false)) {
 									if (getDistance(eventMapX, eventMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY) <= 1)
 										goto T0209096_SetBehavior0_Wander;
 								}
 								/* Set creature target to the home square where the creature was located when the party entered the map */
-								AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_homeMapX;
-								AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_homeMapY;
+								AL0450_i_TargetMapX = activeGroup->_homeMapX;
+								AL0451_i_TargetMapY = activeGroup->_homeMapY;
 								goto T0209084_SingleSquareMoveTowardParty;
 							}
-							AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_targetMapX;
-							AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY;
+							AL0450_i_TargetMapX = activeGroup->_targetMapX;
+							AL0451_i_TargetMapY = activeGroup->_targetMapY;
 						}
 						/* Try and flee from the party (opposite direction) */
-						L0454_i_PrimaryDirectionToOrFromParty = returnOppositeDir((Direction)getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY));
+						primaryDirectionToOrFromParty = returnOppositeDir((Direction)getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY));
 						_vm->_projexpl->_secondaryDirToOrFromParty = returnOppositeDir((Direction)_vm->_projexpl->_secondaryDirToOrFromParty);
-						L0461_i_MovementTicks -= (L0461_i_MovementTicks >> 2);
+						movementTicks -= (movementTicks >> 2);
 						goto T0209085_SingleSquareMove;
 					}
 				}
 			}
 		} else { /* Process events 38 to 41, Update Creature Behavior */
 			if (AL0447_i_Behavior == k5_behavior_FLEE) {
-				if (L0460_ui_CreatureCount) {
-					stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+				if (creatureCount) {
+					stopAttacking(activeGroup, eventMapX, eventMapY);
 				}
 				goto T0209094_FleeFromTarget;
 			}
 			/* If the creature is attacking, then compute the next aspect update time and the next attack time */
-			if (getFlag(L0445_ps_ActiveGroup->_aspect[AL0447_i_CreatureIndex = eventType - k38_TMEventTypeUpdateBehaviour_0], k0x0080_MaskActiveGroupIsAttacking)) {
-				L0464_l_NextAspectUpdateTime = getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false);
-				L0465_s_NextEvent._mapTime += ((AL0447_i_Ticks = L0448_s_CreatureInfo._attackTicks) + _vm->getRandomNumber(4) - 1);
+			if (getFlag(activeGroup->_aspect[AL0447_i_CreatureIndex = eventType - k38_TMEventTypeUpdateBehaviour_0], k0x0080_MaskActiveGroupIsAttacking)) {
+				nextAspectUpdateTime = getCreatureAspectUpdateTime(activeGroup, AL0447_i_CreatureIndex, false);
+				nextEvent._mapTime += ((AL0447_i_Ticks = creatureInfo._attackTicks) + _vm->getRandomNumber(4) - 1);
 				if (AL0447_i_Ticks > 15)
-					L0465_s_NextEvent._mapTime += _vm->getRandomNumber(8) - 2;
+					nextEvent._mapTime += _vm->getRandomNumber(8) - 2;
 			} else { /* If the creature is not attacking, then try attacking if possible */
-				if (AL0447_i_CreatureIndex > L0460_ui_CreatureCount) /* Ignore event if it is for a creature that is not in the group */
-					goto T0209139_Return;
+				if (AL0447_i_CreatureIndex > creatureCount) /* Ignore event if it is for a creature that is not in the group */
+					return;
 
-				L0454_i_PrimaryDirectionToOrFromParty = _currGroupPrimaryDirToParty;
-				L0452_i_DistanceToVisibleParty = groupGetDistanceToVisibleParty(L0444_ps_Group, AL0447_i_CreatureIndex, eventMapX, eventMapY);
+				primaryDirectionToOrFromParty = _currGroupPrimaryDirToParty;
+				distanceToVisibleParty = groupGetDistanceToVisibleParty(curGroup, AL0447_i_CreatureIndex, eventMapX, eventMapY);
 				/* If the party is visible, update the target coordinates */
-				if (L0452_i_DistanceToVisibleParty) {
-					L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
-					L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
+				if (distanceToVisibleParty) {
+					activeGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
+					activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
 				}
 				/* If there is a single creature in the group that is not full square sized and 1/4 chance */
-				if (!L0460_ui_CreatureCount && (L0459_i_CreatureSize != k2_MaskCreatureSizeFull) && !((AL0446_i_GroupCellsCriteria = _vm->getRandomNumber(65536)) & 0x00C0)) {
-					if (L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) {
+				if (!creatureCount && (creatureSize != k2_MaskCreatureSizeFull) && !((AL0446_i_GroupCellsCriteria = _vm->getRandomNumber(65536)) & 0x00C0)) {
+					if (activeGroup->_cells != k255_CreatureTypeSingleCenteredCreature) {
 						/* If the creature is not already on the center of the square then change its cell */
 						if (AL0446_i_GroupCellsCriteria & 0x0038) { /* 7/8 chances of changing cell to the center of the square */
-							L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature;
+							activeGroup->_cells = k255_CreatureTypeSingleCenteredCreature;
 						} else { /* 1/8 chance of changing cell to the next or previous cell on the square */
-							AL0446_i_GroupCellsCriteria = normalizeModulo4(normalizeModulo4(L0445_ps_ActiveGroup->_cells) + ((AL0446_i_GroupCellsCriteria & 0x0001) ? 1 : -1));
+							AL0446_i_GroupCellsCriteria = normalizeModulo4(normalizeModulo4(activeGroup->_cells) + ((AL0446_i_GroupCellsCriteria & 0x0001) ? 1 : -1));
 						}
 					}
 					/* If 1/8 chance and the creature is not adjacent to the party and is a quarter square sized creature then process projectile impacts and update the creature cell if still alive. When the creature is not in front of the party, it has 7/8 chances of dodging a projectile by moving to another cell or staying in the center of the square */
-					if (!(AL0446_i_GroupCellsCriteria & 0x0038) && (L0452_i_DistanceToVisibleParty != 1) && (L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter)) {
-						if (_vm->_projexpl->projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* This call to F0218_PROJECTILE_GetImpactCount works fine because there is a single creature in the group so L0445_ps_ActiveGroup->Cells contains only one cell index */
-							goto T0209139_Return;
-						L0445_ps_ActiveGroup->_cells = normalizeModulo4(AL0446_i_GroupCellsCriteria);
+					if (!(AL0446_i_GroupCellsCriteria & 0x0038) && (distanceToVisibleParty != 1) && (creatureSize == k0_MaskCreatureSizeQuarter)) {
+						if (_vm->_projexpl->projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, activeGroup->_cells) && (_vm->_projexpl->_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* This call to F0218_PROJECTILE_GetImpactCount works fine because there is a single creature in the group so L0445_ps_ActiveGroup->Cells contains only one cell index */
+							return;
+						activeGroup->_cells = normalizeModulo4(AL0446_i_GroupCellsCriteria);
 					}
 				}
 				/* If the creature can see the party and is looking in the party direction or can attack in all direction */
-				if (L0452_i_DistanceToVisibleParty &&
-					(getFlag(L0448_s_CreatureInfo._attributes, k0x0004_MaskCreatureInfo_sideAttack) ||
-					 getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) == L0454_i_PrimaryDirectionToOrFromParty)) {
+				if (distanceToVisibleParty &&
+					(getFlag(creatureInfo._attributes, k0x0004_MaskCreatureInfo_sideAttack) ||
+					 getCreatureValue(activeGroup->_directions, AL0447_i_CreatureIndex) == primaryDirectionToOrFromParty)) {
 					/* If the creature is in range to attack the party and random test succeeds */
-					if ((L0452_i_DistanceToVisibleParty <= (AL0446_i_Range = L0448_s_CreatureInfo.getAttackRange())) &&
+					if ((distanceToVisibleParty <= (AL0446_i_Range = creatureInfo.getAttackRange())) &&
 						(!AL0450_i_DistanceXToParty || !AL0451_i_DistanceYToParty) &&
 						(AL0446_i_Range <= (_vm->getRandomNumber(16) + 1))) {
 						if ((AL0446_i_Range == 1) &&
-							(!getFlag(AL0446_i_CreatureAttributes = L0448_s_CreatureInfo._attributes, k0x0008_MaskCreatureInfo_preferBackRow) || !_vm->getRandomNumber(4) || !getFlag(AL0446_i_CreatureAttributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) &&
-							(L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter) &&
-							(L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) &&
-							((AL0446_i_Cell = getCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex)) != L0454_i_PrimaryDirectionToOrFromParty) &&
-							(AL0446_i_Cell != returnNextVal(L0454_i_PrimaryDirectionToOrFromParty))) { /* If the creature cannot cast spells (range = 1) and is not on a cell where it can attack the party directly and is a quarter square sized creature not in the center of the square then the creature moves to another cell and attack does not occur immediately */
-							if (!L0460_ui_CreatureCount && _vm->getRandomNumber(2)) {
-								L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature;
+							(!getFlag(AL0446_i_CreatureAttributes = creatureInfo._attributes, k0x0008_MaskCreatureInfo_preferBackRow) || !_vm->getRandomNumber(4) || !getFlag(AL0446_i_CreatureAttributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) &&
+							(creatureSize == k0_MaskCreatureSizeQuarter) &&
+							(activeGroup->_cells != k255_CreatureTypeSingleCenteredCreature) &&
+							((AL0446_i_Cell = getCreatureValue(activeGroup->_cells, AL0447_i_CreatureIndex)) != primaryDirectionToOrFromParty) &&
+							(AL0446_i_Cell != returnNextVal(primaryDirectionToOrFromParty))) { /* If the creature cannot cast spells (range = 1) and is not on a cell where it can attack the party directly and is a quarter square sized creature not in the center of the square then the creature moves to another cell and attack does not occur immediately */
+							if (!creatureCount && _vm->getRandomNumber(2)) {
+								activeGroup->_cells = k255_CreatureTypeSingleCenteredCreature;
 							} else {
-								if ((L0454_i_PrimaryDirectionToOrFromParty & 0x0001) == (AL0446_i_Cell & 0x0001)) {
+								if ((primaryDirectionToOrFromParty & 0x0001) == (AL0446_i_Cell & 0x0001)) {
 									AL0446_i_Cell--;
 								} else {
 									AL0446_i_Cell++;
 								}
-								if (!getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = normalizeModulo4(AL0446_i_Cell)) ||
-									(_vm->getRandomNumber(2) && !getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((Direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */
-									if (_vm->_projexpl->projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* BUG0_70 A projectile impact on a creature may be ignored. The function F0218_PROJECTILE_GetImpactCount to detect projectile impacts when a quarter square sized creature moves inside a group (to another cell on the same square) may fail if there are several creatures in the group because the function expects a single cell index for its last parameter. The function should be called once for each cell where there is a creature */
-										goto T0209139_Return;
+								if (!getCreatureOrdinalInCell(curGroup, AL0446_i_Cell = normalizeModulo4(AL0446_i_Cell)) ||
+									(_vm->getRandomNumber(2) && !getCreatureOrdinalInCell(curGroup, AL0446_i_Cell = returnOppositeDir((Direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */
+									if (_vm->_projexpl->projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, activeGroup->_cells) && (_vm->_projexpl->_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* BUG0_70 A projectile impact on a creature may be ignored. The function F0218_PROJECTILE_GetImpactCount to detect projectile impacts when a quarter square sized creature moves inside a group (to another cell on the same square) may fail if there are several creatures in the group because the function expects a single cell index for its last parameter. The function should be called once for each cell where there is a creature */
+										return;
 									if (_vm->_projexpl->_creatureDamageOutcome != k1_outcomeKilledSomeCreaturesInGroup) {
-										L0445_ps_ActiveGroup->_cells = getGroupValueUpdatedWithCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex, AL0446_i_Cell);
+										activeGroup->_cells = getGroupValueUpdatedWithCreatureValue(activeGroup->_cells, AL0447_i_CreatureIndex, AL0446_i_Cell);
 									}
 								}
 							}
-							L0465_s_NextEvent._mapTime += MAX(1, (L0448_s_CreatureInfo._movementTicks >> 1) + _vm->getRandomNumber(2)); /* Time for the creature to change cell */
-							L0465_s_NextEvent._type = eventType;
+							nextEvent._mapTime += MAX(1, (creatureInfo._movementTicks >> 1) + _vm->getRandomNumber(2)); /* Time for the creature to change cell */
+							nextEvent._type = eventType;
 							goto T0209135;
 						}
-						L0464_l_NextAspectUpdateTime = getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, isCreatureAttacking(L0444_ps_Group, eventMapX, eventMapY, AL0447_i_CreatureIndex));
-						L0465_s_NextEvent._mapTime += (L0448_s_CreatureInfo._animationTicks & 0xF) + _vm->getRandomNumber(2);
+						nextAspectUpdateTime = getCreatureAspectUpdateTime(activeGroup, AL0447_i_CreatureIndex, isCreatureAttacking(curGroup, eventMapX, eventMapY, AL0447_i_CreatureIndex));
+						nextEvent._mapTime += (creatureInfo._animationTicks & 0xF) + _vm->getRandomNumber(2);
 					} else {
-						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
-						if (L0460_ui_CreatureCount) {
-							stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+						curGroup->setBehaviour(k7_behavior_APPROACH);
+						if (creatureCount) {
+							stopAttacking(activeGroup, eventMapX, eventMapY);
 						}
 						goto T0209081_RunTowardParty;
 					}
 				} else {
 					/* If the party is visible, update target coordinates */
-					if (groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
-						L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
-						L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
-						setGroupDirection(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf));
-						L0465_s_NextEvent._mapTime += 2;
-						L0464_l_NextAspectUpdateTime = filterTime(L0465_s_NextEvent._mapTime);
+					if (groupGetDistanceToVisibleParty(curGroup, kM1_wholeCreatureGroup, eventMapX, eventMapY)) {
+						activeGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
+						activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
+						setGroupDirection(activeGroup, primaryDirectionToOrFromParty, AL0447_i_CreatureIndex, creatureCount && (creatureSize == k1_MaskCreatureSizeHalf));
+						nextEvent._mapTime += 2;
+						nextAspectUpdateTime = filterTime(nextEvent._mapTime);
 					} else { /* If the party is not visible, move to the target (last known party location) */
-						L0444_ps_Group->setBehaviour(k7_behavior_APPROACH);
-						if (L0460_ui_CreatureCount) {
-							stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY);
+						curGroup->setBehaviour(k7_behavior_APPROACH);
+						if (creatureCount) {
+							stopAttacking(activeGroup, eventMapX, eventMapY);
 						}
 						goto T0209082_WalkTowardTarget;
 					}
 				}
 			}
-			L0465_s_NextEvent._type = eventType;
+			nextEvent._type = eventType;
 			goto T0209136;
 		}
-		L0465_s_NextEvent._mapTime += MAX(1, _vm->getRandomNumber(4) + L0461_i_MovementTicks - 1);
+		nextEvent._mapTime += MAX(1, _vm->getRandomNumber(4) + movementTicks - 1);
 T0209134_SetEvent37:
-		L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup;
+		nextEvent._type = k37_TMEventTypeUpdateBehaviourGroup;
 	}
 T0209135:
-	if (!L0464_l_NextAspectUpdateTime) {
-		L0464_l_NextAspectUpdateTime = getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, kM1_wholeCreatureGroup, false);
+	if (!nextAspectUpdateTime) {
+		nextAspectUpdateTime = getCreatureAspectUpdateTime(activeGroup, kM1_wholeCreatureGroup, false);
 	}
 T0209136:
-	if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) {
-		L0465_s_NextEvent._mapTime += ticks;
+	if (notUpdateBehaviorFl) {
+		nextEvent._mapTime += ticks;
 	} else {
-		L0464_l_NextAspectUpdateTime += ticks;
+		nextAspectUpdateTime += ticks;
 	}
-	addGroupEvent(&L0465_s_NextEvent, L0464_l_NextAspectUpdateTime);
-T0209139_Return:
-	;
+	addGroupEvent(&nextEvent, nextAspectUpdateTime);
 }
 
 bool GroupMan::isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, int16 mapY, uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls) {
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 6627826..5d67d0a 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -197,7 +197,7 @@ public:
 											 int16 mapX, int16 mapY, int16 damage, bool notMoving); // @ F0190_GROUP_GetDamageCreatureOutcome
 	void groupDelete(int16 mapX, int16 mapY); // @ F0189_GROUP_Delete
 	void groupDeleteEvents(int16 mapX, int16 mapY); // @ F0181_GROUP_DeleteEvents
-	uint16 getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatreVal); // @ F0178_GROUP_GetGroupValueUpdatedWithCreatureValue
+	uint16 getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatureVal); // @ F0178_GROUP_GetGroupValueUpdatedWithCreatureValue
 	int16 getDamageAllCreaturesOutcome(Group *group, int16 mapX, int16 mapY, int16 attack, bool notMoving); // @ F0191_GROUP_GetDamageAllCreaturesOutcome
 	int16 groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack); // @ F0192_GROUP_GetResistanceAdjustedPoisonAttack
 	void processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks); // @ F0209_GROUP_ProcessEvents29to41


Commit: adf3931e4048bc4a59b49d697e2474e026a7113d
    https://github.com/scummvm/scummvm/commit/adf3931e4048bc4a59b49d697e2474e026a7113d
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-29T07:50:41+02:00

Commit Message:
DM: Renaming in isMovementPossible and groupGetDistanceToVisibleParty, rewrite getDistanceBetweenSquares

Changed paths:
    engines/dm/group.cpp



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index eada054..79e685b 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -550,7 +550,7 @@ int16 GroupMan::groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16
 }
 
 void GroupMan::processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks) {
-	int16 L0446_i_Multiple;
+	int16 L0446_i_Multiple = 0;
 #define AL0446_i_Direction           L0446_i_Multiple
 #define AL0446_i_Ticks               L0446_i_Multiple
 #define AL0446_i_Behavior2Or3        L0446_i_Multiple
@@ -645,8 +645,12 @@ T0209005_AddEventAndReturn:
 	For event kM2_TMEventTypeCreateReactionEvent30HitByProjectile and kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, the reaction time may be 1 tick or slower: slow moving creatures react more slowly. The more recent is the last creature move, the slower the reaction */
 	if (eventType < 0) {
 		nextEvent._type = eventType + k32_TMEventTypeUpdateAspectGroup;
-		if ((eventType == kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) || ((AL0446_i_Ticks = ((movementTicks + 2) >> 2) - ticksSinceLastMove) < 1)) { /* AL0446_i_Ticks is the reaction time */
+		if (eventType == kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) {
 			AL0446_i_Ticks = 1; /* Retry in 1 tick */
+		} else {
+			 AL0446_i_Ticks = ((movementTicks + 2) >> 2) - ticksSinceLastMove;
+			 if (AL0446_i_Ticks < 1) /* AL0446_i_Ticks is the reaction time */
+				 AL0446_i_Ticks = 1; /* Retry in 1 tick */
 		}
 		goto T0209005_AddEventAndReturn; /* BUG0_68 A group moves or acts with a wrong timing. Event is added but L0465_s_NextEvent.C.Ticks has not been initialized */
 	}
@@ -682,7 +686,8 @@ T0209005_AddEventAndReturn:
 		case kM2_TMEventTypeCreateReactionEvent30HitByProjectile: /* This event is used for the reaction of a group after a projectile impacted with one creature in the group (some creatures may have been killed) */
 			if ((AL0447_i_Behavior == k6_behavior_ATTACK) || (AL0447_i_Behavior == k5_behavior_FLEE)) /* If the creature is attacking the party or fleeing from the target then there is no reaction */
 				return;
-			if ((AL0446_i_Behavior2Or3 = ((AL0447_i_Behavior == k3_behavior_USELESS) || (AL0447_i_Behavior == k2_behavior_USELESS))) || (_vm->getRandomNumber(4))) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances */
+			AL0446_i_Behavior2Or3 = ((AL0447_i_Behavior == k3_behavior_USELESS) || (AL0447_i_Behavior == k2_behavior_USELESS));
+			if (AL0446_i_Behavior2Or3 || (_vm->getRandomNumber(4))) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances */
 				if (!groupGetDistanceToVisibleParty(curGroup, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { /* If the group cannot see the party then look in a random direction to try and search for the party */
 					approachAfterReaction = newGroupDirectionFound = false;
 					goto T0209073_SetDirectionGroup;
@@ -808,7 +813,8 @@ T0209061_MoveGroup:
 									activeGroup->_targetMapX = _vm->_dungeonMan->_partyMapX;
 									activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY;
 								}
-							} while ((AL0446_i_Direction = returnNextVal(AL0446_i_Direction)) != AL0447_i_ReferenceDirection);
+								AL0446_i_Direction = returnNextVal(AL0446_i_Direction);
+							} while (AL0446_i_Direction != AL0447_i_ReferenceDirection);
 						}
 						if (!newGroupDirectionFound &&
 							(ticksSinceLastMove != -1) &&
@@ -1046,123 +1052,109 @@ T0209136:
 }
 
 bool GroupMan::isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, int16 mapY, uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls) {
-	int16 L0428_i_MapX;
-	int16 L0429_i_MapY;
-	uint16 L0430_ui_Square = 0;
-	int16 L0431_i_SquareType = 0;
-	Teleporter *L0432_ps_Teleporter;
-	Thing L0433_T_Thing;
-
 	_groupMovementTestedDirections[dir] = true;
 	_groupMovementBlockedByGroupThing = Thing::_endOfList;
 	_groupMovementBlockedByDoor = false;
 	_groupMovementBlockedByParty = false;
-	if (creatureInfo->_movementTicks == k255_immobile) {
+	if (creatureInfo->_movementTicks == k255_immobile)
 		return false;
-	}
+
 	_vm->_dungeonMan->mapCoordsAfterRelMovement((Direction)dir, 1, 0, mapX, mapY);
-	L0428_i_MapX = mapX;
-	L0429_i_MapY = mapY;
-	L0430_ui_Square = _vm->_dungeonMan->_currMapData[L0428_i_MapX][L0429_i_MapY];
-	L0431_i_SquareType = Square(L0430_ui_Square).getType();
+	uint16 curSquare = _vm->_dungeonMan->_currMapData[mapX][mapY];
+	int16 curSquareType = Square(curSquare).getType();
 	_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter =
-		!(((L0428_i_MapX >= 0) && (L0428_i_MapX < _vm->_dungeonMan->_currMapWidth)) &&
-		 ((L0429_i_MapY >= 0) && (L0429_i_MapY < _vm->_dungeonMan->_currMapHeight)) &&
-		  (L0431_i_SquareType != k0_ElementTypeWall) &&
-		  (L0431_i_SquareType != k3_ElementTypeStairs) &&
-		 ((L0431_i_SquareType != k2_ElementTypePit) || (getFlag(L0430_ui_Square, k0x0001_PitImaginary) && allowMovementOverImaginaryPitsAndFakeWalls) || !getFlag(L0430_ui_Square, k0x0008_PitOpen) || getFlag(creatureInfo->_attributes, k0x0020_MaskCreatureInfo_levitation)) &&
-		 ((L0431_i_SquareType != k6_ElementTypeFakeWall) || getFlag(L0430_ui_Square, k0x0004_FakeWallOpen) || (getFlag(L0430_ui_Square, k0x0001_FakeWallImaginary) && allowMovementOverImaginaryPitsAndFakeWalls)));
+		!(((mapX >= 0) && (mapX < _vm->_dungeonMan->_currMapWidth)) &&
+		 ((mapY >= 0) && (mapY < _vm->_dungeonMan->_currMapHeight)) &&
+		  (curSquareType != k0_ElementTypeWall) &&
+		  (curSquareType != k3_ElementTypeStairs) &&
+		 ((curSquareType != k2_ElementTypePit) || (getFlag(curSquare, k0x0001_PitImaginary) && allowMovementOverImaginaryPitsAndFakeWalls) || !getFlag(curSquare, k0x0008_PitOpen) || getFlag(creatureInfo->_attributes, k0x0020_MaskCreatureInfo_levitation)) &&
+		 ((curSquareType != k6_ElementTypeFakeWall) || getFlag(curSquare, k0x0004_FakeWallOpen) || (getFlag(curSquare, k0x0001_FakeWallImaginary) && allowMovementOverImaginaryPitsAndFakeWalls)));
 
 	if (_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter)
 		return false;
 
 	if (getFlag(creatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) {
-		L0433_T_Thing = _vm->_dungeonMan->getSquareFirstThing(L0428_i_MapX, L0429_i_MapY);
-		while (L0433_T_Thing != Thing::_endOfList) {
-			if ((L0433_T_Thing).getType() == k15_ExplosionThingType) {
-				L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(L0433_T_Thing);
-				if (((Explosion *)L0432_ps_Teleporter)->setType(k50_ExplosionType_Fluxcage)) {
+		Thing curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+		while (curThing != Thing::_endOfList) {
+			if ((curThing).getType() == k15_ExplosionThingType) {
+				Teleporter *curTeleporter = (Teleporter *)_vm->_dungeonMan->getThingData(curThing);
+				if (((Explosion *)curTeleporter)->setType(k50_ExplosionType_Fluxcage)) {
 					_fluxCages[dir] = true;
 					_fluxCageCount++;
 					_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
 					return false;
 				}
 			}
-			L0433_T_Thing = _vm->_dungeonMan->getNextThing(L0433_T_Thing);
+			curThing = _vm->_dungeonMan->getNextThing(curThing);
 		}
 	}
-	if ((L0431_i_SquareType == k5_ElementTypeTeleporter) && getFlag(L0430_ui_Square, k0x0008_TeleporterOpen) && (creatureInfo->getWariness() >= 10)) {
-		L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
-		if (getFlag(L0432_ps_Teleporter->getScope(), k0x0001_TelepScopeCreatures) && !_vm->_dungeonMan->isCreatureAllowedOnMap(_currGroupThing, L0432_ps_Teleporter->getTargetMapIndex())) {
+	if ((curSquareType == k5_ElementTypeTeleporter) && getFlag(curSquare, k0x0008_TeleporterOpen) && (creatureInfo->getWariness() >= 10)) {
+		Teleporter *curTeleporter = (Teleporter *)_vm->_dungeonMan->getSquareFirstThingData(mapX, mapY);
+		if (getFlag(curTeleporter->getScope(), k0x0001_TelepScopeCreatures) && !_vm->_dungeonMan->isCreatureAllowedOnMap(_currGroupThing, curTeleporter->getTargetMapIndex())) {
 			_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true;
 			return false;
 		}
 	}
 
-	_groupMovementBlockedByParty = (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0428_i_MapX == _vm->_dungeonMan->_partyMapX) && (L0429_i_MapY == _vm->_dungeonMan->_partyMapY);
+	_groupMovementBlockedByParty = (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY);
 	if (_groupMovementBlockedByParty)
 		return false;
 
-	if (L0431_i_SquareType == k4_DoorElemType) {
-		L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY);
-		if (((Square(L0430_ui_Square).getDoorState()) > (((Door *)L0432_ps_Teleporter)->opensVertically() ? CreatureInfo::getHeight(creatureInfo->_attributes) : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
+	if (curSquareType == k4_DoorElemType) {
+		Teleporter *curTeleporter = (Teleporter *)_vm->_dungeonMan->getSquareFirstThingData(mapX, mapY);
+		if (((Square(curSquare).getDoorState()) > (((Door *)curTeleporter)->opensVertically() ? CreatureInfo::getHeight(creatureInfo->_attributes) : 1)) && ((Square(curSquare).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
 			_groupMovementBlockedByDoor = true;
 			return false;
 		}
 	}
-	return (_groupMovementBlockedByGroupThing = groupGetThing(L0428_i_MapX, L0429_i_MapY)) == Thing::_endOfList;
+
+	_groupMovementBlockedByGroupThing = groupGetThing(mapX, mapY);
+	return (_groupMovementBlockedByGroupThing == Thing::_endOfList);
 }
 
 int16 GroupMan::getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) {
-	return ((((srcMapX -= destMapX) < 0) ? -srcMapX : srcMapX) +
-		(((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY));
+	return ABS(srcMapX - destMapX) + ABS(srcMapY - destMapY);
 }
 
 int16 GroupMan::groupGetDistanceToVisibleParty(Group *group, int16 creatureIndex, int16 mapX, int16 mapY) {
-	int16 L0420_i_CreatureDirection;
-	int16 L0421_i_CreatureViewDirectionCount; /* Count of directions to test in L0425_ai_CreatureViewDirections */
-	int16 L0422_i_Multiple;
-#define AL0422_i_Counter    L0422_i_Multiple
-#define AL0422_i_SightRange L0422_i_Multiple
-	uint16 L0423_ui_GroupDirections;
-	CreatureInfo *L0424_ps_CreatureInfo;
-	int16 L0425_ai_CreatureViewDirections[4]; /* List of directions to test */
-
-
-	L0424_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type];
-	if (_vm->_championMan->_party._event71Count_Invisibility && !getFlag(L0424_ps_CreatureInfo->_attributes, k0x0800_MaskCreatureInfo_seeInvisible)) {
+	uint16 groupDirections;
+	CreatureInfo *groupCreatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type];
+	if (_vm->_championMan->_party._event71Count_Invisibility && !getFlag(groupCreatureInfo->_attributes, k0x0800_MaskCreatureInfo_seeInvisible)) {
 		return 0;
 	}
-	if (getFlag(L0424_ps_CreatureInfo->_attributes, k0x0004_MaskCreatureInfo_sideAttack)) /* If creature can see in all directions */
+
+	if (getFlag(groupCreatureInfo->_attributes, k0x0004_MaskCreatureInfo_sideAttack)) /* If creature can see in all directions */
 		goto T0200011;
-	L0423_ui_GroupDirections = _activeGroups[group->getActiveGroupIndex()]._directions;
+	groupDirections = _activeGroups[group->getActiveGroupIndex()]._directions;
+	int16 checkDirectionsCount; /* Count of directions to test in L0425_ai_CreatureViewDirections */
+	int16 creatureViewDirections[4]; /* List of directions to test */
 	if (creatureIndex < 0) { /* Negative index means test if each creature in the group can see the party in their respective direction */
-		L0421_i_CreatureViewDirectionCount = 0;
+		checkDirectionsCount = 0;
 		for (creatureIndex = group->getCount(); creatureIndex >= 0; creatureIndex--) {
-			L0420_i_CreatureDirection = normalizeModulo4(L0423_ui_GroupDirections >> (creatureIndex << 1));
-			AL0422_i_Counter = L0421_i_CreatureViewDirectionCount;
-			while (AL0422_i_Counter--) {
-				if (L0425_ai_CreatureViewDirections[AL0422_i_Counter] == L0420_i_CreatureDirection) /* If the creature looks in the same direction as another one in the group */
+			int16 L0420_i_CreatureDirection = normalizeModulo4(groupDirections >> (creatureIndex << 1));
+			int16 counter = checkDirectionsCount;
+			while (counter--) {
+				if (creatureViewDirections[counter] == L0420_i_CreatureDirection) /* If the creature looks in the same direction as another one in the group */
 					goto T0200006;
 			}
-			L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount++] = L0420_i_CreatureDirection;
+			creatureViewDirections[checkDirectionsCount++] = L0420_i_CreatureDirection;
 T0200006:
 			;
 		}
 	} else { /* Positive index means test only if the specified creature in the group can see the party in its direction */
-		L0425_ai_CreatureViewDirections[0] = getCreatureValue(L0423_ui_GroupDirections, creatureIndex);
-		L0421_i_CreatureViewDirectionCount = 1;
+		creatureViewDirections[0] = getCreatureValue(groupDirections, creatureIndex);
+		checkDirectionsCount = 1;
 	}
-	while (L0421_i_CreatureViewDirectionCount--) {
-		if (isDestVisibleFromSource(L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount], mapX, mapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY)) {
+	while (checkDirectionsCount--) {
+		if (isDestVisibleFromSource(creatureViewDirections[checkDirectionsCount], mapX, mapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY)) {
 T0200011:
-			AL0422_i_SightRange = L0424_ps_CreatureInfo->getSightRange();
-			if (!getFlag(L0424_ps_CreatureInfo->_attributes, k0x1000_MaskCreatureInfo_nightVision)) {
-				AL0422_i_SightRange -= _vm->_displayMan->_dungeonViewPaletteIndex >> 1;
-			}
-			if (_currGroupDistanceToParty > MAX((int16)1, AL0422_i_SightRange)) {
+			int16 sightRange = groupCreatureInfo->getSightRange();
+			if (!getFlag(groupCreatureInfo->_attributes, k0x1000_MaskCreatureInfo_nightVision))
+				sightRange -= _vm->_displayMan->_dungeonViewPaletteIndex >> 1;
+
+			if (_currGroupDistanceToParty > MAX<int16>(1, sightRange))
 				return 0;
-			}
+
 			return getDistanceBetweenUnblockedSquares(mapX, mapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, &GroupMan::isViewPartyBlocked);
 		}
 	}


Commit: 150a16cd49b7bb5c19893c1805147d6cc4553fe7
    https://github.com/scummvm/scummvm/commit/150a16cd49b7bb5c19893c1805147d6cc4553fe7
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-29T19:52:54+02:00

Commit Message:
DM: Refactor getDistanceBetweenSquares, get rid of GOTOs

Changed paths:
    engines/dm/group.cpp



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 79e685b..5bf545c 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1119,35 +1119,41 @@ int16 GroupMan::getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 de
 int16 GroupMan::groupGetDistanceToVisibleParty(Group *group, int16 creatureIndex, int16 mapX, int16 mapY) {
 	uint16 groupDirections;
 	CreatureInfo *groupCreatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type];
-	if (_vm->_championMan->_party._event71Count_Invisibility && !getFlag(groupCreatureInfo->_attributes, k0x0800_MaskCreatureInfo_seeInvisible)) {
+	if (_vm->_championMan->_party._event71Count_Invisibility && !getFlag(groupCreatureInfo->_attributes, k0x0800_MaskCreatureInfo_seeInvisible))
 		return 0;
-	}
 
-	if (getFlag(groupCreatureInfo->_attributes, k0x0004_MaskCreatureInfo_sideAttack)) /* If creature can see in all directions */
-		goto T0200011;
-	groupDirections = _activeGroups[group->getActiveGroupIndex()]._directions;
+	bool alwaysSee = false;
 	int16 checkDirectionsCount; /* Count of directions to test in L0425_ai_CreatureViewDirections */
 	int16 creatureViewDirections[4]; /* List of directions to test */
-	if (creatureIndex < 0) { /* Negative index means test if each creature in the group can see the party in their respective direction */
-		checkDirectionsCount = 0;
-		for (creatureIndex = group->getCount(); creatureIndex >= 0; creatureIndex--) {
-			int16 L0420_i_CreatureDirection = normalizeModulo4(groupDirections >> (creatureIndex << 1));
-			int16 counter = checkDirectionsCount;
-			while (counter--) {
-				if (creatureViewDirections[counter] == L0420_i_CreatureDirection) /* If the creature looks in the same direction as another one in the group */
-					goto T0200006;
+	if (getFlag(groupCreatureInfo->_attributes, k0x0004_MaskCreatureInfo_sideAttack)) { /* If creature can see in all directions */
+		alwaysSee = true;
+		checkDirectionsCount = 1;
+		creatureViewDirections[0] = kDirNorth;
+	} else {
+		groupDirections = _activeGroups[group->getActiveGroupIndex()]._directions;
+		if (creatureIndex < 0) { /* Negative index means test if each creature in the group can see the party in their respective direction */
+			checkDirectionsCount = 0;
+			for (creatureIndex = group->getCount(); creatureIndex >= 0; creatureIndex--) {
+				int16 creatureDirection = normalizeModulo4(groupDirections >> (creatureIndex << 1));
+				int16 counter = checkDirectionsCount;
+				bool skipSet = false;
+				while (counter--) {
+					if (creatureViewDirections[counter] == creatureDirection) { /* If the creature looks in the same direction as another one in the group */
+						skipSet = true;
+						break;
+					}
+				}
+				if (!skipSet)
+					creatureViewDirections[checkDirectionsCount++] = creatureDirection;
 			}
-			creatureViewDirections[checkDirectionsCount++] = L0420_i_CreatureDirection;
-T0200006:
-			;
+		} else { /* Positive index means test only if the specified creature in the group can see the party in its direction */
+			creatureViewDirections[0] = getCreatureValue(groupDirections, creatureIndex);
+			checkDirectionsCount = 1;
 		}
-	} else { /* Positive index means test only if the specified creature in the group can see the party in its direction */
-		creatureViewDirections[0] = getCreatureValue(groupDirections, creatureIndex);
-		checkDirectionsCount = 1;
 	}
+
 	while (checkDirectionsCount--) {
-		if (isDestVisibleFromSource(creatureViewDirections[checkDirectionsCount], mapX, mapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY)) {
-T0200011:
+		if (alwaysSee || isDestVisibleFromSource(creatureViewDirections[checkDirectionsCount], mapX, mapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY)) {
 			int16 sightRange = groupCreatureInfo->getSightRange();
 			if (!getFlag(groupCreatureInfo->_attributes, k0x1000_MaskCreatureInfo_nightVision))
 				sightRange -= _vm->_displayMan->_dungeonViewPaletteIndex >> 1;


Commit: dc40f028afb38c970868d469005bd651df9f7b87
    https://github.com/scummvm/scummvm/commit/dc40f028afb38c970868d469005bd651df9f7b87
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-08-30T21:09:33+02:00

Commit Message:
DM: Add message area scroller

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/gfx.cpp
    engines/dm/text.cpp
    engines/dm/text.h



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 4d4fef1..958375b 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -14,7 +14,7 @@ Todo:
 	I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions
 
 Code stuff todo:
-	Complete stub methods(blitShrink, blitmask, scroller)
+	Complete stub methods(blitShrink, blitmask)
 	Add proper save header, add error handling to it
 	Add translations to f433_processCommand140_saveGame 'LOAD'
 	
\ No newline at end of file
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 264fa29..3163b8c 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -38,6 +38,7 @@
 #include "champion.h"
 #include "eventman.h"
 #include "lzw.h"
+#include "text.h"
 
 namespace DM {
 DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
@@ -914,6 +915,7 @@ byte *DisplayMan::getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int
 }
 
 void DisplayMan::updateScreen() {
+	_vm->_textMan->updateMessageArea();
 	// apply copper
 	for (uint32 i = 320 * 30; i < 320 * 170; ++i)
 		_bitmapScreen[i] += 16;
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 6dd906c..80a115c 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -26,6 +26,7 @@
 */
 
 #include "text.h"
+#include <common/system.h>
 
 
 namespace DM {
@@ -36,17 +37,21 @@ TextMan::TextMan(DMEngine* vm) : _vm(vm) {
 	for (uint16 i = 0; i < 4; ++i)
 		_messageAreaRowExpirationTime[i] = 0;
 	_bitmapMessageAreaNewRow = new byte[320 * 7];
+	_isScrolling = false;
+	_startedScrollingAt = -1;
+	_messageAreaCopy = new byte[320 * 7 * 4];
 }
 
 TextMan::~TextMan() {
 	delete[] _bitmapMessageAreaNewRow;
+	delete[] _messageAreaCopy;
 }
 
 #define k5_LetterWidth 5
 #define k6_LetterHeight 6
 
 void TextMan::printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int16 destX, int16 destY,
-									Color textColor, Color bgColor, const char* text, uint16 destHeight) {
+								Color textColor, Color bgColor, const char* text, uint16 destHeight) {
 	if ((destX -= 1) < 0) // fixes missalignment, to be checked
 		destX = 0;
 	if ((destY -= 4) < 0) // fixes missalignment, to be checked
@@ -76,7 +81,7 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int16 de
 
 		Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1);
 		_vm->_displayMan->blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128 / 2, destByteWidth, kM1_ColorNoTransparency,
-											k6_LetterHeight, destHeight);
+									   k6_LetterHeight, destHeight);
 
 		nextX += k5_LetterWidth + 1;
 	}
@@ -91,7 +96,7 @@ void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const cha
 }
 
 void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor,
-										  Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight) {
+									  Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight) {
 	Common::String str = text;
 	for (int16 i = str.size(); i < requiredTextLength; ++i)
 		str += ' ';
@@ -102,7 +107,7 @@ void TextMan::printLineFeed() {
 	printMessage(k0_ColorBlack, "\n");
 }
 
-void TextMan::printMessage(Color color, const char* string) {
+void TextMan::printMessage(Color color, const char* string, bool printWithScroll) {
 	uint16 L0031_ui_CharacterIndex;
 	char L0033_ac_String[54];
 
@@ -118,7 +123,7 @@ void TextMan::printMessage(Color color, const char* string) {
 			if (*string == ' ') {
 				string++;
 				if (_messageAreaCursorColumn != 53) {
-					printString(color, " "); // TODO: I'm not sure this is like the original
+					printString(color, " "); // I'm not sure if this is like the original
 				}
 			} else {
 				L0031_ui_CharacterIndex = 0;
@@ -142,6 +147,7 @@ void TextMan::createNewRow() {
 	if (_messageAreaCursorRow == 3) {
 		isTextScrolling(&_textScroller, true);
 		memset(_bitmapMessageAreaNewRow, k0_ColorBlack, 320 * 7);
+		_isScrolling = true;
 		setScrollerCommand(&_textScroller, 1);
 
 		for (L0029_ui_RowIndex = 0; L0029_ui_RowIndex < 3; L0029_ui_RowIndex++) {
@@ -158,9 +164,10 @@ void TextMan::printString(Color color, const char* string) {
 
 	L0030_i_StringLength = strlen(string);
 	if (isTextScrolling(&_textScroller, false)) {
-		printToLogicalScreen(_messageAreaCursorColumn * 6, (_messageAreaCursorRow * 7 - 6) + 177, color, k0_ColorBlack, string);
+		printToLogicalScreen(_messageAreaCursorColumn * 6, (_messageAreaCursorRow * 7 - 1) + 177, color, k0_ColorBlack, string);
 	} else {
-		printTextToBitmap(_bitmapMessageAreaNewRow, k160_byteWidthScreen, _messageAreaCursorColumn * 6, 5, color, k0_ColorBlack, string, 7);
+		printTextToBitmap(_bitmapMessageAreaNewRow, k160_byteWidthScreen, _messageAreaCursorColumn * 6, 0, color, k0_ColorBlack, string, 7);
+		_isScrolling = true;
 		if (isTextScrolling(&_textScroller, false))
 			setScrollerCommand(&_textScroller, 1);
 	}
@@ -204,7 +211,7 @@ void TextMan::clearExpiredRows() {
 	L0028_s_Box._x2 = 319;
 	for (L0026_ui_RowIndex = 0; L0026_ui_RowIndex < 4; L0026_ui_RowIndex++) {
 		L0027_l_ExpirationTime = _messageAreaRowExpirationTime[L0026_ui_RowIndex];
-		if ((L0027_l_ExpirationTime == -1) || (L0027_l_ExpirationTime > _vm->_gameTime))
+		if ((L0027_l_ExpirationTime == -1) || (L0027_l_ExpirationTime > _vm->_gameTime) || _isScrolling)
 			continue;
 		L0028_s_Box._y2 = (L0028_s_Box._y1 = 172 + (L0026_ui_RowIndex * 7)) + 6;
 		isTextScrolling(&_textScroller, true);
@@ -236,11 +243,30 @@ void TextMan::clearAllRows() {
 
 	Box tmpBox(0, 319, 169, 199);
 	_vm->_displayMan->fillScreenBox(tmpBox, k0_ColorBlack);
-	
+
 	_messageAreaCursorRow = 3;
 	_messageAreaCursorColumn = 0;
 	for (L0023_i_RowIndex = 0; L0023_i_RowIndex < 4; L0023_i_RowIndex++) {
 		_messageAreaRowExpirationTime[L0023_i_RowIndex] = -1;
 	}
 }
+
+void TextMan::updateMessageArea() {
+	if (_isScrolling) {
+		if (_startedScrollingAt == -1) {
+			_startedScrollingAt = _vm->_system->getMillis();
+			memcpy(_messageAreaCopy, _vm->_displayMan->_bitmapScreen + (200 - 7 * 4) * 320, 320 * 7 * 4);
+		}
+		int linesToCopy = (_vm->_system->getMillis() - _startedScrollingAt) / 50;
+		if (linesToCopy >= 7) {
+			linesToCopy = 7;
+			_startedScrollingAt = -1;
+			_isScrolling = false;
+		}
+		memcpy(_vm->_displayMan->_bitmapScreen + (200 - 7 * 4) * 320, _messageAreaCopy + linesToCopy * 320,
+				320 * (7 * 4 - linesToCopy));
+		memcpy(_vm->_displayMan->_bitmapScreen + (200 - linesToCopy) * 320, _bitmapMessageAreaNewRow, 320 * linesToCopy);
+	}
+}
+
 }
diff --git a/engines/dm/text.h b/engines/dm/text.h
index b6049d7..d157c9b 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -43,6 +43,11 @@ class TextMan {
 	int16 _messageAreaCursorRow; // @ G0358_i_MessageAreaCursorRow
 	int32 _messageAreaRowExpirationTime[4]; // @ G0360_al_MessageAreaRowExpirationTime
 	byte *_bitmapMessageAreaNewRow; // @ G0356_puc_Bitmap_MessageAreaNewRow
+
+	// for scrolling 'em messages
+	bool _isScrolling;
+	int64 _startedScrollingAt;
+	byte *_messageAreaCopy;
 public:
 	TextScroller _textScroller;
 
@@ -56,18 +61,18 @@ public:
 	void printWithTrailingSpaces(byte *destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor, Color bgColor,
 									 const char *text, int16 strLenght, int16 destHeight); // @ F0041_TEXT_PrintWithTrailingSpaces
 	void printLineFeed(); // @ F0051_TEXT_MESSAGEAREA_PrintLineFeed
-	void printMessage(Color color, const char *string); // @ F0047_TEXT_MESSAGEAREA_PrintMessage
+	void printMessage(Color color, const char *string, bool printWithScroll = true); // @ F0047_TEXT_MESSAGEAREA_PrintMessage
 	void createNewRow(); // @ F0045_TEXT_MESSAGEAREA_CreateNewRow
 	void printString(Color color, const char* string);// @ F0046_TEXT_MESSAGEAREA_PrintString
 	void initialize(); // @ F0054_TEXT_Initialize
 	void moveCursor(int16 column, int16 row); // @ F0042_TEXT_MESSAGEAREA_MoveCursor
 	void clearExpiredRows(); // @ F0044_TEXT_MESSAGEAREA_ClearExpiredRows
 	void printEndGameString(int16 x, int16 y, Color textColor, char *text); // @ F0443_STARTEND_EndgamePrintString
-	bool isTextScrolling(TextScroller *scroller, bool waitEndOfScrolling) {
-		warning("STUB METHOD: isTextScrolling"); return true;
-	} // @ F0561_SCROLLER_IsTextScrolling
-	void setScrollerCommand(TextScroller *scroller, int16 command) { warning("STUB METHOD: f560_SCROLLER_setCommand");  } // @ F0560_SCROLLER_SetCommand
+	bool isTextScrolling(TextScroller *scroller, bool waitEndOfScrolling) { return false; } // @ F0561_SCROLLER_IsTextScrolling
+	void setScrollerCommand(TextScroller *scroller, int16 command) { } // @ F0560_SCROLLER_SetCommand
 	void clearAllRows(); // @ F0043_TEXT_MESSAGEAREA_ClearAllRows
+
+	void updateMessageArea();
 };
 
 }


Commit: 95272838e16bb62f708cc37cf13713580b296b5d
    https://github.com/scummvm/scummvm/commit/95272838e16bb62f708cc37cf13713580b296b5d
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-30T22:45:42+02:00

Commit Message:
DM: renaming and some refactoring in getDistanceBetweenUnblockedSquares

Changed paths:
    engines/dm/group.cpp



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 5bf545c..9d453b8 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1168,61 +1168,64 @@ int16 GroupMan::groupGetDistanceToVisibleParty(Group *group, int16 creatureIndex
 }
 
 int16 GroupMan::getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 srcMapY,
-														int16 destMapX, int16 destMapY, bool (GroupMan::*isBlocked)(uint16, uint16)) {
-	int16 L0410_i_XAxisStep;
-	int16 L0411_i_YAxisStep;
-	int16 L0412_i_Multiple;
-#define AL0412_i_DistanceX L0412_i_Multiple
-#define AL0412_i_PathMapX  L0412_i_Multiple
-	int16 L0413_i_Multiple;
-#define AL0413_i_DistanceY L0413_i_Multiple
-#define AL0413_i_PathMapY  L0413_i_Multiple
-	int16 L0414_i_LargestAxisDistance;
-	bool L0415_B_DistanceXSmallerThanDistanceY;
-	int16 L0416_i_ValueA;
-	int16 L0417_i_ValueB;
-	bool L0418_B_DistanceXEqualsDistanceY;
-	int16 L0419_i_ValueC;
-
+													int16 destMapX, int16 destMapY, bool (GroupMan::*isBlocked)(uint16, uint16)) {
 
 	if (getDistance(srcMapX, srcMapY, destMapX, destMapY) <= 1) {
 		return 1;
 	}
-	L0415_B_DistanceXSmallerThanDistanceY = (AL0412_i_DistanceX = ((AL0412_i_DistanceX = destMapX - srcMapX) < 0) ? -AL0412_i_DistanceX : AL0412_i_DistanceX) < (AL0413_i_DistanceY = ((AL0413_i_DistanceY = destMapY - srcMapY) < 0) ? -AL0413_i_DistanceY : AL0413_i_DistanceY);
-	L0418_B_DistanceXEqualsDistanceY = (AL0412_i_DistanceX == AL0413_i_DistanceY);
-	L0410_i_XAxisStep = (((AL0412_i_PathMapX = destMapX) - srcMapX) > 0) ? -1 : 1;
-	L0411_i_YAxisStep = (((AL0413_i_PathMapY = destMapY) - srcMapY) > 0) ? -1 : 1;
-	L0419_i_ValueC = L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY - srcMapY) ? ((AL0412_i_PathMapX - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128)
-		: ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX - srcMapX) ? ((AL0413_i_PathMapY - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128);
+
+	int16 distanceX = ABS(destMapX - srcMapX);
+	int16 distanceY = ABS(destMapY - srcMapY);
+	bool isDistanceXSmallerThanDistanceY = (distanceX < distanceY);
+	bool isDistanceXEqualsDistanceY = (distanceX == distanceY);
+	int16 pathMapX = destMapX;
+	int16 pathMapY = destMapY;
+	int16 axisStepX = ((pathMapX - srcMapX) > 0) ? -1 : 1;
+	int16 axisStepY = ((pathMapY - srcMapY) > 0) ? -1 : 1;
+	int16 largestAxisDistance;
+
+	int16 valueA;
+	int16 valueB;
+	int16 valueC;
+
+	if (isDistanceXSmallerThanDistanceY) {
+		largestAxisDistance = pathMapY - srcMapY;
+		valueC = (largestAxisDistance ? ((pathMapX - srcMapX) << 6) / largestAxisDistance : 128);
+	} else {
+		largestAxisDistance = pathMapX - srcMapX;
+		valueC = (largestAxisDistance ? ((pathMapY - srcMapY) << 6) / largestAxisDistance : 128);
+	}
+
 	/* 128 when the creature is on the same row or column as the party */
 	do {
-		if (L0418_B_DistanceXEqualsDistanceY) {
-			if (((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY) && (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX, AL0413_i_PathMapY + L0411_i_YAxisStep)) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX = AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY = AL0413_i_PathMapY + L0411_i_YAxisStep)) {
+		if (isDistanceXEqualsDistanceY) {
+			if ((   (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(pathMapX + axisStepX, pathMapY) 
+				 && (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(pathMapX, pathMapY + axisStepY)) 
+			 || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(pathMapX = pathMapX + axisStepX, pathMapY = pathMapY + axisStepY))
 				return 0;
-			}
 		} else {
-			if ((L0416_i_ValueA = ((L0414_i_LargestAxisDistance = (L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY - srcMapY) ? ((AL0412_i_PathMapX + L0410_i_XAxisStep - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX + L0410_i_XAxisStep - srcMapX) ? ((AL0413_i_PathMapY - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128)) - L0419_i_ValueC) < 0) ? -L0414_i_LargestAxisDistance : L0414_i_LargestAxisDistance) < (L0417_i_ValueB = ((L0414_i_LargestAxisDistance = (L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY + L0411_i_YAxisStep - srcMapY) ? ((AL0412_i_PathMapX - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX - srcMapX) ? ((AL0413_i_PathMapY + L0411_i_YAxisStep - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128)) - L0419_i_ValueC) < 0) ? -L0414_i_LargestAxisDistance : L0414_i_LargestAxisDistance)) {
-				AL0412_i_PathMapX += L0410_i_XAxisStep;
+			if ((valueA = ((largestAxisDistance = (isDistanceXSmallerThanDistanceY ? ((largestAxisDistance = pathMapY - srcMapY) ? ((pathMapX + axisStepX - srcMapX) << 6) / largestAxisDistance : 128) : ((largestAxisDistance = pathMapX + axisStepX - srcMapX) ? ((pathMapY - srcMapY) << 6) / largestAxisDistance : 128)) - valueC) < 0) ? -largestAxisDistance : largestAxisDistance) < (valueB = ((largestAxisDistance = (isDistanceXSmallerThanDistanceY ? ((largestAxisDistance = pathMapY + axisStepY - srcMapY) ? ((pathMapX - srcMapX) << 6) / largestAxisDistance : 128) : ((largestAxisDistance = pathMapX - srcMapX) ? ((pathMapY + axisStepY - srcMapY) << 6) / largestAxisDistance : 128)) - valueC) < 0) ? -largestAxisDistance : largestAxisDistance)) {
+				pathMapX += axisStepX;
 			} else {
-				AL0413_i_PathMapY += L0411_i_YAxisStep;
+				pathMapY += axisStepY;
 			}
-			if ((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX, AL0413_i_PathMapY) && ((L0416_i_ValueA != L0417_i_ValueB) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX = AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY = AL0413_i_PathMapY - L0411_i_YAxisStep))) {
+			if ((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(pathMapX, pathMapY) && ((valueA != valueB) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(pathMapX = pathMapX + axisStepX, pathMapY = pathMapY - axisStepY))) {
 				return 0;
 			}
 		}
-	} while (getDistance(AL0412_i_PathMapX, AL0413_i_PathMapY, srcMapX, srcMapY) > 1);
+	} while (getDistance(pathMapX, pathMapY, srcMapX, srcMapY) > 1);
 	return getDistanceBetweenSquares(srcMapX, srcMapY, destMapX, destMapY);
 }
 
 bool GroupMan::isViewPartyBlocked(uint16 mapX, uint16 mapY) {
-	uint16 L0404_ui_Square = _vm->_dungeonMan->_currMapData[mapX][mapY];
-	int16 L0405_i_SquareType = Square(L0404_ui_Square).getType();
-	if (L0405_i_SquareType == k4_DoorElemType) {
-		Door *L0407_ps_Door = (Door *)_vm->_dungeonMan->getSquareFirstThingData(mapX, mapY);
-		int16 L0406_i_DoorState = Square(L0404_ui_Square).getDoorState();
-		return ((L0406_i_DoorState == k3_doorState_FOURTH) || (L0406_i_DoorState == k4_doorState_CLOSED)) && !getFlag(_vm->_dungeonMan->_currMapDoorInfo[L0407_ps_Door->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough);
-	}
-	return (L0405_i_SquareType == k0_ElementTypeWall) || ((L0405_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0404_ui_Square, k0x0004_FakeWallOpen));
+	uint16 curSquare = _vm->_dungeonMan->_currMapData[mapX][mapY];
+	int16 curSquareType = Square(curSquare).getType();
+	if (curSquareType == k4_DoorElemType) {
+		Door *curDoor = (Door *)_vm->_dungeonMan->getSquareFirstThingData(mapX, mapY);
+		int16 curDoorState = Square(curSquare).getDoorState();
+		return ((curDoorState == k3_doorState_FOURTH) || (curDoorState == k4_doorState_CLOSED)) && !getFlag(_vm->_dungeonMan->_currMapDoorInfo[curDoor->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough);
+	}
+	return (curSquareType == k0_ElementTypeWall) || ((curSquareType == k6_ElementTypeFakeWall) && !getFlag(curSquare, k0x0004_FakeWallOpen));
 }
 
 int32 GroupMan::getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 creatureIndex, bool isAttacking) {


Commit: ff96b8eeb6f5f6e17f630cbf3705b3ae73a5f61b
    https://github.com/scummvm/scummvm/commit/ff96b8eeb6f5f6e17f630cbf3705b3ae73a5f61b
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-30T23:31:04+02:00

Commit Message:
DM: Refactor a couple of 'if' nightmares in getDistanceBetweenUnblockedSquares

Changed paths:
    engines/dm/group.cpp



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 9d453b8..6fd4692 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1204,13 +1204,24 @@ int16 GroupMan::getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 srcMapY,
 			 || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(pathMapX = pathMapX + axisStepX, pathMapY = pathMapY + axisStepY))
 				return 0;
 		} else {
-			if ((valueA = ((largestAxisDistance = (isDistanceXSmallerThanDistanceY ? ((largestAxisDistance = pathMapY - srcMapY) ? ((pathMapX + axisStepX - srcMapX) << 6) / largestAxisDistance : 128) : ((largestAxisDistance = pathMapX + axisStepX - srcMapX) ? ((pathMapY - srcMapY) << 6) / largestAxisDistance : 128)) - valueC) < 0) ? -largestAxisDistance : largestAxisDistance) < (valueB = ((largestAxisDistance = (isDistanceXSmallerThanDistanceY ? ((largestAxisDistance = pathMapY + axisStepY - srcMapY) ? ((pathMapX - srcMapX) << 6) / largestAxisDistance : 128) : ((largestAxisDistance = pathMapX - srcMapX) ? ((pathMapY + axisStepY - srcMapY) << 6) / largestAxisDistance : 128)) - valueC) < 0) ? -largestAxisDistance : largestAxisDistance)) {
-				pathMapX += axisStepX;
+			if (isDistanceXSmallerThanDistanceY) {
+				valueA = ABS(((pathMapY - srcMapY) ? ((pathMapX + axisStepX - srcMapX) << 6) / largestAxisDistance : 128) - valueC);
+				valueB = ABS(((pathMapY + axisStepY - srcMapY) ? ((pathMapX - srcMapX) << 6) / largestAxisDistance : 128) - valueC);
 			} else {
-				pathMapY += axisStepY;
+				valueA = ABS(((pathMapX + axisStepX - srcMapX) ? ((pathMapY - srcMapY) << 6) / largestAxisDistance : 128) - valueC);
+				valueB = ABS(((pathMapX - srcMapX) ? ((pathMapY + axisStepY - srcMapY) << 6) / largestAxisDistance : 128) - valueC);
 			}
-			if ((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(pathMapX, pathMapY) && ((valueA != valueB) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(pathMapX = pathMapX + axisStepX, pathMapY = pathMapY - axisStepY))) {
-				return 0;
+
+			if (valueA < valueB)
+				pathMapX += axisStepX;
+			else
+				pathMapY += axisStepY;
+
+			if ((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(pathMapX, pathMapY)) {
+				pathMapX += axisStepX;
+				pathMapY -= axisStepY;
+				if (((valueA != valueB) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(pathMapX, pathMapY)))
+					return 0;
 			}
 		}
 	} while (getDistance(pathMapX, pathMapY, srcMapX, srcMapY) > 1);


Commit: 643fd69f87497843aa23b09d5363cc5d9636422f
    https://github.com/scummvm/scummvm/commit/643fd69f87497843aa23b09d5363cc5d9636422f
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-08-31T08:02:03+02:00

Commit Message:
DM: More renaming and refactoring in GroupMan

Changed paths:
    engines/dm/group.cpp



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 6fd4692..3b511d9 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1240,103 +1240,96 @@ bool GroupMan::isViewPartyBlocked(uint16 mapX, uint16 mapY) {
 }
 
 int32 GroupMan::getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 creatureIndex, bool isAttacking) {
-	uint16 L0326_ui_Multiple;
-#define AL0326_ui_Aspect         L0326_ui_Multiple
-#define AL0326_ui_AnimationTicks L0326_ui_Multiple
-	uint16 L0327_ui_CreatureGraphicInfo;
-	int16 L0328_i_Offset;
-	Group *L0329_ps_Group;
-	bool L0330_B_ProcessGroup;
-	uint16 L0331_ui_CreatureType;
-	uint16 L1635_ui_SoundIndex;
-
-	L0329_ps_Group = &(((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]);
-	L0327_ui_CreatureGraphicInfo = _vm->_dungeonMan->_creatureInfos[L0331_ui_CreatureType = L0329_ps_Group->_type]._graphicInfo;
-	L0330_B_ProcessGroup = (creatureIndex < 0);
-	if (L0330_B_ProcessGroup) /* If the creature index is negative then all creatures in the group are processed */
-		creatureIndex = L0329_ps_Group->getCount();
+	Group *group = &(((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]);
+	uint16 creatureType = group->_type;
+	uint16 creatureGraphicInfo = _vm->_dungeonMan->_creatureInfos[creatureType]._graphicInfo;
+	bool processGroup = (creatureIndex < 0);
+	if (processGroup) /* If the creature index is negative then all creatures in the group are processed */
+		creatureIndex = group->getCount();
 
 	do {
-		AL0326_ui_Aspect = activeGroup->_aspect[creatureIndex];
-		AL0326_ui_Aspect &= k0x0080_MaskActiveGroupIsAttacking | k0x0040_MaskActiveGroupFlipBitmap;
-		L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 12) & 0x3);
-		if (L0328_i_Offset) {
-			L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset);
+		uint16 aspect = activeGroup->_aspect[creatureIndex];
+		aspect &= k0x0080_MaskActiveGroupIsAttacking | k0x0040_MaskActiveGroupFlipBitmap;
+		int16 offset = ((creatureGraphicInfo >> 12) & 0x3);
+		if (offset) {
+			offset = _vm->getRandomNumber(offset);
 			if (_vm->getRandomNumber(2))
-				L0328_i_Offset = (-L0328_i_Offset) & 0x0007;
+				offset = (-offset) & 0x0007;
 
-			AL0326_ui_Aspect |= L0328_i_Offset;
+			aspect |= offset;
 		}
 
-		L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 14) & 0x3);
-		if (L0328_i_Offset) {
-			L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset);
+		offset = ((creatureGraphicInfo >> 14) & 0x3);
+		if (offset) {
+			offset = _vm->getRandomNumber(offset);
 			if (_vm->getRandomNumber(2))
-				L0328_i_Offset = (-L0328_i_Offset) & 0x0007;
+				offset = (-offset) & 0x0007;
 
-			AL0326_ui_Aspect |= (L0328_i_Offset << 3);
+			aspect |= (offset << 3);
 		}
 		if (isAttacking) {
-			if (getFlag(L0327_ui_CreatureGraphicInfo, k0x0200_CreatureInfoGraphicMaskFlipAttack)) {
-				if (getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) && (L0331_ui_CreatureType == k18_CreatureTypeAnimatedArmourDethKnight)) {
+			if (getFlag(creatureGraphicInfo, k0x0200_CreatureInfoGraphicMaskFlipAttack)) {
+				if (getFlag(aspect, k0x0080_MaskActiveGroupIsAttacking) && (creatureType == k18_CreatureTypeAnimatedArmourDethKnight)) {
 					if (_vm->getRandomNumber(2)) {
-						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+						toggleFlag(aspect, k0x0040_MaskActiveGroupFlipBitmap);
 						_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _currentGroupMapX, _currentGroupMapY, k1_soundModePlayIfPrioritized);
 					}
-				} else if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) {
+				} else if (!getFlag(aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(creatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) {
 					if (_vm->getRandomNumber(2))
-						setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+						setFlag(aspect, k0x0040_MaskActiveGroupFlipBitmap);
 					else
-						clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+						clearFlag(aspect, k0x0040_MaskActiveGroupFlipBitmap);
 				}
 			} else
-				clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+				clearFlag(aspect, k0x0040_MaskActiveGroupFlipBitmap);
 
-			setFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking);
+			setFlag(aspect, k0x0080_MaskActiveGroupIsAttacking);
 		} else {
-			if (getFlag(L0327_ui_CreatureGraphicInfo, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) {
-				if (L0331_ui_CreatureType == k13_CreatureTypeCouatl) {
+			if (getFlag(creatureGraphicInfo, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) {
+				if (creatureType == k13_CreatureTypeCouatl) {
 					if (_vm->getRandomNumber(2)) {
-						toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
-						L1635_ui_SoundIndex = _vm->_moveSens->getSound(k13_CreatureTypeCouatl);
-						if (L1635_ui_SoundIndex <= k34_D13_soundCount)
-							_vm->_sound->requestPlay(L1635_ui_SoundIndex, _currentGroupMapX, _currentGroupMapY, k1_soundModePlayIfPrioritized);
+						toggleFlag(aspect, k0x0040_MaskActiveGroupFlipBitmap);
+						uint16 soundIndex = _vm->_moveSens->getSound(k13_CreatureTypeCouatl);
+						if (soundIndex <= k34_D13_soundCount)
+							_vm->_sound->requestPlay(soundIndex, _currentGroupMapX, _currentGroupMapY, k1_soundModePlayIfPrioritized);
 					}
 				} else if (_vm->getRandomNumber(2))
-					setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+					setFlag(aspect, k0x0040_MaskActiveGroupFlipBitmap);
 				else
-					clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+					clearFlag(aspect, k0x0040_MaskActiveGroupFlipBitmap);
 			} else
-				clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap);
+				clearFlag(aspect, k0x0040_MaskActiveGroupFlipBitmap);
 
-			clearFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking);
+			clearFlag(aspect, k0x0080_MaskActiveGroupIsAttacking);
 		}
-		activeGroup->_aspect[creatureIndex] = AL0326_ui_Aspect;
-	} while (L0330_B_ProcessGroup && (creatureIndex--));
-	AL0326_ui_AnimationTicks = _vm->_dungeonMan->_creatureInfos[L0329_ps_Group->_type]._animationTicks;
-	return _vm->_gameTime + (isAttacking ? ((AL0326_ui_AnimationTicks >> 8) & 0xF) : ((AL0326_ui_AnimationTicks >> 4) & 0xF)) + _vm->getRandomNumber(2);
+		activeGroup->_aspect[creatureIndex] = aspect;
+	} while (processGroup && (creatureIndex--));
+	uint16 animationTicks = _vm->_dungeonMan->_creatureInfos[group->_type]._animationTicks;
+	return _vm->_gameTime + (isAttacking ? ((animationTicks >> 8) & 0xF) : ((animationTicks >> 4) & 0xF)) + _vm->getRandomNumber(2);
 }
 
 void GroupMan::setGroupDirection(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) {
-	uint16 L0435_ui_GroupDirections;
 	static ActiveGroup *G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup;
 
-	if (twoHalfSquareSizedCreatures && (_vm->_gameTime == twoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) {
+	if (twoHalfSquareSizedCreatures
+	 && (_vm->_gameTime == twoHalfSquareSizedCreaturesGroupLastDirectionSetTime)
+	 && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup))
 		return;
-	}
-	L0435_ui_GroupDirections = activeGroup->_directions;
-	if (normalizeModulo4(getCreatureValue(L0435_ui_GroupDirections, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */
+
+	uint16 groupDirections = activeGroup->_directions;
+	if (normalizeModulo4(getCreatureValue(groupDirections, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */
 		dir = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + dir);
-		L0435_ui_GroupDirections = getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir);
-	} else {
-		L0435_ui_GroupDirections = getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir);
-	}
+		groupDirections = getGroupValueUpdatedWithCreatureValue(groupDirections, creatureIndex, dir);
+	} else
+		groupDirections = getGroupValueUpdatedWithCreatureValue(groupDirections, creatureIndex, dir);
+
 	if (twoHalfSquareSizedCreatures) {
-		L0435_ui_GroupDirections = getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex ^ 1, dir); /* Set direction of the second half square sized creature */
+		groupDirections = getGroupValueUpdatedWithCreatureValue(groupDirections, creatureIndex ^ 1, dir); /* Set direction of the second half square sized creature */
 		twoHalfSquareSizedCreaturesGroupLastDirectionSetTime = _vm->_gameTime;
 		G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup = activeGroup;
 	}
-	activeGroup->_directions = (Direction)L0435_ui_GroupDirections;
+
+	activeGroup->_directions = (Direction)groupDirections;
 }
 
 void GroupMan::addGroupEvent(TimelineEvent *event, uint32 time) {
@@ -1352,178 +1345,168 @@ void GroupMan::addGroupEvent(TimelineEvent *event, uint32 time) {
 }
 
 int16 GroupMan::getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo, int16 mapY, int16 mapX) {
-
-	uint16 L0426_ui_SmellRange;
-	int16 L0427_i_ScentOrdinal;
-
-
-	if (!(L0426_ui_SmellRange = creatureInfo->getSmellRange())) {
+	uint16 smellRange = creatureInfo->getSmellRange();
+	if (!smellRange)
 		return 0;
-	}
-	if ((((L0426_ui_SmellRange + 1) >> 1) >= _currGroupDistanceToParty) && getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, &GroupMan::isSmellPartyBlocked)) {
+
+	if ((((smellRange + 1) >> 1) >= _currGroupDistanceToParty) && getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, &GroupMan::isSmellPartyBlocked)) {
 		_vm->_projexpl->_secondaryDirToOrFromParty = _currGroupSecondaryDirToParty;
 		return _vm->indexToOrdinal(_currGroupPrimaryDirToParty);
 	}
-	if ((L0427_i_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapY, mapX)) && ((_vm->_championMan->_party._scentStrengths[_vm->ordinalToIndex(L0427_i_ScentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (L0426_ui_SmellRange << 1)))) { /* If there is a fresh enough party scent on the group square */
-		return _vm->indexToOrdinal(getDirsWhereDestIsVisibleFromSource(mapY, mapX, _vm->_championMan->_party._scents[L0427_i_ScentOrdinal].getMapX(), _vm->_championMan->_party._scents[L0427_i_ScentOrdinal].getMapY()));
+
+	int16 scentOrdinal = _vm->_championMan->getScentOrdinal(mapY, mapX);
+	if (scentOrdinal && ((_vm->_championMan->_party._scentStrengths[_vm->ordinalToIndex(scentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (smellRange << 1)))) { /* If there is a fresh enough party scent on the group square */
+		return _vm->indexToOrdinal(getDirsWhereDestIsVisibleFromSource(mapY, mapX, _vm->_championMan->_party._scents[scentOrdinal].getMapX(), _vm->_championMan->_party._scents[scentOrdinal].getMapY()));
 	}
 	return 0;
 }
 
 bool GroupMan::isSmellPartyBlocked(uint16 mapX, uint16 mapY) {
-	uint16 L0408_ui_Square;
-	int16 L0409_i_SquareType;
+	uint16 square = _vm->_dungeonMan->_currMapData[mapX][mapY];
+	int16 squareType = Square(square).getType();
 
-	return ((L0409_i_SquareType = Square(L0408_ui_Square = _vm->_dungeonMan->_currMapData[mapX][mapY]).getType()) == k0_ElementTypeWall) || ((L0409_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0408_ui_Square, k0x0004_FakeWallOpen));
+	return ( (squareType) == k0_ElementTypeWall) || ((squareType == k6_ElementTypeFakeWall)
+		  && !getFlag(square, k0x0004_FakeWallOpen));
 }
 
 int16 GroupMan::getFirstPossibleMovementDirOrdinal(CreatureInfo *info, int16 mapX, int16 mapY, bool allowMovementOverImaginaryPitsAndFakeWalls) {
-	int16 L0434_i_Direction;
-
-
-	for (L0434_i_Direction = kDirNorth; L0434_i_Direction <= kDirWest; L0434_i_Direction++) {
-		if ((!_groupMovementTestedDirections[L0434_i_Direction]) && isMovementPossible(info, mapX, mapY, L0434_i_Direction, allowMovementOverImaginaryPitsAndFakeWalls)) {
-			return _vm->indexToOrdinal(L0434_i_Direction);
+	for (int16 direction = kDirNorth; direction <= kDirWest; direction++) {
+		if ((!_groupMovementTestedDirections[direction]) && isMovementPossible(info, mapX, mapY, direction, allowMovementOverImaginaryPitsAndFakeWalls)) {
+			return _vm->indexToOrdinal(direction);
 		}
 	}
 	return 0;
 }
 
 void GroupMan::setDirGroup(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, int16 creatureSize) {
-	bool L0436_B_TwoHalfSquareSizedCreatures = creatureIndex && (creatureSize == k1_MaskCreatureSizeHalf);
+	bool twoHalfSquareSizedCreatures = creatureIndex && (creatureSize == k1_MaskCreatureSizeHalf);
 
-	if (L0436_B_TwoHalfSquareSizedCreatures)
+	if (twoHalfSquareSizedCreatures)
 		creatureIndex--;
 
 	do {
 		if (!creatureIndex || _vm->getRandomNumber(2))
-			setGroupDirection(activeGroup, dir, creatureIndex, L0436_B_TwoHalfSquareSizedCreatures);
+			setGroupDirection(activeGroup, dir, creatureIndex, twoHalfSquareSizedCreatures);
 	} while (creatureIndex--);
 }
 
 void GroupMan::stopAttacking(ActiveGroup *group, int16 mapX, int16 mapY) {
-	int16 L0337_i_CreatureIndex;
+	for (int16 creatureIndex = 0; creatureIndex < 4; creatureIndex++)
+		clearFlag(group->_aspect[creatureIndex++], k0x0080_MaskActiveGroupIsAttacking);
 
-	for (L0337_i_CreatureIndex = 0; L0337_i_CreatureIndex < 4; clearFlag(group->_aspect[L0337_i_CreatureIndex++], k0x0080_MaskActiveGroupIsAttacking));
 	groupDeleteEvents(mapX, mapY);
-
 }
 
 bool GroupMan::isArchenemyDoubleMovementPossible(CreatureInfo *info, int16 mapX, int16 mapY, uint16 dir) {
-	if (_fluxCages[dir]) {
+	if (_fluxCages[dir])
 		return false;
-	}
+
 	mapX += _vm->_dirIntoStepCountEast[dir], mapY += _vm->_dirIntoStepCountNorth[dir];
 	return isMovementPossible(info, mapX, mapY, dir, false);
 }
 
 bool GroupMan::isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 creatureIndex) {
-	static const uint8 G0244_auc_Graphic559_CreatureAttackSounds[11] = { 3, 7, 14, 15, 19, 21, 29, 30, 31, 4, 16 }; /* Atari ST: { 3, 7, 14, 15, 19, 21, 4, 16 } */
-
-	uint16 L0437_ui_Multiple;
-#define AL0437_ui_CreatureType L0437_ui_Multiple
-#define AL0437_T_Thing         L0437_ui_Multiple
-	int16 L0439_i_Multiple;
-#define AL0439_i_GroupCells    L0439_i_Multiple
-#define AL0439_i_TargetCell    L0439_i_Multiple
-#define AL0439_i_ChampionIndex L0439_i_Multiple
-	int16 L0440_i_Multiple;
-#define AL0440_i_KineticEnergy      L0440_i_Multiple
-#define AL0440_i_Counter            L0440_i_Multiple
-#define AL0440_i_Damage             L0440_i_Multiple
-#define AL0440_i_AttackSoundOrdinal L0440_i_Multiple
+	static const uint8 creatureAttackSounds[11] = { 3, 7, 14, 15, 19, 21, 29, 30, 31, 4, 16 }; /* Atari ST: { 3, 7, 14, 15, 19, 21, 4, 16 } */
 
 	_vm->_projexpl->_lastCreatureAttackTime = _vm->_gameTime;
-	ActiveGroup L0443_s_ActiveGroup = _activeGroups[group->getActiveGroupIndex()];
-	CreatureInfo *L0441_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[AL0437_ui_CreatureType = group->_type];
-	uint16 L0438_ui_PrimaryDirectionToParty = _currGroupPrimaryDirToParty;
-	if ((AL0439_i_GroupCells = L0443_s_ActiveGroup._cells) == k255_CreatureTypeSingleCenteredCreature) {
-		AL0439_i_TargetCell = _vm->getRandomNumber(2);
-	} else {
-		AL0439_i_TargetCell = ((getCreatureValue(AL0439_i_GroupCells, creatureIndex) + 5 - L0438_ui_PrimaryDirectionToParty) & 0x0002) >> 1;
-	}
-	AL0439_i_TargetCell += L0438_ui_PrimaryDirectionToParty;
-	AL0439_i_TargetCell &= 0x0003;
-	if ((L0441_ps_CreatureInfo->getAttackRange() > 1) && ((_currGroupDistanceToParty > 1) || _vm->getRandomNumber(2))) {
-		switch (AL0437_ui_CreatureType) {
+	ActiveGroup activeGroup = _activeGroups[group->getActiveGroupIndex()];
+	uint16 creatureType = group->_type;
+	CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[creatureType];
+	uint16 primaryDirectionToParty = _currGroupPrimaryDirToParty;
+
+	int16 targetCell;
+	byte groupCells = activeGroup._cells;
+	if (groupCells == k255_CreatureTypeSingleCenteredCreature)
+		targetCell = _vm->getRandomNumber(2);
+	else
+		targetCell = ((getCreatureValue(groupCells, creatureIndex) + 5 - primaryDirectionToParty) & 0x0002) >> 1;
+
+	targetCell += primaryDirectionToParty;
+	targetCell &= 0x0003;
+	if ((creatureInfo->getAttackRange() > 1) && ((_currGroupDistanceToParty > 1) || _vm->getRandomNumber(2))) {
+		Thing projectileThing = Thing::_none;
+
+		switch (creatureType) {
 		case k14_CreatureTypeVexirk:
 		case k23_CreatureTypeLordChaos:
 			if (_vm->getRandomNumber(2)) {
-				AL0437_T_Thing = Thing::_explFireBall.toUint16();
+				projectileThing = Thing::_explFireBall;
 			} else {
 				switch (_vm->getRandomNumber(4)) {
 				case 0:
-					AL0437_T_Thing = Thing::_explHarmNonMaterial.toUint16();
+					projectileThing = Thing::_explHarmNonMaterial;
 					break;
 				case 1:
-					AL0437_T_Thing = Thing::_explLightningBolt.toUint16();
+					projectileThing = Thing::_explLightningBolt;
 					break;
 				case 2:
-					AL0437_T_Thing = Thing::_explPoisonCloud.toUint16();
+					projectileThing = Thing::_explPoisonCloud;
 					break;
 				case 3:
-					AL0437_T_Thing = Thing::_explOpenDoor.toUint16();
+					projectileThing = Thing::_explOpenDoor;
 				}
 			}
 			break;
 		case k1_CreatureTypeSwampSlimeSlime:
-			AL0437_T_Thing = Thing::_explSlime.toUint16();
+			projectileThing = Thing::_explSlime;
 			break;
 		case k3_CreatureTypeWizardEyeFlyingEye:
 			if (_vm->getRandomNumber(8)) {
-				AL0437_T_Thing = Thing::_explLightningBolt.toUint16();
+				projectileThing = Thing::_explLightningBolt;
 			} else {
-				AL0437_T_Thing = Thing::_explOpenDoor.toUint16();
+				projectileThing = Thing::_explOpenDoor;
 			}
 			break;
 		case k19_CreatureTypeMaterializerZytaz:
 			if (_vm->getRandomNumber(2)) {
-				AL0437_T_Thing = Thing::_explPoisonCloud.toUint16();
+				projectileThing = Thing::_explPoisonCloud;
 				break;
 			}
 		case k22_CreatureTypeDemon:
 		case k24_CreatureTypeRedDragon:
-			AL0437_T_Thing = Thing::_explFireBall.toUint16();
+			projectileThing = Thing::_explFireBall;
 		} /* BUG0_13 The game may crash when 'Lord Order' or 'Grey Lord' cast spells. This cannot happen with the original dungeons as they do not contain any groups of these types. 'Lord Order' and 'Grey Lord' creatures can cast spells (attack range > 1) but no projectile type is defined for them in the code. If these creatures are present in a dungeon they will cast projectiles containing undefined things because the variable is not initialized */
-		AL0440_i_KineticEnergy = (L0441_ps_CreatureInfo->_attack >> 2) + 1;
-		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
-		AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy);
+		int16 kineticEnergy = (creatureInfo->_attack >> 2) + 1;
+		kineticEnergy += _vm->getRandomNumber(kineticEnergy);
+		kineticEnergy += _vm->getRandomNumber(kineticEnergy);
 		_vm->_sound->requestPlay(k13_soundSPELL, mapX, mapY, k0_soundModePlayImmediately);
-		_vm->_projexpl->createProjectile(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (Direction)_currGroupPrimaryDirToParty, getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8);
+		_vm->_projexpl->createProjectile(projectileThing, mapX, mapY, targetCell, (Direction)_currGroupPrimaryDirToParty, getBoundedValue((int16)20, kineticEnergy, (int16)255), creatureInfo->_dexterity, 8);
 	} else {
-		if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) {
-			AL0439_i_ChampionIndex = _vm->getRandomNumber(4);
-			for (AL0440_i_Counter = 0; (AL0440_i_Counter < 4) && !_vm->_championMan->_champions[AL0439_i_ChampionIndex]._currHealth; AL0440_i_Counter++) {
-				AL0439_i_ChampionIndex = returnNextVal(AL0439_i_ChampionIndex);
-			}
-			if (AL0440_i_Counter == 4) {
+		int16 championIndex;
+		if (getFlag(creatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) {
+			championIndex = _vm->getRandomNumber(4);
+			int cpt;
+			for (cpt = 0; (cpt < 4) && !_vm->_championMan->_champions[championIndex]._currHealth; cpt++)
+				championIndex = returnNextVal(championIndex);
+
+			if (cpt == 4)
 				return false;
-			}
 		} else {
-			if ((AL0439_i_ChampionIndex = _vm->_championMan->getTargetChampionIndex(mapX, mapY, AL0439_i_TargetCell)) < 0) {
+			championIndex = _vm->_championMan->getTargetChampionIndex(mapX, mapY, targetCell);
+			if (championIndex < 0)
 				return false;
-			}
 		}
-		if (AL0437_ui_CreatureType == k2_CreatureTypeGiggler) {
-			stealFromChampion(group, AL0439_i_ChampionIndex);
-		} else {
-			AL0440_i_Damage = getChampionDamage(group, AL0439_i_ChampionIndex) + 1;
-			Champion *L0442_ps_Champion = &_vm->_championMan->_champions[AL0439_i_ChampionIndex];
-			if (AL0440_i_Damage > L0442_ps_Champion->_maximumDamageReceived) {
-				L0442_ps_Champion->_maximumDamageReceived = AL0440_i_Damage;
-				L0442_ps_Champion->_directionMaximumDamageReceived = returnOppositeDir((Direction)L0438_ui_PrimaryDirectionToParty);
+
+		if (creatureType == k2_CreatureTypeGiggler)
+			stealFromChampion(group, championIndex);
+		else {
+			int16 damage = getChampionDamage(group, championIndex) + 1;
+			Champion *damagedChampion = &_vm->_championMan->_champions[championIndex];
+			if (damage > damagedChampion->_maximumDamageReceived) {
+				damagedChampion->_maximumDamageReceived = damage;
+				damagedChampion->_directionMaximumDamageReceived = returnOppositeDir((Direction)primaryDirectionToParty);
 			}
 		}
 	}
-	AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal;
-	if (AL0440_i_AttackSoundOrdinal)
-		_vm->_sound->requestPlay(G0244_auc_Graphic559_CreatureAttackSounds[--AL0440_i_AttackSoundOrdinal], mapX, mapY, k1_soundModePlayIfPrioritized);
+	int16 attackSoundOrdinal = creatureInfo->_attackSoundOrdinal;
+	if (attackSoundOrdinal)
+		_vm->_sound->requestPlay(creatureAttackSounds[--attackSoundOrdinal], mapX, mapY, k1_soundModePlayIfPrioritized);
 
 	return true;
 }
 
 void GroupMan::setOrderedCellsToAttack(signed char *orderedCellsToAttack, int16 targetMapX, int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource) {
-	static signed char g23_orderedCellsToAttack[8][4] = { // @ G0023_aac_Graphic562_OrderedCellsToAttack
+	static signed char attackOrder[8][4] = { // @ G0023_aac_Graphic562_OrderedCellsToAttack
 		{0, 1, 3, 2},   /* Attack South from position Northwest or Southwest */
 		{1, 0, 2, 3},   /* Attack South from position Northeast or Southeast */
 		{1, 2, 0, 3},   /* Attack West from position Northwest or Northeast */
@@ -1531,52 +1514,48 @@ void GroupMan::setOrderedCellsToAttack(signed char *orderedCellsToAttack, int16
 		{3, 2, 0, 1},   /* Attack North from position Northwest or Southwest */
 		{2, 3, 1, 0},   /* Attack North from position Southeast or Northeast */
 		{0, 3, 1, 2},   /* Attack East from position Northwest or Northeast */
-		{3, 0, 2, 1}}; /* Attack East from position Southeast or Southwest */
-	uint16 L0557_ui_OrderedCellsToAttackIndex;
-
+		{3, 0, 2, 1}    /* Attack East from position Southeast or Southwest */
+	};
 
-	if (!((L0557_ui_OrderedCellsToAttackIndex = getDirsWhereDestIsVisibleFromSource(targetMapX, targetMapY, attackerMapX, attackerMapY) << 1) & 0x0002)) {
+	uint16 orderedCellsToAttackIndex = getDirsWhereDestIsVisibleFromSource(targetMapX, targetMapY, attackerMapX, attackerMapY) << 1;
+	if (!(orderedCellsToAttackIndex & 0x0002))
 		cellSource++;
-	}
-	L0557_ui_OrderedCellsToAttackIndex += (cellSource >> 1) & 0x0001;
+
+	orderedCellsToAttackIndex += (cellSource >> 1) & 0x0001;
 	for (uint16 i = 0; i < 4; ++i)
-		orderedCellsToAttack[i] = g23_orderedCellsToAttack[L0557_ui_OrderedCellsToAttackIndex][i];
+		orderedCellsToAttack[i] = attackOrder[orderedCellsToAttackIndex][i];
 }
 
 void GroupMan::stealFromChampion(Group *group, uint16 championIndex) {
-	int16 L0391_i_Percentage;
-	uint16 L0392_ui_StealFromSlotIndex;
-	uint16 L0393_ui_Counter;
-	Thing L0394_T_Thing;
-	Champion *L0395_ps_Champion;
-	bool L0396_B_ObjectStolen;
 	static unsigned char G0394_auc_StealFromSlotIndices[8]; /* Initialized with 0 bytes by C loader */
 
-
-	L0396_B_ObjectStolen = false;
-	L0391_i_Percentage = 100 - _vm->_championMan->getDexterity(L0395_ps_Champion = &_vm->_championMan->_champions[championIndex]);
-	L0393_ui_Counter = _vm->getRandomNumber(8);
-	while ((L0391_i_Percentage > 0) && !_vm->_championMan->isLucky(L0395_ps_Champion, L0391_i_Percentage)) {
-		if ((L0392_ui_StealFromSlotIndex = G0394_auc_StealFromSlotIndices[L0393_ui_Counter]) == k13_ChampionSlotBackpackLine_1_1) {
-			L0392_ui_StealFromSlotIndex += _vm->getRandomNumber(17); /* Select a random slot in the backpack */
-		}
-		if (((L0394_T_Thing = L0395_ps_Champion->_slots[L0392_ui_StealFromSlotIndex]) != Thing::_none)) {
-			L0396_B_ObjectStolen = true;
-			L0394_T_Thing = _vm->_championMan->getObjectRemovedFromSlot(championIndex, L0392_ui_StealFromSlotIndex);
+	bool objectStolen = false;
+	Champion *champion = &_vm->_championMan->_champions[championIndex];
+	int16 percentage = 100 - _vm->_championMan->getDexterity(champion);
+	uint16 slotIdx = _vm->getRandomNumber(8);
+	while ((percentage > 0) && !_vm->_championMan->isLucky(champion, percentage)) {
+		uint16 stealFromSlotIndex = G0394_auc_StealFromSlotIndices[slotIdx];
+		if (stealFromSlotIndex == k13_ChampionSlotBackpackLine_1_1)
+			stealFromSlotIndex += _vm->getRandomNumber(17); /* Select a random slot in the backpack */
+
+		Thing slotThing = champion->_slots[stealFromSlotIndex];
+		if ((slotThing != Thing::_none)) {
+			objectStolen = true;
+			slotThing = _vm->_championMan->getObjectRemovedFromSlot(championIndex, stealFromSlotIndex);
 			if (group->_slot == Thing::_endOfList) {
-				group->_slot = L0394_T_Thing; /* BUG0_12 An object is cloned and appears at two different locations in the dungeon and/or inventory. The game may crash when interacting with this object. If a Giggler with no possessions steals an object that was previously in a chest and was not the last object in the chest then the objects that followed it are cloned. In the chest, the object is part of a linked list of objects that is not reset when the object is removed from the chest and placed in the inventory (but not in the dungeon), nor when it is stolen and added as the first Giggler possession. If the Giggler already has a possession before stealing the object then this does not create a cloned object.
+				group->_slot = slotThing; /* BUG0_12 An object is cloned and appears at two different locations in the dungeon and/or inventory. The game may crash when interacting with this object. If a Giggler with no possessions steals an object that was previously in a chest and was not the last object in the chest then the objects that followed it are cloned. In the chest, the object is part of a linked list of objects that is not reset when the object is removed from the chest and placed in the inventory (but not in the dungeon), nor when it is stolen and added as the first Giggler possession. If the Giggler already has a possession before stealing the object then this does not create a cloned object.
 											 The following statement is missing: L0394_T_Thing->Next = Thing::_endOfList;
 											 This creates cloned things if L0394_T_Thing->Next is not Thing::_endOfList which is the case when the object comes from a chest in which it was not the last object */
 			} else {
-				_vm->_dungeonMan->linkThingToList(L0394_T_Thing, group->_slot, kM1_MapXNotOnASquare, 0);
+				_vm->_dungeonMan->linkThingToList(slotThing, group->_slot, kM1_MapXNotOnASquare, 0);
 			}
 			_vm->_championMan->drawChampionState((ChampionIndex)championIndex);
 		}
-		++L0393_ui_Counter;
-		L0393_ui_Counter &= 0x0007;
-		L0391_i_Percentage -= 20;
+		++slotIdx;
+		slotIdx &= 0x0007;
+		percentage -= 20;
 	}
-	if (!_vm->getRandomNumber(8) || (L0396_B_ObjectStolen && _vm->getRandomNumber(2))) {
+	if (!_vm->getRandomNumber(8) || (objectStolen && _vm->getRandomNumber(2))) {
 		_activeGroups[group->getActiveGroupIndex()]._delayFleeingFromTarget = _vm->getRandomNumber(64) + 20;
 		group->setBehaviour(k5_behavior_FLEE);
 	}


Commit: c4bf70c9a864f69821821d675d244d9b2865ce41
    https://github.com/scummvm/scummvm/commit/c4bf70c9a864f69821821d675d244d9b2865ce41
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-01T00:40:11+02:00

Commit Message:
DM: Rework getChampionDamage and startWanedring

Changed paths:
    engines/dm/group.cpp



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 3b511d9..66de3fc 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1543,9 +1543,10 @@ void GroupMan::stealFromChampion(Group *group, uint16 championIndex) {
 			objectStolen = true;
 			slotThing = _vm->_championMan->getObjectRemovedFromSlot(championIndex, stealFromSlotIndex);
 			if (group->_slot == Thing::_endOfList) {
-				group->_slot = slotThing; /* BUG0_12 An object is cloned and appears at two different locations in the dungeon and/or inventory. The game may crash when interacting with this object. If a Giggler with no possessions steals an object that was previously in a chest and was not the last object in the chest then the objects that followed it are cloned. In the chest, the object is part of a linked list of objects that is not reset when the object is removed from the chest and placed in the inventory (but not in the dungeon), nor when it is stolen and added as the first Giggler possession. If the Giggler already has a possession before stealing the object then this does not create a cloned object.
-											 The following statement is missing: L0394_T_Thing->Next = Thing::_endOfList;
-											 This creates cloned things if L0394_T_Thing->Next is not Thing::_endOfList which is the case when the object comes from a chest in which it was not the last object */
+				group->_slot = slotThing;
+				/* BUG0_12 An object is cloned and appears at two different locations in the dungeon and/or inventory. The game may crash when interacting with this object. If a Giggler with no possessions steals an object that was previously in a chest and was not the last object in the chest then the objects that followed it are cloned. In the chest, the object is part of a linked list of objects that is not reset when the object is removed from the chest and placed in the inventory (but not in the dungeon), nor when it is stolen and added as the first Giggler possession. If the Giggler already has a possession before stealing the object then this does not create a cloned object.
+				The following statement is missing: L0394_T_Thing->Next = Thing::_endOfList;
+				This creates cloned things if L0394_T_Thing->Next is not Thing::_endOfList which is the case when the object comes from a chest in which it was not the last object */
 			} else {
 				_vm->_dungeonMan->linkThingToList(slotThing, group->_slot, kM1_MapXNotOnASquare, 0);
 			}
@@ -1562,142 +1563,118 @@ void GroupMan::stealFromChampion(Group *group, uint16 championIndex) {
 }
 
 int16 GroupMan::getChampionDamage(Group *group, uint16 champIndex) {
-	unsigned char g24_woundProbabilityIndexToWoundMask[4] = {32, 16, 8, 4}; // @ G0024_auc_Graphic562_WoundProbabilityIndexToWoundMask
-
-	Champion *L0562_ps_Champion;
-	int16 L0558_i_Multiple;
-#define AL0558_i_Attack L0558_i_Multiple
-#define AL0558_i_Damage L0558_i_Multiple
-	uint16 L0559_ui_Multiple;
-#define AL0559_ui_WoundTest          L0559_ui_Multiple
-#define AL0559_ui_PoisonAttack       L0559_ui_Multiple
-#define AL0559_ui_CreatureDifficulty L0559_ui_Multiple
-	uint16 L0560_ui_WoundProbabilities;
-	uint16 L0561_ui_Multiple;
-#define AL0561_ui_WoundProbabilityIndex L0561_ui_Multiple
-#define AL0561_ui_AllowedWound          L0561_ui_Multiple
-	int16 L0563_i_DoubledMapDifficulty;
-	CreatureInfo L0564_s_CreatureInfo;
-
-
-	L0562_ps_Champion = &_vm->_championMan->_champions[champIndex];
-	if (champIndex >= _vm->_championMan->_partyChampionCount) {
+	unsigned char allowedWoundMasks[4] = {32, 16, 8, 4}; // @ G0024_auc_Graphic562_WoundProbabilityIndexToWoundMask
+
+	Champion *curChampion = &_vm->_championMan->_champions[champIndex];
+	if (champIndex >= _vm->_championMan->_partyChampionCount)
 		return 0;
-	}
-	if (!L0562_ps_Champion->_currHealth) {
+
+	if (!curChampion->_currHealth)
 		return 0;
-	}
-	if (_vm->_championMan->_partyIsSleeping) {
+
+	if (_vm->_championMan->_partyIsSleeping)
 		_vm->_championMan->wakeUp();
-	}
-	L0563_i_DoubledMapDifficulty = _vm->_dungeonMan->_currMap->_difficulty << 1;
-	L0564_s_CreatureInfo = _vm->_dungeonMan->_creatureInfos[group->_type];
-	_vm->_championMan->addSkillExperience(champIndex, k7_ChampionSkillParry, L0564_s_CreatureInfo.getExperience());
-	if (_vm->_championMan->_partyIsSleeping || (((_vm->_championMan->getDexterity(L0562_ps_Champion) < (_vm->getRandomNumber(32) + L0564_s_CreatureInfo._dexterity + L0563_i_DoubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !_vm->_championMan->isLucky(L0562_ps_Champion, 60))) {
-		if ((AL0559_ui_WoundTest = _vm->getRandomNumber(65536)) & 0x0070) {
-			AL0559_ui_WoundTest &= 0x000F;
-			L0560_ui_WoundProbabilities = L0564_s_CreatureInfo._woundProbabilities;
-			for (AL0561_ui_WoundProbabilityIndex = 0; AL0559_ui_WoundTest > (L0560_ui_WoundProbabilities & 0x000F); L0560_ui_WoundProbabilities >>= 4) {
-				AL0561_ui_WoundProbabilityIndex++;
-			}
-			AL0561_ui_AllowedWound = g24_woundProbabilityIndexToWoundMask[AL0561_ui_WoundProbabilityIndex];
-		} else {
-			AL0561_ui_AllowedWound = AL0559_ui_WoundTest & 0x0001; /* 0 (Ready hand) or 1 (action hand) */
-		}
-		if ((AL0558_i_Attack = (_vm->getRandomNumber(16) + L0564_s_CreatureInfo._attack + L0563_i_DoubledMapDifficulty) - (_vm->_championMan->getSkillLevel(champIndex, k7_ChampionSkillParry) << 1)) <= 1) {
-			if (_vm->getRandomNumber(2)) {
-				goto T0230014;
+
+	int16 doubledMapDifficulty = _vm->_dungeonMan->_currMap->_difficulty << 1;
+	CreatureInfo creatureInfo = _vm->_dungeonMan->_creatureInfos[group->_type];
+	_vm->_championMan->addSkillExperience(champIndex, k7_ChampionSkillParry, creatureInfo.getExperience());
+	if (_vm->_championMan->_partyIsSleeping || (((_vm->_championMan->getDexterity(curChampion) < (_vm->getRandomNumber(32) + creatureInfo._dexterity + doubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !_vm->_championMan->isLucky(curChampion, 60))) {
+		uint16 allowedWound;
+		uint16 woundTest = _vm->getRandomNumber(65536);
+		if (woundTest & 0x0070) {
+			woundTest &= 0x000F;
+			uint16 woundProbabilities = creatureInfo._woundProbabilities;
+			uint16 woundProbabilityIndex;
+			for (woundProbabilityIndex = 0; woundTest > (woundProbabilities & 0x000F); woundProbabilityIndex++) {
+				woundProbabilities >>= 4;
 			}
-			AL0558_i_Attack = _vm->getRandomNumber(4) + 2;
+			allowedWound = allowedWoundMasks[woundProbabilityIndex];
+		} else
+			allowedWound = woundTest & 0x0001; /* 0 (Ready hand) or 1 (action hand) */
+
+		int16 attack = (_vm->getRandomNumber(16) + creatureInfo._attack + doubledMapDifficulty) - (_vm->_championMan->getSkillLevel(champIndex, k7_ChampionSkillParry) << 1);
+		if (attack <= 1) {
+			if (_vm->getRandomNumber(2))
+				return 0;
+
+			attack = _vm->getRandomNumber(4) + 2;
 		}
-		AL0558_i_Attack >>= 1;
-		AL0558_i_Attack += _vm->getRandomNumber(AL0558_i_Attack) + _vm->getRandomNumber(4);
-		AL0558_i_Attack += _vm->getRandomNumber(AL0558_i_Attack);
-		AL0558_i_Attack >>= 2;
-		AL0558_i_Attack += _vm->getRandomNumber(4) + 1;
+		attack >>= 1;
+		attack += _vm->getRandomNumber(attack) + _vm->getRandomNumber(4);
+		attack += _vm->getRandomNumber(attack);
+		attack >>= 2;
+		attack += _vm->getRandomNumber(4) + 1;
 		if (_vm->getRandomNumber(2))
-			AL0558_i_Attack -= _vm->getRandomNumber((AL0558_i_Attack >> 1) + 1) - 1;
+			attack -= _vm->getRandomNumber((attack >> 1) + 1) - 1;
 
-		AL0558_i_Damage = _vm->_championMan->addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType);
-		if (AL0558_i_Damage) {
+		int16 damage = _vm->_championMan->addPendingDamageAndWounds_getDamage(champIndex, attack, allowedWound, creatureInfo._attackType);
+		if (damage) {
 			_vm->_sound->requestPlay(k09_soundCHAMPION_0_DAMAGED + champIndex, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k2_soundModePlayOneTickLater);
 
-			AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack;
-			if (AL0559_ui_PoisonAttack && _vm->getRandomNumber(2)) {
-				AL0559_ui_PoisonAttack = _vm->_championMan->getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack);
-				if (AL0559_ui_PoisonAttack >= 0)
-					_vm->_championMan->championPoison(champIndex, AL0559_ui_PoisonAttack);
+			uint16 poisonAttack = creatureInfo._poisonAttack;
+			if (poisonAttack && _vm->getRandomNumber(2)) {
+				poisonAttack = _vm->_championMan->getStatisticAdjustedAttack(curChampion, k4_ChampionStatVitality, poisonAttack);
+				if (poisonAttack >= 0)
+					_vm->_championMan->championPoison(champIndex, poisonAttack);
 			}
-			return AL0558_i_Damage;
+			return damage;
 		}
 	}
-T0230014:
+
 	return 0;
 }
 
 void GroupMan::dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY) {
-	Group *L0363_ps_Group;
-	int16 L0364_i_CreatureType;
-
-
 	if (_dropMovingCreatureFixedPossCellCount) {
-		L0363_ps_Group = (Group *)_vm->_dungeonMan->getThingData(thing);
-		L0364_i_CreatureType = L0363_ps_Group->_type;
+		Group *group = (Group *)_vm->_dungeonMan->getThingData(thing);
+		int16 creatureType = group->_type;
 		while (_dropMovingCreatureFixedPossCellCount) {
-			dropCreatureFixedPossessions(L0364_i_CreatureType, mapX, mapY, _dropMovingCreatureFixedPossessionsCell[--_dropMovingCreatureFixedPossCellCount], k2_soundModePlayOneTickLater);
+			dropCreatureFixedPossessions(creatureType, mapX, mapY, _dropMovingCreatureFixedPossessionsCell[--_dropMovingCreatureFixedPossCellCount], k2_soundModePlayOneTickLater);
 		}
 	}
 }
 
 void GroupMan::startWanedring(int16 mapX, int16 mapY) {
-	Group *L0332_ps_Group;
-	TimelineEvent L0333_s_Event;
-
-
-	L0332_ps_Group = (Group *)_vm->_dungeonMan->getThingData(groupGetThing(mapX, mapY));
+	Group *L0332_ps_Group = (Group *)_vm->_dungeonMan->getThingData(groupGetThing(mapX, mapY));
 	if (L0332_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
 		L0332_ps_Group->setBehaviour(k0_behavior_WANDER);
 	}
-	setMapAndTime(L0333_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, (_vm->_gameTime + 1));
-	L0333_s_Event._type = k37_TMEventTypeUpdateBehaviourGroup;
-	L0333_s_Event._priority = 255 - _vm->_dungeonMan->_creatureInfos[L0332_ps_Group->_type]._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
-	L0333_s_Event._C._ticks = 0;
-	L0333_s_Event._B._location._mapX = mapX;
-	L0333_s_Event._B._location._mapY = mapY;
-	_vm->_timeline->addEventGetEventIndex(&L0333_s_Event);
+	TimelineEvent nextEvent;
+	setMapAndTime(nextEvent._mapTime, _vm->_dungeonMan->_currMapIndex, (_vm->_gameTime + 1));
+	nextEvent._type = k37_TMEventTypeUpdateBehaviourGroup;
+	nextEvent._priority = 255 - _vm->_dungeonMan->_creatureInfos[L0332_ps_Group->_type]._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */
+	nextEvent._C._ticks = 0;
+	nextEvent._B._location._mapX = mapX;
+	nextEvent._B._location._mapY = mapY;
+	_vm->_timeline->addEventGetEventIndex(&nextEvent);
 }
 
 void GroupMan::addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
-	uint16 L0339_ui_CreatureIndex;
-	Group *L0340_ps_Group;
-	ActiveGroup *L0341_ps_ActiveGroup;
-	int16 L0344_i_ActiveGroupIndex;
-
-
-	L0341_ps_ActiveGroup = _activeGroups;
-	L0344_i_ActiveGroupIndex = 0;
-	while (L0341_ps_ActiveGroup->_groupThingIndex >= 0) {
-		if (++L0344_i_ActiveGroupIndex >= _maxActiveGroupCount) {
+	ActiveGroup *activeGroup = _activeGroups;
+	int16 activeGroupIndex = 0;
+	while (activeGroup->_groupThingIndex >= 0) {
+		if (++activeGroupIndex >= _maxActiveGroupCount)
 			return;
-		}
-		L0341_ps_ActiveGroup++;
+
+		activeGroup++;
 	}
 	_currActiveGroupCount++;
 
-	L0340_ps_Group = (Group *)(_vm->_dungeonMan->_thingData[k4_GroupThingType] + 
-		_vm->_dungeonMan->_thingDataWordCount[k4_GroupThingType] * (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getIndex()));
+	activeGroup->_groupThingIndex = (thing).getIndex();
+	Group *curGroup = (Group *)(_vm->_dungeonMan->_thingData[k4_GroupThingType] + 
+		_vm->_dungeonMan->_thingDataWordCount[k4_GroupThingType] * activeGroup->_groupThingIndex);
 
-	L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells;
-	L0340_ps_Group->getActiveGroupIndex() = L0344_i_ActiveGroupIndex;
-	L0341_ps_ActiveGroup->_priorMapX = L0341_ps_ActiveGroup->_homeMapX = mapX;
-	L0341_ps_ActiveGroup->_priorMapY = L0341_ps_ActiveGroup->_homeMapY = mapY;
-	L0341_ps_ActiveGroup->_lastMoveTime = _vm->_gameTime - 127;
-	L0339_ui_CreatureIndex = L0340_ps_Group->getCount();
+	activeGroup->_cells = curGroup->_cells;
+	curGroup->getActiveGroupIndex() = activeGroupIndex;
+	activeGroup->_priorMapX = activeGroup->_homeMapX = mapX;
+	activeGroup->_priorMapY = activeGroup->_homeMapY = mapY;
+	activeGroup->_lastMoveTime = _vm->_gameTime - 127;
+	uint16 creatureIndex = curGroup->getCount();
 	do {
-		L0341_ps_ActiveGroup->_directions = (Direction)getGroupValueUpdatedWithCreatureValue(L0341_ps_ActiveGroup->_directions, L0339_ui_CreatureIndex, L0340_ps_Group->getDir());
-		L0341_ps_ActiveGroup->_aspect[L0339_ui_CreatureIndex] = 0;
-	} while (L0339_ui_CreatureIndex--);
-	getCreatureAspectUpdateTime(L0341_ps_ActiveGroup, kM1_wholeCreatureGroup, false);
+		activeGroup->_directions = (Direction)getGroupValueUpdatedWithCreatureValue(activeGroup->_directions, creatureIndex, curGroup->getDir());
+		activeGroup->_aspect[creatureIndex] = 0;
+	} while (creatureIndex--);
+	getCreatureAspectUpdateTime(activeGroup, kM1_wholeCreatureGroup, false);
 }
 
 void GroupMan::removeActiveGroup(uint16 activeGroupIndex) {


Commit: deca60efc9bf1ce4a6321603741e478820e04e1b
    https://github.com/scummvm/scummvm/commit/deca60efc9bf1ce4a6321603741e478820e04e1b
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-01T07:41:44+02:00

Commit Message:
DM: More renaming in GroupMan

Changed paths:
    engines/dm/group.cpp



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 66de3fc..31313c4 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1678,158 +1678,138 @@ void GroupMan::addActiveGroup(Thing thing, int16 mapX, int16 mapY) {
 }
 
 void GroupMan::removeActiveGroup(uint16 activeGroupIndex) {
-	ActiveGroup *L0347_ps_ActiveGroup;
-	Group *L0348_ps_Group;
-
-
-	if ((activeGroupIndex > _maxActiveGroupCount) || (_activeGroups[activeGroupIndex]._groupThingIndex < 0)) {
+	if ((activeGroupIndex > _maxActiveGroupCount) || (_activeGroups[activeGroupIndex]._groupThingIndex < 0))
 		return;
-	}
-	L0347_ps_ActiveGroup = &_activeGroups[activeGroupIndex];
-	L0348_ps_Group = &((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex];
+
+	ActiveGroup *activeGroup = &_activeGroups[activeGroupIndex];
+	Group *group = &((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex];
 	_currActiveGroupCount--;
-	L0348_ps_Group->_cells = L0347_ps_ActiveGroup->_cells;
-	L0348_ps_Group->setDir(normalizeModulo4(L0347_ps_ActiveGroup->_directions));
-	if (L0348_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
-		L0348_ps_Group->setBehaviour(k0_behavior_WANDER);
+	group->_cells = activeGroup->_cells;
+	group->setDir(normalizeModulo4(activeGroup->_directions));
+	if (group->getBehaviour() >= k4_behavior_USELESS) {
+		group->setBehaviour(k0_behavior_WANDER);
 	}
-	L0347_ps_ActiveGroup->_groupThingIndex = -1;
+	activeGroup->_groupThingIndex = -1;
 }
 
 void GroupMan::removeAllActiveGroups() {
-	for (int16 L0397_ui_ActiveGroupIndex = 0; _currActiveGroupCount > 0; L0397_ui_ActiveGroupIndex++) {
-		if (_activeGroups[L0397_ui_ActiveGroupIndex]._groupThingIndex >= 0) {
-			removeActiveGroup(L0397_ui_ActiveGroupIndex);
+	for (int16 idx = 0; _currActiveGroupCount > 0; idx++) {
+		if (_activeGroups[idx]._groupThingIndex >= 0) {
+			removeActiveGroup(idx);
 		}
 	}
 }
 
 void GroupMan::addAllActiveGroups() {
-	uint16 L0398_ui_MapX;
-	uint16 L0399_ui_MapY;
-	Thing L0400_T_Thing;
-	byte *L0401_puc_Square;
-	Thing *L0402_pT_SquareFirstThing;
-
-
-	L0401_puc_Square = _vm->_dungeonMan->_currMapData[0];
-	L0402_pT_SquareFirstThing = &_vm->_dungeonMan->_squareFirstThings[_vm->_dungeonMan->_currMapColCumulativeSquareFirstThingCount[0]];
-	for (L0398_ui_MapX = 0; L0398_ui_MapX < _vm->_dungeonMan->_currMapWidth; L0398_ui_MapX++) {
-		for (L0399_ui_MapY = 0; L0399_ui_MapY < _vm->_dungeonMan->_currMapHeight; L0399_ui_MapY++) {
-			if (getFlag(*L0401_puc_Square++, k0x0010_ThingListPresent)) {
-				L0400_T_Thing = *L0402_pT_SquareFirstThing++;
+	byte *curSquare = _vm->_dungeonMan->_currMapData[0];
+	Thing *squareCurThing = &_vm->_dungeonMan->_squareFirstThings[_vm->_dungeonMan->_currMapColCumulativeSquareFirstThingCount[0]];
+	for (uint16 mapX = 0; mapX < _vm->_dungeonMan->_currMapWidth; mapX++) {
+		for (uint16 mapY = 0; mapY < _vm->_dungeonMan->_currMapHeight; mapY++) {
+			if (getFlag(*curSquare++, k0x0010_ThingListPresent)) {
+				Thing curThing = *squareCurThing++;
 				do {
-					if (L0400_T_Thing.getType() == k4_GroupThingType) {
-						groupDeleteEvents(L0398_ui_MapX, L0399_ui_MapY);
-						addActiveGroup(L0400_T_Thing, L0398_ui_MapX, L0399_ui_MapY);
-						startWanedring(L0398_ui_MapX, L0399_ui_MapY);
+					if (curThing.getType() == k4_GroupThingType) {
+						groupDeleteEvents(mapX, mapY);
+						addActiveGroup(curThing, mapX, mapY);
+						startWanedring(mapX, mapY);
 						break;
 					}
-				} while ((L0400_T_Thing = _vm->_dungeonMan->getNextThing(L0400_T_Thing)) != Thing::_endOfList);
+					curThing = _vm->_dungeonMan->getNextThing(curThing);
+				} while (curThing != Thing::_endOfList);
 			}
 		}
 	}
 }
 
 Thing GroupMan::groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, Direction dir, int16 mapX, int16 mapY) {
-	Thing L0349_T_GroupThing;
-	uint16 L0350_ui_BaseHealth;
-	uint16 L0351_ui_Cell = 0;
-	uint16 L0352_ui_GroupCells = 0;
-	Group* L0353_ps_Group;
-	CreatureInfo* L0354_ps_CreatureInfo;
-	bool L0355_B_SeveralCreaturesInGroup;
-
-
-	if (((_currActiveGroupCount >= (_maxActiveGroupCount - 5)) && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex)) || ((L0349_T_GroupThing = _vm->_dungeonMan->getUnusedThing(k4_GroupThingType)) == Thing::_none)) {
+	Thing groupThing = _vm->_dungeonMan->getUnusedThing(k4_GroupThingType);
+	if (((_currActiveGroupCount >= (_maxActiveGroupCount - 5)) && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex))
+		|| (groupThing == Thing::_none)) {
 		return Thing::_none;
 	}
-	L0353_ps_Group = (Group*)_vm->_dungeonMan->getThingData(L0349_T_GroupThing);
-	L0353_ps_Group->_slot = Thing::_endOfList;
-	L0353_ps_Group->setDoNotDiscard(false);
-	L0353_ps_Group->setDir(dir);
-	L0353_ps_Group->setCount(creatureCount);
-	L0355_B_SeveralCreaturesInGroup = creatureCount;
-	if (L0355_B_SeveralCreaturesInGroup)
-		L0351_ui_Cell = _vm->getRandomNumber(4);
+	Group *group = (Group*)_vm->_dungeonMan->getThingData(groupThing);
+	group->_slot = Thing::_endOfList;
+	group->setDoNotDiscard(false);
+	group->setDir(dir);
+	group->setCount(creatureCount);
+	bool severalCreaturesInGroup = creatureCount;
+	uint16 cell = 0;
+	uint16 groupCells = 0;
+	if (severalCreaturesInGroup)
+		cell = _vm->getRandomNumber(4);
 	else
-		L0352_ui_GroupCells = k255_CreatureTypeSingleCenteredCreature;
+		groupCells = k255_CreatureTypeSingleCenteredCreature;
 
-	L0354_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[L0353_ps_Group->_type = creatureType];
-	L0350_ui_BaseHealth = L0354_ps_CreatureInfo->_baseHealth;
+	CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type = creatureType];
+	uint16 baseHealth = creatureInfo->_baseHealth;
 	do {
-		L0353_ps_Group->_health[creatureCount] = (L0350_ui_BaseHealth * healthMultiplier) + _vm->getRandomNumber((L0350_ui_BaseHealth >> 2) + 1);
-		if (L0355_B_SeveralCreaturesInGroup) {
-			L0352_ui_GroupCells = getGroupValueUpdatedWithCreatureValue(L0352_ui_GroupCells, creatureCount, L0351_ui_Cell++);
-			if (getFlag(L0354_ps_CreatureInfo->_attributes, k0x0003_MaskCreatureInfo_size) == k1_MaskCreatureSizeHalf) {
-				L0351_ui_Cell++;
-			}
-			L0351_ui_Cell &= 0x0003;
+		group->_health[creatureCount] = (baseHealth * healthMultiplier) + _vm->getRandomNumber((baseHealth >> 2) + 1);
+		if (severalCreaturesInGroup) {
+			groupCells = getGroupValueUpdatedWithCreatureValue(groupCells, creatureCount, cell++);
+			if (getFlag(creatureInfo->_attributes, k0x0003_MaskCreatureInfo_size) == k1_MaskCreatureSizeHalf)
+				cell++;
+
+			cell &= 0x0003;
 		}
 	} while (creatureCount--);
-	L0353_ps_Group->_cells = L0352_ui_GroupCells;
-	if (_vm->_moveSens->getMoveResult(L0349_T_GroupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) { /* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile impact (in which case the thing data was marked as unused) or the party is on the destination square and an event is created to move the creature into the dungeon later (in which case the thing is referenced in the event) */
+	group->_cells = groupCells;
+	if (_vm->_moveSens->getMoveResult(groupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) {
+		/* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile
+		   impact (in which case the thing data was marked as unused) or the party is on the destination
+		   square and an event is created to move the creature into the dungeon later
+		   (in which case the thing is referenced in the event) */
 		return Thing::_none;
 	}
 	_vm->_sound->requestPlay(k17_soundBUZZ, mapX, mapY, k1_soundModePlayIfPrioritized);
-	return L0349_T_GroupThing;
+	return groupThing;
 }
 
 bool GroupMan::isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY) {
-	int16 L0544_i_SquareType;
+	int16 squareType = Square(_vm->_dungeonMan->getSquare(mapX, mapY)).getType();
 
-	return (((L0544_i_SquareType = Square(_vm->_dungeonMan->getSquare(mapX, mapY)).getType()) == k1_CorridorElemType)
-			|| (L0544_i_SquareType == k5_ElementTypeTeleporter) || (L0544_i_SquareType == k2_ElementTypePit) || (L0544_i_SquareType == k4_DoorElemType));
+	return ((squareType == k1_CorridorElemType) || (squareType == k5_ElementTypeTeleporter)
+		 || (squareType == k2_ElementTypePit) || (squareType == k4_DoorElemType));
 }
 
 int16 GroupMan::getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 partyY, uint16 champCell) {
-	uint16 L0321_ui_Counter;
-	int16 L0322_i_CreatureOrdinal;
-	Thing L0323_T_GroupThing;
-	Group* L0324_ps_Group;
-	signed char L0325_auc_OrderedCellsToAttack[4];
-
-	L0323_T_GroupThing = groupGetThing(groupX, groupY);
-	if (L0323_T_GroupThing == Thing::_endOfList)
+	Thing groupThing = groupGetThing(groupX, groupY);
+	if (groupThing == Thing::_endOfList)
 		return 0;
 
-	L0324_ps_Group = (Group*)_vm->_dungeonMan->getThingData(L0323_T_GroupThing);
-	setOrderedCellsToAttack(L0325_auc_OrderedCellsToAttack, groupX, groupY, partyX, partyY, champCell);
-	L0321_ui_Counter = 0;
+	Group *group = (Group*)_vm->_dungeonMan->getThingData(groupThing);
+	signed char orderedCellsToAttack[4];
+	setOrderedCellsToAttack(orderedCellsToAttack, groupX, groupY, partyX, partyY, champCell);
+	uint16 counter = 0;
 	for (;;) { /*_Infinite loop_*/
-		L0322_i_CreatureOrdinal = getCreatureOrdinalInCell(L0324_ps_Group, L0325_auc_OrderedCellsToAttack[L0321_ui_Counter]);
-		if (L0322_i_CreatureOrdinal)
-			return L0322_i_CreatureOrdinal;
+		int16 creatureOrdinal = getCreatureOrdinalInCell(group, orderedCellsToAttack[counter]);
+		if (creatureOrdinal)
+			return creatureOrdinal;
 
-		L0321_ui_Counter++;
+		counter++;
 	}
 }
 
 int16 GroupMan::getMeleeActionDamage(Champion* champ, int16 champIndex, Group* group, int16 creatureIndex, int16 mapX, int16 mapY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex) {
 	int16 L0565_i_Damage = 0;
 	int16 L0566_i_Damage = 0;
-	int16 L0567_i_DoubledMapDifficulty;
 	int16 L0568_i_Defense;
 	int16 L0569_i_Outcome;
-	bool L0570_B_ActionHitsNonMaterialCreatures;
-	int16 L0571_i_ActionHandObjectIconIndex;
-	CreatureInfo* L0572_ps_CreatureInfo;
 
-	if (champIndex >= _vm->_championMan->_partyChampionCount) {
+	if (champIndex >= _vm->_championMan->_partyChampionCount)
 		return 0;
-	}
-	if (!champ->_currHealth) {
+
+	if (!champ->_currHealth)
 		return 0;
-	}
-	L0567_i_DoubledMapDifficulty = _vm->_dungeonMan->_currMap->_difficulty << 1;
-	L0572_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type];
-	L0571_i_ActionHandObjectIconIndex = _vm->_objectMan->getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
-	L0570_B_ActionHitsNonMaterialCreatures = getFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
-	if (L0570_B_ActionHitsNonMaterialCreatures)
+
+	int16 doubledMapDifficulty = _vm->_dungeonMan->_currMap->_difficulty << 1;
+	CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type];
+	int16 actionHandObjectIconIndex = _vm->_objectMan->getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
+	bool actionHitsNonMaterialCreatures = getFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
+	if (actionHitsNonMaterialCreatures)
 		clearFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
 
-	if ((!getFlag(L0572_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) || L0570_B_ActionHitsNonMaterialCreatures) &&
-		((_vm->_championMan->getDexterity(champ) > (_vm->getRandomNumber(32) + L0572_ps_CreatureInfo->_dexterity + L0567_i_DoubledMapDifficulty - 16)) ||
+	if ((!getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) || actionHitsNonMaterialCreatures) &&
+		((_vm->_championMan->getDexterity(champ) > (_vm->getRandomNumber(32) + creatureInfo->_dexterity + doubledMapDifficulty - 16)) ||
 		(!_vm->getRandomNumber(4)) ||
 		 (_vm->_championMan->isLucky(champ, 75 - actionHitProbability)))) {
 
@@ -1839,10 +1819,10 @@ int16 GroupMan::getMeleeActionDamage(Champion* champ, int16 champIndex, Group* g
 
 		L0565_i_Damage += _vm->getRandomNumber((L0565_i_Damage >> 1) + 1);
 		L0565_i_Damage = ((long)L0565_i_Damage * (long)actionDamageFactor) >> 5;
-		L0568_i_Defense = _vm->getRandomNumber(32) + L0572_ps_CreatureInfo->_defense + L0567_i_DoubledMapDifficulty;
-		if (L0571_i_ActionHandObjectIconIndex == k39_IconIndiceWeaponDiamondEdge)
+		L0568_i_Defense = _vm->getRandomNumber(32) + creatureInfo->_defense + doubledMapDifficulty;
+		if (actionHandObjectIconIndex == k39_IconIndiceWeaponDiamondEdge)
 			L0568_i_Defense -= L0568_i_Defense >> 2;
-		else if (L0571_i_ActionHandObjectIconIndex == k43_IconIndiceWeaponHardcleaveExecutioner)
+		else if (actionHandObjectIconIndex == k43_IconIndiceWeaponHardcleaveExecutioner)
 			L0568_i_Defense -= L0568_i_Defense >> 3;
 
 		L0565_i_Damage += _vm->getRandomNumber(32) - L0568_i_Defense;
@@ -1854,11 +1834,12 @@ T0231009:
 				goto T0231015;
 
 			L0565_i_Damage++;
-			if (((L0566_i_Damage += _vm->getRandomNumber(16)) > 0) || (_vm->getRandomNumber(2))) {
+			L0566_i_Damage += _vm->getRandomNumber(16);
+
+			if ((L0566_i_Damage > 0) || (_vm->getRandomNumber(2))) {
 				L0565_i_Damage += _vm->getRandomNumber(4);
-				if (!_vm->getRandomNumber(4)) {
+				if (!_vm->getRandomNumber(4))
 					L0565_i_Damage += MAX(0, L0566_i_Damage + _vm->getRandomNumber(16));
-				}
 			}
 		}
 		L0565_i_Damage >>= 1;
@@ -1866,13 +1847,16 @@ T0231009:
 		L0565_i_Damage += _vm->getRandomNumber(L0565_i_Damage);
 		L0565_i_Damage >>= 2;
 		L0565_i_Damage += _vm->getRandomNumber(4) + 1;
-		if ((L0571_i_ActionHandObjectIconIndex == k40_IconIndiceWeaponVorpalBlade) && !getFlag(L0572_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) && !(L0565_i_Damage >>= 1))
+		if ((actionHandObjectIconIndex == k40_IconIndiceWeaponVorpalBlade)
+			&& !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)
+			&& !(L0565_i_Damage >>= 1))
 			goto T0231015;
-		if (_vm->getRandomNumber(64) < _vm->_championMan->getSkillLevel(champIndex, skillIndex)) {
+
+		if (_vm->getRandomNumber(64) < _vm->_championMan->getSkillLevel(champIndex, skillIndex))
 			L0565_i_Damage += L0565_i_Damage + 10;
-		}
+
 		L0569_i_Outcome = groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapY, L0565_i_Damage, true);
-		_vm->_championMan->addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * L0572_ps_CreatureInfo->getExperience() >> 4) + 3);
+		_vm->_championMan->addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * creatureInfo->getExperience() >> 4) + 3);
 		_vm->_championMan->decrementStamina(champIndex, _vm->getRandomNumber(4) + 4);
 		goto T0231016;
 	}
@@ -1889,31 +1873,26 @@ T0231016:
 }
 
 void GroupMan::fluxCageAction(int16 mapX, int16 mapY) {
-	Thing L0545_T_Thing;
-	int16 L0546_i_Multiple;
-#define AL0546_i_SquareType    L0546_i_Multiple
-#define AL0546_i_FluxcageCount L0546_i_Multiple
-	TimelineEvent L0547_s_Event;
-
-
-	AL0546_i_SquareType = _vm->_dungeonMan->getSquare(mapX, mapY).getType();
-	if ((AL0546_i_SquareType == k0_ElementTypeWall) || (AL0546_i_SquareType == k3_ElementTypeStairs))
+	SquareType squareType = _vm->_dungeonMan->getSquare(mapX, mapY).getType();
+	if ((squareType == k0_WallElemType) || (squareType == k3_StairsElemType))
 		return;
 
-	L0545_T_Thing = _vm->_dungeonMan->getUnusedThing(k15_ExplosionThingType);
-	if (L0545_T_Thing == Thing::_none)
+	Thing unusedThing = _vm->_dungeonMan->getUnusedThing(k15_ExplosionThingType);
+	if (unusedThing == Thing::_none)
 		return;
 
-	_vm->_dungeonMan->linkThingToList(L0545_T_Thing, Thing(0), mapX, mapY);
-	(((Explosion*)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[L0545_T_Thing.getIndex()]).setType(k50_ExplosionType_Fluxcage);
-	setMapAndTime(L0547_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + 100);
-	L0547_s_Event._type = k24_TMEventTypeRemoveFluxcage;
-	L0547_s_Event._priority = 0;
-	L0547_s_Event._C._slot = L0545_T_Thing.toUint16();
-	L0547_s_Event._B._location._mapX = mapX;
-	L0547_s_Event._B._location._mapY = mapY;
-	L0547_s_Event._B._location._mapY = mapY;
-	_vm->_timeline->addEventGetEventIndex(&L0547_s_Event);
+	_vm->_dungeonMan->linkThingToList(unusedThing, Thing(0), mapX, mapY);
+	(((Explosion*)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[unusedThing.getIndex()]).setType(k50_ExplosionType_Fluxcage);
+	TimelineEvent newEvent;
+	setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + 100);
+	newEvent._type = k24_TMEventTypeRemoveFluxcage;
+	newEvent._priority = 0;
+	newEvent._C._slot = unusedThing.toUint16();
+	newEvent._B._location._mapX = mapX;
+	newEvent._B._location._mapY = mapY;
+	newEvent._B._location._mapY = mapY;
+	_vm->_timeline->addEventGetEventIndex(&newEvent);
+	int16 AL0546_i_FluxcageCount;
 	if (isLordChaosOnSquare(mapX, mapY - 1)) {
 		mapY--;
 		AL0546_i_FluxcageCount = isFluxcageOnSquare(mapX + 1, mapY);
@@ -1945,85 +1924,78 @@ T0224008:
 }
 
 uint16 GroupMan::isLordChaosOnSquare(int16 mapX, int16 mapY) {
-	Thing L0542_T_Thing;
-	Group* L0543_ps_Group;
-
-	L0542_T_Thing = groupGetThing(mapX, mapY);
-	if (L0542_T_Thing == Thing::_endOfList)
+	Thing thing = groupGetThing(mapX, mapY);
+	if (thing == Thing::_endOfList)
 		return 0;
 
-	L0543_ps_Group = (Group*)_vm->_dungeonMan->getThingData(L0542_T_Thing);
-	if (L0543_ps_Group->_type == k23_CreatureTypeLordChaos)
-		return L0542_T_Thing.toUint16();
+	Group *group = (Group *)_vm->_dungeonMan->getThingData(thing);
+	if (group->_type == k23_CreatureTypeLordChaos)
+		return thing.toUint16();
 
 	return 0;
 }
 
 bool GroupMan::isFluxcageOnSquare(int16 mapX, int16 mapY) {
-	Thing L0540_T_Thing;
-	int16 L0541_i_SquareType;
-
-	L0541_i_SquareType = _vm->_dungeonMan->getSquare(mapX, mapY).getType();
-	if ((L0541_i_SquareType == k0_ElementTypeWall) || (L0541_i_SquareType == k3_ElementTypeStairs))
+	SquareType squareType = _vm->_dungeonMan->getSquare(mapX, mapY).getType();
+	if ((squareType == k0_WallElemType) || (squareType == k3_StairsElemType))
 		return false;
 
-	L0540_T_Thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
-	while (L0540_T_Thing != Thing::_endOfList) {
-		if ((L0540_T_Thing.getType() == k15_ExplosionThingType) && (((Explosion*)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[L0540_T_Thing.getIndex()].getType() == k50_ExplosionType_Fluxcage)) {
+	Thing thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+	while (thing != Thing::_endOfList) {
+		if ((thing.getType() == k15_ExplosionThingType) && (((Explosion*)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[thing.getIndex()].getType() == k50_ExplosionType_Fluxcage))
 			return true;
-		}
-		L0540_T_Thing = _vm->_dungeonMan->getNextThing(L0540_T_Thing);
+
+		thing = _vm->_dungeonMan->getNextThing(thing);
 	}
 	return false;
 }
 
 void GroupMan::fuseAction(uint16 mapX, uint16 mapY) {
-	int16 L0548_i_MapX;
-	int16 L0549_i_MapY;
-	uint16 L0551_ui_FluxcageCount;
-	uint16 L0552_ui_FluxcageIndex;
-	uint16 L0553_ui_Counter;
-	bool L0554_aB_Fluxcages[4];
-	Thing L0555_T_LordChaosThing;
-
-	if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_currMapHeight)) {
+	if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_currMapHeight))
 		return;
-	}
 
 	_vm->_projexpl->createExplosion(Thing::_explHarmNonMaterial, 255, mapX, mapY, k255_CreatureTypeSingleCenteredCreature); /* BUG0_17 The game crashes after the Fuse action is performed while looking at a wall on a map boundary. An explosion thing is created on the square in front of the party but there is no check to ensure the square coordinates are in the map bounds. This corrupts a memory location and leads to a game crash */
-	L0555_T_LordChaosThing = Thing(isLordChaosOnSquare(mapX, mapY));
-	if (L0555_T_LordChaosThing.toUint16()) {
-		L0551_ui_FluxcageCount = (L0554_aB_Fluxcages[0] = isFluxcageOnSquare(mapX - 1, mapY)) +
-			(L0554_aB_Fluxcages[1] = isFluxcageOnSquare(mapX + 1, mapY)) +
-			(L0554_aB_Fluxcages[2] = isFluxcageOnSquare(mapX, mapY - 1)) +
-			(L0554_aB_Fluxcages[3] = isFluxcageOnSquare(mapX, mapY + 1));
-		while (L0551_ui_FluxcageCount++ < 4) {
-			L0548_i_MapX = mapX;
-			L0549_i_MapY = mapY;
-			L0552_ui_FluxcageIndex = _vm->getRandomNumber(4);
-			for (L0553_ui_Counter = 5; --L0553_ui_Counter; L0552_ui_FluxcageIndex = returnNextVal(L0552_ui_FluxcageIndex)) {
-				if (!L0554_aB_Fluxcages[L0552_ui_FluxcageIndex]) {
-					L0554_aB_Fluxcages[L0552_ui_FluxcageIndex] = true;
-					switch (L0552_ui_FluxcageIndex) {
+	Thing lordChaosThing = Thing(isLordChaosOnSquare(mapX, mapY));
+	if (lordChaosThing.toUint16()) {
+		bool isFluxcages[4];
+		isFluxcages[0] = isFluxcageOnSquare(mapX - 1, mapY);
+		isFluxcages[1] = isFluxcageOnSquare(mapX + 1, mapY);
+		isFluxcages[2] = isFluxcageOnSquare(mapX, mapY - 1);
+		isFluxcages[3] = isFluxcageOnSquare(mapX, mapY + 1);
+
+		uint16 fluxcageCount = 0;
+		for (int i = 0; i < 4; i++) {
+			if (isFluxcages[i])
+				fluxcageCount++;
+		}
+
+		while (fluxcageCount++ < 4) {
+			int16 destMapX = mapX;
+			int16 destMapY = mapY;
+			uint16 fluxcageIndex = _vm->getRandomNumber(4);
+			for (uint16 i = 5; --i; fluxcageIndex = returnNextVal(fluxcageIndex)) {
+				if (!isFluxcages[fluxcageIndex]) {
+					isFluxcages[fluxcageIndex] = true;
+					switch (fluxcageIndex) {
 					case 0:
-						L0548_i_MapX--;
+						destMapX--;
 						break;
 					case 1:
-						L0548_i_MapX++;
+						destMapX++;
 						break;
 					case 2:
-						L0549_i_MapY--;
+						destMapY--;
 						break;
 					case 3:
-						L0549_i_MapY++;
+						destMapY++;
 					}
 					break;
 				}
 			}
-			if (isSquareACorridorTeleporterPitOrDoor(L0548_i_MapX, L0549_i_MapY)) {
-				if (!_vm->_moveSens->getMoveResult(L0555_T_LordChaosThing, mapX, mapY, L0548_i_MapX, L0549_i_MapY)) {
-					startWanedring(L0548_i_MapX, L0549_i_MapY);
-				}
+			if (isSquareACorridorTeleporterPitOrDoor(destMapX, destMapY)) {
+				if (!_vm->_moveSens->getMoveResult(lordChaosThing, mapX, mapY, destMapX, destMapY))
+					startWanedring(destMapX, destMapY);
+
 				return;
 			}
 		}


Commit: 40da6882afba07f598fc8b023d14427808e3c1a7
    https://github.com/scummvm/scummvm/commit/40da6882afba07f598fc8b023d14427808e3c1a7
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-01T07:48:01+02:00

Commit Message:
DM: Remove GOTOs in fluxCageAction

Changed paths:
    engines/dm/group.cpp



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 31313c4..5321d0e 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1892,35 +1892,28 @@ void GroupMan::fluxCageAction(int16 mapX, int16 mapY) {
 	newEvent._B._location._mapY = mapY;
 	newEvent._B._location._mapY = mapY;
 	_vm->_timeline->addEventGetEventIndex(&newEvent);
-	int16 AL0546_i_FluxcageCount;
+	int16 fluxcageCount;
 	if (isLordChaosOnSquare(mapX, mapY - 1)) {
 		mapY--;
-		AL0546_i_FluxcageCount = isFluxcageOnSquare(mapX + 1, mapY);
-		goto T0224005;
-	}
-	if (isLordChaosOnSquare(mapX - 1, mapY)) {
+		fluxcageCount = isFluxcageOnSquare(mapX + 1, mapY);
+		fluxcageCount += isFluxcageOnSquare(mapX, mapY - 1) + isFluxcageOnSquare(mapX - 1, mapY);
+	} else if (isLordChaosOnSquare(mapX - 1, mapY)) {
 		mapX--;
-		AL0546_i_FluxcageCount = isFluxcageOnSquare(mapX, mapY + 1);
-T0224005:
-		AL0546_i_FluxcageCount += isFluxcageOnSquare(mapX, mapY - 1) + isFluxcageOnSquare(mapX - 1, mapY);
-	} else {
-		if (isLordChaosOnSquare(mapX + 1, mapY)) {
-			mapX++;
-			AL0546_i_FluxcageCount = isFluxcageOnSquare(mapX, mapY - 1);
-			goto T0224008;
-		}
-		if (isLordChaosOnSquare(mapX, mapY + 1)) {
-			mapY++;
-			AL0546_i_FluxcageCount = isFluxcageOnSquare(mapX - 1, mapY);
-T0224008:
-			AL0546_i_FluxcageCount += isFluxcageOnSquare(mapX, mapY + 1) + isFluxcageOnSquare(mapX + 1, mapY);
-		} else {
-			AL0546_i_FluxcageCount = 0;
-		}
-	}
-	if (AL0546_i_FluxcageCount == 2) {
+		fluxcageCount = isFluxcageOnSquare(mapX, mapY + 1);
+		fluxcageCount += isFluxcageOnSquare(mapX, mapY - 1) + isFluxcageOnSquare(mapX - 1, mapY);
+	} else if (isLordChaosOnSquare(mapX + 1, mapY)) {
+		mapX++;
+		fluxcageCount = isFluxcageOnSquare(mapX, mapY - 1);
+		fluxcageCount += isFluxcageOnSquare(mapX, mapY + 1) + isFluxcageOnSquare(mapX + 1, mapY);
+	} else if (isLordChaosOnSquare(mapX, mapY + 1)) {
+		mapY++;
+		fluxcageCount = isFluxcageOnSquare(mapX - 1, mapY);
+		fluxcageCount += isFluxcageOnSquare(mapX, mapY + 1) + isFluxcageOnSquare(mapX + 1, mapY);
+	} else
+		fluxcageCount = 0;
+
+	if (fluxcageCount == 2)
 		processEvents29to41(mapX, mapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
-	}
 }
 
 uint16 GroupMan::isLordChaosOnSquare(int16 mapX, int16 mapY) {


Commit: d32f6f8388c73df53566bf7e54e34d760eee4714
    https://github.com/scummvm/scummvm/commit/d32f6f8388c73df53566bf7e54e34d760eee4714
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-01T22:01:22+02:00

Commit Message:
DM: Fix a typo in the spelling of startWandering()

Changed paths:
    engines/dm/group.cpp
    engines/dm/group.h
    engines/dm/menus.cpp
    engines/dm/movesens.cpp



diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 5321d0e..901661f 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1634,7 +1634,7 @@ void GroupMan::dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16
 	}
 }
 
-void GroupMan::startWanedring(int16 mapX, int16 mapY) {
+void GroupMan::startWandering(int16 mapX, int16 mapY) {
 	Group *L0332_ps_Group = (Group *)_vm->_dungeonMan->getThingData(groupGetThing(mapX, mapY));
 	if (L0332_ps_Group->getBehaviour() >= k4_behavior_USELESS) {
 		L0332_ps_Group->setBehaviour(k0_behavior_WANDER);
@@ -1711,7 +1711,7 @@ void GroupMan::addAllActiveGroups() {
 					if (curThing.getType() == k4_GroupThingType) {
 						groupDeleteEvents(mapX, mapY);
 						addActiveGroup(curThing, mapX, mapY);
-						startWanedring(mapX, mapY);
+						startWandering(mapX, mapY);
 						break;
 					}
 					curThing = _vm->_dungeonMan->getNextThing(curThing);
@@ -1987,7 +1987,7 @@ void GroupMan::fuseAction(uint16 mapX, uint16 mapY) {
 			}
 			if (isSquareACorridorTeleporterPitOrDoor(destMapX, destMapY)) {
 				if (!_vm->_moveSens->getMoveResult(lordChaosThing, mapX, mapY, destMapX, destMapY))
-					startWanedring(destMapX, destMapY);
+					startWandering(destMapX, destMapY);
 
 				return;
 			}
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 5d67d0a..02f6927 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -228,7 +228,7 @@ public:
 	void stealFromChampion(Group *group, uint16 championIndex); // @ F0193_GROUP_StealFromChampion
 	int16 getChampionDamage(Group *group, uint16 champIndex); // @ F0230_GROUP_GetChampionDamage
 	void dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY); // @ F0187_GROUP_DropMovingCreatureFixedPossessions
-	void startWanedring(int16 mapX, int16 mapY); // @ F0180_GROUP_StartWandering
+	void startWandering(int16 mapX, int16 mapY); // @ F0180_GROUP_StartWandering
 	void addActiveGroup(Thing thing, int16 mapX, int16 mapY); // @ F0183_GROUP_AddActiveGroup
 	void removeActiveGroup(uint16 activeGroupIndex); // @ F0184_GROUP_RemoveActiveGroup
 	void removeAllActiveGroups(); // @ F0194_GROUP_RemoveAllActiveGroups
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index fe6cc29..2c56382 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -1543,7 +1543,7 @@ bool MenuMan::isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, in
 		L1235_ps_ActiveGroup = &_vm->_groupMan->_activeGroups[L1233_ps_Group->getActiveGroupIndex()];
 		if (L1233_ps_Group->getBehaviour() == k6_behavior_ATTACK) {
 			_vm->_groupMan->stopAttacking(L1235_ps_ActiveGroup, mapX, mapY);
-			_vm->_groupMan->startWanedring(mapX, mapY);
+			_vm->_groupMan->startWandering(mapX, mapY);
 		}
 		L1233_ps_Group->setBehaviour(k5_behavior_FLEE);
 		L1235_ps_ActiveGroup->_delayFleeingFromTarget = ((16 - L1230_ui_FearResistance) << 2) / L1234_ps_CreatureInfo->_movementTicks;
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 5d7d7e1..c437e1c 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -499,7 +499,7 @@ bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destM
 					processThingAdditionOrRemoval(destMapX, destMapY, thing, false, true);
 				}
 				if (L0720_ui_MoveGroupResult || (mapX < 0)) { /* If group moved from one map to another or if it was just placed on a square */
-					_vm->_groupMan->startWanedring(destMapX, destMapY);
+					_vm->_groupMan->startWandering(destMapX, destMapY);
 				}
 				_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
 				if (mapX >= 0) {


Commit: 0d7481b2a5acb77e32bec8763fd97de8c8cd4185
    https://github.com/scummvm/scummvm/commit/0d7481b2a5acb77e32bec8763fd97de8c8cd4185
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-02T07:50:18+02:00

Commit Message:
DM: More renaming in InventoryMan, some refactoring

Changed paths:
    engines/dm/inventory.cpp
    engines/dm/inventory.h



diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index ab8cf8b..85bf916 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -43,27 +43,27 @@
 namespace DM {
 
 void InventoryMan::initConstants() {
-	static const char* G0428_apc_SkillLevelNames_EN_ANY[15] = {"NEOPHYTE", "NOVICE", "APPRENTICE", "JOURNEYMAN", "CRAFTSMAN",
+	static const char* skillLevelNamesEN[15] = {"NEOPHYTE", "NOVICE", "APPRENTICE", "JOURNEYMAN", "CRAFTSMAN",
 		"ARTISAN", "ADEPT", "EXPERT", "` MASTER", "a MASTER","b MASTER", "c MASTER", "d MASTER", "e MASTER", "ARCHMASTER"};
-	static const char* G0428_apc_SkillLevelNames_DE_DEU[15] = {"ANFAENGER", "NEULING", "LEHRLING", "ARBEITER", "GESELLE", "HANDWERKR", "FACHMANN",
+	static const char* skillLevelNamesDE[15] = {"ANFAENGER", "NEULING", "LEHRLING", "ARBEITER", "GESELLE", "HANDWERKR", "FACHMANN",
 		"EXPERTE", "` MEISTER", "a MEISTER", "b MEISTER", "c MEISTER", "d MEISTER", "e MEISTER", "ERZMEISTR"};
-	static const char* G0428_apc_SkillLevelNames_FR_FRA[15] = {"NEOPHYTE", "NOVICE", "APPRENTI", "COMPAGNON", "ARTISAN", "PATRON",
+	static const char* skillLevelNamesFR[15] = {"NEOPHYTE", "NOVICE", "APPRENTI", "COMPAGNON", "ARTISAN", "PATRON",
 		"ADEPTE", "EXPERT", "MAITRE '", "MAITRE a", "MAITRE b", "MAITRE c", "MAITRE d", "MAITRE e", "SUR-MAITRE"};
-	const char **g428_byLanguage;
+	const char **translatedSkillLevel;
 	switch (_vm->getGameLanguage()) { // localized
 	default:
 	case Common::EN_ANY:
-		g428_byLanguage = G0428_apc_SkillLevelNames_EN_ANY;
+		translatedSkillLevel = skillLevelNamesEN;
 		break;
 	case Common::DE_DEU:
-		g428_byLanguage = G0428_apc_SkillLevelNames_DE_DEU;
+		translatedSkillLevel = skillLevelNamesDE;
 		break;
 	case Common::FR_FRA:
-		g428_byLanguage = G0428_apc_SkillLevelNames_FR_FRA;
+		translatedSkillLevel = skillLevelNamesFR;
 		break;
 	}
 	for (int i = 0; i < 15; ++i)
-		_skillLevelNames[i] = g428_byLanguage[i];
+		_skillLevelNames[i] = translatedSkillLevel[i];
 
 	_boxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel
 }
@@ -84,34 +84,27 @@ InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
 }
 
 void InventoryMan::toggleInventory(ChampionIndex championIndex) {
-	static Box g41_BoxFloppyZzzCross(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
+	static Box boxFloppyZzzCross(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
 
-
-	uint16 L1102_ui_Multiple;
-#define AL1102_ui_InventoryChampionOrdinal L1102_ui_Multiple
-#define AL1102_ui_SlotIndex                L1102_ui_Multiple
-	Champion* L1103_ps_Champion;
-
-
-	if ((championIndex != k4_ChampionCloseInventory) && !_vm->_championMan->_champions[championIndex]._currHealth) {
+	if ((championIndex != k4_ChampionCloseInventory) && !_vm->_championMan->_champions[championIndex]._currHealth)
 		return;
-	}
-	if (_vm->_pressingMouth || _vm->_pressingEye) {
+
+	if (_vm->_pressingMouth || _vm->_pressingEye)
 		return;
-	}
+
 	_vm->_stopWaitingForPlayerInput = true;
-	AL1102_ui_InventoryChampionOrdinal = _inventoryChampionOrdinal;
-	if (_vm->indexToOrdinal(championIndex) == AL1102_ui_InventoryChampionOrdinal) {
+	uint16 inventoryChampionOrdinal = _inventoryChampionOrdinal;
+	if (_vm->indexToOrdinal(championIndex) == inventoryChampionOrdinal)
 		championIndex = k4_ChampionCloseInventory;
-	}
+
 	_vm->_eventMan->showMouse();
-	if (AL1102_ui_InventoryChampionOrdinal) {
+	if (inventoryChampionOrdinal) {
 		_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 		closeChest();
-		L1103_ps_Champion = &_vm->_championMan->_champions[_vm->ordinalToIndex(AL1102_ui_InventoryChampionOrdinal)];
-		if (L1103_ps_Champion->_currHealth && !_vm->_championMan->_candidateChampionOrdinal) {
-			setFlag(L1103_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox);
-			_vm->_championMan->drawChampionState((ChampionIndex)_vm->ordinalToIndex(AL1102_ui_InventoryChampionOrdinal));
+		Champion *champion = &_vm->_championMan->_champions[_vm->ordinalToIndex(inventoryChampionOrdinal)];
+		if (champion->_currHealth && !_vm->_championMan->_candidateChampionOrdinal) {
+			setFlag(champion->_attributes, k0x1000_ChampionAttributeStatusBox);
+			_vm->_championMan->drawChampionState((ChampionIndex)_vm->ordinalToIndex(inventoryChampionOrdinal));
 		}
 		if (_vm->_championMan->_partyIsSleeping) {
 			_vm->_eventMan->hideMouse();
@@ -130,14 +123,13 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	}
 	_vm->_displayMan->_useByteBoxCoordinates = false;
 	_inventoryChampionOrdinal = _vm->indexToOrdinal(championIndex);
-	if (!AL1102_ui_InventoryChampionOrdinal) {
+	if (!inventoryChampionOrdinal)
 		_vm->_displayMan->shadeScreenBox(&_vm->_displayMan->_boxMovementArrows, k0_ColorBlack);
-	}
-	L1103_ps_Champion = &_vm->_championMan->_champions[championIndex];
+
+	Champion *champion = &_vm->_championMan->_champions[championIndex];
 	_vm->_displayMan->loadIntoBitmap(k17_InventoryGraphicIndice, _vm->_displayMan->_bitmapViewport);
-	if (_vm->_championMan->_candidateChampionOrdinal) {
-		_vm->_displayMan->fillBoxBitmap(_vm->_displayMan->_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
-	}
+	if (_vm->_championMan->_candidateChampionOrdinal)
+		_vm->_displayMan->fillBoxBitmap(_vm->_displayMan->_bitmapViewport, boxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport);
 
 	switch (_vm->getGameLanguage()) { // localized
 	default:
@@ -156,10 +148,11 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	}
 
 	_vm->_textMan->printToViewport(5, 132, k13_ColorLightestGray, "MANA");
-	for (AL1102_ui_SlotIndex = k0_ChampionSlotReadyHand; AL1102_ui_SlotIndex < k30_ChampionSlotChest_1; AL1102_ui_SlotIndex++) {
-		_vm->_championMan->drawSlot(championIndex, AL1102_ui_SlotIndex);
-	}
-	setFlag(L1103_ps_Champion->_attributes, k0x4000_ChampionAttributeViewport | k0x1000_ChampionAttributeStatusBox | k0x0800_ChampionAttributePanel | k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics | k0x0080_ChampionAttributeNameTitle);
+
+	for (uint16 i = k0_ChampionSlotReadyHand; i < k30_ChampionSlotChest_1; i++)
+		_vm->_championMan->drawSlot(championIndex, i);
+
+	setFlag(champion->_attributes, k0x4000_ChampionAttributeViewport | k0x1000_ChampionAttributeStatusBox | k0x0800_ChampionAttributePanel | k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics | k0x0080_ChampionAttributeNameTitle);
 	_vm->_championMan->drawChampionState(championIndex);
 	_vm->_eventMan->_mousePointerBitmapUpdated = true;
 	_vm->_eventMan->hideMouse();
@@ -190,25 +183,24 @@ void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Co
 }
 
 void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
-	if (amount < -512) {
+	if (amount < -512)
 		color = k8_ColorRed;
-	} else if (amount < 0) {
+	else if (amount < 0)
 		color = k11_ColorYellow;
-	}
 
 	int16 pixelWidth = amount + 1024;
-	if (pixelWidth == 3072) {
+	if (pixelWidth == 3072)
 		pixelWidth = 3071;
-	}
+
 	pixelWidth /= 32;
 	drawPanelHorizontalBar(115, y + 2, pixelWidth, k0_ColorBlack);
 	drawPanelHorizontalBar(113, y, pixelWidth, color);
 }
 
 void InventoryMan::drawPanelFoodWaterPoisoned() {
-	static Box g35_BoxFood(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food
-	static Box g36_BoxWater(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
-	static Box g37_BoxPoisoned(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
+	static Box boxFood(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food
+	static Box boxWater(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
+	static Box boxPoisoned(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
 
 	Champion &champ = _vm->_championMan->_champions[_inventoryChampionOrdinal];
 	closeChest();
@@ -218,23 +210,23 @@ void InventoryMan::drawPanelFoodWaterPoisoned() {
 	switch (_vm->getGameLanguage()) { // localized
 	default:
 	case Common::EN_ANY:
-		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k30_FoodLabelIndice), g35_BoxFood, k24_byteWidth, k12_ColorDarkestGray, 9);
-		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k31_WaterLabelIndice), g36_BoxWater, k24_byteWidth, k12_ColorDarkestGray, 9);
+		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k30_FoodLabelIndice), boxFood, k24_byteWidth, k12_ColorDarkestGray, 9);
+		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k31_WaterLabelIndice), boxWater, k24_byteWidth, k12_ColorDarkestGray, 9);
 		break;
 	case Common::DE_DEU:
-		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k30_FoodLabelIndice), g35_BoxFood, k32_byteWidth, k12_ColorDarkestGray, 9);
-		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k31_WaterLabelIndice), g36_BoxWater, k32_byteWidth, k12_ColorDarkestGray, 9);
+		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k30_FoodLabelIndice), boxFood, k32_byteWidth, k12_ColorDarkestGray, 9);
+		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k31_WaterLabelIndice), boxWater, k32_byteWidth, k12_ColorDarkestGray, 9);
 		break;
 	case Common::FR_FRA:
-		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k30_FoodLabelIndice), g35_BoxFood, k48_byteWidth, k12_ColorDarkestGray, 9);
-		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k31_WaterLabelIndice), g36_BoxWater, k24_byteWidth, k12_ColorDarkestGray, 9);
+		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k30_FoodLabelIndice), boxFood, k48_byteWidth, k12_ColorDarkestGray, 9);
+		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k31_WaterLabelIndice), boxWater, k24_byteWidth, k12_ColorDarkestGray, 9);
 		break;
 	}
 
-	if (champ._poisonEventCount) {
+	if (champ._poisonEventCount)
 		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k32_PoisionedLabelIndice),
-								   g37_BoxPoisoned, k48_byteWidth, k12_ColorDarkestGray, 15);
-	}
+								   boxPoisoned, k48_byteWidth, k12_ColorDarkestGray, 15);
+
 	drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown);
 	drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue);
 }
@@ -268,11 +260,11 @@ void InventoryMan::drawPanel() {
 		thing = Thing::_none;
 		break;
 	}
-	if (thing == Thing::_none) {
+
+	if (thing == Thing::_none)
 		drawPanelFoodWaterPoisoned();
-	} else {
+	else
 		drawPanelObject(thing, false);
-	}
 }
 
 void InventoryMan::closeChest() {
@@ -304,11 +296,10 @@ void InventoryMan::closeChest() {
 
 void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) {
 	for (char* iter = text; *iter != '\0'; ++iter) {
-		if ((*iter >= 'A') && (*iter <= 'Z')) {
+		if ((*iter >= 'A') && (*iter <= 'Z'))
 			*iter -= 64;
-		} else if (*iter >= '{') { // this branch is CHANGE5_03_IMPROVEMENT
+		else if (*iter >= '{') // this branch is CHANGE5_03_IMPROVEMENT
 			*iter -= 96;
-		}
 	}
 	_vm->_textMan->printToViewport(162 - (6 * strlen(text) / 2), yPos, k0_ColorBlack, text, k15_ColorWhite);
 }
@@ -319,9 +310,9 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) {
 	char stringFirstLine[300];
 	_vm->_dungeonMan->decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
 	char *charRed = stringFirstLine;
-	while (*charRed && (*charRed != '\n')) {
+	while (*charRed && (*charRed != '\n'))
 		charRed++;
-	}
+
 	*charRed = '\0';
 	dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k23_PanelOpenScrollIndice),
 							   _boxPanel, k72_byteWidth, k8_ColorRed, 73);
@@ -333,27 +324,28 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) {
 		(with no carriage return) then charGreen points to undefined data. This may result in a graphical
 		glitch and also corrupt other memory. This is not an issue in the original dungeons where all
 		scrolls contain at least one carriage return character */
-		if (*charGreen == '\n') {
+		if (*charGreen == '\n')
 			lineCount++;
-		}
+
 		charGreen++;
 	}
-	if (*(charGreen - 1) != '\n') {
+
+	if (*(charGreen - 1) != '\n')
 		lineCount++;
-	} else if (*(charGreen - 2) == '\n') {
+	else if (*(charGreen - 2) == '\n')
 		lineCount--;
-	}
+
 	int16 yPos = 92 - (7 * lineCount) / 2; // center the text vertically
 	drawPanelScrollTextLine(yPos, stringFirstLine);
 	charGreen = charRed;
 	while (*charGreen) {
 		yPos += 7;
-		while (*charRed && (*charRed != '\n')) {
+		while (*charRed && (*charRed != '\n'))
 			charRed++;
-		}
-		if (!(*charRed)) {
+
+		if (!(*charRed))
 			charRed[1] = '\0';
-		}
+
 		*charRed++ = '\0';
 		drawPanelScrollTextLine(yPos, charGreen);
 		charGreen = charRed;
@@ -395,20 +387,18 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is
 
 void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos) {
 	static byte iconBitmap[16 * 16];
-	Box box;
-	box._x2 = (box._x1 = xPos) + 15;
-	box._y2 = (box._y1 = yPos) + 15;
+	Box boxIcon(xPos, xPos + 15, yPos, yPos + 15);
+
 	_vm->_objectMan->extractIconFromBitmap(iconIndex, iconBitmap);
-	_vm->_displayMan->blitToViewport(iconBitmap, box, k8_byteWidth, kM1_ColorNoTransparency, 16);
+	_vm->_displayMan->blitToViewport(iconBitmap, boxIcon, k8_byteWidth, kM1_ColorNoTransparency, 16);
 }
 
 void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, const char** attribStrings, char* destString, const char* prefixString, const char* suffixString) {
 	uint16 identicalBitCount = 0;
 	int16 attribMask = 1;
 	for (uint16 stringIndex = 0; stringIndex < 16; stringIndex++, attribMask <<= 1) {
-		if (attribMask & potentialAttribMask & actualAttribMask) {
+		if (attribMask & potentialAttribMask & actualAttribMask)
 			identicalBitCount++;
-		}
 	}
 
 	if (identicalBitCount == 0) {
@@ -432,7 +422,6 @@ void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 a
 				case Common::DE_DEU: strcat(destString, " UND "); break;
 				case Common::FR_FRA: strcat(destString, " ET "); break;
 				}
-
 			}
 		}
 	}
@@ -484,11 +473,6 @@ void InventoryMan::drawPanelArrowOrEye(bool pressingEye) {
 							   boxArrowOrEye, k8_byteWidth, k8_ColorRed, 9);
 }
 
-#define k0x0001_DescriptionMaskConsumable 0x0001 // @ MASK0x0001_DESCRIPTION_CONSUMABLE
-#define k0x0002_DescriptionMaskPoisoned 0x0002 // @ MASK0x0002_DESCRIPTION_POISONED  
-#define k0x0004_DescriptionMaskBroken 0x0004 // @ MASK0x0004_DESCRIPTION_BROKEN    
-#define k0x0008_DescriptionMaskCursed 0x0008 // @ MASK0x0008_DESCRIPTION_CURSED    
-
 void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 	static Box boxObjectDescCircle(105, 136, 53, 79); // @ G0034_s_Graphic562_Box_ObjectDescriptionCircle 
 
@@ -498,18 +482,17 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 	ChampionMan &champMan = *_vm->_championMan;
 	TextMan &textMan = *_vm->_textMan;
 
-	if (_vm->_pressingEye || _vm->_pressingMouth) {
+	if (_vm->_pressingEye || _vm->_pressingMouth)
 		closeChest();
-	}
 
 	uint16 *rawThingPtr = dunMan.getThingData(thingToDraw);
 	drawPanelObjectDescriptionString("\f"); // form feed
 	ThingType thingType = thingToDraw.getType();
-	if (thingType == k7_ScrollThingType) {
+	if (thingType == k7_ScrollThingType)
 		drawPanelScroll((Scroll*)rawThingPtr);
-	} else if (thingType == k9_ContainerThingType) {
+	else if (thingType == k9_ContainerThingType)
 		openAndDrawChest(thingToDraw, (Container *)rawThingPtr, pressingEye);
-	} else {
+	else {
 		IconIndice iconIndex = objMan.getIconIndex(thingToDraw);
 		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k20_PanelEmptyIndice),
 								   _boxPanel, k72_byteWidth, k8_ColorRed, 73);
@@ -566,9 +549,15 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 
 				switch (_vm->getGameLanguage()) { // localized
 				default:
-				case Common::EN_ANY: drawPanelObjectDescriptionString("(BURNT OUT)"); break;
-				case Common::DE_DEU: drawPanelObjectDescriptionString("(AUSGEBRANNT)"); break;
-				case Common::FR_FRA: drawPanelObjectDescriptionString("(CONSUME)"); break;
+				case Common::EN_ANY:
+					drawPanelObjectDescriptionString("(BURNT OUT)");
+					break;
+				case Common::DE_DEU:
+					drawPanelObjectDescriptionString("(AUSGEBRANNT)");
+					break;
+				case Common::FR_FRA:
+					drawPanelObjectDescriptionString("(CONSUME)");
+					break;
 				}
 			}
 			break;
@@ -629,9 +618,15 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 				const static char* directionName_FR_FRA[4] = {"AU NORD", "A L'EST", "AU SUD", "A L'OUEST"};
 				switch (_vm->getGameLanguage()) { // localized
 				default:
-				case Common::EN_ANY: strcat(str, directionName_EN_ANY[iconIndex]); break;
-				case Common::DE_DEU: strcat(str, directionName_DE_DEU[iconIndex]); break;
-				case Common::FR_FRA: strcat(str, directionName_FR_FRA[iconIndex]); break;
+				case Common::EN_ANY:
+					strcat(str, directionName_EN_ANY[iconIndex]);
+					break;
+				case Common::DE_DEU:
+					strcat(str, directionName_DE_DEU[iconIndex]);
+					break;
+				case Common::FR_FRA:
+					strcat(str, directionName_FR_FRA[iconIndex]);
+					break;
 				}
 
 				drawPanelObjectDescriptionString(str);
@@ -650,13 +645,19 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			static const char *attribString_EN_ANY[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"};
 			static const char *attribString_DE_DEU[4] = {"ESSBAR", "VERGIFTET", "DEFEKT", "VERFLUCHT"};
 			static const char *attribString_FR_FRA[4] = {"COMESTIBLE", "EMPOISONNE", "BRISE", "MAUDIT"};
-			static const char **attribString = nullptr;
+			const char **attribString = nullptr;
 
 			switch (_vm->getGameLanguage()) { // localized
 			default:
-			case Common::EN_ANY: attribString = attribString_EN_ANY; break;
-			case Common::DE_DEU: attribString = attribString_DE_DEU; break;
-			case Common::FR_FRA: attribString = attribString_FR_FRA; break;
+			case Common::EN_ANY:
+				attribString = attribString_EN_ANY;
+				break;
+			case Common::DE_DEU:
+				attribString = attribString_DE_DEU;
+				break;
+			case Common::FR_FRA:
+				attribString = attribString_FR_FRA;
+				break;
 			}
 
 			buildObjectAttributeString(potentialAttribMask, actualAttribMask, attribString, str, "(", ")");
@@ -665,9 +666,15 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 
 		switch (_vm->getGameLanguage()) { // localized
 		default:
-		case Common::EN_ANY: strcpy(str, "WEIGHS "); break;
-		case Common::DE_DEU: strcpy(str, "WIEGT "); break;
-		case Common::FR_FRA: strcpy(str, "PESE "); break;
+		case Common::EN_ANY:
+			strcpy(str, "WEIGHS ");
+			break;
+		case Common::DE_DEU:
+			strcpy(str, "WIEGT ");
+			break;
+		case Common::FR_FRA:
+			strcpy(str, "PESE ");
+			break;
 		}
 
 
@@ -676,9 +683,15 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 
 		switch (_vm->getGameLanguage()) { // localized
 		default:
-		case Common::EN_ANY: strcat(str, "."); break;
-		case Common::DE_DEU: strcat(str, ","); break;
-		case Common::FR_FRA: strcat(str, "KG,"); break;
+		case Common::EN_ANY:
+			strcat(str, ".");
+			break;
+		case Common::DE_DEU:
+			strcat(str, ",");
+			break;
+		case Common::FR_FRA:
+			strcat(str, "KG,");
+			break;
 		}
 
 		weight -= (weight / 10) * 10;
@@ -687,8 +700,12 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		switch (_vm->getGameLanguage()) { // localized
 		default:
 		case Common::EN_ANY:
-		case Common::DE_DEU: strcat(str, " KG."); break;
-		case Common::FR_FRA: strcat(str, "."); break;
+		case Common::DE_DEU:
+			strcat(str, " KG.");
+			break;
+		case Common::FR_FRA:
+			strcat(str, ".");
+			break;
 		}
 
 		drawPanelObjectDescriptionString(str);
@@ -697,73 +714,72 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 }
 
 void InventoryMan::setDungeonViewPalette() {
-	static const int16 g40_palIndexToLightAmmount[6] = {99, 75, 50, 25, 1, 0}; // @ G0040_ai_Graphic562_PaletteIndexToLightAmount
+	static const int16 palIndexToLightAmmount[6] = {99, 75, 50, 25, 1, 0}; // @ G0040_ai_Graphic562_PaletteIndexToLightAmount
 
 	if (_vm->_dungeonMan->_currMap->_difficulty == 0) {
 		_vm->_displayMan->_dungeonViewPaletteIndex = 0; /* Brightest color palette index */
 	} else {
 		/* Get torch light power from both hands of each champion in the party */
-		int16 L1038_i_Counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and _vm->_objectMan->f32_getObjectType then returns -1 */
-		Champion *L1043_ps_Champion = _vm->_championMan->_champions;
-		int16 L1045_ai_TorchesLightPower[8];
-		int16 *AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
-		while (L1038_i_Counter--) {
-			uint16 AL1039_ui_SlotIndex = k1_ChampionSlotActionHand + 1;
-			while (AL1039_ui_SlotIndex--) {
-				uint16 AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16();
-				if ((_vm->_objectMan->getObjectType(Thing(AL1044_T_Thing)) >= k4_IconIndiceWeaponTorchUnlit) &&
-					(_vm->_objectMan->getObjectType(Thing(AL1044_T_Thing)) <= k7_IconIndiceWeaponTorchLit)) {
-					Weapon *L1042_ps_Weapon = (Weapon*)_vm->_dungeonMan->getThingData(Thing(AL1044_T_Thing));
-					*AL1040_pi_TorchLightPower = L1042_ps_Weapon->getChargeCount();
+		int16 counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and _vm->_objectMan->f32_getObjectType then returns -1 */
+		Champion *curChampion = _vm->_championMan->_champions;
+		int16 torchesLightPower[8];
+		int16 *curTorchLightPower = torchesLightPower;
+		while (counter--) {
+			uint16 slotIndex = k1_ChampionSlotActionHand + 1;
+			while (slotIndex--) {
+				Thing slotThing = curChampion->_slots[slotIndex];
+				if ((_vm->_objectMan->getObjectType(slotThing) >= k4_IconIndiceWeaponTorchUnlit) &&
+					(_vm->_objectMan->getObjectType(slotThing) <= k7_IconIndiceWeaponTorchLit)) {
+					Weapon *curWeapon = (Weapon*)_vm->_dungeonMan->getThingData(slotThing);
+					*curTorchLightPower = curWeapon->getChargeCount();
 				} else {
-					*AL1040_pi_TorchLightPower = 0;
+					*curTorchLightPower = 0;
 				}
-				AL1040_pi_TorchLightPower++;
+				curTorchLightPower++;
 			}
-			L1043_ps_Champion++;
+			curChampion++;
 		}
 		/* Sort torch light power values so that the four highest values are in the first four entries in the array L1045_ai_TorchesLightPower in decreasing order. The last four entries contain the smallest values but they are not sorted */
-		AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
-		int16 AL1039_ui_Counter = 0;
-		while (AL1039_ui_Counter != 4) {
-			L1038_i_Counter = 7 - AL1039_ui_Counter;
-			int16 *L1041_pi_TorchLightPower = &L1045_ai_TorchesLightPower[AL1039_ui_Counter + 1];
-			while (L1038_i_Counter--) {
-				if (*L1041_pi_TorchLightPower > *AL1040_pi_TorchLightPower) {
+		curTorchLightPower = torchesLightPower;
+		int16 torchIndex = 0;
+		while (torchIndex != 4) {
+			counter = 7 - torchIndex;
+			int16 *L1041_pi_TorchLightPower = &torchesLightPower[torchIndex + 1];
+			while (counter--) {
+				if (*L1041_pi_TorchLightPower > *curTorchLightPower) {
 					int16 AL1044_ui_TorchLightPower = *L1041_pi_TorchLightPower;
-					*L1041_pi_TorchLightPower = *AL1040_pi_TorchLightPower;
-					*AL1040_pi_TorchLightPower = AL1044_ui_TorchLightPower;
+					*L1041_pi_TorchLightPower = *curTorchLightPower;
+					*curTorchLightPower = AL1044_ui_TorchLightPower;
 				}
 				L1041_pi_TorchLightPower++;
 			}
-			AL1040_pi_TorchLightPower++;
-			AL1039_ui_Counter++;
+			curTorchLightPower++;
+			torchIndex++;
 		}
 		/* Get total light amount provided by the four torches with the highest light power values and by the fifth torch in the array which may be any one of the four torches with the smallest ligh power values */
-		uint16 L1037_ui_TorchLightAmountMultiplier = 6;
-		AL1039_ui_Counter = 5;
-		int16 L1036_i_TotalLightAmount = 0;
-		AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
-		while (AL1039_ui_Counter--) {
-			if (*AL1040_pi_TorchLightPower) {
-				L1036_i_TotalLightAmount += (_vm->_championMan->_lightPowerToLightAmount[*AL1040_pi_TorchLightPower] << L1037_ui_TorchLightAmountMultiplier) >> 6;
-				L1037_ui_TorchLightAmountMultiplier = MAX(0, L1037_ui_TorchLightAmountMultiplier - 1);
+		uint16 torchLightAmountMultiplier = 6;
+		torchIndex = 5;
+		int16 totalLightAmount = 0;
+		curTorchLightPower = torchesLightPower;
+		while (torchIndex--) {
+			if (*curTorchLightPower) {
+				totalLightAmount += (_vm->_championMan->_lightPowerToLightAmount[*curTorchLightPower] << torchLightAmountMultiplier) >> 6;
+				torchLightAmountMultiplier = MAX(0, torchLightAmountMultiplier - 1);
 			}
-			AL1040_pi_TorchLightPower++;
+			curTorchLightPower++;
 		}
-		L1036_i_TotalLightAmount += _vm->_championMan->_party._magicalLightAmount;
+		totalLightAmount += _vm->_championMan->_party._magicalLightAmount;
 		/* Select palette corresponding to the total light amount */
-		const int16 *AL1040_pi_LightAmount = g40_palIndexToLightAmmount;
-		int16 AL1039_ui_PaletteIndex;
-		if (L1036_i_TotalLightAmount > 0) {
-			AL1039_ui_PaletteIndex = 0; /* Brightest color palette index */
-			while (*AL1040_pi_LightAmount++ > L1036_i_TotalLightAmount) {
-				AL1039_ui_PaletteIndex++;
-			}
+		const int16 *curLightAmount = palIndexToLightAmmount;
+		int16 paletteIndex;
+		if (totalLightAmount > 0) {
+			paletteIndex = 0; /* Brightest color palette index */
+			while (*curLightAmount++ > totalLightAmount)
+				paletteIndex++;
 		} else {
-			AL1039_ui_PaletteIndex = 5; /* Darkest color palette index */
+			paletteIndex = 5; /* Darkest color palette index */
 		}
-		_vm->_displayMan->_dungeonViewPaletteIndex = AL1039_ui_PaletteIndex;
+		_vm->_displayMan->_dungeonViewPaletteIndex = paletteIndex;
 	}
 
 	_vm->_displayMan->_refreshDungeonViewPaleteRequested = true;
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 6ad520c..795d287 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -34,6 +34,11 @@
 
 namespace DM {
 
+#define k0x0001_DescriptionMaskConsumable 0x0001 // @ MASK0x0001_DESCRIPTION_CONSUMABLE
+#define k0x0002_DescriptionMaskPoisoned 0x0002 // @ MASK0x0002_DESCRIPTION_POISONED  
+#define k0x0004_DescriptionMaskBroken 0x0004 // @ MASK0x0004_DESCRIPTION_BROKEN    
+#define k0x0008_DescriptionMaskCursed 0x0008 // @ MASK0x0008_DESCRIPTION_CURSED    
+
 #define k69_ChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING
 #define k38_SlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT
 


Commit: cd3b485952b71244392f594164e60b96a07fb23c
    https://github.com/scummvm/scummvm/commit/cd3b485952b71244392f594164e60b96a07fb23c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-09-03T10:38:43+02:00

Commit Message:
DM: Clean up includes

Swap <> to "" with scummvm files
Add dm/ prefix to dm files
Reorder includes to system files, dm files

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/console.cpp
    engines/dm/detection.cpp
    engines/dm/dialog.cpp
    engines/dm/dialog.h
    engines/dm/dm.cpp
    engines/dm/dm.h
    engines/dm/dmglobals.cpp
    engines/dm/dungeonman.cpp
    engines/dm/dungeonman.h
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/group.cpp
    engines/dm/group.h
    engines/dm/inventory.cpp
    engines/dm/inventory.h
    engines/dm/loadsave.cpp
    engines/dm/loadsave.h
    engines/dm/lzw.cpp
    engines/dm/lzw.h
    engines/dm/menus.cpp
    engines/dm/menus.h
    engines/dm/movesens.cpp
    engines/dm/movesens.h
    engines/dm/objectman.cpp
    engines/dm/objectman.h
    engines/dm/projexpl.cpp
    engines/dm/projexpl.h
    engines/dm/sounds.cpp
    engines/dm/sounds.h
    engines/dm/text.cpp
    engines/dm/text.h
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 271af52..7d696a3 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -25,18 +25,18 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include "champion.h"
-#include "dungeonman.h"
-#include "eventman.h"
-#include "menus.h"
-#include "inventory.h"
-#include "objectman.h"
-#include "text.h"
-#include "timeline.h"
-#include "projexpl.h"
-#include "group.h"
-#include "movesens.h"
-#include "sounds.h"
+#include "dm/champion.h"
+#include "dm/dungeonman.h"
+#include "dm/eventman.h"
+#include "dm/menus.h"
+#include "dm/inventory.h"
+#include "dm/objectman.h"
+#include "dm/text.h"
+#include "dm/timeline.h"
+#include "dm/projexpl.h"
+#include "dm/group.h"
+#include "dm/movesens.h"
+#include "dm/sounds.h"
 
 
 namespace DM {
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 88fbfcf..36fbd4e 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -30,8 +30,8 @@
 
 #include "common/str.h"
 
-#include "dm.h"
-#include "gfx.h"
+#include "dm/dm.h"
+#include "dm/gfx.h"
 
 namespace DM {
 
diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index a815700..1ccfe39 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -25,12 +25,12 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include "console.h"
-#include "dm.h"
-#include "champion.h"
-#include "dungeonman.h"
-#include "movesens.h"
-#include "objectman.h"
+#include "dm/console.h"
+#include "dm/dm.h"
+#include "dm/champion.h"
+#include "dm/dungeonman.h"
+#include "dm/movesens.h"
+#include "dm/objectman.h"
 
 
 namespace DM {
diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp
index 548bab8..ad711c5 100644
--- a/engines/dm/detection.cpp
+++ b/engines/dm/detection.cpp
@@ -25,14 +25,15 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include "dm/dm.h"
 
 #include "common/config-manager.h"
 #include "common/error.h"
 #include "common/fs.h"
+#include "common/system.h"
 
 #include "engines/advancedDetector.h"
-#include <common/system.h>
+
+#include "dm/dm.h"
 
 namespace DM {
 static const PlainGameDescriptor DMGames[] = {
diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp
index c6b317c..dd2e158 100644
--- a/engines/dm/dialog.cpp
+++ b/engines/dm/dialog.cpp
@@ -25,11 +25,10 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include "dialog.h"
-#include "gfx.h"
-#include "text.h"
-#include "eventman.h"
-
+#include "dm/dialog.h"
+#include "dm/gfx.h"
+#include "dm/text.h"
+#include "dm/eventman.h"
 
 namespace DM {
 
diff --git a/engines/dm/dialog.h b/engines/dm/dialog.h
index 647ae8d..bf6618a 100644
--- a/engines/dm/dialog.h
+++ b/engines/dm/dialog.h
@@ -25,8 +25,7 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include "dm.h"
-
+#include "dm/dm.h"
 
 namespace DM {
 
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 0bb227a..538124f 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -25,6 +25,8 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
+#include "advancedDetector.h"
+
 #include "common/config-manager.h"
 #include "common/scummsys.h"
 #include "common/system.h"
@@ -33,35 +35,37 @@
 #include "common/debug-channels.h"
 #include "common/error.h"
 
-#include "engines/util.h"
-#include "engines/engine.h"
-#include "graphics/palette.h"
 #include "common/file.h"
 #include "common/events.h"
 #include "common/array.h"
 #include "common/algorithm.h"
+#include "common/translation.h"
+
+#include "engines/util.h"
+#include "engines/engine.h"
+
+#include "graphics/cursorman.h"
+#include "graphics/palette.h"
+#include "graphics/surface.h"
+
+#include "gui/saveload.h"
 
 #include "dm/dm.h"
-#include "gfx.h"
-#include "dungeonman.h"
-#include "eventman.h"
-#include "menus.h"
-#include "champion.h"
-#include "loadsave.h"
-#include "objectman.h"
-#include "inventory.h"
-#include "text.h"
-#include "movesens.h"
-#include "group.h"
-#include "timeline.h"
-#include "projexpl.h"
-#include "dialog.h"
-#include <graphics/cursorman.h>
-#include <advancedDetector.h>
-#include "sounds.h"
-#include <graphics/surface.h>
-#include <common/translation.h>
-#include <gui/saveload.h>
+#include "dm/gfx.h"
+#include "dm/dungeonman.h"
+#include "dm/eventman.h"
+#include "dm/menus.h"
+#include "dm/champion.h"
+#include "dm/loadsave.h"
+#include "dm/objectman.h"
+#include "dm/inventory.h"
+#include "dm/text.h"
+#include "dm/movesens.h"
+#include "dm/group.h"
+#include "dm/timeline.h"
+#include "dm/projexpl.h"
+#include "dm/dialog.h"
+#include "dm/sounds.h"
 
 namespace DM {
 const char *debugGetDirectionName(Direction dir) {
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 083dfad..979301d 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -28,16 +28,17 @@
 #ifndef DM_H
 #define DM_H
 
-#include "common/random.h"
 #include "engines/engine.h"
+#include "engines/savestate.h"
+
+#include "common/random.h"
 #include "common/savefile.h"
 #include "common/str.h"
-#include "engines/savestate.h"
+#include "common/memstream.h"
 
-#include "console.h"
-#include <common/memstream.h>
-#include <advancedDetector.h>
+#include "advancedDetector.h"
 
+#include "dm/console.h"
 
 struct ADGameDescription;
 
diff --git a/engines/dm/dmglobals.cpp b/engines/dm/dmglobals.cpp
index 02e819d..993f112 100644
--- a/engines/dm/dmglobals.cpp
+++ b/engines/dm/dmglobals.cpp
@@ -26,18 +26,18 @@
 */
 
 #include "common/system.h"
+
 #include "dm/dm.h"
-#include "gfx.h"
-#include "dungeonman.h"
-#include "eventman.h"
-#include "menus.h"
-#include "champion.h"
-#include "loadsave.h"
-#include "objectman.h"
-#include "inventory.h"
-#include "text.h"
-#include "movesens.h"
-#include "string.h"
+#include "dm/gfx.h"
+#include "dm/dungeonman.h"
+#include "dm/eventman.h"
+#include "dm/menus.h"
+#include "dm/champion.h"
+#include "dm/loadsave.h"
+#include "dm/objectman.h"
+#include "dm/inventory.h"
+#include "dm/text.h"
+#include "dm/movesens.h"
 
 namespace DM {
 
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index f41ccf2..67f0ac7 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -28,12 +28,12 @@
 #include "common/file.h"
 #include "common/memstream.h"
 
-#include "dungeonman.h"
-#include "timeline.h"
-#include "champion.h"
-#include "group.h"
-#include "movesens.h"
-#include "projexpl.h"
+#include "dm/dungeonman.h"
+#include "dm/timeline.h"
+#include "dm/champion.h"
+#include "dm/group.h"
+#include "dm/movesens.h"
+#include "dm/projexpl.h"
 
 namespace DM {
 
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index ac85b28..450cd7f 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -28,8 +28,8 @@
 #ifndef DUNGEONMAN_H
 #define DUNGEONMAN_H
 
-#include "dm.h"
-#include "gfx.h"
+#include "dm/dm.h"
+#include "dm/gfx.h"
 
 namespace DM {
 
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 01f6567..5d9c04b 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -27,20 +27,20 @@
 
 #include "common/system.h"
 #include "graphics/cursorman.h"
-
-#include "eventman.h"
-#include "dungeonman.h"
-#include "movesens.h"
-#include "objectman.h"
-#include "inventory.h"
-#include "menus.h"
-#include "timeline.h"
-#include "projexpl.h"
-#include "text.h"
-#include "group.h"
-#include "dialog.h"
-#include "sounds.h"
-#include <mortevielle/saveload.h>
+#include "graphics/thumbnail.h"
+
+#include "dm/eventman.h"
+#include "dm/dungeonman.h"
+#include "dm/movesens.h"
+#include "dm/objectman.h"
+#include "dm/inventory.h"
+#include "dm/menus.h"
+#include "dm/timeline.h"
+#include "dm/projexpl.h"
+#include "dm/text.h"
+#include "dm/group.h"
+#include "dm/dialog.h"
+#include "dm/sounds.h"
 
 
 namespace DM {
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 92d055c..649bc39 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -32,9 +32,9 @@
 #include "common/queue.h"
 #include "common/array.h"
 
-#include "dm.h"
-#include "gfx.h"
-#include "champion.h"
+#include "dm/dm.h"
+#include "dm/gfx.h"
+#include "dm/champion.h"
 
 namespace DM {
 
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 3163b8c..0b5fa47 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -28,17 +28,17 @@
 #include "engines/util.h"
 #include "common/system.h"
 #include "common/file.h"
-#include "graphics/palette.h"
 #include "common/endian.h"
+#include "graphics/palette.h"
 
-#include "gfx.h"
-#include "dungeonman.h"
-#include "group.h"
-#include "timeline.h"
-#include "champion.h"
-#include "eventman.h"
-#include "lzw.h"
-#include "text.h"
+#include "dm/gfx.h"
+#include "dm/dungeonman.h"
+#include "dm/group.h"
+#include "dm/timeline.h"
+#include "dm/champion.h"
+#include "dm/eventman.h"
+#include "dm/lzw.h"
+#include "dm/text.h"
 
 namespace DM {
 DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 44e75ab..f3e6a5d 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -31,9 +31,10 @@
 #include "common/scummsys.h"
 #include "common/rect.h"
 #include "common/memstream.h"
-#include "dm.h"
 #include "common/array.h"
 
+#include "dm/dm.h"
+
 namespace DM {
 
 #define k0_viewFloor_D3L 0 // @ C0_VIEW_FLOOR_D3L
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 901661f..09581f7 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -25,15 +25,15 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include "group.h"
-#include "dungeonman.h"
-#include "champion.h"
-#include "movesens.h"
-#include "projexpl.h"
-#include "timeline.h"
-#include "objectman.h"
-#include "menus.h"
-#include "sounds.h"
+#include "dm/group.h"
+#include "dm/dungeonman.h"
+#include "dm/champion.h"
+#include "dm/movesens.h"
+#include "dm/projexpl.h"
+#include "dm/timeline.h"
+#include "dm/objectman.h"
+#include "dm/menus.h"
+#include "dm/sounds.h"
 
 
 namespace DM {
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 02f6927..38c3a0d 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -28,7 +28,7 @@
 #ifndef DM_GROUP_H
 #define DM_GROUP_H
 
-#include "dm.h"
+#include "dm/dm.h"
 
 namespace DM {
 	class Champion;
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 85bf916..516bc46 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -25,19 +25,19 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include <graphics/surface.h>
+#include "graphics/surface.h"
 #include "graphics/thumbnail.h"
 
-#include "inventory.h"
-#include "dungeonman.h"
-#include "eventman.h"
-#include "menus.h"
-#include "gfx.h"
-#include "text.h"
-#include "objectman.h"
-#include "timeline.h"
-#include "projexpl.h"
-#include "sounds.h"
+#include "dm/inventory.h"
+#include "dm/dungeonman.h"
+#include "dm/eventman.h"
+#include "dm/menus.h"
+#include "dm/gfx.h"
+#include "dm/text.h"
+#include "dm/objectman.h"
+#include "dm/timeline.h"
+#include "dm/projexpl.h"
+#include "dm/sounds.h"
 
 
 namespace DM {
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index 795d287..e5bc490 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -25,12 +25,10 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include "dm.h"
-#include "gfx.h"
-#include "champion.h"
-#include "dungeonman.h"
-
-
+#include "dm/dm.h"
+#include "dm/gfx.h"
+#include "dm/champion.h"
+#include "dm/dungeonman.h"
 
 namespace DM {
 
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 0fde805..a9ee6f8 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -26,19 +26,19 @@
 */
 #include "common/system.h"
 #include "common/savefile.h"
+#include "common/translation.h"
 #include "graphics/thumbnail.h"
-
-#include "dm.h"
-#include "dungeonman.h"
-#include "timeline.h"
-#include "group.h"
-#include "champion.h"
-#include "menus.h"
-#include "eventman.h"
-#include "projexpl.h"
-#include "dialog.h"
-#include <gui/saveload.h>
-#include <common/translation.h>
+#include "gui/saveload.h"
+
+#include "dm/dm.h"
+#include "dm/dungeonman.h"
+#include "dm/timeline.h"
+#include "dm/group.h"
+#include "dm/champion.h"
+#include "dm/menus.h"
+#include "dm/eventman.h"
+#include "dm/projexpl.h"
+#include "dm/dialog.h"
 
 
 namespace DM {
diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h
index a224966..ca8f4d6 100644
--- a/engines/dm/loadsave.h
+++ b/engines/dm/loadsave.h
@@ -28,7 +28,7 @@
 #ifndef DM_LOADSAVE_H
 #define DM_LOADSAVE_H
 
-#include "dm.h"
+#include "dm/dm.h"
 
 namespace DM {
 
diff --git a/engines/dm/lzw.cpp b/engines/dm/lzw.cpp
index 63b60c5..a93b0c8 100644
--- a/engines/dm/lzw.cpp
+++ b/engines/dm/lzw.cpp
@@ -25,8 +25,9 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include "lzw.h"
-#include <common/memstream.h>
+#include "common/memstream.h"
+
+#include "dm/lzw.h"
 
 namespace DM {
 
diff --git a/engines/dm/lzw.h b/engines/dm/lzw.h
index a83f1ad..b476c11 100644
--- a/engines/dm/lzw.h
+++ b/engines/dm/lzw.h
@@ -25,9 +25,9 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include <common/file.h>
+#include "common/file.h"
 
-#include "dm.h"
+#include "dm/dm.h"
 
 namespace Common {
 	class MemoryReadStream;
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 2c56382..32d6c62 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -25,19 +25,19 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include "menus.h"
-#include "gfx.h"
-#include "champion.h"
-#include "dungeonman.h"
-#include "objectman.h"
-#include "inventory.h"
-#include "text.h"
-#include "eventman.h"
-#include "timeline.h"
-#include "movesens.h"
-#include "group.h"
-#include "projexpl.h"
-#include "sounds.h"
+#include "dm/menus.h"
+#include "dm/gfx.h"
+#include "dm/champion.h"
+#include "dm/dungeonman.h"
+#include "dm/objectman.h"
+#include "dm/inventory.h"
+#include "dm/text.h"
+#include "dm/eventman.h"
+#include "dm/timeline.h"
+#include "dm/movesens.h"
+#include "dm/group.h"
+#include "dm/projexpl.h"
+#include "dm/sounds.h"
 
 
 namespace DM {
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 77455fb..1d37651 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -28,9 +28,9 @@
 #ifndef DM_MENUS_H
 #define DM_MENUS_H
 
-#include "dm.h"
-#include "champion.h"
-#include "dungeonman.h"
+#include "dm/dm.h"
+#include "dm/champion.h"
+#include "dm/dungeonman.h"
 
 namespace DM {
 
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index c437e1c..308c9e6 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -26,16 +26,16 @@
 */
 
 
-#include "movesens.h"
-#include "champion.h"
-#include "inventory.h"
-#include "dungeonman.h"
-#include "objectman.h"
-#include "timeline.h"
-#include "group.h"
-#include "projexpl.h"
-#include "text.h"
-#include "sounds.h"
+#include "dm/movesens.h"
+#include "dm/champion.h"
+#include "dm/inventory.h"
+#include "dm/dungeonman.h"
+#include "dm/objectman.h"
+#include "dm/timeline.h"
+#include "dm/group.h"
+#include "dm/projexpl.h"
+#include "dm/text.h"
+#include "dm/sounds.h"
 
 
 namespace DM {
diff --git a/engines/dm/movesens.h b/engines/dm/movesens.h
index c9381fa..ce023bc 100644
--- a/engines/dm/movesens.h
+++ b/engines/dm/movesens.h
@@ -29,7 +29,7 @@
 #ifndef DM_MOVESENS_H
 #define DM_MOVESENS_H
 
-#include "dm.h"
+#include "dm/dm.h"
 
 namespace DM {
 	class Sensor;
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index c191fa5..48efb96 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -25,9 +25,9 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include "objectman.h"
-#include "dungeonman.h"
-#include "text.h"
+#include "dm/objectman.h"
+#include "dm/dungeonman.h"
+#include "dm/text.h"
 
 namespace DM {
 
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index 4478bab..6c128ea 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -25,8 +25,8 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include "dm.h"
-#include "champion.h"
+#include "dm/dm.h"
+#include "dm/champion.h"
 
 
 namespace DM {
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 99fda67..aade217 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -26,13 +26,13 @@
 */
 
 
-#include "projexpl.h"
-#include "dungeonman.h"
-#include "timeline.h"
-#include "group.h"
-#include "objectman.h"
-#include "movesens.h"
-#include "sounds.h"
+#include "dm/projexpl.h"
+#include "dm/dungeonman.h"
+#include "dm/timeline.h"
+#include "dm/group.h"
+#include "dm/objectman.h"
+#include "dm/movesens.h"
+#include "dm/sounds.h"
 
 namespace DM {
 
diff --git a/engines/dm/projexpl.h b/engines/dm/projexpl.h
index 1621e31..e8db0bf 100644
--- a/engines/dm/projexpl.h
+++ b/engines/dm/projexpl.h
@@ -27,7 +27,7 @@
 #ifndef DM_PROJEXPL_H
 #define DM_PROJEXPL_H
 
-#include "dm.h"
+#include "dm/dm.h"
 
 
 namespace DM {
diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp
index 421c299..9affc78 100644
--- a/engines/dm/sounds.cpp
+++ b/engines/dm/sounds.cpp
@@ -27,14 +27,14 @@
 
 #include "audio/audiostream.h"
 #include "audio/decoders/raw.h"
-#include <advancedDetector.h>
-
-#include "dm.h"
-#include "gfx.h"
-#include <audio/mixer.h>
-#include "timeline.h"
-#include "dungeonman.h"
-#include "sounds.h"
+#include "audio/mixer.h"
+#include "advancedDetector.h"
+
+#include "dm/dm.h"
+#include "dm/gfx.h"
+#include "dm/timeline.h"
+#include "dm/dungeonman.h"
+#include "dm/sounds.h"
 
 
 namespace DM {
diff --git a/engines/dm/sounds.h b/engines/dm/sounds.h
index e449274..1d09963 100644
--- a/engines/dm/sounds.h
+++ b/engines/dm/sounds.h
@@ -25,7 +25,7 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include "dm.h"
+#include "dm/dm.h"
 
 namespace DM {
 
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 80a115c..16955ba 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -25,9 +25,9 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include "text.h"
-#include <common/system.h>
+#include "common/system.h"
 
+#include "dm/text.h"
 
 namespace DM {
 
diff --git a/engines/dm/text.h b/engines/dm/text.h
index d157c9b..2124834 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -28,8 +28,8 @@
 #ifndef DM_TEXT_H
 #define DM_TEXT_H
 
-#include "dm.h"
-#include "gfx.h"
+#include "dm/dm.h"
+#include "dm/gfx.h"
 
 namespace DM {
 
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 98987dc..b4c70bb 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -25,17 +25,17 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include "timeline.h"
-#include "dungeonman.h"
-#include "champion.h"
-#include "inventory.h"
-#include "group.h"
-#include "projexpl.h"
-#include "movesens.h"
-#include "text.h"
-#include "eventman.h"
-#include "objectman.h"
-#include "sounds.h"
+#include "dm/timeline.h"
+#include "dm/dungeonman.h"
+#include "dm/champion.h"
+#include "dm/inventory.h"
+#include "dm/group.h"
+#include "dm/projexpl.h"
+#include "dm/movesens.h"
+#include "dm/text.h"
+#include "dm/eventman.h"
+#include "dm/objectman.h"
+#include "dm/sounds.h"
 
 
 namespace DM {
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index d3c63fd..1c0f51a 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -28,7 +28,7 @@
 #ifndef DM_TIMELINE_H
 #define DM_TIMELINE_H
 
-#include "dm.h"
+#include "dm/dm.h"
 
 namespace DM {
 	class Champion;


Commit: cb8fca46c5495d8f27c96ab4aa5b23c16910df0e
    https://github.com/scummvm/scummvm/commit/cb8fca46c5495d8f27c96ab4aa5b23c16910df0e
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-09-03T10:47:16+02:00

Commit Message:
DM: Fix include headers

Add DM_ prefix
Add missing include guards

Changed paths:
    engines/dm/console.h
    engines/dm/dialog.h
    engines/dm/dm.h
    engines/dm/dungeonman.h
    engines/dm/gfx.h
    engines/dm/inventory.h
    engines/dm/lzw.h
    engines/dm/objectman.h
    engines/dm/sounds.h



diff --git a/engines/dm/console.h b/engines/dm/console.h
index 546711e..eee72aa 100644
--- a/engines/dm/console.h
+++ b/engines/dm/console.h
@@ -25,11 +25,11 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#include "gui/debugger.h"
-
 #ifndef DM_CONSOLE_H
 #define DM_CONSOLE_H
 
+#include "gui/debugger.h"
+
 namespace DM {
 
 class DMEngine;
diff --git a/engines/dm/dialog.h b/engines/dm/dialog.h
index bf6618a..c736f35 100644
--- a/engines/dm/dialog.h
+++ b/engines/dm/dialog.h
@@ -25,6 +25,9 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
+#ifndef DM_DIALOG_H
+#define DM_DIALOG_H
+
 #include "dm/dm.h"
 
 namespace DM {
@@ -54,3 +57,5 @@ public:
 };
 
 }
+
+#endif
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 979301d..35a1f39 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -25,8 +25,8 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#ifndef DM_H
-#define DM_H
+#ifndef DM_DM_H
+#define DM_DM_H
 
 #include "engines/engine.h"
 #include "engines/savestate.h"
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 450cd7f..100ce75 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -25,8 +25,8 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#ifndef DUNGEONMAN_H
-#define DUNGEONMAN_H
+#ifndef DM_DUNGEONMAN_H
+#define DM_DUNGEONMAN_H
 
 #include "dm/dm.h"
 #include "dm/gfx.h"
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index f3e6a5d..319ac90 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -25,8 +25,8 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-#ifndef GFX_H
-#define GFX_H
+#ifndef DM_GFX_H
+#define DM_GFX_H
 
 #include "common/scummsys.h"
 #include "common/rect.h"
diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h
index e5bc490..c468557 100644
--- a/engines/dm/inventory.h
+++ b/engines/dm/inventory.h
@@ -25,6 +25,9 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
+#ifndef DM_INVENTORY_H
+#define DM_INVENTORY_H
+
 #include "dm/dm.h"
 #include "dm/gfx.h"
 #include "dm/champion.h"
@@ -92,3 +95,5 @@ public:
 };
 
 }
+
+#endif
diff --git a/engines/dm/lzw.h b/engines/dm/lzw.h
index b476c11..3603423 100644
--- a/engines/dm/lzw.h
+++ b/engines/dm/lzw.h
@@ -25,6 +25,9 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
+#ifndef DM_LZW_H
+#define DM_LZW_H
+
 #include "common/file.h"
 
 #include "dm/dm.h"
@@ -62,3 +65,5 @@ public:
 };
 
 }
+
+#endif
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index 6c128ea..9d42d6b 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -25,6 +25,9 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
+#ifndef DM_OBJECTMAN_H
+#define DM_OBJECTMAN_H
+
 #include "dm/dm.h"
 #include "dm/champion.h"
 
@@ -69,3 +72,5 @@ public:
 };
 
 }
+
+#endif
diff --git a/engines/dm/sounds.h b/engines/dm/sounds.h
index 1d09963..f50d481 100644
--- a/engines/dm/sounds.h
+++ b/engines/dm/sounds.h
@@ -25,6 +25,9 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
+#ifndef DM_SOUND_H
+#define DM_SOUND_H
+
 #include "dm/dm.h"
 
 namespace DM {
@@ -94,3 +97,5 @@ public:
 };
 
 }
+
+#endif


Commit: 2e0fae6547e9a69b5f0e308e78e91e56995721f3
    https://github.com/scummvm/scummvm/commit/2e0fae6547e9a69b5f0e308e78e91e56995721f3
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-09-03T10:56:30+02:00

Commit Message:
DM: Fix copyright issues

Changed paths:
    engines/dm/configure.engine
    engines/dm/detection.cpp



diff --git a/engines/dm/configure.engine b/engines/dm/configure.engine
index 476044a..50a3d99 100644
--- a/engines/dm/configure.engine
+++ b/engines/dm/configure.engine
@@ -1,31 +1,3 @@
-# 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.
-#
-#
-#
-#
-# Based on the Reverse Engineering work of Christophe Fontanel,
-# maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
-#
-
-
 # This file is included from the main "configure" script
 # add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
 add_engine dm "Dungeon Master" yes
diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp
index ad711c5..7152871 100644
--- a/engines/dm/detection.cpp
+++ b/engines/dm/detection.cpp
@@ -94,7 +94,7 @@ public:
 	}
 
 	virtual const char *getOriginalCopyright() const {
-		return "Dummy";
+		return "Dungeon Master (C) 1987 FTL Games";
 	}
 
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {


Commit: d059a1cd4b7491e04d10af728ae55a74f0d5035c
    https://github.com/scummvm/scummvm/commit/d059a1cd4b7491e04d10af728ae55a74f0d5035c
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-09-03T11:12:16+02:00

Commit Message:
DM: Use delayMillis(10) in mainLoop

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/dm.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 958375b..6411024 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -5,6 +5,8 @@ Bugs:
 
 	Logic:
 		Items thrown on the right side end up on the left side 
+		Can't place torch in player's hand after loading, can do so only after brining up the inventory
+		Restarting the game after the party is dead segfaults
 
 Todo:
 	Add wiki entry for DM
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 538124f..a0adf5e 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -401,7 +401,7 @@ Common::Error DMEngine::run() {
 
 void DMEngine::gameloop() {
 	_canLoadFromGMM = true;
-	_waitForInputMaxVerticalBlankCount = 10;
+	_waitForInputMaxVerticalBlankCount = 15;
 	while (true) {
 		if (_engineShouldQuit) {
 			_canLoadFromGMM = false;
@@ -503,9 +503,10 @@ void DMEngine::gameloop() {
 				_eventMan->highlightBoxDisable();
 			}
 
-			_system->delayMillis(2);
-			if (++vblankCounter >= _waitForInputMaxVerticalBlankCount * 4)
+			if (++vblankCounter > _waitForInputMaxVerticalBlankCount)
 				_stopWaitingForPlayerInput = true;
+			else if (!_stopWaitingForPlayerInput)
+				_system->delayMillis(10);
 
 		} while (!_stopWaitingForPlayerInput || !_gameTimeTicking);
 	}


Commit: 2fec2241e446b19baf2f3a4bb09bc4ba10ec6a13
    https://github.com/scummvm/scummvm/commit/2fec2241e446b19baf2f3a4bb09bc4ba10ec6a13
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-03T13:13:50+02:00

Commit Message:
DM: More renaming and refactoring in InventoryMan

Changed paths:
    engines/dm/inventory.cpp



diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 516bc46..4320374 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -786,105 +786,95 @@ void InventoryMan::setDungeonViewPalette() {
 }
 
 void InventoryMan::decreaseTorchesLightPower() {
-	bool L1048_B_TorchChargeCountChanged = false;
-	int16 L1046_i_ChampionCount = _vm->_championMan->_partyChampionCount;
-	if (_vm->_championMan->_candidateChampionOrdinal) {
-		L1046_i_ChampionCount--;
-	}
-	Champion *L1050_ps_Champion = _vm->_championMan->_champions;
-	while (L1046_i_ChampionCount--) {
-		int16 L1047_i_SlotIndex = k1_ChampionSlotActionHand + 1;
-		while (L1047_i_SlotIndex--) {
-			int16 L1049_i_IconIndex = _vm->_objectMan->getIconIndex(L1050_ps_Champion->_slots[L1047_i_SlotIndex]);
-			if ((L1049_i_IconIndex >= k4_IconIndiceWeaponTorchUnlit) && (L1049_i_IconIndex <= k7_IconIndiceWeaponTorchLit)) {
-				Weapon *L1051_ps_Weapon = (Weapon *)_vm->_dungeonMan->getThingData(L1050_ps_Champion->_slots[L1047_i_SlotIndex]);
-				if (L1051_ps_Weapon->getChargeCount()) {
-					if (L1051_ps_Weapon->setChargeCount(L1051_ps_Weapon->getChargeCount() - 1) == 0) {
-						L1051_ps_Weapon->setDoNotDiscard(false);
+	bool torchChargeCountChanged = false;
+	int16 championCount = _vm->_championMan->_partyChampionCount;
+	if (_vm->_championMan->_candidateChampionOrdinal)
+		championCount--;
+
+	Champion *curChampion = _vm->_championMan->_champions;
+	while (championCount--) {
+		int16 slotIndex = k1_ChampionSlotActionHand + 1;
+		while (slotIndex--) {
+			int16 iconIndex = _vm->_objectMan->getIconIndex(curChampion->_slots[slotIndex]);
+			if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit)) {
+				Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->getThingData(curChampion->_slots[slotIndex]);
+				if (curWeapon->getChargeCount()) {
+					if (curWeapon->setChargeCount(curWeapon->getChargeCount() - 1) == 0) {
+						curWeapon->setDoNotDiscard(false);
 					}
-					L1048_B_TorchChargeCountChanged = true;
+					torchChargeCountChanged = true;
 				}
 			}
 		}
-		L1050_ps_Champion++;
+		curChampion++;
 	}
-	if (L1048_B_TorchChargeCountChanged) {
+
+	if (torchChargeCountChanged) {
 		setDungeonViewPalette();
 		_vm->_championMan->drawChangedObjectIcons();
 	}
 }
 
 void InventoryMan::drawChampionSkillsAndStatistics() {
+	static const char* statisticNamesEN[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"};
+	static const char* statisticNamesDE[7] = {"L", "STAERKE", "FLINKHEIT", "WEISHEIT", "VITALITAET", "ANTI-MAGIE", "ANTI-FEUER"};
+	static const char* statisticNamesFR[7] = {"L", "FORCE", "DEXTERITE", "SAGESSE", "VITALITE", "ANTI-MAGIE", "ANTI-FEU"};
+
+	const char **statisticNames;
 
-	uint16 L1090_ui_Multiple;
-#define AL1090_ui_SkillIndex     L1090_ui_Multiple
-#define AL1090_ui_StatisticIndex L1090_ui_Multiple
-	int16 L1091_i_Y;
-	int16 L1092_i_Multiple;
-#define AL1092_i_SkillLevel            L1092_i_Multiple
-#define AL1092_i_StatisticCurrentValue L1092_i_Multiple
-	uint16 L1093_ui_ChampionIndex;
-	Champion* L1094_ps_Champion;
-	int16 L1095_i_StatisticColor;
-	uint16 L1096_ui_StatisticMaximumValue;
-	char L1097_ac_String[20];
-
-	static const char* G0431_apc_StatisticNames_EN_ANY[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"};
-	static const char* G0431_apc_StatisticNames_DE_DEU[7] = {"L", "STAERKE", "FLINKHEIT", "WEISHEIT", "VITALITAET", "ANTI-MAGIE", "ANTI-FEUER"};
-	static const char* G0431_apc_StatisticNames_FR_FRA[7] = {"L", "FORCE", "DEXTERITE", "SAGESSE", "VITALITE", "ANTI-MAGIE", "ANTI-FEU"};
-	const char **G0431_apc_StatisticNames;
 	switch (_vm->getGameLanguage()) { // localized
+	case Common::DE_DEU:
+		statisticNames = statisticNamesDE;
+		break;
+	case Common::FR_FRA:
+		statisticNames = statisticNamesFR;
+		break;
 	default:
-	case Common::EN_ANY: G0431_apc_StatisticNames = G0431_apc_StatisticNames_EN_ANY; break;
-	case Common::DE_DEU: G0431_apc_StatisticNames = G0431_apc_StatisticNames_DE_DEU; break;
-	case Common::FR_FRA: G0431_apc_StatisticNames = G0431_apc_StatisticNames_FR_FRA; break;
+		statisticNames = statisticNamesEN;
+		break;
 	}
 
 	closeChest();
-	L1094_ps_Champion = &_vm->_championMan->_champions[L1093_ui_ChampionIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal)];
+	uint16 championIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal);
+	Champion *curChampion = &_vm->_championMan->_champions[championIndex];
 	_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k20_PanelEmptyIndice), _boxPanel, k72_byteWidth, k8_ColorRed, 73);
-	L1091_i_Y = 58;
-	for (AL1090_ui_SkillIndex = k0_ChampionSkillFighter; AL1090_ui_SkillIndex <= k3_ChampionSkillWizard; AL1090_ui_SkillIndex++) {
-		AL1092_i_SkillLevel = MIN((uint16)16, _vm->_championMan->getSkillLevel(L1093_ui_ChampionIndex, AL1090_ui_SkillIndex | k0x8000_IgnoreTemporaryExperience));
-		if (AL1092_i_SkillLevel == 1)
+	int16 textPosY = 58;
+	for (uint16 idx = k0_ChampionSkillFighter; idx <= k3_ChampionSkillWizard; idx++) {
+		int16 skillLevel = MIN((uint16)16, _vm->_championMan->getSkillLevel(championIndex, idx | k0x8000_IgnoreTemporaryExperience));
+		if (skillLevel == 1)
 			continue;
 
+		Common::String displayString;
+
 		switch (_vm->getGameLanguage()) { // localized
-		default:
-		case Common::EN_ANY:
-		case Common::DE_DEU: // english and german versions are the same
-			strcpy(L1097_ac_String, _skillLevelNames[AL1092_i_SkillLevel - 2]);
-			strcat(L1097_ac_String, " ");
-			strcat(L1097_ac_String, _vm->_championMan->_baseSkillName[AL1090_ui_SkillIndex]);
-			break;
 		case Common::FR_FRA:
-			strcat(L1097_ac_String, _vm->_championMan->_baseSkillName[AL1090_ui_SkillIndex]);
-			strcat(L1097_ac_String, " ");
-			strcpy(L1097_ac_String, _skillLevelNames[AL1092_i_SkillLevel - 2]);
+			// Fix original bug: Due to a copy&paste error, the string was concatenate then overwritten be the last part
+			displayString = Common::String::format("%s %s", _vm->_championMan->_baseSkillName[idx], _skillLevelNames[skillLevel - 2]);
+			break;
+		default: // English and German versions are built the same way
+			displayString = Common::String::format("%s %s", _skillLevelNames[skillLevel - 2], _vm->_championMan->_baseSkillName[idx]);
 			break;
 		}
-		_vm->_textMan->printToViewport(108, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String);
-		L1091_i_Y += 7;
+		_vm->_textMan->printToViewport(108, textPosY, k13_ColorLightestGray, displayString.c_str());
+		textPosY += 7;
 	}
-	L1091_i_Y = 86;
-	for (AL1090_ui_StatisticIndex = k1_ChampionStatStrength; AL1090_ui_StatisticIndex <= k6_ChampionStatAntifire; AL1090_ui_StatisticIndex++) {
-		_vm->_textMan->printToViewport(108, L1091_i_Y, k13_ColorLightestGray, G0431_apc_StatisticNames[AL1090_ui_StatisticIndex]);
-		AL1092_i_StatisticCurrentValue = L1094_ps_Champion->_statistics[AL1090_ui_StatisticIndex][k1_ChampionStatCurrent];
-		L1096_ui_StatisticMaximumValue = L1094_ps_Champion->_statistics[AL1090_ui_StatisticIndex][k0_ChampionStatMaximum];
-		if (AL1092_i_StatisticCurrentValue < L1096_ui_StatisticMaximumValue) {
-			L1095_i_StatisticColor = k8_ColorRed;
-		} else {
-			if (AL1092_i_StatisticCurrentValue > L1096_ui_StatisticMaximumValue) {
-				L1095_i_StatisticColor = k7_ColorLightGreen;
-			} else {
-				L1095_i_StatisticColor = k13_ColorLightestGray;
-			}
-		}
-		_vm->_textMan->printToViewport(174, L1091_i_Y, (Color)L1095_i_StatisticColor, _vm->_championMan->getStringFromInteger(AL1092_i_StatisticCurrentValue, true, 3).c_str());
-		strcpy(L1097_ac_String, "/");
-		strcat(L1097_ac_String, _vm->_championMan->getStringFromInteger(L1096_ui_StatisticMaximumValue, true, 3).c_str());
-		_vm->_textMan->printToViewport(192, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String);
-		L1091_i_Y += 7;
+	textPosY = 86;
+	for (uint16 idx = k1_ChampionStatStrength; idx <= k6_ChampionStatAntifire; idx++) {
+		_vm->_textMan->printToViewport(108, textPosY, k13_ColorLightestGray, statisticNames[idx]);
+		int16 statisticCurrentValue = curChampion->_statistics[idx][k1_ChampionStatCurrent];
+		uint16 statisticMaximumValue = curChampion->_statistics[idx][k0_ChampionStatMaximum];
+		int16 statisticColor;
+		if (statisticCurrentValue < statisticMaximumValue)
+			statisticColor = k8_ColorRed;
+		else if (statisticCurrentValue > statisticMaximumValue)
+			statisticColor = k7_ColorLightGreen;
+		else
+			statisticColor = k13_ColorLightestGray;
+
+		_vm->_textMan->printToViewport(174, textPosY, (Color)statisticColor, _vm->_championMan->getStringFromInteger(statisticCurrentValue, true, 3).c_str());
+		Common::String displayString = "/" + _vm->_championMan->getStringFromInteger(statisticMaximumValue, true, 3);
+		_vm->_textMan->printToViewport(192, textPosY, k13_ColorLightestGray, displayString.c_str());
+		textPosY += 7;
 	}
 }
 
@@ -898,14 +888,13 @@ void InventoryMan::drawStopPressingMouth() {
 }
 
 void InventoryMan::drawStopPressingEye() {
-	Thing L1100_T_LeaderHandObject;
-
 	drawIconToViewport(k202_IconIndiceEyeNotLooking, 12, 13);
 	drawPanel();
 	_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
-	if ((L1100_T_LeaderHandObject = _vm->_championMan->_leaderHandObject) != Thing::_none) {
-		_vm->_objectMan->drawLeaderObjectName(L1100_T_LeaderHandObject);
-	}
+	Thing leaderHandObject = _vm->_championMan->_leaderHandObject;
+	if (leaderHandObject != Thing::_none)
+		_vm->_objectMan->drawLeaderObjectName(leaderHandObject);
+
 	_vm->_eventMan->showMouse();
 	_vm->_eventMan->showMouse();
 	_vm->_eventMan->showMouse();
@@ -943,9 +932,9 @@ void InventoryMan::clickOnMouth() {
 
 
 	if (_vm->_championMan->_leaderEmptyHanded) {
-		if (_panelContent == k0_PanelContentFoodWaterPoisoned) {
+		if (_panelContent == k0_PanelContentFoodWaterPoisoned)
 			return;
-		}
+
 		_vm->_eventMan->_ignoreMouseMovements = true;
 		_vm->_pressingMouth = true;
 		if (!_vm->_eventMan->isMouseButtonDown(k1_LeftMouseButton)) {
@@ -960,14 +949,14 @@ void InventoryMan::clickOnMouth() {
 		}
 		return;
 	}
-	if (_vm->_championMan->_candidateChampionOrdinal) {
+
+	if (_vm->_championMan->_candidateChampionOrdinal)
 		return;
-	}
 
 	L1078_T_Thing = _vm->_championMan->_leaderHandObject;
-	if (!getFlag(_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(L1078_T_Thing)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) {
+	if (!getFlag(_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(L1078_T_Thing)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth))
 		return;
-	}
+
 	L1079_ui_IconIndex = _vm->_objectMan->getIconIndex(L1078_T_Thing);
 	AL1088_ui_ThingType = L1078_T_Thing.getType();
 	L1089_ui_Weight = _vm->_dungeonMan->getObjectWeight(L1078_T_Thing);


Commit: 9aa582e341e188895f8a48cc765aaf96d58448a0
    https://github.com/scummvm/scummvm/commit/9aa582e341e188895f8a48cc765aaf96d58448a0
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-03T13:53:52+02:00

Commit Message:
DM: Refactor string manipulation in drawPanelObject

Changed paths:
    engines/dm/inventory.cpp
    engines/dm/menus.cpp



diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 4320374..9c12835 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -499,21 +499,16 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k29_ObjectDescCircleIndice),
 								   boxObjectDescCircle, k16_byteWidth, k12_ColorDarkestGray, 27);
 
-		const char *descString = nullptr;
-		char str[40];
+		Common::String descString;
+		Common::String str;
 		if (iconIndex == k147_IconIndiceJunkChampionBones) {
 			switch (_vm->getGameLanguage()) { // localized
-			default:
-			case Common::EN_ANY:
-			case Common::DE_DEU: // german and english versions are the same
-				strcpy(str, champMan._champions[((Junk *)rawThingPtr)->getChargeCount()]._name);
-				strcat(str, " ");
-				strcat(str, objMan._objectNames[iconIndex]);
-				break;
 			case Common::FR_FRA:
-				strcat(str, objMan._objectNames[iconIndex]);
-				strcat(str, " ");
-				strcpy(str, champMan._champions[((Junk *)rawThingPtr)->getChargeCount()]._name);
+				// Fix original bug dur to a cut&paste error: string was concatenated then overwritten by the name
+				str = Common::String::format("%s %s", objMan._objectNames[iconIndex], champMan._champions[((Junk *)rawThingPtr)->getChargeCount()]._name);
+				break;
+			default: // German and English versions are the same
+				str = Common::String::format("%s %s", champMan._champions[((Junk *)rawThingPtr)->getChargeCount()]._name, objMan._objectNames[iconIndex]);
 				break;
 			}
 
@@ -521,16 +516,15 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		} else if ((thingType == k8_PotionThingType)
 				   && (iconIndex != k163_IconIndicePotionWaterFlask)
 				   && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
-			str[0] = '_' + ((Potion *)rawThingPtr)->getPower() / 40;
-			str[1] = ' ';
-			str[2] = '\0';
-			strcat(str, objMan._objectNames[iconIndex]);
+			str = ('_' + ((Potion *)rawThingPtr)->getPower() / 40);
+			str += " ";
+			str += objMan._objectNames[iconIndex];
 			descString = str;
 		} else {
 			descString = objMan._objectNames[iconIndex];
 		}
 
-		textMan.printToViewport(134, 68, k13_ColorLightestGray, descString);
+		textMan.printToViewport(134, 68, k13_ColorLightestGray, descString.c_str());
 		drawIconToViewport(iconIndex, 111, 59);
 
 
@@ -577,59 +571,47 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		case k10_JunkThingType: {
 			if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
 				potentialAttribMask = 0;
-				const char *descString_EN_ANY[4] = {"(EMPTY)", "(ALMOST EMPTY)", "(ALMOST FULL)", "(FULL)"};
-				const char *descString_DE_DEU[4] = {"(LEER)", "(FAST LEER)", "(FAST VOLL)", "(VOLL)"};
-				const char *descString_FR_FRA[4] = {"(VIDE)", "(PRESQUE VIDE)", "(PRESQUE PLEINE)", "(PLEINE)"};
+				const char *descStringEN[4] = {"(EMPTY)", "(ALMOST EMPTY)", "(ALMOST FULL)", "(FULL)"};
+				const char *descStringDE[4] = {"(LEER)", "(FAST LEER)", "(FAST VOLL)", "(VOLL)"};
+				const char *descStringFR[4] = {"(VIDE)", "(PRESQUE VIDE)", "(PRESQUE PLEINE)", "(PLEINE)"};
 
 				Junk *junk = (Junk *)rawThingPtr;
 				switch (_vm->getGameLanguage()) { // localized
-				default:
-				case Common::EN_ANY:
-					descString = descString_EN_ANY[junk->getChargeCount()];
-					break;
 				case Common::DE_DEU:
-					descString = descString_DE_DEU[junk->getChargeCount()];
+					descString = descStringDE[junk->getChargeCount()];
 					break;
 				case Common::FR_FRA:
-					descString = descString_FR_FRA[junk->getChargeCount()];
+					descString = descStringFR[junk->getChargeCount()];
+					break;
+				default:
+					descString = descStringEN[junk->getChargeCount()];
 					break;
 				}
 
-				drawPanelObjectDescriptionString(descString);
+				drawPanelObjectDescriptionString(descString.c_str());
 			} else if ((iconIndex >= k0_IconIndiceJunkCompassNorth) && (iconIndex <= k3_IconIndiceJunkCompassWest)) {
+				const static char *directionNameEN[4] = {"NORTH", "EAST", "SOUTH", "WEST"};
+				const static char *directionNameDE[4] = {"NORDEN", "OSTEN", "SUEDEN", "WESTEN"};
+				const static char *directionNameFR[4] = {"AU NORD", "A L'EST", "AU SUD", "A L'OUEST"};
+
 				potentialAttribMask = 0;
 
 				switch (_vm->getGameLanguage()) { // localized
-				default:
-				case Common::EN_ANY:
-					strcpy(str, "PARTY FACING ");
-					break;
 				case Common::DE_DEU:
-					strcpy(str, "GRUPPE BLICKT NACH ");
+					str = "GRUPPE BLICKT NACH ";
+					str += directionNameDE[iconIndex];
 					break;
 				case Common::FR_FRA:
-					strcpy(str, "GROUPE FACE ");
+					str = "GROUPE FACE ";
+					str += directionNameFR[iconIndex];
 					break;
-				}
-
-
-				const static char* directionName_EN_ANY[4] = {"NORTH", "EAST", "SOUTH", "WEST"};
-				const static char* directionName_DE_DEU[4] = {"NORDEN", "OSTEN", "SUEDEN", "WESTEN"};
-				const static char* directionName_FR_FRA[4] = {"AU NORD", "A L'EST", "AU SUD", "A L'OUEST"};
-				switch (_vm->getGameLanguage()) { // localized
 				default:
-				case Common::EN_ANY:
-					strcat(str, directionName_EN_ANY[iconIndex]);
-					break;
-				case Common::DE_DEU:
-					strcat(str, directionName_DE_DEU[iconIndex]);
-					break;
-				case Common::FR_FRA:
-					strcat(str, directionName_FR_FRA[iconIndex]);
+					str = "PARTY FACING ";
+					str += directionNameEN[iconIndex];
 					break;
 				}
 
-				drawPanelObjectDescriptionString(str);
+				drawPanelObjectDescriptionString(str.c_str());
 			} else {
 				Junk *junk = (Junk *)rawThingPtr;
 				potentialAttribMask = k0x0001_DescriptionMaskConsumable;
@@ -642,73 +624,54 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 		} // end of switch 
 
 		if (potentialAttribMask) {
-			static const char *attribString_EN_ANY[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"};
-			static const char *attribString_DE_DEU[4] = {"ESSBAR", "VERGIFTET", "DEFEKT", "VERFLUCHT"};
-			static const char *attribString_FR_FRA[4] = {"COMESTIBLE", "EMPOISONNE", "BRISE", "MAUDIT"};
+			static const char *attribStringEN[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"};
+			static const char *attribStringDE[4] = {"ESSBAR", "VERGIFTET", "DEFEKT", "VERFLUCHT"};
+			static const char *attribStringFR[4] = {"COMESTIBLE", "EMPOISONNE", "BRISE", "MAUDIT"};
 			const char **attribString = nullptr;
 
 			switch (_vm->getGameLanguage()) { // localized
-			default:
-			case Common::EN_ANY:
-				attribString = attribString_EN_ANY;
-				break;
 			case Common::DE_DEU:
-				attribString = attribString_DE_DEU;
+				attribString = attribStringDE;
 				break;
 			case Common::FR_FRA:
-				attribString = attribString_FR_FRA;
+				attribString = attribStringFR;
+				break;
+			default:
+				attribString = attribStringEN;
 				break;
 			}
 
-			buildObjectAttributeString(potentialAttribMask, actualAttribMask, attribString, str, "(", ")");
-			drawPanelObjectDescriptionString(str);
+			char destString[40];
+			buildObjectAttributeString(potentialAttribMask, actualAttribMask, attribString, destString, "(", ")");
+			drawPanelObjectDescriptionString(destString);
 		}
 
+		uint16 weight = dunMan.getObjectWeight(thingToDraw);
 		switch (_vm->getGameLanguage()) { // localized
-		default:
-		case Common::EN_ANY:
-			strcpy(str, "WEIGHS ");
-			break;
 		case Common::DE_DEU:
-			strcpy(str, "WIEGT ");
+			str = "WIEGT " + champMan.getStringFromInteger(weight / 10, false, 3) + ",";
 			break;
 		case Common::FR_FRA:
-			strcpy(str, "PESE ");
+			str = "PESE " + champMan.getStringFromInteger(weight / 10, false, 3) + "KG,";
 			break;
-		}
-
-
-		uint16 weight = dunMan.getObjectWeight(thingToDraw);
-		strcat(str, champMan.getStringFromInteger(weight / 10, false, 3).c_str());
-
-		switch (_vm->getGameLanguage()) { // localized
 		default:
-		case Common::EN_ANY:
-			strcat(str, ".");
-			break;
-		case Common::DE_DEU:
-			strcat(str, ",");
-			break;
-		case Common::FR_FRA:
-			strcat(str, "KG,");
+			str = "WEIGHS " + champMan.getStringFromInteger(weight / 10, false, 3) + ".";
 			break;
 		}
 
 		weight -= (weight / 10) * 10;
-		strcat(str, champMan.getStringFromInteger(weight, false, 1).c_str());
+		str += champMan.getStringFromInteger(weight, false, 1);
 
 		switch (_vm->getGameLanguage()) { // localized
-		default:
-		case Common::EN_ANY:
-		case Common::DE_DEU:
-			strcat(str, " KG.");
-			break;
 		case Common::FR_FRA:
-			strcat(str, ".");
+			str += ".";
+			break;
+		default:
+			str += " KG.";
 			break;
 		}
 
-		drawPanelObjectDescriptionString(str);
+		drawPanelObjectDescriptionString(str.c_str());
 	}
 	drawPanelArrowOrEye(pressingEye);
 }
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 32d6c62..687e619 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -837,13 +837,14 @@ void MenuMan::addChampionSymbol(int16 symbolIndex) {
 		{1, 2, 3, 4, 5, 6},   /* Power 1 */
 		{2, 3, 4, 5, 6, 7},   /* Power 2 */
 		{4, 5, 6, 7, 7, 9},   /* Power 3 */
-		{2, 2, 3, 4, 6, 7}}; /* Power 4 */
+		{2, 2, 3, 4, 6, 7}    /* Power 4 */
+	};
 	static byte G0486_auc_Graphic560_SymbolManaCostMultiplier[6] = {8, 12, 16, 20, 24, 28};
 
 	uint16 L1222_ui_SymbolStep;
 	uint16 L1223_ui_ManaCost;
 	uint16 L1224_ui_SymbolIndex;
-	Champion* L1225_ps_Champion;
+	Champion *L1225_ps_Champion;
 
 	L1225_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
 	L1222_ui_SymbolStep = L1225_ps_Champion->_symbolStep;
@@ -867,7 +868,7 @@ void MenuMan::addChampionSymbol(int16 symbolIndex) {
 
 void MenuMan::deleteChampionSymbol() {
 	int16 L1226_ui_SymbolStep;
-	Champion* L1228_ps_Champion;
+	Champion *L1228_ps_Champion;
 
 	L1228_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
 	if (!strlen(L1228_ps_Champion->_symbols)) {


Commit: fbe9c92ce1418238d5aaed3e88f7982d80fd375d
    https://github.com/scummvm/scummvm/commit/fbe9c92ce1418238d5aaed3e88f7982d80fd375d
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-03T14:20:13+02:00

Commit Message:
DM: Fix the style used for some pointers and casts

Changed paths:
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.h
    engines/dm/group.cpp
    engines/dm/group.h



diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 35a1f39..6127da0 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -324,7 +324,7 @@ public:
 	int16 _waitForInputMaxVerticalBlankCount; // @ G0318_i_WaitForInputMaximumVerticalBlankCount
 };
 
-bool readSaveGameHeader(Common::InSaveFile* in, SaveGameHeader* header);
+bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader *header);
 
 } // End of namespace DM
 
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 67f0ac7..1356120 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -49,31 +49,31 @@ void DungeonMan::setupConstants() {
 	ObjectInfo objectInfo[180] = { // @ G0237_as_Graphic559_ObjectInfo
 		/* { Type, ObjectAspectIndex, ActionSetIndex, AllowedSlots } */
 		ObjectInfo(30,  1,  0, 0x0500),   /* COMPASS        Pouch/Chest */
-		ObjectInfo(144,  0,  0, 0x0200),   /* COMPASS        Hands */
-		ObjectInfo(148, 67,  0, 0x0500),   /* COMPASS        Pouch/Chest */
-		ObjectInfo(149, 67,  0, 0x0500),   /* COMPASS        Pouch/Chest */
-		ObjectInfo(150, 67,  0, 0x0500),   /* TORCH          Pouch/Chest */
-		ObjectInfo(151, 67, 42, 0x0500),   /* TORCH          Pouch/Chest */
-		ObjectInfo(152, 67,  0, 0x0500),   /* TORCH          Pouch/Chest */
-		ObjectInfo(153, 67,  0, 0x0500),   /* TORCH          Pouch/Chest */
-		ObjectInfo(154,  2,  0, 0x0501),   /* WATERSKIN      Mouth/Pouch/Chest */
-		ObjectInfo(155,  2,  0, 0x0501),   /* WATER          Mouth/Pouch/Chest */
-		ObjectInfo(156,  2,  0, 0x0501),   /* JEWEL SYMAL    Mouth/Pouch/Chest */
-		ObjectInfo(157,  2,  0, 0x0501),   /* JEWEL SYMAL    Mouth/Pouch/Chest */
-		ObjectInfo(158,  2,  0, 0x0501),   /* ILLUMULET      Mouth/Pouch/Chest */
-		ObjectInfo(159,  2,  0, 0x0501),   /* ILLUMULET      Mouth/Pouch/Chest */
-		ObjectInfo(160,  2,  0, 0x0501),   /* FLAMITT        Mouth/Pouch/Chest */
-		ObjectInfo(161,  2,  0, 0x0501),   /* FLAMITT        Mouth/Pouch/Chest */
-		ObjectInfo(162,  2,  0, 0x0501),   /* EYE OF TIME    Mouth/Pouch/Chest */
-		ObjectInfo(163,  2,  0, 0x0501),   /* EYE OF TIME    Mouth/Pouch/Chest */
-		ObjectInfo(164, 68,  0, 0x0500),   /* STORMRING      Pouch/Chest */
-		ObjectInfo(165, 68,  0, 0x0500),   /* STORMRING      Pouch/Chest */
-		ObjectInfo(166, 68,  0, 0x0500),   /* STAFF OF CLAWS Pouch/Chest */
-		ObjectInfo(167, 68, 42, 0x0500),   /* STAFF OF CLAWS Pouch/Chest */
-		ObjectInfo(195, 80,  0, 0x0500),   /* STAFF OF CLAWS Pouch/Chest */
+		ObjectInfo(144,  0,  0, 0x0200),  /* COMPASS        Hands */
+		ObjectInfo(148, 67,  0, 0x0500),  /* COMPASS        Pouch/Chest */
+		ObjectInfo(149, 67,  0, 0x0500),  /* COMPASS        Pouch/Chest */
+		ObjectInfo(150, 67,  0, 0x0500),  /* TORCH          Pouch/Chest */
+		ObjectInfo(151, 67, 42, 0x0500),  /* TORCH          Pouch/Chest */
+		ObjectInfo(152, 67,  0, 0x0500),  /* TORCH          Pouch/Chest */
+		ObjectInfo(153, 67,  0, 0x0500),  /* TORCH          Pouch/Chest */
+		ObjectInfo(154,  2,  0, 0x0501),  /* WATERSKIN      Mouth/Pouch/Chest */
+		ObjectInfo(155,  2,  0, 0x0501),  /* WATER          Mouth/Pouch/Chest */
+		ObjectInfo(156,  2,  0, 0x0501),  /* JEWEL SYMAL    Mouth/Pouch/Chest */
+		ObjectInfo(157,  2,  0, 0x0501),  /* JEWEL SYMAL    Mouth/Pouch/Chest */
+		ObjectInfo(158,  2,  0, 0x0501),  /* ILLUMULET      Mouth/Pouch/Chest */
+		ObjectInfo(159,  2,  0, 0x0501),  /* ILLUMULET      Mouth/Pouch/Chest */
+		ObjectInfo(160,  2,  0, 0x0501),  /* FLAMITT        Mouth/Pouch/Chest */
+		ObjectInfo(161,  2,  0, 0x0501),  /* FLAMITT        Mouth/Pouch/Chest */
+		ObjectInfo(162,  2,  0, 0x0501),  /* EYE OF TIME    Mouth/Pouch/Chest */
+		ObjectInfo(163,  2,  0, 0x0501),  /* EYE OF TIME    Mouth/Pouch/Chest */
+		ObjectInfo(164, 68,  0, 0x0500),  /* STORMRING      Pouch/Chest */
+		ObjectInfo(165, 68,  0, 0x0500),  /* STORMRING      Pouch/Chest */
+		ObjectInfo(166, 68,  0, 0x0500),  /* STAFF OF CLAWS Pouch/Chest */
+		ObjectInfo(167, 68, 42, 0x0500),  /* STAFF OF CLAWS Pouch/Chest */
+		ObjectInfo(195, 80,  0, 0x0500),  /* STAFF OF CLAWS Pouch/Chest */
 		ObjectInfo(16, 38, 43, 0x0500),   /* BOLT BLADE     Pouch/Chest */
 		ObjectInfo(18, 38,  7, 0x0500),   /* BOLT BLADE     Pouch/Chest */
-		ObjectInfo(4, 35,  5, 0x0400),   /* FURY           Chest */
+		ObjectInfo(4, 35,  5, 0x0400),    /* FURY           Chest */
 		ObjectInfo(14, 37,  6, 0x0400),   /* FURY           Chest */
 		ObjectInfo(20, 11,  8, 0x0040),   /* THE FIRESTAFF  Quiver 1 */
 		ObjectInfo(23, 12,  9, 0x0040),   /* THE FIRESTAFF  Quiver 1 */
@@ -114,14 +114,14 @@ void DungeonMan::setupConstants() {
 		ObjectInfo(64, 51, 33, 0x0040),   /* SNAKE STAFF    Quiver 1 */
 		ObjectInfo(65, 32,  5, 0x0440),   /* THE CONDUIT    Quiver 1/Chest */
 		ObjectInfo(66, 30, 35, 0x0040),   /* DRAGON SPIT    Quiver 1 */
-		ObjectInfo(135, 65, 36, 0x0440),   /* SCEPTRE OF LYF Quiver 1/Chest */
-		ObjectInfo(143, 45, 27, 0x0040),   /* ROBE           Quiver 1 */
+		ObjectInfo(135, 65, 36, 0x0440),  /* SCEPTRE OF LYF Quiver 1/Chest */
+		ObjectInfo(143, 45, 27, 0x0040),  /* ROBE           Quiver 1 */
 		ObjectInfo(28, 82,  1, 0x0040),   /* FINE ROBE      Quiver 1 */
 		ObjectInfo(80, 23,  0, 0x040C),   /* KIRTLE         Neck/Torso/Chest */
 		ObjectInfo(81, 23,  0, 0x040C),   /* SILK SHIRT     Neck/Torso/Chest */
 		ObjectInfo(82, 23,  0, 0x0410),   /* ELVEN DOUBLET  Legs/Chest */
-		ObjectInfo(112, 55,  0, 0x0420),   /* LEATHER JERKIN Feet/Chest */
-		ObjectInfo(114,  8,  0, 0x0420),   /* TUNIC          Feet/Chest */
+		ObjectInfo(112, 55,  0, 0x0420),  /* LEATHER JERKIN Feet/Chest */
+		ObjectInfo(114,  8,  0, 0x0420),  /* TUNIC          Feet/Chest */
 		ObjectInfo(67, 24,  0, 0x0408),   /* GHI            Torso/Chest */
 		ObjectInfo(83, 24,  0, 0x0410),   /* MAIL AKETON    Legs/Chest */
 		ObjectInfo(68, 24,  0, 0x0408),   /* MITHRAL AKETON Torso/Chest */
@@ -132,102 +132,102 @@ void DungeonMan::setupConstants() {
 		ObjectInfo(86, 69,  0, 0x0410),   /* CLOAK OF NIGHT Legs/Chest */
 		ObjectInfo(71,  7,  0, 0x0408),   /* BARBARIAN HIDE Torso/Chest */
 		ObjectInfo(87,  7,  0, 0x0410),   /* ROBE           Legs/Chest */
-		ObjectInfo(119, 57,  0, 0x0420),   /* FINE ROBE      Feet/Chest */
+		ObjectInfo(119, 57,  0, 0x0420),  /* FINE ROBE      Feet/Chest */
 		ObjectInfo(72, 23,  0, 0x0408),   /* TABARD         Torso/Chest */
 		ObjectInfo(88, 23,  0, 0x0410),   /* GUNNA          Legs/Chest */
-		ObjectInfo(113, 29,  0, 0x0420),   /* ELVEN HUKE     Feet/Chest */
+		ObjectInfo(113, 29,  0, 0x0420),  /* ELVEN HUKE     Feet/Chest */
 		ObjectInfo(89, 69,  0, 0x0410),   /* LEATHER PANTS  Legs/Chest */
 		ObjectInfo(73, 69,  0, 0x0408),   /* BLUE PANTS     Torso/Chest */
 		ObjectInfo(74, 24,  0, 0x0408),   /* GHI TROUSERS   Torso/Chest */
 		ObjectInfo(90, 24,  0, 0x0410),   /* LEG MAIL       Legs/Chest */
-		ObjectInfo(103, 53,  0, 0x0402),   /* MITHRAL MAIL   Head/Chest */
-		ObjectInfo(104, 53,  0, 0x0402),   /* LEG PLATE      Head/Chest */
+		ObjectInfo(103, 53,  0, 0x0402),  /* MITHRAL MAIL   Head/Chest */
+		ObjectInfo(104, 53,  0, 0x0402),  /* LEG PLATE      Head/Chest */
 		ObjectInfo(96,  9,  0, 0x0402),   /* POLEYN OF LYTE Head/Chest */
 		ObjectInfo(97,  9,  0, 0x0402),   /* POLEYN OF DARC Head/Chest */
 		ObjectInfo(98,  9,  0, 0x0402),   /* BEZERKER HELM  Head/Chest */
-		ObjectInfo(105, 54, 41, 0x0400),   /* HELMET         Chest */
-		ObjectInfo(106, 54, 41, 0x0200),   /* BASINET        Hands */
-		ObjectInfo(108, 10, 41, 0x0200),   /* CASQUE 'N COIF Hands */
-		ObjectInfo(107, 54, 41, 0x0200),   /* ARMET          Hands */
+		ObjectInfo(105, 54, 41, 0x0400),  /* HELMET         Chest */
+		ObjectInfo(106, 54, 41, 0x0200),  /* BASINET        Hands */
+		ObjectInfo(108, 10, 41, 0x0200),  /* CASQUE 'N COIF Hands */
+		ObjectInfo(107, 54, 41, 0x0200),  /* ARMET          Hands */
 		ObjectInfo(75, 19,  0, 0x0408),   /* HELM OF LYTE   Torso/Chest */
 		ObjectInfo(91, 19,  0, 0x0410),   /* HELM OF DARC   Legs/Chest */
 		ObjectInfo(76, 19,  0, 0x0408),   /* CALISTA        Torso/Chest */
 		ObjectInfo(92, 19,  0, 0x0410),   /* CROWN OF NERRA Legs/Chest */
 		ObjectInfo(99,  9,  0, 0x0402),   /* BUCKLER        Head/Chest */
-		ObjectInfo(115, 19,  0, 0x0420),   /* HIDE SHIELD    Feet/Chest */
-		ObjectInfo(100, 52,  0, 0x0402),   /* SMALL SHIELD   Head/Chest */
+		ObjectInfo(115, 19,  0, 0x0420),  /* HIDE SHIELD    Feet/Chest */
+		ObjectInfo(100, 52,  0, 0x0402),  /* SMALL SHIELD   Head/Chest */
 		ObjectInfo(77, 20,  0, 0x0008),   /* WOODEN SHIELD  Torso */
 		ObjectInfo(93, 22,  0, 0x0010),   /* LARGE SHIELD   Legs */
-		ObjectInfo(116, 56,  0, 0x0420),   /* SHIELD OF LYTE Feet/Chest */
-		ObjectInfo(109, 10, 41, 0x0200),   /* SHIELD OF DARC Hands */
-		ObjectInfo(101, 52,  0, 0x0402),   /* SANDALS        Head/Chest */
+		ObjectInfo(116, 56,  0, 0x0420),  /* SHIELD OF LYTE Feet/Chest */
+		ObjectInfo(109, 10, 41, 0x0200),  /* SHIELD OF DARC Hands */
+		ObjectInfo(101, 52,  0, 0x0402),  /* SANDALS        Head/Chest */
 		ObjectInfo(78, 20,  0, 0x0008),   /* SUEDE BOOTS    Torso */
 		ObjectInfo(94, 22,  0, 0x0010),   /* LEATHER BOOTS  Legs */
-		ObjectInfo(117, 56,  0, 0x0420),   /* HOSEN          Feet/Chest */
-		ObjectInfo(110, 10, 41, 0x0200),   /* FOOT PLATE     Hands */
-		ObjectInfo(102, 52,  0, 0x0402),   /* GREAVE OF LYTE Head/Chest */
+		ObjectInfo(117, 56,  0, 0x0420),  /* HOSEN          Feet/Chest */
+		ObjectInfo(110, 10, 41, 0x0200),  /* FOOT PLATE     Hands */
+		ObjectInfo(102, 52,  0, 0x0402),  /* GREAVE OF LYTE Head/Chest */
 		ObjectInfo(79, 20,  0, 0x0008),   /* GREAVE OF DARC Torso */
 		ObjectInfo(95, 22,  0, 0x0010),   /* ELVEN BOOTS    Legs */
-		ObjectInfo(118, 56,  0, 0x0420),   /* GEM OF AGES    Feet/Chest */
-		ObjectInfo(111, 10, 41, 0x0200),   /* EKKHARD CROSS  Hands */
-		ObjectInfo(140, 52,  0, 0x0402),   /* MOONSTONE      Head/Chest */
-		ObjectInfo(141, 19,  0, 0x0408),   /* THE HELLION    Torso/Chest */
-		ObjectInfo(142, 22,  0, 0x0010),   /* PENDANT FERAL  Legs */
-		ObjectInfo(194, 81,  0, 0x0420),   /* COPPER COIN    Feet/Chest */
-		ObjectInfo(196, 84,  0, 0x0408),   /* SILVER COIN    Torso/Chest */
-		ObjectInfo(0, 34,  0, 0x0500),   /* GOLD COIN      Pouch/Chest */
-		ObjectInfo(8,  6,  0, 0x0501),   /* BOULDER        Mouth/Pouch/Chest */
+		ObjectInfo(118, 56,  0, 0x0420),  /* GEM OF AGES    Feet/Chest */
+		ObjectInfo(111, 10, 41, 0x0200),  /* EKKHARD CROSS  Hands */
+		ObjectInfo(140, 52,  0, 0x0402),  /* MOONSTONE      Head/Chest */
+		ObjectInfo(141, 19,  0, 0x0408),  /* THE HELLION    Torso/Chest */
+		ObjectInfo(142, 22,  0, 0x0010),  /* PENDANT FERAL  Legs */
+		ObjectInfo(194, 81,  0, 0x0420),  /* COPPER COIN    Feet/Chest */
+		ObjectInfo(196, 84,  0, 0x0408),  /* SILVER COIN    Torso/Chest */
+		ObjectInfo(0, 34,  0, 0x0500),    /* GOLD COIN      Pouch/Chest */
+		ObjectInfo(8,  6,  0, 0x0501),    /* BOULDER        Mouth/Pouch/Chest */
 		ObjectInfo(10, 15,  0, 0x0504),   /* BLUE GEM       Neck/Pouch/Chest */
 		ObjectInfo(12, 15,  0, 0x0504),   /* ORANGE GEM     Neck/Pouch/Chest */
-		ObjectInfo(146, 40,  0, 0x0500),   /* GREEN GEM      Pouch/Chest */
-		ObjectInfo(147, 41,  0, 0x0400),   /* MAGICAL BOX    Chest */
-		ObjectInfo(125,  4, 37, 0x0500),   /* MAGICAL BOX    Pouch/Chest */
-		ObjectInfo(126, 83, 37, 0x0500),   /* MIRROR OF DAWN Pouch/Chest */
-		ObjectInfo(127,  4, 37, 0x0500),   /* HORN OF FEAR   Pouch/Chest */
-		ObjectInfo(176, 18,  0, 0x0500),   /* ROPE           Pouch/Chest */
-		ObjectInfo(177, 18,  0, 0x0500),   /* RABBIT'S FOOT  Pouch/Chest */
-		ObjectInfo(178, 18,  0, 0x0500),   /* CORBAMITE      Pouch/Chest */
-		ObjectInfo(179, 18,  0, 0x0500),   /* CHOKER         Pouch/Chest */
-		ObjectInfo(180, 18,  0, 0x0500),   /* DEXHELM        Pouch/Chest */
-		ObjectInfo(181, 18,  0, 0x0500),   /* FLAMEBAIN      Pouch/Chest */
-		ObjectInfo(182, 18,  0, 0x0500),   /* POWERTOWERS    Pouch/Chest */
-		ObjectInfo(183, 18,  0, 0x0500),   /* SPEEDBOW       Pouch/Chest */
-		ObjectInfo(184, 62,  0, 0x0500),   /* CHEST          Pouch/Chest */
-		ObjectInfo(185, 62,  0, 0x0500),   /* OPEN CHEST     Pouch/Chest */
-		ObjectInfo(186, 62,  0, 0x0500),   /* ASHES          Pouch/Chest */
-		ObjectInfo(187, 62,  0, 0x0500),   /* BONES          Pouch/Chest */
-		ObjectInfo(188, 62,  0, 0x0500),   /* MON POTION     Pouch/Chest */
-		ObjectInfo(189, 62,  0, 0x0500),   /* UM POTION      Pouch/Chest */
-		ObjectInfo(190, 62,  0, 0x0500),   /* DES POTION     Pouch/Chest */
-		ObjectInfo(191, 62,  0, 0x0500),   /* VEN POTION     Pouch/Chest */
-		ObjectInfo(128, 76,  0, 0x0200),   /* SAR POTION     Hands */
-		ObjectInfo(129,  3,  0, 0x0500),   /* ZO POTION      Pouch/Chest */
-		ObjectInfo(130, 60,  0, 0x0500),   /* ROS POTION     Pouch/Chest */
-		ObjectInfo(131, 61,  0, 0x0500),   /* KU POTION      Pouch/Chest */
-		ObjectInfo(168, 27,  0, 0x0501),   /* DANE POTION    Mouth/Pouch/Chest */
-		ObjectInfo(169, 28,  0, 0x0501),   /* NETA POTION    Mouth/Pouch/Chest */
-		ObjectInfo(170, 25,  0, 0x0501),   /* BRO POTION     Mouth/Pouch/Chest */
-		ObjectInfo(171, 26,  0, 0x0501),   /* MA POTION      Mouth/Pouch/Chest */
-		ObjectInfo(172, 71,  0, 0x0401),   /* YA POTION      Mouth/Chest */
-		ObjectInfo(173, 70,  0, 0x0401),   /* EE POTION      Mouth/Chest */
-		ObjectInfo(174,  5,  0, 0x0501),   /* VI POTION      Mouth/Pouch/Chest */
-		ObjectInfo(175, 66,  0, 0x0501),   /* WATER FLASK    Mouth/Pouch/Chest */
-		ObjectInfo(120, 15,  0, 0x0504),   /* KATH BOMB      Neck/Pouch/Chest */
-		ObjectInfo(121, 15,  0, 0x0504),   /* PEW BOMB       Neck/Pouch/Chest */
-		ObjectInfo(122, 58,  0, 0x0504),   /* RA BOMB        Neck/Pouch/Chest */
-		ObjectInfo(123, 59,  0, 0x0504),   /* FUL BOMB       Neck/Pouch/Chest */
-		ObjectInfo(124, 59,  0, 0x0504),   /* APPLE          Neck/Pouch/Chest */
-		ObjectInfo(132, 79, 38, 0x0500),   /* CORN           Pouch/Chest */
-		ObjectInfo(133, 63, 38, 0x0500),   /* BREAD          Pouch/Chest */
-		ObjectInfo(134, 64,  0, 0x0500),   /* CHEESE         Pouch/Chest */
-		ObjectInfo(136, 72, 39, 0x0400),   /* SCREAMER SLICE Chest */
-		ObjectInfo(137, 73,  0, 0x0500),   /* WORM ROUND     Pouch/Chest */
-		ObjectInfo(138, 74,  0, 0x0500),   /* DRUMSTICK      Pouch/Chest */
-		ObjectInfo(139, 75,  0, 0x0504),   /* DRAGON STEAK   Neck/Pouch/Chest */
-		ObjectInfo(192, 77,  0, 0x0500),   /* IRON KEY       Pouch/Chest */
-		ObjectInfo(193, 78,  0, 0x0500),   /* KEY OF B       Pouch/Chest */
-		ObjectInfo(197, 74,  0, 0x0000),   /* SOLID KEY */
-		ObjectInfo(198, 41,  0, 0x0400)    /* SQUARE KEY     Chest */
+		ObjectInfo(146, 40,  0, 0x0500),  /* GREEN GEM      Pouch/Chest */
+		ObjectInfo(147, 41,  0, 0x0400),  /* MAGICAL BOX    Chest */
+		ObjectInfo(125,  4, 37, 0x0500),  /* MAGICAL BOX    Pouch/Chest */
+		ObjectInfo(126, 83, 37, 0x0500),  /* MIRROR OF DAWN Pouch/Chest */
+		ObjectInfo(127,  4, 37, 0x0500),  /* HORN OF FEAR   Pouch/Chest */
+		ObjectInfo(176, 18,  0, 0x0500),  /* ROPE           Pouch/Chest */
+		ObjectInfo(177, 18,  0, 0x0500),  /* RABBIT'S FOOT  Pouch/Chest */
+		ObjectInfo(178, 18,  0, 0x0500),  /* CORBAMITE      Pouch/Chest */
+		ObjectInfo(179, 18,  0, 0x0500),  /* CHOKER         Pouch/Chest */
+		ObjectInfo(180, 18,  0, 0x0500),  /* DEXHELM        Pouch/Chest */
+		ObjectInfo(181, 18,  0, 0x0500),  /* FLAMEBAIN      Pouch/Chest */
+		ObjectInfo(182, 18,  0, 0x0500),  /* POWERTOWERS    Pouch/Chest */
+		ObjectInfo(183, 18,  0, 0x0500),  /* SPEEDBOW       Pouch/Chest */
+		ObjectInfo(184, 62,  0, 0x0500),  /* CHEST          Pouch/Chest */
+		ObjectInfo(185, 62,  0, 0x0500),  /* OPEN CHEST     Pouch/Chest */
+		ObjectInfo(186, 62,  0, 0x0500),  /* ASHES          Pouch/Chest */
+		ObjectInfo(187, 62,  0, 0x0500),  /* BONES          Pouch/Chest */
+		ObjectInfo(188, 62,  0, 0x0500),  /* MON POTION     Pouch/Chest */
+		ObjectInfo(189, 62,  0, 0x0500),  /* UM POTION      Pouch/Chest */
+		ObjectInfo(190, 62,  0, 0x0500),  /* DES POTION     Pouch/Chest */
+		ObjectInfo(191, 62,  0, 0x0500),  /* VEN POTION     Pouch/Chest */
+		ObjectInfo(128, 76,  0, 0x0200),  /* SAR POTION     Hands */
+		ObjectInfo(129,  3,  0, 0x0500),  /* ZO POTION      Pouch/Chest */
+		ObjectInfo(130, 60,  0, 0x0500),  /* ROS POTION     Pouch/Chest */
+		ObjectInfo(131, 61,  0, 0x0500),  /* KU POTION      Pouch/Chest */
+		ObjectInfo(168, 27,  0, 0x0501),  /* DANE POTION    Mouth/Pouch/Chest */
+		ObjectInfo(169, 28,  0, 0x0501),  /* NETA POTION    Mouth/Pouch/Chest */
+		ObjectInfo(170, 25,  0, 0x0501),  /* BRO POTION     Mouth/Pouch/Chest */
+		ObjectInfo(171, 26,  0, 0x0501),  /* MA POTION      Mouth/Pouch/Chest */
+		ObjectInfo(172, 71,  0, 0x0401),  /* YA POTION      Mouth/Chest */
+		ObjectInfo(173, 70,  0, 0x0401),  /* EE POTION      Mouth/Chest */
+		ObjectInfo(174,  5,  0, 0x0501),  /* VI POTION      Mouth/Pouch/Chest */
+		ObjectInfo(175, 66,  0, 0x0501),  /* WATER FLASK    Mouth/Pouch/Chest */
+		ObjectInfo(120, 15,  0, 0x0504),  /* KATH BOMB      Neck/Pouch/Chest */
+		ObjectInfo(121, 15,  0, 0x0504),  /* PEW BOMB       Neck/Pouch/Chest */
+		ObjectInfo(122, 58,  0, 0x0504),  /* RA BOMB        Neck/Pouch/Chest */
+		ObjectInfo(123, 59,  0, 0x0504),  /* FUL BOMB       Neck/Pouch/Chest */
+		ObjectInfo(124, 59,  0, 0x0504),  /* APPLE          Neck/Pouch/Chest */
+		ObjectInfo(132, 79, 38, 0x0500),  /* CORN           Pouch/Chest */
+		ObjectInfo(133, 63, 38, 0x0500),  /* BREAD          Pouch/Chest */
+		ObjectInfo(134, 64,  0, 0x0500),  /* CHEESE         Pouch/Chest */
+		ObjectInfo(136, 72, 39, 0x0400),  /* SCREAMER SLICE Chest */
+		ObjectInfo(137, 73,  0, 0x0500),  /* WORM ROUND     Pouch/Chest */
+		ObjectInfo(138, 74,  0, 0x0500),  /* DRUMSTICK      Pouch/Chest */
+		ObjectInfo(139, 75,  0, 0x0504),  /* DRAGON STEAK   Neck/Pouch/Chest */
+		ObjectInfo(192, 77,  0, 0x0500),  /* IRON KEY       Pouch/Chest */
+		ObjectInfo(193, 78,  0, 0x0500),  /* KEY OF B       Pouch/Chest */
+		ObjectInfo(197, 74,  0, 0x0000),  /* SOLID KEY */
+		ObjectInfo(198, 41,  0, 0x0400)   /* SQUARE KEY     Chest */
 	};
 	ArmourInfo armourInfo[58] = { // G0239_as_Graphic559_ArmourInfo
 		/* { Weight, Defense, Attributes, Unreferenced } */
@@ -235,7 +235,7 @@ void DungeonMan::setupConstants() {
 		ArmourInfo(4,  10, 0x01),   /* CLOAK OF NIGHT */
 		ArmourInfo(3,   4, 0x01),   /* BARBARIAN HIDE */
 		ArmourInfo(6,   5, 0x02),   /* SANDALS */
-		ArmourInfo(16,  25, 0x04),   /* LEATHER BOOTS */
+		ArmourInfo(16,  25, 0x04),  /* LEATHER BOOTS */
 		ArmourInfo(4,   5, 0x00),   /* ROBE */
 		ArmourInfo(4,   5, 0x00),   /* ROBE */
 		ArmourInfo(3,   7, 0x01),   /* FINE ROBE */
@@ -249,59 +249,59 @@ void DungeonMan::setupConstants() {
 		ArmourInfo(4,  13, 0x02),   /* ELVEN BOOTS */
 		ArmourInfo(6,  17, 0x03),   /* LEATHER JERKIN */
 		ArmourInfo(8,  20, 0x03),   /* LEATHER PANTS */
-		ArmourInfo(14,  20, 0x03),   /* SUEDE BOOTS */
+		ArmourInfo(14,  20, 0x03),  /* SUEDE BOOTS */
 		ArmourInfo(6,  12, 0x02),   /* BLUE PANTS */
 		ArmourInfo(5,   9, 0x01),   /* TUNIC */
 		ArmourInfo(5,   8, 0x01),   /* GHI */
 		ArmourInfo(5,   9, 0x01),   /* GHI TROUSERS */
 		ArmourInfo(4,   1, 0x04),   /* CALISTA */
 		ArmourInfo(6,   5, 0x04),   /* CROWN OF NERRA */
-		ArmourInfo(11,  12, 0x05),   /* BEZERKER HELM */
-		ArmourInfo(14,  17, 0x05),   /* HELMET */
-		ArmourInfo(15,  20, 0x05),   /* BASINET */
-		ArmourInfo(11,  22, 0x85),   /* BUCKLER */
-		ArmourInfo(10,  16, 0x82),   /* HIDE SHIELD */
-		ArmourInfo(14,  20, 0x83),   /* WOODEN SHIELD */
-		ArmourInfo(21,  35, 0x84),   /* SMALL SHIELD */
-		ArmourInfo(65,  35, 0x05),   /* MAIL AKETON */
-		ArmourInfo(53,  35, 0x05),   /* LEG MAIL */
-		ArmourInfo(52,  70, 0x07),   /* MITHRAL AKETON */
-		ArmourInfo(41,  55, 0x07),   /* MITHRAL MAIL */
-		ArmourInfo(16,  25, 0x06),   /* CASQUE 'N COIF */
-		ArmourInfo(16,  30, 0x06),   /* HOSEN */
-		ArmourInfo(19,  40, 0x07),   /* ARMET */
-		ArmourInfo(120,  65, 0x04),   /* TORSO PLATE */
-		ArmourInfo(80,  56, 0x04),   /* LEG PLATE */
-		ArmourInfo(28,  37, 0x05),   /* FOOT PLATE */
-		ArmourInfo(34,  56, 0x84),   /* LARGE SHIELD */
-		ArmourInfo(17,  62, 0x05),   /* HELM OF LYTE */
-		ArmourInfo(108, 125, 0x04),   /* PLATE OF LYTE */
-		ArmourInfo(72,  90, 0x04),   /* POLEYN OF LYTE */
-		ArmourInfo(24,  50, 0x05),   /* GREAVE OF LYTE */
-		ArmourInfo(30,  85, 0x84),   /* SHIELD OF LYTE */
-		ArmourInfo(35,  76, 0x04),   /* HELM OF DARC */
-		ArmourInfo(141, 160, 0x04),   /* PLATE OF DARC */
-		ArmourInfo(90, 101, 0x04),   /* POLEYN OF DARC */
-		ArmourInfo(31,  60, 0x05),   /* GREAVE OF DARC */
-		ArmourInfo(40, 100, 0x84),   /* SHIELD OF DARC */
-		ArmourInfo(14,  54, 0x06),   /* DEXHELM */
-		ArmourInfo(57,  60, 0x07),   /* FLAMEBAIN */
-		ArmourInfo(81,  88, 0x04),   /* POWERTOWERS */
+		ArmourInfo(11,  12, 0x05),  /* BEZERKER HELM */
+		ArmourInfo(14,  17, 0x05),  /* HELMET */
+		ArmourInfo(15,  20, 0x05),  /* BASINET */
+		ArmourInfo(11,  22, 0x85),  /* BUCKLER */
+		ArmourInfo(10,  16, 0x82),  /* HIDE SHIELD */
+		ArmourInfo(14,  20, 0x83),  /* WOODEN SHIELD */
+		ArmourInfo(21,  35, 0x84),  /* SMALL SHIELD */
+		ArmourInfo(65,  35, 0x05),  /* MAIL AKETON */
+		ArmourInfo(53,  35, 0x05),  /* LEG MAIL */
+		ArmourInfo(52,  70, 0x07),  /* MITHRAL AKETON */
+		ArmourInfo(41,  55, 0x07),  /* MITHRAL MAIL */
+		ArmourInfo(16,  25, 0x06),  /* CASQUE 'N COIF */
+		ArmourInfo(16,  30, 0x06),  /* HOSEN */
+		ArmourInfo(19,  40, 0x07),  /* ARMET */
+		ArmourInfo(120,  65, 0x04), /* TORSO PLATE */
+		ArmourInfo(80,  56, 0x04),  /* LEG PLATE */
+		ArmourInfo(28,  37, 0x05),  /* FOOT PLATE */
+		ArmourInfo(34,  56, 0x84),  /* LARGE SHIELD */
+		ArmourInfo(17,  62, 0x05),  /* HELM OF LYTE */
+		ArmourInfo(108, 125, 0x04), /* PLATE OF LYTE */
+		ArmourInfo(72,  90, 0x04),  /* POLEYN OF LYTE */
+		ArmourInfo(24,  50, 0x05),  /* GREAVE OF LYTE */
+		ArmourInfo(30,  85, 0x84),  /* SHIELD OF LYTE */
+		ArmourInfo(35,  76, 0x04),  /* HELM OF DARC */
+		ArmourInfo(141, 160, 0x04), /* PLATE OF DARC */
+		ArmourInfo(90, 101, 0x04),  /* POLEYN OF DARC */
+		ArmourInfo(31,  60, 0x05),  /* GREAVE OF DARC */
+		ArmourInfo(40, 100, 0x84),  /* SHIELD OF DARC */
+		ArmourInfo(14,  54, 0x06),  /* DEXHELM */
+		ArmourInfo(57,  60, 0x07),  /* FLAMEBAIN */
+		ArmourInfo(81,  88, 0x04),  /* POWERTOWERS */
 		ArmourInfo(3,  16, 0x02),   /* BOOTS OF SPEED */
 		ArmourInfo(2,   3, 0x03)    /* HALTER */
 	};
 
 	WeaponInfo weaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo
 		/* { Weight, Class, Strength, KineticEnergy, Attributes } */
-		WeaponInfo(1, 130,   2,   0, 0x2000),   /* EYE OF TIME */
-		WeaponInfo(1, 131,   2,   0, 0x2000),   /* STORMRING */
+		WeaponInfo(1, 130,   2,   0, 0x2000),  /* EYE OF TIME */
+		WeaponInfo(1, 131,   2,   0, 0x2000),  /* STORMRING */
 		WeaponInfo(11, 0,   8,   2, 0x2000),   /* TORCH */
-		WeaponInfo(12, 112,  10,  80, 0x2028),   /* FLAMITT */
-		WeaponInfo(9, 129,  16,   7, 0x2000),   /* STAFF OF CLAWS */
-		WeaponInfo(30, 113,  49, 110, 0x0942),   /* BOLT BLADE */
+		WeaponInfo(12, 112,  10,  80, 0x2028), /* FLAMITT */
+		WeaponInfo(9, 129,  16,   7, 0x2000),  /* STAFF OF CLAWS */
+		WeaponInfo(30, 113,  49, 110, 0x0942), /* BOLT BLADE */
 		WeaponInfo(47, 0,  55,  20, 0x0900),   /* FURY */
-		WeaponInfo(24, 255,  25,  10, 0x20FF),   /* THE FIRESTAFF */
-		WeaponInfo(5, 2,  10,  19, 0x0200),   /* DAGGER */
+		WeaponInfo(24, 255,  25,  10, 0x20FF), /* THE FIRESTAFF */
+		WeaponInfo(5, 2,  10,  19, 0x0200),    /* DAGGER */
 		WeaponInfo(33, 0,  30,   8, 0x0900),   /* FALCHION */
 		WeaponInfo(32, 0,  34,  10, 0x0900),   /* SWORD */
 		WeaponInfo(26, 0,  38,  10, 0x0900),   /* RAPIER */
@@ -317,28 +317,28 @@ void DungeonMan::setupConstants() {
 		WeaponInfo(41, 0,  42,  13, 0x2000),   /* MACE OF ORDER */
 		WeaponInfo(50, 0,  60,  15, 0x2000),   /* MORNINGSTAR */
 		WeaponInfo(36, 0,  19,  10, 0x2700),   /* CLUB */
-		WeaponInfo(110, 0,  44,  22, 0x2600),   /* STONE CLUB */
-		WeaponInfo(10, 20,   1,  50, 0x2032),   /* BOW */
-		WeaponInfo(28, 30,   1, 180, 0x2078),   /* CROSSBOW */
+		WeaponInfo(110, 0,  44,  22, 0x2600),  /* STONE CLUB */
+		WeaponInfo(10, 20,   1,  50, 0x2032),  /* BOW */
+		WeaponInfo(28, 30,   1, 180, 0x2078),  /* CROSSBOW */
 		WeaponInfo(2, 10,   2,  10, 0x0100),   /* ARROW */
 		WeaponInfo(2, 10,   2,  28, 0x0500),   /* SLAYER */
-		WeaponInfo(19, 39,   5,  20, 0x2032),   /* SLING */
-		WeaponInfo(10, 11,   6,  18, 0x2000),   /* ROCK */
+		WeaponInfo(19, 39,   5,  20, 0x2032),  /* SLING */
+		WeaponInfo(10, 11,   6,  18, 0x2000),  /* ROCK */
 		WeaponInfo(3, 12,   7,  23, 0x0800),   /* POISON DART */
-		WeaponInfo(1, 1,   3,  19, 0x0A00),   /* THROWING STAR */
-		WeaponInfo(8, 0,   4,   4, 0x2000),   /* STICK */
-		WeaponInfo(26, 129,  12,   4, 0x2000),   /* STAFF */
-		WeaponInfo(1, 130,   0,   0, 0x2000),   /* WAND */
-		WeaponInfo(2, 140,   1,  20, 0x2000),   /* TEOWAND */
-		WeaponInfo(35, 128,  18,   6, 0x2000),   /* YEW STAFF */
-		WeaponInfo(29, 159,   0,   4, 0x2000),   /* STAFF OF MANAR */
-		WeaponInfo(21, 131,   0,   3, 0x2000),   /* SNAKE STAFF */
-		WeaponInfo(33, 136,   0,   7, 0x2000),   /* THE CONDUIT */
-		WeaponInfo(8, 132,   3,   1, 0x2000),   /* DRAGON SPIT */
-		WeaponInfo(18, 131,   9,   4, 0x2000),   /* SCEPTRE OF LYF */
-		WeaponInfo(8, 192,   1,   1, 0x2000),   /* HORN OF FEAR */
-		WeaponInfo(30, 26,   1, 220, 0x207D),   /* SPEEDBOW */
-		WeaponInfo(36, 255, 100,  50, 0x20FF)   /* THE FIRESTAFF */
+		WeaponInfo(1, 1,   3,  19, 0x0A00),    /* THROWING STAR */
+		WeaponInfo(8, 0,   4,   4, 0x2000),    /* STICK */
+		WeaponInfo(26, 129,  12,   4, 0x2000), /* STAFF */
+		WeaponInfo(1, 130,   0,   0, 0x2000),  /* WAND */
+		WeaponInfo(2, 140,   1,  20, 0x2000),  /* TEOWAND */
+		WeaponInfo(35, 128,  18,   6, 0x2000), /* YEW STAFF */
+		WeaponInfo(29, 159,   0,   4, 0x2000), /* STAFF OF MANAR */
+		WeaponInfo(21, 131,   0,   3, 0x2000), /* SNAKE STAFF */
+		WeaponInfo(33, 136,   0,   7, 0x2000), /* THE CONDUIT */
+		WeaponInfo(8, 132,   3,   1, 0x2000),  /* DRAGON SPIT */
+		WeaponInfo(18, 131,   9,   4, 0x2000), /* SCEPTRE OF LYF */
+		WeaponInfo(8, 192,   1,   1, 0x2000),  /* HORN OF FEAR */
+		WeaponInfo(30, 26,   1, 220, 0x207D),  /* SPEEDBOW */
+		WeaponInfo(36, 255, 100,  50, 0x20FF)  /* THE FIRESTAFF */
 	};
 
 	CreatureInfo creatureInfo[k27_CreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo
@@ -735,7 +735,7 @@ void DungeonMan::loadDungeonFile(Common::InSaveFile *file) {
 		uint8 mapCount = _dungeonFileHeader._mapCount;
 		delete[] _dungeonMapData;
 		_dungeonMapData = new byte**[_dungeonColumCount + mapCount];
-		byte **colFirstSquares = (byte**)_dungeonMapData + mapCount;
+		byte **colFirstSquares = (byte **)_dungeonMapData + mapCount;
 		for (uint8 i = 0; i < mapCount; ++i) {
 			_dungeonMapData[i] = colFirstSquares;
 			byte *square = _dungeonRawMapData + _dungeonMaps[i]._rawDunDataOffset;
@@ -897,9 +897,9 @@ T0172010_ClosedFakeWall:
 			ThingType curThingType = curThing.getType();
 			int16 AL0310_i_SideIndex = normalizeModulo4(curThing.getCell() - dir);
 			if (AL0310_i_SideIndex) { /* Invisible on the back wall if 0 */
-				Sensor *curSensor = (Sensor*)getThingData(curThing);
+				Sensor *curSensor = (Sensor *)getThingData(curThing);
 				if (curThingType == k2_TextstringType) {
-					if (((TextString*)curSensor)->isVisible()) {
+					if (((TextString *)curSensor)->isVisible()) {
 						aspectArray[AL0310_i_SideIndex + 1] = _currMapInscriptionWallOrnIndex + 1;
 						_vm->_displayMan->_inscriptionThing = curThing; /* BUG0_76 The same text is drawn on multiple sides of a wall square. The engine stores only a single text to draw on a wall in a global variable. Even if different texts are placed on different sides of the wall, the same text is drawn on each affected side */
 					}
@@ -948,7 +948,7 @@ T0172010_ClosedFakeWall:
 
 		while ((curThing != Thing::_endOfList) && (curThing.getType() <= k3_SensorThingType)) {
 			if (curThing.getType() == k3_SensorThingType) {
-				Sensor *curSensor = (Sensor*)getThingData(curThing);
+				Sensor *curSensor = (Sensor *)getThingData(curThing);
 				aspectArray[k4_FloorOrnOrdAspect] = curSensor->getAttrOrnOrdinal();
 			}
 			curThing = getNextThing(curThing);
@@ -1027,7 +1027,7 @@ uint16 *DungeonMan::getThingData(Thing thing) {
 	return _thingData[thing.getType()] + thing.getIndex() * _thingDataWordCount[thing.getType()];
 }
 
-uint16* DungeonMan::getSquareFirstThingData(int16 mapX, int16 mapY) {
+uint16 *DungeonMan::getSquareFirstThingData(int16 mapX, int16 mapY) {
 	return getThingData(getSquareFirstThing(mapX, mapY));
 }
 
@@ -1263,14 +1263,14 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {
 		break;
 	case k9_ContainerThingType:
 		weight = 50;
-		thing = ((Container*)junk)->getSlot();
+		thing = ((Container *)junk)->getSlot();
 		while (thing != Thing::_endOfList) {
 			weight += getObjectWeight(thing);
 			thing = getNextThing(thing);
 		}
 		break;
 	case k8_PotionThingType:
-		if (((Potion*)junk)->getType() == k20_PotionTypeEmptyFlask)
+		if (((Potion *)junk)->getType() == k20_PotionTypeEmptyFlask)
 			weight = 1;
 		else
 			weight = 3;
@@ -1318,7 +1318,7 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map
 			thingInList = getSquareFirstThing(mapX, mapY);
 		} else {
 			setFlag(*currSquare, k0x0010_ThingListPresent);
-			uint16 * tmp = _currMapColCumulativeSquareFirstThingCount + mapX + 1;
+			uint16 *tmp = _currMapColCumulativeSquareFirstThingCount + mapX + 1;
 			uint16 currColumn = _dungeonColumCount - (_dungeonMapsFirstColumnIndex[_currMapIndex] + mapX) - 1;
 			while (currColumn--) { /* For each column starting from and after the column containing the square where the thing is added */
 				(*tmp++)++; /* Increment the cumulative first thing count */
@@ -1347,8 +1347,8 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map
 	*thingPtr = thingToLink;
 }
 
-WeaponInfo* DungeonMan::getWeaponInfo(Thing thing) {
-	Weapon* weapon = (Weapon*)getThingData(thing);
+WeaponInfo *DungeonMan::getWeaponInfo(Thing thing) {
+	Weapon *weapon = (Weapon *)getThingData(thing);
 	return &_weaponInfos[weapon->getType()];
 }
 
@@ -1375,7 +1375,7 @@ int16 DungeonMan::getProjectileAspect(Thing thing) {
 	return _objectInfos[getObjectInfoIndex(thing)]._objectAspectIndex;
 }
 
-int16 DungeonMan::getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16* mapX, int16* mapY) {
+int16 DungeonMan::getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16 *mapX, int16 *mapY) {
 	if (_partyMapIndex == k255_mapIndexEntrance)
 		return kM1_mapIndexNone;
 
@@ -1406,7 +1406,7 @@ Thing DungeonMan::getSquareFirstObject(int16 mapX, int16 mapY) {
 	return thing;
 }
 
-uint16 DungeonMan::getArmourDefense(ArmourInfo* armourInfo, bool useSharpDefense) {
+uint16 DungeonMan::getArmourDefense(ArmourInfo *armourInfo, bool useSharpDefense) {
 	uint16 defense = armourInfo->_defense;
 	if (useSharpDefense)
 		defense = _vm->getScaledProduct(defense, 3, getFlag(armourInfo->_attributes, k0x0007_ArmourAttributeSharpDefense) + 4);
@@ -1443,14 +1443,14 @@ Thing DungeonMan::getDiscardThing(uint16 thingType) {
 					do {
 						ThingType squareThingType = squareThing.getType();
 						if (squareThingType == k3_SensorThingType) {
-							Thing *squareThingData = (Thing*)getThingData(squareThing);
-							if (((Sensor*)squareThingData)->getType()) /* If sensor is not disabled */
+							Thing *squareThingData = (Thing *)getThingData(squareThing);
+							if (((Sensor *)squareThingData)->getType()) /* If sensor is not disabled */
 								break;
 						} else if (squareThingType == thingType) {
-							Thing *squareThingData = (Thing*)getThingData(squareThing);
+							Thing *squareThingData = (Thing *)getThingData(squareThing);
 							switch (thingType) {
 							case k4_GroupThingType:
-								if (((Group*)squareThingData)->getDoNotDiscard())
+								if (((Group *)squareThingData)->getDoNotDiscard())
 									continue;
 							case k14_ProjectileThingType:
 								setCurrentMap(mapIndex);
@@ -1464,28 +1464,28 @@ Thing DungeonMan::getDiscardThing(uint16 thingType) {
 								}
 								break;
 							case k6_ArmourThingType:
-								if (((Armour*)squareThingData)->getDoNotDiscard())
+								if (((Armour *)squareThingData)->getDoNotDiscard())
 									continue;
 
 								setCurrentMap(mapIndex);
 								_vm->_moveSens->getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
 								break;
 							case k5_WeaponThingType:
-								if (((Weapon*)squareThingData)->getDoNotDiscard())
+								if (((Weapon *)squareThingData)->getDoNotDiscard())
 									continue;
 
 								setCurrentMap(mapIndex);
 								_vm->_moveSens->getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
 								break;
 							case k10_JunkThingType:
-								if (((Junk*)squareThingData)->getDoNotDiscard())
+								if (((Junk *)squareThingData)->getDoNotDiscard())
 									continue;
 
 								setCurrentMap(mapIndex);
 								_vm->_moveSens->getMoveResult(squareThing, currMapX, currMapY, kM1_MapXNotOnASquare, 0);
 								break;
 							case k8_PotionThingType:
-								if (((Potion*)squareThingData)->getDoNotDiscard())
+								if (((Potion *)squareThingData)->getDoNotDiscard())
 									continue;
 
 								setCurrentMap(mapIndex);
@@ -1520,14 +1520,14 @@ uint16 DungeonMan::getCreatureAttributes(Thing thing) {
 	return _creatureInfos[currGroup->_type]._attributes;
 }
 
-void DungeonMan::setGroupCells(Group* group, uint16 cells, uint16 mapIndex) {
+void DungeonMan::setGroupCells(Group *group, uint16 cells, uint16 mapIndex) {
 	if (mapIndex == _partyMapIndex)
 		_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()]._cells = cells;
 	else
 		group->_cells = cells;
 }
 
-void DungeonMan::setGroupDirections(Group* group, int16 dir, uint16 mapIndex) {
+void DungeonMan::setGroupDirections(Group *group, int16 dir, uint16 mapIndex) {
 	if (mapIndex == _partyMapIndex)
 		_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()]._directions = (Direction)dir;
 	else
@@ -1535,7 +1535,7 @@ void DungeonMan::setGroupDirections(Group* group, int16 dir, uint16 mapIndex) {
 }
 
 bool DungeonMan::isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) {
-	int16 creatureType = ((Group*)getThingData(thing))->_type;
+	int16 creatureType = ((Group *)getThingData(thing))->_type;
 	Map *map = &_dungeonMaps[mapIndex];
 	byte *allowedCreatureType = _dungeonMapData[mapIndex][map->_width] + map->_height + 1;
 	for (int16 L0234_i_Counter = map->_creatureTypeCount; L0234_i_Counter > 0; L0234_i_Counter--) {
@@ -1555,10 +1555,10 @@ void DungeonMan::unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int
 
 	Thing *thingPtr = nullptr;
 	if (mapX >= 0) {
-		thingPtr = (Thing*)getThingData(thingToUnlink);
+		thingPtr = (Thing *)getThingData(thingToUnlink);
 		uint16 firstThingIndex = getSquareFirstThingIndex(mapX, mapY);
 		Thing *currThing = &_squareFirstThings[firstThingIndex]; /* BUG0_01 Coding error without consequence. The engine does not check that there are things at the specified square coordinates. f160_getSquareFirstThingIndex would return -1 for an empty square. No consequence as the function is never called with the coordinates of an empty square (except in the case of BUG0_59) */
-		if ((*thingPtr == Thing::_endOfList) && (((Thing*)currThing)->getTypeAndIndex() == thingToUnlink.toUint16())) { /* If the thing to unlink is the last thing on the square */
+		if ((*thingPtr == Thing::_endOfList) && (((Thing *)currThing)->getTypeAndIndex() == thingToUnlink.toUint16())) { /* If the thing to unlink is the last thing on the square */
 			clearFlag(_currMapData[mapX][mapY], k0x0010_ThingListPresent);
 			uint16 squareFirstThingIdx = _dungeonFileHeader._squareFirstThingCount - 1;
 			for (uint16 i = 0; i < squareFirstThingIdx - firstThingIndex; ++i)
@@ -1573,7 +1573,7 @@ void DungeonMan::unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int
 			*thingPtr = Thing::_endOfList;
 			return;
 		}
-		if (((Thing*)currThing)->getTypeAndIndex() == thingToUnlink.toUint16()) {
+		if (((Thing *)currThing)->getTypeAndIndex() == thingToUnlink.toUint16()) {
 			*currThing = *thingPtr;
 			*thingPtr = Thing::_endOfList;
 			return;
@@ -1589,9 +1589,9 @@ void DungeonMan::unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int
 		}
 		currThing = getNextThing(thingInList = currThing);
 	}
-	thingPtr = (Thing*)getThingData(thingInList);
+	thingPtr = (Thing *)getThingData(thingInList);
 	*thingPtr = getNextThing(currThing);
-	thingPtr = (Thing*)getThingData(thingToUnlink);
+	thingPtr = (Thing *)getThingData(thingToUnlink);
 	*thingPtr = Thing::_endOfList;
 }
 
@@ -1655,10 +1655,10 @@ Thing DungeonMan::getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {
 	if (unusedThing == Thing::_none)
 		return Thing::_none;
 
-	Junk *junkPtr = (Junk*)getThingData(unusedThing);
+	Junk *junkPtr = (Junk *)getThingData(unusedThing);
 	junkPtr->setType(junkType); /* Also works for WEAPON in cases other than Boulder */
-	if ((iconIndex == k4_IconIndiceWeaponTorchUnlit) && ((Weapon*)junkPtr)->isLit()) /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */
-		((Weapon*)junkPtr)->setChargeCount(15);
+	if ((iconIndex == k4_IconIndiceWeaponTorchUnlit) && ((Weapon *)junkPtr)->isLit()) /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */
+		((Weapon *)junkPtr)->setChargeCount(15);
 
 	return unusedThing;
 }
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 5d9c04b..2c6ee2b 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -441,7 +441,7 @@ void EventManager::setMousePointerToNormal(int16 mousePointer) {
 	buildpointerScreenArea(_mousePos.x, _mousePos.y);
 }
 
-void EventManager::setPointerToObject(byte* bitmap) {
+void EventManager::setPointerToObject(byte *bitmap) {
 	static byte palChangesMousepointerOjbectIconShadow[16] = {120, 120, 120, 120, 120, 120, 120, 120,
 		120, 120, 120, 120, 0, 120, 120, 120}; // @ K0027_auc_PaletteChanges_MousePointerObjectIconShadow
 	static byte palChangesMousePointerIcon[16] = {120, 10, 20, 30, 40, 50, 60, 70, 80, 90,
@@ -1079,7 +1079,7 @@ bool EventManager::isLeaderHandObjThrown(int16 posX, int16 posY) {
 	return objectThrownFl;
 }
 
-void EventManager::setMousePointerFromSpriteData(byte* mouseSprite) {
+void EventManager::setMousePointerFromSpriteData(byte *mouseSprite) {
 	byte bitmap[16 * 18];
 	memset(bitmap, 0, sizeof(bitmap));
 	for (int16 imgPart = 1; imgPart < 3; ++imgPart) {
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 649bc39..34984f1 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -224,15 +224,15 @@ class EventManager {
 	void commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty
 	void commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty
 	bool isLeaderHandObjThrown(int16 posX, int16 posY); // @ F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown
-	void setMousePointerFromSpriteData(byte* mouseSprite);
+	void setMousePointerFromSpriteData(byte *mouseSprite);
 
 	Box _highlightScreenBox; // @ G0336_i_HighlightBoxX1
 public:
 	explicit EventManager(DMEngine *vm);
 	~EventManager();
 
-	MouseInput* _primaryMouseInput;// @ G0441_ps_PrimaryMouseInput
-	MouseInput* _secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput
+	MouseInput *_primaryMouseInput;// @ G0441_ps_PrimaryMouseInput
+	MouseInput *_secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput
 	bool _mousePointerBitmapUpdated; // @ G0598_B_MousePointerBitmapUpdated
 	bool _refreshMousePointerInMainLoop; // @ G0326_B_RefreshMousePointerInMainLoop
 	bool _highlightBoxEnabled; // @ G0341_B_HighlightBoxEnabled
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 319ac90..1d1f8c4 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -727,8 +727,8 @@ public:
 
 	void blitToViewport(byte *bitmap, Box &box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
 	void blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
-	void blitToScreen(byte *bitmap, int16* box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
-	void blitToScreen(byte* bitmap, Box* box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
+	void blitToScreen(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
+	void blitToScreen(byte *bitmap, Box *box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
 
 
 	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which
@@ -752,7 +752,7 @@ public:
 	void fillScreen(Color color);
 	/* Expects inclusive boundaries in box */
 	void fillScreenBox(Box &box, Color color); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox
-/* Expects inclusive boundaries in box */
+	/* Expects inclusive boundaries in box */
 	void fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 byteWidth, int16 height); // @ F0135_VIDEO_FillBox
 	void drawDungeon(Direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
 	void drawFloorAndCeiling(); // @ F0098_DUNGEONVIEW_DrawFloorAndCeiling
@@ -821,8 +821,8 @@ public:
 	void releaseBlock(uint16 index); // @ F0480_CACHE_ReleaseBlock
 	uint16 getDarkenedColor(uint16 RGBcolor);
 	void startEndFadeToPalette(uint16 *P0849_pui_Palette); // @ F0436_STARTEND_FadeToPalette
-	void buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom); // @ F0508_AMIGA_BuildPaletteChangeCopperList
-	void shadeScreenBox(Box* box, Color color) { warning("STUB METHOD: shadeScreenBox"); } // @ F0136_VIDEO_ShadeScreenBox
+	void buildPaletteChangeCopperList(uint16 *middleScreen, uint16 *topAndBottom); // @ F0508_AMIGA_BuildPaletteChangeCopperList
+	void shadeScreenBox(Box *box, Color color) { warning("STUB METHOD: shadeScreenBox"); } // @ F0136_VIDEO_ShadeScreenBox
 
 private:
 	void initConstants();
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 09581f7..fe80a10 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -280,7 +280,7 @@ void GroupMan::dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int
 			continue;
 
 		Weapon *currWeapon = (Weapon *)_vm->_dungeonMan->getThingData(nextUnusedThing);
-/* The same pointer type is used no matter the actual type k5_WeaponThingType, k6_ArmourThingType or k10_JunkThingType */
+		/* The same pointer type is used no matter the actual type k5_WeaponThingType, k6_ArmourThingType or k10_JunkThingType */
 		currWeapon->setType(currFixedPossession);
 		currWeapon->setCursed(cursedPossessions);
 		nextUnusedThing = thingWithNewCell(nextUnusedThing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell);
@@ -1789,7 +1789,7 @@ int16 GroupMan::getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16
 	}
 }
 
-int16 GroupMan::getMeleeActionDamage(Champion* champ, int16 champIndex, Group* group, int16 creatureIndex, int16 mapX, int16 mapY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex) {
+int16 GroupMan::getMeleeActionDamage(Champion *champ, int16 champIndex, Group *group, int16 creatureIndex, int16 mapX, int16 mapY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex) {
 	int16 L0565_i_Damage = 0;
 	int16 L0566_i_Damage = 0;
 	int16 L0568_i_Defense;
@@ -1996,7 +1996,7 @@ void GroupMan::fuseAction(uint16 mapX, uint16 mapY) {
 	}
 }
 
-void GroupMan::saveActiveGroupPart(Common::OutSaveFile* file) {
+void GroupMan::saveActiveGroupPart(Common::OutSaveFile *file) {
 	for (uint16 i = 0; i < _maxActiveGroupCount; ++i) {
 		ActiveGroup *group = &_activeGroups[i];
 		file->writeUint16BE(group->_groupThingIndex);
@@ -2015,7 +2015,7 @@ void GroupMan::saveActiveGroupPart(Common::OutSaveFile* file) {
 	}
 }
 
-void GroupMan::loadActiveGroupPart(Common::InSaveFile* file) {
+void GroupMan::loadActiveGroupPart(Common::InSaveFile *file) {
 	for (uint16 i = 0; i < _maxActiveGroupCount; ++i) {
 		ActiveGroup *group = &_activeGroups[i];
 		group->_groupThingIndex = file->readUint16BE();
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 38c3a0d..53d80c6 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -223,7 +223,7 @@ public:
 	void stopAttacking(ActiveGroup *group, int16 mapX, int16 mapY);// @ F0182_GROUP_StopAttacking
 	bool isArchenemyDoubleMovementPossible(CreatureInfo *info, int16 mapX, int16 mapY, uint16 dir); // @ F0204_GROUP_IsArchenemyDoubleMovementPossible
 	bool isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 creatureIndex); // @ F0207_GROUP_IsCreatureAttacking
-	void setOrderedCellsToAttack(signed char * orderedCellsToAttack, int16 targetMapX,
+	void setOrderedCellsToAttack(signed char *orderedCellsToAttack, int16 targetMapX,
 	                                  int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource); // @ F0229_GROUP_SetOrderedCellsToAttack
 	void stealFromChampion(Group *group, uint16 championIndex); // @ F0193_GROUP_StealFromChampion
 	int16 getChampionDamage(Group *group, uint16 champIndex); // @ F0230_GROUP_GetChampionDamage
@@ -244,7 +244,7 @@ public:
 	bool isFluxcageOnSquare(int16 mapX, int16 mapY); // @ F0221_GROUP_IsFluxcageOnSquare
 	void fuseAction(uint16 mapX, uint16 mapY); // @ F0225_GROUP_FuseAction
 	void saveActiveGroupPart(Common::OutSaveFile *file);
-	void loadActiveGroupPart(Common::InSaveFile* file);
+	void loadActiveGroupPart(Common::InSaveFile *file);
 };
 
 }


Commit: d0bae5b805797fa44dc6a68f925fdad718d36284
    https://github.com/scummvm/scummvm/commit/d0bae5b805797fa44dc6a68f925fdad718d36284
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-09-03T15:52:59+02:00

Commit Message:
DM: Replace _vm->_system with g_system

Changed paths:
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/text.cpp



diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index a0adf5e..9d9e44a 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -815,9 +815,9 @@ void DMEngine::openEntranceDoors() {
 
 		_displayMan->blitToScreen(_savedScreenForOpenEntranceDoors, &screenBox, 160, kM1_ColorNoTransparency, 200);
 		_displayMan->blitToBitmap(leftDoorBitmap, _displayMan->_bitmapScreen, leftDoorBox, leftDoorBlitFrom, 0, 64, k160_byteWidthScreen,
-									   kM1_ColorNoTransparency, 161, k200_heightScreen);
+								  kM1_ColorNoTransparency, 161, k200_heightScreen);
 		_displayMan->blitToBitmap(rightDoorBitmap, _displayMan->_bitmapScreen, rightDoorBox, 0, 0, 64, k160_byteWidthScreen,
-									   kM1_ColorNoTransparency, 161, k200_heightScreen);
+								  kM1_ColorNoTransparency, 161, k200_heightScreen);
 		_eventMan->discardAllInput();
 		_displayMan->updateScreen();
 
@@ -938,7 +938,7 @@ void DMEngine::fuseSequence() {
 	int16 fluxCageMapX = _dungeonMan->_partyMapX;
 	int16 fluxcageMapY = _dungeonMan->_partyMapY;
 
-	for(;;) {
+	for (;;) {
 		Thing curThing = _dungeonMan->getSquareFirstObject(fluxCageMapX, fluxcageMapY);
 		while (curThing != Thing::_endOfList) {
 			if (curThing.getType() == k15_ExplosionThingType) {
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 5d9c04b..d478d4c 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -597,12 +597,12 @@ bool EventManager::isMouseButtonDown(MouseButton button) {
 }
 
 void EventManager::setMousePos(Common::Point pos) {
-	_vm->_system->warpMouse(pos.x, pos.y);
+	g_system->warpMouse(pos.x, pos.y);
 }
 
 Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Event *grabMouseClick) {
 	Common::Event event;
-	while (_vm->_system->getEventManager()->pollEvent(event)) {
+	while (g_system->getEventManager()->pollEvent(event)) {
 		switch (event.type) {
 		case Common::EVENT_KEYDOWN: {
 			if (event.synthetic)
@@ -1420,7 +1420,7 @@ void EventManager::drawSleepScreen() {
 
 void EventManager::discardAllInput() {
 	Common::Event event;
-	while (_vm->_system->getEventManager()->pollEvent(event) && !_vm->_engineShouldQuit) {
+	while (g_system->getEventManager()->pollEvent(event) && !_vm->_engineShouldQuit) {
 		if (event.type == Common::EVENT_QUIT)
 			_vm->_engineShouldQuit = true;
 	}
@@ -1626,7 +1626,7 @@ void EventManager::waitForMouseOrKeyActivity() {
 	discardAllInput();
 	Common::Event event;
 	while (true) {
-		if (_vm->_system->getEventManager()->pollEvent(event)) {
+		if (g_system->getEventManager()->pollEvent(event)) {
 			switch (event.type) {
 			case Common::EVENT_QUIT:
 				_vm->_engineShouldQuit = true;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 0b5fa47..00bf044 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -919,9 +919,9 @@ void DisplayMan::updateScreen() {
 	// apply copper
 	for (uint32 i = 320 * 30; i < 320 * 170; ++i)
 		_bitmapScreen[i] += 16;
-	_vm->_system->copyRectToScreen(_bitmapScreen, _screenWidth, 0, 0, _screenWidth, _screenHeight);
+	g_system->copyRectToScreen(_bitmapScreen, _screenWidth, 0, 0, _screenWidth, _screenHeight);
 	_vm->_console->onFrame();
-	_vm->_system->updateScreen();
+	g_system->updateScreen();
 	for (uint32 i = 320 * 30; i < 320 * 170; ++i)
 		_bitmapScreen[i] -= 16;
 }
@@ -3861,7 +3861,7 @@ void DisplayMan::buildPaletteChangeCopperList(uint16* middleScreen, uint16* topA
 		colorPalette[i * 3 + 1] = (middleScreen[i - 16] >> 4) * (256 / 16);
 		colorPalette[i * 3 + 2] = middleScreen[i - 16] * (256 / 16);
 	}
-	_vm->_system->getPaletteManager()->setPalette(colorPalette, 0, 32);
+	g_system->getPaletteManager()->setPalette(colorPalette, 0, 32);
 }
 
 }
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 16955ba..52e83d1 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -254,10 +254,10 @@ void TextMan::clearAllRows() {
 void TextMan::updateMessageArea() {
 	if (_isScrolling) {
 		if (_startedScrollingAt == -1) {
-			_startedScrollingAt = _vm->_system->getMillis();
+			_startedScrollingAt = g_system->getMillis();
 			memcpy(_messageAreaCopy, _vm->_displayMan->_bitmapScreen + (200 - 7 * 4) * 320, 320 * 7 * 4);
 		}
-		int linesToCopy = (_vm->_system->getMillis() - _startedScrollingAt) / 50;
+		int linesToCopy = (g_system->getMillis() - _startedScrollingAt) / 50;
 		if (linesToCopy >= 7) {
 			linesToCopy = 7;
 			_startedScrollingAt = -1;


Commit: 3191f2605bbb28704a88ecbf9faa72b62bcb12e7
    https://github.com/scummvm/scummvm/commit/3191f2605bbb28704a88ecbf9faa72b62bcb12e7
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-09-03T16:01:31+02:00

Commit Message:
Merge branch 'dm' of https://github.com/WinterGrascph/scummvm into dm

Changed paths:
    engines/dm/dm.h
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/eventman.h
    engines/dm/gfx.h
    engines/dm/group.cpp
    engines/dm/group.h
    engines/dm/inventory.cpp
    engines/dm/menus.cpp





Commit: 8d41bf9ad73f40ddc5b0578160118dc4d05696f8
    https://github.com/scummvm/scummvm/commit/8d41bf9ad73f40ddc5b0578160118dc4d05696f8
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-03T21:42:58+02:00

Commit Message:
DM: Some more fixes concerning pointer formatting

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/lzw.h
    engines/dm/menus.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 0b5fa47..9349587 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -2628,7 +2628,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
 	unsigned char inscriptionString[70];
 	bool isInscription = (wallOrnamentIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex);
 	if (isInscription)
-		_vm->_dungeonMan->decodeText((char*)inscriptionString, _inscriptionThing, k0_TextTypeInscription);
+		_vm->_dungeonMan->decodeText((char *)inscriptionString, _inscriptionThing, k0_TextTypeInscription);
 
 	int16 blitPosX;
 	byte *ornBlitBitmap;
@@ -3234,14 +3234,14 @@ T0115015_DrawProjectileAsObject:
 
 		ActiveGroup *activeGroup;
 		if (group == nullptr) { /* If all creature data and info has not already been gathered */
-			group = (Group*)_vm->_dungeonMan->getThingData(groupThing);
+			group = (Group *)_vm->_dungeonMan->getThingData(groupThing);
 			activeGroup = &_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()];
 			CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type];
 			creatureAspectStruct = &_creatureAspects219[creatureInfo->_creatureAspectIndex];
 			creatureSize = getFlag(creatureInfo->_attributes, k0x0003_MaskCreatureInfo_size);
 			creatureGraphicInfoGreen = creatureInfo->_graphicInfo;
 		}
-		objectAspect = (ObjectAspect*)creatureAspectStruct;
+		objectAspect = (ObjectAspect *)creatureAspectStruct;
 		AL_0_creatureIndexRed = _vm->_groupMan->getCreatureOrdinalInCell(group, cellYellowBear);
 
 		if (AL_0_creatureIndexRed) { /* If there is a creature on the cell being processed */
@@ -3297,12 +3297,12 @@ T0115015_DrawProjectileAsObject:
 			viewSquareIndex--;
 
 T0115077_DrawSecondHalfSquareCreature:
-		coordinateSet = creatureCoordinateSets[((CreatureAspect*)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell];
+		coordinateSet = creatureCoordinateSets[((CreatureAspect *)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell];
 		if (!coordinateSet[1])
 			goto T0115126_CreatureNotVisible;
 		AL_0_creatureGraphicInfoRed = creatureGraphicInfoGreen;
-		AL_4_nativeBitmapIndex = k446_FirstCreatureGraphicIndice + ((CreatureAspect*)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */
-		derivedBitmapIndex = ((CreatureAspect*)objectAspect)->_firstDerivedBitmapIndex;
+		AL_4_nativeBitmapIndex = k446_FirstCreatureGraphicIndice + ((CreatureAspect *)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */
+		derivedBitmapIndex = ((CreatureAspect *)objectAspect)->_firstDerivedBitmapIndex;
 		int16 sourceByteWidth;
 		int16 sourceHeight;
 		useCreatureSideBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide) && (creatureDirectionDelta & 0x0001);
@@ -3310,15 +3310,15 @@ T0115077_DrawSecondHalfSquareCreature:
 			useCreatureAttackBitmap = useFlippedHorizontallyCreatureFrontImage = useCreatureBackBitmap = false;
 			AL_4_nativeBitmapIndex++; /* Skip the front image. Side image is right after the front image */
 			derivedBitmapIndex += 2;
-			sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthSide;
-			sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightSide;
+			sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthSide;
+			sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightSide;
 		} else {
 			useCreatureBackBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack) && (creatureDirectionDelta == 0);
 			useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, k0x0080_MaskActiveGroupIsAttacking) && getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack);
 			if (useCreatureAttackBitmap) {
 				useFlippedHorizontallyCreatureFrontImage = false;
-				sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthAttack;
-				sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightAttack;
+				sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthAttack;
+				sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightAttack;
 				AL_4_nativeBitmapIndex++; /* Skip the front image */
 				derivedBitmapIndex += 2;
 				if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) {
@@ -3331,8 +3331,8 @@ T0115077_DrawSecondHalfSquareCreature:
 					derivedBitmapIndex += 2;
 				}
 			} else {
-				sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthFront;
-				sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightFront;
+				sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthFront;
+				sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightFront;
 				if (useCreatureBackBitmap) {
 					useFlippedHorizontallyCreatureFrontImage = false;
 					if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) {
@@ -3363,7 +3363,7 @@ T0115077_DrawSecondHalfSquareCreature:
 		if (viewSquareIndex >= k6_ViewSquare_D1C) { /* Creature is on D1 */
 			creaturePaddingPixelCount = 0;
 			AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
-			transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour();
+			transparentColor = ((CreatureAspect *)objectAspect)->getTranspColour();
 			if (useCreatureSideBitmap) {
 				bitmapRedBanana = getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
 				if (creatureDirectionDelta == 1) {
@@ -3405,7 +3405,7 @@ T0115077_DrawSecondHalfSquareCreature:
 
 			byteWidth = getScaledDimension(sourceByteWidth, scale);
 			heightRedEagle = getScaledDimension(sourceHeight, scale);
-			transparentColor = paletteChanges[((CreatureAspect*)objectAspect)->getTranspColour()] / 10;
+			transparentColor = paletteChanges[((CreatureAspect *)objectAspect)->getTranspColour()] / 10;
 
 			bool derivedBitmapInCache = isDerivedBitmapInCache(derivedBitmapIndex);
 			if (derivedBitmapInCache)
@@ -3484,25 +3484,25 @@ T0115129_DrawProjectiles:
 		thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */
 		do {
 			if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) {
-				Projectile *projectile = (Projectile*)_vm->_dungeonMan->getThingData(thingParam);
+				Projectile *projectile = (Projectile *)_vm->_dungeonMan->getThingData(thingParam);
 				if ((AL_4_projectileAspect = _vm->_dungeonMan->getProjectileAspect(projectile->_slot)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
-					objectAspect = (ObjectAspect*)&_projectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)];
-					AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
-					projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
+					objectAspect = (ObjectAspect *)&_projectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)];
+					AL_4_nativeBitmapIndex = ((ProjectileAspect *)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
+					projectileAspectType = getFlag(((ProjectileAspect *)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
 
-					bool doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask);
+					bool doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect *)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask);
 					if ((doNotScaleWithKineticEnergy || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == k9_ViewSquare_D0C)) {
 						scale = 0; /* Use native bitmap without resizing */
-						byteWidth = ((ProjectileAspect*)objectAspect)->_byteWidth;
-						heightRedEagle = ((ProjectileAspect*)objectAspect)->_height;
+						byteWidth = ((ProjectileAspect *)objectAspect)->_byteWidth;
+						heightRedEagle = ((ProjectileAspect *)objectAspect)->_height;
 					} else {
 						AL_8_projectileScaleIndex = ((viewSquareIndex / 3) << 1) + (AL_2_viewCell >> 1);
 						scale = _projectileScales[AL_8_projectileScaleIndex];
 						if (!doNotScaleWithKineticEnergy) {
 							scale = (scale * MAX(96, projectile->_kineticEnergy + 1)) >> 8;
 						}
-						byteWidth = getScaledDimension(((ProjectileAspect*)objectAspect)->_byteWidth, scale);
-						heightRedEagle = getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale);
+						byteWidth = getScaledDimension(((ProjectileAspect *)objectAspect)->_byteWidth, scale);
+						heightRedEagle = getScaledDimension(((ProjectileAspect *)objectAspect)->_height, scale);
 					}
 					bool projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == k0_ProjectileAspectHasBackGraphicRotation);
 					if (projectileAspectTypeHasBackGraphicAndRotation)
@@ -3533,7 +3533,7 @@ T0115129_DrawProjectiles:
 							projectileBitmapIndexDelta = 1;
 
 						flipVertical = projectileAspectTypeHasBackGraphicAndRotation && (AL_2_viewCell < k2_ViewCellBackRight);
-						flipHorizontal = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0010_ProjectileSideMask) && !((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight))));
+						flipHorizontal = getFlag(((ProjectileAspect *)objectAspect)->_graphicInfo, k0x0010_ProjectileSideMask) && !((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight))));
 					}
 
 					AL_4_nativeBitmapIndex += projectileBitmapIndexDelta;
@@ -3544,7 +3544,7 @@ T0115129_DrawProjectiles:
 						if (flipHorizontal)
 							paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1;
 
-						if (doNotScaleWithKineticEnergy && isDerivedBitmapInCache(derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstDerivedBitmapRelativeIndex + (projectileBitmapIndexDelta * 6) + AL_8_projectileScaleIndex)) {
+						if (doNotScaleWithKineticEnergy && isDerivedBitmapInCache(derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect *)objectAspect)->_firstDerivedBitmapRelativeIndex + (projectileBitmapIndexDelta * 6) + AL_8_projectileScaleIndex)) {
 							bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
 						} else {
 							bitmapGreenAnt = getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
@@ -3553,7 +3553,7 @@ T0115129_DrawProjectiles:
 							else
 								bitmapRedBanana = _tmpBitmap;
 
-							blitToBitmapShrinkWithPalChange(bitmapGreenAnt, bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, _palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
+							blitToBitmapShrinkWithPalChange(bitmapGreenAnt, bitmapRedBanana, ((ProjectileAspect *)objectAspect)->_byteWidth << 1, ((ProjectileAspect *)objectAspect)->_height, byteWidth << 1, heightRedEagle, _palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
 							if (doNotScaleWithKineticEnergy) {
 								addDerivedBitmap(derivedBitmapIndex);
 							}
@@ -3613,7 +3613,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 	do {
 		if (thingParam.getType() == k15_ExplosionThingType) {
 			AL_2_cellPurpleMan = thingParam.getCell();
-			Explosion *explosion = (Explosion*)_vm->_dungeonMan->getThingData(thingParam);
+			Explosion *explosion = (Explosion *)_vm->_dungeonMan->getThingData(thingParam);
 			bool rebirthExplosion = ((uint16)(AL_4_explosionType = explosion->getType()) >= k100_ExplosionType_RebirthStep1);
 			if (rebirthExplosion && ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion) || (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion) || (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */
 				continue;
@@ -3629,13 +3629,13 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
 						AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke;
 					} else {
 						if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) {
-							objectAspect = (ObjectAspect*)&_projectileAspect[_vm->ordinalToIndex(-_vm->_dungeonMan->getProjectileAspect(Thing::_explLightningBolt))];
-							bitmapRedBanana = getNativeBitmapOrGraphic(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
+							objectAspect = (ObjectAspect *)&_projectileAspect[_vm->ordinalToIndex(-_vm->_dungeonMan->getProjectileAspect(Thing::_explLightningBolt))];
+							bitmapRedBanana = getNativeBitmapOrGraphic(((ProjectileAspect *)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
 							explosionCoordinates = rebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
-							byteWidth = getScaledDimension((((ProjectileAspect*)objectAspect)->_byteWidth), explosionCoordinates[2]);
-							heightRedEagle = getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
+							byteWidth = getScaledDimension((((ProjectileAspect *)objectAspect)->_byteWidth), explosionCoordinates[2]);
+							heightRedEagle = getScaledDimension((((ProjectileAspect *)objectAspect)->_height), explosionCoordinates[2]);
 							if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) {
-								blitToBitmapShrinkWithPalChange(bitmapRedBanana, _tmpBitmap, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, _palChangesNoChanges);
+								blitToBitmapShrinkWithPalChange(bitmapRedBanana, _tmpBitmap, ((ProjectileAspect *)objectAspect)->_byteWidth << 1, ((ProjectileAspect *)objectAspect)->_height, byteWidth << 1, heightRedEagle, _palChangesNoChanges);
 								bitmapRedBanana = _tmpBitmap;
 							}
 							goto T0115200_DrawExplosion;
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index fe80a10..160c97d 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1727,7 +1727,7 @@ Thing GroupMan::groupGetGenerated(int16 creatureType, int16 healthMultiplier, ui
 		|| (groupThing == Thing::_none)) {
 		return Thing::_none;
 	}
-	Group *group = (Group*)_vm->_dungeonMan->getThingData(groupThing);
+	Group *group = (Group *)_vm->_dungeonMan->getThingData(groupThing);
 	group->_slot = Thing::_endOfList;
 	group->setDoNotDiscard(false);
 	group->setDir(dir);
@@ -1776,7 +1776,7 @@ int16 GroupMan::getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16
 	if (groupThing == Thing::_endOfList)
 		return 0;
 
-	Group *group = (Group*)_vm->_dungeonMan->getThingData(groupThing);
+	Group *group = (Group *)_vm->_dungeonMan->getThingData(groupThing);
 	signed char orderedCellsToAttack[4];
 	setOrderedCellsToAttack(orderedCellsToAttack, groupX, groupY, partyX, partyY, champCell);
 	uint16 counter = 0;
@@ -1882,7 +1882,7 @@ void GroupMan::fluxCageAction(int16 mapX, int16 mapY) {
 		return;
 
 	_vm->_dungeonMan->linkThingToList(unusedThing, Thing(0), mapX, mapY);
-	(((Explosion*)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[unusedThing.getIndex()]).setType(k50_ExplosionType_Fluxcage);
+	(((Explosion *)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[unusedThing.getIndex()]).setType(k50_ExplosionType_Fluxcage);
 	TimelineEvent newEvent;
 	setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + 100);
 	newEvent._type = k24_TMEventTypeRemoveFluxcage;
@@ -1935,7 +1935,7 @@ bool GroupMan::isFluxcageOnSquare(int16 mapX, int16 mapY) {
 
 	Thing thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
 	while (thing != Thing::_endOfList) {
-		if ((thing.getType() == k15_ExplosionThingType) && (((Explosion*)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[thing.getIndex()].getType() == k50_ExplosionType_Fluxcage))
+		if ((thing.getType() == k15_ExplosionThingType) && (((Explosion *)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[thing.getIndex()].getType() == k50_ExplosionType_Fluxcage))
 			return true;
 
 		thing = _vm->_dungeonMan->getNextThing(thing);
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 9c12835..c28e414 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -273,7 +273,7 @@ void InventoryMan::closeChest() {
 	bool processFirstChestSlot = true;
 	if (_openChest == Thing::_none)
 		return;
-	Container *container = (Container*)dunMan.getThingData(_openChest);
+	Container *container = (Container *)dunMan.getThingData(_openChest);
 	_openChest = Thing::_none;
 	container->getSlot() = Thing::_endOfList;
 	Thing prevThing;
@@ -294,8 +294,8 @@ void InventoryMan::closeChest() {
 	}
 }
 
-void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) {
-	for (char* iter = text; *iter != '\0'; ++iter) {
+void InventoryMan::drawPanelScrollTextLine(int16 yPos, char *text) {
+	for (char *iter = text; *iter != '\0'; ++iter) {
 		if ((*iter >= 'A') && (*iter <= 'Z'))
 			*iter -= 64;
 		else if (*iter >= '{') // this branch is CHANGE5_03_IMPROVEMENT
@@ -304,7 +304,7 @@ void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) {
 	_vm->_textMan->printToViewport(162 - (6 * strlen(text) / 2), yPos, k0_ColorBlack, text, k15_ColorWhite);
 }
 
-void InventoryMan::drawPanelScroll(Scroll* scroll) {
+void InventoryMan::drawPanelScroll(Scroll *scroll) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 
 	char stringFirstLine[300];
@@ -352,7 +352,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) {
 	}
 }
 
-void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool isPressingEye) {
+void InventoryMan::openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye) {
 	DisplayMan &dispMan = *_vm->_displayMan;
 	ObjectMan &objMan = *_vm->_objectMan;
 
@@ -393,7 +393,7 @@ void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yP
 	_vm->_displayMan->blitToViewport(iconBitmap, boxIcon, k8_byteWidth, kM1_ColorNoTransparency, 16);
 }
 
-void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, const char** attribStrings, char* destString, const char* prefixString, const char* suffixString) {
+void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, const char **attribStrings, char *destString, const char *prefixString, const char *suffixString) {
 	uint16 identicalBitCount = 0;
 	int16 attribMask = 1;
 	for (uint16 stringIndex = 0; stringIndex < 16; stringIndex++, attribMask <<= 1) {
@@ -489,7 +489,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 	drawPanelObjectDescriptionString("\f"); // form feed
 	ThingType thingType = thingToDraw.getType();
 	if (thingType == k7_ScrollThingType)
-		drawPanelScroll((Scroll*)rawThingPtr);
+		drawPanelScroll((Scroll *)rawThingPtr);
 	else if (thingType == k9_ContainerThingType)
 		openAndDrawChest(thingToDraw, (Container *)rawThingPtr, pressingEye);
 	else {
@@ -693,7 +693,7 @@ void InventoryMan::setDungeonViewPalette() {
 				Thing slotThing = curChampion->_slots[slotIndex];
 				if ((_vm->_objectMan->getObjectType(slotThing) >= k4_IconIndiceWeaponTorchUnlit) &&
 					(_vm->_objectMan->getObjectType(slotThing) <= k7_IconIndiceWeaponTorchLit)) {
-					Weapon *curWeapon = (Weapon*)_vm->_dungeonMan->getThingData(slotThing);
+					Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->getThingData(slotThing);
 					*curTorchLightPower = curWeapon->getChargeCount();
 				} else {
 					*curTorchLightPower = 0;
@@ -779,9 +779,9 @@ void InventoryMan::decreaseTorchesLightPower() {
 }
 
 void InventoryMan::drawChampionSkillsAndStatistics() {
-	static const char* statisticNamesEN[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"};
-	static const char* statisticNamesDE[7] = {"L", "STAERKE", "FLINKHEIT", "WEISHEIT", "VITALITAET", "ANTI-MAGIE", "ANTI-FEUER"};
-	static const char* statisticNamesFR[7] = {"L", "FORCE", "DEXTERITE", "SAGESSE", "VITALITE", "ANTI-MAGIE", "ANTI-FEU"};
+	static const char *statisticNamesEN[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"};
+	static const char *statisticNamesDE[7] = {"L", "STAERKE", "FLINKHEIT", "WEISHEIT", "VITALITAET", "ANTI-MAGIE", "ANTI-FEUER"};
+	static const char *statisticNamesFR[7] = {"L", "FORCE", "DEXTERITE", "SAGESSE", "VITALITE", "ANTI-MAGIE", "ANTI-FEU"};
 
 	const char **statisticNames;
 
@@ -872,14 +872,15 @@ void InventoryMan::clickOnMouth() {
 		550,    /* Screamer Slice */
 		350,    /* Worm round */
 		990,    /* Drumstick / Shank */
-		1400}; /* Dragon steak */
+		1400    /* Dragon steak */
+	};
 
 	Thing L1078_T_Thing;
 	uint16 L1079_ui_IconIndex;
 	uint16 L1080_ui_ChampionIndex;
 	bool L1081_B_RemoveObjectFromLeaderHand;
-	Junk* L1082_ps_Junk;
-	Champion* L1083_ps_Champion;
+	Junk *L1082_ps_Junk;
+	Champion *L1083_ps_Champion;
 	TimelineEvent L1084_s_Event;
 	uint16 L1085_ui_Multiple;
 #define AL1085_ui_PotionPower         L1085_ui_Multiple
@@ -925,7 +926,7 @@ void InventoryMan::clickOnMouth() {
 	L1089_ui_Weight = _vm->_dungeonMan->getObjectWeight(L1078_T_Thing);
 	L1080_ui_ChampionIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal);
 	L1083_ps_Champion = &_vm->_championMan->_champions[L1080_ui_ChampionIndex];
-	L1082_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L1078_T_Thing);
+	L1082_ps_Junk = (Junk *)_vm->_dungeonMan->getThingData(L1078_T_Thing);
 	if ((L1079_ui_IconIndex >= k8_IconIndiceJunkWater) && (L1079_ui_IconIndex <= k9_IconIndiceJunkWaterSkin)) {
 		if (!(L1082_ps_Junk->getChargeCount())) {
 			return;
@@ -946,15 +947,15 @@ void InventoryMan::clickOnMouth() {
 		_vm->_championMan->getObjectRemovedFromLeaderHand();
 	}
 	if (AL1088_ui_ThingType == k8_PotionThingType) {
-		AL1085_ui_PotionPower = ((Potion*)L1082_ps_Junk)->getPower();
+		AL1085_ui_PotionPower = ((Potion *)L1082_ps_Junk)->getPower();
 		L1086_ui_Counter = ((511 - AL1085_ui_PotionPower) / (32 + (AL1085_ui_PotionPower + 1) / 8)) >> 1;
 		AL1085_ui_AdjustedPotionPower = (AL1085_ui_PotionPower / 25) + 8; /* Value between 8 and 18 */
-		switch (((Potion*)L1082_ps_Junk)->getType()) {
+		switch (((Potion *)L1082_ps_Junk)->getType()) {
 		case k6_PotionTypeRos:
 			adjustStatisticCurrentValue(L1083_ps_Champion, k2_ChampionStatDexterity, AL1085_ui_AdjustedPotionPower);
 			break;
 		case k7_PotionTypeKu:
-			adjustStatisticCurrentValue(L1083_ps_Champion, k1_ChampionStatStrength, (((Potion*)L1082_ps_Junk)->getPower() / 35) + 5); /* Value between 5 and 12 */
+			adjustStatisticCurrentValue(L1083_ps_Champion, k1_ChampionStatStrength, (((Potion *)L1082_ps_Junk)->getPower() / 35) + 5); /* Value between 5 and 12 */
 			break;
 		case k8_PotionTypeDane:
 			adjustStatisticCurrentValue(L1083_ps_Champion, k3_ChampionStatWisdom, AL1085_ui_AdjustedPotionPower);
@@ -989,7 +990,7 @@ void InventoryMan::clickOnMouth() {
 			L1083_ps_Champion->_currMana = AL1088_ui_Mana;
 			break;
 		case k14_PotionTypeVi:
-			AL1088_ui_HealWoundIterationCount = MAX(1, (((Potion*)L1082_ps_Junk)->getPower() / 42));
+			AL1088_ui_HealWoundIterationCount = MAX(1, (((Potion *)L1082_ps_Junk)->getPower() / 42));
 			L1083_ps_Champion->_currHealth += L1083_ps_Champion->_maxHealth / L1086_ui_Counter;
 			L1087_i_Wounds = L1083_ps_Champion->_wounds;
 			if (L1087_i_Wounds) { /* If the champion is wounded */
@@ -1009,7 +1010,7 @@ void InventoryMan::clickOnMouth() {
 		default:
 			break;
 		}
-		((Potion*)L1082_ps_Junk)->setType(k20_PotionTypeEmptyFlask);
+		((Potion *)L1082_ps_Junk)->setType(k20_PotionTypeEmptyFlask);
 	} else if ((L1079_ui_IconIndex >= k168_IconIndiceJunkApple) && (L1079_ui_IconIndex < k176_IconIndiceJunkIronKey)) {
 		L1083_ps_Champion->_food = MIN(L1083_ps_Champion->_food + G0242_ai_Graphic559_FoodAmounts[L1079_ui_IconIndex - k168_IconIndiceJunkApple], 2048);
 	}
@@ -1042,7 +1043,7 @@ void InventoryMan::clickOnMouth() {
 	_vm->_eventMan->hideMouse();
 }
 
-void InventoryMan::adjustStatisticCurrentValue(Champion* champ, uint16 statIndex, int16 valueDelta) {
+void InventoryMan::adjustStatisticCurrentValue(Champion *champ, uint16 statIndex, int16 valueDelta) {
 	int16 L1077_i_Multiple;
 #define AL1077_i_CurrentValue L1077_i_Multiple
 #define AL1077_i_Delta        L1077_i_Multiple
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index a9ee6f8..ef3ed34 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -257,7 +257,7 @@ Common::String DMEngine::getSavefileName(uint16 slot) {
 #define SAVEGAME_ID       MKTAG('D', 'M', 'D', 'M')
 #define SAVEGAME_VERSION  1
 
-void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::String& saveName) {
+void DMEngine::writeSaveGameHeader(Common::OutSaveFile *out, const Common::String& saveName) {
 	out->writeUint32BE(SAVEGAME_ID);
 
 	// Write version
@@ -405,7 +405,7 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 	return true;
 }
 
-bool readSaveGameHeader(Common::InSaveFile* in, SaveGameHeader* header) {
+bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader *header) {
 	uint32 id = in->readUint32BE();
 
 	// Check if it's a valid ScummVM savegame
diff --git a/engines/dm/lzw.h b/engines/dm/lzw.h
index 3603423..313b74b 100644
--- a/engines/dm/lzw.h
+++ b/engines/dm/lzw.h
@@ -51,7 +51,7 @@ class LZWdecompressor {
 	int16 _inputBufferBitCount;
 	int16 _charToRepeat;
 
-	byte* _tempBuffer;
+	byte *_tempBuffer;
 	int16 *_prefixCode;
 	byte *_appendCharacter;
 
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 687e619..f0f7930 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -87,7 +87,7 @@ void MenuMan::initConstants() {
 		16, /* SPIT */
 		14, /* BRANDISH */
 		10, /* THROW */
-		3 /* FUSE */
+		3   /* FUSE */
 	};
 
 	_boxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
@@ -282,7 +282,7 @@ void MenuMan::drawActionArea() {
 	_refreshActionArea = false;
 }
 
-const char* MenuMan::getActionName(ChampionAction actionIndex) {
+const char *MenuMan::getActionName(ChampionAction actionIndex) {
 	const char *g490_ChampionActionNames[44] = { // @ G0490_ac_Graphic560_ActionNames
 		"N", "BLOCK", "CHOP", "X", "BLOW HORN", "FLIP", "PUNCH",
 		"KICK", "WAR CRY", "STAB", "CLIMB DOWN", "FREEZE LIFE",
@@ -399,7 +399,7 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
 	static Box boxSpellAreaLine2(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 
 	static Box boxSpellAreaLine3(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 
 
-	Champion* L1213_ps_Champion;
+	Champion *L1213_ps_Champion;
 
 	if ((champIndex == _vm->_championMan->_magicCasterChampionIndex) || ((champIndex != kM1_ChampionNone) && !_vm->_championMan->_champions[champIndex]._currHealth)) {
 		return;
@@ -458,7 +458,7 @@ void MenuMan::drawEnabledMenus() {
 
 int16 MenuMan::getClickOnSpellCastResult() {
 	int16 L1259_i_SpellCastResult;
-	Champion* L1260_ps_Champion;
+	Champion *L1260_ps_Champion;
 
 
 	L1260_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
@@ -486,14 +486,14 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 #define AL1269_ui_RequiredSkillLevel L1269_ui_Multiple
 #define AL1269_ui_EmptyFlaskWeight   L1269_ui_Multiple
 #define AL1269_ui_Ticks              L1269_ui_Multiple
-	Champion* L1270_ps_Champion;
-	Spell* L1271_ps_Spell;
+	Champion *L1270_ps_Champion;
+	Spell *L1271_ps_Spell;
 	Thing L1272_T_Object;
 	uint16 L1273_ui_Experience;
 	int16 L1274_i_MissingSkillLevelCount;
-	Potion* L1275_ps_Potion;
+	Potion *L1275_ps_Potion;
 	TimelineEvent L1276_s_Event;
-	Junk* L1277_ps_Junk;
+	Junk *L1277_ps_Junk;
 
 
 	if (champIndex >= _vm->_championMan->_partyChampionCount) {
@@ -607,7 +607,7 @@ T0412033:
 		case k7_spellType_otherZokathra:
 			if ((L1272_T_Object = _vm->_dungeonMan->getUnusedThing(k10_JunkThingType)) == Thing::_none)
 				break;
-			L1277_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L1272_T_Object);
+			L1277_ps_Junk = (Junk *)_vm->_dungeonMan->getThingData(L1272_T_Object);
 			L1277_ps_Junk->setType(k51_JunkTypeZokathra);
 			ChampionSlot AL1267_ui_SlotIndex;
 			if (L1270_ps_Champion->_slots[k0_ChampionSlotReadyHand] == Thing::_none) {
@@ -635,7 +635,7 @@ T0412033:
 	return k1_spellCastSuccess;
 }
 
-Spell* MenuMan::getSpellFromSymbols(byte* symbols) {
+Spell *MenuMan::getSpellFromSymbols(byte *symbols) {
 	static Spell G0487_as_Graphic560_Spells[25] = {
 		/* { Symbols, BaseRequiredSkillLevel, SkillIndex, Attributes } */
 		Spell(0x00666F00, 2, 15, 0x7843),
@@ -689,7 +689,7 @@ Spell* MenuMan::getSpellFromSymbols(byte* symbols) {
 	return NULL;
 }
 
-void MenuMan::menusPrintSpellFailureMessage(Champion* champ, uint16 failureType, uint16 skillIndex) {
+void MenuMan::menusPrintSpellFailureMessage(Champion *champ, uint16 failureType, uint16 skillIndex) {
 	const char *L1264_pc_Message = nullptr;
 
 	if (skillIndex > k3_ChampionSkillWizard)
@@ -734,14 +734,14 @@ void MenuMan::menusPrintSpellFailureMessage(Champion* champ, uint16 failureType,
 	_vm->_textMan->printMessage(k4_ColorCyan, L1264_pc_Message);
 }
 
-Potion* MenuMan::getEmptyFlaskInHand(Champion* champ, Thing* potionThing) {
+Potion *MenuMan::getEmptyFlaskInHand(Champion *champ, Thing *potionThing) {
 	Thing L1265_T_Thing;
 	int16 L1266_i_SlotIndex;
 
 	for (L1266_i_SlotIndex = k2_ChampionSlotHead; --L1266_i_SlotIndex >= k0_ChampionSlotReadyHand; ) {
 		if (((L1265_T_Thing = champ->_slots[L1266_i_SlotIndex]) != Thing::_none) && (_vm->_objectMan->getIconIndex(L1265_T_Thing) == k195_IconIndicePotionEmptyFlask)) {
 			*potionThing = L1265_T_Thing;
-			return (Potion*)_vm->_dungeonMan->getThingData(L1265_T_Thing);
+			return (Potion *)_vm->_dungeonMan->getThingData(L1265_T_Thing);
 		}
 	}
 	return nullptr;
@@ -758,7 +758,7 @@ void MenuMan::createEvent70_light(int16 lightPower, int16 ticks) {
 	_vm->_inventoryMan->setDungeonViewPalette();
 }
 
-bool MenuMan::isPartySpellOrFireShieldSuccessful(Champion* champ, bool spellShield, uint16 ticks, bool useMana) {
+bool MenuMan::isPartySpellOrFireShieldSuccessful(Champion *champ, bool spellShield, uint16 ticks, bool useMana) {
 	bool L1239_B_IsPartySpellOrFireShieldSuccessful;
 	TimelineEvent L1240_s_Event;
 
@@ -812,7 +812,7 @@ void MenuMan::drawAvailableSymbols(uint16 symbolStep) {
 	}
 }
 
-void MenuMan::drawChampionSymbols(Champion* champ) {
+void MenuMan::drawChampionSymbols(Champion *champ) {
 	uint16 L1218_ui_SymbolIndex;
 	int16 L1219_i_X;
 	uint16 L1220_ui_SymbolCount;
@@ -886,8 +886,7 @@ bool MenuMan::didClickTriggerAction(int16 actionListIndex) {
 	uint16 L1196_ui_ChampionIndex;
 	uint16 L1197_ui_ActionIndex;
 	bool L1198_B_ClickTriggeredAction;
-	Champion* L1199_ps_Champion;
-
+	Champion *L1199_ps_Champion;
 
 	if (!_vm->_championMan->_actingChampionOrdinal || (actionListIndex != -1 && (_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone)))
 		return false;
@@ -953,7 +952,8 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		22, /* SPIT */
 		10, /* BRANDISH */
 		0,  /* THROW */
-		2}; /* FUSE */
+		2   /* FUSE */
+	};
 	static unsigned char G0494_auc_Graphic560_ActionStamina[44] = {
 		0,  /* N */
 		4,  /* BLOCK */
@@ -998,7 +998,8 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		3,  /* SPIT */
 		2,  /* BRANDISH */
 		0,  /* THROW */
-		2}; /* FUSE */
+		2   /* FUSE */
+	};
 	static unsigned char G0497_auc_Graphic560_ActionExperienceGain[44] = {
 		0,  /* N */
 		8,  /* BLOCK */
@@ -1043,7 +1044,8 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		25, /* SPIT */
 		0,  /* BRANDISH */
 		5,  /* THROW */
-		1}; /* FUSE */
+		1   /* FUSE */
+	};
 	uint16 L1244_ui_Multiple;
 #define AL1244_ui_TargetSquare  L1244_ui_Multiple
 #define AL1244_ui_HealingAmount L1244_ui_Multiple
@@ -1070,8 +1072,8 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 	int16 L1253_i_ActionStamina;
 	int16 L1254_i_ActionSkillIndex;
 	int16 L1255_i_ActionExperienceGain;
-	WeaponInfo* L1256_ps_WeaponInfoActionHand;
-	WeaponInfo* L1257_ps_WeaponInfoReadyHand;
+	WeaponInfo *L1256_ps_WeaponInfoActionHand;
+	WeaponInfo *L1257_ps_WeaponInfoReadyHand;
 	TimelineEvent L1258_s_Event;
 
 
@@ -1079,7 +1081,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		return false;
 	}
 	L1247_ps_Champion = &_vm->_championMan->_champions[champIndex];
-	L1248_ps_Weapon = (Weapon*)_vm->_dungeonMan->getThingData(L1247_ps_Champion->_slots[k1_ChampionSlotActionHand]);
+	L1248_ps_Weapon = (Weapon *)_vm->_dungeonMan->getThingData(L1247_ps_Champion->_slots[k1_ChampionSlotActionHand]);
 	if (!L1247_ps_Champion->_currHealth) {
 		return false;
 	}
@@ -1335,27 +1337,27 @@ T0407076:
 	return AL1245_B_ActionPerformed;
 }
 
-void MenuMan::setChampionDirectionToPartyDirection(Champion* champ) {
+void MenuMan::setChampionDirectionToPartyDirection(Champion *champ) {
 	if (champ->_dir != _vm->_dungeonMan->_partyDir) {
 		champ->_dir = _vm->_dungeonMan->_partyDir;
 		setFlag(champ->_attributes, k0x0400_ChampionAttributeIcon);
 	}
 }
 
-void MenuMan::decrementCharges(Champion* champ) {
+void MenuMan::decrementCharges(Champion *champ) {
 	Thing L1242_T_Thing;
-	Junk* L1243_ps_Junk;
+	Junk *L1243_ps_Junk;
 
-	L1243_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L1242_T_Thing = champ->_slots[k1_ChampionSlotActionHand]);
+	L1243_ps_Junk = (Junk *)_vm->_dungeonMan->getThingData(L1242_T_Thing = champ->_slots[k1_ChampionSlotActionHand]);
 	switch (L1242_T_Thing.getType()) {
 	case k5_WeaponThingType:
-		if (((Weapon*)L1243_ps_Junk)->getChargeCount()) {
-			((Weapon*)L1243_ps_Junk)->setChargeCount(((Weapon*)L1243_ps_Junk)->getChargeCount() - 1);
+		if (((Weapon *)L1243_ps_Junk)->getChargeCount()) {
+			((Weapon *)L1243_ps_Junk)->setChargeCount(((Weapon *)L1243_ps_Junk)->getChargeCount() - 1);
 		}
 		break;
 	case k6_ArmourThingType:
-		if (((Armour*)L1243_ps_Junk)->getChargeCount()) {
-			((Armour*)L1243_ps_Junk)->setChargeCount(((Armour*)L1243_ps_Junk)->getChargeCount() - 1);
+		if (((Armour *)L1243_ps_Junk)->getChargeCount()) {
+			((Armour *)L1243_ps_Junk)->setChargeCount(((Armour *)L1243_ps_Junk)->getChargeCount() - 1);
 		}
 		break;
 	case k10_JunkThingType:
@@ -1369,7 +1371,7 @@ void MenuMan::decrementCharges(Champion* champ) {
 	_vm->_championMan->drawChangedObjectIcons();
 }
 
-bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion* champ, int16 actionIndex, int16 targetMapX, int16 targetMapY, int16 skillIndex) {
+bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 actionIndex, int16 targetMapX, int16 targetMapY, int16 skillIndex) {
 	static unsigned char G0492_auc_Graphic560_ActionDamageFactor[44] = {
 		0,  /* N */
 		15, /* BLOCK */
@@ -1414,7 +1416,8 @@ bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion* champ, int16 ac
 		0,  /* SPIT */
 		0,  /* BRANDISH */
 		0,  /* THROW */
-		0}; /* FUSE */
+		0   /* FUSE */
+	};
 	static unsigned char G0493_auc_Graphic560_ActionHitProbability[44] = {
 		0,  /* N */
 		22, /* BLOCK */
@@ -1459,7 +1462,8 @@ bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion* champ, int16 ac
 		0,  /* SPIT */
 		0,  /* BRANDISH */
 		0,  /* THROW */
-		0}; /* FUSE */
+		0   /* FUSE */
+	};
 
 	uint16 L1236_ui_Multiple;
 #define AL1236_ui_ChampionCell       L1236_ui_Multiple
@@ -1494,7 +1498,7 @@ T0402005: /* Check if there is another champion in front */
 		if ((_vm->_objectMan->getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
 			setFlag(AL1237_ui_ActionHitProbability, k0x8000_hitNonMaterialCreatures);
 		}
-		_actionDamage = _vm->_groupMan->getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->getThingData(_actionTargetGroupThing), _vm->ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
+		_actionDamage = _vm->_groupMan->getMeleeActionDamage(champ, champIndex, (Group *)_vm->_dungeonMan->getThingData(_actionTargetGroupThing), _vm->ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
 		return true;
 	}
 T0402010:
@@ -1506,9 +1510,9 @@ bool MenuMan::isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, in
 	uint16 L1230_ui_FearResistance;
 	uint16 L1231_ui_Experience = 0;
 	bool L1232_B_IsGroupFrightenedByAction;
-	Group* L1233_ps_Group;
-	CreatureInfo* L1234_ps_CreatureInfo;
-	ActiveGroup* L1235_ps_ActiveGroup;
+	Group *L1233_ps_Group;
+	CreatureInfo *L1234_ps_CreatureInfo;
+	ActiveGroup *L1235_ps_ActiveGroup;
 
 
 	L1232_B_IsGroupFrightenedByAction = false;
@@ -1536,7 +1540,7 @@ bool MenuMan::isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, in
 		L1231_ui_Experience = 45;
 	}
 	L1229_i_FrightAmount += _vm->_championMan->getSkillLevel(champIndex, k14_ChampionSkillInfluence);
-	L1233_ps_Group = (Group*)_vm->_dungeonMan->getThingData(_actionTargetGroupThing);
+	L1233_ps_Group = (Group *)_vm->_dungeonMan->getThingData(_actionTargetGroupThing);
 	L1234_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[L1233_ps_Group->_type];
 	if (((L1230_ui_FearResistance = L1234_ps_CreatureInfo->getFearResistance()) > _vm->getRandomNumber(L1229_i_FrightAmount)) || (L1230_ui_FearResistance == k15_immuneToFear)) {
 		L1231_ui_Experience >>= 1;
@@ -1555,9 +1559,9 @@ T0401016:
 	return L1232_B_IsGroupFrightenedByAction;
 }
 
-void MenuMan::printMessageAfterReplacements(const char* str) {
-	char* L1164_pc_Character;
-	char* L1165_pc_ReplacementString;
+void MenuMan::printMessageAfterReplacements(const char *str) {
+	char *L1164_pc_Character;
+	char *L1165_pc_ReplacementString;
 	char L1166_ac_OutputString[128];
 
 
@@ -1633,11 +1637,12 @@ void MenuMan::processCommands116To119_setActingChampion(uint16 champIndex) {
 		ActionSet(42,   9, 255, 0x00, 0x00),
 		ActionSet(1,  12, 255, 0x02, 0x00),
 		ActionSet(42, 255, 255, 0x00, 0x00),
-		ActionSet(6,  11, 255, 0x80, 0x00)};
+		ActionSet(6,  11, 255, 0x80, 0x00)
+	};
 	uint16 L1188_ui_ActionSetIndex;
 	Thing L1189_T_Thing;
-	Champion* L1190_ps_Champion;
-	ActionSet* L1191_ps_ActionSet;
+	Champion *L1190_ps_Champion;
+	ActionSet *L1191_ps_ActionSet;
 
 
 	L1190_ps_Champion = &_vm->_championMan->_champions[champIndex];
@@ -1659,7 +1664,7 @@ void MenuMan::processCommands116To119_setActingChampion(uint16 champIndex) {
 	drawActionArea();
 }
 
-void MenuMan::setActionList(ActionSet* actionSet) {
+void MenuMan::setActionList(ActionSet *actionSet) {
 
 #define k0x0080_actionRequiresCharge 0x0080 // @ MASK0x0080_ACTION_REQUIRES_CHARGE 
 
@@ -1691,15 +1696,15 @@ void MenuMan::setActionList(ActionSet* actionSet) {
 
 int16 MenuMan::getActionObjectChargeCount() {
 	Thing L1167_T_Thing;
-	Junk* L1168_ps_Junk;
+	Junk *L1168_ps_Junk;
 
 
-	L1168_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L1167_T_Thing = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand]);
+	L1168_ps_Junk = (Junk *)_vm->_dungeonMan->getThingData(L1167_T_Thing = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand]);
 	switch (L1167_T_Thing.getType()) {
 	case k5_WeaponThingType:
-		return ((Weapon*)L1168_ps_Junk)->getChargeCount();
+		return ((Weapon *)L1168_ps_Junk)->getChargeCount();
 	case k6_ArmourThingType:
-		return ((Armour*)L1168_ps_Junk)->getChargeCount();
+		return ((Armour *)L1168_ps_Junk)->getChargeCount();
 	case k10_JunkThingType:
 		return L1168_ps_Junk->getChargeCount();
 	default:
@@ -1718,12 +1723,12 @@ void MenuMan::drawActionDamage(int16 damage) {
 	int16 L1176_i_Multiple;
 #define AL1176_i_X          L1176_i_Multiple
 #define AL1176_i_PixelWidth L1176_i_Multiple
-	byte* L1177_puc_Bitmap;
-	unsigned char* L1178_puc_Multiple;
+	byte *L1177_puc_Bitmap;
+	unsigned char *L1178_puc_Multiple;
 #define AL1178_puc_String L1178_puc_Multiple
 #define AL1178_puc_Bitmap L1178_puc_Multiple
 	char L1179_ac_String[6];
-	const Box* L1180_ps_Box;
+	const Box *L1180_ps_Box;
 	int16 L1643_i_Width;
 
 	_vm->_eventMan->showMouse();
@@ -1747,10 +1752,10 @@ void MenuMan::drawActionDamage(int16 damage) {
 
 		if (damage == kM1_damageCantReach) {
 			AL1176_i_X = pos[0];
-			AL1178_puc_String = (byte*)message[0];
+			AL1178_puc_String = (byte *)message[0];
 		} else {
 			AL1176_i_X = pos[1];
-			AL1178_puc_String = (byte*)message[1];
+			AL1178_puc_String = (byte *)message[1];
 		}
 		_vm->_textMan->printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, (char *)AL1178_puc_String);
 	} else {


Commit: 807bfc270b0d421e2ba7819dfcf27e3e30191d67
    https://github.com/scummvm/scummvm/commit/807bfc270b0d421e2ba7819dfcf27e3e30191d67
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-03T22:58:39+02:00

Commit Message:
DM: Finish the renaming of variables in InventoryMan

Changed paths:
    engines/dm/inventory.cpp



diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index c28e414..efe1e04 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -864,7 +864,7 @@ void InventoryMan::drawStopPressingEye() {
 }
 
 void InventoryMan::clickOnMouth() {
-	static int16 G0242_ai_Graphic559_FoodAmounts[8] = {
+	static int16 foodAmounts[8] = {
 		500,    /* Apple */
 		600,    /* Corn */
 		650,    /* Bread */
@@ -875,26 +875,6 @@ void InventoryMan::clickOnMouth() {
 		1400    /* Dragon steak */
 	};
 
-	Thing L1078_T_Thing;
-	uint16 L1079_ui_IconIndex;
-	uint16 L1080_ui_ChampionIndex;
-	bool L1081_B_RemoveObjectFromLeaderHand;
-	Junk *L1082_ps_Junk;
-	Champion *L1083_ps_Champion;
-	TimelineEvent L1084_s_Event;
-	uint16 L1085_ui_Multiple;
-#define AL1085_ui_PotionPower         L1085_ui_Multiple
-#define AL1085_ui_AdjustedPotionPower L1085_ui_Multiple
-#define AL1085_ui_Counter             L1085_ui_Multiple
-	uint16 L1086_ui_Counter;
-	int16 L1087_i_Wounds;
-	uint16 L1088_ui_Multiple;
-#define AL1088_ui_ThingType               L1088_ui_Multiple
-#define AL1088_ui_Mana                    L1088_ui_Multiple
-#define AL1088_ui_HealWoundIterationCount L1088_ui_Multiple
-	uint16 L1089_ui_Weight;
-
-
 	if (_vm->_championMan->_leaderEmptyHanded) {
 		if (_panelContent == k0_PanelContentFoodWaterPoisoned)
 			return;
@@ -917,113 +897,116 @@ void InventoryMan::clickOnMouth() {
 	if (_vm->_championMan->_candidateChampionOrdinal)
 		return;
 
-	L1078_T_Thing = _vm->_championMan->_leaderHandObject;
-	if (!getFlag(_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(L1078_T_Thing)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth))
+	Thing handThing = _vm->_championMan->_leaderHandObject;
+	if (!getFlag(_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(handThing)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth))
 		return;
 
-	L1079_ui_IconIndex = _vm->_objectMan->getIconIndex(L1078_T_Thing);
-	AL1088_ui_ThingType = L1078_T_Thing.getType();
-	L1089_ui_Weight = _vm->_dungeonMan->getObjectWeight(L1078_T_Thing);
-	L1080_ui_ChampionIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal);
-	L1083_ps_Champion = &_vm->_championMan->_champions[L1080_ui_ChampionIndex];
-	L1082_ps_Junk = (Junk *)_vm->_dungeonMan->getThingData(L1078_T_Thing);
-	if ((L1079_ui_IconIndex >= k8_IconIndiceJunkWater) && (L1079_ui_IconIndex <= k9_IconIndiceJunkWaterSkin)) {
-		if (!(L1082_ps_Junk->getChargeCount())) {
+	uint16 iconIndex = _vm->_objectMan->getIconIndex(handThing);
+	uint16 handThingType = handThing.getType();
+	uint16 handThingWeight = _vm->_dungeonMan->getObjectWeight(handThing);
+	uint16 championIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal);
+	Champion *curChampion = &_vm->_championMan->_champions[championIndex];
+	Junk *junkData = (Junk *)_vm->_dungeonMan->getThingData(handThing);
+	bool removeObjectFromLeaderHand;
+	if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
+		if (!(junkData->getChargeCount()))
 			return;
-		}
-		L1083_ps_Champion->_water = MIN(L1083_ps_Champion->_water + 800, 2048);
-		L1082_ps_Junk->setChargeCount(L1082_ps_Junk->getChargeCount() - 1);
-		L1081_B_RemoveObjectFromLeaderHand = false;
-	} else {
-		if (AL1088_ui_ThingType == k8_PotionThingType) {
-			L1081_B_RemoveObjectFromLeaderHand = false;
-		} else {
-			L1082_ps_Junk->setNextThing(Thing::_none);
-			L1081_B_RemoveObjectFromLeaderHand = true;
-		}
+
+		curChampion->_water = MIN(curChampion->_water + 800, 2048);
+		junkData->setChargeCount(junkData->getChargeCount() - 1);
+		removeObjectFromLeaderHand = false;
+	} else if (handThingType == k8_PotionThingType)
+		removeObjectFromLeaderHand = false;
+	else {
+		junkData->setNextThing(Thing::_none);
+		removeObjectFromLeaderHand = true;
 	}
 	_vm->_eventMan->showMouse();
-	if (L1081_B_RemoveObjectFromLeaderHand) {
+	if (removeObjectFromLeaderHand)
 		_vm->_championMan->getObjectRemovedFromLeaderHand();
-	}
-	if (AL1088_ui_ThingType == k8_PotionThingType) {
-		AL1085_ui_PotionPower = ((Potion *)L1082_ps_Junk)->getPower();
-		L1086_ui_Counter = ((511 - AL1085_ui_PotionPower) / (32 + (AL1085_ui_PotionPower + 1) / 8)) >> 1;
-		AL1085_ui_AdjustedPotionPower = (AL1085_ui_PotionPower / 25) + 8; /* Value between 8 and 18 */
-		switch (((Potion *)L1082_ps_Junk)->getType()) {
+
+	if (handThingType == k8_PotionThingType) {
+		uint16 potionPower = ((Potion *)junkData)->getPower();
+		uint16 counter = ((511 - potionPower) / (32 + (potionPower + 1) / 8)) >> 1;
+		uint16 adjustedPotionPower = (potionPower / 25) + 8; /* Value between 8 and 18 */
+
+		switch (((Potion *)junkData)->getType()) {
 		case k6_PotionTypeRos:
-			adjustStatisticCurrentValue(L1083_ps_Champion, k2_ChampionStatDexterity, AL1085_ui_AdjustedPotionPower);
+			adjustStatisticCurrentValue(curChampion, k2_ChampionStatDexterity, adjustedPotionPower);
 			break;
 		case k7_PotionTypeKu:
-			adjustStatisticCurrentValue(L1083_ps_Champion, k1_ChampionStatStrength, (((Potion *)L1082_ps_Junk)->getPower() / 35) + 5); /* Value between 5 and 12 */
+			adjustStatisticCurrentValue(curChampion, k1_ChampionStatStrength, (((Potion *)junkData)->getPower() / 35) + 5); /* Value between 5 and 12 */
 			break;
 		case k8_PotionTypeDane:
-			adjustStatisticCurrentValue(L1083_ps_Champion, k3_ChampionStatWisdom, AL1085_ui_AdjustedPotionPower);
+			adjustStatisticCurrentValue(curChampion, k3_ChampionStatWisdom, adjustedPotionPower);
 			break;
 		case k9_PotionTypeNeta:
-			adjustStatisticCurrentValue(L1083_ps_Champion, k4_ChampionStatVitality, AL1085_ui_AdjustedPotionPower);
+			adjustStatisticCurrentValue(curChampion, k4_ChampionStatVitality, adjustedPotionPower);
 			break;
 		case k10_PotionTypeAntivenin:
-			_vm->_championMan->unpoison(L1080_ui_ChampionIndex);
+			_vm->_championMan->unpoison(championIndex);
 			break;
 		case k11_PotionTypeMon:
-			L1083_ps_Champion->_currStamina += MIN(L1083_ps_Champion->_maxStamina - L1083_ps_Champion->_currStamina, L1083_ps_Champion->_maxStamina / L1086_ui_Counter);
+			curChampion->_currStamina += MIN(curChampion->_maxStamina - curChampion->_currStamina, curChampion->_maxStamina / counter);
 			break;
-		case k12_PotionTypeYa:
-			AL1085_ui_AdjustedPotionPower += AL1085_ui_AdjustedPotionPower >> 1;
-			if (L1083_ps_Champion->_shieldDefense > 50) {
-				AL1085_ui_AdjustedPotionPower >>= 2;
+		case k12_PotionTypeYa: {
+			adjustedPotionPower += adjustedPotionPower >> 1;
+			if (curChampion->_shieldDefense > 50)
+				adjustedPotionPower >>= 2;
+
+			curChampion->_shieldDefense += adjustedPotionPower;
+			TimelineEvent newEvent;
+			newEvent._type = k72_TMEventTypeChampionShield;
+			setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + (adjustedPotionPower * adjustedPotionPower));
+			newEvent._priority = championIndex;
+			newEvent._B._defense = adjustedPotionPower;
+			_vm->_timeline->addEventGetEventIndex(&newEvent);
+			setFlag(curChampion->_attributes, k0x1000_ChampionAttributeStatusBox);
 			}
-			L1083_ps_Champion->_shieldDefense += AL1085_ui_AdjustedPotionPower;
-			L1084_s_Event._type = k72_TMEventTypeChampionShield;
-			setMapAndTime(L1084_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + (AL1085_ui_AdjustedPotionPower * AL1085_ui_AdjustedPotionPower));
-			L1084_s_Event._priority = L1080_ui_ChampionIndex;
-			L1084_s_Event._B._defense = AL1085_ui_AdjustedPotionPower;
-			_vm->_timeline->addEventGetEventIndex(&L1084_s_Event);
-			setFlag(L1083_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox);
 			break;
-		case k13_PotionTypeEe:
-			AL1088_ui_Mana = MIN(900, (L1083_ps_Champion->_currMana + AL1085_ui_AdjustedPotionPower) + (AL1085_ui_AdjustedPotionPower - 8));
-			if (AL1088_ui_Mana > L1083_ps_Champion->_maxMana) {
-				AL1088_ui_Mana -= (AL1088_ui_Mana - MAX(L1083_ps_Champion->_currMana, L1083_ps_Champion->_maxMana)) >> 1;
+		case k13_PotionTypeEe: {
+			uint16 mana = MIN(900, (curChampion->_currMana + adjustedPotionPower) + (adjustedPotionPower - 8));
+			if (mana > curChampion->_maxMana)
+				mana -= (mana - MAX(curChampion->_currMana, curChampion->_maxMana)) >> 1;
+
+			curChampion->_currMana = mana;
 			}
-			L1083_ps_Champion->_currMana = AL1088_ui_Mana;
 			break;
-		case k14_PotionTypeVi:
-			AL1088_ui_HealWoundIterationCount = MAX(1, (((Potion *)L1082_ps_Junk)->getPower() / 42));
-			L1083_ps_Champion->_currHealth += L1083_ps_Champion->_maxHealth / L1086_ui_Counter;
-			L1087_i_Wounds = L1083_ps_Champion->_wounds;
-			if (L1087_i_Wounds) { /* If the champion is wounded */
-				L1086_ui_Counter = 10;
+		case k14_PotionTypeVi: {
+			uint16 healWoundIterationCount = MAX(1, (((Potion *)junkData)->getPower() / 42));
+			curChampion->_currHealth += curChampion->_maxHealth / counter;
+			int16 wounds = curChampion->_wounds;
+			if (wounds) { /* If the champion is wounded */
+				counter = 10;
 				do {
-					for (AL1085_ui_Counter = 0; AL1085_ui_Counter < AL1088_ui_HealWoundIterationCount; AL1085_ui_Counter++) {
-						L1083_ps_Champion->_wounds &= _vm->getRandomNumber(65536);
-					}
-					AL1088_ui_HealWoundIterationCount = 1;
-				} while ((L1087_i_Wounds == L1083_ps_Champion->_wounds) && --L1086_ui_Counter); /* Loop until at least one wound is healed or there are no more heal iterations */
+					for (uint16 i = 0; i < healWoundIterationCount; i++)
+						curChampion->_wounds &= _vm->getRandomNumber(65536);
+
+					healWoundIterationCount = 1;
+				} while ((wounds == curChampion->_wounds) && --counter); /* Loop until at least one wound is healed or there are no more heal iterations */
+			}
+			setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad | k0x2000_ChampionAttributeWounds);
 			}
-			setFlag(L1083_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad | k0x2000_ChampionAttributeWounds);
 			break;
 		case k15_PotionTypeWaterFlask:
-			L1083_ps_Champion->_water = MIN(L1083_ps_Champion->_water + 1600, 2048);
+			curChampion->_water = MIN(curChampion->_water + 1600, 2048);
 			break;
 		default:
 			break;
 		}
-		((Potion *)L1082_ps_Junk)->setType(k20_PotionTypeEmptyFlask);
-	} else if ((L1079_ui_IconIndex >= k168_IconIndiceJunkApple) && (L1079_ui_IconIndex < k176_IconIndiceJunkIronKey)) {
-		L1083_ps_Champion->_food = MIN(L1083_ps_Champion->_food + G0242_ai_Graphic559_FoodAmounts[L1079_ui_IconIndex - k168_IconIndiceJunkApple], 2048);
-	}
+		((Potion *)junkData)->setType(k20_PotionTypeEmptyFlask);
+	} else if ((iconIndex >= k168_IconIndiceJunkApple) && (iconIndex < k176_IconIndiceJunkIronKey))
+		curChampion->_food = MIN(curChampion->_food + foodAmounts[iconIndex - k168_IconIndiceJunkApple], 2048);
 
-	if (L1083_ps_Champion->_currStamina > L1083_ps_Champion->_maxStamina)
-		L1083_ps_Champion->_currStamina = L1083_ps_Champion->_maxStamina;
+	if (curChampion->_currStamina > curChampion->_maxStamina)
+		curChampion->_currStamina = curChampion->_maxStamina;
 
-	if (L1083_ps_Champion->_currHealth > L1083_ps_Champion->_maxHealth)
-		L1083_ps_Champion->_currHealth = L1083_ps_Champion->_maxHealth;
+	if (curChampion->_currHealth > curChampion->_maxHealth)
+		curChampion->_currHealth = curChampion->_maxHealth;
 
-	if (L1081_B_RemoveObjectFromLeaderHand) {
-		for (L1086_ui_Counter = 5; --L1086_ui_Counter; _vm->delay(8)) { /* Animate mouth icon */
-			_vm->_objectMan->drawIconToScreen(k205_IconIndiceMouthOpen + !(L1086_ui_Counter & 0x0001), 56, 46);
+	if (removeObjectFromLeaderHand) {
+		for (uint16 i = 5; --i; _vm->delay(8)) { /* Animate mouth icon */
+			_vm->_objectMan->drawIconToScreen(k205_IconIndiceMouthOpen + !(i & 0x0001), 56, 46);
 			_vm->_eventMan->discardAllInput();
 			if (_vm->_engineShouldQuit)
 				return;
@@ -1031,36 +1014,35 @@ void InventoryMan::clickOnMouth() {
 		}
 	} else {
 		_vm->_championMan->drawChangedObjectIcons();
-		_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(L1078_T_Thing) - L1089_ui_Weight;
+		_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(handThing) - handThingWeight;
 		setFlag(_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
 	}
 	_vm->_sound->requestPlay(k08_soundSWALLOW, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
-	setFlag(L1083_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
-	if (_panelContent == k0_PanelContentFoodWaterPoisoned) {
-		setFlag(L1083_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
-	}
-	_vm->_championMan->drawChampionState((ChampionIndex)L1080_ui_ChampionIndex);
+	setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+
+	if (_panelContent == k0_PanelContentFoodWaterPoisoned)
+		setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel);
+
+	_vm->_championMan->drawChampionState((ChampionIndex)championIndex);
 	_vm->_eventMan->hideMouse();
 }
 
 void InventoryMan::adjustStatisticCurrentValue(Champion *champ, uint16 statIndex, int16 valueDelta) {
-	int16 L1077_i_Multiple;
-#define AL1077_i_CurrentValue L1077_i_Multiple
-#define AL1077_i_Delta        L1077_i_Multiple
-
+	int16 delta;
 	if (valueDelta >= 0) {
-		if ((AL1077_i_CurrentValue = champ->_statistics[statIndex][k1_ChampionStatCurrent]) > 120) {
+		int16 currentValue = champ->_statistics[statIndex][k1_ChampionStatCurrent];
+		if (currentValue > 120) {
 			valueDelta >>= 1;
-			if (AL1077_i_CurrentValue > 150) {
+			if (currentValue > 150) {
 				valueDelta >>= 1;
 			}
 			valueDelta++;
 		}
-		AL1077_i_Delta = MIN(valueDelta, (int16)(170 - AL1077_i_CurrentValue));
+		delta = MIN(valueDelta, (int16)(170 - currentValue));
 	} else { /* BUG0_00 Useless code. The function is always called with valueDelta having a positive value */
-		AL1077_i_Delta = MAX(valueDelta, int16(champ->_statistics[statIndex][k2_ChampionStatMinimum] - champ->_statistics[statIndex][k1_ChampionStatCurrent]));
+		delta = MAX(valueDelta, int16(champ->_statistics[statIndex][k2_ChampionStatMinimum] - champ->_statistics[statIndex][k1_ChampionStatCurrent]));
 	}
-	champ->_statistics[statIndex][k1_ChampionStatCurrent] += AL1077_i_Delta;
+	champ->_statistics[statIndex][k1_ChampionStatCurrent] += delta;
 }
 
 void InventoryMan::clickOnEye() {
@@ -1078,13 +1060,13 @@ void InventoryMan::clickOnEye() {
 	_vm->_eventMan->hideMouse();
 	_vm->delay(8);
 	drawIconToViewport(k203_IconIndiceEyeLooking, 12, 13);
-	if (_vm->_championMan->_leaderEmptyHanded) {
+	if (_vm->_championMan->_leaderEmptyHanded)
 		drawChampionSkillsAndStatistics();
-	} else {
+	else {
 		_vm->_objectMan->clearLeaderObjectName();
 		drawPanelObject(_vm->_championMan->_leaderHandObject, true);
 	}
 	_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
-
 }
+
 }


Commit: e4863c0c7357e7f0fff0776018843acd6656c4d0
    https://github.com/scummvm/scummvm/commit/e4863c0c7357e7f0fff0776018843acd6656c4d0
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-03T23:59:31+02:00

Commit Message:
DM: Polishing in loadsave

Changed paths:
    engines/dm/loadsave.cpp



diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index ef3ed34..c6f1b21 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -40,14 +40,13 @@
 #include "dm/projexpl.h"
 #include "dm/dialog.h"
 
-
 namespace DM {
 
 LoadgameResponse DMEngine::loadgame(int16 slot) {
 	if (slot == -1 && _newGameFl == k0_modeLoadSavedGame)
 		return kM1_LoadgameFailure;
 
-	bool L1366_B_FadePalette = true;
+	bool fadePalette = true;
 	Common::String fileName;
 	Common::SaveFileManager *saveFileManager = nullptr;
 	Common::InSaveFile *file = nullptr;
@@ -131,7 +130,7 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
 		_timeline->initTimeline();
 		_groupMan->initActiveGroups();
 
-		if (L1366_B_FadePalette) {
+		if (fadePalette) {
 			_displayMan->startEndFadeToPalette(_displayMan->_blankBuffer);
 			delay(1);
 			_displayMan->fillScreen(k0_ColorBlack);
@@ -154,7 +153,6 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
 			_dialog->dialogDraw(nullptr, "CHARGEMENT DU JEU . . .", nullptr, nullptr, nullptr, nullptr, true, true, true);
 			break;
 		}
-
 	}
 	_championMan->_partyDead = false;
 
@@ -268,9 +266,9 @@ void DMEngine::writeSaveGameHeader(Common::OutSaveFile *out, const Common::Strin
 	out->writeByte(0);
 
 	// Save the game thumbnail
-	if (_saveThumbnail) {
+	if (_saveThumbnail)
 		out->write(_saveThumbnail->getData(), _saveThumbnail->size());
-	} else
+	else
 		Graphics::saveThumbnail(*out);
 
 	// Creation date/time
@@ -291,9 +289,8 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 	Common::SaveFileManager *saveFileManager = _system->getSavefileManager();
 	Common::OutSaveFile *file = saveFileManager->openForSaving(savefileName);
 
-	if (!file) {
+	if (!file)
 		return false;
-	}
 
 	writeSaveGameHeader(file, saveDescription);
 
@@ -339,29 +336,27 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
 	file->writeUint32BE(0x6f85e3d3);
 
 	// save _g278_dungeonFileHeader
-	{
-		DungeonFileHeader &header = _dungeonMan->_dungeonFileHeader;
-		file->writeUint16BE(header._ornamentRandomSeed);
-		file->writeUint16BE(header._rawMapDataSize);
-		file->writeByte(header._mapCount);
-		file->writeByte(0); // to match the structure of dungeon.dat, will be discarded
-		file->writeUint16BE(header._textDataWordCount);
-		file->writeUint16BE(header._partyStartLocation);
-		file->writeUint16BE(header._squareFirstThingCount);
-		for (uint16 i = 0; i < 16; ++i)
-			file->writeUint16BE(header._thingCounts[i]);
-	}
+	DungeonFileHeader &header = _dungeonMan->_dungeonFileHeader;
+	file->writeUint16BE(header._ornamentRandomSeed);
+	file->writeUint16BE(header._rawMapDataSize);
+	file->writeByte(header._mapCount);
+	file->writeByte(0); // to match the structure of dungeon.dat, will be discarded
+	file->writeUint16BE(header._textDataWordCount);
+	file->writeUint16BE(header._partyStartLocation);
+	file->writeUint16BE(header._squareFirstThingCount);
+	for (uint16 i = 0; i < 16; ++i)
+		file->writeUint16BE(header._thingCounts[i]);
 
 	// save _g277_dungeonMaps
 	for (uint16 i = 0; i < _dungeonMan->_dungeonFileHeader._mapCount; ++i) {
 		Map &map = _dungeonMan->_dungeonMaps[i];
-		uint16 tmp;
 
 		file->writeUint16BE(map._rawDunDataOffset);
 		file->writeUint32BE(0); // to match the structure of dungeon.dat, will be discarded
 		file->writeByte(map._offsetMapX);
 		file->writeByte(map._offsetMapY);
 
+		uint16 tmp;
 		tmp = ((map._height & 0x1F) << 11) | ((map._width & 0x1F) << 6) | (map._level & 0x3F);
 		file->writeUint16BE(tmp);
 


Commit: 3ecc98e83203b70378adef1efe572ec436e4343a
    https://github.com/scummvm/scummvm/commit/3ecc98e83203b70378adef1efe572ec436e4343a
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T00:01:16+02:00

Commit Message:
DM: Change savegame signature to DM21 instead of DMDM. That breaks savegames compatibility.

Changed paths:
    engines/dm/loadsave.cpp



diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index c6f1b21..5feb484 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -252,7 +252,7 @@ Common::String DMEngine::getSavefileName(uint16 slot) {
 	return Common::String::format("%s.%03u", _targetName.c_str(), slot);
 }
 
-#define SAVEGAME_ID       MKTAG('D', 'M', 'D', 'M')
+#define SAVEGAME_ID       MKTAG('D', 'M', '2', '1')
 #define SAVEGAME_VERSION  1
 
 void DMEngine::writeSaveGameHeader(Common::OutSaveFile *out, const Common::String& saveName) {


Commit: ef144e1e8b90badc0bbbe2e7b624fd4ac08c7bc6
    https://github.com/scummvm/scummvm/commit/ef144e1e8b90badc0bbbe2e7b624fd4ac08c7bc6
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T00:13:19+02:00

Commit Message:
DM: Polishing in LZWdecompressor

Changed paths:
    engines/dm/lzw.cpp



diff --git a/engines/dm/lzw.cpp b/engines/dm/lzw.cpp
index a93b0c8..dc5055f 100644
--- a/engines/dm/lzw.cpp
+++ b/engines/dm/lzw.cpp
@@ -106,28 +106,25 @@ int16 LZWdecompressor::getNextInputCode(Common::MemoryReadStream &inputStream, i
 }
 
 void LZWdecompressor::outputCharacter(byte character, byte **out) {
-	byte *L1558_pc_Output = *out;
+	byte *output = *out;
 
 	if (false == _repetitionEnabled) {
-		if (character == 0x90) {
+		if (character == 0x90)
 			_repetitionEnabled = true;
-		} else {
-			*L1558_pc_Output++ = _charToRepeat = character;
-		}
-		*out = L1558_pc_Output;
-		return;
+		else
+			*output++ = _charToRepeat = character;
 	} else {
 		if (character) { /* If character following 0x90 is not 0x00 then it is the repeat count */
-			while (--character) {
-				*L1558_pc_Output++ = _charToRepeat;
-			}
-		} else { /* else output a 0x90 character */
-			*L1558_pc_Output++ = 0x90;
-		}
+			while (--character)
+				*output++ = _charToRepeat;
+		} else /* else output a 0x90 character */
+			*output++ = 0x90;
+
 		_repetitionEnabled = false;
-		*out = L1558_pc_Output;
-		return;
 	}
+
+	*out = output;
+	return;
 }
 
 int32 LZWdecompressor::decompress(Common::MemoryReadStream &inStream, int32 inputByteCount, byte *out) {


Commit: 4eeeea2c8d8cacbc52da370a54021913dcd37e0f
    https://github.com/scummvm/scummvm/commit/4eeeea2c8d8cacbc52da370a54021913dcd37e0f
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T08:47:13+02:00

Commit Message:
DM: Refactoring, enforce the use of ChampionIndex

Changed paths:
    engines/dm/champion.cpp
    engines/dm/eventman.cpp
    engines/dm/menus.cpp
    engines/dm/menus.h



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 7d696a3..6385547 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1495,19 +1495,19 @@ void ChampionMan::championKill(uint16 champIndex) {
 	_vm->_displayMan->fillScreenBox(_boxChampionIcons[curChampionIconIndex], k0_ColorBlack);
 	drawChampionState((ChampionIndex)champIndex);
 
-	int16 aliveChampionIndex;
-	for (aliveChampionIndex = k0_ChampionFirst, curChampion = _champions; aliveChampionIndex < _partyChampionCount; aliveChampionIndex++, curChampion++) {
-		if (curChampion->_currHealth)
-			break;
-	}
+	ChampionIndex aliveChampionIndex;
+	int idx = 0;
+	for (curChampion = _champions; (idx < _partyChampionCount) && (curChampion->_currHealth == 0); idx++, curChampion++)
+		;
 
+	aliveChampionIndex = (ChampionIndex)idx;
 	if (aliveChampionIndex == _partyChampionCount) { /* BUG0_43 The game does not end if the last living champion in the party is killed while looking at a candidate champion in a portrait. The condition to end the game when the whole party is killed is not true because the code considers the candidate champion as alive (in the loop above) */
 		_partyDead = true;
 		return;
 	}
 
 	if (champIndex == _leaderIndex)
-		_vm->_eventMan->commandSetLeader((ChampionIndex)aliveChampionIndex);
+		_vm->_eventMan->commandSetLeader(aliveChampionIndex);
 
 	if (champIndex == _magicCasterChampionIndex)
 		_vm->_menuMan->setMagicCasterAndDrawSpellArea(aliveChampionIndex);
@@ -1829,28 +1829,31 @@ ChampionIndex ChampionMan::getIndexInCell(int16 cell) {
 
 void ChampionMan::resetDataToStartGame() {
 	if (!_vm->_newGameFl) {
-		Thing L0787_T_Thing;
-		if ((L0787_T_Thing = _leaderHandObject) == Thing::_none) {
+		Thing handThing = _leaderHandObject;
+		if (handThing == Thing::_none) {
 			_leaderEmptyHanded = true;
 			_leaderHandObjectIconIndex = kM1_IconIndiceNone;
 			_vm->_eventMan->setMousePointer();
-		} else {
-			putObjectInLeaderHand(L0787_T_Thing, true); /* This call will add the weight of the leader hand object to the Load of the leader a first time */
-		}
-		Champion *L0788_ps_Champion = _champions;
-		int16 L0785_i_ChampionIndex;
-		for (L0785_i_ChampionIndex = k0_ChampionFirst; L0785_i_ChampionIndex < _partyChampionCount; L0785_i_ChampionIndex++, L0788_ps_Champion++) {
-			clearFlag(L0788_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
-			setFlag(L0788_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
+		} else
+			putObjectInLeaderHand(handThing, true); /* This call will add the weight of the leader hand object to the Load of the leader a first time */
+
+		Champion *curChampion = _champions;
+		for (int16 idx = 0; idx < _partyChampionCount; idx++, curChampion++) {
+			clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
+			setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
 		}
 		drawAllChampionStates();
-		if ((L0785_i_ChampionIndex = _leaderIndex) != kM1_ChampionNone) {
+
+		ChampionIndex championIndex = _leaderIndex;
+		if (championIndex != kM1_ChampionNone) {
 			_leaderIndex = kM1_ChampionNone;
-			_vm->_eventMan->commandSetLeader((ChampionIndex)L0785_i_ChampionIndex);
+			_vm->_eventMan->commandSetLeader(championIndex);
 		}
-		if ((L0785_i_ChampionIndex = _magicCasterChampionIndex) != kM1_ChampionNone) {
+
+		championIndex = _magicCasterChampionIndex;
+		if (championIndex != kM1_ChampionNone) {
 			_magicCasterChampionIndex = kM1_ChampionNone;
-			_vm->_menuMan->setMagicCasterAndDrawSpellArea(L0785_i_ChampionIndex);
+			_vm->_menuMan->setMagicCasterAndDrawSpellArea(championIndex);
 		}
 		return;
 	}
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 2c6ee2b..8027b30 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1497,43 +1497,43 @@ void EventManager::mouseProcessCommands125To128_clickOnChampionIcon(uint16 champ
 }
 
 void EventManager::commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY) {
-	int16 championIndex = kM1_ChampionNone;
+	ChampionIndex championIndex = kM1_ChampionNone;
 	if (posY <= 48) {
 		switch (_vm->_championMan->_magicCasterChampionIndex) {
 		case 0:
 			if ((posX >= 280) && (posX <= 291))
-				championIndex = 1;
+				championIndex = k1_ChampionSecond;
 			else if ((posX >= 294) && (posX <= 305))
-				championIndex = 2;
+				championIndex = k2_ChampionThird;
 			else if (posX >= 308)
-				championIndex = 3;
+				championIndex = k3_ChampionFourth;
 
 			break;
 		case 1:
 			if ((posX >= 233) && (posX <= 244))
-				championIndex = 0;
+				championIndex = k0_ChampionFirst;
 			else if ((posX >= 294) && (posX <= 305))
-				championIndex = 2;
+				championIndex = k2_ChampionThird;
 			else if (posX >= 308)
-				championIndex = 3;
+				championIndex = k3_ChampionFourth;
 
 			break;
 		case 2:
 			if ((posX >= 233) && (posX <= 244))
-				championIndex = 0;
+				championIndex = k0_ChampionFirst;
 			else if ((posX >= 247) && (posX <= 258))
-				championIndex = 1;
+				championIndex = k1_ChampionSecond;
 			else if (posX >= 308)
-				championIndex = 3;
+				championIndex = k3_ChampionFourth;
 
 			break;
 		case 3:
 			if ((posX >= 247) && (posX <= 258))
-				championIndex = 1;
+				championIndex = k1_ChampionSecond;
 			else if ((posX >= 261) && (posX <= 272))
-				championIndex = 2;
+				championIndex = k2_ChampionThird;
 			else if (posX <= 244)
-				championIndex = 0;
+				championIndex = k0_ChampionFirst;
 			break;
 		default:
 			break;
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index f0f7930..17c08a4 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -283,7 +283,7 @@ void MenuMan::drawActionArea() {
 }
 
 const char *MenuMan::getActionName(ChampionAction actionIndex) {
-	const char *g490_ChampionActionNames[44] = { // @ G0490_ac_Graphic560_ActionNames
+	const char *championActionNames[44] = { // @ G0490_ac_Graphic560_ActionNames
 		"N", "BLOCK", "CHOP", "X", "BLOW HORN", "FLIP", "PUNCH",
 		"KICK", "WAR CRY", "STAB", "CLIMB DOWN", "FREEZE LIFE",
 		"HIT", "SWING", "STAB", "THRUST", "JAB", "PARRY", "HACK",
@@ -294,7 +294,7 @@ const char *MenuMan::getActionName(ChampionAction actionIndex) {
 		"BRANDISH", "THROW", "FUSE"
 	};
 
-	return (actionIndex == k255_ChampionActionNone) ? "" : g490_ChampionActionNames[actionIndex];
+	return (actionIndex == k255_ChampionActionNone) ? "" : championActionNames[actionIndex];
 }
 
 void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
@@ -308,55 +308,61 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
 	int16 champHP3 = _vm->_championMan->_champions[3]._currHealth;
 	_vm->_eventMan->showMouse();
 	_vm->_displayMan->fillScreenBox(boxSpellAreaControls, k0_ColorBlack);
+
 	switch (champIndex) {
 	case 0:
 		_vm->_eventMan->highlightScreenBox(233, 277, 42, 49);
 		_vm->_textMan->printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
 		if (_vm->_championMan->_partyChampionCount > 1) {
-			if (champHP1) {
+			if (champHP1)
 				_vm->_eventMan->highlightScreenBox(280, 291, 42, 48);
-			}
-T0393002:
+
 			if (_vm->_championMan->_partyChampionCount > 2) {
-				if (champHP2) {
+				if (champHP2)
 					_vm->_eventMan->highlightScreenBox(294, 305, 42, 48);
-				}
-T0393003:
-				if (_vm->_championMan->_partyChampionCount > 3) {
-					if (champHP3) {
-						_vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
-					}
-				}
+
+				if ((_vm->_championMan->_partyChampionCount > 3) && champHP3)
+					_vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
 			}
 		}
 		break;
 	case 1:
-		if (champHP0) {
+		if (champHP0)
 			_vm->_eventMan->highlightScreenBox(233, 244, 42, 48);
-		}
+
 		_vm->_eventMan->highlightScreenBox(247, 291, 42, 49);
 		_vm->_textMan->printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
-		goto T0393002;
+		if (_vm->_championMan->_partyChampionCount > 2) {
+			if (champHP2)
+				_vm->_eventMan->highlightScreenBox(294, 305, 42, 48);
+
+			if ((_vm->_championMan->_partyChampionCount > 3) && champHP3)
+				_vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
+		}
+		break;
 	case 2:
-		if (champHP0) {
+		if (champHP0)
 			_vm->_eventMan->highlightScreenBox(233, 244, 42, 48);
-		}
-		if (champHP1) {
+
+		if (champHP1)
 			_vm->_eventMan->highlightScreenBox(247, 258, 42, 48);
-		}
+
 		_vm->_eventMan->highlightScreenBox(261, 305, 42, 49);
 		_vm->_textMan->printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
-		goto T0393003;
+		if ((_vm->_championMan->_partyChampionCount > 3) && champHP3)
+			_vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
+		break;
+
 	case 3:
-		if (champHP0) {
+		if (champHP0)
 			_vm->_eventMan->highlightScreenBox(233, 244, 42, 48);
-		}
-		if (champHP1) {
+
+		if (champHP1)
 			_vm->_eventMan->highlightScreenBox(247, 258, 42, 48);
-		}
-		if (champHP2) {
+
+		if (champHP2)
 			_vm->_eventMan->highlightScreenBox(261, 272, 42, 48);
-		}
+
 		_vm->_eventMan->highlightScreenBox(275, 319, 42, 49);
 		_vm->_textMan->printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
 		break;
@@ -366,44 +372,42 @@ T0393003:
 	_vm->_eventMan->hideMouse();
 }
 
-#define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
-#define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
-
 void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
 	static Box boxSpellAreaLine(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine 
 
-	char L1204_ac_SpellSymbolString[2] = {'\0', '\0'};
-	Champion *L1203_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
+	char spellSymbolString[2] = {'\0', '\0'};
+	Champion *magicChampion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
 	if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) {
 		_vm->_displayMan->_useByteBoxCoordinates = false;
 		_vm->_displayMan->blitToBitmap(_bitmapSpellAreaLines, _bitmapSpellAreaLine, boxSpellAreaLine, 0, 12, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
 		int16 x = 1;
-		char character = 96 + (6 * L1203_ps_Champion->_symbolStep);
+		char character = 96 + (6 * magicChampion->_symbolStep);
 		for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
-			L1204_ac_SpellSymbolString[0] = character++;
-			_vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 48, x += 14, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
+			spellSymbolString[0] = character++;
+			x += 14;
+			_vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 48, x, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
 		}
 	} else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) {
 		_vm->_displayMan->_useByteBoxCoordinates = false;
 		_vm->_displayMan->blitToBitmap(_bitmapSpellAreaLines, _bitmapSpellAreaLine, boxSpellAreaLine, 0, 24, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
 		int16 x = 8;
 		for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
-			if ((L1204_ac_SpellSymbolString[0] = L1203_ps_Champion->_symbols[symbolIndex]) == '\0')
+			if ((spellSymbolString[0] = magicChampion->_symbols[symbolIndex]) == '\0')
 				break;
-			_vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 48, x += 9, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
+			x += 9;
+			_vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 48, x, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
 		}
 	}
 }
 
-void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
+void MenuMan::setMagicCasterAndDrawSpellArea(ChampionIndex champIndex) {
 	static Box boxSpellAreaLine2(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 
 	static Box boxSpellAreaLine3(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 
 
-	Champion *L1213_ps_Champion;
-
-	if ((champIndex == _vm->_championMan->_magicCasterChampionIndex) || ((champIndex != kM1_ChampionNone) && !_vm->_championMan->_champions[champIndex]._currHealth)) {
+	if ((champIndex == _vm->_championMan->_magicCasterChampionIndex)
+	|| ((champIndex != kM1_ChampionNone) && !_vm->_championMan->_champions[champIndex]._currHealth))
 		return;
-	}
+
 	if (_vm->_championMan->_magicCasterChampionIndex == kM1_ChampionNone) {
 		_vm->_eventMan->showMouse();
 		_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &_boxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33);
@@ -417,7 +421,8 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
 		_vm->_eventMan->hideMouse();
 		return;
 	}
-	L1213_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex = (ChampionIndex)champIndex];
+	_vm->_championMan->_magicCasterChampionIndex = champIndex;
+	Champion *L1213_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
 	buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
 	_vm->_eventMan->showMouse();
 	drawSpellAreaControls((ChampionIndex)champIndex);
@@ -428,23 +433,18 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
 }
 
 void MenuMan::drawEnabledMenus() {
-	int16 L1462_i_Multiple;
-#define AL1462_i_MagicCasterChampionIndex L1462_i_Multiple
-#define AL1462_i_InventoryChampionOrdinal L1462_i_Multiple
-
-
 	if (_vm->_championMan->_partyIsSleeping) {
 		_vm->_eventMan->drawSleepScreen();
 		_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 	} else {
-		AL1462_i_MagicCasterChampionIndex = _vm->_championMan->_magicCasterChampionIndex;
+		ChampionIndex casterChampionIndex = _vm->_championMan->_magicCasterChampionIndex;
 		_vm->_championMan->_magicCasterChampionIndex = kM1_ChampionNone; /* Force next function to draw the spell area */
-		setMagicCasterAndDrawSpellArea(AL1462_i_MagicCasterChampionIndex);
+		setMagicCasterAndDrawSpellArea(casterChampionIndex);
 		if (!_vm->_championMan->_actingChampionOrdinal) {
 			_actionAreaContainsIcons = true;
 		}
 		drawActionArea();
-		AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_inventoryChampionOrdinal;
+		int16 AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_inventoryChampionOrdinal;
 		if (AL1462_i_InventoryChampionOrdinal) {
 			_vm->_inventoryMan->_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
 			_vm->_inventoryMan->toggleInventory((ChampionIndex)_vm->ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 1d37651..ab6e002 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -36,6 +36,8 @@ namespace DM {
 
 #define kM1_damageCantReach -1 // @ CM1_DAMAGE_CANT_REACH    
 #define kM2_damageNoAmmunition -2 // @ CM2_DAMAGE_NO_AMMUNITION 
+#define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
+#define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
 
 #define k0x8000_hitNonMaterialCreatures 0x8000 // @ MASK0x8000_HIT_NON_MATERIAL_CREATURES 
 
@@ -90,7 +92,7 @@ public:
 	const char *getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName
 	void drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls
 	void buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine
-	void setMagicCasterAndDrawSpellArea(int16 champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea
+	void setMagicCasterAndDrawSpellArea(ChampionIndex champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea
 	void drawEnabledMenus(); // @ F0457_START_DrawEnabledMenus_CPSF
 	int16 getClickOnSpellCastResult(); // @ F0408_MENUS_GetClickOnSpellCastResult
 	int16 getChampionSpellCastResult(uint16 champIndex); // @ F0412_MENUS_GetChampionSpellCastResult


Commit: f81093168eac63168544ab3ce952cd4dae749396
    https://github.com/scummvm/scummvm/commit/f81093168eac63168544ab3ce952cd4dae749396
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T08:56:14+02:00

Commit Message:
DM: Rework getClickOnSpellCastResult

Changed paths:
    engines/dm/menus.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 17c08a4..f615c7b 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -440,9 +440,9 @@ void MenuMan::drawEnabledMenus() {
 		ChampionIndex casterChampionIndex = _vm->_championMan->_magicCasterChampionIndex;
 		_vm->_championMan->_magicCasterChampionIndex = kM1_ChampionNone; /* Force next function to draw the spell area */
 		setMagicCasterAndDrawSpellArea(casterChampionIndex);
-		if (!_vm->_championMan->_actingChampionOrdinal) {
+		if (!_vm->_championMan->_actingChampionOrdinal)
 			_actionAreaContainsIcons = true;
-		}
+
 		drawActionArea();
 		int16 AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_inventoryChampionOrdinal;
 		if (AL1462_i_InventoryChampionOrdinal) {
@@ -457,22 +457,20 @@ void MenuMan::drawEnabledMenus() {
 }
 
 int16 MenuMan::getClickOnSpellCastResult() {
-	int16 L1259_i_SpellCastResult;
-	Champion *L1260_ps_Champion;
-
-
-	L1260_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
+	Champion *casterChampion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
 	_vm->_eventMan->showMouse();
 	_vm->_eventMan->highlightBoxDisable();
-	if ((L1259_i_SpellCastResult = getChampionSpellCastResult(_vm->_championMan->_magicCasterChampionIndex)) != k3_spellCastFailureNeedsFlask) {
-		L1260_ps_Champion->_symbols[0] = '\0';
-		drawAvailableSymbols(L1260_ps_Champion->_symbolStep = 0);
-		drawChampionSymbols(L1260_ps_Champion);
-	} else {
-		L1259_i_SpellCastResult = k0_spellCastFailure;
-	}
+
+	int16 spellCastResult = getChampionSpellCastResult(_vm->_championMan->_magicCasterChampionIndex);
+	if (spellCastResult != k3_spellCastFailureNeedsFlask) {
+		casterChampion->_symbols[0] = '\0';
+		drawAvailableSymbols(casterChampion->_symbolStep = 0);
+		drawChampionSymbols(casterChampion);
+	} else
+		spellCastResult = k0_spellCastFailure;
+
 	_vm->_eventMan->hideMouse();
-	return L1259_i_SpellCastResult;
+	return spellCastResult;
 }
 
 int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {


Commit: e0f1285fbcdbf9cd85fc18f187d04b3d044dc489
    https://github.com/scummvm/scummvm/commit/e0f1285fbcdbf9cd85fc18f187d04b3d044dc489
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T08:57:13+02:00

Commit Message:
DM: Remove useless code in setMagicCasterAndDrawSpellArea

Changed paths:
    engines/dm/menus.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index f615c7b..f944560 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -422,7 +422,6 @@ void MenuMan::setMagicCasterAndDrawSpellArea(ChampionIndex champIndex) {
 		return;
 	}
 	_vm->_championMan->_magicCasterChampionIndex = champIndex;
-	Champion *L1213_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
 	buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
 	_vm->_eventMan->showMouse();
 	drawSpellAreaControls((ChampionIndex)champIndex);


Commit: 04c3beefd7ddfb66a486f9cc33a3b622c7d3365d
    https://github.com/scummvm/scummvm/commit/04c3beefd7ddfb66a486f9cc33a3b622c7d3365d
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T09:38:59+02:00

Commit Message:
DM: First pass of renaming in getChampionSpellCastResult

Changed paths:
    engines/dm/menus.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index f944560..23e1a14 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -424,7 +424,7 @@ void MenuMan::setMagicCasterAndDrawSpellArea(ChampionIndex champIndex) {
 	_vm->_championMan->_magicCasterChampionIndex = champIndex;
 	buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
 	_vm->_eventMan->showMouse();
-	drawSpellAreaControls((ChampionIndex)champIndex);
+	drawSpellAreaControls(champIndex);
 	_vm->_displayMan->blitToScreen(_bitmapSpellAreaLine, &boxSpellAreaLine2, k48_byteWidth, kM1_ColorNoTransparency, 12);
 	buildSpellAreaLine(k3_SpellAreaChampionSymbols);
 	_vm->_displayMan->blitToScreen(_bitmapSpellAreaLine, &boxSpellAreaLine3, k48_byteWidth, kM1_ColorNoTransparency, 12);
@@ -478,90 +478,81 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 #define AL1267_ui_LightPower L1267_ui_Multiple
 #define AL1267_ui_SpellPower L1267_ui_Multiple
 #define AL1267_ui_Ticks      L1267_ui_Multiple
-	int16 L1268_i_PowerSymbolOrdinal;
-	uint16 L1269_ui_Multiple;
-#define AL1269_ui_RequiredSkillLevel L1269_ui_Multiple
-#define AL1269_ui_EmptyFlaskWeight   L1269_ui_Multiple
-#define AL1269_ui_Ticks              L1269_ui_Multiple
-	Champion *L1270_ps_Champion;
-	Spell *L1271_ps_Spell;
-	Thing L1272_T_Object;
-	uint16 L1273_ui_Experience;
-	int16 L1274_i_MissingSkillLevelCount;
-	Potion *L1275_ps_Potion;
-	TimelineEvent L1276_s_Event;
-	Junk *L1277_ps_Junk;
 
-
-	if (champIndex >= _vm->_championMan->_partyChampionCount) {
+	if (champIndex >= _vm->_championMan->_partyChampionCount)
 		return k0_spellCastFailure;
-	}
-	L1270_ps_Champion = &_vm->_championMan->_champions[champIndex];
-	if (!(L1270_ps_Champion->_currHealth)) {
+
+	Champion *curChampion = &_vm->_championMan->_champions[champIndex];
+	if (!curChampion->_currHealth)
 		return k0_spellCastFailure;
-	}
-	L1271_ps_Spell = getSpellFromSymbols((unsigned char *)L1270_ps_Champion->_symbols);
-	if (L1271_ps_Spell == 0) {
-		menusPrintSpellFailureMessage(L1270_ps_Champion, k1_spellCastSuccess, 0);
+
+	Spell *curSpell = getSpellFromSymbols((unsigned char *)curChampion->_symbols);
+	if (!curSpell) {
+		menusPrintSpellFailureMessage(curChampion, k1_spellCastSuccess, 0);
 		return k0_spellCastFailure;
 	}
-	L1268_i_PowerSymbolOrdinal = L1270_ps_Champion->_symbols[0] - '_'; /* Values 1 to 6 */
-	AL1269_ui_RequiredSkillLevel = L1271_ps_Spell->_baseRequiredSkillLevel + L1268_i_PowerSymbolOrdinal;
-	L1273_ui_Experience = _vm->getRandomNumber(8) + (AL1269_ui_RequiredSkillLevel << 4) + ((_vm->ordinalToIndex(L1268_i_PowerSymbolOrdinal) * L1271_ps_Spell->_baseRequiredSkillLevel) << 3) + (AL1269_ui_RequiredSkillLevel * AL1269_ui_RequiredSkillLevel);
-	AL1267_ui_SkillLevel = _vm->_championMan->getSkillLevel(champIndex, L1271_ps_Spell->_skillIndex);
-	if (AL1267_ui_SkillLevel < AL1269_ui_RequiredSkillLevel) {
-		L1274_i_MissingSkillLevelCount = AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel;
-		while (L1274_i_MissingSkillLevelCount--) {
-			if (_vm->getRandomNumber(128) > MIN(L1270_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + 15, 115)) {
-				_vm->_championMan->addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience >> (AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel));
-				menusPrintSpellFailureMessage(L1270_ps_Champion, k0_failureNeedsMorePractice, L1271_ps_Spell->_skillIndex);
+	int16 powerSymbolOrdinal = curChampion->_symbols[0] - '_'; /* Values 1 to 6 */
+	uint16 requiredSkillLevel = curSpell->_baseRequiredSkillLevel + powerSymbolOrdinal;
+	uint16 experience = _vm->getRandomNumber(8) + (requiredSkillLevel << 4) + ((_vm->ordinalToIndex(powerSymbolOrdinal) * curSpell->_baseRequiredSkillLevel) << 3) + (requiredSkillLevel * requiredSkillLevel);
+	AL1267_ui_SkillLevel = _vm->_championMan->getSkillLevel(champIndex, curSpell->_skillIndex);
+	if (AL1267_ui_SkillLevel < requiredSkillLevel) {
+		int16 missingSkillLevelCount = requiredSkillLevel - AL1267_ui_SkillLevel;
+		while (missingSkillLevelCount--) {
+			if (_vm->getRandomNumber(128) > MIN(curChampion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + 15, 115)) {
+				_vm->_championMan->addSkillExperience(champIndex, curSpell->_skillIndex, experience >> (requiredSkillLevel - AL1267_ui_SkillLevel));
+				menusPrintSpellFailureMessage(curChampion, k0_failureNeedsMorePractice, curSpell->_skillIndex);
 				return k0_spellCastFailure;
 			}
 		}
 	}
-	switch (L1271_ps_Spell->getKind()) {
-	case k1_spellKindPotion:
-		if ((L1275_ps_Potion = getEmptyFlaskInHand(L1270_ps_Champion, &L1272_T_Object)) == NULL) {
-			menusPrintSpellFailureMessage(L1270_ps_Champion, k10_failureNeedsFlaskInHand, 0);
+	switch (curSpell->getKind()) {
+	case k1_spellKindPotion: {
+		Thing newObject;
+		Potion *newPotion = getEmptyFlaskInHand(curChampion, &newObject);
+		if (!newPotion) {
+			menusPrintSpellFailureMessage(curChampion, k10_failureNeedsFlaskInHand, 0);
 			return k3_spellCastFailureNeedsFlask;
 		}
-		AL1269_ui_EmptyFlaskWeight = _vm->_dungeonMan->getObjectWeight(L1272_T_Object);
-		L1275_ps_Potion->setType((PotionType)L1271_ps_Spell->getType());
-		L1275_ps_Potion->setPower(_vm->getRandomNumber(16) + (L1268_i_PowerSymbolOrdinal * 40));
-		L1270_ps_Champion->_load += _vm->_dungeonMan->getObjectWeight(L1272_T_Object) - AL1269_ui_EmptyFlaskWeight;
+		uint16 emptyFlaskWeight = _vm->_dungeonMan->getObjectWeight(newObject);
+		newPotion->setType((PotionType)curSpell->getType());
+		newPotion->setPower(_vm->getRandomNumber(16) + (powerSymbolOrdinal * 40));
+		curChampion->_load += _vm->_dungeonMan->getObjectWeight(newObject) - emptyFlaskWeight;
 		_vm->_championMan->drawChangedObjectIcons();
 		if (_vm->_inventoryMan->_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex)) {
-			setFlag(L1270_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad);
+			setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad);
 			_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 		}
+		}
 		break;
 	case k2_spellKindProjectile:
-		if (L1270_ps_Champion->_dir != _vm->_dungeonMan->_partyDir) {
-			L1270_ps_Champion->_dir = _vm->_dungeonMan->_partyDir;
-			setFlag(L1270_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon);
+		if (curChampion->_dir != _vm->_dungeonMan->_partyDir) {
+			curChampion->_dir = _vm->_dungeonMan->_partyDir;
+			setFlag(curChampion->_attributes, k0x0400_ChampionAttributeIcon);
 			_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 		}
-		if (L1271_ps_Spell->getType() == k4_spellType_projectileOpenDoor) {
+		if (curSpell->getType() == k4_spellType_projectileOpenDoor) {
 			AL1267_ui_SkillLevel <<= 1;
 		}
-		_vm->_championMan->isProjectileSpellCast(champIndex, Thing(L1271_ps_Spell->getType() + Thing::_firstExplosion.toUint16()), getBoundedValue(21, (L1268_i_PowerSymbolOrdinal + 2) * (4 + (AL1267_ui_SkillLevel << 1)), 255), 0);
+		_vm->_championMan->isProjectileSpellCast(champIndex, Thing(curSpell->getType() + Thing::_firstExplosion.toUint16()), getBoundedValue(21, (powerSymbolOrdinal + 2) * (4 + (AL1267_ui_SkillLevel << 1)), 255), 0);
 		break;
-	case k3_spellKindOther:
-		L1276_s_Event._priority = 0;
-		AL1267_ui_SpellPower = (L1268_i_PowerSymbolOrdinal + 1) << 2;
-		switch (L1271_ps_Spell->getType()) {
+	case k3_spellKindOther: {
+		TimelineEvent newEvent;
+		newEvent._priority = 0;
+		AL1267_ui_SpellPower = (powerSymbolOrdinal + 1) << 2;
+		uint16 ticks;
+		switch (curSpell->getType()) {
 		case k0_spellType_otherLight:
-			AL1269_ui_Ticks = 10000 + ((AL1267_ui_SpellPower - 8) << 9);
+			ticks = 10000 + ((AL1267_ui_SpellPower - 8) << 9);
 			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 1);
 			AL1267_ui_LightPower--;
 			goto T0412019;
 		case k5_spellType_otherMagicTorch:
-			AL1269_ui_Ticks = 2000 + ((AL1267_ui_SpellPower - 3) << 7);
+			ticks = 2000 + ((AL1267_ui_SpellPower - 3) << 7);
 			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
 			AL1267_ui_LightPower++;
 T0412019:
 			_vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[AL1267_ui_LightPower];
-			createEvent70_light(-AL1267_ui_LightPower, AL1269_ui_Ticks);
+			createEvent70_light(-AL1267_ui_LightPower, ticks);
 			break;
 		case k1_spellType_otherDarkness:
 			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
@@ -569,28 +560,28 @@ T0412019:
 			createEvent70_light(AL1267_ui_LightPower, 98);
 			break;
 		case k2_spellType_otherThievesEye:
-			L1276_s_Event._type = k73_TMEventTypeThievesEye;
+			newEvent._type = k73_TMEventTypeThievesEye;
 			_vm->_championMan->_party._event73Count_ThievesEye++;
 			AL1267_ui_SpellPower = (AL1267_ui_SpellPower >> 1);
 			goto T0412032;
 		case k3_spellType_otherInvisibility:
-			L1276_s_Event._type = k71_TMEventTypeInvisibility;
+			newEvent._type = k71_TMEventTypeInvisibility;
 			_vm->_championMan->_party._event71Count_Invisibility++;
 			goto T0412033;
 		case k4_spellType_otherPartyShield:
-			L1276_s_Event._type = k74_TMEventTypePartyShield;
-			L1276_s_Event._B._defense = AL1267_ui_SpellPower;
+			newEvent._type = k74_TMEventTypePartyShield;
+			newEvent._B._defense = AL1267_ui_SpellPower;
 			if (_vm->_championMan->_party._shieldDefense > 50) {
-				L1276_s_Event._B._defense >>= 2;
+				newEvent._B._defense >>= 2;
 			}
-			_vm->_championMan->_party._shieldDefense += L1276_s_Event._B._defense;
+			_vm->_championMan->_party._shieldDefense += newEvent._B._defense;
 			_vm->_timeline->refreshAllChampionStatusBoxes();
 			goto T0412032;
 		case k6_spellType_otherFootprints:
-			L1276_s_Event._type = k79_TMEventTypeFootprints;
+			newEvent._type = k79_TMEventTypeFootprints;
 			_vm->_championMan->_party._event79Count_Footprints++;
 			_vm->_championMan->_party._firstScentIndex = _vm->_championMan->_party._scentCount;
-			if (L1268_i_PowerSymbolOrdinal < 3) {
+			if (powerSymbolOrdinal < 3) {
 				_vm->_championMan->_party._lastScentIndex = _vm->_championMan->_party._firstScentIndex;
 			} else {
 				_vm->_championMan->_party._lastScentIndex = 0;
@@ -598,37 +589,42 @@ T0412019:
 T0412032:
 			AL1267_ui_Ticks = AL1267_ui_SpellPower * AL1267_ui_SpellPower;
 T0412033:
-			setMapAndTime(L1276_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + AL1267_ui_Ticks);
-			_vm->_timeline->addEventGetEventIndex(&L1276_s_Event);
+			setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + AL1267_ui_Ticks);
+			_vm->_timeline->addEventGetEventIndex(&newEvent);
 			break;
-		case k7_spellType_otherZokathra:
-			if ((L1272_T_Object = _vm->_dungeonMan->getUnusedThing(k10_JunkThingType)) == Thing::_none)
+		case k7_spellType_otherZokathra: {
+			Thing unusedObject = _vm->_dungeonMan->getUnusedThing(k10_JunkThingType);
+			if (unusedObject == Thing::_none)
 				break;
-			L1277_ps_Junk = (Junk *)_vm->_dungeonMan->getThingData(L1272_T_Object);
-			L1277_ps_Junk->setType(k51_JunkTypeZokathra);
+
+			Junk *junkData = (Junk *)_vm->_dungeonMan->getThingData(unusedObject);
+			junkData->setType(k51_JunkTypeZokathra);
 			ChampionSlot AL1267_ui_SlotIndex;
-			if (L1270_ps_Champion->_slots[k0_ChampionSlotReadyHand] == Thing::_none) {
+			if (curChampion->_slots[k0_ChampionSlotReadyHand] == Thing::_none)
 				AL1267_ui_SlotIndex = k0_ChampionSlotReadyHand;
-			} else {
-				if (L1270_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) {
-					AL1267_ui_SlotIndex = k1_ChampionSlotActionHand;
-				} else {
-					AL1267_ui_SlotIndex = kM1_ChampionSlotLeaderHand;
-				}
-			}
+			else if (curChampion->_slots[k1_ChampionSlotActionHand] == Thing::_none)
+				AL1267_ui_SlotIndex = k1_ChampionSlotActionHand;
+			else
+				AL1267_ui_SlotIndex = kM1_ChampionSlotLeaderHand;
+
 			if ((AL1267_ui_SlotIndex == k0_ChampionSlotReadyHand) || (AL1267_ui_SlotIndex == k1_ChampionSlotActionHand)) {
-				_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, L1272_T_Object, AL1267_ui_SlotIndex);
+				_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, unusedObject, AL1267_ui_SlotIndex);
 				_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
-			} else {
-				_vm->_moveSens->getMoveResult(L1272_T_Object, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
+			} else
+				_vm->_moveSens->getMoveResult(unusedObject, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
+
 			}
 			break;
 		case k8_spellType_otherFireshield:
-			isPartySpellOrFireShieldSuccessful(L1270_ps_Champion, false, (AL1267_ui_SpellPower * AL1267_ui_SpellPower) + 100, false);
+			isPartySpellOrFireShieldSuccessful(curChampion, false, (AL1267_ui_SpellPower * AL1267_ui_SpellPower) + 100, false);
+			break;
+		default:
+			break;
+		}
 		}
 	}
-	_vm->_championMan->addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience);
-	_vm->_championMan->disableAction(champIndex, L1271_ps_Spell->getDuration());
+	_vm->_championMan->addSkillExperience(champIndex, curSpell->_skillIndex, experience);
+	_vm->_championMan->disableAction(champIndex, curSpell->getDuration());
 	return k1_spellCastSuccess;
 }
 


Commit: 88c8fcf3028fb6a4f159cdba3c54bea95a190151
    https://github.com/scummvm/scummvm/commit/88c8fcf3028fb6a4f159cdba3c54bea95a190151
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T10:18:36+02:00

Commit Message:
DM: More rework in getChampionSpellCastResult, remove GOTOs

Changed paths:
    engines/dm/menus.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 23e1a14..99fcf43 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -473,12 +473,6 @@ int16 MenuMan::getClickOnSpellCastResult() {
 }
 
 int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
-	uint16 L1267_ui_Multiple;
-#define AL1267_ui_SkillLevel L1267_ui_Multiple
-#define AL1267_ui_LightPower L1267_ui_Multiple
-#define AL1267_ui_SpellPower L1267_ui_Multiple
-#define AL1267_ui_Ticks      L1267_ui_Multiple
-
 	if (champIndex >= _vm->_championMan->_partyChampionCount)
 		return k0_spellCastFailure;
 
@@ -494,12 +488,12 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 	int16 powerSymbolOrdinal = curChampion->_symbols[0] - '_'; /* Values 1 to 6 */
 	uint16 requiredSkillLevel = curSpell->_baseRequiredSkillLevel + powerSymbolOrdinal;
 	uint16 experience = _vm->getRandomNumber(8) + (requiredSkillLevel << 4) + ((_vm->ordinalToIndex(powerSymbolOrdinal) * curSpell->_baseRequiredSkillLevel) << 3) + (requiredSkillLevel * requiredSkillLevel);
-	AL1267_ui_SkillLevel = _vm->_championMan->getSkillLevel(champIndex, curSpell->_skillIndex);
-	if (AL1267_ui_SkillLevel < requiredSkillLevel) {
-		int16 missingSkillLevelCount = requiredSkillLevel - AL1267_ui_SkillLevel;
+	uint16 skillLevel = _vm->_championMan->getSkillLevel(champIndex, curSpell->_skillIndex);
+	if (skillLevel < requiredSkillLevel) {
+		int16 missingSkillLevelCount = requiredSkillLevel - skillLevel;
 		while (missingSkillLevelCount--) {
 			if (_vm->getRandomNumber(128) > MIN(curChampion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + 15, 115)) {
-				_vm->_championMan->addSkillExperience(champIndex, curSpell->_skillIndex, experience >> (requiredSkillLevel - AL1267_ui_SkillLevel));
+				_vm->_championMan->addSkillExperience(champIndex, curSpell->_skillIndex, experience >> (requiredSkillLevel - skillLevel));
 				menusPrintSpellFailureMessage(curChampion, k0_failureNeedsMorePractice, curSpell->_skillIndex);
 				return k0_spellCastFailure;
 			}
@@ -530,67 +524,82 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 			setFlag(curChampion->_attributes, k0x0400_ChampionAttributeIcon);
 			_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 		}
-		if (curSpell->getType() == k4_spellType_projectileOpenDoor) {
-			AL1267_ui_SkillLevel <<= 1;
-		}
-		_vm->_championMan->isProjectileSpellCast(champIndex, Thing(curSpell->getType() + Thing::_firstExplosion.toUint16()), getBoundedValue(21, (powerSymbolOrdinal + 2) * (4 + (AL1267_ui_SkillLevel << 1)), 255), 0);
+		if (curSpell->getType() == k4_spellType_projectileOpenDoor)
+			skillLevel <<= 1;
+
+		_vm->_championMan->isProjectileSpellCast(champIndex, Thing(curSpell->getType() + Thing::_firstExplosion.toUint16()), getBoundedValue(21, (powerSymbolOrdinal + 2) * (4 + (skillLevel << 1)), 255), 0);
 		break;
 	case k3_spellKindOther: {
 		TimelineEvent newEvent;
 		newEvent._priority = 0;
-		AL1267_ui_SpellPower = (powerSymbolOrdinal + 1) << 2;
+		uint16 spellPower = (powerSymbolOrdinal + 1) << 2;
 		uint16 ticks;
 		switch (curSpell->getType()) {
-		case k0_spellType_otherLight:
-			ticks = 10000 + ((AL1267_ui_SpellPower - 8) << 9);
-			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 1);
-			AL1267_ui_LightPower--;
-			goto T0412019;
-		case k5_spellType_otherMagicTorch:
-			ticks = 2000 + ((AL1267_ui_SpellPower - 3) << 7);
-			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
-			AL1267_ui_LightPower++;
-T0412019:
-			_vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[AL1267_ui_LightPower];
-			createEvent70_light(-AL1267_ui_LightPower, ticks);
+		case k0_spellType_otherLight: {
+			ticks = 10000 + ((spellPower - 8) << 9);
+			uint16 lightPower = (spellPower >> 1);
+			lightPower--;
+			_vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[lightPower];
+			createEvent70_light(-lightPower, ticks);
+			}
+			break;
+		case k5_spellType_otherMagicTorch: {
+			ticks = 2000 + ((spellPower - 3) << 7);
+			uint16 lightPower = (spellPower >> 2);
+			lightPower++;
+			_vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[lightPower];
+			createEvent70_light(-lightPower, ticks);
+			}
 			break;
-		case k1_spellType_otherDarkness:
-			AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
-			_vm->_championMan->_party._magicalLightAmount -= _vm->_championMan->_lightPowerToLightAmount[AL1267_ui_LightPower];
-			createEvent70_light(AL1267_ui_LightPower, 98);
+		case k1_spellType_otherDarkness: {
+			uint16 lightPower = (spellPower >> 2);
+			_vm->_championMan->_party._magicalLightAmount -= _vm->_championMan->_lightPowerToLightAmount[lightPower];
+			createEvent70_light(lightPower, 98);
+			}
 			break;
-		case k2_spellType_otherThievesEye:
+		case k2_spellType_otherThievesEye: {
 			newEvent._type = k73_TMEventTypeThievesEye;
 			_vm->_championMan->_party._event73Count_ThievesEye++;
-			AL1267_ui_SpellPower = (AL1267_ui_SpellPower >> 1);
-			goto T0412032;
-		case k3_spellType_otherInvisibility:
+			spellPower = (spellPower >> 1);
+			uint16 spellTicks = spellPower * spellPower;
+			setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + spellTicks);
+			_vm->_timeline->addEventGetEventIndex(&newEvent);
+			}
+			break;
+		case k3_spellType_otherInvisibility: {
 			newEvent._type = k71_TMEventTypeInvisibility;
 			_vm->_championMan->_party._event71Count_Invisibility++;
-			goto T0412033;
-		case k4_spellType_otherPartyShield:
+			uint16 spellTicks = spellPower;
+			setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + spellTicks);
+			_vm->_timeline->addEventGetEventIndex(&newEvent);
+			}
+			break;
+		case k4_spellType_otherPartyShield: {
 			newEvent._type = k74_TMEventTypePartyShield;
-			newEvent._B._defense = AL1267_ui_SpellPower;
-			if (_vm->_championMan->_party._shieldDefense > 50) {
+			newEvent._B._defense = spellPower;
+			if (_vm->_championMan->_party._shieldDefense > 50)
 				newEvent._B._defense >>= 2;
-			}
+
 			_vm->_championMan->_party._shieldDefense += newEvent._B._defense;
 			_vm->_timeline->refreshAllChampionStatusBoxes();
-			goto T0412032;
-		case k6_spellType_otherFootprints:
+			uint16 spellTicks = spellPower * spellPower;
+			setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + spellTicks);
+			_vm->_timeline->addEventGetEventIndex(&newEvent);
+			}
+			break;
+		case k6_spellType_otherFootprints: {
 			newEvent._type = k79_TMEventTypeFootprints;
 			_vm->_championMan->_party._event79Count_Footprints++;
 			_vm->_championMan->_party._firstScentIndex = _vm->_championMan->_party._scentCount;
-			if (powerSymbolOrdinal < 3) {
+			if (powerSymbolOrdinal < 3)
 				_vm->_championMan->_party._lastScentIndex = _vm->_championMan->_party._firstScentIndex;
-			} else {
+			else
 				_vm->_championMan->_party._lastScentIndex = 0;
-			}
-T0412032:
-			AL1267_ui_Ticks = AL1267_ui_SpellPower * AL1267_ui_SpellPower;
-T0412033:
-			setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + AL1267_ui_Ticks);
+
+			uint16 spellTicks = spellPower * spellPower;
+			setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + spellTicks);
 			_vm->_timeline->addEventGetEventIndex(&newEvent);
+			}
 			break;
 		case k7_spellType_otherZokathra: {
 			Thing unusedObject = _vm->_dungeonMan->getUnusedThing(k10_JunkThingType);
@@ -599,16 +608,16 @@ T0412033:
 
 			Junk *junkData = (Junk *)_vm->_dungeonMan->getThingData(unusedObject);
 			junkData->setType(k51_JunkTypeZokathra);
-			ChampionSlot AL1267_ui_SlotIndex;
+			ChampionSlot slotIndex;
 			if (curChampion->_slots[k0_ChampionSlotReadyHand] == Thing::_none)
-				AL1267_ui_SlotIndex = k0_ChampionSlotReadyHand;
+				slotIndex = k0_ChampionSlotReadyHand;
 			else if (curChampion->_slots[k1_ChampionSlotActionHand] == Thing::_none)
-				AL1267_ui_SlotIndex = k1_ChampionSlotActionHand;
+				slotIndex = k1_ChampionSlotActionHand;
 			else
-				AL1267_ui_SlotIndex = kM1_ChampionSlotLeaderHand;
+				slotIndex = kM1_ChampionSlotLeaderHand;
 
-			if ((AL1267_ui_SlotIndex == k0_ChampionSlotReadyHand) || (AL1267_ui_SlotIndex == k1_ChampionSlotActionHand)) {
-				_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, unusedObject, AL1267_ui_SlotIndex);
+			if ((slotIndex == k0_ChampionSlotReadyHand) || (slotIndex == k1_ChampionSlotActionHand)) {
+				_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, unusedObject, slotIndex);
 				_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 			} else
 				_vm->_moveSens->getMoveResult(unusedObject, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
@@ -616,7 +625,7 @@ T0412033:
 			}
 			break;
 		case k8_spellType_otherFireshield:
-			isPartySpellOrFireShieldSuccessful(curChampion, false, (AL1267_ui_SpellPower * AL1267_ui_SpellPower) + 100, false);
+			isPartySpellOrFireShieldSuccessful(curChampion, false, (spellPower * spellPower) + 100, false);
 			break;
 		default:
 			break;


Commit: 5bb8d33a1aa9efc4a21f2e8240143a197a9bef0e
    https://github.com/scummvm/scummvm/commit/5bb8d33a1aa9efc4a21f2e8240143a197a9bef0e
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T10:53:26+02:00

Commit Message:
DM: More refactoring in MenuMan

Changed paths:
    engines/dm/menus.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 99fcf43..23b1be5 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -638,7 +638,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 }
 
 Spell *MenuMan::getSpellFromSymbols(byte *symbols) {
-	static Spell G0487_as_Graphic560_Spells[25] = {
+	static Spell SpellsArray[25] = {
 		/* { Symbols, BaseRequiredSkillLevel, SkillIndex, Attributes } */
 		Spell(0x00666F00, 2, 15, 0x7843),
 		Spell(0x00667073, 1, 18, 0x4863),
@@ -668,31 +668,33 @@ Spell *MenuMan::getSpellFromSymbols(byte *symbols) {
 	};
 
 	if (*(symbols + 1)) {
-		int16 AL1262_i_BitShiftCount = 24;
-		int32 L1261_l_Symbols = 0;
-		do {
-			L1261_l_Symbols |= (long)*symbols++ << AL1262_i_BitShiftCount;
-		} while (*symbols && ((AL1262_i_BitShiftCount -= 8) >= 0));
-		Spell *L1263_ps_Spell = G0487_as_Graphic560_Spells;
-		int16 AL1262_i_SpellIndex = 25;
-		while (AL1262_i_SpellIndex--) {
-			if (L1263_ps_Spell->_symbols & 0xFF000000) { /* If byte 1 of spell is not 0 then the spell includes the power symbol */
-				if (L1261_l_Symbols == L1263_ps_Spell->_symbols) { /* Compare champion symbols, including power symbol, with spell (never used with actual spells) */
-					return L1263_ps_Spell;
-				}
-			} else {
-				if ((L1261_l_Symbols & 0x00FFFFFF) == L1263_ps_Spell->_symbols) { /* Compare champion symbols, except power symbol, with spell */
-					return L1263_ps_Spell;
+		int16 bitShiftCount = 24;
+		int32 curSymbols = 0;
+		do
+			curSymbols |= (long)*symbols++ << bitShiftCount;
+		while (*symbols && ((bitShiftCount -= 8) >= 0));
+		Spell *curSpell = SpellsArray;
+		int16 spellIndex = 25;
+		while (spellIndex--) {
+			if (curSpell->_symbols & 0xFF000000) { /* If byte 1 of spell is not 0 then the spell includes the power symbol */
+				if (curSymbols == curSpell->_symbols) { /* Compare champion symbols, including power symbol, with spell (never used with actual spells) */
+					return curSpell;
 				}
-			}
-			L1263_ps_Spell++;
+			} else if ((curSymbols & 0x00FFFFFF) == curSpell->_symbols) /* Compare champion symbols, except power symbol, with spell */
+				return curSpell;
+
+			curSpell++;
 		}
 	}
-	return NULL;
+	return nullptr;
 }
 
 void MenuMan::menusPrintSpellFailureMessage(Champion *champ, uint16 failureType, uint16 skillIndex) {
-	const char *L1264_pc_Message = nullptr;
+	const char *messagesEN[4] = {" NEEDS MORE PRACTICE WITH THIS ", " SPELL.", " MUMBLES A MEANINGLESS SPELL."," NEEDS AN EMPTY FLASK IN HAND FOR POTION."};
+	const char *messagesDE[4] = {" BRAUCHT MEHR UEBUNG MIT DIESEM ", " ZAUBERSPRUCH.",
+		" MURMELT EINEN SINNLOSEN ZAUBERSPRUCH.", " MUSS FUER DEN TRANK EINE LEERE FLASCHE BEREITHALTEN."};
+	const char *messagesFR[5] = {" DOIT PRATIQUER DAVANTAGE SON ", "ENVOUTEMENT.", " MARMONNE UNE CONJURATION IMCOMPREHENSIBLE.",
+		" DOIT AVOIR UN FLACON VIDE EN MAIN POUR LA POTION.", "EXORCISME."};
 
 	if (skillIndex > k3_ChampionSkillWizard)
 		skillIndex = (skillIndex - 4) / 4;
@@ -700,213 +702,191 @@ void MenuMan::menusPrintSpellFailureMessage(Champion *champ, uint16 failureType,
 	_vm->_textMan->printLineFeed();
 	_vm->_textMan->printMessage(k4_ColorCyan, champ->_name);
 
-	const char *messages_EN_ANY[4] = {" NEEDS MORE PRACTICE WITH THIS ", " SPELL.", " MUMBLES A MEANINGLESS SPELL."," NEEDS AN EMPTY FLASK IN HAND FOR POTION."};
-	const char *messages_DE_DEU[4] = {" BRAUCHT MEHR UEBUNG MIT DIESEM ", " ZAUBERSPRUCH.",
-		" MURMELT EINEN SINNLOSEN ZAUBERSPRUCH.", " MUSS FUER DEN TRANK EINE LEERE FLASCHE BEREITHALTEN."};
-	const char *messages_FR_FRA[5] = {" DOIT PRATIQUER DAVANTAGE SON ", "ENVOUTEMENT.", " MARMONNE UNE CONJURATION IMCOMPREHENSIBLE.",
-		" DOIT AVOIR UN FLACON VIDE EN MAIN POUR LA POTION.", "EXORCISME."};
 	const char **messages;
 	switch (_vm->getGameLanguage()) { // localized
-	default:
-	case Common::EN_ANY:
-		messages = messages_EN_ANY; break;
 	case Common::DE_DEU:
-		messages = messages_DE_DEU; break;
+		messages = messagesDE;
+		break;
 	case Common::FR_FRA:
-		messages = messages_FR_FRA; break;
+		messages = messagesFR;
+		break;
+	default:
+		messages = messagesEN;
+		break;
 	}
 
+	const char *message = nullptr;
 	switch (failureType) {
 	case k0_failureNeedsMorePractice:
 		_vm->_textMan->printMessage(k4_ColorCyan, messages[0]);
 		_vm->_textMan->printMessage(k4_ColorCyan, _vm->_championMan->_baseSkillName[skillIndex]);
 		if (_vm->getGameLanguage() != Common::FR_FRA || skillIndex == k3_ChampionSkillWizard)
-			L1264_pc_Message = messages[1];
+			message = messages[1];
 		else
-			L1264_pc_Message = messages[4];
+			message = messages[4];
 
 		break;
 	case k1_failureMeaninglessSpell:
-		L1264_pc_Message = messages[2];
+		message = messages[2];
 		break;
 	case k10_failureNeedsFlaskInHand:
-		L1264_pc_Message = messages[3];
+		message = messages[3];
 		break;
 	}
-	_vm->_textMan->printMessage(k4_ColorCyan, L1264_pc_Message);
+	_vm->_textMan->printMessage(k4_ColorCyan, message);
 }
 
 Potion *MenuMan::getEmptyFlaskInHand(Champion *champ, Thing *potionThing) {
-	Thing L1265_T_Thing;
-	int16 L1266_i_SlotIndex;
-
-	for (L1266_i_SlotIndex = k2_ChampionSlotHead; --L1266_i_SlotIndex >= k0_ChampionSlotReadyHand; ) {
-		if (((L1265_T_Thing = champ->_slots[L1266_i_SlotIndex]) != Thing::_none) && (_vm->_objectMan->getIconIndex(L1265_T_Thing) == k195_IconIndicePotionEmptyFlask)) {
-			*potionThing = L1265_T_Thing;
-			return (Potion *)_vm->_dungeonMan->getThingData(L1265_T_Thing);
+	for (int16 slotIndex = k2_ChampionSlotHead; --slotIndex >= k0_ChampionSlotReadyHand; ) {
+		Thing curThing = champ->_slots[slotIndex];
+		if ((curThing != Thing::_none) && (_vm->_objectMan->getIconIndex(curThing) == k195_IconIndicePotionEmptyFlask)) {
+			*potionThing = curThing;
+			return (Potion *)_vm->_dungeonMan->getThingData(curThing);
 		}
 	}
 	return nullptr;
 }
 
 void MenuMan::createEvent70_light(int16 lightPower, int16 ticks) {
-	TimelineEvent L1241_s_Event;
-
-	L1241_s_Event._type = k70_TMEventTypeLight;
-	L1241_s_Event._B._lightPower = lightPower;
-	setMapAndTime(L1241_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + ticks);
-	L1241_s_Event._priority = 0;
-	_vm->_timeline->addEventGetEventIndex(&L1241_s_Event);
+	TimelineEvent newEvent;
+	newEvent._type = k70_TMEventTypeLight;
+	newEvent._B._lightPower = lightPower;
+	setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + ticks);
+	newEvent._priority = 0;
+	_vm->_timeline->addEventGetEventIndex(&newEvent);
 	_vm->_inventoryMan->setDungeonViewPalette();
 }
 
 bool MenuMan::isPartySpellOrFireShieldSuccessful(Champion *champ, bool spellShield, uint16 ticks, bool useMana) {
-	bool L1239_B_IsPartySpellOrFireShieldSuccessful;
-	TimelineEvent L1240_s_Event;
-
-
-	L1239_B_IsPartySpellOrFireShieldSuccessful = true;
+	bool isPartyMagicShieldSuccessful = true;
 	if (useMana) {
-		if (champ->_currMana == 0) {
+		if (champ->_currMana == 0)
 			return false;
-		}
+
 		if (champ->_currMana < 4) {
 			ticks >>= 1;
 			champ->_currMana = 0;
-			L1239_B_IsPartySpellOrFireShieldSuccessful = false;
-		} else {
+			isPartyMagicShieldSuccessful = false;
+		} else
 			champ->_currMana -= 4;
-		}
 	}
-	L1240_s_Event._B._defense = ticks >> 5;
+	TimelineEvent newEvent;
+	newEvent._B._defense = ticks >> 5;
 	if (spellShield) {
-		L1240_s_Event._type = k77_TMEventTypeSpellShield;
-		if (_vm->_championMan->_party._spellShieldDefense > 50) {
-			L1240_s_Event._B._defense >>= 2;
-		}
-		_vm->_championMan->_party._spellShieldDefense += L1240_s_Event._B._defense;
+		newEvent._type = k77_TMEventTypeSpellShield;
+		if (_vm->_championMan->_party._spellShieldDefense > 50)
+			newEvent._B._defense >>= 2;
+
+		_vm->_championMan->_party._spellShieldDefense += newEvent._B._defense;
 	} else {
-		L1240_s_Event._type = k78_TMEventTypeFireShield;
-		if (_vm->_championMan->_party._fireShieldDefense > 50) {
-			L1240_s_Event._B._defense >>= 2;
-		}
-		_vm->_championMan->_party._fireShieldDefense += L1240_s_Event._B._defense;
+		newEvent._type = k78_TMEventTypeFireShield;
+		if (_vm->_championMan->_party._fireShieldDefense > 50)
+			newEvent._B._defense >>= 2;
+
+		_vm->_championMan->_party._fireShieldDefense += newEvent._B._defense;
 	}
-	L1240_s_Event._priority = 0;
-	setMapAndTime(L1240_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + ticks);
-	_vm->_timeline->addEventGetEventIndex(&L1240_s_Event);
+	newEvent._priority = 0;
+	setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + ticks);
+	_vm->_timeline->addEventGetEventIndex(&newEvent);
 	_vm->_timeline->refreshAllChampionStatusBoxes();
-	return L1239_B_IsPartySpellOrFireShieldSuccessful;
+
+	return isPartyMagicShieldSuccessful;
 }
 
 void MenuMan::drawAvailableSymbols(uint16 symbolStep) {
-	uint16 L1214_ui_Counter;
-	int16 L1215_i_X;
-	char L1216_c_Character;
-	char L1217_ac_String[2];
-
-	L1217_ac_String[1] = '\0';
-	L1216_c_Character = 96 + 6 * symbolStep;
-	L1215_i_X = 225;
-	for (L1214_ui_Counter = 0; L1214_ui_Counter < 6; L1214_ui_Counter++) {
-		L1217_ac_String[0] = L1216_c_Character++;
-		_vm->_textMan->printToLogicalScreen(L1215_i_X += 14, 58, k4_ColorCyan, k0_ColorBlack, L1217_ac_String);
+	char displayBuffer[2];
+	displayBuffer[1] = '\0';
+	char curCharacter = 96 + 6 * symbolStep;
+	int16 textPosX = 225;
+	for (uint16 L1214_ui_Counter = 0; L1214_ui_Counter < 6; L1214_ui_Counter++) {
+		displayBuffer[0] = curCharacter++;
+		textPosX += 14;
+		_vm->_textMan->printToLogicalScreen(textPosX, 58, k4_ColorCyan, k0_ColorBlack, displayBuffer);
 	}
 }
 
 void MenuMan::drawChampionSymbols(Champion *champ) {
-	uint16 L1218_ui_SymbolIndex;
-	int16 L1219_i_X;
-	uint16 L1220_ui_SymbolCount;
-	char L1221_ac_String[2];
-
-
-	L1220_ui_SymbolCount = strlen(champ->_symbols);
-	L1219_i_X = 232;
-	L1221_ac_String[1] = '\0';
-	for (L1218_ui_SymbolIndex = 0; L1218_ui_SymbolIndex < 4; L1218_ui_SymbolIndex++) {
-		if (L1218_ui_SymbolIndex >= L1220_ui_SymbolCount) {
-			L1221_ac_String[0] = ' ';
-		} else {
-			L1221_ac_String[0] = champ->_symbols[L1218_ui_SymbolIndex];
-		}
-		_vm->_textMan->printToLogicalScreen(L1219_i_X += 9, 70, k4_ColorCyan, k0_ColorBlack, L1221_ac_String);
+	uint16 symbolCount = strlen(champ->_symbols);
+	int16 textPosX = 232;
+	char displayBuffer[2];
+	displayBuffer[1] = '\0';
+
+	for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
+		if (symbolIndex >= symbolCount)
+			displayBuffer[0] = ' ';
+		else
+			displayBuffer[0] = champ->_symbols[symbolIndex];
+
+		textPosX += 9;
+		_vm->_textMan->printToLogicalScreen(textPosX, 70, k4_ColorCyan, k0_ColorBlack, displayBuffer);
 	}
 }
 
 void MenuMan::addChampionSymbol(int16 symbolIndex) {
-	static byte G0485_aauc_Graphic560_SymbolBaseManaCost[4][6] = {
+	static byte symbolBaseManaCost[4][6] = {
 		{1, 2, 3, 4, 5, 6},   /* Power 1 */
 		{2, 3, 4, 5, 6, 7},   /* Power 2 */
 		{4, 5, 6, 7, 7, 9},   /* Power 3 */
 		{2, 2, 3, 4, 6, 7}    /* Power 4 */
 	};
-	static byte G0486_auc_Graphic560_SymbolManaCostMultiplier[6] = {8, 12, 16, 20, 24, 28};
-
-	uint16 L1222_ui_SymbolStep;
-	uint16 L1223_ui_ManaCost;
-	uint16 L1224_ui_SymbolIndex;
-	Champion *L1225_ps_Champion;
-
-	L1225_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
-	L1222_ui_SymbolStep = L1225_ps_Champion->_symbolStep;
-	L1223_ui_ManaCost = G0485_aauc_Graphic560_SymbolBaseManaCost[L1222_ui_SymbolStep][symbolIndex];
-	if (L1222_ui_SymbolStep) {
-		L1223_ui_ManaCost = (L1223_ui_ManaCost * G0486_auc_Graphic560_SymbolManaCostMultiplier[L1224_ui_SymbolIndex = L1225_ps_Champion->_symbols[0] - 96]) >> 3;
+	static byte symbolManaCostMultiplier[6] = {8, 12, 16, 20, 24, 28};
+
+	Champion *casterChampion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
+	uint16 symbolStep = casterChampion->_symbolStep;
+	uint16 manaCost = symbolBaseManaCost[symbolStep][symbolIndex];
+	if (symbolStep) {
+		uint16 symbolIndex = casterChampion->_symbols[0] - 96;
+		manaCost = (manaCost * symbolManaCostMultiplier[symbolIndex]) >> 3;
 	}
-	if (L1223_ui_ManaCost <= L1225_ps_Champion->_currMana) {
-		L1225_ps_Champion->_currMana -= L1223_ui_ManaCost;
-		setFlag(L1225_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
-		L1225_ps_Champion->_symbols[L1222_ui_SymbolStep] = 96 + (L1222_ui_SymbolStep * 6) + symbolIndex;
-		L1225_ps_Champion->_symbols[L1222_ui_SymbolStep + 1] = '\0';
-		L1225_ps_Champion->_symbolStep = L1222_ui_SymbolStep = returnNextVal(L1222_ui_SymbolStep);
+
+	if (manaCost <= casterChampion->_currMana) {
+		casterChampion->_currMana -= manaCost;
+		setFlag(casterChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+		casterChampion->_symbols[symbolStep] = 96 + (symbolStep * 6) + symbolIndex;
+		casterChampion->_symbols[symbolStep + 1] = '\0';
+		casterChampion->_symbolStep = symbolStep = returnNextVal(symbolStep);
 		_vm->_eventMan->showMouse();
-		drawAvailableSymbols(L1222_ui_SymbolStep);
-		drawChampionSymbols(L1225_ps_Champion);
+		drawAvailableSymbols(symbolStep);
+		drawChampionSymbols(casterChampion);
 		_vm->_championMan->drawChampionState(_vm->_championMan->_magicCasterChampionIndex);
 		_vm->_eventMan->hideMouse();
 	}
 }
 
 void MenuMan::deleteChampionSymbol() {
-	int16 L1226_ui_SymbolStep;
-	Champion *L1228_ps_Champion;
-
-	L1228_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
-	if (!strlen(L1228_ps_Champion->_symbols)) {
+	Champion *casterChampion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
+	if (!strlen(casterChampion->_symbols))
 		return;
-	}
-	L1228_ps_Champion->_symbolStep = L1226_ui_SymbolStep = returnPrevVal(L1228_ps_Champion->_symbolStep);
-	L1228_ps_Champion->_symbols[L1226_ui_SymbolStep] = '\0';
+
+	int16 symbolStep = returnPrevVal(casterChampion->_symbolStep);
+	casterChampion->_symbolStep = symbolStep;
+	casterChampion->_symbols[symbolStep] = '\0';
 	_vm->_eventMan->showMouse();
-	drawAvailableSymbols(L1226_ui_SymbolStep);
-	drawChampionSymbols(L1228_ps_Champion);
+	drawAvailableSymbols(symbolStep);
+	drawChampionSymbols(casterChampion);
 	_vm->_eventMan->hideMouse();
 }
 
 bool MenuMan::didClickTriggerAction(int16 actionListIndex) {
-	uint16 L1196_ui_ChampionIndex;
-	uint16 L1197_ui_ActionIndex;
-	bool L1198_B_ClickTriggeredAction;
-	Champion *L1199_ps_Champion;
+	bool retVal = false;
 
 	if (!_vm->_championMan->_actingChampionOrdinal || (actionListIndex != -1 && (_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone)))
-		return false;
-
-	L1199_ps_Champion = &_vm->_championMan->_champions[L1196_ui_ChampionIndex = _vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)];
-	if (actionListIndex == -1) {
-		// L1198_B_ClickTriggeredAction is set to -1 since booleans are stored in int16 in the original
-		L1198_B_ClickTriggeredAction = true;
-	} else {
-		L1197_ui_ActionIndex = _actionList._actionIndices[actionListIndex];
-		L1199_ps_Champion->_actionDefense += _actionDefense[L1197_ui_ActionIndex]; /* BUG0_54 The defense modifier of an action is permanent.
-																									 Each action has an associated defense modifier value and a number of ticks while the champion cannot perform another action because the action icon is grayed out. If an action has a non zero defense modifier and a zero value for the number of ticks then the defense modifier is applied but it is never removed. This causes no issue in the original games because there are no actions in this case but it may occur in a version where data is customized. This statement should only be executed if the value for the action in G0491_auc_Graphic560_ActionDisabledTicks is not 0 otherwise the action is not disabled at the end of F0407_MENUS_IsActionPerformed and thus not enabled later in F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction where the defense modifier is also removed */
-		setFlag(L1199_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
-		L1198_B_ClickTriggeredAction = isActionPerformed(L1196_ui_ChampionIndex, L1197_ui_ActionIndex);
-		L1199_ps_Champion->_actionIndex = (ChampionAction)L1197_ui_ActionIndex;
+		return retVal;
+
+	uint16 championIndex = _vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal);
+	Champion *curChampion = &_vm->_championMan->_champions[championIndex];
+	if (actionListIndex == -1)
+		retVal = true;
+	else {
+		uint16 L1197_ui_ActionIndex = _actionList._actionIndices[actionListIndex];
+		curChampion->_actionDefense += _actionDefense[L1197_ui_ActionIndex]; /* BUG0_54 The defense modifier of an action is permanent.
+																				Each action has an associated defense modifier value and a number of ticks while the champion cannot perform another action because the action icon is grayed out. If an action has a non zero defense modifier and a zero value for the number of ticks then the defense modifier is applied but it is never removed. This causes no issue in the original games because there are no actions in this case but it may occur in a version where data is customized. This statement should only be executed if the value for the action in G0491_auc_Graphic560_ActionDisabledTicks is not 0 otherwise the action is not disabled at the end of F0407_MENUS_IsActionPerformed and thus not enabled later in F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction where the defense modifier is also removed */
+		setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+		retVal = isActionPerformed(championIndex, L1197_ui_ActionIndex);
+		curChampion->_actionIndex = (ChampionAction)L1197_ui_ActionIndex;
 	}
 	clearActingChampion();
-	return L1198_B_ClickTriggeredAction;
+	return retVal;
 }
 
 bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {


Commit: db99e8bc604301eb5b85aaeee672daf5b3e04cfb
    https://github.com/scummvm/scummvm/commit/db99e8bc604301eb5b85aaeee672daf5b3e04cfb
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T11:24:22+02:00

Commit Message:
DM: Fix original bug in MenuMan

Changed paths:
    engines/dm/menus.cpp
    engines/dm/menus.h



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 23b1be5..3498bf6 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -89,6 +89,52 @@ void MenuMan::initConstants() {
 		10, /* THROW */
 		3   /* FUSE */
 	};
+	static unsigned char actionDisabledTicks[44] = {
+		0,  /* N */
+		6,  /* BLOCK */
+		8,  /* CHOP */
+		0,  /* X */
+		6,  /* BLOW HORN */
+		3,  /* FLIP */
+		1,  /* PUNCH */
+		5,  /* KICK */
+		3,  /* WAR CRY */
+		5,  /* STAB */
+		35, /* CLIMB DOWN */
+		20, /* FREEZE LIFE */
+		4,  /* HIT */
+		6,  /* SWING */
+		10, /* STAB */
+		16, /* THRUST */
+		2,  /* JAB */
+		18, /* PARRY */
+		8,  /* HACK */
+		30, /* BERZERK */
+		42, /* FIREBALL */
+		31, /* DISPELL */
+		10, /* CONFUSE */
+		38, /* LIGHTNING */
+		9,  /* DISRUPT */
+		20, /* MELEE */
+		10, /* X */
+		16, /* INVOKE */
+		4,  /* SLASH */
+		12, /* CLEAVE */
+		20, /* BASH */
+		7,  /* STUN */
+		14, /* SHOOT */
+		30, /* SPELLSHIELD */
+		35, /* FIRESHIELD */
+		2,  /* FLUXCAGE */
+		19, /* HEAL */
+		9,  /* CALM */
+		10, /* LIGHT */
+		15, /* WINDOW */
+		22, /* SPIT */
+		10, /* BRANDISH */
+		0,  /* THROW */
+		2   /* FUSE */
+	};
 
 	_boxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
 	_boxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
@@ -96,8 +142,10 @@ void MenuMan::initConstants() {
 	_boxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea 
 	_boxSpellArea = Box(224, 319, 42, 74);
 
-	for (int i = 0; i < 40; i++)
+	for (int i = 0; i < 44; i++) {
 		_actionSkillIndex[i] = actionSkillIndex[i];
+		_actionDisabledTicks[i] = actionDisabledTicks[i];
+	}
 }
 
 MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
@@ -878,64 +926,21 @@ bool MenuMan::didClickTriggerAction(int16 actionListIndex) {
 	if (actionListIndex == -1)
 		retVal = true;
 	else {
-		uint16 L1197_ui_ActionIndex = _actionList._actionIndices[actionListIndex];
-		curChampion->_actionDefense += _actionDefense[L1197_ui_ActionIndex]; /* BUG0_54 The defense modifier of an action is permanent.
-																				Each action has an associated defense modifier value and a number of ticks while the champion cannot perform another action because the action icon is grayed out. If an action has a non zero defense modifier and a zero value for the number of ticks then the defense modifier is applied but it is never removed. This causes no issue in the original games because there are no actions in this case but it may occur in a version where data is customized. This statement should only be executed if the value for the action in G0491_auc_Graphic560_ActionDisabledTicks is not 0 otherwise the action is not disabled at the end of F0407_MENUS_IsActionPerformed and thus not enabled later in F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction where the defense modifier is also removed */
+		uint16 actionIndex = _actionList._actionIndices[actionListIndex];
+		// Fix original bug - When disabled ticks is equal to zero, increasing the defense leads
+		// to a permanent increment.
+		if (_actionDisabledTicks[actionIndex])
+			curChampion->_actionDefense += _actionDefense[actionIndex];
+
 		setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
-		retVal = isActionPerformed(championIndex, L1197_ui_ActionIndex);
-		curChampion->_actionIndex = (ChampionAction)L1197_ui_ActionIndex;
+		retVal = isActionPerformed(championIndex, actionIndex);
+		curChampion->_actionIndex = (ChampionAction)actionIndex;
 	}
 	clearActingChampion();
 	return retVal;
 }
 
 bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
-	static unsigned char G0491_auc_Graphic560_ActionDisabledTicks[44] = {
-		0,  /* N */
-		6,  /* BLOCK */
-		8,  /* CHOP */
-		0,  /* X */
-		6,  /* BLOW HORN */
-		3,  /* FLIP */
-		1,  /* PUNCH */
-		5,  /* KICK */
-		3,  /* WAR CRY */
-		5,  /* STAB */
-		35, /* CLIMB DOWN */
-		20, /* FREEZE LIFE */
-		4,  /* HIT */
-		6,  /* SWING */
-		10, /* STAB */
-		16, /* THRUST */
-		2,  /* JAB */
-		18, /* PARRY */
-		8,  /* HACK */
-		30, /* BERZERK */
-		42, /* FIREBALL */
-		31, /* DISPELL */
-		10, /* CONFUSE */
-		38, /* LIGHTNING */
-		9,  /* DISRUPT */
-		20, /* MELEE */
-		10, /* X */
-		16, /* INVOKE */
-		4,  /* SLASH */
-		12, /* CLEAVE */
-		20, /* BASH */
-		7,  /* STUN */
-		14, /* SHOOT */
-		30, /* SPELLSHIELD */
-		35, /* FIRESHIELD */
-		2,  /* FLUXCAGE */
-		19, /* HEAL */
-		9,  /* CALM */
-		10, /* LIGHT */
-		15, /* WINDOW */
-		22, /* SPIT */
-		10, /* BRANDISH */
-		0,  /* THROW */
-		2   /* FUSE */
-	};
 	static unsigned char G0494_auc_Graphic560_ActionStamina[44] = {
 		0,  /* N */
 		4,  /* BLOCK */
@@ -1071,7 +1076,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 	L1252_i_MapY = _vm->_dungeonMan->_partyMapY;
 	L1251_i_MapX += _vm->_dirIntoStepCountEast[L1247_ps_Champion->_dir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[L1247_ps_Champion->_dir];
 	_actionTargetGroupThing = _vm->_groupMan->groupGetThing(L1251_i_MapX, L1252_i_MapY);
-	L1249_ui_ActionDisabledTicks = G0491_auc_Graphic560_ActionDisabledTicks[actionIndex];
+	L1249_ui_ActionDisabledTicks = _actionDisabledTicks[actionIndex];
 	L1254_i_ActionSkillIndex = _actionSkillIndex[actionIndex];
 	L1253_i_ActionStamina = G0494_auc_Graphic560_ActionStamina[actionIndex] + _vm->getRandomNumber(2);
 	L1255_i_ActionExperienceGain = G0497_auc_Graphic560_ActionExperienceGain[actionIndex];
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index ab6e002..8e095b6 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -124,6 +124,7 @@ public:
 	Box _boxActionArea; // @ G0001_s_Graphic562_Box_ActionArea 
 	Box _boxSpellArea;
 	unsigned char _actionSkillIndex[44]; // @ G0496_auc_Graphic560_ActionSkillIndex
+	unsigned char _actionDisabledTicks[44];
 
 	void initConstants();
 };


Commit: c5f45cb301fbc8cd4f6b08cff78456339b3511b8
    https://github.com/scummvm/scummvm/commit/c5f45cb301fbc8cd4f6b08cff78456339b3511b8
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T12:07:31+02:00

Commit Message:
DM: WIP rework in isActionPerformed()

Changed paths:
    engines/dm/menus.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 3498bf6..83c033e 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -941,7 +941,7 @@ bool MenuMan::didClickTriggerAction(int16 actionListIndex) {
 }
 
 bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
-	static unsigned char G0494_auc_Graphic560_ActionStamina[44] = {
+	static unsigned char actionStaminaArray[44] = {
 		0,  /* N */
 		4,  /* BLOCK */
 		10, /* CHOP */
@@ -987,7 +987,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		0,  /* THROW */
 		2   /* FUSE */
 	};
-	static unsigned char G0497_auc_Graphic560_ActionExperienceGain[44] = {
+	static unsigned char actionExperienceGainArray[44] = {
 		0,  /* N */
 		8,  /* BLOCK */
 		10, /* CHOP */
@@ -1033,10 +1033,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		5,  /* THROW */
 		1   /* FUSE */
 	};
-	uint16 L1244_ui_Multiple;
-#define AL1244_ui_TargetSquare  L1244_ui_Multiple
-#define AL1244_ui_HealingAmount L1244_ui_Multiple
-#define AL1244_ui_ManaCost      L1244_ui_Multiple
+
 	int16 L1245_i_Multiple;
 #define AL1245_T_ExplosionThing  L1245_i_Multiple
 #define AL1245_B_ActionPerformed L1245_i_Multiple
@@ -1046,44 +1043,33 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 #define AL1246_i_StepEnergy            L1246_i_Multiple
 #define AL1246_i_HealingCapability     L1246_i_Multiple
 #define AL1246_i_Ticks                 L1246_i_Multiple
-	Champion* L1247_ps_Champion;
-	Weapon* L1248_ps_Weapon;
-	uint16 L1249_ui_ActionDisabledTicks;
 	int16 L1250_i_Multiple;
 #define AL1250_i_KineticEnergy        L1250_i_Multiple
 #define AL1250_i_ReadyHandWeaponClass L1250_i_Multiple
 #define AL1250_i_MissingHealth        L1250_i_Multiple
-#define AL1250_i_HealingAmount        L1250_i_Multiple
-	int16 L1251_i_MapX;
-	int16 L1252_i_MapY;
-	int16 L1253_i_ActionStamina;
-	int16 L1254_i_ActionSkillIndex;
-	int16 L1255_i_ActionExperienceGain;
-	WeaponInfo *L1256_ps_WeaponInfoActionHand;
-	WeaponInfo *L1257_ps_WeaponInfoReadyHand;
-	TimelineEvent L1258_s_Event;
-
-
-	if (champIndex >= _vm->_championMan->_partyChampionCount) {
+
+	if (champIndex >= _vm->_championMan->_partyChampionCount)
 		return false;
-	}
-	L1247_ps_Champion = &_vm->_championMan->_champions[champIndex];
-	L1248_ps_Weapon = (Weapon *)_vm->_dungeonMan->getThingData(L1247_ps_Champion->_slots[k1_ChampionSlotActionHand]);
-	if (!L1247_ps_Champion->_currHealth) {
+
+	Champion *curChampion = &_vm->_championMan->_champions[champIndex];
+	if (!curChampion->_currHealth)
 		return false;
-	}
-	L1251_i_MapX = _vm->_dungeonMan->_partyMapX;
-	L1252_i_MapY = _vm->_dungeonMan->_partyMapY;
-	L1251_i_MapX += _vm->_dirIntoStepCountEast[L1247_ps_Champion->_dir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[L1247_ps_Champion->_dir];
-	_actionTargetGroupThing = _vm->_groupMan->groupGetThing(L1251_i_MapX, L1252_i_MapY);
-	L1249_ui_ActionDisabledTicks = _actionDisabledTicks[actionIndex];
-	L1254_i_ActionSkillIndex = _actionSkillIndex[actionIndex];
-	L1253_i_ActionStamina = G0494_auc_Graphic560_ActionStamina[actionIndex] + _vm->getRandomNumber(2);
-	L1255_i_ActionExperienceGain = G0497_auc_Graphic560_ActionExperienceGain[actionIndex];
-	AL1244_ui_TargetSquare = _vm->_dungeonMan->getSquare(L1251_i_MapX, L1252_i_MapY).toByte();
+
+	Weapon *weaponInHand = (Weapon *)_vm->_dungeonMan->getThingData(curChampion->_slots[k1_ChampionSlotActionHand]);
+
+	int16 nextMapX = _vm->_dungeonMan->_partyMapX;
+	int16 nextMapY = _vm->_dungeonMan->_partyMapY;
+	nextMapX += _vm->_dirIntoStepCountEast[curChampion->_dir];
+	nextMapY += _vm->_dirIntoStepCountNorth[curChampion->_dir];
+	_actionTargetGroupThing = _vm->_groupMan->groupGetThing(nextMapX, nextMapY);
+	uint16 actionDisabledTicks = _actionDisabledTicks[actionIndex];
+	int16 actionSkillIndex = _actionSkillIndex[actionIndex];
+	int16 actionStamina = actionStaminaArray[actionIndex] + _vm->getRandomNumber(2);
+	int16 actionExperienceGain = actionExperienceGainArray[actionIndex];
+	uint16 targetSquare = _vm->_dungeonMan->getSquare(nextMapX, nextMapY).toByte();
 	AL1245_B_ActionPerformed = true;
-	if (((L1254_i_ActionSkillIndex >= k16_ChampionSkillFire) && (L1254_i_ActionSkillIndex <= k19_ChampionSkillWater)) || (L1254_i_ActionSkillIndex == k3_ChampionSkillWizard)) {
-		AL1246_i_RequiredManaAmount = 7 - MIN((uint16)6, _vm->_championMan->getSkillLevel(champIndex, L1254_i_ActionSkillIndex));
+	if (((actionSkillIndex >= k16_ChampionSkillFire) && (actionSkillIndex <= k19_ChampionSkillWater)) || (actionSkillIndex == k3_ChampionSkillWizard)) {
+		AL1246_i_RequiredManaAmount = 7 - MIN((uint16)6, _vm->_championMan->getSkillLevel(champIndex, actionSkillIndex));
 	}
 	switch (actionIndex) {
 	case k23_ChampionActionLightning:
@@ -1096,21 +1082,22 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		goto T0407014;
 	case k20_ChampionActionFireball:
 		AL1250_i_KineticEnergy = 150;
-		goto T0407013;
+		AL1245_T_ExplosionThing = Thing::_explFireBall.toUint16();
+		goto T0407014;
 	case k40_ChampionActionSpit:
 		AL1250_i_KineticEnergy = 250;
-T0407013:
 		AL1245_T_ExplosionThing = Thing::_explFireBall.toUint16();
 T0407014:
-		setChampionDirectionToPartyDirection(L1247_ps_Champion);
-		if (L1247_ps_Champion->_currMana < AL1246_i_RequiredManaAmount) {
-			AL1250_i_KineticEnergy = MAX(2, L1247_ps_Champion->_currMana * AL1250_i_KineticEnergy / AL1246_i_RequiredManaAmount);
-			AL1246_i_RequiredManaAmount = L1247_ps_Champion->_currMana;
-		}
-		if (!(AL1245_B_ActionPerformed = _vm->_championMan->isProjectileSpellCast(champIndex, Thing(AL1245_T_ExplosionThing), AL1250_i_KineticEnergy, AL1246_i_RequiredManaAmount))) {
-			L1255_i_ActionExperienceGain >>= 1;
+		setChampionDirectionToPartyDirection(curChampion);
+		if (curChampion->_currMana < AL1246_i_RequiredManaAmount) {
+			AL1250_i_KineticEnergy = MAX(2, curChampion->_currMana * AL1250_i_KineticEnergy / AL1246_i_RequiredManaAmount);
+			AL1246_i_RequiredManaAmount = curChampion->_currMana;
 		}
-		decrementCharges(L1247_ps_Champion);
+		AL1245_B_ActionPerformed = _vm->_championMan->isProjectileSpellCast(champIndex, Thing(AL1245_T_ExplosionThing), AL1250_i_KineticEnergy, AL1246_i_RequiredManaAmount);
+		if (!AL1245_B_ActionPerformed)
+			actionExperienceGain >>= 1;
+
+		decrementCharges(curChampion);
 		break;
 	case k30_ChampionActionBash:
 	case k18_ChampionActionHack:
@@ -1118,10 +1105,10 @@ T0407014:
 	case k7_ChampionActionKick:
 	case k13_ChampionActionSwing:
 	case k2_ChampionActionChop:
-		if ((Square(AL1244_ui_TargetSquare).getType() == k4_DoorElemType) && (Square(AL1244_ui_TargetSquare).getDoorState() == k4_doorState_CLOSED)) {
+		if ((Square(targetSquare).getType() == k4_DoorElemType) && (Square(targetSquare).getDoorState() == k4_doorState_CLOSED)) {
 			_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
-			L1249_ui_ActionDisabledTicks = 6;
-			_vm->_groupMan->groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
+			actionDisabledTicks = 6;
+			_vm->_groupMan->groupIsDoorDestoryedByAttack(nextMapX, nextMapY, _vm->_championMan->getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
 			_vm->_sound->requestPlay(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k2_soundModePlayOneTickLater);
 			break;
 		}
@@ -1136,80 +1123,92 @@ T0407014:
 	case k28_ChampionActionSlash:
 	case k29_ChampionActionCleave:
 	case k6_ChampionActionPunch:
-		if (!(AL1245_B_ActionPerformed = isMeleeActionPerformed(champIndex, L1247_ps_Champion, actionIndex, L1251_i_MapX, L1252_i_MapY, L1254_i_ActionSkillIndex))) {
-			L1255_i_ActionExperienceGain >>= 1;
-			L1249_ui_ActionDisabledTicks >>= 1;
+		if (!(AL1245_B_ActionPerformed = isMeleeActionPerformed(champIndex, curChampion, actionIndex, nextMapX, nextMapY, actionSkillIndex))) {
+			actionExperienceGain >>= 1;
+			actionDisabledTicks >>= 1;
 		}
 		break;
 	case k22_ChampionActionConfuse:
-		decrementCharges(L1247_ps_Champion);
+		decrementCharges(curChampion);
+		// No break on purpose
 	case k8_ChampionActionWarCry:
 	case k37_ChampionActionCalm:
 	case k41_ChampionActionBrandish:
 	case k4_ChampionActionBlowHorn:
-		if (actionIndex == k8_ChampionActionWarCry) {
-			_vm->_sound->requestPlay(k28_soundWAR_CRY, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
-		}
-		if (actionIndex == k4_ChampionActionBlowHorn) {
-			_vm->_sound->requestPlay(k25_soundBLOW_HORN, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
-		}
-		AL1245_B_ActionPerformed = isGroupFrightenedByAction(champIndex, actionIndex, L1251_i_MapX, L1252_i_MapY);
+		if (actionIndex == k8_ChampionActionWarCry)
+			_vm->_sound->requestPlay(k28_soundWAR_CRY, nextMapX, nextMapY, k0_soundModePlayImmediately);
+		else if (actionIndex == k4_ChampionActionBlowHorn)
+			_vm->_sound->requestPlay(k25_soundBLOW_HORN, nextMapX, nextMapY, k0_soundModePlayImmediately);
+
+		AL1245_B_ActionPerformed = isGroupFrightenedByAction(champIndex, actionIndex, nextMapX, nextMapY);
 		break;
-	case k32_ChampionActionShoot:
-		if (Thing(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]).getType() != k5_WeaponThingType)
-			goto T0407032;
-		L1256_ps_WeaponInfoActionHand = &_vm->_dungeonMan->_weaponInfos[L1248_ps_Weapon->getType()];
-		L1257_ps_WeaponInfoReadyHand = _vm->_dungeonMan->getWeaponInfo(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]);
-		AL1246_i_ActionHandWeaponClass = L1256_ps_WeaponInfoActionHand->_class;
-		AL1250_i_ReadyHandWeaponClass = L1257_ps_WeaponInfoReadyHand->_class;
+	case k32_ChampionActionShoot: {
+		if (Thing(curChampion->_slots[k0_ChampionSlotReadyHand]).getType() != k5_WeaponThingType) {
+			_actionDamage = kM2_damageNoAmmunition;
+			actionExperienceGain = 0;
+			AL1245_B_ActionPerformed = false;
+			break;
+		}
+
+		WeaponInfo *weaponInfoActionHand = &_vm->_dungeonMan->_weaponInfos[weaponInHand->getType()];
+		WeaponInfo *weaponInfoReadyHand = _vm->_dungeonMan->getWeaponInfo(curChampion->_slots[k0_ChampionSlotReadyHand]);
+		AL1246_i_ActionHandWeaponClass = weaponInfoActionHand->_class;
+		AL1250_i_ReadyHandWeaponClass = weaponInfoReadyHand->_class;
 		if ((AL1246_i_ActionHandWeaponClass >= k16_WeaponClassFirstBow) && (AL1246_i_ActionHandWeaponClass <= k31_WeaponClassLastBow)) {
-			if (AL1250_i_ReadyHandWeaponClass != k10_WeaponClassBowAmmunition)
-				goto T0407032;
+			if (AL1250_i_ReadyHandWeaponClass != k10_WeaponClassBowAmmunition) {
+				_actionDamage = kM2_damageNoAmmunition;
+				actionExperienceGain = 0;
+				AL1245_B_ActionPerformed = false;
+				break;
+			}
 			AL1246_i_StepEnergy -= k16_WeaponClassFirstBow;
-		} else {
-			if ((AL1246_i_ActionHandWeaponClass >= k32_WeaponClassFirstSling) && (AL1246_i_ActionHandWeaponClass <= k47_WeaponClassLastSling)) {
-				if (AL1250_i_ReadyHandWeaponClass != k11_WeaponClassSlingAmmunition) {
-T0407032:
-					_actionDamage = kM2_damageNoAmmunition;
-					L1255_i_ActionExperienceGain = 0;
-					AL1245_B_ActionPerformed = false;
-					break;
-				}
-				AL1246_i_StepEnergy -= k32_WeaponClassFirstSling;
+		} else if ((AL1246_i_ActionHandWeaponClass >= k32_WeaponClassFirstSling) && (AL1246_i_ActionHandWeaponClass <= k47_WeaponClassLastSling)) {
+			if (AL1250_i_ReadyHandWeaponClass != k11_WeaponClassSlingAmmunition) {
+				_actionDamage = kM2_damageNoAmmunition;
+				actionExperienceGain = 0;
+				AL1245_B_ActionPerformed = false;
+				break;
 			}
+			AL1246_i_StepEnergy -= k32_WeaponClassFirstSling;
 		}
-		setChampionDirectionToPartyDirection(L1247_ps_Champion);
-		{ // so gotos won't skip init
-			Thing AL1250_T_Object = _vm->_championMan->getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
-			_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
-			_vm->_championMan->championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy);
+
+		setChampionDirectionToPartyDirection(curChampion);
+		Thing removedObject = _vm->_championMan->getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
+		_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
+		_vm->_championMan->championShootProjectile(curChampion, removedObject, weaponInfoActionHand->_kineticEnergy + weaponInfoReadyHand->_kineticEnergy, (weaponInfoActionHand->getShootAttack() + _vm->_championMan->getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy);
 		}
 		break;
 	case k5_ChampionActionFlip: {
-		const char *messages_EN_ANY[2] = {"IT COMES UP HEADS.", "IT COMES UP TAILS."};
-		const char *messages_DE_DEU[2] = {"DIE KOPFSEITE IST OBEN.", "DIE ZAHL IST OBEN."};
-		const char *messages_FR_FRA[2] = {"C'EST FACE.", "C'EST PILE."};
+		const char *messagesEN[2] = {"IT COMES UP HEADS.", "IT COMES UP TAILS."};
+		const char *messagesDE[2] = {"DIE KOPFSEITE IST OBEN.", "DIE ZAHL IST OBEN."};
+		const char *messagesFR[2] = {"C'EST FACE.", "C'EST PILE."};
 		const char **message;
 		switch (_vm->getGameLanguage()) { // localized
 		default:
-		case Common::EN_ANY: message = messages_EN_ANY; break;
-		case Common::DE_DEU: message = messages_DE_DEU; break;
-		case Common::FR_FRA: message = messages_FR_FRA; break;
+		case Common::EN_ANY:
+			message = messagesEN;
+			break;
+		case Common::DE_DEU:
+			message = messagesDE;
+			break;
+		case Common::FR_FRA:
+			message = messagesFR;
+			break;
 		}
-		if (_vm->getRandomNumber(2)) {
+		if (_vm->getRandomNumber(2))
 			printMessageAfterReplacements(message[0]);
-		} else {
+		else
 			printMessageAfterReplacements(message[1]);
+
 		}
-	}
-								break;
+		break;
 	case k33_ChampionActionSpellshield:
 	case k34_ChampionActionFireshield:
-		if (!isPartySpellOrFireShieldSuccessful(L1247_ps_Champion, actionIndex == k33_ChampionActionSpellshield, 280, true)) {
-			L1255_i_ActionExperienceGain >>= 2;
-			L1249_ui_ActionDisabledTicks >>= 1;
+		if (!isPartySpellOrFireShieldSuccessful(curChampion, actionIndex == k33_ChampionActionSpellshield, 280, true)) {
+			actionExperienceGain >>= 2;
+			actionDisabledTicks >>= 1;
 		} else {
-			decrementCharges(L1247_ps_Champion);
+			decrementCharges(curChampion);
 		}
 		break;
 	case k27_ChampionActionInvoke:
@@ -1217,26 +1216,29 @@ T0407032:
 		switch (_vm->getRandomNumber(6)) {
 		case 0:
 			AL1245_T_ExplosionThing = Thing::_explPoisonBolt.toUint16();
-			goto T0407014;
+			break;
 		case 1:
 			AL1245_T_ExplosionThing = Thing::_explPoisonCloud.toUint16();
-			goto T0407014;
+			break;
 		case 2:
 			AL1245_T_ExplosionThing = Thing::_explHarmNonMaterial.toUint16();
-			goto T0407014;
+			break;
 		default:
-			goto T0407013;
+			AL1245_T_ExplosionThing = Thing::_explFireBall.toUint16();
+			break;
 		}
+		goto T0407014;
+
 	case k35_ChampionActionFluxcage:
-		setChampionDirectionToPartyDirection(L1247_ps_Champion);
-		_vm->_groupMan->fluxCageAction(L1251_i_MapX, L1252_i_MapY);
+		setChampionDirectionToPartyDirection(curChampion);
+		_vm->_groupMan->fluxCageAction(nextMapX, nextMapY);
 		break;
 	case k43_ChampionActionFuse:
-		setChampionDirectionToPartyDirection(L1247_ps_Champion);
-		L1251_i_MapX = _vm->_dungeonMan->_partyMapX;
-		L1252_i_MapY = _vm->_dungeonMan->_partyMapY;
-		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
-		_vm->_groupMan->fuseAction(L1251_i_MapX, L1252_i_MapY);
+		setChampionDirectionToPartyDirection(curChampion);
+		nextMapX = _vm->_dungeonMan->_partyMapX;
+		nextMapY = _vm->_dungeonMan->_partyMapY;
+		nextMapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir], nextMapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
+		_vm->_groupMan->fuseAction(nextMapX, nextMapY);
 		break;
 	case k36_ChampionActionHeal:
 		/* CHANGE2_17_IMPROVEMENT Heal action is much more effective
@@ -1244,57 +1246,64 @@ T0407032:
 		Healing amount is Min(Missing health, Min(10, Heal skill level)) * heal cycle count
 		Mana cost is 2 * heal cycle count
 		Experience gain is 2 + 2 * heal cycle count */
-		if (((AL1250_i_MissingHealth = L1247_ps_Champion->_maxHealth - L1247_ps_Champion->_currHealth) > 0) && L1247_ps_Champion->_currMana) {
+		AL1250_i_MissingHealth = curChampion->_maxHealth - curChampion->_currHealth;
+		if ((AL1250_i_MissingHealth > 0) && curChampion->_currMana) {
 			AL1246_i_HealingCapability = MIN((uint16)10, _vm->_championMan->getSkillLevel(champIndex, k13_ChampionSkillHeal));
-			L1255_i_ActionExperienceGain = 2;
+			actionExperienceGain = 2;
+			uint16 healingAmount;
 			do {
-				AL1244_ui_HealingAmount = MIN(AL1250_i_MissingHealth, AL1246_i_HealingCapability);
-				L1247_ps_Champion->_currHealth += AL1244_ui_HealingAmount;
-				L1255_i_ActionExperienceGain += 2;
-			} while (((L1247_ps_Champion->_currMana = L1247_ps_Champion->_currMana - 2) > 0) && (AL1250_i_MissingHealth = AL1250_i_MissingHealth - AL1244_ui_HealingAmount));
-			if (L1247_ps_Champion->_currMana < 0) {
-				L1247_ps_Champion->_currMana = 0;
-			}
-			setFlag(L1247_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+				healingAmount = MIN(AL1250_i_MissingHealth, AL1246_i_HealingCapability);
+				curChampion->_currHealth += healingAmount;
+				actionExperienceGain += 2;
+				curChampion->_currMana = curChampion->_currMana - 2;
+				if (curChampion->_currMana > 0)
+					AL1250_i_MissingHealth -= healingAmount;
+			} while ((curChampion->_currMana > 0) && AL1250_i_MissingHealth);
+
+			if (curChampion->_currMana < 0)
+				curChampion->_currMana = 0;
+
+			setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
 			AL1245_B_ActionPerformed = true;
 		}
 		break;
-	case k39_ChampionActionWindow:
-		AL1246_i_Ticks = _vm->getRandomNumber(_vm->_championMan->getSkillLevel(champIndex, L1254_i_ActionSkillIndex) + 8) + 5;
-		L1258_s_Event._priority = 0;
-		L1258_s_Event._type = k73_TMEventTypeThievesEye;
-		setMapAndTime(L1258_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + AL1246_i_Ticks);
-		_vm->_timeline->addEventGetEventIndex(&L1258_s_Event);
+	case k39_ChampionActionWindow: {
+		AL1246_i_Ticks = _vm->getRandomNumber(_vm->_championMan->getSkillLevel(champIndex, actionSkillIndex) + 8) + 5;
+		TimelineEvent newEvent;
+		newEvent._priority = 0;
+		newEvent._type = k73_TMEventTypeThievesEye;
+		setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + AL1246_i_Ticks);
+		_vm->_timeline->addEventGetEventIndex(&newEvent);
 		_vm->_championMan->_party._event73Count_ThievesEye++;
+		}
 		goto T0407076;
 	case k10_ChampionActionClimbDown:
-		L1251_i_MapX = _vm->_dungeonMan->_partyMapX;
-		L1252_i_MapY = _vm->_dungeonMan->_partyMapY;
-		L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir];
-		L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
+		nextMapX = _vm->_dungeonMan->_partyMapX;
+		nextMapY = _vm->_dungeonMan->_partyMapY;
+		nextMapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir];
+		nextMapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
 		/* CHANGE6_00_FIX The presence of a group over the pit is checked so that you cannot climb down a pit with the rope if there is a group levitating over it */
-		if ((_vm->_dungeonMan->getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_PitElemType) && (_vm->_groupMan->groupGetThing(L1251_i_MapX, L1252_i_MapY) == Thing::_endOfList)) {
+		if ((_vm->_dungeonMan->getSquare(nextMapX, nextMapY).getType() == k2_PitElemType) && (_vm->_groupMan->groupGetThing(nextMapX, nextMapY) == Thing::_endOfList)) {
 			/* BUG0_77 The party moves forward when using the rope in front of a closed pit. The engine does not check whether the pit is open before moving the party over the pit. This is not consistent with the behavior when using the rope in front of a corridor where nothing happens */
 			_vm->_moveSens->_useRopeToClimbDownPit = true;
-			_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, L1251_i_MapX, L1252_i_MapY);
+			_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, nextMapX, nextMapY);
 			_vm->_moveSens->_useRopeToClimbDownPit = false;
 		} else {
-			L1249_ui_ActionDisabledTicks = 0;
+			actionDisabledTicks = 0;
 		}
 		break;
 	case k11_ChampionActionFreezeLife:
-		if (L1248_ps_Weapon->getType() == k42_JunkTypeMagicalBoxBlue) {
+		if (weaponInHand->getType() == k42_JunkTypeMagicalBoxBlue) {
 			AL1246_i_Ticks = 30;
-			goto T0407071;
-		}
-		if (L1248_ps_Weapon->getType() == k43_JunkTypeMagicalBoxGreen) {
+			_vm->_championMan->getObjectRemovedFromSlot(champIndex, k1_ChampionSlotActionHand);
+			weaponInHand->setNextThing(Thing::_none);
+		} else if (weaponInHand->getType() == k43_JunkTypeMagicalBoxGreen) {
 			AL1246_i_Ticks = 125;
-T0407071:
 			_vm->_championMan->getObjectRemovedFromSlot(champIndex, k1_ChampionSlotActionHand);
-			L1248_ps_Weapon->setNextThing(Thing::_none);
+			weaponInHand->setNextThing(Thing::_none);
 		} else {
 			AL1246_i_Ticks = 70;
-			decrementCharges(L1247_ps_Champion);
+			decrementCharges(curChampion);
 		}
 		_vm->_championMan->_party._freezeLifeTicks = MIN(200, _vm->_championMan->_party._freezeLifeTicks + AL1246_i_Ticks);
 		break;
@@ -1302,23 +1311,23 @@ T0407071:
 		_vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[2];
 		createEvent70_light(-2, 2500);
 T0407076:
-		decrementCharges(L1247_ps_Champion);
+		decrementCharges(curChampion);
 		break;
 	case k42_ChampionActionThrow:
-		setChampionDirectionToPartyDirection(L1247_ps_Champion);
-		AL1245_B_ActionPerformed = _vm->_championMan->isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_partyDir)) || (L1247_ps_Champion->_cell == (ViewCell)returnOppositeDir(_vm->_dungeonMan->_partyDir)));
+		setChampionDirectionToPartyDirection(curChampion);
+		AL1245_B_ActionPerformed = _vm->_championMan->isObjectThrown(champIndex, k1_ChampionSlotActionHand, (curChampion->_cell == returnNextVal(_vm->_dungeonMan->_partyDir)) || (curChampion->_cell == (ViewCell)returnOppositeDir(_vm->_dungeonMan->_partyDir)));
 		if (AL1245_B_ActionPerformed) {
-			_vm->_timeline->_events[L1247_ps_Champion->_enableActionEventIndex]._B._slotOrdinal = _vm->indexToOrdinal(k1_ChampionSlotActionHand);
+			_vm->_timeline->_events[curChampion->_enableActionEventIndex]._B._slotOrdinal = _vm->indexToOrdinal(k1_ChampionSlotActionHand);
 		}
 	}
-	if (L1249_ui_ActionDisabledTicks) {
-		_vm->_championMan->disableAction(champIndex, L1249_ui_ActionDisabledTicks);
+	if (actionDisabledTicks) {
+		_vm->_championMan->disableAction(champIndex, actionDisabledTicks);
 	}
-	if (L1253_i_ActionStamina) {
-		_vm->_championMan->decrementStamina(champIndex, L1253_i_ActionStamina);
+	if (actionStamina) {
+		_vm->_championMan->decrementStamina(champIndex, actionStamina);
 	}
-	if (L1255_i_ActionExperienceGain) {
-		_vm->_championMan->addSkillExperience(champIndex, L1254_i_ActionSkillIndex, L1255_i_ActionExperienceGain);
+	if (actionExperienceGain) {
+		_vm->_championMan->addSkillExperience(champIndex, actionSkillIndex, actionExperienceGain);
 	}
 	_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	return AL1245_B_ActionPerformed;


Commit: f2fdc9c06f7c4985c836b1f8b9ceb191ac14f2eb
    https://github.com/scummvm/scummvm/commit/f2fdc9c06f7c4985c836b1f8b9ceb191ac14f2eb
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T13:03:32+02:00

Commit Message:
DM: Finish the rework in isActionPerformed, remove all GOTOs

Changed paths:
    engines/dm/menus.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 83c033e..8637fe4 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -1034,20 +1034,6 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		1   /* FUSE */
 	};
 
-	int16 L1245_i_Multiple;
-#define AL1245_T_ExplosionThing  L1245_i_Multiple
-#define AL1245_B_ActionPerformed L1245_i_Multiple
-	int16 L1246_i_Multiple = 0;
-#define AL1246_i_RequiredManaAmount    L1246_i_Multiple
-#define AL1246_i_ActionHandWeaponClass L1246_i_Multiple
-#define AL1246_i_StepEnergy            L1246_i_Multiple
-#define AL1246_i_HealingCapability     L1246_i_Multiple
-#define AL1246_i_Ticks                 L1246_i_Multiple
-	int16 L1250_i_Multiple;
-#define AL1250_i_KineticEnergy        L1250_i_Multiple
-#define AL1250_i_ReadyHandWeaponClass L1250_i_Multiple
-#define AL1250_i_MissingHealth        L1250_i_Multiple
-
 	if (champIndex >= _vm->_championMan->_partyChampionCount)
 		return false;
 
@@ -1067,37 +1053,35 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 	int16 actionStamina = actionStaminaArray[actionIndex] + _vm->getRandomNumber(2);
 	int16 actionExperienceGain = actionExperienceGainArray[actionIndex];
 	uint16 targetSquare = _vm->_dungeonMan->getSquare(nextMapX, nextMapY).toByte();
-	AL1245_B_ActionPerformed = true;
-	if (((actionSkillIndex >= k16_ChampionSkillFire) && (actionSkillIndex <= k19_ChampionSkillWater)) || (actionSkillIndex == k3_ChampionSkillWizard)) {
-		AL1246_i_RequiredManaAmount = 7 - MIN((uint16)6, _vm->_championMan->getSkillLevel(champIndex, actionSkillIndex));
-	}
+
+	int16 requiredManaAmount = 0;
+	if (((actionSkillIndex >= k16_ChampionSkillFire) && (actionSkillIndex <= k19_ChampionSkillWater)) || (actionSkillIndex == k3_ChampionSkillWizard))
+		requiredManaAmount = 7 - MIN<uint16>(6, _vm->_championMan->getSkillLevel(champIndex, actionSkillIndex));
+
+	bool setDirectionFl = false;
+	int16 kineticEnergy = 0;
+	Thing explosionThing = Thing::_none;
+	bool actionPerformed = true;
 	switch (actionIndex) {
 	case k23_ChampionActionLightning:
-		AL1250_i_KineticEnergy = 180;
-		AL1245_T_ExplosionThing = Thing::_explLightningBolt.toUint16();
-		goto T0407014;
+		kineticEnergy = 180;
+		explosionThing = Thing::_explLightningBolt;
+		setDirectionFl = true;
+		break;
 	case k21_ChampionActionDispel:
-		AL1250_i_KineticEnergy = 150;
-		AL1245_T_ExplosionThing = Thing::_explHarmNonMaterial.toUint16();
-		goto T0407014;
+		kineticEnergy = 150;
+		explosionThing = Thing::_explHarmNonMaterial;
+		setDirectionFl = true;
+		break;
 	case k20_ChampionActionFireball:
-		AL1250_i_KineticEnergy = 150;
-		AL1245_T_ExplosionThing = Thing::_explFireBall.toUint16();
-		goto T0407014;
+		kineticEnergy = 150;
+		explosionThing = Thing::_explFireBall;
+		setDirectionFl = true;
+		break;
 	case k40_ChampionActionSpit:
-		AL1250_i_KineticEnergy = 250;
-		AL1245_T_ExplosionThing = Thing::_explFireBall.toUint16();
-T0407014:
-		setChampionDirectionToPartyDirection(curChampion);
-		if (curChampion->_currMana < AL1246_i_RequiredManaAmount) {
-			AL1250_i_KineticEnergy = MAX(2, curChampion->_currMana * AL1250_i_KineticEnergy / AL1246_i_RequiredManaAmount);
-			AL1246_i_RequiredManaAmount = curChampion->_currMana;
-		}
-		AL1245_B_ActionPerformed = _vm->_championMan->isProjectileSpellCast(champIndex, Thing(AL1245_T_ExplosionThing), AL1250_i_KineticEnergy, AL1246_i_RequiredManaAmount);
-		if (!AL1245_B_ActionPerformed)
-			actionExperienceGain >>= 1;
-
-		decrementCharges(curChampion);
+		kineticEnergy = 250;
+		explosionThing = Thing::_explFireBall;
+		setDirectionFl = true;
 		break;
 	case k30_ChampionActionBash:
 	case k18_ChampionActionHack:
@@ -1123,7 +1107,7 @@ T0407014:
 	case k28_ChampionActionSlash:
 	case k29_ChampionActionCleave:
 	case k6_ChampionActionPunch:
-		if (!(AL1245_B_ActionPerformed = isMeleeActionPerformed(champIndex, curChampion, actionIndex, nextMapX, nextMapY, actionSkillIndex))) {
+		if (!(actionPerformed = isMeleeActionPerformed(champIndex, curChampion, actionIndex, nextMapX, nextMapY, actionSkillIndex))) {
 			actionExperienceGain >>= 1;
 			actionDisabledTicks >>= 1;
 		}
@@ -1140,42 +1124,43 @@ T0407014:
 		else if (actionIndex == k4_ChampionActionBlowHorn)
 			_vm->_sound->requestPlay(k25_soundBLOW_HORN, nextMapX, nextMapY, k0_soundModePlayImmediately);
 
-		AL1245_B_ActionPerformed = isGroupFrightenedByAction(champIndex, actionIndex, nextMapX, nextMapY);
+		actionPerformed = isGroupFrightenedByAction(champIndex, actionIndex, nextMapX, nextMapY);
 		break;
 	case k32_ChampionActionShoot: {
 		if (Thing(curChampion->_slots[k0_ChampionSlotReadyHand]).getType() != k5_WeaponThingType) {
 			_actionDamage = kM2_damageNoAmmunition;
 			actionExperienceGain = 0;
-			AL1245_B_ActionPerformed = false;
+			actionPerformed = false;
 			break;
 		}
 
 		WeaponInfo *weaponInfoActionHand = &_vm->_dungeonMan->_weaponInfos[weaponInHand->getType()];
 		WeaponInfo *weaponInfoReadyHand = _vm->_dungeonMan->getWeaponInfo(curChampion->_slots[k0_ChampionSlotReadyHand]);
-		AL1246_i_ActionHandWeaponClass = weaponInfoActionHand->_class;
-		AL1250_i_ReadyHandWeaponClass = weaponInfoReadyHand->_class;
-		if ((AL1246_i_ActionHandWeaponClass >= k16_WeaponClassFirstBow) && (AL1246_i_ActionHandWeaponClass <= k31_WeaponClassLastBow)) {
-			if (AL1250_i_ReadyHandWeaponClass != k10_WeaponClassBowAmmunition) {
+		int16 actionHandWeaponClass = weaponInfoActionHand->_class;
+		int16 readyHandWeaponClass = weaponInfoReadyHand->_class;
+		int16 stepEnergy = actionHandWeaponClass;
+		if ((actionHandWeaponClass >= k16_WeaponClassFirstBow) && (actionHandWeaponClass <= k31_WeaponClassLastBow)) {
+			if (readyHandWeaponClass != k10_WeaponClassBowAmmunition) {
 				_actionDamage = kM2_damageNoAmmunition;
 				actionExperienceGain = 0;
-				AL1245_B_ActionPerformed = false;
+				actionPerformed = false;
 				break;
 			}
-			AL1246_i_StepEnergy -= k16_WeaponClassFirstBow;
-		} else if ((AL1246_i_ActionHandWeaponClass >= k32_WeaponClassFirstSling) && (AL1246_i_ActionHandWeaponClass <= k47_WeaponClassLastSling)) {
-			if (AL1250_i_ReadyHandWeaponClass != k11_WeaponClassSlingAmmunition) {
+			stepEnergy -= k16_WeaponClassFirstBow;
+		} else if ((actionHandWeaponClass >= k32_WeaponClassFirstSling) && (actionHandWeaponClass <= k47_WeaponClassLastSling)) {
+			if (readyHandWeaponClass != k11_WeaponClassSlingAmmunition) {
 				_actionDamage = kM2_damageNoAmmunition;
 				actionExperienceGain = 0;
-				AL1245_B_ActionPerformed = false;
+				actionPerformed = false;
 				break;
 			}
-			AL1246_i_StepEnergy -= k32_WeaponClassFirstSling;
+			stepEnergy -= k32_WeaponClassFirstSling;
 		}
 
 		setChampionDirectionToPartyDirection(curChampion);
 		Thing removedObject = _vm->_championMan->getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
 		_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
-		_vm->_championMan->championShootProjectile(curChampion, removedObject, weaponInfoActionHand->_kineticEnergy + weaponInfoReadyHand->_kineticEnergy, (weaponInfoActionHand->getShootAttack() + _vm->_championMan->getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy);
+		_vm->_championMan->championShootProjectile(curChampion, removedObject, weaponInfoActionHand->_kineticEnergy + weaponInfoReadyHand->_kineticEnergy, (weaponInfoActionHand->getShootAttack() + _vm->_championMan->getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, stepEnergy);
 		}
 		break;
 	case k5_ChampionActionFlip: {
@@ -1207,27 +1192,28 @@ T0407014:
 		if (!isPartySpellOrFireShieldSuccessful(curChampion, actionIndex == k33_ChampionActionSpellshield, 280, true)) {
 			actionExperienceGain >>= 2;
 			actionDisabledTicks >>= 1;
-		} else {
+		} else
 			decrementCharges(curChampion);
-		}
+
 		break;
 	case k27_ChampionActionInvoke:
-		AL1250_i_KineticEnergy = _vm->getRandomNumber(128) + 100;
+		kineticEnergy = _vm->getRandomNumber(128) + 100;
 		switch (_vm->getRandomNumber(6)) {
 		case 0:
-			AL1245_T_ExplosionThing = Thing::_explPoisonBolt.toUint16();
+			explosionThing = Thing::_explPoisonBolt;
 			break;
 		case 1:
-			AL1245_T_ExplosionThing = Thing::_explPoisonCloud.toUint16();
+			explosionThing = Thing::_explPoisonCloud;
 			break;
 		case 2:
-			AL1245_T_ExplosionThing = Thing::_explHarmNonMaterial.toUint16();
+			explosionThing = Thing::_explHarmNonMaterial;
 			break;
 		default:
-			AL1245_T_ExplosionThing = Thing::_explFireBall.toUint16();
+			explosionThing = Thing::_explFireBall;
 			break;
 		}
-		goto T0407014;
+		setDirectionFl = true;
+		break;
 
 	case k35_ChampionActionFluxcage:
 		setChampionDirectionToPartyDirection(curChampion);
@@ -1240,43 +1226,45 @@ T0407014:
 		nextMapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir], nextMapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
 		_vm->_groupMan->fuseAction(nextMapX, nextMapY);
 		break;
-	case k36_ChampionActionHeal:
+	case k36_ChampionActionHeal: {
 		/* CHANGE2_17_IMPROVEMENT Heal action is much more effective
 		Heal cycles occur as long as the champion has missing health and enough mana. Cycle count = Min(Current Mana / 2, Missing health / Min(10, Heal skill level))
 		Healing amount is Min(Missing health, Min(10, Heal skill level)) * heal cycle count
 		Mana cost is 2 * heal cycle count
 		Experience gain is 2 + 2 * heal cycle count */
-		AL1250_i_MissingHealth = curChampion->_maxHealth - curChampion->_currHealth;
-		if ((AL1250_i_MissingHealth > 0) && curChampion->_currMana) {
-			AL1246_i_HealingCapability = MIN((uint16)10, _vm->_championMan->getSkillLevel(champIndex, k13_ChampionSkillHeal));
+		int16 missingHealth = curChampion->_maxHealth - curChampion->_currHealth;
+		if ((missingHealth > 0) && curChampion->_currMana) {
+			int16 healingCapability = MIN((uint16)10, _vm->_championMan->getSkillLevel(champIndex, k13_ChampionSkillHeal));
 			actionExperienceGain = 2;
 			uint16 healingAmount;
 			do {
-				healingAmount = MIN(AL1250_i_MissingHealth, AL1246_i_HealingCapability);
+				healingAmount = MIN(missingHealth, healingCapability);
 				curChampion->_currHealth += healingAmount;
 				actionExperienceGain += 2;
 				curChampion->_currMana = curChampion->_currMana - 2;
 				if (curChampion->_currMana > 0)
-					AL1250_i_MissingHealth -= healingAmount;
-			} while ((curChampion->_currMana > 0) && AL1250_i_MissingHealth);
+					missingHealth -= healingAmount;
+			} while ((curChampion->_currMana > 0) && missingHealth);
 
 			if (curChampion->_currMana < 0)
 				curChampion->_currMana = 0;
 
 			setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
-			AL1245_B_ActionPerformed = true;
+			actionPerformed = true;
+		}
 		}
 		break;
 	case k39_ChampionActionWindow: {
-		AL1246_i_Ticks = _vm->getRandomNumber(_vm->_championMan->getSkillLevel(champIndex, actionSkillIndex) + 8) + 5;
+		int16 windowTicks = _vm->getRandomNumber(_vm->_championMan->getSkillLevel(champIndex, actionSkillIndex) + 8) + 5;
 		TimelineEvent newEvent;
 		newEvent._priority = 0;
 		newEvent._type = k73_TMEventTypeThievesEye;
-		setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + AL1246_i_Ticks);
+		setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + windowTicks);
 		_vm->_timeline->addEventGetEventIndex(&newEvent);
 		_vm->_championMan->_party._event73Count_ThievesEye++;
+		decrementCharges(curChampion);
 		}
-		goto T0407076;
+		break;
 	case k10_ChampionActionClimbDown:
 		nextMapX = _vm->_dungeonMan->_partyMapX;
 		nextMapY = _vm->_dungeonMan->_partyMapY;
@@ -1284,7 +1272,9 @@ T0407014:
 		nextMapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
 		/* CHANGE6_00_FIX The presence of a group over the pit is checked so that you cannot climb down a pit with the rope if there is a group levitating over it */
 		if ((_vm->_dungeonMan->getSquare(nextMapX, nextMapY).getType() == k2_PitElemType) && (_vm->_groupMan->groupGetThing(nextMapX, nextMapY) == Thing::_endOfList)) {
-			/* BUG0_77 The party moves forward when using the rope in front of a closed pit. The engine does not check whether the pit is open before moving the party over the pit. This is not consistent with the behavior when using the rope in front of a corridor where nothing happens */
+			/* BUG0_77 The party moves forward when using the rope in front of a closed pit. The engine does not check whether
+			   the pit is open before moving the party over the pit. This is not consistent with the behavior when using the
+			   rope in front of a corridor where nothing happens */
 			_vm->_moveSens->_useRopeToClimbDownPit = true;
 			_vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, nextMapX, nextMapY);
 			_vm->_moveSens->_useRopeToClimbDownPit = false;
@@ -1292,45 +1282,59 @@ T0407014:
 			actionDisabledTicks = 0;
 		}
 		break;
-	case k11_ChampionActionFreezeLife:
+	case k11_ChampionActionFreezeLife: {
+		int16 freezeTicks;
 		if (weaponInHand->getType() == k42_JunkTypeMagicalBoxBlue) {
-			AL1246_i_Ticks = 30;
+			freezeTicks = 30;
 			_vm->_championMan->getObjectRemovedFromSlot(champIndex, k1_ChampionSlotActionHand);
 			weaponInHand->setNextThing(Thing::_none);
 		} else if (weaponInHand->getType() == k43_JunkTypeMagicalBoxGreen) {
-			AL1246_i_Ticks = 125;
+			freezeTicks = 125;
 			_vm->_championMan->getObjectRemovedFromSlot(champIndex, k1_ChampionSlotActionHand);
 			weaponInHand->setNextThing(Thing::_none);
 		} else {
-			AL1246_i_Ticks = 70;
+			freezeTicks = 70;
 			decrementCharges(curChampion);
 		}
-		_vm->_championMan->_party._freezeLifeTicks = MIN(200, _vm->_championMan->_party._freezeLifeTicks + AL1246_i_Ticks);
+		_vm->_championMan->_party._freezeLifeTicks = MIN(200, _vm->_championMan->_party._freezeLifeTicks + freezeTicks);
+		}
 		break;
 	case k38_ChampionActionLight:
 		_vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[2];
 		createEvent70_light(-2, 2500);
-T0407076:
 		decrementCharges(curChampion);
 		break;
 	case k42_ChampionActionThrow:
 		setChampionDirectionToPartyDirection(curChampion);
-		AL1245_B_ActionPerformed = _vm->_championMan->isObjectThrown(champIndex, k1_ChampionSlotActionHand, (curChampion->_cell == returnNextVal(_vm->_dungeonMan->_partyDir)) || (curChampion->_cell == (ViewCell)returnOppositeDir(_vm->_dungeonMan->_partyDir)));
-		if (AL1245_B_ActionPerformed) {
+		actionPerformed = _vm->_championMan->isObjectThrown(champIndex, k1_ChampionSlotActionHand, (curChampion->_cell == returnNextVal(_vm->_dungeonMan->_partyDir)) || (curChampion->_cell == (ViewCell)returnOppositeDir(_vm->_dungeonMan->_partyDir)));
+		if (actionPerformed)
 			_vm->_timeline->_events[curChampion->_enableActionEventIndex]._B._slotOrdinal = _vm->indexToOrdinal(k1_ChampionSlotActionHand);
+		break;
+	}
+
+	if (setDirectionFl) {
+		setChampionDirectionToPartyDirection(curChampion);
+		if (curChampion->_currMana < requiredManaAmount) {
+			kineticEnergy = MAX(2, curChampion->_currMana * kineticEnergy / requiredManaAmount);
+			requiredManaAmount = curChampion->_currMana;
 		}
+		actionPerformed = _vm->_championMan->isProjectileSpellCast(champIndex, explosionThing, kineticEnergy, requiredManaAmount);
+		if (!actionPerformed)
+			actionExperienceGain >>= 1;
+
+		decrementCharges(curChampion);
 	}
-	if (actionDisabledTicks) {
+	if (actionDisabledTicks)
 		_vm->_championMan->disableAction(champIndex, actionDisabledTicks);
-	}
-	if (actionStamina) {
+
+	if (actionStamina)
 		_vm->_championMan->decrementStamina(champIndex, actionStamina);
-	}
-	if (actionExperienceGain) {
+
+	if (actionExperienceGain)
 		_vm->_championMan->addSkillExperience(champIndex, actionSkillIndex, actionExperienceGain);
-	}
+
 	_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
-	return AL1245_B_ActionPerformed;
+	return actionPerformed;
 }
 
 void MenuMan::setChampionDirectionToPartyDirection(Champion *champ) {


Commit: e8f4b15af9b557627aa25135056b3b8b0da3c4d8
    https://github.com/scummvm/scummvm/commit/e8f4b15af9b557627aa25135056b3b8b0da3c4d8
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T15:44:40+02:00

Commit Message:
DM: More refactoring and renaming in MenuMan

Changed paths:
    engines/dm/menus.cpp



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 8637fe4..446c239 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -1345,24 +1345,22 @@ void MenuMan::setChampionDirectionToPartyDirection(Champion *champ) {
 }
 
 void MenuMan::decrementCharges(Champion *champ) {
-	Thing L1242_T_Thing;
-	Junk *L1243_ps_Junk;
-
-	L1243_ps_Junk = (Junk *)_vm->_dungeonMan->getThingData(L1242_T_Thing = champ->_slots[k1_ChampionSlotActionHand]);
-	switch (L1242_T_Thing.getType()) {
+	Thing slotActionThing = champ->_slots[k1_ChampionSlotActionHand];
+	Junk *slotActionData = (Junk *)_vm->_dungeonMan->getThingData(slotActionThing);
+	switch (slotActionThing.getType()) {
 	case k5_WeaponThingType:
-		if (((Weapon *)L1243_ps_Junk)->getChargeCount()) {
-			((Weapon *)L1243_ps_Junk)->setChargeCount(((Weapon *)L1243_ps_Junk)->getChargeCount() - 1);
+		if (((Weapon *)slotActionData)->getChargeCount()) {
+			((Weapon *)slotActionData)->setChargeCount(((Weapon *)slotActionData)->getChargeCount() - 1);
 		}
 		break;
 	case k6_ArmourThingType:
-		if (((Armour *)L1243_ps_Junk)->getChargeCount()) {
-			((Armour *)L1243_ps_Junk)->setChargeCount(((Armour *)L1243_ps_Junk)->getChargeCount() - 1);
+		if (((Armour *)slotActionData)->getChargeCount()) {
+			((Armour *)slotActionData)->setChargeCount(((Armour *)slotActionData)->getChargeCount() - 1);
 		}
 		break;
 	case k10_JunkThingType:
-		if (L1243_ps_Junk->getChargeCount()) {
-			L1243_ps_Junk->setChargeCount(L1243_ps_Junk->getChargeCount() - 1);
+		if (slotActionData->getChargeCount()) {
+			slotActionData->setChargeCount(slotActionData->getChargeCount() - 1);
 		}
 		break;
 	default:
@@ -1372,7 +1370,7 @@ void MenuMan::decrementCharges(Champion *champ) {
 }
 
 bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 actionIndex, int16 targetMapX, int16 targetMapY, int16 skillIndex) {
-	static unsigned char G0492_auc_Graphic560_ActionDamageFactor[44] = {
+	static unsigned char actionDamageFactorArray[44] = {
 		0,  /* N */
 		15, /* BLOCK */
 		48, /* CHOP */
@@ -1418,7 +1416,7 @@ bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 ac
 		0,  /* THROW */
 		0   /* FUSE */
 	};
-	static unsigned char G0493_auc_Graphic560_ActionHitProbability[44] = {
+	static unsigned char actionHitProbabilityArray[44] = {
 		0,  /* N */
 		22, /* BLOCK */
 		48, /* CHOP */
@@ -1465,134 +1463,122 @@ bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 ac
 		0   /* FUSE */
 	};
 
-	uint16 L1236_ui_Multiple;
-#define AL1236_ui_ChampionCell       L1236_ui_Multiple
-#define AL1236_ui_ActionDamageFactor L1236_ui_Multiple
-	uint16 L1237_ui_Multiple;
-#define AL1237_ui_Direction            L1237_ui_Multiple
-#define AL1237_ui_CellDelta            L1237_ui_Multiple
-#define AL1237_ui_ActionHitProbability L1237_ui_Multiple
-	int16 L1238_i_CreatureOrdinal;
-
 	_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 	if (_actionTargetGroupThing == Thing::_endOfList)
-		goto T0402010;
-	L1238_i_CreatureOrdinal = _vm->_groupMan->getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, AL1236_ui_ChampionCell = champ->_cell);
-	if (L1238_i_CreatureOrdinal) {
-		switch (normalizeModulo4(AL1236_ui_ChampionCell + 4 - champ->_dir)) {
+		return false;
+
+	uint16 championCell = champ->_cell;
+	int16 targetCreatureOrdinal = _vm->_groupMan->getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, championCell);
+	if (targetCreatureOrdinal) {
+		uint16 viewCell = normalizeModulo4(championCell + 4 - champ->_dir);
+		switch (viewCell) {
 		case k2_ViewCellBackRight: /* Champion is on the back right of the square and tries to attack a creature in the front right of its square */
-			AL1237_ui_CellDelta = 3;
-			goto T0402005;
 		case k3_ViewCellBackLeft: /* Champion is on the back left of the square and tries to attack a creature in the front left of its square */
-			AL1237_ui_CellDelta = 1;
-T0402005: /* Check if there is another champion in front */
-			if (_vm->_championMan->getIndexInCell(normalizeModulo4(AL1236_ui_ChampionCell + AL1237_ui_CellDelta)) != kM1_ChampionNone) {
+			uint16 cellDelta = (viewCell == k2_ViewCellBackRight) ? 3 : 1;
+			/* Check if there is another champion in front */
+			if (_vm->_championMan->getIndexInCell(normalizeModulo4(championCell + cellDelta)) != kM1_ChampionNone) {
 				_actionDamage = kM1_damageCantReach;
-				goto T0402010;
+				return false;
 			}
+			break;
 		}
+
 		if ((actionIndex == k24_ChampionActionDisrupt) && !getFlag(_vm->_dungeonMan->getCreatureAttributes(_actionTargetGroupThing), k0x0040_MaskCreatureInfo_nonMaterial))
-			goto T0402010;
-		AL1237_ui_ActionHitProbability = G0493_auc_Graphic560_ActionHitProbability[actionIndex];
-		AL1236_ui_ActionDamageFactor = G0492_auc_Graphic560_ActionDamageFactor[actionIndex];
+			return false;
+
+		uint16 actionHitProbability = actionHitProbabilityArray[actionIndex];
+		uint16 actionDamageFactor = actionDamageFactorArray[actionIndex];
 		if ((_vm->_objectMan->getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
-			setFlag(AL1237_ui_ActionHitProbability, k0x8000_hitNonMaterialCreatures);
+			setFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
 		}
-		_actionDamage = _vm->_groupMan->getMeleeActionDamage(champ, champIndex, (Group *)_vm->_dungeonMan->getThingData(_actionTargetGroupThing), _vm->ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
+		_actionDamage = _vm->_groupMan->getMeleeActionDamage(champ, champIndex, (Group *)_vm->_dungeonMan->getThingData(_actionTargetGroupThing), _vm->ordinalToIndex(targetCreatureOrdinal), targetMapX, targetMapY, actionHitProbability, actionDamageFactor, skillIndex);
 		return true;
 	}
-T0402010:
+
 	return false;
 }
 
 bool MenuMan::isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, int16 mapX, int16 mapY) {
-	int16 L1229_i_FrightAmount = 0;
-	uint16 L1230_ui_FearResistance;
-	uint16 L1231_ui_Experience = 0;
-	bool L1232_B_IsGroupFrightenedByAction;
-	Group *L1233_ps_Group;
-	CreatureInfo *L1234_ps_CreatureInfo;
-	ActiveGroup *L1235_ps_ActiveGroup;
+	bool isGroupFrightenedByAction = false;
+	if (_actionTargetGroupThing == Thing::_endOfList)
+		return isGroupFrightenedByAction;
 
+	uint16 experience = 0;
+	int16 frightAmount = 0;
 
-	L1232_B_IsGroupFrightenedByAction = false;
-	if (_actionTargetGroupThing == Thing::_endOfList)
-		goto T0401016;
 	switch (actionIndex) {
 	case k8_ChampionActionWarCry:
-		L1229_i_FrightAmount = 3;
-		L1231_ui_Experience = 12; /* War Cry gives experience in priest skill k14_ChampionSkillInfluence below. The War Cry action also has an experience gain of 7 defined in G0497_auc_Graphic560_ActionExperienceGain in the same skill (versions 1.1 and below) or in the fighter skill k7_ChampionSkillParry (versions 1.2 and above). In versions 1.2 and above, this is the only action that gives experience in two skills */
+		frightAmount = 3;
+		experience = 12; /* War Cry gives experience in priest skill k14_ChampionSkillInfluence below. The War Cry action also has an experience gain of 7 defined in G0497_auc_Graphic560_ActionExperienceGain in the same skill (versions 1.1 and below) or in the fighter skill k7_ChampionSkillParry (versions 1.2 and above). In versions 1.2 and above, this is the only action that gives experience in two skills */
 		break;
 	case k37_ChampionActionCalm:
-		L1229_i_FrightAmount = 7;
-		L1231_ui_Experience = 35;
+		frightAmount = 7;
+		experience = 35;
 		break;
 	case k41_ChampionActionBrandish:
-		L1229_i_FrightAmount = 6;
-		L1231_ui_Experience = 30;
+		frightAmount = 6;
+		experience = 30;
 		break;
 	case k4_ChampionActionBlowHorn:
-		L1229_i_FrightAmount = 6;
-		L1231_ui_Experience = 20;
+		frightAmount = 6;
+		experience = 20;
 		break;
 	case k22_ChampionActionConfuse:
-		L1229_i_FrightAmount = 12;
-		L1231_ui_Experience = 45;
+		frightAmount = 12;
+		experience = 45;
+		break;
 	}
-	L1229_i_FrightAmount += _vm->_championMan->getSkillLevel(champIndex, k14_ChampionSkillInfluence);
-	L1233_ps_Group = (Group *)_vm->_dungeonMan->getThingData(_actionTargetGroupThing);
-	L1234_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[L1233_ps_Group->_type];
-	if (((L1230_ui_FearResistance = L1234_ps_CreatureInfo->getFearResistance()) > _vm->getRandomNumber(L1229_i_FrightAmount)) || (L1230_ui_FearResistance == k15_immuneToFear)) {
-		L1231_ui_Experience >>= 1;
+	frightAmount += _vm->_championMan->getSkillLevel(champIndex, k14_ChampionSkillInfluence);
+	Group *targetGroup = (Group *)_vm->_dungeonMan->getThingData(_actionTargetGroupThing);
+	CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[targetGroup->_type];
+	uint16 fearResistance = creatureInfo->getFearResistance();
+	if ((fearResistance > _vm->getRandomNumber(frightAmount)) || (fearResistance == k15_immuneToFear)) {
+		experience >>= 1;
 	} else {
-		L1235_ps_ActiveGroup = &_vm->_groupMan->_activeGroups[L1233_ps_Group->getActiveGroupIndex()];
-		if (L1233_ps_Group->getBehaviour() == k6_behavior_ATTACK) {
-			_vm->_groupMan->stopAttacking(L1235_ps_ActiveGroup, mapX, mapY);
+		ActiveGroup *activeGroup = &_vm->_groupMan->_activeGroups[targetGroup->getActiveGroupIndex()];
+		if (targetGroup->getBehaviour() == k6_behavior_ATTACK) {
+			_vm->_groupMan->stopAttacking(activeGroup, mapX, mapY);
 			_vm->_groupMan->startWandering(mapX, mapY);
 		}
-		L1233_ps_Group->setBehaviour(k5_behavior_FLEE);
-		L1235_ps_ActiveGroup->_delayFleeingFromTarget = ((16 - L1230_ui_FearResistance) << 2) / L1234_ps_CreatureInfo->_movementTicks;
-		L1232_B_IsGroupFrightenedByAction = true;
+		targetGroup->setBehaviour(k5_behavior_FLEE);
+		activeGroup->_delayFleeingFromTarget = ((16 - fearResistance) << 2) / creatureInfo->_movementTicks;
+		isGroupFrightenedByAction = true;
 	}
-	_vm->_championMan->addSkillExperience(champIndex, k14_ChampionSkillInfluence, L1231_ui_Experience);
-T0401016:
-	return L1232_B_IsGroupFrightenedByAction;
+	_vm->_championMan->addSkillExperience(champIndex, k14_ChampionSkillInfluence, experience);
+
+	return isGroupFrightenedByAction;
 }
 
 void MenuMan::printMessageAfterReplacements(const char *str) {
-	char *L1164_pc_Character;
-	char *L1165_pc_ReplacementString;
-	char L1166_ac_OutputString[128];
-
-
-	L1164_pc_Character = L1166_ac_OutputString;
-	*L1164_pc_Character++ = '\n'; /* New line */
+	char outputString[128];
+	char *curCharacter = outputString;
+	*curCharacter++ = '\n'; /* New line */
+	char *replacementString = "";
 	do {
 		if (*str == '@') {
 			str++;
-			if (*(L1164_pc_Character - 1) != '\n') { /* New line */
-				*L1164_pc_Character++ = ' ';
-			}
-			switch (*str) {
-			case 'p': /* '@p' in the source string is replaced by the champion name followed by a space */
-				L1165_pc_ReplacementString = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._name;
-			}
-			*L1164_pc_Character = '\0';
-			strcat(L1166_ac_OutputString, L1165_pc_ReplacementString);
-			L1164_pc_Character += strlen(L1165_pc_ReplacementString);
-			*L1164_pc_Character++ = ' ';
+			if (*(curCharacter - 1) != '\n') /* New line */
+				*curCharacter++ = ' ';
+
+			if (*str == 'p') /* '@p' in the source string is replaced by the champion name followed by a space */
+				replacementString = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._name;
+
+			*curCharacter = '\0';
+			strcat(outputString, replacementString);
+			curCharacter += strlen(replacementString);
+			*curCharacter++ = ' ';
 		} else {
-			*L1164_pc_Character++ = *str;
+			*curCharacter++ = *str;
 		}
 	} while (*str++);
-	*L1164_pc_Character = '\0';
-	if (L1166_ac_OutputString[1]) { /* If the string is not empty (the first character is a new line \n) */
-		_vm->_textMan->printMessage(k4_ColorCyan, L1166_ac_OutputString);
-	}
+	*curCharacter = '\0';
+
+	if (outputString[1]) /* If the string is not empty (the first character is a new line \n) */
+		_vm->_textMan->printMessage(k4_ColorCyan, outputString);
 }
 
 void MenuMan::processCommands116To119_setActingChampion(uint16 champIndex) {
-	static ActionSet G0489_as_Graphic560_ActionSets[44] = {
+	static ActionSet actionSets[44] = {
 		/* { ActionIndices[0], ActionIndices[1], ActionIndices[2], ActionProperties[0], ActionProperties[1], Useless } */
 		ActionSet(255, 255, 255, 0x00, 0x00),
 		ActionSet(27,  43,  35, 0x00, 0x00),
@@ -1639,74 +1625,69 @@ void MenuMan::processCommands116To119_setActingChampion(uint16 champIndex) {
 		ActionSet(42, 255, 255, 0x00, 0x00),
 		ActionSet(6,  11, 255, 0x80, 0x00)
 	};
-	uint16 L1188_ui_ActionSetIndex;
-	Thing L1189_T_Thing;
-	Champion *L1190_ps_Champion;
-	ActionSet *L1191_ps_ActionSet;
-
 
-	L1190_ps_Champion = &_vm->_championMan->_champions[champIndex];
-	if (getFlag(L1190_ps_Champion->_attributes, k0x0008_ChampionAttributeDisableAction) || !L1190_ps_Champion->_currHealth) {
-		return;
-	}
-	if ((L1189_T_Thing = L1190_ps_Champion->_slots[k1_ChampionSlotActionHand]) == Thing::_none) {
-		L1188_ui_ActionSetIndex = 2; /* Actions Punch, Kick and War Cry */
-	} else if ((L1188_ui_ActionSetIndex = _vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(L1189_T_Thing)]._actionSetIndex) == 0) {
+	Champion *curChampion = &_vm->_championMan->_champions[champIndex];
+	if (getFlag(curChampion->_attributes, k0x0008_ChampionAttributeDisableAction) || !curChampion->_currHealth)
 		return;
+
+	uint16 actionSetIndex;
+	Thing slotActionThing = curChampion->_slots[k1_ChampionSlotActionHand];
+
+	if (slotActionThing == Thing::_none)
+		actionSetIndex = 2; /* Actions Punch, Kick and War Cry */
+	else {
+		actionSetIndex = _vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(slotActionThing)]._actionSetIndex;
+		if (actionSetIndex == 0)
+			return;
 	}
-	L1191_ps_ActionSet = &G0489_as_Graphic560_ActionSets[L1188_ui_ActionSetIndex];
+
+	ActionSet *actionSet = &actionSets[actionSetIndex];
 	_vm->_championMan->_actingChampionOrdinal = _vm->indexToOrdinal(champIndex);
-	setActionList(L1191_ps_ActionSet);
+	setActionList(actionSet);
 	_actionAreaContainsIcons = false;
-	setFlag(L1190_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand);
+	setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand);
 	_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	drawActionArea();
 	drawActionArea();
 }
 
 void MenuMan::setActionList(ActionSet *actionSet) {
-
-#define k0x0080_actionRequiresCharge 0x0080 // @ MASK0x0080_ACTION_REQUIRES_CHARGE 
-
-	uint16 L1169_ui_ActionListIndex;
-	uint16 L1170_ui_NextAvailableActionListIndex;
-	uint16 L1171_ui_ActionIndex;
-	uint16 L1172_ui_MinimumSkillLevel;
-
 	_actionList._actionIndices[0] = (ChampionAction)actionSet->_actionIndices[0];
 	_actionList._minimumSkillLevel[0] = 1;
-	L1170_ui_NextAvailableActionListIndex = 1;
-	for (L1169_ui_ActionListIndex = 1; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) {
-		if ((L1171_ui_ActionIndex = actionSet->_actionIndices[L1169_ui_ActionListIndex]) == k255_ChampionActionNone)
+	uint16 nextAvailableActionListIndex = 1;
+	for (uint16 idx = 1; idx < 3; idx++) {
+		uint16 actionIndex = actionSet->_actionIndices[idx];
+
+		if (actionIndex == k255_ChampionActionNone)
 			continue;
-		if (getFlag(L1172_ui_MinimumSkillLevel = actionSet->_actionProperties[L1169_ui_ActionListIndex - 1], k0x0080_actionRequiresCharge) && !getActionObjectChargeCount())
+
+		uint16 minimumSkillLevel = actionSet->_actionProperties[idx - 1];
+		if (getFlag(minimumSkillLevel, k0x0080_actionRequiresCharge) && !getActionObjectChargeCount())
 			continue;
-		clearFlag(L1172_ui_MinimumSkillLevel, k0x0080_actionRequiresCharge);
-		if (_vm->_championMan->getSkillLevel(_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal), _actionSkillIndex[L1171_ui_ActionIndex]) >= L1172_ui_MinimumSkillLevel) {
-			_actionList._actionIndices[L1170_ui_NextAvailableActionListIndex] = (ChampionAction)L1171_ui_ActionIndex;
-			_actionList._minimumSkillLevel[L1170_ui_NextAvailableActionListIndex] = L1172_ui_MinimumSkillLevel;
-			L1170_ui_NextAvailableActionListIndex++;
+
+		clearFlag(minimumSkillLevel, k0x0080_actionRequiresCharge);
+		if (_vm->_championMan->getSkillLevel(_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal), _actionSkillIndex[actionIndex]) >= minimumSkillLevel) {
+			_actionList._actionIndices[nextAvailableActionListIndex] = (ChampionAction)actionIndex;
+			_actionList._minimumSkillLevel[nextAvailableActionListIndex] = minimumSkillLevel;
+			nextAvailableActionListIndex++;
 		}
 	}
-	_actionCount = L1170_ui_NextAvailableActionListIndex;
-	for (L1169_ui_ActionListIndex = L1170_ui_NextAvailableActionListIndex; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) {
-		_actionList._actionIndices[L1169_ui_ActionListIndex] = k255_ChampionActionNone;
-	}
+	_actionCount = nextAvailableActionListIndex;
+
+	for (uint16 idx = nextAvailableActionListIndex; idx < 3; idx++)
+		_actionList._actionIndices[idx] = k255_ChampionActionNone;
 }
 
 int16 MenuMan::getActionObjectChargeCount() {
-	Thing L1167_T_Thing;
-	Junk *L1168_ps_Junk;
-
-
-	L1168_ps_Junk = (Junk *)_vm->_dungeonMan->getThingData(L1167_T_Thing = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand]);
-	switch (L1167_T_Thing.getType()) {
+	Thing slotActionThing = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand];
+	Junk *junkData = (Junk *)_vm->_dungeonMan->getThingData(slotActionThing);
+	switch (slotActionThing.getType()) {
 	case k5_WeaponThingType:
-		return ((Weapon *)L1168_ps_Junk)->getChargeCount();
+		return ((Weapon *)junkData)->getChargeCount();
 	case k6_ArmourThingType:
-		return ((Armour *)L1168_ps_Junk)->getChargeCount();
+		return ((Armour *)junkData)->getChargeCount();
 	case k10_JunkThingType:
-		return L1168_ps_Junk->getChargeCount();
+		return junkData->getChargeCount();
 	default:
 		return 1;
 	}


Commit: 9284e4c9fd6db6b95115c5f46a84644bfbec5cd7
    https://github.com/scummvm/scummvm/commit/9284e4c9fd6db6b95115c5f46a84644bfbec5cd7
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T18:29:16+02:00

Commit Message:
DM: Remove a variant of blitToScreen, refactor drawActionDamage

Changed paths:
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/menus.cpp
    engines/dm/menus.h



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 9349587..7054c34 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -834,7 +834,7 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
 	}
 }
 
-void DisplayMan::blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
+void DisplayMan::blitToBitmap(byte *srcBitmap, byte *destBitmap, const Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
 								   uint16 destByteWidth, Color transparent, int16 srcHeight, int16 destHight) {
 	uint16 srcWidth = srcByteWidth * 2;
 	uint16 destWidth = destByteWidth * 2;
@@ -1177,12 +1177,7 @@ void DisplayMan::blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color
 	blitToViewport(bitmap, actualBox, byteWidth, transparent, height);
 }
 
-void DisplayMan::blitToScreen(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height) {
-	Box actualBox(box[0], box[1], box[2], box[3]);
-	blitToScreen(bitmap, &actualBox, byteWidth, transparent, height);
-}
-
-void DisplayMan::blitToScreen(byte *bitmap, Box *box, int16 byteWidth, Color transparent, int16 height) {
+void DisplayMan::blitToScreen(byte *bitmap, const Box *box, int16 byteWidth, Color transparent, int16 height) {
 	_useByteBoxCoordinates = false;
 	blitToBitmap(bitmap, _bitmapScreen, *box, 0, 0, byteWidth, k160_byteWidthScreen, transparent, height, k200_heightScreen);
 }
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 1d1f8c4..76f08e8 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -727,15 +727,14 @@ public:
 
 	void blitToViewport(byte *bitmap, Box &box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
 	void blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
-	void blitToScreen(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
-	void blitToScreen(byte *bitmap, Box *box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
+	void blitToScreen(byte *bitmap, const Box *box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
 
 
 	/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which
 	does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters
 	match the original exactly, if need arises for heights then we'll have to retrospectively add them in old function calls*/
 	/* Expects inclusive boundaries in box */
-	void blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
+	void blitToBitmap(byte *srcBitmap, byte *destBitmap, const Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
 						   uint16 destByteWidth, Color transparent, int16 srcHeight, int16 destHight); // @ F0132_VIDEO_Blit
 	 /* Expects inclusive boundaries in box */
 	void blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 446c239..b2f159f 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -1694,89 +1694,91 @@ int16 MenuMan::getActionObjectChargeCount() {
 }
 
 void MenuMan::drawActionDamage(int16 damage) {
-	static const Box G0502_s_Graphic560_Box_ActionAreaMediumDamage = Box(242, 305, 81, 117);
-	static const Box G0503_s_Graphic560_Box_ActionAreaSmallDamage = Box(251, 292, 81, 117);
-
-	uint16 L1174_ui_Multiple;
-#define AL1174_ui_DerivedBitmapIndex L1174_ui_Multiple
-#define AL1174_ui_CharacterIndex     L1174_ui_Multiple
-	int16 L1175_i_ByteWidth;
-	int16 L1176_i_Multiple;
-#define AL1176_i_X          L1176_i_Multiple
-#define AL1176_i_PixelWidth L1176_i_Multiple
-	byte *L1177_puc_Bitmap;
-	unsigned char *L1178_puc_Multiple;
-#define AL1178_puc_String L1178_puc_Multiple
-#define AL1178_puc_Bitmap L1178_puc_Multiple
-	char L1179_ac_String[6];
-	const Box *L1180_ps_Box;
-	int16 L1643_i_Width;
+	static const Box actionAreaMediumDamage(242, 305, 81, 117);
+	static const Box actionAreaSmallDamage(251, 292, 81, 117);
 
 	_vm->_eventMan->showMouse();
 	_vm->_displayMan->_useByteBoxCoordinates = false;
 	_vm->_displayMan->fillScreenBox(_boxActionArea, k0_ColorBlack);
 	if (damage < 0) {
-		static const char *messages_EN_ANY[2] = {"CAN'T REACH", "NEED AMMO"};
-		static const char *messages_DE_DEU[2] = {"ZU WEIT WEG", "MEHR MUNITION"};
-		static const char *messages_FR_FRA[2] = {"TROP LOIN", "SANS MUNITION"};
-		static int16  pos_EN_ANY[2] = {242, 248};
-		static int16  pos_DE_DEU[2] = {242, 236};
-		static int16  pos_FR_FRA[2] = {248, 236};
+		static const char *messagesEN[2] = {"CAN'T REACH", "NEED AMMO"};
+		static const char *messagesDE[2] = {"ZU WEIT WEG", "MEHR MUNITION"};
+		static const char *messagesFR[2] = {"TROP LOIN", "SANS MUNITION"};
+		static int16 posEN[2] = {242, 248};
+		static int16 posDE[2] = {242, 236};
+		static int16 posFR[2] = {248, 236};
 		const char **message;
 		int16 *pos;
 		switch (_vm->getGameLanguage()) { // localized
+		case Common::DE_DEU:
+			message = messagesDE;
+			pos = posDE;
+			break;
+		case Common::FR_FRA:
+			message = messagesFR;
+			pos = posFR;
+			break;
 		default:
-		case Common::EN_ANY: message = messages_EN_ANY; pos = pos_EN_ANY;  break;
-		case Common::DE_DEU: message = messages_DE_DEU; pos = pos_DE_DEU; break;
-		case Common::FR_FRA: message = messages_FR_FRA; pos = pos_FR_FRA; break;
+			message = messagesEN;
+			pos = posEN;
+			break;
 		}
 
+		const char *displayString;
+		int16 textPosX;
 		if (damage == kM1_damageCantReach) {
-			AL1176_i_X = pos[0];
-			AL1178_puc_String = (byte *)message[0];
+			textPosX = pos[0];
+			displayString = message[0];
 		} else {
-			AL1176_i_X = pos[1];
-			AL1178_puc_String = (byte *)message[1];
+			textPosX = pos[1];
+			displayString = message[1];
 		}
-		_vm->_textMan->printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, (char *)AL1178_puc_String);
+		_vm->_textMan->printToLogicalScreen(textPosX, 100, k4_ColorCyan, k0_ColorBlack, displayString);
 	} else {
+		int16 byteWidth;
+		byte *blitBitmap;
+		const Box *blitBox;
+		int16 displayHeight;
 		if (damage > 40) {
-			L1180_ps_Box = &_boxActionArea3ActionMenu;
-			L1177_puc_Bitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
-			L1175_i_ByteWidth = k48_byteWidth;
-			L1643_i_Width = 45;
+			blitBox = &_boxActionArea3ActionMenu;
+			blitBitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
+			byteWidth = k48_byteWidth;
+			displayHeight = 45;
 		} else {
+			uint16 derivedBitmapIndex;
+			int16 destPixelWidth;
 			if (damage > 15) {
-				AL1174_ui_DerivedBitmapIndex = k2_DerivedBitmapDamageToCreatureMedium;
-				AL1176_i_PixelWidth = 64;
-				L1175_i_ByteWidth = k32_byteWidth;
-				L1180_ps_Box = &G0502_s_Graphic560_Box_ActionAreaMediumDamage;
+				derivedBitmapIndex = k2_DerivedBitmapDamageToCreatureMedium;
+				destPixelWidth = 64;
+				byteWidth = k32_byteWidth;
+				blitBox = &actionAreaMediumDamage;
 			} else {
-				AL1174_ui_DerivedBitmapIndex = k3_DerivedBitmapDamageToCreatureSmall;
-				AL1176_i_PixelWidth = 42;
-				L1175_i_ByteWidth = k24_byteWidth;
-				L1180_ps_Box = &G0503_s_Graphic560_Box_ActionAreaSmallDamage;
+				derivedBitmapIndex = k3_DerivedBitmapDamageToCreatureSmall;
+				destPixelWidth = 42;
+				byteWidth = k24_byteWidth;
+				blitBox = &actionAreaSmallDamage;
 			}
-			L1643_i_Width = 37;
-			if (!_vm->_displayMan->isDerivedBitmapInCache(AL1174_ui_DerivedBitmapIndex)) {
-				AL1178_puc_Bitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
-				L1177_puc_Bitmap = _vm->_displayMan->getDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
-				_vm->_displayMan->blitToBitmapShrinkWithPalChange(AL1178_puc_Bitmap, L1177_puc_Bitmap, 96, 45, AL1176_i_PixelWidth, 37, _vm->_displayMan->_palChangesNoChanges);
-				_vm->_displayMan->addDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
+			displayHeight = 37;
+			if (!_vm->_displayMan->isDerivedBitmapInCache(derivedBitmapIndex)) {
+				byte *nativeBitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
+				blitBitmap = _vm->_displayMan->getDerivedBitmap(derivedBitmapIndex);
+				_vm->_displayMan->blitToBitmapShrinkWithPalChange(nativeBitmap, blitBitmap, 96, 45, destPixelWidth, 37, _vm->_displayMan->_palChangesNoChanges);
+				_vm->_displayMan->addDerivedBitmap(derivedBitmapIndex);
 			} else {
-				L1177_puc_Bitmap = _vm->_displayMan->getDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
+				blitBitmap = _vm->_displayMan->getDerivedBitmap(derivedBitmapIndex);
 			}
 		}
-		_vm->_displayMan->blitToScreen(L1177_puc_Bitmap, (int16 *)L1180_ps_Box, L1175_i_ByteWidth, kM1_ColorNoTransparency, L1643_i_Width);
+		_vm->_displayMan->blitToScreen(blitBitmap, blitBox, byteWidth, kM1_ColorNoTransparency, displayHeight);
 		/* Convert damage value to string */
-		AL1174_ui_CharacterIndex = 5;
-		AL1176_i_X = 274;
-		L1179_ac_String[5] = '\0';
+		uint16 charIndex = 5;
+		int16 textPosX = 274;
+		char scoreString[6];
+		scoreString[5] = '\0';
 		do {
-			L1179_ac_String[--AL1174_ui_CharacterIndex] = '0' + (damage % 10);
-			AL1176_i_X -= 3;
+			scoreString[--charIndex] = '0' + (damage % 10);
+			textPosX -= 3;
 		} while (damage /= 10);
-		_vm->_textMan->printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, &L1179_ac_String[AL1174_ui_CharacterIndex]);
+		_vm->_textMan->printToLogicalScreen(textPosX, 100, k4_ColorCyan, k0_ColorBlack, &scoreString[charIndex]);
 	}
 	_vm->_eventMan->hideMouse();
 }
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 8e095b6..1123248 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -39,6 +39,7 @@ namespace DM {
 #define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
 #define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
 
+#define k0x0080_actionRequiresCharge 0x0080 // @ MASK0x0080_ACTION_REQUIRES_CHARGE 
 #define k0x8000_hitNonMaterialCreatures 0x8000 // @ MASK0x8000_HIT_NON_MATERIAL_CREATURES 
 
 class ActionList {


Commit: d663f7f7880af69990b4a7af925121b1e5544c31
    https://github.com/scummvm/scummvm/commit/d663f7f7880af69990b4a7af925121b1e5544c31
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T19:18:33+02:00

Commit Message:
DM: First pass of refactoring in sensorIsTriggeredByClickOnWall, clean pointers type in movesens

Changed paths:
    engines/dm/movesens.cpp



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 308c9e6..cd06c42 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -40,7 +40,7 @@
 
 namespace DM {
 
-MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {
+MovesensMan::MovesensMan(DMEngine *vm) : _vm(vm) {
 	_moveResultMapX = 0;
 	_moveResultMapY = 0;
 	_moveResultMapIndex = 0;
@@ -54,160 +54,150 @@ MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {
 }
 
 bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam) {
-	Thing L0750_T_ThingBeingProcessed;
-	uint16 L0751_ui_ThingType;
-	uint16 L0752_ui_Cell;
-	bool L0753_B_DoNotTriggerSensor;
-	Thing* L0754_ps_Generic;
-	Sensor* L0755_ps_Sensor;
-	int16 L0756_i_SensorEffect;
-	uint16 L0757_ui_SensorType;
-	int16 L0758_i_SensorData;
-	bool L0759_B_AtLeastOneSensorWasTriggered;
-	int16 L0760_ai_SensorCountToProcessPerCell[4];
-	Thing L0761_T_LeaderHandObject;
-	Thing L0762_T_ThingOnSquare;
-	Thing L0763_T_LastProcessedThing;
-	Thing L0764_T_SquareFirstThing;
-	Sensor* L0765_ps_Sensor;
+	bool atLeastOneSensorWasTriggered = false;
+	Thing leaderHandObject = _vm->_championMan->_leaderHandObject;
+	int16 sensorCountToProcessPerCell[4];
+	for (int16 i = k0_CellNorthWest; i < k3_CellSouthWest + 1; i++)
+		sensorCountToProcessPerCell[i] = 0;
 
+	Thing squareFirstThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+	Thing thingBeingProcessed = squareFirstThing;
+	while (thingBeingProcessed != Thing::_endOfList) {
+		ThingType thingType = thingBeingProcessed.getType();
+		if (thingType == k3_SensorThingType)
+			sensorCountToProcessPerCell[(thingBeingProcessed).getCell()]++;
+		else if (thingType >= k4_GroupThingType)
+			break;
 
-	L0759_B_AtLeastOneSensorWasTriggered = false;
-	L0761_T_LeaderHandObject = _vm->_championMan->_leaderHandObject;
-	for (L0752_ui_Cell = k0_CellNorthWest; L0752_ui_Cell < k3_CellSouthWest + 1; L0752_ui_Cell++) {
-		L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell] = 0;
-	}
-	L0764_T_SquareFirstThing = L0750_T_ThingBeingProcessed = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
-	while (L0750_T_ThingBeingProcessed != Thing::_endOfList) {
-		if ((L0751_ui_ThingType = (L0750_T_ThingBeingProcessed).getType()) == k3_SensorThingType) {
-			L0760_ai_SensorCountToProcessPerCell[(L0750_T_ThingBeingProcessed).getCell()]++;
-		} else {
-			if (L0751_ui_ThingType >= k4_GroupThingType)
-				break;
-		}
-		L0750_T_ThingBeingProcessed = _vm->_dungeonMan->getNextThing(L0750_T_ThingBeingProcessed);
+		thingBeingProcessed = _vm->_dungeonMan->getNextThing(thingBeingProcessed);
 	}
-	L0763_T_LastProcessedThing = L0750_T_ThingBeingProcessed = L0764_T_SquareFirstThing;
-	while (L0750_T_ThingBeingProcessed != Thing::_endOfList) {
-		if ((L0751_ui_ThingType = (L0750_T_ThingBeingProcessed).getType()) == k3_SensorThingType) {
-			L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell = (L0750_T_ThingBeingProcessed).getCell()]--;
-			L0755_ps_Sensor = (Sensor *)_vm->_dungeonMan->getThingData(L0750_T_ThingBeingProcessed);
-			if ((L0757_ui_SensorType = (L0755_ps_Sensor)->getType()) == k0_SensorDisabled)
+	Thing lastProcessedThing = thingBeingProcessed = squareFirstThing;
+	while (thingBeingProcessed != Thing::_endOfList) {
+		uint16 ProcessedThingType = (thingBeingProcessed).getType();
+		if (ProcessedThingType == k3_SensorThingType) {
+			int16 cellIdx = thingBeingProcessed.getCell();
+			sensorCountToProcessPerCell[cellIdx]--;
+			Sensor *currentSensor = (Sensor *)_vm->_dungeonMan->getThingData(thingBeingProcessed);
+			SensorType processedSensorType = currentSensor->getType();
+			if (processedSensorType == k0_SensorDisabled)
 				goto T0275058_ProceedToNextThing;
-			if ((_vm->_championMan->_leaderIndex == kM1_ChampionNone) && (L0757_ui_SensorType != k127_SensorWallChampionPortrait))
+			if ((_vm->_championMan->_leaderIndex == kM1_ChampionNone) && (processedSensorType != k127_SensorWallChampionPortrait))
 				goto T0275058_ProceedToNextThing;
-			if (L0752_ui_Cell != cellParam)
+			if (cellIdx != cellParam)
 				goto T0275058_ProceedToNextThing;
-			L0758_i_SensorData = L0755_ps_Sensor->getData();
-			L0756_i_SensorEffect = L0755_ps_Sensor->getAttrEffectA();
-			switch (L0757_ui_SensorType) {
+			int16 sensorData = currentSensor->getData();
+			int16 sensorEffect = currentSensor->getAttrEffectA();
+
+			bool doNotTriggerSensor;
+			switch (processedSensorType) {
 			case k1_SensorWallOrnClick:
-				L0753_B_DoNotTriggerSensor = false;
-				if (L0755_ps_Sensor->getAttrEffectA() == k3_SensorEffHold) {
+				doNotTriggerSensor = false;
+				if (currentSensor->getAttrEffectA() == k3_SensorEffHold) {
 					goto T0275058_ProceedToNextThing;
 				}
 				break;
 			case k2_SensorWallOrnClickWithAnyObj:
-				L0753_B_DoNotTriggerSensor = (_vm->_championMan->_leaderEmptyHanded != L0755_ps_Sensor->getAttrRevertEffectA());
+				doNotTriggerSensor = (_vm->_championMan->_leaderEmptyHanded != currentSensor->getAttrRevertEffectA());
 				break;
 			case k17_SensorWallOrnClickWithSpecObjRemovedSensor:
 			case k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors:
-				if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */
+				if (sensorCountToProcessPerCell[cellIdx]) /* If the sensor is not the last one of its type on the cell */
 					goto T0275058_ProceedToNextThing;
 			case k3_SensorWallOrnClickWithSpecObj:
 			case k4_SensorWallOrnClickWithSpecObjRemoved:
-				L0753_B_DoNotTriggerSensor = ((L0758_i_SensorData == _vm->_objectMan->getObjectType(L0761_T_LeaderHandObject)) == L0755_ps_Sensor->getAttrRevertEffectA());
-				if (!L0753_B_DoNotTriggerSensor && (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) {
-					if (L0763_T_LastProcessedThing == L0750_T_ThingBeingProcessed) /* If the sensor is the only one of its type on the cell */
+				doNotTriggerSensor = ((sensorData == _vm->_objectMan->getObjectType(leaderHandObject)) == currentSensor->getAttrRevertEffectA());
+				if (!doNotTriggerSensor && (processedSensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) {
+					if (lastProcessedThing == thingBeingProcessed) /* If the sensor is the only one of its type on the cell */
 						break;
-					L0765_ps_Sensor = (Sensor *)_vm->_dungeonMan->getThingData(L0763_T_LastProcessedThing);
-					L0765_ps_Sensor->setNextThing(L0755_ps_Sensor->getNextThing());
-					L0755_ps_Sensor->setNextThing(Thing::_none);
-					L0750_T_ThingBeingProcessed = L0763_T_LastProcessedThing;
+					Sensor *lastSensor = (Sensor *)_vm->_dungeonMan->getThingData(lastProcessedThing);
+					lastSensor->setNextThing(currentSensor->getNextThing());
+					currentSensor->setNextThing(Thing::_none);
+					thingBeingProcessed = lastProcessedThing;
 				}
-				if (!L0753_B_DoNotTriggerSensor && (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors)) {
-					triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
+				if (!doNotTriggerSensor && (processedSensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors)) {
+					triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
 				}
 				break;
 			case k12_SensorWallObjGeneratorRotateSensors:
-				if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */
+				if (sensorCountToProcessPerCell[cellIdx]) /* If the sensor is not the last one of its type on the cell */
 					goto T0275058_ProceedToNextThing;
-				L0753_B_DoNotTriggerSensor = !_vm->_championMan->_leaderEmptyHanded;
-				if (!L0753_B_DoNotTriggerSensor) {
-					triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
+				doNotTriggerSensor = !_vm->_championMan->_leaderEmptyHanded;
+				if (!doNotTriggerSensor) {
+					triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
 				}
 				break;
 			case k13_SensorWallSingleObjStorageRotateSensors:
 				if (_vm->_championMan->_leaderEmptyHanded) {
-					if ((L0761_T_LeaderHandObject = getObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData)) == Thing::_none)
+					if ((leaderHandObject = getObjectOfTypeInCell(mapX, mapY, cellIdx, sensorData)) == Thing::_none)
 						goto T0275058_ProceedToNextThing;
-					_vm->_dungeonMan->unlinkThingFromList(L0761_T_LeaderHandObject, Thing(0), mapX, mapY);
-					_vm->_championMan->putObjectInLeaderHand(L0761_T_LeaderHandObject, true);
+					_vm->_dungeonMan->unlinkThingFromList(leaderHandObject, Thing(0), mapX, mapY);
+					_vm->_championMan->putObjectInLeaderHand(leaderHandObject, true);
 				} else {
-					if ((_vm->_objectMan->getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (getObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData) != Thing::_none))
+					if ((_vm->_objectMan->getObjectType(leaderHandObject) != sensorData) || (getObjectOfTypeInCell(mapX, mapY, cellIdx, sensorData) != Thing::_none))
 						goto T0275058_ProceedToNextThing;
 					_vm->_championMan->getObjectRemovedFromLeaderHand();
-					_vm->_dungeonMan->linkThingToList(thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
-					L0761_T_LeaderHandObject = Thing::_none;
-				}
-				triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
-				if ((L0756_i_SensorEffect == k3_SensorEffHold) && !_vm->_championMan->_leaderEmptyHanded) {
-					L0753_B_DoNotTriggerSensor = true;
-				} else {
-					L0753_B_DoNotTriggerSensor = false;
+					_vm->_dungeonMan->linkThingToList(thingWithNewCell(leaderHandObject, cellIdx), Thing(0), mapX, mapY);
+					leaderHandObject = Thing::_none;
 				}
+				triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
+				if ((sensorEffect == k3_SensorEffHold) && !_vm->_championMan->_leaderEmptyHanded)
+					doNotTriggerSensor = true;
+				else
+					doNotTriggerSensor = false;
+
 				break;
-			case k16_SensorWallObjExchanger:
-				if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */
+			case k16_SensorWallObjExchanger: {
+				if (sensorCountToProcessPerCell[cellIdx]) /* If the sensor is not the last one of its type on the cell */
 					goto T0275058_ProceedToNextThing;
-				L0762_T_ThingOnSquare = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
-				if ((_vm->_objectMan->getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (L0762_T_ThingOnSquare == Thing::_none))
+				Thing thingOnSquare = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
+				if ((_vm->_objectMan->getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_none))
 					goto T0275058_ProceedToNextThing;
-				_vm->_dungeonMan->unlinkThingFromList(L0762_T_ThingOnSquare, Thing(0), mapX, mapY);
+				_vm->_dungeonMan->unlinkThingFromList(thingOnSquare, Thing(0), mapX, mapY);
 				_vm->_championMan->getObjectRemovedFromLeaderHand();
-				_vm->_dungeonMan->linkThingToList(thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
-				_vm->_championMan->putObjectInLeaderHand(L0762_T_ThingOnSquare, true);
-				L0753_B_DoNotTriggerSensor = false;
+				_vm->_dungeonMan->linkThingToList(thingWithNewCell(leaderHandObject, cellIdx), Thing(0), mapX, mapY);
+				_vm->_championMan->putObjectInLeaderHand(thingOnSquare, true);
+				doNotTriggerSensor = false;
+				}
 				break;
 			case k127_SensorWallChampionPortrait:
-				_vm->_championMan->addCandidateChampionToParty(L0758_i_SensorData);
+				_vm->_championMan->addCandidateChampionToParty(sensorData);
 				goto T0275058_ProceedToNextThing;
 			default:
 				goto T0275058_ProceedToNextThing;
 			}
-			if (L0756_i_SensorEffect == k3_SensorEffHold) {
-				L0756_i_SensorEffect = L0753_B_DoNotTriggerSensor ? k1_SensorEffClear : k0_SensorEffSet;
-				L0753_B_DoNotTriggerSensor = false;
+
+			if (sensorEffect == k3_SensorEffHold) {
+				sensorEffect = doNotTriggerSensor ? k1_SensorEffClear : k0_SensorEffSet;
+				doNotTriggerSensor = false;
 			}
-			if (!L0753_B_DoNotTriggerSensor) {
-				L0759_B_AtLeastOneSensorWasTriggered = true;
-				if (L0755_ps_Sensor->getAttrAudibleA()) {
+			if (!doNotTriggerSensor) {
+				atLeastOneSensorWasTriggered = true;
+				if (currentSensor->getAttrAudibleA())
 					_vm->_sound->requestPlay(k01_soundSWITCH, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
-				}
-				if (!_vm->_championMan->_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
-					L0754_ps_Generic = (Thing *)_vm->_dungeonMan->getThingData(L0761_T_LeaderHandObject);
-					*L0754_ps_Generic = Thing::_none;
+
+				if (!_vm->_championMan->_leaderEmptyHanded && ((processedSensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (processedSensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (processedSensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
+					Thing *leaderThing = (Thing *)_vm->_dungeonMan->getThingData(leaderHandObject);
+					*leaderThing = Thing::_none;
 					_vm->_championMan->getObjectRemovedFromLeaderHand();
-					L0761_T_LeaderHandObject = Thing::_none;
-				} else {
-					if (_vm->_championMan->_leaderEmptyHanded &&
-						(L0757_ui_SensorType == k12_SensorWallObjGeneratorRotateSensors) &&
-						((L0761_T_LeaderHandObject = _vm->_dungeonMan->getObjForProjectileLaucherOrObjGen(L0758_i_SensorData)) != Thing::_none)) {
-						_vm->_championMan->putObjectInLeaderHand(L0761_T_LeaderHandObject, true);
-					}
+					leaderHandObject = Thing::_none;
+				} else if (_vm->_championMan->_leaderEmptyHanded
+					&& (processedSensorType == k12_SensorWallObjGeneratorRotateSensors)) {
+					leaderHandObject = _vm->_dungeonMan->getObjForProjectileLaucherOrObjGen(sensorData);
+					if (leaderHandObject != Thing::_none)
+						_vm->_championMan->putObjectInLeaderHand(leaderHandObject, true);
 				}
-				triggerEffect(L0755_ps_Sensor, L0756_i_SensorEffect, mapX, mapY, L0752_ui_Cell);
+				triggerEffect(currentSensor, sensorEffect, mapX, mapY, cellIdx);
 			}
 			goto T0275058_ProceedToNextThing;
 		}
-		if (L0751_ui_ThingType >= k4_GroupThingType)
+		if (ProcessedThingType >= k4_GroupThingType)
 			break;
 T0275058_ProceedToNextThing:
-		L0763_T_LastProcessedThing = L0750_T_ThingBeingProcessed;
-		L0750_T_ThingBeingProcessed = _vm->_dungeonMan->getNextThing(L0750_T_ThingBeingProcessed);
+		lastProcessedThing = thingBeingProcessed;
+		thingBeingProcessed = _vm->_dungeonMan->getNextThing(thingBeingProcessed);
 	}
 	processRotationEffect();
-	return L0759_B_AtLeastOneSensorWasTriggered;
+	return atLeastOneSensorWasTriggered;
 }
 
 bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destMapX, int16 destMapY) {
@@ -219,8 +209,8 @@ bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destM
 #define AL0709_i_DestinationSquareType L0709_i_Multiple
 #define AL0709_i_ChampionIndex         L0709_i_Multiple
 	int16 L0710_i_ThingType;
-	Champion* L0711_ps_Champion;
-	Teleporter* L0712_ps_Teleporter;
+	Champion *L0711_ps_Champion;
+	Teleporter *L0712_ps_Teleporter;
 	int16 L0718_i_RequiredTeleporterScope;
 	// Strangerke: Only present in v2.1, but it fixes a bug, so I propose to keep it
 	int16 L0719_i_TraversedPitCount;
@@ -548,7 +538,7 @@ bool MovesensMan::moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMapY, i
 #define AL0700_B_CreatureAlive      L0700_i_Multiple
 #define AL0700_i_Distance           L0700_i_Multiple
 #define AL0700_i_SecondaryDirection L0700_i_Multiple
-	Group* L0701_ps_Group;
+	Group *L0701_ps_Group;
 	int16 L0702_i_ImpactType;
 	bool L0703_B_CheckDestinationSquareProjectileImpacts;
 	uint16 L0704_ui_ProjectileMapX;
@@ -690,11 +680,11 @@ int16 MovesensMan::getSound(byte creatureType) {
 	return -1000; // if this is returned, it's an error, this should break it good
 }
 
-int16 MovesensMan::getTeleporterRotatedGroupResult(Teleporter* teleporter, Thing thing, uint16 mapIndex) {
+int16 MovesensMan::getTeleporterRotatedGroupResult(Teleporter *teleporter, Thing thing, uint16 mapIndex) {
 	int16 L0683_i_Rotation;
 	uint16 L0684_ui_GroupDirections;
 	uint16 L0685_ui_UpdatedGroupDirections;
-	Group* L0686_ps_Group;
+	Group *L0686_ps_Group;
 	uint16 L0687_ui_UpdatedGroupCells;
 	int16 L0688_i_CreatureIndex;
 	bool L0689_B_AbsoluteRotation;
@@ -740,7 +730,7 @@ int16 MovesensMan::getTeleporterRotatedGroupResult(Teleporter* teleporter, Thing
 	return 1;
 }
 
-Thing MovesensMan::getTeleporterRotatedProjectileThing(Teleporter* teleporter, Thing projectileThing) {
+Thing MovesensMan::getTeleporterRotatedProjectileThing(Teleporter *teleporter, Thing projectileThing) {
 	int16 L0693_i_UpdatedDirection;
 	int16 L0694_i_Rotation;
 
@@ -760,7 +750,7 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 	Thing L0766_T_Thing;
 	int16 L0767_i_ThingType;
 	bool L0768_B_TriggerSensor;
-	Sensor* L0769_ps_Sensor;
+	Sensor *L0769_ps_Sensor;
 	int16 L0770_ui_SensorTriggeredCell;
 	uint16 L0771_ui_ThingType;
 	bool L0772_B_SquareContainsObject;
@@ -929,11 +919,11 @@ bool MovesensMan::isObjcetInPartyPossession(int16 objectType) {
 	int16 L0742_i_ChampionIndex;
 	uint16 L0743_ui_SlotIndex = 0;
 	Thing L0744_T_Thing = Thing::_none;
-	Champion* L0745_ps_Champion;
-	Thing* L0746_pT_Thing = nullptr;
+	Champion *L0745_ps_Champion;
+	Thing *L0746_pT_Thing = nullptr;
 	int16 L0747_i_ObjectType;
 	bool L0748_B_LeaderHandObjectProcessed;
-	Container* L0749_ps_Container;
+	Container *L0749_ps_Container;
 
 
 	L0748_B_LeaderHandObjectProcessed = false;
@@ -968,7 +958,7 @@ T0274003:
 	return false;
 }
 
-void MovesensMan::triggerEffect(Sensor* sensor, int16 effect, int16 mapX, int16 mapY, uint16 cell) {
+void MovesensMan::triggerEffect(Sensor *sensor, int16 effect, int16 mapX, int16 mapY, uint16 cell) {
 	byte g59_squareTypeToEventType[7] = { // @ G0059_auc_Graphic562_SquareTypeToEventType
 		k6_TMEventTypeWall,
 		k5_TMEventTypeCorridor,
@@ -1035,8 +1025,8 @@ void MovesensMan::addSkillExperience(int16 skillIndex, uint16 exp, bool leaderOn
 void MovesensMan::processRotationEffect() {
 	Thing L0732_T_FirstSensorThing;
 	Thing L0733_T_LastSensorThing;
-	Sensor* L0734_ps_FirstSensor;
-	Sensor* L0735_ps_LastSensor;
+	Sensor *L0734_ps_FirstSensor;
+	Sensor *L0735_ps_LastSensor;
 
 
 	if (_sensorRotationEffect == kM1_SensorEffNone) {


Commit: 3b4c06e926d6202b20ef566781eb780c8d349852
    https://github.com/scummvm/scummvm/commit/3b4c06e926d6202b20ef566781eb780c8d349852
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T19:36:41+02:00

Commit Message:
DM: Refactor sensorIsTriggeredByClickOnWall, remove all GOTOs

Changed paths:
    engines/dm/movesens.cpp



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index cd06c42..3ec3f37 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -73,6 +73,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 	}
 	Thing lastProcessedThing = thingBeingProcessed = squareFirstThing;
 	while (thingBeingProcessed != Thing::_endOfList) {
+		bool skipToNextThing = false;
 		uint16 ProcessedThingType = (thingBeingProcessed).getType();
 		if (ProcessedThingType == k3_SensorThingType) {
 			int16 cellIdx = thingBeingProcessed.getCell();
@@ -80,119 +81,140 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 			Sensor *currentSensor = (Sensor *)_vm->_dungeonMan->getThingData(thingBeingProcessed);
 			SensorType processedSensorType = currentSensor->getType();
 			if (processedSensorType == k0_SensorDisabled)
-				goto T0275058_ProceedToNextThing;
-			if ((_vm->_championMan->_leaderIndex == kM1_ChampionNone) && (processedSensorType != k127_SensorWallChampionPortrait))
-				goto T0275058_ProceedToNextThing;
-			if (cellIdx != cellParam)
-				goto T0275058_ProceedToNextThing;
-			int16 sensorData = currentSensor->getData();
-			int16 sensorEffect = currentSensor->getAttrEffectA();
+				skipToNextThing = true;
+			else if ((_vm->_championMan->_leaderIndex == kM1_ChampionNone) && (processedSensorType != k127_SensorWallChampionPortrait))
+				skipToNextThing = true;
+			else if (cellIdx != cellParam)
+				skipToNextThing = true;
 
 			bool doNotTriggerSensor;
-			switch (processedSensorType) {
-			case k1_SensorWallOrnClick:
-				doNotTriggerSensor = false;
-				if (currentSensor->getAttrEffectA() == k3_SensorEffHold) {
-					goto T0275058_ProceedToNextThing;
-				}
-				break;
-			case k2_SensorWallOrnClickWithAnyObj:
-				doNotTriggerSensor = (_vm->_championMan->_leaderEmptyHanded != currentSensor->getAttrRevertEffectA());
-				break;
-			case k17_SensorWallOrnClickWithSpecObjRemovedSensor:
-			case k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors:
-				if (sensorCountToProcessPerCell[cellIdx]) /* If the sensor is not the last one of its type on the cell */
-					goto T0275058_ProceedToNextThing;
-			case k3_SensorWallOrnClickWithSpecObj:
-			case k4_SensorWallOrnClickWithSpecObjRemoved:
-				doNotTriggerSensor = ((sensorData == _vm->_objectMan->getObjectType(leaderHandObject)) == currentSensor->getAttrRevertEffectA());
-				if (!doNotTriggerSensor && (processedSensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) {
-					if (lastProcessedThing == thingBeingProcessed) /* If the sensor is the only one of its type on the cell */
+			int16 sensorData = 0;
+			int16 sensorEffect = 0;
+			if (!skipToNextThing) {
+				sensorData = currentSensor->getData();
+				sensorEffect = currentSensor->getAttrEffectA();
+
+				switch (processedSensorType) {
+				case k1_SensorWallOrnClick:
+					doNotTriggerSensor = false;
+					if (currentSensor->getAttrEffectA() == k3_SensorEffHold)
+						skipToNextThing = true;
+					break;
+				case k2_SensorWallOrnClickWithAnyObj:
+					doNotTriggerSensor = (_vm->_championMan->_leaderEmptyHanded != currentSensor->getAttrRevertEffectA());
+					break;
+				case k17_SensorWallOrnClickWithSpecObjRemovedSensor:
+				case k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors:
+					if (sensorCountToProcessPerCell[cellIdx]) { /* If the sensor is not the last one of its type on the cell */
+						skipToNextThing = true;
 						break;
-					Sensor *lastSensor = (Sensor *)_vm->_dungeonMan->getThingData(lastProcessedThing);
-					lastSensor->setNextThing(currentSensor->getNextThing());
-					currentSensor->setNextThing(Thing::_none);
-					thingBeingProcessed = lastProcessedThing;
-				}
-				if (!doNotTriggerSensor && (processedSensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors)) {
-					triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
-				}
-				break;
-			case k12_SensorWallObjGeneratorRotateSensors:
-				if (sensorCountToProcessPerCell[cellIdx]) /* If the sensor is not the last one of its type on the cell */
-					goto T0275058_ProceedToNextThing;
-				doNotTriggerSensor = !_vm->_championMan->_leaderEmptyHanded;
-				if (!doNotTriggerSensor) {
+					}
+					// No break on purpose
+				case k3_SensorWallOrnClickWithSpecObj:
+				case k4_SensorWallOrnClickWithSpecObjRemoved:
+					doNotTriggerSensor = ((sensorData == _vm->_objectMan->getObjectType(leaderHandObject)) == currentSensor->getAttrRevertEffectA());
+					if (!doNotTriggerSensor && (processedSensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) {
+						if (lastProcessedThing == thingBeingProcessed) /* If the sensor is the only one of its type on the cell */
+							break;
+						Sensor *lastSensor = (Sensor *)_vm->_dungeonMan->getThingData(lastProcessedThing);
+						lastSensor->setNextThing(currentSensor->getNextThing());
+						currentSensor->setNextThing(Thing::_none);
+						thingBeingProcessed = lastProcessedThing;
+					}
+					if (!doNotTriggerSensor && (processedSensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors)) {
+						triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
+					}
+					break;
+				case k12_SensorWallObjGeneratorRotateSensors:
+					if (sensorCountToProcessPerCell[cellIdx]) { /* If the sensor is not the last one of its type on the cell */
+						skipToNextThing = true;
+						break;
+					}
+					doNotTriggerSensor = !_vm->_championMan->_leaderEmptyHanded;
+					if (!doNotTriggerSensor)
+						triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
+					break;
+				case k13_SensorWallSingleObjStorageRotateSensors:
+					if (_vm->_championMan->_leaderEmptyHanded) {
+						leaderHandObject = getObjectOfTypeInCell(mapX, mapY, cellIdx, sensorData);
+						if (leaderHandObject == Thing::_none) {
+							skipToNextThing = true;
+							break;
+						}
+						_vm->_dungeonMan->unlinkThingFromList(leaderHandObject, Thing(0), mapX, mapY);
+						_vm->_championMan->putObjectInLeaderHand(leaderHandObject, true);
+					} else {
+						if ((_vm->_objectMan->getObjectType(leaderHandObject) != sensorData) || (getObjectOfTypeInCell(mapX, mapY, cellIdx, sensorData) != Thing::_none)) {
+							skipToNextThing = true;
+							break;
+						}
+						_vm->_championMan->getObjectRemovedFromLeaderHand();
+						_vm->_dungeonMan->linkThingToList(thingWithNewCell(leaderHandObject, cellIdx), Thing(0), mapX, mapY);
+						leaderHandObject = Thing::_none;
+					}
 					triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
-				}
-				break;
-			case k13_SensorWallSingleObjStorageRotateSensors:
-				if (_vm->_championMan->_leaderEmptyHanded) {
-					if ((leaderHandObject = getObjectOfTypeInCell(mapX, mapY, cellIdx, sensorData)) == Thing::_none)
-						goto T0275058_ProceedToNextThing;
-					_vm->_dungeonMan->unlinkThingFromList(leaderHandObject, Thing(0), mapX, mapY);
-					_vm->_championMan->putObjectInLeaderHand(leaderHandObject, true);
-				} else {
-					if ((_vm->_objectMan->getObjectType(leaderHandObject) != sensorData) || (getObjectOfTypeInCell(mapX, mapY, cellIdx, sensorData) != Thing::_none))
-						goto T0275058_ProceedToNextThing;
+					if ((sensorEffect == k3_SensorEffHold) && !_vm->_championMan->_leaderEmptyHanded)
+						doNotTriggerSensor = true;
+					else
+						doNotTriggerSensor = false;
+	
+					break;
+				case k16_SensorWallObjExchanger: {
+					if (sensorCountToProcessPerCell[cellIdx]) { /* If the sensor is not the last one of its type on the cell */
+						skipToNextThing = true;
+						break;
+					}
+					Thing thingOnSquare = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
+					if ((_vm->_objectMan->getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_none)) {
+						skipToNextThing = true;
+						break;
+					}
+					_vm->_dungeonMan->unlinkThingFromList(thingOnSquare, Thing(0), mapX, mapY);
 					_vm->_championMan->getObjectRemovedFromLeaderHand();
 					_vm->_dungeonMan->linkThingToList(thingWithNewCell(leaderHandObject, cellIdx), Thing(0), mapX, mapY);
-					leaderHandObject = Thing::_none;
-				}
-				triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
-				if ((sensorEffect == k3_SensorEffHold) && !_vm->_championMan->_leaderEmptyHanded)
-					doNotTriggerSensor = true;
-				else
+					_vm->_championMan->putObjectInLeaderHand(thingOnSquare, true);
 					doNotTriggerSensor = false;
-
-				break;
-			case k16_SensorWallObjExchanger: {
-				if (sensorCountToProcessPerCell[cellIdx]) /* If the sensor is not the last one of its type on the cell */
-					goto T0275058_ProceedToNextThing;
-				Thing thingOnSquare = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
-				if ((_vm->_objectMan->getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_none))
-					goto T0275058_ProceedToNextThing;
-				_vm->_dungeonMan->unlinkThingFromList(thingOnSquare, Thing(0), mapX, mapY);
-				_vm->_championMan->getObjectRemovedFromLeaderHand();
-				_vm->_dungeonMan->linkThingToList(thingWithNewCell(leaderHandObject, cellIdx), Thing(0), mapX, mapY);
-				_vm->_championMan->putObjectInLeaderHand(thingOnSquare, true);
-				doNotTriggerSensor = false;
+					}
+					break;
+				case k127_SensorWallChampionPortrait:
+					_vm->_championMan->addCandidateChampionToParty(sensorData);
+					skipToNextThing = true;
+					break;
+				default:
+					skipToNextThing = true;
+					break;
 				}
-				break;
-			case k127_SensorWallChampionPortrait:
-				_vm->_championMan->addCandidateChampionToParty(sensorData);
-				goto T0275058_ProceedToNextThing;
-			default:
-				goto T0275058_ProceedToNextThing;
-			}
-
-			if (sensorEffect == k3_SensorEffHold) {
-				sensorEffect = doNotTriggerSensor ? k1_SensorEffClear : k0_SensorEffSet;
-				doNotTriggerSensor = false;
 			}
-			if (!doNotTriggerSensor) {
-				atLeastOneSensorWasTriggered = true;
-				if (currentSensor->getAttrAudibleA())
-					_vm->_sound->requestPlay(k01_soundSWITCH, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 
-				if (!_vm->_championMan->_leaderEmptyHanded && ((processedSensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (processedSensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (processedSensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
-					Thing *leaderThing = (Thing *)_vm->_dungeonMan->getThingData(leaderHandObject);
-					*leaderThing = Thing::_none;
-					_vm->_championMan->getObjectRemovedFromLeaderHand();
-					leaderHandObject = Thing::_none;
-				} else if (_vm->_championMan->_leaderEmptyHanded
-					&& (processedSensorType == k12_SensorWallObjGeneratorRotateSensors)) {
-					leaderHandObject = _vm->_dungeonMan->getObjForProjectileLaucherOrObjGen(sensorData);
-					if (leaderHandObject != Thing::_none)
-						_vm->_championMan->putObjectInLeaderHand(leaderHandObject, true);
+			if (!skipToNextThing) {
+				if (sensorEffect == k3_SensorEffHold) {
+					sensorEffect = doNotTriggerSensor ? k1_SensorEffClear : k0_SensorEffSet;
+					doNotTriggerSensor = false;
 				}
-				triggerEffect(currentSensor, sensorEffect, mapX, mapY, cellIdx);
+				if (!doNotTriggerSensor) {
+					atLeastOneSensorWasTriggered = true;
+					if (currentSensor->getAttrAudibleA())
+						_vm->_sound->requestPlay(k01_soundSWITCH, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
+	
+					if (!_vm->_championMan->_leaderEmptyHanded && ((processedSensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (processedSensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (processedSensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
+						Thing *leaderThing = (Thing *)_vm->_dungeonMan->getThingData(leaderHandObject);
+						*leaderThing = Thing::_none;
+						_vm->_championMan->getObjectRemovedFromLeaderHand();
+						leaderHandObject = Thing::_none;
+					} else if (_vm->_championMan->_leaderEmptyHanded
+						&& (processedSensorType == k12_SensorWallObjGeneratorRotateSensors)) {
+						leaderHandObject = _vm->_dungeonMan->getObjForProjectileLaucherOrObjGen(sensorData);
+						if (leaderHandObject != Thing::_none)
+							_vm->_championMan->putObjectInLeaderHand(leaderHandObject, true);
+					}
+					triggerEffect(currentSensor, sensorEffect, mapX, mapY, cellIdx);
+				}
+				skipToNextThing = true;
 			}
-			goto T0275058_ProceedToNextThing;
 		}
-		if (ProcessedThingType >= k4_GroupThingType)
+		if (!skipToNextThing && (ProcessedThingType >= k4_GroupThingType))
 			break;
-T0275058_ProceedToNextThing:
+
 		lastProcessedThing = thingBeingProcessed;
 		thingBeingProcessed = _vm->_dungeonMan->getNextThing(thingBeingProcessed);
 	}


Commit: 3df32ecf204f301c2dc2348c0a6369d06a310504
    https://github.com/scummvm/scummvm/commit/3df32ecf204f301c2dc2348c0a6369d06a310504
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T20:45:38+02:00

Commit Message:
DM: Refactor getMoveResult()

Changed paths:
    engines/dm/movesens.cpp



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 3ec3f37..d5e941f 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -223,331 +223,293 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 }
 
 bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destMapX, int16 destMapY) {
-	int16 L0708_i_Multiple = 0;
-#define AL0708_i_DestinationSquare L0708_i_Multiple
-#define AL0708_i_ScentIndex        L0708_i_Multiple
-#define AL0708_i_ActiveGroupIndex  L0708_i_Multiple
-	int16 L0709_i_Multiple;
-#define AL0709_i_DestinationSquareType L0709_i_Multiple
-#define AL0709_i_ChampionIndex         L0709_i_Multiple
-	int16 L0710_i_ThingType;
-	Champion *L0711_ps_Champion;
-	Teleporter *L0712_ps_Teleporter;
-	int16 L0718_i_RequiredTeleporterScope;
-	// Strangerke: Only present in v2.1, but it fixes a bug, so I propose to keep it
-	int16 L0719_i_TraversedPitCount;
-	uint16 L0720_ui_MoveGroupResult;
-	uint16 L0727_ui_Multiple;
-#define AL0727_ui_ThingCell L0727_ui_Multiple
-#define AL0727_ui_Outcome   L0727_ui_Multiple
-#define AL0727_ui_Backup    L0727_ui_Multiple
-	int16 L0728_i_ChainedMoveCount;
-	uint16 L1638_ui_MovementSoundIndex;
-
-	L0710_i_ThingType = kM1_PartyThingType;
-	L0719_i_TraversedPitCount = 0;
-	L0720_ui_MoveGroupResult = 0;
-
-	uint16 L0717_ui_ThingCell = 0;
-
-	bool L0713_B_ThingLevitates = false;
+	ThingType thingType = kM1_PartyThingType;
+	int16 traversedPitCount = 0;
+	uint16 moveGroupResult = 0;
+	uint16 thingCell = 0;
+	bool thingLevitates = false;
+
 	if (thing != Thing::_party) {
-		L0710_i_ThingType = thing.getType();
-		L0717_ui_ThingCell = thing.getCell();
-		L0713_B_ThingLevitates = isLevitating(thing);
+		thingType = thing.getType();
+		thingCell = thing.getCell();
+		thingLevitates = isLevitating(thing);
 	}
 	/* If moving the party or a creature on the party map from a dungeon square then check for a projectile impact */
-	if ((mapX >= 0) && ((thing == Thing::_party) || ((L0710_i_ThingType == k4_GroupThingType) && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex)))) {
-		if (moveIsKilledByProjectileImpact(mapX, mapY, destMapX, destMapY, thing)) {
+	if ((mapX >= 0) && ((thing == Thing::_party) || ((thingType == k4_GroupThingType) && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex)))) {
+		if (moveIsKilledByProjectileImpact(mapX, mapY, destMapX, destMapY, thing))
 			return true; /* The specified group thing cannot be moved because it was killed by a projectile impact */
-		}
 	}
 
-	uint16 L0714_ui_MapIndexSource = 0;
-	uint16 L0715_ui_MapIndexDestination = 0;
-	bool L0721_B_GroupOnPartyMap = false;
-	bool L0725_B_PartySquare = false;
-	bool L0726_B_Audible = false;
+	uint16 mapIndexSource = 0;
+	uint16 mapIndexDestination = 0;
+	bool groupOnPartyMap = false;
+	bool partySquare = false;
+	bool audibleTeleporter = false;
 
 	if (destMapX >= 0) {
-		L0714_ui_MapIndexSource = L0715_ui_MapIndexDestination = _vm->_dungeonMan->_currMapIndex;
-		L0721_B_GroupOnPartyMap = (L0714_ui_MapIndexSource == _vm->_dungeonMan->_partyMapIndex) && (mapX >= 0);
-		uint16 L0716_ui_Direction = 0;
-		bool L0722_B_FallKilledGroup = false;
-		bool L0723_B_DrawDungeonViewWhileFalling = false;
-		bool L0724_B_DestinationIsTeleporterTarget = false;
+		mapIndexSource = mapIndexDestination = _vm->_dungeonMan->_currMapIndex;
+		groupOnPartyMap = (mapIndexSource == _vm->_dungeonMan->_partyMapIndex) && (mapX >= 0);
+		uint16 direction = 0;
+		bool fallKilledGroup = false;
+		bool drawDungeonViewWhileFalling = false;
+		bool destinationIsTeleporterTarget = false;
+		int16 requiredTeleporterScope;
 		if (thing == Thing::_party) {
 			_vm->_dungeonMan->_partyMapX = destMapX;
 			_vm->_dungeonMan->_partyMapY = destMapY;
-			L0718_i_RequiredTeleporterScope = k0x0002_TelepScopeObjOrParty;
-			L0723_B_DrawDungeonViewWhileFalling = !_vm->_inventoryMan->_inventoryChampionOrdinal && !_vm->_championMan->_partyIsSleeping;
-			L0716_ui_Direction = _vm->_dungeonMan->_partyDir;
-		} else {
-			if (L0710_i_ThingType == k4_GroupThingType) {
-				L0718_i_RequiredTeleporterScope = k0x0001_TelepScopeCreatures;
-			} else {
-				L0718_i_RequiredTeleporterScope = (k0x0001_TelepScopeCreatures | k0x0002_TelepScopeObjOrParty);
-			}
-		}
-		if (L0710_i_ThingType == k14_ProjectileThingType) {
-			L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(thing);
+			requiredTeleporterScope = k0x0002_TelepScopeObjOrParty;
+			drawDungeonViewWhileFalling = !_vm->_inventoryMan->_inventoryChampionOrdinal && !_vm->_championMan->_partyIsSleeping;
+			direction = _vm->_dungeonMan->_partyDir;
+		} else if (thingType == k4_GroupThingType)
+			requiredTeleporterScope = k0x0001_TelepScopeCreatures;
+		else
+			requiredTeleporterScope = (k0x0001_TelepScopeCreatures | k0x0002_TelepScopeObjOrParty);
+
+		if (thingType == k14_ProjectileThingType) {
+			Teleporter *L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(thing);
 			_moveResultDir = (_vm->_timeline->_events[((Projectile *)L0712_ps_Teleporter)->_eventIndex])._C._projectile.getDir();
 		}
-		for (L0728_i_ChainedMoveCount = 1000; --L0728_i_ChainedMoveCount; ) { /* No more than 1000 chained moves at once (in a chain of teleporters and pits for example) */
-			AL0708_i_DestinationSquare = _vm->_dungeonMan->_currMapData[destMapX][destMapY];
-			if ((AL0709_i_DestinationSquareType = Square(AL0708_i_DestinationSquare).getType()) == k5_ElementTypeTeleporter) {
-				if (!getFlag(AL0708_i_DestinationSquare, k0x0008_TeleporterOpen))
+
+		int16 destinationSquareData = 0;
+		/* No more than 1000 chained moves at once (in a chain of teleporters and pits for example) */
+		for (int16 chainedMoveCount = 1000; --chainedMoveCount; ) {
+			destinationSquareData = _vm->_dungeonMan->_currMapData[destMapX][destMapY];
+			SquareType destinationSquareType = Square(destinationSquareData).getType();
+			if (destinationSquareType == k5_ElementTypeTeleporter) {
+				if (!getFlag(destinationSquareData, k0x0008_TeleporterOpen))
 					break;
-				L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getSquareFirstThingData(destMapX, destMapY);
-				if ((L0712_ps_Teleporter->getScope() == k0x0001_TelepScopeCreatures) && (L0710_i_ThingType != k4_GroupThingType))
+
+				Teleporter *teleporter = (Teleporter *)_vm->_dungeonMan->getSquareFirstThingData(destMapX, destMapY);
+				if ((teleporter->getScope() == k0x0001_TelepScopeCreatures) && (thingType != k4_GroupThingType))
 					break;
-				if ((L0718_i_RequiredTeleporterScope != (k0x0001_TelepScopeCreatures | k0x0002_TelepScopeObjOrParty)) && !getFlag(L0712_ps_Teleporter->getScope(), L0718_i_RequiredTeleporterScope))
+
+				if ((requiredTeleporterScope != (k0x0001_TelepScopeCreatures | k0x0002_TelepScopeObjOrParty)) && !getFlag(teleporter->getScope(), requiredTeleporterScope))
 					break;
-				L0724_B_DestinationIsTeleporterTarget = (destMapX == L0712_ps_Teleporter->getTargetMapX()) && (destMapY == L0712_ps_Teleporter->getTargetMapY()) && (L0715_ui_MapIndexDestination == L0712_ps_Teleporter->getTargetMapIndex());
-				destMapX = L0712_ps_Teleporter->getTargetMapX();
-				destMapY = L0712_ps_Teleporter->getTargetMapY();
-				L0726_B_Audible = L0712_ps_Teleporter->isAudible();
-				_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination = L0712_ps_Teleporter->getTargetMapIndex());
+
+				destinationIsTeleporterTarget = (destMapX == teleporter->getTargetMapX()) && (destMapY == teleporter->getTargetMapY()) && (mapIndexDestination == teleporter->getTargetMapIndex());
+				destMapX = teleporter->getTargetMapX();
+				destMapY = teleporter->getTargetMapY();
+				audibleTeleporter = teleporter->isAudible();
+				_vm->_dungeonMan->setCurrentMap(mapIndexDestination = teleporter->getTargetMapIndex());
 				if (thing == Thing::_party) {
 					_vm->_dungeonMan->_partyMapX = destMapX;
 					_vm->_dungeonMan->_partyMapY = destMapY;
-					if (L0712_ps_Teleporter->isAudible()) {
+					if (teleporter->isAudible())
 						_vm->_sound->requestPlay(k17_soundBUZZ, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
-					}
-					L0723_B_DrawDungeonViewWhileFalling = true;
-					if (L0712_ps_Teleporter->getAbsoluteRotation()) {
-						_vm->_championMan->setPartyDirection(L0712_ps_Teleporter->getRotation());
-					} else {
-						_vm->_championMan->setPartyDirection(normalizeModulo4(_vm->_dungeonMan->_partyDir + L0712_ps_Teleporter->getRotation()));
-					}
+
+					drawDungeonViewWhileFalling = true;
+					if (teleporter->getAbsoluteRotation())
+						_vm->_championMan->setPartyDirection(teleporter->getRotation());
+					else
+						_vm->_championMan->setPartyDirection(normalizeModulo4(_vm->_dungeonMan->_partyDir + teleporter->getRotation()));
 				} else {
-					if (L0710_i_ThingType == k4_GroupThingType) {
-						if (L0712_ps_Teleporter->isAudible()) {
+					if (thingType == k4_GroupThingType) {
+						if (teleporter->isAudible())
 							_vm->_sound->requestPlay(k17_soundBUZZ, destMapX, destMapY, k1_soundModePlayIfPrioritized);
-						}
-						L0720_ui_MoveGroupResult = getTeleporterRotatedGroupResult(L0712_ps_Teleporter, thing, L0714_ui_MapIndexSource);
+
+						moveGroupResult = getTeleporterRotatedGroupResult(teleporter, thing, mapIndexSource);
 					} else {
-						if (L0710_i_ThingType == k14_ProjectileThingType) {
-							thing = getTeleporterRotatedProjectileThing(L0712_ps_Teleporter, thing);
-						} else {
-							if (!(L0712_ps_Teleporter->getAbsoluteRotation()) && (mapX != -2)) {
-								thing = thingWithNewCell(thing, normalizeModulo4(thing.getCell() + L0712_ps_Teleporter->getRotation()));
-							}
-						}
+						if (thingType == k14_ProjectileThingType)
+							thing = getTeleporterRotatedProjectileThing(teleporter, thing);
+						else if (!(teleporter->getAbsoluteRotation()) && (mapX != -2))
+							thing = thingWithNewCell(thing, normalizeModulo4(thing.getCell() + teleporter->getRotation()));
 					}
 				}
-				if (L0724_B_DestinationIsTeleporterTarget)
+				if (destinationIsTeleporterTarget)
 					break;
 			} else {
-				if ((AL0709_i_DestinationSquareType == k2_ElementTypePit) && !L0713_B_ThingLevitates && getFlag(AL0708_i_DestinationSquare, k0x0008_PitOpen) && !getFlag(AL0708_i_DestinationSquare, k0x0001_PitImaginary)) {
-					if (L0723_B_DrawDungeonViewWhileFalling && !_useRopeToClimbDownPit) {
-						L0723_B_DrawDungeonViewWhileFalling = true;
-						if (L0719_i_TraversedPitCount) {
-							_vm->_dungeonMan->setCurrentMapAndPartyMap(L0715_ui_MapIndexDestination);
+				if ((destinationSquareType == k2_ElementTypePit) && !thingLevitates && getFlag(destinationSquareData, k0x0008_PitOpen) && !getFlag(destinationSquareData, k0x0001_PitImaginary)) {
+					if (drawDungeonViewWhileFalling && !_useRopeToClimbDownPit) {
+						drawDungeonViewWhileFalling = true;
+						if (traversedPitCount) {
+							_vm->_dungeonMan->setCurrentMapAndPartyMap(mapIndexDestination);
 							_vm->_displayMan->loadCurrentMapGraphics();
 						}
-						L0719_i_TraversedPitCount++;
+						traversedPitCount++;
 						_vm->_displayMan->drawDungeon(_vm->_dungeonMan->_partyDir, destMapX, destMapY); /* BUG0_28 When falling through multiple pits the dungeon view is updated to show each traversed map but the graphics used for creatures, wall and floor ornaments may not be correct. The dungeon view is drawn for each map by using the graphics loaded for the source map. Therefore the graphics for creatures, wall and floor ornaments may not look like what they should */
 																												  /* BUG0_71 Some timings are too short on fast computers. When the party falls in a series of pits, the dungeon view is refreshed too quickly because the execution speed is not limited */
 																												  /* BUG0_01 While drawing creatures the engine will read invalid ACTIVE_GROUP data in _vm->_groupMan->_g375_activeGroups because the data is for the creatures on the source map and not the map being drawn. The only consequence is that creatures may be drawn with incorrect bitmaps and/or directions */
 					}
-					L0715_ui_MapIndexDestination = _vm->_dungeonMan->getLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &destMapX, &destMapY);
-					_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
+					mapIndexDestination = _vm->_dungeonMan->getLocationAfterLevelChange(mapIndexDestination, 1, &destMapX, &destMapY);
+					_vm->_dungeonMan->setCurrentMap(mapIndexDestination);
 					if (thing == Thing::_party) {
 						_vm->_dungeonMan->_partyMapX = destMapX;
 						_vm->_dungeonMan->_partyMapY = destMapY;
 						if (_vm->_championMan->_partyChampionCount > 0) {
 							if (_useRopeToClimbDownPit) {
-								for (AL0709_i_ChampionIndex = k0_ChampionFirst, L0711_ps_Champion = _vm->_championMan->_champions; AL0709_i_ChampionIndex < _vm->_championMan->_partyChampionCount; AL0709_i_ChampionIndex++, L0711_ps_Champion++) {
-									if (L0711_ps_Champion->_currHealth) {
-										_vm->_championMan->decrementStamina(AL0709_i_ChampionIndex, ((L0711_ps_Champion->_load * 25) / _vm->_championMan->getMaximumLoad(L0711_ps_Champion)) + 1);
-									}
-								}
-							} else {
-								if (_vm->_championMan->getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF)) {
-									_vm->_sound->requestPlay(k06_soundSCREAM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
+								Champion *curChampion = _vm->_championMan->_champions;
+								for (int16 championIdx = k0_ChampionFirst; championIdx < _vm->_championMan->_partyChampionCount; championIdx++, curChampion++) {
+									if (curChampion->_currHealth)
+										_vm->_championMan->decrementStamina(championIdx, ((curChampion->_load * 25) / _vm->_championMan->getMaximumLoad(curChampion)) + 1);
 								}
-							}
+							} else if (_vm->_championMan->getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF))
+								_vm->_sound->requestPlay(k06_soundSCREAM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
 						}
 						_useRopeToClimbDownPit = false;
-					} else {
-						if (L0710_i_ThingType == k4_GroupThingType) {
-							_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
-							AL0727_ui_Outcome = _vm->_groupMan->getDamageAllCreaturesOutcome((Group *)_vm->_dungeonMan->getThingData(thing), mapX, mapY, 20, false);
-							_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
-							L0722_B_FallKilledGroup = (AL0727_ui_Outcome == k2_outcomeKilledAllCreaturesInGroup);
-							if (L0722_B_FallKilledGroup)
-								break;
-							if (AL0727_ui_Outcome == k1_outcomeKilledSomeCreaturesInGroup) {
-								_vm->_groupMan->dropMovingCreatureFixedPossession(thing, destMapX, destMapY);
-							}
-						}
+					} else if (thingType == k4_GroupThingType) {
+						_vm->_dungeonMan->setCurrentMap(mapIndexSource);
+						uint16 outcome = _vm->_groupMan->getDamageAllCreaturesOutcome((Group *)_vm->_dungeonMan->getThingData(thing), mapX, mapY, 20, false);
+						_vm->_dungeonMan->setCurrentMap(mapIndexDestination);
+						fallKilledGroup = (outcome == k2_outcomeKilledAllCreaturesInGroup);
+						if (fallKilledGroup)
+							break;
+
+						if (outcome == k1_outcomeKilledSomeCreaturesInGroup)
+							_vm->_groupMan->dropMovingCreatureFixedPossession(thing, destMapX, destMapY);
 					}
-				} else {
-					if ((AL0709_i_DestinationSquareType == k3_ElementTypeStairs) && (thing != Thing::_party) && (L0710_i_ThingType != k14_ProjectileThingType)) {
-						if (!getFlag(AL0708_i_DestinationSquare, k0x0004_StairsUp)) {
-							L0715_ui_MapIndexDestination = _vm->_dungeonMan->getLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &destMapX, &destMapY);
-							_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
-						}
-						L0716_ui_Direction = _vm->_dungeonMan->getStairsExitDirection(destMapX, destMapY);
-						destMapX += _vm->_dirIntoStepCountEast[L0716_ui_Direction], destMapY += _vm->_dirIntoStepCountNorth[L0716_ui_Direction];
-						L0716_ui_Direction = returnOppositeDir((Direction)L0716_ui_Direction);
-						AL0727_ui_ThingCell = thing.getCell();
-						AL0727_ui_ThingCell = normalizeModulo4((((AL0727_ui_ThingCell - L0716_ui_Direction + 1) & 0x0002) >> 1) + L0716_ui_Direction);
-						thing = thingWithNewCell(thing, AL0727_ui_ThingCell);
-					} else
-						break;
-				}
+				} else if ((destinationSquareType == k3_ElementTypeStairs) && (thing != Thing::_party) && (thingType != k14_ProjectileThingType)) {
+					if (!getFlag(destinationSquareData, k0x0004_StairsUp)) {
+						mapIndexDestination = _vm->_dungeonMan->getLocationAfterLevelChange(mapIndexDestination, 1, &destMapX, &destMapY);
+						_vm->_dungeonMan->setCurrentMap(mapIndexDestination);
+					}
+					direction = _vm->_dungeonMan->getStairsExitDirection(destMapX, destMapY);
+					destMapX += _vm->_dirIntoStepCountEast[direction], destMapY += _vm->_dirIntoStepCountNorth[direction];
+					direction = returnOppositeDir((Direction)direction);
+					uint16 thingCell = thing.getCell();
+					thingCell = normalizeModulo4((((thingCell - direction + 1) & 0x0002) >> 1) + direction);
+					thing = thingWithNewCell(thing, thingCell);
+				} else
+					break;
 			}
 		}
-		if ((L0710_i_ThingType == k4_GroupThingType) && (L0722_B_FallKilledGroup || !_vm->_dungeonMan->isCreatureAllowedOnMap(thing, L0715_ui_MapIndexDestination))) {
+		if ((thingType == k4_GroupThingType) && (fallKilledGroup || !_vm->_dungeonMan->isCreatureAllowedOnMap(thing, mapIndexDestination))) {
 			_vm->_groupMan->dropMovingCreatureFixedPossession(thing, destMapX, destMapY);
 			_vm->_groupMan->dropGroupPossessions(destMapX, destMapY, thing, k2_soundModePlayOneTickLater);
-			_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
-			if (mapX >= 0) {
+			_vm->_dungeonMan->setCurrentMap(mapIndexSource);
+			if (mapX >= 0)
 				_vm->_groupMan->groupDelete(mapX, mapY);
-			}
+
 			return true; /* The specified group thing cannot be moved because it was killed by a fall or because it is not allowed on the destination map */
 		}
 		_moveResultMapX = destMapX;
 		_moveResultMapY = destMapY;
-		_moveResultMapIndex = L0715_ui_MapIndexDestination;
+		_moveResultMapIndex = mapIndexDestination;
 		_moveResultCell = thing.getCell();
-		L0725_B_PartySquare = (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) && (destMapX == mapX) && (destMapY == mapY);
-		if (L0725_B_PartySquare) {
+		partySquare = (mapIndexDestination == mapIndexSource) && (destMapX == mapX) && (destMapY == mapY);
+		if (partySquare) {
 			if (thing == Thing::_party) {
-				if (_vm->_dungeonMan->_partyDir == L0716_ui_Direction) {
+				if (_vm->_dungeonMan->_partyDir == direction)
 					return false;
-				}
-			} else {
-				if ((_moveResultCell == L0717_ui_ThingCell) && (L0710_i_ThingType != k14_ProjectileThingType)) {
-					return false;
-				}
-			}
+			} else if ((_moveResultCell == thingCell) && (thingType != k14_ProjectileThingType))
+				return false;
 		} else {
 			if ((thing == Thing::_party) && _vm->_championMan->_partyChampionCount) {
-				AL0727_ui_Backup = AL0708_i_DestinationSquare;
-				AL0708_i_ScentIndex = _vm->_championMan->_party._scentCount;
-				while (AL0708_i_ScentIndex >= 24) {
+				uint16 oldDestinationSquare = destinationSquareData;
+				int16 scentIndex = _vm->_championMan->_party._scentCount;
+				while (scentIndex >= 24) {
 					_vm->_championMan->deleteScent(0);
-					AL0708_i_ScentIndex--;
+					scentIndex--;
 				}
-				if (AL0708_i_ScentIndex) {
+
+				if (scentIndex)
 					_vm->_championMan->addScentStrength(mapX, mapY, (int)(_vm->_gameTime - _vm->_projexpl->_lastPartyMovementTime));
-				}
+
 				_vm->_projexpl->_lastPartyMovementTime = _vm->_gameTime;
 				_vm->_championMan->_party._scentCount++;
-				if (_vm->_championMan->_party._event79Count_Footprints) {
+				if (_vm->_championMan->_party._event79Count_Footprints)
 					_vm->_championMan->_party._lastScentIndex = _vm->_championMan->_party._scentCount;
-				}
-				_vm->_championMan->_party._scents[AL0708_i_ScentIndex].setMapX(destMapX);
-				_vm->_championMan->_party._scents[AL0708_i_ScentIndex].setMapY(destMapY);
-				_vm->_championMan->_party._scents[AL0708_i_ScentIndex].setMapIndex(L0715_ui_MapIndexDestination);
-				_vm->_championMan->_party._scentStrengths[AL0708_i_ScentIndex] = 0;
+
+				_vm->_championMan->_party._scents[scentIndex].setMapX(destMapX);
+				_vm->_championMan->_party._scents[scentIndex].setMapY(destMapY);
+				_vm->_championMan->_party._scents[scentIndex].setMapIndex(mapIndexDestination);
+				_vm->_championMan->_party._scentStrengths[scentIndex] = 0;
 				_vm->_championMan->addScentStrength(destMapX, destMapY, k0x8000_mergeCycles | 24);
-				AL0708_i_DestinationSquare = AL0727_ui_Backup;
-			}
-			if (L0715_ui_MapIndexDestination != L0714_ui_MapIndexSource) {
-				_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
+				destinationSquareData = oldDestinationSquare;
 			}
+			if (mapIndexDestination != mapIndexSource)
+				_vm->_dungeonMan->setCurrentMap(mapIndexSource);
 		}
 	}
 	if (mapX >= 0) {
-		if (thing == Thing::_party) {
-			processThingAdditionOrRemoval(mapX, mapY, Thing::_party, L0725_B_PartySquare, false);
-		} else {
-			if (L0713_B_ThingLevitates) {
-				_vm->_dungeonMan->unlinkThingFromList(thing, Thing(0), mapX, mapY);
-			} else {
-				processThingAdditionOrRemoval(mapX, mapY, thing, (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY), false);
-			}
-		}
+		if (thing == Thing::_party)
+			processThingAdditionOrRemoval(mapX, mapY, Thing::_party, partySquare, false);
+		else if (thingLevitates)
+			_vm->_dungeonMan->unlinkThingFromList(thing, Thing::_none, mapX, mapY);
+		else
+			processThingAdditionOrRemoval(mapX, mapY, thing, (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY), false);
 	}
 	if (destMapX >= 0) {
 		if (thing == Thing::_party) {
-			_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
+			_vm->_dungeonMan->setCurrentMap(mapIndexDestination);
 			if ((thing = _vm->_groupMan->groupGetThing(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY)) != Thing::_endOfList) { /* Delete group if party moves onto its square */
 				_vm->_groupMan->dropGroupPossessions(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, thing, k1_soundModePlayIfPrioritized);
 				_vm->_groupMan->groupDelete(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
 			}
-			if (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) {
-				processThingAdditionOrRemoval(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, Thing::_party, L0725_B_PartySquare, true);
-			} else {
-				_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
-				_vm->_newPartyMapIndex = L0715_ui_MapIndexDestination;
+
+			if (mapIndexDestination == mapIndexSource)
+				processThingAdditionOrRemoval(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, Thing::_party, partySquare, true);
+			else {
+				_vm->_dungeonMan->setCurrentMap(mapIndexSource);
+				_vm->_newPartyMapIndex = mapIndexDestination;
 			}
 		} else {
-			if (L0710_i_ThingType == k4_GroupThingType) {
-				_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
-				L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(thing);
-				AL0708_i_ActiveGroupIndex = ((Group *)L0712_ps_Teleporter)->getActiveGroupIndex();
-				if (((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_partyMapIndex) && (destMapX == _vm->_dungeonMan->_partyMapX) && (destMapY == _vm->_dungeonMan->_partyMapY)) || (_vm->_groupMan->groupGetThing(destMapX, destMapY) != Thing::_endOfList)) { /* If a group tries to move to the party square or over another group then create an event to move the group later */
-					_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
-					if (mapX >= 0) {
+			if (thingType == k4_GroupThingType) {
+				_vm->_dungeonMan->setCurrentMap(mapIndexDestination);
+				Teleporter *L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(thing);
+				int16 activeGroupIndex = ((Group *)L0712_ps_Teleporter)->getActiveGroupIndex();
+				if (((mapIndexDestination == _vm->_dungeonMan->_partyMapIndex) && (destMapX == _vm->_dungeonMan->_partyMapX) && (destMapY == _vm->_dungeonMan->_partyMapY)) || (_vm->_groupMan->groupGetThing(destMapX, destMapY) != Thing::_endOfList)) { /* If a group tries to move to the party square or over another group then create an event to move the group later */
+					_vm->_dungeonMan->setCurrentMap(mapIndexSource);
+					if (mapX >= 0)
 						_vm->_groupMan->groupDeleteEvents(mapX, mapY);
-					}
-					if (L0721_B_GroupOnPartyMap) {
-						_vm->_groupMan->removeActiveGroup(AL0708_i_ActiveGroupIndex);
-					}
-					createEventMoveGroup(thing, destMapX, destMapY, L0715_ui_MapIndexDestination, L0726_B_Audible);
+
+					if (groupOnPartyMap)
+						_vm->_groupMan->removeActiveGroup(activeGroupIndex);
+
+					createEventMoveGroup(thing, destMapX, destMapY, mapIndexDestination, audibleTeleporter);
 					return true; /* The specified group thing cannot be moved because the party or another group is on the destination square */
 				}
-				L1638_ui_MovementSoundIndex = getSound(((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[thing.getIndex()]._type);
-				if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) {
-					_vm->_sound->requestPlay(L1638_ui_MovementSoundIndex, destMapX, destMapY, k1_soundModePlayIfPrioritized);
-				}
-				if (L0721_B_GroupOnPartyMap && (L0715_ui_MapIndexDestination != _vm->_dungeonMan->_partyMapIndex)) { /* If the group leaves the party map */
-					_vm->_groupMan->removeActiveGroup(AL0708_i_ActiveGroupIndex);
-					L0720_ui_MoveGroupResult = true;
-				} else {
-					if ((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_partyMapIndex) && (!L0721_B_GroupOnPartyMap)) { /* If the group arrives on the party map */
-						_vm->_groupMan->addActiveGroup(thing, destMapX, destMapY);
-						L0720_ui_MoveGroupResult = true;
-					}
+				uint16 movementSoundIndex = getSound(((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[thing.getIndex()]._type);
+				if (movementSoundIndex < k34_D13_soundCount)
+					_vm->_sound->requestPlay(movementSoundIndex, destMapX, destMapY, k1_soundModePlayIfPrioritized);
+
+				if (groupOnPartyMap && (mapIndexDestination != _vm->_dungeonMan->_partyMapIndex)) { /* If the group leaves the party map */
+					_vm->_groupMan->removeActiveGroup(activeGroupIndex);
+					moveGroupResult = true;
+				} else if ((mapIndexDestination == _vm->_dungeonMan->_partyMapIndex) && (!groupOnPartyMap)) { /* If the group arrives on the party map */
+					_vm->_groupMan->addActiveGroup(thing, destMapX, destMapY);
+					moveGroupResult = true;
 				}
-				if (L0713_B_ThingLevitates) {
+				if (thingLevitates)
 					_vm->_dungeonMan->linkThingToList(thing, Thing(0), destMapX, destMapY);
-				} else {
+				else
 					processThingAdditionOrRemoval(destMapX, destMapY, thing, false, true);
-				}
-				if (L0720_ui_MoveGroupResult || (mapX < 0)) { /* If group moved from one map to another or if it was just placed on a square */
+
+				if (moveGroupResult || (mapX < 0)) /* If group moved from one map to another or if it was just placed on a square */
 					_vm->_groupMan->startWandering(destMapX, destMapY);
-				}
-				_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
+
+				_vm->_dungeonMan->setCurrentMap(mapIndexSource);
 				if (mapX >= 0) {
-					if (L0720_ui_MoveGroupResult > 1) { /* If the group behavior was C6_BEHAVIOR_ATTACK before being teleported from and to the party map */
-						_vm->_groupMan->stopAttacking(&_vm->_groupMan->_activeGroups[L0720_ui_MoveGroupResult - 2], mapX, mapY);
-					} else {
-						if (L0720_ui_MoveGroupResult) { /* If the group was teleported or leaved the party map or entered the party map */
-							_vm->_groupMan->groupDeleteEvents(mapX, mapY);
-						}
-					}
+					if (moveGroupResult > 1) /* If the group behavior was C6_BEHAVIOR_ATTACK before being teleported from and to the party map */
+						_vm->_groupMan->stopAttacking(&_vm->_groupMan->_activeGroups[moveGroupResult - 2], mapX, mapY);
+					else if (moveGroupResult) /* If the group was teleported or leaved the party map or entered the party map */
+						_vm->_groupMan->groupDeleteEvents(mapX, mapY);
 				}
-				return L0720_ui_MoveGroupResult;
+				return moveGroupResult;
 			}
-			_vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
-			if (L0710_i_ThingType == k14_ProjectileThingType) { /* BUG0_29 An explosion can trigger a floor sensor. Explosions do not trigger floor sensors on the square where they are created. However, if an explosion is moved by a teleporter (or by falling into a pit, see BUG0_26) after it was created, it can trigger floor sensors on the destination square. This is because explosions are not considered as levitating in the code, while projectiles are. The condition here should be (L0713_B_ThingLevitates) so that explosions would not start sensor processing on their destination square as they should be Levitating. This would work if F0264_MOVE_IsLevitating returned true for explosions (see BUG0_26) */
+			_vm->_dungeonMan->setCurrentMap(mapIndexDestination);
+			if (thingType == k14_ProjectileThingType) /* BUG0_29 An explosion can trigger a floor sensor. Explosions do not trigger floor sensors on the square where they are created. However, if an explosion is moved by a teleporter (or by falling into a pit, see BUG0_26) after it was created, it can trigger floor sensors on the destination square. This is because explosions are not considered as levitating in the code, while projectiles are. The condition here should be (L0713_B_ThingLevitates) so that explosions would not start sensor processing on their destination square as they should be Levitating. This would work if F0264_MOVE_IsLevitating returned true for explosions (see BUG0_26) */
 				_vm->_dungeonMan->linkThingToList(thing, Thing(0), destMapX, destMapY);
-			} else {
+			else
 				processThingAdditionOrRemoval(destMapX, destMapY, thing, (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (destMapX == _vm->_dungeonMan->_partyMapX) && (destMapY == _vm->_dungeonMan->_partyMapY), true);
-			}
-			_vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
+
+			_vm->_dungeonMan->setCurrentMap(mapIndexSource);
 		}
 	}
 	return false;
 }
 
 bool MovesensMan::isLevitating(Thing thing) {
-	int16 L0695_i_ThingType;
+	ThingType thingType = thing.getType();
+	bool retVal = false;
+	if (thingType == k4_GroupThingType)
+		retVal = getFlag(_vm->_dungeonMan->getCreatureAttributes(thing), k0x0020_MaskCreatureInfo_levitation);
+	else if (thingType == k14_ProjectileThingType)
+		/* BUG0_26 An explosion may fall in a pit. If a pit is opened while there is an explosion above then the explosion
+		falls into the pit in getMoveResult(). Explosions are not considered as levitating so they are moved when the pit
+		is opened. This function should return true for explosions */
+		retVal = true;
 
-
-	if ((L0695_i_ThingType = thing.getType()) == k4_GroupThingType) {
-		return getFlag(_vm->_dungeonMan->getCreatureAttributes(thing), k0x0020_MaskCreatureInfo_levitation);
-	}
-	if (L0695_i_ThingType == k14_ProjectileThingType) { /* BUG0_26 An explosion may fall in a pit. If a pit is opened while there is an explosion above then the explosion falls into the pit in F0267_MOVE_GetMoveResult_CPSCE. Explosions are not considered as levitating so they are moved when the pit is opened. This function should return true for explosions */
-		return true;
-	}
-	return false;
+	return retVal;
 }
 
 bool MovesensMan::moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY, Thing thing) {


Commit: 1a9f9c54aafa81648bf2400529e4c6d6cb906350
    https://github.com/scummvm/scummvm/commit/1a9f9c54aafa81648bf2400529e4c6d6cb906350
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T20:49:45+02:00

Commit Message:
DM: Fix original bug in isLevitating

Changed paths:
    engines/dm/movesens.cpp



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index d5e941f..38db12e 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -503,10 +503,8 @@ bool MovesensMan::isLevitating(Thing thing) {
 	bool retVal = false;
 	if (thingType == k4_GroupThingType)
 		retVal = getFlag(_vm->_dungeonMan->getCreatureAttributes(thing), k0x0020_MaskCreatureInfo_levitation);
-	else if (thingType == k14_ProjectileThingType)
-		/* BUG0_26 An explosion may fall in a pit. If a pit is opened while there is an explosion above then the explosion
-		falls into the pit in getMoveResult(). Explosions are not considered as levitating so they are moved when the pit
-		is opened. This function should return true for explosions */
+	else if ((thingType == k14_ProjectileThingType) || (thingType == k15_ExplosionThingType))
+	// Fix original bug involving explosions falling in pits
 		retVal = true;
 
 	return retVal;


Commit: e5c1888e8c1f1af0c03c3ac0252d97c458acc5c5
    https://github.com/scummvm/scummvm/commit/e5c1888e8c1f1af0c03c3ac0252d97c458acc5c5
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T22:02:27+02:00

Commit Message:
DM: Some more refactoring in MovesensMan, change return value of getSound()

Changed paths:
    engines/dm/movesens.cpp



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 38db12e..bf18a85 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -511,116 +511,108 @@ bool MovesensMan::isLevitating(Thing thing) {
 }
 
 bool MovesensMan::moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY, Thing thing) {
-	Thing L0697_T_Thing;
-	uint16 L0699_ui_Multiple;
-#define AL0699_ui_Cell                      L0699_ui_Multiple
-#define AL0699_ui_PrimaryDirection          L0699_ui_Multiple
-#define AL0699_ui_ChampionOrCreatureOrdinal L0699_ui_Multiple
-	int16 L0700_i_Multiple;
-#define AL0700_B_CreatureAlive      L0700_i_Multiple
-#define AL0700_i_Distance           L0700_i_Multiple
-#define AL0700_i_SecondaryDirection L0700_i_Multiple
-	Group *L0701_ps_Group;
-	int16 L0702_i_ImpactType;
-	bool L0703_B_CheckDestinationSquareProjectileImpacts;
-	uint16 L0704_ui_ProjectileMapX;
-	uint16 L0705_ui_ProjectileMapY;
-	byte L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[4]; /* This array is used only when moving between two adjacent squares and is used to test projectile impacts when the party or group is in the 'intermediary' step between the two squares. Without this test, in the example below no impact would be detected. In this example, the party moves from the source square on the left (which contains a single champion at cell 2) to the destination square on the right (which contains a single projectile at cell 3).
-																			Party:      Projectiles on target square:   Incorrect result without the test for the intermediary step (the champion would have passed through the projectile without impact):
-																			00    ->    00                         00
-																			01          P0                         P1 */
-	byte L0707_auc_ChampionOrCreatureOrdinalInCell[4]; /* This array has an entry for each cell on the source square, containing the ordinal of the champion or creature (0 if there is no champion or creature at this cell) */
-
-
-	L0703_B_CheckDestinationSquareProjectileImpacts = false;
+	/* This array is used only when moving between two adjacent squares and is used to test projectile
+	impacts when the party or group is in the 'intermediary' step between the two squares. Without
+	this test, in the example below no impact would be detected. In this example, the party moves from
+	the source square on the left (which contains a single champion at cell 2) to the destination square
+	on the right (which contains a single projectile at cell 3).
+	Party:      Projectiles on target square:   Incorrect result without the test for the intermediary step (the champion would have passed through the projectile without impact):
+	00    ->    00                         00
+	01          P0                         P1 */
+	byte intermediaryChampionOrCreatureOrdinalInCell[4]; 
+
+	/* This array has an entry for each cell on the source square, containing the ordinal of the champion
+	or creature (0 if there is no champion or creature at this cell) */
+	byte championOrCreatureOrdinalInCell[4];
+
+	bool checkDestinationSquareProjectileImpacts = false;
 	for (int16 i = 0; i < 4; ++i)
-		L0707_auc_ChampionOrCreatureOrdinalInCell[i] = 0;
+		championOrCreatureOrdinalInCell[i] = 0;
+
+	SquareType impactType;
 	if (thing == Thing::_party) {
-		L0702_i_ImpactType = kM2_ChampionElemType;
-		for (AL0699_ui_Cell = k0_CellNorthWest; AL0699_ui_Cell < k3_CellSouthWest + 1; AL0699_ui_Cell++) {
-			if (_vm->_championMan->getIndexInCell((ViewCell)AL0699_ui_Cell) >= 0) {
-				L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = _vm->indexToOrdinal(AL0699_ui_Cell);
-			}
+		impactType = kM2_ChampionElemType;
+		for (uint16 cellIdx = k0_CellNorthWest; cellIdx < k3_CellSouthWest + 1; cellIdx++) {
+			if (_vm->_championMan->getIndexInCell((ViewCell)cellIdx) >= 0)
+				championOrCreatureOrdinalInCell[cellIdx] = _vm->indexToOrdinal(cellIdx);
 		}
 	} else {
-		L0702_i_ImpactType = kM1_CreatureElemType;
-		L0701_ps_Group = (Group *)_vm->_dungeonMan->getThingData(thing);
-		for (AL0699_ui_Cell = k0_CellNorthWest, AL0700_B_CreatureAlive = false; AL0699_ui_Cell < k3_CellSouthWest + 1; AL0699_ui_Cell++) {
-			AL0700_B_CreatureAlive |= L0701_ps_Group->_health[AL0699_ui_Cell];
-			if (_vm->_groupMan->getCreatureOrdinalInCell(L0701_ps_Group, AL0699_ui_Cell)) {
-				L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = _vm->indexToOrdinal(AL0699_ui_Cell);
-			}
+		impactType = kM1_CreatureElemType;
+		Group *curGroup = (Group *)_vm->_dungeonMan->getThingData(thing);
+		int16 creatureAlive = 0;
+		for (uint16 cellIdx = k0_CellNorthWest; cellIdx < k3_CellSouthWest + 1; cellIdx++) {
+			creatureAlive |= curGroup->_health[cellIdx];
+			if (_vm->_groupMan->getCreatureOrdinalInCell(curGroup, cellIdx))
+				championOrCreatureOrdinalInCell[cellIdx] = _vm->indexToOrdinal(cellIdx);
 		}
-		if (!AL0700_B_CreatureAlive) {
+		if (!creatureAlive)
 			return false;
-		}
 	}
-	if ((destMapX >= 0) && ((abs(srcMapX - destMapX) + abs(srcMapY - destMapY)) == 1)) { /* If source and destination squares are adjacent (if party or group is not being teleported) */
-		AL0699_ui_PrimaryDirection = _vm->_groupMan->getDirsWhereDestIsVisibleFromSource(srcMapX, srcMapY, destMapX, destMapY);
-		AL0700_i_SecondaryDirection = returnNextVal(AL0699_ui_PrimaryDirection);
+	if ((destMapX >= 0) && ((abs(srcMapX - destMapX) + abs(srcMapY - destMapY)) == 1)) {
+		/* If source and destination squares are adjacent (if party or group is not being teleported) */
+		int16 primaryDirection = _vm->_groupMan->getDirsWhereDestIsVisibleFromSource(srcMapX, srcMapY, destMapX, destMapY);
+		int16 secondaryDirection = returnNextVal(primaryDirection);
 		for (int16 i = 0; i < 4; ++i)
-			L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[i] = 0;
+			intermediaryChampionOrCreatureOrdinalInCell[i] = 0;
 
-		L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnPrevVal(AL0699_ui_PrimaryDirection)] = L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection];
-		if (L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnPrevVal(AL0699_ui_PrimaryDirection)]) {
-			L0703_B_CheckDestinationSquareProjectileImpacts = true;
-		}
+		intermediaryChampionOrCreatureOrdinalInCell[returnPrevVal(primaryDirection)] = championOrCreatureOrdinalInCell[primaryDirection];
+		if (intermediaryChampionOrCreatureOrdinalInCell[returnPrevVal(primaryDirection)])
+			checkDestinationSquareProjectileImpacts = true;
 
-		L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnNextVal(AL0700_i_SecondaryDirection)] = L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection];
-		if (L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnNextVal(AL0700_i_SecondaryDirection)]) {
-			L0703_B_CheckDestinationSquareProjectileImpacts = true;
-		}
-		if (!L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection]) {
-			L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection] = L0707_auc_ChampionOrCreatureOrdinalInCell[returnPrevVal(AL0699_ui_PrimaryDirection)];
-		}
-		if (!L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection]) {
-			L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection] = L0707_auc_ChampionOrCreatureOrdinalInCell[returnNextVal(AL0700_i_SecondaryDirection)];
-		}
+		intermediaryChampionOrCreatureOrdinalInCell[returnNextVal(secondaryDirection)] = championOrCreatureOrdinalInCell[secondaryDirection];
+		if (intermediaryChampionOrCreatureOrdinalInCell[returnNextVal(secondaryDirection)])
+			checkDestinationSquareProjectileImpacts = true;
+
+		if (!championOrCreatureOrdinalInCell[primaryDirection])
+			championOrCreatureOrdinalInCell[primaryDirection] = championOrCreatureOrdinalInCell[returnPrevVal(primaryDirection)];
+
+		if (!championOrCreatureOrdinalInCell[secondaryDirection])
+			championOrCreatureOrdinalInCell[secondaryDirection] = championOrCreatureOrdinalInCell[returnNextVal(secondaryDirection)];
 	}
-	L0704_ui_ProjectileMapX = srcMapX; /* Check impacts with projectiles on the source square */
-	L0705_ui_ProjectileMapY = srcMapY;
+	uint16 projectileMapX = srcMapX; /* Check impacts with projectiles on the source square */
+	uint16 projectileMapY = srcMapY;
 T0266017_CheckProjectileImpacts:
-	L0697_T_Thing = _vm->_dungeonMan->getSquareFirstThing(L0704_ui_ProjectileMapX, L0705_ui_ProjectileMapY);
-	while (L0697_T_Thing != Thing::_endOfList) {
-		if (((L0697_T_Thing).getType() == k14_ProjectileThingType) &&
-			(_vm->_timeline->_events[(((Projectile *)_vm->_dungeonMan->_thingData[k14_ProjectileThingType])[(L0697_T_Thing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts) && (AL0699_ui_ChampionOrCreatureOrdinal = L0707_auc_ChampionOrCreatureOrdinalInCell[(L0697_T_Thing).getCell()]) &&
-			_vm->_projexpl->hasProjectileImpactOccurred(L0702_i_ImpactType, srcMapX, srcMapY, _vm->ordinalToIndex(AL0699_ui_ChampionOrCreatureOrdinal), L0697_T_Thing)) {
-			_vm->_projexpl->projectileDeleteEvent(L0697_T_Thing);
-			if (_vm->_projexpl->_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup) {
-				return true;
+	Thing curThing = _vm->_dungeonMan->getSquareFirstThing(projectileMapX, projectileMapY);
+	while (curThing != Thing::_endOfList) {
+		if (((curThing).getType() == k14_ProjectileThingType) &&
+			(_vm->_timeline->_events[(((Projectile *)_vm->_dungeonMan->_thingData[k14_ProjectileThingType])[(curThing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts)) {
+			int16 championOrCreatureOrdinal = championOrCreatureOrdinalInCell[curThing.getCell()];
+			if (championOrCreatureOrdinal && _vm->_projexpl->hasProjectileImpactOccurred(impactType, srcMapX, srcMapY, _vm->ordinalToIndex(championOrCreatureOrdinal), curThing)) {
+				_vm->_projexpl->projectileDeleteEvent(curThing);
+				if (_vm->_projexpl->_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)
+					return true;
+
+				goto T0266017_CheckProjectileImpacts;
 			}
-			goto T0266017_CheckProjectileImpacts;
 		}
-		L0697_T_Thing = _vm->_dungeonMan->getNextThing(L0697_T_Thing);
+		curThing = _vm->_dungeonMan->getNextThing(curThing);
 	}
-	if (L0703_B_CheckDestinationSquareProjectileImpacts) {
-		srcMapX |= ((L0704_ui_ProjectileMapX = destMapX) + 1) << 8; /* Check impacts with projectiles on the destination square */
-		srcMapY |= (L0705_ui_ProjectileMapY = destMapY) << 8;
+	if (checkDestinationSquareProjectileImpacts) {
+		srcMapX |= ((projectileMapX = destMapX) + 1) << 8; /* Check impacts with projectiles on the destination square */
+		srcMapY |= (projectileMapY = destMapY) << 8;
 		for (uint16 i = 0; i < 4; ++i)
-			L0707_auc_ChampionOrCreatureOrdinalInCell[i] = L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[i];
-		L0703_B_CheckDestinationSquareProjectileImpacts = false;
+			championOrCreatureOrdinalInCell[i] = intermediaryChampionOrCreatureOrdinalInCell[i];
+		checkDestinationSquareProjectileImpacts = false;
 		goto T0266017_CheckProjectileImpacts;
 	}
 	return false;
 }
 
 void MovesensMan::addEvent(byte type, byte mapX, byte mapY, byte cell, byte effect, int32 time) {
-	TimelineEvent L0729_s_Event;
-
-	setMapAndTime(L0729_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, time);
-	L0729_s_Event._type = type;
-	L0729_s_Event._priority = 0;
-	L0729_s_Event._B._location._mapX = mapX;
-	L0729_s_Event._B._location._mapY = mapY;
-	L0729_s_Event._C.A._cell = cell;
-	L0729_s_Event._C.A._effect = effect;
-	_vm->_timeline->addEventGetEventIndex(&L0729_s_Event);
+	TimelineEvent newEvent;
+	setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_currMapIndex, time);
+	newEvent._type = type;
+	newEvent._priority = 0;
+	newEvent._B._location._mapX = mapX;
+	newEvent._B._location._mapY = mapY;
+	newEvent._C.A._cell = cell;
+	newEvent._C.A._effect = effect;
+	_vm->_timeline->addEventGetEventIndex(&newEvent);
 }
 
 int16 MovesensMan::getSound(byte creatureType) {
-	if (_vm->_championMan->_partyIsSleeping) {
+	if (_vm->_championMan->_partyIsSleeping)
 		return 35;
-	}
 
 	switch (creatureType) {
 	case k3_CreatureTypeWizardEyeFlyingEye:
@@ -659,7 +651,8 @@ int16 MovesensMan::getSound(byte creatureType) {
 	case k17_CreatureTypeGiantWaspMuncher:
 		return k23_soundMOVE_COUATL_GIANT_WASP_MUNCHER;
 	}
-	return -1000; // if this is returned, it's an error, this should break it good
+
+	return 35;
 }
 
 int16 MovesensMan::getTeleporterRotatedGroupResult(Teleporter *teleporter, Thing thing, uint16 mapIndex) {


Commit: c95620b8dbbd4b0a343c2c44ae144fdcc2d67465
    https://github.com/scummvm/scummvm/commit/c95620b8dbbd4b0a343c2c44ae144fdcc2d67465
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T22:47:23+02:00

Commit Message:
DM: First pass of refactoring of getTeleporterRotatedGroupResult

Changed paths:
    engines/dm/movesens.cpp



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index bf18a85..9c80be0 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -656,236 +656,207 @@ int16 MovesensMan::getSound(byte creatureType) {
 }
 
 int16 MovesensMan::getTeleporterRotatedGroupResult(Teleporter *teleporter, Thing thing, uint16 mapIndex) {
-	int16 L0683_i_Rotation;
-	uint16 L0684_ui_GroupDirections;
-	uint16 L0685_ui_UpdatedGroupDirections;
-	Group *L0686_ps_Group;
-	uint16 L0687_ui_UpdatedGroupCells;
-	int16 L0688_i_CreatureIndex;
-	bool L0689_B_AbsoluteRotation;
-	uint16 L0690_ui_GroupCells;
-	int16 L0691_i_CreatureSize;
-	int16 L0692_i_RelativeRotation;
-
-	L0686_ps_Group = (Group *)_vm->_dungeonMan->getThingData(thing);
-	L0683_i_Rotation = teleporter->getRotation();
-	L0684_ui_GroupDirections = _vm->_groupMan->getGroupDirections(L0686_ps_Group, mapIndex);
-
-	L0689_B_AbsoluteRotation = teleporter->getAbsoluteRotation();
-	if (L0689_B_AbsoluteRotation) {
-		L0685_ui_UpdatedGroupDirections = L0683_i_Rotation;
-	} else {
-		L0685_ui_UpdatedGroupDirections = normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation);
-	}
-
-	L0687_ui_UpdatedGroupCells = _vm->_groupMan->getGroupCells(L0686_ps_Group, mapIndex);
-	if (L0687_ui_UpdatedGroupCells != k255_CreatureTypeSingleCenteredCreature) {
-		L0690_ui_GroupCells = L0687_ui_UpdatedGroupCells;
-		L0691_i_CreatureSize = getFlag(_vm->_dungeonMan->_creatureInfos[L0686_ps_Group->_type]._attributes, k0x0003_MaskCreatureInfo_size);
-		L0692_i_RelativeRotation = normalizeModulo4(4 + L0685_ui_UpdatedGroupDirections - L0684_ui_GroupDirections);
-		for (L0688_i_CreatureIndex = 0; L0688_i_CreatureIndex <= L0686_ps_Group->getCount(); L0688_i_CreatureIndex++) {
-			L0685_ui_UpdatedGroupDirections = _vm->_groupMan->getGroupValueUpdatedWithCreatureValue(L0685_ui_UpdatedGroupDirections, L0688_i_CreatureIndex, L0689_B_AbsoluteRotation ? L0683_i_Rotation : normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation));
-			if (L0691_i_CreatureSize == k0_MaskCreatureSizeQuarter) {
-				L0692_i_RelativeRotation = !L0689_B_AbsoluteRotation;
-				if (L0692_i_RelativeRotation) 
-					L0692_i_RelativeRotation = L0683_i_Rotation;
-			}
-			if (L0692_i_RelativeRotation) {
-				L0687_ui_UpdatedGroupCells = _vm->_groupMan->getGroupValueUpdatedWithCreatureValue(L0687_ui_UpdatedGroupCells, L0688_i_CreatureIndex, normalizeModulo4(L0690_ui_GroupCells + L0692_i_RelativeRotation));
+	Group *group = (Group *)_vm->_dungeonMan->getThingData(thing);
+	Direction rotation = teleporter->getRotation();
+	uint16 groupDirections = _vm->_groupMan->getGroupDirections(group, mapIndex);
+
+	bool absoluteRotation = teleporter->getAbsoluteRotation();
+	uint16 updatedGroupDirections;
+	if (absoluteRotation)
+		updatedGroupDirections = rotation;
+	else
+		updatedGroupDirections = normalizeModulo4(groupDirections + rotation);
+
+	uint16 updatedGroupCells = _vm->_groupMan->getGroupCells(group, mapIndex);
+	if (updatedGroupCells != k255_CreatureTypeSingleCenteredCreature) {
+		int16 groupCells = updatedGroupCells;
+		int16 creatureSize = getFlag(_vm->_dungeonMan->_creatureInfos[group->_type]._attributes, k0x0003_MaskCreatureInfo_size);
+		int16 relativeRotation = normalizeModulo4(4 + updatedGroupDirections - groupDirections);
+		for (int16 creatureIdx = 0; creatureIdx <= group->getCount(); creatureIdx++) {
+			updatedGroupDirections = _vm->_groupMan->getGroupValueUpdatedWithCreatureValue(updatedGroupDirections, creatureIdx, absoluteRotation ? rotation : normalizeModulo4(groupDirections + rotation));
+			if (creatureSize == k0_MaskCreatureSizeQuarter) {
+				relativeRotation = absoluteRotation ? 1 : 0;
+				if (relativeRotation) 
+					relativeRotation = rotation;
 			}
-			L0684_ui_GroupDirections >>= 2;
-			L0690_ui_GroupCells >>= 2;
+			if (relativeRotation)
+				updatedGroupCells = _vm->_groupMan->getGroupValueUpdatedWithCreatureValue(updatedGroupCells, creatureIdx, normalizeModulo4(groupCells + relativeRotation));
+
+			groupDirections >>= 2;
+			groupCells >>= 2;
 		}
 	}
-	_vm->_dungeonMan->setGroupDirections(L0686_ps_Group, L0685_ui_UpdatedGroupDirections, mapIndex);
-	_vm->_dungeonMan->setGroupCells(L0686_ps_Group, L0687_ui_UpdatedGroupCells, mapIndex);
-	if ((mapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0686_ps_Group->setBehaviour(k6_behavior_ATTACK))) {
-		return L0686_ps_Group->getActiveGroupIndex() + 2;
-	}
+	_vm->_dungeonMan->setGroupDirections(group, updatedGroupDirections, mapIndex);
+	_vm->_dungeonMan->setGroupCells(group, updatedGroupCells, mapIndex);
+	if ((mapIndex == _vm->_dungeonMan->_partyMapIndex) && (group->setBehaviour(k6_behavior_ATTACK)))
+		return group->getActiveGroupIndex() + 2;
+
 	return 1;
 }
 
 Thing MovesensMan::getTeleporterRotatedProjectileThing(Teleporter *teleporter, Thing projectileThing) {
-	int16 L0693_i_UpdatedDirection;
-	int16 L0694_i_Rotation;
-
-	L0693_i_UpdatedDirection = _moveResultDir;
-	L0694_i_Rotation = teleporter->getRotation();
-	if (teleporter->getAbsoluteRotation()) {
-		L0693_i_UpdatedDirection = L0694_i_Rotation;
-	} else {
-		L0693_i_UpdatedDirection = normalizeModulo4(L0693_i_UpdatedDirection + L0694_i_Rotation);
-		projectileThing = thingWithNewCell(projectileThing, normalizeModulo4((projectileThing).getCell() + L0694_i_Rotation));
+	int16 updatedDirection = _moveResultDir;
+	int16 rotation = teleporter->getRotation();
+	if (teleporter->getAbsoluteRotation())
+		updatedDirection = rotation;
+	else {
+		updatedDirection = normalizeModulo4(updatedDirection + rotation);
+		projectileThing = thingWithNewCell(projectileThing, normalizeModulo4((projectileThing).getCell() + rotation));
 	}
-	_moveResultDir = L0693_i_UpdatedDirection;
+	_moveResultDir = updatedDirection;
 	return projectileThing;
 }
 
 void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing thing, bool partySquare, bool addThing) {
-	Thing L0766_T_Thing;
-	int16 L0767_i_ThingType;
-	bool L0768_B_TriggerSensor;
-	Sensor *L0769_ps_Sensor;
-	int16 L0770_ui_SensorTriggeredCell;
-	uint16 L0771_ui_ThingType;
-	bool L0772_B_SquareContainsObject;
-	bool L0773_B_SquareContainsGroup;
-	int16 L0774_i_ObjectType;
-	bool L0775_B_SquareContainsThingOfSameType;
-	bool L0776_B_SquareContainsThingOfDifferentType;
-	uint16 L0777_ui_Square;
-	int16 L0778_i_Effect;
-	int16 L0779_i_SensorData;
-
-
+	int16 thingType;
+	int16 objectType;
 	if (thing != Thing::_party) {
-		L0767_i_ThingType = thing.getType();
-		L0774_i_ObjectType = _vm->_objectMan->getObjectType(thing);
+		thingType = thing.getType();
+		objectType = _vm->_objectMan->getObjectType(thing);
 	} else {
-		L0767_i_ThingType = kM1_PartyThingType;
-		L0774_i_ObjectType = kM1_IconIndiceNone;
+		thingType = kM1_PartyThingType;
+		objectType = kM1_IconIndiceNone;
 	}
-	if ((!addThing) && (L0767_i_ThingType != kM1_PartyThingType)) {
+
+	if ((!addThing) && (thingType != kM1_PartyThingType))
 		_vm->_dungeonMan->unlinkThingFromList(thing, Thing(0), mapX, mapY);
-	}
 
-	L0777_ui_Square = _vm->_dungeonMan->_currMapData[mapX][mapY];
-	if (Square(L0777_ui_Square).getType() == k0_WallElemType) {
-		L0770_ui_SensorTriggeredCell = thing.getCell();
-	} else {
-		L0770_ui_SensorTriggeredCell = kM1_CellAny; // this will wrap around
-	}
-	L0772_B_SquareContainsObject = L0773_B_SquareContainsGroup = L0775_B_SquareContainsThingOfSameType = L0776_B_SquareContainsThingOfDifferentType = false;
-	L0766_T_Thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
-	if (L0770_ui_SensorTriggeredCell == kM1_CellAny) {
-		while (L0766_T_Thing != Thing::_endOfList) {
-			if ((L0771_ui_ThingType = (L0766_T_Thing).getType()) == k4_GroupThingType) {
-				L0773_B_SquareContainsGroup = true;
-			} else {
-				if ((L0771_ui_ThingType == k2_TextstringType) && (L0767_i_ThingType == kM1_PartyThingType) && addThing && !partySquare) {
-					_vm->_dungeonMan->decodeText(_vm->_stringBuildBuffer, L0766_T_Thing, k1_TextTypeMessage);
-					_vm->_textMan->printMessage(k15_ColorWhite, _vm->_stringBuildBuffer);
-				} else {
-					if ((L0771_ui_ThingType > k4_GroupThingType) && (L0771_ui_ThingType < k14_ProjectileThingType)) {
-						L0772_B_SquareContainsObject = true;
-						L0775_B_SquareContainsThingOfSameType |= (_vm->_objectMan->getObjectType(L0766_T_Thing) == L0774_i_ObjectType);
-						L0776_B_SquareContainsThingOfDifferentType |= (_vm->_objectMan->getObjectType(L0766_T_Thing) != L0774_i_ObjectType);
-					}
-				}
+	uint16 curSquare = _vm->_dungeonMan->_currMapData[mapX][mapY];
+	int16 sensorTriggeredCell;
+	if (Square(curSquare).getType() == k0_WallElemType)
+		sensorTriggeredCell = thing.getCell();
+	else
+		sensorTriggeredCell = kM1_CellAny; // this will wrap around
+
+	bool squareContainsObject = false;
+	bool squareContainsGroup = false;
+	bool squareContainsThingOfSameType = false;
+	bool squareContainsThingOfDifferentType = false;
+	Thing curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+	if (sensorTriggeredCell == kM1_CellAny) {
+		while (curThing != Thing::_endOfList) {
+			uint16 curThingType = curThing.getType();
+			if (curThingType == k4_GroupThingType)
+				squareContainsGroup = true;
+			else if ((curThingType == k2_TextstringType) && (thingType == kM1_PartyThingType) && addThing && !partySquare) {
+				_vm->_dungeonMan->decodeText(_vm->_stringBuildBuffer, curThing, k1_TextTypeMessage);
+				_vm->_textMan->printMessage(k15_ColorWhite, _vm->_stringBuildBuffer);
+			} else if ((curThingType > k4_GroupThingType) && (curThingType < k14_ProjectileThingType)) {
+				squareContainsObject = true;
+				squareContainsThingOfSameType |= (_vm->_objectMan->getObjectType(curThing) == objectType);
+				squareContainsThingOfDifferentType |= (_vm->_objectMan->getObjectType(curThing) != objectType);
 			}
-			L0766_T_Thing = _vm->_dungeonMan->getNextThing(L0766_T_Thing);
+			curThing = _vm->_dungeonMan->getNextThing(curThing);
 		}
 	} else {
-		while (L0766_T_Thing != Thing::_endOfList) {
-			if ((L0770_ui_SensorTriggeredCell == (L0766_T_Thing).getCell()) && ((L0766_T_Thing).getType() > k4_GroupThingType)) {
-				L0772_B_SquareContainsObject = true;
-				L0775_B_SquareContainsThingOfSameType |= (_vm->_objectMan->getObjectType(L0766_T_Thing) == L0774_i_ObjectType);
-				L0776_B_SquareContainsThingOfDifferentType |= (_vm->_objectMan->getObjectType(L0766_T_Thing) != L0774_i_ObjectType);
+		while (curThing != Thing::_endOfList) {
+			if ((sensorTriggeredCell == (curThing).getCell()) && ((curThing).getType() > k4_GroupThingType)) {
+				squareContainsObject = true;
+				squareContainsThingOfSameType |= (_vm->_objectMan->getObjectType(curThing) == objectType);
+				squareContainsThingOfDifferentType |= (_vm->_objectMan->getObjectType(curThing) != objectType);
 			}
-			L0766_T_Thing = _vm->_dungeonMan->getNextThing(L0766_T_Thing);
+			curThing = _vm->_dungeonMan->getNextThing(curThing);
 		}
 	}
-	if (addThing && (L0767_i_ThingType != kM1_PartyThingType)) {
+	if (addThing && (thingType != kM1_PartyThingType))
 		_vm->_dungeonMan->linkThingToList(thing, Thing(0), mapX, mapY);
-	}
-	L0766_T_Thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
-	while (L0766_T_Thing != Thing::_endOfList) {
-		L0771_ui_ThingType = (L0766_T_Thing).getType();
-		if (L0771_ui_ThingType == k3_SensorThingType) {
-			L0769_ps_Sensor = (Sensor *)_vm->_dungeonMan->getThingData(L0766_T_Thing);
-			if ((L0769_ps_Sensor)->getType() == k0_SensorDisabled)
+
+	curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+	while (curThing != Thing::_endOfList) {
+		uint16 curThingType = curThing.getType();
+		if (curThingType == k3_SensorThingType) {
+			Sensor *curSensor = (Sensor *)_vm->_dungeonMan->getThingData(curThing);
+			if (curSensor->getType() == k0_SensorDisabled)
 				goto T0276079;
-			L0779_i_SensorData = L0769_ps_Sensor->getData();
-			L0768_B_TriggerSensor = addThing;
-			if (L0770_ui_SensorTriggeredCell == kM1_CellAny) {
-				switch (L0769_ps_Sensor->getType()) {
+			int16 curSensorData = curSensor->getData();
+			bool triggerSensor = addThing;
+			if (sensorTriggeredCell == kM1_CellAny) {
+				switch (curSensor->getType()) {
 				case k1_SensorFloorTheronPartyCreatureObj:
-					if (partySquare || L0772_B_SquareContainsObject || L0773_B_SquareContainsGroup) /* BUG0_30 A floor sensor is not triggered when you put an object on the floor if a levitating creature is present on the same square. The condition to determine if the sensor should be triggered checks if there is a creature on the square but does not check whether the creature is levitating. While it is normal not to trigger the sensor if there is a non levitating creature on the square (because it was already triggered by the creature itself), a levitating creature should not prevent triggering the sensor with an object. */
+					if (partySquare || squareContainsObject || squareContainsGroup) /* BUG0_30 A floor sensor is not triggered when you put an object on the floor if a levitating creature is present on the same square. The condition to determine if the sensor should be triggered checks if there is a creature on the square but does not check whether the creature is levitating. While it is normal not to trigger the sensor if there is a non levitating creature on the square (because it was already triggered by the creature itself), a levitating creature should not prevent triggering the sensor with an object. */
 						goto T0276079;
 					break;
 				case k2_SensorFloorTheronPartyCreature:
-					if ((L0767_i_ThingType > k4_GroupThingType) || partySquare || L0773_B_SquareContainsGroup)
+					if ((thingType > k4_GroupThingType) || partySquare || squareContainsGroup)
 						goto T0276079;
 					break;
 				case k3_SensorFloorParty:
-					if ((L0767_i_ThingType != kM1_PartyThingType) || (_vm->_championMan->_partyChampionCount == 0))
+					if ((thingType != kM1_PartyThingType) || (_vm->_championMan->_partyChampionCount == 0))
 						goto T0276079;
-					if (L0779_i_SensorData == 0) {
+
+					if (curSensorData == 0) {
 						if (partySquare)
 							goto T0276079;
-					} else {
-						if (!addThing) {
-							L0768_B_TriggerSensor = false;
-						} else {
-							L0768_B_TriggerSensor = (L0779_i_SensorData == _vm->indexToOrdinal(_vm->_dungeonMan->_partyDir));
-						}
-					}
+					} else if (!addThing)
+						triggerSensor = false;
+					else
+						triggerSensor = (curSensorData == _vm->indexToOrdinal(_vm->_dungeonMan->_partyDir));
 					break;
 				case k4_SensorFloorObj:
-					if ((L0779_i_SensorData != _vm->_objectMan->getObjectType(thing)) || L0775_B_SquareContainsThingOfSameType)
+					if ((curSensorData != _vm->_objectMan->getObjectType(thing)) || squareContainsThingOfSameType)
 						goto T0276079;
 					break;
 				case k5_SensorFloorPartyOnStairs:
-					if ((L0767_i_ThingType != kM1_PartyThingType) || (Square(L0777_ui_Square).getType() != k3_StairsElemType))
+					if ((thingType != kM1_PartyThingType) || (Square(curSquare).getType() != k3_StairsElemType))
 						goto T0276079;
 					break;
 				case k6_SensorFloorGroupGenerator:
 					goto T0276079;
 				case k7_SensorFloorCreature:
-					if ((L0767_i_ThingType > k4_GroupThingType) || (L0767_i_ThingType == kM1_PartyThingType) || L0773_B_SquareContainsGroup)
+					if ((thingType > k4_GroupThingType) || (thingType == kM1_PartyThingType) || squareContainsGroup)
 						goto T0276079;
 					break;
 				case k8_SensorFloorPartyPossession:
-					if (L0767_i_ThingType != kM1_PartyThingType)
+					if (thingType != kM1_PartyThingType)
 						goto T0276079;
-					L0768_B_TriggerSensor = isObjcetInPartyPossession(L0779_i_SensorData);
+					triggerSensor = isObjcetInPartyPossession(curSensorData);
 					break;
 				case k9_SensorFloorVersionChecker:
-					if ((L0767_i_ThingType != kM1_PartyThingType) || !addThing || partySquare)
+					if ((thingType != kM1_PartyThingType) || !addThing || partySquare)
 						goto T0276079;
 					// Strangerke: 20 is a hardcoded version of the game. later version uses 21. Not present in the original dungeons anyway.
-					L0768_B_TriggerSensor = (L0779_i_SensorData <= 20);
+					triggerSensor = (curSensorData <= 20);
 					break;
 				default:
 					goto T0276079;
 				}
 			} else {
-				if (L0770_ui_SensorTriggeredCell != (L0766_T_Thing).getCell())
+				if (sensorTriggeredCell != (curThing).getCell())
 					goto T0276079;
-				switch (L0769_ps_Sensor->getType()) {
+				switch (curSensor->getType()) {
 				case k1_SensorWallOrnClick:
-					if (L0772_B_SquareContainsObject)
+					if (squareContainsObject)
 						goto T0276079;
 					break;
 				case k2_SensorWallOrnClickWithAnyObj:
-					if (L0775_B_SquareContainsThingOfSameType || (L0769_ps_Sensor->getData() != _vm->_objectMan->getObjectType(thing)))
+					if (squareContainsThingOfSameType || (curSensor->getData() != _vm->_objectMan->getObjectType(thing)))
 						goto T0276079;
 					break;
 				case k3_SensorWallOrnClickWithSpecObj:
-					if (L0776_B_SquareContainsThingOfDifferentType || (L0769_ps_Sensor->getData() == _vm->_objectMan->getObjectType(thing)))
+					if (squareContainsThingOfDifferentType || (curSensor->getData() == _vm->_objectMan->getObjectType(thing)))
 						goto T0276079;
 					break;
 				default:
 					goto T0276079;
 				}
 			}
-			L0768_B_TriggerSensor ^= L0769_ps_Sensor->getAttrRevertEffectA();
-			L0778_i_Effect = L0769_ps_Sensor->getAttrEffectA();
-			if (L0778_i_Effect == k3_SensorEffHold) {
-				L0778_i_Effect = L0768_B_TriggerSensor ? k0_SensorEffSet : k1_SensorEffClear;
-			} else if (!L0768_B_TriggerSensor)
+			triggerSensor ^= curSensor->getAttrRevertEffectA();
+			int16 curSensorEffect = curSensor->getAttrEffectA();
+			if (curSensorEffect == k3_SensorEffHold)
+				curSensorEffect = triggerSensor ? k0_SensorEffSet : k1_SensorEffClear;
+			else if (!triggerSensor)
 				goto T0276079;
 
-			if (L0769_ps_Sensor->getAttrAudibleA())
+			if (curSensor->getAttrAudibleA())
 				_vm->_sound->requestPlay(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized);
 
-			triggerEffect(L0769_ps_Sensor, L0778_i_Effect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
+			triggerEffect(curSensor, curSensorEffect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
 			goto T0276079;
 		}
-		if (L0771_ui_ThingType >= k4_GroupThingType)
+		if (curThingType >= k4_GroupThingType)
 			break;
 T0276079:
-		L0766_T_Thing = _vm->_dungeonMan->getNextThing(L0766_T_Thing);
+		curThing = _vm->_dungeonMan->getNextThing(curThing);
 	}
 	processRotationEffect();
 }


Commit: 91fe53762d4aaa69ec428af89cf6ecc514a8b3f3
    https://github.com/scummvm/scummvm/commit/91fe53762d4aaa69ec428af89cf6ecc514a8b3f3
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T23:13:30+02:00

Commit Message:
DM: First pass of refactoring in isObjcetInPartyPossession

Changed paths:
    engines/dm/movesens.cpp



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 9c80be0..3458cdf 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -862,43 +862,38 @@ T0276079:
 }
 
 bool MovesensMan::isObjcetInPartyPossession(int16 objectType) {
-	int16 L0742_i_ChampionIndex;
-	uint16 L0743_ui_SlotIndex = 0;
-	Thing L0744_T_Thing = Thing::_none;
-	Champion *L0745_ps_Champion;
-	Thing *L0746_pT_Thing = nullptr;
-	int16 L0747_i_ObjectType;
-	bool L0748_B_LeaderHandObjectProcessed;
-	Container *L0749_ps_Container;
-
-
-	L0748_B_LeaderHandObjectProcessed = false;
-	for (L0742_i_ChampionIndex = k0_ChampionFirst, L0745_ps_Champion = _vm->_championMan->_champions; L0742_i_ChampionIndex < _vm->_championMan->_partyChampionCount; L0742_i_ChampionIndex++, L0745_ps_Champion++) {
-		if (L0745_ps_Champion->_currHealth) {
-			L0746_pT_Thing = L0745_ps_Champion->_slots;
-			for (L0743_ui_SlotIndex = k0_ChampionSlotReadyHand; (L0743_ui_SlotIndex < k30_ChampionSlotChest_1) && !L0748_B_LeaderHandObjectProcessed; L0743_ui_SlotIndex++) {
-				L0744_T_Thing = *L0746_pT_Thing++;
+	bool leaderHandObjectProcessed = false;
+	Champion *curChampion = _vm->_championMan->_champions;
+	int16 championIdx;
+	uint16 slotIdx = 0;
+	Thing curThing;
+	Thing *curSlotThing = nullptr;
+	for (championIdx = k0_ChampionFirst; championIdx < _vm->_championMan->_partyChampionCount; championIdx++, curChampion++) {
+		if (curChampion->_currHealth) {
+			curSlotThing = curChampion->_slots;
+			for (slotIdx = k0_ChampionSlotReadyHand; (slotIdx < k30_ChampionSlotChest_1) && !leaderHandObjectProcessed; slotIdx++) {
+				curThing = *curSlotThing++;
 T0274003:
-				L0747_i_ObjectType = _vm->_objectMan->getObjectType(L0744_T_Thing);
-				if (L0747_i_ObjectType == objectType) {
+				int16 objectType = _vm->_objectMan->getObjectType(curThing);
+				if (objectType == objectType)
 					return true;
-				}
-				if (L0747_i_ObjectType == k144_IconIndiceContainerChestClosed) {
-					L0749_ps_Container = (Container *)_vm->_dungeonMan->getThingData(L0744_T_Thing);
-					L0744_T_Thing = L0749_ps_Container->getSlot();
-					while (L0744_T_Thing != Thing::_endOfList) {
-						if (_vm->_objectMan->getObjectType(L0744_T_Thing) == objectType) {
+
+				if (objectType == k144_IconIndiceContainerChestClosed) {
+					Container *container = (Container *)_vm->_dungeonMan->getThingData(curThing);
+					curThing = container->getSlot();
+					while (curThing != Thing::_endOfList) {
+						if (_vm->_objectMan->getObjectType(curThing) == objectType)
 							return true;
-						}
-						L0744_T_Thing = _vm->_dungeonMan->getNextThing(L0744_T_Thing);
+
+						curThing = _vm->_dungeonMan->getNextThing(curThing);
 					}
 				}
 			}
 		}
 	}
-	if (!L0748_B_LeaderHandObjectProcessed) {
-		L0748_B_LeaderHandObjectProcessed = true;
-		L0744_T_Thing = _vm->_championMan->_leaderHandObject;
+	if (!leaderHandObjectProcessed) {
+		leaderHandObjectProcessed = true;
+		curThing = _vm->_championMan->_leaderHandObject;
 		goto T0274003;
 	}
 	return false;


Commit: 47741742f52855b47306120e6c1d43cfbb196a2b
    https://github.com/scummvm/scummvm/commit/47741742f52855b47306120e6c1d43cfbb196a2b
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T23:18:11+02:00

Commit Message:
DM: Fix typo in the name of isObjectInPartyPossession, get rid of the GOTO

Changed paths:
    engines/dm/movesens.cpp
    engines/dm/movesens.h



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 3458cdf..fe94cb7 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -809,7 +809,7 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 				case k8_SensorFloorPartyPossession:
 					if (thingType != kM1_PartyThingType)
 						goto T0276079;
-					triggerSensor = isObjcetInPartyPossession(curSensorData);
+					triggerSensor = isObjectInPartyPossession(curSensorData);
 					break;
 				case k9_SensorFloorVersionChecker:
 					if ((thingType != kM1_PartyThingType) || !addThing || partySquare)
@@ -861,7 +861,7 @@ T0276079:
 	processRotationEffect();
 }
 
-bool MovesensMan::isObjcetInPartyPossession(int16 objectType) {
+bool MovesensMan::isObjectInPartyPossession(int16 objectType) {
 	bool leaderHandObjectProcessed = false;
 	Champion *curChampion = _vm->_championMan->_champions;
 	int16 championIdx;
@@ -871,14 +871,19 @@ bool MovesensMan::isObjcetInPartyPossession(int16 objectType) {
 	for (championIdx = k0_ChampionFirst; championIdx < _vm->_championMan->_partyChampionCount; championIdx++, curChampion++) {
 		if (curChampion->_currHealth) {
 			curSlotThing = curChampion->_slots;
-			for (slotIdx = k0_ChampionSlotReadyHand; (slotIdx < k30_ChampionSlotChest_1) && !leaderHandObjectProcessed; slotIdx++) {
-				curThing = *curSlotThing++;
-T0274003:
-				int16 objectType = _vm->_objectMan->getObjectType(curThing);
-				if (objectType == objectType)
+			for (slotIdx = k0_ChampionSlotReadyHand; (slotIdx < k30_ChampionSlotChest_1) || !leaderHandObjectProcessed; slotIdx++) {
+				if (slotIdx < k30_ChampionSlotChest_1)
+					curThing = *curSlotThing++;
+				else {
+					leaderHandObjectProcessed = true;
+					curThing = _vm->_championMan->_leaderHandObject;
+				}
+
+				int16 curObjectType = _vm->_objectMan->getObjectType(curThing);
+				if (curObjectType == objectType)
 					return true;
 
-				if (objectType == k144_IconIndiceContainerChestClosed) {
+				if (curObjectType == k144_IconIndiceContainerChestClosed) {
 					Container *container = (Container *)_vm->_dungeonMan->getThingData(curThing);
 					curThing = container->getSlot();
 					while (curThing != Thing::_endOfList) {
@@ -891,11 +896,6 @@ T0274003:
 			}
 		}
 	}
-	if (!leaderHandObjectProcessed) {
-		leaderHandObjectProcessed = true;
-		curThing = _vm->_championMan->_leaderHandObject;
-		goto T0274003;
-	}
 	return false;
 }
 
diff --git a/engines/dm/movesens.h b/engines/dm/movesens.h
index ce023bc..7746fca 100644
--- a/engines/dm/movesens.h
+++ b/engines/dm/movesens.h
@@ -60,7 +60,7 @@ public:
 	int16 getTeleporterRotatedGroupResult(Teleporter *teleporter, Thing thing, uint16 mapIndex);// @ F0262_MOVE_GetTeleporterRotatedGroupResult
 	Thing getTeleporterRotatedProjectileThing(Teleporter *teleporter, Thing projectileThing); // @ F0263_MOVE_GetTeleporterRotatedProjectileThing
 	void processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing thing, bool partySquare, bool addThing);// @ F0276_SENSOR_ProcessThingAdditionOrRemoval
-	bool isObjcetInPartyPossession(int16 objectType); // @ F0274_SENSOR_IsObjectInPartyPossession
+	bool isObjectInPartyPossession(int16 objectType); // @ F0274_SENSOR_IsObjectInPartyPossession
 	void triggerEffect(Sensor *sensor, int16 effect, int16 mapX, int16 mapY, uint16 cell); // @ F0272_SENSOR_TriggerEffect
 	void triggerLocalEffect(int16 localEffect, int16 effX, int16 effY, int16 effCell); // @ F0270_SENSOR_TriggerLocalEffect
 	void addSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly); // @ F0269_SENSOR_AddSkillExperience


Commit: d6b2ea67b03a8bf635fb109c375d6de7e726399d
    https://github.com/scummvm/scummvm/commit/d6b2ea67b03a8bf635fb109c375d6de7e726399d
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T23:35:58+02:00

Commit Message:
DM: More polishing in MovesensMan

Changed paths:
    engines/dm/movesens.cpp



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index fe94cb7..d27ef86 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -65,7 +65,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 	while (thingBeingProcessed != Thing::_endOfList) {
 		ThingType thingType = thingBeingProcessed.getType();
 		if (thingType == k3_SensorThingType)
-			sensorCountToProcessPerCell[(thingBeingProcessed).getCell()]++;
+			sensorCountToProcessPerCell[thingBeingProcessed.getCell()]++;
 		else if (thingType >= k4_GroupThingType)
 			break;
 
@@ -74,7 +74,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 	Thing lastProcessedThing = thingBeingProcessed = squareFirstThing;
 	while (thingBeingProcessed != Thing::_endOfList) {
 		bool skipToNextThing = false;
-		uint16 ProcessedThingType = (thingBeingProcessed).getType();
+		uint16 ProcessedThingType = thingBeingProcessed.getType();
 		if (ProcessedThingType == k3_SensorThingType) {
 			int16 cellIdx = thingBeingProcessed.getCell();
 			sensorCountToProcessPerCell[cellIdx]--;
@@ -574,8 +574,8 @@ bool MovesensMan::moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMapY, i
 T0266017_CheckProjectileImpacts:
 	Thing curThing = _vm->_dungeonMan->getSquareFirstThing(projectileMapX, projectileMapY);
 	while (curThing != Thing::_endOfList) {
-		if (((curThing).getType() == k14_ProjectileThingType) &&
-			(_vm->_timeline->_events[(((Projectile *)_vm->_dungeonMan->_thingData[k14_ProjectileThingType])[(curThing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts)) {
+		if ((curThing.getType() == k14_ProjectileThingType) &&
+			(_vm->_timeline->_events[(((Projectile *)_vm->_dungeonMan->_thingData[k14_ProjectileThingType])[curThing.getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts)) {
 			int16 championOrCreatureOrdinal = championOrCreatureOrdinalInCell[curThing.getCell()];
 			if (championOrCreatureOrdinal && _vm->_projexpl->hasProjectileImpactOccurred(impactType, srcMapX, srcMapY, _vm->ordinalToIndex(championOrCreatureOrdinal), curThing)) {
 				_vm->_projexpl->projectileDeleteEvent(curThing);
@@ -701,7 +701,7 @@ Thing MovesensMan::getTeleporterRotatedProjectileThing(Teleporter *teleporter, T
 		updatedDirection = rotation;
 	else {
 		updatedDirection = normalizeModulo4(updatedDirection + rotation);
-		projectileThing = thingWithNewCell(projectileThing, normalizeModulo4((projectileThing).getCell() + rotation));
+		projectileThing = thingWithNewCell(projectileThing, normalizeModulo4(projectileThing.getCell() + rotation));
 	}
 	_moveResultDir = updatedDirection;
 	return projectileThing;
@@ -750,7 +750,7 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 		}
 	} else {
 		while (curThing != Thing::_endOfList) {
-			if ((sensorTriggeredCell == (curThing).getCell()) && ((curThing).getType() > k4_GroupThingType)) {
+			if ((sensorTriggeredCell == curThing.getCell()) && (curThing.getType() > k4_GroupThingType)) {
 				squareContainsObject = true;
 				squareContainsThingOfSameType |= (_vm->_objectMan->getObjectType(curThing) == objectType);
 				squareContainsThingOfDifferentType |= (_vm->_objectMan->getObjectType(curThing) != objectType);
@@ -821,7 +821,7 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 					goto T0276079;
 				}
 			} else {
-				if (sensorTriggeredCell != (curThing).getCell())
+				if (sensorTriggeredCell != curThing.getCell())
 					goto T0276079;
 				switch (curSensor->getType()) {
 				case k1_SensorWallOrnClick:
@@ -900,38 +900,33 @@ bool MovesensMan::isObjectInPartyPossession(int16 objectType) {
 }
 
 void MovesensMan::triggerEffect(Sensor *sensor, int16 effect, int16 mapX, int16 mapY, uint16 cell) {
-	byte g59_squareTypeToEventType[7] = { // @ G0059_auc_Graphic562_SquareTypeToEventType
+	TimelineEventType squareTypeToEventTypeArray[7] = { // @ G0059_auc_Graphic562_SquareTypeToEventType
 		k6_TMEventTypeWall,
 		k5_TMEventTypeCorridor,
 		k9_TMEventTypePit,
 		k0_TMEventTypeNone,
 		k10_TMEventTypeDoor,
 		k8_TMEventTypeTeleporter,
-		k7_TMEventTypeFakeWall}; /* 1 byte of padding inserted by compiler */
+		k7_TMEventTypeFakeWall
+	};
 
-	int16 L0736_i_TargetMapX;
-	int16 L0737_i_TargetMapY;
-	int32 L0738_l_Time;
-	uint16 L0739_ui_SquareType;
-	uint16 L0740_ui_TargetCell;
-
-
-	if (sensor->getAttrOnlyOnce()) {
+	if (sensor->getAttrOnlyOnce())
 		sensor->setTypeDisabled();
-	}
-	L0738_l_Time = _vm->_gameTime + sensor->getAttrValue();
-	if (sensor->getAttrLocalEffect()) {
+
+	int32 endTime = _vm->_gameTime + sensor->getAttrValue();
+	if (sensor->getAttrLocalEffect())
 		triggerLocalEffect(sensor->getActionLocalEffect(), mapX, mapY, cell);
-	} else {
-		L0736_i_TargetMapX = sensor->getActionTargetMapX();
-		L0737_i_TargetMapY = sensor->getActionTargetMapY();
-		L0739_ui_SquareType = Square(_vm->_dungeonMan->_currMapData[L0736_i_TargetMapX][L0737_i_TargetMapY]).getType();
-		if (L0739_ui_SquareType == k0_ElementTypeWall) {
-			L0740_ui_TargetCell = sensor->getActionTargetCell();
-		} else {
-			L0740_ui_TargetCell = k0_CellNorthWest;
-		}
-		addEvent(g59_squareTypeToEventType[L0739_ui_SquareType], L0736_i_TargetMapX, L0737_i_TargetMapY, L0740_ui_TargetCell, effect, L0738_l_Time);
+	else {
+		int16 targetMapX = sensor->getActionTargetMapX();
+		int16 targetMapY = sensor->getActionTargetMapY();
+		SquareType curSquareType = Square(_vm->_dungeonMan->_currMapData[targetMapX][targetMapY]).getType();
+		uint16 targetCell;
+		if (curSquareType == k0_ElementTypeWall)
+			targetCell = sensor->getActionTargetCell();
+		else
+			targetCell = k0_CellNorthWest;
+
+		addEvent(squareTypeToEventTypeArray[curSquareType], targetMapX, targetMapY, targetCell, effect, endTime);
 	}
 }
 
@@ -947,85 +942,73 @@ void MovesensMan::triggerLocalEffect(int16 localEffect, int16 effX, int16 effY,
 }
 
 void MovesensMan::addSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly) {
-
 	if (leaderOnly) {
-		if (_vm->_championMan->_leaderIndex != kM1_ChampionNone) {
+		if (_vm->_championMan->_leaderIndex != kM1_ChampionNone)
 			_vm->_championMan->addSkillExperience(_vm->_championMan->_leaderIndex, skillIndex, exp);
-		}
 	} else {
 		exp /= _vm->_championMan->_partyChampionCount;
-		Champion *L0731_ps_Champion = _vm->_championMan->_champions;
-		for (int16 L0730_i_ChampionIndex = k0_ChampionFirst; L0730_i_ChampionIndex < _vm->_championMan->_partyChampionCount; L0730_i_ChampionIndex++, L0731_ps_Champion++) {
-			if (L0731_ps_Champion->_currHealth) {
-				_vm->_championMan->addSkillExperience(L0730_i_ChampionIndex, skillIndex, exp);
-			}
+		Champion *curChampion = _vm->_championMan->_champions;
+		for (int16 championIdx = k0_ChampionFirst; championIdx < _vm->_championMan->_partyChampionCount; championIdx++, curChampion++) {
+			if (curChampion->_currHealth)
+				_vm->_championMan->addSkillExperience(championIdx, skillIndex, exp);
 		}
 	}
 }
 
 void MovesensMan::processRotationEffect() {
-	Thing L0732_T_FirstSensorThing;
-	Thing L0733_T_LastSensorThing;
-	Sensor *L0734_ps_FirstSensor;
-	Sensor *L0735_ps_LastSensor;
-
-
-	if (_sensorRotationEffect == kM1_SensorEffNone) {
+	if (_sensorRotationEffect == kM1_SensorEffNone)
 		return;
-	}
+
 	switch (_sensorRotationEffect) {
 	case k1_SensorEffClear:
 	case k2_SensorEffToggle:
-		L0732_T_FirstSensorThing = _vm->_dungeonMan->getSquareFirstThing(_sensorRotationEffMapX, _sensorRotationEffMapY);
-		while (((L0732_T_FirstSensorThing).getType() != k3_SensorThingType) || ((_sensorRotationEffCell != kM1_CellAny) && ((L0732_T_FirstSensorThing).getCell() != _sensorRotationEffCell))) {
-			L0732_T_FirstSensorThing = _vm->_dungeonMan->getNextThing(L0732_T_FirstSensorThing);
+		Thing firstSensorThing = _vm->_dungeonMan->getSquareFirstThing(_sensorRotationEffMapX, _sensorRotationEffMapY);
+		while ((firstSensorThing.getType() != k3_SensorThingType)
+			|| ((_sensorRotationEffCell != kM1_CellAny) && (firstSensorThing.getCell() != _sensorRotationEffCell))) {
+			firstSensorThing = _vm->_dungeonMan->getNextThing(firstSensorThing);
 		}
-		L0734_ps_FirstSensor = (Sensor *)_vm->_dungeonMan->getThingData(L0732_T_FirstSensorThing);
-		L0733_T_LastSensorThing = L0734_ps_FirstSensor->getNextThing();
-		while ((L0733_T_LastSensorThing != Thing::_endOfList) && (((L0733_T_LastSensorThing).getType() != k3_SensorThingType) || ((_sensorRotationEffCell != kM1_CellAny) && ((L0733_T_LastSensorThing).getCell() != _sensorRotationEffCell)))) {
-			L0733_T_LastSensorThing = _vm->_dungeonMan->getNextThing(L0733_T_LastSensorThing);
+		Sensor *firstSensor = (Sensor *)_vm->_dungeonMan->getThingData(firstSensorThing);
+		Thing lastSensorThing = firstSensor->getNextThing();
+		while ((lastSensorThing != Thing::_endOfList)
+		    && ((lastSensorThing.getType() != k3_SensorThingType)
+				|| ((_sensorRotationEffCell != kM1_CellAny) && (lastSensorThing.getCell() != _sensorRotationEffCell)))) {
+			lastSensorThing = _vm->_dungeonMan->getNextThing(lastSensorThing);
 		}
-		if (L0733_T_LastSensorThing == Thing::_endOfList)
+		if (lastSensorThing == Thing::_endOfList)
 			break;
-		_vm->_dungeonMan->unlinkThingFromList(L0732_T_FirstSensorThing, Thing(0), _sensorRotationEffMapX, _sensorRotationEffMapY);
-		L0735_ps_LastSensor = (Sensor *)_vm->_dungeonMan->getThingData(L0733_T_LastSensorThing);
-		L0733_T_LastSensorThing = _vm->_dungeonMan->getNextThing(L0733_T_LastSensorThing);
-		while (((L0733_T_LastSensorThing != Thing::_endOfList) && ((L0733_T_LastSensorThing).getType() == k3_SensorThingType))) {
-			if ((_sensorRotationEffCell == kM1_CellAny) || ((L0733_T_LastSensorThing).getCell() == _sensorRotationEffCell)) {
-				L0735_ps_LastSensor = (Sensor *)_vm->_dungeonMan->getThingData(L0733_T_LastSensorThing);
-			}
-			L0733_T_LastSensorThing = _vm->_dungeonMan->getNextThing(L0733_T_LastSensorThing);
+		_vm->_dungeonMan->unlinkThingFromList(firstSensorThing, Thing(0), _sensorRotationEffMapX, _sensorRotationEffMapY);
+		Sensor *lastSensor = (Sensor *)_vm->_dungeonMan->getThingData(lastSensorThing);
+		lastSensorThing = _vm->_dungeonMan->getNextThing(lastSensorThing);
+		while (((lastSensorThing != Thing::_endOfList) && (lastSensorThing.getType() == k3_SensorThingType))) {
+			if ((_sensorRotationEffCell == kM1_CellAny) || (lastSensorThing.getCell() == _sensorRotationEffCell))
+				lastSensor = (Sensor *)_vm->_dungeonMan->getThingData(lastSensorThing);
+			lastSensorThing = _vm->_dungeonMan->getNextThing(lastSensorThing);
 		}
-		L0734_ps_FirstSensor->setNextThing(L0735_ps_LastSensor->getNextThing());
-		L0735_ps_LastSensor->setNextThing(L0732_T_FirstSensorThing);
+		firstSensor->setNextThing(lastSensor->getNextThing());
+		lastSensor->setNextThing(firstSensorThing);
 	}
 	_sensorRotationEffect = kM1_SensorEffNone;
 }
 
 void MovesensMan::createEventMoveGroup(Thing groupThing, int16 mapX, int16 mapY, int16 mapIndex, bool audible) {
-	TimelineEvent L0696_s_Event;
-
-	setMapAndTime(L0696_s_Event._mapTime, mapIndex, _vm->_gameTime + 5);
-	L0696_s_Event._type = audible ? k61_TMEventTypeMoveGroupAudible : k60_TMEventTypeMoveGroupSilent;
-	L0696_s_Event._priority = 0;
-	L0696_s_Event._B._location._mapX = mapX;
-	L0696_s_Event._B._location._mapY = mapY;
-	L0696_s_Event._C._slot = groupThing.toUint16();
-	_vm->_timeline->addEventGetEventIndex(&L0696_s_Event);
+	TimelineEvent newEvent;
+	setMapAndTime(newEvent._mapTime, mapIndex, _vm->_gameTime + 5);
+	newEvent._type = audible ? k61_TMEventTypeMoveGroupAudible : k60_TMEventTypeMoveGroupSilent;
+	newEvent._priority = 0;
+	newEvent._B._location._mapX = mapX;
+	newEvent._B._location._mapY = mapY;
+	newEvent._C._slot = groupThing.toUint16();
+	_vm->_timeline->addEventGetEventIndex(&newEvent);
 }
 
 Thing MovesensMan::getObjectOfTypeInCell(int16 mapX, int16 mapY, int16 cell, int16 objectType) {
-	Thing L0741_T_Thing;
-
-
-	L0741_T_Thing = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
-	while (L0741_T_Thing != Thing::_endOfList) {
-		if (_vm->_objectMan->getObjectType(L0741_T_Thing) == objectType) {
-			if ((cell == kM1_CellAny) || ((L0741_T_Thing.getCell()) == cell)) {
-				return L0741_T_Thing;
-			}
+	Thing curThing = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
+	while (curThing != Thing::_endOfList) {
+		if (_vm->_objectMan->getObjectType(curThing) == objectType) {
+			if ((cell == kM1_CellAny) || (curThing.getCell() == cell))
+				return curThing;
 		}
-		L0741_T_Thing = _vm->_dungeonMan->getNextThing(L0741_T_Thing);
+		curThing = _vm->_dungeonMan->getNextThing(curThing);
 	}
 	return Thing::_none;
 }


Commit: 6e404ec0bc98eddf51749f94f9a9ffa7884b9119
    https://github.com/scummvm/scummvm/commit/6e404ec0bc98eddf51749f94f9a9ffa7884b9119
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-04T23:58:51+02:00

Commit Message:
DM: Small refactoring in processThingAdditionOrRemoval

Changed paths:
    engines/dm/movesens.cpp



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index d27ef86..2cc1760 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -709,7 +709,7 @@ Thing MovesensMan::getTeleporterRotatedProjectileThing(Teleporter *teleporter, T
 
 void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing thing, bool partySquare, bool addThing) {
 	int16 thingType;
-	int16 objectType;
+	IconIndice objectType;
 	if (thing != Thing::_party) {
 		thingType = thing.getType();
 		objectType = _vm->_objectMan->getObjectType(thing);
@@ -721,9 +721,9 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 	if ((!addThing) && (thingType != kM1_PartyThingType))
 		_vm->_dungeonMan->unlinkThingFromList(thing, Thing(0), mapX, mapY);
 
-	uint16 curSquare = _vm->_dungeonMan->_currMapData[mapX][mapY];
+	Square curSquare = Square(_vm->_dungeonMan->_currMapData[mapX][mapY]);
 	int16 sensorTriggeredCell;
-	if (Square(curSquare).getType() == k0_WallElemType)
+	if (curSquare.getType() == k0_WallElemType)
 		sensorTriggeredCell = thing.getCell();
 	else
 		sensorTriggeredCell = kM1_CellAny; // this will wrap around
@@ -797,7 +797,7 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 						goto T0276079;
 					break;
 				case k5_SensorFloorPartyOnStairs:
-					if ((thingType != kM1_PartyThingType) || (Square(curSquare).getType() != k3_StairsElemType))
+					if ((thingType != kM1_PartyThingType) || (curSquare.getType() != k3_StairsElemType))
 						goto T0276079;
 					break;
 				case k6_SensorFloorGroupGenerator:


Commit: 4663d190c4112279cfbb321d7edebd78dafcb161
    https://github.com/scummvm/scummvm/commit/4663d190c4112279cfbb321d7edebd78dafcb161
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-05T20:53:55+02:00

Commit Message:
DM: Get rid of Gotos in processThingAdditionOrRemoval

Changed paths:
    engines/dm/movesens.cpp



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 2cc1760..07909c8 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -763,99 +763,116 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 
 	curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
 	while (curThing != Thing::_endOfList) {
+		bool skipToNextThing = false;
 		uint16 curThingType = curThing.getType();
 		if (curThingType == k3_SensorThingType) {
 			Sensor *curSensor = (Sensor *)_vm->_dungeonMan->getThingData(curThing);
 			if (curSensor->getType() == k0_SensorDisabled)
-				goto T0276079;
-			int16 curSensorData = curSensor->getData();
-			bool triggerSensor = addThing;
-			if (sensorTriggeredCell == kM1_CellAny) {
-				switch (curSensor->getType()) {
-				case k1_SensorFloorTheronPartyCreatureObj:
-					if (partySquare || squareContainsObject || squareContainsGroup) /* BUG0_30 A floor sensor is not triggered when you put an object on the floor if a levitating creature is present on the same square. The condition to determine if the sensor should be triggered checks if there is a creature on the square but does not check whether the creature is levitating. While it is normal not to trigger the sensor if there is a non levitating creature on the square (because it was already triggered by the creature itself), a levitating creature should not prevent triggering the sensor with an object. */
-						goto T0276079;
-					break;
-				case k2_SensorFloorTheronPartyCreature:
-					if ((thingType > k4_GroupThingType) || partySquare || squareContainsGroup)
-						goto T0276079;
-					break;
-				case k3_SensorFloorParty:
-					if ((thingType != kM1_PartyThingType) || (_vm->_championMan->_partyChampionCount == 0))
-						goto T0276079;
-
-					if (curSensorData == 0) {
-						if (partySquare)
-							goto T0276079;
-					} else if (!addThing)
-						triggerSensor = false;
-					else
-						triggerSensor = (curSensorData == _vm->indexToOrdinal(_vm->_dungeonMan->_partyDir));
-					break;
-				case k4_SensorFloorObj:
-					if ((curSensorData != _vm->_objectMan->getObjectType(thing)) || squareContainsThingOfSameType)
-						goto T0276079;
-					break;
-				case k5_SensorFloorPartyOnStairs:
-					if ((thingType != kM1_PartyThingType) || (curSquare.getType() != k3_StairsElemType))
-						goto T0276079;
-					break;
-				case k6_SensorFloorGroupGenerator:
-					goto T0276079;
-				case k7_SensorFloorCreature:
-					if ((thingType > k4_GroupThingType) || (thingType == kM1_PartyThingType) || squareContainsGroup)
-						goto T0276079;
-					break;
-				case k8_SensorFloorPartyPossession:
-					if (thingType != kM1_PartyThingType)
-						goto T0276079;
-					triggerSensor = isObjectInPartyPossession(curSensorData);
-					break;
-				case k9_SensorFloorVersionChecker:
-					if ((thingType != kM1_PartyThingType) || !addThing || partySquare)
-						goto T0276079;
-					// Strangerke: 20 is a hardcoded version of the game. later version uses 21. Not present in the original dungeons anyway.
-					triggerSensor = (curSensorData <= 20);
-					break;
-				default:
-					goto T0276079;
+				skipToNextThing = true;
+
+			if (!skipToNextThing) {
+				int16 curSensorData = curSensor->getData();
+				bool triggerSensor = addThing;
+				if (sensorTriggeredCell == kM1_CellAny) {
+					switch (curSensor->getType()) {
+					case k1_SensorFloorTheronPartyCreatureObj:
+						if (partySquare || squareContainsObject || squareContainsGroup) /* BUG0_30 A floor sensor is not triggered when you put an object on the floor if a levitating creature is present on the same square. The condition to determine if the sensor should be triggered checks if there is a creature on the square but does not check whether the creature is levitating. While it is normal not to trigger the sensor if there is a non levitating creature on the square (because it was already triggered by the creature itself), a levitating creature should not prevent triggering the sensor with an object. */
+							skipToNextThing = true;
+						break;
+					case k2_SensorFloorTheronPartyCreature:
+						if ((thingType > k4_GroupThingType) || partySquare || squareContainsGroup)
+							skipToNextThing = true;
+						break;
+					case k3_SensorFloorParty:
+						if ((thingType != kM1_PartyThingType) || (_vm->_championMan->_partyChampionCount == 0)) {
+							skipToNextThing = true;
+							break;
+						}
+	
+						if (curSensorData == 0) {
+							if (partySquare)
+								skipToNextThing = true;
+						} else if (!addThing)
+							triggerSensor = false;
+						else
+							triggerSensor = (curSensorData == _vm->indexToOrdinal(_vm->_dungeonMan->_partyDir));
+						break;
+					case k4_SensorFloorObj:
+						if ((curSensorData != _vm->_objectMan->getObjectType(thing)) || squareContainsThingOfSameType)
+							skipToNextThing = true;
+						break;
+					case k5_SensorFloorPartyOnStairs:
+						if ((thingType != kM1_PartyThingType) || (curSquare.getType() != k3_StairsElemType))
+							skipToNextThing = true;
+						break;
+					case k6_SensorFloorGroupGenerator:
+						skipToNextThing = true;
+						break;
+					case k7_SensorFloorCreature:
+						if ((thingType > k4_GroupThingType) || (thingType == kM1_PartyThingType) || squareContainsGroup)
+							skipToNextThing = true;
+						break;
+					case k8_SensorFloorPartyPossession:
+						if (thingType != kM1_PartyThingType)
+							skipToNextThing = true;
+						else
+							triggerSensor = isObjectInPartyPossession(curSensorData);
+						break;
+					case k9_SensorFloorVersionChecker:
+						if ((thingType != kM1_PartyThingType) || !addThing || partySquare)
+							skipToNextThing = true;
+						else 
+						// Strangerke: 20 is a hardcoded version of the game. later version uses 21. Not present in the original dungeons anyway.
+							triggerSensor = (curSensorData <= 20);
+						break;
+					default:
+						skipToNextThing = true;
+						break;
+					}
+				} else {
+					if (sensorTriggeredCell != curThing.getCell())
+						skipToNextThing = true;
+					else {
+						switch (curSensor->getType()) {
+						case k1_SensorWallOrnClick:
+							if (squareContainsObject)
+								skipToNextThing = true;
+							break;
+						case k2_SensorWallOrnClickWithAnyObj:
+							if (squareContainsThingOfSameType || (curSensor->getData() != _vm->_objectMan->getObjectType(thing)))
+								skipToNextThing = true;
+							break;
+						case k3_SensorWallOrnClickWithSpecObj:
+							if (squareContainsThingOfDifferentType || (curSensor->getData() == _vm->_objectMan->getObjectType(thing)))
+								skipToNextThing = true;
+							break;
+						default:
+							skipToNextThing = true;
+							break;
+						}
+					}
 				}
-			} else {
-				if (sensorTriggeredCell != curThing.getCell())
-					goto T0276079;
-				switch (curSensor->getType()) {
-				case k1_SensorWallOrnClick:
-					if (squareContainsObject)
-						goto T0276079;
-					break;
-				case k2_SensorWallOrnClickWithAnyObj:
-					if (squareContainsThingOfSameType || (curSensor->getData() != _vm->_objectMan->getObjectType(thing)))
-						goto T0276079;
-					break;
-				case k3_SensorWallOrnClickWithSpecObj:
-					if (squareContainsThingOfDifferentType || (curSensor->getData() == _vm->_objectMan->getObjectType(thing)))
-						goto T0276079;
-					break;
-				default:
-					goto T0276079;
+				if (!skipToNextThing) {
+					triggerSensor ^= curSensor->getAttrRevertEffectA();
+					int16 curSensorEffect = curSensor->getAttrEffectA();
+					if (curSensorEffect == k3_SensorEffHold)
+						curSensorEffect = triggerSensor ? k0_SensorEffSet : k1_SensorEffClear;
+					else if (!triggerSensor)
+						skipToNextThing = true;
+		
+					if (!skipToNextThing) {
+						if (curSensor->getAttrAudibleA())
+							_vm->_sound->requestPlay(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized);
+			
+						triggerEffect(curSensor, curSensorEffect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
+						skipToNextThing = true;
+					}
 				}
 			}
-			triggerSensor ^= curSensor->getAttrRevertEffectA();
-			int16 curSensorEffect = curSensor->getAttrEffectA();
-			if (curSensorEffect == k3_SensorEffHold)
-				curSensorEffect = triggerSensor ? k0_SensorEffSet : k1_SensorEffClear;
-			else if (!triggerSensor)
-				goto T0276079;
-
-			if (curSensor->getAttrAudibleA())
-				_vm->_sound->requestPlay(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized);
-
-			triggerEffect(curSensor, curSensorEffect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
-			goto T0276079;
 		}
-		if (curThingType >= k4_GroupThingType)
+		if (!skipToNextThing && (curThingType >= k4_GroupThingType))
 			break;
-T0276079:
+
 		curThing = _vm->_dungeonMan->getNextThing(curThing);
 	}
 	processRotationEffect();


Commit: 4befd3a23214953632d1cdc5ba32d2bd1bb7293d
    https://github.com/scummvm/scummvm/commit/4befd3a23214953632d1cdc5ba32d2bd1bb7293d
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-09-05T19:05:02+02:00

Commit Message:
Merge branch 'dm' of github.com:WinterGrascph/scummvm into dm

Changed paths:
    engines/dm/champion.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/gfx.h
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/loadsave.cpp
    engines/dm/lzw.cpp
    engines/dm/lzw.h
    engines/dm/menus.cpp
    engines/dm/menus.h
    engines/dm/movesens.cpp
    engines/dm/movesens.h





Commit: 17bf26821b5d800dc7bd9d2fd0e382b6a777e4a6
    https://github.com/scummvm/scummvm/commit/17bf26821b5d800dc7bd9d2fd0e382b6a777e4a6
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-05T21:08:06+02:00

Commit Message:
DM: Better refactoring of processThingAdditionOrRemoval

Changed paths:
    engines/dm/movesens.cpp



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 07909c8..fc0f4b2 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -761,119 +761,108 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 	if (addThing && (thingType != kM1_PartyThingType))
 		_vm->_dungeonMan->linkThingToList(thing, Thing(0), mapX, mapY);
 
-	curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
-	while (curThing != Thing::_endOfList) {
-		bool skipToNextThing = false;
+	for (curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY); curThing != Thing::_endOfList; curThing = _vm->_dungeonMan->getNextThing(curThing)) {
 		uint16 curThingType = curThing.getType();
 		if (curThingType == k3_SensorThingType) {
 			Sensor *curSensor = (Sensor *)_vm->_dungeonMan->getThingData(curThing);
 			if (curSensor->getType() == k0_SensorDisabled)
-				skipToNextThing = true;
+				continue;
+
+			int16 curSensorData = curSensor->getData();
+			bool triggerSensor = addThing;
+			if (sensorTriggeredCell == kM1_CellAny) {
+				switch (curSensor->getType()) {
+				case k1_SensorFloorTheronPartyCreatureObj:
+					if (partySquare || squareContainsObject || squareContainsGroup) /* BUG0_30 A floor sensor is not triggered when you put an object on the floor if a levitating creature is present on the same square. The condition to determine if the sensor should be triggered checks if there is a creature on the square but does not check whether the creature is levitating. While it is normal not to trigger the sensor if there is a non levitating creature on the square (because it was already triggered by the creature itself), a levitating creature should not prevent triggering the sensor with an object. */
+						continue;
+					break;
+				case k2_SensorFloorTheronPartyCreature:
+					if ((thingType > k4_GroupThingType) || partySquare || squareContainsGroup)
+						continue;
+					break;
+				case k3_SensorFloorParty:
+					if ((thingType != kM1_PartyThingType) || (_vm->_championMan->_partyChampionCount == 0))
+						continue;
+
+					if (curSensorData == 0) {
+						if (partySquare)
+							continue;
+					} else if (!addThing)
+						triggerSensor = false;
+					else
+						triggerSensor = (curSensorData == _vm->indexToOrdinal(_vm->_dungeonMan->_partyDir));
+					break;
+				case k4_SensorFloorObj:
+					if ((curSensorData != _vm->_objectMan->getObjectType(thing)) || squareContainsThingOfSameType)
+						continue;
+					break;
+				case k5_SensorFloorPartyOnStairs:
+					if ((thingType != kM1_PartyThingType) || (curSquare.getType() != k3_StairsElemType))
+						continue;
+					break;
+				case k6_SensorFloorGroupGenerator:
+					continue;
+					break;
+				case k7_SensorFloorCreature:
+					if ((thingType > k4_GroupThingType) || (thingType == kM1_PartyThingType) || squareContainsGroup)
+						continue;
+					break;
+				case k8_SensorFloorPartyPossession:
+					if (thingType != kM1_PartyThingType)
+						continue;
 
-			if (!skipToNextThing) {
-				int16 curSensorData = curSensor->getData();
-				bool triggerSensor = addThing;
-				if (sensorTriggeredCell == kM1_CellAny) {
-					switch (curSensor->getType()) {
-					case k1_SensorFloorTheronPartyCreatureObj:
-						if (partySquare || squareContainsObject || squareContainsGroup) /* BUG0_30 A floor sensor is not triggered when you put an object on the floor if a levitating creature is present on the same square. The condition to determine if the sensor should be triggered checks if there is a creature on the square but does not check whether the creature is levitating. While it is normal not to trigger the sensor if there is a non levitating creature on the square (because it was already triggered by the creature itself), a levitating creature should not prevent triggering the sensor with an object. */
-							skipToNextThing = true;
-						break;
-					case k2_SensorFloorTheronPartyCreature:
-						if ((thingType > k4_GroupThingType) || partySquare || squareContainsGroup)
-							skipToNextThing = true;
-						break;
-					case k3_SensorFloorParty:
-						if ((thingType != kM1_PartyThingType) || (_vm->_championMan->_partyChampionCount == 0)) {
-							skipToNextThing = true;
-							break;
-						}
-	
-						if (curSensorData == 0) {
-							if (partySquare)
-								skipToNextThing = true;
-						} else if (!addThing)
-							triggerSensor = false;
-						else
-							triggerSensor = (curSensorData == _vm->indexToOrdinal(_vm->_dungeonMan->_partyDir));
-						break;
-					case k4_SensorFloorObj:
-						if ((curSensorData != _vm->_objectMan->getObjectType(thing)) || squareContainsThingOfSameType)
-							skipToNextThing = true;
-						break;
-					case k5_SensorFloorPartyOnStairs:
-						if ((thingType != kM1_PartyThingType) || (curSquare.getType() != k3_StairsElemType))
-							skipToNextThing = true;
-						break;
-					case k6_SensorFloorGroupGenerator:
-						skipToNextThing = true;
-						break;
-					case k7_SensorFloorCreature:
-						if ((thingType > k4_GroupThingType) || (thingType == kM1_PartyThingType) || squareContainsGroup)
-							skipToNextThing = true;
-						break;
-					case k8_SensorFloorPartyPossession:
-						if (thingType != kM1_PartyThingType)
-							skipToNextThing = true;
-						else
-							triggerSensor = isObjectInPartyPossession(curSensorData);
-						break;
-					case k9_SensorFloorVersionChecker:
-						if ((thingType != kM1_PartyThingType) || !addThing || partySquare)
-							skipToNextThing = true;
-						else 
-						// Strangerke: 20 is a hardcoded version of the game. later version uses 21. Not present in the original dungeons anyway.
-							triggerSensor = (curSensorData <= 20);
-						break;
-					default:
-						skipToNextThing = true;
-						break;
-					}
-				} else {
-					if (sensorTriggeredCell != curThing.getCell())
-						skipToNextThing = true;
-					else {
-						switch (curSensor->getType()) {
-						case k1_SensorWallOrnClick:
-							if (squareContainsObject)
-								skipToNextThing = true;
-							break;
-						case k2_SensorWallOrnClickWithAnyObj:
-							if (squareContainsThingOfSameType || (curSensor->getData() != _vm->_objectMan->getObjectType(thing)))
-								skipToNextThing = true;
-							break;
-						case k3_SensorWallOrnClickWithSpecObj:
-							if (squareContainsThingOfDifferentType || (curSensor->getData() == _vm->_objectMan->getObjectType(thing)))
-								skipToNextThing = true;
-							break;
-						default:
-							skipToNextThing = true;
-							break;
-						}
-					}
+					triggerSensor = isObjectInPartyPossession(curSensorData);
+					break;
+				case k9_SensorFloorVersionChecker:
+					if ((thingType != kM1_PartyThingType) || !addThing || partySquare)
+						continue;
+
+					// Strangerke: 20 is a hardcoded version of the game. later version uses 21. Not present in the original dungeons anyway.
+					triggerSensor = (curSensorData <= 20);
+					break;
+				default:
+					continue;
+					break;
 				}
-				if (!skipToNextThing) {
-					triggerSensor ^= curSensor->getAttrRevertEffectA();
-					int16 curSensorEffect = curSensor->getAttrEffectA();
-					if (curSensorEffect == k3_SensorEffHold)
-						curSensorEffect = triggerSensor ? k0_SensorEffSet : k1_SensorEffClear;
-					else if (!triggerSensor)
-						skipToNextThing = true;
-		
-					if (!skipToNextThing) {
-						if (curSensor->getAttrAudibleA())
-							_vm->_sound->requestPlay(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized);
-			
-						triggerEffect(curSensor, curSensorEffect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
-						skipToNextThing = true;
-					}
+			} else {
+				if (sensorTriggeredCell != curThing.getCell())
+					continue;
+
+				switch (curSensor->getType()) {
+				case k1_SensorWallOrnClick:
+					if (squareContainsObject)
+						continue;
+					break;
+				case k2_SensorWallOrnClickWithAnyObj:
+					if (squareContainsThingOfSameType || (curSensor->getData() != _vm->_objectMan->getObjectType(thing)))
+						continue;
+					break;
+				case k3_SensorWallOrnClickWithSpecObj:
+					if (squareContainsThingOfDifferentType || (curSensor->getData() == _vm->_objectMan->getObjectType(thing)))
+						continue;
+					break;
+				default:
+					continue;
+					break;
 				}
 			}
+
+			triggerSensor ^= curSensor->getAttrRevertEffectA();
+			int16 curSensorEffect = curSensor->getAttrEffectA();
+			if (curSensorEffect == k3_SensorEffHold)
+				curSensorEffect = triggerSensor ? k0_SensorEffSet : k1_SensorEffClear;
+			else if (!triggerSensor)
+				continue;
+
+			if (curSensor->getAttrAudibleA())
+				_vm->_sound->requestPlay(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized);
+
+			triggerEffect(curSensor, curSensorEffect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
+			continue;
 		}
-		if (!skipToNextThing && (curThingType >= k4_GroupThingType))
-			break;
 
-		curThing = _vm->_dungeonMan->getNextThing(curThing);
+		if (curThingType >= k4_GroupThingType)
+			break;
 	}
 	processRotationEffect();
 }


Commit: 70906ba7ebf58601279fcb900ac910f983fc8c86
    https://github.com/scummvm/scummvm/commit/70906ba7ebf58601279fcb900ac910f983fc8c86
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-05T21:16:34+02:00

Commit Message:
DM: Better refactoring of sensorIsTriggeredByClickOnWall

Changed paths:
    engines/dm/movesens.cpp



diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index fc0f4b2..f76f675 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -71,9 +71,8 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 
 		thingBeingProcessed = _vm->_dungeonMan->getNextThing(thingBeingProcessed);
 	}
-	Thing lastProcessedThing = thingBeingProcessed = squareFirstThing;
-	while (thingBeingProcessed != Thing::_endOfList) {
-		bool skipToNextThing = false;
+	for (Thing thingBeingProcessed = squareFirstThing; thingBeingProcessed != Thing::_endOfList; thingBeingProcessed = _vm->_dungeonMan->getNextThing(thingBeingProcessed)) {
+		Thing lastProcessedThing = thingBeingProcessed;
 		uint16 ProcessedThingType = thingBeingProcessed.getType();
 		if (ProcessedThingType == k3_SensorThingType) {
 			int16 cellIdx = thingBeingProcessed.getCell();
@@ -81,142 +80,132 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 			Sensor *currentSensor = (Sensor *)_vm->_dungeonMan->getThingData(thingBeingProcessed);
 			SensorType processedSensorType = currentSensor->getType();
 			if (processedSensorType == k0_SensorDisabled)
-				skipToNextThing = true;
-			else if ((_vm->_championMan->_leaderIndex == kM1_ChampionNone) && (processedSensorType != k127_SensorWallChampionPortrait))
-				skipToNextThing = true;
-			else if (cellIdx != cellParam)
-				skipToNextThing = true;
+				continue;
+			
+			if ((_vm->_championMan->_leaderIndex == kM1_ChampionNone) && (processedSensorType != k127_SensorWallChampionPortrait))
+				continue;
+			
+			if (cellIdx != cellParam)
+				continue;
 
 			bool doNotTriggerSensor;
 			int16 sensorData = 0;
 			int16 sensorEffect = 0;
-			if (!skipToNextThing) {
-				sensorData = currentSensor->getData();
-				sensorEffect = currentSensor->getAttrEffectA();
 
-				switch (processedSensorType) {
-				case k1_SensorWallOrnClick:
-					doNotTriggerSensor = false;
-					if (currentSensor->getAttrEffectA() == k3_SensorEffHold)
-						skipToNextThing = true;
-					break;
-				case k2_SensorWallOrnClickWithAnyObj:
-					doNotTriggerSensor = (_vm->_championMan->_leaderEmptyHanded != currentSensor->getAttrRevertEffectA());
-					break;
-				case k17_SensorWallOrnClickWithSpecObjRemovedSensor:
-				case k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors:
-					if (sensorCountToProcessPerCell[cellIdx]) { /* If the sensor is not the last one of its type on the cell */
-						skipToNextThing = true;
-						break;
-					}
-					// No break on purpose
-				case k3_SensorWallOrnClickWithSpecObj:
-				case k4_SensorWallOrnClickWithSpecObjRemoved:
-					doNotTriggerSensor = ((sensorData == _vm->_objectMan->getObjectType(leaderHandObject)) == currentSensor->getAttrRevertEffectA());
-					if (!doNotTriggerSensor && (processedSensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) {
-						if (lastProcessedThing == thingBeingProcessed) /* If the sensor is the only one of its type on the cell */
-							break;
-						Sensor *lastSensor = (Sensor *)_vm->_dungeonMan->getThingData(lastProcessedThing);
-						lastSensor->setNextThing(currentSensor->getNextThing());
-						currentSensor->setNextThing(Thing::_none);
-						thingBeingProcessed = lastProcessedThing;
-					}
-					if (!doNotTriggerSensor && (processedSensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors)) {
-						triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
-					}
-					break;
-				case k12_SensorWallObjGeneratorRotateSensors:
-					if (sensorCountToProcessPerCell[cellIdx]) { /* If the sensor is not the last one of its type on the cell */
-						skipToNextThing = true;
+			sensorData = currentSensor->getData();
+			sensorEffect = currentSensor->getAttrEffectA();
+
+			switch (processedSensorType) {
+			case k1_SensorWallOrnClick:
+				doNotTriggerSensor = false;
+				if (currentSensor->getAttrEffectA() == k3_SensorEffHold)
+					continue;
+				break;
+			case k2_SensorWallOrnClickWithAnyObj:
+				doNotTriggerSensor = (_vm->_championMan->_leaderEmptyHanded != currentSensor->getAttrRevertEffectA());
+				break;
+			case k17_SensorWallOrnClickWithSpecObjRemovedSensor:
+			case k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors:
+				if (sensorCountToProcessPerCell[cellIdx]) /* If the sensor is not the last one of its type on the cell */
+					continue;
+				// No break on purpose
+			case k3_SensorWallOrnClickWithSpecObj:
+			case k4_SensorWallOrnClickWithSpecObjRemoved:
+				doNotTriggerSensor = ((sensorData == _vm->_objectMan->getObjectType(leaderHandObject)) == currentSensor->getAttrRevertEffectA());
+				if (!doNotTriggerSensor && (processedSensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) {
+					if (lastProcessedThing == thingBeingProcessed) /* If the sensor is the only one of its type on the cell */
 						break;
-					}
-					doNotTriggerSensor = !_vm->_championMan->_leaderEmptyHanded;
-					if (!doNotTriggerSensor)
-						triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
-					break;
-				case k13_SensorWallSingleObjStorageRotateSensors:
-					if (_vm->_championMan->_leaderEmptyHanded) {
-						leaderHandObject = getObjectOfTypeInCell(mapX, mapY, cellIdx, sensorData);
-						if (leaderHandObject == Thing::_none) {
-							skipToNextThing = true;
-							break;
-						}
-						_vm->_dungeonMan->unlinkThingFromList(leaderHandObject, Thing(0), mapX, mapY);
-						_vm->_championMan->putObjectInLeaderHand(leaderHandObject, true);
-					} else {
-						if ((_vm->_objectMan->getObjectType(leaderHandObject) != sensorData) || (getObjectOfTypeInCell(mapX, mapY, cellIdx, sensorData) != Thing::_none)) {
-							skipToNextThing = true;
-							break;
-						}
-						_vm->_championMan->getObjectRemovedFromLeaderHand();
-						_vm->_dungeonMan->linkThingToList(thingWithNewCell(leaderHandObject, cellIdx), Thing(0), mapX, mapY);
-						leaderHandObject = Thing::_none;
-					}
+					Sensor *lastSensor = (Sensor *)_vm->_dungeonMan->getThingData(lastProcessedThing);
+					lastSensor->setNextThing(currentSensor->getNextThing());
+					currentSensor->setNextThing(Thing::_none);
+					thingBeingProcessed = lastProcessedThing;
+				}
+
+				if (!doNotTriggerSensor && (processedSensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors))
 					triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
-					if ((sensorEffect == k3_SensorEffHold) && !_vm->_championMan->_leaderEmptyHanded)
-						doNotTriggerSensor = true;
-					else
-						doNotTriggerSensor = false;
-	
-					break;
-				case k16_SensorWallObjExchanger: {
-					if (sensorCountToProcessPerCell[cellIdx]) { /* If the sensor is not the last one of its type on the cell */
-						skipToNextThing = true;
-						break;
-					}
-					Thing thingOnSquare = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
-					if ((_vm->_objectMan->getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_none)) {
-						skipToNextThing = true;
-						break;
-					}
-					_vm->_dungeonMan->unlinkThingFromList(thingOnSquare, Thing(0), mapX, mapY);
+
+				break;
+			case k12_SensorWallObjGeneratorRotateSensors:
+				if (sensorCountToProcessPerCell[cellIdx]) /* If the sensor is not the last one of its type on the cell */
+					continue;
+
+				doNotTriggerSensor = !_vm->_championMan->_leaderEmptyHanded;
+				if (!doNotTriggerSensor)
+					triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
+				break;
+			case k13_SensorWallSingleObjStorageRotateSensors:
+				if (_vm->_championMan->_leaderEmptyHanded) {
+					leaderHandObject = getObjectOfTypeInCell(mapX, mapY, cellIdx, sensorData);
+					if (leaderHandObject == Thing::_none)
+						continue;
+
+					_vm->_dungeonMan->unlinkThingFromList(leaderHandObject, Thing(0), mapX, mapY);
+					_vm->_championMan->putObjectInLeaderHand(leaderHandObject, true);
+				} else {
+					if ((_vm->_objectMan->getObjectType(leaderHandObject) != sensorData) || (getObjectOfTypeInCell(mapX, mapY, cellIdx, sensorData) != Thing::_none))
+						continue;
+
 					_vm->_championMan->getObjectRemovedFromLeaderHand();
 					_vm->_dungeonMan->linkThingToList(thingWithNewCell(leaderHandObject, cellIdx), Thing(0), mapX, mapY);
-					_vm->_championMan->putObjectInLeaderHand(thingOnSquare, true);
+					leaderHandObject = Thing::_none;
+				}
+				triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
+				if ((sensorEffect == k3_SensorEffHold) && !_vm->_championMan->_leaderEmptyHanded)
+					doNotTriggerSensor = true;
+				else
 					doNotTriggerSensor = false;
-					}
-					break;
-				case k127_SensorWallChampionPortrait:
-					_vm->_championMan->addCandidateChampionToParty(sensorData);
-					skipToNextThing = true;
-					break;
-				default:
-					skipToNextThing = true;
-					break;
+
+				break;
+			case k16_SensorWallObjExchanger: {
+				if (sensorCountToProcessPerCell[cellIdx]) /* If the sensor is not the last one of its type on the cell */
+					continue;
+
+				Thing thingOnSquare = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
+				if ((_vm->_objectMan->getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_none))
+					continue;
+
+				_vm->_dungeonMan->unlinkThingFromList(thingOnSquare, Thing(0), mapX, mapY);
+				_vm->_championMan->getObjectRemovedFromLeaderHand();
+				_vm->_dungeonMan->linkThingToList(thingWithNewCell(leaderHandObject, cellIdx), Thing(0), mapX, mapY);
+				_vm->_championMan->putObjectInLeaderHand(thingOnSquare, true);
+				doNotTriggerSensor = false;
 				}
+				break;
+			case k127_SensorWallChampionPortrait:
+				_vm->_championMan->addCandidateChampionToParty(sensorData);
+				continue;
+				break;
+			default:
+				continue;
+				break;
 			}
 
-			if (!skipToNextThing) {
-				if (sensorEffect == k3_SensorEffHold) {
-					sensorEffect = doNotTriggerSensor ? k1_SensorEffClear : k0_SensorEffSet;
-					doNotTriggerSensor = false;
-				}
-				if (!doNotTriggerSensor) {
-					atLeastOneSensorWasTriggered = true;
-					if (currentSensor->getAttrAudibleA())
-						_vm->_sound->requestPlay(k01_soundSWITCH, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
-	
-					if (!_vm->_championMan->_leaderEmptyHanded && ((processedSensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (processedSensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (processedSensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
-						Thing *leaderThing = (Thing *)_vm->_dungeonMan->getThingData(leaderHandObject);
-						*leaderThing = Thing::_none;
-						_vm->_championMan->getObjectRemovedFromLeaderHand();
-						leaderHandObject = Thing::_none;
-					} else if (_vm->_championMan->_leaderEmptyHanded
-						&& (processedSensorType == k12_SensorWallObjGeneratorRotateSensors)) {
-						leaderHandObject = _vm->_dungeonMan->getObjForProjectileLaucherOrObjGen(sensorData);
-						if (leaderHandObject != Thing::_none)
-							_vm->_championMan->putObjectInLeaderHand(leaderHandObject, true);
-					}
-					triggerEffect(currentSensor, sensorEffect, mapX, mapY, cellIdx);
+			if (sensorEffect == k3_SensorEffHold) {
+				sensorEffect = doNotTriggerSensor ? k1_SensorEffClear : k0_SensorEffSet;
+				doNotTriggerSensor = false;
+			}
+			if (!doNotTriggerSensor) {
+				atLeastOneSensorWasTriggered = true;
+				if (currentSensor->getAttrAudibleA())
+					_vm->_sound->requestPlay(k01_soundSWITCH, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
+
+				if (!_vm->_championMan->_leaderEmptyHanded && ((processedSensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (processedSensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (processedSensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
+					Thing *leaderThing = (Thing *)_vm->_dungeonMan->getThingData(leaderHandObject);
+					*leaderThing = Thing::_none;
+					_vm->_championMan->getObjectRemovedFromLeaderHand();
+					leaderHandObject = Thing::_none;
+				} else if (_vm->_championMan->_leaderEmptyHanded
+					&& (processedSensorType == k12_SensorWallObjGeneratorRotateSensors)) {
+					leaderHandObject = _vm->_dungeonMan->getObjForProjectileLaucherOrObjGen(sensorData);
+					if (leaderHandObject != Thing::_none)
+						_vm->_championMan->putObjectInLeaderHand(leaderHandObject, true);
 				}
-				skipToNextThing = true;
+				triggerEffect(currentSensor, sensorEffect, mapX, mapY, cellIdx);
 			}
+			continue;
 		}
-		if (!skipToNextThing && (ProcessedThingType >= k4_GroupThingType))
-			break;
-
-		lastProcessedThing = thingBeingProcessed;
-		thingBeingProcessed = _vm->_dungeonMan->getNextThing(thingBeingProcessed);
+		if (ProcessedThingType >= k4_GroupThingType)
+			break;		
 	}
 	processRotationEffect();
 	return atLeastOneSensorWasTriggered;


Commit: e4fe372bdb2aefb320f50cb249773a2b94861b0f
    https://github.com/scummvm/scummvm/commit/e4fe372bdb2aefb320f50cb249773a2b94861b0f
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-05T22:02:28+02:00

Commit Message:
DM: Start refactoring ObjectMan

Changed paths:
    engines/dm/objectman.cpp
    engines/dm/objectman.h



diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 48efb96..92453b7 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -31,18 +31,18 @@
 
 namespace DM {
 
-int16 gK77_IconGraphicHeight[7] = {32, 32, 32, 32, 32, 32, 32}; // @ K0077_ai_IconGraphicHeight
+void ObjectMan::initConstants() {
+	int16 iconGraphicHeight[7] = {32, 32, 32, 32, 32, 32, 32}; // @ K0077_ai_IconGraphicHeight
+	int16 iconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex
+		0,     /* First icon index in graphic #42 */
+		32,    /* First icon index in graphic #43 */
+		64,    /* First icon index in graphic #44 */
+		96,    /* First icon index in graphic #45 */
+		128,   /* First icon index in graphic #46 */
+		160,   /* First icon index in graphic #47 */
+		192    /* First icon index in graphic #48 */
+	};
 
-int16 g26_IconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex
-	0,     /* First icon index in graphic #42 */
-	32,    /* First icon index in graphic #43 */
-	64,    /* First icon index in graphic #44 */
-	96,    /* First icon index in graphic #45 */
-	128,   /* First icon index in graphic #46 */
-	160,   /* First icon index in graphic #47 */
-	192}; /* First icon index in graphic #48 */
-
-ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {
 	/* 8 for champion hands in status boxes, 30 for champion inventory, 8 for chest */
 	_slotBoxes[0] = SlotBox(4, 10, 0);    /* Champion Status Box 0 Ready Hand */
 	_slotBoxes[1] = SlotBox(24, 10, 0);   /* Champion Status Box 0 Action Hand */
@@ -91,10 +91,19 @@ ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {
 	_slotBoxes[44] = SlotBox(179, 104, 0); /* Chest 7 */
 	_slotBoxes[45] = SlotBox(196, 105, 0); /* Chest 8 */
 
+	for (int i = 0; i < 7; i++) {
+		iconGraphicHeight[i] = iconGraphicHeight[i];
+		iconGraphicFirstIndex[i] = iconGraphicFirstIndex[i];
+	}
+}
+
+ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {
 	for (uint16 i = 0; i < k199_ObjectNameCount; ++i)
 		_objectNames[i] = nullptr;
 
 	_objectIconForMousePointer = nullptr;
+
+	initConstants();
 }
 
 ObjectMan::~ObjectMan() {
@@ -102,8 +111,6 @@ ObjectMan::~ObjectMan() {
 	delete[] _objectNames[0];
 }
 
-#define k556_ObjectNamesGraphicIndice 556 // @ C556_GRAPHIC_OBJECT_NAMES
-
 void ObjectMan::loadObjectNames() {
 	DisplayMan &dispMan = *_vm->_displayMan;
 
@@ -129,41 +136,38 @@ IconIndice ObjectMan::getObjectType(Thing thing) {
 		return kM1_IconIndiceNone;
 
 	int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing);
-	if (objectInfoIndex != -1) {
+	if (objectInfoIndex != -1)
 		objectInfoIndex = _vm->_dungeonMan->_objectInfos[objectInfoIndex]._type;
-	}
+
 	return (IconIndice)objectInfoIndex;
 }
 
-byte g29_ChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType
-
 IconIndice ObjectMan::getIconIndex(Thing thing) {
-	int16 L0005_i_IconIndex = getObjectType(thing);
-	if (L0005_i_IconIndex != kM1_IconIndiceNone) {
-		if (((L0005_i_IconIndex < k32_IconIndiceWeaponDagger) && (L0005_i_IconIndex >= k0_IconIndiceJunkCompassNorth)) ||
-			((L0005_i_IconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (L0005_i_IconIndex <= k163_IconIndicePotionWaterFlask)) ||
-			(L0005_i_IconIndex == k195_IconIndicePotionEmptyFlask)) {
-			Junk *L0006_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(thing);
-			switch (L0005_i_IconIndex) {
+	static byte chargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType
+
+	int16 iconIndex = getObjectType(thing);
+	if (iconIndex != kM1_IconIndiceNone) {
+		if (((iconIndex < k32_IconIndiceWeaponDagger) && (iconIndex >= k0_IconIndiceJunkCompassNorth)) ||
+			((iconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (iconIndex <= k163_IconIndicePotionWaterFlask)) ||
+			(iconIndex == k195_IconIndicePotionEmptyFlask)) {
+			Junk *junkThing = (Junk*)_vm->_dungeonMan->getThingData(thing);
+			switch (iconIndex) {
 			case k0_IconIndiceJunkCompassNorth:
-				L0005_i_IconIndex += _vm->_dungeonMan->_partyDir;
+				iconIndex += _vm->_dungeonMan->_partyDir;
 				break;
 			case k4_IconIndiceWeaponTorchUnlit:
-				if (((Weapon*)L0006_ps_Junk)->isLit()) {
-					L0005_i_IconIndex += g29_ChargeCountToTorchType[((Weapon*)L0006_ps_Junk)->getChargeCount()];
-				}
+				if (((Weapon*)junkThing)->isLit())
+					iconIndex += chargeCountToTorchType[((Weapon*)junkThing)->getChargeCount()];
 				break;
 			case k30_IconIndiceScrollOpen:
-				if (((Scroll*)L0006_ps_Junk)->getClosed()) {
-					L0005_i_IconIndex++;
-				}
+				if (((Scroll*)junkThing)->getClosed())
+					iconIndex++;
 				break;
 			case k8_IconIndiceJunkWater:
 			case k12_IconIndiceJunkIllumuletUnequipped:
 			case k10_IconIndiceJunkJewelSymalUnequipped:
-				if (L0006_ps_Junk->getChargeCount()) {
-					L0005_i_IconIndex++;
-				}
+				if (junkThing->getChargeCount())
+					iconIndex++;
 				break;
 			case k23_IconIndiceWeaponBoltBladeStormEmpty:
 			case k14_IconIndiceWeaponFlamittEmpty:
@@ -171,70 +175,65 @@ IconIndice ObjectMan::getIconIndex(Thing thing) {
 			case k25_IconIndiceWeaponFuryRaBladeEmpty:
 			case k16_IconIndiceWeaponEyeOfTimeEmpty:
 			case k20_IconIndiceWeaponStaffOfClawsEmpty:
-				if (((Weapon*)L0006_ps_Junk)->getChargeCount()) {
-					L0005_i_IconIndex++;
-				}
+				if (((Weapon*)junkThing)->getChargeCount())
+					iconIndex++;
+				break;
 			}
 		}
 	}
-	return (IconIndice)L0005_i_IconIndex;
+	return (IconIndice)iconIndex;
 }
 
 void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
-	uint16 L0011_ui_Counter;
-	byte* L0012_pl_Bitmap_Icon;
-	Box L1568_s_Box;
-
-	for (L0011_ui_Counter = 0; L0011_ui_Counter < 7; L0011_ui_Counter++) {
-		if (g26_IconGraphicFirstIndex[L0011_ui_Counter] > iconIndex)
+	uint16 counter;
+	for (counter = 0; counter < 7; counter++) {
+		if (iconGraphicFirstIndex[counter] > iconIndex)
 			break;
 	}
-	L0012_pl_Bitmap_Icon = _vm->_displayMan->getNativeBitmapOrGraphic(k42_ObjectIcons_000_TO_031 + --L0011_ui_Counter);
-	iconIndex -= g26_IconGraphicFirstIndex[L0011_ui_Counter];
+	--counter;
+	byte *iconBitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k42_ObjectIcons_000_TO_031 + counter);
+	iconIndex -= iconGraphicFirstIndex[counter];
 	_vm->_displayMan->_useByteBoxCoordinates = true;
-	L1568_s_Box._y1 = 0;
-	L1568_s_Box._x1 = 0;
-	L1568_s_Box._y2 = 15;
-	L1568_s_Box._x2 = 15;
-	_vm->_displayMan->blitToBitmap(L0012_pl_Bitmap_Icon, destBitmap, L1568_s_Box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, kM1_ColorNoTransparency, gK77_IconGraphicHeight[L0011_ui_Counter], 16);
+	Box blitBox(0, 15, 0, 15);
+	_vm->_displayMan->blitToBitmap(iconBitmap, destBitmap, blitBox, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, kM1_ColorNoTransparency, iconGraphicHeight[counter], 16);
 }
 
 void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
-	uint16 L0015_ui_IconGraphicIndex;
-	int16 L0016_i_ByteWidth;
-	SlotBox* L0017_ps_SlotBox;
-	byte* L0018_puc_Bitmap_Icons;
-	Box L0019_s_Box;
-	byte* L0020_puc_Bitmap_Destination;
-	int16 L1569_i_Width;
-
-	L0017_ps_SlotBox = &_slotBoxes[slotBoxIndex];
-	if ((L0017_ps_SlotBox->_iconIndex = iconIndex) == kM1_IconIndiceNone) {
+	SlotBox *slotBox = &_slotBoxes[slotBoxIndex];
+	slotBox->_iconIndex = iconIndex;
+	if (slotBox->_iconIndex == kM1_IconIndiceNone)
 		return;
-	}
-	L0019_s_Box._x2 = (L0019_s_Box._x1 = L0017_ps_SlotBox->_x) + 15;
-	L0019_s_Box._y2 = (L0019_s_Box._y1 = L0017_ps_SlotBox->_y) + 15;
-	for (L0015_ui_IconGraphicIndex = 0; L0015_ui_IconGraphicIndex < 7; L0015_ui_IconGraphicIndex++) {
-		if (g26_IconGraphicFirstIndex[L0015_ui_IconGraphicIndex] > iconIndex)
+
+	Box blitBox;
+	blitBox._x1 = slotBox->_x;
+	blitBox._x2 = blitBox._x1 + 15;
+	blitBox._y1 = slotBox->_y;
+	blitBox._y2 = blitBox._y1 + 15;
+
+	uint16 iconGraphicIndex;
+	for (iconGraphicIndex = 0; iconGraphicIndex < 7; iconGraphicIndex++) {
+		if (iconGraphicFirstIndex[iconGraphicIndex] > iconIndex)
 			break;
 	}
-	L0015_ui_IconGraphicIndex--;
-	L0018_puc_Bitmap_Icons = _vm->_displayMan->getNativeBitmapOrGraphic(L0015_ui_IconGraphicIndex + k42_ObjectIcons_000_TO_031);
-	iconIndex -= g26_IconGraphicFirstIndex[L0015_ui_IconGraphicIndex];
+	iconGraphicIndex--;
+	byte *iconBitmap = _vm->_displayMan->getNativeBitmapOrGraphic(iconGraphicIndex + k42_ObjectIcons_000_TO_031);
+	iconIndex -= iconGraphicFirstIndex[iconGraphicIndex];
+	int16 byteWidth;
+	byte* blitDestination;
+	int16 destHeight;
 	if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) {
-		L0020_puc_Bitmap_Destination = _vm->_displayMan->_bitmapViewport;
-		L0016_i_ByteWidth = k112_byteWidthViewport;
-		L1569_i_Width = 136;
+		blitDestination = _vm->_displayMan->_bitmapViewport;
+		byteWidth = k112_byteWidthViewport;
+		destHeight = 136;
 	} else {
-		L0020_puc_Bitmap_Destination = (unsigned char*)_vm->_displayMan->_bitmapScreen;
-		L0016_i_ByteWidth = k160_byteWidthScreen;
-		L1569_i_Width = 200;
+		blitDestination = (unsigned char*)_vm->_displayMan->_bitmapScreen;
+		byteWidth = k160_byteWidthScreen;
+		destHeight = 200;
 	}
-	_vm->_displayMan->_useByteBoxCoordinates = false, _vm->_displayMan->blitToBitmap(L0018_puc_Bitmap_Icons, L0020_puc_Bitmap_Destination, L0019_s_Box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, k128_byteWidth, L0016_i_ByteWidth, kM1_ColorNoTransparency, gK77_IconGraphicHeight[L0015_ui_IconGraphicIndex], L1569_i_Width);
+	_vm->_displayMan->_useByteBoxCoordinates = false;
+	_vm->_displayMan->blitToBitmap(iconBitmap, blitDestination, blitBox, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, k128_byteWidth, byteWidth, kM1_ColorNoTransparency, iconGraphicHeight[iconGraphicIndex], destHeight);
 }
 
-#define k14_ObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH
-
 void ObjectMan::drawLeaderObjectName(Thing thing) {
 	char* objectName = nullptr;
 	int16 L0007_i_IconIndex = getIconIndex(thing);
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index 9d42d6b..cfdc752 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -31,14 +31,15 @@
 #include "dm/dm.h"
 #include "dm/champion.h"
 
-
 namespace DM {
 
 #define k8_SlotBoxInventoryFirstSlot 8 // @ C08_SLOT_BOX_INVENTORY_FIRST_SLOT   
 #define k9_SlotBoxInventoryActionHand 9 // @ C09_SLOT_BOX_INVENTORY_ACTION_HAND  
 #define k38_SlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT      
 
+#define k14_ObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH
 #define k199_ObjectNameCount 199 // @ C199_OBJECT_NAME_COUNT
+#define k556_ObjectNamesGraphicIndice 556 // @ C556_GRAPHIC_OBJECT_NAMES
 
 class SlotBox {
 public:
@@ -69,6 +70,11 @@ public:
 	IconIndice getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox
 	void clearLeaderObjectName(); // @ F0035_OBJECT_ClearLeaderHandObjectName
 	void drawIconToScreen(int16 iconIndex, int16 posX, int16 posY); // @ F0037_OBJECT_DrawIconToScreen
+
+	int16 iconGraphicHeight[7]; // @ K0077_ai_IconGraphicHeight
+	int16 iconGraphicFirstIndex[7]; // G0026_ai_Graphic562_IconGraphicFirstIconIndex
+
+	void initConstants();
 };
 
 }


Commit: b6ab58658fad5519582e80482d1671cc08a38b56
    https://github.com/scummvm/scummvm/commit/b6ab58658fad5519582e80482d1671cc08a38b56
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-05T22:10:22+02:00

Commit Message:
DM: Finish the renaming in ObjectMan

Changed paths:
    engines/dm/objectman.cpp



diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 92453b7..1fc6aa4 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -236,28 +236,27 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 
 void ObjectMan::drawLeaderObjectName(Thing thing) {
 	char* objectName = nullptr;
-	int16 L0007_i_IconIndex = getIconIndex(thing);
-	if (L0007_i_IconIndex == k147_IconIndiceJunkChampionBones) {
+	int16 iconIndex = getIconIndex(thing);
+	if (iconIndex == k147_IconIndiceJunkChampionBones) {
 		Junk *junk = (Junk*)_vm->_dungeonMan->getThingData(thing);
 		char champBonesName[16];
 
 		switch (_vm->getGameLanguage()) { // localized
-		default:
-		case Common::EN_ANY:
-		case Common::DE_DEU: // english and german version are the same
-			strcpy(champBonesName, _vm->_championMan->_champions[junk->getChargeCount()]._name);
-			strcat(champBonesName, _objectNames[L0007_i_IconIndex]);
-			break;
 		case Common::FR_FRA:
-			strcat(champBonesName, _objectNames[L0007_i_IconIndex]);
+			// Fix original bug: strcpy was coming after strcat
+			strcpy(champBonesName, _objectNames[iconIndex]);
+			strcat(champBonesName, _vm->_championMan->_champions[junk->getChargeCount()]._name);
+			break;
+		default: // English and German version are the same
 			strcpy(champBonesName, _vm->_championMan->_champions[junk->getChargeCount()]._name);
+			strcat(champBonesName, _objectNames[iconIndex]);
 			break;
 		}
 
 		objectName = champBonesName;
-	} else {
-		objectName = _objectNames[L0007_i_IconIndex];
-	}
+	} else
+		objectName = _objectNames[iconIndex];
+
 	_vm->_textMan->printWithTrailingSpaces(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, 233, 37, k4_ColorCyan, k0_ColorBlack, objectName, k14_ObjectNameMaximumLength, k200_heightScreen);
 }
 
@@ -266,17 +265,14 @@ IconIndice ObjectMan::getIconIndexInSlotBox(uint16 slotBoxIndex) {
 }
 
 void ObjectMan::clearLeaderObjectName() {
-	static Box g28_BoxLeaderHandObjectName(233, 319, 33, 38); // @ G0028_s_Graphic562_Box_LeaderHandObjectName 
-	_vm->_displayMan->fillScreenBox(g28_BoxLeaderHandObjectName, k0_ColorBlack);
+	static Box boxLeaderHandObjectName(233, 319, 33, 38); // @ G0028_s_Graphic562_Box_LeaderHandObjectName 
+	_vm->_displayMan->fillScreenBox(boxLeaderHandObjectName, k0_ColorBlack);
 }
 
 void ObjectMan::drawIconToScreen(int16 iconIndex, int16 posX, int16 posY) {
-	static byte L0013_puc_Bitmap_Icon[16 * 16];
-	Box L0014_s_Box;
-
-	L0014_s_Box._x2 = (L0014_s_Box._x1 = posX) + 15;
-	L0014_s_Box._y2 = (L0014_s_Box._y1 = posY) + 15;
-	extractIconFromBitmap(iconIndex, L0013_puc_Bitmap_Icon);
-	_vm->_displayMan->blitToScreen(L0013_puc_Bitmap_Icon, &L0014_s_Box, k8_byteWidth, kM1_ColorNoTransparency, 16);
+	static byte iconBitmap[16 * 16];
+	Box blitBox(posX, posX + 15, posY, posY + 15);
+	extractIconFromBitmap(iconIndex, iconBitmap);
+	_vm->_displayMan->blitToScreen(iconBitmap, &blitBox, k8_byteWidth, kM1_ColorNoTransparency, 16);
 }
 }


Commit: dad8637ae89d363c40fecfdd8b76afe3d041d6d0
    https://github.com/scummvm/scummvm/commit/dad8637ae89d363c40fecfdd8b76afe3d041d6d0
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-05T22:12:20+02:00

Commit Message:
DM: Fix pointer style in ObjectMan

Changed paths:
    engines/dm/objectman.cpp



diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 1fc6aa4..b81415d 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -235,7 +235,7 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 }
 
 void ObjectMan::drawLeaderObjectName(Thing thing) {
-	char* objectName = nullptr;
+	char *objectName = nullptr;
 	int16 iconIndex = getIconIndex(thing);
 	if (iconIndex == k147_IconIndiceJunkChampionBones) {
 		Junk *junk = (Junk*)_vm->_dungeonMan->getThingData(thing);


Commit: 0ae23fa2dbe645472d8bb5b430da728025aa1a9f
    https://github.com/scummvm/scummvm/commit/0ae23fa2dbe645472d8bb5b430da728025aa1a9f
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-09-05T23:11:25+02:00

Commit Message:
DM: Fix regression introduced in 901ba6f

Unable to place items directly into champions' hands

Changed paths:
    engines/dm/TODOs/todo.txt
    engines/dm/eventman.cpp



diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 6411024..4309c98 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -5,7 +5,6 @@ Bugs:
 
 	Logic:
 		Items thrown on the right side end up on the left side 
-		Can't place torch in player's hand after loading, can do so only after brining up the inventory
 		Restarting the game after the party is dead segfaults
 
 Todo:
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 76a5497..a4734ad 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -355,7 +355,7 @@ void EventManager::initArrays() {
 	}
 
 	for (int i = 0; i < 13; i++)
-		_mouseInputChampionNamesHands[13] = mouseInputChampionNamesHands[i];
+		_mouseInputChampionNamesHands[i] = mouseInputChampionNamesHands[i];
 
 	for (int i = 0; i < 19; i++)
 		_secondaryKeyboardInputMovement[i] = secondaryKeyboardInputMovement[i];


Commit: 06ec57e7e308d7be6864a7cde7bce051778a72d1
    https://github.com/scummvm/scummvm/commit/06ec57e7e308d7be6864a7cde7bce051778a72d1
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-09-05T23:13:21+02:00

Commit Message:
DM: Merge branch 'dm' of github.com:WinterGrascph/scummvm into dm

Changed paths:
    engines/dm/objectman.cpp
    engines/dm/objectman.h





Commit: a4de5d0dd29dae16786a23d9a526dbf9b86aac7d
    https://github.com/scummvm/scummvm/commit/a4de5d0dd29dae16786a23d9a526dbf9b86aac7d
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-06T07:23:45+02:00

Commit Message:
DM: First pass of refactoring in hasProjectileImpactOccurred

Changed paths:
    engines/dm/projexpl.cpp



diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index aade217..87442f6 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -25,7 +25,6 @@
 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
 */
 
-
 #include "dm/projexpl.h"
 #include "dm/dungeonman.h"
 #include "dm/timeline.h"
@@ -47,203 +46,183 @@ ProjExpl::ProjExpl(DMEngine* vm) : _vm(vm) {
 }
 
 void ProjExpl::createProjectile(Thing thing, int16 mapX, int16 mapY, uint16 cell, Direction dir, byte kineticEnergy, byte attack, byte stepEnergy) {
-	Thing L0466_T_ProjectileThing;
-	Projectile* L0467_ps_Projectile;
-	TimelineEvent L0468_s_Event;
+	Thing projectileThing = _vm->_dungeonMan->getUnusedThing(k14_ProjectileThingType);
+	if (projectileThing == Thing::_none) /* BUG0_16 If the game cannot create a projectile thing because it has run out of such things (60 maximum) then the object being thrown/shot/launched is orphaned. If the game has run out of projectile things it will try to remove a projectile from elsewhere in the dungeon, except in an area of 11x11 squares centered around the party (to make sure the player cannot actually see the thing disappear on screen) */
+		return;
 
+	projectileThing = thingWithNewCell(projectileThing, cell);
+	Projectile *projectilePtr = (Projectile *)_vm->_dungeonMan->getThingData(projectileThing);
+	projectilePtr->_slot = thing;
+	projectilePtr->_kineticEnergy = MIN((int16)kineticEnergy, (int16)255);
+	projectilePtr->_attack = attack;
+	_vm->_dungeonMan->linkThingToList(projectileThing, Thing(0), mapX, mapY); /* Projectiles are added on the square and not 'moved' onto the square. In the case of a projectile launcher sensor, this means that the new projectile traverses the square in front of the launcher without any trouble: there is no impact if it is a wall, the projectile direction is not changed if it is a teleporter. Impacts with creatures and champions are still processed */
+	TimelineEvent newEvent;
+	setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + 1);
+	if (_createLauncherProjectile)
+		newEvent._type = k49_TMEventTypeMoveProjectile; /* Launcher projectiles can impact immediately */
+	else
+		newEvent._type = k48_TMEventTypeMoveProjectileIgnoreImpacts; /* Projectiles created by champions or creatures ignore impacts on their first movement */
 
-	if ((L0466_T_ProjectileThing = _vm->_dungeonMan->getUnusedThing(k14_ProjectileThingType)) == Thing::_none) { /* BUG0_16 If the game cannot create a projectile thing because it has run out of such things (60 maximum) then the object being thrown/shot/launched is orphaned. If the game has run out of projectile things it will try to remove a projectile from elsewhere in the dungeon, except in an area of 11x11 squares centered around the party (to make sure the player cannot actually see the thing disappear on screen) */
-		return;
-	}
-	L0466_T_ProjectileThing = thingWithNewCell(L0466_T_ProjectileThing, cell);
-	L0467_ps_Projectile = (Projectile *)_vm->_dungeonMan->getThingData(L0466_T_ProjectileThing);
-	L0467_ps_Projectile->_slot = thing;
-	L0467_ps_Projectile->_kineticEnergy = MIN((int16)kineticEnergy, (int16)255);
-	L0467_ps_Projectile->_attack = attack;
-	_vm->_dungeonMan->linkThingToList(L0466_T_ProjectileThing, Thing(0), mapX, mapY); /* Projectiles are added on the square and not 'moved' onto the square. In the case of a projectile launcher sensor, this means that the new projectile traverses the square in front of the launcher without any trouble: there is no impact if it is a wall, the projectile direction is not changed if it is a teleporter. Impacts with creatures and champions are still processed */
-	setMapAndTime(L0468_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + 1);
-	if (_createLauncherProjectile) {
-		L0468_s_Event._type = k49_TMEventTypeMoveProjectile; /* Launcher projectiles can impact immediately */
-	} else {
-		L0468_s_Event._type = k48_TMEventTypeMoveProjectileIgnoreImpacts; /* Projectiles created by champions or creatures ignore impacts on their first movement */
-	}
-	L0468_s_Event._priority = 0;
-	L0468_s_Event._B._slot = L0466_T_ProjectileThing.toUint16();
-	L0468_s_Event._C._projectile.setMapX(mapX);
-	L0468_s_Event._C._projectile.setMapY(mapY);
-	L0468_s_Event._C._projectile.setStepEnergy(stepEnergy);
-	L0468_s_Event._C._projectile.setDir(dir);
-	L0467_ps_Projectile->_eventIndex = _vm->_timeline->addEventGetEventIndex(&L0468_s_Event);
+	newEvent._priority = 0;
+	newEvent._B._slot = projectileThing.toUint16();
+	newEvent._C._projectile.setMapX(mapX);
+	newEvent._C._projectile.setMapY(mapY);
+	newEvent._C._projectile.setStepEnergy(stepEnergy);
+	newEvent._C._projectile.setDir(dir);
+	projectilePtr->_eventIndex = _vm->_timeline->addEventGetEventIndex(&newEvent);
 }
 
 bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, int16 mapYCombo, int16 cell, Thing projectileThing) {
-#define AP0454_i_ProjectileTargetMapX mapXCombo
-#define AP0455_i_ProjectileTargetMapY mapYCombo
 #define AP0456_i_ChampionIndex cell
-	Projectile* L0490_ps_Projectile;
-	Group* L0491_ps_Group;
-	Thing L0486_T_ProjectileAssociatedThing;
 	int16 L0487_i_Multiple;
 #define AL0487_i_DoorState  L0487_i_Multiple
 #define AL0487_i_IconIndex  L0487_i_Multiple
 #define AL0487_i_Outcome    L0487_i_Multiple
 #define AL0487_i_WeaponType L0487_i_Multiple
-	int16 L0488_i_Attack = 0;
-	Potion* L0492_ps_Potion = nullptr;
-	CreatureInfo* L0493_ps_CreatureInfo;
-	Door* L0494_ps_Door;
-	Weapon* L0495_ps_Weapon;
-	uint16* L0496_pui_CreatureHealth;
-	Thing* L0497_pT_GroupSlot;
-	Thing L0498_T_ExplosionThing;
-	int16 L0499_i_ProjectileMapX;
-	int16 L0500_i_ProjectileMapY;
-	int16 L0501_i_MapXCombo;
-	int16 L0502_i_MapYCombo;
-	byte L0503_uc_Square;
-	bool L0505_B_CreateExplosionOnImpact;
-	int16 L0489_i_ChampionAttack;
 	uint16 L0507_ui_Multiple;
 #define AL0507_ui_ExplosionAttack L0507_ui_Multiple
 #define AL0507_ui_SoundIndex      L0507_ui_Multiple
-	int16 L0508_i_PotionPower = 0;
-	bool L0509_B_RemovePotion;
-	int16 L0510_i_ProjectileAssociatedThingType;
-	uint16 L0511_ui_CreatureType;
-	uint16 L0512_ui_CreatureIndex;
-
-	L0490_ps_Projectile = (Projectile *)_vm->_dungeonMan->getThingData(Thing(projectileThing));
-	L0501_i_MapXCombo = mapXCombo;
-	L0502_i_MapYCombo = mapYCombo;
-	L0509_B_RemovePotion = false;
+
+	Projectile *projectileThingData = (Projectile *)_vm->_dungeonMan->getThingData(Thing(projectileThing));
+	bool removePotion = false;
+	int16 potionPower = 0;
 	_creatureDamageOutcome = k0_outcomeKilledNoCreaturesInGroup;
-	if ((L0510_i_ProjectileAssociatedThingType = (L0486_T_ProjectileAssociatedThing = L0490_ps_Projectile->_slot).getType()) == k8_PotionThingType) {
-		L0491_ps_Group = (Group *)_vm->_dungeonMan->getThingData(L0486_T_ProjectileAssociatedThing);
-		switch (((Potion *)L0491_ps_Group)->getType()) {
-		case k3_PotionTypeVen:
-			L0498_T_ExplosionThing = Thing::_explPoisonCloud;
-			goto T0217004;
-		case k19_PotionTypeFulBomb:
-			L0498_T_ExplosionThing = Thing::_explFireBall;
-T0217004:
-			L0509_B_RemovePotion = true;
-			L0508_i_PotionPower = ((Potion *)L0491_ps_Group)->getPower();
-			L0492_ps_Potion = (Potion *)L0491_ps_Group;
-			break;
-		default:
-			break;
+	Thing projectileAssociatedThing = projectileThingData->_slot;
+	int16 projectileAssociatedThingType = projectileAssociatedThing.getType();
+	Potion *potion = nullptr;
+	Thing explosionThing = Thing::_none;
+	if (projectileAssociatedThingType == k8_PotionThingType) {
+		Group *projectileAssociatedGroup = (Group *)_vm->_dungeonMan->getThingData(projectileAssociatedThing);
+		PotionType potionType = ((Potion *)projectileAssociatedGroup)->getType();
+		if ((potionType == k3_PotionTypeVen) || (potionType == k19_PotionTypeFulBomb)) {
+			explosionThing = (potionType == k3_PotionTypeVen) ? Thing::_explPoisonCloud: Thing::_explFireBall;
+			removePotion = true;
+			potionPower = ((Potion *)projectileAssociatedGroup)->getPower();
+			potion = (Potion *)projectileAssociatedGroup;
 		}
 	}
-	L0505_B_CreateExplosionOnImpact = (L0510_i_ProjectileAssociatedThingType == k15_ExplosionThingType) && (L0486_T_ProjectileAssociatedThing != Thing::_explSlime) && (L0486_T_ProjectileAssociatedThing != Thing::_explPoisonBolt);
-	L0497_pT_GroupSlot = NULL;
-	L0489_i_ChampionAttack = 0;
+	bool createExplosionOnImpact = (projectileAssociatedThingType == k15_ExplosionThingType) && (projectileAssociatedThing != Thing::_explSlime) && (projectileAssociatedThing != Thing::_explPoisonBolt);
+	Thing *curGroupSlot = nullptr;
+	int16 championAttack = 0;
+	int16 projectileMapX;
+	int16 projectileMapY;
+	int16 projectileTargetMapX = mapXCombo;
+	int16 projectileTargetMapY = mapYCombo;
+
 	if (mapXCombo <= 255) {
-		L0499_i_ProjectileMapX = mapXCombo;
-		L0500_i_ProjectileMapY = mapYCombo;
+		projectileMapX = mapXCombo;
+		projectileMapY = mapYCombo;
 	} else {
-		L0499_i_ProjectileMapX = (mapXCombo >> 8) - 1;
-		L0500_i_ProjectileMapY = (mapYCombo >> 8);
-		AP0454_i_ProjectileTargetMapX &= 0x00FF;
-		AP0455_i_ProjectileTargetMapY &= 0x00FF;
+		projectileMapX = (mapXCombo >> 8) - 1;
+		projectileMapY = (mapYCombo >> 8);
+		projectileTargetMapX &= 0x00FF;
+		projectileTargetMapY &= 0x00FF;
 	}
+
+	int16 attack = 0;
 	switch (impactType) {
-	case k4_DoorElemType:
-		AL0487_i_DoorState = Square(L0503_uc_Square = _vm->_dungeonMan->_currMapData[AP0454_i_ProjectileTargetMapX][AP0455_i_ProjectileTargetMapY]).getDoorState();
-		L0494_ps_Door = (Door *)_vm->_dungeonMan->getSquareFirstThingData(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY);
-		if ((AL0487_i_DoorState != k5_doorState_DESTROYED) && (L0486_T_ProjectileAssociatedThing == Thing::_explOpenDoor)) {
-			if (L0494_ps_Door->hasButton()) {
-				_vm->_moveSens->addEvent(k10_TMEventTypeDoor, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, 0, k2_SensorEffToggle, _vm->_gameTime + 1);
-			}
+	case k4_DoorElemType: {
+		byte curSquare = _vm->_dungeonMan->_currMapData[projectileTargetMapX][projectileTargetMapY];
+		AL0487_i_DoorState = Square(curSquare).getDoorState();
+		Door *curDoor = (Door *)_vm->_dungeonMan->getSquareFirstThingData(projectileTargetMapX, projectileTargetMapY);
+		if ((AL0487_i_DoorState != k5_doorState_DESTROYED) && (projectileAssociatedThing == Thing::_explOpenDoor)) {
+			if (curDoor->hasButton())
+				_vm->_moveSens->addEvent(k10_TMEventTypeDoor, projectileTargetMapX, projectileTargetMapY, 0, k2_SensorEffToggle, _vm->_gameTime + 1);
 			break;
 		}
 		if ((AL0487_i_DoorState == k5_doorState_DESTROYED) ||
 			(AL0487_i_DoorState <= k1_doorState_FOURTH) ||
-			(getFlag(_vm->_dungeonMan->_currMapDoorInfo[L0494_ps_Door->getType()]._attributes, k0x0002_MaskDoorInfo_ProjectilesCanPassThrough) &&
-			((L0510_i_ProjectileAssociatedThingType == k15_ExplosionThingType) ?
-			 (L0486_T_ProjectileAssociatedThing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) :
-			 ((L0490_ps_Projectile->_attack > _vm->getRandomNumber(128)) &&
-			  getFlag(_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(L0486_T_ProjectileAssociatedThing)].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)
-			  && ((L0510_i_ProjectileAssociatedThingType != k10_JunkThingType) ||
-			  ((AL0487_i_IconIndex = _vm->_objectMan->getIconIndex(L0486_T_ProjectileAssociatedThing)) < 0) ||
+			(getFlag(_vm->_dungeonMan->_currMapDoorInfo[curDoor->getType()]._attributes, k0x0002_MaskDoorInfo_ProjectilesCanPassThrough) &&
+			((projectileAssociatedThingType == k15_ExplosionThingType) ?
+			 (projectileAssociatedThing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) :
+			 ((projectileThingData->_attack > _vm->getRandomNumber(128)) &&
+			  getFlag(_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(projectileAssociatedThing)].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)
+			  && ((projectileAssociatedThingType != k10_JunkThingType) ||
+			  ((AL0487_i_IconIndex = _vm->_objectMan->getIconIndex(projectileAssociatedThing)) < 0) ||
 				  (!((AL0487_i_IconIndex >= k176_IconIndiceJunkIronKey) && (AL0487_i_IconIndex <= k191_IconIndiceJunkMasterKey))))
 			  )))) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
 			return false;
 		}
-		L0488_i_Attack = getProjectileImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing) + 1;
-		_vm->_groupMan->groupIsDoorDestoryedByAttack(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, L0488_i_Attack + _vm->getRandomNumber(L0488_i_Attack), false, 0);
+		attack = getProjectileImpactAttack(projectileThingData, projectileAssociatedThing) + 1;
+		_vm->_groupMan->groupIsDoorDestoryedByAttack(projectileTargetMapX, projectileTargetMapY, attack + _vm->getRandomNumber(attack), false, 0);
+		}
 		break;
 	case kM2_ChampionElemType:
-		if ((AP0456_i_ChampionIndex = _vm->_championMan->getIndexInCell(cell)) < 0) {
+		if ((AP0456_i_ChampionIndex = _vm->_championMan->getIndexInCell(cell)) < 0)
 			return false;
-		}
-		L0489_i_ChampionAttack = L0488_i_Attack = getProjectileImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing);
+
+		championAttack = attack = getProjectileImpactAttack(projectileThingData, projectileAssociatedThing);
 		break;
-	case kM1_CreatureElemType:
-		L0491_ps_Group = (Group *)_vm->_dungeonMan->getThingData(_vm->_groupMan->groupGetThing(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY));
-		if (!(L0512_ui_CreatureIndex = _vm->_groupMan->getCreatureOrdinalInCell(L0491_ps_Group, cell))) {
+	case kM1_CreatureElemType: {
+		Group *curGroup = (Group *)_vm->_dungeonMan->getThingData(_vm->_groupMan->groupGetThing(projectileTargetMapX, projectileTargetMapY));
+		uint16 curCreatureIndex = _vm->_groupMan->getCreatureOrdinalInCell(curGroup, cell);
+		if (!curCreatureIndex)
 			return false;
-		}
-		L0512_ui_CreatureIndex--;
-		L0493_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[L0511_ui_CreatureType = L0491_ps_Group->_type];
-		if ((L0486_T_ProjectileAssociatedThing == Thing::_explFireBall) && (L0511_ui_CreatureType == k11_CreatureTypeBlackFlame)) {
-			L0496_pui_CreatureHealth = &L0491_ps_Group->_health[L0512_ui_CreatureIndex];
-			*L0496_pui_CreatureHealth = MIN(1000, *L0496_pui_CreatureHealth + getProjectileImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing));
+
+		curCreatureIndex--;
+		uint16 curCreatureType = curGroup->_type;
+		CreatureInfo *curCreatureInfo = &_vm->_dungeonMan->_creatureInfos[curCreatureType];
+		if ((projectileAssociatedThing == Thing::_explFireBall) && (curCreatureType == k11_CreatureTypeBlackFlame)) {
+			uint16 *curCreatureHealth = &curGroup->_health[curCreatureIndex];
+			*curCreatureHealth = MIN(1000, *curCreatureHealth + getProjectileImpactAttack(projectileThingData, projectileAssociatedThing));
 			goto T0217044;
 		}
-		if (getFlag(L0493_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) && (L0486_T_ProjectileAssociatedThing != Thing::_explHarmNonMaterial)) {
+		if (getFlag(curCreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) && (projectileAssociatedThing != Thing::_explHarmNonMaterial))
 			return false;
-		}
-		L0488_i_Attack = (uint16)((unsigned long)getProjectileImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing) << 6) / L0493_ps_CreatureInfo->_defense;
-		if (L0488_i_Attack) {
-			if ((AL0487_i_Outcome = _vm->_groupMan->groupGetDamageCreatureOutcome(L0491_ps_Group, L0512_ui_CreatureIndex, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, L0488_i_Attack + _vm->_groupMan->groupGetResistanceAdjustedPoisonAttack(L0511_ui_CreatureType, _projectilePoisonAttack), true)) != k0_outcomeKilledNoCreaturesInGroup) {
-				_vm->_groupMan->processEvents29to41(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, kM2_TMEventTypeCreateReactionEvent30HitByProjectile, 0);
-			}
+
+		attack = (uint16)((unsigned long)getProjectileImpactAttack(projectileThingData, projectileAssociatedThing) << 6) / curCreatureInfo->_defense;
+		if (attack) {
+			if ((AL0487_i_Outcome = _vm->_groupMan->groupGetDamageCreatureOutcome(curGroup, curCreatureIndex, projectileTargetMapX, projectileTargetMapY, attack + _vm->_groupMan->groupGetResistanceAdjustedPoisonAttack(curCreatureType, _projectilePoisonAttack), true)) != k0_outcomeKilledNoCreaturesInGroup)
+				_vm->_groupMan->processEvents29to41(projectileTargetMapX, projectileTargetMapY, kM2_TMEventTypeCreateReactionEvent30HitByProjectile, 0);
+
 			_creatureDamageOutcome = AL0487_i_Outcome;
-			if (!L0505_B_CreateExplosionOnImpact &&
-				(AL0487_i_Outcome == k0_outcomeKilledNoCreaturesInGroup) &&
-				(L0510_i_ProjectileAssociatedThingType == k5_WeaponThingType) &&
-				getFlag(L0493_ps_CreatureInfo->_attributes, k0x0400_MaskCreatureInfo_keepThrownSharpWeapon)) {
-				L0495_ps_Weapon = (Weapon *)_vm->_dungeonMan->getThingData(L0486_T_ProjectileAssociatedThing);
-				AL0487_i_WeaponType = L0495_ps_Weapon->getType();
-				if ((AL0487_i_WeaponType == k8_WeaponTypeDagger) || (AL0487_i_WeaponType == k27_WeaponTypeArrow) || (AL0487_i_WeaponType == k28_WeaponTypeSlayer) || (AL0487_i_WeaponType == k31_WeaponTypePoisonDart) || (AL0487_i_WeaponType == k32_WeaponTypeThrowingStar)) {
-					L0497_pT_GroupSlot = &L0491_ps_Group->_slot;
-				}
+			if (!createExplosionOnImpact && (AL0487_i_Outcome == k0_outcomeKilledNoCreaturesInGroup)
+			&& (projectileAssociatedThingType == k5_WeaponThingType)
+			&& getFlag(curCreatureInfo->_attributes, k0x0400_MaskCreatureInfo_keepThrownSharpWeapon)) {
+				Weapon *weapon = (Weapon *)_vm->_dungeonMan->getThingData(projectileAssociatedThing);
+				AL0487_i_WeaponType = weapon->getType();
+				if ((AL0487_i_WeaponType == k8_WeaponTypeDagger) || (AL0487_i_WeaponType == k27_WeaponTypeArrow)
+				|| (AL0487_i_WeaponType == k28_WeaponTypeSlayer) || (AL0487_i_WeaponType == k31_WeaponTypePoisonDart)
+				|| (AL0487_i_WeaponType == k32_WeaponTypeThrowingStar))
+					curGroupSlot = &curGroup->_slot;
 			}
 		}
+		}
+		break;
 	}
-	if (L0489_i_ChampionAttack && _vm->_championMan->addPendingDamageAndWounds_getDamage(AP0456_i_ChampionIndex, L0488_i_Attack, k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso, _projectileAttackType) && _projectilePoisonAttack && _vm->getRandomNumber(2)) {
+	if (championAttack && _projectilePoisonAttack && _vm->getRandomNumber(2)
+	&& _vm->_championMan->addPendingDamageAndWounds_getDamage(AP0456_i_ChampionIndex, attack, k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso, _projectileAttackType))
 		_vm->_championMan->championPoison(AP0456_i_ChampionIndex, _projectilePoisonAttack);
-	}
-	if (L0505_B_CreateExplosionOnImpact || L0509_B_RemovePotion
-		) {
-		if (L0509_B_RemovePotion) {
-			L0486_T_ProjectileAssociatedThing = L0498_T_ExplosionThing;
-			AL0507_ui_ExplosionAttack = L0508_i_PotionPower;
+
+	if (createExplosionOnImpact || removePotion) {
+		if (removePotion) {
+			projectileAssociatedThing = explosionThing;
+			AL0507_ui_ExplosionAttack = potionPower;
 		} else {
-			AL0507_ui_ExplosionAttack = L0490_ps_Projectile->_kineticEnergy;
+			AL0507_ui_ExplosionAttack = projectileThingData->_kineticEnergy;
 		}
-		if ((L0486_T_ProjectileAssociatedThing == Thing::_explLightningBolt) && !(AL0507_ui_ExplosionAttack >>= 1))
+		if ((projectileAssociatedThing == Thing::_explLightningBolt) && !(AL0507_ui_ExplosionAttack >>= 1))
 			goto T0217044;
-		createExplosion(L0486_T_ProjectileAssociatedThing, AL0507_ui_ExplosionAttack, L0501_i_MapXCombo, L0502_i_MapYCombo, (L0486_T_ProjectileAssociatedThing == Thing::_explPoisonCloud) ? k255_CreatureTypeSingleCenteredCreature : cell);
+		createExplosion(projectileAssociatedThing, AL0507_ui_ExplosionAttack, mapXCombo, mapYCombo, (projectileAssociatedThing == Thing::_explPoisonCloud) ? k255_CreatureTypeSingleCenteredCreature : cell);
 	} else {
-		if ((L0486_T_ProjectileAssociatedThing).getType() == k5_WeaponThingType) {
+		if ((projectileAssociatedThing).getType() == k5_WeaponThingType) {
 			AL0507_ui_SoundIndex = k00_soundMETALLIC_THUD;
 		} else {
-			if (L0486_T_ProjectileAssociatedThing == Thing::_explPoisonBolt) {
+			if (projectileAssociatedThing == Thing::_explPoisonBolt) {
 				AL0507_ui_SoundIndex = k13_soundSPELL;
 			} else {
 				AL0507_ui_SoundIndex = k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM;
 			}
 		}
-		_vm->_sound->requestPlay(AL0507_ui_SoundIndex, L0499_i_ProjectileMapX, L0500_i_ProjectileMapY, k1_soundModePlayIfPrioritized);
+		_vm->_sound->requestPlay(AL0507_ui_SoundIndex, projectileMapX, projectileMapY, k1_soundModePlayIfPrioritized);
 	}
 T0217044:
-	if (L0509_B_RemovePotion) {
-		L0492_ps_Potion->_nextThing = Thing::_none;
-		L0490_ps_Projectile->_slot = L0498_T_ExplosionThing;
+	if (removePotion) {
+		potion->_nextThing = Thing::_none;
+		projectileThingData->_slot = explosionThing;
 	}
-	_vm->_dungeonMan->unlinkThingFromList(projectileThing, Thing(0), L0499_i_ProjectileMapX, L0500_i_ProjectileMapY);
-	projectileDelete(projectileThing, L0497_pT_GroupSlot, L0499_i_ProjectileMapX, L0500_i_ProjectileMapY);
+	_vm->_dungeonMan->unlinkThingFromList(projectileThing, Thing(0), projectileMapX, projectileMapY);
+	projectileDelete(projectileThing, curGroupSlot, projectileMapX, projectileMapY);
 	return true;
 }
 


Commit: 46b41f9b2bc9eb5d592e11aaad61d208c26ae903
    https://github.com/scummvm/scummvm/commit/46b41f9b2bc9eb5d592e11aaad61d208c26ae903
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-06T20:39:05+02:00

Commit Message:
DM: Split redefined variables in hasProjectileImpactOccurred()

Changed paths:
    engines/dm/projexpl.cpp



diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 87442f6..2a71e7b 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -73,16 +73,6 @@ void ProjExpl::createProjectile(Thing thing, int16 mapX, int16 mapY, uint16 cell
 }
 
 bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, int16 mapYCombo, int16 cell, Thing projectileThing) {
-#define AP0456_i_ChampionIndex cell
-	int16 L0487_i_Multiple;
-#define AL0487_i_DoorState  L0487_i_Multiple
-#define AL0487_i_IconIndex  L0487_i_Multiple
-#define AL0487_i_Outcome    L0487_i_Multiple
-#define AL0487_i_WeaponType L0487_i_Multiple
-	uint16 L0507_ui_Multiple;
-#define AL0507_ui_ExplosionAttack L0507_ui_Multiple
-#define AL0507_ui_SoundIndex      L0507_ui_Multiple
-
 	Projectile *projectileThingData = (Projectile *)_vm->_dungeonMan->getThingData(Thing(projectileThing));
 	bool removePotion = false;
 	int16 potionPower = 0;
@@ -103,7 +93,6 @@ bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, in
 	}
 	bool createExplosionOnImpact = (projectileAssociatedThingType == k15_ExplosionThingType) && (projectileAssociatedThing != Thing::_explSlime) && (projectileAssociatedThing != Thing::_explPoisonBolt);
 	Thing *curGroupSlot = nullptr;
-	int16 championAttack = 0;
 	int16 projectileMapX;
 	int16 projectileMapY;
 	int16 projectileTargetMapX = mapXCombo;
@@ -119,19 +108,23 @@ bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, in
 		projectileTargetMapY &= 0x00FF;
 	}
 
+	int16 championAttack = 0;
 	int16 attack = 0;
+	int16 championIndex = 0;
 	switch (impactType) {
 	case k4_DoorElemType: {
 		byte curSquare = _vm->_dungeonMan->_currMapData[projectileTargetMapX][projectileTargetMapY];
-		AL0487_i_DoorState = Square(curSquare).getDoorState();
+		int16 curDoorState = Square(curSquare).getDoorState();
 		Door *curDoor = (Door *)_vm->_dungeonMan->getSquareFirstThingData(projectileTargetMapX, projectileTargetMapY);
-		if ((AL0487_i_DoorState != k5_doorState_DESTROYED) && (projectileAssociatedThing == Thing::_explOpenDoor)) {
+		if ((curDoorState != k5_doorState_DESTROYED) && (projectileAssociatedThing == Thing::_explOpenDoor)) {
 			if (curDoor->hasButton())
 				_vm->_moveSens->addEvent(k10_TMEventTypeDoor, projectileTargetMapX, projectileTargetMapY, 0, k2_SensorEffToggle, _vm->_gameTime + 1);
 			break;
 		}
-		if ((AL0487_i_DoorState == k5_doorState_DESTROYED) ||
-			(AL0487_i_DoorState <= k1_doorState_FOURTH) ||
+
+		int16 AL0487_i_IconIndex;
+		if ((curDoorState == k5_doorState_DESTROYED) ||
+			(curDoorState <= k1_doorState_FOURTH) ||
 			(getFlag(_vm->_dungeonMan->_currMapDoorInfo[curDoor->getType()]._attributes, k0x0002_MaskDoorInfo_ProjectilesCanPassThrough) &&
 			((projectileAssociatedThingType == k15_ExplosionThingType) ?
 			 (projectileAssociatedThing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) :
@@ -148,7 +141,8 @@ bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, in
 		}
 		break;
 	case kM2_ChampionElemType:
-		if ((AP0456_i_ChampionIndex = _vm->_championMan->getIndexInCell(cell)) < 0)
+		championIndex = _vm->_championMan->getIndexInCell(cell);
+		if (championIndex < 0)
 			return false;
 
 		championAttack = attack = getProjectileImpactAttack(projectileThingData, projectileAssociatedThing);
@@ -172,18 +166,19 @@ bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, in
 
 		attack = (uint16)((unsigned long)getProjectileImpactAttack(projectileThingData, projectileAssociatedThing) << 6) / curCreatureInfo->_defense;
 		if (attack) {
-			if ((AL0487_i_Outcome = _vm->_groupMan->groupGetDamageCreatureOutcome(curGroup, curCreatureIndex, projectileTargetMapX, projectileTargetMapY, attack + _vm->_groupMan->groupGetResistanceAdjustedPoisonAttack(curCreatureType, _projectilePoisonAttack), true)) != k0_outcomeKilledNoCreaturesInGroup)
+			int16 outcome = _vm->_groupMan->groupGetDamageCreatureOutcome(curGroup, curCreatureIndex, projectileTargetMapX, projectileTargetMapY, attack + _vm->_groupMan->groupGetResistanceAdjustedPoisonAttack(curCreatureType, _projectilePoisonAttack), true);
+			if (outcome != k0_outcomeKilledNoCreaturesInGroup)
 				_vm->_groupMan->processEvents29to41(projectileTargetMapX, projectileTargetMapY, kM2_TMEventTypeCreateReactionEvent30HitByProjectile, 0);
 
-			_creatureDamageOutcome = AL0487_i_Outcome;
-			if (!createExplosionOnImpact && (AL0487_i_Outcome == k0_outcomeKilledNoCreaturesInGroup)
+			_creatureDamageOutcome = outcome;
+			if (!createExplosionOnImpact && (outcome == k0_outcomeKilledNoCreaturesInGroup)
 			&& (projectileAssociatedThingType == k5_WeaponThingType)
 			&& getFlag(curCreatureInfo->_attributes, k0x0400_MaskCreatureInfo_keepThrownSharpWeapon)) {
 				Weapon *weapon = (Weapon *)_vm->_dungeonMan->getThingData(projectileAssociatedThing);
-				AL0487_i_WeaponType = weapon->getType();
-				if ((AL0487_i_WeaponType == k8_WeaponTypeDagger) || (AL0487_i_WeaponType == k27_WeaponTypeArrow)
-				|| (AL0487_i_WeaponType == k28_WeaponTypeSlayer) || (AL0487_i_WeaponType == k31_WeaponTypePoisonDart)
-				|| (AL0487_i_WeaponType == k32_WeaponTypeThrowingStar))
+				WeaponType weaponType = weapon->getType();
+				if ((weaponType == k8_WeaponTypeDagger) || (weaponType == k27_WeaponTypeArrow)
+				|| (weaponType == k28_WeaponTypeSlayer) || (weaponType == k31_WeaponTypePoisonDart)
+				|| (weaponType == k32_WeaponTypeThrowingStar))
 					curGroupSlot = &curGroup->_slot;
 			}
 		}
@@ -191,30 +186,30 @@ bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, in
 		break;
 	}
 	if (championAttack && _projectilePoisonAttack && _vm->getRandomNumber(2)
-	&& _vm->_championMan->addPendingDamageAndWounds_getDamage(AP0456_i_ChampionIndex, attack, k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso, _projectileAttackType))
-		_vm->_championMan->championPoison(AP0456_i_ChampionIndex, _projectilePoisonAttack);
+	&& _vm->_championMan->addPendingDamageAndWounds_getDamage(championIndex, attack, k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso, _projectileAttackType))
+		_vm->_championMan->championPoison(championIndex, _projectilePoisonAttack);
 
 	if (createExplosionOnImpact || removePotion) {
+		uint16 explosionAttack;
 		if (removePotion) {
 			projectileAssociatedThing = explosionThing;
-			AL0507_ui_ExplosionAttack = potionPower;
+			explosionAttack = potionPower;
 		} else {
-			AL0507_ui_ExplosionAttack = projectileThingData->_kineticEnergy;
+			explosionAttack = projectileThingData->_kineticEnergy;
 		}
-		if ((projectileAssociatedThing == Thing::_explLightningBolt) && !(AL0507_ui_ExplosionAttack >>= 1))
+		if ((projectileAssociatedThing == Thing::_explLightningBolt) && !(explosionAttack >>= 1))
 			goto T0217044;
-		createExplosion(projectileAssociatedThing, AL0507_ui_ExplosionAttack, mapXCombo, mapYCombo, (projectileAssociatedThing == Thing::_explPoisonCloud) ? k255_CreatureTypeSingleCenteredCreature : cell);
+		createExplosion(projectileAssociatedThing, explosionAttack, mapXCombo, mapYCombo, (projectileAssociatedThing == Thing::_explPoisonCloud) ? k255_CreatureTypeSingleCenteredCreature : cell);
 	} else {
-		if ((projectileAssociatedThing).getType() == k5_WeaponThingType) {
-			AL0507_ui_SoundIndex = k00_soundMETALLIC_THUD;
-		} else {
-			if (projectileAssociatedThing == Thing::_explPoisonBolt) {
-				AL0507_ui_SoundIndex = k13_soundSPELL;
-			} else {
-				AL0507_ui_SoundIndex = k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM;
-			}
-		}
-		_vm->_sound->requestPlay(AL0507_ui_SoundIndex, projectileMapX, projectileMapY, k1_soundModePlayIfPrioritized);
+		uint16 soundIndex;
+		if ((projectileAssociatedThing).getType() == k5_WeaponThingType)
+			soundIndex = k00_soundMETALLIC_THUD;
+		else if (projectileAssociatedThing == Thing::_explPoisonBolt)
+			soundIndex = k13_soundSPELL;
+		else
+			soundIndex = k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM;
+
+		_vm->_sound->requestPlay(soundIndex, projectileMapX, projectileMapY, k1_soundModePlayIfPrioritized);
 	}
 T0217044:
 	if (removePotion) {


Commit: 92ca2ae87bd1702160853c8187ef8ef4adead950
    https://github.com/scummvm/scummvm/commit/92ca2ae87bd1702160853c8187ef8ef4adead950
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-06T22:36:59+02:00

Commit Message:
DM: Rework a if statement in hasProjectileImpactOccurred to make it readable

Changed paths:
    engines/dm/projexpl.cpp



diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 2a71e7b..25e0b58 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -122,19 +122,24 @@ bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, in
 			break;
 		}
 
-		int16 AL0487_i_IconIndex;
-		if ((curDoorState == k5_doorState_DESTROYED) ||
-			(curDoorState <= k1_doorState_FOURTH) ||
-			(getFlag(_vm->_dungeonMan->_currMapDoorInfo[curDoor->getType()]._attributes, k0x0002_MaskDoorInfo_ProjectilesCanPassThrough) &&
-			((projectileAssociatedThingType == k15_ExplosionThingType) ?
-			 (projectileAssociatedThing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) :
-			 ((projectileThingData->_attack > _vm->getRandomNumber(128)) &&
-			  getFlag(_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(projectileAssociatedThing)].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)
-			  && ((projectileAssociatedThingType != k10_JunkThingType) ||
-			  ((AL0487_i_IconIndex = _vm->_objectMan->getIconIndex(projectileAssociatedThing)) < 0) ||
-				  (!((AL0487_i_IconIndex >= k176_IconIndiceJunkIronKey) && (AL0487_i_IconIndex <= k191_IconIndiceJunkMasterKey))))
-			  )))) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
+		if ((curDoorState == k5_doorState_DESTROYED) || (curDoorState <= k1_doorState_FOURTH))
 			return false;
+
+		DoorInfo curDoorInfo = _vm->_dungeonMan->_currMapDoorInfo[curDoor->getType()];
+		if (getFlag(curDoorInfo._attributes, k0x0002_MaskDoorInfo_ProjectilesCanPassThrough)) {
+			if (projectileAssociatedThingType == k15_ExplosionThingType) {
+				if (projectileAssociatedThing.toUint16() >= Thing::_explHarmNonMaterial.toUint16())
+					return false;
+			} else {
+				int16 associatedThingIndex = _vm->_dungeonMan->getObjectInfoIndex(projectileAssociatedThing);
+				if ((projectileThingData->_attack > _vm->getRandomNumber(128))
+				&& getFlag(_vm->_dungeonMan->_objectInfos[associatedThingIndex].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)) {
+
+					int16 iconIndex = _vm->_objectMan->getIconIndex(projectileAssociatedThing);
+					if ((projectileAssociatedThingType != k10_JunkThingType) || (iconIndex < k176_IconIndiceJunkIronKey) || (iconIndex > k191_IconIndiceJunkMasterKey))
+						return false;
+				}
+			}
 		}
 		attack = getProjectileImpactAttack(projectileThingData, projectileAssociatedThing) + 1;
 		_vm->_groupMan->groupIsDoorDestoryedByAttack(projectileTargetMapX, projectileTargetMapY, attack + _vm->getRandomNumber(attack), false, 0);


Commit: 78085dcd8d376e6f66f753fa40fc5537ba604d42
    https://github.com/scummvm/scummvm/commit/78085dcd8d376e6f66f753fa40fc5537ba604d42
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-06T22:52:58+02:00

Commit Message:
DM: Take Dreammaster's suggestion into account to make it even more readable

Changed paths:
    engines/dm/projexpl.cpp



diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 25e0b58..3bcd3ca 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -132,12 +132,16 @@ bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, in
 					return false;
 			} else {
 				int16 associatedThingIndex = _vm->_dungeonMan->getObjectInfoIndex(projectileAssociatedThing);
-				if ((projectileThingData->_attack > _vm->getRandomNumber(128))
-				&& getFlag(_vm->_dungeonMan->_objectInfos[associatedThingIndex].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)) {
+				uint16 associatedAllowedSlots = _vm->_dungeonMan->_objectInfos[associatedThingIndex].getAllowedSlots();
+				int16 iconIndex = _vm->_objectMan->getIconIndex(projectileAssociatedThing);
 
-					int16 iconIndex = _vm->_objectMan->getIconIndex(projectileAssociatedThing);
-					if ((projectileAssociatedThingType != k10_JunkThingType) || (iconIndex < k176_IconIndiceJunkIronKey) || (iconIndex > k191_IconIndiceJunkMasterKey))
-						return false;
+				if ((projectileThingData->_attack > _vm->getRandomNumber(128))
+				&& getFlag(associatedAllowedSlots, k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)
+				&& (   (projectileAssociatedThingType != k10_JunkThingType)
+					|| (iconIndex < k176_IconIndiceJunkIronKey)
+					|| (iconIndex > k191_IconIndiceJunkMasterKey)
+					)) {
+					return false;
 				}
 			}
 		}


Commit: 6df9a20b8549196e20a79b6972edb338b1b22110
    https://github.com/scummvm/scummvm/commit/6df9a20b8549196e20a79b6972edb338b1b22110
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-06T23:45:56+02:00

Commit Message:
DM: Renaming in ProjExpl

Changed paths:
    engines/dm/projexpl.cpp



diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 3bcd3ca..c87a4fb 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -230,120 +230,116 @@ T0217044:
 	return true;
 }
 
-uint16 ProjExpl::getProjectileImpactAttack(Projectile* projectile, Thing thing) {
-	WeaponInfo* L0485_ps_WeaponInfo;
-	uint16 L0483_ui_Multiple;
-#define AL0483_ui_ThingType L0483_ui_Multiple
-#define AL0483_ui_Attack    L0483_ui_Multiple
-	uint16 L0484_ui_KineticEnergy;
-
-
+uint16 ProjExpl::getProjectileImpactAttack(Projectile *projectile, Thing thing) {
 	_projectilePoisonAttack = 0;
 	_projectileAttackType = k3_attackType_BLUNT;
 
-	L0484_ui_KineticEnergy = projectile->_kineticEnergy;
-	if ((AL0483_ui_ThingType = thing.getType()) != k15_ExplosionThingType) {
-		if (AL0483_ui_ThingType == k5_WeaponThingType) {
-			L0485_ps_WeaponInfo = _vm->_dungeonMan->getWeaponInfo(thing);
-			AL0483_ui_Attack = L0485_ps_WeaponInfo->_kineticEnergy;
+	uint16 kineticEnergy = projectile->_kineticEnergy;
+	ThingType thingType = thing.getType();
+	uint16 attack;
+	if (thingType != k15_ExplosionThingType) {
+		if (thingType == k5_WeaponThingType) {
+			WeaponInfo *weaponInfo = _vm->_dungeonMan->getWeaponInfo(thing);
+			attack = weaponInfo->_kineticEnergy;
 			_projectileAttackType = k3_attackType_BLUNT;
-		} else {
-			AL0483_ui_Attack = _vm->getRandomNumber(4);
-		}
-		AL0483_ui_Attack += _vm->_dungeonMan->getObjectWeight(thing) >> 1;
+		} else
+			attack = _vm->getRandomNumber(4);
+
+		attack += _vm->_dungeonMan->getObjectWeight(thing) >> 1;
+	} else if (thing == Thing::_explSlime) {
+		attack = _vm->getRandomNumber(16);
+		_projectilePoisonAttack = attack + 10;
+		attack += _vm->getRandomNumber(32);
 	} else {
-		if (thing == Thing::_explSlime) {
-			AL0483_ui_Attack = _vm->getRandomNumber(16);
-			_projectilePoisonAttack = AL0483_ui_Attack + 10;
-			AL0483_ui_Attack += _vm->getRandomNumber(32);
-		} else {
-			if (thing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) {
-				_projectileAttackType = k5_attackType_MAGIC;
-				if (thing == Thing::_explPoisonBolt) {
-					_projectilePoisonAttack = L0484_ui_KineticEnergy;
-					return 1;
-				}
-				return 0;
-			}
-			_projectileAttackType = k1_attackType_FIRE;
-			AL0483_ui_Attack = _vm->getRandomNumber(16) + _vm->getRandomNumber(16) + 10;
-			if (thing == Thing::_explLightningBolt) {
-				_projectileAttackType = k7_attackType_LIGHTNING;
-				AL0483_ui_Attack *= 5;
+		if (thing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) {
+			_projectileAttackType = k5_attackType_MAGIC;
+			if (thing == Thing::_explPoisonBolt) {
+				_projectilePoisonAttack = kineticEnergy;
+				return 1;
 			}
+			return 0;
+		}
+		_projectileAttackType = k1_attackType_FIRE;
+		attack = _vm->getRandomNumber(16) + _vm->getRandomNumber(16) + 10;
+		if (thing == Thing::_explLightningBolt) {
+			_projectileAttackType = k7_attackType_LIGHTNING;
+			attack *= 5;
 		}
 	}
-	AL0483_ui_Attack = ((AL0483_ui_Attack + L0484_ui_KineticEnergy) >> 4) + 1;
-	AL0483_ui_Attack += _vm->getRandomNumber((AL0483_ui_Attack >> 1) + 1) + _vm->getRandomNumber(4);
-	AL0483_ui_Attack = MAX(AL0483_ui_Attack >> 1, AL0483_ui_Attack - (32 - (projectile->_attack >> 3)));
-	return AL0483_ui_Attack;
+	attack = ((attack + kineticEnergy) >> 4) + 1;
+	attack += _vm->getRandomNumber((attack >> 1) + 1) + _vm->getRandomNumber(4);
+	attack = MAX(attack >> 1, attack - (32 - (projectile->_attack >> 3)));
+	return attack;
 }
 
 void ProjExpl::createExplosion(Thing explThing, uint16 attack, uint16 mapXCombo, uint16 mapYCombo, uint16 cell) {
-#define AP0443_ui_ProjectileMapX mapXCombo
-#define AP0444_ui_ProjectileMapY mapYCombo
-	Thing L0473_T_Thing = _vm->_dungeonMan->getUnusedThing(k15_ExplosionThingType);
-	if (L0473_T_Thing == Thing::_none) {
+	Thing unusedThing = _vm->_dungeonMan->getUnusedThing(k15_ExplosionThingType);
+	if (unusedThing == Thing::_none)
 		return;
-	}
 
-	Explosion *L0470_ps_Explosion = &((Explosion *)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[(L0473_T_Thing).getIndex()];
-	int16 L0474_i_ProjectileTargetMapX;
-	int16 L0475_i_ProjectileTargetMapY;
+	Explosion *explosion = &((Explosion *)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[(unusedThing).getIndex()];
+	int16 projectileTargetMapX;
+	int16 projectileTargetMapY;
+	uint16 projectileMapX = mapXCombo;
+	uint16 projectileMapY = mapYCombo;
+
 	if (mapXCombo <= 255) {
-		L0474_i_ProjectileTargetMapX = mapXCombo;
-		L0475_i_ProjectileTargetMapY = mapYCombo;
+		projectileTargetMapX = mapXCombo;
+		projectileTargetMapY = mapYCombo;
 	} else {
-		L0474_i_ProjectileTargetMapX = mapXCombo & 0x00FF;
-		L0475_i_ProjectileTargetMapY = mapYCombo & 0x00FF;
-		AP0443_ui_ProjectileMapX >>= 8;
-		AP0443_ui_ProjectileMapX--;
-		AP0444_ui_ProjectileMapY >>= 8;
+		projectileTargetMapX = mapXCombo & 0x00FF;
+		projectileTargetMapY = mapYCombo & 0x00FF;
+		projectileMapX >>= 8;
+		projectileMapX--;
+		projectileMapY >>= 8;
 	}
-	if (cell == k255_CreatureTypeSingleCenteredCreature) {
-		L0470_ps_Explosion->setCentered(true);
-	} else {
-		L0470_ps_Explosion->setCentered(false);
-		L0473_T_Thing = thingWithNewCell(L0473_T_Thing, cell);
+
+	if (cell == k255_CreatureTypeSingleCenteredCreature)
+		explosion->setCentered(true);
+	else {
+		explosion->setCentered(false);
+		unusedThing = thingWithNewCell(unusedThing, cell);
 	}
-	L0470_ps_Explosion->setType(explThing.toUint16() - Thing::_firstExplosion.toUint16());
-	L0470_ps_Explosion->setAttack(attack);
+
+	explosion->setType(explThing.toUint16() - Thing::_firstExplosion.toUint16());
+	explosion->setAttack(attack);
 	if (explThing.toUint16() < Thing::_explHarmNonMaterial.toUint16()) {
-		_vm->_sound->requestPlay((attack > 80) ? k05_soundSTRONG_EXPLOSION : k20_soundWEAK_EXPLOSION, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized);
-	} else {
-		if (explThing != Thing::_explSmoke) {
-			_vm->_sound->requestPlay(k13_soundSPELL, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized);
-		}
-	}
-	_vm->_dungeonMan->linkThingToList(L0473_T_Thing, Thing(0), AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY);
-	TimelineEvent L0476_s_Event;
-	setMapAndTime(L0476_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + ((explThing == Thing::_explRebirthStep1) ? 5 : 1));
-	L0476_s_Event._type = k25_TMEventTypeExplosion;
-	L0476_s_Event._priority = 0;
-	L0476_s_Event._C._slot = L0473_T_Thing.toUint16();
-	L0476_s_Event._B._location._mapX = AP0443_ui_ProjectileMapX;
-	L0476_s_Event._B._location._mapY = AP0444_ui_ProjectileMapY;
-	_vm->_timeline->addEventGetEventIndex(&L0476_s_Event);
+		uint16 soundIndex = (attack > 80) ? k05_soundSTRONG_EXPLOSION : k20_soundWEAK_EXPLOSION;
+		_vm->_sound->requestPlay(soundIndex, projectileMapX, projectileMapY, k1_soundModePlayIfPrioritized);
+	} else if (explThing != Thing::_explSmoke)
+		_vm->_sound->requestPlay(k13_soundSPELL, projectileMapX, projectileMapY, k1_soundModePlayIfPrioritized);
+
+	_vm->_dungeonMan->linkThingToList(unusedThing, Thing(0), projectileMapX, projectileMapY);
+	TimelineEvent newEvent;
+	setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + ((explThing == Thing::_explRebirthStep1) ? 5 : 1));
+	newEvent._type = k25_TMEventTypeExplosion;
+	newEvent._priority = 0;
+	newEvent._C._slot = unusedThing.toUint16();
+	newEvent._B._location._mapX = projectileMapX;
+	newEvent._B._location._mapY = projectileMapY;
+	_vm->_timeline->addEventGetEventIndex(&newEvent);
 	if ((explThing == Thing::_explLightningBolt) || (explThing == Thing::_explFireBall)) {
-		AP0443_ui_ProjectileMapX = L0474_i_ProjectileTargetMapX;
-		AP0444_ui_ProjectileMapY = L0475_i_ProjectileTargetMapY;
+		projectileMapX = projectileTargetMapX;
+		projectileMapY = projectileTargetMapY;
 		attack = (attack >> 1) + 1;
 		attack += _vm->getRandomNumber(attack) + 1;
 		if ((explThing == Thing::_explFireBall) || (attack >>= 1)) {
-			if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (AP0443_ui_ProjectileMapX == _vm->_dungeonMan->_partyMapX) && (AP0444_ui_ProjectileMapY == _vm->_dungeonMan->_partyMapY)) {
-				_vm->_championMan->getDamagedChampionCount(attack, k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand | k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k1_attackType_FIRE);
+			if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (projectileMapX == _vm->_dungeonMan->_partyMapX) && (projectileMapY == _vm->_dungeonMan->_partyMapY)) {
+				int16 wounds = k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand | k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet;
+				_vm->_championMan->getDamagedChampionCount(attack, wounds, k1_attackType_FIRE);
 			} else {
-				if ((L0473_T_Thing = _vm->_groupMan->groupGetThing(AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY)) != Thing::_endOfList) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
-					Group *L0472_ps_Group = (Group *)_vm->_dungeonMan->getThingData(L0473_T_Thing);
-					CreatureInfo *L0471_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[L0472_ps_Group->_type];
-					int16 L0469_i_CreatureFireResistance = L0471_ps_CreatureInfo->getFireResistance();
-					if (L0469_i_CreatureFireResistance != k15_immuneToFire) {
-						if (getFlag(L0471_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
+				unusedThing = _vm->_groupMan->groupGetThing(projectileMapX, projectileMapY);
+				if (unusedThing != Thing::_endOfList) {
+					Group *creatureGroup = (Group *)_vm->_dungeonMan->getThingData(unusedThing);
+					CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[creatureGroup->_type];
+					int16 creatureFireResistance = creatureInfo->getFireResistance();
+					if (creatureFireResistance != k15_immuneToFire) {
+						if (getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial))
 							attack >>= 2;
-						}
-						if ((attack -= _vm->getRandomNumber((L0469_i_CreatureFireResistance << 1) + 1)) > 0) {
-							_creatureDamageOutcome = _vm->_groupMan->getDamageAllCreaturesOutcome(L0472_ps_Group, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, attack, true);
-						}
+
+						if ((attack -= _vm->getRandomNumber((creatureFireResistance << 1) + 1)) > 0)
+							_creatureDamageOutcome = _vm->_groupMan->getDamageAllCreaturesOutcome(creatureGroup, projectileMapX, projectileMapY, attack, true);
+
 					}
 				}
 			}
@@ -352,55 +348,46 @@ void ProjExpl::createExplosion(Thing explThing, uint16 attack, uint16 mapXCombo,
 }
 
 int16 ProjExpl::projectileGetImpactCount(int16 impactType, int16 mapX, int16 mapY, int16 cell) {
-	Thing L0513_T_Thing;
-	int16 L0514_i_ImpactCount;
-
-
-	L0514_i_ImpactCount = 0;
+	int16 impactCount = 0;
 	_creatureDamageOutcome = k0_outcomeKilledNoCreaturesInGroup;
 T0218001:
-	L0513_T_Thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
-	while (L0513_T_Thing != Thing::_endOfList) {
-		if (((L0513_T_Thing).getType() == k14_ProjectileThingType) &&
-			((L0513_T_Thing).getCell() == cell) &&
-			hasProjectileImpactOccurred(impactType, mapX, mapY, cell, L0513_T_Thing)) {
-			projectileDeleteEvent(L0513_T_Thing);
-			L0514_i_ImpactCount++;
+	Thing curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+	while (curThing != Thing::_endOfList) {
+		if (((curThing).getType() == k14_ProjectileThingType) &&
+			((curThing).getCell() == cell) &&
+			hasProjectileImpactOccurred(impactType, mapX, mapY, cell, curThing)) {
+			projectileDeleteEvent(curThing);
+			impactCount++;
 			if ((impactType == kM1_CreatureElemType) && (_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup))
 				break;
 			goto T0218001;
 		}
-		L0513_T_Thing = _vm->_dungeonMan->getNextThing(L0513_T_Thing);
+		curThing = _vm->_dungeonMan->getNextThing(curThing);
 	}
-	return L0514_i_ImpactCount;
+	return impactCount;
 }
 
 void ProjExpl::projectileDeleteEvent(Thing thing) {
-	Projectile* L0477_ps_Projectile;
-
-
-	L0477_ps_Projectile = (Projectile *)_vm->_dungeonMan->getThingData(thing);
-	_vm->_timeline->deleteEvent(L0477_ps_Projectile->_eventIndex);
+	Projectile *projectile = (Projectile *)_vm->_dungeonMan->getThingData(thing);
+	_vm->_timeline->deleteEvent(projectile->_eventIndex);
 }
 
-void ProjExpl::projectileDelete(Thing projectileThing, Thing* groupSlot, int16 mapX, int16 mapY) {
-	Projectile *L0480_ps_Projectile = (Projectile *)_vm->_dungeonMan->getThingData(projectileThing);
-	Thing L0479_T_Thing = L0480_ps_Projectile->_slot;
-	if (L0479_T_Thing.getType() != k15_ExplosionThingType) {
+void ProjExpl::projectileDelete(Thing projectileThing, Thing *groupSlot, int16 mapX, int16 mapY) {
+	Projectile *projectile = (Projectile *)_vm->_dungeonMan->getThingData(projectileThing);
+	Thing projectileSlotThing = projectile->_slot;
+	if (projectileSlotThing.getType() != k15_ExplosionThingType) {
 		if (groupSlot != NULL) {
-			Thing L0478_T_PreviousThing = *groupSlot;
-			if (L0478_T_PreviousThing == Thing::_endOfList) {
-				Thing *L0481_ps_Generic = (Thing *)_vm->_dungeonMan->getThingData(L0479_T_Thing);
-				*L0481_ps_Generic = Thing::_endOfList;
-				*groupSlot = L0479_T_Thing;
-			} else {
-				_vm->_dungeonMan->linkThingToList(L0479_T_Thing, L0478_T_PreviousThing, kM1_MapXNotOnASquare, 0);
-			}
-		} else {
-			_vm->_moveSens->getMoveResult(Thing((L0479_T_Thing).getTypeAndIndex() | getFlag(projectileThing.toUint16(), 0xC)), -2, 0, mapX, mapY);
-		}
+			Thing previousThing = *groupSlot;
+			if (previousThing == Thing::_endOfList) {
+				Thing *genericThing = (Thing *)_vm->_dungeonMan->getThingData(projectileSlotThing);
+				*genericThing = Thing::_endOfList;
+				*groupSlot = projectileSlotThing;
+			} else
+				_vm->_dungeonMan->linkThingToList(projectileSlotThing, previousThing, kM1_MapXNotOnASquare, 0);
+		} else
+			_vm->_moveSens->getMoveResult(Thing((projectileSlotThing).getTypeAndIndex() | getFlag(projectileThing.toUint16(), 0xC)), -2, 0, mapX, mapY);
 	}
-	L0480_ps_Projectile->_nextThing = Thing::_none;
+	projectile->_nextThing = Thing::_none;
 }
 
 void ProjExpl::processEvents48To49(TimelineEvent* event) {


Commit: 8f33b469bef763e6603afe6b9818e2c3eee6999c
    https://github.com/scummvm/scummvm/commit/8f33b469bef763e6603afe6b9818e2c3eee6999c
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-07T07:14:50+02:00

Commit Message:
DM: Get rid of a GOTO in projectileGetImpactCount

Changed paths:
    engines/dm/projexpl.cpp



diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index c87a4fb..f5c0a71 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -350,19 +350,18 @@ void ProjExpl::createExplosion(Thing explThing, uint16 attack, uint16 mapXCombo,
 int16 ProjExpl::projectileGetImpactCount(int16 impactType, int16 mapX, int16 mapY, int16 cell) {
 	int16 impactCount = 0;
 	_creatureDamageOutcome = k0_outcomeKilledNoCreaturesInGroup;
-T0218001:
-	Thing curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
-	while (curThing != Thing::_endOfList) {
-		if (((curThing).getType() == k14_ProjectileThingType) &&
-			((curThing).getCell() == cell) &&
+	
+	for (Thing curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY); curThing != Thing::_endOfList; ) {
+		if (((curThing).getType() == k14_ProjectileThingType) && ((curThing).getCell() == cell) &&
 			hasProjectileImpactOccurred(impactType, mapX, mapY, cell, curThing)) {
 			projectileDeleteEvent(curThing);
 			impactCount++;
 			if ((impactType == kM1_CreatureElemType) && (_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup))
 				break;
-			goto T0218001;
-		}
-		curThing = _vm->_dungeonMan->getNextThing(curThing);
+
+			Thing curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+		} else
+			curThing = _vm->_dungeonMan->getNextThing(curThing);
 	}
 	return impactCount;
 }


Commit: 57d950b46fa7a926e6dfffd916606902e6c29308
    https://github.com/scummvm/scummvm/commit/57d950b46fa7a926e6dfffd916606902e6c29308
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-07T07:45:24+02:00

Commit Message:
DM: Refactor processEvents48To49

Changed paths:
    engines/dm/projexpl.cpp



diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index f5c0a71..a24fb43 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -390,94 +390,83 @@ void ProjExpl::projectileDelete(Thing projectileThing, Thing *groupSlot, int16 m
 }
 
 void ProjExpl::processEvents48To49(TimelineEvent* event) {
-	TimelineEvent* L0519_ps_Event;
-	Projectile* L0520_ps_Projectile;
-	Thing L0515_T_ProjectileThingNewCell;
-	uint16 L0516_ui_Multiple;
-#define AL0516_ui_StepEnergy L0516_ui_Multiple
-#define AL0516_ui_Square     L0516_ui_Multiple
-	Thing L0521_T_ProjectileThing;
-	uint16 L0517_ui_ProjectileDirection;
-	bool L0522_B_ProjectileMovesToOtherSquare;
-	int16 L0523_i_DestinationMapX;
-	int16 L0524_i_DestinationMapY;
-	uint16 L0518_ui_Cell;
-	int16 L0525_i_SourceMapX = -1;
-	int16 L0526_i_SourceMapY = -1;
-	TimelineEvent L0527_s_Event;
-
-
-	L0527_s_Event = *event;
-	L0519_ps_Event = &L0527_s_Event;
-	L0520_ps_Projectile = (Projectile*)_vm->_dungeonMan->getThingData(L0521_T_ProjectileThing = L0515_T_ProjectileThingNewCell = Thing(L0519_ps_Event->_B._slot));
-	L0523_i_DestinationMapX = L0519_ps_Event->_C._projectile.getMapX();
-	L0524_i_DestinationMapY = L0519_ps_Event->_C._projectile.getMapY();
-	if (L0519_ps_Event->_type == k48_TMEventTypeMoveProjectileIgnoreImpacts) {
-		L0519_ps_Event->_type = k49_TMEventTypeMoveProjectile;
-	} else {
-		L0518_ui_Cell = (L0515_T_ProjectileThingNewCell).getCell();
-		if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0523_i_DestinationMapX == _vm->_dungeonMan->_partyMapX) && (L0524_i_DestinationMapY == _vm->_dungeonMan->_partyMapY) && hasProjectileImpactOccurred(kM2_ChampionElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
+	int16 sourceMapX = -1;
+	int16 sourceMapY = -1;
+	TimelineEvent firstEvent = *event;
+	TimelineEvent *curEvent = &firstEvent;
+	Thing projectileThingNewCell = Thing(curEvent->_B._slot);
+	Thing projectileThing  = projectileThingNewCell;
+	Projectile *projectile = (Projectile*)_vm->_dungeonMan->getThingData(projectileThing);
+	int16 destinationMapX = curEvent->_C._projectile.getMapX();
+	int16 destinationMapY = curEvent->_C._projectile.getMapY();
+
+	if (curEvent->_type == k48_TMEventTypeMoveProjectileIgnoreImpacts)
+		curEvent->_type = k49_TMEventTypeMoveProjectile;
+	else {
+		uint16 projectileCurCell = projectileThingNewCell.getCell();
+		if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (destinationMapX == _vm->_dungeonMan->_partyMapX) && (destinationMapY == _vm->_dungeonMan->_partyMapY) && hasProjectileImpactOccurred(kM2_ChampionElemType, destinationMapX, destinationMapY, projectileCurCell, projectileThingNewCell))
 			return;
-		}
-		if ((_vm->_groupMan->groupGetThing(L0523_i_DestinationMapX, L0524_i_DestinationMapY) != Thing::_endOfList) && hasProjectileImpactOccurred(kM1_CreatureElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
+
+		if ((_vm->_groupMan->groupGetThing(destinationMapX, destinationMapY) != Thing::_endOfList) && hasProjectileImpactOccurred(kM1_CreatureElemType, destinationMapX, destinationMapY, projectileCurCell, projectileThing))
 			return;
-		}
-		if (L0520_ps_Projectile->_kineticEnergy <= (AL0516_ui_StepEnergy = L0519_ps_Event->_C._projectile.getStepEnergy())) {
-			_vm->_dungeonMan->unlinkThingFromList(L0515_T_ProjectileThingNewCell = L0521_T_ProjectileThing, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
-			projectileDelete(L0515_T_ProjectileThingNewCell, NULL, L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+
+		uint16 stepEnergy = curEvent->_C._projectile.getStepEnergy();
+		if (projectile->_kineticEnergy <= stepEnergy) {
+			_vm->_dungeonMan->unlinkThingFromList(projectileThingNewCell = projectileThing, Thing(0), destinationMapX, destinationMapY);
+			projectileDelete(projectileThingNewCell, NULL, destinationMapX, destinationMapY);
 			return;
 		}
-		L0520_ps_Projectile->_kineticEnergy -= AL0516_ui_StepEnergy;
-		if (L0520_ps_Projectile->_attack < AL0516_ui_StepEnergy) {
-			L0520_ps_Projectile->_attack = 0;
-		} else {
-			L0520_ps_Projectile->_attack -= AL0516_ui_StepEnergy;
-		}
+		projectile->_kineticEnergy -= stepEnergy;
+		if (projectile->_attack < stepEnergy)
+			projectile->_attack = 0;
+		else
+			projectile->_attack -= stepEnergy;
 	}
-	L0517_ui_ProjectileDirection = L0519_ps_Event->_C._projectile.getDir();
-	L0515_T_ProjectileThingNewCell = Thing(L0519_ps_Event->_B._slot);
-	L0518_ui_Cell = L0515_T_ProjectileThingNewCell.getCell();
-	L0522_B_ProjectileMovesToOtherSquare = (L0517_ui_ProjectileDirection == L0518_ui_Cell) || (returnNextVal(L0517_ui_ProjectileDirection) == L0518_ui_Cell);
-	if (L0522_B_ProjectileMovesToOtherSquare) {
-		L0525_i_SourceMapX = L0523_i_DestinationMapX;
-		L0526_i_SourceMapY = L0524_i_DestinationMapY;
-		L0523_i_DestinationMapX += _vm->_dirIntoStepCountEast[L0517_ui_ProjectileDirection], L0524_i_DestinationMapY += _vm->_dirIntoStepCountNorth[L0517_ui_ProjectileDirection];
-		AL0516_ui_Square = _vm->_dungeonMan->getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY).toByte();
-		if ((Square(AL0516_ui_Square).getType() == k0_WallElemType) ||
-			((Square(AL0516_ui_Square).getType() == k6_FakeWallElemType) && !getFlag(AL0516_ui_Square, (k0x0001_FakeWallImaginary | k0x0004_FakeWallOpen))) ||
-			((Square(AL0516_ui_Square).getType() == k3_StairsElemType) && (Square(_vm->_dungeonMan->_currMapData[L0525_i_SourceMapX][L0526_i_SourceMapY]).getType() == k3_StairsElemType))) {
-			if (hasProjectileImpactOccurred(Square(AL0516_ui_Square).getType(), L0525_i_SourceMapX, L0526_i_SourceMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
+	uint16 projectileDirection = curEvent->_C._projectile.getDir();
+	projectileThingNewCell = Thing(curEvent->_B._slot);
+	uint16 projectileNewCell = projectileThingNewCell.getCell();
+	bool projectileMovesToOtherSquare = (projectileDirection == projectileNewCell) || (returnNextVal(projectileDirection) == projectileNewCell);
+	if (projectileMovesToOtherSquare) {
+		sourceMapX = destinationMapX;
+		sourceMapY = destinationMapY;
+		destinationMapX += _vm->_dirIntoStepCountEast[projectileDirection], destinationMapY += _vm->_dirIntoStepCountNorth[projectileDirection];
+		Square destSquare = _vm->_dungeonMan->getSquare(destinationMapX, destinationMapY);
+		SquareType destSquareType = destSquare.getType();
+		if ((destSquareType == k0_WallElemType) ||
+			((destSquareType == k6_FakeWallElemType) && !getFlag(destSquare.toByte(), (k0x0001_FakeWallImaginary | k0x0004_FakeWallOpen))) ||
+			((destSquareType == k3_StairsElemType) && (Square(_vm->_dungeonMan->_currMapData[sourceMapX][sourceMapY]).getType() == k3_StairsElemType))) {
+			if (hasProjectileImpactOccurred(destSquare.getType(), sourceMapX, sourceMapY, projectileNewCell, projectileThingNewCell)) {
 				return;
 			}
 		}
 	}
-	if ((L0517_ui_ProjectileDirection & 0x0001) == (L0518_ui_Cell & 0x0001)) {
-		L0518_ui_Cell--;
-	} else {
-		L0518_ui_Cell++;
-	}
-	L0515_T_ProjectileThingNewCell = thingWithNewCell(L0515_T_ProjectileThingNewCell, L0518_ui_Cell &= 0x0003);
-	if (L0522_B_ProjectileMovesToOtherSquare) {
-		_vm->_moveSens->getMoveResult(L0515_T_ProjectileThingNewCell, L0525_i_SourceMapX, L0526_i_SourceMapY, L0523_i_DestinationMapX, L0524_i_DestinationMapY);
-		L0519_ps_Event->_C._projectile.setMapX(_vm->_moveSens->_moveResultMapX);
-		L0519_ps_Event->_C._projectile.setMapY(_vm->_moveSens->_moveResultMapY);
-		L0519_ps_Event->_C._projectile.setDir((Direction)_vm->_moveSens->_moveResultDir);
-		L0515_T_ProjectileThingNewCell = thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_moveSens->_moveResultCell);
-		M31_setMap(L0519_ps_Event->_mapTime, _vm->_moveSens->_moveResultMapIndex);
+
+	if ((projectileDirection & 0x0001) == (projectileNewCell & 0x0001))
+		projectileNewCell--;
+	else
+		projectileNewCell++;
+
+	projectileThingNewCell = thingWithNewCell(projectileThingNewCell, projectileNewCell &= 0x0003);
+	if (projectileMovesToOtherSquare) {
+		_vm->_moveSens->getMoveResult(projectileThingNewCell, sourceMapX, sourceMapY, destinationMapX, destinationMapY);
+		curEvent->_C._projectile.setMapX(_vm->_moveSens->_moveResultMapX);
+		curEvent->_C._projectile.setMapY(_vm->_moveSens->_moveResultMapY);
+		curEvent->_C._projectile.setDir((Direction)_vm->_moveSens->_moveResultDir);
+		projectileThingNewCell = thingWithNewCell(projectileThingNewCell, _vm->_moveSens->_moveResultCell);
+		M31_setMap(curEvent->_mapTime, _vm->_moveSens->_moveResultMapIndex);
 	} else {
-		if ((Square(_vm->_dungeonMan->getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY)).getType() == k4_DoorElemType) && hasProjectileImpactOccurred(k4_DoorElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
+		if ((Square(_vm->_dungeonMan->getSquare(destinationMapX, destinationMapY)).getType() == k4_DoorElemType) && hasProjectileImpactOccurred(k4_DoorElemType, destinationMapX, destinationMapY, projectileNewCell, projectileThing))
 			return;
-		}
-		_vm->_dungeonMan->unlinkThingFromList(L0515_T_ProjectileThingNewCell, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
-		_vm->_dungeonMan->linkThingToList(L0515_T_ProjectileThingNewCell, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+
+		_vm->_dungeonMan->unlinkThingFromList(projectileThingNewCell, Thing(0), destinationMapX, destinationMapY);
+		_vm->_dungeonMan->linkThingToList(projectileThingNewCell, Thing(0), destinationMapX, destinationMapY);
 	}
-	L0519_ps_Event->_mapTime += (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) ? 1 : 3;
-	//Strangerke: CHECKME: Maybe we should keep that piece of code too as it sounds like it's fixing a weird behavior of projectiles on different maps
-#ifdef COMPILE42_CSB20EN_CSB21EN /* CHANGE7_20_IMPROVEMENT Projectiles now move at the same speed on all maps instead of moving slower on maps other than the party map */
-	L0519_ps_Event->Map_Time++;
-#endif
-	L0519_ps_Event->_B._slot = L0515_T_ProjectileThingNewCell.toUint16();
-	L0520_ps_Projectile->_eventIndex = _vm->_timeline->addEventGetEventIndex(L0519_ps_Event);
+
+	// This code is from CSB20. The projectiles move at the same speed on all maps instead of moving slower on maps other than the party map */
+	curEvent->_mapTime++;
+
+	curEvent->_B._slot = projectileThingNewCell.toUint16();
+	projectile->_eventIndex = _vm->_timeline->addEventGetEventIndex(curEvent);
 }
 
 void ProjExpl::processEvent25(TimelineEvent* event) {


Commit: 4a29167fd0cc04dcba639770c78bf6b5cc6317dc
    https://github.com/scummvm/scummvm/commit/4a29167fd0cc04dcba639770c78bf6b5cc6317dc
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-07T08:04:10+02:00

Commit Message:
DM: Refactor processEvent25

Changed paths:
    engines/dm/projexpl.cpp



diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index a24fb43..06f78ad 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -389,7 +389,7 @@ void ProjExpl::projectileDelete(Thing projectileThing, Thing *groupSlot, int16 m
 	projectile->_nextThing = Thing::_none;
 }
 
-void ProjExpl::processEvents48To49(TimelineEvent* event) {
+void ProjExpl::processEvents48To49(TimelineEvent *event) {
 	int16 sourceMapX = -1;
 	int16 sourceMapY = -1;
 	TimelineEvent firstEvent = *event;
@@ -469,95 +469,88 @@ void ProjExpl::processEvents48To49(TimelineEvent* event) {
 	projectile->_eventIndex = _vm->_timeline->addEventGetEventIndex(curEvent);
 }
 
-void ProjExpl::processEvent25(TimelineEvent* event) {
-	Explosion* L0532_ps_Explosion;
-	Group* L0533_ps_Group = nullptr;
-	CreatureInfo* L0534_ps_CreatureInfo = nullptr;
-	uint16 L0528_ui_MapX;
-	uint16 L0529_ui_MapY;
-	int16 L0530_i_Attack;
-	int16 L0531_i_Multiple;
-#define AL0531_i_SquareType    L0531_i_Multiple
-#define AL0531_i_CreatureCount L0531_i_Multiple
-	Thing L0535_T_GroupThing;
-	Thing L0536_T_ExplosionThing;
-	uint16 L0537_ui_Multiple = 0;
-#define AL0537_ui_CreatureType                L0537_ui_Multiple
-#define AL0537_ui_NonMaterialAdditionalAttack L0537_ui_Multiple
-	bool L0538_B_ExplosionOnPartySquare;
-	TimelineEvent L0539_s_Event;
-
-	L0528_ui_MapX = event->_B._location._mapX;
-	L0529_ui_MapY = event->_B._location._mapY;
-	L0532_ps_Explosion = &((Explosion*)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[Thing((event->_C._slot)).getIndex()];
-	AL0531_i_SquareType = Square(_vm->_dungeonMan->_currMapData[L0528_ui_MapX][L0529_ui_MapY]).getType();
-	L0538_B_ExplosionOnPartySquare = (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0528_ui_MapX == _vm->_dungeonMan->_partyMapX) && (L0529_ui_MapY == _vm->_dungeonMan->_partyMapY);
-	if ((L0535_T_GroupThing = _vm->_groupMan->groupGetThing(L0528_ui_MapX, L0529_ui_MapY)) != Thing::_endOfList) {
-		L0533_ps_Group = (Group*)_vm->_dungeonMan->getThingData(L0535_T_GroupThing);
-		L0534_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[AL0537_ui_CreatureType = L0533_ps_Group->_type];
-	}
-	if ((L0536_T_ExplosionThing = Thing(Thing::_firstExplosion.toUint16() + L0532_ps_Explosion->getType())) == Thing::_explPoisonCloud) {
-		L0530_i_Attack = MAX(1, MIN(L0532_ps_Explosion->getAttack() >> 5, 4) + _vm->getRandomNumber(2)); /* Value between 1 and 5 */
-	} else {
-		L0530_i_Attack = (L0532_ps_Explosion->getAttack() >> 1) + 1;
-		L0530_i_Attack += _vm->getRandomNumber(L0530_i_Attack) + 1;
+void ProjExpl::processEvent25(TimelineEvent *event) {
+	uint16 mapX = event->_B._location._mapX;
+	uint16 mapY = event->_B._location._mapY;
+	Explosion *explosion = &((Explosion*)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[Thing((event->_C._slot)).getIndex()];
+	int16 curSquareType = Square(_vm->_dungeonMan->_currMapData[mapX][mapY]).getType();
+	bool explosionOnPartySquare = (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY);
+	Thing groupThing = _vm->_groupMan->groupGetThing(mapX, mapY);
+
+	Group *group = nullptr;
+	CreatureInfo *creatureInfo = nullptr;
+
+	uint16 creatureType = 0;
+	if (groupThing != Thing::_endOfList) {
+		group = (Group*)_vm->_dungeonMan->getThingData(groupThing);
+		creatureType = group->_type;
+		creatureInfo = &_vm->_dungeonMan->_creatureInfos[creatureType];
 	}
 
+	Thing explosionThing = Thing(Thing::_firstExplosion.toUint16() + explosion->getType());
+	int16 attack;
+	if (explosionThing == Thing::_explPoisonCloud)
+		attack = MAX(1, MIN(explosion->getAttack() >> 5, 4) + _vm->getRandomNumber(2)); /* Value between 1 and 5 */
+	else {
+		attack = (explosion->getAttack() >> 1) + 1;
+		attack += _vm->getRandomNumber(attack) + 1;
+	}
 
-	switch (L0536_T_ExplosionThing.toUint16()) {
+	switch (explosionThing.toUint16()) {
 	case 0xFF82:
-		if (!(L0530_i_Attack >>= 1))
+		if (!(attack >>= 1))
 			break;
 	case 0xFF80:
-		if (AL0531_i_SquareType == k4_DoorElemType) {
-			_vm->_groupMan->groupIsDoorDestoryedByAttack(L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true, 0);
-		}
+		if (curSquareType == k4_DoorElemType)
+			_vm->_groupMan->groupIsDoorDestoryedByAttack(mapX, mapY, attack, true, 0);
+
 		break;
 	case 0xFF83:
-		if ((L0535_T_GroupThing != Thing::_endOfList) && getFlag(L0534_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
-			if ((AL0537_ui_CreatureType == k19_CreatureTypeMaterializerZytaz) && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex)) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */
-				L0530_i_Attack -= (AL0537_ui_NonMaterialAdditionalAttack = L0530_i_Attack >> 3);
-				AL0537_ui_NonMaterialAdditionalAttack <<= 1;
-				AL0537_ui_NonMaterialAdditionalAttack++;
-				AL0531_i_CreatureCount = L0533_ps_Group->getCount();
+		if ((groupThing != Thing::_endOfList) && getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
+			if ((creatureType == k19_CreatureTypeMaterializerZytaz) && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex)) {
+				int16 nonMaterialAdditionalAttack = attack >> 3;
+				attack -= nonMaterialAdditionalAttack;
+				nonMaterialAdditionalAttack <<= 1;
+				nonMaterialAdditionalAttack++;
+				int16 creatureCount = group->getCount();
 				do {
-					if (getFlag(_vm->_groupMan->_activeGroups[L0533_ps_Group->getActiveGroupIndex()]._aspect[AL0531_i_CreatureCount], k0x0080_MaskActiveGroupIsAttacking)) { /* Materializer / Zytaz can only be damaged while they are attacking */
-						_vm->_groupMan->groupGetDamageCreatureOutcome(L0533_ps_Group, AL0531_i_CreatureCount, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack + _vm->getRandomNumber(AL0537_ui_NonMaterialAdditionalAttack) + _vm->getRandomNumber(4), true);
-					}
-				} while (--AL0531_i_CreatureCount >= 0);
-			} else {
-				_vm->_groupMan->getDamageAllCreaturesOutcome(L0533_ps_Group, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true);
-			}
+					if (getFlag(_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()]._aspect[creatureCount], k0x0080_MaskActiveGroupIsAttacking)) /* Materializer / Zytaz can only be damaged while they are attacking */
+						_vm->_groupMan->groupGetDamageCreatureOutcome(group, creatureCount, mapX, mapY, attack + _vm->getRandomNumber(nonMaterialAdditionalAttack) + _vm->getRandomNumber(4), true);
+				} while (--creatureCount >= 0);
+			} else
+				_vm->_groupMan->getDamageAllCreaturesOutcome(group, mapX, mapY, attack, true);
 		}
 		break;
 	case 0xFFE4:
-		L0532_ps_Explosion->setType(L0532_ps_Explosion->getType() + 1);
-		_vm->_sound->requestPlay(k05_soundSTRONG_EXPLOSION, L0528_ui_MapX, L0529_ui_MapY, k1_soundModePlayIfPrioritized);
+		explosion->setType(explosion->getType() + 1);
+		_vm->_sound->requestPlay(k05_soundSTRONG_EXPLOSION, mapX, mapY, k1_soundModePlayIfPrioritized);
 		goto T0220026;
 	case 0xFFA8:
-		if (L0532_ps_Explosion->getAttack() > 55) {
-			L0532_ps_Explosion->setAttack(L0532_ps_Explosion->getAttack() - 40);
+		if (explosion->getAttack() > 55) {
+			explosion->setAttack(explosion->getAttack() - 40);
 			goto T0220026;
 		}
 		break;
 	case 0xFF87:
-		if (L0538_B_ExplosionOnPartySquare) {
-			_vm->_championMan->getDamagedChampionCount(L0530_i_Attack, k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
-		} else {
-			if ((L0535_T_GroupThing != Thing::_endOfList) && (L0530_i_Attack = _vm->_groupMan->groupGetResistanceAdjustedPoisonAttack(AL0537_ui_CreatureType, L0530_i_Attack)) && (_vm->_groupMan->getDamageAllCreaturesOutcome(L0533_ps_Group, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true) != k2_outcomeKilledAllCreaturesInGroup) && (L0530_i_Attack > 2)) {
-				_vm->_groupMan->processEvents29to41(L0528_ui_MapX, L0529_ui_MapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
-			}
+		if (explosionOnPartySquare)
+			_vm->_championMan->getDamagedChampionCount(attack, k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
+		else if ((groupThing != Thing::_endOfList)
+			&& (attack = _vm->_groupMan->groupGetResistanceAdjustedPoisonAttack(creatureType, attack))
+			&& (_vm->_groupMan->getDamageAllCreaturesOutcome(group, mapX, mapY, attack, true) != k2_outcomeKilledAllCreaturesInGroup)
+			&& (attack > 2)) {
+			_vm->_groupMan->processEvents29to41(mapX, mapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
 		}
-		if (L0532_ps_Explosion->getAttack() >= 6) {
-			L0532_ps_Explosion->setAttack(L0532_ps_Explosion->getAttack() - 3);
+		if (explosion->getAttack() >= 6) {
+			explosion->setAttack(explosion->getAttack() - 3);
 T0220026:
-			L0539_s_Event = *event;
-			L0539_s_Event._mapTime++;
-			_vm->_timeline->addEventGetEventIndex(&L0539_s_Event);
+			TimelineEvent newEvent;
+			newEvent = *event;
+			newEvent._mapTime++;
+			_vm->_timeline->addEventGetEventIndex(&newEvent);
 			return;
 		}
 	}
-	_vm->_dungeonMan->unlinkThingFromList(Thing(event->_C._slot), Thing(0), L0528_ui_MapX, L0529_ui_MapY);
-	L0532_ps_Explosion->setNextThing(Thing::_none);
+	_vm->_dungeonMan->unlinkThingFromList(Thing(event->_C._slot), Thing(0), mapX, mapY);
+	explosion->setNextThing(Thing::_none);
 }
 }


Commit: 6e1a3d6217950776aa8d2b35f6f2de763750c4d8
    https://github.com/scummvm/scummvm/commit/6e1a3d6217950776aa8d2b35f6f2de763750c4d8
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-07T08:07:29+02:00

Commit Message:
DM: Remove the use of GOTO in processEvent25

Changed paths:
    engines/dm/projexpl.cpp



diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 06f78ad..e1a62d1 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -496,6 +496,8 @@ void ProjExpl::processEvent25(TimelineEvent *event) {
 		attack += _vm->getRandomNumber(attack) + 1;
 	}
 
+	bool AddEventFl = false;
+
 	switch (explosionThing.toUint16()) {
 	case 0xFF82:
 		if (!(attack >>= 1))
@@ -524,11 +526,12 @@ void ProjExpl::processEvent25(TimelineEvent *event) {
 	case 0xFFE4:
 		explosion->setType(explosion->getType() + 1);
 		_vm->_sound->requestPlay(k05_soundSTRONG_EXPLOSION, mapX, mapY, k1_soundModePlayIfPrioritized);
-		goto T0220026;
+		AddEventFl = true;
+		break;
 	case 0xFFA8:
 		if (explosion->getAttack() > 55) {
 			explosion->setAttack(explosion->getAttack() - 40);
-			goto T0220026;
+			AddEventFl = true;
 		}
 		break;
 	case 0xFF87:
@@ -542,15 +545,18 @@ void ProjExpl::processEvent25(TimelineEvent *event) {
 		}
 		if (explosion->getAttack() >= 6) {
 			explosion->setAttack(explosion->getAttack() - 3);
-T0220026:
-			TimelineEvent newEvent;
-			newEvent = *event;
-			newEvent._mapTime++;
-			_vm->_timeline->addEventGetEventIndex(&newEvent);
-			return;
+			AddEventFl = true;
 		}
+		break;
+	}
+	if (AddEventFl) {
+		TimelineEvent newEvent;
+		newEvent = *event;
+		newEvent._mapTime++;
+		_vm->_timeline->addEventGetEventIndex(&newEvent);
+	} else {
+		_vm->_dungeonMan->unlinkThingFromList(Thing(event->_C._slot), Thing(0), mapX, mapY);
+		explosion->setNextThing(Thing::_none);
 	}
-	_vm->_dungeonMan->unlinkThingFromList(Thing(event->_C._slot), Thing(0), mapX, mapY);
-	explosion->setNextThing(Thing::_none);
 }
 }


Commit: b62f4babbe53d655a20c904d89ca11f1cfb34ce4
    https://github.com/scummvm/scummvm/commit/b62f4babbe53d655a20c904d89ca11f1cfb34ce4
Author: Bendegúz Nagy (bendeguz.nagy.rf at gmail.com)
Date: 2016-09-07T17:45:20+02:00

Commit Message:
DM: Fix regression introduced in e4fe372

Changed paths:
    engines/dm/objectman.cpp
    engines/dm/objectman.h



diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index b81415d..bc8105c 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -92,8 +92,8 @@ void ObjectMan::initConstants() {
 	_slotBoxes[45] = SlotBox(196, 105, 0); /* Chest 8 */
 
 	for (int i = 0; i < 7; i++) {
-		iconGraphicHeight[i] = iconGraphicHeight[i];
-		iconGraphicFirstIndex[i] = iconGraphicFirstIndex[i];
+		_iconGraphicHeight[i] = iconGraphicHeight[i];
+		_iconGraphicFirstIndex[i] = iconGraphicFirstIndex[i];
 	}
 }
 
@@ -187,15 +187,15 @@ IconIndice ObjectMan::getIconIndex(Thing thing) {
 void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 	uint16 counter;
 	for (counter = 0; counter < 7; counter++) {
-		if (iconGraphicFirstIndex[counter] > iconIndex)
+		if (_iconGraphicFirstIndex[counter] > iconIndex)
 			break;
 	}
 	--counter;
 	byte *iconBitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k42_ObjectIcons_000_TO_031 + counter);
-	iconIndex -= iconGraphicFirstIndex[counter];
+	iconIndex -= _iconGraphicFirstIndex[counter];
 	_vm->_displayMan->_useByteBoxCoordinates = true;
 	Box blitBox(0, 15, 0, 15);
-	_vm->_displayMan->blitToBitmap(iconBitmap, destBitmap, blitBox, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, kM1_ColorNoTransparency, iconGraphicHeight[counter], 16);
+	_vm->_displayMan->blitToBitmap(iconBitmap, destBitmap, blitBox, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, kM1_ColorNoTransparency, _iconGraphicHeight[counter], 16);
 }
 
 void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
@@ -212,12 +212,12 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 
 	uint16 iconGraphicIndex;
 	for (iconGraphicIndex = 0; iconGraphicIndex < 7; iconGraphicIndex++) {
-		if (iconGraphicFirstIndex[iconGraphicIndex] > iconIndex)
+		if (_iconGraphicFirstIndex[iconGraphicIndex] > iconIndex)
 			break;
 	}
 	iconGraphicIndex--;
 	byte *iconBitmap = _vm->_displayMan->getNativeBitmapOrGraphic(iconGraphicIndex + k42_ObjectIcons_000_TO_031);
-	iconIndex -= iconGraphicFirstIndex[iconGraphicIndex];
+	iconIndex -= _iconGraphicFirstIndex[iconGraphicIndex];
 	int16 byteWidth;
 	byte* blitDestination;
 	int16 destHeight;
@@ -231,7 +231,7 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 		destHeight = 200;
 	}
 	_vm->_displayMan->_useByteBoxCoordinates = false;
-	_vm->_displayMan->blitToBitmap(iconBitmap, blitDestination, blitBox, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, k128_byteWidth, byteWidth, kM1_ColorNoTransparency, iconGraphicHeight[iconGraphicIndex], destHeight);
+	_vm->_displayMan->blitToBitmap(iconBitmap, blitDestination, blitBox, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, k128_byteWidth, byteWidth, kM1_ColorNoTransparency, _iconGraphicHeight[iconGraphicIndex], destHeight);
 }
 
 void ObjectMan::drawLeaderObjectName(Thing thing) {
diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h
index cfdc752..bb7d06c 100644
--- a/engines/dm/objectman.h
+++ b/engines/dm/objectman.h
@@ -71,8 +71,8 @@ public:
 	void clearLeaderObjectName(); // @ F0035_OBJECT_ClearLeaderHandObjectName
 	void drawIconToScreen(int16 iconIndex, int16 posX, int16 posY); // @ F0037_OBJECT_DrawIconToScreen
 
-	int16 iconGraphicHeight[7]; // @ K0077_ai_IconGraphicHeight
-	int16 iconGraphicFirstIndex[7]; // G0026_ai_Graphic562_IconGraphicFirstIconIndex
+	int16 _iconGraphicHeight[7]; // @ K0077_ai_IconGraphicHeight
+	int16 _iconGraphicFirstIndex[7]; // G0026_ai_Graphic562_IconGraphicFirstIconIndex
 
 	void initConstants();
 };


Commit: 4414995c29a8de9228346f948f8d6bea5a099ecb
    https://github.com/scummvm/scummvm/commit/4414995c29a8de9228346f948f8d6bea5a099ecb
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-07T19:49:10+02:00

Commit Message:
DM: Fix the style of some pointers in projexpl

Changed paths:
    engines/dm/projexpl.cpp
    engines/dm/projexpl.h



diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index e1a62d1..7c4bc53 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -35,7 +35,7 @@
 
 namespace DM {
 
-ProjExpl::ProjExpl(DMEngine* vm) : _vm(vm) {
+ProjExpl::ProjExpl(DMEngine *vm) : _vm(vm) {
 	_creatureDamageOutcome = 0;
 	_secondaryDirToOrFromParty = 0;
 	_lastCreatureAttackTime = -200;
@@ -396,7 +396,7 @@ void ProjExpl::processEvents48To49(TimelineEvent *event) {
 	TimelineEvent *curEvent = &firstEvent;
 	Thing projectileThingNewCell = Thing(curEvent->_B._slot);
 	Thing projectileThing  = projectileThingNewCell;
-	Projectile *projectile = (Projectile*)_vm->_dungeonMan->getThingData(projectileThing);
+	Projectile *projectile = (Projectile *)_vm->_dungeonMan->getThingData(projectileThing);
 	int16 destinationMapX = curEvent->_C._projectile.getMapX();
 	int16 destinationMapY = curEvent->_C._projectile.getMapY();
 
@@ -472,7 +472,7 @@ void ProjExpl::processEvents48To49(TimelineEvent *event) {
 void ProjExpl::processEvent25(TimelineEvent *event) {
 	uint16 mapX = event->_B._location._mapX;
 	uint16 mapY = event->_B._location._mapY;
-	Explosion *explosion = &((Explosion*)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[Thing((event->_C._slot)).getIndex()];
+	Explosion *explosion = &((Explosion *)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[Thing((event->_C._slot)).getIndex()];
 	int16 curSquareType = Square(_vm->_dungeonMan->_currMapData[mapX][mapY]).getType();
 	bool explosionOnPartySquare = (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY);
 	Thing groupThing = _vm->_groupMan->groupGetThing(mapX, mapY);
@@ -482,7 +482,7 @@ void ProjExpl::processEvent25(TimelineEvent *event) {
 
 	uint16 creatureType = 0;
 	if (groupThing != Thing::_endOfList) {
-		group = (Group*)_vm->_dungeonMan->getThingData(groupThing);
+		group = (Group *)_vm->_dungeonMan->getThingData(groupThing);
 		creatureType = group->_type;
 		creatureInfo = &_vm->_dungeonMan->_creatureInfos[creatureType];
 	}
diff --git a/engines/dm/projexpl.h b/engines/dm/projexpl.h
index e8db0bf..7559fef 100644
--- a/engines/dm/projexpl.h
+++ b/engines/dm/projexpl.h
@@ -29,7 +29,6 @@
 
 #include "dm/dm.h"
 
-
 namespace DM {
 
 #define k0_outcomeKilledNoCreaturesInGroup 0 // @ C0_OUTCOME_KILLED_NO_CREATURES_IN_GROUP   
@@ -71,7 +70,6 @@ namespace DM {
 #define k32_soundMOVE_RED_DRAGON 32 // @ C32_SOUND_MOVE_RED_DRAGON
 #define k33_soundMOVE_SKELETON 33 // @ C33_SOUND_MOVE_SKELETON
 
-
 #define M31_setMap(map_time, map) ((map_time) = (((map_time) & 0x00FFFFFF) | (((int32)(map)) << 24)))
 
 class TimelineEvent;


Commit: 878ae1a88253677d1bdd30efe74134c571e9623b
    https://github.com/scummvm/scummvm/commit/878ae1a88253677d1bdd30efe74134c571e9623b
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-07T21:09:35+02:00

Commit Message:
DM: More renaming and refactoring

Changed paths:
    engines/dm/sounds.cpp
    engines/dm/sounds.h
    engines/dm/text.cpp
    engines/dm/text.h



diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp
index 9affc78..bcc333c 100644
--- a/engines/dm/sounds.cpp
+++ b/engines/dm/sounds.cpp
@@ -36,10 +36,9 @@
 #include "dm/dungeonman.h"
 #include "dm/sounds.h"
 
-
 namespace DM {
 
-SoundMan* SoundMan::getSoundMan(DMEngine* vm, const DMADGameDescription* gameVersion) {
+SoundMan *SoundMan::getSoundMan(DMEngine *vm, const DMADGameDescription *gameVersion) {
 	switch (gameVersion->_desc.platform) {
 	default:
 		warning("Unknown platform, using default Amiga SoundMan");
@@ -92,7 +91,7 @@ void SoundMan::initConstants() {
 		_sounds[i] = sounds[i];
 }
 
-SoundMan::SoundMan(DMEngine* vm) : _vm(vm) {
+SoundMan::SoundMan(DMEngine *vm) : _vm(vm) {
 	initConstants();
 }
 
@@ -132,8 +131,8 @@ void SoundMan::playPendingSound() {
 	}
 }
 
-bool SoundMan::soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, uint8* rightVolume) {
-	static byte K0030_aauc_DistanceToSoundVolume[25][25] = {
+bool SoundMan::soundGetVolume(int16 mapX, int16 mapY, uint8 *leftVolume, uint8 *rightVolume) {
+	static byte distanceToSoundVolume[25][25] = {
 		{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4,  5,  5,  5,  5,  5,  5,  5, 5, 4, 4, 4, 4, 4},
 		{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 5,  6,  6,  6,  6,  5,  5,  5, 5, 5, 5, 4, 4, 4},
 		{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 5,  6,  6,  6,  6,  6,  6,  5, 5, 5, 5, 5, 4, 4},
@@ -160,66 +159,63 @@ bool SoundMan::soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, uint8*
 		{1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3,  4,  4,  4,  4,  4,  4,  4, 4, 3, 3, 3, 3, 3},
 		{1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3,  4,  4,  4,  4,  4,  4,  4, 3, 3, 3, 3, 3, 3}};
 
-	int16 L1678_i_RightVolumeColumnIndex = 0;
-	int16 L1679_i_LineIndex = 0;
-	int16 L1680_i_LeftVolumeColumnIndex = 0;
-
+	int16 lineIndex = 0;
+	int16 rightVolumeColumnIndex = 0;
 
 	switch (_vm->_dungeonMan->_partyDir) {
 	case kDirNorth:
-		L1678_i_RightVolumeColumnIndex = mapX - _vm->_dungeonMan->_partyMapX;
-		L1679_i_LineIndex = mapY - _vm->_dungeonMan->_partyMapY;
+		rightVolumeColumnIndex = mapX - _vm->_dungeonMan->_partyMapX;
+		lineIndex = mapY - _vm->_dungeonMan->_partyMapY;
 		break;
 	case kDirEast:
-		L1678_i_RightVolumeColumnIndex = mapY - _vm->_dungeonMan->_partyMapY;
-		L1679_i_LineIndex = -(mapX - _vm->_dungeonMan->_partyMapX);
+		rightVolumeColumnIndex = mapY - _vm->_dungeonMan->_partyMapY;
+		lineIndex = -(mapX - _vm->_dungeonMan->_partyMapX);
 		break;
 	case kDirSouth:
-		L1678_i_RightVolumeColumnIndex = -(mapX - _vm->_dungeonMan->_partyMapX);
-		L1679_i_LineIndex = -(mapY - _vm->_dungeonMan->_partyMapY);
+		rightVolumeColumnIndex = -(mapX - _vm->_dungeonMan->_partyMapX);
+		lineIndex = -(mapY - _vm->_dungeonMan->_partyMapY);
 		break;
 	case kDirWest:
-		L1678_i_RightVolumeColumnIndex = -(mapY - _vm->_dungeonMan->_partyMapY);
-		L1679_i_LineIndex = mapX - _vm->_dungeonMan->_partyMapX;
+		rightVolumeColumnIndex = -(mapY - _vm->_dungeonMan->_partyMapY);
+		lineIndex = mapX - _vm->_dungeonMan->_partyMapX;
 		break;
 	}
-	if ((L1678_i_RightVolumeColumnIndex < -12) || (L1678_i_RightVolumeColumnIndex > 12)) { /* Sound is not audible if source is more than 12 squares away from the party */
+
+	if ((rightVolumeColumnIndex < -12) || (rightVolumeColumnIndex > 12)) /* Sound is not audible if source is more than 12 squares away from the party */
 		return false;
-	}
-	if ((L1679_i_LineIndex < -12) || (L1679_i_LineIndex > 12)) { /* Sound is not audible if source is more than 12 squares away from the party */
+
+	if ((lineIndex < -12) || (lineIndex > 12)) /* Sound is not audible if source is more than 12 squares away from the party */
 		return false;
-	}
-	L1680_i_LeftVolumeColumnIndex = -L1678_i_RightVolumeColumnIndex + 12;
-	L1678_i_RightVolumeColumnIndex += 12;
-	L1679_i_LineIndex += 12;
-	*rightVolume = K0030_aauc_DistanceToSoundVolume[L1679_i_LineIndex][L1678_i_RightVolumeColumnIndex];
-	*leftVolume = K0030_aauc_DistanceToSoundVolume[L1679_i_LineIndex][L1680_i_LeftVolumeColumnIndex];
+
+	int16 leftVolumeColumnIndex = -rightVolumeColumnIndex + 12;
+	rightVolumeColumnIndex += 12;
+	lineIndex += 12;
+	*rightVolume = distanceToSoundVolume[lineIndex][rightVolumeColumnIndex];
+	*leftVolume = distanceToSoundVolume[lineIndex][leftVolumeColumnIndex];
 	return true;
 }
 
 void SoundMan::requestPlay(uint16 soundIndex, int16 mapX, int16 mapY, uint16 mode) {
-	Sound* sound;
-	uint8 leftVolume, rightVolume;
-
 	if (mode && (_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex))
 		return;
 
-	sound = &_sounds[soundIndex];
+	Sound *sound = &_sounds[soundIndex];
 	if (mode > k1_soundModePlayIfPrioritized) { /* Add an event in the timeline to play the sound (mode - 1) ticks later */
-		TimelineEvent event;
-		setMapAndTime(event._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + mode - 1);
-		event._type = k20_TMEventTypePlaySound;
-		event._priority = sound->_priority;
-		event._C._soundIndex = soundIndex;
-		event._B._location._mapX = mapX;
-		event._B._location._mapY = mapY;
-		_vm->_timeline->addEventGetEventIndex(&event);
+		TimelineEvent newEvent;
+		setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + mode - 1);
+		newEvent._type = k20_TMEventTypePlaySound;
+		newEvent._priority = sound->_priority;
+		newEvent._C._soundIndex = soundIndex;
+		newEvent._B._location._mapX = mapX;
+		newEvent._B._location._mapY = mapY;
+		_vm->_timeline->addEventGetEventIndex(&newEvent);
 		return;
 	}
 
-	if (!soundGetVolume(mapX, mapY, &leftVolume, &rightVolume)) {
+	uint8 leftVolume, rightVolume;
+	if (!soundGetVolume(mapX, mapY, &leftVolume, &rightVolume))
 		return;
-	}
+
 	if (!mode) { /* Play the sound immediately */
 		play(soundIndex, sound->_period, leftVolume, rightVolume);
 		return;
@@ -227,5 +223,4 @@ void SoundMan::requestPlay(uint16 soundIndex, int16 mapX, int16 mapY, uint16 mod
 	_pendingSounds.push(PendingSound(leftVolume, rightVolume, soundIndex));
 }
 
-
 }
diff --git a/engines/dm/sounds.h b/engines/dm/sounds.h
index f50d481..fc9561a 100644
--- a/engines/dm/sounds.h
+++ b/engines/dm/sounds.h
@@ -37,7 +37,7 @@ namespace DM {
 class SoundData {
 public:
 	uint32 _byteCount;
-	byte* _firstSample;
+	byte *_firstSample;
 	uint32 _sampleCount;
 	SoundData() : _byteCount(0), _firstSample(nullptr), _sampleCount(0) {}
 }; // @ SOUND_DATA
@@ -67,7 +67,7 @@ class SoundMan {
 	DMEngine *_vm;
 
 protected:
-	SoundMan(DMEngine* vm);
+	SoundMan(DMEngine *vm);
 public:
 	virtual ~SoundMan();
 
@@ -89,7 +89,7 @@ public:
 class SoundMan_Atari: public SoundMan {
 	friend class SoundMan;
 
-	SoundMan_Atari(DMEngine* vm): SoundMan(vm) {};
+	SoundMan_Atari(DMEngine *vm): SoundMan(vm) {};
 public:
 	void loadSounds() override {} // @ F0503_SOUND_LoadAll
 	void requestPlay(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode) override {} // @ F0064_SOUND_RequestPlay_CPSD
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 52e83d1..00049bb 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -31,11 +31,12 @@
 
 namespace DM {
 
-TextMan::TextMan(DMEngine* vm) : _vm(vm) {
+TextMan::TextMan(DMEngine *vm) : _vm(vm) {
 	_messageAreaCursorColumn = 0;
 	_messageAreaCursorRow = 0;
 	for (uint16 i = 0; i < 4; ++i)
 		_messageAreaRowExpirationTime[i] = 0;
+
 	_bitmapMessageAreaNewRow = new byte[320 * 7];
 	_isScrolling = false;
 	_startedScrollingAt = -1;
@@ -47,11 +48,8 @@ TextMan::~TextMan() {
 	delete[] _messageAreaCopy;
 }
 
-#define k5_LetterWidth 5
-#define k6_LetterHeight 6
-
-void TextMan::printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int16 destX, int16 destY,
-								Color textColor, Color bgColor, const char* text, uint16 destHeight) {
+void TextMan::printTextToBitmap(byte *destBitmap, uint16 destByteWidth, int16 destX, int16 destY,
+								Color textColor, Color bgColor, const char *text, uint16 destHeight) {
 	if ((destX -= 1) < 0) // fixes missalignment, to be checked
 		destX = 0;
 	if ((destY -= 4) < 0) // fixes missalignment, to be checked
@@ -65,9 +63,9 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int16 de
 	byte *srcBitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k557_FontGraphicIndice);
 
 	byte *tmp = _vm->_displayMan->_tmpBitmap;
-	for (uint16 i = 0; i < (k5_LetterWidth + 1) * k6_LetterHeight * 128; ++i) {
+	for (uint16 i = 0; i < (k5_LetterWidth + 1) * k6_LetterHeight * 128; ++i)
 		tmp[i] = srcBitmap[i] ? textColor : bgColor;
-	}
+
 	srcBitmap = tmp;
 
 	for (const char *begin = text, *end = text + textLength; begin != end; ++begin) {
@@ -77,6 +75,7 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int16 de
 		}
 		if (nextY + k6_LetterHeight >= destHeight)
 			break;
+
 		uint16 srcX = (1 + 5) * *begin; // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
 
 		Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1);
@@ -87,16 +86,16 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int16 de
 	}
 }
 
-void TextMan::printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text) {
+void TextMan::printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text) {
 	printTextToBitmap(_vm->_displayMan->_bitmapScreen, _vm->_displayMan->_screenWidth / 2, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight);
 }
 
-void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) {
+void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor) {
 	printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, posX, posY, textColor, bgColor, text, k136_heightViewport);
 }
 
-void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor,
-									  Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight) {
+void TextMan::printWithTrailingSpaces(byte *destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor,
+									  Color bgColor, const char *text, int16 requiredTextLength, int16 destHeight) {
 	Common::String str = text;
 	for (int16 i = str.size(); i < requiredTextLength; ++i)
 		str += ' ';
@@ -107,10 +106,9 @@ void TextMan::printLineFeed() {
 	printMessage(k0_ColorBlack, "\n");
 }
 
-void TextMan::printMessage(Color color, const char* string, bool printWithScroll) {
-	uint16 L0031_ui_CharacterIndex;
-	char L0033_ac_String[54];
-
+void TextMan::printMessage(Color color, const char *string, bool printWithScroll) {
+	uint16 characterIndex;
+	Common::String wrkString;
 
 	while (*string) {
 		if (*string == '\n') { /* New line */
@@ -119,59 +117,53 @@ void TextMan::printMessage(Color color, const char* string, bool printWithScroll
 				_messageAreaCursorColumn = 0;
 				createNewRow();
 			}
+		} else if (*string == ' ') {
+			string++;
+			if (_messageAreaCursorColumn != 53) {
+				printString(color, " "); // I'm not sure if this is like the original
+			}
 		} else {
-			if (*string == ' ') {
-				string++;
-				if (_messageAreaCursorColumn != 53) {
-					printString(color, " "); // I'm not sure if this is like the original
-				}
-			} else {
-				L0031_ui_CharacterIndex = 0;
-				do {
-					L0033_ac_String[L0031_ui_CharacterIndex++] = *string++;
-				} while (*string && (*string != ' ') && (*string != '\n')); /* End of string, space or New line */
-				L0033_ac_String[L0031_ui_CharacterIndex] = '\0';
-				if (_messageAreaCursorColumn + L0031_ui_CharacterIndex > 53) {
-					_messageAreaCursorColumn = 2;
-					createNewRow();
-				}
-				printString(color, L0033_ac_String);
+			characterIndex = 0;
+			do {
+				wrkString += *string++;
+				characterIndex++;
+			} while (*string && (*string != ' ') && (*string != '\n')); /* End of string, space or New line */
+			wrkString += '\0';
+			if (_messageAreaCursorColumn + characterIndex > 53) {
+				_messageAreaCursorColumn = 2;
+				createNewRow();
 			}
+			printString(color, wrkString.c_str());
 		}
 	}
 }
 
 void TextMan::createNewRow() {
-	uint16 L0029_ui_RowIndex;
-
 	if (_messageAreaCursorRow == 3) {
 		isTextScrolling(&_textScroller, true);
 		memset(_bitmapMessageAreaNewRow, k0_ColorBlack, 320 * 7);
 		_isScrolling = true;
 		setScrollerCommand(&_textScroller, 1);
 
-		for (L0029_ui_RowIndex = 0; L0029_ui_RowIndex < 3; L0029_ui_RowIndex++) {
-			_messageAreaRowExpirationTime[L0029_ui_RowIndex] = _messageAreaRowExpirationTime[L0029_ui_RowIndex + 1];
-		}
+		for (uint16 rowIndex = 0; rowIndex < 3; rowIndex++)
+			_messageAreaRowExpirationTime[rowIndex] = _messageAreaRowExpirationTime[rowIndex + 1];
+
 		_messageAreaRowExpirationTime[3] = -1;
-	} else {
+	} else
 		_messageAreaCursorRow++;
-	}
 }
 
 void TextMan::printString(Color color, const char* string) {
-	int16 L0030_i_StringLength;
-
-	L0030_i_StringLength = strlen(string);
-	if (isTextScrolling(&_textScroller, false)) {
+	int16 stringLength = strlen(string);
+	if (isTextScrolling(&_textScroller, false))
 		printToLogicalScreen(_messageAreaCursorColumn * 6, (_messageAreaCursorRow * 7 - 1) + 177, color, k0_ColorBlack, string);
-	} else {
+	else {
 		printTextToBitmap(_bitmapMessageAreaNewRow, k160_byteWidthScreen, _messageAreaCursorColumn * 6, 0, color, k0_ColorBlack, string, 7);
 		_isScrolling = true;
 		if (isTextScrolling(&_textScroller, false))
 			setScrollerCommand(&_textScroller, 1);
 	}
-	_messageAreaCursorColumn += L0030_i_StringLength;
+	_messageAreaCursorColumn += stringLength;
 	_messageAreaRowExpirationTime[_messageAreaCursorRow] = _vm->_gameTime + 200;
 
 }
@@ -183,21 +175,17 @@ void TextMan::initialize() {
 }
 
 void TextMan::moveCursor(int16 column, int16 row) {
-	if (column < 0) {
+	if (column < 0)
 		column = 0;
-	} else {
-		if (column >= 53) {
-			column = 52;
-		}
-	}
+	else if (column >= 53)
+		column = 52;
+
 	_messageAreaCursorColumn = column;
-	if (row < 0) {
+	if (row < 0)
 		row = 0;
-	} else {
-		if (row >= 4) {
-			row = 3;
-		}
-	}
+	else if (row >= 4)
+		row = 3;
+
 	_messageAreaCursorRow = row;
 }
 
diff --git a/engines/dm/text.h b/engines/dm/text.h
index 2124834..6a93424 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -37,6 +37,9 @@ struct TextScroller {
 	// Placeholder, empty for now
 }; // @ Text_Scroller
 
+#define k5_LetterWidth 5
+#define k6_LetterHeight 6
+
 class TextMan {
 	DMEngine *_vm;
 	int16 _messageAreaCursorColumn; // @ G0359_i_MessageAreaCursorColumn


Commit: 53a8bda124691c42ecf06d9d907902fe6e8e75cf
    https://github.com/scummvm/scummvm/commit/53a8bda124691c42ecf06d9d907902fe6e8e75cf
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-07T21:28:25+02:00

Commit Message:
DM: Finish the renaming and first refactoring pass in TextMan

Changed paths:
    engines/dm/text.cpp



diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 00049bb..b92b434 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -190,43 +190,37 @@ void TextMan::moveCursor(int16 column, int16 row) {
 }
 
 void TextMan::clearExpiredRows() {
-	uint16 L0026_ui_RowIndex;
-	int32 L0027_l_ExpirationTime;
-	Box L0028_s_Box;
-
 	_vm->_displayMan->_useByteBoxCoordinates = false;
-	L0028_s_Box._x1 = 0;
-	L0028_s_Box._x2 = 319;
-	for (L0026_ui_RowIndex = 0; L0026_ui_RowIndex < 4; L0026_ui_RowIndex++) {
-		L0027_l_ExpirationTime = _messageAreaRowExpirationTime[L0026_ui_RowIndex];
-		if ((L0027_l_ExpirationTime == -1) || (L0027_l_ExpirationTime > _vm->_gameTime) || _isScrolling)
+	Box displayBox;
+	displayBox._x1 = 0;
+	displayBox._x2 = 319;
+	for (uint16 rowIndex = 0; rowIndex < 4; rowIndex++) {
+		int32 expirationTime = _messageAreaRowExpirationTime[rowIndex];
+		if ((expirationTime == -1) || (expirationTime > _vm->_gameTime) || _isScrolling)
 			continue;
-		L0028_s_Box._y2 = (L0028_s_Box._y1 = 172 + (L0026_ui_RowIndex * 7)) + 6;
+		displayBox._y2 = (displayBox._y1 = 172 + (rowIndex * 7)) + 6;
 		isTextScrolling(&_textScroller, true);
-		_vm->_displayMan->fillBoxBitmap(_vm->_displayMan->_bitmapScreen, L0028_s_Box, k0_ColorBlack, k160_byteWidthScreen, k200_heightScreen);
-		_messageAreaRowExpirationTime[L0026_ui_RowIndex] = -1;
+		_vm->_displayMan->fillBoxBitmap(_vm->_displayMan->_bitmapScreen, displayBox, k0_ColorBlack, k160_byteWidthScreen, k200_heightScreen);
+		_messageAreaRowExpirationTime[rowIndex] = -1;
 	}
 }
 
 void TextMan::printEndGameString(int16 x, int16 y, Color textColor, char* text) {
-	char* L1407_pc_Character;
-	char L1408_ac_ModifiedString[50];
-
-	L1407_pc_Character = L1408_ac_ModifiedString;
-	*L1407_pc_Character = *text++;
-	while (*L1407_pc_Character) {
-		if ((*L1407_pc_Character >= 'A') && (*L1407_pc_Character <= 'Z')) {
-			*L1407_pc_Character -= 64; /* Use the same font as the one used for scrolls */
-		}
-		L1407_pc_Character++;
-		*L1407_pc_Character = *text++;
+	char modifiedString[50];
+
+	char *wrkStringPtr = modifiedString;
+	*wrkStringPtr = *text++;
+	while (*wrkStringPtr) {
+		if ((*wrkStringPtr >= 'A') && (*wrkStringPtr <= 'Z'))
+			*wrkStringPtr -= 64; /* Use the same font as the one used for scrolls */
+
+		wrkStringPtr++;
+		*wrkStringPtr = *text++;
 	}
-	printToLogicalScreen(x, y, textColor, k12_ColorDarkestGray, L1408_ac_ModifiedString);
+	printToLogicalScreen(x, y, textColor, k12_ColorDarkestGray, modifiedString);
 }
 
 void TextMan::clearAllRows() {
-	int16 L0023_i_RowIndex;
-
 	isTextScrolling(&_textScroller, true);
 
 	Box tmpBox(0, 319, 169, 199);
@@ -234,9 +228,8 @@ void TextMan::clearAllRows() {
 
 	_messageAreaCursorRow = 3;
 	_messageAreaCursorColumn = 0;
-	for (L0023_i_RowIndex = 0; L0023_i_RowIndex < 4; L0023_i_RowIndex++) {
-		_messageAreaRowExpirationTime[L0023_i_RowIndex] = -1;
-	}
+	for (int16 rowIndex = 0; rowIndex < 4; rowIndex++)
+		_messageAreaRowExpirationTime[rowIndex] = -1;
 }
 
 void TextMan::updateMessageArea() {
@@ -245,6 +238,7 @@ void TextMan::updateMessageArea() {
 			_startedScrollingAt = g_system->getMillis();
 			memcpy(_messageAreaCopy, _vm->_displayMan->_bitmapScreen + (200 - 7 * 4) * 320, 320 * 7 * 4);
 		}
+
 		int linesToCopy = (g_system->getMillis() - _startedScrollingAt) / 50;
 		if (linesToCopy >= 7) {
 			linesToCopy = 7;


Commit: 7bda512dde965e50269d7eba45562db4c8fdd562
    https://github.com/scummvm/scummvm/commit/7bda512dde965e50269d7eba45562db4c8fdd562
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-07T21:43:18+02:00

Commit Message:
DM: Start refactoring Timeline

Changed paths:
    engines/dm/menus.cpp
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index b2f159f..2b331c9 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -930,7 +930,7 @@ bool MenuMan::didClickTriggerAction(int16 actionListIndex) {
 		// Fix original bug - When disabled ticks is equal to zero, increasing the defense leads
 		// to a permanent increment.
 		if (_actionDisabledTicks[actionIndex])
-			curChampion->_actionDefense += _actionDefense[actionIndex];
+			curChampion->_actionDefense += _vm->_timeline->_actionDefense[actionIndex];
 
 		setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
 		retVal = isActionPerformed(championIndex, actionIndex);
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index b4c70bb..0f72207 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -40,51 +40,57 @@
 
 namespace DM {
 
-signed char _actionDefense[44] = { // @ G0495_ac_Graphic560_ActionDefense
-	0,   /* N */
-	36,  /* BLOCK */
-	0,   /* CHOP */
-	0,   /* X */
-	-4,  /* BLOW HORN */
-	-10, /* FLIP */
-	-10, /* PUNCH */
-	-5,  /* KICK */
-	4,   /* WAR CRY */
-	-20, /* STAB */
-	-15, /* CLIMB DOWN */
-	-10, /* FREEZE LIFE */
-	16,  /* HIT */
-	5,   /* SWING */
-	-15, /* STAB */
-	-17, /* THRUST */
-	-5,  /* JAB */
-	29,  /* PARRY */
-	10,  /* HACK */
-	-10, /* BERZERK */
-	-7,  /* FIREBALL */
-	-7,  /* DISPELL */
-	-7,  /* CONFUSE */
-	-7,  /* LIGHTNING */
-	-7,  /* DISRUPT */
-	-5,  /* MELEE */
-	-15, /* X */
-	-9,  /* INVOKE */
-	4,   /* SLASH */
-	0,   /* CLEAVE */
-	0,   /* BASH */
-	5,   /* STUN */
-	-15, /* SHOOT */
-	-7,  /* SPELLSHIELD */
-	-7,  /* FIRESHIELD */
-	8,   /* FLUXCAGE */
-	-20, /* HEAL */
-	-5,  /* CALM */
-	0,   /* LIGHT */
-	-15, /* WINDOW */
-	-7,  /* SPIT */
-	-4,  /* BRANDISH */
-	0,   /* THROW */
-	8};  /* FUSE */
+void Timeline::initConstants() {
+	static signed char actionDefense[44] = { // @ G0495_ac_Graphic560_ActionDefense
+		0,   /* N */
+		36,  /* BLOCK */
+		0,   /* CHOP */
+		0,   /* X */
+		-4,  /* BLOW HORN */
+		-10, /* FLIP */
+		-10, /* PUNCH */
+		-5,  /* KICK */
+		4,   /* WAR CRY */
+		-20, /* STAB */
+		-15, /* CLIMB DOWN */
+		-10, /* FREEZE LIFE */
+		16,  /* HIT */
+		5,   /* SWING */
+		-15, /* STAB */
+		-17, /* THRUST */
+		-5,  /* JAB */
+		29,  /* PARRY */
+		10,  /* HACK */
+		-10, /* BERZERK */
+		-7,  /* FIREBALL */
+		-7,  /* DISPELL */
+		-7,  /* CONFUSE */
+		-7,  /* LIGHTNING */
+		-7,  /* DISRUPT */
+		-5,  /* MELEE */
+		-15, /* X */
+		-9,  /* INVOKE */
+		4,   /* SLASH */
+		0,   /* CLEAVE */
+		0,   /* BASH */
+		5,   /* STUN */
+		-15, /* SHOOT */
+		-7,  /* SPELLSHIELD */
+		-7,  /* FIRESHIELD */
+		8,   /* FLUXCAGE */
+		-20, /* HEAL */
+		-5,  /* CALM */
+		0,   /* LIGHT */
+		-15, /* WINDOW */
+		-7,  /* SPIT */
+		-4,  /* BRANDISH */
+		0,   /* THROW */
+		8    /* FUSE */
+	};
+
+	for (int i = 0; i < 44; i++)
+		_actionDefense[i] = actionDefense[i];
+}
 
 Timeline::Timeline(DMEngine* vm) : _vm(vm) {
 	_eventMaxCount = 0;
@@ -92,6 +98,8 @@ Timeline::Timeline(DMEngine* vm) : _vm(vm) {
 	_eventCount = 0;
 	_timeline = nullptr;
 	_firstUnusedEventIndex = 0;
+
+	initConstants();
 }
 
 Timeline::~Timeline() {
@@ -111,45 +119,37 @@ void Timeline::initTimeline() {
 }
 
 void Timeline::deleteEvent(uint16 eventIndex) {
-	uint16 L0586_ui_TimelineIndex;
-	uint16 L0587_ui_EventCount;
-
-
 	_events[eventIndex]._type = k0_TMEventTypeNone;
-	if (eventIndex < _firstUnusedEventIndex) {
+	if (eventIndex < _firstUnusedEventIndex)
 		_firstUnusedEventIndex = eventIndex;
-	}
+
 	_eventCount--;
-	if ((L0587_ui_EventCount = _eventCount) == 0) {
+	
+	uint16 eventCount = _eventCount;
+	if (eventCount == 0)
 		return;
-	}
-	L0586_ui_TimelineIndex = getIndex(eventIndex);
-	if (L0586_ui_TimelineIndex == L0587_ui_EventCount) {
+
+	uint16 timelineIndex = getIndex(eventIndex);
+	if (timelineIndex == eventCount)
 		return;
-	}
-	_timeline[L0586_ui_TimelineIndex] = _timeline[L0587_ui_EventCount];
-	fixChronology(L0586_ui_TimelineIndex);
+
+	_timeline[timelineIndex] = _timeline[eventCount];
+	fixChronology(timelineIndex);
 }
 
 void Timeline::fixChronology(uint16 timelineIndex) {
-	uint16 L0581_ui_TimelineIndex;
-	uint16 L0582_ui_EventIndex;
-	uint16 L0583_ui_EventCount;
-	TimelineEvent* L0584_ps_Event;
-	bool L0585_B_ChronologyFixed;
-
-
-	if ((L0583_ui_EventCount = _eventCount) == 1) {
+	uint16 eventCount = _eventCount;
+	if (eventCount == 1)
 		return;
-	}
 
-	L0584_ps_Event = &_events[L0582_ui_EventIndex = _timeline[timelineIndex]];
-	L0585_B_ChronologyFixed = false;
+	uint16 L0582_ui_EventIndex = _timeline[timelineIndex];
+	TimelineEvent *timelineEvent = &_events[L0582_ui_EventIndex];
+	bool L0585_B_ChronologyFixed = false;
 	while (timelineIndex > 0) { /* Check if the event should be moved earlier in the timeline */
-		L0581_ui_TimelineIndex = (timelineIndex - 1) >> 1;
-		if (isEventABeforeB(L0584_ps_Event, &_events[_timeline[L0581_ui_TimelineIndex]])) {
-			_timeline[timelineIndex] = _timeline[L0581_ui_TimelineIndex];
-			timelineIndex = L0581_ui_TimelineIndex;
+		uint16 altTimelineIndex = (timelineIndex - 1) >> 1;
+		if (isEventABeforeB(timelineEvent, &_events[_timeline[altTimelineIndex]])) {
+			_timeline[timelineIndex] = _timeline[altTimelineIndex];
+			timelineIndex = altTimelineIndex;
 			L0585_B_ChronologyFixed = true;
 		} else {
 			break;
@@ -157,15 +157,15 @@ void Timeline::fixChronology(uint16 timelineIndex) {
 	}
 	if (L0585_B_ChronologyFixed)
 		goto T0236011;
-	L0583_ui_EventCount = ((L0583_ui_EventCount - 1) - 1) >> 1;
-	while (timelineIndex <= L0583_ui_EventCount) { /* Check if the event should be moved later in the timeline */
-		L0581_ui_TimelineIndex = (timelineIndex << 1) + 1;
-		if (((L0581_ui_TimelineIndex + 1) < _eventCount) && (isEventABeforeB(&_events[_timeline[L0581_ui_TimelineIndex + 1]], &_events[_timeline[L0581_ui_TimelineIndex]]))) {
-			L0581_ui_TimelineIndex++;
+	eventCount = ((eventCount - 1) - 1) >> 1;
+	while (timelineIndex <= eventCount) { /* Check if the event should be moved later in the timeline */
+		uint16 altTimelineIndex = (timelineIndex << 1) + 1;
+		if (((altTimelineIndex + 1) < _eventCount) && (isEventABeforeB(&_events[_timeline[altTimelineIndex + 1]], &_events[_timeline[altTimelineIndex]]))) {
+			altTimelineIndex++;
 		}
-		if (isEventABeforeB(&_events[_timeline[L0581_ui_TimelineIndex]], L0584_ps_Event)) {
-			_timeline[timelineIndex] = _timeline[L0581_ui_TimelineIndex];
-			timelineIndex = L0581_ui_TimelineIndex;
+		if (isEventABeforeB(&_events[_timeline[altTimelineIndex]], timelineEvent)) {
+			_timeline[timelineIndex] = _timeline[altTimelineIndex];
+			timelineIndex = altTimelineIndex;
 		} else {
 			break;
 		}
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 1c0f51a..3f87ae2 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -95,8 +95,6 @@ k82_TMEventTypeMagicMap_C82 = 82, // @ C82_EVENT_MAGIC_MAP
 k83_TMEventTypeMagicMap_C83 = 83  // @ C83_EVENT_MAGIC_MAP    
 };
 
-extern signed char _actionDefense[44]; // @ G0495_ac_Graphic560_ActionDefense
-
 class TimelineEvent {
 public:
 	int32 _mapTime;
@@ -191,6 +189,10 @@ public:
 	void saveTimelinePart(Common::OutSaveFile *file);
 	void loadEventsPart(Common::InSaveFile* file);
 	void loadTimelinePart(Common::InSaveFile* file);
+
+	signed char _actionDefense[44]; // @ G0495_ac_Graphic560_ActionDefense
+
+	void initConstants();
 };
 
 }


Commit: 40f57744ef9eb93fa99d14664053bb1f1e0ffcea
    https://github.com/scummvm/scummvm/commit/40f57744ef9eb93fa99d14664053bb1f1e0ffcea
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-07T21:46:08+02:00

Commit Message:
DM: Remove a GOTO from fixChronology()

Changed paths:
    engines/dm/timeline.cpp



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 0f72207..1123900 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -142,36 +142,34 @@ void Timeline::fixChronology(uint16 timelineIndex) {
 	if (eventCount == 1)
 		return;
 
-	uint16 L0582_ui_EventIndex = _timeline[timelineIndex];
-	TimelineEvent *timelineEvent = &_events[L0582_ui_EventIndex];
-	bool L0585_B_ChronologyFixed = false;
+	uint16 eventIndex = _timeline[timelineIndex];
+	TimelineEvent *timelineEvent = &_events[eventIndex];
+	bool chronologyFixed = false;
 	while (timelineIndex > 0) { /* Check if the event should be moved earlier in the timeline */
 		uint16 altTimelineIndex = (timelineIndex - 1) >> 1;
 		if (isEventABeforeB(timelineEvent, &_events[_timeline[altTimelineIndex]])) {
 			_timeline[timelineIndex] = _timeline[altTimelineIndex];
 			timelineIndex = altTimelineIndex;
-			L0585_B_ChronologyFixed = true;
-		} else {
+			chronologyFixed = true;
+		} else
 			break;
-		}
 	}
-	if (L0585_B_ChronologyFixed)
-		goto T0236011;
-	eventCount = ((eventCount - 1) - 1) >> 1;
-	while (timelineIndex <= eventCount) { /* Check if the event should be moved later in the timeline */
-		uint16 altTimelineIndex = (timelineIndex << 1) + 1;
-		if (((altTimelineIndex + 1) < _eventCount) && (isEventABeforeB(&_events[_timeline[altTimelineIndex + 1]], &_events[_timeline[altTimelineIndex]]))) {
-			altTimelineIndex++;
-		}
-		if (isEventABeforeB(&_events[_timeline[altTimelineIndex]], timelineEvent)) {
-			_timeline[timelineIndex] = _timeline[altTimelineIndex];
-			timelineIndex = altTimelineIndex;
-		} else {
-			break;
+	if (!chronologyFixed) {
+		eventCount = ((eventCount - 1) - 1) >> 1;
+		while (timelineIndex <= eventCount) { /* Check if the event should be moved later in the timeline */
+			uint16 altTimelineIndex = (timelineIndex << 1) + 1;
+			if (((altTimelineIndex + 1) < _eventCount) && (isEventABeforeB(&_events[_timeline[altTimelineIndex + 1]], &_events[_timeline[altTimelineIndex]])))
+				altTimelineIndex++;
+			
+			if (isEventABeforeB(&_events[_timeline[altTimelineIndex]], timelineEvent)) {
+				_timeline[timelineIndex] = _timeline[altTimelineIndex];
+				timelineIndex = altTimelineIndex;
+			} else
+				break;
 		}
 	}
-T0236011:
-	_timeline[timelineIndex] = L0582_ui_EventIndex;
+
+	_timeline[timelineIndex] = eventIndex;
 }
 
 bool Timeline::isEventABeforeB(TimelineEvent* eventA, TimelineEvent* eventB) {


Commit: 6e412c6a8baf127d7cb7624c4b6b2f67765a7d22
    https://github.com/scummvm/scummvm/commit/6e412c6a8baf127d7cb7624c4b6b2f67765a7d22
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-07T22:19:10+02:00

Commit Message:
DM: more renaming in Timeline

Changed paths:
    engines/dm/timeline.cpp



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 1123900..5fc07b4 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -172,203 +172,192 @@ void Timeline::fixChronology(uint16 timelineIndex) {
 	_timeline[timelineIndex] = eventIndex;
 }
 
-bool Timeline::isEventABeforeB(TimelineEvent* eventA, TimelineEvent* eventB) {
-	bool L0578_B_Simultaneous;
+bool Timeline::isEventABeforeB(TimelineEvent *eventA, TimelineEvent *eventB) {
+	bool simultaneousFl = (filterTime(eventA->_mapTime) == filterTime(eventB->_mapTime));
 
 	return (filterTime(eventA->_mapTime) < filterTime(eventB->_mapTime)) ||
-		((L0578_B_Simultaneous = (filterTime(eventA->_mapTime) == filterTime(eventB->_mapTime))) && (eventA->getTypePriority() > eventB->getTypePriority())) ||
-		(L0578_B_Simultaneous && (eventA->getTypePriority() == eventB->getTypePriority()) && (eventA <= eventB));
+		(simultaneousFl && (eventA->getTypePriority() > eventB->getTypePriority())) ||
+		(simultaneousFl && (eventA->getTypePriority() == eventB->getTypePriority()) && (eventA <= eventB));
 }
 
 uint16 Timeline::getIndex(uint16 eventIndex) {
-	uint16 L0579_ui_TimelineIndex;
-	uint16* L0580_pui_TimelineEntry;
+	uint16 timelineIndex;
+	uint16 *timelineEntry = _timeline;
 
-
-	for (L0579_ui_TimelineIndex = 0, L0580_pui_TimelineEntry = _timeline; L0579_ui_TimelineIndex < _eventMaxCount; L0579_ui_TimelineIndex++) {
-		if (*L0580_pui_TimelineEntry++ == eventIndex)
+	for (timelineIndex = 0; timelineIndex < _eventMaxCount; timelineIndex++) {
+		if (*timelineEntry++ == eventIndex)
 			break;
 	}
-	if (L0579_ui_TimelineIndex >= _eventMaxCount) { /* BUG0_00 Useless code. The function is always called with event indices that are in the timeline */
-		L0579_ui_TimelineIndex = 0; /* BUG0_01 Coding error without consequence. Wrong return value. If the specified event index is not found in the timeline the function returns 0 which is the same value that is returned if the event index is found in the first timeline entry. No consequence because this code is never executed */
-	}
-	return L0579_ui_TimelineIndex;
-}
 
-uint16 Timeline::addEventGetEventIndex(TimelineEvent* event) {
-	uint16 L0588_ui_EventIndex;
-	uint16 L0590_ui_NewEventIndex;
-	TimelineEvent* L0591_ps_Event;
+	if (timelineIndex >= _eventMaxCount) /* BUG0_00 Useless code. The function is always called with event indices that are in the timeline */
+		timelineIndex = 0; /* BUG0_01 Coding error without consequence. Wrong return value. If the specified event index is not found in the timeline the function returns 0 which is the same value that is returned if the event index is found in the first timeline entry. No consequence because this code is never executed */
 
+	return timelineIndex;
+}
 
+uint16 Timeline::addEventGetEventIndex(TimelineEvent *event) {
 	if (_eventCount == _eventMaxCount)
 		error("Too many events");
 
 	if ((event->_type >= k5_TMEventTypeCorridor) && (event->_type <= k10_TMEventTypeDoor)) {
-		for (L0588_ui_EventIndex = 0, L0591_ps_Event = _events; L0588_ui_EventIndex < _eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
-			if ((L0591_ps_Event->_type >= k5_TMEventTypeCorridor) && (L0591_ps_Event->_type <= k10_TMEventTypeDoor)) {
-				if ((event->_mapTime == L0591_ps_Event->_mapTime) && (event->getMapXY() == L0591_ps_Event->getMapXY()) && ((L0591_ps_Event->_type != k6_TMEventTypeWall) || (L0591_ps_Event->_C.A._cell == event->_C.A._cell))) {
-					L0591_ps_Event->_C.A._effect = event->_C.A._effect;
-					return L0588_ui_EventIndex;
+		TimelineEvent *curEvent = _events;
+		for (uint16 eventIndex = 0; eventIndex < _eventMaxCount; eventIndex++, curEvent++) {
+			if ((curEvent->_type >= k5_TMEventTypeCorridor) && (curEvent->_type <= k10_TMEventTypeDoor)) {
+				if ((event->_mapTime == curEvent->_mapTime) && (event->getMapXY() == curEvent->getMapXY()) && ((curEvent->_type != k6_TMEventTypeWall) || (curEvent->_C.A._cell == event->_C.A._cell))) {
+					curEvent->_C.A._effect = event->_C.A._effect;
+					return eventIndex;
 				}
 				continue;
-			} else {
-				if ((L0591_ps_Event->_type == k1_TMEventTypeDoorAnimation) && (event->_mapTime == L0591_ps_Event->_mapTime) && (event->getMapXY() == L0591_ps_Event->getMapXY())) {
-					if (event->_C.A._effect == k2_SensorEffToggle) {
-						event->_C.A._effect = 1 - L0591_ps_Event->_C.A._effect;
-					}
-					deleteEvent(L0588_ui_EventIndex);
-					break;
-				}
+			} else if ((curEvent->_type == k1_TMEventTypeDoorAnimation) && (event->_mapTime == curEvent->_mapTime) && (event->getMapXY() == curEvent->getMapXY())) {
+				if (event->_C.A._effect == k2_SensorEffToggle)
+					event->_C.A._effect = 1 - curEvent->_C.A._effect;
+
+				deleteEvent(eventIndex);
+				break;
 			}
 		}
-	} else {
-		if (event->_type == k1_TMEventTypeDoorAnimation) {
-			for (L0588_ui_EventIndex = 0, L0591_ps_Event = _events; L0588_ui_EventIndex < _eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
-				if ((event->_mapTime == L0591_ps_Event->_mapTime) && (event->getMapXY() == L0591_ps_Event->getMapXY())) {
-					if (L0591_ps_Event->_type == k10_TMEventTypeDoor) {
-						if (L0591_ps_Event->_C.A._effect == k2_SensorEffToggle) {
-							L0591_ps_Event->_C.A._effect = 1 - event->_C.A._effect;
-						}
-						return L0588_ui_EventIndex;
-					}
-					if (L0591_ps_Event->_type == k1_TMEventTypeDoorAnimation) {
-						L0591_ps_Event->_C.A._effect = event->_C.A._effect;
-						return L0588_ui_EventIndex;
-					}
+	} else if (event->_type == k1_TMEventTypeDoorAnimation) {
+		TimelineEvent *curEvent = _events;
+		for (uint16 eventIndex = 0; eventIndex < _eventMaxCount; eventIndex++, curEvent++) {
+			if ((event->_mapTime == curEvent->_mapTime) && (event->getMapXY() == curEvent->getMapXY())) {
+				if (curEvent->_type == k10_TMEventTypeDoor) {
+					if (curEvent->_C.A._effect == k2_SensorEffToggle)
+						curEvent->_C.A._effect = 1 - event->_C.A._effect;
+
+					return eventIndex;
 				}
-			}
-		} else {
-			if (event->_type == k2_TMEventTypeDoorDestruction) {
-				for (L0588_ui_EventIndex = 0, L0591_ps_Event = _events; L0588_ui_EventIndex < _eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) {
-					if ((event->getMapXY() == L0591_ps_Event->getMapXY()) && (getMap(event->_mapTime) == getMap(L0591_ps_Event->_mapTime))) {
-						if ((L0591_ps_Event->_type == k1_TMEventTypeDoorAnimation) || (L0591_ps_Event->_type == k10_TMEventTypeDoor)) {
-							deleteEvent(L0588_ui_EventIndex);
-						}
-					}
+				if (curEvent->_type == k1_TMEventTypeDoorAnimation) {
+					curEvent->_C.A._effect = event->_C.A._effect;
+					return eventIndex;
 				}
 			}
 		}
+	} else if (event->_type == k2_TMEventTypeDoorDestruction) {
+		TimelineEvent *curEvent = _events;
+		for (uint16 eventIndex = 0; eventIndex < _eventMaxCount; eventIndex++, curEvent++) {
+			if ((event->getMapXY() == curEvent->getMapXY()) && (getMap(event->_mapTime) == getMap(curEvent->_mapTime))) {
+				if ((curEvent->_type == k1_TMEventTypeDoorAnimation) || (curEvent->_type == k10_TMEventTypeDoor))
+					deleteEvent(eventIndex);
+			}
+		}
 	}
-	_events[L0590_ui_NewEventIndex = _firstUnusedEventIndex] = *event; /* Copy the event data (Megamax C can assign structures) */
+
+	uint16 newEventIndex = _firstUnusedEventIndex;
+	_events[newEventIndex] = *event; /* Copy the event data (Megamax C can assign structures) */
 	do {
 		if (_firstUnusedEventIndex == _eventMaxCount)
 			break;
 		_firstUnusedEventIndex++;
 	} while ((_events[_firstUnusedEventIndex])._type != k0_TMEventTypeNone);
-	_timeline[_eventCount] = L0590_ui_NewEventIndex;
+	_timeline[_eventCount] = newEventIndex;
 	fixChronology(_eventCount++);
-	return L0590_ui_NewEventIndex;
+	return newEventIndex;
 }
 
 void Timeline::processTimeline() {
-	uint16 L0680_ui_Multiple;
-#define AL0680_ui_EventType     L0680_ui_Multiple
-#define AL0680_ui_ChampionIndex L0680_ui_Multiple
-	TimelineEvent* L0681_ps_Event;
-	TimelineEvent L0682_s_Event;
-
-
 	while (isFirstEventExpiered()) {
-		L0681_ps_Event = &L0682_s_Event;
-		extractFirstEvent(L0681_ps_Event);
-		_vm->_dungeonMan->setCurrentMap(getMap(L0682_s_Event._mapTime));
-		AL0680_ui_EventType = L0682_s_Event._type;
-		if ((AL0680_ui_EventType > (k29_TMEventTypeGroupReactionDangerOnSquare - 1)) && (AL0680_ui_EventType < (k41_TMEventTypeUpdateBehaviour_3 + 1))) {
-			_vm->_groupMan->processEvents29to41(L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, AL0680_ui_EventType, L0682_s_Event._C._ticks);
-		} else {
-			switch (AL0680_ui_EventType) {
+		TimelineEvent newEvent;
+		TimelineEvent *curEvent = &newEvent;
+		extractFirstEvent(curEvent);
+		_vm->_dungeonMan->setCurrentMap(getMap(newEvent._mapTime));
+		uint16 curEventType = newEvent._type;
+		if ((curEventType > (k29_TMEventTypeGroupReactionDangerOnSquare - 1)) && (curEventType < (k41_TMEventTypeUpdateBehaviour_3 + 1)))
+			_vm->_groupMan->processEvents29to41(newEvent._B._location._mapX, newEvent._B._location._mapY, curEventType, newEvent._C._ticks);
+		else {
+			switch (curEventType) {
 			case k48_TMEventTypeMoveProjectileIgnoreImpacts:
 			case k49_TMEventTypeMoveProjectile:
-				_vm->_projexpl->processEvents48To49(L0681_ps_Event);
+				_vm->_projexpl->processEvents48To49(curEvent);
 				break;
 			case k1_TMEventTypeDoorAnimation:
-				processEventDoorAnimation(L0681_ps_Event);
+				processEventDoorAnimation(curEvent);
 				break;
 			case k25_TMEventTypeExplosion:
-				_vm->_projexpl->processEvent25(L0681_ps_Event);
+				_vm->_projexpl->processEvent25(curEvent);
 				break;
 			case k7_TMEventTypeFakeWall:
-				processEventSquareFakewall(L0681_ps_Event);
+				processEventSquareFakewall(curEvent);
 				break;
 			case k2_TMEventTypeDoorDestruction:
-				processEventDoorDestruction(L0681_ps_Event);
+				processEventDoorDestruction(curEvent);
 				break;
 			case k10_TMEventTypeDoor:
-				processEventSquareDoor(L0681_ps_Event);
+				processEventSquareDoor(curEvent);
 				break;
 			case k9_TMEventTypePit:
-				processEventSquarePit(L0681_ps_Event);
+				processEventSquarePit(curEvent);
 				break;
 			case k8_TMEventTypeTeleporter:
-				processEventSquareTeleporter(L0681_ps_Event);
+				processEventSquareTeleporter(curEvent);
 				break;
 			case k6_TMEventTypeWall:
-				processEventSquareWall(L0681_ps_Event);
+				processEventSquareWall(curEvent);
 				break;
 			case k5_TMEventTypeCorridor:
-				processEventSquareCorridor(L0681_ps_Event);
+				processEventSquareCorridor(curEvent);
 				break;
 			case k60_TMEventTypeMoveGroupSilent:
 			case k61_TMEventTypeMoveGroupAudible:
-				processEventsMoveGroup(L0681_ps_Event);
+				processEventsMoveGroup(curEvent);
 				break;
 			case k65_TMEventTypeEnableGroupGenerator:
-				procesEventEnableGroupGenerator(L0681_ps_Event);
+				procesEventEnableGroupGenerator(curEvent);
 				break;
 			case k20_TMEventTypePlaySound:
-				_vm->_sound->requestPlay(L0682_s_Event._C._soundIndex, L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, k1_soundModePlayIfPrioritized);
+				_vm->_sound->requestPlay(newEvent._C._soundIndex, newEvent._B._location._mapX, newEvent._B._location._mapY, k1_soundModePlayIfPrioritized);
 				break;
 			case k24_TMEventTypeRemoveFluxcage:
 				if (!_vm->_gameWon) {
-					_vm->_dungeonMan->unlinkThingFromList(Thing(L0682_s_Event._C._slot), Thing(0), L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY);
-					L0681_ps_Event = (TimelineEvent*)_vm->_dungeonMan->getThingData(Thing(L0682_s_Event._C._slot));
-					((Explosion*)L0681_ps_Event)->setNextThing(Thing::_none);
+					_vm->_dungeonMan->unlinkThingFromList(Thing(newEvent._C._slot), Thing(0), newEvent._B._location._mapX, newEvent._B._location._mapY);
+					curEvent = (TimelineEvent*)_vm->_dungeonMan->getThingData(Thing(newEvent._C._slot));
+					((Explosion*)curEvent)->setNextThing(Thing::_none);
 				}
 				break;
 			case k11_TMEventTypeEnableChampionAction:
-				processEventEnableChampionAction(L0682_s_Event._priority);
-				if (L0682_s_Event._B._slotOrdinal) {
-					processEventMoveWeaponFromQuiverToSlot(L0682_s_Event._priority, _vm->ordinalToIndex(L0682_s_Event._B._slotOrdinal));
+				processEventEnableChampionAction(newEvent._priority);
+				if (newEvent._B._slotOrdinal) {
+					processEventMoveWeaponFromQuiverToSlot(newEvent._priority, _vm->ordinalToIndex(newEvent._B._slotOrdinal));
 				}
 				goto T0261048;
 			case k12_TMEventTypeHideDamageReceived:
-				processEventHideDamageReceived(L0682_s_Event._priority);
+				processEventHideDamageReceived(newEvent._priority);
 				break;
 			case k70_TMEventTypeLight:
 				_vm->_dungeonMan->setCurrentMap(_vm->_dungeonMan->_partyMapIndex);
-				processEventLight(L0681_ps_Event);
+				processEventLight(curEvent);
 				_vm->_inventoryMan->setDungeonViewPalette();
 				break;
 			case k71_TMEventTypeInvisibility:
 				_vm->_championMan->_party._event71Count_Invisibility--;
 				break;
 			case k72_TMEventTypeChampionShield:
-				_vm->_championMan->_champions[L0682_s_Event._priority]._shieldDefense -= L0682_s_Event._B._defense;
-				setFlag(_vm->_championMan->_champions[L0682_s_Event._priority]._attributes, k0x1000_ChampionAttributeStatusBox);
+				_vm->_championMan->_champions[newEvent._priority]._shieldDefense -= newEvent._B._defense;
+				setFlag(_vm->_championMan->_champions[newEvent._priority]._attributes, k0x1000_ChampionAttributeStatusBox);
 T0261048:
-				_vm->_championMan->drawChampionState((ChampionIndex)L0682_s_Event._priority);
+				_vm->_championMan->drawChampionState((ChampionIndex)newEvent._priority);
 				break;
 			case k73_TMEventTypeThievesEye:
 				_vm->_championMan->_party._event73Count_ThievesEye--;
 				break;
 			case k74_TMEventTypePartyShield:
-				_vm->_championMan->_party._shieldDefense -= L0682_s_Event._B._defense;
+				_vm->_championMan->_party._shieldDefense -= newEvent._B._defense;
 T0261053:
 				refreshAllChampionStatusBoxes();
 				break;
 			case k77_TMEventTypeSpellShield:
-				_vm->_championMan->_party._spellShieldDefense -= L0682_s_Event._B._defense;
+				_vm->_championMan->_party._spellShieldDefense -= newEvent._B._defense;
 				goto T0261053;
 			case k78_TMEventTypeFireShield:
-				_vm->_championMan->_party._fireShieldDefense -= L0682_s_Event._B._defense;
+				_vm->_championMan->_party._fireShieldDefense -= newEvent._B._defense;
 				goto T0261053;
-			case k75_TMEventTypePoisonChampion:
-				_vm->_championMan->_champions[AL0680_ui_ChampionIndex = L0682_s_Event._priority]._poisonEventCount--;
-				_vm->_championMan->championPoison(AL0680_ui_ChampionIndex, L0682_s_Event._B._attack);
+			case k75_TMEventTypePoisonChampion: {
+				uint16 championIndex = newEvent._priority;
+				_vm->_championMan->_champions[championIndex = newEvent._priority]._poisonEventCount--;
+				_vm->_championMan->championPoison(championIndex, newEvent._B._attack);
+				}
 				break;
 			case k13_TMEventTypeViAltarRebirth:
-				processEventViAltarRebirth(L0681_ps_Event);
+				processEventViAltarRebirth(curEvent);
 				break;
 			case k79_TMEventTypeFootprints:
 				_vm->_championMan->_party._event79Count_Footprints--;
@@ -383,10 +372,10 @@ bool Timeline::isFirstEventExpiered() {
 }
 
 void Timeline::extractFirstEvent(TimelineEvent* event) {
-	uint16 L0592_ui_EventIndex;
+	uint16 eventIndex = _timeline[0];
 
-	*event = _events[L0592_ui_EventIndex = _timeline[0]];
-	deleteEvent(L0592_ui_EventIndex);
+	*event = _events[eventIndex];
+	deleteEvent(eventIndex);
 }
 
 void Timeline::processEventDoorAnimation(TimelineEvent* event) {


Commit: 4703c6e7991349fa06638076d6a9a37d6cf2d3a5
    https://github.com/scummvm/scummvm/commit/4703c6e7991349fa06638076d6a9a37d6cf2d3a5
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-07T22:21:01+02:00

Commit Message:
DM: Remove GOTOs from processTimeline()

Changed paths:
    engines/dm/timeline.cpp



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 5fc07b4..558ecc8 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -315,10 +315,11 @@ void Timeline::processTimeline() {
 				break;
 			case k11_TMEventTypeEnableChampionAction:
 				processEventEnableChampionAction(newEvent._priority);
-				if (newEvent._B._slotOrdinal) {
+				if (newEvent._B._slotOrdinal)
 					processEventMoveWeaponFromQuiverToSlot(newEvent._priority, _vm->ordinalToIndex(newEvent._B._slotOrdinal));
-				}
-				goto T0261048;
+
+				_vm->_championMan->drawChampionState((ChampionIndex)newEvent._priority);
+				break;
 			case k12_TMEventTypeHideDamageReceived:
 				processEventHideDamageReceived(newEvent._priority);
 				break;
@@ -333,7 +334,6 @@ void Timeline::processTimeline() {
 			case k72_TMEventTypeChampionShield:
 				_vm->_championMan->_champions[newEvent._priority]._shieldDefense -= newEvent._B._defense;
 				setFlag(_vm->_championMan->_champions[newEvent._priority]._attributes, k0x1000_ChampionAttributeStatusBox);
-T0261048:
 				_vm->_championMan->drawChampionState((ChampionIndex)newEvent._priority);
 				break;
 			case k73_TMEventTypeThievesEye:
@@ -341,15 +341,16 @@ T0261048:
 				break;
 			case k74_TMEventTypePartyShield:
 				_vm->_championMan->_party._shieldDefense -= newEvent._B._defense;
-T0261053:
 				refreshAllChampionStatusBoxes();
 				break;
 			case k77_TMEventTypeSpellShield:
 				_vm->_championMan->_party._spellShieldDefense -= newEvent._B._defense;
-				goto T0261053;
+				refreshAllChampionStatusBoxes();
+				break;
 			case k78_TMEventTypeFireShield:
 				_vm->_championMan->_party._fireShieldDefense -= newEvent._B._defense;
-				goto T0261053;
+				refreshAllChampionStatusBoxes();
+				break;
 			case k75_TMEventTypePoisonChampion: {
 				uint16 championIndex = newEvent._priority;
 				_vm->_championMan->_champions[championIndex = newEvent._priority]._poisonEventCount--;


Commit: 3d4c73251d62edfeafeceef87a74c1c2641da9c3
    https://github.com/scummvm/scummvm/commit/3d4c73251d62edfeafeceef87a74c1c2641da9c3
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-07T22:58:18+02:00

Commit Message:
DM: More refactoring in Timeline

Changed paths:
    engines/dm/timeline.cpp



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 558ecc8..fc5092f 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -372,162 +372,134 @@ bool Timeline::isFirstEventExpiered() {
 	return (_eventCount && (filterTime(_events[_timeline[0]]._mapTime) <= _vm->_gameTime));
 }
 
-void Timeline::extractFirstEvent(TimelineEvent* event) {
+void Timeline::extractFirstEvent(TimelineEvent *event) {
 	uint16 eventIndex = _timeline[0];
 
 	*event = _events[eventIndex];
 	deleteEvent(eventIndex);
 }
 
-void Timeline::processEventDoorAnimation(TimelineEvent* event) {
-	uint16 L0593_ui_MapX;
-	uint16 L0594_ui_MapY;
-	int16 L0595_i_Effect;
-	int16 L0596_i_DoorState;
-	Square* L0597_puc_Square;
-	Door* L0598_ps_Door;
-	Thing L0599_T_GroupThing;
-	uint16 L0600_ui_CreatureAttributes;
-	uint16 L0602_ui_Multiple;
-#define AL0602_ui_VerticalDoor L0602_ui_Multiple
-#define AL0602_ui_Height       L0602_ui_Multiple
-
-	L0597_puc_Square = (Square*)&_vm->_dungeonMan->_currMapData[L0593_ui_MapX = event->_B._location._mapX][L0594_ui_MapY = event->_B._location._mapY];
-	if ((L0596_i_DoorState = Square(*L0597_puc_Square).getDoorState()) == k5_doorState_DESTROYED) {
+void Timeline::processEventDoorAnimation(TimelineEvent *event) {
+	uint16 mapX = event->_B._location._mapX;
+	uint16 mapY = event->_B._location._mapY;
+	Square *curSquare = (Square*)&_vm->_dungeonMan->_currMapData[mapX][mapY];
+	int16 doorState = Square(*curSquare).getDoorState();
+	if (doorState == k5_doorState_DESTROYED)
 		return;
-	}
+
 	event->_mapTime++;
-	L0595_i_Effect = event->_C.A._effect;
-	if (L0595_i_Effect == k1_SensorEffClear) {
-		L0598_ps_Door = (Door*)_vm->_dungeonMan->getSquareFirstThingData(L0593_ui_MapX, L0594_ui_MapY);
-		AL0602_ui_VerticalDoor = L0598_ps_Door->opensVertically();
-		if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0593_ui_MapX == _vm->_dungeonMan->_partyMapX) && (L0594_ui_MapY == _vm->_dungeonMan->_partyMapY) && (L0596_i_DoorState != k0_doorState_OPEN)) {
+	int16 sensorEffect = event->_C.A._effect;
+	if (sensorEffect == k1_SensorEffClear) {
+		Door *curDoor = (Door *)_vm->_dungeonMan->getSquareFirstThingData(mapX, mapY);
+		bool verticalDoorFl = curDoor->opensVertically();
+		if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX)
+		 && (mapY == _vm->_dungeonMan->_partyMapY) && (doorState != k0_doorState_OPEN)) {
 			if (_vm->_championMan->_partyChampionCount > 0) {
-				L0597_puc_Square->setDoorState(k0_doorState_OPEN);
+				curSquare->setDoorState(k0_doorState_OPEN);
 
 				// Strangerke
 				// Original bug fixed - A closing horizontal door wounds champions to the head instead of to the hands. Missing parenthesis in the condition cause all doors to wound the head in addition to the torso
 				// See BUG0_78
-				if (_vm->_championMan->getDamagedChampionCount(5, k0x0008_ChampionWoundTorso | (AL0602_ui_VerticalDoor ? k0x0004_ChampionWoundHead : k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand), k2_attackType_SELF)) {
-					_vm->_sound->requestPlay(k18_soundPARTY_DAMAGED, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
-				}
+				int16 wounds = k0x0008_ChampionWoundTorso | (verticalDoorFl ? k0x0004_ChampionWoundHead : k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand);
+				if (_vm->_championMan->getDamagedChampionCount(5, wounds, k2_attackType_SELF))
+					_vm->_sound->requestPlay(k18_soundPARTY_DAMAGED, mapX, mapY, k1_soundModePlayIfPrioritized);
 			}
 			event->_mapTime++;
 			addEventGetEventIndex(event);
 			return;
 		}
-		if (((L0599_T_GroupThing = _vm->_groupMan->groupGetThing(L0593_ui_MapX, L0594_ui_MapY)) != Thing::_endOfList) && !getFlag(L0600_ui_CreatureAttributes = _vm->_dungeonMan->getCreatureAttributes(L0599_T_GroupThing), k0x0040_MaskCreatureInfo_nonMaterial)) {
-			if (L0596_i_DoorState >= (AL0602_ui_Height ? CreatureInfo::getHeight(L0600_ui_CreatureAttributes) : 1)) { /* Creature height or 1 */
-				if (_vm->_groupMan->getDamageAllCreaturesOutcome((Group*)_vm->_dungeonMan->getThingData(L0599_T_GroupThing), L0593_ui_MapX, L0594_ui_MapY, 5, true) != k2_outcomeKilledAllCreaturesInGroup) {
-					_vm->_groupMan->processEvents29to41(L0593_ui_MapX, L0594_ui_MapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
-				}
-				L0596_i_DoorState = (L0596_i_DoorState == k0_doorState_OPEN) ? k0_doorState_OPEN : (L0596_i_DoorState - 1);
-				L0597_puc_Square->setDoorState(L0596_i_DoorState);
-				_vm->_sound->requestPlay(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
+		Thing groupThing = _vm->_groupMan->groupGetThing(mapX, mapY);
+		uint16 creatureAttributes = _vm->_dungeonMan->getCreatureAttributes(groupThing);
+		if ((groupThing != Thing::_endOfList) && !getFlag(creatureAttributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
+			if (doorState >= (verticalDoorFl ? CreatureInfo::getHeight(creatureAttributes) : 1)) { /* Creature height or 1 */
+				if (_vm->_groupMan->getDamageAllCreaturesOutcome((Group*)_vm->_dungeonMan->getThingData(groupThing), mapX, mapY, 5, true) != k2_outcomeKilledAllCreaturesInGroup)
+					_vm->_groupMan->processEvents29to41(mapX, mapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
+
+				doorState = (doorState == k0_doorState_OPEN) ? k0_doorState_OPEN : (doorState - 1);
+				curSquare->setDoorState(doorState);
+				_vm->_sound->requestPlay(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, k1_soundModePlayIfPrioritized);
 				event->_mapTime++;
 				addEventGetEventIndex(event);
 				return;
 			}
 		}
 	}
-	if (((L0595_i_Effect == k0_SensorEffSet) && (L0596_i_DoorState == k0_doorState_OPEN)) || ((L0595_i_Effect == k1_SensorEffClear) && (L0596_i_DoorState == k4_doorState_CLOSED))) {
-		goto T0241020_Return;
-	}
-	L0596_i_DoorState += (L0595_i_Effect == k0_SensorEffSet) ? -1 : 1;
-	L0597_puc_Square->setDoorState(L0596_i_DoorState);
-	_vm->_sound->requestPlay(k02_soundDOOR_RATTLE, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized);
+	if ((sensorEffect == k0_SensorEffSet) && (doorState == k0_doorState_OPEN))
+		return;
 
-	if (L0595_i_Effect == k0_SensorEffSet) {
-		if (L0596_i_DoorState == k0_doorState_OPEN) {
-			return;
-		}
-	} else {
-		if (L0596_i_DoorState == k4_doorState_CLOSED) {
+	if ((sensorEffect == k1_SensorEffClear) && (doorState == k4_doorState_CLOSED))
+		return;
+
+	doorState += (sensorEffect == k0_SensorEffSet) ? -1 : 1;
+	curSquare->setDoorState(doorState);
+	_vm->_sound->requestPlay(k02_soundDOOR_RATTLE, mapX, mapY, k1_soundModePlayIfPrioritized);
+
+	if (sensorEffect == k0_SensorEffSet) {
+		if (doorState == k0_doorState_OPEN)
 			return;
-		}
-	}
+	} else if (doorState == k4_doorState_CLOSED)
+		return;
+
 	addEventGetEventIndex(event);
-T0241020_Return:
-	;
 }
 
-void Timeline::processEventSquareFakewall(TimelineEvent* event) {
-	uint16 L0603_ui_MapX;
-	uint16 L0604_ui_MapY;
-	int16 L0605_i_Effect;
-	Thing L0606_T_Thing;
-	byte* L0607_puc_Square;
+void Timeline::processEventSquareFakewall(TimelineEvent *event) {
+	uint16 mapX = event->_B._location._mapX;
+	uint16 mapY = event->_B._location._mapY;
+	byte *curSquare = &_vm->_dungeonMan->_currMapData[mapX][mapY];
+	int16 effect = event->_C.A._effect;
+	if (effect == k2_SensorEffToggle)
+		effect = getFlag(*curSquare, k0x0004_FakeWallOpen) ? k1_SensorEffClear : k0_SensorEffSet;
 
-
-	L0607_puc_Square = &_vm->_dungeonMan->_currMapData[L0603_ui_MapX = event->_B._location._mapX][L0604_ui_MapY = event->_B._location._mapY];
-	L0605_i_Effect = event->_C.A._effect;
-	if (L0605_i_Effect == k2_SensorEffToggle) {
-		L0605_i_Effect = getFlag(*L0607_puc_Square, k0x0004_FakeWallOpen) ? k1_SensorEffClear : k0_SensorEffSet;
-	}
-	if (L0605_i_Effect == k1_SensorEffClear) {
-		if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0603_ui_MapX == _vm->_dungeonMan->_partyMapX) && (L0604_ui_MapY == _vm->_dungeonMan->_partyMapY)) {
+	if (effect == k1_SensorEffClear) {
+		if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY)) {
 			event->_mapTime++;
 			addEventGetEventIndex(event);
 		} else {
-			if (((L0606_T_Thing = _vm->_groupMan->groupGetThing(L0603_ui_MapX, L0604_ui_MapY)) != Thing::_endOfList) && !getFlag(_vm->_dungeonMan->getCreatureAttributes(L0606_T_Thing), k0x0040_MaskCreatureInfo_nonMaterial)) {
+			Thing groupThing = _vm->_groupMan->groupGetThing(mapX, mapY);
+			if ((groupThing != Thing::_endOfList) && !getFlag(_vm->_dungeonMan->getCreatureAttributes(groupThing), k0x0040_MaskCreatureInfo_nonMaterial)) {
 				event->_mapTime++;
 				addEventGetEventIndex(event);
-			} else {
-				clearFlag(*L0607_puc_Square, k0x0004_FakeWallOpen);
-			}
+			} else
+				clearFlag(*curSquare, k0x0004_FakeWallOpen);
 		}
-	} else {
-		setFlag(*L0607_puc_Square, k0x0004_FakeWallOpen);
-	}
+	} else
+		setFlag(*curSquare, k0x0004_FakeWallOpen);
 }
 
-void Timeline::processEventDoorDestruction(TimelineEvent* event) {
-	Square* L0608_puc_Square;
-
-	L0608_puc_Square = (Square*)&_vm->_dungeonMan->_currMapData[event->_B._location._mapX][event->_B._location._mapY];
-	L0608_puc_Square->setDoorState(k5_doorState_DESTROYED);
+void Timeline::processEventDoorDestruction(TimelineEvent *event) {
+	Square *square = (Square*)&_vm->_dungeonMan->_currMapData[event->_B._location._mapX][event->_B._location._mapY];
+	square->setDoorState(k5_doorState_DESTROYED);
 }
 
-void Timeline::processEventSquareDoor(TimelineEvent* event) {
-	int16 L0609_i_DoorState;
-
-
-	if ((L0609_i_DoorState = Square(_vm->_dungeonMan->_currMapData[event->_B._location._mapX][event->_B._location._mapY]).getDoorState()) == k5_doorState_DESTROYED) {
+void Timeline::processEventSquareDoor(TimelineEvent *event) {
+	int16 doorState = Square(_vm->_dungeonMan->_currMapData[event->_B._location._mapX][event->_B._location._mapY]).getDoorState();
+	if (doorState == k5_doorState_DESTROYED)
 		return;
-	}
-	if (event->_C.A._effect == k2_SensorEffToggle) {
-		event->_C.A._effect = (L0609_i_DoorState == k0_doorState_OPEN) ? k1_SensorEffClear : k0_SensorEffSet;
-	} else {
-		if (event->_C.A._effect == k0_SensorEffSet) {
-			if (L0609_i_DoorState == k0_doorState_OPEN) {
-				return;
-			}
-		} else {
-			if (L0609_i_DoorState == k4_doorState_CLOSED) {
-				return;
-			}
-		}
+
+	if (event->_C.A._effect == k2_SensorEffToggle)
+		event->_C.A._effect = (doorState == k0_doorState_OPEN) ? k1_SensorEffClear : k0_SensorEffSet;
+	else if (event->_C.A._effect == k0_SensorEffSet) {
+		if ((doorState == k0_doorState_OPEN) || (doorState == k4_doorState_CLOSED))
+			return;
 	}
 	event->_type = k1_TMEventTypeDoorAnimation;
 	addEventGetEventIndex(event);
 }
 
-void Timeline::processEventSquarePit(TimelineEvent* event) {
-	uint16 L0653_ui_MapX;
-	uint16 L0654_ui_MapY;
-	byte* L0655_puc_Square;
+void Timeline::processEventSquarePit(TimelineEvent *event) {
+	uint16 L0653_ui_MapX = event->_B._location._mapX;
+	uint16 L0654_ui_MapY = event->_B._location._mapY;
 
+	byte *square = &_vm->_dungeonMan->_currMapData[L0653_ui_MapX][L0654_ui_MapY];
+	if (event->_C.A._effect == k2_SensorEffToggle)
+		event->_C.A._effect = getFlag(*square, k0x0008_PitOpen) ? k1_SensorEffClear : k0_SensorEffSet;
 
-	L0655_puc_Square = &_vm->_dungeonMan->_currMapData[L0653_ui_MapX = event->_B._location._mapX][L0654_ui_MapY = event->_B._location._mapY];
-	if (event->_C.A._effect == k2_SensorEffToggle) {
-		event->_C.A._effect = getFlag(*L0655_puc_Square, k0x0008_PitOpen) ? k1_SensorEffClear : k0_SensorEffSet;
-	}
 	if (event->_C.A._effect == k0_SensorEffSet) {
-		setFlag(*L0655_puc_Square, k0x0008_PitOpen);
+		setFlag(*square, k0x0008_PitOpen);
 		moveTeleporterOrPitSquareThings(L0653_ui_MapX, L0654_ui_MapY);
-	} else {
-		clearFlag(*L0655_puc_Square, k0x0008_PitOpen);
-	}
+	} else
+		clearFlag(*square, k0x0008_PitOpen);
 }
 
 void Timeline::moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {


Commit: f18013db6546fef51dcc096e08b770cbe8fbf1a4
    https://github.com/scummvm/scummvm/commit/f18013db6546fef51dcc096e08b770cbe8fbf1a4
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-07T23:29:04+02:00

Commit Message:
DM: Renaming in more functions of Timeline

Changed paths:
    engines/dm/timeline.cpp



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index fc5092f..cfd6d7f 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -503,175 +503,134 @@ void Timeline::processEventSquarePit(TimelineEvent *event) {
 }
 
 void Timeline::moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
-	uint16 L0644_ui_Multiple;
-#define AL0644_ui_ThingType  L0644_ui_Multiple
-#define AL0644_ui_EventIndex L0644_ui_Multiple
-	Thing L0645_T_Thing;
-	Projectile* L0646_ps_Projectile;
-	TimelineEvent* L0647_ps_Event;
-	Thing L0648_T_NextThing;
-	int16 L0649_i_ThingsToMoveCount;
-
-
-	if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY)) {
+	if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex)
+	 && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY)) {
 		_vm->_moveSens->getMoveResult(Thing::_party, mapX, mapY, mapX, mapY);
 		_vm->_championMan->drawChangedObjectIcons();
 	}
-	if ((L0645_T_Thing = _vm->_groupMan->groupGetThing(mapX, mapY)) != Thing::_endOfList) {
-		_vm->_moveSens->getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
-	}
-	L0645_T_Thing = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
-	L0648_T_NextThing = L0645_T_Thing;
-	L0649_i_ThingsToMoveCount = 0;
-	while (L0645_T_Thing != Thing::_endOfList) {
-		if (L0645_T_Thing.getType() > k4_GroupThingType) {
-			L0649_i_ThingsToMoveCount++;
-		}
-		L0645_T_Thing = _vm->_dungeonMan->getNextThing(L0645_T_Thing);
+
+	Thing curThing = _vm->_groupMan->groupGetThing(mapX, mapY);
+	if (curThing != Thing::_endOfList)
+		_vm->_moveSens->getMoveResult(curThing, mapX, mapY, mapX, mapY);
+
+	curThing = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
+	Thing nextThing = curThing;
+	int16 thingsToMoveCount = 0;
+	while (curThing != Thing::_endOfList) {
+		if (curThing.getType() > k4_GroupThingType)
+			thingsToMoveCount++;
+
+		curThing = _vm->_dungeonMan->getNextThing(curThing);
 	}
-	L0645_T_Thing = L0648_T_NextThing;
-	while ((L0645_T_Thing != Thing::_endOfList) && L0649_i_ThingsToMoveCount) {
-		L0649_i_ThingsToMoveCount--;
-		L0648_T_NextThing = _vm->_dungeonMan->getNextThing(L0645_T_Thing);
-		AL0644_ui_ThingType = L0645_T_Thing.getType();
-		if (AL0644_ui_ThingType > k4_GroupThingType) {
-			_vm->_moveSens->getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY);
-		}
-		if (AL0644_ui_ThingType == k14_ProjectileThingType) {
-			L0646_ps_Projectile = (Projectile*)_vm->_dungeonMan->getThingData(L0645_T_Thing);
-			L0647_ps_Event = &_events[L0646_ps_Projectile->_eventIndex];
-			L0647_ps_Event->_C._projectile.setMapX(_vm->_moveSens->_moveResultMapX);
-			L0647_ps_Event->_C._projectile.setMapY(_vm->_moveSens->_moveResultMapY);
-			L0647_ps_Event->_C._projectile.setDir((Direction)_vm->_moveSens->_moveResultDir);
-			L0647_ps_Event->_B._slot = thingWithNewCell(L0645_T_Thing, _vm->_moveSens->_moveResultCell).toUint16();
-			M31_setMap(L0647_ps_Event->_mapTime, _vm->_moveSens->_moveResultMapIndex);
-		} else {
-			if (AL0644_ui_ThingType == k15_ExplosionThingType) {
-				for (AL0644_ui_EventIndex = 0, L0647_ps_Event = _events; AL0644_ui_EventIndex < _eventMaxCount; L0647_ps_Event++, AL0644_ui_EventIndex++) {
-					if ((L0647_ps_Event->_type == k25_TMEventTypeExplosion) && (L0647_ps_Event->_C._slot == L0645_T_Thing.toUint16())) { /* BUG0_23 A Fluxcage explosion remains on a square forever. If you open a pit or teleporter on a square where there is a Fluxcage explosion, the Fluxcage explosion is moved but the associated event is not updated (because Fluxcage explosions do not use k25_TMEventTypeExplosion but rather k24_TMEventTypeRemoveFluxcage) causing the Fluxcage explosion to remain in the dungeon forever on its destination square. When the k24_TMEventTypeRemoveFluxcage expires the explosion thing is not removed, but it is marked as unused. Consequently, any objects placed on the Fluxcage square after it was moved but before it expires become orphans upon expiration. After expiration, any object placed on the fluxcage square is cloned when picked up */
-						L0647_ps_Event->_B._location._mapX = _vm->_moveSens->_moveResultMapX;
-						L0647_ps_Event->_B._location._mapY = _vm->_moveSens->_moveResultMapY;
-						L0647_ps_Event->_C._slot = thingWithNewCell(L0645_T_Thing, _vm->_moveSens->_moveResultCell).toUint16();
-						M31_setMap(L0647_ps_Event->_mapTime, _vm->_moveSens->_moveResultMapIndex);
-					}
+	curThing = nextThing;
+	while ((curThing != Thing::_endOfList) && thingsToMoveCount) {
+		thingsToMoveCount--;
+		nextThing = _vm->_dungeonMan->getNextThing(curThing);
+		uint16 curThingType = curThing.getType();
+		if (curThingType > k4_GroupThingType)
+			_vm->_moveSens->getMoveResult(curThing, mapX, mapY, mapX, mapY);
+
+		if (curThingType == k14_ProjectileThingType) {
+			Projectile *projectile = (Projectile*)_vm->_dungeonMan->getThingData(curThing);
+			TimelineEvent* newEvent;
+			newEvent = &_events[projectile->_eventIndex];
+			newEvent->_C._projectile.setMapX(_vm->_moveSens->_moveResultMapX);
+			newEvent->_C._projectile.setMapY(_vm->_moveSens->_moveResultMapY);
+			newEvent->_C._projectile.setDir((Direction)_vm->_moveSens->_moveResultDir);
+			newEvent->_B._slot = thingWithNewCell(curThing, _vm->_moveSens->_moveResultCell).toUint16();
+			M31_setMap(newEvent->_mapTime, _vm->_moveSens->_moveResultMapIndex);
+		} else if (curThingType == k15_ExplosionThingType) {
+			TimelineEvent *newEvent = _events;
+			for (uint16 i = 0; i < _eventMaxCount; newEvent++, i++) {
+				if ((newEvent->_type == k25_TMEventTypeExplosion) && (newEvent->_C._slot == curThing.toUint16())) { /* BUG0_23 A Fluxcage explosion remains on a square forever. If you open a pit or teleporter on a square where there is a Fluxcage explosion, the Fluxcage explosion is moved but the associated event is not updated (because Fluxcage explosions do not use k25_TMEventTypeExplosion but rather k24_TMEventTypeRemoveFluxcage) causing the Fluxcage explosion to remain in the dungeon forever on its destination square. When the k24_TMEventTypeRemoveFluxcage expires the explosion thing is not removed, but it is marked as unused. Consequently, any objects placed on the Fluxcage square after it was moved but before it expires become orphans upon expiration. After expiration, any object placed on the fluxcage square is cloned when picked up */
+					newEvent->_B._location._mapX = _vm->_moveSens->_moveResultMapX;
+					newEvent->_B._location._mapY = _vm->_moveSens->_moveResultMapY;
+					newEvent->_C._slot = thingWithNewCell(curThing, _vm->_moveSens->_moveResultCell).toUint16();
+					M31_setMap(newEvent->_mapTime, _vm->_moveSens->_moveResultMapIndex);
 				}
 			}
 		}
-		L0645_T_Thing = L0648_T_NextThing;
+		curThing = nextThing;
 	}
 }
 
-void Timeline::processEventSquareTeleporter(TimelineEvent* event) {
-	uint16 L0650_ui_MapX;
-	uint16 L0651_ui_MapY;
-	byte* L0652_puc_Square;
+void Timeline::processEventSquareTeleporter(TimelineEvent *event) {
+	uint16 mapX = event->_B._location._mapX;
+	uint16 mapY = event->_B._location._mapY;
 
+	byte *curSquare = &_vm->_dungeonMan->_currMapData[mapX][mapY];
+	if (event->_C.A._effect == k2_SensorEffToggle)
+		event->_C.A._effect = getFlag(*curSquare, k0x0008_TeleporterOpen) ? k1_SensorEffClear : k0_SensorEffSet;
 
-	L0652_puc_Square = &_vm->_dungeonMan->_currMapData[L0650_ui_MapX = event->_B._location._mapX][L0651_ui_MapY = event->_B._location._mapY];
-	if (event->_C.A._effect == k2_SensorEffToggle) {
-		event->_C.A._effect = getFlag(*L0652_puc_Square, k0x0008_TeleporterOpen) ? k1_SensorEffClear : k0_SensorEffSet;
-	}
 	if (event->_C.A._effect == k0_SensorEffSet) {
-		setFlag(*L0652_puc_Square, k0x0008_TeleporterOpen);
-		moveTeleporterOrPitSquareThings(L0650_ui_MapX, L0651_ui_MapY);
-	} else {
-		clearFlag(*L0652_puc_Square, k0x0008_TeleporterOpen);
-	}
+		setFlag(*curSquare, k0x0008_TeleporterOpen);
+		moveTeleporterOrPitSquareThings(mapX, mapY);
+	} else
+		clearFlag(*curSquare, k0x0008_TeleporterOpen);
 }
 
-void Timeline::processEventSquareWall(TimelineEvent* event) {
-	Thing L0634_T_Thing;
-	int16 L0635_i_ThingType;
-	int16 L0636_i_Multiple;
-#define AL0636_B_TriggerSetEffect L0636_i_Multiple
-#define AL0636_i_BitMask          L0636_i_Multiple
-	uint16 L0637_ui_SensorData;
-	Sensor* L0638_ps_Sensor;
-	TextString* L0639_ps_TextString;
-	uint16 L0640_ui_SensorType;
-	int16 L0641_i_MapX;
-	int16 L0642_i_MapY;
-	uint16 L0643_ui_Cell;
-
-
-	L0634_T_Thing = _vm->_dungeonMan->getSquareFirstThing(L0641_i_MapX = event->_B._location._mapX, L0642_i_MapY = event->_B._location._mapY);
-	L0643_ui_Cell = event->_C.A._cell;
-	while (L0634_T_Thing != Thing::_endOfList) {
-		if (((L0635_i_ThingType = L0634_T_Thing.getType()) == k2_TextstringType) && (L0634_T_Thing.getCell() == event->_C.A._cell)) {
-			L0639_ps_TextString = (TextString*)_vm->_dungeonMan->getThingData(L0634_T_Thing);
-			if (event->_C.A._effect == k2_SensorEffToggle) {
-				L0639_ps_TextString->setVisible(!L0639_ps_TextString->isVisible());
-			} else {
-				L0639_ps_TextString->setVisible(event->_C.A._effect == k0_SensorEffSet);
-			}
-		} else {
-			if (L0635_i_ThingType == k3_SensorThingType) {
-				L0638_ps_Sensor = (Sensor*)_vm->_dungeonMan->getThingData(L0634_T_Thing);
-				L0640_ui_SensorType = L0638_ps_Sensor->getType();
-				L0637_ui_SensorData = L0638_ps_Sensor->getData();
-				if (L0640_ui_SensorType == k6_SensorWallCountdown) {
-					if (L0637_ui_SensorData > 0) {
-						if (event->_C.A._effect == k0_SensorEffSet) {
-							if (L0637_ui_SensorData < 511) {
-								L0637_ui_SensorData++;
-							}
-						} else {
-							L0637_ui_SensorData--;
-						}
-						L0638_ps_Sensor->setData(L0637_ui_SensorData);
-						if (L0638_ps_Sensor->getAttrEffectA() == k3_SensorEffHold) {
-							AL0636_B_TriggerSetEffect = ((L0637_ui_SensorData == 0) != L0638_ps_Sensor->getAttrRevertEffectA());
-							_vm->_moveSens->triggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
-						} else {
-							if (L0637_ui_SensorData == 0) {
-								_vm->_moveSens->triggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getAttrEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
-							}
-						}
-					}
-				} else {
-					if (L0640_ui_SensorType == k5_SensorWallAndOrGate) {
-						AL0636_i_BitMask = 1 << (event->_C.A._cell);
-						if (event->_C.A._effect == k2_SensorEffToggle) {
-							if (getFlag(L0637_ui_SensorData, AL0636_i_BitMask)) {
-								clearFlag(L0637_ui_SensorData, AL0636_i_BitMask);
-							} else {
-								setFlag(L0637_ui_SensorData, AL0636_i_BitMask);
-							}
-						} else {
-							if (event->_C.A._effect) {
-								clearFlag(L0637_ui_SensorData, AL0636_i_BitMask);
-							} else {
-								setFlag(L0637_ui_SensorData, AL0636_i_BitMask);
-							}
-						}
-						L0638_ps_Sensor->setData(L0637_ui_SensorData);
-						AL0636_B_TriggerSetEffect = (Sensor::getDataMask1(L0637_ui_SensorData) == Sensor::getDataMask2(L0637_ui_SensorData)) != L0638_ps_Sensor->getAttrRevertEffectA();
-						if (L0638_ps_Sensor->getAttrEffectA() == k3_SensorEffHold) {
-							_vm->_moveSens->triggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
-						} else {
-							if (AL0636_B_TriggerSetEffect) {
-								_vm->_moveSens->triggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getAttrEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell);
-							}
-						}
-					} else {
-						if ((((L0640_ui_SensorType >= k7_SensorWallSingleProjLauncherNewObj) && (L0640_ui_SensorType <= k10_SensorWallDoubleProjLauncherExplosion)) || (L0640_ui_SensorType == k14_SensorWallSingleProjLauncherSquareObj) || (L0640_ui_SensorType == k15_SensorWallDoubleProjLauncherSquareObj)) && (L0634_T_Thing.getCell() == event->_C.A._cell)) {
-							triggerProjectileLauncher(L0638_ps_Sensor, event);
-							if (L0638_ps_Sensor->getAttrOnlyOnce()) {
-								L0638_ps_Sensor->setTypeDisabled();
-							}
-						} else {
-							if (L0640_ui_SensorType == k18_SensorWallEndGame) {
-								_vm->delay(60 * L0638_ps_Sensor->getAttrValue());
-								_vm->_restartGameAllowed = false;
-								_vm->_gameWon = true;
-								_vm->endGame(true);
-							}
-						}
-					}
+void Timeline::processEventSquareWall(TimelineEvent *event) {
+	int16 mapX = event->_B._location._mapX;
+	int16 mapY = event->_B._location._mapY;
+	Thing curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+	uint16 curCell = event->_C.A._cell;
+	while (curThing != Thing::_endOfList) {
+		int16 curThingType = curThing.getType();
+		if ((curThingType == k2_TextstringType) && (curThing.getCell() == event->_C.A._cell)) {
+			TextString *textString = (TextString*)_vm->_dungeonMan->getThingData(curThing);
+			if (event->_C.A._effect == k2_SensorEffToggle)
+				textString->setVisible(!textString->isVisible());
+			else
+				textString->setVisible(event->_C.A._effect == k0_SensorEffSet);
+		} else if (curThingType == k3_SensorThingType) {
+			Sensor *curThingSensor = (Sensor*)_vm->_dungeonMan->getThingData(curThing);
+			uint16 curSensorType = curThingSensor->getType();
+			uint16 curSensorData = curThingSensor->getData();
+			if (curSensorType == k6_SensorWallCountdown) {
+				if (curSensorData > 0) {
+					if (event->_C.A._effect == k0_SensorEffSet) {
+						if (curSensorData < 511)
+							curSensorData++;
+					} else
+						curSensorData--;
+
+					curThingSensor->setData(curSensorData);
+					if (curThingSensor->getAttrEffectA() == k3_SensorEffHold) {
+						int16 triggerSetEffect = ((curSensorData == 0) != curThingSensor->getAttrRevertEffectA());
+						_vm->_moveSens->triggerEffect(curThingSensor, triggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, mapX, mapY, curCell);
+					} else if (curSensorData == 0)
+						_vm->_moveSens->triggerEffect(curThingSensor, curThingSensor->getAttrEffectA(), mapX, mapY, curCell);
 				}
+			} else if (curSensorType == k5_SensorWallAndOrGate) {
+				int16 bitMask = 1 << (event->_C.A._cell);
+				if (event->_C.A._effect == k2_SensorEffToggle) {
+					if (getFlag(curSensorData, bitMask))
+						clearFlag(curSensorData, bitMask);
+					else
+						setFlag(curSensorData, bitMask);
+				} else if (event->_C.A._effect)
+					clearFlag(curSensorData, bitMask);
+				else
+					setFlag(curSensorData, bitMask);
+	
+				curThingSensor->setData(curSensorData);
+				bool triggerSetEffect = (Sensor::getDataMask1(curSensorData) == Sensor::getDataMask2(curSensorData)) != curThingSensor->getAttrRevertEffectA();
+				if (curThingSensor->getAttrEffectA() == k3_SensorEffHold)
+					_vm->_moveSens->triggerEffect(curThingSensor, triggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, mapX, mapY, curCell);
+				else if (triggerSetEffect)
+					_vm->_moveSens->triggerEffect(curThingSensor, curThingSensor->getAttrEffectA(), mapX, mapY, curCell);
+			} else if ((((curSensorType >= k7_SensorWallSingleProjLauncherNewObj) && (curSensorType <= k10_SensorWallDoubleProjLauncherExplosion)) || (curSensorType == k14_SensorWallSingleProjLauncherSquareObj) || (curSensorType == k15_SensorWallDoubleProjLauncherSquareObj)) && (curThing.getCell() == event->_C.A._cell)) {
+				triggerProjectileLauncher(curThingSensor, event);
+				if (curThingSensor->getAttrOnlyOnce())
+					curThingSensor->setTypeDisabled();
+			} else if (curSensorType == k18_SensorWallEndGame) {
+				_vm->delay(60 * curThingSensor->getAttrValue());
+				_vm->_restartGameAllowed = false;
+				_vm->_gameWon = true;
+				_vm->endGame(true);
 			}
 		}
-		L0634_T_Thing = _vm->_dungeonMan->getNextThing(L0634_T_Thing);
+		curThing = _vm->_dungeonMan->getNextThing(curThing);
 	}
 	_vm->_moveSens->processRotationEffect();
 }


Commit: ebc0dbe8b8bca99c9dfa4858a61754126e989df2
    https://github.com/scummvm/scummvm/commit/ebc0dbe8b8bca99c9dfa4858a61754126e989df2
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-08T06:47:56+02:00

Commit Message:
DM: Check the style used for the pointers in Timeline, more renaming

Changed paths:
    engines/dm/timeline.cpp
    engines/dm/timeline.h



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index cfd6d7f..e8d8ee2 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -92,7 +92,7 @@ void Timeline::initConstants() {
 		_actionDefense[i] = actionDefense[i];
 }
 
-Timeline::Timeline(DMEngine* vm) : _vm(vm) {
+Timeline::Timeline(DMEngine *vm) : _vm(vm) {
 	_eventMaxCount = 0;
 	_events = nullptr;
 	_eventCount = 0;
@@ -309,8 +309,8 @@ void Timeline::processTimeline() {
 			case k24_TMEventTypeRemoveFluxcage:
 				if (!_vm->_gameWon) {
 					_vm->_dungeonMan->unlinkThingFromList(Thing(newEvent._C._slot), Thing(0), newEvent._B._location._mapX, newEvent._B._location._mapY);
-					curEvent = (TimelineEvent*)_vm->_dungeonMan->getThingData(Thing(newEvent._C._slot));
-					((Explosion*)curEvent)->setNextThing(Thing::_none);
+					curEvent = (TimelineEvent *)_vm->_dungeonMan->getThingData(Thing(newEvent._C._slot));
+					((Explosion *)curEvent)->setNextThing(Thing::_none);
 				}
 				break;
 			case k11_TMEventTypeEnableChampionAction:
@@ -382,7 +382,7 @@ void Timeline::extractFirstEvent(TimelineEvent *event) {
 void Timeline::processEventDoorAnimation(TimelineEvent *event) {
 	uint16 mapX = event->_B._location._mapX;
 	uint16 mapY = event->_B._location._mapY;
-	Square *curSquare = (Square*)&_vm->_dungeonMan->_currMapData[mapX][mapY];
+	Square *curSquare = (Square *)&_vm->_dungeonMan->_currMapData[mapX][mapY];
 	int16 doorState = Square(*curSquare).getDoorState();
 	if (doorState == k5_doorState_DESTROYED)
 		return;
@@ -412,7 +412,7 @@ void Timeline::processEventDoorAnimation(TimelineEvent *event) {
 		uint16 creatureAttributes = _vm->_dungeonMan->getCreatureAttributes(groupThing);
 		if ((groupThing != Thing::_endOfList) && !getFlag(creatureAttributes, k0x0040_MaskCreatureInfo_nonMaterial)) {
 			if (doorState >= (verticalDoorFl ? CreatureInfo::getHeight(creatureAttributes) : 1)) { /* Creature height or 1 */
-				if (_vm->_groupMan->getDamageAllCreaturesOutcome((Group*)_vm->_dungeonMan->getThingData(groupThing), mapX, mapY, 5, true) != k2_outcomeKilledAllCreaturesInGroup)
+				if (_vm->_groupMan->getDamageAllCreaturesOutcome((Group *)_vm->_dungeonMan->getThingData(groupThing), mapX, mapY, 5, true) != k2_outcomeKilledAllCreaturesInGroup)
 					_vm->_groupMan->processEvents29to41(mapX, mapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
 
 				doorState = (doorState == k0_doorState_OPEN) ? k0_doorState_OPEN : (doorState - 1);
@@ -468,7 +468,7 @@ void Timeline::processEventSquareFakewall(TimelineEvent *event) {
 }
 
 void Timeline::processEventDoorDestruction(TimelineEvent *event) {
-	Square *square = (Square*)&_vm->_dungeonMan->_currMapData[event->_B._location._mapX][event->_B._location._mapY];
+	Square *square = (Square *)&_vm->_dungeonMan->_currMapData[event->_B._location._mapX][event->_B._location._mapY];
 	square->setDoorState(k5_doorState_DESTROYED);
 }
 
@@ -531,8 +531,8 @@ void Timeline::moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) {
 			_vm->_moveSens->getMoveResult(curThing, mapX, mapY, mapX, mapY);
 
 		if (curThingType == k14_ProjectileThingType) {
-			Projectile *projectile = (Projectile*)_vm->_dungeonMan->getThingData(curThing);
-			TimelineEvent* newEvent;
+			Projectile *projectile = (Projectile *)_vm->_dungeonMan->getThingData(curThing);
+			TimelineEvent *newEvent;
 			newEvent = &_events[projectile->_eventIndex];
 			newEvent->_C._projectile.setMapX(_vm->_moveSens->_moveResultMapX);
 			newEvent->_C._projectile.setMapY(_vm->_moveSens->_moveResultMapY);
@@ -577,13 +577,13 @@ void Timeline::processEventSquareWall(TimelineEvent *event) {
 	while (curThing != Thing::_endOfList) {
 		int16 curThingType = curThing.getType();
 		if ((curThingType == k2_TextstringType) && (curThing.getCell() == event->_C.A._cell)) {
-			TextString *textString = (TextString*)_vm->_dungeonMan->getThingData(curThing);
+			TextString *textString = (TextString *)_vm->_dungeonMan->getThingData(curThing);
 			if (event->_C.A._effect == k2_SensorEffToggle)
 				textString->setVisible(!textString->isVisible());
 			else
 				textString->setVisible(event->_C.A._effect == k0_SensorEffSet);
 		} else if (curThingType == k3_SensorThingType) {
-			Sensor *curThingSensor = (Sensor*)_vm->_dungeonMan->getThingData(curThing);
+			Sensor *curThingSensor = (Sensor *)_vm->_dungeonMan->getThingData(curThing);
 			uint16 curSensorType = curThingSensor->getType();
 			uint16 curSensorData = curThingSensor->getData();
 			if (curSensorType == k6_SensorWallCountdown) {
@@ -635,192 +635,161 @@ void Timeline::processEventSquareWall(TimelineEvent *event) {
 	_vm->_moveSens->processRotationEffect();
 }
 
-void Timeline::triggerProjectileLauncher(Sensor* sensor, TimelineEvent* event) {
-	Thing L0622_T_FirstProjectileAssociatedThing;
-	Thing L0623_T_SecondProjectileAssociatedThing;
-	uint16 L0624_ui_Cell;
-	int16 L0625_i_SensorType;
-	int16 L0626_i_MapX;
-	int16 L0627_i_MapY;
-	uint16 L0628_ui_ProjectileCell;
-	int16 L0629_i_SensorData;
-	int16 L0630_i_KineticEnergy;
-	int16 L0631_i_StepEnergy;
-	bool L0632_B_LaunchSingleProjectile;
-	uint16 L0633_ui_ThingCell;
-
-
-	L0626_i_MapX = event->_B._location._mapX;
-	L0627_i_MapY = event->_B._location._mapY;
-	L0624_ui_Cell = event->_C.A._cell;
-	L0628_ui_ProjectileCell = returnOppositeDir((Direction)L0624_ui_Cell);
-	L0625_i_SensorType = sensor->getType();
-	L0629_i_SensorData = sensor->getData();
-	L0630_i_KineticEnergy = sensor->getActionKineticEnergy();
-	L0631_i_StepEnergy = sensor->getActionStepEnergy();
-	L0632_B_LaunchSingleProjectile = (L0625_i_SensorType == k7_SensorWallSingleProjLauncherNewObj) ||
-		(L0625_i_SensorType == k8_SensorWallSingleProjLauncherExplosion) ||
-		(L0625_i_SensorType == k14_SensorWallSingleProjLauncherSquareObj);
-	if ((L0625_i_SensorType == k8_SensorWallSingleProjLauncherExplosion) || (L0625_i_SensorType == k10_SensorWallDoubleProjLauncherExplosion)) {
-		L0622_T_FirstProjectileAssociatedThing = L0623_T_SecondProjectileAssociatedThing = Thing(L0629_i_SensorData + Thing::_firstExplosion.toUint16());
-	} else {
-		if ((L0625_i_SensorType == k14_SensorWallSingleProjLauncherSquareObj) || (L0625_i_SensorType == k15_SensorWallDoubleProjLauncherSquareObj)) {
-			L0622_T_FirstProjectileAssociatedThing = _vm->_dungeonMan->getSquareFirstThing(L0626_i_MapX, L0627_i_MapY);
-			while (L0622_T_FirstProjectileAssociatedThing != Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList. If there are no more objects on the square then this loop may return an undefined value, this can crash the game. In the original DM and CSB dungeons, the number of times that these sensors are triggered is always controlled to be equal to the number of available objects (with a countdown sensor or a number of once only sensors) */
-				L0633_ui_ThingCell = L0622_T_FirstProjectileAssociatedThing.getCell();
-				if ((L0622_T_FirstProjectileAssociatedThing.getType() > k3_SensorThingType) && ((L0633_ui_ThingCell == L0624_ui_Cell) || (L0633_ui_ThingCell == returnNextVal(L0624_ui_Cell))))
+void Timeline::triggerProjectileLauncher(Sensor *sensor, TimelineEvent *event) {
+	int16 mapX = event->_B._location._mapX;
+	int16 mapY = event->_B._location._mapY;
+	uint16 cell = event->_C.A._cell;
+	uint16 projectileCell = returnOppositeDir((Direction)cell);
+	int16 sensorType = sensor->getType();
+	int16 sensorData = sensor->getData();
+	int16 kineticEnergy = sensor->getActionKineticEnergy();
+	int16 stepEnergy = sensor->getActionStepEnergy();
+	bool launchSingleProjectile = (sensorType == k7_SensorWallSingleProjLauncherNewObj) ||
+		(sensorType == k8_SensorWallSingleProjLauncherExplosion) ||
+		(sensorType == k14_SensorWallSingleProjLauncherSquareObj);
+
+	Thing firstProjectileAssociatedThing;
+	Thing secondProjectileAssociatedThing;
+	if ((sensorType == k8_SensorWallSingleProjLauncherExplosion) || (sensorType == k10_SensorWallDoubleProjLauncherExplosion))
+		firstProjectileAssociatedThing = secondProjectileAssociatedThing = Thing(sensorData + Thing::_firstExplosion.toUint16());
+	else if ((sensorType == k14_SensorWallSingleProjLauncherSquareObj) || (sensorType == k15_SensorWallDoubleProjLauncherSquareObj)) {
+		firstProjectileAssociatedThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+		while (firstProjectileAssociatedThing != Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList. If there are no more objects on the square then this loop may return an undefined value, this can crash the game. In the original DM and CSB dungeons, the number of times that these sensors are triggered is always controlled to be equal to the number of available objects (with a countdown sensor or a number of once only sensors) */
+			uint16 projectiveThingCell = firstProjectileAssociatedThing.getCell();
+			if ((firstProjectileAssociatedThing.getType() > k3_SensorThingType) && ((projectiveThingCell == cell) || (projectiveThingCell == returnNextVal(cell))))
+				break;
+			firstProjectileAssociatedThing = _vm->_dungeonMan->getNextThing(firstProjectileAssociatedThing);
+		}
+		if (firstProjectileAssociatedThing == Thing::_none) /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList */
+			return;
+
+		_vm->_dungeonMan->unlinkThingFromList(firstProjectileAssociatedThing, Thing(0), mapX, mapY); /* The object is removed without triggering any sensor effects */
+		if (!launchSingleProjectile) {
+			secondProjectileAssociatedThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+			while (secondProjectileAssociatedThing != Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList. If there are no more objects on the square then this loop may return an undefined value, this can crash the game */
+				uint16 projectiveThingCell = secondProjectileAssociatedThing.getCell();
+				if ((secondProjectileAssociatedThing.getType() > k3_SensorThingType) && ((projectiveThingCell == cell) || (projectiveThingCell == returnNextVal(cell))))
 					break;
-				L0622_T_FirstProjectileAssociatedThing = _vm->_dungeonMan->getNextThing(L0622_T_FirstProjectileAssociatedThing);
-			}
-			if (L0622_T_FirstProjectileAssociatedThing == Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList */
-				return;
-			}
-			_vm->_dungeonMan->unlinkThingFromList(L0622_T_FirstProjectileAssociatedThing, Thing(0), L0626_i_MapX, L0627_i_MapY); /* The object is removed without triggering any sensor effects */
-			if (!L0632_B_LaunchSingleProjectile) {
-				L0623_T_SecondProjectileAssociatedThing = _vm->_dungeonMan->getSquareFirstThing(L0626_i_MapX, L0627_i_MapY);
-				while (L0623_T_SecondProjectileAssociatedThing != Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList. If there are no more objects on the square then this loop may return an undefined value, this can crash the game */
-					L0633_ui_ThingCell = L0623_T_SecondProjectileAssociatedThing.getCell();
-					if ((L0623_T_SecondProjectileAssociatedThing.getType() > k3_SensorThingType) && ((L0633_ui_ThingCell == L0624_ui_Cell) || (L0633_ui_ThingCell == returnNextVal(L0624_ui_Cell))))
-						break;
-					L0623_T_SecondProjectileAssociatedThing = _vm->_dungeonMan->getNextThing(L0623_T_SecondProjectileAssociatedThing);
-				}
-				if (L0623_T_SecondProjectileAssociatedThing == Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList */
-					L0632_B_LaunchSingleProjectile = true;
-				} else {
-					_vm->_dungeonMan->unlinkThingFromList(L0623_T_SecondProjectileAssociatedThing, Thing(0), L0626_i_MapX, L0627_i_MapY); /* The object is removed without triggering any sensor effects */
-				}
-			}
-		} else {
-			if ((L0622_T_FirstProjectileAssociatedThing = _vm->_dungeonMan->getObjForProjectileLaucherOrObjGen(L0629_i_SensorData)) == Thing::_none) {
-				return;
-			}
-			if (!L0632_B_LaunchSingleProjectile && ((L0623_T_SecondProjectileAssociatedThing = _vm->_dungeonMan->getObjForProjectileLaucherOrObjGen(L0629_i_SensorData)) == Thing::_none)) {
-				L0632_B_LaunchSingleProjectile = true;
+				secondProjectileAssociatedThing = _vm->_dungeonMan->getNextThing(secondProjectileAssociatedThing);
 			}
+			if (secondProjectileAssociatedThing == Thing::_none) /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList */
+				launchSingleProjectile = true;
+			else
+				_vm->_dungeonMan->unlinkThingFromList(secondProjectileAssociatedThing, Thing::_none, mapX, mapY); /* The object is removed without triggering any sensor effects */
 		}
+	} else {
+		firstProjectileAssociatedThing = _vm->_dungeonMan->getObjForProjectileLaucherOrObjGen(sensorData);
+		if ((firstProjectileAssociatedThing) == Thing::_none)
+			return;
+
+		secondProjectileAssociatedThing = _vm->_dungeonMan->getObjForProjectileLaucherOrObjGen(sensorData);
+		if (!launchSingleProjectile && (secondProjectileAssociatedThing == Thing::_none))
+			launchSingleProjectile = true;
 	}
-	if (L0632_B_LaunchSingleProjectile) {
-		L0628_ui_ProjectileCell = normalizeModulo4(L0628_ui_ProjectileCell + _vm->getRandomNumber(2));
-	}
-	L0626_i_MapX += _vm->_dirIntoStepCountEast[L0624_ui_Cell], L0627_i_MapY += _vm->_dirIntoStepCountNorth[L0624_ui_Cell]; /* BUG0_20 The game crashes if the launcher sensor is on a map boundary and shoots in a direction outside the map */
+	if (launchSingleProjectile)
+		projectileCell = normalizeModulo4(projectileCell + _vm->getRandomNumber(2));
+
+	/* BUG0_20 The game crashes if the launcher sensor is on a map boundary and shoots in a direction outside the map */
+	mapX += _vm->_dirIntoStepCountEast[cell];
+	mapY += _vm->_dirIntoStepCountNorth[cell];
 	_vm->_projexpl->_createLauncherProjectile = true;
-	_vm->_projexpl->createProjectile(L0622_T_FirstProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, L0628_ui_ProjectileCell, (Direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy);
-	if (!L0632_B_LaunchSingleProjectile) {
-		_vm->_projexpl->createProjectile(L0623_T_SecondProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, returnNextVal(L0628_ui_ProjectileCell), (Direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy);
-	}
+	_vm->_projexpl->createProjectile(firstProjectileAssociatedThing, mapX, mapY, projectileCell, (Direction)cell, kineticEnergy, 100, stepEnergy);
+	if (!launchSingleProjectile)
+		_vm->_projexpl->createProjectile(secondProjectileAssociatedThing, mapX, mapY, returnNextVal(projectileCell), (Direction)cell, kineticEnergy, 100, stepEnergy);
+
 	_vm->_projexpl->_createLauncherProjectile = false;
 }
 
-void Timeline::processEventSquareCorridor(TimelineEvent* event) {
-#define k0x0008_randomizeGeneratedCreatureCount 0x0008 // @ MASK0x0008_RANDOMIZE_GENERATED_CREATURE_COUNT
-#define k0x0007_generatedCreatureCount 0x0007	// @ MASK0x0007_GENERATED_CREATURE_COUNT
-
-	int16 L0610_i_ThingType;
-	bool L0611_B_TextCurrentlyVisible;
-	int16 L0612_i_CreatureCount;
-	Thing L0613_T_Thing;
-	Sensor* L0614_ps_Sensor;
-	TextString* L0615_ps_TextString;
-	uint16 L0616_ui_MapX;
-	uint16 L0617_ui_MapY;
-	uint16 L0618_ui_Multiple;
-#define AL0618_ui_HealthMultiplier L0618_ui_Multiple
-#define AL0618_ui_Ticks            L0618_ui_Multiple
-	TimelineEvent L0619_s_Event;
-
-
-	L0613_T_Thing = _vm->_dungeonMan->getSquareFirstThing(L0616_ui_MapX = event->_B._location._mapX, L0617_ui_MapY = event->_B._location._mapY);
-	while (L0613_T_Thing != Thing::_endOfList) {
-		if ((L0610_i_ThingType = L0613_T_Thing.getType()) == k2_TextstringType) {
-			L0615_ps_TextString = (TextString*)_vm->_dungeonMan->getThingData(L0613_T_Thing);
-			L0611_B_TextCurrentlyVisible = L0615_ps_TextString->isVisible();
-			if (event->_C.A._effect == k2_SensorEffToggle) {
-				L0615_ps_TextString->setVisible(!L0611_B_TextCurrentlyVisible);
-			} else {
-				L0615_ps_TextString->setVisible((event->_C.A._effect == k0_SensorEffSet));
-			}
-			if (!L0611_B_TextCurrentlyVisible && L0615_ps_TextString->isVisible() && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0616_ui_MapX == _vm->_dungeonMan->_partyMapX) && (L0617_ui_MapY == _vm->_dungeonMan->_partyMapY)) {
-				_vm->_dungeonMan->decodeText(_vm->_stringBuildBuffer, L0613_T_Thing, k1_TextTypeMessage);
+void Timeline::processEventSquareCorridor(TimelineEvent *event) {
+	uint16 mapX = event->_B._location._mapX;
+	uint16 mapY = event->_B._location._mapY;
+	Thing curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+	while (curThing != Thing::_endOfList) {
+		int16 curThingType = curThing.getType();
+		if (curThingType == k2_TextstringType) {
+			TextString *textString = (TextString *)_vm->_dungeonMan->getThingData(curThing);
+			bool textCurrentlyVisible = textString->isVisible();
+			if (event->_C.A._effect == k2_SensorEffToggle)
+				textString->setVisible(!textCurrentlyVisible);
+			else
+				textString->setVisible((event->_C.A._effect == k0_SensorEffSet));
+
+			if (!textCurrentlyVisible && textString->isVisible() && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY)) {
+				_vm->_dungeonMan->decodeText(_vm->_stringBuildBuffer, curThing, k1_TextTypeMessage);
 				_vm->_textMan->printMessage(k15_ColorWhite, _vm->_stringBuildBuffer);
 			}
-		} else {
-			if (L0610_i_ThingType == k3_SensorThingType) {
-				L0614_ps_Sensor = (Sensor*)_vm->_dungeonMan->getThingData(L0613_T_Thing);
-				if (L0614_ps_Sensor->getType() == k6_SensorFloorGroupGenerator) {
-					L0612_i_CreatureCount = L0614_ps_Sensor->getAttrValue();
-					if (getFlag(L0612_i_CreatureCount, k0x0008_randomizeGeneratedCreatureCount)) {
-						L0612_i_CreatureCount = _vm->getRandomNumber(getFlag(L0612_i_CreatureCount, k0x0007_generatedCreatureCount));
-					} else {
-						L0612_i_CreatureCount--;
-					}
-					AL0618_ui_HealthMultiplier = L0614_ps_Sensor->getActionHealthMultiplier();
-					if (AL0618_ui_HealthMultiplier == 0) {
-						AL0618_ui_HealthMultiplier = _vm->_dungeonMan->_currMap->_difficulty;
-					}
-					_vm->_groupMan->groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (Direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY);
-					if (L0614_ps_Sensor->getAttrAudibleA()) {
-						_vm->_sound->requestPlay(k17_soundBUZZ, L0616_ui_MapX, L0617_ui_MapY, k1_soundModePlayIfPrioritized);
-					}
-					if (L0614_ps_Sensor->getAttrOnlyOnce()) {
-						L0614_ps_Sensor->setTypeDisabled();
-					} else {
-						AL0618_ui_Ticks = L0614_ps_Sensor->getActionTicks();
-						if (AL0618_ui_Ticks != 0) {
-							L0614_ps_Sensor->setTypeDisabled();
-							if (AL0618_ui_Ticks > 127) {
-								AL0618_ui_Ticks = (AL0618_ui_Ticks - 126) << 6;
-							}
-							L0619_s_Event._type = k65_TMEventTypeEnableGroupGenerator;
-							setMapAndTime(L0619_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + AL0618_ui_Ticks);
-							L0619_s_Event._priority = 0;
-							L0619_s_Event._B._location._mapX = L0616_ui_MapX;
-							L0619_s_Event._B._location._mapY = L0617_ui_MapY;
-							L0619_s_Event._B._location._mapY = L0617_ui_MapY;
-							addEventGetEventIndex(&L0619_s_Event);
-						}
+		} else if (curThingType == k3_SensorThingType) {
+			Sensor *curSensor = (Sensor *)_vm->_dungeonMan->getThingData(curThing);
+			if (curSensor->getType() == k6_SensorFloorGroupGenerator) {
+				int16 creatureCount = curSensor->getAttrValue();
+				if (getFlag(creatureCount, k0x0008_randomizeGeneratedCreatureCount))
+					creatureCount = _vm->getRandomNumber(getFlag(creatureCount, k0x0007_generatedCreatureCount));
+				else
+					creatureCount--;
+
+				uint16 healthMultiplier = curSensor->getActionHealthMultiplier();
+				if (healthMultiplier == 0)
+					healthMultiplier = _vm->_dungeonMan->_currMap->_difficulty;
+
+				_vm->_groupMan->groupGetGenerated(curSensor->getData(), healthMultiplier, creatureCount, (Direction)_vm->getRandomNumber(4), mapX, mapY);
+				if (curSensor->getAttrAudibleA())
+					_vm->_sound->requestPlay(k17_soundBUZZ, mapX, mapY, k1_soundModePlayIfPrioritized);
+
+				if (curSensor->getAttrOnlyOnce())
+					curSensor->setTypeDisabled();
+				else {
+					uint16 actionTicks = curSensor->getActionTicks();
+					if (actionTicks != 0) {
+						curSensor->setTypeDisabled();
+						if (actionTicks > 127)
+							actionTicks = (actionTicks - 126) << 6;
+
+						TimelineEvent newEvent;
+						newEvent._type = k65_TMEventTypeEnableGroupGenerator;
+						setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + actionTicks);
+						newEvent._priority = 0;
+						newEvent._B._location._mapX = mapX;
+						newEvent._B._location._mapY = mapY;
+						newEvent._B._location._mapY = mapY;
+						addEventGetEventIndex(&newEvent);
 					}
 				}
 			}
 		}
-		L0613_T_Thing = _vm->_dungeonMan->getNextThing(L0613_T_Thing);
+		curThing = _vm->_dungeonMan->getNextThing(curThing);
 	}
 }
 
-void Timeline::processEventsMoveGroup(TimelineEvent* event) {
-	uint16 L0656_ui_MapX;
-	uint16 L0657_ui_MapY;
-	Group* L0658_ps_Group;
-	bool L0659_B_RandomDirectionMoveRetried;
+void Timeline::processEventsMoveGroup(TimelineEvent *event) {
+	bool randomDirectionMoveRetried = false;
+	uint16 mapX = event->_B._location._mapX;
+	uint16 mapY = event->_B._location._mapY;
 
-	L0659_B_RandomDirectionMoveRetried = false;
-	L0656_ui_MapX = event->_B._location._mapX;
-	L0657_ui_MapY = event->_B._location._mapY;
-	L0657_ui_MapY = event->_B._location._mapY;
 T0252001:
-	if (((_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex) || (L0656_ui_MapX != _vm->_dungeonMan->_partyMapX) || (L0657_ui_MapY != _vm->_dungeonMan->_partyMapY)) && (_vm->_groupMan->groupGetThing(L0656_ui_MapX, L0657_ui_MapY) == Thing::_endOfList)) { /* BUG0_24 Lord Chaos may teleport into one of the Black Flames and become invisible until the Black Flame is killed. In this case, _vm->_groupMan->f175_groupGetThing returns the Black Flame thing and the Lord Chaos thing is not moved into the dungeon until the Black Flame is killed */
-		if (event->_type == k61_TMEventTypeMoveGroupAudible) {
-			_vm->_sound->requestPlay(k17_soundBUZZ, L0656_ui_MapX, L0657_ui_MapY, k1_soundModePlayIfPrioritized);
-		}
-		_vm->_moveSens->getMoveResult(Thing(event->_C._slot), kM1_MapXNotOnASquare, 0, L0656_ui_MapX, L0657_ui_MapY);
+	if (((_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex) || (mapX != _vm->_dungeonMan->_partyMapX) || (mapY != _vm->_dungeonMan->_partyMapY)) && (_vm->_groupMan->groupGetThing(mapX, mapY) == Thing::_endOfList)) { /* BUG0_24 Lord Chaos may teleport into one of the Black Flames and become invisible until the Black Flame is killed. In this case, _vm->_groupMan->f175_groupGetThing returns the Black Flame thing and the Lord Chaos thing is not moved into the dungeon until the Black Flame is killed */
+		if (event->_type == k61_TMEventTypeMoveGroupAudible)
+			_vm->_sound->requestPlay(k17_soundBUZZ, mapX, mapY, k1_soundModePlayIfPrioritized);
+
+		_vm->_moveSens->getMoveResult(Thing(event->_C._slot), kM1_MapXNotOnASquare, 0, mapX, mapY);
 	} else {
-		if (!L0659_B_RandomDirectionMoveRetried) {
-			L0659_B_RandomDirectionMoveRetried = true;
-			L0658_ps_Group = (Group*)_vm->_dungeonMan->getThingData(Thing(event->_C._slot));
-			if ((L0658_ps_Group->_type == k23_CreatureTypeLordChaos) && !_vm->getRandomNumber(4)) {
+		if (!randomDirectionMoveRetried) {
+			randomDirectionMoveRetried = true;
+			Group *group = (Group *)_vm->_dungeonMan->getThingData(Thing(event->_C._slot));
+			if ((group->_type == k23_CreatureTypeLordChaos) && !_vm->getRandomNumber(4)) {
 				switch (_vm->getRandomNumber(4)) {
 				case 0:
-					L0656_ui_MapX--;
+					mapX--;
 					break;
 				case 1:
-					L0656_ui_MapX++;
+					mapX++;
 					break;
 				case 2:
-					L0657_ui_MapY--;
+					mapY--;
 					break;
 				case 3:
-					L0657_ui_MapY++;
+					mapY++;
 				}
-				if (_vm->_groupMan->isSquareACorridorTeleporterPitOrDoor(L0656_ui_MapX, L0657_ui_MapY))
+				if (_vm->_groupMan->isSquareACorridorTeleporterPitOrDoor(mapX, mapY))
 					goto T0252001;
 			}
 		}
@@ -829,15 +798,15 @@ T0252001:
 	}
 }
 
-void Timeline::procesEventEnableGroupGenerator(TimelineEvent* event) {
+void Timeline::procesEventEnableGroupGenerator(TimelineEvent *event) {
 	Thing L0620_T_Thing;
-	Sensor* L0621_ps_Sensor;
+	Sensor *L0621_ps_Sensor;
 
 	L0620_T_Thing = _vm->_dungeonMan->getSquareFirstThing(event->_B._location._mapX, event->_B._location._mapY);
 	L0620_T_Thing = _vm->_dungeonMan->getSquareFirstThing(event->_B._location._mapX, event->_B._location._mapY);
 	while (L0620_T_Thing != Thing::_none) {
 		if ((L0620_T_Thing.getType()) == k3_SensorThingType) {
-			L0621_ps_Sensor = (Sensor*)_vm->_dungeonMan->getThingData(L0620_T_Thing);
+			L0621_ps_Sensor = (Sensor *)_vm->_dungeonMan->getThingData(L0620_T_Thing);
 			if (L0621_ps_Sensor->getType() == k0_SensorDisabled) {
 				L0621_ps_Sensor->setDatAndTypeWithOr(k6_SensorFloorGroupGenerator);
 				return;
@@ -850,7 +819,7 @@ void Timeline::procesEventEnableGroupGenerator(TimelineEvent* event) {
 void Timeline::processEventEnableChampionAction(uint16 champIndex) {
 	int16 L0660_i_SlotIndex;
 	int16 L0661_i_QuiverSlotIndex;
-	Champion* L0662_ps_Champion;
+	Champion *L0662_ps_Champion;
 
 	L0662_ps_Champion = &_vm->_championMan->_champions[champIndex];
 	L0662_ps_Champion->_enableActionEventIndex = -1;
@@ -878,7 +847,7 @@ T0253002:
 
 void Timeline::processEventMoveWeaponFromQuiverToSlot(uint16 champIndex, uint16 slotIndex) {
 	uint16 L0677_ui_SlotIndex;
-	Champion* L0678_ps_Champion;
+	Champion *L0678_ps_Champion;
 
 	L0678_ps_Champion = &_vm->_championMan->_champions[champIndex];
 	if (L0678_ps_Champion->_slots[slotIndex] != Thing::_none) {
@@ -893,7 +862,7 @@ void Timeline::processEventMoveWeaponFromQuiverToSlot(uint16 champIndex, uint16
 	}
 }
 
-bool Timeline::hasWeaponMovedSlot(int16 champIndex, Champion* champ, uint16 sourceSlotIndex, int16 destSlotIndex) {
+bool Timeline::hasWeaponMovedSlot(int16 champIndex, Champion *champ, uint16 sourceSlotIndex, int16 destSlotIndex) {
 	if (Thing(champ->_slots[sourceSlotIndex]).getType() == k5_WeaponThingType) {
 		_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->getObjectRemovedFromSlot(champIndex, sourceSlotIndex),
 			(ChampionSlot)destSlotIndex);
@@ -903,7 +872,7 @@ bool Timeline::hasWeaponMovedSlot(int16 champIndex, Champion* champ, uint16 sour
 }
 
 void Timeline::processEventHideDamageReceived(uint16 champIndex) {
-	Champion* L0663_ps_Champion;
+	Champion *L0663_ps_Champion;
 
 
 	L0663_ps_Champion = &_vm->_championMan->_champions[champIndex];
@@ -921,7 +890,7 @@ void Timeline::processEventHideDamageReceived(uint16 champIndex) {
 	}
 }
 
-void Timeline::processEventLight(TimelineEvent* event) {
+void Timeline::processEventLight(TimelineEvent *event) {
 	int16 L0673_i_WeakerLightPower;
 	int16 L0674_i_Multiple;
 #define AL0674_i_LightPower  L0674_i_Multiple
@@ -964,12 +933,12 @@ void Timeline::refreshAllChampionStatusBoxes() {
 	_vm->_championMan->drawAllChampionStates();
 }
 
-void Timeline::processEventViAltarRebirth(TimelineEvent* event) {
+void Timeline::processEventViAltarRebirth(TimelineEvent *event) {
 	int16 L0664_i_MapX;
 	int16 L0665_i_MapY;
 	uint16 L0666_ui_Cell;
 	Thing L0667_T_Thing;
-	Junk* L0668_ps_Junk;
+	Junk *L0668_ps_Junk;
 	int16 L0669_i_IconIndex;
 	uint16 L0670_ui_Step;
 	uint16 L0671_ui_ChampionIndex;
@@ -995,7 +964,7 @@ T0255002:
 			if ((L0667_T_Thing.getCell() == L0666_ui_Cell) && (L0667_T_Thing.getType() == k10_JunkThingType)) {
 				L0669_i_IconIndex = _vm->_objectMan->getIconIndex(L0667_T_Thing);
 				if (L0669_i_IconIndex == k147_IconIndiceJunkChampionBones) {
-					L0668_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L0667_T_Thing);
+					L0668_ps_Junk = (Junk *)_vm->_dungeonMan->getThingData(L0667_T_Thing);
 					if (L0668_ps_Junk->getChargeCount() == L0671_ui_ChampionIndex) {
 						_vm->_dungeonMan->unlinkThingFromList(L0667_T_Thing, Thing(0), L0664_i_MapX, L0665_i_MapY); /* BUG0_25 When a champion dies, no bones object is created so it is not possible to bring the champion back to life at an altar of Vi. Each time a champion is brought back to life, the bones object is removed from the dungeon but it is not marked as unused and thus becomes an orphan. After a large number of champion deaths, all JUNK things are exhausted and the game cannot create any more. This also affects the creation of JUNK things dropped by some creatures when they die (Screamer, Rockpile, Magenta Worm, Pain Rat, Red Dragon) */
 						L0668_ps_Junk->setNextThing(Thing::_none);
@@ -1012,7 +981,7 @@ T0255002:
 	}
 }
 
-void Timeline::saveEventsPart(Common::OutSaveFile* file) {
+void Timeline::saveEventsPart(Common::OutSaveFile *file) {
 	for (uint16 i = 0; i < _eventMaxCount; ++i) {
 		TimelineEvent *event = &_events[i];
 		file->writeSint32BE(event->_mapTime);
@@ -1025,12 +994,12 @@ void Timeline::saveEventsPart(Common::OutSaveFile* file) {
 	}
 }
 
-void Timeline::saveTimelinePart(Common::OutSaveFile* file) {
+void Timeline::saveTimelinePart(Common::OutSaveFile *file) {
 	for (uint16 i = 0; i < _eventMaxCount; ++i)
 		file->writeUint16BE(_timeline[i]);
 }
 
-void Timeline::loadEventsPart(Common::InSaveFile* file) {
+void Timeline::loadEventsPart(Common::InSaveFile *file) {
 	for (uint16 i = 0; i < _eventMaxCount; ++i) {
 		TimelineEvent *event = &_events[i];
 		event->_mapTime = file->readSint32BE();
@@ -1043,7 +1012,7 @@ void Timeline::loadEventsPart(Common::InSaveFile* file) {
 	}
 }
 
-void Timeline::loadTimelinePart(Common::InSaveFile* file) {
+void Timeline::loadTimelinePart(Common::InSaveFile *file) {
 	for (uint16 i = 0; i < _eventMaxCount; ++i)
 		_timeline[i] = file->readUint16BE();
 }
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 3f87ae2..727ed14 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -34,7 +34,7 @@ namespace DM {
 	class Champion;
 	class Sensor;
 
-	/* Event types */
+/* Event types */
 enum TimelineEventType {
 /* Used when a creature in a group was damaged or killed by a Poison Cloud or by a closing door or if Lord Chaos is surrounded by = 3, Fluxcages */
 kM3_TMEventTypeCreateReactionEvent29DangerOnSquare = -3, // @ CM3_EVENT_CREATE_REACTION_EVENT_29_DANGER_ON_SQUARE 
@@ -95,6 +95,9 @@ k82_TMEventTypeMagicMap_C82 = 82, // @ C82_EVENT_MAGIC_MAP
 k83_TMEventTypeMagicMap_C83 = 83  // @ C83_EVENT_MAGIC_MAP    
 };
 
+#define k0x0007_generatedCreatureCount 0x0007	// @ MASK0x0007_GENERATED_CREATURE_COUNT
+#define k0x0008_randomizeGeneratedCreatureCount 0x0008 // @ MASK0x0008_RANDOMIZE_GENERATED_CREATURE_COUNT
+
 class TimelineEvent {
 public:
 	int32 _mapTime;
@@ -177,8 +180,7 @@ public:
 	void processEventsMoveGroup(TimelineEvent *event); // @ F0252_TIMELINE_ProcessEvents60to61_MoveGroup
 	void procesEventEnableGroupGenerator(TimelineEvent *event); // @ F0246_TIMELINE_ProcessEvent65_EnableGroupGenerator
 	void processEventEnableChampionAction(uint16 champIndex); // @ F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction
-	void processEventMoveWeaponFromQuiverToSlot(uint16 champIndex,
-																	 uint16 slotIndex);// @ F0259_TIMELINE_ProcessEvent11Part2_MoveWeaponFromQuiverToSlot
+	void processEventMoveWeaponFromQuiverToSlot(uint16 champIndex, uint16 slotIndex);// @ F0259_TIMELINE_ProcessEvent11Part2_MoveWeaponFromQuiverToSlot
 	bool hasWeaponMovedSlot(int16 champIndex, Champion *champ,
 										 uint16 sourceSlotIndex, int16 destSlotIndex); // @ F0258_TIMELINE_HasWeaponMovedToSlot
 	void processEventHideDamageReceived(uint16 champIndex); // @ F0254_TIMELINE_ProcessEvent12_HideDamageReceived
@@ -187,8 +189,8 @@ public:
 	void processEventViAltarRebirth(TimelineEvent *event); // @ F0255_TIMELINE_ProcessEvent13_ViAltarRebirth
 	void saveEventsPart(Common::OutSaveFile *file);
 	void saveTimelinePart(Common::OutSaveFile *file);
-	void loadEventsPart(Common::InSaveFile* file);
-	void loadTimelinePart(Common::InSaveFile* file);
+	void loadEventsPart(Common::InSaveFile *file);
+	void loadTimelinePart(Common::InSaveFile *file);
 
 	signed char _actionDefense[44]; // @ G0495_ac_Graphic560_ActionDefense
 


Commit: 7654c89d4f420d4277b06698ec60ce289f2d3892
    https://github.com/scummvm/scummvm/commit/7654c89d4f420d4277b06698ec60ce289f2d3892
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-08T07:15:12+02:00

Commit Message:
DM: Finish refactoring pass in Timeline

Changed paths:
    engines/dm/timeline.cpp



diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index e8d8ee2..a69a0b2 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -488,16 +488,16 @@ void Timeline::processEventSquareDoor(TimelineEvent *event) {
 }
 
 void Timeline::processEventSquarePit(TimelineEvent *event) {
-	uint16 L0653_ui_MapX = event->_B._location._mapX;
-	uint16 L0654_ui_MapY = event->_B._location._mapY;
+	uint16 mapX = event->_B._location._mapX;
+	uint16 mapY = event->_B._location._mapY;
 
-	byte *square = &_vm->_dungeonMan->_currMapData[L0653_ui_MapX][L0654_ui_MapY];
+	byte *square = &_vm->_dungeonMan->_currMapData[mapX][mapY];
 	if (event->_C.A._effect == k2_SensorEffToggle)
 		event->_C.A._effect = getFlag(*square, k0x0008_PitOpen) ? k1_SensorEffClear : k0_SensorEffSet;
 
 	if (event->_C.A._effect == k0_SensorEffSet) {
 		setFlag(*square, k0x0008_PitOpen);
-		moveTeleporterOrPitSquareThings(L0653_ui_MapX, L0654_ui_MapY);
+		moveTeleporterOrPitSquareThings(mapX, mapY);
 	} else
 		clearFlag(*square, k0x0008_PitOpen);
 }
@@ -799,65 +799,55 @@ T0252001:
 }
 
 void Timeline::procesEventEnableGroupGenerator(TimelineEvent *event) {
-	Thing L0620_T_Thing;
-	Sensor *L0621_ps_Sensor;
-
-	L0620_T_Thing = _vm->_dungeonMan->getSquareFirstThing(event->_B._location._mapX, event->_B._location._mapY);
-	L0620_T_Thing = _vm->_dungeonMan->getSquareFirstThing(event->_B._location._mapX, event->_B._location._mapY);
-	while (L0620_T_Thing != Thing::_none) {
-		if ((L0620_T_Thing.getType()) == k3_SensorThingType) {
-			L0621_ps_Sensor = (Sensor *)_vm->_dungeonMan->getThingData(L0620_T_Thing);
-			if (L0621_ps_Sensor->getType() == k0_SensorDisabled) {
-				L0621_ps_Sensor->setDatAndTypeWithOr(k6_SensorFloorGroupGenerator);
+	Thing curThing = _vm->_dungeonMan->getSquareFirstThing(event->_B._location._mapX, event->_B._location._mapY);
+	while (curThing != Thing::_none) {
+		if ((curThing.getType()) == k3_SensorThingType) {
+			Sensor *curSensor = (Sensor *)_vm->_dungeonMan->getThingData(curThing);
+			if (curSensor->getType() == k0_SensorDisabled) {
+				curSensor->setDatAndTypeWithOr(k6_SensorFloorGroupGenerator);
 				return;
 			}
 		}
-		L0620_T_Thing = _vm->_dungeonMan->getNextThing(L0620_T_Thing);
+		curThing = _vm->_dungeonMan->getNextThing(curThing);
 	}
 }
 
 void Timeline::processEventEnableChampionAction(uint16 champIndex) {
-	int16 L0660_i_SlotIndex;
-	int16 L0661_i_QuiverSlotIndex;
-	Champion *L0662_ps_Champion;
-
-	L0662_ps_Champion = &_vm->_championMan->_champions[champIndex];
-	L0662_ps_Champion->_enableActionEventIndex = -1;
-	clearFlag(L0662_ps_Champion->_attributes, k0x0008_ChampionAttributeDisableAction);
-	if (L0662_ps_Champion->_actionIndex != k255_ChampionActionNone) {
-		L0662_ps_Champion->_actionDefense -= _actionDefense[L0662_ps_Champion->_actionDefense];
-	}
-	if (L0662_ps_Champion->_currHealth) {
-		if ((L0662_ps_Champion->_actionIndex == k32_ChampionActionShoot) && (L0662_ps_Champion->_slots[k0_ChampionSlotReadyHand] == Thing::_none)) {
-			if (_vm->_championMan->isAmmunitionCompatibleWithWeapon(champIndex, k1_ChampionSlotActionHand, L0660_i_SlotIndex = k12_ChampionSlotQuiverLine_1_1)) {
-T0253002:
-				_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->getObjectRemovedFromSlot(champIndex, L0660_i_SlotIndex), k0_ChampionSlotReadyHand);
-			} else {
-				for (L0661_i_QuiverSlotIndex = 0; L0661_i_QuiverSlotIndex < 3; L0661_i_QuiverSlotIndex++) {
-					if (_vm->_championMan->isAmmunitionCompatibleWithWeapon(champIndex, k1_ChampionSlotActionHand, L0660_i_SlotIndex = L0661_i_QuiverSlotIndex + k7_ChampionSlotQuiverLine_2_1))
-						goto T0253002;
+	Champion *curChampion = &_vm->_championMan->_champions[champIndex];
+	curChampion->_enableActionEventIndex = -1;
+	clearFlag(curChampion->_attributes, k0x0008_ChampionAttributeDisableAction);
+	if (curChampion->_actionIndex != k255_ChampionActionNone) {
+		curChampion->_actionDefense -= _actionDefense[curChampion->_actionDefense];
+	}
+	if (curChampion->_currHealth) {
+		if ((curChampion->_actionIndex == k32_ChampionActionShoot) && (curChampion->_slots[k0_ChampionSlotReadyHand] == Thing::_none)) {
+			int16 slotIndex = k12_ChampionSlotQuiverLine_1_1;
+			if (_vm->_championMan->isAmmunitionCompatibleWithWeapon(champIndex, k1_ChampionSlotActionHand, slotIndex))
+				_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->getObjectRemovedFromSlot(champIndex, slotIndex), k0_ChampionSlotReadyHand);
+			else {
+				for (int16 quiverSlotIndex = 0; quiverSlotIndex < 3; quiverSlotIndex++) {
+					slotIndex = quiverSlotIndex + k7_ChampionSlotQuiverLine_2_1;
+					if (_vm->_championMan->isAmmunitionCompatibleWithWeapon(champIndex, k1_ChampionSlotActionHand, slotIndex))
+						_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->getObjectRemovedFromSlot(champIndex, slotIndex), k0_ChampionSlotReadyHand);
 				}
 			}
 		}
-		setFlag(L0662_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand);
+		setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand);
 		_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	}
-	L0662_ps_Champion->_actionIndex = k255_ChampionActionNone;
+	curChampion->_actionIndex = k255_ChampionActionNone;
 }
 
 void Timeline::processEventMoveWeaponFromQuiverToSlot(uint16 champIndex, uint16 slotIndex) {
-	uint16 L0677_ui_SlotIndex;
-	Champion *L0678_ps_Champion;
-
-	L0678_ps_Champion = &_vm->_championMan->_champions[champIndex];
-	if (L0678_ps_Champion->_slots[slotIndex] != Thing::_none) {
+	Champion *curChampion = &_vm->_championMan->_champions[champIndex];
+	if (curChampion->_slots[slotIndex] != Thing::_none)
 		return;
-	}
-	if (hasWeaponMovedSlot(champIndex, L0678_ps_Champion, k12_ChampionSlotQuiverLine_1_1, slotIndex)) {
+
+	if (hasWeaponMovedSlot(champIndex, curChampion, k12_ChampionSlotQuiverLine_1_1, slotIndex))
 		return;
-	}
-	for (L0677_ui_SlotIndex = k7_ChampionSlotQuiverLine_2_1; L0677_ui_SlotIndex <= k9_ChampionSlotQuiverLine_2_2; L0677_ui_SlotIndex++) {
-		if (hasWeaponMovedSlot(champIndex, L0678_ps_Champion, L0677_ui_SlotIndex, slotIndex))
+
+	for (uint16 srcSlotIndex = k7_ChampionSlotQuiverLine_2_1; srcSlotIndex <= k9_ChampionSlotQuiverLine_2_2; srcSlotIndex++) {
+		if (hasWeaponMovedSlot(champIndex, curChampion, srcSlotIndex, slotIndex))
 			break;
 	}
 }
@@ -872,108 +862,86 @@ bool Timeline::hasWeaponMovedSlot(int16 champIndex, Champion *champ, uint16 sour
 }
 
 void Timeline::processEventHideDamageReceived(uint16 champIndex) {
-	Champion *L0663_ps_Champion;
-
-
-	L0663_ps_Champion = &_vm->_championMan->_champions[champIndex];
-	L0663_ps_Champion->_hideDamageReceivedIndex = -1;
-	if (!L0663_ps_Champion->_currHealth) {
+	Champion *curChampion = &_vm->_championMan->_champions[champIndex];
+	curChampion->_hideDamageReceivedIndex = -1;
+	if (!curChampion->_currHealth)
 		return;
-	}
+
 	if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) {
 		_vm->_eventMan->showMouse();
 		_vm->_inventoryMan->drawStatusBoxPortrait((ChampionIndex)champIndex);
 		_vm->_eventMan->hideMouse();
 	} else {
-		setFlag(L0663_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle);
+		setFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle);
 		_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	}
 }
 
 void Timeline::processEventLight(TimelineEvent *event) {
-	int16 L0673_i_WeakerLightPower;
-	int16 L0674_i_Multiple;
-#define AL0674_i_LightPower  L0674_i_Multiple
-#define AL0674_i_LightAmount L0674_i_Multiple
-	bool L0675_B_NegativeLightPower;
-	TimelineEvent L0676_s_Event;
-
-
-	if ((AL0674_i_LightPower = event->_B._lightPower) == 0) {
+	int16 lightPower = event->_B._lightPower;
+	if (lightPower == 0)
 		return;
-	}
 
-	L0675_B_NegativeLightPower = (AL0674_i_LightPower < 0);
-	if (L0675_B_NegativeLightPower) {
-		AL0674_i_LightPower = -AL0674_i_LightPower;
-	}
+	bool negativeLightPower = (lightPower < 0);
+	if (negativeLightPower)
+		lightPower = -lightPower;
 
-	L0673_i_WeakerLightPower = AL0674_i_LightPower - 1;
-	AL0674_i_LightAmount = _vm->_championMan->_lightPowerToLightAmount[AL0674_i_LightPower] - _vm->_championMan->_lightPowerToLightAmount[L0673_i_WeakerLightPower];
-	if (L0675_B_NegativeLightPower) {
-		AL0674_i_LightAmount = -AL0674_i_LightAmount;
-		L0673_i_WeakerLightPower = -L0673_i_WeakerLightPower;
+	int16 weakerLightPower = lightPower - 1;
+	int16 lightAmount = _vm->_championMan->_lightPowerToLightAmount[lightPower] - _vm->_championMan->_lightPowerToLightAmount[weakerLightPower];
+	if (negativeLightPower) {
+		lightAmount = -lightAmount;
+		weakerLightPower = -weakerLightPower;
 	}
-	_vm->_championMan->_party._magicalLightAmount += AL0674_i_LightAmount;
-	if (L0673_i_WeakerLightPower) {
-		L0676_s_Event._type = k70_TMEventTypeLight;
-		L0676_s_Event._B._lightPower = L0673_i_WeakerLightPower;
-		setMapAndTime(L0676_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + 4);
-		L0676_s_Event._priority = 0;
-		addEventGetEventIndex(&L0676_s_Event);
+	_vm->_championMan->_party._magicalLightAmount += lightAmount;
+	if (weakerLightPower) {
+		TimelineEvent newEvent;
+		newEvent._type = k70_TMEventTypeLight;
+		newEvent._B._lightPower = weakerLightPower;
+		setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + 4);
+		newEvent._priority = 0;
+		addEventGetEventIndex(&newEvent);
 	}
 }
 
 void Timeline::refreshAllChampionStatusBoxes() {
-	uint16 L0679_ui_ChampionIndex;
+	for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_partyChampionCount; idx++)
+		setFlag(_vm->_championMan->_champions[idx]._attributes, k0x1000_ChampionAttributeStatusBox);
 
-	for (L0679_ui_ChampionIndex = k0_ChampionFirst; L0679_ui_ChampionIndex < _vm->_championMan->_partyChampionCount; L0679_ui_ChampionIndex++) {
-		setFlag(_vm->_championMan->_champions[L0679_ui_ChampionIndex]._attributes, k0x1000_ChampionAttributeStatusBox);
-	}
 	_vm->_championMan->drawAllChampionStates();
 }
 
 void Timeline::processEventViAltarRebirth(TimelineEvent *event) {
-	int16 L0664_i_MapX;
-	int16 L0665_i_MapY;
-	uint16 L0666_ui_Cell;
-	Thing L0667_T_Thing;
-	Junk *L0668_ps_Junk;
-	int16 L0669_i_IconIndex;
-	uint16 L0670_ui_Step;
-	uint16 L0671_ui_ChampionIndex;
-
-
-	L0664_i_MapX = event->_B._location._mapX;
-	L0665_i_MapY = event->_B._location._mapY;
-	L0665_i_MapY = event->_B._location._mapY;
-	L0666_ui_Cell = event->_C.A._cell;
-	L0671_ui_ChampionIndex = event->_priority;
-	switch (L0670_ui_Step = event->_C.A._effect) { /* Rebirth is a 3 steps process (Step 2 -> Step 1 -> Step 0). Step is stored in the Effect value of the event */
+	int16 mapX = event->_B._location._mapX;
+	int16 mapY = event->_B._location._mapY;
+	uint16 cell = event->_C.A._cell;
+	uint16 championIndex = event->_priority;
+	uint16 rebirthStep = event->_C.A._effect;
+	switch (rebirthStep) { /* Rebirth is a 3 steps process (Step 2 -> Step 1 -> Step 0). Step is stored in the Effect value of the event */
 	case 2:
-		_vm->_projexpl->createExplosion(Thing::_explRebirthStep1, 0, L0664_i_MapX, L0665_i_MapY, L0666_ui_Cell);
+		_vm->_projexpl->createExplosion(Thing::_explRebirthStep1, 0, mapX, mapY, cell);
 		event->_mapTime += 5;
 T0255002:
-		L0670_ui_Step--;
-		event->_C.A._effect = L0670_ui_Step;
+		rebirthStep--;
+		event->_C.A._effect = rebirthStep;
 		addEventGetEventIndex(event);
 		break;
-	case 1:
-		L0667_T_Thing = _vm->_dungeonMan->getSquareFirstThing(L0664_i_MapX, L0665_i_MapY);
-		while (L0667_T_Thing != Thing::_endOfList) {
-			if ((L0667_T_Thing.getCell() == L0666_ui_Cell) && (L0667_T_Thing.getType() == k10_JunkThingType)) {
-				L0669_i_IconIndex = _vm->_objectMan->getIconIndex(L0667_T_Thing);
-				if (L0669_i_IconIndex == k147_IconIndiceJunkChampionBones) {
-					L0668_ps_Junk = (Junk *)_vm->_dungeonMan->getThingData(L0667_T_Thing);
-					if (L0668_ps_Junk->getChargeCount() == L0671_ui_ChampionIndex) {
-						_vm->_dungeonMan->unlinkThingFromList(L0667_T_Thing, Thing(0), L0664_i_MapX, L0665_i_MapY); /* BUG0_25 When a champion dies, no bones object is created so it is not possible to bring the champion back to life at an altar of Vi. Each time a champion is brought back to life, the bones object is removed from the dungeon but it is not marked as unused and thus becomes an orphan. After a large number of champion deaths, all JUNK things are exhausted and the game cannot create any more. This also affects the creation of JUNK things dropped by some creatures when they die (Screamer, Rockpile, Magenta Worm, Pain Rat, Red Dragon) */
-						L0668_ps_Junk->setNextThing(Thing::_none);
+	case 1: {
+		Thing curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+		while (curThing != Thing::_endOfList) {
+			if ((curThing.getCell() == cell) && (curThing.getType() == k10_JunkThingType)) {
+				int16 iconIndex = _vm->_objectMan->getIconIndex(curThing);
+				if (iconIndex == k147_IconIndiceJunkChampionBones) {
+					Junk *junkData = (Junk *)_vm->_dungeonMan->getThingData(curThing);
+					if (junkData->getChargeCount() == championIndex) {
+						_vm->_dungeonMan->unlinkThingFromList(curThing, Thing(0), mapX, mapY); /* BUG0_25 When a champion dies, no bones object is created so it is not possible to bring the champion back to life at an altar of Vi. Each time a champion is brought back to life, the bones object is removed from the dungeon but it is not marked as unused and thus becomes an orphan. After a large number of champion deaths, all JUNK things are exhausted and the game cannot create any more. This also affects the creation of JUNK things dropped by some creatures when they die (Screamer, Rockpile, Magenta Worm, Pain Rat, Red Dragon) */
+						junkData->setNextThing(Thing::_none);
 						event->_mapTime += 1;
 						goto T0255002;
 					}
 				}
 			}
-			L0667_T_Thing = _vm->_dungeonMan->getNextThing(L0667_T_Thing);
+			curThing = _vm->_dungeonMan->getNextThing(curThing);
+		}
 		}
 		break;
 	case 0:


Commit: b365338293ab1bbad4deef5f2979639f360d77db
    https://github.com/scummvm/scummvm/commit/b365338293ab1bbad4deef5f2979639f360d77db
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-09T01:09:25+02:00

Commit Message:
DM: Rename IconIndice enum

Changed paths:
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/dungeonman.cpp
    engines/dm/eventman.cpp
    engines/dm/gfx.cpp
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/objectman.cpp
    engines/dm/projexpl.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 36fbd4e..fe8f0fb 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -35,8 +35,8 @@
 
 namespace DM {
 
-#define k0x4000_IgnoreObjectModifiers 0x4000 // @ MASK0x4000_IGNORE_OBJECT_MODIFIERS     
-#define k0x8000_IgnoreTemporaryExperience 0x8000 // @ MASK0x8000_IGNORE_TEMPORARY_EXPERIENCE 
+#define kDMIgnoreObjectModifiers 0x4000 // @ MASK0x4000_IGNORE_OBJECT_MODIFIERS     
+#define kDMIgnoreTemporaryExperience 0x8000 // @ MASK0x8000_IGNORE_TEMPORARY_EXPERIENCE 
 
 class Scent {
 	uint16 _scent;
@@ -97,79 +97,79 @@ public:
 }; // @  PARTY
 
 enum IconIndice {
-	kM1_IconIndiceNone = -1, // @ CM1_ICON_NONE
-	k0_IconIndiceJunkCompassNorth = 0, // @ C000_ICON_JUNK_COMPASS_NORTH
-	k3_IconIndiceJunkCompassWest = 3, // @ C003_ICON_JUNK_COMPASS_WEST
-	k4_IconIndiceWeaponTorchUnlit = 4, // @ C004_ICON_WEAPON_TORCH_UNLIT
-	k7_IconIndiceWeaponTorchLit = 7, // @ C007_ICON_WEAPON_TORCH_LIT
-	k8_IconIndiceJunkWater = 8, // @ C008_ICON_JUNK_WATER
-	k9_IconIndiceJunkWaterSkin = 9, // @ C009_ICON_JUNK_WATERSKIN
-	k10_IconIndiceJunkJewelSymalUnequipped = 10, // @ C010_ICON_JUNK_JEWEL_SYMAL_UNEQUIPPED
-	k11_IconIndiceJunkJewelSymalEquipped = 11, // @ C011_ICON_JUNK_JEWEL_SYMAL_EQUIPPED
-	k12_IconIndiceJunkIllumuletUnequipped = 12, // @ C012_ICON_JUNK_ILLUMULET_UNEQUIPPED
-	k13_IconIndiceJunkIllumuletEquipped = 13, // @ C013_ICON_JUNK_ILLUMULET_EQUIPPED
-	k14_IconIndiceWeaponFlamittEmpty = 14, // @ C014_ICON_WEAPON_FLAMITT_EMPTY
-	k16_IconIndiceWeaponEyeOfTimeEmpty = 16, // @ C016_ICON_WEAPON_EYE_OF_TIME_EMPTY
-	k18_IconIndiceWeaponStormringEmpty = 18, // @ C018_ICON_WEAPON_STORMRING_EMPTY
-	k20_IconIndiceWeaponStaffOfClawsEmpty = 20, // @ C020_ICON_WEAPON_STAFF_OF_CLAWS_EMPTY
-	k22_IconIndiceWeaponStaffOfClawsFull = 22, // @ C022_ICON_WEAPON_STAFF_OF_CLAWS_FULL
-	k23_IconIndiceWeaponBoltBladeStormEmpty = 23, // @ C023_ICON_WEAPON_BOLT_BLADE_STORM_EMPTY
-	k25_IconIndiceWeaponFuryRaBladeEmpty = 25, // @ C025_ICON_WEAPON_FURY_RA_BLADE_EMPTY
-	k27_IconIndiceWeaponTheFirestaff = 27, // @ C027_ICON_WEAPON_THE_FIRESTAFF
-	k28_IconIndiceWeaponTheFirestaffComplete = 28, // @ C028_ICON_WEAPON_THE_FIRESTAFF_COMPLETE
-	k30_IconIndiceScrollOpen = 30, // @ C030_ICON_SCROLL_SCROLL_OPEN
-	k31_IconIndiceScrollClosed = 31, // @ C031_ICON_SCROLL_SCROLL_CLOSED
-	k32_IconIndiceWeaponDagger = 32, // @ C032_ICON_WEAPON_DAGGER
-	k38_IconIndiceWeaponDeltaSideSplitter = 38, // @ C038_ICON_WEAPON_DELTA_SIDE_SPLITTER
-	k39_IconIndiceWeaponDiamondEdge = 39, // @ C039_ICON_WEAPON_DIAMOND_EDGE
-	k40_IconIndiceWeaponVorpalBlade = 40, // @ C040_ICON_WEAPON_VORPAL_BLADE
-	k41_IconIndiceWeaponTheInquisitorDragonFang = 41, // @ C041_ICON_WEAPON_THE_INQUISITOR_DRAGON_FANG
-	k43_IconIndiceWeaponHardcleaveExecutioner = 43, // @ C043_ICON_WEAPON_HARDCLEAVE_EXECUTIONER
-	k45_IconIndiceWeaponMaceOfOrder = 45, // @ C045_ICON_WEAPON_MACE_OF_ORDER
-	k51_IconIndiceWeaponArrow = 51, // @ C051_ICON_WEAPON_ARROW
-	k52_IconIndiceWeaponSlayer = 52, // @ C052_ICON_WEAPON_SLAYER
-	k54_IconIndiceWeaponRock = 54, // @ C054_ICON_WEAPON_ROCK
-	k55_IconIndiceWeaponPoisonDart = 55, // @ C055_ICON_WEAPON_POISON_DART
-	k56_IconIndiceWeaponThrowingStar = 56, // @ C056_ICON_WEAPON_THROWING_STAR
-	k58_IconIndiceWeaponStaff = 58, // @ C058_ICON_WEAPON_STAFF
-	k59_IconIndiceWeaponWand = 59, // @ C059_ICON_WEAPON_WAND
-	k60_IconIndiceWeaponTeowand = 60, // @ C060_ICON_WEAPON_TEOWAND
-	k61_IconIndiceWeaponYewStaff = 61, // @ C061_ICON_WEAPON_YEW_STAFF
-	k62_IconIndiceWeaponStaffOfManarStaffOfIrra = 62, // @ C062_ICON_WEAPON_STAFF_OF_MANAR_STAFF_OF_IRRA
-	k63_IconIndiceWeaponSnakeStaffCrossOfNeta = 63, // @ C063_ICON_WEAPON_SNAKE_STAFF_CROSS_OF_NETA
-	k64_IconIndiceWeaponTheConduitSerpentStaff = 64, // @ C064_ICON_WEAPON_THE_CONDUIT_SERPENT_STAFF
-	k65_IconIndiceWeaponDragonSpit = 65, // @ C065_ICON_WEAPON_DRAGON_SPIT
-	k66_IconIndiceWeaponSceptreOfLyf = 66, // @ C066_ICON_WEAPON_SCEPTRE_OF_LYF
-	k81_IconIndiceArmourCloakOfNight = 81, // @ C081_ICON_ARMOUR_CLOAK_OF_NIGHT
-	k104_IconIndiceArmourCrownOfNerra = 104, // @ C104_ICON_ARMOUR_CROWN_OF_NERRA
-	k119_IconIndiceArmourElvenBoots = 119, // @ C119_ICON_ARMOUR_ELVEN_BOOTS
-	k120_IconIndiceJunkGemOfAges = 120, // @ C120_ICON_JUNK_GEM_OF_AGES
-	k121_IconIndiceJunkEkkhardCross = 121, // @ C121_ICON_JUNK_EKKHARD_CROSS
-	k122_IconIndiceJunkMoonstone = 122, // @ C122_ICON_JUNK_MOONSTONE
-	k124_IconIndiceJunkPendantFeral = 124, // @ C124_ICON_JUNK_PENDANT_FERAL
-	k128_IconIndiceJunkBoulder = 128, // @ C128_ICON_JUNK_BOULDER
-	k137_IconIndiceJunkRabbitsFoot = 137, // @ C137_ICON_JUNK_RABBITS_FOOT
-	k140_IconIndiceArmourDexhelm = 140, // @ C140_ICON_ARMOUR_DEXHELM
-	k141_IconIndiceArmourFlamebain = 141, // @ C141_ICON_ARMOUR_FLAMEBAIN
-	k142_IconIndiceArmourPowertowers = 142, // @ C142_ICON_ARMOUR_POWERTOWERS
-	k144_IconIndiceContainerChestClosed = 144, // @ C144_ICON_CONTAINER_CHEST_CLOSED
-	k145_IconIndiceContainerChestOpen = 145, // @ C145_ICON_CONTAINER_CHEST_OPEN
-	k147_IconIndiceJunkChampionBones = 147, // @ C147_ICON_JUNK_CHAMPION_BONES
-	k148_IconIndicePotionMaPotionMonPotion = 148, // @ C148_ICON_POTION_MA_POTION_MON_POTION
-	k163_IconIndicePotionWaterFlask = 163, // @ C163_ICON_POTION_WATER_FLASK
-	k168_IconIndiceJunkApple = 168, // @ C168_ICON_JUNK_APPLE
-	k176_IconIndiceJunkIronKey = 176, // @ C176_ICON_JUNK_IRON_KEY
-	k191_IconIndiceJunkMasterKey = 191, // @ C191_ICON_JUNK_MASTER_KEY
-	k194_IconIndiceArmourBootOfSpeed = 194, // @ C194_ICON_ARMOUR_BOOT_OF_SPEED
-	k195_IconIndicePotionEmptyFlask = 195, // @ C195_ICON_POTION_EMPTY_FLASK
-	k197_IconIndiceJunkZokathra = 197, // @ C197_ICON_JUNK_ZOKATHRA
-	k201_IconIndiceActionEmptyHand = 201, // @ C201_ICON_ACTION_ICON_EMPTY_HAND
-	k202_IconIndiceEyeNotLooking = 202, // @ C202_ICON_EYE_NOT_LOOKING /* One pixel is different in this bitmap from the eye in C017_GRAPHIC_INVENTORY. This is visible by selecting another champion after clicking the eye */
-	k203_IconIndiceEyeLooking = 203, // @ C203_ICON_EYE_LOOKING
-	k204_IconIndiceEmptyBox = 204, // @ C204_ICON_EMPTY_BOX
-	k205_IconIndiceMouthOpen = 205, // @ C205_ICON_MOUTH_OPEN
-	k208_IconIndiceNeck = 208, // @ C208_ICON_NECK
-	k212_IconIndiceReadyHand = 212 // @ C212_ICON_READY_HAND
+	kDMIconIndiceNone = -1, // @ CM1_ICON_NONE
+	kDMIconIndiceJunkCompassNorth = 0, // @ C000_ICON_JUNK_COMPASS_NORTH
+	kDMIconIndiceJunkCompassWest = 3, // @ C003_ICON_JUNK_COMPASS_WEST
+	kDMIconIndiceWeaponTorchUnlit = 4, // @ C004_ICON_WEAPON_TORCH_UNLIT
+	kDMIconIndiceWeaponTorchLit = 7, // @ C007_ICON_WEAPON_TORCH_LIT
+	kDMIconIndiceJunkWater = 8, // @ C008_ICON_JUNK_WATER
+	kDMIconIndiceJunkWaterSkin = 9, // @ C009_ICON_JUNK_WATERSKIN
+	kDMIconIndiceJunkJewelSymalUnequipped = 10, // @ C010_ICON_JUNK_JEWEL_SYMAL_UNEQUIPPED
+	kDMIconIndiceJunkJewelSymalEquipped = 11, // @ C011_ICON_JUNK_JEWEL_SYMAL_EQUIPPED
+	kDMIconIndiceJunkIllumuletUnequipped = 12, // @ C012_ICON_JUNK_ILLUMULET_UNEQUIPPED
+	kDMIconIndiceJunkIllumuletEquipped = 13, // @ C013_ICON_JUNK_ILLUMULET_EQUIPPED
+	kDMIconIndiceWeaponFlamittEmpty = 14, // @ C014_ICON_WEAPON_FLAMITT_EMPTY
+	kDMIconIndiceWeaponEyeOfTimeEmpty = 16, // @ C016_ICON_WEAPON_EYE_OF_TIME_EMPTY
+	kDMIconIndiceWeaponStormringEmpty = 18, // @ C018_ICON_WEAPON_STORMRING_EMPTY
+	kDMIconIndiceWeaponStaffOfClawsEmpty = 20, // @ C020_ICON_WEAPON_STAFF_OF_CLAWS_EMPTY
+	kDMIconIndiceWeaponStaffOfClawsFull = 22, // @ C022_ICON_WEAPON_STAFF_OF_CLAWS_FULL
+	kDMIconIndiceWeaponBoltBladeStormEmpty = 23, // @ C023_ICON_WEAPON_BOLT_BLADE_STORM_EMPTY
+	kDMIconIndiceWeaponFuryRaBladeEmpty = 25, // @ C025_ICON_WEAPON_FURY_RA_BLADE_EMPTY
+	kDMIconIndiceWeaponTheFirestaff = 27, // @ C027_ICON_WEAPON_THE_FIRESTAFF
+	kDMIconIndiceWeaponTheFirestaffComplete = 28, // @ C028_ICON_WEAPON_THE_FIRESTAFF_COMPLETE
+	kDMIconIndiceScrollOpen = 30, // @ C030_ICON_SCROLL_SCROLL_OPEN
+	kDMIconIndiceScrollClosed = 31, // @ C031_ICON_SCROLL_SCROLL_CLOSED
+	kDMIconIndiceWeaponDagger = 32, // @ C032_ICON_WEAPON_DAGGER
+	kDMIconIndiceWeaponDeltaSideSplitter = 38, // @ C038_ICON_WEAPON_DELTA_SIDE_SPLITTER
+	kDMIconIndiceWeaponDiamondEdge = 39, // @ C039_ICON_WEAPON_DIAMOND_EDGE
+	kDMIconIndiceWeaponVorpalBlade = 40, // @ C040_ICON_WEAPON_VORPAL_BLADE
+	kDMIconIndiceWeaponTheInquisitorDragonFang = 41, // @ C041_ICON_WEAPON_THE_INQUISITOR_DRAGON_FANG
+	kDMIconIndiceWeaponHardcleaveExecutioner = 43, // @ C043_ICON_WEAPON_HARDCLEAVE_EXECUTIONER
+	kDMIconIndiceWeaponMaceOfOrder = 45, // @ C045_ICON_WEAPON_MACE_OF_ORDER
+	kDMIconIndiceWeaponArrow = 51, // @ C051_ICON_WEAPON_ARROW
+	kDMIconIndiceWeaponSlayer = 52, // @ C052_ICON_WEAPON_SLAYER
+	kDMIconIndiceWeaponRock = 54, // @ C054_ICON_WEAPON_ROCK
+	kDMIconIndiceWeaponPoisonDart = 55, // @ C055_ICON_WEAPON_POISON_DART
+	kDMIconIndiceWeaponThrowingStar = 56, // @ C056_ICON_WEAPON_THROWING_STAR
+	kDMIconIndiceWeaponStaff = 58, // @ C058_ICON_WEAPON_STAFF
+	kDMIconIndiceWeaponWand = 59, // @ C059_ICON_WEAPON_WAND
+	kDMIconIndiceWeaponTeowand = 60, // @ C060_ICON_WEAPON_TEOWAND
+	kDMIconIndiceWeaponYewStaff = 61, // @ C061_ICON_WEAPON_YEW_STAFF
+	kDMIconIndiceWeaponStaffOfManarStaffOfIrra = 62, // @ C062_ICON_WEAPON_STAFF_OF_MANAR_STAFF_OF_IRRA
+	kDMIconIndiceWeaponSnakeStaffCrossOfNeta = 63, // @ C063_ICON_WEAPON_SNAKE_STAFF_CROSS_OF_NETA
+	kDMIconIndiceWeaponTheConduitSerpentStaff = 64, // @ C064_ICON_WEAPON_THE_CONDUIT_SERPENT_STAFF
+	kDMIconIndiceWeaponDragonSpit = 65, // @ C065_ICON_WEAPON_DRAGON_SPIT
+	kDMIconIndiceWeaponSceptreOfLyf = 66, // @ C066_ICON_WEAPON_SCEPTRE_OF_LYF
+	kDMIconIndiceArmourCloakOfNight = 81, // @ C081_ICON_ARMOUR_CLOAK_OF_NIGHT
+	kDMIconIndiceArmourCrownOfNerra = 104, // @ C104_ICON_ARMOUR_CROWN_OF_NERRA
+	kDMIconIndiceArmourElvenBoots = 119, // @ C119_ICON_ARMOUR_ELVEN_BOOTS
+	kDMIconIndiceJunkGemOfAges = 120, // @ C120_ICON_JUNK_GEM_OF_AGES
+	kDMIconIndiceJunkEkkhardCross = 121, // @ C121_ICON_JUNK_EKKHARD_CROSS
+	kDMIconIndiceJunkMoonstone = 122, // @ C122_ICON_JUNK_MOONSTONE
+	kDMIconIndiceJunkPendantFeral = 124, // @ C124_ICON_JUNK_PENDANT_FERAL
+	kDMIconIndiceJunkBoulder = 128, // @ C128_ICON_JUNK_BOULDER
+	kDMIconIndiceJunkRabbitsFoot = 137, // @ C137_ICON_JUNK_RABBITS_FOOT
+	kDMIconIndiceArmourDexhelm = 140, // @ C140_ICON_ARMOUR_DEXHELM
+	kDMIconIndiceArmourFlamebain = 141, // @ C141_ICON_ARMOUR_FLAMEBAIN
+	kDMIconIndiceArmourPowertowers = 142, // @ C142_ICON_ARMOUR_POWERTOWERS
+	kDMIconIndiceContainerChestClosed = 144, // @ C144_ICON_CONTAINER_CHEST_CLOSED
+	kDMIconIndiceContainerChestOpen = 145, // @ C145_ICON_CONTAINER_CHEST_OPEN
+	kDMIconIndiceJunkChampionBones = 147, // @ C147_ICON_JUNK_CHAMPION_BONES
+	kDMIconIndicePotionMaPotionMonPotion = 148, // @ C148_ICON_POTION_MA_POTION_MON_POTION
+	kDMIconIndicePotionWaterFlask = 163, // @ C163_ICON_POTION_WATER_FLASK
+	kDMIconIndiceJunkApple = 168, // @ C168_ICON_JUNK_APPLE
+	kDMIconIndiceJunkIronKey = 176, // @ C176_ICON_JUNK_IRON_KEY
+	kDMIconIndiceJunkMasterKey = 191, // @ C191_ICON_JUNK_MASTER_KEY
+	kDMIconIndiceArmourBootOfSpeed = 194, // @ C194_ICON_ARMOUR_BOOT_OF_SPEED
+	kDMIconIndicePotionEmptyFlask = 195, // @ C195_ICON_POTION_EMPTY_FLASK
+	kDMIconIndiceJunkZokathra = 197, // @ C197_ICON_JUNK_ZOKATHRA
+	kDMIconIndiceActionEmptyHand = 201, // @ C201_ICON_ACTION_ICON_EMPTY_HAND
+	kDMIconIndiceEyeNotLooking = 202, // @ C202_ICON_EYE_NOT_LOOKING /* One pixel is different in this bitmap from the eye in C017_GRAPHIC_INVENTORY. This is visible by selecting another champion after clicking the eye */
+	kDMIconIndiceEyeLooking = 203, // @ C203_ICON_EYE_LOOKING
+	kDMIconIndiceEmptyBox = 204, // @ C204_ICON_EMPTY_BOX
+	kDMIconIndiceMouthOpen = 205, // @ C205_ICON_MOUTH_OPEN
+	kDMIconIndiceNeck = 208, // @ C208_ICON_NECK
+	kDMIconIndiceReadyHand = 212 // @ C212_ICON_READY_HAND
 };
 
 enum ChampionIndex {
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 9d9e44a..443a39d 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -656,7 +656,7 @@ void DMEngine::endGame(bool doNotDrawCreditsOnly) {
 
 				_textMan->printEndGameString(textPosX, textPosY++, k9_ColorGold, curChampion->_title);
 				for (int16 idx = k0_ChampionSkillFighter; idx <= k3_ChampionSkillWizard; idx++) {
-					uint16 skillLevel = MIN<uint16>(16, _championMan->getSkillLevel(championIndex, idx | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience)));
+					uint16 skillLevel = MIN<uint16>(16, _championMan->getSkillLevel(championIndex, idx | (kDMIgnoreObjectModifiers | kDMIgnoreTemporaryExperience)));
 					if (skillLevel == 1)
 						continue;
 
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 1356120..5527e1e 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -1616,35 +1616,35 @@ int16 DungeonMan::getStairsExitDirection(int16 mapX, int16 mapY) {
 
 Thing DungeonMan::getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {
 	int16 thingType = k5_WeaponThingType;
-	if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit))
-		iconIndex = k4_IconIndiceWeaponTorchUnlit;
+	if ((iconIndex >= kDMIconIndiceWeaponTorchUnlit) && (iconIndex <= kDMIconIndiceWeaponTorchLit))
+		iconIndex = kDMIconIndiceWeaponTorchUnlit;
 
 	int16 junkType;
 
 	switch (iconIndex) {
-	case k54_IconIndiceWeaponRock:
+	case kDMIconIndiceWeaponRock:
 		junkType = k30_WeaponTypeRock;
 		break;
-	case k128_IconIndiceJunkBoulder:
+	case kDMIconIndiceJunkBoulder:
 		junkType = k25_JunkTypeBoulder;
 		thingType = k10_JunkThingType;
 		break;
-	case k51_IconIndiceWeaponArrow:
+	case kDMIconIndiceWeaponArrow:
 		junkType = k27_WeaponTypeArrow;
 		break;
-	case k52_IconIndiceWeaponSlayer:
+	case kDMIconIndiceWeaponSlayer:
 		junkType = k28_WeaponTypeSlayer;
 		break;
-	case k55_IconIndiceWeaponPoisonDart:
+	case kDMIconIndiceWeaponPoisonDart:
 		junkType = k31_WeaponTypePoisonDart;
 		break;
-	case k56_IconIndiceWeaponThrowingStar:
+	case kDMIconIndiceWeaponThrowingStar:
 		junkType = k32_WeaponTypeThrowingStar;
 		break;
-	case k32_IconIndiceWeaponDagger:
+	case kDMIconIndiceWeaponDagger:
 		junkType = k8_WeaponTypeDagger;
 		break;
-	case k4_IconIndiceWeaponTorchUnlit:
+	case kDMIconIndiceWeaponTorchUnlit:
 		junkType = k2_WeaponTypeTorch;
 		break;
 	default:
@@ -1657,7 +1657,7 @@ Thing DungeonMan::getObjForProjectileLaucherOrObjGen(uint16 iconIndex) {
 
 	Junk *junkPtr = (Junk *)getThingData(unusedThing);
 	junkPtr->setType(junkType); /* Also works for WEAPON in cases other than Boulder */
-	if ((iconIndex == k4_IconIndiceWeaponTorchUnlit) && ((Weapon *)junkPtr)->isLit()) /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */
+	if ((iconIndex == kDMIconIndiceWeaponTorchUnlit) && ((Weapon *)junkPtr)->isLit()) /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */
 		((Weapon *)junkPtr)->setChargeCount(15);
 
 	return unusedThing;
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index a4734ad..d2ee2f8 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1197,9 +1197,9 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 					if (_vm->_dungeonMan->_isFacingFountain) {
 						uint16 iconIdx = _vm->_objectMan->getIconIndex(thingHandObject);
 						uint16 weight = _vm->_dungeonMan->getObjectWeight(thingHandObject);
-						if ((iconIdx >= k8_IconIndiceJunkWater) && (iconIdx <= k9_IconIndiceJunkWaterSkin))
+						if ((iconIdx >= kDMIconIndiceJunkWater) && (iconIdx <= kDMIconIndiceJunkWaterSkin))
 							junkPtr->setChargeCount(3); /* Full */
-						else if (iconIdx == k195_IconIndicePotionEmptyFlask)
+						else if (iconIdx == kDMIconIndicePotionEmptyFlask)
 							((Potion*)junkPtr)->setType(k15_PotionTypeWaterFlask);
 						else {
 							commandProcessType80ClickInDungeonViewTouchFrontWall();
@@ -1356,7 +1356,7 @@ void EventManager::processType80_clickInDungeonView_grabLeaderHandObject(uint16
 	}
 
 	Thing topPileThing = _vm->_dungeonMan->_pileTopObject[viewCell];
-	if (_vm->_objectMan->getIconIndex(topPileThing) != kM1_IconIndiceNone) {
+	if (_vm->_objectMan->getIconIndex(topPileThing) != kDMIconIndiceNone) {
 		_vm->_moveSens->getMoveResult(topPileThing, mapX, mapY, kM1_MapXNotOnASquare, 0);
 		_vm->_championMan->putObjectInLeaderHand(topPileThing, true);
 	}
@@ -1380,7 +1380,7 @@ void EventManager::processType80_clickInDungeonViewDropLeaderHandObject(uint16 v
 	uint16 currCell = normalizeModulo4(_vm->_dungeonMan->_partyDir + viewCell);
 	Thing removedThing = _vm->_championMan->getObjectRemovedFromLeaderHand();
 	_vm->_moveSens->getMoveResult(thingWithNewCell(removedThing, currCell), kM1_MapXNotOnASquare, 0, mapX, mapY);
-	if (droppingIntoAnAlcove && _vm->_dungeonMan->_isFacingViAltar && (_vm->_objectMan->getIconIndex(removedThing) == k147_IconIndiceJunkChampionBones)) {
+	if (droppingIntoAnAlcove && _vm->_dungeonMan->_isFacingViAltar && (_vm->_objectMan->getIconIndex(removedThing) == kDMIconIndiceJunkChampionBones)) {
 		Junk *removedJunk = (Junk*)_vm->_dungeonMan->getThingData(removedThing);
 		TimelineEvent newEvent;
 		setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + 1);
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 25f60d4..56dacec 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -3309,8 +3309,8 @@ T0115077_DrawSecondHalfSquareCreature:
 			sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightSide;
 		} else {
 			useCreatureBackBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack) && (creatureDirectionDelta == 0);
-			useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, k0x0080_MaskActiveGroupIsAttacking) && getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack);
-			if (useCreatureAttackBitmap) {
+			useCreatureAttackBitmap = !useCreatureBackBitmap;
+			if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0080_MaskActiveGroupIsAttacking) && getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack)) {
 				useFlippedHorizontallyCreatureFrontImage = false;
 				sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthAttack;
 				sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightAttack;
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 160c97d..bb0bab1 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1820,9 +1820,9 @@ int16 GroupMan::getMeleeActionDamage(Champion *champ, int16 champIndex, Group *g
 		L0565_i_Damage += _vm->getRandomNumber((L0565_i_Damage >> 1) + 1);
 		L0565_i_Damage = ((long)L0565_i_Damage * (long)actionDamageFactor) >> 5;
 		L0568_i_Defense = _vm->getRandomNumber(32) + creatureInfo->_defense + doubledMapDifficulty;
-		if (actionHandObjectIconIndex == k39_IconIndiceWeaponDiamondEdge)
+		if (actionHandObjectIconIndex == kDMIconIndiceWeaponDiamondEdge)
 			L0568_i_Defense -= L0568_i_Defense >> 2;
-		else if (actionHandObjectIconIndex == k43_IconIndiceWeaponHardcleaveExecutioner)
+		else if (actionHandObjectIconIndex == kDMIconIndiceWeaponHardcleaveExecutioner)
 			L0568_i_Defense -= L0568_i_Defense >> 3;
 
 		L0565_i_Damage += _vm->getRandomNumber(32) - L0568_i_Defense;
@@ -1847,7 +1847,7 @@ T0231009:
 		L0565_i_Damage += _vm->getRandomNumber(L0565_i_Damage);
 		L0565_i_Damage >>= 2;
 		L0565_i_Damage += _vm->getRandomNumber(4) + 1;
-		if ((actionHandObjectIconIndex == k40_IconIndiceWeaponVorpalBlade)
+		if ((actionHandObjectIconIndex == kDMIconIndiceWeaponVorpalBlade)
 			&& !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)
 			&& !(L0565_i_Damage >>= 1))
 			goto T0231015;
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index efe1e04..9435a8b 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -364,7 +364,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container *chest, bool is
 
 	_openChest = thingToOpen;
 	if (!isPressingEye) {
-		objMan.drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen);
+		objMan.drawIconInSlotBox(k9_SlotBoxInventoryActionHand, kDMIconIndiceContainerChestOpen);
 	}
 	dispMan.blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k25_PanelOpenChestIndice),
 							   _boxPanel, k72_byteWidth, k8_ColorRed, 73);
@@ -380,7 +380,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container *chest, bool is
 		thing = _vm->_dungeonMan->getNextThing(thing);
 	}
 	while (chestSlotIndex < 8) {
-		objMan.drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, kM1_IconIndiceNone);
+		objMan.drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, kDMIconIndiceNone);
 		_chestSlots[chestSlotIndex++] = Thing::_none;
 	}
 }
@@ -501,7 +501,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 
 		Common::String descString;
 		Common::String str;
-		if (iconIndex == k147_IconIndiceJunkChampionBones) {
+		if (iconIndex == kDMIconIndiceJunkChampionBones) {
 			switch (_vm->getGameLanguage()) { // localized
 			case Common::FR_FRA:
 				// Fix original bug dur to a cut&paste error: string was concatenated then overwritten by the name
@@ -514,7 +514,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 
 			descString = str;
 		} else if ((thingType == k8_PotionThingType)
-				   && (iconIndex != k163_IconIndicePotionWaterFlask)
+				   && (iconIndex != kDMIconIndicePotionWaterFlask)
 				   && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
 			str = ('_' + ((Potion *)rawThingPtr)->getPower() / 40);
 			str += " ";
@@ -537,8 +537,8 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			potentialAttribMask = k0x0008_DescriptionMaskCursed | k0x0002_DescriptionMaskPoisoned | k0x0004_DescriptionMaskBroken;
 			Weapon *weapon = (Weapon *)rawThingPtr;
 			actualAttribMask = (weapon->getCursed() << 3) | (weapon->getPoisoned() << 1) | (weapon->getBroken() << 2);
-			if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit)
-				&& (iconIndex <= k7_IconIndiceWeaponTorchLit)
+			if ((iconIndex >= kDMIconIndiceWeaponTorchUnlit)
+				&& (iconIndex <= kDMIconIndiceWeaponTorchLit)
 				&& (weapon->getChargeCount() == 0)) {
 
 				switch (_vm->getGameLanguage()) { // localized
@@ -569,7 +569,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			break;
 		}
 		case k10_JunkThingType: {
-			if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
+			if ((iconIndex >= kDMIconIndiceJunkWater) && (iconIndex <= kDMIconIndiceJunkWaterSkin)) {
 				potentialAttribMask = 0;
 				const char *descStringEN[4] = {"(EMPTY)", "(ALMOST EMPTY)", "(ALMOST FULL)", "(FULL)"};
 				const char *descStringDE[4] = {"(LEER)", "(FAST LEER)", "(FAST VOLL)", "(VOLL)"};
@@ -589,7 +589,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 				}
 
 				drawPanelObjectDescriptionString(descString.c_str());
-			} else if ((iconIndex >= k0_IconIndiceJunkCompassNorth) && (iconIndex <= k3_IconIndiceJunkCompassWest)) {
+			} else if ((iconIndex >= kDMIconIndiceJunkCompassNorth) && (iconIndex <= kDMIconIndiceJunkCompassWest)) {
 				const static char *directionNameEN[4] = {"NORTH", "EAST", "SOUTH", "WEST"};
 				const static char *directionNameDE[4] = {"NORDEN", "OSTEN", "SUEDEN", "WESTEN"};
 				const static char *directionNameFR[4] = {"AU NORD", "A L'EST", "AU SUD", "A L'OUEST"};
@@ -691,8 +691,8 @@ void InventoryMan::setDungeonViewPalette() {
 			uint16 slotIndex = k1_ChampionSlotActionHand + 1;
 			while (slotIndex--) {
 				Thing slotThing = curChampion->_slots[slotIndex];
-				if ((_vm->_objectMan->getObjectType(slotThing) >= k4_IconIndiceWeaponTorchUnlit) &&
-					(_vm->_objectMan->getObjectType(slotThing) <= k7_IconIndiceWeaponTorchLit)) {
+				if ((_vm->_objectMan->getObjectType(slotThing) >= kDMIconIndiceWeaponTorchUnlit) &&
+					(_vm->_objectMan->getObjectType(slotThing) <= kDMIconIndiceWeaponTorchLit)) {
 					Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->getThingData(slotThing);
 					*curTorchLightPower = curWeapon->getChargeCount();
 				} else {
@@ -759,7 +759,7 @@ void InventoryMan::decreaseTorchesLightPower() {
 		int16 slotIndex = k1_ChampionSlotActionHand + 1;
 		while (slotIndex--) {
 			int16 iconIndex = _vm->_objectMan->getIconIndex(curChampion->_slots[slotIndex]);
-			if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit)) {
+			if ((iconIndex >= kDMIconIndiceWeaponTorchUnlit) && (iconIndex <= kDMIconIndiceWeaponTorchLit)) {
 				Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->getThingData(curChampion->_slots[slotIndex]);
 				if (curWeapon->getChargeCount()) {
 					if (curWeapon->setChargeCount(curWeapon->getChargeCount() - 1) == 0) {
@@ -803,7 +803,7 @@ void InventoryMan::drawChampionSkillsAndStatistics() {
 	_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k20_PanelEmptyIndice), _boxPanel, k72_byteWidth, k8_ColorRed, 73);
 	int16 textPosY = 58;
 	for (uint16 idx = k0_ChampionSkillFighter; idx <= k3_ChampionSkillWizard; idx++) {
-		int16 skillLevel = MIN((uint16)16, _vm->_championMan->getSkillLevel(championIndex, idx | k0x8000_IgnoreTemporaryExperience));
+		int16 skillLevel = MIN((uint16)16, _vm->_championMan->getSkillLevel(championIndex, idx | kDMIgnoreTemporaryExperience));
 		if (skillLevel == 1)
 			continue;
 
@@ -851,7 +851,7 @@ void InventoryMan::drawStopPressingMouth() {
 }
 
 void InventoryMan::drawStopPressingEye() {
-	drawIconToViewport(k202_IconIndiceEyeNotLooking, 12, 13);
+	drawIconToViewport(kDMIconIndiceEyeNotLooking, 12, 13);
 	drawPanel();
 	_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 	Thing leaderHandObject = _vm->_championMan->_leaderHandObject;
@@ -908,7 +908,7 @@ void InventoryMan::clickOnMouth() {
 	Champion *curChampion = &_vm->_championMan->_champions[championIndex];
 	Junk *junkData = (Junk *)_vm->_dungeonMan->getThingData(handThing);
 	bool removeObjectFromLeaderHand;
-	if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
+	if ((iconIndex >= kDMIconIndiceJunkWater) && (iconIndex <= kDMIconIndiceJunkWaterSkin)) {
 		if (!(junkData->getChargeCount()))
 			return;
 
@@ -995,8 +995,8 @@ void InventoryMan::clickOnMouth() {
 			break;
 		}
 		((Potion *)junkData)->setType(k20_PotionTypeEmptyFlask);
-	} else if ((iconIndex >= k168_IconIndiceJunkApple) && (iconIndex < k176_IconIndiceJunkIronKey))
-		curChampion->_food = MIN(curChampion->_food + foodAmounts[iconIndex - k168_IconIndiceJunkApple], 2048);
+	} else if ((iconIndex >= kDMIconIndiceJunkApple) && (iconIndex < kDMIconIndiceJunkIronKey))
+		curChampion->_food = MIN(curChampion->_food + foodAmounts[iconIndex - kDMIconIndiceJunkApple], 2048);
 
 	if (curChampion->_currStamina > curChampion->_maxStamina)
 		curChampion->_currStamina = curChampion->_maxStamina;
@@ -1006,7 +1006,7 @@ void InventoryMan::clickOnMouth() {
 
 	if (removeObjectFromLeaderHand) {
 		for (uint16 i = 5; --i; _vm->delay(8)) { /* Animate mouth icon */
-			_vm->_objectMan->drawIconToScreen(k205_IconIndiceMouthOpen + !(i & 0x0001), 56, 46);
+			_vm->_objectMan->drawIconToScreen(kDMIconIndiceMouthOpen + !(i & 0x0001), 56, 46);
 			_vm->_eventMan->discardAllInput();
 			if (_vm->_engineShouldQuit)
 				return;
@@ -1059,7 +1059,7 @@ void InventoryMan::clickOnEye() {
 	_vm->_eventMan->hideMouse();
 	_vm->_eventMan->hideMouse();
 	_vm->delay(8);
-	drawIconToViewport(k203_IconIndiceEyeLooking, 12, 13);
+	drawIconToViewport(kDMIconIndiceEyeLooking, 12, 13);
 	if (_vm->_championMan->_leaderEmptyHanded)
 		drawChampionSkillsAndStatistics();
 	else {
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 2b331c9..81a341b 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -204,7 +204,7 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) {
 	Thing thing = champion.getSlot(k1_ChampionSlotActionHand);
 	IconIndice iconIndex;
 	if (thing == Thing::_none) {
-		iconIndex = k201_IconIndiceActionEmptyHand;
+		iconIndex = kDMIconIndiceActionEmptyHand;
 	} else if (_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
 		iconIndex = _vm->_objectMan->getIconIndex(thing);
 	} else {
@@ -787,7 +787,7 @@ void MenuMan::menusPrintSpellFailureMessage(Champion *champ, uint16 failureType,
 Potion *MenuMan::getEmptyFlaskInHand(Champion *champ, Thing *potionThing) {
 	for (int16 slotIndex = k2_ChampionSlotHead; --slotIndex >= k0_ChampionSlotReadyHand; ) {
 		Thing curThing = champ->_slots[slotIndex];
-		if ((curThing != Thing::_none) && (_vm->_objectMan->getIconIndex(curThing) == k195_IconIndicePotionEmptyFlask)) {
+		if ((curThing != Thing::_none) && (_vm->_objectMan->getIconIndex(curThing) == kDMIconIndicePotionEmptyFlask)) {
 			*potionThing = curThing;
 			return (Potion *)_vm->_dungeonMan->getThingData(curThing);
 		}
@@ -1488,7 +1488,7 @@ bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 ac
 
 		uint16 actionHitProbability = actionHitProbabilityArray[actionIndex];
 		uint16 actionDamageFactor = actionDamageFactorArray[actionIndex];
-		if ((_vm->_objectMan->getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
+		if ((_vm->_objectMan->getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == kDMIconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
 			setFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
 		}
 		_actionDamage = _vm->_groupMan->getMeleeActionDamage(champ, champIndex, (Group *)_vm->_dungeonMan->getThingData(_actionTargetGroupThing), _vm->ordinalToIndex(targetCreatureOrdinal), targetMapX, targetMapY, actionHitProbability, actionDamageFactor, skillIndex);
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index f76f675..7604479 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -704,7 +704,7 @@ void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing
 		objectType = _vm->_objectMan->getObjectType(thing);
 	} else {
 		thingType = kM1_PartyThingType;
-		objectType = kM1_IconIndiceNone;
+		objectType = kDMIconIndiceNone;
 	}
 
 	if ((!addThing) && (thingType != kM1_PartyThingType))
@@ -878,7 +878,7 @@ bool MovesensMan::isObjectInPartyPossession(int16 objectType) {
 				if (curObjectType == objectType)
 					return true;
 
-				if (curObjectType == k144_IconIndiceContainerChestClosed) {
+				if (curObjectType == kDMIconIndiceContainerChestClosed) {
 					Container *container = (Container *)_vm->_dungeonMan->getThingData(curThing);
 					curThing = container->getSlot();
 					while (curThing != Thing::_endOfList) {
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index bc8105c..7e403be 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -133,7 +133,7 @@ void ObjectMan::loadObjectNames() {
 
 IconIndice ObjectMan::getObjectType(Thing thing) {
 	if (thing == Thing::_none)
-		return kM1_IconIndiceNone;
+		return kDMIconIndiceNone;
 
 	int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing);
 	if (objectInfoIndex != -1)
@@ -146,35 +146,35 @@ IconIndice ObjectMan::getIconIndex(Thing thing) {
 	static byte chargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType
 
 	int16 iconIndex = getObjectType(thing);
-	if (iconIndex != kM1_IconIndiceNone) {
-		if (((iconIndex < k32_IconIndiceWeaponDagger) && (iconIndex >= k0_IconIndiceJunkCompassNorth)) ||
-			((iconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (iconIndex <= k163_IconIndicePotionWaterFlask)) ||
-			(iconIndex == k195_IconIndicePotionEmptyFlask)) {
+	if (iconIndex != kDMIconIndiceNone) {
+		if (((iconIndex < kDMIconIndiceWeaponDagger) && (iconIndex >= kDMIconIndiceJunkCompassNorth)) ||
+			((iconIndex >= kDMIconIndicePotionMaPotionMonPotion) && (iconIndex <= kDMIconIndicePotionWaterFlask)) ||
+			(iconIndex == kDMIconIndicePotionEmptyFlask)) {
 			Junk *junkThing = (Junk*)_vm->_dungeonMan->getThingData(thing);
 			switch (iconIndex) {
-			case k0_IconIndiceJunkCompassNorth:
+			case kDMIconIndiceJunkCompassNorth:
 				iconIndex += _vm->_dungeonMan->_partyDir;
 				break;
-			case k4_IconIndiceWeaponTorchUnlit:
+			case kDMIconIndiceWeaponTorchUnlit:
 				if (((Weapon*)junkThing)->isLit())
 					iconIndex += chargeCountToTorchType[((Weapon*)junkThing)->getChargeCount()];
 				break;
-			case k30_IconIndiceScrollOpen:
+			case kDMIconIndiceScrollOpen:
 				if (((Scroll*)junkThing)->getClosed())
 					iconIndex++;
 				break;
-			case k8_IconIndiceJunkWater:
-			case k12_IconIndiceJunkIllumuletUnequipped:
-			case k10_IconIndiceJunkJewelSymalUnequipped:
+			case kDMIconIndiceJunkWater:
+			case kDMIconIndiceJunkIllumuletUnequipped:
+			case kDMIconIndiceJunkJewelSymalUnequipped:
 				if (junkThing->getChargeCount())
 					iconIndex++;
 				break;
-			case k23_IconIndiceWeaponBoltBladeStormEmpty:
-			case k14_IconIndiceWeaponFlamittEmpty:
-			case k18_IconIndiceWeaponStormringEmpty:
-			case k25_IconIndiceWeaponFuryRaBladeEmpty:
-			case k16_IconIndiceWeaponEyeOfTimeEmpty:
-			case k20_IconIndiceWeaponStaffOfClawsEmpty:
+			case kDMIconIndiceWeaponBoltBladeStormEmpty:
+			case kDMIconIndiceWeaponFlamittEmpty:
+			case kDMIconIndiceWeaponStormringEmpty:
+			case kDMIconIndiceWeaponFuryRaBladeEmpty:
+			case kDMIconIndiceWeaponEyeOfTimeEmpty:
+			case kDMIconIndiceWeaponStaffOfClawsEmpty:
 				if (((Weapon*)junkThing)->getChargeCount())
 					iconIndex++;
 				break;
@@ -201,7 +201,7 @@ void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
 void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 	SlotBox *slotBox = &_slotBoxes[slotBoxIndex];
 	slotBox->_iconIndex = iconIndex;
-	if (slotBox->_iconIndex == kM1_IconIndiceNone)
+	if (slotBox->_iconIndex == kDMIconIndiceNone)
 		return;
 
 	Box blitBox;
@@ -237,7 +237,7 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
 void ObjectMan::drawLeaderObjectName(Thing thing) {
 	char *objectName = nullptr;
 	int16 iconIndex = getIconIndex(thing);
-	if (iconIndex == k147_IconIndiceJunkChampionBones) {
+	if (iconIndex == kDMIconIndiceJunkChampionBones) {
 		Junk *junk = (Junk*)_vm->_dungeonMan->getThingData(thing);
 		char champBonesName[16];
 
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 7c4bc53..15ccc52 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -138,8 +138,8 @@ bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, in
 				if ((projectileThingData->_attack > _vm->getRandomNumber(128))
 				&& getFlag(associatedAllowedSlots, k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors)
 				&& (   (projectileAssociatedThingType != k10_JunkThingType)
-					|| (iconIndex < k176_IconIndiceJunkIronKey)
-					|| (iconIndex > k191_IconIndiceJunkMasterKey)
+					|| (iconIndex < kDMIconIndiceJunkIronKey)
+					|| (iconIndex > kDMIconIndiceJunkMasterKey)
 					)) {
 					return false;
 				}
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index a69a0b2..9100f9b 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -930,7 +930,7 @@ T0255002:
 		while (curThing != Thing::_endOfList) {
 			if ((curThing.getCell() == cell) && (curThing.getType() == k10_JunkThingType)) {
 				int16 iconIndex = _vm->_objectMan->getIconIndex(curThing);
-				if (iconIndex == k147_IconIndiceJunkChampionBones) {
+				if (iconIndex == kDMIconIndiceJunkChampionBones) {
 					Junk *junkData = (Junk *)_vm->_dungeonMan->getThingData(curThing);
 					if (junkData->getChargeCount() == championIndex) {
 						_vm->_dungeonMan->unlinkThingFromList(curThing, Thing(0), mapX, mapY); /* BUG0_25 When a champion dies, no bones object is created so it is not possible to bring the champion back to life at an altar of Vi. Each time a champion is brought back to life, the bones object is removed from the dungeon but it is not marked as unused and thus becomes an orphan. After a large number of champion deaths, all JUNK things are exhausted and the game cannot create any more. This also affects the creation of JUNK things dropped by some creatures when they die (Screamer, Rockpile, Magenta Worm, Pain Rat, Red Dragon) */


Commit: 1b482a1e129b2bf00f49a9c4ef5c8d84470be1af
    https://github.com/scummvm/scummvm/commit/1b482a1e129b2bf00f49a9c4ef5c8d84470be1af
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-09T07:12:36+02:00

Commit Message:
DM: Rename enums ChampionIndex, ChampionAttribute, ChampionWound, ChampionStatisticType, ChampionStatisticValue

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/projexpl.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 6385547..f550e67 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -169,21 +169,21 @@ ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
 	_partyChampionCount = 0;
 	_partyDead = false;
 	_leaderHandObject = Thing(0);
-	_leaderIndex = kM1_ChampionNone;
+	_leaderIndex = kDMChampionNone;
 	_candidateChampionOrdinal = 0;
 	_partyIsSleeping = false;
 	_actingChampionOrdinal = 0;
 	_leaderHandObjectIconIndex = (IconIndice)0;
 	_leaderEmptyHanded = false;
 	_party.resetToZero();
-	_magicCasterChampionIndex = kM1_ChampionNone;
+	_magicCasterChampionIndex = kDMChampionNone;
 	_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
 
 	initConstants();
 }
 
 bool ChampionMan::isLeaderHandObjectThrown(int16 side) {
-	if (_leaderIndex == kM1_ChampionNone)
+	if (_leaderIndex == kDMChampionNone)
 		return false;
 
 	return isObjectThrown(_leaderIndex, kM1_ChampionSlotLeaderHand, side);
@@ -287,7 +287,7 @@ Common::String ChampionMan::getStringFromInteger(uint16 val, bool padding, uint1
 }
 
 void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing) {
-	int16 statIndex = k0_ChampionStatLuck;
+	int16 statIndex = kDMChampionStatLuck;
 	int16 modifier = 0;
 	ThingType thingType = thing.getType();
 
@@ -304,7 +304,7 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 		}
 
 		if (cursed) {
-			statIndex = k0_ChampionStatLuck;
+			statIndex = kDMChampionStatLuck;
 			modifier = -3;
 		}
 	}
@@ -312,53 +312,53 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 	if (!cursed) {
 		statIndex = (ChampionStatisticType)thingType; // variable sharing
 
-		if ((iconIndex == k137_IconIndiceJunkRabbitsFoot) && (slotIndex < k30_ChampionSlotChest_1)) {
-			statIndex = k0_ChampionStatLuck;
+		if ((iconIndex == kDMIconIndiceJunkRabbitsFoot) && (slotIndex < k30_ChampionSlotChest_1)) {
+			statIndex = kDMChampionStatLuck;
 			modifier = 10;
 		} else if (slotIndex == k1_ChampionSlotActionHand) {
-			if (iconIndex == k45_IconIndiceWeaponMaceOfOrder) {
-				statIndex = k1_ChampionStatStrength;
+			if (iconIndex == kDMIconIndiceWeaponMaceOfOrder) {
+				statIndex = kDMChampionStatStrength;
 				modifier = 5;
 			} else {
-				statIndex = k8_ChampionStatMana;
-				if ((iconIndex >= k20_IconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= k22_IconIndiceWeaponStaffOfClawsFull)) {
+				statIndex = kDMChampionStatMana;
+				if ((iconIndex >= kDMIconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= kDMIconIndiceWeaponStaffOfClawsFull)) {
 					modifier = 4;
 				} else {
 					switch (iconIndex) {
-					case k38_IconIndiceWeaponDeltaSideSplitter:
+					case kDMIconIndiceWeaponDeltaSideSplitter:
 						modifier = 1;
 						break;
-					case k41_IconIndiceWeaponTheInquisitorDragonFang:
+					case kDMIconIndiceWeaponTheInquisitorDragonFang:
 						modifier = 2;
 						break;
-					case k40_IconIndiceWeaponVorpalBlade:
+					case kDMIconIndiceWeaponVorpalBlade:
 						modifier = 4;
 						break;
-					case k58_IconIndiceWeaponStaff:
+					case kDMIconIndiceWeaponStaff:
 						modifier = 2;
 						break;
-					case k59_IconIndiceWeaponWand:
+					case kDMIconIndiceWeaponWand:
 						modifier = 1;
 						break;
-					case k60_IconIndiceWeaponTeowand:
+					case kDMIconIndiceWeaponTeowand:
 						modifier = 6;
 						break;
-					case k61_IconIndiceWeaponYewStaff:
+					case kDMIconIndiceWeaponYewStaff:
 						modifier = 4;
 						break;
-					case k62_IconIndiceWeaponStaffOfManarStaffOfIrra:
+					case kDMIconIndiceWeaponStaffOfManarStaffOfIrra:
 						modifier = 10;
 						break;
-					case k63_IconIndiceWeaponSnakeStaffCrossOfNeta:
+					case kDMIconIndiceWeaponSnakeStaffCrossOfNeta:
 						modifier = 8;
 						break;
-					case k64_IconIndiceWeaponTheConduitSerpentStaff:
+					case kDMIconIndiceWeaponTheConduitSerpentStaff:
 						modifier = 16;
 						break;
-					case k65_IconIndiceWeaponDragonSpit:
+					case kDMIconIndiceWeaponDragonSpit:
 						modifier = 7;
 						break;
-					case k66_IconIndiceWeaponSceptreOfLyf:
+					case kDMIconIndiceWeaponSceptreOfLyf:
 						modifier = 5;
 						break;
 					default:
@@ -367,18 +367,18 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 				}
 			}
 		} else if (slotIndex == k4_ChampionSlotLegs) {
-			if (iconIndex == k142_IconIndiceArmourPowertowers) {
-				statIndex = k1_ChampionStatStrength;
+			if (iconIndex == kDMIconIndiceArmourPowertowers) {
+				statIndex = kDMChampionStatStrength;
 				modifier = 10;
 			}
 		} else if (slotIndex == k2_ChampionSlotHead) {
 			switch (iconIndex) {
-			case k104_IconIndiceArmourCrownOfNerra:
-				statIndex = k3_ChampionStatWisdom;
+			case kDMIconIndiceArmourCrownOfNerra:
+				statIndex = kDMChampionStatWisdom;
 				modifier = 10;
 				break;
-			case k140_IconIndiceArmourDexhelm:
-				statIndex = k2_ChampionStatDexterity;
+			case kDMIconIndiceArmourDexhelm:
+				statIndex = kDMChampionStatDexterity;
 				modifier = 10;
 				break;
 			default:
@@ -386,12 +386,12 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 			}
 		} else if (slotIndex == k3_ChampionSlotTorso) {
 			switch (iconIndex) {
-			case k141_IconIndiceArmourFlamebain:
-				statIndex = k6_ChampionStatAntifire;
+			case kDMIconIndiceArmourFlamebain:
+				statIndex = kDMChampionStatAntifire;
 				modifier = 12;
 				break;
-			case k81_IconIndiceArmourCloakOfNight:
-				statIndex = k2_ChampionStatDexterity;
+			case kDMIconIndiceArmourCloakOfNight:
+				statIndex = kDMChampionStatDexterity;
 				modifier = 8;
 				break;
 			default:
@@ -399,17 +399,17 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 			}
 		} else if (slotIndex == k10_ChampionSlotNeck) {
 			switch (iconIndex) {
-			case k10_IconIndiceJunkJewelSymalUnequipped:
-			case k11_IconIndiceJunkJewelSymalEquipped:
-				statIndex = k5_ChampionStatAntimagic;
+			case kDMIconIndiceJunkJewelSymalUnequipped:
+			case kDMIconIndiceJunkJewelSymalEquipped:
+				statIndex = kDMChampionStatAntimagic;
 				modifier = 15;
 				break;
-			case k81_IconIndiceArmourCloakOfNight:
-				statIndex = k2_ChampionStatDexterity;
+			case kDMIconIndiceArmourCloakOfNight:
+				statIndex = kDMChampionStatDexterity;
 				modifier = 8;
 				break;
-			case k122_IconIndiceJunkMoonstone:
-				statIndex = k8_ChampionStatMana;
+			case kDMIconIndiceJunkMoonstone:
+				statIndex = kDMChampionStatMana;
 				modifier = 3;
 				break;
 			default:
@@ -421,10 +421,10 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 	if (modifier) {
 		modifier *= modifierFactor;
 		//statIndex is set when modifier is set
-		if (statIndex == k8_ChampionStatMana) {
+		if (statIndex == kDMChampionStatMana) {
 			champ->_maxMana += modifier;
-		} else if (statIndex < k6_ChampionStatAntifire + 1) {
-			for (uint16 statValIndex = k0_ChampionStatMaximum; statValIndex <= k2_ChampionStatMinimum; ++statValIndex) {
+		} else if (statIndex < kDMChampionStatAntifire + 1) {
+			for (uint16 statValIndex = kDMChampionStatMaximum; statValIndex <= kDMChampionStatMinimum; ++statValIndex) {
 				champ->getStatistic((ChampionStatisticType)statIndex, (ChampionStatisticValue)statValIndex) += modifier;
 			}
 		}
@@ -435,9 +435,9 @@ bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing)
 	ObjectMan &objMan = *_vm->_objectMan;
 
 	IconIndice currIconIndex = objMan.getIconIndexInSlotBox(slotBoxIndex);
-	if (((currIconIndex < k32_IconIndiceWeaponDagger) && (currIconIndex >= k0_IconIndiceJunkCompassNorth))
-		|| ((currIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (currIconIndex <= k163_IconIndicePotionWaterFlask))
-		|| (currIconIndex == k195_IconIndicePotionEmptyFlask)) {
+	if (((currIconIndex < kDMIconIndiceWeaponDagger) && (currIconIndex >= kDMIconIndiceJunkCompassNorth))
+		|| ((currIconIndex >= kDMIconIndicePotionMaPotionMonPotion) && (currIconIndex <= kDMIconIndicePotionWaterFlask))
+		|| (currIconIndex == kDMIconIndicePotionEmptyFlask)) {
 		IconIndice newIconIndex = objMan.getIconIndex(thing);
 		if (newIconIndex != currIconIndex) {
 			if ((slotBoxIndex < k8_SlotBoxInventoryFirstSlot) && !_mousePointerHiddenToDrawChangedObjIconOnScreen) {
@@ -464,9 +464,9 @@ void ChampionMan::drawChangedObjectIcons() {
 	_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
 	IconIndice leaderHandObjIconIndex = _leaderHandObjectIconIndex;
 
-	if (((leaderHandObjIconIndex < k32_IconIndiceWeaponDagger) && (leaderHandObjIconIndex >= k0_IconIndiceJunkCompassNorth))	// < instead of <= is correct
-		|| ((leaderHandObjIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= k163_IconIndicePotionWaterFlask))
-		|| (leaderHandObjIconIndex == k195_IconIndicePotionEmptyFlask)) {
+	if (((leaderHandObjIconIndex < kDMIconIndiceWeaponDagger) && (leaderHandObjIconIndex >= kDMIconIndiceJunkCompassNorth))	// < instead of <= is correct
+		|| ((leaderHandObjIconIndex >= kDMIconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= kDMIconIndicePotionWaterFlask))
+		|| (leaderHandObjIconIndex == kDMIconIndicePotionEmptyFlask)) {
 		IconIndice iconIndex = objMan.getIconIndex(_leaderHandObject);
 		if (iconIndex != leaderHandObjIconIndex) {
 			_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
@@ -511,7 +511,7 @@ void ChampionMan::drawChangedObjectIcons() {
 		}
 
 		if (drawViewport) {
-			champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
+			champ->setAttributeFlag(kDMChampionAttributeViewport, true);
 			drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
 		}
 	}
@@ -538,7 +538,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 	}
 
 	champ->_load += dunMan.getObjectWeight(thing);
-	champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
+	champ->setAttributeFlag(kDMChampionAttributeLoad, true);
 	IconIndice iconIndex = objMan.getIconIndex(thing);
 	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
 	applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
@@ -546,31 +546,31 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 
 	if (slotIndex < k2_ChampionSlotHead) {
 		if (slotIndex == k1_ChampionSlotActionHand) {
-			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
+			champ->setAttributeFlag(kDMChampionAttributeActionHand, true);
 			if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
 				menuMan.clearActingChampion();
 
-			if ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)) {
+			if ((iconIndex >= kDMIconIndiceScrollOpen) && (iconIndex <= kDMIconIndiceScrollClosed)) {
 				((Scroll *)rawObjPtr)->setClosed(false);
 				drawChangedObjectIcons();
 			}
 		}
 
-		if (iconIndex == k4_IconIndiceWeaponTorchUnlit) {
+		if (iconIndex == kDMIconIndiceWeaponTorchUnlit) {
 			((Weapon *)rawObjPtr)->setLit(true);
 			_vm->_inventoryMan->setDungeonViewPalette();
 			drawChangedObjectIcons();
 		} else if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand) &&
-			((iconIndex == k144_IconIndiceContainerChestClosed) || ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)))) {
-			champ->setAttributeFlag(k0x0800_ChampionAttributePanel, true);
+			((iconIndex == kDMIconIndiceContainerChestClosed) || ((iconIndex >= kDMIconIndiceScrollOpen) && (iconIndex <= kDMIconIndiceScrollClosed)))) {
+			champ->setAttributeFlag(kDMChampionAttributePanel, true);
 		}
 	} else if (slotIndex == k10_ChampionSlotNeck) {
-		if ((iconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (iconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
+		if ((iconIndex >= kDMIconIndiceJunkIllumuletUnequipped) && (iconIndex <= kDMIconIndiceJunkIllumuletEquipped)) {
 			((Junk *)rawObjPtr)->setChargeCount(1);
 			_party._magicalLightAmount += _lightPowerToLightAmount[2];
 			_vm->_inventoryMan->setDungeonViewPalette();
 			iconIndex = (IconIndice)(iconIndex + 1);
-		} else if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
+		} else if ((iconIndex >= kDMIconIndiceJunkJewelSymalUnequipped) && (iconIndex <= kDMIconIndiceJunkJewelSymalEquipped)) {
 			((Junk *)rawObjPtr)->setChargeCount(1);
 			iconIndex = (IconIndice)(iconIndex + 1);
 		}
@@ -578,7 +578,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 
 	drawSlot(champIndex, slotIndex);
 	if (isInventoryChampion)
-		champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
+		champ->setAttributeFlag(kDMChampionAttributeViewport, true);
 }
 
 int16 ChampionMan::getScentOrdinal(int16 mapX, int16 mapY) {
@@ -606,14 +606,14 @@ Thing ChampionMan::getObjectRemovedFromLeaderHand() {
 
 	if (leaderHandObject != Thing::_none) {
 		_leaderHandObject = Thing::_none;
-		_leaderHandObjectIconIndex = kM1_IconIndiceNone;
+		_leaderHandObjectIconIndex = kDMIconIndiceNone;
 		_vm->_eventMan->showMouse();
 		_vm->_objectMan->clearLeaderObjectName();
 		_vm->_eventMan->setMousePointer();
 		_vm->_eventMan->hideMouse();
-		if (_leaderIndex != kM1_ChampionNone) {
+		if (_leaderIndex != kDMChampionNone) {
 			_champions[_leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(leaderHandObject);
-			setFlag(_champions[_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
+			setFlag(_champions[_leaderIndex]._attributes, kDMChampionAttributeLoad);
 			drawChampionState(_leaderIndex);
 		}
 	}
@@ -622,7 +622,7 @@ Thing ChampionMan::getObjectRemovedFromLeaderHand() {
 
 uint16 ChampionMan::getStrength(int16 champIndex, int16 slotIndex) {
 	Champion *curChampion = &_champions[champIndex];
-	int16 strength = _vm->getRandomNumber(16) + curChampion->_statistics[k1_ChampionStatStrength][k1_ChampionStatCurrent];
+	int16 strength = _vm->getRandomNumber(16) + curChampion->_statistics[kDMChampionStatStrength][kDMChampionStatCurrent];
 	Thing curThing = curChampion->_slots[slotIndex];
 	uint16 objectWeight = _vm->_dungeonMan->getObjectWeight(curThing);
 	uint16 oneSixteenthMaximumLoad = getMaximumLoad(curChampion) >> 4;
@@ -654,7 +654,7 @@ uint16 ChampionMan::getStrength(int16 champIndex, int16 slotIndex) {
 		strength += skillLevel << 1;
 	}
 	strength = getStaminaAdjustedValue(curChampion, strength);
-	if (getFlag(curChampion->_wounds, (slotIndex == k0_ChampionSlotReadyHand) ? k0x0001_ChampionWoundReadHand : k0x0002_ChampionWoundActionHand)) {
+	if (getFlag(curChampion->_wounds, (slotIndex == k0_ChampionSlotReadyHand) ? kDMChampionWoundReadHand : kDMChampionWoundActionHand)) {
 		strength >>= 1;
 	}
 	return getBoundedValue(0, strength >> 1, 100);
@@ -682,32 +682,32 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 
 	Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->getThingData(curThing);
 	if (slotIndex == k10_ChampionSlotNeck) {
-		if ((curIconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (curIconIndex <= k13_IconIndiceJunkIllumuletEquipped)) {
+		if ((curIconIndex >= kDMIconIndiceJunkIllumuletUnequipped) && (curIconIndex <= kDMIconIndiceJunkIllumuletEquipped)) {
 			((Junk *)curWeapon)->setChargeCount(0);
 			_party._magicalLightAmount -= _lightPowerToLightAmount[2];
 			_vm->_inventoryMan->setDungeonViewPalette();
-		} else if ((curIconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (curIconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) {
+		} else if ((curIconIndex >= kDMIconIndiceJunkJewelSymalUnequipped) && (curIconIndex <= kDMIconIndiceJunkJewelSymalEquipped)) {
 			((Junk *)curWeapon)->setChargeCount(0);
 		}
 	}
 
 	drawSlot(champIndex, slotIndex);
 	if (isInventoryChampion)
-		setFlag(curChampion->_attributes, k0x4000_ChampionAttributeViewport);
+		setFlag(curChampion->_attributes, kDMChampionAttributeViewport);
 
 	if (slotIndex < k2_ChampionSlotHead) {
 		if (slotIndex == k1_ChampionSlotActionHand) {
-			setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand);
+			setFlag(curChampion->_attributes, kDMChampionAttributeActionHand);
 			if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
 				_vm->_menuMan->clearActingChampion();
 
-			if ((curIconIndex >= k30_IconIndiceScrollOpen) && (curIconIndex <= k31_IconIndiceScrollClosed)) {
+			if ((curIconIndex >= kDMIconIndiceScrollOpen) && (curIconIndex <= kDMIconIndiceScrollClosed)) {
 				((Scroll *)curWeapon)->setClosed(true);
 				drawChangedObjectIcons();
 			}
 		}
 
-		if ((curIconIndex >= k4_IconIndiceWeaponTorchUnlit) && (curIconIndex <= k7_IconIndiceWeaponTorchLit)) {
+		if ((curIconIndex >= kDMIconIndiceWeaponTorchUnlit) && (curIconIndex <= kDMIconIndiceWeaponTorchLit)) {
 			curWeapon->setLit(false);
 			_vm->_inventoryMan->setDungeonViewPalette();
 			drawChangedObjectIcons();
@@ -715,12 +715,12 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 
 		if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand)) {
 			switch (curIconIndex) {
-			case k144_IconIndiceContainerChestClosed:
+			case kDMIconIndiceContainerChestClosed:
 				_vm->_inventoryMan->closeChest();
 			// No break on purpose
-			case k30_IconIndiceScrollOpen:
-			case k31_IconIndiceScrollClosed:
-				setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel);
+			case kDMIconIndiceScrollOpen:
+			case kDMIconIndiceScrollClosed:
+				setFlag(curChampion->_attributes, kDMChampionAttributePanel);
 				break;
 			default:
 				break;
@@ -728,12 +728,12 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 		}
 	}
 	curChampion->_load -= _vm->_dungeonMan->getObjectWeight(curThing);
-	setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad);
+	setFlag(curChampion->_attributes, kDMChampionAttributeLoad);
 	return curThing;
 }
 
 void ChampionMan::decrementStamina(int16 championIndex, int16 decrement) {
-	if (championIndex == kM1_ChampionNone)
+	if (championIndex == kDMChampionNone)
 		return;
 
 	Champion *curChampion = &_champions[championIndex];
@@ -742,12 +742,12 @@ void ChampionMan::decrementStamina(int16 championIndex, int16 decrement) {
 	int16 stamina = curChampion->_currStamina;
 	if (stamina <= 0) {
 		curChampion->_currStamina = 0;
-		addPendingDamageAndWounds_getDamage(championIndex, (-stamina) >> 1, k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
+		addPendingDamageAndWounds_getDamage(championIndex, (-stamina) >> 1, kDMChampionWoundNone, k0_attackType_NORMAL);
 	} else if (stamina > curChampion->_maxStamina) {
 		curChampion->_currStamina = curChampion->_maxStamina;
 	}
 
-	setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics);
+	setFlag(curChampion->_attributes, kDMChampionAttributeLoad | kDMChampionAttributeStatistics);
 }
 
 int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds, uint16 attackType) {
@@ -774,7 +774,7 @@ int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 a
 		switch (attackType) {
 		case k6_attackType_PSYCHIC:
 		{
-			int16 wisdomFactor = 115 - curChampion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent];
+			int16 wisdomFactor = 115 - curChampion->_statistics[kDMChampionStatWisdom][kDMChampionStatCurrent];
 			if (wisdomFactor <= 0) {
 				attack = 0;
 			} else {
@@ -785,12 +785,12 @@ int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 a
 		}
 		break;
 		case k5_attackType_MAGIC:
-			attack = getStatisticAdjustedAttack(curChampion, k5_ChampionStatAntimagic, attack);
+			attack = getStatisticAdjustedAttack(curChampion, kDMChampionStatAntimagic, attack);
 			attack -= _party._spellShieldDefense;
 			skipScaling = true;
 			break;
 		case k1_attackType_FIRE:
-			attack = getStatisticAdjustedAttack(curChampion, k6_ChampionStatAntifire, attack);
+			attack = getStatisticAdjustedAttack(curChampion, kDMChampionStatAntifire, attack);
 			attack -= _party._fireShieldDefense;
 			break;
 		case k2_attackType_SELF:
@@ -818,7 +818,7 @@ int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 a
 		if (attack <= 0)
 			return 0;
 
-		int16 adjustedAttack = getStatisticAdjustedAttack(curChampion, k4_ChampionStatVitality, _vm->getRandomNumber(128) + 10);
+		int16 adjustedAttack = getStatisticAdjustedAttack(curChampion, kDMChampionStatVitality, _vm->getRandomNumber(128) + 10);
 		if (attack > adjustedAttack) {
 		/* BUG0_45
 			This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the
@@ -858,7 +858,7 @@ int16 ChampionMan::getWoundDefense(int16 champIndex, uint16 woundIndex) {
 		}
 	}
 
-	int16 woundDefense = _vm->getRandomNumber((curChampion->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] >> 3) + 1);
+	int16 woundDefense = _vm->getRandomNumber((curChampion->_statistics[kDMChampionStatVitality][kDMChampionStatCurrent] >> 3) + 1);
 	if (useSharpDefense)
 		woundDefense >>= 1;
 
@@ -881,7 +881,7 @@ int16 ChampionMan::getWoundDefense(int16 champIndex, uint16 woundIndex) {
 }
 
 uint16 ChampionMan::getStatisticAdjustedAttack(Champion *champ, uint16 statIndex, uint16 attack) {
-	int16 factor = 170 - champ->_statistics[statIndex][k1_ChampionStatCurrent];
+	int16 factor = 170 - champ->_statistics[statIndex][kDMChampionStatCurrent];
 
 	/* BUG0_41
 		The Antifire and Antimagic statistics are completely ignored. The Vitality statistic is ignored
@@ -939,7 +939,7 @@ void ChampionMan::disableAction(uint16 champIndex, uint16 ticks) {
 		}
 		_vm->_timeline->deleteEvent(eventIndex);
 	} else {
-		setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x0008_ChampionAttributeDisableAction);
+		setFlag(curChampion->_attributes, kDMChampionAttributeActionHand | kDMChampionAttributeDisableAction);
 		drawChampionState((ChampionIndex)champIndex);
 	}
 	setMapAndTime(curEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, updatedEnableActionEventTime);
@@ -961,7 +961,7 @@ void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint1
 		else
 			baseSkillIndex = skillIndex;
 
-		uint16 skillLevelBefore = getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
+		uint16 skillLevelBefore = getSkillLevel(champIndex, baseSkillIndex | (kDMIgnoreObjectModifiers | kDMIgnoreTemporaryExperience));
 
 		if ((skillIndex >= k4_ChampionSkillSwing) && (_vm->_projexpl->_lastCreatureAttackTime > _vm->_gameTime - 25))
 			exp <<= 1;
@@ -975,7 +975,7 @@ void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint1
 		if (skillIndex >= k4_ChampionSkillSwing)
 			curSkill->_experience += exp;
 
-		uint16 skillLevelAfter = getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience));
+		uint16 skillLevelAfter = getSkillLevel(champIndex, baseSkillIndex | (kDMIgnoreObjectModifiers | kDMIgnoreTemporaryExperience));
 		if (skillLevelAfter > skillLevelBefore) {
 			int16 newBaseSkillLevel = skillLevelAfter;
 			int16 minorStatIncrease = _vm->getRandomNumber(2);
@@ -984,34 +984,34 @@ void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint1
 			if (baseSkillIndex != k2_ChampionSkillPriest) {
 				vitalityAmount &= skillLevelAfter; /* For non Priest skills the amount is 0 for even skill levels. The amount is 0 or 1 for odd skill levels */
 			}
-			curChampion->_statistics[k4_ChampionStatVitality][k0_ChampionStatMaximum] += vitalityAmount;
+			curChampion->_statistics[kDMChampionStatVitality][kDMChampionStatMaximum] += vitalityAmount;
 			uint16 staminaAmount = curChampion->_maxStamina;
-			curChampion->_statistics[k6_ChampionStatAntifire][k0_ChampionStatMaximum] += _vm->getRandomNumber(2) & ~skillLevelAfter; /* The amount is 0 for odd skill levels. The amount is 0 or 1 for even skill levels */
+			curChampion->_statistics[kDMChampionStatAntifire][kDMChampionStatMaximum] += _vm->getRandomNumber(2) & ~skillLevelAfter; /* The amount is 0 for odd skill levels. The amount is 0 or 1 for even skill levels */
 			bool increaseManaFl = false;
 			switch (baseSkillIndex) {
 			case k0_ChampionSkillFighter:
 				staminaAmount >>= 4;
 				skillLevelAfter *= 3;
-				curChampion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += majorStatIncrease;
-				curChampion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += minorStatIncrease;
+				curChampion->_statistics[kDMChampionStatStrength][kDMChampionStatMaximum] += majorStatIncrease;
+				curChampion->_statistics[kDMChampionStatDexterity][kDMChampionStatMaximum] += minorStatIncrease;
 				break;
 			case k1_ChampionSkillNinja:
 				staminaAmount /= 21;
 				skillLevelAfter <<= 1;
-				curChampion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += minorStatIncrease;
-				curChampion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += majorStatIncrease;
+				curChampion->_statistics[kDMChampionStatStrength][kDMChampionStatMaximum] += minorStatIncrease;
+				curChampion->_statistics[kDMChampionStatDexterity][kDMChampionStatMaximum] += majorStatIncrease;
 				break;
 			case k3_ChampionSkillWizard:
 				staminaAmount >>= 5;
 				curChampion->_maxMana += skillLevelAfter + (skillLevelAfter >> 1);
-				curChampion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += majorStatIncrease;
+				curChampion->_statistics[kDMChampionStatWisdom][kDMChampionStatMaximum] += majorStatIncrease;
 				increaseManaFl = true;
 				break;
 			case k2_ChampionSkillPriest:
 				staminaAmount /= 25;
 				curChampion->_maxMana += skillLevelAfter;
 				skillLevelAfter += (skillLevelAfter + 1) >> 1;
-				curChampion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += minorStatIncrease;
+				curChampion->_statistics[kDMChampionStatWisdom][kDMChampionStatMaximum] += minorStatIncrease;
 				increaseManaFl = true;
 				break;
 			default:
@@ -1020,7 +1020,7 @@ void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint1
 			if (increaseManaFl) {
 				if ((curChampion->_maxMana += MIN(_vm->getRandomNumber(4), (uint16)(newBaseSkillLevel - 1))) > 900)
 					curChampion->_maxMana = 900;
-				curChampion->_statistics[k5_ChampionStatAntimagic][k0_ChampionStatMaximum] += _vm->getRandomNumber(3);
+				curChampion->_statistics[kDMChampionStatAntimagic][kDMChampionStatMaximum] += _vm->getRandomNumber(3);
 			}
 
 			if ((curChampion->_maxHealth += skillLevelAfter + _vm->getRandomNumber((skillLevelAfter >> 1) + 1)) > 999)
@@ -1029,7 +1029,7 @@ void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint1
 			if ((curChampion->_maxStamina += staminaAmount + _vm->getRandomNumber((staminaAmount >> 1) + 1)) > 9999)
 				curChampion->_maxStamina = 9999;
 
-			setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+			setFlag(curChampion->_attributes, kDMChampionAttributeStatistics);
 			drawChampionState((ChampionIndex)champIndex);
 			_vm->_textMan->printLineFeed();
 			Color curChampionColor = _championColor[champIndex];
@@ -1060,7 +1060,7 @@ int16 ChampionMan::getDamagedChampionCount(uint16 attack, int16 wounds, int16 at
 	randomMax <<= 1;
 
 	int16 damagedChampionCount = 0;
-	for (int16 championIndex = k0_ChampionFirst; championIndex < _partyChampionCount; championIndex++) {
+	for (int16 championIndex = kDMChampionFirst; championIndex < _partyChampionCount; championIndex++) {
 		// Actual attack is attack +/- (attack / 8)
 		if (addPendingDamageAndWounds_getDamage(championIndex, MAX(1, reducedAttack + _vm->getRandomNumber(randomMax)), wounds, attackType))
 			damagedChampionCount++;
@@ -1079,11 +1079,11 @@ int16 ChampionMan::getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) {
 				return championIndex;
 		}
 	}
-	return kM1_ChampionNone;
+	return kDMChampionNone;
 }
 
 int16 ChampionMan::getDexterity(Champion *champ) {
-	int16 dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent];
+	int16 dexterity = _vm->getRandomNumber(8) + champ->_statistics[kDMChampionStatDexterity][kDMChampionStatCurrent];
 	dexterity -= ((int32)(dexterity >> 1) * (int32)champ->_load) / getMaximumLoad(champ);
 	if (_partyIsSleeping)
 		dexterity >>= 1;
@@ -1095,21 +1095,21 @@ bool ChampionMan::isLucky(Champion *champ, uint16 percentage) {
 	if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage))
 		return true;
 
-	unsigned char *curStat = champ->_statistics[k0_ChampionStatLuck];
-	bool isLucky = (_vm->getRandomNumber(curStat[k1_ChampionStatCurrent]) > percentage);
-	curStat[k1_ChampionStatCurrent] = getBoundedValue<char>(curStat[k2_ChampionStatMinimum], curStat[k1_ChampionStatCurrent] + (isLucky ? -2 : 2), curStat[k0_ChampionStatMaximum]);
+	unsigned char *curStat = champ->_statistics[kDMChampionStatLuck];
+	bool isLucky = (_vm->getRandomNumber(curStat[kDMChampionStatCurrent]) > percentage);
+	curStat[kDMChampionStatCurrent] = getBoundedValue<char>(curStat[kDMChampionStatMinimum], curStat[kDMChampionStatCurrent] + (isLucky ? -2 : 2), curStat[kDMChampionStatMaximum]);
 	return isLucky;
 }
 
 void ChampionMan::championPoison(int16 champIndex, uint16 attack) {
-	if ((champIndex == kM1_ChampionNone) || (_vm->indexToOrdinal(champIndex) == _candidateChampionOrdinal))
+	if ((champIndex == kDMChampionNone) || (_vm->indexToOrdinal(champIndex) == _candidateChampionOrdinal))
 		return;
 
 	Champion *curChampion = &_champions[champIndex];
-	addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
-	setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+	addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), kDMChampionWoundNone, k0_attackType_NORMAL);
+	setFlag(curChampion->_attributes, kDMChampionAttributeStatistics);
 	if ((_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) && (_vm->_inventoryMan->_panelContent == k0_PanelContentFoodWaterPoisoned)) {
-		setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel);
+		setFlag(curChampion->_attributes, kDMChampionAttributePanel);
 	}
 
 	if (--attack) {
@@ -1134,7 +1134,7 @@ void ChampionMan::setPartyDirection(int16 dir) {
 		L0834_i_Delta += 4;
 
 	Champion *curChampion = _champions;
-	for (int16 i = k0_ChampionFirst; i < _partyChampionCount; i++) {
+	for (int16 i = kDMChampionFirst; i < _partyChampionCount; i++) {
 		curChampion->_cell = (ViewCell)normalizeModulo4(curChampion->_cell + L0834_i_Delta);
 		curChampion->_dir = (Direction)normalizeModulo4(curChampion->_dir + L0834_i_Delta);
 		curChampion++;
@@ -1206,9 +1206,9 @@ void ChampionMan::putObjectInLeaderHand(Thing thing, bool setMousePointer) {
 		_vm->_eventMan->setPointerToObject(_vm->_objectMan->_objectIconForMousePointer);
 
 	_vm->_eventMan->hideMouse();
-	if (_leaderIndex != kM1_ChampionNone) {
+	if (_leaderIndex != kDMChampionNone) {
 		_champions[_leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(thing);
-		setFlag(_champions[_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
+		setFlag(_champions[_leaderIndex]._attributes, kDMChampionAttributeLoad);
 		drawChampionState(_leaderIndex);
 	}
 }
@@ -1235,10 +1235,10 @@ int16 ChampionMan::getMovementTicks(Champion *champ) {
 		woundTicks = 2;
 	}
 
-	if (getFlag(champ->_wounds, k0x0020_ChampionWoundFeet))
+	if (getFlag(champ->_wounds, kDMChampionWoundFeet))
 		ticks += woundTicks;
 
-	if (_vm->_objectMan->getIconIndex(champ->_slots[k5_ChampionSlotFeet]) == k194_IconIndiceArmourBootOfSpeed)
+	if (_vm->_objectMan->getIconIndex(champ->_slots[k5_ChampionSlotFeet]) == kDMIconIndiceArmourBootOfSpeed)
 		ticks--;
 
 	return ticks;
@@ -1267,15 +1267,15 @@ bool ChampionMan::isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 wea
 }
 
 void ChampionMan::drawAllChampionStates() {
-	for (int16 i = k0_ChampionFirst; i < _partyChampionCount; i++)
+	for (int16 i = kDMChampionFirst; i < _partyChampionCount; i++)
 		drawChampionState((ChampionIndex)i);
 }
 
 void ChampionMan::viAltarRebirth(uint16 champIndex) {
 	Champion *curChampion = &_champions[champIndex];
-	if (getIndexInCell(curChampion->_cell) != kM1_ChampionNone) {
+	if (getIndexInCell(curChampion->_cell) != kDMChampionNone) {
 		uint16 numCell = k0_CellNorthWest;
-		while (getIndexInCell(numCell) != kM1_ChampionNone)
+		while (getIndexInCell(numCell) != kDMChampionNone)
 			numCell++;
 
 		curChampion->_cell = (ViewCell)numCell;
@@ -1286,7 +1286,7 @@ void ChampionMan::viAltarRebirth(uint16 champIndex) {
 	curChampion->_currHealth = curChampion->_maxHealth >> 1;
 	_vm->_menuMan->drawSpellAreaControls(_magicCasterChampionIndex);
 	curChampion->_dir = _vm->_dungeonMan->_partyDir;
-	setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
+	setFlag(curChampion->_attributes, kDMChampionAttributeActionHand | kDMChampionAttributeStatusBox | kDMChampionAttributeIcon);
 	drawChampionState((ChampionIndex)champIndex);
 }
 
@@ -1344,7 +1344,7 @@ bool ChampionMan::isProjectileSpellCast(uint16 champIndex, Thing thing, int16 ki
 		return false;
 
 	curChampion->_currMana -= requiredManaAmount;
-	setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+	setFlag(curChampion->_attributes, kDMChampionAttributeStatistics);
 	int16 stepEnergy = 10 - MIN(8, curChampion->_maxMana >> 3);
 	if (kineticEnergy < (stepEnergy << 2)) {
 		kineticEnergy += 3;
@@ -1364,7 +1364,7 @@ void ChampionMan::championShootProjectile(Champion *champ, Thing thing, int16 ki
 
 void ChampionMan::applyAndDrawPendingDamageAndWounds() {
 	Champion *championPtr = _champions;
-	for (uint16 championIndex = k0_ChampionFirst; championIndex < _partyChampionCount; championIndex++, championPtr++) {
+	for (uint16 championIndex = kDMChampionFirst; championIndex < _partyChampionCount; championIndex++, championPtr++) {
 		int16 pendingWounds = _championPendingWounds[championIndex];
 		setFlag(championPtr->_wounds, pendingWounds);
 		_championPendingWounds[championIndex] = 0;
@@ -1385,9 +1385,9 @@ void ChampionMan::applyAndDrawPendingDamageAndWounds() {
 			championKill(championIndex);
 		} else {
 			championPtr->_currHealth = curHealth;
-			setFlag(championPtr->_attributes, k0x0100_ChampionAttributeStatistics);
+			setFlag(championPtr->_attributes, kDMChampionAttributeStatistics);
 			if (pendingWounds) {
-				setFlag(championPtr->_attributes, k0x2000_ChampionAttributeWounds);
+				setFlag(championPtr->_attributes, kDMChampionAttributeWounds);
 			}
 
 			int16 textPosX = championIndex * k69_ChampionStatusBoxSpacing;
@@ -1449,7 +1449,7 @@ void ChampionMan::applyAndDrawPendingDamageAndWounds() {
 void ChampionMan::championKill(uint16 champIndex) {
 	Champion *curChampion = &_champions[champIndex];
 	curChampion->_currHealth = 0;
-	setFlag(curChampion->_attributes, k0x1000_ChampionAttributeStatusBox);
+	setFlag(curChampion->_attributes, kDMChampionAttributeStatusBox);
 	if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) {
 		if (_vm->_pressingEye) {
 			_vm->_pressingEye = false;
@@ -1465,7 +1465,7 @@ void ChampionMan::championKill(uint16 champIndex) {
 			_vm->_eventMan->_hideMousePointerRequestCount = 1;
 			_vm->_eventMan->hideMouse();
 		}
-		_vm->_inventoryMan->toggleInventory(k4_ChampionCloseInventory);
+		_vm->_inventoryMan->toggleInventory(kDMChampionCloseInventory);
 	}
 	dropAllObjects(champIndex);
 	Thing unusedThing = _vm->_dungeonMan->getUnusedThing(k0x8000_championBones | k10_JunkThingType);
@@ -1485,7 +1485,7 @@ void ChampionMan::championKill(uint16 champIndex) {
 	uint16 curChampionIconIndex = getChampionIconIndex(curCell, _vm->_dungeonMan->_partyDir);
 	if (_vm->indexToOrdinal(curChampionIconIndex) == _vm->_eventMan->_useChampionIconOrdinalAsMousePointerBitmap) {
 		_vm->_eventMan->_mousePointerBitmapUpdated = true;
-		_vm->_eventMan->_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kM1_ChampionNone);
+		_vm->_eventMan->_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kDMChampionNone);
 	}
 
 	if (curChampion->_poisonEventCount)
@@ -1558,7 +1558,7 @@ void ChampionMan::dropAllObjects(uint16 champIndex) {
 }
 
 void ChampionMan::unpoison(int16 champIndex) {
-	if (champIndex == kM1_ChampionNone)
+	if (champIndex == kDMChampionNone)
 		return;
 
 	TimelineEvent *eventPtr = _vm->_timeline->_events;
@@ -1591,11 +1591,11 @@ void ChampionMan::applyTimeEffects() {
 	uint16 gameTime = _vm->_gameTime & 0xFFFF;
 	uint16 timeCriteria = (((gameTime & 0x0080) + ((gameTime & 0x0100) >> 2)) + ((gameTime & 0x0040) << 2)) >> 2;
 	Champion *championPtr = _champions;
-	for (uint16 championIndex = k0_ChampionFirst; championIndex < _partyChampionCount; championIndex++, championPtr++) {
+	for (uint16 championIndex = kDMChampionFirst; championIndex < _partyChampionCount; championIndex++, championPtr++) {
 		if (championPtr->_currHealth && (_vm->indexToOrdinal(championIndex) != _candidateChampionOrdinal)) {
 			uint16 wizardSkillLevel = getSkillLevel(championIndex, k3_ChampionSkillWizard) + getSkillLevel(championIndex, k2_ChampionSkillPriest);
 			if ((championPtr->_currMana < championPtr->_maxMana)
-				&& (timeCriteria < championPtr->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + wizardSkillLevel)) {
+				&& (timeCriteria < championPtr->_statistics[kDMChampionStatWisdom][kDMChampionStatCurrent] + wizardSkillLevel)) {
 				int16 manaGain = championPtr->_maxMana / 40;
 				if (_partyIsSleeping)
 					manaGain <<= 1;
@@ -1658,35 +1658,35 @@ void ChampionMan::applyTimeEffects() {
 			if (championPtr->_water < -1024)
 				championPtr->_water = -1024;
 
-			if ((championPtr->_currHealth < championPtr->_maxHealth) && (championPtr->_currStamina >= (championPtr->_maxStamina >> 2)) && (timeCriteria < (championPtr->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] + 12))) {
+			if ((championPtr->_currHealth < championPtr->_maxHealth) && (championPtr->_currStamina >= (championPtr->_maxStamina >> 2)) && (timeCriteria < (championPtr->_statistics[kDMChampionStatVitality][kDMChampionStatCurrent] + 12))) {
 				int16 healthGain = (championPtr->_maxHealth >> 7) + 1;
 				if (_partyIsSleeping)
 					healthGain <<= 1;
 
-				if (_vm->_objectMan->getIconIndex(championPtr->_slots[k10_ChampionSlotNeck]) == k121_IconIndiceJunkEkkhardCross)
+				if (_vm->_objectMan->getIconIndex(championPtr->_slots[k10_ChampionSlotNeck]) == kDMIconIndiceJunkEkkhardCross)
 					healthGain += (healthGain >> 1) + 1;
 
 				championPtr->_currHealth += MIN(healthGain, (int16)(championPtr->_maxHealth - championPtr->_currHealth));
 			}
 			if (!((int)_vm->_gameTime & (_partyIsSleeping ? 63 : 255))) {
-				for (uint16 i = k0_ChampionStatLuck; i <= k6_ChampionStatAntifire; i++) {
+				for (uint16 i = kDMChampionStatLuck; i <= kDMChampionStatAntifire; i++) {
 					byte *curStatistic = championPtr->_statistics[i];
-					uint16 statisticMaximum = curStatistic[k0_ChampionStatMaximum];
-					if (curStatistic[k1_ChampionStatCurrent] < statisticMaximum)
-						curStatistic[k1_ChampionStatCurrent]++;
-					else if (curStatistic[k1_ChampionStatCurrent] > statisticMaximum)
-						curStatistic[k1_ChampionStatCurrent] -= curStatistic[k1_ChampionStatCurrent] / statisticMaximum;
+					uint16 statisticMaximum = curStatistic[kDMChampionStatMaximum];
+					if (curStatistic[kDMChampionStatCurrent] < statisticMaximum)
+						curStatistic[kDMChampionStatCurrent]++;
+					else if (curStatistic[kDMChampionStatCurrent] > statisticMaximum)
+						curStatistic[kDMChampionStatCurrent] -= curStatistic[kDMChampionStatCurrent] / statisticMaximum;
 				}
 			}
 			if (!_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_partyDir) && (_vm->_projexpl->_lastCreatureAttackTime + 60 < _vm->_gameTime)) {
 				championPtr->_dir = _vm->_dungeonMan->_partyDir;
 				championPtr->_maximumDamageReceived = 0;
-				setFlag(championPtr->_attributes, k0x0400_ChampionAttributeIcon);
+				setFlag(championPtr->_attributes, kDMChampionAttributeIcon);
 			}
-			setFlag(championPtr->_attributes, k0x0100_ChampionAttributeStatistics);
+			setFlag(championPtr->_attributes, kDMChampionAttributeStatistics);
 			if (_vm->indexToOrdinal(championIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) {
 				if (_vm->_pressingMouth || _vm->_pressingEye || (_vm->_inventoryMan->_panelContent == k0_PanelContentFoodWaterPoisoned)) {
-					setFlag(championPtr->_attributes, k0x0800_ChampionAttributePanel);
+					setFlag(championPtr->_attributes, kDMChampionAttributePanel);
 				}
 			}
 		}
@@ -1824,7 +1824,7 @@ ChampionIndex ChampionMan::getIndexInCell(int16 cell) {
 			return (ChampionIndex)i;
 	}
 
-	return kM1_ChampionNone;
+	return kDMChampionNone;
 }
 
 void ChampionMan::resetDataToStartGame() {
@@ -1832,34 +1832,34 @@ void ChampionMan::resetDataToStartGame() {
 		Thing handThing = _leaderHandObject;
 		if (handThing == Thing::_none) {
 			_leaderEmptyHanded = true;
-			_leaderHandObjectIconIndex = kM1_IconIndiceNone;
+			_leaderHandObjectIconIndex = kDMIconIndiceNone;
 			_vm->_eventMan->setMousePointer();
 		} else
 			putObjectInLeaderHand(handThing, true); /* This call will add the weight of the leader hand object to the Load of the leader a first time */
 
 		Champion *curChampion = _champions;
 		for (int16 idx = 0; idx < _partyChampionCount; idx++, curChampion++) {
-			clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
-			setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
+			clearFlag(curChampion->_attributes, kDMChampionAttributeNameTitle | kDMChampionAttributeStatistics | kDMChampionAttributeLoad | kDMChampionAttributeIcon | kDMChampionAttributePanel | kDMChampionAttributeStatusBox | kDMChampionAttributeWounds | kDMChampionAttributeViewport | kDMChampionAttributeActionHand);
+			setFlag(curChampion->_attributes, kDMChampionAttributeActionHand | kDMChampionAttributeStatusBox | kDMChampionAttributeIcon);
 		}
 		drawAllChampionStates();
 
 		ChampionIndex championIndex = _leaderIndex;
-		if (championIndex != kM1_ChampionNone) {
-			_leaderIndex = kM1_ChampionNone;
+		if (championIndex != kDMChampionNone) {
+			_leaderIndex = kDMChampionNone;
 			_vm->_eventMan->commandSetLeader(championIndex);
 		}
 
 		championIndex = _magicCasterChampionIndex;
-		if (championIndex != kM1_ChampionNone) {
-			_magicCasterChampionIndex = kM1_ChampionNone;
+		if (championIndex != kDMChampionNone) {
+			_magicCasterChampionIndex = kDMChampionNone;
 			_vm->_menuMan->setMagicCasterAndDrawSpellArea(championIndex);
 		}
 		return;
 	}
 
 	_leaderHandObject = Thing::_none;
-	_leaderHandObjectIconIndex = kM1_IconIndiceNone;
+	_leaderHandObjectIconIndex = kDMIconIndiceNone;
 	_leaderEmptyHanded = true;
 }
 
@@ -1881,11 +1881,11 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	championPtr->_hideDamageReceivedIndex = -1;
 	championPtr->_dir = _vm->_dungeonMan->_partyDir;
 	uint16 viewCell = k0_ViewCellFronLeft;
-	while (getIndexInCell(normalizeModulo4(viewCell + _vm->_dungeonMan->_partyDir)) != kM1_ChampionNone)
+	while (getIndexInCell(normalizeModulo4(viewCell + _vm->_dungeonMan->_partyDir)) != kDMChampionNone)
 		viewCell++;
 
 	championPtr->_cell = (ViewCell)normalizeModulo4(viewCell + _vm->_dungeonMan->_partyDir);
-	championPtr->_attributes = k0x0400_ChampionAttributeIcon;
+	championPtr->_attributes = kDMChampionAttributeIcon;
 	championPtr->_directionMaximumDamageReceived = _vm->_dungeonMan->_partyDir;
 	championPtr->_food = 1500 + _vm->getRandomNumber(256);
 	championPtr->_water = 1500 + _vm->getRandomNumber(256);
@@ -1919,7 +1919,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	}
 	championPtr->_title[charIdx] = '\0';
 	if (*decodedStringPtr++ == 'M')
-		setFlag(championPtr->_attributes, k0x0010_ChampionAttributeMale);
+		setFlag(championPtr->_attributes, kDMChampionAttributeMale);
 
 	decodedStringPtr++;
 	championPtr->_currHealth = championPtr->_maxHealth = getDecodedValue(decodedStringPtr, 4);
@@ -1929,12 +1929,12 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	championPtr->_currMana = championPtr->_maxMana = getDecodedValue(decodedStringPtr, 4);
 	decodedStringPtr += 4;
 	decodedStringPtr++;
-	for (int16 statIdx = k0_ChampionStatLuck; statIdx <= k6_ChampionStatAntifire; statIdx++) {
-		championPtr->_statistics[statIdx][k2_ChampionStatMinimum] = 30;
-		championPtr->_statistics[statIdx][k1_ChampionStatCurrent] = championPtr->_statistics[statIdx][k0_ChampionStatMaximum] = getDecodedValue(decodedStringPtr, 2);
+	for (int16 statIdx = kDMChampionStatLuck; statIdx <= kDMChampionStatAntifire; statIdx++) {
+		championPtr->_statistics[statIdx][kDMChampionStatMinimum] = 30;
+		championPtr->_statistics[statIdx][kDMChampionStatCurrent] = championPtr->_statistics[statIdx][kDMChampionStatMaximum] = getDecodedValue(decodedStringPtr, 2);
 		decodedStringPtr += 2;
 	}
-	championPtr->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10;
+	championPtr->_statistics[kDMChampionStatLuck][kDMChampionStatMinimum] = 10;
 	decodedStringPtr++;
 	for (uint16 skillIdx = k4_ChampionSkillSwing; skillIdx <= k19_ChampionSkillWater; skillIdx++) {
 		int skillValue = *decodedStringPtr++ - 'A';
@@ -1951,7 +1951,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	}
 	_candidateChampionOrdinal = previousPartyChampionCount + 1;
 	if (++_partyChampionCount == 1) {
-		_vm->_eventMan->commandSetLeader(k0_ChampionFirst);
+		_vm->_eventMan->commandSetLeader(kDMChampionFirst);
 		_vm->_menuMan->_refreshActionArea = true;
 	} else {
 		_vm->_menuMan->clearActingChampion();
@@ -2098,13 +2098,13 @@ uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) {
 }
 
 uint16 ChampionMan::getMaximumLoad(Champion *champ) {
-	uint16 maximumLoad = champ->getStatistic(k1_ChampionStatStrength, k1_ChampionStatCurrent) * 8 + 100;
+	uint16 maximumLoad = champ->getStatistic(kDMChampionStatStrength, kDMChampionStatCurrent) * 8 + 100;
 	maximumLoad = getStaminaAdjustedValue(champ, maximumLoad);
 	int16 wounds = champ->getWounds();
 	if (wounds)
-		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(k0x0010_ChampionWoundLegs) ? 2 : 3);
+		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kDMChampionWoundLegs) ? 2 : 3);
 
-	if (_vm->_objectMan->getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == k119_IconIndiceArmourElvenBoots)
+	if (_vm->_objectMan->getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == kDMIconIndiceArmourElvenBoots)
 		maximumLoad += maximumLoad * 16;
 
 	maximumLoad += 9;
@@ -2119,13 +2119,13 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	int16 championStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
 	Champion *curChampion = &_champions[champIndex];
 	uint16 championAttributes = curChampion->_attributes;
-	if (!getFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand))
+	if (!getFlag(championAttributes, kDMChampionAttributeNameTitle | kDMChampionAttributeStatistics | kDMChampionAttributeLoad | kDMChampionAttributeIcon | kDMChampionAttributePanel | kDMChampionAttributeStatusBox | kDMChampionAttributeWounds | kDMChampionAttributeViewport | kDMChampionAttributeActionHand))
 		return;
 
 	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal);
 	_vm->_displayMan->_useByteBoxCoordinates = false;
 	_vm->_eventMan->showMouse();
-	if (getFlag(championAttributes, k0x1000_ChampionAttributeStatusBox)) {
+	if (getFlag(championAttributes, kDMChampionAttributeStatusBox)) {
 		Box box;
 		box._y1 = 0;
 		box._y2 = 28;
@@ -2152,26 +2152,26 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 
 			if (isInventoryChampion) {
 				_vm->_inventoryMan->drawStatusBoxPortrait(champIndex);
-				setFlag(championAttributes, k0x0100_ChampionAttributeStatistics);
+				setFlag(championAttributes, kDMChampionAttributeStatistics);
 			} else
-				setFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand);
+				setFlag(championAttributes, kDMChampionAttributeNameTitle | kDMChampionAttributeStatistics | kDMChampionAttributeWounds | kDMChampionAttributeActionHand);
 		} else {
 			_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), &box, k40_byteWidth, kM1_ColorNoTransparency, 29);
 			_vm->_textMan->printToLogicalScreen(championStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, curChampion->_name);
 			_vm->_menuMan->drawActionIcon(champIndex);
 
-			clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
+			clearFlag(curChampion->_attributes, kDMChampionAttributeNameTitle | kDMChampionAttributeStatistics | kDMChampionAttributeLoad | kDMChampionAttributeIcon | kDMChampionAttributePanel | kDMChampionAttributeStatusBox | kDMChampionAttributeWounds | kDMChampionAttributeViewport | kDMChampionAttributeActionHand);
 			_vm->_eventMan->hideMouse();
 			return;
 		}
 	}
 	if (!(curChampion->_currHealth)) {
-		clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
+		clearFlag(curChampion->_attributes, kDMChampionAttributeNameTitle | kDMChampionAttributeStatistics | kDMChampionAttributeLoad | kDMChampionAttributeIcon | kDMChampionAttributePanel | kDMChampionAttributeStatusBox | kDMChampionAttributeWounds | kDMChampionAttributeViewport | kDMChampionAttributeActionHand);
 		_vm->_eventMan->hideMouse();
 		return;
 	}
 
-	if (getFlag(championAttributes, k0x0080_ChampionAttributeNameTitle)) {
+	if (getFlag(championAttributes, kDMChampionAttributeNameTitle)) {
 		Color nameColor = (champIndex == _leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
 		if (isInventoryChampion) {
 			char *championName = curChampion->_name;
@@ -2182,7 +2182,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 				championTitleX += 6;
 
 			_vm->_textMan->printToViewport(championTitleX, 7, nameColor, curChampion->_title);
-			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
+			setFlag(championAttributes, kDMChampionAttributeViewport);
 		} else {
 			Box box;
 			box._y1 = 0;
@@ -2193,7 +2193,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			_vm->_textMan->printToLogicalScreen(championStatusBoxX + 1, 5, nameColor, k1_ColorDarkGary, curChampion->_name);
 		}
 	}
-	if (getFlag(championAttributes, k0x0100_ChampionAttributeStatistics)) {
+	if (getFlag(championAttributes, kDMChampionAttributeStatistics)) {
 		drawChampionBarGraphs(champIndex);
 		if (isInventoryChampion) {
 			drawHealthStaminaManaValues(curChampion);
@@ -2205,24 +2205,24 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 
 			_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(nativeBitmapIndex), boxMouth, k16_byteWidth, k12_ColorDarkestGray, 18);
 			nativeBitmapIndex = k33_SlotBoxNormalIndice;
-			for (int i = k1_ChampionStatStrength; i <= k6_ChampionStatAntifire; i++) {
-				if ((curChampion->_statistics[i][k1_ChampionStatCurrent] < curChampion->_statistics[i][k0_ChampionStatMaximum])) {
+			for (int i = kDMChampionStatStrength; i <= kDMChampionStatAntifire; i++) {
+				if ((curChampion->_statistics[i][kDMChampionStatCurrent] < curChampion->_statistics[i][kDMChampionStatMaximum])) {
 					nativeBitmapIndex = k34_SlotBoxWoundedIndice;
 					break;
 				}
 			}
 			_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(nativeBitmapIndex), boxEye, k16_byteWidth, k12_ColorDarkestGray, 18);
-			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
+			setFlag(championAttributes, kDMChampionAttributeViewport);
 		}
 	}
-	if (getFlag(championAttributes, k0x2000_ChampionAttributeWounds)) {
+	if (getFlag(championAttributes, kDMChampionAttributeWounds)) {
 		for (int i = isInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; i >= k0_ChampionSlotReadyHand; i--)
 			drawSlot(champIndex, i);
 
 		if (isInventoryChampion)
-			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
+			setFlag(championAttributes, kDMChampionAttributeViewport);
 	}
-	if (getFlag(championAttributes, k0x0200_ChampionAttributeLoad) && isInventoryChampion) {
+	if (getFlag(championAttributes, kDMChampionAttributeLoad) && isInventoryChampion) {
 		uint16 maxLoad = getMaximumLoad(curChampion);
 		Color loadColor;
 		if (curChampion->_load > maxLoad)
@@ -2256,14 +2256,14 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		strcat(_vm->_stringBuildBuffer, getStringFromInteger(maxLoad, true, 3).c_str());
 		strcat(_vm->_stringBuildBuffer, " KG");
 		_vm->_textMan->printToViewport(148, 132, loadColor, _vm->_stringBuildBuffer);
-		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
+		setFlag(championAttributes, kDMChampionAttributeViewport);
 	}
 	uint16 championIconIndex = getChampionIconIndex(curChampion->_cell, _vm->_dungeonMan->_partyDir);
-	if (getFlag(championAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(championIconIndex))) {
+	if (getFlag(championAttributes, kDMChampionAttributeIcon) && (_vm->_eventMan->_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(championIconIndex))) {
 		_vm->_displayMan->fillScreenBox(_boxChampionIcons[championIconIndex], _championColor[champIndex]);
 		_vm->_displayMan->blitToBitmap(_vm->_displayMan->getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_bitmapScreen, _boxChampionIcons[championIconIndex], getChampionIconIndex(curChampion->_dir, _vm->_dungeonMan->_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
 	}
-	if (getFlag(championAttributes, k0x0800_ChampionAttributePanel) && isInventoryChampion) {
+	if (getFlag(championAttributes, kDMChampionAttributePanel) && isInventoryChampion) {
 		if (_vm->_pressingMouth)
 			_vm->_inventoryMan->drawPanelFoodWaterPoisoned();
 		else if (_vm->_pressingEye) {
@@ -2272,18 +2272,18 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		} else
 			_vm->_inventoryMan->drawPanel();
 
-		setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
+		setFlag(championAttributes, kDMChampionAttributeViewport);
 	}
-	if (getFlag(championAttributes, k0x8000_ChampionAttributeActionHand)) {
+	if (getFlag(championAttributes, kDMChampionAttributeActionHand)) {
 		drawSlot(champIndex, k1_ChampionSlotActionHand);
 		_vm->_menuMan->drawActionIcon(champIndex);
 		if (isInventoryChampion)
-			setFlag(championAttributes, k0x4000_ChampionAttributeViewport);
+			setFlag(championAttributes, kDMChampionAttributeViewport);
 	}
-	if (getFlag(championAttributes, k0x4000_ChampionAttributeViewport))
+	if (getFlag(championAttributes, kDMChampionAttributeViewport))
 		_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 
-	clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
+	clearFlag(curChampion->_attributes, kDMChampionAttributeNameTitle | kDMChampionAttributeStatistics | kDMChampionAttributeLoad | kDMChampionAttributeIcon | kDMChampionAttributePanel | kDMChampionAttributeStatusBox | kDMChampionAttributeWounds | kDMChampionAttributeViewport | kDMChampionAttributeActionHand);
 	_vm->_eventMan->hideMouse();
 }
 
@@ -2330,7 +2330,7 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 	int16 iconIndex;
 	if (thing == Thing::_none) {
 		if (slotIndex <= k5_ChampionSlotFeet) {
-			iconIndex = k212_IconIndiceReadyHand + (slotIndex << 1);
+			iconIndex = kDMIconIndiceReadyHand + (slotIndex << 1);
 			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) {
 				iconIndex++;
 				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
@@ -2338,13 +2338,13 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 				nativeBitmapIndex = k33_SlotBoxNormalIndice;
 		} else {
 			if ((slotIndex >= k10_ChampionSlotNeck) && (slotIndex <= k13_ChampionSlotBackpackLine_1_1))
-				iconIndex = k208_IconIndiceNeck + (slotIndex - k10_ChampionSlotNeck);
+				iconIndex = kDMIconIndiceNeck + (slotIndex - k10_ChampionSlotNeck);
 			else
-				iconIndex = k204_IconIndiceEmptyBox;
+				iconIndex = kDMIconIndiceEmptyBox;
 		}
 	} else {
 		iconIndex = _vm->_objectMan->getIconIndex(thing); // BUG0_35
-		if (isInventoryChamp && (slotIndex == k1_ChampionSlotActionHand) && ((iconIndex == k144_IconIndiceContainerChestClosed) || (iconIndex == k30_IconIndiceScrollOpen))) {
+		if (isInventoryChamp && (slotIndex == k1_ChampionSlotActionHand) && ((iconIndex == kDMIconIndiceContainerChestClosed) || (iconIndex == kDMIconIndiceScrollOpen))) {
 			iconIndex++;
 		} // BUG2_00
 		if (slotIndex <= k5_ChampionSlotFeet) {
@@ -2439,7 +2439,7 @@ void ChampionMan::renameChampion(Champion *champ) {
 						renamedChampionString[curCharacterIndex] = '\0';
 
 					bool found = false;
-					for (uint16 idx = k0_ChampionFirst; idx < _partyChampionCount - 1; idx++) {
+					for (uint16 idx = kDMChampionFirst; idx < _partyChampionCount - 1; idx++) {
 						if (!strcmp(_champions[idx]._name, renamedChampionString)) {
 							// If an existing champion already has the specified name for the new champion
 							found = true;
@@ -2548,9 +2548,9 @@ uint16 ChampionMan::getSkillLevel(int16 champIndex, uint16 skillIndex) {
 	if (_partyIsSleeping)
 		return 1;
 
-	bool ignoreTmpExp = getFlag(skillIndex, k0x8000_IgnoreTemporaryExperience);
-	bool ignoreObjModifiers = getFlag(skillIndex, k0x4000_IgnoreObjectModifiers);
-	clearFlag(skillIndex, k0x8000_IgnoreTemporaryExperience | k0x4000_IgnoreObjectModifiers);
+	bool ignoreTmpExp = getFlag(skillIndex, kDMIgnoreTemporaryExperience);
+	bool ignoreObjModifiers = getFlag(skillIndex, kDMIgnoreObjectModifiers);
+	clearFlag(skillIndex, kDMIgnoreTemporaryExperience | kDMIgnoreObjectModifiers);
 	Champion *champ = &_champions[champIndex];
 	Skill *skill = &champ->_skills[skillIndex];
 	int32 exp = skill->_experience;
@@ -2573,28 +2573,28 @@ uint16 ChampionMan::getSkillLevel(int16 champIndex, uint16 skillIndex) {
 	}
 	if (!ignoreObjModifiers) {
 		int16 actionHandIconIndex = _vm->_objectMan->getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
-		if (actionHandIconIndex == k27_IconIndiceWeaponTheFirestaff)
+		if (actionHandIconIndex == kDMIconIndiceWeaponTheFirestaff)
 			skillLevel++;
-		else if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete)
+		else if (actionHandIconIndex == kDMIconIndiceWeaponTheFirestaffComplete)
 			skillLevel += 2;
 
 		int16 neckIconIndex = _vm->_objectMan->getIconIndex(champ->_slots[k10_ChampionSlotNeck]);
 		switch (skillIndex) {
 		case k3_ChampionSkillWizard:
-			if (neckIconIndex == k124_IconIndiceJunkPendantFeral)
+			if (neckIconIndex == kDMIconIndiceJunkPendantFeral)
 				skillLevel += 1;
 			break;
 		case k13_ChampionSkillHeal:
 			// The skill modifiers of these two objects are not cumulative
-			if ((neckIconIndex == k120_IconIndiceJunkGemOfAges) || (actionHandIconIndex == k66_IconIndiceWeaponSceptreOfLyf))
+			if ((neckIconIndex == kDMIconIndiceJunkGemOfAges) || (actionHandIconIndex == kDMIconIndiceWeaponSceptreOfLyf))
 				skillLevel += 1;
 			break;
 		case k14_ChampionSkillInfluence:
-			if (neckIconIndex == k122_IconIndiceJunkMoonstone)
+			if (neckIconIndex == kDMIconIndiceJunkMoonstone)
 				skillLevel += 1;
 			break;
 		case k15_ChampionSkillDefend:
-			if (neckIconIndex == k121_IconIndiceJunkEkkhardCross)
+			if (neckIconIndex == kDMIconIndiceJunkEkkhardCross)
 				skillLevel += 1;
 			break;
 		default:
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index fe8f0fb..3ddf097 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -173,57 +173,57 @@ enum IconIndice {
 };
 
 enum ChampionIndex {
-	kM1_ChampionNone = -1, // @ CM1_CHAMPION_NONE
-	k0_ChampionFirst = 0, // @ C00_CHAMPION_FIRST
-	k1_ChampionSecond = 1,
-	k2_ChampionThird = 2,
-	k3_ChampionFourth = 3,
-	k4_ChampionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY
-	k5_ChampionSpecialInventory = 5 // @ C05_CHAMPION_SPECIAL_INVENTORY
+	kDMChampionNone = -1, // @ CM1_CHAMPION_NONE
+	kDMChampionFirst = 0, // @ C00_CHAMPION_FIRST
+	kDMChampionSecond = 1,
+	kDMChampionThird = 2,
+	kDMChampionFourth = 3,
+	kDMChampionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY
+	kDMChampionSpecialInventory = 5 // @ C05_CHAMPION_SPECIAL_INVENTORY
 };
 
 enum ChampionAttribute {
-	k0x0000_ChampionAttributNone = 0x0000, // @ MASK0x0000_NONE
-	k0x0008_ChampionAttributeDisableAction = 0x0008, // @ MASK0x0008_DISABLE_ACTION
-	k0x0010_ChampionAttributeMale = 0x0010, // @ MASK0x0010_MALE
-	k0x0080_ChampionAttributeNameTitle = 0x0080, // @ MASK0x0080_NAME_TITLE
-	k0x0100_ChampionAttributeStatistics = 0x0100, // @ MASK0x0100_STATISTICS
-	k0x0200_ChampionAttributeLoad = 0x0200, // @ MASK0x0200_LOAD
-	k0x0400_ChampionAttributeIcon = 0x0400, // @ MASK0x0400_ICON
-	k0x0800_ChampionAttributePanel = 0x0800, // @ MASK0x0800_PANEL
-	k0x1000_ChampionAttributeStatusBox = 0x1000, // @ MASK0x1000_STATUS_BOX
-	k0x2000_ChampionAttributeWounds = 0x2000, // @ MASK0x2000_WOUNDS
-	k0x4000_ChampionAttributeViewport = 0x4000, // @ MASK0x4000_VIEWPORT
-	k0x8000_ChampionAttributeActionHand = 0x8000 // @ MASK0x8000_ACTION_HAND
+	kDMChampionAttributNone = 0x0000, // @ MASK0x0000_NONE
+	kDMChampionAttributeDisableAction = 0x0008, // @ MASK0x0008_DISABLE_ACTION
+	kDMChampionAttributeMale = 0x0010, // @ MASK0x0010_MALE
+	kDMChampionAttributeNameTitle = 0x0080, // @ MASK0x0080_NAME_TITLE
+	kDMChampionAttributeStatistics = 0x0100, // @ MASK0x0100_STATISTICS
+	kDMChampionAttributeLoad = 0x0200, // @ MASK0x0200_LOAD
+	kDMChampionAttributeIcon = 0x0400, // @ MASK0x0400_ICON
+	kDMChampionAttributePanel = 0x0800, // @ MASK0x0800_PANEL
+	kDMChampionAttributeStatusBox = 0x1000, // @ MASK0x1000_STATUS_BOX
+	kDMChampionAttributeWounds = 0x2000, // @ MASK0x2000_WOUNDS
+	kDMChampionAttributeViewport = 0x4000, // @ MASK0x4000_VIEWPORT
+	kDMChampionAttributeActionHand = 0x8000 // @ MASK0x8000_ACTION_HAND
 };
 
 
 enum ChampionWound {
-	k0x0000_ChampionWoundNone = 0x0000, // @ MASK0x0000_NO_WOUND
-	k0x0001_ChampionWoundReadHand = 0x0001, // @ MASK0x0001_READY_HAND
-	k0x0002_ChampionWoundActionHand = 0x0002, // @ MASK0x0002_ACTION_HAND
-	k0x0004_ChampionWoundHead = 0x0004, // @ MASK0x0004_HEAD
-	k0x0008_ChampionWoundTorso = 0x0008, // @ MASK0x0008_TORSO
-	k0x0010_ChampionWoundLegs = 0x0010, // @ MASK0x0010_LEGS
-	k0x0020_ChampionWoundFeet = 0x0020 // @ MASK0x0020_FEET
+	kDMChampionWoundNone = 0x0000, // @ MASK0x0000_NO_WOUND
+	kDMChampionWoundReadHand = 0x0001, // @ MASK0x0001_READY_HAND
+	kDMChampionWoundActionHand = 0x0002, // @ MASK0x0002_ACTION_HAND
+	kDMChampionWoundHead = 0x0004, // @ MASK0x0004_HEAD
+	kDMChampionWoundTorso = 0x0008, // @ MASK0x0008_TORSO
+	kDMChampionWoundLegs = 0x0010, // @ MASK0x0010_LEGS
+	kDMChampionWoundFeet = 0x0020 // @ MASK0x0020_FEET
 };
 
 
 enum ChampionStatisticType {
-	k0_ChampionStatLuck = 0, // @ C0_STATISTIC_LUCK
-	k1_ChampionStatStrength = 1, // @ C1_STATISTIC_STRENGTH
-	k2_ChampionStatDexterity = 2, // @ C2_STATISTIC_DEXTERITY
-	k3_ChampionStatWisdom = 3, // @ C3_STATISTIC_WISDOM
-	k4_ChampionStatVitality = 4, // @ C4_STATISTIC_VITALITY
-	k5_ChampionStatAntimagic = 5, // @ C5_STATISTIC_ANTIMAGIC
-	k6_ChampionStatAntifire = 6, // @ C6_STATISTIC_ANTIFIRE
-	k8_ChampionStatMana = 8 // @ C8_STATISTIC_MANA /* Used as a fake statistic index for objects granting a Mana bonus */
+	kDMChampionStatLuck = 0, // @ C0_STATISTIC_LUCK
+	kDMChampionStatStrength = 1, // @ C1_STATISTIC_STRENGTH
+	kDMChampionStatDexterity = 2, // @ C2_STATISTIC_DEXTERITY
+	kDMChampionStatWisdom = 3, // @ C3_STATISTIC_WISDOM
+	kDMChampionStatVitality = 4, // @ C4_STATISTIC_VITALITY
+	kDMChampionStatAntimagic = 5, // @ C5_STATISTIC_ANTIMAGIC
+	kDMChampionStatAntifire = 6, // @ C6_STATISTIC_ANTIFIRE
+	kDMChampionStatMana = 8 // @ C8_STATISTIC_MANA /* Used as a fake statistic index for objects granting a Mana bonus */
 };
 
 enum ChampionStatisticValue {
-	k0_ChampionStatMaximum = 0, // @ C0_MAXIMUM
-	k1_ChampionStatCurrent = 1, // @ C1_CURRENT
-	k2_ChampionStatMinimum = 2 // @ C2_MINIMUM
+	kDMChampionStatMaximum = 0, // @ C0_MAXIMUM
+	kDMChampionStatCurrent = 1, // @ C1_CURRENT
+	kDMChampionStatMinimum = 2 // @ C2_MINIMUM
 };
 
 enum ChampionSkill {
@@ -339,14 +339,16 @@ enum ChampionAction {
 	k255_ChampionActionNone = 255 // @ C255_ACTION_NONE
 };
 
-#define k0_attackType_NORMAL 0 // @ C0_ATTACK_NORMAL
-#define k1_attackType_FIRE 1 // @ C1_ATTACK_FIRE
-#define k2_attackType_SELF 2 // @ C2_ATTACK_SELF
-#define k3_attackType_BLUNT 3 // @ C3_ATTACK_BLUNT
-#define k4_attackType_SHARP 4 // @ C4_ATTACK_SHARP
-#define k5_attackType_MAGIC 5 // @ C5_ATTACK_MAGIC
-#define k6_attackType_PSYCHIC 6 // @ C6_ATTACK_PSYCHIC
-#define k7_attackType_LIGHTNING 7 // @ C7_ATTACK_LIGHTNING
+enum AttackType {
+	k0_attackType_NORMAL = 0, // @ C0_ATTACK_NORMAL
+	k1_attackType_FIRE = 1, // @ C1_ATTACK_FIRE
+	k2_attackType_SELF = 2, // @ C2_ATTACK_SELF
+	k3_attackType_BLUNT = 3, // @ C3_ATTACK_BLUNT
+	k4_attackType_SHARP = 4, // @ C4_ATTACK_SHARP
+	k5_attackType_MAGIC = 5, // @ C5_ATTACK_MAGIC
+	k6_attackType_PSYCHIC = 6, // @ C6_ATTACK_PSYCHIC
+	k7_attackType_LIGHTNING = 7 // @ C7_ATTACK_LIGHTNING
+};
 
 class Skill {
 public:
@@ -401,12 +403,12 @@ public:
 	uint16 getAttributes() { return _attributes; }
 	uint16 getAttributes(ChampionAttribute flag) { return _attributes & flag; }
 	void setAttributeFlag(ChampionAttribute flag, bool value);
-	void clearAttributes(ChampionAttribute attribute = k0x0000_ChampionAttributNone) { _attributes = attribute; }
+	void clearAttributes(ChampionAttribute attribute = kDMChampionAttributNone) { _attributes = attribute; }
 
 	uint16 getWounds() { return _wounds; }
 	void setWoundsFlag(ChampionWound flag, bool value);
 	uint16 getWoundsFlag(ChampionWound wound) { return _wounds & wound; }
-	void clearWounds() { _wounds = k0x0000_ChampionWoundNone; }
+	void clearWounds() { _wounds = kDMChampionWoundNone; }
 	void resetSkillsToZero() {
 		for (int16 i = 0; i < 20; ++i)
 			_skills[i].resetToZero();
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 443a39d..a20293c 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -318,9 +318,9 @@ void DMEngine::startGame() {
 	_highlightBoxInversionRequested = false;
 	_eventMan->_highlightBoxEnabled = false;
 	_championMan->_partyIsSleeping = false;
-	_championMan->_actingChampionOrdinal = indexToOrdinal(kM1_ChampionNone);
+	_championMan->_actingChampionOrdinal = indexToOrdinal(kDMChampionNone);
 	_menuMan->_actionAreaContainsIcons = true;
-	_eventMan->_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kM1_ChampionNone);
+	_eventMan->_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kDMChampionNone);
 
 	_eventMan->_primaryMouseInput = _eventMan->_primaryMouseInputInterface;
 	_eventMan->_secondaryMouseInput = _eventMan->_secondaryMouseInputMovement;
@@ -643,7 +643,7 @@ void DMEngine::endGame(bool doNotDrawCreditsOnly) {
 		if (_gameWon) {
 			// Strangerke: Related to portraits. Game data could be missing for earlier versions of the game.
 			_displayMan->fillScreen(k12_ColorDarkestGray);
-			for (int16 championIndex = k0_ChampionFirst; championIndex < _championMan->_partyChampionCount; championIndex++) {
+			for (int16 championIndex = kDMChampionFirst; championIndex < _championMan->_partyChampionCount; championIndex++) {
 				int16 textPosY = championIndex * 48;
 				Champion *curChampion = &_championMan->_champions[championIndex];
 				_displayMan->blitToScreen(_displayMan->getNativeBitmapOrGraphic(k208_wallOrn_43_champMirror), &championMirrorBox, k32_byteWidth, k10_ColorFlesh, 43);
@@ -917,7 +917,7 @@ void DMEngine::entranceDrawCredits() {
 void DMEngine::fuseSequence() {
 	_gameWon = true;
 	if (_inventoryMan->_inventoryChampionOrdinal)
-		_inventoryMan->toggleInventory(k4_ChampionCloseInventory);
+		_inventoryMan->toggleInventory(kDMChampionCloseInventory);
 
 	_eventMan->highlightBoxDisable();
 	_championMan->_party._magicalLightAmount = 200;
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index d2ee2f8..fdf66b7 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -469,7 +469,7 @@ void EventManager::setPointerToObject(byte *bitmap) {
 void EventManager::mouseDropChampionIcon() {
 	_preventBuildPointerScreenArea = true;
 	uint16 championIconIndex = _vm->ordinalToIndex(_useChampionIconOrdinalAsMousePointerBitmap);
-	_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kM1_ChampionNone);
+	_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kDMChampionNone);
 	_mousePointerBitmapUpdated = true;
 	bool useByteBoxCoordinatesBackup = _vm->_displayMan->_useByteBoxCoordinates;
 	_vm->_displayMan->blitToScreen(_mousePointerOriginalColorsChampionIcon, &_vm->_championMan->_boxChampionIcons[championIconIndex << 2], 16, k12_ColorDarkestGray, 18);
@@ -577,7 +577,7 @@ void EventManager::buildpointerScreenArea(int16 mousePosX, int16 mousePosY) {
 
 void EventManager::setMousePointer() {
 	if (_vm->_championMan->_leaderEmptyHanded)
-		setMousePointerToNormal((_vm->_championMan->_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
+		setMousePointerToNormal((_vm->_championMan->_leaderIndex == kDMChampionNone) ? k0_pointerArrow : k1_pointerHand);
 	else
 		setPointerToObject(_vm->_objectMan->_objectIconForMousePointer);
 }
@@ -763,7 +763,7 @@ void EventManager::processCommandQueue() {
 	}
 
 	if ((cmdType >= k28_CommandClickOnSlotBoxInventoryReadyHand) && (cmdType < (k65_CommandClickOnSlotBoxChest_8 + 1))) {
-		if (_vm->_championMan->_leaderIndex != kM1_ChampionNone)
+		if (_vm->_championMan->_leaderIndex != kDMChampionNone)
 			_vm->_championMan->clickOnSlotBox(cmdType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);
 
 		return;
@@ -779,21 +779,21 @@ void EventManager::processCommandQueue() {
 		}
 
 		int16 championIndex = cmdType - k7_CommandToggleInventoryChampion_0;
-		if (((championIndex == k4_ChampionCloseInventory) || (championIndex < _vm->_championMan->_partyChampionCount)) && !_vm->_championMan->_candidateChampionOrdinal)
+		if (((championIndex == kDMChampionCloseInventory) || (championIndex < _vm->_championMan->_partyChampionCount)) && !_vm->_championMan->_candidateChampionOrdinal)
 			_vm->_inventoryMan->toggleInventory((ChampionIndex)championIndex);
 
 		return;
 	}
 
 	if (cmdType == k83_CommandToggleInventoryLeader) {
-		if (_vm->_championMan->_leaderIndex != kM1_ChampionNone)
+		if (_vm->_championMan->_leaderIndex != kDMChampionNone)
 			_vm->_inventoryMan->toggleInventory(_vm->_championMan->_leaderIndex);
 
 		return;
 	}
 
 	if (cmdType == k100_CommandClickInSpellArea) {
-		if ((!_vm->_championMan->_candidateChampionOrdinal) && (_vm->_championMan->_magicCasterChampionIndex != kM1_ChampionNone))
+		if ((!_vm->_championMan->_candidateChampionOrdinal) && (_vm->_championMan->_magicCasterChampionIndex != kDMChampionNone))
 			commandProcessType100_clickInSpellArea(commandX, commandY);
 
 		return;
@@ -831,7 +831,7 @@ void EventManager::processCommandQueue() {
 	if (cmdType == k145_CommandSleep) {
 		if (!_vm->_championMan->_candidateChampionOrdinal) {
 			if (_vm->_inventoryMan->_inventoryChampionOrdinal)
-				_vm->_inventoryMan->toggleInventory(k4_ChampionCloseInventory);
+				_vm->_inventoryMan->toggleInventory(kDMChampionCloseInventory);
 
 			_vm->_menuMan->drawDisabledMenu();
 			_vm->_championMan->_partyIsSleeping = true;
@@ -970,7 +970,7 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 
 	_vm->_stopWaitingForPlayerInput = true;
 	Champion *championsPtr = _vm->_championMan->_champions;
-	for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_partyChampionCount; idx++) {
+	for (uint16 idx = kDMChampionFirst; idx < _vm->_championMan->_partyChampionCount; idx++) {
 		_vm->_championMan->decrementStamina(idx, ((championsPtr->_load * 3) / _vm->_championMan->getMaximumLoad(championsPtr)) + 1); /* BUG0_50 When a champion is brought back to life at a Vi Altar, his current stamina is lower than what it was before dying. Each time the party moves the current stamina of all champions is decreased, including for dead champions, by an amount that depends on the current load of the champion. For a dead champion the load before he died is used */
 		championsPtr++;
 	}
@@ -1009,9 +1009,9 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 			movementArrowIdx += (_vm->_dungeonMan->_partyDir + 2);
 			int16 L1124_i_FirstDamagedChampionIndex = _vm->_championMan->getTargetChampionIndex(partyMapX, partyMapY, normalizeModulo4(movementArrowIdx));
 			int16 L1125_i_SecondDamagedChampionIndex = _vm->_championMan->getTargetChampionIndex(partyMapX, partyMapY, returnNextVal(movementArrowIdx));
-			int16 damage = _vm->_championMan->addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
+			int16 damage = _vm->_championMan->addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex, 1, kDMChampionWoundTorso | kDMChampionWoundLegs, k2_attackType_SELF);
 			if (L1124_i_FirstDamagedChampionIndex != L1125_i_SecondDamagedChampionIndex)
-				damage |= _vm->_championMan->addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF);
+				damage |= _vm->_championMan->addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, kDMChampionWoundTorso | kDMChampionWoundLegs, k2_attackType_SELF);
 
 			if (damage)
 				_vm->_sound->requestPlay(k18_soundPARTY_DAMAGED, partyMapX, partyMapY, k0_soundModePlayImmediately);
@@ -1036,7 +1036,7 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 
 	uint16 disabledMovtTicks = 1;
 	championsPtr = _vm->_championMan->_champions;
-	for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_partyChampionCount; idx++) {
+	for (uint16 idx = kDMChampionFirst; idx < _vm->_championMan->_partyChampionCount; idx++) {
 		if (championsPtr->_currHealth)
 			disabledMovtTicks = MAX((int32)disabledMovtTicks, (int32)_vm->_championMan->getMovementTicks(championsPtr));
 
@@ -1105,19 +1105,19 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
 	ChampionMan &cm = *_vm->_championMan;
 	ChampionIndex leaderIndex;
 
-	if ((cm._leaderIndex == champIndex) || ((champIndex != kM1_ChampionNone) && !cm._champions[champIndex]._currHealth))
+	if ((cm._leaderIndex == champIndex) || ((champIndex != kDMChampionNone) && !cm._champions[champIndex]._currHealth))
 		return;
 
-	if (cm._leaderIndex != kM1_ChampionNone) {
+	if (cm._leaderIndex != kDMChampionNone) {
 		leaderIndex = cm._leaderIndex;
-		cm._champions[leaderIndex].setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
-		cm._champions[leaderIndex].setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
+		cm._champions[leaderIndex].setAttributeFlag(kDMChampionAttributeLoad, true);
+		cm._champions[leaderIndex].setAttributeFlag(kDMChampionAttributeNameTitle, true);
 		cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject);
-		cm._leaderIndex = kM1_ChampionNone;
+		cm._leaderIndex = kDMChampionNone;
 		cm.drawChampionState(leaderIndex);
 	}
-	if (champIndex == kM1_ChampionNone) {
-		cm._leaderIndex = kM1_ChampionNone;
+	if (champIndex == kDMChampionNone) {
+		cm._leaderIndex = kDMChampionNone;
 		return;
 	}
 	cm._leaderIndex = champIndex;
@@ -1125,8 +1125,8 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
 	champion->_dir = _vm->_dungeonMan->_partyDir;
 	cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject);
 	if (_vm->indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) {
-		champion->setAttributeFlag(k0x0400_ChampionAttributeIcon, true);
-		champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
+		champion->setAttributeFlag(kDMChampionAttributeIcon, true);
+		champion->setAttributeFlag(kDMChampionAttributeNameTitle, true);
 		cm.drawChampionState(champIndex);
 	}
 }
@@ -1150,7 +1150,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
 	};
 
 	if (_vm->_dungeonMan->_squareAheadElement == k17_ElementTypeDoorFront) {
-		if (_vm->_championMan->_leaderIndex == kM1_ChampionNone)
+		if (_vm->_championMan->_leaderIndex == kDMChampionNone)
 			return;
 
 		int16 L1155_i_MapX = _vm->_dungeonMan->_partyMapX + _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir];
@@ -1234,10 +1234,10 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	uint16 championIndex = champMan._partyChampionCount - 1;
 	Champion *champ = &champMan._champions[championIndex];
 	if (commandType == k162_CommandClickInPanelCancel) {
-		invMan.toggleInventory(k4_ChampionCloseInventory);
-		champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
+		invMan.toggleInventory(kDMChampionCloseInventory);
+		champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kDMChampionNone);
 		if (champMan._partyChampionCount == 1) {
-			commandSetLeader(kM1_ChampionNone);
+			commandSetLeader(kDMChampionNone);
 		}
 		champMan._partyChampionCount--;
 		Box box;
@@ -1253,7 +1253,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 		return;
 	}
 
-	champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
+	champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kDMChampionNone);
 	int16 mapX = dunMan._partyMapX + _vm->_dirIntoStepCountEast[dunMan._partyDir];
 	int16 mapY = dunMan._partyMapY + _vm->_dirIntoStepCountNorth[dunMan._partyDir];
 
@@ -1280,15 +1280,15 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 
 		for (uint16 i = 0; i < 12; i++) {
 			uint16 statIndex = _vm->getRandomNumber(7);
-			champ->getStatistic((ChampionStatisticType)statIndex, k1_ChampionStatCurrent)++; // returns reference
-			champ->getStatistic((ChampionStatisticType)statIndex, k0_ChampionStatMaximum)++; // returns reference
+			champ->getStatistic((ChampionStatisticType)statIndex, kDMChampionStatCurrent)++; // returns reference
+			champ->getStatistic((ChampionStatisticType)statIndex, kDMChampionStatMaximum)++; // returns reference
 		}
 	}
 
 	if (champMan._partyChampionCount == 1) {
 		_vm->_projexpl->_lastPartyMovementTime = _vm->_gameTime;
-		commandSetLeader(k0_ChampionFirst);
-		_vm->_menuMan->setMagicCasterAndDrawSpellArea(k0_ChampionFirst);
+		commandSetLeader(kDMChampionFirst);
+		_vm->_menuMan->setMagicCasterAndDrawSpellArea(kDMChampionFirst);
 	} else
 		_vm->_menuMan->drawSpellAreaControls(champMan._magicCasterChampionIndex);
 
@@ -1309,9 +1309,9 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 		break;
 	}
 
-	invMan.toggleInventory(k4_ChampionCloseInventory);
+	invMan.toggleInventory(kDMChampionCloseInventory);
 	_vm->_menuMan->drawEnabledMenus();
-	setMousePointerToNormal((_vm->_championMan->_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand);
+	setMousePointerToNormal((_vm->_championMan->_leaderIndex == kDMChampionNone) ? k0_pointerArrow : k1_pointerHand);
 }
 
 void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) {
@@ -1321,7 +1321,7 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) {
 	CommandType commandType;
 	switch (invMan._panelContent) {
 	case k4_PanelContentChest:
-		if (champMan._leaderIndex == kM1_ChampionNone) // if no leader
+		if (champMan._leaderIndex == kDMChampionNone) // if no leader
 			return;
 		commandType = getCommandTypeFromMouseInput(_mouseInputPanelChest, Common::Point(x, y), k1_LeftMouseButton);
 		if (commandType != k0_CommandNone)
@@ -1340,7 +1340,7 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) {
 }
 
 void EventManager::processType80_clickInDungeonView_grabLeaderHandObject(uint16 viewCell) {
-	if (_vm->_championMan->_leaderIndex == kM1_ChampionNone)
+	if (_vm->_championMan->_leaderIndex == kDMChampionNone)
 		return;
 
 	int16 mapX = _vm->_dungeonMan->_partyMapX;
@@ -1365,7 +1365,7 @@ void EventManager::processType80_clickInDungeonView_grabLeaderHandObject(uint16
 }
 
 void EventManager::processType80_clickInDungeonViewDropLeaderHandObject(uint16 viewCell) {
-	if (_vm->_championMan->_leaderIndex == kM1_ChampionNone)
+	if (_vm->_championMan->_leaderIndex == kDMChampionNone)
 		return;
 
 	int16 mapX = _vm->_dungeonMan->_partyMapX;
@@ -1454,7 +1454,7 @@ void EventManager::mouseProcessCommands125To128_clickOnChampionIcon(uint16 champ
 
 	_preventBuildPointerScreenArea = true;
 	if (!_useChampionIconOrdinalAsMousePointerBitmap) {
-		if (_vm->_championMan->getIndexInCell(normalizeModulo4(champIconIndex + _vm->_dungeonMan->_partyDir)) == kM1_ChampionNone) {
+		if (_vm->_championMan->getIndexInCell(normalizeModulo4(champIconIndex + _vm->_dungeonMan->_partyDir)) == kDMChampionNone) {
 			_preventBuildPointerScreenArea = false;
 			return;
 		}
@@ -1473,22 +1473,22 @@ void EventManager::mouseProcessCommands125To128_clickOnChampionIcon(uint16 champ
 	} else {
 		_mousePointerBitmapUpdated = true;
 		uint16 championIconIndex = _vm->ordinalToIndex(_useChampionIconOrdinalAsMousePointerBitmap);
-		_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kM1_ChampionNone);
+		_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kDMChampionNone);
 		int16 championCellIndex = _vm->_championMan->getIndexInCell(normalizeModulo4(championIconIndex + _vm->_dungeonMan->_partyDir));
 		if (championIconIndex == champIconIndex) {
-			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, k0x0400_ChampionAttributeIcon);
+			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, kDMChampionAttributeIcon);
 			_vm->_championMan->drawChampionState((ChampionIndex)championCellIndex);
 		} else {
 			int16 championIndex = _vm->_championMan->getIndexInCell(normalizeModulo4(champIconIndex + _vm->_dungeonMan->_partyDir));
 			if (championIndex >= 0) {
 				_vm->_championMan->_champions[championIndex]._cell = (ViewCell)normalizeModulo4(championIconIndex + _vm->_dungeonMan->_partyDir);
-				setFlag(_vm->_championMan->_champions[championIndex]._attributes, k0x0400_ChampionAttributeIcon);
+				setFlag(_vm->_championMan->_champions[championIndex]._attributes, kDMChampionAttributeIcon);
 				_vm->_championMan->drawChampionState((ChampionIndex)championIndex);
 			} else
 				_vm->_displayMan->fillScreenBox(_vm->_championMan->_boxChampionIcons[championIconIndex], k0_ColorBlack);
 
 			_vm->_championMan->_champions[championCellIndex]._cell = (ViewCell)normalizeModulo4(champIconIndex + _vm->_dungeonMan->_partyDir);
-			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, k0x0400_ChampionAttributeIcon);
+			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, kDMChampionAttributeIcon);
 			_vm->_championMan->drawChampionState((ChampionIndex)championCellIndex);
 		}
 	}
@@ -1497,49 +1497,49 @@ void EventManager::mouseProcessCommands125To128_clickOnChampionIcon(uint16 champ
 }
 
 void EventManager::commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY) {
-	ChampionIndex championIndex = kM1_ChampionNone;
+	ChampionIndex championIndex = kDMChampionNone;
 	if (posY <= 48) {
 		switch (_vm->_championMan->_magicCasterChampionIndex) {
 		case 0:
 			if ((posX >= 280) && (posX <= 291))
-				championIndex = k1_ChampionSecond;
+				championIndex = kDMChampionSecond;
 			else if ((posX >= 294) && (posX <= 305))
-				championIndex = k2_ChampionThird;
+				championIndex = kDMChampionThird;
 			else if (posX >= 308)
-				championIndex = k3_ChampionFourth;
+				championIndex = kDMChampionFourth;
 
 			break;
 		case 1:
 			if ((posX >= 233) && (posX <= 244))
-				championIndex = k0_ChampionFirst;
+				championIndex = kDMChampionFirst;
 			else if ((posX >= 294) && (posX <= 305))
-				championIndex = k2_ChampionThird;
+				championIndex = kDMChampionThird;
 			else if (posX >= 308)
-				championIndex = k3_ChampionFourth;
+				championIndex = kDMChampionFourth;
 
 			break;
 		case 2:
 			if ((posX >= 233) && (posX <= 244))
-				championIndex = k0_ChampionFirst;
+				championIndex = kDMChampionFirst;
 			else if ((posX >= 247) && (posX <= 258))
-				championIndex = k1_ChampionSecond;
+				championIndex = kDMChampionSecond;
 			else if (posX >= 308)
-				championIndex = k3_ChampionFourth;
+				championIndex = kDMChampionFourth;
 
 			break;
 		case 3:
 			if ((posX >= 247) && (posX <= 258))
-				championIndex = k1_ChampionSecond;
+				championIndex = kDMChampionSecond;
 			else if ((posX >= 261) && (posX <= 272))
-				championIndex = k2_ChampionThird;
+				championIndex = kDMChampionThird;
 			else if (posX <= 244)
-				championIndex = k0_ChampionFirst;
+				championIndex = kDMChampionFirst;
 			break;
 		default:
 			break;
 		}
 
-		if ((championIndex != kM1_ChampionNone) && (championIndex < _vm->_championMan->_partyChampionCount))
+		if ((championIndex != kDMChampionNone) && (championIndex < _vm->_championMan->_partyChampionCount))
 			_vm->_menuMan->setMagicCasterAndDrawSpellArea(championIndex);
 
 		return;
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index bb0bab1..78c76b8 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1613,7 +1613,7 @@ int16 GroupMan::getChampionDamage(Group *group, uint16 champIndex) {
 
 			uint16 poisonAttack = creatureInfo._poisonAttack;
 			if (poisonAttack && _vm->getRandomNumber(2)) {
-				poisonAttack = _vm->_championMan->getStatisticAdjustedAttack(curChampion, k4_ChampionStatVitality, poisonAttack);
+				poisonAttack = _vm->_championMan->getStatisticAdjustedAttack(curChampion, kDMChampionStatVitality, poisonAttack);
 				if (poisonAttack >= 0)
 					_vm->_championMan->championPoison(champIndex, poisonAttack);
 			}
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 9435a8b..e5540b5 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -86,7 +86,7 @@ InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
 void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	static Box boxFloppyZzzCross(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
 
-	if ((championIndex != k4_ChampionCloseInventory) && !_vm->_championMan->_champions[championIndex]._currHealth)
+	if ((championIndex != kDMChampionCloseInventory) && !_vm->_championMan->_champions[championIndex]._currHealth)
 		return;
 
 	if (_vm->_pressingMouth || _vm->_pressingEye)
@@ -95,22 +95,22 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	_vm->_stopWaitingForPlayerInput = true;
 	uint16 inventoryChampionOrdinal = _inventoryChampionOrdinal;
 	if (_vm->indexToOrdinal(championIndex) == inventoryChampionOrdinal)
-		championIndex = k4_ChampionCloseInventory;
+		championIndex = kDMChampionCloseInventory;
 
 	_vm->_eventMan->showMouse();
 	if (inventoryChampionOrdinal) {
-		_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
+		_inventoryChampionOrdinal = _vm->indexToOrdinal(kDMChampionNone);
 		closeChest();
 		Champion *champion = &_vm->_championMan->_champions[_vm->ordinalToIndex(inventoryChampionOrdinal)];
 		if (champion->_currHealth && !_vm->_championMan->_candidateChampionOrdinal) {
-			setFlag(champion->_attributes, k0x1000_ChampionAttributeStatusBox);
+			setFlag(champion->_attributes, kDMChampionAttributeStatusBox);
 			_vm->_championMan->drawChampionState((ChampionIndex)_vm->ordinalToIndex(inventoryChampionOrdinal));
 		}
 		if (_vm->_championMan->_partyIsSleeping) {
 			_vm->_eventMan->hideMouse();
 			return;
 		}
-		if (championIndex == k4_ChampionCloseInventory) {
+		if (championIndex == kDMChampionCloseInventory) {
 			_vm->_eventMan->_refreshMousePointerInMainLoop = true;
 			_vm->_menuMan->drawMovementArrows();
 			_vm->_eventMan->hideMouse();
@@ -152,7 +152,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	for (uint16 i = k0_ChampionSlotReadyHand; i < k30_ChampionSlotChest_1; i++)
 		_vm->_championMan->drawSlot(championIndex, i);
 
-	setFlag(champion->_attributes, k0x4000_ChampionAttributeViewport | k0x1000_ChampionAttributeStatusBox | k0x0800_ChampionAttributePanel | k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics | k0x0080_ChampionAttributeNameTitle);
+	setFlag(champion->_attributes, kDMChampionAttributeViewport | kDMChampionAttributeStatusBox | kDMChampionAttributePanel | kDMChampionAttributeLoad | kDMChampionAttributeStatistics | kDMChampionAttributeNameTitle);
 	_vm->_championMan->drawChampionState(championIndex);
 	_vm->_eventMan->_mousePointerBitmapUpdated = true;
 	_vm->_eventMan->hideMouse();
@@ -822,10 +822,10 @@ void InventoryMan::drawChampionSkillsAndStatistics() {
 		textPosY += 7;
 	}
 	textPosY = 86;
-	for (uint16 idx = k1_ChampionStatStrength; idx <= k6_ChampionStatAntifire; idx++) {
+	for (uint16 idx = kDMChampionStatStrength; idx <= kDMChampionStatAntifire; idx++) {
 		_vm->_textMan->printToViewport(108, textPosY, k13_ColorLightestGray, statisticNames[idx]);
-		int16 statisticCurrentValue = curChampion->_statistics[idx][k1_ChampionStatCurrent];
-		uint16 statisticMaximumValue = curChampion->_statistics[idx][k0_ChampionStatMaximum];
+		int16 statisticCurrentValue = curChampion->_statistics[idx][kDMChampionStatCurrent];
+		uint16 statisticMaximumValue = curChampion->_statistics[idx][kDMChampionStatMaximum];
 		int16 statisticColor;
 		if (statisticCurrentValue < statisticMaximumValue)
 			statisticColor = k8_ColorRed;
@@ -932,16 +932,16 @@ void InventoryMan::clickOnMouth() {
 
 		switch (((Potion *)junkData)->getType()) {
 		case k6_PotionTypeRos:
-			adjustStatisticCurrentValue(curChampion, k2_ChampionStatDexterity, adjustedPotionPower);
+			adjustStatisticCurrentValue(curChampion, kDMChampionStatDexterity, adjustedPotionPower);
 			break;
 		case k7_PotionTypeKu:
-			adjustStatisticCurrentValue(curChampion, k1_ChampionStatStrength, (((Potion *)junkData)->getPower() / 35) + 5); /* Value between 5 and 12 */
+			adjustStatisticCurrentValue(curChampion, kDMChampionStatStrength, (((Potion *)junkData)->getPower() / 35) + 5); /* Value between 5 and 12 */
 			break;
 		case k8_PotionTypeDane:
-			adjustStatisticCurrentValue(curChampion, k3_ChampionStatWisdom, adjustedPotionPower);
+			adjustStatisticCurrentValue(curChampion, kDMChampionStatWisdom, adjustedPotionPower);
 			break;
 		case k9_PotionTypeNeta:
-			adjustStatisticCurrentValue(curChampion, k4_ChampionStatVitality, adjustedPotionPower);
+			adjustStatisticCurrentValue(curChampion, kDMChampionStatVitality, adjustedPotionPower);
 			break;
 		case k10_PotionTypeAntivenin:
 			_vm->_championMan->unpoison(championIndex);
@@ -961,7 +961,7 @@ void InventoryMan::clickOnMouth() {
 			newEvent._priority = championIndex;
 			newEvent._B._defense = adjustedPotionPower;
 			_vm->_timeline->addEventGetEventIndex(&newEvent);
-			setFlag(curChampion->_attributes, k0x1000_ChampionAttributeStatusBox);
+			setFlag(curChampion->_attributes, kDMChampionAttributeStatusBox);
 			}
 			break;
 		case k13_PotionTypeEe: {
@@ -985,7 +985,7 @@ void InventoryMan::clickOnMouth() {
 					healWoundIterationCount = 1;
 				} while ((wounds == curChampion->_wounds) && --counter); /* Loop until at least one wound is healed or there are no more heal iterations */
 			}
-			setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad | k0x2000_ChampionAttributeWounds);
+			setFlag(curChampion->_attributes, kDMChampionAttributeLoad | kDMChampionAttributeWounds);
 			}
 			break;
 		case k15_PotionTypeWaterFlask:
@@ -1015,13 +1015,13 @@ void InventoryMan::clickOnMouth() {
 	} else {
 		_vm->_championMan->drawChangedObjectIcons();
 		_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(handThing) - handThingWeight;
-		setFlag(_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
+		setFlag(_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._attributes, kDMChampionAttributeLoad);
 	}
 	_vm->_sound->requestPlay(k08_soundSWALLOW, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
-	setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+	setFlag(curChampion->_attributes, kDMChampionAttributeStatistics);
 
 	if (_panelContent == k0_PanelContentFoodWaterPoisoned)
-		setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel);
+		setFlag(curChampion->_attributes, kDMChampionAttributePanel);
 
 	_vm->_championMan->drawChampionState((ChampionIndex)championIndex);
 	_vm->_eventMan->hideMouse();
@@ -1030,7 +1030,7 @@ void InventoryMan::clickOnMouth() {
 void InventoryMan::adjustStatisticCurrentValue(Champion *champ, uint16 statIndex, int16 valueDelta) {
 	int16 delta;
 	if (valueDelta >= 0) {
-		int16 currentValue = champ->_statistics[statIndex][k1_ChampionStatCurrent];
+		int16 currentValue = champ->_statistics[statIndex][kDMChampionStatCurrent];
 		if (currentValue > 120) {
 			valueDelta >>= 1;
 			if (currentValue > 150) {
@@ -1040,9 +1040,9 @@ void InventoryMan::adjustStatisticCurrentValue(Champion *champ, uint16 statIndex
 		}
 		delta = MIN(valueDelta, (int16)(170 - currentValue));
 	} else { /* BUG0_00 Useless code. The function is always called with valueDelta having a positive value */
-		delta = MAX(valueDelta, int16(champ->_statistics[statIndex][k2_ChampionStatMinimum] - champ->_statistics[statIndex][k1_ChampionStatCurrent]));
+		delta = MAX(valueDelta, int16(champ->_statistics[statIndex][kDMChampionStatMinimum] - champ->_statistics[statIndex][kDMChampionStatCurrent]));
 	}
-	champ->_statistics[statIndex][k1_ChampionStatCurrent] += delta;
+	champ->_statistics[statIndex][kDMChampionStatCurrent] += delta;
 }
 
 void InventoryMan::clickOnEye() {
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 81a341b..bcbe89f 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -175,9 +175,9 @@ void MenuMan::clearActingChampion() {
 	ChampionMan &cm = *_vm->_championMan;
 	if (cm._actingChampionOrdinal) {
 		cm._actingChampionOrdinal--;
-		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
+		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kDMChampionAttributeActionHand, true);
 		cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal);
-		cm._actingChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
+		cm._actingChampionOrdinal = _vm->indexToOrdinal(kDMChampionNone);
 		_refreshActionArea = true;
 	}
 }
@@ -221,7 +221,7 @@ T0386006:
 	box2._y1 = 95;
 	box2._y2 = 110;
 	dm.blitToScreen(bitmapIcon, &box2, k8_byteWidth, kM1_ColorNoTransparency, 16);
-	if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) {
+	if (champion.getAttributes(kDMChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) {
 		_vm->_displayMan->shadeScreenBox(&box, k0_ColorBlack);
 	}
 }
@@ -259,7 +259,7 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
 			return;
 	} else {
 		champ = champMan._champions;
-		int16 champIndex = k0_ChampionFirst;
+		int16 champIndex = kDMChampionFirst;
 
 		do {
 			if ((champIndex != champMan._leaderIndex)
@@ -268,7 +268,7 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
 				&& (champ->_dir != champ->_directionMaximumDamageReceived)) {
 
 				champ->_dir = (Direction)champ->_directionMaximumDamageReceived;
-				champ->setAttributeFlag(k0x0400_ChampionAttributeIcon, true);
+				champ->setAttributeFlag(kDMChampionAttributeIcon, true);
 				champMan.drawChampionState((ChampionIndex)champIndex);
 			}
 			champ->_maximumDamageReceived = 0;
@@ -288,7 +288,7 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
 			}
 		} else {
 			_actionAreaContainsIcons = false;
-			champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true);
+			champ->setAttributeFlag(kDMChampionAttributeActionHand, true);
 			champMan.drawChampionState((ChampionIndex)_vm->ordinalToIndex(champMan._actingChampionOrdinal));
 			drawActionArea();
 		}
@@ -307,7 +307,7 @@ void MenuMan::drawActionArea() {
 	dispMan._useByteBoxCoordinates = false;
 	dispMan.fillScreenBox(_boxActionArea, k0_ColorBlack);
 	if (_actionAreaContainsIcons) {
-		for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._partyChampionCount; ++champIndex)
+		for (uint16 champIndex = kDMChampionFirst; champIndex < champMan._partyChampionCount; ++champIndex)
 			drawActionIcon((ChampionIndex)champIndex);
 	} else if (champMan._actingChampionOrdinal) {
 		Box box = _boxActionArea3ActionMenu;
@@ -453,16 +453,16 @@ void MenuMan::setMagicCasterAndDrawSpellArea(ChampionIndex champIndex) {
 	static Box boxSpellAreaLine3(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 
 
 	if ((champIndex == _vm->_championMan->_magicCasterChampionIndex)
-	|| ((champIndex != kM1_ChampionNone) && !_vm->_championMan->_champions[champIndex]._currHealth))
+	|| ((champIndex != kDMChampionNone) && !_vm->_championMan->_champions[champIndex]._currHealth))
 		return;
 
-	if (_vm->_championMan->_magicCasterChampionIndex == kM1_ChampionNone) {
+	if (_vm->_championMan->_magicCasterChampionIndex == kDMChampionNone) {
 		_vm->_eventMan->showMouse();
 		_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &_boxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33);
 		_vm->_eventMan->hideMouse();
 	}
-	if (champIndex == kM1_ChampionNone) {
-		_vm->_championMan->_magicCasterChampionIndex = kM1_ChampionNone;
+	if (champIndex == kDMChampionNone) {
+		_vm->_championMan->_magicCasterChampionIndex = kDMChampionNone;
 		_vm->_eventMan->showMouse();
 		_vm->_displayMan->_useByteBoxCoordinates = false;
 		_vm->_displayMan->fillScreenBox(_boxSpellArea, k0_ColorBlack);
@@ -485,7 +485,7 @@ void MenuMan::drawEnabledMenus() {
 		_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 	} else {
 		ChampionIndex casterChampionIndex = _vm->_championMan->_magicCasterChampionIndex;
-		_vm->_championMan->_magicCasterChampionIndex = kM1_ChampionNone; /* Force next function to draw the spell area */
+		_vm->_championMan->_magicCasterChampionIndex = kDMChampionNone; /* Force next function to draw the spell area */
 		setMagicCasterAndDrawSpellArea(casterChampionIndex);
 		if (!_vm->_championMan->_actingChampionOrdinal)
 			_actionAreaContainsIcons = true;
@@ -493,7 +493,7 @@ void MenuMan::drawEnabledMenus() {
 		drawActionArea();
 		int16 AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_inventoryChampionOrdinal;
 		if (AL1462_i_InventoryChampionOrdinal) {
-			_vm->_inventoryMan->_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
+			_vm->_inventoryMan->_inventoryChampionOrdinal = _vm->indexToOrdinal(kDMChampionNone);
 			_vm->_inventoryMan->toggleInventory((ChampionIndex)_vm->ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
 		} else {
 			_vm->_displayMan->drawFloorAndCeiling();
@@ -540,7 +540,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 	if (skillLevel < requiredSkillLevel) {
 		int16 missingSkillLevelCount = requiredSkillLevel - skillLevel;
 		while (missingSkillLevelCount--) {
-			if (_vm->getRandomNumber(128) > MIN(curChampion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + 15, 115)) {
+			if (_vm->getRandomNumber(128) > MIN(curChampion->_statistics[kDMChampionStatWisdom][kDMChampionStatCurrent] + 15, 115)) {
 				_vm->_championMan->addSkillExperience(champIndex, curSpell->_skillIndex, experience >> (requiredSkillLevel - skillLevel));
 				menusPrintSpellFailureMessage(curChampion, k0_failureNeedsMorePractice, curSpell->_skillIndex);
 				return k0_spellCastFailure;
@@ -561,7 +561,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 		curChampion->_load += _vm->_dungeonMan->getObjectWeight(newObject) - emptyFlaskWeight;
 		_vm->_championMan->drawChangedObjectIcons();
 		if (_vm->_inventoryMan->_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex)) {
-			setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad);
+			setFlag(curChampion->_attributes, kDMChampionAttributeLoad);
 			_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 		}
 		}
@@ -569,7 +569,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 	case k2_spellKindProjectile:
 		if (curChampion->_dir != _vm->_dungeonMan->_partyDir) {
 			curChampion->_dir = _vm->_dungeonMan->_partyDir;
-			setFlag(curChampion->_attributes, k0x0400_ChampionAttributeIcon);
+			setFlag(curChampion->_attributes, kDMChampionAttributeIcon);
 			_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 		}
 		if (curSpell->getType() == k4_spellType_projectileOpenDoor)
@@ -889,7 +889,7 @@ void MenuMan::addChampionSymbol(int16 symbolIndex) {
 
 	if (manaCost <= casterChampion->_currMana) {
 		casterChampion->_currMana -= manaCost;
-		setFlag(casterChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+		setFlag(casterChampion->_attributes, kDMChampionAttributeStatistics);
 		casterChampion->_symbols[symbolStep] = 96 + (symbolStep * 6) + symbolIndex;
 		casterChampion->_symbols[symbolStep + 1] = '\0';
 		casterChampion->_symbolStep = symbolStep = returnNextVal(symbolStep);
@@ -932,7 +932,7 @@ bool MenuMan::didClickTriggerAction(int16 actionListIndex) {
 		if (_actionDisabledTicks[actionIndex])
 			curChampion->_actionDefense += _vm->_timeline->_actionDefense[actionIndex];
 
-		setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+		setFlag(curChampion->_attributes, kDMChampionAttributeStatistics);
 		retVal = isActionPerformed(championIndex, actionIndex);
 		curChampion->_actionIndex = (ChampionAction)actionIndex;
 	}
@@ -1249,7 +1249,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 			if (curChampion->_currMana < 0)
 				curChampion->_currMana = 0;
 
-			setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+			setFlag(curChampion->_attributes, kDMChampionAttributeStatistics);
 			actionPerformed = true;
 		}
 		}
@@ -1340,7 +1340,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 void MenuMan::setChampionDirectionToPartyDirection(Champion *champ) {
 	if (champ->_dir != _vm->_dungeonMan->_partyDir) {
 		champ->_dir = _vm->_dungeonMan->_partyDir;
-		setFlag(champ->_attributes, k0x0400_ChampionAttributeIcon);
+		setFlag(champ->_attributes, kDMChampionAttributeIcon);
 	}
 }
 
@@ -1476,7 +1476,7 @@ bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 ac
 		case k3_ViewCellBackLeft: /* Champion is on the back left of the square and tries to attack a creature in the front left of its square */
 			uint16 cellDelta = (viewCell == k2_ViewCellBackRight) ? 3 : 1;
 			/* Check if there is another champion in front */
-			if (_vm->_championMan->getIndexInCell(normalizeModulo4(championCell + cellDelta)) != kM1_ChampionNone) {
+			if (_vm->_championMan->getIndexInCell(normalizeModulo4(championCell + cellDelta)) != kDMChampionNone) {
 				_actionDamage = kM1_damageCantReach;
 				return false;
 			}
@@ -1627,7 +1627,7 @@ void MenuMan::processCommands116To119_setActingChampion(uint16 champIndex) {
 	};
 
 	Champion *curChampion = &_vm->_championMan->_champions[champIndex];
-	if (getFlag(curChampion->_attributes, k0x0008_ChampionAttributeDisableAction) || !curChampion->_currHealth)
+	if (getFlag(curChampion->_attributes, kDMChampionAttributeDisableAction) || !curChampion->_currHealth)
 		return;
 
 	uint16 actionSetIndex;
@@ -1645,7 +1645,7 @@ void MenuMan::processCommands116To119_setActingChampion(uint16 champIndex) {
 	_vm->_championMan->_actingChampionOrdinal = _vm->indexToOrdinal(champIndex);
 	setActionList(actionSet);
 	_actionAreaContainsIcons = false;
-	setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand);
+	setFlag(curChampion->_attributes, kDMChampionAttributeActionHand);
 	_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	drawActionArea();
 	drawActionArea();
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 7604479..77717de 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -82,7 +82,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16
 			if (processedSensorType == k0_SensorDisabled)
 				continue;
 			
-			if ((_vm->_championMan->_leaderIndex == kM1_ChampionNone) && (processedSensorType != k127_SensorWallChampionPortrait))
+			if ((_vm->_championMan->_leaderIndex == kDMChampionNone) && (processedSensorType != k127_SensorWallChampionPortrait))
 				continue;
 			
 			if (cellIdx != cellParam)
@@ -327,11 +327,11 @@ bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destM
 						if (_vm->_championMan->_partyChampionCount > 0) {
 							if (_useRopeToClimbDownPit) {
 								Champion *curChampion = _vm->_championMan->_champions;
-								for (int16 championIdx = k0_ChampionFirst; championIdx < _vm->_championMan->_partyChampionCount; championIdx++, curChampion++) {
+								for (int16 championIdx = kDMChampionFirst; championIdx < _vm->_championMan->_partyChampionCount; championIdx++, curChampion++) {
 									if (curChampion->_currHealth)
 										_vm->_championMan->decrementStamina(championIdx, ((curChampion->_load * 25) / _vm->_championMan->getMaximumLoad(curChampion)) + 1);
 								}
-							} else if (_vm->_championMan->getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF))
+							} else if (_vm->_championMan->getDamagedChampionCount(20, kDMChampionWoundLegs | kDMChampionWoundFeet, k2_attackType_SELF))
 								_vm->_sound->requestPlay(k06_soundSCREAM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
 						}
 						_useRopeToClimbDownPit = false;
@@ -863,7 +863,7 @@ bool MovesensMan::isObjectInPartyPossession(int16 objectType) {
 	uint16 slotIdx = 0;
 	Thing curThing;
 	Thing *curSlotThing = nullptr;
-	for (championIdx = k0_ChampionFirst; championIdx < _vm->_championMan->_partyChampionCount; championIdx++, curChampion++) {
+	for (championIdx = kDMChampionFirst; championIdx < _vm->_championMan->_partyChampionCount; championIdx++, curChampion++) {
 		if (curChampion->_currHealth) {
 			curSlotThing = curChampion->_slots;
 			for (slotIdx = k0_ChampionSlotReadyHand; (slotIdx < k30_ChampionSlotChest_1) || !leaderHandObjectProcessed; slotIdx++) {
@@ -938,12 +938,12 @@ void MovesensMan::triggerLocalEffect(int16 localEffect, int16 effX, int16 effY,
 
 void MovesensMan::addSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly) {
 	if (leaderOnly) {
-		if (_vm->_championMan->_leaderIndex != kM1_ChampionNone)
+		if (_vm->_championMan->_leaderIndex != kDMChampionNone)
 			_vm->_championMan->addSkillExperience(_vm->_championMan->_leaderIndex, skillIndex, exp);
 	} else {
 		exp /= _vm->_championMan->_partyChampionCount;
 		Champion *curChampion = _vm->_championMan->_champions;
-		for (int16 championIdx = k0_ChampionFirst; championIdx < _vm->_championMan->_partyChampionCount; championIdx++, curChampion++) {
+		for (int16 championIdx = kDMChampionFirst; championIdx < _vm->_championMan->_partyChampionCount; championIdx++, curChampion++) {
 			if (curChampion->_currHealth)
 				_vm->_championMan->addSkillExperience(championIdx, skillIndex, exp);
 		}
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 15ccc52..48f122c 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -195,7 +195,7 @@ bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, in
 		break;
 	}
 	if (championAttack && _projectilePoisonAttack && _vm->getRandomNumber(2)
-	&& _vm->_championMan->addPendingDamageAndWounds_getDamage(championIndex, attack, k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso, _projectileAttackType))
+	&& _vm->_championMan->addPendingDamageAndWounds_getDamage(championIndex, attack, kDMChampionWoundHead | kDMChampionWoundTorso, _projectileAttackType))
 		_vm->_championMan->championPoison(championIndex, _projectilePoisonAttack);
 
 	if (createExplosionOnImpact || removePotion) {
@@ -325,7 +325,7 @@ void ProjExpl::createExplosion(Thing explThing, uint16 attack, uint16 mapXCombo,
 		attack += _vm->getRandomNumber(attack) + 1;
 		if ((explThing == Thing::_explFireBall) || (attack >>= 1)) {
 			if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (projectileMapX == _vm->_dungeonMan->_partyMapX) && (projectileMapY == _vm->_dungeonMan->_partyMapY)) {
-				int16 wounds = k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand | k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet;
+				int16 wounds = kDMChampionWoundReadHand | kDMChampionWoundActionHand | kDMChampionWoundHead | kDMChampionWoundTorso | kDMChampionWoundLegs | kDMChampionWoundFeet;
 				_vm->_championMan->getDamagedChampionCount(attack, wounds, k1_attackType_FIRE);
 			} else {
 				unusedThing = _vm->_groupMan->groupGetThing(projectileMapX, projectileMapY);
@@ -536,7 +536,7 @@ void ProjExpl::processEvent25(TimelineEvent *event) {
 		break;
 	case 0xFF87:
 		if (explosionOnPartySquare)
-			_vm->_championMan->getDamagedChampionCount(attack, k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
+			_vm->_championMan->getDamagedChampionCount(attack, kDMChampionWoundNone, k0_attackType_NORMAL);
 		else if ((groupThing != Thing::_endOfList)
 			&& (attack = _vm->_groupMan->groupGetResistanceAdjustedPoisonAttack(creatureType, attack))
 			&& (_vm->_groupMan->getDamageAllCreaturesOutcome(group, mapX, mapY, attack, true) != k2_outcomeKilledAllCreaturesInGroup)
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 9100f9b..234881e 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -333,7 +333,7 @@ void Timeline::processTimeline() {
 				break;
 			case k72_TMEventTypeChampionShield:
 				_vm->_championMan->_champions[newEvent._priority]._shieldDefense -= newEvent._B._defense;
-				setFlag(_vm->_championMan->_champions[newEvent._priority]._attributes, k0x1000_ChampionAttributeStatusBox);
+				setFlag(_vm->_championMan->_champions[newEvent._priority]._attributes, kDMChampionAttributeStatusBox);
 				_vm->_championMan->drawChampionState((ChampionIndex)newEvent._priority);
 				break;
 			case k73_TMEventTypeThievesEye:
@@ -400,7 +400,7 @@ void Timeline::processEventDoorAnimation(TimelineEvent *event) {
 				// Strangerke
 				// Original bug fixed - A closing horizontal door wounds champions to the head instead of to the hands. Missing parenthesis in the condition cause all doors to wound the head in addition to the torso
 				// See BUG0_78
-				int16 wounds = k0x0008_ChampionWoundTorso | (verticalDoorFl ? k0x0004_ChampionWoundHead : k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand);
+				int16 wounds = kDMChampionWoundTorso | (verticalDoorFl ? kDMChampionWoundHead : kDMChampionWoundReadHand | kDMChampionWoundActionHand);
 				if (_vm->_championMan->getDamagedChampionCount(5, wounds, k2_attackType_SELF))
 					_vm->_sound->requestPlay(k18_soundPARTY_DAMAGED, mapX, mapY, k1_soundModePlayIfPrioritized);
 			}
@@ -815,7 +815,7 @@ void Timeline::procesEventEnableGroupGenerator(TimelineEvent *event) {
 void Timeline::processEventEnableChampionAction(uint16 champIndex) {
 	Champion *curChampion = &_vm->_championMan->_champions[champIndex];
 	curChampion->_enableActionEventIndex = -1;
-	clearFlag(curChampion->_attributes, k0x0008_ChampionAttributeDisableAction);
+	clearFlag(curChampion->_attributes, kDMChampionAttributeDisableAction);
 	if (curChampion->_actionIndex != k255_ChampionActionNone) {
 		curChampion->_actionDefense -= _actionDefense[curChampion->_actionDefense];
 	}
@@ -832,7 +832,7 @@ void Timeline::processEventEnableChampionAction(uint16 champIndex) {
 				}
 			}
 		}
-		setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand);
+		setFlag(curChampion->_attributes, kDMChampionAttributeActionHand);
 		_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	}
 	curChampion->_actionIndex = k255_ChampionActionNone;
@@ -872,7 +872,7 @@ void Timeline::processEventHideDamageReceived(uint16 champIndex) {
 		_vm->_inventoryMan->drawStatusBoxPortrait((ChampionIndex)champIndex);
 		_vm->_eventMan->hideMouse();
 	} else {
-		setFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle);
+		setFlag(curChampion->_attributes, kDMChampionAttributeNameTitle);
 		_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	}
 }
@@ -904,8 +904,8 @@ void Timeline::processEventLight(TimelineEvent *event) {
 }
 
 void Timeline::refreshAllChampionStatusBoxes() {
-	for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_partyChampionCount; idx++)
-		setFlag(_vm->_championMan->_champions[idx]._attributes, k0x1000_ChampionAttributeStatusBox);
+	for (uint16 idx = kDMChampionFirst; idx < _vm->_championMan->_partyChampionCount; idx++)
+		setFlag(_vm->_championMan->_champions[idx]._attributes, kDMChampionAttributeStatusBox);
 
 	_vm->_championMan->drawAllChampionStates();
 }


Commit: 93fb0efc0bd297be9399cd03b3523cb9f8117691
    https://github.com/scummvm/scummvm/commit/93fb0efc0bd297be9399cd03b3523cb9f8117691
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-09T07:32:32+02:00

Commit Message:
DM: More renaming in champion.h

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/dm.cpp
    engines/dm/eventman.cpp
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/projexpl.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index f550e67..eeea8bf 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -230,9 +230,9 @@ bool ChampionMan::isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side)
 			experience += weaponKineticEnergy >> 2;
 		}
 	}
-	addSkillExperience(champIndex, k10_ChampionSkillThrow, experience);
+	addSkillExperience(champIndex, kDMSkillThrow, experience);
 	kineticEnergy += weaponKineticEnergy;
-	int16 skillLevel = getSkillLevel((ChampionIndex)champIndex, k10_ChampionSkillThrow);
+	int16 skillLevel = getSkillLevel((ChampionIndex)champIndex, kDMSkillThrow);
 	kineticEnergy += _vm->getRandomNumber(16) + (kineticEnergy >> 1) + skillLevel;
 	int16 attack = getBoundedValue((uint16)40, (uint16)((skillLevel << 3) + _vm->getRandomNumber(32)), (uint16)200);
 	int16 stepEnergy = MAX(5, 11 - skillLevel);
@@ -287,7 +287,7 @@ Common::String ChampionMan::getStringFromInteger(uint16 val, bool padding, uint1
 }
 
 void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing) {
-	int16 statIndex = kDMChampionStatLuck;
+	int16 statIndex = kDMStatLuck;
 	int16 modifier = 0;
 	ThingType thingType = thing.getType();
 
@@ -304,23 +304,23 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 		}
 
 		if (cursed) {
-			statIndex = kDMChampionStatLuck;
+			statIndex = kDMStatLuck;
 			modifier = -3;
 		}
 	}
 
 	if (!cursed) {
-		statIndex = (ChampionStatisticType)thingType; // variable sharing
+		statIndex = (ChampionStatType)thingType; // variable sharing
 
 		if ((iconIndex == kDMIconIndiceJunkRabbitsFoot) && (slotIndex < k30_ChampionSlotChest_1)) {
-			statIndex = kDMChampionStatLuck;
+			statIndex = kDMStatLuck;
 			modifier = 10;
 		} else if (slotIndex == k1_ChampionSlotActionHand) {
 			if (iconIndex == kDMIconIndiceWeaponMaceOfOrder) {
-				statIndex = kDMChampionStatStrength;
+				statIndex = kDMStatStrength;
 				modifier = 5;
 			} else {
-				statIndex = kDMChampionStatMana;
+				statIndex = kDMStatMana;
 				if ((iconIndex >= kDMIconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= kDMIconIndiceWeaponStaffOfClawsFull)) {
 					modifier = 4;
 				} else {
@@ -368,17 +368,17 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 			}
 		} else if (slotIndex == k4_ChampionSlotLegs) {
 			if (iconIndex == kDMIconIndiceArmourPowertowers) {
-				statIndex = kDMChampionStatStrength;
+				statIndex = kDMStatStrength;
 				modifier = 10;
 			}
 		} else if (slotIndex == k2_ChampionSlotHead) {
 			switch (iconIndex) {
 			case kDMIconIndiceArmourCrownOfNerra:
-				statIndex = kDMChampionStatWisdom;
+				statIndex = kDMStatWisdom;
 				modifier = 10;
 				break;
 			case kDMIconIndiceArmourDexhelm:
-				statIndex = kDMChampionStatDexterity;
+				statIndex = kDMStatDexterity;
 				modifier = 10;
 				break;
 			default:
@@ -387,11 +387,11 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 		} else if (slotIndex == k3_ChampionSlotTorso) {
 			switch (iconIndex) {
 			case kDMIconIndiceArmourFlamebain:
-				statIndex = kDMChampionStatAntifire;
+				statIndex = kDMStatAntifire;
 				modifier = 12;
 				break;
 			case kDMIconIndiceArmourCloakOfNight:
-				statIndex = kDMChampionStatDexterity;
+				statIndex = kDMStatDexterity;
 				modifier = 8;
 				break;
 			default:
@@ -401,15 +401,15 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 			switch (iconIndex) {
 			case kDMIconIndiceJunkJewelSymalUnequipped:
 			case kDMIconIndiceJunkJewelSymalEquipped:
-				statIndex = kDMChampionStatAntimagic;
+				statIndex = kDMStatAntimagic;
 				modifier = 15;
 				break;
 			case kDMIconIndiceArmourCloakOfNight:
-				statIndex = kDMChampionStatDexterity;
+				statIndex = kDMStatDexterity;
 				modifier = 8;
 				break;
 			case kDMIconIndiceJunkMoonstone:
-				statIndex = kDMChampionStatMana;
+				statIndex = kDMStatMana;
 				modifier = 3;
 				break;
 			default:
@@ -421,11 +421,11 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 	if (modifier) {
 		modifier *= modifierFactor;
 		//statIndex is set when modifier is set
-		if (statIndex == kDMChampionStatMana) {
+		if (statIndex == kDMStatMana) {
 			champ->_maxMana += modifier;
-		} else if (statIndex < kDMChampionStatAntifire + 1) {
-			for (uint16 statValIndex = kDMChampionStatMaximum; statValIndex <= kDMChampionStatMinimum; ++statValIndex) {
-				champ->getStatistic((ChampionStatisticType)statIndex, (ChampionStatisticValue)statValIndex) += modifier;
+		} else if (statIndex < kDMStatAntifire + 1) {
+			for (uint16 statValIndex = kDMStatMaximum; statValIndex <= kDMStatMinimum; ++statValIndex) {
+				champ->getStatistic((ChampionStatType)statIndex, (ChampionStatValue)statValIndex) += modifier;
 			}
 		}
 	}
@@ -511,7 +511,7 @@ void ChampionMan::drawChangedObjectIcons() {
 		}
 
 		if (drawViewport) {
-			champ->setAttributeFlag(kDMChampionAttributeViewport, true);
+			champ->setAttributeFlag(kDMAttributeViewport, true);
 			drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
 		}
 	}
@@ -538,7 +538,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 	}
 
 	champ->_load += dunMan.getObjectWeight(thing);
-	champ->setAttributeFlag(kDMChampionAttributeLoad, true);
+	champ->setAttributeFlag(kDMAttributeLoad, true);
 	IconIndice iconIndex = objMan.getIconIndex(thing);
 	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
 	applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
@@ -546,7 +546,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 
 	if (slotIndex < k2_ChampionSlotHead) {
 		if (slotIndex == k1_ChampionSlotActionHand) {
-			champ->setAttributeFlag(kDMChampionAttributeActionHand, true);
+			champ->setAttributeFlag(kDMAttributeActionHand, true);
 			if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
 				menuMan.clearActingChampion();
 
@@ -562,7 +562,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 			drawChangedObjectIcons();
 		} else if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand) &&
 			((iconIndex == kDMIconIndiceContainerChestClosed) || ((iconIndex >= kDMIconIndiceScrollOpen) && (iconIndex <= kDMIconIndiceScrollClosed)))) {
-			champ->setAttributeFlag(kDMChampionAttributePanel, true);
+			champ->setAttributeFlag(kDMAttributePanel, true);
 		}
 	} else if (slotIndex == k10_ChampionSlotNeck) {
 		if ((iconIndex >= kDMIconIndiceJunkIllumuletUnequipped) && (iconIndex <= kDMIconIndiceJunkIllumuletEquipped)) {
@@ -578,7 +578,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 
 	drawSlot(champIndex, slotIndex);
 	if (isInventoryChampion)
-		champ->setAttributeFlag(kDMChampionAttributeViewport, true);
+		champ->setAttributeFlag(kDMAttributeViewport, true);
 }
 
 int16 ChampionMan::getScentOrdinal(int16 mapX, int16 mapY) {
@@ -613,7 +613,7 @@ Thing ChampionMan::getObjectRemovedFromLeaderHand() {
 		_vm->_eventMan->hideMouse();
 		if (_leaderIndex != kDMChampionNone) {
 			_champions[_leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(leaderHandObject);
-			setFlag(_champions[_leaderIndex]._attributes, kDMChampionAttributeLoad);
+			setFlag(_champions[_leaderIndex]._attributes, kDMAttributeLoad);
 			drawChampionState(_leaderIndex);
 		}
 	}
@@ -622,7 +622,7 @@ Thing ChampionMan::getObjectRemovedFromLeaderHand() {
 
 uint16 ChampionMan::getStrength(int16 champIndex, int16 slotIndex) {
 	Champion *curChampion = &_champions[champIndex];
-	int16 strength = _vm->getRandomNumber(16) + curChampion->_statistics[kDMChampionStatStrength][kDMChampionStatCurrent];
+	int16 strength = _vm->getRandomNumber(16) + curChampion->_statistics[kDMStatStrength][kDMStatCurrent];
 	Thing curThing = curChampion->_slots[slotIndex];
 	uint16 objectWeight = _vm->_dungeonMan->getObjectWeight(curThing);
 	uint16 oneSixteenthMaximumLoad = getMaximumLoad(curChampion) >> 4;
@@ -643,18 +643,18 @@ uint16 ChampionMan::getStrength(int16 champIndex, int16 slotIndex) {
 		uint16 skillLevel = 0;
 		uint16 weaponClass = weaponInfo->_class;
 		if ((weaponClass == k0_WeaponClassSwingWeapon) || (weaponClass == k2_WeaponClassDaggerAndAxes)) {
-			skillLevel = getSkillLevel(champIndex, k4_ChampionSkillSwing);
+			skillLevel = getSkillLevel(champIndex, kDMSkillSwing);
 		}
 		if ((weaponClass != k0_WeaponClassSwingWeapon) && (weaponClass < k16_WeaponClassFirstBow)) {
-			skillLevel += getSkillLevel(champIndex, k10_ChampionSkillThrow);
+			skillLevel += getSkillLevel(champIndex, kDMSkillThrow);
 		}
 		if ((weaponClass >= k16_WeaponClassFirstBow) && (weaponClass < k112_WeaponClassFirstMagicWeapon)) {
-			skillLevel += getSkillLevel(champIndex, k11_ChampionSkillShoot);
+			skillLevel += getSkillLevel(champIndex, kDMSkillShoot);
 		}
 		strength += skillLevel << 1;
 	}
 	strength = getStaminaAdjustedValue(curChampion, strength);
-	if (getFlag(curChampion->_wounds, (slotIndex == k0_ChampionSlotReadyHand) ? kDMChampionWoundReadHand : kDMChampionWoundActionHand)) {
+	if (getFlag(curChampion->_wounds, (slotIndex == k0_ChampionSlotReadyHand) ? kDMWoundReadHand : kDMWoundActionHand)) {
 		strength >>= 1;
 	}
 	return getBoundedValue(0, strength >> 1, 100);
@@ -693,11 +693,11 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 
 	drawSlot(champIndex, slotIndex);
 	if (isInventoryChampion)
-		setFlag(curChampion->_attributes, kDMChampionAttributeViewport);
+		setFlag(curChampion->_attributes, kDMAttributeViewport);
 
 	if (slotIndex < k2_ChampionSlotHead) {
 		if (slotIndex == k1_ChampionSlotActionHand) {
-			setFlag(curChampion->_attributes, kDMChampionAttributeActionHand);
+			setFlag(curChampion->_attributes, kDMAttributeActionHand);
 			if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
 				_vm->_menuMan->clearActingChampion();
 
@@ -720,7 +720,7 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 			// No break on purpose
 			case kDMIconIndiceScrollOpen:
 			case kDMIconIndiceScrollClosed:
-				setFlag(curChampion->_attributes, kDMChampionAttributePanel);
+				setFlag(curChampion->_attributes, kDMAttributePanel);
 				break;
 			default:
 				break;
@@ -728,7 +728,7 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 		}
 	}
 	curChampion->_load -= _vm->_dungeonMan->getObjectWeight(curThing);
-	setFlag(curChampion->_attributes, kDMChampionAttributeLoad);
+	setFlag(curChampion->_attributes, kDMAttributeLoad);
 	return curThing;
 }
 
@@ -742,12 +742,12 @@ void ChampionMan::decrementStamina(int16 championIndex, int16 decrement) {
 	int16 stamina = curChampion->_currStamina;
 	if (stamina <= 0) {
 		curChampion->_currStamina = 0;
-		addPendingDamageAndWounds_getDamage(championIndex, (-stamina) >> 1, kDMChampionWoundNone, k0_attackType_NORMAL);
+		addPendingDamageAndWounds_getDamage(championIndex, (-stamina) >> 1, kDMWoundNone, k0_attackType_NORMAL);
 	} else if (stamina > curChampion->_maxStamina) {
 		curChampion->_currStamina = curChampion->_maxStamina;
 	}
 
-	setFlag(curChampion->_attributes, kDMChampionAttributeLoad | kDMChampionAttributeStatistics);
+	setFlag(curChampion->_attributes, kDMAttributeLoad | kDMAttributeStatistics);
 }
 
 int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds, uint16 attackType) {
@@ -774,7 +774,7 @@ int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 a
 		switch (attackType) {
 		case k6_attackType_PSYCHIC:
 		{
-			int16 wisdomFactor = 115 - curChampion->_statistics[kDMChampionStatWisdom][kDMChampionStatCurrent];
+			int16 wisdomFactor = 115 - curChampion->_statistics[kDMStatWisdom][kDMStatCurrent];
 			if (wisdomFactor <= 0) {
 				attack = 0;
 			} else {
@@ -785,12 +785,12 @@ int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 a
 		}
 		break;
 		case k5_attackType_MAGIC:
-			attack = getStatisticAdjustedAttack(curChampion, kDMChampionStatAntimagic, attack);
+			attack = getStatisticAdjustedAttack(curChampion, kDMStatAntimagic, attack);
 			attack -= _party._spellShieldDefense;
 			skipScaling = true;
 			break;
 		case k1_attackType_FIRE:
-			attack = getStatisticAdjustedAttack(curChampion, kDMChampionStatAntifire, attack);
+			attack = getStatisticAdjustedAttack(curChampion, kDMStatAntifire, attack);
 			attack -= _party._fireShieldDefense;
 			break;
 		case k2_attackType_SELF:
@@ -818,7 +818,7 @@ int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 a
 		if (attack <= 0)
 			return 0;
 
-		int16 adjustedAttack = getStatisticAdjustedAttack(curChampion, kDMChampionStatVitality, _vm->getRandomNumber(128) + 10);
+		int16 adjustedAttack = getStatisticAdjustedAttack(curChampion, kDMStatVitality, _vm->getRandomNumber(128) + 10);
 		if (attack > adjustedAttack) {
 		/* BUG0_45
 			This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the
@@ -858,7 +858,7 @@ int16 ChampionMan::getWoundDefense(int16 champIndex, uint16 woundIndex) {
 		}
 	}
 
-	int16 woundDefense = _vm->getRandomNumber((curChampion->_statistics[kDMChampionStatVitality][kDMChampionStatCurrent] >> 3) + 1);
+	int16 woundDefense = _vm->getRandomNumber((curChampion->_statistics[kDMStatVitality][kDMStatCurrent] >> 3) + 1);
 	if (useSharpDefense)
 		woundDefense >>= 1;
 
@@ -881,7 +881,7 @@ int16 ChampionMan::getWoundDefense(int16 champIndex, uint16 woundIndex) {
 }
 
 uint16 ChampionMan::getStatisticAdjustedAttack(Champion *champ, uint16 statIndex, uint16 attack) {
-	int16 factor = 170 - champ->_statistics[statIndex][kDMChampionStatCurrent];
+	int16 factor = 170 - champ->_statistics[statIndex][kDMStatCurrent];
 
 	/* BUG0_41
 		The Antifire and Antimagic statistics are completely ignored. The Vitality statistic is ignored
@@ -939,7 +939,7 @@ void ChampionMan::disableAction(uint16 champIndex, uint16 ticks) {
 		}
 		_vm->_timeline->deleteEvent(eventIndex);
 	} else {
-		setFlag(curChampion->_attributes, kDMChampionAttributeActionHand | kDMChampionAttributeDisableAction);
+		setFlag(curChampion->_attributes, kDMAttributeActionHand | kDMAttributeDisableAction);
 		drawChampionState((ChampionIndex)champIndex);
 	}
 	setMapAndTime(curEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, updatedEnableActionEventTime);
@@ -947,7 +947,7 @@ void ChampionMan::disableAction(uint16 champIndex, uint16 ticks) {
 }
 
 void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp) {
-	if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && (_vm->_projexpl->_lastCreatureAttackTime < _vm->_gameTime - 150))
+	if ((skillIndex >= kDMSkillSwing) && (skillIndex <= kDMSkillShoot) && (_vm->_projexpl->_lastCreatureAttackTime < _vm->_gameTime - 150))
 		exp >>= 1;
 
 	if (exp) {
@@ -956,14 +956,14 @@ void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint1
 
 		Champion *curChampion = &_champions[champIndex];
 		uint16 baseSkillIndex;
-		if (skillIndex >= k4_ChampionSkillSwing)
-			baseSkillIndex = (skillIndex - k4_ChampionSkillSwing) >> 2;
+		if (skillIndex >= kDMSkillSwing)
+			baseSkillIndex = (skillIndex - kDMSkillSwing) >> 2;
 		else
 			baseSkillIndex = skillIndex;
 
 		uint16 skillLevelBefore = getSkillLevel(champIndex, baseSkillIndex | (kDMIgnoreObjectModifiers | kDMIgnoreTemporaryExperience));
 
-		if ((skillIndex >= k4_ChampionSkillSwing) && (_vm->_projexpl->_lastCreatureAttackTime > _vm->_gameTime - 25))
+		if ((skillIndex >= kDMSkillSwing) && (_vm->_projexpl->_lastCreatureAttackTime > _vm->_gameTime - 25))
 			exp <<= 1;
 
 		Skill *curSkill = &curChampion->_skills[skillIndex];
@@ -972,7 +972,7 @@ void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint1
 			curSkill->_temporaryExperience += getBoundedValue(1, exp >> 3, 100);
 
 		curSkill = &curChampion->_skills[baseSkillIndex];
-		if (skillIndex >= k4_ChampionSkillSwing)
+		if (skillIndex >= kDMSkillSwing)
 			curSkill->_experience += exp;
 
 		uint16 skillLevelAfter = getSkillLevel(champIndex, baseSkillIndex | (kDMIgnoreObjectModifiers | kDMIgnoreTemporaryExperience));
@@ -981,37 +981,37 @@ void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint1
 			int16 minorStatIncrease = _vm->getRandomNumber(2);
 			int16 majorStatIncrease = 1 + _vm->getRandomNumber(2);
 			uint16 vitalityAmount = _vm->getRandomNumber(2); /* For Priest skill, the amount is 0 or 1 for all skill levels */
-			if (baseSkillIndex != k2_ChampionSkillPriest) {
+			if (baseSkillIndex != kDMSkillPriest) {
 				vitalityAmount &= skillLevelAfter; /* For non Priest skills the amount is 0 for even skill levels. The amount is 0 or 1 for odd skill levels */
 			}
-			curChampion->_statistics[kDMChampionStatVitality][kDMChampionStatMaximum] += vitalityAmount;
+			curChampion->_statistics[kDMStatVitality][kDMStatMaximum] += vitalityAmount;
 			uint16 staminaAmount = curChampion->_maxStamina;
-			curChampion->_statistics[kDMChampionStatAntifire][kDMChampionStatMaximum] += _vm->getRandomNumber(2) & ~skillLevelAfter; /* The amount is 0 for odd skill levels. The amount is 0 or 1 for even skill levels */
+			curChampion->_statistics[kDMStatAntifire][kDMStatMaximum] += _vm->getRandomNumber(2) & ~skillLevelAfter; /* The amount is 0 for odd skill levels. The amount is 0 or 1 for even skill levels */
 			bool increaseManaFl = false;
 			switch (baseSkillIndex) {
-			case k0_ChampionSkillFighter:
+			case kDMSkillFighter:
 				staminaAmount >>= 4;
 				skillLevelAfter *= 3;
-				curChampion->_statistics[kDMChampionStatStrength][kDMChampionStatMaximum] += majorStatIncrease;
-				curChampion->_statistics[kDMChampionStatDexterity][kDMChampionStatMaximum] += minorStatIncrease;
+				curChampion->_statistics[kDMStatStrength][kDMStatMaximum] += majorStatIncrease;
+				curChampion->_statistics[kDMStatDexterity][kDMStatMaximum] += minorStatIncrease;
 				break;
-			case k1_ChampionSkillNinja:
+			case kDMSkillNinja:
 				staminaAmount /= 21;
 				skillLevelAfter <<= 1;
-				curChampion->_statistics[kDMChampionStatStrength][kDMChampionStatMaximum] += minorStatIncrease;
-				curChampion->_statistics[kDMChampionStatDexterity][kDMChampionStatMaximum] += majorStatIncrease;
+				curChampion->_statistics[kDMStatStrength][kDMStatMaximum] += minorStatIncrease;
+				curChampion->_statistics[kDMStatDexterity][kDMStatMaximum] += majorStatIncrease;
 				break;
-			case k3_ChampionSkillWizard:
+			case kDMSkillWizard:
 				staminaAmount >>= 5;
 				curChampion->_maxMana += skillLevelAfter + (skillLevelAfter >> 1);
-				curChampion->_statistics[kDMChampionStatWisdom][kDMChampionStatMaximum] += majorStatIncrease;
+				curChampion->_statistics[kDMStatWisdom][kDMStatMaximum] += majorStatIncrease;
 				increaseManaFl = true;
 				break;
-			case k2_ChampionSkillPriest:
+			case kDMSkillPriest:
 				staminaAmount /= 25;
 				curChampion->_maxMana += skillLevelAfter;
 				skillLevelAfter += (skillLevelAfter + 1) >> 1;
-				curChampion->_statistics[kDMChampionStatWisdom][kDMChampionStatMaximum] += minorStatIncrease;
+				curChampion->_statistics[kDMStatWisdom][kDMStatMaximum] += minorStatIncrease;
 				increaseManaFl = true;
 				break;
 			default:
@@ -1020,7 +1020,7 @@ void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint1
 			if (increaseManaFl) {
 				if ((curChampion->_maxMana += MIN(_vm->getRandomNumber(4), (uint16)(newBaseSkillLevel - 1))) > 900)
 					curChampion->_maxMana = 900;
-				curChampion->_statistics[kDMChampionStatAntimagic][kDMChampionStatMaximum] += _vm->getRandomNumber(3);
+				curChampion->_statistics[kDMStatAntimagic][kDMStatMaximum] += _vm->getRandomNumber(3);
 			}
 
 			if ((curChampion->_maxHealth += skillLevelAfter + _vm->getRandomNumber((skillLevelAfter >> 1) + 1)) > 999)
@@ -1029,7 +1029,7 @@ void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint1
 			if ((curChampion->_maxStamina += staminaAmount + _vm->getRandomNumber((staminaAmount >> 1) + 1)) > 9999)
 				curChampion->_maxStamina = 9999;
 
-			setFlag(curChampion->_attributes, kDMChampionAttributeStatistics);
+			setFlag(curChampion->_attributes, kDMAttributeStatistics);
 			drawChampionState((ChampionIndex)champIndex);
 			_vm->_textMan->printLineFeed();
 			Color curChampionColor = _championColor[champIndex];
@@ -1083,7 +1083,7 @@ int16 ChampionMan::getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) {
 }
 
 int16 ChampionMan::getDexterity(Champion *champ) {
-	int16 dexterity = _vm->getRandomNumber(8) + champ->_statistics[kDMChampionStatDexterity][kDMChampionStatCurrent];
+	int16 dexterity = _vm->getRandomNumber(8) + champ->_statistics[kDMStatDexterity][kDMStatCurrent];
 	dexterity -= ((int32)(dexterity >> 1) * (int32)champ->_load) / getMaximumLoad(champ);
 	if (_partyIsSleeping)
 		dexterity >>= 1;
@@ -1095,9 +1095,9 @@ bool ChampionMan::isLucky(Champion *champ, uint16 percentage) {
 	if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage))
 		return true;
 
-	unsigned char *curStat = champ->_statistics[kDMChampionStatLuck];
-	bool isLucky = (_vm->getRandomNumber(curStat[kDMChampionStatCurrent]) > percentage);
-	curStat[kDMChampionStatCurrent] = getBoundedValue<char>(curStat[kDMChampionStatMinimum], curStat[kDMChampionStatCurrent] + (isLucky ? -2 : 2), curStat[kDMChampionStatMaximum]);
+	unsigned char *curStat = champ->_statistics[kDMStatLuck];
+	bool isLucky = (_vm->getRandomNumber(curStat[kDMStatCurrent]) > percentage);
+	curStat[kDMStatCurrent] = getBoundedValue<char>(curStat[kDMStatMinimum], curStat[kDMStatCurrent] + (isLucky ? -2 : 2), curStat[kDMStatMaximum]);
 	return isLucky;
 }
 
@@ -1106,10 +1106,10 @@ void ChampionMan::championPoison(int16 champIndex, uint16 attack) {
 		return;
 
 	Champion *curChampion = &_champions[champIndex];
-	addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), kDMChampionWoundNone, k0_attackType_NORMAL);
-	setFlag(curChampion->_attributes, kDMChampionAttributeStatistics);
+	addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), kDMWoundNone, k0_attackType_NORMAL);
+	setFlag(curChampion->_attributes, kDMAttributeStatistics);
 	if ((_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) && (_vm->_inventoryMan->_panelContent == k0_PanelContentFoodWaterPoisoned)) {
-		setFlag(curChampion->_attributes, kDMChampionAttributePanel);
+		setFlag(curChampion->_attributes, kDMAttributePanel);
 	}
 
 	if (--attack) {
@@ -1208,7 +1208,7 @@ void ChampionMan::putObjectInLeaderHand(Thing thing, bool setMousePointer) {
 	_vm->_eventMan->hideMouse();
 	if (_leaderIndex != kDMChampionNone) {
 		_champions[_leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(thing);
-		setFlag(_champions[_leaderIndex]._attributes, kDMChampionAttributeLoad);
+		setFlag(_champions[_leaderIndex]._attributes, kDMAttributeLoad);
 		drawChampionState(_leaderIndex);
 	}
 }
@@ -1235,7 +1235,7 @@ int16 ChampionMan::getMovementTicks(Champion *champ) {
 		woundTicks = 2;
 	}
 
-	if (getFlag(champ->_wounds, kDMChampionWoundFeet))
+	if (getFlag(champ->_wounds, kDMWoundFeet))
 		ticks += woundTicks;
 
 	if (_vm->_objectMan->getIconIndex(champ->_slots[k5_ChampionSlotFeet]) == kDMIconIndiceArmourBootOfSpeed)
@@ -1286,7 +1286,7 @@ void ChampionMan::viAltarRebirth(uint16 champIndex) {
 	curChampion->_currHealth = curChampion->_maxHealth >> 1;
 	_vm->_menuMan->drawSpellAreaControls(_magicCasterChampionIndex);
 	curChampion->_dir = _vm->_dungeonMan->_partyDir;
-	setFlag(curChampion->_attributes, kDMChampionAttributeActionHand | kDMChampionAttributeStatusBox | kDMChampionAttributeIcon);
+	setFlag(curChampion->_attributes, kDMAttributeActionHand | kDMAttributeStatusBox | kDMAttributeIcon);
 	drawChampionState((ChampionIndex)champIndex);
 }
 
@@ -1344,7 +1344,7 @@ bool ChampionMan::isProjectileSpellCast(uint16 champIndex, Thing thing, int16 ki
 		return false;
 
 	curChampion->_currMana -= requiredManaAmount;
-	setFlag(curChampion->_attributes, kDMChampionAttributeStatistics);
+	setFlag(curChampion->_attributes, kDMAttributeStatistics);
 	int16 stepEnergy = 10 - MIN(8, curChampion->_maxMana >> 3);
 	if (kineticEnergy < (stepEnergy << 2)) {
 		kineticEnergy += 3;
@@ -1385,9 +1385,9 @@ void ChampionMan::applyAndDrawPendingDamageAndWounds() {
 			championKill(championIndex);
 		} else {
 			championPtr->_currHealth = curHealth;
-			setFlag(championPtr->_attributes, kDMChampionAttributeStatistics);
+			setFlag(championPtr->_attributes, kDMAttributeStatistics);
 			if (pendingWounds) {
-				setFlag(championPtr->_attributes, kDMChampionAttributeWounds);
+				setFlag(championPtr->_attributes, kDMAttributeWounds);
 			}
 
 			int16 textPosX = championIndex * k69_ChampionStatusBoxSpacing;
@@ -1449,7 +1449,7 @@ void ChampionMan::applyAndDrawPendingDamageAndWounds() {
 void ChampionMan::championKill(uint16 champIndex) {
 	Champion *curChampion = &_champions[champIndex];
 	curChampion->_currHealth = 0;
-	setFlag(curChampion->_attributes, kDMChampionAttributeStatusBox);
+	setFlag(curChampion->_attributes, kDMAttributeStatusBox);
 	if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) {
 		if (_vm->_pressingEye) {
 			_vm->_pressingEye = false;
@@ -1593,9 +1593,9 @@ void ChampionMan::applyTimeEffects() {
 	Champion *championPtr = _champions;
 	for (uint16 championIndex = kDMChampionFirst; championIndex < _partyChampionCount; championIndex++, championPtr++) {
 		if (championPtr->_currHealth && (_vm->indexToOrdinal(championIndex) != _candidateChampionOrdinal)) {
-			uint16 wizardSkillLevel = getSkillLevel(championIndex, k3_ChampionSkillWizard) + getSkillLevel(championIndex, k2_ChampionSkillPriest);
+			uint16 wizardSkillLevel = getSkillLevel(championIndex, kDMSkillWizard) + getSkillLevel(championIndex, kDMSkillPriest);
 			if ((championPtr->_currMana < championPtr->_maxMana)
-				&& (timeCriteria < championPtr->_statistics[kDMChampionStatWisdom][kDMChampionStatCurrent] + wizardSkillLevel)) {
+				&& (timeCriteria < championPtr->_statistics[kDMStatWisdom][kDMStatCurrent] + wizardSkillLevel)) {
 				int16 manaGain = championPtr->_maxMana / 40;
 				if (_partyIsSleeping)
 					manaGain <<= 1;
@@ -1606,7 +1606,7 @@ void ChampionMan::applyTimeEffects() {
 			} else if (championPtr->_currMana > championPtr->_maxMana)
 				championPtr->_currMana--;
 
-			for (int16 idx = k19_ChampionSkillWater; idx >= k0_ChampionSkillFighter; idx--) {
+			for (int16 idx = kDMSkillWater; idx >= kDMSkillFighter; idx--) {
 				if (championPtr->_skills[idx]._temporaryExperience > 0)
 					championPtr->_skills[idx]._temporaryExperience--;
 			}
@@ -1658,7 +1658,7 @@ void ChampionMan::applyTimeEffects() {
 			if (championPtr->_water < -1024)
 				championPtr->_water = -1024;
 
-			if ((championPtr->_currHealth < championPtr->_maxHealth) && (championPtr->_currStamina >= (championPtr->_maxStamina >> 2)) && (timeCriteria < (championPtr->_statistics[kDMChampionStatVitality][kDMChampionStatCurrent] + 12))) {
+			if ((championPtr->_currHealth < championPtr->_maxHealth) && (championPtr->_currStamina >= (championPtr->_maxStamina >> 2)) && (timeCriteria < (championPtr->_statistics[kDMStatVitality][kDMStatCurrent] + 12))) {
 				int16 healthGain = (championPtr->_maxHealth >> 7) + 1;
 				if (_partyIsSleeping)
 					healthGain <<= 1;
@@ -1669,24 +1669,24 @@ void ChampionMan::applyTimeEffects() {
 				championPtr->_currHealth += MIN(healthGain, (int16)(championPtr->_maxHealth - championPtr->_currHealth));
 			}
 			if (!((int)_vm->_gameTime & (_partyIsSleeping ? 63 : 255))) {
-				for (uint16 i = kDMChampionStatLuck; i <= kDMChampionStatAntifire; i++) {
+				for (uint16 i = kDMStatLuck; i <= kDMStatAntifire; i++) {
 					byte *curStatistic = championPtr->_statistics[i];
-					uint16 statisticMaximum = curStatistic[kDMChampionStatMaximum];
-					if (curStatistic[kDMChampionStatCurrent] < statisticMaximum)
-						curStatistic[kDMChampionStatCurrent]++;
-					else if (curStatistic[kDMChampionStatCurrent] > statisticMaximum)
-						curStatistic[kDMChampionStatCurrent] -= curStatistic[kDMChampionStatCurrent] / statisticMaximum;
+					uint16 statisticMaximum = curStatistic[kDMStatMaximum];
+					if (curStatistic[kDMStatCurrent] < statisticMaximum)
+						curStatistic[kDMStatCurrent]++;
+					else if (curStatistic[kDMStatCurrent] > statisticMaximum)
+						curStatistic[kDMStatCurrent] -= curStatistic[kDMStatCurrent] / statisticMaximum;
 				}
 			}
 			if (!_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_partyDir) && (_vm->_projexpl->_lastCreatureAttackTime + 60 < _vm->_gameTime)) {
 				championPtr->_dir = _vm->_dungeonMan->_partyDir;
 				championPtr->_maximumDamageReceived = 0;
-				setFlag(championPtr->_attributes, kDMChampionAttributeIcon);
+				setFlag(championPtr->_attributes, kDMAttributeIcon);
 			}
-			setFlag(championPtr->_attributes, kDMChampionAttributeStatistics);
+			setFlag(championPtr->_attributes, kDMAttributeStatistics);
 			if (_vm->indexToOrdinal(championIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) {
 				if (_vm->_pressingMouth || _vm->_pressingEye || (_vm->_inventoryMan->_panelContent == k0_PanelContentFoodWaterPoisoned)) {
-					setFlag(championPtr->_attributes, kDMChampionAttributePanel);
+					setFlag(championPtr->_attributes, kDMAttributePanel);
 				}
 			}
 		}
@@ -1839,8 +1839,8 @@ void ChampionMan::resetDataToStartGame() {
 
 		Champion *curChampion = _champions;
 		for (int16 idx = 0; idx < _partyChampionCount; idx++, curChampion++) {
-			clearFlag(curChampion->_attributes, kDMChampionAttributeNameTitle | kDMChampionAttributeStatistics | kDMChampionAttributeLoad | kDMChampionAttributeIcon | kDMChampionAttributePanel | kDMChampionAttributeStatusBox | kDMChampionAttributeWounds | kDMChampionAttributeViewport | kDMChampionAttributeActionHand);
-			setFlag(curChampion->_attributes, kDMChampionAttributeActionHand | kDMChampionAttributeStatusBox | kDMChampionAttributeIcon);
+			clearFlag(curChampion->_attributes, kDMAttributeNameTitle | kDMAttributeStatistics | kDMAttributeLoad | kDMAttributeIcon | kDMAttributePanel | kDMAttributeStatusBox | kDMAttributeWounds | kDMAttributeViewport | kDMAttributeActionHand);
+			setFlag(curChampion->_attributes, kDMAttributeActionHand | kDMAttributeStatusBox | kDMAttributeIcon);
 		}
 		drawAllChampionStates();
 
@@ -1885,7 +1885,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 		viewCell++;
 
 	championPtr->_cell = (ViewCell)normalizeModulo4(viewCell + _vm->_dungeonMan->_partyDir);
-	championPtr->_attributes = kDMChampionAttributeIcon;
+	championPtr->_attributes = kDMAttributeIcon;
 	championPtr->_directionMaximumDamageReceived = _vm->_dungeonMan->_partyDir;
 	championPtr->_food = 1500 + _vm->getRandomNumber(256);
 	championPtr->_water = 1500 + _vm->getRandomNumber(256);
@@ -1919,7 +1919,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	}
 	championPtr->_title[charIdx] = '\0';
 	if (*decodedStringPtr++ == 'M')
-		setFlag(championPtr->_attributes, kDMChampionAttributeMale);
+		setFlag(championPtr->_attributes, kDMAttributeMale);
 
 	decodedStringPtr++;
 	championPtr->_currHealth = championPtr->_maxHealth = getDecodedValue(decodedStringPtr, 4);
@@ -1929,19 +1929,19 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	championPtr->_currMana = championPtr->_maxMana = getDecodedValue(decodedStringPtr, 4);
 	decodedStringPtr += 4;
 	decodedStringPtr++;
-	for (int16 statIdx = kDMChampionStatLuck; statIdx <= kDMChampionStatAntifire; statIdx++) {
-		championPtr->_statistics[statIdx][kDMChampionStatMinimum] = 30;
-		championPtr->_statistics[statIdx][kDMChampionStatCurrent] = championPtr->_statistics[statIdx][kDMChampionStatMaximum] = getDecodedValue(decodedStringPtr, 2);
+	for (int16 statIdx = kDMStatLuck; statIdx <= kDMStatAntifire; statIdx++) {
+		championPtr->_statistics[statIdx][kDMStatMinimum] = 30;
+		championPtr->_statistics[statIdx][kDMStatCurrent] = championPtr->_statistics[statIdx][kDMStatMaximum] = getDecodedValue(decodedStringPtr, 2);
 		decodedStringPtr += 2;
 	}
-	championPtr->_statistics[kDMChampionStatLuck][kDMChampionStatMinimum] = 10;
+	championPtr->_statistics[kDMStatLuck][kDMStatMinimum] = 10;
 	decodedStringPtr++;
-	for (uint16 skillIdx = k4_ChampionSkillSwing; skillIdx <= k19_ChampionSkillWater; skillIdx++) {
+	for (uint16 skillIdx = kDMSkillSwing; skillIdx <= kDMSkillWater; skillIdx++) {
 		int skillValue = *decodedStringPtr++ - 'A';
 		if (skillValue > 0)
 			championPtr->_skills[skillIdx]._experience = 125L << skillValue;
 	}
-	for (uint16 skillIdx = k0_ChampionSkillFighter; skillIdx <= k3_ChampionSkillWizard; skillIdx++) {
+	for (uint16 skillIdx = kDMSkillFighter; skillIdx <= kDMSkillWizard; skillIdx++) {
 		int32 baseSkillExperience = 0;
 		int16 hiddenSkillIndex = (skillIdx + 1) << 2;
 		for (uint16 hiddenIdx = 0; hiddenIdx < 4; hiddenIdx++)
@@ -2098,11 +2098,11 @@ uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) {
 }
 
 uint16 ChampionMan::getMaximumLoad(Champion *champ) {
-	uint16 maximumLoad = champ->getStatistic(kDMChampionStatStrength, kDMChampionStatCurrent) * 8 + 100;
+	uint16 maximumLoad = champ->getStatistic(kDMStatStrength, kDMStatCurrent) * 8 + 100;
 	maximumLoad = getStaminaAdjustedValue(champ, maximumLoad);
 	int16 wounds = champ->getWounds();
 	if (wounds)
-		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kDMChampionWoundLegs) ? 2 : 3);
+		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kDMWoundLegs) ? 2 : 3);
 
 	if (_vm->_objectMan->getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == kDMIconIndiceArmourElvenBoots)
 		maximumLoad += maximumLoad * 16;
@@ -2119,13 +2119,13 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 	int16 championStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
 	Champion *curChampion = &_champions[champIndex];
 	uint16 championAttributes = curChampion->_attributes;
-	if (!getFlag(championAttributes, kDMChampionAttributeNameTitle | kDMChampionAttributeStatistics | kDMChampionAttributeLoad | kDMChampionAttributeIcon | kDMChampionAttributePanel | kDMChampionAttributeStatusBox | kDMChampionAttributeWounds | kDMChampionAttributeViewport | kDMChampionAttributeActionHand))
+	if (!getFlag(championAttributes, kDMAttributeNameTitle | kDMAttributeStatistics | kDMAttributeLoad | kDMAttributeIcon | kDMAttributePanel | kDMAttributeStatusBox | kDMAttributeWounds | kDMAttributeViewport | kDMAttributeActionHand))
 		return;
 
 	bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal);
 	_vm->_displayMan->_useByteBoxCoordinates = false;
 	_vm->_eventMan->showMouse();
-	if (getFlag(championAttributes, kDMChampionAttributeStatusBox)) {
+	if (getFlag(championAttributes, kDMAttributeStatusBox)) {
 		Box box;
 		box._y1 = 0;
 		box._y2 = 28;
@@ -2152,26 +2152,26 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 
 			if (isInventoryChampion) {
 				_vm->_inventoryMan->drawStatusBoxPortrait(champIndex);
-				setFlag(championAttributes, kDMChampionAttributeStatistics);
+				setFlag(championAttributes, kDMAttributeStatistics);
 			} else
-				setFlag(championAttributes, kDMChampionAttributeNameTitle | kDMChampionAttributeStatistics | kDMChampionAttributeWounds | kDMChampionAttributeActionHand);
+				setFlag(championAttributes, kDMAttributeNameTitle | kDMAttributeStatistics | kDMAttributeWounds | kDMAttributeActionHand);
 		} else {
 			_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), &box, k40_byteWidth, kM1_ColorNoTransparency, 29);
 			_vm->_textMan->printToLogicalScreen(championStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, curChampion->_name);
 			_vm->_menuMan->drawActionIcon(champIndex);
 
-			clearFlag(curChampion->_attributes, kDMChampionAttributeNameTitle | kDMChampionAttributeStatistics | kDMChampionAttributeLoad | kDMChampionAttributeIcon | kDMChampionAttributePanel | kDMChampionAttributeStatusBox | kDMChampionAttributeWounds | kDMChampionAttributeViewport | kDMChampionAttributeActionHand);
+			clearFlag(curChampion->_attributes, kDMAttributeNameTitle | kDMAttributeStatistics | kDMAttributeLoad | kDMAttributeIcon | kDMAttributePanel | kDMAttributeStatusBox | kDMAttributeWounds | kDMAttributeViewport | kDMAttributeActionHand);
 			_vm->_eventMan->hideMouse();
 			return;
 		}
 	}
 	if (!(curChampion->_currHealth)) {
-		clearFlag(curChampion->_attributes, kDMChampionAttributeNameTitle | kDMChampionAttributeStatistics | kDMChampionAttributeLoad | kDMChampionAttributeIcon | kDMChampionAttributePanel | kDMChampionAttributeStatusBox | kDMChampionAttributeWounds | kDMChampionAttributeViewport | kDMChampionAttributeActionHand);
+		clearFlag(curChampion->_attributes, kDMAttributeNameTitle | kDMAttributeStatistics | kDMAttributeLoad | kDMAttributeIcon | kDMAttributePanel | kDMAttributeStatusBox | kDMAttributeWounds | kDMAttributeViewport | kDMAttributeActionHand);
 		_vm->_eventMan->hideMouse();
 		return;
 	}
 
-	if (getFlag(championAttributes, kDMChampionAttributeNameTitle)) {
+	if (getFlag(championAttributes, kDMAttributeNameTitle)) {
 		Color nameColor = (champIndex == _leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
 		if (isInventoryChampion) {
 			char *championName = curChampion->_name;
@@ -2182,7 +2182,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 				championTitleX += 6;
 
 			_vm->_textMan->printToViewport(championTitleX, 7, nameColor, curChampion->_title);
-			setFlag(championAttributes, kDMChampionAttributeViewport);
+			setFlag(championAttributes, kDMAttributeViewport);
 		} else {
 			Box box;
 			box._y1 = 0;
@@ -2193,7 +2193,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 			_vm->_textMan->printToLogicalScreen(championStatusBoxX + 1, 5, nameColor, k1_ColorDarkGary, curChampion->_name);
 		}
 	}
-	if (getFlag(championAttributes, kDMChampionAttributeStatistics)) {
+	if (getFlag(championAttributes, kDMAttributeStatistics)) {
 		drawChampionBarGraphs(champIndex);
 		if (isInventoryChampion) {
 			drawHealthStaminaManaValues(curChampion);
@@ -2205,24 +2205,24 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 
 			_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(nativeBitmapIndex), boxMouth, k16_byteWidth, k12_ColorDarkestGray, 18);
 			nativeBitmapIndex = k33_SlotBoxNormalIndice;
-			for (int i = kDMChampionStatStrength; i <= kDMChampionStatAntifire; i++) {
-				if ((curChampion->_statistics[i][kDMChampionStatCurrent] < curChampion->_statistics[i][kDMChampionStatMaximum])) {
+			for (int i = kDMStatStrength; i <= kDMStatAntifire; i++) {
+				if ((curChampion->_statistics[i][kDMStatCurrent] < curChampion->_statistics[i][kDMStatMaximum])) {
 					nativeBitmapIndex = k34_SlotBoxWoundedIndice;
 					break;
 				}
 			}
 			_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(nativeBitmapIndex), boxEye, k16_byteWidth, k12_ColorDarkestGray, 18);
-			setFlag(championAttributes, kDMChampionAttributeViewport);
+			setFlag(championAttributes, kDMAttributeViewport);
 		}
 	}
-	if (getFlag(championAttributes, kDMChampionAttributeWounds)) {
+	if (getFlag(championAttributes, kDMAttributeWounds)) {
 		for (int i = isInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; i >= k0_ChampionSlotReadyHand; i--)
 			drawSlot(champIndex, i);
 
 		if (isInventoryChampion)
-			setFlag(championAttributes, kDMChampionAttributeViewport);
+			setFlag(championAttributes, kDMAttributeViewport);
 	}
-	if (getFlag(championAttributes, kDMChampionAttributeLoad) && isInventoryChampion) {
+	if (getFlag(championAttributes, kDMAttributeLoad) && isInventoryChampion) {
 		uint16 maxLoad = getMaximumLoad(curChampion);
 		Color loadColor;
 		if (curChampion->_load > maxLoad)
@@ -2256,14 +2256,14 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		strcat(_vm->_stringBuildBuffer, getStringFromInteger(maxLoad, true, 3).c_str());
 		strcat(_vm->_stringBuildBuffer, " KG");
 		_vm->_textMan->printToViewport(148, 132, loadColor, _vm->_stringBuildBuffer);
-		setFlag(championAttributes, kDMChampionAttributeViewport);
+		setFlag(championAttributes, kDMAttributeViewport);
 	}
 	uint16 championIconIndex = getChampionIconIndex(curChampion->_cell, _vm->_dungeonMan->_partyDir);
-	if (getFlag(championAttributes, kDMChampionAttributeIcon) && (_vm->_eventMan->_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(championIconIndex))) {
+	if (getFlag(championAttributes, kDMAttributeIcon) && (_vm->_eventMan->_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(championIconIndex))) {
 		_vm->_displayMan->fillScreenBox(_boxChampionIcons[championIconIndex], _championColor[champIndex]);
 		_vm->_displayMan->blitToBitmap(_vm->_displayMan->getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_bitmapScreen, _boxChampionIcons[championIconIndex], getChampionIconIndex(curChampion->_dir, _vm->_dungeonMan->_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
 	}
-	if (getFlag(championAttributes, kDMChampionAttributePanel) && isInventoryChampion) {
+	if (getFlag(championAttributes, kDMAttributePanel) && isInventoryChampion) {
 		if (_vm->_pressingMouth)
 			_vm->_inventoryMan->drawPanelFoodWaterPoisoned();
 		else if (_vm->_pressingEye) {
@@ -2272,18 +2272,18 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		} else
 			_vm->_inventoryMan->drawPanel();
 
-		setFlag(championAttributes, kDMChampionAttributeViewport);
+		setFlag(championAttributes, kDMAttributeViewport);
 	}
-	if (getFlag(championAttributes, kDMChampionAttributeActionHand)) {
+	if (getFlag(championAttributes, kDMAttributeActionHand)) {
 		drawSlot(champIndex, k1_ChampionSlotActionHand);
 		_vm->_menuMan->drawActionIcon(champIndex);
 		if (isInventoryChampion)
-			setFlag(championAttributes, kDMChampionAttributeViewport);
+			setFlag(championAttributes, kDMAttributeViewport);
 	}
-	if (getFlag(championAttributes, kDMChampionAttributeViewport))
+	if (getFlag(championAttributes, kDMAttributeViewport))
 		_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
 
-	clearFlag(curChampion->_attributes, kDMChampionAttributeNameTitle | kDMChampionAttributeStatistics | kDMChampionAttributeLoad | kDMChampionAttributeIcon | kDMChampionAttributePanel | kDMChampionAttributeStatusBox | kDMChampionAttributeWounds | kDMChampionAttributeViewport | kDMChampionAttributeActionHand);
+	clearFlag(curChampion->_attributes, kDMAttributeNameTitle | kDMAttributeStatistics | kDMAttributeLoad | kDMAttributeIcon | kDMAttributePanel | kDMAttributeStatusBox | kDMAttributeWounds | kDMAttributeViewport | kDMAttributeActionHand);
 	_vm->_eventMan->hideMouse();
 }
 
@@ -2557,9 +2557,9 @@ uint16 ChampionMan::getSkillLevel(int16 champIndex, uint16 skillIndex) {
 	if (!ignoreTmpExp)
 		exp += skill->_temporaryExperience;
 
-	if (skillIndex > k3_ChampionSkillWizard) {
+	if (skillIndex > kDMSkillWizard) {
 		// Hidden skill
-		skill = &champ->_skills[(skillIndex - k4_ChampionSkillSwing) >> 2];
+		skill = &champ->_skills[(skillIndex - kDMSkillSwing) >> 2];
 		exp += skill->_experience; // Add experience in the base skill
 		if (!ignoreTmpExp)
 			exp += skill->_temporaryExperience;
@@ -2580,20 +2580,20 @@ uint16 ChampionMan::getSkillLevel(int16 champIndex, uint16 skillIndex) {
 
 		int16 neckIconIndex = _vm->_objectMan->getIconIndex(champ->_slots[k10_ChampionSlotNeck]);
 		switch (skillIndex) {
-		case k3_ChampionSkillWizard:
+		case kDMSkillWizard:
 			if (neckIconIndex == kDMIconIndiceJunkPendantFeral)
 				skillLevel += 1;
 			break;
-		case k13_ChampionSkillHeal:
+		case kDMSkillHeal:
 			// The skill modifiers of these two objects are not cumulative
 			if ((neckIconIndex == kDMIconIndiceJunkGemOfAges) || (actionHandIconIndex == kDMIconIndiceWeaponSceptreOfLyf))
 				skillLevel += 1;
 			break;
-		case k14_ChampionSkillInfluence:
+		case kDMSkillInfluence:
 			if (neckIconIndex == kDMIconIndiceJunkMoonstone)
 				skillLevel += 1;
 			break;
-		case k15_ChampionSkillDefend:
+		case kDMSkillDefend:
 			if (neckIconIndex == kDMIconIndiceJunkEkkhardCross)
 				skillLevel += 1;
 			break;
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 3ddf097..ef47994 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -183,70 +183,69 @@ enum ChampionIndex {
 };
 
 enum ChampionAttribute {
-	kDMChampionAttributNone = 0x0000, // @ MASK0x0000_NONE
-	kDMChampionAttributeDisableAction = 0x0008, // @ MASK0x0008_DISABLE_ACTION
-	kDMChampionAttributeMale = 0x0010, // @ MASK0x0010_MALE
-	kDMChampionAttributeNameTitle = 0x0080, // @ MASK0x0080_NAME_TITLE
-	kDMChampionAttributeStatistics = 0x0100, // @ MASK0x0100_STATISTICS
-	kDMChampionAttributeLoad = 0x0200, // @ MASK0x0200_LOAD
-	kDMChampionAttributeIcon = 0x0400, // @ MASK0x0400_ICON
-	kDMChampionAttributePanel = 0x0800, // @ MASK0x0800_PANEL
-	kDMChampionAttributeStatusBox = 0x1000, // @ MASK0x1000_STATUS_BOX
-	kDMChampionAttributeWounds = 0x2000, // @ MASK0x2000_WOUNDS
-	kDMChampionAttributeViewport = 0x4000, // @ MASK0x4000_VIEWPORT
-	kDMChampionAttributeActionHand = 0x8000 // @ MASK0x8000_ACTION_HAND
+	kDMAttributNone = 0x0000, // @ MASK0x0000_NONE
+	kDMAttributeDisableAction = 0x0008, // @ MASK0x0008_DISABLE_ACTION
+	kDMAttributeMale = 0x0010, // @ MASK0x0010_MALE
+	kDMAttributeNameTitle = 0x0080, // @ MASK0x0080_NAME_TITLE
+	kDMAttributeStatistics = 0x0100, // @ MASK0x0100_STATISTICS
+	kDMAttributeLoad = 0x0200, // @ MASK0x0200_LOAD
+	kDMAttributeIcon = 0x0400, // @ MASK0x0400_ICON
+	kDMAttributePanel = 0x0800, // @ MASK0x0800_PANEL
+	kDMAttributeStatusBox = 0x1000, // @ MASK0x1000_STATUS_BOX
+	kDMAttributeWounds = 0x2000, // @ MASK0x2000_WOUNDS
+	kDMAttributeViewport = 0x4000, // @ MASK0x4000_VIEWPORT
+	kDMAttributeActionHand = 0x8000 // @ MASK0x8000_ACTION_HAND
 };
 
-
 enum ChampionWound {
-	kDMChampionWoundNone = 0x0000, // @ MASK0x0000_NO_WOUND
-	kDMChampionWoundReadHand = 0x0001, // @ MASK0x0001_READY_HAND
-	kDMChampionWoundActionHand = 0x0002, // @ MASK0x0002_ACTION_HAND
-	kDMChampionWoundHead = 0x0004, // @ MASK0x0004_HEAD
-	kDMChampionWoundTorso = 0x0008, // @ MASK0x0008_TORSO
-	kDMChampionWoundLegs = 0x0010, // @ MASK0x0010_LEGS
-	kDMChampionWoundFeet = 0x0020 // @ MASK0x0020_FEET
+	kDMWoundNone = 0x0000, // @ MASK0x0000_NO_WOUND
+	kDMWoundReadHand = 0x0001, // @ MASK0x0001_READY_HAND
+	kDMWoundActionHand = 0x0002, // @ MASK0x0002_ACTION_HAND
+	kDMWoundHead = 0x0004, // @ MASK0x0004_HEAD
+	kDMWoundTorso = 0x0008, // @ MASK0x0008_TORSO
+	kDMWoundLegs = 0x0010, // @ MASK0x0010_LEGS
+	kDMWoundFeet = 0x0020 // @ MASK0x0020_FEET
 };
 
 
-enum ChampionStatisticType {
-	kDMChampionStatLuck = 0, // @ C0_STATISTIC_LUCK
-	kDMChampionStatStrength = 1, // @ C1_STATISTIC_STRENGTH
-	kDMChampionStatDexterity = 2, // @ C2_STATISTIC_DEXTERITY
-	kDMChampionStatWisdom = 3, // @ C3_STATISTIC_WISDOM
-	kDMChampionStatVitality = 4, // @ C4_STATISTIC_VITALITY
-	kDMChampionStatAntimagic = 5, // @ C5_STATISTIC_ANTIMAGIC
-	kDMChampionStatAntifire = 6, // @ C6_STATISTIC_ANTIFIRE
-	kDMChampionStatMana = 8 // @ C8_STATISTIC_MANA /* Used as a fake statistic index for objects granting a Mana bonus */
+enum ChampionStatType {
+	kDMStatLuck = 0, // @ C0_STATISTIC_LUCK
+	kDMStatStrength = 1, // @ C1_STATISTIC_STRENGTH
+	kDMStatDexterity = 2, // @ C2_STATISTIC_DEXTERITY
+	kDMStatWisdom = 3, // @ C3_STATISTIC_WISDOM
+	kDMStatVitality = 4, // @ C4_STATISTIC_VITALITY
+	kDMStatAntimagic = 5, // @ C5_STATISTIC_ANTIMAGIC
+	kDMStatAntifire = 6, // @ C6_STATISTIC_ANTIFIRE
+	kDMStatMana = 8 // @ C8_STATISTIC_MANA /* Used as a fake statistic index for objects granting a Mana bonus */
 };
 
-enum ChampionStatisticValue {
-	kDMChampionStatMaximum = 0, // @ C0_MAXIMUM
-	kDMChampionStatCurrent = 1, // @ C1_CURRENT
-	kDMChampionStatMinimum = 2 // @ C2_MINIMUM
+enum ChampionStatValue {
+	kDMStatMaximum = 0, // @ C0_MAXIMUM
+	kDMStatCurrent = 1, // @ C1_CURRENT
+	kDMStatMinimum = 2 // @ C2_MINIMUM
 };
 
 enum ChampionSkill {
-	k0_ChampionSkillFighter = 0, // @ C00_SKILL_FIGHTER
-	k1_ChampionSkillNinja = 1, // @ C01_SKILL_NINJA
-	k2_ChampionSkillPriest = 2, // @ C02_SKILL_PRIEST
-	k3_ChampionSkillWizard = 3, // @ C03_SKILL_WIZARD
-	k4_ChampionSkillSwing = 4, // @ C04_SKILL_SWING
-	k5_ChampionSkillThrust = 5, // @ C05_SKILL_THRUST
-	k6_ChampionSkillClub = 6, // @ C06_SKILL_CLUB
-	k7_ChampionSkillParry = 7, // @ C07_SKILL_PARRY
-	k8_ChampionSkillSteal = 8, // @ C08_SKILL_STEAL
-	k9_ChampionSkillFight = 9, // @ C09_SKILL_FIGHT
-	k10_ChampionSkillThrow = 10, // @ C10_SKILL_THROW
-	k11_ChampionSkillShoot = 11, // @ C11_SKILL_SHOOT
-	k12_ChampionSkillIdentify = 12, // @ C12_SKILL_IDENTIFY
-	k13_ChampionSkillHeal = 13, // @ C13_SKILL_HEAL
-	k14_ChampionSkillInfluence = 14, // @ C14_SKILL_INFLUENCE
-	k15_ChampionSkillDefend = 15, // @ C15_SKILL_DEFEND
-	k16_ChampionSkillFire = 16, // @ C16_SKILL_FIRE
-	k17_ChampionSkillAir = 17, // @ C17_SKILL_AIR
-	k18_ChampionSkillEarth = 18, // @ C18_SKILL_EARTH
-	k19_ChampionSkillWater = 19 // @ C19_SKILL_WATER
+	kDMSkillFighter = 0, // @ C00_SKILL_FIGHTER
+	kDMSkillNinja = 1, // @ C01_SKILL_NINJA
+	kDMSkillPriest = 2, // @ C02_SKILL_PRIEST
+	kDMSkillWizard = 3, // @ C03_SKILL_WIZARD
+	kDMSkillSwing = 4, // @ C04_SKILL_SWING
+	kDMSkillThrust = 5, // @ C05_SKILL_THRUST
+	kDMSkillClub = 6, // @ C06_SKILL_CLUB
+	kDMSkillParry = 7, // @ C07_SKILL_PARRY
+	kDMSkillSteal = 8, // @ C08_SKILL_STEAL
+	kDMSkillFight = 9, // @ C09_SKILL_FIGHT
+	kDMSkillThrow = 10, // @ C10_SKILL_THROW
+	kDMSkillShoot = 11, // @ C11_SKILL_SHOOT
+	kDMSkillIdentify = 12, // @ C12_SKILL_IDENTIFY
+	kDMSkillHeal = 13, // @ C13_SKILL_HEAL
+	kDMSkillInfluence = 14, // @ C14_SKILL_INFLUENCE
+	kDMSkillDefend = 15, // @ C15_SKILL_DEFEND
+	kDMSkillFire = 16, // @ C16_SKILL_FIRE
+	kDMSkillAir = 17, // @ C17_SKILL_AIR
+	kDMSkillEarth = 18, // @ C18_SKILL_EARTH
+	kDMSkillWater = 19 // @ C19_SKILL_WATER
 };
 
 enum ChampionSlot {
@@ -350,6 +349,40 @@ enum AttackType {
 	k7_attackType_LIGHTNING = 7 // @ C7_ATTACK_LIGHTNING
 };
 
+#define k0x0000_maskDoNotUseSharpDefense 0x0000 // @ MASK0x0000_DO_NOT_USE_SHARP_DEFENSE 
+#define k0x8000_maskUseSharpDefense 0x8000 // @ MASK0x8000_USE_SHARP_DEFENSE        
+
+#define k0x8000_mergeCycles 0x8000 // @ MASK0x8000_MERGE_CYCLES
+
+#define k0_spellCastFailure 0 // @ C0_SPELL_CAST_FAILURE             
+#define k1_spellCastSuccess 1 // @ C1_SPELL_CAST_SUCCESS             
+#define k3_spellCastFailureNeedsFlask 3 // @ C3_SPELL_CAST_FAILURE_NEEDS_FLASK 
+
+#define k0_failureNeedsMorePractice 0 // @ C00_FAILURE_NEEDS_MORE_PRACTICE      
+#define k1_failureMeaninglessSpell 1 // @ C01_FAILURE_MEANINGLESS_SPELL        
+#define k10_failureNeedsFlaskInHand 10 // @ C10_FAILURE_NEEDS_FLASK_IN_HAND     
+#define k11_failureNeedsMagicMapInHand 11 // @ C11_FAILURE_NEEDS_MAGIC_MAP_IN_HAND 
+
+#define k1_spellKindPotion 1 // @ C1_SPELL_KIND_POTION    
+#define k2_spellKindProjectile 2 // @ C2_SPELL_KIND_PROJECTILE
+#define k3_spellKindOther 3 // @ C3_SPELL_KIND_OTHER     
+#define k4_spellKindMagicMap 4 // @ C4_SPELL_KIND_MAGIC_MAP 
+
+#define k4_spellType_projectileOpenDoor 4 // @ C4_SPELL_TYPE_PROJECTILE_OPEN_DOOR
+#define k0_spellType_otherLight 0 // @ C0_SPELL_TYPE_OTHER_LIGHT         
+#define k1_spellType_otherDarkness 1 // @ C1_SPELL_TYPE_OTHER_DARKNESS      
+#define k2_spellType_otherThievesEye 2 // @ C2_SPELL_TYPE_OTHER_THIEVES_EYE   
+#define k3_spellType_otherInvisibility 3 // @ C3_SPELL_TYPE_OTHER_INVISIBILITY  
+#define k4_spellType_otherPartyShield 4 // @ C4_SPELL_TYPE_OTHER_PARTY_SHIELD  
+#define k5_spellType_otherMagicTorch 5 // @ C5_SPELL_TYPE_OTHER_MAGIC_TORCH   
+#define k6_spellType_otherFootprints 6 // @ C6_SPELL_TYPE_OTHER_FOOTPRINTS    
+#define k7_spellType_otherZokathra 7 // @ C7_SPELL_TYPE_OTHER_ZOKATHRA      
+#define k8_spellType_otherFireshield 8 // @ C8_SPELL_TYPE_OTHER_FIRESHIELD    
+#define k0_spellType_magicMap0 0 // @ C0_SPELL_TYPE_MAGIC_MAP           
+#define k1_spellType_magicMap1 1 // @ C1_SPELL_TYPE_MAGIC_MAP           
+#define k2_spellType_magicMap2 2 // @ C2_SPELL_TYPE_MAGIC_MAP           
+#define k3_spellType_magicMap3 3 // @ C3_SPELL_TYPE_MAGIC_MAP           
+
 class Skill {
 public:
 	int16 _temporaryExperience;
@@ -397,18 +430,18 @@ public:
 	void setSkillExp(ChampionSkill skill,  int32 val) { _skills[skill]._experience = val; }
 	void setSkillTempExp(ChampionSkill skill,  int16 val) { _skills[skill]._temporaryExperience= val; }
 
-	byte& getStatistic(ChampionStatisticType type, ChampionStatisticValue valType) { return _statistics[type][valType]; }
-	void setStatistic(ChampionStatisticType type, ChampionStatisticValue valType, byte newVal) { _statistics[type][valType] = newVal; }
+	byte& getStatistic(ChampionStatType type, ChampionStatValue valType) { return _statistics[type][valType]; }
+	void setStatistic(ChampionStatType type, ChampionStatValue valType, byte newVal) { _statistics[type][valType] = newVal; }
 
 	uint16 getAttributes() { return _attributes; }
 	uint16 getAttributes(ChampionAttribute flag) { return _attributes & flag; }
 	void setAttributeFlag(ChampionAttribute flag, bool value);
-	void clearAttributes(ChampionAttribute attribute = kDMChampionAttributNone) { _attributes = attribute; }
+	void clearAttributes(ChampionAttribute attribute = kDMAttributNone) { _attributes = attribute; }
 
 	uint16 getWounds() { return _wounds; }
 	void setWoundsFlag(ChampionWound flag, bool value);
 	uint16 getWoundsFlag(ChampionWound wound) { return _wounds & wound; }
-	void clearWounds() { _wounds = kDMChampionWoundNone; }
+	void clearWounds() { _wounds = kDMWoundNone; }
 	void resetSkillsToZero() {
 		for (int16 i = 0; i < 20; ++i)
 			_skills[i].resetToZero();
@@ -417,40 +450,6 @@ public:
 
 }; // @ CHAMPION_INCLUDING_PORTRAIT
 
-#define k0x0000_maskDoNotUseSharpDefense 0x0000 // @ MASK0x0000_DO_NOT_USE_SHARP_DEFENSE 
-#define k0x8000_maskUseSharpDefense 0x8000 // @ MASK0x8000_USE_SHARP_DEFENSE        
-
-#define k0x8000_mergeCycles 0x8000 // @ MASK0x8000_MERGE_CYCLES
-
-#define k0_spellCastFailure 0 // @ C0_SPELL_CAST_FAILURE             
-#define k1_spellCastSuccess 1 // @ C1_SPELL_CAST_SUCCESS             
-#define k3_spellCastFailureNeedsFlask 3 // @ C3_SPELL_CAST_FAILURE_NEEDS_FLASK 
-
-#define k0_failureNeedsMorePractice 0 // @ C00_FAILURE_NEEDS_MORE_PRACTICE      
-#define k1_failureMeaninglessSpell 1 // @ C01_FAILURE_MEANINGLESS_SPELL        
-#define k10_failureNeedsFlaskInHand 10 // @ C10_FAILURE_NEEDS_FLASK_IN_HAND     
-#define k11_failureNeedsMagicMapInHand 11 // @ C11_FAILURE_NEEDS_MAGIC_MAP_IN_HAND 
-
-#define k1_spellKindPotion 1 // @ C1_SPELL_KIND_POTION    
-#define k2_spellKindProjectile 2 // @ C2_SPELL_KIND_PROJECTILE
-#define k3_spellKindOther 3 // @ C3_SPELL_KIND_OTHER     
-#define k4_spellKindMagicMap 4 // @ C4_SPELL_KIND_MAGIC_MAP 
-
-#define k4_spellType_projectileOpenDoor 4 // @ C4_SPELL_TYPE_PROJECTILE_OPEN_DOOR
-#define k0_spellType_otherLight 0 // @ C0_SPELL_TYPE_OTHER_LIGHT         
-#define k1_spellType_otherDarkness 1 // @ C1_SPELL_TYPE_OTHER_DARKNESS      
-#define k2_spellType_otherThievesEye 2 // @ C2_SPELL_TYPE_OTHER_THIEVES_EYE   
-#define k3_spellType_otherInvisibility 3 // @ C3_SPELL_TYPE_OTHER_INVISIBILITY  
-#define k4_spellType_otherPartyShield 4 // @ C4_SPELL_TYPE_OTHER_PARTY_SHIELD  
-#define k5_spellType_otherMagicTorch 5 // @ C5_SPELL_TYPE_OTHER_MAGIC_TORCH   
-#define k6_spellType_otherFootprints 6 // @ C6_SPELL_TYPE_OTHER_FOOTPRINTS    
-#define k7_spellType_otherZokathra 7 // @ C7_SPELL_TYPE_OTHER_ZOKATHRA      
-#define k8_spellType_otherFireshield 8 // @ C8_SPELL_TYPE_OTHER_FIRESHIELD    
-#define k0_spellType_magicMap0 0 // @ C0_SPELL_TYPE_MAGIC_MAP           
-#define k1_spellType_magicMap1 1 // @ C1_SPELL_TYPE_MAGIC_MAP           
-#define k2_spellType_magicMap2 2 // @ C2_SPELL_TYPE_MAGIC_MAP           
-#define k3_spellType_magicMap3 3 // @ C3_SPELL_TYPE_MAGIC_MAP           
-
 class Spell {
 public:
 	Spell() {}
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index a20293c..78ef3a7 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -655,7 +655,7 @@ void DMEngine::endGame(bool doNotDrawCreditsOnly) {
 					textPosX += 6;
 
 				_textMan->printEndGameString(textPosX, textPosY++, k9_ColorGold, curChampion->_title);
-				for (int16 idx = k0_ChampionSkillFighter; idx <= k3_ChampionSkillWizard; idx++) {
+				for (int16 idx = kDMSkillFighter; idx <= kDMSkillWizard; idx++) {
 					uint16 skillLevel = MIN<uint16>(16, _championMan->getSkillLevel(championIndex, idx | (kDMIgnoreObjectModifiers | kDMIgnoreTemporaryExperience)));
 					if (skillLevel == 1)
 						continue;
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index fdf66b7..cb33642 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1009,9 +1009,9 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 			movementArrowIdx += (_vm->_dungeonMan->_partyDir + 2);
 			int16 L1124_i_FirstDamagedChampionIndex = _vm->_championMan->getTargetChampionIndex(partyMapX, partyMapY, normalizeModulo4(movementArrowIdx));
 			int16 L1125_i_SecondDamagedChampionIndex = _vm->_championMan->getTargetChampionIndex(partyMapX, partyMapY, returnNextVal(movementArrowIdx));
-			int16 damage = _vm->_championMan->addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex, 1, kDMChampionWoundTorso | kDMChampionWoundLegs, k2_attackType_SELF);
+			int16 damage = _vm->_championMan->addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex, 1, kDMWoundTorso | kDMWoundLegs, k2_attackType_SELF);
 			if (L1124_i_FirstDamagedChampionIndex != L1125_i_SecondDamagedChampionIndex)
-				damage |= _vm->_championMan->addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, kDMChampionWoundTorso | kDMChampionWoundLegs, k2_attackType_SELF);
+				damage |= _vm->_championMan->addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, kDMWoundTorso | kDMWoundLegs, k2_attackType_SELF);
 
 			if (damage)
 				_vm->_sound->requestPlay(k18_soundPARTY_DAMAGED, partyMapX, partyMapY, k0_soundModePlayImmediately);
@@ -1110,8 +1110,8 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
 
 	if (cm._leaderIndex != kDMChampionNone) {
 		leaderIndex = cm._leaderIndex;
-		cm._champions[leaderIndex].setAttributeFlag(kDMChampionAttributeLoad, true);
-		cm._champions[leaderIndex].setAttributeFlag(kDMChampionAttributeNameTitle, true);
+		cm._champions[leaderIndex].setAttributeFlag(kDMAttributeLoad, true);
+		cm._champions[leaderIndex].setAttributeFlag(kDMAttributeNameTitle, true);
 		cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject);
 		cm._leaderIndex = kDMChampionNone;
 		cm.drawChampionState(leaderIndex);
@@ -1125,8 +1125,8 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) {
 	champion->_dir = _vm->_dungeonMan->_partyDir;
 	cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject);
 	if (_vm->indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) {
-		champion->setAttributeFlag(kDMChampionAttributeIcon, true);
-		champion->setAttributeFlag(kDMChampionAttributeNameTitle, true);
+		champion->setAttributeFlag(kDMAttributeIcon, true);
+		champion->setAttributeFlag(kDMAttributeNameTitle, true);
 		cm.drawChampionState(champIndex);
 	}
 }
@@ -1280,8 +1280,8 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 
 		for (uint16 i = 0; i < 12; i++) {
 			uint16 statIndex = _vm->getRandomNumber(7);
-			champ->getStatistic((ChampionStatisticType)statIndex, kDMChampionStatCurrent)++; // returns reference
-			champ->getStatistic((ChampionStatisticType)statIndex, kDMChampionStatMaximum)++; // returns reference
+			champ->getStatistic((ChampionStatType)statIndex, kDMStatCurrent)++; // returns reference
+			champ->getStatistic((ChampionStatType)statIndex, kDMStatMaximum)++; // returns reference
 		}
 	}
 
@@ -1476,19 +1476,19 @@ void EventManager::mouseProcessCommands125To128_clickOnChampionIcon(uint16 champ
 		_useChampionIconOrdinalAsMousePointerBitmap = _vm->indexToOrdinal(kDMChampionNone);
 		int16 championCellIndex = _vm->_championMan->getIndexInCell(normalizeModulo4(championIconIndex + _vm->_dungeonMan->_partyDir));
 		if (championIconIndex == champIconIndex) {
-			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, kDMChampionAttributeIcon);
+			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, kDMAttributeIcon);
 			_vm->_championMan->drawChampionState((ChampionIndex)championCellIndex);
 		} else {
 			int16 championIndex = _vm->_championMan->getIndexInCell(normalizeModulo4(champIconIndex + _vm->_dungeonMan->_partyDir));
 			if (championIndex >= 0) {
 				_vm->_championMan->_champions[championIndex]._cell = (ViewCell)normalizeModulo4(championIconIndex + _vm->_dungeonMan->_partyDir);
-				setFlag(_vm->_championMan->_champions[championIndex]._attributes, kDMChampionAttributeIcon);
+				setFlag(_vm->_championMan->_champions[championIndex]._attributes, kDMAttributeIcon);
 				_vm->_championMan->drawChampionState((ChampionIndex)championIndex);
 			} else
 				_vm->_displayMan->fillScreenBox(_vm->_championMan->_boxChampionIcons[championIconIndex], k0_ColorBlack);
 
 			_vm->_championMan->_champions[championCellIndex]._cell = (ViewCell)normalizeModulo4(champIconIndex + _vm->_dungeonMan->_partyDir);
-			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, kDMChampionAttributeIcon);
+			setFlag(_vm->_championMan->_champions[championCellIndex]._attributes, kDMAttributeIcon);
 			_vm->_championMan->drawChampionState((ChampionIndex)championCellIndex);
 		}
 	}
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 78c76b8..89efd6b 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1577,7 +1577,7 @@ int16 GroupMan::getChampionDamage(Group *group, uint16 champIndex) {
 
 	int16 doubledMapDifficulty = _vm->_dungeonMan->_currMap->_difficulty << 1;
 	CreatureInfo creatureInfo = _vm->_dungeonMan->_creatureInfos[group->_type];
-	_vm->_championMan->addSkillExperience(champIndex, k7_ChampionSkillParry, creatureInfo.getExperience());
+	_vm->_championMan->addSkillExperience(champIndex, kDMSkillParry, creatureInfo.getExperience());
 	if (_vm->_championMan->_partyIsSleeping || (((_vm->_championMan->getDexterity(curChampion) < (_vm->getRandomNumber(32) + creatureInfo._dexterity + doubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !_vm->_championMan->isLucky(curChampion, 60))) {
 		uint16 allowedWound;
 		uint16 woundTest = _vm->getRandomNumber(65536);
@@ -1592,7 +1592,7 @@ int16 GroupMan::getChampionDamage(Group *group, uint16 champIndex) {
 		} else
 			allowedWound = woundTest & 0x0001; /* 0 (Ready hand) or 1 (action hand) */
 
-		int16 attack = (_vm->getRandomNumber(16) + creatureInfo._attack + doubledMapDifficulty) - (_vm->_championMan->getSkillLevel(champIndex, k7_ChampionSkillParry) << 1);
+		int16 attack = (_vm->getRandomNumber(16) + creatureInfo._attack + doubledMapDifficulty) - (_vm->_championMan->getSkillLevel(champIndex, kDMSkillParry) << 1);
 		if (attack <= 1) {
 			if (_vm->getRandomNumber(2))
 				return 0;
@@ -1613,7 +1613,7 @@ int16 GroupMan::getChampionDamage(Group *group, uint16 champIndex) {
 
 			uint16 poisonAttack = creatureInfo._poisonAttack;
 			if (poisonAttack && _vm->getRandomNumber(2)) {
-				poisonAttack = _vm->_championMan->getStatisticAdjustedAttack(curChampion, kDMChampionStatVitality, poisonAttack);
+				poisonAttack = _vm->_championMan->getStatisticAdjustedAttack(curChampion, kDMStatVitality, poisonAttack);
 				if (poisonAttack >= 0)
 					_vm->_championMan->championPoison(champIndex, poisonAttack);
 			}
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index e5540b5..07c7a5b 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -103,7 +103,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 		closeChest();
 		Champion *champion = &_vm->_championMan->_champions[_vm->ordinalToIndex(inventoryChampionOrdinal)];
 		if (champion->_currHealth && !_vm->_championMan->_candidateChampionOrdinal) {
-			setFlag(champion->_attributes, kDMChampionAttributeStatusBox);
+			setFlag(champion->_attributes, kDMAttributeStatusBox);
 			_vm->_championMan->drawChampionState((ChampionIndex)_vm->ordinalToIndex(inventoryChampionOrdinal));
 		}
 		if (_vm->_championMan->_partyIsSleeping) {
@@ -152,7 +152,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 	for (uint16 i = k0_ChampionSlotReadyHand; i < k30_ChampionSlotChest_1; i++)
 		_vm->_championMan->drawSlot(championIndex, i);
 
-	setFlag(champion->_attributes, kDMChampionAttributeViewport | kDMChampionAttributeStatusBox | kDMChampionAttributePanel | kDMChampionAttributeLoad | kDMChampionAttributeStatistics | kDMChampionAttributeNameTitle);
+	setFlag(champion->_attributes, kDMAttributeViewport | kDMAttributeStatusBox | kDMAttributePanel | kDMAttributeLoad | kDMAttributeStatistics | kDMAttributeNameTitle);
 	_vm->_championMan->drawChampionState(championIndex);
 	_vm->_eventMan->_mousePointerBitmapUpdated = true;
 	_vm->_eventMan->hideMouse();
@@ -515,7 +515,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
 			descString = str;
 		} else if ((thingType == k8_PotionThingType)
 				   && (iconIndex != kDMIconIndicePotionWaterFlask)
-				   && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
+				   && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_inventoryChampionOrdinal), kDMSkillPriest) > 1)) {
 			str = ('_' + ((Potion *)rawThingPtr)->getPower() / 40);
 			str += " ";
 			str += objMan._objectNames[iconIndex];
@@ -802,7 +802,7 @@ void InventoryMan::drawChampionSkillsAndStatistics() {
 	Champion *curChampion = &_vm->_championMan->_champions[championIndex];
 	_vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k20_PanelEmptyIndice), _boxPanel, k72_byteWidth, k8_ColorRed, 73);
 	int16 textPosY = 58;
-	for (uint16 idx = k0_ChampionSkillFighter; idx <= k3_ChampionSkillWizard; idx++) {
+	for (uint16 idx = kDMSkillFighter; idx <= kDMSkillWizard; idx++) {
 		int16 skillLevel = MIN((uint16)16, _vm->_championMan->getSkillLevel(championIndex, idx | kDMIgnoreTemporaryExperience));
 		if (skillLevel == 1)
 			continue;
@@ -822,10 +822,10 @@ void InventoryMan::drawChampionSkillsAndStatistics() {
 		textPosY += 7;
 	}
 	textPosY = 86;
-	for (uint16 idx = kDMChampionStatStrength; idx <= kDMChampionStatAntifire; idx++) {
+	for (uint16 idx = kDMStatStrength; idx <= kDMStatAntifire; idx++) {
 		_vm->_textMan->printToViewport(108, textPosY, k13_ColorLightestGray, statisticNames[idx]);
-		int16 statisticCurrentValue = curChampion->_statistics[idx][kDMChampionStatCurrent];
-		uint16 statisticMaximumValue = curChampion->_statistics[idx][kDMChampionStatMaximum];
+		int16 statisticCurrentValue = curChampion->_statistics[idx][kDMStatCurrent];
+		uint16 statisticMaximumValue = curChampion->_statistics[idx][kDMStatMaximum];
 		int16 statisticColor;
 		if (statisticCurrentValue < statisticMaximumValue)
 			statisticColor = k8_ColorRed;
@@ -932,16 +932,16 @@ void InventoryMan::clickOnMouth() {
 
 		switch (((Potion *)junkData)->getType()) {
 		case k6_PotionTypeRos:
-			adjustStatisticCurrentValue(curChampion, kDMChampionStatDexterity, adjustedPotionPower);
+			adjustStatisticCurrentValue(curChampion, kDMStatDexterity, adjustedPotionPower);
 			break;
 		case k7_PotionTypeKu:
-			adjustStatisticCurrentValue(curChampion, kDMChampionStatStrength, (((Potion *)junkData)->getPower() / 35) + 5); /* Value between 5 and 12 */
+			adjustStatisticCurrentValue(curChampion, kDMStatStrength, (((Potion *)junkData)->getPower() / 35) + 5); /* Value between 5 and 12 */
 			break;
 		case k8_PotionTypeDane:
-			adjustStatisticCurrentValue(curChampion, kDMChampionStatWisdom, adjustedPotionPower);
+			adjustStatisticCurrentValue(curChampion, kDMStatWisdom, adjustedPotionPower);
 			break;
 		case k9_PotionTypeNeta:
-			adjustStatisticCurrentValue(curChampion, kDMChampionStatVitality, adjustedPotionPower);
+			adjustStatisticCurrentValue(curChampion, kDMStatVitality, adjustedPotionPower);
 			break;
 		case k10_PotionTypeAntivenin:
 			_vm->_championMan->unpoison(championIndex);
@@ -961,7 +961,7 @@ void InventoryMan::clickOnMouth() {
 			newEvent._priority = championIndex;
 			newEvent._B._defense = adjustedPotionPower;
 			_vm->_timeline->addEventGetEventIndex(&newEvent);
-			setFlag(curChampion->_attributes, kDMChampionAttributeStatusBox);
+			setFlag(curChampion->_attributes, kDMAttributeStatusBox);
 			}
 			break;
 		case k13_PotionTypeEe: {
@@ -985,7 +985,7 @@ void InventoryMan::clickOnMouth() {
 					healWoundIterationCount = 1;
 				} while ((wounds == curChampion->_wounds) && --counter); /* Loop until at least one wound is healed or there are no more heal iterations */
 			}
-			setFlag(curChampion->_attributes, kDMChampionAttributeLoad | kDMChampionAttributeWounds);
+			setFlag(curChampion->_attributes, kDMAttributeLoad | kDMAttributeWounds);
 			}
 			break;
 		case k15_PotionTypeWaterFlask:
@@ -1015,13 +1015,13 @@ void InventoryMan::clickOnMouth() {
 	} else {
 		_vm->_championMan->drawChangedObjectIcons();
 		_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(handThing) - handThingWeight;
-		setFlag(_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._attributes, kDMChampionAttributeLoad);
+		setFlag(_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._attributes, kDMAttributeLoad);
 	}
 	_vm->_sound->requestPlay(k08_soundSWALLOW, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
-	setFlag(curChampion->_attributes, kDMChampionAttributeStatistics);
+	setFlag(curChampion->_attributes, kDMAttributeStatistics);
 
 	if (_panelContent == k0_PanelContentFoodWaterPoisoned)
-		setFlag(curChampion->_attributes, kDMChampionAttributePanel);
+		setFlag(curChampion->_attributes, kDMAttributePanel);
 
 	_vm->_championMan->drawChampionState((ChampionIndex)championIndex);
 	_vm->_eventMan->hideMouse();
@@ -1030,7 +1030,7 @@ void InventoryMan::clickOnMouth() {
 void InventoryMan::adjustStatisticCurrentValue(Champion *champ, uint16 statIndex, int16 valueDelta) {
 	int16 delta;
 	if (valueDelta >= 0) {
-		int16 currentValue = champ->_statistics[statIndex][kDMChampionStatCurrent];
+		int16 currentValue = champ->_statistics[statIndex][kDMStatCurrent];
 		if (currentValue > 120) {
 			valueDelta >>= 1;
 			if (currentValue > 150) {
@@ -1040,9 +1040,9 @@ void InventoryMan::adjustStatisticCurrentValue(Champion *champ, uint16 statIndex
 		}
 		delta = MIN(valueDelta, (int16)(170 - currentValue));
 	} else { /* BUG0_00 Useless code. The function is always called with valueDelta having a positive value */
-		delta = MAX(valueDelta, int16(champ->_statistics[statIndex][kDMChampionStatMinimum] - champ->_statistics[statIndex][kDMChampionStatCurrent]));
+		delta = MAX(valueDelta, int16(champ->_statistics[statIndex][kDMStatMinimum] - champ->_statistics[statIndex][kDMStatCurrent]));
 	}
-	champ->_statistics[statIndex][kDMChampionStatCurrent] += delta;
+	champ->_statistics[statIndex][kDMStatCurrent] += delta;
 }
 
 void InventoryMan::clickOnEye() {
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index bcbe89f..4ad8646 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -175,7 +175,7 @@ void MenuMan::clearActingChampion() {
 	ChampionMan &cm = *_vm->_championMan;
 	if (cm._actingChampionOrdinal) {
 		cm._actingChampionOrdinal--;
-		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kDMChampionAttributeActionHand, true);
+		cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kDMAttributeActionHand, true);
 		cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal);
 		cm._actingChampionOrdinal = _vm->indexToOrdinal(kDMChampionNone);
 		_refreshActionArea = true;
@@ -221,7 +221,7 @@ T0386006:
 	box2._y1 = 95;
 	box2._y2 = 110;
 	dm.blitToScreen(bitmapIcon, &box2, k8_byteWidth, kM1_ColorNoTransparency, 16);
-	if (champion.getAttributes(kDMChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) {
+	if (champion.getAttributes(kDMAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) {
 		_vm->_displayMan->shadeScreenBox(&box, k0_ColorBlack);
 	}
 }
@@ -268,7 +268,7 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
 				&& (champ->_dir != champ->_directionMaximumDamageReceived)) {
 
 				champ->_dir = (Direction)champ->_directionMaximumDamageReceived;
-				champ->setAttributeFlag(kDMChampionAttributeIcon, true);
+				champ->setAttributeFlag(kDMAttributeIcon, true);
 				champMan.drawChampionState((ChampionIndex)champIndex);
 			}
 			champ->_maximumDamageReceived = 0;
@@ -288,7 +288,7 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() {
 			}
 		} else {
 			_actionAreaContainsIcons = false;
-			champ->setAttributeFlag(kDMChampionAttributeActionHand, true);
+			champ->setAttributeFlag(kDMAttributeActionHand, true);
 			champMan.drawChampionState((ChampionIndex)_vm->ordinalToIndex(champMan._actingChampionOrdinal));
 			drawActionArea();
 		}
@@ -540,7 +540,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 	if (skillLevel < requiredSkillLevel) {
 		int16 missingSkillLevelCount = requiredSkillLevel - skillLevel;
 		while (missingSkillLevelCount--) {
-			if (_vm->getRandomNumber(128) > MIN(curChampion->_statistics[kDMChampionStatWisdom][kDMChampionStatCurrent] + 15, 115)) {
+			if (_vm->getRandomNumber(128) > MIN(curChampion->_statistics[kDMStatWisdom][kDMStatCurrent] + 15, 115)) {
 				_vm->_championMan->addSkillExperience(champIndex, curSpell->_skillIndex, experience >> (requiredSkillLevel - skillLevel));
 				menusPrintSpellFailureMessage(curChampion, k0_failureNeedsMorePractice, curSpell->_skillIndex);
 				return k0_spellCastFailure;
@@ -561,7 +561,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 		curChampion->_load += _vm->_dungeonMan->getObjectWeight(newObject) - emptyFlaskWeight;
 		_vm->_championMan->drawChangedObjectIcons();
 		if (_vm->_inventoryMan->_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex)) {
-			setFlag(curChampion->_attributes, kDMChampionAttributeLoad);
+			setFlag(curChampion->_attributes, kDMAttributeLoad);
 			_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 		}
 		}
@@ -569,7 +569,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 	case k2_spellKindProjectile:
 		if (curChampion->_dir != _vm->_dungeonMan->_partyDir) {
 			curChampion->_dir = _vm->_dungeonMan->_partyDir;
-			setFlag(curChampion->_attributes, kDMChampionAttributeIcon);
+			setFlag(curChampion->_attributes, kDMAttributeIcon);
 			_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 		}
 		if (curSpell->getType() == k4_spellType_projectileOpenDoor)
@@ -744,7 +744,7 @@ void MenuMan::menusPrintSpellFailureMessage(Champion *champ, uint16 failureType,
 	const char *messagesFR[5] = {" DOIT PRATIQUER DAVANTAGE SON ", "ENVOUTEMENT.", " MARMONNE UNE CONJURATION IMCOMPREHENSIBLE.",
 		" DOIT AVOIR UN FLACON VIDE EN MAIN POUR LA POTION.", "EXORCISME."};
 
-	if (skillIndex > k3_ChampionSkillWizard)
+	if (skillIndex > kDMSkillWizard)
 		skillIndex = (skillIndex - 4) / 4;
 
 	_vm->_textMan->printLineFeed();
@@ -768,7 +768,7 @@ void MenuMan::menusPrintSpellFailureMessage(Champion *champ, uint16 failureType,
 	case k0_failureNeedsMorePractice:
 		_vm->_textMan->printMessage(k4_ColorCyan, messages[0]);
 		_vm->_textMan->printMessage(k4_ColorCyan, _vm->_championMan->_baseSkillName[skillIndex]);
-		if (_vm->getGameLanguage() != Common::FR_FRA || skillIndex == k3_ChampionSkillWizard)
+		if (_vm->getGameLanguage() != Common::FR_FRA || skillIndex == kDMSkillWizard)
 			message = messages[1];
 		else
 			message = messages[4];
@@ -889,7 +889,7 @@ void MenuMan::addChampionSymbol(int16 symbolIndex) {
 
 	if (manaCost <= casterChampion->_currMana) {
 		casterChampion->_currMana -= manaCost;
-		setFlag(casterChampion->_attributes, kDMChampionAttributeStatistics);
+		setFlag(casterChampion->_attributes, kDMAttributeStatistics);
 		casterChampion->_symbols[symbolStep] = 96 + (symbolStep * 6) + symbolIndex;
 		casterChampion->_symbols[symbolStep + 1] = '\0';
 		casterChampion->_symbolStep = symbolStep = returnNextVal(symbolStep);
@@ -932,7 +932,7 @@ bool MenuMan::didClickTriggerAction(int16 actionListIndex) {
 		if (_actionDisabledTicks[actionIndex])
 			curChampion->_actionDefense += _vm->_timeline->_actionDefense[actionIndex];
 
-		setFlag(curChampion->_attributes, kDMChampionAttributeStatistics);
+		setFlag(curChampion->_attributes, kDMAttributeStatistics);
 		retVal = isActionPerformed(championIndex, actionIndex);
 		curChampion->_actionIndex = (ChampionAction)actionIndex;
 	}
@@ -1055,7 +1055,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 	uint16 targetSquare = _vm->_dungeonMan->getSquare(nextMapX, nextMapY).toByte();
 
 	int16 requiredManaAmount = 0;
-	if (((actionSkillIndex >= k16_ChampionSkillFire) && (actionSkillIndex <= k19_ChampionSkillWater)) || (actionSkillIndex == k3_ChampionSkillWizard))
+	if (((actionSkillIndex >= kDMSkillFire) && (actionSkillIndex <= kDMSkillWater)) || (actionSkillIndex == kDMSkillWizard))
 		requiredManaAmount = 7 - MIN<uint16>(6, _vm->_championMan->getSkillLevel(champIndex, actionSkillIndex));
 
 	bool setDirectionFl = false;
@@ -1160,7 +1160,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		setChampionDirectionToPartyDirection(curChampion);
 		Thing removedObject = _vm->_championMan->getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
 		_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
-		_vm->_championMan->championShootProjectile(curChampion, removedObject, weaponInfoActionHand->_kineticEnergy + weaponInfoReadyHand->_kineticEnergy, (weaponInfoActionHand->getShootAttack() + _vm->_championMan->getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, stepEnergy);
+		_vm->_championMan->championShootProjectile(curChampion, removedObject, weaponInfoActionHand->_kineticEnergy + weaponInfoReadyHand->_kineticEnergy, (weaponInfoActionHand->getShootAttack() + _vm->_championMan->getSkillLevel(champIndex, kDMSkillShoot)) << 1, stepEnergy);
 		}
 		break;
 	case k5_ChampionActionFlip: {
@@ -1234,7 +1234,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		Experience gain is 2 + 2 * heal cycle count */
 		int16 missingHealth = curChampion->_maxHealth - curChampion->_currHealth;
 		if ((missingHealth > 0) && curChampion->_currMana) {
-			int16 healingCapability = MIN((uint16)10, _vm->_championMan->getSkillLevel(champIndex, k13_ChampionSkillHeal));
+			int16 healingCapability = MIN((uint16)10, _vm->_championMan->getSkillLevel(champIndex, kDMSkillHeal));
 			actionExperienceGain = 2;
 			uint16 healingAmount;
 			do {
@@ -1249,7 +1249,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 			if (curChampion->_currMana < 0)
 				curChampion->_currMana = 0;
 
-			setFlag(curChampion->_attributes, kDMChampionAttributeStatistics);
+			setFlag(curChampion->_attributes, kDMAttributeStatistics);
 			actionPerformed = true;
 		}
 		}
@@ -1340,7 +1340,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 void MenuMan::setChampionDirectionToPartyDirection(Champion *champ) {
 	if (champ->_dir != _vm->_dungeonMan->_partyDir) {
 		champ->_dir = _vm->_dungeonMan->_partyDir;
-		setFlag(champ->_attributes, kDMChampionAttributeIcon);
+		setFlag(champ->_attributes, kDMAttributeIcon);
 	}
 }
 
@@ -1528,7 +1528,7 @@ bool MenuMan::isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, in
 		experience = 45;
 		break;
 	}
-	frightAmount += _vm->_championMan->getSkillLevel(champIndex, k14_ChampionSkillInfluence);
+	frightAmount += _vm->_championMan->getSkillLevel(champIndex, kDMSkillInfluence);
 	Group *targetGroup = (Group *)_vm->_dungeonMan->getThingData(_actionTargetGroupThing);
 	CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[targetGroup->_type];
 	uint16 fearResistance = creatureInfo->getFearResistance();
@@ -1544,7 +1544,7 @@ bool MenuMan::isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, in
 		activeGroup->_delayFleeingFromTarget = ((16 - fearResistance) << 2) / creatureInfo->_movementTicks;
 		isGroupFrightenedByAction = true;
 	}
-	_vm->_championMan->addSkillExperience(champIndex, k14_ChampionSkillInfluence, experience);
+	_vm->_championMan->addSkillExperience(champIndex, kDMSkillInfluence, experience);
 
 	return isGroupFrightenedByAction;
 }
@@ -1627,7 +1627,7 @@ void MenuMan::processCommands116To119_setActingChampion(uint16 champIndex) {
 	};
 
 	Champion *curChampion = &_vm->_championMan->_champions[champIndex];
-	if (getFlag(curChampion->_attributes, kDMChampionAttributeDisableAction) || !curChampion->_currHealth)
+	if (getFlag(curChampion->_attributes, kDMAttributeDisableAction) || !curChampion->_currHealth)
 		return;
 
 	uint16 actionSetIndex;
@@ -1645,7 +1645,7 @@ void MenuMan::processCommands116To119_setActingChampion(uint16 champIndex) {
 	_vm->_championMan->_actingChampionOrdinal = _vm->indexToOrdinal(champIndex);
 	setActionList(actionSet);
 	_actionAreaContainsIcons = false;
-	setFlag(curChampion->_attributes, kDMChampionAttributeActionHand);
+	setFlag(curChampion->_attributes, kDMAttributeActionHand);
 	_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	drawActionArea();
 	drawActionArea();
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 77717de..2475ebc 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -331,7 +331,7 @@ bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destM
 									if (curChampion->_currHealth)
 										_vm->_championMan->decrementStamina(championIdx, ((curChampion->_load * 25) / _vm->_championMan->getMaximumLoad(curChampion)) + 1);
 								}
-							} else if (_vm->_championMan->getDamagedChampionCount(20, kDMChampionWoundLegs | kDMChampionWoundFeet, k2_attackType_SELF))
+							} else if (_vm->_championMan->getDamagedChampionCount(20, kDMWoundLegs | kDMWoundFeet, k2_attackType_SELF))
 								_vm->_sound->requestPlay(k06_soundSCREAM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
 						}
 						_useRopeToClimbDownPit = false;
@@ -927,7 +927,7 @@ void MovesensMan::triggerEffect(Sensor *sensor, int16 effect, int16 mapX, int16
 
 void MovesensMan::triggerLocalEffect(int16 localEffect, int16 effX, int16 effY, int16 effCell) {
 	if (localEffect == k10_SensorEffAddExp) {
-		addSkillExperience(k8_ChampionSkillSteal, 300, localEffect != kM1_CellAny);
+		addSkillExperience(kDMSkillSteal, 300, localEffect != kM1_CellAny);
 		return;
 	}
 	_sensorRotationEffect = localEffect;
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 48f122c..cbf0085 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -195,7 +195,7 @@ bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, in
 		break;
 	}
 	if (championAttack && _projectilePoisonAttack && _vm->getRandomNumber(2)
-	&& _vm->_championMan->addPendingDamageAndWounds_getDamage(championIndex, attack, kDMChampionWoundHead | kDMChampionWoundTorso, _projectileAttackType))
+	&& _vm->_championMan->addPendingDamageAndWounds_getDamage(championIndex, attack, kDMWoundHead | kDMWoundTorso, _projectileAttackType))
 		_vm->_championMan->championPoison(championIndex, _projectilePoisonAttack);
 
 	if (createExplosionOnImpact || removePotion) {
@@ -325,7 +325,7 @@ void ProjExpl::createExplosion(Thing explThing, uint16 attack, uint16 mapXCombo,
 		attack += _vm->getRandomNumber(attack) + 1;
 		if ((explThing == Thing::_explFireBall) || (attack >>= 1)) {
 			if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (projectileMapX == _vm->_dungeonMan->_partyMapX) && (projectileMapY == _vm->_dungeonMan->_partyMapY)) {
-				int16 wounds = kDMChampionWoundReadHand | kDMChampionWoundActionHand | kDMChampionWoundHead | kDMChampionWoundTorso | kDMChampionWoundLegs | kDMChampionWoundFeet;
+				int16 wounds = kDMWoundReadHand | kDMWoundActionHand | kDMWoundHead | kDMWoundTorso | kDMWoundLegs | kDMWoundFeet;
 				_vm->_championMan->getDamagedChampionCount(attack, wounds, k1_attackType_FIRE);
 			} else {
 				unusedThing = _vm->_groupMan->groupGetThing(projectileMapX, projectileMapY);
@@ -536,7 +536,7 @@ void ProjExpl::processEvent25(TimelineEvent *event) {
 		break;
 	case 0xFF87:
 		if (explosionOnPartySquare)
-			_vm->_championMan->getDamagedChampionCount(attack, kDMChampionWoundNone, k0_attackType_NORMAL);
+			_vm->_championMan->getDamagedChampionCount(attack, kDMWoundNone, k0_attackType_NORMAL);
 		else if ((groupThing != Thing::_endOfList)
 			&& (attack = _vm->_groupMan->groupGetResistanceAdjustedPoisonAttack(creatureType, attack))
 			&& (_vm->_groupMan->getDamageAllCreaturesOutcome(group, mapX, mapY, attack, true) != k2_outcomeKilledAllCreaturesInGroup)
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 234881e..f92a09f 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -333,7 +333,7 @@ void Timeline::processTimeline() {
 				break;
 			case k72_TMEventTypeChampionShield:
 				_vm->_championMan->_champions[newEvent._priority]._shieldDefense -= newEvent._B._defense;
-				setFlag(_vm->_championMan->_champions[newEvent._priority]._attributes, kDMChampionAttributeStatusBox);
+				setFlag(_vm->_championMan->_champions[newEvent._priority]._attributes, kDMAttributeStatusBox);
 				_vm->_championMan->drawChampionState((ChampionIndex)newEvent._priority);
 				break;
 			case k73_TMEventTypeThievesEye:
@@ -400,7 +400,7 @@ void Timeline::processEventDoorAnimation(TimelineEvent *event) {
 				// Strangerke
 				// Original bug fixed - A closing horizontal door wounds champions to the head instead of to the hands. Missing parenthesis in the condition cause all doors to wound the head in addition to the torso
 				// See BUG0_78
-				int16 wounds = kDMChampionWoundTorso | (verticalDoorFl ? kDMChampionWoundHead : kDMChampionWoundReadHand | kDMChampionWoundActionHand);
+				int16 wounds = kDMWoundTorso | (verticalDoorFl ? kDMWoundHead : kDMWoundReadHand | kDMWoundActionHand);
 				if (_vm->_championMan->getDamagedChampionCount(5, wounds, k2_attackType_SELF))
 					_vm->_sound->requestPlay(k18_soundPARTY_DAMAGED, mapX, mapY, k1_soundModePlayIfPrioritized);
 			}
@@ -815,7 +815,7 @@ void Timeline::procesEventEnableGroupGenerator(TimelineEvent *event) {
 void Timeline::processEventEnableChampionAction(uint16 champIndex) {
 	Champion *curChampion = &_vm->_championMan->_champions[champIndex];
 	curChampion->_enableActionEventIndex = -1;
-	clearFlag(curChampion->_attributes, kDMChampionAttributeDisableAction);
+	clearFlag(curChampion->_attributes, kDMAttributeDisableAction);
 	if (curChampion->_actionIndex != k255_ChampionActionNone) {
 		curChampion->_actionDefense -= _actionDefense[curChampion->_actionDefense];
 	}
@@ -832,7 +832,7 @@ void Timeline::processEventEnableChampionAction(uint16 champIndex) {
 				}
 			}
 		}
-		setFlag(curChampion->_attributes, kDMChampionAttributeActionHand);
+		setFlag(curChampion->_attributes, kDMAttributeActionHand);
 		_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	}
 	curChampion->_actionIndex = k255_ChampionActionNone;
@@ -872,7 +872,7 @@ void Timeline::processEventHideDamageReceived(uint16 champIndex) {
 		_vm->_inventoryMan->drawStatusBoxPortrait((ChampionIndex)champIndex);
 		_vm->_eventMan->hideMouse();
 	} else {
-		setFlag(curChampion->_attributes, kDMChampionAttributeNameTitle);
+		setFlag(curChampion->_attributes, kDMAttributeNameTitle);
 		_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	}
 }
@@ -905,7 +905,7 @@ void Timeline::processEventLight(TimelineEvent *event) {
 
 void Timeline::refreshAllChampionStatusBoxes() {
 	for (uint16 idx = kDMChampionFirst; idx < _vm->_championMan->_partyChampionCount; idx++)
-		setFlag(_vm->_championMan->_champions[idx]._attributes, kDMChampionAttributeStatusBox);
+		setFlag(_vm->_championMan->_champions[idx]._attributes, kDMAttributeStatusBox);
 
 	_vm->_championMan->drawAllChampionStates();
 }


Commit: 33287b765735e48185d45f7367eb091310c715f4
    https://github.com/scummvm/scummvm/commit/33287b765735e48185d45f7367eb091310c715f4
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-10T00:12:07+02:00

Commit Message:
DM: Fix regression in 4613e8ffad84e76d06024448f9215439d5cea5e7

Changed paths:
    engines/dm/gfx.cpp



diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 56dacec..3c992a8 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -3730,8 +3730,7 @@ T0115200_DrawExplosion:
 				blitToBitmap(bitmapRedBanana, _bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport, k10_ColorFlesh, heightRedEagle, k136_heightViewport);
 			}
 		}
-		thingParam = _vm->_dungeonMan->getNextThing(thingParam);
-	} while (thingParam != Thing::_endOfList);
+	} while ((thingParam = _vm->_dungeonMan->getNextThing(thingParam))!= Thing::_endOfList);
 
 	if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_doNotDrawFluxcagesDuringEndgame) { /* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */
 		AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */


Commit: d588e15dad218c4b797a16cf694a954e4d5b35b7
    https://github.com/scummvm/scummvm/commit/d588e15dad218c4b797a16cf694a954e4d5b35b7
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-10T11:47:36+02:00

Commit Message:
DM: Rename ChampionSlot enum

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/eventman.cpp
    engines/dm/group.cpp
    engines/dm/inventory.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index eeea8bf..4f02db1 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -186,7 +186,7 @@ bool ChampionMan::isLeaderHandObjectThrown(int16 side) {
 	if (_leaderIndex == kDMChampionNone)
 		return false;
 
-	return isObjectThrown(_leaderIndex, kM1_ChampionSlotLeaderHand, side);
+	return isObjectThrown(_leaderIndex, kDMSlotLeaderHand, side);
 }
 
 bool ChampionMan::isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side) {
@@ -201,9 +201,9 @@ bool ChampionMan::isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side)
 
 		curThing = getObjectRemovedFromLeaderHand();
 		curChampion = &_champions[champIndex];
-		actionHandThing = curChampion->getSlot(k1_ChampionSlotActionHand);
-		curChampion->setSlot(k1_ChampionSlotActionHand, curThing);
-		slotIndex = k1_ChampionSlotActionHand;
+		actionHandThing = curChampion->getSlot(kDMSlotActionHand);
+		curChampion->setSlot(kDMSlotActionHand, curThing);
+		slotIndex = kDMSlotActionHand;
 		throwingLeaderHandObjectFl = true;
 	}
 
@@ -293,7 +293,7 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 
 	bool cursed = false;
 	if (((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType))
-		&& (slotIndex >= k0_ChampionSlotReadyHand) && (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) {
+		&& (slotIndex >= kDMSlotReadyHand) && (slotIndex <= kDMSlotQuiverLine1_1)) {
 		if (thingType == k5_WeaponThingType) {
 			Weapon *weapon = (Weapon *)_vm->_dungeonMan->getThingData(thing);
 			cursed = weapon->getCursed();
@@ -312,10 +312,10 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 	if (!cursed) {
 		statIndex = (ChampionStatType)thingType; // variable sharing
 
-		if ((iconIndex == kDMIconIndiceJunkRabbitsFoot) && (slotIndex < k30_ChampionSlotChest_1)) {
+		if ((iconIndex == kDMIconIndiceJunkRabbitsFoot) && (slotIndex < kDMSlotChest1)) {
 			statIndex = kDMStatLuck;
 			modifier = 10;
-		} else if (slotIndex == k1_ChampionSlotActionHand) {
+		} else if (slotIndex == kDMSlotActionHand) {
 			if (iconIndex == kDMIconIndiceWeaponMaceOfOrder) {
 				statIndex = kDMStatStrength;
 				modifier = 5;
@@ -366,12 +366,12 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 					}
 				}
 			}
-		} else if (slotIndex == k4_ChampionSlotLegs) {
+		} else if (slotIndex == kDMSlotLegs) {
 			if (iconIndex == kDMIconIndiceArmourPowertowers) {
 				statIndex = kDMStatStrength;
 				modifier = 10;
 			}
-		} else if (slotIndex == k2_ChampionSlotHead) {
+		} else if (slotIndex == kDMSlotHead) {
 			switch (iconIndex) {
 			case kDMIconIndiceArmourCrownOfNerra:
 				statIndex = kDMStatWisdom;
@@ -384,7 +384,7 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 			default:
 				break;
 			}
-		} else if (slotIndex == k3_ChampionSlotTorso) {
+		} else if (slotIndex == kDMSlotTorso) {
 			switch (iconIndex) {
 			case kDMIconIndiceArmourFlamebain:
 				statIndex = kDMStatAntifire;
@@ -397,7 +397,7 @@ void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, i
 			default:
 				break;
 			}
-		} else if (slotIndex == k10_ChampionSlotNeck) {
+		} else if (slotIndex == kDMSlotNeck) {
 			switch (iconIndex) {
 			case kDMIconIndiceJunkJewelSymalUnequipped:
 			case kDMIconIndiceJunkJewelSymalEquipped:
@@ -484,7 +484,7 @@ void ChampionMan::drawChangedObjectIcons() {
 			continue;
 
 		if (hasObjectIconInSlotBoxChanged(slotBoxIndex, _champions[champIndex].getSlot((ChampionSlot)getHandSlotIndex(slotBoxIndex)))
-			&& (getHandSlotIndex(slotBoxIndex) == k1_ChampionSlotActionHand)) {
+			&& (getHandSlotIndex(slotBoxIndex) == kDMSlotActionHand)) {
 
 			menuMan.drawActionIcon((ChampionIndex)champIndex);
 		}
@@ -492,13 +492,13 @@ void ChampionMan::drawChangedObjectIcons() {
 
 	if (invChampOrdinal) {
 		Champion *champ = &_champions[_vm->ordinalToIndex(invChampOrdinal)];
-		Thing *thing = &champ->getSlot(k0_ChampionSlotReadyHand);
+		Thing *thing = &champ->getSlot(kDMSlotReadyHand);
 		uint16 drawViewport = 0;
 
-		for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++, thing++) {
+		for (uint16 slotIndex = kDMSlotReadyHand; slotIndex < kDMSlotChest1; slotIndex++, thing++) {
 			uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + k8_SlotBoxInventoryFirstSlot, *thing) ? 1 : 0;
 			drawViewport |= objIconChanged;
-			if (objIconChanged && (slotIndex == k1_ChampionSlotActionHand)) {
+			if (objIconChanged && (slotIndex == kDMSlotActionHand)) {
 				menuMan.drawActionIcon((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
 			}
 		}
@@ -531,8 +531,8 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 
 	Champion *champ = &_champions[champIndex];
 
-	if (slotIndex >= k30_ChampionSlotChest_1) {
-		invMan._chestSlots[slotIndex - k30_ChampionSlotChest_1] = thing;
+	if (slotIndex >= kDMSlotChest1) {
+		invMan._chestSlots[slotIndex - kDMSlotChest1] = thing;
 	} else {
 		champ->setSlot(slotIndex, thing);
 	}
@@ -544,8 +544,8 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 	applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
 	uint16 *rawObjPtr = dunMan.getThingData(thing);
 
-	if (slotIndex < k2_ChampionSlotHead) {
-		if (slotIndex == k1_ChampionSlotActionHand) {
+	if (slotIndex < kDMSlotHead) {
+		if (slotIndex == kDMSlotActionHand) {
 			champ->setAttributeFlag(kDMAttributeActionHand, true);
 			if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
 				menuMan.clearActingChampion();
@@ -560,11 +560,11 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio
 			((Weapon *)rawObjPtr)->setLit(true);
 			_vm->_inventoryMan->setDungeonViewPalette();
 			drawChangedObjectIcons();
-		} else if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand) &&
+		} else if (isInventoryChampion && (slotIndex == kDMSlotActionHand) &&
 			((iconIndex == kDMIconIndiceContainerChestClosed) || ((iconIndex >= kDMIconIndiceScrollOpen) && (iconIndex <= kDMIconIndiceScrollClosed)))) {
 			champ->setAttributeFlag(kDMAttributePanel, true);
 		}
-	} else if (slotIndex == k10_ChampionSlotNeck) {
+	} else if (slotIndex == kDMSlotNeck) {
 		if ((iconIndex >= kDMIconIndiceJunkIllumuletUnequipped) && (iconIndex <= kDMIconIndiceJunkIllumuletEquipped)) {
 			((Junk *)rawObjPtr)->setChargeCount(1);
 			_party._magicalLightAmount += _lightPowerToLightAmount[2];
@@ -654,7 +654,7 @@ uint16 ChampionMan::getStrength(int16 champIndex, int16 slotIndex) {
 		strength += skillLevel << 1;
 	}
 	strength = getStaminaAdjustedValue(curChampion, strength);
-	if (getFlag(curChampion->_wounds, (slotIndex == k0_ChampionSlotReadyHand) ? kDMWoundReadHand : kDMWoundActionHand)) {
+	if (getFlag(curChampion->_wounds, (slotIndex == kDMSlotReadyHand) ? kDMWoundReadHand : kDMWoundActionHand)) {
 		strength >>= 1;
 	}
 	return getBoundedValue(0, strength >> 1, 100);
@@ -664,9 +664,9 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 	Champion *curChampion = &_champions[champIndex];
 	Thing curThing;
 
-	if (slotIndex >= k30_ChampionSlotChest_1) {
-		curThing = _vm->_inventoryMan->_chestSlots[slotIndex - k30_ChampionSlotChest_1];
-		_vm->_inventoryMan->_chestSlots[slotIndex - k30_ChampionSlotChest_1] = Thing::_none;
+	if (slotIndex >= kDMSlotChest1) {
+		curThing = _vm->_inventoryMan->_chestSlots[slotIndex - kDMSlotChest1];
+		_vm->_inventoryMan->_chestSlots[slotIndex - kDMSlotChest1] = Thing::_none;
 	} else {
 		curThing = curChampion->_slots[slotIndex];
 		curChampion->_slots[slotIndex] = Thing::_none;
@@ -681,7 +681,7 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 	applyModifiersToStatistics(curChampion, slotIndex, curIconIndex, -1, curThing);
 
 	Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->getThingData(curThing);
-	if (slotIndex == k10_ChampionSlotNeck) {
+	if (slotIndex == kDMSlotNeck) {
 		if ((curIconIndex >= kDMIconIndiceJunkIllumuletUnequipped) && (curIconIndex <= kDMIconIndiceJunkIllumuletEquipped)) {
 			((Junk *)curWeapon)->setChargeCount(0);
 			_party._magicalLightAmount -= _lightPowerToLightAmount[2];
@@ -695,8 +695,8 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 	if (isInventoryChampion)
 		setFlag(curChampion->_attributes, kDMAttributeViewport);
 
-	if (slotIndex < k2_ChampionSlotHead) {
-		if (slotIndex == k1_ChampionSlotActionHand) {
+	if (slotIndex < kDMSlotHead) {
+		if (slotIndex == kDMSlotActionHand) {
 			setFlag(curChampion->_attributes, kDMAttributeActionHand);
 			if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
 				_vm->_menuMan->clearActingChampion();
@@ -713,7 +713,7 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex)
 			drawChangedObjectIcons();
 		}
 
-		if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand)) {
+		if (isInventoryChampion && (slotIndex == kDMSlotActionHand)) {
 			switch (curIconIndex) {
 			case kDMIconIndiceContainerChestClosed:
 				_vm->_inventoryMan->closeChest();
@@ -761,7 +761,7 @@ int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 a
 	if (attackType != k0_attackType_NORMAL) {
 		uint16 defense = 0;
 		uint16 woundCount = 0;
-		for (int16 woundIndex = k0_ChampionSlotReadyHand; woundIndex <= k5_ChampionSlotFeet; woundIndex++) {
+		for (int16 woundIndex = kDMSlotReadyHand; woundIndex <= kDMSlotFeet; woundIndex++) {
 			if (allowedWounds & (1 << woundIndex)) {
 				woundCount++;
 				defense += getWoundDefense(champIndex, woundIndex | ((attackType == k4_attackType_SHARP) ? k0x8000_maskUseSharpDefense : k0x0000_maskDoNotUseSharpDefense));
@@ -848,7 +848,7 @@ int16 ChampionMan::getWoundDefense(int16 champIndex, uint16 woundIndex) {
 		clearFlag(woundIndex, k0x8000_maskUseSharpDefense);
 
 	uint16 armorShieldDefense = 0;
-	for (int16 slotIndex = k0_ChampionSlotReadyHand; slotIndex <= k1_ChampionSlotActionHand; slotIndex++) {
+	for (int16 slotIndex = kDMSlotReadyHand; slotIndex <= kDMSlotActionHand; slotIndex++) {
 		Thing curThing = curChampion->_slots[slotIndex];
 		if (curThing.getType() == k6_ArmourThingType) {
 			ArmourInfo *armorInfo = (ArmourInfo *)_vm->_dungeonMan->getThingData(curThing);
@@ -863,7 +863,7 @@ int16 ChampionMan::getWoundDefense(int16 champIndex, uint16 woundIndex) {
 		woundDefense >>= 1;
 
 	woundDefense += curChampion->_actionDefense + curChampion->_shieldDefense + _party._shieldDefense + armorShieldDefense;
-	if (woundIndex > k1_ChampionSlotActionHand) {
+	if (woundIndex > kDMSlotActionHand) {
 		Thing curThing = curChampion->_slots[woundIndex];
 		if (curThing.getType() == k6_ArmourThingType) {
 			ArmourInfo *armourInfo = (ArmourInfo *)_vm->_dungeonMan->getThingData(curThing);
@@ -1238,7 +1238,7 @@ int16 ChampionMan::getMovementTicks(Champion *champ) {
 	if (getFlag(champ->_wounds, kDMWoundFeet))
 		ticks += woundTicks;
 
-	if (_vm->_objectMan->getIconIndex(champ->_slots[k5_ChampionSlotFeet]) == kDMIconIndiceArmourBootOfSpeed)
+	if (_vm->_objectMan->getIconIndex(champ->_slots[kDMSlotFeet]) == kDMIconIndiceArmourBootOfSpeed)
 		ticks--;
 
 	return ticks;
@@ -1310,8 +1310,8 @@ void ChampionMan::clickOnSlotBox(uint16 slotBoxIndex) {
 
 	Thing leaderHandObject = _leaderHandObject;
 	Thing slotThing;
-	if (slotIndex >= k30_ChampionSlotChest_1) {
-		slotThing = _vm->_inventoryMan->_chestSlots[slotIndex - k30_ChampionSlotChest_1];
+	if (slotIndex >= kDMSlotChest1) {
+		slotThing = _vm->_inventoryMan->_chestSlots[slotIndex - kDMSlotChest1];
 	} else {
 		slotThing = _champions[champIndex]._slots[slotIndex];
 	}
@@ -1517,40 +1517,40 @@ void ChampionMan::championKill(uint16 champIndex) {
 
 void ChampionMan::dropAllObjects(uint16 champIndex) {
 	static const int16 slotDropOrder[30] = {
-		k5_ChampionSlotFeet,
-		k4_ChampionSlotLegs,
-		k9_ChampionSlotQuiverLine_2_2,
-		k8_ChampionSlotQuiverLine_1_2,
-		k7_ChampionSlotQuiverLine_2_1,
-		k12_ChampionSlotQuiverLine_1_1,
-		k6_ChampionSlotPouch_2,
-		k11_ChampionSlotPouch_1,
-		k3_ChampionSlotTorso,
-		k13_ChampionSlotBackpackLine_1_1,
-		k14_ChampionSlotBackpackLine_2_2,
-		k15_ChampionSlotBackpackLine_2_3,
-		k16_ChampionSlotBackpackLine_2_4,
-		k17_ChampionSlotBackpackLine_2_5,
-		k18_ChampionSlotBackpackLine_2_6,
-		k19_ChampionSlotBackpackLine_2_7,
-		k20_ChampionSlotBackpackLine_2_8,
-		k21_ChampionSlotBackpackLine_2_9,
-		k22_ChampionSlotBackpackLine_1_2,
-		k23_ChampionSlotBackpackLine_1_3,
-		k24_ChampionSlotBackpackLine_1_4,
-		k25_ChampionSlotBackpackLine_1_5,
-		k26_ChampionSlotBackpackLine_1_6,
-		k27_ChampionSlotBackpackLine_1_7,
-		k28_ChampionSlotBackpackLine_1_8,
-		k29_ChampionSlotBackpackLine_1_9,
-		k10_ChampionSlotNeck,
-		k2_ChampionSlotHead,
-		k0_ChampionSlotReadyHand,
-		k1_ChampionSlotActionHand
+		kDMSlotFeet,
+		kDMSlotLegs,
+		kDMSlotQuiverLine2_2,
+		kDMSlotQuiverLine1_2,
+		kDMSlotQuiverLine2_1,
+		kDMSlotQuiverLine1_1,
+		kDMSlotPouch_2,
+		kDMSlotPouch1,
+		kDMSlotTorso,
+		kDMSlotBackpackLine1_1,
+		kDMSlotBackpackLine2_2,
+		kDMSlotBackpackLine2_3,
+		kDMSlotBackpackLine2_4,
+		kDMSlotBackpackLine2_5,
+		kDMSlotBackpackLine2_6,
+		kDMSlotBackpackLine2_7,
+		kDMSlotBackpackLine2_8,
+		kDMSlotBackpackLine2_9,
+		kDMSlotBackpackLine1_2,
+		kDMSlotBackpackLine1_3,
+		kDMSlotBackpackLine1_4,
+		kDMSlotBackpackLine1_5,
+		kDMSlotBackpackLine1_6,
+		kDMSlotBackpackLine1_7,
+		kDMSlotBackpackLine1_8,
+		kDMSlotBackpackLine1_9,
+		kDMSlotNeck,
+		kDMSlotHead,
+		kDMSlotReadyHand,
+		kDMSlotActionHand
 	};
 
 	uint16 curCell = _champions[champIndex]._cell;
-	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
+	for (uint16 slotIndex = kDMSlotReadyHand; slotIndex < kDMSlotChest1; slotIndex++) {
 		Thing curThing = getObjectRemovedFromSlot(champIndex, slotDropOrder[slotIndex]);
 		if (curThing != Thing::_none)
 			_vm->_moveSens->getMoveResult(thingWithNewCell(curThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
@@ -1663,7 +1663,7 @@ void ChampionMan::applyTimeEffects() {
 				if (_partyIsSleeping)
 					healthGain <<= 1;
 
-				if (_vm->_objectMan->getIconIndex(championPtr->_slots[k10_ChampionSlotNeck]) == kDMIconIndiceJunkEkkhardCross)
+				if (_vm->_objectMan->getIconIndex(championPtr->_slots[kDMSlotNeck]) == kDMIconIndiceJunkEkkhardCross)
 					healthGain += (healthGain >> 1) + 1;
 
 				championPtr->_currHealth += MIN(healthGain, (int16)(championPtr->_maxHealth - championPtr->_currHealth));
@@ -1889,7 +1889,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	championPtr->_directionMaximumDamageReceived = _vm->_dungeonMan->_partyDir;
 	championPtr->_food = 1500 + _vm->getRandomNumber(256);
 	championPtr->_water = 1500 + _vm->getRandomNumber(256);
-	for (int16 slotIdx = k0_ChampionSlotReadyHand; slotIdx < k30_ChampionSlotChest_1; slotIdx++)
+	for (int16 slotIdx = kDMSlotReadyHand; slotIdx < kDMSlotChest1; slotIdx++)
 		championPtr->_slots[slotIdx] = Thing::_none;
 
 	Thing curThing = _vm->_dungeonMan->getSquareFirstThing(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
@@ -1963,16 +1963,16 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	uint16 championObjectsCell = returnOppositeDir(_vm->_dungeonMan->_partyDir);
 	curMapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir], curMapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
 	curThing = _vm->_dungeonMan->getSquareFirstThing(curMapX, curMapY);
-	int16 slotIdx = k13_ChampionSlotBackpackLine_1_1;
+	int16 slotIdx = kDMSlotBackpackLine1_1;
 	while (curThing != Thing::_endOfList) {
 		ThingType thingType = curThing.getType();
 		if ((thingType > k3_SensorThingType) && (curThing.getCell() == championObjectsCell)) {
 			int16 objectAllowedSlots = _vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(curThing)]._allowedSlots;
-			uint16 curSlotIndex = k0_ChampionSlotReadyHand;
+			uint16 curSlotIndex = kDMSlotReadyHand;
 			switch (thingType) {
 			case k6_ArmourThingType: {
 				bool skipCheck = false;
-				for (curSlotIndex = k2_ChampionSlotHead; curSlotIndex <= k5_ChampionSlotFeet; curSlotIndex++) {
+				for (curSlotIndex = kDMSlotHead; curSlotIndex <= kDMSlotFeet; curSlotIndex++) {
 					if (objectAllowedSlots & _slotMasks[curSlotIndex]) {
 						skipCheck = true;
 						break;
@@ -1982,36 +1982,36 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 				if (skipCheck)
 					break;
 
-				if ((objectAllowedSlots & _slotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
-					curSlotIndex = k10_ChampionSlotNeck;
+				if ((objectAllowedSlots & _slotMasks[kDMSlotNeck]) && (championPtr->_slots[kDMSlotNeck] == Thing::_none))
+					curSlotIndex = kDMSlotNeck;
 				else
 					curSlotIndex = slotIdx++;
 
 				break;
 			}
 			case k5_WeaponThingType:
-				if (championPtr->_slots[k1_ChampionSlotActionHand] == Thing::_none)
-					curSlotIndex = k1_ChampionSlotActionHand;
-				else if ((objectAllowedSlots & _slotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
-					curSlotIndex = k10_ChampionSlotNeck;
+				if (championPtr->_slots[kDMSlotActionHand] == Thing::_none)
+					curSlotIndex = kDMSlotActionHand;
+				else if ((objectAllowedSlots & _slotMasks[kDMSlotNeck]) && (championPtr->_slots[kDMSlotNeck] == Thing::_none))
+					curSlotIndex = kDMSlotNeck;
 				else
 					curSlotIndex = slotIdx++;
 				break;
 			case k7_ScrollThingType:
 			case k8_PotionThingType:
-				if (championPtr->_slots[k11_ChampionSlotPouch_1] == Thing::_none)
-					curSlotIndex = k11_ChampionSlotPouch_1;
-				else if (championPtr->_slots[k6_ChampionSlotPouch_2] == Thing::_none)
-					curSlotIndex = k6_ChampionSlotPouch_2;
-				else if ((objectAllowedSlots & _slotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
-					curSlotIndex = k10_ChampionSlotNeck;
+				if (championPtr->_slots[kDMSlotPouch1] == Thing::_none)
+					curSlotIndex = kDMSlotPouch1;
+				else if (championPtr->_slots[kDMSlotPouch_2] == Thing::_none)
+					curSlotIndex = kDMSlotPouch_2;
+				else if ((objectAllowedSlots & _slotMasks[kDMSlotNeck]) && (championPtr->_slots[kDMSlotNeck] == Thing::_none))
+					curSlotIndex = kDMSlotNeck;
 				else
 					curSlotIndex = slotIdx++;
 				break;
 			case k9_ContainerThingType:
 			case k10_JunkThingType:
-				if ((objectAllowedSlots & _slotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
-					curSlotIndex = k10_ChampionSlotNeck;
+				if ((objectAllowedSlots & _slotMasks[kDMSlotNeck]) && (championPtr->_slots[kDMSlotNeck] == Thing::_none))
+					curSlotIndex = kDMSlotNeck;
 				else
 					curSlotIndex = slotIdx++;
 
@@ -2021,8 +2021,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 			}
 
 			while (championPtr->_slots[curSlotIndex] != Thing::_none) {
-				if ((objectAllowedSlots & _slotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none))
-					curSlotIndex = k10_ChampionSlotNeck;
+				if ((objectAllowedSlots & _slotMasks[kDMSlotNeck]) && (championPtr->_slots[kDMSlotNeck] == Thing::_none))
+					curSlotIndex = kDMSlotNeck;
 				else
 					curSlotIndex = slotIdx++;
 			}
@@ -2104,7 +2104,7 @@ uint16 ChampionMan::getMaximumLoad(Champion *champ) {
 	if (wounds)
 		maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kDMWoundLegs) ? 2 : 3);
 
-	if (_vm->_objectMan->getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == kDMIconIndiceArmourElvenBoots)
+	if (_vm->_objectMan->getIconIndex(champ->getSlot(kDMSlotFeet)) == kDMIconIndiceArmourElvenBoots)
 		maximumLoad += maximumLoad * 16;
 
 	maximumLoad += 9;
@@ -2216,7 +2216,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		}
 	}
 	if (getFlag(championAttributes, kDMAttributeWounds)) {
-		for (int i = isInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; i >= k0_ChampionSlotReadyHand; i--)
+		for (int i = isInventoryChampion ? kDMSlotFeet : kDMSlotActionHand; i >= kDMSlotReadyHand; i--)
 			drawSlot(champIndex, i);
 
 		if (isInventoryChampion)
@@ -2275,7 +2275,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) {
 		setFlag(championAttributes, kDMAttributeViewport);
 	}
 	if (getFlag(championAttributes, kDMAttributeActionHand)) {
-		drawSlot(champIndex, k1_ChampionSlotActionHand);
+		drawSlot(champIndex, kDMSlotActionHand);
 		_vm->_menuMan->drawActionIcon(champIndex);
 		if (isInventoryChampion)
 			setFlag(championAttributes, kDMAttributeViewport);
@@ -2305,15 +2305,15 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 	uint16 slotBoxIndex;
 	if (!isInventoryChamp) {
 		// If drawing a slot for a champion other than the champion whose inventory is open
-		if ((slotIndex > k1_ChampionSlotActionHand) || (_candidateChampionOrdinal == _vm->indexToOrdinal(champIndex)))
+		if ((slotIndex > kDMSlotActionHand) || (_candidateChampionOrdinal == _vm->indexToOrdinal(champIndex)))
 			return;
 		slotBoxIndex = (champIndex << 1) + slotIndex;
 	} else
 		slotBoxIndex = k8_SlotBoxInventoryFirstSlot + slotIndex;
 
 	Thing thing;
-	if (slotIndex >= k30_ChampionSlotChest_1)
-		thing = _vm->_inventoryMan->_chestSlots[slotIndex - k30_ChampionSlotChest_1];
+	if (slotIndex >= kDMSlotChest1)
+		thing = _vm->_inventoryMan->_chestSlots[slotIndex - kDMSlotChest1];
 	else
 		thing = champ->getSlot((ChampionSlot)slotIndex);
 
@@ -2329,7 +2329,7 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 
 	int16 iconIndex;
 	if (thing == Thing::_none) {
-		if (slotIndex <= k5_ChampionSlotFeet) {
+		if (slotIndex <= kDMSlotFeet) {
 			iconIndex = kDMIconIndiceReadyHand + (slotIndex << 1);
 			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) {
 				iconIndex++;
@@ -2337,17 +2337,17 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 			} else
 				nativeBitmapIndex = k33_SlotBoxNormalIndice;
 		} else {
-			if ((slotIndex >= k10_ChampionSlotNeck) && (slotIndex <= k13_ChampionSlotBackpackLine_1_1))
-				iconIndex = kDMIconIndiceNeck + (slotIndex - k10_ChampionSlotNeck);
+			if ((slotIndex >= kDMSlotNeck) && (slotIndex <= kDMSlotBackpackLine1_1))
+				iconIndex = kDMIconIndiceNeck + (slotIndex - kDMSlotNeck);
 			else
 				iconIndex = kDMIconIndiceEmptyBox;
 		}
 	} else {
 		iconIndex = _vm->_objectMan->getIconIndex(thing); // BUG0_35
-		if (isInventoryChamp && (slotIndex == k1_ChampionSlotActionHand) && ((iconIndex == kDMIconIndiceContainerChestClosed) || (iconIndex == kDMIconIndiceScrollOpen))) {
+		if (isInventoryChamp && (slotIndex == kDMSlotActionHand) && ((iconIndex == kDMIconIndiceContainerChestClosed) || (iconIndex == kDMIconIndiceScrollOpen))) {
 			iconIndex++;
 		} // BUG2_00
-		if (slotIndex <= k5_ChampionSlotFeet) {
+		if (slotIndex <= kDMSlotFeet) {
 			if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex)))
 				nativeBitmapIndex = k34_SlotBoxWoundedIndice;
 			else
@@ -2355,7 +2355,7 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) {
 		}
 	}
 
-	if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->indexToOrdinal(champIndex) == _actingChampionOrdinal))
+	if ((slotIndex == kDMSlotActionHand) && (_vm->indexToOrdinal(champIndex) == _actingChampionOrdinal))
 		nativeBitmapIndex = k35_SlotBoxActingHandIndice;
 
 	if (nativeBitmapIndex != -1) {
@@ -2572,13 +2572,13 @@ uint16 ChampionMan::getSkillLevel(int16 champIndex, uint16 skillIndex) {
 		skillLevel++;
 	}
 	if (!ignoreObjModifiers) {
-		int16 actionHandIconIndex = _vm->_objectMan->getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
+		int16 actionHandIconIndex = _vm->_objectMan->getIconIndex(champ->_slots[kDMSlotActionHand]);
 		if (actionHandIconIndex == kDMIconIndiceWeaponTheFirestaff)
 			skillLevel++;
 		else if (actionHandIconIndex == kDMIconIndiceWeaponTheFirestaffComplete)
 			skillLevel += 2;
 
-		int16 neckIconIndex = _vm->_objectMan->getIconIndex(champ->_slots[k10_ChampionSlotNeck]);
+		int16 neckIconIndex = _vm->_objectMan->getIconIndex(champ->_slots[kDMSlotNeck]);
 		switch (skillIndex) {
 		case kDMSkillWizard:
 			if (neckIconIndex == kDMIconIndiceJunkPendantFeral)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index ef47994..bc2ee7c 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -207,7 +207,6 @@ enum ChampionWound {
 	kDMWoundFeet = 0x0020 // @ MASK0x0020_FEET
 };
 
-
 enum ChampionStatType {
 	kDMStatLuck = 0, // @ C0_STATISTIC_LUCK
 	kDMStatStrength = 1, // @ C1_STATISTIC_STRENGTH
@@ -249,45 +248,45 @@ enum ChampionSkill {
 };
 
 enum ChampionSlot {
-	kM1_ChampionSlotLeaderHand = -1, // @ CM1_SLOT_LEADER_HAND
-	k0_ChampionSlotReadyHand = 0, // @ C00_SLOT_READY_HAND
-	k1_ChampionSlotActionHand = 1, // @ C01_SLOT_ACTION_HAND
-	k2_ChampionSlotHead = 2, // @ C02_SLOT_HEAD
-	k3_ChampionSlotTorso = 3, // @ C03_SLOT_TORSO
-	k4_ChampionSlotLegs = 4, // @ C04_SLOT_LEGS
-	k5_ChampionSlotFeet = 5, // @ C05_SLOT_FEET
-	k6_ChampionSlotPouch_2 = 6, // @ C06_SLOT_POUCH_2
-	k7_ChampionSlotQuiverLine_2_1 = 7, // @ C07_SLOT_QUIVER_LINE2_1
-	k8_ChampionSlotQuiverLine_1_2 = 8, // @ C08_SLOT_QUIVER_LINE1_2
-	k9_ChampionSlotQuiverLine_2_2 = 9, // @ C09_SLOT_QUIVER_LINE2_2
-	k10_ChampionSlotNeck = 10, // @ C10_SLOT_NECK
-	k11_ChampionSlotPouch_1 = 11, // @ C11_SLOT_POUCH_1
-	k12_ChampionSlotQuiverLine_1_1 = 12, // @ C12_SLOT_QUIVER_LINE1_1
-	k13_ChampionSlotBackpackLine_1_1 = 13, // @ C13_SLOT_BACKPACK_LINE1_1
-	k14_ChampionSlotBackpackLine_2_2 = 14, // @ C14_SLOT_BACKPACK_LINE2_2
-	k15_ChampionSlotBackpackLine_2_3 = 15, // @ C15_SLOT_BACKPACK_LINE2_3
-	k16_ChampionSlotBackpackLine_2_4 = 16, // @ C16_SLOT_BACKPACK_LINE2_4
-	k17_ChampionSlotBackpackLine_2_5 = 17, // @ C17_SLOT_BACKPACK_LINE2_5
-	k18_ChampionSlotBackpackLine_2_6 = 18, // @ C18_SLOT_BACKPACK_LINE2_6
-	k19_ChampionSlotBackpackLine_2_7 = 19, // @ C19_SLOT_BACKPACK_LINE2_7
-	k20_ChampionSlotBackpackLine_2_8 = 20, // @ C20_SLOT_BACKPACK_LINE2_8
-	k21_ChampionSlotBackpackLine_2_9 = 21, // @ C21_SLOT_BACKPACK_LINE2_9
-	k22_ChampionSlotBackpackLine_1_2 = 22, // @ C22_SLOT_BACKPACK_LINE1_2
-	k23_ChampionSlotBackpackLine_1_3 = 23, // @ C23_SLOT_BACKPACK_LINE1_3
-	k24_ChampionSlotBackpackLine_1_4 = 24, // @ C24_SLOT_BACKPACK_LINE1_4
-	k25_ChampionSlotBackpackLine_1_5 = 25, // @ C25_SLOT_BACKPACK_LINE1_5
-	k26_ChampionSlotBackpackLine_1_6 = 26, // @ C26_SLOT_BACKPACK_LINE1_6
-	k27_ChampionSlotBackpackLine_1_7 = 27, // @ C27_SLOT_BACKPACK_LINE1_7
-	k28_ChampionSlotBackpackLine_1_8 = 28, // @ C28_SLOT_BACKPACK_LINE1_8
-	k29_ChampionSlotBackpackLine_1_9 = 29, // @ C29_SLOT_BACKPACK_LINE1_9
-	k30_ChampionSlotChest_1 = 30, // @ C30_SLOT_CHEST_1
-	k31_ChampionSlotChest_2 = 31, // @ C31_SLOT_CHEST_2
-	k32_ChampionSlotChest_3 = 32, // @ C32_SLOT_CHEST_3
-	k33_ChampionSlotChest_4 = 33, // @ C33_SLOT_CHEST_4
-	k34_ChampionSlotChest_5 = 34, // @ C34_SLOT_CHEST_5
-	k35_ChampionSlotChest_6 = 35, // @ C35_SLOT_CHEST_6
-	k36_ChampionSlotChest_7 = 36, // @ C36_SLOT_CHEST_7
-	k37_ChampionSlotChest_8 = 37 // @ C37_SLOT_CHEST_8
+	kDMSlotLeaderHand = -1, // @ CM1_SLOT_LEADER_HAND
+	kDMSlotReadyHand = 0, // @ C00_SLOT_READY_HAND
+	kDMSlotActionHand = 1, // @ C01_SLOT_ACTION_HAND
+	kDMSlotHead = 2, // @ C02_SLOT_HEAD
+	kDMSlotTorso = 3, // @ C03_SLOT_TORSO
+	kDMSlotLegs = 4, // @ C04_SLOT_LEGS
+	kDMSlotFeet = 5, // @ C05_SLOT_FEET
+	kDMSlotPouch_2 = 6, // @ C06_SLOT_POUCH_2
+	kDMSlotQuiverLine2_1 = 7, // @ C07_SLOT_QUIVER_LINE2_1
+	kDMSlotQuiverLine1_2 = 8, // @ C08_SLOT_QUIVER_LINE1_2
+	kDMSlotQuiverLine2_2 = 9, // @ C09_SLOT_QUIVER_LINE2_2
+	kDMSlotNeck = 10, // @ C10_SLOT_NECK
+	kDMSlotPouch1 = 11, // @ C11_SLOT_POUCH_1
+	kDMSlotQuiverLine1_1 = 12, // @ C12_SLOT_QUIVER_LINE1_1
+	kDMSlotBackpackLine1_1 = 13, // @ C13_SLOT_BACKPACK_LINE1_1
+	kDMSlotBackpackLine2_2 = 14, // @ C14_SLOT_BACKPACK_LINE2_2
+	kDMSlotBackpackLine2_3 = 15, // @ C15_SLOT_BACKPACK_LINE2_3
+	kDMSlotBackpackLine2_4 = 16, // @ C16_SLOT_BACKPACK_LINE2_4
+	kDMSlotBackpackLine2_5 = 17, // @ C17_SLOT_BACKPACK_LINE2_5
+	kDMSlotBackpackLine2_6 = 18, // @ C18_SLOT_BACKPACK_LINE2_6
+	kDMSlotBackpackLine2_7 = 19, // @ C19_SLOT_BACKPACK_LINE2_7
+	kDMSlotBackpackLine2_8 = 20, // @ C20_SLOT_BACKPACK_LINE2_8
+	kDMSlotBackpackLine2_9 = 21, // @ C21_SLOT_BACKPACK_LINE2_9
+	kDMSlotBackpackLine1_2 = 22, // @ C22_SLOT_BACKPACK_LINE1_2
+	kDMSlotBackpackLine1_3 = 23, // @ C23_SLOT_BACKPACK_LINE1_3
+	kDMSlotBackpackLine1_4 = 24, // @ C24_SLOT_BACKPACK_LINE1_4
+	kDMSlotBackpackLine1_5 = 25, // @ C25_SLOT_BACKPACK_LINE1_5
+	kDMSlotBackpackLine1_6 = 26, // @ C26_SLOT_BACKPACK_LINE1_6
+	kDMSlotBackpackLine1_7 = 27, // @ C27_SLOT_BACKPACK_LINE1_7
+	kDMSlotBackpackLine1_8 = 28, // @ C28_SLOT_BACKPACK_LINE1_8
+	kDMSlotBackpackLine1_9 = 29, // @ C29_SLOT_BACKPACK_LINE1_9
+	kDMSlotChest1 = 30, // @ C30_SLOT_CHEST_1
+	kDMSlotChest2 = 31, // @ C31_SLOT_CHEST_2
+	kDMSlotChest3 = 32, // @ C32_SLOT_CHEST_3
+	kDMSlotChest4 = 33, // @ C33_SLOT_CHEST_4
+	kDMSlotChest5 = 34, // @ C34_SLOT_CHEST_5
+	kDMSlotChest6 = 35, // @ C35_SLOT_CHEST_6
+	kDMSlotChest7 = 36, // @ C36_SLOT_CHEST_7
+	kDMSlotChest8 = 37 // @ C37_SLOT_CHEST_8
 };
 
 enum ChampionAction {
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index cb33642..97fd534 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1257,7 +1257,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane
 	int16 mapX = dunMan._partyMapX + _vm->_dirIntoStepCountEast[dunMan._partyDir];
 	int16 mapY = dunMan._partyMapY + _vm->_dirIntoStepCountNorth[dunMan._partyDir];
 
-	for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
+	for (uint16 slotIndex = kDMSlotReadyHand; slotIndex < kDMSlotChest1; slotIndex++) {
 		Thing thing = champ->getSlot((ChampionSlot)slotIndex);
 		if (thing != Thing::_none) {
 			_vm->_dungeonMan->unlinkThingFromList(thing, Thing(0), mapX, mapY);
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 89efd6b..4ec74ef 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1535,7 +1535,7 @@ void GroupMan::stealFromChampion(Group *group, uint16 championIndex) {
 	uint16 slotIdx = _vm->getRandomNumber(8);
 	while ((percentage > 0) && !_vm->_championMan->isLucky(champion, percentage)) {
 		uint16 stealFromSlotIndex = G0394_auc_StealFromSlotIndices[slotIdx];
-		if (stealFromSlotIndex == k13_ChampionSlotBackpackLine_1_1)
+		if (stealFromSlotIndex == kDMSlotBackpackLine1_1)
 			stealFromSlotIndex += _vm->getRandomNumber(17); /* Select a random slot in the backpack */
 
 		Thing slotThing = champion->_slots[stealFromSlotIndex];
@@ -1803,7 +1803,7 @@ int16 GroupMan::getMeleeActionDamage(Champion *champ, int16 champIndex, Group *g
 
 	int16 doubledMapDifficulty = _vm->_dungeonMan->_currMap->_difficulty << 1;
 	CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type];
-	int16 actionHandObjectIconIndex = _vm->_objectMan->getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
+	int16 actionHandObjectIconIndex = _vm->_objectMan->getIconIndex(champ->_slots[kDMSlotActionHand]);
 	bool actionHitsNonMaterialCreatures = getFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
 	if (actionHitsNonMaterialCreatures)
 		clearFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
@@ -1813,7 +1813,7 @@ int16 GroupMan::getMeleeActionDamage(Champion *champ, int16 champIndex, Group *g
 		(!_vm->getRandomNumber(4)) ||
 		 (_vm->_championMan->isLucky(champ, 75 - actionHitProbability)))) {
 
-		L0565_i_Damage = _vm->_championMan->getStrength(champIndex, k1_ChampionSlotActionHand);
+		L0565_i_Damage = _vm->_championMan->getStrength(champIndex, kDMSlotActionHand);
 		if (!(L0565_i_Damage))
 			goto T0231009;
 
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 07c7a5b..7355708 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -149,7 +149,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
 
 	_vm->_textMan->printToViewport(5, 132, k13_ColorLightestGray, "MANA");
 
-	for (uint16 i = k0_ChampionSlotReadyHand; i < k30_ChampionSlotChest_1; i++)
+	for (uint16 i = kDMSlotReadyHand; i < kDMSlotChest1; i++)
 		_vm->_championMan->drawSlot(championIndex, i);
 
 	setFlag(champion->_attributes, kDMAttributeViewport | kDMAttributeStatusBox | kDMAttributePanel | kDMAttributeLoad | kDMAttributeStatistics | kDMAttributeNameTitle);
@@ -246,7 +246,7 @@ void InventoryMan::drawPanel() {
 		return;
 	}
 
-	Thing thing = cm._champions[_vm->ordinalToIndex(_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand);
+	Thing thing = cm._champions[_vm->ordinalToIndex(_inventoryChampionOrdinal)].getSlot(kDMSlotActionHand);
 
 	_panelContent = k0_PanelContentFoodWaterPoisoned;
 	switch (thing.getType()) {
@@ -688,7 +688,7 @@ void InventoryMan::setDungeonViewPalette() {
 		int16 torchesLightPower[8];
 		int16 *curTorchLightPower = torchesLightPower;
 		while (counter--) {
-			uint16 slotIndex = k1_ChampionSlotActionHand + 1;
+			uint16 slotIndex = kDMSlotActionHand + 1;
 			while (slotIndex--) {
 				Thing slotThing = curChampion->_slots[slotIndex];
 				if ((_vm->_objectMan->getObjectType(slotThing) >= kDMIconIndiceWeaponTorchUnlit) &&
@@ -756,7 +756,7 @@ void InventoryMan::decreaseTorchesLightPower() {
 
 	Champion *curChampion = _vm->_championMan->_champions;
 	while (championCount--) {
-		int16 slotIndex = k1_ChampionSlotActionHand + 1;
+		int16 slotIndex = kDMSlotActionHand + 1;
 		while (slotIndex--) {
 			int16 iconIndex = _vm->_objectMan->getIconIndex(curChampion->_slots[slotIndex]);
 			if ((iconIndex >= kDMIconIndiceWeaponTorchUnlit) && (iconIndex <= kDMIconIndiceWeaponTorchLit)) {
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 4ad8646..5da7321 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -201,7 +201,7 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) {
 		return;
 	}
 	byte *bitmapIcon = dm._tmpBitmap;
-	Thing thing = champion.getSlot(k1_ChampionSlotActionHand);
+	Thing thing = champion.getSlot(kDMSlotActionHand);
 	IconIndice iconIndex;
 	if (thing == Thing::_none) {
 		iconIndex = kDMIconIndiceActionEmptyHand;
@@ -657,14 +657,14 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 			Junk *junkData = (Junk *)_vm->_dungeonMan->getThingData(unusedObject);
 			junkData->setType(k51_JunkTypeZokathra);
 			ChampionSlot slotIndex;
-			if (curChampion->_slots[k0_ChampionSlotReadyHand] == Thing::_none)
-				slotIndex = k0_ChampionSlotReadyHand;
-			else if (curChampion->_slots[k1_ChampionSlotActionHand] == Thing::_none)
-				slotIndex = k1_ChampionSlotActionHand;
+			if (curChampion->_slots[kDMSlotReadyHand] == Thing::_none)
+				slotIndex = kDMSlotReadyHand;
+			else if (curChampion->_slots[kDMSlotActionHand] == Thing::_none)
+				slotIndex = kDMSlotActionHand;
 			else
-				slotIndex = kM1_ChampionSlotLeaderHand;
+				slotIndex = kDMSlotLeaderHand;
 
-			if ((slotIndex == k0_ChampionSlotReadyHand) || (slotIndex == k1_ChampionSlotActionHand)) {
+			if ((slotIndex == kDMSlotReadyHand) || (slotIndex == kDMSlotActionHand)) {
 				_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, unusedObject, slotIndex);
 				_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 			} else
@@ -785,7 +785,7 @@ void MenuMan::menusPrintSpellFailureMessage(Champion *champ, uint16 failureType,
 }
 
 Potion *MenuMan::getEmptyFlaskInHand(Champion *champ, Thing *potionThing) {
-	for (int16 slotIndex = k2_ChampionSlotHead; --slotIndex >= k0_ChampionSlotReadyHand; ) {
+	for (int16 slotIndex = kDMSlotHead; --slotIndex >= kDMSlotReadyHand; ) {
 		Thing curThing = champ->_slots[slotIndex];
 		if ((curThing != Thing::_none) && (_vm->_objectMan->getIconIndex(curThing) == kDMIconIndicePotionEmptyFlask)) {
 			*potionThing = curThing;
@@ -1041,7 +1041,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 	if (!curChampion->_currHealth)
 		return false;
 
-	Weapon *weaponInHand = (Weapon *)_vm->_dungeonMan->getThingData(curChampion->_slots[k1_ChampionSlotActionHand]);
+	Weapon *weaponInHand = (Weapon *)_vm->_dungeonMan->getThingData(curChampion->_slots[kDMSlotActionHand]);
 
 	int16 nextMapX = _vm->_dungeonMan->_partyMapX;
 	int16 nextMapY = _vm->_dungeonMan->_partyMapY;
@@ -1092,7 +1092,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		if ((Square(targetSquare).getType() == k4_DoorElemType) && (Square(targetSquare).getDoorState() == k4_doorState_CLOSED)) {
 			_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 			actionDisabledTicks = 6;
-			_vm->_groupMan->groupIsDoorDestoryedByAttack(nextMapX, nextMapY, _vm->_championMan->getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
+			_vm->_groupMan->groupIsDoorDestoryedByAttack(nextMapX, nextMapY, _vm->_championMan->getStrength(champIndex, kDMSlotActionHand), false, 2);
 			_vm->_sound->requestPlay(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k2_soundModePlayOneTickLater);
 			break;
 		}
@@ -1127,7 +1127,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		actionPerformed = isGroupFrightenedByAction(champIndex, actionIndex, nextMapX, nextMapY);
 		break;
 	case k32_ChampionActionShoot: {
-		if (Thing(curChampion->_slots[k0_ChampionSlotReadyHand]).getType() != k5_WeaponThingType) {
+		if (Thing(curChampion->_slots[kDMSlotReadyHand]).getType() != k5_WeaponThingType) {
 			_actionDamage = kM2_damageNoAmmunition;
 			actionExperienceGain = 0;
 			actionPerformed = false;
@@ -1135,7 +1135,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		}
 
 		WeaponInfo *weaponInfoActionHand = &_vm->_dungeonMan->_weaponInfos[weaponInHand->getType()];
-		WeaponInfo *weaponInfoReadyHand = _vm->_dungeonMan->getWeaponInfo(curChampion->_slots[k0_ChampionSlotReadyHand]);
+		WeaponInfo *weaponInfoReadyHand = _vm->_dungeonMan->getWeaponInfo(curChampion->_slots[kDMSlotReadyHand]);
 		int16 actionHandWeaponClass = weaponInfoActionHand->_class;
 		int16 readyHandWeaponClass = weaponInfoReadyHand->_class;
 		int16 stepEnergy = actionHandWeaponClass;
@@ -1158,7 +1158,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		}
 
 		setChampionDirectionToPartyDirection(curChampion);
-		Thing removedObject = _vm->_championMan->getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
+		Thing removedObject = _vm->_championMan->getObjectRemovedFromSlot(champIndex, kDMSlotReadyHand);
 		_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 		_vm->_championMan->championShootProjectile(curChampion, removedObject, weaponInfoActionHand->_kineticEnergy + weaponInfoReadyHand->_kineticEnergy, (weaponInfoActionHand->getShootAttack() + _vm->_championMan->getSkillLevel(champIndex, kDMSkillShoot)) << 1, stepEnergy);
 		}
@@ -1286,11 +1286,11 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		int16 freezeTicks;
 		if (weaponInHand->getType() == k42_JunkTypeMagicalBoxBlue) {
 			freezeTicks = 30;
-			_vm->_championMan->getObjectRemovedFromSlot(champIndex, k1_ChampionSlotActionHand);
+			_vm->_championMan->getObjectRemovedFromSlot(champIndex, kDMSlotActionHand);
 			weaponInHand->setNextThing(Thing::_none);
 		} else if (weaponInHand->getType() == k43_JunkTypeMagicalBoxGreen) {
 			freezeTicks = 125;
-			_vm->_championMan->getObjectRemovedFromSlot(champIndex, k1_ChampionSlotActionHand);
+			_vm->_championMan->getObjectRemovedFromSlot(champIndex, kDMSlotActionHand);
 			weaponInHand->setNextThing(Thing::_none);
 		} else {
 			freezeTicks = 70;
@@ -1306,9 +1306,9 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		break;
 	case k42_ChampionActionThrow:
 		setChampionDirectionToPartyDirection(curChampion);
-		actionPerformed = _vm->_championMan->isObjectThrown(champIndex, k1_ChampionSlotActionHand, (curChampion->_cell == returnNextVal(_vm->_dungeonMan->_partyDir)) || (curChampion->_cell == (ViewCell)returnOppositeDir(_vm->_dungeonMan->_partyDir)));
+		actionPerformed = _vm->_championMan->isObjectThrown(champIndex, kDMSlotActionHand, (curChampion->_cell == returnNextVal(_vm->_dungeonMan->_partyDir)) || (curChampion->_cell == (ViewCell)returnOppositeDir(_vm->_dungeonMan->_partyDir)));
 		if (actionPerformed)
-			_vm->_timeline->_events[curChampion->_enableActionEventIndex]._B._slotOrdinal = _vm->indexToOrdinal(k1_ChampionSlotActionHand);
+			_vm->_timeline->_events[curChampion->_enableActionEventIndex]._B._slotOrdinal = _vm->indexToOrdinal(kDMSlotActionHand);
 		break;
 	}
 
@@ -1345,7 +1345,7 @@ void MenuMan::setChampionDirectionToPartyDirection(Champion *champ) {
 }
 
 void MenuMan::decrementCharges(Champion *champ) {
-	Thing slotActionThing = champ->_slots[k1_ChampionSlotActionHand];
+	Thing slotActionThing = champ->_slots[kDMSlotActionHand];
 	Junk *slotActionData = (Junk *)_vm->_dungeonMan->getThingData(slotActionThing);
 	switch (slotActionThing.getType()) {
 	case k5_WeaponThingType:
@@ -1488,7 +1488,7 @@ bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 ac
 
 		uint16 actionHitProbability = actionHitProbabilityArray[actionIndex];
 		uint16 actionDamageFactor = actionDamageFactorArray[actionIndex];
-		if ((_vm->_objectMan->getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == kDMIconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
+		if ((_vm->_objectMan->getIconIndex(champ->_slots[kDMSlotActionHand]) == kDMIconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
 			setFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
 		}
 		_actionDamage = _vm->_groupMan->getMeleeActionDamage(champ, champIndex, (Group *)_vm->_dungeonMan->getThingData(_actionTargetGroupThing), _vm->ordinalToIndex(targetCreatureOrdinal), targetMapX, targetMapY, actionHitProbability, actionDamageFactor, skillIndex);
@@ -1631,7 +1631,7 @@ void MenuMan::processCommands116To119_setActingChampion(uint16 champIndex) {
 		return;
 
 	uint16 actionSetIndex;
-	Thing slotActionThing = curChampion->_slots[k1_ChampionSlotActionHand];
+	Thing slotActionThing = curChampion->_slots[kDMSlotActionHand];
 
 	if (slotActionThing == Thing::_none)
 		actionSetIndex = 2; /* Actions Punch, Kick and War Cry */
@@ -1679,7 +1679,7 @@ void MenuMan::setActionList(ActionSet *actionSet) {
 }
 
 int16 MenuMan::getActionObjectChargeCount() {
-	Thing slotActionThing = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand];
+	Thing slotActionThing = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._slots[kDMSlotActionHand];
 	Junk *junkData = (Junk *)_vm->_dungeonMan->getThingData(slotActionThing);
 	switch (slotActionThing.getType()) {
 	case k5_WeaponThingType:
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 2475ebc..8787e50 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -866,8 +866,8 @@ bool MovesensMan::isObjectInPartyPossession(int16 objectType) {
 	for (championIdx = kDMChampionFirst; championIdx < _vm->_championMan->_partyChampionCount; championIdx++, curChampion++) {
 		if (curChampion->_currHealth) {
 			curSlotThing = curChampion->_slots;
-			for (slotIdx = k0_ChampionSlotReadyHand; (slotIdx < k30_ChampionSlotChest_1) || !leaderHandObjectProcessed; slotIdx++) {
-				if (slotIdx < k30_ChampionSlotChest_1)
+			for (slotIdx = kDMSlotReadyHand; (slotIdx < kDMSlotChest1) || !leaderHandObjectProcessed; slotIdx++) {
+				if (slotIdx < kDMSlotChest1)
 					curThing = *curSlotThing++;
 				else {
 					leaderHandObjectProcessed = true;
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index f92a09f..0bbe400 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -820,15 +820,15 @@ void Timeline::processEventEnableChampionAction(uint16 champIndex) {
 		curChampion->_actionDefense -= _actionDefense[curChampion->_actionDefense];
 	}
 	if (curChampion->_currHealth) {
-		if ((curChampion->_actionIndex == k32_ChampionActionShoot) && (curChampion->_slots[k0_ChampionSlotReadyHand] == Thing::_none)) {
-			int16 slotIndex = k12_ChampionSlotQuiverLine_1_1;
-			if (_vm->_championMan->isAmmunitionCompatibleWithWeapon(champIndex, k1_ChampionSlotActionHand, slotIndex))
-				_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->getObjectRemovedFromSlot(champIndex, slotIndex), k0_ChampionSlotReadyHand);
+		if ((curChampion->_actionIndex == k32_ChampionActionShoot) && (curChampion->_slots[kDMSlotReadyHand] == Thing::_none)) {
+			int16 slotIndex = kDMSlotQuiverLine1_1;
+			if (_vm->_championMan->isAmmunitionCompatibleWithWeapon(champIndex, kDMSlotActionHand, slotIndex))
+				_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->getObjectRemovedFromSlot(champIndex, slotIndex), kDMSlotReadyHand);
 			else {
 				for (int16 quiverSlotIndex = 0; quiverSlotIndex < 3; quiverSlotIndex++) {
-					slotIndex = quiverSlotIndex + k7_ChampionSlotQuiverLine_2_1;
-					if (_vm->_championMan->isAmmunitionCompatibleWithWeapon(champIndex, k1_ChampionSlotActionHand, slotIndex))
-						_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->getObjectRemovedFromSlot(champIndex, slotIndex), k0_ChampionSlotReadyHand);
+					slotIndex = quiverSlotIndex + kDMSlotQuiverLine2_1;
+					if (_vm->_championMan->isAmmunitionCompatibleWithWeapon(champIndex, kDMSlotActionHand, slotIndex))
+						_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->getObjectRemovedFromSlot(champIndex, slotIndex), kDMSlotReadyHand);
 				}
 			}
 		}
@@ -843,10 +843,10 @@ void Timeline::processEventMoveWeaponFromQuiverToSlot(uint16 champIndex, uint16
 	if (curChampion->_slots[slotIndex] != Thing::_none)
 		return;
 
-	if (hasWeaponMovedSlot(champIndex, curChampion, k12_ChampionSlotQuiverLine_1_1, slotIndex))
+	if (hasWeaponMovedSlot(champIndex, curChampion, kDMSlotQuiverLine1_1, slotIndex))
 		return;
 
-	for (uint16 srcSlotIndex = k7_ChampionSlotQuiverLine_2_1; srcSlotIndex <= k9_ChampionSlotQuiverLine_2_2; srcSlotIndex++) {
+	for (uint16 srcSlotIndex = kDMSlotQuiverLine2_1; srcSlotIndex <= kDMSlotQuiverLine2_2; srcSlotIndex++) {
 		if (hasWeaponMovedSlot(champIndex, curChampion, srcSlotIndex, slotIndex))
 			break;
 	}


Commit: d2b0829476e6e045a1d322b94bde64b0fcb87234
    https://github.com/scummvm/scummvm/commit/d2b0829476e6e045a1d322b94bde64b0fcb87234
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-10T14:31:49+02:00

Commit Message:
DM: Change constants into enums in champion.h, renaming

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/eventman.cpp
    engines/dm/menus.cpp
    engines/dm/movesens.cpp
    engines/dm/projexpl.cpp
    engines/dm/timeline.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 4f02db1..ea48f85 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -52,7 +52,7 @@ void Champion::resetToZero() {
 	memset(_title, '\0', 20);
 	_dir = kDirNorth;
 	_cell = k0_ViewCellFronLeft;
-	_actionIndex = k0_ChampionActionN;
+	_actionIndex = kDMActionN;
 	_symbolStep = 0;
 	memset(_symbols, '\0', 5);
 	_directionMaximumDamageReceived = _maximumDamageReceived = _poisonEventCount = _enableActionEventIndex = 0;
@@ -742,7 +742,7 @@ void ChampionMan::decrementStamina(int16 championIndex, int16 decrement) {
 	int16 stamina = curChampion->_currStamina;
 	if (stamina <= 0) {
 		curChampion->_currStamina = 0;
-		addPendingDamageAndWounds_getDamage(championIndex, (-stamina) >> 1, kDMWoundNone, k0_attackType_NORMAL);
+		addPendingDamageAndWounds_getDamage(championIndex, (-stamina) >> 1, kDMWoundNone, kDMAttackTypeNormal);
 	} else if (stamina > curChampion->_maxStamina) {
 		curChampion->_currStamina = curChampion->_maxStamina;
 	}
@@ -758,13 +758,13 @@ int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 a
 	if (!curChampion->_currHealth)
 		return 0;
 
-	if (attackType != k0_attackType_NORMAL) {
+	if (attackType != kDMAttackTypeNormal) {
 		uint16 defense = 0;
 		uint16 woundCount = 0;
 		for (int16 woundIndex = kDMSlotReadyHand; woundIndex <= kDMSlotFeet; woundIndex++) {
 			if (allowedWounds & (1 << woundIndex)) {
 				woundCount++;
-				defense += getWoundDefense(champIndex, woundIndex | ((attackType == k4_attackType_SHARP) ? k0x8000_maskUseSharpDefense : k0x0000_maskDoNotUseSharpDefense));
+				defense += getWoundDefense(champIndex, woundIndex | ((attackType == kDMAttackTypeSharp) ? k0x8000_maskUseSharpDefense : k0x0000_maskDoNotUseSharpDefense));
 			}
 		}
 		if (woundCount)
@@ -772,7 +772,7 @@ int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 a
 
 		bool skipScaling = false;
 		switch (attackType) {
-		case k6_attackType_PSYCHIC:
+		case kDMAttackTypePsychic:
 		{
 			int16 wisdomFactor = 115 - curChampion->_statistics[kDMStatWisdom][kDMStatCurrent];
 			if (wisdomFactor <= 0) {
@@ -784,16 +784,16 @@ int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 a
 			skipScaling = true;
 		}
 		break;
-		case k5_attackType_MAGIC:
+		case kDMAttackTypeMagic:
 			attack = getStatisticAdjustedAttack(curChampion, kDMStatAntimagic, attack);
 			attack -= _party._spellShieldDefense;
 			skipScaling = true;
 			break;
-		case k1_attackType_FIRE:
+		case kDMAttackTypeFire:
 			attack = getStatisticAdjustedAttack(curChampion, kDMStatAntifire, attack);
 			attack -= _party._fireShieldDefense;
 			break;
-		case k2_attackType_SELF:
+		case kDMAttackTypeSelf:
 			defense >>= 1;
 			break;
 		default:
@@ -1106,7 +1106,7 @@ void ChampionMan::championPoison(int16 champIndex, uint16 attack) {
 		return;
 
 	Champion *curChampion = &_champions[champIndex];
-	addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), kDMWoundNone, k0_attackType_NORMAL);
+	addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), kDMWoundNone, kDMAttackTypeNormal);
 	setFlag(curChampion->_attributes, kDMAttributeStatistics);
 	if ((_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) && (_vm->_inventoryMan->_panelContent == k0_PanelContentFoodWaterPoisoned)) {
 		setFlag(curChampion->_attributes, kDMAttributePanel);
@@ -1876,7 +1876,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
 	// Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portraits could be missing in the data)
 	_vm->_displayMan->_useByteBoxCoordinates = true;
 	_vm->_displayMan->blitToBitmap(_vm->_displayMan->getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, _boxChampionPortrait, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency, 87, 29);
-	championPtr->_actionIndex = k255_ChampionActionNone;
+	championPtr->_actionIndex = kDMActionNone;
 	championPtr->_enableActionEventIndex = -1;
 	championPtr->_hideDamageReceivedIndex = -1;
 	championPtr->_dir = _vm->_dungeonMan->_partyDir;
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index bc2ee7c..013f118 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -290,77 +290,80 @@ enum ChampionSlot {
 };
 
 enum ChampionAction {
-	k0_ChampionActionN = 0, // @ C000_ACTION_N
-	k1_ChampionActionBlock = 1, // @ C001_ACTION_BLOCK
-	k2_ChampionActionChop = 2, // @ C002_ACTION_CHOP
-	k3_ChampionActionX_C003 = 3, // @ C003_ACTION_X
-	k4_ChampionActionBlowHorn = 4, // @ C004_ACTION_BLOW_HORN
-	k5_ChampionActionFlip = 5, // @ C005_ACTION_FLIP
-	k6_ChampionActionPunch = 6, // @ C006_ACTION_PUNCH
-	k7_ChampionActionKick = 7, // @ C007_ACTION_KICK
-	k8_ChampionActionWarCry = 8, // @ C008_ACTION_WAR_CRY
-	k9_ChampionActionStab_C009 = 9, // @ C009_ACTION_STAB
-	k10_ChampionActionClimbDown = 10, // @ C010_ACTION_CLIMB_DOWN
-	k11_ChampionActionFreezeLife = 11, // @ C011_ACTION_FREEZE_LIFE
-	k12_ChampionActionHit = 12, // @ C012_ACTION_HIT
-	k13_ChampionActionSwing = 13, // @ C013_ACTION_SWING
-	k14_ChampionActionStab_C014 = 14, // @ C014_ACTION_STAB
-	k15_ChampionActionThrust = 15, // @ C015_ACTION_THRUST
-	k16_ChampionActionJab = 16, // @ C016_ACTION_JAB
-	k17_ChampionActionParry = 17, // @ C017_ACTION_PARRY
-	k18_ChampionActionHack = 18, // @ C018_ACTION_HACK
-	k19_ChampionActionBerzerk = 19, // @ C019_ACTION_BERZERK
-	k20_ChampionActionFireball = 20, // @ C020_ACTION_FIREBALL
-	k21_ChampionActionDispel = 21, // @ C021_ACTION_DISPELL
-	k22_ChampionActionConfuse = 22, // @ C022_ACTION_CONFUSE
-	k23_ChampionActionLightning = 23, // @ C023_ACTION_LIGHTNING
-	k24_ChampionActionDisrupt = 24, // @ C024_ACTION_DISRUPT
-	k25_ChampionActionMelee = 25, // @ C025_ACTION_MELEE
-	k26_ChampionActionX_C026 = 26, // @ C026_ACTION_X
-	k27_ChampionActionInvoke = 27, // @ C027_ACTION_INVOKE
-	k28_ChampionActionSlash = 28, // @ C028_ACTION_SLASH
-	k29_ChampionActionCleave = 29, // @ C029_ACTION_CLEAVE
-	k30_ChampionActionBash = 30, // @ C030_ACTION_BASH
-	k31_ChampionActionStun = 31, // @ C031_ACTION_STUN
-	k32_ChampionActionShoot = 32, // @ C032_ACTION_SHOOT
-	k33_ChampionActionSpellshield = 33, // @ C033_ACTION_SPELLSHIELD
-	k34_ChampionActionFireshield = 34, // @ C034_ACTION_FIRESHIELD
-	k35_ChampionActionFluxcage = 35, // @ C035_ACTION_FLUXCAGE
-	k36_ChampionActionHeal = 36, // @ C036_ACTION_HEAL
-	k37_ChampionActionCalm = 37, // @ C037_ACTION_CALM
-	k38_ChampionActionLight = 38, // @ C038_ACTION_LIGHT
-	k39_ChampionActionWindow = 39, // @ C039_ACTION_WINDOW
-	k40_ChampionActionSpit = 40, // @ C040_ACTION_SPIT
-	k41_ChampionActionBrandish = 41, // @ C041_ACTION_BRANDISH
-	k42_ChampionActionThrow = 42, // @ C042_ACTION_THROW
-	k43_ChampionActionFuse = 43, // @ C043_ACTION_FUSE
-	k255_ChampionActionNone = 255 // @ C255_ACTION_NONE
+	kDMActionN = 0, // @ C000_ACTION_N
+	kDMActionBlock = 1, // @ C001_ACTION_BLOCK
+	kDMActionChop = 2, // @ C002_ACTION_CHOP
+	kDMActionX = 3, // @ C003_ACTION_X
+	kDMActionBlowHorn = 4, // @ C004_ACTION_BLOW_HORN
+	kDMActionFlip = 5, // @ C005_ACTION_FLIP
+	kDMActionPunch = 6, // @ C006_ACTION_PUNCH
+	kDMActionKick = 7, // @ C007_ACTION_KICK
+	kDMActionWarCry = 8, // @ C008_ACTION_WAR_CRY
+	kDMActionStab9 = 9, // @ C009_ACTION_STAB
+	kDMActionClimbDown = 10, // @ C010_ACTION_CLIMB_DOWN
+	kDMActionFreezeLife = 11, // @ C011_ACTION_FREEZE_LIFE
+	kDMActionHit = 12, // @ C012_ACTION_HIT
+	kDMActionSwing = 13, // @ C013_ACTION_SWING
+	kDMActionStab14 = 14, // @ C014_ACTION_STAB
+	kDMActionThrust = 15, // @ C015_ACTION_THRUST
+	kDMActionJab = 16, // @ C016_ACTION_JAB
+	kDMActionParry = 17, // @ C017_ACTION_PARRY
+	kDMActionHack = 18, // @ C018_ACTION_HACK
+	kDMActionBerzerk = 19, // @ C019_ACTION_BERZERK
+	kDMActionFireball = 20, // @ C020_ACTION_FIREBALL
+	kDMActionDispel = 21, // @ C021_ACTION_DISPELL
+	kDMActionConfuse = 22, // @ C022_ACTION_CONFUSE
+	kDMActionLightning = 23, // @ C023_ACTION_LIGHTNING
+	kDMActionDisrupt = 24, // @ C024_ACTION_DISRUPT
+	kDMActionMelee = 25, // @ C025_ACTION_MELEE
+	kDMActionX_C026 = 26, // @ C026_ACTION_X
+	kDMActionInvoke = 27, // @ C027_ACTION_INVOKE
+	kDMActionSlash = 28, // @ C028_ACTION_SLASH
+	kDMActionCleave = 29, // @ C029_ACTION_CLEAVE
+	kDMActionBash = 30, // @ C030_ACTION_BASH
+	kDMActionStun = 31, // @ C031_ACTION_STUN
+	kDMActionShoot = 32, // @ C032_ACTION_SHOOT
+	kDMActionSpellshield = 33, // @ C033_ACTION_SPELLSHIELD
+	kDMActionFireshield = 34, // @ C034_ACTION_FIRESHIELD
+	kDMActionFluxcage = 35, // @ C035_ACTION_FLUXCAGE
+	kDMActionHeal = 36, // @ C036_ACTION_HEAL
+	kDMActionCalm = 37, // @ C037_ACTION_CALM
+	kDMActionLight = 38, // @ C038_ACTION_LIGHT
+	kDMActionWindow = 39, // @ C039_ACTION_WINDOW
+	kDMActionSpit = 40, // @ C040_ACTION_SPIT
+	kDMActionBrandish = 41, // @ C041_ACTION_BRANDISH
+	kDMActionThrow = 42, // @ C042_ACTION_THROW
+	kDMActionFuse = 43, // @ C043_ACTION_FUSE
+	kDMActionNone = 255 // @ C255_ACTION_NONE
 };
 
 enum AttackType {
-	k0_attackType_NORMAL = 0, // @ C0_ATTACK_NORMAL
-	k1_attackType_FIRE = 1, // @ C1_ATTACK_FIRE
-	k2_attackType_SELF = 2, // @ C2_ATTACK_SELF
-	k3_attackType_BLUNT = 3, // @ C3_ATTACK_BLUNT
-	k4_attackType_SHARP = 4, // @ C4_ATTACK_SHARP
-	k5_attackType_MAGIC = 5, // @ C5_ATTACK_MAGIC
-	k6_attackType_PSYCHIC = 6, // @ C6_ATTACK_PSYCHIC
-	k7_attackType_LIGHTNING = 7 // @ C7_ATTACK_LIGHTNING
+	kDMAttackTypeNormal = 0, // @ C0_ATTACK_NORMAL
+	kDMAttackTypeFire = 1, // @ C1_ATTACK_FIRE
+	kDMAttackTypeSelf = 2, // @ C2_ATTACK_SELF
+	kDMAttackTypeBlunt = 3, // @ C3_ATTACK_BLUNT
+	kDMAttackTypeSharp = 4, // @ C4_ATTACK_SHARP
+	kDMAttackTypeMagic = 5, // @ C5_ATTACK_MAGIC
+	kDMAttackTypePsychic = 6, // @ C6_ATTACK_PSYCHIC
+	kDMAttackTypeLightning = 7 // @ C7_ATTACK_LIGHTNING
 };
 
 #define k0x0000_maskDoNotUseSharpDefense 0x0000 // @ MASK0x0000_DO_NOT_USE_SHARP_DEFENSE 
 #define k0x8000_maskUseSharpDefense 0x8000 // @ MASK0x8000_USE_SHARP_DEFENSE        
-
 #define k0x8000_mergeCycles 0x8000 // @ MASK0x8000_MERGE_CYCLES
 
-#define k0_spellCastFailure 0 // @ C0_SPELL_CAST_FAILURE             
-#define k1_spellCastSuccess 1 // @ C1_SPELL_CAST_SUCCESS             
-#define k3_spellCastFailureNeedsFlask 3 // @ C3_SPELL_CAST_FAILURE_NEEDS_FLASK 
+enum SpellCastResult {
+	kDMSpellCastFailure = 0, // @ C0_SPELL_CAST_FAILURE             
+	kDMSpellCastSuccess = 1, // @ C1_SPELL_CAST_SUCCESS             
+	kDMSpellCastFailureNeedsFlask = 3 // @ C3_SPELL_CAST_FAILURE_NEEDS_FLASK 
+};
 
-#define k0_failureNeedsMorePractice 0 // @ C00_FAILURE_NEEDS_MORE_PRACTICE      
-#define k1_failureMeaninglessSpell 1 // @ C01_FAILURE_MEANINGLESS_SPELL        
-#define k10_failureNeedsFlaskInHand 10 // @ C10_FAILURE_NEEDS_FLASK_IN_HAND     
-#define k11_failureNeedsMagicMapInHand 11 // @ C11_FAILURE_NEEDS_MAGIC_MAP_IN_HAND 
+enum SpellFailure {
+	kDMFailureNeedsMorePractice = 0, // @ C00_FAILURE_NEEDS_MORE_PRACTICE      
+	kDMFailureMeaninglessSpell = 1, // @ C01_FAILURE_MEANINGLESS_SPELL        
+	kDMFailureNeedsFlaskInHand = 10, // @ C10_FAILURE_NEEDS_FLASK_IN_HAND     
+	kDMFailureNeedsMagicMapInHand = 11 // @ C11_FAILURE_NEEDS_MAGIC_MAP_IN_HAND 
+};
 
 #define k1_spellKindPotion 1 // @ C1_SPELL_KIND_POTION    
 #define k2_spellKindProjectile 2 // @ C2_SPELL_KIND_PROJECTILE
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 97fd534..e7095ce 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1009,9 +1009,9 @@ void EventManager::commandMoveParty(CommandType cmdType) {
 			movementArrowIdx += (_vm->_dungeonMan->_partyDir + 2);
 			int16 L1124_i_FirstDamagedChampionIndex = _vm->_championMan->getTargetChampionIndex(partyMapX, partyMapY, normalizeModulo4(movementArrowIdx));
 			int16 L1125_i_SecondDamagedChampionIndex = _vm->_championMan->getTargetChampionIndex(partyMapX, partyMapY, returnNextVal(movementArrowIdx));
-			int16 damage = _vm->_championMan->addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex, 1, kDMWoundTorso | kDMWoundLegs, k2_attackType_SELF);
+			int16 damage = _vm->_championMan->addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex, 1, kDMWoundTorso | kDMWoundLegs, kDMAttackTypeSelf);
 			if (L1124_i_FirstDamagedChampionIndex != L1125_i_SecondDamagedChampionIndex)
-				damage |= _vm->_championMan->addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, kDMWoundTorso | kDMWoundLegs, k2_attackType_SELF);
+				damage |= _vm->_championMan->addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, kDMWoundTorso | kDMWoundLegs, kDMAttackTypeSelf);
 
 			if (damage)
 				_vm->_sound->requestPlay(k18_soundPARTY_DAMAGED, partyMapX, partyMapY, k0_soundModePlayImmediately);
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 5da7321..3454379 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -311,9 +311,9 @@ void MenuMan::drawActionArea() {
 			drawActionIcon((ChampionIndex)champIndex);
 	} else if (champMan._actingChampionOrdinal) {
 		Box box = _boxActionArea3ActionMenu;
-		if (_actionList._actionIndices[2] == k255_ChampionActionNone)
+		if (_actionList._actionIndices[2] == kDMActionNone)
 			box = _boxActionArea2ActionMenu;
-		if (_actionList._actionIndices[1] == k255_ChampionActionNone)
+		if (_actionList._actionIndices[1] == kDMActionNone)
 			box = _boxActionArea1ActionMenu;
 		dispMan.blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k10_MenuActionAreaIndice),
 								 &box, k48_byteWidth, kM1_ColorNoTransparency, 45);
@@ -342,7 +342,7 @@ const char *MenuMan::getActionName(ChampionAction actionIndex) {
 		"BRANDISH", "THROW", "FUSE"
 	};
 
-	return (actionIndex == k255_ChampionActionNone) ? "" : championActionNames[actionIndex];
+	return (actionIndex == kDMActionNone) ? "" : championActionNames[actionIndex];
 }
 
 void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
@@ -509,12 +509,12 @@ int16 MenuMan::getClickOnSpellCastResult() {
 	_vm->_eventMan->highlightBoxDisable();
 
 	int16 spellCastResult = getChampionSpellCastResult(_vm->_championMan->_magicCasterChampionIndex);
-	if (spellCastResult != k3_spellCastFailureNeedsFlask) {
+	if (spellCastResult != kDMSpellCastFailureNeedsFlask) {
 		casterChampion->_symbols[0] = '\0';
 		drawAvailableSymbols(casterChampion->_symbolStep = 0);
 		drawChampionSymbols(casterChampion);
 	} else
-		spellCastResult = k0_spellCastFailure;
+		spellCastResult = kDMSpellCastFailure;
 
 	_vm->_eventMan->hideMouse();
 	return spellCastResult;
@@ -522,16 +522,16 @@ int16 MenuMan::getClickOnSpellCastResult() {
 
 int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 	if (champIndex >= _vm->_championMan->_partyChampionCount)
-		return k0_spellCastFailure;
+		return kDMSpellCastFailure;
 
 	Champion *curChampion = &_vm->_championMan->_champions[champIndex];
 	if (!curChampion->_currHealth)
-		return k0_spellCastFailure;
+		return kDMSpellCastFailure;
 
 	Spell *curSpell = getSpellFromSymbols((unsigned char *)curChampion->_symbols);
 	if (!curSpell) {
-		menusPrintSpellFailureMessage(curChampion, k1_spellCastSuccess, 0);
-		return k0_spellCastFailure;
+		menusPrintSpellFailureMessage(curChampion, kDMSpellCastSuccess, 0);
+		return kDMSpellCastFailure;
 	}
 	int16 powerSymbolOrdinal = curChampion->_symbols[0] - '_'; /* Values 1 to 6 */
 	uint16 requiredSkillLevel = curSpell->_baseRequiredSkillLevel + powerSymbolOrdinal;
@@ -542,8 +542,8 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 		while (missingSkillLevelCount--) {
 			if (_vm->getRandomNumber(128) > MIN(curChampion->_statistics[kDMStatWisdom][kDMStatCurrent] + 15, 115)) {
 				_vm->_championMan->addSkillExperience(champIndex, curSpell->_skillIndex, experience >> (requiredSkillLevel - skillLevel));
-				menusPrintSpellFailureMessage(curChampion, k0_failureNeedsMorePractice, curSpell->_skillIndex);
-				return k0_spellCastFailure;
+				menusPrintSpellFailureMessage(curChampion, kDMFailureNeedsMorePractice, curSpell->_skillIndex);
+				return kDMSpellCastFailure;
 			}
 		}
 	}
@@ -552,8 +552,8 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 		Thing newObject;
 		Potion *newPotion = getEmptyFlaskInHand(curChampion, &newObject);
 		if (!newPotion) {
-			menusPrintSpellFailureMessage(curChampion, k10_failureNeedsFlaskInHand, 0);
-			return k3_spellCastFailureNeedsFlask;
+			menusPrintSpellFailureMessage(curChampion, kDMFailureNeedsFlaskInHand, 0);
+			return kDMSpellCastFailureNeedsFlask;
 		}
 		uint16 emptyFlaskWeight = _vm->_dungeonMan->getObjectWeight(newObject);
 		newPotion->setType((PotionType)curSpell->getType());
@@ -682,7 +682,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 	}
 	_vm->_championMan->addSkillExperience(champIndex, curSpell->_skillIndex, experience);
 	_vm->_championMan->disableAction(champIndex, curSpell->getDuration());
-	return k1_spellCastSuccess;
+	return kDMSpellCastSuccess;
 }
 
 Spell *MenuMan::getSpellFromSymbols(byte *symbols) {
@@ -765,7 +765,7 @@ void MenuMan::menusPrintSpellFailureMessage(Champion *champ, uint16 failureType,
 
 	const char *message = nullptr;
 	switch (failureType) {
-	case k0_failureNeedsMorePractice:
+	case kDMFailureNeedsMorePractice:
 		_vm->_textMan->printMessage(k4_ColorCyan, messages[0]);
 		_vm->_textMan->printMessage(k4_ColorCyan, _vm->_championMan->_baseSkillName[skillIndex]);
 		if (_vm->getGameLanguage() != Common::FR_FRA || skillIndex == kDMSkillWizard)
@@ -774,12 +774,14 @@ void MenuMan::menusPrintSpellFailureMessage(Champion *champ, uint16 failureType,
 			message = messages[4];
 
 		break;
-	case k1_failureMeaninglessSpell:
+	case kDMFailureMeaninglessSpell:
 		message = messages[2];
 		break;
-	case k10_failureNeedsFlaskInHand:
+	case kDMFailureNeedsFlaskInHand:
 		message = messages[3];
 		break;
+	default:
+		break;
 	}
 	_vm->_textMan->printMessage(k4_ColorCyan, message);
 }
@@ -918,7 +920,7 @@ void MenuMan::deleteChampionSymbol() {
 bool MenuMan::didClickTriggerAction(int16 actionListIndex) {
 	bool retVal = false;
 
-	if (!_vm->_championMan->_actingChampionOrdinal || (actionListIndex != -1 && (_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone)))
+	if (!_vm->_championMan->_actingChampionOrdinal || (actionListIndex != -1 && (_actionList._actionIndices[actionListIndex] == kDMActionNone)))
 		return retVal;
 
 	uint16 championIndex = _vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal);
@@ -1063,32 +1065,32 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 	Thing explosionThing = Thing::_none;
 	bool actionPerformed = true;
 	switch (actionIndex) {
-	case k23_ChampionActionLightning:
+	case kDMActionLightning:
 		kineticEnergy = 180;
 		explosionThing = Thing::_explLightningBolt;
 		setDirectionFl = true;
 		break;
-	case k21_ChampionActionDispel:
+	case kDMActionDispel:
 		kineticEnergy = 150;
 		explosionThing = Thing::_explHarmNonMaterial;
 		setDirectionFl = true;
 		break;
-	case k20_ChampionActionFireball:
+	case kDMActionFireball:
 		kineticEnergy = 150;
 		explosionThing = Thing::_explFireBall;
 		setDirectionFl = true;
 		break;
-	case k40_ChampionActionSpit:
+	case kDMActionSpit:
 		kineticEnergy = 250;
 		explosionThing = Thing::_explFireBall;
 		setDirectionFl = true;
 		break;
-	case k30_ChampionActionBash:
-	case k18_ChampionActionHack:
-	case k19_ChampionActionBerzerk:
-	case k7_ChampionActionKick:
-	case k13_ChampionActionSwing:
-	case k2_ChampionActionChop:
+	case kDMActionBash:
+	case kDMActionHack:
+	case kDMActionBerzerk:
+	case kDMActionKick:
+	case kDMActionSwing:
+	case kDMActionChop:
 		if ((Square(targetSquare).getType() == k4_DoorElemType) && (Square(targetSquare).getDoorState() == k4_doorState_CLOSED)) {
 			_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
 			actionDisabledTicks = 6;
@@ -1096,37 +1098,37 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 			_vm->_sound->requestPlay(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k2_soundModePlayOneTickLater);
 			break;
 		}
-	case k24_ChampionActionDisrupt:
-	case k16_ChampionActionJab:
-	case k17_ChampionActionParry:
-	case k14_ChampionActionStab_C014:
-	case k9_ChampionActionStab_C009:
-	case k31_ChampionActionStun:
-	case k15_ChampionActionThrust:
-	case k25_ChampionActionMelee:
-	case k28_ChampionActionSlash:
-	case k29_ChampionActionCleave:
-	case k6_ChampionActionPunch:
+	case kDMActionDisrupt:
+	case kDMActionJab:
+	case kDMActionParry:
+	case kDMActionStab14:
+	case kDMActionStab9:
+	case kDMActionStun:
+	case kDMActionThrust:
+	case kDMActionMelee:
+	case kDMActionSlash:
+	case kDMActionCleave:
+	case kDMActionPunch:
 		if (!(actionPerformed = isMeleeActionPerformed(champIndex, curChampion, actionIndex, nextMapX, nextMapY, actionSkillIndex))) {
 			actionExperienceGain >>= 1;
 			actionDisabledTicks >>= 1;
 		}
 		break;
-	case k22_ChampionActionConfuse:
+	case kDMActionConfuse:
 		decrementCharges(curChampion);
 		// No break on purpose
-	case k8_ChampionActionWarCry:
-	case k37_ChampionActionCalm:
-	case k41_ChampionActionBrandish:
-	case k4_ChampionActionBlowHorn:
-		if (actionIndex == k8_ChampionActionWarCry)
+	case kDMActionWarCry:
+	case kDMActionCalm:
+	case kDMActionBrandish:
+	case kDMActionBlowHorn:
+		if (actionIndex == kDMActionWarCry)
 			_vm->_sound->requestPlay(k28_soundWAR_CRY, nextMapX, nextMapY, k0_soundModePlayImmediately);
-		else if (actionIndex == k4_ChampionActionBlowHorn)
+		else if (actionIndex == kDMActionBlowHorn)
 			_vm->_sound->requestPlay(k25_soundBLOW_HORN, nextMapX, nextMapY, k0_soundModePlayImmediately);
 
 		actionPerformed = isGroupFrightenedByAction(champIndex, actionIndex, nextMapX, nextMapY);
 		break;
-	case k32_ChampionActionShoot: {
+	case kDMActionShoot: {
 		if (Thing(curChampion->_slots[kDMSlotReadyHand]).getType() != k5_WeaponThingType) {
 			_actionDamage = kM2_damageNoAmmunition;
 			actionExperienceGain = 0;
@@ -1163,7 +1165,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		_vm->_championMan->championShootProjectile(curChampion, removedObject, weaponInfoActionHand->_kineticEnergy + weaponInfoReadyHand->_kineticEnergy, (weaponInfoActionHand->getShootAttack() + _vm->_championMan->getSkillLevel(champIndex, kDMSkillShoot)) << 1, stepEnergy);
 		}
 		break;
-	case k5_ChampionActionFlip: {
+	case kDMActionFlip: {
 		const char *messagesEN[2] = {"IT COMES UP HEADS.", "IT COMES UP TAILS."};
 		const char *messagesDE[2] = {"DIE KOPFSEITE IST OBEN.", "DIE ZAHL IST OBEN."};
 		const char *messagesFR[2] = {"C'EST FACE.", "C'EST PILE."};
@@ -1187,16 +1189,16 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 
 		}
 		break;
-	case k33_ChampionActionSpellshield:
-	case k34_ChampionActionFireshield:
-		if (!isPartySpellOrFireShieldSuccessful(curChampion, actionIndex == k33_ChampionActionSpellshield, 280, true)) {
+	case kDMActionSpellshield:
+	case kDMActionFireshield:
+		if (!isPartySpellOrFireShieldSuccessful(curChampion, actionIndex == kDMActionSpellshield, 280, true)) {
 			actionExperienceGain >>= 2;
 			actionDisabledTicks >>= 1;
 		} else
 			decrementCharges(curChampion);
 
 		break;
-	case k27_ChampionActionInvoke:
+	case kDMActionInvoke:
 		kineticEnergy = _vm->getRandomNumber(128) + 100;
 		switch (_vm->getRandomNumber(6)) {
 		case 0:
@@ -1215,18 +1217,18 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		setDirectionFl = true;
 		break;
 
-	case k35_ChampionActionFluxcage:
+	case kDMActionFluxcage:
 		setChampionDirectionToPartyDirection(curChampion);
 		_vm->_groupMan->fluxCageAction(nextMapX, nextMapY);
 		break;
-	case k43_ChampionActionFuse:
+	case kDMActionFuse:
 		setChampionDirectionToPartyDirection(curChampion);
 		nextMapX = _vm->_dungeonMan->_partyMapX;
 		nextMapY = _vm->_dungeonMan->_partyMapY;
 		nextMapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir], nextMapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
 		_vm->_groupMan->fuseAction(nextMapX, nextMapY);
 		break;
-	case k36_ChampionActionHeal: {
+	case kDMActionHeal: {
 		/* CHANGE2_17_IMPROVEMENT Heal action is much more effective
 		Heal cycles occur as long as the champion has missing health and enough mana. Cycle count = Min(Current Mana / 2, Missing health / Min(10, Heal skill level))
 		Healing amount is Min(Missing health, Min(10, Heal skill level)) * heal cycle count
@@ -1254,7 +1256,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		}
 		}
 		break;
-	case k39_ChampionActionWindow: {
+	case kDMActionWindow: {
 		int16 windowTicks = _vm->getRandomNumber(_vm->_championMan->getSkillLevel(champIndex, actionSkillIndex) + 8) + 5;
 		TimelineEvent newEvent;
 		newEvent._priority = 0;
@@ -1265,7 +1267,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		decrementCharges(curChampion);
 		}
 		break;
-	case k10_ChampionActionClimbDown:
+	case kDMActionClimbDown:
 		nextMapX = _vm->_dungeonMan->_partyMapX;
 		nextMapY = _vm->_dungeonMan->_partyMapY;
 		nextMapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir];
@@ -1282,7 +1284,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 			actionDisabledTicks = 0;
 		}
 		break;
-	case k11_ChampionActionFreezeLife: {
+	case kDMActionFreezeLife: {
 		int16 freezeTicks;
 		if (weaponInHand->getType() == k42_JunkTypeMagicalBoxBlue) {
 			freezeTicks = 30;
@@ -1299,12 +1301,12 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
 		_vm->_championMan->_party._freezeLifeTicks = MIN(200, _vm->_championMan->_party._freezeLifeTicks + freezeTicks);
 		}
 		break;
-	case k38_ChampionActionLight:
+	case kDMActionLight:
 		_vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[2];
 		createEvent70_light(-2, 2500);
 		decrementCharges(curChampion);
 		break;
-	case k42_ChampionActionThrow:
+	case kDMActionThrow:
 		setChampionDirectionToPartyDirection(curChampion);
 		actionPerformed = _vm->_championMan->isObjectThrown(champIndex, kDMSlotActionHand, (curChampion->_cell == returnNextVal(_vm->_dungeonMan->_partyDir)) || (curChampion->_cell == (ViewCell)returnOppositeDir(_vm->_dungeonMan->_partyDir)));
 		if (actionPerformed)
@@ -1483,12 +1485,12 @@ bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 ac
 			break;
 		}
 
-		if ((actionIndex == k24_ChampionActionDisrupt) && !getFlag(_vm->_dungeonMan->getCreatureAttributes(_actionTargetGroupThing), k0x0040_MaskCreatureInfo_nonMaterial))
+		if ((actionIndex == kDMActionDisrupt) && !getFlag(_vm->_dungeonMan->getCreatureAttributes(_actionTargetGroupThing), k0x0040_MaskCreatureInfo_nonMaterial))
 			return false;
 
 		uint16 actionHitProbability = actionHitProbabilityArray[actionIndex];
 		uint16 actionDamageFactor = actionDamageFactorArray[actionIndex];
-		if ((_vm->_objectMan->getIconIndex(champ->_slots[kDMSlotActionHand]) == kDMIconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
+		if ((_vm->_objectMan->getIconIndex(champ->_slots[kDMSlotActionHand]) == kDMIconIndiceWeaponVorpalBlade) || (actionIndex == kDMActionDisrupt)) {
 			setFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
 		}
 		_actionDamage = _vm->_groupMan->getMeleeActionDamage(champ, champIndex, (Group *)_vm->_dungeonMan->getThingData(_actionTargetGroupThing), _vm->ordinalToIndex(targetCreatureOrdinal), targetMapX, targetMapY, actionHitProbability, actionDamageFactor, skillIndex);
@@ -1507,23 +1509,23 @@ bool MenuMan::isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, in
 	int16 frightAmount = 0;
 
 	switch (actionIndex) {
-	case k8_ChampionActionWarCry:
+	case kDMActionWarCry:
 		frightAmount = 3;
 		experience = 12; /* War Cry gives experience in priest skill k14_ChampionSkillInfluence below. The War Cry action also has an experience gain of 7 defined in G0497_auc_Graphic560_ActionExperienceGain in the same skill (versions 1.1 and below) or in the fighter skill k7_ChampionSkillParry (versions 1.2 and above). In versions 1.2 and above, this is the only action that gives experience in two skills */
 		break;
-	case k37_ChampionActionCalm:
+	case kDMActionCalm:
 		frightAmount = 7;
 		experience = 35;
 		break;
-	case k41_ChampionActionBrandish:
+	case kDMActionBrandish:
 		frightAmount = 6;
 		experience = 30;
 		break;
-	case k4_ChampionActionBlowHorn:
+	case kDMActionBlowHorn:
 		frightAmount = 6;
 		experience = 20;
 		break;
-	case k22_ChampionActionConfuse:
+	case kDMActionConfuse:
 		frightAmount = 12;
 		experience = 45;
 		break;
@@ -1658,7 +1660,7 @@ void MenuMan::setActionList(ActionSet *actionSet) {
 	for (uint16 idx = 1; idx < 3; idx++) {
 		uint16 actionIndex = actionSet->_actionIndices[idx];
 
-		if (actionIndex == k255_ChampionActionNone)
+		if (actionIndex == kDMActionNone)
 			continue;
 
 		uint16 minimumSkillLevel = actionSet->_actionProperties[idx - 1];
@@ -1675,7 +1677,7 @@ void MenuMan::setActionList(ActionSet *actionSet) {
 	_actionCount = nextAvailableActionListIndex;
 
 	for (uint16 idx = nextAvailableActionListIndex; idx < 3; idx++)
-		_actionList._actionIndices[idx] = k255_ChampionActionNone;
+		_actionList._actionIndices[idx] = kDMActionNone;
 }
 
 int16 MenuMan::getActionObjectChargeCount() {
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 8787e50..815442a 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -331,7 +331,7 @@ bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destM
 									if (curChampion->_currHealth)
 										_vm->_championMan->decrementStamina(championIdx, ((curChampion->_load * 25) / _vm->_championMan->getMaximumLoad(curChampion)) + 1);
 								}
-							} else if (_vm->_championMan->getDamagedChampionCount(20, kDMWoundLegs | kDMWoundFeet, k2_attackType_SELF))
+							} else if (_vm->_championMan->getDamagedChampionCount(20, kDMWoundLegs | kDMWoundFeet, kDMAttackTypeSelf))
 								_vm->_sound->requestPlay(k06_soundSCREAM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
 						}
 						_useRopeToClimbDownPit = false;
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index cbf0085..c9682a1 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -232,7 +232,7 @@ T0217044:
 
 uint16 ProjExpl::getProjectileImpactAttack(Projectile *projectile, Thing thing) {
 	_projectilePoisonAttack = 0;
-	_projectileAttackType = k3_attackType_BLUNT;
+	_projectileAttackType = kDMAttackTypeBlunt;
 
 	uint16 kineticEnergy = projectile->_kineticEnergy;
 	ThingType thingType = thing.getType();
@@ -241,7 +241,7 @@ uint16 ProjExpl::getProjectileImpactAttack(Projectile *projectile, Thing thing)
 		if (thingType == k5_WeaponThingType) {
 			WeaponInfo *weaponInfo = _vm->_dungeonMan->getWeaponInfo(thing);
 			attack = weaponInfo->_kineticEnergy;
-			_projectileAttackType = k3_attackType_BLUNT;
+			_projectileAttackType = kDMAttackTypeBlunt;
 		} else
 			attack = _vm->getRandomNumber(4);
 
@@ -252,17 +252,17 @@ uint16 ProjExpl::getProjectileImpactAttack(Projectile *projectile, Thing thing)
 		attack += _vm->getRandomNumber(32);
 	} else {
 		if (thing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) {
-			_projectileAttackType = k5_attackType_MAGIC;
+			_projectileAttackType = kDMAttackTypeMagic;
 			if (thing == Thing::_explPoisonBolt) {
 				_projectilePoisonAttack = kineticEnergy;
 				return 1;
 			}
 			return 0;
 		}
-		_projectileAttackType = k1_attackType_FIRE;
+		_projectileAttackType = kDMAttackTypeFire;
 		attack = _vm->getRandomNumber(16) + _vm->getRandomNumber(16) + 10;
 		if (thing == Thing::_explLightningBolt) {
-			_projectileAttackType = k7_attackType_LIGHTNING;
+			_projectileAttackType = kDMAttackTypeLightning;
 			attack *= 5;
 		}
 	}
@@ -326,7 +326,7 @@ void ProjExpl::createExplosion(Thing explThing, uint16 attack, uint16 mapXCombo,
 		if ((explThing == Thing::_explFireBall) || (attack >>= 1)) {
 			if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (projectileMapX == _vm->_dungeonMan->_partyMapX) && (projectileMapY == _vm->_dungeonMan->_partyMapY)) {
 				int16 wounds = kDMWoundReadHand | kDMWoundActionHand | kDMWoundHead | kDMWoundTorso | kDMWoundLegs | kDMWoundFeet;
-				_vm->_championMan->getDamagedChampionCount(attack, wounds, k1_attackType_FIRE);
+				_vm->_championMan->getDamagedChampionCount(attack, wounds, kDMAttackTypeFire);
 			} else {
 				unusedThing = _vm->_groupMan->groupGetThing(projectileMapX, projectileMapY);
 				if (unusedThing != Thing::_endOfList) {
@@ -536,7 +536,7 @@ void ProjExpl::processEvent25(TimelineEvent *event) {
 		break;
 	case 0xFF87:
 		if (explosionOnPartySquare)
-			_vm->_championMan->getDamagedChampionCount(attack, kDMWoundNone, k0_attackType_NORMAL);
+			_vm->_championMan->getDamagedChampionCount(attack, kDMWoundNone, kDMAttackTypeNormal);
 		else if ((groupThing != Thing::_endOfList)
 			&& (attack = _vm->_groupMan->groupGetResistanceAdjustedPoisonAttack(creatureType, attack))
 			&& (_vm->_groupMan->getDamageAllCreaturesOutcome(group, mapX, mapY, attack, true) != k2_outcomeKilledAllCreaturesInGroup)
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 0bbe400..8ec70f7 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -401,7 +401,7 @@ void Timeline::processEventDoorAnimation(TimelineEvent *event) {
 				// Original bug fixed - A closing horizontal door wounds champions to the head instead of to the hands. Missing parenthesis in the condition cause all doors to wound the head in addition to the torso
 				// See BUG0_78
 				int16 wounds = kDMWoundTorso | (verticalDoorFl ? kDMWoundHead : kDMWoundReadHand | kDMWoundActionHand);
-				if (_vm->_championMan->getDamagedChampionCount(5, wounds, k2_attackType_SELF))
+				if (_vm->_championMan->getDamagedChampionCount(5, wounds, kDMAttackTypeSelf))
 					_vm->_sound->requestPlay(k18_soundPARTY_DAMAGED, mapX, mapY, k1_soundModePlayIfPrioritized);
 			}
 			event->_mapTime++;
@@ -816,11 +816,11 @@ void Timeline::processEventEnableChampionAction(uint16 champIndex) {
 	Champion *curChampion = &_vm->_championMan->_champions[champIndex];
 	curChampion->_enableActionEventIndex = -1;
 	clearFlag(curChampion->_attributes, kDMAttributeDisableAction);
-	if (curChampion->_actionIndex != k255_ChampionActionNone) {
+	if (curChampion->_actionIndex != kDMActionNone) {
 		curChampion->_actionDefense -= _actionDefense[curChampion->_actionDefense];
 	}
 	if (curChampion->_currHealth) {
-		if ((curChampion->_actionIndex == k32_ChampionActionShoot) && (curChampion->_slots[kDMSlotReadyHand] == Thing::_none)) {
+		if ((curChampion->_actionIndex == kDMActionShoot) && (curChampion->_slots[kDMSlotReadyHand] == Thing::_none)) {
 			int16 slotIndex = kDMSlotQuiverLine1_1;
 			if (_vm->_championMan->isAmmunitionCompatibleWithWeapon(champIndex, kDMSlotActionHand, slotIndex))
 				_vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->getObjectRemovedFromSlot(champIndex, slotIndex), kDMSlotReadyHand);
@@ -835,7 +835,7 @@ void Timeline::processEventEnableChampionAction(uint16 champIndex) {
 		setFlag(curChampion->_attributes, kDMAttributeActionHand);
 		_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 	}
-	curChampion->_actionIndex = k255_ChampionActionNone;
+	curChampion->_actionIndex = kDMActionNone;
 }
 
 void Timeline::processEventMoveWeaponFromQuiverToSlot(uint16 champIndex, uint16 slotIndex) {


Commit: 4099814fbe6894931b7b393dc2f6ef5736297338
    https://github.com/scummvm/scummvm/commit/4099814fbe6894931b7b393dc2f6ef5736297338
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-09-10T14:53:10+02:00

Commit Message:
DM: Finish the renaming in champion.h

Changed paths:
    engines/dm/champion.cpp
    engines/dm/champion.h
    engines/dm/menus.cpp
    engines/dm/movesens.cpp



diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index ea48f85..6b89506 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -764,7 +764,7 @@ int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 a
 		for (int16 woundIndex = kDMSlotReadyHand; woundIndex <= kDMSlotFeet; woundIndex++) {
 			if (allowedWounds & (1 << woundIndex)) {
 				woundCount++;
-				defense += getWoundDefense(champIndex, woundIndex | ((attackType == kDMAttackTypeSharp) ? k0x8000_maskUseSharpDefense : k0x0000_maskDoNotUseSharpDefense));
+				defense += getWoundDefense(champIndex, woundIndex | ((attackType == kDMAttackTypeSharp) ? kDMMaskSharpDefense : kDMMaskNoSharpDefense));
 			}
 		}
 		if (woundCount)
@@ -843,9 +843,9 @@ int16 ChampionMan::getWoundDefense(int16 champIndex, uint16 woundIndex) {
 	static const byte woundDefenseFactor[6] = {5, 5, 4, 6, 3, 1}; // @ G0050_auc_Graphic562_WoundDefenseFactor
 
 	Champion *curChampion = &_champions[champIndex];
-	bool useSharpDefense = getFlag(woundIndex, k0x8000_maskUseSharpDefense);
+	bool useSharpDefense = getFlag(woundIndex, kDMMaskSharpDefense);
 	if (useSharpDefense)
-		clearFlag(woundIndex, k0x8000_maskUseSharpDefense);
+		clearFlag(woundIndex, kDMMaskSharpDefense);
 
 	uint16 armorShieldDefense = 0;
 	for (int16 slotIndex = kDMSlotReadyHand; slotIndex <= kDMSlotActionHand; slotIndex++) {
@@ -1164,9 +1164,9 @@ void ChampionMan::deleteScent(uint16 scentIndex) {
 void ChampionMan::addScentStrength(int16 mapX, int16 mapY, int32 cycleCount) {
 	int16 scentIndex = _party._scentCount;
 	if (scentIndex) {
-		bool mergeFl = getFlag(cycleCount, k0x8000_mergeCycles);
+		bool mergeFl = getFlag(cycleCount, kDMMaskMergeCycles);
 		if (mergeFl)
-			clearFlag(cycleCount, k0x8000_mergeCycles);
+			clearFlag(cycleCount, kDMMaskMergeCycles);
 
 		Scent newScent; /* BUG0_00 Useless code */
 		newScent.setMapX(mapX); /* BUG0_00 Useless code */
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index 013f118..2eb4d28 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -348,10 +348,6 @@ enum AttackType {
 	kDMAttackTypeLightning = 7 // @ C7_ATTACK_LIGHTNING
 };
 
-#define k0x0000_maskDoNotUseSharpDefense 0x0000 // @ MASK0x0000_DO_NOT_USE_SHARP_DEFENSE 
-#define k0x8000_maskUseSharpDefense 0x8000 // @ MASK0x8000_USE_SHARP_DEFENSE        
-#define k0x8000_mergeCycles 0x8000 // @ MASK0x8000_MERGE_CYCLES
-
 enum SpellCastResult {
 	kDMSpellCastFailure = 0, // @ C0_SPELL_CAST_FAILURE             
 	kDMSpellCastSuccess = 1, // @ C1_SPELL_CAST_SUCCESS             
@@ -365,25 +361,33 @@ enum SpellFailure {
 	kDMFailureNeedsMagicMapInHand = 11 // @ C11_FAILURE_NEEDS_MAGIC_MAP_IN_HAND 
 };
 
-#define k1_spellKindPotion 1 // @ C1_SPELL_KIND_POTION    
-#define k2_spellKindProjectile 2 // @ C2_SPELL_KIND_PROJECTILE
-#define k3_spellKindOther 3 // @ C3_SPELL_KIND_OTHER     
-#define k4_spellKindMagicMap 4 // @ C4_SPELL_KIND_MAGIC_MAP 
-
-#define k4_spellType_projectileOpenDoor 4 // @ C4_SPELL_TYPE_PROJECTILE_OPEN_DOOR
-#define k0_spellType_otherLight 0 // @ C0_SPELL_TYPE_OTHER_LIGHT         
-#define k1_spellType_otherDarkness 1 // @ C1_SPELL_TYPE_OTHER_DARKNESS      
-#define k2_spellType_otherThievesEye 2 // @ C2_SPELL_TYPE_OTHER_THIEVES_EYE   
-#define k3_spellType_otherInvisibility 3 // @ C3_SPELL_TYPE_OTHER_INVISIBILITY  
-#define k4_spellType_otherPartyShield 4 // @ C4_SPELL_TYPE_OTHER_PARTY_SHIELD  
-#define k5_spellType_otherMagicTorch 5 // @ C5_SPELL_TYPE_OTHER_MAGIC_TORCH   
-#define k6_spellType_otherFootprints 6 // @ C6_SPELL_TYPE_OTHER_FOOTPRINTS    
-#define k7_spellType_otherZokathra 7 // @ C7_SPELL_TYPE_OTHER_ZOKATHRA      
-#define k8_spellType_otherFireshield 8 // @ C8_SPELL_TYPE_OTHER_FIRESHIELD    
-#define k0_spellType_magicMap0 0 // @ C0_SPELL_TYPE_MAGIC_MAP           
-#define k1_spellType_magicMap1 1 // @ C1_SPELL_TYPE_MAGIC_MAP           
-#define k2_spellType_magicMap2 2 // @ C2_SPELL_TYPE_MAGIC_MAP           
-#define k3_spellType_magicMap3 3 // @ C3_SPELL_TYPE_MAGIC_MAP           
+enum SpellKind {
+	kDMSpellKindPotion = 1, // @ C1_SPELL_KIND_POTION    
+	kDMSpellKindProjectile = 2, // @ C2_SPELL_KIND_PROJECTILE
+	kDMSpellKindOther = 3, // @ C3_SPELL_KIND_OTHER     
+	kDMSpellKindMagicMap = 4 // @ C4_SPELL_KIND_MAGIC_MAP 
+};
+
+enum SpellType {
+	kDMSpellTypeProjectileOpenDoor = 4, // @ C4_SPELL_TYPE_PROJECTILE_OPEN_DOOR
+	kDMSpellTypeOtherLight = 0, // @ C0_SPELL_TYPE_OTHER_LIGHT         
+	kDMSpellTypeOtherDarkness = 1, // @ C1_SPELL_TYPE_OTHER_DARKNESS      
+	kDMSpellTypeOtherThievesEye = 2, // @ C2_SPELL_TYPE_OTHER_THIEVES_EYE   
+	kDMSpellTypeOtherInvisibility = 3, // @ C3_SPELL_TYPE_OTHER_INVISIBILITY  
+	kDMSpellTypeOtherPartyShield = 4, // @ C4_SPELL_TYPE_OTHER_PARTY_SHIELD  
+	kDMSpellTypeOtherMagicTorch = 5, // @ C5_SPELL_TYPE_OTHER_MAGIC_TORCH   
+	kDMSpellTypeOtherFootprints = 6, // @ C6_SPELL_TYPE_OTHER_FOOTPRINTS    
+	kDMSpellTypeOtherZokathra = 7, // @ C7_SPELL_TYPE_OTHER_ZOKATHRA      
+	kDMSpellTypeOtherFireshield = 8, // @ C8_SPELL_TYPE_OTHER_FIRESHIELD    
+	kDMSpellTypeMagicMap0 = 0, // @ C0_SPELL_TYPE_MAGIC_MAP           
+	kDMSpellTypeMagicMap1 = 1, // @ C1_SPELL_TYPE_MAGIC_MAP           
+	kDMSpellTypeMagicMap2 = 2, // @ C2_SPELL_TYPE_MAGIC_MAP           
+	kDMSpellTypeMagicMap3 = 3 // @ C3_SPELL_TYPE_MAGIC_MAP           
+};
+
+#define kDMMaskNoSharpDefense 0x0000 // @ MASK0x0000_DO_NOT_USE_SHARP_DEFENSE 
+#define kDMMaskSharpDefense 0x8000 // @ MASK0x8000_USE_SHARP_DEFENSE        
+#define kDMMaskMergeCycles 0x8000 // @ MASK0x8000_MERGE_CYCLES
 
 class Skill {
 public:
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 3454379..e3bc088 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -548,7 +548,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 		}
 	}
 	switch (curSpell->getKind()) {
-	case k1_spellKindPotion: {
+	case kDMSpellKindPotion: {
 		Thing newObject;
 		Potion *newPotion = getEmptyFlaskInHand(curChampion, &newObject);
 		if (!newPotion) {
@@ -566,24 +566,24 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 		}
 		}
 		break;
-	case k2_spellKindProjectile:
+	case kDMSpellKindProjectile:
 		if (curChampion->_dir != _vm->_dungeonMan->_partyDir) {
 			curChampion->_dir = _vm->_dungeonMan->_partyDir;
 			setFlag(curChampion->_attributes, kDMAttributeIcon);
 			_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
 		}
-		if (curSpell->getType() == k4_spellType_projectileOpenDoor)
+		if (curSpell->getType() == kDMSpellTypeProjectileOpenDoor)
 			skillLevel <<= 1;
 
 		_vm->_championMan->isProjectileSpellCast(champIndex, Thing(curSpell->getType() + Thing::_firstExplosion.toUint16()), getBoundedValue(21, (powerSymbolOrdinal + 2) * (4 + (skillLevel << 1)), 255), 0);
 		break;
-	case k3_spellKindOther: {
+	case kDMSpellKindOther: {
 		TimelineEvent newEvent;
 		newEvent._priority = 0;
 		uint16 spellPower = (powerSymbolOrdinal + 1) << 2;
 		uint16 ticks;
 		switch (curSpell->getType()) {
-		case k0_spellType_otherLight: {
+		case kDMSpellTypeOtherLight: {
 			ticks = 10000 + ((spellPower - 8) << 9);
 			uint16 lightPower = (spellPower >> 1);
 			lightPower--;
@@ -591,7 +591,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 			createEvent70_light(-lightPower, ticks);
 			}
 			break;
-		case k5_spellType_otherMagicTorch: {
+		case kDMSpellTypeOtherMagicTorch: {
 			ticks = 2000 + ((spellPower - 3) << 7);
 			uint16 lightPower = (spellPower >> 2);
 			lightPower++;
@@ -599,13 +599,13 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 			createEvent70_light(-lightPower, ticks);
 			}
 			break;
-		case k1_spellType_otherDarkness: {
+		case kDMSpellTypeOtherDarkness: {
 			uint16 lightPower = (spellPower >> 2);
 			_vm->_championMan->_party._magicalLightAmount -= _vm->_championMan->_lightPowerToLightAmount[lightPower];
 			createEvent70_light(lightPower, 98);
 			}
 			break;
-		case k2_spellType_otherThievesEye: {
+		case kDMSpellTypeOtherThievesEye: {
 			newEvent._type = k73_TMEventTypeThievesEye;
 			_vm->_championMan->_party._event73Count_ThievesEye++;
 			spellPower = (spellPower >> 1);
@@ -614,7 +614,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 			_vm->_timeline->addEventGetEventIndex(&newEvent);
 			}
 			break;
-		case k3_spellType_otherInvisibility: {
+		case kDMSpellTypeOtherInvisibility: {
 			newEvent._type = k71_TMEventTypeInvisibility;
 			_vm->_championMan->_party._event71Count_Invisibility++;
 			uint16 spellTicks = spellPower;
@@ -622,7 +622,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 			_vm->_timeline->addEventGetEventIndex(&newEvent);
 			}
 			break;
-		case k4_spellType_otherPartyShield: {
+		case kDMSpellTypeOtherPartyShield: {
 			newEvent._type = k74_TMEventTypePartyShield;
 			newEvent._B._defense = spellPower;
 			if (_vm->_championMan->_party._shieldDefense > 50)
@@ -635,7 +635,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 			_vm->_timeline->addEventGetEventIndex(&newEvent);
 			}
 			break;
-		case k6_spellType_otherFootprints: {
+		case kDMSpellTypeOtherFootprints: {
 			newEvent._type = k79_TMEventTypeFootprints;
 			_vm->_championMan->_party._event79Count_Footprints++;
 			_vm->_championMan->_party._firstScentIndex = _vm->_championMan->_party._scentCount;
@@ -649,7 +649,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 			_vm->_timeline->addEventGetEventIndex(&newEvent);
 			}
 			break;
-		case k7_spellType_otherZokathra: {
+		case kDMSpellTypeOtherZokathra: {
 			Thing unusedObject = _vm->_dungeonMan->getUnusedThing(k10_JunkThingType);
 			if (unusedObject == Thing::_none)
 				break;
@@ -672,7 +672,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
 
 			}
 			break;
-		case k8_spellType_otherFireshield:
+		case kDMSpellTypeOtherFireshield:
 			isPartySpellOrFireShieldSuccessful(curChampion, false, (spellPower * spellPower) + 100, false);
 			break;
 		default:
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 815442a..bca61fe 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -402,7 +402,7 @@ bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destM
 				_vm->_championMan->_party._scents[scentIndex].setMapY(destMapY);
 				_vm->_championMan->_party._scents[scentIndex].setMapIndex(mapIndexDestination);
 				_vm->_championMan->_party._scentStrengths[scentIndex] = 0;
-				_vm->_championMan->addScentStrength(destMapX, destMapY, k0x8000_mergeCycles | 24);
+				_vm->_championMan->addScentStrength(destMapX, destMapY, kDMMaskMergeCycles | 24);
 				destinationSquareData = oldDestinationSquare;
 			}
 			if (mapIndexDestination != mapIndexSource)


Commit: a46cc8597cdc2ab2aca146ed79c0fcf3f4df5617
    https://github.com/scummvm/scummvm/commit/a46cc8597cdc2ab2aca146ed79c0fcf3f4df5617
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-09-10T16:55:13+02:00

Commit Message:
Merge pull request #817 from WinterGrascph/dm

DM: New Engine

Changed paths:
  A engines/dm/.gitattributes
  A engines/dm/TODOs/methodtree.txt
  A engines/dm/TODOs/todo.txt
  A engines/dm/champion.cpp
  A engines/dm/champion.h
  A engines/dm/configure.engine
  A engines/dm/console.cpp
  A engines/dm/console.h
  A engines/dm/detection.cpp
  A engines/dm/dialog.cpp
  A engines/dm/dialog.h
  A engines/dm/dm.cpp
  A engines/dm/dm.h
  A engines/dm/dmglobals.cpp
  A engines/dm/dungeonman.cpp
  A engines/dm/dungeonman.h
  A engines/dm/eventman.cpp
  A engines/dm/eventman.h
  A engines/dm/gfx.cpp
  A engines/dm/gfx.h
  A engines/dm/group.cpp
  A engines/dm/group.h
  A engines/dm/inventory.cpp
  A engines/dm/inventory.h
  A engines/dm/loadsave.cpp
  A engines/dm/loadsave.h
  A engines/dm/lzw.cpp
  A engines/dm/lzw.h
  A engines/dm/menus.cpp
  A engines/dm/menus.h
  A engines/dm/module.mk
  A engines/dm/movesens.cpp
  A engines/dm/movesens.h
  A engines/dm/objectman.cpp
  A engines/dm/objectman.h
  A engines/dm/projexpl.cpp
  A engines/dm/projexpl.h
  A engines/dm/sounds.cpp
  A engines/dm/sounds.h
  A engines/dm/text.cpp
  A engines/dm/text.h
  A engines/dm/timeline.cpp
  A engines/dm/timeline.h








More information about the Scummvm-git-logs mailing list